@aws-amplify/api-graphql 4.0.22-unstable.bd1fefd.0 → 4.0.22-unstable.f6055cb.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +40 -31
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/dist/cjs/internals/APIClient.js +34 -19
- package/dist/cjs/internals/APIClient.js.map +1 -1
- package/dist/cjs/internals/InternalGraphQLAPI.js +10 -9
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/internals/generateClient.js +1 -1
- package/dist/cjs/internals/generateClient.js.map +1 -1
- package/dist/cjs/internals/operations/custom.js +2 -2
- package/dist/cjs/internals/operations/custom.js.map +1 -1
- package/dist/cjs/internals/operations/list.js +1 -1
- package/dist/cjs/internals/operations/list.js.map +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -1
- package/dist/cjs/internals/v6.js +0 -2
- package/dist/cjs/internals/v6.js.map +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -1
- package/dist/esm/GraphQLAPI.d.ts +2 -2
- package/dist/esm/GraphQLAPI.mjs.map +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +8 -8
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +40 -31
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
- package/dist/esm/internals/APIClient.d.ts +5 -6
- package/dist/esm/internals/APIClient.mjs +34 -19
- package/dist/esm/internals/APIClient.mjs.map +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.mjs +10 -9
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/internals/generateClient.mjs +1 -1
- package/dist/esm/internals/generateClient.mjs.map +1 -1
- package/dist/esm/internals/generateCustomOperationsProperty.d.ts +2 -2
- package/dist/esm/internals/operations/custom.d.ts +1 -1
- package/dist/esm/internals/operations/custom.mjs +2 -2
- package/dist/esm/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/internals/operations/get.d.ts +1 -1
- package/dist/esm/internals/operations/get.mjs.map +1 -1
- package/dist/esm/internals/operations/indexQuery.d.ts +3 -3
- package/dist/esm/internals/operations/indexQuery.mjs.map +1 -1
- package/dist/esm/internals/operations/list.d.ts +1 -1
- package/dist/esm/internals/operations/list.mjs +1 -1
- package/dist/esm/internals/operations/list.mjs.map +1 -1
- package/dist/esm/internals/operations/subscription.d.ts +1 -1
- package/dist/esm/internals/operations/subscription.mjs.map +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
- package/dist/esm/internals/server/generateModelsProperty.d.ts +1 -2
- package/dist/esm/internals/server/generateModelsProperty.mjs +1 -1
- package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -1
- package/dist/esm/internals/types.d.ts +2 -2
- package/dist/esm/internals/utils/clientProperties/generateModelsProperty.d.ts +1 -1
- package/dist/esm/internals/v6.d.ts +1 -1
- package/dist/esm/internals/v6.mjs +0 -2
- package/dist/esm/internals/v6.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +33 -35
- package/dist/esm/utils/ConnectionStateMonitor.d.ts +2 -2
- package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -1
- package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -1
- package/dist/esm/utils/errors/repackageAuthError.d.ts +2 -2
- package/dist/esm/utils/errors/repackageAuthError.mjs +1 -1
- package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -1
- package/dist/esm/utils/findIndexByFields.d.ts +1 -1
- package/package.json +6 -5
- package/src/GraphQLAPI.ts +4 -3
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +84 -64
- package/src/internals/APIClient.ts +59 -27
- package/src/internals/InternalGraphQLAPI.ts +26 -30
- package/src/internals/clientUtils.ts +1 -1
- package/src/internals/generateClient.ts +12 -10
- package/src/internals/generateCustomOperationsProperty.ts +7 -6
- package/src/internals/operations/custom.ts +16 -13
- package/src/internals/operations/get.ts +9 -8
- package/src/internals/operations/indexQuery.ts +12 -11
- package/src/internals/operations/list.ts +11 -15
- package/src/internals/operations/observeQuery.ts +3 -1
- package/src/internals/operations/subscription.ts +12 -10
- package/src/internals/server/generateClientWithAmplifyInstance.ts +7 -7
- package/src/internals/server/generateModelsProperty.ts +7 -4
- package/src/internals/types.ts +2 -2
- package/src/internals/utils/clientProperties/generateEnumsProperty.ts +7 -6
- package/src/internals/utils/clientProperties/generateModelsProperty.ts +7 -6
- package/src/internals/v6.ts +6 -4
- package/src/server/generateClient.ts +4 -1
- package/src/types/PubSub.ts +1 -0
- package/src/types/index.ts +49 -47
- package/src/utils/ConnectionStateMonitor.ts +8 -3
- package/src/utils/ReachabilityMonitor/index.native.ts +1 -1
- package/src/utils/ReachabilityMonitor/index.ts +1 -0
- package/src/utils/ReconnectionMonitor.ts +1 -0
- package/src/utils/errors/repackageAuthError.ts +6 -7
- package/src/utils/findIndexByFields.ts +1 -1
- package/src/utils/resolveConfig.ts +1 -0
- package/src/utils/resolveLibraryOptions.ts +1 -0
- package/src/utils/resolveOwnerFields.ts +7 -5
- package/src/utils/resolvePKFields.ts +1 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export { OperationTypeNode } from 'graphql';
|
|
2
|
+
import { CustomHeaders, CustomMutations, CustomQueries, EnumTypes, ModelTypes } from '@aws-amplify/data-schema-types';
|
|
3
|
+
import { DocumentNode, GraphQLError, Source } from 'graphql';
|
|
5
4
|
import { Observable } from 'rxjs';
|
|
6
|
-
import {
|
|
5
|
+
import { DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
7
6
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
7
|
+
export { OperationTypeNode } from 'graphql';
|
|
8
8
|
export { CONTROL_MSG, ConnectionState } from './PubSub';
|
|
9
9
|
export { SelectionSet } from '@aws-amplify/data-schema-types';
|
|
10
10
|
export { CommonPublicClientOptions } from '../internals/types';
|
|
@@ -24,9 +24,7 @@ export interface GraphQLOptions {
|
|
|
24
24
|
export interface GraphQLResult<T = object> {
|
|
25
25
|
data: T;
|
|
26
26
|
errors?: GraphQLError[];
|
|
27
|
-
extensions?:
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
};
|
|
27
|
+
extensions?: Record<string, any>;
|
|
30
28
|
}
|
|
31
29
|
declare const queryType: unique symbol;
|
|
32
30
|
export type GraphQLQuery<T> = T & {
|
|
@@ -56,18 +54,18 @@ export type GraphQLSubscription<T> = T & {
|
|
|
56
54
|
*
|
|
57
55
|
* This util simply makes related model properties optional recursively.
|
|
58
56
|
*/
|
|
59
|
-
export type GraphQLReturnType<T> = T extends
|
|
57
|
+
export type GraphQLReturnType<T> = T extends Record<string, unknown> ? {
|
|
60
58
|
[K in keyof T]?: GraphQLReturnType<T[K]>;
|
|
61
59
|
} : T;
|
|
62
60
|
/**
|
|
63
61
|
* Describes a paged list result from AppSync, which can either
|
|
64
62
|
* live at the top query or property (e.g., related model) level.
|
|
65
63
|
*/
|
|
66
|
-
|
|
64
|
+
interface PagedList<T, TYPENAME> {
|
|
67
65
|
__typename: TYPENAME;
|
|
68
66
|
nextToken?: string | null | undefined;
|
|
69
|
-
items:
|
|
70
|
-
}
|
|
67
|
+
items: T[];
|
|
68
|
+
}
|
|
71
69
|
/**
|
|
72
70
|
* Recursively looks through a result type and removes nulls and
|
|
73
71
|
* and undefined from `PagedList` types.
|
|
@@ -76,7 +74,7 @@ type PagedList<T, TYPENAME> = {
|
|
|
76
74
|
* array, this will only be the case when we also have errors,
|
|
77
75
|
* which will then be *thrown*.
|
|
78
76
|
*/
|
|
79
|
-
type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends
|
|
77
|
+
type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends Record<string, unknown> ? {
|
|
80
78
|
[K in keyof T]: WithListsFixed<T[K]>;
|
|
81
79
|
} : T;
|
|
82
80
|
/**
|
|
@@ -132,9 +130,9 @@ export type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptionMessage
|
|
|
132
130
|
* })
|
|
133
131
|
* ```
|
|
134
132
|
*/
|
|
135
|
-
export
|
|
133
|
+
export interface GraphqlSubscriptionMessage<T> {
|
|
136
134
|
data: T;
|
|
137
|
-
}
|
|
135
|
+
}
|
|
138
136
|
export interface AWSAppSyncRealTimeProviderOptions {
|
|
139
137
|
appSyncGraphqlEndpoint?: string;
|
|
140
138
|
authenticationType?: GraphQLAuthMode;
|
|
@@ -142,12 +140,12 @@ export interface AWSAppSyncRealTimeProviderOptions {
|
|
|
142
140
|
variables?: Record<string, unknown>;
|
|
143
141
|
apiKey?: string;
|
|
144
142
|
region?: string;
|
|
145
|
-
libraryConfigHeaders
|
|
143
|
+
libraryConfigHeaders?(): () => Promise<Record<string, unknown> | Headers>;
|
|
146
144
|
additionalHeaders?: CustomHeaders;
|
|
147
145
|
}
|
|
148
|
-
export
|
|
146
|
+
export interface AWSAppSyncRealTimeProvider {
|
|
149
147
|
subscribe(options?: AWSAppSyncRealTimeProviderOptions): Observable<Record<string, unknown>>;
|
|
150
|
-
}
|
|
148
|
+
}
|
|
151
149
|
export declare enum GraphQLAuthError {
|
|
152
150
|
NO_API_KEY = "No api-key configured",
|
|
153
151
|
NO_CURRENT_USER = "No current user",
|
|
@@ -191,7 +189,7 @@ export type GraphQLVariablesV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING extend
|
|
|
191
189
|
* The expected return type with respect to the given `FALLBACK_TYPE`
|
|
192
190
|
* and `TYPED_GQL_STRING`.
|
|
193
191
|
*/
|
|
194
|
-
export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer
|
|
192
|
+
export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer _, infer QUERY_OUT> ? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>> : TYPED_GQL_STRING extends GeneratedMutation<infer _, infer MUTATION_OUT> ? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>> : TYPED_GQL_STRING extends GeneratedSubscription<infer _, infer SUB_OUT> ? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>> : FALLBACK_TYPE extends GraphQLQuery<infer _> ? Promise<GraphQLResult<FALLBACK_TYPE>> : FALLBACK_TYPE extends GraphQLSubscription<infer _> ? GraphqlSubscriptionResult<FALLBACK_TYPE> : FALLBACK_TYPE extends GraphQLOperationType<infer _, infer CUSTOM_OUT> ? CUSTOM_OUT : UnknownGraphQLResponse;
|
|
195
193
|
/**
|
|
196
194
|
* The shape customers can use to provide `T` to `graphql<T>()` to specify both
|
|
197
195
|
* `IN` and `OUT` types (the type of `variables` and the return type, respectively).
|
|
@@ -210,10 +208,10 @@ export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends
|
|
|
210
208
|
* })
|
|
211
209
|
* ```
|
|
212
210
|
*/
|
|
213
|
-
export
|
|
211
|
+
export interface GraphQLOperationType<IN extends Record<string, DocumentType>, OUT extends Record<string, DocumentType>> {
|
|
214
212
|
variables: IN;
|
|
215
213
|
result: OUT;
|
|
216
|
-
}
|
|
214
|
+
}
|
|
217
215
|
/**
|
|
218
216
|
* Nominal type for branding generated graphql query operation strings with
|
|
219
217
|
* input and output types.
|
|
@@ -291,8 +289,8 @@ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
|
291
289
|
[__authToken]?: string;
|
|
292
290
|
[__headers]?: CustomHeaders;
|
|
293
291
|
graphql: GraphQLMethod;
|
|
294
|
-
cancel
|
|
295
|
-
isCancelError
|
|
292
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
293
|
+
isCancelError(error: any): boolean;
|
|
296
294
|
models: ModelTypes<T>;
|
|
297
295
|
enums: EnumTypes<T>;
|
|
298
296
|
queries: CustomQueries<T>;
|
|
@@ -304,8 +302,8 @@ export type V6ClientSSRRequest<T extends Record<any, any> = never> = ExcludeNeve
|
|
|
304
302
|
[__authToken]?: string;
|
|
305
303
|
[__headers]?: CustomHeaders;
|
|
306
304
|
graphql: GraphQLMethodSSR;
|
|
307
|
-
cancel
|
|
308
|
-
isCancelError
|
|
305
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
306
|
+
isCancelError(error: any): boolean;
|
|
309
307
|
models: ModelTypes<T, 'REQUEST'>;
|
|
310
308
|
enums: EnumTypes<T>;
|
|
311
309
|
queries: CustomQueries<T, 'REQUEST'>;
|
|
@@ -317,8 +315,8 @@ export type V6ClientSSRCookies<T extends Record<any, any> = never> = ExcludeNeve
|
|
|
317
315
|
[__authToken]?: string;
|
|
318
316
|
[__headers]?: CustomHeaders;
|
|
319
317
|
graphql: GraphQLMethod;
|
|
320
|
-
cancel
|
|
321
|
-
isCancelError
|
|
318
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
319
|
+
isCancelError(error: any): boolean;
|
|
322
320
|
models: ModelTypes<T, 'COOKIES'>;
|
|
323
321
|
enums: EnumTypes<T>;
|
|
324
322
|
queries: CustomQueries<T, 'COOKIES'>;
|
|
@@ -331,22 +329,22 @@ export type GraphQLMethodSSR = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING exten
|
|
|
331
329
|
*
|
|
332
330
|
* The knobs available for configuring `server/generateClient` internally.
|
|
333
331
|
*/
|
|
334
|
-
export
|
|
332
|
+
export interface ServerClientGenerationParams {
|
|
335
333
|
amplify: null | ((fn: (amplify: AmplifyClassV6) => Promise<any>) => Promise<any>);
|
|
336
334
|
config: ResourcesConfig;
|
|
337
|
-
}
|
|
335
|
+
}
|
|
338
336
|
export type QueryArgs = Record<string, unknown>;
|
|
339
|
-
export
|
|
337
|
+
export interface ListArgs extends Record<string, unknown> {
|
|
340
338
|
selectionSet?: string[];
|
|
341
|
-
filter?:
|
|
339
|
+
filter?: Record<string, unknown>;
|
|
342
340
|
headers?: CustomHeaders;
|
|
343
|
-
}
|
|
344
|
-
export
|
|
341
|
+
}
|
|
342
|
+
export interface AuthModeParams extends Record<string, unknown> {
|
|
345
343
|
authMode?: GraphQLAuthMode;
|
|
346
344
|
authToken?: string;
|
|
347
|
-
}
|
|
348
|
-
export
|
|
345
|
+
}
|
|
346
|
+
export interface GenerateServerClientParams {
|
|
349
347
|
config: ResourcesConfig;
|
|
350
348
|
authMode?: GraphQLAuthMode;
|
|
351
349
|
authToken?: string;
|
|
352
|
-
}
|
|
350
|
+
}
|
|
@@ -2,12 +2,12 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { ConnectionState } from '../types/PubSub';
|
|
3
3
|
type LinkedConnectionState = 'connected' | 'disconnected';
|
|
4
4
|
type LinkedHealthState = 'healthy' | 'unhealthy';
|
|
5
|
-
|
|
5
|
+
interface LinkedConnectionStates {
|
|
6
6
|
networkState: LinkedConnectionState;
|
|
7
7
|
connectionState: LinkedConnectionState | 'connecting';
|
|
8
8
|
intendedConnectionState: LinkedConnectionState;
|
|
9
9
|
keepAliveState: LinkedHealthState;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export declare const CONNECTION_CHANGE: {
|
|
12
12
|
[key in 'KEEP_ALIVE_MISSED' | 'KEEP_ALIVE' | 'CONNECTION_ESTABLISHED' | 'CONNECTION_FAILED' | 'CLOSING_CONNECTION' | 'OPENING_CONNECTION' | 'CLOSED' | 'ONLINE' | 'OFFLINE']: Partial<LinkedConnectionStates>;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionStateMonitor.mjs","sources":["../../../src/utils/ConnectionStateMonitor.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable,
|
|
1
|
+
{"version":3,"file":"ConnectionStateMonitor.mjs","sources":["../../../src/utils/ConnectionStateMonitor.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable, filter, map } from 'rxjs';\nimport { ConnectionState } from '../types/PubSub';\nimport { ReachabilityMonitor } from './ReachabilityMonitor';\nexport const CONNECTION_CHANGE = {\n KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },\n KEEP_ALIVE: { keepAliveState: 'healthy' },\n CONNECTION_ESTABLISHED: { connectionState: 'connected' },\n CONNECTION_FAILED: {\n intendedConnectionState: 'disconnected',\n connectionState: 'disconnected',\n },\n CLOSING_CONNECTION: { intendedConnectionState: 'disconnected' },\n OPENING_CONNECTION: {\n intendedConnectionState: 'connected',\n connectionState: 'connecting',\n },\n CLOSED: { connectionState: 'disconnected' },\n ONLINE: { networkState: 'connected' },\n OFFLINE: { networkState: 'disconnected' },\n};\nexport class ConnectionStateMonitor {\n constructor() {\n this._networkMonitoringSubscription = undefined;\n this._linkedConnectionState = {\n networkState: 'connected',\n connectionState: 'disconnected',\n intendedConnectionState: 'disconnected',\n keepAliveState: 'healthy',\n };\n // Attempt to update the state with the current actual network state\n this._initialNetworkStateSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n this._initialNetworkStateSubscription?.unsubscribe();\n });\n this._linkedConnectionStateObservable =\n new Observable(connectionStateObserver => {\n connectionStateObserver.next(this._linkedConnectionState);\n this._linkedConnectionStateObserver = connectionStateObserver;\n });\n }\n /**\n * Turn network state monitoring on if it isn't on already\n */\n enableNetworkMonitoring() {\n // If no initial network state was discovered, stop trying\n this._initialNetworkStateSubscription?.unsubscribe();\n // Maintain the network state based on the reachability monitor\n if (this._networkMonitoringSubscription === undefined) {\n this._networkMonitoringSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n });\n }\n }\n /**\n * Turn network state monitoring off if it isn't off already\n */\n disableNetworkMonitoring() {\n this._networkMonitoringSubscription?.unsubscribe();\n this._networkMonitoringSubscription = undefined;\n }\n /**\n * Get the observable that allows us to monitor the connection state\n *\n * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates\n */\n get connectionStateObservable() {\n let previous;\n // The linked state aggregates state changes to any of the network, connection,\n // intendedConnection and keepAliveHealth. Some states will change these independent\n // states without changing the overall connection state.\n // After translating from linked states to ConnectionState, then remove any duplicates\n return this._linkedConnectionStateObservable\n .pipe(map(value => {\n return this.connectionStatesTranslator(value);\n }))\n .pipe(filter(current => {\n const toInclude = current !== previous;\n previous = current;\n return toInclude;\n }));\n }\n /*\n * Updates local connection state and emits the full state to the observer.\n */\n record(statusUpdates) {\n // Maintain the network monitor\n if (statusUpdates.intendedConnectionState === 'connected') {\n this.enableNetworkMonitoring();\n }\n else if (statusUpdates.intendedConnectionState === 'disconnected') {\n this.disableNetworkMonitoring();\n }\n // Maintain the socket state\n const newSocketStatus = {\n ...this._linkedConnectionState,\n ...statusUpdates,\n };\n this._linkedConnectionState = { ...newSocketStatus };\n this._linkedConnectionStateObserver?.next(this._linkedConnectionState);\n }\n /*\n * Translate the ConnectionState structure into a specific ConnectionState string literal union\n */\n connectionStatesTranslator({ connectionState, networkState, intendedConnectionState, keepAliveState, }) {\n if (connectionState === 'connected' && networkState === 'disconnected')\n return ConnectionState.ConnectedPendingNetwork;\n if (connectionState === 'connected' &&\n intendedConnectionState === 'disconnected')\n return ConnectionState.ConnectedPendingDisconnect;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected' &&\n networkState === 'disconnected')\n return ConnectionState.ConnectionDisruptedPendingNetwork;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected')\n return ConnectionState.ConnectionDisrupted;\n if (connectionState === 'connected' && keepAliveState === 'unhealthy')\n return ConnectionState.ConnectedPendingKeepAlive;\n // All remaining states directly correspond to the connection state\n if (connectionState === 'connecting')\n return ConnectionState.Connecting;\n if (connectionState === 'disconnected')\n return ConnectionState.Disconnected;\n return ConnectionState.Connected;\n }\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,iBAAiB,GAAG;AACjC,IAAI,iBAAiB,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;AACtD,IAAI,UAAU,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE;AAC7C,IAAI,sBAAsB,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE;AAC5D,IAAI,iBAAiB,EAAE;AACvB,QAAQ,uBAAuB,EAAE,cAAc;AAC/C,QAAQ,eAAe,EAAE,cAAc;AACvC,KAAK;AACL,IAAI,kBAAkB,EAAE,EAAE,uBAAuB,EAAE,cAAc,EAAE;AACnE,IAAI,kBAAkB,EAAE;AACxB,QAAQ,uBAAuB,EAAE,WAAW;AAC5C,QAAQ,eAAe,EAAE,YAAY;AACrC,KAAK;AACL,IAAI,MAAM,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE;AAC/C,IAAI,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE;AACzC,IAAI,OAAO,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE;AAC7C,EAAE;AACK,MAAM,sBAAsB,CAAC;AACpC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ACA,IAAI,0BAA0B,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,uBAAuB,EAAE,cAAc,GAAG,EAAE;AAC5G,QAAQ,IAAI,eAAe,KAAK,WAAW,IAAI,YAAY,KAAK,cAAc;AAC9E,YAAY,OAAO,eAAe,CAAC,uBAAuB,CAAC;AAC3D,QAAQ,IAAI,eAAe,KAAK,WAAW;AAC3C,YAAY,uBAAuB,KAAK,cAAc;AACtD,YAAY,OAAO,eAAe,CAAC,0BAA0B,CAAC;AAC9D,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,YAAY,KAAK,cAAc;AAC3C,YAAY,OAAO,eAAe,CAAC,iCAAiC,CAAC;AACrE,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,OAAO,eAAe,CAAC,mBAAmB,CAAC;AACvD,QAAQ,IAAI,eAAe,KAAK,WAAW,IAAI,cAAc,KAAK,WAAW;AAC7E,YAAY,OAAO,eAAe,CAAC,yBAAyB,CAAC;AAC7D;AACA,QAAQ,IAAI,eAAe,KAAK,YAAY;AAC5C,YAAY,OAAO,eAAe,CAAC,UAAU,CAAC;AAC9C,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,OAAO,eAAe,CAAC,YAAY,CAAC;AAChD,QAAQ,OAAO,eAAe,CAAC,SAAS,CAAC;AACzC,KAAK;AACL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nimport
|
|
1
|
+
{"version":3,"file":"index.native.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nimport NetInfo from '@react-native-community/netinfo';\nexport const ReachabilityMonitor = () => new Reachability().networkMonitor(NetInfo);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,mBAAmB,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,cAAc,CAAC,OAAO;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
2
|
-
|
|
2
|
+
interface ErrorObject {
|
|
3
3
|
errors: AmplifyErrorParams[];
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
/**
|
|
6
6
|
* Checks to see if the given response or subscription message contains an
|
|
7
7
|
* unauth error. If it does, it changes the error message to include instructions
|
|
@@ -21,7 +21,7 @@ function repackageUnauthError(content) {
|
|
|
21
21
|
}
|
|
22
22
|
function isUnauthError(error) {
|
|
23
23
|
// Error pattern corresponding to appsync calls
|
|
24
|
-
if (error?.
|
|
24
|
+
if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
// Error pattern corresponding to appsync subscriptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repackageAuthError.mjs","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Checks to see if the given response or subscription message contains an\n * unauth error. If it does, it changes the error message to include instructions\n * for the app developer.\n */\nexport function repackageUnauthError(content) {\n if (content.errors && Array.isArray(content.errors)) {\n content.errors.forEach(e => {\n if (isUnauthError(e)) {\n e.message = 'Unauthorized';\n e.recoverySuggestion =\n `If you're calling an Amplify-generated API, make sure ` +\n `to set the \"authMode\" in generateClient({ authMode: '...' }) to the backend authorization ` +\n `rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;\n }\n });\n }\n return content;\n}\nfunction isUnauthError(error) {\n // Error pattern corresponding to appsync calls\n if (error?.
|
|
1
|
+
{"version":3,"file":"repackageAuthError.mjs","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Checks to see if the given response or subscription message contains an\n * unauth error. If it does, it changes the error message to include instructions\n * for the app developer.\n */\nexport function repackageUnauthError(content) {\n if (content.errors && Array.isArray(content.errors)) {\n content.errors.forEach(e => {\n if (isUnauthError(e)) {\n e.message = 'Unauthorized';\n e.recoverySuggestion =\n `If you're calling an Amplify-generated API, make sure ` +\n `to set the \"authMode\" in generateClient({ authMode: '...' }) to the backend authorization ` +\n `rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;\n }\n });\n }\n return content;\n}\nfunction isUnauthError(error) {\n // Error pattern corresponding to appsync calls\n if (error?.originalError?.name?.startsWith('UnauthorizedException')) {\n return true;\n }\n // Error pattern corresponding to appsync subscriptions\n if (error.message?.startsWith('Connection failed:') &&\n error.message?.includes('Permission denied')) {\n return true;\n }\n return false;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,OAAO,EAAE;AAC9C,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzD,QAAQ,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;AACpC,YAAY,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE;AAClC,gBAAgB,CAAC,CAAC,OAAO,GAAG,cAAc,CAAC;AAC3C,gBAAgB,CAAC,CAAC,kBAAkB;AACpC,oBAAoB,CAAC,sDAAsD,CAAC;AAC5E,wBAAwB,CAAC,0FAA0F,CAAC;AACpH,wBAAwB,CAAC,oEAAoE,CAAC,CAAC;AAC/F,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB,CAAC;AACD,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B;AACA,IAAI,IAAI,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,CAAC,uBAAuB,CAAC,EAAE;AACzE,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL;AACA,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,oBAAoB,CAAC;AACvD,QAAQ,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE;AACtD,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;;;"}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param keyFields The fields used to indicate a match
|
|
7
7
|
* @returns Index of `needle` in `haystack`, otherwise -1 if not found.
|
|
8
8
|
*/
|
|
9
|
-
export declare function findIndexByFields<T>(needle: T, haystack: T[], keyFields:
|
|
9
|
+
export declare function findIndexByFields<T>(needle: T, haystack: T[], keyFields: (keyof T)[]): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/api-graphql",
|
|
3
|
-
"version": "4.0.22-unstable.
|
|
3
|
+
"version": "4.0.22-unstable.f6055cb.0+f6055cb",
|
|
4
4
|
"description": "Api-graphql category of aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"clean": "npm run clean:size && rimraf dist lib lib-esm",
|
|
25
25
|
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
26
26
|
"format": "echo \"Not implemented\"",
|
|
27
|
-
"lint": "
|
|
27
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
28
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
28
29
|
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 70.0"
|
|
29
30
|
},
|
|
30
31
|
"exports": {
|
|
@@ -84,8 +85,8 @@
|
|
|
84
85
|
"server"
|
|
85
86
|
],
|
|
86
87
|
"dependencies": {
|
|
87
|
-
"@aws-amplify/api-rest": "4.0.22-unstable.
|
|
88
|
-
"@aws-amplify/core": "6.0.22-unstable.
|
|
88
|
+
"@aws-amplify/api-rest": "4.0.22-unstable.f6055cb.0+f6055cb",
|
|
89
|
+
"@aws-amplify/core": "6.0.22-unstable.f6055cb.0+f6055cb",
|
|
89
90
|
"@aws-amplify/data-schema-types": "^0.7.6",
|
|
90
91
|
"@aws-sdk/types": "3.387.0",
|
|
91
92
|
"graphql": "15.8.0",
|
|
@@ -101,5 +102,5 @@
|
|
|
101
102
|
"limit": "91.7 kB"
|
|
102
103
|
}
|
|
103
104
|
],
|
|
104
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "f6055cb5333222ee730ab2b67f81bf28c0c0a2a6"
|
|
105
106
|
}
|
package/src/GraphQLAPI.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
4
|
-
import {
|
|
5
|
-
import { GraphQLOptions, GraphQLResult } from './types';
|
|
6
|
-
import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
|
|
4
|
+
import { ApiAction, Category } from '@aws-amplify/core/internals/utils';
|
|
7
5
|
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
8
6
|
import { Observable } from 'rxjs';
|
|
9
7
|
|
|
8
|
+
import { GraphQLOptions, GraphQLResult } from './types';
|
|
9
|
+
import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
|
|
10
|
+
|
|
10
11
|
export const graphqlOperation = (
|
|
11
12
|
query: any,
|
|
12
13
|
variables = {},
|