@powersync/service-sync-rules 0.43.0 → 0.45.0

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 (85) hide show
  1. package/LICENSE +201 -67
  2. package/README.md +1 -1
  3. package/dist/BucketDescription.d.ts +1 -1
  4. package/dist/BucketParameterQuerier.d.ts +38 -2
  5. package/dist/BucketParameterQuerier.js.map +1 -1
  6. package/dist/BucketSource.d.ts +3 -3
  7. package/dist/BucketSource.js.map +1 -1
  8. package/dist/HydratedSyncConfig.d.ts +6 -0
  9. package/dist/HydratedSyncConfig.js +10 -0
  10. package/dist/HydratedSyncConfig.js.map +1 -1
  11. package/dist/SourceTableConfig.d.ts +42 -0
  12. package/dist/SourceTableConfig.js +152 -0
  13. package/dist/SourceTableConfig.js.map +1 -0
  14. package/dist/SqlSyncRules.d.ts +18 -49
  15. package/dist/SqlSyncRules.js +16 -23
  16. package/dist/SqlSyncRules.js.map +1 -1
  17. package/dist/SyncConfig.d.ts +13 -1
  18. package/dist/SyncConfig.js +14 -1
  19. package/dist/SyncConfig.js.map +1 -1
  20. package/dist/SyncConfigDiagnostics.d.ts +12 -0
  21. package/dist/SyncConfigDiagnostics.js +2 -0
  22. package/dist/SyncConfigDiagnostics.js.map +1 -0
  23. package/dist/TablePattern.d.ts +2 -2
  24. package/dist/TablePattern.js +17 -7
  25. package/dist/TablePattern.js.map +1 -1
  26. package/dist/compatibility.d.ts +2 -2
  27. package/dist/compatibility.js +3 -3
  28. package/dist/compatibility.js.map +1 -1
  29. package/dist/compiler/rows.d.ts +2 -2
  30. package/dist/errors.d.ts +5 -5
  31. package/dist/errors.js +3 -3
  32. package/dist/errors.js.map +1 -1
  33. package/dist/from_yaml.d.ts +15 -3
  34. package/dist/from_yaml.js +156 -24
  35. package/dist/from_yaml.js.map +1 -1
  36. package/dist/index.d.ts +7 -1
  37. package/dist/index.js +7 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/json.d.ts +7 -0
  40. package/dist/json.js +2 -0
  41. package/dist/json.js.map +1 -0
  42. package/dist/json_schema.d.ts +12 -2
  43. package/dist/json_schema.js +25 -5
  44. package/dist/json_schema.js.map +1 -1
  45. package/dist/legacy/SqlBucketDescriptor.d.ts +2 -3
  46. package/dist/legacy/SqlBucketDescriptor.js.map +1 -1
  47. package/dist/legacy/SqlDataQuery.d.ts +2 -3
  48. package/dist/legacy/SqlDataQuery.js.map +1 -1
  49. package/dist/legacy/streams/from_sql.js +1 -1
  50. package/dist/legacy/streams/from_sql.js.map +1 -1
  51. package/dist/mongo/MongoBsonValidators.d.ts +78 -0
  52. package/dist/mongo/MongoBsonValidators.js +129 -0
  53. package/dist/mongo/MongoBsonValidators.js.map +1 -0
  54. package/dist/mongo/MongoFilterExpression.d.ts +65 -0
  55. package/dist/mongo/MongoFilterExpression.js +183 -0
  56. package/dist/mongo/MongoFilterExpression.js.map +1 -0
  57. package/dist/mongo/MongoFilterValidation.d.ts +28 -0
  58. package/dist/mongo/MongoFilterValidation.js +47 -0
  59. package/dist/mongo/MongoFilterValidation.js.map +1 -0
  60. package/dist/schema-generators/DartSchemaGenerator.js +1 -1
  61. package/dist/schema-generators/DartSchemaGenerator.js.map +1 -1
  62. package/dist/schema-generators/TsSchemaGenerator.d.ts +1 -0
  63. package/dist/schema-generators/TsSchemaGenerator.js +15 -9
  64. package/dist/schema-generators/TsSchemaGenerator.js.map +1 -1
  65. package/dist/sync_plan/evaluator/bucket_source.js.map +1 -1
  66. package/dist/sync_plan/evaluator/index.d.ts +3 -1
  67. package/dist/sync_plan/evaluator/index.js +4 -1
  68. package/dist/sync_plan/evaluator/index.js.map +1 -1
  69. package/dist/sync_plan/plan.d.ts +2 -0
  70. package/dist/sync_plan/serialize.d.ts +13 -2
  71. package/dist/sync_plan/serialize.js +17 -8
  72. package/dist/sync_plan/serialize.js.map +1 -1
  73. package/dist/types.d.ts +29 -10
  74. package/dist/types.js +10 -15
  75. package/dist/types.js.map +1 -1
  76. package/dist/utils.d.ts +15 -3
  77. package/dist/utils.js +19 -7
  78. package/dist/utils.js.map +1 -1
  79. package/dist/yaml_source_locations.d.ts +14 -0
  80. package/dist/yaml_source_locations.js +112 -0
  81. package/dist/yaml_source_locations.js.map +1 -0
  82. package/dist/yaml_validation.js.map +1 -1
  83. package/package.json +8 -5
  84. package/schema/sync_config.json +383 -3
  85. package/schema/sync_rules.json +620 -0
