@aws-amplify/graphql-api-construct 1.4.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.jsii +384 -253
- package/API.md +16 -4
- package/CHANGELOG.md +12 -0
- package/lib/amplify-dynamodb-table-wrapper.js +1 -1
- package/lib/amplify-graphql-api.d.ts +1 -1
- package/lib/amplify-graphql-api.js +16 -5
- package/lib/amplify-graphql-definition.d.ts +4 -3
- package/lib/amplify-graphql-definition.js +8 -16
- package/lib/index.d.ts +3 -1
- package/lib/index.js +19 -2
- package/lib/internal/data-source-config.d.ts +21 -2
- package/lib/internal/data-source-config.js +72 -33
- package/lib/internal/model-type-name.d.ts +2 -2
- package/lib/internal/model-type-name.js +4 -4
- package/lib/model-datasource-strategy.d.ts +116 -0
- package/lib/model-datasource-strategy.js +10 -0
- package/lib/sql-model-datasource-strategy.d.ts +1 -1
- package/lib/sql-model-datasource-strategy.js +5 -1
- package/lib/types.d.ts +16 -124
- package/lib/types.js +1 -1
- package/node_modules/@aws-amplify/graphql-auth-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-auth-transformer/package.json +10 -10
- package/node_modules/@aws-amplify/graphql-default-value-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-default-value-transformer/package.json +7 -7
- package/node_modules/@aws-amplify/graphql-function-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-function-transformer/package.json +6 -6
- package/node_modules/@aws-amplify/graphql-http-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-http-transformer/package.json +6 -6
- package/node_modules/@aws-amplify/graphql-index-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-index-transformer/package.json +7 -7
- package/node_modules/@aws-amplify/graphql-maps-to-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-maps-to-transformer/lib/assets/mapping-lambda.zip +0 -0
- package/node_modules/@aws-amplify/graphql-maps-to-transformer/package.json +10 -10
- package/node_modules/@aws-amplify/graphql-model-transformer/API.md +16 -0
- package/node_modules/@aws-amplify/graphql-model-transformer/CHANGELOG.md +12 -0
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/index.d.ts +1 -0
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/index.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/index.js +3 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/index.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-lambda.zip +0 -0
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-notification-lambda.zip +0 -0
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/rds-patching-lambda.zip +0 -0
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/resolver.d.ts +4 -2
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/resolver.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/resolver.js +30 -86
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/resolver.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/rds-model-resource-generator.d.ts +2 -3
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/rds-model-resource-generator.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/rds-model-resource-generator.js +36 -18
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resources/rds-model-resource-generator.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/package.json +6 -6
- package/node_modules/@aws-amplify/graphql-predictions-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-predictions-transformer/lib/predictionsLambdaFunction.zip +0 -0
- package/node_modules/@aws-amplify/graphql-predictions-transformer/package.json +6 -6
- package/node_modules/@aws-amplify/graphql-relational-transformer/CHANGELOG.md +10 -0
- package/node_modules/@aws-amplify/graphql-relational-transformer/package.json +8 -8
- package/node_modules/@aws-amplify/graphql-searchable-transformer/CHANGELOG.md +8 -0
- package/node_modules/@aws-amplify/graphql-searchable-transformer/lib/streaming-lambda.zip +0 -0
- package/node_modules/@aws-amplify/graphql-searchable-transformer/package.json +7 -7
- package/node_modules/@aws-amplify/graphql-sql-transformer/CHANGELOG.md +10 -0
- package/node_modules/@aws-amplify/graphql-sql-transformer/lib/graphql-sql-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-sql-transformer/lib/graphql-sql-transformer.js +15 -1
- package/node_modules/@aws-amplify/graphql-sql-transformer/lib/graphql-sql-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-sql-transformer/package.json +7 -7
- package/node_modules/@aws-amplify/graphql-transformer/API.md +3 -1
- package/node_modules/@aws-amplify/graphql-transformer/CHANGELOG.md +10 -0
- package/node_modules/@aws-amplify/graphql-transformer/lib/graphql-transformer.d.ts +2 -1
- package/node_modules/@aws-amplify/graphql-transformer/lib/graphql-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer/lib/graphql-transformer.js +2 -1
- package/node_modules/@aws-amplify/graphql-transformer/lib/graphql-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer/package.json +15 -15
- package/node_modules/@aws-amplify/graphql-transformer/src/graphql-transformer.ts +4 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/API.md +35 -5
- package/node_modules/@aws-amplify/graphql-transformer-core/CHANGELOG.md +12 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.d.ts +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.js +19 -13
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/transform.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/transform.js +20 -2
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/transform.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/types.d.ts +2 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/types.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/index.d.ts +24 -6
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/index.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/index.js +16 -14
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/index.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/stack-manager.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/stack-manager.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/graphql-utils.d.ts +14 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/graphql-utils.d.ts.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/graphql-utils.js +23 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/graphql-utils.js.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.d.ts +2 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.js +16 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/index.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/model-datasource-strategy-utils.d.ts +11 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/model-datasource-strategy-utils.d.ts.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/model-datasource-strategy-utils.js +84 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/model-datasource-strategy-utils.js.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/package.json +4 -4
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/API.md +89 -5
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/CHANGELOG.md +6 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/graphql-api-provider.d.ts +0 -17
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/graphql-api-provider.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/graphql-api-provider.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/index.d.ts +2 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/index.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/index.js +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/index.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/index.d.ts +2 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/index.d.ts.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/index.js +18 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/index.js.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/types.d.ts +55 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/types.d.ts.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/types.js +3 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/types.js.map +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transform-host-provider.d.ts +2 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transform-host-provider.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/index.d.ts +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/index.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transformer-context-provider.d.ts +6 -4
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/transformer-context/transformer-context-provider.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/package.json +3 -2
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/graphql-api-provider.ts +1 -41
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/index.ts +1 -4
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/model-datasource/index.ts +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/model-datasource/types.ts +163 -0
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transform-host-provider.ts +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transformer-context/index.ts +4 -3
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transformer-context/transformer-context-provider.ts +6 -7
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/transformer-context/transformer-datasource-provider.ts +2 -2
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/tsconfig.tsbuildinfo +1 -1
- package/node_modules/graphql-transformer-common/API.md +11 -4
- package/node_modules/graphql-transformer-common/CHANGELOG.md +6 -0
- package/node_modules/graphql-transformer-common/lib/ResourceConstants.d.ts +11 -4
- package/node_modules/graphql-transformer-common/lib/ResourceConstants.d.ts.map +1 -1
- package/node_modules/graphql-transformer-common/lib/ResourceConstants.js +11 -4
- package/node_modules/graphql-transformer-common/lib/ResourceConstants.js.map +1 -1
- package/node_modules/graphql-transformer-common/package.json +2 -3
- package/package.json +17 -17
- package/src/amplify-graphql-api.ts +20 -5
- package/src/amplify-graphql-definition.ts +8 -15
- package/src/index.ts +3 -11
- package/src/internal/data-source-config.ts +89 -35
- package/src/internal/model-type-name.ts +3 -3
- package/src/model-datasource-strategy.ts +149 -0
- package/src/sql-model-datasource-strategy.ts +1 -1
- package/src/types.ts +17 -151
- /package/node_modules/{graphql-transformer-common → @aws-amplify/graphql-transformer-interfaces}/LICENSE +0 -0
@@ -407,19 +407,26 @@ export class ResourceConstants {
|
|
407
407
|
OpenSearchStreamingLambdaIAMRoleLogicalID: string;
|
408
408
|
OpenSearchStreamingLambdaFunctionLogicalID: string;
|
409
409
|
OpenSearchDataSourceLogicalID: string;
|
410
|
+
SQLLambdaAliasLogicalID: string;
|
410
411
|
SQLLambdaIAMRoleLogicalID: string;
|
411
412
|
SQLLambdaLogAccessPolicy: string;
|
412
|
-
SQLPatchingLambdaIAMRoleLogicalID: string;
|
413
413
|
SQLLambdaLogicalID: string;
|
414
|
+
SQLStackName: string;
|
415
|
+
SQLVpcEndpointLogicalIDPrefix: string;
|
416
|
+
SQLLambdaDataSourceLogicalID: string;
|
417
|
+
SQLPatchingLambdaIAMRoleLogicalID: string;
|
414
418
|
SQLPatchingLambdaLogAccessPolicy: string;
|
415
419
|
SQLPatchingLambdaLogicalID: string;
|
416
|
-
SQLLambdaDataSourceLogicalID: string;
|
417
420
|
SQLPatchingSubscriptionLogicalID: string;
|
418
421
|
SQLPatchingTopicLogicalID: string;
|
419
|
-
|
422
|
+
AmplifySQLLayerNotificationTopicName: string;
|
423
|
+
AmplifySQLLayerNotificationTopicAccount: string;
|
424
|
+
SQLLayerVersionManifestBucket: string;
|
425
|
+
SQLLayerVersionManifestBucketRegion: string;
|
426
|
+
SQLLayerVersionManifestKeyPrefix: string;
|
420
427
|
SQLLambdaLayerVersionLogicalID: string;
|
421
428
|
SQLLayerMappingID: string;
|
422
|
-
|
429
|
+
SQLLayerVersionCustomResourceID: string;
|
423
430
|
NoneDataSource: string;
|
424
431
|
AuthCognitoUserPoolLogicalID: string;
|
425
432
|
AuthCognitoUserPoolNativeClientLogicalID: string;
|
@@ -3,6 +3,12 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [4.26.2](https://github.com/aws-amplify/amplify-category-api/compare/graphql-transformer-common@4.26.1...graphql-transformer-common@4.26.2) (2023-11-18)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
- regionalize lambda layer patching SNS topics ([#2079](https://github.com/aws-amplify/amplify-category-api/issues/2079)) ([6006c86](https://github.com/aws-amplify/amplify-category-api/commit/6006c86cd4ee624b24c184fab523fcdcdb38be63))
|
11
|
+
|
6
12
|
## [4.26.1](https://github.com/aws-amplify/amplify-category-api/compare/graphql-transformer-common@4.26.0...graphql-transformer-common@4.26.1) (2023-11-16)
|
7
13
|
|
8
14
|
### Bug Fixes
|
@@ -19,19 +19,26 @@ export declare class ResourceConstants {
|
|
19
19
|
OpenSearchStreamingLambdaIAMRoleLogicalID: string;
|
20
20
|
OpenSearchStreamingLambdaFunctionLogicalID: string;
|
21
21
|
OpenSearchDataSourceLogicalID: string;
|
22
|
+
SQLLambdaAliasLogicalID: string;
|
22
23
|
SQLLambdaIAMRoleLogicalID: string;
|
23
24
|
SQLLambdaLogAccessPolicy: string;
|
24
|
-
SQLPatchingLambdaIAMRoleLogicalID: string;
|
25
25
|
SQLLambdaLogicalID: string;
|
26
|
+
SQLStackName: string;
|
27
|
+
SQLVpcEndpointLogicalIDPrefix: string;
|
28
|
+
SQLLambdaDataSourceLogicalID: string;
|
29
|
+
SQLPatchingLambdaIAMRoleLogicalID: string;
|
26
30
|
SQLPatchingLambdaLogAccessPolicy: string;
|
27
31
|
SQLPatchingLambdaLogicalID: string;
|
28
|
-
SQLLambdaDataSourceLogicalID: string;
|
29
32
|
SQLPatchingSubscriptionLogicalID: string;
|
30
33
|
SQLPatchingTopicLogicalID: string;
|
31
|
-
|
34
|
+
AmplifySQLLayerNotificationTopicName: string;
|
35
|
+
AmplifySQLLayerNotificationTopicAccount: string;
|
36
|
+
SQLLayerVersionManifestBucket: string;
|
37
|
+
SQLLayerVersionManifestBucketRegion: string;
|
38
|
+
SQLLayerVersionManifestKeyPrefix: string;
|
32
39
|
SQLLambdaLayerVersionLogicalID: string;
|
33
40
|
SQLLayerMappingID: string;
|
34
|
-
|
41
|
+
SQLLayerVersionCustomResourceID: string;
|
35
42
|
NoneDataSource: string;
|
36
43
|
AuthCognitoUserPoolLogicalID: string;
|
37
44
|
AuthCognitoUserPoolNativeClientLogicalID: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResourceConstants.d.ts","sourceRoot":"","sources":["../src/ResourceConstants.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAiB;IAC5B,OAAc,IAAI,SAAU;IAE5B,OAAc,kBAAkB,SAAO;IAEvC,OAAc,6BAA6B,SAAO;IAElD,OAAc,6BAA6B,SAAO;IAElD,gBAAuB,SAAS
|
1
|
+
{"version":3,"file":"ResourceConstants.d.ts","sourceRoot":"","sources":["../src/ResourceConstants.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAiB;IAC5B,OAAc,IAAI,SAAU;IAE5B,OAAc,kBAAkB,SAAO;IAEvC,OAAc,6BAA6B,SAAO;IAElD,OAAc,6BAA6B,SAAO;IAElD,gBAAuB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAoI9B;IAEF,OAAc,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiDtB;IAEF,OAAc,QAAQ,KAAM;IAE5B,OAAc,UAAU;;;;;;;MAYtB;IAEF,OAAc,OAAO;;;;;;;;;;;;;;;MAsBnB;IAEF,OAAc,QAAQ,KAAM;IAE5B,gBAAuB,QAAQ;;;;;;;;;;;;;;;MAe7B;CACH"}
|
@@ -24,19 +24,26 @@ ResourceConstants.RESOURCES = {
|
|
24
24
|
OpenSearchStreamingLambdaIAMRoleLogicalID: 'OpenSearchStreamingLambdaIAMRole',
|
25
25
|
OpenSearchStreamingLambdaFunctionLogicalID: 'OpenSearchStreamingLambdaFunction',
|
26
26
|
OpenSearchDataSourceLogicalID: 'OpenSearchDataSource',
|
27
|
+
SQLLambdaAliasLogicalID: 'SQLLambdaAlias',
|
27
28
|
SQLLambdaIAMRoleLogicalID: 'SQLLambdaIAMRole',
|
28
29
|
SQLLambdaLogAccessPolicy: 'SQLLambdaLogAccessPolicy',
|
29
|
-
SQLPatchingLambdaIAMRoleLogicalID: 'SQLPatchingLambdaIAMRole',
|
30
30
|
SQLLambdaLogicalID: 'SQLLambdaFunction',
|
31
|
+
SQLStackName: 'SqlApiStack',
|
32
|
+
SQLVpcEndpointLogicalIDPrefix: 'SQLVpcEndpoint',
|
33
|
+
SQLLambdaDataSourceLogicalID: 'SQLLambdaDataSource',
|
34
|
+
SQLPatchingLambdaIAMRoleLogicalID: 'SQLPatchingLambdaIAMRole',
|
31
35
|
SQLPatchingLambdaLogAccessPolicy: 'SQLPatchingLambdaLogAccessPolicy',
|
32
36
|
SQLPatchingLambdaLogicalID: 'SQLPatchingLambda',
|
33
|
-
SQLLambdaDataSourceLogicalID: 'SQLLambdaDataSource',
|
34
37
|
SQLPatchingSubscriptionLogicalID: 'SQLPatchingSubscription',
|
35
38
|
SQLPatchingTopicLogicalID: 'SQLPatchingTopic',
|
36
|
-
|
39
|
+
AmplifySQLLayerNotificationTopicName: 'AmplifySQLLayerNotification',
|
40
|
+
AmplifySQLLayerNotificationTopicAccount: '582037449441',
|
41
|
+
SQLLayerVersionManifestBucket: 'amplify-rds-layer-resources',
|
42
|
+
SQLLayerVersionManifestBucketRegion: 'us-east-1',
|
43
|
+
SQLLayerVersionManifestKeyPrefix: 'sql-layer-versions/',
|
37
44
|
SQLLambdaLayerVersionLogicalID: 'SQLLambdaLayerVersion',
|
38
45
|
SQLLayerMappingID: 'SQLLayerResourceMapping',
|
39
|
-
|
46
|
+
SQLLayerVersionCustomResourceID: 'SQLLayerVersionCustomResource',
|
40
47
|
NoneDataSource: 'NoneDataSource',
|
41
48
|
AuthCognitoUserPoolLogicalID: 'AuthCognitoUserPool',
|
42
49
|
AuthCognitoUserPoolNativeClientLogicalID: 'AuthCognitoUserPoolNativeClient',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResourceConstants.js","sourceRoot":"","sources":["../src/ResourceConstants.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAiB;;AAA9B,
|
1
|
+
{"version":3,"file":"ResourceConstants.js","sourceRoot":"","sources":["../src/ResourceConstants.ts"],"names":[],"mappings":"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"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "graphql-transformer-common",
|
3
|
-
"version": "4.26.
|
3
|
+
"version": "4.26.2",
|
4
4
|
"description": "Common code and constants for AppSync Transformers",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -54,6 +54,5 @@
|
|
54
54
|
"json",
|
55
55
|
"node"
|
56
56
|
]
|
57
|
-
}
|
58
|
-
"gitHead": "317a141956493f0940bb506470259026edf3b7bc"
|
57
|
+
}
|
59
58
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-amplify/graphql-api-construct",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.3",
|
4
4
|
"description": "AppSync GraphQL Api Construct using Amplify GraphQL Transformer.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -75,20 +75,20 @@
|
|
75
75
|
"dependencies": {
|
76
76
|
"@aws-amplify/backend-output-schemas": "^0.4.0",
|
77
77
|
"@aws-amplify/backend-output-storage": "^0.2.2",
|
78
|
-
"@aws-amplify/graphql-auth-transformer": "3.2.
|
79
|
-
"@aws-amplify/graphql-default-value-transformer": "2.1.
|
80
|
-
"@aws-amplify/graphql-function-transformer": "2.1.
|
81
|
-
"@aws-amplify/graphql-http-transformer": "2.1.
|
82
|
-
"@aws-amplify/graphql-index-transformer": "2.2.
|
83
|
-
"@aws-amplify/graphql-maps-to-transformer": "3.3.
|
84
|
-
"@aws-amplify/graphql-model-transformer": "2.3.
|
85
|
-
"@aws-amplify/graphql-predictions-transformer": "2.1.
|
86
|
-
"@aws-amplify/graphql-relational-transformer": "2.2.
|
87
|
-
"@aws-amplify/graphql-searchable-transformer": "2.3.
|
88
|
-
"@aws-amplify/graphql-sql-transformer": "0.1.
|
89
|
-
"@aws-amplify/graphql-transformer": "1.3.
|
90
|
-
"@aws-amplify/graphql-transformer-core": "2.3.
|
91
|
-
"@aws-amplify/graphql-transformer-interfaces": "3.3.
|
78
|
+
"@aws-amplify/graphql-auth-transformer": "3.2.3",
|
79
|
+
"@aws-amplify/graphql-default-value-transformer": "2.1.12",
|
80
|
+
"@aws-amplify/graphql-function-transformer": "2.1.11",
|
81
|
+
"@aws-amplify/graphql-http-transformer": "2.1.11",
|
82
|
+
"@aws-amplify/graphql-index-transformer": "2.2.3",
|
83
|
+
"@aws-amplify/graphql-maps-to-transformer": "3.3.3",
|
84
|
+
"@aws-amplify/graphql-model-transformer": "2.3.3",
|
85
|
+
"@aws-amplify/graphql-predictions-transformer": "2.1.11",
|
86
|
+
"@aws-amplify/graphql-relational-transformer": "2.2.3",
|
87
|
+
"@aws-amplify/graphql-searchable-transformer": "2.3.3",
|
88
|
+
"@aws-amplify/graphql-sql-transformer": "0.1.3",
|
89
|
+
"@aws-amplify/graphql-transformer": "1.3.3",
|
90
|
+
"@aws-amplify/graphql-transformer-core": "2.3.3",
|
91
|
+
"@aws-amplify/graphql-transformer-interfaces": "3.3.1",
|
92
92
|
"@aws-amplify/platform-core": "^0.2.0",
|
93
93
|
"@aws-amplify/plugin-types": "^0.4.1",
|
94
94
|
"charenc": "^0.0.2",
|
@@ -97,7 +97,7 @@
|
|
97
97
|
"graceful-fs": "^4.2.11",
|
98
98
|
"graphql": "^15.5.0",
|
99
99
|
"graphql-mapping-template": "4.20.12",
|
100
|
-
"graphql-transformer-common": "4.26.
|
100
|
+
"graphql-transformer-common": "4.26.2",
|
101
101
|
"hjson": "^3.2.2",
|
102
102
|
"immer": "^9.0.12",
|
103
103
|
"is-buffer": "^2.0.5",
|
@@ -164,5 +164,5 @@
|
|
164
164
|
}
|
165
165
|
}
|
166
166
|
},
|
167
|
-
"gitHead": "
|
167
|
+
"gitHead": "5256b5955ee204dd56f8074a43406852f8206c54"
|
168
168
|
}
|
@@ -38,7 +38,6 @@ import type {
|
|
38
38
|
IBackendOutputStorageStrategy,
|
39
39
|
AddFunctionProps,
|
40
40
|
ConflictResolution,
|
41
|
-
SQLLambdaModelDataSourceStrategy,
|
42
41
|
} from './types';
|
43
42
|
import {
|
44
43
|
convertAuthorizationModesToTransformerAuthConfig,
|
@@ -50,9 +49,10 @@ import {
|
|
50
49
|
CodegenAssets,
|
51
50
|
getAdditionalAuthenticationTypes,
|
52
51
|
} from './internal';
|
53
|
-
import {
|
54
|
-
import { parseDataSourceConfig } from './internal/data-source-config';
|
52
|
+
import { mapInterfaceCustomSqlStrategiesToImplementationStrategies, parseDataSourceConfig } from './internal/data-source-config';
|
55
53
|
import { getStackForScope, walkAndProcessNodes } from './internal/construct-tree';
|
54
|
+
import { SQLLambdaModelDataSourceStrategy } from './model-datasource-strategy';
|
55
|
+
import { isSQLLambdaModelDataSourceStrategy } from './sql-model-datasource-strategy';
|
56
56
|
|
57
57
|
/**
|
58
58
|
* L3 Construct which invokes the Amplify Transformer Pattern over an input Graphql Schema.
|
@@ -209,8 +209,22 @@ export class AmplifyGraphqlApi extends Construct {
|
|
209
209
|
...parseDataSourceConfig(definition.dataSourceStrategies),
|
210
210
|
};
|
211
211
|
|
212
|
+
// TODO: Normalize all of this once we start using strategies internally. Right now the data source configuration (VPC, connection info,
|
213
|
+
// etc) is separate from the DataSourceType, and singular
|
214
|
+
const customSqlDataSourceStrategies = mapInterfaceCustomSqlStrategiesToImplementationStrategies(
|
215
|
+
definition.customSqlDataSourceStrategies,
|
216
|
+
);
|
217
|
+
if (customSqlDataSourceStrategies.length > 0) {
|
218
|
+
executeTransformConfig = {
|
219
|
+
...executeTransformConfig,
|
220
|
+
customSqlDataSourceStrategies,
|
221
|
+
};
|
222
|
+
}
|
223
|
+
|
212
224
|
// TODO: Update this to support multiple definitions; right now we assume only one SQL data source type
|
213
|
-
|
225
|
+
const modelStrategies = Object.values(definition.dataSourceStrategies).filter(isSQLLambdaModelDataSourceStrategy);
|
226
|
+
const customSqlStrategies = definition.customSqlDataSourceStrategies?.map((css) => css.strategy) ?? [];
|
227
|
+
for (const strategy of [...modelStrategies, ...customSqlStrategies]) {
|
214
228
|
if (isSQLLambdaModelDataSourceStrategy(strategy)) {
|
215
229
|
executeTransformConfig = this.extendTransformConfig(executeTransformConfig, strategy);
|
216
230
|
break;
|
@@ -235,7 +249,7 @@ export class AmplifyGraphqlApi extends Construct {
|
|
235
249
|
/**
|
236
250
|
* Extends executeTransformConfig with fields for provisioning a SQL Lambda
|
237
251
|
* @param executeTransformConfig the executeTransformConfig to extend
|
238
|
-
* @param
|
252
|
+
* @param strategy the SQLLambdaModelDataSourceStrategy containing the SQL connection values to add to the transform config
|
239
253
|
* @returns the extended configuration that includes SQL DB connection information
|
240
254
|
*/
|
241
255
|
private extendTransformConfig(
|
@@ -243,6 +257,7 @@ export class AmplifyGraphqlApi extends Construct {
|
|
243
257
|
strategy: SQLLambdaModelDataSourceStrategy,
|
244
258
|
): ExecuteTransformConfig {
|
245
259
|
const extendedConfig = { ...executeTransformConfig };
|
260
|
+
|
246
261
|
if (strategy.customSqlStatements) {
|
247
262
|
extendedConfig.customQueries = new Map(Object.entries(strategy.customSqlStatements));
|
248
263
|
}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import * as os from 'os';
|
2
2
|
import { SchemaFile } from 'aws-cdk-lib/aws-appsync';
|
3
|
-
import { IAmplifyGraphqlDefinition
|
3
|
+
import { IAmplifyGraphqlDefinition } from './types';
|
4
4
|
import { constructDataSourceStrategyMap } from './internal';
|
5
|
+
import { ModelDataSourceStrategy } from './model-datasource-strategy';
|
6
|
+
import { constructCustomSqlDataSourceStrategies } from './internal/data-source-config';
|
5
7
|
|
6
8
|
export const DEFAULT_MODEL_DATA_SOURCE_STRATEGY: ModelDataSourceStrategy = {
|
7
9
|
dbType: 'DYNAMODB',
|
@@ -18,8 +20,8 @@ export class AmplifyGraphqlDefinition {
|
|
18
20
|
* **NOTE** The 'dataSourceStrategy' configuration option is in preview and is not recommended to use with production systems.
|
19
21
|
*
|
20
22
|
* @param schema the graphql input as a string
|
21
|
-
* @param dataSourceStrategy the provisioning definition for datasources that resolve `@model`s in this schema.
|
22
|
-
* CloudFormation will be used by default.
|
23
|
+
* @param dataSourceStrategy the provisioning definition for datasources that resolve `@model`s and custom SQL statements in this schema.
|
24
|
+
* The DynamoDB from CloudFormation will be used by default.
|
23
25
|
* @experimental dataSourceStrategy
|
24
26
|
* @returns a fully formed amplify graphql definition
|
25
27
|
*/
|
@@ -32,6 +34,7 @@ export class AmplifyGraphqlDefinition {
|
|
32
34
|
functionSlots: [],
|
33
35
|
referencedLambdaFunctions: {},
|
34
36
|
dataSourceStrategies: constructDataSourceStrategyMap(schema, dataSourceStrategy),
|
37
|
+
customSqlDataSourceStrategies: constructCustomSqlDataSourceStrategies(schema, dataSourceStrategy),
|
35
38
|
};
|
36
39
|
}
|
37
40
|
|
@@ -45,12 +48,7 @@ export class AmplifyGraphqlDefinition {
|
|
45
48
|
filePaths = [filePaths];
|
46
49
|
}
|
47
50
|
const schema = filePaths.map((filePath) => new SchemaFile({ filePath }).definition).join(os.EOL);
|
48
|
-
return
|
49
|
-
schema,
|
50
|
-
functionSlots: [],
|
51
|
-
referencedLambdaFunctions: {},
|
52
|
-
dataSourceStrategies: constructDataSourceStrategyMap(schema, DEFAULT_MODEL_DATA_SOURCE_STRATEGY),
|
53
|
-
};
|
51
|
+
return AmplifyGraphqlDefinition.fromString(schema, DEFAULT_MODEL_DATA_SOURCE_STRATEGY);
|
54
52
|
}
|
55
53
|
|
56
54
|
/**
|
@@ -72,12 +70,7 @@ export class AmplifyGraphqlDefinition {
|
|
72
70
|
filePaths = [filePaths];
|
73
71
|
}
|
74
72
|
const schema = filePaths.map((filePath) => new SchemaFile({ filePath }).definition).join(os.EOL);
|
75
|
-
return
|
76
|
-
schema,
|
77
|
-
functionSlots: [],
|
78
|
-
referencedLambdaFunctions: {},
|
79
|
-
dataSourceStrategies: constructDataSourceStrategyMap(schema, dataSourceStrategy),
|
80
|
-
};
|
73
|
+
return AmplifyGraphqlDefinition.fromString(schema, dataSourceStrategy);
|
81
74
|
}
|
82
75
|
|
83
76
|
/**
|
package/src/index.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* ATTENTION
|
2
2
|
*
|
3
|
-
* If you modify this file
|
3
|
+
* If you modify this file you must also modify packages/amplify-data-construct/src/index.ts to have the same exports
|
4
4
|
*/
|
5
5
|
export type {
|
6
6
|
IAMAuthorizationConfig,
|
@@ -31,16 +31,6 @@ export type {
|
|
31
31
|
IBackendOutputStorageStrategy,
|
32
32
|
IBackendOutputEntry,
|
33
33
|
AddFunctionProps,
|
34
|
-
ModelDataSourceStrategy,
|
35
|
-
DefaultDynamoDbModelDataSourceStrategy,
|
36
|
-
AmplifyDynamoDbModelDataSourceStrategy,
|
37
|
-
SQLLambdaModelDataSourceStrategy,
|
38
|
-
ModelDataSourceStrategyDbType,
|
39
|
-
VpcConfig,
|
40
|
-
SubnetAvailabilityZone,
|
41
|
-
SQLLambdaLayerMapping,
|
42
|
-
SqlModelDataSourceDbConnectionConfig,
|
43
|
-
ProvisionedConcurrencyConfig,
|
44
34
|
} from './types';
|
45
35
|
export { AmplifyGraphqlApi } from './amplify-graphql-api';
|
46
36
|
export { AmplifyGraphqlDefinition } from './amplify-graphql-definition';
|
@@ -52,3 +42,5 @@ export {
|
|
52
42
|
SSEType,
|
53
43
|
StreamSpecification,
|
54
44
|
} from './amplify-dynamodb-table-wrapper';
|
45
|
+
export { SQLLambdaModelDataSourceStrategyFactory } from './sql-model-datasource-strategy';
|
46
|
+
export * from './model-datasource-strategy';
|
@@ -1,46 +1,23 @@
|
|
1
|
+
import { parse } from 'graphql';
|
1
2
|
import {
|
3
|
+
CustomSqlDataSourceStrategy as ImplementationCustomSqlDataSourceStrategy,
|
2
4
|
DataSourceType,
|
3
|
-
DynamoDBProvisionStrategy,
|
4
|
-
SQLDBType,
|
5
5
|
SQLLambdaModelProvisionStrategy,
|
6
6
|
} from '@aws-amplify/graphql-transformer-interfaces';
|
7
|
-
import {
|
7
|
+
import {
|
8
|
+
dataSourceStrategyToDataSourceType,
|
9
|
+
isSqlStrategy,
|
10
|
+
isQueryNode,
|
11
|
+
isMutationNode,
|
12
|
+
fieldsWithSqlDirective,
|
13
|
+
} from '@aws-amplify/graphql-transformer-core';
|
14
|
+
import { normalizeDbType } from '@aws-amplify/graphql-transformer-core/lib/utils';
|
15
|
+
import { CustomSqlDataSourceStrategy as InterfaceCustomSqlDataSourceStrategy, ModelDataSourceStrategy } from '../model-datasource-strategy';
|
8
16
|
|
9
17
|
type DataSourceConfig = {
|
10
18
|
modelToDatasourceMap: Map<string, DataSourceType>;
|
11
19
|
};
|
12
20
|
|
13
|
-
// TODO: Do away with this after we normalize database types throughout the internals
|
14
|
-
const convertSQLDBType = (definitionDBType: 'MYSQL' | 'POSTGRES'): SQLDBType => (definitionDBType === 'MYSQL' ? 'MySQL' : 'Postgres');
|
15
|
-
|
16
|
-
const convertToDataSourceType = (dataSourceStrategy: ModelDataSourceStrategy): DataSourceType => {
|
17
|
-
if (dataSourceStrategy.dbType === 'DYNAMODB') {
|
18
|
-
switch (dataSourceStrategy.provisionStrategy) {
|
19
|
-
case 'DEFAULT':
|
20
|
-
return {
|
21
|
-
dbType: 'DDB',
|
22
|
-
provisionDB: true,
|
23
|
-
provisionStrategy: DynamoDBProvisionStrategy.DEFAULT,
|
24
|
-
};
|
25
|
-
case 'AMPLIFY_TABLE':
|
26
|
-
return {
|
27
|
-
dbType: 'DDB',
|
28
|
-
provisionDB: true,
|
29
|
-
provisionStrategy: DynamoDBProvisionStrategy.AMPLIFY_TABLE,
|
30
|
-
};
|
31
|
-
default:
|
32
|
-
throw new Error(`Encountered unexpected provision strategy: ${(dataSourceStrategy as any).provisionStrategy}`);
|
33
|
-
}
|
34
|
-
} else if (dataSourceStrategy.dbType === 'MYSQL' || dataSourceStrategy.dbType === 'POSTGRES') {
|
35
|
-
return {
|
36
|
-
dbType: convertSQLDBType(dataSourceStrategy.dbType),
|
37
|
-
provisionDB: false,
|
38
|
-
provisionStrategy: SQLLambdaModelProvisionStrategy.DEFAULT,
|
39
|
-
};
|
40
|
-
}
|
41
|
-
throw new Error(`Encountered unexpected database type ${dataSourceStrategy.dbType}`);
|
42
|
-
};
|
43
|
-
|
44
21
|
/**
|
45
22
|
* An internal helper to convert from a map of model-to-ModelDataSourceStrategies to the map of model-to-DataSourceTypes that internal
|
46
23
|
* transform processing requires. TODO: We can remove this once we refactor the internals to use ModelDataSourceStrategies natively.
|
@@ -48,10 +25,87 @@ const convertToDataSourceType = (dataSourceStrategy: ModelDataSourceStrategy): D
|
|
48
25
|
export const parseDataSourceConfig = (dataSourceDefinitionMap: Record<string, ModelDataSourceStrategy>): DataSourceConfig => {
|
49
26
|
const modelToDatasourceMap = new Map<string, DataSourceType>();
|
50
27
|
for (const [key, value] of Object.entries(dataSourceDefinitionMap)) {
|
51
|
-
const dataSourceType =
|
28
|
+
const dataSourceType = dataSourceStrategyToDataSourceType(value);
|
52
29
|
modelToDatasourceMap.set(key, dataSourceType);
|
53
30
|
}
|
54
31
|
return {
|
55
32
|
modelToDatasourceMap,
|
56
33
|
};
|
57
34
|
};
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Creates an interface flavor of customSqlDataSourceStrategies from a factory method's schema and data source. Internally, this function
|
38
|
+
* scans the fields of `Query` and `Mutation` looking for fields annotated with the `@sql` directive and designates the specified
|
39
|
+
* dataSourceStrategy to fulfill those custom queries.
|
40
|
+
*
|
41
|
+
* Note that we do not scan for `Subscription` fields: `@sql` directives are not allowed on those, and it wouldn't make sense to do so
|
42
|
+
* anyway, since subscriptions are processed from an incoming Mutation, not as the result of a direct datasource access.
|
43
|
+
*
|
44
|
+
* TODO: Reword this when we refactor to use Strategies throughout the implementation rather than DataSources.
|
45
|
+
*/
|
46
|
+
export const constructCustomSqlDataSourceStrategies = (
|
47
|
+
schema: string,
|
48
|
+
dataSourceStrategy: ModelDataSourceStrategy,
|
49
|
+
): InterfaceCustomSqlDataSourceStrategy[] => {
|
50
|
+
if (!isSqlStrategy(dataSourceStrategy)) {
|
51
|
+
return [];
|
52
|
+
}
|
53
|
+
|
54
|
+
const parsedSchema = parse(schema);
|
55
|
+
|
56
|
+
const queryNode = parsedSchema.definitions.find(isQueryNode);
|
57
|
+
const mutationNode = parsedSchema.definitions.find(isMutationNode);
|
58
|
+
if (!queryNode && !mutationNode) {
|
59
|
+
return [];
|
60
|
+
}
|
61
|
+
|
62
|
+
const customSqlDataSourceStrategies: InterfaceCustomSqlDataSourceStrategy[] = [];
|
63
|
+
|
64
|
+
if (queryNode) {
|
65
|
+
const fields = fieldsWithSqlDirective(queryNode);
|
66
|
+
for (const field of fields) {
|
67
|
+
customSqlDataSourceStrategies.push({
|
68
|
+
typeName: 'Query',
|
69
|
+
fieldName: field.name.value,
|
70
|
+
strategy: dataSourceStrategy,
|
71
|
+
});
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
if (mutationNode) {
|
76
|
+
const fields = fieldsWithSqlDirective(mutationNode);
|
77
|
+
for (const field of fields) {
|
78
|
+
customSqlDataSourceStrategies.push({
|
79
|
+
typeName: 'Mutation',
|
80
|
+
fieldName: field.name.value,
|
81
|
+
strategy: dataSourceStrategy,
|
82
|
+
});
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
return customSqlDataSourceStrategies;
|
87
|
+
};
|
88
|
+
|
89
|
+
/**
|
90
|
+
* We currently use a different type structure to model strategies in the interface than we do in the implementation. This maps the
|
91
|
+
* interface CustomSqlDataSourceStrategy (which uses SQLLambdaModelDataSourceStrategy) to the implementation flavor (which uses
|
92
|
+
* DataSourceType).
|
93
|
+
*
|
94
|
+
* TODO: Remove this once we refactor the internals to use strategies rather than DataSourceTypes
|
95
|
+
*/
|
96
|
+
export const mapInterfaceCustomSqlStrategiesToImplementationStrategies = (
|
97
|
+
strategies?: InterfaceCustomSqlDataSourceStrategy[],
|
98
|
+
): ImplementationCustomSqlDataSourceStrategy[] => {
|
99
|
+
if (!strategies) {
|
100
|
+
return [];
|
101
|
+
}
|
102
|
+
return strategies.map((interfaceStrategy) => ({
|
103
|
+
fieldName: interfaceStrategy.fieldName,
|
104
|
+
typeName: interfaceStrategy.typeName,
|
105
|
+
dataSourceType: {
|
106
|
+
dbType: normalizeDbType(interfaceStrategy.strategy.dbType),
|
107
|
+
provisionDB: false,
|
108
|
+
provisionStrategy: SQLLambdaModelProvisionStrategy.DEFAULT,
|
109
|
+
},
|
110
|
+
}));
|
111
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { ModelDataSourceStrategy } from '../types';
|
2
1
|
import { Kind, ObjectTypeDefinitionNode, StringValueNode, parse } from 'graphql';
|
2
|
+
import { ModelDataSourceStrategy } from '../model-datasource-strategy';
|
3
3
|
|
4
4
|
const MODEL_DIRECTIVE_NAME = 'model';
|
5
5
|
const MANY_TO_MANY_DIRECTIVE_NAME = 'manyToMany';
|
@@ -8,7 +8,7 @@ const MANY_TO_MANY_DIRECTIVE_NAME = 'manyToMany';
|
|
8
8
|
* @param schema graphql schema in SDL
|
9
9
|
* @returns type names which model diretives are attached
|
10
10
|
*/
|
11
|
-
export
|
11
|
+
export const getModelTypeNames = (schema: string): string[] => {
|
12
12
|
const parsedSchema = parse(schema);
|
13
13
|
const nodesWithModelDirective = parsedSchema.definitions.filter(
|
14
14
|
(obj) => obj.kind === Kind.OBJECT_TYPE_DEFINITION && obj.directives?.some((dir) => dir.name.value === MODEL_DIRECTIVE_NAME),
|
@@ -28,7 +28,7 @@ export function getModelTypeNames(schema: string): string[] {
|
|
28
28
|
});
|
29
29
|
});
|
30
30
|
return modelKeys.filter((key, idx) => modelKeys.indexOf(key) === idx);
|
31
|
-
}
|
31
|
+
};
|
32
32
|
|
33
33
|
export const constructDataSourceStrategyMap = (
|
34
34
|
schema: string,
|