Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APP-15158] - Export entity schema to graph schema #1081

Merged
merged 3 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to

# Unreleased

- integration-sdk-cli: Export entity schema to graph schema
- integration-sdk-core: Add createIntegrationHelpers

# 12.7.1 - 2024-05-14
Expand Down
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