@aws-amplify/api-graphql 4.0.17 → 4.0.18-experimental-lerna-test.d2b0b08.55
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/Providers/AWSAppSyncRealTimeProvider/index.js +40 -31
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/dist/cjs/internals/APIClient.js +145 -54
- package/dist/cjs/internals/APIClient.js.map +1 -1
- package/dist/cjs/internals/InternalGraphQLAPI.js +41 -42
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/internals/generateClient.js +15 -5
- package/dist/cjs/internals/generateClient.js.map +1 -1
- package/dist/cjs/internals/generateCustomOperationsProperty.js +50 -0
- package/dist/cjs/internals/generateCustomOperationsProperty.js.map +1 -0
- package/dist/cjs/internals/operations/custom.js +356 -0
- package/dist/cjs/internals/operations/custom.js.map +1 -0
- package/dist/cjs/internals/operations/get.js +1 -1
- package/dist/cjs/internals/operations/get.js.map +1 -1
- package/dist/cjs/internals/operations/indexQuery.js +1 -1
- package/dist/cjs/internals/operations/indexQuery.js.map +1 -1
- package/dist/cjs/internals/operations/list.js +2 -2
- package/dist/cjs/internals/operations/list.js.map +1 -1
- package/dist/cjs/internals/operations/subscription.js +1 -1
- package/dist/cjs/internals/operations/subscription.js.map +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +12 -2
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -1
- package/dist/cjs/internals/utils/clientProperties/generateEnumsProperty.js.map +1 -0
- package/dist/cjs/internals/utils/{generateModelsProperty.js → clientProperties/generateModelsProperty.js} +7 -7
- package/dist/cjs/internals/utils/clientProperties/generateModelsProperty.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js +15 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js.map +1 -0
- package/dist/cjs/internals/v6.js +0 -2
- package/dist/cjs/internals/v6.js.map +1 -1
- package/dist/cjs/utils/errors/constants.js +47 -0
- package/dist/cjs/utils/errors/constants.js.map +1 -0
- package/dist/cjs/utils/errors/createGraphQLResultWithError.js +15 -0
- package/dist/cjs/utils/errors/createGraphQLResultWithError.js.map +1 -0
- package/dist/cjs/utils/errors/index.js +3 -1
- package/dist/cjs/utils/errors/index.js.map +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js +7 -7
- package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -1
- package/dist/cjs/utils/resolveOwnerFields.js +6 -0
- package/dist/cjs/utils/resolveOwnerFields.js.map +1 -1
- package/dist/esm/GraphQLAPI.d.ts +2 -2
- package/dist/esm/GraphQLAPI.mjs.map +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +8 -8
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +40 -31
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
- package/dist/esm/internals/APIClient.d.ts +10 -9
- package/dist/esm/internals/APIClient.mjs +144 -54
- package/dist/esm/internals/APIClient.mjs.map +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.mjs +45 -44
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/internals/generateClient.mjs +15 -5
- package/dist/esm/internals/generateClient.mjs.map +1 -1
- package/dist/esm/internals/generateCustomOperationsProperty.d.ts +9 -0
- package/dist/esm/internals/generateCustomOperationsProperty.mjs +45 -0
- package/dist/esm/internals/generateCustomOperationsProperty.mjs.map +1 -0
- package/dist/esm/internals/operations/custom.d.ts +63 -0
- package/dist/esm/internals/operations/custom.mjs +354 -0
- package/dist/esm/internals/operations/custom.mjs.map +1 -0
- package/dist/esm/internals/operations/get.d.ts +1 -1
- package/dist/esm/internals/operations/get.mjs +1 -1
- package/dist/esm/internals/operations/get.mjs.map +1 -1
- package/dist/esm/internals/operations/indexQuery.d.ts +3 -3
- package/dist/esm/internals/operations/indexQuery.mjs +1 -1
- package/dist/esm/internals/operations/indexQuery.mjs.map +1 -1
- package/dist/esm/internals/operations/list.d.ts +1 -1
- package/dist/esm/internals/operations/list.mjs +2 -2
- package/dist/esm/internals/operations/list.mjs.map +1 -1
- package/dist/esm/internals/operations/subscription.d.ts +1 -1
- package/dist/esm/internals/operations/subscription.mjs +1 -1
- package/dist/esm/internals/operations/subscription.mjs.map +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +12 -2
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
- package/dist/esm/internals/server/generateModelsProperty.d.ts +3 -3
- package/dist/esm/internals/server/generateModelsProperty.mjs +1 -1
- package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -1
- package/dist/esm/internals/types.d.ts +2 -2
- package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.mjs.map +1 -0
- package/dist/esm/internals/utils/{generateModelsProperty.d.ts → clientProperties/generateModelsProperty.d.ts} +2 -2
- package/dist/esm/internals/utils/{generateModelsProperty.mjs → clientProperties/generateModelsProperty.mjs} +7 -7
- package/dist/esm/internals/utils/clientProperties/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs.map +1 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs.map +1 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.d.ts +2 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs +12 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs.map +1 -0
- package/dist/esm/internals/v6.d.ts +1 -1
- package/dist/esm/internals/v6.mjs +0 -2
- package/dist/esm/internals/v6.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +43 -35
- package/dist/esm/utils/ConnectionStateMonitor.d.ts +2 -2
- package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -1
- package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -1
- package/dist/esm/utils/errors/constants.d.ts +7 -0
- package/dist/esm/utils/errors/constants.mjs +46 -0
- package/dist/esm/utils/errors/constants.mjs.map +1 -0
- package/dist/esm/utils/errors/createGraphQLResultWithError.d.ts +2 -0
- package/dist/esm/utils/errors/createGraphQLResultWithError.mjs +13 -0
- package/dist/esm/utils/errors/createGraphQLResultWithError.mjs.map +1 -0
- package/dist/esm/utils/errors/index.d.ts +1 -0
- package/dist/esm/utils/errors/index.mjs +1 -0
- package/dist/esm/utils/errors/index.mjs.map +1 -1
- package/dist/esm/utils/errors/repackageAuthError.d.ts +3 -7
- package/dist/esm/utils/errors/repackageAuthError.mjs +6 -6
- package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -1
- package/dist/esm/utils/findIndexByFields.d.ts +1 -1
- package/dist/esm/utils/resolveConfig.mjs +1 -0
- package/dist/esm/utils/resolveConfig.mjs.map +1 -1
- package/dist/esm/utils/resolveOwnerFields.mjs +6 -0
- package/dist/esm/utils/resolveOwnerFields.mjs.map +1 -1
- package/package.json +8 -7
- package/src/GraphQLAPI.ts +4 -3
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +84 -64
- package/src/internals/APIClient.ts +242 -104
- package/src/internals/InternalGraphQLAPI.ts +65 -75
- package/src/internals/clientUtils.ts +1 -1
- package/src/internals/generateClient.ts +43 -6
- package/src/internals/generateCustomOperationsProperty.ts +112 -0
- package/src/internals/operations/custom.ts +492 -0
- package/src/internals/operations/get.ts +10 -9
- package/src/internals/operations/indexQuery.ts +13 -12
- package/src/internals/operations/list.ts +11 -15
- package/src/internals/operations/observeQuery.ts +3 -1
- package/src/internals/operations/subscription.ts +14 -10
- package/src/internals/server/generateClientWithAmplifyInstance.ts +26 -7
- package/src/internals/server/generateModelsProperty.ts +12 -6
- package/src/internals/types.ts +2 -2
- package/src/internals/utils/{generateEnumsProperty.ts → clientProperties/generateEnumsProperty.ts} +7 -6
- package/src/internals/utils/{generateModelsProperty.ts → clientProperties/generateModelsProperty.ts} +11 -10
- package/src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts +15 -0
- package/src/internals/v6.ts +6 -4
- package/src/server/generateClient.ts +4 -1
- package/src/types/PubSub.ts +1 -0
- package/src/types/index.ts +61 -45
- package/src/utils/ConnectionStateMonitor.ts +8 -3
- package/src/utils/ReachabilityMonitor/index.native.ts +1 -1
- package/src/utils/ReachabilityMonitor/index.ts +1 -0
- package/src/utils/ReconnectionMonitor.ts +1 -0
- package/src/utils/errors/constants.ts +56 -0
- package/src/utils/errors/createGraphQLResultWithError.ts +15 -0
- package/src/utils/errors/index.ts +1 -0
- package/src/utils/errors/repackageAuthError.ts +11 -14
- package/src/utils/findIndexByFields.ts +1 -1
- package/src/utils/resolveConfig.ts +1 -0
- package/src/utils/resolveLibraryOptions.ts +1 -0
- package/src/utils/resolveOwnerFields.ts +19 -7
- package/src/utils/resolvePKFields.ts +1 -0
- package/dist/cjs/internals/utils/generateEnumsProperty.js.map +0 -1
- package/dist/cjs/internals/utils/generateModelsProperty.js.map +0 -1
- package/dist/cjs/internals/utils/isApiGraphQLProviderConfig.js.map +0 -1
- package/dist/cjs/internals/utils/isConfigureEventWithResourceConfig.js.map +0 -1
- package/dist/esm/internals/utils/generateEnumsProperty.mjs.map +0 -1
- package/dist/esm/internals/utils/generateModelsProperty.mjs.map +0 -1
- package/dist/esm/internals/utils/isApiGraphQLProviderConfig.mjs.map +0 -1
- package/dist/esm/internals/utils/isConfigureEventWithResourceConfig.mjs.map +0 -1
- /package/dist/cjs/internals/utils/{generateEnumsProperty.js → clientProperties/generateEnumsProperty.js} +0 -0
- /package/dist/cjs/internals/utils/{isApiGraphQLProviderConfig.js → runtimeTypeGuards/isApiGraphQLProviderConfig.js} +0 -0
- /package/dist/cjs/internals/utils/{isConfigureEventWithResourceConfig.js → runtimeTypeGuards/isConfigureEventWithResourceConfig.js} +0 -0
- /package/dist/esm/internals/utils/{generateEnumsProperty.d.ts → clientProperties/generateEnumsProperty.d.ts} +0 -0
- /package/dist/esm/internals/utils/{generateEnumsProperty.mjs → clientProperties/generateEnumsProperty.mjs} +0 -0
- /package/dist/esm/internals/utils/{isApiGraphQLProviderConfig.d.ts → runtimeTypeGuards/isApiGraphQLProviderConfig.d.ts} +0 -0
- /package/dist/esm/internals/utils/{isApiGraphQLProviderConfig.mjs → runtimeTypeGuards/isApiGraphQLProviderConfig.mjs} +0 -0
- /package/dist/esm/internals/utils/{isConfigureEventWithResourceConfig.d.ts → runtimeTypeGuards/isConfigureEventWithResourceConfig.d.ts} +0 -0
- /package/dist/esm/internals/utils/{isConfigureEventWithResourceConfig.mjs → runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs} +0 -0
- /package/src/internals/utils/{isApiGraphQLProviderConfig.ts → runtimeTypeGuards/isApiGraphQLProviderConfig.ts} +0 -0
- /package/src/internals/utils/{isConfigureEventWithResourceConfig.ts → runtimeTypeGuards/isConfigureEventWithResourceConfig.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateEnumsProperty.js","sources":["../../../../../src/internals/utils/clientProperties/generateEnumsProperty.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.generateEnumsProperty = void 0;\nconst generateEnumsProperty = (graphqlConfig) => {\n const modelIntrospection = graphqlConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const enums = {};\n for (const [_, enumData] of Object.entries(modelIntrospection.enums)) {\n enums[enumData.name] = {\n values: () => enumData.values,\n };\n }\n return enums;\n};\nexports.generateEnumsProperty = generateEnumsProperty;\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,KAAK,CAAC,CAAC;AACvC,MAAM,qBAAqB,GAAG,CAAC,aAAa,KAAK;AACjD,IAAI,MAAM,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC;AAChE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;AACrB,IAAI,KAAK,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;AAC1E,QAAQ,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG;AAC/B,YAAY,MAAM,EAAE,MAAM,QAAQ,CAAC,MAAM;AACzC,SAAS,CAAC;AACV,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AACF,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.generateModelsProperty = void 0;
|
|
5
|
-
const APIClient_1 = require("
|
|
6
|
-
const list_1 = require("
|
|
7
|
-
const indexQuery_1 = require("
|
|
8
|
-
const get_1 = require("
|
|
9
|
-
const subscription_1 = require("
|
|
10
|
-
const observeQuery_1 = require("
|
|
11
|
-
const clientUtils_1 = require("
|
|
5
|
+
const APIClient_1 = require("../../APIClient");
|
|
6
|
+
const list_1 = require("../../operations/list");
|
|
7
|
+
const indexQuery_1 = require("../../operations/indexQuery");
|
|
8
|
+
const get_1 = require("../../operations/get");
|
|
9
|
+
const subscription_1 = require("../../operations/subscription");
|
|
10
|
+
const observeQuery_1 = require("../../operations/observeQuery");
|
|
11
|
+
const clientUtils_1 = require("../../clientUtils");
|
|
12
12
|
function generateModelsProperty(client, apiGraphQLConfig) {
|
|
13
13
|
const models = {};
|
|
14
14
|
const modelIntrospection = apiGraphQLConfig.modelIntrospection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateModelsProperty.js","sources":["../../../../../src/internals/utils/clientProperties/generateModelsProperty.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateModelsProperty = void 0;\nconst APIClient_1 = require(\"../../APIClient\");\nconst list_1 = require(\"../../operations/list\");\nconst indexQuery_1 = require(\"../../operations/indexQuery\");\nconst get_1 = require(\"../../operations/get\");\nconst subscription_1 = require(\"../../operations/subscription\");\nconst observeQuery_1 = require(\"../../operations/observeQuery\");\nconst clientUtils_1 = require(\"../../clientUtils\");\nfunction generateModelsProperty(client, apiGraphQLConfig) {\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(APIClient_1.graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = (0, list_1.listFactory)(client, modelIntrospection, model);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = (0, subscription_1.subscriptionFactory)(client, modelIntrospection, model, operation);\n }\n else if (operation === 'OBSERVE_QUERY') {\n models[name][operationPrefix] = (0, observeQuery_1.observeQueryFactory)(models, model);\n }\n else {\n models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation);\n }\n });\n const secondaryIdxs = (0, clientUtils_1.getSecondaryIndexesFromSchemaModel)(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = (0, indexQuery_1.indexQueryFactory)(client, modelIntrospection, model, idx);\n }\n }\n return models;\n}\nexports.generateModelsProperty = generateModelsProperty;\n"],"names":[],"mappings":";;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,iBAAiB,CAAC,CAAC;AAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAChD,MAAM,YAAY,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAChE,MAAM,cAAc,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAChE,MAAM,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACnD,SAAS,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE;AAC1D,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,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,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,CAAC,CAAC;AAC3G,aAAa;AACb,iBAAiB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC3D,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,cAAc,CAAC,mBAAmB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACtI,aAAa;AACb,iBAAiB,IAAI,SAAS,KAAK,eAAe,EAAE;AACpD,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,cAAc,CAAC,mBAAmB,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACvG,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,CAAC,CAAC;AACpH,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AAC3F,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACvH,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isApiGraphQLProviderConfig.js","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.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.isApiGraphQLConfig = void 0;\nfunction isApiGraphQLConfig(apiGraphQLConfig) {\n return apiGraphQLConfig !== undefined;\n}\nexports.isApiGraphQLConfig = isApiGraphQLConfig;\n"],"names":[],"mappings":";;AACA;AACA;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,SAAS,kBAAkB,CAAC,gBAAgB,EAAE;AAC9C,IAAI,OAAO,gBAAgB,KAAK,SAAS,CAAC;AAC1C,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isConfigureEventWithResourceConfig.js","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.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.isConfigureEventWithResourceConfig = void 0;\nfunction isConfigureEventWithResourceConfig(payload) {\n return payload.event === 'configure';\n}\nexports.isConfigureEventWithResourceConfig = isConfigureEventWithResourceConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD,SAAS,kCAAkC,CAAC,OAAO,EAAE;AACrD,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,WAAW,CAAC;AACzC,CAAC;AACD,OAAO,CAAC,kCAAkC,GAAG,kCAAkC;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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.isGraphQLResponseWithErrors = void 0;
|
|
7
|
+
function isGraphQLResponseWithErrors(response) {
|
|
8
|
+
if (!response) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const r = response;
|
|
12
|
+
return Array.isArray(r.errors) && r.errors.length > 0;
|
|
13
|
+
}
|
|
14
|
+
exports.isGraphQLResponseWithErrors = isGraphQLResponseWithErrors;
|
|
15
|
+
//# sourceMappingURL=isGraphQLResponseWithErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isGraphQLResponseWithErrors.js","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.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.isGraphQLResponseWithErrors = void 0;\nfunction isGraphQLResponseWithErrors(response) {\n if (!response) {\n return false;\n }\n const r = response;\n return Array.isArray(r.errors) && r.errors.length > 0;\n}\nexports.isGraphQLResponseWithErrors = isGraphQLResponseWithErrors;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,2BAA2B,GAAG,KAAK,CAAC,CAAC;AAC7C,SAAS,2BAA2B,CAAC,QAAQ,EAAE;AAC/C,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,MAAM,CAAC,GAAG,QAAQ,CAAC;AACvB,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1D,CAAC;AACD,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;;"}
|
package/dist/cjs/internals/v6.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.isCancelError = exports.cancel = exports.graphql = void 0;
|
|
5
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
7
5
|
const GraphQLAPI_1 = require("../GraphQLAPI");
|
|
8
6
|
const types_1 = require("../types");
|
|
9
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v6.js","sources":["../../../src/internals/v6.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isCancelError = exports.cancel = exports.graphql = void 0;\
|
|
1
|
+
{"version":3,"file":"v6.js","sources":["../../../src/internals/v6.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isCancelError = exports.cancel = exports.graphql = void 0;\nconst GraphQLAPI_1 = require(\"../GraphQLAPI\");\nconst types_1 = require(\"../types\");\n/**\n * Invokes graphql operations against a graphql service, providing correct input and\n * output types if Amplify-generated graphql from a recent version of the CLI/codegen\n * are used *or* correct typing is provided via the type argument.\n *\n * Amplify-generated \"branded\" graphql queries will look similar to this:\n *\n * ```ts\n * //\n * // |-- branding\n * // v\n * export const getModel = `...` as GeneratedQuery<\n * \tGetModelQueryVariables,\n * \tGetModelQuery\n * >;\n * ```\n *\n * If this branding is not in your generated graphql, update to a newer version of\n * CLI/codegen and regenerate your graphql using `amplify codegen`.\n *\n * ## Using Amplify-generated graphql\n *\n * ```ts\n * import * as queries from './graphql/queries';\n *\n * //\n * // |-- correctly typed graphql response containing a Widget\n * // v\n * const queryResult = await graphql({\n * \tquery: queries.getWidget,\n * \tvariables: {\n * \t\tid: \"abc\", // <-- type hinted/enforced\n * \t},\n * });\n *\n * //\n * // |-- a correctly typed Widget\n * // v\n * const fetchedWidget = queryResult.data?.getWidget!;\n * ```\n *\n * ## Custom input + result types\n *\n * To provide input types (`variables`) and result types:\n *\n * ```ts\n * type GetById_NameOnly = {\n * \tvariables: {\n * \t\tid: string\n * \t},\n * \tresult: Promise<{\n * \t\tdata: { getWidget: { name: string } }\n * \t}>\n * }\n *\n * //\n * // |-- type is GetById_NameOnly[\"result\"]\n * // v\n * const result = graphql<GetById_NameOnly>({\n * \tquery: \"...\",\n * \tvariables: { id: \"abc\" } // <-- type of GetById_NameOnly[\"variables\"]\n * });\n * ```\n *\n * ## Custom result type only\n *\n * To specify result types only, use a type that is *not* in the `{variables, result}` shape:\n *\n * ```ts\n * type MyResultType = Promise<{\n * \tdata: {\n * \t\tgetWidget: { name: string }\n * \t}\n * }>\n *\n * //\n * // |-- type is MyResultType\n * // v\n * const result = graphql<MyResultType>({query: \"...\"});\n * ```\n *\n * @param options\n * @param additionalHeaders\n */\nfunction graphql(options, additionalHeaders) {\n // inject client-level auth\n options.authMode = options.authMode || this[types_1.__authMode];\n options.authToken = options.authToken || this[types_1.__authToken];\n /**\n * The correctness of these typings depends on correct string branding or overrides.\n * Neither of these can actually be validated at runtime. Hence, we don't perform\n * any validation or type-guarding here.\n */\n const result = GraphQLAPI_1.GraphQLAPI.graphql(this[types_1.__amplify], options, additionalHeaders);\n return result;\n}\nexports.graphql = graphql;\n/**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\nfunction cancel(promise, message) {\n return GraphQLAPI_1.GraphQLAPI.cancel(promise, message);\n}\nexports.cancel = cancel;\n/**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @returns - A boolean indicating if the error was from an api request cancellation\n */\nfunction isCancelError(error) {\n return GraphQLAPI_1.GraphQLAPI.isCancelError(error);\n}\nexports.isCancelError = isCancelError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AAClE,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE;AAC7C;AACA,IAAI,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpE,IAAI,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AACvE;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACxG,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAClC,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;AACxB;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
|
|
@@ -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.NO_ENDPOINT = exports.NO_AUTH_TOKEN_HEADER = exports.NO_SIGNED_IN_USER = exports.NO_VALID_AUTH_TOKEN = exports.NO_VALID_CREDENTIALS = exports.NO_API_KEY = void 0;
|
|
7
|
+
const types_1 = require("../../types");
|
|
8
|
+
exports.NO_API_KEY = {
|
|
9
|
+
name: 'NoApiKey',
|
|
10
|
+
// ideal: No API key configured.
|
|
11
|
+
message: types_1.GraphQLAuthError.NO_API_KEY,
|
|
12
|
+
recoverySuggestion: 'The API request was made with `authMode: "apiKey"` but no API Key was passed into `Amplify.configure()`. Review if your API key is passed into the `Amplify.configure()` function.',
|
|
13
|
+
};
|
|
14
|
+
exports.NO_VALID_CREDENTIALS = {
|
|
15
|
+
name: 'NoCredentials',
|
|
16
|
+
// ideal: No auth credentials available.
|
|
17
|
+
message: types_1.GraphQLAuthError.NO_CREDENTIALS,
|
|
18
|
+
recoverySuggestion: `The API request was made with \`authMode: "iam"\` but no authentication credentials are available.
|
|
19
|
+
|
|
20
|
+
If you intended to make a request using an authenticated role, review if your user is signed in before making the request.
|
|
21
|
+
|
|
22
|
+
If you intend to make a request using an unauthenticated role or also known as "guest access", verify if "Auth.Cognito.allowGuestAccess" is set to "true" in the \`Amplify.configure()\` function.`,
|
|
23
|
+
};
|
|
24
|
+
exports.NO_VALID_AUTH_TOKEN = {
|
|
25
|
+
name: 'NoValidAuthTokens',
|
|
26
|
+
// ideal: No valid JWT auth token provided to make the API request..
|
|
27
|
+
message: types_1.GraphQLAuthError.NO_FEDERATED_JWT,
|
|
28
|
+
recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',
|
|
29
|
+
};
|
|
30
|
+
exports.NO_SIGNED_IN_USER = {
|
|
31
|
+
name: 'NoSignedUser',
|
|
32
|
+
// ideal: Couldn't retrieve authentication credentials to make the API request.
|
|
33
|
+
message: types_1.GraphQLAuthError.NO_CURRENT_USER,
|
|
34
|
+
recoverySuggestion: 'Review the underlying exception field for more details. If you intended to make an authenticated API request, review if the current user is signed in.',
|
|
35
|
+
};
|
|
36
|
+
exports.NO_AUTH_TOKEN_HEADER = {
|
|
37
|
+
name: 'NoAuthorizationHeader',
|
|
38
|
+
// ideal: Authorization header not specified.
|
|
39
|
+
message: types_1.GraphQLAuthError.NO_AUTH_TOKEN,
|
|
40
|
+
recoverySuggestion: 'The API request was made with `authMode: "lambda"` but no `authToken` is set. Review if a valid authToken is passed into the request options or in the `Amplify.configure()` function.',
|
|
41
|
+
};
|
|
42
|
+
exports.NO_ENDPOINT = {
|
|
43
|
+
name: 'NoEndpoint',
|
|
44
|
+
message: 'No GraphQL endpoint configured in `Amplify.configure()`.',
|
|
45
|
+
recoverySuggestion: 'Review if the GraphQL API endpoint is set in the `Amplify.configure()` function.',
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/utils/errors/constants.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.NO_ENDPOINT = exports.NO_AUTH_TOKEN_HEADER = exports.NO_SIGNED_IN_USER = exports.NO_VALID_AUTH_TOKEN = exports.NO_VALID_CREDENTIALS = exports.NO_API_KEY = void 0;\nconst types_1 = require(\"../../types\");\nexports.NO_API_KEY = {\n name: 'NoApiKey',\n // ideal: No API key configured.\n message: types_1.GraphQLAuthError.NO_API_KEY,\n recoverySuggestion: 'The API request was made with `authMode: \"apiKey\"` but no API Key was passed into `Amplify.configure()`. Review if your API key is passed into the `Amplify.configure()` function.',\n};\nexports.NO_VALID_CREDENTIALS = {\n name: 'NoCredentials',\n // ideal: No auth credentials available.\n message: types_1.GraphQLAuthError.NO_CREDENTIALS,\n recoverySuggestion: `The API request was made with \\`authMode: \"iam\"\\` but no authentication credentials are available.\n\nIf you intended to make a request using an authenticated role, review if your user is signed in before making the request.\n\nIf you intend to make a request using an unauthenticated role or also known as \"guest access\", verify if \"Auth.Cognito.allowGuestAccess\" is set to \"true\" in the \\`Amplify.configure()\\` function.`,\n};\nexports.NO_VALID_AUTH_TOKEN = {\n name: 'NoValidAuthTokens',\n // ideal: No valid JWT auth token provided to make the API request..\n message: types_1.GraphQLAuthError.NO_FEDERATED_JWT,\n recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',\n};\nexports.NO_SIGNED_IN_USER = {\n name: 'NoSignedUser',\n // ideal: Couldn't retrieve authentication credentials to make the API request.\n message: types_1.GraphQLAuthError.NO_CURRENT_USER,\n recoverySuggestion: 'Review the underlying exception field for more details. If you intended to make an authenticated API request, review if the current user is signed in.',\n};\nexports.NO_AUTH_TOKEN_HEADER = {\n name: 'NoAuthorizationHeader',\n // ideal: Authorization header not specified.\n message: types_1.GraphQLAuthError.NO_AUTH_TOKEN,\n recoverySuggestion: 'The API request was made with `authMode: \"lambda\"` but no `authToken` is set. Review if a valid authToken is passed into the request options or in the `Amplify.configure()` function.',\n};\nexports.NO_ENDPOINT = {\n name: 'NoEndpoint',\n message: 'No GraphQL endpoint configured in `Amplify.configure()`.',\n recoverySuggestion: 'Review if the GraphQL API endpoint is set in the `Amplify.configure()` function.',\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;AAC1K,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,OAAO,CAAC,UAAU,GAAG;AACrB,IAAI,IAAI,EAAE,UAAU;AACpB;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU;AAChD,IAAI,kBAAkB,EAAE,oLAAoL;AAC5M,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG;AAC/B,IAAI,IAAI,EAAE,eAAe;AACzB;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,cAAc;AACpD,IAAI,kBAAkB,EAAE,CAAC;AACzB;AACA;AACA;AACA,kMAAkM,CAAC;AACnM,CAAC,CAAC;AACF,OAAO,CAAC,mBAAmB,GAAG;AAC9B,IAAI,IAAI,EAAE,mBAAmB;AAC7B;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,gBAAgB;AACtD,IAAI,kBAAkB,EAAE,gGAAgG;AACxH,CAAC,CAAC;AACF,OAAO,CAAC,iBAAiB,GAAG;AAC5B,IAAI,IAAI,EAAE,cAAc;AACxB;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,eAAe;AACrD,IAAI,kBAAkB,EAAE,wJAAwJ;AAChL,CAAC,CAAC;AACF,OAAO,CAAC,oBAAoB,GAAG;AAC/B,IAAI,IAAI,EAAE,uBAAuB;AACjC;AACA,IAAI,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,aAAa;AACnD,IAAI,kBAAkB,EAAE,wLAAwL;AAChN,CAAC,CAAC;AACF,OAAO,CAAC,WAAW,GAAG;AACtB,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,OAAO,EAAE,0DAA0D;AACvE,IAAI,kBAAkB,EAAE,kFAAkF;AAC1G,CAAC;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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.createGraphQLResultWithError = void 0;
|
|
7
|
+
const graphql_1 = require("graphql");
|
|
8
|
+
const createGraphQLResultWithError = (error) => {
|
|
9
|
+
return {
|
|
10
|
+
data: {},
|
|
11
|
+
errors: [new graphql_1.GraphQLError(error.message, null, null, null, null, error)],
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.createGraphQLResultWithError = createGraphQLResultWithError;
|
|
15
|
+
//# sourceMappingURL=createGraphQLResultWithError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGraphQLResultWithError.js","sources":["../../../../src/utils/errors/createGraphQLResultWithError.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.createGraphQLResultWithError = void 0;\nconst graphql_1 = require(\"graphql\");\nconst createGraphQLResultWithError = (error) => {\n return {\n data: {},\n errors: [new graphql_1.GraphQLError(error.message, null, null, null, null, error)],\n };\n};\nexports.createGraphQLResultWithError = createGraphQLResultWithError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,4BAA4B,GAAG,KAAK,CAAC,CAAC;AAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACrC,MAAM,4BAA4B,GAAG,CAAC,KAAK,KAAK;AAChD,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,EAAE;AAChB,QAAQ,MAAM,EAAE,CAAC,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1F,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,4BAA4B,GAAG,4BAA4B;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
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.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.GraphQLApiError = void 0;
|
|
6
|
+
exports.createGraphQLResultWithError = exports.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.GraphQLApiError = void 0;
|
|
7
7
|
var GraphQLApiError_1 = require("./GraphQLApiError");
|
|
8
8
|
Object.defineProperty(exports, "GraphQLApiError", { enumerable: true, get: function () { return GraphQLApiError_1.GraphQLApiError; } });
|
|
9
9
|
var assertValidationError_1 = require("./assertValidationError");
|
|
@@ -11,4 +11,6 @@ Object.defineProperty(exports, "assertValidationError", { enumerable: true, get:
|
|
|
11
11
|
var validation_1 = require("./validation");
|
|
12
12
|
Object.defineProperty(exports, "APIValidationErrorCode", { enumerable: true, get: function () { return validation_1.APIValidationErrorCode; } });
|
|
13
13
|
Object.defineProperty(exports, "validationErrorMap", { enumerable: true, get: function () { return validation_1.validationErrorMap; } });
|
|
14
|
+
var createGraphQLResultWithError_1 = require("./createGraphQLResultWithError");
|
|
15
|
+
Object.defineProperty(exports, "createGraphQLResultWithError", { enumerable: true, get: function () { return createGraphQLResultWithError_1.createGraphQLResultWithError; } });
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/utils/errors/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.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.GraphQLApiError = void 0;\nvar GraphQLApiError_1 = require(\"./GraphQLApiError\");\nObject.defineProperty(exports, \"GraphQLApiError\", { enumerable: true, get: function () { return GraphQLApiError_1.GraphQLApiError; } });\nvar assertValidationError_1 = require(\"./assertValidationError\");\nObject.defineProperty(exports, \"assertValidationError\", { enumerable: true, get: function () { return assertValidationError_1.assertValidationError; } });\nvar validation_1 = require(\"./validation\");\nObject.defineProperty(exports, \"APIValidationErrorCode\", { enumerable: true, get: function () { return validation_1.APIValidationErrorCode; } });\nObject.defineProperty(exports, \"validationErrorMap\", { enumerable: true, get: function () { return validation_1.validationErrorMap; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/utils/errors/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.createGraphQLResultWithError = exports.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.GraphQLApiError = void 0;\nvar GraphQLApiError_1 = require(\"./GraphQLApiError\");\nObject.defineProperty(exports, \"GraphQLApiError\", { enumerable: true, get: function () { return GraphQLApiError_1.GraphQLApiError; } });\nvar assertValidationError_1 = require(\"./assertValidationError\");\nObject.defineProperty(exports, \"assertValidationError\", { enumerable: true, get: function () { return assertValidationError_1.assertValidationError; } });\nvar validation_1 = require(\"./validation\");\nObject.defineProperty(exports, \"APIValidationErrorCode\", { enumerable: true, get: function () { return validation_1.APIValidationErrorCode; } });\nObject.defineProperty(exports, \"validationErrorMap\", { enumerable: true, get: function () { return validation_1.validationErrorMap; } });\nvar createGraphQLResultWithError_1 = require(\"./createGraphQLResultWithError\");\nObject.defineProperty(exports, \"createGraphQLResultWithError\", { enumerable: true, get: function () { return createGraphQLResultWithError_1.createGraphQLResultWithError; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACtK,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,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,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC3C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,wBAAwB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,YAAY,CAAC,sBAAsB,CAAC,EAAE,EAAE,CAAC,CAAC;AACjJ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,YAAY,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC,CAAC;AACzI,IAAI,8BAA8B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAC/E,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,8BAA8B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,8BAA8B,CAAC,4BAA4B,CAAC,EAAE,EAAE,CAAC;;"}
|
|
@@ -3,16 +3,16 @@
|
|
|
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.
|
|
6
|
+
exports.repackageUnauthorizedError = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Checks to see if the given response or subscription message contains an
|
|
9
|
-
*
|
|
9
|
+
* Unauthorized error. If it does, it changes the error message to include instructions
|
|
10
10
|
* for the app developer.
|
|
11
11
|
*/
|
|
12
|
-
function
|
|
12
|
+
function repackageUnauthorizedError(content) {
|
|
13
13
|
if (content.errors && Array.isArray(content.errors)) {
|
|
14
14
|
content.errors.forEach(e => {
|
|
15
|
-
if (
|
|
15
|
+
if (isUnauthorizedError(e)) {
|
|
16
16
|
e.message = 'Unauthorized';
|
|
17
17
|
e.recoverySuggestion =
|
|
18
18
|
`If you're calling an Amplify-generated API, make sure ` +
|
|
@@ -23,10 +23,10 @@ function repackageUnauthError(content) {
|
|
|
23
23
|
}
|
|
24
24
|
return content;
|
|
25
25
|
}
|
|
26
|
-
exports.
|
|
27
|
-
function
|
|
26
|
+
exports.repackageUnauthorizedError = repackageUnauthorizedError;
|
|
27
|
+
function isUnauthorizedError(error) {
|
|
28
28
|
// Error pattern corresponding to appsync calls
|
|
29
|
-
if (error?.
|
|
29
|
+
if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
// Error pattern corresponding to appsync subscriptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repackageAuthError.js","sources":["../../../../src/utils/errors/repackageAuthError.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.
|
|
1
|
+
{"version":3,"file":"repackageAuthError.js","sources":["../../../../src/utils/errors/repackageAuthError.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.repackageUnauthorizedError = void 0;\n/**\n * Checks to see if the given response or subscription message contains an\n * Unauthorized error. If it does, it changes the error message to include instructions\n * for the app developer.\n */\nfunction repackageUnauthorizedError(content) {\n if (content.errors && Array.isArray(content.errors)) {\n content.errors.forEach(e => {\n if (isUnauthorizedError(e)) {\n e.message = 'Unauthorized';\n e.recoverySuggestion =\n `If you're calling an Amplify-generated API, make sure ` +\n `to set the \"authMode\" in generateClient({ authMode: '...' }) to the backend authorization ` +\n `rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;\n }\n });\n }\n return content;\n}\nexports.repackageUnauthorizedError = repackageUnauthorizedError;\nfunction isUnauthorizedError(error) {\n // Error pattern corresponding to appsync calls\n if (error?.originalError?.name?.startsWith('UnauthorizedException')) {\n return true;\n }\n // Error pattern corresponding to appsync subscriptions\n if (error.message?.startsWith('Connection failed:') &&\n error.message?.includes('Permission denied')) {\n return true;\n }\n return false;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC5C;AACA;AACA;AACA;AACA;AACA,SAAS,0BAA0B,CAAC,OAAO,EAAE;AAC7C,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzD,QAAQ,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;AACpC,YAAY,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AACxC,gBAAgB,CAAC,CAAC,OAAO,GAAG,cAAc,CAAC;AAC3C,gBAAgB,CAAC,CAAC,kBAAkB;AACpC,oBAAoB,CAAC,sDAAsD,CAAC;AAC5E,wBAAwB,CAAC,0FAA0F,CAAC;AACpH,wBAAwB,CAAC,oEAAoE,CAAC,CAAC;AAC/F,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB,CAAC;AACD,OAAO,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;AAChE,SAAS,mBAAmB,CAAC,KAAK,EAAE;AACpC;AACA,IAAI,IAAI,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,CAAC,uBAAuB,CAAC,EAAE;AACzE,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL;AACA,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,oBAAoB,CAAC;AACvD,QAAQ,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE;AACtD,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;"}
|
|
@@ -16,6 +16,12 @@ function resolveOwnerFields(model) {
|
|
|
16
16
|
if (rule.allow === 'owner') {
|
|
17
17
|
ownerFields.add(rule.ownerField || 'owner');
|
|
18
18
|
}
|
|
19
|
+
else if (rule.allow === 'groups' && rule.groupsField !== undefined) {
|
|
20
|
+
// only valid for dynamic group(s)
|
|
21
|
+
// static group auth will have an array of predefined groups in the attribute, groups: string[]
|
|
22
|
+
// but `groupsField` will be undefined
|
|
23
|
+
ownerFields.add(rule.groupsField);
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
}
|
|
@@ -1 +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;;"}
|
|
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 else if (rule.allow === 'groups' && rule.groupsField !== undefined) {\n // only valid for dynamic group(s)\n // static group auth will have an array of predefined groups in the attribute, groups: string[]\n // but `groupsField` will be undefined\n ownerFields.add(rule.groupsField);\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,qBAAqB,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;AACpF;AACA;AACA;AACA,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACtD,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;;"}
|
package/dist/esm/GraphQLAPI.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
-
import { GraphQLOptions, GraphQLResult } from './types';
|
|
3
|
-
import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
|
|
4
2
|
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
5
3
|
import { Observable } from 'rxjs';
|
|
4
|
+
import { GraphQLOptions, GraphQLResult } from './types';
|
|
5
|
+
import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
|
|
6
6
|
export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
|
|
7
7
|
query: any;
|
|
8
8
|
variables: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import { ApiAction, Category } from '@aws-amplify/core/internals/utils';\nimport { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';\nexport const graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\n/**\n * Export Cloud Logic APIs\n */\nexport class GraphQLAPIClass extends InternalGraphQLAPIClass {\n getModuleName() {\n return 'GraphQLAPI';\n }\n /**\n * Executes a GraphQL operation\n *\n * @param options - GraphQL Options\n * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config\n * @returns An Observable if the query is a subscription query, else a promise of the graphql result.\n */\n graphql(amplify, options, additionalHeaders) {\n return super.graphql(amplify, options, additionalHeaders, {\n category: Category.API,\n action: ApiAction.GraphQl,\n });\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param error - Any error\n * @returns A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return super.isCancelError(error);\n }\n /**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns A boolean indicating if the request was cancelled\n */\n cancel(request, message) {\n return super.cancel(request, message);\n }\n}\nexport const GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;;AAEY,MAAC,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,MAAM;AACvE,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,SAAS;AACb,CAAC,EAAE;AACH;AACA;AACA;AACO,MAAM,eAAe,SAAS,uBAAuB,CAAC;AAC7D,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY,CAAC;AAC5B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAClC,YAAY,MAAM,EAAE,SAAS,CAAC,OAAO;AACrC,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,CAAC;AACW,MAAC,UAAU,GAAG,IAAI,eAAe;;;;"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import {
|
|
2
|
+
import { CustomUserAgentDetails, DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
3
4
|
import { PubSubContentObserver } from '../../types/PubSub';
|
|
4
5
|
import { SUBSCRIPTION_STATUS } from '../constants';
|
|
5
|
-
|
|
6
|
-
export type ObserverQuery = {
|
|
6
|
+
export interface ObserverQuery {
|
|
7
7
|
observer: PubSubContentObserver;
|
|
8
8
|
query: string;
|
|
9
9
|
variables: Record<string, DocumentType>;
|
|
10
10
|
subscriptionState: SUBSCRIPTION_STATUS;
|
|
11
|
-
subscriptionReadyCallback
|
|
12
|
-
subscriptionFailedCallback?:
|
|
11
|
+
subscriptionReadyCallback?(): void;
|
|
12
|
+
subscriptionFailedCallback?(reason?: any): void;
|
|
13
13
|
startAckTimeoutId?: ReturnType<typeof setTimeout>;
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
export interface AWSAppSyncRealTimeProviderOptions {
|
|
16
16
|
appSyncGraphqlEndpoint?: string;
|
|
17
17
|
authenticationType?: GraphQLAuthMode;
|
|
@@ -19,7 +19,7 @@ export interface AWSAppSyncRealTimeProviderOptions {
|
|
|
19
19
|
variables?: Record<string, DocumentType>;
|
|
20
20
|
apiKey?: string;
|
|
21
21
|
region?: string;
|
|
22
|
-
libraryConfigHeaders
|
|
22
|
+
libraryConfigHeaders?(): Promise<Record<string, unknown> | Headers>;
|
|
23
23
|
additionalHeaders?: CustomHeaders;
|
|
24
24
|
additionalCustomHeaders?: Record<string, string>;
|
|
25
25
|
authToken?: string;
|
|
@@ -36,7 +36,7 @@ export declare class AWSAppSyncRealTimeProvider {
|
|
|
36
36
|
private readonly connectionStateMonitor;
|
|
37
37
|
private readonly reconnectionMonitor;
|
|
38
38
|
private connectionStateMonitorSubscription;
|
|
39
|
-
constructor(
|
|
39
|
+
constructor();
|
|
40
40
|
/**
|
|
41
41
|
* Mark the socket closed and release all active listeners
|
|
42
42
|
*/
|
|
@@ -14,10 +14,10 @@ const logger = new ConsoleLogger('AWSAppSyncRealTimeProvider');
|
|
|
14
14
|
const dispatchApiEvent = (payload) => {
|
|
15
15
|
Hub.dispatch('api', payload, 'PubSub', AMPLIFY_SYMBOL);
|
|
16
16
|
};
|
|
17
|
-
const standardDomainPattern = /^https:\/\/\w{26}\.appsync
|
|
17
|
+
const standardDomainPattern = /^https:\/\/\w{26}\.appsync-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/graphql$/i;
|
|
18
18
|
const customDomainPath = '/realtime';
|
|
19
19
|
class AWSAppSyncRealTimeProvider {
|
|
20
|
-
constructor(
|
|
20
|
+
constructor() {
|
|
21
21
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
22
22
|
this.keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
|
|
23
23
|
this.subscriptionObserverMap = new Map();
|
|
@@ -119,10 +119,9 @@ class AWSAppSyncRealTimeProvider {
|
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
let reconnectSubscription;
|
|
123
122
|
// Add an observable to the reconnection list to manage reconnection for this subscription
|
|
124
|
-
reconnectSubscription = new Observable(
|
|
125
|
-
this.reconnectionMonitor.addObserver(
|
|
123
|
+
const reconnectSubscription = new Observable(reconnectSubscriptionObserver => {
|
|
124
|
+
this.reconnectionMonitor.addObserver(reconnectSubscriptionObserver);
|
|
126
125
|
}).subscribe(() => {
|
|
127
126
|
startSubscription();
|
|
128
127
|
});
|
|
@@ -245,7 +244,7 @@ class AWSAppSyncRealTimeProvider {
|
|
|
245
244
|
subscriptionReadyCallback,
|
|
246
245
|
subscriptionFailedCallback,
|
|
247
246
|
startAckTimeoutId: setTimeout(() => {
|
|
248
|
-
this._timeoutStartSubscriptionAck
|
|
247
|
+
this._timeoutStartSubscriptionAck(subscriptionId);
|
|
249
248
|
}, START_ACK_TIMEOUT),
|
|
250
249
|
});
|
|
251
250
|
if (this.awsRealTimeSocket) {
|
|
@@ -257,7 +256,7 @@ class AWSAppSyncRealTimeProvider {
|
|
|
257
256
|
logger.debug({ err });
|
|
258
257
|
const message = String(err.message ?? '');
|
|
259
258
|
// Resolving to give the state observer time to propogate the update
|
|
260
|
-
|
|
259
|
+
this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
|
|
261
260
|
// Capture the error only when the network didn't cause disruption
|
|
262
261
|
if (this.connectionState !== ConnectionState.ConnectionDisruptedPendingNetwork) {
|
|
263
262
|
// When the error is non-retriable, error out the observable
|
|
@@ -287,15 +286,15 @@ class AWSAppSyncRealTimeProvider {
|
|
|
287
286
|
const { subscriptionState } = subscriptionObserver;
|
|
288
287
|
// This in case unsubscribe is invoked before sending start subscription message
|
|
289
288
|
if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
|
|
290
|
-
return new Promise((
|
|
291
|
-
const { observer, subscriptionState, variables, query } = subscriptionObserver;
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
const { observer, subscriptionState: observedSubscriptionState, variables, query, } = subscriptionObserver;
|
|
292
291
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
293
292
|
observer,
|
|
294
|
-
subscriptionState,
|
|
293
|
+
subscriptionState: observedSubscriptionState,
|
|
295
294
|
variables,
|
|
296
295
|
query,
|
|
297
|
-
subscriptionReadyCallback:
|
|
298
|
-
subscriptionFailedCallback:
|
|
296
|
+
subscriptionReadyCallback: resolve,
|
|
297
|
+
subscriptionFailedCallback: reject,
|
|
299
298
|
});
|
|
300
299
|
});
|
|
301
300
|
}
|
|
@@ -406,7 +405,9 @@ class AWSAppSyncRealTimeProvider {
|
|
|
406
405
|
clearTimeout(this.keepAliveTimeoutId);
|
|
407
406
|
if (this.keepAliveAlertTimeoutId)
|
|
408
407
|
clearTimeout(this.keepAliveAlertTimeoutId);
|
|
409
|
-
this.keepAliveTimeoutId = setTimeout(() =>
|
|
408
|
+
this.keepAliveTimeoutId = setTimeout(() => {
|
|
409
|
+
this._errorDisconnect(CONTROL_MSG.TIMEOUT_DISCONNECT);
|
|
410
|
+
}, this.keepAliveTimeout);
|
|
410
411
|
this.keepAliveAlertTimeoutId = setTimeout(() => {
|
|
411
412
|
this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE_MISSED);
|
|
412
413
|
}, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT);
|
|
@@ -470,8 +471,10 @@ class AWSAppSyncRealTimeProvider {
|
|
|
470
471
|
if (this.socketStatus === SOCKET_STATUS.READY) {
|
|
471
472
|
return;
|
|
472
473
|
}
|
|
473
|
-
|
|
474
|
-
|
|
474
|
+
// TODO(Eslint): refactor to now use async function as the promise executor
|
|
475
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
476
|
+
return new Promise(async (resolve, reject) => {
|
|
477
|
+
this.promiseArray.push({ res: resolve, rej: reject });
|
|
475
478
|
if (this.socketStatus === SOCKET_STATUS.CLOSED) {
|
|
476
479
|
try {
|
|
477
480
|
this.socketStatus = SOCKET_STATUS.CONNECTING;
|
|
@@ -514,7 +517,9 @@ class AWSAppSyncRealTimeProvider {
|
|
|
514
517
|
}
|
|
515
518
|
catch (err) {
|
|
516
519
|
logger.debug('Connection exited with', err);
|
|
517
|
-
this.promiseArray.forEach(({ rej }) =>
|
|
520
|
+
this.promiseArray.forEach(({ rej }) => {
|
|
521
|
+
rej(err);
|
|
522
|
+
});
|
|
518
523
|
this.promiseArray = [];
|
|
519
524
|
if (this.awsRealTimeSocket &&
|
|
520
525
|
this.awsRealTimeSocket.readyState === WebSocket.OPEN) {
|
|
@@ -536,23 +541,23 @@ class AWSAppSyncRealTimeProvider {
|
|
|
536
541
|
// Step 1: connect websocket
|
|
537
542
|
try {
|
|
538
543
|
await (() => {
|
|
539
|
-
return new Promise((
|
|
544
|
+
return new Promise((resolve, reject) => {
|
|
540
545
|
const newSocket = this.getNewWebSocket(awsRealTimeUrl, 'graphql-ws');
|
|
541
546
|
newSocket.onerror = () => {
|
|
542
547
|
logger.debug(`WebSocket connection error`);
|
|
543
548
|
};
|
|
544
549
|
newSocket.onclose = () => {
|
|
545
|
-
|
|
550
|
+
reject(new Error('Connection handshake error'));
|
|
546
551
|
};
|
|
547
552
|
newSocket.onopen = () => {
|
|
548
553
|
this.awsRealTimeSocket = newSocket;
|
|
549
|
-
|
|
554
|
+
resolve();
|
|
550
555
|
};
|
|
551
556
|
});
|
|
552
557
|
})();
|
|
553
558
|
// Step 2: wait for ack from AWS AppSyncReaTime after sending init
|
|
554
559
|
await (() => {
|
|
555
|
-
return new Promise((
|
|
560
|
+
return new Promise((resolve, reject) => {
|
|
556
561
|
if (this.awsRealTimeSocket) {
|
|
557
562
|
let ackOk = false;
|
|
558
563
|
this.awsRealTimeSocket.onerror = error => {
|
|
@@ -560,7 +565,7 @@ class AWSAppSyncRealTimeProvider {
|
|
|
560
565
|
};
|
|
561
566
|
this.awsRealTimeSocket.onclose = event => {
|
|
562
567
|
logger.debug(`WebSocket closed ${event.reason}`);
|
|
563
|
-
|
|
568
|
+
reject(new Error(JSON.stringify(event)));
|
|
564
569
|
};
|
|
565
570
|
this.awsRealTimeSocket.onmessage = (message) => {
|
|
566
571
|
if (typeof message.data !== 'string') {
|
|
@@ -584,25 +589,29 @@ class AWSAppSyncRealTimeProvider {
|
|
|
584
589
|
this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);
|
|
585
590
|
};
|
|
586
591
|
}
|
|
587
|
-
|
|
592
|
+
resolve('Cool, connected to AWS AppSyncRealTime');
|
|
588
593
|
return;
|
|
589
594
|
}
|
|
590
595
|
if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
|
|
591
596
|
const { payload: { errors: [{ errorType = '', errorCode = 0 } = {}] = [], } = {}, } = data;
|
|
592
|
-
|
|
597
|
+
// TODO(Eslint): refactor to reject an Error object instead of a plain object
|
|
598
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
599
|
+
reject({ errorType, errorCode });
|
|
593
600
|
}
|
|
594
601
|
};
|
|
595
602
|
const gqlInit = {
|
|
596
603
|
type: MESSAGE_TYPES.GQL_CONNECTION_INIT,
|
|
597
604
|
};
|
|
598
605
|
this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
599
|
-
const checkAckOk = (
|
|
600
|
-
if (!
|
|
606
|
+
const checkAckOk = (targetAckOk) => {
|
|
607
|
+
if (!targetAckOk) {
|
|
601
608
|
this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);
|
|
602
|
-
|
|
609
|
+
reject(new Error(`Connection timeout: ack from AWSAppSyncRealTime was not received after ${CONNECTION_INIT_TIMEOUT} ms`));
|
|
603
610
|
}
|
|
604
611
|
};
|
|
605
|
-
setTimeout(() =>
|
|
612
|
+
setTimeout(() => {
|
|
613
|
+
checkAckOk(ackOk);
|
|
614
|
+
}, CONNECTION_INIT_TIMEOUT);
|
|
606
615
|
}
|
|
607
616
|
});
|
|
608
617
|
})();
|
|
@@ -664,7 +673,7 @@ class AWSAppSyncRealTimeProvider {
|
|
|
664
673
|
}
|
|
665
674
|
async _awsRealTimeApiKeyHeader({ apiKey, host, }) {
|
|
666
675
|
const dt = new Date();
|
|
667
|
-
const dtStr = dt.toISOString().replace(/[
|
|
676
|
+
const dtStr = dt.toISOString().replace(/[:-]|\.\d{3}/g, '');
|
|
668
677
|
return {
|
|
669
678
|
host,
|
|
670
679
|
'x-amz-date': dtStr,
|
|
@@ -683,7 +692,7 @@ class AWSAppSyncRealTimeProvider {
|
|
|
683
692
|
method: 'POST',
|
|
684
693
|
headers: { ...AWS_APPSYNC_REALTIME_HEADERS },
|
|
685
694
|
};
|
|
686
|
-
const
|
|
695
|
+
const signedParams = signRequest({
|
|
687
696
|
headers: request.headers,
|
|
688
697
|
method: request.method,
|
|
689
698
|
url: new AmplifyUrl(request.url),
|
|
@@ -694,7 +703,7 @@ class AWSAppSyncRealTimeProvider {
|
|
|
694
703
|
signingRegion: endpointInfo.region,
|
|
695
704
|
signingService: endpointInfo.service,
|
|
696
705
|
});
|
|
697
|
-
return
|
|
706
|
+
return signedParams.headers;
|
|
698
707
|
}
|
|
699
708
|
_customAuthHeader({ host, additionalCustomHeaders, }) {
|
|
700
709
|
/**
|
|
@@ -702,7 +711,7 @@ class AWSAppSyncRealTimeProvider {
|
|
|
702
711
|
* the headers that are returned by that function will already have been
|
|
703
712
|
* provided before this function is called.
|
|
704
713
|
*/
|
|
705
|
-
if (!additionalCustomHeaders?.
|
|
714
|
+
if (!additionalCustomHeaders?.Authorization) {
|
|
706
715
|
throw new Error('No auth token specified');
|
|
707
716
|
}
|
|
708
717
|
return {
|