@powersync/service-sync-rules 0.29.9 → 0.30.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/BaseSqlDataQuery.d.ts +3 -9
- package/dist/BaseSqlDataQuery.js +11 -21
- package/dist/BaseSqlDataQuery.js.map +1 -1
- package/dist/BucketParameterQuerier.d.ts +42 -9
- package/dist/BucketParameterQuerier.js +30 -7
- package/dist/BucketParameterQuerier.js.map +1 -1
- package/dist/BucketSource.d.ts +94 -25
- package/dist/BucketSource.js +67 -0
- package/dist/BucketSource.js.map +1 -1
- package/dist/ExpressionType.d.ts +4 -2
- package/dist/ExpressionType.js.map +1 -1
- package/dist/HydratedSyncRules.d.ts +46 -0
- package/dist/HydratedSyncRules.js +88 -0
- package/dist/HydratedSyncRules.js.map +1 -0
- package/dist/HydrationState.d.ts +45 -0
- package/dist/HydrationState.js +41 -0
- package/dist/HydrationState.js.map +1 -0
- package/dist/SqlBucketDescriptor.d.ts +31 -28
- package/dist/SqlBucketDescriptor.js +89 -112
- package/dist/SqlBucketDescriptor.js.map +1 -1
- package/dist/SqlDataQuery.d.ts +4 -4
- package/dist/SqlDataQuery.js +5 -6
- package/dist/SqlDataQuery.js.map +1 -1
- package/dist/SqlParameterQuery.d.ts +17 -9
- package/dist/SqlParameterQuery.js +49 -23
- package/dist/SqlParameterQuery.js.map +1 -1
- package/dist/SqlSyncRules.d.ts +13 -29
- package/dist/SqlSyncRules.js +48 -77
- package/dist/SqlSyncRules.js.map +1 -1
- package/dist/StaticSqlParameterQuery.d.ts +13 -3
- package/dist/StaticSqlParameterQuery.js +38 -4
- package/dist/StaticSqlParameterQuery.js.map +1 -1
- package/dist/TablePattern.d.ts +4 -1
- package/dist/TablePattern.js +11 -0
- package/dist/TablePattern.js.map +1 -1
- package/dist/TableValuedFunctionSqlParameterQuery.d.ts +14 -4
- package/dist/TableValuedFunctionSqlParameterQuery.js +41 -7
- package/dist/TableValuedFunctionSqlParameterQuery.js.map +1 -1
- package/dist/compatibility.d.ts +23 -1
- package/dist/compatibility.js +32 -4
- package/dist/compatibility.js.map +1 -1
- package/dist/compiler/bucket_resolver.d.ts +70 -0
- package/dist/compiler/bucket_resolver.js +131 -0
- package/dist/compiler/bucket_resolver.js.map +1 -0
- package/dist/compiler/compatibility.d.ts +16 -0
- package/dist/compiler/compatibility.js +12 -0
- package/dist/compiler/compatibility.js.map +1 -0
- package/dist/compiler/compiler.d.ts +104 -0
- package/dist/compiler/compiler.js +113 -0
- package/dist/compiler/compiler.js.map +1 -0
- package/dist/compiler/equality.d.ts +99 -0
- package/dist/compiler/equality.js +284 -0
- package/dist/compiler/equality.js.map +1 -0
- package/dist/compiler/expression.d.ts +77 -0
- package/dist/compiler/expression.js +122 -0
- package/dist/compiler/expression.js.map +1 -0
- package/dist/compiler/filter.d.ts +71 -0
- package/dist/compiler/filter.js +110 -0
- package/dist/compiler/filter.js.map +1 -0
- package/dist/compiler/filter_simplifier.d.ts +26 -0
- package/dist/compiler/filter_simplifier.js +119 -0
- package/dist/compiler/filter_simplifier.js.map +1 -0
- package/dist/compiler/ir_to_sync_plan.d.ts +37 -0
- package/dist/compiler/ir_to_sync_plan.js +163 -0
- package/dist/compiler/ir_to_sync_plan.js.map +1 -0
- package/dist/compiler/parser.d.ts +99 -0
- package/dist/compiler/parser.js +556 -0
- package/dist/compiler/parser.js.map +1 -0
- package/dist/compiler/querier_graph.d.ts +42 -0
- package/dist/compiler/querier_graph.js +365 -0
- package/dist/compiler/querier_graph.js.map +1 -0
- package/dist/compiler/rows.d.ts +113 -0
- package/dist/compiler/rows.js +156 -0
- package/dist/compiler/rows.js.map +1 -0
- package/dist/compiler/scope.d.ts +22 -0
- package/dist/compiler/scope.js +47 -0
- package/dist/compiler/scope.js.map +1 -0
- package/dist/compiler/sqlite.d.ts +77 -0
- package/dist/compiler/sqlite.js +412 -0
- package/dist/compiler/sqlite.js.map +1 -0
- package/dist/compiler/table.d.ts +67 -0
- package/dist/compiler/table.js +67 -0
- package/dist/compiler/table.js.map +1 -0
- package/dist/errors.d.ts +4 -2
- package/dist/errors.js +16 -1
- package/dist/errors.js.map +1 -1
- package/dist/events/SqlEventDescriptor.js +1 -1
- package/dist/events/SqlEventDescriptor.js.map +1 -1
- package/dist/events/SqlEventSourceQuery.d.ts +1 -1
- package/dist/events/SqlEventSourceQuery.js +1 -2
- package/dist/events/SqlEventSourceQuery.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/json_schema.js +5 -1
- package/dist/json_schema.js.map +1 -1
- package/dist/request_functions.js +1 -1
- package/dist/request_functions.js.map +1 -1
- package/dist/schema-generators/SchemaGenerator.d.ts +5 -0
- package/dist/schema-generators/SchemaGenerator.js +21 -14
- package/dist/schema-generators/SchemaGenerator.js.map +1 -1
- package/dist/sql_functions.d.ts +2 -1
- package/dist/sql_functions.js +1 -1
- package/dist/sql_functions.js.map +1 -1
- package/dist/streams/filter.d.ts +34 -4
- package/dist/streams/filter.js +93 -23
- package/dist/streams/filter.js.map +1 -1
- package/dist/streams/from_sql.js +2 -5
- package/dist/streams/from_sql.js.map +1 -1
- package/dist/streams/parameter.d.ts +7 -6
- package/dist/streams/stream.d.ts +25 -15
- package/dist/streams/stream.js +59 -87
- package/dist/streams/stream.js.map +1 -1
- package/dist/streams/variant.d.ts +14 -21
- package/dist/streams/variant.js +68 -46
- package/dist/streams/variant.js.map +1 -1
- package/dist/sync_plan/engine/javascript.d.ts +6 -0
- package/dist/sync_plan/engine/javascript.js +208 -0
- package/dist/sync_plan/engine/javascript.js.map +1 -0
- package/dist/sync_plan/engine/scalar_expression_engine.d.ts +48 -0
- package/dist/sync_plan/engine/scalar_expression_engine.js +99 -0
- package/dist/sync_plan/engine/scalar_expression_engine.js.map +1 -0
- package/dist/sync_plan/engine/sqlite.d.ts +12 -0
- package/dist/sync_plan/engine/sqlite.js +53 -0
- package/dist/sync_plan/engine/sqlite.js.map +1 -0
- package/dist/sync_plan/evaluator/bucket_data_source.d.ts +23 -0
- package/dist/sync_plan/evaluator/bucket_data_source.js +137 -0
- package/dist/sync_plan/evaluator/bucket_data_source.js.map +1 -0
- package/dist/sync_plan/evaluator/bucket_source.d.ts +19 -0
- package/dist/sync_plan/evaluator/bucket_source.js +145 -0
- package/dist/sync_plan/evaluator/bucket_source.js.map +1 -0
- package/dist/sync_plan/evaluator/index.d.ts +7 -0
- package/dist/sync_plan/evaluator/index.js +26 -0
- package/dist/sync_plan/evaluator/index.js.map +1 -0
- package/dist/sync_plan/evaluator/parameter_evaluator.d.ts +138 -0
- package/dist/sync_plan/evaluator/parameter_evaluator.js +359 -0
- package/dist/sync_plan/evaluator/parameter_evaluator.js.map +1 -0
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.d.ts +19 -0
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.js +62 -0
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.js.map +1 -0
- package/dist/sync_plan/expression.d.ts +109 -0
- package/dist/sync_plan/expression.js +85 -0
- package/dist/sync_plan/expression.js.map +1 -0
- package/dist/sync_plan/expression_to_sql.d.ts +43 -0
- package/dist/sync_plan/expression_to_sql.js +190 -0
- package/dist/sync_plan/expression_to_sql.js.map +1 -0
- package/dist/sync_plan/expression_visitor.d.ts +57 -0
- package/dist/sync_plan/expression_visitor.js +181 -0
- package/dist/sync_plan/expression_visitor.js.map +1 -0
- package/dist/sync_plan/plan.d.ts +196 -0
- package/dist/sync_plan/plan.js +2 -0
- package/dist/sync_plan/plan.js.map +1 -0
- package/dist/sync_plan/schema_inference.d.ts +15 -0
- package/dist/sync_plan/schema_inference.js +121 -0
- package/dist/sync_plan/schema_inference.js.map +1 -0
- package/dist/sync_plan/serialize.d.ts +82 -0
- package/dist/sync_plan/serialize.js +209 -0
- package/dist/sync_plan/serialize.js.map +1 -0
- package/dist/types/custom_sqlite_value.d.ts +1 -1
- package/dist/types/time.d.ts +24 -5
- package/dist/types/time.js +67 -12
- package/dist/types/time.js.map +1 -1
- package/dist/types.d.ts +52 -24
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +9 -2
- package/dist/utils.js +26 -3
- package/dist/utils.js.map +1 -1
- package/package.json +4 -3
- package/schema/sync_rules.json +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableValuedFunctionSqlParameterQuery.js","sourceRoot":"","sources":["../src/TableValuedFunctionSqlParameterQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"TableValuedFunctionSqlParameterQuery.js","sourceRoot":"","sources":["../src/TableValuedFunctionSqlParameterQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,uBAAuB,EAAkB,MAAM,wBAAwB,CAAC;AAEpH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAU3C,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,4BAA4B,EAAuB,MAAM,2BAA2B,CAAC;AAS9F,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAmB1D;;;;;;;;GAQG;AACH,MAAM,OAAO,oCAAoC;IAC/C,MAAM,CAAC,OAAO,CACZ,cAAsB,EACtB,GAAW,EACX,IAAc,EACd,CAAsB,EACtB,OAA0B,EAC1B,OAAe,EACf,iBAAmC;QAEnC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC5C,IAAI,MAAM,GAAmB,EAAE,CAAC;QAEhC,MAAM,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,GAAG,EAAE,CAAC,CA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AM,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAE3D,sEAAsE;QACtE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEhC,OAAO,OAAO,CAAC,oCAAoC,CAAC;IACtD,CAAC;IAED,IAAI,8BAA8B;QAChC,OAAO,IAAI,CAAC,oCAAoC,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC;IAC7F,CAAC;CACF"}
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -2,6 +2,16 @@ export declare enum CompatibilityEdition {
|
|
|
2
2
|
LEGACY = 1,
|
|
3
3
|
SYNC_STREAMS = 2
|
|
4
4
|
}
|
|
5
|
+
export declare class TimeValuePrecision {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly subSecondDigits: number;
|
|
8
|
+
private constructor();
|
|
9
|
+
static seconds: TimeValuePrecision;
|
|
10
|
+
static milliseconds: TimeValuePrecision;
|
|
11
|
+
static microseconds: TimeValuePrecision;
|
|
12
|
+
static nanoseconds: TimeValuePrecision;
|
|
13
|
+
static byName: Record<string, TimeValuePrecision>;
|
|
14
|
+
}
|
|
5
15
|
/**
|
|
6
16
|
* A historical issue of the PowerSync service that can only be changed in a backwards-incompatible manner.
|
|
7
17
|
*
|
|
@@ -19,6 +29,11 @@ export declare class CompatibilityOption {
|
|
|
19
29
|
static customTypes: CompatibilityOption;
|
|
20
30
|
static byName: Record<string, CompatibilityOption>;
|
|
21
31
|
}
|
|
32
|
+
export interface CompatibilityContextOptions {
|
|
33
|
+
edition: CompatibilityEdition;
|
|
34
|
+
overrides?: Map<CompatibilityOption, boolean>;
|
|
35
|
+
maxTimeValuePrecision?: TimeValuePrecision;
|
|
36
|
+
}
|
|
22
37
|
export declare class CompatibilityContext {
|
|
23
38
|
/**
|
|
24
39
|
* The general compatibility level we're operating under.
|
|
@@ -31,7 +46,14 @@ export declare class CompatibilityContext {
|
|
|
31
46
|
* Overrides to customize used compatibility options to deviate from defaults at the given {@link edition}.
|
|
32
47
|
*/
|
|
33
48
|
readonly overrides: Map<CompatibilityOption, boolean>;
|
|
34
|
-
|
|
49
|
+
/**
|
|
50
|
+
* A limit for the precision the sync service uses to encode time values.
|
|
51
|
+
*
|
|
52
|
+
* This can be set to e.g. `milliseconds` to only emit three digits of sub-second precision even if the source
|
|
53
|
+
* database uses microseconds natively.
|
|
54
|
+
*/
|
|
55
|
+
readonly maxTimeValuePrecision: TimeValuePrecision | null;
|
|
56
|
+
constructor(options: CompatibilityContextOptions);
|
|
35
57
|
isEnabled(option: CompatibilityOption): boolean;
|
|
36
58
|
/**
|
|
37
59
|
* A {@link CompatibilityContext} in which no fixes are applied.
|
package/dist/compatibility.js
CHANGED
|
@@ -3,6 +3,24 @@ export var CompatibilityEdition;
|
|
|
3
3
|
CompatibilityEdition[CompatibilityEdition["LEGACY"] = 1] = "LEGACY";
|
|
4
4
|
CompatibilityEdition[CompatibilityEdition["SYNC_STREAMS"] = 2] = "SYNC_STREAMS";
|
|
5
5
|
})(CompatibilityEdition || (CompatibilityEdition = {}));
|
|
6
|
+
export class TimeValuePrecision {
|
|
7
|
+
name;
|
|
8
|
+
subSecondDigits;
|
|
9
|
+
constructor(name, subSecondDigits) {
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.subSecondDigits = subSecondDigits;
|
|
12
|
+
}
|
|
13
|
+
static seconds = new TimeValuePrecision('seconds', 0);
|
|
14
|
+
static milliseconds = new TimeValuePrecision('milliseconds', 3);
|
|
15
|
+
static microseconds = new TimeValuePrecision('microseconds', 6);
|
|
16
|
+
static nanoseconds = new TimeValuePrecision('nanoseconds', 9);
|
|
17
|
+
static byName = Object.freeze({
|
|
18
|
+
seconds: this.seconds,
|
|
19
|
+
milliseconds: this.milliseconds,
|
|
20
|
+
microseconds: this.microseconds,
|
|
21
|
+
nanoseconds: this.nanoseconds
|
|
22
|
+
});
|
|
23
|
+
}
|
|
6
24
|
/**
|
|
7
25
|
* A historical issue of the PowerSync service that can only be changed in a backwards-incompatible manner.
|
|
8
26
|
*
|
|
@@ -41,9 +59,17 @@ export class CompatibilityContext {
|
|
|
41
59
|
* Overrides to customize used compatibility options to deviate from defaults at the given {@link edition}.
|
|
42
60
|
*/
|
|
43
61
|
overrides;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
/**
|
|
63
|
+
* A limit for the precision the sync service uses to encode time values.
|
|
64
|
+
*
|
|
65
|
+
* This can be set to e.g. `milliseconds` to only emit three digits of sub-second precision even if the source
|
|
66
|
+
* database uses microseconds natively.
|
|
67
|
+
*/
|
|
68
|
+
maxTimeValuePrecision;
|
|
69
|
+
constructor(options) {
|
|
70
|
+
this.edition = options.edition;
|
|
71
|
+
this.overrides = options.overrides ?? new Map();
|
|
72
|
+
this.maxTimeValuePrecision = options.maxTimeValuePrecision ?? null;
|
|
47
73
|
}
|
|
48
74
|
isEnabled(option) {
|
|
49
75
|
return this.overrides.get(option) ?? option.fixedIn <= this.edition;
|
|
@@ -51,6 +77,8 @@ export class CompatibilityContext {
|
|
|
51
77
|
/**
|
|
52
78
|
* A {@link CompatibilityContext} in which no fixes are applied.
|
|
53
79
|
*/
|
|
54
|
-
static FULL_BACKWARDS_COMPATIBILITY = new CompatibilityContext(
|
|
80
|
+
static FULL_BACKWARDS_COMPATIBILITY = new CompatibilityContext({
|
|
81
|
+
edition: CompatibilityEdition.LEGACY
|
|
82
|
+
});
|
|
55
83
|
}
|
|
56
84
|
//# sourceMappingURL=compatibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,mEAAU,CAAA;IACV,+EAAgB,CAAA;AAClB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAEnB;IACA;IACA;IAH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wC,MAAM,CAAC,MAAM,CAAC;QACjE,kBAAkB,EAAE,IAAI,CAAC,iBAAiB;QAC1C,oBAAoB,EAAE,IAAI,CAAC,kBAAkB;QAC7C,kBAAkB,EAAE,IAAI,CAAC,gBAAgB;QACzC,qBAAqB,EAAE,IAAI,CAAC,WAAW;KACxC,CAAC,CAAC;;AASL,MAAM,OAAO,oBAAoB;IAC/B;;;;;OAKG;IACM,OAAO,CAAuB;IAEvC;;OAEG;IACM,SAAS,CAAoC;IAEtD;;;;;OAKG;IACM,qBAAqB,CAA4B;IAE1D,YAAY,OAAoC;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,GAAG,EAAE,CAAC;QAChD,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,IAAI,IAAI,CAAC;IACrE,CAAC;IAED,SAAS,CAAC,MAA2B;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,4BAA4B,GAAyB,IAAI,oBAAoB,CAAC;QACnF,OAAO,EAAE,oBAAoB,CAAC,MAAM;KACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Equatable, HashSet, StableHasher } from './equality.js';
|
|
2
|
+
import { RequestExpression, RowExpression } from './filter.js';
|
|
3
|
+
import { PointLookup, RowEvaluator } from './rows.js';
|
|
4
|
+
import { RequestTableValuedResultSet } from './table.js';
|
|
5
|
+
import { StreamOptions } from '../sync_plan/plan.js';
|
|
6
|
+
/**
|
|
7
|
+
* Describes how to resolve a subscription to buckets.
|
|
8
|
+
*/
|
|
9
|
+
export declare class StreamResolver {
|
|
10
|
+
readonly options: StreamOptions;
|
|
11
|
+
readonly requestFilters: RequestExpression[];
|
|
12
|
+
readonly lookupStages: ExpandingLookup[][];
|
|
13
|
+
readonly resolvedBucket: ResolveBucket;
|
|
14
|
+
readonly uniqueName: string;
|
|
15
|
+
constructor(options: StreamOptions, requestFilters: RequestExpression[], lookupStages: ExpandingLookup[][], resolvedBucket: ResolveBucket, uniqueName: string);
|
|
16
|
+
buildInstantiationHash(hasher: StableHasher): void;
|
|
17
|
+
hasIdenticalInstantiation(other: StreamResolver): boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A lookup returning multiple rows when instantiated.
|
|
21
|
+
*/
|
|
22
|
+
export type ExpandingLookup = ParameterLookup | EvaluateTableValuedFunction;
|
|
23
|
+
export declare class ParameterLookup implements Equatable {
|
|
24
|
+
readonly lookup: PointLookup;
|
|
25
|
+
readonly instantiation: ParameterValue[];
|
|
26
|
+
constructor(lookup: PointLookup, instantiation: ParameterValue[]);
|
|
27
|
+
buildHash(hasher: StableHasher): void;
|
|
28
|
+
equals(other: unknown): boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare class EvaluateTableValuedFunction implements Equatable {
|
|
31
|
+
readonly tableValuedFunction: RequestTableValuedResultSet;
|
|
32
|
+
readonly outputs: RowExpression[];
|
|
33
|
+
readonly filters: RowExpression[];
|
|
34
|
+
constructor(tableValuedFunction: RequestTableValuedResultSet, outputs: RowExpression[], filters: RowExpression[]);
|
|
35
|
+
buildHash(hasher: StableHasher): void;
|
|
36
|
+
equals(other: unknown): boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare class ResolveBucket {
|
|
39
|
+
readonly instantiation: ParameterValue[];
|
|
40
|
+
readonly evaluators: HashSet<RowEvaluator>;
|
|
41
|
+
constructor(evaluator: RowEvaluator, instantiation: ParameterValue[]);
|
|
42
|
+
buildInstantiationHash(hasher: StableHasher): void;
|
|
43
|
+
hasIdenticalInstantiation(other: ResolveBucket): boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A value passed as input to a partition key of a {@link SourceRowProcessor}
|
|
47
|
+
*/
|
|
48
|
+
export type ParameterValue = RequestParameterValue | LookupResultParameterValue | IntersectionParameterValue;
|
|
49
|
+
/**
|
|
50
|
+
* A value derived from request data.
|
|
51
|
+
*/
|
|
52
|
+
export declare class RequestParameterValue implements Equatable {
|
|
53
|
+
readonly expression: RequestExpression;
|
|
54
|
+
constructor(expression: RequestExpression);
|
|
55
|
+
buildHash(hasher: StableHasher): void;
|
|
56
|
+
equals(other: unknown): boolean;
|
|
57
|
+
}
|
|
58
|
+
export declare class LookupResultParameterValue implements Equatable {
|
|
59
|
+
readonly resultIndex: number;
|
|
60
|
+
lookup: ExpandingLookup | undefined;
|
|
61
|
+
constructor(resultIndex: number);
|
|
62
|
+
buildHash(hasher: StableHasher): void;
|
|
63
|
+
equals(other: ParameterValue): boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare class IntersectionParameterValue implements Equatable {
|
|
66
|
+
readonly inner: ParameterValue[];
|
|
67
|
+
constructor(inner: ParameterValue[]);
|
|
68
|
+
buildHash(hasher: StableHasher): void;
|
|
69
|
+
equals(other: unknown): boolean;
|
|
70
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { HashSet, StableHasher } from './equality.js';
|
|
2
|
+
import { equalsIgnoringResultSetList, equalsIgnoringResultSetUnordered } from './compatibility.js';
|
|
3
|
+
/**
|
|
4
|
+
* Describes how to resolve a subscription to buckets.
|
|
5
|
+
*/
|
|
6
|
+
export class StreamResolver {
|
|
7
|
+
options;
|
|
8
|
+
requestFilters;
|
|
9
|
+
lookupStages;
|
|
10
|
+
resolvedBucket;
|
|
11
|
+
uniqueName;
|
|
12
|
+
constructor(options, requestFilters, lookupStages, resolvedBucket, uniqueName) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.requestFilters = requestFilters;
|
|
15
|
+
this.lookupStages = lookupStages;
|
|
16
|
+
this.resolvedBucket = resolvedBucket;
|
|
17
|
+
this.uniqueName = uniqueName;
|
|
18
|
+
}
|
|
19
|
+
buildInstantiationHash(hasher) {
|
|
20
|
+
equalsIgnoringResultSetUnordered.hash(hasher, this.requestFilters);
|
|
21
|
+
this.resolvedBucket.buildInstantiationHash(hasher);
|
|
22
|
+
}
|
|
23
|
+
hasIdenticalInstantiation(other) {
|
|
24
|
+
if (other.options != this.options) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (!equalsIgnoringResultSetUnordered.equals(other.requestFilters, this.requestFilters)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return other.resolvedBucket.hasIdenticalInstantiation(this.resolvedBucket);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class ParameterLookup {
|
|
34
|
+
lookup;
|
|
35
|
+
instantiation;
|
|
36
|
+
constructor(lookup, instantiation) {
|
|
37
|
+
this.lookup = lookup;
|
|
38
|
+
this.instantiation = instantiation;
|
|
39
|
+
}
|
|
40
|
+
buildHash(hasher) {
|
|
41
|
+
hasher.addHash(this.lookup.behaviorHashCode);
|
|
42
|
+
hasher.add(...this.instantiation);
|
|
43
|
+
}
|
|
44
|
+
equals(other) {
|
|
45
|
+
return (other instanceof ParameterLookup &&
|
|
46
|
+
other.lookup.behavesIdenticalTo(this.lookup) &&
|
|
47
|
+
StableHasher.defaultListEquality.equals(other.instantiation, this.instantiation));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class EvaluateTableValuedFunction {
|
|
51
|
+
tableValuedFunction;
|
|
52
|
+
outputs;
|
|
53
|
+
filters;
|
|
54
|
+
constructor(tableValuedFunction, outputs, filters) {
|
|
55
|
+
this.tableValuedFunction = tableValuedFunction;
|
|
56
|
+
this.outputs = outputs;
|
|
57
|
+
this.filters = filters;
|
|
58
|
+
}
|
|
59
|
+
buildHash(hasher) {
|
|
60
|
+
this.tableValuedFunction.buildBehaviorHashCode(hasher);
|
|
61
|
+
equalsIgnoringResultSetList.hash(hasher, this.outputs);
|
|
62
|
+
equalsIgnoringResultSetList.hash(hasher, this.filters);
|
|
63
|
+
}
|
|
64
|
+
equals(other) {
|
|
65
|
+
return (other instanceof EvaluateTableValuedFunction &&
|
|
66
|
+
other.tableValuedFunction.behavesIdenticalTo(this.tableValuedFunction) &&
|
|
67
|
+
equalsIgnoringResultSetList.equals(other.outputs, this.outputs) &&
|
|
68
|
+
equalsIgnoringResultSetList.equals(other.filters, this.filters));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export class ResolveBucket {
|
|
72
|
+
instantiation;
|
|
73
|
+
evaluators = new HashSet({
|
|
74
|
+
hash: (hasher, value) => value.buildBehaviorHashCode(hasher),
|
|
75
|
+
equals: (a, b) => a.behavesIdenticalTo(b)
|
|
76
|
+
});
|
|
77
|
+
constructor(evaluator, instantiation) {
|
|
78
|
+
this.instantiation = instantiation;
|
|
79
|
+
this.evaluators.add(evaluator);
|
|
80
|
+
}
|
|
81
|
+
buildInstantiationHash(hasher) {
|
|
82
|
+
hasher.add(...this.instantiation);
|
|
83
|
+
}
|
|
84
|
+
hasIdenticalInstantiation(other) {
|
|
85
|
+
return StableHasher.defaultListEquality.equals(other.instantiation, this.instantiation);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A value derived from request data.
|
|
90
|
+
*/
|
|
91
|
+
export class RequestParameterValue {
|
|
92
|
+
expression;
|
|
93
|
+
constructor(expression) {
|
|
94
|
+
this.expression = expression;
|
|
95
|
+
}
|
|
96
|
+
buildHash(hasher) {
|
|
97
|
+
this.expression.assumingSameResultSetEqualityHashCode(hasher);
|
|
98
|
+
}
|
|
99
|
+
equals(other) {
|
|
100
|
+
return other instanceof RequestParameterValue && other.expression.equalsAssumingSameResultSet(this.expression);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export class LookupResultParameterValue {
|
|
104
|
+
resultIndex;
|
|
105
|
+
lookup; // Set lazily
|
|
106
|
+
constructor(resultIndex) {
|
|
107
|
+
this.resultIndex = resultIndex;
|
|
108
|
+
}
|
|
109
|
+
buildHash(hasher) {
|
|
110
|
+
this.lookup?.buildHash(hasher);
|
|
111
|
+
hasher.addHash(this.resultIndex);
|
|
112
|
+
}
|
|
113
|
+
equals(other) {
|
|
114
|
+
return (other instanceof LookupResultParameterValue &&
|
|
115
|
+
other.lookup.equals(this.lookup) &&
|
|
116
|
+
other.resultIndex == this.resultIndex);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export class IntersectionParameterValue {
|
|
120
|
+
inner;
|
|
121
|
+
constructor(inner) {
|
|
122
|
+
this.inner = inner;
|
|
123
|
+
}
|
|
124
|
+
buildHash(hasher) {
|
|
125
|
+
hasher.add(...this.inner);
|
|
126
|
+
}
|
|
127
|
+
equals(other) {
|
|
128
|
+
return (other instanceof IntersectionParameterValue && StableHasher.defaultListEquality.equals(other.inner, this.inner));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=bucket_resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucket_resolver.js","sourceRoot":"","sources":["../../src/compiler/bucket_resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAMnG;;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,gCAAgC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAA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AAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Equality, StableHasher } from './equality.js';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for structures that can be compared for equality in a way that ignores referenced result set.
|
|
4
|
+
*
|
|
5
|
+
* This is primarily used to compare expressions across streams. If we have two streams defined as
|
|
6
|
+
* `SELECT * FROM users WHERE id = ...` , the `id` column would not be equal between those since it references a the
|
|
7
|
+
* logical `users` table added to each individual statement. But if we are in a context where we know the physical table
|
|
8
|
+
* is the same, this allows comparing expressions for equality.
|
|
9
|
+
*/
|
|
10
|
+
export interface EqualsIgnoringResultSet {
|
|
11
|
+
equalsAssumingSameResultSet(other: EqualsIgnoringResultSet): boolean;
|
|
12
|
+
assumingSameResultSetEqualityHashCode(hasher: StableHasher): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const equalsIgnoringResultSet: Equality<EqualsIgnoringResultSet>;
|
|
15
|
+
export declare const equalsIgnoringResultSetList: Equality<Iterable<EqualsIgnoringResultSet>>;
|
|
16
|
+
export declare const equalsIgnoringResultSetUnordered: Equality<Iterable<EqualsIgnoringResultSet>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { listEquality } from './equality.js';
|
|
2
|
+
export const equalsIgnoringResultSet = {
|
|
3
|
+
equals: function (a, b) {
|
|
4
|
+
return a.equalsAssumingSameResultSet(b);
|
|
5
|
+
},
|
|
6
|
+
hash: function (hasher, value) {
|
|
7
|
+
return value.assumingSameResultSetEqualityHashCode(hasher);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export const equalsIgnoringResultSetList = listEquality(equalsIgnoringResultSet);
|
|
11
|
+
export const equalsIgnoringResultSetUnordered = listEquality(equalsIgnoringResultSet);
|
|
12
|
+
//# sourceMappingURL=compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../../src/compiler/compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAgB,MAAM,eAAe,CAAC;AAerE,MAAM,CAAC,MAAM,uBAAuB,GAAsC;IACxE,MAAM,EAAE,UAAU,CAA0B,EAAE,CAA0B;QACtE,OAAO,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,EAAE,UAAU,MAAoB,EAAE,KAA8B;QAClE,OAAO,KAAK,CAAC,qCAAqC,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AACjF,MAAM,CAAC,MAAM,gCAAgC,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { NodeLocation, PGNode } from 'pgsql-ast-parser';
|
|
2
|
+
import { PointLookup, RowEvaluator } from './rows.js';
|
|
3
|
+
import { StreamResolver } from './bucket_resolver.js';
|
|
4
|
+
import { StreamOptions, SyncPlan } from '../sync_plan/plan.js';
|
|
5
|
+
import { PreparedSubquery } from './sqlite.js';
|
|
6
|
+
import { SourceSchema } from '../types.js';
|
|
7
|
+
export interface SyncStreamsCompilerOptions {
|
|
8
|
+
defaultSchema: string;
|
|
9
|
+
/**
|
|
10
|
+
* An optional schema, used exclusively for linting table and column references that can't be resolved in it.
|
|
11
|
+
*
|
|
12
|
+
* Sync streams compile to the same plan regardless of the assumed schema, and it's possible to reuse compiled sync
|
|
13
|
+
* streams across schema changes.
|
|
14
|
+
*/
|
|
15
|
+
schema?: SourceSchema;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* State for compiling sync streams.
|
|
19
|
+
*
|
|
20
|
+
* The output of compiling all sync streams is a {@link SyncPlan}, a declarative description of the sync process that
|
|
21
|
+
* can be serialized to bucket storage. The compiler stores a mutable intermediate representation that is essentially a
|
|
22
|
+
* copy of the sync plan, except that we're using JavaScript classes with methods to compute hash codes and equality
|
|
23
|
+
* relations. This allows the compiler to efficiently de-duplicate parameters and buckets.
|
|
24
|
+
*
|
|
25
|
+
* Overall, the compilation process is as follows: Each data query for a stream is first parsed by
|
|
26
|
+
* {@link StreamQueryParser} into a canonicalized intermediate representation (see that class for details).
|
|
27
|
+
* Then, {@link QuerierGraphBuilder} analyzes a chain of `AND` expressions to identify parameters (as partition keys)
|
|
28
|
+
* and their instantiation, as well as static filters that need to be added to reach row.
|
|
29
|
+
*/
|
|
30
|
+
export declare class SyncStreamsCompiler {
|
|
31
|
+
readonly options: SyncStreamsCompilerOptions;
|
|
32
|
+
readonly output: CompiledStreamQueries;
|
|
33
|
+
private readonly locations;
|
|
34
|
+
constructor(options: SyncStreamsCompilerOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Tries to parse the SQL query as a `SELECT` statement into a form supported for common table expressions.
|
|
37
|
+
*
|
|
38
|
+
* Common table expressions are parsed and validated independently and without a shared scope, meaning that CTEs are
|
|
39
|
+
* not allowed to reference other CTEs. This limitation is deliberate, but we _could_ support it (referenced CTEs
|
|
40
|
+
* would just get inlined into the new CTE by the parser). So we can revisit this and potentially support that in the
|
|
41
|
+
* future.
|
|
42
|
+
*
|
|
43
|
+
* Returns null and reports errors if that fails.
|
|
44
|
+
*/
|
|
45
|
+
commonTableExpression(sql: string, errors: ParsingErrorListener): PreparedSubquery | null;
|
|
46
|
+
/**
|
|
47
|
+
* Utility for compiling a sync stream.
|
|
48
|
+
*
|
|
49
|
+
* @param options Name, priority and `auto_subscribe` state for the stream.
|
|
50
|
+
*/
|
|
51
|
+
stream(options: StreamOptions): IndividualSyncStreamCompiler;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Utility for compiling a single sync stream.
|
|
55
|
+
*/
|
|
56
|
+
export interface IndividualSyncStreamCompiler {
|
|
57
|
+
/**
|
|
58
|
+
* Makes a common table expression prepared through {@link SyncStreamsCompiler.commonTableExpression} available when
|
|
59
|
+
* parsing queries for this stream.
|
|
60
|
+
*/
|
|
61
|
+
registerCommonTableExpression(name: string, cte: PreparedSubquery): void;
|
|
62
|
+
/**
|
|
63
|
+
* Validates and adds a parameter query to this stream.
|
|
64
|
+
*
|
|
65
|
+
* @param sql The SQL query to add.
|
|
66
|
+
* @param errors An error reporter associating source positions with the current SQL source.
|
|
67
|
+
*/
|
|
68
|
+
addQuery(sql: string, errors: ParsingErrorListener): void;
|
|
69
|
+
/**
|
|
70
|
+
* Merges added queries into compatible bucket groups and adds them to the compiled sync plan.
|
|
71
|
+
*/
|
|
72
|
+
finish(): void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Something reporting errors.
|
|
76
|
+
*
|
|
77
|
+
* While sync streams can be made up of multiple SQL statements from different YAML strings, we want to be able to
|
|
78
|
+
* accurately describe the source of an error in YAML when we report it.
|
|
79
|
+
*
|
|
80
|
+
* So, every transformation that might need to report errors receives an instance of this interface which implicitly
|
|
81
|
+
* binds errors to one specific SQL string.
|
|
82
|
+
*/
|
|
83
|
+
export interface ParsingErrorListener {
|
|
84
|
+
report(message: string, location: NodeLocation | PGNode, options?: {
|
|
85
|
+
isWarning: boolean;
|
|
86
|
+
}): void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A mutable collection of resources (row evaluators, point lookups and stream resolvers) created for all streams in a
|
|
90
|
+
* definition file.
|
|
91
|
+
*/
|
|
92
|
+
export declare class CompiledStreamQueries {
|
|
93
|
+
private readonly _evaluators;
|
|
94
|
+
private readonly _pointLookups;
|
|
95
|
+
readonly resolvers: StreamResolver[];
|
|
96
|
+
get evaluators(): RowEvaluator[];
|
|
97
|
+
get pointLookups(): PointLookup[];
|
|
98
|
+
canonicalizeEvaluator(evaluator: RowEvaluator): RowEvaluator;
|
|
99
|
+
canonicalizePointLookup(lookup: PointLookup): PointLookup;
|
|
100
|
+
/**
|
|
101
|
+
* @returns A sync plan representing an immutable snapshot of this intermediate representation.
|
|
102
|
+
*/
|
|
103
|
+
toSyncPlan(): SyncPlan;
|
|
104
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { parse } from 'pgsql-ast-parser';
|
|
2
|
+
import { HashSet } from './equality.js';
|
|
3
|
+
import { CompilerModelToSyncPlan } from './ir_to_sync_plan.js';
|
|
4
|
+
import { QuerierGraphBuilder } from './querier_graph.js';
|
|
5
|
+
import { StreamQueryParser } from './parser.js';
|
|
6
|
+
import { NodeLocations } from './expression.js';
|
|
7
|
+
import { SqlScope } from './scope.js';
|
|
8
|
+
/**
|
|
9
|
+
* State for compiling sync streams.
|
|
10
|
+
*
|
|
11
|
+
* The output of compiling all sync streams is a {@link SyncPlan}, a declarative description of the sync process that
|
|
12
|
+
* can be serialized to bucket storage. The compiler stores a mutable intermediate representation that is essentially a
|
|
13
|
+
* copy of the sync plan, except that we're using JavaScript classes with methods to compute hash codes and equality
|
|
14
|
+
* relations. This allows the compiler to efficiently de-duplicate parameters and buckets.
|
|
15
|
+
*
|
|
16
|
+
* Overall, the compilation process is as follows: Each data query for a stream is first parsed by
|
|
17
|
+
* {@link StreamQueryParser} into a canonicalized intermediate representation (see that class for details).
|
|
18
|
+
* Then, {@link QuerierGraphBuilder} analyzes a chain of `AND` expressions to identify parameters (as partition keys)
|
|
19
|
+
* and their instantiation, as well as static filters that need to be added to reach row.
|
|
20
|
+
*/
|
|
21
|
+
export class SyncStreamsCompiler {
|
|
22
|
+
options;
|
|
23
|
+
output = new CompiledStreamQueries();
|
|
24
|
+
locations = new NodeLocations();
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.options = options;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Tries to parse the SQL query as a `SELECT` statement into a form supported for common table expressions.
|
|
30
|
+
*
|
|
31
|
+
* Common table expressions are parsed and validated independently and without a shared scope, meaning that CTEs are
|
|
32
|
+
* not allowed to reference other CTEs. This limitation is deliberate, but we _could_ support it (referenced CTEs
|
|
33
|
+
* would just get inlined into the new CTE by the parser). So we can revisit this and potentially support that in the
|
|
34
|
+
* future.
|
|
35
|
+
*
|
|
36
|
+
* Returns null and reports errors if that fails.
|
|
37
|
+
*/
|
|
38
|
+
commonTableExpression(sql, errors) {
|
|
39
|
+
const parser = new StreamQueryParser({
|
|
40
|
+
compiler: this,
|
|
41
|
+
originalText: sql,
|
|
42
|
+
locations: this.locations,
|
|
43
|
+
parentScope: new SqlScope({}),
|
|
44
|
+
errors
|
|
45
|
+
});
|
|
46
|
+
const [stmt] = parse(sql, { locationTracking: true });
|
|
47
|
+
return parser.parseAsSubquery(stmt);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Utility for compiling a sync stream.
|
|
51
|
+
*
|
|
52
|
+
* @param options Name, priority and `auto_subscribe` state for the stream.
|
|
53
|
+
*/
|
|
54
|
+
stream(options) {
|
|
55
|
+
const builder = new QuerierGraphBuilder(this, options);
|
|
56
|
+
const rootScope = new SqlScope({});
|
|
57
|
+
return {
|
|
58
|
+
registerCommonTableExpression: (name, cte) => {
|
|
59
|
+
rootScope.registerCommonTableExpression(name, cte);
|
|
60
|
+
},
|
|
61
|
+
addQuery: (sql, errors) => {
|
|
62
|
+
const [stmt] = parse(sql, { locationTracking: true });
|
|
63
|
+
const parser = new StreamQueryParser({
|
|
64
|
+
compiler: this,
|
|
65
|
+
originalText: sql,
|
|
66
|
+
locations: this.locations,
|
|
67
|
+
parentScope: rootScope,
|
|
68
|
+
errors
|
|
69
|
+
});
|
|
70
|
+
const query = parser.parse(stmt);
|
|
71
|
+
if (query) {
|
|
72
|
+
builder.process(query, errors);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
finish: () => builder.finish()
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A mutable collection of resources (row evaluators, point lookups and stream resolvers) created for all streams in a
|
|
81
|
+
* definition file.
|
|
82
|
+
*/
|
|
83
|
+
export class CompiledStreamQueries {
|
|
84
|
+
_evaluators = new HashSet({
|
|
85
|
+
hash: (hasher, value) => value.buildBehaviorHashCode(hasher),
|
|
86
|
+
equals: (a, b) => a.behavesIdenticalTo(b)
|
|
87
|
+
});
|
|
88
|
+
_pointLookups = new HashSet({
|
|
89
|
+
hash: (hasher, value) => value.buildBehaviorHashCode(hasher),
|
|
90
|
+
equals: (a, b) => a.behavesIdenticalTo(b)
|
|
91
|
+
});
|
|
92
|
+
resolvers = [];
|
|
93
|
+
get evaluators() {
|
|
94
|
+
return [...this._evaluators];
|
|
95
|
+
}
|
|
96
|
+
get pointLookups() {
|
|
97
|
+
return [...this._pointLookups];
|
|
98
|
+
}
|
|
99
|
+
canonicalizeEvaluator(evaluator) {
|
|
100
|
+
return this._evaluators.getOrInsert(evaluator)[0];
|
|
101
|
+
}
|
|
102
|
+
canonicalizePointLookup(lookup) {
|
|
103
|
+
return this._pointLookups.getOrInsert(lookup)[0];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @returns A sync plan representing an immutable snapshot of this intermediate representation.
|
|
107
|
+
*/
|
|
108
|
+
toSyncPlan() {
|
|
109
|
+
const translator = new CompilerModelToSyncPlan();
|
|
110
|
+
return translator.translate(this);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAU,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,Y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