@aws-amplify/datastore 5.0.32 → 5.0.33-s-auth.30d0cd2.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 (149) hide show
  1. package/dist/cjs/authModeStrategies/multiAuthStrategy.js +1 -1
  2. package/dist/cjs/authModeStrategies/multiAuthStrategy.js.map +1 -1
  3. package/dist/cjs/datastore/datastore.js +46 -41
  4. package/dist/cjs/datastore/datastore.js.map +1 -1
  5. package/dist/cjs/index.js +3 -1
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/predicates/index.js +1 -0
  8. package/dist/cjs/predicates/index.js.map +1 -1
  9. package/dist/cjs/predicates/next.js +13 -12
  10. package/dist/cjs/predicates/next.js.map +1 -1
  11. package/dist/cjs/predicates/sort.js +2 -2
  12. package/dist/cjs/predicates/sort.js.map +1 -1
  13. package/dist/cjs/storage/adapter/AsyncStorageAdapter.js +21 -18
  14. package/dist/cjs/storage/adapter/AsyncStorageAdapter.js.map +1 -1
  15. package/dist/cjs/storage/adapter/AsyncStorageDatabase.js +10 -9
  16. package/dist/cjs/storage/adapter/AsyncStorageDatabase.js.map +1 -1
  17. package/dist/cjs/storage/adapter/InMemoryStore.js +4 -1
  18. package/dist/cjs/storage/adapter/InMemoryStore.js.map +1 -1
  19. package/dist/cjs/storage/adapter/IndexedDBAdapter.js +21 -23
  20. package/dist/cjs/storage/adapter/IndexedDBAdapter.js.map +1 -1
  21. package/dist/cjs/storage/adapter/StorageAdapterBase.js +7 -7
  22. package/dist/cjs/storage/adapter/StorageAdapterBase.js.map +1 -1
  23. package/dist/cjs/storage/adapter/getDefaultAdapter/index.js +4 -1
  24. package/dist/cjs/storage/adapter/getDefaultAdapter/index.js.map +1 -1
  25. package/dist/cjs/storage/adapter/getDefaultAdapter/index.native.js +1 -0
  26. package/dist/cjs/storage/adapter/getDefaultAdapter/index.native.js.map +1 -1
  27. package/dist/cjs/storage/relationship.js +1 -0
  28. package/dist/cjs/storage/relationship.js.map +1 -1
  29. package/dist/cjs/storage/storage.js +14 -14
  30. package/dist/cjs/storage/storage.js.map +1 -1
  31. package/dist/cjs/sync/datastoreConnectivity.js +0 -3
  32. package/dist/cjs/sync/datastoreConnectivity.js.map +1 -1
  33. package/dist/cjs/sync/index.js +47 -43
  34. package/dist/cjs/sync/index.js.map +1 -1
  35. package/dist/cjs/sync/merger.js +1 -1
  36. package/dist/cjs/sync/merger.js.map +1 -1
  37. package/dist/cjs/sync/outbox.js +19 -17
  38. package/dist/cjs/sync/outbox.js.map +1 -1
  39. package/dist/cjs/sync/processors/errorMaps.js.map +1 -1
  40. package/dist/cjs/sync/processors/mutation.js +31 -28
  41. package/dist/cjs/sync/processors/mutation.js.map +1 -1
  42. package/dist/cjs/sync/processors/subscription.js +21 -12
  43. package/dist/cjs/sync/processors/subscription.js.map +1 -1
  44. package/dist/cjs/sync/processors/sync.js +25 -21
  45. package/dist/cjs/sync/processors/sync.js.map +1 -1
  46. package/dist/cjs/sync/utils.js +20 -21
  47. package/dist/cjs/sync/utils.js.map +1 -1
  48. package/dist/cjs/types.js +1 -0
  49. package/dist/cjs/types.js.map +1 -1
  50. package/dist/cjs/util.js +46 -25
  51. package/dist/cjs/util.js.map +1 -1
  52. package/dist/esm/authModeStrategies/multiAuthStrategy.d.ts +1 -1
  53. package/dist/esm/authModeStrategies/multiAuthStrategy.mjs +1 -1
  54. package/dist/esm/authModeStrategies/multiAuthStrategy.mjs.map +1 -1
  55. package/dist/esm/datastore/datastore.d.ts +4 -6
  56. package/dist/esm/datastore/datastore.mjs +42 -34
  57. package/dist/esm/datastore/datastore.mjs.map +1 -1
  58. package/dist/esm/index.d.ts +1 -1
  59. package/dist/esm/index.mjs +2 -2
  60. package/dist/esm/index.mjs.map +1 -1
  61. package/dist/esm/predicates/index.mjs +1 -0
  62. package/dist/esm/predicates/index.mjs.map +1 -1
  63. package/dist/esm/predicates/next.d.ts +7 -7
  64. package/dist/esm/predicates/next.mjs +13 -12
  65. package/dist/esm/predicates/next.mjs.map +1 -1
  66. package/dist/esm/predicates/sort.d.ts +1 -1
  67. package/dist/esm/predicates/sort.mjs +2 -2
  68. package/dist/esm/predicates/sort.mjs.map +1 -1
  69. package/dist/esm/storage/adapter/AsyncStorageAdapter.d.ts +1 -1
  70. package/dist/esm/storage/adapter/AsyncStorageAdapter.mjs +21 -18
  71. package/dist/esm/storage/adapter/AsyncStorageAdapter.mjs.map +1 -1
  72. package/dist/esm/storage/adapter/AsyncStorageDatabase.mjs +10 -9
  73. package/dist/esm/storage/adapter/AsyncStorageDatabase.mjs.map +1 -1
  74. package/dist/esm/storage/adapter/InMemoryStore.mjs +4 -1
  75. package/dist/esm/storage/adapter/InMemoryStore.mjs.map +1 -1
  76. package/dist/esm/storage/adapter/IndexedDBAdapter.mjs +21 -23
  77. package/dist/esm/storage/adapter/IndexedDBAdapter.mjs.map +1 -1
  78. package/dist/esm/storage/adapter/StorageAdapterBase.d.ts +2 -2
  79. package/dist/esm/storage/adapter/StorageAdapterBase.mjs +7 -7
  80. package/dist/esm/storage/adapter/StorageAdapterBase.mjs.map +1 -1
  81. package/dist/esm/storage/adapter/getDefaultAdapter/index.mjs +3 -1
  82. package/dist/esm/storage/adapter/getDefaultAdapter/index.mjs.map +1 -1
  83. package/dist/esm/storage/adapter/getDefaultAdapter/index.native.mjs +1 -0
  84. package/dist/esm/storage/adapter/getDefaultAdapter/index.native.mjs.map +1 -1
  85. package/dist/esm/storage/adapter/index.d.ts +1 -1
  86. package/dist/esm/storage/relationship.mjs +1 -0
  87. package/dist/esm/storage/relationship.mjs.map +1 -1
  88. package/dist/esm/storage/storage.d.ts +11 -11
  89. package/dist/esm/storage/storage.mjs +10 -10
  90. package/dist/esm/storage/storage.mjs.map +1 -1
  91. package/dist/esm/sync/datastoreConnectivity.d.ts +2 -2
  92. package/dist/esm/sync/datastoreConnectivity.mjs +0 -3
  93. package/dist/esm/sync/datastoreConnectivity.mjs.map +1 -1
  94. package/dist/esm/sync/index.d.ts +3 -3
  95. package/dist/esm/sync/index.mjs +47 -43
  96. package/dist/esm/sync/index.mjs.map +1 -1
  97. package/dist/esm/sync/merger.d.ts +1 -1
  98. package/dist/esm/sync/merger.mjs +1 -1
  99. package/dist/esm/sync/merger.mjs.map +1 -1
  100. package/dist/esm/sync/outbox.d.ts +4 -4
  101. package/dist/esm/sync/outbox.mjs +19 -17
  102. package/dist/esm/sync/outbox.mjs.map +1 -1
  103. package/dist/esm/sync/processors/errorMaps.mjs.map +1 -1
  104. package/dist/esm/sync/processors/mutation.d.ts +5 -5
  105. package/dist/esm/sync/processors/mutation.mjs +31 -28
  106. package/dist/esm/sync/processors/mutation.mjs.map +1 -1
  107. package/dist/esm/sync/processors/subscription.d.ts +1 -1
  108. package/dist/esm/sync/processors/subscription.mjs +21 -12
  109. package/dist/esm/sync/processors/subscription.mjs.map +1 -1
  110. package/dist/esm/sync/processors/sync.d.ts +3 -3
  111. package/dist/esm/sync/processors/sync.mjs +13 -9
  112. package/dist/esm/sync/processors/sync.mjs.map +1 -1
  113. package/dist/esm/sync/utils.d.ts +11 -13
  114. package/dist/esm/sync/utils.mjs +20 -21
  115. package/dist/esm/sync/utils.mjs.map +1 -1
  116. package/dist/esm/types.d.ts +121 -131
  117. package/dist/esm/types.mjs +3 -2
  118. package/dist/esm/types.mjs.map +1 -1
  119. package/dist/esm/util.d.ts +5 -5
  120. package/dist/esm/util.mjs +46 -25
  121. package/dist/esm/util.mjs.map +1 -1
  122. package/package.json +74 -73
  123. package/src/authModeStrategies/multiAuthStrategy.ts +8 -4
  124. package/src/datastore/datastore.ts +145 -123
  125. package/src/index.ts +10 -8
  126. package/src/predicates/index.ts +10 -2
  127. package/src/predicates/next.ts +39 -28
  128. package/src/predicates/sort.ts +23 -26
  129. package/src/storage/adapter/AsyncStorageAdapter.ts +43 -25
  130. package/src/storage/adapter/AsyncStorageDatabase.ts +18 -10
  131. package/src/storage/adapter/InMemoryStore.ts +5 -1
  132. package/src/storage/adapter/IndexedDBAdapter.ts +50 -37
  133. package/src/storage/adapter/StorageAdapterBase.ts +24 -18
  134. package/src/storage/adapter/getDefaultAdapter/index.native.ts +1 -0
  135. package/src/storage/adapter/getDefaultAdapter/index.ts +4 -1
  136. package/src/storage/adapter/index.ts +2 -2
  137. package/src/storage/relationship.ts +5 -1
  138. package/src/storage/storage.ts +38 -30
  139. package/src/sync/datastoreConnectivity.ts +4 -6
  140. package/src/sync/index.ts +228 -230
  141. package/src/sync/merger.ts +4 -3
  142. package/src/sync/outbox.ts +26 -24
  143. package/src/sync/processors/errorMaps.ts +5 -0
  144. package/src/sync/processors/mutation.ts +80 -72
  145. package/src/sync/processors/subscription.ts +69 -53
  146. package/src/sync/processors/sync.ts +49 -37
  147. package/src/sync/utils.ts +60 -41
  148. package/src/types.ts +165 -165
  149. package/src/util.ts +89 -53
