@powersync/service-sync-rules 0.30.0 → 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/HydratedSyncRules.d.ts +3 -3
- package/dist/HydratedSyncRules.js.map +1 -1
- package/dist/SqlSyncRules.d.ts +11 -37
- package/dist/SqlSyncRules.js +11 -340
- package/dist/SqlSyncRules.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 +21 -6
- package/dist/TablePattern.js +57 -30
- package/dist/TablePattern.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/compiler.d.ts +7 -1
- package/dist/compiler/compiler.js +19 -2
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/parser.js +3 -3
- package/dist/compiler/parser.js.map +1 -1
- package/dist/compiler/rows.d.ts +2 -2
- package/dist/compiler/table.d.ts +3 -4
- package/dist/compiler/table.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 +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/json_schema.js +17 -1
- package/dist/json_schema.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 +3 -3
- 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 +2 -2
- package/dist/sync_plan/evaluator/bucket_data_source.d.ts +1 -0
- package/dist/sync_plan/evaluator/bucket_data_source.js +5 -3
- package/dist/sync_plan/evaluator/bucket_data_source.js.map +1 -1
- package/dist/sync_plan/evaluator/index.d.ts +12 -2
- package/dist/sync_plan/evaluator/index.js +26 -20
- package/dist/sync_plan/evaluator/index.js.map +1 -1
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.d.ts +2 -1
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.js +6 -4
- package/dist/sync_plan/evaluator/parameter_index_lookup_creator.js.map +1 -1
- package/dist/sync_plan/plan.d.ts +2 -2
- package/dist/sync_plan/schema_inference.d.ts +2 -1
- package/dist/sync_plan/schema_inference.js +4 -2
- package/dist/sync_plan/schema_inference.js.map +1 -1
- package/dist/sync_plan/serialize.d.ts +2 -2
- package/dist/sync_plan/serialize.js +7 -2
- package/dist/sync_plan/serialize.js.map +1 -1
- package/dist/types.d.ts +20 -5
- package/dist/types.js +27 -5
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
- package/schema/sync_rules.json +19 -3
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSONBig } from '@powersync/service-jsonbig';
|
|
2
2
|
import { CompatibilityContext } from './compatibility.js';
|
|
3
|
-
import { toSyncRulesParameters } from './utils.js';
|
|
3
|
+
import { jsonValueToSqlite, toSyncRulesParameters } from './utils.js';
|
|
4
4
|
export function isEvaluationError(e) {
|
|
5
5
|
return typeof e.error == 'string';
|
|
6
6
|
}
|
|
@@ -13,6 +13,28 @@ export function isSourceEvaluatedRow(e) {
|
|
|
13
13
|
export function isEvaluatedParameters(e) {
|
|
14
14
|
return 'lookup' in e;
|
|
15
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
|
+
}
|
|
16
38
|
export class RequestParameters {
|
|
17
39
|
parsedTokenPayload;
|
|
18
40
|
legacyTokenParameters;
|
|
@@ -45,14 +67,14 @@ export class RequestParameters {
|
|
|
45
67
|
const tokenParameters = {
|
|
46
68
|
...legacyParameters,
|
|
47
69
|
// sub takes presedence over any embedded parameters
|
|
48
|
-
user_id: tokenPayload.
|
|
70
|
+
user_id: tokenPayload.userIdJson
|
|
49
71
|
};
|
|
50
72
|
// Client and token parameters don't contain DateTime values or other custom types, so we don't need to consider
|
|
51
73
|
// compatibility.
|
|
52
|
-
this.parsedTokenPayload = tokenPayload;
|
|
74
|
+
this.parsedTokenPayload = tokenPayload.parsedPayload;
|
|
53
75
|
this.legacyTokenParameters = toSyncRulesParameters(tokenParameters, CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY);
|
|
54
|
-
this.userId = tokenPayload.
|
|
55
|
-
this.rawTokenPayload = JSONBig.stringify(tokenPayload);
|
|
76
|
+
this.userId = tokenPayload.userIdJson;
|
|
77
|
+
this.rawTokenPayload = JSONBig.stringify(tokenPayload.parsedPayload);
|
|
56
78
|
this.rawUserParameters = JSONBig.stringify(clientParameters);
|
|
57
79
|
this.userParameters = toSyncRulesParameters(clientParameters, CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY);
|
|
58
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;AAGpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAO1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,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;AACzD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAmB;IAChD,OAAO,OAAQ,CAAkB,CAAC,MAAM,IAAI,QAAQ,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAA2B;IAC9D,OAAO,OAAQ,CAA0B,CAAC,0BAA0B,IAAI,QAAQ,CAAC;AACnF,CAAC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AC7C,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
|
@@ -19,7 +19,7 @@ export declare function filterJsonRow(data: SqliteRow): SqliteJsonRow;
|
|
|
19
19
|
*
|
|
20
20
|
* Types specifically not supported in output are `boolean` and `undefined`.
|
|
21
21
|
*/
|
|
22
|
-
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;
|
|
23
23
|
export declare function isJsonValue(value: SqliteValue): value is SqliteJsonValue;
|
|
24
24
|
export declare function isValidParameterValue(value: SqliteValue): value is SqliteParameterValue;
|
|
25
25
|
/**
|
package/package.json
CHANGED
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)."
|