@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
@@ -0,0 +1,44 @@
1
+ /**
2
+ * A map of cancellable promise "extensions".
3
+ *
4
+ * Each entry value must either be a directly `cancel()`-able promise, or must
5
+ * refer to another entry.
6
+ *
7
+ * When cancellation of a promise is requested, cancel
8
+ * will check to see if the promise exists in the map. If it does, it pulls
9
+ * the value and repeats the check. If not, it will perform the underlying
10
+ * cancel operation.
11
+ */
12
+ const promiseMap = new WeakMap();
13
+ function extendCancellability(existingCancellablePromise, newPromiseToRegister) {
14
+ promiseMap.set(newPromiseToRegister, existingCancellablePromise);
15
+ return existingCancellablePromise.finally(() => {
16
+ promiseMap.delete(newPromiseToRegister);
17
+ });
18
+ }
19
+ /**
20
+ * Wraps the existing `cancel()` method with logic to iteratively search for
21
+ * the corresponding base level promise, if needed, that the core graphql client
22
+ * knows how to cancel.
23
+ *
24
+ * @param client
25
+ */
26
+ function upgradeClientCancellation(client) {
27
+ const innerCancel = client.cancel.bind(client);
28
+ client.cancel = function (promise, message) {
29
+ const visited = new Set();
30
+ let targetPromise = promise;
31
+ while (targetPromise && promiseMap.has(targetPromise)) {
32
+ if (visited.has(targetPromise))
33
+ throw new Error('A cycle was detected in the modeled graphql cancellation chain. This is a bug. Please report it!');
34
+ visited.add(targetPromise);
35
+ targetPromise = promiseMap.get(targetPromise);
36
+ }
37
+ // call `innerCancel` with `targetPromise!` to defer to existing implementation
38
+ // on how to handle `null | undefined` or otherwise "non-cancellable" objects.
39
+ return innerCancel(targetPromise, message);
40
+ };
41
+ }
42
+
43
+ export { extendCancellability, upgradeClientCancellation };
44
+ //# sourceMappingURL=cancellation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancellation.mjs","sources":["../../../../src/runtime/internals/cancellation.ts"],"sourcesContent":["/**\n * A map of cancellable promise \"extensions\".\n *\n * Each entry value must either be a directly `cancel()`-able promise, or must\n * refer to another entry.\n *\n * When cancellation of a promise is requested, cancel\n * will check to see if the promise exists in the map. If it does, it pulls\n * the value and repeats the check. If not, it will perform the underlying\n * cancel operation.\n */\nconst promiseMap = new WeakMap();\nexport function extendCancellability(existingCancellablePromise, newPromiseToRegister) {\n promiseMap.set(newPromiseToRegister, existingCancellablePromise);\n return existingCancellablePromise.finally(() => {\n promiseMap.delete(newPromiseToRegister);\n });\n}\n/**\n * Wraps the existing `cancel()` method with logic to iteratively search for\n * the corresponding base level promise, if needed, that the core graphql client\n * knows how to cancel.\n *\n * @param client\n */\nexport function upgradeClientCancellation(client) {\n const innerCancel = client.cancel.bind(client);\n client.cancel = function (promise, message) {\n const visited = new Set();\n let targetPromise = promise;\n while (targetPromise && promiseMap.has(targetPromise)) {\n if (visited.has(targetPromise))\n throw new Error('A cycle was detected in the modeled graphql cancellation chain. This is a bug. Please report it!');\n visited.add(targetPromise);\n targetPromise = promiseMap.get(targetPromise);\n }\n // call `innerCancel` with `targetPromise!` to defer to existing implementation\n // on how to handle `null | undefined` or otherwise \"non-cancellable\" objects.\n return innerCancel(targetPromise, message);\n };\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,UAAU,GAAG,IAAI,OAAO,EAAE,CAAC;AAC1B,SAAS,oBAAoB,CAAC,0BAA0B,EAAE,oBAAoB,EAAE;AACvF,IAAI,UAAU,CAAC,GAAG,CAAC,oBAAoB,EAAE,0BAA0B,CAAC,CAAC;AACrE,IAAI,OAAO,0BAA0B,CAAC,OAAO,CAAC,MAAM;AACpD,QAAQ,UAAU,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAChD,KAAK,CAAC,CAAC;AACP,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,yBAAyB,CAAC,MAAM,EAAE;AAClD,IAAI,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnD,IAAI,MAAM,CAAC,MAAM,GAAG,UAAU,OAAO,EAAE,OAAO,EAAE;AAChD,QAAQ,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;AAClC,QAAQ,IAAI,aAAa,GAAG,OAAO,CAAC;AACpC,QAAQ,OAAO,aAAa,IAAI,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;AAC/D,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AAC1C,gBAAgB,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAC;AACpI,YAAY,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACvC,YAAY,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAC1D,SAAS;AACT;AACA;AACA,QAAQ,OAAO,WAAW,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACnD,KAAK,CAAC;AACN;;;;"}
@@ -1,6 +1,83 @@
1
- import type { SchemaModel } from '../bridge-types';
1
+ import type { SchemaModel, ModelIntrospectionSchema } from '../bridge-types';
2
2
  export declare const getSecondaryIndexesFromSchemaModel: (model: SchemaModel) => {
3
3
  queryField: string;
4
4
  pk: string;
5
5
  sk: string[];
6
6
  }[];
