@dxos/echo-protocol 0.8.4-main.b97322e → 0.8.4-main.bd9b33e6c8
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 → neutral}/index.mjs +378 -83
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/types/src/document-structure.d.ts +15 -1
- package/dist/types/src/document-structure.d.ts.map +1 -1
- package/dist/types/src/echo-feed-codec.d.ts +17 -0
- package/dist/types/src/echo-feed-codec.d.ts.map +1 -0
- package/dist/types/src/foreign-key.d.ts +1 -1
- package/dist/types/src/foreign-key.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/query/ast.d.ts +207 -23
- package/dist/types/src/query/ast.d.ts.map +1 -1
- package/dist/types/src/reference.d.ts +1 -0
- package/dist/types/src/reference.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -11
- package/src/document-structure.ts +24 -2
- package/src/echo-feed-codec.ts +67 -0
- package/src/foreign-key.ts +4 -3
- package/src/index.ts +4 -3
- package/src/query/ast.ts +294 -34
- package/src/reference.ts +5 -2
- package/src/space-id.ts +1 -1
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -525
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/src/query/ast.ts
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Match from 'effect/Match';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
6
7
|
|
|
7
8
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
8
9
|
|
|
9
10
|
import { ForeignKey } from '../foreign-key';
|
|
10
11
|
|
|
11
12
|
const TypenameSpecifier = Schema.Union(DXN.Schema, Schema.Null).annotations({
|
|
12
|
-
description: 'DXN or null
|
|
13
|
+
description: 'DXN or null; null matches any type',
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
// NOTE: This pattern with 3 definitions per schema is need to make the types opaque, and circular references in AST to not cause compiler errors.
|
|
@@ -46,6 +47,9 @@ const FilterObject_ = Schema.Struct({
|
|
|
46
47
|
export interface FilterObject extends Schema.Schema.Type<typeof FilterObject_> {}
|
|
47
48
|
export const FilterObject: Schema.Schema<FilterObject> = FilterObject_;
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Compare.
|
|
52
|
+
*/
|
|
49
53
|
const FilterCompare_ = Schema.Struct({
|
|
50
54
|
type: Schema.Literal('compare'),
|
|
51
55
|
operator: Schema.Literal('eq', 'neq', 'gt', 'gte', 'lt', 'lte'),
|
|
@@ -54,6 +58,9 @@ const FilterCompare_ = Schema.Struct({
|
|
|
54
58
|
export interface FilterCompare extends Schema.Schema.Type<typeof FilterCompare_> {}
|
|
55
59
|
export const FilterCompare: Schema.Schema<FilterCompare> = FilterCompare_;
|
|
56
60
|
|
|
61
|
+
/**
|
|
62
|
+
* In.
|
|
63
|
+
*/
|
|
57
64
|
const FilterIn_ = Schema.Struct({
|
|
58
65
|
type: Schema.Literal('in'),
|
|
59
66
|
values: Schema.Array(Schema.Any),
|
|
@@ -61,53 +68,121 @@ const FilterIn_ = Schema.Struct({
|
|
|
61
68
|
export interface FilterIn extends Schema.Schema.Type<typeof FilterIn_> {}
|
|
62
69
|
export const FilterIn: Schema.Schema<FilterIn> = FilterIn_;
|
|
63
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Contains.
|
|
73
|
+
*/
|
|
74
|
+
const FilterContains_ = Schema.Struct({
|
|
75
|
+
type: Schema.Literal('contains'),
|
|
76
|
+
value: Schema.Any,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export interface FilterContains extends Schema.Schema.Type<typeof FilterContains_> {}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Predicate for an array property to contain the provided value.
|
|
83
|
+
* Nested objects are matched using strict structural matching.
|
|
84
|
+
*/
|
|
85
|
+
export const FilterContains: Schema.Schema<FilterContains> = FilterContains_;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Filters objects that have certain tag.
|
|
89
|
+
*/
|
|
90
|
+
const FilterTag_ = Schema.Struct({
|
|
91
|
+
type: Schema.Literal('tag'),
|
|
92
|
+
tag: Schema.String, // TODO(burdon): Make OR-collection?
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export interface FilterTag extends Schema.Schema.Type<typeof FilterTag_> {}
|
|
96
|
+
export const FilterTag: Schema.Schema<FilterTag> = FilterTag_;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Range.
|
|
100
|
+
*/
|
|
64
101
|
const FilterRange_ = Schema.Struct({
|
|
65
102
|
type: Schema.Literal('range'),
|
|
66
103
|
from: Schema.Any,
|
|
67
104
|
to: Schema.Any,
|
|
68
105
|
});
|
|
106
|
+
|
|
69
107
|
export interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {}
|
|
70
108
|
export const FilterRange: Schema.Schema<FilterRange> = FilterRange_;
|
|
71
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Filter by system timestamp (createdAt / updatedAt).
|
|
112
|
+
* Timestamps are unix milliseconds stored in the object meta index.
|
|
113
|
+
*/
|
|
114
|
+
const FilterTimestamp_ = Schema.Struct({
|
|
115
|
+
type: Schema.Literal('timestamp'),
|
|
116
|
+
field: Schema.Literal('createdAt', 'updatedAt'),
|
|
117
|
+
operator: Schema.Literal('gt', 'gte', 'lt', 'lte'),
|
|
118
|
+
value: Schema.Number,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
export interface FilterTimestamp extends Schema.Schema.Type<typeof FilterTimestamp_> {}
|
|
122
|
+
export const FilterTimestamp: Schema.Schema<FilterTimestamp> = FilterTimestamp_;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Text search.
|
|
126
|
+
*/
|
|
72
127
|
const FilterTextSearch_ = Schema.Struct({
|
|
73
128
|
type: Schema.Literal('text-search'),
|
|
74
129
|
text: Schema.String,
|
|
75
130
|
searchKind: Schema.optional(Schema.Literal('full-text', 'vector')),
|
|
76
131
|
});
|
|
132
|
+
|
|
77
133
|
export interface FilterTextSearch extends Schema.Schema.Type<typeof FilterTextSearch_> {}
|
|
78
134
|
export const FilterTextSearch: Schema.Schema<FilterTextSearch> = FilterTextSearch_;
|
|
79
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Not.
|
|
138
|
+
*/
|
|
80
139
|
const FilterNot_ = Schema.Struct({
|
|
81
140
|
type: Schema.Literal('not'),
|
|
82
141
|
filter: Schema.suspend(() => Filter),
|
|
83
142
|
});
|
|
143
|
+
|
|
84
144
|
export interface FilterNot extends Schema.Schema.Type<typeof FilterNot_> {}
|
|
85
145
|
export const FilterNot: Schema.Schema<FilterNot> = FilterNot_;
|
|
86
146
|
|
|
147
|
+
/**
|
|
148
|
+
* And.
|
|
149
|
+
*/
|
|
87
150
|
const FilterAnd_ = Schema.Struct({
|
|
88
151
|
type: Schema.Literal('and'),
|
|
89
152
|
filters: Schema.Array(Schema.suspend(() => Filter)),
|
|
90
153
|
});
|
|
154
|
+
|
|
91
155
|
export interface FilterAnd extends Schema.Schema.Type<typeof FilterAnd_> {}
|
|
92
156
|
export const FilterAnd: Schema.Schema<FilterAnd> = FilterAnd_;
|
|
93
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Or.
|
|
160
|
+
*/
|
|
94
161
|
const FilterOr_ = Schema.Struct({
|
|
95
162
|
type: Schema.Literal('or'),
|
|
96
163
|
filters: Schema.Array(Schema.suspend(() => Filter)),
|
|
97
164
|
});
|
|
165
|
+
|
|
98
166
|
export interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {}
|
|
99
167
|
export const FilterOr: Schema.Schema<FilterOr> = FilterOr_;
|
|
100
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Union of filters.
|
|
171
|
+
*/
|
|
101
172
|
export const Filter = Schema.Union(
|
|
102
173
|
FilterObject,
|
|
103
|
-
FilterTextSearch,
|
|
104
174
|
FilterCompare,
|
|
105
175
|
FilterIn,
|
|
176
|
+
FilterContains,
|
|
177
|
+
FilterTag,
|
|
106
178
|
FilterRange,
|
|
179
|
+
FilterTimestamp,
|
|
180
|
+
FilterTextSearch,
|
|
107
181
|
FilterNot,
|
|
108
182
|
FilterAnd,
|
|
109
183
|
FilterOr,
|
|
110
|
-
);
|
|
184
|
+
).annotations({ identifier: 'org.dxos.schema.filter' });
|
|
185
|
+
|
|
111
186
|
export type Filter = Schema.Schema.Type<typeof Filter>;
|
|
112
187
|
|
|
113
188
|
/**
|
|
@@ -117,6 +192,7 @@ const QuerySelectClause_ = Schema.Struct({
|
|
|
117
192
|
type: Schema.Literal('select'),
|
|
118
193
|
filter: Schema.suspend(() => Filter),
|
|
119
194
|
});
|
|
195
|
+
|
|
120
196
|
export interface QuerySelectClause extends Schema.Schema.Type<typeof QuerySelectClause_> {}
|
|
121
197
|
export const QuerySelectClause: Schema.Schema<QuerySelectClause> = QuerySelectClause_;
|
|
122
198
|
|
|
@@ -128,6 +204,7 @@ const QueryFilterClause_ = Schema.Struct({
|
|
|
128
204
|
selection: Schema.suspend(() => Query),
|
|
129
205
|
filter: Schema.suspend(() => Filter),
|
|
130
206
|
});
|
|
207
|
+
|
|
131
208
|
export interface QueryFilterClause extends Schema.Schema.Type<typeof QueryFilterClause_> {}
|
|
132
209
|
export const QueryFilterClause: Schema.Schema<QueryFilterClause> = QueryFilterClause_;
|
|
133
210
|
|
|
@@ -139,6 +216,7 @@ const QueryReferenceTraversalClause_ = Schema.Struct({
|
|
|
139
216
|
anchor: Schema.suspend(() => Query),
|
|
140
217
|
property: Schema.String, // TODO(dmaretskyi): Change to EscapedPropPath.
|
|
141
218
|
});
|
|
219
|
+
|
|
142
220
|
export interface QueryReferenceTraversalClause extends Schema.Schema.Type<typeof QueryReferenceTraversalClause_> {}
|
|
143
221
|
export const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversalClause> =
|
|
144
222
|
QueryReferenceTraversalClause_;
|
|
@@ -149,9 +227,14 @@ export const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversa
|
|
|
149
227
|
const QueryIncomingReferencesClause_ = Schema.Struct({
|
|
150
228
|
type: Schema.Literal('incoming-references'),
|
|
151
229
|
anchor: Schema.suspend(() => Query),
|
|
152
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Property path where the reference is located.
|
|
232
|
+
* If null, matches references from any property.
|
|
233
|
+
*/
|
|
234
|
+
property: Schema.NullOr(Schema.String),
|
|
153
235
|
typename: TypenameSpecifier,
|
|
154
236
|
});
|
|
237
|
+
|
|
155
238
|
export interface QueryIncomingReferencesClause extends Schema.Schema.Type<typeof QueryIncomingReferencesClause_> {}
|
|
156
239
|
export const QueryIncomingReferencesClause: Schema.Schema<QueryIncomingReferencesClause> =
|
|
157
240
|
QueryIncomingReferencesClause_;
|
|
@@ -170,6 +253,7 @@ const QueryRelationClause_ = Schema.Struct({
|
|
|
170
253
|
direction: Schema.Literal('outgoing', 'incoming', 'both'),
|
|
171
254
|
filter: Schema.optional(Schema.suspend(() => Filter)),
|
|
172
255
|
});
|
|
256
|
+
|
|
173
257
|
export interface QueryRelationClause extends Schema.Schema.Type<typeof QueryRelationClause_> {}
|
|
174
258
|
export const QueryRelationClause: Schema.Schema<QueryRelationClause> = QueryRelationClause_;
|
|
175
259
|
|
|
@@ -181,9 +265,27 @@ const QueryRelationTraversalClause_ = Schema.Struct({
|
|
|
181
265
|
anchor: Schema.suspend(() => Query),
|
|
182
266
|
direction: Schema.Literal('source', 'target', 'both'),
|
|
183
267
|
});
|
|
268
|
+
|
|
184
269
|
export interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {}
|
|
185
270
|
export const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause> = QueryRelationTraversalClause_;
|
|
186
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Traverse parent-child hierarchy.
|
|
274
|
+
*/
|
|
275
|
+
const QueryHierarchyTraversalClause_ = Schema.Struct({
|
|
276
|
+
type: Schema.Literal('hierarchy-traversal'),
|
|
277
|
+
anchor: Schema.suspend(() => Query),
|
|
278
|
+
/**
|
|
279
|
+
* to-parent: traverse from child to parent.
|
|
280
|
+
* to-children: traverse from parent to children.
|
|
281
|
+
*/
|
|
282
|
+
direction: Schema.Literal('to-parent', 'to-children'),
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
export interface QueryHierarchyTraversalClause extends Schema.Schema.Type<typeof QueryHierarchyTraversalClause_> {}
|
|
286
|
+
export const QueryHierarchyTraversalClause: Schema.Schema<QueryHierarchyTraversalClause> =
|
|
287
|
+
QueryHierarchyTraversalClause_;
|
|
288
|
+
|
|
187
289
|
/**
|
|
188
290
|
* Union of multiple queries.
|
|
189
291
|
*/
|
|
@@ -191,6 +293,7 @@ const QueryUnionClause_ = Schema.Struct({
|
|
|
191
293
|
type: Schema.Literal('union'),
|
|
192
294
|
queries: Schema.Array(Schema.suspend(() => Query)),
|
|
193
295
|
});
|
|
296
|
+
|
|
194
297
|
export interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {}
|
|
195
298
|
export const QueryUnionClause: Schema.Schema<QueryUnionClause> = QueryUnionClause_;
|
|
196
299
|
|
|
@@ -202,9 +305,47 @@ const QuerySetDifferenceClause_ = Schema.Struct({
|
|
|
202
305
|
source: Schema.suspend(() => Query),
|
|
203
306
|
exclude: Schema.suspend(() => Query),
|
|
204
307
|
});
|
|
308
|
+
|
|
205
309
|
export interface QuerySetDifferenceClause extends Schema.Schema.Type<typeof QuerySetDifferenceClause_> {}
|
|
206
310
|
export const QuerySetDifferenceClause: Schema.Schema<QuerySetDifferenceClause> = QuerySetDifferenceClause_;
|
|
207
311
|
|
|
312
|
+
export const OrderDirection = Schema.Literal('asc', 'desc');
|
|
313
|
+
export type OrderDirection = Schema.Schema.Type<typeof OrderDirection>;
|
|
314
|
+
|
|
315
|
+
const Order_ = Schema.Union(
|
|
316
|
+
Schema.Struct({
|
|
317
|
+
// How database wants to order them (in practice - by id).
|
|
318
|
+
kind: Schema.Literal('natural'),
|
|
319
|
+
}),
|
|
320
|
+
Schema.Struct({
|
|
321
|
+
kind: Schema.Literal('property'),
|
|
322
|
+
property: Schema.String,
|
|
323
|
+
direction: OrderDirection,
|
|
324
|
+
}),
|
|
325
|
+
Schema.Struct({
|
|
326
|
+
// Order by relevance rank (for FTS/vector search results).
|
|
327
|
+
// Default direction is 'desc' (higher rank = better match first).
|
|
328
|
+
kind: Schema.Literal('rank'),
|
|
329
|
+
direction: OrderDirection,
|
|
330
|
+
}),
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
export type Order = Schema.Schema.Type<typeof Order_>;
|
|
334
|
+
export const Order: Schema.Schema<Order> = Order_;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Order the query results.
|
|
338
|
+
* Left-to-right the orders dominate.
|
|
339
|
+
*/
|
|
340
|
+
const QueryOrderClause_ = Schema.Struct({
|
|
341
|
+
type: Schema.Literal('order'),
|
|
342
|
+
query: Schema.suspend(() => Query),
|
|
343
|
+
order: Schema.Array(Order),
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
export interface QueryOrderClause extends Schema.Schema.Type<typeof QueryOrderClause_> {}
|
|
347
|
+
export const QueryOrderClause: Schema.Schema<QueryOrderClause> = QueryOrderClause_;
|
|
348
|
+
|
|
208
349
|
/**
|
|
209
350
|
* Add options to a query.
|
|
210
351
|
*/
|
|
@@ -213,9 +354,37 @@ const QueryOptionsClause_ = Schema.Struct({
|
|
|
213
354
|
query: Schema.suspend(() => Query),
|
|
214
355
|
options: Schema.suspend(() => QueryOptions),
|
|
215
356
|
});
|
|
357
|
+
|
|
216
358
|
export interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}
|
|
217
359
|
export const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;
|
|
218
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Limit the number of results.
|
|
363
|
+
*/
|
|
364
|
+
const QueryLimitClause_ = Schema.Struct({
|
|
365
|
+
type: Schema.Literal('limit'),
|
|
366
|
+
query: Schema.suspend(() => Query),
|
|
367
|
+
limit: Schema.Number,
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
export interface QueryLimitClause extends Schema.Schema.Type<typeof QueryLimitClause_> {}
|
|
371
|
+
export const QueryLimitClause: Schema.Schema<QueryLimitClause> = QueryLimitClause_;
|
|
372
|
+
|
|
373
|
+
export const QueryFromClause_ = Schema.Struct({
|
|
374
|
+
type: Schema.Literal('from'),
|
|
375
|
+
query: Schema.suspend(() => Query),
|
|
376
|
+
from: Schema.Union(
|
|
377
|
+
Schema.TaggedStruct('scope', {
|
|
378
|
+
scope: Schema.suspend(() => Scope),
|
|
379
|
+
}),
|
|
380
|
+
Schema.TaggedStruct('query', {
|
|
381
|
+
query: Schema.suspend(() => Query),
|
|
382
|
+
}),
|
|
383
|
+
),
|
|
384
|
+
});
|
|
385
|
+
export interface QueryFromClause extends Schema.Schema.Type<typeof QueryFromClause_> {}
|
|
386
|
+
export const QueryFromClause: Schema.Schema<QueryFromClause> = QueryFromClause_;
|
|
387
|
+
|
|
219
388
|
const Query_ = Schema.Union(
|
|
220
389
|
QuerySelectClause,
|
|
221
390
|
QueryFilterClause,
|
|
@@ -223,46 +392,137 @@ const Query_ = Schema.Union(
|
|
|
223
392
|
QueryIncomingReferencesClause,
|
|
224
393
|
QueryRelationClause,
|
|
225
394
|
QueryRelationTraversalClause,
|
|
395
|
+
QueryHierarchyTraversalClause,
|
|
226
396
|
QueryUnionClause,
|
|
227
397
|
QuerySetDifferenceClause,
|
|
398
|
+
QueryOrderClause,
|
|
228
399
|
QueryOptionsClause,
|
|
229
|
-
|
|
400
|
+
QueryLimitClause,
|
|
401
|
+
QueryFromClause,
|
|
402
|
+
).annotations({ identifier: 'org.dxos.schema.query' });
|
|
230
403
|
|
|
231
404
|
export type Query = Schema.Schema.Type<typeof Query_>;
|
|
232
405
|
export const Query: Schema.Schema<Query> = Query_;
|
|
233
406
|
|
|
234
407
|
export const QueryOptions = Schema.Struct({
|
|
235
|
-
|
|
408
|
+
/**
|
|
409
|
+
* Nested select statements will use this option to filter deleted objects.
|
|
410
|
+
*/
|
|
236
411
|
deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),
|
|
237
412
|
});
|
|
413
|
+
|
|
238
414
|
export interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}
|
|
239
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Specifies the scope of the data to query from.
|
|
418
|
+
*/
|
|
419
|
+
export const Scope = Schema.Struct({
|
|
420
|
+
/**
|
|
421
|
+
* The nested select statemets will select from the given spaces.
|
|
422
|
+
*
|
|
423
|
+
* NOTE: Spaces and queues are unioned together if both are specified.
|
|
424
|
+
*/
|
|
425
|
+
spaceIds: Schema.optional(Schema.Array(Schema.String)),
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* If true, the nested select statements will select from all queues in the spaces specified by `spaceIds`.
|
|
429
|
+
*/
|
|
430
|
+
allQueuesFromSpaces: Schema.optional(Schema.Boolean),
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The nested select statemets will select from the given queues.
|
|
434
|
+
*
|
|
435
|
+
* NOTE: Spaces and queues are unioned together if both are specified.
|
|
436
|
+
*/
|
|
437
|
+
queues: Schema.optional(Schema.Array(DXN.Schema)),
|
|
438
|
+
});
|
|
439
|
+
export interface Scope extends Schema.Schema.Type<typeof Scope> {}
|
|
440
|
+
|
|
240
441
|
export const visit = (query: Query, visitor: (node: Query) => void) => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
442
|
+
visitor(query);
|
|
443
|
+
|
|
444
|
+
Match.value(query).pipe(
|
|
445
|
+
Match.when({ type: 'filter' }, ({ selection }) => visit(selection, visitor)),
|
|
446
|
+
Match.when({ type: 'reference-traversal' }, ({ anchor }) => visit(anchor, visitor)),
|
|
447
|
+
Match.when({ type: 'incoming-references' }, ({ anchor }) => visit(anchor, visitor)),
|
|
448
|
+
Match.when({ type: 'relation' }, ({ anchor }) => visit(anchor, visitor)),
|
|
449
|
+
Match.when({ type: 'options' }, ({ query }) => visit(query, visitor)),
|
|
450
|
+
Match.when({ type: 'relation-traversal' }, ({ anchor }) => visit(anchor, visitor)),
|
|
451
|
+
Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => visit(anchor, visitor)),
|
|
452
|
+
Match.when({ type: 'union' }, ({ queries }) => queries.forEach((q) => visit(q, visitor))),
|
|
453
|
+
Match.when({ type: 'set-difference' }, ({ source, exclude }) => {
|
|
454
|
+
visit(source, visitor);
|
|
455
|
+
visit(exclude, visitor);
|
|
456
|
+
}),
|
|
457
|
+
Match.when({ type: 'order' }, ({ query }) => visit(query, visitor)),
|
|
458
|
+
Match.when({ type: 'limit' }, ({ query }) => visit(query, visitor)),
|
|
459
|
+
Match.when({ type: 'from' }, (node) => {
|
|
460
|
+
visit(node.query, visitor);
|
|
461
|
+
if (node.from._tag === 'query') {
|
|
462
|
+
visit(node.from.query, visitor);
|
|
463
|
+
}
|
|
464
|
+
}),
|
|
465
|
+
Match.when({ type: 'select' }, () => {}),
|
|
466
|
+
Match.exhaustive,
|
|
467
|
+
);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Recursively transforms a query tree bottom-up.
|
|
472
|
+
* The mapper receives each node with its children already transformed.
|
|
473
|
+
*/
|
|
474
|
+
export const map = (query: Query, mapper: (node: Query) => Query): Query => {
|
|
475
|
+
const mapped: Query = Match.value(query).pipe(
|
|
476
|
+
Match.when({ type: 'filter' }, (node) => ({ ...node, selection: map(node.selection, mapper) })),
|
|
477
|
+
Match.when({ type: 'reference-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
478
|
+
Match.when({ type: 'incoming-references' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
479
|
+
Match.when({ type: 'relation' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
480
|
+
Match.when({ type: 'relation-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
481
|
+
Match.when({ type: 'hierarchy-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
482
|
+
Match.when({ type: 'options' }, (node) => ({ ...node, query: map(node.query, mapper) })),
|
|
483
|
+
Match.when({ type: 'order' }, (node) => ({ ...node, query: map(node.query, mapper) })),
|
|
484
|
+
Match.when({ type: 'limit' }, (node) => ({ ...node, query: map(node.query, mapper) })),
|
|
485
|
+
Match.when({ type: 'from' }, (node) => ({
|
|
486
|
+
...node,
|
|
487
|
+
query: map(node.query, mapper),
|
|
488
|
+
...(node.from._tag === 'query' ? { from: { _tag: 'query' as const, query: map(node.from.query, mapper) } } : {}),
|
|
489
|
+
})),
|
|
490
|
+
Match.when({ type: 'union' }, (node) => ({ ...node, queries: node.queries.map((q) => map(q, mapper)) })),
|
|
491
|
+
Match.when({ type: 'set-difference' }, (node) => ({
|
|
492
|
+
...node,
|
|
493
|
+
source: map(node.source, mapper),
|
|
494
|
+
exclude: map(node.exclude, mapper),
|
|
495
|
+
})),
|
|
496
|
+
Match.when({ type: 'select' }, (node) => node),
|
|
497
|
+
Match.exhaustive,
|
|
498
|
+
);
|
|
499
|
+
return mapper(mapped);
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
export const fold = <T>(query: Query, reducer: (node: Query) => T): T[] => {
|
|
503
|
+
return Match.value(query).pipe(
|
|
504
|
+
Match.withReturnType<T[]>(),
|
|
505
|
+
Match.when({ type: 'filter' }, ({ selection }) => fold(selection, reducer)),
|
|
506
|
+
Match.when({ type: 'reference-traversal' }, ({ anchor }) => fold(anchor, reducer)),
|
|
507
|
+
Match.when({ type: 'incoming-references' }, ({ anchor }) => fold(anchor, reducer)),
|
|
508
|
+
Match.when({ type: 'relation' }, ({ anchor }) => fold(anchor, reducer)),
|
|
509
|
+
Match.when({ type: 'options' }, ({ query }) => fold(query, reducer)),
|
|
510
|
+
Match.when({ type: 'relation-traversal' }, ({ anchor }) => fold(anchor, reducer)),
|
|
511
|
+
Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => fold(anchor, reducer)),
|
|
512
|
+
Match.when({ type: 'union' }, ({ queries }) => queries.flatMap((q) => fold(q, reducer))),
|
|
513
|
+
Match.when({ type: 'set-difference' }, ({ source, exclude }) =>
|
|
514
|
+
fold(source, reducer).concat(fold(exclude, reducer)),
|
|
515
|
+
),
|
|
516
|
+
Match.when({ type: 'order' }, ({ query }) => fold(query, reducer)),
|
|
517
|
+
Match.when({ type: 'limit' }, ({ query }) => fold(query, reducer)),
|
|
518
|
+
Match.when({ type: 'from' }, (node) => {
|
|
519
|
+
const results = fold(node.query, reducer);
|
|
520
|
+
if (node.from._tag === 'query') {
|
|
521
|
+
return results.concat(fold(node.from.query, reducer));
|
|
522
|
+
}
|
|
523
|
+
return results;
|
|
524
|
+
}),
|
|
525
|
+
Match.when({ type: 'select' }, () => []),
|
|
526
|
+
Match.exhaustive,
|
|
527
|
+
);
|
|
268
528
|
};
|
package/src/reference.ts
CHANGED
|
@@ -170,13 +170,16 @@ export const isEncodedReference = (value: any): value is EncodedReference =>
|
|
|
170
170
|
export const EncodedReference = Object.freeze({
|
|
171
171
|
isEncodedReference,
|
|
172
172
|
getReferenceString: (value: EncodedReference): string => {
|
|
173
|
-
assertArgument(isEncodedReference(value), 'invalid reference');
|
|
173
|
+
assertArgument(isEncodedReference(value), 'value', 'invalid reference');
|
|
174
174
|
return value['/'];
|
|
175
175
|
},
|
|
176
176
|
toDXN: (value: EncodedReference): DXN => {
|
|
177
177
|
return DXN.parse(EncodedReference.getReferenceString(value));
|
|
178
178
|
},
|
|
179
179
|
fromDXN: (dxn: DXN): EncodedReference => {
|
|
180
|
-
return
|
|
180
|
+
return { '/': dxn.toString() };
|
|
181
|
+
},
|
|
182
|
+
fromLegacyTypename: (typename: string): EncodedReference => {
|
|
183
|
+
return { '/': DXN.fromTypename(typename).toString() };
|
|
181
184
|
},
|
|
182
185
|
});
|
package/src/space-id.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const createIdFromSpaceKey = async (spaceKey: PublicKey): Promise<SpaceId
|
|
|
18
18
|
return cachedValue;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const digest = await subtleCrypto.digest('SHA-256', spaceKey.asUint8Array());
|
|
21
|
+
const digest = await subtleCrypto.digest('SHA-256', spaceKey.asUint8Array() as Uint8Array<ArrayBuffer>);
|
|
22
22
|
|
|
23
23
|
const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);
|
|
24
24
|
const spaceId = SpaceId.encode(bytes);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/document-structure.ts", "../../../src/reference.ts", "../../../src/space-doc-version.ts", "../../../src/space-id.ts", "../../../src/foreign-key.ts", "../../../src/query/ast.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\nimport type { DXN, ObjectId } from '@dxos/keys';\nimport { visitValues } from '@dxos/util';\n\nimport { type RawString } from './automerge';\nimport type { ForeignKey } from './foreign-key';\nimport { isEncodedReference, type EncodedReference } from './reference';\nimport { type SpaceDocVersion } from './space-doc-version';\n\nexport type SpaceState = {\n // Url of the root automerge document.\n rootUrl?: string;\n};\n\n/**\n * Array indexes get converted to strings.\n */\nexport type ObjectProp = string;\nexport type ObjectPropPath = ObjectProp[];\n\n/**\n * Link to all documents that hold objects in the space.\n */\nexport interface DatabaseDirectory {\n version?: SpaceDocVersion;\n\n access?: {\n spaceKey: string;\n };\n /**\n * Objects inlined in the current document.\n */\n objects?: {\n [id: string]: ObjectStructure;\n };\n /**\n * Object id points to an automerge doc url where the object is embedded.\n */\n links?: {\n [echoId: string]: string | RawString;\n };\n\n /**\n * @deprecated\n * For backward compatibility.\n */\n experimental_spaceKey?: string;\n}\n\nexport const DatabaseDirectory = Object.freeze({\n /**\n * @returns Space key in hex of the space that owns the document. In hex format. Without 0x prefix.\n */\n getSpaceKey: (doc: DatabaseDirectory): string | null => {\n // experimental_spaceKey is set on old documents, new ones are created with doc.access.spaceKey\n const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;\n if (rawSpaceKey == null) {\n return null;\n }\n\n const rawKey = String(rawSpaceKey);\n invariant(!rawKey.startsWith('0x'), 'Space key must not start with 0x');\n return rawKey;\n },\n\n getInlineObject: (doc: DatabaseDirectory, id: ObjectId): ObjectStructure | undefined => {\n return doc.objects?.[id];\n },\n\n getLink: (doc: DatabaseDirectory, id: ObjectId): string | undefined => {\n return doc.links?.[id]?.toString();\n },\n\n make: ({\n spaceKey,\n objects,\n links,\n }: {\n spaceKey: string;\n objects?: Record<string, ObjectStructure>;\n links?: Record<string, RawString>;\n }): DatabaseDirectory => ({\n access: {\n spaceKey,\n },\n objects: objects ?? {},\n links: links ?? {},\n }),\n});\n\n/**\n * Representation of an ECHO object in an AM document.\n */\nexport type ObjectStructure = {\n // TODO(dmaretskyi): Missing in some cases.\n system?: ObjectSystem;\n\n meta: ObjectMeta;\n /**\n * User-defined data.\n * Adheres to schema in `system.type`\n */\n data: Record<string, any>;\n};\n\n// Helper methods to interact with the {@link ObjectStructure}.\nexport const ObjectStructure = Object.freeze({\n /**\n * @throws On invalid object structure.\n */\n getTypeReference: (object: ObjectStructure): EncodedReference | undefined => {\n return object.system?.type;\n },\n\n /**\n * @throws On invalid object structure.\n */\n getEntityKind: (object: ObjectStructure): 'object' | 'relation' => {\n const kind = object.system?.kind ?? 'object';\n invariant(kind === 'object' || kind === 'relation', 'Invalid kind');\n return kind;\n },\n\n isDeleted: (object: ObjectStructure): boolean => {\n return object.system?.deleted ?? false;\n },\n\n getRelationSource: (object: ObjectStructure): EncodedReference | undefined => {\n return object.system?.source;\n },\n\n getRelationTarget: (object: ObjectStructure): EncodedReference | undefined => {\n return object.system?.target;\n },\n\n /**\n * @returns All references in the data section of the object.\n */\n getAllOutgoingReferences: (object: ObjectStructure): { path: ObjectPropPath; reference: EncodedReference }[] => {\n const references: { path: ObjectPropPath; reference: EncodedReference }[] = [];\n const visit = (path: ObjectPropPath, value: unknown) => {\n if (isEncodedReference(value)) {\n references.push({ path, reference: value });\n } else {\n visitValues(value, (value, key) => visit([...path, String(key)], value));\n }\n };\n visitValues(object.data, (value, key) => visit([String(key)], value));\n return references;\n },\n\n makeObject: ({\n type,\n data,\n keys,\n }: {\n type: DXN.String;\n deleted?: boolean;\n keys?: ForeignKey[];\n data?: unknown;\n }): ObjectStructure => {\n return {\n system: {\n kind: 'object',\n type: { '/': type },\n },\n meta: {\n keys: keys ?? [],\n },\n data: data ?? {},\n };\n },\n\n makeRelation: ({\n type,\n source,\n target,\n deleted,\n keys,\n data,\n }: {\n type: DXN.String;\n source: EncodedReference;\n target: EncodedReference;\n deleted?: boolean;\n keys?: ForeignKey[];\n data?: unknown;\n }): ObjectStructure => {\n return {\n system: {\n kind: 'relation',\n type: { '/': type },\n source,\n target,\n deleted: deleted ?? false,\n },\n meta: {\n keys: keys ?? [],\n },\n data: data ?? {},\n };\n },\n});\n\n/**\n * Echo object metadata.\n */\nexport type ObjectMeta = {\n /**\n * Foreign keys.\n */\n keys: ForeignKey[];\n};\n\n/**\n * Automerge object system properties.\n * (Is automerge specific.)\n */\nexport type ObjectSystem = {\n /**\n * Entity kind.\n */\n kind?: 'object' | 'relation';\n\n /**\n * Object reference ('protobuf' protocol) type.\n */\n type?: EncodedReference;\n\n /**\n * Deletion marker.\n */\n deleted?: boolean;\n\n /**\n * Only for relations.\n */\n source?: EncodedReference;\n\n /**\n * Only for relations.w\n */\n target?: EncodedReference;\n};\n\n/**\n * Id property name.\n */\nexport const PROPERTY_ID = 'id';\n\n/**\n * Data namespace.\n * The key on {@link ObjectStructure} that contains the user-defined data.\n */\nexport const DATA_NAMESPACE = 'data';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { assertArgument } from '@dxos/invariant';\nimport { DXN, LOCAL_SPACE_TAG, type PublicKey } from '@dxos/keys';\nimport { type ObjectId } from '@dxos/protocols';\nimport { type Reference as ReferenceProto } from '@dxos/protocols/proto/dxos/echo/model/document';\n\n/**\n * Runtime representation of an reference in ECHO.\n * Implemented as a DXN, but we might extend it to other URIs in the future.\n * @deprecated Use `EncodedReference` instead.\n */\nexport class Reference {\n /**\n * Protocol references to runtime registered types.\n * @deprecated\n */\n static TYPE_PROTOCOL = 'protobuf';\n\n static fromDXN(dxn: DXN): Reference {\n switch (dxn.kind) {\n case DXN.kind.TYPE:\n return new Reference(dxn.parts[0], Reference.TYPE_PROTOCOL, 'dxos.org', dxn);\n case DXN.kind.ECHO:\n if (dxn.parts[0] === LOCAL_SPACE_TAG) {\n return new Reference(dxn.parts[1], undefined, undefined, dxn);\n } else {\n return new Reference(dxn.parts[1], undefined, dxn.parts[0], dxn);\n }\n default:\n return new Reference(dxn.parts[0], undefined, dxn.parts[0], dxn);\n }\n }\n\n static fromValue(value: ReferenceProto): Reference {\n return new Reference(value.objectId, value.protocol, value.host);\n }\n\n /**\n * Reference an object in the local space.\n */\n static localObjectReference(objectId: ObjectId): Reference {\n return new Reference(objectId);\n }\n\n /**\n * @deprecated\n */\n // TODO(dmaretskyi): Remove.\n static fromLegacyTypename(type: string): Reference {\n return new Reference(type, Reference.TYPE_PROTOCOL, 'dxos.org');\n }\n\n /**\n * @deprecated\n */\n // TODO(dmaretskyi): Remove\n static fromObjectIdAndSpaceKey(objectId: ObjectId, spaceKey: PublicKey): Reference {\n // TODO(dmaretskyi): FIX ME! This should be a space ID not a space key.\n return new Reference(objectId, undefined, spaceKey.toHex());\n }\n\n // prettier-ignore\n private constructor(\n // TODO(dmaretskyi): Remove and just leave DXN.\n private readonly _objectId: ObjectId,\n private readonly _protocol?: string,\n private readonly _host?: string,\n private readonly _dxn?: DXN,\n ) {}\n\n get dxn(): DXN | undefined {\n return this._dxn;\n }\n\n /**\n * @deprecated\n */\n // TODO(dmaretskyi): Remove.\n get objectId(): ObjectId {\n return this._objectId;\n }\n\n /**\n * @deprecated\n */\n // TODO(dmaretskyi): Remove.\n get protocol(): string | undefined {\n return this._protocol;\n }\n\n /**\n * @deprecated\n */\n // TODO(dmaretskyi): Remove.\n get host(): string | undefined {\n return this._host;\n }\n\n encode(): ReferenceProto {\n return { objectId: this.objectId, host: this.host, protocol: this.protocol };\n }\n\n // TODO(dmaretskyi): Remove in favor of `reference.dxn`.\n toDXN(): DXN {\n if (this._dxn) {\n return this._dxn;\n }\n\n if (this.protocol === Reference.TYPE_PROTOCOL) {\n return new DXN(DXN.kind.TYPE, [this.objectId]);\n } else {\n if (this.host) {\n // Host is assumed to be the space key.\n // The DXN should actually have the space ID.\n // TODO(dmaretskyi): Migrate to space id.\n return new DXN(DXN.kind.ECHO, [this.host, this.objectId]);\n } else {\n return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, this.objectId]);\n }\n }\n }\n}\n\n// TODO(dmaretskyi): Is this used anywhere?\nexport const REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';\n\n/**\n * Reference as it is stored in Automerge document.\n */\nexport type EncodedReference = {\n '/': string;\n};\n\n/**\n * @deprecated Use `EncodedReference.fromDXN` instead.\n */\nexport const encodeReference = (reference: Reference): EncodedReference => ({\n '/': reference.toDXN().toString(),\n});\n\n/**\n * @deprecated Use `EncodedReference.toDXN` instead.\n */\nexport const decodeReference = (value: any) => {\n if (typeof value !== 'object' || value === null || typeof value['/'] !== 'string') {\n throw new Error('Invalid reference');\n }\n const dxnString = value['/'];\n\n if (\n dxnString.length % 2 === 0 &&\n dxnString.slice(0, dxnString.length / 2) === dxnString.slice(dxnString.length / 2) &&\n dxnString.includes('dxn:echo')\n ) {\n throw new Error('Automerge bug detected!');\n }\n\n return Reference.fromDXN(DXN.parse(dxnString));\n};\n\n/**\n * @deprecated Use `EncodedReference.isEncodedReference` instead.\n */\nexport const isEncodedReference = (value: any): value is EncodedReference =>\n typeof value === 'object' && value !== null && Object.keys(value).length === 1 && typeof value['/'] === 'string';\n\nexport const EncodedReference = Object.freeze({\n isEncodedReference,\n getReferenceString: (value: EncodedReference): string => {\n assertArgument(isEncodedReference(value), 'invalid reference');\n return value['/'];\n },\n toDXN: (value: EncodedReference): DXN => {\n return DXN.parse(EncodedReference.getReferenceString(value));\n },\n fromDXN: (dxn: DXN): EncodedReference => {\n return encodeReference(Reference.fromDXN(dxn));\n },\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\n/**\n * Denotes the data version of the space automerge document as well as the leaf documents for each individual ECHO object.\n */\nexport type SpaceDocVersion = number & { __type: 'SpaceDocVersion' };\n\nexport const SpaceDocVersion = Object.freeze({\n /**\n * For the documents created before the versioning was introduced.\n */\n LEGACY: 0 as SpaceDocVersion,\n\n /**\n * Current version.\n */\n CURRENT: 1 as SpaceDocVersion,\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { subtleCrypto } from '@dxos/crypto';\nimport { PublicKey, SpaceId } from '@dxos/keys';\nimport { ComplexMap } from '@dxos/util';\n\nconst SPACE_IDS_CACHE = new ComplexMap<PublicKey, SpaceId>(PublicKey.hash);\n\n/**\n * Space keys are generated by creating a keypair, and then taking the first 20 bytes of the SHA-256 hash of the public key and encoding them to multibase RFC4648 base-32 format (prefixed with B, see Multibase Table).\n * Inspired by how ethereum addresses are derived.\n */\nexport const createIdFromSpaceKey = async (spaceKey: PublicKey): Promise<SpaceId> => {\n const cachedValue = SPACE_IDS_CACHE.get(spaceKey);\n if (cachedValue !== undefined) {\n return cachedValue;\n }\n\n const digest = await subtleCrypto.digest('SHA-256', spaceKey.asUint8Array());\n\n const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);\n const spaceId = SpaceId.encode(bytes);\n SPACE_IDS_CACHE.set(spaceKey, spaceId);\n return spaceId;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema, SchemaAST } from 'effect';\n\nconst ForeignKey_ = Schema.Struct({\n /**\n * Name of the foreign database/system.\n * E.g., `github.com`.\n */\n source: Schema.String,\n\n /**\n * Id within the foreign database.\n */\n // TODO(wittjosiah): This annotation is currently used to ensure id field shows up in forms.\n // TODO(dmaretskyi): `false` is not a valid value for the annotation.\n id: Schema.String.annotations({ [SchemaAST.IdentifierAnnotationId]: false }),\n});\n\nexport type ForeignKey = Schema.Schema.Type<typeof ForeignKey_>;\n\n/**\n * Reference to an object in a foreign database.\n */\nexport const ForeignKey: Schema.Schema<ForeignKey> = ForeignKey_;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { DXN, ObjectId } from '@dxos/keys';\n\nimport { ForeignKey } from '../foreign-key';\n\nconst TypenameSpecifier = Schema.Union(DXN.Schema, Schema.Null).annotations({\n description: 'DXN or null. Null means any type will match',\n});\n\n// NOTE: This pattern with 3 definitions per schema is need to make the types opaque, and circular references in AST to not cause compiler errors.\n\n/**\n * Filter by object type and properties.\n *\n * Clauses are combined using logical AND.\n */\n// TODO(burdon): Filter object vs. relation.\nconst FilterObject_ = Schema.Struct({\n type: Schema.Literal('object'),\n\n typename: TypenameSpecifier,\n\n id: Schema.optional(Schema.Array(ObjectId)),\n\n /**\n * Filter by property.\n * Must not include object ID.\n */\n props: Schema.Record({\n key: Schema.String.annotations({ description: 'Property name' }),\n value: Schema.suspend(() => Filter),\n }),\n\n /**\n * Objects that have any of the given foreign keys.\n */\n foreignKeys: Schema.optional(Schema.Array(ForeignKey)),\n\n // NOTE: Make sure to update `FilterStep.isNoop` if you change this.\n});\nexport interface FilterObject extends Schema.Schema.Type<typeof FilterObject_> {}\nexport const FilterObject: Schema.Schema<FilterObject> = FilterObject_;\n\nconst FilterCompare_ = Schema.Struct({\n type: Schema.Literal('compare'),\n operator: Schema.Literal('eq', 'neq', 'gt', 'gte', 'lt', 'lte'),\n value: Schema.Unknown,\n});\nexport interface FilterCompare extends Schema.Schema.Type<typeof FilterCompare_> {}\nexport const FilterCompare: Schema.Schema<FilterCompare> = FilterCompare_;\n\nconst FilterIn_ = Schema.Struct({\n type: Schema.Literal('in'),\n values: Schema.Array(Schema.Any),\n});\nexport interface FilterIn extends Schema.Schema.Type<typeof FilterIn_> {}\nexport const FilterIn: Schema.Schema<FilterIn> = FilterIn_;\n\nconst FilterRange_ = Schema.Struct({\n type: Schema.Literal('range'),\n from: Schema.Any,\n to: Schema.Any,\n});\nexport interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {}\nexport const FilterRange: Schema.Schema<FilterRange> = FilterRange_;\n\nconst FilterTextSearch_ = Schema.Struct({\n type: Schema.Literal('text-search'),\n text: Schema.String,\n searchKind: Schema.optional(Schema.Literal('full-text', 'vector')),\n});\nexport interface FilterTextSearch extends Schema.Schema.Type<typeof FilterTextSearch_> {}\nexport const FilterTextSearch: Schema.Schema<FilterTextSearch> = FilterTextSearch_;\n\nconst FilterNot_ = Schema.Struct({\n type: Schema.Literal('not'),\n filter: Schema.suspend(() => Filter),\n});\nexport interface FilterNot extends Schema.Schema.Type<typeof FilterNot_> {}\nexport const FilterNot: Schema.Schema<FilterNot> = FilterNot_;\n\nconst FilterAnd_ = Schema.Struct({\n type: Schema.Literal('and'),\n filters: Schema.Array(Schema.suspend(() => Filter)),\n});\nexport interface FilterAnd extends Schema.Schema.Type<typeof FilterAnd_> {}\nexport const FilterAnd: Schema.Schema<FilterAnd> = FilterAnd_;\n\nconst FilterOr_ = Schema.Struct({\n type: Schema.Literal('or'),\n filters: Schema.Array(Schema.suspend(() => Filter)),\n});\nexport interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {}\nexport const FilterOr: Schema.Schema<FilterOr> = FilterOr_;\n\nexport const Filter = Schema.Union(\n FilterObject,\n FilterTextSearch,\n FilterCompare,\n FilterIn,\n FilterRange,\n FilterNot,\n FilterAnd,\n FilterOr,\n);\nexport type Filter = Schema.Schema.Type<typeof Filter>;\n\n/**\n * Query objects by type, id, and/or predicates.\n */\nconst QuerySelectClause_ = Schema.Struct({\n type: Schema.Literal('select'),\n filter: Schema.suspend(() => Filter),\n});\nexport interface QuerySelectClause extends Schema.Schema.Type<typeof QuerySelectClause_> {}\nexport const QuerySelectClause: Schema.Schema<QuerySelectClause> = QuerySelectClause_;\n\n/**\n * Filter objects from selection.\n */\nconst QueryFilterClause_ = Schema.Struct({\n type: Schema.Literal('filter'),\n selection: Schema.suspend(() => Query),\n filter: Schema.suspend(() => Filter),\n});\nexport interface QueryFilterClause extends Schema.Schema.Type<typeof QueryFilterClause_> {}\nexport const QueryFilterClause: Schema.Schema<QueryFilterClause> = QueryFilterClause_;\n\n/**\n * Traverse references from an anchor object.\n */\nconst QueryReferenceTraversalClause_ = Schema.Struct({\n type: Schema.Literal('reference-traversal'),\n anchor: Schema.suspend(() => Query),\n property: Schema.String, // TODO(dmaretskyi): Change to EscapedPropPath.\n});\nexport interface QueryReferenceTraversalClause extends Schema.Schema.Type<typeof QueryReferenceTraversalClause_> {}\nexport const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversalClause> =\n QueryReferenceTraversalClause_;\n\n/**\n * Traverse incoming references to an anchor object.\n */\nconst QueryIncomingReferencesClause_ = Schema.Struct({\n type: Schema.Literal('incoming-references'),\n anchor: Schema.suspend(() => Query),\n property: Schema.String,\n typename: TypenameSpecifier,\n});\nexport interface QueryIncomingReferencesClause extends Schema.Schema.Type<typeof QueryIncomingReferencesClause_> {}\nexport const QueryIncomingReferencesClause: Schema.Schema<QueryIncomingReferencesClause> =\n QueryIncomingReferencesClause_;\n\n/**\n * Traverse relations connecting to an anchor object.\n */\nconst QueryRelationClause_ = Schema.Struct({\n type: Schema.Literal('relation'),\n anchor: Schema.suspend(() => Query),\n /**\n * outgoing: anchor is the source of the relation.\n * incoming: anchor is the target of the relation.\n * both: anchor is either the source or target of the relation.\n */\n direction: Schema.Literal('outgoing', 'incoming', 'both'),\n filter: Schema.optional(Schema.suspend(() => Filter)),\n});\nexport interface QueryRelationClause extends Schema.Schema.Type<typeof QueryRelationClause_> {}\nexport const QueryRelationClause: Schema.Schema<QueryRelationClause> = QueryRelationClause_;\n\n/**\n * Traverse into the source or target of a relation.\n */\nconst QueryRelationTraversalClause_ = Schema.Struct({\n type: Schema.Literal('relation-traversal'),\n anchor: Schema.suspend(() => Query),\n direction: Schema.Literal('source', 'target', 'both'),\n});\nexport interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {}\nexport const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause> = QueryRelationTraversalClause_;\n\n/**\n * Union of multiple queries.\n */\nconst QueryUnionClause_ = Schema.Struct({\n type: Schema.Literal('union'),\n queries: Schema.Array(Schema.suspend(() => Query)),\n});\nexport interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {}\nexport const QueryUnionClause: Schema.Schema<QueryUnionClause> = QueryUnionClause_;\n\n/**\n * Set difference of two queries.\n */\nconst QuerySetDifferenceClause_ = Schema.Struct({\n type: Schema.Literal('set-difference'),\n source: Schema.suspend(() => Query),\n exclude: Schema.suspend(() => Query),\n});\nexport interface QuerySetDifferenceClause extends Schema.Schema.Type<typeof QuerySetDifferenceClause_> {}\nexport const QuerySetDifferenceClause: Schema.Schema<QuerySetDifferenceClause> = QuerySetDifferenceClause_;\n\n/**\n * Add options to a query.\n */\nconst QueryOptionsClause_ = Schema.Struct({\n type: Schema.Literal('options'),\n query: Schema.suspend(() => Query),\n options: Schema.suspend(() => QueryOptions),\n});\nexport interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}\nexport const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;\n\nconst Query_ = Schema.Union(\n QuerySelectClause,\n QueryFilterClause,\n QueryReferenceTraversalClause,\n QueryIncomingReferencesClause,\n QueryRelationClause,\n QueryRelationTraversalClause,\n QueryUnionClause,\n QuerySetDifferenceClause,\n QueryOptionsClause,\n);\n\nexport type Query = Schema.Schema.Type<typeof Query_>;\nexport const Query: Schema.Schema<Query> = Query_;\n\nexport const QueryOptions = Schema.Struct({\n spaceIds: Schema.optional(Schema.Array(Schema.String)),\n deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),\n});\nexport interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}\n\nexport const visit = (query: Query, visitor: (node: Query) => void) => {\n switch (query.type) {\n case 'filter':\n visit(query.selection, visitor);\n break;\n case 'reference-traversal':\n visit(query.anchor, visitor);\n break;\n case 'incoming-references':\n visit(query.anchor, visitor);\n break;\n case 'relation':\n visit(query.anchor, visitor);\n break;\n case 'options':\n visit(query.query, visitor);\n break;\n case 'relation-traversal':\n visit(query.anchor, visitor);\n break;\n case 'union':\n query.queries.forEach((q) => visit(q, visitor));\n break;\n case 'set-difference':\n visit(query.source, visitor);\n visit(query.exclude, visitor);\n break;\n }\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,SAASA,iBAAiB;AAE1B,SAASC,mBAAmB;;;ACF5B,SAASC,sBAAsB;AAC/B,SAASC,KAAKC,uBAAuC;AAS9C,IAAMC,YAAN,MAAMA,WAAAA;EAKX;;;;;SAAOC,gBAAgB;;EAEvB,OAAOC,QAAQC,KAAqB;AAClC,YAAQA,IAAIC,MAAI;MACd,KAAKC,IAAID,KAAKE;A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AACHD,YAAMP,MAAMlB,QAAQ0B,OAAAA;AACpB;IACF,KAAK;AACHR,YAAMP,QAAQgB,QAAQ,CAACC,MAAMH,MAAMG,GAAGF,OAAAA,CAAAA;AACtC;IACF,KAAK;AACHD,YAAMP,MAAMJ,QAAQY,OAAAA;AACpBD,YAAMP,MAAMH,SAASW,OAAAA;AACrB;EACJ;AACF;",
|
|
6
|
-
"names": ["invariant", "visitValues", "assertArgument", "DXN", "LOCAL_SPACE_TAG", "Reference", "TYPE_PROTOCOL", "fromDXN", "dxn", "kind", "DXN", "TYPE", "parts", "ECHO", "LOCAL_SPACE_TAG", "undefined", "fromValue", "value", "objectId", "protocol", "host", "localObjectReference", "fromLegacyTypename", "type", "fromObjectIdAndSpaceKey", "spaceKey", "toHex", "_objectId", "_protocol", "_host", "_dxn", "encode", "toDXN", "REFERENCE_TYPE_TAG", "encodeReference", "reference", "toString", "decodeReference", "Error", "dxnString", "length", "slice", "includes", "parse", "isEncodedReference", "Object", "keys", "EncodedReference", "freeze", "getReferenceString", "assertArgument", "DatabaseDirectory", "Object", "freeze", "getSpaceKey", "doc", "rawSpaceKey", "access", "spaceKey", "experimental_spaceKey", "rawKey", "String", "invariant", "startsWith", "getInlineObject", "id", "objects", "getLink", "links", "toString", "make", "ObjectStructure", "getTypeReference", "object", "system", "type", "getEntityKind", "kind", "isDeleted", "deleted", "getRelationSource", "source", "getRelationTarget", "target", "getAllOutgoingReferences", "references", "visit", "path", "value", "isEncodedReference", "push", "reference", "visitValues", "key", "data", "makeObject", "keys", "meta", "makeRelation", "PROPERTY_ID", "DATA_NAMESPACE", "SpaceDocVersion", "Object", "freeze", "LEGACY", "CURRENT", "subtleCrypto", "PublicKey", "SpaceId", "ComplexMap", "SPACE_IDS_CACHE", "ComplexMap", "PublicKey", "hash", "createIdFromSpaceKey", "spaceKey", "cachedValue", "get", "undefined", "digest", "subtleCrypto", "asUint8Array", "bytes", "Uint8Array", "slice", "SpaceId", "byteLength", "spaceId", "encode", "set", "Schema", "SchemaAST", "ForeignKey_", "Schema", "Struct", "source", "String", "id", "annotations", "SchemaAST", "IdentifierAnnotationId", "ForeignKey", "Schema", "DXN", "ObjectId", "TypenameSpecifier", "Schema", "Union", "DXN", "Null", "annotations", "description", "FilterObject_", "Struct", "type", "Literal", "typename", "id", "optional", "Array", "ObjectId", "props", "Record", "key", "String", "value", "suspend", "Filter", "foreignKeys", "ForeignKey", "FilterObject", "FilterCompare_", "operator", "Unknown", "FilterCompare", "FilterIn_", "values", "Any", "FilterIn", "FilterRange_", "from", "to", "FilterRange", "FilterTextSearch_", "text", "searchKind", "FilterTextSearch", "FilterNot_", "filter", "FilterNot", "FilterAnd_", "filters", "FilterAnd", "FilterOr_", "FilterOr", "QuerySelectClause_", "QuerySelectClause", "QueryFilterClause_", "selection", "Query", "QueryFilterClause", "QueryReferenceTraversalClause_", "anchor", "property", "QueryReferenceTraversalClause", "QueryIncomingReferencesClause_", "QueryIncomingReferencesClause", "QueryRelationClause_", "direction", "QueryRelationClause", "QueryRelationTraversalClause_", "QueryRelationTraversalClause", "QueryUnionClause_", "queries", "QueryUnionClause", "QuerySetDifferenceClause_", "source", "exclude", "QuerySetDifferenceClause", "QueryOptionsClause_", "query", "options", "QueryOptions", "QueryOptionsClause", "Query_", "spaceIds", "deleted", "visit", "visitor", "forEach", "q"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/reference.ts":{"bytes":16981,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/document-structure.ts":{"bytes":15682,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/reference.ts","kind":"import-statement","original":"./reference"}],"format":"esm"},"src/space-doc-version.ts":{"bytes":1538,"imports":[],"format":"esm"},"src/space-id.ts":{"bytes":3511,"imports":[{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/foreign-key.ts":{"bytes":2428,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/query/ast.ts":{"bytes":26583,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/foreign-key.ts","kind":"import-statement","original":"../foreign-key"}],"format":"esm"},"src/query/index.ts":{"bytes":516,"imports":[{"path":"src/query/ast.ts","kind":"import-statement","original":"./ast"}],"format":"esm"},"src/index.ts":{"bytes":1011,"imports":[{"path":"src/document-structure.ts","kind":"import-statement","original":"./document-structure"},{"path":"src/reference.ts","kind":"import-statement","original":"./reference"},{"path":"src/space-doc-version.ts","kind":"import-statement","original":"./space-doc-version"},{"path":"src/space-id.ts","kind":"import-statement","original":"./space-id"},{"path":"src/foreign-key.ts","kind":"import-statement","original":"./foreign-key"},{"path":"src/query/index.ts","kind":"import-statement","original":"./query"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":34948},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"exports":["DATA_NAMESPACE","DatabaseDirectory","EncodedReference","ForeignKey","ObjectStructure","PROPERTY_ID","QueryAST","REFERENCE_TYPE_TAG","Reference","SpaceDocVersion","createIdFromSpaceKey","decodeReference","encodeReference","isEncodedReference"],"entryPoint":"src/index.ts","inputs":{"src/document-structure.ts":{"bytesInOutput":3028},"src/reference.ts":{"bytesInOutput":3669},"src/index.ts":{"bytesInOutput":0},"src/space-doc-version.ts":{"bytesInOutput":179},"src/space-id.ts":{"bytesInOutput":604},"src/foreign-key.ts":{"bytesInOutput":512},"src/query/ast.ts":{"bytesInOutput":6379},"src/query/index.ts":{"bytesInOutput":0}},"bytes":15030}}}
|