@powersync/service-sync-rules 0.0.0-dev-20260909133214 → 0.0.0-dev-20260929095716
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/README.md +49 -14
- package/dist/BucketSource.d.ts +2 -2
- package/dist/ConnectionConfig.d.ts +39 -0
- package/dist/ConnectionConfig.js +97 -0
- package/dist/ConnectionConfig.js.map +1 -0
- package/dist/HydratedSyncConfig.d.ts +2 -0
- package/dist/HydratedSyncConfig.js +6 -3
- package/dist/HydratedSyncConfig.js.map +1 -1
- package/dist/SqlSyncRules.d.ts +15 -0
- package/dist/SqlSyncRules.js +3 -1
- package/dist/SqlSyncRules.js.map +1 -1
- package/dist/SyncConfig.d.ts +8 -1
- package/dist/SyncConfig.js +7 -1
- package/dist/SyncConfig.js.map +1 -1
- package/dist/SyncConfigParserHooks.d.ts +103 -0
- package/dist/SyncConfigParserHooks.js +11 -0
- package/dist/SyncConfigParserHooks.js.map +1 -0
- package/dist/compatibility.d.ts +2 -1
- package/dist/compatibility.js +4 -2
- package/dist/compatibility.js.map +1 -1
- package/dist/compiler/compiler.d.ts +4 -4
- package/dist/compiler/compiler.js +2 -2
- package/dist/compiler/equality.d.ts +2 -2
- package/dist/compiler/equality.js +2 -2
- package/dist/compiler/expression.d.ts +3 -3
- package/dist/compiler/expression.js +2 -2
- package/dist/compiler/parser.d.ts +1 -1
- package/dist/compiler/parser.js +2 -2
- package/dist/compiler/sqlite.js +1 -2
- package/dist/compiler/sqlite.js.map +1 -1
- package/dist/compiler/table.d.ts +2 -2
- package/dist/compiler/table.js +1 -1
- package/dist/from_yaml.d.ts +14 -1
- package/dist/from_yaml.js +77 -19
- package/dist/from_yaml.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -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 +11 -0
- package/dist/json_schema.js +26 -3
- package/dist/json_schema.js.map +1 -1
- package/dist/legacy/BaseSqlDataQuery.d.ts +12 -0
- package/dist/legacy/BaseSqlDataQuery.js +3 -0
- package/dist/legacy/BaseSqlDataQuery.js.map +1 -1
- package/dist/legacy/SqlBucketDescriptor.d.ts +9 -0
- package/dist/legacy/SqlBucketDescriptor.js +6 -0
- package/dist/legacy/SqlBucketDescriptor.js.map +1 -1
- package/dist/legacy/SqlDataQuery.d.ts +6 -0
- package/dist/legacy/SqlDataQuery.js +3 -0
- package/dist/legacy/SqlDataQuery.js.map +1 -1
- package/dist/legacy/SqlParameterQuery.d.ts +4 -0
- package/dist/legacy/SqlParameterQuery.js +1 -0
- package/dist/legacy/SqlParameterQuery.js.map +1 -1
- package/dist/legacy/StaticSqlParameterQuery.d.ts +4 -0
- package/dist/legacy/StaticSqlParameterQuery.js +1 -0
- package/dist/legacy/StaticSqlParameterQuery.js.map +1 -1
- package/dist/legacy/TableQuerySchema.d.ts +1 -0
- package/dist/legacy/TableQuerySchema.js +1 -0
- package/dist/legacy/TableQuerySchema.js.map +1 -1
- package/dist/legacy/TableValuedFunctionSqlParameterQuery.d.ts +4 -0
- package/dist/legacy/TableValuedFunctionSqlParameterQuery.js +1 -0
- package/dist/legacy/TableValuedFunctionSqlParameterQuery.js.map +1 -1
- package/dist/legacy/sql_filters.d.ts +13 -0
- package/dist/legacy/sql_filters.js +10 -0
- package/dist/legacy/sql_filters.js.map +1 -1
- package/dist/legacy/sql_support.d.ts +33 -0
- package/dist/legacy/sql_support.js +33 -0
- package/dist/legacy/sql_support.js.map +1 -1
- package/dist/legacy/streams/filter.d.ts +22 -0
- package/dist/legacy/streams/filter.js +19 -0
- package/dist/legacy/streams/filter.js.map +1 -1
- package/dist/legacy/streams/from_sql.d.ts +3 -0
- package/dist/legacy/streams/from_sql.js +4 -1
- package/dist/legacy/streams/from_sql.js.map +1 -1
- package/dist/legacy/streams/functions.d.ts +3 -0
- package/dist/legacy/streams/functions.js +3 -0
- package/dist/legacy/streams/functions.js.map +1 -1
- package/dist/legacy/streams/parameter.d.ts +10 -0
- package/dist/legacy/streams/stream.d.ts +7 -1
- package/dist/legacy/streams/stream.js +7 -1
- package/dist/legacy/streams/stream.js.map +1 -1
- package/dist/legacy/streams/variant.d.ts +6 -0
- package/dist/legacy/streams/variant.js +1 -0
- package/dist/legacy/streams/variant.js.map +1 -1
- package/dist/legacy/validators.d.ts +1 -0
- package/dist/legacy/validators.js +1 -0
- package/dist/legacy/validators.js.map +1 -1
- package/dist/sql_functions.d.ts +1 -1
- package/dist/sync_plan/evaluator/bucket_source.js +1 -1
- package/dist/sync_plan/evaluator/index.js +1 -0
- package/dist/sync_plan/evaluator/index.js.map +1 -1
- package/dist/sync_plan/evaluator/parameter_evaluator.d.ts +1 -1
- package/dist/sync_plan/evaluator/parameter_evaluator.js +1 -1
- package/dist/sync_plan/plan.d.ts +7 -1
- package/dist/sync_plan/schema_inference.d.ts +1 -1
- package/dist/sync_plan/schema_inference.js +1 -1
- package/dist/sync_plan/serialize.d.ts +18 -2
- package/dist/sync_plan/serialize.js +34 -6
- package/dist/sync_plan/serialize.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +43 -12
- package/dist/utils.js.map +1 -1
- package/dist/yaml_source_locations.d.ts +14 -0
- package/dist/yaml_source_locations.js +117 -0
- package/dist/yaml_source_locations.js.map +1 -0
- package/dist/yaml_validation.js.map +1 -1
- package/package.json +2 -1
- package/schema/sync_rules.json +46 -1
package/README.md
CHANGED
|
@@ -1,19 +1,56 @@
|
|
|
1
|
-
# powersync-sync-rules
|
|
1
|
+
# @powersync/service-sync-rules
|
|
2
2
|
|
|
3
|
-
A library containing logic for PowerSync sync config.
|
|
3
|
+
A library containing the parsing, compilation and evaluation logic for the PowerSync sync config.
|
|
4
4
|
|
|
5
5
|
This is not intended to be used directly by users of PowerSync. If you are interested in the internals, read on.
|
|
6
6
|
|
|
7
7
|
# Overview
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The sync config is the YAML document that defines which data each client receives. It supports two engines:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
- **Sync Streams** (`streams:`): the current engine. Queries are compiled by `src/compiler/` into a sync plan and evaluated by `src/sync_plan/`. Requires `config: edition: 3`.
|
|
12
|
+
- **Legacy Sync Rules** (`bucket_definitions:`): deprecated. Implemented in `src/legacy/` and kept only so that existing deployments keep working. Do not add features there. See [Legacy Sync Rules](#legacy-sync-rules-deprecated).
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Both engines define the same two operations:
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
1. Given a data row, compute the list of buckets it belongs to.
|
|
17
|
+
2. Given an authenticated request, return the list of buckets to sync.
|
|
18
|
+
|
|
19
|
+
None of the SQL is executed against a database. It is used to pre-process replicated rows into a format for efficient sync.
|
|
20
|
+
|
|
21
|
+
`SqlSyncRules.fromYaml()` in `src/SqlSyncRules.ts` parses either engine into a `SyncConfig`. The service hydrates it with persisted state into a `HydratedSyncConfig` (`src/HydratedSyncConfig.ts`), which is what replication and sync use at runtime.
|
|
22
|
+
|
|
23
|
+
# Sync Streams
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
config:
|
|
29
|
+
edition: 3
|
|
30
|
+
|
|
31
|
+
streams:
|
|
32
|
+
lists:
|
|
33
|
+
auto_subscribe: true
|
|
34
|
+
query: SELECT * FROM lists WHERE owner_id = auth.user_id()
|
|
35
|
+
todos:
|
|
36
|
+
query: SELECT * FROM todos WHERE list_id = subscription.parameter('list_id')
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
A stream is one or more SQL queries over source tables. Streams with `auto_subscribe: true` sync when the client connects. Other streams sync when the client subscribes to them, optionally with parameters read through `subscription.parameter()`. Request-level values come from `auth.*` functions (JWT claims) and `connection.parameters()`.
|
|
40
|
+
|
|
41
|
+
Compilation and evaluation:
|
|
42
|
+
|
|
43
|
+
1. `SyncStreamsCompiler` (`src/compiler/compiler.ts`) parses each query and builds an intermediate representation. Compilation is schema-independent; the source schema, when available, is only used for validation warnings and output schema inference.
|
|
44
|
+
2. `toSyncPlan()` produces a `SyncPlan` (`src/sync_plan/plan.ts`) describing bucket data sources, parameter lookups and queriers. The plan is serialized and stored alongside the deployed config.
|
|
45
|
+
3. `PrecompiledSyncConfig` (`src/sync_plan/evaluator/`) evaluates the plan at runtime, using either the JavaScript or the SQLite expression engine (`src/sync_plan/engine/`).
|
|
46
|
+
|
|
47
|
+
The grammar is in `grammar/sync-streams-compiler.ebnf`. User documentation: https://docs.powersync.com/sync/streams/overview.
|
|
48
|
+
|
|
49
|
+
# Legacy Sync Rules (deprecated)
|
|
50
|
+
|
|
51
|
+
Sync Rules are deprecated in favour of Sync Streams. The sections below document the legacy implementation in `src/legacy/`, which is preserved for backwards compatibility only.
|
|
52
|
+
|
|
53
|
+
Legacy Sync Rules define the two operations above with explicit queries: parameter queries return the buckets for a request, and data queries assign rows to buckets.
|
|
17
54
|
|
|
18
55
|
Example:
|
|
19
56
|
|
|
@@ -30,8 +67,6 @@ bucket_definitions:
|
|
|
30
67
|
|
|
31
68
|
For the above example, a document with `org_id: 'org1'` will belong to a single bucket `by_org["org1"]`. Similarly, a user with `org_id: 'org1'` will sync the bucket `by_org["org1"]`.
|
|
32
69
|
|
|
33
|
-
An important aspect is that none of these SQL queries are actually executed against any SQL database. Instead, it is used to pre-process data before storing the data in a format for efficient sync operations.
|
|
34
|
-
|
|
35
70
|
When data is replicated from the source database to PowerSync, we do two things for each row:
|
|
36
71
|
|
|
37
72
|
1. Evaluate data queries on the row: `syncRules.evaluateRow(row)`.
|
|
@@ -39,9 +74,9 @@ When data is replicated from the source database to PowerSync, we do two things
|
|
|
39
74
|
|
|
40
75
|
Data queries also have the option to transform the row instead of just using `select *`. We store the transformed data for each of the buckets it belongs to.
|
|
41
76
|
|
|
42
|
-
|
|
77
|
+
## Query Structure
|
|
43
78
|
|
|
44
|
-
|
|
79
|
+
### Data queries
|
|
45
80
|
|
|
46
81
|
A data query is turned into a function `(row) => Array<{bucket, data}>`. The main implementation is in the `SqlDataQuery` class.
|
|
47
82
|
|
|
@@ -67,14 +102,14 @@ bucket.param IN mytable.some_array -- ParameterMatchClause
|
|
|
67
102
|
(mytable.column1 = bucket.param) OR (mytable.column2 = bucket.param) -- ParameterMatchClause
|
|
68
103
|
```
|
|
69
104
|
|
|
70
|
-
|
|
105
|
+
### Parameter Queries
|
|
71
106
|
|
|
72
107
|
There are two types of parameter queries:
|
|
73
108
|
|
|
74
109
|
1. Queries without tables. These just operate on request parameters. Example: `select token_parameters.user_id`. Thes are implemented in the `StaticSqlParameterQuery` class.
|
|
75
110
|
2. Queries with tables. Example: `select org_id from users where id = token_parameters.user_id`. These use parameter tables, and are implemented in `SqlParameterQuery`. These are used to pre-process rows in the parameter tables for efficient lookup later.
|
|
76
111
|
|
|
77
|
-
|
|
112
|
+
#### StaticSqlParameterQuery
|
|
78
113
|
|
|
79
114
|
These are effecitively just a function of `(request) => Array[{bucket}]`. These queries can select values from request parameters, and apply filters from request parameters.
|
|
80
115
|
|
|
@@ -90,7 +125,7 @@ request.parameters() -- ParameterValueClause
|
|
|
90
125
|
fn(token_parameters.param) -- ParameterValueClause. This includes most operators.
|
|
91
126
|
```
|
|
92
127
|
|
|
93
|
-
|
|
128
|
+
#### SqlParameterQuery
|
|
94
129
|
|
|
95
130
|
These queries pre-process parameter tables to effectively create an "index" for efficient queries when syncing.
|
|
96
131
|
|
package/dist/BucketSource.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface HydrationInput extends CreateSourceParams {
|
|
|
20
20
|
scalarExpressions: ScalarExpressionEngine;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* A BucketSource is a _logical_ bucket or
|
|
23
|
+
* A BucketSource is a _logical_ bucket or Sync Stream definition. It is primarily used to group together
|
|
24
24
|
* related BucketDataSource, BucketParameterLookupSource and BucketParameterQuerierSource definitions,
|
|
25
25
|
* for the purpose of subscribing to specific streams. It does not directly define the implementation
|
|
26
26
|
* or replication process.
|
|
@@ -70,7 +70,7 @@ export type ScopedEvaluateParameterRow = (sourceTable: SourceTableRef, row: Sqli
|
|
|
70
70
|
* Encodes a static definition of a bucket source, as parsed from sync rules or stream definitions.
|
|
71
71
|
*
|
|
72
72
|
* This does not require any "hydration" itself: All results are independent of bucket names.
|
|
73
|
-
* The higher-level
|
|
73
|
+
* The higher-level HydratedSyncConfig will use a HydrationState to generate bucket names.
|
|
74
74
|
*/
|
|
75
75
|
export interface BucketDataSource {
|
|
76
76
|
/**
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as t from 'ts-codec';
|
|
2
|
+
import type { JsonObject } from './json.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for one source table, such as `config.connections.default.tables.orders`. This repo has no table options yet.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SOURCE_TABLE_CONFIG: t.ObjectCodec<{}>;
|
|
7
|
+
export type SourceTableConfig = t.Decoded<typeof SOURCE_TABLE_CONFIG>;
|
|
8
|
+
/**
|
|
9
|
+
* Shared connection structure. A source module specializes the table codec to describe its additional options.
|
|
10
|
+
*/
|
|
11
|
+
export declare function connectionConfigCodec<T extends t.AnyCodec>(tableConfig: T): t.ObjectCodec<{
|
|
12
|
+
type: t.IdentityCodec<t.CodecType.String>;
|
|
13
|
+
tables: t.OptionalCodec<t.Codec<Record<string, t.Ix<T>>, Record<string, t.Ox<T>>, string, t.CodecProps>>;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const CONNECTION_CONFIG: t.ObjectCodec<{
|
|
16
|
+
type: t.IdentityCodec<t.CodecType.String>;
|
|
17
|
+
tables: t.OptionalCodec<t.Codec<Record<string, {}>, Record<string, {}>, string, t.CodecProps>>;
|
|
18
|
+
}>;
|
|
19
|
+
export type ConnectionConfig<TTableConfig extends SourceTableConfig = SourceTableConfig> = {
|
|
20
|
+
readonly type: string;
|
|
21
|
+
readonly tables?: Readonly<Partial<Record<string, TTableConfig>>>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Connection tags are map keys; table names and patterns remain relative to their connection's default schema.
|
|
25
|
+
*/
|
|
26
|
+
export type ConnectionConfigMap = Readonly<Partial<Record<string, ConnectionConfig>>>;
|
|
27
|
+
/**
|
|
28
|
+
* Generate the common shape while making the empty base table option explicit, regardless of generator defaults.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createConnectionConfigSchema(): JsonObject;
|
|
31
|
+
/**
|
|
32
|
+
* Validate and copy portable connection options, preserving module-owned fields.
|
|
33
|
+
* Sort connection tags only: table declaration order can determine wildcard precedence, and literal object order matters.
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeConnectionConfig(value: unknown): ConnectionConfigMap;
|
|
36
|
+
/**
|
|
37
|
+
* Conservative equality: an expression rewrite may require a new snapshot even if MongoDB evaluates it identically.
|
|
38
|
+
*/
|
|
39
|
+
export declare function connectionConfigsEqual(left: ConnectionConfigMap, right: ConnectionConfigMap): boolean;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as t from 'ts-codec';
|
|
2
|
+
/**
|
|
3
|
+
* Options for one source table, such as `config.connections.default.tables.orders`. This repo has no table options yet.
|
|
4
|
+
*/
|
|
5
|
+
export const SOURCE_TABLE_CONFIG = t.object({});
|
|
6
|
+
/**
|
|
7
|
+
* Shared connection structure. A source module specializes the table codec to describe its additional options.
|
|
8
|
+
*/
|
|
9
|
+
export function connectionConfigCodec(tableConfig) {
|
|
10
|
+
return t.object({ type: t.string, tables: t.record(tableConfig).optional() });
|
|
11
|
+
}
|
|
12
|
+
export const CONNECTION_CONFIG = connectionConfigCodec(SOURCE_TABLE_CONFIG);
|
|
13
|
+
/**
|
|
14
|
+
* Generate the common shape while making the empty base table option explicit, regardless of generator defaults.
|
|
15
|
+
*/
|
|
16
|
+
export function createConnectionConfigSchema() {
|
|
17
|
+
const connection = t.generateJSONSchema(CONNECTION_CONFIG, { allowAdditional: false });
|
|
18
|
+
const properties = connection.properties;
|
|
19
|
+
properties.type = { type: 'string', minLength: 1 };
|
|
20
|
+
properties.tables = {
|
|
21
|
+
type: 'object',
|
|
22
|
+
propertyNames: { minLength: 1 },
|
|
23
|
+
additionalProperties: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {},
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
maxProperties: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// The empty connection spelling means no options. Nonempty connections require their discriminator.
|
|
31
|
+
return {
|
|
32
|
+
type: 'object',
|
|
33
|
+
propertyNames: { minLength: 1 },
|
|
34
|
+
additionalProperties: {
|
|
35
|
+
anyOf: [{ type: 'object', additionalProperties: false, maxProperties: 0 }, connection]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Validate and copy portable connection options, preserving module-owned fields.
|
|
41
|
+
* Sort connection tags only: table declaration order can determine wildcard precedence, and literal object order matters.
|
|
42
|
+
*/
|
|
43
|
+
export function normalizeConnectionConfig(value) {
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
return {};
|
|
46
|
+
assertJsonObject(value);
|
|
47
|
+
const entries = Object.entries(value).sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
|
|
48
|
+
return Object.fromEntries(entries.flatMap(([tag, config]) => {
|
|
49
|
+
assertJsonObject(config);
|
|
50
|
+
if (!tag)
|
|
51
|
+
throw new Error('A connection tag must not be empty.');
|
|
52
|
+
if (Object.keys(config).length == 0)
|
|
53
|
+
return [];
|
|
54
|
+
if (typeof config.type != 'string' || !config.type)
|
|
55
|
+
throw new Error('A connection type must not be empty.');
|
|
56
|
+
if (config.tables !== undefined) {
|
|
57
|
+
assertJsonObject(config.tables);
|
|
58
|
+
for (const [table, options] of Object.entries(config.tables)) {
|
|
59
|
+
if (!table)
|
|
60
|
+
throw new Error('A source table name must not be empty.');
|
|
61
|
+
assertJsonObject(options);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return [[tag, structuredClone(config)]];
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Conservative equality: an expression rewrite may require a new snapshot even if MongoDB evaluates it identically.
|
|
69
|
+
*/
|
|
70
|
+
export function connectionConfigsEqual(left, right) {
|
|
71
|
+
return JSON.stringify(normalizeConnectionConfig(left)) == JSON.stringify(normalizeConnectionConfig(right));
|
|
72
|
+
}
|
|
73
|
+
function assertJsonObject(value) {
|
|
74
|
+
if (value == null || typeof value != 'object' || Array.isArray(value)) {
|
|
75
|
+
throw new Error('Connection and table configuration must be JSON objects.');
|
|
76
|
+
}
|
|
77
|
+
assertJsonValue(value, new Set());
|
|
78
|
+
}
|
|
79
|
+
function assertJsonValue(value, parents) {
|
|
80
|
+
if (value === null || typeof value == 'string' || typeof value == 'boolean')
|
|
81
|
+
return;
|
|
82
|
+
if (typeof value == 'number' && Number.isFinite(value))
|
|
83
|
+
return;
|
|
84
|
+
if (typeof value != 'object' || parents.has(value)) {
|
|
85
|
+
throw new Error('Connection configuration must contain finite, acyclic JSON values.');
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(value) &&
|
|
88
|
+
Object.getPrototypeOf(value) !== Object.prototype &&
|
|
89
|
+
Object.getPrototypeOf(value) !== null) {
|
|
90
|
+
throw new Error('Connection configuration must contain plain JSON objects.');
|
|
91
|
+
}
|
|
92
|
+
parents.add(value);
|
|
93
|
+
for (const child of Object.values(value))
|
|
94
|
+
assertJsonValue(child, parents);
|
|
95
|
+
parents.delete(value);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=ConnectionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionConfig.js","sourceRoot":"","sources":["../src/ConnectionConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B;;GAEG;AACH,MAAM,CAAC,MAAM,mBAA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AAM,CAAC,CAAC;IACpB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAM,CAAC;QAAE,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3E,OAAO,CAAC,MAAM,CAAC,KAAM,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BucketDataSource } from './BucketSource.js';
|
|
2
|
+
import { ConnectionConfigMap } from './ConnectionConfig.js';
|
|
2
3
|
import { BucketSource, CompatibilityContext, EvaluatedParameters, EvaluatedRow, EvaluationError, GetBucketParameterQuerierResult, GetQuerierOptions, HydratedEventDescriptor, HydrateSyncConfigParams, ParameterIndexLookupCreator, SqliteInputValue, SqliteValue, SyncConfig, TablePattern } from './index.js';
|
|
3
4
|
import { SourceTableRef } from './SourceTableRef.js';
|
|
4
5
|
import { EvaluateRowOptions, SqliteRow } from './types.js';
|
|
@@ -17,6 +18,7 @@ export interface MatchingSources {
|
|
|
17
18
|
*/
|
|
18
19
|
export declare class HydratedSyncConfig {
|
|
19
20
|
#private;
|
|
21
|
+
readonly connectionConfig: ConnectionConfigMap;
|
|
20
22
|
/**
|
|
21
23
|
* These are used by queriers, and do not support merging across multiple SyncConfigs.
|
|
22
24
|
*/
|
|
@@ -12,6 +12,7 @@ import { applyRowContext, uniqueBy } from './utils.js';
|
|
|
12
12
|
* The persisted state specifically affects bucket names, as well as V3+ storage structure.
|
|
13
13
|
*/
|
|
14
14
|
export class HydratedSyncConfig {
|
|
15
|
+
connectionConfig;
|
|
15
16
|
/**
|
|
16
17
|
* These are used by queriers, and do not support merging across multiple SyncConfigs.
|
|
17
18
|
*/
|
|
@@ -54,8 +55,10 @@ export class HydratedSyncConfig {
|
|
|
54
55
|
const hydrationState = params.createParams.hydrationState;
|
|
55
56
|
const definitions = params.definitions;
|
|
56
57
|
if (definitions.length == 0) {
|
|
57
|
-
throw new Error('
|
|
58
|
+
throw new Error('HydratedSyncConfig requires at least one SyncConfig definition');
|
|
58
59
|
}
|
|
60
|
+
// The service validates that definitions sharing a source reader have compatible connection options.
|
|
61
|
+
this.connectionConfig = definitions[0].connectionConfig;
|
|
59
62
|
this.sourceDefinitions = [...definitions];
|
|
60
63
|
this.compatibility = assertSharedCompatibility(this.sourceDefinitions);
|
|
61
64
|
this.hydrationInput = {
|
|
@@ -199,7 +202,7 @@ export class HydratedSyncConfig {
|
|
|
199
202
|
assertSingleSourceDefinition(debugName) {
|
|
200
203
|
// We may split the types in the future to enforce this on a type level instead of runtime level
|
|
201
204
|
if (this.sourceDefinitions.length != 1) {
|
|
202
|
-
throw new Error(`${debugName} is not supported for
|
|
205
|
+
throw new Error(`${debugName} is not supported for HydratedSyncConfig with multiple SyncConfigs`);
|
|
203
206
|
}
|
|
204
207
|
}
|
|
205
208
|
}
|
|
@@ -210,7 +213,7 @@ function assertSharedCompatibility(definitions) {
|
|
|
210
213
|
}
|
|
211
214
|
for (const definition of definitions) {
|
|
212
215
|
if (!definition.compatibility.equals(compatibility)) {
|
|
213
|
-
throw new Error('All SyncConfigs in a
|
|
216
|
+
throw new Error('All SyncConfigs in a HydratedSyncConfig instance must use the same CompatibilityContext');
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
return compatibility;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydratedSyncConfig.js","sourceRoot":"","sources":["../src/HydratedSyncConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HydratedSyncConfig.js","sourceRoot":"","sources":["../src/HydratedSyncConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,oBAAoB,EASpB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,4BAA4B,EAC5B,gBAAgB,EAChB,iCAAiC,EAEjC,uBAAuB,EAQxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAkB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+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,CAAC,OAAO,EACzC,CAAC;gBACD,MAAM,CAAC,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,4BAA4B,CAAC,QAAQ,CAAC,CAAC;QACvD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC;IAEO,4BAA4B,CAAC,SAAiB;QACpD,gGAAgG;QAChG,IAAI,IAAI,CAAC,iBAAiB,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,oEAAoE,CAAC,CAAC;QACpG,CAAC;IACH,CAAC;CACF;AAED,SAAS,yBAAyB,CAAC,WAAyB;IAC1D,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IACnD,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC;QAC7G,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/SqlSyncRules.d.ts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { BucketPriority } from './BucketDescription.js';
|
|
2
2
|
import { SyncConfig, SyncConfigWithErrors } from './SyncConfig.js';
|
|
3
|
+
import type { AdditionalSyncConfigParser } from './SyncConfigParserHooks.js';
|
|
3
4
|
import { YamlError } from './errors.js';
|
|
5
|
+
import type { SyncRulesSchemaValidator } from './json_schema.js';
|
|
4
6
|
import { RequestParameters, SourceSchema, SqliteJsonRow } from './types.js';
|
|
5
7
|
export interface SyncRulesOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Additional parsing hooks. The service supplies its registered hooks; standalone callers and extension tests
|
|
10
|
+
* can supply hooks directly. Defaults to no additional hooks.
|
|
11
|
+
*/
|
|
12
|
+
parsers?: readonly AdditionalSyncConfigParser[];
|
|
13
|
+
/**
|
|
14
|
+
* Compiled schema validator supplied by the service parser. Must match the supplied parsers.
|
|
15
|
+
* Standalone callers, including tests, normally omit this to compose the schema from parsers.
|
|
16
|
+
*/
|
|
17
|
+
schemaValidator?: SyncRulesSchemaValidator;
|
|
18
|
+
/**
|
|
19
|
+
* Source database schema.
|
|
20
|
+
*/
|
|
6
21
|
schema?: SourceSchema;
|
|
7
22
|
/**
|
|
8
23
|
* The default schema to use when only a table name is specified.
|
package/dist/SqlSyncRules.js
CHANGED
|
@@ -23,7 +23,9 @@ export class SqlSyncRules extends SyncConfig {
|
|
|
23
23
|
const parser = new SyncConfigFromYaml({
|
|
24
24
|
throwOnError: options.throwOnError ?? true,
|
|
25
25
|
schema: options.schema,
|
|
26
|
-
defaultSchema: options.defaultSchema
|
|
26
|
+
defaultSchema: options.defaultSchema,
|
|
27
|
+
parsers: options.parsers ?? [],
|
|
28
|
+
schemaValidator: options.schemaValidator
|
|
27
29
|
}, yaml);
|
|
28
30
|
return parser.read();
|
|
29
31
|
}
|
package/dist/SqlSyncRules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlSyncRules.js","sourceRoot":"","sources":["../src/SqlSyncRules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"SqlSyncRules.js","sourceRoot":"","sources":["../src/SqlSyncRules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAwEpD,MAAM,OAAO,YAAa,SAAQ,UAAU;IAC1C,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,OAAyB;QACrD,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC3C,OAAO,KAAK,CAAC,MAAM,CAAC;QACtB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,eAAe,EAAE,CAAC;gBACjC,OAAO,CAAC,CAAC,MAAM,CAAC;YAClB,CAAC;iBAAM,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;gBAClC,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,OAAyB;QACrD,MAAM,MAAM,GAAG,IAAI,kBAAkB,CACnC;YACE,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI;YAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;SACzC,EACD,IAAI,CACL,CAAC;QAEF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;CACF"}
|
package/dist/SyncConfig.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BucketDataSource, BucketSource, HydrateSyncConfigParams, ParameterIndexLookupCreator } from './BucketSource.js';
|
|
2
2
|
import { CompatibilityContext } from './compatibility.js';
|
|
3
|
+
import { ConnectionConfigMap } from './ConnectionConfig.js';
|
|
3
4
|
import { YamlError } from './errors.js';
|
|
4
5
|
import { EventDefinition } from './events/EventDescriptor.js';
|
|
5
6
|
import { HydratedSyncConfig } from './HydratedSyncConfig.js';
|
|
@@ -11,10 +12,16 @@ import { SqliteInputValue, SqliteRow, SqliteValue } from './types.js';
|
|
|
11
12
|
* resolve buckets for connections).
|
|
12
13
|
*/
|
|
13
14
|
export declare abstract class SyncConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Source options keyed by connection tag; module-specific table fields stay opaque to core.
|
|
17
|
+
*/
|
|
18
|
+
connectionConfig: ConnectionConfigMap;
|
|
14
19
|
bucketDataSources: BucketDataSource[];
|
|
15
20
|
bucketParameterLookupSources: ParameterIndexLookupCreator[];
|
|
16
21
|
bucketSources: BucketSource[];
|
|
17
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Prepared event definitions. Executable event descriptors only exist on {@link HydratedSyncConfig}.
|
|
24
|
+
*/
|
|
18
25
|
eventDefinitions: EventDefinition[];
|
|
19
26
|
compatibility: CompatibilityContext;
|
|
20
27
|
/**
|
package/dist/SyncConfig.js
CHANGED
|
@@ -6,10 +6,16 @@ import { applyRowContext } from './utils.js';
|
|
|
6
6
|
* resolve buckets for connections).
|
|
7
7
|
*/
|
|
8
8
|
export class SyncConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Source options keyed by connection tag; module-specific table fields stay opaque to core.
|
|
11
|
+
*/
|
|
12
|
+
connectionConfig = {};
|
|
9
13
|
bucketDataSources = [];
|
|
10
14
|
bucketParameterLookupSources = [];
|
|
11
15
|
bucketSources = [];
|
|
12
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Prepared event definitions. Executable event descriptors only exist on {@link HydratedSyncConfig}.
|
|
18
|
+
*/
|
|
13
19
|
eventDefinitions = [];
|
|
14
20
|
compatibility = CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY;
|
|
15
21
|
/**
|
package/dist/SyncConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncConfig.js","sourceRoot":"","sources":["../src/SyncConfig.ts"],"names":[],"mappings":"AAMA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AAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,oBAAoB,CAAC,KAAqB;QACxC,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,oBAAoB;QAClB,IAAI,MAAM,GAA0B,EAAE,CAAC;QACvC,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC1C,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,mBAAmB;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { JsonObject } from './json.js';
|
|
2
|
+
import type { SyncConfig } from './SyncConfig.js';
|
|
3
|
+
import type { TablePattern } from './TablePattern.js';
|
|
4
|
+
/**
|
|
5
|
+
* A decoded config path, for example `['config', 'connections', 'default', 'tables', 'orders', 'filter']`.
|
|
6
|
+
*/
|
|
7
|
+
export type SyncConfigSourcePath = readonly (string | number)[];
|
|
8
|
+
export type SyncConfigSourceLocationTarget = 'key' | 'value';
|
|
9
|
+
/**
|
|
10
|
+
* Offsets into the authored config, compatible with locations returned by service diagnostics.
|
|
11
|
+
*/
|
|
12
|
+
export interface SyncConfigSourceSpan {
|
|
13
|
+
start_offset: number;
|
|
14
|
+
end_offset: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A parser warning or failure, optionally pointing to the relevant config key or value.
|
|
18
|
+
*/
|
|
19
|
+
export interface SyncConfigDiagnostic {
|
|
20
|
+
level: 'warning' | 'fatal';
|
|
21
|
+
message: string;
|
|
22
|
+
location?: SyncConfigSourceSpan;
|
|
23
|
+
}
|
|
24
|
+
export interface SyncConfigSourceLocationResolver {
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a field to its source span, falling back to its nearest existing ancestor.
|
|
27
|
+
*/
|
|
28
|
+
getLocation(path: SyncConfigSourcePath, target?: SyncConfigSourceLocationTarget): SyncConfigSourceSpan | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Context for parsing input sync config.
|
|
32
|
+
*/
|
|
33
|
+
export interface SyncConfigParserContext {
|
|
34
|
+
readonly defaultSchema: string;
|
|
35
|
+
/**
|
|
36
|
+
* Candidate being assembled. With throwOnError: false, a partial config may be returned with fatal diagnostics.
|
|
37
|
+
* Store options on the appropriate config fields.
|
|
38
|
+
*/
|
|
39
|
+
parsedConfig: SyncConfig;
|
|
40
|
+
/**
|
|
41
|
+
* Sources selected by SQL. Additional parsers may inspect these, but cannot add replication sources.
|
|
42
|
+
*/
|
|
43
|
+
sourceTables: readonly TablePattern[];
|
|
44
|
+
/**
|
|
45
|
+
* Utility helpers for determining source locations.
|
|
46
|
+
*/
|
|
47
|
+
sourceLocations: SyncConfigSourceLocationResolver;
|
|
48
|
+
/**
|
|
49
|
+
* Report a diagnostic found while parsing.
|
|
50
|
+
*/
|
|
51
|
+
reportDiagnostic(diagnostic: SyncConfigDiagnostic): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Context for validating persisted sync config.
|
|
55
|
+
*/
|
|
56
|
+
export interface PersistedSyncConfigParserContext {
|
|
57
|
+
/**
|
|
58
|
+
* Default schema used to resolve unqualified table names during validation.
|
|
59
|
+
* Some callers supply a placeholder; do not persist names qualified using this value.
|
|
60
|
+
*/
|
|
61
|
+
readonly defaultSchema: string;
|
|
62
|
+
/**
|
|
63
|
+
* Report a warning or fatal error found while validating the persisted config.
|
|
64
|
+
* Include a config source location when available. Fatal errors prevent the config from loading.
|
|
65
|
+
*/
|
|
66
|
+
reportDiagnostic(diagnostic: SyncConfigDiagnostic): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Additional deterministic parsing/validation, registered per service rather than globally or by connection type.
|
|
70
|
+
* A hook identifies its own fields and leaves unrelated input alone. Source I/O belongs in source validation.
|
|
71
|
+
*/
|
|
72
|
+
export interface AdditionalSyncConfigParser {
|
|
73
|
+
/**
|
|
74
|
+
* A unique ID for the parser. Persisted sync configs store these IDs to validate
|
|
75
|
+
* if modules which created the persisted config are present.
|
|
76
|
+
*/
|
|
77
|
+
readonly id: string;
|
|
78
|
+
/**
|
|
79
|
+
* Mutates an isolated schema before parsing.
|
|
80
|
+
*/
|
|
81
|
+
extendJsonSchema?(options: {
|
|
82
|
+
schema: JsonObject;
|
|
83
|
+
}): void;
|
|
84
|
+
/**
|
|
85
|
+
* `config` is decoded sync config. Everything else needed to parse it is supplied through `context`.
|
|
86
|
+
* Parse module-owned input into context.parsedConfig, including connectionConfig entries for this module.
|
|
87
|
+
* Core does not copy connection options from the input or normalize the parser's output here.
|
|
88
|
+
* For a PrecompiledSyncConfig, add this parser's ID to parsedConfig.plan.moduleData with a null value
|
|
89
|
+
* when the config requires this module. The plan's keys determine which parsers must be present on reload.
|
|
90
|
+
*/
|
|
91
|
+
parse(options: {
|
|
92
|
+
config: unknown;
|
|
93
|
+
context: SyncConfigParserContext;
|
|
94
|
+
}): void;
|
|
95
|
+
/**
|
|
96
|
+
* Validate saved config fields without reparsing their original config or requiring config source locations.
|
|
97
|
+
*/
|
|
98
|
+
validatePersisted?(options: {
|
|
99
|
+
config: SyncConfig;
|
|
100
|
+
context: PersistedSyncConfigParserContext;
|
|
101
|
+
}): void;
|
|
102
|
+
}
|
|
103
|
+
export declare function validateAdditionalSyncConfigParsers(parsers: readonly AdditionalSyncConfigParser[]): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function validateAdditionalSyncConfigParsers(parsers) {
|
|
2
|
+
const ids = new Set();
|
|
3
|
+
for (const parser of parsers) {
|
|
4
|
+
if (!parser.id)
|
|
5
|
+
throw new Error('A sync config parser id must not be empty.');
|
|
6
|
+
if (ids.has(parser.id))
|
|
7
|
+
throw new Error(`A sync config parser is already registered with id '${parser.id}'.`);
|
|
8
|
+
ids.add(parser.id);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=SyncConfigParserHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncConfigParserHooks.js","sourceRoot":"","sources":["../src/SyncConfigParserHooks.ts"],"names":[],"mappings":"AAyGA,MAAM,UAAU,mCAAmC,CAAC,OAA8C;IAChG,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC9E,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;QAC9G,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class TimeValuePrecision {
|
|
|
17
17
|
* A historical issue of the PowerSync service that can only be changed in a backwards-incompatible manner.
|
|
18
18
|
*
|
|
19
19
|
* To avoid breaking existing users, fixes to those quirks are opt-in: Users either have to use `fixed_quirks` list when
|
|
20
|
-
* defining
|
|
20
|
+
* defining legacy Sync Rules or use a new feature such as Sync Streams where these issues are fixed by default.
|
|
21
21
|
*/
|
|
22
22
|
export declare class CompatibilityOption {
|
|
23
23
|
readonly name: string;
|
|
@@ -29,6 +29,7 @@ export declare class CompatibilityOption {
|
|
|
29
29
|
static fixedJsonExtract: CompatibilityOption;
|
|
30
30
|
static customTypes: CompatibilityOption;
|
|
31
31
|
static sqliteExpressionEngine: CompatibilityOption;
|
|
32
|
+
static fixedBooleanInJson: CompatibilityOption;
|
|
32
33
|
static byName: Record<string, CompatibilityOption>;
|
|
33
34
|
}
|
|
34
35
|
export interface CompatibilityContextOptions {
|
package/dist/compatibility.js
CHANGED
|
@@ -26,7 +26,7 @@ export class TimeValuePrecision {
|
|
|
26
26
|
* A historical issue of the PowerSync service that can only be changed in a backwards-incompatible manner.
|
|
27
27
|
*
|
|
28
28
|
* To avoid breaking existing users, fixes to those quirks are opt-in: Users either have to use `fixed_quirks` list when
|
|
29
|
-
* defining
|
|
29
|
+
* defining legacy Sync Rules or use a new feature such as Sync Streams where these issues are fixed by default.
|
|
30
30
|
*/
|
|
31
31
|
export class CompatibilityOption {
|
|
32
32
|
name;
|
|
@@ -42,12 +42,14 @@ export class CompatibilityOption {
|
|
|
42
42
|
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);
|
|
43
43
|
static customTypes = new CompatibilityOption('custom_postgres_types', 'Map custom Postgres types into appropriate structures instead of syncing the raw string.', CompatibilityEdition.SYNC_STREAMS);
|
|
44
44
|
static sqliteExpressionEngine = new CompatibilityOption('unstable_sqlite_expression_engine', 'Experimental option to evaluate functions and operators in Sync Streams with SQLite instead of a JavaScript implementation.', null);
|
|
45
|
+
static fixedBooleanInJson = new CompatibilityOption('fixed_booleans_in_json', 'Consistently sync boolean values of a JSON object or array in source data as booleans (instead of integers 0/1).', null);
|
|
45
46
|
static byName = Object.freeze({
|
|
46
47
|
timestamps_iso8601: this.timestampsIso8601,
|
|
47
48
|
versioned_bucket_ids: this.versionedBucketIds,
|
|
48
49
|
fixed_json_extract: this.fixedJsonExtract,
|
|
49
50
|
custom_postgres_types: this.customTypes,
|
|
50
|
-
unstable_sqlite_expression_engine: this.sqliteExpressionEngine
|
|
51
|
+
unstable_sqlite_expression_engine: this.sqliteExpressionEngine,
|
|
52
|
+
fixed_booleans_in_json: this.fixedBooleanInJson
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
export class CompatibilityContext {
|