7
+ /**
8
+ * returns graphQLOperationsInfo, but filters out operations that were disabled via model().disableOperations([...])
9
+ */
10
+ export declare const excludeDisabledOps: (mis: ModelIntrospectionSchema, modelName: string) => {
11
+ readonly CREATE: {
12
+ readonly operationPrefix: "create";
13
+ readonly usePlural: false;
14
+ };
15
+ readonly GET: {
16
+ readonly operationPrefix: "get";
17
+ readonly usePlural: false;
18
+ };
19
+ readonly UPDATE: {
20
+ readonly operationPrefix: "update";
21
+ readonly usePlural: false;
22
+ };
23
+ readonly DELETE: {
24
+ readonly operationPrefix: "delete";
25
+ readonly usePlural: false;
26
+ };
27
+ readonly LIST: {
28
+ readonly operationPrefix: "list";
29
+ readonly usePlural: true;
30
+ };
31
+ readonly INDEX_QUERY: {
32
+ readonly operationPrefix: "";
33
+ readonly usePlural: false;
34
+ };
35
+ readonly ONCREATE: {
36
+ readonly operationPrefix: "onCreate";
37
+ readonly usePlural: false;
38
+ };
39
+ readonly ONUPDATE: {
40
+ readonly operationPrefix: "onUpdate";
41
+ readonly usePlural: false;
42
+ };
43
+ readonly ONDELETE: {
44
+ readonly operationPrefix: "onDelete";
45
+ readonly usePlural: false;
46
+ };
47
+ readonly OBSERVEQUERY: {
48
+ readonly operationPrefix: "observeQuery";
49
+ readonly usePlural: false;
50
+ };
51
+ } | {
52
+ [k: string]: {
53
+ readonly operationPrefix: "create";
54
+ readonly usePlural: false;
55
+ } | {
56
+ readonly operationPrefix: "get";
57
+ readonly usePlural: false;
58
+ } | {
59
+ readonly operationPrefix: "update";
60
+ readonly usePlural: false;
61
+ } | {
62
+ readonly operationPrefix: "delete";
63
+ readonly usePlural: false;
64
+ } | {
65
+ readonly operationPrefix: "list";
66
+ readonly usePlural: true;
67
+ } | {
68
+ readonly operationPrefix: "";
69
+ readonly usePlural: false;
70
+ } | {
71
+ readonly operationPrefix: "onCreate";
72
+ readonly usePlural: false;
73
+ } | {
74
+ readonly operationPrefix: "onUpdate";
75
+ readonly usePlural: false;
76
+ } | {
77
+ readonly operationPrefix: "onDelete";
78
+ readonly usePlural: false;
79
+ } | {
80
+ readonly operationPrefix: "observeQuery";
81
+ readonly usePlural: false;
82
+ };
83
+ };
@@ -1,5 +1,5 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ import { graphQLOperationsInfo } from './APIClient.mjs';
2
+
3
3
  const attributeIsSecondaryIndex = (attr) => {
4
4
  return (attr.type === 'key' &&
5
5
  // presence of `name` property distinguishes GSI from primary index
@@ -21,6 +21,48 @@ const getSecondaryIndexesFromSchemaModel = (model) => {
21
21
  });
22
22
  return idxs || [];
23
23
  };
