@dxos/echo 0.8.1 → 0.8.2-main.10c050d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +116 -0
  2. package/dist/lib/browser/index.mjs +241 -32
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node/index.cjs +243 -28
  6. package/dist/lib/node/index.cjs.map +4 -4
  7. package/dist/lib/node/meta.json +1 -1
  8. package/dist/lib/node-esm/index.mjs +241 -32
  9. package/dist/lib/node-esm/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/meta.json +1 -1
  11. package/dist/types/src/Obj.d.ts +39 -0
  12. package/dist/types/src/Obj.d.ts.map +1 -0
  13. package/dist/types/src/Ref.d.ts +11 -0
  14. package/dist/types/src/Ref.d.ts.map +1 -0
  15. package/dist/types/src/Relation.d.ts +19 -0
  16. package/dist/types/src/Relation.d.ts.map +1 -0
  17. package/dist/types/src/Type.d.ts +80 -42
  18. package/dist/types/src/Type.d.ts.map +1 -1
  19. package/dist/types/src/{Database.d.ts → experimental/database.d.ts} +1 -1
  20. package/dist/types/src/experimental/database.d.ts.map +1 -0
  21. package/dist/types/src/experimental/index.d.ts +1 -0
  22. package/dist/types/src/experimental/index.d.ts.map +1 -0
  23. package/dist/types/src/{Queue.d.ts → experimental/queue.d.ts} +1 -1
  24. package/dist/types/src/experimental/queue.d.ts.map +1 -0
  25. package/dist/types/src/{Space.d.ts → experimental/space.d.ts} +1 -1
  26. package/dist/types/src/experimental/space.d.ts.map +1 -0
  27. package/dist/types/src/index.d.ts +5 -5
  28. package/dist/types/src/index.d.ts.map +1 -1
  29. package/dist/types/src/{api.test.d.ts.map → test/api.test.d.ts.map} +1 -1
  30. package/dist/types/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +14 -15
  32. package/src/Obj.ts +86 -0
  33. package/src/Ref.ts +21 -0
  34. package/src/Relation.ts +45 -0
  35. package/src/Type.ts +103 -75
  36. package/src/{Database.ts → experimental/database.ts} +1 -1
  37. package/src/experimental/index.ts +7 -0
  38. package/src/{Queue.ts → experimental/queue.ts} +1 -1
  39. package/src/index.ts +6 -7
  40. package/src/test/api.test.ts +128 -0
  41. package/dist/types/src/Database.d.ts.map +0 -1
  42. package/dist/types/src/Queue.d.ts.map +0 -1
  43. package/dist/types/src/Space.d.ts.map +0 -1
  44. package/src/api.test.ts +0 -94
  45. /package/dist/types/src/{api.test.d.ts → test/api.test.d.ts} +0 -0
  46. /package/src/{Space.ts → experimental/space.ts} +0 -0
