@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.
Files changed (98) hide show
  1. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +40 -31
  2. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
  3. package/dist/cjs/internals/APIClient.js +34 -19
  4. package/dist/cjs/internals/APIClient.js.map +1 -1
  5. package/dist/cjs/internals/InternalGraphQLAPI.js +10 -9
  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 +0 -2
  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 +40 -31
  25. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
  26. package/dist/esm/internals/APIClient.d.ts +5 -6
  27. package/dist/esm/internals/APIClient.mjs +34 -19
  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 +10 -9
  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 +1 -2
  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 +0 -2
  57. package/dist/esm/internals/v6.mjs.map +1 -1
  58. package/dist/esm/types/index.d.ts +33 -35
  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 +6 -5
  67. package/src/GraphQLAPI.ts +4 -3
  68. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +84 -64
  69. package/src/internals/APIClient.ts +59 -27
  70. package/src/internals/InternalGraphQLAPI.ts +26 -30
  71. package/src/internals/clientUtils.ts +1 -1
  72. package/src/internals/generateClient.ts +12 -10
  73. package/src/internals/generateCustomOperationsProperty.ts +7 -6
  74. package/src/internals/operations/custom.ts +16 -13
  75. package/src/internals/operations/get.ts +9 -8
  76. package/src/internals/operations/indexQuery.ts +12 -11
  77. package/src/internals/operations/list.ts +11 -15
  78. package/src/internals/operations/observeQuery.ts +3 -1
  79. package/src/internals/operations/subscription.ts +12 -10
  80. package/src/internals/server/generateClientWithAmplifyInstance.ts +7 -7
  81. package/src/internals/server/generateModelsProperty.ts +7 -4
  82. package/src/internals/types.ts +2 -2
  83. package/src/internals/utils/clientProperties/generateEnumsProperty.ts +7 -6
  84. package/src/internals/utils/clientProperties/generateModelsProperty.ts +7 -6
  85. package/src/internals/v6.ts +6 -4
  86. package/src/server/generateClient.ts +4 -1
  87. package/src/types/PubSub.ts +1 -0
  88. package/src/types/index.ts +49 -47
  89. package/src/utils/ConnectionStateMonitor.ts +8 -3
  90. package/src/utils/ReachabilityMonitor/index.native.ts +1 -1
  91. package/src/utils/ReachabilityMonitor/index.ts +1 -0
  92. package/src/utils/ReconnectionMonitor.ts +1 -0
  93. package/src/utils/errors/repackageAuthError.ts +6 -7
  94. package/src/utils/findIndexByFields.ts +1 -1
  95. package/src/utils/resolveConfig.ts +1 -0
  96. package/src/utils/resolveLibraryOptions.ts +1 -0
  97. package/src/utils/resolveOwnerFields.ts +7 -5
  98. package/src/utils/resolvePKFields.ts +1 -0
@@ -2,25 +2,26 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
4
4
  import {
5
- initializeModel,
6
- generateGraphQLDocument,
5
+ ModelIntrospectionSchema,
6
+ SchemaModel,
7
+ } from '@aws-amplify/core/internals/utils';
8
+
9
+ import {
10
+ authModeParams,
7
11
  buildGraphQLVariables,
8
12
  flattenItems,
9
- authModeParams,
13
+ generateGraphQLDocument,
10
14
  getCustomHeaders,
15
+ initializeModel,
11
16
  } from '../APIClient';
12
17
  import {
13
18
  AuthModeParams,
14
19
  ClientWithModels,
20
+ GraphQLResult,
15
21
  ListArgs,
16
22
  V6Client,
17
23
  V6ClientSSRRequest,
18
- GraphQLResult,
19
24
  } from '../../types';
20
- import {
21
- ModelIntrospectionSchema,
22
- SchemaModel,
23
- } from '@aws-amplify/core/internals/utils';
24
25
 
