@dxos/echo-protocol 0.8.4-main.ae835ea → 0.8.4-main.bc674ce

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/echo-protocol",
3
- "version": "0.8.4-main.ae835ea",
3
+ "version": "0.8.4-main.bc674ce",
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
  ".": {
@@ -26,12 +29,12 @@
26
29
  "src"
27
30
  ],
28
31
  "dependencies": {
29
- "effect": "3.18.3",
30
- "@dxos/crypto": "0.8.4-main.ae835ea",
31
- "@dxos/invariant": "0.8.4-main.ae835ea",
32
- "@dxos/protocols": "0.8.4-main.ae835ea",
33
- "@dxos/keys": "0.8.4-main.ae835ea",
34
- "@dxos/util": "0.8.4-main.ae835ea"
32
+ "effect": "3.19.11",
33
+ "@dxos/crypto": "0.8.4-main.bc674ce",
34
+ "@dxos/invariant": "0.8.4-main.bc674ce",
35
+ "@dxos/protocols": "0.8.4-main.bc674ce",
36
+ "@dxos/util": "0.8.4-main.bc674ce",
37
+ "@dxos/keys": "0.8.4-main.bc674ce"
35
38
  },
36
39
  "publishConfig": {
37
40
  "access": "public"
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. Null means any type will match',
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
 
@@ -159,6 +167,7 @@ export const Filter = Schema.Union(
159
167
  FilterAnd,
160
168
  FilterOr,
161
169
  ).annotations({ identifier: 'dxos.org/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
- 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),
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,6 +250,7 @@ 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
 
@@ -242,6 +261,7 @@ const QueryUnionClause_ = Schema.Struct({
242
261
  type: Schema.Literal('union'),
243
262
  queries: Schema.Array(Schema.suspend(() => Query)),
244
263
  });
264
+
245
265
  export interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {}
246
266
  export const QueryUnionClause: Schema.Schema<QueryUnionClause> = QueryUnionClause_;
247
267
 
@@ -253,6 +273,7 @@ const QuerySetDifferenceClause_ = Schema.Struct({
253
273
  source: Schema.suspend(() => Query),
254
274
  exclude: Schema.suspend(() => Query),
255
275
  });
276
+
256
277
  export interface QuerySetDifferenceClause extends Schema.Schema.Type<typeof QuerySetDifferenceClause_> {}
257
278
  export const QuerySetDifferenceClause: Schema.Schema<QuerySetDifferenceClause> = QuerySetDifferenceClause_;
258
279
 
@@ -269,7 +290,14 @@ const Order_ = Schema.Union(
269
290
  property: Schema.String,
270
291
  direction: OrderDirection,
271
292
  }),
293
+ Schema.Struct({
294
+ // Order by relevance rank (for FTS/vector search results).
295
+ // Default direction is 'desc' (higher rank = better match first).
296
+ kind: Schema.Literal('rank'),
297
+ direction: OrderDirection,
298
+ }),
272
299
  );
300
+
273
301
  export type Order = Schema.Schema.Type<typeof Order_>;
274
302
  export const Order: Schema.Schema<Order> = Order_;
275
303
 
@@ -282,6 +310,7 @@ const QueryOrderClause_ = Schema.Struct({
282
310
  query: Schema.suspend(() => Query),
283
311
  order: Schema.Array(Order),
284
312
  });
313
+
285
314
  export interface QueryOrderClause extends Schema.Schema.Type<typeof QueryOrderClause_> {}
286
315
  export const QueryOrderClause: Schema.Schema<QueryOrderClause> = QueryOrderClause_;
287
316
 
@@ -293,9 +322,22 @@ const QueryOptionsClause_ = Schema.Struct({
293
322
  query: Schema.suspend(() => Query),
294
323
  options: Schema.suspend(() => QueryOptions),
295
324
  });
325
+
296
326
  export interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}
297
327
  export const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;
298
328
 
329
+ /**
330
+ * Limit the number of results.
331
+ */
332
+ const QueryLimitClause_ = Schema.Struct({
333
+ type: Schema.Literal('limit'),
334
+ query: Schema.suspend(() => Query),
335
+ limit: Schema.Number,
336
+ });
337
+
338
+ export interface QueryLimitClause extends Schema.Schema.Type<typeof QueryLimitClause_> {}
339
+ export const QueryLimitClause: Schema.Schema<QueryLimitClause> = QueryLimitClause_;
340
+
299
341
  const Query_ = Schema.Union(
300
342
  QuerySelectClause,
301
343
  QueryFilterClause,
@@ -307,6 +349,7 @@ const Query_ = Schema.Union(
307
349
  QuerySetDifferenceClause,
308
350
  QueryOrderClause,
309
351
  QueryOptionsClause,
352
+ QueryLimitClause,
310
353
  ).annotations({ identifier: 'dxos.org/schema/Query' });
311
354
 
312
355
  export type Query = Schema.Schema.Type<typeof Query_>;
@@ -320,6 +363,11 @@ export const QueryOptions = Schema.Struct({
320
363
  */
321
364
  spaceIds: Schema.optional(Schema.Array(Schema.String)),
322
365
 
366
+ /**
367
+ * If true, the nested select statements will select from all queues in the spaces specified by `spaceIds`.
368
+ */
369
+ allQueuesFromSpaces: Schema.optional(Schema.Boolean),
370
+
323
371
  /**
324
372
  * The nested select statemets will select from the given queues.
325
373
  *
@@ -332,6 +380,7 @@ export const QueryOptions = Schema.Struct({
332
380
  */
333
381
  deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),
334
382
  });
383
+
335
384
  export interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}
336
385
 
337
386
  export const visit = (query: Query, visitor: (node: Query) => void) => {
@@ -350,6 +399,7 @@ export const visit = (query: Query, visitor: (node: Query) => void) => {
350
399
  visit(exclude, visitor);
351
400
  }),
352
401
  Match.when({ type: 'order' }, ({ query }) => visit(query, visitor)),
402
+ Match.when({ type: 'limit' }, ({ query }) => visit(query, visitor)),
353
403
  Match.when({ type: 'select' }, () => {}),
354
404
  Match.exhaustive,
355
405
  );
@@ -369,6 +419,7 @@ export const fold = <T>(query: Query, reducer: (node: Query) => T): T[] => {
369
419
  fold(source, reducer).concat(fold(exclude, reducer)),
370
420
  ),
371
421
  Match.when({ type: 'order' }, ({ query }) => fold(query, reducer)),
422
+ Match.when({ type: 'limit' }, ({ query }) => fold(query, reducer)),
372
423
  Match.when({ type: 'select' }, () => []),
373
424
  Match.exhaustive,
374
425
  );
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
  });