Skip to content

Commit

Permalink
Export entity schema to graph schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Geovanni Pacheco committed May 16, 2024
1 parent 21f970d commit f732d93
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/integration-sdk-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,62 @@ describe('#generateIntegrationGraphSchema', () => {
});
});

test('should dedup entity metadata with schema', () => {
const steps: IntegrationStep<IntegrationInstanceConfig>[] = [
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<IntegrationInstanceConfig>[] = [
getMockIntegrationStep({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
GraphObjectSchema,
IntegrationInstanceConfig,
IntegrationStepExecutionContext,
Step,
Expand Down Expand Up @@ -63,6 +64,7 @@ type IntegrationGraphSchemaEntityMetadata = {
resourceName: string;
_class: string | string[];
_type: string;
schema?: GraphObjectSchema;
};

type IntegrationGraphSchemaRelationshipMetadata = {
Expand Down Expand Up @@ -210,6 +212,7 @@ function toIntegrationGraphSchemaEntityMetadata(
resourceName: stepEntityMetadata.resourceName,
_class: stepEntityMetadata._class,
_type: stepEntityMetadata._type,
schema: stepEntityMetadata.schema,
};
}

Expand Down

0 comments on commit f732d93

Please sign in to comment.