25
26
  export function listFactory(
26
27
  client: ClientWithModels,
@@ -51,12 +52,7 @@ async function _list(
51
52
  ) {
52
53
  const { name } = model;
53
54
 
54
- const query = generateGraphQLDocument(
55
- modelIntrospection,
56
- name,
57
- 'LIST',
58
- args,
59
- );
55
+ const query = generateGraphQLDocument(modelIntrospection, name, 'LIST', args);
60
56
  const variables = buildGraphQLVariables(
61
57
  model,
62
58
  'LIST',
@@ -69,7 +65,7 @@ async function _list(
69
65
 
70
66
  const headers = getCustomHeaders(client, args?.headers);
71
67
 
72
- const { data, extensions } = !!contextSpec
68
+ const { data, extensions } = contextSpec
73
69
  ? ((await (client as V6ClientSSRRequest<Record<string, any>>).graphql(
74
70
  contextSpec,
75
71
  {
@@ -1,9 +1,10 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Observable } from 'rxjs';
4
- import { findIndexByFields, resolvePKFields } from '../../utils';
5
4
  import { SchemaModel } from '@aws-amplify/core/internals/utils';
6
5
 
6
+ import { findIndexByFields, resolvePKFields } from '../../utils';
7
+
7
8
  export function observeQueryFactory(models: any, model: SchemaModel) {
8
9
  const { name } = model;
9
10
 
@@ -124,6 +125,7 @@ export function observeQueryFactory(models: any, model: SchemaModel) {
124
125
  // switch the queue to write directly to the items collection
125
126
  receiveMessages = (...messages: typeof messageQueue) => {
126
127
  ingestMessages(messages);
128
+
127
129
  return items.length;
128
130
  };
129
131
  })();
@@ -2,20 +2,21 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { map } from 'rxjs';
5
- import { V6Client, GraphqlSubscriptionResult } from '../../types';
6
- import {
7
- initializeModel,
8
- generateGraphQLDocument,
9
- buildGraphQLVariables,
10
- authModeParams,
11
- ModelOperation,
12
- getCustomHeaders,
13
- } from '../APIClient';
14
5
  import {
15
6
  ModelIntrospectionSchema,
16
7
  SchemaModel,
17
8
  } from '@aws-amplify/core/internals/utils';
18
9
 
10
+ import { GraphqlSubscriptionResult, V6Client } from '../../types';
11
+ import {
12
+ ModelOperation,
13
+ authModeParams,
14
+ buildGraphQLVariables,
15
+ generateGraphQLDocument,
16
+ getCustomHeaders,
17
+ initializeModel,
18
+ } from '../APIClient';
19
+
19
20
  export function subscriptionFactory(
20
21
  client: any,
21
22
  modelIntrospection: ModelIntrospectionSchema,
@@ -29,7 +30,7 @@ export function subscriptionFactory(
29
30
  modelIntrospection,
30
31
  name,
31
32
  operation,
32
- args
33
+ args,
33
34
  );
34
35
 
35
36
  const variables = buildGraphQLVariables(
@@ -64,6 +65,7 @@ export function subscriptionFactory(
64
65
  auth.authMode,
65
66
  auth.authToken,
66
67
  );
68
+
67
69
  return initialized;
68
70
  }),
69
71
  );
@@ -1,18 +1,16 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { graphql, cancel, isCancelError } from '..';
5
- import { generateModelsProperty } from './generateModelsProperty';
6
- import { Hub } from '@aws-amplify/core';
4
+ import { cancel, graphql, isCancelError } from '..';
7
5
  import {
6
+ CommonPublicClientOptions,
7
+ ServerClientGenerationParams,
8
+ V6ClientSSRCookies,
9
+ V6ClientSSRRequest,
8
10
  __amplify,
9
11
  __authMode,
10
12
  __authToken,
11
13
  __headers,
12
- V6ClientSSRRequest,
13
- V6ClientSSRCookies,
14
- ServerClientGenerationParams,
15
- CommonPublicClientOptions,
16
14
  } from '../../types';
17
15
  import { isApiGraphQLConfig } from '../utils/runtimeTypeGuards/isApiGraphQLProviderConfig';
18
16
  import { generateEnumsProperty } from '../utils/clientProperties/generateEnumsProperty';
@@ -21,6 +19,8 @@ import {
21
19
  generateCustomQueriesProperty,
22
20
  } from '../generateCustomOperationsProperty';
23
21
 
22
+ import { generateModelsProperty } from './generateModelsProperty';
23
+
24
24
  /**
25
25
  * @private
26
26
  *
@@ -1,11 +1,14 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { ModelTypes } from '@aws-amplify/data-schema-types';
4
- import { graphQLOperationsInfo, ModelOperation } from '../APIClient';
5
- import { ServerClientGenerationParams } from '../../types/';
6
- import { V6ClientSSRRequest, V6ClientSSRCookies } from '../../types';
7
4
  import { ModelIntrospectionSchema } from '@aws-amplify/core/internals/utils';
8
5
 
6
+ import { ModelOperation, graphQLOperationsInfo } from '../APIClient';
7
+ import {
8
+ ServerClientGenerationParams,
9
+ V6ClientSSRCookies,
10
+ V6ClientSSRRequest,
11
+ } from '../../types/';
9
12
  import { listFactory } from '../operations/list';
10
13
  import { indexQueryFactory } from '../operations/indexQuery';
11
14
  import { getFactory } from '../operations/get';
@@ -20,7 +23,7 @@ export function generateModelsProperty<
20
23
  >,
21
24
  >(client: ClientType, params: ServerClientGenerationParams): ClientType {
22
25
  const models = {} as any;
23
- const config = params.config;
26
+ const { config } = params;
24
27
  const useContext = params.amplify === null;
25
28
 
26
29
  if (!config) {
@@ -16,8 +16,8 @@ export type ClientGenerationParams = {
16
16
  /**
17
17
  * Common options that can be used on public `generateClient()` interfaces.
18
18
  */
19
- export type CommonPublicClientOptions = {
19
+ export interface CommonPublicClientOptions {
20
20
  authMode?: GraphQLAuthMode;
21
21
  authToken?: string;
22
22
  headers?: CustomHeaders;
23
- };
23
+ }
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import {
5
- ModelIntrospectionSchema,
6
5
  GraphQLProviderConfig,
6
+ ModelIntrospectionSchema,
7
7
  } from '@aws-amplify/core/internals/utils';
8
8
  import { EnumTypes } from '@aws-amplify/data-schema-types';
9
9
 
@@ -17,11 +17,12 @@ export const generateEnumsProperty = <T extends Record<any, any> = never>(
17
17
  return {} as EnumTypes<never>;
18
18
  }
19
19
 
20
- const enums: {
21
- [EnumName: string]: {
22
- values: () => string[];
23
- };
24
- } = {};
20
+ const enums: Record<
21
+ string,
22
+ {
23
+ values(): string[];
24
+ }
25
+ > = {};
25
26
 
26
27
  for (const [_, enumData] of Object.entries(modelIntrospection.enums)) {
27
28
  enums[enumData.name] = {
@@ -1,17 +1,18 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { ModelTypes } from '@aws-amplify/data-schema-types';
4
- import { graphQLOperationsInfo, ModelOperation } from '../../APIClient';
5
- import { V6Client, __authMode, __authToken } from '../../../types';
4
+ import {
5
+ GraphQLProviderConfig,
6
+ ModelIntrospectionSchema,
7
+ } from '@aws-amplify/core/internals/utils';
8
+
9
+ import { ModelOperation, graphQLOperationsInfo } from '../../APIClient';
10
+ import { V6Client } from '../../../types';
6
11
  import { listFactory } from '../../operations/list';
7
12
  import { indexQueryFactory } from '../../operations/indexQuery';
8
13
  import { getFactory } from '../../operations/get';
9
14
  import { subscriptionFactory } from '../../operations/subscription';
10
15
  import { observeQueryFactory } from '../../operations/observeQuery';
11
- import {
12
- ModelIntrospectionSchema,
13
- GraphQLProviderConfig,
14
- } from '@aws-amplify/core/internals/utils';
15
16
  import { getSecondaryIndexesFromSchemaModel } from '../../clientUtils';
16
17
 
17
18
  export function generateModelsProperty<T extends Record<any, any> = never>(
@@ -1,15 +1,16 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ import { CustomHeaders } from '@aws-amplify/data-schema-types';
4
+
3
5
  import { GraphQLAPI } from '../GraphQLAPI';
4
6
  import {
7
+ GraphQLOptionsV6,
8
+ GraphQLResponseV6,
9
+ V6Client,
5
10
  __amplify,
6
11
  __authMode,
7
12
  __authToken,
8
- V6Client,
9
- GraphQLOptionsV6,
10
- GraphQLResponseV6,
11
13
  } from '../types';
12
- import { CustomHeaders } from '@aws-amplify/data-schema-types';
13
14
 
14
15
  /**
15
16
  * Invokes graphql operations against a graphql service, providing correct input and
@@ -117,6 +118,7 @@ export function graphql<
117
118
  options,
118
119
  additionalHeaders,
119
120
  );
121
+
120
122
  return result as any;
121
123
  }
122
124
 
@@ -5,6 +5,8 @@ import {
5
5
  AmplifyServer,
6
6
  getAmplifyServerContext,
7
7
  } from '@aws-amplify/core/internals/adapter-core';
8
+ import { CustomHeaders } from '@aws-amplify/data-schema-types';
9
+
8
10
  import { generateClientWithAmplifyInstance } from '../internals/server';
9
11
  import {
10
12
  GenerateServerClientParams,
@@ -14,7 +16,6 @@ import {
14
16
  V6ClientSSRRequest,
15
17
  __amplify,
16
18
  } from '../types';
17
- import { CustomHeaders } from '@aws-amplify/data-schema-types';
18
19
 
19
20
  /**
20
21
  * Generates an GraphQL API client that works with Amplify server context.
@@ -55,6 +56,7 @@ export function generateClient<T extends Record<any, any> = never>({
55
56
  additionalHeaders?: CustomHeaders,
56
57
  ) => {
57
58
  const amplifyInstance = getAmplifyServerContext(contextSpec).amplify;
59
+
58
60
  return prevGraphql.call(
59
61
  { [__amplify]: amplifyInstance },
60
62
  options,
@@ -63,5 +65,6 @@ export function generateClient<T extends Record<any, any> = never>({
63
65
  };
64
66
 
65
67
  client.graphql = wrappedGraphql as unknown as GraphQLMethodSSR;
68
+
66
69
  return client;
67
70
  }
@@ -1,6 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Observer } from 'rxjs';
4
+
4
5
  export interface SubscriptionObserver<T> {
5
6
  closed: boolean;
6
7
  next(value: T): void;
@@ -2,22 +2,22 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
4
4
  import {
5
- EnumTypes,
6
- ModelTypes,
7
5
  CustomHeaders,
8
- CustomQueries,
9
6
  CustomMutations,
7
+ CustomQueries,
8
+ EnumTypes,
9
+ ModelTypes,
10
10
  } from '@aws-amplify/data-schema-types';
11
- import { Source, DocumentNode, GraphQLError } from 'graphql';
12
- export { OperationTypeNode } from 'graphql';
11
+ import { DocumentNode, GraphQLError, Source } from 'graphql';
13
12
  import { Observable } from 'rxjs';
14
-
15
13
  import {
16
- GraphQLAuthMode,
17
14
  DocumentType,
15
+ GraphQLAuthMode,
18
16
  } from '@aws-amplify/core/internals/utils';
19
17
  import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
20
18
 
19
+ export { OperationTypeNode } from 'graphql';
20
+
21
21
  export { CONTROL_MSG, ConnectionState } from './PubSub';
22
22
 
23
23
  export { SelectionSet } from '@aws-amplify/data-schema-types';
@@ -41,9 +41,7 @@ export interface GraphQLOptions {
41
41
  export interface GraphQLResult<T = object> {
42
42
  data: T;
43
43
  errors?: GraphQLError[];
44
- extensions?: {
45
- [key: string]: any;
46
- };
44
+ extensions?: Record<string, any>;
47
45
  }
48
46
 
49
47
  // Opaque type used for determining the graphql query type
@@ -75,21 +73,22 @@ export type GraphQLSubscription<T> = T & {
75
73
  *
76
74
  * This util simply makes related model properties optional recursively.
77
75
  */
78
- export type GraphQLReturnType<T> = T extends {}
79
- ? {
80
- [K in keyof T]?: GraphQLReturnType<T[K]>;
81
- }
82
- : T;
76
+ export type GraphQLReturnType<T> =
77
+ T extends Record<string, unknown>
78
+ ? {
79
+ [K in keyof T]?: GraphQLReturnType<T[K]>;
80
+ }
81
+ : T;
83
82
 
84
83
  /**
85
84
  * Describes a paged list result from AppSync, which can either
86
85
  * live at the top query or property (e.g., related model) level.
87
86
  */
88
- type PagedList<T, TYPENAME> = {
87
+ interface PagedList<T, TYPENAME> {
89
88
  __typename: TYPENAME;
90
89
  nextToken?: string | null | undefined;
91
- items: Array<T>;
92
- };
90
+ items: T[];
91
+ }
93
92
 
94
93
  /**
95
94
  * Recursively looks through a result type and removes nulls and
@@ -102,7 +101,7 @@ type PagedList<T, TYPENAME> = {
102
101
  type WithListsFixed<T> =
103
102
  T extends PagedList<infer IT, infer NAME>
104
103
  ? PagedList<Exclude<IT, null | undefined>, NAME>
105
- : T extends {}
104
+ : T extends Record<string, unknown>
106
105
  ? {
107
106
  [K in keyof T]: WithListsFixed<T[K]>;
108
107
  }
@@ -169,9 +168,9 @@ export type GraphqlSubscriptionResult<T> = Observable<
169
168
  * })
170
169
  * ```
171
170
  */
172
- export type GraphqlSubscriptionMessage<T> = {
171
+ export interface GraphqlSubscriptionMessage<T> {
173
172
  data: T;
174
- };
173
+ }
175
174
 
176
175
  export interface AWSAppSyncRealTimeProviderOptions {
177
176
  appSyncGraphqlEndpoint?: string;
@@ -180,15 +179,15 @@ export interface AWSAppSyncRealTimeProviderOptions {
180
179
  variables?: Record<string, unknown>;
181
180
  apiKey?: string;
182
181
  region?: string;
183
- libraryConfigHeaders?: () => {} | (() => Promise<{}>);
182
+ libraryConfigHeaders?(): () => Promise<Record<string, unknown> | Headers>;
184
183
  additionalHeaders?: CustomHeaders;
185
184
  }
186
185
 
187
- export type AWSAppSyncRealTimeProvider = {
186
+ export interface AWSAppSyncRealTimeProvider {
188
187
  subscribe(
189
188
  options?: AWSAppSyncRealTimeProviderOptions,
190
189
  ): Observable<Record<string, unknown>>;
191
- };
190
+ }
192
191
 
193
192
  export enum GraphQLAuthError {
194
193
  NO_API_KEY = 'No api-key configured',
@@ -259,18 +258,18 @@ export type GraphQLResponseV6<
259
258
  FALLBACK_TYPE = unknown,
260
259
  TYPED_GQL_STRING extends string = string,
261
260
  > =
262
- TYPED_GQL_STRING extends GeneratedQuery<infer IN, infer QUERY_OUT>
261
+ TYPED_GQL_STRING extends GeneratedQuery<infer _, infer QUERY_OUT>
263
262
  ? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>>
264
- : TYPED_GQL_STRING extends GeneratedMutation<infer IN, infer MUTATION_OUT>
263
+ : TYPED_GQL_STRING extends GeneratedMutation<infer _, infer MUTATION_OUT>
265
264
  ? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>>
266
- : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, infer SUB_OUT>
265
+ : TYPED_GQL_STRING extends GeneratedSubscription<infer _, infer SUB_OUT>
267
266
  ? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>>
268
- : FALLBACK_TYPE extends GraphQLQuery<infer T>
267
+ : FALLBACK_TYPE extends GraphQLQuery<infer _>
269
268
  ? Promise<GraphQLResult<FALLBACK_TYPE>>
270
- : FALLBACK_TYPE extends GraphQLSubscription<infer T>
269
+ : FALLBACK_TYPE extends GraphQLSubscription<infer _>
271
270
  ? GraphqlSubscriptionResult<FALLBACK_TYPE>
272
271
  : FALLBACK_TYPE extends GraphQLOperationType<
273
- infer IN,
272
+ infer _,
274
273
  infer CUSTOM_OUT
275
274
  >
276
275
  ? CUSTOM_OUT
@@ -294,10 +293,13 @@ export type GraphQLResponseV6<
294
293
  * })
295
294
  * ```
296
295
  */
297
- export type GraphQLOperationType<IN extends {}, OUT extends {}> = {
296
+ export interface GraphQLOperationType<
297
+ IN extends Record<string, DocumentType>,
298
+ OUT extends Record<string, DocumentType>,
299
+ > {
298
300
  variables: IN;
299
301
  result: OUT;
300
- };
302
+ }
301
303
 
302
304
  /**
303
305
  * Nominal type for branding generated graphql query operation strings with
@@ -386,8 +388,8 @@ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
386
388
  [__authToken]?: string;
387
389
  [__headers]?: CustomHeaders;
388
390
  graphql: GraphQLMethod;
389
- cancel: (promise: Promise<any>, message?: string) => boolean;
390
- isCancelError: (error: any) => boolean;
391
+ cancel(promise: Promise<any>, message?: string): boolean;
392
+ isCancelError(error: any): boolean;
391
393
  models: ModelTypes<T>;
392
394
  enums: EnumTypes<T>;
393
395
  queries: CustomQueries<T>;
@@ -401,8 +403,8 @@ export type V6ClientSSRRequest<T extends Record<any, any> = never> =
401
403
  [__authToken]?: string;
402
404
  [__headers]?: CustomHeaders;
403
405
  graphql: GraphQLMethodSSR;
404
- cancel: (promise: Promise<any>, message?: string) => boolean;
405
- isCancelError: (error: any) => boolean;
406
+ cancel(promise: Promise<any>, message?: string): boolean;
407
+ isCancelError(error: any): boolean;
406
408
  models: ModelTypes<T, 'REQUEST'>;
407
409
  enums: EnumTypes<T>;
408
410
  queries: CustomQueries<T, 'REQUEST'>;
@@ -416,8 +418,8 @@ export type V6ClientSSRCookies<T extends Record<any, any> = never> =
416
418
  [__authToken]?: string;
417
419
  [__headers]?: CustomHeaders;
418
420
  graphql: GraphQLMethod;
419
- cancel: (promise: Promise<any>, message?: string) => boolean;
420
- isCancelError: (error: any) => boolean;
421
+ cancel(promise: Promise<any>, message?: string): boolean;
422
+ isCancelError(error: any): boolean;
421
423
  models: ModelTypes<T, 'COOKIES'>;
422
424
  enums: EnumTypes<T>;
423
425
  queries: CustomQueries<T, 'COOKIES'>;
@@ -446,30 +448,30 @@ export type GraphQLMethodSSR = <
446
448
  *
447
449
  * The knobs available for configuring `server/generateClient` internally.
448
450
  */
449
- export type ServerClientGenerationParams = {
451
+ export interface ServerClientGenerationParams {
450
452
  amplify:
451
453
  | null // null expected when used with `generateServerClient`
452
454
  // closure expected with `generateServerClientUsingCookies`
453
455
  | ((fn: (amplify: AmplifyClassV6) => Promise<any>) => Promise<any>);
454
456
  // global env-sourced config use for retrieving modelIntro
455
457
  config: ResourcesConfig;
456
- };
458
+ }
457
459
 
458
460
  export type QueryArgs = Record<string, unknown>;
459
461
 
460
- export type ListArgs = {
462
+ export interface ListArgs extends Record<string, unknown> {
461
463
  selectionSet?: string[];
462
- filter?: {};
464
+ filter?: Record<string, unknown>;
463
465
  headers?: CustomHeaders;
464
- };
466
+ }
465
467
 
466
- export type AuthModeParams = {
468
+ export interface AuthModeParams extends Record<string, unknown> {
467
469
  authMode?: GraphQLAuthMode;
468
470
  authToken?: string;
469
- };
471
+ }
470
472
 
471
- export type GenerateServerClientParams = {
473
+ export interface GenerateServerClientParams {
472
474
  config: ResourcesConfig;
473
475
  authMode?: GraphQLAuthMode;
474
476
  authToken?: string;
475
- };
477
+ }
@@ -1,19 +1,21 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { Observable, Observer, SubscriptionLike, map, filter } from 'rxjs';
4
+ import { Observable, Observer, SubscriptionLike, filter, map } from 'rxjs';
5
+
5
6
  import { ConnectionState } from '../types/PubSub';
7
+
6
8
  import { ReachabilityMonitor } from './ReachabilityMonitor';
7
9
 
8
10
  // Internal types for tracking different connection states
9
11
  type LinkedConnectionState = 'connected' | 'disconnected';
10
12
  type LinkedHealthState = 'healthy' | 'unhealthy';
11
- type LinkedConnectionStates = {
13
+ interface LinkedConnectionStates {
12
14
  networkState: LinkedConnectionState;
13
15
  connectionState: LinkedConnectionState | 'connecting';
14
16
  intendedConnectionState: LinkedConnectionState;
15
17
  keepAliveState: LinkedHealthState;
16
- };
18
+ }
17
19
 
18
20
  export const CONNECTION_CHANGE: {
19
21
  [key in
@@ -53,6 +55,7 @@ export class ConnectionStateMonitor {
53
55
  private _linkedConnectionStateObserver:
54
56
  | Observer<LinkedConnectionStates>
55
57
  | undefined;
58
+
56
59
  private _networkMonitoringSubscription?: SubscriptionLike;
57
60
  private _initialNetworkStateSubscription?: SubscriptionLike;
58
61
 
@@ -132,6 +135,7 @@ export class ConnectionStateMonitor {
132
135
  filter(current => {
133
136
  const toInclude = current !== previous;
134
137
  previous = current;
138
+
135
139
  return toInclude;
136
140
  }),
137
141
  );
@@ -196,6 +200,7 @@ export class ConnectionStateMonitor {
196
200
  // All remaining states directly correspond to the connection state
197
201
  if (connectionState === 'connecting') return ConnectionState.Connecting;
198
202
  if (connectionState === 'disconnected') return ConnectionState.Disconnected;
203
+
199
204
  return ConnectionState.Connected;
200
205
  }
201
206
  }
@@ -1,7 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Reachability } from '@aws-amplify/core/internals/utils';
4
- import { default as NetInfo } from '@react-native-community/netinfo';
4
+ import NetInfo from '@react-native-community/netinfo';
5
5
 
6
6
  export const ReachabilityMonitor = () =>
7
7
  new Reachability().networkMonitor(NetInfo);
@@ -1,4 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Reachability } from '@aws-amplify/core/internals/utils';
4
+
4
5
  export const ReachabilityMonitor = () => new Reachability().networkMonitor();
@@ -1,6 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Observer } from 'rxjs';
4
+
4
5
  import { RECONNECT_DELAY, RECONNECT_INTERVAL } from '../Providers/constants';
5
6
 
6
7
  export enum ReconnectEvent {
@@ -1,14 +1,11 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import {
5
- AmplifyErrorParams,
6
- GraphQLAuthMode,
7
- } from '@aws-amplify/core/internals/utils';
4
+ import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
8
5
 
9
- type ErrorObject = {
6
+ interface ErrorObject {
10
7
  errors: AmplifyErrorParams[];
11
- };
8
+ }
12
9
 
13
10
  /**
14
11
  * Checks to see if the given response or subscription message contains an
@@ -27,12 +24,13 @@ export function repackageUnauthError<T extends ErrorObject>(content: T): T {
27
24
  }
28
25
  });
29
26
  }
27
+
30
28
  return content;
31
29
  }
32
30
 
33
31
  function isUnauthError(error: any): boolean {
34
32
  // Error pattern corresponding to appsync calls
35
- if (error?.['originalError']?.['name']?.startsWith('UnauthorizedException')) {
33
+ if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
36
34
  return true;
37
35
  }
38
36
  // Error pattern corresponding to appsync subscriptions
@@ -42,5 +40,6 @@ function isUnauthError(error: any): boolean {
42
40
  ) {
43
41
  return true;
44
42
  }
43
+
45
44
  return false;
46
45
  }
@@ -11,7 +11,7 @@
11
11
  export function findIndexByFields<T>(
12
12
  needle: T,
13
13
  haystack: T[],
14
- keyFields: Array<keyof T>,
14
+ keyFields: (keyof T)[],
15
15
  ): number {
16
16
  const searchObject = Object.fromEntries(
17
17
  keyFields.map(fieldName => [fieldName, needle[fieldName]]),
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { AmplifyClassV6, ConsoleLogger } from '@aws-amplify/core';
5
+
5
6
  import { APIValidationErrorCode, assertValidationError } from './errors';
6
7
 
7
8
  const logger = new ConsoleLogger('GraphQLAPI resolveConfig');