24
+ /**
25
+ * returns graphQLOperationsInfo, but filters out operations that were disabled via model().disableOperations([...])
26
+ */
27
+ const excludeDisabledOps = (mis, modelName) => {
28
+ /* Example model attributes in MIS {
29
+ "type": "model",
30
+ "properties": {
31
+ "subscriptions": null,
32
+ "mutations": { "delete": null }
33
+ } }*/
34
+ const modelAttrs = mis.models[modelName].attributes?.find((attr) => attr.type === 'model');
35
+ const coarseToFineDict = {
36
+ queries: ['list', 'get', 'observeQuery'],
37
+ mutations: ['create', 'update', 'delete'],
38
+ subscriptions: ['onCreate', 'onUpdate', 'onDelete'],
39
+ };
40
+ const disabledOps = [];
41
+ if (!modelAttrs) {
42
+ return graphQLOperationsInfo;
43
+ }
44
+ if (modelAttrs.properties) {
45
+ for (const [key, value] of Object.entries(modelAttrs.properties)) {
46
+ if (value === null) {
47
+ // coarse-grained disable, e.g. "subscriptions": null,
48
+ disabledOps.push(...coarseToFineDict[key]);
49
+ }
50
+ else if (value instanceof Object) {
51
+ // fine-grained, e.g. "mutations": { "delete": null }
52
+ disabledOps.push(...Object.keys(value));
53
+ }
54
+ }
55
+ }
56
+ // observeQuery only exists on the client side, so can't be explicitly disabled via schema builder.
57
+ // It's unusable without `list`
58
+ if (disabledOps.includes('list')) {
59
+ disabledOps.push('observeQuery');
60
+ }
61
+ // graphQLOperationsInfo keys are in caps
62
+ const disabledOpsUpper = disabledOps.map((op) => op.toUpperCase());
63
+ const filteredGraphQLOperations = Object.fromEntries(Object.entries(graphQLOperationsInfo).filter(([key]) => !disabledOpsUpper.includes(key)));
64
+ return filteredGraphQLOperations;
65
+ };
24
66
 
25
- export { getSecondaryIndexesFromSchemaModel };
67
+ export { excludeDisabledOps, getSecondaryIndexesFromSchemaModel };
26
68
  //# sourceMappingURL=clientUtils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientUtils.mjs","sources":["../../../../src/runtime/internals/clientUtils.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.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};\nexport const 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};\n"],"names":[],"mappings":"AAAA;AACA;AACA,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;AACU,MAAC,kCAAkC,GAAG,CAAC,KAAK,KAAK;AAC7D,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;;;;"}
