@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
|
@@ -6,7 +6,7 @@ import { getSecondaryIndexesFromSchemaModel } from '../clientUtils.mjs';
|
|
|
6
6
|
|
|
7
7
|
function generateModelsProperty(client, params) {
|
|
8
8
|
const models = {};
|
|
9
|
-
const config = params
|
|
9
|
+
const { config } = params;
|
|
10
10
|
const useContext = params.amplify === null;
|
|
11
11
|
if (!config) {
|
|
12
12
|
throw new Error('generateModelsProperty cannot retrieve Amplify config');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../src/internals/server/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from '../APIClient';\nimport { listFactory } from '../operations/list';\nimport { indexQueryFactory } from '../operations/indexQuery';\nimport { getFactory } from '../operations/get';\nimport { getSecondaryIndexesFromSchemaModel } from '../clientUtils';\nexport function generateModelsProperty(client, params) {\n const models = {};\n const config = params
|
|
1
|
+
{"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../src/internals/server/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from '../APIClient';\nimport { listFactory } from '../operations/list';\nimport { indexQueryFactory } from '../operations/indexQuery';\nimport { getFactory } from '../operations/get';\nimport { getSecondaryIndexesFromSchemaModel } from '../clientUtils';\nexport function generateModelsProperty(client, params) {\n const models = {};\n const { config } = params;\n const useContext = params.amplify === null;\n if (!config) {\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\n }\n if (!config.API?.GraphQL) {\n return {};\n }\n const modelIntrospection = config.API.GraphQL.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SSR_UNSUPORTED_OPS = [\n 'ONCREATE',\n 'ONUPDATE',\n 'ONDELETE',\n 'OBSERVE_QUERY',\n ];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n // subscriptions are not supported in SSR\n if (SSR_UNSUPORTED_OPS.includes(operation))\n return;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model, useContext);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, useContext);\n }\n });\n const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = indexQueryFactory(client, modelIntrospection, model, idx);\n }\n }\n return models;\n}\n"],"names":[],"mappings":";;;;;;AAKO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C,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AAC3G,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACrH,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,kCAAkC,CAAC,KAAK,CAAC,CAAC;AACxE,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACrG,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
|
|
@@ -12,8 +12,8 @@ export type ClientGenerationParams = {
|
|
|
12
12
|
/**
|
|
13
13
|
* Common options that can be used on public `generateClient()` interfaces.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export interface CommonPublicClientOptions {
|
|
16
16
|
authMode?: GraphQLAuthMode;
|
|
17
17
|
authToken?: string;
|
|
18
18
|
headers?: CustomHeaders;
|
|
19
|
-
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateEnumsProperty.mjs","sources":["../../../../../src/internals/utils/clientProperties/generateEnumsProperty.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const 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};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,qBAAqB,GAAG,CAAC,aAAa,KAAK;AACxD,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;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ModelTypes } from '@aws-amplify/data-schema-types';
|
|
2
|
-
import { V6Client } from '../../types';
|
|
3
2
|
import { GraphQLProviderConfig } from '@aws-amplify/core/internals/utils';
|
|
4
|
-
|
|
3
|
+
import { V6Client } from '../../../types';
|
|
4
|
+
export declare function generateModelsProperty<T extends Record<any, any> = never>(client: V6Client<Record<string, any>>, apiGraphQLConfig: GraphQLProviderConfig['GraphQL']): ModelTypes<T> | ModelTypes<never>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { graphQLOperationsInfo } from '
|
|
2
|
-
import { listFactory } from '
|
|
3
|
-
import { indexQueryFactory } from '
|
|
4
|
-
import { getFactory } from '
|
|
5
|
-
import { subscriptionFactory } from '
|
|
6
|
-
import { observeQueryFactory } from '
|
|
7
|
-
import { getSecondaryIndexesFromSchemaModel } from '
|
|
1
|
+
import { graphQLOperationsInfo } from '../../APIClient.mjs';
|
|
2
|
+
import { listFactory } from '../../operations/list.mjs';
|
|
3
|
+
import { indexQueryFactory } from '../../operations/indexQuery.mjs';
|
|
4
|
+
import { getFactory } from '../../operations/get.mjs';
|
|
5
|
+
import { subscriptionFactory } from '../../operations/subscription.mjs';
|
|
6
|
+
import { observeQueryFactory } from '../../operations/observeQuery.mjs';
|
|
7
|
+
import { getSecondaryIndexesFromSchemaModel } from '../../clientUtils.mjs';
|
|
8
8
|
|
|
9
9
|
function generateModelsProperty(client, apiGraphQLConfig) {
|
|
10
10
|
const models = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../../src/internals/utils/clientProperties/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from '../../APIClient';\nimport { listFactory } from '../../operations/list';\nimport { indexQueryFactory } from '../../operations/indexQuery';\nimport { getFactory } from '../../operations/get';\nimport { subscriptionFactory } from '../../operations/subscription';\nimport { observeQueryFactory } from '../../operations/observeQuery';\nimport { getSecondaryIndexesFromSchemaModel } from '../../clientUtils';\nexport function generateModelsProperty(client, apiGraphQLConfig) {\n const models = {};\n const modelIntrospection = apiGraphQLConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation);\n }\n else if (operation === 'OBSERVE_QUERY') {\n models[name][operationPrefix] = observeQueryFactory(models, model);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation);\n }\n });\n const secondaryIdxs = getSecondaryIndexesFromSchemaModel(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField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,CAAC,eAAe,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACnF,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACzG,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,kCAAkC,CAAC,KAAK,CAAC,CAAC;AACxE,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACrG,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isApiGraphQLProviderConfig.mjs","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isApiGraphQLConfig(apiGraphQLConfig) {\n return apiGraphQLConfig !== undefined;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,kBAAkB,CAAC,gBAAgB,EAAE;AACrD,IAAI,OAAO,gBAAgB,KAAK,SAAS,CAAC;AAC1C;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isConfigureEventWithResourceConfig.mjs","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isConfigureEventWithResourceConfig(payload) {\n return payload.event === 'configure';\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,kCAAkC,CAAC,OAAO,EAAE;AAC5D,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,WAAW,CAAC;AACzC;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
function isGraphQLResponseWithErrors(response) {
|
|
4
|
+
if (!response) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const r = response;
|
|
8
|
+
return Array.isArray(r.errors) && r.errors.length > 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { isGraphQLResponseWithErrors };
|
|
12
|
+
//# sourceMappingURL=isGraphQLResponseWithErrors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isGraphQLResponseWithErrors.mjs","sources":["../../../../../src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isGraphQLResponseWithErrors(response) {\n if (!response) {\n return false;\n }\n const r = response;\n return Array.isArray(r.errors) && r.errors.length > 0;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,2BAA2B,CAAC,QAAQ,EAAE;AACtD,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;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V6Client, GraphQLOptionsV6, GraphQLResponseV6 } from '../types';
|
|
2
1
|
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
2
|
+
import { GraphQLOptionsV6, GraphQLResponseV6, V6Client } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Invokes graphql operations against a graphql service, providing correct input and
|
|
5
5
|
* output types if Amplify-generated graphql from a recent version of the CLI/codegen
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { GraphQLAPI } from '../GraphQLAPI.mjs';
|
|
2
2
|
import { __authMode, __authToken, __amplify } from '../types/index.mjs';
|
|
3
3
|
|
|
4
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
6
4
|
/**
|
|
7
5
|
* Invokes graphql operations against a graphql service, providing correct input and
|
|
8
6
|
* output types if Amplify-generated graphql from a recent version of the CLI/codegen
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v6.mjs","sources":["../../../src/internals/v6.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"v6.mjs","sources":["../../../src/internals/v6.ts"],"sourcesContent":["import { GraphQLAPI } from '../GraphQLAPI';\nimport { __amplify, __authMode, __authToken, } from '../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 */\nexport function graphql(options, additionalHeaders) {\n // inject client-level auth\n options.authMode = options.authMode || this[__authMode];\n options.authToken = options.authToken || this[__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.graphql(this[__amplify], options, additionalHeaders);\n return result;\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 */\nexport function cancel(promise, message) {\n return GraphQLAPI.cancel(promise, message);\n}\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 */\nexport function isCancelError(error) {\n return GraphQLAPI.isCancelError(error);\n}\n"],"names":[],"mappings":";;;AAEA;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;AACO,SAAS,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE;AACpD;AACA,IAAI,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC5D,IAAI,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;AAC/D;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACnF,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AACzC,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,KAAK,EAAE;AACrC,IAAI,OAAO,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC3C;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export { OperationTypeNode } from 'graphql';
|
|
2
|
+
import { CustomHeaders, CustomMutations, CustomQueries, CustomSubscriptions, EnumTypes, ModelSortDirection, ModelTypes } from '@aws-amplify/data-schema-types';
|
|
3
|
+
import { DocumentNode, GraphQLError, Source } from 'graphql';
|
|
5
4
|
import { Observable } from 'rxjs';
|
|
6
|
-
import {
|
|
5
|
+
import { DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
7
6
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
7
|
+
export { OperationTypeNode } from 'graphql';
|
|
8
8
|
export { CONTROL_MSG, ConnectionState } from './PubSub';
|
|
9
9
|
export { SelectionSet } from '@aws-amplify/data-schema-types';
|
|
10
10
|
export { CommonPublicClientOptions } from '../internals/types';
|
|
@@ -24,9 +24,7 @@ export interface GraphQLOptions {
|
|
|
24
24
|
export interface GraphQLResult<T = object> {
|
|
25
25
|
data: T;
|
|
26
26
|
errors?: GraphQLError[];
|
|
27
|
-
extensions?:
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
};
|
|
27
|
+
extensions?: Record<string, any>;
|
|
30
28
|
}
|
|
31
29
|
declare const queryType: unique symbol;
|
|
32
30
|
export type GraphQLQuery<T> = T & {
|
|
@@ -56,18 +54,18 @@ export type GraphQLSubscription<T> = T & {
|
|
|
56
54
|
*
|
|
57
55
|
* This util simply makes related model properties optional recursively.
|
|
58
56
|
*/
|
|
59
|
-
export type GraphQLReturnType<T> = T extends
|
|
57
|
+
export type GraphQLReturnType<T> = T extends Record<string, unknown> ? {
|
|
60
58
|
[K in keyof T]?: GraphQLReturnType<T[K]>;
|
|
61
59
|
} : T;
|
|
62
60
|
/**
|
|
63
61
|
* Describes a paged list result from AppSync, which can either
|
|
64
62
|
* live at the top query or property (e.g., related model) level.
|
|
65
63
|
*/
|
|
66
|
-
|
|
64
|
+
interface PagedList<T, TYPENAME> {
|
|
67
65
|
__typename: TYPENAME;
|
|
68
66
|
nextToken?: string | null | undefined;
|
|
69
|
-
items:
|
|
70
|
-
}
|
|
67
|
+
items: T[];
|
|
68
|
+
}
|
|
71
69
|
/**
|
|
72
70
|
* Recursively looks through a result type and removes nulls and
|
|
73
71
|
* and undefined from `PagedList` types.
|
|
@@ -76,7 +74,7 @@ type PagedList<T, TYPENAME> = {
|
|
|
76
74
|
* array, this will only be the case when we also have errors,
|
|
77
75
|
* which will then be *thrown*.
|
|
78
76
|
*/
|
|
79
|
-
type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends
|
|
77
|
+
type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends Record<string, unknown> ? {
|
|
80
78
|
[K in keyof T]: WithListsFixed<T[K]>;
|
|
81
79
|
} : T;
|
|
82
80
|
/**
|
|
@@ -132,9 +130,9 @@ export type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptionMessage
|
|
|
132
130
|
* })
|
|
133
131
|
* ```
|
|
134
132
|
*/
|
|
135
|
-
export
|
|
133
|
+
export interface GraphqlSubscriptionMessage<T> {
|
|
136
134
|
data: T;
|
|
137
|
-
}
|
|
135
|
+
}
|
|
138
136
|
export interface AWSAppSyncRealTimeProviderOptions {
|
|
139
137
|
appSyncGraphqlEndpoint?: string;
|
|
140
138
|
authenticationType?: GraphQLAuthMode;
|
|
@@ -142,12 +140,12 @@ export interface AWSAppSyncRealTimeProviderOptions {
|
|
|
142
140
|
variables?: Record<string, unknown>;
|
|
143
141
|
apiKey?: string;
|
|
144
142
|
region?: string;
|
|
145
|
-
libraryConfigHeaders
|
|
143
|
+
libraryConfigHeaders?(): () => Promise<Record<string, unknown> | Headers>;
|
|
146
144
|
additionalHeaders?: CustomHeaders;
|
|
147
145
|
}
|
|
148
|
-
export
|
|
146
|
+
export interface AWSAppSyncRealTimeProvider {
|
|
149
147
|
subscribe(options?: AWSAppSyncRealTimeProviderOptions): Observable<Record<string, unknown>>;
|
|
150
|
-
}
|
|
148
|
+
}
|
|
151
149
|
export declare enum GraphQLAuthError {
|
|
152
150
|
NO_API_KEY = "No api-key configured",
|
|
153
151
|
NO_CURRENT_USER = "No current user",
|
|
@@ -191,7 +189,7 @@ export type GraphQLVariablesV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING extend
|
|
|
191
189
|
* The expected return type with respect to the given `FALLBACK_TYPE`
|
|
192
190
|
* and `TYPED_GQL_STRING`.
|
|
193
191
|
*/
|
|
194
|
-
export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer
|
|
192
|
+
export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer _, infer QUERY_OUT> ? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>> : TYPED_GQL_STRING extends GeneratedMutation<infer _, infer MUTATION_OUT> ? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>> : TYPED_GQL_STRING extends GeneratedSubscription<infer _, infer SUB_OUT> ? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>> : FALLBACK_TYPE extends GraphQLQuery<infer _> ? Promise<GraphQLResult<FALLBACK_TYPE>> : FALLBACK_TYPE extends GraphQLSubscription<infer _> ? GraphqlSubscriptionResult<FALLBACK_TYPE> : FALLBACK_TYPE extends GraphQLOperationType<infer _, infer CUSTOM_OUT> ? CUSTOM_OUT : UnknownGraphQLResponse;
|
|
195
193
|
/**
|
|
196
194
|
* The shape customers can use to provide `T` to `graphql<T>()` to specify both
|
|
197
195
|
* `IN` and `OUT` types (the type of `variables` and the return type, respectively).
|
|
@@ -210,10 +208,10 @@ export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends
|
|
|
210
208
|
* })
|
|
211
209
|
* ```
|
|
212
210
|
*/
|
|
213
|
-
export
|
|
211
|
+
export interface GraphQLOperationType<IN extends Record<string, DocumentType>, OUT extends Record<string, DocumentType>> {
|
|
214
212
|
variables: IN;
|
|
215
213
|
result: OUT;
|
|
216
|
-
}
|
|
214
|
+
}
|
|
217
215
|
/**
|
|
218
216
|
* Nominal type for branding generated graphql query operation strings with
|
|
219
217
|
* input and output types.
|
|
@@ -291,10 +289,13 @@ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
|
291
289
|
[__authToken]?: string;
|
|
292
290
|
[__headers]?: CustomHeaders;
|
|
293
291
|
graphql: GraphQLMethod;
|
|
294
|
-
cancel
|
|
295
|
-
isCancelError
|
|
292
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
293
|
+
isCancelError(error: any): boolean;
|
|
296
294
|
models: ModelTypes<T>;
|
|
297
295
|
enums: EnumTypes<T>;
|
|
296
|
+
queries: CustomQueries<T>;
|
|
297
|
+
mutations: CustomMutations<T>;
|
|
298
|
+
subscriptions: CustomSubscriptions<T>;
|
|
298
299
|
}>;
|
|
299
300
|
export type V6ClientSSRRequest<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
300
301
|
[__amplify]: AmplifyClassV6;
|
|
@@ -302,9 +303,12 @@ export type V6ClientSSRRequest<T extends Record<any, any> = never> = ExcludeNeve
|
|
|
302
303
|
[__authToken]?: string;
|
|
303
304
|
[__headers]?: CustomHeaders;
|
|
304
305
|
graphql: GraphQLMethodSSR;
|
|
305
|
-
cancel
|
|
306
|
-
isCancelError
|
|
306
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
307
|
+
isCancelError(error: any): boolean;
|
|
307
308
|
models: ModelTypes<T, 'REQUEST'>;
|
|
309
|
+
enums: EnumTypes<T>;
|
|
310
|
+
queries: CustomQueries<T, 'REQUEST'>;
|
|
311
|
+
mutations: CustomMutations<T, 'REQUEST'>;
|
|
308
312
|
}>;
|
|
309
313
|
export type V6ClientSSRCookies<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
310
314
|
[__amplify]: AmplifyClassV6;
|
|
@@ -312,9 +316,12 @@ export type V6ClientSSRCookies<T extends Record<any, any> = never> = ExcludeNeve
|
|
|
312
316
|
[__authToken]?: string;
|
|
313
317
|
[__headers]?: CustomHeaders;
|
|
314
318
|
graphql: GraphQLMethod;
|
|
315
|
-
cancel
|
|
316
|
-
isCancelError
|
|
319
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
320
|
+
isCancelError(error: any): boolean;
|
|
317
321
|
models: ModelTypes<T, 'COOKIES'>;
|
|
322
|
+
enums: EnumTypes<T>;
|
|
323
|
+
queries: CustomQueries<T, 'COOKIES'>;
|
|
324
|
+
mutations: CustomMutations<T, 'COOKIES'>;
|
|
318
325
|
}>;
|
|
319
326
|
export type GraphQLMethod = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>, additionalHeaders?: CustomHeaders | undefined) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
320
327
|
export type GraphQLMethodSSR = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(contextSpec: AmplifyServer.ContextSpec, options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>, additionalHeaders?: CustomHeaders | undefined) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
@@ -323,22 +330,23 @@ export type GraphQLMethodSSR = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING exten
|
|
|
323
330
|
*
|
|
324
331
|
* The knobs available for configuring `server/generateClient` internally.
|
|
325
332
|
*/
|
|
326
|
-
export
|
|
333
|
+
export interface ServerClientGenerationParams {
|
|
327
334
|
amplify: null | ((fn: (amplify: AmplifyClassV6) => Promise<any>) => Promise<any>);
|
|
328
335
|
config: ResourcesConfig;
|
|
329
|
-
}
|
|
336
|
+
}
|
|
330
337
|
export type QueryArgs = Record<string, unknown>;
|
|
331
|
-
export
|
|
338
|
+
export interface ListArgs extends Record<string, unknown> {
|
|
332
339
|
selectionSet?: string[];
|
|
333
|
-
filter?:
|
|
340
|
+
filter?: Record<string, unknown>;
|
|
341
|
+
sortDirection?: ModelSortDirection;
|
|
334
342
|
headers?: CustomHeaders;
|
|
335
|
-
}
|
|
336
|
-
export
|
|
343
|
+
}
|
|
344
|
+
export interface AuthModeParams extends Record<string, unknown> {
|
|
337
345
|
authMode?: GraphQLAuthMode;
|
|
338
346
|
authToken?: string;
|
|
339
|
-
}
|
|
340
|
-
export
|
|
347
|
+
}
|
|
348
|
+
export interface GenerateServerClientParams {
|
|
341
349
|
config: ResourcesConfig;
|
|
342
350
|
authMode?: GraphQLAuthMode;
|
|
343
351
|
authToken?: string;
|
|
344
|
-
}
|
|
352
|
+
}
|
|
@@ -2,12 +2,12 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { ConnectionState } from '../types/PubSub';
|
|
3
3
|
type LinkedConnectionState = 'connected' | 'disconnected';
|
|
4
4
|
type LinkedHealthState = 'healthy' | 'unhealthy';
|
|
5
|
-
|
|
5
|
+
interface LinkedConnectionStates {
|
|
6
6
|
networkState: LinkedConnectionState;
|
|
7
7
|
connectionState: LinkedConnectionState | 'connecting';
|
|
8
8
|
intendedConnectionState: LinkedConnectionState;
|
|
9
9
|
keepAliveState: LinkedHealthState;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export declare const CONNECTION_CHANGE: {
|
|
12
12
|
[key in 'KEEP_ALIVE_MISSED' | 'KEEP_ALIVE' | 'CONNECTION_ESTABLISHED' | 'CONNECTION_FAILED' | 'CLOSING_CONNECTION' | 'OPENING_CONNECTION' | 'CLOSED' | 'ONLINE' | 'OFFLINE']: Partial<LinkedConnectionStates>;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionStateMonitor.mjs","sources":["../../../src/utils/ConnectionStateMonitor.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable,
|
|
1
|
+
{"version":3,"file":"ConnectionStateMonitor.mjs","sources":["../../../src/utils/ConnectionStateMonitor.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable, filter, map } from 'rxjs';\nimport { ConnectionState } from '../types/PubSub';\nimport { ReachabilityMonitor } from './ReachabilityMonitor';\nexport const CONNECTION_CHANGE = {\n KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },\n KEEP_ALIVE: { keepAliveState: 'healthy' },\n CONNECTION_ESTABLISHED: { connectionState: 'connected' },\n CONNECTION_FAILED: {\n intendedConnectionState: 'disconnected',\n connectionState: 'disconnected',\n },\n CLOSING_CONNECTION: { intendedConnectionState: 'disconnected' },\n OPENING_CONNECTION: {\n intendedConnectionState: 'connected',\n connectionState: 'connecting',\n },\n CLOSED: { connectionState: 'disconnected' },\n ONLINE: { networkState: 'connected' },\n OFFLINE: { networkState: 'disconnected' },\n};\nexport class ConnectionStateMonitor {\n constructor() {\n this._networkMonitoringSubscription = undefined;\n this._linkedConnectionState = {\n networkState: 'connected',\n connectionState: 'disconnected',\n intendedConnectionState: 'disconnected',\n keepAliveState: 'healthy',\n };\n // Attempt to update the state with the current actual network state\n this._initialNetworkStateSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n this._initialNetworkStateSubscription?.unsubscribe();\n });\n this._linkedConnectionStateObservable =\n new Observable(connectionStateObserver => {\n connectionStateObserver.next(this._linkedConnectionState);\n this._linkedConnectionStateObserver = connectionStateObserver;\n });\n }\n /**\n * Turn network state monitoring on if it isn't on already\n */\n enableNetworkMonitoring() {\n // If no initial network state was discovered, stop trying\n this._initialNetworkStateSubscription?.unsubscribe();\n // Maintain the network state based on the reachability monitor\n if (this._networkMonitoringSubscription === undefined) {\n this._networkMonitoringSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n });\n }\n }\n /**\n * Turn network state monitoring off if it isn't off already\n */\n disableNetworkMonitoring() {\n this._networkMonitoringSubscription?.unsubscribe();\n this._networkMonitoringSubscription = undefined;\n }\n /**\n * Get the observable that allows us to monitor the connection state\n *\n * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates\n */\n get connectionStateObservable() {\n let previous;\n // The linked state aggregates state changes to any of the network, connection,\n // intendedConnection and keepAliveHealth. Some states will change these independent\n // states without changing the overall connection state.\n // After translating from linked states to ConnectionState, then remove any duplicates\n return this._linkedConnectionStateObservable\n .pipe(map(value => {\n return this.connectionStatesTranslator(value);\n }))\n .pipe(filter(current => {\n const toInclude = current !== previous;\n previous = current;\n return toInclude;\n }));\n }\n /*\n * Updates local connection state and emits the full state to the observer.\n */\n record(statusUpdates) {\n // Maintain the network monitor\n if (statusUpdates.intendedConnectionState === 'connected') {\n this.enableNetworkMonitoring();\n }\n else if (statusUpdates.intendedConnectionState === 'disconnected') {\n this.disableNetworkMonitoring();\n }\n // Maintain the socket state\n const newSocketStatus = {\n ...this._linkedConnectionState,\n ...statusUpdates,\n };\n this._linkedConnectionState = { ...newSocketStatus };\n this._linkedConnectionStateObserver?.next(this._linkedConnectionState);\n }\n /*\n * Translate the ConnectionState structure into a specific ConnectionState string literal union\n */\n connectionStatesTranslator({ connectionState, networkState, intendedConnectionState, keepAliveState, }) {\n if (connectionState === 'connected' && networkState === 'disconnected')\n return ConnectionState.ConnectedPendingNetwork;\n if (connectionState === 'connected' &&\n intendedConnectionState === 'disconnected')\n return ConnectionState.ConnectedPendingDisconnect;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected' &&\n networkState === 'disconnected')\n return ConnectionState.ConnectionDisruptedPendingNetwork;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected')\n return ConnectionState.ConnectionDisrupted;\n if (connectionState === 'connected' && keepAliveState === 'unhealthy')\n return ConnectionState.ConnectedPendingKeepAlive;\n // All remaining states directly correspond to the connection state\n if (connectionState === 'connecting')\n return ConnectionState.Connecting;\n if (connectionState === 'disconnected')\n return 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AAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,OAAO,eAAe,CAAC,mBAAmB,CAAC;AACvD,QAAQ,IAAI,eAAe,KAAK,WAAW,IAAI,cAAc,KAAK,WAAW;AAC7E,YAAY,OAAO,eAAe,CAAC,yBAAyB,CAAC;AAC7D;AACA,QAAQ,IAAI,eAAe,KAAK,YAAY;AAC5C,YAAY,OAAO,eAAe,CAAC,UAAU,CAAC;AAC9C,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,OAAO,eAAe,CAAC,YAAY,CAAC;AAChD,QAAQ,OAAO,eAAe,CAAC,SAAS,CAAC;AACzC,KAAK;AACL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nimport
|
|
1
|
+
{"version":3,"file":"index.native.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nimport NetInfo from '@react-native-community/netinfo';\nexport const ReachabilityMonitor = () => new Reachability().networkMonitor(NetInfo);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,mBAAmB,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,cAAc,CAAC,OAAO;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
export declare const NO_API_KEY: AmplifyErrorParams;
|
|
3
|
+
export declare const NO_VALID_CREDENTIALS: AmplifyErrorParams;
|
|
4
|
+
export declare const NO_VALID_AUTH_TOKEN: AmplifyErrorParams;
|
|
5
|
+
export declare const NO_SIGNED_IN_USER: AmplifyErrorParams;
|
|
6
|
+
export declare const NO_AUTH_TOKEN_HEADER: AmplifyErrorParams;
|
|
7
|
+
export declare const NO_ENDPOINT: AmplifyErrorParams;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GraphQLAuthError } from '../../types/index.mjs';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
const NO_API_KEY = {
|
|
6
|
+
name: 'NoApiKey',
|
|
7
|
+
// ideal: No API key configured.
|
|
8
|
+
message: GraphQLAuthError.NO_API_KEY,
|
|
9
|
+
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.',
|
|
10
|
+
};
|
|
11
|
+
const NO_VALID_CREDENTIALS = {
|
|
12
|
+
name: 'NoCredentials',
|
|
13
|
+
// ideal: No auth credentials available.
|
|
14
|
+
message: GraphQLAuthError.NO_CREDENTIALS,
|
|
15
|
+
recoverySuggestion: `The API request was made with \`authMode: "iam"\` but no authentication credentials are available.
|
|
16
|
+
|
|
17
|
+
If you intended to make a request using an authenticated role, review if your user is signed in before making the request.
|
|
18
|
+
|
|
19
|
+
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.`,
|
|
20
|
+
};
|
|
21
|
+
const NO_VALID_AUTH_TOKEN = {
|
|
22
|
+
name: 'NoValidAuthTokens',
|
|
23
|
+
// ideal: No valid JWT auth token provided to make the API request..
|
|
24
|
+
message: GraphQLAuthError.NO_FEDERATED_JWT,
|
|
25
|
+
recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',
|
|
26
|
+
};
|
|
27
|
+
const NO_SIGNED_IN_USER = {
|
|
28
|
+
name: 'NoSignedUser',
|
|
29
|
+
// ideal: Couldn't retrieve authentication credentials to make the API request.
|
|
30
|
+
message: GraphQLAuthError.NO_CURRENT_USER,
|
|
31
|
+
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.',
|
|
32
|
+
};
|
|
33
|
+
const NO_AUTH_TOKEN_HEADER = {
|
|
34
|
+
name: 'NoAuthorizationHeader',
|
|
35
|
+
// ideal: Authorization header not specified.
|
|
36
|
+
message: GraphQLAuthError.NO_AUTH_TOKEN,
|
|
37
|
+
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.',
|
|
38
|
+
};
|
|
39
|
+
const NO_ENDPOINT = {
|
|
40
|
+
name: 'NoEndpoint',
|
|
41
|
+
message: 'No GraphQL endpoint configured in `Amplify.configure()`.',
|
|
42
|
+
recoverySuggestion: 'Review if the GraphQL API endpoint is set in the `Amplify.configure()` function.',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { NO_API_KEY, NO_AUTH_TOKEN_HEADER, NO_ENDPOINT, NO_SIGNED_IN_USER, NO_VALID_AUTH_TOKEN, NO_VALID_CREDENTIALS };
|
|
46
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../../src/utils/errors/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { GraphQLAuthError } from '../../types';\nexport const NO_API_KEY = {\n name: 'NoApiKey',\n // ideal: No API key configured.\n message: 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};\nexport const NO_VALID_CREDENTIALS = {\n name: 'NoCredentials',\n // ideal: No auth credentials available.\n message: 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};\nexport const NO_VALID_AUTH_TOKEN = {\n name: 'NoValidAuthTokens',\n // ideal: No valid JWT auth token provided to make the API request..\n message: GraphQLAuthError.NO_FEDERATED_JWT,\n recoverySuggestion: 'If you intended to make an authenticated API request, review if the current user is signed in.',\n};\nexport const NO_SIGNED_IN_USER = {\n name: 'NoSignedUser',\n // ideal: Couldn't retrieve authentication credentials to make the API request.\n message: 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};\nexport const NO_AUTH_TOKEN_HEADER = {\n name: 'NoAuthorizationHeader',\n // ideal: Authorization header not specified.\n message: 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};\nexport const 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":";;AAAA;AACA;AAEY,MAAC,UAAU,GAAG;AAC1B,IAAI,IAAI,EAAE,UAAU;AACpB;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,UAAU;AACxC,IAAI,kBAAkB,EAAE,oLAAoL;AAC5M,EAAE;AACU,MAAC,oBAAoB,GAAG;AACpC,IAAI,IAAI,EAAE,eAAe;AACzB;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,cAAc;AAC5C,IAAI,kBAAkB,EAAE,CAAC;AACzB;AACA;AACA;AACA,kMAAkM,CAAC;AACnM,EAAE;AACU,MAAC,mBAAmB,GAAG;AACnC,IAAI,IAAI,EAAE,mBAAmB;AAC7B;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,gBAAgB;AAC9C,IAAI,kBAAkB,EAAE,gGAAgG;AACxH,EAAE;AACU,MAAC,iBAAiB,GAAG;AACjC,IAAI,IAAI,EAAE,cAAc;AACxB;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,eAAe;AAC7C,IAAI,kBAAkB,EAAE,wJAAwJ;AAChL,EAAE;AACU,MAAC,oBAAoB,GAAG;AACpC,IAAI,IAAI,EAAE,uBAAuB;AACjC;AACA,IAAI,OAAO,EAAE,gBAAgB,CAAC,aAAa;AAC3C,IAAI,kBAAkB,EAAE,wLAAwL;AAChN,EAAE;AACU,MAAC,WAAW,GAAG;AAC3B,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,OAAO,EAAE,0DAA0D;AACvE,IAAI,kBAAkB,EAAE,kFAAkF;AAC1G;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
const createGraphQLResultWithError = (error) => {
|
|
6
|
+
return {
|
|
7
|
+
data: {},
|
|
8
|
+
errors: [new GraphQLError(error.message, null, null, null, null, error)],
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { createGraphQLResultWithError };
|
|
13
|
+
//# sourceMappingURL=createGraphQLResultWithError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGraphQLResultWithError.mjs","sources":["../../../../src/utils/errors/createGraphQLResultWithError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { GraphQLError } from 'graphql';\nexport const createGraphQLResultWithError = (error) => {\n return {\n data: {},\n errors: [new GraphQLError(error.message, null, null, null, null, error)],\n };\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,4BAA4B,GAAG,CAAC,KAAK,KAAK;AACvD,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,EAAE;AAChB,QAAQ,MAAM,EAAE,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAChF,KAAK,CAAC;AACN;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { GraphQLApiError } from './GraphQLApiError';
|
|
2
2
|
export { assertValidationError } from './assertValidationError';
|
|
3
3
|
export { APIValidationErrorCode, validationErrorMap } from './validation';
|
|
4
|
+
export { createGraphQLResultWithError } from './createGraphQLResultWithError';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { GraphQLApiError } from './GraphQLApiError.mjs';
|
|
2
2
|
export { assertValidationError } from './assertValidationError.mjs';
|
|
3
3
|
export { APIValidationErrorCode, validationErrorMap } from './validation.mjs';
|
|
4
|
+
export { createGraphQLResultWithError } from './createGraphQLResultWithError.mjs';
|
|
4
5
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ErrorObject = {
|
|
3
|
-
errors: AmplifyErrorParams[];
|
|
4
|
-
};
|
|
1
|
+
import { GraphQLResult } from '../../types';
|
|
5
2
|
/**
|
|
6
3
|
* Checks to see if the given response or subscription message contains an
|
|
7
|
-
*
|
|
4
|
+
* Unauthorized error. If it does, it changes the error message to include instructions
|
|
8
5
|
* for the app developer.
|
|
9
6
|
*/
|
|
10
|
-
export declare function
|
|
11
|
-
export {};
|
|
7
|
+
export declare function repackageUnauthorizedError<T extends GraphQLResult<any>>(content: T): T;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
/**
|
|
4
4
|
* Checks to see if the given response or subscription message contains an
|
|
5
|
-
*
|
|
5
|
+
* Unauthorized error. If it does, it changes the error message to include instructions
|
|
6
6
|
* for the app developer.
|
|
7
7
|
*/
|
|
8
|
-
function
|
|
8
|
+
function repackageUnauthorizedError(content) {
|
|
9
9
|
if (content.errors && Array.isArray(content.errors)) {
|
|
10
10
|
content.errors.forEach(e => {
|
|
11
|
-
if (
|
|
11
|
+
if (isUnauthorizedError(e)) {
|
|
12
12
|
e.message = 'Unauthorized';
|
|
13
13
|
e.recoverySuggestion =
|
|
14
14
|
`If you're calling an Amplify-generated API, make sure ` +
|
|
@@ -19,9 +19,9 @@ function repackageUnauthError(content) {
|
|
|
19
19
|
}
|
|
20
20
|
return content;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function isUnauthorizedError(error) {
|
|
23
23
|
// Error pattern corresponding to appsync calls
|
|
24
|
-
if (error?.
|
|
24
|
+
if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
// Error pattern corresponding to appsync subscriptions
|
|
@@ -32,5 +32,5 @@ function isUnauthError(error) {
|
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export {
|
|
35
|
+
export { repackageUnauthorizedError };
|
|
36
36
|
//# sourceMappingURL=repackageAuthError.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repackageAuthError.mjs","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Checks to see if the given response or subscription message contains an\n *
|
|
1
|
+
{"version":3,"file":"repackageAuthError.mjs","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.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 */\nexport function 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}\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":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,OAAO,EAAE;AACpD,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,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;;;;"}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param keyFields The fields used to indicate a match
|
|
7
7
|
* @returns Index of `needle` in `haystack`, otherwise -1 if not found.
|
|
8
8
|
*/
|
|
9
|
-
export declare function findIndexByFields<T>(needle: T, haystack: T[], keyFields:
|
|
9
|
+
export declare function findIndexByFields<T>(needle: T, haystack: T[], keyFields: (keyof T)[]): number;
|