@powersync/service-sync-rules 0.28.0 → 0.29.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/LICENSE +3 -3
- package/dist/BaseSqlDataQuery.d.ts +9 -1
- package/dist/BaseSqlDataQuery.js +42 -0
- package/dist/BaseSqlDataQuery.js.map +1 -1
- package/dist/BucketDescription.d.ts +16 -0
- package/dist/BucketParameterQuerier.d.ts +19 -3
- package/dist/BucketParameterQuerier.js.map +1 -1
- package/dist/BucketSource.d.ts +72 -0
- package/dist/BucketSource.js +6 -0
- package/dist/BucketSource.js.map +1 -0
- package/dist/ExpressionType.d.ts +1 -0
- package/dist/ExpressionType.js.map +1 -1
- package/dist/SqlBucketDescriptor.d.ts +40 -8
- package/dist/SqlBucketDescriptor.js +78 -10
- package/dist/SqlBucketDescriptor.js.map +1 -1
- package/dist/SqlDataQuery.d.ts +4 -3
- package/dist/SqlDataQuery.js +10 -30
- package/dist/SqlDataQuery.js.map +1 -1
- package/dist/SqlParameterQuery.d.ts +4 -4
- package/dist/SqlParameterQuery.js +9 -4
- package/dist/SqlParameterQuery.js.map +1 -1
- package/dist/SqlSyncRules.d.ts +55 -7
- package/dist/SqlSyncRules.js +126 -47
- package/dist/SqlSyncRules.js.map +1 -1
- package/dist/StaticSqlParameterQuery.d.ts +2 -2
- package/dist/StaticSqlParameterQuery.js +3 -2
- package/dist/StaticSqlParameterQuery.js.map +1 -1
- package/dist/TableValuedFunctionSqlParameterQuery.d.ts +2 -2
- package/dist/TableValuedFunctionSqlParameterQuery.js +11 -10
- package/dist/TableValuedFunctionSqlParameterQuery.js.map +1 -1
- package/dist/TableValuedFunctions.d.ts +2 -2
- package/dist/TableValuedFunctions.js +38 -35
- package/dist/TableValuedFunctions.js.map +1 -1
- package/dist/compatibility.d.ts +39 -0
- package/dist/compatibility.js +54 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/events/SqlEventDescriptor.d.ts +3 -1
- package/dist/events/SqlEventDescriptor.js +4 -2
- package/dist/events/SqlEventDescriptor.js.map +1 -1
- package/dist/events/SqlEventSourceQuery.d.ts +2 -1
- package/dist/events/SqlEventSourceQuery.js +3 -2
- package/dist/events/SqlEventSourceQuery.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/json_schema.js +54 -1
- package/dist/json_schema.js.map +1 -1
- package/dist/request_functions.d.ts +24 -4
- package/dist/request_functions.js +68 -17
- package/dist/request_functions.js.map +1 -1
- package/dist/schema-generators/SchemaGenerator.js +2 -12
- package/dist/schema-generators/SchemaGenerator.js.map +1 -1
- package/dist/sql_filters.d.ts +25 -2
- package/dist/sql_filters.js +223 -119
- package/dist/sql_filters.js.map +1 -1
- package/dist/sql_functions.d.ts +13 -31
- package/dist/sql_functions.js +191 -114
- package/dist/sql_functions.js.map +1 -1
- package/dist/sql_support.d.ts +20 -0
- package/dist/sql_support.js +67 -14
- package/dist/sql_support.js.map +1 -1
- package/dist/streams/filter.d.ts +148 -0
- package/dist/streams/filter.js +426 -0
- package/dist/streams/filter.js.map +1 -0
- package/dist/streams/from_sql.d.ts +4 -0
- package/dist/streams/from_sql.js +375 -0
- package/dist/streams/from_sql.js.map +1 -0
- package/dist/streams/functions.d.ts +2 -0
- package/dist/streams/functions.js +38 -0
- package/dist/streams/functions.js.map +1 -0
- package/dist/streams/parameter.d.ts +67 -0
- package/dist/streams/parameter.js +2 -0
- package/dist/streams/parameter.js.map +1 -0
- package/dist/streams/stream.d.ts +40 -0
- package/dist/streams/stream.js +139 -0
- package/dist/streams/stream.js.map +1 -0
- package/dist/streams/utils.d.ts +1 -0
- package/dist/streams/utils.js +13 -0
- package/dist/streams/utils.js.map +1 -0
- package/dist/streams/variant.d.ts +122 -0
- package/dist/streams/variant.js +266 -0
- package/dist/streams/variant.js.map +1 -0
- package/dist/types/custom_sqlite_value.d.ts +38 -0
- package/dist/types/custom_sqlite_value.js +50 -0
- package/dist/types/custom_sqlite_value.js.map +1 -0
- package/dist/types/time.d.ts +33 -0
- package/dist/types/time.js +67 -0
- package/dist/types/time.js.map +1 -0
- package/dist/types.d.ts +52 -9
- package/dist/types.js +28 -2
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +9 -6
- package/dist/utils.js +42 -17
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/schema/sync_rules.json +80 -2
|
@@ -17,6 +17,7 @@ export class StaticSqlParameterQuery {
|
|
|
17
17
|
table: undefined,
|
|
18
18
|
parameterTables: ['token_parameters', 'user_parameters'],
|
|
19
19
|
supportsParameterExpressions: true,
|
|
20
|
+
compatibilityContext: options.compatibility,
|
|
20
21
|
sql
|
|
21
22
|
});
|
|
22
23
|
const where = q.where;
|
|
@@ -111,7 +112,7 @@ export class StaticSqlParameterQuery {
|
|
|
111
112
|
this.filter = options.filter;
|
|
112
113
|
this.errors = options.errors ?? [];
|
|
113
114
|
}
|
|
114
|
-
getStaticBucketDescriptions(parameters) {
|
|
115
|
+
getStaticBucketDescriptions(parameters, transformer) {
|
|
115
116
|
if (this.filter == null) {
|
|
116
117
|
// Error in filter clause
|
|
117
118
|
return [];
|
|
@@ -134,7 +135,7 @@ export class StaticSqlParameterQuery {
|
|
|
134
135
|
}
|
|
135
136
|
return [
|
|
136
137
|
{
|
|
137
|
-
bucket: getBucketId(this.descriptorName, this.bucketParameters, result),
|
|
138
|
+
bucket: getBucketId(this.descriptorName, this.bucketParameters, result, transformer),
|
|
138
139
|
priority: this.priority
|
|
139
140
|
}
|
|
140
141
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticSqlParameterQuery.js","sourceRoot":"","sources":["../src/StaticSqlParameterQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAA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AAI,oCAAoC;QACtC,2DAA2D;QAC3D,MAAM,qBAAqB,GAAG,IAAI,CAAC,MAAM,EAAE,oCAAoC,CAAC;QAEhF,+CAA+C;QAC/C,MAAM,wBAAwB,GAC5B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAC1C,CAAC,MAAM,EAAE,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,oCAAoC,CAC1F,IAAI,IAAI,CAAC;QAEZ,OAAO,qBAAqB,IAAI,wBAAwB,CAAC;IAC3D,CAAC;IAED,IAAI,8BAA8B;QAChC,OAAO,IAAI,CAAC,oCAAoC,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC;IAC7F,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FromCall, SelectFromStatement } from 'pgsql-ast-parser';
|
|
2
2
|
import { SqlRuleError } from './errors.js';
|
|
3
3
|
import { TableValuedFunction } from './TableValuedFunctions.js';
|
|
4
|
-
import { ParameterValueClause, QueryParseOptions, RequestParameters } from './types.js';
|
|
4
|
+
import { BucketIdTransformer, ParameterValueClause, QueryParseOptions, RequestParameters } from './types.js';
|
|
5
5
|
import { BucketDescription, BucketPriority } from './BucketDescription.js';
|
|
6
6
|
export interface TableValuedFunctionSqlParameterQueryOptions {
|
|
7
7
|
sql: string;
|
|
@@ -82,7 +82,7 @@ export declare class TableValuedFunctionSqlParameterQuery {
|
|
|
82
82
|
readonly callTableName: string;
|
|
83
83
|
readonly errors: SqlRuleError[];
|
|
84
84
|
constructor(options: TableValuedFunctionSqlParameterQueryOptions);
|
|
85
|
-
getStaticBucketDescriptions(parameters: RequestParameters): BucketDescription[];
|
|
85
|
+
getStaticBucketDescriptions(parameters: RequestParameters, transformer: BucketIdTransformer): BucketDescription[];
|
|
86
86
|
private getIndividualBucketDescription;
|
|
87
87
|
get hasAuthenticatedBucketParameters(): boolean;
|
|
88
88
|
get usesUnauthenticatedRequestParameters(): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SqlRuleError } from './errors.js';
|
|
2
2
|
import { SqlTools } from './sql_filters.js';
|
|
3
3
|
import { checkUnsupportedFeatures, isClauseError, isParameterValueClause, sqliteBool } from './sql_support.js';
|
|
4
|
-
import {
|
|
4
|
+
import { generateTableValuedFunctions } from './TableValuedFunctions.js';
|
|
5
5
|
import { getBucketId, isJsonValue } from './utils.js';
|
|
6
6
|
import { DEFAULT_BUCKET_PRIORITY } from './BucketDescription.js';
|
|
7
7
|
/**
|
|
@@ -15,9 +15,11 @@ import { DEFAULT_BUCKET_PRIORITY } from './BucketDescription.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export class TableValuedFunctionSqlParameterQuery {
|
|
17
17
|
static fromSql(descriptorName, sql, call, q, options, queryId) {
|
|
18
|
+
const compatibility = options.compatibility;
|
|
18
19
|
let errors = [];
|
|
19
20
|
errors.push(...checkUnsupportedFeatures(sql, q));
|
|
20
|
-
|
|
21
|
+
const tableValuedFunctions = generateTableValuedFunctions(compatibility);
|
|
22
|
+
if (!(call.function.name in tableValuedFunctions)) {
|
|
21
23
|
throw new SqlRuleError(`Table-valued function ${call.function.name} is not defined.`, sql, call);
|
|
22
24
|
}
|
|
23
25
|
const callTable = call.alias?.name ?? call.function.name;
|
|
@@ -26,6 +28,7 @@ export class TableValuedFunctionSqlParameterQuery {
|
|
|
26
28
|
table: callTable,
|
|
27
29
|
parameterTables: ['token_parameters', 'user_parameters', callTable],
|
|
28
30
|
supportsParameterExpressions: true,
|
|
31
|
+
compatibilityContext: compatibility,
|
|
29
32
|
sql
|
|
30
33
|
});
|
|
31
34
|
const where = q.where;
|
|
@@ -33,7 +36,7 @@ export class TableValuedFunctionSqlParameterQuery {
|
|
|
33
36
|
const callClause = tools.compileParameterValueExtractor(callExpression);
|
|
34
37
|
const columns = q.columns ?? [];
|
|
35
38
|
const bucketParameters = columns.map((column) => tools.getOutputName(column));
|
|
36
|
-
const functionImpl =
|
|
39
|
+
const functionImpl = tableValuedFunctions[call.function.name];
|
|
37
40
|
let priority = options.priority;
|
|
38
41
|
let parameterExtractors = {};
|
|
39
42
|
for (let column of columns) {
|
|
@@ -140,7 +143,7 @@ export class TableValuedFunctionSqlParameterQuery {
|
|
|
140
143
|
this.callTableName = options.callTableName;
|
|
141
144
|
this.errors = options.errors;
|
|
142
145
|
}
|
|
143
|
-
getStaticBucketDescriptions(parameters) {
|
|
146
|
+
getStaticBucketDescriptions(parameters, transformer) {
|
|
144
147
|
if (this.filter == null || this.callClause == null) {
|
|
145
148
|
// Error in filter clause
|
|
146
149
|
return [];
|
|
@@ -149,18 +152,16 @@ export class TableValuedFunctionSqlParameterQuery {
|
|
|
149
152
|
const rows = this.function.call([valueString]);
|
|
150
153
|
let total = [];
|
|
151
154
|
for (let row of rows) {
|
|
152
|
-
const description = this.getIndividualBucketDescription(row, parameters);
|
|
155
|
+
const description = this.getIndividualBucketDescription(row, parameters, transformer);
|
|
153
156
|
if (description !== null) {
|
|
154
157
|
total.push(description);
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
160
|
return total;
|
|
158
161
|
}
|
|
159
|
-
getIndividualBucketDescription(row, parameters) {
|
|
162
|
+
getIndividualBucketDescription(row, parameters, transformer) {
|
|
160
163
|
const mergedParams = {
|
|
161
|
-
|
|
162
|
-
rawUserParameters: parameters.rawUserParameters,
|
|
163
|
-
userId: parameters.userId,
|
|
164
|
+
...parameters,
|
|
164
165
|
lookup: (table, column) => {
|
|
165
166
|
if (table == this.callTableName) {
|
|
166
167
|
return row[column];
|
|
@@ -185,7 +186,7 @@ export class TableValuedFunctionSqlParameterQuery {
|
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
188
|
return {
|
|
188
|
-
bucket: getBucketId(this.descriptorName, this.bucketParameters, result),
|
|
189
|
+
bucket: getBucketId(this.descriptorName, this.bucketParameters, result, transformer),
|
|
189
190
|
priority: this.priority
|
|
190
191
|
};
|
|
191
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableValuedFunctionSqlParameterQuery.js","sourceRoot":"","sources":["../src/TableValuedFunctionSqlParameterQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"TableValuedFunctionSqlParameterQuery.js","sourceRoot":"","sources":["../src/TableValuedFunctionSqlParameterQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,4BAA4B,EAAuB,MAAM,2BAA2B,CAAC;AAU9F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAqC,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAkBpG;;;;;;;;GAQG;AACH,MAAM,OAAO,oCAAoC;IAC/C,MAAM,CAAC,OAAO,CACZ,cAAsB,EACtB,GAAW,EACX,IAAc,EACd,CAAsB,EACtB,OAA0B,EAC1B,OAAe;QAEf,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC5C,IAAI,MAAM,GAAmB,EAAE,CAAC;QAEhC,MAAM,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAEjD,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,aAAa,CAAC,CAAC;QACzE,IAAI,CAAC,CAAC,IAAI,CAAC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UAAU,EAAE,oCAAoC,IAAI,KAAK,CAAC;QAE/F,OAAO,qBAAqB,IAAI,wBAAwB,IAAI,uBAAuB,CAAC;IACtF,CAAC;IAED,IAAI,8BAA8B;QAChC,OAAO,IAAI,CAAC,oCAAoC,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC;IAC7F,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompatibilityContext } from './compatibility.js';
|
|
1
2
|
import { SqliteRow, SqliteValue } from './types.js';
|
|
2
3
|
export interface TableValuedFunction {
|
|
3
4
|
readonly name: string;
|
|
@@ -5,5 +6,4 @@ export interface TableValuedFunction {
|
|
|
5
6
|
detail: string;
|
|
6
7
|
documentation: string;
|
|
7
8
|
}
|
|
8
|
-
export declare
|
|
9
|
-
export declare const TABLE_VALUED_FUNCTIONS: Record<string, TableValuedFunction>;
|
|
9
|
+
export declare function generateTableValuedFunctions(compatibility: CompatibilityContext): Record<string, TableValuedFunction>;
|
|
@@ -1,37 +1,40 @@
|
|
|
1
|
+
import { CompatibilityOption } from './compatibility.js';
|
|
1
2
|
import { jsonValueToSqlite } from './utils.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
3
|
+
function jsonEachImplementation(fixedJsonBehavior) {
|
|
4
|
+
return {
|
|
5
|
+
name: 'json_each',
|
|
6
|
+
call(args) {
|
|
7
|
+
if (args.length != 1) {
|
|
8
|
+
throw new Error(`json_each expects 1 argument, got ${args.length}`);
|
|
9
|
+
}
|
|
10
|
+
const valueString = args[0];
|
|
11
|
+
if (valueString === null) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
else if (typeof valueString !== 'string') {
|
|
15
|
+
throw new Error(`Expected json_each to be called with a string, got ${valueString}`);
|
|
16
|
+
}
|
|
17
|
+
let values = [];
|
|
18
|
+
try {
|
|
19
|
+
values = JSON.parse(valueString);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
throw new Error('Expected JSON string');
|
|
23
|
+
}
|
|
24
|
+
if (!Array.isArray(values)) {
|
|
25
|
+
throw new Error(`Expected an array, got ${valueString}`);
|
|
26
|
+
}
|
|
27
|
+
return values.map((v) => {
|
|
28
|
+
return {
|
|
29
|
+
value: jsonValueToSqlite(fixedJsonBehavior, v)
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
detail: 'Each element of a JSON array',
|
|
34
|
+
documentation: 'Returns each element of a JSON array as a separate row.'
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function generateTableValuedFunctions(compatibility) {
|
|
38
|
+
return { json_each: jsonEachImplementation(compatibility.isEnabled(CompatibilityOption.fixedJsonExtract)) };
|
|
39
|
+
}
|
|
37
40
|
//# sourceMappingURL=TableValuedFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableValuedFunctions.js","sourceRoot":"","sources":["../src/TableValuedFunctions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableValuedFunctions.js","sourceRoot":"","sources":["../src/TableValuedFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAS/C,SAAS,sBAAsB,CAAC,iBAA0B;IACxD,O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AC9G,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare enum CompatibilityEdition {
|
|
2
|
+
LEGACY = 1,
|
|
3
|
+
SYNC_STREAMS = 2
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A historical issue of the PowerSync service that can only be changed in a backwards-incompatible manner.
|
|
7
|
+
*
|
|
8
|
+
* To avoid breaking existing users, fixes to those quirks are opt-in: Users either have to use `fixed_quirks` list when
|
|
9
|
+
* defining sync rules or use a new feature such as sync streams where these issues are fixed by default.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CompatibilityOption {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly fixedIn: CompatibilityEdition;
|
|
15
|
+
private constructor();
|
|
16
|
+
static timestampsIso8601: CompatibilityOption;
|
|
17
|
+
static versionedBucketIds: CompatibilityOption;
|
|
18
|
+
static fixedJsonExtract: CompatibilityOption;
|
|
19
|
+
static byName: Record<string, CompatibilityOption>;
|
|
20
|
+
}
|
|
21
|
+
export declare class CompatibilityContext {
|
|
22
|
+
/**
|
|
23
|
+
* The general compatibility level we're operating under.
|
|
24
|
+
*
|
|
25
|
+
* This is {@link CompatibilityEdition.LEGACY} by default, but can be changed when defining sync rules to allow newer
|
|
26
|
+
* features.
|
|
27
|
+
*/
|
|
28
|
+
readonly edition: CompatibilityEdition;
|
|
29
|
+
/**
|
|
30
|
+
* Overrides to customize used compatibility options to deviate from defaults at the given {@link edition}.
|
|
31
|
+
*/
|
|
32
|
+
readonly overrides: Map<CompatibilityOption, boolean>;
|
|
33
|
+
constructor(edition: CompatibilityEdition, overrides?: Map<CompatibilityOption, boolean>);
|
|
34
|
+
isEnabled(option: CompatibilityOption): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* A {@link CompatibilityContext} in which no fixes are applied.
|
|
37
|
+
*/
|
|
38
|
+
static FULL_BACKWARDS_COMPATIBILITY: CompatibilityContext;
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export var CompatibilityEdition;
|
|
2
|
+
(function (CompatibilityEdition) {
|
|
3
|
+
CompatibilityEdition[CompatibilityEdition["LEGACY"] = 1] = "LEGACY";
|
|
4
|
+
CompatibilityEdition[CompatibilityEdition["SYNC_STREAMS"] = 2] = "SYNC_STREAMS";
|
|
5
|
+
})(CompatibilityEdition || (CompatibilityEdition = {}));
|
|
6
|
+
/**
|
|
7
|
+
* A historical issue of the PowerSync service that can only be changed in a backwards-incompatible manner.
|
|
8
|
+
*
|
|
9
|
+
* To avoid breaking existing users, fixes to those quirks are opt-in: Users either have to use `fixed_quirks` list when
|
|
10
|
+
* defining sync rules or use a new feature such as sync streams where these issues are fixed by default.
|
|
11
|
+
*/
|
|
12
|
+
export class CompatibilityOption {
|
|
13
|
+
name;
|
|
14
|
+
description;
|
|
15
|
+
fixedIn;
|
|
16
|
+
constructor(name, description, fixedIn) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.description = description;
|
|
19
|
+
this.fixedIn = fixedIn;
|
|
20
|
+
}
|
|
21
|
+
static timestampsIso8601 = new CompatibilityOption('timestamps_iso8601', 'Consistently renders timestamps with an ISO 8601-compatible format (previous versions used a space instead of a T to separate date and time).', CompatibilityEdition.SYNC_STREAMS);
|
|
22
|
+
static versionedBucketIds = new CompatibilityOption('versioned_bucket_ids', 'Encode the version of sync rules in generated bucket ids, which avoids clients downloading data twice and improves client-side progress estimates.', CompatibilityEdition.SYNC_STREAMS);
|
|
23
|
+
static fixedJsonExtract = new CompatibilityOption('fixed_json_extract', "Old versions of the sync service used to treat `->> 'foo.bar'` as a two-element JSON path. With this compatibility option enabled, it follows modern SQLite and treats it as a single key. The `$.` prefix would be required to split on `.`.", CompatibilityEdition.SYNC_STREAMS);
|
|
24
|
+
static byName = Object.freeze({
|
|
25
|
+
timestamps_iso8601: this.timestampsIso8601,
|
|
26
|
+
versioned_bucket_ids: this.versionedBucketIds,
|
|
27
|
+
fixed_json_extract: this.fixedJsonExtract
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export class CompatibilityContext {
|
|
31
|
+
/**
|
|
32
|
+
* The general compatibility level we're operating under.
|
|
33
|
+
*
|
|
34
|
+
* This is {@link CompatibilityEdition.LEGACY} by default, but can be changed when defining sync rules to allow newer
|
|
35
|
+
* features.
|
|
36
|
+
*/
|
|
37
|
+
edition;
|
|
38
|
+
/**
|
|
39
|
+
* Overrides to customize used compatibility options to deviate from defaults at the given {@link edition}.
|
|
40
|
+
*/
|
|
41
|
+
overrides;
|
|
42
|
+
constructor(edition, overrides) {
|
|
43
|
+
this.edition = edition;
|
|
44
|
+
this.overrides = overrides ?? new Map();
|
|
45
|
+
}
|
|
46
|
+
isEnabled(option) {
|
|
47
|
+
return this.overrides.get(option) ?? option.fixedIn <= this.edition;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A {@link CompatibilityContext} in which no fixes are applied.
|
|
51
|
+
*/
|
|
52
|
+
static FULL_BACKWARDS_COMPATIBILITY = new CompatibilityContext(CompatibilityEdition.LEGACY);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,mEAAU,CAAA;IACV,+EAAgB,CAAA;AAClB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAEnB;IACA;IACA;IAHX,YACW,IAAY,EACZ,WAAmB,EACnB,OAA6B;QAF7B,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAsB;IACrC,CAAC;IAEJ,MAAM,CAAC,iBAAiB,GAAG,IAAI,mBAAmB,CAChD,oBAAoB,EACpB,+IAA+I,EAC/I,oBAAoB,CAAC,YAAY,CAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,GAAG,IAAI,mBAAmB,CACjD,sBAAsB,EACtB,oJAAoJ,EACpJ,oBAAoB,CAAC,YAAY,CAClC,CAAC;IAEF,MAAM,CAAC,gBAAgB,GAAG,IAAI,mBAAmB,CAC/C,oBAAoB,EACpB,+OAA+O,EAC/O,oBAAoB,CAAC,YAAY,CAClC,CAAC;IAEF,MAAM,CAAC,MAAM,GAAwC,MAAM,CAAC,MAAM,CAAC;QACjE,kBAAkB,EAAE,IAAI,CAAC,iBAAiB;QAC1C,oBAAoB,EAAE,IAAI,CAAC,kBAAkB;QAC7C,kBAAkB,EAAE,IAAI,CAAC,gBAAgB;KAC1C,CAAC,CAAC;;AAGL,MAAM,OAAO,oBAAoB;IAC/B;;;;;OAKG;IACM,OAAO,CAAuB;IAEvC;;OAEG;IACM,SAAS,CAAoC;IAEtD,YAAY,OAA6B,EAAE,SAA6C;QACtF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,GAAG,EAAE,CAAC;IAC1C,CAAC;IAED,SAAS,CAAC,MAA2B;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,4BAA4B,GAAyB,IAAI,oBAAoB,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompatibilityContext } from '../compatibility.js';
|
|
1
2
|
import { SourceTableInterface } from '../SourceTableInterface.js';
|
|
2
3
|
import { QueryParseResult } from '../SqlBucketDescriptor.js';
|
|
3
4
|
import { SyncRulesOptions } from '../SqlSyncRules.js';
|
|
@@ -8,9 +9,10 @@ import { EvaluatedEventRowWithErrors, SqlEventSourceQuery } from './SqlEventSour
|
|
|
8
9
|
* A sync rules event which is triggered from a SQL table change.
|
|
9
10
|
*/
|
|
10
11
|
export declare class SqlEventDescriptor {
|
|
12
|
+
private readonly compatibility;
|
|
11
13
|
name: string;
|
|
12
14
|
sourceQueries: SqlEventSourceQuery[];
|
|
13
|
-
constructor(name: string);
|
|
15
|
+
constructor(name: string, compatibility: CompatibilityContext);
|
|
14
16
|
addSourceQuery(sql: string, options: SyncRulesOptions): QueryParseResult;
|
|
15
17
|
evaluateRowWithErrors(options: EvaluateRowOptions): EvaluatedEventRowWithErrors;
|
|
16
18
|
getSourceTables(): Set<TablePattern>;
|
|
@@ -4,13 +4,15 @@ import { SqlEventSourceQuery } from './SqlEventSourceQuery.js';
|
|
|
4
4
|
* A sync rules event which is triggered from a SQL table change.
|
|
5
5
|
*/
|
|
6
6
|
export class SqlEventDescriptor {
|
|
7
|
+
compatibility;
|
|
7
8
|
name;
|
|
8
9
|
sourceQueries = [];
|
|
9
|
-
constructor(name) {
|
|
10
|
+
constructor(name, compatibility) {
|
|
11
|
+
this.compatibility = compatibility;
|
|
10
12
|
this.name = name;
|
|
11
13
|
}
|
|
12
14
|
addSourceQuery(sql, options) {
|
|
13
|
-
const source = SqlEventSourceQuery.fromSql(this.name, sql, options);
|
|
15
|
+
const source = SqlEventSourceQuery.fromSql(this.name, sql, options, this.compatibility);
|
|
14
16
|
// Each source query should be for a unique table
|
|
15
17
|
const existingSourceQuery = this.sourceQueries.find((q) => q.table == source.table);
|
|
16
18
|
if (existingSourceQuery) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlEventDescriptor.js","sourceRoot":"","sources":["../../src/events/SqlEventDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SqlEventDescriptor.js","sourceRoot":"","sources":["../../src/events/SqlEventDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,E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AE,4CAA4C,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;aAC5F,CAAC;QACJ,CAAC;QAED,OAAO,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAClF,CAAC;IAED,eAAe;QACb,IAAI,MAAM,GAAG,IAAI,GAAG,EAAgB,CAAC;QACrC,KAAK,IAAI,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAY,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,kBAAkB,CAAC,KAA2B;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -2,6 +2,7 @@ import { BaseSqlDataQuery, BaseSqlDataQueryOptions } from '../BaseSqlDataQuery.j
|
|
|
2
2
|
import { SourceTableInterface } from '../SourceTableInterface.js';
|
|
3
3
|
import { SyncRulesOptions } from '../SqlSyncRules.js';
|
|
4
4
|
import { EvaluationError, SqliteJsonRow, SqliteRow } from '../types.js';
|
|
5
|
+
import { CompatibilityContext } from '../compatibility.js';
|
|
5
6
|
export type EvaluatedEventSourceRow = {
|
|
6
7
|
data: SqliteJsonRow;
|
|
7
8
|
};
|
|
@@ -13,7 +14,7 @@ export type EvaluatedEventRowWithErrors = {
|
|
|
13
14
|
* Defines how a Replicated Row is mapped to source parameters for events.
|
|
14
15
|
*/
|
|
15
16
|
export declare class SqlEventSourceQuery extends BaseSqlDataQuery {
|
|
16
|
-
static fromSql(descriptor_name: string, sql: string, options: SyncRulesOptions): SqlEventSourceQuery;
|
|
17
|
+
static fromSql(descriptor_name: string, sql: string, options: SyncRulesOptions, compatibility: CompatibilityContext): SqlEventSourceQuery;
|
|
17
18
|
constructor(options: BaseSqlDataQueryOptions);
|
|
18
19
|
evaluateRowWithErrors(table: SourceTableInterface, row: SqliteRow): EvaluatedEventRowWithErrors;
|
|
19
20
|
}
|
|
@@ -11,7 +11,7 @@ import { isSelectStatement } from '../utils.js';
|
|
|
11
11
|
* Defines how a Replicated Row is mapped to source parameters for events.
|
|
12
12
|
*/
|
|
13
13
|
export class SqlEventSourceQuery extends BaseSqlDataQuery {
|
|
14
|
-
static fromSql(descriptor_name, sql, options) {
|
|
14
|
+
static fromSql(descriptor_name, sql, options, compatibility) {
|
|
15
15
|
const parsed = parse(sql, { locationTracking: true });
|
|
16
16
|
const schema = options.schema;
|
|
17
17
|
if (parsed.length > 1) {
|
|
@@ -49,7 +49,8 @@ export class SqlEventSourceQuery extends BaseSqlDataQuery {
|
|
|
49
49
|
parameterTables: [],
|
|
50
50
|
valueTables: [alias],
|
|
51
51
|
sql,
|
|
52
|
-
schema: querySchema
|
|
52
|
+
schema: querySchema,
|
|
53
|
+
compatibilityContext: compatibility
|
|
53
54
|
});
|
|
54
55
|
let extractors = [];
|
|
55
56
|
for (let column of q.columns ?? []) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlEventSourceQuery.js","sourceRoot":"","sources":["../../src/events/SqlEventSourceQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAA8C,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,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,GAAc;QAC/D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,KAAM,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YAExE,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACvC,OAAO;gBACL,MAAM,EAAE;oBACN,IAAI;iBACL;gBACD,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,8BAA8B,CAAC,EAAE,CAAC;QACnE,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './BucketDescription.js';
|
|
2
2
|
export * from './BucketParameterQuerier.js';
|
|
3
|
+
export * from './BucketSource.js';
|
|
4
|
+
export * from './compatibility.js';
|
|
3
5
|
export * from './errors.js';
|
|
4
6
|
export * from './events/SqlEventDescriptor.js';
|
|
5
7
|
export * from './events/SqlEventSourceQuery.js';
|
|
@@ -11,10 +13,15 @@ export * from './schema-generators/schema-generators.js';
|
|
|
11
13
|
export * from './SourceTableInterface.js';
|
|
12
14
|
export * from './sql_filters.js';
|
|
13
15
|
export * from './sql_functions.js';
|
|
16
|
+
export { SqlBucketDescriptor } from './SqlBucketDescriptor.js';
|
|
14
17
|
export * from './SqlDataQuery.js';
|
|
15
18
|
export * from './SqlParameterQuery.js';
|
|
16
19
|
export * from './SqlSyncRules.js';
|
|
17
20
|
export * from './StaticSchema.js';
|
|
21
|
+
export { SyncStream } from './streams/stream.js';
|
|
22
|
+
export { syncStreamFromSql } from './streams/from_sql.js';
|
|
18
23
|
export * from './TablePattern.js';
|
|
19
24
|
export * from './types.js';
|
|
25
|
+
export * from './types/custom_sqlite_value.js';
|
|
26
|
+
export * from './types/time.js';
|
|
20
27
|
export * from './utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './BucketDescription.js';
|
|
2
2
|
export * from './BucketParameterQuerier.js';
|
|
3
|
+
export * from './BucketSource.js';
|
|
4
|
+
export * from './compatibility.js';
|
|
3
5
|
export * from './errors.js';
|
|
4
6
|
export * from './events/SqlEventDescriptor.js';
|
|
5
7
|
export * from './events/SqlEventSourceQuery.js';
|
|
@@ -11,11 +13,16 @@ export * from './schema-generators/schema-generators.js';
|
|
|
11
13
|
export * from './SourceTableInterface.js';
|
|
12
14
|
export * from './sql_filters.js';
|
|
13
15
|
export * from './sql_functions.js';
|
|
16
|
+
export { SqlBucketDescriptor } from './SqlBucketDescriptor.js';
|
|
14
17
|
export * from './SqlDataQuery.js';
|
|
15
18
|
export * from './SqlParameterQuery.js';
|
|
16
19
|
export * from './SqlSyncRules.js';
|
|
17
20
|
export * from './StaticSchema.js';
|
|
21
|
+
export { SyncStream } from './streams/stream.js';
|
|
22
|
+
export { syncStreamFromSql } from './streams/from_sql.js';
|
|
18
23
|
export * from './TablePattern.js';
|
|
19
24
|
export * from './types.js';
|
|
25
|
+
export * from './types/custom_sqlite_value.js';
|
|
26
|
+
export * from './types/time.js';
|
|
20
27
|
export * from './utils.js';
|
|
21
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0CAA0C,CAAC;AACzD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0CAA0C,CAAC;AACzD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
package/dist/json_schema.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ajvModule from 'ajv';
|
|
2
|
+
import { CompatibilityEdition, CompatibilityOption } from './compatibility.js';
|
|
2
3
|
// Hack to make this work both in NodeJS and a browser
|
|
3
4
|
const Ajv = ajvModule.default ?? ajvModule;
|
|
4
5
|
const ajv = new Ajv({ allErrors: true, verbose: true });
|
|
@@ -48,6 +49,36 @@ export const syncRulesSchema = {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
},
|
|
52
|
+
streams: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
description: 'List of stream definitions',
|
|
55
|
+
examples: [{ user_details: { query: 'select * from users where id = auth.user_id()' } }],
|
|
56
|
+
patternProperties: {
|
|
57
|
+
'.*': {
|
|
58
|
+
type: 'object',
|
|
59
|
+
required: ['query'],
|
|
60
|
+
examples: [{ query: ['select * from mytable'] }],
|
|
61
|
+
properties: {
|
|
62
|
+
accept_potentially_dangerous_queries: {
|
|
63
|
+
description: 'If true, disables warnings on potentially dangerous queries',
|
|
64
|
+
type: 'boolean'
|
|
65
|
+
},
|
|
66
|
+
auto_subscribe: {
|
|
67
|
+
description: 'Whether clients will subscribe to this stream by default.',
|
|
68
|
+
type: 'boolean'
|
|
69
|
+
},
|
|
70
|
+
priority: {
|
|
71
|
+
description: 'Priority for the bucket (lower values indicate higher priority).',
|
|
72
|
+
type: 'integer'
|
|
73
|
+
},
|
|
74
|
+
query: {
|
|
75
|
+
description: 'The SQL query defining content to sync in this stream.',
|
|
76
|
+
type: 'string'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
51
82
|
event_definitions: {
|
|
52
83
|
type: 'object',
|
|
53
84
|
description: 'Record of sync replication event definitions',
|
|
@@ -76,9 +107,31 @@ export const syncRulesSchema = {
|
|
|
76
107
|
}
|
|
77
108
|
}
|
|
78
109
|
}
|
|
110
|
+
},
|
|
111
|
+
config: {
|
|
112
|
+
type: 'object',
|
|
113
|
+
description: 'Config declaring the compatibility level used to parse these definitions.',
|
|
114
|
+
properties: {
|
|
115
|
+
edition: {
|
|
116
|
+
type: 'integer',
|
|
117
|
+
default: CompatibilityEdition.LEGACY,
|
|
118
|
+
minimum: CompatibilityEdition.LEGACY,
|
|
119
|
+
exclusiveMaximum: CompatibilityEdition.SYNC_STREAMS + 1
|
|
120
|
+
},
|
|
121
|
+
...Object.fromEntries(Object.entries(CompatibilityOption.byName).map((e) => {
|
|
122
|
+
return [
|
|
123
|
+
e[0],
|
|
124
|
+
{
|
|
125
|
+
type: 'boolean',
|
|
126
|
+
description: `Enabled by default starting from edition ${e[1].fixedIn}: ${e[1].description}`
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
}))
|
|
130
|
+
},
|
|
131
|
+
additionalProperties: false
|
|
79
132
|
}
|
|
80
133
|
},
|
|
81
|
-
required: ['bucket_definitions'],
|
|
134
|
+
anyOf: [{ required: ['bucket_definitions'] }, { required: ['streams'] }],
|
|
82
135
|
additionalProperties: false
|
|
83
136
|
};
|
|
84
137
|
export const validateSyncRulesSchema = ajv.compile(syncRulesSchema);
|