1
+ {"version":3,"file":"clientUtils.mjs","sources":["../../../../src/runtime/internals/clientUtils.ts"],"sourcesContent":["import { graphQLOperationsInfo } from './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};\nexport const 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};\n/**\n * returns graphQLOperationsInfo, but filters out operations that were disabled via model().disableOperations([...])\n */\nexport const 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 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(graphQLOperationsInfo).filter(([key]) => !disabledOpsUpper.includes(key)));\n return filteredGraphQLOperations;\n};\n"],"names":[],"mappings":";;AACA,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;AACU,MAAC,kCAAkC,GAAG,CAAC,KAAK,KAAK;AAC7D,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,EAAE;AACF;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK;AACtD;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,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CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnJ,IAAI,OAAO,yBAAyB,CAAC;AACrC;;;;"}
@@ -4,3 +4,4 @@ export { generateModelsProperty } from './utils/clientProperties/generateModelsP
4
4
  export { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors';
5
5
  export { isApiGraphQLConfig } from './utils/runtimeTypeGuards/isApiGraphQLProviderConfig';
6
6
  export { isConfigureEventWithResourceConfig } from './utils/runtimeTypeGuards/isConfigureEventWithResourceConfig';
7
+ export { upgradeClientCancellation } from './cancellation';
@@ -4,4 +4,5 @@ export { generateModelsProperty } from './utils/clientProperties/generateModelsP
4
4
  export { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs';
5
5
  export { isApiGraphQLConfig } from './utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs';
6
6
  export { isConfigureEventWithResourceConfig } from './utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs';
7
+ export { upgradeClientCancellation } from './cancellation.mjs';
7
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -57,5 +57,5 @@ type OpArgs = [AmplifyServer.ContextSpec, QueryArgs, CustomOperationOptions] | [
57
57
  * @param useContext Whether the function needs to accept an SSR context.
58
58
  * @returns The operation function to attach to query, mutations, etc.
59
59
  */
60
- export declare function customOpFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, operationType: 'query' | 'mutation' | 'subscription', operation: CustomOperation, useContext: boolean, getInternals: ClientInternalsGetter): (...args: OpArgs) => Promise<any> | import("rxjs").Observable<any>;
60
+ export declare function customOpFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, operationType: 'query' | 'mutation' | 'subscription', operation: CustomOperation, useContext: boolean, getInternals: ClientInternalsGetter): (...args: OpArgs) => Promise<unknown> | import("rxjs").Observable<any>;
61
61
  export {};
@@ -1,6 +1,8 @@
1
1
  import { map } from 'rxjs';
2
2
  import { authModeParams, getCustomHeaders, initializeModel, selectionSetIRToString, getDefaultSelectionSetForNonModelWithIR, generateSelectionSet } from '../APIClient.mjs';
3
3
  import { handleSingularGraphQlError } from './utils.mjs';
4
+ import { selfAwareAsync } from '../../utils/selfAwareAsync.mjs';
5
+ import { extendCancellability } from '../cancellation.mjs';
4
6
 
5
7
  /**
6
8
  * Type guard for checking whether a Custom Operation argument is a contextSpec object
@@ -267,88 +269,48 @@ function operationVariables(operation, args = {}) {
267
269
  * @param context SSR context if relevant.
268
270
  * @returns Result from the graphql request, model-instantiated when relevant.
269
271
  */
270
- async function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {
271
- const { name: operationName } = operation;
272
- const auth = authModeParams(client, getInternals, options);
273
- const headers = getCustomHeaders(client, getInternals, options?.headers);
274
- const outerArgsString = outerArguments(operation);
275
- const innerArgsString = innerArguments(operation);
276
- const selectionSet = operationSelectionSet(modelIntrospection, operation);
277
- const returnTypeModelName = hasStringField(operation.type, 'model')
278
- ? operation.type.model
279
- : undefined;
280
- const query = `
272
+ function _op(client, modelIntrospection, operationType, operation, getInternals, args, options, context) {
273
+ return selfAwareAsync(async (resultPromise) => {
274
+ const { name: operationName } = operation;
275
+ const auth = authModeParams(client, getInternals, options);
276
+ const headers = getCustomHeaders(client, getInternals, options?.headers);
277
+ const outerArgsString = outerArguments(operation);
278
+ const innerArgsString = innerArguments(operation);
279
+ const selectionSet = operationSelectionSet(modelIntrospection, operation);
280
+ const returnTypeModelName = hasStringField(operation.type, 'model')
281
+ ? operation.type.model
282
+ : undefined;
283
+ const query = `
281
284
  ${operationType.toLocaleLowerCase()}${outerArgsString} {
282
285
  ${operationName}${innerArgsString} ${selectionSet}
283
286
  }
284
287
  `;
285
- const variables = operationVariables(operation, args);
286
- try {
287
- const { data, extensions } = context
288
- ? (await client.graphql(context, {
289
- ...auth,
290
- query,
291
- variables,
292
- }, headers))
293
- : (await client.graphql({
294
- ...auth,
295
- query,
296
- variables,
297
- }, headers));
298
- // flatten response
299
- if (data) {
300
- const [key] = Object.keys(data);
301
- const isArrayResult = Array.isArray(data[key]);
302
- // TODO: when adding support for custom selection set, flattening will need
303
- // to occur recursively. For now, it's expected that related models are not
304
- // present in the result. Only FK's are present. Any related model properties
305
- // should be replaced with lazy loaders under the current implementation.
306
- const flattenedResult = isArrayResult
307
- ? data[key].filter((x) => x)
308
- : data[key];
309
- // TODO: custom selection set. current selection set is default selection set only
310
- // custom selection set requires data-schema-type + runtime updates above.
311
- const initialized = returnTypeModelName
312
- ? initializeModel(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)
313
- : flattenedResult;
314
- return {
315
- data: !isArrayResult && Array.isArray(initialized)
316
- ? initialized.shift()
317
- : initialized,
318
- extensions,
319
- };
320
- }
321
- else {
322
- return { data: null, extensions };
323
- }
324
- }
325
- catch (error) {
326
- /**
327
- * The `data` type returned by `error` here could be:
328
- * 1) `null`
329
- * 2) an empty object
330
- * 3) "populated" but with a `null` value `{ getPost: null }`
331
- * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`
332
- */
333
- const { data, errors } = error;
334
- /**
335
- * `data` is not `null`, and is not an empty object:
336
- */
337
- if (data && Object.keys(data).length !== 0 && errors) {
338
- const [key] = Object.keys(data);
339
- const isArrayResult = Array.isArray(data[key]);
340
- // TODO: when adding support for custom selection set, flattening will need
341
- // to occur recursively. For now, it's expected that related models are not
342
- // present in the result. Only FK's are present. Any related model properties
343
- // should be replaced with lazy loaders under the current implementation.
344
- const flattenedResult = isArrayResult
345
- ? data[key].filter((x) => x)
346
- : data[key];
347
- /**
348
- * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)
349
- * if `flattenedResult`, result is an actual record:
350
- */
351
- if (flattenedResult) {
288
+ const variables = operationVariables(operation, args);
289
+ try {
290
+ const basePromise = context
291
+ ? client.graphql(context, {
292
+ ...auth,
293
+ query,
294
+ variables,
295
+ }, headers)
296
+ : client.graphql({
297
+ ...auth,
298
+ query,
299
+ variables,
300
+ }, headers);
301
+ const extendedPromise = extendCancellability(basePromise, resultPromise);
302
+ const { data, extensions } = await extendedPromise;
303
+ // flatten response
304
+ if (data) {
305
+ const [key] = Object.keys(data);
306
+ const isArrayResult = Array.isArray(data[key]);
307
+ // TODO: when adding support for custom selection set, flattening will need
308
+ // to occur recursively. For now, it's expected that related models are not
309
+ // present in the result. Only FK's are present. Any related model properties
310
+ // should be replaced with lazy loaders under the current implementation.
311
+ const flattenedResult = isArrayResult
312
+ ? data[key].filter((x) => x)
313
+ : data[key];
352
314
  // TODO: custom selection set. current selection set is default selection set only
353
315
  // custom selection set requires data-schema-type + runtime updates above.
354
316
  const initialized = returnTypeModelName
@@ -358,19 +320,63 @@ async function _op(client, modelIntrospection, operationType, operation, getInte
358
320
  data: !isArrayResult && Array.isArray(initialized)
359
321
  ? initialized.shift()
360
322
  : initialized,
361
- errors,
323
+ extensions,
362
324
  };
363
325
  }
364
326
  else {
365
- // was `data: { getPost: null }`)
366
- return handleSingularGraphQlError(error);
327
+ return { data: null, extensions };
367
328
  }
368
329
  }
369
- else {
370
- // `data` is `null`:
371
- return handleSingularGraphQlError(error);
330
+ catch (error) {
331
+ /**
332
+ * The `data` type returned by `error` here could be:
333
+ * 1) `null`
334
+ * 2) an empty object
335
+ * 3) "populated" but with a `null` value `{ getPost: null }`
336
+ * 4) an actual record `{ getPost: { id: '1', title: 'Hello, World!' } }`
337
+ */
338
+ const { data, errors } = error;
339
+ /**
340
+ * `data` is not `null`, and is not an empty object:
341
+ */
342
+ if (data && Object.keys(data).length !== 0 && errors) {
343
+ const [key] = Object.keys(data);
344
+ const isArrayResult = Array.isArray(data[key]);
345
+ // TODO: when adding support for custom selection set, flattening will need
346
+ // to occur recursively. For now, it's expected that related models are not
347
+ // present in the result. Only FK's are present. Any related model properties
348
+ // should be replaced with lazy loaders under the current implementation.
349
+ const flattenedResult = isArrayResult
350
+ ? data[key].filter((x) => x)
351
+ : data[key];
352
+ /**
353
+ * `flattenedResult` could be `null` here (e.g. `data: { getPost: null }`)
354
+ * if `flattenedResult`, result is an actual record:
355
+ */
356
+ if (flattenedResult) {
357
+ // TODO: custom selection set. current selection set is default selection set only
358
+ // custom selection set requires data-schema-type + runtime updates above.
359
+ const initialized = returnTypeModelName
360
+ ? initializeModel(client, returnTypeModelName, isArrayResult ? flattenedResult : [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)
361
+ : flattenedResult;
362
+ return {
363
+ data: !isArrayResult && Array.isArray(initialized)
364
+ ? initialized.shift()
365
+ : initialized,
366
+ errors,
367
+ };
368
+ }
369
+ else {
370
+ // was `data: { getPost: null }`)
371
+ return handleSingularGraphQlError(error);
372
+ }
373
+ }
374
+ else {
375
+ // `data` is `null`:
376
+ return handleSingularGraphQlError(error);
377
+ }
372
378
  }
373
- }
379
+ });
374
380
  }
375
381
  /**
376
382
  * Executes an operation from the given model intro schema against a client, returning
@@ -1 +1 @@
1
- {"version":3,"file":"custom.mjs","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["import { map } from 'rxjs';\nimport { authModeParams, getDefaultSelectionSetForNonModelWithIR, generateSelectionSet, getCustomHeaders, initializeModel, selectionSetIRToString, } from '../APIClient';\nimport { handleSingularGraphQlError } from './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 */\nexport function 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}\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 `{${selectionSetIRToString(getDefaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${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 = authModeParams(client, getInternals, options);\n const headers = 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 ? 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 ? 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 handleSingularGraphQlError(error);\n }\n }\n else {\n // `data` is `null`:\n return 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 = authModeParams(client, getInternals, options);\n const headers = 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(map((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;;;AAGA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK;AAClC,IAAI,OAAO,OAAO,GAAG,EAAE,KAAK,EAAE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AC,IAAI,CAAC,KAAK;AAC9B,UAAU,SAAS,CAAC;AACpB,IAAI,MAAM,KAAK,GAAG,CAAC;AACnB,IAAI,EAAE,aAAa,CAAC,iBAAiB,EAAE,CAAC,EAAE,eAAe,CAAC;AAC1D,MAAM,EAAE,aAAa,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC;AACxD;AACA,EAAE,CAAC,CAAC;AACJ,IAAI,MAAM,SAAS,GAAG,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC1D,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;AACtC,QAAQ,GAAG,IAAI;AACf,QAAQ,KAAK;AACb,QAAQ,SAAS;AACjB,KAAK,EAAE,OAAO,CAAC,CAAC;AAChB,IAAI,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;AAC1C,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,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AACrH,cAAc,CAAC,IAAI,CAAC,CAAC;AACrB,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK,CAAC,CAAC,CAAC;AACR;;;;"}
1
+ {"version":3,"file":"custom.mjs","sources":["../../../../../src/runtime/internals/operations/custom.ts"],"sourcesContent":["import { map } from 'rxjs';\nimport { authModeParams, getDefaultSelectionSetForNonModelWithIR, generateSelectionSet, getCustomHeaders, initializeModel, selectionSetIRToString, } from '../APIClient';\nimport { handleSingularGraphQlError } from './utils';\nimport { selfAwareAsync } from '../../utils';\nimport { extendCancellability } from '../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 */\nexport function 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}\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 `{${selectionSetIRToString(getDefaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${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 selfAwareAsync(async (resultPromise) => {\n const { name: operationName } = operation;\n const auth = authModeParams(client, getInternals, options);\n const headers = 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 = 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 ? 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 ? 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 handleSingularGraphQlError(error);\n }\n }\n else {\n // `data` is `null`:\n return 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 = authModeParams(client, getInternals, options);\n const headers = 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(map((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = returnTypeModelName\n ? initializeModel(client, returnTypeModelName, [data], modelIntrospection, auth.authMode, auth.authToken)\n : [data];\n return initialized;\n }));\n}\n"],"names":[],"mappings":";;;;;;AAKA;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;AACO,SAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AAChH;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;AACxB,YAAY,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;AAC3C,gBAAgB,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CA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AAI,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,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;AACrH,cAAc,CAAC,IAAI,CAAC,CAAC;AACrB,QAAQ,OAAO,WAAW,CAAC;AAC3B,KAAK,CAAC,CAAC,CAAC;AACR;;;;"}
@@ -1,3 +1,3 @@
1
1
  import { AmplifyServer, BaseClient, ClientInternalsGetter, GraphQLOptions, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
2
2
  import { ModelOperation } from '../APIClient';
3
- export declare function getFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, model: SchemaModel, operation: ModelOperation, getInternals: ClientInternalsGetter, useContext?: boolean): (contextSpec: AmplifyServer.ContextSpec & GraphQLOptions, arg?: any, options?: any) => Promise<any>;
3
+ export declare function getFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, model: SchemaModel, operation: ModelOperation, getInternals: ClientInternalsGetter, useContext?: boolean): (contextSpec: AmplifyServer.ContextSpec & GraphQLOptions, arg?: any, options?: any) => Promise<unknown>;