@powersync/service-sync-rules 0.0.0-dev-20260803144812 → 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 +11 -2
- package/dist/HydratedSyncConfig.js +18 -4
- package/dist/HydratedSyncConfig.js.map +1 -1
- package/dist/HydrationState.d.ts +2 -0
- package/dist/HydrationState.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/StorageVersion.js +2 -1
- package/dist/StorageVersion.js.map +1 -1
- package/dist/SyncConfig.d.ts +11 -3
- package/dist/SyncConfig.js +16 -11
- 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/bucket_resolver.d.ts +1 -0
- package/dist/compiler/bucket_resolver.js +22 -12
- package/dist/compiler/bucket_resolver.js.map +1 -1
- package/dist/compiler/compatibility.d.ts +38 -9
- package/dist/compiler/compatibility.js +81 -11
- package/dist/compiler/compatibility.js.map +1 -1
- package/dist/compiler/compiler.d.ts +84 -16
- package/dist/compiler/compiler.js +112 -16
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/equality.d.ts +2 -2
- package/dist/compiler/equality.js +2 -2
- package/dist/compiler/expression.d.ts +20 -18
- package/dist/compiler/expression.js +23 -14
- package/dist/compiler/expression.js.map +1 -1
- package/dist/compiler/filter.d.ts +4 -4
- package/dist/compiler/filter.js +5 -4
- package/dist/compiler/filter.js.map +1 -1
- package/dist/compiler/ir_to_sync_plan.d.ts +4 -2
- package/dist/compiler/ir_to_sync_plan.js +40 -36
- package/dist/compiler/ir_to_sync_plan.js.map +1 -1
- package/dist/compiler/parser.d.ts +1 -1
- package/dist/compiler/parser.js +2 -2
- package/dist/compiler/querier_graph.js +43 -24
- package/dist/compiler/querier_graph.js.map +1 -1
- package/dist/compiler/rows.d.ts +23 -29
- package/dist/compiler/rows.js +83 -59
- package/dist/compiler/rows.js.map +1 -1
- package/dist/compiler/sqlite.js +1 -2
- package/dist/compiler/sqlite.js.map +1 -1
- package/dist/compiler/table.d.ts +5 -4
- package/dist/compiler/table.js +6 -7
- package/dist/compiler/table.js.map +1 -1
- package/dist/events/CompiledEventSourceQuery.d.ts +51 -0
- package/dist/events/CompiledEventSourceQuery.js +119 -0
- package/dist/events/CompiledEventSourceQuery.js.map +1 -0
- package/dist/events/EventDescriptor.d.ts +26 -0
- package/dist/events/EventDescriptor.js +2 -0
- package/dist/events/EventDescriptor.js.map +1 -0
- package/dist/from_yaml.d.ts +14 -1
- package/dist/from_yaml.js +101 -39
- package/dist/from_yaml.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- 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 +27 -4
- 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/schema-generators/RustSchemaGenerator.d.ts +22 -0
- package/dist/schema-generators/RustSchemaGenerator.js +120 -0
- package/dist/schema-generators/RustSchemaGenerator.js.map +1 -0
- package/dist/schema-generators/generators.d.ts +2 -0
- package/dist/schema-generators/generators.js +2 -0
- package/dist/schema-generators/generators.js.map +1 -1
- package/dist/schema-generators/schema-generators.d.ts +1 -0
- package/dist/schema-generators/schema-generators.js +1 -0
- package/dist/schema-generators/schema-generators.js.map +1 -1
- package/dist/sql_functions.d.ts +1 -1
- package/dist/sync_plan/evaluator/bucket_data_source.js +11 -53
- package/dist/sync_plan/evaluator/bucket_data_source.js.map +1 -1
- package/dist/sync_plan/evaluator/bucket_source.js +1 -1
- package/dist/sync_plan/evaluator/index.d.ts +2 -7
- package/dist/sync_plan/evaluator/index.js +7 -7
- 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 +12 -8
- package/dist/sync_plan/evaluator/parameter_evaluator.js.map +1 -1
- package/dist/sync_plan/evaluator/row_projection.d.ts +22 -0
- package/dist/sync_plan/evaluator/row_projection.js +71 -0
- package/dist/sync_plan/evaluator/row_projection.js.map +1 -0
- package/dist/sync_plan/plan.d.ts +43 -6
- package/dist/sync_plan/plan_equality_serialized.d.ts +12 -2
- package/dist/sync_plan/plan_equality_serialized.js +56 -0
- package/dist/sync_plan/plan_equality_serialized.js.map +1 -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 +52 -5
- package/dist/sync_plan/serialize.js +125 -20
- 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 +49 -3
- package/dist/events/SqlEventDescriptor.d.ts +0 -20
- package/dist/events/SqlEventDescriptor.js +0 -51
- package/dist/events/SqlEventDescriptor.js.map +0 -1
- package/dist/events/SqlEventSourceQuery.d.ts +0 -20
- package/dist/events/SqlEventSourceQuery.js +0 -125
- package/dist/events/SqlEventSourceQuery.js.map +0 -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,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAGhD;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAuB,WAAc;IACxE,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;AAW5E;;GAEG;AACH,MAAM,UAAU,4BAA4B;IAC1C,MAAM,UAAU,GAAG,CAAC,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,CAAe,CAAC;IACrG,MAAM,UAAU,GAAG,UAAU,CAAC,UAAwB,CAAC;IACvD,UAAU,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACnD,UAAU,CAAC,MAAM,GAAG;QAClB,IAAI,EAAE,QAAQ;QACd,aAAa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;IACpF,IAAI,OAAO,KAAK,IAAI,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO;IAC/D,IAAI,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,KAAM,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS;QACjD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EACrC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,KAAM,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,5 +1,6 @@
|
|
|
1
1
|
import { BucketDataSource } from './BucketSource.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ConnectionConfigMap } from './ConnectionConfig.js';
|
|
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';
|
|
5
6
|
export interface MatchingSources {
|
|
@@ -17,11 +18,19 @@ 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
|
*/
|
|
23
25
|
private bucketSources;
|
|
24
|
-
eventDescriptors:
|
|
26
|
+
eventDescriptors: HydratedEventDescriptor[];
|
|
27
|
+
/**
|
|
28
|
+
* Hydrated events grouped by their source definition.
|
|
29
|
+
*
|
|
30
|
+
* Deduplication of events across definitions is left to the caller (storage resolves each event to its
|
|
31
|
+
* per-config assigned id and dedupes on that), so this keeps every definition's events intact for that.
|
|
32
|
+
*/
|
|
33
|
+
readonly eventDescriptorsByDefinition: Map<SyncConfig, HydratedEventDescriptor[]>;
|
|
25
34
|
/**
|
|
26
35
|
* Only a single compatibility context is supported across all merged SyncConfigs.
|
|
27
36
|
*/
|
|
@@ -12,11 +12,19 @@ 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
|
*/
|
|
18
19
|
bucketSources = [];
|
|
19
20
|
eventDescriptors = [];
|
|
21
|
+
/**
|
|
22
|
+
* Hydrated events grouped by their source definition.
|
|
23
|
+
*
|
|
24
|
+
* Deduplication of events across definitions is left to the caller (storage resolves each event to its
|
|
25
|
+
* per-config assigned id and dedupes on that), so this keeps every definition's events intact for that.
|
|
26
|
+
*/
|
|
27
|
+
eventDescriptorsByDefinition = new Map();
|
|
20
28
|
/**
|
|
21
29
|
* Only a single compatibility context is supported across all merged SyncConfigs.
|
|
22
30
|
*/
|
|
@@ -47,8 +55,10 @@ export class HydratedSyncConfig {
|
|
|
47
55
|
const hydrationState = params.createParams.hydrationState;
|
|
48
56
|
const definitions = params.definitions;
|
|
49
57
|
if (definitions.length == 0) {
|
|
50
|
-
throw new Error('
|
|
58
|
+
throw new Error('HydratedSyncConfig requires at least one SyncConfig definition');
|
|
51
59
|
}
|
|
60
|
+
// The service validates that definitions sharing a source reader have compatible connection options.
|
|
61
|
+
this.connectionConfig = definitions[0].connectionConfig;
|
|
52
62
|
this.sourceDefinitions = [...definitions];
|
|
53
63
|
this.compatibility = assertSharedCompatibility(this.sourceDefinitions);
|
|
54
64
|
this.hydrationInput = {
|
|
@@ -59,7 +69,11 @@ export class HydratedSyncConfig {
|
|
|
59
69
|
this.bucketParameterLookupSources = uniqueBy(definitions.flatMap((definition) => definition.bucketParameterLookupSources), (source) => parameterLookupScopeKey(hydrationState.getParameterIndexLookupScope(source)));
|
|
60
70
|
this.innerEvaluateRow = mergeDataSources(this.hydrationInput, this.bucketDataSources).evaluateRow;
|
|
61
71
|
this.innerEvaluateParameterRow = mergeParameterIndexLookupCreators(this.hydrationInput, this.bucketParameterLookupSources).evaluateParameterRow;
|
|
62
|
-
this.eventDescriptors = definitions.flatMap((definition) =>
|
|
72
|
+
this.eventDescriptors = definitions.flatMap((definition) => {
|
|
73
|
+
const events = definition.eventDefinitions.map((event) => event.createEvaluator(this.hydrationInput));
|
|
74
|
+
this.eventDescriptorsByDefinition.set(definition, events);
|
|
75
|
+
return events;
|
|
76
|
+
});
|
|
63
77
|
if (definitions.length == 1) {
|
|
64
78
|
this.#bucketSourceDefinitions = definitions[0].bucketSources;
|
|
65
79
|
this.bucketSources = this.#bucketSourceDefinitions.map((source) => source.hydrate(this.hydrationInput));
|
|
@@ -188,7 +202,7 @@ export class HydratedSyncConfig {
|
|
|
188
202
|
assertSingleSourceDefinition(debugName) {
|
|
189
203
|
// We may split the types in the future to enforce this on a type level instead of runtime level
|
|
190
204
|
if (this.sourceDefinitions.length != 1) {
|
|
191
|
-
throw new Error(`${debugName} is not supported for
|
|
205
|
+
throw new Error(`${debugName} is not supported for HydratedSyncConfig with multiple SyncConfigs`);
|
|
192
206
|
}
|
|
193
207
|
}
|
|
194
208
|
}
|
|
@@ -199,7 +213,7 @@ function assertSharedCompatibility(definitions) {
|
|
|
199
213
|
}
|
|
200
214
|
for (const definition of definitions) {
|
|
201
215
|
if (!definition.compatibility.equals(compatibility)) {
|
|
202
|
-
throw new Error('All SyncConfigs in a
|
|
216
|
+
throw new Error('All SyncConfigs in a HydratedSyncConfig instance must use the same CompatibilityContext');
|
|
203
217
|
}
|
|
204
218
|
}
|
|
205
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+B,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOvD;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IACpB,gBAAgB,CAAsB;IAC/C;;OAEG;IACK,aAAa,GAA2B,EAAE,CAAC;IAEnD,gBAAgB,GAA8B,EAAE,CAAC;IAEjD;;;;;OAKG;IACM,4BAA4B,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEzF;;OAEG;IACH,aAAa,GAAyB,oBAAoB,CAAC,4BAA4B,CAAC;IAExF;;;;;OAKG;IACc,iBAAiB,CAAe;IAEjD;;OAEG;IACM,iBAAiB,CAAqB;IACtC,4BAA4B,CAAgC;IAErE;;OAEG;IACM,wBAAwB,CAAiB;IAEjC,gBAAgB,CAAoB;I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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/HydrationState.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BucketDataSource, ParameterIndexLookupCreator } from './BucketSource.js';
|
|
2
2
|
export type BucketDefinitionId = string;
|
|
3
3
|
export type ParameterIndexId = string;
|
|
4
|
+
/** Stream-local storage identity assigned to a replication event definition. */
|
|
5
|
+
export type EventDefinitionId = string;
|
|
4
6
|
export interface BucketDataScope {
|
|
5
7
|
/**
|
|
6
8
|
* The prefix is the bucket name before the parameters.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationState.js","sourceRoot":"","sources":["../src/HydrationState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HydrationState.js","sourceRoot":"","sources":["../src/HydrationState.ts"],"names":[],"mappings":"AA0DA;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAmB;IACrD,oBAAoB,CAAC,MAAwB;QAC3C,OAAO;YACL,YAAY,EAAE,MAAM,CAAC,UAAU;YAC/B,MAAM;SACP,CAAC;IACJ,CAAC;IACD,4BAA4B,CAAC,MAAmC;QAC9D,OAAO;YACL,GAAG,MAAM,CAAC,QAAQ;YAClB,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,OAAO;QACL,oBAAoB,CAAC,MAAwB;YAC3C,OAAO;gBACL,YAAY,EAAE,GAAG,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE;gBAC/C,MAAM;aACP,CAAC;QACJ,CAAC;QAED,4BAA4B,CAAC,MAAmC;YAC9D,kCAAkC;YAClC,OAAO;gBACL,GAAG,MAAM,CAAC,QAAQ;gBAClB,MAAM;aACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,KAAkC;IACxE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,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/StorageVersion.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export const STORAGE_VERSIONS = new Map([
|
|
2
2
|
// version 1 is supported by the storage modules, but cannot be used in sync config
|
|
3
3
|
[2, { version: 2, stable: true }],
|
|
4
|
-
[3, { version: 3, stable: false }]
|
|
4
|
+
[3, { version: 3, stable: false }],
|
|
5
|
+
[4, { version: 4, stable: true }]
|
|
5
6
|
]);
|
|
6
7
|
export const DEFAULT_STORAGE_VERSION = STORAGE_VERSIONS.get(2);
|
|
7
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageVersion.js","sourceRoot":"","sources":["../src/StorageVersion.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAkC;IACvE,mFAAmF;IACnF,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACjC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"StorageVersion.js","sourceRoot":"","sources":["../src/StorageVersion.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAkC;IACvE,mFAAmF;IACnF,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACjC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAClC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;CAClC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,OAAO,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/SyncConfig.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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
|
-
import {
|
|
5
|
+
import { EventDefinition } from './events/EventDescriptor.js';
|
|
5
6
|
import { HydratedSyncConfig } from './HydratedSyncConfig.js';
|
|
6
7
|
import { SourceTableRef } from './SourceTableRef.js';
|
|
7
8
|
import { TablePattern } from './TablePattern.js';
|
|
@@ -11,17 +12,24 @@ 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[];
|
|
22
|
+
/**
|
|
23
|
+
* Prepared event definitions. Executable event descriptors only exist on {@link HydratedSyncConfig}.
|
|
24
|
+
*/
|
|
25
|
+
eventDefinitions: EventDefinition[];
|
|
17
26
|
compatibility: CompatibilityContext;
|
|
18
27
|
/**
|
|
19
|
-
* If not defined, the storage module picks the
|
|
28
|
+
* If not defined, the storage module picks the version.
|
|
20
29
|
*
|
|
21
30
|
* Only supported storage versions can be set here when parsing from yaml.
|
|
22
31
|
*/
|
|
23
32
|
storageVersion: number | undefined;
|
|
24
|
-
eventDescriptors: SqlEventDescriptor[];
|
|
25
33
|
/**
|
|
26
34
|
* The (YAML-based) source contents from which this sync config has been derived.
|
|
27
35
|
*/
|
package/dist/SyncConfig.js
CHANGED
|
@@ -6,17 +6,24 @@ 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 = [];
|
|
16
|
+
/**
|
|
17
|
+
* Prepared event definitions. Executable event descriptors only exist on {@link HydratedSyncConfig}.
|
|
18
|
+
*/
|
|
19
|
+
eventDefinitions = [];
|
|
12
20
|
compatibility = CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY;
|
|
13
21
|
/**
|
|
14
|
-
* If not defined, the storage module picks the
|
|
22
|
+
* If not defined, the storage module picks the version.
|
|
15
23
|
*
|
|
16
24
|
* Only supported storage versions can be set here when parsing from yaml.
|
|
17
25
|
*/
|
|
18
26
|
storageVersion;
|
|
19
|
-
eventDescriptors = [];
|
|
20
27
|
/**
|
|
21
28
|
* The (YAML-based) source contents from which this sync config has been derived.
|
|
22
29
|
*/
|
|
@@ -52,9 +59,9 @@ export class SyncConfig {
|
|
|
52
59
|
sourceTables.set(r.key(), r);
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
|
-
for (const event of this.
|
|
56
|
-
for (const
|
|
57
|
-
sourceTables.set(
|
|
62
|
+
for (const event of this.eventDefinitions) {
|
|
63
|
+
for (const table of event.getSourceTables()) {
|
|
64
|
+
sourceTables.set(table.key(), table);
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
@@ -65,17 +72,15 @@ export class SyncConfig {
|
|
|
65
72
|
}
|
|
66
73
|
getEventTables() {
|
|
67
74
|
const eventTables = new Map();
|
|
68
|
-
|
|
69
|
-
for (const
|
|
70
|
-
|
|
71
|
-
eventTables.set(r.key(), r);
|
|
72
|
-
}
|
|
75
|
+
for (const event of this.eventDefinitions) {
|
|
76
|
+
for (const table of event.getSourceTables()) {
|
|
77
|
+
eventTables.set(table.key(), table);
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
return [...eventTables.values()];
|
|
76
81
|
}
|
|
77
82
|
tableTriggersEvent(table) {
|
|
78
|
-
return this.
|
|
83
|
+
return this.eventDefinitions.some((event) => event.tableTriggersEvent(table));
|
|
79
84
|
}
|
|
80
85
|
tableSyncsData(table) {
|
|
81
86
|
return this.bucketDataSources.some((b) => b.tableSyncsData(table));
|
package/dist/SyncConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncConfig.js","sourceRoot":"","sources":["../src/SyncConfig.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"SyncConfig.js","sourceRoot":"","sources":["../src/SyncConfig.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,o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