@aws-amplify/datastore 5.0.1-console-preview.431c340.0 → 5.0.1-console-preview.4b7d177.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 (42) hide show
  1. package/lib/datastore/datastore.d.ts +1 -1
  2. package/lib/datastore/datastore.js +5 -8
  3. package/lib/storage/storage.d.ts +1 -1
  4. package/lib/storage/storage.js +11 -9
  5. package/lib/sync/datastoreConnectivity.d.ts +1 -1
  6. package/lib/sync/datastoreConnectivity.js +2 -5
  7. package/lib/sync/datastoreReachability/index.d.ts +1 -3
  8. package/lib/sync/datastoreReachability/index.native.d.ts +1 -3
  9. package/lib/sync/index.d.ts +1 -1
  10. package/lib/sync/index.js +6 -6
  11. package/lib/sync/processors/mutation.d.ts +1 -1
  12. package/lib/sync/processors/mutation.js +2 -5
  13. package/lib/sync/processors/subscription.d.ts +1 -1
  14. package/lib/sync/processors/subscription.js +3 -7
  15. package/lib/sync/processors/sync.d.ts +1 -1
  16. package/lib/sync/processors/sync.js +2 -5
  17. package/lib/tsconfig.tsbuildinfo +1 -1
  18. package/lib-esm/datastore/datastore.d.ts +1 -1
  19. package/lib-esm/datastore/datastore.js +3 -3
  20. package/lib-esm/storage/storage.d.ts +1 -1
  21. package/lib-esm/storage/storage.js +11 -9
  22. package/lib-esm/sync/datastoreConnectivity.d.ts +1 -1
  23. package/lib-esm/sync/datastoreConnectivity.js +1 -1
  24. package/lib-esm/sync/datastoreReachability/index.d.ts +1 -3
  25. package/lib-esm/sync/datastoreReachability/index.native.d.ts +1 -3
  26. package/lib-esm/sync/index.d.ts +1 -1
  27. package/lib-esm/sync/index.js +4 -4
  28. package/lib-esm/sync/processors/mutation.d.ts +1 -1
  29. package/lib-esm/sync/processors/mutation.js +1 -1
  30. package/lib-esm/sync/processors/subscription.d.ts +1 -1
  31. package/lib-esm/sync/processors/subscription.js +1 -2
  32. package/lib-esm/sync/processors/sync.d.ts +1 -1
  33. package/lib-esm/sync/processors/sync.js +1 -1
  34. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +8 -9
  36. package/src/datastore/datastore.ts +5 -5
  37. package/src/storage/storage.ts +26 -22
  38. package/src/sync/datastoreConnectivity.ts +3 -3
  39. package/src/sync/index.ts +10 -8
  40. package/src/sync/processors/mutation.ts +2 -2
  41. package/src/sync/processors/subscription.ts +5 -6
  42. package/src/sync/processors/sync.ts +1 -1
@@ -1,4 +1,4 @@
1
- import Observable from 'zen-observable-ts';
1
+ import { Observable } from 'rxjs';
2
2
  import { PredicateAll } from '../predicates';
3
3
  import { ConflictHandler, DataStoreConfig, ProducerPaginationInput, PersistentModel, PersistentModelConstructor, Schema, SubscriptionMessage, DataStoreSnapshot, TypeConstructorMap, ErrorHandler, ObserveQueryOptions, PersistentModelMetaData, IdentifierFieldOrIdentifierObject, RecursiveModelPredicateExtender, ModelPredicateExtender } from '../types';
4
4
  export declare let syncClasses: TypeConstructorMap;
@@ -115,9 +115,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
115
115
  }
116
116
  return to.concat(ar || Array.prototype.slice.call(from));
117
117
  };
118
- var __importDefault = (this && this.__importDefault) || function (mod) {
119
- return (mod && mod.__esModule) ? mod : { "default": mod };
120
- };
121
118
  Object.defineProperty(exports, "__esModule", { value: true });
122
119
  exports.DataStore = exports.initSchema = exports.DataStoreClass = exports.AsyncCollection = exports.AsyncItem = exports.getAttachment = exports.attached = exports.syncClasses = void 0;
