@aws-amplify/data-schema 1.3.9 → 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 (104) 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 +18 -10
  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/esm/util/Filters.d.ts +42 -3
  82. package/dist/meta/cjs.tsbuildinfo +1 -1
  83. package/package.json +2 -2
  84. package/src/ClientSchema/Core/ClientModel.ts +29 -0
  85. package/src/ClientSchema/utilities/ResolveField.ts +26 -6
  86. package/src/ModelType.ts +31 -0
  87. package/src/SchemaProcessor.ts +77 -2
  88. package/src/runtime/addSchemaToClient.ts +2 -0
  89. package/src/runtime/addSchemaToClientWithInstance.ts +2 -0
  90. package/src/runtime/bridge-types.ts +2 -2
  91. package/src/runtime/client/index.ts +230 -184
  92. package/src/runtime/internals/APIClient.ts +67 -23
  93. package/src/runtime/internals/cancellation.ts +57 -0
  94. package/src/runtime/internals/clientUtils.ts +61 -1
  95. package/src/runtime/internals/index.ts +1 -0
  96. package/src/runtime/internals/operations/custom.ts +117 -109
  97. package/src/runtime/internals/operations/get.ts +111 -95
  98. package/src/runtime/internals/operations/indexQuery.ts +100 -94
  99. package/src/runtime/internals/operations/list.ts +132 -119
  100. package/src/runtime/internals/server/generateModelsProperty.ts +31 -28
  101. package/src/runtime/internals/utils/clientProperties/generateModelsProperty.ts +36 -33
  102. package/src/runtime/utils/index.ts +1 -0
  103. package/src/runtime/utils/selfAwareAsync.ts +39 -0
  104. package/src/util/Filters.ts +47 -3
@@ -1,14 +1,16 @@
1
1
  import { generateGraphQLDocument, buildGraphQLVariables, authModeParams, getCustomHeaders, flattenItems, initializeModel } from '../APIClient.mjs';
2
2
  import { handleListGraphQlError } from './utils.mjs';
3
+ import { selfAwareAsync } from '../../utils/selfAwareAsync.mjs';
4
+ import { extendCancellability } from '../cancellation.mjs';
3
5
 
