@aws-amplify/cli-internal-gen2-migration-experimental-alpha 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/adr/001-refactor-gen2-migration-generate.md +413 -0
- package/adr/002-refactor-gen2-migration-refactor.md +593 -0
- package/adr/003-gen2-migration-assess.md +414 -0
- package/adr/004-gen2-migration-validation-modeling.md +336 -0
- package/aws-amplify-cli-internal-gen2-migration-experimental-alpha-0.7.0.tgz +0 -0
- package/bin/amplify +1 -1
- package/lib/commands/drift-detection/detect-local-drift.d.ts +1 -2
- package/lib/commands/drift-detection/detect-local-drift.d.ts.map +1 -1
- package/lib/commands/drift-detection/detect-local-drift.js +19 -6
- package/lib/commands/drift-detection/detect-local-drift.js.map +1 -1
- package/lib/commands/drift-detection/detect-stack-drift.d.ts +20 -9
- package/lib/commands/drift-detection/detect-stack-drift.d.ts.map +1 -1
- package/lib/commands/drift-detection/detect-stack-drift.js +121 -151
- package/lib/commands/drift-detection/detect-stack-drift.js.map +1 -1
- package/lib/commands/drift-detection/detect-template-drift.d.ts +8 -21
- package/lib/commands/drift-detection/detect-template-drift.d.ts.map +1 -1
- package/lib/commands/drift-detection/detect-template-drift.js +81 -89
- package/lib/commands/drift-detection/detect-template-drift.js.map +1 -1
- package/lib/commands/drift-detection/index.d.ts +2 -3
- package/lib/commands/drift-detection/index.d.ts.map +1 -1
- package/lib/commands/drift-detection/index.js +1 -3
- package/lib/commands/drift-detection/index.js.map +1 -1
- package/lib/commands/drift-detection/services/amplify-config-service.d.ts +0 -1
- package/lib/commands/drift-detection/services/amplify-config-service.d.ts.map +1 -1
- package/lib/commands/drift-detection/services/amplify-config-service.js +0 -16
- package/lib/commands/drift-detection/services/amplify-config-service.js.map +1 -1
- package/lib/commands/drift-detection/services/cloudformation-service.d.ts +2 -4
- package/lib/commands/drift-detection/services/cloudformation-service.d.ts.map +1 -1
- package/lib/commands/drift-detection/services/cloudformation-service.js +7 -11
- package/lib/commands/drift-detection/services/cloudformation-service.js.map +1 -1
- package/lib/commands/drift-detection/services/drift-formatter.d.ts +3 -70
- package/lib/commands/drift-detection/services/drift-formatter.d.ts.map +1 -1
- package/lib/commands/drift-detection/services/drift-formatter.js +148 -603
- package/lib/commands/drift-detection/services/drift-formatter.js.map +1 -1
- package/lib/commands/drift-detection/services/index.d.ts +1 -2
- package/lib/commands/drift-detection/services/index.d.ts.map +1 -1
- package/lib/commands/drift-detection/services/index.js +2 -4
- package/lib/commands/drift-detection/services/index.js.map +1 -1
- package/lib/commands/drift.d.ts +7 -18
- package/lib/commands/drift.d.ts.map +1 -1
- package/lib/commands/drift.js +71 -172
- package/lib/commands/drift.js.map +1 -1
- package/lib/commands/gen2-migration/_infra/aws-clients.d.ts +31 -0
- package/lib/commands/gen2-migration/_infra/aws-clients.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/aws-clients.js +64 -0
- package/lib/commands/gen2-migration/_infra/aws-clients.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/categories.d.ts +2 -0
- package/lib/commands/gen2-migration/_infra/categories.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/categories.js +32 -0
- package/lib/commands/gen2-migration/_infra/categories.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/cfn-template.d.ts +52 -0
- package/lib/commands/gen2-migration/_infra/cfn-template.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/cfn-template.js +21 -0
- package/lib/commands/gen2-migration/_infra/cfn-template.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/operation.d.ts +16 -0
- package/lib/commands/gen2-migration/_infra/operation.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/operation.js +3 -0
- package/lib/commands/gen2-migration/_infra/operation.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/plan.d.ts +21 -0
- package/lib/commands/gen2-migration/_infra/plan.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/plan.js +111 -0
- package/lib/commands/gen2-migration/_infra/plan.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/planner.d.ts +5 -0
- package/lib/commands/gen2-migration/_infra/planner.d.ts.map +1 -0
- package/lib/commands/gen2-migration/{generate/custom-resources/types.js → _infra/planner.js} +1 -1
- package/lib/commands/gen2-migration/_infra/planner.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/spinning-logger.d.ts +25 -0
- package/lib/commands/gen2-migration/_infra/spinning-logger.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/spinning-logger.js +115 -0
- package/lib/commands/gen2-migration/_infra/spinning-logger.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/stateful-resources.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/stateful-resources.js.map +1 -0
- package/lib/commands/gen2-migration/_infra/step.d.ts +15 -0
- package/lib/commands/gen2-migration/_infra/step.d.ts.map +1 -0
- package/lib/commands/gen2-migration/_infra/step.js +13 -0
- package/lib/commands/gen2-migration/_infra/step.js.map +1 -0
- package/lib/commands/gen2-migration/{_validations.d.ts → _infra/validations.d.ts} +6 -7
- package/lib/commands/gen2-migration/_infra/validations.d.ts.map +1 -0
- package/lib/commands/gen2-migration/{_validations.js → _infra/validations.js} +24 -60
- package/lib/commands/gen2-migration/_infra/validations.js.map +1 -0
- package/lib/commands/gen2-migration/assess/analytics/kinesis.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/analytics/kinesis.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/analytics/kinesis.assessor.js +15 -0
- package/lib/commands/gen2-migration/assess/analytics/kinesis.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/api/data.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/api/data.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/api/data.assessor.js +25 -0
- package/lib/commands/gen2-migration/assess/api/data.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/api/rest-api.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/api/rest-api.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/api/rest-api.assessor.js +25 -0
- package/lib/commands/gen2-migration/assess/api/rest-api.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/assessment.d.ts +42 -0
- package/lib/commands/gen2-migration/assess/assessment.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/assessment.js +118 -0
- package/lib/commands/gen2-migration/assess/assessment.js.map +1 -0
- package/lib/commands/gen2-migration/assess/assessor.d.ts +5 -0
- package/lib/commands/gen2-migration/assess/assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/{generate/types.js → assess/assessor.js} +1 -1
- package/lib/commands/gen2-migration/assess/assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/auth/auth-cognito.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/auth/auth-cognito.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/auth/auth-cognito.assessor.js +30 -0
- package/lib/commands/gen2-migration/assess/auth/auth-cognito.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/auth/auth-user-pool-groups.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/auth/auth-user-pool-groups.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/auth/auth-user-pool-groups.assessor.js +24 -0
- package/lib/commands/gen2-migration/assess/auth/auth-user-pool-groups.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/function/function.assessor.d.ts +12 -0
- package/lib/commands/gen2-migration/assess/function/function.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/function/function.assessor.js +40 -0
- package/lib/commands/gen2-migration/assess/function/function.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/geo/geo-geofence-collection.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/geo/geo-geofence-collection.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/geo/geo-geofence-collection.assessor.js +19 -0
- package/lib/commands/gen2-migration/assess/geo/geo-geofence-collection.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/geo/geo-map.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/geo/geo-map.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/geo/geo-map.assessor.js +15 -0
- package/lib/commands/gen2-migration/assess/geo/geo-map.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/geo/geo-place-index.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/geo/geo-place-index.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/geo/geo-place-index.assessor.js +15 -0
- package/lib/commands/gen2-migration/assess/geo/geo-place-index.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/storage/dynamodb.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/storage/dynamodb.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/storage/dynamodb.assessor.js +25 -0
- package/lib/commands/gen2-migration/assess/storage/dynamodb.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess/storage/s3.assessor.d.ts +10 -0
- package/lib/commands/gen2-migration/assess/storage/s3.assessor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess/storage/s3.assessor.js +25 -0
- package/lib/commands/gen2-migration/assess/storage/s3.assessor.js.map +1 -0
- package/lib/commands/gen2-migration/assess.d.ts +9 -0
- package/lib/commands/gen2-migration/assess.d.ts.map +1 -0
- package/lib/commands/gen2-migration/assess.js +80 -0
- package/lib/commands/gen2-migration/assess.js.map +1 -0
- package/lib/commands/gen2-migration/decommission.d.ts +6 -5
- package/lib/commands/gen2-migration/decommission.d.ts.map +1 -1
- package/lib/commands/gen2-migration/decommission.js +82 -25
- package/lib/commands/gen2-migration/decommission.js.map +1 -1
- package/lib/commands/gen2-migration/generate/_infra/aws-fetcher.d.ts +32 -0
- package/lib/commands/gen2-migration/generate/_infra/aws-fetcher.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/_infra/aws-fetcher.js +136 -0
- package/lib/commands/gen2-migration/generate/_infra/aws-fetcher.js.map +1 -0
- package/lib/commands/gen2-migration/generate/_infra/files.d.ts +2 -0
- package/lib/commands/gen2-migration/generate/_infra/files.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/{codegen-head/directory_exists.js → _infra/files.js} +4 -5
- package/lib/commands/gen2-migration/generate/_infra/files.js.map +1 -0
- package/lib/commands/gen2-migration/generate/_infra/gen1-app.d.ts +40 -0
- package/lib/commands/gen2-migration/generate/_infra/gen1-app.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/_infra/gen1-app.js +198 -0
- package/lib/commands/gen2-migration/generate/_infra/gen1-app.js.map +1 -0
- package/lib/commands/gen2-migration/generate/_infra/ts.d.ts +24 -0
- package/lib/commands/gen2-migration/generate/_infra/ts.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/_infra/ts.js +128 -0
- package/lib/commands/gen2-migration/generate/_infra/ts.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/cfn-condition-resolver.d.ts +18 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/cfn-condition-resolver.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/cfn-condition-resolver.js +126 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/cfn-condition-resolver.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis-cfn-converter.d.ts +33 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis-cfn-converter.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/{unsupported/cdk-from-cfn.js → amplify/analytics/kinesis-cfn-converter.js} +94 -52
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis-cfn-converter.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.generator.d.ts +14 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.generator.js +69 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.renderer.d.ts +18 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.renderer.js +68 -0
- package/lib/commands/gen2-migration/generate/amplify/analytics/kinesis.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.generator.d.ts +24 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.generator.js +233 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.renderer.d.ts +78 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.renderer.js +491 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/auth.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.generator.d.ts +15 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.generator.js +75 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.renderer.d.ts +13 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.renderer.js +33 -0
- package/lib/commands/gen2-migration/generate/amplify/auth/reference-auth.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/backend.generator.d.ts +22 -0
- package/lib/commands/gen2-migration/generate/amplify/backend.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/backend.generator.js +150 -0
- package/lib/commands/gen2-migration/generate/amplify/backend.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/{custom-resources/transformer → amplify/custom-resources}/amplify-helper-transformer.d.ts +4 -0
- package/lib/commands/gen2-migration/generate/amplify/custom-resources/amplify-helper-transformer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/custom-resources/amplify-helper-transformer.js +333 -0
- package/lib/commands/gen2-migration/generate/amplify/custom-resources/amplify-helper-transformer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/custom-resources/custom.generator.d.ts +17 -0
- package/lib/commands/gen2-migration/generate/amplify/custom-resources/custom.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/custom-resources/custom.generator.js +190 -0
- package/lib/commands/gen2-migration/generate/amplify/custom-resources/custom.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.generator.d.ts +15 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.generator.js +112 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.renderer.d.ts +22 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.renderer.js +167 -0
- package/lib/commands/gen2-migration/generate/amplify/data/data.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.generator.d.ts +49 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.generator.js +626 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.renderer.d.ts +21 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.renderer.js +105 -0
- package/lib/commands/gen2-migration/generate/amplify/function/function.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo-cfn-converter.d.ts +49 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo-cfn-converter.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo-cfn-converter.js +239 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo-cfn-converter.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.generator.d.ts +14 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.generator.js +70 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.renderer.d.ts +13 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.renderer.js +161 -0
- package/lib/commands/gen2-migration/generate/amplify/geo/geo.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/package.json.generator.d.ts +8 -0
- package/lib/commands/gen2-migration/generate/amplify/package.json.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/package.json.generator.js +28 -0
- package/lib/commands/gen2-migration/generate/amplify/package.json.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.d.ts +15 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.js +162 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.renderer.d.ts +51 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.renderer.js +269 -0
- package/lib/commands/gen2-migration/generate/amplify/rest-api/rest-api.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.generator.d.ts +14 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.generator.js +96 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.renderer.d.ts +30 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.renderer.js +90 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/dynamodb.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.generator.d.ts +22 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.generator.js +132 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.renderer.d.ts +31 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.renderer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.renderer.js +137 -0
- package/lib/commands/gen2-migration/generate/amplify/storage/s3.renderer.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/tsconfig.generator.d.ts +8 -0
- package/lib/commands/gen2-migration/generate/amplify/tsconfig.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify/tsconfig.generator.js +45 -0
- package/lib/commands/gen2-migration/generate/amplify/tsconfig.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify.yml.generator.d.ts +9 -0
- package/lib/commands/gen2-migration/generate/amplify.yml.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/amplify.yml.generator.js +112 -0
- package/lib/commands/gen2-migration/generate/amplify.yml.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/gitignore.generator.d.ts +6 -0
- package/lib/commands/gen2-migration/generate/gitignore.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/gitignore.generator.js +45 -0
- package/lib/commands/gen2-migration/generate/gitignore.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate/package.json.generator.d.ts +12 -0
- package/lib/commands/gen2-migration/generate/package.json.generator.d.ts.map +1 -0
- package/lib/commands/gen2-migration/generate/package.json.generator.js +83 -0
- package/lib/commands/gen2-migration/generate/package.json.generator.js.map +1 -0
- package/lib/commands/gen2-migration/generate.d.ts +6 -5
- package/lib/commands/gen2-migration/generate.d.ts.map +1 -1
- package/lib/commands/gen2-migration/generate.js +232 -17
- package/lib/commands/gen2-migration/generate.js.map +1 -1
- package/lib/commands/gen2-migration/lock.d.ts +10 -6
- package/lib/commands/gen2-migration/lock.d.ts.map +1 -1
- package/lib/commands/gen2-migration/lock.js +182 -64
- package/lib/commands/gen2-migration/lock.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/analytics/analytics-forward.d.ts +9 -0
- package/lib/commands/gen2-migration/refactor/analytics/analytics-forward.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/analytics/analytics-forward.js +19 -0
- package/lib/commands/gen2-migration/refactor/analytics/analytics-forward.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/analytics/analytics-rollback.d.ts +9 -0
- package/lib/commands/gen2-migration/refactor/analytics/analytics-rollback.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/analytics/analytics-rollback.js +26 -0
- package/lib/commands/gen2-migration/refactor/analytics/analytics-rollback.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-forward.d.ts +21 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-forward.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-forward.js +87 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-forward.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-rollback.d.ts +9 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-rollback.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-rollback.js +44 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-cognito-rollback.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-forward.d.ts +11 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-forward.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-forward.js +33 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-forward.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-rollback.d.ts +9 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-rollback.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-rollback.js +26 -0
- package/lib/commands/gen2-migration/refactor/auth/auth-user-pool-groups-rollback.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/cfn.d.ts +41 -0
- package/lib/commands/gen2-migration/refactor/cfn.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/cfn.js +337 -0
- package/lib/commands/gen2-migration/refactor/cfn.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/index.d.ts +1 -1
- package/lib/commands/gen2-migration/refactor/index.d.ts.map +1 -1
- package/lib/commands/gen2-migration/refactor/index.js +1 -1
- package/lib/commands/gen2-migration/refactor/index.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/oauth-values-retriever.d.ts +23 -11
- package/lib/commands/gen2-migration/refactor/oauth-values-retriever.d.ts.map +1 -1
- package/lib/commands/gen2-migration/refactor/oauth-values-retriever.js +53 -45
- package/lib/commands/gen2-migration/refactor/oauth-values-retriever.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-condition-resolver.d.ts +2 -11
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-condition-resolver.d.ts.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-condition-resolver.js +89 -123
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-condition-resolver.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-dependency-resolver.d.ts +2 -7
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-dependency-resolver.d.ts.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-dependency-resolver.js +6 -22
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-dependency-resolver.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-output-resolver.d.ts +8 -12
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-output-resolver.d.ts.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-output-resolver.js +105 -127
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-output-resolver.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-parameter-resolver.d.ts +2 -8
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-parameter-resolver.d.ts.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-parameter-resolver.js +36 -41
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-parameter-resolver.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-tree-walker.d.ts +3 -0
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-tree-walker.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-tree-walker.js +18 -0
- package/lib/commands/gen2-migration/refactor/resolvers/cfn-tree-walker.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/stack-facade.d.ts +13 -0
- package/lib/commands/gen2-migration/refactor/stack-facade.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/stack-facade.js +39 -0
- package/lib/commands/gen2-migration/refactor/stack-facade.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-forward.d.ts +8 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-forward.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-forward.js +18 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-forward.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-rollback.d.ts +9 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-rollback.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-rollback.js +26 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-dynamo-rollback.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-forward.d.ts +10 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-forward.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-forward.js +36 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-forward.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-rollback.d.ts +9 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-rollback.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-rollback.js +26 -0
- package/lib/commands/gen2-migration/refactor/storage/storage-rollback.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/utils.d.ts +1 -1
- package/lib/commands/gen2-migration/refactor/utils.d.ts.map +1 -1
- package/lib/commands/gen2-migration/refactor/utils.js +2 -2
- package/lib/commands/gen2-migration/refactor/utils.js.map +1 -1
- package/lib/commands/gen2-migration/refactor/workflow/category-refactorer.d.ts +52 -0
- package/lib/commands/gen2-migration/refactor/workflow/category-refactorer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/workflow/category-refactorer.js +212 -0
- package/lib/commands/gen2-migration/refactor/workflow/category-refactorer.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/workflow/forward-category-refactorer.d.ts +15 -0
- package/lib/commands/gen2-migration/refactor/workflow/forward-category-refactorer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/workflow/forward-category-refactorer.js +148 -0
- package/lib/commands/gen2-migration/refactor/workflow/forward-category-refactorer.js.map +1 -0
- package/lib/commands/gen2-migration/refactor/workflow/rollback-category-refactorer.d.ts +13 -0
- package/lib/commands/gen2-migration/refactor/workflow/rollback-category-refactorer.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor/workflow/rollback-category-refactorer.js +123 -0
- package/lib/commands/gen2-migration/refactor/workflow/rollback-category-refactorer.js.map +1 -0
- package/lib/commands/gen2-migration/refactor.d.ts +11 -0
- package/lib/commands/gen2-migration/refactor.d.ts.map +1 -0
- package/lib/commands/gen2-migration/refactor.js +189 -0
- package/lib/commands/gen2-migration/refactor.js.map +1 -0
- package/lib/commands/gen2-migration.d.ts +0 -12
- package/lib/commands/gen2-migration.d.ts.map +1 -1
- package/lib/commands/gen2-migration.js +82 -111
- package/lib/commands/gen2-migration.js.map +1 -1
- package/package.json +21 -12
- package/aws-amplify-cli-internal-gen2-migration-experimental-alpha-0.6.0.tgz +0 -0
- package/lib/commands/drift-detection/services/file-service.d.ts +0 -7
- package/lib/commands/drift-detection/services/file-service.d.ts.map +0 -1
- package/lib/commands/drift-detection/services/file-service.js +0 -53
- package/lib/commands/drift-detection/services/file-service.js.map +0 -1
- package/lib/commands/gen2-migration/_step.d.ts +0 -17
- package/lib/commands/gen2-migration/_step.d.ts.map +0 -1
- package/lib/commands/gen2-migration/_step.js +0 -16
- package/lib/commands/gen2-migration/_step.js.map +0 -1
- package/lib/commands/gen2-migration/_validations.d.ts.map +0 -1
- package/lib/commands/gen2-migration/_validations.js.map +0 -1
- package/lib/commands/gen2-migration/cleanup.d.ts +0 -8
- package/lib/commands/gen2-migration/cleanup.d.ts.map +0 -1
- package/lib/commands/gen2-migration/cleanup.js +0 -21
- package/lib/commands/gen2-migration/cleanup.js.map +0 -1
- package/lib/commands/gen2-migration/clone.d.ts +0 -8
- package/lib/commands/gen2-migration/clone.d.ts.map +0 -1
- package/lib/commands/gen2-migration/clone.js +0 -21
- package/lib/commands/gen2-migration/clone.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/auth/index.d.ts +0 -24
- package/lib/commands/gen2-migration/generate/adapters/auth/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/auth/index.js +0 -297
- package/lib/commands/gen2-migration/generate/adapters/auth/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/auth/index.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/adapters/auth/index.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/auth/index.test.js +0 -140
- package/lib/commands/gen2-migration/generate/adapters/auth/index.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/data/index.d.ts +0 -5
- package/lib/commands/gen2-migration/generate/adapters/data/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/data/index.js +0 -17
- package/lib/commands/gen2-migration/generate/adapters/data/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.d.ts +0 -10
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.js +0 -43
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.test.js +0 -34
- package/lib/commands/gen2-migration/generate/adapters/functions/api-trigger-detector.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/functions/index.d.ts +0 -18
- package/lib/commands/gen2-migration/generate/adapters/functions/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/functions/index.js +0 -85
- package/lib/commands/gen2-migration/generate/adapters/functions/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/project/index.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/adapters/project/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/project/index.js +0 -7
- package/lib/commands/gen2-migration/generate/adapters/project/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.d.ts +0 -31
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.js +0 -34
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.js +0 -181
- package/lib/commands/gen2-migration/generate/adapters/storage/gen1_storage_codegen_adapter.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/index.d.ts +0 -3
- package/lib/commands/gen2-migration/generate/adapters/storage/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/index.js +0 -10
- package/lib/commands/gen2-migration/generate/adapters/storage/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.d.ts +0 -25
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.js +0 -76
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.js.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.test.js +0 -125
- package/lib/commands/gen2-migration/generate/adapters/storage/storage_access.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/backend/synthesizer.d.ts +0 -91
- package/lib/commands/gen2-migration/generate/backend/synthesizer.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/backend/synthesizer.js +0 -1014
- package/lib/commands/gen2-migration/generate/backend/synthesizer.js.map +0 -1
- package/lib/commands/gen2-migration/generate/backend/synthesizer.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/backend/synthesizer.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/backend/synthesizer.test.js +0 -777
- package/lib/commands/gen2-migration/generate/backend/synthesizer.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.d.ts +0 -14
- package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.js +0 -82
- package/lib/commands/gen2-migration/generate/codegen-head/amplify_stack_parser.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/analytics.d.ts +0 -10
- package/lib/commands/gen2-migration/generate/codegen-head/analytics.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/analytics.js +0 -11
- package/lib/commands/gen2-migration/generate/codegen-head/analytics.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/api-cfn-access.d.ts +0 -7
- package/lib/commands/gen2-migration/generate/codegen-head/api-cfn-access.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/api-cfn-access.js +0 -80
- package/lib/commands/gen2-migration/generate/codegen-head/api-cfn-access.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.d.ts +0 -13
- package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.js +0 -59
- package/lib/commands/gen2-migration/generate/codegen-head/app_analytics_definition_fetcher.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.d.ts +0 -24
- package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.js +0 -167
- package/lib/commands/gen2-migration/generate/codegen-head/app_auth_definition_fetcher.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.d.ts +0 -21
- package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.js +0 -135
- package/lib/commands/gen2-migration/generate/codegen-head/app_functions_definition_fetcher.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.d.ts +0 -23
- package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.js +0 -181
- package/lib/commands/gen2-migration/generate/codegen-head/app_storage_definition_fetcher.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/auth_access_analyzer.d.ts +0 -12
- package/lib/commands/gen2-migration/generate/codegen-head/auth_access_analyzer.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/auth_access_analyzer.js +0 -157
- package/lib/commands/gen2-migration/generate/codegen-head/auth_access_analyzer.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.d.ts +0 -10
- package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.js +0 -48
- package/lib/commands/gen2-migration/generate/codegen-head/backend_downloader.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.d.ts +0 -11
- package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.js +0 -38
- package/lib/commands/gen2-migration/generate/codegen-head/backend_environment_selector.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.d.ts +0 -13
- package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.js +0 -498
- package/lib/commands/gen2-migration/generate/codegen-head/command-handlers.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.d.ts +0 -47
- package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.js +0 -222
- package/lib/commands/gen2-migration/generate/codegen-head/data_definition_fetcher.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.d.ts +0 -10
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.js +0 -59
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.test.js +0 -90
- package/lib/commands/gen2-migration/generate/codegen-head/data_model_access_parser.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/directory_exists.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.d.ts +0 -14
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.js +0 -100
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.test.js +0 -69
- package/lib/commands/gen2-migration/generate/codegen-head/dynamodb_cfn_access_parser.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/format.d.ts +0 -8
- package/lib/commands/gen2-migration/generate/codegen-head/format.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/format.js +0 -66
- package/lib/commands/gen2-migration/generate/codegen-head/format.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/logger.d.ts +0 -15
- package/lib/commands/gen2-migration/generate/codegen-head/logger.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/logger.js +0 -14
- package/lib/commands/gen2-migration/generate/codegen-head/logger.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/printer.d.ts +0 -26
- package/lib/commands/gen2-migration/generate/codegen-head/printer.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/printer.js +0 -103
- package/lib/commands/gen2-migration/generate/codegen-head/printer.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.d.ts +0 -13
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.js +0 -66
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.js.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.test.js +0 -97
- package/lib/commands/gen2-migration/generate/codegen-head/s3_cfn_access_parser.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/core/migration-pipeline.d.ts +0 -26
- package/lib/commands/gen2-migration/generate/core/migration-pipeline.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/core/migration-pipeline.js +0 -269
- package/lib/commands/gen2-migration/generate/core/migration-pipeline.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.d.ts +0 -7
- package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.js +0 -84
- package/lib/commands/gen2-migration/generate/custom-resources/generator/backend-updater.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.d.ts +0 -8
- package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.js +0 -105
- package/lib/commands/gen2-migration/generate/custom-resources/generator/dependency-merger.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.d.ts +0 -5
- package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.js +0 -88
- package/lib/commands/gen2-migration/generate/custom-resources/generator/file-converter.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.d.ts +0 -8
- package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.js +0 -36
- package/lib/commands/gen2-migration/generate/custom-resources/generator/gen2-file-generator.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.d.ts +0 -5
- package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.js +0 -81
- package/lib/commands/gen2-migration/generate/custom-resources/parser/cdk-stack-parser.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.d.ts +0 -15
- package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.js +0 -35
- package/lib/commands/gen2-migration/generate/custom-resources/parser/pattern-detector.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.d.ts +0 -5
- package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.js +0 -66
- package/lib/commands/gen2-migration/generate/custom-resources/scanner/custom-resource-scanner.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/transformer/amplify-helper-transformer.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/transformer/amplify-helper-transformer.js +0 -178
- package/lib/commands/gen2-migration/generate/custom-resources/transformer/amplify-helper-transformer.js.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/types.d.ts +0 -38
- package/lib/commands/gen2-migration/generate/custom-resources/types.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/custom-resources/types.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/analytics/index.d.ts +0 -9
- package/lib/commands/gen2-migration/generate/generators/analytics/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/analytics/index.js +0 -40
- package/lib/commands/gen2-migration/generate/generators/analytics/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/auth/index.d.ts +0 -107
- package/lib/commands/gen2-migration/generate/generators/auth/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/auth/index.js +0 -313
- package/lib/commands/gen2-migration/generate/generators/auth/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/auth/index.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/generators/auth/index.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/auth/index.test.js +0 -566
- package/lib/commands/gen2-migration/generate/generators/auth/index.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/data/index.d.ts +0 -35
- package/lib/commands/gen2-migration/generate/generators/data/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/data/index.js +0 -185
- package/lib/commands/gen2-migration/generate/generators/data/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/data/index.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/generators/data/index.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/data/index.test.js +0 -47
- package/lib/commands/gen2-migration/generate/generators/data/index.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/index.d.ts +0 -53
- package/lib/commands/gen2-migration/generate/generators/functions/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/index.js +0 -125
- package/lib/commands/gen2-migration/generate/generators/functions/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/lambda.d.ts +0 -6
- package/lib/commands/gen2-migration/generate/generators/functions/lambda.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/lambda.js +0 -16
- package/lib/commands/gen2-migration/generate/generators/functions/lambda.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.d.ts +0 -3
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.js +0 -106
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.test.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.test.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.test.js +0 -120
- package/lib/commands/gen2-migration/generate/generators/functions/lambda_env_generator.test.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/storage/access.d.ts +0 -4
- package/lib/commands/gen2-migration/generate/generators/storage/access.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/storage/access.js +0 -73
- package/lib/commands/gen2-migration/generate/generators/storage/access.js.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/storage/index.d.ts +0 -37
- package/lib/commands/gen2-migration/generate/generators/storage/index.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/generators/storage/index.js +0 -78
- package/lib/commands/gen2-migration/generate/generators/storage/index.js.map +0 -1
- package/lib/commands/gen2-migration/generate/npm_package/renderer.d.ts +0 -27
- package/lib/commands/gen2-migration/generate/npm_package/renderer.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/npm_package/renderer.js +0 -28
- package/lib/commands/gen2-migration/generate/npm_package/renderer.js.map +0 -1
- package/lib/commands/gen2-migration/generate/render_pipeline.d.ts +0 -9
- package/lib/commands/gen2-migration/generate/render_pipeline.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/render_pipeline.js +0 -15
- package/lib/commands/gen2-migration/generate/render_pipeline.js.map +0 -1
- package/lib/commands/gen2-migration/generate/renderers/ensure_directory.d.ts +0 -7
- package/lib/commands/gen2-migration/generate/renderers/ensure_directory.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/renderers/ensure_directory.js +0 -17
- package/lib/commands/gen2-migration/generate/renderers/ensure_directory.js.map +0 -1
- package/lib/commands/gen2-migration/generate/renderers/package_json.d.ts +0 -8
- package/lib/commands/gen2-migration/generate/renderers/package_json.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/renderers/package_json.js +0 -15
- package/lib/commands/gen2-migration/generate/renderers/package_json.js.map +0 -1
- package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.d.ts +0 -11
- package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.js +0 -22
- package/lib/commands/gen2-migration/generate/renderers/typescript_block_node.js.map +0 -1
- package/lib/commands/gen2-migration/generate/resource/resource.d.ts +0 -20
- package/lib/commands/gen2-migration/generate/resource/resource.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/resource/resource.js +0 -60
- package/lib/commands/gen2-migration/generate/resource/resource.js.map +0 -1
- package/lib/commands/gen2-migration/generate/test_utils/import_regex.d.ts +0 -2
- package/lib/commands/gen2-migration/generate/test_utils/import_regex.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/test_utils/import_regex.js +0 -6
- package/lib/commands/gen2-migration/generate/test_utils/import_regex.js.map +0 -1
- package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.d.ts +0 -4
- package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.js +0 -22
- package/lib/commands/gen2-migration/generate/test_utils/ts_node_printer.js.map +0 -1
- package/lib/commands/gen2-migration/generate/todo_error.d.ts +0 -3
- package/lib/commands/gen2-migration/generate/todo_error.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/todo_error.js +0 -11
- package/lib/commands/gen2-migration/generate/todo_error.js.map +0 -1
- package/lib/commands/gen2-migration/generate/ts_factory_utils.d.ts +0 -3
- package/lib/commands/gen2-migration/generate/ts_factory_utils.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/ts_factory_utils.js +0 -10
- package/lib/commands/gen2-migration/generate/ts_factory_utils.js.map +0 -1
- package/lib/commands/gen2-migration/generate/types.d.ts +0 -4
- package/lib/commands/gen2-migration/generate/types.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/types.js.map +0 -1
- package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.d.ts +0 -26
- package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.d.ts.map +0 -1
- package/lib/commands/gen2-migration/generate/unsupported/cdk-from-cfn.js.map +0 -1
- package/lib/commands/gen2-migration/refactor/cfn-stack-refactor-updater.d.ts +0 -5
- package/lib/commands/gen2-migration/refactor/cfn-stack-refactor-updater.d.ts.map +0 -1
- package/lib/commands/gen2-migration/refactor/cfn-stack-refactor-updater.js +0 -76
- package/lib/commands/gen2-migration/refactor/cfn-stack-refactor-updater.js.map +0 -1
- package/lib/commands/gen2-migration/refactor/cfn-stack-updater.d.ts +0 -6
- package/lib/commands/gen2-migration/refactor/cfn-stack-updater.d.ts.map +0 -1
- package/lib/commands/gen2-migration/refactor/cfn-stack-updater.js +0 -52
- package/lib/commands/gen2-migration/refactor/cfn-stack-updater.js.map +0 -1
- package/lib/commands/gen2-migration/refactor/generators/category-template-generator.d.ts +0 -40
- package/lib/commands/gen2-migration/refactor/generators/category-template-generator.d.ts.map +0 -1
- package/lib/commands/gen2-migration/refactor/generators/category-template-generator.js +0 -321
- package/lib/commands/gen2-migration/refactor/generators/category-template-generator.js.map +0 -1
- package/lib/commands/gen2-migration/refactor/generators/template-generator.d.ts +0 -48
- package/lib/commands/gen2-migration/refactor/generators/template-generator.d.ts.map +0 -1
- package/lib/commands/gen2-migration/refactor/generators/template-generator.js +0 -513
- package/lib/commands/gen2-migration/refactor/generators/template-generator.js.map +0 -1
- package/lib/commands/gen2-migration/refactor/refactor.d.ts +0 -19
- package/lib/commands/gen2-migration/refactor/refactor.d.ts.map +0 -1
- package/lib/commands/gen2-migration/refactor/refactor.js +0 -241
- package/lib/commands/gen2-migration/refactor/refactor.js.map +0 -1
- package/lib/commands/gen2-migration/refactor/types.d.ts +0 -128
- package/lib/commands/gen2-migration/refactor/types.d.ts.map +0 -1
- package/lib/commands/gen2-migration/refactor/types.js +0 -59
- package/lib/commands/gen2-migration/refactor/types.js.map +0 -1
- package/lib/commands/gen2-migration/shift.d.ts +0 -8
- package/lib/commands/gen2-migration/shift.d.ts.map +0 -1
- package/lib/commands/gen2-migration/shift.js +0 -21
- package/lib/commands/gen2-migration/shift.js.map +0 -1
- package/lib/commands/gen2-migration/stateful-resources.d.ts.map +0 -1
- package/lib/commands/gen2-migration/stateful-resources.js.map +0 -1
- /package/lib/commands/gen2-migration/{stateful-resources.d.ts → _infra/stateful-resources.d.ts} +0 -0
- /package/lib/commands/gen2-migration/{stateful-resources.js → _infra/stateful-resources.js} +0 -0
|
@@ -1,1014 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BackendSynthesizer = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
|
|
9
|
-
const assert_1 = __importDefault(require("assert"));
|
|
10
|
-
const ts_factory_utils_1 = require("../ts_factory_utils");
|
|
11
|
-
const lambda_env_generator_1 = require("../generators/functions/lambda_env_generator");
|
|
12
|
-
const factory = typescript_1.default.factory;
|
|
13
|
-
class BackendSynthesizer {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.importDurationFlag = false;
|
|
16
|
-
this.oAuthFlag = false;
|
|
17
|
-
this.readWriteAttributeFlag = false;
|
|
18
|
-
this.supportedIdentityProviderFlag = false;
|
|
19
|
-
}
|
|
20
|
-
createPropertyAccessExpression(objectIdentifier, propertyPath) {
|
|
21
|
-
const parts = propertyPath.split('.');
|
|
22
|
-
let expression = objectIdentifier;
|
|
23
|
-
for (let i = 0; i < parts.length; i++) {
|
|
24
|
-
expression = factory.createPropertyAccessExpression(expression, factory.createIdentifier(parts[i]));
|
|
25
|
-
}
|
|
26
|
-
return expression;
|
|
27
|
-
}
|
|
28
|
-
createVariableDeclaration(identifierName, propertyPath) {
|
|
29
|
-
const identifier = factory.createIdentifier(identifierName);
|
|
30
|
-
const propertyAccessExpression = this.createPropertyAccessExpression(factory.createIdentifier('backend'), propertyPath);
|
|
31
|
-
return factory.createVariableDeclaration(identifier, undefined, undefined, propertyAccessExpression);
|
|
32
|
-
}
|
|
33
|
-
createVariableStatement(variableDeclaration) {
|
|
34
|
-
return factory.createVariableStatement([], factory.createVariableDeclarationList([variableDeclaration], typescript_1.default.NodeFlags.Const));
|
|
35
|
-
}
|
|
36
|
-
createImportStatement(identifiers, backendPackageName) {
|
|
37
|
-
return factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports(identifiers.map((identifier) => factory.createImportSpecifier(false, undefined, identifier)))), factory.createStringLiteral(backendPackageName));
|
|
38
|
-
}
|
|
39
|
-
defineBackendCall(backendFunctionIdentifier, properties) {
|
|
40
|
-
const backendFunctionArgs = factory.createObjectLiteralExpression(properties, true);
|
|
41
|
-
return factory.createCallExpression(backendFunctionIdentifier, undefined, [backendFunctionArgs]);
|
|
42
|
-
}
|
|
43
|
-
setPropertyValue(objectIdentifier, propertyPath, value) {
|
|
44
|
-
const propertyAccessExpression = this.createPropertyAccessExpression(objectIdentifier, propertyPath);
|
|
45
|
-
const overrideValue = this.getOverrideValue(value);
|
|
46
|
-
return factory.createExpressionStatement(factory.createAssignment(propertyAccessExpression, overrideValue));
|
|
47
|
-
}
|
|
48
|
-
getOverrideValue(value) {
|
|
49
|
-
if (typeof value === 'number') {
|
|
50
|
-
return factory.createNumericLiteral(value);
|
|
51
|
-
}
|
|
52
|
-
else if (typeof value === 'string') {
|
|
53
|
-
return factory.createStringLiteral(value);
|
|
54
|
-
}
|
|
55
|
-
else if (Array.isArray(value) && value.every((item) => typeof item === 'string')) {
|
|
56
|
-
return factory.createArrayLiteralExpression(value.map((item) => factory.createStringLiteral(item)));
|
|
57
|
-
}
|
|
58
|
-
else if (typeof value === 'boolean') {
|
|
59
|
-
return value ? factory.createTrue() : factory.createFalse();
|
|
60
|
-
}
|
|
61
|
-
else if (typeof value === 'object' && value !== null) {
|
|
62
|
-
const properties = [];
|
|
63
|
-
for (const [key, val] of Object.entries(value)) {
|
|
64
|
-
const property = factory.createPropertyAssignment(factory.createIdentifier(key), this.getOverrideValue(val));
|
|
65
|
-
properties.push(property);
|
|
66
|
-
}
|
|
67
|
-
return factory.createObjectLiteralExpression(properties, true);
|
|
68
|
-
}
|
|
69
|
-
else if (value === undefined) {
|
|
70
|
-
return factory.createIdentifier('undefined');
|
|
71
|
-
}
|
|
72
|
-
throw new TypeError(`Unrecognized type: ${typeof value}`);
|
|
73
|
-
}
|
|
74
|
-
createBooleanPropertyAssignment(identifier, condition) {
|
|
75
|
-
return factory.createPropertyAssignment(factory.createIdentifier(identifier), condition ? factory.createTrue() : factory.createFalse());
|
|
76
|
-
}
|
|
77
|
-
createListPropertyAssignment(identifier, listAttribute) {
|
|
78
|
-
return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createArrayLiteralExpression(listAttribute.map((attribute) => factory.createStringLiteral(attribute))));
|
|
79
|
-
}
|
|
80
|
-
createEnumListPropertyAssignment(identifier, enumIdentifier, listAttribute) {
|
|
81
|
-
return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createArrayLiteralExpression(listAttribute.map((attribute) => factory.createPropertyAccessExpression(factory.createIdentifier(enumIdentifier), factory.createIdentifier(attribute))), true));
|
|
82
|
-
}
|
|
83
|
-
createNumericPropertyAssignment(identifier, numericLiteral) {
|
|
84
|
-
return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createNumericLiteral(numericLiteral));
|
|
85
|
-
}
|
|
86
|
-
createDurationPropertyAssignment(identifier, numericLiteral, durationUnit) {
|
|
87
|
-
const duration = factory.createCallExpression(factory.createIdentifier(`Duration.${durationUnit}`), undefined, [
|
|
88
|
-
factory.createNumericLiteral(numericLiteral),
|
|
89
|
-
]);
|
|
90
|
-
return factory.createPropertyAssignment(factory.createIdentifier(identifier), duration);
|
|
91
|
-
}
|
|
92
|
-
createStringPropertyAssignment(identifier, stringLiteral) {
|
|
93
|
-
return factory.createPropertyAssignment(factory.createIdentifier(identifier), factory.createStringLiteral(stringLiteral));
|
|
94
|
-
}
|
|
95
|
-
createUserPoolClientAssignment(userPoolClient, imports, createConstant) {
|
|
96
|
-
const userPoolClientAttributesMap = new Map();
|
|
97
|
-
userPoolClientAttributesMap.set('ClientSecret', 'generateSecret');
|
|
98
|
-
userPoolClientAttributesMap.set('ReadAttributes', 'readAttributes');
|
|
99
|
-
userPoolClientAttributesMap.set('WriteAttributes', 'writeAttributes');
|
|
100
|
-
userPoolClientAttributesMap.set('RefreshTokenValidity', 'refreshTokenValidity');
|
|
101
|
-
userPoolClientAttributesMap.set('AccessTokenValidity', 'accessTokenValidity');
|
|
102
|
-
userPoolClientAttributesMap.set('IdTokenValidity', 'idTokenValidity');
|
|
103
|
-
userPoolClientAttributesMap.set('RefreshToken', 'refreshToken');
|
|
104
|
-
userPoolClientAttributesMap.set('AccessToken', 'accessToken');
|
|
105
|
-
userPoolClientAttributesMap.set('IdToken', 'idToken');
|
|
106
|
-
userPoolClientAttributesMap.set('AllowedOAuthScopes', 'scopes');
|
|
107
|
-
userPoolClientAttributesMap.set('CallbackURLs', 'callbackUrls');
|
|
108
|
-
userPoolClientAttributesMap.set('LogoutURLs', 'logoutUrls');
|
|
109
|
-
userPoolClientAttributesMap.set('DefaultRedirectURI', 'defaultRedirectUri');
|
|
110
|
-
userPoolClientAttributesMap.set('AllowedOAuthFlowsUserPoolClient', 'disableOAuth');
|
|
111
|
-
userPoolClientAttributesMap.set('EnableTokenRevocation', 'enableTokenRevocation');
|
|
112
|
-
userPoolClientAttributesMap.set('EnablePropagateAdditionalUserContextData', 'enablePropagateAdditionalUserContextData');
|
|
113
|
-
userPoolClientAttributesMap.set('SupportedIdentityProviders', 'supportedIdentityProviders');
|
|
114
|
-
userPoolClientAttributesMap.set('AuthSessionValidity', 'authSessionValidity');
|
|
115
|
-
userPoolClientAttributesMap.set('ExplicitAuthFlows', 'authFlows');
|
|
116
|
-
userPoolClientAttributesMap.set('AllowedOAuthFlows', 'flows');
|
|
117
|
-
const addClientCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('userPool'), factory.createIdentifier('addClient')), undefined, [factory.createStringLiteral('NativeAppClient'), this.createNestedObjectExpression(userPoolClient, userPoolClientAttributesMap)]);
|
|
118
|
-
if (this.importDurationFlag) {
|
|
119
|
-
imports.push(this.createImportStatement([factory.createIdentifier('Duration')], 'aws-cdk-lib'));
|
|
120
|
-
}
|
|
121
|
-
if (this.readWriteAttributeFlag || this.oAuthFlag || this.supportedIdentityProviderFlag) {
|
|
122
|
-
const identifiers = [
|
|
123
|
-
...(this.readWriteAttributeFlag ? [factory.createIdentifier('ClientAttributes')] : []),
|
|
124
|
-
...(this.oAuthFlag ? [factory.createIdentifier('OAuthScope')] : []),
|
|
125
|
-
...(this.supportedIdentityProviderFlag ? [factory.createIdentifier('UserPoolClientIdentityProvider')] : []),
|
|
126
|
-
];
|
|
127
|
-
if (identifiers.length > 0) {
|
|
128
|
-
imports.push(this.createImportStatement(identifiers, 'aws-cdk-lib/aws-cognito'));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (createConstant) {
|
|
132
|
-
return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier('userPoolClient'), undefined, undefined, addClientCall)], typescript_1.default.NodeFlags.Const));
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return factory.createExpressionStatement(addClientCall);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
createPropertyAccessChain(identifiers) {
|
|
139
|
-
return identifiers
|
|
140
|
-
.slice(1)
|
|
141
|
-
.reduce((acc, curr) => factory.createPropertyAccessExpression(acc, factory.createIdentifier(curr)), factory.createIdentifier(identifiers[0]));
|
|
142
|
-
}
|
|
143
|
-
getProviderSetupDeclaration() {
|
|
144
|
-
const providerSetupResult = 'providerSetupResult';
|
|
145
|
-
return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
|
|
146
|
-
factory.createVariableDeclaration(factory.createIdentifier(providerSetupResult), undefined, undefined, factory.createPropertyAccessExpression(factory.createParenthesizedExpression(factory.createAsExpression(factory.createCallExpression(factory.createPropertyAccessExpression(this.createPropertyAccessChain(['backend', 'auth', 'stack', 'node', 'children']), factory.createIdentifier('find')), undefined, [
|
|
147
|
-
factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, factory.createIdentifier('child'))], undefined, factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), factory.createBinaryExpression(this.createPropertyAccessChain(['child', 'node', 'id']), factory.createToken(typescript_1.default.SyntaxKind.EqualsEqualsEqualsToken), factory.createStringLiteral('amplifyAuth'))),
|
|
148
|
-
]), factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.AnyKeyword))), factory.createIdentifier(providerSetupResult))),
|
|
149
|
-
], typescript_1.default.NodeFlags.Const));
|
|
150
|
-
}
|
|
151
|
-
getProviderSetupForeachStatement() {
|
|
152
|
-
const providerSetupResult = 'providerSetupResult';
|
|
153
|
-
return factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('Object'), factory.createIdentifier('keys')), undefined, [factory.createIdentifier(providerSetupResult)]), factory.createIdentifier('forEach')), undefined, [
|
|
154
|
-
factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, factory.createIdentifier('provider'))], undefined, factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), factory.createBlock([
|
|
155
|
-
factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
|
|
156
|
-
factory.createVariableDeclaration(factory.createIdentifier('providerSetupPropertyValue'), undefined, undefined, factory.createElementAccessExpression(factory.createIdentifier(providerSetupResult), factory.createIdentifier('provider'))),
|
|
157
|
-
], typescript_1.default.NodeFlags.Const)),
|
|
158
|
-
factory.createIfStatement(factory.createLogicalAnd(factory.createPropertyAccessExpression(factory.createIdentifier('providerSetupPropertyValue'), factory.createIdentifier('node')), factory.createCallExpression(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createPropertyAccessExpression(this.createPropertyAccessChain(['providerSetupPropertyValue', 'node', 'id']), factory.createIdentifier('toLowerCase')), undefined, []), factory.createIdentifier('endsWith')), undefined, [factory.createStringLiteral('idp')])), factory.createBlock([
|
|
159
|
-
factory.createExpressionStatement(factory.createCallExpression(this.createPropertyAccessChain(['userPoolClient', 'node', 'addDependency']), undefined, [factory.createIdentifier('providerSetupPropertyValue')])),
|
|
160
|
-
], true)),
|
|
161
|
-
], true)),
|
|
162
|
-
]));
|
|
163
|
-
}
|
|
164
|
-
createProviderSetupCode() {
|
|
165
|
-
const providerSetupDeclaration = this.getProviderSetupDeclaration();
|
|
166
|
-
const forEachStatement = this.getProviderSetupForeachStatement();
|
|
167
|
-
return [providerSetupDeclaration, forEachStatement];
|
|
168
|
-
}
|
|
169
|
-
createNestedObjectExpression(object, gen2PropertyMap) {
|
|
170
|
-
const objectLiterals = [];
|
|
171
|
-
const clientSecretKey = 'ClientSecret';
|
|
172
|
-
for (const [key, value] of Object.entries(object)) {
|
|
173
|
-
const mappedProperty = gen2PropertyMap.get(key);
|
|
174
|
-
if (mappedProperty) {
|
|
175
|
-
if (typeof value == 'boolean') {
|
|
176
|
-
if (key === 'AllowedOAuthFlowsUserPoolClient') {
|
|
177
|
-
objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, !value));
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, value));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else if (typeof value == 'string') {
|
|
184
|
-
if (!this.oAuthFlag && key == 'DefaultRedirectURI') {
|
|
185
|
-
this.oAuthFlag = true;
|
|
186
|
-
objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
|
|
187
|
-
}
|
|
188
|
-
else if (key === clientSecretKey) {
|
|
189
|
-
objectLiterals.push(this.createBooleanPropertyAssignment(mappedProperty, true));
|
|
190
|
-
}
|
|
191
|
-
else if (key != 'DefaultRedirectURI') {
|
|
192
|
-
objectLiterals.push(this.createStringPropertyAssignment(mappedProperty, value));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else if (typeof value == 'number') {
|
|
196
|
-
if (['IdTokenValidity', 'RefreshTokenValidity', 'AccessTokenValidity', 'AuthSessionValidity'].includes(key)) {
|
|
197
|
-
this.importDurationFlag = true;
|
|
198
|
-
if (key == 'IdTokenValidity') {
|
|
199
|
-
let durationUnit = 'hours';
|
|
200
|
-
if (object['TokenValidityUnits'] && object['TokenValidityUnits'].IdToken) {
|
|
201
|
-
durationUnit = object['TokenValidityUnits'].IdToken;
|
|
202
|
-
}
|
|
203
|
-
objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, durationUnit));
|
|
204
|
-
}
|
|
205
|
-
else if (key == 'RefreshTokenValidity') {
|
|
206
|
-
let durationUnit = 'days';
|
|
207
|
-
if (object['TokenValidityUnits'] && object['TokenValidityUnits'].RefreshToken) {
|
|
208
|
-
durationUnit = object['TokenValidityUnits'].RefreshToken;
|
|
209
|
-
}
|
|
210
|
-
objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, durationUnit));
|
|
211
|
-
}
|
|
212
|
-
else if (key == 'AccessTokenValidity') {
|
|
213
|
-
let durationUnit = 'hours';
|
|
214
|
-
if (object['TokenValidityUnits'] && object['TokenValidityUnits'].AccessToken) {
|
|
215
|
-
durationUnit = object['TokenValidityUnits'].AccessToken;
|
|
216
|
-
}
|
|
217
|
-
objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, durationUnit));
|
|
218
|
-
}
|
|
219
|
-
else if (key == 'AuthSessionValidity') {
|
|
220
|
-
objectLiterals.push(this.createDurationPropertyAssignment(mappedProperty, value, 'minutes'));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
objectLiterals.push(this.createNumericPropertyAssignment(mappedProperty, value));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
else if (Array.isArray(value) && gen2PropertyMap.has(key)) {
|
|
228
|
-
if (key == 'ReadAttributes' || key == 'WriteAttributes') {
|
|
229
|
-
objectLiterals.push(this.createReadWriteAttributes(mappedProperty, value));
|
|
230
|
-
}
|
|
231
|
-
else if (key == 'SupportedIdentityProviders') {
|
|
232
|
-
this.supportedIdentityProviderFlag = true;
|
|
233
|
-
objectLiterals.push(this.createEnumListPropertyAssignment(mappedProperty, 'UserPoolClientIdentityProvider', value.map((provider) => {
|
|
234
|
-
if (provider.toUpperCase() == 'LOGINWITHAMAZON') {
|
|
235
|
-
return 'AMAZON';
|
|
236
|
-
}
|
|
237
|
-
else if (provider.toUpperCase() === 'SIGNINWITHAPPLE') {
|
|
238
|
-
return 'APPLE';
|
|
239
|
-
}
|
|
240
|
-
return provider.toUpperCase();
|
|
241
|
-
})));
|
|
242
|
-
}
|
|
243
|
-
else if (!this.oAuthFlag && key == 'AllowedOAuthFlows') {
|
|
244
|
-
this.oAuthFlag = true;
|
|
245
|
-
objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
|
|
246
|
-
}
|
|
247
|
-
else if (key == 'ExplicitAuthFlows') {
|
|
248
|
-
objectLiterals.push(factory.createPropertyAssignment(factory.createIdentifier(mappedProperty), this.createAuthFlowsObjectExpression(value)));
|
|
249
|
-
}
|
|
250
|
-
else if (!this.oAuthFlag && key == 'AllowedOAuthScopes') {
|
|
251
|
-
this.oAuthFlag = true;
|
|
252
|
-
objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
if (!this.oAuthFlag && (key == 'CallbackURLs' || key == 'LogoutURLs')) {
|
|
256
|
-
this.oAuthFlag = true;
|
|
257
|
-
objectLiterals.push(this.createOAuthObjectExpression(object, gen2PropertyMap));
|
|
258
|
-
}
|
|
259
|
-
else if (key != 'CallbackURLs' && key != 'LogoutURLs' && key != 'AllowedOAuthScopes') {
|
|
260
|
-
objectLiterals.push(this.createListPropertyAssignment(mappedProperty, value));
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
else if (typeof value == 'object' && value !== null) {
|
|
265
|
-
objectLiterals.push(factory.createPropertyAssignment(factory.createIdentifier(key), this.createNestedObjectExpression(value, gen2PropertyMap)));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (object[clientSecretKey] === undefined && gen2PropertyMap.has(clientSecretKey)) {
|
|
270
|
-
const mappedClientSecretKey = gen2PropertyMap.get(clientSecretKey);
|
|
271
|
-
(0, assert_1.default)(mappedClientSecretKey);
|
|
272
|
-
objectLiterals.push(this.createBooleanPropertyAssignment(mappedClientSecretKey, false));
|
|
273
|
-
}
|
|
274
|
-
return factory.createObjectLiteralExpression(objectLiterals, true);
|
|
275
|
-
}
|
|
276
|
-
createReadWriteAttributes(identifier, attributes) {
|
|
277
|
-
const standardAttrMap = new Map();
|
|
278
|
-
standardAttrMap.set('address', 'address');
|
|
279
|
-
standardAttrMap.set('birthdate', 'birthdate');
|
|
280
|
-
standardAttrMap.set('email', 'email');
|
|
281
|
-
standardAttrMap.set('family_name', 'familyName');
|
|
282
|
-
standardAttrMap.set('gender', 'gender');
|
|
283
|
-
standardAttrMap.set('given_name', 'givenName');
|
|
284
|
-
standardAttrMap.set('locale', 'locale');
|
|
285
|
-
standardAttrMap.set('middle_name', 'middleName');
|
|
286
|
-
standardAttrMap.set('name', 'fullname');
|
|
287
|
-
standardAttrMap.set('nickname', 'nickname');
|
|
288
|
-
standardAttrMap.set('phone_number', 'phoneNumber');
|
|
289
|
-
standardAttrMap.set('picture', 'profilePicture');
|
|
290
|
-
standardAttrMap.set('preferred_username', 'preferredUsername');
|
|
291
|
-
standardAttrMap.set('profile', 'profilePage');
|
|
292
|
-
standardAttrMap.set('updated_at', 'lastUpdateTime');
|
|
293
|
-
standardAttrMap.set('website', 'website');
|
|
294
|
-
standardAttrMap.set('zoneinfo', 'timezone');
|
|
295
|
-
standardAttrMap.set('email_verified', 'emailVerified');
|
|
296
|
-
standardAttrMap.set('phone_number_verified', 'phoneNumberVerified');
|
|
297
|
-
this.readWriteAttributeFlag = true;
|
|
298
|
-
const standardAttributes = attributes.filter((attribute) => !attribute.startsWith('custom:'));
|
|
299
|
-
const standardAttributesLiterals = [];
|
|
300
|
-
standardAttributes.forEach((attribute) => {
|
|
301
|
-
if (standardAttrMap.has(attribute)) {
|
|
302
|
-
const mappedAttribute = standardAttrMap.get(attribute);
|
|
303
|
-
if (mappedAttribute) {
|
|
304
|
-
standardAttributesLiterals.push(factory.createPropertyAssignment(factory.createIdentifier(mappedAttribute), factory.createTrue()));
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
let clientAttributes = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('new ClientAttributes()'), factory.createIdentifier('withStandardAttributes')), undefined, [factory.createObjectLiteralExpression(standardAttributesLiterals, true)]);
|
|
309
|
-
const customAttributes = attributes.filter((attribute) => attribute.startsWith('custom:'));
|
|
310
|
-
if (customAttributes) {
|
|
311
|
-
clientAttributes = factory.createCallExpression(factory.createPropertyAccessExpression(clientAttributes, factory.createIdentifier('withCustomAttributes')), undefined, customAttributes.map((attr) => factory.createStringLiteral(attr)));
|
|
312
|
-
}
|
|
313
|
-
return factory.createPropertyAssignment(factory.createIdentifier(identifier), clientAttributes);
|
|
314
|
-
}
|
|
315
|
-
mapOAuthScopes(scopes) {
|
|
316
|
-
const scopeMap = new Map();
|
|
317
|
-
scopeMap.set('phone', 'PHONE');
|
|
318
|
-
scopeMap.set('email', 'EMAIL');
|
|
319
|
-
scopeMap.set('openid', 'OPENID');
|
|
320
|
-
scopeMap.set('profile', 'PROFILE');
|
|
321
|
-
scopeMap.set('aws.cognito.signin.user.admin', 'COGNITO_ADMIN');
|
|
322
|
-
const scopesList = [];
|
|
323
|
-
scopes.forEach((scope) => {
|
|
324
|
-
if (scopeMap.has(scope)) {
|
|
325
|
-
const scopeValue = scopeMap.get(scope);
|
|
326
|
-
if (scopeValue) {
|
|
327
|
-
scopesList.push(scopeValue);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
return scopesList;
|
|
332
|
-
}
|
|
333
|
-
createOAuthObjectExpression(object, map) {
|
|
334
|
-
const oAuthLiterals = [];
|
|
335
|
-
for (const [key, value] of Object.entries(object)) {
|
|
336
|
-
if (key == 'AllowedOAuthFlows') {
|
|
337
|
-
oAuthLiterals.push(factory.createPropertyAssignment(factory.createIdentifier('flows'), this.createOAuthFlowsObjectExpression(value)));
|
|
338
|
-
}
|
|
339
|
-
else if (key == 'AllowedOAuthScopes') {
|
|
340
|
-
oAuthLiterals.push(this.createEnumListPropertyAssignment('scopes', 'OAuthScope', this.mapOAuthScopes(value)));
|
|
341
|
-
}
|
|
342
|
-
else if (key == 'CallbackURLs' || key == 'LogoutURLs') {
|
|
343
|
-
const urlValue = map.get(key);
|
|
344
|
-
if (urlValue) {
|
|
345
|
-
oAuthLiterals.push(this.createListPropertyAssignment(urlValue, value));
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
else if (key == 'DefaultRedirectURI') {
|
|
349
|
-
const redirectUriValue = map.get(key);
|
|
350
|
-
if (redirectUriValue) {
|
|
351
|
-
oAuthLiterals.push(this.createStringPropertyAssignment(redirectUriValue, value));
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return factory.createPropertyAssignment(factory.createIdentifier('oAuth'), factory.createObjectLiteralExpression(oAuthLiterals, true));
|
|
356
|
-
}
|
|
357
|
-
createOAuthFlowsObjectExpression(value) {
|
|
358
|
-
return factory.createObjectLiteralExpression([
|
|
359
|
-
this.createBooleanPropertyAssignment('authorizationCodeGrant', value.includes(client_cognito_identity_provider_1.OAuthFlowType.code)),
|
|
360
|
-
this.createBooleanPropertyAssignment('implicitCodeGrant', value.includes(client_cognito_identity_provider_1.OAuthFlowType.implicit)),
|
|
361
|
-
this.createBooleanPropertyAssignment('clientCredentials', value.includes(client_cognito_identity_provider_1.OAuthFlowType.client_credentials)),
|
|
362
|
-
]);
|
|
363
|
-
}
|
|
364
|
-
createAuthFlowsObjectExpression(value) {
|
|
365
|
-
return factory.createObjectLiteralExpression([
|
|
366
|
-
this.createBooleanPropertyAssignment('adminUserPassword', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_ADMIN_USER_PASSWORD_AUTH)),
|
|
367
|
-
this.createBooleanPropertyAssignment('custom', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_CUSTOM_AUTH)),
|
|
368
|
-
this.createBooleanPropertyAssignment('userPassword', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_USER_PASSWORD_AUTH)),
|
|
369
|
-
this.createBooleanPropertyAssignment('userSrp', value.includes(client_cognito_identity_provider_1.ExplicitAuthFlowsType.ALLOW_USER_SRP_AUTH)),
|
|
370
|
-
]);
|
|
371
|
-
}
|
|
372
|
-
createAdditionalAuthProvidersArray(providers) {
|
|
373
|
-
const providerElements = providers.map((provider) => {
|
|
374
|
-
const properties = [];
|
|
375
|
-
properties.push(factory.createPropertyAssignment(factory.createIdentifier('authenticationType'), factory.createStringLiteral(provider.authenticationType)));
|
|
376
|
-
if (provider.userPoolConfig) {
|
|
377
|
-
const userPoolConfigProps = [];
|
|
378
|
-
if (provider.userPoolConfig.appIdClientRegex) {
|
|
379
|
-
userPoolConfigProps.push(factory.createPropertyAssignment(factory.createIdentifier('appIdClientRegex'), factory.createStringLiteral(provider.userPoolConfig.appIdClientRegex)));
|
|
380
|
-
}
|
|
381
|
-
if (provider.userPoolConfig.awsRegion) {
|
|
382
|
-
userPoolConfigProps.push(factory.createPropertyAssignment(factory.createIdentifier('awsRegion'), factory.createPropertyAccessExpression(factory.createIdentifier('backend'), 'auth.resources.userPool.stack.region')));
|
|
383
|
-
}
|
|
384
|
-
if (provider.userPoolConfig.userPoolId) {
|
|
385
|
-
userPoolConfigProps.push(factory.createPropertyAssignment(factory.createIdentifier('userPoolId'), this.createPropertyAccessExpression(factory.createIdentifier('backend'), 'auth.resources.userPool.userPoolId')));
|
|
386
|
-
}
|
|
387
|
-
properties.push(factory.createPropertyAssignment(factory.createIdentifier('userPoolConfig'), factory.createObjectLiteralExpression(userPoolConfigProps, true)));
|
|
388
|
-
}
|
|
389
|
-
if (provider.lambdaAuthorizerConfig) {
|
|
390
|
-
properties.push(factory.createPropertyAssignment(factory.createIdentifier('lambdaAuthorizerConfig'), this.getOverrideValue(provider.lambdaAuthorizerConfig)));
|
|
391
|
-
}
|
|
392
|
-
if (provider.openIdConnectConfig) {
|
|
393
|
-
properties.push(factory.createPropertyAssignment(factory.createIdentifier('openIdConnectConfig'), this.getOverrideValue(provider.openIdConnectConfig)));
|
|
394
|
-
}
|
|
395
|
-
return factory.createObjectLiteralExpression(properties, true);
|
|
396
|
-
});
|
|
397
|
-
return factory.createArrayLiteralExpression(providerElements, true);
|
|
398
|
-
}
|
|
399
|
-
createTemplateLiteralExpression(id1, id2, templateHead, templateSpan, templateTail) {
|
|
400
|
-
return factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier(id1), factory.createIdentifier(id2)), factory.createTemplateExpression(factory.createTemplateHead(templateHead), [
|
|
401
|
-
factory.createTemplateSpan(factory.createIdentifier(templateSpan), factory.createTemplateTail(templateTail)),
|
|
402
|
-
])));
|
|
403
|
-
}
|
|
404
|
-
createAmplifyEnvNameLogic() {
|
|
405
|
-
const variableDeclaration = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
|
|
406
|
-
factory.createVariableDeclaration(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'), undefined, undefined, factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('process'), factory.createIdentifier('env')), factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'))),
|
|
407
|
-
], typescript_1.default.NodeFlags.Let));
|
|
408
|
-
const ifStatement = factory.createIfStatement(factory.createLogicalAnd(factory.createPropertyAccessExpression(factory.createIdentifier('ci'), factory.createIdentifier('isCI')), factory.createLogicalNot(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'))), factory.createBlock([
|
|
409
|
-
factory.createThrowStatement(factory.createNewExpression(factory.createIdentifier('Error'), undefined, [
|
|
410
|
-
factory.createStringLiteral('AMPLIFY_GEN_1_ENV_NAME is required in CI environment'),
|
|
411
|
-
])),
|
|
412
|
-
], true), factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalNot(factory.createPropertyAccessExpression(factory.createIdentifier('ci'), factory.createIdentifier('isCI'))), factory.createLogicalNot(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'))), factory.createBlock([
|
|
413
|
-
factory.createExpressionStatement(factory.createBinaryExpression(factory.createIdentifier('AMPLIFY_GEN_1_ENV_NAME'), factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), factory.createStringLiteral('sandbox'))),
|
|
414
|
-
], true)));
|
|
415
|
-
return [variableDeclaration, ifStatement];
|
|
416
|
-
}
|
|
417
|
-
sanitizeVariableName(name) {
|
|
418
|
-
return name.replace(/-/g, '_');
|
|
419
|
-
}
|
|
420
|
-
render(renderArgs) {
|
|
421
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
|
|
422
|
-
const authFunctionIdentifier = factory.createIdentifier('auth');
|
|
423
|
-
const storageFunctionIdentifier = factory.createIdentifier('storage');
|
|
424
|
-
const dataFunctionIdentifier = factory.createIdentifier('data');
|
|
425
|
-
const backendFunctionIdentifier = factory.createIdentifier('defineBackend');
|
|
426
|
-
const imports = [];
|
|
427
|
-
const errors = [];
|
|
428
|
-
const defineBackendProperties = [];
|
|
429
|
-
const nodes = [];
|
|
430
|
-
const mappedPolicyType = {
|
|
431
|
-
MinimumLength: 'minimumLength',
|
|
432
|
-
RequireUppercase: 'requireUppercase',
|
|
433
|
-
RequireLowercase: 'requireLowercase',
|
|
434
|
-
RequireNumbers: 'requireNumbers',
|
|
435
|
-
RequireSymbols: 'requireSymbols',
|
|
436
|
-
PasswordHistorySize: 'passwordHistorySize',
|
|
437
|
-
TemporaryPasswordValidityDays: 'temporaryPasswordValidityDays',
|
|
438
|
-
};
|
|
439
|
-
if (renderArgs.auth) {
|
|
440
|
-
imports.push(this.createImportStatement([authFunctionIdentifier], renderArgs.auth.importFrom));
|
|
441
|
-
const auth = factory.createShorthandPropertyAssignment(authFunctionIdentifier);
|
|
442
|
-
defineBackendProperties.push(auth);
|
|
443
|
-
}
|
|
444
|
-
if (renderArgs.data) {
|
|
445
|
-
imports.push(this.createImportStatement([dataFunctionIdentifier], renderArgs.data.importFrom));
|
|
446
|
-
const data = factory.createShorthandPropertyAssignment(dataFunctionIdentifier);
|
|
447
|
-
defineBackendProperties.push(data);
|
|
448
|
-
}
|
|
449
|
-
if (((_a = renderArgs.storage) === null || _a === void 0 ? void 0 : _a.hasS3Bucket) || ((_c = (_b = renderArgs.storage) === null || _b === void 0 ? void 0 : _b.dynamoTables) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
450
|
-
if (renderArgs.storage.hasS3Bucket) {
|
|
451
|
-
imports.push(this.createImportStatement([storageFunctionIdentifier], renderArgs.storage.importFrom));
|
|
452
|
-
const storage = factory.createShorthandPropertyAssignment(storageFunctionIdentifier);
|
|
453
|
-
defineBackendProperties.push(storage);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
if (renderArgs.function) {
|
|
457
|
-
const functionNameCategories = renderArgs.function.functionNamesAndCategories;
|
|
458
|
-
for (const [functionName, category] of functionNameCategories) {
|
|
459
|
-
const functionProperty = factory.createShorthandPropertyAssignment(factory.createIdentifier(functionName));
|
|
460
|
-
defineBackendProperties.push(functionProperty);
|
|
461
|
-
imports.push(this.createImportStatement([factory.createIdentifier(functionName)], `./${category}/${functionName}/resource`));
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
if ((_d = renderArgs.data) === null || _d === void 0 ? void 0 : _d.restApis) {
|
|
465
|
-
const allUniqueFunctions = new Set();
|
|
466
|
-
renderArgs.data.restApis.forEach((restApi) => {
|
|
467
|
-
if (restApi.uniqueFunctions) {
|
|
468
|
-
restApi.uniqueFunctions.forEach((funcName) => allUniqueFunctions.add(funcName));
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
const existingFunctions = ((_e = renderArgs.function) === null || _e === void 0 ? void 0 : _e.functionNamesAndCategories) || new Map();
|
|
472
|
-
allUniqueFunctions.forEach((funcName) => {
|
|
473
|
-
if (!existingFunctions.has(funcName)) {
|
|
474
|
-
const functionProperty = factory.createShorthandPropertyAssignment(factory.createIdentifier(funcName));
|
|
475
|
-
defineBackendProperties.push(functionProperty);
|
|
476
|
-
imports.push(this.createImportStatement([factory.createIdentifier(funcName)], `./function/${funcName}/resource`));
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
if ((_g = (_f = renderArgs.storage) === null || _f === void 0 ? void 0 : _f.dynamoTables) === null || _g === void 0 ? void 0 : _g.length) {
|
|
481
|
-
imports.push(this.createImportStatement([
|
|
482
|
-
factory.createIdentifier('Table'),
|
|
483
|
-
factory.createIdentifier('AttributeType'),
|
|
484
|
-
factory.createIdentifier('BillingMode'),
|
|
485
|
-
factory.createIdentifier('StreamViewType'),
|
|
486
|
-
], 'aws-cdk-lib/aws-dynamodb'));
|
|
487
|
-
const stackDeclaration = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
488
|
-
factory.createVariableDeclaration('storageStack', undefined, undefined, renderArgs.storage.hasS3Bucket
|
|
489
|
-
? factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('storage')), factory.createIdentifier('stack'))
|
|
490
|
-
: factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('createStack')), undefined, [factory.createStringLiteral('storage')])),
|
|
491
|
-
], typescript_1.default.NodeFlags.Const));
|
|
492
|
-
nodes.push(stackDeclaration);
|
|
493
|
-
renderArgs.storage.dynamoTables.forEach((table) => {
|
|
494
|
-
var _a;
|
|
495
|
-
const baseTableName = table.tableName.replace(/-[^-]+$/, '');
|
|
496
|
-
const sanitizedTableName = this.sanitizeVariableName(baseTableName);
|
|
497
|
-
const tableProps = [
|
|
498
|
-
factory.createPropertyAssignment('partitionKey', factory.createObjectLiteralExpression([
|
|
499
|
-
factory.createPropertyAssignment('name', factory.createStringLiteral(table.partitionKey.name)),
|
|
500
|
-
factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(table.partitionKey.type))),
|
|
501
|
-
])),
|
|
502
|
-
factory.createPropertyAssignment('billingMode', factory.createPropertyAccessExpression(factory.createIdentifier('BillingMode'), factory.createIdentifier(table.billingMode || 'PROVISIONED'))),
|
|
503
|
-
];
|
|
504
|
-
if (table.billingMode !== 'PAY_PER_REQUEST') {
|
|
505
|
-
tableProps.push(factory.createPropertyAssignment('readCapacity', factory.createNumericLiteral(String(table.readCapacity || 5))));
|
|
506
|
-
tableProps.push(factory.createPropertyAssignment('writeCapacity', factory.createNumericLiteral(String(table.writeCapacity || 5))));
|
|
507
|
-
}
|
|
508
|
-
if (table.streamEnabled && table.streamViewType) {
|
|
509
|
-
tableProps.push(factory.createPropertyAssignment('stream', factory.createPropertyAccessExpression(factory.createIdentifier('StreamViewType'), factory.createIdentifier(table.streamViewType))));
|
|
510
|
-
}
|
|
511
|
-
if (table.sortKey) {
|
|
512
|
-
tableProps.push(factory.createPropertyAssignment('sortKey', factory.createObjectLiteralExpression([
|
|
513
|
-
factory.createPropertyAssignment('name', factory.createStringLiteral(table.sortKey.name)),
|
|
514
|
-
factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(table.sortKey.type))),
|
|
515
|
-
])));
|
|
516
|
-
}
|
|
517
|
-
if (table.gsis && table.gsis.length > 0) {
|
|
518
|
-
const tableDeclaration = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
519
|
-
factory.createVariableDeclaration(sanitizedTableName, undefined, undefined, factory.createNewExpression(factory.createIdentifier('Table'), undefined, [
|
|
520
|
-
factory.createIdentifier('storageStack'),
|
|
521
|
-
factory.createStringLiteral(sanitizedTableName),
|
|
522
|
-
factory.createObjectLiteralExpression(tableProps),
|
|
523
|
-
])),
|
|
524
|
-
], typescript_1.default.NodeFlags.Const));
|
|
525
|
-
nodes.push(tableDeclaration);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
const tableCreation = factory.createExpressionStatement(factory.createNewExpression(factory.createIdentifier('Table'), undefined, [
|
|
529
|
-
factory.createIdentifier('storageStack'),
|
|
530
|
-
factory.createStringLiteral(sanitizedTableName),
|
|
531
|
-
factory.createObjectLiteralExpression(tableProps),
|
|
532
|
-
]));
|
|
533
|
-
nodes.push(tableCreation);
|
|
534
|
-
}
|
|
535
|
-
const tableNameComment1 = factory.createNotEmittedStatement(factory.createStringLiteral(''));
|
|
536
|
-
typescript_1.default.addSyntheticLeadingComment(tableNameComment1, typescript_1.default.SyntaxKind.SingleLineCommentTrivia, ` Add this property to the Table above post refactor: tableName: '${table.tableName}'`, true);
|
|
537
|
-
nodes.push(tableNameComment1);
|
|
538
|
-
(_a = table.gsis) === null || _a === void 0 ? void 0 : _a.forEach((gsi) => {
|
|
539
|
-
const gsiProps = [
|
|
540
|
-
factory.createPropertyAssignment('indexName', factory.createStringLiteral(gsi.indexName)),
|
|
541
|
-
factory.createPropertyAssignment('partitionKey', factory.createObjectLiteralExpression([
|
|
542
|
-
factory.createPropertyAssignment('name', factory.createStringLiteral(gsi.partitionKey.name)),
|
|
543
|
-
factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(gsi.partitionKey.type))),
|
|
544
|
-
])),
|
|
545
|
-
];
|
|
546
|
-
if (gsi.sortKey) {
|
|
547
|
-
gsiProps.push(factory.createPropertyAssignment('sortKey', factory.createObjectLiteralExpression([
|
|
548
|
-
factory.createPropertyAssignment('name', factory.createStringLiteral(gsi.sortKey.name)),
|
|
549
|
-
factory.createPropertyAssignment('type', factory.createPropertyAccessExpression(factory.createIdentifier('AttributeType'), factory.createIdentifier(gsi.sortKey.type))),
|
|
550
|
-
])));
|
|
551
|
-
}
|
|
552
|
-
gsiProps.push(factory.createPropertyAssignment('readCapacity', factory.createNumericLiteral('5')));
|
|
553
|
-
gsiProps.push(factory.createPropertyAssignment('writeCapacity', factory.createNumericLiteral('5')));
|
|
554
|
-
const gsiCall = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(sanitizedTableName), factory.createIdentifier('addGlobalSecondaryIndex')), undefined, [factory.createObjectLiteralExpression(gsiProps)]));
|
|
555
|
-
nodes.push(gsiCall);
|
|
556
|
-
});
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
if (renderArgs.dynamoTriggers && renderArgs.dynamoTriggers.length > 0) {
|
|
560
|
-
imports.push(this.createImportStatement([factory.createIdentifier('DynamoEventSource')], 'aws-cdk-lib/aws-lambda-event-sources'));
|
|
561
|
-
imports.push(this.createImportStatement([factory.createIdentifier('StartingPosition')], 'aws-cdk-lib/aws-lambda'));
|
|
562
|
-
}
|
|
563
|
-
imports.push(this.createImportStatement([backendFunctionIdentifier], '@aws-amplify/backend'));
|
|
564
|
-
if (renderArgs.analytics) {
|
|
565
|
-
const analyticsFunctionIdentifier = factory.createIdentifier('analytics');
|
|
566
|
-
imports.push(this.createImportStatement([analyticsFunctionIdentifier], renderArgs.analytics.importFrom));
|
|
567
|
-
}
|
|
568
|
-
if (((_h = renderArgs.data) === null || _h === void 0 ? void 0 : _h.restApis) && renderArgs.function) {
|
|
569
|
-
const functionNameCategories = renderArgs.function.functionNamesAndCategories;
|
|
570
|
-
const hasRestApis = renderArgs.data.restApis.some((restApi) => functionNameCategories.has(restApi.functionName));
|
|
571
|
-
if (hasRestApis) {
|
|
572
|
-
imports.push(this.createImportStatement([factory.createIdentifier('HttpApi'), factory.createIdentifier('HttpMethod'), factory.createIdentifier('CorsHttpMethod')], 'aws-cdk-lib/aws-apigatewayv2'));
|
|
573
|
-
imports.push(this.createImportStatement([factory.createIdentifier('HttpLambdaIntegration')], 'aws-cdk-lib/aws-apigatewayv2-integrations'));
|
|
574
|
-
const hasPrivateAuth = renderArgs.data.restApis.some((restApi) => restApi.paths.some((path) => path.authType === 'private'));
|
|
575
|
-
const hasProtectedAuth = renderArgs.data.restApis.some((restApi) => restApi.paths.some((path) => path.authType === 'protected'));
|
|
576
|
-
const hasUserPoolGroups = renderArgs.data.restApis.some((restApi) => restApi.paths.some((path) => path.userPoolGroups && path.userPoolGroups.length > 0));
|
|
577
|
-
const authorizerImports = [];
|
|
578
|
-
if (hasPrivateAuth) {
|
|
579
|
-
authorizerImports.push(factory.createIdentifier('HttpIamAuthorizer'));
|
|
580
|
-
}
|
|
581
|
-
if (hasProtectedAuth && renderArgs.auth) {
|
|
582
|
-
authorizerImports.push(factory.createIdentifier('HttpUserPoolAuthorizer'));
|
|
583
|
-
}
|
|
584
|
-
if (hasUserPoolGroups && renderArgs.auth) {
|
|
585
|
-
authorizerImports.push(factory.createIdentifier('HttpUserPoolAuthorizer'));
|
|
586
|
-
}
|
|
587
|
-
if (authorizerImports.length > 0) {
|
|
588
|
-
imports.push(this.createImportStatement(authorizerImports, 'aws-cdk-lib/aws-apigatewayv2-authorizers'));
|
|
589
|
-
}
|
|
590
|
-
imports.push(this.createImportStatement([factory.createIdentifier('Policy'), factory.createIdentifier('PolicyStatement')], 'aws-cdk-lib/aws-iam'));
|
|
591
|
-
imports.push(this.createImportStatement([factory.createIdentifier('Stack')], 'aws-cdk-lib'));
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
if (renderArgs.unsupportedCategories) {
|
|
595
|
-
const categories = renderArgs.unsupportedCategories;
|
|
596
|
-
for (const [key, value] of categories) {
|
|
597
|
-
errors.push(factory.createCallExpression(factory.createIdentifier('throw new Error'), undefined, [
|
|
598
|
-
factory.createStringLiteral(`Category ${key} is unsupported, please follow ${value}`),
|
|
599
|
-
]));
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
const callBackendFn = this.defineBackendCall(backendFunctionIdentifier, defineBackendProperties);
|
|
603
|
-
const backendVariable = factory.createVariableDeclaration('backend', undefined, undefined, callBackendFn);
|
|
604
|
-
const backendStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([backendVariable], typescript_1.default.NodeFlags.Const));
|
|
605
|
-
if (renderArgs.analytics) {
|
|
606
|
-
const analyticsCall = factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier('analytics'), undefined, [factory.createIdentifier('backend')]));
|
|
607
|
-
nodes.push(analyticsCall);
|
|
608
|
-
}
|
|
609
|
-
if (((_j = renderArgs.auth) === null || _j === void 0 ? void 0 : _j.userPoolOverrides) && !((_k = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _k === void 0 ? void 0 : _k.referenceAuth)) {
|
|
610
|
-
const cfnUserPoolVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnUserPool', 'auth.resources.cfnResources.cfnUserPool'));
|
|
611
|
-
nodes.push(cfnUserPoolVariableStatement);
|
|
612
|
-
const policies = {
|
|
613
|
-
passwordPolicy: {},
|
|
614
|
-
};
|
|
615
|
-
for (const [overridePath, value] of Object.entries(renderArgs.auth.userPoolOverrides)) {
|
|
616
|
-
if (overridePath.includes('PasswordPolicy')) {
|
|
617
|
-
const policyKey = overridePath.split('.')[2];
|
|
618
|
-
if (value !== undefined && policyKey in mappedPolicyType) {
|
|
619
|
-
policies.passwordPolicy[mappedPolicyType[policyKey]] = value;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPool'), overridePath, value));
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPool'), 'policies', policies));
|
|
627
|
-
}
|
|
628
|
-
if (((_l = renderArgs.auth) === null || _l === void 0 ? void 0 : _l.guestLogin) === false && !((_m = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _m === void 0 ? void 0 : _m.referenceAuth)) {
|
|
629
|
-
const cfnIdentityPoolVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnIdentityPool', 'auth.resources.cfnResources.cfnIdentityPool'));
|
|
630
|
-
nodes.push(cfnIdentityPoolVariableStatement);
|
|
631
|
-
nodes.push(this.setPropertyValue(factory.createIdentifier('cfnIdentityPool'), 'allowUnauthenticatedIdentities', false));
|
|
632
|
-
}
|
|
633
|
-
if ((((_o = renderArgs.auth) === null || _o === void 0 ? void 0 : _o.oAuthFlows) || ((_p = renderArgs.auth) === null || _p === void 0 ? void 0 : _p.readAttributes) || ((_q = renderArgs.auth) === null || _q === void 0 ? void 0 : _q.writeAttributes)) &&
|
|
634
|
-
!((_r = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _r === void 0 ? void 0 : _r.referenceAuth)) {
|
|
635
|
-
const cfnUserPoolClientVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnUserPoolClient', 'auth.resources.cfnResources.cfnUserPoolClient'));
|
|
636
|
-
nodes.push(cfnUserPoolClientVariableStatement);
|
|
637
|
-
if ((_s = renderArgs.auth) === null || _s === void 0 ? void 0 : _s.oAuthFlows) {
|
|
638
|
-
nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPoolClient'), 'allowedOAuthFlows', (_t = renderArgs.auth) === null || _t === void 0 ? void 0 : _t.oAuthFlows));
|
|
639
|
-
}
|
|
640
|
-
if ((_u = renderArgs.auth) === null || _u === void 0 ? void 0 : _u.readAttributes) {
|
|
641
|
-
nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPoolClient'), 'readAttributes', (_v = renderArgs.auth) === null || _v === void 0 ? void 0 : _v.readAttributes));
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
if (((_w = renderArgs.auth) === null || _w === void 0 ? void 0 : _w.writeAttributes) && !((_x = renderArgs === null || renderArgs === void 0 ? void 0 : renderArgs.auth) === null || _x === void 0 ? void 0 : _x.referenceAuth)) {
|
|
645
|
-
nodes.push(this.setPropertyValue(factory.createIdentifier('cfnUserPoolClient'), 'writeAttributes', (_y = renderArgs.auth) === null || _y === void 0 ? void 0 : _y.writeAttributes));
|
|
646
|
-
}
|
|
647
|
-
if ((_z = renderArgs.auth) === null || _z === void 0 ? void 0 : _z.userPoolClient) {
|
|
648
|
-
const userPoolVariableStatement = this.createVariableStatement(this.createVariableDeclaration('userPool', 'auth.resources.userPool'));
|
|
649
|
-
nodes.push(userPoolVariableStatement);
|
|
650
|
-
const needsUserPoolClientConstant = renderArgs.auth.userPoolClient.SupportedIdentityProviders && renderArgs.auth.userPoolClient.SupportedIdentityProviders.length > 0;
|
|
651
|
-
nodes.push(this.createUserPoolClientAssignment((_0 = renderArgs.auth) === null || _0 === void 0 ? void 0 : _0.userPoolClient, imports, needsUserPoolClientConstant));
|
|
652
|
-
}
|
|
653
|
-
if (renderArgs.storage && renderArgs.storage.hasS3Bucket) {
|
|
654
|
-
(0, assert_1.default)(renderArgs.storage.bucketName);
|
|
655
|
-
const cfnStorageVariableStatement = this.createVariableStatement(this.createVariableDeclaration('s3Bucket', 'storage.resources.cfnResources.cfnBucket'));
|
|
656
|
-
nodes.push(cfnStorageVariableStatement);
|
|
657
|
-
const bucketNameComment1 = factory.createNotEmittedStatement(factory.createStringLiteral(''));
|
|
658
|
-
typescript_1.default.addSyntheticLeadingComment(bucketNameComment1, typescript_1.default.SyntaxKind.SingleLineCommentTrivia, ` Use this bucket name post refactor`, true);
|
|
659
|
-
const bucketNameComment2 = factory.createNotEmittedStatement(factory.createStringLiteral(''));
|
|
660
|
-
typescript_1.default.addSyntheticLeadingComment(bucketNameComment2, typescript_1.default.SyntaxKind.SingleLineCommentTrivia, ` s3Bucket.bucketName = '${renderArgs.storage.bucketName}';`, true);
|
|
661
|
-
nodes.push(bucketNameComment1, bucketNameComment2);
|
|
662
|
-
}
|
|
663
|
-
if (((_1 = renderArgs.storage) === null || _1 === void 0 ? void 0 : _1.accelerateConfiguration) ||
|
|
664
|
-
((_2 = renderArgs.storage) === null || _2 === void 0 ? void 0 : _2.versionConfiguration) ||
|
|
665
|
-
((_3 = renderArgs.storage) === null || _3 === void 0 ? void 0 : _3.bucketEncryptionAlgorithm)) {
|
|
666
|
-
if ((_4 = renderArgs.storage) === null || _4 === void 0 ? void 0 : _4.accelerateConfiguration) {
|
|
667
|
-
const accelerateConfigAssignment = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('s3Bucket'), factory.createIdentifier('accelerateConfiguration')), factory.createObjectLiteralExpression([this.createStringPropertyAssignment('accelerationStatus', renderArgs.storage.accelerateConfiguration)], false)));
|
|
668
|
-
nodes.push(accelerateConfigAssignment);
|
|
669
|
-
}
|
|
670
|
-
if ((_5 = renderArgs.storage) === null || _5 === void 0 ? void 0 : _5.versionConfiguration) {
|
|
671
|
-
const versionConfigAssignment = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('s3Bucket'), factory.createIdentifier('versioningConfiguration')), factory.createObjectLiteralExpression([this.createStringPropertyAssignment('status', renderArgs.storage.versionConfiguration)], false)));
|
|
672
|
-
nodes.push(versionConfigAssignment);
|
|
673
|
-
}
|
|
674
|
-
if ((_6 = renderArgs.storage) === null || _6 === void 0 ? void 0 : _6.bucketEncryptionAlgorithm) {
|
|
675
|
-
const serverSideEncryptionByDefaultMap = new Map();
|
|
676
|
-
serverSideEncryptionByDefaultMap.set('SSEAlgorithm', 'sseAlgorithm');
|
|
677
|
-
serverSideEncryptionByDefaultMap.set('KMSMasterKeyID', 'kmsMasterKeyId');
|
|
678
|
-
serverSideEncryptionByDefaultMap.set('bucketKeyEnabled', 'bucketKeyEnabled');
|
|
679
|
-
serverSideEncryptionByDefaultMap.set('serverSideEncryptionByDefault', 'serverSideEncryptionByDefault');
|
|
680
|
-
const bucketEncryptionAssignment = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('s3Bucket'), factory.createIdentifier('bucketEncryption')), factory.createObjectLiteralExpression([
|
|
681
|
-
factory.createPropertyAssignment(factory.createIdentifier('serverSideEncryptionConfiguration'), factory.createArrayLiteralExpression([this.createNestedObjectExpression(renderArgs.storage.bucketEncryptionAlgorithm, serverSideEncryptionByDefaultMap)], true)),
|
|
682
|
-
], true)));
|
|
683
|
-
nodes.push(bucketEncryptionAssignment);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
if (((_7 = renderArgs.auth) === null || _7 === void 0 ? void 0 : _7.userPoolClient) &&
|
|
687
|
-
renderArgs.auth.userPoolClient.SupportedIdentityProviders &&
|
|
688
|
-
renderArgs.auth.userPoolClient.SupportedIdentityProviders.length > 0) {
|
|
689
|
-
const idpStatements = this.createProviderSetupCode();
|
|
690
|
-
nodes.push(...idpStatements);
|
|
691
|
-
const userPoolDomainRemovalStatementCommented = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('// backend.auth.resources.userPool'), factory.createIdentifier('node')), factory.createIdentifier('tryRemoveChild')), undefined, [factory.createStringLiteral('UserPoolDomain')]));
|
|
692
|
-
nodes.push(userPoolDomainRemovalStatementCommented);
|
|
693
|
-
}
|
|
694
|
-
if (((_8 = renderArgs.data) === null || _8 === void 0 ? void 0 : _8.additionalAuthProviders) && renderArgs.auth) {
|
|
695
|
-
const cfnGraphqlApiVariableStatement = this.createVariableStatement(this.createVariableDeclaration('cfnGraphqlApi', 'data.resources.cfnResources.cfnGraphqlApi'));
|
|
696
|
-
nodes.push(cfnGraphqlApiVariableStatement);
|
|
697
|
-
const additionalAuthProviders = this.createAdditionalAuthProvidersArray(renderArgs.data.additionalAuthProviders);
|
|
698
|
-
nodes.push(factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier('cfnGraphqlApi'), factory.createIdentifier('additionalAuthenticationProviders')), additionalAuthProviders)));
|
|
699
|
-
}
|
|
700
|
-
if (renderArgs.function) {
|
|
701
|
-
const branchNameStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
702
|
-
factory.createVariableDeclaration('branchName', undefined, undefined, factory.createIdentifier('process.env.AWS_BRANCH ?? "sandbox"')),
|
|
703
|
-
], typescript_1.default.NodeFlags.Const));
|
|
704
|
-
nodes.push(branchNameStatement);
|
|
705
|
-
const functionNameCategories = renderArgs.function.functionNamesAndCategories;
|
|
706
|
-
for (const [functionName] of functionNameCategories) {
|
|
707
|
-
nodes.push(factory.createExpressionStatement(factory.createBinaryExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier(functionName)), factory.createIdentifier('resources')), factory.createIdentifier('cfnResources')), factory.createIdentifier('cfnFunction')), factory.createIdentifier('functionName')), factory.createToken(typescript_1.default.SyntaxKind.EqualsToken), factory.createTemplateExpression(factory.createTemplateHead(`${functionName}-`), [
|
|
708
|
-
factory.createTemplateSpan(factory.createIdentifier('branchName'), factory.createTemplateTail('')),
|
|
709
|
-
]))));
|
|
710
|
-
if ((_9 = renderArgs.function.functionEnvironments) === null || _9 === void 0 ? void 0 : _9.has(functionName)) {
|
|
711
|
-
const envVars = renderArgs.function.functionEnvironments.get(functionName);
|
|
712
|
-
const escapeHatches = (0, lambda_env_generator_1.generateLambdaEnvVars)(functionName, envVars);
|
|
713
|
-
nodes.push(...escapeHatches);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
if (((_10 = renderArgs.function) === null || _10 === void 0 ? void 0 : _10.functionsWithApiAccess) && renderArgs.data) {
|
|
718
|
-
for (const [functionName, permissions] of renderArgs.function.functionsWithApiAccess) {
|
|
719
|
-
if (permissions.hasQuery) {
|
|
720
|
-
nodes.push(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.data.resources.graphqlApi'), factory.createIdentifier('grantQuery')), undefined, [
|
|
721
|
-
factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${functionName}.resources`), factory.createIdentifier('lambda')),
|
|
722
|
-
])));
|
|
723
|
-
}
|
|
724
|
-
if (permissions.hasMutation) {
|
|
725
|
-
nodes.push(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.data.resources.graphqlApi'), factory.createIdentifier('grantMutation')), undefined, [
|
|
726
|
-
factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${functionName}.resources`), factory.createIdentifier('lambda')),
|
|
727
|
-
])));
|
|
728
|
-
}
|
|
729
|
-
if (permissions.hasSubscription) {
|
|
730
|
-
nodes.push(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.data.resources.graphqlApi'), factory.createIdentifier('grantSubscription')), undefined, [
|
|
731
|
-
factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${functionName}.resources`), factory.createIdentifier('lambda')),
|
|
732
|
-
])));
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
if (((_11 = renderArgs.data) === null || _11 === void 0 ? void 0 : _11.restApis) && renderArgs.function) {
|
|
737
|
-
const functionNameCategories = renderArgs.function.functionNamesAndCategories;
|
|
738
|
-
const validRestApis = renderArgs.data.restApis.filter((restApi) => functionNameCategories.has(restApi.functionName));
|
|
739
|
-
if (validRestApis.length > 0) {
|
|
740
|
-
const apiStackStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
741
|
-
factory.createVariableDeclaration('apiStack', undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('createStack')), undefined, [factory.createStringLiteral('api-stack')])),
|
|
742
|
-
], typescript_1.default.NodeFlags.Const));
|
|
743
|
-
nodes.push(apiStackStatement);
|
|
744
|
-
const hasPrivateAuth = validRestApis.some((restApi) => restApi.paths.some((path) => path.authType === 'private'));
|
|
745
|
-
const hasProtectedAuth = validRestApis.some((restApi) => restApi.paths.some((path) => path.authType === 'protected'));
|
|
746
|
-
const hasUserPoolGroups = validRestApis.some((restApi) => restApi.paths.some((path) => path.userPoolGroups && path.userPoolGroups.length > 0));
|
|
747
|
-
if (hasPrivateAuth) {
|
|
748
|
-
const iamAuthorizerStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
749
|
-
factory.createVariableDeclaration('iamAuthorizer', undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpIamAuthorizer'), undefined, [])),
|
|
750
|
-
], typescript_1.default.NodeFlags.Const));
|
|
751
|
-
nodes.push(iamAuthorizerStatement);
|
|
752
|
-
}
|
|
753
|
-
if (hasProtectedAuth && renderArgs.auth) {
|
|
754
|
-
const userPoolAuthorizerStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
755
|
-
factory.createVariableDeclaration('userPoolAuthorizer', undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpUserPoolAuthorizer'), undefined, [
|
|
756
|
-
factory.createStringLiteral('userPoolAuth'),
|
|
757
|
-
factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPool')),
|
|
758
|
-
factory.createObjectLiteralExpression([
|
|
759
|
-
factory.createPropertyAssignment(factory.createIdentifier('userPoolClients'), factory.createArrayLiteralExpression([
|
|
760
|
-
factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPoolClient')),
|
|
761
|
-
])),
|
|
762
|
-
]),
|
|
763
|
-
])),
|
|
764
|
-
], typescript_1.default.NodeFlags.Const));
|
|
765
|
-
nodes.push(userPoolAuthorizerStatement);
|
|
766
|
-
}
|
|
767
|
-
if (hasUserPoolGroups && renderArgs.auth) {
|
|
768
|
-
const allGroups = new Set();
|
|
769
|
-
validRestApis.forEach((restApi) => {
|
|
770
|
-
restApi.paths.forEach((path) => {
|
|
771
|
-
if (path.userPoolGroups) {
|
|
772
|
-
path.userPoolGroups.forEach((group) => allGroups.add(group));
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
});
|
|
776
|
-
allGroups.forEach((groupName) => {
|
|
777
|
-
const groupAuthorizerStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
778
|
-
factory.createVariableDeclaration(`${groupName}Authorizer`, undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpUserPoolAuthorizer'), undefined, [
|
|
779
|
-
factory.createStringLiteral(`${groupName}Auth`),
|
|
780
|
-
factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPool')),
|
|
781
|
-
factory.createObjectLiteralExpression([
|
|
782
|
-
factory.createPropertyAssignment(factory.createIdentifier('userPoolClients'), factory.createArrayLiteralExpression([
|
|
783
|
-
factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources'), factory.createIdentifier('userPoolClient')),
|
|
784
|
-
])),
|
|
785
|
-
factory.createPropertyAssignment(factory.createIdentifier('identitySource'), factory.createArrayLiteralExpression([factory.createStringLiteral('$request.header.Authorization')])),
|
|
786
|
-
]),
|
|
787
|
-
])),
|
|
788
|
-
], typescript_1.default.NodeFlags.Const));
|
|
789
|
-
nodes.push(groupAuthorizerStatement);
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
const httpApiVariables = [];
|
|
793
|
-
validRestApis.forEach((restApi, index) => {
|
|
794
|
-
var _a, _b, _c;
|
|
795
|
-
const httpApiVarName = `httpApi${index > 0 ? index + 1 : ''}`;
|
|
796
|
-
httpApiVariables.push(httpApiVarName);
|
|
797
|
-
const httpApiStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
798
|
-
factory.createVariableDeclaration(httpApiVarName, undefined, undefined, factory.createNewExpression(factory.createIdentifier('HttpApi'), undefined, [
|
|
799
|
-
factory.createIdentifier('apiStack'),
|
|
800
|
-
factory.createStringLiteral(`HttpApi${index > 0 ? index + 1 : ''}`),
|
|
801
|
-
factory.createObjectLiteralExpression([
|
|
802
|
-
factory.createPropertyAssignment(factory.createIdentifier('apiName'), factory.createTemplateExpression(factory.createTemplateHead(`${restApi.apiName}-`), [
|
|
803
|
-
factory.createTemplateSpan(factory.createIdentifier('branchName'), factory.createTemplateTail('')),
|
|
804
|
-
])),
|
|
805
|
-
factory.createPropertyAssignment(factory.createIdentifier('createDefaultStage'), factory.createTrue()),
|
|
806
|
-
factory.createPropertyAssignment(factory.createIdentifier('corsPreflight'), factory.createObjectLiteralExpression([
|
|
807
|
-
factory.createPropertyAssignment(factory.createIdentifier('allowMethods'), factory.createArrayLiteralExpression((((_a = restApi.corsConfiguration) === null || _a === void 0 ? void 0 : _a.allowMethods) || ['GET', 'POST', 'PUT', 'DELETE']).map((method) => factory.createPropertyAccessExpression(factory.createIdentifier('CorsHttpMethod'), factory.createIdentifier(method.toUpperCase()))))),
|
|
808
|
-
factory.createPropertyAssignment(factory.createIdentifier('allowOrigins'), factory.createArrayLiteralExpression((((_b = restApi.corsConfiguration) === null || _b === void 0 ? void 0 : _b.allowOrigins) || ['*']).map((origin) => factory.createStringLiteral(origin)))),
|
|
809
|
-
factory.createPropertyAssignment(factory.createIdentifier('allowHeaders'), factory.createArrayLiteralExpression((((_c = restApi.corsConfiguration) === null || _c === void 0 ? void 0 : _c.allowHeaders) || ['content-type', 'authorization']).map((header) => factory.createStringLiteral(header)))),
|
|
810
|
-
])),
|
|
811
|
-
]),
|
|
812
|
-
])),
|
|
813
|
-
], typescript_1.default.NodeFlags.Const));
|
|
814
|
-
nodes.push(httpApiStatement);
|
|
815
|
-
restApi.paths.forEach((pathConfig) => {
|
|
816
|
-
const pathFunctionName = pathConfig.lambdaFunction || restApi.functionName;
|
|
817
|
-
if (!functionNameCategories.has(pathFunctionName)) {
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
const routeConfig = [
|
|
821
|
-
factory.createPropertyAssignment(factory.createIdentifier('path'), factory.createStringLiteral(pathConfig.path)),
|
|
822
|
-
factory.createPropertyAssignment(factory.createIdentifier('methods'), factory.createArrayLiteralExpression(pathConfig.methods.map((method) => factory.createPropertyAccessExpression(factory.createIdentifier('HttpMethod'), factory.createIdentifier(method.toUpperCase()))))),
|
|
823
|
-
factory.createPropertyAssignment(factory.createIdentifier('integration'), factory.createNewExpression(factory.createIdentifier('HttpLambdaIntegration'), undefined, [
|
|
824
|
-
factory.createStringLiteral(`${pathFunctionName}Integration`),
|
|
825
|
-
factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${pathFunctionName}.resources`), factory.createIdentifier('lambda')),
|
|
826
|
-
])),
|
|
827
|
-
];
|
|
828
|
-
if (pathConfig.userPoolGroups && pathConfig.userPoolGroups.length > 0) {
|
|
829
|
-
pathConfig.userPoolGroups.forEach((groupName) => {
|
|
830
|
-
const groupRouteConfig = [...routeConfig];
|
|
831
|
-
groupRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier(`${groupName}Authorizer`)));
|
|
832
|
-
const addGroupRouteStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(groupRouteConfig)]));
|
|
833
|
-
nodes.push(addGroupRouteStatement);
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
else if (pathConfig.authType === 'private') {
|
|
837
|
-
routeConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('iamAuthorizer')));
|
|
838
|
-
const addRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(routeConfig)]));
|
|
839
|
-
nodes.push(addRoutesStatement);
|
|
840
|
-
}
|
|
841
|
-
else if (pathConfig.authType === 'protected') {
|
|
842
|
-
routeConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('userPoolAuthorizer')));
|
|
843
|
-
const addRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(routeConfig)]));
|
|
844
|
-
nodes.push(addRoutesStatement);
|
|
845
|
-
}
|
|
846
|
-
else {
|
|
847
|
-
const addRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(routeConfig)]));
|
|
848
|
-
nodes.push(addRoutesStatement);
|
|
849
|
-
}
|
|
850
|
-
const proxyRouteConfig = [
|
|
851
|
-
factory.createPropertyAssignment(factory.createIdentifier('path'), factory.createStringLiteral(`${pathConfig.path}/{proxy+}`)),
|
|
852
|
-
factory.createPropertyAssignment(factory.createIdentifier('methods'), factory.createArrayLiteralExpression([
|
|
853
|
-
factory.createPropertyAccessExpression(factory.createIdentifier('HttpMethod'), factory.createIdentifier('ANY')),
|
|
854
|
-
])),
|
|
855
|
-
factory.createPropertyAssignment(factory.createIdentifier('integration'), factory.createNewExpression(factory.createIdentifier('HttpLambdaIntegration'), undefined, [
|
|
856
|
-
factory.createStringLiteral(`${pathFunctionName}ProxyIntegration`),
|
|
857
|
-
factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${pathFunctionName}.resources`), factory.createIdentifier('lambda')),
|
|
858
|
-
])),
|
|
859
|
-
];
|
|
860
|
-
if (pathConfig.userPoolGroups && pathConfig.userPoolGroups.length > 0) {
|
|
861
|
-
pathConfig.userPoolGroups.forEach((groupName) => {
|
|
862
|
-
const groupProxyRouteConfig = [...proxyRouteConfig];
|
|
863
|
-
groupProxyRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier(`${groupName}Authorizer`)));
|
|
864
|
-
const addGroupProxyRouteStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(groupProxyRouteConfig)]));
|
|
865
|
-
nodes.push(addGroupProxyRouteStatement);
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
else if (pathConfig.authType === 'private') {
|
|
869
|
-
proxyRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('iamAuthorizer')));
|
|
870
|
-
const addProxyRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(proxyRouteConfig)]));
|
|
871
|
-
nodes.push(addProxyRoutesStatement);
|
|
872
|
-
}
|
|
873
|
-
else if (pathConfig.authType === 'protected') {
|
|
874
|
-
proxyRouteConfig.push(factory.createPropertyAssignment(factory.createIdentifier('authorizer'), factory.createIdentifier('userPoolAuthorizer')));
|
|
875
|
-
const addProxyRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(proxyRouteConfig)]));
|
|
876
|
-
nodes.push(addProxyRoutesStatement);
|
|
877
|
-
}
|
|
878
|
-
else {
|
|
879
|
-
const addProxyRoutesStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVarName), factory.createIdentifier('addRoutes')), undefined, [factory.createObjectLiteralExpression(proxyRouteConfig)]));
|
|
880
|
-
nodes.push(addProxyRoutesStatement);
|
|
881
|
-
}
|
|
882
|
-
});
|
|
883
|
-
});
|
|
884
|
-
if (renderArgs.auth) {
|
|
885
|
-
const policyResources = httpApiVariables.map((httpApiVar) => factory.createTemplateExpression(factory.createTemplateHead(''), [
|
|
886
|
-
factory.createTemplateSpan(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVar), factory.createIdentifier('arnForExecuteApi')), undefined, [factory.createStringLiteral('*'), factory.createStringLiteral('/*')]), factory.createTemplateTail('')),
|
|
887
|
-
]));
|
|
888
|
-
const apiPolicyStatement = factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
889
|
-
factory.createVariableDeclaration('apiPolicy', undefined, undefined, factory.createNewExpression(factory.createIdentifier('Policy'), undefined, [
|
|
890
|
-
factory.createIdentifier('apiStack'),
|
|
891
|
-
factory.createStringLiteral('ApiPolicy'),
|
|
892
|
-
factory.createObjectLiteralExpression([
|
|
893
|
-
factory.createPropertyAssignment(factory.createIdentifier('statements'), factory.createArrayLiteralExpression([
|
|
894
|
-
factory.createNewExpression(factory.createIdentifier('PolicyStatement'), undefined, [
|
|
895
|
-
factory.createObjectLiteralExpression([
|
|
896
|
-
factory.createPropertyAssignment(factory.createIdentifier('actions'), factory.createArrayLiteralExpression([factory.createStringLiteral('execute-api:Invoke')])),
|
|
897
|
-
factory.createPropertyAssignment(factory.createIdentifier('resources'), factory.createArrayLiteralExpression(policyResources)),
|
|
898
|
-
]),
|
|
899
|
-
]),
|
|
900
|
-
])),
|
|
901
|
-
]),
|
|
902
|
-
])),
|
|
903
|
-
], typescript_1.default.NodeFlags.Const));
|
|
904
|
-
nodes.push(apiPolicyStatement);
|
|
905
|
-
const attachAuthenticatedPolicyStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources.authenticatedUserIamRole'), factory.createIdentifier('attachInlinePolicy')), undefined, [factory.createIdentifier('apiPolicy')]));
|
|
906
|
-
nodes.push(attachAuthenticatedPolicyStatement);
|
|
907
|
-
const attachUnauthenticatedPolicyStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.auth.resources.unauthenticatedUserIamRole'), factory.createIdentifier('attachInlinePolicy')), undefined, [factory.createIdentifier('apiPolicy')]));
|
|
908
|
-
nodes.push(attachUnauthenticatedPolicyStatement);
|
|
909
|
-
}
|
|
910
|
-
const apiOutputs = httpApiVariables.map((httpApiVar, index) => {
|
|
911
|
-
const restApi = validRestApis[index];
|
|
912
|
-
return factory.createPropertyAssignment(factory.createComputedPropertyName(factory.createNonNullExpression(factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVar), factory.createIdentifier('httpApiName')))), factory.createObjectLiteralExpression([
|
|
913
|
-
factory.createPropertyAssignment(factory.createIdentifier('endpoint'), factory.createPropertyAccessExpression(factory.createIdentifier(httpApiVar), factory.createIdentifier('url'))),
|
|
914
|
-
factory.createPropertyAssignment(factory.createIdentifier('region'), factory.createPropertyAccessExpression(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('Stack'), factory.createIdentifier('of')), undefined, [factory.createIdentifier(httpApiVar)]), factory.createIdentifier('region'))),
|
|
915
|
-
]));
|
|
916
|
-
});
|
|
917
|
-
const addOutputStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier('addOutput')), undefined, [
|
|
918
|
-
factory.createObjectLiteralExpression([
|
|
919
|
-
factory.createPropertyAssignment(factory.createIdentifier('api'), factory.createObjectLiteralExpression([
|
|
920
|
-
factory.createPropertyAssignment(factory.createIdentifier('REST'), factory.createObjectLiteralExpression(apiOutputs)),
|
|
921
|
-
])),
|
|
922
|
-
]),
|
|
923
|
-
]));
|
|
924
|
-
nodes.push(addOutputStatement);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
if (((_12 = renderArgs.storage) === null || _12 === void 0 ? void 0 : _12.dynamoFunctionAccess) && renderArgs.storage.dynamoFunctionAccess.length > 0) {
|
|
928
|
-
const uniqueFunctionAccess = new Map();
|
|
929
|
-
renderArgs.storage.dynamoFunctionAccess.forEach((functionAccess) => {
|
|
930
|
-
const key = `${functionAccess.functionName}-${functionAccess.tableResource}`;
|
|
931
|
-
if (!uniqueFunctionAccess.has(key)) {
|
|
932
|
-
uniqueFunctionAccess.set(key, functionAccess);
|
|
933
|
-
}
|
|
934
|
-
else {
|
|
935
|
-
const existing = uniqueFunctionAccess.get(key);
|
|
936
|
-
if (existing) {
|
|
937
|
-
const mergedActions = [...new Set([...existing.actions, ...functionAccess.actions])];
|
|
938
|
-
uniqueFunctionAccess.set(key, { ...existing, actions: mergedActions });
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
uniqueFunctionAccess.forEach((functionAccess) => {
|
|
943
|
-
var _a, _b;
|
|
944
|
-
const matchingTable = (_b = (_a = renderArgs.storage) === null || _a === void 0 ? void 0 : _a.dynamoTables) === null || _b === void 0 ? void 0 : _b.find((table) => {
|
|
945
|
-
const baseTableName = table.tableName.split('-')[0];
|
|
946
|
-
const tableRefPattern = new RegExp(`storage${baseTableName.replace(/[^a-zA-Z0-9]/g, '')}(Name|Arn)`, 'i');
|
|
947
|
-
return tableRefPattern.test(functionAccess.tableResource);
|
|
948
|
-
});
|
|
949
|
-
if (matchingTable) {
|
|
950
|
-
const sanitizedTableName = this.sanitizeVariableName(matchingTable.tableName.replace(/-[^-]+$/, ''));
|
|
951
|
-
const grantStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(sanitizedTableName), factory.createIdentifier('grant')), undefined, [
|
|
952
|
-
factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend'), factory.createIdentifier(functionAccess.functionName)), factory.createIdentifier('resources')), factory.createIdentifier('lambda')),
|
|
953
|
-
...functionAccess.actions.map((action) => factory.createStringLiteral(action)),
|
|
954
|
-
]));
|
|
955
|
-
nodes.push(grantStatement);
|
|
956
|
-
}
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
if (((_13 = renderArgs.function) === null || _13 === void 0 ? void 0 : _13.functionsWithDataModelAccess) && renderArgs.data) {
|
|
960
|
-
const uniqueDataModelAccess = new Map();
|
|
961
|
-
for (const [functionName, tableAccesses] of renderArgs.function.functionsWithDataModelAccess) {
|
|
962
|
-
for (const tableAccess of tableAccesses) {
|
|
963
|
-
const key = `${functionName}-${tableAccess.tableName}`;
|
|
964
|
-
if (!uniqueDataModelAccess.has(key)) {
|
|
965
|
-
uniqueDataModelAccess.set(key, tableAccess);
|
|
966
|
-
}
|
|
967
|
-
else {
|
|
968
|
-
const existing = uniqueDataModelAccess.get(key);
|
|
969
|
-
if (existing) {
|
|
970
|
-
const mergedActions = [...new Set([...existing.actions, ...tableAccess.actions])];
|
|
971
|
-
uniqueDataModelAccess.set(key, { ...existing, actions: mergedActions });
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
uniqueDataModelAccess.forEach((tableAccess) => {
|
|
977
|
-
const tableName = tableAccess.tableName.replace('Table', '');
|
|
978
|
-
nodes.push(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createElementAccessExpression(factory.createIdentifier('backend.data.resources.tables'), factory.createStringLiteral(tableName)), factory.createIdentifier('grant')), undefined, [
|
|
979
|
-
factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${tableAccess.functionName}.resources`), factory.createIdentifier('lambda')),
|
|
980
|
-
...tableAccess.actions.map((action) => factory.createStringLiteral(action)),
|
|
981
|
-
])));
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
if (renderArgs.dynamoTriggers && renderArgs.dynamoTriggers.length > 0) {
|
|
985
|
-
renderArgs.dynamoTriggers.forEach((trigger) => {
|
|
986
|
-
if (trigger.models.length > 0) {
|
|
987
|
-
const forStatement = factory.createForOfStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration('model', undefined, undefined, undefined)], typescript_1.default.NodeFlags.Const), factory.createArrayLiteralExpression(trigger.models.map((model) => factory.createStringLiteral(model))), factory.createBlock([
|
|
988
|
-
factory.createVariableStatement([], factory.createVariableDeclarationList([
|
|
989
|
-
factory.createVariableDeclaration('table', undefined, undefined, factory.createElementAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('backend.data.resources'), factory.createIdentifier('tables')), factory.createIdentifier('model'))),
|
|
990
|
-
], typescript_1.default.NodeFlags.Const)),
|
|
991
|
-
factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${trigger.functionName}.resources`), factory.createIdentifier('lambda')), factory.createIdentifier('addEventSource')), undefined, [
|
|
992
|
-
factory.createNewExpression(factory.createIdentifier('DynamoEventSource'), undefined, [
|
|
993
|
-
factory.createIdentifier('table'),
|
|
994
|
-
factory.createObjectLiteralExpression([
|
|
995
|
-
factory.createPropertyAssignment('startingPosition', factory.createPropertyAccessExpression(factory.createIdentifier('StartingPosition'), factory.createIdentifier('LATEST'))),
|
|
996
|
-
]),
|
|
997
|
-
]),
|
|
998
|
-
])),
|
|
999
|
-
factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('table'), factory.createIdentifier('grantStreamRead')), undefined, [
|
|
1000
|
-
factory.createNonNullExpression(factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${trigger.functionName}.resources.lambda`), factory.createIdentifier('role'))),
|
|
1001
|
-
])),
|
|
1002
|
-
factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier('table'), factory.createIdentifier('grantTableListStreams')), undefined, [
|
|
1003
|
-
factory.createNonNullExpression(factory.createPropertyAccessExpression(factory.createIdentifier(`backend.${trigger.functionName}.resources.lambda`), factory.createIdentifier('role'))),
|
|
1004
|
-
])),
|
|
1005
|
-
], true));
|
|
1006
|
-
nodes.push(forStatement);
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
return factory.createNodeArray([...imports, ts_factory_utils_1.newLineIdentifier, ...errors, ts_factory_utils_1.newLineIdentifier, backendStatement, ...nodes], true);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
exports.BackendSynthesizer = BackendSynthesizer;
|
|
1014
|
-
//# sourceMappingURL=synthesizer.js.map
|