@aws-amplify/datastore 3.7.3 → 3.7.4-custom-pk.86

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 (137) hide show
  1. package/CHANGELOG.md +144 -17
  2. package/README.md +154 -0
  3. package/dist/aws-amplify-datastore.js +3740 -1599
  4. package/dist/aws-amplify-datastore.js.map +1 -1
  5. package/dist/aws-amplify-datastore.min.js +25 -95
  6. package/dist/aws-amplify-datastore.min.js.map +1 -1
  7. package/lib/authModeStrategies/multiAuthStrategy.d.ts +2 -2
  8. package/lib/authModeStrategies/multiAuthStrategy.js +32 -26
  9. package/lib/authModeStrategies/multiAuthStrategy.js.map +1 -1
  10. package/lib/datastore/datastore.d.ts +17 -16
  11. package/lib/datastore/datastore.js +291 -83
  12. package/lib/datastore/datastore.js.map +1 -1
  13. package/lib/index.d.ts +3 -19
  14. package/lib/predicates/index.d.ts +3 -2
  15. package/lib/predicates/index.js +12 -2
  16. package/lib/predicates/index.js.map +1 -1
  17. package/lib/storage/adapter/AsyncStorageAdapter.d.ts +6 -2
  18. package/lib/storage/adapter/AsyncStorageAdapter.js +361 -193
  19. package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
  20. package/lib/storage/adapter/AsyncStorageDatabase.d.ts +4 -4
  21. package/lib/storage/adapter/AsyncStorageDatabase.js +59 -28
  22. package/lib/storage/adapter/AsyncStorageDatabase.js.map +1 -1
  23. package/lib/storage/adapter/InMemoryStore.js +2 -2
  24. package/lib/storage/adapter/InMemoryStore.js.map +1 -1
  25. package/lib/storage/adapter/IndexedDBAdapter.d.ts +7 -2
  26. package/lib/storage/adapter/IndexedDBAdapter.js +454 -252
  27. package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
  28. package/lib/storage/adapter/index.d.ts +1 -1
  29. package/lib/storage/storage.d.ts +3 -3
  30. package/lib/storage/storage.js +106 -28
  31. package/lib/storage/storage.js.map +1 -1
  32. package/lib/sync/index.d.ts +23 -7
  33. package/lib/sync/index.js +18 -17
  34. package/lib/sync/index.js.map +1 -1
  35. package/lib/sync/merger.d.ts +3 -3
  36. package/lib/sync/merger.js +8 -6
  37. package/lib/sync/merger.js.map +1 -1
  38. package/lib/sync/outbox.d.ts +2 -2
  39. package/lib/sync/outbox.js +12 -9
  40. package/lib/sync/outbox.js.map +1 -1
  41. package/lib/sync/processors/errorMaps.d.ts +17 -0
  42. package/lib/sync/processors/errorMaps.js +125 -0
  43. package/lib/sync/processors/errorMaps.js.map +1 -0
  44. package/lib/sync/processors/mutation.d.ts +22 -4
  45. package/lib/sync/processors/mutation.js +119 -51
  46. package/lib/sync/processors/mutation.js.map +1 -1
  47. package/lib/sync/processors/subscription.d.ts +4 -2
  48. package/lib/sync/processors/subscription.js +76 -41
  49. package/lib/sync/processors/subscription.js.map +1 -1
  50. package/lib/sync/processors/sync.d.ts +4 -2
  51. package/lib/sync/processors/sync.js +62 -27
  52. package/lib/sync/processors/sync.js.map +1 -1
  53. package/lib/sync/utils.d.ts +3 -2
  54. package/lib/sync/utils.js +58 -7
  55. package/lib/sync/utils.js.map +1 -1
  56. package/lib/types.d.ts +90 -34
  57. package/lib/types.js +31 -2
  58. package/lib/types.js.map +1 -1
  59. package/lib/util.d.ts +48 -33
  60. package/lib/util.js +219 -57
  61. package/lib/util.js.map +1 -1
  62. package/lib-esm/authModeStrategies/multiAuthStrategy.d.ts +2 -2
  63. package/lib-esm/authModeStrategies/multiAuthStrategy.js +32 -26
  64. package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +1 -1
  65. package/lib-esm/datastore/datastore.d.ts +17 -16
  66. package/lib-esm/datastore/datastore.js +293 -85
  67. package/lib-esm/datastore/datastore.js.map +1 -1
  68. package/lib-esm/index.d.ts +3 -19
  69. package/lib-esm/predicates/index.d.ts +3 -2
  70. package/lib-esm/predicates/index.js +13 -3
  71. package/lib-esm/predicates/index.js.map +1 -1
  72. package/lib-esm/storage/adapter/AsyncStorageAdapter.d.ts +6 -2
  73. package/lib-esm/storage/adapter/AsyncStorageAdapter.js +361 -193
  74. package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
  75. package/lib-esm/storage/adapter/AsyncStorageDatabase.d.ts +4 -4
  76. package/lib-esm/storage/adapter/AsyncStorageDatabase.js +60 -29
  77. package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +1 -1
  78. package/lib-esm/storage/adapter/InMemoryStore.js +2 -2
  79. package/lib-esm/storage/adapter/InMemoryStore.js.map +1 -1
  80. package/lib-esm/storage/adapter/IndexedDBAdapter.d.ts +7 -2
  81. package/lib-esm/storage/adapter/IndexedDBAdapter.js +454 -252
  82. package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
  83. package/lib-esm/storage/adapter/index.d.ts +1 -1
  84. package/lib-esm/storage/storage.d.ts +3 -3
  85. package/lib-esm/storage/storage.js +106 -28
  86. package/lib-esm/storage/storage.js.map +1 -1
  87. package/lib-esm/sync/index.d.ts +23 -7
  88. package/lib-esm/sync/index.js +20 -19
  89. package/lib-esm/sync/index.js.map +1 -1
  90. package/lib-esm/sync/merger.d.ts +3 -3
  91. package/lib-esm/sync/merger.js +8 -6
  92. package/lib-esm/sync/merger.js.map +1 -1
  93. package/lib-esm/sync/outbox.d.ts +2 -2
  94. package/lib-esm/sync/outbox.js +13 -10
  95. package/lib-esm/sync/outbox.js.map +1 -1
  96. package/lib-esm/sync/processors/errorMaps.d.ts +17 -0
  97. package/lib-esm/sync/processors/errorMaps.js +119 -0
  98. package/lib-esm/sync/processors/errorMaps.js.map +1 -0
  99. package/lib-esm/sync/processors/mutation.d.ts +22 -4
  100. package/lib-esm/sync/processors/mutation.js +122 -54
  101. package/lib-esm/sync/processors/mutation.js.map +1 -1
  102. package/lib-esm/sync/processors/subscription.d.ts +4 -2
  103. package/lib-esm/sync/processors/subscription.js +77 -42
  104. package/lib-esm/sync/processors/subscription.js.map +1 -1
  105. package/lib-esm/sync/processors/sync.d.ts +4 -2
  106. package/lib-esm/sync/processors/sync.js +62 -27
  107. package/lib-esm/sync/processors/sync.js.map +1 -1
  108. package/lib-esm/sync/utils.d.ts +3 -2
  109. package/lib-esm/sync/utils.js +58 -8
  110. package/lib-esm/sync/utils.js.map +1 -1
  111. package/lib-esm/types.d.ts +90 -34
  112. package/lib-esm/types.js +29 -3
  113. package/lib-esm/types.js.map +1 -1
  114. package/lib-esm/util.d.ts +48 -33
  115. package/lib-esm/util.js +207 -54
  116. package/lib-esm/util.js.map +1 -1
  117. package/package.json +10 -9
  118. package/src/authModeStrategies/multiAuthStrategy.ts +24 -21
  119. package/src/datastore/datastore.ts +448 -148
  120. package/src/predicates/index.ts +32 -10
  121. package/src/storage/adapter/AsyncStorageAdapter.ts +305 -78
  122. package/src/storage/adapter/AsyncStorageDatabase.ts +65 -26
  123. package/src/storage/adapter/InMemoryStore.ts +2 -2
  124. package/src/storage/adapter/IndexedDBAdapter.ts +344 -101
  125. package/src/storage/adapter/index.ts +1 -1
  126. package/src/storage/storage.ts +85 -24
  127. package/src/sync/index.ts +74 -58
  128. package/src/sync/merger.ts +16 -4
  129. package/src/sync/outbox.ts +22 -8
  130. package/src/sync/processors/errorMaps.ts +93 -0
  131. package/src/sync/processors/mutation.ts +143 -84
  132. package/src/sync/processors/subscription.ts +67 -36
  133. package/src/sync/processors/sync.ts +37 -12
  134. package/src/sync/utils.ts +67 -16
  135. package/src/types.ts +252 -50
  136. package/src/util.ts +256 -42
  137. package/ssr/package.json +1 -1
