@aws-amplify/api-graphql 4.0.22-unstable.f6055cb.0 → 4.0.22

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.
Files changed (98) hide show
  1. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +31 -40
  2. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
  3. package/dist/cjs/internals/APIClient.js +19 -34
  4. package/dist/cjs/internals/APIClient.js.map +1 -1
  5. package/dist/cjs/internals/InternalGraphQLAPI.js +9 -10
  6. package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
  7. package/dist/cjs/internals/generateClient.js +1 -1
  8. package/dist/cjs/internals/generateClient.js.map +1 -1
  9. package/dist/cjs/internals/operations/custom.js +2 -2
  10. package/dist/cjs/internals/operations/custom.js.map +1 -1
  11. package/dist/cjs/internals/operations/list.js +1 -1
  12. package/dist/cjs/internals/operations/list.js.map +1 -1
  13. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +1 -1
  14. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
  15. package/dist/cjs/internals/server/generateModelsProperty.js +1 -1
  16. package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -1
  17. package/dist/cjs/internals/v6.js +2 -0
  18. package/dist/cjs/internals/v6.js.map +1 -1
  19. package/dist/cjs/utils/errors/repackageAuthError.js +1 -1
  20. package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -1
  21. package/dist/esm/GraphQLAPI.d.ts +2 -2
  22. package/dist/esm/GraphQLAPI.mjs.map +1 -1
  23. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +8 -8
  24. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +31 -40
  25. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
  26. package/dist/esm/internals/APIClient.d.ts +6 -5
  27. package/dist/esm/internals/APIClient.mjs +19 -34
  28. package/dist/esm/internals/APIClient.mjs.map +1 -1
  29. package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
  30. package/dist/esm/internals/InternalGraphQLAPI.mjs +9 -10
  31. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
  32. package/dist/esm/internals/generateClient.mjs +1 -1
  33. package/dist/esm/internals/generateClient.mjs.map +1 -1
  34. package/dist/esm/internals/generateCustomOperationsProperty.d.ts +2 -2
  35. package/dist/esm/internals/operations/custom.d.ts +1 -1
  36. package/dist/esm/internals/operations/custom.mjs +2 -2
  37. package/dist/esm/internals/operations/custom.mjs.map +1 -1
  38. package/dist/esm/internals/operations/get.d.ts +1 -1
  39. package/dist/esm/internals/operations/get.mjs.map +1 -1
  40. package/dist/esm/internals/operations/indexQuery.d.ts +3 -3
  41. package/dist/esm/internals/operations/indexQuery.mjs.map +1 -1
  42. package/dist/esm/internals/operations/list.d.ts +1 -1
  43. package/dist/esm/internals/operations/list.mjs +1 -1
  44. package/dist/esm/internals/operations/list.mjs.map +1 -1
  45. package/dist/esm/internals/operations/subscription.d.ts +1 -1
  46. package/dist/esm/internals/operations/subscription.mjs.map +1 -1
  47. package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +1 -1
  48. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +1 -1
  49. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
  50. package/dist/esm/internals/server/generateModelsProperty.d.ts +2 -1
  51. package/dist/esm/internals/server/generateModelsProperty.mjs +1 -1
  52. package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -1
  53. package/dist/esm/internals/types.d.ts +2 -2
  54. package/dist/esm/internals/utils/clientProperties/generateModelsProperty.d.ts +1 -1
  55. package/dist/esm/internals/v6.d.ts +1 -1
  56. package/dist/esm/internals/v6.mjs +2 -0
  57. package/dist/esm/internals/v6.mjs.map +1 -1
  58. package/dist/esm/types/index.d.ts +35 -33
  59. package/dist/esm/utils/ConnectionStateMonitor.d.ts +2 -2
  60. package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -1
  61. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -1
  62. package/dist/esm/utils/errors/repackageAuthError.d.ts +2 -2
  63. package/dist/esm/utils/errors/repackageAuthError.mjs +1 -1
  64. package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -1
  65. package/dist/esm/utils/findIndexByFields.d.ts +1 -1
  66. package/package.json +5 -6
  67. package/src/GraphQLAPI.ts +3 -4
  68. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +64 -84
  69. package/src/internals/APIClient.ts +27 -59
  70. package/src/internals/InternalGraphQLAPI.ts +30 -26
  71. package/src/internals/clientUtils.ts +1 -1
  72. package/src/internals/generateClient.ts +10 -12
  73. package/src/internals/generateCustomOperationsProperty.ts +6 -7
  74. package/src/internals/operations/custom.ts +13 -16
  75. package/src/internals/operations/get.ts +8 -9
  76. package/src/internals/operations/indexQuery.ts +11 -12
  77. package/src/internals/operations/list.ts +15 -11
  78. package/src/internals/operations/observeQuery.ts +1 -3
  79. package/src/internals/operations/subscription.ts +10 -12
  80. package/src/internals/server/generateClientWithAmplifyInstance.ts +7 -7
  81. package/src/internals/server/generateModelsProperty.ts +4 -7
  82. package/src/internals/types.ts +2 -2
  83. package/src/internals/utils/clientProperties/generateEnumsProperty.ts +6 -7
  84. package/src/internals/utils/clientProperties/generateModelsProperty.ts +6 -7
  85. package/src/internals/v6.ts +4 -6
  86. package/src/server/generateClient.ts +1 -4
  87. package/src/types/PubSub.ts +0 -1
  88. package/src/types/index.ts +47 -49
  89. package/src/utils/ConnectionStateMonitor.ts +3 -8
  90. package/src/utils/ReachabilityMonitor/index.native.ts +1 -1
  91. package/src/utils/ReachabilityMonitor/index.ts +0 -1
  92. package/src/utils/ReconnectionMonitor.ts +0 -1
  93. package/src/utils/errors/repackageAuthError.ts +7 -6
  94. package/src/utils/findIndexByFields.ts +1 -1
  95. package/src/utils/resolveConfig.ts +0 -1
  96. package/src/utils/resolveLibraryOptions.ts +0 -1
  97. package/src/utils/resolveOwnerFields.ts +5 -7
  98. package/src/utils/resolvePKFields.ts +0 -1
