@aws-amplify/data-schema 1.3.10 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/cjs/ModelType.js +5 -0
  2. package/dist/cjs/ModelType.js.map +1 -1
  3. package/dist/cjs/SchemaProcessor.js +58 -1
  4. package/dist/cjs/SchemaProcessor.js.map +1 -1
  5. package/dist/cjs/runtime/addSchemaToClient.js +1 -0
  6. package/dist/cjs/runtime/addSchemaToClient.js.map +1 -1
  7. package/dist/cjs/runtime/addSchemaToClientWithInstance.js +1 -0
  8. package/dist/cjs/runtime/addSchemaToClientWithInstance.js.map +1 -1
  9. package/dist/cjs/runtime/internals/APIClient.js +63 -42
  10. package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
  11. package/dist/cjs/runtime/internals/cancellation.js +48 -0
  12. package/dist/cjs/runtime/internals/cancellation.js.map +1 -0
  13. package/dist/cjs/runtime/internals/clientUtils.js +45 -3
  14. package/dist/cjs/runtime/internals/clientUtils.js.map +1 -1
  15. package/dist/cjs/runtime/internals/index.js +3 -1
  16. package/dist/cjs/runtime/internals/index.js.map +1 -1
  17. package/dist/cjs/runtime/internals/operations/custom.js +91 -85
  18. package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
  19. package/dist/cjs/runtime/internals/operations/get.js +71 -65
  20. package/dist/cjs/runtime/internals/operations/get.js.map +1 -1
  21. package/dist/cjs/runtime/internals/operations/indexQuery.js +66 -60
  22. package/dist/cjs/runtime/internals/operations/indexQuery.js.map +1 -1
  23. package/dist/cjs/runtime/internals/operations/list.js +90 -84
  24. package/dist/cjs/runtime/internals/operations/list.js.map +1 -1
  25. package/dist/cjs/runtime/internals/server/generateModelsProperty.js +3 -3
  26. package/dist/cjs/runtime/internals/server/generateModelsProperty.js.map +1 -1
  27. package/dist/cjs/runtime/internals/utils/clientProperties/generateModelsProperty.js +3 -3
  28. package/dist/cjs/runtime/internals/utils/clientProperties/generateModelsProperty.js.map +1 -1
  29. package/dist/cjs/runtime/utils/index.js +3 -1
  30. package/dist/cjs/runtime/utils/index.js.map +1 -1
  31. package/dist/cjs/runtime/utils/selfAwareAsync.js +40 -0
  32. package/dist/cjs/runtime/utils/selfAwareAsync.js.map +1 -0
  33. package/dist/esm/Authorization.d.ts +1 -1
  34. package/dist/esm/ClientSchema/Core/ClientModel.d.ts +20 -1
  35. package/dist/esm/ClientSchema/utilities/ResolveField.d.ts +5 -1
  36. package/dist/esm/ModelType.d.ts +6 -0
  37. package/dist/esm/ModelType.mjs +5 -0
  38. package/dist/esm/ModelType.mjs.map +1 -1
  39. package/dist/esm/SchemaProcessor.mjs +58 -1
  40. package/dist/esm/SchemaProcessor.mjs.map +1 -1
  41. package/dist/esm/runtime/addSchemaToClient.mjs +2 -0
  42. package/dist/esm/runtime/addSchemaToClient.mjs.map +1 -1
  43. package/dist/esm/runtime/addSchemaToClientWithInstance.mjs +2 -0
  44. package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -1
  45. package/dist/esm/runtime/bridge-types.d.ts +2 -2
  46. package/dist/esm/runtime/client/index.d.ts +6 -6
  47. package/dist/esm/runtime/internals/APIClient.d.ts +2 -2
  48. package/dist/esm/runtime/internals/APIClient.mjs +64 -42
  49. package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
  50. package/dist/esm/runtime/internals/cancellation.d.ts +10 -0
  51. package/dist/esm/runtime/internals/cancellation.mjs +44 -0
  52. package/dist/esm/runtime/internals/cancellation.mjs.map +1 -0
  53. package/dist/esm/runtime/internals/clientUtils.d.ts +78 -1
  54. package/dist/esm/runtime/internals/clientUtils.mjs +45 -3
  55. package/dist/esm/runtime/internals/clientUtils.mjs.map +1 -1
  56. package/dist/esm/runtime/internals/index.d.ts +1 -0
  57. package/dist/esm/runtime/internals/index.mjs +1 -0
  58. package/dist/esm/runtime/internals/index.mjs.map +1 -1
  59. package/dist/esm/runtime/internals/operations/custom.d.ts +1 -1
  60. package/dist/esm/runtime/internals/operations/custom.mjs +91 -85
  61. package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
  62. package/dist/esm/runtime/internals/operations/get.d.ts +1 -1
  63. package/dist/esm/runtime/internals/operations/get.mjs +71 -65
  64. package/dist/esm/runtime/internals/operations/get.mjs.map +1 -1
  65. package/dist/esm/runtime/internals/operations/indexQuery.d.ts +1 -1
  66. package/dist/esm/runtime/internals/operations/indexQuery.mjs +66 -60
  67. package/dist/esm/runtime/internals/operations/indexQuery.mjs.map +1 -1
  68. package/dist/esm/runtime/internals/operations/list.d.ts +1 -1
  69. package/dist/esm/runtime/internals/operations/list.mjs +90 -84
  70. package/dist/esm/runtime/internals/operations/list.mjs.map +1 -1
  71. package/dist/esm/runtime/internals/server/generateModelsProperty.mjs +4 -4
  72. package/dist/esm/runtime/internals/server/generateModelsProperty.mjs.map +1 -1
  73. package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.mjs +4 -4
  74. package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.mjs.map +1 -1
  75. package/dist/esm/runtime/utils/index.d.ts +1 -0
  76. package/dist/esm/runtime/utils/index.mjs +1 -0
  77. package/dist/esm/runtime/utils/index.mjs.map +1 -1
  78. package/dist/esm/runtime/utils/selfAwareAsync.d.ts +19 -0
  79. package/dist/esm/runtime/utils/selfAwareAsync.mjs +37 -0
  80. package/dist/esm/runtime/utils/selfAwareAsync.mjs.map +1 -0
  81. package/dist/meta/cjs.tsbuildinfo +1 -1
  82. package/package.json +2 -2
  83. package/src/ClientSchema/Core/ClientModel.ts +29 -0
  84. package/src/ClientSchema/utilities/ResolveField.ts +26 -6
  85. package/src/ModelType.ts +31 -0
  86. package/src/SchemaProcessor.ts +77 -2
  87. package/src/runtime/addSchemaToClient.ts +2 -0
  88. package/src/runtime/addSchemaToClientWithInstance.ts +2 -0
  89. package/src/runtime/bridge-types.ts +2 -2
  90. package/src/runtime/client/index.ts +207 -184
  91. package/src/runtime/internals/APIClient.ts +67 -23
  92. package/src/runtime/internals/cancellation.ts +57 -0
  93. package/src/runtime/internals/clientUtils.ts +61 -1
  94. package/src/runtime/internals/index.ts +1 -0
  95. package/src/runtime/internals/operations/custom.ts +117 -109
  96. package/src/runtime/internals/operations/get.ts +111 -95
  97. package/src/runtime/internals/operations/indexQuery.ts +100 -94
  98. package/src/runtime/internals/operations/list.ts +132 -119
  99. package/src/runtime/internals/server/generateModelsProperty.ts +31 -28
  100. package/src/runtime/internals/utils/clientProperties/generateModelsProperty.ts +36 -33
  101. package/src/runtime/utils/index.ts +1 -0
  102. package/src/runtime/utils/selfAwareAsync.ts +39 -0
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
- // SPDX-License-Identifier: Apache-2.0
5
3
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSecondaryIndexesFromSchemaModel = void 0;
4
+ exports.excludeDisabledOps = exports.getSecondaryIndexesFromSchemaModel = void 0;
5
+ const APIClient_1 = require("./APIClient");
7
6
  const attributeIsSecondaryIndex = (attr) => {
8
7
  return (attr.type === 'key' &&
9
8
  // presence of `name` property distinguishes GSI from primary index
@@ -26,4 +25,47 @@ const getSecondaryIndexesFromSchemaModel = (model) => {
26
25
  return idxs || [];
27
26
  };
28
27
  exports.getSecondaryIndexesFromSchemaModel = getSecondaryIndexesFromSchemaModel;
28
+ /**
29
+ * returns graphQLOperationsInfo, but filters out operations that were disabled via model().disableOperations([...])
30
+ */
31
+ const excludeDisabledOps = (mis, modelName) => {
32
+ /* Example model attributes in MIS {
33
+ "type": "model",
34
+ "properties": {
35
+ "subscriptions": null,
36
+ "mutations": { "delete": null }
37
+ } }*/
38
+ const modelAttrs = mis.models[modelName].attributes?.find((attr) => attr.type === 'model');
39
+ const coarseToFineDict = {
40
+ queries: ['list', 'get', 'observeQuery'],
41
+ mutations: ['create', 'update', 'delete'],
42
+ subscriptions: ['onCreate', 'onUpdate', 'onDelete'],
43
+ };
44
+ const disabledOps = [];
45
+ if (!modelAttrs) {
46
+ return APIClient_1.graphQLOperationsInfo;
47
+ }
48
+ if (modelAttrs.properties) {
49
+ for (const [key, value] of Object.entries(modelAttrs.properties)) {
50
+ if (value === null) {
51
+ // coarse-grained disable, e.g. "subscriptions": null,
52
+ disabledOps.push(...coarseToFineDict[key]);
53
+ }
54
+ else if (value instanceof Object) {
55
+ // fine-grained, e.g. "mutations": { "delete": null }
56
+ disabledOps.push(...Object.keys(value));
57
+ }
58
+ }
59
+ }
60
+ // observeQuery only exists on the client side, so can't be explicitly disabled via schema builder.
61
+ // It's unusable without `list`
62
+ if (disabledOps.includes('list')) {
63
+ disabledOps.push('observeQuery');
64
+ }
65
+ // graphQLOperationsInfo keys are in caps
66
+ const disabledOpsUpper = disabledOps.map((op) => op.toUpperCase());
67
+ const filteredGraphQLOperations = Object.fromEntries(Object.entries(APIClient_1.graphQLOperationsInfo).filter(([key]) => !disabledOpsUpper.includes(key)));
68
+ return filteredGraphQLOperations;
69
+ };
70
+ exports.excludeDisabledOps = excludeDisabledOps;
29
71
  //# sourceMappingURL=clientUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientUtils.js","sources":["../../../../src/runtime/internals/clientUtils.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getSecondaryIndexesFromSchemaModel = void 0;\nconst attributeIsSecondaryIndex = (attr) => {\n return (attr.type === 'key' &&\n // presence of `name` property distinguishes GSI from primary index\n attr.properties?.name &&\n attr.properties?.queryField &&\n attr.properties?.fields.length > 0);\n};\nconst getSecondaryIndexesFromSchemaModel = (model) => {\n const idxs = model.attributes\n ?.filter(attributeIsSecondaryIndex)\n .map((attr) => {\n const queryField = attr.properties.queryField;\n const [pk, ...sk] = attr.properties.fields;\n return {\n queryField,\n pk,\n sk,\n };\n });\n return idxs || [];\n};\nexports.getSecondaryIndexesFromSchemaModel = getSecondaryIndexesFromSchemaModel;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD,MAAM,yBAAyB,GAAG,CAAC,IAAI,KAAK;AAC5C,IAAI,QAAQ,IAAI,CAAC,IAAI,KAAK,KAAK;AAC/B;AACA,QAAQ,IAAI,CAAC,UAAU,EAAE,IAAI;AAC7B,QAAQ,IAAI,CAAC,UAAU,EAAE,UAAU;AACnC,QAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;AAC5C,CAAC,CAAC;AACF,MAAM,kCAAkC,GAAG,CAAC,KAAK,KAAK;AACtD,IAAI,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU;AACjC,UAAU,MAAM,CAAC,yBAAyB,CAAC;AAC3C,SAAS,GAAG,CAAC,CAAC,IAAI,KAAK;AACvB,QAAQ,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;AACtD,QAAQ,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;AACnD,QAAQ,OAAO;AACf,YAAY,UAAU;AACtB,YAAY,EAAE;AACd,YAAY,EAAE;AACd,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;AACtB,CAAC,CAAC;AACF,OAAO,CAAC,kCAAkC,GAAG,kCAAkC;;"}
1
+ {"version":3,"file":"clientUtils.js","sources":["../../../../src/runtime/internals/clientUtils.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.excludeDisabledOps = exports.getSecondaryIndexesFromSchemaModel = void 0;\nconst APIClient_1 = require(\"./APIClient\");\nconst attributeIsSecondaryIndex = (attr) => {\n return (attr.type === 'key' &&\n // presence of `name` property distinguishes GSI from primary index\n attr.properties?.name &&\n attr.properties?.queryField &&\n attr.properties?.fields.length > 0);\n};\nconst getSecondaryIndexesFromSchemaModel = (model) => {\n const idxs = model.attributes\n ?.filter(attributeIsSecondaryIndex)\n .map((attr) => {\n const queryField = attr.properties.queryField;\n const [pk, ...sk] = attr.properties.fields;\n return {\n queryField,\n pk,\n sk,\n };\n });\n return idxs || [];\n};\nexports.getSecondaryIndexesFromSchemaModel = getSecondaryIndexesFromSchemaModel;\n/**\n * returns graphQLOperationsInfo, but filters out operations that were disabled via model().disableOperations([...])\n */\nconst excludeDisabledOps = (mis, modelName) => {\n /* Example model attributes in MIS {\n \"type\": \"model\",\n \"properties\": {\n \"subscriptions\": null,\n \"mutations\": { \"delete\": null }\n } }*/\n const modelAttrs = mis.models[modelName].attributes?.find((attr) => attr.type === 'model');\n const coarseToFineDict = {\n queries: ['list', 'get', 'observeQuery'],\n mutations: ['create', 'update', 'delete'],\n subscriptions: ['onCreate', 'onUpdate', 'onDelete'],\n };\n const disabledOps = [];\n if (!modelAttrs) {\n return APIClient_1.graphQLOperationsInfo;\n }\n if (modelAttrs.properties) {\n for (const [key, value] of Object.entries(modelAttrs.properties)) {\n if (value === null) {\n // coarse-grained disable, e.g. \"subscriptions\": null,\n disabledOps.push(...coarseToFineDict[key]);\n }\n else if (value instanceof Object) {\n // fine-grained, e.g. \"mutations\": { \"delete\": null }\n disabledOps.push(...Object.keys(value));\n }\n }\n }\n // observeQuery only exists on the client side, so can't be explicitly disabled via schema builder.\n // It's unusable without `list`\n if (disabledOps.includes('list')) {\n disabledOps.push('observeQuery');\n }\n // graphQLOperationsInfo keys are in caps\n const disabledOpsUpper = disabledOps.map((op) => op.toUpperCase());\n const filteredGraphQLOperations = Object.fromEntries(Object.entries(APIClient_1.graphQLOperationsInfo).filter(([key]) => !disabledOpsUpper.includes(key)));\n return filtered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AE,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACvE,IAAI,MAAM,yBAAyB,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/J,IAAI,OAAO,yBAAyB,CAAC;AACrC,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;
4
+ exports.upgradeClientCancellation = exports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;
5
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
6
  // SPDX-License-Identifier: Apache-2.0
7
7
  var generateCustomOperationsProperty_1 = require("./generateCustomOperationsProperty");
@@ -18,4 +18,6 @@ var isApiGraphQLProviderConfig_1 = require("./utils/runtimeTypeGuards/isApiGraph
18
18
  Object.defineProperty(exports, "isApiGraphQLConfig", { enumerable: true, get: function () { return isApiGraphQLProviderConfig_1.isApiGraphQLConfig; } });
19
19
  var isConfigureEventWithResourceConfig_1 = require("./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig");
20
20
  Object.defineProperty(exports, "isConfigureEventWithResourceConfig", { enumerable: true, get: function () { return isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig; } });
21
+ var cancellation_1 = require("./cancellation");
22
+ Object.defineProperty(exports, "upgradeClientCancellation", { enumerable: true, get: function () { return cancellation_1.upgradeClientCancellation; } });
21
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/runtime/internals/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar generateCustomOperationsProperty_1 = require(\"./generateCustomOperationsProperty\");\nObject.defineProperty(exports, \"generateCustomMutationsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomMutationsProperty; } });\nObject.defineProperty(exports, \"generateCustomQueriesProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomQueriesProperty; } });\nObject.defineProperty(exports, \"generateCustomSubscriptionsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomSubscriptionsProperty; } });\nvar generateEnumsProperty_1 = require(\"./utils/clientProperties/generateEnumsProperty\");\nObject.defineProperty(exports, \"generateEnumsProperty\", { enumerable: true, get: function () { return generateEnumsProperty_1.generateEnumsProperty; } });\nvar generateModelsProperty_1 = require(\"./utils/clientProperties/generateModelsProperty\");\nObject.defineProperty(exports, \"generateModelsProperty\", { enumerable: true, get: function () { return generateModelsProperty_1.generateModelsProperty; } });\nvar isGraphQLResponseWithErrors_1 = require(\"./utils/runtimeTypeGuards/isGraphQLResponseWithErrors\");\nObject.defineProperty(exports, \"isGraphQLResponseWithErrors\", { enumerable: true, get: function () { return isGraphQLResponseWithErrors_1.isGraphQLResponseWithErrors; } });\nvar isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nObject.defineProperty(exports, \"isApiGraphQLConfig\", { enumerable: true, get: function () { return isApiGraphQLProviderConfig_1.isApiGraphQLConfig; } });\nvar isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\nObject.defineProperty(exports, \"isConfigureEventWithResourceConfig\", { enumerable: true, get: function () { return isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,+BAA+B,GAAG,KAAK,CAAC,CAAC;AACxT;AACA;AACA,IAAI,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACvF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iCAAiC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kCAAkC,CAAC,+BAA+B,CAAC,EAAE,EAAE,CAAC,CAAC;AACzL,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,+BAA+B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kCAAkC,CAAC,6BAA6B,CAAC,EAAE,EAAE,CAAC,CAAC;AACrL,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,qCAAqC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kCAAkC,CAAC,mCAAmC,CAAC,EAAE,EAAE,C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.defineProperty(exports, \"__esModule\", { value: true });\nexports.upgradeClientCancellation = exports.isConfigureEventWithResourceConfig = exports.isApiGraphQLConfig = exports.isGraphQLResponseWithErrors = exports.generateModelsProperty = exports.generateEnumsProperty = exports.generateCustomSubscriptionsProperty = exports.generateCustomQueriesProperty = exports.generateCustomMutationsProperty = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar generateCustomOperationsProperty_1 = require(\"./generateCustomOperationsProperty\");\nObject.defineProperty(exports, \"generateCustomMutationsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomMutationsProperty; } });\nObject.defineProperty(exports, \"generateCustomQueriesProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomQueriesProperty; } });\nObject.defineProperty(exports, \"generateCustomSubscriptionsProperty\", { enumerable: true, get: function () { return generateCustomOperationsProperty_1.generateCustomSubscriptionsProperty; } });\nvar generateEnumsProperty_1 = require(\"./utils/clientProperties/generateEnumsProperty\");\nObject.defineProperty(exports, \"generateEnumsProperty\", { enumerable: true, get: function () { return generateEnumsProperty_1.generateEnumsProperty; } });\nvar generateModelsProperty_1 = require(\"./utils/clientProperties/generateModelsProperty\");\nObject.defineProperty(exports, \"generateModelsProperty\", { enumerable: true, get: function () { return generateModelsProperty_1.generateModelsProperty; } });\nvar isGraphQLResponseWithErrors_1 = require(\"./utils/runtimeTypeGuards/isGraphQLResponseWithErrors\");\nObject.defineProperty(exports, \"isGraphQLResponseWithErrors\", { enumerable: true, get: function () { return isGraphQLResponseWithErrors_1.isGraphQLResponseWithErrors; } });\nvar isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nObject.defineProperty(exports, \"isApiGraphQLConfig\", { enumerable: true, get: function () { return isApiGraphQLProviderConfig_1.isApiGraphQLConfig; } });\nvar isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\nObject.defineProperty(exports, \"isConfigureEventWithResourceConfig\", { enumerable: true, get: function () { return isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig; } });\nvar cancellation_1 = require(\"./cancellation\");\nObject.defineProperty(exports, \"upgradeClientCancellation\", { enumerable: true, get: function () { return cancellation_1.upgradeClientCancellation; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,kCAAkC,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,6BAA6B,GAAG,OAAO,CAAC,+BAA+B,GAAG,KAAK,CAAC,CAAC;AAC5V;AACA;AACA,IAAI,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACvF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iCAAiC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kCAAkC,CAAC,+BAA+B,CAAC,EAAE,EAAE,CAAC,CAAC;AACzL,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,+BAA+B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kCAAkC,CAAC,6BAA6B,CAAC,EAAE,EAAE,CAAC,CAAC;AACrL,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,qCAAqC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kCAAkC,CAAC,mCAAmC,CAAC,EAAE,EAAE,CAAC,CAAC;AACjM,IAAI,uBAAuB,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AACxF,M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,EAAE,YAAY,EAAE,OAAO,cAAc,CAAC,yBAAyB,CAAC,EAAE,EAAE,CAAC;;"}
@@ -5,6 +5,8 @@ exports.customOpFactory = void 0;
5
5
  const rxjs_1 = require("rxjs");
6
6
  const APIClient_1 = require("../APIClient");
7
7
  const utils_1 = require("./utils");
8
+ const utils_2 = require("../../utils");
9
+ const cancellation_1 = require("../cancellation");
8
10
  /**
9
11
  * Type guard for checking whether a Custom Operation argument is a contextSpec object
10
12
  */
@@ -271,88 +273,48 @@ function operationVariables(operation, args = {}) {
271
273
  * @param context SSR context if relevant.
272
274
  * @returns Result from the graphql request, model-instantiated when relevant.
273
275
  */
274
- async function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {
275
- const { name: operationName } = operation;
276
- const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);
277
- const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);
278
- const outerArgsString = outerArguments(operation);
279
- const innerArgsString = innerArguments(operation);
280
- const selectionSet = operationSelectionSet(modelIntrospection, operation);
281
- const returnTypeModelName = hasStringField(operation.type, 'model')
282
- ? operation.type.model
283
- : undefined;
284
- const query = `
276
+ function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {
277
+ return (0, utils_2.selfAwareAsync)(async (resultPromise) => {
278
+ const { name: operationName } = operation;
279
+ const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);
280
+ const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);
281
+ const outerArgsString = outerArguments(operation);
282
+ const innerArgsString = innerArguments(operation);
283
+ const selectionSet = operationSelectionSet(modelIntrospection, operation);
284
+ const returnTypeModelName = hasStringField(operation.type, 'model')
285
+ ? operation.type.model
286
+ : undefined;
287
+ const query = `
285
288
  ${operationType.toLocaleLowerCase()}${outerArgsString} {
286
289
  ${operationName}${innerArgsString} ${selectionSet}
287
290
  }
288
291
  `;
289
- const variables = operationVariables(operation, args);
290
- try {
291
- const { data, extensions } = context
292
- ? (await client.graphql(context, {
293
- ...auth,
294
- query,
295
- variables,
296
- }, headers))
297
- : (await client.graphql({
298
- ...auth,
299
- query,
300
- variables,
301
- }, headers));
302
- // flatten response
303
- if (data) {
304
- const [key] = Object.keys(data);
305
- const isArrayResult = Array.isArray(data[key]);
306
- // TODO: when adding support for custom selection set, flattening will need
307
- // to occur recursively. For now, it's expected that related models are not
308
- // present in the result. Only FK's are present. Any related model properties
309
- // should be replaced with lazy loaders under the current implementation.
310
- const flattenedResult = isArrayResult
311
- ? data[key].filter((x) => x)
312
- : data[key];
313
- // TODO: custom selection set. current selection set is default selection set only
314
- // custom selection set requires data-schema-type + runtime updates above.
315
- const initialized = returnTypeModelName
316
- ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)
317
- : flattenedResult;
318
- return {
319
- data: !isArrayResult && Array.isArray(initialized)
320
- ? initialized.shift()
321
- : initialized,
322
- extensions,
323
- };
324
- }
325
- else {
326
- return { data: null, extensions };
327
- }
328
- }
329
- catch (error) {
330
- /**
331
- * The `data` type returned by `error` here could be:
332
- * 1) `null`
333
- * 2) an empty object
334
- * 3) "populated" but with a `null` value `{ getPost: null }`
335
- * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`
336
- */
337
- const { data, errors } = error;
338
- /**
339
- * `data` is not `null`, and is not an empty object:
340
- */
341
- if (data && Object.keys(data).length !== 0 && errors) {
342
- const [key] = Object.keys(data);
343
- const isArrayResult = Array.isArray(data[key]);
344
- // TODO: when adding support for custom selection set, flattening will need
345
- // to occur recursively. For now, it's expected that related models are not
346
- // present in the result. Only FK's are present. Any related model properties
347
- // should be replaced with lazy loaders under the current implementation.
348
- const flattenedResult = isArrayResult
349
- ? data[key].filter((x) => x)
350
- : data[key];
351
- /**
352
- * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)
353
- * if `flattenedResult`, result is an actual record:
354
- */
355
- if (flattenedResult) {
292
+ const variables = operationVariables(operation, args);
293
+ try {
294
+ const basePromise = context
295
+ ? client.graphql(context, {
296
+ ...auth,
297
+ query,
298
+ variables,
299
+ }, headers)
300
+ : client.graphql({
301
+ ...auth,
302
+ query,
303
+ variables,
304
+ }, headers);
305
+ const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);
306
+ const { data, extensions } = await extendedPromise;
307
+ // flatten response
308
+ if (data) {
309
+ const [key] = Object.keys(data);
310
+ const isArrayResult = Array.isArray(data[key]);
311
+ // TODO: when adding support for custom selection set, flattening will need
312
+ // to occur recursively. For now, it's expected that related models are not
313
+ // present in the result. Only FK's are present. Any related model properties
314
+ // should be replaced with lazy loaders under the current implementation.
315
+ const flattenedResult = isArrayResult
316
+ ? data[key].filter((x) => x)
317
+ : data[key];
356
318
  // TODO: custom selection set. current selection set is default selection set only
357
319
  // custom selection set requires data-schema-type + runtime updates above.
358
320
  const initialized = returnTypeModelName
@@ -362,19 +324,63 @@ async function _op(client, modelIntrospection, operationType, operation, getInte
362
324
  data: !isArrayResult && Array.isArray(initialized)
363
325
  ? initialized.shift()
364
326
  : initialized,
365
- errors,
327
+ extensions,
366
328
  };
367
329
  }
368
330
  else {
369
- // was `data: { getPost: null }`)
370
- return (0, utils_1.handleSingularGraphQlError)(error);
331
+ return { data: null, extensions };
371
332
  }
372
333
  }
373
- else {
374
- // `data` is `null`:
375
- return (0, utils_1.handleSingularGraphQlError)(error);
334
+ catch (error) {
335
+ /**
336
+ * The `data` type returned by `error` here could be:
337
+ * 1) `null`
338
+ * 2) an empty object
339
+ * 3) "populated" but with a `null` value `{ getPost: null }`
340
+ * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`
341
+ */
342
+ const { data, errors } = error;
343
+ /**
344
+ * `data` is not `null`, and is not an empty object:
345
+ */
346
+ if (data && Object.keys(data).length !== 0 && errors) {
347
+ const [key] = Object.keys(data);
348
+ const isArrayResult = Array.isArray(data[key]);
349
+ // TODO: when adding support for custom selection set, flattening will need
350
+ // to occur recursively. For now, it's expected that related models are not
351
+ // present in the result. Only FK's are present. Any related model properties
352
+ // should be replaced with lazy loaders under the current implementation.
353
+ const flattenedResult = isArrayResult
354
+ ? data[key].filter((x) => x)
355
+ : data[key];
356
+ /**
357
+ * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)
358
+ * if `flattenedResult`, result is an actual record:
359
+ */
360
+ if (flattenedResult) {
361
+ // TODO: custom selection set. current selection set is default selection set only
362
+ // custom selection set requires data-schema-type + runtime updates above.
363
+ const initialized = returnTypeModelName
364
+ ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)
365
+ : flattenedResult;
366
+ return {
367
+ data: !isArrayResult && Array.isArray(initialized)
368
+ ? initialized.shift()
369
+ : initialized,
370
+ errors,
371
+ };
372
+ }
373
+ else {
374
+ // was `data: { getPost: null }`)
375
+ return (0, utils_1.handleSingularGraphQlError)(error);
376
+ }
377
+ }
378
+ else {
379
+ // `data` is `null`:
380
+ return (0, utils_1.handleSingularGraphQlError)(error);
381
+ }
376
382
  }
377
- }
383
+ });
378
384
  }
379
385
  /**
380
386
  * Executes an operation from the given model intro schema against a client, returning
@@ -1 +1 @@
1
- {"version":3,"file":"custom.js","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.customOpFactory = void 0;\nconst rxjs_1 = require(\"rxjs\");\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec);\n };\n return op;\n}\nexports.customOpFactory = customOpFactory;\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\n/**\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if the arg is required.\n */\nfunction argumentBaseTypeString(argDef) {\n const requiredFlag = argDef.isRequired ? '!' : '';\n if (argDef.type instanceof Object && 'enum' in argDef.type) {\n return argDef.type.enum + requiredFlag;\n }\n else {\n return argDef.type + requiredFlag;\n }\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.entries(operation.arguments)\n .map(([k, v]) => {\n const baseType = argumentBaseTypeString(v);\n const finalType = v.isArray\n ? `[${baseType}]${v.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.keys(operation.arguments)\n .map((k) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doesn't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${(0, APIClient_1.selectionSetIRToString)((0, APIClient_1.getDefaultSelectionSetForNonModelWithIR)(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${(0, APIClient_1.generateSelectionSet)(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nasync function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n try {\n const { data, extensions } = context\n ? (await client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers))\n : (await client.graphql({\n ...auth,\n query,\n variables,\n }, headers));\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ,CAAC;AACjD,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AACzG;AACA;AACA,IAAI,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC;AAC1D,IAAI,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK;AAC5B;AACA,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,QAAQ,IAAI,WAAW,CAAC;AACxB,QAAQ,IAAI,GAAG,CAAC;AAChB,QAAQ,IAAI,UAAU,EAAE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CAAC;AAChB,IAAI,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,KAAK;AACtD,QAAQ,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9C,QAAQ,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,QAAQ,MAAM,CAAC,WAAW,CAAC,GAAG,mBAAmB;AACjD,cAAc,IAAI,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AACtI,cAAc,CAAC,IAAI,CAAC,CAAC;AACrB,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK,CAAC,CAAC,CAAC;AACR;;"}
1
+ {"version":3,"file":"custom.js","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.customOpFactory = void 0;\nconst rxjs_1 = require(\"rxjs\");\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nconst utils_2 = require(\"../../utils\");\nconst cancellation_1 = require(\"../cancellation\");\n/**\n * Type guard for checking whether a Custom Operation argument is a contextSpec object\n */\nconst argIsContextSpec = (arg) => {\n return typeof arg?.token?.value === 'symbol';\n};\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext, getInternals) {\n // .arguments() are defined for the custom operation in the schema builder\n // and are present in the model introspection schema\n const argsDefined = operation.arguments !== undefined;\n const op = (...args) => {\n // options is always the last argument\n const options = args[args.length - 1];\n let contextSpec;\n let arg;\n if (useContext) {\n if (argIsContextSpec(args[0])) {\n contextSpec = args[0];\n }\n else {\n throw new Error(`Invalid first argument passed to ${operation.name}. Expected contextSpec`);\n }\n }\n if (argsDefined) {\n if (useContext) {\n arg = args[1];\n }\n else {\n arg = args[0];\n }\n }\n if (operationType === 'subscription') {\n return _opSubscription(\n // subscriptions are only enabled on the clientside\n client, modelIntrospection, operation, getInternals, arg, options);\n }\n return _op(client, modelIntrospection, operationType, operation, getInternals, arg, options, contextSpec);\n };\n return op;\n}\nexports.customOpFactory = customOpFactory;\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\n/**\n * @param argDef A single argument definition from a custom operation\n * @returns A string naming the base type including the `!` if the arg is required.\n */\nfunction argumentBaseTypeString(argDef) {\n const requiredFlag = argDef.isRequired ? '!' : '';\n if (argDef.type instanceof Object && 'enum' in argDef.type) {\n return argDef.type.enum + requiredFlag;\n }\n else {\n return argDef.type + requiredFlag;\n }\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.entries(operation.arguments)\n .map(([k, v]) => {\n const baseType = argumentBaseTypeString(v);\n const finalType = v.isArray\n ? `[${baseType}]${v.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n if (operation.arguments === undefined) {\n return '';\n }\n const args = Object.keys(operation.arguments)\n .map((k) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doesn't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${(0, APIClient_1.selectionSetIRToString)((0, APIClient_1.getDefaultSelectionSetForNonModelWithIR)(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${(0, APIClient_1.generateSelectionSet)(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n if (operation.arguments === undefined) {\n return variables;\n }\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {\n return (0, utils_2.selfAwareAsync)(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n try {\n const basePromise = context\n ? client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers)\n : client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n const extendedPromise = (0, cancellation_1.extendCancellability)(basePromise, resultPromise);\n const { data, extensions } = await extendedPromise;\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n extensions,\n };\n }\n else {\n return { data: null, extensions };\n }\n }\n catch (error) {\n /**\n * The `data` type returned by `error` here could be:\n * 1) `null`\n * 2) an empty object\n * 3) \"populated\" but with a `null` value `{ getPost: null }`\n * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`\n */\n const { data, errors } = error;\n /**\n * `data` is not `null`, and is not an empty object:\n */\n if (data && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n const isArrayResult = Array.isArray(data[key]);\n // TODO: when adding support for custom selection set, flattening will need\n // to occur recursively. For now, it's expected that related models are not\n // present in the result. Only FK's are present. Any related model properties\n // should be replaced with lazy loaders under the current implementation.\n const flattenedResult = isArrayResult\n ? data[key].filter((x) => x)\n : data[key];\n /**\n * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)\n * if `flattenedResult`, result is an actual record:\n */\n if (flattenedResult) {\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const initialized = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : flattenedResult;\n return {\n data: !isArrayResult && Array.isArray(initialized)\n ? initialized.shift()\n : initialized,\n errors,\n };\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n });\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nfunction _opSubscription(client, modelIntrospection, operation, getInternals, args, options) {\n const operationType = 'subscription';\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n ${operationType.toLocaleLowerCase()}${outerArgsString} {\n ${operationName}${innerArgsString} ${selectionSet}\n }\n `;\n const variables = operationVariables(operation, args);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAClD;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,QAAQ,CAAC;AACjD,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AACzG;AACA;AACA,IAAI,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC;AAC1D,IAAI,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK;AAC5B;AACA,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,QAAQ,IAAI,WAAW,C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