@aws-amplify/graphql-api-construct 1.9.0-gen2-release-0418-2.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.jsii +73 -59
- package/API.md +1 -1
- package/CHANGELOG.md +3 -1
- package/README.md +156 -24
- package/lib/amplify-dynamodb-table-wrapper.js +1 -1
- package/lib/amplify-graphql-api.js +7 -10
- package/lib/amplify-graphql-definition.js +1 -1
- package/lib/internal/asset-provider.d.ts +26 -0
- package/lib/internal/asset-provider.js +58 -0
- package/lib/internal/data-source-config.js +12 -2
- package/lib/internal/index.d.ts +1 -1
- package/lib/internal/index.js +2 -2
- package/lib/model-datasource-strategy-types.d.ts +7 -2
- package/lib/model-datasource-strategy-types.js +1 -1
- package/lib/sql-model-datasource-strategy.js +4 -3
- package/node_modules/@aws-amplify/graphql-auth-transformer/CHANGELOG.md +7 -1
- package/node_modules/@aws-amplify/graphql-auth-transformer/lib/vtl-generator/rds/resolvers/mutation.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-auth-transformer/lib/vtl-generator/rds/resolvers/mutation.js +3 -0
- package/node_modules/@aws-amplify/graphql-auth-transformer/lib/vtl-generator/rds/resolvers/mutation.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-auth-transformer/package.json +14 -14
- package/node_modules/@aws-amplify/graphql-default-value-transformer/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-default-value-transformer/package.json +9 -9
- package/node_modules/@aws-amplify/graphql-directives/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-directives/package.json +2 -2
- package/node_modules/@aws-amplify/graphql-function-transformer/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-function-transformer/package.json +8 -8
- package/node_modules/@aws-amplify/graphql-http-transformer/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-http-transformer/package.json +8 -8
- package/node_modules/@aws-amplify/graphql-index-transformer/CHANGELOG.md +2 -1
- package/node_modules/@aws-amplify/graphql-index-transformer/lib/schema.js +8 -3
- package/node_modules/@aws-amplify/graphql-index-transformer/lib/schema.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-index-transformer/package.json +9 -9
- package/node_modules/@aws-amplify/graphql-maps-to-transformer/CHANGELOG.md +4 -2
- 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 +12 -12
- package/node_modules/@aws-amplify/graphql-model-transformer/CHANGELOG.md +3 -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/mutation.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/mutation.js +10 -10
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/mutation.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/query.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/query.js +5 -5
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/query.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-model-transformer/lib/resolvers/rds/resolver.d.ts +0 -8
- 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 +9 -37
- 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.js +1 -1
- 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 +8 -8
- package/node_modules/@aws-amplify/graphql-predictions-transformer/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-predictions-transformer/lib/predictionsLambdaFunction.zip +0 -0
- package/node_modules/@aws-amplify/graphql-predictions-transformer/package.json +8 -8
- package/node_modules/@aws-amplify/graphql-relational-transformer/CHANGELOG.md +4 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-ddb-references-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-ddb-references-transformer.js +1 -0
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-ddb-references-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-sql-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-sql-transformer.js +1 -0
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-sql-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-transformer-factory.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-transformer-factory.js +2 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/belongs-to/belongs-to-directive-transformer-factory.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/graphql-has-many-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/graphql-has-many-transformer.js +11 -4
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/graphql-has-many-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/graphql-has-one-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/graphql-has-one-transformer.js +8 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/graphql-has-one-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-ddb-references-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-ddb-references-transformer.js +2 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-ddb-references-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-sql-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-sql-transformer.js +2 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-sql-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-transformer-factory.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-transformer-factory.js +3 -2
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-many/has-many-directive-transformer-factory.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-ddb-references-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-ddb-references-transformer.js +2 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-ddb-references-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-sql-transformer.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-sql-transformer.js +2 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-sql-transformer.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-transformer-factory.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-transformer-factory.js +2 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/has-one/has-one-directive-transformer-factory.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolver/ddb-references-generator.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolver/ddb-references-generator.js +4 -4
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolver/ddb-references-generator.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolver/rds-generator.d.ts +2 -2
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolver/rds-generator.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolver/rds-generator.js +9 -5
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolver/rds-generator.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.js +5 -3
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/resolvers.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/types.d.ts +1 -0
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/types.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/utils.d.ts +2 -2
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/utils.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/utils.js +101 -8
- package/node_modules/@aws-amplify/graphql-relational-transformer/lib/utils.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-relational-transformer/package.json +10 -10
- package/node_modules/@aws-amplify/graphql-searchable-transformer/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-searchable-transformer/lib/streaming-lambda.zip +0 -0
- package/node_modules/@aws-amplify/graphql-searchable-transformer/package.json +9 -9
- package/node_modules/@aws-amplify/graphql-sql-transformer/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-sql-transformer/package.json +9 -9
- package/node_modules/@aws-amplify/graphql-transformer/CHANGELOG.md +1 -1
- package/node_modules/@aws-amplify/graphql-transformer/package.json +15 -15
- package/node_modules/@aws-amplify/graphql-transformer-core/API.md +20 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/CHANGELOG.md +8 -2
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/appsync-function.js +2 -2
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/appsync-function.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/cdk-compat/schema-asset.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/cdk-compat/schema-asset.js +1 -2
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/cdk-compat/schema-asset.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/cdk-compat/template-asset.d.ts +3 -3
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/cdk-compat/template-asset.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/cdk-compat/template-asset.js +4 -5
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/cdk-compat/template-asset.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/graphql-api.d.ts +3 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/graphql-api.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/graphql-api.js +1 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/graphql-api.js.map +1 -1
- 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 +14 -8
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/index.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transform-host.js +5 -5
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transform-host.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformation/transform.d.ts +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 +3 -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/transformer-context/index.d.ts +1 -0
- 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 +1 -2
- 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/utils/index.d.ts +1 -1
- 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 +7 -1
- 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/rds-util.d.ts +9 -0
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/rds-util.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/rds-util.js +34 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/utils/rds-util.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/package.json +6 -5
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/API.md +9 -6
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/CHANGELOG.md +3 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/asset-provider.d.ts +2 -2
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/asset-provider.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/graphql-api-provider.d.ts +4 -2
- 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/model-datasource/types.d.ts +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/types.d.ts.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/types.js +2 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/lib/model-datasource/types.js.map +1 -1
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/package.json +2 -2
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/asset-provider.ts +2 -2
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/graphql-api-provider.ts +4 -2
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/src/model-datasource/types.ts +5 -2
- package/node_modules/@aws-amplify/graphql-transformer-interfaces/tsconfig.tsbuildinfo +1 -1
- package/node_modules/graphql-mapping-template/API.md +14 -1
- package/node_modules/graphql-mapping-template/CHANGELOG.md +6 -0
- package/node_modules/graphql-mapping-template/LICENSE +201 -0
- package/node_modules/graphql-mapping-template/lib/ast.d.ts +7 -1
- package/node_modules/graphql-mapping-template/lib/ast.d.ts.map +1 -1
- package/node_modules/graphql-mapping-template/lib/ast.js +9 -1
- package/node_modules/graphql-mapping-template/lib/ast.js.map +1 -1
- package/node_modules/graphql-mapping-template/lib/print.d.ts.map +1 -1
- package/node_modules/graphql-mapping-template/lib/print.js +5 -0
- package/node_modules/graphql-mapping-template/lib/print.js.map +1 -1
- package/node_modules/graphql-mapping-template/package.json +5 -4
- package/node_modules/graphql-transformer-common/CHANGELOG.md +1 -1
- package/node_modules/graphql-transformer-common/package.json +3 -3
- package/package.json +20 -20
- package/src/amplify-graphql-api.ts +6 -11
- package/src/internal/asset-provider.ts +64 -0
- package/src/internal/data-source-config.ts +12 -1
- package/src/internal/index.ts +1 -1
- package/src/model-datasource-strategy-types.ts +7 -2
- package/src/sql-model-datasource-strategy.ts +4 -1
- package/lib/internal/asset-manager.d.ts +0 -12
- package/lib/internal/asset-manager.js +0 -44
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/asset-manager.d.ts +0 -10
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/asset-manager.d.ts.map +0 -1
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/asset-manager.js +0 -20
- package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/asset-manager.js.map +0 -1
- package/src/internal/asset-manager.ts +0 -43
@@ -0,0 +1,64 @@
|
|
1
|
+
import * as fs from 'fs';
|
2
|
+
import * as path from 'path';
|
3
|
+
import { Construct } from 'constructs';
|
4
|
+
import * as cdk from 'aws-cdk-lib';
|
5
|
+
import { Asset } from 'aws-cdk-lib/aws-s3-assets';
|
6
|
+
import { AssetProps, S3Asset, AssetProvider as AssetProviderInterface } from '@aws-amplify/graphql-transformer-interfaces';
|
7
|
+
|
8
|
+
const TEMP_PREFIX = 'transformer-assets';
|
9
|
+
const FUNCTION_PREFIX = 'functions';
|
10
|
+
const RESOLVER_PREFIX = 'resolvers';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* The asset provider bridges the gap between creation of file assets in the transformer (which provide a name+contents tuple)
|
14
|
+
* with the path method which is used in CDK.
|
15
|
+
* The CDK S3 asset require the contents to be written to the file system first.
|
16
|
+
* The asset provider writes to a temporary directory before creating the CDK S3 asset.
|
17
|
+
*
|
18
|
+
*/
|
19
|
+
export class AssetProvider implements AssetProviderInterface {
|
20
|
+
private readonly tempAssetDir: string;
|
21
|
+
public readonly resolverAssets: Record<string, string> = {};
|
22
|
+
|
23
|
+
constructor(scope: Construct) {
|
24
|
+
this.tempAssetDir = cdk.FileSystem.mkdtemp(`${TEMP_PREFIX}-${scope.node.addr}`);
|
25
|
+
}
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Creates a new CDK S3 asset. The file contents in assetProps is first stored in a temporary file that is referenced by the CDK S3 asset.
|
29
|
+
* @param assetScope the parent of the asset
|
30
|
+
* @param assetId unique ID for CDK S3 asset
|
31
|
+
* @param assetProps name and contents of file to be added to CDK S3 asset
|
32
|
+
* @returns the CDK S3 asset
|
33
|
+
*/
|
34
|
+
public provide(assetScope: Construct, assetId: string, assetProps: AssetProps): S3Asset {
|
35
|
+
return new Asset(assetScope, assetId, { path: this.addAsset(assetProps.fileName, assetProps.fileContent) });
|
36
|
+
}
|
37
|
+
|
38
|
+
private addAsset(fileName: string, contents: string): string {
|
39
|
+
this.trackResolverAsset(fileName, contents);
|
40
|
+
const writableContents = this.isContentsAReference(fileName) ? this.dereferenceContents(contents) : contents;
|
41
|
+
const filePath = path.join(this.tempAssetDir, fileName);
|
42
|
+
const fileDirName = path.dirname(filePath);
|
43
|
+
if (!fs.existsSync(fileDirName)) {
|
44
|
+
fs.mkdirSync(fileDirName, { recursive: true });
|
45
|
+
}
|
46
|
+
fs.writeFileSync(filePath, writableContents);
|
47
|
+
return filePath;
|
48
|
+
}
|
49
|
+
|
50
|
+
private isContentsAReference(fileName: string): boolean {
|
51
|
+
return fileName.startsWith(FUNCTION_PREFIX);
|
52
|
+
}
|
53
|
+
|
54
|
+
private dereferenceContents(contents: string): Buffer {
|
55
|
+
return fs.readFileSync(contents);
|
56
|
+
}
|
57
|
+
|
58
|
+
private trackResolverAsset(fileName: string, contents: string): void {
|
59
|
+
if (fileName.startsWith(RESOLVER_PREFIX)) {
|
60
|
+
const resolverFileName = fileName.split('/')[1];
|
61
|
+
this.resolverAssets[resolverFileName] = contents;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
@@ -200,7 +200,18 @@ export const validateDataSourceStrategy = (strategy: ConstructModelDataSourceStr
|
|
200
200
|
isSqlModelDataSourceSsmDbConnectionConfig(dbConnectionConfig) ||
|
201
201
|
isSqlModelDataSourceSsmDbConnectionStringConfig(dbConnectionConfig)
|
202
202
|
) {
|
203
|
-
const
|
203
|
+
const ssmPaths = Object.values(dbConnectionConfig).filter((value) => typeof value === 'string');
|
204
|
+
if (isSqlModelDataSourceSsmDbConnectionStringConfig(dbConnectionConfig)) {
|
205
|
+
const hasMultipleSSMPaths = Array.isArray(dbConnectionConfig?.connectionUriSsmPath);
|
206
|
+
if (hasMultipleSSMPaths) {
|
207
|
+
if (dbConnectionConfig?.connectionUriSsmPath?.length < 1) {
|
208
|
+
throw new Error(`Invalid data source strategy "${strategy.name}". connectionUriSsmPath must be a string or non-empty array.`);
|
209
|
+
}
|
210
|
+
ssmPaths.push(...dbConnectionConfig.connectionUriSsmPath);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
const invalidSSMPaths = ssmPaths.filter((value) => !isValidSSMPath(value));
|
204
215
|
if (invalidSSMPaths.length > 0) {
|
205
216
|
throw new Error(
|
206
217
|
`Invalid data source strategy "${
|
package/src/internal/index.ts
CHANGED
@@ -2,6 +2,6 @@ export * from './authorization-modes';
|
|
2
2
|
export * from './construct-exports';
|
3
3
|
export * from './default-parameters';
|
4
4
|
export * from './conflict-resolution';
|
5
|
-
export * from './asset-
|
5
|
+
export * from './asset-provider';
|
6
6
|
export * from './codegen-assets';
|
7
7
|
export * from './model-type-name';
|
@@ -131,8 +131,13 @@ export type SqlModelDataSourceDbConnectionConfig =
|
|
131
131
|
* @experimental
|
132
132
|
*/
|
133
133
|
export interface SqlModelDataSourceSsmDbConnectionStringConfig {
|
134
|
-
/**
|
135
|
-
|
134
|
+
/**
|
135
|
+
* The SSM Path to the secure connection string used for connecting to the database. If more than one path is provided,
|
136
|
+
* the SQL Lambda will attempt to retrieve connection information from each path in order until it finds a valid
|
137
|
+
* path entry, then stop. If the connection information contained in that path is invalid, the SQL Lambda will not
|
138
|
+
* attempt to retrieve connection information from subsequent paths in the array.
|
139
|
+
**/
|
140
|
+
readonly connectionUriSsmPath: string | string[];
|
136
141
|
}
|
137
142
|
|
138
143
|
/**
|
@@ -76,7 +76,10 @@ export const isSqlModelDataSourceSecretsManagerDbConnectionConfig = (
|
|
76
76
|
* @returns true if the object is shaped like a SqlModelDataSourceSsmDbConnectionStringConfig
|
77
77
|
*/
|
78
78
|
export const isSqlModelDataSourceSsmDbConnectionStringConfig = (obj: any): obj is SqlModelDataSourceSsmDbConnectionStringConfig => {
|
79
|
-
return (
|
79
|
+
return (
|
80
|
+
(typeof obj === 'object' || typeof obj === 'function') &&
|
81
|
+
(typeof obj.connectionUriSsmPath === 'string' || Array.isArray(obj.connectionUriSsmPath))
|
82
|
+
);
|
80
83
|
};
|
81
84
|
|
82
85
|
/**
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* The asset manager bridges the gap between creation of file assets in the transformer (which provide a name+contents tuple)
|
3
|
-
* with the path method which is used in CDK.
|
4
|
-
*/
|
5
|
-
export declare class AssetManager {
|
6
|
-
private readonly tempAssetDir;
|
7
|
-
readonly resolverAssets: Record<string, string>;
|
8
|
-
addAsset(fileName: string, contents: string): string;
|
9
|
-
private isContentsAReference;
|
10
|
-
private dereferenceContents;
|
11
|
-
private trackResolverAsset;
|
12
|
-
}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.AssetManager = void 0;
|
4
|
-
const fs = require("fs");
|
5
|
-
const path = require("path");
|
6
|
-
const cdk = require("aws-cdk-lib");
|
7
|
-
const TEMP_PREFIX = 'transformer-assets';
|
8
|
-
const FUNCTION_PREFIX = 'functions';
|
9
|
-
const RESOLVER_PREFIX = 'resolvers';
|
10
|
-
/**
|
11
|
-
* The asset manager bridges the gap between creation of file assets in the transformer (which provide a name+contents tuple)
|
12
|
-
* with the path method which is used in CDK.
|
13
|
-
*/
|
14
|
-
class AssetManager {
|
15
|
-
constructor() {
|
16
|
-
this.tempAssetDir = cdk.FileSystem.mkdtemp(TEMP_PREFIX);
|
17
|
-
this.resolverAssets = {};
|
18
|
-
}
|
19
|
-
addAsset(fileName, contents) {
|
20
|
-
this.trackResolverAsset(fileName, contents);
|
21
|
-
const writableContents = this.isContentsAReference(fileName) ? this.dereferenceContents(contents) : contents;
|
22
|
-
const filePath = path.join(this.tempAssetDir, fileName);
|
23
|
-
const fileDirName = path.dirname(filePath);
|
24
|
-
if (!fs.existsSync(fileDirName)) {
|
25
|
-
fs.mkdirSync(fileDirName, { recursive: true });
|
26
|
-
}
|
27
|
-
fs.writeFileSync(filePath, writableContents);
|
28
|
-
return filePath;
|
29
|
-
}
|
30
|
-
isContentsAReference(fileName) {
|
31
|
-
return fileName.startsWith(FUNCTION_PREFIX);
|
32
|
-
}
|
33
|
-
dereferenceContents(contents) {
|
34
|
-
return fs.readFileSync(contents);
|
35
|
-
}
|
36
|
-
trackResolverAsset(fileName, contents) {
|
37
|
-
if (fileName.startsWith(RESOLVER_PREFIX)) {
|
38
|
-
const resolverFileName = fileName.split('/')[1];
|
39
|
-
this.resolverAssets[resolverFileName] = contents;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
exports.AssetManager = AssetManager;
|
44
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXQtbWFuYWdlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9pbnRlcm5hbC9hc3NldC1tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHlCQUF5QjtBQUN6Qiw2QkFBNkI7QUFDN0IsbUNBQW1DO0FBRW5DLE1BQU0sV0FBVyxHQUFHLG9CQUFvQixDQUFDO0FBQ3pDLE1BQU0sZUFBZSxHQUFHLFdBQVcsQ0FBQztBQUNwQyxNQUFNLGVBQWUsR0FBRyxXQUFXLENBQUM7QUFFcEM7OztHQUdHO0FBQ0gsTUFBYSxZQUFZO0lBQXpCO1FBQ21CLGlCQUFZLEdBQVcsR0FBRyxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM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W5nLCBjb250ZW50czogc3RyaW5nKTogdm9pZCB7XG4gICAgaWYgKGZpbGVOYW1lLnN0YXJ0c1dpdGgoUkVTT0xWRVJfUFJFRklYKSkge1xuICAgICAgY29uc3QgcmVzb2x2ZXJGaWxlTmFtZSA9IGZpbGVOYW1lLnNwbGl0KCcvJylbMV07XG4gICAgICB0aGlzLnJlc29sdmVyQXNzZXRzW3Jlc29sdmVyRmlsZU5hbWVdID0gY29udGVudHM7XG4gICAgfVxuICB9XG59XG4iXX0=
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { AssetProvider, S3Asset, AssetProps } from '@aws-amplify/graphql-transformer-interfaces';
|
2
|
-
import { Construct } from 'constructs';
|
3
|
-
export declare class AssetManager {
|
4
|
-
private assetProvider;
|
5
|
-
createAsset(scope: Construct, name: string, props: AssetProps): S3Asset;
|
6
|
-
private getAssetProvider;
|
7
|
-
setAssetProvider(provider: AssetProvider): void;
|
8
|
-
}
|
9
|
-
export declare const assetManager: AssetManager;
|
10
|
-
//# sourceMappingURL=asset-manager.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"asset-manager.d.ts","sourceRoot":"","sources":["../../src/transformer-context/asset-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,qBAAa,YAAY;IACvB,OAAO,CAAC,aAAa,CAA4B;IAE1C,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO;IAI9E,OAAO,CAAC,gBAAgB;IAOjB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;CAGvD;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
package/node_modules/@aws-amplify/graphql-transformer-core/lib/transformer-context/asset-manager.js
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.assetManager = exports.AssetManager = void 0;
|
4
|
-
class AssetManager {
|
5
|
-
createAsset(scope, name, props) {
|
6
|
-
return this.getAssetProvider().provide(scope, name, props);
|
7
|
-
}
|
8
|
-
getAssetProvider() {
|
9
|
-
if (!this.assetProvider) {
|
10
|
-
throw new Error('AssetProvider not initialized');
|
11
|
-
}
|
12
|
-
return this.assetProvider;
|
13
|
-
}
|
14
|
-
setAssetProvider(provider) {
|
15
|
-
this.assetProvider = provider;
|
16
|
-
}
|
17
|
-
}
|
18
|
-
exports.AssetManager = AssetManager;
|
19
|
-
exports.assetManager = new AssetManager();
|
20
|
-
//# sourceMappingURL=asset-manager.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"asset-manager.js","sourceRoot":"","sources":["../../src/transformer-context/asset-manager.ts"],"names":[],"mappings":";;;AAGA,MAAa,YAAY;IAGhB,WAAW,CAAC,KAAgB,EAAE,IAAY,EAAE,KAAiB;QAClE,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEM,gBAAgB,CAAC,QAAuB;QAC7C,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;IAChC,CAAC;CACF;AAjBD,oCAiBC;AAEY,QAAA,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC"}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import * as fs from 'fs';
|
2
|
-
import * as path from 'path';
|
3
|
-
import * as cdk from 'aws-cdk-lib';
|
4
|
-
|
5
|
-
const TEMP_PREFIX = 'transformer-assets';
|
6
|
-
const FUNCTION_PREFIX = 'functions';
|
7
|
-
const RESOLVER_PREFIX = 'resolvers';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* The asset manager bridges the gap between creation of file assets in the transformer (which provide a name+contents tuple)
|
11
|
-
* with the path method which is used in CDK.
|
12
|
-
*/
|
13
|
-
export class AssetManager {
|
14
|
-
private readonly tempAssetDir: string = cdk.FileSystem.mkdtemp(TEMP_PREFIX);
|
15
|
-
public readonly resolverAssets: Record<string, string> = {};
|
16
|
-
|
17
|
-
public addAsset(fileName: string, contents: string): string {
|
18
|
-
this.trackResolverAsset(fileName, contents);
|
19
|
-
const writableContents = this.isContentsAReference(fileName) ? this.dereferenceContents(contents) : contents;
|
20
|
-
const filePath = path.join(this.tempAssetDir, fileName);
|
21
|
-
const fileDirName = path.dirname(filePath);
|
22
|
-
if (!fs.existsSync(fileDirName)) {
|
23
|
-
fs.mkdirSync(fileDirName, { recursive: true });
|
24
|
-
}
|
25
|
-
fs.writeFileSync(filePath, writableContents);
|
26
|
-
return filePath;
|
27
|
-
}
|
28
|
-
|
29
|
-
private isContentsAReference(fileName: string): boolean {
|
30
|
-
return fileName.startsWith(FUNCTION_PREFIX);
|
31
|
-
}
|
32
|
-
|
33
|
-
private dereferenceContents(contents: string): Buffer {
|
34
|
-
return fs.readFileSync(contents);
|
35
|
-
}
|
36
|
-
|
37
|
-
private trackResolverAsset(fileName: string, contents: string): void {
|
38
|
-
if (fileName.startsWith(RESOLVER_PREFIX)) {
|
39
|
-
const resolverFileName = fileName.split('/')[1];
|
40
|
-
this.resolverAssets[resolverFileName] = contents;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|