@marlonjd/graphql-relational-transformer-stack-limits 3.1.13-stack-limits.3

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.
Files changed (113) hide show
  1. package/API.md +97 -0
  2. package/CHANGELOG.md +807 -0
  3. package/README.md +43 -0
  4. package/jest.config.js +12 -0
  5. package/lib/belongs-to/belongs-to-directive-ddb-fields-transformer.d.ts +11 -0
  6. package/lib/belongs-to/belongs-to-directive-ddb-fields-transformer.d.ts.map +1 -0
  7. package/lib/belongs-to/belongs-to-directive-ddb-fields-transformer.js +37 -0
  8. package/lib/belongs-to/belongs-to-directive-ddb-fields-transformer.js.map +1 -0
  9. package/lib/belongs-to/belongs-to-directive-ddb-references-transformer.d.ts +11 -0
  10. package/lib/belongs-to/belongs-to-directive-ddb-references-transformer.d.ts.map +1 -0
  11. package/lib/belongs-to/belongs-to-directive-ddb-references-transformer.js +37 -0
  12. package/lib/belongs-to/belongs-to-directive-ddb-references-transformer.js.map +1 -0
  13. package/lib/belongs-to/belongs-to-directive-sql-transformer.d.ts +11 -0
  14. package/lib/belongs-to/belongs-to-directive-sql-transformer.d.ts.map +1 -0
  15. package/lib/belongs-to/belongs-to-directive-sql-transformer.js +32 -0
  16. package/lib/belongs-to/belongs-to-directive-sql-transformer.js.map +1 -0
  17. package/lib/belongs-to/belongs-to-directive-transformer-factory.d.ts +5 -0
  18. package/lib/belongs-to/belongs-to-directive-transformer-factory.d.ts.map +1 -0
  19. package/lib/belongs-to/belongs-to-directive-transformer-factory.js +32 -0
  20. package/lib/belongs-to/belongs-to-directive-transformer-factory.js.map +1 -0
  21. package/lib/data-source-based-directive-transformer.d.ts +11 -0
  22. package/lib/data-source-based-directive-transformer.d.ts.map +1 -0
  23. package/lib/data-source-based-directive-transformer.js +3 -0
  24. package/lib/data-source-based-directive-transformer.js.map +1 -0
  25. package/lib/graphql-belongs-to-transformer.d.ts +13 -0
  26. package/lib/graphql-belongs-to-transformer.d.ts.map +1 -0
  27. package/lib/graphql-belongs-to-transformer.js +139 -0
  28. package/lib/graphql-belongs-to-transformer.js.map +1 -0
  29. package/lib/graphql-has-many-transformer.d.ts +13 -0
  30. package/lib/graphql-has-many-transformer.d.ts.map +1 -0
  31. package/lib/graphql-has-many-transformer.js +120 -0
  32. package/lib/graphql-has-many-transformer.js.map +1 -0
  33. package/lib/graphql-has-one-transformer.d.ts +13 -0
  34. package/lib/graphql-has-one-transformer.d.ts.map +1 -0
  35. package/lib/graphql-has-one-transformer.js +132 -0
  36. package/lib/graphql-has-one-transformer.js.map +1 -0
  37. package/lib/graphql-many-to-many-transformer.d.ts +22 -0
  38. package/lib/graphql-many-to-many-transformer.d.ts.map +1 -0
  39. package/lib/graphql-many-to-many-transformer.js +384 -0
  40. package/lib/graphql-many-to-many-transformer.js.map +1 -0
  41. package/lib/has-many/has-many-directive-ddb-fields-transformer.d.ts +11 -0
  42. package/lib/has-many/has-many-directive-ddb-fields-transformer.d.ts.map +1 -0
  43. package/lib/has-many/has-many-directive-ddb-fields-transformer.js +36 -0
  44. package/lib/has-many/has-many-directive-ddb-fields-transformer.js.map +1 -0
  45. package/lib/has-many/has-many-directive-ddb-references-transformer.d.ts +11 -0
  46. package/lib/has-many/has-many-directive-ddb-references-transformer.d.ts.map +1 -0
  47. package/lib/has-many/has-many-directive-ddb-references-transformer.js +52 -0
  48. package/lib/has-many/has-many-directive-ddb-references-transformer.js.map +1 -0
  49. package/lib/has-many/has-many-directive-sql-transformer.d.ts +11 -0
  50. package/lib/has-many/has-many-directive-sql-transformer.d.ts.map +1 -0
  51. package/lib/has-many/has-many-directive-sql-transformer.js +32 -0
  52. package/lib/has-many/has-many-directive-sql-transformer.js.map +1 -0
  53. package/lib/has-many/has-many-directive-transformer-factory.d.ts +5 -0
  54. package/lib/has-many/has-many-directive-transformer-factory.d.ts.map +1 -0
  55. package/lib/has-many/has-many-directive-transformer-factory.js +32 -0
  56. package/lib/has-many/has-many-directive-transformer-factory.js.map +1 -0
  57. package/lib/has-one/has-one-directive-ddb-fields-transformer.d.ts +11 -0
  58. package/lib/has-one/has-one-directive-ddb-fields-transformer.d.ts.map +1 -0
  59. package/lib/has-one/has-one-directive-ddb-fields-transformer.js +34 -0
  60. package/lib/has-one/has-one-directive-ddb-fields-transformer.js.map +1 -0
  61. package/lib/has-one/has-one-directive-ddb-references-transformer.d.ts +11 -0
  62. package/lib/has-one/has-one-directive-ddb-references-transformer.d.ts.map +1 -0
  63. package/lib/has-one/has-one-directive-ddb-references-transformer.js +52 -0
  64. package/lib/has-one/has-one-directive-ddb-references-transformer.js.map +1 -0
  65. package/lib/has-one/has-one-directive-sql-transformer.d.ts +11 -0
  66. package/lib/has-one/has-one-directive-sql-transformer.d.ts.map +1 -0
  67. package/lib/has-one/has-one-directive-sql-transformer.js +32 -0
  68. package/lib/has-one/has-one-directive-sql-transformer.js.map +1 -0
  69. package/lib/has-one/has-one-directive-transformer-factory.d.ts +5 -0
  70. package/lib/has-one/has-one-directive-transformer-factory.d.ts.map +1 -0
  71. package/lib/has-one/has-one-directive-transformer-factory.js +32 -0
  72. package/lib/has-one/has-one-directive-transformer-factory.js.map +1 -0
  73. package/lib/index.d.ts +6 -0
  74. package/lib/index.d.ts.map +1 -0
  75. package/lib/index.js +16 -0
  76. package/lib/index.js.map +1 -0
  77. package/lib/resolver/ddb-generator.d.ts +14 -0
  78. package/lib/resolver/ddb-generator.d.ts.map +1 -0
  79. package/lib/resolver/ddb-generator.js +188 -0
  80. package/lib/resolver/ddb-generator.js.map +1 -0
  81. package/lib/resolver/ddb-references-generator.d.ts +11 -0
  82. package/lib/resolver/ddb-references-generator.d.ts.map +1 -0
  83. package/lib/resolver/ddb-references-generator.js +216 -0
  84. package/lib/resolver/ddb-references-generator.js.map +1 -0
  85. package/lib/resolver/generator-factory.d.ts +4 -0
  86. package/lib/resolver/generator-factory.d.ts.map +1 -0
  87. package/lib/resolver/generator-factory.js +18 -0
  88. package/lib/resolver/generator-factory.js.map +1 -0
  89. package/lib/resolver/generator.d.ts +8 -0
  90. package/lib/resolver/generator.d.ts.map +1 -0
  91. package/lib/resolver/generator.js +7 -0
  92. package/lib/resolver/generator.js.map +1 -0
  93. package/lib/resolver/rds-generator.d.ts +16 -0
  94. package/lib/resolver/rds-generator.d.ts.map +1 -0
  95. package/lib/resolver/rds-generator.js +148 -0
  96. package/lib/resolver/rds-generator.js.map +1 -0
  97. package/lib/resolvers.d.ts +8 -0
  98. package/lib/resolvers.d.ts.map +1 -0
  99. package/lib/resolvers.js +246 -0
  100. package/lib/resolvers.js.map +1 -0
  101. package/lib/schema.d.ts +15 -0
  102. package/lib/schema.d.ts.map +1 -0
  103. package/lib/schema.js +379 -0
  104. package/lib/schema.js.map +1 -0
  105. package/lib/types.d.ts +79 -0
  106. package/lib/types.d.ts.map +1 -0
  107. package/lib/types.js +3 -0
  108. package/lib/types.js.map +1 -0
  109. package/lib/utils.d.ts +43 -0
  110. package/lib/utils.d.ts.map +1 -0
  111. package/lib/utils.js +465 -0
  112. package/lib/utils.js.map +1 -0
  113. package/package.json +49 -0
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HasManyDirectiveSQLTransformer = void 0;
4
+ const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
5
+ const generator_factory_1 = require("../resolver/generator-factory");
6
+ const resolvers_1 = require("../resolvers");
7
+ const utils_1 = require("../utils");
8
+ class HasManyDirectiveSQLTransformer {
9
+ constructor() {
10
+ this.dbType = graphql_transformer_core_1.POSTGRES_DB_TYPE || graphql_transformer_core_1.MYSQL_DB_TYPE;
11
+ this.prepare = (context, config) => {
12
+ var _a, _b;
13
+ const modelName = config.object.name.value;
14
+ (0, resolvers_1.setFieldMappingResolverReference)(context, (_b = (_a = config.relatedType) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.value, modelName, config.field.name.value, true);
15
+ };
16
+ this.transformSchema = (context, config) => {
17
+ (0, utils_1.validateParentReferencesFields)(config, context);
18
+ };
19
+ this.generateResolvers = (context, config) => {
20
+ const generator = (0, generator_factory_1.getGenerator)(this.dbType);
21
+ generator.makeHasManyGetItemsConnectionWithKeyResolver(config, context);
22
+ };
23
+ this.validate = (context, config) => {
24
+ (0, utils_1.ensureReferencesArray)(config);
25
+ config.referenceNodes = (0, utils_1.getReferencesNodes)(config, context);
26
+ (0, utils_1.validateReferencesRelationalFieldNullability)(config);
27
+ (0, utils_1.validateReferencesBidirectionality)(config);
28
+ };
29
+ }
30
+ }
31
+ exports.HasManyDirectiveSQLTransformer = HasManyDirectiveSQLTransformer;
32
+ //# sourceMappingURL=has-many-directive-sql-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-many-directive-sql-transformer.js","sourceRoot":"","sources":["../../src/has-many/has-many-directive-sql-transformer.ts"],"names":[],"mappings":";;;AAAA,oFAAwF;AAOxF,qEAA6D;AAC7D,4CAAgE;AAEhE,oCAMkB;AAMlB,MAAa,8BAA8B;IAA3C;QACE,WAAM,GAAG,2CAAgB,IAAI,wCAAa,CAAC;QAE3C,YAAO,GAAG,CAAC,OAA8C,EAAE,MAAqC,EAAQ,EAAE;;YACxG,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YAC3C,IAAA,4CAAgC,EAAC,OAAO,EAAE,MAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,IAAI,0CAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvH,CAAC,CAAC;QAEF,oBAAe,GAAG,CAAC,OAAsD,EAAE,MAAqC,EAAQ,EAAE;YACxH,IAAA,sCAA8B,EAAC,MAAM,EAAE,OAAqC,CAAC,CAAC;QAChF,CAAC,CAAC;QAEF,sBAAiB,GAAG,CAAC,OAAmC,EAAE,MAAqC,EAAQ,EAAE;YACvG,MAAM,SAAS,GAAG,IAAA,gCAAY,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5C,SAAS,CAAC,4CAA4C,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1E,CAAC,CAAC;QAEF,aAAQ,GAAG,CAAC,OAAmC,EAAE,MAAqC,EAAQ,EAAE;YAC9F,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;YAC9B,MAAM,CAAC,cAAc,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5D,IAAA,oDAA4C,EAAC,MAAM,CAAC,CAAC;YACrD,IAAA,0CAAkC,EAAC,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC;CAAA;AAvBD,wEAuBC"}
@@ -0,0 +1,5 @@
1
+ import { ModelDataSourceStrategyDbType } from '@aws-amplify/graphql-transformer-interfaces';
2
+ import { HasManyDirectiveConfiguration } from '../types';
3
+ import { DataSourceBasedDirectiveTransformer } from '../data-source-based-directive-transformer';
4
+ export declare const getHasManyDirectiveTransformer: (dbType: ModelDataSourceStrategyDbType, config: HasManyDirectiveConfiguration) => DataSourceBasedDirectiveTransformer<HasManyDirectiveConfiguration>;
5
+ //# sourceMappingURL=has-many-directive-transformer-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-many-directive-transformer-factory.d.ts","sourceRoot":"","sources":["../../src/has-many/has-many-directive-transformer-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AAWjG,eAAO,MAAM,8BAA8B,WACjC,6BAA6B,UAC7B,6BAA6B,KAEpC,oCAAoC,6BAA6B,CAwBnE,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHasManyDirectiveTransformer = void 0;
4
+ const has_many_directive_ddb_fields_transformer_1 = require("./has-many-directive-ddb-fields-transformer");
5
+ const has_many_directive_sql_transformer_1 = require("./has-many-directive-sql-transformer");
6
+ const has_many_directive_ddb_references_transformer_1 = require("./has-many-directive-ddb-references-transformer");
7
+ const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
8
+ const hasManyDirectiveMySqlTransformer = new has_many_directive_sql_transformer_1.HasManyDirectiveSQLTransformer();
9
+ const hasManyDirectivePostgresTransformer = new has_many_directive_sql_transformer_1.HasManyDirectiveSQLTransformer();
10
+ const hasManyDirectiveDdbFieldsTransformer = new has_many_directive_ddb_fields_transformer_1.HasManyDirectiveDDBFieldsTransformer();
11
+ const hasManyDirectiveDdbReferencesTransformer = new has_many_directive_ddb_references_transformer_1.HasManyDirectiveDDBReferencesTransformer();
12
+ const getHasManyDirectiveTransformer = (dbType, config) => {
13
+ switch (dbType) {
14
+ case 'MYSQL':
15
+ return hasManyDirectiveMySqlTransformer;
16
+ case 'POSTGRES':
17
+ return hasManyDirectivePostgresTransformer;
18
+ case 'DYNAMODB':
19
+ if (config.references) {
20
+ if (config.fields) {
21
+ throw new graphql_transformer_core_1.InvalidDirectiveError(`fields and references cannot be defined in the same ${config.directiveName}. Use 'references'`);
22
+ }
23
+ if (config.references.length < 1) {
24
+ throw new graphql_transformer_core_1.InvalidDirectiveError(`Invalid @hasMany directive on ${config.field.name.value} - empty references list`);
25
+ }
26
+ return hasManyDirectiveDdbReferencesTransformer;
27
+ }
28
+ return hasManyDirectiveDdbFieldsTransformer;
29
+ }
30
+ };
31
+ exports.getHasManyDirectiveTransformer = getHasManyDirectiveTransformer;
32
+ //# sourceMappingURL=has-many-directive-transformer-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-many-directive-transformer-factory.js","sourceRoot":"","sources":["../../src/has-many/has-many-directive-transformer-factory.ts"],"names":[],"mappings":";;;AAGA,2GAAmG;AACnG,6FAAsF;AACtF,mHAA2G;AAC3G,oFAA8E;AAE9E,MAAM,gCAAgC,GAAG,IAAI,mEAA8B,EAAE,CAAC;AAC9E,MAAM,mCAAmC,GAAG,IAAI,mEAA8B,EAAE,CAAC;AACjF,MAAM,oCAAoC,GAAG,IAAI,gFAAoC,EAAE,CAAC;AACxF,MAAM,wCAAwC,GAAG,IAAI,wFAAwC,EAAE,CAAC;AAEzF,MAAM,8BAA8B,GAAG,CAC5C,MAAqC,EACrC,MAAqC,EAE+B,EAAE;IACtE,QAAQ,MAAM,EAAE;QACd,KAAK,OAAO;YACV,OAAO,gCAAgC,CAAC;QAC1C,KAAK,UAAU;YACb,OAAO,mCAAmC,CAAC;QAC7C,KAAK,UAAU;YAGb,IAAI,MAAM,CAAC,UAAU,EAAE;gBAErB,IAAI,MAAM,CAAC,MAAM,EAAE;oBACjB,MAAM,IAAI,gDAAqB,CAAC,uDAAuD,MAAM,CAAC,aAAa,oBAAoB,CAAC,CAAC;iBAClI;gBACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;oBAChC,MAAM,IAAI,gDAAqB,CAAC,iCAAiC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,0BAA0B,CAAC,CAAC;iBACrH;gBACD,OAAO,wCAAwC,CAAC;aACjD;YAID,OAAO,oCAAoC,CAAC;KAC/C;AACH,CAAC,CAAC;AA5BW,QAAA,8BAA8B,kCA4BzC"}
@@ -0,0 +1,11 @@
1
+ import { TransformerContextProvider, TransformerPrepareStepContextProvider, TransformerTransformSchemaStepContextProvider } from '@aws-amplify/graphql-transformer-interfaces';
2
+ import { DataSourceBasedDirectiveTransformer } from '../data-source-based-directive-transformer';
3
+ import { HasOneDirectiveConfiguration } from '../types';
4
+ export declare class HasOneDirectiveDDBFieldsTransformer implements DataSourceBasedDirectiveTransformer<HasOneDirectiveConfiguration> {
5
+ dbType: import("@aws-amplify/graphql-transformer-interfaces").ModelDataSourceStrategyDbType;
6
+ prepare: (context: TransformerPrepareStepContextProvider, config: HasOneDirectiveConfiguration) => void;
7
+ transformSchema: (context: TransformerTransformSchemaStepContextProvider, config: HasOneDirectiveConfiguration) => void;
8
+ generateResolvers: (context: TransformerContextProvider, config: HasOneDirectiveConfiguration) => void;
9
+ validate: (context: TransformerContextProvider, config: HasOneDirectiveConfiguration) => void;
10
+ }
11
+ //# sourceMappingURL=has-one-directive-ddb-fields-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-ddb-fields-transformer.d.ts","sourceRoot":"","sources":["../../src/has-one/has-one-directive-ddb-fields-transformer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,qCAAqC,EACrC,6CAA6C,EAC9C,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAUxD,qBAAa,mCAAoC,YAAW,mCAAmC,CAAC,4BAA4B,CAAC;IAC3H,MAAM,sFAAe;IAErB,OAAO,YAAa,qCAAqC,UAAU,4BAA4B,KAAG,IAAI,CASpG;IAEF,eAAe,YAAa,6CAA6C,UAAU,4BAA4B,KAAG,IAAI,CAEpH;IAEF,iBAAiB,YAAa,0BAA0B,UAAU,4BAA4B,KAAG,IAAI,CAGnG;IAEF,QAAQ,YAAa,0BAA0B,UAAU,4BAA4B,KAAG,IAAI,CAG1F;CACH"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HasOneDirectiveDDBFieldsTransformer = void 0;
4
+ const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
5
+ const utils_1 = require("../utils");
6
+ const generator_factory_1 = require("../resolver/generator-factory");
7
+ class HasOneDirectiveDDBFieldsTransformer {
8
+ constructor() {
9
+ this.dbType = graphql_transformer_core_1.DDB_DB_TYPE;
10
+ this.prepare = (context, config) => {
11
+ const modelName = config.object.name.value;
12
+ (0, utils_1.registerHasOneForeignKeyMappings)({
13
+ transformParameters: context.transformParameters,
14
+ resourceHelper: context.resourceHelper,
15
+ thisTypeName: modelName,
16
+ thisFieldName: config.field.name.value,
17
+ relatedType: config.relatedType,
18
+ });
19
+ };
20
+ this.transformSchema = (context, config) => {
21
+ config.relatedTypeIndex = (0, utils_1.getRelatedTypeIndex)(config, context);
22
+ };
23
+ this.generateResolvers = (context, config) => {
24
+ const generator = (0, generator_factory_1.getGenerator)(this.dbType);
25
+ generator.makeHasOneGetItemConnectionWithKeyResolver(config, context);
26
+ };
27
+ this.validate = (context, config) => {
28
+ (0, utils_1.ensureFieldsArray)(config);
29
+ config.fieldNodes = (0, utils_1.getFieldsNodes)(config, context);
30
+ };
31
+ }
32
+ }
33
+ exports.HasOneDirectiveDDBFieldsTransformer = HasOneDirectiveDDBFieldsTransformer;
34
+ //# sourceMappingURL=has-one-directive-ddb-fields-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-ddb-fields-transformer.js","sourceRoot":"","sources":["../../src/has-one/has-one-directive-ddb-fields-transformer.ts"],"names":[],"mappings":";;;AAAA,oFAAoE;AAQpE,oCAAoH;AACpH,qEAA6D;AAQ7D,MAAa,mCAAmC;IAAhD;QACE,WAAM,GAAG,sCAAW,CAAC;QAErB,YAAO,GAAG,CAAC,OAA8C,EAAE,MAAoC,EAAQ,EAAE;YACvG,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YAC3C,IAAA,wCAAgC,EAAC;gBAC/B,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;gBAChD,cAAc,EAAE,OAAO,CAAC,cAAc;gBACtC,YAAY,EAAE,SAAS;gBACvB,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK;gBACtC,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,oBAAe,GAAG,CAAC,OAAsD,EAAE,MAAoC,EAAQ,EAAE;YACvH,MAAM,CAAC,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,MAAM,EAAE,OAAqC,CAAC,CAAC;QAC/F,CAAC,CAAC;QAEF,sBAAiB,GAAG,CAAC,OAAmC,EAAE,MAAoC,EAAQ,EAAE;YACtG,MAAM,SAAS,GAAG,IAAA,gCAAY,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5C,SAAS,CAAC,0CAA0C,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC,CAAC;QAEF,aAAQ,GAAG,CAAC,OAAmC,EAAE,MAAoC,EAAQ,EAAE;YAC7F,IAAA,yBAAiB,EAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,CAAC,UAAU,GAAG,IAAA,sBAAc,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC,CAAC;IACJ,CAAC;CAAA;AA3BD,kFA2BC"}
@@ -0,0 +1,11 @@
1
+ import { TransformerContextProvider, TransformerPrepareStepContextProvider, TransformerTransformSchemaStepContextProvider } from '@aws-amplify/graphql-transformer-interfaces';
2
+ import { DataSourceBasedDirectiveTransformer } from '../data-source-based-directive-transformer';
3
+ import { HasOneDirectiveConfiguration } from '../types';
4
+ export declare class HasOneDirectiveDDBReferencesTransformer implements DataSourceBasedDirectiveTransformer<HasOneDirectiveConfiguration> {
5
+ dbType: import("@aws-amplify/graphql-transformer-interfaces").ModelDataSourceStrategyDbType;
6
+ prepare: (context: TransformerPrepareStepContextProvider, config: HasOneDirectiveConfiguration) => void;
7
+ transformSchema: (context: TransformerTransformSchemaStepContextProvider, config: HasOneDirectiveConfiguration) => void;
8
+ generateResolvers: (context: TransformerContextProvider, config: HasOneDirectiveConfiguration) => void;
9
+ validate: (context: TransformerContextProvider, config: HasOneDirectiveConfiguration) => void;
10
+ }
11
+ //# sourceMappingURL=has-one-directive-ddb-references-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-ddb-references-transformer.d.ts","sourceRoot":"","sources":["../../src/has-one/has-one-directive-ddb-references-transformer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,qCAAqC,EACrC,6CAA6C,EAC9C,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AAOjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAiBxD,qBAAa,uCAAwC,YAAW,mCAAmC,CAAC,4BAA4B,CAAC;IAC/H,MAAM,sFAAe;IAErB,OAAO,YAAa,qCAAqC,UAAU,4BAA4B,KAAG,IAAI,CAUpG;IAEF,eAAe,YAAa,6CAA6C,UAAU,4BAA4B,KAAG,IAAI,CAAO;IAE7H,iBAAiB,YAAa,0BAA0B,UAAU,4BAA4B,KAAG,IAAI,CAInG;IAUF,QAAQ,YAAa,0BAA0B,UAAU,4BAA4B,KAAG,IAAI,CAoB1F;CACH"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HasOneDirectiveDDBReferencesTransformer = void 0;
4
+ const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
5
+ const ddb_references_generator_1 = require("../resolver/ddb-references-generator");
6
+ const resolvers_1 = require("../resolvers");
7
+ const utils_1 = require("../utils");
8
+ class HasOneDirectiveDDBReferencesTransformer {
9
+ constructor() {
10
+ this.dbType = graphql_transformer_core_1.DDB_DB_TYPE;
11
+ this.prepare = (context, config) => {
12
+ var _a, _b;
13
+ const modelName = config.object.name.value;
14
+ (0, resolvers_1.setFieldMappingResolverReference)(context, (_b = (_a = config.relatedType) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.value, modelName, config.field.name.value, true);
15
+ (0, utils_1.registerHasOneForeignKeyMappings)({
16
+ transformParameters: context.transformParameters,
17
+ resourceHelper: context.resourceHelper,
18
+ thisTypeName: modelName,
19
+ thisFieldName: config.field.name.value,
20
+ relatedType: config.relatedType,
21
+ });
22
+ };
23
+ this.transformSchema = (context, config) => { };
24
+ this.generateResolvers = (context, config) => {
25
+ (0, resolvers_1.updateTableForReferencesConnection)(config, context);
26
+ (0, resolvers_1.updateRelatedModelMutationResolversForCompositeSortKeys)(config, context);
27
+ new ddb_references_generator_1.DDBRelationalReferencesResolverGenerator().makeHasOneGetItemConnectionWithKeyResolver(config, context);
28
+ };
29
+ this.validate = (context, config) => {
30
+ if (config.indexName) {
31
+ const mappedObjectName = context.resourceHelper.getModelNameMapping(config.object.name.value);
32
+ throw new Error(`Invalid @${config.directiveName} directive on ${mappedObjectName}.${config.field.name.value} - indexName is not supported with DynamoDB references.`);
33
+ }
34
+ (0, utils_1.ensureReferencesArray)(config);
35
+ (0, utils_1.validateParentReferencesFields)(config, context);
36
+ (0, utils_1.validateReferencesRelationalFieldNullability)(config);
37
+ const objectName = config.object.name.value;
38
+ const fieldName = config.field.name.value;
39
+ config.referenceNodes = (0, utils_1.getReferencesNodes)(config, context);
40
+ (0, utils_1.validateReferencesBidirectionality)(config);
41
+ const overrideIndexName = (0, utils_1.getOverrideIndexName)(config);
42
+ if (overrideIndexName) {
43
+ config.indexName = overrideIndexName;
44
+ }
45
+ else {
46
+ config.indexName = `gsi-${objectName}.${fieldName}`;
47
+ }
48
+ };
49
+ }
50
+ }
51
+ exports.HasOneDirectiveDDBReferencesTransformer = HasOneDirectiveDDBReferencesTransformer;
52
+ //# sourceMappingURL=has-one-directive-ddb-references-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-ddb-references-transformer.js","sourceRoot":"","sources":["../../src/has-one/has-one-directive-ddb-references-transformer.ts"],"names":[],"mappings":";;;AAAA,oFAAoE;AAOpE,mFAAgG;AAChG,4CAIsB;AAEtB,oCAQkB;AAQlB,MAAa,uCAAuC;IAApD;QACE,WAAM,GAAG,sCAAW,CAAC;QAErB,YAAO,GAAG,CAAC,OAA8C,EAAE,MAAoC,EAAQ,EAAE;;YACvG,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YAC3C,IAAA,4CAAgC,EAAC,OAAO,EAAE,MAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,IAAI,0CAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACrH,IAAA,wCAAgC,EAAC;gBAC/B,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;gBAChD,cAAc,EAAE,OAAO,CAAC,cAAc;gBACtC,YAAY,EAAE,SAAS;gBACvB,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK;gBACtC,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,oBAAe,GAAG,CAAC,OAAsD,EAAE,MAAoC,EAAQ,EAAE,GAAE,CAAC,CAAC;QAE7H,sBAAiB,GAAG,CAAC,OAAmC,EAAE,MAAoC,EAAQ,EAAE;YACtG,IAAA,8CAAkC,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACpD,IAAA,mEAAuD,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACzE,IAAI,mEAAwC,EAAE,CAAC,0CAA0C,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7G,CAAC,CAAC;QAUF,aAAQ,GAAG,CAAC,OAAmC,EAAE,MAAoC,EAAQ,EAAE;YAC7F,IAAI,MAAM,CAAC,SAAS,EAAE;gBACpB,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9F,MAAM,IAAI,KAAK,CACb,YAAY,MAAM,CAAC,aAAa,iBAAiB,gBAAgB,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,yDAAyD,CACtJ,CAAC;aACH;YACD,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;YAC9B,IAAA,sCAA8B,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChD,IAAA,oDAA4C,EAAC,MAAM,CAAC,CAAC;YACrD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;YAC1C,MAAM,CAAC,cAAc,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5D,IAAA,0CAAkC,EAAC,MAAM,CAAC,CAAC;YAC3C,MAAM,iBAAiB,GAAG,IAAA,4BAAoB,EAAC,MAAM,CAAC,CAAC;YACvD,IAAI,iBAAiB,EAAE;gBACrB,MAAM,CAAC,SAAS,GAAG,iBAAiB,CAAC;aACtC;iBAAM;gBACL,MAAM,CAAC,SAAS,GAAG,OAAO,UAAU,IAAI,SAAS,EAAE,CAAC;aACrD;QACH,CAAC,CAAC;IACJ,CAAC;CAAA;AApDD,0FAoDC"}
@@ -0,0 +1,11 @@
1
+ import { TransformerContextProvider, TransformerPrepareStepContextProvider, TransformerTransformSchemaStepContextProvider } from '@aws-amplify/graphql-transformer-interfaces';
2
+ import { DataSourceBasedDirectiveTransformer } from '../data-source-based-directive-transformer';
3
+ import { HasOneDirectiveConfiguration } from '../types';
4
+ export declare class HasOneDirectiveSQLTransformer implements DataSourceBasedDirectiveTransformer<HasOneDirectiveConfiguration> {
5
+ dbType: import("@aws-amplify/graphql-transformer-interfaces").ModelDataSourceStrategySqlDbType;
6
+ prepare: (context: TransformerPrepareStepContextProvider, config: HasOneDirectiveConfiguration) => void;
7
+ transformSchema: (context: TransformerTransformSchemaStepContextProvider, config: HasOneDirectiveConfiguration) => void;
8
+ generateResolvers: (context: TransformerContextProvider, config: HasOneDirectiveConfiguration) => void;
9
+ validate: (context: TransformerContextProvider, config: HasOneDirectiveConfiguration) => void;
10
+ }
11
+ //# sourceMappingURL=has-one-directive-sql-transformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-sql-transformer.d.ts","sourceRoot":"","sources":["../../src/has-one/has-one-directive-sql-transformer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,qCAAqC,EACrC,6CAA6C,EAC9C,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AAEjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAcxD,qBAAa,6BAA8B,YAAW,mCAAmC,CAAC,4BAA4B,CAAC;IACrH,MAAM,yFAAqC;IAE3C,OAAO,YAAa,qCAAqC,UAAU,4BAA4B,KAAG,IAAI,CAGpG;IAEF,eAAe,YAAa,6CAA6C,UAAU,4BAA4B,KAAG,IAAI,CAEpH;IAEF,iBAAiB,YAAa,0BAA0B,UAAU,4BAA4B,KAAG,IAAI,CAGnG;IAEF,QAAQ,YAAa,0BAA0B,UAAU,4BAA4B,KAAG,IAAI,CAK1F;CACH"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HasOneDirectiveSQLTransformer = void 0;
4
+ const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
5
+ const resolvers_1 = require("../resolvers");
6
+ const utils_1 = require("../utils");
7
+ const generator_factory_1 = require("../resolver/generator-factory");
8
+ class HasOneDirectiveSQLTransformer {
9
+ constructor() {
10
+ this.dbType = graphql_transformer_core_1.POSTGRES_DB_TYPE || graphql_transformer_core_1.MYSQL_DB_TYPE;
11
+ this.prepare = (context, config) => {
12
+ var _a, _b;
13
+ const modelName = config.object.name.value;
14
+ (0, resolvers_1.setFieldMappingResolverReference)(context, (_b = (_a = config.relatedType) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.value, modelName, config.field.name.value, true);
15
+ };
16
+ this.transformSchema = (context, config) => {
17
+ (0, utils_1.validateParentReferencesFields)(config, context);
18
+ };
19
+ this.generateResolvers = (context, config) => {
20
+ const generator = (0, generator_factory_1.getGenerator)(this.dbType);
21
+ generator.makeHasOneGetItemConnectionWithKeyResolver(config, context);
22
+ };
23
+ this.validate = (context, config) => {
24
+ (0, utils_1.ensureReferencesArray)(config);
25
+ config.referenceNodes = (0, utils_1.getReferencesNodes)(config, context);
26
+ (0, utils_1.validateReferencesRelationalFieldNullability)(config);
27
+ (0, utils_1.validateReferencesBidirectionality)(config);
28
+ };
29
+ }
30
+ }
31
+ exports.HasOneDirectiveSQLTransformer = HasOneDirectiveSQLTransformer;
32
+ //# sourceMappingURL=has-one-directive-sql-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-sql-transformer.js","sourceRoot":"","sources":["../../src/has-one/has-one-directive-sql-transformer.ts"],"names":[],"mappings":";;;AAAA,oFAAwF;AAOxF,4CAAgE;AAEhE,oCAMkB;AAClB,qEAA6D;AAM7D,MAAa,6BAA6B;IAA1C;QACE,WAAM,GAAG,2CAAgB,IAAI,wCAAa,CAAC;QAE3C,YAAO,GAAG,CAAC,OAA8C,EAAE,MAAoC,EAAQ,EAAE;;YACvG,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YAC3C,IAAA,4CAAgC,EAAC,OAAO,EAAE,MAAA,MAAA,MAAM,CAAC,WAAW,0CAAE,IAAI,0CAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvH,CAAC,CAAC;QAEF,oBAAe,GAAG,CAAC,OAAsD,EAAE,MAAoC,EAAQ,EAAE;YACvH,IAAA,sCAA8B,EAAC,MAAM,EAAE,OAAqC,CAAC,CAAC;QAChF,CAAC,CAAC;QAEF,sBAAiB,GAAG,CAAC,OAAmC,EAAE,MAAoC,EAAQ,EAAE;YACtG,MAAM,SAAS,GAAG,IAAA,gCAAY,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5C,SAAS,CAAC,0CAA0C,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxE,CAAC,CAAC;QAEF,aAAQ,GAAG,CAAC,OAAmC,EAAE,MAAoC,EAAQ,EAAE;YAC7F,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;YAC9B,MAAM,CAAC,cAAc,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5D,IAAA,oDAA4C,EAAC,MAAM,CAAC,CAAC;YACrD,IAAA,0CAAkC,EAAC,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC;CAAA;AAvBD,sEAuBC"}
@@ -0,0 +1,5 @@
1
+ import { ModelDataSourceStrategyDbType } from '@aws-amplify/graphql-transformer-interfaces';
2
+ import { HasOneDirectiveConfiguration } from '../types';
3
+ import { DataSourceBasedDirectiveTransformer } from '../data-source-based-directive-transformer';
4
+ export declare const getHasOneDirectiveTransformer: (dbType: ModelDataSourceStrategyDbType, config: HasOneDirectiveConfiguration) => DataSourceBasedDirectiveTransformer<HasOneDirectiveConfiguration>;
5
+ //# sourceMappingURL=has-one-directive-transformer-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-transformer-factory.d.ts","sourceRoot":"","sources":["../../src/has-one/has-one-directive-transformer-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,mCAAmC,EAAE,MAAM,4CAA4C,CAAC;AAWjG,eAAO,MAAM,6BAA6B,WAChC,6BAA6B,UAC7B,4BAA4B,KAEnC,oCAAoC,4BAA4B,CAwBlE,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHasOneDirectiveTransformer = void 0;
4
+ const has_one_directive_ddb_fields_transformer_1 = require("./has-one-directive-ddb-fields-transformer");
5
+ const has_one_directive_sql_transformer_1 = require("./has-one-directive-sql-transformer");
6
+ const has_one_directive_ddb_references_transformer_1 = require("./has-one-directive-ddb-references-transformer");
7
+ const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
8
+ const hasOneDirectiveMySqlTransformer = new has_one_directive_sql_transformer_1.HasOneDirectiveSQLTransformer();
9
+ const hasOneDirectivePostgresTransformer = new has_one_directive_sql_transformer_1.HasOneDirectiveSQLTransformer();
10
+ const hasOneDirectiveDdbFieldsTransformer = new has_one_directive_ddb_fields_transformer_1.HasOneDirectiveDDBFieldsTransformer();
11
+ const hasOneDirectiveDdbReferencesTransformer = new has_one_directive_ddb_references_transformer_1.HasOneDirectiveDDBReferencesTransformer();
12
+ const getHasOneDirectiveTransformer = (dbType, config) => {
13
+ switch (dbType) {
14
+ case 'MYSQL':
15
+ return hasOneDirectiveMySqlTransformer;
16
+ case 'POSTGRES':
17
+ return hasOneDirectivePostgresTransformer;
18
+ case 'DYNAMODB':
19
+ if (config.references) {
20
+ if (config.fields) {
21
+ throw new graphql_transformer_core_1.InvalidDirectiveError(`fields and references cannot be defined in the same ${config.directiveName}. Use 'references'`);
22
+ }
23
+ if (config.references.length < 1) {
24
+ throw new Error(`Invalid @hasOne directive on ${config.field.name.value} - empty references list`);
25
+ }
26
+ return hasOneDirectiveDdbReferencesTransformer;
27
+ }
28
+ return hasOneDirectiveDdbFieldsTransformer;
29
+ }
30
+ };
31
+ exports.getHasOneDirectiveTransformer = getHasOneDirectiveTransformer;
32
+ //# sourceMappingURL=has-one-directive-transformer-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-one-directive-transformer-factory.js","sourceRoot":"","sources":["../../src/has-one/has-one-directive-transformer-factory.ts"],"names":[],"mappings":";;;AAGA,yGAAiG;AACjG,2FAAoF;AACpF,iHAAyG;AACzG,oFAA8E;AAE9E,MAAM,+BAA+B,GAAG,IAAI,iEAA6B,EAAE,CAAC;AAC5E,MAAM,kCAAkC,GAAG,IAAI,iEAA6B,EAAE,CAAC;AAC/E,MAAM,mCAAmC,GAAG,IAAI,8EAAmC,EAAE,CAAC;AACtF,MAAM,uCAAuC,GAAG,IAAI,sFAAuC,EAAE,CAAC;AAEvF,MAAM,6BAA6B,GAAG,CAC3C,MAAqC,EACrC,MAAoC,EAE+B,EAAE;IACrE,QAAQ,MAAM,EAAE;QACd,KAAK,OAAO;YACV,OAAO,+BAA+B,CAAC;QACzC,KAAK,UAAU;YACb,OAAO,kCAAkC,CAAC;QAC5C,KAAK,UAAU;YAGb,IAAI,MAAM,CAAC,UAAU,EAAE;gBAErB,IAAI,MAAM,CAAC,MAAM,EAAE;oBACjB,MAAM,IAAI,gDAAqB,CAAC,uDAAuD,MAAM,CAAC,aAAa,oBAAoB,CAAC,CAAC;iBAClI;gBACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;oBAChC,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,0BAA0B,CAAC,CAAC;iBACpG;gBACD,OAAO,uCAAuC,CAAC;aAChD;YAID,OAAO,mCAAmC,CAAC;KAC9C;AACH,CAAC,CAAC;AA5BW,QAAA,6BAA6B,iCA4BxC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export { HasOneTransformer } from './graphql-has-one-transformer';
2
+ export { HasManyTransformer } from './graphql-has-many-transformer';
3
+ export { BelongsToTransformer } from './graphql-belongs-to-transformer';
4
+ export { ManyToManyTransformer } from './graphql-many-to-many-transformer';
5
+ export { getConnectionAttributeName, getObjectPrimaryKey, getSortKeyConnectionAttributeName } from './utils';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSortKeyConnectionAttributeName = exports.getObjectPrimaryKey = exports.getConnectionAttributeName = exports.ManyToManyTransformer = exports.BelongsToTransformer = exports.HasManyTransformer = exports.HasOneTransformer = void 0;
4
+ var graphql_has_one_transformer_1 = require("./graphql-has-one-transformer");
5
+ Object.defineProperty(exports, "HasOneTransformer", { enumerable: true, get: function () { return graphql_has_one_transformer_1.HasOneTransformer; } });
6
+ var graphql_has_many_transformer_1 = require("./graphql-has-many-transformer");
7
+ Object.defineProperty(exports, "HasManyTransformer", { enumerable: true, get: function () { return graphql_has_many_transformer_1.HasManyTransformer; } });
8
+ var graphql_belongs_to_transformer_1 = require("./graphql-belongs-to-transformer");
9
+ Object.defineProperty(exports, "BelongsToTransformer", { enumerable: true, get: function () { return graphql_belongs_to_transformer_1.BelongsToTransformer; } });
10
+ var graphql_many_to_many_transformer_1 = require("./graphql-many-to-many-transformer");
11
+ Object.defineProperty(exports, "ManyToManyTransformer", { enumerable: true, get: function () { return graphql_many_to_many_transformer_1.ManyToManyTransformer; } });
12
+ var utils_1 = require("./utils");
13
+ Object.defineProperty(exports, "getConnectionAttributeName", { enumerable: true, get: function () { return utils_1.getConnectionAttributeName; } });
14
+ Object.defineProperty(exports, "getObjectPrimaryKey", { enumerable: true, get: function () { return utils_1.getObjectPrimaryKey; } });
15
+ Object.defineProperty(exports, "getSortKeyConnectionAttributeName", { enumerable: true, get: function () { return utils_1.getSortKeyConnectionAttributeName; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6EAAkE;AAAzD,gIAAA,iBAAiB,OAAA;AAC1B,+EAAoE;AAA3D,kIAAA,kBAAkB,OAAA;AAC3B,mFAAwE;AAA/D,sIAAA,oBAAoB,OAAA;AAC7B,uFAA2E;AAAlE,yIAAA,qBAAqB,OAAA;AAC9B,iCAA6G;AAApG,mHAAA,0BAA0B,OAAA;AAAE,4GAAA,mBAAmB,OAAA;AAAE,0HAAA,iCAAiC,OAAA"}
@@ -0,0 +1,14 @@
1
+ import { TransformerContextProvider } from '@aws-amplify/graphql-transformer-interfaces';
2
+ import { Expression, ObjectNode } from 'graphql-mapping-template';
3
+ import { ObjectTypeDefinitionNode } from 'graphql';
4
+ import { BelongsToDirectiveConfiguration, HasManyDirectiveConfiguration, HasOneDirectiveConfiguration } from '../types';
5
+ import { RelationalResolverGenerator } from './generator';
6
+ export declare class DDBRelationalResolverGenerator extends RelationalResolverGenerator {
7
+ makeExpression: (keySchema: any[], connectionAttributes: string[]) => ObjectNode;
8
+ makeHasManyGetItemsConnectionWithKeyResolver: (config: HasManyDirectiveConfiguration, ctx: TransformerContextProvider) => void;
9
+ makeHasOneGetItemConnectionWithKeyResolver: (config: HasOneDirectiveConfiguration, ctx: TransformerContextProvider) => void;
10
+ makeBelongsToGetItemConnectionWithKeyResolver: (config: BelongsToDirectiveConfiguration, ctx: TransformerContextProvider) => void;
11
+ makeHasOneBelongToGetItemConnectionWithKeyResolver: (config: HasOneDirectiveConfiguration | BelongsToDirectiveConfiguration, ctx: TransformerContextProvider) => void;
12
+ buildKeyValueExpression: (fieldName: string, object: ObjectTypeDefinitionNode, isPartitionKey?: boolean) => Expression;
13
+ }
14
+ //# sourceMappingURL=ddb-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ddb-generator.d.ts","sourceRoot":"","sources":["../../src/resolver/ddb-generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAEL,UAAU,EACV,UAAU,EAuBX,MAAM,0BAA0B,CAAC;AAWlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExH,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAO1D,qBAAa,8BAA+B,SAAQ,2BAA2B;IAC7E,cAAc,cAAe,GAAG,EAAE,wBAAwB,MAAM,EAAE,KAAG,UAAU,CAkC7E;IAOF,4CAA4C,WAAY,6BAA6B,OAAO,0BAA0B,KAAG,IAAI,CA4I3H;IAOF,0CAA0C,WAAY,4BAA4B,OAAO,0BAA0B,KAAG,IAAI,CAExH;IAEF,6CAA6C,WAAY,+BAA+B,OAAO,0BAA0B,KAAG,IAAI,CAE9H;IAEF,kDAAkD,WACxC,4BAA4B,GAAG,+BAA+B,OACjE,0BAA0B,KAC9B,IAAI,CAyHL;IAEF,uBAAuB,cAAe,MAAM,UAAU,wBAAwB,+BAA2B,UAAU,CAWjH;CACH"}
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DDBRelationalResolverGenerator = void 0;
4
+ const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
5
+ const graphql_mapping_template_1 = require("graphql-mapping-template");
6
+ const graphql_transformer_common_1 = require("graphql-transformer-common");
7
+ const graphql_model_transformer_1 = require("@aws-amplify/graphql-model-transformer");
8
+ const resolvers_1 = require("../resolvers");
9
+ const generator_1 = require("./generator");
10
+ const SORT_KEY_VALUE = 'sortKeyValue';
11
+ const CONNECTION_STACK = 'ConnectionStack';
12
+ const authFilter = (0, graphql_mapping_template_1.ref)('ctx.stash.authFilter');
13
+ const PARTITION_KEY_VALUE = 'partitionKeyValue';
14
+ class DDBRelationalResolverGenerator extends generator_1.RelationalResolverGenerator {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.makeExpression = (keySchema, connectionAttributes) => {
18
+ if (keySchema[1] && connectionAttributes[1]) {
19
+ let condensedSortKeyValue;
20
+ if (connectionAttributes.length > 2) {
21
+ const rangeKeyFields = connectionAttributes.slice(1);
22
+ condensedSortKeyValue = rangeKeyFields
23
+ .map((keyField, idx) => `\${${SORT_KEY_VALUE}${idx}}`)
24
+ .join(graphql_transformer_common_1.ModelResourceIDs.ModelCompositeKeySeparator());
25
+ }
26
+ return (0, graphql_mapping_template_1.obj)({
27
+ expression: (0, graphql_mapping_template_1.str)('#partitionKey = :partitionKey AND #sortKey = :sortKey'),
28
+ expressionNames: (0, graphql_mapping_template_1.obj)({
29
+ '#partitionKey': (0, graphql_mapping_template_1.str)(keySchema[0].attributeName),
30
+ '#sortKey': (0, graphql_mapping_template_1.str)(keySchema[1].attributeName),
31
+ }),
32
+ expressionValues: (0, graphql_mapping_template_1.obj)({
33
+ ':partitionKey': (0, graphql_mapping_template_1.ref)(`util.dynamodb.toDynamoDB($${PARTITION_KEY_VALUE})`),
34
+ ':sortKey': (0, graphql_mapping_template_1.ref)(`util.dynamodb.toDynamoDB(${condensedSortKeyValue ? `"${condensedSortKeyValue}"` : `$${SORT_KEY_VALUE}0`})`),
35
+ }),
36
+ });
37
+ }
38
+ return (0, graphql_mapping_template_1.obj)({
39
+ expression: (0, graphql_mapping_template_1.str)('#partitionKey = :partitionKey'),
40
+ expressionNames: (0, graphql_mapping_template_1.obj)({
41
+ '#partitionKey': (0, graphql_mapping_template_1.str)(keySchema[0].attributeName),
42
+ }),
43
+ expressionValues: (0, graphql_mapping_template_1.obj)({
44
+ ':partitionKey': (0, graphql_mapping_template_1.ref)(`util.dynamodb.toDynamoDB($${PARTITION_KEY_VALUE})`),
45
+ }),
46
+ });
47
+ };
48
+ this.makeHasManyGetItemsConnectionWithKeyResolver = (config, ctx) => {
49
+ const { connectionFields, field, fields, indexName, limit, object, relatedType } = config;
50
+ const connectionAttributes = fields.length > 0 ? fields : connectionFields;
51
+ if (connectionAttributes.length === 0) {
52
+ throw new Error('Either connection fields or local fields should be populated.');
53
+ }
54
+ const table = (0, graphql_transformer_core_1.getTable)(ctx, relatedType);
55
+ const dataSourceName = (0, graphql_transformer_core_1.getModelDataSourceNameForTypeName)(ctx, relatedType.name.value);
56
+ const dataSource = ctx.api.host.getDataSource(dataSourceName);
57
+ const keySchema = (0, graphql_transformer_core_1.getKeySchema)(table, indexName);
58
+ const setup = [
59
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('limit'), (0, graphql_mapping_template_1.ref)(`util.defaultIfNull($context.args.limit, ${limit})`)),
60
+ ...connectionAttributes
61
+ .slice(1)
62
+ .map((ca, idx) => (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)(`${SORT_KEY_VALUE}${idx}`), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.defaultIfNull'), (0, graphql_mapping_template_1.ref)(`ctx.stash.connectionAttibutes.get("${ca}")`), (0, graphql_mapping_template_1.ref)(`ctx.source.${ca}`)))),
63
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('query'), this.makeExpression(keySchema, connectionAttributes)),
64
+ ];
65
+ if (keySchema[1] && !connectionAttributes[1]) {
66
+ const sortKeyFieldName = keySchema[1].attributeName;
67
+ const sortKeyField = relatedType.fields.find((f) => f.name.value === sortKeyFieldName);
68
+ if (sortKeyField) {
69
+ setup.push((0, graphql_transformer_common_1.applyKeyConditionExpression)(sortKeyFieldName, (0, graphql_transformer_common_1.attributeTypeFromScalar)(sortKeyField.type), 'query'));
70
+ }
71
+ else {
72
+ const sortKeyFieldNames = sortKeyFieldName.split(graphql_transformer_common_1.ModelResourceIDs.ModelCompositeKeySeparator());
73
+ setup.push((0, graphql_transformer_common_1.applyCompositeKeyConditionExpression)(sortKeyFieldNames, 'query', (0, graphql_transformer_common_1.toCamelCase)(sortKeyFieldNames), sortKeyFieldName));
74
+ }
75
+ }
76
+ setup.push(graphql_transformer_common_1.setArgs, (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)(authFilter)), (0, graphql_mapping_template_1.compoundExpression)([
77
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), authFilter),
78
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('args.filter'))), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.obj)({ and: (0, graphql_mapping_template_1.list)([(0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('args.filter')]) }))),
79
+ ]), (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('args.filter'))), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('args.filter')))), (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('filter'))), (0, graphql_mapping_template_1.compoundExpression)([
80
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filterExpression'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.parseJson'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.transform.toDynamoDBFilterExpression'), (0, graphql_mapping_template_1.ref)('filter')))),
81
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.isNullOrBlank'), (0, graphql_mapping_template_1.ref)('filterExpression.expression'))), (0, graphql_mapping_template_1.compoundExpression)([
82
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('filterExpression.expressionValues.size')), (0, graphql_mapping_template_1.int)(0)), (0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('filterExpression.remove'), (0, graphql_mapping_template_1.str)('expressionValues')))),
83
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('filterExpression')),
84
+ ])),
85
+ ])));
86
+ const queryArguments = {
87
+ query: (0, graphql_mapping_template_1.raw)('$util.toJson($query)'),
88
+ scanIndexForward: (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('context.args.sortDirection'), (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('context.args.sortDirection'), (0, graphql_mapping_template_1.str)('ASC')), (0, graphql_mapping_template_1.bool)(true), (0, graphql_mapping_template_1.bool)(false)), (0, graphql_mapping_template_1.bool)(true)),
89
+ filter: (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('util.toJson($filter)'), (0, graphql_mapping_template_1.nul)()),
90
+ limit: (0, graphql_mapping_template_1.ref)('limit'),
91
+ nextToken: (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('context.args.nextToken'), (0, graphql_mapping_template_1.ref)('util.toJson($context.args.nextToken)'), (0, graphql_mapping_template_1.nul)()),
92
+ };
93
+ if (indexName) {
94
+ queryArguments.index = (0, graphql_mapping_template_1.str)(indexName);
95
+ }
96
+ const queryObj = graphql_mapping_template_1.DynamoDBMappingTemplate.query(queryArguments);
97
+ const resolverResourceId = graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(object.name.value, field.name.value);
98
+ const resolver = ctx.resolvers.generateQueryResolver(object.name.value, field.name.value, resolverResourceId, dataSource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.compoundExpression)([
99
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.ref)('ctx.stash.deniedField'), (0, graphql_mapping_template_1.compoundExpression)([(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('result'), (0, graphql_mapping_template_1.obj)({ items: (0, graphql_mapping_template_1.list)([]) })), (0, graphql_mapping_template_1.raw)('#return($result)')])),
100
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)(PARTITION_KEY_VALUE), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.defaultIfNull'), (0, graphql_mapping_template_1.ref)(`ctx.stash.connectionAttributes.get("${connectionAttributes[0]}")`), (0, graphql_mapping_template_1.ref)(`ctx.source.${connectionAttributes[0]}`))),
101
+ (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.isNull'), (0, graphql_mapping_template_1.ref)(PARTITION_KEY_VALUE)), (0, graphql_mapping_template_1.compoundExpression)([(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('result'), (0, graphql_mapping_template_1.obj)({ items: (0, graphql_mapping_template_1.list)([]) })), (0, graphql_mapping_template_1.raw)('#return($result)')]), (0, graphql_mapping_template_1.compoundExpression)([...setup, queryObj])),
102
+ ])), `${object.name.value}.${field.name.value}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)(graphql_mapping_template_1.DynamoDBMappingTemplate.dynamoDBResponse(false, (0, graphql_mapping_template_1.compoundExpression)([
103
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.raw)('!$result'), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('result'), (0, graphql_mapping_template_1.ref)('ctx.result'))),
104
+ (0, graphql_mapping_template_1.compoundExpression)([
105
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.defaultIfNull'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('ctx.source.get'), (0, graphql_mapping_template_1.str)(graphql_model_transformer_1.OPERATION_KEY)), (0, graphql_mapping_template_1.nul)()), (0, graphql_mapping_template_1.str)('Mutation')), (0, graphql_mapping_template_1.forEach)((0, graphql_mapping_template_1.ref)('item'), (0, graphql_mapping_template_1.ref)('result.items'), [(0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('item.put'), (0, graphql_mapping_template_1.str)(graphql_model_transformer_1.OPERATION_KEY), (0, graphql_mapping_template_1.str)('Mutation')))])),
106
+ (0, graphql_mapping_template_1.raw)('$util.toJson($result)'),
107
+ ]),
108
+ ]))), `${object.name.value}.${field.name.value}.res.vtl`));
109
+ resolver.setScope(ctx.stackManager.getScopeFor(resolverResourceId, CONNECTION_STACK));
110
+ ctx.resolvers.addResolver(object.name.value, field.name.value, resolver);
111
+ };
112
+ this.makeHasOneGetItemConnectionWithKeyResolver = (config, ctx) => {
113
+ this.makeHasOneBelongToGetItemConnectionWithKeyResolver(config, ctx);
114
+ };
115
+ this.makeBelongsToGetItemConnectionWithKeyResolver = (config, ctx) => {
116
+ this.makeHasOneBelongToGetItemConnectionWithKeyResolver(config, ctx);
117
+ };
118
+ this.makeHasOneBelongToGetItemConnectionWithKeyResolver = (config, ctx) => {
119
+ const { connectionFields, field, fields, object, relatedType, relatedTypeIndex } = config;
120
+ if (relatedTypeIndex.length === 0) {
121
+ throw new Error('Expected relatedType index fields to be set for connection.');
122
+ }
123
+ const localFields = fields.length > 0 ? fields : connectionFields;
124
+ const table = (0, graphql_transformer_core_1.getTable)(ctx, relatedType);
125
+ const { keySchema } = table;
126
+ const dataSourceName = (0, graphql_transformer_core_1.getModelDataSourceNameForTypeName)(ctx, relatedType.name.value);
127
+ const dataSource = ctx.api.host.getDataSource(dataSourceName);
128
+ const partitionKeyName = keySchema[0].attributeName;
129
+ const totalExpressions = ['#partitionKey = :partitionValue'];
130
+ const totalExpressionNames = {
131
+ '#partitionKey': (0, graphql_mapping_template_1.str)(partitionKeyName),
132
+ };
133
+ const totalExpressionValues = {
134
+ ':partitionValue': this.buildKeyValueExpression(localFields[0], ctx.output.getObject(object.name.value), true),
135
+ };
136
+ if (relatedTypeIndex.length > 2) {
137
+ const rangeKeyFields = localFields.slice(1);
138
+ const sortKeyName = keySchema[1].attributeName;
139
+ const condensedSortKeyValue = (0, resolvers_1.condenseRangeKey)(rangeKeyFields.map((keyField) => `\${ctx.source.${keyField}}`));
140
+ totalExpressions.push('#sortKeyName = :sortKeyName');
141
+ totalExpressionNames['#sortKeyName'] = (0, graphql_mapping_template_1.str)(sortKeyName);
142
+ totalExpressionValues[':sortKeyName'] = (0, graphql_mapping_template_1.ref)(`util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank("${condensedSortKeyValue}", "${graphql_transformer_common_1.NONE_VALUE}")))`);
143
+ }
144
+ else if (relatedTypeIndex.length === 2) {
145
+ const sortKeyName = keySchema[1].attributeName;
146
+ totalExpressions.push('#sortKeyName = :sortKeyName');
147
+ totalExpressionNames['#sortKeyName'] = (0, graphql_mapping_template_1.str)(sortKeyName);
148
+ totalExpressionValues[':sortKeyName'] = this.buildKeyValueExpression(localFields[1], ctx.output.getObject(object.name.value));
149
+ }
150
+ const resolverResourceId = graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(object.name.value, field.name.value);
151
+ const resolver = ctx.resolvers.generateQueryResolver(object.name.value, field.name.value, resolverResourceId, dataSource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.compoundExpression)([
152
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.ref)('ctx.stash.deniedField'), (0, graphql_mapping_template_1.raw)('#return($util.toJson(null))')),
153
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)(PARTITION_KEY_VALUE), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.defaultIfNull'), (0, graphql_mapping_template_1.ref)(`ctx.stash.connectionAttibutes.get("${localFields[0]}")`), (0, graphql_mapping_template_1.ref)(`ctx.source.${localFields[0]}`))),
154
+ (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.or)([
155
+ (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.isNull'), (0, graphql_mapping_template_1.ref)(PARTITION_KEY_VALUE)),
156
+ ...localFields.slice(1).map((f) => (0, graphql_mapping_template_1.raw)(`$util.isNull($ctx.source.${f})`)),
157
+ ]), (0, graphql_mapping_template_1.raw)('#return'), (0, graphql_mapping_template_1.compoundExpression)([
158
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('GetRequest'), (0, graphql_mapping_template_1.obj)({ version: (0, graphql_mapping_template_1.str)('2018-05-29'), operation: (0, graphql_mapping_template_1.str)('Query') })),
159
+ (0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('GetRequest.put'), (0, graphql_mapping_template_1.str)('query'), (0, graphql_mapping_template_1.obj)({
160
+ expression: (0, graphql_mapping_template_1.str)(totalExpressions.join(' AND ')),
161
+ expressionNames: (0, graphql_mapping_template_1.obj)(totalExpressionNames),
162
+ expressionValues: (0, graphql_mapping_template_1.obj)(totalExpressionValues),
163
+ }))),
164
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)(authFilter)), (0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('GetRequest.put'), (0, graphql_mapping_template_1.str)('filter'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.parseJson'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.transform.toDynamoDBFilterExpression'), authFilter))))),
165
+ (0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.ref)('GetRequest')),
166
+ ])),
167
+ ])), `${object.name.value}.${field.name.value}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)(graphql_mapping_template_1.DynamoDBMappingTemplate.dynamoDBResponse(false, (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.and)([(0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.ref)('ctx.result.items.isEmpty()')), (0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('ctx.result.scannedCount'), (0, graphql_mapping_template_1.int)(1))]), (0, graphql_mapping_template_1.compoundExpression)([
168
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('resultValue'), (0, graphql_mapping_template_1.ref)('ctx.result.items[0]')),
169
+ (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('operation'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.defaultIfNull'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('ctx.source.get'), (0, graphql_mapping_template_1.str)(graphql_model_transformer_1.OPERATION_KEY)), (0, graphql_mapping_template_1.nul)())),
170
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('operation'), (0, graphql_mapping_template_1.str)('Mutation')), (0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('resultValue.put'), (0, graphql_mapping_template_1.str)(graphql_model_transformer_1.OPERATION_KEY), (0, graphql_mapping_template_1.str)('Mutation')))),
171
+ (0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.ref)('resultValue')),
172
+ ]), (0, graphql_mapping_template_1.compoundExpression)([
173
+ (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.and)([(0, graphql_mapping_template_1.ref)('ctx.result.items.isEmpty()'), (0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('ctx.result.scannedCount'), (0, graphql_mapping_template_1.int)(1))]), (0, graphql_mapping_template_1.ref)('util.unauthorized()')),
174
+ (0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.nul)()),
175
+ ])))), `${object.name.value}.${field.name.value}.res.vtl`));
176
+ resolver.setScope(ctx.stackManager.getScopeFor(resolverResourceId, CONNECTION_STACK));
177
+ ctx.resolvers.addResolver(object.name.value, field.name.value, resolver);
178
+ };
179
+ this.buildKeyValueExpression = (fieldName, object, isPartitionKey = false) => {
180
+ var _a;
181
+ const field = (_a = object.fields) === null || _a === void 0 ? void 0 : _a.find((it) => it.name.value === fieldName);
182
+ const attributeType = field ? (0, graphql_transformer_common_1.attributeTypeFromScalar)(field.type) : 'S';
183
+ return (0, graphql_mapping_template_1.ref)(`util.parseJson($util.dynamodb.toDynamoDBJson($util.${attributeType === 'S' ? 'defaultIfNullOrBlank' : 'defaultIfNull'}(${isPartitionKey ? `$${PARTITION_KEY_VALUE}` : `$ctx.source.${fieldName}`}, "${graphql_transformer_common_1.NONE_VALUE}")))`);
184
+ };
185
+ }
186
+ }
187
+ exports.DDBRelationalResolverGenerator = DDBRelationalResolverGenerator;
188
+ //# sourceMappingURL=ddb-generator.js.map