@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,270 @@
|
|
|
1
|
+
import { parse, print } from 'graphql';
|
|
2
|
+
import { catchError } from 'rxjs';
|
|
3
|
+
import { AmplifyUrl, getAmplifyUserAgent } from '@aws-amplify/core/internals/utils';
|
|
4
|
+
import { isCancelError } from '@aws-amplify/api-rest';
|
|
5
|
+
import { updateRequestToBeCancellable, cancel, post } from '@aws-amplify/api-rest/internals';
|
|
6
|
+
import { AWSAppSyncRealTimeProvider } from '../Providers/AWSAppSyncRealTimeProvider/index.mjs';
|
|
7
|
+
import { resolveConfig } from '../utils/resolveConfig.mjs';
|
|
8
|
+
import { resolveLibraryOptions } from '../utils/resolveLibraryOptions.mjs';
|
|
9
|
+
import { repackageUnauthorizedError } from '../utils/errors/repackageAuthError.mjs';
|
|
10
|
+
import { NO_ENDPOINT } from '../utils/errors/constants.mjs';
|
|
11
|
+
import { GraphQLApiError } from '../utils/errors/GraphQLApiError.mjs';
|
|
12
|
+
import '../utils/errors/validation.mjs';
|
|
13
|
+
import { createGraphQLResultWithError } from '../utils/errors/createGraphQLResultWithError.mjs';
|
|
14
|
+
import { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs';
|
|
15
|
+
import { headerBasedAuth } from './graphqlAuth.mjs';
|
|
16
|
+
|
|
17
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
18
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
const USER_AGENT_HEADER = 'x-amz-user-agent';
|
|
20
|
+
const isAmplifyInstance = (amplify) => {
|
|
21
|
+
return typeof amplify !== 'function';
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Export Cloud Logic APIs
|
|
25
|
+
*/
|
|
26
|
+
class InternalGraphQLAPIClass {
|
|
27
|
+
constructor() {
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
this.appSyncRealTime = new Map();
|
|
32
|
+
this._api = {
|
|
33
|
+
post,
|
|
34
|
+
cancelREST: cancel,
|
|
35
|
+
isCancelErrorREST: isCancelError,
|
|
36
|
+
updateRequestToBeCancellable,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
getModuleName() {
|
|
40
|
+
return 'InternalGraphQLAPI';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* to get the operation type
|
|
44
|
+
* @param operation
|
|
45
|
+
*/
|
|
46
|
+
getGraphqlOperationType(operation) {
|
|
47
|
+
const doc = parse(operation);
|
|
48
|
+
const definitions = doc.definitions;
|
|
49
|
+
const [{ operation: operationType }] = definitions;
|
|
50
|
+
return operationType;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Executes a GraphQL operation
|
|
54
|
+
*
|
|
55
|
+
* @param options - GraphQL Options
|
|
56
|
+
* @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
|
|
57
|
+
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
58
|
+
*/
|
|
59
|
+
graphql(amplify, { query: paramQuery, variables = {}, authMode, authToken, endpoint, apiKey, }, additionalHeaders, customUserAgentDetails) {
|
|
60
|
+
const query = typeof paramQuery === 'string'
|
|
61
|
+
? parse(paramQuery)
|
|
62
|
+
: parse(print(paramQuery));
|
|
63
|
+
const [operationDef = {}] = query.definitions.filter(def => def.kind === 'OperationDefinition');
|
|
64
|
+
const { operation: operationType } = operationDef;
|
|
65
|
+
const headers = additionalHeaders || {};
|
|
66
|
+
switch (operationType) {
|
|
67
|
+
case 'query':
|
|
68
|
+
case 'mutation': {
|
|
69
|
+
const abortController = new AbortController();
|
|
70
|
+
let responsePromise;
|
|
71
|
+
if (isAmplifyInstance(amplify)) {
|
|
72
|
+
responsePromise = this._graphql(amplify, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// NOTE: this wrapper function must be await-able so the Amplify server context manager can
|
|
76
|
+
// destroy the context only after it completes
|
|
77
|
+
const wrapper = async (amplifyInstance) => {
|
|
78
|
+
const result = await this._graphql(amplifyInstance, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
responsePromise = amplify(wrapper);
|
|
82
|
+
}
|
|
83
|
+
this._api.updateRequestToBeCancellable(responsePromise, abortController);
|
|
84
|
+
return responsePromise;
|
|
85
|
+
}
|
|
86
|
+
case 'subscription':
|
|
87
|
+
return this._graphqlSubscribe(amplify, { query, variables, authMode, apiKey, endpoint }, headers, customUserAgentDetails, authToken);
|
|
88
|
+
default:
|
|
89
|
+
throw new Error(`invalid operation type: ${operationType}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async _graphql(amplify, { query, variables, authMode: authModeOverride, endpoint: endpointOverride, apiKey: apiKeyOverride, }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {
|
|
93
|
+
const { apiKey, region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, defaultAuthMode, } = resolveConfig(amplify);
|
|
94
|
+
const initialAuthMode = authModeOverride || defaultAuthMode || 'iam';
|
|
95
|
+
// identityPool is an alias for iam. TODO: remove 'iam' in v7
|
|
96
|
+
const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;
|
|
97
|
+
/**
|
|
98
|
+
* Retrieve library options from Amplify configuration.
|
|
99
|
+
* `customHeaders` here are from the Amplify configuration options,
|
|
100
|
+
* and are for non-AppSync endpoints only. These are *not* the same as
|
|
101
|
+
* `additionalHeaders`, which are custom headers that are either 1)
|
|
102
|
+
* included when configuring the API client or 2) passed along with
|
|
103
|
+
* individual requests.
|
|
104
|
+
*/
|
|
105
|
+
const { headers: customHeaders, withCredentials } = resolveLibraryOptions(amplify);
|
|
106
|
+
/**
|
|
107
|
+
* Client or request-specific custom headers that may or may not be
|
|
108
|
+
* returned by a function:
|
|
109
|
+
*/
|
|
110
|
+
let additionalCustomHeaders;
|
|
111
|
+
if (typeof additionalHeaders === 'function') {
|
|
112
|
+
const requestOptions = {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
url: new AmplifyUrl(endpointOverride || customEndpoint || appSyncGraphqlEndpoint || '').toString(),
|
|
115
|
+
queryString: print(query),
|
|
116
|
+
};
|
|
117
|
+
additionalCustomHeaders = await additionalHeaders(requestOptions);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
additionalCustomHeaders = additionalHeaders;
|
|
121
|
+
}
|
|
122
|
+
// if an authorization header is set, have the explicit authToken take precedence
|
|
123
|
+
if (authToken) {
|
|
124
|
+
additionalCustomHeaders = {
|
|
125
|
+
...additionalCustomHeaders,
|
|
126
|
+
Authorization: authToken,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const authHeaders = await headerBasedAuth(amplify, authMode, apiKeyOverride ?? apiKey, additionalCustomHeaders);
|
|
130
|
+
const headers = {
|
|
131
|
+
...(!customEndpoint && authHeaders),
|
|
132
|
+
/**
|
|
133
|
+
* Custom endpoint headers.
|
|
134
|
+
* If there is both a custom endpoint and custom region present, we get the headers.
|
|
135
|
+
* If there is a custom endpoint but no region, we return an empty object.
|
|
136
|
+
* If neither are present, we return an empty object.
|
|
137
|
+
*/
|
|
138
|
+
...((customEndpoint && (customEndpointRegion ? authHeaders : {})) || {}),
|
|
139
|
+
// Custom headers included in Amplify configuration options:
|
|
140
|
+
...(customHeaders &&
|
|
141
|
+
(await customHeaders({
|
|
142
|
+
query: print(query),
|
|
143
|
+
variables,
|
|
144
|
+
}))),
|
|
145
|
+
// Custom headers from individual requests or API client configuration:
|
|
146
|
+
...additionalCustomHeaders,
|
|
147
|
+
// User agent headers:
|
|
148
|
+
...(!customEndpoint && {
|
|
149
|
+
[USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
152
|
+
const body = {
|
|
153
|
+
query: print(query),
|
|
154
|
+
variables: variables || null,
|
|
155
|
+
};
|
|
156
|
+
let signingServiceInfo;
|
|
157
|
+
/**
|
|
158
|
+
* We do not send the signing service info to the REST API under the
|
|
159
|
+
* following conditions (i.e. it will not sign the request):
|
|
160
|
+
* - there is a custom endpoint but no region
|
|
161
|
+
* - the auth mode is `none`, or `apiKey`
|
|
162
|
+
* - the auth mode is a type other than the types listed below
|
|
163
|
+
*/
|
|
164
|
+
if ((customEndpoint && !customEndpointRegion) ||
|
|
165
|
+
(authMode !== 'oidc' &&
|
|
166
|
+
authMode !== 'userPool' &&
|
|
167
|
+
authMode !== 'iam' &&
|
|
168
|
+
authMode !== 'lambda')) {
|
|
169
|
+
signingServiceInfo = undefined;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
signingServiceInfo = {
|
|
173
|
+
service: !customEndpointRegion ? 'appsync' : 'execute-api',
|
|
174
|
+
region: !customEndpointRegion ? region : customEndpointRegion,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const endpoint = endpointOverride || customEndpoint || appSyncGraphqlEndpoint;
|
|
178
|
+
if (!endpoint) {
|
|
179
|
+
throw createGraphQLResultWithError(new GraphQLApiError(NO_ENDPOINT));
|
|
180
|
+
}
|
|
181
|
+
let response;
|
|
182
|
+
try {
|
|
183
|
+
// // // See the inline doc of the REST `post()` API for possible errors to be thrown.
|
|
184
|
+
// // // As these errors are catastrophic they should be caught and handled by GraphQL
|
|
185
|
+
// // // API consumers.
|
|
186
|
+
const { body: responseBody } = await this._api.post(amplify, {
|
|
187
|
+
url: new AmplifyUrl(endpoint),
|
|
188
|
+
options: {
|
|
189
|
+
headers,
|
|
190
|
+
body,
|
|
191
|
+
signingServiceInfo,
|
|
192
|
+
withCredentials,
|
|
193
|
+
},
|
|
194
|
+
abortController,
|
|
195
|
+
});
|
|
196
|
+
response = await responseBody.json();
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
if (this.isCancelError(error)) {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
response = createGraphQLResultWithError(error);
|
|
203
|
+
}
|
|
204
|
+
if (isGraphQLResponseWithErrors(response)) {
|
|
205
|
+
throw repackageUnauthorizedError(response);
|
|
206
|
+
}
|
|
207
|
+
return response;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
211
|
+
* @param {any} error - Any error
|
|
212
|
+
* @return {boolean} - A boolean indicating if the error was from an api request cancellation
|
|
213
|
+
*/
|
|
214
|
+
isCancelError(error) {
|
|
215
|
+
return this._api.isCancelErrorREST(error);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
219
|
+
* @param {any} request - request to cancel
|
|
220
|
+
* @returns - A boolean indicating if the request was cancelled
|
|
221
|
+
*/
|
|
222
|
+
cancel(request, message) {
|
|
223
|
+
return this._api.cancelREST(request, message);
|
|
224
|
+
}
|
|
225
|
+
_graphqlSubscribe(amplify, { query, variables, authMode: authModeOverride, apiKey: apiKeyOverride, endpoint, }, additionalHeaders = {}, customUserAgentDetails, authToken) {
|
|
226
|
+
const config = resolveConfig(amplify);
|
|
227
|
+
const initialAuthMode = authModeOverride || config?.defaultAuthMode || 'iam';
|
|
228
|
+
// identityPool is an alias for iam. TODO: remove 'iam' in v7
|
|
229
|
+
const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;
|
|
230
|
+
/**
|
|
231
|
+
* Retrieve library options from Amplify configuration.
|
|
232
|
+
* `libraryConfigHeaders` are from the Amplify configuration options,
|
|
233
|
+
* and will not be overwritten by other custom headers. These are *not*
|
|
234
|
+
* the same as `additionalHeaders`, which are custom headers that are
|
|
235
|
+
* either 1)included when configuring the API client or 2) passed along
|
|
236
|
+
* with individual requests.
|
|
237
|
+
*/
|
|
238
|
+
const { headers: libraryConfigHeaders } = resolveLibraryOptions(amplify);
|
|
239
|
+
const appSyncGraphqlEndpoint = endpoint ?? config?.endpoint;
|
|
240
|
+
// TODO: This could probably be an exception. But, lots of tests rely on
|
|
241
|
+
// attempting to connect to nowhere. So, I'm treating as the opposite of
|
|
242
|
+
// a Chesterton's fence for now. (A fence I shouldn't build, because I don't
|
|
243
|
+
// know why somethings depends on its absence!)
|
|
244
|
+
const memoKey = appSyncGraphqlEndpoint ?? 'none';
|
|
245
|
+
const realtimeProvider = this.appSyncRealTime.get(memoKey) ?? new AWSAppSyncRealTimeProvider();
|
|
246
|
+
this.appSyncRealTime.set(memoKey, realtimeProvider);
|
|
247
|
+
return realtimeProvider
|
|
248
|
+
.subscribe({
|
|
249
|
+
query: print(query),
|
|
250
|
+
variables,
|
|
251
|
+
appSyncGraphqlEndpoint,
|
|
252
|
+
region: config?.region,
|
|
253
|
+
authenticationType: authMode,
|
|
254
|
+
apiKey: apiKeyOverride ?? config?.apiKey,
|
|
255
|
+
additionalHeaders,
|
|
256
|
+
authToken,
|
|
257
|
+
libraryConfigHeaders,
|
|
258
|
+
}, customUserAgentDetails)
|
|
259
|
+
.pipe(catchError(e => {
|
|
260
|
+
if (e.errors) {
|
|
261
|
+
throw repackageUnauthorizedError(e);
|
|
262
|
+
}
|
|
263
|
+
throw e;
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const InternalGraphQLAPI = new InternalGraphQLAPIClass();
|
|
268
|
+
|
|
269
|
+
export { InternalGraphQLAPI, InternalGraphQLAPIClass };
|
|
270
|
+
//# sourceMappingURL=InternalGraphQLAPI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalGraphQLAPI.mjs","sources":["../../../src/internals/InternalGraphQLAPI.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parse, print, } from 'graphql';\nimport { catchError } from 'rxjs';\nimport { AmplifyUrl, getAmplifyUserAgent, } from '@aws-amplify/core/internals/utils';\nimport { isCancelError as isCancelErrorREST } from '@aws-amplify/api-rest';\nimport { cancel as cancelREST, post, updateRequestToBeCancellable, } from '@aws-amplify/api-rest/internals';\nimport { AWSAppSyncRealTimeProvider } from '../Providers/AWSAppSyncRealTimeProvider';\nimport { resolveConfig, resolveLibraryOptions } from '../utils';\nimport { repackageUnauthorizedError } from '../utils/errors/repackageAuthError';\nimport { NO_ENDPOINT } from '../utils/errors/constants';\nimport { GraphQLApiError, createGraphQLResultWithError } from '../utils/errors';\nimport { isGraphQLResponseWithErrors } from './utils/runtimeTypeGuards/isGraphQLResponseWithErrors';\nimport { headerBasedAuth } from './graphqlAuth';\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst isAmplifyInstance = (amplify) => {\n return typeof amplify !== 'function';\n};\n/**\n * Export Cloud Logic APIs\n */\nexport class InternalGraphQLAPIClass {\n constructor() {\n /**\n * @private\n */\n this.appSyncRealTime = new Map();\n this._api = {\n post,\n cancelREST,\n isCancelErrorREST,\n updateRequestToBeCancellable,\n };\n }\n getModuleName() {\n return 'InternalGraphQLAPI';\n }\n /**\n * to get the operation type\n * @param operation\n */\n getGraphqlOperationType(operation) {\n const doc = parse(operation);\n const definitions = doc.definitions;\n const [{ operation: operationType }] = definitions;\n return operationType;\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, { query: paramQuery, variables = {}, authMode, authToken, endpoint, apiKey, }, additionalHeaders, customUserAgentDetails) {\n const query = typeof paramQuery === 'string'\n ? parse(paramQuery)\n : parse(print(paramQuery));\n const [operationDef = {}] = query.definitions.filter(def => def.kind === 'OperationDefinition');\n const { operation: operationType } = operationDef;\n const headers = additionalHeaders || {};\n switch (operationType) {\n case 'query':\n case 'mutation': {\n const abortController = new AbortController();\n let responsePromise;\n if (isAmplifyInstance(amplify)) {\n responsePromise = this._graphql(amplify, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);\n }\n else {\n // NOTE: this wrapper function must be await-able so the Amplify server context manager can\n // destroy the context only after it completes\n const wrapper = async (amplifyInstance) => {\n const result = await this._graphql(amplifyInstance, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);\n return result;\n };\n responsePromise = amplify(wrapper);\n }\n this._api.updateRequestToBeCancellable(responsePromise, abortController);\n return responsePromise;\n }\n case 'subscription':\n return this._graphqlSubscribe(amplify, { query, variables, authMode, apiKey, endpoint }, headers, customUserAgentDetails, authToken);\n default:\n throw new Error(`invalid operation type: ${operationType}`);\n }\n }\n async _graphql(amplify, { query, variables, authMode: authModeOverride, endpoint: endpointOverride, apiKey: apiKeyOverride, }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {\n const { apiKey, region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, defaultAuthMode, } = resolveConfig(amplify);\n const initialAuthMode = authModeOverride || defaultAuthMode || 'iam';\n // identityPool is an alias for iam. TODO: remove 'iam' in v7\n const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;\n /**\n * Retrieve library options from Amplify configuration.\n * `customHeaders` here are from the Amplify configuration options,\n * and are for non-AppSync endpoints only. These are *not* the same as\n * `additionalHeaders`, which are custom headers that are either 1)\n * included when configuring the API client or 2) passed along with\n * individual requests.\n */\n const { headers: customHeaders, withCredentials } = resolveLibraryOptions(amplify);\n /**\n * Client or request-specific custom headers that may or may not be\n * returned by a function:\n */\n let additionalCustomHeaders;\n if (typeof additionalHeaders === 'function') {\n const requestOptions = {\n method: 'POST',\n url: new AmplifyUrl(endpointOverride || customEndpoint || appSyncGraphqlEndpoint || '').toString(),\n queryString: print(query),\n };\n additionalCustomHeaders = await additionalHeaders(requestOptions);\n }\n else {\n additionalCustomHeaders = additionalHeaders;\n }\n // if an authorization header is set, have the explicit authToken take precedence\n if (authToken) {\n additionalCustomHeaders = {\n ...additionalCustomHeaders,\n Authorization: authToken,\n };\n }\n const authHeaders = await headerBasedAuth(amplify, authMode, apiKeyOverride ?? apiKey, additionalCustomHeaders);\n const headers = {\n ...(!customEndpoint && authHeaders),\n /**\n * Custom endpoint headers.\n * If there is both a custom endpoint and custom region present, we get the headers.\n * If there is a custom endpoint but no region, we return an empty object.\n * If neither are present, we return an empty object.\n */\n ...((customEndpoint && (customEndpointRegion ? authHeaders : {})) || {}),\n // Custom headers included in Amplify configuration options:\n ...(customHeaders &&\n (await customHeaders({\n query: print(query),\n variables,\n }))),\n // Custom headers from individual requests or API client configuration:\n ...additionalCustomHeaders,\n // User agent headers:\n ...(!customEndpoint && {\n [USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),\n }),\n };\n const body = {\n query: print(query),\n variables: variables || null,\n };\n let signingServiceInfo;\n /**\n * We do not send the signing service info to the REST API under the\n * following conditions (i.e. it will not sign the request):\n * - there is a custom endpoint but no region\n * - the auth mode is `none`, or `apiKey`\n * - the auth mode is a type other than the types listed below\n */\n if ((customEndpoint && !customEndpointRegion) ||\n (authMode !== 'oidc' &&\n authMode !== 'userPool' &&\n authMode !== 'iam' &&\n authMode !== 'lambda')) {\n signingServiceInfo = undefined;\n }\n else {\n signingServiceInfo = {\n service: !customEndpointRegion ? 'appsync' : 'execute-api',\n region: !customEndpointRegion ? region : customEndpointRegion,\n };\n }\n const endpoint = endpointOverride || customEndpoint || appSyncGraphqlEndpoint;\n if (!endpoint) {\n throw createGraphQLResultWithError(new GraphQLApiError(NO_ENDPOINT));\n }\n let response;\n try {\n // \t// // See the inline doc of the REST `post()` API for possible errors to be thrown.\n // \t// // As these errors are catastrophic they should be caught and handled by GraphQL\n // \t// // API consumers.\n const { body: responseBody } = await this._api.post(amplify, {\n url: new AmplifyUrl(endpoint),\n options: {\n headers,\n body,\n signingServiceInfo,\n withCredentials,\n },\n abortController,\n });\n response = await responseBody.json();\n }\n catch (error) {\n if (this.isCancelError(error)) {\n throw error;\n }\n response = createGraphQLResultWithError(error);\n }\n if (isGraphQLResponseWithErrors(response)) {\n throw repackageUnauthorizedError(response);\n }\n return response;\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @return {boolean} - A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return this._api.isCancelErrorREST(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 this._api.cancelREST(request, message);\n }\n _graphqlSubscribe(amplify, { query, variables, authMode: authModeOverride, apiKey: apiKeyOverride, endpoint, }, additionalHeaders = {}, customUserAgentDetails, authToken) {\n const config = resolveConfig(amplify);\n const initialAuthMode = authModeOverride || config?.defaultAuthMode || 'iam';\n // identityPool is an alias for iam. TODO: remove 'iam' in v7\n const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;\n /**\n * Retrieve library options from Amplify configuration.\n * `libraryConfigHeaders` are from the Amplify configuration options,\n * and will not be overwritten by other custom headers. These are *not*\n * the same as `additionalHeaders`, which are custom headers that are\n * either 1)included when configuring the API client or 2) passed along\n * with individual requests.\n */\n const { headers: libraryConfigHeaders } = resolveLibraryOptions(amplify);\n const appSyncGraphqlEndpoint = endpoint ?? config?.endpoint;\n // TODO: This could probably be an exception. But, lots of tests rely on\n // attempting to connect to nowhere. So, I'm treating as the opposite of\n // a Chesterton's fence for now. (A fence I shouldn't build, because I don't\n // know why somethings depends on its absence!)\n const memoKey = appSyncGraphqlEndpoint ?? 'none';\n const realtimeProvider = this.appSyncRealTime.get(memoKey) ?? new AWSAppSyncRealTimeProvider();\n this.appSyncRealTime.set(memoKey, realtimeProvider);\n return realtimeProvider\n .subscribe({\n query: print(query),\n variables,\n appSyncGraphqlEndpoint,\n region: config?.region,\n authenticationType: authMode,\n apiKey: apiKeyOverride ?? config?.apiKey,\n additionalHeaders,\n authToken,\n libraryConfigHeaders,\n }, customUserAgentDetails)\n .pipe(catchError(e => {\n if (e.errors) {\n throw repackageUnauthorizedError(e);\n }\n throw e;\n }));\n }\n}\nexport const InternalGraphQLAPI = new InternalGraphQLAPIClass();\n"],"names":["cancelREST","isCancelErrorREST"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAaA,MAAM,iBAAiB,GAAG,kBAAkB;AAC5C,MAAM,iBAAiB,GAAG,CAAC,OAAO,KAAK;AACvC,IAAI,OAAO,OAAO,OAAO,KAAK,UAAU;AACxC,CAAC;AACD;AACA;AACA;AACO,MAAM,uBAAuB,CAAC;AACrC,IAA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AAY,SAAS;AACrB,YAAY,oBAAoB;AAChC,SAAS,EAAE,sBAAsB;AACjC,aAAa,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI;AAClC,YAAY,IAAI,CAAC,CAAC,MAAM,EAAE;AAC1B,gBAAgB,MAAM,0BAA0B,CAAC,CAAC,CAAC;AACnD,YAAY;AACZ,YAAY,MAAM,CAAC;AACnB,QAAQ,CAAC,CAAC,CAAC;AACX,IAAI;AACJ;AACY,MAAC,kBAAkB,GAAG,IAAI,uBAAuB;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
+
import { CustomUserAgentDetails, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
import { CustomHeaders } from '@aws-amplify/data-schema/runtime';
|
|
4
|
+
interface GqlRequestOptions {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
region?: string;
|
|
7
|
+
appSyncGraphqlEndpoint: string;
|
|
8
|
+
authenticationType: GraphQLAuthMode;
|
|
9
|
+
query: string;
|
|
10
|
+
variables: string[];
|
|
11
|
+
authToken?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function appsyncRequest<T = any>(amplify: AmplifyClassV6, options: GqlRequestOptions, additionalHeaders: CustomHeaders | undefined, abortController: AbortController, customUserAgentDetails?: CustomUserAgentDetails): Promise<T>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { AmplifyUrl, getAmplifyUserAgent } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import { post } from '@aws-amplify/api-rest/internals';
|
|
3
|
+
import '../../utils/resolveConfig.mjs';
|
|
4
|
+
import { resolveLibraryOptions } from '../../utils/resolveLibraryOptions.mjs';
|
|
5
|
+
import { repackageUnauthorizedError } from '../../utils/errors/repackageAuthError.mjs';
|
|
6
|
+
import { headerBasedAuth } from '../graphqlAuth.mjs';
|
|
7
|
+
import { isGraphQLResponseWithErrors } from '../utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs';
|
|
8
|
+
|
|
9
|
+
const USER_AGENT_HEADER = 'x-amz-user-agent';
|
|
10
|
+
// This is effectively a copy of InternalGraphQLAPI.ts._graphql(...)
|
|
11
|
+
// Our existing unit tests are tightly coupled to the implementation, so i was unable to refactor
|
|
12
|
+
// and extend _graphql() without having to change a bunch of tests as well... which in turn reduces confidence
|
|
13
|
+
// that this feature will _not affect_ GQL behavior.
|
|
14
|
+
async function appsyncRequest(amplify, options, additionalHeaders = {}, abortController, customUserAgentDetails) {
|
|
15
|
+
const { region, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, } = options;
|
|
16
|
+
if (!endpoint) {
|
|
17
|
+
throw new Error('No endpoint');
|
|
18
|
+
}
|
|
19
|
+
const { withCredentials } = resolveLibraryOptions(amplify);
|
|
20
|
+
const headers = await requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails);
|
|
21
|
+
const body = {
|
|
22
|
+
channel: query,
|
|
23
|
+
events: variables,
|
|
24
|
+
};
|
|
25
|
+
const signingServiceInfo = ['apiKey', 'none'].includes(authMode)
|
|
26
|
+
? undefined
|
|
27
|
+
: {
|
|
28
|
+
service: 'appsync',
|
|
29
|
+
region,
|
|
30
|
+
};
|
|
31
|
+
const { body: responseBody } = await post(amplify, {
|
|
32
|
+
url: new AmplifyUrl(endpoint),
|
|
33
|
+
options: {
|
|
34
|
+
headers,
|
|
35
|
+
body,
|
|
36
|
+
signingServiceInfo,
|
|
37
|
+
withCredentials,
|
|
38
|
+
},
|
|
39
|
+
abortController,
|
|
40
|
+
});
|
|
41
|
+
const response = await responseBody.json();
|
|
42
|
+
if (isGraphQLResponseWithErrors(response)) {
|
|
43
|
+
throw repackageUnauthorizedError(response);
|
|
44
|
+
}
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Computes all the necessary HTTP headers for the request based on:
|
|
49
|
+
* 1. Operation-level header options
|
|
50
|
+
* 2. Amplify.configure custom headers
|
|
51
|
+
* 3. AuthZ headers for explicit auth mode specified for operation ?? default auth mode in config
|
|
52
|
+
*
|
|
53
|
+
* @returns HTTP request headers key/value
|
|
54
|
+
*/
|
|
55
|
+
async function requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails) {
|
|
56
|
+
const { apiKey, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, authToken, } = options;
|
|
57
|
+
const { headers: customHeadersFn } = resolveLibraryOptions(amplify);
|
|
58
|
+
let additionalCustomHeaders;
|
|
59
|
+
if (typeof additionalHeaders === 'function') {
|
|
60
|
+
const requestOptions = {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
url: new AmplifyUrl(endpoint).toString(),
|
|
63
|
+
queryString: query,
|
|
64
|
+
};
|
|
65
|
+
additionalCustomHeaders = await additionalHeaders(requestOptions);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
additionalCustomHeaders = additionalHeaders;
|
|
69
|
+
}
|
|
70
|
+
// if an authorization header is set, have the operation-level authToken take precedence
|
|
71
|
+
if (authToken) {
|
|
72
|
+
additionalCustomHeaders = {
|
|
73
|
+
...additionalCustomHeaders,
|
|
74
|
+
Authorization: authToken,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const authHeaders = await headerBasedAuth(amplify, authMode, apiKey, additionalCustomHeaders);
|
|
78
|
+
const customHeaders = customHeadersFn &&
|
|
79
|
+
(await customHeadersFn({
|
|
80
|
+
query,
|
|
81
|
+
variables: variables,
|
|
82
|
+
}));
|
|
83
|
+
const headers = {
|
|
84
|
+
...authHeaders,
|
|
85
|
+
// Custom headers included in Amplify configuration options:
|
|
86
|
+
...customHeaders,
|
|
87
|
+
// Custom headers from individual requests or API client configuration:
|
|
88
|
+
...additionalCustomHeaders,
|
|
89
|
+
// User agent headers:
|
|
90
|
+
[USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
|
|
91
|
+
};
|
|
92
|
+
return headers;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { appsyncRequest };
|
|
96
|
+
//# sourceMappingURL=appsyncRequest.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appsyncRequest.mjs","sources":["../../../../src/internals/events/appsyncRequest.ts"],"sourcesContent":["import { AmplifyUrl, getAmplifyUserAgent, } from '@aws-amplify/core/internals/utils';\nimport { post } from '@aws-amplify/api-rest/internals';\nimport { resolveLibraryOptions } from '../../utils';\nimport { repackageUnauthorizedError } from '../../utils/errors/repackageAuthError';\nimport { headerBasedAuth } from '../graphqlAuth';\nimport { isGraphQLResponseWithErrors } from '../utils/runtimeTypeGuards/isGraphQLResponseWithErrors';\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\n// This is effectively a copy of InternalGraphQLAPI.ts._graphql(...)\n// Our existing unit tests are tightly coupled to the implementation, so i was unable to refactor\n// and extend _graphql() without having to change a bunch of tests as well... which in turn reduces confidence\n// that this feature will _not affect_ GQL behavior.\nexport async function appsyncRequest(amplify, options, additionalHeaders = {}, abortController, customUserAgentDetails) {\n const { region, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, } = options;\n if (!endpoint) {\n throw new Error('No endpoint');\n }\n const { withCredentials } = resolveLibraryOptions(amplify);\n const headers = await requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails);\n const body = {\n channel: query,\n events: variables,\n };\n const signingServiceInfo = ['apiKey', 'none'].includes(authMode)\n ? undefined\n : {\n service: 'appsync',\n region,\n };\n const { body: responseBody } = await post(amplify, {\n url: new AmplifyUrl(endpoint),\n options: {\n headers,\n body,\n signingServiceInfo,\n withCredentials,\n },\n abortController,\n });\n const response = await responseBody.json();\n if (isGraphQLResponseWithErrors(response)) {\n throw repackageUnauthorizedError(response);\n }\n return response;\n}\n/**\n * Computes all the necessary HTTP headers for the request based on:\n * 1. Operation-level header options\n * 2. Amplify.configure custom headers\n * 3. AuthZ headers for explicit auth mode specified for operation ?? default auth mode in config\n *\n * @returns HTTP request headers key/value\n */\nasync function requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails) {\n const { apiKey, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, authToken, } = options;\n const { headers: customHeadersFn } = resolveLibraryOptions(amplify);\n let additionalCustomHeaders;\n if (typeof additionalHeaders === 'function') {\n const requestOptions = {\n method: 'POST',\n url: new AmplifyUrl(endpoint).toString(),\n queryString: query,\n };\n additionalCustomHeaders = await additionalHeaders(requestOptions);\n }\n else {\n additionalCustomHeaders = additionalHeaders;\n }\n // if an authorization header is set, have the operation-level authToken take precedence\n if (authToken) {\n additionalCustomHeaders = {\n ...additionalCustomHeaders,\n Authorization: authToken,\n };\n }\n const authHeaders = await headerBasedAuth(amplify, authMode, apiKey, additionalCustomHeaders);\n const customHeaders = customHeadersFn &&\n (await customHeadersFn({\n query,\n variables: variables,\n }));\n const headers = {\n ...authHeaders,\n // Custom headers included in Amplify configuration options:\n ...customHeaders,\n // Custom headers from individual requests or API client configuration:\n ...additionalCustomHeaders,\n // User agent headers:\n [USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),\n };\n return headers;\n}\n"],"names":[],"mappings":";;;;;;;;AAMA,MAAM,iBAAiB,GAAG,kBAAkB;AAC5C;AACA;AACA;AACA;AACO,eAAe,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,EAAE,EAAE,eAAe,EAAE,sBAAsB,EAAE;AACxH,IAAI,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,GAAG,GAAG,OAAO;AACjH,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,EAAE,eAAe,EAAE,GAAG,qBAAqB,CAAC,OAAO,CAAC;AAC9D,IAAI,MAAM,OAAO,GAAG,MAAM,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,KAAK,UAAU,EAAE;AACjD,QAAQ,MAAM,cAAc,GAAG;AAC/B,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,GAAG,EAAE,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE;AACpD,YAAY,WAAW,EAAE,KAAK;AAC9B,SAAS;AACT,QAAQ,uBAAuB,GAAG,MAAM,iBAAiB,CAAC,cAAc,CAAC;AACzE,IAAI;AACJ,SAAS;AACT,QAAQ,uBAAuB,GAAG,iBAAiB;AACnD,IAAI;AACJ;AACA,IAAI,IAAI,SAAS,EAAE;AACnB,QAAQ,uBAAuB,GAAG;AAClC,YAAY,GAAG,uBAAuB;AACtC,YAAY,aAAa,EAAE,SAAS;AACpC,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,uBAAuB,CAAC;AACjG,IAAI,MAAM,aAAa,GAAG,eAAe;AACzC,SAAS,MAAM,eAAe,CAAC;AAC/B,YAAY,KAAK;AACjB,YAAY,SAAS,EAAE,SAAS;AAChC,SAAS,CAAC,CAAC;AACX,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,GAAG,WAAW;AACtB;AACA,QAAQ,GAAG,aAAa;AACxB;AACA,QAAQ,GAAG,uBAAuB;AAClC;AACA,QAAQ,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,sBAAsB,CAAC;AACxE,KAAK;AACL,IAAI,OAAO,OAAO;AAClB;;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DocumentType } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import type { EventsChannel, EventsOptions, PublishedEvent } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @experimental API may change in future versions
|
|
5
|
+
*
|
|
6
|
+
* Establish a WebSocket connection to an Events channel
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const channel = await events.connect("default/channel")
|
|
10
|
+
*
|
|
11
|
+
* channel.subscribe({
|
|
12
|
+
* next: (data) => { console.log(data) },
|
|
13
|
+
* error: (err) => { console.error(err) },
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* @example // authMode override
|
|
17
|
+
* const channel = await events.connect("default/channel", { authMode: "userPool" })
|
|
18
|
+
*
|
|
19
|
+
* @param channel - channel path; `<namespace>/<channel>`
|
|
20
|
+
* @param options - request overrides: `authMode`, `authToken`
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
declare function connect(channel: string, options?: EventsOptions): Promise<EventsChannel>;
|
|
24
|
+
/**
|
|
25
|
+
* @experimental API may change in future versions
|
|
26
|
+
*
|
|
27
|
+
* Publish events to a channel via HTTP request
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* await events.post("default/channel", { some: "event" })
|
|
31
|
+
*
|
|
32
|
+
* @example // event batching
|
|
33
|
+
* await events.post("default/channel", [{ some: "event" }, { some: "event2" }])
|
|
34
|
+
*
|
|
35
|
+
* @example // authMode override
|
|
36
|
+
* await events.post("default/channel", { some: "event" }, { authMode: "userPool" })
|
|
37
|
+
*
|
|
38
|
+
* @param channel - channel path; `<namespace>/<channel>`
|
|
39
|
+
* @param event - JSON-serializable value or an array of values
|
|
40
|
+
* @param options - request overrides: `authMode`, `authToken`
|
|
41
|
+
*
|
|
42
|
+
* @returns void on success
|
|
43
|
+
* @throws on error
|
|
44
|
+
*/
|
|
45
|
+
declare function post(channel: string, event: DocumentType | DocumentType[], options?: EventsOptions): Promise<void | PublishedEvent[]>;
|
|
46
|
+
/**
|
|
47
|
+
* @experimental API may change in future versions
|
|
48
|
+
*
|
|
49
|
+
* Close WebSocket connection, disconnect listeners and reconnect observers
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* await events.closeAll()
|
|
53
|
+
*
|
|
54
|
+
* @returns void on success
|
|
55
|
+
* @throws on error
|
|
56
|
+
*/
|
|
57
|
+
declare function closeAll(): Promise<void>;
|
|
58
|
+
export { connect, post, closeAll };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Amplify } from '@aws-amplify/core';
|
|
2
|
+
import { amplifyUuid } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
import { AppSyncEventProvider } from '../../Providers/AWSAppSyncEventsProvider/index.mjs';
|
|
4
|
+
import { appsyncRequest } from './appsyncRequest.mjs';
|
|
5
|
+
import { configure, normalizeAuth, serializeEvents } from './utils.mjs';
|
|
6
|
+
|
|
7
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
// Keeps a list of open channels in the websocket
|
|
10
|
+
const openChannels = new Set();
|
|
11
|
+
/**
|
|
12
|
+
* @experimental API may change in future versions
|
|
13
|
+
*
|
|
14
|
+
* Establish a WebSocket connection to an Events channel
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const channel = await events.connect("default/channel")
|
|
18
|
+
*
|
|
19
|
+
* channel.subscribe({
|
|
20
|
+
* next: (data) => { console.log(data) },
|
|
21
|
+
* error: (err) => { console.error(err) },
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* @example // authMode override
|
|
25
|
+
* const channel = await events.connect("default/channel", { authMode: "userPool" })
|
|
26
|
+
*
|
|
27
|
+
* @param channel - channel path; `<namespace>/<channel>`
|
|
28
|
+
* @param options - request overrides: `authMode`, `authToken`
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
async function connect(channel, options) {
|
|
32
|
+
const providerOptions = configure();
|
|
33
|
+
providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);
|
|
34
|
+
providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;
|
|
35
|
+
providerOptions.authToken = options?.authToken || providerOptions.authToken;
|
|
36
|
+
await AppSyncEventProvider.connect(providerOptions);
|
|
37
|
+
const channelId = amplifyUuid();
|
|
38
|
+
openChannels.add(channelId);
|
|
39
|
+
let _subscription;
|
|
40
|
+
const sub = (observer, subOptions) => {
|
|
41
|
+
if (!openChannels.has(channelId)) {
|
|
42
|
+
throw new Error('Channel is closed');
|
|
43
|
+
}
|
|
44
|
+
const subscribeOptions = { ...providerOptions, query: channel };
|
|
45
|
+
subscribeOptions.authenticationType = normalizeAuth(subOptions?.authMode, subscribeOptions.authenticationType);
|
|
46
|
+
subscribeOptions.apiKey = subOptions?.apiKey || subscribeOptions.apiKey;
|
|
47
|
+
subscribeOptions.authToken =
|
|
48
|
+
subOptions?.authToken || subscribeOptions.authToken;
|
|
49
|
+
_subscription = AppSyncEventProvider
|
|
50
|
+
.subscribe(subscribeOptions)
|
|
51
|
+
.subscribe(observer);
|
|
52
|
+
return _subscription;
|
|
53
|
+
};
|
|
54
|
+
const pub = async (event, pubOptions) => {
|
|
55
|
+
if (!openChannels.has(channelId)) {
|
|
56
|
+
throw new Error('Channel is closed');
|
|
57
|
+
}
|
|
58
|
+
const publishOptions = {
|
|
59
|
+
...providerOptions,
|
|
60
|
+
query: channel,
|
|
61
|
+
variables: event,
|
|
62
|
+
};
|
|
63
|
+
publishOptions.authenticationType = normalizeAuth(pubOptions?.authMode, publishOptions.authenticationType);
|
|
64
|
+
publishOptions.apiKey = pubOptions?.apiKey || publishOptions.apiKey;
|
|
65
|
+
publishOptions.authToken =
|
|
66
|
+
pubOptions?.authToken || publishOptions.authToken;
|
|
67
|
+
return AppSyncEventProvider.publish(publishOptions);
|
|
68
|
+
};
|
|
69
|
+
const close = async () => {
|
|
70
|
+
_subscription && _subscription.unsubscribe();
|
|
71
|
+
openChannels.delete(channelId);
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
if (openChannels.size === 0) {
|
|
74
|
+
AppSyncEventProvider.closeIfNoActiveSubscription();
|
|
75
|
+
}
|
|
76
|
+
}, 1000);
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
subscribe: sub,
|
|
80
|
+
close,
|
|
81
|
+
publish: pub,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @experimental API may change in future versions
|
|
86
|
+
*
|
|
87
|
+
* Publish events to a channel via HTTP request
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* await events.post("default/channel", { some: "event" })
|
|
91
|
+
*
|
|
92
|
+
* @example // event batching
|
|
93
|
+
* await events.post("default/channel", [{ some: "event" }, { some: "event2" }])
|
|
94
|
+
*
|
|
95
|
+
* @example // authMode override
|
|
96
|
+
* await events.post("default/channel", { some: "event" }, { authMode: "userPool" })
|
|
97
|
+
*
|
|
98
|
+
* @param channel - channel path; `<namespace>/<channel>`
|
|
99
|
+
* @param event - JSON-serializable value or an array of values
|
|
100
|
+
* @param options - request overrides: `authMode`, `authToken`
|
|
101
|
+
*
|
|
102
|
+
* @returns void on success
|
|
103
|
+
* @throws on error
|
|
104
|
+
*/
|
|
105
|
+
async function post(channel, event, options) {
|
|
106
|
+
const providerOptions = configure();
|
|
107
|
+
providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);
|
|
108
|
+
providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;
|
|
109
|
+
providerOptions.authToken = options?.authToken || providerOptions.authToken;
|
|
110
|
+
// trailing slash required in publish
|
|
111
|
+
const normalizedChannelName = channel[0] === '/' ? channel : `/${channel}`;
|
|
112
|
+
const publishOptions = {
|
|
113
|
+
...providerOptions,
|
|
114
|
+
query: normalizedChannelName,
|
|
115
|
+
variables: serializeEvents(event),
|
|
116
|
+
};
|
|
117
|
+
const abortController = new AbortController();
|
|
118
|
+
const res = await appsyncRequest(Amplify, publishOptions, {}, abortController);
|
|
119
|
+
if (res.failed?.length > 0) {
|
|
120
|
+
return res.failed;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @experimental API may change in future versions
|
|
125
|
+
*
|
|
126
|
+
* Close WebSocket connection, disconnect listeners and reconnect observers
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* await events.closeAll()
|
|
130
|
+
*
|
|
131
|
+
* @returns void on success
|
|
132
|
+
* @throws on error
|
|
133
|
+
*/
|
|
134
|
+
async function closeAll() {
|
|
135
|
+
await AppSyncEventProvider.close();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { closeAll, connect, post };
|
|
139
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/internals/events/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { amplifyUuid } from '@aws-amplify/core/internals/utils';\nimport { AppSyncEventProvider as eventProvider } from '../../Providers/AWSAppSyncEventsProvider';\nimport { appsyncRequest } from './appsyncRequest';\nimport { configure, normalizeAuth, serializeEvents } from './utils';\n// Keeps a list of open channels in the websocket\nconst openChannels = new Set();\n/**\n * @experimental API may change in future versions\n *\n * Establish a WebSocket connection to an Events channel\n *\n * @example\n * const channel = await events.connect(\"default/channel\")\n *\n * channel.subscribe({\n * next: (data) => { console.log(data) },\n * error: (err) => { console.error(err) },\n * })\n *\n * @example // authMode override\n * const channel = await events.connect(\"default/channel\", { authMode: \"userPool\" })\n *\n * @param channel - channel path; `<namespace>/<channel>`\n * @param options - request overrides: `authMode`, `authToken`\n *\n */\nasync function connect(channel, options) {\n const providerOptions = configure();\n providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);\n providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;\n providerOptions.authToken = options?.authToken || providerOptions.authToken;\n await eventProvider.connect(providerOptions);\n const channelId = amplifyUuid();\n openChannels.add(channelId);\n let _subscription;\n const sub = (observer, subOptions) => {\n if (!openChannels.has(channelId)) {\n throw new Error('Channel is closed');\n }\n const subscribeOptions = { ...providerOptions, query: channel };\n subscribeOptions.authenticationType = normalizeAuth(subOptions?.authMode, subscribeOptions.authenticationType);\n subscribeOptions.apiKey = subOptions?.apiKey || subscribeOptions.apiKey;\n subscribeOptions.authToken =\n subOptions?.authToken || subscribeOptions.authToken;\n _subscription = eventProvider\n .subscribe(subscribeOptions)\n .subscribe(observer);\n return _subscription;\n };\n const pub = async (event, pubOptions) => {\n if (!openChannels.has(channelId)) {\n throw new Error('Channel is closed');\n }\n const publishOptions = {\n ...providerOptions,\n query: channel,\n variables: event,\n };\n publishOptions.authenticationType = normalizeAuth(pubOptions?.authMode, publishOptions.authenticationType);\n publishOptions.apiKey = pubOptions?.apiKey || publishOptions.apiKey;\n publishOptions.authToken =\n pubOptions?.authToken || publishOptions.authToken;\n return eventProvider.publish(publishOptions);\n };\n const close = async () => {\n _subscription && _subscription.unsubscribe();\n openChannels.delete(channelId);\n setTimeout(() => {\n if (openChannels.size === 0) {\n eventProvider.closeIfNoActiveSubscription();\n }\n }, 1000);\n };\n return {\n subscribe: sub,\n close,\n publish: pub,\n };\n}\n/**\n * @experimental API may change in future versions\n *\n * Publish events to a channel via HTTP request\n *\n * @example\n * await events.post(\"default/channel\", { some: \"event\" })\n *\n * @example // event batching\n * await events.post(\"default/channel\", [{ some: \"event\" }, { some: \"event2\" }])\n *\n * @example // authMode override\n * await events.post(\"default/channel\", { some: \"event\" }, { authMode: \"userPool\" })\n *\n * @param channel - channel path; `<namespace>/<channel>`\n * @param event - JSON-serializable value or an array of values\n * @param options - request overrides: `authMode`, `authToken`\n *\n * @returns void on success\n * @throws on error\n */\nasync function post(channel, event, options) {\n const providerOptions = configure();\n providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);\n providerOptions.apiKey = options?.apiKey || providerOptions.apiKey;\n providerOptions.authToken = options?.authToken || providerOptions.authToken;\n // trailing slash required in publish\n const normalizedChannelName = channel[0] === '/' ? channel : `/${channel}`;\n const publishOptions = {\n ...providerOptions,\n query: normalizedChannelName,\n variables: serializeEvents(event),\n };\n const abortController = new AbortController();\n const res = await appsyncRequest(Amplify, publishOptions, {}, abortController);\n if (res.failed?.length > 0) {\n return res.failed;\n }\n}\n/**\n * @experimental API may change in future versions\n *\n * Close WebSocket connection, disconnect listeners and reconnect observers\n *\n * @example\n * await events.closeAll()\n *\n * @returns void on success\n * @throws on error\n */\nasync function closeAll() {\n await eventProvider.close();\n}\nexport { connect, post, closeAll };\n"],"names":["eventProvider"],"mappings":";;;;;;AAAA;AACA;AAMA;AACA,MAAM,YAAY,GAAG,IAAI,GAAG,EAAE;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE;AACzC,IAAI,MAAM,eAAe,GAAG,SAAS,EAAE;AACvC,IAAI,eAAe,CAAC,kBAAkB,GAAG,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,kBAAkB,CAAC;AAC7G,IAAI,eAAe,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,eAAe,CAAC,MAAM;AACtE,IAAI,eAAe,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,eAAe,CAAC,SAAS;AAC/E,IAAI,MAAMA,oBAAa,CAAC,OAAO,CAAC,eAAe,CAAC;AAChD,IAAI,MAAM,SAAS,GAAG,WAAW,EAAE;AACnC,IAAI,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/B,IAAI,IAAI,aAAa;AACrB,IAAI,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK;AAC1C,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;AAC1C,YAAY,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC;AAChD,QAAQ;AACR,QAAQ,MAAM,gBAAgB,GAAG,EAAE,GAAG,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE;AACvE,QAAQ,gBAAgB,CAAC,kBA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