@aws-amplify/datastore 4.1.0 → 4.1.1-unstable-v5.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/lib/datastore/datastore.d.ts +0 -1
- package/lib/datastore/datastore.js +21 -28
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/predicates/index.d.ts +31 -6
- package/lib/predicates/index.js +38 -73
- package/lib/predicates/index.js.map +1 -1
- package/lib/predicates/next.d.ts +5 -1
- package/lib/predicates/next.js +7 -1
- package/lib/predicates/next.js.map +1 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib/storage/storage.js.map +1 -1
- package/lib/sync/index.d.ts +1 -1
- package/lib/sync/index.js +1 -1
- package/lib/sync/index.js.map +1 -1
- package/lib/sync/outbox.js +14 -7
- package/lib/sync/outbox.js.map +1 -1
- package/lib/sync/processors/mutation.js.map +1 -1
- package/lib/sync/processors/subscription.d.ts +1 -1
- package/lib/sync/processors/subscription.js +1 -0
- package/lib/sync/processors/subscription.js.map +1 -1
- package/lib/sync/processors/sync.d.ts +1 -1
- package/lib/sync/processors/sync.js.map +1 -1
- package/lib/sync/utils.d.ts +2 -1
- package/lib/sync/utils.js +4 -0
- package/lib/sync/utils.js.map +1 -1
- package/lib-esm/datastore/datastore.d.ts +0 -1
- package/lib-esm/datastore/datastore.js +21 -28
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/predicates/index.d.ts +31 -6
- package/lib-esm/predicates/index.js +38 -73
- package/lib-esm/predicates/index.js.map +1 -1
- package/lib-esm/predicates/next.d.ts +5 -1
- package/lib-esm/predicates/next.js +7 -1
- package/lib-esm/predicates/next.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib-esm/storage/storage.js.map +1 -1
- package/lib-esm/sync/index.d.ts +1 -1
- package/lib-esm/sync/index.js +1 -1
- package/lib-esm/sync/index.js.map +1 -1
- package/lib-esm/sync/outbox.js +14 -7
- package/lib-esm/sync/outbox.js.map +1 -1
- package/lib-esm/sync/processors/mutation.js.map +1 -1
- package/lib-esm/sync/processors/subscription.d.ts +1 -1
- package/lib-esm/sync/processors/subscription.js +1 -0
- package/lib-esm/sync/processors/subscription.js.map +1 -1
- package/lib-esm/sync/processors/sync.d.ts +1 -1
- package/lib-esm/sync/processors/sync.js.map +1 -1
- package/lib-esm/sync/utils.d.ts +2 -1
- package/lib-esm/sync/utils.js +4 -0
- package/lib-esm/sync/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/datastore/datastore.ts +17 -34
- package/src/predicates/index.ts +41 -135
- package/src/predicates/next.ts +13 -13
- package/src/storage/adapter/AsyncStorageAdapter.ts +1 -1
- package/src/storage/storage.ts +6 -6
- package/src/sync/index.ts +6 -3
- package/src/sync/outbox.ts +17 -11
- package/src/sync/processors/mutation.ts +1 -1
- package/src/sync/processors/subscription.ts +6 -1
- package/src/sync/processors/sync.ts +4 -1
- package/src/sync/utils.ts +4 -0
package/src/sync/outbox.ts
CHANGED
|
@@ -38,12 +38,14 @@ class MutationEventOutbox {
|
|
|
38
38
|
|
|
39
39
|
// `id` is the key for the record in the mutationEvent;
|
|
40
40
|
// `modelId` is the key for the actual record that was mutated
|
|
41
|
-
const predicate = ModelPredicateCreator.
|
|
41
|
+
const predicate = ModelPredicateCreator.createFromAST<MutationEvent>(
|
|
42
42
|
mutationEventModelDefinition,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
{
|
|
44
|
+
and: [
|
|
45
|
+
{ modelId: { eq: mutationEvent.modelId } },
|
|
46
|
+
{ id: { ne: this.inProgressMutationEventId } },
|
|
47
|
+
],
|
|
48
|
+
}
|
|
47
49
|
);
|
|
48
50
|
|
|
49
51
|
// Check if there are any other records with same id
|
|
@@ -138,10 +140,9 @@ class MutationEventOutbox {
|
|
|
138
140
|
|
|
139
141
|
const mutationEvents = await storage.query(
|
|
140
142
|
this.MutationEvent,
|
|
141
|
-
ModelPredicateCreator.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
)
|
|
143
|
+
ModelPredicateCreator.createFromAST(mutationEventModelDefinition, {
|
|
144
|
+
and: { modelId: { eq: modelId } },
|
|
145
|
+
})
|
|
145
146
|
);
|
|
146
147
|
|
|
147
148
|
return mutationEvents;
|
|
@@ -201,9 +202,14 @@ class MutationEventOutbox {
|
|
|
201
202
|
|
|
202
203
|
const recordId = getIdentifierValue(userModelDefinition, record);
|
|
203
204
|
|
|
204
|
-
const predicate = ModelPredicateCreator.
|
|
205
|
+
const predicate = ModelPredicateCreator.createFromAST<MutationEvent>(
|
|
205
206
|
mutationEventModelDefinition,
|
|
206
|
-
|
|
207
|
+
{
|
|
208
|
+
and: [
|
|
209
|
+
{ modelId: { eq: recordId } },
|
|
210
|
+
{ id: { ne: this.inProgressMutationEventId } },
|
|
211
|
+
],
|
|
212
|
+
}
|
|
207
213
|
);
|
|
208
214
|
|
|
209
215
|
const outdatedMutations = await storage.query(
|
|
@@ -72,7 +72,10 @@ class SubscriptionProcessor {
|
|
|
72
72
|
|
|
73
73
|
constructor(
|
|
74
74
|
private readonly schema: InternalSchema,
|
|
75
|
-
private readonly syncPredicates: WeakMap<
|
|
75
|
+
private readonly syncPredicates: WeakMap<
|
|
76
|
+
SchemaModel,
|
|
77
|
+
ModelPredicate<any> | null
|
|
78
|
+
>,
|
|
76
79
|
private readonly amplifyConfig: Record<string, any> = {},
|
|
77
80
|
private readonly authModeStrategy: AuthModeStrategy,
|
|
78
81
|
private readonly errorHandler: ErrorHandler,
|
|
@@ -749,6 +752,8 @@ class SubscriptionProcessor {
|
|
|
749
752
|
'Filters combination exceed maximum limit': RTFError.MaxCombinations,
|
|
750
753
|
'filter uses same fieldName multiple time': RTFError.RepeatedFieldname,
|
|
751
754
|
"The variables input contains a field name 'not'": RTFError.NotGroup,
|
|
755
|
+
'The variables input contains a field that is not defined for input object type':
|
|
756
|
+
RTFError.FieldNotInType,
|
|
752
757
|
};
|
|
753
758
|
|
|
754
759
|
const [_errorMsg, errorType] =
|
|
@@ -45,7 +45,10 @@ class SyncProcessor {
|
|
|
45
45
|
|
|
46
46
|
constructor(
|
|
47
47
|
private readonly schema: InternalSchema,
|
|
48
|
-
private readonly syncPredicates: WeakMap<
|
|
48
|
+
private readonly syncPredicates: WeakMap<
|
|
49
|
+
SchemaModel,
|
|
50
|
+
ModelPredicate<any> | null
|
|
51
|
+
>,
|
|
49
52
|
private readonly amplifyConfig: Record<string, any> = {},
|
|
50
53
|
private readonly authModeStrategy: AuthModeStrategy,
|
|
51
54
|
private readonly errorHandler: ErrorHandler,
|
package/src/sync/utils.ts
CHANGED
|
@@ -732,6 +732,7 @@ export enum RTFError {
|
|
|
732
732
|
MaxCombinations,
|
|
733
733
|
RepeatedFieldname,
|
|
734
734
|
NotGroup,
|
|
735
|
+
FieldNotInType,
|
|
735
736
|
}
|
|
736
737
|
|
|
737
738
|
export function generateRTFRemediation(
|
|
@@ -785,6 +786,9 @@ export function generateRTFRemediation(
|
|
|
785
786
|
`Your selective sync expression for ${modelDefinition.name} uses a \`not\` group. If you'd like to filter subscriptions in the backend, ` +
|
|
786
787
|
`rewrite your expression using \`ne\` or \`notContains\` operators.`
|
|
787
788
|
);
|
|
789
|
+
case RTFError.FieldNotInType:
|
|
790
|
+
// no remediation instructions. We'll surface the message directly
|
|
791
|
+
return '';
|
|
788
792
|
}
|
|
789
793
|
}
|
|
790
794
|
|