@dxos/echo-protocol 0.8.4-main.1f223c7 → 0.8.4-main.2244d791bb

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/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@dxos/echo-protocol",
3
- "version": "0.8.4-main.1f223c7",
3
+ "version": "0.8.4-main.2244d791bb",
4
4
  "description": "Core ECHO APIs.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
- "repository": "github:dxos/dxos",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
8
11
  "license": "MIT",
9
12
  "author": "DXOS.org",
10
- "sideEffects": true,
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
- "browser": "./dist/lib/browser/index.mjs",
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.17.7",
30
- "@dxos/crypto": "0.8.4-main.1f223c7",
31
- "@dxos/invariant": "0.8.4-main.1f223c7",
32
- "@dxos/protocols": "0.8.4-main.1f223c7",
33
- "@dxos/keys": "0.8.4-main.1f223c7",
34
- "@dxos/util": "0.8.4-main.1f223c7"
31
+ "effect": "3.19.16",
32
+ "@dxos/crypto": "0.8.4-main.2244d791bb",
33
+ "@dxos/invariant": "0.8.4-main.2244d791bb",
34
+ "@dxos/keys": "0.8.4-main.2244d791bb",
35
+ "@dxos/protocols": "0.8.4-main.2244d791bb",
36
+ "@dxos/util": "0.8.4-main.2244d791bb"
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
  */
@@ -153,6 +157,10 @@ export const ObjectStructure = Object.freeze({
153
157
  return references;
154
158
  },
155
159
 
160
+ getTags: (object: ObjectStructure): string[] => {
161
+ return object.meta.tags ?? [];
162
+ },
163
+
156
164
  makeObject: ({
157
165
  type,
158
166
  data,
@@ -214,6 +222,14 @@ export type ObjectMeta = {
214
222
  * Foreign keys.
215
223
  */
216
224
  keys: ForeignKey[];
225
+
226
+ /**
227
+ * Tags.
228
+ * An array of DXNs of Tag objects within the space.
229
+ *
230
+ * NOTE: Optional for backwards compatibilty.
231
+ */
232
+ tags?: string[];
217
233
  };
218
234
 
219
235
  /**
@@ -236,13 +252,19 @@ export type ObjectSystem = {
236
252
  */
237
253
  deleted?: boolean;
238
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
+
239
261
  /**
240
262
  * Only for relations.
241
263
  */
242
264
  source?: EncodedReference;
243
265
 
244
266
  /**
245
- * Only for relations.w
267
+ * Only for relations.
246
268
  */
247
269
  target?: EncodedReference;
248
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
+ }
@@ -2,7 +2,8 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema, SchemaAST } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
+ import * as SchemaAST from 'effect/SchemaAST';
6
7
 
7
8
  const ForeignKey_ = Schema.Struct({
8
9
  /**
@@ -15,8 +16,8 @@ const ForeignKey_ = Schema.Struct({
15
16
  * Id within the foreign database.
16
17
  */
17
18
  // TODO(wittjosiah): This annotation is currently used to ensure id field shows up in forms.
18
- // TODO(dmaretskyi): `false` is not a valid value for the annotation.
19
- id: Schema.String.annotations({ [SchemaAST.IdentifierAnnotationId]: false }),
19
+ // TODO(dmaretskyi): `false` is not a valid value for the annotation. Use a different annotation.
20
+ id: Schema.String.annotations({ [SchemaAST.IdentifierAnnotationId]: 'false' }),
20
21
  });
21
22
 
22
23
  export type ForeignKey = Schema.Schema.Type<typeof ForeignKey_>;
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
@@ -2,14 +2,15 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Match, Schema } from 'effect';
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. Null means any type will match',
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,65 +68,106 @@ 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
+ */
64
74
  const FilterContains_ = Schema.Struct({
65
75
  type: Schema.Literal('contains'),
66
76
  value: Schema.Any,
67
77
  });
78
+
68
79
  export interface FilterContains extends Schema.Schema.Type<typeof FilterContains_> {}
80
+
69
81
  /**
70
82
  * Predicate for an array property to contain the provided value.
71
83
  * Nested objects are matched using strict structural matching.
72
84
  */