123
120
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -126,7 +123,7 @@ var internals_1 = require("@aws-amplify/api/internals");
126
123
  var core_1 = require("@aws-amplify/core");
127
124
  var immer_1 = require("immer");
128
125
  var uuid_1 = require("uuid");
129
- var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
126
+ var rxjs_1 = require("rxjs");
130
127
  var authModeStrategies_1 = require("../authModeStrategies");
131
128
  var predicates_1 = require("../predicates");
132
129
  var storage_1 = require("../storage/storage");
@@ -1758,7 +1755,7 @@ var DataStore = /** @class */ (function () {
1758
1755
  else if (modelConstructor && typeof identifierOrCriteria === 'function') {
1759
1756
  executivePredicate = (0, next_1.internals)(identifierOrCriteria(buildSeedPredicate(modelConstructor)));
1760
1757
  }
1761
- return new zen_observable_ts_1.default(function (observer) {
1758
+ return new rxjs_1.Observable(function (observer) {
1762
1759
  var source;
1763
1760
  _this.runningProcesses
1764
1761
  .add(function () { return __awaiter(_this, void 0, void 0, function () {
@@ -1771,10 +1768,10 @@ var DataStore = /** @class */ (function () {
1771
1768
  // Filter the events returned by Storage according to namespace,
1772
1769
  // append original element data, and subscribe to the observable
1773
1770
  source = this.storage.observe(modelConstructor)
1774
- .filter(function (_a) {
1771
+ .pipe((0, rxjs_1.filter)(function (_a) {
1775
1772
  var model = _a.model;
1776
1773
  return namespaceResolver(model) === util_1.USER;
1777
- })
1774
+ }))
1778
1775
  .subscribe({
1779
1776
  next: function (item) {
1780
1777
  return _this.runningProcesses.isOpen &&
@@ -1834,7 +1831,7 @@ var DataStore = /** @class */ (function () {
1834
1831
  });
1835
1832
  };
1836
1833
  this.observeQuery = function (model, criteria, options) {
1837
- return new zen_observable_ts_1.default(function (observer) {
1834
+ return new rxjs_1.Observable(function (observer) {
1838
1835
  var items = new Map();
1839
1836
  var itemsChanged = new Map();
1840
1837
  var deletedItemIds = [];
@@ -1,4 +1,4 @@
1
- import Observable from 'zen-observable-ts';
1
+ import { Observable } from 'rxjs';
2
2
  import { Patch } from 'immer';
3
3
  import { ModelInstanceCreator } from '../datastore/datastore';
4
4
  import { InternalSchema, ModelInstanceMetadata, ModelPredicate, NamespaceResolver, OpType, PaginationInput, PersistentModel, PersistentModelConstructor, QueryOne, SchemaNamespace, InternalSubscriptionMessage, SubscriptionMessage } from '../types';
@@ -89,7 +89,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
89
89
  };
90
90
  Object.defineProperty(exports, "__esModule", { value: true });
91
91
  exports.ExclusiveStorage = void 0;
92
- var zen_push_1 = __importDefault(require("zen-push"));
92
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
93
+ // SPDX-License-Identifier: Apache-2.0
94
+ var rxjs_1 = require("rxjs");
93
95
  var predicates_1 = require("../predicates");
94
96
  var types_1 = require("../types");
95
97
  var util_1 = require("../util");
@@ -106,7 +108,7 @@ var StorageClass = /** @class */ (function () {
106
108
  this.adapter = adapter;
107
109
  this.sessionId = sessionId;
108
110
  this.adapter = this.adapter || (0, getDefaultAdapter_1.default)();
109
- this.pushStream = new zen_push_1.default();
111
+ this.pushStream = new rxjs_1.Subject();
110
112
  }
111
113
  StorageClass.getNamespace = function () {
112
114
  var namespace = {
@@ -295,17 +297,17 @@ var StorageClass = /** @class */ (function () {
295
297
  var listenToAll = !modelConstructor;
296
298
  var _a = (predicate && predicates_1.ModelPredicateCreator.getPredicates(predicate, false)) ||
297
299
  {}, predicates = _a.predicates, type = _a.type;
298
- var result = this.pushStream.observable
299
- .filter(function (_a) {
300
+ var result = this.pushStream
301
+ .pipe((0, rxjs_1.filter)(function (_a) {
300
302
  var mutator = _a.mutator;
301
303
  return !skipOwn || mutator !== skipOwn;
302
- })
303
- .map(function (_a) {
304
+ }))
305
+ .pipe((0, rxjs_1.map)(function (_a) {
304
306
  var _mutator = _a.mutator, message = __rest(_a, ["mutator"]);
305
307
  return message;
306
- });
308
+ }));
307
309
  if (!listenToAll) {
308
- result = result.filter(function (_a) {
310
+ result = result.pipe((0, rxjs_1.filter)(function (_a) {
309
311
  var model = _a.model, element = _a.element;
310
312
  if (modelConstructor !== model) {
311
313
  return false;
@@ -314,7 +316,7 @@ var StorageClass = /** @class */ (function () {
314
316
  return (0, util_1.validatePredicate)(element, type, predicates);
315
317
  }
316
318
  return true;
317
- });
319
+ }));
318
320
  }
319
321
  return result;
320
322
  };
@@ -1,4 +1,4 @@
1
- import Observable from 'zen-observable-ts';
1
+ import { Observable } from 'rxjs';
2
2
  type ConnectionStatus = {
3
3
  online: boolean;
4
4
  };
@@ -46,13 +46,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
49
  Object.defineProperty(exports, "__esModule", { value: true });
53
50
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
54
51
  // SPDX-License-Identifier: Apache-2.0
55
- var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
52
+ var rxjs_1 = require("rxjs");
56
53
  var datastoreReachability_1 = require("./datastoreReachability");
57
54
  var utils_1 = require("@aws-amplify/core/internals/utils");
58
55
  var logger = new utils_1.Logger('DataStore');
@@ -68,7 +65,7 @@ var DataStoreConnectivity = /** @class */ (function () {
68
65
  if (this.observer) {
69
66
  throw new Error('Subscriber already exists');
70
67
  }
71
- return new zen_observable_ts_1.default(function (observer) {
68
+ return new rxjs_1.Observable(function (observer) {
72
69
  _this.observer = observer;
73
70
  // Will be used to forward socket connection changes, enhancing Reachability
74
71
  _this.subscription = datastoreReachability_1.ReachabilityMonitor.subscribe(function (_a) {
@@ -1,3 +1 @@
1
- export declare const ReachabilityMonitor: import("zen-observable-ts").default<{
2
- online: boolean;
3
- }>;
1
+ export declare const ReachabilityMonitor: import("rxjs").Observable<import("@aws-amplify/core/lib-esm/Reachability/types").NetworkStatus>;
@@ -1,3 +1 @@
1
- export declare const ReachabilityMonitor: import("zen-observable-ts").default<{
2
- online: boolean;
3
- }>;
1
+ export declare const ReachabilityMonitor: import("rxjs").Observable<import("@aws-amplify/core/lib-esm/Reachability/types").NetworkStatus>;
@@ -1,4 +1,4 @@
1
- import Observable from 'zen-observable-ts';
1
+ import { Observable } from 'rxjs';
2
2
  import { ModelInstanceCreator } from '../datastore/datastore';
3
3
  import { ExclusiveStorage as Storage } from '../storage/storage';
4
4
  import { ConflictHandler, ControlMessageType, ErrorHandler, InternalSchema, ModelInit, MutableModel, NamespaceResolver, PersistentModelConstructor, SchemaModel, SchemaNamespace, TypeConstructorMap, ModelPredicate, AuthModeStrategy, ManagedIdentifier, OptionallyManagedIdentifier, AmplifyContext } from '../types';
package/lib/sync/index.js CHANGED
@@ -80,7 +80,7 @@ exports.SyncEngine = exports.ControlMessage = void 0;
80
80
  // SPDX-License-Identifier: Apache-2.0
81
81
  var utils_1 = require("@aws-amplify/core/internals/utils");
82
82
  var core_1 = require("@aws-amplify/core");
83
- var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
83
+ var rxjs_1 = require("rxjs");
84
84
  var predicates_1 = require("../predicates");
85
85
  var types_1 = require("../types");
86
86
  var util_1 = require("../util");
@@ -143,7 +143,7 @@ var SyncEngine = /** @class */ (function () {
143
143
  };
144
144
  SyncEngine.prototype.start = function (params) {
145
145
  var _this = this;
146
- return new zen_observable_ts_1.default(function (observer) {
146
+ return new rxjs_1.Observable(function (observer) {
147
147
  logger.log('starting sync engine...');
148
148
  var subscriptions = [];
149
149
  _this.runningProcesses.add(function () { return __awaiter(_this, void 0, void 0, function () {
@@ -339,11 +339,11 @@ var SyncEngine = /** @class */ (function () {
339
339
  });
340
340
  this.storage
341
341
  .observe(null, null, ownSymbol)
342
- .filter(function (_a) {
342
+ .pipe((0, rxjs_1.filter)(function (_a) {
343
343
  var model = _a.model;
344
344
  var modelDefinition = _this.getModelDefinition(model);
345
345
  return modelDefinition.syncable === true;
346
- })
346
+ }))
347
347
  .subscribe({
348
348
  next: function (_a) {
349
349
  var opType = _a.opType, model = _a.model, element = _a.element, condition = _a.condition;
@@ -444,9 +444,9 @@ var SyncEngine = /** @class */ (function () {
444
444
  SyncEngine.prototype.syncQueriesObservable = function () {
445
445
  var _this = this;
446
446
  if (!this.online) {
447
- return zen_observable_ts_1.default.of();
447
+ return (0, rxjs_1.of)({}); // TODO(v6): fix this
448
448
  }
449
- return new zen_observable_ts_1.default(function (observer) {
449
+ return new rxjs_1.Observable(function (observer) {
450
450
  var syncQueriesSubscription;
451
451
  _this.runningProcesses.isOpen &&
452
452
  _this.runningProcesses.add(function (onTerminate) { return __awaiter(_this, void 0, void 0, function () {
@@ -1,4 +1,4 @@
1
- import Observable from 'zen-observable-ts';
1
+ 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';
@@ -84,14 +84,11 @@ var __values = (this && this.__values) || function(o) {
84
84
  };
85
85
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
86
86
  };
87
- var __importDefault = (this && this.__importDefault) || function (mod) {
88
- return (mod && mod.__esModule) ? mod : { "default": mod };
89
- };
90
87
  Object.defineProperty(exports, "__esModule", { value: true });
91
88
  exports.MutationProcessor = exports.safeJitteredBackoff = void 0;
92
89
  var internals_1 = require("@aws-amplify/api/internals");
93
90
  var utils_1 = require("@aws-amplify/core/internals/utils");
94
- var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
91
+ var rxjs_1 = require("rxjs");
95
92
  var types_1 = require("../../types");
96
93
  var util_1 = require("../../util");
97
94
  var utils_2 = require("../utils");
@@ -145,7 +142,7 @@ var MutationProcessor = /** @class */ (function () {
145
142
  MutationProcessor.prototype.start = function () {
146
143
  var _this = this;
147
144
  this.runningProcesses = new utils_1.BackgroundProcessManager();
148
- var observable = new zen_observable_ts_1.default(function (observer) {
145
+ var observable = new rxjs_1.Observable(function (observer) {
149
146
  _this.observer = observer;
150
147
  try {
151
148
  _this.resume();
@@ -1,4 +1,4 @@
1
- import Observable from 'zen-observable-ts';
1
+ import { Observable } from 'rxjs';
2
2
  import { InternalSchema, PersistentModel, SchemaModel, ModelPredicate, AuthModeStrategy, ErrorHandler, AmplifyContext } from '../../types';
3
3
  import { TransformerMutationType } from '../utils';
4
4
  export declare enum CONTROL_MSG {
@@ -71,15 +71,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
71
71
  }
72
72
  return to.concat(ar || Array.prototype.slice.call(from));
73
73
  };
74
- var __importDefault = (this && this.__importDefault) || function (mod) {
75
- return (mod && mod.__esModule) ? mod : { "default": mod };
76
- };
77
74
  Object.defineProperty(exports, "__esModule", { value: true });
78
75
  exports.SubscriptionProcessor = exports.USER_CREDENTIALS = exports.CONTROL_MSG = void 0;
79
76
  var internals_1 = require("@aws-amplify/api/internals");
80
77
  var core_1 = require("@aws-amplify/core");
81
78
  var utils_1 = require("@aws-amplify/core/internals/utils");
82
- var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
79
+ var rxjs_1 = require("rxjs");
83
80
  var types_1 = require("../../types");
84
81
  var utils_2 = require("../utils");
85
82
  var predicates_1 = require("../../predicates");
@@ -198,7 +195,7 @@ var SubscriptionProcessor = /** @class */ (function () {
198
195
  var _this = this;
199
196
  this.runningProcesses =
200
197
  this.runningProcesses || new utils_1.BackgroundProcessManager();
201
- var ctlObservable = new zen_observable_ts_1.default(function (observer) {
198
+ var ctlObservable = new rxjs_1.Observable(function (observer) {
202
199
  var promises = [];
203
200
  // Creating subs for each model/operation combo so they can be unsubscribed
204
201
  // independently, since the auth retry behavior is asynchronous.
@@ -307,7 +304,6 @@ var SubscriptionProcessor = /** @class */ (function () {
307
304
  queryObservable = this.amplifyContext.InternalAPI.graphql(__assign(__assign({ query: query, variables: variables }, { authMode: authMode }), { authToken: authToken }), undefined, customUserAgentDetails);
308
305
  // TODO: consider onTerminate.then(() => API.cancel(...))
309
306
  subscriptions[modelDefinition.name][transformerMutationType].push(queryObservable
310
- .filter(function () { return true; }) // to make change more readable
311
307
  .subscribe({
312
308
  next: function (result) {
313
309
  var data = result.data, errors = result.errors;
@@ -462,7 +458,7 @@ var SubscriptionProcessor = /** @class */ (function () {
462
458
  });
463
459
  }); });
464
460
  });
465
- var dataObservable = new zen_observable_ts_1.default(function (observer) {
461
+ var dataObservable = new rxjs_1.Observable(function (observer) {
466
462
  _this.dataObserver = observer;
467
463
  _this.drainBuffer();
468
464
  return _this.runningProcesses.addCleaner(function () { return __awaiter(_this, void 0, void 0, function () {
@@ -1,4 +1,4 @@
1
- import Observable from 'zen-observable-ts';
1
+ import { Observable } from 'rxjs';
2
2
  import { InternalSchema, ModelInstanceMetadata, SchemaModel, ModelPredicate, AuthModeStrategy, ErrorHandler, AmplifyContext } from '../../types';
3
3
  declare class SyncProcessor {
4
4
  private readonly schema;
@@ -62,13 +62,10 @@ var __values = (this && this.__values) || function(o) {
62
62
  };
63
63
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
64
64
  };
65
- var __importDefault = (this && this.__importDefault) || function (mod) {
66
- return (mod && mod.__esModule) ? mod : { "default": mod };
67
- };
68
65
  Object.defineProperty(exports, "__esModule", { value: true });
69
66
  exports.SyncProcessor = void 0;
70
67
  var internals_1 = require("@aws-amplify/api/internals");
71
- var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
68
+ var rxjs_1 = require("rxjs");
72
69
  var types_1 = require("../../types");
73
70
  var utils_1 = require("../utils");
74
71
  var utils_2 = require("@aws-amplify/core/internals/utils");
@@ -346,7 +343,7 @@ var SyncProcessor = /** @class */ (function () {
346
343
  var _this = this;
347
344
  var _a = this.amplifyConfig, maxRecordsToSync = _a.maxRecordsToSync, syncPageSize = _a.syncPageSize;
348
345
  var parentPromises = new Map();
349
- var observable = new zen_observable_ts_1.default(function (observer) {
346
+ var observable = new rxjs_1.Observable(function (observer) {
350
347
  var sortedTypesLastSyncs = Object.values(_this.schema.namespaces).reduce(function (map, namespace) {
351
348
  var e_2, _a;
352
349
  try {