@@ -2,22 +2,22 @@ import { Observable } from 'rxjs';
2
2
  import { MutationEvent } from '../';
3
3
  import { ModelInstanceCreator } from '../../datastore/datastore';
4
4
  import { ExclusiveStorage as Storage } from '../../storage/storage';
5
- import { AuthModeStrategy, ConflictHandler, ErrorHandler, InternalSchema, PersistentModel, PersistentModelConstructor, SchemaModel, TypeConstructorMap, AmplifyContext } from '../../types';
5
+ import { AmplifyContext, AuthModeStrategy, ConflictHandler, ErrorHandler, InternalSchema, PersistentModel, PersistentModelConstructor, SchemaModel, TypeConstructorMap } from '../../types';
6
6
  import { MutationEventOutbox } from '../outbox';
7
7
  import { TransformerMutationType } from '../utils';
8
- type MutationProcessorEvent = {
8
+ interface MutationProcessorEvent {
9
9
  operation: TransformerMutationType;
10
10
  modelDefinition: SchemaModel;
11
11
  model: PersistentModel;
12
12
  hasMore: boolean;
13
- };
13
+ }
14
14
  declare class MutationProcessor {
15
15
  private readonly schema;
16
16
  private readonly storage;
17
17
  private readonly userClasses;
18
18
  private readonly outbox;
19
19
  private readonly modelInstanceCreator;
20
- private readonly MutationEvent;
20
+ private readonly _MutationEvent;
21
21
  private readonly amplifyConfig;
22
22
  private readonly authModeStrategy;
23
23
  private readonly errorHandler;
@@ -35,7 +35,7 @@ declare class MutationProcessor {
35
35
  private readonly typeQuery;
36
36
  private processing;
37
37
  private runningProcesses;
38
- constructor(schema: InternalSchema, storage: Storage, userClasses: TypeConstructorMap, outbox: MutationEventOutbox, modelInstanceCreator: ModelInstanceCreator, MutationEvent: PersistentModelConstructor<MutationEvent>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, errorHandler: ErrorHandler, conflictHandler: ConflictHandler, amplifyContext: AmplifyContext);
38
+ constructor(schema: InternalSchema, storage: Storage, userClasses: TypeConstructorMap, outbox: MutationEventOutbox, modelInstanceCreator: ModelInstanceCreator, _MutationEvent: PersistentModelConstructor<MutationEvent>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, errorHandler: ErrorHandler, conflictHandler: ConflictHandler, amplifyContext: AmplifyContext);
39
39
  private generateQueries;
40
40
  private isReady;
41
41
  start(): Observable<MutationProcessorEvent>;
@@ -1,22 +1,22 @@
1
1
  import { InternalAPI } from '@aws-amplify/api/internals';
2
2
  import { jitteredBackoff, BackgroundProcessManager, retry, Category, DataStoreAction, NonRetryableError } from '@aws-amplify/core/internals/utils';
3
3
  import { Observable } from 'rxjs';
4
+ import { ConsoleLogger } from '@aws-amplify/core';
4
5
  import { ProcessName, DISCARD, isModelFieldType, isTargetNameAssociation, OpType } from '../../types.mjs';
5
6
  import { extractTargetNamesFromSrc, USER, ID } from '../../util.mjs';
6
7
  import { buildGraphQLOperation, getModelAuthModes, getTokenForCustomAuth, createMutationInstanceFromModelOperation, TransformerMutationType } from '../utils.mjs';
7
8
  import { getMutationErrorType } from './errorMaps.mjs';
8
- import { ConsoleLogger } from '@aws-amplify/core';
9
9
 
10
10
  const MAX_ATTEMPTS = 10;
11
11
  const logger = new ConsoleLogger('DataStore');
12
12
  class MutationProcessor {
13
- constructor(schema, storage, userClasses, outbox, modelInstanceCreator, MutationEvent, amplifyConfig = {}, authModeStrategy, errorHandler, conflictHandler, amplifyContext) {
13
+ constructor(schema, storage, userClasses, outbox, modelInstanceCreator, _MutationEvent, amplifyConfig = {}, authModeStrategy, errorHandler, conflictHandler, amplifyContext) {
14
14
  this.schema = schema;
15
15
  this.storage = storage;
16
16
  this.userClasses = userClasses;
17
17
  this.outbox = outbox;
18
18
  this.modelInstanceCreator = modelInstanceCreator;
19
- this.MutationEvent = MutationEvent;
19
+ this._MutationEvent = _MutationEvent;
20
20
  this.amplifyConfig = amplifyConfig;
21
21
  this.authModeStrategy = authModeStrategy;
22
22
  this.errorHandler = errorHandler;
@@ -108,7 +108,7 @@ class MutationProcessor {
108
108
  const authModeRetry = async () => {
109
109
  try {
110
110
  logger.debug(`Attempting mutation with authMode: ${operationAuthModes[authModeAttempts]}`);
111
- const response = await this.jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, this.MutationEvent, head, operationAuthModes[authModeAttempts], onTerminate);
111
+ const response = await this.jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, this._MutationEvent, head, operationAuthModes[authModeAttempts], onTerminate);
112
112
  logger.debug(`Mutation sent successfully with authMode: ${operationAuthModes[authModeAttempts]}`);
113
113
  return response;
114
114
  }
@@ -117,6 +117,7 @@ class MutationProcessor {
117
117
  if (authModeAttempts >= operationAuthModes.length) {
118
118
  logger.debug(`Mutation failed with authMode: ${operationAuthModes[authModeAttempts - 1]}`);
119
119
  try {
120
+ // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
120
121
  await this.errorHandler({
121
122
  recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',
122
123
  localModel: null,
@@ -135,7 +136,7 @@ class MutationProcessor {
135
136
  throw error;
136
137
  }
137
138
  logger.debug(`Mutation failed with authMode: ${operationAuthModes[authModeAttempts - 1]}. Retrying with authMode: ${operationAuthModes[authModeAttempts]}`);
138
- return await authModeRetry();
139
+ return authModeRetry();
139
140
  }
140
141
  };
141
142
  [result, opName, modelDefinition] = await authModeRetry();
@@ -173,9 +174,9 @@ class MutationProcessor {
173
174
  }, 'mutation resume loop');
174
175
  }
175
176
  }
176
- async jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent, authMode, onTerminate) {
177
- return await retry(async (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) => {
178
- const [query, variables, graphQLCondition, opName, modelDefinition] = this.createQueryVariables(namespaceName, model, operation, data, condition);
177
+ async jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, MutationEventCtor, mutationEvent, authMode, onTerminate) {
178
+ return retry(async (retriedModel, retriedOperation, retriedData, retriedCondition, retriedModelConstructor, retiredMutationEventCtor, retiredMutationEvent) => {
179
+ const [query, variables, graphQLCondition, opName, modelDefinition] = this.createQueryVariables(namespaceName, retriedModel, retriedOperation, retriedData, retriedCondition);
179
180
  const authToken = await getTokenForCustomAuth(authMode, this.amplifyConfig);
180
181
  const tryWith = {
181
182
  query,
@@ -184,7 +185,7 @@ class MutationProcessor {
184
185
  authToken,
185
186
  };
186
187
  let attempt = 0;
187
- const opType = this.opTypeFromTransformerOperation(operation);
188
+ const opType = this.opTypeFromTransformerOperation(retriedOperation);
188
189
  const customUserAgentDetails = {
189
190
  category: Category.DataStore,
190
191
  action: DataStoreAction.GraphQl,
@@ -222,34 +223,34 @@ class MutationProcessor {
222
223
  else {
223
224
  try {
224
225
  retryWith = await this.conflictHandler({
225
- modelConstructor,
226
- localModel: this.modelInstanceCreator(modelConstructor, variables.input),
227
- remoteModel: this.modelInstanceCreator(modelConstructor, error.data),
226
+ modelConstructor: retriedModelConstructor,
227
+ localModel: this.modelInstanceCreator(retriedModelConstructor, variables.input),
228
+ remoteModel: this.modelInstanceCreator(retriedModelConstructor, error.data),
228
229
  operation: opType,
229
230
  attempts: attempt,
230
231
  });
231
232
  }
232
- catch (err) {
233
- logger.warn('conflict trycatch', err);
233
+ catch (caughtErr) {
234
+ logger.warn('conflict trycatch', caughtErr);
234
235
  continue;
235
236
  }
236
237
  }
237
238
  if (retryWith === DISCARD) {
238
239
  // Query latest from server and notify merger
239
- const [[, opName, query]] = buildGraphQLOperation(this.schema.namespaces[namespaceName], modelDefinition, 'GET');
240
- const authToken = await getTokenForCustomAuth(authMode, this.amplifyConfig);
241
- const serverData = await this.amplifyContext.InternalAPI.graphql({
242
- query,
240
+ const [[, builtOpName, builtQuery]] = buildGraphQLOperation(this.schema.namespaces[namespaceName], modelDefinition, 'GET');
241
+ const newAuthToken = await getTokenForCustomAuth(authMode, this.amplifyConfig);
242
+ const serverData = (await this.amplifyContext.InternalAPI.graphql({
243
+ query: builtQuery,
243
244
  variables: { id: variables.input.id },
244
245
  authMode,
245
- authToken,
246
- }, undefined, customUserAgentDetails);
246
+ authToken: newAuthToken,
247
+ }, undefined, customUserAgentDetails));
247
248
  // onTerminate cancel graphql()
248
- return [serverData, opName, modelDefinition];
249
+ return [serverData, builtOpName, modelDefinition];
249
250
  }
250
251
  const namespace = this.schema.namespaces[namespaceName];
251
252
  // convert retry with to tryWith
252
- const updatedMutation = createMutationInstanceFromModelOperation(namespace.relationships, modelDefinition, opType, modelConstructor, retryWith, graphQLCondition, MutationEvent, this.modelInstanceCreator, mutationEvent.id);
253
+ const updatedMutation = createMutationInstanceFromModelOperation(namespace.relationships, modelDefinition, opType, retriedModelConstructor, retryWith, graphQLCondition, retiredMutationEventCtor, this.modelInstanceCreator, retiredMutationEvent.id);
253
254
  await this.storage.save(updatedMutation);
254
255
  throw new NonRetryableError('RetryMutation');
255
256
  }
@@ -259,21 +260,22 @@ class MutationProcessor {
259
260
  recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',
260
261
  localModel: variables.input,
261
262
  message: error.message,
262
- operation,
263
+ operation: retriedOperation,
263
264
  errorType: getMutationErrorType(error),
264
265
  errorInfo: error.errorInfo,
265
266
  process: ProcessName.mutate,
266
267
  cause: error,
267
268
  remoteModel: error.data
268
- ? this.modelInstanceCreator(modelConstructor, error.data)
269
+ ? this.modelInstanceCreator(retriedModelConstructor, error.data)
269
270
  : null,
270
271
  });
271
272
  }
272
- catch (err) {
273
- logger.warn('Mutation error handler failed with:', err);
273
+ catch (caughtErr) {
274
+ logger.warn('Mutation error handler failed with:', caughtErr);
274
275
  }
275
276
  finally {
276
277
  // Return empty tuple, dequeues the mutation
278
+ // eslint-disable-next-line no-unsafe-finally
277
279
  return error.data
278
280
  ? [
279
281
  { data: { [opName]: error.data } },
@@ -290,6 +292,7 @@ class MutationProcessor {
290
292
  throw new NonRetryableError(err);
291
293
  }
292
294
  }
295
+ // eslint-disable-next-line no-unmodified-loop-condition
293
296
  } while (tryWith);
294
297
  }, [
295
298
  model,
@@ -297,7 +300,7 @@ class MutationProcessor {
297
300
  data,
298
301
  condition,
299
302
  modelConstructor,
300
- MutationEvent,
303
+ MutationEventCtor,
301
304
  mutationEvent,
302
305
  ], safeJitteredBackoff, onTerminate);
303
306
  }
@@ -356,7 +359,7 @@ class MutationProcessor {
356
359
  }
357
360
  // scalar fields / non-model types
358
361
  if (operation === TransformerMutationType.UPDATE) {
359
- if (!parsedData.hasOwnProperty(name)) {
362
+ if (!Object.prototype.hasOwnProperty.call(parsedData, name)) {
360
363
  // for update mutations - strip out a field if it's unchanged
361
364
  continue;
362
365
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mutation.mjs","sources":["../../../../src/sync/processors/mutation.ts"],"sourcesContent":["import { InternalAPI } from '@aws-amplify/api/internals';\nimport { Category, DataStoreAction, jitteredBackoff, NonRetryableError, retry, BackgroundProcessManager, } from '@aws-amplify/core/internals/utils';\nimport { Observable } from 'rxjs';\nimport { DISCARD, isModelFieldType, isTargetNameAssociation, OpType, ProcessName, } from '../../types';\nimport { extractTargetNamesFromSrc, USER, ID } from '../../util';\nimport { buildGraphQLOperation, createMutationInstanceFromModelOperation, getModelAuthModes, TransformerMutationType, getTokenForCustomAuth, } from '../utils';\nimport { getMutationErrorType } from './errorMaps';\nimport { ConsoleLogger } from '@aws-amplify/core';\nconst MAX_ATTEMPTS = 10;\nconst logger = new ConsoleLogger('DataStore');\nclass MutationProcessor {\n constructor(schema, storage, userClasses, outbox, modelInstanceCreator, MutationEvent, amplifyConfig = {}, authModeStrategy, errorHandler, conflictHandler, amplifyContext) {\n this.schema = schema;\n this.storage = storage;\n this.userClasses = userClasses;\n this.outbox = outbox;\n this.modelInstanceCreator = modelInstanceCreator;\n this.MutationEvent = MutationEvent;\n this.amplifyConfig = amplifyConfig;\n this.authModeStrategy = authModeStrategy;\n this.errorHandler = errorHandler;\n this.conflictHandler = conflictHandler;\n this.amplifyContext = amplifyContext;\n this.typeQuery = new WeakMap();\n this.processing = false;\n this.runningProcesses = new BackgroundProcessManager();\n this.amplifyContext.InternalAPI =\n this.amplifyContext.InternalAPI || InternalAPI;\n this.generateQueries();\n }\n generateQueries() {\n Object.values(this.schema.namespaces).forEach(namespace => {\n Object.values(namespace.models)\n .filter(({ syncable }) => syncable)\n .forEach(model => {\n const [createMutation] = buildGraphQLOperation(namespace, model, 'CREATE');\n const [updateMutation] = buildGraphQLOperation(namespace, model, 'UPDATE');\n const [deleteMutation] = buildGraphQLOperation(namespace, model, 'DELETE');\n this.typeQuery.set(model, [\n createMutation,\n updateMutation,\n deleteMutation,\n ]);\n });\n });\n }\n isReady() {\n return this.observer !== undefined;\n }\n start() {\n this.runningProcesses = new BackgroundProcessManager();\n const observable = new Observable(observer => {\n this.observer = observer;\n try {\n this.resume();\n }\n catch (error) {\n logger.error('mutations processor start error', error);\n throw error;\n }\n return this.runningProcesses.addCleaner(async () => {\n // The observer has unsubscribed and/or `stop()` has been called.\n this.removeObserver();\n this.pause();\n });\n });\n return observable;\n }\n async stop() {\n this.removeObserver();\n await this.runningProcesses.close();\n await this.runningProcesses.open();\n }\n removeObserver() {\n this.observer?.complete?.();\n this.observer = undefined;\n }\n async resume() {\n if (this.runningProcesses.isOpen) {\n await this.runningProcesses.add(async (onTerminate) => {\n if (this.processing ||\n !this.isReady() ||\n !this.runningProcesses.isOpen) {\n return;\n }\n this.processing = true;\n let head;\n const namespaceName = USER;\n // start to drain outbox\n while (this.processing &&\n this.runningProcesses.isOpen &&\n (head = await this.outbox.peek(this.storage)) !== undefined) {\n const { model, operation, data, condition } = head;\n const modelConstructor = this.userClasses[model];\n let result = undefined;\n let opName = undefined;\n let modelDefinition = undefined;\n try {\n const modelAuthModes = await getModelAuthModes({\n authModeStrategy: this.authModeStrategy,\n defaultAuthMode: this.amplifyConfig.aws_appsync_authenticationType,\n modelName: model,\n schema: this.schema,\n });\n const operationAuthModes = modelAuthModes[operation.toUpperCase()];\n let authModeAttempts = 0;\n const authModeRetry = async () => {\n try {\n logger.debug(`Attempting mutation with authMode: ${operationAuthModes[authModeAttempts]}`);\n const response = await this.jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, this.MutationEvent, head, operationAuthModes[authModeAttempts], onTerminate);\n logger.debug(`Mutation sent successfully with authMode: ${operationAuthModes[authModeAttempts]}`);\n return response;\n }\n catch (error) {\n authModeAttempts++;\n if (authModeAttempts >= operationAuthModes.length) {\n logger.debug(`Mutation failed with authMode: ${operationAuthModes[authModeAttempts - 1]}`);\n try {\n await this.errorHandler({\n recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',\n localModel: null,\n message: error.message,\n model: modelConstructor.name,\n operation: opName,\n errorType: getMutationErrorType(error),\n process: ProcessName.sync,\n remoteModel: null,\n cause: error,\n });\n }\n catch (e) {\n logger.error('Mutation error handler failed with:', e);\n }\n throw error;\n }\n logger.debug(`Mutation failed with authMode: ${operationAuthModes[authModeAttempts - 1]}. Retrying with authMode: ${operationAuthModes[authModeAttempts]}`);\n return await authModeRetry();\n }\n };\n [result, opName, modelDefinition] = await authModeRetry();\n }\n catch (error) {\n if (error.message === 'Offline' ||\n error.message === 'RetryMutation') {\n continue;\n }\n }\n if (result === undefined) {\n logger.debug('done retrying');\n await this.storage.runExclusive(async (storage) => {\n await this.outbox.dequeue(storage);\n });\n continue;\n }\n const record = result.data[opName];\n let hasMore = false;\n await this.storage.runExclusive(async (storage) => {\n // using runExclusive to prevent possible race condition\n // when another record gets enqueued between dequeue and peek\n await this.outbox.dequeue(storage, record, operation);\n hasMore = (await this.outbox.peek(storage)) !== undefined;\n });\n this.observer?.next?.({\n operation,\n modelDefinition,\n model: record,\n hasMore,\n });\n }\n // pauses itself\n this.pause();\n }, 'mutation resume loop');\n }\n }\n async jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent, authMode, onTerminate) {\n return await retry(async (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) => {\n const [query, variables, graphQLCondition, opName, modelDefinition] = this.createQueryVariables(namespaceName, model, operation, data, condition);\n const authToken = await getTokenForCustomAuth(authMode, this.amplifyConfig);\n const tryWith = {\n query,\n variables,\n authMode,\n authToken,\n };\n let attempt = 0;\n const opType = this.opTypeFromTransformerOperation(operation);\n const customUserAgentDetails = {\n category: Category.DataStore,\n action: DataStoreAction.GraphQl,\n };\n do {\n try {\n const result = (await this.amplifyContext.InternalAPI.graphql(tryWith, undefined, customUserAgentDetails));\n // Use `as any` because TypeScript doesn't seem to like passing tuples\n // through generic params.\n return [result, opName, modelDefinition];\n }\n catch (err) {\n if (err.errors && err.errors.length > 0) {\n const [error] = err.errors;\n const { originalError: { code = null } = {} } = error;\n if (error.errorType === 'Unauthorized') {\n throw new NonRetryableError('Unauthorized');\n }\n if (error.message === 'Network Error' ||\n code === 'ECONNABORTED' // refers to axios timeout error caused by device's bad network condition\n ) {\n if (!this.processing) {\n throw new NonRetryableError('Offline');\n }\n // TODO: Check errors on different env (react-native or other browsers)\n throw new Error('Network Error');\n }\n if (error.errorType === 'ConflictUnhandled') {\n // TODO: add on ConflictConditionalCheck error query last from server\n attempt++;\n let retryWith;\n if (attempt > MAX_ATTEMPTS) {\n retryWith = DISCARD;\n }\n else {\n try {\n retryWith = await this.conflictHandler({\n modelConstructor,\n localModel: this.modelInstanceCreator(modelConstructor, variables.input),\n remoteModel: this.modelInstanceCreator(modelConstructor, error.data),\n operation: opType,\n attempts: attempt,\n });\n }\n catch (err) {\n logger.warn('conflict trycatch', err);\n continue;\n }\n }\n if (retryWith === DISCARD) {\n // Query latest from server and notify merger\n const [[, opName, query]] = buildGraphQLOperation(this.schema.namespaces[namespaceName], modelDefinition, 'GET');\n const authToken = await getTokenForCustomAuth(authMode, this.amplifyConfig);\n const serverData = await this.amplifyContext.InternalAPI.graphql({\n query,\n variables: { id: variables.input.id },\n authMode,\n authToken,\n }, undefined, customUserAgentDetails);\n // onTerminate cancel graphql()\n return [serverData, opName, modelDefinition];\n }\n const namespace = this.schema.namespaces[namespaceName];\n // convert retry with to tryWith\n const updatedMutation = createMutationInstanceFromModelOperation(namespace.relationships, modelDefinition, opType, modelConstructor, retryWith, graphQLCondition, MutationEvent, this.modelInstanceCreator, mutationEvent.id);\n await this.storage.save(updatedMutation);\n throw new NonRetryableError('RetryMutation');\n }\n else {\n try {\n this.errorHandler({\n recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',\n localModel: variables.input,\n message: error.message,\n operation,\n errorType: getMutationErrorType(error),\n errorInfo: error.errorInfo,\n process: ProcessName.mutate,\n cause: error,\n remoteModel: error.data\n ? this.modelInstanceCreator(modelConstructor, error.data)\n : null,\n });\n }\n catch (err) {\n logger.warn('Mutation error handler failed with:', err);\n }\n finally {\n // Return empty tuple, dequeues the mutation\n return error.data\n ? [\n { data: { [opName]: error.data } },\n opName,\n modelDefinition,\n ]\n : [];\n }\n }\n }\n else {\n // Catch-all for client-side errors that don't come back in the `GraphQLError` format.\n // These errors should not be retried.\n throw new NonRetryableError(err);\n }\n }\n } while (tryWith);\n }, [\n model,\n operation,\n data,\n condition,\n modelConstructor,\n MutationEvent,\n mutationEvent,\n ], safeJitteredBackoff, onTerminate);\n }\n createQueryVariables(namespaceName, model, operation, data, condition) {\n const modelDefinition = this.schema.namespaces[namespaceName].models[model];\n const { primaryKey } = this.schema.namespaces[namespaceName].keys[model];\n const auth = modelDefinition.attributes?.find(a => a.type === 'auth');\n const ownerFields = auth?.properties?.rules\n .map(rule => rule.ownerField)\n .filter(f => f) || ['owner'];\n const queriesTuples = this.typeQuery.get(modelDefinition);\n const [, opName, query] = queriesTuples.find(([transformerMutationType]) => transformerMutationType === operation);\n const { _version, ...parsedData } = JSON.parse(data);\n // include all the fields that comprise a custom PK if one is specified\n const deleteInput = {};\n if (primaryKey && primaryKey.length) {\n for (const pkField of primaryKey) {\n deleteInput[pkField] = parsedData[pkField];\n }\n }\n else {\n deleteInput[ID] = parsedData.id;\n }\n let mutationInput;\n if (operation === TransformerMutationType.DELETE) {\n // For DELETE mutations, only the key(s) are included in the input\n mutationInput = deleteInput;\n }\n else {\n // Otherwise, we construct the mutation input with the following logic\n mutationInput = {};\n const modelFields = Object.values(modelDefinition.fields);\n for (const { name, type, association, isReadOnly } of modelFields) {\n // omit readonly fields. cloud storage doesn't need them and won't take them!\n if (isReadOnly) {\n continue;\n }\n // omit owner fields if it's `null`. cloud storage doesn't allow it.\n if (ownerFields.includes(name) && parsedData[name] === null) {\n continue;\n }\n // model fields should be stripped out from the input\n if (isModelFieldType(type)) {\n // except for belongs to relations - we need to replace them with the correct foreign key(s)\n if (isTargetNameAssociation(association) &&\n association.connectionType === 'BELONGS_TO') {\n const targetNames = extractTargetNamesFromSrc(association);\n if (targetNames) {\n // instead of including the connected model itself, we add its key(s) to the mutation input\n for (const targetName of targetNames) {\n mutationInput[targetName] = parsedData[targetName];\n }\n }\n }\n continue;\n }\n // scalar fields / non-model types\n if (operation === TransformerMutationType.UPDATE) {\n if (!parsedData.hasOwnProperty(name)) {\n // for update mutations - strip out a field if it's unchanged\n continue;\n }\n }\n // all other fields are added to the input object\n mutationInput[name] = parsedData[name];\n }\n }\n // Build mutation variables input object\n const input = {\n ...mutationInput,\n _version,\n };\n const graphQLCondition = JSON.parse(condition);\n const variables = {\n input,\n ...(operation === TransformerMutationType.CREATE\n ? {}\n : {\n condition: Object.keys(graphQLCondition).length > 0\n ? graphQLCondition\n : null,\n }),\n };\n return [query, variables, graphQLCondition, opName, modelDefinition];\n }\n opTypeFromTransformerOperation(operation) {\n switch (operation) {\n case TransformerMutationType.CREATE:\n return OpType.INSERT;\n case TransformerMutationType.DELETE:\n return OpType.DELETE;\n case TransformerMutationType.UPDATE:\n return OpType.UPDATE;\n case TransformerMutationType.GET: // Intentionally blank\n break;\n default:\n throw new Error(`Invalid operation ${operation}`);\n }\n // because it makes TS happy ...\n return undefined;\n }\n pause() {\n this.processing = false;\n }\n}\nconst MAX_RETRY_DELAY_MS = 5 * 60 * 1000;\nconst originalJitteredBackoff = jitteredBackoff(MAX_RETRY_DELAY_MS);\n/**\n * @private\n * Internal use of Amplify only.\n *\n * Wraps the jittered backoff calculation to retry Network Errors indefinitely.\n * Backs off according to original jittered retry logic until the original retry\n * logic hits its max. After this occurs, if the error is a Network Error, we\n * ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until\n * the request succeeds).\n *\n * @param attempt ignored\n * @param _args ignored\n * @param error tested to see if `.message` is 'Network Error'\n * @returns number | false :\n */\nexport const safeJitteredBackoff = (attempt, _args, error) => {\n const attemptResult = originalJitteredBackoff(attempt);\n // If this is the last attempt and it is a network error, we retry indefinitively every 5 minutes\n if (attemptResult === false &&\n (error || {}).message === 'Network Error') {\n return MAX_RETRY_DELAY_MS;\n }\n return attemptResult;\n};\nexport { MutationProcessor };\n"],"names":[],"mappings":";;;;;;;;;AAQA,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;AAC9C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BAA8B,CAAC,SAAS,EAAE;AAC9C,QAAQ,QAAQ,SAAS;AACzB,YAAY,KAAK,uBAAuB,CAAC,MAAM;AAC/C,gBAAgB,OAAO,MAAM,CAAC,MAAM,CAAC;AACrC,YAAY,KAAK,uBAAuB,CAAC,MAAM;AAC/C,gBAAgB,OAAO,MAAM,CAAC,MAAM,CAAC;AACrC,YAAY,KAAK,uBAAuB,CAAC,MAAM;AAC/C,gBAAgB,OAAO,MAAM,CAAC,MAAM,CAAC;AACrC,YAAY,KAAK,uBAAuB,CAAC,GAAG;AAC5C,gBAAgB,MAAM;AACtB,YAAY;AACZ,gBAAgB,MAAM,IAAI,KAAK,CAAC,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AAClE,SAAS;AACT;AACA,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,IAAI,KAAK,GAAG;AACZ,QAAQ,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;AAChC,KAAK;AACL,CAAC;AACD,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,MAAM,uBAAuB,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,mBAAmB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK;AAC9D,IAAI,MAAM,aAAa,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC3D;AACA,IAAI,IAAI,aAAa,KAAK,KAAK;AAC/B,QAAQ,CAAC,KAAK,IAAI,EAAE,EAAE,OAAO,KAAK,eAAe,EAAE;AACnD,QAAQ,OAAO,kBAAkB,CAAC;AAClC,KAAK;AACL,IAAI,OAAO,aAAa,CAAC;AACzB;;;;"}
1
+ {"version":3,"file":"mutation.mjs","sources":["../../../../src/sync/processors/mutation.ts"],"sourcesContent":["import { InternalAPI } from '@aws-amplify/api/internals';\nimport { BackgroundProcessManager, Category, DataStoreAction, NonRetryableError, jitteredBackoff, retry, } from '@aws-amplify/core/internals/utils';\nimport { Observable } from 'rxjs';\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { DISCARD, OpType, ProcessName, isModelFieldType, isTargetNameAssociation, } from '../../types';\nimport { ID, USER, extractTargetNamesFromSrc } from '../../util';\nimport { TransformerMutationType, buildGraphQLOperation, createMutationInstanceFromModelOperation, getModelAuthModes, getTokenForCustomAuth, } from '../utils';\nimport { getMutationErrorType } from './errorMaps';\nconst MAX_ATTEMPTS = 10;\nconst logger = new ConsoleLogger('DataStore');\nclass MutationProcessor {\n constructor(schema, storage, userClasses, outbox, modelInstanceCreator, _MutationEvent, amplifyConfig = {}, authModeStrategy, errorHandler, conflictHandler, amplifyContext) {\n this.schema = schema;\n this.storage = storage;\n this.userClasses = userClasses;\n this.outbox = outbox;\n this.modelInstanceCreator = modelInstanceCreator;\n this._MutationEvent = _MutationEvent;\n this.amplifyConfig = amplifyConfig;\n this.authModeStrategy = authModeStrategy;\n this.errorHandler = errorHandler;\n this.conflictHandler = conflictHandler;\n this.amplifyContext = amplifyContext;\n this.typeQuery = new WeakMap();\n this.processing = false;\n this.runningProcesses = new BackgroundProcessManager();\n this.amplifyContext.InternalAPI =\n this.amplifyContext.InternalAPI || InternalAPI;\n this.generateQueries();\n }\n generateQueries() {\n Object.values(this.schema.namespaces).forEach(namespace => {\n Object.values(namespace.models)\n .filter(({ syncable }) => syncable)\n .forEach(model => {\n const [createMutation] = buildGraphQLOperation(namespace, model, 'CREATE');\n const [updateMutation] = buildGraphQLOperation(namespace, model, 'UPDATE');\n const [deleteMutation] = buildGraphQLOperation(namespace, model, 'DELETE');\n this.typeQuery.set(model, [\n createMutation,\n updateMutation,\n deleteMutation,\n ]);\n });\n });\n }\n isReady() {\n return this.observer !== undefined;\n }\n start() {\n this.runningProcesses = new BackgroundProcessManager();\n const observable = new Observable(observer => {\n this.observer = observer;\n try {\n this.resume();\n }\n catch (error) {\n logger.error('mutations processor start error', error);\n throw error;\n }\n return this.runningProcesses.addCleaner(async () => {\n // The observer has unsubscribed and/or `stop()` has been called.\n this.removeObserver();\n this.pause();\n });\n });\n return observable;\n }\n async stop() {\n this.removeObserver();\n await this.runningProcesses.close();\n await this.runningProcesses.open();\n }\n removeObserver() {\n this.observer?.complete?.();\n this.observer = undefined;\n }\n async resume() {\n if (this.runningProcesses.isOpen) {\n await this.runningProcesses.add(async (onTerminate) => {\n if (this.processing ||\n !this.isReady() ||\n !this.runningProcesses.isOpen) {\n return;\n }\n this.processing = true;\n let head;\n const namespaceName = USER;\n // start to drain outbox\n while (this.processing &&\n this.runningProcesses.isOpen &&\n (head = await this.outbox.peek(this.storage)) !== undefined) {\n const { model, operation, data, condition } = head;\n const modelConstructor = this.userClasses[model];\n let result = undefined;\n let opName = undefined;\n let modelDefinition = undefined;\n try {\n const modelAuthModes = await getModelAuthModes({\n authModeStrategy: this.authModeStrategy,\n defaultAuthMode: this.amplifyConfig.aws_appsync_authenticationType,\n modelName: model,\n schema: this.schema,\n });\n const operationAuthModes = modelAuthModes[operation.toUpperCase()];\n let authModeAttempts = 0;\n const authModeRetry = async () => {\n try {\n logger.debug(`Attempting mutation with authMode: ${operationAuthModes[authModeAttempts]}`);\n const response = await this.jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, this._MutationEvent, head, operationAuthModes[authModeAttempts], onTerminate);\n logger.debug(`Mutation sent successfully with authMode: ${operationAuthModes[authModeAttempts]}`);\n return response;\n }\n catch (error) {\n authModeAttempts++;\n if (authModeAttempts >= operationAuthModes.length) {\n logger.debug(`Mutation failed with authMode: ${operationAuthModes[authModeAttempts - 1]}`);\n try {\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n await this.errorHandler({\n recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',\n localModel: null,\n message: error.message,\n model: modelConstructor.name,\n operation: opName,\n errorType: getMutationErrorType(error),\n process: ProcessName.sync,\n remoteModel: null,\n cause: error,\n });\n }\n catch (e) {\n logger.error('Mutation error handler failed with:', e);\n }\n throw error;\n }\n logger.debug(`Mutation failed with authMode: ${operationAuthModes[authModeAttempts - 1]}. Retrying with authMode: ${operationAuthModes[authModeAttempts]}`);\n return authModeRetry();\n }\n };\n [result, opName, modelDefinition] = await authModeRetry();\n }\n catch (error) {\n if (error.message === 'Offline' ||\n error.message === 'RetryMutation') {\n continue;\n }\n }\n if (result === undefined) {\n logger.debug('done retrying');\n await this.storage.runExclusive(async (storage) => {\n await this.outbox.dequeue(storage);\n });\n continue;\n }\n const record = result.data[opName];\n let hasMore = false;\n await this.storage.runExclusive(async (storage) => {\n // using runExclusive to prevent possible race condition\n // when another record gets enqueued between dequeue and peek\n await this.outbox.dequeue(storage, record, operation);\n hasMore = (await this.outbox.peek(storage)) !== undefined;\n });\n this.observer?.next?.({\n operation,\n modelDefinition,\n model: record,\n hasMore,\n });\n }\n // pauses itself\n this.pause();\n }, 'mutation resume loop');\n }\n }\n async jitteredRetry(namespaceName, model, operation, data, condition, modelConstructor, MutationEventCtor, mutationEvent, authMode, onTerminate) {\n return retry(async (retriedModel, retriedOperation, retriedData, retriedCondition, retriedModelConstructor, retiredMutationEventCtor, retiredMutationEvent) => {\n const [query, variables, graphQLCondition, opName, modelDefinition] = this.createQueryVariables(namespaceName, retriedModel, retriedOperation, retriedData, retriedCondition);\n const authToken = await getTokenForCustomAuth(authMode, this.amplifyConfig);\n const tryWith = {\n query,\n variables,\n authMode,\n authToken,\n };\n let attempt = 0;\n const opType = this.opTypeFromTransformerOperation(retriedOperation);\n const customUserAgentDetails = {\n category: Category.DataStore,\n action: DataStoreAction.GraphQl,\n };\n do {\n try {\n const result = (await this.amplifyContext.InternalAPI.graphql(tryWith, undefined, customUserAgentDetails));\n // Use `as any` because TypeScript doesn't seem to like passing tuples\n // through generic params.\n return [result, opName, modelDefinition];\n }\n catch (err) {\n if (err.errors && err.errors.length > 0) {\n const [error] = err.errors;\n const { originalError: { code = null } = {} } = error;\n if (error.errorType === 'Unauthorized') {\n throw new NonRetryableError('Unauthorized');\n }\n if (error.message === 'Network Error' ||\n code === 'ECONNABORTED' // refers to axios timeout error caused by device's bad network condition\n ) {\n if (!this.processing) {\n throw new NonRetryableError('Offline');\n }\n // TODO: Check errors on different env (react-native or other browsers)\n throw new Error('Network Error');\n }\n if (error.errorType === 'ConflictUnhandled') {\n // TODO: add on ConflictConditionalCheck error query last from server\n attempt++;\n let retryWith;\n if (attempt > MAX_ATTEMPTS) {\n retryWith = DISCARD;\n }\n else {\n try {\n retryWith = await this.conflictHandler({\n modelConstructor: retriedModelConstructor,\n localModel: this.modelInstanceCreator(retriedModelConstructor, variables.input),\n remoteModel: this.modelInstanceCreator(retriedModelConstructor, error.data),\n operation: opType,\n attempts: attempt,\n });\n }\n catch (caughtErr) {\n logger.warn('conflict trycatch', caughtErr);\n continue;\n }\n }\n if (retryWith === DISCARD) {\n // Query latest from server and notify merger\n const [[, builtOpName, builtQuery]] = buildGraphQLOperation(this.schema.namespaces[namespaceName], modelDefinition, 'GET');\n const newAuthToken = await getTokenForCustomAuth(authMode, this.amplifyConfig);\n const serverData = (await this.amplifyContext.InternalAPI.graphql({\n query: builtQuery,\n variables: { id: variables.input.id },\n authMode,\n authToken: newAuthToken,\n }, undefined, customUserAgentDetails));\n // onTerminate cancel graphql()\n return [serverData, builtOpName, modelDefinition];\n }\n const namespace = this.schema.namespaces[namespaceName];\n // convert retry with to tryWith\n const updatedMutation = createMutationInstanceFromModelOperation(namespace.relationships, modelDefinition, opType, retriedModelConstructor, retryWith, graphQLCondition, retiredMutationEventCtor, this.modelInstanceCreator, retiredMutationEvent.id);\n await this.storage.save(updatedMutation);\n throw new NonRetryableError('RetryMutation');\n }\n else {\n try {\n this.errorHandler({\n recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',\n localModel: variables.input,\n message: error.message,\n operation: retriedOperation,\n errorType: getMutationErrorType(error),\n errorInfo: error.errorInfo,\n process: ProcessName.mutate,\n cause: error,\n remoteModel: error.data\n ? this.modelInstanceCreator(retriedModelConstructor, error.data)\n : null,\n });\n }\n catch (caughtErr) {\n logger.warn('Mutation error handler failed with:', caughtErr);\n }\n finally {\n // Return empty tuple, dequeues the mutation\n // eslint-disable-next-line no-unsafe-finally\n return error.data\n ? [\n { data: { [opName]: error.data } },\n opName,\n modelDefinition,\n ]\n : [];\n }\n }\n }\n else {\n // Catch-all for client-side errors that don't come back in the `GraphQLError` format.\n // These errors should not be retried.\n throw new NonRetryableError(err);\n }\n }\n // eslint-disable-next-line no-unmodified-loop-condition\n } while (tryWith);\n }, [\n model,\n operation,\n data,\n condition,\n modelConstructor,\n MutationEventCtor,\n mutationEvent,\n ], safeJitteredBackoff, onTerminate);\n }\n createQueryVariables(namespaceName, model, operation, data, condition) {\n const modelDefinition = this.schema.namespaces[namespaceName].models[model];\n const { primaryKey } = this.schema.namespaces[namespaceName].keys[model];\n const auth = modelDefinition.attributes?.find(a => a.type === 'auth');\n const ownerFields = auth?.properties?.rules\n .map(rule => rule.ownerField)\n .filter(f => f) || ['owner'];\n const queriesTuples = this.typeQuery.get(modelDefinition);\n const [, opName, query] = queriesTuples.find(([transformerMutationType]) => transformerMutationType === operation);\n const { _version, ...parsedData } = JSON.parse(data);\n // include all the fields that comprise a custom PK if one is specified\n const deleteInput = {};\n if (primaryKey && primaryKey.length) {\n for (const pkField of primaryKey) {\n deleteInput[pkField] = parsedData[pkField];\n }\n }\n else {\n deleteInput[ID] = parsedData.id;\n }\n let mutationInput;\n if (operation === TransformerMutationType.DELETE) {\n // For DELETE mutations, only the key(s) are included in the input\n mutationInput = deleteInput;\n }\n else {\n // Otherwise, we construct the mutation input with the following logic\n mutationInput = {};\n const modelFields = Object.values(modelDefinition.fields);\n for (const { name, type, association, isReadOnly } of modelFields) {\n // omit readonly fields. cloud storage doesn't need them and won't take them!\n if (isReadOnly) {\n continue;\n }\n // omit owner fields if it's `null`. cloud storage doesn't allow it.\n if (ownerFields.includes(name) && parsedData[name] === null) {\n continue;\n }\n // model fields should be stripped out from the input\n if (isModelFieldType(type)) {\n // except for belongs to relations - we need to replace them with the correct foreign key(s)\n if (isTargetNameAssociation(association) &&\n association.connectionType === 'BELONGS_TO') {\n const targetNames = extractTargetNamesFromSrc(association);\n if (targetNames) {\n // instead of including the connected model itself, we add its key(s) to the mutation input\n for (const targetName of targetNames) {\n mutationInput[targetName] = parsedData[targetName];\n }\n }\n }\n continue;\n }\n // scalar fields / non-model types\n if (operation === TransformerMutationType.UPDATE) {\n if (!Object.prototype.hasOwnProperty.call(parsedData, name)) {\n // for update mutations - strip out a field if it's unchanged\n continue;\n }\n }\n // all other fields are added to the input object\n mutationInput[name] = parsedData[name];\n }\n }\n // Build mutation variables input object\n const input = {\n ...mutationInput,\n _version,\n };\n const graphQLCondition = JSON.parse(condition);\n const variables = {\n input,\n ...(operation === TransformerMutationType.CREATE\n ? {}\n : {\n condition: Object.keys(graphQLCondition).length > 0\n ? graphQLCondition\n : null,\n }),\n };\n return [query, variables, graphQLCondition, opName, modelDefinition];\n }\n opTypeFromTransformerOperation(operation) {\n switch (operation) {\n case TransformerMutationType.CREATE:\n return OpType.INSERT;\n case TransformerMutationType.DELETE:\n return OpType.DELETE;\n case TransformerMutationType.UPDATE:\n return OpType.UPDATE;\n case TransformerMutationType.GET: // Intentionally blank\n break;\n default:\n throw new Error(`Invalid operation ${operation}`);\n }\n // because it makes TS happy ...\n return undefined;\n }\n pause() {\n this.processing = false;\n }\n}\nconst MAX_RETRY_DELAY_MS = 5 * 60 * 1000;\nconst originalJitteredBackoff = jitteredBackoff(MAX_RETRY_DELAY_MS);\n/**\n * @private\n * Internal use of Amplify only.\n *\n * Wraps the jittered backoff calculation to retry Network Errors indefinitely.\n * Backs off according to original jittered retry logic until the original retry\n * logic hits its max. After this occurs, if the error is a Network Error, we\n * ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until\n * the request succeeds).\n *\n * @param attempt ignored\n * @param _args ignored\n * @param error tested to see if `.message` is 'Network Error'\n * @returns number | false :\n */\nexport const safeJitteredBackoff = (attempt, _args, error) => {\n const attemptResult = originalJitteredBackoff(attempt);\n // If this is the last attempt and it is a network error, we retry indefinitively every 5 minutes\n if (attemptResult === false &&\n (error || {}).message === 'Network Error') {\n return MAX_RETRY_DELAY_MS;\n }\n return attemptResult;\n};\nexport { MutationProcessor };\n"],"names":[],"mappings":";;;;;;;;;AAQA,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;AAC9C,MAAM,iBAAiB,CAAC;AACxB,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,GAAG,EAAE,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE;AACjL,QAAQ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AAC7B,QAAQ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAC/B,QAAQ,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;AACvC,QAAQ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AAC7B,QAAQ,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;AAC7C,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AAC3C,QAAQ,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AACjD,QAAQ,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACzC,QAAQ,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;AAC/C,QAAQ,IAAI,CAAC,c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,CAAC;AACD,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,MAAM,uBAAuB,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,mBAAmB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK;AAC9D,IAAI,MAAM,aAAa,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC3D;AACA,IAAI,IAAI,aAAa,KAAK,KAAK;AAC/B,QAAQ,CAAC,KAAK,IAAI,EAAE,EAAE,OAAO,KAAK,eAAe,EAAE;AACnD,QAAQ,OAAO,kBAAkB,CAAC;AAClC,KAAK;AACL,IAAI,OAAO,aAAa,CAAC;AACzB;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { InternalSchema, PersistentModel, SchemaModel, ModelPredicate, AuthModeStrategy, ErrorHandler, AmplifyContext } from '../../types';
2
+ import { AmplifyContext, AuthModeStrategy, ErrorHandler, InternalSchema, ModelPredicate, PersistentModel, SchemaModel } from '../../types';
3
3
  import { TransformerMutationType } from '../utils';
4
4
  export declare enum CONTROL_MSG {
5
5
  CONNECTED = "CONNECTED"
@@ -2,12 +2,12 @@ import { InternalAPI } from '@aws-amplify/api/internals';
2
2
  import { ConsoleLogger, fetchAuthSession, Hub } from '@aws-amplify/core';
3
3
  import { BackgroundProcessManager, Category, DataStoreAction } from '@aws-amplify/core/internals/utils';
4
4
  import { Observable } from 'rxjs';
5
+ import { CONTROL_MSG as CONTROL_MSG$1 } from '@aws-amplify/api-graphql';
5
6
  import { ProcessName } from '../../types.mjs';
6
7
  import { buildSubscriptionGraphQLOperation, getAuthorizationRules, getUserGroupsFromToken, getModelAuthModes, TransformerMutationType, RTFError, generateRTFRemediation, getTokenForCustomAuth, predicateToGraphQLFilter } from '../utils.mjs';
7
8
  import { ModelPredicateCreator } from '../../predicates/index.mjs';
8
9
  import { validatePredicate } from '../../util.mjs';
9
10
  import { getSubscriptionErrorType } from './errorMaps.mjs';
10
- import { CONTROL_MSG as CONTROL_MSG$1 } from '@aws-amplify/api-graphql';
11
11
 
12
12
  const logger = new ConsoleLogger('DataStore');
13
13
  var CONTROL_MSG;
@@ -55,6 +55,7 @@ class SubscriptionProcessor {
55
55
  const groupAuthRules = rules.filter(rule => rule.authStrategy === 'groups' &&
56
56
  ['userPools', 'oidc'].includes(rule.provider));
57
57
  const validGroup = (authMode === 'oidc' || authMode === 'userPool') &&
58
+ // eslint-disable-next-line array-callback-return
58
59
  groupAuthRules.find(groupAuthRule => {
59
60
  // validate token against groupClaim
60
61
  if (oidcTokenPayload) {
@@ -183,7 +184,7 @@ class SubscriptionProcessor {
183
184
  action: DataStoreAction.Subscribe,
184
185
  };
185
186
  if (addFilter && predicatesGroup) {
186
- variables['filter'] =
187
+ variables.filter =
187
188
  predicateToGraphQLFilter(predicatesGroup);
188
189
  }
189
190
  if (isOwner) {
@@ -211,14 +212,13 @@ class SubscriptionProcessor {
211
212
  this.drainBuffer();
212
213
  return;
213
214
  }
214
- const predicatesGroup = ModelPredicateCreator.getPredicates(this.syncPredicates.get(modelDefinition), false);
215
- // @ts-ignore
215
+ const resolvedPredicatesGroup = ModelPredicateCreator.getPredicates(this.syncPredicates.get(modelDefinition), false);
216
216
  const { [opName]: record } = data;
217
217
  // checking incoming subscription against syncPredicate.
218
218
  // once AppSync implements filters on subscriptions, we'll be
219
219
  // able to set these when establishing the subscription instead.
220
220
  // Until then, we'll need to filter inbound
221
- if (this.passesPredicateValidation(record, predicatesGroup)) {
221
+ if (this.passesPredicateValidation(record, resolvedPredicatesGroup)) {
222
222
  this.pushToBuffer(transformerMutationType, modelDefinition, record);
223
223
  }
224
224
  this.drainBuffer();
@@ -259,6 +259,7 @@ class SubscriptionProcessor {
259
259
  }
260
260
  logger.warn('subscriptionError', message);
261
261
  try {
262
+ // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
262
263
  await this.errorHandler({
263
264
  recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',
264
265
  localModel: null,
@@ -287,9 +288,9 @@ class SubscriptionProcessor {
287
288
  promises.push((async () => {
288
289
  let boundFunction;
289
290
  let removeBoundFunctionListener;
290
- await new Promise(res => {
291
- subscriptionReadyCallback = res;
292
- boundFunction = this.hubQueryCompletionListener.bind(this, res);
291
+ await new Promise(resolve => {
292
+ subscriptionReadyCallback = resolve;
293
+ boundFunction = this.hubQueryCompletionListener.bind(this, resolve);
293
294
  removeBoundFunctionListener = Hub.listen('api', boundFunction);
294
295
  });
295
296
  removeBoundFunctionListener();
@@ -305,9 +306,15 @@ class SubscriptionProcessor {
305
306
  }, 'subscription processor new subscriber');
306
307
  return this.runningProcesses.addCleaner(async () => {
307
308
  Object.keys(subscriptions).forEach(modelName => {
308
- subscriptions[modelName][TransformerMutationType.CREATE].forEach(subscription => subscription.unsubscribe());
309
- subscriptions[modelName][TransformerMutationType.UPDATE].forEach(subscription => subscription.unsubscribe());
310
- subscriptions[modelName][TransformerMutationType.DELETE].forEach(subscription => subscription.unsubscribe());
309
+ subscriptions[modelName][TransformerMutationType.CREATE].forEach(subscription => {
310
+ subscription.unsubscribe();
311
+ });
312
+ subscriptions[modelName][TransformerMutationType.UPDATE].forEach(subscription => {
313
+ subscription.unsubscribe();
314
+ });
315
+ subscriptions[modelName][TransformerMutationType.DELETE].forEach(subscription => {
316
+ subscription.unsubscribe();
317
+ });
311
318
  });
312
319
  });
313
320
  });
@@ -336,7 +343,9 @@ class SubscriptionProcessor {
336
343
  }
337
344
  drainBuffer() {
338
345
  if (this.dataObserver) {
339
- this.buffer.forEach(data => this.dataObserver.next(data));
346
+ this.buffer.forEach(data => {
347
+ this.dataObserver.next(data);
348
+ });
340
349
  this.buffer = [];
341
350
  }
342
351
  }