@aws-amplify/api-graphql 4.0.1 → 4.0.2-unstable.b778a9e.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.
- package/dist/cjs/internals/APIClient.js +503 -0
- package/dist/cjs/internals/APIClient.js.map +1 -0
- package/dist/cjs/internals/InternalGraphQLAPI.js +1 -1
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/internals/generateClient.js +33 -0
- package/dist/cjs/internals/generateClient.js.map +1 -0
- package/dist/cjs/internals/generateModelsProperty.js +43 -0
- package/dist/cjs/internals/generateModelsProperty.js.map +1 -0
- package/dist/cjs/internals/index.js +3 -1
- package/dist/cjs/internals/index.js.map +1 -1
- package/dist/cjs/internals/operations/get.js +61 -0
- package/dist/cjs/internals/operations/get.js.map +1 -0
- package/dist/cjs/internals/operations/list.js +73 -0
- package/dist/cjs/internals/operations/list.js.map +1 -0
- package/dist/cjs/internals/operations/observeQuery.js +121 -0
- package/dist/cjs/internals/operations/observeQuery.js.map +1 -0
- package/dist/cjs/internals/operations/subscription.js +29 -0
- package/dist/cjs/internals/operations/subscription.js.map +1 -0
- package/dist/cjs/internals/server/generateClient.js +32 -0
- package/dist/cjs/internals/server/generateClient.js.map +1 -0
- package/dist/cjs/internals/server/generateModelsProperty.js +47 -0
- package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -0
- package/dist/cjs/internals/server/index.js +9 -0
- package/dist/cjs/internals/server/index.js.map +1 -0
- package/dist/cjs/internals/types.js +4 -0
- package/dist/cjs/internals/types.js.map +1 -0
- package/dist/cjs/types/index.js +3 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/findIndexByFields.js +25 -0
- package/dist/cjs/utils/findIndexByFields.js.map +1 -0
- package/dist/cjs/utils/index.js +5 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/resolveOwnerFields.js +42 -0
- package/dist/cjs/utils/resolveOwnerFields.js.map +1 -0
- package/dist/cjs/utils/resolvePKFields.js +17 -0
- package/dist/cjs/utils/resolvePKFields.js.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internals/APIClient.d.ts +121 -0
- package/dist/esm/internals/APIClient.mjs +493 -0
- package/dist/esm/internals/APIClient.mjs.map +1 -0
- package/dist/esm/internals/InternalGraphQLAPI.mjs +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/internals/generateClient.d.ts +12 -0
- package/dist/esm/internals/generateClient.mjs +31 -0
- package/dist/esm/internals/generateClient.mjs.map +1 -0
- package/dist/esm/internals/generateModelsProperty.d.ts +4 -0
- package/dist/esm/internals/generateModelsProperty.mjs +41 -0
- package/dist/esm/internals/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/internals/index.d.ts +1 -0
- package/dist/esm/internals/index.mjs +1 -0
- package/dist/esm/internals/index.mjs.map +1 -1
- package/dist/esm/internals/operations/get.d.ts +2 -0
- package/dist/esm/internals/operations/get.mjs +59 -0
- package/dist/esm/internals/operations/get.mjs.map +1 -0
- package/dist/esm/internals/operations/list.d.ts +2 -0
- package/dist/esm/internals/operations/list.mjs +71 -0
- package/dist/esm/internals/operations/list.mjs.map +1 -0
- package/dist/esm/internals/operations/observeQuery.d.ts +2 -0
- package/dist/esm/internals/operations/observeQuery.mjs +122 -0
- package/dist/esm/internals/operations/observeQuery.mjs.map +1 -0
- package/dist/esm/internals/operations/subscription.d.ts +1 -0
- package/dist/esm/internals/operations/subscription.mjs +27 -0
- package/dist/esm/internals/operations/subscription.mjs.map +1 -0
- package/dist/esm/internals/server/generateClient.d.ts +11 -0
- package/dist/esm/internals/server/generateClient.mjs +34 -0
- package/dist/esm/internals/server/generateClient.mjs.map +1 -0
- package/dist/esm/internals/server/generateModelsProperty.d.ts +3 -0
- package/dist/esm/internals/server/generateModelsProperty.mjs +45 -0
- package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/internals/server/index.d.ts +1 -0
- package/dist/esm/internals/server/index.mjs +2 -0
- package/dist/esm/internals/server/index.mjs.map +1 -0
- package/dist/esm/internals/types.d.ts +17 -0
- package/dist/esm/internals/types.mjs +2 -0
- package/dist/esm/internals/types.mjs.map +1 -0
- package/dist/esm/types/index.d.ts +22 -2
- package/dist/esm/types/index.mjs +3 -1
- package/dist/esm/types/index.mjs.map +1 -1
- package/dist/esm/utils/findIndexByFields.d.ts +9 -0
- package/dist/esm/utils/findIndexByFields.mjs +22 -0
- package/dist/esm/utils/findIndexByFields.mjs.map +1 -0
- package/dist/esm/utils/index.d.ts +2 -0
- package/dist/esm/utils/index.mjs +2 -0
- package/dist/esm/utils/index.mjs.map +1 -1
- package/dist/esm/utils/resolveOwnerFields.d.ts +12 -0
- package/dist/esm/utils/resolveOwnerFields.mjs +39 -0
- package/dist/esm/utils/resolveOwnerFields.mjs.map +1 -0
- package/dist/esm/utils/resolvePKFields.d.ts +13 -0
- package/dist/esm/utils/resolvePKFields.mjs +14 -0
- package/dist/esm/utils/resolvePKFields.mjs.map +1 -0
- package/internals/server/package.json +8 -0
- package/package.json +15 -9
- package/src/internals/APIClient.ts +724 -0
- package/src/internals/InternalGraphQLAPI.ts +1 -1
- package/src/internals/generateClient.ts +33 -0
- package/src/internals/generateModelsProperty.ts +70 -0
- package/src/internals/index.ts +1 -0
- package/src/internals/operations/get.ts +121 -0
- package/src/internals/operations/list.ts +111 -0
- package/src/internals/operations/observeQuery.ts +140 -0
- package/src/internals/operations/subscription.ts +59 -0
- package/src/internals/server/generateClient.ts +45 -0
- package/src/internals/server/generateModelsProperty.ts +70 -0
- package/src/internals/server/index.ts +4 -0
- package/src/internals/types.ts +21 -0
- package/src/types/index.ts +28 -2
- package/src/utils/findIndexByFields.ts +29 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/resolveOwnerFields.ts +65 -0
- package/src/utils/resolvePKFields.ts +22 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateModelsProperty = void 0;
|
|
7
|
+
const APIClient_1 = require("../APIClient");
|
|
8
|
+
const list_1 = require("../operations/list");
|
|
9
|
+
const get_1 = require("../operations/get");
|
|
10
|
+
function generateModelsProperty(client, params) {
|
|
11
|
+
const models = {};
|
|
12
|
+
const config = params.config;
|
|
13
|
+
const useContext = client === null;
|
|
14
|
+
if (!config) {
|
|
15
|
+
// TODO: improve
|
|
16
|
+
throw new Error('generateModelsProperty cannot retrieve Amplify config');
|
|
17
|
+
}
|
|
18
|
+
const modelIntrospection = config.API?.GraphQL?.modelIntrospection;
|
|
19
|
+
if (!modelIntrospection) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
const SSR_UNSUPORTED_OPS = [
|
|
23
|
+
'ONCREATE',
|
|
24
|
+
'ONUPDATE',
|
|
25
|
+
'ONDELETE',
|
|
26
|
+
'OBSERVE_QUERY',
|
|
27
|
+
];
|
|
28
|
+
for (const model of Object.values(modelIntrospection.models)) {
|
|
29
|
+
const { name } = model;
|
|
30
|
+
models[name] = {};
|
|
31
|
+
Object.entries(APIClient_1.graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {
|
|
32
|
+
const operation = key;
|
|
33
|
+
// subscriptions are not supported in SSR
|
|
34
|
+
if (SSR_UNSUPORTED_OPS.includes(operation))
|
|
35
|
+
return;
|
|
36
|
+
if (operation === 'LIST') {
|
|
37
|
+
models[name][operationPrefix] = (0, list_1.listFactory)(client, modelIntrospection, model, useContext);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation, useContext);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return models;
|
|
45
|
+
}
|
|
46
|
+
exports.generateModelsProperty = generateModelsProperty;
|
|
47
|
+
//# sourceMappingURL=generateModelsProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateModelsProperty.js","sources":["../../../../src/internals/server/generateModelsProperty.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.generateModelsProperty = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst list_1 = require(\"../operations/list\");\nconst get_1 = require(\"../operations/get\");\nfunction generateModelsProperty(client, params) {\n const models = {};\n const config = params.config;\n const useContext = client === null;\n if (!config) {\n // TODO: improve\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\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(APIClient_1.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] = (0, list_1.listFactory)(client, modelIntrospection, model, useContext);\n }\n else {\n models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation, useContext);\n }\n });\n }\n return models;\n}\nexports.generateModelsProperty = generateModelsProperty;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC3C,SAAS,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE;AAChD,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACjC,IAAI,MAAM,UAAU,GAAG,MAAM,KAAK,IAAI,CAAC;AACvC,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB;AACA,QAAQ,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,kBAAkB,CAAC;AACvE,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,eAAe;AACvB,KAAK,CAAC;AACN,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;AAClE,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC/B,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,CAAC,KAAK;AAClG,YAAY,MAAM,SAAS,GAAG,GAAG,CAAC;AAClC;AACA,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC,SAAS,CAAC;AACtD,gBAAgB,OAAO;AACvB,YAAY,IAAI,SAAS,KAAK,MAAM,EAAE;AACtC,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACvH,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAChI,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateClient = void 0;
|
|
7
|
+
var generateClient_1 = require("./generateClient");
|
|
8
|
+
Object.defineProperty(exports, "generateClient", { enumerable: true, get: function () { return generateClient_1.generateClient; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/internals/server/index.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.generateClient = void 0;\nvar generateClient_1 = require(\"./generateClient\");\nObject.defineProperty(exports, \"generateClient\", { enumerable: true, get: function () { return generateClient_1.generateClient; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,IAAI,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACnD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,gBAAgB,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/internals/types.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;
|
|
4
|
+
exports.__authToken = exports.__authMode = exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;
|
|
5
5
|
var PubSub_1 = require("./PubSub");
|
|
6
6
|
Object.defineProperty(exports, "CONTROL_MSG", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });
|
|
7
7
|
Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });
|
|
@@ -13,4 +13,6 @@ Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: funct
|
|
|
13
13
|
GraphQLAuthError["NO_AUTH_TOKEN"] = "No auth token specified";
|
|
14
14
|
})(exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));
|
|
15
15
|
exports.__amplify = Symbol('amplify');
|
|
16
|
+
exports.__authMode = Symbol('authMode');
|
|
17
|
+
exports.__authToken = Symbol('authToken');
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;\nvar PubSub_1 = require(\"./PubSub\");\nObject.defineProperty(exports, \"CONTROL_MSG\", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });\nObject.defineProperty(exports, \"ConnectionState\", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });\nvar GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError = exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));\nexports.__amplify = Symbol('amplify');\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.__authToken = exports.__authMode = exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;\nvar PubSub_1 = require(\"./PubSub\");\nObject.defineProperty(exports, \"CONTROL_MSG\", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });\nObject.defineProperty(exports, \"ConnectionState\", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });\nvar GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError = exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));\nexports.__amplify = Symbol('amplify');\nexports.__authMode = Symbol('authMode');\nexports.__authToken = Symbol('authToken');\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AACjJ,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;AACvH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;AAE/H,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,YAAY,CAAC,GAAG,uBAAuB,CAAC;AAC7D,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC5D,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AAC1D,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC9D,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,yBAAyB,CAAC;AAClE,CAAC,EAAqB,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC;AACnF,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AACtC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AACxC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.findIndexByFields = void 0;
|
|
5
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
/**
|
|
8
|
+
* Iterates through a collection to find a matching item and returns the index.
|
|
9
|
+
*
|
|
10
|
+
* @param needle The item to search for
|
|
11
|
+
* @param haystack The collection to search
|
|
12
|
+
* @param keyFields The fields used to indicate a match
|
|
13
|
+
* @returns Index of `needle` in `haystack`, otherwise -1 if not found.
|
|
14
|
+
*/
|
|
15
|
+
function findIndexByFields(needle, haystack, keyFields) {
|
|
16
|
+
const searchObject = Object.fromEntries(keyFields.map(fieldName => [fieldName, needle[fieldName]]));
|
|
17
|
+
for (let i = 0; i < haystack.length; i++) {
|
|
18
|
+
if (Object.keys(searchObject).every(k => searchObject[k] === haystack[i][k])) {
|
|
19
|
+
return i;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
exports.findIndexByFields = findIndexByFields;
|
|
25
|
+
//# sourceMappingURL=findIndexByFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findIndexByFields.js","sources":["../../../src/utils/findIndexByFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.findIndexByFields = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Iterates through a collection to find a matching item and returns the index.\n *\n * @param needle The item to search for\n * @param haystack The collection to search\n * @param keyFields The fields used to indicate a match\n * @returns Index of `needle` in `haystack`, otherwise -1 if not found.\n */\nfunction findIndexByFields(needle, haystack, keyFields) {\n const searchObject = Object.fromEntries(keyFields.map(fieldName => [fieldName, needle[fieldName]]));\n for (let i = 0; i < haystack.length; i++) {\n if (Object.keys(searchObject).every(k => searchObject[k] === haystack[i][k])) {\n return i;\n }\n }\n return -1;\n}\nexports.findIndexByFields = findIndexByFields;\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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE;AACxD,IAAI,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACxG,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC9C,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACtF,YAAY,OAAO,CAAC,CAAC;AACrB,SAAS;AACT,KAAK;AACL,IAAI,OAAO,CAAC,CAAC,CAAC;AACd,CAAC;AACD,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;;"}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveLibraryOptions = exports.resolveConfig = void 0;
|
|
6
|
+
exports.findIndexByFields = exports.resolvePKFields = exports.resolveLibraryOptions = exports.resolveConfig = void 0;
|
|
7
7
|
var resolveConfig_1 = require("./resolveConfig");
|
|
8
8
|
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });
|
|
9
9
|
var resolveLibraryOptions_1 = require("./resolveLibraryOptions");
|
|
10
10
|
Object.defineProperty(exports, "resolveLibraryOptions", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });
|
|
11
|
+
var resolvePKFields_1 = require("./resolvePKFields");
|
|
12
|
+
Object.defineProperty(exports, "resolvePKFields", { enumerable: true, get: function () { return resolvePKFields_1.resolvePKFields; } });
|
|
13
|
+
var findIndexByFields_1 = require("./findIndexByFields");
|
|
14
|
+
Object.defineProperty(exports, "findIndexByFields", { enumerable: true, get: function () { return findIndexByFields_1.findIndexByFields; } });
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/index.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.resolveLibraryOptions = exports.resolveConfig = void 0;\nvar resolveConfig_1 = require(\"./resolveConfig\");\nObject.defineProperty(exports, \"resolveConfig\", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });\nvar resolveLibraryOptions_1 = require(\"./resolveLibraryOptions\");\nObject.defineProperty(exports, \"resolveLibraryOptions\", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/index.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.findIndexByFields = exports.resolvePKFields = exports.resolveLibraryOptions = exports.resolveConfig = void 0;\nvar resolveConfig_1 = require(\"./resolveConfig\");\nObject.defineProperty(exports, \"resolveConfig\", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });\nvar resolveLibraryOptions_1 = require(\"./resolveLibraryOptions\");\nObject.defineProperty(exports, \"resolveLibraryOptions\", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });\nvar resolvePKFields_1 = require(\"./resolvePKFields\");\nObject.defineProperty(exports, \"resolvePKFields\", { enumerable: true, get: function () { return resolvePKFields_1.resolvePKFields; } });\nvar findIndexByFields_1 = require(\"./findIndexByFields\");\nObject.defineProperty(exports, \"findIndexByFields\", { enumerable: true, get: function () { return findIndexByFields_1.findIndexByFields; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AACrH,IAAI,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACjD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAAe,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;AAClI,IAAI,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACjE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1J,IAAI,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACrD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,iBAAiB,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;AACxI,IAAI,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolveOwnerFields = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Given an introspection schema model, returns all owner fields.
|
|
7
|
+
*
|
|
8
|
+
* @param model Model from an introspection schema
|
|
9
|
+
* @returns List of owner field names
|
|
10
|
+
*/
|
|
11
|
+
function resolveOwnerFields(model) {
|
|
12
|
+
const ownerFields = new Set();
|
|
13
|
+
for (const attr of model.attributes || []) {
|
|
14
|
+
if (isAuthAttribute(attr)) {
|
|
15
|
+
for (const rule of attr.properties.rules) {
|
|
16
|
+
if (rule.allow === 'owner') {
|
|
17
|
+
ownerFields.add(rule.ownerField || 'owner');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return Array.from(ownerFields);
|
|
23
|
+
}
|
|
24
|
+
exports.resolveOwnerFields = resolveOwnerFields;
|
|
25
|
+
/**
|
|
26
|
+
* Type guard that identifies an auth attribute with an attached rules list that
|
|
27
|
+
* specifies an `allow` attribute at a minimum.
|
|
28
|
+
*
|
|
29
|
+
* @param attribute Any object. Ideally a model introspection schema model attribute
|
|
30
|
+
* @returns True if given object is an auth attribute
|
|
31
|
+
*/
|
|
32
|
+
function isAuthAttribute(attribute) {
|
|
33
|
+
if (attribute?.type === 'auth') {
|
|
34
|
+
if (typeof attribute?.properties === 'object') {
|
|
35
|
+
if (Array.isArray(attribute?.properties?.rules)) {
|
|
36
|
+
return (attribute?.properties?.rules).every(rule => !!rule.allow);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=resolveOwnerFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveOwnerFields.js","sources":["../../../src/utils/resolveOwnerFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveOwnerFields = void 0;\n/**\n * Given an introspection schema model, returns all owner fields.\n *\n * @param model Model from an introspection schema\n * @returns List of owner field names\n */\nfunction resolveOwnerFields(model) {\n const ownerFields = new Set();\n for (const attr of model.attributes || []) {\n if (isAuthAttribute(attr)) {\n for (const rule of attr.properties.rules) {\n if (rule.allow === 'owner') {\n ownerFields.add(rule.ownerField || 'owner');\n }\n }\n }\n }\n return Array.from(ownerFields);\n}\nexports.resolveOwnerFields = resolveOwnerFields;\n/**\n * Type guard that identifies an auth attribute with an attached rules list that\n * specifies an `allow` attribute at a minimum.\n *\n * @param attribute Any object. Ideally a model introspection schema model attribute\n * @returns True if given object is an auth attribute\n */\nfunction isAuthAttribute(attribute) {\n if (attribute?.type === 'auth') {\n if (typeof attribute?.properties === 'object') {\n if (Array.isArray(attribute?.properties?.rules)) {\n return (attribute?.properties?.rules).every(rule => !!rule.allow);\n }\n }\n }\n return false;\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAE;AACnC,IAAI,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAClC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE;AAC/C,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;AACnC,YAAY,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACtD,gBAAgB,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;AAC5C,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC;AAChE,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,SAAS,EAAE;AACpC,IAAI,IAAI,SAAS,EAAE,IAAI,KAAK,MAAM,EAAE;AACpC,QAAQ,IAAI,OAAO,SAAS,EAAE,UAAU,KAAK,QAAQ,EAAE;AACvD,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE;AAC7D,gBAAgB,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolvePKFields = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key
|
|
7
|
+
* as an array of field names.
|
|
8
|
+
*
|
|
9
|
+
* @param model The model object
|
|
10
|
+
* @returns Array of field names
|
|
11
|
+
*/
|
|
12
|
+
function resolvePKFields(model) {
|
|
13
|
+
const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;
|
|
14
|
+
return [primaryKeyFieldName, ...sortKeyFieldNames];
|
|
15
|
+
}
|
|
16
|
+
exports.resolvePKFields = resolvePKFields;
|
|
17
|
+
//# sourceMappingURL=resolvePKFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePKFields.js","sources":["../../../src/utils/resolvePKFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolvePKFields = void 0;\n/**\n * Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key\n * as an array of field names.\n *\n * @param model The model object\n * @returns Array of field names\n */\nfunction resolvePKFields(model) {\n const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;\n return [primaryKeyFieldName, ...sortKeyFieldNames];\n}\nexports.resolvePKFields = resolvePKFields;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,KAAK,EAAE;AAChC,IAAI,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC;AAC5E,IAAI,OAAO,CAAC,mBAAmB,EAAE,GAAG,iBAAiB,CAAC,CAAC;AACvD,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { GraphQLAPI, GraphQLAPIClass, graphqlOperation } from './GraphQLAPI.mjs';
|
|
2
|
-
export { GraphQLAuthError, __amplify } from './types/index.mjs';
|
|
2
|
+
export { GraphQLAuthError, __amplify, __authMode, __authToken } from './types/index.mjs';
|
|
3
3
|
export { CONNECTION_STATE_CHANGE } from './Providers/constants.mjs';
|
|
4
4
|
export { CONTROL_MSG, ConnectionState } from './types/PubSub.mjs';
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import { V6Client } from '../types';
|
|
3
|
+
type ListArgs = {
|
|
4
|
+
selectionSet?: string[];
|
|
5
|
+
filter?: {};
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param GraphQL response object
|
|
10
|
+
* @returns response object with `items` properties flattened
|
|
11
|
+
*/
|
|
12
|
+
export declare const flattenItems: (obj: Record<string, any>) => Record<string, any>;
|
|
13
|
+
export declare function initializeModel(client: any, modelName: string, result: any[], modelIntrospection: any, authMode: GraphQLAuthMode | undefined, authToken: string | undefined, context?: boolean): any[];
|
|
14
|
+
export declare const graphQLOperationsInfo: {
|
|
15
|
+
CREATE: {
|
|
16
|
+
operationPrefix: "create";
|
|
17
|
+
usePlural: boolean;
|
|
18
|
+
};
|
|
19
|
+
READ: {
|
|
20
|
+
operationPrefix: "get";
|
|
21
|
+
usePlural: boolean;
|
|
22
|
+
};
|
|
23
|
+
UPDATE: {
|
|
24
|
+
operationPrefix: "update";
|
|
25
|
+
usePlural: boolean;
|
|
26
|
+
};
|
|
27
|
+
DELETE: {
|
|
28
|
+
operationPrefix: "delete";
|
|
29
|
+
usePlural: boolean;
|
|
30
|
+
};
|
|
31
|
+
LIST: {
|
|
32
|
+
operationPrefix: "list";
|
|
33
|
+
usePlural: boolean;
|
|
34
|
+
};
|
|
35
|
+
ONCREATE: {
|
|
36
|
+
operationPrefix: "onCreate";
|
|
37
|
+
usePlural: boolean;
|
|
38
|
+
};
|
|
39
|
+
ONUPDATE: {
|
|
40
|
+
operationPrefix: "onUpdate";
|
|
41
|
+
usePlural: boolean;
|
|
42
|
+
};
|
|
43
|
+
ONDELETE: {
|
|
44
|
+
operationPrefix: "onDelete";
|
|
45
|
+
usePlural: boolean;
|
|
46
|
+
};
|
|
47
|
+
OBSERVE_QUERY: {
|
|
48
|
+
operationPrefix: "observeQuery";
|
|
49
|
+
usePlural: boolean;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export type ModelOperation = keyof typeof graphQLOperationsInfo;
|
|
53
|
+
/**
|
|
54
|
+
* Generates nested Custom Selection Set IR from path
|
|
55
|
+
*
|
|
56
|
+
* @param modelIntrospection
|
|
57
|
+
* @param modelName
|
|
58
|
+
* @param selectionSet - array of object paths
|
|
59
|
+
* @example
|
|
60
|
+
* ### Given
|
|
61
|
+
* `selectionSet = ['id', 'comments.post.id']`
|
|
62
|
+
* ### Returns
|
|
63
|
+
* ```ts
|
|
64
|
+
* {
|
|
65
|
+
* id: '',
|
|
66
|
+
* comments: {
|
|
67
|
+
* items: { post: { id: '' } }
|
|
68
|
+
* }
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function customSelectionSetToIR(modelIntrospection: any, modelName: string, selectionSet: string[]): Record<string, string | object>;
|
|
73
|
+
/**
|
|
74
|
+
* Stringifies selection set IR
|
|
75
|
+
* * @example
|
|
76
|
+
* ### Given
|
|
77
|
+
* ```ts
|
|
78
|
+
* {
|
|
79
|
+
* id: '',
|
|
80
|
+
* comments: {
|
|
81
|
+
* items: { post: { id: '' } }
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
* ### Returns
|
|
86
|
+
* `'id comments { items { post { id } } }'`
|
|
87
|
+
*/
|
|
88
|
+
export declare function selectionSetIRToString(obj: Record<string, string | any>): string;
|
|
89
|
+
export declare function generateSelectionSet(modelIntrospection: any, modelName: string, selectionSet?: string[]): string;
|
|
90
|
+
export declare function generateGraphQLDocument(modelIntrospection: any, modelName: string, modelOperation: ModelOperation, listArgs?: ListArgs): string;
|
|
91
|
+
export declare function buildGraphQLVariables(modelDefinition: any, operation: ModelOperation, arg: any, modelIntrospection: any): object;
|
|
92
|
+
/**
|
|
93
|
+
* Iterates over mutation input values and resolves any model inputs to their corresponding join fields/values
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ### Usage
|
|
97
|
+
* ```ts
|
|
98
|
+
* const result = normalizeMutationInput({ post: post }, model, modelDefinition);
|
|
99
|
+
* ```
|
|
100
|
+
* ### Result
|
|
101
|
+
* ```ts
|
|
102
|
+
* { postId: "abc123" }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
*/
|
|
106
|
+
export declare function normalizeMutationInput(mutationInput: any, model: any, modelDefinition: any): Record<string, unknown>;
|
|
107
|
+
type AuthModeParams = {
|
|
108
|
+
authMode?: GraphQLAuthMode;
|
|
109
|
+
authToken?: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Produces a parameter object that can contains auth mode/token overrides
|
|
113
|
+
* only if present in either `options` (first) or configured on the `client`
|
|
114
|
+
* as a fallback.
|
|
115
|
+
*
|
|
116
|
+
* @param client Configured client from `generateClient`
|
|
117
|
+
* @param options Args/Options obect from call site.
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
export declare function authModeParams(client: V6Client, options?: AuthModeParams): AuthModeParams;
|
|
121
|
+
export {};
|