@powersync/service-sync-rules 0.17.10 → 0.18.1
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/README.md +126 -0
- package/dist/ExpressionType.d.ts +1 -0
- package/dist/ExpressionType.js +3 -0
- package/dist/ExpressionType.js.map +1 -1
- package/dist/SqlBucketDescriptor.d.ts +3 -3
- package/dist/SqlBucketDescriptor.js +2 -2
- package/dist/SqlBucketDescriptor.js.map +1 -1
- package/dist/SqlDataQuery.js +28 -7
- package/dist/SqlDataQuery.js.map +1 -1
- package/dist/SqlParameterQuery.d.ts +54 -12
- package/dist/SqlParameterQuery.js +106 -33
- package/dist/SqlParameterQuery.js.map +1 -1
- package/dist/SqlSyncRules.d.ts +2 -2
- package/dist/SqlSyncRules.js +21 -4
- package/dist/SqlSyncRules.js.map +1 -1
- package/dist/StaticSqlParameterQuery.d.ts +9 -6
- package/dist/StaticSqlParameterQuery.js +42 -12
- package/dist/StaticSqlParameterQuery.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/json_schema.js +4 -0
- package/dist/json_schema.js.map +1 -1
- package/dist/request_functions.d.ts +19 -0
- package/dist/request_functions.js +47 -0
- package/dist/request_functions.js.map +1 -0
- package/dist/sql_filters.d.ts +38 -4
- package/dist/sql_filters.js +270 -177
- package/dist/sql_filters.js.map +1 -1
- package/dist/sql_functions.d.ts +30 -19
- package/dist/sql_functions.js +113 -17
- package/dist/sql_functions.js.map +1 -1
- package/dist/sql_support.d.ts +6 -3
- package/dist/sql_support.js +72 -35
- package/dist/sql_support.js.map +1 -1
- package/dist/types.d.ts +100 -12
- package/dist/types.js +18 -0
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +1 -2
- package/dist/utils.js +0 -6
- package/dist/utils.js.map +1 -1
- package/package.json +6 -3
package/dist/sql_support.js
CHANGED
|
@@ -3,14 +3,17 @@ import { evaluateOperator, getOperatorReturnType } from './sql_functions.js';
|
|
|
3
3
|
import { SqlRuleError } from './errors.js';
|
|
4
4
|
import { ExpressionType } from './ExpressionType.js';
|
|
5
5
|
export function isParameterMatchClause(clause) {
|
|
6
|
-
return Array.isArray(clause.
|
|
6
|
+
return Array.isArray(clause.inputParameters);
|
|
7
7
|
}
|
|
8
|
-
export function
|
|
8
|
+
export function isRowValueClause(clause) {
|
|
9
9
|
return typeof clause.evaluate == 'function';
|
|
10
10
|
}
|
|
11
|
+
export function isStaticValueClause(clause) {
|
|
12
|
+
return isRowValueClause(clause) && typeof clause.value != 'undefined';
|
|
13
|
+
}
|
|
11
14
|
export function isParameterValueClause(clause) {
|
|
12
15
|
// noinspection SuspiciousTypeOfGuard
|
|
13
|
-
return typeof clause.
|
|
16
|
+
return typeof clause.key == 'string';
|
|
14
17
|
}
|
|
15
18
|
export function isClauseError(clause) {
|
|
16
19
|
return clause.error === true;
|
|
@@ -51,8 +54,19 @@ export function compileStaticOperator(op, left, right) {
|
|
|
51
54
|
}
|
|
52
55
|
};
|
|
53
56
|
}
|
|
57
|
+
export function getOperatorFunction(op) {
|
|
58
|
+
return {
|
|
59
|
+
debugName: `operator${op}`,
|
|
60
|
+
call(...args) {
|
|
61
|
+
return evaluateOperator(op, args[0], args[1]);
|
|
62
|
+
},
|
|
63
|
+
getReturnType(args) {
|
|
64
|
+
return getOperatorReturnType(op, args[0], args[1]);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
54
68
|
export function andFilters(a, b) {
|
|
55
|
-
if (
|
|
69
|
+
if (isRowValueClause(a) && isRowValueClause(b)) {
|
|
56
70
|
// Optimization
|
|
57
71
|
return {
|
|
58
72
|
evaluate(tables) {
|
|
@@ -67,20 +81,20 @@ export function andFilters(a, b) {
|
|
|
67
81
|
}
|
|
68
82
|
const aFilter = toBooleanParameterSetClause(a);
|
|
69
83
|
const bFilter = toBooleanParameterSetClause(b);
|
|
70
|
-
const aParams = aFilter.
|
|
71
|
-
const bParams = bFilter.
|
|
84
|
+
const aParams = aFilter.inputParameters;
|
|
85
|
+
const bParams = bFilter.inputParameters;
|
|
72
86
|
if (aFilter.unbounded && bFilter.unbounded) {
|
|
73
87
|
// This could explode the number of buckets for the row
|
|
74
88
|
throw new Error('Cannot have multiple IN expressions on bucket parameters');
|
|
75
89
|
}
|
|
76
|
-
const
|
|
90
|
+
const combinedMap = new Map([...aParams, ...bParams].map((p) => [p.key, p]));
|
|
77
91
|
return {
|
|
78
92
|
error: aFilter.error || bFilter.error,
|
|
79
|
-
|
|
93
|
+
inputParameters: [...combinedMap.values()],
|
|
80
94
|
unbounded: aFilter.unbounded || bFilter.unbounded,
|
|
81
|
-
|
|
82
|
-
const aResult = aFilter.
|
|
83
|
-
const bResult = bFilter.
|
|
95
|
+
filterRow: (tables) => {
|
|
96
|
+
const aResult = aFilter.filterRow(tables);
|
|
97
|
+
const bResult = bFilter.filterRow(tables);
|
|
84
98
|
let results = [];
|
|
85
99
|
for (let result1 of aResult) {
|
|
86
100
|
for (let result2 of bResult) {
|
|
@@ -97,11 +111,13 @@ export function andFilters(a, b) {
|
|
|
97
111
|
}
|
|
98
112
|
}
|
|
99
113
|
return results;
|
|
100
|
-
}
|
|
114
|
+
},
|
|
115
|
+
usesAuthenticatedRequestParameters: aFilter.usesAuthenticatedRequestParameters || bFilter.usesAuthenticatedRequestParameters,
|
|
116
|
+
usesUnauthenticatedRequestParameters: aFilter.usesUnauthenticatedRequestParameters || bFilter.usesUnauthenticatedRequestParameters
|
|
101
117
|
};
|
|
102
118
|
}
|
|
103
119
|
export function orFilters(a, b) {
|
|
104
|
-
if (
|
|
120
|
+
if (isRowValueClause(a) && isRowValueClause(b)) {
|
|
105
121
|
// Optimization
|
|
106
122
|
return {
|
|
107
123
|
evaluate(tables) {
|
|
@@ -119,27 +135,31 @@ export function orFilters(a, b) {
|
|
|
119
135
|
return orParameterSetClauses(aFilter, bFilter);
|
|
120
136
|
}
|
|
121
137
|
export function orParameterSetClauses(a, b) {
|
|
122
|
-
const aParams = a.
|
|
123
|
-
const bParams = b.
|
|
138
|
+
const aParams = a.inputParameters;
|
|
139
|
+
const bParams = b.inputParameters;
|
|
124
140
|
// This gives the guaranteed set of parameters matched against.
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
141
|
+
const combinedMap = new Map([...aParams, ...bParams].map((p) => [p.key, p]));
|
|
142
|
+
if (combinedMap.size != aParams.length || combinedMap.size != bParams.length) {
|
|
127
143
|
throw new Error(`Left and right sides of OR must use the same parameters, or split into separate queries. ${JSON.stringify(aParams)} != ${JSON.stringify(bParams)}`);
|
|
128
144
|
}
|
|
129
|
-
const parameters = [...
|
|
145
|
+
const parameters = [...combinedMap.values()];
|
|
130
146
|
// assets.region_id = bucket.region_id AND bucket.user_id IN assets.user_ids
|
|
131
147
|
// OR bucket.region_id IN assets.region_ids AND bucket.user_id = assets.user_id
|
|
132
148
|
const unbounded = a.unbounded || b.unbounded;
|
|
133
149
|
return {
|
|
134
150
|
error: a.error || b.error,
|
|
135
|
-
|
|
151
|
+
inputParameters: parameters,
|
|
136
152
|
unbounded,
|
|
137
|
-
|
|
138
|
-
const aResult = a.
|
|
139
|
-
const bResult = b.
|
|
153
|
+
filterRow: (tables) => {
|
|
154
|
+
const aResult = a.filterRow(tables);
|
|
155
|
+
const bResult = b.filterRow(tables);
|
|
140
156
|
let results = [...aResult, ...bResult];
|
|
141
157
|
return results;
|
|
142
|
-
}
|
|
158
|
+
},
|
|
159
|
+
// Pessimistic check
|
|
160
|
+
usesAuthenticatedRequestParameters: a.usesAuthenticatedRequestParameters && b.usesAuthenticatedRequestParameters,
|
|
161
|
+
// Optimistic check
|
|
162
|
+
usesUnauthenticatedRequestParameters: a.usesUnauthenticatedRequestParameters || b.usesUnauthenticatedRequestParameters
|
|
143
163
|
};
|
|
144
164
|
}
|
|
145
165
|
/**
|
|
@@ -151,37 +171,54 @@ export function toBooleanParameterSetClause(clause) {
|
|
|
151
171
|
if (isParameterMatchClause(clause)) {
|
|
152
172
|
return clause;
|
|
153
173
|
}
|
|
154
|
-
else if (
|
|
174
|
+
else if (isRowValueClause(clause)) {
|
|
155
175
|
return {
|
|
156
176
|
error: false,
|
|
157
|
-
|
|
177
|
+
inputParameters: [],
|
|
158
178
|
unbounded: false,
|
|
159
|
-
|
|
179
|
+
filterRow(tables) {
|
|
160
180
|
const value = sqliteBool(clause.evaluate(tables));
|
|
161
181
|
return value ? MATCH_CONST_TRUE : MATCH_CONST_FALSE;
|
|
162
|
-
}
|
|
182
|
+
},
|
|
183
|
+
usesAuthenticatedRequestParameters: false,
|
|
184
|
+
usesUnauthenticatedRequestParameters: false
|
|
163
185
|
};
|
|
164
186
|
}
|
|
165
187
|
else if (isClauseError(clause)) {
|
|
166
188
|
return {
|
|
167
189
|
error: true,
|
|
168
|
-
|
|
190
|
+
inputParameters: [],
|
|
169
191
|
unbounded: false,
|
|
170
|
-
|
|
192
|
+
filterRow(tables) {
|
|
171
193
|
throw new Error('invalid clause');
|
|
172
|
-
}
|
|
194
|
+
},
|
|
195
|
+
usesAuthenticatedRequestParameters: false,
|
|
196
|
+
usesUnauthenticatedRequestParameters: false
|
|
173
197
|
};
|
|
174
198
|
}
|
|
175
199
|
else {
|
|
176
200
|
// Equivalent to `bucket.param = true`
|
|
177
|
-
const
|
|
201
|
+
const key = clause.key;
|
|
202
|
+
const inputParam = {
|
|
203
|
+
key: key,
|
|
204
|
+
expands: false,
|
|
205
|
+
filteredRowToLookupValue: (filterParameters) => {
|
|
206
|
+
return filterParameters[key];
|
|
207
|
+
},
|
|
208
|
+
parametersToLookupValue: (parameters) => {
|
|
209
|
+
const inner = clause.lookupParameterValue(parameters);
|
|
210
|
+
return sqliteBool(inner);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
178
213
|
return {
|
|
179
214
|
error: false,
|
|
180
|
-
|
|
215
|
+
inputParameters: [inputParam],
|
|
181
216
|
unbounded: false,
|
|
182
|
-
|
|
183
|
-
return [{ [
|
|
184
|
-
}
|
|
217
|
+
filterRow(tables) {
|
|
218
|
+
return [{ [key]: SQLITE_TRUE }];
|
|
219
|
+
},
|
|
220
|
+
usesAuthenticatedRequestParameters: clause.usesAuthenticatedRequestParameters,
|
|
221
|
+
usesUnauthenticatedRequestParameters: clause.usesUnauthenticatedRequestParameters
|
|
185
222
|
};
|
|
186
223
|
}
|
|
187
224
|
}
|
package/dist/sql_support.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_support.js","sourceRoot":"","sources":["../src/sql_support.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql_support.js","sourceRoot":"","sources":["../src/sql_support.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAe,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IAC3D,OAAO,KAAK,CAAC,OAAO,CAAE,MAA+B,CAAC,eAAe,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAsB;IACrD,OAAO,OAAQ,MAAyB,CAAC,QAAQ,IAAI,UAAU,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACxD,OAAO,gBAAgB,CAAC,MAAM,CAAC,IAAI,OAAQ,MAA4B,CAAC,KAAK,IAAI,WAAW,CAAC;AAC/F,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IAC3D,qCAAqC;IACrC,OAAO,OAAQ,MAA+B,CAAC,GAAG,IAAI,QAAQ,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAsB;IAClD,OAAQ,MAAsB,CAAC,KAAK,KAAK,IAAI,CAAC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AC,IAAI,YAAY,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC,CAAC;KACjE;IAED,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE;QACjB,MAAM,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,6BAA6B,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;KACpF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export interface SyncRules {
|
|
|
6
6
|
evaluateRow(options: EvaluateRowOptions): EvaluationResult[];
|
|
7
7
|
evaluateParameterRow(table: SourceTableInterface, row: SqliteRow): EvaluatedParametersResult[];
|
|
8
8
|
}
|
|
9
|
+
export interface QueryParseOptions {
|
|
10
|
+
accept_potentially_dangerous_queries?: boolean;
|
|
11
|
+
}
|
|
9
12
|
export interface EvaluatedParameters {
|
|
10
13
|
lookup: SqliteJsonValue[];
|
|
11
14
|
/**
|
|
@@ -36,9 +39,26 @@ export declare function isEvaluationError(e: any): e is EvaluationError;
|
|
|
36
39
|
export declare function isEvaluatedRow(e: EvaluationResult): e is EvaluatedRow;
|
|
37
40
|
export declare function isEvaluatedParameters(e: EvaluatedParametersResult): e is EvaluatedParameters;
|
|
38
41
|
export type EvaluationResult = EvaluatedRow | EvaluationError;
|
|
39
|
-
export interface
|
|
42
|
+
export interface RequestJwtPayload {
|
|
43
|
+
/**
|
|
44
|
+
* user_id
|
|
45
|
+
*/
|
|
46
|
+
sub: string;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
export declare class RequestParameters {
|
|
40
50
|
token_parameters: SqliteJsonRow;
|
|
41
51
|
user_parameters: SqliteJsonRow;
|
|
52
|
+
/**
|
|
53
|
+
* JSON string of raw request parameters.
|
|
54
|
+
*/
|
|
55
|
+
raw_user_parameters: string;
|
|
56
|
+
/**
|
|
57
|
+
* JSON string of raw request parameters.
|
|
58
|
+
*/
|
|
59
|
+
raw_token_payload: string;
|
|
60
|
+
user_id: string;
|
|
61
|
+
constructor(tokenPayload: RequestJwtPayload, clientParameters: Record<string, any>);
|
|
42
62
|
}
|
|
43
63
|
/**
|
|
44
64
|
* A value that is both SQLite and JSON-compatible.
|
|
@@ -96,16 +116,52 @@ export type QueryParameters = {
|
|
|
96
116
|
* A single set of parameters that would make a WHERE filter true.
|
|
97
117
|
*
|
|
98
118
|
* Each parameter is prefixed with a table name, e.g. 'bucket.param'.
|
|
119
|
+
*
|
|
120
|
+
* Data queries: this is converted into a bucket id, given named bucket parameters.
|
|
121
|
+
*
|
|
122
|
+
* Parameter queries: this is converted into a lookup array.
|
|
99
123
|
*/
|
|
100
124
|
export type FilterParameters = {
|
|
101
125
|
[parameter: string]: SqliteJsonValue;
|
|
102
126
|
};
|
|
127
|
+
export interface InputParameter {
|
|
128
|
+
/**
|
|
129
|
+
* An unique identifier per parameter in a query.
|
|
130
|
+
*
|
|
131
|
+
* This is used to identify the same parameters used in a query multiple times.
|
|
132
|
+
*
|
|
133
|
+
* The value itself does not necessarily have any specific meaning.
|
|
134
|
+
*/
|
|
135
|
+
key: string;
|
|
136
|
+
/**
|
|
137
|
+
* True if the parameter expands to an array. This means parametersToLookupValue() can
|
|
138
|
+
* return a JSON array. This is different from `unbounded` on the clause.
|
|
139
|
+
*/
|
|
140
|
+
expands: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Given FilterParameters from a data row, return the associated value.
|
|
143
|
+
*
|
|
144
|
+
* Only relevant for parameter queries.
|
|
145
|
+
*/
|
|
146
|
+
filteredRowToLookupValue(filterParameters: FilterParameters): SqliteJsonValue;
|
|
147
|
+
/**
|
|
148
|
+
* Given RequestParameters, return the associated value to lookup.
|
|
149
|
+
*
|
|
150
|
+
* Only relevant for parameter queries.
|
|
151
|
+
*/
|
|
152
|
+
parametersToLookupValue(parameters: RequestParameters): SqliteValue;
|
|
153
|
+
}
|
|
103
154
|
export interface EvaluateRowOptions {
|
|
104
155
|
sourceTable: SourceTableInterface;
|
|
105
156
|
record: SqliteRow;
|
|
106
157
|
}
|
|
107
158
|
/**
|
|
108
|
-
*
|
|
159
|
+
* This is a clause that matches row and parameter values.
|
|
160
|
+
*
|
|
161
|
+
* Example:
|
|
162
|
+
* [WHERE] users.org_id = bucket.org_id
|
|
163
|
+
*
|
|
164
|
+
* For a given a row, this produces a set of parameters that would make the clause evaluate to true.
|
|
109
165
|
*/
|
|
110
166
|
export interface ParameterMatchClause {
|
|
111
167
|
error: boolean;
|
|
@@ -116,9 +172,10 @@ export interface ParameterMatchClause {
|
|
|
116
172
|
*
|
|
117
173
|
* These parameters are always matched by this clause, and no additional parameters are matched.
|
|
118
174
|
*/
|
|
119
|
-
|
|
175
|
+
inputParameters: InputParameter[];
|
|
120
176
|
/**
|
|
121
|
-
* True if the filter depends on an unbounded array column.
|
|
177
|
+
* True if the filter depends on an unbounded array column. This means filterRow can return
|
|
178
|
+
* multiple items.
|
|
122
179
|
*
|
|
123
180
|
* We restrict filters to only allow a single unbounded column for bucket parameters, otherwise the number of
|
|
124
181
|
* bucketParameter combinations could grow too much.
|
|
@@ -127,42 +184,73 @@ export interface ParameterMatchClause {
|
|
|
127
184
|
/**
|
|
128
185
|
* Given a data row, give a set of filter parameters that would make the filter be true.
|
|
129
186
|
*
|
|
187
|
+
* For StaticSqlParameterQuery, the tables are token_parameters and user_parameters.
|
|
188
|
+
* For others, it is the table of the data or parameter query.
|
|
189
|
+
*
|
|
130
190
|
* @param tables - {table => row}
|
|
131
191
|
* @return The filter parameters
|
|
132
192
|
*/
|
|
133
|
-
|
|
193
|
+
filterRow(tables: QueryParameters): TrueIfParametersMatch;
|
|
194
|
+
/** request.user_id(), request.jwt(), token_parameters.* */
|
|
195
|
+
usesAuthenticatedRequestParameters: boolean;
|
|
196
|
+
/** request.parameters(), user_parameters.* */
|
|
197
|
+
usesUnauthenticatedRequestParameters: boolean;
|
|
134
198
|
}
|
|
135
199
|
/**
|
|
136
|
-
*
|
|
200
|
+
* This is a clause that operates on request or bucket parameters.
|
|
137
201
|
*/
|
|
138
202
|
export interface ParameterValueClause {
|
|
203
|
+
/** request.user_id(), request.jwt(), token_parameters.* */
|
|
204
|
+
usesAuthenticatedRequestParameters: boolean;
|
|
205
|
+
/** request.parameters(), user_parameters.* */
|
|
206
|
+
usesUnauthenticatedRequestParameters: boolean;
|
|
139
207
|
/**
|
|
140
|
-
*
|
|
208
|
+
* An unique key for the clause.
|
|
209
|
+
*
|
|
210
|
+
* For bucket parameters, this is `bucket.${name}`.
|
|
211
|
+
* For expressions, the exact format is undefined.
|
|
141
212
|
*/
|
|
142
|
-
|
|
213
|
+
key: string;
|
|
214
|
+
/**
|
|
215
|
+
* Given RequestParameters, return the associated value to lookup.
|
|
216
|
+
*
|
|
217
|
+
* Only relevant for parameter queries.
|
|
218
|
+
*/
|
|
219
|
+
lookupParameterValue(parameters: RequestParameters): SqliteValue;
|
|
143
220
|
}
|
|
144
221
|
export interface QuerySchema {
|
|
145
222
|
getType(table: string, column: string): ExpressionType;
|
|
146
223
|
getColumns(table: string): ColumnDefinition[];
|
|
147
224
|
}
|
|
148
225
|
/**
|
|
149
|
-
*
|
|
226
|
+
* A clause that uses row values as input.
|
|
227
|
+
*
|
|
228
|
+
* For parameter queries, that is the parameter table being queried.
|
|
229
|
+
* For data queries, that is the data table being queried.
|
|
150
230
|
*/
|
|
151
|
-
export interface
|
|
231
|
+
export interface RowValueClause {
|
|
152
232
|
evaluate(tables: QueryParameters): SqliteValue;
|
|
153
233
|
getType(schema: QuerySchema): ExpressionType;
|
|
154
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Completely static value.
|
|
237
|
+
*
|
|
238
|
+
* Extends RowValueClause and ParameterValueClause to simplify code in some places.
|
|
239
|
+
*/
|
|
240
|
+
export interface StaticValueClause extends RowValueClause, ParameterValueClause {
|
|
241
|
+
readonly value: SqliteValue;
|
|
242
|
+
}
|
|
155
243
|
export interface ClauseError {
|
|
156
244
|
error: true;
|
|
157
245
|
}
|
|
158
|
-
export type CompiledClause =
|
|
246
|
+
export type CompiledClause = RowValueClause | ParameterMatchClause | ParameterValueClause | ClauseError;
|
|
159
247
|
/**
|
|
160
248
|
* true if any of the filter parameter sets match
|
|
161
249
|
*/
|
|
162
250
|
export type TrueIfParametersMatch = FilterParameters[];
|
|
163
251
|
export interface QueryBucketIdOptions {
|
|
164
252
|
getParameterSets: (lookups: SqliteJsonValue[][]) => Promise<SqliteJsonRow[]>;
|
|
165
|
-
parameters:
|
|
253
|
+
parameters: RequestParameters;
|
|
166
254
|
}
|
|
167
255
|
export interface SourceSchemaTable {
|
|
168
256
|
table: string;
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { JSONBig } from '@powersync/service-jsonbig';
|
|
2
|
+
import { toSyncRulesParameters } from './utils.js';
|
|
1
3
|
export function isEvaluationError(e) {
|
|
2
4
|
return typeof e.error == 'string';
|
|
3
5
|
}
|
|
@@ -7,4 +9,20 @@ export function isEvaluatedRow(e) {
|
|
|
7
9
|
export function isEvaluatedParameters(e) {
|
|
8
10
|
return Array.isArray(e.lookup);
|
|
9
11
|
}
|
|
12
|
+
export class RequestParameters {
|
|
13
|
+
constructor(tokenPayload, clientParameters) {
|
|
14
|
+
// This type is verified when we verify the token
|
|
15
|
+
const legacyParameters = tokenPayload.parameters;
|
|
16
|
+
const token_parameters = {
|
|
17
|
+
...legacyParameters,
|
|
18
|
+
// sub takes presedence over any embedded parameters
|
|
19
|
+
user_id: tokenPayload.sub
|
|
20
|
+
};
|
|
21
|
+
this.token_parameters = toSyncRulesParameters(token_parameters);
|
|
22
|
+
this.user_id = tokenPayload.sub;
|
|
23
|
+
this.raw_token_payload = JSONBig.stringify(tokenPayload);
|
|
24
|
+
this.raw_user_parameters = JSONBig.stringify(clientParameters);
|
|
25
|
+
this.user_parameters = toSyncRulesParameters(clientParameters);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
10
28
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAC;AAIpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA+CnD,MAAM,UAAU,iBAAiB,CAAC,CAAM;IACtC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAmB;IAChD,OAAO,OAAQ,CAAkB,CAAC,MAAM,IAAI,QAAQ,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,CAA4B;IAChE,OAAO,KAAK,CAAC,OAAO,CAAE,CAAS,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC;AAaD,MAAM,OAAO,iBAAiB;IAgB5B,YAAY,YAA+B,EAAE,gBAAqC;QAChF,iDAAiD;QACjD,MAAM,gBAAgB,GAAG,YAAY,CAAC,UAA6C,CAAC;QAEpF,MAAM,gBAAgB,GAAG;YACvB,GAAG,gBAAgB;YACnB,oDAAoD;YACpD,OAAO,EAAE,YAAY,CAAC,GAAG;SAC1B,CAAC;QAEF,IAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAEzD,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAC/D,IAAI,CAAC,eAAe,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACjE,CAAC;CACF"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Statement, SelectFromStatement } from 'pgsql-ast-parser';
|
|
2
|
-
import { DatabaseInputRow, SqliteRow, SqliteJsonRow, SqliteJsonValue, SqliteValue
|
|
2
|
+
import { DatabaseInputRow, SqliteRow, SqliteJsonRow, SqliteJsonValue, SqliteValue } from './types.js';
|
|
3
3
|
import { Replacer } from '@powersync/service-jsonbig';
|
|
4
4
|
export declare function isSelectStatement(q: Statement): q is SelectFromStatement;
|
|
5
5
|
export declare function getBucketId(descriptor_id: string, bucket_parameters: string[], params: Record<string, SqliteJsonValue>): string;
|
|
@@ -34,7 +34,6 @@ export declare function toSyncRulesParameters(parameters: Record<string, any>):
|
|
|
34
34
|
* Any object or array is converted to JSON TEXT.
|
|
35
35
|
*/
|
|
36
36
|
export declare function toSyncRulesValue(data: any, autoBigNum?: boolean, keepUndefined?: boolean): SqliteValue;
|
|
37
|
-
export declare function normalizeTokenParameters(token_parameters: Record<string, any>, user_parameters?: Record<string, any>): SyncParameters;
|
|
38
37
|
/**
|
|
39
38
|
* Only use this for serializing bucket names. Bucket names should never be parsed except perhaps for debug purposes.
|
|
40
39
|
*
|
package/dist/utils.js
CHANGED
|
@@ -154,12 +154,6 @@ export function toSyncRulesValue(data, autoBigNum, keepUndefined) {
|
|
|
154
154
|
return null;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
export function normalizeTokenParameters(token_parameters, user_parameters) {
|
|
158
|
-
return {
|
|
159
|
-
token_parameters: toSyncRulesParameters(token_parameters),
|
|
160
|
-
user_parameters: toSyncRulesParameters(user_parameters ?? {})
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
157
|
/**
|
|
164
158
|
* Only use this for serializing bucket names. Bucket names should never be parsed except perhaps for debug purposes.
|
|
165
159
|
*
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"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|
@@ -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.18.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "FSL-1.1-Apache-2.0",
|
|
@@ -20,10 +20,13 @@
|
|
|
20
20
|
"@powersync/service-jsonbig": "^0.17.10"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "18.11.11"
|
|
23
|
+
"@types/node": "18.11.11",
|
|
24
|
+
"vitest": "^0.34.6"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"clean": "rm -r ./dist && tsc -b --clean",
|
|
27
|
-
"build": "tsc -b"
|
|
28
|
+
"build": "tsc -b",
|
|
29
|
+
"build:tests": "tsc -b test/tsconfig.json",
|
|
30
|
+
"test": "vitest"
|
|
28
31
|
}
|
|
29
32
|
}
|