@aws-amplify/datastore 5.0.1-console-preview.67f944e.0 → 5.0.1-console-preview.0bbe168.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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/datastore",
3
- "version": "5.0.1-console-preview.67f944e.0+67f944e",
3
+ "version": "5.0.1-console-preview.0bbe168.0+0bbe168",
4
4
  "description": "AppSyncLocal support for aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -47,21 +47,20 @@
47
47
  "ssr"
48
48
  ],
49
49
  "dependencies": {
50
- "@aws-amplify/api": "6.0.1-console-preview.67f944e.0+67f944e",
51
- "@aws-amplify/auth": "6.0.1-console-preview.67f944e.0+67f944e",
50
+ "@aws-amplify/api": "6.0.1-console-preview.0bbe168.0+0bbe168",
51
+ "@aws-amplify/auth": "6.0.1-console-preview.0bbe168.0+0bbe168",
52
52
  "buffer": "4.9.2",
53
53
  "idb": "5.0.6",
54
54
  "immer": "9.0.6",
55
+ "rxjs": "^7.8.1",
55
56
  "ulid": "^2.3.0",
56
- "uuid": "^9.0.0",
57
- "zen-observable-ts": "0.8.19",
58
- "zen-push": "0.2.1"
57
+ "uuid": "^9.0.0"
59
58
  },
60
59
  "peerDependencies": {
61
- "@aws-amplify/core": "6.0.1-console-preview.67f944e.0+67f944e"
60
+ "@aws-amplify/core": "6.0.1-console-preview.0bbe168.0+0bbe168"
62
61
  },
63
62
  "devDependencies": {
64
- "@aws-amplify/core": "6.0.1-console-preview.67f944e.0+67f944e",
63
+ "@aws-amplify/core": "6.0.1-console-preview.0bbe168.0+0bbe168",
65
64
  "@react-native-community/netinfo": "4.7.0",
66
65
  "@types/uuid": "^9.0.0",
67
66
  "@types/uuid-validate": "^0.0.1",
@@ -137,5 +136,5 @@
137
136
  "lib-esm"
138
137
  ]
139
138
  },
140
- "gitHead": "67f944e08acb70d5edf6743f5d23a048db1a57ae"
139
+ "gitHead": "0bbe168c66929877174b331c71f7666bb16529d6"
141
140
  }
@@ -12,7 +12,7 @@ import {
12
12
  Patch,
13
13
  } from 'immer';
14
14
  import { v4 as uuid4 } from 'uuid';
15
- import Observable, { ZenObservable } from 'zen-observable-ts';
15
+ import { Observable, SubscriptionLike, filter } from 'rxjs';
16
16
  import { defaultAuthStrategy, multiAuthStrategy } from '../authModeStrategies';
17
17
  import {
18
18
  isPredicatesAll,
@@ -1326,7 +1326,7 @@ async function checkSchemaVersion(
1326
1326
  });
1327
1327
  }
1328
1328
 
1329
- let syncSubscription: ZenObservable.Subscription;
1329
+ let syncSubscription: SubscriptionLike;
1330
1330
 
