@aws-amplify/api-graphql 0.0.0-unstable-1ca644b-20260128091132
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/README.md +3 -0
- package/dist/cjs/GraphQLAPI.js +66 -0
- package/dist/cjs/GraphQLAPI.js.map +1 -0
- package/dist/cjs/Providers/AWSAppSyncEventsProvider/index.js +117 -0
- package/dist/cjs/Providers/AWSAppSyncEventsProvider/index.js.map +1 -0
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +96 -0
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -0
- package/dist/cjs/Providers/AWSWebSocketProvider/appsyncUrl.js +113 -0
- package/dist/cjs/Providers/AWSWebSocketProvider/appsyncUrl.js.map +1 -0
- package/dist/cjs/Providers/AWSWebSocketProvider/authHeaders.js +99 -0
- package/dist/cjs/Providers/AWSWebSocketProvider/authHeaders.js.map +1 -0
- package/dist/cjs/Providers/AWSWebSocketProvider/index.js +693 -0
- package/dist/cjs/Providers/AWSWebSocketProvider/index.js.map +1 -0
- package/dist/cjs/Providers/constants.js +149 -0
- package/dist/cjs/Providers/constants.js.map +1 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/internals/InternalGraphQLAPI.js +269 -0
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -0
- package/dist/cjs/internals/events/appsyncRequest.js +96 -0
- package/dist/cjs/internals/events/appsyncRequest.js.map +1 -0
- package/dist/cjs/internals/events/index.js +142 -0
- package/dist/cjs/internals/events/index.js.map +1 -0
- package/dist/cjs/internals/events/types.js +6 -0
- package/dist/cjs/internals/events/types.js.map +1 -0
- package/dist/cjs/internals/events/utils.js +57 -0
- package/dist/cjs/internals/events/utils.js.map +1 -0
- package/dist/cjs/internals/generateClient.js +86 -0
- package/dist/cjs/internals/generateClient.js.map +1 -0
- package/dist/cjs/internals/graphqlAuth.js +63 -0
- package/dist/cjs/internals/graphqlAuth.js.map +1 -0
- package/dist/cjs/internals/graphqlRequest.js +19 -0
- package/dist/cjs/internals/graphqlRequest.js.map +1 -0
- package/dist/cjs/internals/index.js +16 -0
- package/dist/cjs/internals/index.js.map +1 -0
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +48 -0
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -0
- package/dist/cjs/internals/server/index.js +9 -0
- package/dist/cjs/internals/server/index.js.map +1 -0
- package/dist/cjs/internals/types.js +4 -0
- package/dist/cjs/internals/types.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js +10 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js +10 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js +14 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js.map +1 -0
- package/dist/cjs/internals/v6.js +155 -0
- package/dist/cjs/internals/v6.js.map +1 -0
- package/dist/cjs/server/generateClient.js +42 -0
- package/dist/cjs/server/generateClient.js.map +1 -0
- package/dist/cjs/server/index.js +9 -0
- package/dist/cjs/server/index.js.map +1 -0
- package/dist/cjs/types/PubSub.js +49 -0
- package/dist/cjs/types/PubSub.js.map +1 -0
- package/dist/cjs/types/index.js +34 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/ConnectionStateMonitor.js +134 -0
- package/dist/cjs/utils/ConnectionStateMonitor.js.map +1 -0
- package/dist/cjs/utils/ReachabilityMonitor/index.js +10 -0
- package/dist/cjs/utils/ReachabilityMonitor/index.js.map +1 -0
- package/dist/cjs/utils/ReachabilityMonitor/index.native.js +12 -0
- package/dist/cjs/utils/ReachabilityMonitor/index.native.js.map +1 -0
- package/dist/cjs/utils/ReconnectionMonitor.js +71 -0
- package/dist/cjs/utils/ReconnectionMonitor.js.map +1 -0
- package/dist/cjs/utils/errors/GraphQLApiError.js +21 -0
- package/dist/cjs/utils/errors/GraphQLApiError.js.map +1 -0
- package/dist/cjs/utils/errors/assertValidationError.js +18 -0
- package/dist/cjs/utils/errors/assertValidationError.js.map +1 -0
- 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 +16 -0
- package/dist/cjs/utils/errors/index.js.map +1 -0
- package/dist/cjs/utils/errors/repackageAuthError.js +38 -0
- package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -0
- package/dist/cjs/utils/errors/validation.js +28 -0
- package/dist/cjs/utils/errors/validation.js.map +1 -0
- package/dist/cjs/utils/index.js +11 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/resolveConfig.js +32 -0
- package/dist/cjs/utils/resolveConfig.js.map +1 -0
- package/dist/cjs/utils/resolveLibraryOptions.js +16 -0
- package/dist/cjs/utils/resolveLibraryOptions.js.map +1 -0
- package/dist/esm/GraphQLAPI.d.ts +37 -0
- package/dist/esm/GraphQLAPI.mjs +63 -0
- package/dist/esm/GraphQLAPI.mjs.map +1 -0
- package/dist/esm/Providers/AWSAppSyncEventsProvider/index.d.ts +49 -0
- package/dist/esm/Providers/AWSAppSyncEventsProvider/index.mjs +115 -0
- package/dist/esm/Providers/AWSAppSyncEventsProvider/index.mjs.map +1 -0
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +47 -0
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +94 -0
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -0
- package/dist/esm/Providers/AWSWebSocketProvider/appsyncUrl.d.ts +21 -0
- package/dist/esm/Providers/AWSWebSocketProvider/appsyncUrl.mjs +107 -0
- package/dist/esm/Providers/AWSWebSocketProvider/appsyncUrl.mjs.map +1 -0
- package/dist/esm/Providers/AWSWebSocketProvider/authHeaders.d.ts +8 -0
- package/dist/esm/Providers/AWSWebSocketProvider/authHeaders.mjs +97 -0
- package/dist/esm/Providers/AWSWebSocketProvider/authHeaders.mjs.map +1 -0
- package/dist/esm/Providers/AWSWebSocketProvider/index.d.ts +99 -0
- package/dist/esm/Providers/AWSWebSocketProvider/index.mjs +691 -0
- package/dist/esm/Providers/AWSWebSocketProvider/index.mjs.map +1 -0
- package/dist/esm/Providers/constants.d.ts +135 -0
- package/dist/esm/Providers/constants.mjs +147 -0
- package/dist/esm/Providers/constants.mjs.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.mjs +7 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +45 -0
- package/dist/esm/internals/InternalGraphQLAPI.mjs +270 -0
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -0
- package/dist/esm/internals/events/appsyncRequest.d.ts +14 -0
- package/dist/esm/internals/events/appsyncRequest.mjs +96 -0
- package/dist/esm/internals/events/appsyncRequest.mjs.map +1 -0
- package/dist/esm/internals/events/index.d.ts +58 -0
- package/dist/esm/internals/events/index.mjs +139 -0
- package/dist/esm/internals/events/index.mjs.map +1 -0
- package/dist/esm/internals/events/types.d.ts +93 -0
- package/dist/esm/internals/events/types.mjs +2 -0
- package/dist/esm/internals/events/types.mjs.map +1 -0
- package/dist/esm/internals/events/utils.d.ts +16 -0
- package/dist/esm/internals/events/utils.mjs +53 -0
- package/dist/esm/internals/events/utils.mjs.map +1 -0
- package/dist/esm/internals/generateClient.d.ts +12 -0
- package/dist/esm/internals/generateClient.mjs +85 -0
- package/dist/esm/internals/generateClient.mjs.map +1 -0
- package/dist/esm/internals/graphqlAuth.d.ts +3 -0
- package/dist/esm/internals/graphqlAuth.mjs +64 -0
- package/dist/esm/internals/graphqlAuth.mjs.map +1 -0
- package/dist/esm/internals/graphqlRequest.d.ts +3 -0
- package/dist/esm/internals/graphqlRequest.mjs +18 -0
- package/dist/esm/internals/graphqlRequest.mjs.map +1 -0
- package/dist/esm/internals/index.d.ts +4 -0
- package/dist/esm/internals/index.mjs +4 -0
- package/dist/esm/internals/index.mjs.map +1 -0
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +13 -0
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +61 -0
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -0
- package/dist/esm/internals/server/index.d.ts +1 -0
- package/dist/esm/internals/server/index.mjs +2 -0
- package/dist/esm/internals/server/index.mjs.map +1 -0
- package/dist/esm/internals/types.d.ts +34 -0
- package/dist/esm/internals/types.mjs +2 -0
- package/dist/esm/internals/types.mjs.map +1 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.d.ts +2 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs +8 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs.map +1 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.d.ts +8 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs +8 -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 +100 -0
- package/dist/esm/internals/v6.mjs +152 -0
- package/dist/esm/internals/v6.mjs.map +1 -0
- package/dist/esm/server/generateClient.d.ts +21 -0
- package/dist/esm/server/generateClient.mjs +41 -0
- package/dist/esm/server/generateClient.mjs.map +1 -0
- package/dist/esm/server/index.d.ts +1 -0
- package/dist/esm/server/index.mjs +2 -0
- package/dist/esm/server/index.mjs.map +1 -0
- package/dist/esm/types/PubSub.d.ts +27 -0
- package/dist/esm/types/PubSub.mjs +47 -0
- package/dist/esm/types/PubSub.mjs.map +1 -0
- package/dist/esm/types/index.d.ts +369 -0
- package/dist/esm/types/index.mjs +30 -0
- package/dist/esm/types/index.mjs.map +1 -0
- package/dist/esm/utils/ConnectionStateMonitor.d.ts +69 -0
- package/dist/esm/utils/ConnectionStateMonitor.mjs +132 -0
- package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -0
- package/dist/esm/utils/ReachabilityMonitor/index.d.ts +1 -0
- package/dist/esm/utils/ReachabilityMonitor/index.mjs +8 -0
- package/dist/esm/utils/ReachabilityMonitor/index.mjs.map +1 -0
- package/dist/esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
- package/dist/esm/utils/ReachabilityMonitor/index.native.mjs +9 -0
- package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -0
- package/dist/esm/utils/ReconnectionMonitor.d.ts +29 -0
- package/dist/esm/utils/ReconnectionMonitor.mjs +69 -0
- package/dist/esm/utils/ReconnectionMonitor.mjs.map +1 -0
- package/dist/esm/utils/errors/GraphQLApiError.d.ts +7 -0
- package/dist/esm/utils/errors/GraphQLApiError.mjs +19 -0
- package/dist/esm/utils/errors/GraphQLApiError.mjs.map +1 -0
- package/dist/esm/utils/errors/assertValidationError.d.ts +5 -0
- package/dist/esm/utils/errors/assertValidationError.mjs +17 -0
- package/dist/esm/utils/errors/assertValidationError.mjs.map +1 -0
- 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 +4 -0
- package/dist/esm/utils/errors/index.mjs +5 -0
- package/dist/esm/utils/errors/index.mjs.map +1 -0
- package/dist/esm/utils/errors/repackageAuthError.d.ts +7 -0
- package/dist/esm/utils/errors/repackageAuthError.mjs +36 -0
- package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -0
- package/dist/esm/utils/errors/validation.d.ts +7 -0
- package/dist/esm/utils/errors/validation.mjs +26 -0
- package/dist/esm/utils/errors/validation.mjs.map +1 -0
- package/dist/esm/utils/index.d.ts +2 -0
- package/dist/esm/utils/index.mjs +3 -0
- package/dist/esm/utils/index.mjs.map +1 -0
- package/dist/esm/utils/resolveConfig.d.ts +12 -0
- package/dist/esm/utils/resolveConfig.mjs +33 -0
- package/dist/esm/utils/resolveConfig.mjs.map +1 -0
- package/dist/esm/utils/resolveLibraryOptions.d.ts +11 -0
- package/dist/esm/utils/resolveLibraryOptions.mjs +13 -0
- package/dist/esm/utils/resolveLibraryOptions.mjs.map +1 -0
- package/internals/package.json +8 -0
- package/internals/server/package.json +8 -0
- package/package.json +99 -0
- package/server/package.json +7 -0
- package/src/GraphQLAPI.ts +97 -0
- package/src/Providers/AWSAppSyncEventsProvider/index.ts +218 -0
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +185 -0
- package/src/Providers/AWSWebSocketProvider/appsyncUrl.ts +152 -0
- package/src/Providers/AWSWebSocketProvider/authHeaders.ts +146 -0
- package/src/Providers/AWSWebSocketProvider/index.ts +1028 -0
- package/src/Providers/constants.ts +154 -0
- package/src/index.ts +12 -0
- package/src/internals/InternalGraphQLAPI.ts +424 -0
- package/src/internals/events/appsyncRequest.ts +169 -0
- package/src/internals/events/index.ts +199 -0
- package/src/internals/events/types.ts +109 -0
- package/src/internals/events/utils.ts +77 -0
- package/src/internals/generateClient.ts +120 -0
- package/src/internals/graphqlAuth.ts +87 -0
- package/src/internals/graphqlRequest.ts +30 -0
- package/src/internals/index.ts +10 -0
- package/src/internals/server/generateClientWithAmplifyInstance.ts +73 -0
- package/src/internals/server/index.ts +4 -0
- package/src/internals/types.ts +42 -0
- package/src/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.ts +10 -0
- package/src/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.ts +13 -0
- package/src/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts +15 -0
- package/src/internals/v6.ts +189 -0
- package/src/server/generateClient.ts +68 -0
- package/src/server/index.ts +4 -0
- package/src/types/PubSub.ts +57 -0
- package/src/types/index.ts +524 -0
- package/src/utils/ConnectionStateMonitor.ts +195 -0
- package/src/utils/ReachabilityMonitor/index.native.ts +7 -0
- package/src/utils/ReachabilityMonitor/index.ts +5 -0
- package/src/utils/ReconnectionMonitor.ts +77 -0
- package/src/utils/errors/GraphQLApiError.ts +21 -0
- package/src/utils/errors/assertValidationError.ts +19 -0
- package/src/utils/errors/constants.ts +56 -0
- package/src/utils/errors/createGraphQLResultWithError.ts +15 -0
- package/src/utils/errors/index.ts +7 -0
- package/src/utils/errors/repackageAuthError.ts +43 -0
- package/src/utils/errors/validation.ts +26 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/resolveConfig.ts +46 -0
- package/src/utils/resolveLibraryOptions.ts +14 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionStateMonitor.js","sources":["../../../src/utils/ConnectionStateMonitor.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.ConnectionStateMonitor = exports.CONNECTION_CHANGE = void 0;\nconst rxjs_1 = require(\"rxjs\");\nconst PubSub_1 = require(\"../types/PubSub\");\nconst ReachabilityMonitor_1 = require(\"./ReachabilityMonitor\");\nexports.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};\nclass 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 = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(({ online }) => {\n this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);\n this._initialNetworkStateSubscription?.unsubscribe();\n });\n this._linkedConnectionStateObservable =\n new rxjs_1.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 = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(({ online }) => {\n this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.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((0, rxjs_1.map)(value => {\n return this.connectionStatesTranslator(value);\n }))\n .pipe((0, rxjs_1.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 PubSub_1.ConnectionState.ConnectedPendingNetwork;\n if (connectionState === 'connected' &&\n intendedConnectionState === 'disconnected')\n return PubSub_1.ConnectionState.ConnectedPendingDisconnect;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected' &&\n networkState === 'disconnected')\n return PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected')\n return PubSub_1.ConnectionState.ConnectionDisrupted;\n if (connectionState === 'connected' && keepAliveState === 'unhealthy')\n return PubSub_1.ConnectionState.ConnectedPendingKeepAlive;\n // All remaining states directly correspond to the connection state\n if (connectionState === 'connecting')\n return PubSub_1.ConnectionState.Connecting;\n if (connectionState === 'disconnected')\n return PubSub_1.ConnectionState.Disconnected;\n return PubSub_1.ConnectionState.Connected;\n }\n}\nexports.ConnectionStateMonitor = ConnectionStateMonitor;\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ReachabilityMonitor = void 0;
|
|
5
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
|
+
const ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor();
|
|
9
|
+
exports.ReachabilityMonitor = ReachabilityMonitor;
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/utils/ReachabilityMonitor/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReachabilityMonitor = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor();\nexports.ReachabilityMonitor = ReachabilityMonitor;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,MAAM;AACpC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,mBAAmB,GAAG,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,cAAc,EAAE;AAC7E,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ReachabilityMonitor = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
|
+
const netinfo_1 = tslib_1.__importDefault(require("@react-native-community/netinfo"));
|
|
10
|
+
const ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor(netinfo_1.default);
|
|
11
|
+
exports.ReachabilityMonitor = ReachabilityMonitor;
|
|
12
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.js","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReachabilityMonitor = void 0;\nconst tslib_1 = require(\"tslib\");\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst netinfo_1 = tslib_1.__importDefault(require(\"@react-native-community/netinfo\"));\nconst ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor(netinfo_1.default);\nexports.ReachabilityMonitor = ReachabilityMonitor;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,MAAM;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AAChC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;AACrF,MAAM,mBAAmB,GAAG,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC;AAC9F,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ReconnectionMonitor = exports.ReconnectEvent = void 0;
|
|
5
|
+
const constants_1 = require("../Providers/constants");
|
|
6
|
+
var ReconnectEvent;
|
|
7
|
+
(function (ReconnectEvent) {
|
|
8
|
+
ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
|
|
9
|
+
ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
|
|
10
|
+
})(ReconnectEvent || (exports.ReconnectEvent = ReconnectEvent = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Captures the reconnect event logic used to determine when to reconnect to PubSub providers.
|
|
13
|
+
* Reconnect attempts are delayed by 5 seconds to let the interface settle.
|
|
14
|
+
* Attempting to reconnect only once creates unrecoverable states when the network state isn't
|
|
15
|
+
* supported by the browser, so this keeps retrying every minute until halted.
|
|
16
|
+
*/
|
|
17
|
+
class ReconnectionMonitor {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.reconnectObservers = [];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Add reconnect observer to the list of observers to alert on reconnect
|
|
23
|
+
*/
|
|
24
|
+
addObserver(reconnectObserver) {
|
|
25
|
+
this.reconnectObservers.push(reconnectObserver);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Given a reconnect event, start the appropriate behavior
|
|
29
|
+
*/
|
|
30
|
+
record(event) {
|
|
31
|
+
if (event === ReconnectEvent.START_RECONNECT) {
|
|
32
|
+
// If the reconnection hasn't been started
|
|
33
|
+
if (this.reconnectSetTimeoutId === undefined &&
|
|
34
|
+
this.reconnectIntervalId === undefined) {
|
|
35
|
+
this.reconnectSetTimeoutId = setTimeout(() => {
|
|
36
|
+
// Reconnect now
|
|
37
|
+
this._triggerReconnect();
|
|
38
|
+
// Retry reconnect every periodically until it works
|
|
39
|
+
this.reconnectIntervalId = setInterval(() => {
|
|
40
|
+
this._triggerReconnect();
|
|
41
|
+
}, constants_1.RECONNECT_INTERVAL);
|
|
42
|
+
}, constants_1.RECONNECT_DELAY);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (event === ReconnectEvent.HALT_RECONNECT) {
|
|
46
|
+
if (this.reconnectIntervalId) {
|
|
47
|
+
clearInterval(this.reconnectIntervalId);
|
|
48
|
+
this.reconnectIntervalId = undefined;
|
|
49
|
+
}
|
|
50
|
+
if (this.reconnectSetTimeoutId) {
|
|
51
|
+
clearTimeout(this.reconnectSetTimeoutId);
|
|
52
|
+
this.reconnectSetTimeoutId = undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Complete all reconnect observers
|
|
58
|
+
*/
|
|
59
|
+
close() {
|
|
60
|
+
this.reconnectObservers.forEach(reconnectObserver => {
|
|
61
|
+
reconnectObserver.complete?.();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
_triggerReconnect() {
|
|
65
|
+
this.reconnectObservers.forEach(reconnectObserver => {
|
|
66
|
+
reconnectObserver.next?.();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ReconnectionMonitor = ReconnectionMonitor;
|
|
71
|
+
//# sourceMappingURL=ReconnectionMonitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReconnectionMonitor.js","sources":["../../../src/utils/ReconnectionMonitor.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReconnectionMonitor = exports.ReconnectEvent = void 0;\nconst constants_1 = require(\"../Providers/constants\");\nvar ReconnectEvent;\n(function (ReconnectEvent) {\n ReconnectEvent[\"START_RECONNECT\"] = \"START_RECONNECT\";\n ReconnectEvent[\"HALT_RECONNECT\"] = \"HALT_RECONNECT\";\n})(ReconnectEvent || (exports.ReconnectEvent = ReconnectEvent = {}));\n/**\n * Captures the reconnect event logic used to determine when to reconnect to PubSub providers.\n * Reconnect attempts are delayed by 5 seconds to let the interface settle.\n * Attempting to reconnect only once creates unrecoverable states when the network state isn't\n * supported by the browser, so this keeps retrying every minute until halted.\n */\nclass ReconnectionMonitor {\n constructor() {\n this.reconnectObservers = [];\n }\n /**\n * Add reconnect observer to the list of observers to alert on reconnect\n */\n addObserver(reconnectObserver) {\n this.reconnectObservers.push(reconnectObserver);\n }\n /**\n * Given a reconnect event, start the appropriate behavior\n */\n record(event) {\n if (event === ReconnectEvent.START_RECONNECT) {\n // If the reconnection hasn't been started\n if (this.reconnectSetTimeoutId === undefined &&\n this.reconnectIntervalId === undefined) {\n this.reconnectSetTimeoutId = setTimeout(() => {\n // Reconnect now\n this._triggerReconnect();\n // Retry reconnect every periodically until it works\n this.reconnectIntervalId = setInterval(() => {\n this._triggerReconnect();\n }, constants_1.RECONNECT_INTERVAL);\n }, constants_1.RECONNECT_DELAY);\n }\n }\n if (event === ReconnectEvent.HALT_RECONNECT) {\n if (this.reconnectIntervalId) {\n clearInterval(this.reconnectIntervalId);\n this.reconnectIntervalId = undefined;\n }\n if (this.reconnectSetTimeoutId) {\n clearTimeout(this.reconnectSetTimeoutId);\n this.reconnectSetTimeoutId = undefined;\n }\n }\n }\n /**\n * Complete all reconnect observers\n */\n close() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.complete?.();\n });\n }\n _triggerReconnect() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.next?.();\n });\n }\n}\nexports.ReconnectionMonitor = ReconnectionMonitor;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,MAAM;AAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,wBAAwB,CAAC;AACrD,IAAI,cAAc;AAClB,CAAC,UAAU,cAAc,EAAE;AAC3B,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,iBAAiB;AACzD,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAAG,gBAAgB;AACvD,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,GAAG,cAAc,GAAG,EAAE,CAAC,CAAC;AACpE;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,mBAAmB,CAAC;AAC1B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,kBAAkB,GAAG,EAAE;AACpC,IAAI;AACJ;AACA;AACA;AACA,IAAI,WAAW,CAAC,iBAAiB,EAAE;AACnC,QAAQ,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC;AACvD,IAAI;AACJ;AACA;AACA;AACA,IAAI,MAAM,CAAC,KAAK,EAAE;AAClB,QAAQ,IAAI,KAAK,KAAK,cAAc,CAAC,eAAe,EAAE;AACtD;AACA,YAAY,IAAI,IAAI,CAAC,qBAAqB,KAAK,SAAS;AACxD,gBAAgB,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;AACxD,gBAAgB,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,MAAM;AAC9D;AACA,oBAAoB,IAAI,CAAC,iBAAiB,EAAE;AAC5C;AACA,oBAAoB,IAAI,CAAC,mBAAmB,GAAG,WAAW,CAAC,MAAM;AACjE,wBAAwB,IAAI,CAAC,iBAAiB,EAAE;AAChD,oBAAoB,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;AACtD,gBAAgB,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC;AAC/C,YAAY;AACZ,QAAQ;AACR,QAAQ,IAAI,KAAK,KAAK,cAAc,CAAC,cAAc,EAAE;AACrD,YAAY,IAAI,IAAI,CAAC,mBAAmB,EAAE;AAC1C,gBAAgB,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC;AACvD,gBAAgB,IAAI,CAAC,mBAAmB,GAAG,SAAS;AACpD,YAAY;AACZ,YAAY,IAAI,IAAI,CAAC,qBAAqB,EAAE;AAC5C,gBAAgB,YAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC;AACxD,gBAAgB,IAAI,CAAC,qBAAqB,GAAG,SAAS;AACtD,YAAY;AACZ,QAAQ;AACR,IAAI;AACJ;AACA;AACA;AACA,IAAI,KAAK,GAAG;AACZ,QAAQ,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,iBAAiB,IAAI;AAC7D,YAAY,iBAAiB,CAAC,QAAQ,IAAI;AAC1C,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ,IAAI,iBAAiB,GAAG;AACxB,QAAQ,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,iBAAiB,IAAI;AAC7D,YAAY,iBAAiB,CAAC,IAAI,IAAI;AACtC,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;AACA,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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.GraphQLApiError = void 0;
|
|
7
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
class GraphQLApiError extends utils_1.AmplifyError {
|
|
12
|
+
constructor(params) {
|
|
13
|
+
super(params);
|
|
14
|
+
// Hack for making the custom error class work when transpiled to es5
|
|
15
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
16
|
+
this.constructor = GraphQLApiError;
|
|
17
|
+
Object.setPrototypeOf(this, GraphQLApiError.prototype);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.GraphQLApiError = GraphQLApiError;
|
|
21
|
+
//# sourceMappingURL=GraphQLApiError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphQLApiError.js","sources":["../../../../src/utils/errors/GraphQLApiError.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.GraphQLApiError = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\n/**\n * @internal\n */\nclass GraphQLApiError extends utils_1.AmplifyError {\n constructor(params) {\n super(params);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = GraphQLApiError;\n Object.setPrototypeOf(this, GraphQLApiError.prototype);\n }\n}\nexports.GraphQLApiError = GraphQLApiError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,MAAM;AAChC,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D;AACA;AACA;AACA,MAAM,eAAe,SAAS,OAAO,CAAC,YAAY,CAAC;AACnD,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC;AACrB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,eAAe;AAC1C,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC;AAC9D,IAAI;AACJ;AACA,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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.assertValidationError = assertValidationError;
|
|
7
|
+
const GraphQLApiError_1 = require("./GraphQLApiError");
|
|
8
|
+
const validation_1 = require("./validation");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function assertValidationError(assertion, name) {
|
|
13
|
+
const { message, recoverySuggestion } = validation_1.validationErrorMap[name];
|
|
14
|
+
if (!assertion) {
|
|
15
|
+
throw new GraphQLApiError_1.GraphQLApiError({ name, message, recoverySuggestion });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=assertValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertValidationError.js","sources":["../../../../src/utils/errors/assertValidationError.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.assertValidationError = assertValidationError;\nconst GraphQLApiError_1 = require(\"./GraphQLApiError\");\nconst validation_1 = require(\"./validation\");\n/**\n * @internal\n */\nfunction assertValidationError(assertion, name) {\n const { message, recoverySuggestion } = validation_1.validationErrorMap[name];\n if (!assertion) {\n throw new GraphQLApiError_1.GraphQLApiError({ name, message, recoverySuggestion });\n }\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD,MAAM,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;AACtD,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;AAC5C;AACA;AACA;AACA,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AAChD,IAAI,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC;AACjF,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,iBAAiB,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC1F,IAAI;AACJ;;"}
|
|
@@ -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;AAC7D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,UAAU,GAAG,MAAM;AACzK,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,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;AACD,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;;AAEzB;;AAEA,kMAAkM,CAAC;AACnM,CAAC;AACD,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;AACD,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;AACD,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;AACD,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;AAC7D,OAAO,CAAC,4BAA4B,GAAG,MAAM;AAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;AACpC,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;AACL,CAAC;AACD,OAAO,CAAC,4BAA4B,GAAG,4BAA4B;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 = exports.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.GraphQLApiError = void 0;
|
|
7
|
+
var GraphQLApiError_1 = require("./GraphQLApiError");
|
|
8
|
+
Object.defineProperty(exports, "GraphQLApiError", { enumerable: true, get: function () { return GraphQLApiError_1.GraphQLApiError; } });
|
|
9
|
+
var assertValidationError_1 = require("./assertValidationError");
|
|
10
|
+
Object.defineProperty(exports, "assertValidationError", { enumerable: true, get: function () { return assertValidationError_1.assertValidationError; } });
|
|
11
|
+
var validation_1 = require("./validation");
|
|
12
|
+
Object.defineProperty(exports, "APIValidationErrorCode", { enumerable: true, get: function () { return validation_1.APIValidationErrorCode; } });
|
|
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; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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.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;AAC7D,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,eAAe,GAAG,MAAM;AACrK,IAAI,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;AACpD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;AACvI,IAAI,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC;AAChE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,uBAAuB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;AACzJ,IAAI,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;AAC1C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,wBAAwB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAC;AAChJ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;AACxI,IAAI,8BAA8B,GAAG,OAAO,CAAC,gCAAgC,CAAC;AAC9E,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,8BAA8B,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,8BAA8B,CAAC,4BAA4B,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.repackageUnauthorizedError = repackageUnauthorizedError;
|
|
7
|
+
/**
|
|
8
|
+
* Checks to see if the given response or subscription message contains an
|
|
9
|
+
* Unauthorized error. If it does, it changes the error message to include instructions
|
|
10
|
+
* for the app developer.
|
|
11
|
+
*/
|
|
12
|
+
function repackageUnauthorizedError(content) {
|
|
13
|
+
if (content.errors && Array.isArray(content.errors)) {
|
|
14
|
+
content.errors.forEach(e => {
|
|
15
|
+
if (isUnauthorizedError(e)) {
|
|
16
|
+
e.message = 'Unauthorized';
|
|
17
|
+
e.recoverySuggestion =
|
|
18
|
+
`If you're calling an Amplify-generated API, make sure ` +
|
|
19
|
+
`to set the "authMode" in generateClient({ authMode: '...' }) to the backend authorization ` +
|
|
20
|
+
`rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return content;
|
|
25
|
+
}
|
|
26
|
+
function isUnauthorizedError(error) {
|
|
27
|
+
// Error pattern corresponding to appsync calls
|
|
28
|
+
if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
// Error pattern corresponding to appsync subscriptions
|
|
32
|
+
if (error.message?.startsWith('Connection failed:') &&
|
|
33
|
+
error.message?.includes('Permission denied')) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=repackageAuthError.js.map
|
|
@@ -0,0 +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.repackageUnauthorizedError = repackageUnauthorizedError;\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}\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;AAC7D,OAAO,CAAC,0BAA0B,GAAG,0BAA0B;AAC/D;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;AAC1C,gBAAgB,CAAC,CAAC,kBAAkB;AACpC,oBAAoB,CAAC,sDAAsD,CAAC;AAC5E,wBAAwB,CAAC,0FAA0F,CAAC;AACpH,wBAAwB,CAAC,oEAAoE,CAAC;AAC9F,YAAY;AACZ,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ,IAAI,OAAO,OAAO;AAClB;AACA,SAAS,mBAAmB,CAAC,KAAK,EAAE;AACpC;AACA,IAAI,IAAI,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,CAAC,uBAAuB,CAAC,EAAE;AACzE,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ;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;AACnB,IAAI;AACJ,IAAI,OAAO,KAAK;AAChB;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.validationErrorMap = exports.APIValidationErrorCode = void 0;
|
|
7
|
+
var APIValidationErrorCode;
|
|
8
|
+
(function (APIValidationErrorCode) {
|
|
9
|
+
APIValidationErrorCode["NoAuthSession"] = "NoAuthSession";
|
|
10
|
+
APIValidationErrorCode["NoRegion"] = "NoRegion";
|
|
11
|
+
APIValidationErrorCode["NoCustomEndpoint"] = "NoCustomEndpoint";
|
|
12
|
+
})(APIValidationErrorCode || (exports.APIValidationErrorCode = APIValidationErrorCode = {}));
|
|
13
|
+
exports.validationErrorMap = {
|
|
14
|
+
[APIValidationErrorCode.NoAuthSession]: {
|
|
15
|
+
message: 'Auth session should not be empty.',
|
|
16
|
+
},
|
|
17
|
+
// TODO: re-enable when working in all test environments:
|
|
18
|
+
// [APIValidationErrorCode.NoEndpoint]: {
|
|
19
|
+
// message: 'Missing endpoint',
|
|
20
|
+
// },
|
|
21
|
+
[APIValidationErrorCode.NoRegion]: {
|
|
22
|
+
message: 'Missing region.',
|
|
23
|
+
},
|
|
24
|
+
[APIValidationErrorCode.NoCustomEndpoint]: {
|
|
25
|
+
message: 'Custom endpoint region is present without custom endpoint.',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sources":["../../../../src/utils/errors/validation.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 = void 0;\nvar APIValidationErrorCode;\n(function (APIValidationErrorCode) {\n APIValidationErrorCode[\"NoAuthSession\"] = \"NoAuthSession\";\n APIValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n APIValidationErrorCode[\"NoCustomEndpoint\"] = \"NoCustomEndpoint\";\n})(APIValidationErrorCode || (exports.APIValidationErrorCode = APIValidationErrorCode = {}));\nexports.validationErrorMap = {\n [APIValidationErrorCode.NoAuthSession]: {\n message: 'Auth session should not be empty.',\n },\n // TODO: re-enable when working in all test environments:\n // [APIValidationErrorCode.NoEndpoint]: {\n // \tmessage: 'Missing endpoint',\n // },\n [APIValidationErrorCode.NoRegion]: {\n message: 'Missing region.',\n },\n [APIValidationErrorCode.NoCustomEndpoint]: {\n message: 'Custom endpoint region is present without custom endpoint.',\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,GAAG,MAAM;AACpE,IAAI,sBAAsB;AAC1B,CAAC,UAAU,sBAAsB,EAAE;AACnC,IAAI,sBAAsB,CAAC,eAAe,CAAC,GAAG,eAAe;AAC7D,IAAI,sBAAsB,CAAC,UAAU,CAAC,GAAG,UAAU;AACnD,IAAI,sBAAsB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB;AACnE,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,sBAAsB,GAAG,sBAAsB,GAAG,EAAE,CAAC,CAAC;AAC5F,OAAO,CAAC,kBAAkB,GAAG;AAC7B,IAAI,CAAC,sBAAsB,CAAC,aAAa,GAAG;AAC5C,QAAQ,OAAO,EAAE,mCAAmC;AACpD,KAAK;AACL;AACA;AACA;AACA;AACA,IAAI,CAAC,sBAAsB,CAAC,QAAQ,GAAG;AACvC,QAAQ,OAAO,EAAE,iBAAiB;AAClC,KAAK;AACL,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,GAAG;AAC/C,QAAQ,OAAO,EAAE,4DAA4D;AAC7E,KAAK;AACL,CAAC;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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.resolveLibraryOptions = exports.resolveConfig = void 0;
|
|
7
|
+
var resolveConfig_1 = require("./resolveConfig");
|
|
8
|
+
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });
|
|
9
|
+
var resolveLibraryOptions_1 = require("./resolveLibraryOptions");
|
|
10
|
+
Object.defineProperty(exports, "resolveLibraryOptions", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveLibraryOptions = exports.resolveConfig = void 0;\nvar resolveConfig_1 = require(\"./resolveConfig\");\nObject.defineProperty(exports, \"resolveConfig\", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });\nvar resolveLibraryOptions_1 = require(\"./resolveLibraryOptions\");\nObject.defineProperty(exports, \"resolveLibraryOptions\", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,aAAa,GAAG,MAAM;AAC9D,IAAI,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAChD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;AACjI,IAAI,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC;AAChE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,uBAAuB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.resolveConfig = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
const logger = new core_1.ConsoleLogger('GraphQLAPI resolveConfig');
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
const resolveConfig = (amplify) => {
|
|
14
|
+
const config = amplify.getConfig();
|
|
15
|
+
if (!config.API?.GraphQL) {
|
|
16
|
+
logger.warn('The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().');
|
|
17
|
+
}
|
|
18
|
+
const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = config.API?.GraphQL ?? {};
|
|
19
|
+
// TODO: re-enable when working in all test environments:
|
|
20
|
+
// assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);
|
|
21
|
+
(0, errors_1.assertValidationError)(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);
|
|
22
|
+
return {
|
|
23
|
+
apiKey,
|
|
24
|
+
customEndpoint,
|
|
25
|
+
customEndpointRegion,
|
|
26
|
+
defaultAuthMode,
|
|
27
|
+
endpoint,
|
|
28
|
+
region,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.resolveConfig = resolveConfig;
|
|
32
|
+
//# sourceMappingURL=resolveConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveConfig.js","sources":["../../../src/utils/resolveConfig.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.resolveConfig = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst errors_1 = require(\"./errors\");\nconst logger = new core_1.ConsoleLogger('GraphQLAPI resolveConfig');\n/**\n * @internal\n */\nconst resolveConfig = (amplify) => {\n const config = amplify.getConfig();\n if (!config.API?.GraphQL) {\n logger.warn('The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().');\n }\n const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = config.API?.GraphQL ?? {};\n // TODO: re-enable when working in all test environments:\n // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);\n (0, errors_1.assertValidationError)(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);\n return {\n apiKey,\n customEndpoint,\n customEndpointRegion,\n defaultAuthMode,\n endpoint,\n region,\n };\n};\nexports.resolveConfig = resolveConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,aAAa,GAAG,MAAM;AAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,0BAA0B,CAAC;AACnE;AACA;AACA;AACA,MAAM,aAAa,GAAG,CAAC,OAAO,KAAK;AACnC,IAAI,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE;AACtC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE;AAC9B,QAAQ,MAAM,CAAC,IAAI,CAAC,yHAAyH,CAAC;AAC9I,IAAI;AACJ,IAAI,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,IAAI,EAAE;AAC1H;AACA;AACA,IAAI,IAAI,QAAQ,CAAC,qBAAqB,EAAE,EAAE,CAAC,cAAc,IAAI,oBAAoB,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,gBAAgB,CAAC;AACrI,IAAI,OAAO;AACX,QAAQ,MAAM;AACd,QAAQ,cAAc;AACtB,QAAQ,oBAAoB;AAC5B,QAAQ,eAAe;AACvB,QAAQ,QAAQ;AAChB,QAAQ,MAAM;AACd,KAAK;AACL,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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.resolveLibraryOptions = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const resolveLibraryOptions = (amplify) => {
|
|
11
|
+
const headers = amplify.libraryOptions?.API?.GraphQL?.headers;
|
|
12
|
+
const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;
|
|
13
|
+
return { headers, withCredentials };
|
|
14
|
+
};
|
|
15
|
+
exports.resolveLibraryOptions = resolveLibraryOptions;
|
|
16
|
+
//# sourceMappingURL=resolveLibraryOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveLibraryOptions.js","sources":["../../../src/utils/resolveLibraryOptions.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveLibraryOptions = void 0;\n/**\n * @internal\n */\nconst resolveLibraryOptions = (amplify) => {\n const headers = amplify.libraryOptions?.API?.GraphQL?.headers;\n const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;\n return { headers, withCredentials };\n};\nexports.resolveLibraryOptions = resolveLibraryOptions;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,qBAAqB,GAAG,MAAM;AACtC;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,CAAC,OAAO,KAAK;AAC3C,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;AACjE,IAAI,MAAM,eAAe,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe;AACjF,IAAI,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE;AACvC,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
+
import { CustomHeaders } from '@aws-amplify/data-schema/runtime';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { GraphQLOptions, GraphQLResult } from './types';
|
|
5
|
+
import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
|
|
6
|
+
export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
|
|
7
|
+
query: any;
|
|
8
|
+
variables: {};
|
|
9
|
+
authToken: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Export Cloud Logic APIs
|
|
13
|
+
*/
|
|
14
|
+
export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
|
|
15
|
+
getModuleName(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Executes a GraphQL operation
|
|
18
|
+
*
|
|
19
|
+
* @param options - GraphQL Options
|
|
20
|
+
* @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
|
|
21
|
+
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
22
|
+
*/
|
|
23
|
+
graphql<T = any>(amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>), options: GraphQLOptions, additionalHeaders?: CustomHeaders): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
|
|
24
|
+
/**
|
|
25
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
26
|
+
* @param error - Any error
|
|
27
|
+
* @returns A boolean indicating if the error was from an api request cancellation
|
|
28
|
+
*/
|
|
29
|
+
isCancelError(error: any): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
32
|
+
* @param {any} request - request to cancel
|
|
33
|
+
* @returns A boolean indicating if the request was cancelled
|
|
34
|
+
*/
|
|
35
|
+
cancel(request: Promise<any>, message?: string): boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const GraphQLAPI: GraphQLAPIClass;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ApiAction, Category } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import { INTERNAL_USER_AGENT_OVERRIDE } from '@aws-amplify/data-schema/runtime';
|
|
3
|
+
import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI.mjs';
|
|
4
|
+
|
|
5
|
+
function isGraphQLOptionsWithOverride(options) {
|
|
6
|
+
return INTERNAL_USER_AGENT_OVERRIDE in options;
|
|
7
|
+
}
|
|
8
|
+
const graphqlOperation = (query, variables = {}, authToken) => ({
|
|
9
|
+
query,
|
|
10
|
+
variables,
|
|
11
|
+
authToken,
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Export Cloud Logic APIs
|
|
15
|
+
*/
|
|
16
|
+
class GraphQLAPIClass extends InternalGraphQLAPIClass {
|
|
17
|
+
getModuleName() {
|
|
18
|
+
return 'GraphQLAPI';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Executes a GraphQL operation
|
|
22
|
+
*
|
|
23
|
+
* @param options - GraphQL Options
|
|
24
|
+
* @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
|
|
25
|
+
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
26
|
+
*/
|
|
27
|
+
graphql(amplify, options, additionalHeaders) {
|
|
28
|
+
const userAgentDetails = {
|
|
29
|
+
category: Category.API,
|
|
30
|
+
action: ApiAction.GraphQl,
|
|
31
|
+
};
|
|
32
|
+
if (isGraphQLOptionsWithOverride(options)) {
|
|
33
|
+
const { [INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride, ...cleanOptions } = options;
|
|
34
|
+
return super.graphql(amplify, cleanOptions, additionalHeaders, {
|
|
35
|
+
...userAgentDetails,
|
|
36
|
+
...internalUserAgentOverride,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return super.graphql(amplify, options, additionalHeaders, {
|
|
40
|
+
...userAgentDetails,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
45
|
+
* @param error - Any error
|
|
46
|
+
* @returns A boolean indicating if the error was from an api request cancellation
|
|
47
|
+
*/
|
|
48
|
+
isCancelError(error) {
|
|
49
|
+
return super.isCancelError(error);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
53
|
+
* @param {any} request - request to cancel
|
|
54
|
+
* @returns A boolean indicating if the request was cancelled
|
|
55
|
+
*/
|
|
56
|
+
cancel(request, message) {
|
|
57
|
+
return super.cancel(request, message);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const GraphQLAPI = new GraphQLAPIClass();
|
|
61
|
+
|
|
62
|
+
export { GraphQLAPI, GraphQLAPIClass, graphqlOperation };
|
|
63
|
+
//# sourceMappingURL=GraphQLAPI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import { ApiAction, Category, } from '@aws-amplify/core/internals/utils';\nimport { INTERNAL_USER_AGENT_OVERRIDE, } from '@aws-amplify/data-schema/runtime';\nimport { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';\nfunction isGraphQLOptionsWithOverride(options) {\n return INTERNAL_USER_AGENT_OVERRIDE in options;\n}\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 const userAgentDetails = {\n category: Category.API,\n action: ApiAction.GraphQl,\n };\n if (isGraphQLOptionsWithOverride(options)) {\n const { [INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride, ...cleanOptions } = options;\n return super.graphql(amplify, cleanOptions, additionalHeaders, {\n ...userAgentDetails,\n ...internalUserAgentOverride,\n });\n }\n return super.graphql(amplify, options, additionalHeaders, {\n ...userAgentDetails,\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":";;;;AAGA,SAAS,4BAA4B,CAAC,OAAO,EAAE;AAC/C,IAAI,OAAO,4BAA4B,IAAI,OAAO;AAClD;AACY,MAAC,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,MAAM;AACvE,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,SAAS;AACb,CAAC;AACD;AACA;AACA;AACO,MAAM,eAAe,SAAS,uBAAuB,CAAC;AAC7D,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY;AAC3B,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,MAAM,gBAAgB,GAAG;AACjC,YAAY,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAClC,YAAY,MAAM,EAAE,SAAS,CAAC,OAAO;AACrC,SAAS;AACT,QAAQ,IAAI,4BAA4B,CAAC,OAAO,CAAC,EAAE;AACnD,YAAY,MAAM,EAAE,CAAC,4BAA4B,GAAG,yBAAyB,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO;AAC1G,YAAY,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE;AAC3E,gBAAgB,GAAG,gBAAgB;AACnC,gBAAgB,GAAG,yBAAyB;AAC5C,aAAa,CAAC;AACd,QAAQ;AACR,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,GAAG,gBAAgB;AAC/B,SAAS,CAAC;AACV,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC;AACzC,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;AAC7C,IAAI;AACJ;AACY,MAAC,UAAU,GAAG,IAAI,eAAe;;;;"}
|