diff --git a/codebuild_specs/e2e_workflow.yml b/codebuild_specs/e2e_workflow.yml index 2ddd172910..c812f241f2 100644 --- a/codebuild_specs/e2e_workflow.yml +++ b/codebuild_specs/e2e_workflow.yml @@ -76,6 +76,7 @@ batch: TEST_SUITE: >- src/__tests__/api_7.test.ts|src/__tests__/schema-function-2.test.ts|src/__tests__/global_sandbox.test.ts|src/__tests__/graphql-v2/lambda-conflict-handler.test.ts|src/__tests__/graphql-v2/index-with-stack-mappings.test.ts CLI_REGION: eu-west-1 + CLI_REGION: eu-west-1 depend-on: - publish_to_local_registry - identifier: >- @@ -88,6 +89,7 @@ batch: TEST_SUITE: >- src/__tests__/api_5.test.ts|src/__tests__/schema-function-1.test.ts|src/__tests__/generate_ts_data_schema.test.ts|src/__tests__/resolvers.test.ts|src/__tests__/graphql-v2/sync_query_datastore.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: api_6_api_lambda_auth @@ -99,6 +101,7 @@ batch: TEST_SUITE: >- src/__tests__/api_6.test.ts|src/__tests__/graphql-v2/api_lambda_auth.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: rds_v2 @@ -109,6 +112,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-v2.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: schema_iterative_update_5 @@ -119,6 +123,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-iterative-update-5.test.ts CLI_REGION: ap-south-1 + CLI_REGION: ap-south-1 depend-on: - publish_to_local_registry - identifier: schema_auth_2 @@ -129,6 +134,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-2.test.ts CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-1 depend-on: - publish_to_local_registry - identifier: schema_auth_10 @@ -139,6 +145,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-10.test.ts CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-2 depend-on: - publish_to_local_registry - identifier: schema_auth_1 @@ -149,6 +156,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-1.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: schema_auth_13 @@ -159,6 +167,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-13.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: schema_auth_12 @@ -169,6 +178,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-12.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: schema_auth_3 @@ -179,6 +189,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-3.test.ts CLI_REGION: eu-south-1 + CLI_REGION: eu-south-1 depend-on: - publish_to_local_registry - identifier: schema_auth_15 @@ -189,6 +200,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-15.test.ts CLI_REGION: eu-west-1 + CLI_REGION: eu-west-1 depend-on: - publish_to_local_registry - identifier: schema_auth_8 @@ -199,6 +211,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-8.test.ts CLI_REGION: eu-west-3 + CLI_REGION: eu-west-3 depend-on: - publish_to_local_registry - identifier: schema_auth_4 @@ -209,6 +222,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-4.test.ts CLI_REGION: me-south-1 + CLI_REGION: me-south-1 depend-on: - publish_to_local_registry - identifier: schema_auth_11 @@ -219,6 +233,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-11.test.ts CLI_REGION: sa-east-1 + CLI_REGION: sa-east-1 depend-on: - publish_to_local_registry - identifier: sql_generate_unauth @@ -229,6 +244,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-generate-unauth.test.ts CLI_REGION: us-west-2 + CLI_REGION: us-west-2 depend-on: - publish_to_local_registry - identifier: schema_model @@ -239,6 +255,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-model.test.ts CLI_REGION: us-east-2 + CLI_REGION: us-east-2 depend-on: - publish_to_local_registry - identifier: rds_v2_test_utils @@ -249,6 +266,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-v2-test-utils.test.ts CLI_REGION: ap-northeast-2 + CLI_REGION: ap-northeast-2 depend-on: - publish_to_local_registry - identifier: rds_relational_directives @@ -259,6 +277,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-relational-directives.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: rds_pg_v2_generate_schema @@ -269,6 +288,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-v2-generate-schema.test.ts CLI_REGION: ap-south-1 + CLI_REGION: ap-south-1 depend-on: - publish_to_local_registry - identifier: rds_pg_userpool_auth @@ -279,6 +299,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-userpool-auth.test.ts CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-1 depend-on: - publish_to_local_registry - identifier: rds_pg_userpool_auth_fields @@ -289,6 +310,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-userpool-auth-fields.test.ts CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-2 depend-on: - publish_to_local_registry - identifier: rds_pg_relational_directives @@ -299,6 +321,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-relational-directives.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: rds_pg_refers_to @@ -309,6 +332,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-refers-to.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: rds_pg_refers_to_fields @@ -319,6 +343,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-refers-to-fields.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: rds_pg_oidc_auth @@ -329,6 +354,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-oidc-auth.test.ts CLI_REGION: eu-west-1 + CLI_REGION: eu-west-1 depend-on: - publish_to_local_registry - identifier: rds_pg_oidc_auth_fields @@ -339,6 +365,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-oidc-auth-fields.test.ts CLI_REGION: eu-west-2 + CLI_REGION: eu-west-2 depend-on: - publish_to_local_registry - identifier: rds_pg_model_v2 @@ -349,6 +376,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-model-v2.test.ts CLI_REGION: eu-west-3 + CLI_REGION: eu-west-3 depend-on: - publish_to_local_registry - identifier: rds_pg_import @@ -359,6 +387,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-import.test.ts CLI_REGION: sa-east-1 + CLI_REGION: sa-east-1 depend-on: - publish_to_local_registry - identifier: rds_pg_field_auth_userpool_static_dynamic @@ -369,6 +398,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-field-auth-userpool-static-dynamic.test.ts CLI_REGION: us-east-1 + CLI_REGION: us-east-1 depend-on: - publish_to_local_registry - identifier: rds_pg_field_auth_userpool_iam @@ -379,6 +409,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-field-auth-userpool-iam.test.ts CLI_REGION: us-east-2 + CLI_REGION: us-east-2 depend-on: - publish_to_local_registry - identifier: rds_pg_field_auth_lambda @@ -389,6 +420,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-field-auth-lambda.test.ts CLI_REGION: us-west-1 + CLI_REGION: us-west-1 depend-on: - publish_to_local_registry - identifier: rds_pg_field_auth_identityPool @@ -399,6 +431,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-field-auth-identityPool.test.ts CLI_REGION: us-west-2 + CLI_REGION: us-west-2 depend-on: - publish_to_local_registry - identifier: rds_pg_field_auth_iam @@ -409,6 +442,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-field-auth-iam.test.ts CLI_REGION: ap-northeast-1 + CLI_REGION: ap-northeast-1 depend-on: - publish_to_local_registry - identifier: rds_pg_field_auth_apikey @@ -419,6 +453,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-field-auth-apikey.test.ts CLI_REGION: ap-northeast-2 + CLI_REGION: ap-northeast-2 depend-on: - publish_to_local_registry - identifier: rds_pg_custom_claims_refersto_auth @@ -429,6 +464,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-custom-claims-refersto-auth.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: rds_pg_auth_iam @@ -439,6 +475,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-auth-iam.test.ts CLI_REGION: ap-south-1 + CLI_REGION: ap-south-1 depend-on: - publish_to_local_registry - identifier: rds_pg_auth_iam_apikey_lambda_subscription @@ -449,6 +486,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-auth-iam-apikey-lambda-subscription.test.ts CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-1 depend-on: - publish_to_local_registry - identifier: rds_pg_auth_apikey_lambda @@ -459,6 +497,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-auth-apikey-lambda.test.ts CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-2 depend-on: - publish_to_local_registry - identifier: rds_pg_array_objects @@ -469,6 +508,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-pg-array-objects.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_v2_generate_schema @@ -479,6 +519,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-v2-generate-schema.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_userpool_auth @@ -489,6 +530,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-userpool-auth.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_userpool_auth_fields @@ -499,6 +541,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-userpool-auth-fields.test.ts CLI_REGION: eu-west-1 + CLI_REGION: eu-west-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_refers_to @@ -509,6 +552,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-refers-to.test.ts CLI_REGION: eu-west-2 + CLI_REGION: eu-west-2 depend-on: - publish_to_local_registry - identifier: rds_mysql_refers_to_fields @@ -519,6 +563,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-refers-to-fields.test.ts CLI_REGION: eu-west-3 + CLI_REGION: eu-west-3 depend-on: - publish_to_local_registry - identifier: rds_mysql_oidc_auth @@ -529,6 +574,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-oidc-auth.test.ts CLI_REGION: sa-east-1 + CLI_REGION: sa-east-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_oidc_auth_fields @@ -539,6 +585,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-oidc-auth-fields.test.ts CLI_REGION: us-east-1 + CLI_REGION: us-east-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_multi_auth_1 @@ -549,6 +596,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-multi-auth-1.test.ts CLI_REGION: us-east-2 + CLI_REGION: us-east-2 depend-on: - publish_to_local_registry - identifier: rds_mysql_model_v2 @@ -559,6 +607,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-model-v2.test.ts CLI_REGION: us-west-1 + CLI_REGION: us-west-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_field_auth_userpool_static_dynamic @@ -569,6 +618,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-field-auth-userpool-static-dynamic.test.ts CLI_REGION: us-west-2 + CLI_REGION: us-west-2 depend-on: - publish_to_local_registry - identifier: rds_mysql_field_auth_userpool_iam @@ -579,6 +629,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-field-auth-userpool-iam.test.ts CLI_REGION: ap-northeast-1 + CLI_REGION: ap-northeast-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_field_auth_lambda @@ -589,6 +640,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-field-auth-lambda.test.ts CLI_REGION: ap-northeast-2 + CLI_REGION: ap-northeast-2 depend-on: - publish_to_local_registry - identifier: rds_mysql_field_auth_identityPool @@ -599,6 +651,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-field-auth-identityPool.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: rds_mysql_field_auth_iam @@ -609,6 +662,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-field-auth-iam.test.ts CLI_REGION: ap-south-1 + CLI_REGION: ap-south-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_field_auth_apikey @@ -619,6 +673,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-field-auth-apikey.test.ts CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_custom_claims_refersto_auth @@ -629,6 +684,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-custom-claims-refersto-auth.test.ts CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-2 depend-on: - publish_to_local_registry - identifier: rds_mysql_auth_iam @@ -639,6 +695,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-auth-iam.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_auth_iam_apikey_lambda_subscription @@ -649,6 +706,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-auth-iam-apikey-lambda-subscription.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: rds_mysql_auth_apikey_lambda @@ -659,6 +717,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/rds-mysql-auth-apikey-lambda.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: schema_auth_9 @@ -669,6 +728,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-9.test.ts CLI_REGION: ap-east-1 + CLI_REGION: ap-east-1 depend-on: - publish_to_local_registry - identifier: schema_auth_7 @@ -679,6 +739,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-7.test.ts CLI_REGION: ap-northeast-1 + CLI_REGION: ap-northeast-1 depend-on: - publish_to_local_registry - identifier: schema_auth_14 @@ -689,6 +750,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-14.test.ts CLI_REGION: ap-northeast-2 + CLI_REGION: ap-northeast-2 depend-on: - publish_to_local_registry - identifier: schema_auth_5 @@ -699,6 +761,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-5.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: schema_searchable @@ -720,6 +783,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/graphql-v2/searchable-datastore.test.ts CLI_REGION: us-west-1 + CLI_REGION: us-west-1 USE_PARENT_ACCOUNT: 1 depend-on: - publish_to_local_registry @@ -731,6 +795,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/schema-auth-6.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: searchable_previous_deployment_had_node_to_node @@ -742,6 +807,7 @@ batch: TEST_SUITE: >- src/__tests__/graphql-v2/searchable-node-to-node-encryption/searchable-previous-deployment-had-node-to-node.test.ts CLI_REGION: ap-northeast-1 + CLI_REGION: ap-northeast-1 depend-on: - publish_to_local_registry - identifier: searchable_previous_deployment_no_node_to_node @@ -753,6 +819,7 @@ batch: TEST_SUITE: >- src/__tests__/graphql-v2/searchable-node-to-node-encryption/searchable-previous-deployment-no-node-to-node.test.ts CLI_REGION: ap-northeast-2 + CLI_REGION: ap-northeast-2 depend-on: - publish_to_local_registry - identifier: utils_ddb_iam_access_data_construct_custom_logic_amplify_table_5 @@ -764,6 +831,7 @@ batch: TEST_SUITE: >- src/__tests__/utils.test.ts|src/__tests__/ddb-iam-access.test.ts|src/__tests__/data-construct.test.ts|src/__tests__/custom-logic.test.ts|src/__tests__/amplify-table-5.test.ts CLI_REGION: eu-west-2 + CLI_REGION: eu-west-2 depend-on: - publish_to_local_registry - identifier: >- @@ -858,6 +926,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-pg-models.test.ts CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-1 depend-on: - publish_to_local_registry - identifier: sql_pg_canary @@ -881,6 +950,16 @@ batch: CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry + - identifier: sql_pg_auto_increment + buildspec: codebuild_specs/run_cdk_tests.yml + env: + compute-type: BUILD_GENERAL1_MEDIUM + variables: + NODE_OPTIONS: '--max-old-space-size=6656' + TEST_SUITE: src/__tests__/sql-pg-auto-increment.test.ts + CLI_REGION: ca-central-1 + depend-on: + - publish_to_local_registry - identifier: sql_pg_array_objects buildspec: codebuild_specs/run_cdk_tests.yml env: @@ -889,6 +968,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-pg-array-objects.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: sql_mysql_canary @@ -899,6 +979,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-mysql-canary.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: sql_models_2 @@ -909,6 +990,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-models-2.test.ts CLI_REGION: eu-west-1 + CLI_REGION: eu-west-1 depend-on: - publish_to_local_registry - identifier: sql_models_1 @@ -919,6 +1001,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-models-1.test.ts CLI_REGION: eu-west-2 + CLI_REGION: eu-west-2 depend-on: - publish_to_local_registry - identifier: sql_iam_access @@ -929,6 +1012,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-iam-access.test.ts CLI_REGION: eu-west-3 + CLI_REGION: eu-west-3 depend-on: - publish_to_local_registry - identifier: default_ddb_canary @@ -939,6 +1023,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/default-ddb-canary.test.ts CLI_REGION: eu-west-2 + CLI_REGION: eu-west-2 depend-on: - publish_to_local_registry - identifier: base_cdk_ap_east_1 @@ -981,6 +1066,16 @@ batch: CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry + - identifier: base_cdk_ap_northeast_3 + buildspec: codebuild_specs/run_cdk_tests.yml + env: + compute-type: BUILD_GENERAL1_MEDIUM + variables: + NODE_OPTIONS: '--max-old-space-size=6656' + TEST_SUITE: src/__tests__/base-cdk.test.ts + CLI_REGION: ap-northeast-3 + depend-on: + - publish_to_local_registry - identifier: base_cdk_ap_south_1 buildspec: codebuild_specs/run_cdk_tests.yml env: @@ -1149,6 +1244,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/amplify-table-4.test.ts CLI_REGION: me-south-1 + CLI_REGION: me-south-1 depend-on: - publish_to_local_registry - identifier: amplify_table_3 @@ -1159,6 +1255,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/amplify-table-3.test.ts CLI_REGION: sa-east-1 + CLI_REGION: sa-east-1 depend-on: - publish_to_local_registry - identifier: amplify_table_2 @@ -1169,6 +1266,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/amplify-table-2.test.ts CLI_REGION: us-east-1 + CLI_REGION: us-east-1 depend-on: - publish_to_local_registry - identifier: amplify_table_1 @@ -1179,6 +1277,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/amplify-table-1.test.ts CLI_REGION: us-east-2 + CLI_REGION: us-east-2 depend-on: - publish_to_local_registry - identifier: amplify_ddb_canary @@ -1189,6 +1288,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/amplify-ddb-canary.test.ts CLI_REGION: us-west-1 + CLI_REGION: us-west-1 depend-on: - publish_to_local_registry - identifier: all_auth_modes @@ -1199,6 +1299,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/all-auth-modes.test.ts CLI_REGION: us-west-2 + CLI_REGION: us-west-2 depend-on: - publish_to_local_registry - identifier: admin_role @@ -1209,6 +1310,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/admin-role.test.ts CLI_REGION: ap-east-1 + CLI_REGION: ap-east-1 depend-on: - publish_to_local_registry - identifier: sql_custom_ssl @@ -1219,6 +1321,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/sql-custom-ssl/sql-custom-ssl.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: restricted_field_auth_gen2 @@ -1230,6 +1333,7 @@ batch: TEST_SUITE: >- src/__tests__/restricted-field-auth/restricted-field-auth-gen2.test.ts CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-1 depend-on: - publish_to_local_registry - identifier: restricted_field_auth_gen1 @@ -1241,6 +1345,7 @@ batch: TEST_SUITE: >- src/__tests__/restricted-field-auth/restricted-field-auth-gen1.test.ts CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-2 depend-on: - publish_to_local_registry - identifier: restricted_field_auth_gen2_subscriptions_off @@ -1252,6 +1357,7 @@ batch: TEST_SUITE: >- src/__tests__/restricted-field-auth/subscriptions-off/restricted-field-auth-gen2-subscriptions-off.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: restricted_field_auth_gen1_subscriptions_off @@ -1263,6 +1369,7 @@ batch: TEST_SUITE: >- src/__tests__/restricted-field-auth/subscriptions-off/restricted-field-auth-gen1-subscriptions-off.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: references_sqlprimary_sqlrelated @@ -1274,6 +1381,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/references/references-sqlprimary-sqlrelated.test.ts CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-2 depend-on: - publish_to_local_registry - identifier: references_sqlprimary_ddbrelated @@ -1285,6 +1393,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/references/references-sqlprimary-ddbrelated.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: references_ddbprimary_sqlrelated @@ -1296,6 +1405,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/references/references-ddbprimary-sqlrelated.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: references_ddbprimary_ddbrelated @@ -1307,6 +1417,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/references/references-ddbprimary-ddbrelated.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: recursive_relationships_sql @@ -1318,6 +1429,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/recursive/recursive-relationships-sql.test.ts CLI_REGION: eu-south-1 + CLI_REGION: eu-south-1 depend-on: - publish_to_local_registry - identifier: recursive_relationships_ddb @@ -1329,6 +1441,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/recursive/recursive-relationships-ddb.test.ts CLI_REGION: eu-west-1 + CLI_REGION: eu-west-1 depend-on: - publish_to_local_registry - identifier: uuid_pk_sqlprimary_sqlrelated @@ -1340,6 +1453,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/postgres-uuid-pk/uuid-pk-sqlprimary-sqlrelated.test.ts CLI_REGION: eu-west-2 + CLI_REGION: eu-west-2 depend-on: - publish_to_local_registry - identifier: uuid_pk_sqlprimary_ddbrelated @@ -1351,6 +1465,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/postgres-uuid-pk/uuid-pk-sqlprimary-ddbrelated.test.ts CLI_REGION: eu-west-3 + CLI_REGION: eu-west-3 depend-on: - publish_to_local_registry - identifier: uuid_pk_ddbprimary_sqlrelated @@ -1362,6 +1477,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/postgres-uuid-pk/uuid-pk-ddbprimary-sqlrelated.test.ts CLI_REGION: me-south-1 + CLI_REGION: me-south-1 depend-on: - publish_to_local_registry - identifier: multi_relationship_sqlprimary_sqlrelated @@ -1373,6 +1489,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/multi-relationship/multi-relationship-sqlprimary-sqlrelated.test.ts CLI_REGION: sa-east-1 + CLI_REGION: sa-east-1 depend-on: - publish_to_local_registry - identifier: multi_relationship_sqlprimary_ddbrelated @@ -1384,6 +1501,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/multi-relationship/multi-relationship-sqlprimary-ddbrelated.test.ts CLI_REGION: us-east-1 + CLI_REGION: us-east-1 depend-on: - publish_to_local_registry - identifier: multi_relationship_ddbprimary_sqlrelated @@ -1395,6 +1513,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/multi-relationship/multi-relationship-ddbprimary-sqlrelated.test.ts CLI_REGION: us-east-2 + CLI_REGION: us-east-2 depend-on: - publish_to_local_registry - identifier: multi_relationship_ddbprimary_ddbrelated @@ -1406,6 +1525,7 @@ batch: TEST_SUITE: >- src/__tests__/relationships/multi-relationship/multi-relationship-ddbprimary-ddbrelated.test.ts CLI_REGION: us-west-1 + CLI_REGION: us-west-1 depend-on: - publish_to_local_registry - identifier: relationships_gen1 @@ -1416,6 +1536,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/relationships/gen1/relationships-gen1.test.ts CLI_REGION: us-west-2 + CLI_REGION: us-west-2 depend-on: - publish_to_local_registry - identifier: assoc_field_subscriptions_off @@ -1740,6 +1861,7 @@ batch: TEST_SUITE: >- src/__tests__/NonModelAuthV2Function.e2e.test.ts|src/__tests__/TransformerOptionsV2.e2e.test.ts|src/__tests__/PredictionsTransformerV2Tests.e2e.test.ts|src/__tests__/DefaultValueTransformer.e2e.test.ts|src/__tests__/PerFieldAuthV2TransformerWithFF.e2e.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: >- @@ -1752,6 +1874,7 @@ batch: TEST_SUITE: >- src/__tests__/PerFieldAuthV2Transformer.e2e.test.ts|src/__tests__/BelongsToTransformerV2.e2e.test.ts|src/__tests__/RelationalWithAuthV2WithFF.e2e.test.ts|src/__tests__/IndexWithAuthV2.e2e.test.ts|src/__tests__/IndexWithAuthV2WithFF.e2e.test.ts CLI_REGION: ap-south-1 + CLI_REGION: ap-south-1 depend-on: - publish_to_local_registry - identifier: >- @@ -1764,6 +1887,7 @@ batch: TEST_SUITE: >- src/__tests__/SubscriptionsWithAuthV2WithFF.e2e.test.ts|src/__tests__/MultiAuthV2Transformer.e2e.test.ts|src/__tests__/ModelTransformer.e2e.test.ts|src/__tests__/SubscriptionsWithAuthV2.e2e.test.ts|src/__tests__/RelationalWithAuthV2.e2e.test.ts CLI_REGION: ap-southeast-1 + CLI_REGION: ap-southeast-1 depend-on: - publish_to_local_registry - identifier: >- @@ -1776,6 +1900,7 @@ batch: TEST_SUITE: >- src/__tests__/MapsToTransformer.e2e.test.ts|src/__tests__/MultiAuthV2TransformerWithFF.e2e.test.ts|src/__tests__/AuthV2Transformer.e2e.test.ts|src/__tests__/AuthV2ExhaustiveT1B.test.ts|src/__tests__/AuthV2ExhaustiveT1A.test.ts CLI_REGION: ap-southeast-2 + CLI_REGION: ap-southeast-2 depend-on: - publish_to_local_registry - identifier: >- @@ -1788,6 +1913,7 @@ batch: TEST_SUITE: >- src/__tests__/AuthV2TransformerWithFF.e2e.test.ts|src/__tests__/SubscriptionsRuntimeFiltering.e2e.test.ts|src/__tests__/AuthV2ExhaustiveT2A.test.ts|src/__tests__/AuthV2ExhaustiveT1C.test.ts|src/__tests__/AuthV2ExhaustiveT1D.test.ts CLI_REGION: ca-central-1 + CLI_REGION: ca-central-1 depend-on: - publish_to_local_registry - identifier: >- @@ -1800,6 +1926,7 @@ batch: TEST_SUITE: >- src/__tests__/AuthV2ExhaustiveT2B.test.ts|src/__tests__/AuthV2ExhaustiveT2D.test.ts|src/__tests__/AuthV2ExhaustiveT2C.test.ts|src/__tests__/RelationalWithAuthV2Redacted.e2e.test.ts|src/__tests__/RelationalWithAuthV2NonRedacted.e2e.test.ts CLI_REGION: eu-central-1 + CLI_REGION: eu-central-1 depend-on: - publish_to_local_registry - identifier: >- @@ -1812,6 +1939,7 @@ batch: TEST_SUITE: >- src/__tests__/AuthV2TransformerIAM.test.ts|src/__tests__/AuthV2ExhaustiveT3D.test.ts|src/__tests__/AuthV2ExhaustiveT3C.test.ts|src/__tests__/AuthV2ExhaustiveT3B.test.ts|src/__tests__/AuthV2ExhaustiveT3A.test.ts CLI_REGION: eu-north-1 + CLI_REGION: eu-north-1 depend-on: - publish_to_local_registry - identifier: >- @@ -1824,6 +1952,7 @@ batch: TEST_SUITE: >- src/__tests__/SearchableModelTransformerV2.e2e.test.ts|src/__tests__/SearchableWithAuthV2WithFF.e2e.test.ts|src/__tests__/SearchableWithAuthV2.e2e.test.ts CLI_REGION: eu-west-2 + CLI_REGION: eu-west-2 depend-on: - publish_to_local_registry - identifier: FunctionTransformerTestsV2 @@ -1834,6 +1963,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/FunctionTransformerTestsV2.e2e.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 USE_PARENT_ACCOUNT: 1 depend-on: - publish_to_local_registry @@ -1845,6 +1975,7 @@ batch: NODE_OPTIONS: '--max-old-space-size=6656' TEST_SUITE: src/__tests__/HttpTransformerV2.e2e.test.ts CLI_REGION: ap-northeast-3 + CLI_REGION: ap-northeast-3 depend-on: - publish_to_local_registry - identifier: cleanup_e2e_resources diff --git a/packages/amplify-graphql-api-construct-tests/package.json b/packages/amplify-graphql-api-construct-tests/package.json index c0e26375fb..103de978b0 100644 --- a/packages/amplify-graphql-api-construct-tests/package.json +++ b/packages/amplify-graphql-api-construct-tests/package.json @@ -1,6 +1,7 @@ { "name": "amplify-graphql-api-construct-tests", "version": "1.10.1", + "version": "1.10.1", "description": "E2e test suite", "repository": { "type": "git", @@ -32,6 +33,7 @@ "@aws-sdk/client-sts": "3.624.0", "@faker-js/faker": "^8.2.0", "amplify-category-api-e2e-core": "5.0.4", + "amplify-category-api-e2e-core": "5.0.4", "aws-amplify": "^4.2.8", "aws-appsync": "^4.1.1", "fs-extra": "^8.1.0", @@ -42,10 +44,13 @@ "@aws-amplify/amplify-cli-core": "^4.3.9" }, "devDependencies": { + "@aws-amplify/graphql-transformer-core": "3.2.1", + "@aws-amplify/graphql-transformer-interfaces": "4.1.2", "@aws-amplify/graphql-transformer-core": "3.2.1", "@aws-amplify/graphql-transformer-interfaces": "4.1.2", "@types/node": "^18.0.0", "aws-cdk-lib": "2.158.0", + "aws-cdk-lib": "2.158.0", "constructs": "10.3.0", "ts-node": "^8.10.2" }, diff --git a/packages/amplify-graphql-schema-generator/src/ts-schema-generator/helpers.ts b/packages/amplify-graphql-schema-generator/src/ts-schema-generator/helpers.ts index 0683ec7826..9041509639 100644 --- a/packages/amplify-graphql-schema-generator/src/ts-schema-generator/helpers.ts +++ b/packages/amplify-graphql-schema-generator/src/ts-schema-generator/helpers.ts @@ -1,5 +1,6 @@ import ts from 'typescript'; import { TYPESCRIPT_DATA_SCHEMA_CONSTANTS, toPascalCase } from 'graphql-transformer-common'; +import { TYPESCRIPT_DATA_SCHEMA_CONSTANTS, toPascalCase } from 'graphql-transformer-common'; import { VpcConfig } from '@aws-amplify/graphql-transformer-interfaces'; import { DBEngineType, EnumType, Field, FieldType, Model, Schema } from '../schema-representation'; @@ -27,6 +28,7 @@ const GQL_TYPESCRIPT_DATA_SCHEMA_TYPE_MAP = { * @returns Typescript data schema property in TS Node format */ const createProperty = (field: Field): ts.Node => { + const typeExpression = createDataType(field); const typeExpression = createDataType(field); return ts.factory.createPropertyAssignment(ts.factory.createIdentifier(field.name), typeExpression as ts.Expression); }; @@ -35,6 +37,7 @@ const createProperty = (field: Field): ts.Node => { * Creates a typescript data schema type from internal SQL schema representation * Example typescript data schema type output: `a.string().required()` * @param field SQL IR field + * @param field SQL IR field * @returns Typescript data schema type in TS Node format */ const createDataType = (field: Field): ts.Node => { @@ -51,24 +54,44 @@ const createDataType = (field: Field): ts.Node => { ); } + if (field.type.kind === 'Scalar') { +const createDataType = (field: Field): ts.Node => { + if (isSequenceField(field)) { + const baseTypeExpression = + field.type.kind === 'NonNull' + ? createDataType(new Field(field.name, field.type.type)) + : createDataType(new Field(field.name, field.type)); + + return ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(baseTypeExpression as ts.Expression, TYPESCRIPT_DATA_SCHEMA_CONSTANTS.DEFAULT_METHOD), + undefined, + undefined, + ); + } + if (field.type.kind === 'Scalar') { return ts.factory.createCallExpression( + ts.factory.createIdentifier(`${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REFERENCE_A}.${getTypescriptDataSchemaType(field.type.name)}`), ts.factory.createIdentifier(`${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REFERENCE_A}.${getTypescriptDataSchemaType(field.type.name)}`), undefined, undefined, ); } + if (field.type.kind === 'Enum') { if (field.type.kind === 'Enum') { return ts.factory.createCallExpression( + ts.factory.createIdentifier(`${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REFERENCE_A}.${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REF_METHOD}`), ts.factory.createIdentifier(`${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REFERENCE_A}.${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REF_METHOD}`), undefined, [ts.factory.createStringLiteral(toPascalCase([field.type.name]))], + [ts.factory.createStringLiteral(toPascalCase([field.type.name]))], ); } // We do not import any Database type as 'Custom' type. // In case if there is a custom type in the IR schema, we will import it as string. + if (field.type.kind === 'Custom') { if (field.type.kind === 'Custom') { return ts.factory.createCallExpression( ts.factory.createIdentifier(`${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REFERENCE_A}.${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.STRING_METHOD}`), @@ -81,7 +104,11 @@ const createDataType = (field: Field): ts.Node => { const modifier = field.type.kind === 'List' ? TYPESCRIPT_DATA_SCHEMA_CONSTANTS.ARRAY_METHOD : TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REQUIRED_METHOD; const unwrappedField = new Field(field.name, field.type.type); + const modifier = + field.type.kind === 'List' ? TYPESCRIPT_DATA_SCHEMA_CONSTANTS.ARRAY_METHOD : TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REQUIRED_METHOD; + const unwrappedField = new Field(field.name, field.type.type); return ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(createDataType(unwrappedField) as ts.Expression, ts.factory.createIdentifier(modifier)), ts.factory.createPropertyAccessExpression(createDataType(unwrappedField) as ts.Expression, ts.factory.createIdentifier(modifier)), undefined, undefined, @@ -93,6 +120,11 @@ const isSequenceField = (field: Field): boolean => { return field.default?.kind === 'DB_GENERATED' && sequenceRegex.test(field.default.value.toString()); }; +const isSequenceField = (field: Field): boolean => { + const sequenceRegex = /^nextval\(.+::regclass\)$/; + return field.default?.kind === 'DB_GENERATED' && sequenceRegex.test(field.default.value.toString()); +}; + const getTypescriptDataSchemaType = (type: string): string => { const DEFAULT_DATATYPE = TYPESCRIPT_DATA_SCHEMA_CONSTANTS.STRING_METHOD; const tsDataSchemaType = GQL_TYPESCRIPT_DATA_SCHEMA_TYPE_MAP[type.toLowerCase()]; @@ -126,6 +158,26 @@ const createEnums = (type: EnumType): ts.Node => { return ts.factory.createPropertyAssignment(ts.factory.createIdentifier(toPascalCase([type.name])), typeExpression); }; +/** + * Creates a typescript data schema type from internal SQL schema representation + * Example typescript data schema type output: `a.enum()` + * @param type SQL IR Enum type + * @returns Typescript data schema type in TS Node format + */ +const createEnums = (type: EnumType): ts.Node => { + const typeExpression = ts.factory.createCallExpression( + ts.factory.createIdentifier(`${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REFERENCE_A}.${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.ENUM_METHOD}`), + undefined, + [ + ts.factory.createArrayLiteralExpression( + type.values.map((value) => ts.factory.createStringLiteral(value)), + true, + ), + ], + ); + return ts.factory.createPropertyAssignment(ts.factory.createIdentifier(toPascalCase([type.name])), typeExpression); +}; + const createModel = (model: Model): ts.Node => { const modelExpr = ts.factory.createCallExpression( ts.factory.createIdentifier(`${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.REFERENCE_A}.${TYPESCRIPT_DATA_SCHEMA_CONSTANTS.MODEL_METHOD}`), @@ -208,6 +260,32 @@ export const createSchema = (schema: Schema, config?: DataSourceGenerateConfig): }), ); + const nullableEnumFields = schema.getModels().map((model) => + model + .getFields() + .filter((field) => field.type.kind === 'Enum') + .map((field) => { + if (field.type.kind === 'Enum') { + return createEnums(field.type); + } else { + return undefined; + } + }), + ); + + const requiredEnumFields = schema.getModels().map((model) => + model + .getFields() + .filter((field) => field.type.kind === 'NonNull' && field.type.type.kind === 'Enum') + .map((field) => { + if (field.type.kind === 'NonNull' && field.type.type.kind === 'Enum') { + return createEnums(field.type.type); + } else { + return undefined; + } + }), + ); + const models = schema .getModels() .filter((model) => model.getPrimaryKey()) @@ -230,6 +308,22 @@ export const createSchema = (schema: Schema, config?: DataSourceGenerateConfig): const modelsWithEnums = models.concat(uniqueEnums); + + const combinedEnums = nullableEnumFields.concat(requiredEnumFields).flat(); // making 1 D array + + // to eliminate duplicate definition of enums in case where same enum is referenced in 2 differed models + const seenEnums = new Set(); + const uniqueEnums = combinedEnums.filter((node) => { + if (seenEnums.has(node['name'].escapedText)) { + return false; + } else { + seenEnums.add(node['name'].escapedText); + return true; + } + }); + + const modelsWithEnums = models.concat(uniqueEnums); + const tsSchema = ts.factory.createCallExpression( ts.factory.createPropertyAccessExpression( createConfigureExpression(schema, config), @@ -237,6 +331,7 @@ export const createSchema = (schema: Schema, config?: DataSourceGenerateConfig): ), undefined, [ts.factory.createObjectLiteralExpression(modelsWithEnums as ts.ObjectLiteralElementLike[], true)], + [ts.factory.createObjectLiteralExpression(modelsWithEnums as ts.ObjectLiteralElementLike[], true)], ); return ts.factory.createVariableStatement( [exportModifier],