@@ -1,10 +1,10 @@
1
1
  import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
2
- import { CustomHeaders, CustomMutations, CustomQueries, EnumTypes, ModelTypes } from '@aws-amplify/data-schema-types';
3
- import { DocumentNode, GraphQLError, Source } from 'graphql';
2
+ import { EnumTypes, ModelTypes, CustomHeaders, CustomQueries, CustomMutations } from '@aws-amplify/data-schema-types';
3
+ import { Source, DocumentNode, GraphQLError } from 'graphql';
4
+ export { OperationTypeNode } from 'graphql';
4
5
  import { Observable } from 'rxjs';
5
- import { DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
6
+ import { GraphQLAuthMode, DocumentType } from '@aws-amplify/core/internals/utils';
6
7
  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,7 +24,9 @@ export interface GraphQLOptions {
24
24
  export interface GraphQLResult<T = object> {
25
25
  data: T;
26
26
  errors?: GraphQLError[];
27
- extensions?: Record<string, any>;
27
+ extensions?: {
28
+ [key: string]: any;
29
+ };
28
30
  }
29
31
  declare const queryType: unique symbol;
30
32
  export type GraphQLQuery<T> = T & {
@@ -54,18 +56,18 @@ export type GraphQLSubscription<T> = T & {
54
56
  *
55
57
  * This util simply makes related model properties optional recursively.
56
58
  */
57
- export type GraphQLReturnType<T> = T extends Record<string, unknown> ? {
59
+ export type GraphQLReturnType<T> = T extends {} ? {
58
60
  [K in keyof T]?: GraphQLReturnType<T[K]>;
59
61
  } : T;
60
62
  /**
61
63
  * Describes a paged list result from AppSync, which can either
62
64
  * live at the top query or property (e.g., related model) level.
63
65
  */
64
- interface PagedList<T, TYPENAME> {
66
+ type PagedList<T, TYPENAME> = {
65
67
  __typename: TYPENAME;
66
68
  nextToken?: string | null | undefined;
67
- items: T[];
68
- }
69
+ items: Array<T>;
70
+ };
69
71
  /**
70
72
  * Recursively looks through a result type and removes nulls and
71
73
  * and undefined from `PagedList` types.
@@ -74,7 +76,7 @@ interface PagedList<T, TYPENAME> {
74
76
  * array, this will only be the case when we also have errors,
75
77
  * which will then be *thrown*.
76
78
  */
77
- type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends Record<string, unknown> ? {
79
+ type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends {} ? {
78
80
  [K in keyof T]: WithListsFixed<T[K]>;
79
81
  } : T;
80
82
  /**
@@ -130,9 +132,9 @@ export type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptionMessage
130
132
  * })
131
133
  * ```
132
134
  */
133
- export interface GraphqlSubscriptionMessage<T> {
135
+ export type GraphqlSubscriptionMessage<T> = {
134
136
  data: T;
135
- }
137
+ };
136
138
  export interface AWSAppSyncRealTimeProviderOptions {
137
139
  appSyncGraphqlEndpoint?: string;
138
140
  authenticationType?: GraphQLAuthMode;
@@ -140,12 +142,12 @@ export interface AWSAppSyncRealTimeProviderOptions {
140
142
  variables?: Record<string, unknown>;
141
143
  apiKey?: string;
142
144
  region?: string;
143
- libraryConfigHeaders?(): () => Promise<Record<string, unknown> | Headers>;
145
+ libraryConfigHeaders?: () => {} | (() => Promise<{}>);
144
146
  additionalHeaders?: CustomHeaders;
145
147
  }
146
- export interface AWSAppSyncRealTimeProvider {
148
+ export type AWSAppSyncRealTimeProvider = {
147
149
  subscribe(options?: AWSAppSyncRealTimeProviderOptions): Observable<Record<string, unknown>>;
148
- }
150
+ };
149
151
  export declare enum GraphQLAuthError {
150
152
  NO_API_KEY = "No api-key configured",
151
153
  NO_CURRENT_USER = "No current user",
@@ -189,7 +191,7 @@ export type GraphQLVariablesV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING extend
189
191
  * The expected return type with respect to the given `FALLBACK_TYPE`
190
192
  * and `TYPED_GQL_STRING`.
191
193
  */
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;
194
+ export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer IN, infer QUERY_OUT> ? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>> : TYPED_GQL_STRING extends GeneratedMutation<infer IN, infer MUTATION_OUT> ? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>> : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, infer SUB_OUT> ? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>> : FALLBACK_TYPE extends GraphQLQuery<infer T> ? Promise<GraphQLResult<FALLBACK_TYPE>> : FALLBACK_TYPE extends GraphQLSubscription<infer T> ? GraphqlSubscriptionResult<FALLBACK_TYPE> : FALLBACK_TYPE extends GraphQLOperationType<infer IN, infer CUSTOM_OUT> ? CUSTOM_OUT : UnknownGraphQLResponse;
193
195
  /**
194
196
  * The shape customers can use to provide `T` to `graphql<T>()` to specify both
195
197
  * `IN` and `OUT` types (the type of `variables` and the return type, respectively).
@@ -208,10 +210,10 @@ export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends
208
210
  * })
209
211
  * ```
210
212
  */
211
- export interface GraphQLOperationType<IN extends Record<string, DocumentType>, OUT extends Record<string, DocumentType>> {
213
+ export type GraphQLOperationType<IN extends {}, OUT extends {}> = {
212
214
  variables: IN;
213
215
  result: OUT;
214
- }
216
+ };
215
217
  /**
216
218
  * Nominal type for branding generated graphql query operation strings with
217
219
  * input and output types.
@@ -289,8 +291,8 @@ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
289
291
  [__authToken]?: string;
290
292
  [__headers]?: CustomHeaders;
291
293
  graphql: GraphQLMethod;
292
- cancel(promise: Promise<any>, message?: string): boolean;
293
- isCancelError(error: any): boolean;
294
+ cancel: (promise: Promise<any>, message?: string) => boolean;
295
+ isCancelError: (error: any) => boolean;
294
296
  models: ModelTypes<T>;
295
297
  enums: EnumTypes<T>;
296
298
  queries: CustomQueries<T>;
@@ -302,8 +304,8 @@ export type V6ClientSSRRequest<T extends Record<any, any> = never> = ExcludeNeve
302
304
  [__authToken]?: string;
303
305
  [__headers]?: CustomHeaders;
304
306
  graphql: GraphQLMethodSSR;
305
- cancel(promise: Promise<any>, message?: string): boolean;
306
- isCancelError(error: any): boolean;
307
+ cancel: (promise: Promise<any>, message?: string) => boolean;
308
+ isCancelError: (error: any) => boolean;
307
309
  models: ModelTypes<T, 'REQUEST'>;
308
310
  enums: EnumTypes<T>;
309
311
  queries: CustomQueries<T, 'REQUEST'>;
@@ -315,8 +317,8 @@ export type V6ClientSSRCookies<T extends Record<any, any> = never> = ExcludeNeve
315
317
  [__authToken]?: string;
316
318
  [__headers]?: CustomHeaders;
317
319
  graphql: GraphQLMethod;
318
- cancel(promise: Promise<any>, message?: string): boolean;
319
- isCancelError(error: any): boolean;
320
+ cancel: (promise: Promise<any>, message?: string) => boolean;
321
+ isCancelError: (error: any) => boolean;
320
322
  models: ModelTypes<T, 'COOKIES'>;
321
323
  enums: EnumTypes<T>;
322
324
  queries: CustomQueries<T, 'COOKIES'>;
@@ -329,22 +331,22 @@ export type GraphQLMethodSSR = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING exten
329
331
  *
330
332
  * The knobs available for configuring `server/generateClient` internally.
331
333
  */
332
- export interface ServerClientGenerationParams {
334
+ export type ServerClientGenerationParams = {
333
335
  amplify: null | ((fn: (amplify: AmplifyClassV6) => Promise<any>) => Promise<any>);
334
336
  config: ResourcesConfig;
335
- }
337
+ };
336
338
  export type QueryArgs = Record<string, unknown>;
337
- export interface ListArgs extends Record<string, unknown> {
339
+ export type ListArgs = {
338
340
  selectionSet?: string[];
339
- filter?: Record<string, unknown>;
341
+ filter?: {};
340
342
  headers?: CustomHeaders;
341
- }
342
- export interface AuthModeParams extends Record<string, unknown> {
343
+ };
344
+ export type AuthModeParams = {
343
345
  authMode?: GraphQLAuthMode;
344
346
  authToken?: string;
345
- }
346
- export interface GenerateServerClientParams {
347
+ };
348
+ export type GenerateServerClientParams = {
347
349
  config: ResourcesConfig;
348
350
  authMode?: GraphQLAuthMode;
349
351
  authToken?: string;
350
- }
352
+ };
@@ -2,12 +2,12 @@ import { Observable } from 'rxjs';
2
2
  import { ConnectionState } from '../types/PubSub';
3
3
  type LinkedConnectionState = 'connected' | 'disconnected';
4
4
  type LinkedHealthState = 'healthy' | 'unhealthy';
5
- interface LinkedConnectionStates {
5
+ type 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, 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,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,8BAA8B,GAAG,SAAS,CAAC;AACxD,QAAQ,IAAI,CAAC,sBAAsB,GAAG;AACtC,YAAY,YAAY,EAAE,WAAW;AACrC,YAAY,eAAe,EAAE,cAAc;AAC3C,YAAY,uBAAuB,EAAE,cAAc;AACnD,YAAY,cAAc,EAAE,SAAS;AACrC,SAAS,CAAC;AACV;AACA,QAAQ,IAAI,CAAC,gCAAgC,GAAG,mBAAmB,EA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AAC;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
+ {"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, map, filter } 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,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, 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
+ {"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 { default as 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
- interface ErrorObject {
2
+ type 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?.originalError?.name?.startsWith('UnauthorizedException')) {
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?.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;;;;"}
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,GAAG,eAAe,CAAC,GAAG,MAAM,CAAC,EAAE,UAAU,CAAC,uBAAuB,CAAC,EAAE;AACjF,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: (keyof T)[]): number;
9
+ export declare function findIndexByFields<T>(needle: T, haystack: T[], keyFields: Array<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.f6055cb.0+f6055cb",
3
+ "version": "4.0.22",
4
4
  "description": "Api-graphql category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -24,8 +24,7 @@
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": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
28
- "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
27
+ "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
29
28
  "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 70.0"
30
29
  },
31
30
  "exports": {
@@ -85,8 +84,8 @@
85
84
  "server"
86
85
  ],
87
86
  "dependencies": {
88
- "@aws-amplify/api-rest": "4.0.22-unstable.f6055cb.0+f6055cb",
89
- "@aws-amplify/core": "6.0.22-unstable.f6055cb.0+f6055cb",
87
+ "@aws-amplify/api-rest": "4.0.22",
88
+ "@aws-amplify/core": "6.0.22",
90
89
  "@aws-amplify/data-schema-types": "^0.7.6",
91
90
  "@aws-sdk/types": "3.387.0",
92
91
  "graphql": "15.8.0",
@@ -102,5 +101,5 @@
102
101
  "limit": "91.7 kB"
103
102
  }
104
103
  ],
105
- "gitHead": "f6055cb5333222ee730ab2b67f81bf28c0c0a2a6"
104
+ "gitHead": "080f8c11e9eb89cdcd29d78a2b4fe07c8c5b5404"
106
105
  }
package/src/GraphQLAPI.ts CHANGED
@@ -1,12 +1,11 @@
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 { ApiAction, Category } from '@aws-amplify/core/internals/utils';
5
- import { CustomHeaders } from '@aws-amplify/data-schema-types';
6
- import { Observable } from 'rxjs';
7
-
4
+ import { Category, ApiAction } from '@aws-amplify/core/internals/utils';
8
5
  import { GraphQLOptions, GraphQLResult } from './types';
9
6
  import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
7
+ import { CustomHeaders } from '@aws-amplify/data-schema-types';
8
+ import { Observable } from 'rxjs';
10
9
 
11
10
  export const graphqlOperation = (
12
11
  query: any,