@dxos/echo-query 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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/lib/browser/index.mjs +159 -3
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +159 -3
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/query-lite/index.d.ts +8765 -0
- package/dist/query-lite/index.d.ts.map +1 -0
- package/dist/query-lite/index.js +356 -376
- package/dist/query-lite/index.js.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/parser/query-builder.d.ts +1 -1
- package/dist/types/src/parser/query-builder.d.ts.map +1 -1
- package/dist/types/src/query-lite/query-lite.d.ts +4 -4
- package/dist/types/src/query-lite/query-lite.d.ts.map +1 -1
- package/dist/types/src/sandbox/index.d.ts +2 -0
- package/dist/types/src/sandbox/index.d.ts.map +1 -0
- package/dist/types/src/sandbox/quickjs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -14
- package/src/index.ts +1 -0
- package/src/parser/query-builder.ts +1 -1
- package/src/query-lite/query-lite.ts +79 -57
- package/src/sandbox/index.ts +5 -0
- package/src/sandbox/quickjs.ts +1 -2
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-query",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bc674ce",
|
|
4
4
|
"description": "ECHO queries.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "info@dxos.org",
|
|
9
13
|
"sideEffects": false,
|
|
@@ -17,7 +21,8 @@
|
|
|
17
21
|
"types": "./dist/types/src/index.d.ts",
|
|
18
22
|
"browser": "./dist/lib/browser/index.mjs",
|
|
19
23
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
20
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"./api.d.ts": "./dist/query-lite/index.d.ts"
|
|
21
26
|
},
|
|
22
27
|
"types": "dist/types/src/index.d.ts",
|
|
23
28
|
"typesVersions": {
|
|
@@ -31,21 +36,22 @@
|
|
|
31
36
|
"@lezer/common": "^1.2.2",
|
|
32
37
|
"@lezer/lezer": "^1.1.2",
|
|
33
38
|
"@lezer/lr": "^1.4.2",
|
|
34
|
-
"@
|
|
35
|
-
"@dxos/debug": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/echo-protocol": "0.8.4-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/node-std": "0.8.4-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/vendor-quickjs": "0.8.4-main.ae835ea"
|
|
39
|
+
"@dxos/context": "0.8.4-main.bc674ce",
|
|
40
|
+
"@dxos/debug": "0.8.4-main.bc674ce",
|
|
41
|
+
"@dxos/echo": "0.8.4-main.bc674ce",
|
|
42
|
+
"@dxos/errors": "0.8.4-main.bc674ce",
|
|
43
|
+
"@dxos/echo-protocol": "0.8.4-main.bc674ce",
|
|
44
|
+
"@dxos/invariant": "0.8.4-main.bc674ce",
|
|
45
|
+
"@dxos/node-std": "0.8.4-main.bc674ce",
|
|
46
|
+
"@dxos/util": "0.8.4-main.bc674ce",
|
|
47
|
+
"@dxos/vendor-quickjs": "0.8.4-main.bc674ce"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
50
|
"@lezer/generator": "^1.7.1",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
51
|
+
"tsdown": "^0.16.7",
|
|
52
|
+
"typescript": "^5.9.3",
|
|
53
|
+
"@dxos/echo-generator": "0.8.4-main.bc674ce",
|
|
54
|
+
"@dxos/random": "0.8.4-main.bc674ce"
|
|
49
55
|
},
|
|
50
56
|
"publishConfig": {
|
|
51
57
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type BuildResult = { filter?: Filter.Any; name?: string };
|
|
|
21
21
|
export class QueryBuilder {
|
|
22
22
|
private readonly _parser: Parser = QueryDSL.Parser.configure({ strict: true });
|
|
23
23
|
|
|
24
|
-
constructor(private readonly _tags?: Tag.
|
|
24
|
+
constructor(private readonly _tags?: Tag.Map) {}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Check valid input.
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import type { Filter
|
|
8
|
-
import type * as Echo from '@dxos/echo';
|
|
7
|
+
import type { Filter as Filter$, Order as Order$, Query as Query$, Ref } from '@dxos/echo';
|
|
9
8
|
import type { ForeignKey, QueryAST } from '@dxos/echo-protocol';
|
|
10
9
|
import { assertArgument } from '@dxos/invariant';
|
|
11
10
|
import type { DXN, ObjectId } from '@dxos/keys';
|
|
@@ -14,10 +13,12 @@ import type { DXN, ObjectId } from '@dxos/keys';
|
|
|
14
13
|
// Light-weight implementation of query execution.
|
|
15
14
|
//
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
private static variance: Echo.Order<any>['~Order'] = {} as Echo.Order<any>['~Order'];
|
|
16
|
+
// TODO(wittjosiah): The `export * as ...` syntax causes tsdown to genereate multiple files which breaks the sandbox.
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
class OrderClass implements Order$.Any {
|
|
19
|
+
private static variance: Order$.Any['~Order'] = {} as Order$.Any['~Order'];
|
|
20
|
+
|
|
21
|
+
static is(value: unknown): value is Order$.Any {
|
|
21
22
|
return typeof value === 'object' && value !== null && '~Order' in value;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -27,26 +28,31 @@ class OrderClass implements Echo.Order<any> {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
namespace Order1 {
|
|
30
|
-
export const natural:
|
|
31
|
-
export const property = <T>(property: keyof T & string, direction: QueryAST.OrderDirection):
|
|
31
|
+
export const natural: Order$.Any = new OrderClass({ kind: 'natural' });
|
|
32
|
+
export const property = <T>(property: keyof T & string, direction: QueryAST.OrderDirection): Order$.Order<T> =>
|
|
32
33
|
new OrderClass({
|
|
33
34
|
kind: 'property',
|
|
34
35
|
property,
|
|
35
36
|
direction,
|
|
36
37
|
});
|
|
38
|
+
export const rank = <T>(direction: QueryAST.OrderDirection = 'desc'): Order$.Order<T> =>
|
|
39
|
+
new OrderClass({
|
|
40
|
+
kind: 'rank',
|
|
41
|
+
direction,
|
|
42
|
+
});
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
const Order2: typeof
|
|
45
|
+
const Order2: typeof Order$ = Order1;
|
|
40
46
|
export { Order2 as Order };
|
|
41
47
|
|
|
42
|
-
class FilterClass implements
|
|
43
|
-
private static variance:
|
|
48
|
+
class FilterClass implements Filter$.Any {
|
|
49
|
+
private static variance: Filter$.Any['~Filter'] = {} as Filter$.Any['~Filter'];
|
|
44
50
|
|
|
45
|
-
static is(value: unknown): value is
|
|
51
|
+
static is(value: unknown): value is Filter$.Any {
|
|
46
52
|
return typeof value === 'object' && value !== null && '~Filter' in value;
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
static fromAst(ast: QueryAST.Filter): Filter
|
|
55
|
+
static fromAst(ast: QueryAST.Filter): Filter$.Any {
|
|
50
56
|
return new FilterClass(ast);
|
|
51
57
|
}
|
|
52
58
|
|
|
@@ -77,7 +83,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
77
83
|
});
|
|
78
84
|
}
|
|
79
85
|
|
|
80
|
-
static
|
|
86
|
+
static id(...ids: ObjectId[]): Filter$.Any {
|
|
81
87
|
// assertArgument(
|
|
82
88
|
// ids.every((id) => ObjectId.isValid(id)),
|
|
83
89
|
// 'ids',
|
|
@@ -98,8 +104,8 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
98
104
|
|
|
99
105
|
static type<S extends Schema.Schema.All>(
|
|
100
106
|
schema: S | string,
|
|
101
|
-
props?:
|
|
102
|
-
):
|
|
107
|
+
props?: Filter$.Props<Schema.Schema.Type<S>>,
|
|
108
|
+
): Filter$.Filter<Schema.Schema.Type<S>> {
|
|
103
109
|
if (typeof schema !== 'string') {
|
|
104
110
|
throw new TypeError('expected typename as the first paramter');
|
|
105
111
|
}
|
|
@@ -110,7 +116,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
110
116
|
});
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
static typename(typename: string):
|
|
119
|
+
static typename(typename: string): Filter$.Any {
|
|
114
120
|
return new FilterClass({
|
|
115
121
|
type: 'object',
|
|
116
122
|
typename: makeTypeDxn(typename),
|
|
@@ -118,7 +124,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
118
124
|
});
|
|
119
125
|
}
|
|
120
126
|
|
|
121
|
-
static typeDXN(dxn: DXN):
|
|
127
|
+
static typeDXN(dxn: DXN): Filter$.Any {
|
|
122
128
|
return new FilterClass({
|
|
123
129
|
type: 'object',
|
|
124
130
|
typename: dxn.toString(),
|
|
@@ -126,14 +132,14 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
126
132
|
});
|
|
127
133
|
}
|
|
128
134
|
|
|
129
|
-
static tag(tag: string):
|
|
135
|
+
static tag(tag: string): Filter$.Any {
|
|
130
136
|
return new FilterClass({
|
|
131
137
|
type: 'tag',
|
|
132
138
|
tag,
|
|
133
139
|
});
|
|
134
140
|
}
|
|
135
141
|
|
|
136
|
-
static props<T>(props:
|
|
142
|
+
static props<T>(props: Filter$.Props<T>): Filter$.Filter<T> {
|
|
137
143
|
return new FilterClass({
|
|
138
144
|
type: 'object',
|
|
139
145
|
typename: null,
|
|
@@ -141,7 +147,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
141
147
|
});
|
|
142
148
|
}
|
|
143
149
|
|
|
144
|
-
static text(text: string, options?:
|
|
150
|
+
static text(text: string, options?: Filter$.TextSearchOptions): Filter$.Any {
|
|
145
151
|
return new FilterClass({
|
|
146
152
|
type: 'text-search',
|
|
147
153
|
text,
|
|
@@ -152,7 +158,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
152
158
|
static foreignKeys<S extends Schema.Schema.All>(
|
|
153
159
|
schema: S | string,
|
|
154
160
|
keys: ForeignKey[],
|
|
155
|
-
):
|
|
161
|
+
): Filter$.Filter<Schema.Schema.Type<S>> {
|
|
156
162
|
assertArgument(typeof schema === 'string', 'schema');
|
|
157
163
|
assertArgument(!schema.startsWith('dxn:'), 'schema');
|
|
158
164
|
return new FilterClass({
|
|
@@ -163,7 +169,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
163
169
|
});
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
static eq<T>(value: T):
|
|
172
|
+
static eq<T>(value: T): Filter$.Filter<T | undefined> {
|
|
167
173
|
if (!isRef(value) && typeof value === 'object' && value !== null) {
|
|
168
174
|
throw new TypeError('Cannot use object as a value for eq filter');
|
|
169
175
|
}
|
|
@@ -175,7 +181,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
175
181
|
});
|
|
176
182
|
}
|
|
177
183
|
|
|
178
|
-
static neq<T>(value: T):
|
|
184
|
+
static neq<T>(value: T): Filter$.Filter<T | undefined> {
|
|
179
185
|
return new FilterClass({
|
|
180
186
|
type: 'compare',
|
|
181
187
|
operator: 'neq',
|
|
@@ -183,7 +189,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
183
189
|
});
|
|
184
190
|
}
|
|
185
191
|
|
|
186
|
-
static gt<T>(value: T):
|
|
192
|
+
static gt<T>(value: T): Filter$.Filter<T | undefined> {
|
|
187
193
|
return new FilterClass({
|
|
188
194
|
type: 'compare',
|
|
189
195
|
operator: 'gt',
|
|
@@ -191,7 +197,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
191
197
|
});
|
|
192
198
|
}
|
|
193
199
|
|
|
194
|
-
static gte<T>(value: T):
|
|
200
|
+
static gte<T>(value: T): Filter$.Filter<T | undefined> {
|
|
195
201
|
return new FilterClass({
|
|
196
202
|
type: 'compare',
|
|
197
203
|
operator: 'gte',
|
|
@@ -199,7 +205,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
199
205
|
});
|
|
200
206
|
}
|
|
201
207
|
|
|
202
|
-
static lt<T>(value: T):
|
|
208
|
+
static lt<T>(value: T): Filter$.Filter<T | undefined> {
|
|
203
209
|
return new FilterClass({
|
|
204
210
|
type: 'compare',
|
|
205
211
|
operator: 'lt',
|
|
@@ -207,7 +213,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
207
213
|
});
|
|
208
214
|
}
|
|
209
215
|
|
|
210
|
-
static lte<T>(value: T):
|
|
216
|
+
static lte<T>(value: T): Filter$.Filter<T | undefined> {
|
|
211
217
|
return new FilterClass({
|
|
212
218
|
type: 'compare',
|
|
213
219
|
operator: 'lte',
|
|
@@ -215,21 +221,21 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
215
221
|
});
|
|
216
222
|
}
|
|
217
223
|
|
|
218
|
-
static in<T>(...values: T[]):
|
|
224
|
+
static in<T>(...values: T[]): Filter$.Filter<T | undefined> {
|
|
219
225
|
return new FilterClass({
|
|
220
226
|
type: 'in',
|
|
221
227
|
values,
|
|
222
228
|
});
|
|
223
229
|
}
|
|
224
230
|
|
|
225
|
-
static contains<T>(value: T):
|
|
231
|
+
static contains<T>(value: T): Filter$.Filter<readonly T[] | undefined> {
|
|
226
232
|
return new FilterClass({
|
|
227
233
|
type: 'contains',
|
|
228
234
|
value,
|
|
229
235
|
});
|
|
230
236
|
}
|
|
231
237
|
|
|
232
|
-
static between<T>(from: T, to: T):
|
|
238
|
+
static between<T>(from: T, to: T): Filter$.Filter<unknown> {
|
|
233
239
|
return new FilterClass({
|
|
234
240
|
type: 'range',
|
|
235
241
|
from,
|
|
@@ -237,21 +243,25 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
237
243
|
});
|
|
238
244
|
}
|
|
239
245
|
|
|
240
|
-
static not<F extends
|
|
246
|
+
static not<F extends Filter$.Any>(filter: F): Filter$.Filter<Filter$.Type<F>> {
|
|
241
247
|
return new FilterClass({
|
|
242
248
|
type: 'not',
|
|
243
249
|
filter: filter.ast,
|
|
244
250
|
});
|
|
245
251
|
}
|
|
246
252
|
|
|
247
|
-
static and<
|
|
253
|
+
static and<Filters extends readonly Filter$.Any[]>(
|
|
254
|
+
...filters: Filters
|
|
255
|
+
): Filter$.Filter<Filter$.Type<Filters[number]>> {
|
|
248
256
|
return new FilterClass({
|
|
249
257
|
type: 'and',
|
|
250
258
|
filters: filters.map((f) => f.ast),
|
|
251
259
|
});
|
|
252
260
|
}
|
|
253
261
|
|
|
254
|
-
static or<
|
|
262
|
+
static or<Filters extends readonly Filter$.Any[]>(
|
|
263
|
+
...filters: Filters
|
|
264
|
+
): Filter$.Filter<Filter$.Type<Filters[number]>> {
|
|
255
265
|
return new FilterClass({
|
|
256
266
|
type: 'or',
|
|
257
267
|
filters: filters.map((f) => f.ast),
|
|
@@ -263,7 +273,7 @@ class FilterClass implements Echo.Filter<any> {
|
|
|
263
273
|
'~Filter' = FilterClass.variance;
|
|
264
274
|
}
|
|
265
275
|
|
|
266
|
-
export const Filter1: typeof
|
|
276
|
+
export const Filter1: typeof Filter$ = FilterClass;
|
|
267
277
|
export { Filter1 as Filter };
|
|
268
278
|
|
|
269
279
|
/**
|
|
@@ -272,7 +282,7 @@ export { Filter1 as Filter };
|
|
|
272
282
|
// TODO(dmaretskyi): Filter only properties that are references (or optional references, or unions that include references).
|
|
273
283
|
type RefPropKey<T> = keyof T & string;
|
|
274
284
|
|
|
275
|
-
const propsFilterToAst = (predicates:
|
|
285
|
+
const propsFilterToAst = (predicates: Filter$.Props<any>): Pick<QueryAST.FilterObject, 'id' | 'props'> => {
|
|
276
286
|
let idFilter: readonly ObjectId[] | undefined;
|
|
277
287
|
if ('id' in predicates) {
|
|
278
288
|
assertArgument(
|
|
@@ -317,32 +327,32 @@ const processPredicate = (predicate: any): QueryAST.Filter => {
|
|
|
317
327
|
return FilterClass.eq(predicate).ast;
|
|
318
328
|
};
|
|
319
329
|
|
|
320
|
-
class QueryClass implements
|
|
321
|
-
private static variance:
|
|
330
|
+
class QueryClass implements Query$.Any {
|
|
331
|
+
private static variance: Query$.Any['~Query'] = {} as Query$.Any['~Query'];
|
|
322
332
|
|
|
323
|
-
static is(value: unknown): value is
|
|
333
|
+
static is(value: unknown): value is Query$.Any {
|
|
324
334
|
return typeof value === 'object' && value !== null && '~Query' in value;
|
|
325
335
|
}
|
|
326
336
|
|
|
327
|
-
static fromAst(ast: QueryAST.Query):
|
|
337
|
+
static fromAst(ast: QueryAST.Query): Query$.Any {
|
|
328
338
|
return new QueryClass(ast);
|
|
329
339
|
}
|
|
330
340
|
|
|
331
|
-
static select<F extends
|
|
341
|
+
static select<F extends Filter$.Any>(filter: F): Query$.Query<Filter$.Type<F>> {
|
|
332
342
|
return new QueryClass({
|
|
333
343
|
type: 'select',
|
|
334
344
|
filter: filter.ast,
|
|
335
345
|
});
|
|
336
346
|
}
|
|
337
347
|
|
|
338
|
-
static type(schema: Schema.Schema.All | string, predicates?:
|
|
348
|
+
static type(schema: Schema.Schema.All | string, predicates?: Filter$.Props<unknown>): Query$.Any {
|
|
339
349
|
return new QueryClass({
|
|
340
350
|
type: 'select',
|
|
341
351
|
filter: FilterClass.type(schema, predicates).ast,
|
|
342
352
|
});
|
|
343
353
|
}
|
|
344
354
|
|
|
345
|
-
static all(...queries: Query
|
|
355
|
+
static all(...queries: Query$.Any[]): Query$.Any {
|
|
346
356
|
if (queries.length === 0) {
|
|
347
357
|
throw new TypeError(
|
|
348
358
|
'Query.all combines results of multiple queries, to query all objects use Query.select(Filter.everything())',
|
|
@@ -354,7 +364,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
354
364
|
});
|
|
355
365
|
}
|
|
356
366
|
|
|
357
|
-
static without<T>(source: Query<T>, exclude: Query<T>): Query<T> {
|
|
367
|
+
static without<T>(source: Query$.Query<T>, exclude: Query$.Query<T>): Query$.Query<T> {
|
|
358
368
|
return new QueryClass({
|
|
359
369
|
type: 'set-difference',
|
|
360
370
|
source: source.ast,
|
|
@@ -366,7 +376,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
366
376
|
|
|
367
377
|
'~Query' = QueryClass.variance;
|
|
368
378
|
|
|
369
|
-
select(filter: Filter
|
|
379
|
+
select(filter: Filter$.Any | Filter$.Props<any>): Query$.Any {
|
|
370
380
|
if (FilterClass.is(filter)) {
|
|
371
381
|
return new QueryClass({
|
|
372
382
|
type: 'filter',
|
|
@@ -382,7 +392,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
382
392
|
}
|
|
383
393
|
}
|
|
384
394
|
|
|
385
|
-
reference(key: string): Query
|
|
395
|
+
reference(key: string): Query$.Any {
|
|
386
396
|
return new QueryClass({
|
|
387
397
|
type: 'reference-traversal',
|
|
388
398
|
anchor: this.ast,
|
|
@@ -390,18 +400,22 @@ class QueryClass implements Echo.Query<any> {
|
|
|
390
400
|
});
|
|
391
401
|
}
|
|
392
402
|
|
|
393
|
-
referencedBy(target
|
|
394
|
-
|
|
395
|
-
|
|
403
|
+
referencedBy(target?: Schema.Schema.All | string, key?: string): Query$.Any {
|
|
404
|
+
const typename =
|
|
405
|
+
target !== undefined
|
|
406
|
+
? (assertArgument(typeof target === 'string', 'target'),
|
|
407
|
+
assertArgument(!target.startsWith('dxn:'), 'target'),
|
|
408
|
+
target)
|
|
409
|
+
: null;
|
|
396
410
|
return new QueryClass({
|
|
397
411
|
type: 'incoming-references',
|
|
398
412
|
anchor: this.ast,
|
|
399
|
-
property: key,
|
|
400
|
-
typename
|
|
413
|
+
property: key ?? null,
|
|
414
|
+
typename,
|
|
401
415
|
});
|
|
402
416
|
}
|
|
403
417
|
|
|
404
|
-
sourceOf(relation: Schema.Schema.All | string, predicates?: Filter
|
|
418
|
+
sourceOf(relation: Schema.Schema.All | string, predicates?: Filter$.Props<unknown> | undefined): Query$.Any {
|
|
405
419
|
return new QueryClass({
|
|
406
420
|
type: 'relation',
|
|
407
421
|
anchor: this.ast,
|
|
@@ -410,7 +424,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
410
424
|
});
|
|
411
425
|
}
|
|
412
426
|
|
|
413
|
-
targetOf(relation: Schema.Schema.All | string, predicates?: Filter
|
|
427
|
+
targetOf(relation: Schema.Schema.All | string, predicates?: Filter$.Props<unknown> | undefined): Query$.Any {
|
|
414
428
|
return new QueryClass({
|
|
415
429
|
type: 'relation',
|
|
416
430
|
anchor: this.ast,
|
|
@@ -419,7 +433,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
419
433
|
});
|
|
420
434
|
}
|
|
421
435
|
|
|
422
|
-
source(): Query
|
|
436
|
+
source(): Query$.Any {
|
|
423
437
|
return new QueryClass({
|
|
424
438
|
type: 'relation-traversal',
|
|
425
439
|
anchor: this.ast,
|
|
@@ -427,7 +441,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
427
441
|
});
|
|
428
442
|
}
|
|
429
443
|
|
|
430
|
-
target(): Query
|
|
444
|
+
target(): Query$.Any {
|
|
431
445
|
return new QueryClass({
|
|
432
446
|
type: 'relation-traversal',
|
|
433
447
|
anchor: this.ast,
|
|
@@ -435,7 +449,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
435
449
|
});
|
|
436
450
|
}
|
|
437
451
|
|
|
438
|
-
orderBy(...order: Order
|
|
452
|
+
orderBy(...order: Order$.Any[]): Query$.Any {
|
|
439
453
|
return new QueryClass({
|
|
440
454
|
type: 'order',
|
|
441
455
|
query: this.ast,
|
|
@@ -443,7 +457,15 @@ class QueryClass implements Echo.Query<any> {
|
|
|
443
457
|
});
|
|
444
458
|
}
|
|
445
459
|
|
|
446
|
-
|
|
460
|
+
limit(limit: number): Query$.Any {
|
|
461
|
+
return new QueryClass({
|
|
462
|
+
type: 'limit',
|
|
463
|
+
query: this.ast,
|
|
464
|
+
limit,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
options(options: QueryAST.QueryOptions): Query$.Any {
|
|
447
469
|
return new QueryClass({
|
|
448
470
|
type: 'options',
|
|
449
471
|
query: this.ast,
|
|
@@ -452,7 +474,7 @@ class QueryClass implements Echo.Query<any> {
|
|
|
452
474
|
}
|
|
453
475
|
}
|
|
454
476
|
|
|
455
|
-
export const Query1: typeof
|
|
477
|
+
export const Query1: typeof Query$ = QueryClass;
|
|
456
478
|
export { Query1 as Query };
|
|
457
479
|
|
|
458
480
|
const RefTypeId: unique symbol = Symbol('@dxos/echo-query/Ref');
|
package/src/sandbox/quickjs.ts
CHANGED
|
@@ -17,8 +17,7 @@ export const unwrapResult = <T>(context: QuickJSContext, result: SuccessOrFail<T
|
|
|
17
17
|
if (
|
|
18
18
|
typeof contextError === 'object' &&
|
|
19
19
|
typeof contextError.name === 'string' &&
|
|
20
|
-
typeof contextError.message === 'string'
|
|
21
|
-
typeof contextError.stack === 'string'
|
|
20
|
+
typeof contextError.message === 'string'
|
|
22
21
|
) {
|
|
23
22
|
const error = new Error(contextError.message);
|
|
24
23
|
Object.defineProperty(error, 'name', { value: contextError.name });
|