4
6
  function indexQueryFactory(client, modelIntrospection, model, indexMeta, getInternals, context = false) {
5
- const indexQueryWithContext = async (contextSpec, args, options) => {
7
+ const indexQueryWithContext = (contextSpec, args, options) => {
6
8
  return _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, {
7
9
  ...args,
8
10
  ...options,
9
11
  }, contextSpec);
10
12
  };
11
- const indexQuery = async (args, options) => {
13
+ const indexQuery = (args, options) => {
12
14
  return _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, {
13
15
  ...args,
14
16
  ...options,
@@ -34,68 +36,72 @@ function processGraphQlResponse(modelIntroSchema, modelName, result, selectionSe
34
36
  extensions,
35
37
  };
36
38
  }
37
- async function _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, args, contextSpec) {
38
- const { name } = model;
39
- const query = generateGraphQLDocument(modelIntrospection, name, 'INDEX_QUERY', args, indexMeta);
40
- const variables = buildGraphQLVariables(model, 'INDEX_QUERY', args, modelIntrospection, indexMeta);
41
- const auth = authModeParams(client, getInternals, args);
42
- const modelInitializer = (flattenedResult) => initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);
43
- try {
44
- const headers = getCustomHeaders(client, getInternals, args?.headers);
45
- const graphQlParams = {
46
- ...auth,
47
- query,
48
- variables,
49
- };
50
- const requestArgs = [graphQlParams, headers];
51
- if (contextSpec !== undefined) {
52
- requestArgs.unshift(contextSpec);
53
- }
54
- const response = (await client.graphql(...requestArgs));
55
- if (response.data !== undefined) {
56
- return processGraphQlResponse(modelIntrospection, name, response, args?.selectionSet, modelInitializer);
39
+ function _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, args, contextSpec) {
40
+ return selfAwareAsync(async (resultPromise) => {
41
+ const { name } = model;
42
+ const query = generateGraphQLDocument(modelIntrospection, name, 'INDEX_QUERY', args, indexMeta);
43
+ const variables = buildGraphQLVariables(model, 'INDEX_QUERY', args, modelIntrospection, indexMeta);
44
+ const auth = authModeParams(client, getInternals, args);
45
+ const modelInitializer = (flattenedResult) => initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);
46
+ try {
47
+ const headers = getCustomHeaders(client, getInternals, args?.headers);
48
+ const graphQlParams = {
49
+ ...auth,
50
+ query,
51
+ variables,
52
+ };
53
+ const requestArgs = [graphQlParams, headers];
54
+ if (contextSpec !== undefined) {
55
+ requestArgs.unshift(contextSpec);
56
+ }
57
+ const basePromise = client.graphql(...requestArgs);
58
+ const extendedPromise = extendCancellability(basePromise, resultPromise);
59
+ const response = await extendedPromise;
60
+ if (response.data !== undefined) {
61
+ return processGraphQlResponse(modelIntrospection, name, response, args?.selectionSet, modelInitializer);
62
+ }
57
63
  }
58
- }
59
- catch (error) {
60
- /**
61
- * The `data` type returned by `error` here could be:
62
- * 1) `null`
63
- * 2) an empty object
64
- * 3) "populated" but with a `null` value:
65
- * `data: { listByExampleId: null }`
66
- * 4) an actual record:
67
- * `data: { listByExampleId: items: [{ id: '1', ...etc } }]`
68
- */
69
- const { data, errors } = error;
70
- // `data` is not `null`, and is not an empty object:
71
- if (data !== undefined && Object.keys(data).length !== 0 && errors) {
72
- const [key] = Object.keys(data);
73
- if (data[key]?.items) {
74
- const flattenedResult = data[key]?.items.map((value) => flattenItems(modelIntrospection, name, value));
75
- /**
76
- * Check exists since `flattenedResult` could be `null`.
77
- * if `flattenedResult` exists, result is an actual record.
78
- */
79
- if (flattenedResult) {
80
- return {
81
- data: args?.selectionSet
82
- ? flattenedResult
83
- : modelInitializer(flattenedResult),
84
- nextToken: data[key]?.nextToken,
85
- };
64
+ catch (error) {
65
+ /**
66
+ * The `data` type returned by `error` here could be:
67
+ * 1) `null`
68
+ * 2) an empty object
69
+ * 3) "populated" but with a `null` value:
70
+ * `data: { listByExampleId: null }`
71
+ * 4) an actual record:
72
+ * `data: { listByExampleId: items: [{ id: '1', ...etc } }]`
73
+ */
74
+ const { data, errors } = error;
75
+ // `data` is not `null`, and is not an empty object:
76
+ if (data !== undefined && Object.keys(data).length !== 0 && errors) {
77
+ const [key] = Object.keys(data);
78
+ if (data[key]?.items) {
79
+ const flattenedResult = data[key]?.items.map((value) => flattenItems(modelIntrospection, name, value));
80
+ /**
81
+ * Check exists since `flattenedResult` could be `null`.
82
+ * if `flattenedResult` exists, result is an actual record.
83
+ */
84
+ if (flattenedResult) {
85
+ return {
86
+ data: args?.selectionSet
87
+ ? flattenedResult
88
+ : modelInitializer(flattenedResult),
89
+ nextToken: data[key]?.nextToken,
90
+ };
91
+ }
86
92
  }
93
+ // response is of type `data: { listByExampleId: null }`
94
+ return {
95
+ data: data[key],
96
+ nextToken: data[key]?.nextToken,
97
+ };
98
+ }
99
+ else {
100
+ // `data` is `null` or an empty object:
101
+ return handleListGraphQlError(error);
87
102
  }
88
- // response is of type `data: { listByExampleId: null }`
89
- return {
90
- data: data[key],
91
- nextToken: data[key]?.nextToken,
92
- };
93
- }
94
- else {
95
- // `data` is `null` or an empty object:
96
- return handleListGraphQlError(error);
97
103
  }
98
- }
104
+ });
99
105
  }
100
106
 
101
107
  export { indexQueryFactory };
@@ -1 +1 @@
1
- {"version":3,"file":"indexQuery.mjs","sources":["../../../../../src/runtime/internals/operations/indexQuery.ts"],"sourcesContent":["import { authModeParams, buildGraphQLVariables, flattenItems, generateGraphQLDocument, getCustomHeaders, initializeModel, } from '../APIClient';\nimport { handleListGraphQlError } from './utils';\nexport function indexQueryFactory(client, modelIntrospection, model, indexMeta, getInternals, context = false) {\n const indexQueryWithContext = async (contextSpec, args, options) => {\n return _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, {\n ...args,\n ...options,\n }, contextSpec);\n };\n const indexQuery = async (args, options) => {\n return _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, {\n ...args,\n ...options,\n });\n };\n return context ? indexQueryWithContext : indexQuery;\n}\nfunction processGraphQlResponse(modelIntroSchema, modelName, result, selectionSet, modelInitializer) {\n const { data, extensions } = result;\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = data[key].items.map((value) => flattenItems(modelIntroSchema, modelName, value));\n return {\n data: selectionSet ? flattenedResult : modelInitializer(flattenedResult),\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n // Index queries are always list queries. No `items`? No flattening needed.\n return {\n data: data[key],\n nextToken: data[key].nextToken,\n extensions,\n };\n}\nasync function _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, args, contextSpec) {\n const { name } = model;\n const query = generateGraphQLDocument(modelIntrospection, name, 'INDEX_QUERY', args, indexMeta);\n const variables = buildGraphQLVariables(model, 'INDEX_QUERY', args, modelIntrospection, indexMeta);\n const auth = authModeParams(client, getInternals, args);\n const modelInitializer = (flattenedResult) => initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n try {\n const headers = getCustomHeaders(client, getInternals, args?.headers);\n const graphQlParams = {\n ...auth,\n query,\n variables,\n };\n const requestArgs = [graphQlParams, headers];\n if (contextSpec !== undefined) {\n requestArgs.unshift(contextSpec);\n }\n const response = (await client.graphql(...requestArgs));\n if (response.data !== undefined) {\n return processGraphQlResponse(modelIntrospection, name, response, args?.selectionSet, modelInitializer);\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:\n * `data: { listByExampleId: null }`\n * 4) an actual record:\n * `data: { listByExampleId: items: [{ id: '1', ...etc } }]`\n */\n const { data, errors } = error;\n // `data` is not `null`, and is not an empty object:\n if (data !== undefined && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n if (data[key]?.items) {\n const flattenedResult = data[key]?.items.map((value) => flattenItems(modelIntrospection, name, value));\n /**\n * Check exists since `flattenedResult` could be `null`.\n * if `flattenedResult` exists, result is an actual record.\n */\n if (flattenedResult) {\n return {\n data: args?.selectionSet\n ? flattenedResult\n : modelInitializer(flattenedResult),\n nextToken: data[key]?.nextToken,\n };\n }\n }\n // response is of type `data: { listByExampleId: null }`\n return {\n data: data[key],\n nextToken: data[key]?.nextToken,\n };\n }\n else {\n // `data` is `null` or an empty object:\n return handleListGraphQlError(error);\n }\n }\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,GAAG,KAAK,EAAE;AAC/G,IAAI,MAAM,qBAAqB,GAAG,OAAO,WAAW,EAAE,IAAI,EAAE,OAAO,KAAK;AACxE,QAAQ,OAAO,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE;AACvF,YAAY,GAAG,IAAI;AACnB,YAAY,GAAG,OAAO;AACtB,SAAS,EAAE,WAAW,CAAC,CAAC;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,UAAU,GAAG,OAAO,IAAI,EAAE,OAAO,KAAK;AAChD,QAAQ,OAAO,WAAW,CAA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B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;AACvC;AACA,QAAQ,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,EAAE;AAC5E,YAAY,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE;AAClC,gBAAgB,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,YAAY,CAAC,kBAAkB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACvH;AACA;AACA;AACA;AACA,gBAAgB,IAAI,eAAe,EAAE;AACrC,oBAAoB,OAAO;AAC3B,wBAAwB,IAAI,EAAE,IAAI,EAAE,YAAY;AAChD,8BAA8B,eAAe;AAC7C,8BAA8B,gBAAgB,CAAC,eAAe,CAAC;AAC/D,wBAAwB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AACvD,qBAAqB,CAAC;AACtB,iBAAiB;AACjB,aAAa;AACb;AACA,YAAY,OAAO;AACnB,gBAAgB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAC/B,gBAAgB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AAC/C,aAAa,CAAC;AACd,SAAS;AACT,aAAa;AACb;AACA,YAAY,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACjD,SAAS;AACT,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"indexQuery.mjs","sources":["../../../../../src/runtime/internals/operations/indexQuery.ts"],"sourcesContent":["import { authModeParams, buildGraphQLVariables, flattenItems, generateGraphQLDocument, getCustomHeaders, initializeModel, } from '../APIClient';\nimport { handleListGraphQlError } from './utils';\nimport { selfAwareAsync } from '../../utils';\nimport { extendCancellability } from '../cancellation';\nexport function indexQueryFactory(client, modelIntrospection, model, indexMeta, getInternals, context = false) {\n const indexQueryWithContext = (contextSpec, args, options) => {\n return _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, {\n ...args,\n ...options,\n }, contextSpec);\n };\n const indexQuery = (args, options) => {\n return _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, {\n ...args,\n ...options,\n });\n };\n return context ? indexQueryWithContext : indexQuery;\n}\nfunction processGraphQlResponse(modelIntroSchema, modelName, result, selectionSet, modelInitializer) {\n const { data, extensions } = result;\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = data[key].items.map((value) => flattenItems(modelIntroSchema, modelName, value));\n return {\n data: selectionSet ? flattenedResult : modelInitializer(flattenedResult),\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n // Index queries are always list queries. No `items`? No flattening needed.\n return {\n data: data[key],\n nextToken: data[key].nextToken,\n extensions,\n };\n}\nfunction _indexQuery(client, modelIntrospection, model, indexMeta, getInternals, args, contextSpec) {\n return selfAwareAsync(async (resultPromise) => {\n const { name } = model;\n const query = generateGraphQLDocument(modelIntrospection, name, 'INDEX_QUERY', args, indexMeta);\n const variables = buildGraphQLVariables(model, 'INDEX_QUERY', args, modelIntrospection, indexMeta);\n const auth = authModeParams(client, getInternals, args);\n const modelInitializer = (flattenedResult) => initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n try {\n const headers = getCustomHeaders(client, getInternals, args?.headers);\n const graphQlParams = {\n ...auth,\n query,\n variables,\n };\n const requestArgs = [graphQlParams, headers];\n if (contextSpec !== undefined) {\n requestArgs.unshift(contextSpec);\n }\n const basePromise = client.graphql(...requestArgs);\n const extendedPromise = extendCancellability(basePromise, resultPromise);\n const response = await extendedPromise;\n if (response.data !== undefined) {\n return processGraphQlResponse(modelIntrospection, name, response, args?.selectionSet, modelInitializer);\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:\n * `data: { listByExampleId: null }`\n * 4) an actual record:\n * `data: { listByExampleId: items: [{ id: '1', ...etc } }]`\n */\n const { data, errors } = error;\n // `data` is not `null`, and is not an empty object:\n if (data !== undefined && Object.keys(data).length !== 0 && errors) {\n const [key] = Object.keys(data);\n if (data[key]?.items) {\n const flattenedResult = data[key]?.items.map((value) => flattenItems(modelIntrospection, name, value));\n /**\n * Check exists since `flattenedResult` could be `null`.\n * if `flattenedResult` exists, result is an actual record.\n */\n if (flattenedResult) {\n return {\n data: args?.selectionSet\n ? flattenedResult\n : modelInitializer(flattenedResult),\n nextToken: data[key]?.nextToken,\n };\n }\n }\n // response is of type `data: { listByExampleId: null }`\n return {\n data: data[key],\n nextToken: data[key]?.nextToken,\n };\n }\n else {\n // `data` is `null` or an empty object:\n return handleListGraphQlError(error);\n }\n }\n });\n}\n"],"names":[],"mappings":";;;;;AAIO,SAAS,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,GAAG,KAAK,EAAE;AAC/G,IAAI,MAAM,qBAAqB,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,KAAK;AAClE,QAAQ,OAAO,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE;AACvF,YAAY,GAAG,IAAI;AACnB,YAAY,GAAG,OAAO;AACtB,SAAS,EAAE,WAAW,CAAC,CAAC;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK;AAC1C,QAAQ,OAAO,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE;AACvF,YAAY,GAAG,IAAI;AACnB,YAAY,G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1
1
  import { AmplifyServer, BaseClient, ClientInternalsGetter, ListArgs, ModelIntrospectionSchema, SchemaModel } from '../../bridge-types';
2
- export declare function listFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, model: SchemaModel, getInternals: ClientInternalsGetter, context?: boolean): ((contextSpec: AmplifyServer.ContextSpec, args?: ListArgs) => Promise<any>) | ((args?: Record<string, any>) => Promise<any>);
2
+ export declare function listFactory(client: BaseClient, modelIntrospection: ModelIntrospectionSchema, model: SchemaModel, getInternals: ClientInternalsGetter, context?: boolean): ((contextSpec: AmplifyServer.ContextSpec, args?: ListArgs) => Promise<unknown>) | ((args?: Record<string, any>) => Promise<unknown>);
@@ -1,118 +1,124 @@
1
1
  import { generateGraphQLDocument, buildGraphQLVariables, authModeParams, getCustomHeaders, flattenItems, initializeModel } from '../APIClient.mjs';
2
2
  import { handleListGraphQlError } from './utils.mjs';
3
+ import { selfAwareAsync } from '../../utils/selfAwareAsync.mjs';
4
+ import { extendCancellability } from '../cancellation.mjs';
3
5
 
4
6
  function listFactory(client, modelIntrospection, model, getInternals, context = false) {
5
- const listWithContext = async (contextSpec, args) => {
7
+ const listWithContext = (contextSpec, args) => {
6
8
  return _list(client, modelIntrospection, model, getInternals, args, contextSpec);
7
9
  };
8
- const list = async (args) => {
10
+ const list = (args) => {
9
11
  return _list(client, modelIntrospection, model, getInternals, args);
10
12
  };
11
13
  return context ? listWithContext : list;
12
14
  }
13
- async function _list(client, modelIntrospection, model, getInternals, args, contextSpec) {
14
- const { name } = model;
15
- const query = generateGraphQLDocument(modelIntrospection, name, 'LIST', args);
16
- const variables = buildGraphQLVariables(model, 'LIST', args, modelIntrospection);
17
- const auth = authModeParams(client, getInternals, args);
18
- try {
19
- const headers = getCustomHeaders(client, getInternals, args?.headers);
20
- const { data, extensions } = contextSpec
21
- ? (await client.graphql(contextSpec, {
22
- ...auth,
23
- query,
24
- variables,
25
- }, headers))
26
- : (await client.graphql({
27
- ...auth,
28
- query,
29
- variables,
30
- }, headers));
31
- // flatten response
32
- if (data !== undefined) {
33
- const [key] = Object.keys(data);
34
- if (data[key].items) {
35
- const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));
36
- // don't init if custom selection set
37
- if (args?.selectionSet) {
38
- return {
39
- data: flattenedResult,
40
- nextToken: data[key].nextToken,
41
- extensions,
42
- };
43
- }
44
- else {
45
- const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);
46
- return {
47
- data: initialized,
48
- nextToken: data[key].nextToken,
49
- extensions,
50
- };
51
- }
52
- }
53
- return {
54
- data: data[key],
55
- nextToken: data[key].nextToken,
56
- extensions,
57
- };
58
- }
59
- }
60
- catch (error) {
61
- /**
62
- * The `data` type returned by `error` here could be:
63
- * 1) `null`
64
- * 2) an empty object
65
- * 3) "populated" but with a `null` value `data: { listPosts: null }`
66
- * 4) actual records `data: { listPosts: items: [{ id: '1', ...etc }] }`
67
- */
68
- const { data, errors } = error;
69
- // `data` is not `null`, and is not an empty object:
70
- if (data !== undefined &&
71
- data !== null &&
72
- Object.keys(data).length !== 0 &&
73
- errors) {
74
- const [key] = Object.keys(data);
75
- if (data[key]?.items) {
76
- const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));
77
- /**
78
- * Check exists since `flattenedResult` could be `null`.
79
- * if `flattenedResult` exists, result is an actual record.
80
- */
81
- if (flattenedResult) {
15
+ function _list(client, modelIntrospection, model, getInternals, args, contextSpec) {
16
+ return selfAwareAsync(async (resultPromise) => {
17
+ const { name } = model;
18
+ const query = generateGraphQLDocument(modelIntrospection, name, 'LIST', args);
19
+ const variables = buildGraphQLVariables(model, 'LIST', args, modelIntrospection);
20
+ const auth = authModeParams(client, getInternals, args);
21
+ try {
22
+ const headers = getCustomHeaders(client, getInternals, args?.headers);
23
+ const basePromise = contextSpec
24
+ ? client.graphql(contextSpec, {
25
+ ...auth,
26
+ query,
27
+ variables,
28
+ }, headers)
29
+ : client.graphql({
30
+ ...auth,
31
+ query,
32
+ variables,
33
+ }, headers);
34
+ const extendedPromise = extendCancellability(basePromise, resultPromise);
35
+ const { data, extensions } = await extendedPromise;
36
+ // flatten response
37
+ if (data !== undefined) {
38
+ const [key] = Object.keys(data);
39
+ if (data[key].items) {
40
+ const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));
82
41
  // don't init if custom selection set
83
42
  if (args?.selectionSet) {
84
43
  return {
85
44
  data: flattenedResult,
86
- nextToken: data[key]?.nextToken,
87
- errors,
45
+ nextToken: data[key].nextToken,
46
+ extensions,
88
47
  };
89
48
  }
90
49
  else {
91
50
  const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);
92
- // data is full record w/out selection set:
93
51
  return {
94
52
  data: initialized,
95
- nextToken: data[key]?.nextToken,
96
- errors,
53
+ nextToken: data[key].nextToken,
54
+ extensions,
97
55
  };
98
56
  }
99
57
  }
100
58
  return {
101
59
  data: data[key],
102
- nextToken: data[key]?.nextToken,
103
- errors,
60
+ nextToken: data[key].nextToken,
61
+ extensions,
104
62
  };
105
63
  }
64
+ }
65
+ catch (error) {
66
+ /**
67
+ * The `data` type returned by `error` here could be:
68
+ * 1) `null`
69
+ * 2) an empty object
70
+ * 3) "populated" but with a `null` value `data: { listPosts: null }`
71
+ * 4) actual records `data: { listPosts: items: [{ id: '1', ...etc }] }`
72
+ */
73
+ const { data, errors } = error;
74
+ // `data` is not `null`, and is not an empty object:
75
+ if (data !== undefined &&
76
+ data !== null &&
77
+ Object.keys(data).length !== 0 &&
78
+ errors) {
79
+ const [key] = Object.keys(data);
80
+ if (data[key]?.items) {
81
+ const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));
82
+ /**
83
+ * Check exists since `flattenedResult` could be `null`.
84
+ * if `flattenedResult` exists, result is an actual record.
85
+ */
86
+ if (flattenedResult) {
87
+ // don't init if custom selection set
88
+ if (args?.selectionSet) {
89
+ return {
90
+ data: flattenedResult,
91
+ nextToken: data[key]?.nextToken,
92
+ errors,
93
+ };
94
+ }
95
+ else {
96
+ const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);
97
+ // data is full record w/out selection set:
98
+ return {
99
+ data: initialized,
100
+ nextToken: data[key]?.nextToken,
101
+ errors,
102
+ };
103
+ }
104
+ }
105
+ return {
106
+ data: data[key],
107
+ nextToken: data[key]?.nextToken,
108
+ errors,
109
+ };
110
+ }
111
+ else {
112
+ // response is of type `data: { getPost: null }`)
113
+ return handleListGraphQlError(error);
114
+ }
115
+ }
106
116
  else {
107
- // response is of type `data: { getPost: null }`)
117
+ // `data` is `null` or an empty object:
108
118
  return handleListGraphQlError(error);
109
119
  }
110
120
  }
111
- else {
112
- // `data` is `null` or an empty object:
113
- return handleListGraphQlError(error);
114
- }
115
- }
121
+ });
116
122
  }
