@dxos/echo-protocol 0.8.4-main.cb12b3f963 → 0.8.4-main.d05539e30a
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 +26 -7
- 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 +10 -0
- package/dist/types/src/document-structure.d.ts.map +1 -1
- 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 +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/query/ast.d.ts +19 -10
- package/dist/types/src/query/ast.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/document-structure.ts +12 -0
- package/src/edge-peer.ts +27 -0
- package/src/index.ts +1 -0
- package/src/query/ast.ts +17 -6
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
|
|
@@ -273,6 +273,15 @@ var ObjectStructure = Object.freeze({
|
|
|
273
273
|
var PROPERTY_ID = "id";
|
|
274
274
|
var DATA_NAMESPACE = "data";
|
|
275
275
|
|
|
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
|
+
|
|
276
285
|
// src/echo-feed-codec.ts
|
|
277
286
|
import { FeedProtocol } from "@dxos/protocols";
|
|
278
287
|
var ATTR_META = "@meta";
|
|
@@ -409,7 +418,16 @@ var FilterObject_ = Schema2.Struct({
|
|
|
409
418
|
/**
|
|
410
419
|
* Objects that have any of the given foreign keys.
|
|
411
420
|
*/
|
|
412
|
-
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)
|
|
413
431
|
});
|
|
414
432
|
var FilterObject = FilterObject_;
|
|
415
433
|
var FilterCompare_ = Schema2.Struct({
|
|
@@ -606,19 +624,19 @@ var Scope = Schema2.Struct({
|
|
|
606
624
|
/**
|
|
607
625
|
* The nested select statemets will select from the given spaces.
|
|
608
626
|
*
|
|
609
|
-
* NOTE: Spaces and
|
|
627
|
+
* NOTE: Spaces and feeds are unioned together if both are specified.
|
|
610
628
|
*/
|
|
611
629
|
spaceIds: Schema2.optional(Schema2.Array(Schema2.String)),
|
|
612
630
|
/**
|
|
613
|
-
* 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`.
|
|
614
632
|
*/
|
|
615
|
-
|
|
633
|
+
allFeedsFromSpaces: Schema2.optional(Schema2.Boolean),
|
|
616
634
|
/**
|
|
617
|
-
* The nested select statemets will select from the given
|
|
635
|
+
* The nested select statemets will select from the given feeds (by underlying queue DXN).
|
|
618
636
|
*
|
|
619
|
-
* NOTE: Spaces and
|
|
637
|
+
* NOTE: Spaces and feeds are unioned together if both are specified.
|
|
620
638
|
*/
|
|
621
|
-
|
|
639
|
+
feeds: Schema2.optional(Schema2.Array(DXN2.Schema))
|
|
622
640
|
});
|
|
623
641
|
var visit = (query, visitor) => {
|
|
624
642
|
visitor(query);
|
|
@@ -811,6 +829,7 @@ export {
|
|
|
811
829
|
createIdFromSpaceKey,
|
|
812
830
|
decodeReference,
|
|
813
831
|
encodeReference,
|
|
832
|
+
isEdgePeerId,
|
|
814
833
|
isEncodedReference
|
|
815
834
|
};
|
|
816
835
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/document-structure.ts", "../../../src/reference.ts", "../../../src/echo-feed-codec.ts", "../../../src/foreign-key.ts", "../../../src/query/ast.ts", "../../../src/space-doc-version.ts", "../../../src/space-id.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 getParent: (object: ObjectStructure): EncodedReference | undefined => {\n return object.system?.parent;\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 * Object parent.\n * Objects with no parent are at the top level of the object hierarchy in the space.\n */\n parent?: EncodedReference;\n\n /**\n * Only for relations.\n */\n source?: EncodedReference;\n\n /**\n * Only for relations.\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 { '/': dxn.toString() };\n },\n fromLegacyTypename: (typename: string): EncodedReference => {\n return { '/': DXN.fromTypename(typename).toString() };\n },\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FeedProtocol } from '@dxos/protocols';\n\nimport type { ForeignKey } from './foreign-key';\n\n/** Property name for meta when object is serialized to JSON. Matches @dxos/echo/internal ATTR_META. */\nconst ATTR_META = '@meta';\n\n/**\n * Codec for ECHO objects in feed block payload: JSON object ↔ UTF-8 bytes.\n * Encodes with queue position stripped; decodes with optional position injection.\n */\nexport class EchoFeedCodec {\n static readonly #encoder = new TextEncoder();\n static readonly #decoder = new TextDecoder();\n\n /**\n * Prepares a value for feed storage (strips queue position from metadata) and encodes to bytes.\n */\n static encode(value: Record<string, unknown>): Uint8Array {\n const prepared = EchoFeedCodec.#stripQueuePosition(value);\n return EchoFeedCodec.#encoder.encode(JSON.stringify(prepared));\n }\n\n /**\n * Decodes feed block bytes to a JSON value.\n * If position is provided, injects queue position into the decoded object's metadata.\n */\n static decode(data: Uint8Array, position?: number): Record<string, unknown> {\n const decoded = JSON.parse(EchoFeedCodec.#decoder.decode(data));\n if (position !== undefined && typeof decoded === 'object' && decoded !== null) {\n EchoFeedCodec.#setQueuePosition(decoded, position);\n }\n return decoded;\n }\n\n static #stripQueuePosition(value: Record<string, unknown>): Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n const obj = structuredClone(value);\n const meta = obj[ATTR_META] as { keys?: ForeignKey[] } | undefined;\n if (meta?.keys?.some((key: ForeignKey) => key.source === FeedProtocol.KEY_QUEUE_POSITION)) {\n meta.keys = meta.keys.filter((key: ForeignKey) => key.source !== FeedProtocol.KEY_QUEUE_POSITION);\n }\n return obj;\n }\n\n static #setQueuePosition(obj: Record<string, any>, position: number): void {\n obj[ATTR_META] ??= { keys: [] };\n obj[ATTR_META]!.keys ??= [];\n const keys = obj[ATTR_META]!.keys!;\n for (let i = 0; i < keys.length; i++) {\n if (keys[i].source === FeedProtocol.KEY_QUEUE_POSITION) {\n keys.splice(i, 1);\n i--;\n }\n }\n keys.push({\n source: FeedProtocol.KEY_QUEUE_POSITION,\n id: position.toString(),\n });\n }\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 matches any type',\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});\n\nexport interface FilterContains extends Schema.Schema.Type<typeof FilterContains_> {}\n\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});\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});\n\nexport interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {}\nexport const FilterRange: Schema.Schema<FilterRange> = FilterRange_;\n\n/**\n * Filter by system timestamp (createdAt / updatedAt).\n * Timestamps are unix milliseconds stored in the object meta index.\n */\nconst FilterTimestamp_ = Schema.Struct({\n type: Schema.Literal('timestamp'),\n field: Schema.Literal('createdAt', 'updatedAt'),\n operator: Schema.Literal('gt', 'gte', 'lt', 'lte'),\n value: Schema.Number,\n});\n\nexport interface FilterTimestamp extends Schema.Schema.Type<typeof FilterTimestamp_> {}\nexport const FilterTimestamp: Schema.Schema<FilterTimestamp> = FilterTimestamp_;\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});\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});\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});\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});\n\nexport interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {}\nexport const FilterOr: Schema.Schema<FilterOr> = FilterOr_;\n\n/**\n * Filter objects that are children of the specified parents.\n * With transitive=true (default), matches grandchildren and beyond.\n */\nconst FilterChildOf_ = Schema.Struct({\n type: Schema.Literal('child-of'),\n /** Parent DXNs to match children of. */\n parents: Schema.Array(DXN.Schema),\n /** Whether to match transitively (grandchildren, etc.). Defaults to true. */\n transitive: Schema.Boolean,\n});\n\nexport interface FilterChildOf extends Schema.Schema.Type<typeof FilterChildOf_> {}\nexport const FilterChildOf: Schema.Schema<FilterChildOf> = FilterChildOf_;\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 FilterTimestamp,\n FilterTextSearch,\n FilterChildOf,\n FilterNot,\n FilterAnd,\n FilterOr,\n).annotations({ identifier: 'org.dxos.schema.filter' });\n\nexport type Filter = Schema.Schema.Type<typeof Filter>;\n\n/**\n * Query objects by type, id, and/or predicates.\n */\nconst QuerySelectClause_ = Schema.Struct({\n type: Schema.Literal('select'),\n filter: Schema.suspend(() => Filter),\n});\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});\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});\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 /**\n * Property path where the reference is located.\n * If null, matches references from any property.\n */\n property: Schema.NullOr(Schema.String),\n typename: TypenameSpecifier,\n});\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});\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});\n\nexport interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {}\nexport const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause> = QueryRelationTraversalClause_;\n\n/**\n * Traverse parent-child hierarchy.\n */\nconst QueryHierarchyTraversalClause_ = Schema.Struct({\n type: Schema.Literal('hierarchy-traversal'),\n anchor: Schema.suspend(() => Query),\n /**\n * to-parent: traverse from child to parent.\n * to-children: traverse from parent to children.\n */\n direction: Schema.Literal('to-parent', 'to-children'),\n});\n\nexport interface QueryHierarchyTraversalClause extends Schema.Schema.Type<typeof QueryHierarchyTraversalClause_> {}\nexport const QueryHierarchyTraversalClause: Schema.Schema<QueryHierarchyTraversalClause> =\n QueryHierarchyTraversalClause_;\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});\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});\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 Schema.Struct({\n // Order by relevance rank (for FTS/vector search results).\n // Default direction is 'desc' (higher rank = better match first).\n kind: Schema.Literal('rank'),\n direction: OrderDirection,\n }),\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});\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});\n\nexport interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}\nexport const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;\n\n/**\n * Limit the number of results.\n */\nconst QueryLimitClause_ = Schema.Struct({\n type: Schema.Literal('limit'),\n query: Schema.suspend(() => Query),\n limit: Schema.Number,\n});\n\nexport interface QueryLimitClause extends Schema.Schema.Type<typeof QueryLimitClause_> {}\nexport const QueryLimitClause: Schema.Schema<QueryLimitClause> = QueryLimitClause_;\n\nexport const QueryFromClause_ = Schema.Struct({\n type: Schema.Literal('from'),\n query: Schema.suspend(() => Query),\n from: Schema.Union(\n Schema.TaggedStruct('scope', {\n scope: Schema.suspend(() => Scope),\n }),\n Schema.TaggedStruct('query', {\n query: Schema.suspend(() => Query),\n }),\n ),\n});\nexport interface QueryFromClause extends Schema.Schema.Type<typeof QueryFromClause_> {}\nexport const QueryFromClause: Schema.Schema<QueryFromClause> = QueryFromClause_;\n\nconst Query_ = Schema.Union(\n QuerySelectClause,\n QueryFilterClause,\n QueryReferenceTraversalClause,\n QueryIncomingReferencesClause,\n QueryRelationClause,\n QueryRelationTraversalClause,\n QueryHierarchyTraversalClause,\n QueryUnionClause,\n QuerySetDifferenceClause,\n QueryOrderClause,\n QueryOptionsClause,\n QueryLimitClause,\n QueryFromClause,\n).annotations({ identifier: 'org.dxos.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 * Nested select statements will use this option to filter deleted objects.\n */\n deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),\n\n /**\n * Diagnostics-only label for logs / tooling (not used by execution semantics).\n */\n debugLabel: Schema.optional(Schema.String),\n});\n\nexport interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}\n\n/**\n * Specifies the scope of the data to query from.\n */\nexport const Scope = 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 * If true, the nested select statements will select from all queues in the spaces specified by `spaceIds`.\n */\n allQueuesFromSpaces: Schema.optional(Schema.Boolean),\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});\nexport interface Scope extends Schema.Schema.Type<typeof Scope> {}\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: 'hierarchy-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: 'limit' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'from' }, (node) => {\n visit(node.query, visitor);\n if (node.from._tag === 'query') {\n visit(node.from.query, visitor);\n }\n }),\n Match.when({ type: 'select' }, () => {}),\n Match.exhaustive,\n );\n};\n\n/**\n * Recursively transforms a query tree bottom-up.\n * The mapper receives each node with its children already transformed.\n */\nexport const map = (query: Query, mapper: (node: Query) => Query): Query => {\n const mapped: Query = Match.value(query).pipe(\n Match.when({ type: 'filter' }, (node) => ({ ...node, selection: map(node.selection, mapper) })),\n Match.when({ type: 'reference-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'incoming-references' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'relation' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'relation-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'hierarchy-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'options' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'order' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'limit' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'from' }, (node) => ({\n ...node,\n query: map(node.query, mapper),\n ...(node.from._tag === 'query' ? { from: { _tag: 'query' as const, query: map(node.from.query, mapper) } } : {}),\n })),\n Match.when({ type: 'union' }, (node) => ({ ...node, queries: node.queries.map((q) => map(q, mapper)) })),\n Match.when({ type: 'set-difference' }, (node) => ({\n ...node,\n source: map(node.source, mapper),\n exclude: map(node.exclude, mapper),\n })),\n Match.when({ type: 'select' }, (node) => node),\n Match.exhaustive,\n );\n return mapper(mapped);\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: 'hierarchy-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: 'limit' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'from' }, (node) => {\n const results = fold(node.query, reducer);\n if (node.from._tag === 'query') {\n return results.concat(fold(node.from.query, reducer));\n }\n return results;\n }),\n Match.when({ type: 'select' }, () => []),\n Match.exhaustive,\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"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,SAASA,iBAAiB;AAE1B,SAASC,mBAAmB;;;ACF5B,SAASC,sBAAsB;AAC/B,SAASC,KAAKC,uBAAuC;AAS9C,IAAMC,YAAN,MAAMA,WAAAA;;;;;;;;;EAKX,OAAOC,gBAAgB;E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MC,kBAAkB,IAAID,WAA+BF,UAAUI,IAAI;AAMlE,IAAMC,uBAAuB,OAAOC,aAAAA;AACzC,QAAMC,cAAcJ,gBAAgBK,IAAIF,QAAAA;AACxC,MAAIC,gBAAgBE,QAAW;AAC7B,WAAOF;EACT;AAEA,QAAMG,SAAS,MAAMX,aAAaW,OAAO,WAAWJ,SAASK,aAAY,CAAA;AAEzE,QAAMC,QAAQ,IAAIC,WAAWH,MAAAA,EAAQI,MAAM,GAAGb,QAAQc,UAAU;AAChE,QAAMC,UAAUf,QAAQgB,OAAOL,KAAAA;AAC/BT,kBAAgBe,IAAIZ,UAAUU,OAAAA;AAC9B,SAAOA;AACT;",
|
|
6
|
-
"names": ["invariant", "visitValues", "assertArgument", "DXN", "LOCAL_SPACE_TAG", "Reference", "TYPE_PROTOCOL", "fromDXN", "dxn", "kind", "TYPE", "parts", "ECHO", "undefined", "fromValue", "value", "objectId", "protocol", "host", "localObjectReference", "fromLegacyTypename", "type", "fromObjectIdAndSpaceKey", "spaceKey", "toHex", "_objectId", "_protocol", "_host", "_dxn", "encode", "toDXN", "REFERENCE_TYPE_TAG", "encodeReference", "reference", "toString", "decodeReference", "Error", "dxnString", "length", "slice", "includes", "parse", "isEncodedReference", "Object", "keys", "EncodedReference", "freeze", "getReferenceString", "typename", "fromTypename", "DatabaseDirectory", "rawSpaceKey", "rawKey", "invariant", "getInlineObject", "getLink", "doc", "id", "make", "spaceKey", "objects", "links", "kind", "isDeleted", "getRelationSource", "object", "getRelationTarget", "getParent", "value", "isEncodedReference", "references", "push", "path", "reference", "visitValues", "String", "key", "getTags", "makeObject", "type", "data", "system", "meta", "makeRelation", "source", "target", "deleted", "FeedProtocol", "ATTR_META", "EchoFeedCodec", "TextEncoder", "TextDecoder", "encode", "value", "prepared", "JSON", "stringify", "decode", "data", "position", "decoded", "parse", "undefined", "obj", "structuredClone", "meta", "keys", "some", "key", "source", "KEY_QUEUE_POSITION", "filter", "i", "length", "splice", "push", "id", "toString", "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", "FilterTimestamp_", "field", "Number", "FilterTimestamp", "FilterTextSearch_", "text", "searchKind", "FilterTextSearch", "FilterNot_", "filter", "FilterNot", "FilterAnd_", "filters", "FilterAnd", "FilterOr_", "FilterOr", "FilterChildOf_", "parents", "transitive", "Boolean", "FilterChildOf", "identifier", "QuerySelectClause_", "QuerySelectClause", "QueryFilterClause_", "selection", "Query", "QueryFilterClause", "QueryReferenceTraversalClause_", "anchor", "property", "QueryReferenceTraversalClause", "QueryIncomingReferencesClause_", "NullOr", "QueryIncomingReferencesClause", "QueryRelationClause_", "direction", "QueryRelationClause", "QueryRelationTraversalClause_", "QueryRelationTraversalClause", "QueryHierarchyTraversalClause_", "QueryHierarchyTraversalClause", "QueryUnionClause_", "queries", "QueryUnionClause", "QuerySetDifferenceClause_", "source", "exclude", "QuerySetDifferenceClause", "OrderDirection", "Order_", "kind", "Order", "QueryOrderClause_", "query", "order", "QueryOrderClause", "QueryOptionsClause_", "options", "QueryOptions", "QueryOptionsClause", "QueryLimitClause_", "limit", "QueryLimitClause", "QueryFromClause_", "TaggedStruct", "scope", "Scope", "QueryFromClause", "Query_", "deleted", "debugLabel", "spaceIds", "
|
|
3
|
+
"sources": ["../../../src/document-structure.ts", "../../../src/reference.ts", "../../../src/edge-peer.ts", "../../../src/echo-feed-codec.ts", "../../../src/foreign-key.ts", "../../../src/query/ast.ts", "../../../src/space-doc-version.ts", "../../../src/space-id.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 getParent: (object: ObjectStructure): EncodedReference | undefined => {\n return object.system?.parent;\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 * Fully-qualified registry key for the object (FQN format, e.g. `org.example.type.foo`).\n * Identifies the canonical registry entry the object instance was created from.\n */\n key?: string;\n\n /**\n * Semantic version of the registry entry the object was created from.\n * Must be a valid semver string (e.g. `1.2.3`).\n */\n version?: 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 * Object parent.\n * Objects with no parent are at the top level of the object hierarchy in the space.\n */\n parent?: EncodedReference;\n\n /**\n * Only for relations.\n */\n source?: EncodedReference;\n\n /**\n * Only for relations.\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 { '/': dxn.toString() };\n },\n fromLegacyTypename: (typename: string): EncodedReference => {\n return { '/': DXN.fromTypename(typename).toString() };\n },\n});\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { type SpaceId } from '@dxos/keys';\nimport { EdgeService } from '@dxos/protocols';\nimport { compositeKey } from '@dxos/util';\n\n/**\n * Returns true if the given peerId belongs to an EDGE replicator (Automerge or Subduction).\n *\n * When `spaceId` is provided, the match is scoped to that space (peerId must start with\n * `<service>:<spaceId>`). When omitted, only the leading service segment is checked\n * (peerId must start with `<service>:`), which is useful when the caller doesn't have a\n * spaceId on hand or wants to match any edge replicator regardless of space.\n */\nexport const isEdgePeerId = (peerId: string, spaceId?: SpaceId): boolean => {\n const automergePrefix =\n spaceId !== undefined\n ? compositeKey(EdgeService.AUTOMERGE_REPLICATOR, spaceId)\n : `${EdgeService.AUTOMERGE_REPLICATOR}:`;\n const subductionPrefix =\n spaceId !== undefined\n ? compositeKey(EdgeService.SUBDUCTION_REPLICATOR, spaceId)\n : `${EdgeService.SUBDUCTION_REPLICATOR}:`;\n return peerId.startsWith(automergePrefix) || peerId.startsWith(subductionPrefix);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FeedProtocol } from '@dxos/protocols';\n\nimport type { ForeignKey } from './foreign-key';\n\n/** Property name for meta when object is serialized to JSON. Matches @dxos/echo/internal ATTR_META. */\nconst ATTR_META = '@meta';\n\n/**\n * Codec for ECHO objects in feed block payload: JSON object ↔ UTF-8 bytes.\n * Encodes with queue position stripped; decodes with optional position injection.\n */\nexport class EchoFeedCodec {\n static readonly #encoder = new TextEncoder();\n static readonly #decoder = new TextDecoder();\n\n /**\n * Prepares a value for feed storage (strips queue position from metadata) and encodes to bytes.\n */\n static encode(value: Record<string, unknown>): Uint8Array {\n const prepared = EchoFeedCodec.#stripQueuePosition(value);\n return EchoFeedCodec.#encoder.encode(JSON.stringify(prepared));\n }\n\n /**\n * Decodes feed block bytes to a JSON value.\n * If position is provided, injects queue position into the decoded object's metadata.\n */\n static decode(data: Uint8Array, position?: number): Record<string, unknown> {\n const decoded = JSON.parse(EchoFeedCodec.#decoder.decode(data));\n if (position !== undefined && typeof decoded === 'object' && decoded !== null) {\n EchoFeedCodec.#setQueuePosition(decoded, position);\n }\n return decoded;\n }\n\n static #stripQueuePosition(value: Record<string, unknown>): Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n const obj = structuredClone(value);\n const meta = obj[ATTR_META] as { keys?: ForeignKey[] } | undefined;\n if (meta?.keys?.some((key: ForeignKey) => key.source === FeedProtocol.KEY_QUEUE_POSITION)) {\n meta.keys = meta.keys.filter((key: ForeignKey) => key.source !== FeedProtocol.KEY_QUEUE_POSITION);\n }\n return obj;\n }\n\n static #setQueuePosition(obj: Record<string, any>, position: number): void {\n obj[ATTR_META] ??= { keys: [] };\n obj[ATTR_META]!.keys ??= [];\n const keys = obj[ATTR_META]!.keys!;\n for (let i = 0; i < keys.length; i++) {\n if (keys[i].source === FeedProtocol.KEY_QUEUE_POSITION) {\n keys.splice(i, 1);\n i--;\n }\n }\n keys.push({\n source: FeedProtocol.KEY_QUEUE_POSITION,\n id: position.toString(),\n });\n }\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 matches any type',\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 /**\n * Match objects whose meta `key` equals this fully-qualified registry key (FQN format).\n */\n metaKey: Schema.optional(Schema.String),\n\n /**\n * Semver range matched against the object's meta `version`.\n * Only consulted when {@link metaKey} is set. Objects with no `version` do not satisfy a version-constrained filter.\n */\n metaVersion: Schema.optional(Schema.String),\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});\n\nexport interface FilterContains extends Schema.Schema.Type<typeof FilterContains_> {}\n\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});\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});\n\nexport interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {}\nexport const FilterRange: Schema.Schema<FilterRange> = FilterRange_;\n\n/**\n * Filter by system timestamp (createdAt / updatedAt).\n * Timestamps are unix milliseconds stored in the object meta index.\n */\nconst FilterTimestamp_ = Schema.Struct({\n type: Schema.Literal('timestamp'),\n field: Schema.Literal('createdAt', 'updatedAt'),\n operator: Schema.Literal('gt', 'gte', 'lt', 'lte'),\n value: Schema.Number,\n});\n\nexport interface FilterTimestamp extends Schema.Schema.Type<typeof FilterTimestamp_> {}\nexport const FilterTimestamp: Schema.Schema<FilterTimestamp> = FilterTimestamp_;\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});\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});\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});\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});\n\nexport interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {}\nexport const FilterOr: Schema.Schema<FilterOr> = FilterOr_;\n\n/**\n * Filter objects that are children of the specified parents.\n * With transitive=true (default), matches grandchildren and beyond.\n */\nconst FilterChildOf_ = Schema.Struct({\n type: Schema.Literal('child-of'),\n /** Parent DXNs to match children of. */\n parents: Schema.Array(DXN.Schema),\n /** Whether to match transitively (grandchildren, etc.). Defaults to true. */\n transitive: Schema.Boolean,\n});\n\nexport interface FilterChildOf extends Schema.Schema.Type<typeof FilterChildOf_> {}\nexport const FilterChildOf: Schema.Schema<FilterChildOf> = FilterChildOf_;\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 FilterTimestamp,\n FilterTextSearch,\n FilterChildOf,\n FilterNot,\n FilterAnd,\n FilterOr,\n).annotations({ identifier: 'org.dxos.schema.filter' });\n\nexport type Filter = Schema.Schema.Type<typeof Filter>;\n\n/**\n * Query objects by type, id, and/or predicates.\n */\nconst QuerySelectClause_ = Schema.Struct({\n type: Schema.Literal('select'),\n filter: Schema.suspend(() => Filter),\n});\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});\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});\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 /**\n * Property path where the reference is located.\n * If null, matches references from any property.\n */\n property: Schema.NullOr(Schema.String),\n typename: TypenameSpecifier,\n});\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});\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});\n\nexport interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {}\nexport const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause> = QueryRelationTraversalClause_;\n\n/**\n * Traverse parent-child hierarchy.\n */\nconst QueryHierarchyTraversalClause_ = Schema.Struct({\n type: Schema.Literal('hierarchy-traversal'),\n anchor: Schema.suspend(() => Query),\n /**\n * to-parent: traverse from child to parent.\n * to-children: traverse from parent to children.\n */\n direction: Schema.Literal('to-parent', 'to-children'),\n});\n\nexport interface QueryHierarchyTraversalClause extends Schema.Schema.Type<typeof QueryHierarchyTraversalClause_> {}\nexport const QueryHierarchyTraversalClause: Schema.Schema<QueryHierarchyTraversalClause> =\n QueryHierarchyTraversalClause_;\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});\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});\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 Schema.Struct({\n // Order by relevance rank (for FTS/vector search results).\n // Default direction is 'desc' (higher rank = better match first).\n kind: Schema.Literal('rank'),\n direction: OrderDirection,\n }),\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});\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});\n\nexport interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {}\nexport const QueryOptionsClause: Schema.Schema<QueryOptionsClause> = QueryOptionsClause_;\n\n/**\n * Limit the number of results.\n */\nconst QueryLimitClause_ = Schema.Struct({\n type: Schema.Literal('limit'),\n query: Schema.suspend(() => Query),\n limit: Schema.Number,\n});\n\nexport interface QueryLimitClause extends Schema.Schema.Type<typeof QueryLimitClause_> {}\nexport const QueryLimitClause: Schema.Schema<QueryLimitClause> = QueryLimitClause_;\n\nexport const QueryFromClause_ = Schema.Struct({\n type: Schema.Literal('from'),\n query: Schema.suspend(() => Query),\n from: Schema.Union(\n Schema.TaggedStruct('scope', {\n scope: Schema.suspend(() => Scope),\n }),\n Schema.TaggedStruct('query', {\n query: Schema.suspend(() => Query),\n }),\n ),\n});\nexport interface QueryFromClause extends Schema.Schema.Type<typeof QueryFromClause_> {}\nexport const QueryFromClause: Schema.Schema<QueryFromClause> = QueryFromClause_;\n\nconst Query_ = Schema.Union(\n QuerySelectClause,\n QueryFilterClause,\n QueryReferenceTraversalClause,\n QueryIncomingReferencesClause,\n QueryRelationClause,\n QueryRelationTraversalClause,\n QueryHierarchyTraversalClause,\n QueryUnionClause,\n QuerySetDifferenceClause,\n QueryOrderClause,\n QueryOptionsClause,\n QueryLimitClause,\n QueryFromClause,\n).annotations({ identifier: 'org.dxos.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 * Nested select statements will use this option to filter deleted objects.\n */\n deleted: Schema.optional(Schema.Literal('include', 'exclude', 'only')),\n\n /**\n * Diagnostics-only label for logs / tooling (not used by execution semantics).\n */\n debugLabel: Schema.optional(Schema.String),\n});\n\nexport interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {}\n\n/**\n * Specifies the scope of the data to query from.\n */\nexport const Scope = Schema.Struct({\n /**\n * The nested select statemets will select from the given spaces.\n *\n * NOTE: Spaces and feeds are unioned together if both are specified.\n */\n spaceIds: Schema.optional(Schema.Array(Schema.String)),\n\n /**\n * If true, the nested select statements will select from all feeds in the spaces specified by `spaceIds`.\n */\n allFeedsFromSpaces: Schema.optional(Schema.Boolean),\n\n /**\n * The nested select statemets will select from the given feeds (by underlying queue DXN).\n *\n * NOTE: Spaces and feeds are unioned together if both are specified.\n */\n feeds: Schema.optional(Schema.Array(DXN.Schema)),\n});\nexport interface Scope extends Schema.Schema.Type<typeof Scope> {}\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: 'hierarchy-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: 'limit' }, ({ query }) => visit(query, visitor)),\n Match.when({ type: 'from' }, (node) => {\n visit(node.query, visitor);\n if (node.from._tag === 'query') {\n visit(node.from.query, visitor);\n }\n }),\n Match.when({ type: 'select' }, () => {}),\n Match.exhaustive,\n );\n};\n\n/**\n * Recursively transforms a query tree bottom-up.\n * The mapper receives each node with its children already transformed.\n */\nexport const map = (query: Query, mapper: (node: Query) => Query): Query => {\n const mapped: Query = Match.value(query).pipe(\n Match.when({ type: 'filter' }, (node) => ({ ...node, selection: map(node.selection, mapper) })),\n Match.when({ type: 'reference-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'incoming-references' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'relation' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'relation-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'hierarchy-traversal' }, (node) => ({ ...node, anchor: map(node.anchor, mapper) })),\n Match.when({ type: 'options' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'order' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'limit' }, (node) => ({ ...node, query: map(node.query, mapper) })),\n Match.when({ type: 'from' }, (node) => ({\n ...node,\n query: map(node.query, mapper),\n ...(node.from._tag === 'query' ? { from: { _tag: 'query' as const, query: map(node.from.query, mapper) } } : {}),\n })),\n Match.when({ type: 'union' }, (node) => ({ ...node, queries: node.queries.map((q) => map(q, mapper)) })),\n Match.when({ type: 'set-difference' }, (node) => ({\n ...node,\n source: map(node.source, mapper),\n exclude: map(node.exclude, mapper),\n })),\n Match.when({ type: 'select' }, (node) => node),\n Match.exhaustive,\n );\n return mapper(mapped);\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: 'hierarchy-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: 'limit' }, ({ query }) => fold(query, reducer)),\n Match.when({ type: 'from' }, (node) => {\n const results = fold(node.query, reducer);\n if (node.from._tag === 'query') {\n return results.concat(fold(node.from.query, reducer));\n }\n return results;\n }),\n Match.when({ type: 'select' }, () => []),\n Match.exhaustive,\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"],
|
|
5
|
+
"mappings": ";;;;;;;AAIA,SAASA,iBAAiB;AAE1B,SAASC,mBAAmB;;;ACF5B,SAASC,sBAAsB;AAC/B,SAASC,KAAKC,uBAAuC;AAS9C,IAAMC,YAAN,MAAMA,WAAAA;;;;;;;;;EAKX,OAAOC,gBAAgB;EAEvB,OAAOC,QAAQC,KAAqB;AAClC,YAAQA,IAAIC,MAAI;MACd,KAAKN,IAAIM,KAAKC;AACZ,eAAO,IAAIL,WAAUG,IAAIG,MAAM,CAAA,GAAIN,WAAUC,eAAe,YAAYE,GAAAA;MAC1E,KAAKL,IAAIM,KAAKG;AACZ,YAAIJ,IAAIG,MAAM,CAAA,MAAOP,iBAAiB;AACpC,iBAAO,IAAIC,WAAUG,IAAIG,MAAM,CAAA,GAAIE,QAAWA,QAAWL,GAAAA;QAC3D,OAAO;AACL,iBAAO,IAAIH,WAAUG,IAAIG,MAAM,CAAA,GAAIE,QAAWL,IAAIG,MAAM,CAAA,GAAIH,GAAAA;QAC9D;MACF;AACE,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ID,WAA+BF,UAAUI,IAAI;AAMlE,IAAMC,uBAAuB,OAAOC,aAAAA;AACzC,QAAMC,cAAcJ,gBAAgBK,IAAIF,QAAAA;AACxC,MAAIC,gBAAgBE,QAAW;AAC7B,WAAOF;EACT;AAEA,QAAMG,SAAS,MAAMX,aAAaW,OAAO,WAAWJ,SAASK,aAAY,CAAA;AAEzE,QAAMC,QAAQ,IAAIC,WAAWH,MAAAA,EAAQI,MAAM,GAAGb,QAAQc,UAAU;AAChE,QAAMC,UAAUf,QAAQgB,OAAOL,KAAAA;AAC/BT,kBAAgBe,IAAIZ,UAAUU,OAAAA;AAC9B,SAAOA;AACT;",
|
|
6
|
+
"names": ["invariant", "visitValues", "assertArgument", "DXN", "LOCAL_SPACE_TAG", "Reference", "TYPE_PROTOCOL", "fromDXN", "dxn", "kind", "TYPE", "parts", "ECHO", "undefined", "fromValue", "value", "objectId", "protocol", "host", "localObjectReference", "fromLegacyTypename", "type", "fromObjectIdAndSpaceKey", "spaceKey", "toHex", "_objectId", "_protocol", "_host", "_dxn", "encode", "toDXN", "REFERENCE_TYPE_TAG", "encodeReference", "reference", "toString", "decodeReference", "Error", "dxnString", "length", "slice", "includes", "parse", "isEncodedReference", "Object", "keys", "EncodedReference", "freeze", "getReferenceString", "typename", "fromTypename", "DatabaseDirectory", "rawSpaceKey", "rawKey", "invariant", "getInlineObject", "getLink", "doc", "id", "make", "spaceKey", "objects", "links", "kind", "isDeleted", "getRelationSource", "object", "getRelationTarget", "getParent", "value", "isEncodedReference", "references", "push", "path", "reference", "visitValues", "String", "key", "getTags", "makeObject", "type", "data", "system", "meta", "makeRelation", "source", "target", "deleted", "EdgeService", "compositeKey", "isEdgePeerId", "peerId", "spaceId", "automergePrefix", "undefined", "AUTOMERGE_REPLICATOR", "subductionPrefix", "SUBDUCTION_REPLICATOR", "startsWith", "FeedProtocol", "ATTR_META", "EchoFeedCodec", "TextEncoder", "TextDecoder", "encode", "value", "prepared", "JSON", "stringify", "decode", "data", "position", "decoded", "parse", "undefined", "obj", "structuredClone", "meta", "keys", "some", "key", "source", "KEY_QUEUE_POSITION", "filter", "i", "length", "splice", "push", "id", "toString", "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", "metaKey", "metaVersion", "FilterObject", "FilterCompare_", "operator", "Unknown", "FilterCompare", "FilterIn_", "values", "Any", "FilterIn", "FilterContains_", "FilterContains", "FilterTag_", "tag", "FilterTag", "FilterRange_", "from", "to", "FilterRange", "FilterTimestamp_", "field", "Number", "FilterTimestamp", "FilterTextSearch_", "text", "searchKind", "FilterTextSearch", "FilterNot_", "filter", "FilterNot", "FilterAnd_", "filters", "FilterAnd", "FilterOr_", "FilterOr", "FilterChildOf_", "parents", "transitive", "Boolean", "FilterChildOf", "identifier", "QuerySelectClause_", "QuerySelectClause", "QueryFilterClause_", "selection", "Query", "QueryFilterClause", "QueryReferenceTraversalClause_", "anchor", "property", "QueryReferenceTraversalClause", "QueryIncomingReferencesClause_", "NullOr", "QueryIncomingReferencesClause", "QueryRelationClause_", "direction", "QueryRelationClause", "QueryRelationTraversalClause_", "QueryRelationTraversalClause", "QueryHierarchyTraversalClause_", "QueryHierarchyTraversalClause", "QueryUnionClause_", "queries", "QueryUnionClause", "QuerySetDifferenceClause_", "source", "exclude", "QuerySetDifferenceClause", "OrderDirection", "Order_", "kind", "Order", "QueryOrderClause_", "query", "order", "QueryOrderClause", "QueryOptionsClause_", "options", "QueryOptions", "QueryOptionsClause", "QueryLimitClause_", "limit", "QueryLimitClause", "QueryFromClause_", "TaggedStruct", "scope", "Scope", "QueryFromClause", "Query_", "deleted", "debugLabel", "spaceIds", "allFeedsFromSpaces", "feeds", "visit", "visitor", "Match", "pipe", "when", "forEach", "q", "node", "_tag", "exhaustive", "map", "mapper", "mapped", "fold", "reducer", "withReturnType", "flatMap", "concat", "results", "SpaceDocVersion", "Object", "freeze", "LEGACY", "CURRENT", "subtleCrypto", "PublicKey", "SpaceId", "ComplexMap", "SPACE_IDS_CACHE", "hash", "createIdFromSpaceKey", "spaceKey", "cachedValue", "get", "undefined", "digest", "asUint8Array", "bytes", "Uint8Array", "slice", "byteLength", "spaceId", "encode", "set"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/reference.ts":{"bytes":17351,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/document-structure.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/reference.ts":{"bytes":17351,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/document-structure.ts":{"bytes":17029,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/reference.ts","kind":"import-statement","original":"./reference"}],"format":"esm"},"src/edge-peer.ts":{"bytes":3448,"imports":[{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/echo-feed-codec.ts":{"bytes":7738,"imports":[{"path":"@dxos/protocols","kind":"import-statement","external":true}],"format":"esm"},"src/foreign-key.ts":{"bytes":2525,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true}],"format":"esm"},"src/query/ast.ts":{"bytes":59945,"imports":[{"path":"effect/Match","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/foreign-key.ts","kind":"import-statement","original":"../foreign-key"}],"format":"esm"},"src/query/index.ts":{"bytes":427,"imports":[{"path":"src/query/ast.ts","kind":"import-statement","original":"./ast"}],"format":"esm"},"src/space-doc-version.ts":{"bytes":1443,"imports":[],"format":"esm"},"src/space-id.ts":{"bytes":3461,"imports":[{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1124,"imports":[{"path":"src/document-structure.ts","kind":"import-statement","original":"./document-structure"},{"path":"src/edge-peer.ts","kind":"import-statement","original":"./edge-peer"},{"path":"src/echo-feed-codec.ts","kind":"import-statement","original":"./echo-feed-codec"},{"path":"src/foreign-key.ts","kind":"import-statement","original":"./foreign-key"},{"path":"src/query/index.ts","kind":"import-statement","original":"./query"},{"path":"src/reference.ts","kind":"import-statement","original":"./reference"},{"path":"src/space-doc-version.ts","kind":"import-statement","original":"./space-doc-version"},{"path":"src/space-id.ts","kind":"import-statement","original":"./space-id"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":57694},"dist/lib/neutral/index.mjs":{"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"effect/Match","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["DATA_NAMESPACE","DatabaseDirectory","EchoFeedCodec","EncodedReference","ForeignKey","ObjectStructure","PROPERTY_ID","QueryAST","REFERENCE_TYPE_TAG","Reference","SpaceDocVersion","createIdFromSpaceKey","decodeReference","encodeReference","isEdgePeerId","isEncodedReference"],"entryPoint":"src/index.ts","inputs":{"src/document-structure.ts":{"bytesInOutput":3108},"src/reference.ts":{"bytesInOutput":3823},"src/index.ts":{"bytesInOutput":0},"src/edge-peer.ts":{"bytesInOutput":512},"src/echo-feed-codec.ts":{"bytesInOutput":1719},"src/foreign-key.ts":{"bytesInOutput":586},"src/query/ast.ts":{"bytesInOutput":14667},"src/query/index.ts":{"bytesInOutput":0},"src/space-doc-version.ts":{"bytesInOutput":179},"src/space-id.ts":{"bytesInOutput":604}},"bytes":25938}}}
|
|
@@ -113,6 +113,16 @@ export type ObjectMeta = {
|
|
|
113
113
|
* NOTE: Optional for backwards compatibilty.
|
|
114
114
|
*/
|
|
115
115
|
tags?: string[];
|
|
116
|
+
/**
|
|
117
|
+
* Fully-qualified registry key for the object (FQN format, e.g. `org.example.type.foo`).
|
|
118
|
+
* Identifies the canonical registry entry the object instance was created from.
|
|
119
|
+
*/
|
|
120
|
+
key?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Semantic version of the registry entry the object was created from.
|
|
123
|
+
* Must be a valid semver string (e.g. `1.2.3`).
|
|
124
|
+
*/
|
|
125
|
+
version?: string;
|
|
116
126
|
};
|
|
117
127
|
/**
|
|
118
128
|
* Automerge object system properties.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-structure.d.ts","sourceRoot":"","sources":["../../../src/document-structure.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,K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YAAY,GAAG;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAE7B;;OAEG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SpaceId } from '@dxos/keys';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given peerId belongs to an EDGE replicator (Automerge or Subduction).
|
|
4
|
+
*
|
|
5
|
+
* When `spaceId` is provided, the match is scoped to that space (peerId must start with
|
|
6
|
+
* `<service>:<spaceId>`). When omitted, only the leading service segment is checked
|
|
7
|
+
* (peerId must start with `<service>:`), which is useful when the caller doesn't have a
|
|
8
|
+
* spaceId on hand or wants to match any edge replicator regardless of space.
|
|
9
|
+
*/
|
|
10
|
+
export declare const isEdgePeerId: (peerId: string, spaceId?: SpaceId) => boolean;
|
|
11
|
+
//# sourceMappingURL=edge-peer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-peer.d.ts","sourceRoot":"","sources":["../../../src/edge-peer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,YAAY,OAAO,KAAG,OAUhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,mBAAmB,mBAAmB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,mBAAmB,mBAAmB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|