Add classification and type to types
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { DecodedBqrsChunk } from "../common/bqrs-cli-types";
|
||||
import { Call, ExternalApiUsage } from "./external-api-usage";
|
||||
import {
|
||||
Call,
|
||||
CallClassification,
|
||||
ExternalApiUsage,
|
||||
} from "./external-api-usage";
|
||||
import { ModeledMethodType } from "./modeled-method";
|
||||
|
||||
export function decodeBqrsToExternalApiUsages(
|
||||
chunk: DecodedBqrsChunk,
|
||||
@@ -11,6 +16,8 @@ export function decodeBqrsToExternalApiUsages(
|
||||
const signature = tuple[1] as string;
|
||||
const supported = (tuple[2] as string) === "true";
|
||||
const library = tuple[4] as string;
|
||||
const type = tuple[6] as ModeledMethodType;
|
||||
const classification = tuple[8] as CallClassification;
|
||||
|
||||
const [packageWithType, methodDeclaration] = signature.split("#");
|
||||
|
||||
@@ -39,12 +46,16 @@ export function decodeBqrsToExternalApiUsages(
|
||||
methodName,
|
||||
methodParameters,
|
||||
supported,
|
||||
supportedType: type,
|
||||
usages: [],
|
||||
});
|
||||
}
|
||||
|
||||
const method = methodsByApiName.get(signature)!;
|
||||
method.usages.push(usage);
|
||||
method.usages.push({
|
||||
...usage,
|
||||
classification,
|
||||
});
|
||||
});
|
||||
|
||||
return Array.from(methodsByApiName.values());
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
import { ResolvableLocationValue } from "../common/bqrs-cli-types";
|
||||
import { ModeledMethodType } from "./modeled-method";
|
||||
|
||||
export type Call = {
|
||||
label: string;
|
||||
url: ResolvableLocationValue;
|
||||
};
|
||||
|
||||
export enum CallClassification {
|
||||
Unknown = "unknown",
|
||||
Source = "source",
|
||||
Test = "test",
|
||||
Generated = "generated",
|
||||
}
|
||||
|
||||
export type Usage = Call & {
|
||||
classification: CallClassification;
|
||||
};
|
||||
|
||||
export type ExternalApiUsage = {
|
||||
/**
|
||||
* Contains the name of the library containing the method declaration, e.g. `sql2o-1.6.0.jar` or `System.Runtime.dll`
|
||||
@@ -30,5 +42,6 @@ export type ExternalApiUsage = {
|
||||
* If so, there is no need for the user to model it themselves.
|
||||
*/
|
||||
supported: boolean;
|
||||
usages: Call[];
|
||||
supportedType: ModeledMethodType;
|
||||
usages: Usage[];
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
|
||||
import { Mode } from "../../data-extensions-editor/shared/mode";
|
||||
import { DataExtensionsEditor as DataExtensionsEditorComponent } from "../../view/data-extensions-editor/DataExtensionsEditor";
|
||||
import { CallClassification } from "../../data-extensions-editor/external-api-usage";
|
||||
|
||||
export default {
|
||||
title: "Data Extensions Editor/Data Extensions Editor",
|
||||
@@ -39,6 +40,7 @@ DataExtensionsEditor.args = {
|
||||
methodName: "createQuery",
|
||||
methodParameters: "(String)",
|
||||
supported: true,
|
||||
supportedType: "summary",
|
||||
usages: Array(10).fill({
|
||||
label: "createQuery(...)",
|
||||
url: {
|
||||
@@ -48,6 +50,7 @@ DataExtensionsEditor.args = {
|
||||
endLine: 15,
|
||||
endColumn: 56,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
}),
|
||||
},
|
||||
{
|
||||
@@ -58,6 +61,7 @@ DataExtensionsEditor.args = {
|
||||
methodName: "executeScalar",
|
||||
methodParameters: "(Class)",
|
||||
supported: true,
|
||||
supportedType: "neutral",
|
||||
usages: Array(2).fill({
|
||||
label: "executeScalar(...)",
|
||||
url: {
|
||||
@@ -67,6 +71,7 @@ DataExtensionsEditor.args = {
|
||||
endLine: 15,
|
||||
endColumn: 85,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
}),
|
||||
},
|
||||
{
|
||||
@@ -77,6 +82,7 @@ DataExtensionsEditor.args = {
|
||||
methodName: "open",
|
||||
methodParameters: "()",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: Array(28).fill({
|
||||
label: "open(...)",
|
||||
url: {
|
||||
@@ -86,6 +92,7 @@ DataExtensionsEditor.args = {
|
||||
endLine: 14,
|
||||
endColumn: 35,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
}),
|
||||
},
|
||||
{
|
||||
@@ -96,6 +103,7 @@ DataExtensionsEditor.args = {
|
||||
methodName: "println",
|
||||
methodParameters: "(String)",
|
||||
supported: true,
|
||||
supportedType: "summary",
|
||||
usages: [
|
||||
{
|
||||
label: "println(...)",
|
||||
@@ -106,6 +114,7 @@ DataExtensionsEditor.args = {
|
||||
endLine: 29,
|
||||
endColumn: 49,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -118,6 +127,7 @@ DataExtensionsEditor.args = {
|
||||
methodName: "run",
|
||||
methodParameters: "(Class,String[])",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: Array(7).fill({
|
||||
label: "run(...)",
|
||||
url: {
|
||||
@@ -127,6 +137,7 @@ DataExtensionsEditor.args = {
|
||||
endLine: 9,
|
||||
endColumn: 66,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
}),
|
||||
},
|
||||
{
|
||||
@@ -137,6 +148,7 @@ DataExtensionsEditor.args = {
|
||||
methodName: "Sql2o",
|
||||
methodParameters: "(String,String,String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: Array(106).fill({
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
@@ -145,6 +157,7 @@ DataExtensionsEditor.args = {
|
||||
startColumn: 33,
|
||||
endLine: 10,
|
||||
endColumn: 88,
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -156,6 +169,7 @@ DataExtensionsEditor.args = {
|
||||
methodName: "Sql2o",
|
||||
methodParameters: "(String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: Array(4).fill({
|
||||
label: "new Sql2o(...)",
|
||||
url: {
|
||||
@@ -165,6 +179,7 @@ DataExtensionsEditor.args = {
|
||||
endLine: 23,
|
||||
endColumn: 36,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
}),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as React from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
|
||||
import { MethodRow as MethodRowComponent } from "../../view/data-extensions-editor/MethodRow";
|
||||
import { CallClassification } from "../../data-extensions-editor/external-api-usage";
|
||||
|
||||
export default {
|
||||
title: "Data Extensions Editor/Method Row",
|
||||
@@ -23,6 +24,7 @@ MethodRow.args = {
|
||||
methodName: "open",
|
||||
methodParameters: "()",
|
||||
supported: true,
|
||||
supportedType: "summary",
|
||||
usages: [
|
||||
{
|
||||
label: "open(...)",
|
||||
@@ -33,6 +35,7 @@ MethodRow.args = {
|
||||
endLine: 14,
|
||||
endColumn: 35,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "open(...)",
|
||||
@@ -43,6 +46,7 @@ MethodRow.args = {
|
||||
endLine: 25,
|
||||
endColumn: 35,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -3,7 +3,10 @@ import {
|
||||
createAutoModelRequest,
|
||||
parsePredictedClassifications,
|
||||
} from "../../../src/data-extensions-editor/auto-model";
|
||||
import { ExternalApiUsage } from "../../../src/data-extensions-editor/external-api-usage";
|
||||
import {
|
||||
CallClassification,
|
||||
ExternalApiUsage,
|
||||
} from "../../../src/data-extensions-editor/external-api-usage";
|
||||
import { ModeledMethod } from "../../../src/data-extensions-editor/modeled-method";
|
||||
import {
|
||||
ClassificationType,
|
||||
@@ -22,6 +25,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "run",
|
||||
methodParameters: "(Class,String[])",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "run(...)",
|
||||
@@ -32,6 +36,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 9,
|
||||
endColumn: 66,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -43,6 +48,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "createQuery",
|
||||
methodParameters: "(String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -53,6 +59,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 15,
|
||||
endColumn: 56,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -63,6 +70,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 26,
|
||||
endColumn: 39,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -74,6 +82,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "executeScalar",
|
||||
methodParameters: "(Class)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -84,6 +93,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 15,
|
||||
endColumn: 85,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -94,6 +104,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 26,
|
||||
endColumn: 68,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -105,6 +116,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "open",
|
||||
methodParameters: "()",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "open(...)",
|
||||
@@ -115,6 +127,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 14,
|
||||
endColumn: 35,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "open(...)",
|
||||
@@ -125,6 +138,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 25,
|
||||
endColumn: 35,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -136,6 +150,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "println",
|
||||
methodParameters: "(String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "println(...)",
|
||||
@@ -146,6 +161,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 29,
|
||||
endColumn: 49,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -157,6 +173,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "Sql2o",
|
||||
methodParameters: "(String,String,String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
@@ -167,6 +184,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 10,
|
||||
endColumn: 88,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -178,6 +196,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "Sql2o",
|
||||
methodParameters: "(String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
@@ -188,6 +207,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 23,
|
||||
endColumn: 36,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -199,6 +219,7 @@ describe("createAutoModelRequest", () => {
|
||||
methodName: "test",
|
||||
methodParameters: "()",
|
||||
supported: true,
|
||||
supportedType: "neutral",
|
||||
usages: [
|
||||
{
|
||||
label: "abc.test(...)",
|
||||
@@ -209,6 +230,7 @@ describe("createAutoModelRequest", () => {
|
||||
endLine: 23,
|
||||
endColumn: 36,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
createFilenameForLibrary,
|
||||
loadDataExtensionYaml,
|
||||
} from "../../../src/data-extensions-editor/yaml";
|
||||
import { CallClassification } from "../../../src/data-extensions-editor/external-api-usage";
|
||||
|
||||
describe("createDataExtensionYaml", () => {
|
||||
it("creates the correct YAML file", () => {
|
||||
@@ -18,6 +19,7 @@ describe("createDataExtensionYaml", () => {
|
||||
methodName: "createQuery",
|
||||
methodParameters: "(String)",
|
||||
supported: true,
|
||||
supportedType: "sink",
|
||||
usages: [
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -28,6 +30,7 @@ describe("createDataExtensionYaml", () => {
|
||||
endLine: 15,
|
||||
endColumn: 56,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -38,6 +41,7 @@ describe("createDataExtensionYaml", () => {
|
||||
endLine: 26,
|
||||
endColumn: 39,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -58,6 +62,7 @@ describe("createDataExtensionYaml", () => {
|
||||
methodName: "executeScalar",
|
||||
methodParameters: "(Class)",
|
||||
supported: true,
|
||||
supportedType: "neutral",
|
||||
usages: [
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -68,6 +73,7 @@ describe("createDataExtensionYaml", () => {
|
||||
endLine: 15,
|
||||
endColumn: 85,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -78,6 +84,7 @@ describe("createDataExtensionYaml", () => {
|
||||
endLine: 26,
|
||||
endColumn: 68,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -148,6 +155,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
methodName: "createQuery",
|
||||
methodParameters: "(String)",
|
||||
supported: true,
|
||||
supportedType: "sink",
|
||||
usages: [
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -158,6 +166,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
endLine: 15,
|
||||
endColumn: 56,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -168,6 +177,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
endLine: 26,
|
||||
endColumn: 39,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -179,6 +189,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
methodName: "executeScalar",
|
||||
methodParameters: "(Class)",
|
||||
supported: true,
|
||||
supportedType: "neutral",
|
||||
usages: [
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -189,6 +200,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
endLine: 15,
|
||||
endColumn: 85,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -199,6 +211,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
endLine: 26,
|
||||
endColumn: 68,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -210,6 +223,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
methodName: "Sql2o",
|
||||
methodParameters: "(String,String,String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
@@ -220,6 +234,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
endLine: 10,
|
||||
endColumn: 88,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -232,6 +247,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
methodName: "run",
|
||||
methodParameters: "(Class,String[])",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "run(...)",
|
||||
@@ -242,6 +258,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
endLine: 9,
|
||||
endColumn: 66,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -253,6 +270,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
methodName: "println",
|
||||
methodParameters: "(String)",
|
||||
supported: true,
|
||||
supportedType: "summary",
|
||||
usages: [
|
||||
{
|
||||
label: "println(...)",
|
||||
@@ -263,6 +281,7 @@ describe("createDataExtensionYamlsForApplicationMode", () => {
|
||||
endLine: 29,
|
||||
endColumn: 49,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -356,6 +375,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
methodName: "createQuery",
|
||||
methodParameters: "(String)",
|
||||
supported: true,
|
||||
supportedType: "sink",
|
||||
usages: [
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -366,6 +386,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
endLine: 15,
|
||||
endColumn: 56,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "createQuery(...)",
|
||||
@@ -376,6 +397,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
endLine: 26,
|
||||
endColumn: 39,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -387,6 +409,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
methodName: "executeScalar",
|
||||
methodParameters: "(Class)",
|
||||
supported: true,
|
||||
supportedType: "neutral",
|
||||
usages: [
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -397,6 +420,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
endLine: 15,
|
||||
endColumn: 85,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
{
|
||||
label: "executeScalar(...)",
|
||||
@@ -407,6 +431,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
endLine: 26,
|
||||
endColumn: 68,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -418,6 +443,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
methodName: "Sql2o",
|
||||
methodParameters: "(String,String,String)",
|
||||
supported: false,
|
||||
supportedType: "none",
|
||||
usages: [
|
||||
{
|
||||
label: "new Sql2o(...)",
|
||||
@@ -428,6 +454,7 @@ describe("createDataExtensionYamlsForFrameworkMode", () => {
|
||||
endLine: 10,
|
||||
endColumn: 88,
|
||||
},
|
||||
classification: CallClassification.Source,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user