@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.
Files changed (62) hide show
  1. package/lib/datastore/datastore.d.ts +0 -1
  2. package/lib/datastore/datastore.js +21 -28
  3. package/lib/datastore/datastore.js.map +1 -1
  4. package/lib/predicates/index.d.ts +31 -6
  5. package/lib/predicates/index.js +38 -73
  6. package/lib/predicates/index.js.map +1 -1
  7. package/lib/predicates/next.d.ts +5 -1
  8. package/lib/predicates/next.js +7 -1
  9. package/lib/predicates/next.js.map +1 -1
  10. package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
  11. package/lib/storage/storage.js.map +1 -1
  12. package/lib/sync/index.d.ts +1 -1
  13. package/lib/sync/index.js +1 -1
  14. package/lib/sync/index.js.map +1 -1
  15. package/lib/sync/outbox.js +14 -7
  16. package/lib/sync/outbox.js.map +1 -1
  17. package/lib/sync/processors/mutation.js.map +1 -1
  18. package/lib/sync/processors/subscription.d.ts +1 -1
  19. package/lib/sync/processors/subscription.js +1 -0
  20. package/lib/sync/processors/subscription.js.map +1 -1
  21. package/lib/sync/processors/sync.d.ts +1 -1
  22. package/lib/sync/processors/sync.js.map +1 -1
  23. package/lib/sync/utils.d.ts +2 -1
  24. package/lib/sync/utils.js +4 -0
  25. package/lib/sync/utils.js.map +1 -1
  26. package/lib-esm/datastore/datastore.d.ts +0 -1
  27. package/lib-esm/datastore/datastore.js +21 -28
  28. package/lib-esm/datastore/datastore.js.map +1 -1
  29. package/lib-esm/predicates/index.d.ts +31 -6
  30. package/lib-esm/predicates/index.js +38 -73
  31. package/lib-esm/predicates/index.js.map +1 -1
  32. package/lib-esm/predicates/next.d.ts +5 -1
  33. package/lib-esm/predicates/next.js +7 -1
  34. package/lib-esm/predicates/next.js.map +1 -1
  35. package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
  36. package/lib-esm/storage/storage.js.map +1 -1
  37. package/lib-esm/sync/index.d.ts +1 -1
  38. package/lib-esm/sync/index.js +1 -1
  39. package/lib-esm/sync/index.js.map +1 -1
  40. package/lib-esm/sync/outbox.js +14 -7
  41. package/lib-esm/sync/outbox.js.map +1 -1
  42. package/lib-esm/sync/processors/mutation.js.map +1 -1
  43. package/lib-esm/sync/processors/subscription.d.ts +1 -1
  44. package/lib-esm/sync/processors/subscription.js +1 -0
  45. package/lib-esm/sync/processors/subscription.js.map +1 -1
  46. package/lib-esm/sync/processors/sync.d.ts +1 -1
  47. package/lib-esm/sync/processors/sync.js.map +1 -1
  48. package/lib-esm/sync/utils.d.ts +2 -1
  49. package/lib-esm/sync/utils.js +4 -0
  50. package/lib-esm/sync/utils.js.map +1 -1
  51. package/package.json +8 -8
  52. package/src/datastore/datastore.ts +17 -34
  53. package/src/predicates/index.ts +41 -135
  54. package/src/predicates/next.ts +13 -13
  55. package/src/storage/adapter/AsyncStorageAdapter.ts +1 -1
  56. package/src/storage/storage.ts +6 -6
  57. package/src/sync/index.ts +6 -3
  58. package/src/sync/outbox.ts +17 -11
  59. package/src/sync/processors/mutation.ts +1 -1
  60. package/src/sync/processors/subscription.ts +6 -1
  61. package/src/sync/processors/sync.ts +4 -1
  62. package/src/sync/utils.ts +4 -0
@@ -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.createFromExisting<MutationEvent>(
41
+ const predicate = ModelPredicateCreator.createFromAST<MutationEvent>(
42
42
  mutationEventModelDefinition,
43
- c =>
44
- c
45
- .modelId('eq', mutationEvent.modelId)
46
- .id('ne', this.inProgressMutationEventId)
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.createFromExisting(
142
- mutationEventModelDefinition,
143
- c => c.modelId('eq', modelId)
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.createFromExisting<MutationEvent>(
205
+ const predicate = ModelPredicateCreator.createFromAST<MutationEvent>(
205
206
  mutationEventModelDefinition,
206
- c => c.modelId('eq', recordId).id('ne', this.inProgressMutationEventId)
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(
@@ -195,7 +195,7 @@ class MutationProcessor {
195
195
  operation,
196
196
  data,
197
197
  condition,
198
- modelConstructor as any,
198
+ modelConstructor,
199
199
  this.MutationEvent,
200
200
  head,
201
201
  operationAuthModes[authModeAttempts],
@@ -72,7 +72,10 @@ class SubscriptionProcessor {
72
72
 
73
73
  constructor(
74
74
  private readonly schema: InternalSchema,
75
- private readonly syncPredicates: WeakMap<SchemaModel, ModelPredicate<any>>,
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<SchemaModel, ModelPredicate<any>>,
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