@dxos/echo 0.8.3-main.672df60 → 0.8.3-main.7f5a14c
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/README.md +25 -23
- package/dist/lib/browser/index.mjs +139 -136
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +134 -132
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +139 -136
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/Key.d.ts +2 -0
- package/dist/types/src/Key.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +15 -11
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +9 -3
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +15 -13
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +5 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/Key.ts +5 -0
- package/src/Obj.ts +23 -20
- package/src/Ref.ts +9 -6
- package/src/Type.ts +19 -14
- package/src/index.ts +5 -3
- package/src/test/api.test.ts +17 -2
package/README.md
CHANGED
|
@@ -26,28 +26,30 @@ License: [MIT](./LICENSE) Copyright 2022 © DXOS
|
|
|
26
26
|
import { Type, Obj, Relation, Ref, Query, Filter } from '@dxos/echo';
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
| | Object
|
|
30
|
-
| ----------------------------- |
|
|
29
|
+
| | Object | Relation (extends Obj) | Ref |
|
|
30
|
+
| ----------------------------- | -------------------------- | -------------------------- | -------------- |
|
|
31
31
|
| **SCHEMA API** |
|
|
32
|
-
| Define schema | `Type.Obj()`
|
|
33
|
-
| Any schema type | `Type.Obj.Any`
|
|
34
|
-
| Get DXN (of schema) | `Type.getDXN(schema)`
|
|
35
|
-
| Get typename (of schema) | `Type.getTypename(schema)`
|
|
36
|
-
| Get type metadata (of schema) | `Type.getMeta(schema)`
|
|
37
|
-
| Is mutable schema | `Type.isMutable(schema)`
|
|
38
|
-
|
|
|
39
|
-
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
| Get
|
|
46
|
-
| Get
|
|
47
|
-
|
|
|
48
|
-
| Get
|
|
49
|
-
| Get
|
|
50
|
-
|
|
|
32
|
+
| Define schema | `Type.Obj()` | `Type.Relation()` | `Type.Ref()` |
|
|
33
|
+
| Any schema type | `Type.Obj.Any` | `Type.Relation.Any` | `Type.Ref.Any` |
|
|
34
|
+
| Get DXN (of schema) | `Type.getDXN(schema)` | `Type.getDXN(schema)` | |
|
|
35
|
+
| Get typename (of schema) | `Type.getTypename(schema)` | `Type.getTypename(schema)` | |
|
|
36
|
+
| Get type metadata (of schema) | `Type.getMeta(schema)` | `Type.getMeta(schema)` | |
|
|
37
|
+
| Is mutable schema | `Type.isMutable(schema)` | `Type.isMutable(schema)` | |
|
|
38
|
+
| Expando | `Type.Expando` |
|
|
39
|
+
|
|
40
|
+
|
|
|
41
|
+
| **DATA API** |
|
|
42
|
+
| Any instance type | `Obj.Any` | `Relation.Any` | `Ref.Any` |
|
|
43
|
+
| Create object | `Obj.make(Schema, { ... })` | `Relation.make(Schema, { ... })` | `Ref.make(obj)` |
|
|
44
|
+
| Check kind | `Obj.isObject(obj)` | `Relation.isRelation(obj)` | `Ref.isRef(ref)` |
|
|
45
|
+
| Get relation source | | `Relation.getSource(relation)` | |
|
|
46
|
+
| Get relation target | | `Relation.getTarget(relation)` | |
|
|
47
|
+
| Check instance of | `Obj.instanceOf(Schema, obj)` |
|
|
48
|
+
| Get schema | `Obj.getSchema(obj)` |
|
|
49
|
+
| Get DXN (of instance) | `Obj.getDXN(obj)` |
|
|
50
|
+
| Get typename (of instance) | `Obj.getTypename(obj)` |
|
|
51
|
+
| Get Meta | `Obj.getMeta(obj)` |
|
|
52
|
+
| Is deleted | `Obj.isDeleted(obj)` |
|
|
51
53
|
|
|
52
54
|
```ts
|
|
53
55
|
Type.getDXN(schema) == DXN.parse('dxn:type:example.com/type/Person:0.1.0');
|
|
@@ -58,12 +60,12 @@ Type.getVersion(schema) === '0.1.0'
|
|
|
58
60
|
Obj.getDXN(obj) === DXN.parse('dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX')
|
|
59
61
|
|
|
60
62
|
// We need this for objects that have typename defined, but their schema can't be resolved (Obj.getSchema(obj) === undefined)
|
|
61
|
-
Obj.
|
|
63
|
+
Obj.getTypeDXN(obj) === DXN.parse('dxn:type:example.com/type/Person:0.1.0');
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* @deprecated
|
|
65
67
|
**/
|
|
66
|
-
// TODO(dmaretskyi): Consider keeping it as a shorthand for zType.getTypename(Obj.getSchema(obj)) ?? Obj.
|
|
68
|
+
// TODO(dmaretskyi): Consider keeping it as a shorthand for zType.getTypename(Obj.getSchema(obj)) ?? Obj.getTypeDXN(obj)?.asTypeDXN()?.type`
|
|
67
69
|
Obj.getTypename(obj) === 'example.com/type/Person'
|
|
68
70
|
```
|
|
69
71
|
|
|
@@ -5,86 +5,24 @@ var __export = (target, all) => {
|
|
|
5
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
// packages/core/echo/echo/src/
|
|
9
|
-
var
|
|
10
|
-
__export(
|
|
11
|
-
DXN: () => DXN,
|
|
12
|
-
Expando: () => Expando,
|
|
13
|
-
Format: () => Format,
|
|
14
|
-
JsonSchema: () => JsonSchemaType,
|
|
15
|
-
Kind: () => EntityKind,
|
|
16
|
-
Obj: () => Obj,
|
|
8
|
+
// packages/core/echo/echo/src/Key.ts
|
|
9
|
+
var Key_exports = {};
|
|
10
|
+
__export(Key_exports, {
|
|
17
11
|
ObjectId: () => ObjectId,
|
|
18
|
-
|
|
19
|
-
Relation: () => Relation,
|
|
20
|
-
SpaceId: () => SpaceId,
|
|
21
|
-
getDXN: () => getDXN,
|
|
22
|
-
getMeta: () => getMeta,
|
|
23
|
-
getTypename: () => getTypename,
|
|
24
|
-
getVersion: () => getVersion,
|
|
25
|
-
isMutable: () => isMutable2,
|
|
26
|
-
toJsonSchema: () => toJsonSchema
|
|
12
|
+
SpaceId: () => SpaceId
|
|
27
13
|
});
|
|
28
|
-
import
|
|
29
|
-
import { invariant } from "@dxos/invariant";
|
|
30
|
-
import { EntityKind } from "@dxos/echo-schema";
|
|
31
|
-
import { SpaceId, ObjectId, DXN } from "@dxos/keys";
|
|
32
|
-
import {
|
|
33
|
-
Expando,
|
|
34
|
-
JsonSchemaType,
|
|
35
|
-
toJsonSchema,
|
|
36
|
-
Format
|
|
37
|
-
} from "@dxos/echo-schema";
|
|
38
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Type.ts";
|
|
39
|
-
var Obj = EchoSchema.EchoObject;
|
|
40
|
-
var Relation = EchoSchema.EchoRelation;
|
|
41
|
-
var Ref2 = EchoSchema.Ref;
|
|
42
|
-
var getDXN = (schema) => {
|
|
43
|
-
return EchoSchema.getSchemaDXN(schema);
|
|
44
|
-
};
|
|
45
|
-
var getTypename = (schema) => {
|
|
46
|
-
const typename = EchoSchema.getSchemaTypename(schema);
|
|
47
|
-
invariant(typeof typename === "string" && !typename.startsWith("dxn:"), "Invalid typename", {
|
|
48
|
-
F: __dxlog_file,
|
|
49
|
-
L: 84,
|
|
50
|
-
S: void 0,
|
|
51
|
-
A: [
|
|
52
|
-
"typeof typename === 'string' && !typename.startsWith('dxn:')",
|
|
53
|
-
"'Invalid typename'"
|
|
54
|
-
]
|
|
55
|
-
});
|
|
56
|
-
return typename;
|
|
57
|
-
};
|
|
58
|
-
var getVersion = (schema) => {
|
|
59
|
-
const version = EchoSchema.getSchemaVersion(schema);
|
|
60
|
-
invariant(typeof version === "string" && version.match(/^\d+\.\d+\.\d+$/), "Invalid version", {
|
|
61
|
-
F: __dxlog_file,
|
|
62
|
-
L: 94,
|
|
63
|
-
S: void 0,
|
|
64
|
-
A: [
|
|
65
|
-
"typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/)",
|
|
66
|
-
"'Invalid version'"
|
|
67
|
-
]
|
|
68
|
-
});
|
|
69
|
-
return version;
|
|
70
|
-
};
|
|
71
|
-
var getMeta = (schema) => {
|
|
72
|
-
return EchoSchema.getTypeAnnotation(schema);
|
|
73
|
-
};
|
|
74
|
-
var isMutable2 = (schema) => {
|
|
75
|
-
return EchoSchema.isMutable(schema);
|
|
76
|
-
};
|
|
14
|
+
import { SpaceId, ObjectId } from "@dxos/keys";
|
|
77
15
|
|
|
78
16
|
// packages/core/echo/echo/src/Obj.ts
|
|
79
17
|
var Obj_exports = {};
|
|
80
18
|
__export(Obj_exports, {
|
|
81
19
|
fromJSON: () => fromJSON,
|
|
82
|
-
getDXN: () =>
|
|
20
|
+
getDXN: () => getDXN,
|
|
83
21
|
getLabel: () => getLabel2,
|
|
84
|
-
getMeta: () =>
|
|
22
|
+
getMeta: () => getMeta2,
|
|
85
23
|
getSchema: () => getSchema2,
|
|
86
|
-
|
|
87
|
-
getTypename: () =>
|
|
24
|
+
getTypeDXN: () => getTypeDXN,
|
|
25
|
+
getTypename: () => getTypename,
|
|
88
26
|
instanceOf: () => instanceOf,
|
|
89
27
|
isDeleted: () => isDeleted2,
|
|
90
28
|
isObject: () => isObject,
|
|
@@ -92,27 +30,29 @@ __export(Obj_exports, {
|
|
|
92
30
|
toJSON: () => toJSON
|
|
93
31
|
});
|
|
94
32
|
import { Schema } from "effect";
|
|
95
|
-
import * as
|
|
96
|
-
import { assertArgument, invariant
|
|
33
|
+
import * as EchoSchema from "@dxos/echo-schema";
|
|
34
|
+
import { assertArgument, invariant } from "@dxos/invariant";
|
|
97
35
|
import * as LiveObject from "@dxos/live-object";
|
|
98
|
-
|
|
36
|
+
import { assumeType } from "@dxos/util";
|
|
37
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Obj.ts";
|
|
99
38
|
var make = LiveObject.live;
|
|
100
39
|
var isObject = (obj) => {
|
|
101
|
-
|
|
40
|
+
assumeType(obj);
|
|
41
|
+
return typeof obj === "object" && obj !== null && obj[EchoSchema.EntityKindId] === EchoSchema.EntityKind.Object;
|
|
102
42
|
};
|
|
103
43
|
var instanceOf = (...args) => {
|
|
104
44
|
if (args.length === 1) {
|
|
105
|
-
return (obj) =>
|
|
45
|
+
return (obj) => EchoSchema.isInstanceOf(args[0], obj);
|
|
106
46
|
}
|
|
107
|
-
return
|
|
47
|
+
return EchoSchema.isInstanceOf(args[0], args[1]);
|
|
108
48
|
};
|
|
109
|
-
var getSchema2 =
|
|
110
|
-
var
|
|
49
|
+
var getSchema2 = EchoSchema.getSchema;
|
|
50
|
+
var getDXN = (obj) => {
|
|
111
51
|
assertArgument(!Schema.isSchema(obj), "Object should not be a schema.");
|
|
112
|
-
const dxn =
|
|
113
|
-
|
|
114
|
-
F:
|
|
115
|
-
L:
|
|
52
|
+
const dxn = EchoSchema.getObjectDXN(obj);
|
|
53
|
+
invariant(dxn != null, "Invalid object.", {
|
|
54
|
+
F: __dxlog_file,
|
|
55
|
+
L: 58,
|
|
116
56
|
S: void 0,
|
|
117
57
|
A: [
|
|
118
58
|
"dxn != null",
|
|
@@ -121,31 +61,19 @@ var getDXN2 = (obj) => {
|
|
|
121
61
|
});
|
|
122
62
|
return dxn;
|
|
123
63
|
};
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
invariant2(type != null, "Invalid object.", {
|
|
127
|
-
F: __dxlog_file2,
|
|
128
|
-
L: 61,
|
|
129
|
-
S: void 0,
|
|
130
|
-
A: [
|
|
131
|
-
"type != null",
|
|
132
|
-
"'Invalid object.'"
|
|
133
|
-
]
|
|
134
|
-
});
|
|
135
|
-
return type;
|
|
136
|
-
};
|
|
137
|
-
var getTypename2 = (obj) => {
|
|
64
|
+
var getTypeDXN = EchoSchema.getType;
|
|
65
|
+
var getTypename = (obj) => {
|
|
138
66
|
const schema = getSchema2(obj);
|
|
139
67
|
if (schema == null) {
|
|
140
|
-
return
|
|
68
|
+
return EchoSchema.getType(obj)?.asTypeDXN()?.type;
|
|
141
69
|
}
|
|
142
|
-
return
|
|
70
|
+
return EchoSchema.getSchemaTypename(schema);
|
|
143
71
|
};
|
|
144
|
-
var
|
|
145
|
-
const meta =
|
|
146
|
-
|
|
147
|
-
F:
|
|
148
|
-
L:
|
|
72
|
+
var getMeta2 = (obj) => {
|
|
73
|
+
const meta = EchoSchema.getMeta(obj);
|
|
74
|
+
invariant(meta != null, "Invalid object.", {
|
|
75
|
+
F: __dxlog_file,
|
|
76
|
+
L: 86,
|
|
149
77
|
S: void 0,
|
|
150
78
|
A: [
|
|
151
79
|
"meta != null",
|
|
@@ -155,10 +83,10 @@ var getMeta3 = (obj) => {
|
|
|
155
83
|
return meta;
|
|
156
84
|
};
|
|
157
85
|
var isDeleted2 = (obj) => {
|
|
158
|
-
const deleted =
|
|
159
|
-
|
|
160
|
-
F:
|
|
161
|
-
L:
|
|
86
|
+
const deleted = EchoSchema.isDeleted(obj);
|
|
87
|
+
invariant(typeof deleted === "boolean", "Invalid object.", {
|
|
88
|
+
F: __dxlog_file,
|
|
89
|
+
L: 93,
|
|
162
90
|
S: void 0,
|
|
163
91
|
A: [
|
|
164
92
|
"typeof deleted === 'boolean'",
|
|
@@ -170,11 +98,25 @@ var isDeleted2 = (obj) => {
|
|
|
170
98
|
var getLabel2 = (obj) => {
|
|
171
99
|
const schema = getSchema2(obj);
|
|
172
100
|
if (schema != null) {
|
|
173
|
-
return
|
|
101
|
+
return EchoSchema.getLabel(schema, obj);
|
|
174
102
|
}
|
|
175
103
|
};
|
|
176
|
-
var toJSON = (obj) =>
|
|
177
|
-
var fromJSON =
|
|
104
|
+
var toJSON = (obj) => EchoSchema.objectToJSON(obj);
|
|
105
|
+
var fromJSON = EchoSchema.objectFromJSON;
|
|
106
|
+
|
|
107
|
+
// packages/core/echo/echo/src/Ref.ts
|
|
108
|
+
var Ref_exports = {};
|
|
109
|
+
__export(Ref_exports, {
|
|
110
|
+
Array: () => Array,
|
|
111
|
+
fromDXN: () => fromDXN,
|
|
112
|
+
isRef: () => isRef,
|
|
113
|
+
make: () => make2
|
|
114
|
+
});
|
|
115
|
+
import * as EchoSchema2 from "@dxos/echo-schema";
|
|
116
|
+
var Array = EchoSchema2.RefArray;
|
|
117
|
+
var isRef = EchoSchema2.Ref.isRef;
|
|
118
|
+
var make2 = EchoSchema2.Ref.make;
|
|
119
|
+
var fromDXN = EchoSchema2.Ref.fromDXN;
|
|
178
120
|
|
|
179
121
|
// packages/core/echo/echo/src/Relation.ts
|
|
180
122
|
var Relation_exports = {};
|
|
@@ -186,17 +128,17 @@ __export(Relation_exports, {
|
|
|
186
128
|
getTarget: () => getTarget,
|
|
187
129
|
getTargetDXN: () => getTargetDXN,
|
|
188
130
|
isRelation: () => isRelation,
|
|
189
|
-
make: () =>
|
|
131
|
+
make: () => make3
|
|
190
132
|
});
|
|
191
133
|
import * as EchoSchema3 from "@dxos/echo-schema";
|
|
192
|
-
import { assertArgument as assertArgument2, invariant as
|
|
193
|
-
import { DXN
|
|
134
|
+
import { assertArgument as assertArgument2, invariant as invariant2 } from "@dxos/invariant";
|
|
135
|
+
import { DXN } from "@dxos/keys";
|
|
194
136
|
import * as LiveObject2 from "@dxos/live-object";
|
|
195
|
-
import { assumeType } from "@dxos/util";
|
|
196
|
-
var
|
|
137
|
+
import { assumeType as assumeType2 } from "@dxos/util";
|
|
138
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Relation.ts";
|
|
197
139
|
var Source = EchoSchema3.RelationSourceId;
|
|
198
140
|
var Target = EchoSchema3.RelationTargetId;
|
|
199
|
-
var
|
|
141
|
+
var make3 = LiveObject2.live;
|
|
200
142
|
var isRelation = (value) => {
|
|
201
143
|
if (typeof value !== "object" || value === null) {
|
|
202
144
|
return false;
|
|
@@ -209,10 +151,10 @@ var isRelation = (value) => {
|
|
|
209
151
|
};
|
|
210
152
|
var getSourceDXN = (value) => {
|
|
211
153
|
assertArgument2(isRelation(value), "Expected a relation");
|
|
212
|
-
|
|
154
|
+
assumeType2(value);
|
|
213
155
|
const dxn = value[EchoSchema3.RelationSourceDXNId];
|
|
214
|
-
|
|
215
|
-
F:
|
|
156
|
+
invariant2(dxn instanceof DXN, void 0, {
|
|
157
|
+
F: __dxlog_file2,
|
|
216
158
|
L: 38,
|
|
217
159
|
S: void 0,
|
|
218
160
|
A: [
|
|
@@ -224,10 +166,10 @@ var getSourceDXN = (value) => {
|
|
|
224
166
|
};
|
|
225
167
|
var getTargetDXN = (value) => {
|
|
226
168
|
assertArgument2(isRelation(value), "Expected a relation");
|
|
227
|
-
|
|
169
|
+
assumeType2(value);
|
|
228
170
|
const dxn = value[EchoSchema3.RelationTargetDXNId];
|
|
229
|
-
|
|
230
|
-
F:
|
|
171
|
+
invariant2(dxn instanceof DXN, void 0, {
|
|
172
|
+
F: __dxlog_file2,
|
|
231
173
|
L: 50,
|
|
232
174
|
S: void 0,
|
|
233
175
|
A: [
|
|
@@ -240,8 +182,8 @@ var getTargetDXN = (value) => {
|
|
|
240
182
|
var getSource = (relation) => {
|
|
241
183
|
assertArgument2(isRelation(relation), "Expected a relation");
|
|
242
184
|
const obj = relation[EchoSchema3.RelationSourceId];
|
|
243
|
-
|
|
244
|
-
F:
|
|
185
|
+
invariant2(obj !== void 0, `Invalid source: ${relation.id}`, {
|
|
186
|
+
F: __dxlog_file2,
|
|
245
187
|
L: 61,
|
|
246
188
|
S: void 0,
|
|
247
189
|
A: [
|
|
@@ -254,8 +196,8 @@ var getSource = (relation) => {
|
|
|
254
196
|
var getTarget = (relation) => {
|
|
255
197
|
assertArgument2(isRelation(relation), "Expected a relation");
|
|
256
198
|
const obj = relation[EchoSchema3.RelationTargetId];
|
|
257
|
-
|
|
258
|
-
F:
|
|
199
|
+
invariant2(obj !== void 0, `Invalid target: ${relation.id}`, {
|
|
200
|
+
F: __dxlog_file2,
|
|
259
201
|
L: 72,
|
|
260
202
|
S: void 0,
|
|
261
203
|
A: [
|
|
@@ -266,22 +208,83 @@ var getTarget = (relation) => {
|
|
|
266
208
|
return obj;
|
|
267
209
|
};
|
|
268
210
|
|
|
269
|
-
// packages/core/echo/echo/src/
|
|
270
|
-
var
|
|
271
|
-
__export(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
211
|
+
// packages/core/echo/echo/src/Type.ts
|
|
212
|
+
var Type_exports = {};
|
|
213
|
+
__export(Type_exports, {
|
|
214
|
+
DXN: () => DXN2,
|
|
215
|
+
Expando: () => Expando,
|
|
216
|
+
Format: () => Format,
|
|
217
|
+
JsonSchema: () => JsonSchemaType,
|
|
218
|
+
Kind: () => EntityKind3,
|
|
219
|
+
Obj: () => Obj,
|
|
220
|
+
ObjectId: () => ObjectId2,
|
|
221
|
+
Ref: () => Ref3,
|
|
222
|
+
Relation: () => Relation,
|
|
223
|
+
SpaceId: () => SpaceId2,
|
|
224
|
+
getDXN: () => getDXN2,
|
|
225
|
+
getMeta: () => getMeta3,
|
|
226
|
+
getTypename: () => getTypename2,
|
|
227
|
+
getVersion: () => getVersion,
|
|
228
|
+
isMutable: () => isMutable2,
|
|
229
|
+
toEffectSchema: () => toEffectSchema,
|
|
230
|
+
toJsonSchema: () => toJsonSchema
|
|
275
231
|
});
|
|
276
232
|
import * as EchoSchema4 from "@dxos/echo-schema";
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
233
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
234
|
+
import { EntityKind as EntityKind3 } from "@dxos/echo-schema";
|
|
235
|
+
import { SpaceId as SpaceId2, ObjectId as ObjectId2, DXN as DXN2 } from "@dxos/keys";
|
|
236
|
+
import {
|
|
237
|
+
Expando,
|
|
238
|
+
Format,
|
|
239
|
+
JsonSchemaType,
|
|
240
|
+
toEffectSchema,
|
|
241
|
+
toJsonSchema
|
|
242
|
+
} from "@dxos/echo-schema";
|
|
243
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Type.ts";
|
|
244
|
+
var Obj = EchoSchema4.EchoObject;
|
|
245
|
+
var Relation = EchoSchema4.EchoRelation;
|
|
246
|
+
var Ref3 = EchoSchema4.Ref;
|
|
247
|
+
var getDXN2 = (schema) => {
|
|
248
|
+
return EchoSchema4.getSchemaDXN(schema);
|
|
249
|
+
};
|
|
250
|
+
var getTypename2 = (schema) => {
|
|
251
|
+
const typename = EchoSchema4.getSchemaTypename(schema);
|
|
252
|
+
invariant3(typeof typename === "string" && !typename.startsWith("dxn:"), "Invalid typename", {
|
|
253
|
+
F: __dxlog_file3,
|
|
254
|
+
L: 89,
|
|
255
|
+
S: void 0,
|
|
256
|
+
A: [
|
|
257
|
+
"typeof typename === 'string' && !typename.startsWith('dxn:')",
|
|
258
|
+
"'Invalid typename'"
|
|
259
|
+
]
|
|
260
|
+
});
|
|
261
|
+
return typename;
|
|
262
|
+
};
|
|
263
|
+
var getVersion = (schema) => {
|
|
264
|
+
const version = EchoSchema4.getSchemaVersion(schema);
|
|
265
|
+
invariant3(typeof version === "string" && version.match(/^\d+\.\d+\.\d+$/), "Invalid version", {
|
|
266
|
+
F: __dxlog_file3,
|
|
267
|
+
L: 99,
|
|
268
|
+
S: void 0,
|
|
269
|
+
A: [
|
|
270
|
+
"typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/)",
|
|
271
|
+
"'Invalid version'"
|
|
272
|
+
]
|
|
273
|
+
});
|
|
274
|
+
return version;
|
|
275
|
+
};
|
|
276
|
+
var getMeta3 = (schema) => {
|
|
277
|
+
return EchoSchema4.getTypeAnnotation(schema);
|
|
278
|
+
};
|
|
279
|
+
var isMutable2 = EchoSchema4.isMutable;
|
|
280
280
|
|
|
281
281
|
// packages/core/echo/echo/src/index.ts
|
|
282
|
+
import { DXN as DXN3 } from "@dxos/keys";
|
|
282
283
|
import { Filter, Query } from "@dxos/echo-schema";
|
|
283
284
|
export {
|
|
285
|
+
DXN3 as DXN,
|
|
284
286
|
Filter,
|
|
287
|
+
Key_exports as Key,
|
|
285
288
|
Obj_exports as Obj,
|
|
286
289
|
Query,
|
|
287
290
|
Ref_exports as Ref,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport type { EncodedReference } from '@dxos/echo-protocol';\nimport * as EchoSchema from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport type * as Keys from '@dxos/keys';\n\n/**\n * ECHO schema.\n */\nexport type Schema = EchoSchema.EchoSchema;\n\n/**\n * EchoObject schema.\n */\nexport const Obj = EchoSchema.EchoObject;\n\n/**\n * EchoRelation schema.\n */\nexport const Relation = EchoSchema.EchoRelation;\n\n/**\n * Ref schema.\n */\nexport const Ref: <S extends Obj.Any>(schema: S) => EchoSchema.Ref$<Schema.Schema.Type<S>> = EchoSchema.Ref;\n\nexport namespace Obj {\n /**\n * Type that represents an arbitrary schema type of an object.\n * NOTE: This is not an instance type.\n */\n // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.\n export type Any = Schema.Schema.AnyNoContext;\n}\n\nexport namespace Relation {\n /**\n * Type that represents an arbitrary schema type of a relation.\n * NOTE: This is not an instance type.\n */\n // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.\n export type Any = Schema.Schema.AnyNoContext;\n\n /**\n * Get relation target type.\n */\n export type Target<A> = A extends EchoSchema.RelationSourceTargetRefs<infer T, infer _S> ? T : never;\n\n /**\n * Get relation source type.\n */\n export type Source<A> = A extends EchoSchema.RelationSourceTargetRefs<infer _T, infer S> ? S : never;\n}\n\nexport namespace Ref {\n /**\n * Type that represents an arbitrary schema type of a reference.\n * NOTE: This is not an instance type.\n */\n export type Any = Schema.Schema<EchoSchema.Ref<any>, EncodedReference>;\n}\n\n/**\n * Gets the full DXN of the schema.\n * Will include the version if it's a `type` DXN.\n * @example \"dxn:example.com/type/Person:0.1.0\"\n * @example \"dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX\"\n */\nexport const getDXN = (schema: Obj.Any | Relation.Any): Keys.DXN | undefined => {\n return EchoSchema.getSchemaDXN(schema);\n};\n\n/**\n * @param schema - Schema to get the typename from.\n * @returns The typename of the schema. Example: `example.com/type/Person`.\n */\nexport const getTypename = (schema: Obj.Any | Relation.Any): string => {\n const typename = EchoSchema.getSchemaTypename(schema);\n invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');\n return typename;\n};\n\n/**\n * Gets the version of the schema.\n * @example 0.1.0\n */\nexport const getVersion = (schema: Obj.Any | Relation.Any): string => {\n const version = EchoSchema.getSchemaVersion(schema);\n invariant(typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/), 'Invalid version');\n return version;\n};\n\n/**\n * ECHO type metadata.\n */\nexport type Meta = EchoSchema.TypeAnnotation;\n\n/**\n * Gets the meta data of the schema.\n */\nexport const getMeta = (schema: Obj.Any | Relation.Any): Meta | undefined => {\n return EchoSchema.getTypeAnnotation(schema);\n};\n\nexport { EntityKind as Kind } from '@dxos/echo-schema';\n\n/**\n * @returns True if the schema is mutable.\n */\nexport const isMutable = (schema: Obj.Any | Relation.Any): boolean => {\n return EchoSchema.isMutable(schema);\n};\n\nexport { SpaceId, ObjectId, DXN } from '@dxos/keys';\n\nexport {\n //\n Expando,\n JsonSchemaType as JsonSchema,\n toJsonSchema,\n Format,\n} from '@dxos/echo-schema';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport * as EchoSchema from '@dxos/echo-schema';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport type { DXN } from '@dxos/keys';\nimport * as LiveObject from '@dxos/live-object';\n\nimport type * as Ref from './Ref';\nimport type * as Type from './Type';\n\nexport type Any = EchoSchema.AnyEchoObject;\n\nexport const make = LiveObject.live;\n\n// TODO(dmaretskyi): Currently broken\nexport const isObject = (obj: unknown): obj is Any => {\n return LiveObject.isLiveObject(obj);\n};\n\n/**\n * Check that object or relation is an instance of a schema.\n * @example\n * ```ts\n * const person = Obj.make(Person, { name: 'John' });\n * const isPerson = Obj.instanceOf(Person);\n * isPerson(person); // true\n * ```\n */\nexport const instanceOf: {\n <S extends Type.Relation.Any | Type.Obj.Any>(schema: S): (value: unknown) => value is S;\n <S extends Type.Relation.Any | Type.Obj.Any>(schema: S, value: unknown): value is S;\n} = ((...args: any[]) => {\n if (args.length === 1) {\n return (obj: unknown) => EchoSchema.isInstanceOf(args[0], obj);\n }\n\n return EchoSchema.isInstanceOf(args[0], args[1]);\n}) as any;\n\nexport const getSchema = EchoSchema.getSchema;\n\n// TODO(dmaretskyi): Allow returning undefined.\nexport const getDXN = (obj: Any): DXN => {\n assertArgument(!Schema.isSchema(obj), 'Object should not be a schema.');\n const dxn = EchoSchema.getObjectDXN(obj);\n invariant(dxn != null, 'Invalid object.');\n return dxn;\n};\n\n/**\n * @returns The DXN of the object's type.\n * @example dxn:example.com/type/Contact:1.0.0\n */\n// TODO(dmaretskyi): Allow returning undefined.\nexport const getSchemaDXN = (obj: Any): DXN => {\n const type = EchoSchema.getType(obj);\n invariant(type != null, 'Invalid object.');\n return type;\n};\n\n/**\n * @returns The typename of the object's type.\n * @example `example.com/type/Contact`\n */\nexport const getTypename = (obj: Any): string | undefined => {\n const schema = getSchema(obj);\n if (schema == null) {\n // Try to extract typename from DXN.\n return getSchemaDXN(obj)?.asTypeDXN()?.type;\n }\n\n return EchoSchema.getSchemaTypename(schema);\n};\n\n// TODO(dmaretskyi): Allow returning undefined.\nexport const getMeta = (obj: Any): EchoSchema.ObjectMeta => {\n const meta = EchoSchema.getMeta(obj);\n invariant(meta != null, 'Invalid object.');\n return meta;\n};\n\n// TODO(dmaretskyi): Default to `false`.\nexport const isDeleted = (obj: Any): boolean => {\n const deleted = EchoSchema.isDeleted(obj);\n invariant(typeof deleted === 'boolean', 'Invalid object.');\n return deleted;\n};\n\nexport const getLabel = (obj: Any): string | undefined => {\n const schema = getSchema(obj);\n if (schema != null) {\n return EchoSchema.getLabel(schema, obj);\n }\n};\n\n/**\n * JSON representation of an object.\n */\nexport type JSON = EchoSchema.ObjectJSON;\n\n/**\n * Converts object to it's JSON representation.\n *\n * The same algorithm is used when calling the standard `JSON.stringify(obj)` function.\n */\nexport const toJSON = (obj: Any): JSON => EchoSchema.objectToJSON(obj);\n\n/**\n * Creates an object from it's json representation.\n * Performs schema validation.\n * References and schema will be resolvable if the `refResolver` is provided.\n *\n * The function need to be async to support resolving the schema as well as the relation endpoints.\n */\nexport const fromJSON: (json: unknown, options?: { refResolver?: Ref.Resolver }) => Promise<Any> =\n EchoSchema.objectFromJSON;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as EchoSchema from '@dxos/echo-schema';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN } from '@dxos/keys';\nimport * as LiveObject from '@dxos/live-object';\nimport { assumeType } from '@dxos/util';\n\nexport type Any = EchoSchema.AnyEchoObject & EchoSchema.RelationSourceTargetRefs;\n\nexport const Source = EchoSchema.RelationSourceId;\nexport const Target = EchoSchema.RelationTargetId;\n\nexport const make = LiveObject.live;\n\nexport const isRelation = (value: unknown): value is Any => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (EchoSchema.ATTR_RELATION_SOURCE in value || EchoSchema.ATTR_RELATION_TARGET in value) {\n return true;\n }\n\n const kind = (value as any)[EchoSchema.EntityKindId];\n return kind === EchoSchema.EntityKind.Relation;\n};\n\n/**\n * @returns Relation source DXN.\n * @throws If the object is not a relation.\n */\nexport const getSourceDXN = (value: Any): DXN => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<EchoSchema.InternalObjectProps>(value);\n const dxn = value[EchoSchema.RelationSourceDXNId];\n invariant(dxn instanceof DXN);\n return dxn;\n};\n\n/**\n * @returns Relation target DXN.\n * @throws If the object is not a relation.\n */\nexport const getTargetDXN = (value: Any): DXN => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<EchoSchema.InternalObjectProps>(value);\n const dxn = value[EchoSchema.RelationTargetDXNId];\n invariant(dxn instanceof DXN);\n return dxn;\n};\n\n/**\n * @returns Relation source.\n * @throws If the object is not a relation.\n */\nexport const getSource = <T extends Any>(relation: T): EchoSchema.RelationSource<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n const obj = relation[EchoSchema.RelationSourceId];\n invariant(obj !== undefined, `Invalid source: ${relation.id}`);\n return obj;\n};\n\n/**\n * @returns Relation target.\n * @throws If the object is not a relation.\n */\nexport const getTarget = <T extends Any>(relation: T): EchoSchema.RelationTarget<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n const obj = relation[EchoSchema.RelationTargetId];\n invariant(obj !== undefined, `Invalid target: ${relation.id}`);\n return obj;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as EchoSchema from '@dxos/echo-schema';\n\nimport type * as Obj from './Obj';\n\nexport type Any = EchoSchema.Ref<Obj.Any>;\n\nexport const make = EchoSchema.Ref.make;\n\nexport const isRef: (value: unknown) => value is Any = EchoSchema.Ref.isRef;\n\n// TODO(dmaretskyi): Consider just allowing `make` to accept DXN.\nexport const fromDXN = EchoSchema.Ref.fromDXN;\n\n/**\n * Extract reference target.\n */\nexport type Target<R extends Any> = R extends EchoSchema.Ref<infer T> ? T : never;\n\n/**\n * Reference resolver.\n */\nexport type Resolver = EchoSchema.RefResolver;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport * as Type from './Type';\nexport * as Obj from './Obj';\nexport * as Relation from './Relation';\nexport * as Ref from './Ref';\n\nexport { type Live } from '@dxos/live-object';\nexport { Filter, Query } from '@dxos/echo-schema';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAAA
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/Key.ts", "../../../src/Obj.ts", "../../../src/Ref.ts", "../../../src/Relation.ts", "../../../src/Type.ts", "../../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { SpaceId, ObjectId } from '@dxos/keys';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport * as EchoSchema from '@dxos/echo-schema';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { type DXN } from '@dxos/keys';\nimport * as LiveObject from '@dxos/live-object';\nimport { assumeType } from '@dxos/util';\n\nimport type * as Ref from './Ref';\nimport type * as Type from './Type';\n\nexport type Obj<T = any> = EchoSchema.AnyEchoObject & T;\nexport type Any = EchoSchema.AnyEchoObject;\n\nexport const make = LiveObject.live;\n\nexport const isObject = (obj: unknown): obj is Any => {\n assumeType<EchoSchema.InternalObjectProps>(obj);\n return typeof obj === 'object' && obj !== null && obj[EchoSchema.EntityKindId] === EchoSchema.EntityKind.Object;\n};\n\n/**\n * Test if object or relation is an instance of a schema.\n * @example\n * ```ts\n * const john = Obj.make(Person, { name: 'John' });\n * const johnIsPerson = Obj.instanceOf(Person)(john);\n *\n * const isPerson = Obj.instanceOf(Person);\n * if(isPerson(john)) {\n * // john is Person\n * }\n * ```\n */\nexport const instanceOf: {\n <S extends Type.Relation.Any | Type.Obj.Any>(schema: S): (value: unknown) => value is Schema.Schema.Type<S>;\n <S extends Type.Relation.Any | Type.Obj.Any>(schema: S, value: unknown): value is Schema.Schema.Type<S>;\n} = ((\n ...args: [schema: Type.Relation.Any | Type.Obj.Any, value: unknown] | [schema: Type.Relation.Any | Type.Obj.Any]\n) => {\n if (args.length === 1) {\n return (obj: unknown) => EchoSchema.isInstanceOf(args[0], obj);\n }\n\n return EchoSchema.isInstanceOf(args[0], args[1]);\n}) as any;\n\nexport const getSchema = EchoSchema.getSchema;\n\n// TODO(dmaretskyi): Allow returning undefined.\nexport const getDXN = (obj: Any): DXN => {\n assertArgument(!Schema.isSchema(obj), 'Object should not be a schema.');\n const dxn = EchoSchema.getObjectDXN(obj);\n invariant(dxn != null, 'Invalid object.');\n return dxn;\n};\n\n/**\n * @returns The DXN of the object's type.\n * @example dxn:example.com/type/Contact:1.0.0\n */\n// TODO(burdon): Expando does not have a type.\nexport const getTypeDXN = EchoSchema.getType;\n\n/**\n * @returns The typename of the object's type.\n * @example `example.com/type/Contact`\n */\nexport const getTypename = (obj: Any): string | undefined => {\n const schema = getSchema(obj);\n if (schema == null) {\n // Try to extract typename from DXN.\n return EchoSchema.getType(obj)?.asTypeDXN()?.type;\n }\n\n return EchoSchema.getSchemaTypename(schema);\n};\n\n// TODO(dmaretskyi): Allow returning undefined.\nexport const getMeta = (obj: Any): EchoSchema.ObjectMeta => {\n const meta = EchoSchema.getMeta(obj);\n invariant(meta != null, 'Invalid object.');\n return meta;\n};\n\n// TODO(dmaretskyi): Default to `false`.\nexport const isDeleted = (obj: Any): boolean => {\n const deleted = EchoSchema.isDeleted(obj);\n invariant(typeof deleted === 'boolean', 'Invalid object.');\n return deleted;\n};\n\nexport const getLabel = (obj: Any): string | undefined => {\n const schema = getSchema(obj);\n if (schema != null) {\n return EchoSchema.getLabel(schema, obj);\n }\n};\n\n/**\n * JSON representation of an object.\n */\nexport type JSON = EchoSchema.ObjectJSON;\n\n/**\n * Converts object to its JSON representation.\n *\n * The same algorithm is used when calling the standard `JSON.stringify(obj)` function.\n */\nexport const toJSON = (obj: Any): JSON => EchoSchema.objectToJSON(obj);\n\n/**\n * Creates an object from its json representation, performing schema validation.\n * References and schemas will be resolvable if the `refResolver` is provided.\n *\n * The function need to be async to support resolving the schema as well as the relation endpoints.\n */\nexport const fromJSON: (json: unknown, options?: { refResolver?: Ref.Resolver }) => Promise<Any> =\n EchoSchema.objectFromJSON;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as EchoSchema from '@dxos/echo-schema';\n\nimport type * as Obj from './Obj';\n\nexport type Ref<T extends Obj.Any> = EchoSchema.Ref<T>;\nexport type Any = EchoSchema.Ref<Obj.Any>;\n\nexport const Array = EchoSchema.RefArray;\n\n/**\n * Extract reference target.\n */\nexport type Target<R extends Any> = R extends EchoSchema.Ref<infer T> ? T : never;\n\n/**\n * Reference resolver.\n */\nexport type Resolver = EchoSchema.RefResolver;\n\nexport const isRef: (value: unknown) => value is Any = EchoSchema.Ref.isRef;\n\nexport const make = EchoSchema.Ref.make;\n\n// TODO(dmaretskyi): Consider just allowing `make` to accept DXN.\nexport const fromDXN = EchoSchema.Ref.fromDXN;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as EchoSchema from '@dxos/echo-schema';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN } from '@dxos/keys';\nimport * as LiveObject from '@dxos/live-object';\nimport { assumeType } from '@dxos/util';\n\nexport type Any = EchoSchema.AnyEchoObject & EchoSchema.RelationSourceTargetRefs;\n\nexport const Source = EchoSchema.RelationSourceId;\nexport const Target = EchoSchema.RelationTargetId;\n\nexport const make = LiveObject.live;\n\nexport const isRelation = (value: unknown): value is Any => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (EchoSchema.ATTR_RELATION_SOURCE in value || EchoSchema.ATTR_RELATION_TARGET in value) {\n return true;\n }\n\n const kind = (value as any)[EchoSchema.EntityKindId];\n return kind === EchoSchema.EntityKind.Relation;\n};\n\n/**\n * @returns Relation source DXN.\n * @throws If the object is not a relation.\n */\nexport const getSourceDXN = (value: Any): DXN => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<EchoSchema.InternalObjectProps>(value);\n const dxn = value[EchoSchema.RelationSourceDXNId];\n invariant(dxn instanceof DXN);\n return dxn;\n};\n\n/**\n * @returns Relation target DXN.\n * @throws If the object is not a relation.\n */\nexport const getTargetDXN = (value: Any): DXN => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<EchoSchema.InternalObjectProps>(value);\n const dxn = value[EchoSchema.RelationTargetDXNId];\n invariant(dxn instanceof DXN);\n return dxn;\n};\n\n/**\n * @returns Relation source.\n * @throws If the object is not a relation.\n */\nexport const getSource = <T extends Any>(relation: T): EchoSchema.RelationSource<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n const obj = relation[EchoSchema.RelationSourceId];\n invariant(obj !== undefined, `Invalid source: ${relation.id}`);\n return obj;\n};\n\n/**\n * @returns Relation target.\n * @throws If the object is not a relation.\n */\nexport const getTarget = <T extends Any>(relation: T): EchoSchema.RelationTarget<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n const obj = relation[EchoSchema.RelationTargetId];\n invariant(obj !== undefined, `Invalid target: ${relation.id}`);\n return obj;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport type { EncodedReference } from '@dxos/echo-protocol';\nimport * as EchoSchema from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport type * as Keys from '@dxos/keys';\n\n/**\n * ECHO schema.\n */\nexport type Schema = EchoSchema.EchoSchema;\n\n/**\n * EchoObject schema.\n */\nexport const Obj = EchoSchema.EchoObject;\n\n// TODO(buurdon): Move to Obj?\nexport namespace Obj {\n /**\n * Type that represents an arbitrary schema type of an object.\n * NOTE: This is not an instance type.\n */\n // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.\n export type Any = Schema.Schema.AnyNoContext;\n}\n\n/**\n * EchoRelation schema.\n */\nexport const Relation = EchoSchema.EchoRelation;\n\n// TODO(buurdon): Move to Relation?\nexport namespace Relation {\n /**\n * Type that represents an arbitrary schema type of a relation.\n * NOTE: This is not an instance type.\n */\n // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.\n export type Any = Schema.Schema.AnyNoContext;\n\n /**\n * Get relation target type.\n */\n export type Target<A> = A extends EchoSchema.RelationSourceTargetRefs<infer T, infer _S> ? T : never;\n\n /**\n * Get relation source type.\n */\n export type Source<A> = A extends EchoSchema.RelationSourceTargetRefs<infer _T, infer S> ? S : never;\n}\n\n/**\n * Ref schema.\n */\nexport const Ref: <S extends Obj.Any>(schema: S) => EchoSchema.Ref$<Schema.Schema.Type<S>> = EchoSchema.Ref;\n\nexport interface Ref<T> extends Schema.SchemaClass<EchoSchema.Ref<T>, EncodedReference> {}\n\n// TODO(buurdon): Move to Ref?\nexport namespace Ref {\n /**\n * Type that represents an arbitrary schema type of a reference.\n * NOTE: This is not an instance type.\n */\n export type Any = Schema.Schema<EchoSchema.Ref<any>, EncodedReference>;\n}\n\n/**\n * Gets the full DXN of the schema.\n * Will include the version if it's a `type` DXN.\n * @example \"dxn:example.com/type/Person:0.1.0\"\n * @example \"dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX\"\n */\nexport const getDXN = (schema: Obj.Any | Relation.Any): Keys.DXN | undefined => {\n return EchoSchema.getSchemaDXN(schema);\n};\n\n/**\n * @param schema - Schema to get the typename from.\n * @returns The typename of the schema. Example: `example.com/type/Person`.\n */\nexport const getTypename = (schema: Obj.Any | Relation.Any): string => {\n const typename = EchoSchema.getSchemaTypename(schema);\n invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');\n return typename;\n};\n\n/**\n * Gets the version of the schema.\n * @example 0.1.0\n */\nexport const getVersion = (schema: Obj.Any | Relation.Any): string => {\n const version = EchoSchema.getSchemaVersion(schema);\n invariant(typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/), 'Invalid version');\n return version;\n};\n\n/**\n * ECHO type metadata.\n */\nexport type Meta = EchoSchema.TypeAnnotation;\n\n/**\n * Gets the meta data of the schema.\n */\nexport const getMeta = (schema: Obj.Any | Relation.Any): Meta | undefined => {\n return EchoSchema.getTypeAnnotation(schema);\n};\n\nexport { EntityKind as Kind } from '@dxos/echo-schema';\n\n/**\n * @returns True if the schema is mutable.\n */\nexport const isMutable = EchoSchema.isMutable;\n\nexport { SpaceId, ObjectId, DXN } from '@dxos/keys';\n\nexport {\n //\n Expando,\n // TODO(burdon): Standardize.\n Format,\n JsonSchemaType as JsonSchema,\n toEffectSchema,\n toJsonSchema,\n} from '@dxos/echo-schema';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport * as Key from './Key';\nexport * as Obj from './Obj';\nexport * as Ref from './Ref';\nexport * as Relation from './Relation';\nexport * as Type from './Type';\n\nexport { DXN } from '@dxos/keys';\nexport { Filter, Query } from '@dxos/echo-schema';\nexport { type Live } from '@dxos/live-object';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;;AAIA,SAASA,SAASC,gBAAgB;;;ACJlC;;;;kBAAAC;EAAA,eAAAC;EAAA,iBAAAC;EAAA;;;mBAAAC;EAAA;;;;AAIA,SAASC,cAAc;AAEvB,YAAYC,gBAAgB;AAC5B,SAASC,gBAAgBC,iBAAiB;AAE1C,YAAYC,gBAAgB;AAC5B,SAASC,kBAAkB;;AAQpB,IAAMC,OAAkBC;AAExB,IAAMC,WAAW,CAACC,QAAAA;AACvBJ,aAA2CI,GAAAA;AAC3C,SAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQA,IAAeC,uBAAY,MAAiBC,sBAAWC;AAC3G;AAeO,IAAMC,aAGR,IACAC,SAAAA;AAEH,MAAIA,KAAKC,WAAW,GAAG;AACrB,WAAO,CAACN,QAA4BO,wBAAaF,KAAK,CAAA,GAAIL,GAAAA;EAC5D;AAEA,SAAkBO,wBAAaF,KAAK,CAAA,GAAIA,KAAK,CAAA,CAAE;AACjD;AAEO,IAAMhB,aAAuBA;AAG7B,IAAMmB,SAAS,CAACR,QAAAA;AACrBP,iBAAe,CAACF,OAAOkB,SAAST,GAAAA,GAAM,gCAAA;AACtC,QAAMU,MAAiBC,wBAAaX,GAAAA;AACpCN,YAAUgB,OAAO,MAAM,mBAAA;;;;;;;;;AACvB,SAAOA;AACT;AAOO,IAAME,aAAwBC;AAM9B,IAAMC,cAAc,CAACd,QAAAA;AAC1B,QAAMe,SAAS1B,WAAUW,GAAAA;AACzB,MAAIe,UAAU,MAAM;AAElB,WAAkBF,mBAAQb,GAAAA,GAAMgB,UAAAA,GAAaC;EAC/C;AAEA,SAAkBC,6BAAkBH,MAAAA;AACtC;AAGO,IAAM3B,WAAU,CAACY,QAAAA;AACtB,QAAMmB,OAAkB/B,mBAAQY,GAAAA;AAChCN,YAAUyB,QAAQ,MAAM,mBAAA;;;;;;;;;AACxB,SAAOA;AACT;AAGO,IAAM7B,aAAY,CAACU,QAAAA;AACxB,QAAMoB,UAAqB9B,qBAAUU,GAAAA;AACrCN,YAAU,OAAO0B,YAAY,WAAW,mBAAA;;;;;;;;;AACxC,SAAOA;AACT;AAEO,IAAMjC,YAAW,CAACa,QAAAA;AACvB,QAAMe,SAAS1B,WAAUW,GAAAA;AACzB,MAAIe,UAAU,MAAM;AAClB,WAAkB5B,oBAAS4B,QAAQf,GAAAA;EACrC;AACF;AAYO,IAAMqB,SAAS,CAACrB,QAA8BsB,wBAAatB,GAAAA;AAQ3D,IAAMuB,WACAC;;;AC1Hb;;;;;cAAAC;;AAIA,YAAYC,iBAAgB;AAOrB,IAAMC,QAAmBC;AAYzB,IAAMC,QAAqDC,gBAAID;AAE/D,IAAME,QAAkBD,gBAAIC;AAG5B,IAAMC,UAAqBF,gBAAIE;;;AC5BtC;;;;;;;;;cAAAC;;AAIA,YAAYC,iBAAgB;AAC5B,SAASC,kBAAAA,iBAAgBC,aAAAA,kBAAiB;AAC1C,SAASC,WAAW;AACpB,YAAYC,iBAAgB;AAC5B,SAASC,cAAAA,mBAAkB;;AAIpB,IAAMC,SAAoBC;AAC1B,IAAMC,SAAoBC;AAE1B,IAAMV,QAAkBW;AAExB,IAAMC,aAAa,CAACC,UAAAA;AACzB,MAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM;AAC/C,WAAO;EACT;AACA,MAAeC,oCAAwBD,SAAoBE,oCAAwBF,OAAO;AACxF,WAAO;EACT;AAEA,QAAMG,OAAQH,MAAyBI,wBAAY;AACnD,SAAOD,SAAoBE,uBAAWC;AACxC;AAMO,IAAMC,eAAe,CAACP,UAAAA;AAC3BX,EAAAA,gBAAeU,WAAWC,KAAAA,GAAQ,qBAAA;AAClCP,EAAAA,YAA2CO,KAAAA;AAC3C,QAAMQ,MAAMR,MAAiBS,+BAAmB;AAChDnB,EAAAA,WAAUkB,eAAejB,KAAAA,QAAAA;;;;;;;;;AACzB,SAAOiB;AACT;AAMO,IAAME,eAAe,CAACV,UAAAA;AAC3BX,EAAAA,gBAAeU,WAAWC,KAAAA,GAAQ,qBAAA;AAClCP,EAAAA,YAA2CO,KAAAA;AAC3C,QAAMQ,MAAMR,MAAiBW,+BAAmB;AAChDrB,EAAAA,WAAUkB,eAAejB,KAAAA,QAAAA;;;;;;;;;AACzB,SAAOiB;AACT;AAMO,IAAMI,YAAY,CAAgBC,aAAAA;AACvCxB,EAAAA,gBAAeU,WAAWc,QAAAA,GAAW,qBAAA;AACrC,QAAMC,MAAMD,SAAoBlB,4BAAgB;AAChDL,EAAAA,WAAUwB,QAAQC,QAAW,mBAAmBF,SAASG,EAAE,IAAE;;;;;;;;;AAC7D,SAAOF;AACT;AAMO,IAAMG,YAAY,CAAgBJ,aAAAA;AACvCxB,EAAAA,gBAAeU,WAAWc,QAAAA,GAAW,qBAAA;AACrC,QAAMC,MAAMD,SAAoBhB,4BAAgB;AAChDP,EAAAA,WAAUwB,QAAQC,QAAW,mBAAmBF,SAASG,EAAE,IAAE;;;;;;;;;AAC7D,SAAOF;AACT;;;ACzEA;;aAAAI;EAAA;;;cAAAC;EAAA;kBAAAC;EAAA,WAAAC;EAAA;iBAAAC;EAAA,cAAAC;EAAA,eAAAC;EAAA,mBAAAC;EAAA;mBAAAC;EAAA;;;AAOA,YAAYC,iBAAgB;AAC5B,SAASC,aAAAA,kBAAiB;AA0G1B,SAAuBC,cAAdV,mBAA0B;AAOnC,SAASG,WAAAA,UAASF,YAAAA,WAAUF,OAAAA,YAAW;AAEvC;EAEEY;EAEAC;EACkBC;EAClBC;EACAC;OACK;;AAhHA,IAAMC,MAAiBC;AAevB,IAAMC,WAAsBC;AAyB5B,IAAMjB,OAA2FA;AAmBjG,IAAME,UAAS,CAACgB,WAAAA;AACrB,SAAkBC,yBAAaD,MAAAA;AACjC;AAMO,IAAMd,eAAc,CAACc,WAAAA;AAC1B,QAAME,WAAsBC,8BAAkBH,MAAAA;AAC9CX,EAAAA,WAAU,OAAOa,aAAa,YAAY,CAACA,SAASE,WAAW,MAAA,GAAS,oBAAA;;;;;;;;;AACxE,SAAOF;AACT;AAMO,IAAMG,aAAa,CAACL,WAAAA;AACzB,QAAMM,UAAqBC,6BAAiBP,MAAAA;AAC5CX,EAAAA,WAAU,OAAOiB,YAAY,YAAYA,QAAQE,MAAM,iBAAA,GAAoB,mBAAA;;;;;;;;;AAC3E,SAAOF;AACT;AAUO,IAAMrB,WAAU,CAACe,WAAAA;AACtB,SAAkBS,8BAAkBT,MAAAA;AACtC;AAOO,IAAMb,aAAuBA;;;AC7GpC,SAASuB,OAAAA,YAAW;AACpB,SAASC,QAAQC,aAAa;",
|
|
6
|
+
"names": ["SpaceId", "ObjectId", "getLabel", "getMeta", "getSchema", "isDeleted", "Schema", "EchoSchema", "assertArgument", "invariant", "LiveObject", "assumeType", "make", "live", "isObject", "obj", "EntityKindId", "EntityKind", "Object", "instanceOf", "args", "length", "isInstanceOf", "getDXN", "isSchema", "dxn", "getObjectDXN", "getTypeDXN", "getType", "getTypename", "schema", "asTypeDXN", "type", "getSchemaTypename", "meta", "deleted", "toJSON", "objectToJSON", "fromJSON", "objectFromJSON", "make", "EchoSchema", "Array", "RefArray", "isRef", "Ref", "make", "fromDXN", "make", "EchoSchema", "assertArgument", "invariant", "DXN", "LiveObject", "assumeType", "Source", "RelationSourceId", "Target", "RelationTargetId", "live", "isRelation", "value", "ATTR_RELATION_SOURCE", "ATTR_RELATION_TARGET", "kind", "EntityKindId", "EntityKind", "Relation", "getSourceDXN", "dxn", "RelationSourceDXNId", "getTargetDXN", "RelationTargetDXNId", "getSource", "relation", "obj", "undefined", "id", "getTarget", "DXN", "EntityKind", "ObjectId", "Ref", "SpaceId", "getDXN", "getMeta", "getTypename", "isMutable", "EchoSchema", "invariant", "Kind", "Expando", "Format", "JsonSchema", "toEffectSchema", "toJsonSchema", "Obj", "EchoObject", "Relation", "EchoRelation", "schema", "getSchemaDXN", "typename", "getSchemaTypename", "startsWith", "getVersion", "version", "getSchemaVersion", "match", "getTypeAnnotation", "DXN", "Filter", "Query"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo/src/
|
|
1
|
+
{"inputs":{"packages/core/echo/echo/src/Key.ts":{"bytes":561,"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/Obj.ts":{"bytes":11506,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/Ref.ts":{"bytes":1965,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/Relation.ts":{"bytes":8382,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/Type.ts":{"bytes":9107,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":1410,"imports":[{"path":"packages/core/echo/echo/src/Key.ts","kind":"import-statement","original":"./Key"},{"path":"packages/core/echo/echo/src/Obj.ts","kind":"import-statement","original":"./Obj"},{"path":"packages/core/echo/echo/src/Ref.ts","kind":"import-statement","original":"./Ref"},{"path":"packages/core/echo/echo/src/Relation.ts","kind":"import-statement","original":"./Relation"},{"path":"packages/core/echo/echo/src/Type.ts","kind":"import-statement","original":"./Type"},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16247},"packages/core/echo/echo/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["DXN","Filter","Key","Obj","Query","Ref","Relation","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/Key.ts":{"bytesInOutput":151},"packages/core/echo/echo/src/index.ts":{"bytesInOutput":93},"packages/core/echo/echo/src/Obj.ts":{"bytesInOutput":2435},"packages/core/echo/echo/src/Ref.ts":{"bytesInOutput":332},"packages/core/echo/echo/src/Relation.ts":{"bytesInOutput":2515},"packages/core/echo/echo/src/Type.ts":{"bytesInOutput":2037}},"bytes":8207}}}
|