@@ -2,7 +2,7 @@ import Observable from 'zen-observable-ts';
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 } from '../../types';
5
+ import { AuthModeStrategy, ConflictHandler, ErrorHandler, InternalSchema, PersistentModel, PersistentModelConstructor, SchemaModel, TypeConstructorMap, AmplifyContext } from '../../types';
6
6
  import { MutationEventOutbox } from '../outbox';
7
7
  import { TransformerMutationType } from '../utils';
8
8
  declare type MutationProcessorEvent = {
@@ -20,12 +20,13 @@ declare class MutationProcessor {
20
20
  private readonly MutationEvent;
21
21
  private readonly amplifyConfig;
22
22
  private readonly authModeStrategy;
23
- private readonly conflictHandler?;
24
- private readonly errorHandler?;
23
+ private readonly errorHandler;
24
+ private readonly conflictHandler;
25
+ private readonly amplifyContext;
25
26
  private observer;
26
27
  private readonly typeQuery;
27
28
  private processing;
28
- constructor(schema: InternalSchema, storage: Storage, userClasses: TypeConstructorMap, outbox: MutationEventOutbox, modelInstanceCreator: ModelInstanceCreator, MutationEvent: PersistentModelConstructor<MutationEvent>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, conflictHandler?: ConflictHandler, errorHandler?: ErrorHandler);
29
+ 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);
29
30
  private generateQueries;
30
31
  private isReady;
31
32
  start(): Observable<MutationProcessorEvent>;
@@ -35,4 +36,21 @@ declare class MutationProcessor {
35
36
  private opTypeFromTransformerOperation;
36
37
  pause(): void;
37
38
  }
39
+ declare const originalJitteredBackoff: import("@aws-amplify/core/lib-esm/types").DelayFunction;
40
+ /**
41
+ * @private
42
+ * Internal use of Amplify only.
43
+ *
44
+ * Wraps the jittered backoff calculation to retry Network Errors indefinitely.
45
+ * Backs off according to original jittered retry logic until the original retry
46
+ * logic hits its max. After this occurs, if the error is a Network Error, we
47
+ * ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until
48
+ * the request succeeds).
49
+ *
50
+ * @param attempt ignored
51
+ * @param _args ignored
52
+ * @param error tested to see if `.message` is 'Network Error'
53
+ * @returns number | false :
54
+ */
55
+ export declare const safeJitteredBackoff: typeof originalJitteredBackoff;
38
56
  export { MutationProcessor };
@@ -84,15 +84,16 @@ var __values = (this && this.__values) || function(o) {
84
84
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
85
85
  };
86
86
  import API from '@aws-amplify/api';
87
- import { ConsoleLogger as Logger, jitteredExponentialRetry, NonRetryableError, } from '@aws-amplify/core';
87
+ import { ConsoleLogger as Logger, jitteredBackoff, NonRetryableError, retry, } from '@aws-amplify/core';
88
88
  import Observable from 'zen-observable-ts';
89
- import { DISCARD, isModelFieldType, isTargetNameAssociation, OpType, } from '../../types';
90
- import { exhaustiveCheck, USER } from '../../util';
89
+ import { DISCARD, isModelFieldType, isTargetNameAssociation, OpType, ProcessName, } from '../../types';
90
+ import { exhaustiveCheck, extractTargetNamesFromSrc, USER, USER_AGENT_SUFFIX_DATASTORE, } from '../../util';
91
91
  import { buildGraphQLOperation, createMutationInstanceFromModelOperation, getModelAuthModes, TransformerMutationType, getTokenForCustomAuth, } from '../utils';
92
+ import { getMutationErrorType } from './errorMaps';
92
93
  var MAX_ATTEMPTS = 10;
93
94
  var logger = new Logger('DataStore');
94
95
  var MutationProcessor = /** @class */ (function () {
95
- function MutationProcessor(schema, storage, userClasses, outbox, modelInstanceCreator, MutationEvent, amplifyConfig, authModeStrategy, conflictHandler, errorHandler) {
96
+ function MutationProcessor(schema, storage, userClasses, outbox, modelInstanceCreator, MutationEvent, amplifyConfig, authModeStrategy, errorHandler, conflictHandler, amplifyContext) {
96
97
  if (amplifyConfig === void 0) { amplifyConfig = {}; }
97
98
  this.schema = schema;
98
99
  this.storage = storage;
@@ -102,10 +103,12 @@ var MutationProcessor = /** @class */ (function () {
102
103
  this.MutationEvent = MutationEvent;
103
104
  this.amplifyConfig = amplifyConfig;
104
105
  this.authModeStrategy = authModeStrategy;
105
- this.conflictHandler = conflictHandler;
106
106
  this.errorHandler = errorHandler;
107
+ this.conflictHandler = conflictHandler;
108
+ this.amplifyContext = amplifyContext;
107
109
  this.typeQuery = new WeakMap();
108
110
  this.processing = false;
111
+ this.amplifyContext.API = this.amplifyContext.API || API;
109
112
  this.generateQueries();
110
113
  }
111
114
  MutationProcessor.prototype.generateQueries = function () {
@@ -291,7 +294,7 @@ var MutationProcessor = /** @class */ (function () {
291
294
  var _this = this;
292
295
  return __generator(this, function (_a) {
293
296
  switch (_a.label) {
294
- case 0: return [4 /*yield*/, jitteredExponentialRetry(function (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) { return __awaiter(_this, void 0, void 0, function () {
297
+ case 0: return [4 /*yield*/, retry(function (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) { return __awaiter(_this, void 0, void 0, function () {
295
298
  var _a, query, variables, graphQLCondition, opName, modelDefinition, authToken, tryWith, attempt, opType, result, err_1, _b, error, _c, _d, code, retryWith, err_2, _e, _f, opName_1, query_1, authToken_1, serverData, namespace, updatedMutation, err_3;
296
299
  var _g;
297
300
  return __generator(this, function (_h) {
@@ -301,13 +304,19 @@ var MutationProcessor = /** @class */ (function () {
301
304
  return [4 /*yield*/, getTokenForCustomAuth(authMode, this.amplifyConfig)];
302
305
  case 1:
303
306
  authToken = _h.sent();
304
- tryWith = { query: query, variables: variables, authMode: authMode, authToken: authToken };
307
+ tryWith = {
308
+ query: query,
309
+ variables: variables,
310
+ authMode: authMode,
311
+ authToken: authToken,
312
+ userAgentSuffix: USER_AGENT_SUFFIX_DATASTORE,
313
+ };
305
314
  attempt = 0;
306
315
  opType = this.opTypeFromTransformerOperation(operation);
307
316
  _h.label = 2;
308
317
  case 2:
309
318
  _h.trys.push([2, 4, , 20]);
310
- return [4 /*yield*/, API.graphql(tryWith)];
319
+ return [4 /*yield*/, this.amplifyContext.API.graphql(tryWith)];
311
320
  case 3:
312
321
  result = (_h.sent());
313
322
  return [2 /*return*/, [result, opName, modelDefinition]];
@@ -357,11 +366,12 @@ var MutationProcessor = /** @class */ (function () {
357
366
  return [4 /*yield*/, getTokenForCustomAuth(authMode, this.amplifyConfig)];
358
367
  case 9:
359
368
  authToken_1 = _h.sent();
360
- return [4 /*yield*/, API.graphql({
369
+ return [4 /*yield*/, this.amplifyContext.API.graphql({
361
370
  query: query_1,
362
371
  variables: { id: variables.input.id },
363
372
  authMode: authMode,
364
373
  authToken: authToken_1,
374
+ userAgentSuffix: USER_AGENT_SUFFIX_DATASTORE,
365
375
  })];
366
376
  case 10:
367
377
  serverData = _h.sent();
@@ -376,11 +386,14 @@ var MutationProcessor = /** @class */ (function () {
376
386
  case 13:
377
387
  _h.trys.push([13, 15, 16, 17]);
378
388
  return [4 /*yield*/, this.errorHandler({
379
- localModel: this.modelInstanceCreator(modelConstructor, variables.input),
389
+ 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',
390
+ localModel: variables.input,
380
391
  message: error.message,
381
392
  operation: operation,
382
- errorType: error.errorType,
393
+ errorType: getMutationErrorType(error),
383
394
  errorInfo: error.errorInfo,
395
+ process: ProcessName.mutate,
396
+ cause: error,
384
397
  remoteModel: error.data
385
398
  ? this.modelInstanceCreator(modelConstructor, error.data)
386
399
  : null,
@@ -390,7 +403,7 @@ var MutationProcessor = /** @class */ (function () {
390
403
  return [3 /*break*/, 17];
391
404
  case 15:
392
405
  err_3 = _h.sent();
393
- logger.warn('failed to execute errorHandler', err_3);
406
+ logger.warn('Mutation error handler failed with:', err_3);
394
407
  return [3 /*break*/, 17];
395
408
  case 16:
396
409
  // Return empty tuple, dequeues the mutation
@@ -421,25 +434,25 @@ var MutationProcessor = /** @class */ (function () {
421
434
  modelConstructor,
422
435
  MutationEvent,
423
436
  mutationEvent,
424
- ])];
437
+ ], safeJitteredBackoff)];
425
438
  case 1: return [2 /*return*/, _a.sent()];
426
439
  }
427
440
  });
428
441
  });
429
442
  };
430
443
  MutationProcessor.prototype.createQueryVariables = function (namespaceName, model, operation, data, condition) {
431
- var e_1, _a;
444
+ var e_1, _a, e_2, _b, e_3, _c;
432
445
  var modelDefinition = this.schema.namespaces[namespaceName].models[model];
433
446
  var primaryKey = this.schema.namespaces[namespaceName].keys[model].primaryKey;
434
447
  var queriesTuples = this.typeQuery.get(modelDefinition);
435
- var _b = __read(queriesTuples.find(function (_a) {
448
+ var _d = __read(queriesTuples.find(function (_a) {
436
449
  var _b = __read(_a, 1), transformerMutationType = _b[0];
437
450
  return transformerMutationType === operation;
438
- }), 3), opName = _b[1], query = _b[2];
439
- var _c = JSON.parse(data), _version = _c._version, parsedData = __rest(_c, ["_version"]);
451
+ }), 3), opName = _d[1], query = _d[2];
452
+ var _e = JSON.parse(data), _version = _e._version, parsedData = __rest(_e, ["_version"]);
440
453
  // include all the fields that comprise a custom PK if one is specified
441
454
  var deleteInput = {};
442
- if (primaryKey && primaryKey.length) {
455
+ if (primaryKey === null || primaryKey === void 0 ? void 0 : primaryKey.length) {
443
456
  try {
444
457
  for (var primaryKey_1 = __values(primaryKey), primaryKey_1_1 = primaryKey_1.next(); !primaryKey_1_1.done; primaryKey_1_1 = primaryKey_1.next()) {
445
458
  var pkField = primaryKey_1_1.value;
@@ -455,48 +468,78 @@ var MutationProcessor = /** @class */ (function () {
455
468
  }
456
469
  }
457
470
  else {
471
+ // CPK TODO:
472
+ // Previous comment from Manuel: what if it was renamed ?
458
473
  deleteInput['id'] = parsedData.id;
459
474
  }
460
- var filteredData = operation === TransformerMutationType.DELETE
461
- ? deleteInput // For DELETE mutations, only PK is sent
462
- : Object.values(modelDefinition.fields)
463
- .filter(function (_a) {
464
- var name = _a.name, type = _a.type, association = _a.association;
465
- // connections
466
- if (isModelFieldType(type)) {
467
- // BELONGS_TO
468
- if (isTargetNameAssociation(association) &&
469
- association.connectionType === 'BELONGS_TO') {
470
- return true;
475
+ var mutationInput;
476
+ if (operation === TransformerMutationType.DELETE) {
477
+ // For DELETE mutations, only the key(s) are included in the input
478
+ mutationInput = deleteInput;
479
+ }
480
+ else {
481
+ // Otherwise, we construct the mutation input with the following logic
482
+ mutationInput = {};
483
+ var modelFields = Object.values(modelDefinition.fields);
484
+ try {
485
+ for (var modelFields_1 = __values(modelFields), modelFields_1_1 = modelFields_1.next(); !modelFields_1_1.done; modelFields_1_1 = modelFields_1.next()) {
486
+ var _f = modelFields_1_1.value, name_1 = _f.name, type = _f.type, association = _f.association;
487
+ // model fields should be stripped out from the input
488
+ if (isModelFieldType(type)) {
489
+ // except for belongs to relations - we need to replace them with the correct foreign key(s)
490
+ if (isTargetNameAssociation(association) &&
491
+ association.connectionType === 'BELONGS_TO') {
492
+ var targetNames = extractTargetNamesFromSrc(association);
493
+ if (targetNames) {
494
+ try {
495
+ // instead of including the connected model itself, we add its key(s) to the mutation input
496
+ for (var targetNames_1 = (e_3 = void 0, __values(targetNames)), targetNames_1_1 = targetNames_1.next(); !targetNames_1_1.done; targetNames_1_1 = targetNames_1.next()) {
497
+ var targetName = targetNames_1_1.value;
498
+ mutationInput[targetName] = parsedData[targetName];
499
+ }
500
+ }
501
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
502
+ finally {
503
+ try {
504
+ if (targetNames_1_1 && !targetNames_1_1.done && (_c = targetNames_1.return)) _c.call(targetNames_1);
505
+ }
506
+ finally { if (e_3) throw e_3.error; }
507
+ }
508
+ // if (association?.targetNames?.length) {
509
+ // // instead of including the connected model itself, we add its key(s) to the mutation input
510
+ // for (const targetName of association.targetNames) {
511
+ // mutationInput[targetName] = parsedData[targetName];
512
+ // }
513
+ // } else if (association.targetName) {
514
+ // // backwards-compatability for schema generated prior to custom primary key support
515
+ // mutationInput[association.targetName] =
516
+ // parsedData[association.targetName];
517
+ // }
518
+ }
519
+ }
520
+ continue;
471
521
  }
472
- // All other connections
473
- return false;
474
- }
475
- if (operation === TransformerMutationType.UPDATE) {
476
- // this limits the update mutation input to changed fields only
477
- return parsedData.hasOwnProperty(name);
522
+ // scalar fields / non-model types
523
+ if (operation === TransformerMutationType.UPDATE) {
524
+ if (!parsedData.hasOwnProperty(name_1)) {
525
+ // for update mutations - strip out a field if it's unchanged
526
+ continue;
527
+ }
528
+ }
529
+ // all other fields are added to the input object
530
+ mutationInput[name_1] = parsedData[name_1];
478
531
  }
479
- // scalars and non-model types
480
- return true;
481
- })
482
- .map(function (_a) {
483
- var name = _a.name, type = _a.type, association = _a.association;
484
- var fieldName = name;
485
- var val = parsedData[name];
486
- if (isModelFieldType(type) &&
487
- isTargetNameAssociation(association)) {
488
- fieldName = association.targetName;
489
- val = parsedData[fieldName];
532
+ }
533
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
534
+ finally {
535
+ try {
536
+ if (modelFields_1_1 && !modelFields_1_1.done && (_b = modelFields_1.return)) _b.call(modelFields_1);
490
537
  }
491
- return [fieldName, val];
492
- })
493
- .reduce(function (acc, _a) {
494
- var _b = __read(_a, 2), k = _b[0], v = _b[1];
495
- acc[k] = v;
496
- return acc;
497
- }, {});
538
+ finally { if (e_2) throw e_2.error; }
539
+ }
540
+ }
498
541
  // Build mutation variables input object
499
- var input = __assign(__assign({}, filteredData), { _version: _version });
542
+ var input = __assign(__assign({}, mutationInput), { _version: _version });
500
543
  var graphQLCondition = JSON.parse(condition);
501
544
  var variables = __assign({ input: input }, (operation === TransformerMutationType.CREATE
502
545
  ? {}
@@ -526,5 +569,30 @@ var MutationProcessor = /** @class */ (function () {
526
569
  };
527
570
  return MutationProcessor;
528
571
  }());
572
+ var MAX_RETRY_DELAY_MS = 5 * 60 * 1000;
573
+ var originalJitteredBackoff = jitteredBackoff(MAX_RETRY_DELAY_MS);
574
+ /**
575
+ * @private
576
+ * Internal use of Amplify only.
577
+ *
578
+ * Wraps the jittered backoff calculation to retry Network Errors indefinitely.
579
+ * Backs off according to original jittered retry logic until the original retry
580
+ * logic hits its max. After this occurs, if the error is a Network Error, we
581
+ * ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until
582
+ * the request succeeds).
583
+ *
584
+ * @param attempt ignored
585
+ * @param _args ignored
586
+ * @param error tested to see if `.message` is 'Network Error'
587
+ * @returns number | false :
588
+ */
589
+ export var safeJitteredBackoff = function (attempt, _args, error) {
590
+ var attemptResult = originalJitteredBackoff(attempt);
591
+ // If this is the last attempt and it is a network error, we retry indefinitively every 5 minutes
592
+ if (attemptResult === false && (error === null || error === void 0 ? void 0 : error.message) === 'Network Error') {
593
+ return MAX_RETRY_DELAY_MS;
594
+ }
595
+ return attemptResult;
596
+ };
529
597
  export { MutationProcessor };
530
598
  //# sourceMappingURL=mutation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutation.js","sourceRoot":"","sources":["../../../src/sync/processors/mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,GAAyC,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACN,aAAa,IAAI,MAAM,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,UAA6B,MAAM,mBAAmB,CAAC;AAI9D,OAAO,EAGN,OAAO,EAIP,gBAAgB,EAChB,uBAAuB,EAEvB,MAAM,GAKN,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EACN,qBAAqB,EACrB,wCAAwC,EACxC,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACrB,MAAM,UAAU,CAAC;AAElB,IAAM,YAAY,GAAG,EAAE,CAAC;AAExB,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;AASvC;IAQC,2BACkB,MAAsB,EACtB,OAAgB,EAChB,WAA+B,EAC/B,MAA2B,EAC3B,oBAA0C,EAC1C,aAAwD,EACxD,aAAuC,EACvC,gBAAkC,EAClC,eAAiC,EACjC,YAA2B;QAH3B,8BAAA,EAAA,kBAAuC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;IAEM,iCAAK,GAAZ;QACC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IACzB,CAAC;IACF,wBAAC;AAAD,CAAC,AA7fD,IA6fC;AAED,IAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,IAAM,uBAAuB,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAmC,UAClE,OAAO,EACP,KAAK,EACL,KAAK;IAEL,IAAM,aAAa,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAEvD,iGAAiG;IACjG,IAAI,aAAa,KAAK,KAAK,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,MAAK,eAAe,EAAE;QAClE,OAAO,kBAAkB,CAAC;KAC1B;IAED,OAAO,aAAa,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import Observable from 'zen-observable-ts';
2
- import { InternalSchema, PersistentModel, SchemaModel, ModelPredicate, AuthModeStrategy } from '../../types';
2
+ import { InternalSchema, PersistentModel, SchemaModel, ModelPredicate, AuthModeStrategy, ErrorHandler, AmplifyContext } from '../../types';
3
3
  import { TransformerMutationType } from '../utils';
4
4
  export declare enum CONTROL_MSG {
5
5
  CONNECTED = "CONNECTED"
@@ -14,10 +14,12 @@ declare class SubscriptionProcessor {
14
14
  private readonly syncPredicates;
15
15
  private readonly amplifyConfig;
16
16
  private readonly authModeStrategy;
17
+ private readonly errorHandler;
18
+ private readonly amplifyContext;
17
19
  private readonly typeQuery;
18
20
  private buffer;
19
21
  private dataObserver;
20
- constructor(schema: InternalSchema, syncPredicates: WeakMap<SchemaModel, ModelPredicate<any>>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy);
22
+ constructor(schema: InternalSchema, syncPredicates: WeakMap<SchemaModel, ModelPredicate<any>>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, errorHandler: ErrorHandler, amplifyContext?: AmplifyContext);
21
23
  private buildSubscription;
22
24
  private getAuthorizationInfo;
23
25
  private hubQueryCompletionListener;
@@ -66,14 +66,16 @@ var __spread = (this && this.__spread) || function () {
66
66
  return ar;
67
67
  };
68
68
  import API, { GRAPHQL_AUTH_MODE } from '@aws-amplify/api';
69
- import Auth from '@aws-amplify/auth';
69
+ import { Auth } from '@aws-amplify/auth';
70
70
  import Cache from '@aws-amplify/cache';
71
71
  import { ConsoleLogger as Logger, Hub } from '@aws-amplify/core';
72
72
  import { CONTROL_MSG as PUBSUB_CONTROL_MSG } from '@aws-amplify/pubsub';
73
73
  import Observable from 'zen-observable-ts';
74
+ import { ProcessName, } from '../../types';
74
75
  import { buildSubscriptionGraphQLOperation, getAuthorizationRules, getModelAuthModes, getUserGroupsFromToken, TransformerMutationType, getTokenForCustomAuth, } from '../utils';
75
76
  import { ModelPredicateCreator } from '../../predicates';
76
- import { validatePredicate } from '../../util';
77
+ import { validatePredicate, USER_AGENT_SUFFIX_DATASTORE } from '../../util';
78
+ import { getSubscriptionErrorType } from './errorMaps';
77
79
  var logger = new Logger('DataStore');
78
80
  export var CONTROL_MSG;
79
81
  (function (CONTROL_MSG) {
@@ -86,12 +88,15 @@ export var USER_CREDENTIALS;
86
88
  USER_CREDENTIALS[USER_CREDENTIALS["auth"] = 2] = "auth";
87
89
  })(USER_CREDENTIALS || (USER_CREDENTIALS = {}));
88
90
  var SubscriptionProcessor = /** @class */ (function () {
89
- function SubscriptionProcessor(schema, syncPredicates, amplifyConfig, authModeStrategy) {
91
+ function SubscriptionProcessor(schema, syncPredicates, amplifyConfig, authModeStrategy, errorHandler, amplifyContext) {
90
92
  if (amplifyConfig === void 0) { amplifyConfig = {}; }
93
+ if (amplifyContext === void 0) { amplifyContext = { Auth: Auth, API: API, Cache: Cache }; }
91
94
  this.schema = schema;
92
95
  this.syncPredicates = syncPredicates;
93
96
  this.amplifyConfig = amplifyConfig;
94
97
  this.authModeStrategy = authModeStrategy;
98
+ this.errorHandler = errorHandler;
99
+ this.amplifyContext = amplifyContext;
95
100
  this.typeQuery = new WeakMap();
96
101
  this.buffer = [];
97
102
  }
@@ -206,7 +211,7 @@ var SubscriptionProcessor = /** @class */ (function () {
206
211
  switch (_b.label) {
207
212
  case 0:
208
213
  _b.trys.push([0, 2, , 3]);
209
- return [4 /*yield*/, Auth.currentCredentials()];
214
+ return [4 /*yield*/, this.amplifyContext.Auth.currentCredentials()];
210
215
  case 1:
211
216
  credentials = _b.sent();
212
217
  userCredentials = credentials.authenticated
@@ -218,7 +223,7 @@ var SubscriptionProcessor = /** @class */ (function () {
218
223
  return [3 /*break*/, 3];
219
224
  case 3:
220
225
  _b.trys.push([3, 5, , 6]);
221
- return [4 /*yield*/, Auth.currentSession()];
226
+ return [4 /*yield*/, this.amplifyContext.Auth.currentSession()];
222
227
  case 4:
223
228
  session = _b.sent();
224
229
  cognitoTokenPayload = session.getIdToken().decodePayload();
@@ -233,13 +238,13 @@ var SubscriptionProcessor = /** @class */ (function () {
233
238
  throw 'Auth is not configured';
234
239
  }
235
240
  token = void 0;
236
- return [4 /*yield*/, Cache.getItem('federatedInfo')];
241
+ return [4 /*yield*/, this.amplifyContext.Cache.getItem('federatedInfo')];
237
242
  case 7:
238
243
  federatedInfo = _b.sent();
239
244
  if (!federatedInfo) return [3 /*break*/, 8];
240
245
  token = federatedInfo.token;
241
246
  return [3 /*break*/, 10];
242
- case 8: return [4 /*yield*/, Auth.currentAuthenticatedUser()];
247
+ case 8: return [4 /*yield*/, this.amplifyContext.Auth.currentAuthenticatedUser()];
243
248
  case 9:
244
249
  currentUser = _b.sent();
245
250
  if (currentUser) {
@@ -271,8 +276,7 @@ var SubscriptionProcessor = /** @class */ (function () {
271
276
  switch (_d.label) {
272
277
  case 0: return [4 /*yield*/, getModelAuthModes({
273
278
  authModeStrategy: this.authModeStrategy,
274
- defaultAuthMode: this.amplifyConfig
275
- .aws_appsync_authenticationType,
279
+ defaultAuthMode: this.amplifyConfig.aws_appsync_authenticationType,
276
280
  modelName: modelDefinition.name,
277
281
  schema: this.schema,
278
282
  })];
@@ -295,7 +299,7 @@ var SubscriptionProcessor = /** @class */ (function () {
295
299
  _c[TransformerMutationType.DELETE] = 0,
296
300
  _c);
297
301
  authModeRetry = function (operation) { return __awaiter(_this, void 0, void 0, function () {
298
- var _a, transformerMutationType, opName, query, isOwner, ownerField, ownerValue, authMode, authToken, variables, queryObservable, subscriptionReadyCallback;
302
+ var _a, transformerMutationType, opName, query, isOwner, ownerField, ownerValue, authMode, authToken, variables, userAgentSuffix, queryObservable, subscriptionReadyCallback;
299
303
  var _this = this;
300
304
  return __generator(this, function (_b) {
301
305
  switch (_b.label) {
@@ -313,7 +317,8 @@ var SubscriptionProcessor = /** @class */ (function () {
313
317
  variables[ownerField] = ownerValue;
314
318
  }
315
319
  logger.debug("Attempting " + operation + " subscription with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
316
- queryObservable = API.graphql(__assign(__assign({ query: query, variables: variables }, { authMode: authMode }), { authToken: authToken }));
320
+ userAgentSuffix = USER_AGENT_SUFFIX_DATASTORE;
321
+ queryObservable = this.amplifyContext.API.graphql(__assign(__assign({ query: query, variables: variables }, { authMode: authMode }), { authToken: authToken, userAgentSuffix: userAgentSuffix }));
317
322
  subscriptions[modelDefinition.name][transformerMutationType].push(queryObservable
318
323
  .map(function (_a) {
319
324
  var value = _a.value;
@@ -342,38 +347,68 @@ var SubscriptionProcessor = /** @class */ (function () {
342
347
  }
343
348
  _this.drainBuffer();
344
349
  },
345
- error: function (subscriptionError) {
346
- var _a = subscriptionError.error, _b = __read((_a === void 0 ? {
347
- errors: [],
348
- } : _a).errors, 1), _c = _b[0], _d = (_c === void 0 ? {} : _c).message, message = _d === void 0 ? '' : _d;
349
- if (message.includes(PUBSUB_CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR) ||
350
- message.includes(PUBSUB_CONTROL_MSG.CONNECTION_FAILED)) {
351
- // Unsubscribe and clear subscription array for model/operation
352
- subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) { return subscription.unsubscribe(); });
353
- subscriptions[modelDefinition.name][transformerMutationType] = [];
354
- operationAuthModeAttempts[operation]++;
355
- if (operationAuthModeAttempts[operation] >=
356
- readAuthModes.length) {
357
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
358
- logger.warn('subscriptionError', message);
359
- return;
350
+ error: function (subscriptionError) { return __awaiter(_this, void 0, void 0, function () {
351
+ var _a, _b, _c, _d, message, e_1;
352
+ return __generator(this, function (_e) {
353
+ switch (_e.label) {
354
+ case 0:
355
+ _a = subscriptionError.error, _b = __read((_a === void 0 ? {
356
+ errors: [],
357
+ } : _a).errors, 1), _c = _b[0], _d = (_c === void 0 ? {} : _c).message, message = _d === void 0 ? '' : _d;
358
+ if (message.includes(PUBSUB_CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR) ||
359
+ message.includes(PUBSUB_CONTROL_MSG.CONNECTION_FAILED)) {
360
+ // Unsubscribe and clear subscription array for model/operation
361
+ subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) { return subscription.unsubscribe(); });
362
+ subscriptions[modelDefinition.name][transformerMutationType] = [];
363
+ operationAuthModeAttempts[operation]++;
364
+ if (operationAuthModeAttempts[operation] >=
365
+ readAuthModes.length) {
366
+ // last auth mode retry. Continue with error
367
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
368
+ }
369
+ else {
370
+ // retry with different auth mode. Do not trigger
371
+ // observer error or error handler
372
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
373
+ authModeRetry(operation);
374
+ return [2 /*return*/];
375
+ }
376
+ }
377
+ logger.warn('subscriptionError', message);
378
+ _e.label = 1;
379
+ case 1:
380
+ _e.trys.push([1, 3, , 4]);
381
+ return [4 /*yield*/, this.errorHandler({
382
+ 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',
383
+ localModel: null,
384
+ message: message,
385
+ model: modelDefinition.name,
386
+ operation: operation,
387
+ errorType: getSubscriptionErrorType(subscriptionError),
388
+ process: ProcessName.subscribe,
389
+ remoteModel: null,
390
+ cause: subscriptionError,
391
+ })];
392
+ case 2:
393
+ _e.sent();
394
+ return [3 /*break*/, 4];
395
+ case 3:
396
+ e_1 = _e.sent();
397
+ logger.error('Subscription error handler failed with:', e_1);
398
+ return [3 /*break*/, 4];
399
+ case 4:
400
+ if (typeof subscriptionReadyCallback === 'function') {
401
+ subscriptionReadyCallback();
402
+ }
403
+ if (message.includes('"errorType":"Unauthorized"') ||
404
+ message.includes('"errorType":"OperationDisabled"')) {
405
+ return [2 /*return*/];
406
+ }
407
+ observer.error(message);
408
+ return [2 /*return*/];
360
409
  }
361
- else {
362
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
363
- authModeRetry(operation);
364
- return;
365
- }
366
- }
367
- logger.warn('subscriptionError', message);
368
- if (typeof subscriptionReadyCallback === 'function') {
369
- subscriptionReadyCallback();
370
- }
371
- if (message.includes('"errorType":"Unauthorized"') ||
372
- message.includes('"errorType":"OperationDisabled"')) {
373
- return;
374
- }
375
- observer.error(message);
376
- },
410
+ });
411
+ }); },
377
412
  }));
378
413
  promises.push((function () { return __awaiter(_this, void 0, void 0, function () {
379
414
  var boundFunction;