@aws-amplify/datastore 4.7.5 → 5.0.1-console-preview.4208d73.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 (182) hide show
  1. package/README.md +4 -0
  2. package/lib/authModeStrategies/defaultAuthStrategy.js +3 -2
  3. package/lib/authModeStrategies/index.js +3 -3
  4. package/lib/authModeStrategies/multiAuthStrategy.js +81 -24
  5. package/lib/datastore/datastore.d.ts +3 -4
  6. package/lib/datastore/datastore.js +361 -227
  7. package/lib/index.d.ts +1 -1
  8. package/lib/index.js +25 -12
  9. package/lib/predicates/index.js +46 -12
  10. package/lib/predicates/next.d.ts +2 -2
  11. package/lib/predicates/next.js +172 -74
  12. package/lib/predicates/sort.js +3 -4
  13. package/lib/ssr/index.js +1 -1
  14. package/lib/storage/adapter/AsyncStorageAdapter.js +240 -128
  15. package/lib/storage/adapter/AsyncStorageDatabase.js +100 -39
  16. package/lib/storage/adapter/InMemoryStore.js +68 -17
  17. package/lib/storage/adapter/InMemoryStore.native.js +5 -3
  18. package/lib/storage/adapter/IndexedDBAdapter.js +355 -199
  19. package/lib/storage/adapter/StorageAdapterBase.js +154 -85
  20. package/lib/storage/adapter/getDefaultAdapter/index.js +8 -9
  21. package/lib/storage/adapter/getDefaultAdapter/index.native.js +4 -3
  22. package/lib/storage/adapter/index.js +0 -1
  23. package/lib/storage/relationship.js +31 -21
  24. package/lib/storage/storage.d.ts +3 -3
  25. package/lib/storage/storage.js +143 -61
  26. package/lib/sync/datastoreConnectivity.d.ts +1 -1
  27. package/lib/sync/datastoreConnectivity.js +57 -9
  28. package/lib/sync/datastoreReachability/index.js +3 -3
  29. package/lib/sync/datastoreReachability/index.native.js +7 -5
  30. package/lib/sync/index.d.ts +1 -1
  31. package/lib/sync/index.js +193 -125
  32. package/lib/sync/merger.js +81 -10
  33. package/lib/sync/outbox.js +101 -30
  34. package/lib/sync/processors/errorMaps.d.ts +1 -1
  35. package/lib/sync/processors/errorMaps.js +41 -6
  36. package/lib/sync/processors/mutation.d.ts +1 -1
  37. package/lib/sync/processors/mutation.js +192 -101
  38. package/lib/sync/processors/subscription.d.ts +4 -1
  39. package/lib/sync/processors/subscription.js +190 -178
  40. package/lib/sync/processors/sync.d.ts +1 -1
  41. package/lib/sync/processors/sync.js +113 -47
  42. package/lib/sync/utils.d.ts +4 -4
  43. package/lib/sync/utils.js +162 -81
  44. package/lib/tsconfig.tsbuildinfo +1 -0
  45. package/lib/types.d.ts +138 -140
  46. package/lib/types.js +40 -5
  47. package/lib/util.d.ts +9 -17
  48. package/lib/util.js +216 -100
  49. package/lib-esm/authModeStrategies/defaultAuthStrategy.js +0 -1
  50. package/lib-esm/authModeStrategies/index.js +0 -1
  51. package/lib-esm/authModeStrategies/multiAuthStrategy.js +76 -21
  52. package/lib-esm/datastore/datastore.d.ts +3 -4
  53. package/lib-esm/datastore/datastore.js +206 -77
  54. package/lib-esm/index.d.ts +1 -1
  55. package/lib-esm/index.js +0 -1
  56. package/lib-esm/predicates/index.js +40 -7
  57. package/lib-esm/predicates/next.d.ts +2 -2
  58. package/lib-esm/predicates/next.js +148 -52
  59. package/lib-esm/predicates/sort.js +2 -4
  60. package/lib-esm/ssr/index.js +0 -1
  61. package/lib-esm/storage/adapter/AsyncStorageAdapter.js +203 -95
  62. package/lib-esm/storage/adapter/AsyncStorageDatabase.js +66 -5
  63. package/lib-esm/storage/adapter/InMemoryStore.js +52 -2
  64. package/lib-esm/storage/adapter/InMemoryStore.native.js +0 -1
  65. package/lib-esm/storage/adapter/IndexedDBAdapter.js +271 -138
  66. package/lib-esm/storage/adapter/StorageAdapterBase.js +130 -62
  67. package/lib-esm/storage/adapter/getDefaultAdapter/index.js +2 -5
  68. package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js +0 -1
  69. package/lib-esm/storage/adapter/index.js +1 -1
  70. package/lib-esm/storage/relationship.js +27 -18
  71. package/lib-esm/storage/storage.d.ts +3 -3
  72. package/lib-esm/storage/storage.js +87 -9
  73. package/lib-esm/sync/datastoreConnectivity.d.ts +1 -1
  74. package/lib-esm/sync/datastoreConnectivity.js +48 -3
  75. package/lib-esm/sync/datastoreReachability/index.js +1 -2
  76. package/lib-esm/sync/datastoreReachability/index.native.js +1 -2
  77. package/lib-esm/sync/index.d.ts +1 -1
  78. package/lib-esm/sync/index.js +136 -72
  79. package/lib-esm/sync/merger.js +73 -3
  80. package/lib-esm/sync/outbox.js +75 -5
  81. package/lib-esm/sync/processors/errorMaps.d.ts +1 -1
  82. package/lib-esm/sync/processors/errorMaps.js +39 -5
  83. package/lib-esm/sync/processors/mutation.d.ts +1 -1
  84. package/lib-esm/sync/processors/mutation.js +130 -44
  85. package/lib-esm/sync/processors/subscription.d.ts +4 -1
  86. package/lib-esm/sync/processors/subscription.js +134 -126
  87. package/lib-esm/sync/processors/sync.d.ts +1 -1
  88. package/lib-esm/sync/processors/sync.js +74 -12
  89. package/lib-esm/sync/utils.d.ts +4 -4
  90. package/lib-esm/sync/utils.js +135 -55
  91. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  92. package/lib-esm/types.d.ts +138 -140
  93. package/lib-esm/types.js +36 -2
  94. package/lib-esm/util.d.ts +9 -17
  95. package/lib-esm/util.js +96 -16
  96. package/package.json +139 -132
  97. package/src/authModeStrategies/multiAuthStrategy.ts +11 -12
  98. package/src/datastore/datastore.ts +32 -25
  99. package/src/predicates/sort.ts +3 -1
  100. package/src/storage/adapter/InMemoryStore.ts +1 -1
  101. package/src/storage/adapter/IndexedDBAdapter.ts +1 -1
  102. package/src/storage/adapter/StorageAdapterBase.ts +1 -1
  103. package/src/storage/adapter/getDefaultAdapter/index.ts +2 -3
  104. package/src/storage/storage.ts +1 -1
  105. package/src/sync/datastoreConnectivity.ts +2 -2
  106. package/src/sync/datastoreReachability/index.native.ts +1 -1
  107. package/src/sync/datastoreReachability/index.ts +1 -1
  108. package/src/sync/index.ts +69 -78
  109. package/src/sync/processors/mutation.ts +16 -10
  110. package/src/sync/processors/subscription.ts +55 -127
  111. package/src/sync/processors/sync.ts +8 -4
  112. package/src/sync/utils.ts +7 -8
  113. package/src/types.ts +4 -8
  114. package/src/util.ts +5 -6
  115. package/lib/.tsbuildinfo +0 -3
  116. package/lib/authModeStrategies/defaultAuthStrategy.js.map +0 -1
  117. package/lib/authModeStrategies/index.js.map +0 -1
  118. package/lib/authModeStrategies/multiAuthStrategy.js.map +0 -1
  119. package/lib/datastore/datastore.js.map +0 -1
  120. package/lib/index.js.map +0 -1
  121. package/lib/predicates/index.js.map +0 -1
  122. package/lib/predicates/next.js.map +0 -1
  123. package/lib/predicates/sort.js.map +0 -1
  124. package/lib/ssr/index.js.map +0 -1
  125. package/lib/storage/adapter/AsyncStorageAdapter.js.map +0 -1
  126. package/lib/storage/adapter/AsyncStorageDatabase.js.map +0 -1
  127. package/lib/storage/adapter/InMemoryStore.js.map +0 -1
  128. package/lib/storage/adapter/InMemoryStore.native.js.map +0 -1
  129. package/lib/storage/adapter/IndexedDBAdapter.js.map +0 -1
  130. package/lib/storage/adapter/StorageAdapterBase.js.map +0 -1
  131. package/lib/storage/adapter/getDefaultAdapter/index.js.map +0 -1
  132. package/lib/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
  133. package/lib/storage/adapter/index.js.map +0 -1
  134. package/lib/storage/relationship.js.map +0 -1
  135. package/lib/storage/storage.js.map +0 -1
  136. package/lib/sync/datastoreConnectivity.js.map +0 -1
  137. package/lib/sync/datastoreReachability/index.js.map +0 -1
  138. package/lib/sync/datastoreReachability/index.native.js.map +0 -1
  139. package/lib/sync/index.js.map +0 -1
  140. package/lib/sync/merger.js.map +0 -1
  141. package/lib/sync/outbox.js.map +0 -1
  142. package/lib/sync/processors/errorMaps.js.map +0 -1
  143. package/lib/sync/processors/mutation.js.map +0 -1
  144. package/lib/sync/processors/subscription.js.map +0 -1
  145. package/lib/sync/processors/sync.js.map +0 -1
  146. package/lib/sync/utils.js.map +0 -1
  147. package/lib/types.js.map +0 -1
  148. package/lib/util.js.map +0 -1
  149. package/lib-esm/.tsbuildinfo +0 -3
  150. package/lib-esm/authModeStrategies/defaultAuthStrategy.js.map +0 -1
  151. package/lib-esm/authModeStrategies/index.js.map +0 -1
  152. package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +0 -1
  153. package/lib-esm/datastore/datastore.js.map +0 -1
  154. package/lib-esm/index.js.map +0 -1
  155. package/lib-esm/predicates/index.js.map +0 -1
  156. package/lib-esm/predicates/next.js.map +0 -1
  157. package/lib-esm/predicates/sort.js.map +0 -1
  158. package/lib-esm/ssr/index.js.map +0 -1
  159. package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +0 -1
  160. package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +0 -1
  161. package/lib-esm/storage/adapter/InMemoryStore.js.map +0 -1
  162. package/lib-esm/storage/adapter/InMemoryStore.native.js.map +0 -1
  163. package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +0 -1
  164. package/lib-esm/storage/adapter/StorageAdapterBase.js.map +0 -1
  165. package/lib-esm/storage/adapter/getDefaultAdapter/index.js.map +0 -1
  166. package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
  167. package/lib-esm/storage/adapter/index.js.map +0 -1
  168. package/lib-esm/storage/relationship.js.map +0 -1
  169. package/lib-esm/storage/storage.js.map +0 -1
  170. package/lib-esm/sync/datastoreConnectivity.js.map +0 -1
  171. package/lib-esm/sync/datastoreReachability/index.js.map +0 -1
  172. package/lib-esm/sync/datastoreReachability/index.native.js.map +0 -1
  173. package/lib-esm/sync/index.js.map +0 -1
  174. package/lib-esm/sync/merger.js.map +0 -1
  175. package/lib-esm/sync/outbox.js.map +0 -1
  176. package/lib-esm/sync/processors/errorMaps.js.map +0 -1
  177. package/lib-esm/sync/processors/mutation.js.map +0 -1
  178. package/lib-esm/sync/processors/subscription.js.map +0 -1
  179. package/lib-esm/sync/processors/sync.js.map +0 -1
  180. package/lib-esm/sync/utils.js.map +0 -1
  181. package/lib-esm/types.js.map +0 -1
  182. package/lib-esm/util.js.map +0 -1
