@powersync/service-sync-rules 0.36.0 → 0.37.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 +4 -4
- package/dist/BaseSqlDataQuery.js.map +1 -1
- package/dist/BucketSource.d.ts +35 -28
- package/dist/BucketSource.js +12 -28
- package/dist/BucketSource.js.map +1 -1
- package/dist/HydratedSyncConfig.d.ts +80 -0
- package/dist/HydratedSyncConfig.js +207 -0
- package/dist/HydratedSyncConfig.js.map +1 -0
- package/dist/HydrationState.d.ts +20 -1
- package/dist/HydrationState.js +14 -2
- package/dist/HydrationState.js.map +1 -1
- package/dist/SourceTableRef.d.ts +9 -0
- package/dist/SourceTableRef.js +4 -0
- package/dist/SourceTableRef.js.map +1 -0
- package/dist/SqlBucketDescriptor.d.ts +5 -4
- package/dist/SqlBucketDescriptor.js +3 -0
- package/dist/SqlBucketDescriptor.js.map +1 -1
- package/dist/SqlDataQuery.d.ts +2 -2
- package/dist/SqlDataQuery.js.map +1 -1
- package/dist/SqlParameterQuery.d.ts +8 -7
- package/dist/SqlParameterQuery.js +5 -3
- package/dist/SqlParameterQuery.js.map +1 -1
- package/dist/StaticSqlParameterQuery.d.ts +2 -2
- package/dist/StaticSqlParameterQuery.js.map +1 -1
- package/dist/SyncConfig.d.ts +8 -8
- package/dist/SyncConfig.js +8 -16
- package/dist/SyncConfig.js.map +1 -1
- package/dist/TablePattern.d.ts +8 -2
- package/dist/TablePattern.js +8 -0
- package/dist/TablePattern.js.map +1 -1
- package/dist/TableValuedFunctionSqlParameterQuery.d.ts +2 -2
- package/dist/TableValuedFunctionSqlParameterQuery.js.map +1 -1
- package/dist/TableValuedFunctions.js +15 -10
- package/dist/TableValuedFunctions.js.map +1 -1
- package/dist/cast.js +7 -5
- package/dist/cast.js.map +1 -1
- package/dist/compatibility.d.ts +3 -1
- package/dist/compatibility.js +12 -3
- package/dist/compatibility.js.map +1 -1
- package/dist/compiler/equality.js +2 -1
- package/dist/compiler/equality.js.map +1 -1
- package/dist/events/SqlEventDescriptor.d.ts +2 -2
- package/dist/events/SqlEventDescriptor.js.map +1 -1
- package/dist/events/SqlEventSourceQuery.d.ts +2 -2
- package/dist/events/SqlEventSourceQuery.js.map +1 -1
- package/dist/from_yaml.js +9 -2
- package/dist/from_yaml.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/sql_functions.d.ts +4 -4
- package/dist/sql_functions.js +12 -6
- package/dist/sql_functions.js.map +1 -1
- package/dist/streams/filter.d.ts +8 -7
- package/dist/streams/filter.js +5 -3
- package/dist/streams/filter.js.map +1 -1
- package/dist/streams/stream.d.ts +5 -4
- package/dist/streams/stream.js +3 -0
- package/dist/streams/stream.js.map +1 -1
- package/dist/sync_plan/engine/factory.d.ts +4 -0
- package/dist/sync_plan/engine/factory.js +13 -0
- package/dist/sync_plan/engine/factory.js.map +1 -0
- package/dist/sync_plan/engine/javascript.js +0 -1
- package/dist/sync_plan/engine/javascript.js.map +1 -1
- package/dist/sync_plan/engine/scalar_expression_engine.d.ts +0 -4
- package/dist/sync_plan/engine/scalar_expression_engine.js +2 -2
- package/dist/sync_plan/engine/scalar_expression_engine.js.map +1 -1
- package/dist/sync_plan/engine/sqlite.d.ts +26 -5
- package/dist/sync_plan/engine/sqlite.js +38 -23
- package/dist/sync_plan/engine/sqlite.js.map +1 -1
- package/dist/sync_plan/evaluator/bucket_data_source.d.ts +6 -7
- package/dist/sync_plan/evaluator/bucket_data_source.js +67 -57
- package/dist/sync_plan/evaluator/bucket_data_source.js.map +1 -1
- package/dist/sync_plan/evaluator/bucket_source.d.ts +2 -2
- package/dist/sync_plan/evaluator/bucket_source.js +4 -4
- package/dist/sync_plan/evaluator/bucket_source.js.map +1 -1
- package/dist/sync_plan/evaluator/index.d.ts +0 -2
- package/dist/sync_plan/evaluator/index.js.map +1 -1
- package/dist/sync_plan/evaluator/parameter_evaluator.d.ts +3 -1
- package/dist/sync_plan/evaluator/parameter_evaluator.js +4 -3
- package/dist/sync_plan/evaluator/parameter_evaluator.js.map +1 -1
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.d.ts +8 -9
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.js +62 -58
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.js.map +1 -1
- package/dist/sync_plan/expression.js +1 -1
- package/dist/sync_plan/expression.js.map +1 -1
- package/dist/sync_plan/expression_to_sql.js +1 -1
- package/dist/sync_plan/expression_to_sql.js.map +1 -1
- package/dist/sync_plan/plan.d.ts +2 -2
- package/dist/sync_plan/serialize.d.ts +2 -2
- package/dist/types.d.ts +12 -2
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +13 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/schema/sync_rules.json +4 -0
- package/dist/HydratedSyncRules.d.ts +0 -46
- package/dist/HydratedSyncRules.js +0 -88
- package/dist/HydratedSyncRules.js.map +0 -1
- package/dist/SourceTableInterface.d.ts +0 -5
- package/dist/SourceTableInterface.js +0 -2
- package/dist/SourceTableInterface.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SelectedColumn } from 'pgsql-ast-parser';
|
|
2
2
|
import { SqlRuleError } from './errors.js';
|
|
3
3
|
import { ColumnDefinition } from './ExpressionType.js';
|
|
4
|
-
import {
|
|
4
|
+
import { SourceTableRef } from './SourceTableRef.js';
|
|
5
5
|
import { AvailableTable, SqlTools } from './sql_filters.js';
|
|
6
6
|
import { TablePattern } from './TablePattern.js';
|
|
7
7
|
import { QueryParameters, QuerySchema, SourceSchema, SourceSchemaTable, SqliteJsonRow, SqliteRow, UnscopedEvaluationResult } from './types.js';
|
|
@@ -10,7 +10,7 @@ export interface RowValueExtractor {
|
|
|
10
10
|
getTypes(schema: QuerySchema, into: Record<string, ColumnDefinition>): void;
|
|
11
11
|
}
|
|
12
12
|
export interface EvaluateRowOptions {
|
|
13
|
-
table:
|
|
13
|
+
table: SourceTableRef;
|
|
14
14
|
row: SqliteRow;
|
|
15
15
|
serializedBucketParameters: (params: QueryParameters) => string[];
|
|
16
16
|
}
|
|
@@ -62,8 +62,8 @@ export declare class BaseSqlDataQuery {
|
|
|
62
62
|
private readonly tools;
|
|
63
63
|
readonly errors: SqlRuleError[];
|
|
64
64
|
constructor(options: BaseSqlDataQueryOptions);
|
|
65
|
-
applies(table:
|
|
66
|
-
addSpecialParameters(table:
|
|
65
|
+
applies(table: SourceTableRef): boolean;
|
|
66
|
+
addSpecialParameters(table: SourceTableRef, row: SqliteRow): SqliteRow;
|
|
67
67
|
getOutputName(sourceTable: string): string;
|
|
68
68
|
isUnaliasedWildcard(): boolean;
|
|
69
69
|
columnOutputNames(): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseSqlDataQuery.js","sourceRoot":"","sources":["../src/BaseSqlDataQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAgBvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwB3C,MAAM,OAAO,gBAAgB;IAC3B;;OAEG;IACM,WAAW,CAAe;IAEnC;;;;OAIG;IACM,KAAK,CAAiB;IAE/B;;OAEG;IACM,GAAG,CAAS;IAErB;;OAEG;IACM,OAAO,CAAmB;IAEnC;;;;OAIG;IACM,UAAU,CAAsB;IAEzC;;;;;OAKG;IACM,gBAAgB,CAAW;IACpC;;OAEG;IACc,KAAK,CAAW;IAExB,MAAM,CAAiB;IAEhC,YAAY,OAAgC;QAC1C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CA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AI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;oBACrC,OAAO,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBACvC,CAAC;qBAAM,CAAC;oBACN,2BAA2B;oBAC3B,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;YACD,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;gBACpB,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;oBACrC,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;gBAClC,CAAC;qBAAM,CAAC;oBACN,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;SACF,CAAC;QACF,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACtC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF"}
|
package/dist/BucketSource.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { PendingQueriers } from './BucketParameterQuerier.js';
|
|
2
2
|
import { ColumnDefinition } from './ExpressionType.js';
|
|
3
|
-
import { HydrationState,
|
|
4
|
-
import {
|
|
3
|
+
import { HydrationState, ParameterLookupDefinitionId } from './HydrationState.js';
|
|
4
|
+
import { SourceTableRef } from './SourceTableRef.js';
|
|
5
5
|
import { GetQuerierOptions } from './SqlSyncRules.js';
|
|
6
|
+
import { ScalarExpressionEngine } from './sync_plan/engine/scalar_expression_engine.js';
|
|
7
|
+
import { SQLite } from './sync_plan/engine/sqlite.js';
|
|
6
8
|
import { TablePattern } from './TablePattern.js';
|
|
7
9
|
import { EvaluatedParametersResult, EvaluateRowOptions, EvaluationResult, SourceSchema, SqliteRow, UnscopedEvaluatedParametersResult, UnscopedEvaluationResult } from './types.js';
|
|
8
10
|
export interface CreateSourceParams {
|
|
9
11
|
hydrationState: HydrationState;
|
|
10
12
|
}
|
|
13
|
+
export interface HydrateSyncConfigParams extends CreateSourceParams {
|
|
14
|
+
/**
|
|
15
|
+
* The SQLite engine to use to evaluate scalar expressions in Sync Streams.
|
|
16
|
+
*/
|
|
17
|
+
sqlite: SQLite | null;
|
|
18
|
+
}
|
|
19
|
+
export interface HydrationInput extends CreateSourceParams {
|
|
20
|
+
scalarExpressions: ScalarExpressionEngine;
|
|
21
|
+
}
|
|
11
22
|
/**
|
|
12
23
|
* A BucketSource is a _logical_ bucket or sync stream definition. It is primarily used to group together
|
|
13
24
|
* related BucketDataSource, BucketParameterLookupSource and BucketParameterQuerierSource definitions,
|
|
@@ -35,7 +46,7 @@ export interface BucketSource {
|
|
|
35
46
|
*/
|
|
36
47
|
readonly parameterIndexLookupCreators: ParameterIndexLookupCreator[];
|
|
37
48
|
debugRepresentation(): any;
|
|
38
|
-
hydrate(params:
|
|
49
|
+
hydrate(params: HydrationInput): HydratedBucketSource;
|
|
39
50
|
}
|
|
40
51
|
/**
|
|
41
52
|
* Internal interface for individual queriers. This is not used on its in the public API directly, apart
|
|
@@ -54,7 +65,7 @@ export interface HydratedBucketSource extends BucketParameterQuerierSource {
|
|
|
54
65
|
readonly definition: BucketSource;
|
|
55
66
|
}
|
|
56
67
|
export type ScopedEvaluateRow = (options: EvaluateRowOptions) => EvaluationResult[];
|
|
57
|
-
export type ScopedEvaluateParameterRow = (sourceTable:
|
|
68
|
+
export type ScopedEvaluateParameterRow = (sourceTable: SourceTableRef, row: SqliteRow) => EvaluatedParametersResult[];
|
|
58
69
|
/**
|
|
59
70
|
* Encodes a static definition of a bucket source, as parsed from sync rules or stream definitions.
|
|
60
71
|
*
|
|
@@ -73,12 +84,8 @@ export interface BucketDataSource {
|
|
|
73
84
|
*/
|
|
74
85
|
readonly bucketParameters: string[];
|
|
75
86
|
getSourceTables(): Set<TablePattern>;
|
|
76
|
-
tableSyncsData(table:
|
|
77
|
-
|
|
78
|
-
* Given a row as it appears in a table that affects sync data, return buckets, logical table names and transformed
|
|
79
|
-
* data for rows to add to buckets.
|
|
80
|
-
*/
|
|
81
|
-
evaluateRow(options: EvaluateRowOptions): UnscopedEvaluationResult[];
|
|
87
|
+
tableSyncsData(table: SourceTableRef): boolean;
|
|
88
|
+
createEvaluator(input: HydrationInput): BucketDataEvaluator;
|
|
82
89
|
/**
|
|
83
90
|
* Given a static schema, infer all logical tables and associated columns that appear in buckets defined by this
|
|
84
91
|
* source.
|
|
@@ -90,6 +97,13 @@ export interface BucketDataSource {
|
|
|
90
97
|
query: string;
|
|
91
98
|
}[]>): void;
|
|
92
99
|
}
|
|
100
|
+
export interface BucketDataEvaluator {
|
|
101
|
+
/**
|
|
102
|
+
* Given a row as it appears in a table that affects sync data, return buckets, logical table names and transformed
|
|
103
|
+
* data for rows to add to buckets.
|
|
104
|
+
*/
|
|
105
|
+
evaluateRow(options: EvaluateRowOptions): UnscopedEvaluationResult[];
|
|
106
|
+
}
|
|
93
107
|
/**
|
|
94
108
|
* This defines how to extract parameter index lookup values from parameter queries or stream subqueries.
|
|
95
109
|
*
|
|
@@ -99,10 +113,16 @@ export interface ParameterIndexLookupCreator {
|
|
|
99
113
|
/**
|
|
100
114
|
* lookupName + queryId is used to uniquely identify parameter queries for parameter storage.
|
|
101
115
|
*
|
|
102
|
-
*
|
|
116
|
+
* The values here specifically identify the definition uniquely within a single SyncConfig.
|
|
117
|
+
* It does not guarantee uniqueness across different SyncConfigs.
|
|
103
118
|
*/
|
|
104
|
-
readonly
|
|
119
|
+
readonly sourceId: ParameterLookupDefinitionId;
|
|
105
120
|
getSourceTables(): Set<TablePattern>;
|
|
121
|
+
/** Whether the table possibly affects the buckets resolved by this source. */
|
|
122
|
+
tableSyncsParameters(table: SourceTableRef): boolean;
|
|
123
|
+
createEvaluator(input: HydrationInput): ParameterIndexLookupEvaluator;
|
|
124
|
+
}
|
|
125
|
+
export interface ParameterIndexLookupEvaluator {
|
|
106
126
|
/**
|
|
107
127
|
* Given a row in a source table that affects sync parameters, returns a structure to index which buckets rows should
|
|
108
128
|
* be associated with.
|
|
@@ -110,13 +130,7 @@ export interface ParameterIndexLookupCreator {
|
|
|
110
130
|
* The returned {@link UnscopedParameterLookup} can be referenced by {@link pushBucketParameterQueriers} to allow the storage
|
|
111
131
|
* system to find buckets.
|
|
112
132
|
*/
|
|
113
|
-
evaluateParameterRow(sourceTable:
|
|
114
|
-
/** Whether the table possibly affects the buckets resolved by this source. */
|
|
115
|
-
tableSyncsParameters(table: SourceTableInterface): boolean;
|
|
116
|
-
}
|
|
117
|
-
export interface DebugMergedSource extends HydratedBucketSource {
|
|
118
|
-
evaluateRow: ScopedEvaluateRow;
|
|
119
|
-
evaluateParameterRow: ScopedEvaluateParameterRow;
|
|
133
|
+
evaluateParameterRow(sourceTable: SourceTableRef, row: SqliteRow): UnscopedEvaluatedParametersResult[];
|
|
120
134
|
}
|
|
121
135
|
export declare enum BucketSourceType {
|
|
122
136
|
SYNC_RULE = 0,
|
|
@@ -126,16 +140,9 @@ export type ResultSetDescription = {
|
|
|
126
140
|
name: string;
|
|
127
141
|
columns: ColumnDefinition[];
|
|
128
142
|
};
|
|
129
|
-
export declare function
|
|
130
|
-
export declare function hydrateEvaluateParameterRow(hydrationState: HydrationState, source: ParameterIndexLookupCreator): ScopedEvaluateParameterRow;
|
|
131
|
-
export declare function mergeDataSources(hydrationState: HydrationState, sources: BucketDataSource[]): {
|
|
143
|
+
export declare function mergeDataSources(input: HydrationInput, sources: BucketDataSource[]): {
|
|
132
144
|
evaluateRow: ScopedEvaluateRow;
|
|
133
145
|
};
|
|
134
|
-
export declare function mergeParameterIndexLookupCreators(
|
|
146
|
+
export declare function mergeParameterIndexLookupCreators(input: HydrationInput, sources: ParameterIndexLookupCreator[]): {
|
|
135
147
|
evaluateParameterRow: ScopedEvaluateParameterRow;
|
|
136
148
|
};
|
|
137
|
-
/**
|
|
138
|
-
* For production purposes, we typically need to operate on the different sources separately. However, for debugging,
|
|
139
|
-
* it is useful to have a single merged source that can evaluate everything.
|
|
140
|
-
*/
|
|
141
|
-
export declare function debugHydratedMergedSource(bucketSource: BucketSource, params?: CreateSourceParams): DebugMergedSource;
|
package/dist/BucketSource.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ScopedParameterLookup } from './BucketParameterQuerier.js';
|
|
2
|
-
import { DEFAULT_HYDRATION_STATE } from './HydrationState.js';
|
|
3
2
|
import { isEvaluationError } from './types.js';
|
|
4
3
|
import { withBucketSource } from './utils.js';
|
|
5
4
|
export var BucketSourceType;
|
|
@@ -7,10 +6,11 @@ export var BucketSourceType;
|
|
|
7
6
|
BucketSourceType[BucketSourceType["SYNC_RULE"] = 0] = "SYNC_RULE";
|
|
8
7
|
BucketSourceType[BucketSourceType["SYNC_STREAM"] = 1] = "SYNC_STREAM";
|
|
9
8
|
})(BucketSourceType || (BucketSourceType = {}));
|
|
10
|
-
|
|
11
|
-
const
|
|
9
|
+
function hydrateEvaluateRow(input, source) {
|
|
10
|
+
const evaluator = source.createEvaluator(input);
|
|
11
|
+
const scope = input.hydrationState.getBucketSourceScope(source);
|
|
12
12
|
return (options) => {
|
|
13
|
-
return
|
|
13
|
+
return evaluator.evaluateRow(options).map((result) => {
|
|
14
14
|
if (isEvaluationError(result)) {
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
@@ -24,10 +24,11 @@ export function hydrateEvaluateRow(hydrationState, source) {
|
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
const
|
|
27
|
+
function hydrateEvaluateParameterRow(input, source) {
|
|
28
|
+
const evaluator = source.createEvaluator(input);
|
|
29
|
+
const scope = input.hydrationState.getParameterIndexLookupScope(source);
|
|
29
30
|
return (sourceTable, row) => {
|
|
30
|
-
return
|
|
31
|
+
return evaluator.evaluateParameterRow(sourceTable, row).map((result) => {
|
|
31
32
|
if (isEvaluationError(result)) {
|
|
32
33
|
return result;
|
|
33
34
|
}
|
|
@@ -38,37 +39,20 @@ export function hydrateEvaluateParameterRow(hydrationState, source) {
|
|
|
38
39
|
});
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
export function mergeDataSources(
|
|
42
|
-
const withScope = sources.map((source) => hydrateEvaluateRow(
|
|
42
|
+
export function mergeDataSources(input, sources) {
|
|
43
|
+
const withScope = sources.map((source) => hydrateEvaluateRow(input, source));
|
|
43
44
|
return {
|
|
44
45
|
evaluateRow(options) {
|
|
45
46
|
return withScope.flatMap((source) => source(options));
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
export function mergeParameterIndexLookupCreators(
|
|
50
|
-
const withScope = sources.map((source) => hydrateEvaluateParameterRow(
|
|
50
|
+
export function mergeParameterIndexLookupCreators(input, sources) {
|
|
51
|
+
const withScope = sources.map((source) => hydrateEvaluateParameterRow(input, source));
|
|
51
52
|
return {
|
|
52
53
|
evaluateParameterRow(sourceTable, row) {
|
|
53
54
|
return withScope.flatMap((source) => source(sourceTable, row));
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
/**
|
|
58
|
-
* For production purposes, we typically need to operate on the different sources separately. However, for debugging,
|
|
59
|
-
* it is useful to have a single merged source that can evaluate everything.
|
|
60
|
-
*/
|
|
61
|
-
export function debugHydratedMergedSource(bucketSource, params) {
|
|
62
|
-
const hydrationState = params?.hydrationState ?? DEFAULT_HYDRATION_STATE;
|
|
63
|
-
const resolvedParams = { hydrationState };
|
|
64
|
-
const dataSource = mergeDataSources(hydrationState, bucketSource.dataSources);
|
|
65
|
-
const parameterLookupSource = mergeParameterIndexLookupCreators(hydrationState, bucketSource.parameterIndexLookupCreators);
|
|
66
|
-
const hydratedBucketSource = bucketSource.hydrate(resolvedParams);
|
|
67
|
-
return {
|
|
68
|
-
definition: bucketSource,
|
|
69
|
-
evaluateParameterRow: parameterLookupSource.evaluateParameterRow.bind(parameterLookupSource),
|
|
70
|
-
evaluateRow: dataSource.evaluateRow.bind(dataSource),
|
|
71
|
-
pushBucketParameterQueriers: hydratedBucketSource.pushBucketParameterQueriers.bind(hydratedBucketSource)
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
58
|
//# sourceMappingURL=BucketSource.js.map
|
package/dist/BucketSource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BucketSource.js","sourceRoot":"","sources":["../src/BucketSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"BucketSource.js","sourceRoot":"","sources":["../src/BucketSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAML,iBAAiB,EAKlB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoJ9C,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iEAAS,CAAA;IACT,qEAAW,CAAA;AACb,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAID,SAAS,kBAAkB,CAAC,KAAqB,EAAE,MAAwB;IACzE,MAAM,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAChE,OAAO,CAAC,OAA2B,EAAsB,EAAE;QACzD,OAAO,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACnD,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9B,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,SAAS,GAAiB,gBAAgB,CAC9C;gBACE,MAAM,EAAE,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,0BAA0B;gBAC9D,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,KAAK,EAAE,MAAM,CAAC,KAAK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CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,2BAA2B,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IACtF,OAAO;QACL,oBAAoB,CAAC,WAA2B,EAAE,GAAc;YAC9D,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BucketDataSource } from './BucketSource.js';
|
|
2
|
+
import { BucketSource, CompatibilityContext, EvaluatedParameters, EvaluatedRow, EvaluationError, GetBucketParameterQuerierResult, GetQuerierOptions, HydrateSyncConfigParams, ParameterIndexLookupCreator, SqlEventDescriptor, SqliteInputValue, SqliteValue, SyncConfig, TablePattern } from './index.js';
|
|
3
|
+
import { SourceTableRef } from './SourceTableRef.js';
|
|
4
|
+
import { EvaluateRowOptions, SqliteRow } from './types.js';
|
|
5
|
+
export interface MatchingSources {
|
|
6
|
+
bucketDataSources: BucketDataSource[];
|
|
7
|
+
parameterLookupSources: ParameterIndexLookupCreator[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* HydratedSyncConfig is sync config definitions along with persisted state.
|
|
11
|
+
*
|
|
12
|
+
* This may be a single SyncConfig, or multiple SyncConfigs merged together.
|
|
13
|
+
* In the case of multiple SyncConfigs, they must share the same CompatibilityContext,
|
|
14
|
+
* but can have different bucket sources.
|
|
15
|
+
*
|
|
16
|
+
* The persisted state specifically affects bucket names, as well as V3+ storage structure.
|
|
17
|
+
*/
|
|
18
|
+
export declare class HydratedSyncConfig {
|
|
19
|
+
#private;
|
|
20
|
+
/**
|
|
21
|
+
* These are used by queriers, and do not support merging across multiple SyncConfigs.
|
|
22
|
+
*/
|
|
23
|
+
private bucketSources;
|
|
24
|
+
eventDescriptors: SqlEventDescriptor[];
|
|
25
|
+
/**
|
|
26
|
+
* Only a single compatibility context is supported across all merged SyncConfigs.
|
|
27
|
+
*/
|
|
28
|
+
compatibility: CompatibilityContext;
|
|
29
|
+
/**
|
|
30
|
+
* The source definitions.
|
|
31
|
+
*
|
|
32
|
+
* For most functionality, we don't use these directly, but rather use the
|
|
33
|
+
* merged definitions such as bucketDataSources.
|
|
34
|
+
*/
|
|
35
|
+
private readonly sourceDefinitions;
|
|
36
|
+
/**
|
|
37
|
+
* Bucket data sources from underlying SyncConfig definitions.
|
|
38
|
+
*/
|
|
39
|
+
readonly bucketDataSources: BucketDataSource[];
|
|
40
|
+
readonly bucketParameterLookupSources: ParameterIndexLookupCreator[];
|
|
41
|
+
private readonly innerEvaluateRow;
|
|
42
|
+
private readonly innerEvaluateParameterRow;
|
|
43
|
+
private readonly hydrationInput;
|
|
44
|
+
private readonly matchingSourcesCache;
|
|
45
|
+
private mergedEvaluatorCache;
|
|
46
|
+
private mergedParameterIndexCreatorCache;
|
|
47
|
+
constructor(params: {
|
|
48
|
+
definitions: SyncConfig[];
|
|
49
|
+
createParams: HydrateSyncConfigParams;
|
|
50
|
+
});
|
|
51
|
+
get bucketSourceDefinitions(): BucketSource[];
|
|
52
|
+
getSourceTables(): TablePattern[];
|
|
53
|
+
tableTriggersEvent(table: SourceTableRef): boolean;
|
|
54
|
+
tableSyncsData(table: SourceTableRef): boolean;
|
|
55
|
+
tableSyncsParameters(table: SourceTableRef): boolean;
|
|
56
|
+
getMatchingSources(source: SourceTableRef): MatchingSources;
|
|
57
|
+
applyRowContext<MaybeToast extends undefined = never>(source: SqliteRow<SqliteInputValue | MaybeToast>): SqliteRow<SqliteValue | MaybeToast>;
|
|
58
|
+
/**
|
|
59
|
+
* Throws errors.
|
|
60
|
+
*/
|
|
61
|
+
evaluateRow(options: EvaluateRowOptions): EvaluatedRow[];
|
|
62
|
+
evaluateRowWithErrors(options: EvaluateRowOptions): {
|
|
63
|
+
results: EvaluatedRow[];
|
|
64
|
+
errors: EvaluationError[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Throws errors.
|
|
68
|
+
*/
|
|
69
|
+
evaluateParameterRow(table: SourceTableRef, row: SqliteRow, options?: {
|
|
70
|
+
parameterLookupSources?: ParameterIndexLookupCreator[];
|
|
71
|
+
}): EvaluatedParameters[];
|
|
72
|
+
evaluateParameterRowWithErrors(table: SourceTableRef, row: SqliteRow, options?: {
|
|
73
|
+
parameterLookupSources?: ParameterIndexLookupCreator[];
|
|
74
|
+
}): {
|
|
75
|
+
results: EvaluatedParameters[];
|
|
76
|
+
errors: EvaluationError[];
|
|
77
|
+
};
|
|
78
|
+
getBucketParameterQuerier(options: GetQuerierOptions): GetBucketParameterQuerierResult;
|
|
79
|
+
private assertSingleSourceDefinition;
|
|
80
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { CompatibilityContext, isEvaluatedParameters, isEvaluatedRow, isEvaluationError, mergeBucketParameterQueriers, mergeDataSources, mergeParameterIndexLookupCreators, parameterLookupScopeKey } from './index.js';
|
|
2
|
+
import { sourceTableRefKey } from './SourceTableRef.js';
|
|
3
|
+
import { createScalarExpressionEngine } from './sync_plan/engine/factory.js';
|
|
4
|
+
import { applyRowContext, uniqueBy } from './utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* HydratedSyncConfig is sync config definitions along with persisted state.
|
|
7
|
+
*
|
|
8
|
+
* This may be a single SyncConfig, or multiple SyncConfigs merged together.
|
|
9
|
+
* In the case of multiple SyncConfigs, they must share the same CompatibilityContext,
|
|
10
|
+
* but can have different bucket sources.
|
|
11
|
+
*
|
|
12
|
+
* The persisted state specifically affects bucket names, as well as V3+ storage structure.
|
|
13
|
+
*/
|
|
14
|
+
export class HydratedSyncConfig {
|
|
15
|
+
/**
|
|
16
|
+
* These are used by queriers, and do not support merging across multiple SyncConfigs.
|
|
17
|
+
*/
|
|
18
|
+
bucketSources = [];
|
|
19
|
+
eventDescriptors = [];
|
|
20
|
+
/**
|
|
21
|
+
* Only a single compatibility context is supported across all merged SyncConfigs.
|
|
22
|
+
*/
|
|
23
|
+
compatibility = CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY;
|
|
24
|
+
/**
|
|
25
|
+
* The source definitions.
|
|
26
|
+
*
|
|
27
|
+
* For most functionality, we don't use these directly, but rather use the
|
|
28
|
+
* merged definitions such as bucketDataSources.
|
|
29
|
+
*/
|
|
30
|
+
sourceDefinitions;
|
|
31
|
+
/**
|
|
32
|
+
* Bucket data sources from underlying SyncConfig definitions.
|
|
33
|
+
*/
|
|
34
|
+
bucketDataSources;
|
|
35
|
+
bucketParameterLookupSources;
|
|
36
|
+
/**
|
|
37
|
+
* These are used by queriers, and do not support merging across multiple SyncConfigs.
|
|
38
|
+
*/
|
|
39
|
+
#bucketSourceDefinitions;
|
|
40
|
+
innerEvaluateRow;
|
|
41
|
+
innerEvaluateParameterRow;
|
|
42
|
+
hydrationInput;
|
|
43
|
+
matchingSourcesCache = new Map();
|
|
44
|
+
mergedEvaluatorCache = new WeakMap();
|
|
45
|
+
mergedParameterIndexCreatorCache = new WeakMap();
|
|
46
|
+
constructor(params) {
|
|
47
|
+
const hydrationState = params.createParams.hydrationState;
|
|
48
|
+
const definitions = params.definitions;
|
|
49
|
+
if (definitions.length == 0) {
|
|
50
|
+
throw new Error('HydratedSyncRules requires at least one SyncConfig definition');
|
|
51
|
+
}
|
|
52
|
+
this.sourceDefinitions = [...definitions];
|
|
53
|
+
this.compatibility = assertSharedCompatibility(this.sourceDefinitions);
|
|
54
|
+
this.hydrationInput = {
|
|
55
|
+
hydrationState,
|
|
56
|
+
scalarExpressions: createScalarExpressionEngine(this.compatibility, params.createParams.sqlite)
|
|
57
|
+
};
|
|
58
|
+
this.bucketDataSources = uniqueBy(definitions.flatMap((definition) => definition.bucketDataSources), (source) => hydrationState.getBucketSourceScope(source).bucketPrefix);
|
|
59
|
+
this.bucketParameterLookupSources = uniqueBy(definitions.flatMap((definition) => definition.bucketParameterLookupSources), (source) => parameterLookupScopeKey(hydrationState.getParameterIndexLookupScope(source)));
|
|
60
|
+
this.innerEvaluateRow = mergeDataSources(this.hydrationInput, this.bucketDataSources).evaluateRow;
|
|
61
|
+
this.innerEvaluateParameterRow = mergeParameterIndexLookupCreators(this.hydrationInput, this.bucketParameterLookupSources).evaluateParameterRow;
|
|
62
|
+
this.eventDescriptors = definitions.flatMap((definition) => definition.eventDescriptors);
|
|
63
|
+
if (definitions.length == 1) {
|
|
64
|
+
this.#bucketSourceDefinitions = definitions[0].bucketSources;
|
|
65
|
+
this.bucketSources = this.#bucketSourceDefinitions.map((source) => source.hydrate(this.hydrationInput));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// We do not support merging bucket sources across multiple definitions - these are always used with one
|
|
69
|
+
// SyncConfig at a time.
|
|
70
|
+
this.#bucketSourceDefinitions = [];
|
|
71
|
+
this.bucketSources = [];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
get bucketSourceDefinitions() {
|
|
75
|
+
this.assertSingleSourceDefinition('bucketSourceDefinitions');
|
|
76
|
+
return this.#bucketSourceDefinitions;
|
|
77
|
+
}
|
|
78
|
+
// These methods do not depend on hydration, so we can multiplex them across definitions.
|
|
79
|
+
getSourceTables() {
|
|
80
|
+
const sourceTables = new Map();
|
|
81
|
+
for (const definition of this.sourceDefinitions) {
|
|
82
|
+
definition.writeSourceTables(sourceTables);
|
|
83
|
+
}
|
|
84
|
+
return [...sourceTables.values()];
|
|
85
|
+
}
|
|
86
|
+
tableTriggersEvent(table) {
|
|
87
|
+
return this.sourceDefinitions.some((definition) => definition.tableTriggersEvent(table));
|
|
88
|
+
}
|
|
89
|
+
tableSyncsData(table) {
|
|
90
|
+
return this.sourceDefinitions.some((definition) => definition.tableSyncsData(table));
|
|
91
|
+
}
|
|
92
|
+
tableSyncsParameters(table) {
|
|
93
|
+
return this.sourceDefinitions.some((definition) => definition.tableSyncsParameters(table));
|
|
94
|
+
}
|
|
95
|
+
getMatchingSources(source) {
|
|
96
|
+
const table = {
|
|
97
|
+
connectionTag: source.connectionTag,
|
|
98
|
+
schema: source.schema,
|
|
99
|
+
name: source.name
|
|
100
|
+
};
|
|
101
|
+
const key = sourceTableRefKey(table);
|
|
102
|
+
const cached = this.matchingSourcesCache.get(key);
|
|
103
|
+
if (cached != null) {
|
|
104
|
+
return cached;
|
|
105
|
+
}
|
|
106
|
+
const matchingSources = {
|
|
107
|
+
bucketDataSources: this.bucketDataSources.filter((source) => source.tableSyncsData(table)),
|
|
108
|
+
parameterLookupSources: this.bucketParameterLookupSources.filter((source) => source.tableSyncsParameters(table))
|
|
109
|
+
};
|
|
110
|
+
this.matchingSourcesCache.set(key, matchingSources);
|
|
111
|
+
return matchingSources;
|
|
112
|
+
}
|
|
113
|
+
applyRowContext(source) {
|
|
114
|
+
return applyRowContext(source, this.compatibility);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Throws errors.
|
|
118
|
+
*/
|
|
119
|
+
evaluateRow(options) {
|
|
120
|
+
const { results, errors } = this.evaluateRowWithErrors(options);
|
|
121
|
+
if (errors.length > 0) {
|
|
122
|
+
throw new Error(errors[0].error);
|
|
123
|
+
}
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
126
|
+
evaluateRowWithErrors(options) {
|
|
127
|
+
let rawResults;
|
|
128
|
+
if (options.bucketDataSources != null) {
|
|
129
|
+
// This array is generally expected to be stable, so makes for a good cache key.
|
|
130
|
+
// It is not a strict requirement to use stable arrays, but it can help for performance.
|
|
131
|
+
let merged = this.mergedEvaluatorCache.get(options.bucketDataSources);
|
|
132
|
+
if (merged == null) {
|
|
133
|
+
merged = mergeDataSources(this.hydrationInput, options.bucketDataSources);
|
|
134
|
+
this.mergedEvaluatorCache.set(options.bucketDataSources, merged);
|
|
135
|
+
}
|
|
136
|
+
rawResults = merged.evaluateRow(options);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
rawResults = this.innerEvaluateRow(options);
|
|
140
|
+
}
|
|
141
|
+
const results = rawResults.filter(isEvaluatedRow);
|
|
142
|
+
const errors = rawResults.filter(isEvaluationError);
|
|
143
|
+
return { results, errors };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Throws errors.
|
|
147
|
+
*/
|
|
148
|
+
evaluateParameterRow(table, row, options) {
|
|
149
|
+
const { results, errors } = this.evaluateParameterRowWithErrors(table, row, options);
|
|
150
|
+
if (errors.length > 0) {
|
|
151
|
+
throw new Error(errors[0].error);
|
|
152
|
+
}
|
|
153
|
+
return results;
|
|
154
|
+
}
|
|
155
|
+
evaluateParameterRowWithErrors(table, row, options) {
|
|
156
|
+
let rawResults;
|
|
157
|
+
if (options?.parameterLookupSources != null) {
|
|
158
|
+
// This array is generally expected to be stable, so makes for a good cache key.
|
|
159
|
+
// It is not a strict requirement to use stable arrays, but it can help for performance.
|
|
160
|
+
let merged = this.mergedParameterIndexCreatorCache.get(options.parameterLookupSources);
|
|
161
|
+
if (merged == null) {
|
|
162
|
+
merged = mergeParameterIndexLookupCreators(this.hydrationInput, options.parameterLookupSources);
|
|
163
|
+
this.mergedParameterIndexCreatorCache.set(options.parameterLookupSources, merged);
|
|
164
|
+
}
|
|
165
|
+
rawResults = merged.evaluateParameterRow(table, row);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
rawResults = this.innerEvaluateParameterRow(table, row);
|
|
169
|
+
}
|
|
170
|
+
const results = rawResults.filter(isEvaluatedParameters);
|
|
171
|
+
const errors = rawResults.filter(isEvaluationError);
|
|
172
|
+
return { results, errors };
|
|
173
|
+
}
|
|
174
|
+
getBucketParameterQuerier(options) {
|
|
175
|
+
this.assertSingleSourceDefinition('getBucketParameterQuerier()');
|
|
176
|
+
const queriers = [];
|
|
177
|
+
const errors = [];
|
|
178
|
+
const pending = { queriers, errors };
|
|
179
|
+
for (const source of this.bucketSources) {
|
|
180
|
+
if ((source.definition.subscribedToByDefault && options.hasDefaultStreams) ||
|
|
181
|
+
source.definition.name in options.streams) {
|
|
182
|
+
source.pushBucketParameterQueriers(pending, options);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const querier = mergeBucketParameterQueriers(queriers);
|
|
186
|
+
return { querier, errors };
|
|
187
|
+
}
|
|
188
|
+
assertSingleSourceDefinition(debugName) {
|
|
189
|
+
// We may split the types in the future to enforce this on a type level instead of runtime level
|
|
190
|
+
if (this.sourceDefinitions.length != 1) {
|
|
191
|
+
throw new Error(`${debugName} is not supported for HydratedSyncRules with multiple SyncConfigs`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function assertSharedCompatibility(definitions) {
|
|
196
|
+
const compatibility = definitions[0].compatibility;
|
|
197
|
+
if (definitions.length == 1) {
|
|
198
|
+
return compatibility;
|
|
199
|
+
}
|
|
200
|
+
for (const definition of definitions) {
|
|
201
|
+
if (!definition.compatibility.equals(compatibility)) {
|
|
202
|
+
throw new Error('All SyncConfigs in a HydratedSyncRules instance must use the same CompatibilityContext');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return compatibility;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=HydratedSyncConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HydratedSyncConfig.js","sourceRoot":"","sources":["../src/HydratedSyncConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,oBAAoB,EAQpB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,4BAA4B,EAC5B,gBAAgB,EAChB,iCAAiC,EAEjC,uBAAuB,EASxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAkB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOvD;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;OAEG;IACK,aAAa,GAA2B,EAAE,CAAC;IAEnD,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;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,14 @@
|
|
|
1
1
|
import { BucketDataSource, ParameterIndexLookupCreator } from './BucketSource.js';
|
|
2
|
+
export type BucketDefinitionId = string;
|
|
3
|
+
export type ParameterIndexId = string;
|
|
2
4
|
export interface BucketDataScope {
|
|
3
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* The prefix is the bucket name before the parameters.
|
|
7
|
+
*
|
|
8
|
+
* This also functions as an unique and stable key identifying the bucket source within a single replication stream.
|
|
9
|
+
*
|
|
10
|
+
* It may have duplicates over different streams, depending on storage requirements.
|
|
11
|
+
*/
|
|
4
12
|
bucketPrefix: string;
|
|
5
13
|
/** Source used to generate buckets. */
|
|
6
14
|
source: BucketDataSource;
|
|
@@ -10,12 +18,19 @@ export interface ParameterLookupScope {
|
|
|
10
18
|
* The lookup name + queryid is used to reference the parameter lookup record.
|
|
11
19
|
*
|
|
12
20
|
* In newer storage versions, lookupName = indexId, and queryId = ''.
|
|
21
|
+
*
|
|
22
|
+
* Together, these also function as an unique and stable key identifying the parameter lookup source within a single replication stream.
|
|
23
|
+
* They are not guaranteed to be unique across different streams, depending on storage requirements.
|
|
13
24
|
*/
|
|
14
25
|
lookupName: string;
|
|
15
26
|
queryId: string;
|
|
16
27
|
/** Source used to generate parameter lookups. */
|
|
17
28
|
source: ParameterIndexLookupCreator;
|
|
18
29
|
}
|
|
30
|
+
export interface ParameterLookupDefinitionId {
|
|
31
|
+
lookupName: string;
|
|
32
|
+
queryId: string;
|
|
33
|
+
}
|
|
19
34
|
/**
|
|
20
35
|
* Hydration state information for a source.
|
|
21
36
|
*
|
|
@@ -49,5 +64,9 @@ export declare const DEFAULT_HYDRATION_STATE: HydrationState;
|
|
|
49
64
|
*
|
|
50
65
|
* Note that this transformation has not been present in older versions of the sync service. To preserve backwards
|
|
51
66
|
* compatibility, sync config will not use this without an opt-in.
|
|
67
|
+
*
|
|
68
|
+
* This hydration state does not ensure uniqueness of keys across different sync configs, so it cannot be used
|
|
69
|
+
* for incremental reprocessing / multiple sync configs per replication stream.
|
|
52
70
|
*/
|
|
53
71
|
export declare function versionedHydrationState(version: number): HydrationState;
|
|
72
|
+
export declare function parameterLookupScopeKey(scope: ParameterLookupDefinitionId): ParameterIndexId;
|
package/dist/HydrationState.js
CHANGED
|
@@ -11,7 +11,10 @@ export const DEFAULT_HYDRATION_STATE = {
|
|
|
11
11
|
};
|
|
12
12
|
},
|
|
13
13
|
getParameterIndexLookupScope(source) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...source.sourceId,
|
|
16
|
+
source
|
|
17
|
+
};
|
|
15
18
|
}
|
|
16
19
|
};
|
|
17
20
|
/**
|
|
@@ -25,6 +28,9 @@ export const DEFAULT_HYDRATION_STATE = {
|
|
|
25
28
|
*
|
|
26
29
|
* Note that this transformation has not been present in older versions of the sync service. To preserve backwards
|
|
27
30
|
* compatibility, sync config will not use this without an opt-in.
|
|
31
|
+
*
|
|
32
|
+
* This hydration state does not ensure uniqueness of keys across different sync configs, so it cannot be used
|
|
33
|
+
* for incremental reprocessing / multiple sync configs per replication stream.
|
|
28
34
|
*/
|
|
29
35
|
export function versionedHydrationState(version) {
|
|
30
36
|
return {
|
|
@@ -36,8 +42,14 @@ export function versionedHydrationState(version) {
|
|
|
36
42
|
},
|
|
37
43
|
getParameterIndexLookupScope(source) {
|
|
38
44
|
// No transformations applied here
|
|
39
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
...source.sourceId,
|
|
47
|
+
source
|
|
48
|
+
};
|
|
40
49
|
}
|
|
41
50
|
};
|
|
42
51
|
}
|
|
52
|
+
export function parameterLookupScopeKey(scope) {
|
|
53
|
+
return JSON.stringify([scope.lookupName, scope.queryId]);
|
|
54
|
+
}
|
|
43
55
|
//# sourceMappingURL=HydrationState.js.map
|