@aws-amplify/datastore 3.7.7-unstable.8 → 3.7.8-cloud-logging.7
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 +8 -0
- package/dist/aws-amplify-datastore.js +380 -130
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +7 -7
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/datastore/datastore.js +18 -9
- 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.js +20 -13
- package/lib/sync/index.js.map +1 -1
- package/lib/sync/processors/mutation.js +1 -0
- package/lib/sync/processors/mutation.js.map +1 -1
- package/lib/types.d.ts +1 -0
- package/lib/types.js.map +1 -1
- package/lib-esm/datastore/datastore.js +18 -9
- 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.js +20 -13
- package/lib-esm/sync/index.js.map +1 -1
- package/lib-esm/sync/processors/mutation.js +1 -0
- package/lib-esm/sync/processors/mutation.js.map +1 -1
- package/lib-esm/types.d.ts +1 -0
- package/lib-esm/types.js.map +1 -1
- package/package.json +7 -7
- package/src/datastore/datastore.ts +10 -1
- package/src/storage/adapter/index.ts +1 -0
- package/src/storage/storage.ts +11 -0
- package/src/sync/index.ts +8 -0
- package/src/sync/processors/mutation.ts +21 -24
- package/src/types.ts +11 -12
|
@@ -565,7 +565,7 @@ function defaultConflictHandler(conflictData: SyncConflict): PersistentModel {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
function defaultErrorHandler(error: SyncError) {
|
|
568
|
-
logger.warn(error);
|
|
568
|
+
logger.warn('DataStore Mutation Error', error);
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
function getModelConstructorByModelName(
|
|
@@ -728,6 +728,9 @@ class DataStore {
|
|
|
728
728
|
|
|
729
729
|
await this.storage.init();
|
|
730
730
|
|
|
731
|
+
logger.debug('Debug info before sync');
|
|
732
|
+
await this.storage.logDebugInfo();
|
|
733
|
+
|
|
731
734
|
await checkSchemaVersion(this.storage, schema.version);
|
|
732
735
|
|
|
733
736
|
const { aws_appsync_graphqlEndpoint } = this.amplifyConfig;
|
|
@@ -767,6 +770,12 @@ class DataStore {
|
|
|
767
770
|
this.initResolve();
|
|
768
771
|
}
|
|
769
772
|
|
|
773
|
+
if (type === ControlMessage.SYNC_ENGINE_SYNC_QUERIES_READY) {
|
|
774
|
+
logger.debug('Debug info after sync');
|
|
775
|
+
this.storage.logDebugInfo();
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
logger.debug({ event: type, data });
|
|
770
779
|
Hub.dispatch('datastore', {
|
|
771
780
|
event: type,
|
|
772
781
|
data,
|
package/src/storage/storage.ts
CHANGED
|
@@ -371,6 +371,13 @@ class StorageClass implements StorageFacade {
|
|
|
371
371
|
_deleted,
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
|
+
|
|
375
|
+
async logDebugInfo() {
|
|
376
|
+
if (typeof this.adapter.getDebugInfo === 'function') {
|
|
377
|
+
const results = await this.adapter.getDebugInfo();
|
|
378
|
+
logger.debug('DB Debug Info', results);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
374
381
|
}
|
|
375
382
|
|
|
376
383
|
class ExclusiveStorage implements StorageFacade {
|
|
@@ -482,6 +489,10 @@ class ExclusiveStorage implements StorageFacade {
|
|
|
482
489
|
return this.storage.batchSave(modelConstructor, items);
|
|
483
490
|
}
|
|
484
491
|
|
|
492
|
+
async logDebugInfo(): Promise<void> {
|
|
493
|
+
return this.runExclusive(storage => storage.logDebugInfo());
|
|
494
|
+
}
|
|
495
|
+
|
|
485
496
|
async init() {
|
|
486
497
|
return this.storage.init();
|
|
487
498
|
}
|
package/src/sync/index.ts
CHANGED
|
@@ -303,6 +303,11 @@ export class SyncEngine {
|
|
|
303
303
|
isEmpty: !hasMore,
|
|
304
304
|
},
|
|
305
305
|
});
|
|
306
|
+
|
|
307
|
+
if (!hasMore) {
|
|
308
|
+
logger.debug('Debug info after queue drained');
|
|
309
|
+
this.storage.logDebugInfo();
|
|
310
|
+
}
|
|
306
311
|
})
|
|
307
312
|
);
|
|
308
313
|
//#endregion
|
|
@@ -340,6 +345,9 @@ export class SyncEngine {
|
|
|
340
345
|
},
|
|
341
346
|
});
|
|
342
347
|
|
|
348
|
+
logger.debug('Debug info after offline');
|
|
349
|
+
await this.storage.logDebugInfo();
|
|
350
|
+
|
|
343
351
|
subscriptions.forEach(sub => sub.unsubscribe());
|
|
344
352
|
subscriptions = [];
|
|
345
353
|
}
|
|
@@ -251,19 +251,14 @@ class MutationProcessor {
|
|
|
251
251
|
MutationEvent: PersistentModelConstructor<MutationEvent>,
|
|
252
252
|
mutationEvent: MutationEvent
|
|
253
253
|
) => {
|
|
254
|
-
const [
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
model,
|
|
263
|
-
operation,
|
|
264
|
-
data,
|
|
265
|
-
condition
|
|
266
|
-
);
|
|
254
|
+
const [query, variables, graphQLCondition, opName, modelDefinition] =
|
|
255
|
+
this.createQueryVariables(
|
|
256
|
+
namespaceName,
|
|
257
|
+
model,
|
|
258
|
+
operation,
|
|
259
|
+
data,
|
|
260
|
+
condition
|
|
261
|
+
);
|
|
267
262
|
|
|
268
263
|
const authToken = await getTokenForCustomAuth(
|
|
269
264
|
authMode,
|
|
@@ -358,17 +353,18 @@ class MutationProcessor {
|
|
|
358
353
|
const namespace = this.schema.namespaces[namespaceName];
|
|
359
354
|
|
|
360
355
|
// convert retry with to tryWith
|
|
361
|
-
const updatedMutation =
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
356
|
+
const updatedMutation =
|
|
357
|
+
createMutationInstanceFromModelOperation(
|
|
358
|
+
namespace.relationships,
|
|
359
|
+
modelDefinition,
|
|
360
|
+
opType,
|
|
361
|
+
modelConstructor,
|
|
362
|
+
retryWith,
|
|
363
|
+
graphQLCondition,
|
|
364
|
+
MutationEvent,
|
|
365
|
+
this.modelInstanceCreator,
|
|
366
|
+
mutationEvent.id
|
|
367
|
+
);
|
|
372
368
|
|
|
373
369
|
await this.storage.save(updatedMutation);
|
|
374
370
|
|
|
@@ -380,6 +376,7 @@ class MutationProcessor {
|
|
|
380
376
|
modelConstructor,
|
|
381
377
|
variables.input
|
|
382
378
|
),
|
|
379
|
+
modelName: model,
|
|
383
380
|
message: error.message,
|
|
384
381
|
operation,
|
|
385
382
|
errorType: error.errorType,
|
package/src/types.ts
CHANGED
|
@@ -407,15 +407,14 @@ export type DataStoreSnapshot<T extends PersistentModel> = {
|
|
|
407
407
|
|
|
408
408
|
//#region Predicates
|
|
409
409
|
|
|
410
|
-
export type PredicateExpression<
|
|
410
|
+
export type PredicateExpression<
|
|
411
|
+
M extends PersistentModel,
|
|
411
412
|
FT
|
|
412
|
-
> extends keyof MapTypeToOperands<FT>
|
|
413
|
+
> = TypeName<FT> extends keyof MapTypeToOperands<FT>
|
|
413
414
|
? (
|
|
414
415
|
operator: keyof MapTypeToOperands<FT>[TypeName<FT>],
|
|
415
416
|
// make the operand type match the type they're trying to filter on
|
|
416
|
-
operand: MapTypeToOperands<FT>[TypeName<FT>][keyof MapTypeToOperands<
|
|
417
|
-
FT
|
|
418
|
-
>[TypeName<FT>]]
|
|
417
|
+
operand: MapTypeToOperands<FT>[TypeName<FT>][keyof MapTypeToOperands<FT>[TypeName<FT>]]
|
|
419
418
|
) => ModelPredicate<M>
|
|
420
419
|
: never;
|
|
421
420
|
|
|
@@ -483,8 +482,7 @@ export type PredicateGroups<T extends PersistentModel> = {
|
|
|
483
482
|
|
|
484
483
|
export type ModelPredicate<M extends PersistentModel> = {
|
|
485
484
|
[K in keyof M]-?: PredicateExpression<M, NonNullable<M[K]>>;
|
|
486
|
-
} &
|
|
487
|
-
PredicateGroups<M>;
|
|
485
|
+
} & PredicateGroups<M>;
|
|
488
486
|
|
|
489
487
|
export type ProducerModelPredicate<M extends PersistentModel> = (
|
|
490
488
|
condition: ModelPredicate<M>
|
|
@@ -574,9 +572,10 @@ export type SortPredicate<T extends PersistentModel> = {
|
|
|
574
572
|
[K in keyof T]-?: SortPredicateExpression<T, NonNullable<T[K]>>;
|
|
575
573
|
};
|
|
576
574
|
|
|
577
|
-
export type SortPredicateExpression<
|
|
575
|
+
export type SortPredicateExpression<
|
|
576
|
+
M extends PersistentModel,
|
|
578
577
|
FT
|
|
579
|
-
> extends keyof MapTypeToOperands<FT>
|
|
578
|
+
> = TypeName<FT> extends keyof MapTypeToOperands<FT>
|
|
580
579
|
? (sortDirection: keyof typeof SortDirection) => SortPredicate<M>
|
|
581
580
|
: never;
|
|
582
581
|
|
|
@@ -585,9 +584,8 @@ export enum SortDirection {
|
|
|
585
584
|
DESCENDING = 'DESCENDING',
|
|
586
585
|
}
|
|
587
586
|
|
|
588
|
-
export type SortPredicatesGroup<
|
|
589
|
-
T
|
|
590
|
-
> = SortPredicateObject<T>[];
|
|
587
|
+
export type SortPredicatesGroup<T extends PersistentModel> =
|
|
588
|
+
SortPredicateObject<T>[];
|
|
591
589
|
|
|
592
590
|
export type SortPredicateObject<T extends PersistentModel> = {
|
|
593
591
|
field: keyof T;
|
|
@@ -778,6 +776,7 @@ export type SyncError = {
|
|
|
778
776
|
localModel: PersistentModel;
|
|
779
777
|
remoteModel: PersistentModel;
|
|
780
778
|
operation: string;
|
|
779
|
+
modelName?: string;
|
|
781
780
|
};
|
|
782
781
|
|
|
783
782
|
export const DISCARD = Symbol('DISCARD');
|