@@ -5,45 +5,254 @@ var __export = (target, all) => {
5
5
  __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
 
8
- // packages/core/echo/echo/src/index.ts
9
- import { DXN } from "@dxos/keys";
10
-
11
- // packages/core/echo/echo/src/Database.ts
12
- var Database_exports = {};
13
-
14
- // packages/core/echo/echo/src/Queue.ts
15
- var Queue_exports = {};
16
-
17
- // packages/core/echo/echo/src/Space.ts
18
- var Space_exports = {};
19
-
20
8
  // packages/core/echo/echo/src/Type.ts
21
9
  var Type_exports = {};
22
10
  __export(Type_exports, {
11
+ DXN: () => DXN,
12
+ Expando: () => Expando,
13
+ Format: () => Format,
14
+ JsonSchema: () => JsonSchemaType,
23
15
  Kind: () => EntityKind,
16
+ Obj: () => Obj,
24
17
  ObjectId: () => ObjectId,
25
- Ref: () => Ref,
26
- create: () => create,
27
- def: () => def,
28
- getDXN: () => getSchemaDXN,
29
- getMeta: () => getTypeAnnotation,
30
- getSchema: () => getSchema,
31
- getTypename: () => getSchemaTypename,
32
- getVersion: () => getSchemaVersion,
33
- instanceOf: () => isInstanceOf,
34
- ref: () => ref
18
+ Ref: () => Ref2,
19
+ Relation: () => Relation,
20
+ SpaceId: () => SpaceId,
21
+ getDXN: () => getDXN,
22
+ getMeta: () => getMeta,
23
+ getTypename: () => getTypename,
24
+ getVersion: () => getVersion,
25
+ isMutable: () => isMutable2,
26
+ toJsonSchema: () => toJsonSchema
27
+ });
28
+ import * as EchoSchema from "@dxos/echo-schema";
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
+ };
77
+
78
+ // packages/core/echo/echo/src/Obj.ts
79
+ var Obj_exports = {};
80
+ __export(Obj_exports, {
81
+ getDXN: () => getDXN3,
82
+ getMeta: () => getMeta3,
83
+ getSchema: () => getSchema2,
84
+ getSchemaDXN: () => getSchemaDXN2,
85
+ getTypename: () => getTypename3,
86
+ instanceOf: () => instanceOf,
87
+ isDeleted: () => isDeleted2,
88
+ isObject: () => isObject,
89
+ make: () => make
90
+ });
91
+ import { Schema } from "effect";
92
+ import * as EchoSchema2 from "@dxos/echo-schema";
93
+ import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
94
+ import * as LiveObject from "@dxos/live-object";
95
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Obj.ts";
96
+ var make = LiveObject.live;
97
+ var isObject = (obj) => {
98
+ return LiveObject.isLiveObject(obj);
99
+ };
100
+ var instanceOf = (...args) => {
101
+ if (args.length === 1) {
102
+ return (obj) => EchoSchema2.isInstanceOf(args[0], obj);
103
+ }
104
+ return EchoSchema2.isInstanceOf(args[0], args[1]);
105
+ };
106
+ var getSchema2 = EchoSchema2.getSchema;
107
+ var getDXN3 = (obj) => {
108
+ assertArgument(!Schema.isSchema(obj), "Object should not be a schema.");
109
+ const dxn = EchoSchema2.getDXN(obj);
110
+ invariant2(dxn != null, "Invalid object.", {
111
+ F: __dxlog_file2,
112
+ L: 48,
113
+ S: void 0,
114
+ A: [
115
+ "dxn != null",
116
+ "'Invalid object.'"
117
+ ]
118
+ });
119
+ return dxn;
120
+ };
121
+ var getSchemaDXN2 = (obj) => {
122
+ const type = EchoSchema2.getType(obj);
123
+ invariant2(type != null, "Invalid object.", {
124
+ F: __dxlog_file2,
125
+ L: 58,
126
+ S: void 0,
127
+ A: [
128
+ "type != null",
129
+ "'Invalid object.'"
130
+ ]
131
+ });
132
+ return type;
133
+ };
134
+ var getTypename3 = (obj) => {
135
+ const schema = getSchema2(obj);
136
+ if (schema == null) {
137
+ return getSchemaDXN2(obj)?.asTypeDXN()?.type;
138
+ }
139
+ return EchoSchema2.getTypename(schema);
140
+ };
141
+ var getMeta3 = (obj) => {
142
+ const meta = EchoSchema2.getMeta(obj);
143
+ invariant2(meta != null, "Invalid object.", {
144
+ F: __dxlog_file2,
145
+ L: 78,
146
+ S: void 0,
147
+ A: [
148
+ "meta != null",
149
+ "'Invalid object.'"
150
+ ]
151
+ });
152
+ return meta;
153
+ };
154
+ var isDeleted2 = (obj) => {
155
+ const deleted = EchoSchema2.isDeleted(obj);
156
+ invariant2(typeof deleted === "boolean", "Invalid object.", {
157
+ F: __dxlog_file2,
158
+ L: 84,
159
+ S: void 0,
160
+ A: [
161
+ "typeof deleted === 'boolean'",
162
+ "'Invalid object.'"
163
+ ]
164
+ });
165
+ return deleted;
166
+ };
167
+
168
+ // packages/core/echo/echo/src/Relation.ts
169
+ var Relation_exports = {};
170
+ __export(Relation_exports, {
171
+ getSource: () => getSource,
172
+ getTarget: () => getTarget,
173
+ isRelation: () => isRelation,
174
+ make: () => make2
35
175
  });
