@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
|
@@ -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 {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,mEAAU,CAAA;IACV,+EAAgB,CAAA;IAChB,u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C;YAC9B,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,SAAS;YACT,qBAAqB;SACtB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,4BAA4B,GAAyB,IAAI,oBAAoB,CAAC;QACnF,OAAO,EAAE,oBAAoB,CAAC,MAAM;KACrC,CAAC,CAAC"}
|
|
@@ -30,6 +30,7 @@ export declare class ParameterLookup implements Equatable {
|
|
|
30
30
|
equals(other: unknown): boolean;
|
|
31
31
|
}
|
|
32
32
|
export declare class EvaluateTableValuedFunction implements Equatable {
|
|
33
|
+
#private;
|
|
33
34
|
readonly tableValuedFunction: TableValuedResultSet;
|
|
34
35
|
readonly outputs: RowExpression[];
|
|
35
36
|
readonly filters: RowExpression[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TableValuedFunctionEquality } from './compatibility.js';
|
|
2
2
|
import { HashSet, StableHasher, unorderedEquality } from './equality.js';
|
|
3
3
|
/**
|
|
4
4
|
* Describes how to resolve a subscription to buckets.
|
|
@@ -17,7 +17,7 @@ export class StreamResolver {
|
|
|
17
17
|
this.uniqueName = uniqueName;
|
|
18
18
|
}
|
|
19
19
|
buildInstantiationHash(hasher) {
|
|
20
|
-
|
|
20
|
+
TableValuedFunctionEquality.empty.unorderedEquality.hash(hasher, this.requestFilters);
|
|
21
21
|
StreamResolver.lookupStageEquality.hash(hasher, this.lookupStages);
|
|
22
22
|
this.resolvedBucket.buildInstantiationHash(hasher);
|
|
23
23
|
}
|
|
@@ -25,7 +25,7 @@ export class StreamResolver {
|
|
|
25
25
|
if (other.options != this.options) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
|
-
if (!
|
|
28
|
+
if (!TableValuedFunctionEquality.empty.unorderedEquality.equals(other.requestFilters, this.requestFilters)) {
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
if (!StreamResolver.lookupStageEquality.equals(other.lookupStages, this.lookupStages)) {
|
|
@@ -68,21 +68,30 @@ export class EvaluateTableValuedFunction {
|
|
|
68
68
|
tableValuedFunction;
|
|
69
69
|
outputs;
|
|
70
70
|
filters;
|
|
71
|
+
#hashes;
|
|
71
72
|
constructor(tableValuedFunction, outputs, filters) {
|
|
72
73
|
this.tableValuedFunction = tableValuedFunction;
|
|
73
74
|
this.outputs = outputs;
|
|
74
75
|
this.filters = filters;
|
|
76
|
+
this.#hashes = TableValuedFunctionEquality.forSingleTableValuedFunction(tableValuedFunction);
|
|
75
77
|
}
|
|
76
78
|
buildHash(hasher) {
|
|
77
|
-
this.tableValuedFunction.buildBehaviorHashCode(hasher);
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
this.tableValuedFunction.buildBehaviorHashCode(TableValuedFunctionEquality.empty, hasher);
|
|
80
|
+
this.#hashes.listEquality.hash(hasher, this.outputs);
|
|
81
|
+
this.#hashes.unorderedEquality.hash(hasher, this.filters);
|
|
80
82
|
}
|
|
81
83
|
equals(other) {
|
|
82
|
-
|
|
83
|
-
other.tableValuedFunction.behavesIdenticalTo(this.tableValuedFunction)
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if (!(other instanceof EvaluateTableValuedFunction) ||
|
|
85
|
+
!other.tableValuedFunction.behavesIdenticalTo(this.tableValuedFunction, TableValuedFunctionEquality.empty)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const symbolMap = new Map();
|
|
89
|
+
const symbol = Symbol();
|
|
90
|
+
symbolMap.set(this.tableValuedFunction, symbol);
|
|
91
|
+
symbolMap.set(other.tableValuedFunction, symbol);
|
|
92
|
+
const equality = TableValuedFunctionEquality.mergeForEquality(this.#hashes, other.#hashes, symbolMap);
|
|
93
|
+
return (equality.listEquality.equals(this.outputs, other.outputs) &&
|
|
94
|
+
equality.unorderedEquality.equals(this.filters, other.filters));
|
|
86
95
|
}
|
|
87
96
|
}
|
|
88
97
|
export class ResolveBucket {
|
|
@@ -111,10 +120,11 @@ export class RequestParameterValue {
|
|
|
111
120
|
this.expression = expression;
|
|
112
121
|
}
|
|
113
122
|
buildHash(hasher) {
|
|
114
|
-
this.expression.
|
|
123
|
+
this.expression.assumingSamePrimaryResultSetEqualityHashCode(TableValuedFunctionEquality.empty, hasher);
|
|
115
124
|
}
|
|
116
125
|
equals(other) {
|
|
117
|
-
return other instanceof RequestParameterValue &&
|
|
126
|
+
return (other instanceof RequestParameterValue &&
|
|
127
|
+
this.expression.equalsAssumingSamePrimaryResultSet(other.expression, TableValuedFunctionEquality.empty));
|
|
118
128
|
}
|
|
119
129
|
}
|
|
120
130
|
export class LookupResultParameterValue {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucket_resolver.js","sourceRoot":"","sources":["../../src/compiler/bucket_resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"bucket_resolver.js","sourceRoot":"","sources":["../../src/compiler/bucket_resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAuB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAK9F;;GAEG;AACH,MAAM,OAAO,cAAc;IAEd;IACA;IACA;IACA;IACA;IALX,YACW,OAAsB,EACtB,cAAmC,EACnC,YAAiC,EACjC,cAA6B,EAC7B,UAAkB;QAJlB,YAAO,GAAP,OAAO,CAAe;QACtB,mBAAc,GAAd,cAAc,CAAqB;QACnC,iBAAY,GAAZ,YAAY,CAAqB;QACjC,mBAAc,GAAd,cAAc,CAAe;QAC7B,eAAU,GAAV,UAAU,CAAQ;IAC1B,CAAC;IAEJ,sBAAsB,CAAC,MAAoB;QACzC,2BAA2B,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACtF,cAAc,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,C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,KAAuB;QAAvB,UAAK,GAAL,KAAK,CAAkB;IAAG,CAAC;IAEhD,SAAS,CAAC,MAAoB;QAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,KAAc;QACnB,OAAO,CACL,KAAK,YAAY,0BAA0B,IAAI,YAAY,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAChH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
import { Equality, StableHasher } from './equality.js';
|
|
2
|
+
import { SourceResultSet, TableValuedResultSet } from './table.js';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* A semantic equality operator for syntactic structures.
|
|
4
5
|
*
|
|
5
6
|
* This is primarily used to compare expressions across streams. If we have two streams defined as
|
|
6
7
|
* `SELECT * FROM users WHERE id = ...` , the `id` column would not be equal between those since it references a the
|
|
7
|
-
*
|
|
8
|
-
* is the same, this allows comparing expressions for equality.
|
|
8
|
+
* syntactical `users` table added to each individual statement. But if we are in a context where we know the resolved
|
|
9
|
+
* physical table is the same, this allows comparing expressions for equality.
|
|
10
|
+
*
|
|
11
|
+
* It is the responsibility of the caller to also check the primary result set (like `users` in this example) for
|
|
12
|
+
* equality before invoking these methods. Additionally, streams are allowed to join table-valued functions derived from
|
|
13
|
+
* the primary result set. Those must also be equal, which is why {@link TableValuedHashCodes} is used to generate
|
|
14
|
+
* stable hash codes for them and {@link TableValuedIdentities} guarantees that available table-valued functions have a
|
|
15
|
+
* 1:1 correspondence between compared structures.
|
|
9
16
|
*/
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
export interface EqualsIgnoringPrimaryResultSet {
|
|
18
|
+
equalsAssumingSamePrimaryResultSet(other: EqualsIgnoringPrimaryResultSet, tableValued: TableValuedFunctionEquality): boolean;
|
|
19
|
+
assumingSamePrimaryResultSetEqualityHashCode(tableValued: TableValuedFunctionEquality, hasher: StableHasher): void;
|
|
20
|
+
}
|
|
21
|
+
interface ReadOnlyMap<K, V> {
|
|
22
|
+
get(key: K): V | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare class TableValuedFunctionEquality implements Equality<EqualsIgnoringPrimaryResultSet> {
|
|
25
|
+
#private;
|
|
26
|
+
private constructor();
|
|
27
|
+
get listEquality(): Equality<Iterable<EqualsIgnoringPrimaryResultSet>>;
|
|
28
|
+
get unorderedEquality(): Equality<Iterable<EqualsIgnoringPrimaryResultSet>>;
|
|
29
|
+
equals(a: EqualsIgnoringPrimaryResultSet, b: EqualsIgnoringPrimaryResultSet): boolean;
|
|
30
|
+
resultSetEquals(a: SourceResultSet, b: SourceResultSet): boolean;
|
|
31
|
+
hashResultSet(hasher: StableHasher, resultSet: SourceResultSet): void;
|
|
32
|
+
hash(hasher: StableHasher, value: EqualsIgnoringPrimaryResultSet): void;
|
|
33
|
+
/**
|
|
34
|
+
* An equality operator for table-valued functions, suitable only for generating hash codes within a single structure
|
|
35
|
+
* owning table-valued functions.
|
|
36
|
+
*
|
|
37
|
+
* This can't be used to compare functions across streams or to test for equality.
|
|
38
|
+
*/
|
|
39
|
+
static forHashCode(innerHashes: ReadOnlyMap<TableValuedResultSet, number>): TableValuedFunctionEquality;
|
|
40
|
+
static forSingleTableValuedFunction(resultSet: TableValuedResultSet): TableValuedFunctionEquality;
|
|
41
|
+
static forSingleOwner(innerHashes: ReadOnlyMap<TableValuedResultSet, number>, equality: ReadOnlyMap<TableValuedResultSet, unknown>): TableValuedFunctionEquality;
|
|
42
|
+
static mergeForEquality(localHashes: TableValuedFunctionEquality, otherHashes: TableValuedFunctionEquality, equality: ReadOnlyMap<TableValuedResultSet, symbol>): TableValuedFunctionEquality;
|
|
43
|
+
static readonly empty: TableValuedFunctionEquality;
|
|
13
44
|
}
|
|
14
|
-
export
|
|
15
|
-
export declare const equalsIgnoringResultSetList: Equality<Iterable<EqualsIgnoringResultSet>>;
|
|
16
|
-
export declare const equalsIgnoringResultSetUnordered: Equality<Iterable<EqualsIgnoringResultSet>>;
|
|
45
|
+
export {};
|
|
@@ -1,12 +1,82 @@
|
|
|
1
|
-
import { listEquality } from './equality.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { listEquality, unorderedEquality } from './equality.js';
|
|
2
|
+
import { PhysicalSourceResultSet } from './table.js';
|
|
3
|
+
export class TableValuedFunctionEquality {
|
|
4
|
+
#hashes;
|
|
5
|
+
#identities;
|
|
6
|
+
#ordered;
|
|
7
|
+
#unordered;
|
|
8
|
+
constructor(hashes, identities) {
|
|
9
|
+
this.#hashes = hashes;
|
|
10
|
+
this.#identities = identities;
|
|
11
|
+
}
|
|
12
|
+
get listEquality() {
|
|
13
|
+
return (this.#ordered ??= listEquality(this));
|
|
14
|
+
}
|
|
15
|
+
get unorderedEquality() {
|
|
16
|
+
return (this.#unordered ??= unorderedEquality(this));
|
|
17
|
+
}
|
|
18
|
+
#lookupIdentity(resultSet) {
|
|
19
|
+
const symbol = this.#identities.get(resultSet);
|
|
20
|
+
if (symbol == null) {
|
|
21
|
+
throw new Error('Unknown table-valued result set for equals');
|
|
22
|
+
}
|
|
23
|
+
return symbol;
|
|
24
|
+
}
|
|
25
|
+
equals(a, b) {
|
|
26
|
+
return a.equalsAssumingSamePrimaryResultSet(b, this);
|
|
27
|
+
}
|
|
28
|
+
resultSetEquals(a, b) {
|
|
29
|
+
// We don't need to compare primary result sets, those are assumed to be equal.
|
|
30
|
+
if (a instanceof PhysicalSourceResultSet) {
|
|
31
|
+
return b instanceof PhysicalSourceResultSet;
|
|
32
|
+
}
|
|
33
|
+
else if (b instanceof PhysicalSourceResultSet) {
|
|
34
|
+
return a instanceof PhysicalSourceResultSet;
|
|
35
|
+
}
|
|
36
|
+
return this.#lookupIdentity(a) === this.#lookupIdentity(b);
|
|
37
|
+
}
|
|
38
|
+
hashResultSet(hasher, resultSet) {
|
|
39
|
+
// There's only one primary result set which we ignore by design.
|
|
40
|
+
if (resultSet instanceof PhysicalSourceResultSet)
|
|
41
|
+
return;
|
|
42
|
+
const hash = this.#hashes.get(resultSet);
|
|
43
|
+
if (hash == null) {
|
|
44
|
+
throw new Error('Hashing unknown table-valued result set');
|
|
45
|
+
}
|
|
46
|
+
hasher.addHash(hash);
|
|
47
|
+
}
|
|
48
|
+
hash(hasher, value) {
|
|
49
|
+
return value.assumingSamePrimaryResultSetEqualityHashCode(this, hasher);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* An equality operator for table-valued functions, suitable only for generating hash codes within a single structure
|
|
53
|
+
* owning table-valued functions.
|
|
54
|
+
*
|
|
55
|
+
* This can't be used to compare functions across streams or to test for equality.
|
|
56
|
+
*/
|
|
57
|
+
static forHashCode(innerHashes) {
|
|
58
|
+
return this.forSingleOwner(innerHashes, {
|
|
59
|
+
// Compare by identity within the single owner.
|
|
60
|
+
get: (tableValued) => tableValued
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
static forSingleTableValuedFunction(resultSet) {
|
|
64
|
+
const hashCodeMap = new Map();
|
|
65
|
+
// Hash codes are only used to ensure column references to different table-valued functions generate different
|
|
66
|
+
// codes. Since there's just one, it can be an arbitrary value.
|
|
67
|
+
hashCodeMap.set(resultSet, 0);
|
|
68
|
+
return this.forHashCode(hashCodeMap);
|
|
69
|
+
}
|
|
70
|
+
static forSingleOwner(innerHashes, equality) {
|
|
71
|
+
return new TableValuedFunctionEquality(innerHashes, equality);
|
|
72
|
+
}
|
|
73
|
+
static mergeForEquality(localHashes, otherHashes, equality) {
|
|
74
|
+
return new TableValuedFunctionEquality({
|
|
75
|
+
get(key) {
|
|
76
|
+
return localHashes.#hashes.get(key) ?? otherHashes.#hashes.get(key);
|
|
77
|
+
}
|
|
78
|
+
}, equality);
|
|
79
|
+
}
|
|
80
|
+
static empty = new TableValuedFunctionEquality(new Map(), new Map());
|
|
81
|
+
}
|
|
12
82
|
//# sourceMappingURL=compatibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../../src/compiler/compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAgB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../../src/compiler/compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAgB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAyC,MAAM,YAAY,CAAC;AA6B5F,MAAM,OAAO,2BAA2B;IAC7B,OAAO,CAA4C;IACnD,WAAW,CAA6C;IAEjE,QAAQ,CAAiE;IACzE,UAAU,CAAiE;IAE3E,YACE,MAAiD,EACjD,UAAsD;QAEtD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,IAAI,CAAC,QAAQ,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,iBAAiB;QACnB,OAAO,CAAC,IAAI,CAAC,UAAU,KAAK,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,eAAe,CAAC,SAA+B;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,CAAiC,EAAE,CAAiC;QACzE,OAAO,CAAC,CAAC,kCA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AC,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,cAAc,CACnB,WAAsD,EACtD,QAAoD;QAEpD,OAAO,IAAI,2BAA2B,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,gBAAgB,CACrB,WAAwC,EACxC,WAAwC,EACxC,QAAmD;QAEnD,OAAO,IAAI,2BAA2B,CACpC;YACE,GAAG,CAAC,GAAG;gBACL,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACtE,CAAC;SACF,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,MAAM,CAAU,KAAK,GAAG,IAAI,2BAA2B,CAAC,IAAI,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { NodeLocation, PGNode } from 'pgsql-ast-parser';
|
|
2
|
-
import {
|
|
2
|
+
import { SqlRuleError } from '../errors.js';
|
|
3
|
+
import { CompiledEventDescriptor, StreamOptions, SyncPlan } from '../sync_plan/plan.js';
|
|
3
4
|
import { SourceSchema } from '../types.js';
|
|
4
5
|
import { StreamResolver } from './bucket_resolver.js';
|
|
5
|
-
import { PointLookup, RowEvaluator } from './rows.js';
|
|
6
|
+
import { EventRowEvaluator, PointLookup, RowEvaluator } from './rows.js';
|
|
6
7
|
import { CommonTableExpression, PreparedSubquery } from './sqlite.js';
|
|
8
|
+
import type { PhysicalSourceResultSet } from './table.js';
|
|
7
9
|
export interface SyncStreamsCompilerOptions {
|
|
8
10
|
/**
|
|
9
11
|
* Used exclusively for linting against the given {@link schema}.
|
|
@@ -19,26 +21,33 @@ export interface SyncStreamsCompilerOptions {
|
|
|
19
21
|
* streams across schema changes.
|
|
20
22
|
*/
|
|
21
23
|
schema?: SourceSchema;
|
|
24
|
+
/**
|
|
25
|
+
* Whether event payload `WHERE` clauses are compiled and applied.
|
|
26
|
+
*
|
|
27
|
+
* This defaults to true. It is disabled for editions that cannot persist compiled event plans and when restoring
|
|
28
|
+
* event SQL that predates those plans, because the legacy evaluator parsed `WHERE` clauses but did not validate or
|
|
29
|
+
* evaluate them.
|
|
30
|
+
*/
|
|
31
|
+
compileEventPayloadFilters?: boolean;
|
|
22
32
|
}
|
|
23
33
|
export interface ParseStreamOptions extends StreamOptions {
|
|
24
34
|
warnOnDangerousParameter: boolean;
|
|
25
35
|
}
|
|
26
36
|
/**
|
|
27
|
-
* State for compiling sync
|
|
37
|
+
* State for compiling Sync Streams and replication events into a sync plan.
|
|
28
38
|
*
|
|
29
|
-
* The
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* relations. This allows the compiler to efficiently de-duplicate parameters and buckets.
|
|
39
|
+
* The compiler stores a mutable intermediate representation that is essentially a copy of the resulting
|
|
40
|
+
* {@link SyncPlan}. Stream compilation uses JavaScript classes with behavioral equality, while events use plain
|
|
41
|
+
* compiler records. Stream queries and event definitions remain separate within that model.
|
|
33
42
|
*
|
|
34
|
-
*
|
|
43
|
+
* The stream compilation process is as follows: Each data query for a stream is first parsed by
|
|
35
44
|
* {@link StreamQueryParser} into a canonicalized intermediate representation (see that class for details).
|
|
36
45
|
* Then, {@link QuerierGraphBuilder} analyzes a chain of `AND` expressions to identify parameters (as partition keys)
|
|
37
46
|
* and their instantiation, as well as static filters that need to be added to reach row.
|
|
38
47
|
*/
|
|
39
48
|
export declare class SyncStreamsCompiler {
|
|
40
49
|
readonly options: SyncStreamsCompilerOptions;
|
|
41
|
-
readonly output:
|
|
50
|
+
readonly output: SyncPlanCompilerModel;
|
|
42
51
|
private readonly locations;
|
|
43
52
|
constructor(options: SyncStreamsCompilerOptions);
|
|
44
53
|
/**
|
|
@@ -53,14 +62,35 @@ export declare class SyncStreamsCompiler {
|
|
|
53
62
|
*/
|
|
54
63
|
commonTableExpression(sql: string, errors: ParsingErrorListener): PreparedSubquery | null;
|
|
55
64
|
/**
|
|
56
|
-
* Utility for compiling a
|
|
65
|
+
* Utility for compiling a Sync Stream.
|
|
57
66
|
*
|
|
58
67
|
* @param options Name, priority and `auto_subscribe` state for the stream.
|
|
59
68
|
*/
|
|
60
69
|
stream(options: ParseStreamOptions): IndividualSyncStreamCompiler;
|
|
70
|
+
/**
|
|
71
|
+
* Compiles the payload queries for a named replication event.
|
|
72
|
+
*
|
|
73
|
+
* Event queries intentionally support a smaller surface than stream queries: They must project and filter a single
|
|
74
|
+
* physical source table and cannot depend on request parameters, joins, subqueries or table-valued functions.
|
|
75
|
+
*/
|
|
76
|
+
event(name: string): IndividualEventCompiler;
|
|
77
|
+
/**
|
|
78
|
+
* @returns A sync plan representing an immutable snapshot of the compiler output.
|
|
79
|
+
*/
|
|
80
|
+
toSyncPlan(): SyncPlan;
|
|
61
81
|
}
|
|
62
82
|
/**
|
|
63
|
-
*
|
|
83
|
+
* Compiles raw event definitions from legacy sync plans into the current plan representation.
|
|
84
|
+
*
|
|
85
|
+
* All definitions share one compiler to match normal sync-config compilation. Callers should reject fatal errors
|
|
86
|
+
* rather than carrying invalid legacy event evaluators into a {@link SyncPlan}.
|
|
87
|
+
*/
|
|
88
|
+
export declare function compileEventDefinitions(definitions: Readonly<Record<string, readonly string[]>>, options: SyncStreamsCompilerOptions): {
|
|
89
|
+
events: CompiledEventDescriptor[];
|
|
90
|
+
errors: SqlRuleError[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Utility for compiling a single Sync Stream.
|
|
64
94
|
*/
|
|
65
95
|
export interface IndividualSyncStreamCompiler {
|
|
66
96
|
/**
|
|
@@ -80,10 +110,16 @@ export interface IndividualSyncStreamCompiler {
|
|
|
80
110
|
*/
|
|
81
111
|
finish(): void;
|
|
82
112
|
}
|
|
113
|
+
export interface IndividualEventCompiler {
|
|
114
|
+
/**
|
|
115
|
+
* Validates and adds one payload query to this event.
|
|
116
|
+
*/
|
|
117
|
+
addSourceQuery(sql: string, errors: ParsingErrorListener): void;
|
|
118
|
+
}
|
|
83
119
|
/**
|
|
84
120
|
* Something reporting errors.
|
|
85
121
|
*
|
|
86
|
-
* While
|
|
122
|
+
* While Sync Streams can be made up of multiple SQL statements from different YAML strings, we want to be able to
|
|
87
123
|
* accurately describe the source of an error in YAML when we report it.
|
|
88
124
|
*
|
|
89
125
|
* So, every transformation that might need to report errors receives an instance of this interface which implicitly
|
|
@@ -106,8 +142,40 @@ export declare class CompiledStreamQueries {
|
|
|
106
142
|
get pointLookups(): PointLookup[];
|
|
107
143
|
canonicalizeEvaluator(evaluator: RowEvaluator): RowEvaluator;
|
|
108
144
|
canonicalizePointLookup(lookup: PointLookup): PointLookup;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Compiler model for one SQL query in a named event's `payloads` list.
|
|
148
|
+
*
|
|
149
|
+
* It binds that query to its single physical source table and contains one row evaluator for each normalized `OR`
|
|
150
|
+
* branch. Within each evaluator, filters determine whether a source row triggers the event, while projected columns
|
|
151
|
+
* determine the payload produced for a matching row.
|
|
152
|
+
*
|
|
153
|
+
* {@link sql} is retained so service-core can dual-write the legacy `eventDescriptors` field for older services during
|
|
154
|
+
* rolling upgrades. The executable plan uses the parsed source table and row evaluators instead.
|
|
155
|
+
*/
|
|
156
|
+
export interface CompiledEventSourceQueryModel {
|
|
157
|
+
sql: string;
|
|
158
|
+
sourceTable: PhysicalSourceResultSet;
|
|
159
|
+
variants: EventRowEvaluator[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Compiler model for one named entry under `event_definitions`.
|
|
163
|
+
*
|
|
164
|
+
* {@link name} identifies the event exposed to handlers. {@link sourceQueries} represents its complete `payloads`
|
|
165
|
+
* list, which may define how rows from different source tables trigger that event and produce its payload.
|
|
166
|
+
*/
|
|
167
|
+
export interface CompiledEvent {
|
|
168
|
+
name: string;
|
|
169
|
+
sourceQueries: CompiledEventSourceQueryModel[];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Top-level compiler output used to assemble a complete sync plan.
|
|
173
|
+
*
|
|
174
|
+
* Streams and events are sibling sync-config concerns. Keeping their intermediate state separate prevents stream
|
|
175
|
+
* compilation abstractions from acquiring event-specific responsibilities just because both are persisted in one
|
|
176
|
+
* {@link SyncPlan}.
|
|
177
|
+
*/
|
|
178
|
+
export interface SyncPlanCompilerModel {
|
|
179
|
+
readonly streams: CompiledStreamQueries;
|
|
180
|
+
readonly events: CompiledEvent[];
|
|
113
181
|
}
|