@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,100 @@
|
|
|
1
|
+
import { CustomHeaders } from '@aws-amplify/data-schema/runtime';
|
|
2
|
+
import { CommonPublicClientOptions, GraphQLOptionsV6, GraphQLResponseV6, V6Client } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Invokes graphql operations against a graphql service, providing correct input and
|
|
5
|
+
* output types if Amplify-generated graphql from a recent version of the CLI/codegen
|
|
6
|
+
* are used *or* correct typing is provided via the type argument.
|
|
7
|
+
*
|
|
8
|
+
* Amplify-generated "branded" graphql queries will look similar to this:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* //
|
|
12
|
+
* // |-- branding
|
|
13
|
+
* // v
|
|
14
|
+
* export const getModel = `...` as GeneratedQuery<
|
|
15
|
+
* GetModelQueryVariables,
|
|
16
|
+
* GetModelQuery
|
|
17
|
+
* >;
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* If this branding is not in your generated graphql, update to a newer version of
|
|
21
|
+
* CLI/codegen and regenerate your graphql using `amplify codegen`.
|
|
22
|
+
*
|
|
23
|
+
* ## Using Amplify-generated graphql
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import * as queries from './graphql/queries';
|
|
27
|
+
*
|
|
28
|
+
* //
|
|
29
|
+
* // |-- correctly typed graphql response containing a Widget
|
|
30
|
+
* // v
|
|
31
|
+
* const queryResult = await graphql({
|
|
32
|
+
* query: queries.getWidget,
|
|
33
|
+
* variables: {
|
|
34
|
+
* id: "abc", // <-- type hinted/enforced
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* //
|
|
39
|
+
* // |-- a correctly typed Widget
|
|
40
|
+
* // v
|
|
41
|
+
* const fetchedWidget = queryResult.data?.getWidget!;
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* ## Custom input + result types
|
|
45
|
+
*
|
|
46
|
+
* To provide input types (`variables`) and result types:
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* type GetById_NameOnly = {
|
|
50
|
+
* variables: {
|
|
51
|
+
* id: string
|
|
52
|
+
* },
|
|
53
|
+
* result: Promise<{
|
|
54
|
+
* data: { getWidget: { name: string } }
|
|
55
|
+
* }>
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* //
|
|
59
|
+
* // |-- type is GetById_NameOnly["result"]
|
|
60
|
+
* // v
|
|
61
|
+
* const result = graphql<GetById_NameOnly>({
|
|
62
|
+
* query: "...",
|
|
63
|
+
* variables: { id: "abc" } // <-- type of GetById_NameOnly["variables"]
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* ## Custom result type only
|
|
68
|
+
*
|
|
69
|
+
* To specify result types only, use a type that is *not* in the `{variables, result}` shape:
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* type MyResultType = Promise<{
|
|
73
|
+
* data: {
|
|
74
|
+
* getWidget: { name: string }
|
|
75
|
+
* }
|
|
76
|
+
* }>
|
|
77
|
+
*
|
|
78
|
+
* //
|
|
79
|
+
* // |-- type is MyResultType
|
|
80
|
+
* // v
|
|
81
|
+
* const result = graphql<MyResultType>({query: "..."});
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param options
|
|
85
|
+
* @param additionalHeaders
|
|
86
|
+
*/
|
|
87
|
+
export declare function graphql<FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string, Options extends CommonPublicClientOptions = object>(this: V6Client, options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING, Options>, additionalHeaders?: CustomHeaders): GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
88
|
+
/**
|
|
89
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
90
|
+
* @param {any} request - request to cancel
|
|
91
|
+
* @returns - A boolean indicating if the request was cancelled
|
|
92
|
+
*/
|
|
93
|
+
export declare function cancel(this: V6Client, promise: Promise<any>, message?: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
96
|
+
* @param {any} error - Any error
|
|
97
|
+
* @returns - A boolean indicating if the error was from an api request cancellation
|
|
98
|
+
*/
|
|
99
|
+
export declare function isCancelError(this: V6Client, error: any): boolean;
|
|
100
|
+
export { GraphQLOptionsV6, GraphQLResponseV6 };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { GraphQLAPI } from '../GraphQLAPI.mjs';
|
|
2
|
+
import { getInternals } from '../types/index.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Invokes graphql operations against a graphql service, providing correct input and
|
|
6
|
+
* output types if Amplify-generated graphql from a recent version of the CLI/codegen
|
|
7
|
+
* are used *or* correct typing is provided via the type argument.
|
|
8
|
+
*
|
|
9
|
+
* Amplify-generated "branded" graphql queries will look similar to this:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* //
|
|
13
|
+
* // |-- branding
|
|
14
|
+
* // v
|
|
15
|
+
* export const getModel = `...` as GeneratedQuery<
|
|
16
|
+
* GetModelQueryVariables,
|
|
17
|
+
* GetModelQuery
|
|
18
|
+
* >;
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* If this branding is not in your generated graphql, update to a newer version of
|
|
22
|
+
* CLI/codegen and regenerate your graphql using `amplify codegen`.
|
|
23
|
+
*
|
|
24
|
+
* ## Using Amplify-generated graphql
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import * as queries from './graphql/queries';
|
|
28
|
+
*
|
|
29
|
+
* //
|
|
30
|
+
* // |-- correctly typed graphql response containing a Widget
|
|
31
|
+
* // v
|
|
32
|
+
* const queryResult = await graphql({
|
|
33
|
+
* query: queries.getWidget,
|
|
34
|
+
* variables: {
|
|
35
|
+
* id: "abc", // <-- type hinted/enforced
|
|
36
|
+
* },
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* //
|
|
40
|
+
* // |-- a correctly typed Widget
|
|
41
|
+
* // v
|
|
42
|
+
* const fetchedWidget = queryResult.data?.getWidget!;
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* ## Custom input + result types
|
|
46
|
+
*
|
|
47
|
+
* To provide input types (`variables`) and result types:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* type GetById_NameOnly = {
|
|
51
|
+
* variables: {
|
|
52
|
+
* id: string
|
|
53
|
+
* },
|
|
54
|
+
* result: Promise<{
|
|
55
|
+
* data: { getWidget: { name: string } }
|
|
56
|
+
* }>
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* //
|
|
60
|
+
* // |-- type is GetById_NameOnly["result"]
|
|
61
|
+
* // v
|
|
62
|
+
* const result = graphql<GetById_NameOnly>({
|
|
63
|
+
* query: "...",
|
|
64
|
+
* variables: { id: "abc" } // <-- type of GetById_NameOnly["variables"]
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* ## Custom result type only
|
|
69
|
+
*
|
|
70
|
+
* To specify result types only, use a type that is *not* in the `{variables, result}` shape:
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* type MyResultType = Promise<{
|
|
74
|
+
* data: {
|
|
75
|
+
* getWidget: { name: string }
|
|
76
|
+
* }
|
|
77
|
+
* }>
|
|
78
|
+
*
|
|
79
|
+
* //
|
|
80
|
+
* // |-- type is MyResultType
|
|
81
|
+
* // v
|
|
82
|
+
* const result = graphql<MyResultType>({query: "..."});
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @param options
|
|
86
|
+
* @param additionalHeaders
|
|
87
|
+
*/
|
|
88
|
+
function graphql(options, additionalHeaders) {
|
|
89
|
+
// inject client-level auth
|
|
90
|
+
const internals = getInternals(this);
|
|
91
|
+
/**
|
|
92
|
+
* The custom `endpoint` specific to the client
|
|
93
|
+
*/
|
|
94
|
+
const clientEndpoint = internals.endpoint;
|
|
95
|
+
/**
|
|
96
|
+
* The `authMode` specific to the client.
|
|
97
|
+
*/
|
|
98
|
+
const clientAuthMode = internals.authMode;
|
|
99
|
+
/**
|
|
100
|
+
* The `apiKey` specific to the client.
|
|
101
|
+
*/
|
|
102
|
+
const clientApiKey = internals.apiKey;
|
|
103
|
+
/**
|
|
104
|
+
* The most specific `authMode` wins. Setting an `endpoint` value without also
|
|
105
|
+
* setting an `authMode` value is invalid. This helps to prevent customers apps
|
|
106
|
+
* from unexpectedly sending auth details to endpoints the auth details do not
|
|
107
|
+
* belong to.
|
|
108
|
+
*
|
|
109
|
+
* This is especially pronounced for `apiKey`. When both an `endpoint` *and*
|
|
110
|
+
* `authMode: 'apiKey'` are provided, an explicit `apiKey` override is required
|
|
111
|
+
* to prevent inadvertent sending of an API's `apiKey` to an endpoint is does
|
|
112
|
+
* not belong to.
|
|
113
|
+
*/
|
|
114
|
+
options.authMode = options.authMode || clientAuthMode;
|
|
115
|
+
options.apiKey = options.apiKey ?? clientApiKey;
|
|
116
|
+
options.authToken = options.authToken || internals.authToken;
|
|
117
|
+
if (clientEndpoint && options.authMode === 'apiKey' && !options.apiKey) {
|
|
118
|
+
throw new Error("graphql() requires an explicit `apiKey` for a custom `endpoint` when `authMode = 'apiKey'`.");
|
|
119
|
+
}
|
|
120
|
+
const headers = additionalHeaders || internals.headers;
|
|
121
|
+
/**
|
|
122
|
+
* The correctness of these typings depends on correct string branding or overrides.
|
|
123
|
+
* Neither of these can actually be validated at runtime. Hence, we don't perform
|
|
124
|
+
* any validation or type-guarding here.
|
|
125
|
+
*/
|
|
126
|
+
const result = GraphQLAPI.graphql(
|
|
127
|
+
// TODO: move V6Client back into this package?
|
|
128
|
+
internals.amplify, {
|
|
129
|
+
...options,
|
|
130
|
+
endpoint: clientEndpoint,
|
|
131
|
+
}, headers);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
136
|
+
* @param {any} request - request to cancel
|
|
137
|
+
* @returns - A boolean indicating if the request was cancelled
|
|
138
|
+
*/
|
|
139
|
+
function cancel(promise, message) {
|
|
140
|
+
return GraphQLAPI.cancel(promise, message);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
144
|
+
* @param {any} error - Any error
|
|
145
|
+
* @returns - A boolean indicating if the error was from an api request cancellation
|
|
146
|
+
*/
|
|
147
|
+
function isCancelError(error) {
|
|
148
|
+
return GraphQLAPI.isCancelError(error);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { cancel, graphql, isCancelError };
|
|
152
|
+
//# sourceMappingURL=v6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v6.mjs","sources":["../../../src/internals/v6.ts"],"sourcesContent":["import { GraphQLAPI } from '../GraphQLAPI';\nimport { getInternals, } from '../types';\n/**\n * Invokes graphql operations against a graphql service, providing correct input and\n * output types if Amplify-generated graphql from a recent version of the CLI/codegen\n * are used *or* correct typing is provided via the type argument.\n *\n * Amplify-generated \"branded\" graphql queries will look similar to this:\n *\n * ```ts\n * //\n * // |-- branding\n * // v\n * export const getModel = `...` as GeneratedQuery<\n * \tGetModelQueryVariables,\n * \tGetModelQuery\n * >;\n * ```\n *\n * If this branding is not in your generated graphql, update to a newer version of\n * CLI/codegen and regenerate your graphql using `amplify codegen`.\n *\n * ## Using Amplify-generated graphql\n *\n * ```ts\n * import * as queries from './graphql/queries';\n *\n * //\n * // |-- correctly typed graphql response containing a Widget\n * // v\n * const queryResult = await graphql({\n * \tquery: queries.getWidget,\n * \tvariables: {\n * \t\tid: \"abc\", // <-- type hinted/enforced\n * \t},\n * });\n *\n * //\n * // |-- a correctly typed Widget\n * // v\n * const fetchedWidget = queryResult.data?.getWidget!;\n * ```\n *\n * ## Custom input + result types\n *\n * To provide input types (`variables`) and result types:\n *\n * ```ts\n * type GetById_NameOnly = {\n * \tvariables: {\n * \t\tid: string\n * \t},\n * \tresult: Promise<{\n * \t\tdata: { getWidget: { name: string } }\n * \t}>\n * }\n *\n * //\n * // |-- type is GetById_NameOnly[\"result\"]\n * // v\n * const result = graphql<GetById_NameOnly>({\n * \tquery: \"...\",\n * \tvariables: { id: \"abc\" } // <-- type of GetById_NameOnly[\"variables\"]\n * });\n * ```\n *\n * ## Custom result type only\n *\n * To specify result types only, use a type that is *not* in the `{variables, result}` shape:\n *\n * ```ts\n * type MyResultType = Promise<{\n * \tdata: {\n * \t\tgetWidget: { name: string }\n * \t}\n * }>\n *\n * //\n * // |-- type is MyResultType\n * // v\n * const result = graphql<MyResultType>({query: \"...\"});\n * ```\n *\n * @param options\n * @param additionalHeaders\n */\nexport function graphql(options, additionalHeaders) {\n // inject client-level auth\n const internals = getInternals(this);\n /**\n * The custom `endpoint` specific to the client\n */\n const clientEndpoint = internals.endpoint;\n /**\n * The `authMode` specific to the client.\n */\n const clientAuthMode = internals.authMode;\n /**\n * The `apiKey` specific to the client.\n */\n const clientApiKey = internals.apiKey;\n /**\n * The most specific `authMode` wins. Setting an `endpoint` value without also\n * setting an `authMode` value is invalid. This helps to prevent customers apps\n * from unexpectedly sending auth details to endpoints the auth details do not\n * belong to.\n *\n * This is especially pronounced for `apiKey`. When both an `endpoint` *and*\n * `authMode: 'apiKey'` are provided, an explicit `apiKey` override is required\n * to prevent inadvertent sending of an API's `apiKey` to an endpoint is does\n * not belong to.\n */\n options.authMode = options.authMode || clientAuthMode;\n options.apiKey = options.apiKey ?? clientApiKey;\n options.authToken = options.authToken || internals.authToken;\n if (clientEndpoint && options.authMode === 'apiKey' && !options.apiKey) {\n throw new Error(\"graphql() requires an explicit `apiKey` for a custom `endpoint` when `authMode = 'apiKey'`.\");\n }\n const headers = additionalHeaders || internals.headers;\n /**\n * The correctness of these typings depends on correct string branding or overrides.\n * Neither of these can actually be validated at runtime. Hence, we don't perform\n * any validation or type-guarding here.\n */\n const result = GraphQLAPI.graphql(\n // TODO: move V6Client back into this package?\n internals.amplify, {\n ...options,\n endpoint: clientEndpoint,\n }, headers);\n return result;\n}\n/**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\nexport function cancel(promise, message) {\n return GraphQLAPI.cancel(promise, message);\n}\n/**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @returns - A boolean indicating if the error was from an api request cancellation\n */\nexport function isCancelError(error) {\n return GraphQLAPI.isCancelError(error);\n}\n"],"names":[],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE;AACpD;AACA,IAAI,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC;AACxC;AACA;AACA;AACA,IAAI,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ;AAC7C;AACA;AACA;AACA,IAAI,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ;AAC7C;AACA;AACA;AACA,IAAI,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,cAAc;AACzD,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,YAAY;AACnD,IAAI,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS;AAChE,IAAI,IAAI,cAAc,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AAC5E,QAAQ,MAAM,IAAI,KAAK,CAAC,6FAA6F,CAAC;AACtH,IAAI;AACJ,IAAI,MAAM,OAAO,GAAG,iBAAiB,IAAI,SAAS,CAAC,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO;AACrC;AACA,IAAI,SAAS,CAAC,OAAO,EAAE;AACvB,QAAQ,GAAG,OAAO;AAClB,QAAQ,QAAQ,EAAE,cAAc;AAChC,KAAK,EAAE,OAAO,CAAC;AACf,IAAI,OAAO,MAAM;AACjB;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AACzC,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;AAC9C;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,KAAK,EAAE;AACrC,IAAI,OAAO,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC;AAC1C;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ResourcesConfig } from '@aws-amplify/core';
|
|
2
|
+
import { GenerateServerClientParams, V6ClientSSRRequest } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates an GraphQL API client that works with Amplify server context.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import config from './amplifyconfiguration.json';
|
|
8
|
+
* import { listPosts } from './graphql/queries';
|
|
9
|
+
*
|
|
10
|
+
* const client = generateServerClient({ config });
|
|
11
|
+
*
|
|
12
|
+
* const result = await runWithAmplifyServerContext({
|
|
13
|
+
* nextServerContext: { request, response },
|
|
14
|
+
* operation: (contextSpec) => client.graphql(contextSpec, {
|
|
15
|
+
* query: listPosts,
|
|
16
|
+
* }),
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateClient<T extends Record<any, any> = never, Options extends GenerateServerClientParams = {
|
|
20
|
+
config: ResourcesConfig;
|
|
21
|
+
}>(options: Options): V6ClientSSRRequest<T, Options>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getAmplifyServerContext } from '@aws-amplify/core/internals/adapter-core';
|
|
2
|
+
import { generateClientWithAmplifyInstance } from '../internals/server/generateClientWithAmplifyInstance.mjs';
|
|
3
|
+
import { __amplify } from '../types/index.mjs';
|
|
4
|
+
|
|
5
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
/**
|
|
8
|
+
* Generates an GraphQL API client that works with Amplify server context.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import config from './amplifyconfiguration.json';
|
|
12
|
+
* import { listPosts } from './graphql/queries';
|
|
13
|
+
*
|
|
14
|
+
* const client = generateServerClient({ config });
|
|
15
|
+
*
|
|
16
|
+
* const result = await runWithAmplifyServerContext({
|
|
17
|
+
* nextServerContext: { request, response },
|
|
18
|
+
* operation: (contextSpec) => client.graphql(contextSpec, {
|
|
19
|
+
* query: listPosts,
|
|
20
|
+
* }),
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
23
|
+
function generateClient(options) {
|
|
24
|
+
// passing `null` instance because each (future model) method must retrieve a valid instance
|
|
25
|
+
// from server context
|
|
26
|
+
const client = generateClientWithAmplifyInstance({
|
|
27
|
+
amplify: null,
|
|
28
|
+
...options,
|
|
29
|
+
});
|
|
30
|
+
// TODO: improve this and the next type
|
|
31
|
+
const prevGraphql = client.graphql;
|
|
32
|
+
const wrappedGraphql = (contextSpec, innerOptions, additionalHeaders) => {
|
|
33
|
+
const amplifyInstance = getAmplifyServerContext(contextSpec).amplify;
|
|
34
|
+
return prevGraphql.call({ [__amplify]: amplifyInstance }, innerOptions, additionalHeaders);
|
|
35
|
+
};
|
|
36
|
+
client.graphql = wrappedGraphql;
|
|
37
|
+
return client;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { generateClient };
|
|
41
|
+
//# sourceMappingURL=generateClient.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateClient.mjs","sources":["../../../src/server/generateClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { generateClientWithAmplifyInstance } from '../internals/server';\nimport { __amplify, } from '../types';\n/**\n * Generates an GraphQL API client that works with Amplify server context.\n *\n * @example\n * import config from './amplifyconfiguration.json';\n * import { listPosts } from './graphql/queries';\n *\n * const client = generateServerClient({ config });\n *\n * const result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nexport function generateClient(options) {\n // passing `null` instance because each (future model) method must retrieve a valid instance\n // from server context\n const client = generateClientWithAmplifyInstance({\n amplify: null,\n ...options,\n });\n // TODO: improve this and the next type\n const prevGraphql = client.graphql;\n const wrappedGraphql = (contextSpec, innerOptions, additionalHeaders) => {\n const amplifyInstance = getAmplifyServerContext(contextSpec).amplify;\n return prevGraphql.call({ [__amplify]: amplifyInstance }, innerOptions, additionalHeaders);\n };\n client.graphql = wrappedGraphql;\n return client;\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,EAAE;AACxC;AACA;AACA,IAAI,MAAM,MAAM,GAAG,iCAAiC,CAAC;AACrD,QAAQ,OAAO,EAAE,IAAI;AACrB,QAAQ,GAAG,OAAO;AAClB,KAAK,CAAC;AACN;AACA,IAAI,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO;AACtC,IAAI,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,iBAAiB,KAAK;AAC7E,QAAQ,MAAM,eAAe,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO;AAC5E,QAAQ,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,eAAe,EAAE,EAAE,YAAY,EAAE,iBAAiB,CAAC;AAClG,IAAI,CAAC;AACL,IAAI,MAAM,CAAC,OAAO,GAAG,cAAc;AACnC,IAAI,OAAO,MAAM;AACjB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateClient } from './generateClient';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Observer } from 'rxjs';
|
|
2
|
+
export interface SubscriptionObserver<T> {
|
|
3
|
+
closed: boolean;
|
|
4
|
+
next(value: T): void;
|
|
5
|
+
error(errorValue: any): void;
|
|
6
|
+
complete(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare enum CONTROL_MSG {
|
|
9
|
+
CONNECTION_CLOSED = "Connection closed",
|
|
10
|
+
CONNECTION_FAILED = "Connection failed",
|
|
11
|
+
REALTIME_SUBSCRIPTION_INIT_ERROR = "AppSync Realtime subscription init error",
|
|
12
|
+
SUBSCRIPTION_ACK = "Subscription ack",
|
|
13
|
+
TIMEOUT_DISCONNECT = "Timeout disconnect"
|
|
14
|
+
}
|
|
15
|
+
/** @enum {string} */
|
|
16
|
+
export declare enum ConnectionState {
|
|
17
|
+
Connected = "Connected",
|
|
18
|
+
ConnectedPendingNetwork = "ConnectedPendingNetwork",
|
|
19
|
+
ConnectionDisrupted = "ConnectionDisrupted",
|
|
20
|
+
ConnectionDisruptedPendingNetwork = "ConnectionDisruptedPendingNetwork",
|
|
21
|
+
Connecting = "Connecting",
|
|
22
|
+
ConnectedPendingDisconnect = "ConnectedPendingDisconnect",
|
|
23
|
+
Disconnected = "Disconnected",
|
|
24
|
+
ConnectedPendingKeepAlive = "ConnectedPendingKeepAlive"
|
|
25
|
+
}
|
|
26
|
+
export type PubSubContent = Record<string, unknown>;
|
|
27
|
+
export type PubSubContentObserver = Observer<PubSubContent>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var CONTROL_MSG;
|
|
2
|
+
(function (CONTROL_MSG) {
|
|
3
|
+
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
4
|
+
CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
|
|
5
|
+
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
6
|
+
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
7
|
+
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
8
|
+
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
9
|
+
/** @enum {string} */
|
|
10
|
+
var ConnectionState;
|
|
11
|
+
(function (ConnectionState) {
|
|
12
|
+
/*
|
|
13
|
+
* The connection is alive and healthy
|
|
14
|
+
*/
|
|
15
|
+
ConnectionState["Connected"] = "Connected";
|
|
16
|
+
/*
|
|
17
|
+
* The connection is alive, but the connection is offline
|
|
18
|
+
*/
|
|
19
|
+
ConnectionState["ConnectedPendingNetwork"] = "ConnectedPendingNetwork";
|
|
20
|
+
/*
|
|
21
|
+
* The connection has been disconnected while in use
|
|
22
|
+
*/
|
|
23
|
+
ConnectionState["ConnectionDisrupted"] = "ConnectionDisrupted";
|
|
24
|
+
/*
|
|
25
|
+
* The connection has been disconnected and the network is offline
|
|
26
|
+
*/
|
|
27
|
+
ConnectionState["ConnectionDisruptedPendingNetwork"] = "ConnectionDisruptedPendingNetwork";
|
|
28
|
+
/*
|
|
29
|
+
* The connection is in the process of connecting
|
|
30
|
+
*/
|
|
31
|
+
ConnectionState["Connecting"] = "Connecting";
|
|
32
|
+
/*
|
|
33
|
+
* The connection is not in use and is being disconnected
|
|
34
|
+
*/
|
|
35
|
+
ConnectionState["ConnectedPendingDisconnect"] = "ConnectedPendingDisconnect";
|
|
36
|
+
/*
|
|
37
|
+
* The connection is not in use and has been disconnected
|
|
38
|
+
*/
|
|
39
|
+
ConnectionState["Disconnected"] = "Disconnected";
|
|
40
|
+
/*
|
|
41
|
+
* The connection is alive, but a keep alive message has been missed
|
|
42
|
+
*/
|
|
43
|
+
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
44
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
45
|
+
|
|
46
|
+
export { CONTROL_MSG, ConnectionState };
|
|
47
|
+
//# sourceMappingURL=PubSub.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PubSub.mjs","sources":["../../../src/types/PubSub.ts"],"sourcesContent":["export var CONTROL_MSG;\n(function (CONTROL_MSG) {\n CONTROL_MSG[\"CONNECTION_CLOSED\"] = \"Connection closed\";\n CONTROL_MSG[\"CONNECTION_FAILED\"] = \"Connection failed\";\n CONTROL_MSG[\"REALTIME_SUBSCRIPTION_INIT_ERROR\"] = \"AppSync Realtime subscription init error\";\n CONTROL_MSG[\"SUBSCRIPTION_ACK\"] = \"Subscription ack\";\n CONTROL_MSG[\"TIMEOUT_DISCONNECT\"] = \"Timeout disconnect\";\n})(CONTROL_MSG || (CONTROL_MSG = {}));\n/** @enum {string} */\nexport var ConnectionState;\n(function (ConnectionState) {\n /*\n * The connection is alive and healthy\n */\n ConnectionState[\"Connected\"] = \"Connected\";\n /*\n * The connection is alive, but the connection is offline\n */\n ConnectionState[\"ConnectedPendingNetwork\"] = \"ConnectedPendingNetwork\";\n /*\n * The connection has been disconnected while in use\n */\n ConnectionState[\"ConnectionDisrupted\"] = \"ConnectionDisrupted\";\n /*\n * The connection has been disconnected and the network is offline\n */\n ConnectionState[\"ConnectionDisruptedPendingNetwork\"] = \"ConnectionDisruptedPendingNetwork\";\n /*\n * The connection is in the process of connecting\n */\n ConnectionState[\"Connecting\"] = \"Connecting\";\n /*\n * The connection is not in use and is being disconnected\n */\n ConnectionState[\"ConnectedPendingDisconnect\"] = \"ConnectedPendingDisconnect\";\n /*\n * The connection is not in use and has been disconnected\n */\n ConnectionState[\"Disconnected\"] = \"Disconnected\";\n /*\n * The connection is alive, but a keep alive message has been missed\n */\n ConnectionState[\"ConnectedPendingKeepAlive\"] = \"ConnectedPendingKeepAlive\";\n})(ConnectionState || (ConnectionState = {}));\n"],"names":[],"mappings":"AAAU,IAAC;AACX,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;AAC1D,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;AAC1D,IAAI,WAAW,CAAC,kCAAkC,CAAC,GAAG,0CAA0C;AAChG,IAAI,WAAW,CAAC,kBAAkB,CAAC,GAAG,kBAAkB;AACxD,IAAI,WAAW,CAAC,oBAAoB,CAAC,GAAG,oBAAoB;AAC5D,CAAC,EAAE,WAAW,KAAK,WAAW,GAAG,EAAE,CAAC,CAAC;AACrC;AACU,IAAC;AACX,CAAC,UAAU,eAAe,EAAE;AAC5B;AACA;AACA;AACA,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW;AAC9C;AACA;AACA;AACA,IAAI,eAAe,CAAC,yBAAyB,CAAC,GAAG,yBAAyB;AAC1E;AACA;AACA;AACA,IAAI,eAAe,CAAC,qBAAqB,CAAC,GAAG,qBAAqB;AAClE;AACA;AACA;AACA,IAAI,eAAe,CAAC,mCAAmC,CAAC,GAAG,mCAAmC;AAC9F;AACA;AACA;AACA,IAAI,eAAe,CAAC,YAAY,CAAC,GAAG,YAAY;AAChD;AACA;AACA;AACA,IAAI,eAAe,CAAC,4BAA4B,CAAC,GAAG,4BAA4B;AAChF;AACA;AACA;AACA,IAAI,eAAe,CAAC,cAAc,CAAC,GAAG,cAAc;AACpD;AACA;AACA;AACA,IAAI,eAAe,CAAC,2BAA2B,CAAC,GAAG,2BAA2B;AAC9E,CAAC,EAAE,eAAe,KAAK,eAAe,GAAG,EAAE,CAAC,CAAC;;;;"}
|