@@ -1,11 +1,62 @@
1
- import { __asyncValues, __awaiter, __generator, __values } from "tslib";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
38
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
39
+ var m = o[Symbol.asyncIterator], i;
40
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
41
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
42
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
43
+ };
44
+ var __values = (this && this.__values) || function(o) {
45
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
46
+ if (m) return m.call(o);
47
+ if (o && typeof o.length === "number") return {
48
+ next: function () {
49
+ if (o && i >= o.length) o = void 0;
50
+ return { value: o && o[i++], done: !o };
51
+ }
52
+ };
53
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
54
+ };
5
55
  import { ModelPredicateCreator } from '../../predicates';
6
56
  import { isPredicateObj, } from '../../types';
7
57
  import { getStorename, getIndexKeys, extractPrimaryKeyValues, traverseModel, validatePredicate, isModelConstructor, extractPrimaryKeyFieldNames, } from '../../util';
8
58
  import { ModelRelationship } from '../relationship';
59
+ import { Logger } from '@aws-amplify/core/internals/utils';
9
60
  var logger = new Logger('DataStore');
10
61
  var DB_NAME = 'amplify-datastore';
11
62
  var StorageAdapterBase = /** @class */ (function () {
@@ -42,7 +93,7 @@ var StorageAdapterBase = /** @class */ (function () {
42
93
  return [2 /*return*/];
43
94
  case 4:
44
95
  if (sessionId) {
45
- this.dbName = DB_NAME + "-" + sessionId;
96
+ this.dbName = "".concat(DB_NAME, "-").concat(sessionId);
46
97
  }
47
98
  this.schema = theSchema;
48
99
  this.namespaceResolver = namespaceResolver;
@@ -343,23 +394,28 @@ var StorageAdapterBase = /** @class */ (function () {
343
394
  * @param deleteQueue
344
395
  */
345
396
  StorageAdapterBase.prototype.deleteTraverse = function (models, modelConstructor, namespace, deleteQueue) {
346
- var models_1, models_1_1;
347
- var e_2, _a, e_3, _b;
397
+ var _a, models_1, models_1_1;
398
+ var _b, e_2, _c, _d, _e, e_3, _f, _g;
348
399
  return __awaiter(this, void 0, void 0, function () {
349
- var cascadingRelationTypes, model, modelDefinition, modelMeta, relationships, relationships_1, relationships_1_1, r, queryObject, relatedRecords, e_3_1, e_2_1;
350
- return __generator(this, function (_c) {
351
- switch (_c.label) {
400
+ var cascadingRelationTypes, model, modelDefinition, modelMeta, relationships, _h, relationships_1, relationships_1_1, r, queryObject, relatedRecords, e_3_1, e_2_1;
401
+ return __generator(this, function (_j) {
402
+ switch (_j.label) {
352
403
  case 0:
353
404
  cascadingRelationTypes = ['HAS_ONE', 'HAS_MANY'];
354
- _c.label = 1;
405
+ _j.label = 1;
355
406
  case 1:
356
- _c.trys.push([1, 19, 20, 25]);
357
- models_1 = __asyncValues(models);
358
- _c.label = 2;
407
+ _j.trys.push([1, 25, 26, 31]);
408
+ _a = true, models_1 = __asyncValues(models);
409
+ _j.label = 2;
359
410
  case 2: return [4 /*yield*/, models_1.next()];
360
411
  case 3:
361
- if (!(models_1_1 = _c.sent(), !models_1_1.done)) return [3 /*break*/, 18];
362
- model = models_1_1.value;
412
+ if (!(models_1_1 = _j.sent(), _b = models_1_1.done, !_b)) return [3 /*break*/, 24];
413
+ _d = models_1_1.value;
414
+ _a = false;
415
+ _j.label = 4;
416
+ case 4:
417
+ _j.trys.push([4, , 22, 23]);
418
+ model = _d;
363
419
  modelDefinition = this.schema.namespaces[namespace].models[modelConstructor.name];
364
420
  modelMeta = {
365
421
  builder: modelConstructor,
@@ -369,61 +425,74 @@ var StorageAdapterBase = /** @class */ (function () {
369
425
  relationships = ModelRelationship.allFrom(modelMeta).filter(function (r) {
370
426
  return cascadingRelationTypes.includes(r.type);
371
427
  });
372
- _c.label = 4;
373
- case 4:
374
- _c.trys.push([4, 11, 12, 17]);
375
- relationships_1 = __asyncValues(relationships);
376
- _c.label = 5;
377
- case 5: return [4 /*yield*/, relationships_1.next()];
378
- case 6:
379
- if (!(relationships_1_1 = _c.sent(), !relationships_1_1.done)) return [3 /*break*/, 10];
380
- r = relationships_1_1.value;
428
+ _j.label = 5;
429
+ case 5:
430
+ _j.trys.push([5, 15, 16, 21]);
431
+ _h = true, relationships_1 = (e_3 = void 0, __asyncValues(relationships));
432
+ _j.label = 6;
433
+ case 6: return [4 /*yield*/, relationships_1.next()];
434
+ case 7:
435
+ if (!(relationships_1_1 = _j.sent(), _e = relationships_1_1.done, !_e)) return [3 /*break*/, 14];
436
+ _g = relationships_1_1.value;
437
+ _h = false;
438
+ _j.label = 8;
439
+ case 8:
440
+ _j.trys.push([8, , 12, 13]);
441
+ r = _g;
381
442
  queryObject = r.createRemoteQueryObject(model);
382
- if (!(queryObject !== null)) return [3 /*break*/, 9];
443
+ if (!(queryObject !== null)) return [3 /*break*/, 11];
383
444
  return [4 /*yield*/, this.query(r.remoteModelConstructor, ModelPredicateCreator.createFromFlatEqualities(r.remoteDefinition, queryObject))];
384
- case 7:
385
- relatedRecords = _c.sent();
445
+ case 9:
446
+ relatedRecords = _j.sent();
386
447
  return [4 /*yield*/, this.deleteTraverse(relatedRecords, r.remoteModelConstructor, namespace, deleteQueue)];
387
- case 8:
388
- _c.sent();
389
- _c.label = 9;
390
- case 9: return [3 /*break*/, 5];
391
- case 10: return [3 /*break*/, 17];
392
- case 11:
393
- e_3_1 = _c.sent();
394
- e_3 = { error: e_3_1 };
395
- return [3 /*break*/, 17];
448
+ case 10:
449
+ _j.sent();
450
+ _j.label = 11;
451
+ case 11: return [3 /*break*/, 13];
396
452
  case 12:
397
- _c.trys.push([12, , 15, 16]);
398
- if (!(relationships_1_1 && !relationships_1_1.done && (_b = relationships_1.return))) return [3 /*break*/, 14];
399
- return [4 /*yield*/, _b.call(relationships_1)];
400
- case 13:
401
- _c.sent();
402
- _c.label = 14;
403
- case 14: return [3 /*break*/, 16];
453
+ _h = true;
454
+ return [7 /*endfinally*/];
455
+ case 13: return [3 /*break*/, 6];
456
+ case 14: return [3 /*break*/, 21];
404
457
  case 15:
458
+ e_3_1 = _j.sent();
459
+ e_3 = { error: e_3_1 };
460
+ return [3 /*break*/, 21];
461
+ case 16:
462
+ _j.trys.push([16, , 19, 20]);
463
+ if (!(!_h && !_e && (_f = relationships_1.return))) return [3 /*break*/, 18];
464
+ return [4 /*yield*/, _f.call(relationships_1)];
465
+ case 17:
466
+ _j.sent();
467
+ _j.label = 18;
468
+ case 18: return [3 /*break*/, 20];
469
+ case 19:
405
470
  if (e_3) throw e_3.error;
406
471
  return [7 /*endfinally*/];
407
- case 16: return [7 /*endfinally*/];
408
- case 17: return [3 /*break*/, 2];
409
- case 18: return [3 /*break*/, 25];
410
- case 19:
411
- e_2_1 = _c.sent();
472
+ case 20: return [7 /*endfinally*/];
473
+ case 21: return [3 /*break*/, 23];
474
+ case 22:
475
+ _a = true;
476
+ return [7 /*endfinally*/];
477
+ case 23: return [3 /*break*/, 2];
478
+ case 24: return [3 /*break*/, 31];
479
+ case 25:
480
+ e_2_1 = _j.sent();
412
481
  e_2 = { error: e_2_1 };
413
- return [3 /*break*/, 25];
414
- case 20:
415
- _c.trys.push([20, , 23, 24]);
416
- if (!(models_1_1 && !models_1_1.done && (_a = models_1.return))) return [3 /*break*/, 22];
417
- return [4 /*yield*/, _a.call(models_1)];
418
- case 21:
419
- _c.sent();
420
- _c.label = 22;
421
- case 22: return [3 /*break*/, 24];
422
- case 23:
482
+ return [3 /*break*/, 31];
483
+ case 26:
484
+ _j.trys.push([26, , 29, 30]);
485
+ if (!(!_a && !_b && (_c = models_1.return))) return [3 /*break*/, 28];
486
+ return [4 /*yield*/, _c.call(models_1)];
487
+ case 27:
488
+ _j.sent();
489
+ _j.label = 28;
490
+ case 28: return [3 /*break*/, 30];
491
+ case 29:
423
492
  if (e_2) throw e_2.error;
424
493
  return [7 /*endfinally*/];
425
- case 24: return [7 /*endfinally*/];
426
- case 25:
494
+ case 30: return [7 /*endfinally*/];
495
+ case 31:
427
496
  deleteQueue.push({
428
497
  storeName: getStorename(namespace, modelConstructor.name),
429
498
  items: models,
@@ -436,4 +505,3 @@ var StorageAdapterBase = /** @class */ (function () {
436
505
  return StorageAdapterBase;
437
506
  }());
438
507
  export { StorageAdapterBase };
439
- //# sourceMappingURL=StorageAdapterBase.js.map
@@ -1,14 +1,11 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { browserOrNode, isWebWorker } from '@aws-amplify/core';
4
1
  import IndexedDBAdapter from '../IndexedDBAdapter';
5
2
  import AsyncStorageAdapter from '../AsyncStorageAdapter';
3
+ import { isWebWorker } from '@aws-amplify/core/internals/utils';
6
4
  var getDefaultAdapter = function () {
7
- var isBrowser = browserOrNode().isBrowser;
5
+ var isBrowser = true; // TODO(v6): Update this for SSR
8
6
  if ((isBrowser && window.indexedDB) || (isWebWorker() && self.indexedDB)) {
9
7
  return IndexedDBAdapter;
10
8
  }
11
9
  return AsyncStorageAdapter;
12
10
  };
13
11
  export default getDefaultAdapter;
14
- //# sourceMappingURL=index.js.map
@@ -3,4 +3,3 @@ var getDefaultAdapter = function () {
3
3
  return AsyncStorageAdapter;
4
4
  };
5
5
  export default getDefaultAdapter;
6
- //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=index.js.map
1
+ export {};
@@ -1,4 +1,14 @@
1
- import { __values } from "tslib";
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
2
12
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
13
  // SPDX-License-Identifier: Apache-2.0
4
14
  import { isFieldAssociation } from '../types';
@@ -17,7 +27,7 @@ var ModelRelationship = /** @class */ (function () {
17
27
  */
18
28
  function ModelRelationship(model, field) {
19
29
  if (!isFieldAssociation(model.schema, field)) {
20
- throw new Error(model.schema.name + "." + field + " is not a relationship.");
30
+ throw new Error("".concat(model.schema.name, ".").concat(field, " is not a relationship."));
21
31
  }
22
32
  this.localModel = model;
23
33
  this._field = field;
@@ -65,7 +75,7 @@ var ModelRelationship = /** @class */ (function () {
65
75
  get: function () {
66
76
  return this.localModel.schema;
67
77
  },
68
- enumerable: true,
78
+ enumerable: false,
69
79
  configurable: true
70
80
  });
71
81
  Object.defineProperty(ModelRelationship.prototype, "field", {
@@ -76,7 +86,7 @@ var ModelRelationship = /** @class */ (function () {
76
86
  get: function () {
77
87
  return this._field;
78
88
  },
79
- enumerable: true,
89
+ enumerable: false,
80
90
  configurable: true
81
91
  });
82
92
  Object.defineProperty(ModelRelationship.prototype, "localConstructor", {
@@ -87,7 +97,7 @@ var ModelRelationship = /** @class */ (function () {
87
97
  get: function () {
88
98
  return this.localModel.builder;
89
99
  },
90
- enumerable: true,
100
+ enumerable: false,
91
101
  configurable: true
92
102
  });
93
103
  Object.defineProperty(ModelRelationship.prototype, "type", {
@@ -98,7 +108,7 @@ var ModelRelationship = /** @class */ (function () {
98
108
  get: function () {
99
109
  return this.localAssocation.connectionType;
100
110
  },
101
- enumerable: true,
111
+ enumerable: false,
102
112
  configurable: true
103
113
  });
104
114
  Object.defineProperty(ModelRelationship.prototype, "localAssocation", {
@@ -112,7 +122,7 @@ var ModelRelationship = /** @class */ (function () {
112
122
  get: function () {
113
123
  return this.localDefinition.fields[this.field].association;
114
124
  },
115
- enumerable: true,
125
+ enumerable: false,
116
126
  configurable: true
117
127
  });
118
128
  Object.defineProperty(ModelRelationship.prototype, "localJoinFields", {
@@ -143,7 +153,7 @@ var ModelRelationship = /** @class */ (function () {
143
153
  return this.localPKFields;
144
154
  }
145
155
  },
146
- enumerable: true,
156
+ enumerable: false,
147
157
  configurable: true
148
158
  });
149
159
  Object.defineProperty(ModelRelationship.prototype, "localPKFields", {
@@ -155,7 +165,7 @@ var ModelRelationship = /** @class */ (function () {
155
165
  get: function () {
156
166
  return this.localModel.pkField;
157
167
  },
158
- enumerable: true,
168
+ enumerable: false,
159
169
  configurable: true
160
170
  });
161
171
  Object.defineProperty(ModelRelationship.prototype, "remoteDefinition", {
@@ -163,14 +173,14 @@ var ModelRelationship = /** @class */ (function () {
163
173
  var _a;
164
174
  return (_a = this.remoteModelType.modelConstructor) === null || _a === void 0 ? void 0 : _a.schema;
165
175
  },
166
- enumerable: true,
176
+ enumerable: false,
167
177
  configurable: true
168
178
  });
169
179
  Object.defineProperty(ModelRelationship.prototype, "remoteModelType", {
170
180
  get: function () {
171
181
  return this.localDefinition.fields[this.field].type;
172
182
  },
173
- enumerable: true,
183
+ enumerable: false,
174
184
  configurable: true
175
185
  });
176
186
  Object.defineProperty(ModelRelationship.prototype, "remoteModelConstructor", {
@@ -181,7 +191,7 @@ var ModelRelationship = /** @class */ (function () {
181
191
  get: function () {
182
192
  return this.remoteModelType.modelConstructor.builder;
183
193
  },
184
- enumerable: true,
194
+ enumerable: false,
185
195
  configurable: true
186
196
  });
187
197
  Object.defineProperty(ModelRelationship.prototype, "remotePKFields", {
@@ -194,7 +204,7 @@ var ModelRelationship = /** @class */ (function () {
194
204
  var _a;
195
205
  return ((_a = this.remoteModelType.modelConstructor) === null || _a === void 0 ? void 0 : _a.pkField) || ['id'];
196
206
  },
197
- enumerable: true,
207
+ enumerable: false,
198
208
  configurable: true
199
209
  });
200
210
  Object.defineProperty(ModelRelationship.prototype, "localAssociatedWith", {
@@ -217,7 +227,7 @@ var ModelRelationship = /** @class */ (function () {
217
227
  return undefined;
218
228
  }
219
229
  },
220
- enumerable: true,
230
+ enumerable: false,
221
231
  configurable: true
222
232
  });
223
233
  Object.defineProperty(ModelRelationship.prototype, "explicitRemoteAssociation", {
@@ -241,7 +251,7 @@ var ModelRelationship = /** @class */ (function () {
241
251
  }
242
252
  }
243
253
  },
244
- enumerable: true,
254
+ enumerable: false,
245
255
  configurable: true
246
256
  });
247
257
  Object.defineProperty(ModelRelationship.prototype, "remoteJoinFields", {
@@ -272,7 +282,7 @@ var ModelRelationship = /** @class */ (function () {
272
282
  return this.remotePKFields;
273
283
  }
274
284
  },
275
- enumerable: true,
285
+ enumerable: false,
276
286
  configurable: true
277
287
  });
278
288
  Object.defineProperty(ModelRelationship.prototype, "isComplete", {
@@ -283,7 +293,7 @@ var ModelRelationship = /** @class */ (function () {
283
293
  get: function () {
284
294
  return this.localJoinFields.length > 0 && this.remoteJoinFields.length > 0;
285
295
  },
286
- enumerable: true,
296
+ enumerable: false,
287
297
  configurable: true
288
298
  });
289
299
  /**
@@ -341,4 +351,3 @@ var ModelRelationship = /** @class */ (function () {
341
351
  return ModelRelationship;
342
352
  }());
343
353
  export { ModelRelationship };
344
- //# sourceMappingURL=relationship.js.map
@@ -4,11 +4,11 @@ import { ModelInstanceCreator } from '../datastore/datastore';
4
4
  import { InternalSchema, ModelInstanceMetadata, ModelPredicate, NamespaceResolver, OpType, PaginationInput, PersistentModel, PersistentModelConstructor, QueryOne, SchemaNamespace, InternalSubscriptionMessage, SubscriptionMessage } from '../types';
5
5
  import { NAMESPACES } from '../util';
6
6
  import { Adapter } from './adapter';
7
- export declare type StorageSubscriptionMessage<T extends PersistentModel> = InternalSubscriptionMessage<T> & {
7
+ export type StorageSubscriptionMessage<T extends PersistentModel> = InternalSubscriptionMessage<T> & {
8
8
  mutator?: Symbol;
9
9
  };
10
- export declare type StorageFacade = Omit<Adapter, 'setUp'>;
11
- export declare type Storage = InstanceType<typeof StorageClass>;
10
+ export type StorageFacade = Omit<Adapter, 'setUp'>;
11
+ export type Storage = InstanceType<typeof StorageClass>;
12
12
  declare class StorageClass implements StorageFacade {
13
13
  private readonly schema;
14
14
  private readonly namespaceResolver;
@@ -1,13 +1,95 @@
1
- import { __assign, __awaiter, __generator, __read, __rest, __values } from "tslib";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- import { Logger, Mutex } from '@aws-amplify/core';
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ var __read = (this && this.__read) || function (o, n) {
60
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
61
+ if (!m) return o;
62
+ var i = m.call(o), r, ar = [], e;
63
+ try {
64
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
65
+ }
66
+ catch (error) { e = { error: error }; }
67
+ finally {
68
+ try {
69
+ if (r && !r.done && (m = i["return"])) m.call(i);
70
+ }
71
+ finally { if (e) throw e.error; }
72
+ }
73
+ return ar;
74
+ };
75
+ var __values = (this && this.__values) || function(o) {
76
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
77
+ if (m) return m.call(o);
78
+ if (o && typeof o.length === "number") return {
79
+ next: function () {
80
+ if (o && i >= o.length) o = void 0;
81
+ return { value: o && o[i++], done: !o };
82
+ }
83
+ };
84
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
85
+ };
5
86
  import PushStream from 'zen-push';
6
87
  import { ModelPredicateCreator } from '../predicates';
7
88
  import { OpType, QueryOne, isTargetNameAssociation, } from '../types';
8
89
  import { isModelConstructor, STORAGE, validatePredicate, valuesEqual, } from '../util';
9
90
  import { getIdentifierValue } from '../sync/utils';
10
91
  import getDefaultAdapter from './adapter/getDefaultAdapter';
92
+ import { Logger, Mutex } from '@aws-amplify/core/internals/utils';
11
93
  var logger = new Logger('DataStore');
12
94
  var StorageClass = /** @class */ (function () {
13
95
  function StorageClass(schema, namespaceResolver, getModelConstructorByModelName, modelInstanceCreator, adapter, sessionId) {
@@ -420,10 +502,7 @@ var StorageClass = /** @class */ (function () {
420
502
  var id = originalElement.id, _version = originalElement._version, _lastChangedAt = originalElement._lastChangedAt, _deleted = originalElement._deleted;
421
503
  // For update mutations we only want to send fields with changes
422
504
  // and the required internal fields
423
- return __assign(__assign({}, updatedElement), { id: id,
424
- _version: _version,
425
- _lastChangedAt: _lastChangedAt,
426
- _deleted: _deleted });
505
+ return __assign(__assign({}, updatedElement), { id: id, _version: _version, _lastChangedAt: _lastChangedAt, _deleted: _deleted });
427
506
  };
428
507
  return StorageClass;
429
508
  }());
@@ -510,4 +589,3 @@ var ExclusiveStorage = /** @class */ (function () {
510
589
  return ExclusiveStorage;
511
590
  }());
512
591
  export { ExclusiveStorage };
513
- //# sourceMappingURL=storage.js.map
@@ -1,5 +1,5 @@
1
1
  import Observable from 'zen-observable-ts';
2
- declare type ConnectionStatus = {
2
+ type ConnectionStatus = {
3
3
  online: boolean;
4
4
  };
5
5
  export default class DataStoreConnectivity {
@@ -1,9 +1,55 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
2
48
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
49
  // SPDX-License-Identifier: Apache-2.0
4
50
  import Observable from 'zen-observable-ts';
5
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
6
51
  import { ReachabilityMonitor } from './datastoreReachability';
52
+ import { Logger } from '@aws-amplify/core/internals/utils';
7
53
  var logger = new Logger('DataStore');
8
54
  var RECONNECTING_IN = 5000; // 5s this may be configurable in the future
9
55
  var DataStoreConnectivity = /** @class */ (function () {
@@ -60,4 +106,3 @@ var DataStoreConnectivity = /** @class */ (function () {
60
106
  return DataStoreConnectivity;
61
107
  }());
62
108
  export default DataStoreConnectivity;
63
- //# sourceMappingURL=datastoreConnectivity.js.map
@@ -1,5 +1,4 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { Reachability } from '@aws-amplify/core';
3
+ import { Reachability } from '@aws-amplify/core/internals/utils';
4
4
  export var ReachabilityMonitor = new Reachability().networkMonitor();
5
- //# sourceMappingURL=index.js.map
@@ -1,6 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { Reachability } from '@aws-amplify/core';
3
+ import { Reachability } from '@aws-amplify/core/internals/utils';
4
4
  import { default as NetInfo } from '@react-native-community/netinfo';
5
5
  export var ReachabilityMonitor = new Reachability().networkMonitor(NetInfo);
6
- //# sourceMappingURL=index.native.js.map