36
- import { EchoObject, EntityKind, ObjectId, Ref as Ref$, getTypeAnnotation, getSchema, getSchemaDXN, getSchemaTypename, getSchemaVersion, isInstanceOf } from "@dxos/echo-schema";
37
- import { create as create$, makeRef } from "@dxos/live-object";
38
- var ref = makeRef;
39
- var create = create$;
40
- var def = (meta) => EchoObject(meta);
41
- var Ref = (self) => Ref$(self);
176
+ import * as EchoSchema3 from "@dxos/echo-schema";
177
+ import { invariant as invariant3 } from "@dxos/invariant";
178
+ import * as LiveObject2 from "@dxos/live-object";
179
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/Relation.ts";
180
+ var make2 = LiveObject2.live;
181
+ var isRelation = (value) => {
182
+ if (typeof value !== "object" || value === null) {
183
+ return false;
184
+ }
185
+ if (EchoSchema3.ATTR_RELATION_SOURCE in value || EchoSchema3.ATTR_RELATION_TARGET in value) {
186
+ return true;
187
+ }
188
+ const kind = value[EchoSchema3.EntityKindPropertyId];
189
+ return kind === EchoSchema3.EntityKind.Relation;
190
+ };
191
+ var getSource = (relation) => {
192
+ invariant3(isRelation(relation), void 0, {
193
+ F: __dxlog_file3,
194
+ L: 30,
195
+ S: void 0,
196
+ A: [
197
+ "isRelation(relation)",
198
+ ""
199
+ ]
200
+ });
201
+ const obj = relation[EchoSchema3.RelationSourceId];
202
+ invariant3(obj !== void 0, `Invalid source: ${relation.id}`, {
203
+ F: __dxlog_file3,
204
+ L: 32,
205
+ S: void 0,
206
+ A: [
207
+ "obj !== undefined",
208
+ "`Invalid source: ${relation.id}`"
209
+ ]
210
+ });
211
+ return obj;
212
+ };
213
+ var getTarget = (relation) => {
214
+ invariant3(isRelation(relation), void 0, {
215
+ F: __dxlog_file3,
216
+ L: 41,
217
+ S: void 0,
218
+ A: [
219
+ "isRelation(relation)",
220
+ ""
221
+ ]
222
+ });
223
+ const obj = relation[EchoSchema3.RelationTargetId];
224
+ invariant3(obj !== void 0, `Invalid target: ${relation.id}`, {
225
+ F: __dxlog_file3,
226
+ L: 43,
227
+ S: void 0,
228
+ A: [
229
+ "obj !== undefined",
230
+ "`Invalid target: ${relation.id}`"
231
+ ]
232
+ });
233
+ return obj;
234
+ };
235
+
236
+ // packages/core/echo/echo/src/Ref.ts
237
+ var Ref_exports = {};
238
+ __export(Ref_exports, {
239
+ fromDXN: () => fromDXN,
240
+ isRef: () => isRef,
241
+ make: () => make3
242
+ });
243
+ import * as EchoSchema4 from "@dxos/echo-schema";
244
+ var make3 = EchoSchema4.Ref.make;
245
+ var isRef = EchoSchema4.Ref.isRef;
246
+ var fromDXN = EchoSchema4.Ref.fromDXN;
247
+
248
+ // packages/core/echo/echo/src/index.ts
249
+ import { Filter, Query } from "@dxos/echo-schema";
42
250
  export {
43
- DXN,
44
- Database_exports as Database,
45
- Queue_exports as Queue,
46
- Space_exports as Space,
251
+ Filter,
252
+ Obj_exports as Obj,
253
+ Query,
254
+ Ref_exports as Ref,
255
+ Relation_exports as Relation,
47
256
  Type_exports as Type
48
257
  };
