@powersync/service-sync-rules 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HydratedSyncConfig.d.ts +9 -2
- package/dist/HydratedSyncConfig.js +12 -1
- package/dist/HydratedSyncConfig.js.map +1 -1
- package/dist/HydrationState.d.ts +2 -0
- package/dist/HydrationState.js.map +1 -1
- package/dist/StorageVersion.js +2 -1
- package/dist/StorageVersion.js.map +1 -1
- package/dist/SyncConfig.d.ts +4 -3
- package/dist/SyncConfig.js +10 -11
- package/dist/SyncConfig.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 +81 -13
- package/dist/compiler/compiler.js +111 -15
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/expression.d.ts +17 -15
- package/dist/compiler/expression.js +21 -12
- 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/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/table.d.ts +3 -2
- package/dist/compiler/table.js +5 -6
- 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.js +24 -20
- package/dist/from_yaml.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/json_schema.js +1 -1
- package/dist/json_schema.js.map +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/index.d.ts +2 -7
- package/dist/sync_plan/evaluator/index.js +6 -7
- package/dist/sync_plan/evaluator/index.js.map +1 -1
- package/dist/sync_plan/evaluator/parameter_evaluator.js +11 -7
- 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 +36 -5
- 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/serialize.d.ts +35 -4
- package/dist/sync_plan/serialize.js +93 -16
- package/dist/sync_plan/serialize.js.map +1 -1
- package/package.json +1 -1
- package/schema/sync_rules.json +3 -2
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BucketDataSource } from './BucketSource.js';
|
|
2
|
-
import { BucketSource, CompatibilityContext, EvaluatedParameters, EvaluatedRow, EvaluationError, GetBucketParameterQuerierResult, GetQuerierOptions, HydrateSyncConfigParams, ParameterIndexLookupCreator,
|
|
2
|
+
import { BucketSource, CompatibilityContext, EvaluatedParameters, EvaluatedRow, EvaluationError, GetBucketParameterQuerierResult, GetQuerierOptions, HydratedEventDescriptor, HydrateSyncConfigParams, ParameterIndexLookupCreator, SqliteInputValue, SqliteValue, SyncConfig, TablePattern } from './index.js';
|
|
3
3
|
import { SourceTableRef } from './SourceTableRef.js';
|
|
4
4
|
import { EvaluateRowOptions, SqliteRow } from './types.js';
|
|
5
5
|
export interface MatchingSources {
|
|
@@ -21,7 +21,14 @@ export declare class HydratedSyncConfig {
|
|
|
21
21
|
* These are used by queriers, and do not support merging across multiple SyncConfigs.
|
|
22
22
|
*/
|
|
23
23
|
private bucketSources;
|
|
24
|
-
eventDescriptors:
|
|
24
|
+
eventDescriptors: HydratedEventDescriptor[];
|
|
25
|
+
/**
|
|
26
|
+
* Hydrated events grouped by their source definition.
|
|
27
|
+
*
|
|
28
|
+
* Deduplication of events across definitions is left to the caller (storage resolves each event to its
|
|
29
|
+
* per-config assigned id and dedupes on that), so this keeps every definition's events intact for that.
|
|
30
|
+
*/
|
|
31
|
+
readonly eventDescriptorsByDefinition: Map<SyncConfig, HydratedEventDescriptor[]>;
|
|
25
32
|
/**
|
|
26
33
|
* Only a single compatibility context is supported across all merged SyncConfigs.
|
|
27
34
|
*/
|
|
@@ -17,6 +17,13 @@ export class HydratedSyncConfig {
|
|
|
17
17
|
*/
|
|
18
18
|
bucketSources = [];
|
|
19
19
|
eventDescriptors = [];
|
|
20
|
+
/**
|
|
21
|
+
* Hydrated events grouped by their source definition.
|
|
22
|
+
*
|
|
23
|
+
* Deduplication of events across definitions is left to the caller (storage resolves each event to its
|
|
24
|
+
* per-config assigned id and dedupes on that), so this keeps every definition's events intact for that.
|
|
25
|
+
*/
|
|
26
|
+
eventDescriptorsByDefinition = new Map();
|
|
20
27
|
/**
|
|
21
28
|
* Only a single compatibility context is supported across all merged SyncConfigs.
|
|
22
29
|
*/
|
|
@@ -59,7 +66,11 @@ export class HydratedSyncConfig {
|
|
|
59
66
|
this.bucketParameterLookupSources = uniqueBy(definitions.flatMap((definition) => definition.bucketParameterLookupSources), (source) => parameterLookupScopeKey(hydrationState.getParameterIndexLookupScope(source)));
|
|
60
67
|
this.innerEvaluateRow = mergeDataSources(this.hydrationInput, this.bucketDataSources).evaluateRow;
|
|
61
68
|
this.innerEvaluateParameterRow = mergeParameterIndexLookupCreators(this.hydrationInput, this.bucketParameterLookupSources).evaluateParameterRow;
|
|
62
|
-
this.eventDescriptors = definitions.flatMap((definition) =>
|
|
69
|
+
this.eventDescriptors = definitions.flatMap((definition) => {
|
|
70
|
+
const events = definition.eventDefinitions.map((event) => event.createEvaluator(this.hydrationInput));
|
|
71
|
+
this.eventDescriptorsByDefinition.set(definition, events);
|
|
72
|
+
return events;
|
|
73
|
+
});
|
|
63
74
|
if (definitions.length == 1) {
|
|
64
75
|
this.#bucketSourceDefinitions = definitions[0].bucketSources;
|
|
65
76
|
this.bucketSources = this.#bucketSourceDefinitions.map((source) => source.hydrate(this.hydrationInput));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydratedSyncConfig.js","sourceRoot":"","sources":["../src/HydratedSyncConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"HydratedSyncConfig.js","sourceRoot":"","sources":["../src/HydratedSyncConfig.ts"],"names":[],"mappings":"AACA,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;;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AAE,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,mEAAmE,CAAC,CAAC;QACnG,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,wFAAwF,CAAC,CAAC;QAC5G,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/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,7 @@
|
|
|
1
1
|
import { BucketDataSource, BucketSource, HydrateSyncConfigParams, ParameterIndexLookupCreator } from './BucketSource.js';
|
|
2
2
|
import { CompatibilityContext } from './compatibility.js';
|
|
3
3
|
import { YamlError } from './errors.js';
|
|
4
|
-
import {
|
|
4
|
+
import { EventDefinition } from './events/EventDescriptor.js';
|
|
5
5
|
import { HydratedSyncConfig } from './HydratedSyncConfig.js';
|
|
6
6
|
import { SourceTableRef } from './SourceTableRef.js';
|
|
7
7
|
import { TablePattern } from './TablePattern.js';
|
|
@@ -14,14 +14,15 @@ export declare abstract class SyncConfig {
|
|
|
14
14
|
bucketDataSources: BucketDataSource[];
|
|
15
15
|
bucketParameterLookupSources: ParameterIndexLookupCreator[];
|
|
16
16
|
bucketSources: BucketSource[];
|
|
17
|
+
/** Prepared event definitions. Executable event descriptors only exist on {@link HydratedSyncConfig}. */
|
|
18
|
+
eventDefinitions: EventDefinition[];
|
|
17
19
|
compatibility: CompatibilityContext;
|
|
18
20
|
/**
|
|
19
|
-
* If not defined, the storage module picks the
|
|
21
|
+
* If not defined, the storage module picks the version.
|
|
20
22
|
*
|
|
21
23
|
* Only supported storage versions can be set here when parsing from yaml.
|
|
22
24
|
*/
|
|
23
25
|
storageVersion: number | undefined;
|
|
24
|
-
eventDescriptors: SqlEventDescriptor[];
|
|
25
26
|
/**
|
|
26
27
|
* The (YAML-based) source contents from which this sync config has been derived.
|
|
27
28
|
*/
|
package/dist/SyncConfig.js
CHANGED
|
@@ -9,14 +9,15 @@ export class SyncConfig {
|
|
|
9
9
|
bucketDataSources = [];
|
|
10
10
|
bucketParameterLookupSources = [];
|
|
11
11
|
bucketSources = [];
|
|
12
|
+
/** Prepared event definitions. Executable event descriptors only exist on {@link HydratedSyncConfig}. */
|
|
13
|
+
eventDefinitions = [];
|
|
12
14
|
compatibility = CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY;
|
|
13
15
|
/**
|
|
14
|
-
* If not defined, the storage module picks the
|
|
16
|
+
* If not defined, the storage module picks the version.
|
|
15
17
|
*
|
|
16
18
|
* Only supported storage versions can be set here when parsing from yaml.
|
|
17
19
|
*/
|
|
18
20
|
storageVersion;
|
|
19
|
-
eventDescriptors = [];
|
|
20
21
|
/**
|
|
21
22
|
* The (YAML-based) source contents from which this sync config has been derived.
|
|
22
23
|
*/
|
|
@@ -52,9 +53,9 @@ export class SyncConfig {
|
|
|
52
53
|
sourceTables.set(r.key(), r);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
for (const event of this.
|
|
56
|
-
for (const
|
|
57
|
-
sourceTables.set(
|
|
56
|
+
for (const event of this.eventDefinitions) {
|
|
57
|
+
for (const table of event.getSourceTables()) {
|
|
58
|
+
sourceTables.set(table.key(), table);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -65,17 +66,15 @@ export class SyncConfig {
|
|
|
65
66
|
}
|
|
66
67
|
getEventTables() {
|
|
67
68
|
const eventTables = new Map();
|
|
68
|
-
|
|
69
|
-
for (const
|
|
70
|
-
|
|
71
|
-
eventTables.set(r.key(), r);
|
|
72
|
-
}
|
|
69
|
+
for (const event of this.eventDefinitions) {
|
|
70
|
+
for (const table of event.getSourceTables()) {
|
|
71
|
+
eventTables.set(table.key(), table);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
return [...eventTables.values()];
|
|
76
75
|
}
|
|
77
76
|
tableTriggersEvent(table) {
|
|
78
|
-
return this.
|
|
77
|
+
return this.eventDefinitions.some((event) => event.tableTriggersEvent(table));
|
|
79
78
|
}
|
|
80
79
|
tableSyncsData(table) {
|
|
81
80
|
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;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,MAAM,OAAgB,UAAU;IAC9B,iBAAiB,GAAuB,EAAE,CAAC;IAC3C,4BAA4B,GAAkC,EAAE,CAAC;IACjE,aAAa,GAAmB,EAAE,CAAC;IACnC,aAAa,GAAyB,oBAAoB,CAAC,4BAA4B,CAAC;IACxF;;;;OAIG;IACH,cAAc,CAAqB;
|
|
1
|
+
{"version":3,"file":"SyncConfig.js","sourceRoot":"","sources":["../src/SyncCon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;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"}
|
|
@@ -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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CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,KAAqB;QAC1B,OAAO,CACL,KAAK,YAAY,0BAA0B;YAC3C,KAAK,CAAC,MAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YACjC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CACtC,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,0BAA0B;IAChB;IAArB,YAAqB,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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AAc,CAAC,WAAW,EAAE;YACtC,+CAA+C;YAC/C,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW;SAClC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,4BAA4B,CAAC,SAA+B;QACjE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAgC,CAAC;QAC5D,8GAA8G;QAC9G,+DAA+D;QAC/D,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,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 streams.
|
|
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
|
/**
|
|
@@ -58,7 +67,28 @@ export declare class SyncStreamsCompiler {
|
|
|
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
|
}
|
|
82
|
+
/**
|
|
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
|
+
};
|
|
62
92
|
/**
|
|
63
93
|
* Utility for compiling a single sync stream.
|
|
64
94
|
*/
|
|
@@ -80,6 +110,12 @@ 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
|
*
|
|
@@ -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
|
}
|