@dxos/echo-protocol 0.8.4-main.ef1bc66f44 → 0.8.4-main.f466a3d56e
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/index.mjs +238 -55
- package/dist/lib/neutral/index.mjs.map +4 -4
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/document-structure.d.ts +11 -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/edge-peer.d.ts +11 -0
- package/dist/types/src/edge-peer.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/query/ast.d.ts +108 -40
- package/dist/types/src/query/ast.d.ts.map +1 -1
- package/dist/types/src/reference.d.ts.map +1 -1
- package/dist/types/src/space-id.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -11
- package/src/document-structure.ts +12 -0
- package/src/echo-feed-codec.ts +67 -0
- package/src/edge-peer.ts +27 -0
- package/src/index.ts +5 -3
- package/src/query/ast.ts +129 -15
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -18,4 +18,4 @@ pnpm i @dxos/echo-protocol
|
|
|
18
18
|
|
|
19
19
|
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
20
20
|
|
|
21
|
-
License: [
|
|
21
|
+
License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
|
|
@@ -168,15 +168,7 @@ var DatabaseDirectory = Object.freeze({
|
|
|
168
168
|
return null;
|
|
169
169
|
}
|
|
170
170
|
const rawKey = String(rawSpaceKey);
|
|
171
|
-
invariant(!rawKey.startsWith("0x"), "Space key must not start with 0x", {
|
|
172
|
-
F: __dxlog_file,
|
|
173
|
-
L: 66,
|
|
174
|
-
S: void 0,
|
|
175
|
-
A: [
|
|
176
|
-
"!rawKey.startsWith('0x')",
|
|
177
|
-
"'Space key must not start with 0x'"
|
|
178
|
-
]
|
|
179
|
-
});
|
|
171
|
+
invariant(!rawKey.startsWith("0x"), "Space key must not start with 0x", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 17, S: void 0, A: ["!rawKey.startsWith('0x')", "'Space key must not start with 0x'"] });
|
|
180
172
|
return rawKey;
|
|
181
173
|
},
|
|
182
174
|
getInlineObject: (doc, id) => {
|
|
@@ -205,15 +197,7 @@ var ObjectStructure = Object.freeze({
|
|
|
205
197
|
*/
|
|
206
198
|
getEntityKind: (object) => {
|
|
207
199
|
const kind = object.system?.kind ?? "object";
|
|
208
|
-
invariant(kind === "object" || kind === "relation", "Invalid kind", {
|
|
209
|
-
F: __dxlog_file,
|
|
210
|
-
L: 124,
|
|
211
|
-
S: void 0,
|
|
212
|
-
A: [
|
|
213
|
-
"kind === 'object' || kind === 'relation'",
|
|
214
|
-
"'Invalid kind'"
|
|
215
|
-
]
|
|
216
|
-
});
|
|
200
|
+
invariant(kind === "object" || kind === "relation", "Invalid kind", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 45, S: void 0, A: ["kind === 'object' || kind === 'relation'", "'Invalid kind'"] });
|
|
217
201
|
return kind;
|
|
218
202
|
},
|
|
219
203
|
isDeleted: (object) => {
|
|
@@ -289,33 +273,67 @@ var ObjectStructure = Object.freeze({
|
|
|
289
273
|
var PROPERTY_ID = "id";
|
|
290
274
|
var DATA_NAMESPACE = "data";
|
|
291
275
|
|
|
292
|
-
// src/
|
|
293
|
-
|
|
276
|
+
// src/edge-peer.ts
|
|
277
|
+
import { EdgeService } from "@dxos/protocols";
|
|
278
|
+
import { compositeKey } from "@dxos/util";
|
|
279
|
+
var isEdgePeerId = (peerId, spaceId) => {
|
|
280
|
+
const automergePrefix = spaceId !== void 0 ? compositeKey(EdgeService.AUTOMERGE_REPLICATOR, spaceId) : `${EdgeService.AUTOMERGE_REPLICATOR}:`;
|
|
281
|
+
const subductionPrefix = spaceId !== void 0 ? compositeKey(EdgeService.SUBDUCTION_REPLICATOR, spaceId) : `${EdgeService.SUBDUCTION_REPLICATOR}:`;
|
|
282
|
+
return peerId.startsWith(automergePrefix) || peerId.startsWith(subductionPrefix);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// src/echo-feed-codec.ts
|
|
286
|
+
import { FeedProtocol } from "@dxos/protocols";
|
|
287
|
+
var ATTR_META = "@meta";
|
|
288
|
+
var EchoFeedCodec = class _EchoFeedCodec {
|
|
289
|
+
static #encoder = new TextEncoder();
|
|
290
|
+
static #decoder = new TextDecoder();
|
|
294
291
|
/**
|
|
295
|
-
*
|
|
292
|
+
* Prepares a value for feed storage (strips queue position from metadata) and encodes to bytes.
|
|
296
293
|
*/
|
|
297
|
-
|
|
294
|
+
static encode(value2) {
|
|
295
|
+
const prepared = _EchoFeedCodec.#stripQueuePosition(value2);
|
|
296
|
+
return _EchoFeedCodec.#encoder.encode(JSON.stringify(prepared));
|
|
297
|
+
}
|
|
298
298
|
/**
|
|
299
|
-
*
|
|
299
|
+
* Decodes feed block bytes to a JSON value.
|
|
300
|
+
* If position is provided, injects queue position into the decoded object's metadata.
|
|
300
301
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
302
|
+
static decode(data, position) {
|
|
303
|
+
const decoded = JSON.parse(_EchoFeedCodec.#decoder.decode(data));
|
|
304
|
+
if (position !== void 0 && typeof decoded === "object" && decoded !== null) {
|
|
305
|
+
_EchoFeedCodec.#setQueuePosition(decoded, position);
|
|
306
|
+
}
|
|
307
|
+
return decoded;
|
|
308
|
+
}
|
|
309
|
+
static #stripQueuePosition(value2) {
|
|
310
|
+
if (typeof value2 !== "object" || value2 === null) {
|
|
311
|
+
return value2;
|
|
312
|
+
}
|
|
313
|
+
const obj = structuredClone(value2);
|
|
314
|
+
const meta = obj[ATTR_META];
|
|
315
|
+
if (meta?.keys?.some((key) => key.source === FeedProtocol.KEY_QUEUE_POSITION)) {
|
|
316
|
+
meta.keys = meta.keys.filter((key) => key.source !== FeedProtocol.KEY_QUEUE_POSITION);
|
|
317
|
+
}
|
|
318
|
+
return obj;
|
|
319
|
+
}
|
|
320
|
+
static #setQueuePosition(obj, position) {
|
|
321
|
+
obj[ATTR_META] ??= {
|
|
322
|
+
keys: []
|
|
323
|
+
};
|
|
324
|
+
obj[ATTR_META].keys ??= [];
|
|
325
|
+
const keys = obj[ATTR_META].keys;
|
|
326
|
+
for (let i = 0; i < keys.length; i++) {
|
|
327
|
+
if (keys[i].source === FeedProtocol.KEY_QUEUE_POSITION) {
|
|
328
|
+
keys.splice(i, 1);
|
|
329
|
+
i--;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
keys.push({
|
|
333
|
+
source: FeedProtocol.KEY_QUEUE_POSITION,
|
|
334
|
+
id: position.toString()
|
|
335
|
+
});
|
|
313
336
|
}
|
|
314
|
-
const digest = await subtleCrypto.digest("SHA-256", spaceKey.asUint8Array());
|
|
315
|
-
const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);
|
|
316
|
-
const spaceId = SpaceId.encode(bytes);
|
|
317
|
-
SPACE_IDS_CACHE.set(spaceKey, spaceId);
|
|
318
|
-
return spaceId;
|
|
319
337
|
};
|
|
320
338
|
|
|
321
339
|
// src/foreign-key.ts
|
|
@@ -343,6 +361,7 @@ var ast_exports = {};
|
|
|
343
361
|
__export(ast_exports, {
|
|
344
362
|
Filter: () => Filter,
|
|
345
363
|
FilterAnd: () => FilterAnd,
|
|
364
|
+
FilterChildOf: () => FilterChildOf,
|
|
346
365
|
FilterCompare: () => FilterCompare,
|
|
347
366
|
FilterContains: () => FilterContains,
|
|
348
367
|
FilterIn: () => FilterIn,
|
|
@@ -352,10 +371,13 @@ __export(ast_exports, {
|
|
|
352
371
|
FilterRange: () => FilterRange,
|
|
353
372
|
FilterTag: () => FilterTag,
|
|
354
373
|
FilterTextSearch: () => FilterTextSearch,
|
|
374
|
+
FilterTimestamp: () => FilterTimestamp,
|
|
355
375
|
Order: () => Order,
|
|
356
376
|
OrderDirection: () => OrderDirection,
|
|
357
377
|
Query: () => Query,
|
|
358
378
|
QueryFilterClause: () => QueryFilterClause,
|
|
379
|
+
QueryFromClause: () => QueryFromClause,
|
|
380
|
+
QueryFromClause_: () => QueryFromClause_,
|
|
359
381
|
QueryHierarchyTraversalClause: () => QueryHierarchyTraversalClause,
|
|
360
382
|
QueryIncomingReferencesClause: () => QueryIncomingReferencesClause,
|
|
361
383
|
QueryLimitClause: () => QueryLimitClause,
|
|
@@ -368,7 +390,9 @@ __export(ast_exports, {
|
|
|
368
390
|
QuerySelectClause: () => QuerySelectClause,
|
|
369
391
|
QuerySetDifferenceClause: () => QuerySetDifferenceClause,
|
|
370
392
|
QueryUnionClause: () => QueryUnionClause,
|
|
393
|
+
Scope: () => Scope,
|
|
371
394
|
fold: () => fold,
|
|
395
|
+
map: () => map,
|
|
372
396
|
visit: () => visit
|
|
373
397
|
});
|
|
374
398
|
import * as Match from "effect/Match";
|
|
@@ -394,7 +418,16 @@ var FilterObject_ = Schema2.Struct({
|
|
|
394
418
|
/**
|
|
395
419
|
* Objects that have any of the given foreign keys.
|
|
396
420
|
*/
|
|
397
|
-
foreignKeys: Schema2.optional(Schema2.Array(ForeignKey))
|
|
421
|
+
foreignKeys: Schema2.optional(Schema2.Array(ForeignKey)),
|
|
422
|
+
/**
|
|
423
|
+
* Match objects whose meta `key` equals this fully-qualified registry key (FQN format).
|
|
424
|
+
*/
|
|
425
|
+
metaKey: Schema2.optional(Schema2.String),
|
|
426
|
+
/**
|
|
427
|
+
* Semver range matched against the object's meta `version`.
|
|
428
|
+
* Only consulted when {@link metaKey} is set. Objects with no `version` do not satisfy a version-constrained filter.
|
|
429
|
+
*/
|
|
430
|
+
metaVersion: Schema2.optional(Schema2.String)
|
|
398
431
|
});
|
|
399
432
|
var FilterObject = FilterObject_;
|
|
400
433
|
var FilterCompare_ = Schema2.Struct({
|
|
@@ -424,6 +457,13 @@ var FilterRange_ = Schema2.Struct({
|
|
|
424
457
|
to: Schema2.Any
|
|
425
458
|
});
|
|
426
459
|
var FilterRange = FilterRange_;
|
|
460
|
+
var FilterTimestamp_ = Schema2.Struct({
|
|
461
|
+
type: Schema2.Literal("timestamp"),
|
|
462
|
+
field: Schema2.Literal("createdAt", "updatedAt"),
|
|
463
|
+
operator: Schema2.Literal("gt", "gte", "lt", "lte"),
|
|
464
|
+
value: Schema2.Number
|
|
465
|
+
});
|
|
466
|
+
var FilterTimestamp = FilterTimestamp_;
|
|
427
467
|
var FilterTextSearch_ = Schema2.Struct({
|
|
428
468
|
type: Schema2.Literal("text-search"),
|
|
429
469
|
text: Schema2.String,
|
|
@@ -445,8 +485,16 @@ var FilterOr_ = Schema2.Struct({
|
|
|
445
485
|
filters: Schema2.Array(Schema2.suspend(() => Filter))
|
|
446
486
|
});
|
|
447
487
|
var FilterOr = FilterOr_;
|
|
448
|
-
var
|
|
449
|
-
|
|
488
|
+
var FilterChildOf_ = Schema2.Struct({
|
|
489
|
+
type: Schema2.Literal("child-of"),
|
|
490
|
+
/** Parent DXNs to match children of. */
|
|
491
|
+
parents: Schema2.Array(DXN2.Schema),
|
|
492
|
+
/** Whether to match transitively (grandchildren, etc.). Defaults to true. */
|
|
493
|
+
transitive: Schema2.Boolean
|
|
494
|
+
});
|
|
495
|
+
var FilterChildOf = FilterChildOf_;
|
|
496
|
+
var Filter = Schema2.Union(FilterObject, FilterCompare, FilterIn, FilterContains, FilterTag, FilterRange, FilterTimestamp, FilterTextSearch, FilterChildOf, FilterNot, FilterAnd, FilterOr).annotations({
|
|
497
|
+
identifier: "org.dxos.schema.filter"
|
|
450
498
|
});
|
|
451
499
|
var QuerySelectClause_ = Schema2.Struct({
|
|
452
500
|
type: Schema2.Literal("select"),
|
|
@@ -548,31 +596,47 @@ var QueryLimitClause_ = Schema2.Struct({
|
|
|
548
596
|
limit: Schema2.Number
|
|
549
597
|
});
|
|
550
598
|
var QueryLimitClause = QueryLimitClause_;
|
|
551
|
-
var
|
|
552
|
-
|
|
599
|
+
var QueryFromClause_ = Schema2.Struct({
|
|
600
|
+
type: Schema2.Literal("from"),
|
|
601
|
+
query: Schema2.suspend(() => Query),
|
|
602
|
+
from: Schema2.Union(Schema2.TaggedStruct("scope", {
|
|
603
|
+
scope: Schema2.suspend(() => Scope)
|
|
604
|
+
}), Schema2.TaggedStruct("query", {
|
|
605
|
+
query: Schema2.suspend(() => Query)
|
|
606
|
+
}))
|
|
607
|
+
});
|
|
608
|
+
var QueryFromClause = QueryFromClause_;
|
|
609
|
+
var Query_ = Schema2.Union(QuerySelectClause, QueryFilterClause, QueryReferenceTraversalClause, QueryIncomingReferencesClause, QueryRelationClause, QueryRelationTraversalClause, QueryHierarchyTraversalClause, QueryUnionClause, QuerySetDifferenceClause, QueryOrderClause, QueryOptionsClause, QueryLimitClause, QueryFromClause).annotations({
|
|
610
|
+
identifier: "org.dxos.schema.query"
|
|
553
611
|
});
|
|
554
612
|
var Query = Query_;
|
|
555
613
|
var QueryOptions = Schema2.Struct({
|
|
614
|
+
/**
|
|
615
|
+
* Nested select statements will use this option to filter deleted objects.
|
|
616
|
+
*/
|
|
617
|
+
deleted: Schema2.optional(Schema2.Literal("include", "exclude", "only")),
|
|
618
|
+
/**
|
|
619
|
+
* Diagnostics-only label for logs / tooling (not used by execution semantics).
|
|
620
|
+
*/
|
|
621
|
+
debugLabel: Schema2.optional(Schema2.String)
|
|
622
|
+
});
|
|
623
|
+
var Scope = Schema2.Struct({
|
|
556
624
|
/**
|
|
557
625
|
* The nested select statemets will select from the given spaces.
|
|
558
626
|
*
|
|
559
|
-
* NOTE: Spaces and
|
|
627
|
+
* NOTE: Spaces and feeds are unioned together if both are specified.
|
|
560
628
|
*/
|
|
561
629
|
spaceIds: Schema2.optional(Schema2.Array(Schema2.String)),
|
|
562
630
|
/**
|
|
563
|
-
* If true, the nested select statements will select from all
|
|
631
|
+
* If true, the nested select statements will select from all feeds in the spaces specified by `spaceIds`.
|
|
564
632
|
*/
|
|
565
|
-
|
|
633
|
+
allFeedsFromSpaces: Schema2.optional(Schema2.Boolean),
|
|
566
634
|
/**
|
|
567
|
-
* The nested select statemets will select from the given
|
|
635
|
+
* The nested select statemets will select from the given feeds (by underlying queue DXN).
|
|
568
636
|
*
|
|
569
|
-
* NOTE: Spaces and
|
|
637
|
+
* NOTE: Spaces and feeds are unioned together if both are specified.
|
|
570
638
|
*/
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Nested select statements will use this option to filter deleted objects.
|
|
574
|
-
*/
|
|
575
|
-
deleted: Schema2.optional(Schema2.Literal("include", "exclude", "only"))
|
|
639
|
+
feeds: Schema2.optional(Schema2.Array(DXN2.Schema))
|
|
576
640
|
});
|
|
577
641
|
var visit = (query, visitor) => {
|
|
578
642
|
visitor(query);
|
|
@@ -602,10 +666,90 @@ var visit = (query, visitor) => {
|
|
|
602
666
|
}, ({ query: query2 }) => visit(query2, visitor)), Match.when({
|
|
603
667
|
type: "limit"
|
|
604
668
|
}, ({ query: query2 }) => visit(query2, visitor)), Match.when({
|
|
669
|
+
type: "from"
|
|
670
|
+
}, (node) => {
|
|
671
|
+
visit(node.query, visitor);
|
|
672
|
+
if (node.from._tag === "query") {
|
|
673
|
+
visit(node.from.query, visitor);
|
|
674
|
+
}
|
|
675
|
+
}), Match.when({
|
|
605
676
|
type: "select"
|
|
606
677
|
}, () => {
|
|
607
678
|
}), Match.exhaustive);
|
|
608
679
|
};
|
|
680
|
+
var map = (query, mapper) => {
|
|
681
|
+
const mapped = Match.value(query).pipe(Match.when({
|
|
682
|
+
type: "filter"
|
|
683
|
+
}, (node) => ({
|
|
684
|
+
...node,
|
|
685
|
+
selection: map(node.selection, mapper)
|
|
686
|
+
})), Match.when({
|
|
687
|
+
type: "reference-traversal"
|
|
688
|
+
}, (node) => ({
|
|
689
|
+
...node,
|
|
690
|
+
anchor: map(node.anchor, mapper)
|
|
691
|
+
})), Match.when({
|
|
692
|
+
type: "incoming-references"
|
|
693
|
+
}, (node) => ({
|
|
694
|
+
...node,
|
|
695
|
+
anchor: map(node.anchor, mapper)
|
|
696
|
+
})), Match.when({
|
|
697
|
+
type: "relation"
|
|
698
|
+
}, (node) => ({
|
|
699
|
+
...node,
|
|
700
|
+
anchor: map(node.anchor, mapper)
|
|
701
|
+
})), Match.when({
|
|
702
|
+
type: "relation-traversal"
|
|
703
|
+
}, (node) => ({
|
|
704
|
+
...node,
|
|
705
|
+
anchor: map(node.anchor, mapper)
|
|
706
|
+
})), Match.when({
|
|
707
|
+
type: "hierarchy-traversal"
|
|
708
|
+
}, (node) => ({
|
|
709
|
+
...node,
|
|
710
|
+
anchor: map(node.anchor, mapper)
|
|
711
|
+
})), Match.when({
|
|
712
|
+
type: "options"
|
|
713
|
+
}, (node) => ({
|
|
714
|
+
...node,
|
|
715
|
+
query: map(node.query, mapper)
|
|
716
|
+
})), Match.when({
|
|
717
|
+
type: "order"
|
|
718
|
+
}, (node) => ({
|
|
719
|
+
...node,
|
|
720
|
+
query: map(node.query, mapper)
|
|
721
|
+
})), Match.when({
|
|
722
|
+
type: "limit"
|
|
723
|
+
}, (node) => ({
|
|
724
|
+
...node,
|
|
725
|
+
query: map(node.query, mapper)
|
|
726
|
+
})), Match.when({
|
|
727
|
+
type: "from"
|
|
728
|
+
}, (node) => ({
|
|
729
|
+
...node,
|
|
730
|
+
query: map(node.query, mapper),
|
|
731
|
+
...node.from._tag === "query" ? {
|
|
732
|
+
from: {
|
|
733
|
+
_tag: "query",
|
|
734
|
+
query: map(node.from.query, mapper)
|
|
735
|
+
}
|
|
736
|
+
} : {}
|
|
737
|
+
})), Match.when({
|
|
738
|
+
type: "union"
|
|
739
|
+
}, (node) => ({
|
|
740
|
+
...node,
|
|
741
|
+
queries: node.queries.map((q) => map(q, mapper))
|
|
742
|
+
})), Match.when({
|
|
743
|
+
type: "set-difference"
|
|
744
|
+
}, (node) => ({
|
|
745
|
+
...node,
|
|
746
|
+
source: map(node.source, mapper),
|
|
747
|
+
exclude: map(node.exclude, mapper)
|
|
748
|
+
})), Match.when({
|
|
749
|
+
type: "select"
|
|
750
|
+
}, (node) => node), Match.exhaustive);
|
|
751
|
+
return mapper(mapped);
|
|
752
|
+
};
|
|
609
753
|
var fold = (query, reducer) => {
|
|
610
754
|
return Match.value(query).pipe(Match.withReturnType(), Match.when({
|
|
611
755
|
type: "filter"
|
|
@@ -630,12 +774,50 @@ var fold = (query, reducer) => {
|
|
|
630
774
|
}, ({ query: query2 }) => fold(query2, reducer)), Match.when({
|
|
631
775
|
type: "limit"
|
|
632
776
|
}, ({ query: query2 }) => fold(query2, reducer)), Match.when({
|
|
777
|
+
type: "from"
|
|
778
|
+
}, (node) => {
|
|
779
|
+
const results = fold(node.query, reducer);
|
|
780
|
+
if (node.from._tag === "query") {
|
|
781
|
+
return results.concat(fold(node.from.query, reducer));
|
|
782
|
+
}
|
|
783
|
+
return results;
|
|
784
|
+
}), Match.when({
|
|
633
785
|
type: "select"
|
|
634
786
|
}, () => []), Match.exhaustive);
|
|
635
787
|
};
|
|
788
|
+
|
|
789
|
+
// src/space-doc-version.ts
|
|
790
|
+
var SpaceDocVersion = Object.freeze({
|
|
791
|
+
/**
|
|
792
|
+
* For the documents created before the versioning was introduced.
|
|
793
|
+
*/
|
|
794
|
+
LEGACY: 0,
|
|
795
|
+
/**
|
|
796
|
+
* Current version.
|
|
797
|
+
*/
|
|
798
|
+
CURRENT: 1
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
// src/space-id.ts
|
|
802
|
+
import { subtleCrypto } from "@dxos/crypto";
|
|
803
|
+
import { PublicKey, SpaceId } from "@dxos/keys";
|
|
804
|
+
import { ComplexMap } from "@dxos/util";
|
|
805
|
+
var SPACE_IDS_CACHE = new ComplexMap(PublicKey.hash);
|
|
806
|
+
var createIdFromSpaceKey = async (spaceKey) => {
|
|
807
|
+
const cachedValue = SPACE_IDS_CACHE.get(spaceKey);
|
|
808
|
+
if (cachedValue !== void 0) {
|
|
809
|
+
return cachedValue;
|
|
810
|
+
}
|
|
811
|
+
const digest = await subtleCrypto.digest("SHA-256", spaceKey.asUint8Array());
|
|
812
|
+
const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);
|
|
813
|
+
const spaceId = SpaceId.encode(bytes);
|
|
814
|
+
SPACE_IDS_CACHE.set(spaceKey, spaceId);
|
|
815
|
+
return spaceId;
|
|
816
|
+
};
|
|
636
817
|
export {
|
|
637
818
|
DATA_NAMESPACE,
|
|
638
819
|
DatabaseDirectory,
|
|
820
|
+
EchoFeedCodec,
|
|
639
821
|
EncodedReference,
|
|
640
822
|
ForeignKey,
|
|
641
823
|
ObjectStructure,
|
|
@@ -647,6 +829,7 @@ export {
|
|
|
647
829
|
createIdFromSpaceKey,
|
|
648
830
|
decodeReference,
|
|
649
831
|
encodeReference,
|
|
832
|
+
isEdgePeerId,
|
|
650
833
|
isEncodedReference
|
|
651
834
|
};
|
|
652
835
|
//# sourceMappingURL=index.mjs.map
|