1331
1331
  function getNamespace(): SchemaNamespace {
1332
1332
  const namespace: SchemaNamespace = {
@@ -2117,7 +2117,7 @@ class DataStore {
2117
2117
  }
2118
2118
 
2119
2119
  return new Observable<SubscriptionMessage<T>>(observer => {
2120
- let source: ZenObservable.Subscription;
2120
+ let source: SubscriptionLike;
2121
2121
 
2122
2122
  this.runningProcesses
2123
2123
  .add(async () => {
@@ -2126,7 +2126,7 @@ class DataStore {
2126
2126
  // Filter the events returned by Storage according to namespace,
2127
2127
  // append original element data, and subscribe to the observable
2128
2128
  source = this.storage!.observe(modelConstructor)
2129
- .filter(({ model }) => namespaceResolver(model) === USER)
2129
+ .pipe(filter(({ model }) => namespaceResolver(model) === USER))
2130
2130
  .subscribe({
2131
2131
  next: item =>
2132
2132
  this.runningProcesses.isOpen &&
@@ -2200,7 +2200,7 @@ class DataStore {
2200
2200
  const items = new Map<string, T>();
2201
2201
  const itemsChanged = new Map<string, T>();
2202
2202
  let deletedItemIds: string[] = [];
2203
- let handle: ZenObservable.Subscription;
2203
+ let handle: SubscriptionLike;
2204
2204
  // let predicate: ModelPredicate<T> | undefined;
2205
2205
  let executivePredicate: GroupCondition | undefined;
2206
2206
 
@@ -1,7 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import Observable, { ZenObservable } from 'zen-observable-ts';
4
- import PushStream from 'zen-push';
3
+ import { Observable, filter, map, Subject } from 'rxjs';
5
4
  import { Patch } from 'immer';
6
5
  import { ModelInstanceCreator } from '../datastore/datastore';
7
6
  import { ModelPredicateCreator } from '../predicates';
@@ -44,10 +43,8 @@ export type Storage = InstanceType<typeof StorageClass>;
44
43
  const logger = new Logger('DataStore');
45
44
  class StorageClass implements StorageFacade {
46
45
  private initialized: Promise<void> | undefined;
47
- private readonly pushStream: {
48
- observable: Observable<StorageSubscriptionMessage<PersistentModel>>;
49
- } & Required<
50
- ZenObservable.Observer<StorageSubscriptionMessage<PersistentModel>>
46
+ private readonly pushStream: Subject<
47
+ StorageSubscriptionMessage<PersistentModel>
51
48
  >;
52
49
 
53
50
  constructor(
@@ -62,7 +59,7 @@ class StorageClass implements StorageFacade {
62
59
  private readonly sessionId?: string
63
60
  ) {
64
61
  this.adapter = this.adapter || getDefaultAdapter();
65
- this.pushStream = new PushStream();
62
+ this.pushStream = new Subject();
66
63
  }
67
64
 
68
65
  static getNamespace() {
@@ -285,26 +282,33 @@ class StorageClass implements StorageFacade {
285
282
  (predicate && ModelPredicateCreator.getPredicates(predicate, false)) ||
286
283
  {};
287
284
 
288
- let result = this.pushStream.observable
289
- .filter(({ mutator }) => {
290
- return !skipOwn || mutator !== skipOwn;
291
- })
292
- .map(
293
- ({ mutator: _mutator, ...message }) => message as SubscriptionMessage<T>
285
+ let result = this.pushStream
286
+ .pipe(
287
+ filter(({ mutator }) => {
288
+ return !skipOwn || mutator !== skipOwn;
289
+ })
290
+ )
291
+ .pipe(
292
+ map(
293
+ ({ mutator: _mutator, ...message }) =>
294
+ message as SubscriptionMessage<T>
295
+ )
294
296
  );
295
297
 
296
298
  if (!listenToAll) {
297
- result = result.filter(({ model, element }) => {
298
- if (modelConstructor !== model) {
299
- return false;
300
- }
299
+ result = result.pipe(
300
+ filter(({ model, element }) => {
301
+ if (modelConstructor !== model) {
302
+ return false;
303
+ }
301
304
 
302
- if (!!predicates && !!type) {
303
- return validatePredicate(element, type, predicates);
304
- }
305
+ if (!!predicates && !!type) {
306
+ return validatePredicate(element, type, predicates);
307
+ }
305
308
 
306
- return true;
307
- });
309
+ return true;
310
+ })
311
+ );
308
312
  }
309
313
 
310
314
  return result;
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import Observable, { ZenObservable } from 'zen-observable-ts';
3
+ import { Observable, Observer, SubscriptionLike } from 'rxjs';
4
4
  import { ReachabilityMonitor } from './datastoreReachability';
5
5
  import { Logger } from '@aws-amplify/core/internals/utils';
6
6
 
@@ -15,8 +15,8 @@ type ConnectionStatus = {
15
15
 
16
16
  export default class DataStoreConnectivity {
17
17
  private connectionStatus: ConnectionStatus;
18
- private observer!: ZenObservable.SubscriptionObserver<ConnectionStatus>;
19
- private subscription!: ZenObservable.Subscription;
18
+ private observer!: Observer<ConnectionStatus>;
19
+ private subscription!: SubscriptionLike;
20
20
  private timeout!: ReturnType<typeof setTimeout>;
21
21
  constructor() {
22
22
  this.connectionStatus = {
package/src/sync/index.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  } from '@aws-amplify/core/internals/utils';
7
7
  import { Hub } from '@aws-amplify/core';
8
8
 
9
- import Observable, { ZenObservable } from 'zen-observable-ts';
9
+ import { filter, Observable, Observer, of, SubscriptionLike } from 'rxjs';
10
10
  import { ModelInstanceCreator } from '../datastore/datastore';
11
11
  import { ModelPredicateCreator } from '../predicates';
12
12
  import { ExclusiveStorage as Storage } from '../storage/storage';
@@ -215,7 +215,7 @@ export class SyncEngine {
215
215
  return new Observable<ControlMessageType<ControlMessage>>(observer => {
216
216
  logger.log('starting sync engine...');
217
217
 
218
- let subscriptions: ZenObservable.Subscription[] = [];
218
+ let subscriptions: SubscriptionLike[] = [];
219
219
 
220
220
  this.runningProcesses.add(async () => {
221
221
  try {
@@ -416,10 +416,12 @@ export class SyncEngine {
416
416
 
417
417
  this.storage
418
418
  .observe(null, null, ownSymbol)
419
- .filter(({ model }) => {
420
- const modelDefinition = this.getModelDefinition(model);
421
- return modelDefinition.syncable === true;
422
- })
419
+ .pipe(
420
+ filter(({ model }) => {
421
+ const modelDefinition = this.getModelDefinition(model);
422
+ return modelDefinition.syncable === true;
423
+ })
424
+ )
423
425
  .subscribe({
424
426
  next: async ({ opType, model, element, condition }) =>
425
427
  this.runningProcesses.add(async () => {
@@ -531,11 +533,11 @@ export class SyncEngine {
531
533
  ControlMessageType<ControlMessage>
532
534
  > {
533
535
  if (!this.online) {
534
- return Observable.of<ControlMessageType<ControlMessage>>();
536
+ return of<ControlMessageType<ControlMessage>>({} as any); // TODO(v6): fix this
535
537
  }
536
538
 
537
539
  return new Observable<ControlMessageType<ControlMessage>>(observer => {
538
- let syncQueriesSubscription: ZenObservable.Subscription;
540
+ let syncQueriesSubscription: SubscriptionLike;
539
541
 
540
542
  this.runningProcesses.isOpen &&
541
543
  this.runningProcesses.add(async onTerminate => {
@@ -15,7 +15,7 @@ import {
15
15
  AmplifyError,
16
16
  } from '@aws-amplify/core/internals/utils';
17
17
 
18
- import Observable, { ZenObservable } from 'zen-observable-ts';
18
+ import { Observable, Observer } from 'rxjs';
19
19
  import { MutationEvent } from '../';
20
20
  import { ModelInstanceCreator } from '../../datastore/datastore';
21
21
  import { ExclusiveStorage as Storage } from '../../storage/storage';
@@ -68,7 +68,7 @@ class MutationProcessor {
68
68
  * yet started. In this case, `isReady()` will be `false` and `resume()` will exit
69
69
  * early.
70
70
  */
71
- private observer?: ZenObservable.Observer<MutationProcessorEvent>;
71
+ private observer?: Observer<MutationProcessorEvent>;
72
72
  private readonly typeQuery = new WeakMap<
73
73
  SchemaModel,
74
74
  [TransformerMutationType, string, string][]
@@ -14,7 +14,7 @@ import {
14
14
  JwtPayload,
15
15
  } from '@aws-amplify/core/internals/utils';
16
16
 
17
- import Observable, { ZenObservable } from 'zen-observable-ts';
17
+ import { Observable, Observer, SubscriptionLike } from 'rxjs';
18
18
  import {
19
19
  InternalSchema,
20
20
  PersistentModel,
@@ -73,7 +73,7 @@ class SubscriptionProcessor {
73
73
  >();
74
74
  private buffer: [TransformerMutationType, SchemaModel, PersistentModel][] =
75
75
  [];
76
- private dataObserver!: ZenObservable.Observer<any>;
76
+ private dataObserver!: Observer<any>;
77
77
 
78
78
  private runningProcesses = new BackgroundProcessManager();
79
79
 
@@ -255,9 +255,9 @@ class SubscriptionProcessor {
255
255
  // independently, since the auth retry behavior is asynchronous.
256
256
  let subscriptions: {
257
257
  [modelName: string]: {
258
- [TransformerMutationType.CREATE]: ZenObservable.Subscription[];
259
- [TransformerMutationType.UPDATE]: ZenObservable.Subscription[];
260
- [TransformerMutationType.DELETE]: ZenObservable.Subscription[];
258
+ [TransformerMutationType.CREATE]: SubscriptionLike[];
259
+ [TransformerMutationType.UPDATE]: SubscriptionLike[];
260
+ [TransformerMutationType.DELETE]: SubscriptionLike[];
261
261
  };
262
262
  } = {};
263
263
  let oidcTokenPayload: JwtPayload | undefined;
@@ -407,7 +407,6 @@ class SubscriptionProcessor {
407
407
  transformerMutationType
408
408
  ].push(
409
409
  queryObservable
410
- .filter(() => true) // to make change more readable
411
410
  .subscribe({
412
411
  next: result => {
413
412
  const { data, errors } = result;
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { GraphQLResult } from '@aws-amplify/api';
4
4
  import { InternalAPI } from '@aws-amplify/api/internals';
5
- import Observable from 'zen-observable-ts';
5
+ import { Observable } from 'rxjs';
6
6
  import {
7
7
  InternalSchema,
8
8
  ModelInstanceMetadata,