117
123
 
118
124
  export { listFactory };
@@ -1 +1 @@
1
- {"version":3,"file":"list.mjs","sources":["../../../../../src/runtime/internals/operations/list.ts"],"sourcesContent":["import { authModeParams, buildGraphQLVariables, flattenItems, generateGraphQLDocument, getCustomHeaders, initializeModel, } from '../APIClient';\nimport { handleListGraphQlError } from './utils';\nexport function listFactory(client, modelIntrospection, model, getInternals, context = false) {\n const listWithContext = async (contextSpec, args) => {\n return _list(client, modelIntrospection, model, getInternals, args, contextSpec);\n };\n const list = async (args) => {\n return _list(client, modelIntrospection, model, getInternals, args);\n };\n return context ? listWithContext : list;\n}\nasync function _list(client, modelIntrospection, model, getInternals, args, contextSpec) {\n const { name } = model;\n const query = generateGraphQLDocument(modelIntrospection, name, 'LIST', args);\n const variables = buildGraphQLVariables(model, 'LIST', args, modelIntrospection);\n const auth = authModeParams(client, getInternals, args);\n try {\n const headers = getCustomHeaders(client, getInternals, args?.headers);\n const { data, extensions } = contextSpec\n ? (await client.graphql(contextSpec, {\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 !== undefined) {\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n else {\n const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n return {\n data: initialized,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key].nextToken,\n extensions,\n };\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 `data: { listPosts: null }`\n * 4) actual records `data: { listPosts: items: [{ id: '1', ...etc }] }`\n */\n const { data, errors } = error;\n // `data` is not `null`, and is not an empty object:\n if (data !== undefined &&\n data !== null &&\n Object.keys(data).length !== 0 &&\n errors) {\n const [key] = Object.keys(data);\n if (data[key]?.items) {\n const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));\n /**\n * Check exists since `flattenedResult` could be `null`.\n * if `flattenedResult` exists, result is an actual record.\n */\n if (flattenedResult) {\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n // data is full record w/out selection set:\n return {\n data: initialized,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n // response is of type `data: { getPost: null }`)\n return handleListGraphQlError(error);\n }\n }\n else {\n // `data` is `null` or an empty object:\n return handleListGraphQlError(error);\n }\n }\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,GAAG,KAAK,EAAE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SAAS;AAC3D,4BAA4B,MAAM;AAClC,yBAAyB,CAAC;AAC1B,qBAAqB;AACrB,iBAAiB;AACjB,gBAAgB,OAAO;AACvB,oBAAoB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AACnC,oBAAoB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AACnD,oBAAoB,MAAM;AAC1B,iBAAiB,CAAC;AAClB,aAAa;AACb,iBAAiB;AACjB;AACA,gBAAgB,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACrD,aAAa;AACb,SAAS;AACT,aAAa;AACb;AACA,YAAY,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACjD,SAAS;AACT,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"list.mjs","sources":["../../../../../src/runtime/internals/operations/list.ts"],"sourcesContent":["import { authModeParams, buildGraphQLVariables, flattenItems, generateGraphQLDocument, getCustomHeaders, initializeModel, } from '../APIClient';\nimport { handleListGraphQlError } from './utils';\nimport { selfAwareAsync } from '../../utils';\nimport { extendCancellability } from '../cancellation';\nexport function listFactory(client, modelIntrospection, model, getInternals, context = false) {\n const listWithContext = (contextSpec, args) => {\n return _list(client, modelIntrospection, model, getInternals, args, contextSpec);\n };\n const list = (args) => {\n return _list(client, modelIntrospection, model, getInternals, args);\n };\n return context ? listWithContext : list;\n}\nfunction _list(client, modelIntrospection, model, getInternals, args, contextSpec) {\n return selfAwareAsync(async (resultPromise) => {\n const { name } = model;\n const query = generateGraphQLDocument(modelIntrospection, name, 'LIST', args);\n const variables = buildGraphQLVariables(model, 'LIST', args, modelIntrospection);\n const auth = authModeParams(client, getInternals, args);\n try {\n const headers = getCustomHeaders(client, getInternals, args?.headers);\n const basePromise = contextSpec\n ? client.graphql(contextSpec, {\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 !== undefined) {\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n else {\n const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n return {\n data: initialized,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key].nextToken,\n extensions,\n };\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 `data: { listPosts: null }`\n * 4) actual records `data: { listPosts: items: [{ id: '1', ...etc }] }`\n */\n const { data, errors } = error;\n // `data` is not `null`, and is not an empty object:\n if (data !== undefined &&\n data !== null &&\n Object.keys(data).length !== 0 &&\n errors) {\n const [key] = Object.keys(data);\n if (data[key]?.items) {\n const flattenedResult = data[key].items.map((value) => flattenItems(modelIntrospection, name, value));\n /**\n * Check exists since `flattenedResult` could be `null`.\n * if `flattenedResult` exists, result is an actual record.\n */\n if (flattenedResult) {\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n // data is full record w/out selection set:\n return {\n data: initialized,\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key]?.nextToken,\n errors,\n };\n }\n else {\n // response is of type `data: { getPost: null }`)\n return handleListGraphQlError(error);\n }\n }\n else {\n // `data` is `null` or an empty object:\n return handleListGraphQlError(error);\n }\n }\n });\n}\n"],"names":[],"mappings":";;;;;AAIO,SAAS,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,GAA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EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;AACjK;AACA,4BAA4B,OAAO;AACnC,gCAAgC,IAAI,EAAE,WAAW;AACjD,gCAAgC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AAC/D,gCAAgC,MAAM;AACtC,6BAA6B,CAAC;AAC9B,yBAAyB;AACzB,qBAAqB;AACrB,oBAAoB,OAAO;AAC3B,wBAAwB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AACvC,wBAAwB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS;AACvD,wBAAwB,MAAM;AAC9B,qBAAqB,CAAC;AACtB,iBAAiB;AACjB,qBAAqB;AACrB;AACA,oBAAoB,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACzD,iBAAiB;AACjB,aAAa;AACb,iBAAiB;AACjB;AACA,gBAAgB,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACrD,aAAa;AACb,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -1,8 +1,7 @@
1
- import { graphQLOperationsInfo } from '../APIClient.mjs';
2
1
  import { listFactory } from '../operations/list.mjs';
3
2
  import { indexQueryFactory } from '../operations/indexQuery.mjs';
4
3
  import { getFactory } from '../operations/get.mjs';
5
- import { getSecondaryIndexesFromSchemaModel } from '../clientUtils.mjs';
4
+ import { excludeDisabledOps, getSecondaryIndexesFromSchemaModel } from '../clientUtils.mjs';
6
5
 
7
6
  function generateModelsProperty(client, params, getInternals) {
8
7
  const models = {};
@@ -22,12 +21,13 @@ function generateModelsProperty(client, params, getInternals) {
22
21
  'ONCREATE',
23
22
  'ONUPDATE',
24
23
  'ONDELETE',
25
- 'OBSERVE_QUERY',
24
+ 'OBSERVEQUERY',
26
25
  ];
27
26
  for (const model of Object.values(modelIntrospection.models)) {
28
27
  const { name } = model;
29
28
  models[name] = {};
30
- Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {
29
+ const enabledModelOps = excludeDisabledOps(modelIntrospection, name);
30
+ Object.entries(enabledModelOps).forEach(([key, { operationPrefix }]) => {
31
31
  const operation = key;
32
32
  // subscriptions are not supported in SSR
33
33
  if (SSR_UNSUPORTED_OPS.includes(operation))
@@ -1 +1 @@
1
- {"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../../src/runtime/internals/server/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from '../APIClient';\nimport { listFactory } from '../operations/list';\nimport { indexQueryFactory } from '../operations/indexQuery';\nimport { getFactory } from '../operations/get';\nimport { getSecondaryIndexesFromSchemaModel } from '../clientUtils';\nexport function generateModelsProperty(client, params, getInternals) {\n const models = {};\n const { config } = params;\n const useContext = params.amplify === null;\n if (!config) {\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\n }\n if (!config.API?.GraphQL) {\n return {};\n }\n const modelIntrospection = config.API.GraphQL.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SSR_UNSUPORTED_OPS = [\n 'ONCREATE',\n 'ONUPDATE',\n 'ONDELETE',\n 'OBSERVE_QUERY',\n ];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n // subscriptions are not supported in SSR\n if (SSR_UNSUPORTED_OPS.includes(operation))\n return;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model, getInternals, useContext);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, getInternals, useContext);\n }\n });\n const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx, getInternals, useContext);\n }\n }\n return models;\n}\n"],"names":[],"mappings":";;;;;;AAKO,SAAS,sBAAsB,CAAC,M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AC,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AACzH,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AACnI,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,kCAAkC,CAAC,KAAK,CAAC,CAAC;AACxE,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAC/H,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
1
+ {"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../../src/runtime/internals/server/generateModelsProperty.ts"],"sourcesContent":["import { listFactory } from '../operations/list';\nimport { indexQueryFactory } from '../operations/indexQuery';\nimport { getFactory } from '../operations/get';\nimport { getSecondaryIndexesFromSchemaModel, excludeDisabledOps, } from '../clientUtils';\nexport function generateModelsProperty(client, params, getInternals) {\n const models = {};\n const { config } = params;\n const useContext = params.amplify === null;\n if (!config) {\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\n }\n if (!config.API?.GraphQL) {\n return {};\n }\n const modelIntrospection = config.API.GraphQL.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SSR_UNSUPORTED_OPS = [\n 'ONCREATE',\n 'ONUPDATE',\n 'ONDELETE',\n 'OBSERVEQUERY',\n ];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n const enabledModelOps = excludeDisabledOps(modelIntrospection, name);\n Object.entries(enabledModelOps).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n // subscriptions are not supported in SSR\n if (SSR_UNSUPORTED_OPS.includes(operation))\n return;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model, getInternals, useContext);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, getInternals, useContext);\n }\n });\n const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx, getInternals, useContext);\n }\n }\n return models;\n}\n"],"names":[],"mappings":";;;;;AAIO,SAAS,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE;AACrE,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;AAC9B,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC;AAC/C,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE;AAC9B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC;AACrE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,UAAU;AAClB,QAAQ,UAAU;AAClB,QAAQ,UAAU;AAClB,QAAQ,cAAc;AACtB,KAAK,CAAC;AACN,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM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sInfo } from '../../APIClient.mjs';
2
1
  import { listFactory } from '../../operations/list.mjs';
3
2
  import { indexQueryFactory } from '../../operations/indexQuery.mjs';
4
3
  import { getFactory } from '../../operations/get.mjs';
5
4
  import { subscriptionFactory } from '../../operations/subscription.mjs';
6
5
  import { observeQueryFactory } from '../../operations/observeQuery.mjs';
7
- import { getSecondaryIndexesFromSchemaModel } from '../../clientUtils.mjs';
6
+ import { excludeDisabledOps, getSecondaryIndexesFromSchemaModel } from '../../clientUtils.mjs';
8
7
 
9
8
  function generateModelsProperty(client, apiGraphQLConfig, getInternals) {
10
9
  const models = {};
@@ -16,7 +15,8 @@ function generateModelsProperty(client, apiGraphQLConfig, getInternals) {
16
15
  for (const model of Object.values(modelIntrospection.models)) {
17
16
  const { name } = model;
18
17
  models[name] = {};
19
- Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {
18
+ const enabledModelOps = excludeDisabledOps(modelIntrospection, name);
19
+ Object.entries(enabledModelOps).forEach(([key, { operationPrefix }]) => {
20
20
  const operation = key;
21
21
  if (operation === 'LIST') {
22
22
  models[name][operationPrefix] = listFactory(client, modelIntrospection, model, getInternals);
@@ -24,7 +24,7 @@ function generateModelsProperty(client, apiGraphQLConfig, getInternals) {
24
24
  else if (SUBSCRIPTION_OPS.includes(operation)) {
25
25
  models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation, getInternals);
26
26
  }
27
- else if (operation === 'OBSERVE_QUERY') {
27
+ else if (operation === 'OBSERVEQUERY') {
28
28
  models[name][operationPrefix] = observeQueryFactory(models, model);
29
29
  }
30
30
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from '../../APIClient';\nimport { listFactory } from '../../operations/list';\nimport { indexQueryFactory } from '../../operations/indexQuery';\nimport { getFactory } from '../../operations/get';\nimport { subscriptionFactory } from '../../operations/subscription';\nimport { observeQueryFactory } from '../../operations/observeQuery';\nimport { getSecondaryIndexesFromSchemaModel } from '../../clientUtils';\nexport function generateModelsProperty(client, apiGraphQLConfig, getInternals) {\n const models = {};\n const modelIntrospection = apiGraphQLConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model, getInternals);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation, getInternals);\n }\n else if (operation === 'OBSERVE_QUERY') {\n models[name][operationPrefix] = observeQueryFactory(models, model);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, getInternals);\n }\n });\n const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx, getInternals);\n }\n }\n return models;\n}\n"],"names":[],"mappings":";;;;;;;;AAOO,SAAS,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC/E,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC;AACnE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAClE,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;AAClE,QAAQ,MAAM,EAAE,IA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B,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;AACnH,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
1
+ {"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateModelsProperty.ts"],"sourcesContent":["import { listFactory } from '../../operations/list';\nimport { indexQueryFactory } from '../../operations/indexQuery';\nimport { getFactory } from '../../operations/get';\nimport { subscriptionFactory } from '../../operations/subscription';\nimport { observeQueryFactory } from '../../operations/observeQuery';\nimport { getSecondaryIndexesFromSchemaModel, excludeDisabledOps, } from '../../clientUtils';\nexport function generateModelsProperty(client, apiGraphQLConfig, getInternals) {\n const models = {};\n const modelIntrospection = apiGraphQLConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n const enabledModelOps = excludeDisabledOps(modelIntrospection, name);\n Object.entries(enabledModelOps).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model, getInternals);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation, getInternals);\n }\n else if (operation === 'OBSERVEQUERY') {\n models[name][operationPrefix] = observeQueryFactory(models, model);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, getInternals);\n }\n });\n const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx, getInternals);\n }\n }\n return models;\n}\n"],"names":[],"mappings":";;;;;;;AAMO,SAAS,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AAC/E,IAAI,MAAM,MAAM,GAAG,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,CAAC,CAAC;AACnF,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AACvH,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,kCAAkC,CAAC,KAAK,CAAC,CAAC;AACxE,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;AACnH,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -2,3 +2,4 @@ export { resolvePKFields } from './resolvePKFields';
2
2
  export { findIndexByFields } from './findIndexByFields';
3
3
  export { resolveOwnerFields } from './resolveOwnerFields';
4
4
  export { capitalize } from './stringTransformation';
5
+ export { selfAwareAsync } from './selfAwareAsync';
@@ -2,4 +2,5 @@ export { resolvePKFields } from './resolvePKFields.mjs';
2
2
  export { findIndexByFields } from './findIndexByFields.mjs';
3
3
  export { resolveOwnerFields } from './resolveOwnerFields.mjs';
4
4
  export { capitalize } from './stringTransformation.mjs';
5
+ export { selfAwareAsync } from './selfAwareAsync.mjs';
5
6
  //# 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":";;;;"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Executes an `async` resolver function, providing the `Promise`-to-be-returned as the
3
+ * first argument to the resolver so that the resolver can refer to the `Promise` that
4
+ * external callers will see.
5
+ *
6
+ * ```ts
7
+ * const outer = selfAwareAsync(async inner => {
8
+ * console.log(outer === inner); // true
9
+ * });
10
+ * ```
11
+ *
12
+ * This utility exists to reduce boilerplate in cases where promise resolving code needs
13
+ * to track or register its "own" `Promise` *as seen by the caller* in some way. E.g.,
14
+ * when mapping `Promise` chains for `client.cancel()`.
15
+ *
16
+ * @param resolver
17
+ * @returns
18
+ */
19
+ export declare function selfAwareAsync<T>(resolver: (promise: Promise<T>) => Promise<T>): Promise<T>;