73
85
  export const FilterContains: Schema.Schema<FilterContains> = FilterContains_;
74
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
+ */
75
101
  const FilterRange_ = Schema.Struct({
76
102
  type: Schema.Literal('range'),
77
103
  from: Schema.Any,
78
104
  to: Schema.Any,
79
105
  });
106
+
80
107
  export interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {}
81
108
  export const FilterRange: Schema.Schema<FilterRange> = FilterRange_;
82
109
 
110
+ /**
111
+ * Text search.
112
+ */
83
113
  const FilterTextSearch_ = Schema.Struct({
84
114
  type: Schema.Literal('text-search'),
85
115
  text: Schema.String,
86
116
  searchKind: Schema.optional(Schema.Literal('full-text', 'vector')),
87
117
  });
118
+
88
119
  export interface FilterTextSearch extends Schema.Schema.Type<typeof FilterTextSearch_> {}
89
120
  export const FilterTextSearch: Schema.Schema<FilterTextSearch> = FilterTextSearch_;
90
121
 
122
+ /**
123
+ * Not.
124
+ */
91
125
  const FilterNot_ = Schema.Struct({
92
126
  type: Schema.Literal('not'),
93
127
  filter: Schema.suspend(() => Filter),
94
128
  });
129
+
95
130
  export interface FilterNot extends Schema.Schema.Type<typeof FilterNot_> {}
96
131
  export const FilterNot: Schema.Schema<FilterNot> = FilterNot_;
97
132
 
133
+ /**
134
+ * And.
135
+ */
98
136
  const FilterAnd_ = Schema.Struct({
99
137
  type: Schema.Literal('and'),
100
138
  filters: Schema.Array(Schema.suspend(() => Filter)),
101
139
  });
140
+
102
141
  export interface FilterAnd extends Schema.Schema.Type<typeof FilterAnd_> {}
103
142
  export const FilterAnd: Schema.Schema<FilterAnd> = FilterAnd_;
104
143
 
144
+ /**
145
+ * Or.
146
+ */
105
147
  const FilterOr_ = Schema.Struct({
106
148
  type: Schema.Literal('or'),
107
149
  filters: Schema.Array(Schema.suspend(() => Filter)),
108
150
  });
151
+
109
152
  export interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {}
110
153
  export const FilterOr: Schema.Schema<FilterOr> = FilterOr_;
111
154
 
155
+ /**
156
+ * Union of filters.
157
+ */
112
158
  export const Filter = Schema.Union(
113
159
  FilterObject,
114
- FilterTextSearch,
115
160
  FilterCompare,
116
161
  FilterIn,
117
162
  FilterContains,
163
+ FilterTag,
118
164
  FilterRange,
165
+ FilterTextSearch,
119
166
  FilterNot,
120
167
  FilterAnd,
121
168
  FilterOr,
122
- );
169
+ ).annotations({ identifier: 'dxos.org/schema/Filter' });
170
+
123
171
  export type Filter = Schema.Schema.Type<typeof Filter>;
124
172
 
125
173
  /**
@@ -129,6 +177,7 @@ const QuerySelectClause_ = Schema.Struct({
129
177
  type: Schema.Literal('select'),
130
178
  filter: Schema.suspend(() => Filter),
131
179
  });
180
+
132
181
  export interface QuerySelectClause extends Schema.Schema.Type<typeof QuerySelectClause_> {}
133
182
  export const QuerySelectClause: Schema.Schema<QuerySelectClause> = QuerySelectClause_;
134
183
 
@@ -140,6 +189,7 @@ const QueryFilterClause_ = Schema.Struct({
140
189
  selection: Schema.suspend(() => Query),
141
190
  filter: Schema.suspend(() => Filter),
142
191
  });
192
+
143
193
  export interface QueryFilterClause extends Schema.Schema.Type<typeof QueryFilterClause_> {}
144
194
  export const QueryFilterClause: Schema.Schema<QueryFilterClause> = QueryFilterClause_;
145
195
 
@@ -151,6 +201,7 @@ const QueryReferenceTraversalClause_ = Schema.Struct({
151
201
  anchor: Schema.suspend(() => Query),
152
202
  property: Schema.String, // TODO(dmaretskyi): Change to EscapedPropPath.
153
203
  });
204
+
154
205
  export interface QueryReferenceTraversalClause extends Schema.Schema.Type<typeof QueryReferenceTraversalClause_> {}
155
206
  export const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversalClause> =
156
207
  QueryReferenceTraversalClause_;
@@ -161,9 +212,14 @@ export const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversa
161
212
  const QueryIncomingReferencesClause_ = Schema.Struct({
162
213
  type: Schema.Literal('incoming-references'),
163
214
  anchor: Schema.suspend(() => Query),
164
- property: Schema.String,
215
+ /**
216
+ * Property path where the reference is located.
217
+ * If null, matches references from any property.
218
+ */
219
+ property: Schema.NullOr(Schema.String),
165
220
  typename: TypenameSpecifier,
