@powersync/service-sync-rules 0.29.10 → 0.31.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 +11 -53
- package/dist/SqlSyncRules.js +11 -376
- 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/SyncConfig.d.ts +43 -0
- package/dist/SyncConfig.js +102 -0
- package/dist/SyncConfig.js.map +1 -0
- package/dist/TablePattern.d.ts +22 -4
- package/dist/TablePattern.js +57 -19
- 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 +7 -0
- package/dist/compatibility.js +34 -0
- 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 +110 -0
- package/dist/compiler/compiler.js +130 -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 +66 -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/from_yaml.d.ts +28 -0
- package/dist/from_yaml.js +411 -0
- package/dist/from_yaml.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/json_schema.js +17 -1
- package/dist/json_schema.js.map +1 -1
- package/dist/request_functions.js.map +1 -1
- package/dist/schema-generators/DartSchemaGenerator.d.ts +3 -3
- package/dist/schema-generators/DartSchemaGenerator.js.map +1 -1
- package/dist/schema-generators/DotNetSchemaGenerator.d.ts +2 -2
- package/dist/schema-generators/DotNetSchemaGenerator.js.map +1 -1
- package/dist/schema-generators/JsLegacySchemaGenerator.d.ts +2 -2
- package/dist/schema-generators/JsLegacySchemaGenerator.js.map +1 -1
- package/dist/schema-generators/KotlinSchemaGenerator.d.ts +2 -2
- package/dist/schema-generators/KotlinSchemaGenerator.js.map +1 -1
- package/dist/schema-generators/RoomSchemaGenerator.d.ts +2 -2
- package/dist/schema-generators/RoomSchemaGenerator.js.map +1 -1
- package/dist/schema-generators/SchemaGenerator.d.ts +8 -3
- package/dist/schema-generators/SchemaGenerator.js +21 -14
- package/dist/schema-generators/SchemaGenerator.js.map +1 -1
- package/dist/schema-generators/SqlSchemaGenerator.d.ts +2 -2
- package/dist/schema-generators/SqlSchemaGenerator.js.map +1 -1
- package/dist/schema-generators/SwiftSchemaGenerator.d.ts +2 -2
- package/dist/schema-generators/SwiftSchemaGenerator.js.map +1 -1
- package/dist/schema-generators/TsSchemaGenerator.d.ts +2 -2
- package/dist/schema-generators/TsSchemaGenerator.js.map +1 -1
- package/dist/sql_functions.d.ts +4 -3
- 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 +24 -0
- package/dist/sync_plan/evaluator/bucket_data_source.js +139 -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 +17 -0
- package/dist/sync_plan/evaluator/index.js +32 -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 +20 -0
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.js +64 -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 +16 -0
- package/dist/sync_plan/schema_inference.js +123 -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 +214 -0
- package/dist/sync_plan/serialize.js.map +1 -0
- package/dist/types/custom_sqlite_value.d.ts +1 -1
- package/dist/types.d.ts +72 -29
- package/dist/types.js +30 -5
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +10 -3
- package/dist/utils.js +26 -3
- package/dist/utils.js.map +1 -1
- package/package.json +4 -3
- package/schema/sync_rules.json +19 -3
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { JsonContainer } from '@powersync/service-jsonbig';
|
|
2
|
+
import { BucketPriority } from './BucketDescription.js';
|
|
3
|
+
import { ScopedParameterLookup, UnscopedParameterLookup } from './BucketParameterQuerier.js';
|
|
4
|
+
import { CompatibilityContext } from './compatibility.js';
|
|
2
5
|
import { ColumnDefinition } from './ExpressionType.js';
|
|
6
|
+
import { RequestFunctionCall } from './request_functions.js';
|
|
3
7
|
import { SourceTableInterface } from './SourceTableInterface.js';
|
|
4
8
|
import { SyncRulesOptions } from './SqlSyncRules.js';
|
|
5
9
|
import { TablePattern } from './TablePattern.js';
|
|
6
|
-
import { BucketPriority } from './BucketDescription.js';
|
|
7
|
-
import { ParameterLookup } from './BucketParameterQuerier.js';
|
|
8
10
|
import { CustomSqliteValue } from './types/custom_sqlite_value.js';
|
|
9
|
-
import { CompatibilityContext } from './compatibility.js';
|
|
10
|
-
import { RequestFunctionCall } from './request_functions.js';
|
|
11
|
-
export interface SyncRules {
|
|
12
|
-
evaluateRow(options: EvaluateRowOptions): EvaluationResult[];
|
|
13
|
-
evaluateParameterRow(table: SourceTableInterface, row: SqliteRow): EvaluatedParametersResult[];
|
|
14
|
-
}
|
|
15
11
|
export interface QueryParseOptions extends SyncRulesOptions {
|
|
16
12
|
accept_potentially_dangerous_queries?: boolean;
|
|
17
13
|
priority?: BucketPriority;
|
|
@@ -21,7 +17,16 @@ export interface StreamParseOptions extends QueryParseOptions {
|
|
|
21
17
|
auto_subscribe?: boolean;
|
|
22
18
|
}
|
|
23
19
|
export interface EvaluatedParameters {
|
|
24
|
-
lookup:
|
|
20
|
+
lookup: ScopedParameterLookup;
|
|
21
|
+
/**
|
|
22
|
+
* Parameters used to generate bucket id. May be incomplete.
|
|
23
|
+
*
|
|
24
|
+
* JSON-serializable.
|
|
25
|
+
*/
|
|
26
|
+
bucketParameters: Record<string, SqliteJsonValue>[];
|
|
27
|
+
}
|
|
28
|
+
export interface UnscopedEvaluatedParameters {
|
|
29
|
+
lookup: UnscopedParameterLookup;
|
|
25
30
|
/**
|
|
26
31
|
* Parameters used to generate bucket id. May be incomplete.
|
|
27
32
|
*
|
|
@@ -30,6 +35,7 @@ export interface EvaluatedParameters {
|
|
|
30
35
|
bucketParameters: Record<string, SqliteJsonValue>[];
|
|
31
36
|
}
|
|
32
37
|
export type EvaluatedParametersResult = EvaluatedParameters | EvaluationError;
|
|
38
|
+
export type UnscopedEvaluatedParametersResult = UnscopedEvaluatedParameters | EvaluationError;
|
|
33
39
|
export interface EvaluatedRow {
|
|
34
40
|
bucket: string;
|
|
35
41
|
/** Output table - may be different from input table. */
|
|
@@ -41,19 +47,62 @@ export interface EvaluatedRow {
|
|
|
41
47
|
/** Must be JSON-serializable. */
|
|
42
48
|
data: SqliteJsonRow;
|
|
43
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Bucket data as evaluated by the BucketDataSource.
|
|
52
|
+
*
|
|
53
|
+
* The bucket name must still be resolved, external to this.
|
|
54
|
+
*/
|
|
55
|
+
export interface UnscopedEvaluatedRow {
|
|
56
|
+
/**
|
|
57
|
+
* Serialized evaluated parameters used to generate the bucket id. Serialized as a JSON array.
|
|
58
|
+
*
|
|
59
|
+
* Examples:
|
|
60
|
+
* [] // no bucket parameters
|
|
61
|
+
* [1] // single numeric parameter
|
|
62
|
+
* [1,"foo"] // multiple parameters
|
|
63
|
+
*
|
|
64
|
+
* The bucket name is derived by using concetenating these parameters with the generated bucket name.
|
|
65
|
+
*/
|
|
66
|
+
serializedBucketParameters: string;
|
|
67
|
+
/** Output table - may be different from input table. */
|
|
68
|
+
table: string;
|
|
69
|
+
/**
|
|
70
|
+
* Convenience attribute. Must match data.id.
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
/** Must be JSON-serializable. */
|
|
74
|
+
data: SqliteJsonRow;
|
|
75
|
+
}
|
|
44
76
|
export interface EvaluationError {
|
|
45
77
|
error: string;
|
|
46
78
|
}
|
|
47
|
-
export declare function isEvaluationError(e:
|
|
79
|
+
export declare function isEvaluationError(e: EvaluationResult | UnscopedEvaluationResult | EvaluatedParametersResult | UnscopedEvaluatedParametersResult): e is EvaluationError;
|
|
48
80
|
export declare function isEvaluatedRow(e: EvaluationResult): e is EvaluatedRow;
|
|
81
|
+
export declare function isSourceEvaluatedRow(e: UnscopedEvaluationResult): e is UnscopedEvaluatedRow;
|
|
49
82
|
export declare function isEvaluatedParameters(e: EvaluatedParametersResult): e is EvaluatedParameters;
|
|
50
83
|
export type EvaluationResult = EvaluatedRow | EvaluationError;
|
|
84
|
+
export type UnscopedEvaluationResult = UnscopedEvaluatedRow | EvaluationError;
|
|
51
85
|
export interface RequestJwtPayload {
|
|
86
|
+
userIdJson: SqliteJsonValue;
|
|
87
|
+
parsedPayload: Record<string, any>;
|
|
88
|
+
/** Legacy token_parameters */
|
|
89
|
+
parameters?: Record<string, any> | undefined;
|
|
90
|
+
}
|
|
91
|
+
export declare class BaseJwtPayload implements RequestJwtPayload {
|
|
52
92
|
/**
|
|
53
|
-
*
|
|
93
|
+
* Raw payload from JSON.parse.
|
|
94
|
+
*
|
|
95
|
+
* May contain arbitrary nested values.
|
|
54
96
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
97
|
+
readonly parsedPayload: Record<string, any>;
|
|
98
|
+
/**
|
|
99
|
+
* sub, converted to a SQLite-compatible value (number | string | bigint | null).
|
|
100
|
+
*
|
|
101
|
+
* This is the value used for sync rules and in logs.
|
|
102
|
+
*/
|
|
103
|
+
readonly userIdJson: SqliteJsonValue;
|
|
104
|
+
constructor(parsedPayload: Record<string, any>);
|
|
105
|
+
get parameters(): Record<string, any> | undefined;
|
|
57
106
|
}
|
|
58
107
|
export interface ParameterValueSet {
|
|
59
108
|
lookup(table: string, column: string): SqliteValue;
|
|
@@ -73,7 +122,7 @@ export interface ParameterValueSet {
|
|
|
73
122
|
rawTokenPayload: string;
|
|
74
123
|
parsedTokenPayload: SqliteJsonRow;
|
|
75
124
|
legacyTokenParameters: SqliteJsonRow;
|
|
76
|
-
userId:
|
|
125
|
+
userId: SqliteJsonValue;
|
|
77
126
|
}
|
|
78
127
|
export declare class RequestParameters implements ParameterValueSet {
|
|
79
128
|
parsedTokenPayload: SqliteJsonRow;
|
|
@@ -89,7 +138,7 @@ export declare class RequestParameters implements ParameterValueSet {
|
|
|
89
138
|
* JSON string of raw request parameters.
|
|
90
139
|
*/
|
|
91
140
|
rawTokenPayload: string;
|
|
92
|
-
userId:
|
|
141
|
+
userId: SqliteJsonValue;
|
|
93
142
|
constructor(tokenPayload: RequestJwtPayload, clientParameters: Record<string, any>);
|
|
94
143
|
constructor(params: RequestParameters);
|
|
95
144
|
lookup(table: string, column: string): SqliteJsonValue;
|
|
@@ -101,6 +150,14 @@ export declare class RequestParameters implements ParameterValueSet {
|
|
|
101
150
|
* Uint8Array is not supported.
|
|
102
151
|
*/
|
|
103
152
|
export type SqliteJsonValue = number | string | bigint | null;
|
|
153
|
+
/**
|
|
154
|
+
* A value that can be used as a bucket parameter.
|
|
155
|
+
*
|
|
156
|
+
* We don't support binary bucket parameters, so this needs to be a {@link SqliteJsonValue}. Further, bucket parameters
|
|
157
|
+
* are always instantiated through the `=` operator, and `NULL` values in SQLite don't compare via `=`. So, `null`
|
|
158
|
+
* values also aren't allowed as parameters.
|
|
159
|
+
*/
|
|
160
|
+
export type SqliteParameterValue = NonNullable<SqliteJsonValue>;
|
|
104
161
|
/**
|
|
105
162
|
* A value supported by the SQLite type system.
|
|
106
163
|
*/
|
|
@@ -190,21 +247,7 @@ export interface InputParameter {
|
|
|
190
247
|
*/
|
|
191
248
|
parametersToLookupValue(parameters: ParameterValueSet): SqliteValue;
|
|
192
249
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Transforms bucket ids generated when evaluating the row by e.g. encoding version information.
|
|
195
|
-
*
|
|
196
|
-
* Because buckets are recreated on a sync rule redeploy, it makes sense to use different bucket ids (otherwise, clients
|
|
197
|
-
* may run into checksum errors causing a sync to take longer than necessary or breaking progress).
|
|
198
|
-
*
|
|
199
|
-
* So, this transformer receives the original bucket id as generated by defined sync rules, and can prepend a version
|
|
200
|
-
* identifier.
|
|
201
|
-
*
|
|
202
|
-
* Note that this transformation has not been present in older versions of the sync service. To preserve backwards
|
|
203
|
-
* compatibility, sync rules will not use this function without an opt-in.
|
|
204
|
-
*/
|
|
205
|
-
export type BucketIdTransformer = (regularId: string) => string;
|
|
206
250
|
export interface EvaluateRowOptions extends TableRow {
|
|
207
|
-
bucketIdTransformer: BucketIdTransformer;
|
|
208
251
|
}
|
|
209
252
|
/**
|
|
210
253
|
* A row associated with the table it's coming from.
|
package/dist/types.js
CHANGED
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import { JSONBig } from '@powersync/service-jsonbig';
|
|
2
|
-
import { toSyncRulesParameters } from './utils.js';
|
|
3
2
|
import { CompatibilityContext } from './compatibility.js';
|
|
3
|
+
import { jsonValueToSqlite, toSyncRulesParameters } from './utils.js';
|
|
4
4
|
export function isEvaluationError(e) {
|
|
5
5
|
return typeof e.error == 'string';
|
|
6
6
|
}
|
|
7
7
|
export function isEvaluatedRow(e) {
|
|
8
8
|
return typeof e.bucket == 'string';
|
|
9
9
|
}
|
|
10
|
+
export function isSourceEvaluatedRow(e) {
|
|
11
|
+
return typeof e.serializedBucketParameters == 'string';
|
|
12
|
+
}
|
|
10
13
|
export function isEvaluatedParameters(e) {
|
|
11
14
|
return 'lookup' in e;
|
|
12
15
|
}
|
|
16
|
+
export class BaseJwtPayload {
|
|
17
|
+
/**
|
|
18
|
+
* Raw payload from JSON.parse.
|
|
19
|
+
*
|
|
20
|
+
* May contain arbitrary nested values.
|
|
21
|
+
*/
|
|
22
|
+
parsedPayload;
|
|
23
|
+
/**
|
|
24
|
+
* sub, converted to a SQLite-compatible value (number | string | bigint | null).
|
|
25
|
+
*
|
|
26
|
+
* This is the value used for sync rules and in logs.
|
|
27
|
+
*/
|
|
28
|
+
userIdJson;
|
|
29
|
+
constructor(parsedPayload) {
|
|
30
|
+
this.parsedPayload = parsedPayload;
|
|
31
|
+
this.userIdJson = jsonValueToSqlite(true, parsedPayload.sub);
|
|
32
|
+
}
|
|
33
|
+
get parameters() {
|
|
34
|
+
// Verified to be either undefined or an object when parsing the token.
|
|
35
|
+
return this.parsedPayload.parameters;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
13
38
|
export class RequestParameters {
|
|
14
39
|
parsedTokenPayload;
|
|
15
40
|
legacyTokenParameters;
|
|
@@ -42,14 +67,14 @@ export class RequestParameters {
|
|
|
42
67
|
const tokenParameters = {
|
|
43
68
|
...legacyParameters,
|
|
44
69
|
// sub takes presedence over any embedded parameters
|
|
45
|
-
user_id: tokenPayload.
|
|
70
|
+
user_id: tokenPayload.userIdJson
|
|
46
71
|
};
|
|
47
72
|
// Client and token parameters don't contain DateTime values or other custom types, so we don't need to consider
|
|
48
73
|
// compatibility.
|
|
49
|
-
this.parsedTokenPayload = tokenPayload;
|
|
74
|
+
this.parsedTokenPayload = tokenPayload.parsedPayload;
|
|
50
75
|
this.legacyTokenParameters = toSyncRulesParameters(tokenParameters, CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY);
|
|
51
|
-
this.userId = tokenPayload.
|
|
52
|
-
this.rawTokenPayload = JSONBig.stringify(tokenPayload);
|
|
76
|
+
this.userId = tokenPayload.userIdJson;
|
|
77
|
+
this.rawTokenPayload = JSONBig.stringify(tokenPayload.parsedPayload);
|
|
53
78
|
this.rawUserParameters = JSONBig.stringify(clientParameters);
|
|
54
79
|
this.userParameters = toSyncRulesParameters(clientParameters, CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY);
|
|
55
80
|
this.streamParameters = null;
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAO1D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAsFtE,MAAM,UAAU,iBAAiB,CAC/B,CAA8G;IAE9G,OAAO,OAAQ,CAAqB,CAAC,KAAK,IAAI,QAAQ,CAAC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C;QACrC,CAAC;aAAM,IAAI,KAAK,IAAI,yBAAyB,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;YAC/E,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,yBAAyB,CAAC,MAA2B;QACnD,MAAM,KAAK,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC1C,KAAK,CAAC,gBAAgB,GAAG,MAAM,CAAC;QAChC,KAAK,CAAC,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEtD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA6MD,MAAM,UAAU,gCAAgC,CAAC,MAAsB;IACrE,OAAQ,MAAyC,CAAC,KAAK,IAAI,IAAI,CAAC;AAClE,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Replacer } from '@powersync/service-jsonbig';
|
|
2
2
|
import { SelectFromStatement, Statement } from 'pgsql-ast-parser';
|
|
3
3
|
import { CompatibilityContext } from './compatibility.js';
|
|
4
|
-
import {
|
|
4
|
+
import { BucketDataScope } from './HydrationState.js';
|
|
5
|
+
import { DatabaseInputRow, DatabaseInputValue, SqliteInputRow, SqliteInputValue, SqliteJsonRow, SqliteJsonValue, SqliteParameterValue, SqliteRow, SqliteValue } from './types.js';
|
|
5
6
|
export declare function isSelectStatement(q: Statement): q is SelectFromStatement;
|
|
6
|
-
export declare function
|
|
7
|
+
export declare function buildBucketName(scope: BucketDataScope, serializedParameters: string): string;
|
|
8
|
+
export declare function serializeBucketParameters(bucketParameters: string[], params: Record<string, SqliteJsonValue>): string;
|
|
7
9
|
/**
|
|
8
10
|
* SqliteRow -> SqliteJsonRow.
|
|
9
11
|
*
|
|
@@ -17,8 +19,9 @@ export declare function filterJsonRow(data: SqliteRow): SqliteJsonRow;
|
|
|
17
19
|
*
|
|
18
20
|
* Types specifically not supported in output are `boolean` and `undefined`.
|
|
19
21
|
*/
|
|
20
|
-
export declare function jsonValueToSqlite(fixedJsonBehavior: boolean, value: null | undefined | string | number | bigint | boolean | any):
|
|
22
|
+
export declare function jsonValueToSqlite(fixedJsonBehavior: boolean, value: null | undefined | string | number | bigint | boolean | any): SqliteJsonValue;
|
|
21
23
|
export declare function isJsonValue(value: SqliteValue): value is SqliteJsonValue;
|
|
24
|
+
export declare function isValidParameterValue(value: SqliteValue): value is SqliteParameterValue;
|
|
22
25
|
/**
|
|
23
26
|
* Map database row to SqliteRow for use in sync rules.
|
|
24
27
|
*/
|
|
@@ -49,3 +52,7 @@ export declare const JSONBucketNameSerialize: {
|
|
|
49
52
|
* Lookup serialization must be number-agnostic. I.e. normalize numbers, instead of preserving numbers.
|
|
50
53
|
*/
|
|
51
54
|
export declare function normalizeParameterValue(value: SqliteJsonValue): SqliteJsonValue;
|
|
55
|
+
/**
|
|
56
|
+
* Extracts and normalizes the ID column from a row.
|
|
57
|
+
*/
|
|
58
|
+
export declare function idFromData(data: SqliteJsonRow): string;
|
package/dist/utils.js
CHANGED
|
@@ -2,13 +2,17 @@ import { JSONBig, JsonContainer, stringifyRaw } from '@powersync/service-jsonbig
|
|
|
2
2
|
import { SyncRuleProcessingError as SyncRulesProcessingError } from './errors.js';
|
|
3
3
|
import { SQLITE_FALSE, SQLITE_TRUE } from './sql_support.js';
|
|
4
4
|
import { CustomArray, CustomObject, CustomSqliteValue } from './types/custom_sqlite_value.js';
|
|
5
|
+
import { castAsText } from './sql_functions.js';
|
|
5
6
|
export function isSelectStatement(q) {
|
|
6
7
|
return q.type == 'select';
|
|
7
8
|
}
|
|
8
|
-
export function
|
|
9
|
+
export function buildBucketName(scope, serializedParameters) {
|
|
10
|
+
return scope.bucketPrefix + serializedParameters;
|
|
11
|
+
}
|
|
12
|
+
export function serializeBucketParameters(bucketParameters, params) {
|
|
9
13
|
// Important: REAL and INTEGER values matching the same number needs the same representation in the bucket name.
|
|
10
|
-
const paramArray =
|
|
11
|
-
return
|
|
14
|
+
const paramArray = bucketParameters.map((name) => params[`bucket.${name}`]);
|
|
15
|
+
return JSONBucketNameSerialize.stringify(paramArray);
|
|
12
16
|
}
|
|
13
17
|
const DEPTH_LIMIT = 10;
|
|
14
18
|
/**
|
|
@@ -54,6 +58,9 @@ export function jsonValueToSqlite(fixedJsonBehavior, value) {
|
|
|
54
58
|
export function isJsonValue(value) {
|
|
55
59
|
return value == null || typeof value == 'string' || typeof value == 'number' || typeof value == 'bigint';
|
|
56
60
|
}
|
|
61
|
+
export function isValidParameterValue(value) {
|
|
62
|
+
return value != null && isJsonValue(value);
|
|
63
|
+
}
|
|
57
64
|
function filterJsonData(data, context, depth = 0) {
|
|
58
65
|
if (depth > DEPTH_LIMIT) {
|
|
59
66
|
// This is primarily to prevent infinite recursion
|
|
@@ -210,4 +217,20 @@ export function normalizeParameterValue(value) {
|
|
|
210
217
|
}
|
|
211
218
|
return value;
|
|
212
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Extracts and normalizes the ID column from a row.
|
|
222
|
+
*/
|
|
223
|
+
export function idFromData(data) {
|
|
224
|
+
let id = data.id;
|
|
225
|
+
if (typeof id != 'string') {
|
|
226
|
+
// While an explicit cast would be better, this covers against very common
|
|
227
|
+
// issues when initially testing out sync, for example when the id column is an
|
|
228
|
+
// auto-incrementing integer.
|
|
229
|
+
// If there is no id column, we use a blank id. This will result in the user syncing
|
|
230
|
+
// a single arbitrary row for this table - better than just not being able to sync
|
|
231
|
+
// anything.
|
|
232
|
+
id = castAsText(id) ?? '';
|
|
233
|
+
}
|
|
234
|
+
return id;
|
|
235
|
+
}
|
|
213
236
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"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AkF;QAClF,YAAY;QACZ,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/service-sync-rules",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.31.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "FSL-1.1-ALv2",
|
|
@@ -23,12 +23,13 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.16.2",
|
|
26
|
-
"vitest": "^
|
|
26
|
+
"vitest": "^4.0.16"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"clean": "rm -r ./dist && tsc -b --clean",
|
|
30
30
|
"build:tsc": "tsc -b",
|
|
31
|
-
"build": "pnpm build:tsc &&
|
|
31
|
+
"build": "pnpm build:tsc && pnpm run build:extra",
|
|
32
|
+
"build:extra": "node scripts/compile-schema.js",
|
|
32
33
|
"build:tests": "tsc -b test/tsconfig.json",
|
|
33
34
|
"test": "vitest"
|
|
34
35
|
}
|
package/schema/sync_rules.json
CHANGED
|
@@ -74,9 +74,6 @@
|
|
|
74
74
|
"patternProperties": {
|
|
75
75
|
".*": {
|
|
76
76
|
"type": "object",
|
|
77
|
-
"required": [
|
|
78
|
-
"query"
|
|
79
|
-
],
|
|
80
77
|
"examples": [
|
|
81
78
|
{
|
|
82
79
|
"query": [
|
|
@@ -100,6 +97,22 @@
|
|
|
100
97
|
"query": {
|
|
101
98
|
"description": "The SQL query defining content to sync in this stream.",
|
|
102
99
|
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"queries": {
|
|
102
|
+
"description": "SQL queries defining content to sync in this stream.",
|
|
103
|
+
"type": "array",
|
|
104
|
+
"items": {
|
|
105
|
+
"type": "string"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"with": {
|
|
109
|
+
"type": "object",
|
|
110
|
+
"description": "Common table expressions defining subqueries available in queries.",
|
|
111
|
+
"patternProperties": {
|
|
112
|
+
".*": {
|
|
113
|
+
"type": "string"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
103
116
|
}
|
|
104
117
|
}
|
|
105
118
|
}
|
|
@@ -165,6 +178,9 @@
|
|
|
165
178
|
"nanoseconds"
|
|
166
179
|
]
|
|
167
180
|
},
|
|
181
|
+
"sync_config_compiler": {
|
|
182
|
+
"type": "boolean"
|
|
183
|
+
},
|
|
168
184
|
"timestamps_iso8601": {
|
|
169
185
|
"type": "boolean",
|
|
170
186
|
"description": "Enabled by default starting from edition 2: Consistently renders timestamps with an ISO 8601-compatible format (previous versions used a space instead of a T to separate date and time)."
|