@aws-amplify/datastore 3.7.6-unstable.3 → 3.7.7-cloud-logging.3
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.
- package/CHANGELOG.md +11 -0
- package/dist/aws-amplify-datastore.js +530 -331
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +4 -4
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/datastore/datastore.js +24 -13
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/storage/adapter/index.d.ts +1 -0
- package/lib/storage/storage.d.ts +2 -0
- package/lib/storage/storage.js +24 -0
- package/lib/storage/storage.js.map +1 -1
- package/lib/sync/index.d.ts +1 -3
- package/lib/sync/index.js +1 -3
- package/lib/sync/index.js.map +1 -1
- package/lib-esm/datastore/datastore.js +24 -13
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/storage/adapter/index.d.ts +1 -0
- package/lib-esm/storage/storage.d.ts +2 -0
- package/lib-esm/storage/storage.js +24 -0
- package/lib-esm/storage/storage.js.map +1 -1
- package/lib-esm/sync/index.d.ts +1 -3
- package/lib-esm/sync/index.js +1 -3
- package/lib-esm/sync/index.js.map +1 -1
- package/package.json +7 -7
- package/src/datastore/datastore.ts +15 -6
- package/src/storage/adapter/index.ts +1 -0
- package/src/storage/storage.ts +11 -0
- package/src/sync/index.ts +23 -32
package/src/sync/index.ts
CHANGED
|
@@ -113,8 +113,6 @@ export class SyncEngine {
|
|
|
113
113
|
private readonly userModelClasses: TypeConstructorMap,
|
|
114
114
|
private readonly storage: Storage,
|
|
115
115
|
private readonly modelInstanceCreator: ModelInstanceCreator,
|
|
116
|
-
private readonly maxRecordsToSync: number,
|
|
117
|
-
private readonly syncPageSize: number,
|
|
118
116
|
conflictHandler: ConflictHandler,
|
|
119
117
|
errorHandler: ErrorHandler,
|
|
120
118
|
private readonly syncPredicates: WeakMap<SchemaModel, ModelPredicate<any>>,
|
|
@@ -189,11 +187,9 @@ export class SyncEngine {
|
|
|
189
187
|
});
|
|
190
188
|
|
|
191
189
|
let ctlSubsObservable: Observable<CONTROL_MSG>;
|
|
192
|
-
let dataSubsObservable: Observable<
|
|
193
|
-
TransformerMutationType,
|
|
194
|
-
|
|
195
|
-
PersistentModel
|
|
196
|
-
]>;
|
|
190
|
+
let dataSubsObservable: Observable<
|
|
191
|
+
[TransformerMutationType, SchemaModel, PersistentModel]
|
|
192
|
+
>;
|
|
197
193
|
|
|
198
194
|
if (isNode) {
|
|
199
195
|
logger.warn(
|
|
@@ -244,8 +240,8 @@ export class SyncEngine {
|
|
|
244
240
|
//#region Base & Sync queries
|
|
245
241
|
try {
|
|
246
242
|
await new Promise((resolve, reject) => {
|
|
247
|
-
const syncQuerySubscription =
|
|
248
|
-
{
|
|
243
|
+
const syncQuerySubscription =
|
|
244
|
+
this.syncQueriesObservable().subscribe({
|
|
249
245
|
next: message => {
|
|
250
246
|
const { type } = message;
|
|
251
247
|
|
|
@@ -263,8 +259,7 @@ export class SyncEngine {
|
|
|
263
259
|
error: error => {
|
|
264
260
|
reject(error);
|
|
265
261
|
},
|
|
266
|
-
}
|
|
267
|
-
);
|
|
262
|
+
});
|
|
268
263
|
|
|
269
264
|
if (syncQuerySubscription) {
|
|
270
265
|
subscriptions.push(syncQuerySubscription);
|
|
@@ -295,8 +290,7 @@ export class SyncEngine {
|
|
|
295
290
|
);
|
|
296
291
|
|
|
297
292
|
observer.next({
|
|
298
|
-
type:
|
|
299
|
-
ControlMessage.SYNC_ENGINE_OUTBOX_MUTATION_PROCESSED,
|
|
293
|
+
type: ControlMessage.SYNC_ENGINE_OUTBOX_MUTATION_PROCESSED,
|
|
300
294
|
data: {
|
|
301
295
|
model: modelConstructor,
|
|
302
296
|
element: model,
|
|
@@ -363,9 +357,8 @@ export class SyncEngine {
|
|
|
363
357
|
})
|
|
364
358
|
.subscribe({
|
|
365
359
|
next: async ({ opType, model, element, condition }) => {
|
|
366
|
-
const namespace =
|
|
367
|
-
this.namespaceResolver(model)
|
|
368
|
-
];
|
|
360
|
+
const namespace =
|
|
361
|
+
this.schema.namespaces[this.namespaceResolver(model)];
|
|
369
362
|
const MutationEventConstructor = this.modelClasses[
|
|
370
363
|
'MutationEvent'
|
|
371
364
|
] as PersistentModelConstructor<MutationEvent>;
|
|
@@ -603,16 +596,15 @@ export class SyncEngine {
|
|
|
603
596
|
isFullSync ? startedAt : lastFullSync
|
|
604
597
|
);
|
|
605
598
|
|
|
606
|
-
modelMetadata = (
|
|
607
|
-
.
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
);
|
|
599
|
+
modelMetadata = (
|
|
600
|
+
this.modelClasses
|
|
601
|
+
.ModelMetadata as PersistentModelConstructor<any>
|
|
602
|
+
).copyOf(modelMetadata, draft => {
|
|
603
|
+
draft.lastSync = startedAt;
|
|
604
|
+
draft.lastFullSync = isFullSync
|
|
605
|
+
? startedAt
|
|
606
|
+
: modelMetadata.lastFullSync;
|
|
607
|
+
});
|
|
616
608
|
|
|
617
609
|
await this.storage.save(
|
|
618
610
|
modelMetadata,
|
|
@@ -757,9 +749,9 @@ export class SyncEngine {
|
|
|
757
749
|
const syncPredicateUpdated = prevSyncPredicate !== lastSyncPredicate;
|
|
758
750
|
|
|
759
751
|
[[savedModel]] = await this.storage.save(
|
|
760
|
-
(
|
|
761
|
-
any
|
|
762
|
-
|
|
752
|
+
(
|
|
753
|
+
this.modelClasses.ModelMetadata as PersistentModelConstructor<any>
|
|
754
|
+
).copyOf(modelMetadata, draft => {
|
|
763
755
|
draft.fullSyncInterval = fullSyncInterval;
|
|
764
756
|
// perform a base sync if the syncPredicate changed in between calls to DataStore.start
|
|
765
757
|
// ensures that the local store contains all the data specified by the syncExpression
|
|
@@ -819,9 +811,8 @@ export class SyncEngine {
|
|
|
819
811
|
): SchemaModel {
|
|
820
812
|
const namespaceName = this.namespaceResolver(modelConstructor);
|
|
821
813
|
|
|
822
|
-
const modelDefinition =
|
|
823
|
-
modelConstructor.name
|
|
824
|
-
];
|
|
814
|
+
const modelDefinition =
|
|
815
|
+
this.schema.namespaces[namespaceName].models[modelConstructor.name];
|
|
825
816
|
|
|
826
817
|
return modelDefinition;
|
|
827
818
|
}
|