@dxos/echo-protocol 0.8.3 → 0.8.4-main.28f8d3d
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 +32 -15
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +32 -15
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/document-structure.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/reference.d.ts +16 -0
- package/dist/types/src/reference.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/document-structure.ts +1 -1
- package/src/index.ts +1 -1
- package/src/reference.ts +26 -0
- package/src/space-id.ts +1 -1
- package/dist/lib/node/index.cjs +0 -527
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
package/src/reference.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { assertArgument } from '@dxos/invariant';
|
|
5
6
|
import { DXN, LOCAL_SPACE_TAG, type PublicKey } from '@dxos/keys';
|
|
6
7
|
import { type ObjectId } from '@dxos/protocols';
|
|
7
8
|
import { type Reference as ReferenceProto } from '@dxos/protocols/proto/dxos/echo/model/document';
|
|
@@ -9,6 +10,7 @@ import { type Reference as ReferenceProto } from '@dxos/protocols/proto/dxos/ech
|
|
|
9
10
|
/**
|
|
10
11
|
* Runtime representation of an reference in ECHO.
|
|
11
12
|
* Implemented as a DXN, but we might extend it to other URIs in the future.
|
|
13
|
+
* @deprecated Use `EncodedReference` instead.
|
|
12
14
|
*/
|
|
13
15
|
export class Reference {
|
|
14
16
|
/**
|
|
@@ -122,6 +124,7 @@ export class Reference {
|
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
|
|
127
|
+
// TODO(dmaretskyi): Is this used anywhere?
|
|
125
128
|
export const REFERENCE_TYPE_TAG = 'dxos.echo.model.document.Reference';
|
|
126
129
|
|
|
127
130
|
/**
|
|
@@ -131,10 +134,16 @@ export type EncodedReference = {
|
|
|
131
134
|
'/': string;
|
|
132
135
|
};
|
|
133
136
|
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated Use `EncodedReference.fromDXN` instead.
|
|
139
|
+
*/
|
|
134
140
|
export const encodeReference = (reference: Reference): EncodedReference => ({
|
|
135
141
|
'/': reference.toDXN().toString(),
|
|
136
142
|
});
|
|
137
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @deprecated Use `EncodedReference.toDXN` instead.
|
|
146
|
+
*/
|
|
138
147
|
export const decodeReference = (value: any) => {
|
|
139
148
|
if (typeof value !== 'object' || value === null || typeof value['/'] !== 'string') {
|
|
140
149
|
throw new Error('Invalid reference');
|
|
@@ -152,5 +161,22 @@ export const decodeReference = (value: any) => {
|
|
|
152
161
|
return Reference.fromDXN(DXN.parse(dxnString));
|
|
153
162
|
};
|
|
154
163
|
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Use `EncodedReference.isEncodedReference` instead.
|
|
166
|
+
*/
|
|
155
167
|
export const isEncodedReference = (value: any): value is EncodedReference =>
|
|
156
168
|
typeof value === 'object' && value !== null && Object.keys(value).length === 1 && typeof value['/'] === 'string';
|
|
169
|
+
|
|
170
|
+
export const EncodedReference = Object.freeze({
|
|
171
|
+
isEncodedReference,
|
|
172
|
+
getReferenceString: (value: EncodedReference): string => {
|
|
173
|
+
assertArgument(isEncodedReference(value), 'invalid reference');
|
|
174
|
+
return value['/'];
|
|
175
|
+
},
|
|
176
|
+
toDXN: (value: EncodedReference): DXN => {
|
|
177
|
+
return DXN.parse(EncodedReference.getReferenceString(value));
|
|
178
|
+
},
|
|
179
|
+
fromDXN: (dxn: DXN): EncodedReference => {
|
|
180
|
+
return encodeReference(Reference.fromDXN(dxn));
|
|
181
|
+
},
|
|
182
|
+
});
|
package/src/space-id.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const createIdFromSpaceKey = async (spaceKey: PublicKey): Promise<SpaceId
|
|
|
18
18
|
return cachedValue;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const digest = await subtleCrypto.digest('SHA-256', spaceKey.asUint8Array());
|
|
21
|
+
const digest = await subtleCrypto.digest('SHA-256', spaceKey.asUint8Array() as Uint8Array<ArrayBuffer>);
|
|
22
22
|
|
|
23
23
|
const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);
|
|
24
24
|
const spaceId = SpaceId.encode(bytes);
|
package/dist/lib/node/index.cjs
DELETED
|
@@ -1,527 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var node_exports = {};
|
|
20
|
-
__export(node_exports, {
|
|
21
|
-
DATA_NAMESPACE: () => DATA_NAMESPACE,
|
|
22
|
-
DatabaseDirectory: () => DatabaseDirectory,
|
|
23
|
-
ForeignKey: () => ForeignKey,
|
|
24
|
-
ObjectStructure: () => ObjectStructure,
|
|
25
|
-
PROPERTY_ID: () => PROPERTY_ID,
|
|
26
|
-
QueryAST: () => ast_exports,
|
|
27
|
-
REFERENCE_TYPE_TAG: () => REFERENCE_TYPE_TAG,
|
|
28
|
-
Reference: () => Reference,
|
|
29
|
-
SpaceDocVersion: () => SpaceDocVersion,
|
|
30
|
-
createIdFromSpaceKey: () => createIdFromSpaceKey,
|
|
31
|
-
decodeReference: () => decodeReference,
|
|
32
|
-
encodeReference: () => encodeReference,
|
|
33
|
-
isEncodedReference: () => isEncodedReference
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(node_exports);
|
|
36
|
-
var import_invariant = require("@dxos/invariant");
|
|
37
|
-
var import_util = require("@dxos/util");
|
|
38
|
-
var import_keys = require("@dxos/keys");
|
|
39
|
-
var import_crypto = require("@dxos/crypto");
|
|
40
|
-
var import_keys2 = require("@dxos/keys");
|
|
41
|
-
var import_util2 = require("@dxos/util");
|
|
42
|
-
var import_effect = require("effect");
|
|
43
|
-
var import_effect2 = require("effect");
|
|
44
|
-
var import_keys3 = require("@dxos/keys");
|
|
45
|
-
var __defProp2 = Object.defineProperty;
|
|
46
|
-
var __export2 = (target, all) => {
|
|
47
|
-
for (var name in all)
|
|
48
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
49
|
-
};
|
|
50
|
-
var Reference = class _Reference {
|
|
51
|
-
static {
|
|
52
|
-
this.TYPE_PROTOCOL = "protobuf";
|
|
53
|
-
}
|
|
54
|
-
static fromDXN(dxn) {
|
|
55
|
-
switch (dxn.kind) {
|
|
56
|
-
case import_keys.DXN.kind.TYPE:
|
|
57
|
-
return new _Reference(dxn.parts[0], _Reference.TYPE_PROTOCOL, "dxos.org", dxn);
|
|
58
|
-
case import_keys.DXN.kind.ECHO:
|
|
59
|
-
if (dxn.parts[0] === import_keys.LOCAL_SPACE_TAG) {
|
|
60
|
-
return new _Reference(dxn.parts[1], void 0, void 0, dxn);
|
|
61
|
-
} else {
|
|
62
|
-
return new _Reference(dxn.parts[1], void 0, dxn.parts[0], dxn);
|
|
63
|
-
}
|
|
64
|
-
default:
|
|
65
|
-
return new _Reference(dxn.parts[0], void 0, dxn.parts[0], dxn);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
static fromValue(value) {
|
|
69
|
-
return new _Reference(value.objectId, value.protocol, value.host);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Reference an object in the local space.
|
|
73
|
-
*/
|
|
74
|
-
static localObjectReference(objectId) {
|
|
75
|
-
return new _Reference(objectId);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* @deprecated
|
|
79
|
-
*/
|
|
80
|
-
// TODO(dmaretskyi): Remove.
|
|
81
|
-
static fromLegacyTypename(type) {
|
|
82
|
-
return new _Reference(type, _Reference.TYPE_PROTOCOL, "dxos.org");
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @deprecated
|
|
86
|
-
*/
|
|
87
|
-
// TODO(dmaretskyi): Remove
|
|
88
|
-
static fromObjectIdAndSpaceKey(objectId, spaceKey) {
|
|
89
|
-
return new _Reference(objectId, void 0, spaceKey.toHex());
|
|
90
|
-
}
|
|
91
|
-
// prettier-ignore
|
|
92
|
-
constructor(_objectId, _protocol, _host, _dxn) {
|
|
93
|
-
this._objectId = _objectId;
|
|
94
|
-
this._protocol = _protocol;
|
|
95
|
-
this._host = _host;
|
|
96
|
-
this._dxn = _dxn;
|
|
97
|
-
}
|
|
98
|
-
get dxn() {
|
|
99
|
-
return this._dxn;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @deprecated
|
|
103
|
-
*/
|
|
104
|
-
// TODO(dmaretskyi): Remove.
|
|
105
|
-
get objectId() {
|
|
106
|
-
return this._objectId;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* @deprecated
|
|
110
|
-
*/
|
|
111
|
-
// TODO(dmaretskyi): Remove.
|
|
112
|
-
get protocol() {
|
|
113
|
-
return this._protocol;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* @deprecated
|
|
117
|
-
*/
|
|
118
|
-
// TODO(dmaretskyi): Remove.
|
|
119
|
-
get host() {
|
|
120
|
-
return this._host;
|
|
121
|
-
}
|
|
122
|
-
encode() {
|
|
123
|
-
return {
|
|
124
|
-
objectId: this.objectId,
|
|
125
|
-
host: this.host,
|
|
126
|
-
protocol: this.protocol
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
// TODO(dmaretskyi): Remove in favor of `reference.dxn`.
|
|
130
|
-
toDXN() {
|
|
131
|
-
if (this._dxn) {
|
|
132
|
-
return this._dxn;
|
|
133
|
-
}
|
|
134
|
-
if (this.protocol === _Reference.TYPE_PROTOCOL) {
|
|
135
|
-
return new import_keys.DXN(import_keys.DXN.kind.TYPE, [
|
|
136
|
-
this.objectId
|
|
137
|
-
]);
|
|
138
|
-
} else {
|
|
139
|
-
if (this.host) {
|
|
140
|
-
return new import_keys.DXN(import_keys.DXN.kind.ECHO, [
|
|
141
|
-
this.host,
|
|
142
|
-
this.objectId
|
|
143
|
-
]);
|
|
144
|
-
} else {
|
|
145
|
-
return new import_keys.DXN(import_keys.DXN.kind.ECHO, [
|
|
146
|
-
import_keys.LOCAL_SPACE_TAG,
|
|
147
|
-
this.objectId
|
|
148
|
-
]);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
var REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
|
|
154
|
-
var encodeReference = (reference) => ({
|
|
155
|
-
"/": reference.toDXN().toString()
|
|
156
|
-
});
|
|
157
|
-
var decodeReference = (value) => {
|
|
158
|
-
if (typeof value !== "object" || value === null || typeof value["/"] !== "string") {
|
|
159
|
-
throw new Error("Invalid reference");
|
|
160
|
-
}
|
|
161
|
-
const dxnString = value["/"];
|
|
162
|
-
if (dxnString.length % 2 === 0 && dxnString.slice(0, dxnString.length / 2) === dxnString.slice(dxnString.length / 2) && dxnString.includes("dxn:echo")) {
|
|
163
|
-
throw new Error("Automerge bug detected!");
|
|
164
|
-
}
|
|
165
|
-
return Reference.fromDXN(import_keys.DXN.parse(dxnString));
|
|
166
|
-
};
|
|
167
|
-
var isEncodedReference = (value) => typeof value === "object" && value !== null && Object.keys(value).length === 1 && typeof value["/"] === "string";
|
|
168
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-protocol/src/document-structure.ts";
|
|
169
|
-
var DatabaseDirectory = Object.freeze({
|
|
170
|
-
/**
|
|
171
|
-
* @returns Space key in hex of the space that owns the document. In hex format. Without 0x prefix.
|
|
172
|
-
*/
|
|
173
|
-
getSpaceKey: (doc) => {
|
|
174
|
-
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
175
|
-
if (rawSpaceKey == null) {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
const rawKey = String(rawSpaceKey);
|
|
179
|
-
(0, import_invariant.invariant)(!rawKey.startsWith("0x"), "Space key must not start with 0x", {
|
|
180
|
-
F: __dxlog_file,
|
|
181
|
-
L: 66,
|
|
182
|
-
S: void 0,
|
|
183
|
-
A: [
|
|
184
|
-
"!rawKey.startsWith('0x')",
|
|
185
|
-
"'Space key must not start with 0x'"
|
|
186
|
-
]
|
|
187
|
-
});
|
|
188
|
-
return rawKey;
|
|
189
|
-
},
|
|
190
|
-
getInlineObject: (doc, id) => {
|
|
191
|
-
return doc.objects?.[id];
|
|
192
|
-
},
|
|
193
|
-
getLink: (doc, id) => {
|
|
194
|
-
return doc.links?.[id]?.toString();
|
|
195
|
-
},
|
|
196
|
-
make: ({ spaceKey, objects, links }) => ({
|
|
197
|
-
access: {
|
|
198
|
-
spaceKey
|
|
199
|
-
},
|
|
200
|
-
objects: objects ?? {},
|
|
201
|
-
links: links ?? {}
|
|
202
|
-
})
|
|
203
|
-
});
|
|
204
|
-
var ObjectStructure = Object.freeze({
|
|
205
|
-
/**
|
|
206
|
-
* @throws On invalid object structure.
|
|
207
|
-
*/
|
|
208
|
-
getTypeReference: (object) => {
|
|
209
|
-
return object.system?.type;
|
|
210
|
-
},
|
|
211
|
-
/**
|
|
212
|
-
* @throws On invalid object structure.
|
|
213
|
-
*/
|
|
214
|
-
getEntityKind: (object) => {
|
|
215
|
-
const kind = object.system?.kind ?? "object";
|
|
216
|
-
(0, import_invariant.invariant)(kind === "object" || kind === "relation", "Invalid kind", {
|
|
217
|
-
F: __dxlog_file,
|
|
218
|
-
L: 124,
|
|
219
|
-
S: void 0,
|
|
220
|
-
A: [
|
|
221
|
-
"kind === 'object' || kind === 'relation'",
|
|
222
|
-
"'Invalid kind'"
|
|
223
|
-
]
|
|
224
|
-
});
|
|
225
|
-
return kind;
|
|
226
|
-
},
|
|
227
|
-
isDeleted: (object) => {
|
|
228
|
-
return object.system?.deleted ?? false;
|
|
229
|
-
},
|
|
230
|
-
getRelationSource: (object) => {
|
|
231
|
-
return object.system?.source;
|
|
232
|
-
},
|
|
233
|
-
getRelationTarget: (object) => {
|
|
234
|
-
return object.system?.target;
|
|
235
|
-
},
|
|
236
|
-
/**
|
|
237
|
-
* @returns All references in the data section of the object.
|
|
238
|
-
*/
|
|
239
|
-
getAllOutgoingReferences: (object) => {
|
|
240
|
-
const references = [];
|
|
241
|
-
const visit2 = (path, value) => {
|
|
242
|
-
if (isEncodedReference(value)) {
|
|
243
|
-
references.push({
|
|
244
|
-
path,
|
|
245
|
-
reference: value
|
|
246
|
-
});
|
|
247
|
-
} else {
|
|
248
|
-
(0, import_util.visitValues)(value, (value2, key) => visit2([
|
|
249
|
-
...path,
|
|
250
|
-
String(key)
|
|
251
|
-
], value2));
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
(0, import_util.visitValues)(object.data, (value, key) => visit2([
|
|
255
|
-
String(key)
|
|
256
|
-
], value));
|
|
257
|
-
return references;
|
|
258
|
-
},
|
|
259
|
-
makeObject: ({ type, data, keys }) => {
|
|
260
|
-
return {
|
|
261
|
-
system: {
|
|
262
|
-
kind: "object",
|
|
263
|
-
type: {
|
|
264
|
-
"/": type
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
meta: {
|
|
268
|
-
keys: keys ?? []
|
|
269
|
-
},
|
|
270
|
-
data: data ?? {}
|
|
271
|
-
};
|
|
272
|
-
},
|
|
273
|
-
makeRelation: ({ type, source, target, deleted, keys, data }) => {
|
|
274
|
-
return {
|
|
275
|
-
system: {
|
|
276
|
-
kind: "relation",
|
|
277
|
-
type: {
|
|
278
|
-
"/": type
|
|
279
|
-
},
|
|
280
|
-
source,
|
|
281
|
-
target,
|
|
282
|
-
deleted: deleted ?? false
|
|
283
|
-
},
|
|
284
|
-
meta: {
|
|
285
|
-
keys: keys ?? []
|
|
286
|
-
},
|
|
287
|
-
data: data ?? {}
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
var PROPERTY_ID = "id";
|
|
292
|
-
var DATA_NAMESPACE = "data";
|
|
293
|
-
var SpaceDocVersion = Object.freeze({
|
|
294
|
-
/**
|
|
295
|
-
* For the documents created before the versioning was introduced.
|
|
296
|
-
*/
|
|
297
|
-
LEGACY: 0,
|
|
298
|
-
/**
|
|
299
|
-
* Current version.
|
|
300
|
-
*/
|
|
301
|
-
CURRENT: 1
|
|
302
|
-
});
|
|
303
|
-
var SPACE_IDS_CACHE = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
|
|
304
|
-
var createIdFromSpaceKey = async (spaceKey) => {
|
|
305
|
-
const cachedValue = SPACE_IDS_CACHE.get(spaceKey);
|
|
306
|
-
if (cachedValue !== void 0) {
|
|
307
|
-
return cachedValue;
|
|
308
|
-
}
|
|
309
|
-
const digest = await import_crypto.subtleCrypto.digest("SHA-256", spaceKey.asUint8Array());
|
|
310
|
-
const bytes = new Uint8Array(digest).slice(0, import_keys2.SpaceId.byteLength);
|
|
311
|
-
const spaceId = import_keys2.SpaceId.encode(bytes);
|
|
312
|
-
SPACE_IDS_CACHE.set(spaceKey, spaceId);
|
|
313
|
-
return spaceId;
|
|
314
|
-
};
|
|
315
|
-
var ForeignKey_ = import_effect.Schema.Struct({
|
|
316
|
-
/**
|
|
317
|
-
* Name of the foreign database/system.
|
|
318
|
-
* E.g., `github.com`.
|
|
319
|
-
*/
|
|
320
|
-
source: import_effect.Schema.String,
|
|
321
|
-
/**
|
|
322
|
-
* Id within the foreign database.
|
|
323
|
-
*/
|
|
324
|
-
// TODO(wittjosiah): This annotation is currently used to ensure id field shows up in forms.
|
|
325
|
-
// TODO(dmaretskyi): `false` is not a valid value for the annotation.
|
|
326
|
-
id: import_effect.Schema.String.annotations({
|
|
327
|
-
[import_effect.SchemaAST.IdentifierAnnotationId]: false
|
|
328
|
-
})
|
|
329
|
-
});
|
|
330
|
-
var ForeignKey = ForeignKey_;
|
|
331
|
-
var ast_exports = {};
|
|
332
|
-
__export2(ast_exports, {
|
|
333
|
-
Filter: () => Filter,
|
|
334
|
-
FilterAnd: () => FilterAnd,
|
|
335
|
-
FilterCompare: () => FilterCompare,
|
|
336
|
-
FilterIn: () => FilterIn,
|
|
337
|
-
FilterNot: () => FilterNot,
|
|
338
|
-
FilterObject: () => FilterObject,
|
|
339
|
-
FilterOr: () => FilterOr,
|
|
340
|
-
FilterRange: () => FilterRange,
|
|
341
|
-
FilterTextSearch: () => FilterTextSearch,
|
|
342
|
-
Query: () => Query,
|
|
343
|
-
QueryFilterClause: () => QueryFilterClause,
|
|
344
|
-
QueryIncomingReferencesClause: () => QueryIncomingReferencesClause,
|
|
345
|
-
QueryOptions: () => QueryOptions,
|
|
346
|
-
QueryOptionsClause: () => QueryOptionsClause,
|
|
347
|
-
QueryReferenceTraversalClause: () => QueryReferenceTraversalClause,
|
|
348
|
-
QueryRelationClause: () => QueryRelationClause,
|
|
349
|
-
QueryRelationTraversalClause: () => QueryRelationTraversalClause,
|
|
350
|
-
QuerySelectClause: () => QuerySelectClause,
|
|
351
|
-
QuerySetDifferenceClause: () => QuerySetDifferenceClause,
|
|
352
|
-
QueryUnionClause: () => QueryUnionClause,
|
|
353
|
-
visit: () => visit
|
|
354
|
-
});
|
|
355
|
-
var TypenameSpecifier = import_effect2.Schema.Union(import_keys3.DXN.Schema, import_effect2.Schema.Null).annotations({
|
|
356
|
-
description: "DXN or null. Null means any type will match"
|
|
357
|
-
});
|
|
358
|
-
var FilterObject_ = import_effect2.Schema.Struct({
|
|
359
|
-
type: import_effect2.Schema.Literal("object"),
|
|
360
|
-
typename: TypenameSpecifier,
|
|
361
|
-
id: import_effect2.Schema.optional(import_effect2.Schema.Array(import_keys3.ObjectId)),
|
|
362
|
-
/**
|
|
363
|
-
* Filter by property.
|
|
364
|
-
* Must not include object ID.
|
|
365
|
-
*/
|
|
366
|
-
props: import_effect2.Schema.Record({
|
|
367
|
-
key: import_effect2.Schema.String.annotations({
|
|
368
|
-
description: "Property name"
|
|
369
|
-
}),
|
|
370
|
-
value: import_effect2.Schema.suspend(() => Filter)
|
|
371
|
-
}),
|
|
372
|
-
/**
|
|
373
|
-
* Objects that have any of the given foreign keys.
|
|
374
|
-
*/
|
|
375
|
-
foreignKeys: import_effect2.Schema.optional(import_effect2.Schema.Array(ForeignKey))
|
|
376
|
-
});
|
|
377
|
-
var FilterObject = FilterObject_;
|
|
378
|
-
var FilterCompare_ = import_effect2.Schema.Struct({
|
|
379
|
-
type: import_effect2.Schema.Literal("compare"),
|
|
380
|
-
operator: import_effect2.Schema.Literal("eq", "neq", "gt", "gte", "lt", "lte"),
|
|
381
|
-
value: import_effect2.Schema.Unknown
|
|
382
|
-
});
|
|
383
|
-
var FilterCompare = FilterCompare_;
|
|
384
|
-
var FilterIn_ = import_effect2.Schema.Struct({
|
|
385
|
-
type: import_effect2.Schema.Literal("in"),
|
|
386
|
-
values: import_effect2.Schema.Array(import_effect2.Schema.Any)
|
|
387
|
-
});
|
|
388
|
-
var FilterIn = FilterIn_;
|
|
389
|
-
var FilterRange_ = import_effect2.Schema.Struct({
|
|
390
|
-
type: import_effect2.Schema.Literal("range"),
|
|
391
|
-
from: import_effect2.Schema.Any,
|
|
392
|
-
to: import_effect2.Schema.Any
|
|
393
|
-
});
|
|
394
|
-
var FilterRange = FilterRange_;
|
|
395
|
-
var FilterTextSearch_ = import_effect2.Schema.Struct({
|
|
396
|
-
type: import_effect2.Schema.Literal("text-search"),
|
|
397
|
-
text: import_effect2.Schema.String,
|
|
398
|
-
searchKind: import_effect2.Schema.optional(import_effect2.Schema.Literal("full-text", "vector"))
|
|
399
|
-
});
|
|
400
|
-
var FilterTextSearch = FilterTextSearch_;
|
|
401
|
-
var FilterNot_ = import_effect2.Schema.Struct({
|
|
402
|
-
type: import_effect2.Schema.Literal("not"),
|
|
403
|
-
filter: import_effect2.Schema.suspend(() => Filter)
|
|
404
|
-
});
|
|
405
|
-
var FilterNot = FilterNot_;
|
|
406
|
-
var FilterAnd_ = import_effect2.Schema.Struct({
|
|
407
|
-
type: import_effect2.Schema.Literal("and"),
|
|
408
|
-
filters: import_effect2.Schema.Array(import_effect2.Schema.suspend(() => Filter))
|
|
409
|
-
});
|
|
410
|
-
var FilterAnd = FilterAnd_;
|
|
411
|
-
var FilterOr_ = import_effect2.Schema.Struct({
|
|
412
|
-
type: import_effect2.Schema.Literal("or"),
|
|
413
|
-
filters: import_effect2.Schema.Array(import_effect2.Schema.suspend(() => Filter))
|
|
414
|
-
});
|
|
415
|
-
var FilterOr = FilterOr_;
|
|
416
|
-
var Filter = import_effect2.Schema.Union(FilterObject, FilterTextSearch, FilterCompare, FilterIn, FilterRange, FilterNot, FilterAnd, FilterOr);
|
|
417
|
-
var QuerySelectClause_ = import_effect2.Schema.Struct({
|
|
418
|
-
type: import_effect2.Schema.Literal("select"),
|
|
419
|
-
filter: import_effect2.Schema.suspend(() => Filter)
|
|
420
|
-
});
|
|
421
|
-
var QuerySelectClause = QuerySelectClause_;
|
|
422
|
-
var QueryFilterClause_ = import_effect2.Schema.Struct({
|
|
423
|
-
type: import_effect2.Schema.Literal("filter"),
|
|
424
|
-
selection: import_effect2.Schema.suspend(() => Query),
|
|
425
|
-
filter: import_effect2.Schema.suspend(() => Filter)
|
|
426
|
-
});
|
|
427
|
-
var QueryFilterClause = QueryFilterClause_;
|
|
428
|
-
var QueryReferenceTraversalClause_ = import_effect2.Schema.Struct({
|
|
429
|
-
type: import_effect2.Schema.Literal("reference-traversal"),
|
|
430
|
-
anchor: import_effect2.Schema.suspend(() => Query),
|
|
431
|
-
property: import_effect2.Schema.String
|
|
432
|
-
});
|
|
433
|
-
var QueryReferenceTraversalClause = QueryReferenceTraversalClause_;
|
|
434
|
-
var QueryIncomingReferencesClause_ = import_effect2.Schema.Struct({
|
|
435
|
-
type: import_effect2.Schema.Literal("incoming-references"),
|
|
436
|
-
anchor: import_effect2.Schema.suspend(() => Query),
|
|
437
|
-
property: import_effect2.Schema.String,
|
|
438
|
-
typename: TypenameSpecifier
|
|
439
|
-
});
|
|
440
|
-
var QueryIncomingReferencesClause = QueryIncomingReferencesClause_;
|
|
441
|
-
var QueryRelationClause_ = import_effect2.Schema.Struct({
|
|
442
|
-
type: import_effect2.Schema.Literal("relation"),
|
|
443
|
-
anchor: import_effect2.Schema.suspend(() => Query),
|
|
444
|
-
/**
|
|
445
|
-
* outgoing: anchor is the source of the relation.
|
|
446
|
-
* incoming: anchor is the target of the relation.
|
|
447
|
-
* both: anchor is either the source or target of the relation.
|
|
448
|
-
*/
|
|
449
|
-
direction: import_effect2.Schema.Literal("outgoing", "incoming", "both"),
|
|
450
|
-
filter: import_effect2.Schema.optional(import_effect2.Schema.suspend(() => Filter))
|
|
451
|
-
});
|
|
452
|
-
var QueryRelationClause = QueryRelationClause_;
|
|
453
|
-
var QueryRelationTraversalClause_ = import_effect2.Schema.Struct({
|
|
454
|
-
type: import_effect2.Schema.Literal("relation-traversal"),
|
|
455
|
-
anchor: import_effect2.Schema.suspend(() => Query),
|
|
456
|
-
direction: import_effect2.Schema.Literal("source", "target", "both")
|
|
457
|
-
});
|
|
458
|
-
var QueryRelationTraversalClause = QueryRelationTraversalClause_;
|
|
459
|
-
var QueryUnionClause_ = import_effect2.Schema.Struct({
|
|
460
|
-
type: import_effect2.Schema.Literal("union"),
|
|
461
|
-
queries: import_effect2.Schema.Array(import_effect2.Schema.suspend(() => Query))
|
|
462
|
-
});
|
|
463
|
-
var QueryUnionClause = QueryUnionClause_;
|
|
464
|
-
var QuerySetDifferenceClause_ = import_effect2.Schema.Struct({
|
|
465
|
-
type: import_effect2.Schema.Literal("set-difference"),
|
|
466
|
-
source: import_effect2.Schema.suspend(() => Query),
|
|
467
|
-
exclude: import_effect2.Schema.suspend(() => Query)
|
|
468
|
-
});
|
|
469
|
-
var QuerySetDifferenceClause = QuerySetDifferenceClause_;
|
|
470
|
-
var QueryOptionsClause_ = import_effect2.Schema.Struct({
|
|
471
|
-
type: import_effect2.Schema.Literal("options"),
|
|
472
|
-
query: import_effect2.Schema.suspend(() => Query),
|
|
473
|
-
options: import_effect2.Schema.suspend(() => QueryOptions)
|
|
474
|
-
});
|
|
475
|
-
var QueryOptionsClause = QueryOptionsClause_;
|
|
476
|
-
var Query_ = import_effect2.Schema.Union(QuerySelectClause, QueryFilterClause, QueryReferenceTraversalClause, QueryIncomingReferencesClause, QueryRelationClause, QueryRelationTraversalClause, QueryUnionClause, QuerySetDifferenceClause, QueryOptionsClause);
|
|
477
|
-
var Query = Query_;
|
|
478
|
-
var QueryOptions = import_effect2.Schema.Struct({
|
|
479
|
-
spaceIds: import_effect2.Schema.optional(import_effect2.Schema.Array(import_effect2.Schema.String)),
|
|
480
|
-
deleted: import_effect2.Schema.optional(import_effect2.Schema.Literal("include", "exclude", "only"))
|
|
481
|
-
});
|
|
482
|
-
var visit = (query, visitor) => {
|
|
483
|
-
switch (query.type) {
|
|
484
|
-
case "filter":
|
|
485
|
-
visit(query.selection, visitor);
|
|
486
|
-
break;
|
|
487
|
-
case "reference-traversal":
|
|
488
|
-
visit(query.anchor, visitor);
|
|
489
|
-
break;
|
|
490
|
-
case "incoming-references":
|
|
491
|
-
visit(query.anchor, visitor);
|
|
492
|
-
break;
|
|
493
|
-
case "relation":
|
|
494
|
-
visit(query.anchor, visitor);
|
|
495
|
-
break;
|
|
496
|
-
case "options":
|
|
497
|
-
visit(query.query, visitor);
|
|
498
|
-
break;
|
|
499
|
-
case "relation-traversal":
|
|
500
|
-
visit(query.anchor, visitor);
|
|
501
|
-
break;
|
|
502
|
-
case "union":
|
|
503
|
-
query.queries.forEach((q) => visit(q, visitor));
|
|
504
|
-
break;
|
|
505
|
-
case "set-difference":
|
|
506
|
-
visit(query.source, visitor);
|
|
507
|
-
visit(query.exclude, visitor);
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
512
|
-
0 && (module.exports = {
|
|
513
|
-
DATA_NAMESPACE,
|
|
514
|
-
DatabaseDirectory,
|
|
515
|
-
ForeignKey,
|
|
516
|
-
ObjectStructure,
|
|
517
|
-
PROPERTY_ID,
|
|
518
|
-
QueryAST,
|
|
519
|
-
REFERENCE_TYPE_TAG,
|
|
520
|
-
Reference,
|
|
521
|
-
SpaceDocVersion,
|
|
522
|
-
createIdFromSpaceKey,
|
|
523
|
-
decodeReference,
|
|
524
|
-
encodeReference,
|
|
525
|
-
isEncodedReference
|
|
526
|
-
});
|
|
527
|
-
//# sourceMappingURL=index.cjs.map
|