49
258
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/Database.ts", "../../../src/Queue.ts", "../../../src/Space.ts", "../../../src/Type.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { DXN } from '@dxos/keys';\n\nexport { DXN };\n\nexport * as Database from './Database';\nexport * as Queue from './Queue';\nexport * as Space from './Space';\nexport * as Type from './Type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Database API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport declare namespace Database {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Queue API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport declare namespace Queue {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Space API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport declare namespace Space {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport {\n type BaseSchema,\n type EchoSchema,\n type Expando as Expando$,\n type ImmutableSchema,\n type JsonSchemaType,\n type TypeMeta,\n EchoObject,\n EntityKind,\n ObjectId,\n Ref as Ref$,\n getTypeAnnotation,\n getSchema,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n isInstanceOf,\n} from '@dxos/echo-schema';\nimport { create as create$, makeRef } from '@dxos/live-object';\n\n// NOTES:\n// - New Echo package and namespaces allow for incremental migration; vastly simplifies imports.\n// - Split into separate ECHO namespaces: Database, Space, Type, Query, Queue.\n// - Example; import { Database, Type, Query, Queue } from '@dxos/echo';\n// - Use `declare namespace` for types (no code is generated). See Effect pattern, where Schema is a namespace, interface, and function.\n// - Test with @dxos/schema/testing types.\n// - Define user (Composer) types in namespace (e.g., of plugin) and drop Type suffix; remove all deprecated Braneframe types.\n\nexport type { TypeMeta as Meta, JsonSchemaType as JsonSchema };\nexport {\n EntityKind as Kind,\n ObjectId,\n getTypeAnnotation as getMeta,\n getSchema,\n getSchemaDXN as getDXN,\n getSchemaTypename as getTypename,\n getSchemaVersion as getVersion,\n isInstanceOf as instanceOf,\n};\n\n/**\n * Type API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport declare namespace Type {\n /**\n * A schema that can be extended with arbitrary properties.\n */\n export type Expando = Expando$;\n\n export type Abstract<T = any> = BaseSchema<T>;\n export type ImmutableType<T> = ImmutableSchema<T>;\n export type MutableType<T> = EchoSchema<T>;\n}\n\n//\n// Constructors\n//\n\nexport const ref = makeRef;\nexport const create = create$;\n\n//\n// Combinators\n//\n\n/**\n * Defines an ECHO type.\n *\n * @example\n * ```ts\n * const Org = S.Struct({\n * name: S.String,\n * }).pipe(Type.def({ typename: 'example.com/type/Org', version: '1.0.0' }));\n * ```\n */\nexport const def = (meta: TypeMeta) => EchoObject(meta);\n\n/**\n * Defines a reference to an ECHO object.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Contact = S.Struct({\n * name: S.String,\n * employer: Type.Ref(Org),\n * }).pipe(Type.def({ typename: 'example.com/type/Contact', version: '1.0.0' }));\n * ```\n */\nexport const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);\n"],
5
- "mappings": ";;;;;;;;AAIA,SAASA,WAAW;;;ACJpB;;;ACAA;;;ACAA;;;ACAA;;;;;;;;;;;;;;;AAMA,SAOEC,YACAC,YACAC,UACAC,OAAOC,MACPC,mBACAC,WACAC,cACAC,mBACAC,kBACAC,oBACK;AACP,SAASC,UAAUC,SAASC,eAAe;AA2CpC,IAAMC,MAAMC;AACZ,IAAMC,SAASC;AAgBf,IAAMC,MAAM,CAACC,SAAmBC,WAAWD,IAAAA;AAc3C,IAAME,MAAM,CAAuCC,SAAYC,KAA4BD,IAAAA;",
6
- "names": ["DXN", "EchoObject", "EntityKind", "ObjectId", "Ref", "Ref$", "getTypeAnnotation", "getSchema", "getSchemaDXN", "getSchemaTypename", "getSchemaVersion", "isInstanceOf", "create", "create$", "makeRef", "ref", "makeRef", "create", "create$", "def", "meta", "EchoObject", "Ref", "self", "Ref$"]
3
+ "sources": ["../../../src/Type.ts", "../../../src/Obj.ts", "../../../src/Relation.ts", "../../../src/Ref.ts", "../../../src/index.ts"],
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": ";;;;;;;;AAAA;;;;;;;;;aAAAA;EAAA;;;;;;mBAAAC;EAAA;;AAOA,YAAYC,gBAAgB;AAC5B,SAASC,iBAAiB;AAqG1B,SAAuBC,kBAAY;AASnC,SAASC,SAASC,UAAUC,WAAW;AAEvC;EAEEC;EACkBC;EAClBC;EACAC;OACK;;AA3GA,IAAMC,MAAiBC;AAKvB,IAAM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SAASI,EAAE,IAAE;;;;;;;;;AAC7D,SAAOH;AACT;AAMO,IAAMI,YAAY,CAAgBL,aAAAA;AACvCZ,EAAAA,WAAUG,WAAWS,QAAAA,GAAAA,QAAAA;;;;;;;;;AACrB,QAAMC,MAAMD,SAAoBM,4BAAgB;AAChDlB,EAAAA,WAAUa,QAAQE,QAAW,mBAAmBH,SAASI,EAAE,IAAE;;;;;;;;;AAC7D,SAAOH;AACT;;;AC5CA;;;;cAAAM;;AAIA,YAAYC,iBAAgB;AAMrB,IAAMC,QAAkBC,gBAAID;AAE5B,IAAME,QAAqDD,gBAAIC;AAG/D,IAAMC,UAAqBF,gBAAIE;;;ACLtC,SAASC,QAAQC,aAAa;",
6
+ "names": ["Ref", "isMutable", "EchoSchema", "invariant", "Kind", "SpaceId", "ObjectId", "DXN", "Expando", "JsonSchema", "toJsonSchema", "Format", "Obj", "EchoObject", "Relation", "EchoRelation", "getDXN", "schema", "getSchemaDXN", "getTypename", "typename", "getSchemaTypename", "startsWith", "getVersion", "version", "getSchemaVersion", "match", "getMeta", "getTypeAnnotation", "getDXN", "getMeta", "getSchema", "getSchemaDXN", "getTypename", "isDeleted", "Schema", "EchoSchema", "assertArgument", "invariant", "LiveObject", "make", "live", "isObject", "obj", "isLiveObject", "instanceOf", "args", "length", "isInstanceOf", "isSchema", "dxn", "type", "getType", "schema", "asTypeDXN", "meta", "deleted", "make", "EchoSchema", "invariant", "LiveObject", "live", "isRelation", "value", "ATTR_RELATION_SOURCE", "ATTR_RELATION_TARGET", "kind", "EntityKindPropertyId", "EntityKind", "Relation", "getSource", "relation", "obj", "RelationSourceId", "undefined", "id", "getTarget", "RelationTargetId", "make", "EchoSchema", "make", "Ref", "isRef", "fromDXN", "Filter", "Query"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/echo/echo/src/Database.ts":{"bytes":689,"imports":[],"format":"esm"},"packages/core/echo/echo/src/Queue.ts":{"bytes":671,"imports":[],"format":"esm"},"packages/core/echo/echo/src/Space.ts":{"bytes":671,"imports":[],"format":"esm"},"packages/core/echo/echo/src/Type.ts":{"bytes":6001,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":1157,"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/echo/echo/src/Database.ts","kind":"import-statement","original":"./Database"},{"path":"packages/core/echo/echo/src/Queue.ts","kind":"import-statement","original":"./Queue"},{"path":"packages/core/echo/echo/src/Space.ts","kind":"import-statement","original":"./Space"},{"path":"packages/core/echo/echo/src/Type.ts","kind":"import-statement","original":"./Type"}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4021},"packages/core/echo/echo/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"exports":["DXN","Database","Queue","Space","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/index.ts":{"bytesInOutput":34},"packages/core/echo/echo/src/Database.ts":{"bytesInOutput":27},"packages/core/echo/echo/src/Queue.ts":{"bytesInOutput":24},"packages/core/echo/echo/src/Space.ts":{"bytesInOutput":24},"packages/core/echo/echo/src/Type.ts":{"bytesInOutput":744}},"bytes":1480}}}
1
+ {"inputs":{"packages/core/echo/echo/src/Type.ts":{"bytes":8839,"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/Obj.ts":{"bytes":8124,"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}],"format":"esm"},"packages/core/echo/echo/src/Relation.ts":{"bytes":5369,"imports":[{"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}],"format":"esm"},"packages/core/echo/echo/src/Ref.ts":{"bytes":1595,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":1162,"imports":[{"path":"packages/core/echo/echo/src/Type.ts","kind":"import-statement","original":"./Type"},{"path":"packages/core/echo/echo/src/Obj.ts","kind":"import-statement","original":"./Obj"},{"path":"packages/core/echo/echo/src/Relation.ts","kind":"import-statement","original":"./Relation"},{"path":"packages/core/echo/echo/src/Ref.ts","kind":"import-statement","original":"./Ref"},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12154},"packages/core/echo/echo/dist/lib/node-esm/index.mjs":{"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},{"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/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/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["Filter","Obj","Query","Ref","Relation","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/Type.ts":{"bytesInOutput":1927},"packages/core/echo/echo/src/index.ts":{"bytesInOutput":51},"packages/core/echo/echo/src/Obj.ts":{"bytesInOutput":2226},"packages/core/echo/echo/src/Relation.ts":{"bytesInOutput":1700},"packages/core/echo/echo/src/Ref.ts":{"bytesInOutput":276}},"bytes":6807}}}
@@ -0,0 +1,39 @@
1
+ import { Schema } from 'effect';
2
+ import * as EchoSchema from '@dxos/echo-schema';
3
+ import type { DXN } from '@dxos/keys';
4
+ import * as LiveObject from '@dxos/live-object';
5
+ import type * as Type from './Type';
6
+ export type Any = EchoSchema.AnyEchoObject;
7
+ export declare const make: {
8
+ <T extends EchoSchema.BaseObject>(obj: T): LiveObject.Live<T>;
9
+ <T extends EchoSchema.BaseObject>(schema: Schema.Schema<T, any, never>, obj: NoInfer<EchoSchema.ExcludeId<T>>, meta?: EchoSchema.ObjectMeta): LiveObject.Live<T>;
10
+ };
11
+ export declare const isObject: (obj: unknown) => obj is Any;
12
+ /**
13
+ * Check that object or relation is an instance of a schema.
14
+ * @example
15
+ * ```ts
16
+ * const person = Obj.make(Person, { name: 'John' });
17
+ * const isPerson = Obj.instanceOf(Person);
18
+ * isPerson(person); // true
19
+ * ```
20
+ */
21
+ export declare const instanceOf: {
22
+ <S extends Type.Relation.Any | Type.Obj.Any>(schema: S): (value: unknown) => value is S;
23
+ <S extends Type.Relation.Any | Type.Obj.Any>(schema: S, value: unknown): value is S;
24
+ };
25
+ export declare const getSchema: (obj: unknown | undefined) => Schema.Schema.AnyNoContext | undefined;
26
+ export declare const getDXN: (obj: Any) => DXN;
27
+ /**
28
+ * @returns The DXN of the object's type.
29
+ * @example dxn:example.com/type/Contact:1.0.0
30
+ */
31
+ export declare const getSchemaDXN: (obj: Any) => DXN;
32
+ /**
33
+ * @returns The typename of the object's type.
34
+ * @example `example.com/type/Contact`
35
+ */
36
+ export declare const getTypename: (obj: Any) => string | undefined;
37
+ export declare const getMeta: (obj: Any) => EchoSchema.ObjectMeta;
38
+ export declare const isDeleted: (obj: Any) => boolean;
39
+ //# sourceMappingURL=Obj.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Obj.d.ts","sourceRoot":"","sources":["../../../src/Obj.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,KAAK,IAAI,MAAM,QAAQ,CAAC;AAEpC,MAAM,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC;AAE3C,eAAO,MAAM,IAAI;;;CAAkB,CAAC;AAGpC,eAAO,MAAM,QAAQ,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,GAE9C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,CAAC,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;IACxF,CAAC,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC;CAO7E,CAAC;AAEV,eAAO,MAAM,SAAS,sEAAuB,CAAC;AAE9C,eAAO,MAAM,MAAM,GAAI,KAAK,GAAG,KAAG,GAKjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,GAAG,KAAG,GAIvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,GAAG,KAAG,MAAM,GAAG,SAQ/C,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,KAAK,GAAG,KAAG,UAAU,CAAC,UAI7C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,OAIpC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import * as EchoSchema from '@dxos/echo-schema';
2
+ import type * as Obj from './Obj';
3
+ export type Any = EchoSchema.Ref<Obj.Any>;
4
+ export declare const make: <T extends EchoSchema.WithId>(object: T) => EchoSchema.Ref<T>;
5
+ export declare const isRef: (value: unknown) => value is Any;
6
+ export declare const fromDXN: (dxn: import("@dxos/keys").DXN) => EchoSchema.Ref<any>;
7
+ /**
8
+ * Extract reference target.
9
+ */
10
+ export type Target<R extends Any> = R extends EchoSchema.Ref<infer T> ? T : never;
11
+ //# sourceMappingURL=Ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../../../src/Ref.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,KAAK,GAAG,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE1C,eAAO,MAAM,IAAI,+DAAsB,CAAC;AAExC,eAAO,MAAM,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,GAA0B,CAAC;AAG5E,eAAO,MAAM,OAAO,wDAAyB,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
@@ -0,0 +1,19 @@
1
+ import * as EchoSchema from '@dxos/echo-schema';
2
+ import * as LiveObject from '@dxos/live-object';
3
+ export type Any = EchoSchema.AnyEchoObject & EchoSchema.RelationSourceTargetRefs;
4
+ export declare const make: {
5
+ <T extends EchoSchema.BaseObject>(obj: T): LiveObject.Live<T>;
6
+ <T extends EchoSchema.BaseObject>(schema: import("effect/Schema").Schema<T, any, never>, obj: NoInfer<EchoSchema.ExcludeId<T>>, meta?: EchoSchema.ObjectMeta): LiveObject.Live<T>;
7
+ };
8
+ export declare const isRelation: (value: unknown) => value is Any;
9
+ /**
10
+ * @returns Relation source.
11
+ * @throws If the object is not a relation.
12
+ */
13
+ export declare const getSource: <T extends Any>(relation: T) => EchoSchema.RelationSource<T>;
14
+ /**
15
+ * @returns Relation target.
16
+ * @throws If the object is not a relation.
17
+ */
18
+ export declare const getTarget: <T extends Any>(relation: T) => EchoSchema.RelationTarget<T>;
19
+ //# sourceMappingURL=Relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Relation.d.ts","sourceRoot":"","sources":["../../../src/Relation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,wBAAwB,CAAC;AAEjF,eAAO,MAAM,IAAI;;;CAAkB,CAAC;AAEpC,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,GAUpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,GAAG,EAAE,UAAU,CAAC,KAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAKjF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,GAAG,EAAE,UAAU,CAAC,KAAG,UAAU,CAAC,cAAc,CAAC,CAAC,CAKjF,CAAC"}
@@ -1,49 +1,87 @@
1
1
  import { type Schema } from 'effect';
2
- import { type BaseSchema, type EchoSchema, type Expando as Expando$, type ImmutableSchema, type JsonSchemaType, type TypeMeta, EntityKind, ObjectId, Ref as Ref$, getTypeAnnotation, getSchema, getSchemaDXN, getSchemaTypename, getSchemaVersion, isInstanceOf } from '@dxos/echo-schema';
3
- export type { TypeMeta as Meta, JsonSchemaType as JsonSchema };
4
- export { EntityKind as Kind, ObjectId, getTypeAnnotation as getMeta, getSchema, getSchemaDXN as getDXN, getSchemaTypename as getTypename, getSchemaVersion as getVersion, isInstanceOf as instanceOf, };
2
+ import type { EncodedReference } from '@dxos/echo-protocol';
3
+ import * as EchoSchema from '@dxos/echo-schema';
4
+ import type * as Keys from '@dxos/keys';
5
5
  /**
6
- * Type API.
7
- *
8
- * @category api namespace
9
- * @since 0.9.0
6
+ * ECHO schema.
10
7
  */
11
- export declare namespace Type {
8
+ export type Schema = EchoSchema.EchoSchema;
9
+ /**
10
+ * EchoObject schema.
11
+ */
12
+ export declare const Obj: (meta: EchoSchema.TypeMeta) => <Self extends Schema.Schema.Any>(self: Self) => EchoSchema.EchoTypeSchema<Self>;
13
+ /**
14
+ * EchoRelation schema.
15
+ */
16
+ export declare const Relation: <Source extends Schema.Schema.AnyNoContext, Target extends Schema.Schema.AnyNoContext>(options: {
17
+ typename: string;
18
+ version: string;
19
+ source: Source;
20
+ target: Target;
21
+ }) => <Self extends Schema.Schema.Any>(self: Self) => EchoSchema.EchoTypeSchema<Self, EchoSchema.RelationSourceTargetRefs<Schema.Schema.Type<Source>, Schema.Schema.Type<Target>>>;
22
+ /**
23
+ * Ref schema.
24
+ */
25
+ export declare const Ref: <S extends Obj.Any>(schema: S) => EchoSchema.Ref$<Schema.Schema.Type<S>>;
26
+ export declare namespace Obj {
27
+ /**
28
+ * Type that represents an arbitrary schema type of an object.
29
+ * NOTE: This is not an instance type.
30
+ */
31
+ type Any = Schema.Schema.AnyNoContext;
32
+ }
33
+ export declare namespace Relation {
34
+ /**
35
+ * Type that represents an arbitrary schema type of a relation.
36
+ * NOTE: This is not an instance type.
37
+ */
38
+ type Any = Schema.Schema.AnyNoContext;
39
+ /**
40
+ * Get relation target type.
41
+ */
42
+ type Target<A> = A extends EchoSchema.RelationSourceTargetRefs<infer T, infer _S> ? T : never;
43
+ /**
44
+ * Get relation source type.
45
+ */
46
+ type Source<A> = A extends EchoSchema.RelationSourceTargetRefs<infer _T, infer S> ? S : never;
47
+ }
48
+ export declare namespace Ref {
12
49
  /**
13
- * A schema that can be extended with arbitrary properties.
50
+ * Type that represents an arbitrary schema type of a reference.
51
+ * NOTE: This is not an instance type.
14
52
  */
15
- type Expando = Expando$;
16
- type Abstract<T = any> = BaseSchema<T>;
17
- type ImmutableType<T> = ImmutableSchema<T>;
18
- type MutableType<T> = EchoSchema<T>;
53
+ type Any = Schema.Schema<EchoSchema.Ref<any>, EncodedReference>;
19
54
  }
20
- export declare const ref: <T extends import("@dxos/echo-schema").BaseObject>(obj: T) => Ref$<T>;
21
- export declare const create: {
22
- <T extends import("@dxos/echo-schema").BaseObject>(obj: T): import("@dxos/live-object").ReactiveObject<T>;
23
- <T extends import("@dxos/echo-schema").BaseObject>(schema: Schema.Schema<T, any, never>, obj: NoInfer<import("@dxos/echo-schema").ExcludeId<T>>, meta?: import("@dxos/echo-schema").ObjectMeta): import("@dxos/live-object").ReactiveObject<T>;
24
- };
25
- /**
26
- * Defines an ECHO type.
27
- *
28
- * @example
29
- * ```ts
30
- * const Org = S.Struct({
31
- * name: S.String,
32
- * }).pipe(Type.def({ typename: 'example.com/type/Org', version: '1.0.0' }));
33
- * ```
34
- */
35
- export declare const def: (meta: TypeMeta) => <Self extends Schema.Schema.Any>(self: Self) => import("@dxos/echo-schema").EchoObjectSchema<Self>;
36
- /**
37
- * Defines a reference to an ECHO object.
38
- *
39
- * @example
40
- * ```ts
41
- * import { Type } from '@dxos/echo';
42
- * const Contact = S.Struct({
43
- * name: S.String,
44
- * employer: Type.Ref(Org),
45
- * }).pipe(Type.def({ typename: 'example.com/type/Contact', version: '1.0.0' }));
46
- * ```
47
- */
48
- export declare const Ref: <S extends Schema.Schema.AnyNoContext>(self: S) => import("@dxos/echo-schema").Ref$<Schema.Schema.Type<S>>;
55
+ /**
56
+ * Gets the full DXN of the schema.
57
+ * Will include the version if it's a `type` DXN.
58
+ * @example "dxn:example.com/type/Person:0.1.0"
59
+ * @example "dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX"
60
+ */
61
+ export declare const getDXN: (schema: Obj.Any | Relation.Any) => Keys.DXN | undefined;
62
+ /**
63
+ * @param schema - Schema to get the typename from.
64
+ * @returns The typename of the schema. Example: `example.com/type/Person`.
65
+ */
66
+ export declare const getTypename: (schema: Obj.Any | Relation.Any) => string;
67
+ /**
68
+ * Gets the version of the schema.
69
+ * @example 0.1.0
70
+ */
71
+ export declare const getVersion: (schema: Obj.Any | Relation.Any) => string;
72
+ /**
73
+ * ECHO type metadata.
74
+ */
75
+ export type Meta = EchoSchema.TypeAnnotation;
76
+ /**
77
+ * Gets the meta data of the schema.
78
+ */
79
+ export declare const getMeta: (schema: Obj.Any | Relation.Any) => Meta | undefined;
80
+ export { EntityKind as Kind } from '@dxos/echo-schema';
81
+ /**
82
+ * @returns True if the schema is mutable.
83
+ */
84
+ export declare const isMutable: (schema: Obj.Any | Relation.Any) => boolean;
85
+ export { SpaceId, ObjectId, DXN } from '@dxos/keys';
86
+ export { Expando, JsonSchemaType as JsonSchema, toJsonSchema, Format, } from '@dxos/echo-schema';
49
87
  //# sourceMappingURL=Type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Type.d.ts","sourceRoot":"","sources":["../../../src/Type.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,QAAQ,EAEb,UAAU,EACV,QAAQ,EACR,GAAG,IAAI,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AGG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,KAAG,MAI5D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,KAAG,MAI3D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,UAAU,CAAC,cAAc,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,KAAG,IAAI,GAAG,SAE/D,CAAC;AAEF,OAAO,EAAE,UAAU,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,KAAG,OAE1D,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAEL,OAAO,EACP,cAAc,IAAI,UAAU,EAC5B,YAAY,EACZ,MAAM,GACP,MAAM,mBAAmB,CAAC"}
@@ -5,4 +5,4 @@
5
5
  * @since 0.9.0
6
6
  */
7
7
  export declare namespace Database { }
8
- //# sourceMappingURL=Database.d.ts.map
8
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../../src/experimental/database.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,QAAQ,CAAC,GAAE"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/experimental/index.ts"],"names":[],"mappings":""}
@@ -5,4 +5,4 @@
5
5
  * @since 0.9.0
6
6
  */
7
7
  export declare namespace Queue { }
8
- //# sourceMappingURL=Queue.d.ts.map
8
+ //# sourceMappingURL=queue.d.ts.map