@aws-amplify/data-schema 1.2.3 → 1.2.4
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.
- package/dist/cjs/runtime/internals/APIClient.js +85 -15
- package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/custom.js +10 -2
- package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/get.js +2 -2
- package/dist/cjs/runtime/internals/operations/get.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/indexQuery.js +5 -4
- package/dist/cjs/runtime/internals/operations/indexQuery.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/list.js +2 -2
- package/dist/cjs/runtime/internals/operations/list.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/subscription.js +1 -0
- package/dist/cjs/runtime/internals/operations/subscription.js.map +1 -1
- package/dist/esm/runtime/internals/APIClient.d.ts +41 -3
- package/dist/esm/runtime/internals/APIClient.mjs +85 -15
- package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/custom.mjs +11 -3
- package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/get.mjs +2 -2
- package/dist/esm/runtime/internals/operations/get.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/indexQuery.mjs +5 -4
- package/dist/esm/runtime/internals/operations/indexQuery.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/list.mjs +2 -2
- package/dist/esm/runtime/internals/operations/list.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/subscription.mjs +1 -0
- package/dist/esm/runtime/internals/operations/subscription.mjs.map +1 -1
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/runtime/internals/APIClient.ts +107 -21
- package/src/runtime/internals/operations/custom.ts +12 -3
- package/src/runtime/internals/operations/get.ts +2 -2
- package/src/runtime/internals/operations/indexQuery.ts +12 -2
- package/src/runtime/internals/operations/list.ts +8 -2
- package/src/runtime/internals/operations/subscription.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sources":["../../../../../src/runtime/internals/operations/get.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nfunction getFactory(client, modelIntrospection, model, operation, getInternals, useContext = false) {\n const getWithContext = async (contextSpec, arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals, contextSpec);\n };\n const get = async (arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals);\n };\n return useContext ? getWithContext : get;\n}\nexports.getFactory = getFactory;\nasync function _get(client, modelIntrospection, model, arg, options, operation, getInternals, context) {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, operation, options);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, operation, arg, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n try {\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\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 flattenedResult = (0, APIClient_1.flattenItems)(data
|
|
1
|
+
{"version":3,"file":"get.js","sources":["../../../../../src/runtime/internals/operations/get.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nfunction getFactory(client, modelIntrospection, model, operation, getInternals, useContext = false) {\n const getWithContext = async (contextSpec, arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals, contextSpec);\n };\n const get = async (arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, getInternals);\n };\n return useContext ? getWithContext : get;\n}\nexports.getFactory = getFactory;\nasync function _get(client, modelIntrospection, model, arg, options, operation, getInternals, context) {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, operation, options);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, operation, arg, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, options);\n try {\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, options?.headers);\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 flattenedResult = (0, APIClient_1.flattenItems)(modelIntrospection, name, data[key]);\n if (flattenedResult === null) {\n return { data: null, extensions };\n }\n else if (options?.selectionSet) {\n return { data: flattenedResult, extensions };\n }\n else {\n // TODO: refactor to avoid destructuring here\n const [initialized] = (0, APIClient_1.initializeModel)(client, name, [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context);\n return { data: initialized, 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 flattenedResult = (0, APIClient_1.flattenItems)(modelIntrospection, name, 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 if (options?.selectionSet) {\n return { data: flattenedResult, errors };\n }\n else {\n // TODO: refactor to avoid destructuring here\n const [initialized] = (0, APIClient_1.initializeModel)(client, name, [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context);\n return { data: initialized, errors };\n }\n }\n else {\n // was `data: { getPost: null }`)\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n else {\n // `data` is `null`:\n return (0, utils_1.handleSingularGraphQlError)(error);\n }\n }\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,SAAS,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,GAAG,KAAK,EAAE;AACpG,IAAI,MAAM,cAAc,GAAG,OAAO,WAAW,EAAE,GAAG,EAAE,OAAO,KAAK;AAChE,QAAQ,OAAO,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAC3G,KAAK,CAAC;AACN,IAAI,MAAM,GAAG,GAAG,OAAO,GAAG,EAAE,OAAO,KAAK;AACxC,QAAQ,OAAO,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9F,KAAK,CAAC;AACN,IAAI,OAAO,UAAU,GAAG,cAAc,GAAG,GAAG,CAAC;AAC7C,CAAC;AACD,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;AAChC,eAAe,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE;AACvG,IAA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,CAAC;AAC7D,iBAAiB;AACjB,qBAAqB;AACrB;AACA,oBAAoB,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AAC1K,oBAAoB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACzD,iBAAiB;AACjB,aAAa;AACb,iBAAiB;AACjB;AACA,gBAAgB,OAAO,IAAI,OAAO,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;AACtE,aAAa;AACb,SAAS;AACT,aAAa;AACb;AACA,YAAY,OAAO,IAAI,OAAO,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;AAClE,SAAS;AACT,KAAK;AACL;;"}
|
|
@@ -20,17 +20,18 @@ function indexQueryFactory(client, modelIntrospection, model, indexMeta, getInte
|
|
|
20
20
|
return context ? indexQueryWithContext : indexQuery;
|
|
21
21
|
}
|
|
22
22
|
exports.indexQueryFactory = indexQueryFactory;
|
|
23
|
-
function processGraphQlResponse(result, selectionSet, modelInitializer) {
|
|
23
|
+
function processGraphQlResponse(modelIntroSchema, modelName, result, selectionSet, modelInitializer) {
|
|
24
24
|
const { data, extensions } = result;
|
|
25
25
|
const [key] = Object.keys(data);
|
|
26
26
|
if (data[key].items) {
|
|
27
|
-
const flattenedResult = (0, APIClient_1.flattenItems)(
|
|
27
|
+
const flattenedResult = data[key].items.map((value) => (0, APIClient_1.flattenItems)(modelIntroSchema, modelName, value));
|
|
28
28
|
return {
|
|
29
29
|
data: selectionSet ? flattenedResult : modelInitializer(flattenedResult),
|
|
30
30
|
nextToken: data[key].nextToken,
|
|
31
31
|
extensions,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
// Index queries are always list queries. No `items`? No flattening needed.
|
|
34
35
|
return {
|
|
35
36
|
data: data[key],
|
|
36
37
|
nextToken: data[key].nextToken,
|
|
@@ -56,7 +57,7 @@ async function _indexQuery(client, modelIntrospection, model, indexMeta, getInte
|
|
|
56
57
|
}
|
|
57
58
|
const response = (await client.graphql(...requestArgs));
|
|
58
59
|
if (response.data !== undefined) {
|
|
59
|
-
return processGraphQlResponse(response, args?.selectionSet, modelInitializer);
|
|
60
|
+
return processGraphQlResponse(modelIntrospection, name, response, args?.selectionSet, modelInitializer);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
catch (error) {
|
|
@@ -74,7 +75,7 @@ async function _indexQuery(client, modelIntrospection, model, indexMeta, getInte
|
|
|
74
75
|
if (data !== undefined && Object.keys(data).length !== 0 && errors) {
|
|
75
76
|
const [key] = Object.keys(data);
|
|
76
77
|
if (data[key]?.items) {
|
|
77
|
-
const flattenedResult = (0, APIClient_1.flattenItems)(
|
|
78
|
+
const flattenedResult = data[key]?.items.map((value) => (0, APIClient_1.flattenItems)(modelIntrospection, name, value));
|
|
78
79
|
/**
|
|
79
80
|
* Check exists since `flattenedResult` could be `null`.
|
|
80
81
|
* if `flattenedResult` exists, result is an actual record.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexQuery.js","sources":["../../../../../src/runtime/internals/operations/indexQuery.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.indexQueryFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nfunction 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}\nexports.indexQueryFactory = indexQueryFactory;\nfunction processGraphQlResponse(result, selectionSet, modelInitializer) {\n const { data, extensions } = result;\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = (0, APIClient_1.flattenItems)(
|
|
1
|
+
{"version":3,"file":"indexQuery.js","sources":["../../../../../src/runtime/internals/operations/indexQuery.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.indexQueryFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nfunction 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}\nexports.indexQueryFactory = indexQueryFactory;\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) => (0, APIClient_1.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 = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'INDEX_QUERY', args, indexMeta);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'INDEX_QUERY', args, modelIntrospection, indexMeta);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);\n const modelInitializer = (flattenedResult) => (0, APIClient_1.initializeModel)(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\n try {\n const headers = (0, APIClient_1.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) => (0, APIClient_1.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 (0, utils_1.handleListGraphQlError)(error);\n }\n }\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,CAAC;AACnC,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,SAAS,iBAAiB,CAAC,MAAM,EAAE,kBAA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O;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,IAAI,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;AAC9D,SAAS;AACT,KAAK;AACL;;"}
|
|
@@ -36,7 +36,7 @@ async function _list(client, modelIntrospection, model, getInternals, args, cont
|
|
|
36
36
|
if (data !== undefined) {
|
|
37
37
|
const [key] = Object.keys(data);
|
|
38
38
|
if (data[key].items) {
|
|
39
|
-
const flattenedResult = (0, APIClient_1.flattenItems)(
|
|
39
|
+
const flattenedResult = data[key].items.map((value) => (0, APIClient_1.flattenItems)(modelIntrospection, name, value));
|
|
40
40
|
// don't init if custom selection set
|
|
41
41
|
if (args?.selectionSet) {
|
|
42
42
|
return {
|
|
@@ -77,7 +77,7 @@ async function _list(client, modelIntrospection, model, getInternals, args, cont
|
|
|
77
77
|
errors) {
|
|
78
78
|
const [key] = Object.keys(data);
|
|
79
79
|
if (data[key]?.items) {
|
|
80
|
-
const flattenedResult = (0, APIClient_1.flattenItems)(
|
|
80
|
+
const flattenedResult = data[key].items.map((value) => (0, APIClient_1.flattenItems)(modelIntrospection, name, value));
|
|
81
81
|
/**
|
|
82
82
|
* Check exists since `flattenedResult` could be `null`.
|
|
83
83
|
* if `flattenedResult` exists, result is an actual record.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sources":["../../../../../src/runtime/internals/operations/list.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.listFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nfunction 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}\nexports.listFactory = listFactory;\nasync function _list(client, modelIntrospection, model, getInternals, args, contextSpec) {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'LIST', args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'LIST', args, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);\n try {\n const headers = (0, APIClient_1.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 = (0, APIClient_1.flattenItems)(
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../../src/runtime/internals/operations/list.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.listFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst utils_1 = require(\"./utils\");\nfunction 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}\nexports.listFactory = listFactory;\nasync function _list(client, modelIntrospection, model, getInternals, args, contextSpec) {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'LIST', args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'LIST', args, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);\n try {\n const headers = (0, APIClient_1.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) => (0, APIClient_1.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 = (0, APIClient_1.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) => (0, APIClient_1.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 = (0, APIClient_1.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 (0, utils_1.handleListGraphQlError)(error);\n }\n }\n else {\n // `data` is `null` or an empty object:\n return (0, utils_1.handleListGraphQlError)(error);\n }\n }\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,SAAS,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,GAAG,KAAK,EAAE;AACvF,IAAI,MAAM,eAAe,GAAG,OAAO,WAAW,EAAE,IAAI,KAAK;AACzD,QAAQ,OAAO,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACzF,KAAK,CAAC;AACN,IAAI,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK;AACjC,QAAQ,OAAO,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;AAC5E,KAAK,CAAC;AACN,IAAI,OAAO,OAAO,GAAG,eAAe,GAAG,IAAI,CAAC;AAC5C,CAAC;AACD,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;AAClC,eAAe,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE;AACzF,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;A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,YAAY,OAAO,IAAI,OAAO,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;AAC9D,SAAS;AACT,KAAK;AACL;;"}
|
|
@@ -20,6 +20,7 @@ function subscriptionFactory(client, modelIntrospection, model, operation, getIn
|
|
|
20
20
|
}, headers);
|
|
21
21
|
return observable.pipe((0, rxjs_1.map)((value) => {
|
|
22
22
|
const [key] = Object.keys(value.data);
|
|
23
|
+
// Will need flattening here if/when custom selection set support is added:
|
|
23
24
|
const data = value.data[key];
|
|
24
25
|
const [initialized] = (0, APIClient_1.initializeModel)(client, name, [data], modelIntrospection, auth.authMode, auth.authToken);
|
|
25
26
|
return initialized;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sources":["../../../../../src/runtime/internals/operations/subscription.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.subscriptionFactory = void 0;\nconst rxjs_1 = require(\"rxjs\");\nconst APIClient_1 = require(\"../APIClient\");\nfunction subscriptionFactory(client, modelIntrospection, model, operation, getInternals) {\n const { name } = model;\n const subscription = (args) => {\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, operation, args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, operation, args, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, args?.headers);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n const data = value.data[key];\n const [initialized] = (0, APIClient_1.initializeModel)(client, name, [data], modelIntrospection, auth.authMode, auth.authToken);\n return initialized;\n }));\n };\n return subscription;\n}\nexports.subscriptionFactory = subscriptionFactory;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAA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AClD,YAAY,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5I,YAAY,OAAO,WAAW,CAAC;AAC/B,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,YAAY,CAAC;AACxB,CAAC;AACD,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
|
|
1
|
+
{"version":3,"file":"subscription.js","sources":["../../../../../src/runtime/internals/operations/subscription.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.subscriptionFactory = void 0;\nconst rxjs_1 = require(\"rxjs\");\nconst APIClient_1 = require(\"../APIClient\");\nfunction subscriptionFactory(client, modelIntrospection, model, operation, getInternals) {\n const { name } = model;\n const subscription = (args) => {\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, operation, args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, operation, args, modelIntrospection);\n const auth = (0, APIClient_1.authModeParams)(client, getInternals, args);\n const headers = (0, APIClient_1.getCustomHeaders)(client, getInternals, args?.headers);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n }, headers);\n return observable.pipe((0, rxjs_1.map)((value) => {\n const [key] = Object.keys(value.data);\n // Will need flattening here if/when custom selection set support is added:\n const data = value.data[key];\n const [initialized] = (0, APIClient_1.initializeModel)(client, name, [data], modelIntrospection, auth.authMode, auth.authToken);\n return initialized;\n }));\n };\n return subscription;\n}\nexports.subscriptionFactory = subscriptionFactory;\n"],"names":[],"mappings":";;AACA;AACA;AACA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AC,IAAI,CAAC,CAAC;AAClD;AACA,YAAY,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5I,YAAY,OAAO,WAAW,CAAC;AAC/B,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,YAAY,CAAC;AACxB,CAAC;AACD,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
|
|
@@ -2,11 +2,49 @@ import { AuthModeParams, BaseClient, GraphQLAuthMode, ClientInternalsGetter, Lis
|
|
|
2
2
|
import { CustomHeaders } from '../client';
|
|
3
3
|
import type { IndexMeta } from './operations/indexQuery';
|
|
4
4
|
/**
|
|
5
|
+
* Crawls a model tree, starting with a given **individual** model instance record, looking
|
|
6
|
+
* for related hasMany children to extract from their `items` containers.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
+
* E.g., if we have a record like this:
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* {
|
|
12
|
+
* id: 'some-id',
|
|
13
|
+
* children: {
|
|
14
|
+
* items: [
|
|
15
|
+
* { name: 'a' }
|
|
16
|
+
* { name: 'b' }
|
|
17
|
+
* { name: 'c' }
|
|
18
|
+
* ]
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* And if `children` refers to *an array of another model* (as opposed to a custom type),
|
|
24
|
+
* the `items` will be extracted. We do this because `items` is just the mechanism for nesting
|
|
25
|
+
* child records -- we don't want customers to have to dig the items out in application code.
|
|
26
|
+
* Ultimately, we return this "flattened" structure:
|
|
27
|
+
*
|
|
28
|
+
* ```js
|
|
29
|
+
* {
|
|
30
|
+
* id: 'some-id',
|
|
31
|
+
* children: [
|
|
32
|
+
* { name: 'a' }
|
|
33
|
+
* { name: 'b' }
|
|
34
|
+
* { name: 'c' }
|
|
35
|
+
* ]
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Notably, an identical record could be the result of a nested custom type that contains an
|
|
40
|
+
* `items` property. This will *not* be flattened, because in that case the `items` property is
|
|
41
|
+
* actually part of the customer's schema. Similarly if a model contains an explicit `items` field.
|
|
42
|
+
*
|
|
43
|
+
* @param modelIntrospection Top-level model introspection schema.
|
|
44
|
+
* @param modelName The name of the model. Can be `undefined`. E.g., for customOperation return types.
|
|
45
|
+
* @param modelRecord The individual "model instance record" to normalize.
|
|
8
46
|
*/
|
|
9
|
-
export declare const flattenItems: (
|
|
47
|
+
export declare const flattenItems: (modelIntrospection: ModelIntrospectionSchema, modelName: string | undefined, modelRecord: Record<string, any>) => Record<string, any> | null;
|
|
10
48
|
export declare function initializeModel(client: BaseClient, modelName: string, result: any[], modelIntrospection: ModelIntrospectionSchema, authMode: GraphQLAuthMode | undefined, authToken: string | undefined, context?: boolean): any[];
|
|
11
49
|
export declare const graphQLOperationsInfo: {
|
|
12
50
|
readonly CREATE: {
|
|
@@ -41,25 +41,95 @@ const resolvedSkName = (sk) => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
+
* Crawls a model tree, starting with a given **individual** model instance record, looking
|
|
45
|
+
* for related hasMany children to extract from their `items` containers.
|
|
44
46
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
+
* E.g., if we have a record like this:
|
|
48
|
+
*
|
|
49
|
+
* ```js
|
|
50
|
+
* {
|
|
51
|
+
* id: 'some-id',
|
|
52
|
+
* children: {
|
|
53
|
+
* items: [
|
|
54
|
+
* { name: 'a' }
|
|
55
|
+
* { name: 'b' }
|
|
56
|
+
* { name: 'c' }
|
|
57
|
+
* ]
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* And if `children` refers to *an array of another model* (as opposed to a custom type),
|
|
63
|
+
* the `items` will be extracted. We do this because `items` is just the mechanism for nesting
|
|
64
|
+
* child records -- we don't want customers to have to dig the items out in application code.
|
|
65
|
+
* Ultimately, we return this "flattened" structure:
|
|
66
|
+
*
|
|
67
|
+
* ```js
|
|
68
|
+
* {
|
|
69
|
+
* id: 'some-id',
|
|
70
|
+
* children: [
|
|
71
|
+
* { name: 'a' }
|
|
72
|
+
* { name: 'b' }
|
|
73
|
+
* { name: 'c' }
|
|
74
|
+
* ]
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* Notably, an identical record could be the result of a nested custom type that contains an
|
|
79
|
+
* `items` property. This will *not* be flattened, because in that case the `items` property is
|
|
80
|
+
* actually part of the customer's schema. Similarly if a model contains an explicit `items` field.
|
|
81
|
+
*
|
|
82
|
+
* @param modelIntrospection Top-level model introspection schema.
|
|
83
|
+
* @param modelName The name of the model. Can be `undefined`. E.g., for customOperation return types.
|
|
84
|
+
* @param modelRecord The individual "model instance record" to normalize.
|
|
47
85
|
*/
|
|
48
|
-
const flattenItems = (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
const flattenItems = (modelIntrospection, modelName, modelRecord) => {
|
|
87
|
+
if (!modelRecord)
|
|
88
|
+
return null;
|
|
89
|
+
const mapped = {};
|
|
90
|
+
for (const [fieldName, value] of Object.entries(modelRecord)) {
|
|
91
|
+
const fieldDef = modelName
|
|
92
|
+
? modelIntrospection.models[modelName]?.fields[fieldName]
|
|
93
|
+
: undefined;
|
|
94
|
+
const dvPair = { fieldDef, value };
|
|
95
|
+
if (isRelatedModelItemsArrayPair(dvPair)) {
|
|
96
|
+
mapped[fieldName] = dvPair.value.items.map((itemValue) => flattenItems(modelIntrospection, dvPair.fieldDef.type.model, itemValue));
|
|
58
97
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
98
|
+
else if (isRelatedModelProperty(fieldDef)) {
|
|
99
|
+
mapped[fieldName] = flattenItems(modelIntrospection, fieldDef.type.model, value);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
mapped[fieldName] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return mapped;
|
|
62
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Determines whether the given field definition and associated result value
|
|
109
|
+
* represent a related model array from a HasMany-type relationship.
|
|
110
|
+
*
|
|
111
|
+
* @param dv Pair of field definition and associated result value
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
function isRelatedModelItemsArrayPair(dv) {
|
|
115
|
+
return (typeof dv.fieldDef?.type === 'object' &&
|
|
116
|
+
'model' in dv.fieldDef.type &&
|
|
117
|
+
typeof dv.fieldDef.type.model === 'string' &&
|
|
118
|
+
dv.fieldDef.isArray &&
|
|
119
|
+
Array.isArray(dv.value?.items));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Determines whether the given field definition represents a relationship
|
|
123
|
+
* to another model.
|
|
124
|
+
*
|
|
125
|
+
* @param fieldDef
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
function isRelatedModelProperty(fieldDef) {
|
|
129
|
+
return (typeof fieldDef?.type === 'object' &&
|
|
130
|
+
'model' in fieldDef.type &&
|
|
131
|
+
typeof fieldDef.type.model === 'string');
|
|
132
|
+
}
|
|
63
133
|
// TODO: this should accept single result to support CRUD methods; create helper for array/list
|
|
64
134
|
function initializeModel(client, modelName, result, modelIntrospection, authMode, authToken, context = false) {
|
|
65
135
|
const introModel = modelIntrospection.models[modelName];
|