@dxos/echo-protocol 0.8.1 → 0.8.2-main.10c050d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +341 -1
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +338 -3
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +340 -1
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/document-structure.d.ts +69 -17
- package/dist/types/src/document-structure.d.ts.map +1 -1
- package/dist/types/src/foreign-key.d.ts +19 -0
- package/dist/types/src/foreign-key.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/query/ast.d.ts +194 -0
- package/dist/types/src/query/ast.d.ts.map +1 -0
- package/dist/types/src/query/index.d.ts +2 -0
- package/dist/types/src/query/index.d.ts.map +1 -0
- package/dist/types/src/reference.d.ts.map +1 -1
- package/dist/types/src/space-id.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -5
- package/src/document-structure.ts +170 -21
- package/src/foreign-key.ts +27 -0
- package/src/index.ts +2 -0
- package/src/query/ast.ts +252 -0
- package/src/query/index.ts +5 -0
- package/src/reference.ts +16 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* Filter by object type and properties.
|
|
4
|
+
*
|
|
5
|
+
* Clauses are combined using logical AND.
|
|
6
|
+
*/
|
|
7
|
+
declare const FilterObject_: Schema.Struct<{
|
|
8
|
+
type: Schema.Literal<["object"]>;
|
|
9
|
+
typename: Schema.Union<[Schema.refine<string, typeof Schema.NonEmptyString>, typeof Schema.Null]>;
|
|
10
|
+
id: Schema.optional<Schema.Array$<import("@dxos/keys").ObjectIdClass>>;
|
|
11
|
+
/**
|
|
12
|
+
* Filter by property.
|
|
13
|
+
* Must not include object ID.
|
|
14
|
+
*/
|
|
15
|
+
props: Schema.Record$<Schema.SchemaClass<string, string, never>, Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
16
|
+
/**
|
|
17
|
+
* Objects that have any of the given foreign keys.
|
|
18
|
+
*/
|
|
19
|
+
foreignKeys: Schema.optional<Schema.Array$<Schema.Schema<{
|
|
20
|
+
readonly source: string;
|
|
21
|
+
readonly id: string;
|
|
22
|
+
}, {
|
|
23
|
+
readonly source: string;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
}, never>>>;
|
|
26
|
+
}>;
|
|
27
|
+
export interface FilterObject extends Schema.Schema.Type<typeof FilterObject_> {
|
|
28
|
+
}
|
|
29
|
+
export declare const FilterObject: Schema.Schema<FilterObject>;
|
|
30
|
+
declare const FilterCompare_: Schema.Struct<{
|
|
31
|
+
type: Schema.Literal<["compare"]>;
|
|
32
|
+
operator: Schema.Literal<["eq", "neq", "gt", "gte", "lt", "lte"]>;
|
|
33
|
+
value: typeof Schema.Unknown;
|
|
34
|
+
}>;
|
|
35
|
+
export interface FilterCompare extends Schema.Schema.Type<typeof FilterCompare_> {
|
|
36
|
+
}
|
|
37
|
+
export declare const FilterCompare: Schema.Schema<FilterCompare>;
|
|
38
|
+
declare const FilterIn_: Schema.Struct<{
|
|
39
|
+
type: Schema.Literal<["in"]>;
|
|
40
|
+
values: Schema.Array$<typeof Schema.Any>;
|
|
41
|
+
}>;
|
|
42
|
+
export interface FilterIn extends Schema.Schema.Type<typeof FilterIn_> {
|
|
43
|
+
}
|
|
44
|
+
export declare const FilterIn: Schema.Schema<FilterIn>;
|
|
45
|
+
declare const FilterRange_: Schema.Struct<{
|
|
46
|
+
type: Schema.Literal<["range"]>;
|
|
47
|
+
from: typeof Schema.Any;
|
|
48
|
+
to: typeof Schema.Any;
|
|
49
|
+
}>;
|
|
50
|
+
export interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {
|
|
51
|
+
}
|
|
52
|
+
export declare const FilterRange: Schema.Schema<FilterRange>;
|
|
53
|
+
declare const FilterTextSearch_: Schema.Struct<{
|
|
54
|
+
type: Schema.Literal<["text-search"]>;
|
|
55
|
+
text: typeof Schema.String;
|
|
56
|
+
searchKind: Schema.optional<Schema.Literal<["full-text", "vector"]>>;
|
|
57
|
+
}>;
|
|
58
|
+
export interface FilterTextSearch extends Schema.Schema.Type<typeof FilterTextSearch_> {
|
|
59
|
+
}
|
|
60
|
+
export declare const FilterTextSearch: Schema.Schema<FilterTextSearch>;
|
|
61
|
+
declare const FilterNot_: Schema.Struct<{
|
|
62
|
+
type: Schema.Literal<["not"]>;
|
|
63
|
+
filter: Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>;
|
|
64
|
+
}>;
|
|
65
|
+
export interface FilterNot extends Schema.Schema.Type<typeof FilterNot_> {
|
|
66
|
+
}
|
|
67
|
+
export declare const FilterNot: Schema.Schema<FilterNot>;
|
|
68
|
+
declare const FilterAnd_: Schema.Struct<{
|
|
69
|
+
type: Schema.Literal<["and"]>;
|
|
70
|
+
filters: Schema.Array$<Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
71
|
+
}>;
|
|
72
|
+
export interface FilterAnd extends Schema.Schema.Type<typeof FilterAnd_> {
|
|
73
|
+
}
|
|
74
|
+
export declare const FilterAnd: Schema.Schema<FilterAnd>;
|
|
75
|
+
declare const FilterOr_: Schema.Struct<{
|
|
76
|
+
type: Schema.Literal<["or"]>;
|
|
77
|
+
filters: Schema.Array$<Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
78
|
+
}>;
|
|
79
|
+
export interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {
|
|
80
|
+
}
|
|
81
|
+
export declare const FilterOr: Schema.Schema<FilterOr>;
|
|
82
|
+
export declare const Filter: Schema.Union<[Schema.Schema<FilterObject, FilterObject, never>, Schema.Schema<FilterTextSearch, FilterTextSearch, never>, Schema.Schema<FilterCompare, FilterCompare, never>, Schema.Schema<FilterIn, FilterIn, never>, Schema.Schema<FilterRange, FilterRange, never>, Schema.Schema<FilterNot, FilterNot, never>, Schema.Schema<FilterAnd, FilterAnd, never>, Schema.Schema<FilterOr, FilterOr, never>]>;
|
|
83
|
+
export type Filter = Schema.Schema.Type<typeof Filter>;
|
|
84
|
+
/**
|
|
85
|
+
* Query objects by type, id, and/or predicates.
|
|
86
|
+
*/
|
|
87
|
+
declare const QuerySelectClause_: Schema.Struct<{
|
|
88
|
+
type: Schema.Literal<["select"]>;
|
|
89
|
+
filter: Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>;
|
|
90
|
+
}>;
|
|
91
|
+
export interface QuerySelectClause extends Schema.Schema.Type<typeof QuerySelectClause_> {
|
|
92
|
+
}
|
|
93
|
+
export declare const QuerySelectClause: Schema.Schema<QuerySelectClause>;
|
|
94
|
+
/**
|
|
95
|
+
* Filter objects from selection.
|
|
96
|
+
*/
|
|
97
|
+
declare const QueryFilterClause_: Schema.Struct<{
|
|
98
|
+
type: Schema.Literal<["filter"]>;
|
|
99
|
+
selection: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, never>;
|
|
100
|
+
filter: Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>;
|
|
101
|
+
}>;
|
|
102
|
+
export interface QueryFilterClause extends Schema.Schema.Type<typeof QueryFilterClause_> {
|
|
103
|
+
}
|
|
104
|
+
export declare const QueryFilterClause: Schema.Schema<QueryFilterClause>;
|
|
105
|
+
/**
|
|
106
|
+
* Traverse references from an anchor object.
|
|
107
|
+
*/
|
|
108
|
+
declare const QueryReferenceTraversalClause_: Schema.Struct<{
|
|
109
|
+
type: Schema.Literal<["reference-traversal"]>;
|
|
110
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, never>;
|
|
111
|
+
property: typeof Schema.String;
|
|
112
|
+
}>;
|
|
113
|
+
export interface QueryReferenceTraversalClause extends Schema.Schema.Type<typeof QueryReferenceTraversalClause_> {
|
|
114
|
+
}
|
|
115
|
+
export declare const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversalClause>;
|
|
116
|
+
/**
|
|
117
|
+
* Traverse incoming references to an anchor object.
|
|
118
|
+
*/
|
|
119
|
+
declare const QueryIncomingReferencesClause_: Schema.Struct<{
|
|
120
|
+
type: Schema.Literal<["incoming-references"]>;
|
|
121
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, never>;
|
|
122
|
+
property: typeof Schema.String;
|
|
123
|
+
typename: Schema.Union<[Schema.refine<string, typeof Schema.NonEmptyString>, typeof Schema.Null]>;
|
|
124
|
+
}>;
|
|
125
|
+
export interface QueryIncomingReferencesClause extends Schema.Schema.Type<typeof QueryIncomingReferencesClause_> {
|
|
126
|
+
}
|
|
127
|
+
export declare const QueryIncomingReferencesClause: Schema.Schema<QueryIncomingReferencesClause>;
|
|
128
|
+
/**
|
|
129
|
+
* Traverse relations connecting to an anchor object.
|
|
130
|
+
*/
|
|
131
|
+
declare const QueryRelationClause_: Schema.Struct<{
|
|
132
|
+
type: Schema.Literal<["relation"]>;
|
|
133
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, never>;
|
|
134
|
+
/**
|
|
135
|
+
* outgoing: anchor is the source of the relation.
|
|
136
|
+
* incoming: anchor is the target of the relation.
|
|
137
|
+
* both: anchor is either the source or target of the relation.
|
|
138
|
+
*/
|
|
139
|
+
direction: Schema.Literal<["outgoing", "incoming", "both"]>;
|
|
140
|
+
filter: Schema.optional<Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
141
|
+
}>;
|
|
142
|
+
export interface QueryRelationClause extends Schema.Schema.Type<typeof QueryRelationClause_> {
|
|
143
|
+
}
|
|
144
|
+
export declare const QueryRelationClause: Schema.Schema<QueryRelationClause>;
|
|
145
|
+
/**
|
|
146
|
+
* Traverse into the source or target of a relation.
|
|
147
|
+
*/
|
|
148
|
+
declare const QueryRelationTraversalClause_: Schema.Struct<{
|
|
149
|
+
type: Schema.Literal<["relation-traversal"]>;
|
|
150
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, never>;
|
|
151
|
+
direction: Schema.Literal<["source", "target", "both"]>;
|
|
152
|
+
}>;
|
|
153
|
+
export interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {
|
|
154
|
+
}
|
|
155
|
+
export declare const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause>;
|
|
156
|
+
/**
|
|
157
|
+
* Union of multiple queries.
|
|
158
|
+
*/
|
|
159
|
+
declare const QueryUnionClause_: Schema.Struct<{
|
|
160
|
+
type: Schema.Literal<["union"]>;
|
|
161
|
+
queries: Schema.Array$<Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, never>>;
|
|
162
|
+
}>;
|
|
163
|
+
export interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {
|
|
164
|
+
}
|
|
165
|
+
export declare const QueryUnionClause: Schema.Schema<QueryUnionClause>;
|
|
166
|
+
/**
|
|
167
|
+
* Add options to a query.
|
|
168
|
+
*/
|
|
169
|
+
declare const QueryOptionsClause_: Schema.Struct<{
|
|
170
|
+
type: Schema.Literal<["options"]>;
|
|
171
|
+
query: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause | QueryOptionsClause, never>;
|
|
172
|
+
options: Schema.suspend<{
|
|
173
|
+
readonly deleted?: "include" | "exclude" | "only" | undefined;
|
|
174
|
+
readonly spaceIds?: readonly string[] | undefined;
|
|
175
|
+
}, {
|
|
176
|
+
readonly deleted?: "include" | "exclude" | "only" | undefined;
|
|
177
|
+
readonly spaceIds?: readonly string[] | undefined;
|
|
178
|
+
}, never>;
|
|
179
|
+
}>;
|
|
180
|
+
export interface QueryOptionsClause extends Schema.Schema.Type<typeof QueryOptionsClause_> {
|
|
181
|
+
}
|
|
182
|
+
export declare const QueryOptionsClause: Schema.Schema<QueryOptionsClause>;
|
|
183
|
+
declare const Query_: Schema.Union<[Schema.Schema<QuerySelectClause, QuerySelectClause, never>, Schema.Schema<QueryFilterClause, QueryFilterClause, never>, Schema.Schema<QueryReferenceTraversalClause, QueryReferenceTraversalClause, never>, Schema.Schema<QueryIncomingReferencesClause, QueryIncomingReferencesClause, never>, Schema.Schema<QueryRelationClause, QueryRelationClause, never>, Schema.Schema<QueryRelationTraversalClause, QueryRelationTraversalClause, never>, Schema.Schema<QueryUnionClause, QueryUnionClause, never>, Schema.Schema<QueryOptionsClause, QueryOptionsClause, never>]>;
|
|
184
|
+
export type Query = Schema.Schema.Type<typeof Query_>;
|
|
185
|
+
export declare const Query: Schema.Schema<Query>;
|
|
186
|
+
export declare const QueryOptions: Schema.Struct<{
|
|
187
|
+
spaceIds: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
188
|
+
deleted: Schema.optional<Schema.Literal<["include", "exclude", "only"]>>;
|
|
189
|
+
}>;
|
|
190
|
+
export interface QueryOptions extends Schema.Schema.Type<typeof QueryOptions> {
|
|
191
|
+
}
|
|
192
|
+
export declare const visit: (query: Query, visitor: (node: Query) => void) => void;
|
|
193
|
+
export {};
|
|
194
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../../src/query/ast.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYhC;;;;GAIG;AAEH,QAAA,MAAM,aAAa;;;;IAOjB;;;OAGG;;IAMH;;OAEG;;;;;;;;EAIH,CAAC;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,aAAa,CAAC;CAAG;AACjF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAiB,CAAC;AAEvE,QAAA,MAAM,cAAc;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AM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC;CAAG;AAEhF,eAAO,MAAM,KAAK,GAAI,OAAO,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,SAwBjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/query/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/reference.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,IAAI,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAElG;;;GAGG;AACH,qBAAa,SAAS;IAqDlB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IAvDxB;;;OAGG;IACH,MAAM,CAAC,aAAa,SAAc;IAElC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS;IAenC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS;IAIlD;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS;IAI1D;;OAEG;IAEH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAIlD;;OAEG;IAEH,MAAM,CAAC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS;IAMlF,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AS;IAIlD;;OAEG;IAEH,MAAM,CAAC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS;IAMlF,OAAO;IAQP,IAAI,GAAG,IAAI,GAAG,GAAG,SAAS,CAEzB;IAED;;OAEG;IAEH,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED;;OAEG;IAEH,IAAI,QAAQ,IAAI,MAAM,GAAG,SAAS,CAEjC;IAED;;OAEG;IAEH,IAAI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED,MAAM,IAAI,cAAc;IAKxB,KAAK,IAAI,GAAG;CAkBb;AAED,eAAO,MAAM,kBAAkB,uCAAuC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,WAAW,SAAS,KAAG,gBAErD,CAAC;AAEH,eAAO,MAAM,eAAe,GAAI,OAAO,GAAG,cAezC,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,gBACyD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space-id.d.ts","sourceRoot":"","sources":["../../../src/space-id.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKhD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"space-id.d.ts","sourceRoot":"","sources":["../../../src/space-id.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKhD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAU,UAAU,SAAS,KAAG,OAAO,CAAC,OAAO,CAY/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-protocol",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-main.10c050d",
|
|
4
4
|
"description": "Core ECHO APIs.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,10 +25,12 @@
|
|
|
25
25
|
"src"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"@dxos/keys": "0.8.
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
28
|
+
"effect": "3.14.21",
|
|
29
|
+
"@dxos/keys": "0.8.2-main.10c050d",
|
|
30
|
+
"@dxos/invariant": "0.8.2-main.10c050d",
|
|
31
|
+
"@dxos/crypto": "0.8.2-main.10c050d",
|
|
32
|
+
"@dxos/protocols": "0.8.2-main.10c050d",
|
|
33
|
+
"@dxos/util": "0.8.2-main.10c050d"
|
|
32
34
|
},
|
|
33
35
|
"publishConfig": {
|
|
34
36
|
"access": "public"
|
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { invariant } from '@dxos/invariant';
|
|
6
|
+
import type { DXN, ObjectId } from '@dxos/keys';
|
|
7
|
+
import { visitValues } from '@dxos/util';
|
|
8
|
+
|
|
5
9
|
import { type RawString } from './automerge';
|
|
6
|
-
import {
|
|
10
|
+
import type { ForeignKey } from './foreign-key';
|
|
11
|
+
import { isEncodedReference, type EncodedReference } from './reference';
|
|
7
12
|
import { type SpaceDocVersion } from './space-doc-version';
|
|
8
13
|
|
|
9
14
|
export type SpaceState = {
|
|
@@ -11,8 +16,16 @@ export type SpaceState = {
|
|
|
11
16
|
rootUrl?: string;
|
|
12
17
|
};
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Array indexes get converted to strings.
|
|
21
|
+
*/
|
|
22
|
+
export type ObjectProp = string;
|
|
23
|
+
export type ObjectPropPath = ObjectProp[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Link to all documents that hold objects in the space.
|
|
27
|
+
*/
|
|
28
|
+
export interface DatabaseDirectory {
|
|
16
29
|
version?: SpaceDocVersion;
|
|
17
30
|
|
|
18
31
|
access?: {
|
|
@@ -30,41 +43,177 @@ export interface SpaceDoc {
|
|
|
30
43
|
links?: {
|
|
31
44
|
[echoId: string]: string | RawString;
|
|
32
45
|
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated
|
|
49
|
+
* For backward compatibility.
|
|
50
|
+
*/
|
|
51
|
+
experimental_spaceKey?: string;
|
|
33
52
|
}
|
|
34
53
|
|
|
54
|
+
export const DatabaseDirectory = Object.freeze({
|
|
55
|
+
/**
|
|
56
|
+
* @returns Space key in hex of the space that owns the document. In hex format. Without 0x prefix.
|
|
57
|
+
*/
|
|
58
|
+
getSpaceKey: (doc: DatabaseDirectory): string | null => {
|
|
59
|
+
// experimental_spaceKey is set on old documents, new ones are created with doc.access.spaceKey
|
|
60
|
+
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
61
|
+
if (rawSpaceKey == null) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const rawKey = String(rawSpaceKey);
|
|
66
|
+
invariant(!rawKey.startsWith('0x'), 'Space key must not start with 0x');
|
|
67
|
+
return rawKey;
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
getInlineObject: (doc: DatabaseDirectory, id: ObjectId): ObjectStructure | undefined => {
|
|
71
|
+
return doc.objects?.[id];
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
getLink: (doc: DatabaseDirectory, id: ObjectId): string | undefined => {
|
|
75
|
+
return doc.links?.[id]?.toString();
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
make: ({
|
|
79
|
+
spaceKey,
|
|
80
|
+
objects,
|
|
81
|
+
links,
|
|
82
|
+
}: {
|
|
83
|
+
spaceKey: string;
|
|
84
|
+
objects?: Record<string, ObjectStructure>;
|
|
85
|
+
links?: Record<string, RawString>;
|
|
86
|
+
}): DatabaseDirectory => ({
|
|
87
|
+
access: {
|
|
88
|
+
spaceKey,
|
|
89
|
+
},
|
|
90
|
+
objects: objects ?? {},
|
|
91
|
+
links: links ?? {},
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
|
|
35
95
|
/**
|
|
36
96
|
* Representation of an ECHO object in an AM document.
|
|
37
97
|
*/
|
|
38
98
|
export type ObjectStructure = {
|
|
39
|
-
|
|
99
|
+
// TODO(dmaretskyi): Missing in some cases.
|
|
100
|
+
system?: ObjectSystem;
|
|
101
|
+
|
|
40
102
|
meta: ObjectMeta;
|
|
103
|
+
/**
|
|
104
|
+
* User-defined data.
|
|
105
|
+
* Adheres to schema in `system.type`
|
|
106
|
+
*/
|
|
41
107
|
data: Record<string, any>;
|
|
42
108
|
};
|
|
43
109
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/
|
|
47
|
-
export type ObjectMeta = {
|
|
110
|
+
// Helper methods to interact with the {@link ObjectStructure}.
|
|
111
|
+
export const ObjectStructure = Object.freeze({
|
|
48
112
|
/**
|
|
49
|
-
*
|
|
113
|
+
* @throws On invalid object structure.
|
|
50
114
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
115
|
+
getTypeReference: (object: ObjectStructure): EncodedReference | undefined => {
|
|
116
|
+
return object.system?.type;
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @throws On invalid object structure.
|
|
121
|
+
*/
|
|
122
|
+
getEntityKind: (object: ObjectStructure): 'object' | 'relation' => {
|
|
123
|
+
const kind = object.system?.kind ?? 'object';
|
|
124
|
+
invariant(kind === 'object' || kind === 'relation', 'Invalid kind');
|
|
125
|
+
return kind;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
isDeleted: (object: ObjectStructure): boolean => {
|
|
129
|
+
return object.system?.deleted ?? false;
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
getRelationSource: (object: ObjectStructure): EncodedReference | undefined => {
|
|
133
|
+
return object.system?.source;
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
getRelationTarget: (object: ObjectStructure): EncodedReference | undefined => {
|
|
137
|
+
return object.system?.target;
|
|
138
|
+
},
|
|
53
139
|
|
|
54
|
-
/**
|
|
55
|
-
* Reference to an object in a foreign database.
|
|
56
|
-
*/
|
|
57
|
-
export type ForeignKey = {
|
|
58
140
|
/**
|
|
59
|
-
*
|
|
60
|
-
* E.g., `github.com`.
|
|
141
|
+
* @returns All references in the data section of the object.
|
|
61
142
|
*/
|
|
62
|
-
|
|
143
|
+
getAllOutgoingReferences: (object: ObjectStructure): { path: ObjectPropPath; reference: EncodedReference }[] => {
|
|
144
|
+
const references: { path: ObjectPropPath; reference: EncodedReference }[] = [];
|
|
145
|
+
const visit = (path: ObjectPropPath, value: unknown) => {
|
|
146
|
+
if (isEncodedReference(value)) {
|
|
147
|
+
references.push({ path, reference: value });
|
|
148
|
+
} else {
|
|
149
|
+
visitValues(value, (value, key) => visit([...path, String(key)], value));
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
visitValues(object.data, (value, key) => visit([String(key)], value));
|
|
153
|
+
return references;
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
makeObject: ({
|
|
157
|
+
type,
|
|
158
|
+
data,
|
|
159
|
+
keys,
|
|
160
|
+
}: {
|
|
161
|
+
type: DXN.String;
|
|
162
|
+
deleted?: boolean;
|
|
163
|
+
keys?: ForeignKey[];
|
|
164
|
+
data?: unknown;
|
|
165
|
+
}): ObjectStructure => {
|
|
166
|
+
return {
|
|
167
|
+
system: {
|
|
168
|
+
kind: 'object',
|
|
169
|
+
type: { '/': type },
|
|
170
|
+
},
|
|
171
|
+
meta: {
|
|
172
|
+
keys: keys ?? [],
|
|
173
|
+
},
|
|
174
|
+
data: data ?? {},
|
|
175
|
+
};
|
|
176
|
+
},
|
|
63
177
|
|
|
178
|
+
makeRelation: ({
|
|
179
|
+
type,
|
|
180
|
+
source,
|
|
181
|
+
target,
|
|
182
|
+
deleted,
|
|
183
|
+
keys,
|
|
184
|
+
data,
|
|
185
|
+
}: {
|
|
186
|
+
type: DXN.String;
|
|
187
|
+
source: EncodedReference;
|
|
188
|
+
target: EncodedReference;
|
|
189
|
+
deleted?: boolean;
|
|
190
|
+
keys?: ForeignKey[];
|
|
191
|
+
data?: unknown;
|
|
192
|
+
}): ObjectStructure => {
|
|
193
|
+
return {
|
|
194
|
+
system: {
|
|
195
|
+
kind: 'relation',
|
|
196
|
+
type: { '/': type },
|
|
197
|
+
source,
|
|
198
|
+
target,
|
|
199
|
+
deleted: deleted ?? false,
|
|
200
|
+
},
|
|
201
|
+
meta: {
|
|
202
|
+
keys: keys ?? [],
|
|
203
|
+
},
|
|
204
|
+
data: data ?? {},
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Echo object metadata.
|
|
211
|
+
*/
|
|
212
|
+
export type ObjectMeta = {
|
|
64
213
|
/**
|
|
65
|
-
*
|
|
214
|
+
* Foreign keys.
|
|
66
215
|
*/
|
|
67
|
-
|
|
216
|
+
keys: ForeignKey[];
|
|
68
217
|
};
|
|
69
218
|
|
|
70
219
|
/**
|
|
@@ -93,7 +242,7 @@ export type ObjectSystem = {
|
|
|
93
242
|
source?: EncodedReference;
|
|
94
243
|
|
|
95
244
|
/**
|
|
96
|
-
* Only for relations.
|
|
245
|
+
* Only for relations.w
|
|
97
246
|
*/
|
|
98
247
|
target?: EncodedReference;
|
|
99
248
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema, SchemaAST } from 'effect';
|
|
6
|
+
|
|
7
|
+
const ForeignKey_ = Schema.Struct({
|
|
8
|
+
/**
|
|
9
|
+
* Name of the foreign database/system.
|
|
10
|
+
* E.g., `github.com`.
|
|
11
|
+
*/
|
|
12
|
+
source: Schema.String,
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Id within the foreign database.
|
|
16
|
+
*/
|
|
17
|
+
// TODO(wittjosiah): This annotation is currently used to ensure id field shows up in forms.
|
|
18
|
+
// TODO(dmaretskyi): `false` is not a valid value for the annotation.
|
|
19
|
+
id: Schema.String.annotations({ [SchemaAST.IdentifierAnnotationId]: false }),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type ForeignKey = Schema.Schema.Type<typeof ForeignKey_>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reference to an object in a foreign database.
|
|
26
|
+
*/
|
|
27
|
+
export const ForeignKey: Schema.Schema<ForeignKey> = ForeignKey_;
|