@@ -1,9 +1,366 @@
1
1
  {
2
2
  "type": "object",
3
+ "definitions": {
4
+ "mongodb_filter_expression": {
5
+ "allOf": [
6
+ {
7
+ "$ref": "#/definitions/__schema0"
8
+ }
9
+ ]
10
+ },
11
+ "__schema0": {
12
+ "anyOf": [
13
+ {
14
+ "type": "object",
15
+ "properties": {
16
+ "$eq": {
17
+ "type": "array",
18
+ "items": [
19
+ {
20
+ "$ref": "#/definitions/__schema1"
21
+ },
22
+ {
23
+ "$ref": "#/definitions/__schema2"
24
+ }
25
+ ],
26
+ "additionalItems": false,
27
+ "minItems": 2,
28
+ "maxItems": 2,
29
+ "description": "Compare a source field with a scalar constant.",
30
+ "examples": [
31
+ [
32
+ "$$doc.status",
33
+ "active"
34
+ ]
35
+ ]
36
+ }
37
+ },
38
+ "required": [
39
+ "$eq"
40
+ ],
41
+ "additionalProperties": false
42
+ },
43
+ {
44
+ "type": "object",
45
+ "properties": {
46
+ "$in": {
47
+ "type": "array",
48
+ "items": [
49
+ {
50
+ "$ref": "#/definitions/__schema1"
51
+ },
52
+ {
53
+ "$ref": "#/definitions/__schema6"
54
+ }
55
+ ],
56
+ "additionalItems": false,
57
+ "minItems": 2,
58
+ "maxItems": 2,
59
+ "examples": [
60
+ [
61
+ "$$doc.status",
62
+ [
63
+ "pending",
64
+ "shipped"
65
+ ]
66
+ ]
67
+ ]
68
+ }
69
+ },
70
+ "required": [
71
+ "$in"
72
+ ],
73
+ "additionalProperties": false
74
+ },
75
+ {
76
+ "type": "object",
77
+ "properties": {
78
+ "$and": {
79
+ "minItems": 1,
80
+ "type": "array",
81
+ "items": {
82
+ "$ref": "#/definitions/mongodb_filter_expression"
83
+ },
84
+ "examples": [
85
+ [
86
+ {
87
+ "$eq": [
88
+ "$$doc.active",
89
+ true
90
+ ]
91
+ }
92
+ ]
93
+ ]
94
+ }
95
+ },
96
+ "required": [
97
+ "$and"
98
+ ],
99
+ "additionalProperties": false
100
+ },
101
+ {
102
+ "type": "object",
103
+ "properties": {
104
+ "$or": {
105
+ "minItems": 1,
106
+ "type": "array",
107
+ "items": {
108
+ "$ref": "#/definitions/mongodb_filter_expression"
109
+ },
110
+ "examples": [
111
+ [
112
+ {
113
+ "$eq": [
114
+ "$$doc.status",
115
+ "pending"
116
+ ]
117
+ },
118
+ {
119
+ "$eq": [
120
+ "$$doc.priority",
121
+ true
122
+ ]
123
+ }
124
+ ]
125
+ ]
126
+ }
127
+ },
128
+ "required": [
129
+ "$or"
130
+ ],
131
+ "additionalProperties": false
132
+ }
133
+ ]
134
+ },
135
+ "__schema1": {
136
+ "type": "string",
137
+ "pattern": "^\\$\\$doc(?:\\.(?![0-9]+(?:\\.|$))[^.$][^.]*)+$"
138
+ },
139
+ "__schema2": {
140
+ "anyOf": [
141
+ {
142
+ "type": "boolean"
143
+ },
144
+ {
145
+ "type": "number"
146
+ },
147
+ {
148
+ "type": "string",
149
+ "pattern": "^(?!\\$)"
150
+ },
151
+ {
152
+ "anyOf": [
153
+ {
154
+ "type": "object",
155
+ "properties": {
156
+ "$literal": {
157
+ "type": "string"
158
+ }
159
+ },
160
+ "required": [
161
+ "$literal"
162
+ ],
163
+ "additionalProperties": false
164
+ },
165
+ {
166
+ "type": "object",
167
+ "properties": {
168
+ "$oid": {
169
+ "type": "string",
170
+ "pattern": "^[0-9a-fA-F]{24}$"
171
+ }
172
+ },
173
+ "required": [
174
+ "$oid"
175
+ ],
176
+ "additionalProperties": false
177
+ },
178
+ {
179
+ "type": "object",
180
+ "properties": {
181
+ "$numberInt": {
182
+ "allOf": [
183
+ {
184
+ "$ref": "#/definitions/__schema3"
185
+ }
186
+ ]
187
+ }
188
+ },
189
+ "required": [
190
+ "$numberInt"
191
+ ],
192
+ "additionalProperties": false
193
+ },
194
+ {
195
+ "type": "object",
196
+ "properties": {
197
+ "$numberLong": {
198
+ "allOf": [
199
+ {
200
+ "$ref": "#/definitions/__schema3"
201
+ }
202
+ ]
203
+ }
204
+ },
205
+ "required": [
206
+ "$numberLong"
207
+ ],
208
+ "additionalProperties": false
209
+ },
210
+ {
211
+ "type": "object",
212
+ "properties": {
213
+ "$numberDouble": {
214
+ "type": "string",
215
+ "pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$"
216
+ }
217
+ },
218
+ "required": [
219
+ "$numberDouble"
220
+ ],
221
+ "additionalProperties": false
222
+ },
223
+ {
224
+ "type": "object",
225
+ "properties": {
226
+ "$numberDecimal": {
227
+ "type": "string"
228
+ }
229
+ },
230
+ "required": [
231
+ "$numberDecimal"
232
+ ],
233
+ "additionalProperties": false
234
+ },
235
+ {
236
+ "type": "object",
237
+ "properties": {
238
+ "$uuid": {
239
+ "type": "string",
240
+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
241
+ }
242
+ },
243
+ "required": [
244
+ "$uuid"
245
+ ],
246
+ "additionalProperties": false
247
+ },
248
+ {
249
+ "type": "object",
250
+ "properties": {
251
+ "$date": {
252
+ "anyOf": [
253
+ {
254
+ "type": "string",
255
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$"
256
+ },
257
+ {
258
+ "type": "object",
259
+ "properties": {
260
+ "$numberLong": {
261
+ "allOf": [
262
+ {
263
+ "$ref": "#/definitions/__schema3"
264
+ }
265
+ ]
266
+ }
267
+ },
268
+ "required": [
269
+ "$numberLong"
270
+ ],
271
+ "additionalProperties": false
272
+ }
273
+ ]
274
+ }
275
+ },
276
+ "required": [
277
+ "$date"
278
+ ],
279
+ "additionalProperties": false
280
+ },
281
+ {
282
+ "type": "object",
283
+ "properties": {
284
+ "$timestamp": {
285
+ "type": "object",
286
+ "properties": {
287
+ "t": {
288
+ "type": "integer",
289
+ "minimum": 0,
290
+ "maximum": 4294967295
291
+ },
292
+ "i": {
293
+ "type": "integer",
294
+ "minimum": 0,
295
+ "maximum": 4294967295
296
+ }
297
+ },
298
+ "required": [
299
+ "t",
300
+ "i"
301
+ ],
302
+ "additionalProperties": false
303
+ }
304
+ },
305
+ "required": [
306
+ "$timestamp"
307
+ ],
308
+ "additionalProperties": false
309
+ },
310
+ {
311
+ "type": "object",
312
+ "properties": {
313
+ "$binary": {
314
+ "type": "object",
315
+ "properties": {
316
+ "base64": {
317
+ "$ref": "#/definitions/__schema4"
318
+ },
319
+ "subType": {
320
+ "$ref": "#/definitions/__schema5"
321
+ }
322
+ },
323
+ "required": [
324
+ "base64",
325
+ "subType"
326
+ ],
327
+ "additionalProperties": false
328
+ }
329
+ },
330
+ "required": [
331
+ "$binary"
332
+ ],
333
+ "additionalProperties": false
334
+ }
335
+ ]
336
+ }
337
+ ]
338
+ },
339
+ "__schema3": {
340
+ "type": "string",
341
+ "pattern": "^-?(?:0|[1-9][0-9]*)$"
342
+ },
343
+ "__schema4": {
344
+ "type": "string",
345
+ "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$"
346
+ },
347
+ "__schema5": {
348
+ "type": "string",
349
+ "pattern": "^[0-9a-fA-F]{2}$"
350
+ },
351
+ "__schema6": {
352
+ "minItems": 1,
353
+ "type": "array",
354
+ "items": {
355
+ "$ref": "#/definitions/__schema2"
356
+ }
357
+ }
358
+ },
3
359
  "properties": {
4
360
  "bucket_definitions": {
5
361
  "type": "object",
6
- "description": "List of bucket definitions",
362
+ "deprecated": true,
363
+ "description": "Deprecated: legacy Sync Rules bucket definitions. They will be removed in the next major version of the PowerSync Service. Use `streams:` (Sync Streams) instead: https://docs.powersync.com/sync/rules/migrate-to-sync-streams",
7
364
  "examples": [
8
365
  {
9
366
  "global": {
@@ -170,8 +527,31 @@
170
527
  },
171
528
  "config": {
172
529
  "type": "object",
173
- "description": "Config declaring the compatibility level used to parse these definitions.",
530
+ "description": "Compatibility, storage, and source-table settings for these definitions.",
174
531
  "properties": {
532
+ "source_table_options": {
533
+ "type": "object",
534
+ "propertyNames": {
535
+ "minLength": 1,
536
+ "pattern": "^(?:[^.\"]+|\"(?:[^\"]|\"\")+\")(?:\\.(?:[^.\"]+|\"(?:[^\"]|\"\")+\")){0,2}$"
537
+ },
538
+ "additionalProperties": {
539
+ "type": "object",
540
+ "properties": {
541
+ "mongodb_filter_expression": {
542
+ "anyOf": [
543
+ {
544
+ "$ref": "#/definitions/mongodb_filter_expression"
545
+ },
546
+ {
547
+ "const": "disabled"
548
+ }
549
+ ]
550
+ }
551
+ },
552
+ "additionalProperties": false
553
+ }
554
+ },
175
555
  "edition": {
176
556
  "type": "integer",
177
557
  "default": 1,
@@ -202,7 +582,7 @@
202
582
  },
203
583
  "versioned_bucket_ids": {
204
584
  "type": "boolean",
205
- "description": "Enabled by default starting from edition 2: Encode the version of sync rules in generated bucket ids, which avoids clients downloading data twice and improves client-side progress estimates."
585
+ "description": "Enabled by default starting from edition 2: Encode the version of the sync config in generated bucket ids, which avoids clients downloading data twice and improves client-side progress estimates."
206
586
  },
207
587
  "fixed_json_extract": {
208
588
  "type": "boolean",