166
221
  });
222
+
167
223
  export interface QueryIncomingReferencesClause extends Schema.Schema.Type<typeof QueryIncomingReferencesClause_> {}
168
224
  export const QueryIncomingReferencesClause: Schema.Schema<QueryIncomingReferencesClause> =
169
225
  QueryIncomingReferencesClause_;
@@ -182,6 +238,7 @@ const QueryRelationClause_ = Schema.Struct({
182
238
  direction: Schema.Literal('outgoing', 'incoming', 'both'),
183
239
  filter: Schema.optional(Schema.suspend(() => Filter)),
184
240
  });
241
+
185
242
  export interface QueryRelationClause extends Schema.Schema.Type<typeof QueryRelationClause_> {}
186
243
  export const QueryRelationClause: Schema.Schema<QueryRelationClause> = QueryRelationClause_;
187
244
 
@@ -193,9 +250,27 @@ const QueryRelationTraversalClause_ = Schema.Struct({
193
250
  anchor: Schema.suspend(() => Query),
194
251
  direction: Schema.Literal('source', 'target', 'both'),
195
252
  });
253
+
196
254
  export interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {}
197
255
  export const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause> = QueryRelationTraversalClause_;
198
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
+
199
274
  /**
200
275
  * Union of multiple queries.
201
276
  */
@@ -203,6 +278,7 @@ const QueryUnionClause_ = Schema.Struct({
203
278
  type: Schema.Literal('union'),
204
279
  queries: Schema.Array(Schema.suspend(() => Query)),
205
280
  });
281
+
206
282
  export interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {}
207
283
  export const QueryUnionClause: Schema.Schema<QueryUnionClause> = QueryUnionClause_;
208
284
 
@@ -214,6 +290,7 @@ const QuerySetDifferenceClause_ = Schema.Struct({
214
290
  source: Schema.suspend(() => Query),
215
291
  exclude: Schema.suspend(() => Query),
216
292
  });
293
+
217
294
  export interface QuerySetDifferenceClause extends Schema.Schema.Type<typeof QuerySetDifferenceClause_> {}
218
295
  export const QuerySetDifferenceClause: Schema.Schema<QuerySetDifferenceClause> = QuerySetDifferenceClause_;
219
296
 
@@ -230,7 +307,14 @@ const Order_ = Schema.Union(
230
307
  property: Schema.String,
231
308
  direction: OrderDirection,
232
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
+ }),
233
316
  );
317
+
234
318
  export type Order = Schema.Schema.Type<typeof Order_>;
235
319
  export const Order: Schema.Schema<Order> = Order_;
236
320
 
@@ -243,6 +327,7 @@ const QueryOrderClause_ = Schema.Struct({
243
327
  query: Schema.suspend(() => Query),
244
328
  order: Schema.Array(Order),
245
329
  });
330
+
246
331
  export interface QueryOrderClause extends Schema.Schema.Type<typeof QueryOrderClause_> {}
247
332
  export const QueryOrderClause: Schema.Schema<QueryOrderClause> = QueryOrderClause_;
248
333
 
@@ -254,9 +339,22 @@ const QueryOptionsClause_ = Schema.Struct({
254
339
  query: Schema.suspend(() => Query),
255
340
  options: Schema.suspend(() => QueryOptions),
256
341
  });
342
+
257
343
  export interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}
258
344
  export const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;
