@aws-amplify/datastore 3.8.0 → 3.8.1-geo.11
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 +9 -73
- package/dist/aws-amplify-datastore.js +27 -7
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +2 -2
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/datastore/datastore.js +16 -0
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/storage/storage.d.ts +2 -2
- package/lib/storage/storage.js +6 -4
- package/lib/storage/storage.js.map +1 -1
- package/lib/sync/processors/subscription.js +1 -2
- package/lib/sync/processors/subscription.js.map +1 -1
- package/lib/sync/processors/sync.js.map +1 -1
- package/lib/sync/utils.js.map +1 -1
- package/lib/types.d.ts +3 -1
- package/lib/types.js.map +1 -1
- package/lib-esm/datastore/datastore.js +16 -0
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/storage/storage.d.ts +2 -2
- package/lib-esm/storage/storage.js +6 -4
- package/lib-esm/storage/storage.js.map +1 -1
- package/lib-esm/sync/processors/subscription.js +1 -2
- package/lib-esm/sync/processors/subscription.js.map +1 -1
- package/lib-esm/sync/processors/sync.js.map +1 -1
- package/lib-esm/sync/utils.js.map +1 -1
- package/lib-esm/types.d.ts +3 -1
- package/lib-esm/types.js.map +1 -1
- package/package.json +7 -7
- package/src/datastore/datastore.ts +20 -0
- package/src/storage/storage.ts +8 -7
- package/src/sync/processors/subscription.ts +18 -20
- package/src/sync/processors/sync.ts +5 -4
- package/src/sync/utils.ts +3 -5
- package/src/types.ts +17 -13
- package/ssr/package.json +1 -1
|
@@ -48,11 +48,8 @@ class SubscriptionProcessor {
|
|
|
48
48
|
SchemaModel,
|
|
49
49
|
[TransformerMutationType, string, string][]
|
|
50
50
|
>();
|
|
51
|
-
private buffer: [
|
|
52
|
-
|
|
53
|
-
SchemaModel,
|
|
54
|
-
PersistentModel
|
|
55
|
-
][] = [];
|
|
51
|
+
private buffer: [TransformerMutationType, SchemaModel, PersistentModel][] =
|
|
52
|
+
[];
|
|
56
53
|
private dataObserver: ZenObservable.Observer<any>;
|
|
57
54
|
|
|
58
55
|
constructor(
|
|
@@ -308,8 +305,8 @@ class SubscriptionProcessor {
|
|
|
308
305
|
.forEach(async modelDefinition => {
|
|
309
306
|
const modelAuthModes = await getModelAuthModes({
|
|
310
307
|
authModeStrategy: this.authModeStrategy,
|
|
311
|
-
defaultAuthMode:
|
|
312
|
-
.aws_appsync_authenticationType,
|
|
308
|
+
defaultAuthMode:
|
|
309
|
+
this.amplifyConfig.aws_appsync_authenticationType,
|
|
313
310
|
modelName: modelDefinition.name,
|
|
314
311
|
schema: this.schema,
|
|
315
312
|
});
|
|
@@ -413,10 +410,11 @@ class SubscriptionProcessor {
|
|
|
413
410
|
return;
|
|
414
411
|
}
|
|
415
412
|
|
|
416
|
-
const predicatesGroup =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
413
|
+
const predicatesGroup =
|
|
414
|
+
ModelPredicateCreator.getPredicates(
|
|
415
|
+
this.syncPredicates.get(modelDefinition),
|
|
416
|
+
false
|
|
417
|
+
);
|
|
420
418
|
|
|
421
419
|
const { [opName]: record } = data;
|
|
422
420
|
|
|
@@ -534,15 +532,15 @@ class SubscriptionProcessor {
|
|
|
534
532
|
|
|
535
533
|
return () => {
|
|
536
534
|
Object.keys(subscriptions).forEach(modelName => {
|
|
537
|
-
subscriptions[modelName][
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
subscriptions[modelName][
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
subscriptions[modelName][
|
|
544
|
-
|
|
545
|
-
|
|
535
|
+
subscriptions[modelName][TransformerMutationType.CREATE].forEach(
|
|
536
|
+
subscription => subscription.unsubscribe()
|
|
537
|
+
);
|
|
538
|
+
subscriptions[modelName][TransformerMutationType.UPDATE].forEach(
|
|
539
|
+
subscription => subscription.unsubscribe()
|
|
540
|
+
);
|
|
541
|
+
subscriptions[modelName][TransformerMutationType.DELETE].forEach(
|
|
542
|
+
subscription => subscription.unsubscribe()
|
|
543
|
+
);
|
|
546
544
|
});
|
|
547
545
|
};
|
|
548
546
|
});
|
|
@@ -65,10 +65,11 @@ class SyncProcessor {
|
|
|
65
65
|
if (!this.syncPredicates) {
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
|
-
const predicatesGroup: PredicatesGroup<any> =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const predicatesGroup: PredicatesGroup<any> =
|
|
69
|
+
ModelPredicateCreator.getPredicates(
|
|
70
|
+
this.syncPredicates.get(model),
|
|
71
|
+
false
|
|
72
|
+
);
|
|
72
73
|
|
|
73
74
|
if (!predicatesGroup) {
|
|
74
75
|
return null;
|
package/src/sync/utils.ts
CHANGED
|
@@ -515,11 +515,9 @@ export async function getModelAuthModes({
|
|
|
515
515
|
defaultAuthMode: GRAPHQL_AUTH_MODE;
|
|
516
516
|
modelName: string;
|
|
517
517
|
schema: InternalSchema;
|
|
518
|
-
}): Promise<
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
> {
|
|
518
|
+
}): Promise<{
|
|
519
|
+
[key in ModelOperation]: GRAPHQL_AUTH_MODE[];
|
|
520
|
+
}> {
|
|
523
521
|
const operations = Object.values(ModelOperation);
|
|
524
522
|
|
|
525
523
|
const modelAuthModes: {
|
package/src/types.ts
CHANGED
|
@@ -392,11 +392,17 @@ export enum OpType {
|
|
|
392
392
|
DELETE = 'DELETE',
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
export type SubscriptionMessage<T extends PersistentModel> =
|
|
395
|
+
export type SubscriptionMessage<T extends PersistentModel> = Pick<
|
|
396
|
+
InternalSubscriptionMessage<T>,
|
|
397
|
+
'opType' | 'element' | 'model' | 'condition'
|
|
398
|
+
>;
|
|
399
|
+
|
|
400
|
+
export type InternalSubscriptionMessage<T extends PersistentModel> = {
|
|
396
401
|
opType: OpType;
|
|
397
402
|
element: T;
|
|
398
403
|
model: PersistentModelConstructor<T>;
|
|
399
404
|
condition: PredicatesGroup<T> | null;
|
|
405
|
+
savedElement?: T;
|
|
400
406
|
};
|
|
401
407
|
|
|
402
408
|
export type DataStoreSnapshot<T extends PersistentModel> = {
|
|
@@ -407,15 +413,14 @@ export type DataStoreSnapshot<T extends PersistentModel> = {
|
|
|
407
413
|
|
|
408
414
|
//#region Predicates
|
|
409
415
|
|
|
410
|
-
export type PredicateExpression<
|
|
416
|
+
export type PredicateExpression<
|
|
417
|
+
M extends PersistentModel,
|
|
411
418
|
FT
|
|
412
|
-
> extends keyof MapTypeToOperands<FT>
|
|
419
|
+
> = TypeName<FT> extends keyof MapTypeToOperands<FT>
|
|
413
420
|
? (
|
|
414
421
|
operator: keyof MapTypeToOperands<FT>[TypeName<FT>],
|
|
415
422
|
// 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>]]
|
|
423
|
+
operand: MapTypeToOperands<FT>[TypeName<FT>][keyof MapTypeToOperands<FT>[TypeName<FT>]]
|
|
419
424
|
) => ModelPredicate<M>
|
|
420
425
|
: never;
|
|
421
426
|
|
|
@@ -483,8 +488,7 @@ export type PredicateGroups<T extends PersistentModel> = {
|
|
|
483
488
|
|
|
484
489
|
export type ModelPredicate<M extends PersistentModel> = {
|
|
485
490
|
[K in keyof M]-?: PredicateExpression<M, NonNullable<M[K]>>;
|
|
486
|
-
} &
|
|
487
|
-
PredicateGroups<M>;
|
|
491
|
+
} & PredicateGroups<M>;
|
|
488
492
|
|
|
489
493
|
export type ProducerModelPredicate<M extends PersistentModel> = (
|
|
490
494
|
condition: ModelPredicate<M>
|
|
@@ -574,9 +578,10 @@ export type SortPredicate<T extends PersistentModel> = {
|
|
|
574
578
|
[K in keyof T]-?: SortPredicateExpression<T, NonNullable<T[K]>>;
|
|
575
579
|
};
|
|
576
580
|
|
|
577
|
-
export type SortPredicateExpression<
|
|
581
|
+
export type SortPredicateExpression<
|
|
582
|
+
M extends PersistentModel,
|
|
578
583
|
FT
|
|
579
|
-
> extends keyof MapTypeToOperands<FT>
|
|
584
|
+
> = TypeName<FT> extends keyof MapTypeToOperands<FT>
|
|
580
585
|
? (sortDirection: keyof typeof SortDirection) => SortPredicate<M>
|
|
581
586
|
: never;
|
|
582
587
|
|
|
@@ -585,9 +590,8 @@ export enum SortDirection {
|
|
|
585
590
|
DESCENDING = 'DESCENDING',
|
|
586
591
|
}
|
|
587
592
|
|
|
588
|
-
export type SortPredicatesGroup<
|
|
589
|
-
T
|
|
590
|
-
> = SortPredicateObject<T>[];
|
|
593
|
+
export type SortPredicatesGroup<T extends PersistentModel> =
|
|
594
|
+
SortPredicateObject<T>[];
|
|
591
595
|
|
|
592
596
|
export type SortPredicateObject<T extends PersistentModel> = {
|
|
593
597
|
field: keyof T;
|
package/ssr/package.json
CHANGED