@dxos/echo-protocol 0.8.4-main.406dc2a → 0.8.4-main.40e3dcdf1b
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 +257 -58
- 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 +7 -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/index.d.ts +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/query/ast.d.ts +92 -21
- 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 +13 -11
- package/src/document-structure.ts +11 -1
- package/src/echo-feed-codec.ts +67 -0
- package/src/index.ts +4 -3
- package/src/query/ast.ts +148 -10
- package/src/reference.ts +4 -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 -613
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-protocol",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.40e3dcdf1b",
|
|
4
4
|
"description": "Core ECHO APIs.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
-
"repository":
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
8
11
|
"license": "MIT",
|
|
9
12
|
"author": "DXOS.org",
|
|
10
|
-
"sideEffects":
|
|
13
|
+
"sideEffects": false,
|
|
11
14
|
"type": "module",
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
17
|
"source": "./src/index.ts",
|
|
15
18
|
"types": "./dist/types/src/index.d.ts",
|
|
16
|
-
"
|
|
17
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
19
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -26,12 +28,12 @@
|
|
|
26
28
|
"src"
|
|
27
29
|
],
|
|
28
30
|
"dependencies": {
|
|
29
|
-
"effect": "3.
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
31
|
+
"effect": "3.19.16",
|
|
32
|
+
"@dxos/crypto": "0.8.4-main.40e3dcdf1b",
|
|
33
|
+
"@dxos/invariant": "0.8.4-main.40e3dcdf1b",
|
|
34
|
+
"@dxos/util": "0.8.4-main.40e3dcdf1b",
|
|
35
|
+
"@dxos/protocols": "0.8.4-main.40e3dcdf1b",
|
|
36
|
+
"@dxos/keys": "0.8.4-main.40e3dcdf1b"
|
|
35
37
|
},
|
|
36
38
|
"publishConfig": {
|
|
37
39
|
"access": "public"
|
|
@@ -137,6 +137,10 @@ export const ObjectStructure = Object.freeze({
|
|
|
137
137
|
return object.system?.target;
|
|
138
138
|
},
|
|
139
139
|
|
|
140
|
+
getParent: (object: ObjectStructure): EncodedReference | undefined => {
|
|
141
|
+
return object.system?.parent;
|
|
142
|
+
},
|
|
143
|
+
|
|
140
144
|
/**
|
|
141
145
|
* @returns All references in the data section of the object.
|
|
142
146
|
*/
|
|
@@ -248,13 +252,19 @@ export type ObjectSystem = {
|
|
|
248
252
|
*/
|
|
249
253
|
deleted?: boolean;
|
|
250
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Object parent.
|
|
257
|
+
* Objects with no parent are at the top level of the object hierarchy in the space.
|
|
258
|
+
*/
|
|
259
|
+
parent?: EncodedReference;
|
|
260
|
+
|
|
251
261
|
/**
|
|
252
262
|
* Only for relations.
|
|
253
263
|
*/
|
|
254
264
|
source?: EncodedReference;
|
|
255
265
|
|
|
256
266
|
/**
|
|
257
|
-
* Only for relations.
|
|
267
|
+
* Only for relations.
|
|
258
268
|
*/
|
|
259
269
|
target?: EncodedReference;
|
|
260
270
|
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { FeedProtocol } from '@dxos/protocols';
|
|
6
|
+
|
|
7
|
+
import type { ForeignKey } from './foreign-key';
|
|
8
|
+
|
|
9
|
+
/** Property name for meta when object is serialized to JSON. Matches @dxos/echo/internal ATTR_META. */
|
|
10
|
+
const ATTR_META = '@meta';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Codec for ECHO objects in feed block payload: JSON object ↔ UTF-8 bytes.
|
|
14
|
+
* Encodes with queue position stripped; decodes with optional position injection.
|
|
15
|
+
*/
|
|
16
|
+
export class EchoFeedCodec {
|
|
17
|
+
static readonly #encoder = new TextEncoder();
|
|
18
|
+
static readonly #decoder = new TextDecoder();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Prepares a value for feed storage (strips queue position from metadata) and encodes to bytes.
|
|
22
|
+
*/
|
|
23
|
+
static encode(value: Record<string, unknown>): Uint8Array {
|
|
24
|
+
const prepared = EchoFeedCodec.#stripQueuePosition(value);
|
|
25
|
+
return EchoFeedCodec.#encoder.encode(JSON.stringify(prepared));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Decodes feed block bytes to a JSON value.
|
|
30
|
+
* If position is provided, injects queue position into the decoded object's metadata.
|
|
31
|
+
*/
|
|
32
|
+
static decode(data: Uint8Array, position?: number): Record<string, unknown> {
|
|
33
|
+
const decoded = JSON.parse(EchoFeedCodec.#decoder.decode(data));
|
|
34
|
+
if (position !== undefined && typeof decoded === 'object' && decoded !== null) {
|
|
35
|
+
EchoFeedCodec.#setQueuePosition(decoded, position);
|
|
36
|
+
}
|
|
37
|
+
return decoded;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static #stripQueuePosition(value: Record<string, unknown>): Record<string, unknown> {
|
|
41
|
+
if (typeof value !== 'object' || value === null) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
const obj = structuredClone(value);
|
|
45
|
+
const meta = obj[ATTR_META] as { keys?: ForeignKey[] } | undefined;
|
|
46
|
+
if (meta?.keys?.some((key: ForeignKey) => key.source === FeedProtocol.KEY_QUEUE_POSITION)) {
|
|
47
|
+
meta.keys = meta.keys.filter((key: ForeignKey) => key.source !== FeedProtocol.KEY_QUEUE_POSITION);
|
|
48
|
+
}
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static #setQueuePosition(obj: Record<string, any>, position: number): void {
|
|
53
|
+
obj[ATTR_META] ??= { keys: [] };
|
|
54
|
+
obj[ATTR_META]!.keys ??= [];
|
|
55
|
+
const keys = obj[ATTR_META]!.keys!;
|
|
56
|
+
for (let i = 0; i < keys.length; i++) {
|
|
57
|
+
if (keys[i].source === FeedProtocol.KEY_QUEUE_POSITION) {
|
|
58
|
+
keys.splice(i, 1);
|
|
59
|
+
i--;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
keys.push({
|
|
63
|
+
source: FeedProtocol.KEY_QUEUE_POSITION,
|
|
64
|
+
id: position.toString(),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export type * from './collection-sync';
|
|
5
6
|
export * from './document-structure';
|
|
7
|
+
export * from './echo-feed-codec';
|
|
8
|
+
export * from './foreign-key';
|
|
9
|
+
export * from './query';
|
|
6
10
|
export * from './reference';
|
|
7
11
|
export * from './space-doc-version';
|
|
8
|
-
export type * from './collection-sync';
|
|
9
12
|
export * from './space-id';
|
|
10
|
-
export * from './foreign-key';
|
|
11
|
-
export * from './query';
|
package/src/query/ast.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { DXN, ObjectId } from '@dxos/keys';
|
|
|
10
10
|
import { ForeignKey } from '../foreign-key';
|
|
11
11
|
|
|
12
12
|
const TypenameSpecifier = Schema.Union(DXN.Schema, Schema.Null).annotations({
|
|
13
|
-
description: 'DXN or null
|
|
13
|
+
description: 'DXN or null; null matches any type',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
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.
|
|
@@ -75,7 +75,9 @@ const FilterContains_ = Schema.Struct({
|
|
|
75
75
|
type: Schema.Literal('contains'),
|
|
76
76
|
value: Schema.Any,
|
|
77
77
|
});
|
|
78
|
+
|
|
78
79
|
export interface FilterContains extends Schema.Schema.Type<typeof FilterContains_> {}
|
|
80
|
+
|
|
79
81
|
/**
|
|
80
82
|
* Predicate for an array property to contain the provided value.
|
|
81
83
|
* Nested objects are matched using strict structural matching.
|
|
@@ -89,6 +91,7 @@ const FilterTag_ = Schema.Struct({
|
|
|
89
91
|
type: Schema.Literal('tag'),
|
|
90
92
|
tag: Schema.String, // TODO(burdon): Make OR-collection?
|
|
91
93
|
});
|
|
94
|
+
|
|
92
95
|
export interface FilterTag extends Schema.Schema.Type<typeof FilterTag_> {}
|
|
93
96
|
export const FilterTag: Schema.Schema<FilterTag> = FilterTag_;
|
|
94
97
|
|
|
@@ -100,6 +103,7 @@ const FilterRange_ = Schema.Struct({
|
|
|
100
103
|
from: Schema.Any,
|
|
101
104
|
to: Schema.Any,
|
|
102
105
|
});
|
|
106
|
+
|
|
103
107
|
export interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {}
|
|
104
108
|
export const FilterRange: Schema.Schema<FilterRange> = FilterRange_;
|
|
105
109
|
|
|
@@ -111,6 +115,7 @@ const FilterTextSearch_ = Schema.Struct({
|
|
|
111
115
|
text: Schema.String,
|
|
112
116
|
searchKind: Schema.optional(Schema.Literal('full-text', 'vector')),
|
|
113
117
|
});
|
|
118
|
+
|
|
114
119
|
export interface FilterTextSearch extends Schema.Schema.Type<typeof FilterTextSearch_> {}
|
|
115
120
|
export const FilterTextSearch: Schema.Schema<FilterTextSearch> = FilterTextSearch_;
|
|
116
121
|
|
|
@@ -121,6 +126,7 @@ const FilterNot_ = Schema.Struct({
|
|
|
121
126
|
type: Schema.Literal('not'),
|
|
122
127
|
filter: Schema.suspend(() => Filter),
|
|
123
128
|
});
|
|
129
|
+
|
|
124
130
|
export interface FilterNot extends Schema.Schema.Type<typeof FilterNot_> {}
|
|
125
131
|
export const FilterNot: Schema.Schema<FilterNot> = FilterNot_;
|
|
126
132
|
|
|
@@ -131,6 +137,7 @@ const FilterAnd_ = Schema.Struct({
|
|
|
131
137
|
type: Schema.Literal('and'),
|
|
132
138
|
filters: Schema.Array(Schema.suspend(() => Filter)),
|
|
133
139
|
});
|
|
140
|
+
|
|
134
141
|
export interface FilterAnd extends Schema.Schema.Type<typeof FilterAnd_> {}
|
|
135
142
|
export const FilterAnd: Schema.Schema<FilterAnd> = FilterAnd_;
|
|
136
143
|
|
|
@@ -141,6 +148,7 @@ const FilterOr_ = Schema.Struct({
|
|
|
141
148
|
type: Schema.Literal('or'),
|
|
142
149
|
filters: Schema.Array(Schema.suspend(() => Filter)),
|
|
143
150
|
});
|
|
151
|
+
|
|
144
152
|
export interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {}
|
|
145
153
|
export const FilterOr: Schema.Schema<FilterOr> = FilterOr_;
|
|
146
154
|
|
|
@@ -158,7 +166,8 @@ export const Filter = Schema.Union(
|
|
|
158
166
|
FilterNot,
|
|
159
167
|
FilterAnd,
|
|
160
168
|
FilterOr,
|
|
161
|
-
).annotations({ identifier: 'dxos.
|
|
169
|
+
).annotations({ identifier: 'org.dxos.schema.filter' });
|
|
170
|
+
|
|
162
171
|
export type Filter = Schema.Schema.Type<typeof Filter>;
|
|
163
172
|
|
|
164
173
|
/**
|
|
@@ -168,6 +177,7 @@ const QuerySelectClause_ = Schema.Struct({
|
|
|
168
177
|
type: Schema.Literal('select'),
|
|
169
178
|
filter: Schema.suspend(() => Filter),
|
|
170
179
|
});
|
|
180
|
+
|
|
171
181
|
export interface QuerySelectClause extends Schema.Schema.Type<typeof QuerySelectClause_> {}
|
|
172
182
|
export const QuerySelectClause: Schema.Schema<QuerySelectClause> = QuerySelectClause_;
|
|
173
183
|
|
|
@@ -179,6 +189,7 @@ const QueryFilterClause_ = Schema.Struct({
|
|
|
179
189
|
selection: Schema.suspend(() => Query),
|
|
180
190
|
filter: Schema.suspend(() => Filter),
|
|
181
191
|
});
|
|
192
|
+
|
|
182
193
|
export interface QueryFilterClause extends Schema.Schema.Type<typeof QueryFilterClause_> {}
|
|
183
194
|
export const QueryFilterClause: Schema.Schema<QueryFilterClause> = QueryFilterClause_;
|
|
184
195
|
|
|
@@ -190,6 +201,7 @@ const QueryReferenceTraversalClause_ = Schema.Struct({
|
|
|
190
201
|
anchor: Schema.suspend(() => Query),
|
|
191
202
|
property: Schema.String, // TODO(dmaretskyi): Change to EscapedPropPath.
|
|
192
203
|
});
|
|
204
|
+
|
|
193
205
|
export interface QueryReferenceTraversalClause extends Schema.Schema.Type<typeof QueryReferenceTraversalClause_> {}
|
|
194
206
|
export const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversalClause> =
|
|
195
207
|
QueryReferenceTraversalClause_;
|
|
@@ -200,9 +212,14 @@ export const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversa
|
|
|
200
212
|
const QueryIncomingReferencesClause_ = Schema.Struct({
|
|
201
213
|
type: Schema.Literal('incoming-references'),
|
|
202
214
|
anchor: Schema.suspend(() => Query),
|
|
203
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Property path where the reference is located.
|
|
217
|
+
* If null, matches references from any property.
|
|
218
|
+
*/
|
|
219
|
+
property: Schema.NullOr(Schema.String),
|
|
204
220
|
typename: TypenameSpecifier,
|
|
205
221
|
});
|
|
222
|
+
|
|
206
223
|
export interface QueryIncomingReferencesClause extends Schema.Schema.Type<typeof QueryIncomingReferencesClause_> {}
|
|
207
224
|
export const QueryIncomingReferencesClause: Schema.Schema<QueryIncomingReferencesClause> =
|
|
208
225
|
QueryIncomingReferencesClause_;
|
|
@@ -221,6 +238,7 @@ const QueryRelationClause_ = Schema.Struct({
|
|
|
221
238
|
direction: Schema.Literal('outgoing', 'incoming', 'both'),
|
|
222
239
|
filter: Schema.optional(Schema.suspend(() => Filter)),
|
|
223
240
|
});
|
|
241
|
+
|
|
224
242
|
export interface QueryRelationClause extends Schema.Schema.Type<typeof QueryRelationClause_> {}
|
|
225
243
|
export const QueryRelationClause: Schema.Schema<QueryRelationClause> = QueryRelationClause_;
|
|
226
244
|
|
|
@@ -232,9 +250,27 @@ const QueryRelationTraversalClause_ = Schema.Struct({
|
|
|
232
250
|
anchor: Schema.suspend(() => Query),
|
|
233
251
|
direction: Schema.Literal('source', 'target', 'both'),
|
|
234
252
|
});
|
|
253
|
+
|
|
235
254
|
export interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {}
|
|
236
255
|
export const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause> = QueryRelationTraversalClause_;
|
|
237
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Traverse parent-child hierarchy.
|
|
259
|
+
*/
|
|
260
|
+
const QueryHierarchyTraversalClause_ = Schema.Struct({
|
|
261
|
+
type: Schema.Literal('hierarchy-traversal'),
|
|
262
|
+
anchor: Schema.suspend(() => Query),
|
|
263
|
+
/**
|
|
264
|
+
* to-parent: traverse from child to parent.
|
|
265
|
+
* to-children: traverse from parent to children.
|
|
266
|
+
*/
|
|
267
|
+
direction: Schema.Literal('to-parent', 'to-children'),
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
export interface QueryHierarchyTraversalClause extends Schema.Schema.Type<typeof QueryHierarchyTraversalClause_> {}
|
|
271
|
+
export const QueryHierarchyTraversalClause: Schema.Schema<QueryHierarchyTraversalClause> =
|
|
272
|
+
QueryHierarchyTraversalClause_;
|
|
273
|
+
|
|
238
274
|
/**
|
|
239
275
|
* Union of multiple queries.
|
|
240
276
|
*/
|
|
@@ -242,6 +278,7 @@ const QueryUnionClause_ = Schema.Struct({
|
|
|
242
278
|
type: Schema.Literal('union'),
|
|
243
279
|
queries: Schema.Array(Schema.suspend(() => Query)),
|
|
244
280
|
});
|
|
281
|
+
|
|
245
282
|
export interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {}
|
|
246
283
|
export const QueryUnionClause: Schema.Schema<QueryUnionClause> = QueryUnionClause_;
|
|
247
284
|
|
|
@@ -253,6 +290,7 @@ const QuerySetDifferenceClause_ = Schema.Struct({
|
|
|
253
290
|
source: Schema.suspend(() => Query),
|
|
254
291
|
exclude: Schema.suspend(() => Query),
|
|
255
292
|
});
|
|
293
|
+
|
|
256
294
|
export interface QuerySetDifferenceClause extends Schema.Schema.Type<typeof QuerySetDifferenceClause_> {}
|
|
257
295
|
export const QuerySetDifferenceClause: Schema.Schema<QuerySetDifferenceClause> = QuerySetDifferenceClause_;
|
|
258
296
|
|
|
@@ -269,7 +307,14 @@ const Order_ = Schema.Union(
|
|
|
269
307
|
property: Schema.String,
|
|
270
308
|
direction: OrderDirection,
|
|
271
309
|
}),
|
|
310
|
+
Schema.Struct({
|
|
311
|
+
// Order by relevance rank (for FTS/vector search results).
|
|
312
|
+
// Default direction is 'desc' (higher rank = better match first).
|
|
313
|
+
kind: Schema.Literal('rank'),
|
|
314
|
+
direction: OrderDirection,
|
|
315
|
+
}),
|
|
272
316
|
);
|
|
317
|
+
|
|
273
318
|
export type Order = Schema.Schema.Type<typeof Order_>;
|
|
274
319
|
export const Order: Schema.Schema<Order> = Order_;
|
|
275
320
|
|
|
@@ -282,6 +327,7 @@ const QueryOrderClause_ = Schema.Struct({
|
|
|
282
327
|
query: Schema.suspend(() => Query),
|
|
283
328
|
order: Schema.Array(Order),
|
|
284
329
|
});
|
|
330
|
+
|
|
285
331
|
export interface QueryOrderClause extends Schema.Schema.Type<typeof QueryOrderClause_> {}
|
|
286
332
|
export const QueryOrderClause: Schema.Schema<QueryOrderClause> = QueryOrderClause_;
|
|
287
333
|
|
|
@@ -293,9 +339,37 @@ const QueryOptionsClause_ = Schema.Struct({
|
|
|
293
339
|
query: Schema.suspend(() => Query),
|
|
294
340
|
options: Schema.suspend(() => QueryOptions),
|
|
295
341
|
});
|
|
342
|
+
|
|
296
343
|
export interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}
|
|
297
344
|
export const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;
|
|
298
345
|
|
|
346
|
+
/**
|
|
347
|
+
* Limit the number of results.
|
|
348
|
+
*/
|
|
349
|
+
const QueryLimitClause_ = Schema.Struct({
|
|
350
|
+
type: Schema.Literal('limit'),
|
|
351
|
+
query: Schema.suspend(() => Query),
|
|
352
|
+
limit: Schema.Number,
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
export interface QueryLimitClause extends Schema.Schema.Type<typeof QueryLimitClause_> {}
|
|
356
|
+
export const QueryLimitClause: Schema.Schema<QueryLimitClause> = QueryLimitClause_;
|
|
357
|
+
|
|
358
|
+
export const QueryFromClause_ = Schema.Struct({
|
|
359
|
+
type: Schema.Literal('from'),
|
|
360
|
+
query: Schema.suspend(() => Query),
|
|
361
|
+
from: Schema.Union(
|
|
362
|
+
Schema.TaggedStruct('scope', {
|
|
363
|
+
scope: Schema.suspend(() => Scope),
|
|
364
|
+
}),
|
|
365
|
+
Schema.TaggedStruct('query', {
|
|
366
|
+
query: Schema.suspend(() => Query),
|
|
367
|
+
}),
|
|
368
|
+
),
|
|
369
|
+
});
|
|
370
|
+
export interface QueryFromClause extends Schema.Schema.Type<typeof QueryFromClause_> {}
|
|
371
|
+
export const QueryFromClause: Schema.Schema<QueryFromClause> = QueryFromClause_;
|
|
372
|
+
|
|
299
373
|
const Query_ = Schema.Union(
|
|
300
374
|
QuerySelectClause,
|
|
301
375
|
QueryFilterClause,
|
|
@@ -303,16 +377,31 @@ const Query_ = Schema.Union(
|
|
|
303
377
|
QueryIncomingReferencesClause,
|
|
304
378
|
QueryRelationClause,
|
|
305
379
|
QueryRelationTraversalClause,
|
|
380
|
+
QueryHierarchyTraversalClause,
|
|
306
381
|
QueryUnionClause,
|
|
307
382
|
QuerySetDifferenceClause,
|
|
308
383
|
QueryOrderClause,
|
|
309
384
|
QueryOptionsClause,
|
|
310
|
-
|
|
385
|
+
QueryLimitClause,
|
|
386
|
+
QueryFromClause,
|
|
387
|
+
).annotations({ identifier: 'org.dxos.schema.query' });
|
|
311
388
|
|
|
312
389
|
export type Query = Schema.Schema.Type<typeof Query_>;
|
|
313
390
|
export const Query: Schema.Schema<Query> = Query_;
|
|
314
391
|
|
|
315
392
|
export const QueryOptions = Schema.Struct({
|
|
393
|
+
/**
|
|
394
|
+
* Nested select statements will use this option to filter deleted objects.
|
|
395
|
+
*/
|
|
396
|
+
deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
export interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Specifies the scope of the data to query from.
|
|
403
|
+
*/
|
|
404
|
+
export const Scope = Schema.Struct({
|
|
316
405
|
/**
|
|
317
406
|
* The nested select statemets will select from the given spaces.
|
|
318
407
|
*
|
|
@@ -320,19 +409,19 @@ export const QueryOptions = Schema.Struct({
|
|
|
320
409
|
*/
|
|
321
410
|
spaceIds: Schema.optional(Schema.Array(Schema.String)),
|
|
322
411
|
|
|
412
|
+
/**
|
|
413
|
+
* If true, the nested select statements will select from all queues in the spaces specified by `spaceIds`.
|
|
414
|
+
*/
|
|
415
|
+
allQueuesFromSpaces: Schema.optional(Schema.Boolean),
|
|
416
|
+
|
|
323
417
|
/**
|
|
324
418
|
* The nested select statemets will select from the given queues.
|
|
325
419
|
*
|
|
326
420
|
* NOTE: Spaces and queues are unioned together if both are specified.
|
|
327
421
|
*/
|
|
328
422
|
queues: Schema.optional(Schema.Array(DXN.Schema)),
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Nested select statements will use this option to filter deleted objects.
|
|
332
|
-
*/
|
|
333
|
-
deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),
|
|
334
423
|
});
|
|
335
|
-
export interface
|
|
424
|
+
export interface Scope extends Schema.Schema.Type<typeof Scope> {}
|
|
336
425
|
|
|
337
426
|
export const visit = (query: Query, visitor: (node: Query) => void) => {
|
|
338
427
|
visitor(query);
|
|
@@ -344,17 +433,57 @@ export const visit = (query: Query, visitor: (node: Query) => void) => {
|
|
|
344
433
|
Match.when({ type: 'relation' }, ({ anchor }) => visit(anchor, visitor)),
|
|
345
434
|
Match.when({ type: 'options' }, ({ query }) => visit(query, visitor)),
|
|
346
435
|
Match.when({ type: 'relation-traversal' }, ({ anchor }) => visit(anchor, visitor)),
|
|
436
|
+
Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => visit(anchor, visitor)),
|
|
347
437
|
Match.when({ type: 'union' }, ({ queries }) => queries.forEach((q) => visit(q, visitor))),
|
|
348
438
|
Match.when({ type: 'set-difference' }, ({ source, exclude }) => {
|
|
349
439
|
visit(source, visitor);
|
|
350
440
|
visit(exclude, visitor);
|
|
351
441
|
}),
|
|
352
442
|
Match.when({ type: 'order' }, ({ query }) => visit(query, visitor)),
|
|
443
|
+
Match.when({ type: 'limit' }, ({ query }) => visit(query, visitor)),
|
|
444
|
+
Match.when({ type: 'from' }, (node) => {
|
|
445
|
+
visit(node.query, visitor);
|
|
446
|
+
if (node.from._tag === 'query') {
|
|
447
|
+
visit(node.from.query, visitor);
|
|
448
|
+
}
|
|
449
|
+
}),
|
|
353
450
|
Match.when({ type: 'select' }, () => {}),
|
|
354
451
|
Match.exhaustive,
|
|
355
452
|
);
|
|
356
453
|
};
|
|
357
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Recursively transforms a query tree bottom-up.
|
|
457
|
+
* The mapper receives each node with its children already transformed.
|
|
458
|
+
*/
|
|
459
|
+
export const map = (query: Query, mapper: (node: Query) => Query): Query => {
|
|
460
|
+
const mapped: Query = Match.value(query).pipe(
|
|
461
|
+
Match.when({ type: 'filter' }, (node) => ({ ...node, selection: map(node.selection, mapper) })),
|
|
462
|
+
Match.when({ type: 'reference-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
463
|
+
Match.when({ type: 'incoming-references' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
464
|
+
Match.when({ type: 'relation' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
465
|
+
Match.when({ type: 'relation-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
466
|
+
Match.when({ type: 'hierarchy-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),
|
|
467
|
+
Match.when({ type: 'options' }, (node) => ({ ...node, query: map(node.query, mapper) })),
|
|
468
|
+
Match.when({ type: 'order' }, (node) => ({ ...node, query: map(node.query, mapper) })),
|
|
469
|
+
Match.when({ type: 'limit' }, (node) => ({ ...node, query: map(node.query, mapper) })),
|
|
470
|
+
Match.when({ type: 'from' }, (node) => ({
|
|
471
|
+
...node,
|
|
472
|
+
query: map(node.query, mapper),
|
|
473
|
+
...(node.from._tag === 'query' ? { from: { _tag: 'query' as const, query: map(node.from.query, mapper) } } : {}),
|
|
474
|
+
})),
|
|
475
|
+
Match.when({ type: 'union' }, (node) => ({ ...node, queries: node.queries.map((q) => map(q, mapper)) })),
|
|
476
|
+
Match.when({ type: 'set-difference' }, (node) => ({
|
|
477
|
+
...node,
|
|
478
|
+
source: map(node.source, mapper),
|
|
479
|
+
exclude: map(node.exclude, mapper),
|
|
480
|
+
})),
|
|
481
|
+
Match.when({ type: 'select' }, (node) => node),
|
|
482
|
+
Match.exhaustive,
|
|
483
|
+
);
|
|
484
|
+
return mapper(mapped);
|
|
485
|
+
};
|
|
486
|
+
|
|
358
487
|
export const fold = <T>(query: Query, reducer: (node: Query) => T): T[] => {
|
|
359
488
|
return Match.value(query).pipe(
|
|
360
489
|
Match.withReturnType<T[]>(),
|
|
@@ -364,11 +493,20 @@ export const fold = <T>(query: Query, reducer: (node: Query) => T): T[] => {
|
|
|
364
493
|
Match.when({ type: 'relation' }, ({ anchor }) => fold(anchor, reducer)),
|
|
365
494
|
Match.when({ type: 'options' }, ({ query }) => fold(query, reducer)),
|
|
366
495
|
Match.when({ type: 'relation-traversal' }, ({ anchor }) => fold(anchor, reducer)),
|
|
496
|
+
Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => fold(anchor, reducer)),
|
|
367
497
|
Match.when({ type: 'union' }, ({ queries }) => queries.flatMap((q) => fold(q, reducer))),
|
|
368
498
|
Match.when({ type: 'set-difference' }, ({ source, exclude }) =>
|
|
369
499
|
fold(source, reducer).concat(fold(exclude, reducer)),
|
|
370
500
|
),
|
|
371
501
|
Match.when({ type: 'order' }, ({ query }) => fold(query, reducer)),
|
|
502
|
+
Match.when({ type: 'limit' }, ({ query }) => fold(query, reducer)),
|
|
503
|
+
Match.when({ type: 'from' }, (node) => {
|
|
504
|
+
const results = fold(node.query, reducer);
|
|
505
|
+
if (node.from._tag === 'query') {
|
|
506
|
+
return results.concat(fold(node.from.query, reducer));
|
|
507
|
+
}
|
|
508
|
+
return results;
|
|
509
|
+
}),
|
|
372
510
|
Match.when({ type: 'select' }, () => []),
|
|
373
511
|
Match.exhaustive,
|
|
374
512
|
);
|
package/src/reference.ts
CHANGED
|
@@ -177,6 +177,9 @@ export const EncodedReference = Object.freeze({
|
|
|
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
|
});
|
|
@@ -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 { type EncodedReference, isEncodedReference } 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 getTags: (object: ObjectStructure): string[] => {\n return object.meta.tags ?? [];\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 * Tags.\n * An array of DXNs of Tag objects within the space.\n *\n * NOTE: Optional for backwards compatibilty.\n */\n tags?: string[];\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), '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() as Uint8Array<ArrayBuffer>);\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 * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\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. Use a different 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 * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\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\n/**\n * Compare.\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\n/**\n * In.\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\n/**\n * Contains.\n */\nconst FilterContains_ = Schema.Struct({\n type: Schema.Literal('contains'),\n value: Schema.Any,\n});\nexport interface FilterContains extends Schema.Schema.Type<typeof FilterContains_> {}\n/**\n * Predicate for an array property to contain the provided value.\n * Nested objects are matched using strict structural matching.\n */\nexport const FilterContains: Schema.Schema<FilterContains> = FilterContains_;\n\n/**\n * Filters objects that have certain tag.\n */\nconst FilterTag_ = Schema.Struct({\n type: Schema.Literal('tag'),\n tag: Schema.String, // TODO(burdon): Make OR-collection?\n});\nexport interface FilterTag extends Schema.Schema.Type<typeof FilterTag_> {}\nexport const FilterTag: Schema.Schema<FilterTag> = FilterTag_;\n\n/**\n * Range.\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\n/**\n * Text search.\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\n/**\n * Not.\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\n/**\n * And.\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\n/**\n * Or.\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\n/**\n * Union of filters.\n */\nexport const Filter = Schema.Union(\n FilterObject,\n FilterCompare,\n FilterIn,\n FilterContains,\n FilterTag,\n FilterRange,\n FilterTextSearch,\n FilterNot,\n FilterAnd,\n FilterOr,\n).annotations({ identifier: 'dxos.org/schema/Filter' });\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\nexport const OrderDirection = Schema.Literal('asc', 'desc');\nexport type OrderDirection = Schema.Schema.Type<typeof OrderDirection>;\n\nconst Order_ = Schema.Union(\n Schema.Struct({\n // How database wants to order them (in practice - by id).\n kind: Schema.Literal('natural'),\n }),\n Schema.Struct({\n kind: Schema.Literal('property'),\n property: Schema.String,\n direction: OrderDirection,\n }),\n);\nexport type Order = Schema.Schema.Type<typeof Order_>;\nexport const Order: Schema.Schema<Order> = Order_;\n\n/**\n * Order the query results.\n * Left-to-right the orders dominate.\n */\nconst QueryOrderClause_ = Schema.Struct({\n type: Schema.Literal('order'),\n query: Schema.suspend(() => Query),\n order: Schema.Array(Order),\n});\nexport interface QueryOrderClause extends Schema.Schema.Type<typeof QueryOrderClause_> {}\nexport const QueryOrderClause: Schema.Schema<QueryOrderClause> = QueryOrderClause_;\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 QueryOrderClause,\n QueryOptionsClause,\n).annotations({ identifier: 'dxos.org/schema/Query' });\n\nexport type Query = Schema.Schema.Type<typeof Query_>;\nexport const Query: Schema.Schema<Query> = Query_;\n\nexport const QueryOptions = Schema.Struct({\n /**\n * The nested select statemets will select from the given spaces.\n *\n * NOTE: Spaces and queues are unioned together if both are specified.\n */\n spaceIds: Schema.optional(Schema.Array(Schema.String)),\n\n /**\n * The nested select statemets will select from the given queues.\n *\n * NOTE: Spaces and queues are unioned together if both are specified.\n */\n queues: Schema.optional(Schema.Array(DXN.Schema)),\n\n /**\n * Nested select statements will use this option to filter deleted objects.\n */\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 visitor(query);\n\n Match.value(query).pipe(\n Match.when({ type: 'filter' }, ({ selection }) => visit(selection, visitor)),\n Match.when({ type: 'reference-traversal' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'incoming-references' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'relation' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'options' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'relation-traversal' }, ({ anchor }) => visit(anchor, visitor)),\n Match.when({ type: 'union' }, ({ queries }) => queries.forEach((q) => visit(q, visitor))),\n Match.when({ type: 'set-difference' }, ({ source, exclude }) => {\n visit(source, visitor);\n visit(exclude, visitor);\n }),\n Match.when({ type: 'order' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'select' }, () => {}),\n Match.exhaustive,\n );\n};\n\nexport const fold = <T>(query: Query, reducer: (node: Query) => T): T[] => {\n return Match.value(query).pipe(\n Match.withReturnType<T[]>(),\n Match.when({ type: 'filter' }, ({ selection }) => fold(selection, reducer)),\n Match.when({ type: 'reference-traversal' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'incoming-references' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'relation' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'options' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'relation-traversal' }, ({ anchor }) => fold(anchor, reducer)),\n Match.when({ type: 'union' }, ({ queries }) => queries.flatMap((q) => fold(q, reducer))),\n Match.when({ type: 'set-difference' }, ({ source, exclude }) =>\n fold(source, reducer).concat(fold(exclude, reducer)),\n ),\n Match.when({ type: 'order' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'select' }, () => []),\n Match.exhaustive,\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,SAASA,iBAAiB;AAE1B,SAASC,mBAAmB;;;ACF5B,SAASC,sBAAsB;AAC/B,SAASC,KAAKC,uBAAuC;;;;;;;;;;;;;;AAS9C,IAAMC,YAAN,MAAMA,WAAAA;EAOX,OAAOC,QAAQC,KAAqB;AAClC,YAAQA,IAAIC,MAAI;MACd,KAAKC,IAAID,KAAKE;AACZ,eAAO,IAAIL,WAAUE,IAAII,MAAM,CAAA,GAAIN,WAAUO,eAAe,YAAYL,GAAAA;MAC1E,KAAKE,IAAID,KAAKK;AACZ,YAAIN,IAAII,MAAM,CAAA,MAAOG,iBAAiB;AACpC,iBAAO,IAAIT,WAAUE,IAAII,MAAM,CAAA,GAAII,QAAWA,QAAWR,GAAAA;QAC3D,OAAO;AACL,iBAAO,IAAIF,WAAUE,IAAII,MAAM,CAAA,GAAII,QAAWR,IAAII,MAAM,CAAA,GAAIJ,GAAAA;QAC9D;MACF;AACE,eAAO,IAAIF,WAAUE,IAAII,MAAM,CAAA,GAAII,QAAWR,IAAII,MAAM,CAAA,GAAIJ,GAAAA;IAChE;EACF;EAEA,OAAOS,UAAUC,QAAkC;AACjD,WAAO,IAAIZ,WAAUY,OAAMC,UAAUD,OAAME,UAAUF,OAAMG,IAAI;EACjE;;;;EAKA,OAAOC,qBAAqBH,UAA+B;AACzD,WAAO,IAAIb,WAAUa,QAAAA;EACvB;;;;;EAMA,OAAOI,mBAAmBC,MAAyB;AACjD,WAAO,IAAIlB,WAAUkB,MAAMlB,WAAUO,eAAe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Q,GAAG,CAAC,EAAEiE,QAAO,MAAOA,QAAQiC,QAAQ,CAACL,MAAME,KAAKF,GAAGG,OAAAA,CAAAA,CAAAA,GACxEL,WAAK;IAAE3F,MAAM;EAAiB,GAAG,CAAC,EAAEoE,QAAQC,QAAO,MACvD0B,KAAK3B,QAAQ4B,OAAAA,EAASG,OAAOJ,KAAK1B,SAAS2B,OAAAA,CAAAA,CAAAA,GAEvCL,WAAK;IAAE3F,MAAM;EAAQ,GAAG,CAAC,EAAE4E,OAAAA,OAAK,MAAOmB,KAAKnB,QAAOoB,OAAAA,CAAAA,GACnDL,WAAK;IAAE3F,MAAM;EAAS,GAAG,MAAM,CAAA,CAAE,GACjC8F,gBAAU;AAEpB;",
|
|
6
|
-
"names": ["invariant", "visitValues", "assertArgument", "DXN", "LOCAL_SPACE_TAG", "Reference", "fromDXN", "dxn", "kind", "DXN", "TYPE", "parts", "TYPE_PROTOCOL", "ECHO", "LOCAL_SPACE_TAG", "undefined", "fromValue", "value", "objectId", "protocol", "host", "localObjectReference", "fromLegacyTypename", "type", "fromObjectIdAndSpaceKey", "spaceKey", "toHex", "_dxn", "_objectId", "_protocol", "_host", "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", "getTags", "meta", "tags", "makeObject", "keys", "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_", "Struct", "source", "String", "id", "annotations", "IdentifierAnnotationId", "ForeignKey", "Match", "Schema", "DXN", "ObjectId", "TypenameSpecifier", "Union", "DXN", "Schema", "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", "FilterContains_", "FilterContains", "FilterTag_", "tag", "FilterTag", "FilterRange_", "from", "to", "FilterRange", "FilterTextSearch_", "text", "searchKind", "FilterTextSearch", "FilterNot_", "filter", "FilterNot", "FilterAnd_", "filters", "FilterAnd", "FilterOr_", "FilterOr", "identifier", "QuerySelectClause_", "QuerySelectClause", "QueryFilterClause_", "selection", "Query", "QueryFilterClause", "QueryReferenceTraversalClause_", "anchor", "property", "QueryReferenceTraversalClause", "QueryIncomingReferencesClause_", "QueryIncomingReferencesClause", "QueryRelationClause_", "direction", "QueryRelationClause", "QueryRelationTraversalClause_", "QueryRelationTraversalClause", "QueryUnionClause_", "queries", "QueryUnionClause", "QuerySetDifferenceClause_", "source", "exclude", "QuerySetDifferenceClause", "OrderDirection", "Order_", "kind", "Order", "QueryOrderClause_", "query", "order", "QueryOrderClause", "QueryOptionsClause_", "options", "QueryOptions", "QueryOptionsClause", "Query_", "spaceIds", "queues", "deleted", "visit", "visitor", "Match", "pipe", "when", "forEach", "q", "exhaustive", "fold", "reducer", "withReturnType", "flatMap", "concat"]
|
|
7
|
-
}
|