259
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
+
260
358
  const Query_ = Schema.Union(
261
359
  QuerySelectClause,
262
360
  QueryFilterClause,
@@ -264,11 +362,13 @@ const Query_ = Schema.Union(
264
362
  QueryIncomingReferencesClause,
265
363
  QueryRelationClause,
266
364
  QueryRelationTraversalClause,
365
+ QueryHierarchyTraversalClause,
267
366
  QueryUnionClause,
268
367
  QuerySetDifferenceClause,
269
368
  QueryOrderClause,
270
369
  QueryOptionsClause,
271
- );
370
+ QueryLimitClause,
371
+ ).annotations({ identifier: 'dxos.org/schema/Query' });
272
372
 
273
373
  export type Query = Schema.Schema.Type<typeof Query_>;
274
374
  export const Query: Schema.Schema<Query> = Query_;
@@ -281,6 +381,11 @@ export const QueryOptions = Schema.Struct({
281
381
  */
282
382
  spaceIds: Schema.optional(Schema.Array(Schema.String)),
283
383
 
384
+ /**
385
+ * If true, the nested select statements will select from all queues in the spaces specified by `spaceIds`.
386
+ */
387
+ allQueuesFromSpaces: Schema.optional(Schema.Boolean),
388
+
284
389
  /**
285
390
  * The nested select statemets will select from the given queues.
286
391
  *
@@ -293,6 +398,7 @@ export const QueryOptions = Schema.Struct({
293
398
  */
294
399
  deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),
295
400
  });
401
+
296
402
  export interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}
297
403
 
298
404
  export const visit = (query: Query, visitor: (node: Query) => void) => {
@@ -305,12 +411,14 @@ export const visit = (query: Query, visitor: (node: Query) => void) => {
305
411
  Match.when({ type: 'relation' }, ({ anchor }) => visit(anchor, visitor)),
306
412
  Match.when({ type: 'options' }, ({ query }) => visit(query, visitor)),
307
413
  Match.when({ type: 'relation-traversal' }, ({ anchor }) => visit(anchor, visitor)),
414
+ Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => visit(anchor, visitor)),
308
415
  Match.when({ type: 'union' }, ({ queries }) => queries.forEach((q) => visit(q, visitor))),
309
416
  Match.when({ type: 'set-difference' }, ({ source, exclude }) => {
310
417
  visit(source, visitor);
311
418
  visit(exclude, visitor);
312
419
  }),
313
420
  Match.when({ type: 'order' }, ({ query }) => visit(query, visitor)),
421
+ Match.when({ type: 'limit' }, ({ query }) => visit(query, visitor)),
314
422
  Match.when({ type: 'select' }, () => {}),
315
423
  Match.exhaustive,
316
424
  );
@@ -325,11 +433,13 @@ export const fold = <T>(query: Query, reducer: (node: Query) => T): T[] => {
325
433
  Match.when({ type: 'relation' }, ({ anchor }) => fold(anchor, reducer)),
326
434
  Match.when({ type: 'options' }, ({ query }) => fold(query, reducer)),
327
435
  Match.when({ type: 'relation-traversal' }, ({ anchor }) => fold(anchor, reducer)),
436
+ Match.when({ type: 'hierarchy-traversal' }, ({ anchor }) => fold(anchor, reducer)),
328
437
  Match.when({ type: 'union' }, ({ queries }) => queries.flatMap((q) => fold(q, reducer))),
329
438
  Match.when({ type: 'set-difference' }, ({ source, exclude }) =>
330
439
  fold(source, reducer).concat(fold(exclude, reducer)),
331
440
  ),
332
441
  Match.when({ type: 'order' }, ({ query }) => fold(query, reducer)),
442
+ Match.when({ type: 'limit' }, ({ query }) => fold(query, reducer)),
333
443
  Match.when({ type: 'select' }, () => []),
334
444
  Match.exhaustive,
335
445
  );
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 encodeReference(Reference.fromDXN(dxn));
180
+ return { '/': dxn.toString() };
181
+ },
182
+ fromLegacyTypename: (typename: string): EncodedReference => {
183
+ return { '/': DXN.fromTypename(typename).toString() };
181
184
  },
182
185
  });