diff --git a/packages/integration-sdk-cli/package.json b/packages/integration-sdk-cli/package.json index d1f67580..f8b539fc 100644 --- a/packages/integration-sdk-cli/package.json +++ b/packages/integration-sdk-cli/package.json @@ -17,6 +17,7 @@ "access": "public" }, "scripts": { + "test": "jest", "prebuild:dist": "rm -rf dist && mkdir dist", "build:dist": "tsc -p tsconfig.dist.json --declaration && npm run copy-files", "prepack": "npm run build:dist", diff --git a/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.test.ts b/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.test.ts index 316d8dc4..f0aea8ef 100644 --- a/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.test.ts +++ b/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.test.ts @@ -128,6 +128,62 @@ describe('#generateIntegrationGraphSchema', () => { }); }); + test('should dedup entity metadata with schema', () => { + const steps: IntegrationStep[] = [ + getMockIntegrationStep({ + entities: [ + { + _class: 'User', + _type: 'my_user', + resourceName: 'The user', + schema: { + $id: 'id', + }, + }, + { + _class: 'User', + _type: 'my_user', + resourceName: 'The user', + schema: { + $id: 'id', + }, + }, + ], + relationships: [], + mappedRelationships: [], + }), + getMockIntegrationStep({ + entities: [ + { + _class: 'User', + _type: 'my_user', + resourceName: 'The user', + schema: { + $id: 'id', + }, + }, + ], + relationships: [], + mappedRelationships: [], + }), + ]; + + expect(generateIntegrationGraphSchema(steps)).toEqual({ + entities: [ + { + _class: 'User', + _type: 'my_user', + resourceName: 'The user', + schema: { + $id: 'id', + }, + }, + ], + relationships: [], + mappedRelationships: [], + }); + }); + test('should dedup relationship metadata', () => { const steps: IntegrationStep[] = [ getMockIntegrationStep({ diff --git a/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.ts b/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.ts index 52514b96..c9600a9e 100644 --- a/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.ts +++ b/packages/integration-sdk-cli/src/commands/generate-integration-graph-schema.ts @@ -1,4 +1,5 @@ import { + GraphObjectSchema, IntegrationInstanceConfig, IntegrationStepExecutionContext, Step, @@ -63,6 +64,7 @@ type IntegrationGraphSchemaEntityMetadata = { resourceName: string; _class: string | string[]; _type: string; + schema?: GraphObjectSchema; }; type IntegrationGraphSchemaRelationshipMetadata = { @@ -210,6 +212,7 @@ function toIntegrationGraphSchemaEntityMetadata( resourceName: stepEntityMetadata.resourceName, _class: stepEntityMetadata._class, _type: stepEntityMetadata._type, + schema: stepEntityMetadata.schema, }; }