@powersync/service-sync-rules 0.43.0 → 0.44.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.
- package/dist/HydratedSyncConfig.d.ts +2 -0
- package/dist/HydratedSyncConfig.js +6 -0
- package/dist/HydratedSyncConfig.js.map +1 -1
- package/dist/SourceTableConfig.d.ts +42 -0
- package/dist/SourceTableConfig.js +152 -0
- package/dist/SourceTableConfig.js.map +1 -0
- package/dist/SqlSyncRules.d.ts +14 -0
- package/dist/SqlSyncRules.js +2 -1
- package/dist/SqlSyncRules.js.map +1 -1
- package/dist/SyncConfig.d.ts +3 -1
- package/dist/SyncConfig.js +3 -1
- package/dist/SyncConfig.js.map +1 -1
- package/dist/SyncConfigDiagnostics.d.ts +12 -0
- package/dist/SyncConfigDiagnostics.js +2 -0
- package/dist/SyncConfigDiagnostics.js.map +1 -0
- package/dist/TablePattern.d.ts +2 -2
- package/dist/TablePattern.js +17 -7
- package/dist/TablePattern.js.map +1 -1
- package/dist/from_yaml.d.ts +3 -1
- package/dist/from_yaml.js +116 -19
- package/dist/from_yaml.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +7 -0
- package/dist/json.js +2 -0
- package/dist/json.js.map +1 -0
- package/dist/json_schema.d.ts +10 -0
- package/dist/json_schema.js +24 -4
- package/dist/json_schema.js.map +1 -1
- package/dist/legacy/streams/from_sql.js +1 -1
- package/dist/legacy/streams/from_sql.js.map +1 -1
- package/dist/mongo/MongoBsonValidators.d.ts +78 -0
- package/dist/mongo/MongoBsonValidators.js +129 -0
- package/dist/mongo/MongoBsonValidators.js.map +1 -0
- package/dist/mongo/MongoFilterExpression.d.ts +65 -0
- package/dist/mongo/MongoFilterExpression.js +183 -0
- package/dist/mongo/MongoFilterExpression.js.map +1 -0
- package/dist/mongo/MongoFilterValidation.d.ts +28 -0
- package/dist/mongo/MongoFilterValidation.js +47 -0
- package/dist/mongo/MongoFilterValidation.js.map +1 -0
- package/dist/schema-generators/TsSchemaGenerator.d.ts +1 -0
- package/dist/schema-generators/TsSchemaGenerator.js +15 -9
- package/dist/schema-generators/TsSchemaGenerator.js.map +1 -1
- package/dist/sync_plan/plan.d.ts +2 -0
- package/dist/sync_plan/serialize.d.ts +13 -2
- package/dist/sync_plan/serialize.js +17 -8
- package/dist/sync_plan/serialize.js.map +1 -1
- package/dist/types.d.ts +1 -8
- package/dist/types.js +8 -13
- package/dist/types.js.map +1 -1
- package/dist/yaml_source_locations.d.ts +14 -0
- package/dist/yaml_source_locations.js +112 -0
- package/dist/yaml_source_locations.js.map +1 -0
- package/dist/yaml_validation.js.map +1 -1
- package/package.json +5 -2
- package/schema/sync_config.json +382 -2
- package/schema/sync_rules.json +620 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specialized payload checks attached directly to Zod schemas. Wrapper selection and recursion belong to the schema.
|
|
3
|
+
* This validates the filter's supported EJSON subset without replacing authored values with BSON instances.
|
|
4
|
+
* EJSON.deserialize alone is not a strict validator: the BSON library can coerce overflowing integers or
|
|
5
|
+
* normalize malformed base64 instead of rejecting them. Explicit bounds and syntax checks prevent those coercions;
|
|
6
|
+
* BSON still supplies Decimal128 representability and binary subtype checks where appropriate.
|
|
7
|
+
* Date strings deliberately retain the library's Date.parse behavior rather than strict calendar validation.
|
|
8
|
+
* See docs/replication/sync-config-parsing.md for the differences from general Extended JSON.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MONGO_BSON_VALIDATORS: {
|
|
11
|
+
readonly mongoNumber: {
|
|
12
|
+
readonly type: "number";
|
|
13
|
+
/**
|
|
14
|
+
* Plain integer literals have an Int32 interpretation; larger integers must select an EJSON type explicitly.
|
|
15
|
+
*/
|
|
16
|
+
readonly validate: (value: unknown) => void;
|
|
17
|
+
};
|
|
18
|
+
readonly mongoInt32: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
/**
|
|
21
|
+
* Checks a canonical Int32 payload against its signed bounds.
|
|
22
|
+
* In BSON 6.10.4, EJSON.deserialize({ $numberInt: '2147483648' }, { relaxed: false })
|
|
23
|
+
* wraps to -2147483648. Default relaxed mode instead returns the out-of-range JS number 2147483648.
|
|
24
|
+
* Reject the overflow in either case rather than relying on deserialization to validate the bounds.
|
|
25
|
+
*/
|
|
26
|
+
readonly validate: (value: unknown) => void;
|
|
27
|
+
};
|
|
28
|
+
readonly mongoInt64: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
/**
|
|
31
|
+
* Checks a canonical Int64 payload using exact integer arithmetic.
|
|
32
|
+
* In BSON 6.10.4, EJSON.deserialize({ $numberLong: '9223372036854775808' }, { relaxed: false })
|
|
33
|
+
* wraps to Long(-9223372036854775808). Default relaxed mode also wraps, then loses precision when
|
|
34
|
+
* converting to a JS number. Checking with BigInt rejects the overflow before either conversion.
|
|
35
|
+
*/
|
|
36
|
+
readonly validate: (value: unknown) => void;
|
|
37
|
+
};
|
|
38
|
+
readonly mongoDouble: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
/**
|
|
41
|
+
* Rejects overflow to infinity after the schema checks decimal/exponent syntax.
|
|
42
|
+
*/
|
|
43
|
+
readonly validate: (value: unknown) => void;
|
|
44
|
+
};
|
|
45
|
+
readonly mongoDecimal128: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
/**
|
|
48
|
+
* Delegates representability to BSON rather than converting through a lossy JavaScript number.
|
|
49
|
+
*/
|
|
50
|
+
readonly validate: (value: unknown) => void;
|
|
51
|
+
};
|
|
52
|
+
readonly mongoDateString: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
/**
|
|
55
|
+
* Requires a finite timestamp after the schema checks the timestamp format and explicit timezone.
|
|
56
|
+
* BSON's EJSON date-string conversion also uses Date.parse, including its calendar normalization
|
|
57
|
+
* (for example, 2026-02-29 becomes March 1). This does not enforce strict calendar validity.
|
|
58
|
+
*/
|
|
59
|
+
readonly validate: (value: unknown) => void;
|
|
60
|
+
};
|
|
61
|
+
readonly mongoDateMillis: {
|
|
62
|
+
readonly type: "string";
|
|
63
|
+
/**
|
|
64
|
+
* BSON dates are restored as JavaScript Date objects and must fit their supported millisecond range.
|
|
65
|
+
*/
|
|
66
|
+
readonly validate: (value: unknown) => void;
|
|
67
|
+
};
|
|
68
|
+
readonly mongoBinary: {
|
|
69
|
+
readonly type: "object";
|
|
70
|
+
/**
|
|
71
|
+
* Checks BSON subtype constraints, including UUID byte length, after structural byte-encoding validation.
|
|
72
|
+
* BSON 6.10.4 accepts { $binary: { base64: 'AQI', subType: '0' } } in both relaxed and typed modes;
|
|
73
|
+
* re-serialization produces base64 'AQI=' and subtype '00'. The Zod schema rejects missing padding
|
|
74
|
+
* and one-digit subtypes independently before this check, requiring the canonical spelling we support.
|
|
75
|
+
*/
|
|
76
|
+
readonly validate: (value: unknown) => void;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Decimal128, EJSON } from 'bson';
|
|
2
|
+
import { MongoFilterValidationError } from './MongoFilterValidation.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reports a payload error relative to the codec node; Zod supplies the surrounding source path.
|
|
5
|
+
*/
|
|
6
|
+
function fail(message) {
|
|
7
|
+
throw new MongoFilterValidationError({ path: [], message });
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Checks integer-string bounds without losing Int64 precision. Syntax is constrained by the codec's pattern.
|
|
11
|
+
*/
|
|
12
|
+
function integerRange(value, minimum, maximum) {
|
|
13
|
+
if (typeof value != 'string' || !/^-?(?:0|[1-9][0-9]*)$/.test(value))
|
|
14
|
+
return;
|
|
15
|
+
const parsed = BigInt(value);
|
|
16
|
+
if (parsed < minimum || parsed > maximum)
|
|
17
|
+
fail('integer is outside the supported BSON range.');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Specialized payload checks attached directly to Zod schemas. Wrapper selection and recursion belong to the schema.
|
|
21
|
+
* This validates the filter's supported EJSON subset without replacing authored values with BSON instances.
|
|
22
|
+
* EJSON.deserialize alone is not a strict validator: the BSON library can coerce overflowing integers or
|
|
23
|
+
* normalize malformed base64 instead of rejecting them. Explicit bounds and syntax checks prevent those coercions;
|
|
24
|
+
* BSON still supplies Decimal128 representability and binary subtype checks where appropriate.
|
|
25
|
+
* Date strings deliberately retain the library's Date.parse behavior rather than strict calendar validation.
|
|
26
|
+
* See docs/replication/sync-config-parsing.md for the differences from general Extended JSON.
|
|
27
|
+
*/
|
|
28
|
+
export const MONGO_BSON_VALIDATORS = {
|
|
29
|
+
mongoNumber: {
|
|
30
|
+
type: 'number',
|
|
31
|
+
/**
|
|
32
|
+
* Plain integer literals have an Int32 interpretation; larger integers must select an EJSON type explicitly.
|
|
33
|
+
*/
|
|
34
|
+
validate(value) {
|
|
35
|
+
if (typeof value == 'number' && Number.isInteger(value) && (value < -2_147_483_648 || value > 2_147_483_647)) {
|
|
36
|
+
fail('integers outside the BSON Int32 range require an EJSON wrapper.');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
mongoInt32: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
/**
|
|
43
|
+
* Checks a canonical Int32 payload against its signed bounds.
|
|
44
|
+
* In BSON 6.10.4, EJSON.deserialize({ $numberInt: '2147483648' }, { relaxed: false })
|
|
45
|
+
* wraps to -2147483648. Default relaxed mode instead returns the out-of-range JS number 2147483648.
|
|
46
|
+
* Reject the overflow in either case rather than relying on deserialization to validate the bounds.
|
|
47
|
+
*/
|
|
48
|
+
validate(value) {
|
|
49
|
+
integerRange(value, -2147483648n, 2147483647n);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
mongoInt64: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
/**
|
|
55
|
+
* Checks a canonical Int64 payload using exact integer arithmetic.
|
|
56
|
+
* In BSON 6.10.4, EJSON.deserialize({ $numberLong: '9223372036854775808' }, { relaxed: false })
|
|
57
|
+
* wraps to Long(-9223372036854775808). Default relaxed mode also wraps, then loses precision when
|
|
58
|
+
* converting to a JS number. Checking with BigInt rejects the overflow before either conversion.
|
|
59
|
+
*/
|
|
60
|
+
validate(value) {
|
|
61
|
+
integerRange(value, -9223372036854775808n, 9223372036854775807n);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
mongoDouble: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
/**
|
|
67
|
+
* Rejects overflow to infinity after the schema checks decimal/exponent syntax.
|
|
68
|
+
*/
|
|
69
|
+
validate(value) {
|
|
70
|
+
if (!Number.isFinite(Number(value)))
|
|
71
|
+
fail('expected a finite Extended JSON double string.');
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
mongoDecimal128: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
/**
|
|
77
|
+
* Delegates representability to BSON rather than converting through a lossy JavaScript number.
|
|
78
|
+
*/
|
|
79
|
+
validate(value) {
|
|
80
|
+
if (typeof value != 'string' || /nan|inf/i.test(value))
|
|
81
|
+
fail('expected a finite Extended JSON Decimal128 string.');
|
|
82
|
+
try {
|
|
83
|
+
Decimal128.fromString(value);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
fail('expected a valid Extended JSON Decimal128 string.');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
mongoDateString: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
/**
|
|
93
|
+
* Requires a finite timestamp after the schema checks the timestamp format and explicit timezone.
|
|
94
|
+
* BSON's EJSON date-string conversion also uses Date.parse, including its calendar normalization
|
|
95
|
+
* (for example, 2026-02-29 becomes March 1). This does not enforce strict calendar validity.
|
|
96
|
+
*/
|
|
97
|
+
validate(value) {
|
|
98
|
+
if (typeof value != 'string' || !Number.isFinite(Date.parse(value)))
|
|
99
|
+
fail('expected a valid ISO date string.');
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
mongoDateMillis: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
/**
|
|
105
|
+
* BSON dates are restored as JavaScript Date objects and must fit their supported millisecond range.
|
|
106
|
+
*/
|
|
107
|
+
validate(value) {
|
|
108
|
+
integerRange(value, -8640000000000000n, 8640000000000000n);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
mongoBinary: {
|
|
112
|
+
type: 'object',
|
|
113
|
+
/**
|
|
114
|
+
* Checks BSON subtype constraints, including UUID byte length, after structural byte-encoding validation.
|
|
115
|
+
* BSON 6.10.4 accepts { $binary: { base64: 'AQI', subType: '0' } } in both relaxed and typed modes;
|
|
116
|
+
* re-serialization produces base64 'AQI=' and subtype '00'. The Zod schema rejects missing padding
|
|
117
|
+
* and one-digit subtypes independently before this check, requiring the canonical spelling we support.
|
|
118
|
+
*/
|
|
119
|
+
validate(value) {
|
|
120
|
+
try {
|
|
121
|
+
EJSON.deserialize({ $binary: value }, { relaxed: false });
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
fail('the Extended JSON binary value is invalid or unsupported.');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=MongoBsonValidators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongoBsonValidators.js","sourceRoot":"","sources":["../../src/mongo/MongoBsonValidators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE;;GAEG;AACH,SAAS,IAAI,CAAC,OAAe;IAC3B,MAAM,IAAI,0BAA0B,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,KAAc,EAAE,OAAe,EAAE,OAAe;IACpE,IAAI,OAAO,KAAK,IAAI,Q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K,IAAI,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;gBACpD,IAAI,CAAC,oDAAoD,CAAC,CAAC;YAC7D,IAAI,CAAC;gBACH,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC,mDAAmD,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;KACF;IACD,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ;QACd;;;;WAIG;QACH,QAAQ,CAAC,KAAc;YACrB,IAAI,OAAO,KAAK,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAAE,IAAI,CAAC,mCAAmC,CAAC,CAAC;QACjH,CAAC;KACF;IACD,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ;QACd;;WAEG;QACH,QAAQ,CAAC,KAAc;YACrB,YAAY,CAAC,KAAK,EAAE,CAAC,iBAAsB,EAAE,iBAAsB,CAAC,CAAC;QACvE,CAAC;KACF;IACD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd;;;;;WAKG;QACH,QAAQ,CAAC,KAAc;YACrB,IAAI,CAAC;gBACH,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;YAC5D,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC,2DAA2D,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;KACF;CACO,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { YamlError } from '../errors.js';
|
|
3
|
+
import type { JsonObject } from '../json.js';
|
|
4
|
+
import type { SyncConfigSourceLocationResolver, SyncConfigSourcePath } from '../SyncConfigDiagnostics.js';
|
|
5
|
+
/**
|
|
6
|
+
* Supported filter literals, not a general-purpose EJSON parser. EJSON.deserialize converts BSON wrappers but
|
|
7
|
+
* does not enforce our expression grammar, reject ordinary object operands, or generate editor schemas.
|
|
8
|
+
* These declarations also supply paths for YAML diagnostics while keeping authored wrappers in saved plans.
|
|
9
|
+
* We intentionally exclude other EJSON types and non-finite numbers. Plain integers must fit Int32, date
|
|
10
|
+
* milliseconds must fit JavaScript Date, and binary subtypes use exactly two hex digits.
|
|
11
|
+
* $literal is a string-only aggregation-expression escape here, not an EJSON type wrapper.
|
|
12
|
+
* See docs/replication/sync-config-parsing.md for the supported subset and parser compatibility details.
|
|
13
|
+
*/
|
|
14
|
+
declare const WRAPPERS: {
|
|
15
|
+
$literal: z.ZodString;
|
|
16
|
+
$oid: z.ZodString;
|
|
17
|
+
$numberInt: z.ZodString;
|
|
18
|
+
$numberLong: z.ZodString;
|
|
19
|
+
$numberDouble: z.ZodString;
|
|
20
|
+
$numberDecimal: z.ZodString;
|
|
21
|
+
$uuid: z.ZodString;
|
|
22
|
+
$date: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
23
|
+
$numberLong: z.ZodString;
|
|
24
|
+
}, z.core.$strict>]>;
|
|
25
|
+
$timestamp: z.ZodObject<{
|
|
26
|
+
t: z.ZodNumber;
|
|
27
|
+
i: z.ZodNumber;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
$binary: z.ZodObject<{
|
|
30
|
+
base64: z.ZodString;
|
|
31
|
+
subType: z.ZodString;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
};
|
|
34
|
+
export declare const MONGO_FILTER_SCHEMA: z.ZodType<MongoFilterExpression, unknown, z.core.$ZodTypeInternals<MongoFilterExpression, unknown>>;
|
|
35
|
+
export declare const MONGO_FILTER_VALIDATOR: z.ZodType<MongoFilterExpression, unknown, z.core.$ZodTypeInternals<MongoFilterExpression, unknown>>;
|
|
36
|
+
export declare const MONGO_FILTER_JSON_SCHEMA_DEFINITIONS: JsonObject;
|
|
37
|
+
/**
|
|
38
|
+
* Validates authored input without replacing it with Zod's parsed output.
|
|
39
|
+
*
|
|
40
|
+
* The base path locates the expression within the config. Validation errors may point inside nested
|
|
41
|
+
* expression objects or operand arrays, so their relative paths are appended to that base path and
|
|
42
|
+
* resolved through sourceLocationResolver to highlight the specific key or value in the original source.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseMongoFilterExpression({ value, basePath, sourceLocationResolver }: {
|
|
45
|
+
value: unknown;
|
|
46
|
+
basePath: SyncConfigSourcePath;
|
|
47
|
+
sourceLocationResolver: SyncConfigSourceLocationResolver;
|
|
48
|
+
}): YamlError[];
|
|
49
|
+
export type MongoFieldPath = `$$doc.${string}`;
|
|
50
|
+
export type MongoExpressionLiteral = boolean | number | string | {
|
|
51
|
+
[Key in keyof typeof WRAPPERS]: {
|
|
52
|
+
[Property in Key]: z.output<(typeof WRAPPERS)[Key]>;
|
|
53
|
+
};
|
|
54
|
+
}[keyof typeof WRAPPERS];
|
|
55
|
+
export type MongoFilterExpression = {
|
|
56
|
+
$eq: [MongoFieldPath, MongoExpressionLiteral];
|
|
57
|
+
} | {
|
|
58
|
+
$in: [MongoFieldPath, MongoExpressionLiteral[]];
|
|
59
|
+
} | {
|
|
60
|
+
$and: MongoFilterExpression[];
|
|
61
|
+
} | {
|
|
62
|
+
$or: MongoFilterExpression[];
|
|
63
|
+
};
|
|
64
|
+
export type MongoTableFilter = MongoFilterExpression | 'disabled';
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { YamlError } from '../errors.js';
|
|
3
|
+
import { MONGO_BSON_VALIDATORS } from './MongoBsonValidators.js';
|
|
4
|
+
import { MongoFilterValidationError } from './MongoFilterValidation.js';
|
|
5
|
+
/**
|
|
6
|
+
* Reuses BSON checks directly, without converting their errors through AJV keywords.
|
|
7
|
+
*/
|
|
8
|
+
function bson(schema, name) {
|
|
9
|
+
return schema.superRefine((value, context) => {
|
|
10
|
+
try {
|
|
11
|
+
MONGO_BSON_VALIDATORS[name].validate(value);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (!(error instanceof MongoFilterValidationError))
|
|
15
|
+
throw error;
|
|
16
|
+
context.addIssue({ code: 'custom', message: error.detail, path: [...error.path] });
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const INTEGER = z.string().regex(/^-?(?:0|[1-9][0-9]*)$/);
|
|
21
|
+
const FIELD = z
|
|
22
|
+
.string({ error: 'Expected a source field such as $$doc.name.' })
|
|
23
|
+
.regex(/^\$\$doc(?:\.(?![0-9]+(?:\.|$))[^.$][^.]*)+$/, 'Expected a source field such as $$doc.name.');
|
|
24
|
+
const NUMBER = bson(z.number(), 'mongoNumber');
|
|
25
|
+
const STRING = z.string().regex(/^(?!\$)/, 'Use $literal for text starting with $.');
|
|
26
|
+
const DATE_STRING = bson(z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/), 'mongoDateString');
|
|
27
|
+
/**
|
|
28
|
+
* Supported filter literals, not a general-purpose EJSON parser. EJSON.deserialize converts BSON wrappers but
|
|
29
|
+
* does not enforce our expression grammar, reject ordinary object operands, or generate editor schemas.
|
|
30
|
+
* These declarations also supply paths for YAML diagnostics while keeping authored wrappers in saved plans.
|
|
31
|
+
* We intentionally exclude other EJSON types and non-finite numbers. Plain integers must fit Int32, date
|
|
32
|
+
* milliseconds must fit JavaScript Date, and binary subtypes use exactly two hex digits.
|
|
33
|
+
* $literal is a string-only aggregation-expression escape here, not an EJSON type wrapper.
|
|
34
|
+
* See docs/replication/sync-config-parsing.md for the supported subset and parser compatibility details.
|
|
35
|
+
*/
|
|
36
|
+
const WRAPPERS = {
|
|
37
|
+
$literal: z.string(),
|
|
38
|
+
$oid: z.string().regex(/^[0-9a-fA-F]{24}$/),
|
|
39
|
+
$numberInt: bson(INTEGER, 'mongoInt32'),
|
|
40
|
+
$numberLong: bson(INTEGER, 'mongoInt64'),
|
|
41
|
+
$numberDouble: bson(z.string().regex(/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/), 'mongoDouble'),
|
|
42
|
+
$numberDecimal: bson(z.string(), 'mongoDecimal128'),
|
|
43
|
+
$uuid: z.string().regex(/^[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}$/),
|
|
44
|
+
$date: z.union([DATE_STRING, z.strictObject({ $numberLong: bson(INTEGER, 'mongoDateMillis') })]),
|
|
45
|
+
$timestamp: z.strictObject({
|
|
46
|
+
t: z.number().int().min(0).max(0xffffffff),
|
|
47
|
+
i: z.number().int().min(0).max(0xffffffff)
|
|
48
|
+
}),
|
|
49
|
+
$binary: bson(z.strictObject({
|
|
50
|
+
base64: z.string().regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$/),
|
|
51
|
+
subType: z.string().regex(/^[0-9a-fA-F]{2}$/)
|
|
52
|
+
}), 'mongoBinary')
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* MongoDB comparisons take a field reference and a scalar or list operand.
|
|
56
|
+
*/
|
|
57
|
+
function comparison(value) {
|
|
58
|
+
return z.tuple([FIELD, value]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Defines operand shapes once for the structural schema and runtime validator.
|
|
62
|
+
* With dispatch=false, explicit unions describe every allowed shape for JSON Schema generation and autocomplete.
|
|
63
|
+
* With dispatch=true, validation selects the schema for the supplied operator or literal type, avoiding union
|
|
64
|
+
* errors from unrelated alternatives. This custom selection cannot be represented in generated JSON Schema,
|
|
65
|
+
* so both schemas share the operand definitions but use different selection logic.
|
|
66
|
+
*/
|
|
67
|
+
function createGrammar({ dispatch }) {
|
|
68
|
+
const wrappers = keyed(WRAPPERS, dispatch);
|
|
69
|
+
const literal = dispatch
|
|
70
|
+
? z.unknown().superRefine((value, context) => {
|
|
71
|
+
const schema = typeof value === 'string'
|
|
72
|
+
? STRING
|
|
73
|
+
: typeof value === 'number'
|
|
74
|
+
? NUMBER
|
|
75
|
+
: typeof value === 'boolean'
|
|
76
|
+
? z.boolean()
|
|
77
|
+
: wrappers;
|
|
78
|
+
forwardIssues(schema, value, context);
|
|
79
|
+
})
|
|
80
|
+
: z.union([z.boolean(), NUMBER, STRING, wrappers]);
|
|
81
|
+
// Defer resolution so boolean operators can contain nested expressions.
|
|
82
|
+
const expression = z
|
|
83
|
+
.lazy(() => keyed(operands, dispatch))
|
|
84
|
+
.meta(dispatch ? {} : { id: 'mongodb_filter_expression' });
|
|
85
|
+
const operands = {
|
|
86
|
+
$eq: comparison(literal).meta({
|
|
87
|
+
description: 'Compare a source field with a scalar constant.',
|
|
88
|
+
examples: [['$$doc.status', 'active']]
|
|
89
|
+
}),
|
|
90
|
+
$in: comparison(z.array(literal).min(1)).meta({
|
|
91
|
+
examples: [['$$doc.status', ['pending', 'shipped']]]
|
|
92
|
+
}),
|
|
93
|
+
$and: z
|
|
94
|
+
.array(expression)
|
|
95
|
+
.min(1)
|
|
96
|
+
.meta({ examples: [[{ $eq: ['$$doc.active', true] }]] }),
|
|
97
|
+
$or: z
|
|
98
|
+
.array(expression)
|
|
99
|
+
.min(1)
|
|
100
|
+
.meta({ examples: [[{ $eq: ['$$doc.status', 'pending'] }, { $eq: ['$$doc.priority', true] }]] })
|
|
101
|
+
};
|
|
102
|
+
return expression;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Chooses one named payload schema without trying unrelated alternatives.
|
|
106
|
+
* Zod tuples and arrays handle operand validation, recursion, and issue paths.
|
|
107
|
+
*/
|
|
108
|
+
function keyed(schemas, dispatch) {
|
|
109
|
+
if (!dispatch) {
|
|
110
|
+
return z.union(Object.entries(schemas).map(([key, schema]) => z.strictObject({ [key]: schema })));
|
|
111
|
+
}
|
|
112
|
+
return z.unknown().superRefine((value, context) => {
|
|
113
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length !== 1) {
|
|
114
|
+
context.addIssue({
|
|
115
|
+
code: 'custom',
|
|
116
|
+
message: `Expected exactly one supported ${Object.hasOwn(schemas, '$eq') ? 'filter operator' : 'literal wrapper'}.`
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const key = Object.keys(value)[0];
|
|
121
|
+
if (!Object.hasOwn(schemas, key)) {
|
|
122
|
+
context.addIssue({
|
|
123
|
+
code: 'custom',
|
|
124
|
+
path: [key],
|
|
125
|
+
params: { target: 'key' },
|
|
126
|
+
message: `Expected one of ${Object.keys(schemas).join(', ')}.`
|
|
127
|
+
});
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
forwardIssues(schemas[key], value[key], context, [key]);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Adds selected-schema issues to the enclosing Zod context, keeping nested paths intact.
|
|
135
|
+
*/
|
|
136
|
+
function forwardIssues(schema, value, context, prefix = []) {
|
|
137
|
+
const result = schema.safeParse(value);
|
|
138
|
+
if (!result.success) {
|
|
139
|
+
for (const issue of result.error.issues) {
|
|
140
|
+
context.addIssue({ ...issue, path: [...prefix, ...issue.path] });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Structural alternatives support editor autocomplete; runtime dispatch gives focused errors.
|
|
145
|
+
export const MONGO_FILTER_SCHEMA = createGrammar({ dispatch: false });
|
|
146
|
+
export const MONGO_FILTER_VALIDATOR = createGrammar({ dispatch: true });
|
|
147
|
+
// Export as a child so Zod names recursive references using its metadata ID instead of `#`.
|
|
148
|
+
// These definitions can then be embedded directly in the complete sync config schema.
|
|
149
|
+
export const MONGO_FILTER_JSON_SCHEMA_DEFINITIONS = z.toJSONSchema(z.object({ mongodb_filter_expression: MONGO_FILTER_SCHEMA }), {
|
|
150
|
+
// Match the draft supported by our default AJV validator.
|
|
151
|
+
target: 'draft-7',
|
|
152
|
+
io: 'input',
|
|
153
|
+
// Share repeated schemas instead of expanding them at every occurrence.
|
|
154
|
+
reused: 'ref'
|
|
155
|
+
}).definitions;
|
|
156
|
+
/**
|
|
157
|
+
* Validates authored input without replacing it with Zod's parsed output.
|
|
158
|
+
*
|
|
159
|
+
* The base path locates the expression within the config. Validation errors may point inside nested
|
|
160
|
+
* expression objects or operand arrays, so their relative paths are appended to that base path and
|
|
161
|
+
* resolved through sourceLocationResolver to highlight the specific key or value in the original source.
|
|
162
|
+
*/
|
|
163
|
+
export function parseMongoFilterExpression({ value, basePath, sourceLocationResolver }) {
|
|
164
|
+
const result = MONGO_FILTER_VALIDATOR.safeParse(value);
|
|
165
|
+
const errors = [];
|
|
166
|
+
for (const issue of result.success ? [] : result.error.issues) {
|
|
167
|
+
// Extra properties point to their keys; operand failures point to their values.
|
|
168
|
+
const targets = issue.code === 'unrecognized_keys'
|
|
169
|
+
? issue.keys.map((key) => ({ path: [...issue.path, key], target: 'key' }))
|
|
170
|
+
: [
|
|
171
|
+
{
|
|
172
|
+
path: issue.path,
|
|
173
|
+
target: issue.code === 'custom' && issue.params?.target === 'key' ? 'key' : 'value'
|
|
174
|
+
}
|
|
175
|
+
];
|
|
176
|
+
for (const { path: relativePath, target } of targets) {
|
|
177
|
+
const path = [...basePath, ...relativePath.map((part) => (typeof part === 'symbol' ? String(part) : part))];
|
|
178
|
+
errors.push(new YamlError(new Error(`Invalid MongoDB pre-filtering expression: ${issue.message}`), sourceLocationResolver.getLocation(path, target)));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return errors;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=MongoFilterExpression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongoFilterExpression.js","sourceRoot":"","sources":["../../src/mongo/MongoFilterExpression.ts"],"names":[],"mappings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EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,KAAc,EAAE,CAAC,CAAC;YACnF,CAAC,CAAC;gBACE;oBACE,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,CAAE,KAAe,CAAC,CAAC,CAAE,OAAiB;iBAC1G;aACF,CAAC;QACR,KAAK,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;YACrD,MAAM,IAAI,GAAG,CAAC,GAAG,QAAQ,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC5G,MAAM,CAAC,IAAI,CACT,IAAI,SAAS,CACX,IAAI,KAAK,CAAC,6CAA6C,KAAK,CAAC,OAAO,EAAE,CAAC,EACvE,sBAAsB,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CACjD,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ErrorLocation } from '../errors.js';
|
|
2
|
+
import type { SyncConfigSourceLocationTarget, SyncConfigSourcePath } from '../SyncConfigDiagnostics.js';
|
|
3
|
+
/**
|
|
4
|
+
* A path into the authored expression, e.g. `['expression', '$eq', 1, '$oid']`, without configured literal values.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MongoFilterValidationError extends Error {
|
|
7
|
+
readonly location?: ErrorLocation;
|
|
8
|
+
readonly detail: string;
|
|
9
|
+
readonly path: SyncConfigSourcePath;
|
|
10
|
+
readonly target: SyncConfigSourceLocationTarget;
|
|
11
|
+
/**
|
|
12
|
+
* Formats the diagnostic path and retains its key/value target for YAML source highlighting.
|
|
13
|
+
*/
|
|
14
|
+
constructor({ path, message, target, location }: {
|
|
15
|
+
path: SyncConfigSourcePath;
|
|
16
|
+
message: string;
|
|
17
|
+
target?: SyncConfigSourceLocationTarget;
|
|
18
|
+
location?: ErrorLocation;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Supported single-key Extended JSON wrappers. Payload validation belongs to the individual codecs.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SUPPORTED_EXTENDED_JSON_WRAPPERS: ReadonlySet<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Authored documents are plain JSON objects; native Date/BSON instances must use their EJSON spelling.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isMongoDocument(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A path into the authored expression, e.g. `['expression', '$eq', 1, '$oid']`, without configured literal values.
|
|
3
|
+
*/
|
|
4
|
+
export class MongoFilterValidationError extends Error {
|
|
5
|
+
location;
|
|
6
|
+
detail;
|
|
7
|
+
path;
|
|
8
|
+
target;
|
|
9
|
+
/**
|
|
10
|
+
* Formats the diagnostic path and retains its key/value target for YAML source highlighting.
|
|
11
|
+
*/
|
|
12
|
+
constructor({ path, message, target = 'value', location }) {
|
|
13
|
+
const formattedPath = path
|
|
14
|
+
.map((part, index) => (typeof part == 'number' ? `[${part}]` : `${index ? '.' : ''}${part}`))
|
|
15
|
+
.join('');
|
|
16
|
+
super(`Invalid MongoDB pre-filtering expression at '${formattedPath}': ${message}`);
|
|
17
|
+
this.name = 'MongoFilterValidationError';
|
|
18
|
+
this.detail = message;
|
|
19
|
+
this.location = location;
|
|
20
|
+
this.path = path;
|
|
21
|
+
this.target = target;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Supported single-key Extended JSON wrappers. Payload validation belongs to the individual codecs.
|
|
26
|
+
*/
|
|
27
|
+
export const SUPPORTED_EXTENDED_JSON_WRAPPERS = new Set([
|
|
28
|
+
'$oid',
|
|
29
|
+
'$numberInt',
|
|
30
|
+
'$numberLong',
|
|
31
|
+
'$numberDouble',
|
|
32
|
+
'$numberDecimal',
|
|
33
|
+
'$date',
|
|
34
|
+
'$timestamp',
|
|
35
|
+
'$binary',
|
|
36
|
+
'$uuid'
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Authored documents are plain JSON objects; native Date/BSON instances must use their EJSON spelling.
|
|
40
|
+
*/
|
|
41
|
+
export function isMongoDocument(value) {
|
|
42
|
+
if (value == null || typeof value != 'object')
|
|
43
|
+
return false;
|
|
44
|
+
const prototype = Object.getPrototypeOf(value);
|
|
45
|
+
return prototype === Object.prototype || prototype === null;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=MongoFilterValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongoFilterValidation.js","sourceRoot":"","sources":["../../src/mongo/MongoFilterValidation.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,QAAQ,CAAiB;IACzB,MAAM,CAAS;IACf,IAAI,CAAuB;IAC3B,MAAM,CAAiC;IAEhD;;OAEG;IACH,YAAY,EACV,IAAI,EACJ,OAAO,EACP,MAAM,GAAG,OAAO,EAChB,QAAQ,EAMT;QACC,MAAM,aAAa,GAAG,IAAI;aACvB,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;aAC5F,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,KAAK,CAAC,gDAAgD,aAAa,MAAM,OAAO,EAAE,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAwB,IAAI,GAAG,CAAC;IAC3E,MAAM;IACN,YAAY;IACZ,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,OAAO;IACP,YAAY;IACZ,SAAS;IACT,OAAO;CACR,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5D,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC;AAC9D,CAAC"}
|
|
@@ -29,6 +29,7 @@ export declare class TsSchemaGenerator extends SchemaGenerator {
|
|
|
29
29
|
generate(source: SyncConfig, schema: SourceSchema, options?: GenerateSchemaOptions): string;
|
|
30
30
|
private generateTypeExports;
|
|
31
31
|
private generateImports;
|
|
32
|
+
private importClause;
|
|
32
33
|
private generateTable;
|
|
33
34
|
private generateStreamHelper;
|
|
34
35
|
private generateColumn;
|
|
@@ -62,21 +62,27 @@ ${streamsHelper ?? ''}`;
|
|
|
62
62
|
}
|
|
63
63
|
generateImports(includeSyncStreams) {
|
|
64
64
|
const importStyle = this.options.imports ?? 'auto';
|
|
65
|
-
const
|
|
66
|
-
if (includeSyncStreams) {
|
|
67
|
-
importedNames.push(...['PowerSyncDatabase', 'SyncStream']);
|
|
68
|
-
}
|
|
69
|
-
const importStart = `import { ${importedNames.join(', ')} } from`;
|
|
65
|
+
const importClause = this.importClause(includeSyncStreams);
|
|
70
66
|
if (importStyle == TsSchemaImports.web) {
|
|
71
|
-
return
|
|
67
|
+
return `import { ${importClause} } from '@powersync/web';`;
|
|
72
68
|
}
|
|
73
69
|
else if (importStyle == TsSchemaImports.reactNative) {
|
|
74
|
-
return
|
|
70
|
+
return `import { ${importClause} } from '@powersync/react-native';`;
|
|
75
71
|
}
|
|
76
72
|
else {
|
|
77
|
-
return
|
|
78
|
-
// OR: ${
|
|
73
|
+
return `import { ${importClause} } from '@powersync/web';
|
|
74
|
+
// OR: import { ${importClause} } from '@powersync/react-native';`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
importClause(includeSyncStreams) {
|
|
78
|
+
const importedNames = ['column', 'Schema', 'Table'];
|
|
79
|
+
if (!includeSyncStreams) {
|
|
80
|
+
return importedNames.join(', ');
|
|
81
|
+
}
|
|
82
|
+
if (this.language == TsSchemaLanguage.ts) {
|
|
83
|
+
return `${importedNames.join(', ')}, type PowerSyncDatabase, type SyncStream`;
|
|
79
84
|
}
|
|
85
|
+
return `${importedNames.join(', ')}, PowerSyncDatabase, SyncStream`;
|
|
80
86
|
}
|
|
81
87
|
generateTable(name, columns, options) {
|
|
82
88
|
const generated = columns.map((c, i) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TsSchemaGenerator.js","sourceRoot":"","sources":["../../src/schema-generators/TsSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGxG,OAAO,EAAyB,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAO3F,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAg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AS,GAAG,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAC;YAChD,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;CACF"}
|
package/dist/sync_plan/plan.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BucketPriority } from '../BucketDescription.js';
|
|
2
2
|
import { ParameterLookupDefinitionId } from '../HydrationState.js';
|
|
3
|
+
import type { SourceTableConfigMap } from '../SourceTableConfig.js';
|
|
3
4
|
import { ImplicitSchemaTablePattern } from '../TablePattern.js';
|
|
4
5
|
import { SqlExpression } from './expression.js';
|
|
5
6
|
/**
|
|
@@ -20,6 +21,7 @@ import { SqlExpression } from './expression.js';
|
|
|
20
21
|
* but we must never alter the semantics for existing serialized plans.
|
|
21
22
|
*/
|
|
22
23
|
export interface SyncPlan {
|
|
24
|
+
sourceTableConfig?: SourceTableConfigMap;
|
|
23
25
|
dataSources: StreamDataSource[];
|
|
24
26
|
buckets: StreamBucketDataSource[];
|
|
25
27
|
parameterIndexes: StreamParameterIndexLookupCreator[];
|