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