@dxos/echo 0.8.2 → 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 +41 -35
- package/dist/lib/browser/index.mjs +179 -143
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +170 -135
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +179 -143
- 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 +33 -7
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +13 -3
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +13 -0
- package/dist/types/src/Relation.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 +54 -17
- package/src/Ref.ts +14 -6
- package/src/Relation.ts +33 -4
- package/src/Type.ts +19 -14
- package/src/index.ts +5 -3
- package/src/test/api.test.ts +17 -2
|
@@ -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}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -28,7 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var node_exports = {};
|
|
30
30
|
__export(node_exports, {
|
|
31
|
+
DXN: () => import_keys4.DXN,
|
|
31
32
|
Filter: () => import_echo_schema3.Filter,
|
|
33
|
+
Key: () => Key_exports,
|
|
32
34
|
Obj: () => Obj_exports,
|
|
33
35
|
Query: () => import_echo_schema3.Query,
|
|
34
36
|
Ref: () => Ref_exports,
|
|
@@ -36,113 +38,69 @@ __export(node_exports, {
|
|
|
36
38
|
Type: () => Type_exports
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(node_exports);
|
|
39
|
-
var EchoSchema = __toESM(require("@dxos/echo-schema"));
|
|
40
|
-
var import_invariant = require("@dxos/invariant");
|
|
41
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
42
41
|
var import_keys = require("@dxos/keys");
|
|
43
|
-
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
44
42
|
var import_effect = require("effect");
|
|
45
|
-
var
|
|
46
|
-
var
|
|
43
|
+
var EchoSchema = __toESM(require("@dxos/echo-schema"));
|
|
44
|
+
var import_invariant = require("@dxos/invariant");
|
|
47
45
|
var LiveObject = __toESM(require("@dxos/live-object"));
|
|
46
|
+
var import_util = require("@dxos/util");
|
|
47
|
+
var EchoSchema2 = __toESM(require("@dxos/echo-schema"));
|
|
48
48
|
var EchoSchema3 = __toESM(require("@dxos/echo-schema"));
|
|
49
|
-
var
|
|
49
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
50
|
+
var import_keys2 = require("@dxos/keys");
|
|
50
51
|
var LiveObject2 = __toESM(require("@dxos/live-object"));
|
|
52
|
+
var import_util2 = require("@dxos/util");
|
|
51
53
|
var EchoSchema4 = __toESM(require("@dxos/echo-schema"));
|
|
54
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
55
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
56
|
+
var import_keys3 = require("@dxos/keys");
|
|
57
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
58
|
+
var import_keys4 = require("@dxos/keys");
|
|
52
59
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
53
60
|
var __defProp2 = Object.defineProperty;
|
|
54
61
|
var __export2 = (target, all) => {
|
|
55
62
|
for (var name in all)
|
|
56
63
|
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
57
64
|
};
|
|
58
|
-
var
|
|
59
|
-
__export2(
|
|
60
|
-
DXN: () => import_keys.DXN,
|
|
61
|
-
Expando: () => import_echo_schema2.Expando,
|
|
62
|
-
Format: () => import_echo_schema2.Format,
|
|
63
|
-
JsonSchema: () => import_echo_schema2.JsonSchemaType,
|
|
64
|
-
Kind: () => import_echo_schema.EntityKind,
|
|
65
|
-
Obj: () => Obj,
|
|
65
|
+
var Key_exports = {};
|
|
66
|
+
__export2(Key_exports, {
|
|
66
67
|
ObjectId: () => import_keys.ObjectId,
|
|
67
|
-
|
|
68
|
-
Relation: () => Relation,
|
|
69
|
-
SpaceId: () => import_keys.SpaceId,
|
|
70
|
-
getDXN: () => getDXN,
|
|
71
|
-
getMeta: () => getMeta,
|
|
72
|
-
getTypename: () => getTypename,
|
|
73
|
-
getVersion: () => getVersion,
|
|
74
|
-
isMutable: () => isMutable2,
|
|
75
|
-
toJsonSchema: () => import_echo_schema2.toJsonSchema
|
|
68
|
+
SpaceId: () => import_keys.SpaceId
|
|
76
69
|
});
|
|
77
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Type.ts";
|
|
78
|
-
var Obj = EchoSchema.EchoObject;
|
|
79
|
-
var Relation = EchoSchema.EchoRelation;
|
|
80
|
-
var Ref2 = EchoSchema.Ref;
|
|
81
|
-
var getDXN = (schema) => {
|
|
82
|
-
return EchoSchema.getSchemaDXN(schema);
|
|
83
|
-
};
|
|
84
|
-
var getTypename = (schema) => {
|
|
85
|
-
const typename = EchoSchema.getSchemaTypename(schema);
|
|
86
|
-
(0, import_invariant.invariant)(typeof typename === "string" && !typename.startsWith("dxn:"), "Invalid typename", {
|
|
87
|
-
F: __dxlog_file,
|
|
88
|
-
L: 84,
|
|
89
|
-
S: void 0,
|
|
90
|
-
A: [
|
|
91
|
-
"typeof typename === 'string' && !typename.startsWith('dxn:')",
|
|
92
|
-
"'Invalid typename'"
|
|
93
|
-
]
|
|
94
|
-
});
|
|
95
|
-
return typename;
|
|
96
|
-
};
|
|
97
|
-
var getVersion = (schema) => {
|
|
98
|
-
const version = EchoSchema.getSchemaVersion(schema);
|
|
99
|
-
(0, import_invariant.invariant)(typeof version === "string" && version.match(/^\d+\.\d+\.\d+$/), "Invalid version", {
|
|
100
|
-
F: __dxlog_file,
|
|
101
|
-
L: 94,
|
|
102
|
-
S: void 0,
|
|
103
|
-
A: [
|
|
104
|
-
"typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/)",
|
|
105
|
-
"'Invalid version'"
|
|
106
|
-
]
|
|
107
|
-
});
|
|
108
|
-
return version;
|
|
109
|
-
};
|
|
110
|
-
var getMeta = (schema) => {
|
|
111
|
-
return EchoSchema.getTypeAnnotation(schema);
|
|
112
|
-
};
|
|
113
|
-
var isMutable2 = (schema) => {
|
|
114
|
-
return EchoSchema.isMutable(schema);
|
|
115
|
-
};
|
|
116
70
|
var Obj_exports = {};
|
|
117
71
|
__export2(Obj_exports, {
|
|
118
|
-
|
|
119
|
-
|
|
72
|
+
fromJSON: () => fromJSON,
|
|
73
|
+
getDXN: () => getDXN,
|
|
74
|
+
getLabel: () => getLabel2,
|
|
75
|
+
getMeta: () => getMeta2,
|
|
120
76
|
getSchema: () => getSchema2,
|
|
121
|
-
|
|
122
|
-
getTypename: () =>
|
|
77
|
+
getTypeDXN: () => getTypeDXN,
|
|
78
|
+
getTypename: () => getTypename,
|
|
123
79
|
instanceOf: () => instanceOf,
|
|
124
80
|
isDeleted: () => isDeleted2,
|
|
125
81
|
isObject: () => isObject,
|
|
126
|
-
make: () => make
|
|
82
|
+
make: () => make,
|
|
83
|
+
toJSON: () => toJSON
|
|
127
84
|
});
|
|
128
|
-
var
|
|
85
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Obj.ts";
|
|
129
86
|
var make = LiveObject.live;
|
|
130
87
|
var isObject = (obj) => {
|
|
131
|
-
|
|
88
|
+
(0, import_util.assumeType)(obj);
|
|
89
|
+
return typeof obj === "object" && obj !== null && obj[EchoSchema.EntityKindId] === EchoSchema.EntityKind.Object;
|
|
132
90
|
};
|
|
133
91
|
var instanceOf = (...args) => {
|
|
134
92
|
if (args.length === 1) {
|
|
135
|
-
return (obj) =>
|
|
93
|
+
return (obj) => EchoSchema.isInstanceOf(args[0], obj);
|
|
136
94
|
}
|
|
137
|
-
return
|
|
95
|
+
return EchoSchema.isInstanceOf(args[0], args[1]);
|
|
138
96
|
};
|
|
139
|
-
var getSchema2 =
|
|
140
|
-
var
|
|
141
|
-
(0,
|
|
142
|
-
const dxn =
|
|
143
|
-
(0,
|
|
144
|
-
F:
|
|
145
|
-
L:
|
|
97
|
+
var getSchema2 = EchoSchema.getSchema;
|
|
98
|
+
var getDXN = (obj) => {
|
|
99
|
+
(0, import_invariant.assertArgument)(!import_effect.Schema.isSchema(obj), "Object should not be a schema.");
|
|
100
|
+
const dxn = EchoSchema.getObjectDXN(obj);
|
|
101
|
+
(0, import_invariant.invariant)(dxn != null, "Invalid object.", {
|
|
102
|
+
F: __dxlog_file,
|
|
103
|
+
L: 58,
|
|
146
104
|
S: void 0,
|
|
147
105
|
A: [
|
|
148
106
|
"dxn != null",
|
|
@@ -151,31 +109,19 @@ var getDXN3 = (obj) => {
|
|
|
151
109
|
});
|
|
152
110
|
return dxn;
|
|
153
111
|
};
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
(0, import_invariant2.invariant)(type != null, "Invalid object.", {
|
|
157
|
-
F: __dxlog_file2,
|
|
158
|
-
L: 58,
|
|
159
|
-
S: void 0,
|
|
160
|
-
A: [
|
|
161
|
-
"type != null",
|
|
162
|
-
"'Invalid object.'"
|
|
163
|
-
]
|
|
164
|
-
});
|
|
165
|
-
return type;
|
|
166
|
-
};
|
|
167
|
-
var getTypename3 = (obj) => {
|
|
112
|
+
var getTypeDXN = EchoSchema.getType;
|
|
113
|
+
var getTypename = (obj) => {
|
|
168
114
|
const schema = getSchema2(obj);
|
|
169
115
|
if (schema == null) {
|
|
170
|
-
return
|
|
116
|
+
return EchoSchema.getType(obj)?.asTypeDXN()?.type;
|
|
171
117
|
}
|
|
172
|
-
return
|
|
118
|
+
return EchoSchema.getSchemaTypename(schema);
|
|
173
119
|
};
|
|
174
|
-
var
|
|
175
|
-
const meta =
|
|
176
|
-
(0,
|
|
177
|
-
F:
|
|
178
|
-
L:
|
|
120
|
+
var getMeta2 = (obj) => {
|
|
121
|
+
const meta = EchoSchema.getMeta(obj);
|
|
122
|
+
(0, import_invariant.invariant)(meta != null, "Invalid object.", {
|
|
123
|
+
F: __dxlog_file,
|
|
124
|
+
L: 86,
|
|
179
125
|
S: void 0,
|
|
180
126
|
A: [
|
|
181
127
|
"meta != null",
|
|
@@ -185,10 +131,10 @@ var getMeta3 = (obj) => {
|
|
|
185
131
|
return meta;
|
|
186
132
|
};
|
|
187
133
|
var isDeleted2 = (obj) => {
|
|
188
|
-
const deleted =
|
|
189
|
-
(0,
|
|
190
|
-
F:
|
|
191
|
-
L:
|
|
134
|
+
const deleted = EchoSchema.isDeleted(obj);
|
|
135
|
+
(0, import_invariant.invariant)(typeof deleted === "boolean", "Invalid object.", {
|
|
136
|
+
F: __dxlog_file,
|
|
137
|
+
L: 93,
|
|
192
138
|
S: void 0,
|
|
193
139
|
A: [
|
|
194
140
|
"typeof deleted === 'boolean'",
|
|
@@ -197,15 +143,40 @@ var isDeleted2 = (obj) => {
|
|
|
197
143
|
});
|
|
198
144
|
return deleted;
|
|
199
145
|
};
|
|
146
|
+
var getLabel2 = (obj) => {
|
|
147
|
+
const schema = getSchema2(obj);
|
|
148
|
+
if (schema != null) {
|
|
149
|
+
return EchoSchema.getLabel(schema, obj);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var toJSON = (obj) => EchoSchema.objectToJSON(obj);
|
|
153
|
+
var fromJSON = EchoSchema.objectFromJSON;
|
|
154
|
+
var Ref_exports = {};
|
|
155
|
+
__export2(Ref_exports, {
|
|
156
|
+
Array: () => Array,
|
|
157
|
+
fromDXN: () => fromDXN,
|
|
158
|
+
isRef: () => isRef,
|
|
159
|
+
make: () => make2
|
|
160
|
+
});
|
|
161
|
+
var Array = EchoSchema2.RefArray;
|
|
162
|
+
var isRef = EchoSchema2.Ref.isRef;
|
|
163
|
+
var make2 = EchoSchema2.Ref.make;
|
|
164
|
+
var fromDXN = EchoSchema2.Ref.fromDXN;
|
|
200
165
|
var Relation_exports = {};
|
|
201
166
|
__export2(Relation_exports, {
|
|
167
|
+
Source: () => Source,
|
|
168
|
+
Target: () => Target,
|
|
202
169
|
getSource: () => getSource,
|
|
170
|
+
getSourceDXN: () => getSourceDXN,
|
|
203
171
|
getTarget: () => getTarget,
|
|
172
|
+
getTargetDXN: () => getTargetDXN,
|
|
204
173
|
isRelation: () => isRelation,
|
|
205
|
-
make: () =>
|
|
174
|
+
make: () => make3
|
|
206
175
|
});
|
|
207
|
-
var
|
|
208
|
-
var
|
|
176
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Relation.ts";
|
|
177
|
+
var Source = EchoSchema3.RelationSourceId;
|
|
178
|
+
var Target = EchoSchema3.RelationTargetId;
|
|
179
|
+
var make3 = LiveObject2.live;
|
|
209
180
|
var isRelation = (value) => {
|
|
210
181
|
if (typeof value !== "object" || value === null) {
|
|
211
182
|
return false;
|
|
@@ -213,23 +184,45 @@ var isRelation = (value) => {
|
|
|
213
184
|
if (EchoSchema3.ATTR_RELATION_SOURCE in value || EchoSchema3.ATTR_RELATION_TARGET in value) {
|
|
214
185
|
return true;
|
|
215
186
|
}
|
|
216
|
-
const kind = value[EchoSchema3.
|
|
187
|
+
const kind = value[EchoSchema3.EntityKindId];
|
|
217
188
|
return kind === EchoSchema3.EntityKind.Relation;
|
|
218
189
|
};
|
|
219
|
-
var
|
|
220
|
-
(0,
|
|
221
|
-
|
|
222
|
-
|
|
190
|
+
var getSourceDXN = (value) => {
|
|
191
|
+
(0, import_invariant2.assertArgument)(isRelation(value), "Expected a relation");
|
|
192
|
+
(0, import_util2.assumeType)(value);
|
|
193
|
+
const dxn = value[EchoSchema3.RelationSourceDXNId];
|
|
194
|
+
(0, import_invariant2.invariant)(dxn instanceof import_keys2.DXN, void 0, {
|
|
195
|
+
F: __dxlog_file2,
|
|
196
|
+
L: 38,
|
|
223
197
|
S: void 0,
|
|
224
198
|
A: [
|
|
225
|
-
"
|
|
199
|
+
"dxn instanceof DXN",
|
|
226
200
|
""
|
|
227
201
|
]
|
|
228
202
|
});
|
|
203
|
+
return dxn;
|
|
204
|
+
};
|
|
205
|
+
var getTargetDXN = (value) => {
|
|
206
|
+
(0, import_invariant2.assertArgument)(isRelation(value), "Expected a relation");
|
|
207
|
+
(0, import_util2.assumeType)(value);
|
|
208
|
+
const dxn = value[EchoSchema3.RelationTargetDXNId];
|
|
209
|
+
(0, import_invariant2.invariant)(dxn instanceof import_keys2.DXN, void 0, {
|
|
210
|
+
F: __dxlog_file2,
|
|
211
|
+
L: 50,
|
|
212
|
+
S: void 0,
|
|
213
|
+
A: [
|
|
214
|
+
"dxn instanceof DXN",
|
|
215
|
+
""
|
|
216
|
+
]
|
|
217
|
+
});
|
|
218
|
+
return dxn;
|
|
219
|
+
};
|
|
220
|
+
var getSource = (relation) => {
|
|
221
|
+
(0, import_invariant2.assertArgument)(isRelation(relation), "Expected a relation");
|
|
229
222
|
const obj = relation[EchoSchema3.RelationSourceId];
|
|
230
|
-
(0,
|
|
231
|
-
F:
|
|
232
|
-
L:
|
|
223
|
+
(0, import_invariant2.invariant)(obj !== void 0, `Invalid source: ${relation.id}`, {
|
|
224
|
+
F: __dxlog_file2,
|
|
225
|
+
L: 61,
|
|
233
226
|
S: void 0,
|
|
234
227
|
A: [
|
|
235
228
|
"obj !== undefined",
|
|
@@ -239,39 +232,81 @@ var getSource = (relation) => {
|
|
|
239
232
|
return obj;
|
|
240
233
|
};
|
|
241
234
|
var getTarget = (relation) => {
|
|
242
|
-
(0,
|
|
235
|
+
(0, import_invariant2.assertArgument)(isRelation(relation), "Expected a relation");
|
|
236
|
+
const obj = relation[EchoSchema3.RelationTargetId];
|
|
237
|
+
(0, import_invariant2.invariant)(obj !== void 0, `Invalid target: ${relation.id}`, {
|
|
238
|
+
F: __dxlog_file2,
|
|
239
|
+
L: 72,
|
|
240
|
+
S: void 0,
|
|
241
|
+
A: [
|
|
242
|
+
"obj !== undefined",
|
|
243
|
+
"`Invalid target: ${relation.id}`"
|
|
244
|
+
]
|
|
245
|
+
});
|
|
246
|
+
return obj;
|
|
247
|
+
};
|
|
248
|
+
var Type_exports = {};
|
|
249
|
+
__export2(Type_exports, {
|
|
250
|
+
DXN: () => import_keys3.DXN,
|
|
251
|
+
Expando: () => import_echo_schema2.Expando,
|
|
252
|
+
Format: () => import_echo_schema2.Format,
|
|
253
|
+
JsonSchema: () => import_echo_schema2.JsonSchemaType,
|
|
254
|
+
Kind: () => import_echo_schema.EntityKind,
|
|
255
|
+
Obj: () => Obj,
|
|
256
|
+
ObjectId: () => import_keys3.ObjectId,
|
|
257
|
+
Ref: () => Ref3,
|
|
258
|
+
Relation: () => Relation,
|
|
259
|
+
SpaceId: () => import_keys3.SpaceId,
|
|
260
|
+
getDXN: () => getDXN2,
|
|
261
|
+
getMeta: () => getMeta3,
|
|
262
|
+
getTypename: () => getTypename2,
|
|
263
|
+
getVersion: () => getVersion,
|
|
264
|
+
isMutable: () => isMutable2,
|
|
265
|
+
toEffectSchema: () => import_echo_schema2.toEffectSchema,
|
|
266
|
+
toJsonSchema: () => import_echo_schema2.toJsonSchema
|
|
267
|
+
});
|
|
268
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Type.ts";
|
|
269
|
+
var Obj = EchoSchema4.EchoObject;
|
|
270
|
+
var Relation = EchoSchema4.EchoRelation;
|
|
271
|
+
var Ref3 = EchoSchema4.Ref;
|
|
272
|
+
var getDXN2 = (schema) => {
|
|
273
|
+
return EchoSchema4.getSchemaDXN(schema);
|
|
274
|
+
};
|
|
275
|
+
var getTypename2 = (schema) => {
|
|
276
|
+
const typename = EchoSchema4.getSchemaTypename(schema);
|
|
277
|
+
(0, import_invariant3.invariant)(typeof typename === "string" && !typename.startsWith("dxn:"), "Invalid typename", {
|
|
243
278
|
F: __dxlog_file3,
|
|
244
|
-
L:
|
|
279
|
+
L: 89,
|
|
245
280
|
S: void 0,
|
|
246
281
|
A: [
|
|
247
|
-
"
|
|
248
|
-
""
|
|
282
|
+
"typeof typename === 'string' && !typename.startsWith('dxn:')",
|
|
283
|
+
"'Invalid typename'"
|
|
249
284
|
]
|
|
250
285
|
});
|
|
251
|
-
|
|
252
|
-
|
|
286
|
+
return typename;
|
|
287
|
+
};
|
|
288
|
+
var getVersion = (schema) => {
|
|
289
|
+
const version = EchoSchema4.getSchemaVersion(schema);
|
|
290
|
+
(0, import_invariant3.invariant)(typeof version === "string" && version.match(/^\d+\.\d+\.\d+$/), "Invalid version", {
|
|
253
291
|
F: __dxlog_file3,
|
|
254
|
-
L:
|
|
292
|
+
L: 99,
|
|
255
293
|
S: void 0,
|
|
256
294
|
A: [
|
|
257
|
-
"
|
|
258
|
-
"
|
|
295
|
+
"typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/)",
|
|
296
|
+
"'Invalid version'"
|
|
259
297
|
]
|
|
260
298
|
});
|
|
261
|
-
return
|
|
299
|
+
return version;
|
|
262
300
|
};
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
make: () => make3
|
|
268
|
-
});
|
|
269
|
-
var make3 = EchoSchema4.Ref.make;
|
|
270
|
-
var isRef = EchoSchema4.Ref.isRef;
|
|
271
|
-
var fromDXN = EchoSchema4.Ref.fromDXN;
|
|
301
|
+
var getMeta3 = (schema) => {
|
|
302
|
+
return EchoSchema4.getTypeAnnotation(schema);
|
|
303
|
+
};
|
|
304
|
+
var isMutable2 = EchoSchema4.isMutable;
|
|
272
305
|
// Annotate the CommonJS export names for ESM import in node:
|
|
273
306
|
0 && (module.exports = {
|
|
307
|
+
DXN,
|
|
274
308
|
Filter,
|
|
309
|
+
Key,
|
|
275
310
|
Obj,
|
|
276
311
|
Query,
|
|
277
312
|
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 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\nexport const getDXN = (obj: Any): DXN => {\n assertArgument(!Schema.isSchema(obj), 'Object should not be a schema.');\n const dxn = EchoSchema.getDXN(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 */\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.getTypename(schema);\n};\n\nexport const getMeta = (obj: Any): EchoSchema.ObjectMeta => {\n const meta = EchoSchema.getMeta(obj);\n invariant(meta != null, 'Invalid object.');\n return meta;\n};\n\nexport const isDeleted = (obj: Any): boolean => {\n const deleted = EchoSchema.isDeleted(obj);\n invariant(typeof deleted === 'boolean', 'Invalid object.');\n return deleted;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as EchoSchema from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport * as LiveObject from '@dxos/live-object';\n\nexport type Any = EchoSchema.AnyEchoObject & EchoSchema.RelationSourceTargetRefs;\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.EntityKindPropertyId];\n return kind === EchoSchema.EntityKind.Relation;\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 invariant(isRelation(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 invariant(isRelation(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// 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": "
|
|
6
|
-
"names": ["import_echo_schema", "
|
|
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": "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",
|
|
6
|
+
"names": ["import_invariant", "import_keys", "import_util", "import_echo_schema", "getLabel", "getMeta", "getSchema", "isDeleted", "make", "live", "isObject", "obj", "assumeType", "EntityKindId", "EntityKind", "Object", "instanceOf", "args", "length", "isInstanceOf", "getDXN", "assertArgument", "Schema", "isSchema", "dxn", "getObjectDXN", "invariant", "getTypeDXN", "getType", "getTypename", "schema", "asTypeDXN", "type", "getSchemaTypename", "meta", "deleted", "toJSON", "objectToJSON", "fromJSON", "objectFromJSON", "Array", "RefArray", "isRef", "Ref", "fromDXN", "Source", "RelationSourceId", "Target", "RelationTargetId", "isRelation", "value", "ATTR_RELATION_SOURCE", "ATTR_RELATION_TARGET", "kind", "Relation", "getSourceDXN", "RelationSourceDXNId", "DXN", "getTargetDXN", "RelationTargetDXNId", "getSource", "relation", "undefined", "id", "getTarget", "ObjectId", "SpaceId", "isMutable", "Obj", "EchoObject", "EchoRelation", "getSchemaDXN", "typename", "startsWith", "getVersion", "version", "getSchemaVersion", "match", "getTypeAnnotation"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -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/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16246},"packages/core/echo/echo/dist/lib/node/index.cjs":{"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":8174}}}
|