@powersync/service-sync-rules 0.33.0 → 0.34.1
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/dist/compiler/bucket_resolver.d.ts +2 -0
- package/dist/compiler/bucket_resolver.js +18 -1
- package/dist/compiler/bucket_resolver.js.map +1 -1
- package/dist/compiler/equality.d.ts +1 -1
- package/dist/compiler/equality.js.map +1 -1
- package/dist/compiler/parser.d.ts +2 -1
- package/dist/compiler/parser.js +42 -6
- package/dist/compiler/parser.js.map +1 -1
- package/dist/compiler/querier_graph.d.ts +1 -0
- package/dist/compiler/querier_graph.js +9 -1
- package/dist/compiler/querier_graph.js.map +1 -1
- package/dist/from_yaml.js +56 -24
- package/dist/from_yaml.js.map +1 -1
- package/dist/json_schema.js +9 -0
- package/dist/json_schema.js.map +1 -1
- package/dist/schema-generators/DotNetSchemaGenerator.d.ts +12 -3
- package/dist/schema-generators/DotNetSchemaGenerator.js +91 -40
- package/dist/schema-generators/DotNetSchemaGenerator.js.map +1 -1
- package/dist/schema-generators/generators.d.ts +2 -1
- package/dist/schema-generators/generators.js +2 -1
- package/dist/schema-generators/generators.js.map +1 -1
- package/dist/sql_functions.d.ts +1 -1
- package/dist/sql_functions.js +30 -0
- package/dist/sql_functions.js.map +1 -1
- package/dist/yaml_scalar_map.d.ts +19 -0
- package/dist/yaml_scalar_map.js +339 -0
- package/dist/yaml_scalar_map.js.map +1 -0
- package/package.json +5 -3
- package/schema/sync_rules.json +9 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { Scalar } from 'yaml';
|
|
2
|
+
function isIndentChar(char) {
|
|
3
|
+
return char === ' ' || char === '\t';
|
|
4
|
+
}
|
|
5
|
+
/** Returns the index of the first character on the next line, handling \r\n as a single break. */
|
|
6
|
+
function nextLineStart(src, nlPos) {
|
|
7
|
+
const next = nlPos + 1;
|
|
8
|
+
return src[nlPos] === '\r' && next < src.length && src[next] === '\n' ? next + 1 : next;
|
|
9
|
+
}
|
|
10
|
+
export function isSingleQuotedScalar(type) {
|
|
11
|
+
return type === Scalar.QUOTE_SINGLE;
|
|
12
|
+
}
|
|
13
|
+
export function isDoubleQuotedScalar(type) {
|
|
14
|
+
return type === Scalar.QUOTE_DOUBLE;
|
|
15
|
+
}
|
|
16
|
+
export function isQuotedScalar(type) {
|
|
17
|
+
return isSingleQuotedScalar(type) || isDoubleQuotedScalar(type);
|
|
18
|
+
}
|
|
19
|
+
export function isBlockLiteralScalar(type) {
|
|
20
|
+
return type === Scalar.BLOCK_LITERAL;
|
|
21
|
+
}
|
|
22
|
+
export function isBlockFoldedScalar(type) {
|
|
23
|
+
return type === Scalar.BLOCK_FOLDED;
|
|
24
|
+
}
|
|
25
|
+
export function isBlockScalar(type) {
|
|
26
|
+
return isBlockLiteralScalar(type) || isBlockFoldedScalar(type);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Builds a map from indexes in parsed YAML scalars to indexes in the source YAML file.
|
|
30
|
+
*
|
|
31
|
+
* Quoted scalars (", ') have escape sequences that take up more chars in the source relative to the parsed value.
|
|
32
|
+
* Multi-line scalars (|, >) have line folding where newline + surrounding whitespace collapses
|
|
33
|
+
* to a single space. In both cases value offsets don't map 1:1 to source offsets.
|
|
34
|
+
*
|
|
35
|
+
* For unrecognised scalar types the map is empty, so all lookups fall back via ??.
|
|
36
|
+
*
|
|
37
|
+
* @param src The raw YAML source of the scalar token.
|
|
38
|
+
* @param scalarType The Scalar.type value.
|
|
39
|
+
*/
|
|
40
|
+
export function buildParsedToSourceValueMap(src, scalarType) {
|
|
41
|
+
const map = [];
|
|
42
|
+
if (isQuotedScalar(scalarType)) {
|
|
43
|
+
const isDoubleQuoted = isDoubleQuotedScalar(scalarType);
|
|
44
|
+
let srcIdx = 0;
|
|
45
|
+
let valIdx = 0;
|
|
46
|
+
while (srcIdx < src.length) {
|
|
47
|
+
const current = src[srcIdx];
|
|
48
|
+
const next = src[srcIdx + 1];
|
|
49
|
+
if (isDoubleQuoted && current === '\\') {
|
|
50
|
+
if (next === '\n' || next === '\r') {
|
|
51
|
+
// Escaped line break: skip \ + [\r]\n + indentation whitespace on next line
|
|
52
|
+
srcIdx++; // skip '\'
|
|
53
|
+
srcIdx = nextLineStart(src, srcIdx); // skip \n or \r\n
|
|
54
|
+
while (srcIdx < src.length && isIndentChar(src[srcIdx]))
|
|
55
|
+
srcIdx++; // skip indentation
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Handle escaped chars / unicode
|
|
59
|
+
map[valIdx++] = srcIdx;
|
|
60
|
+
if (next === 'x')
|
|
61
|
+
srcIdx += 4; // \xXX
|
|
62
|
+
else if (next === 'u')
|
|
63
|
+
srcIdx += 6; // \uXXXX
|
|
64
|
+
else if (next === 'U')
|
|
65
|
+
srcIdx += 10; // \UXXXXXXXX
|
|
66
|
+
else
|
|
67
|
+
srcIdx += 2; // \n, \", \\, etc.
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (!isDoubleQuoted && current === "'" && next === "'") {
|
|
71
|
+
// Handle '' in single quotes
|
|
72
|
+
map[valIdx++] = srcIdx;
|
|
73
|
+
srcIdx += 2;
|
|
74
|
+
}
|
|
75
|
+
else if (current === '\n' || current === '\r') {
|
|
76
|
+
// Literal newline in a multiline quoted scalar: apply line folding (b-l-folded).
|
|
77
|
+
// Leading/trailing whitespace around the line break is stripped; the fold either
|
|
78
|
+
// becomes a space (b-as-space) or, when blank lines follow, is trimmed and each
|
|
79
|
+
// blank line contributes a literal \n (b-l-trimmed).
|
|
80
|
+
const nlPos = srcIdx;
|
|
81
|
+
let nextSrcIdx = nextLineStart(src, srcIdx);
|
|
82
|
+
// Look ahead for blank lines and find the next content line's start
|
|
83
|
+
let emptyCount = 0;
|
|
84
|
+
let foundContent = false;
|
|
85
|
+
let nextContentStart = -1;
|
|
86
|
+
let peekIdx = nextSrcIdx;
|
|
87
|
+
while (peekIdx < src.length) {
|
|
88
|
+
let peekLineEnd = peekIdx;
|
|
89
|
+
while (peekLineEnd < src.length && src[peekLineEnd] !== '\n' && src[peekLineEnd] !== '\r')
|
|
90
|
+
peekLineEnd++;
|
|
91
|
+
let peekContentStart = peekIdx;
|
|
92
|
+
while (peekContentStart < peekLineEnd && isIndentChar(src[peekContentStart]))
|
|
93
|
+
peekContentStart++;
|
|
94
|
+
let peekContentEnd = peekLineEnd;
|
|
95
|
+
while (peekContentEnd > peekContentStart && isIndentChar(src[peekContentEnd - 1]))
|
|
96
|
+
peekContentEnd--;
|
|
97
|
+
if (peekContentStart >= peekContentEnd) {
|
|
98
|
+
emptyCount++;
|
|
99
|
+
if (peekLineEnd >= src.length)
|
|
100
|
+
break;
|
|
101
|
+
peekIdx = nextLineStart(src, peekLineEnd);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
foundContent = true;
|
|
105
|
+
nextContentStart = peekContentStart;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (emptyCount > 0) {
|
|
110
|
+
// b-l-trimmed: content \n is discarded; each blank line contributes a \n.
|
|
111
|
+
map[valIdx++] = nlPos;
|
|
112
|
+
srcIdx = nextSrcIdx;
|
|
113
|
+
for (let e = 0; e < emptyCount; e++) {
|
|
114
|
+
while (srcIdx < src.length && src[srcIdx] !== '\n' && src[srcIdx] !== '\r')
|
|
115
|
+
srcIdx++;
|
|
116
|
+
if (e > 0)
|
|
117
|
+
map[valIdx++] = srcIdx;
|
|
118
|
+
if (srcIdx < src.length)
|
|
119
|
+
srcIdx = nextLineStart(src, srcIdx);
|
|
120
|
+
}
|
|
121
|
+
// Strip leading whitespace on the next content line
|
|
122
|
+
if (foundContent)
|
|
123
|
+
srcIdx = nextContentStart;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// b-as-space: fold to a single space mapped to the newline position.
|
|
127
|
+
map[valIdx++] = nlPos;
|
|
128
|
+
srcIdx = foundContent ? nextContentStart : nextSrcIdx;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
map[valIdx++] = srcIdx++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
map[valIdx] = src.length; // Sentinel
|
|
136
|
+
}
|
|
137
|
+
else if (isBlockScalar(scalarType)) {
|
|
138
|
+
// Detect indentation using first non-empty line
|
|
139
|
+
let trimIndent = 0;
|
|
140
|
+
let i = 0;
|
|
141
|
+
outer: while (i < src.length) {
|
|
142
|
+
// Skip to end of line
|
|
143
|
+
const lineStart = i;
|
|
144
|
+
while (i < src.length && src[i] !== '\n')
|
|
145
|
+
i++;
|
|
146
|
+
// Count chars from start of line until first non-whitespace char
|
|
147
|
+
for (let j = lineStart; j < i; j++) {
|
|
148
|
+
if (!isIndentChar(src[j])) {
|
|
149
|
+
trimIndent = j - lineStart;
|
|
150
|
+
break outer;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// No non-whitespace char found; go to next line
|
|
154
|
+
i++;
|
|
155
|
+
}
|
|
156
|
+
const isFolded = isBlockFoldedScalar(scalarType);
|
|
157
|
+
let valIdx = 0;
|
|
158
|
+
let srcIdx = 0;
|
|
159
|
+
while (srcIdx < src.length) {
|
|
160
|
+
const lineStart = srcIdx;
|
|
161
|
+
// Find end of line content (position of \n or end of string)
|
|
162
|
+
while (srcIdx < src.length && src[srcIdx] !== '\n')
|
|
163
|
+
srcIdx++;
|
|
164
|
+
const lineEnd = srcIdx;
|
|
165
|
+
const lineLen = lineEnd - lineStart;
|
|
166
|
+
// Skip common indentation, but don't skip past the end of line
|
|
167
|
+
const contentStart = lineStart + Math.min(trimIndent, lineLen);
|
|
168
|
+
const hasContent = contentStart < lineEnd;
|
|
169
|
+
// Map content characters
|
|
170
|
+
for (let p = contentStart; p < lineEnd; p++) {
|
|
171
|
+
map[valIdx++] = p;
|
|
172
|
+
}
|
|
173
|
+
// Handle the line break
|
|
174
|
+
if (srcIdx < src.length) {
|
|
175
|
+
const nlPos = srcIdx; // position of the \n
|
|
176
|
+
srcIdx++;
|
|
177
|
+
if (isFolded && hasContent) {
|
|
178
|
+
// A "more-indented" line has extra spaces beyond the base indent (s-nb-spaced-text).
|
|
179
|
+
// Boundaries next to more-indented lines keep their \n literal rather than folding.
|
|
180
|
+
const currentMoreIndented = isIndentChar(src[contentStart]);
|
|
181
|
+
// Look ahead: count consecutive empty lines that follow, and detect if the next
|
|
182
|
+
// content line is more-indented. Also save its contentStart for the fold case.
|
|
183
|
+
let emptyCount = 0;
|
|
184
|
+
let foundContent = false;
|
|
185
|
+
let nextMoreIndented = false;
|
|
186
|
+
let nextContentStart = -1;
|
|
187
|
+
let peekIdx = srcIdx;
|
|
188
|
+
while (peekIdx < src.length) {
|
|
189
|
+
const peekLineStart = peekIdx;
|
|
190
|
+
while (peekIdx < src.length && src[peekIdx] !== '\n')
|
|
191
|
+
peekIdx++;
|
|
192
|
+
const peekLineLen = peekIdx - peekLineStart;
|
|
193
|
+
const peekContentStart = peekLineStart + Math.min(trimIndent, peekLineLen);
|
|
194
|
+
if (peekContentStart >= peekIdx) {
|
|
195
|
+
// Empty line
|
|
196
|
+
emptyCount++;
|
|
197
|
+
if (peekIdx < src.length)
|
|
198
|
+
peekIdx++;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
foundContent = true;
|
|
202
|
+
nextMoreIndented = isIndentChar(src[peekContentStart]);
|
|
203
|
+
nextContentStart = peekContentStart;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (emptyCount > 0) {
|
|
208
|
+
// Empty lines follow: content \n becomes one literal \n; each additional empty
|
|
209
|
+
// line contributes another \n; empty lines are consumed from srcIdx.
|
|
210
|
+
map[valIdx++] = nlPos;
|
|
211
|
+
for (let e = 0; e < emptyCount; e++) {
|
|
212
|
+
while (srcIdx < src.length && src[srcIdx] !== '\n')
|
|
213
|
+
srcIdx++;
|
|
214
|
+
if (e > 0) {
|
|
215
|
+
// Each additional empty line contributes a \n mapped to its own \n position
|
|
216
|
+
map[valIdx++] = srcIdx;
|
|
217
|
+
}
|
|
218
|
+
if (srcIdx < src.length)
|
|
219
|
+
srcIdx++;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if (foundContent && !currentMoreIndented && !nextMoreIndented) {
|
|
223
|
+
// No empty lines, no more-indented boundaries: fold the \n into a space; map the
|
|
224
|
+
// space to the start of the next line's content (after stripping indentation).
|
|
225
|
+
map[valIdx++] = nextContentStart;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// More-indented boundary or end of block: keep \n literal.
|
|
229
|
+
map[valIdx++] = nlPos;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
// BLOCK_LITERAL: always map \n literally.
|
|
234
|
+
// BLOCK_FOLDED empty line: map \n literally (consumed by preceding content line's logic).
|
|
235
|
+
map[valIdx++] = nlPos;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
map[valIdx] = src.length; // Sentinel
|
|
240
|
+
}
|
|
241
|
+
else if (scalarType === Scalar.PLAIN) {
|
|
242
|
+
// Plain scalars may span multiple lines. Line folding collapses each
|
|
243
|
+
// (trailing whitespace + newline + leading whitespace of next line) into a single space.
|
|
244
|
+
// Blank lines are NOT folded: the preceding line break is discarded, and each blank line
|
|
245
|
+
// contributes a literal newline (same folding rule as block folded scalars).
|
|
246
|
+
let valIdx = 0;
|
|
247
|
+
let srcIdx = 0;
|
|
248
|
+
let firstLine = true;
|
|
249
|
+
while (srcIdx <= src.length) {
|
|
250
|
+
// Find content bounds for this line
|
|
251
|
+
let lineEnd = srcIdx;
|
|
252
|
+
while (lineEnd < src.length && src[lineEnd] !== '\n' && src[lineEnd] !== '\r')
|
|
253
|
+
lineEnd++;
|
|
254
|
+
let contentStart = srcIdx;
|
|
255
|
+
if (!firstLine) {
|
|
256
|
+
// Strip leading whitespace from continuation lines
|
|
257
|
+
while (contentStart < lineEnd && isIndentChar(src[contentStart]))
|
|
258
|
+
contentStart++;
|
|
259
|
+
}
|
|
260
|
+
let contentEnd = lineEnd;
|
|
261
|
+
while (contentEnd > contentStart && isIndentChar(src[contentEnd - 1]))
|
|
262
|
+
contentEnd--;
|
|
263
|
+
const hasContent = contentStart < contentEnd;
|
|
264
|
+
// Map content characters
|
|
265
|
+
for (let p = contentStart; p < contentEnd; p++) {
|
|
266
|
+
map[valIdx++] = p;
|
|
267
|
+
}
|
|
268
|
+
if (lineEnd >= src.length)
|
|
269
|
+
break;
|
|
270
|
+
// Handle the line break
|
|
271
|
+
const nlPos = lineEnd;
|
|
272
|
+
let nextSrcIdx = nextLineStart(src, lineEnd);
|
|
273
|
+
if (hasContent) {
|
|
274
|
+
// Look ahead: count consecutive blank (whitespace-only) lines.
|
|
275
|
+
// Also save the next content line's leading-whitespace-stripped start for the fold case.
|
|
276
|
+
let emptyCount = 0;
|
|
277
|
+
let foundContent = false;
|
|
278
|
+
let nextContentStart = -1;
|
|
279
|
+
let peekIdx = nextSrcIdx;
|
|
280
|
+
while (peekIdx < src.length) {
|
|
281
|
+
let peekLineEnd = peekIdx;
|
|
282
|
+
while (peekLineEnd < src.length && src[peekLineEnd] !== '\n' && src[peekLineEnd] !== '\r')
|
|
283
|
+
peekLineEnd++;
|
|
284
|
+
let peekContentStart = peekIdx;
|
|
285
|
+
while (peekContentStart < peekLineEnd && isIndentChar(src[peekContentStart]))
|
|
286
|
+
peekContentStart++;
|
|
287
|
+
let peekContentEnd = peekLineEnd;
|
|
288
|
+
while (peekContentEnd > peekContentStart && isIndentChar(src[peekContentEnd - 1]))
|
|
289
|
+
peekContentEnd--;
|
|
290
|
+
if (peekContentStart >= peekContentEnd) {
|
|
291
|
+
// Blank or whitespace-only line
|
|
292
|
+
emptyCount++;
|
|
293
|
+
if (peekLineEnd >= src.length)
|
|
294
|
+
break;
|
|
295
|
+
peekIdx = nextLineStart(src, peekLineEnd);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
foundContent = true;
|
|
299
|
+
nextContentStart = peekContentStart;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (emptyCount > 0) {
|
|
304
|
+
// Blank lines follow: content \n → first parsed \n; each blank line → additional \n.
|
|
305
|
+
// Blank lines are consumed from srcIdx.
|
|
306
|
+
map[valIdx++] = nlPos;
|
|
307
|
+
for (let e = 0; e < emptyCount; e++) {
|
|
308
|
+
while (nextSrcIdx < src.length && src[nextSrcIdx] !== '\n' && src[nextSrcIdx] !== '\r')
|
|
309
|
+
nextSrcIdx++;
|
|
310
|
+
if (e > 0) {
|
|
311
|
+
// Each additional blank line contributes a \n mapped to its own \n position
|
|
312
|
+
map[valIdx++] = nextSrcIdx;
|
|
313
|
+
}
|
|
314
|
+
if (nextSrcIdx < src.length)
|
|
315
|
+
nextSrcIdx = nextLineStart(src, nextSrcIdx);
|
|
316
|
+
}
|
|
317
|
+
srcIdx = nextSrcIdx;
|
|
318
|
+
}
|
|
319
|
+
else if (foundContent) {
|
|
320
|
+
// No blank lines: fold \n to a space; map the space to the start of the next line's content.
|
|
321
|
+
map[valIdx++] = nextContentStart;
|
|
322
|
+
srcIdx = nextSrcIdx;
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
// No more non-blank lines: end of content
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
// Blank or whitespace-only line without preceding content in this iteration
|
|
331
|
+
srcIdx = nextSrcIdx;
|
|
332
|
+
}
|
|
333
|
+
firstLine = false;
|
|
334
|
+
}
|
|
335
|
+
map[valIdx] = src.length; // Sentinel
|
|
336
|
+
}
|
|
337
|
+
return map;
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=yaml_scalar_map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml_scalar_map.js","sourceRoot":"","sources":["../src/yaml_scalar_map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,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AG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;wBACpC,OAAO,UAAU,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,IAAI;4BAAE,UAAU,EAAE,CAAC;wBACrG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;4BACV,4EAA4E;4BAC5E,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC;wBAC7B,CAAC;wBACD,IAAI,UAAU,GAAG,GAAG,CAAC,MAAM;4BAAE,UAAU,GAAG,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;oBAC3E,CAAC;oBACD,MAAM,GAAG,UAAU,CAAC;gBACtB,CAAC;qBAAM,IAAI,YAAY,EAAE,CAAC;oBACxB,6FAA6F;oBAC7F,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,gBAAgB,CAAC;oBACjC,MAAM,GAAG,UAAU,CAAC;gBACtB,CAAC;qBAAM,CAAC;oBACN,0CAA0C;oBAC1C,MAAM;gBACR,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,4EAA4E;gBAC5E,MAAM,GAAG,UAAU,CAAC;YACtB,CAAC;YAED,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC;QACD,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,WAAW;IACvC,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/service-sync-rules",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.34.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "FSL-1.1-ALv2",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.16.2",
|
|
26
26
|
"ebnf": "^1.9.1",
|
|
27
|
-
"
|
|
27
|
+
"railroad-diagrams": "^1.0.0",
|
|
28
|
+
"vitest": "^4.1.0"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"clean": "rm -r ./dist && tsc -b --clean",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"build": "pnpm build:tsc && pnpm run build:extra",
|
|
33
34
|
"build:extra": "node scripts/compile-schema.js",
|
|
34
35
|
"build:tests": "tsc -b test/tsconfig.json",
|
|
35
|
-
"test": "vitest"
|
|
36
|
+
"test": "vitest",
|
|
37
|
+
"generate:grammar": "node --experimental-strip-types scripts/generate-grammar-docs.ts"
|
|
36
38
|
}
|
|
37
39
|
}
|
package/schema/sync_rules.json
CHANGED
|
@@ -61,6 +61,15 @@
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
+
"with": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"description": "Common-table expressions available to all sync streams",
|
|
67
|
+
"patternProperties": {
|
|
68
|
+
".*": {
|
|
69
|
+
"type": "string"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
64
73
|
"streams": {
|
|
65
74
|
"type": "object",
|
|
66
75
|
"description": "List of stream definitions",
|