@dxos/echo 0.8.1 → 0.8.2-main.2f9c567

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 (35) hide show
  1. package/dist/lib/browser/index.mjs +41 -41
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +39 -35
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +41 -41
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/{Database.d.ts → api/database.d.ts} +1 -1
  11. package/dist/types/src/api/database.d.ts.map +1 -0
  12. package/dist/types/src/api/index.d.ts +4 -0
  13. package/dist/types/src/api/index.d.ts.map +1 -0
  14. package/dist/types/src/{Queue.d.ts → api/queue.d.ts} +1 -1
  15. package/dist/types/src/api/queue.d.ts.map +1 -0
  16. package/dist/types/src/{Space.d.ts → api/space.d.ts} +1 -1
  17. package/dist/types/src/api/space.d.ts.map +1 -0
  18. package/dist/types/src/api/type.d.ts +80 -0
  19. package/dist/types/src/api/type.d.ts.map +1 -0
  20. package/dist/types/src/index.d.ts +1 -6
  21. package/dist/types/src/index.d.ts.map +1 -1
  22. package/package.json +14 -14
  23. package/src/{Database.ts → api/database.ts} +1 -1
  24. package/src/api/index.ts +12 -0
  25. package/src/{Queue.ts → api/queue.ts} +1 -1
  26. package/src/api/type.ts +143 -0
  27. package/src/api.test.ts +46 -34
  28. package/src/index.ts +1 -8
  29. package/dist/types/src/Database.d.ts.map +0 -1
  30. package/dist/types/src/Queue.d.ts.map +0 -1
  31. package/dist/types/src/Space.d.ts.map +0 -1
  32. package/dist/types/src/Type.d.ts +0 -49
  33. package/dist/types/src/Type.d.ts.map +0 -1
  34. package/src/Type.ts +0 -99
  35. /package/src/{Space.ts → api/space.ts} +0 -0
@@ -1,49 +1,49 @@
1
1
  import "@dxos/node-std/globals";
2
- var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
4
- for (var name in all)
5
- __defProp(target, name, { get: all[name], enumerable: true });
6
- };
7
2
 
8
- // packages/core/echo/echo/src/index.ts
3
+ // packages/core/echo/echo/src/api/index.ts
4
+ import { Format } from "@dxos/echo-schema";
9
5
  import { DXN } from "@dxos/keys";
10
6
 
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
- // packages/core/echo/echo/src/Type.ts
21
- var Type_exports = {};
22
- __export(Type_exports, {
23
- Kind: () => EntityKind,
24
- 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
35
- });
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);
7
+ // packages/core/echo/echo/src/api/type.ts
8
+ import { EchoObject, EntityKind, Expando as Expando$, ObjectId as ObjectId$, Ref as Ref$, SpaceIdSchema as SpaceIdSchema$, getTypeAnnotation, getSchema as getSchema$, getSchemaDXN, getSchemaTypename, getSchemaVersion, isInstanceOf, toJsonSchema as toJsonSchema$ } from "@dxos/echo-schema";
9
+ import { invariant } from "@dxos/invariant";
10
+ import { SpaceId as SpaceId$ } from "@dxos/keys";
11
+ import { live as live$ } from "@dxos/live-object";
12
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/api/type.ts";
13
+ var Type;
14
+ (function(Type2) {
15
+ Type2.SpaceIdSchema = SpaceIdSchema$;
16
+ Type2.SpaceId = SpaceId$;
17
+ Type2.ObjectId = ObjectId$;
18
+ Type2.Kind = EntityKind;
19
+ Type2.Expando = Expando$;
20
+ Type2.create = live$;
21
+ Type2.def = (meta) => EchoObject(meta);
22
+ Type2.Ref = (self) => Ref$(self);
23
+ Type2.ref = Ref$.make;
24
+ Type2.getMeta = getTypeAnnotation;
25
+ Type2.getSchema = getSchema$;
26
+ Type2.instanceOf = isInstanceOf;
27
+ Type2.getDXN = getSchemaDXN;
28
+ Type2.getTypename = (schema) => {
29
+ const typename = getSchemaTypename(schema);
30
+ invariant(typename, "Invalid object", {
31
+ F: __dxlog_file,
32
+ L: 138,
33
+ S: this,
34
+ A: [
35
+ "typename",
36
+ "'Invalid object'"
37
+ ]
38
+ });
39
+ return typename;
40
+ };
41
+ Type2.getVersion = getSchemaVersion;
42
+ Type2.toJsonSchema = toJsonSchema$;
43
+ })(Type || (Type = {}));
42
44
  export {
43
45
  DXN,
44
- Database_exports as Database,
45
- Queue_exports as Queue,
46
- Space_exports as Space,
47
- Type_exports as Type
46
+ Format,
47
+ Type
48
48
  };
49
49
  //# 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/api/index.ts", "../../../src/api/type.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\n// export type { Database } from './database';\n// export type { Queue } from './queue';\n// export type { Space } from './space';\n\nexport { Type } from './type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';\nimport {\n type BaseEchoObject,\n type BaseObject,\n type BaseSchema,\n type EchoSchema,\n EchoObject,\n EntityKind,\n Expando as Expando$,\n type ImmutableSchema,\n type JsonSchemaType,\n ObjectId as ObjectId$,\n Ref as Ref$,\n SpaceIdSchema as SpaceIdSchema$,\n type StoredSchema,\n type TypeMeta,\n getTypeAnnotation,\n getSchema as getSchema$,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n isInstanceOf,\n toJsonSchema as toJsonSchema$,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId as SpaceId$ } from '@dxos/keys';\nimport { live as live$ } from '@dxos/live-object';\n\n// TODO(burdon): Type vs. Relation vs. Object.\n\n/**\n * Type System API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport namespace Type {\n //\n // Keys\n //\n\n export const SpaceIdSchema = SpaceIdSchema$; // TODO(burdon): Reconcile with SpaceId as with ObjectId.\n export const SpaceId = SpaceId$;\n export type SpaceId = SpaceId$;\n\n export const ObjectId = ObjectId$;\n export type ObjectId = ObjectId$;\n\n //\n // Objects\n //\n\n export const Kind = EntityKind;\n export type AnyObject = BaseEchoObject;\n export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;\n\n //\n // Schema\n //\n\n export type JsonSchema = JsonSchemaType;\n\n /**\n * A schema that can be extended with arbitrary properties.\n */\n export const Expando = Expando$;\n export type Expando = Expando$;\n\n // TODO(burdon): Review/remove.\n export type Abstract<T = any> = BaseSchema<T>;\n export type ImmutableType<T> = ImmutableSchema<T>;\n export type MutableType<T> = EchoSchema<T>;\n export type StoredType = StoredSchema;\n\n export const create = live$;\n\n /**\n * Defines an ECHO type.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Organization = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.def({\n * typename: 'example.com/type/Organization',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const def = (meta: TypeMeta) => EchoObject(meta);\n\n //\n // Refs\n //\n\n /**\n * Defines a reference to an ECHO object.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Person = Schema.Struct({\n * name: Schema.String,\n * organization: Type.Ref(Organization),\n * }).pipe(Type.def({\n * typename: 'example.com/type/Person',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);\n\n export const ref = Ref$.make;\n\n //\n // Object utils\n //\n\n export const getMeta = getTypeAnnotation;\n export const getSchema = getSchema$;\n export const instanceOf = isInstanceOf;\n\n //\n // Type utils\n //\n\n // TODO(burdon): Reconcile getDXN and getTypename.\n export const getDXN = getSchemaDXN;\n export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {\n const typename = getSchemaTypename(schema);\n invariant(typename, 'Invalid object');\n return typename;\n };\n export const getVersion = getSchemaVersion;\n export const toJsonSchema = toJsonSchema$;\n}\n"],
5
+ "mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,WAAW;;;ACEpB,SAKEC,YACAC,YACAC,WAAWC,UAGXC,YAAYC,WACZC,OAAOC,MACPC,iBAAiBC,gBAGjBC,mBACAC,aAAaC,YACbC,cACAC,mBACAC,kBACAC,cACAC,gBAAgBC,qBACX;AACP,SAASC,iBAAiB;AAC1B,SAASC,WAAWC,gBAAgB;AACpC,SAASC,QAAQC,aAAa;;;UAUbC,OAAAA;QAKFhB,gBAAgBC;QAChBW,UAAUC;QAGVjB,WAAWC;QAOXoB,OAAOxB;AAYnB,EAAAuB,MACYtB,UAAUC;QASVuB,SAASH;AAerB,EAAAC,MACYG,MAAM,CAACC,SAAmB5B,WAAW4B,IAAAA;AAoBjD,EAAAJ,MACYlB,MAAM,CAAuCuB,SAAYtB,KAA4BsB,IAAAA;QAErFC,MAAMvB,KAAKwB;QAMXC,UAAUtB;QACVC,YAAYC;QACZqB,aAAajB;QAObkB,SAASrB;QACTsB,cAAc,CAACC,WAAAA;AAC1B,UAAMC,WAAWvB,kBAAkBsB,MAAAA;AACnCjB,cAAUkB,UAAU,kBAAA;;;;;;;;;AACpB,WAAOA;EACT;QACaC,aAAavB;QACbE,eAAeC;AAC9B,GApGiBM,SAAAA,OAAAA,CAAAA,EAAAA;",
6
+ "names": ["Format", "DXN", "EchoObject", "EntityKind", "Expando", "Expando$", "ObjectId", "ObjectId$", "Ref", "Ref$", "SpaceIdSchema", "SpaceIdSchema$", "getTypeAnnotation", "getSchema", "getSchema$", "getSchemaDXN", "getSchemaTypename", "getSchemaVersion", "isInstanceOf", "toJsonSchema", "toJsonSchema$", "invariant", "SpaceId", "SpaceId$", "live", "live$", "Type", "Kind", "create", "def", "meta", "self", "ref", "make", "getMeta", "instanceOf", "getDXN", "getTypename", "schema", "typename", "getVersion"]
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/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4021},"packages/core/echo/echo/dist/lib/browser/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":1421}}}
1
+ {"inputs":{"packages/core/echo/echo/src/api/type.ts":{"bytes":9128,"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}],"format":"esm"},"packages/core/echo/echo/src/api/index.ts":{"bytes":1177,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/echo/echo/src/api/type.ts","kind":"import-statement","original":"./type"}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":482,"imports":[{"path":"packages/core/echo/echo/src/api/index.ts","kind":"import-statement","original":"./api"}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5033},"packages/core/echo/echo/dist/lib/browser/index.mjs":{"imports":[{"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/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"exports":["DXN","Format","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/api/index.ts":{"bytesInOutput":78},"packages/core/echo/echo/src/api/type.ts":{"bytesInOutput":1352},"packages/core/echo/echo/src/index.ts":{"bytesInOutput":0}},"bytes":1623}}}
@@ -19,48 +19,52 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
21
  DXN: () => import_keys.DXN,
22
- Database: () => Database_exports,
23
- Queue: () => Queue_exports,
24
- Space: () => Space_exports,
25
- Type: () => Type_exports
22
+ Format: () => import_echo_schema.Format,
23
+ Type: () => Type
26
24
  });
27
25
  module.exports = __toCommonJS(node_exports);
28
- var import_keys = require("@dxos/keys");
29
26
  var import_echo_schema = require("@dxos/echo-schema");
27
+ var import_keys = require("@dxos/keys");
28
+ var import_echo_schema2 = require("@dxos/echo-schema");
29
+ var import_invariant = require("@dxos/invariant");
30
+ var import_keys2 = require("@dxos/keys");
30
31
  var import_live_object = require("@dxos/live-object");
31
- var __defProp2 = Object.defineProperty;
32
- var __export2 = (target, all) => {
33
- for (var name in all)
34
- __defProp2(target, name, { get: all[name], enumerable: true });
35
- };
36
- var Database_exports = {};
37
- var Queue_exports = {};
38
- var Space_exports = {};
39
- var Type_exports = {};
40
- __export2(Type_exports, {
41
- Kind: () => import_echo_schema.EntityKind,
42
- ObjectId: () => import_echo_schema.ObjectId,
43
- Ref: () => Ref,
44
- create: () => create,
45
- def: () => def,
46
- getDXN: () => import_echo_schema.getSchemaDXN,
47
- getMeta: () => import_echo_schema.getTypeAnnotation,
48
- getSchema: () => import_echo_schema.getSchema,
49
- getTypename: () => import_echo_schema.getSchemaTypename,
50
- getVersion: () => import_echo_schema.getSchemaVersion,
51
- instanceOf: () => import_echo_schema.isInstanceOf,
52
- ref: () => ref
53
- });
54
- var ref = import_live_object.makeRef;
55
- var create = import_live_object.create;
56
- var def = (meta) => (0, import_echo_schema.EchoObject)(meta);
57
- var Ref = (self) => (0, import_echo_schema.Ref)(self);
32
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/api/type.ts";
33
+ var Type;
34
+ (function(Type2) {
35
+ Type2.SpaceIdSchema = import_echo_schema2.SpaceIdSchema;
36
+ Type2.SpaceId = import_keys2.SpaceId;
37
+ Type2.ObjectId = import_echo_schema2.ObjectId;
38
+ Type2.Kind = import_echo_schema2.EntityKind;
39
+ Type2.Expando = import_echo_schema2.Expando;
40
+ Type2.create = import_live_object.live;
41
+ Type2.def = (meta) => (0, import_echo_schema2.EchoObject)(meta);
42
+ Type2.Ref = (self) => (0, import_echo_schema2.Ref)(self);
43
+ Type2.ref = import_echo_schema2.Ref.make;
44
+ Type2.getMeta = import_echo_schema2.getTypeAnnotation;
45
+ Type2.getSchema = import_echo_schema2.getSchema;
46
+ Type2.instanceOf = import_echo_schema2.isInstanceOf;
47
+ Type2.getDXN = import_echo_schema2.getSchemaDXN;
48
+ Type2.getTypename = (schema) => {
49
+ const typename = (0, import_echo_schema2.getSchemaTypename)(schema);
50
+ (0, import_invariant.invariant)(typename, "Invalid object", {
51
+ F: __dxlog_file,
52
+ L: 138,
53
+ S: this,
54
+ A: [
55
+ "typename",
56
+ "'Invalid object'"
57
+ ]
58
+ });
59
+ return typename;
60
+ };
61
+ Type2.getVersion = import_echo_schema2.getSchemaVersion;
62
+ Type2.toJsonSchema = import_echo_schema2.toJsonSchema;
63
+ })(Type || (Type = {}));
58
64
  // Annotate the CommonJS export names for ESM import in node:
59
65
  0 && (module.exports = {
60
66
  DXN,
61
- Database,
62
- Queue,
63
- Space,
67
+ Format,
64
68
  Type
65
69
  });
66
70
  //# sourceMappingURL=index.cjs.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,kBAAoB;AIEpB,yBAiBO;AACP,yBAA2C;;;;;;AHxB3C,IAAA,mBAAA,CAAA;ACAA,IAAA,gBAAA,CAAA;ACAA,IAAA,gBAAA,CAAA;ACAA,IAAA,eAAA,CAAA;;;;;;;;;;;;;;;AAmEO,IAAMA,MAAMC;AACZ,IAAMC,SAASC,mBAAAA;AAgBf,IAAMC,MAAM,CAACC,aAAmBC,+BAAWD,IAAAA;AAc3C,IAAME,MAAM,CAAuCC,aAAYC,mBAAAA,KAA4BD,IAAAA;",
6
- "names": ["ref", "makeRef", "create", "create$", "def", "meta", "EchoObject", "Ref", "self", "Ref$"]
3
+ "sources": ["../../../src/api/index.ts", "../../../src/api/type.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\n// export type { Database } from './database';\n// export type { Queue } from './queue';\n// export type { Space } from './space';\n\nexport { Type } from './type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';\nimport {\n type BaseEchoObject,\n type BaseObject,\n type BaseSchema,\n type EchoSchema,\n EchoObject,\n EntityKind,\n Expando as Expando$,\n type ImmutableSchema,\n type JsonSchemaType,\n ObjectId as ObjectId$,\n Ref as Ref$,\n SpaceIdSchema as SpaceIdSchema$,\n type StoredSchema,\n type TypeMeta,\n getTypeAnnotation,\n getSchema as getSchema$,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n isInstanceOf,\n toJsonSchema as toJsonSchema$,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId as SpaceId$ } from '@dxos/keys';\nimport { live as live$ } from '@dxos/live-object';\n\n// TODO(burdon): Type vs. Relation vs. Object.\n\n/**\n * Type System API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport namespace Type {\n //\n // Keys\n //\n\n export const SpaceIdSchema = SpaceIdSchema$; // TODO(burdon): Reconcile with SpaceId as with ObjectId.\n export const SpaceId = SpaceId$;\n export type SpaceId = SpaceId$;\n\n export const ObjectId = ObjectId$;\n export type ObjectId = ObjectId$;\n\n //\n // Objects\n //\n\n export const Kind = EntityKind;\n export type AnyObject = BaseEchoObject;\n export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;\n\n //\n // Schema\n //\n\n export type JsonSchema = JsonSchemaType;\n\n /**\n * A schema that can be extended with arbitrary properties.\n */\n export const Expando = Expando$;\n export type Expando = Expando$;\n\n // TODO(burdon): Review/remove.\n export type Abstract<T = any> = BaseSchema<T>;\n export type ImmutableType<T> = ImmutableSchema<T>;\n export type MutableType<T> = EchoSchema<T>;\n export type StoredType = StoredSchema;\n\n export const create = live$;\n\n /**\n * Defines an ECHO type.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Organization = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.def({\n * typename: 'example.com/type/Organization',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const def = (meta: TypeMeta) => EchoObject(meta);\n\n //\n // Refs\n //\n\n /**\n * Defines a reference to an ECHO object.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Person = Schema.Struct({\n * name: Schema.String,\n * organization: Type.Ref(Organization),\n * }).pipe(Type.def({\n * typename: 'example.com/type/Person',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);\n\n export const ref = Ref$.make;\n\n //\n // Object utils\n //\n\n export const getMeta = getTypeAnnotation;\n export const getSchema = getSchema$;\n export const instanceOf = isInstanceOf;\n\n //\n // Type utils\n //\n\n // TODO(burdon): Reconcile getDXN and getTypename.\n export const getDXN = getSchemaDXN;\n export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {\n const typename = getSchemaTypename(schema);\n invariant(typename, 'Invalid object');\n return typename;\n };\n export const getVersion = getSchemaVersion;\n export const toJsonSchema = toJsonSchema$;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAuB;AACvB,kBAAoB;ACEpB,IAAAA,sBAsBO;AACP,uBAA0B;AAC1B,IAAAC,eAAoC;AACpC,yBAA8B;;;UAUbC,OAAAA;QAKFC,gBAAgBC,oBAAAA;QAChBC,UAAUC,aAAAA;QAGVC,WAAWC,oBAAAA;QAOXC,OAAOC;AAYnBR,QACYS,UAAUC,oBAAAA;QASVC,SAASC,mBAAAA;AAerBZ,QACYa,MAAM,CAACC,aAAmBC,gCAAWD,IAAAA;AAoBjDd,QACYgB,MAAM,CAAuCC,aAAYC,oBAAAA,KAA4BD,IAAAA;QAErFE,MAAMD,oBAAAA,IAAKE;QAMXC,UAAUC;QACVC,YAAYC,oBAAAA;QACZC,aAAaC;QAObC,SAASC;QACTC,cAAc,CAACC,WAAAA;AAC1B,UAAMC,eAAWC,uCAAkBF,MAAAA;AACnCG,oCAAUF,UAAU,kBAAA;;;;;;;;;AACpB,WAAOA;EACT;QACaG,aAAaC;QACbC,eAAeC,oBAAAA;AAC9B,GApGiBrC,SAAAA,OAAAA,CAAAA,EAAAA;",
6
+ "names": ["import_echo_schema", "import_keys", "Type", "SpaceIdSchema", "SpaceIdSchema$", "SpaceId", "SpaceId$", "ObjectId", "ObjectId$", "Kind", "EntityKind", "Expando", "Expando$", "create", "live$", "def", "meta", "EchoObject", "Ref", "self", "Ref$", "ref", "make", "getMeta", "getTypeAnnotation", "getSchema", "getSchema$", "instanceOf", "isInstanceOf", "getDXN", "getSchemaDXN", "getTypename", "schema", "typename", "getSchemaTypename", "invariant", "getVersion", "getSchemaVersion", "toJsonSchema", "toJsonSchema$"]
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/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4020},"packages/core/echo/echo/dist/lib/node/index.cjs":{"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":1388}}}
1
+ {"inputs":{"packages/core/echo/echo/src/api/type.ts":{"bytes":9128,"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}],"format":"esm"},"packages/core/echo/echo/src/api/index.ts":{"bytes":1177,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/echo/echo/src/api/type.ts","kind":"import-statement","original":"./type"}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":482,"imports":[{"path":"packages/core/echo/echo/src/api/index.ts","kind":"import-statement","original":"./api"}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5031},"packages/core/echo/echo/dist/lib/node/index.cjs":{"imports":[{"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/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"exports":["DXN","Format","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/api/index.ts":{"bytesInOutput":78},"packages/core/echo/echo/src/api/type.ts":{"bytesInOutput":1352},"packages/core/echo/echo/src/index.ts":{"bytesInOutput":0}},"bytes":1589}}}
@@ -1,49 +1,49 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
4
- for (var name in all)
5
- __defProp(target, name, { get: all[name], enumerable: true });
6
- };
7
2
 
8
- // packages/core/echo/echo/src/index.ts
3
+ // packages/core/echo/echo/src/api/index.ts
4
+ import { Format } from "@dxos/echo-schema";
9
5
  import { DXN } from "@dxos/keys";
10
6
 
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
- // packages/core/echo/echo/src/Type.ts
21
- var Type_exports = {};
22
- __export(Type_exports, {
23
- Kind: () => EntityKind,
24
- 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
35
- });
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);
7
+ // packages/core/echo/echo/src/api/type.ts
8
+ import { EchoObject, EntityKind, Expando as Expando$, ObjectId as ObjectId$, Ref as Ref$, SpaceIdSchema as SpaceIdSchema$, getTypeAnnotation, getSchema as getSchema$, getSchemaDXN, getSchemaTypename, getSchemaVersion, isInstanceOf, toJsonSchema as toJsonSchema$ } from "@dxos/echo-schema";
9
+ import { invariant } from "@dxos/invariant";
10
+ import { SpaceId as SpaceId$ } from "@dxos/keys";
11
+ import { live as live$ } from "@dxos/live-object";
12
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/api/type.ts";
13
+ var Type;
14
+ (function(Type2) {
15
+ Type2.SpaceIdSchema = SpaceIdSchema$;
16
+ Type2.SpaceId = SpaceId$;
17
+ Type2.ObjectId = ObjectId$;
18
+ Type2.Kind = EntityKind;
19
+ Type2.Expando = Expando$;
20
+ Type2.create = live$;
21
+ Type2.def = (meta) => EchoObject(meta);
22
+ Type2.Ref = (self) => Ref$(self);
23
+ Type2.ref = Ref$.make;
24
+ Type2.getMeta = getTypeAnnotation;
25
+ Type2.getSchema = getSchema$;
26
+ Type2.instanceOf = isInstanceOf;
27
+ Type2.getDXN = getSchemaDXN;
28
+ Type2.getTypename = (schema) => {
29
+ const typename = getSchemaTypename(schema);
30
+ invariant(typename, "Invalid object", {
31
+ F: __dxlog_file,
32
+ L: 138,
33
+ S: this,
34
+ A: [
35
+ "typename",
36
+ "'Invalid object'"
37
+ ]
38
+ });
39
+ return typename;
40
+ };
41
+ Type2.getVersion = getSchemaVersion;
42
+ Type2.toJsonSchema = toJsonSchema$;
43
+ })(Type || (Type = {}));
42
44
  export {
43
45
  DXN,
44
- Database_exports as Database,
45
- Queue_exports as Queue,
46
- Space_exports as Space,
47
- Type_exports as Type
46
+ Format,
47
+ Type
48
48
  };
49
49
  //# 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/api/index.ts", "../../../src/api/type.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\n// export type { Database } from './database';\n// export type { Queue } from './queue';\n// export type { Space } from './space';\n\nexport { Type } from './type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';\nimport {\n type BaseEchoObject,\n type BaseObject,\n type BaseSchema,\n type EchoSchema,\n EchoObject,\n EntityKind,\n Expando as Expando$,\n type ImmutableSchema,\n type JsonSchemaType,\n ObjectId as ObjectId$,\n Ref as Ref$,\n SpaceIdSchema as SpaceIdSchema$,\n type StoredSchema,\n type TypeMeta,\n getTypeAnnotation,\n getSchema as getSchema$,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n isInstanceOf,\n toJsonSchema as toJsonSchema$,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId as SpaceId$ } from '@dxos/keys';\nimport { live as live$ } from '@dxos/live-object';\n\n// TODO(burdon): Type vs. Relation vs. Object.\n\n/**\n * Type System API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport namespace Type {\n //\n // Keys\n //\n\n export const SpaceIdSchema = SpaceIdSchema$; // TODO(burdon): Reconcile with SpaceId as with ObjectId.\n export const SpaceId = SpaceId$;\n export type SpaceId = SpaceId$;\n\n export const ObjectId = ObjectId$;\n export type ObjectId = ObjectId$;\n\n //\n // Objects\n //\n\n export const Kind = EntityKind;\n export type AnyObject = BaseEchoObject;\n export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;\n\n //\n // Schema\n //\n\n export type JsonSchema = JsonSchemaType;\n\n /**\n * A schema that can be extended with arbitrary properties.\n */\n export const Expando = Expando$;\n export type Expando = Expando$;\n\n // TODO(burdon): Review/remove.\n export type Abstract<T = any> = BaseSchema<T>;\n export type ImmutableType<T> = ImmutableSchema<T>;\n export type MutableType<T> = EchoSchema<T>;\n export type StoredType = StoredSchema;\n\n export const create = live$;\n\n /**\n * Defines an ECHO type.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Organization = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.def({\n * typename: 'example.com/type/Organization',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const def = (meta: TypeMeta) => EchoObject(meta);\n\n //\n // Refs\n //\n\n /**\n * Defines a reference to an ECHO object.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Person = Schema.Struct({\n * name: Schema.String,\n * organization: Type.Ref(Organization),\n * }).pipe(Type.def({\n * typename: 'example.com/type/Person',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);\n\n export const ref = Ref$.make;\n\n //\n // Object utils\n //\n\n export const getMeta = getTypeAnnotation;\n export const getSchema = getSchema$;\n export const instanceOf = isInstanceOf;\n\n //\n // Type utils\n //\n\n // TODO(burdon): Reconcile getDXN and getTypename.\n export const getDXN = getSchemaDXN;\n export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {\n const typename = getSchemaTypename(schema);\n invariant(typename, 'Invalid object');\n return typename;\n };\n export const getVersion = getSchemaVersion;\n export const toJsonSchema = toJsonSchema$;\n}\n"],
5
+ "mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,WAAW;;;ACEpB,SAKEC,YACAC,YACAC,WAAWC,UAGXC,YAAYC,WACZC,OAAOC,MACPC,iBAAiBC,gBAGjBC,mBACAC,aAAaC,YACbC,cACAC,mBACAC,kBACAC,cACAC,gBAAgBC,qBACX;AACP,SAASC,iBAAiB;AAC1B,SAASC,WAAWC,gBAAgB;AACpC,SAASC,QAAQC,aAAa;;;UAUbC,OAAAA;QAKFhB,gBAAgBC;QAChBW,UAAUC;QAGVjB,WAAWC;QAOXoB,OAAOxB;AAYnB,EAAAuB,MACYtB,UAAUC;QASVuB,SAASH;AAerB,EAAAC,MACYG,MAAM,CAACC,SAAmB5B,WAAW4B,IAAAA;AAoBjD,EAAAJ,MACYlB,MAAM,CAAuCuB,SAAYtB,KAA4BsB,IAAAA;QAErFC,MAAMvB,KAAKwB;QAMXC,UAAUtB;QACVC,YAAYC;QACZqB,aAAajB;QAObkB,SAASrB;QACTsB,cAAc,CAACC,WAAAA;AAC1B,UAAMC,WAAWvB,kBAAkBsB,MAAAA;AACnCjB,cAAUkB,UAAU,kBAAA;;;;;;;;;AACpB,WAAOA;EACT;QACaC,aAAavB;QACbE,eAAeC;AAC9B,GApGiBM,SAAAA,OAAAA,CAAAA,EAAAA;",
6
+ "names": ["Format", "DXN", "EchoObject", "EntityKind", "Expando", "Expando$", "ObjectId", "ObjectId$", "Ref", "Ref$", "SpaceIdSchema", "SpaceIdSchema$", "getTypeAnnotation", "getSchema", "getSchema$", "getSchemaDXN", "getSchemaTypename", "getSchemaVersion", "isInstanceOf", "toJsonSchema", "toJsonSchema$", "invariant", "SpaceId", "SpaceId$", "live", "live$", "Type", "Kind", "create", "def", "meta", "self", "ref", "make", "getMeta", "instanceOf", "getDXN", "getTypename", "schema", "typename", "getVersion"]
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/api/type.ts":{"bytes":9128,"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}],"format":"esm"},"packages/core/echo/echo/src/api/index.ts":{"bytes":1177,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/echo/echo/src/api/type.ts","kind":"import-statement","original":"./type"}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":482,"imports":[{"path":"packages/core/echo/echo/src/api/index.ts","kind":"import-statement","original":"./api"}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5033},"packages/core/echo/echo/dist/lib/node-esm/index.mjs":{"imports":[{"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/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"exports":["DXN","Format","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/api/index.ts":{"bytesInOutput":78},"packages/core/echo/echo/src/api/type.ts":{"bytesInOutput":1352},"packages/core/echo/echo/src/index.ts":{"bytesInOutput":0}},"bytes":1682}}}
@@ -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/api/database.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,QAAQ,CAAC,GAAE"}
@@ -0,0 +1,4 @@
1
+ export { Format } from '@dxos/echo-schema';
2
+ export { DXN } from '@dxos/keys';
3
+ export { Type } from './type';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAMjC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../src/api/queue.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,KAAK,CAAC,GAAE"}
@@ -5,4 +5,4 @@
5
5
  * @since 0.9.0
6
6
  */
7
7
  export declare namespace Space { }
8
- //# sourceMappingURL=Space.d.ts.map
8
+ //# sourceMappingURL=space.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../../src/api/space.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC,GAAE"}
@@ -0,0 +1,80 @@
1
+ import { type Schema } from 'effect';
2
+ import { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';
3
+ import { type BaseEchoObject, type BaseObject, type BaseSchema, type EchoSchema, EntityKind, Expando as Expando$, type ImmutableSchema, type JsonSchemaType, ObjectId as ObjectId$, Ref as Ref$, type StoredSchema, type TypeMeta } from '@dxos/echo-schema';
4
+ import { SpaceId as SpaceId$ } from '@dxos/keys';
5
+ /**
6
+ * Type System API.
7
+ *
8
+ * @category api namespace
9
+ * @since 0.9.0
10
+ */
11
+ export declare namespace Type {
12
+ const SpaceIdSchema: Schema.Schema<SpaceId$, string, never>;
13
+ const SpaceId: Readonly<{
14
+ byteLength: 20;
15
+ encode: (value: Uint8Array) => SpaceId$;
16
+ decode: (value: SpaceId$) => Uint8Array;
17
+ isValid: (value: string) => value is SpaceId$;
18
+ random: () => SpaceId$;
19
+ }>;
20
+ type SpaceId = SpaceId$;
21
+ const ObjectId: import("@dxos/echo-schema").ObjectIdClass;
22
+ type ObjectId = ObjectId$;
23
+ const Kind: typeof EntityKind;
24
+ type AnyObject = BaseEchoObject;
25
+ type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;
26
+ type JsonSchema = JsonSchemaType;
27
+ /**
28
+ * A schema that can be extended with arbitrary properties.
29
+ */
30
+ const Expando: Schema.Schema<Expando$, Expando$, never>;
31
+ type Expando = Expando$;
32
+ type Abstract<T = any> = BaseSchema<T>;
33
+ type ImmutableType<T> = ImmutableSchema<T>;
34
+ type MutableType<T> = EchoSchema<T>;
35
+ type StoredType = StoredSchema;
36
+ const create: {
37
+ <T extends BaseObject>(obj: T): import("@dxos/live-object").Live<T>;
38
+ <T extends 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").Live<T>;
39
+ };
40
+ /**
41
+ * Defines an ECHO type.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * import { Type } from '@dxos/echo';
46
+ * const Organization = Schema.Struct({
47
+ * name: Schema.String,
48
+ * }).pipe(Type.def({
49
+ * typename: 'example.com/type/Organization',
50
+ * version: '0.1.0',
51
+ * }));
52
+ * ```
53
+ */
54
+ const def: (meta: TypeMeta) => <Self extends Schema.Schema.Any>(self: Self) => import("@dxos/echo-schema").EchoTypeSchema<Self>;
55
+ /**
56
+ * Defines a reference to an ECHO object.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * import { Type } from '@dxos/echo';
61
+ * const Person = Schema.Struct({
62
+ * name: Schema.String,
63
+ * organization: Type.Ref(Organization),
64
+ * }).pipe(Type.def({
65
+ * typename: 'example.com/type/Person',
66
+ * version: '0.1.0',
67
+ * }));
68
+ * ```
69
+ */
70
+ const Ref: <S extends Schema.Schema.AnyNoContext>(self: S) => import("@dxos/echo-schema").Ref$<Schema.Schema.Type<S>>;
71
+ const ref: <T extends import("@dxos/echo-schema").WithId>(object: T) => Ref$<T>;
72
+ const getMeta: (schema: Schema.Schema.All) => import("@dxos/echo-schema").TypeAnnotation | undefined;
73
+ const getSchema: (obj: unknown | undefined) => Schema.Schema.AnyNoContext | undefined;
74
+ const instanceOf: <Schema extends Schema.Schema.AnyNoContext>(schema: Schema, object: any) => object is Schema.Schema.Type<Schema>;
75
+ const getDXN: (schema: Schema.Schema.All) => import("@dxos/keys").DXN | undefined;
76
+ const getTypename: (schema: Schema.Schema.AnyNoContext) => string;
77
+ const getVersion: (schema: Schema.Schema.All) => string | undefined;
78
+ const toJsonSchema: (schema: Schema.Schema.All) => JsonSchemaType;
79
+ }
80
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/api/type.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,KAAK,aAAa,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,UAAU,EACV,OAAO,IAAI,QAAQ,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,QAAQ,IAAI,SAAS,EACrB,GAAG,IAAI,IAAI,EAEX,KAAK,YAAY,EACjB,KAAK,QAAQ,EAQd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKjD;;;;;GAKG;AACH,yBAAiB,IAAI,CAAC;IAKb,MAAM,aAAa,wCAAiB,CAAC;IACrC,MAAM,OAAO;;;;;;MAAW,CAAC;IAChC,KAAY,OAAO,GAAG,QAAQ,CAAC;IAExB,MAAM,QAAQ,2CAAY,CAAC;IAClC,KAAY,QAAQ,GAAG,SAAS,CAAC;IAM1B,MAAM,IAAI,mBAAa,CAAC;IAC/B,KAAY,SAAS,GAAG,cAAc,CAAC;IACvC,KAAY,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;IAMpE,KAAY,UAAU,GAAG,cAAc,CAAC;IAExC;;OAEG;IACI,MAAM,OAAO,0CAAW,CAAC;IAChC,KAAY,OAAO,GAAG,QAAQ,CAAC;IAG/B,KAAY,QAAQ,CAAC,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9C,KAAY,aAAa,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;IAClD,KAAY,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3C,KAAY,UAAU,GAAG,YAAY,CAAC;IAE/B,MAAM,MAAM;;uCA7DX,OAAS,MAAK;KA6DK,CAAC;IAE5B;;;;;;;;;;;;;OAaG;IACI,MAAM,GAAG,SAAU,QAAQ,mBAqBuD,OAAQ,MAAM,CAEvG,GAAD,iEAvBwD,CAAC;IAMxD;;;;;;;;;;;;;;OAcG;IACI,MAAM,GAAG,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,QAAQ,CAAC,4DAAsC,CAAC;IAEjG,MAAM,GAAG,sEAAY,CAAC;IAMtB,MAAM,OAAO,WApCD,OAClB,MAAI,CAAC,GAAG,2DAmC+B,CAAC;IAClC,MAAM,SAAS,gCA/GV,OAAQ,MAClB,CAAC,YAAY,YA8GoB,CAAC;IAC7B,MAAM,UAAU,kBAfL,OAAQ,MAAM,CAAC,YAChC,4CAGA,OACC,MAAM,CAAC,IAAI,QAUyB,CAAC;IAOhC,MAAM,MAAM,WA9Gb,OACN,MAAI,CAAC,GAAG,yCA6G0B,CAAC;IAC5B,MAAM,WAAW,WAAY,MAAM,CAAC,MAAM,CAAC,YAAY,KAAG,MAIhE,CAAC;IACK,MAAM,UAAU,WA5BtB,OAAI,MAAM,CAAC,GAAG,uBA4B2B,CAAC;IACpC,MAAM,YAAY,WAlHvB,OAAQ,MACV,CAAC,GAAG,mBAiHqC,CAAC;CAC3C"}
@@ -1,7 +1,2 @@
1
- import { DXN } from '@dxos/keys';
2
- export { DXN };
3
- export * as Database from './Database';
4
- export * as Queue from './Queue';
5
- export * as Space from './Space';
6
- export * as Type from './Type';
1
+ export * from './api';
7
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,GAAG,EAAE,CAAC;AAEf,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo",
3
- "version": "0.8.1",
3
+ "version": "0.8.2-main.2f9c567",
4
4
  "description": "ECHO API",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -22,19 +22,19 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@preact/signals-core": "^1.6.0",
25
- "effect": "3.13.3",
26
- "@dxos/debug": "0.8.1",
27
- "@dxos/echo-db": "0.8.1",
28
- "@dxos/echo-protocol": "0.8.1",
29
- "@dxos/effect": "0.8.1",
30
- "@dxos/echo-signals": "0.8.1",
31
- "@dxos/echo-schema": "0.8.1",
32
- "@dxos/invariant": "0.8.1",
33
- "@dxos/keys": "0.8.1",
34
- "@dxos/live-object": "0.8.1",
35
- "@dxos/node-std": "0.8.1",
36
- "@dxos/log": "0.8.1",
37
- "@dxos/util": "0.8.1"
25
+ "effect": "3.14.21",
26
+ "@dxos/debug": "0.8.2-main.2f9c567",
27
+ "@dxos/echo-protocol": "0.8.2-main.2f9c567",
28
+ "@dxos/echo-db": "0.8.2-main.2f9c567",
29
+ "@dxos/echo-schema": "0.8.2-main.2f9c567",
30
+ "@dxos/echo-signals": "0.8.2-main.2f9c567",
31
+ "@dxos/effect": "0.8.2-main.2f9c567",
32
+ "@dxos/keys": "0.8.2-main.2f9c567",
33
+ "@dxos/log": "0.8.2-main.2f9c567",
34
+ "@dxos/invariant": "0.8.2-main.2f9c567",
35
+ "@dxos/live-object": "0.8.2-main.2f9c567",
36
+ "@dxos/node-std": "0.8.2-main.2f9c567",
37
+ "@dxos/util": "0.8.2-main.2f9c567"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
@@ -8,4 +8,4 @@
8
8
  * @category api namespace
9
9
  * @since 0.9.0
10
10
  */
11
- export declare namespace Database {}
11
+ export namespace Database {}
@@ -0,0 +1,12 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export { Format } from '@dxos/echo-schema';
6
+ export { DXN } from '@dxos/keys';
7
+
8
+ // export type { Database } from './database';
9
+ // export type { Queue } from './queue';
10
+ // export type { Space } from './space';
11
+
12
+ export { Type } from './type';
@@ -8,4 +8,4 @@
8
8
  * @category api namespace
9
9
  * @since 0.9.0
10
10
  */
11
- export declare namespace Queue {}
11
+ export namespace Queue {}
@@ -0,0 +1,143 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Schema } from 'effect';
6
+
7
+ import { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';
8
+ import {
9
+ type BaseEchoObject,
10
+ type BaseObject,
11
+ type BaseSchema,
12
+ type EchoSchema,
13
+ EchoObject,
14
+ EntityKind,
15
+ Expando as Expando$,
16
+ type ImmutableSchema,
17
+ type JsonSchemaType,
18
+ ObjectId as ObjectId$,
19
+ Ref as Ref$,
20
+ SpaceIdSchema as SpaceIdSchema$,
21
+ type StoredSchema,
22
+ type TypeMeta,
23
+ getTypeAnnotation,
24
+ getSchema as getSchema$,
25
+ getSchemaDXN,
26
+ getSchemaTypename,
27
+ getSchemaVersion,
28
+ isInstanceOf,
29
+ toJsonSchema as toJsonSchema$,
30
+ } from '@dxos/echo-schema';
31
+ import { invariant } from '@dxos/invariant';
32
+ import { SpaceId as SpaceId$ } from '@dxos/keys';
33
+ import { live as live$ } from '@dxos/live-object';
34
+
35
+ // TODO(burdon): Type vs. Relation vs. Object.
36
+
37
+ /**
38
+ * Type System API.
39
+ *
40
+ * @category api namespace
41
+ * @since 0.9.0
42
+ */
43
+ export namespace Type {
44
+ //
45
+ // Keys
46
+ //
47
+
48
+ export const SpaceIdSchema = SpaceIdSchema$; // TODO(burdon): Reconcile with SpaceId as with ObjectId.
49
+ export const SpaceId = SpaceId$;
50
+ export type SpaceId = SpaceId$;
51
+
52
+ export const ObjectId = ObjectId$;
53
+ export type ObjectId = ObjectId$;
54
+
55
+ //
56
+ // Objects
57
+ //
58
+
59
+ export const Kind = EntityKind;
60
+ export type AnyObject = BaseEchoObject;
61
+ export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;
62
+
63
+ //
64
+ // Schema
65
+ //
66
+
67
+ export type JsonSchema = JsonSchemaType;
68
+
69
+ /**
70
+ * A schema that can be extended with arbitrary properties.
71
+ */
72
+ export const Expando = Expando$;
73
+ export type Expando = Expando$;
74
+
75
+ // TODO(burdon): Review/remove.
76
+ export type Abstract<T = any> = BaseSchema<T>;
77
+ export type ImmutableType<T> = ImmutableSchema<T>;
78
+ export type MutableType<T> = EchoSchema<T>;
79
+ export type StoredType = StoredSchema;
80
+
81
+ export const create = live$;
82
+
83
+ /**
84
+ * Defines an ECHO type.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { Type } from '@dxos/echo';
89
+ * const Organization = Schema.Struct({
90
+ * name: Schema.String,
91
+ * }).pipe(Type.def({
92
+ * typename: 'example.com/type/Organization',
93
+ * version: '0.1.0',
94
+ * }));
95
+ * ```
96
+ */
97
+ export const def = (meta: TypeMeta) => EchoObject(meta);
98
+
99
+ //
100
+ // Refs
101
+ //
102
+
103
+ /**
104
+ * Defines a reference to an ECHO object.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * import { Type } from '@dxos/echo';
109
+ * const Person = Schema.Struct({
110
+ * name: Schema.String,
111
+ * organization: Type.Ref(Organization),
112
+ * }).pipe(Type.def({
113
+ * typename: 'example.com/type/Person',
114
+ * version: '0.1.0',
115
+ * }));
116
+ * ```
117
+ */
118
+ export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);
119
+
120
+ export const ref = Ref$.make;
121
+
122
+ //
123
+ // Object utils
124
+ //
125
+
126
+ export const getMeta = getTypeAnnotation;
127
+ export const getSchema = getSchema$;
128
+ export const instanceOf = isInstanceOf;
129
+
130
+ //
131
+ // Type utils
132
+ //
133
+
134
+ // TODO(burdon): Reconcile getDXN and getTypename.
135
+ export const getDXN = getSchemaDXN;
136
+ export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {
137
+ const typename = getSchemaTypename(schema);
138
+ invariant(typename, 'Invalid object');
139
+ return typename;
140
+ };
141
+ export const getVersion = getSchemaVersion;
142
+ export const toJsonSchema = toJsonSchema$;
143
+ }
package/src/api.test.ts CHANGED
@@ -2,51 +2,65 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema as S } from 'effect';
5
+ import { Schema } from 'effect';
6
6
  import { describe, test } from 'vitest';
7
7
 
8
8
  import { raise } from '@dxos/debug';
9
9
  import { FormatEnum, FormatAnnotation } from '@dxos/echo-schema';
10
10
 
11
- // Deliberately testing top-level import as if external consumer for @dxos/echo.
12
- import { Type } from '.';
11
+ import { Type } from './api';
13
12
 
14
13
  namespace Testing {
15
- export const Org = S.Struct({
14
+ export const Organization = Schema.Struct({
16
15
  id: Type.ObjectId,
17
- name: S.String,
16
+ name: Schema.String,
18
17
  }).pipe(
19
18
  Type.def({
20
- typename: 'example.com/type/Org',
19
+ typename: 'example.com/type/Organization',
21
20
  version: '0.1.0',
22
21
  }),
23
22
  );
24
23
 
25
- export interface Org extends S.Schema.Type<typeof Org> {}
24
+ export interface Organization extends Schema.Schema.Type<typeof Organization> {}
26
25
 
27
- export const Contact = S.Struct({
28
- name: S.String,
29
- dob: S.optional(S.String),
30
- email: S.optional(S.String.pipe(FormatAnnotation.set(FormatEnum.Email))),
31
- org: S.optional(Type.Ref(Org)),
26
+ export const Person = Schema.Struct({
27
+ name: Schema.String,
28
+ dob: Schema.optional(Schema.String),
29
+ email: Schema.optional(Schema.String.pipe(FormatAnnotation.set(FormatEnum.Email))),
30
+ organization: Schema.optional(Type.Ref(Organization)),
32
31
  }).pipe(
33
32
  Type.def({
34
- typename: 'example.com/type/Contact',
33
+ typename: 'example.com/type/Person',
35
34
  version: '0.1.0',
36
35
  }),
37
36
  );
38
37
 
39
- export interface Contact extends S.Schema.Type<typeof Contact> {}
38
+ export interface Person extends Schema.Schema.Type<typeof Person> {}
40
39
 
41
- export const Message = S.Struct({
40
+ export const Message = Schema.Struct({
42
41
  // TODO(burdon): Support S.Date; Custom Timestamp (with defaults).
43
- // TODO(burdon): Support defaults (update create and createStatic).
44
- timestamp: S.String.pipe(
45
- S.propertySignature,
46
- S.withConstructorDefault(() => new Date().toISOString()),
42
+ // TODO(burdon): Support defaults (update create and create).
43
+ timestamp: Schema.String.pipe(
44
+ Schema.propertySignature,
45
+ Schema.withConstructorDefault(() => new Date().toISOString()),
47
46
  ),
48
47
  });
49
48
 
49
+ export const WorksFor = Schema.Struct({
50
+ // id: Type.ObjectId,
51
+ role: Schema.String,
52
+ }).pipe(
53
+ // Relation.def
54
+ Type.def({
55
+ typename: 'example.com/type/WorksFor',
56
+ version: '0.1.0',
57
+ // source: Person,
58
+ // target: Organization,
59
+ }),
60
+ );
61
+
62
+ export interface WorksFor extends Schema.Schema.Type<typeof WorksFor> {}
63
+
50
64
  // TODO(burdon): Fix (Type.def currently removes TypeLiteral that implements the `make` function)..
51
65
  // }).pipe(
52
66
  // Type.def({
@@ -55,34 +69,32 @@ namespace Testing {
55
69
  // }),
56
70
  // );
57
71
 
58
- export interface Message extends S.Schema.Type<typeof Message> {}
72
+ export interface Message extends Schema.Schema.Type<typeof Message> {}
59
73
  }
60
74
 
61
75
  describe('Experimental API review', () => {
62
76
  test('type checks', ({ expect }) => {
63
- const contact = Type.create(Testing.Contact, { name: 'Test' });
64
- const type: S.Schema<Testing.Contact> = Type.getSchema(contact) ?? raise(new Error('No schema found'));
77
+ const contact = Type.create(Testing.Person, { name: 'Test' });
78
+ const type: Schema.Schema<Testing.Person> = Type.getSchema(contact) ?? raise(new Error('No schema found'));
65
79
 
66
- expect(Type.getDXN(type)?.typename).to.eq(Testing.Contact.typename);
67
- expect(Type.getTypename(type)).to.eq('example.com/type/Contact');
80
+ expect(Type.getDXN(type)?.typename).to.eq(Testing.Person.typename);
81
+ expect(Type.getTypename(type)).to.eq('example.com/type/Person');
68
82
  expect(Type.getVersion(type)).to.eq('0.1.0');
69
83
  expect(Type.getMeta(type)).to.deep.eq({
70
84
  kind: Type.Kind.Object,
71
- typename: 'example.com/type/Contact',
85
+ typename: 'example.com/type/Person',
72
86
  version: '0.1.0',
73
87
  });
74
88
  });
75
89
 
76
90
  test('instance checks', ({ expect }) => {
77
- // TODO(burdon): Implement.
78
- // const org = Org.create({ name: 'DXOS' });
79
- const org = Type.create(Testing.Org, { name: 'DXOS' });
80
- const contact = Type.create(Testing.Contact, { name: 'Test', org: Type.ref(org) });
81
-
82
- expect(S.is(Testing.Contact)(contact)).to.be.true;
83
- expect(Testing.Contact.instanceOf(contact)).to.be.true;
84
- expect(Type.instanceOf(Testing.Contact, contact)).to.be.true;
85
- expect(Type.instanceOf(Testing.Org, contact.org?.target)).to.be.true;
91
+ const organization = Type.create(Testing.Organization, { name: 'DXOS' });
92
+ const contact = Type.create(Testing.Person, { name: 'Test', organization: Type.ref(organization) });
93
+
94
+ expect(Schema.is(Testing.Person)(contact)).to.be.true;
95
+ expect(Testing.Person.instanceOf(contact)).to.be.true;
96
+ expect(Type.instanceOf(Testing.Person, contact)).to.be.true;
97
+ expect(Type.instanceOf(Testing.Organization, organization)).to.be.true;
86
98
  });
87
99
 
88
100
  test('default props', ({ expect }) => {
package/src/index.ts CHANGED
@@ -2,11 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { DXN } from '@dxos/keys';
6
-
7
- export { DXN };
8
-
9
- export * as Database from './Database';
10
- export * as Queue from './Queue';
11
- export * as Space from './Space';
12
- export * as Type from './Type';
5
+ export * from './api';
@@ -1 +0,0 @@
1
- {"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../src/Database.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC,GAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../src/Queue.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC,GAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Space.d.ts","sourceRoot":"","sources":["../../../src/Space.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC,GAAE"}
@@ -1,49 +0,0 @@
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, };
5
- /**
6
- * Type API.
7
- *
8
- * @category api namespace
9
- * @since 0.9.0
10
- */
11
- export declare namespace Type {
12
- /**
13
- * A schema that can be extended with arbitrary properties.
14
- */
15
- type Expando = Expando$;
16
- type Abstract<T = any> = BaseSchema<T>;
17
- type ImmutableType<T> = ImmutableSchema<T>;
18
- type MutableType<T> = EchoSchema<T>;
19
- }
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>>;
49
- //# sourceMappingURL=Type.d.ts.map
@@ -1 +0,0 @@
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,IAAI,EACX,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAW3B,YAAY,EAAE,QAAQ,IAAI,IAAI,EAAE,cAAc,IAAI,UAAU,EAAE,CAAC;AAC/D,OAAO,EACL,UAAU,IAAI,IAAI,EAClB,QAAQ,EACR,iBAAiB,IAAI,OAAO,EAC5B,SAAS,EACT,YAAY,IAAI,MAAM,EACtB,iBAAiB,IAAI,WAAW,EAChC,gBAAgB,IAAI,UAAU,EAC9B,YAAY,IAAI,UAAU,GAC3B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B;;OAEG;IACH,KAAY,OAAO,GAAG,QAAQ,CAAC;IAE/B,KAAY,QAAQ,CAAC,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9C,KAAY,aAAa,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;IAClD,KAAY,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;CAC5C;AAMD,eAAO,MAAM,GAAG,uEAAU,CAAC;AAC3B,eAAO,MAAM,MAAM;;;CAAU,CAAC;AAM9B;;;;;;;;;GASG;AACH,eAAO,MAAM,GAAG,SAAU,QAAQ,uGAAqB,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,QAAQ,CAAC,4DAAsC,CAAC"}
package/src/Type.ts DELETED
@@ -1,99 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { type Schema } from 'effect';
6
-
7
- import {
8
- type BaseSchema,
9
- type EchoSchema,
10
- type Expando as Expando$,
11
- type ImmutableSchema,
12
- type JsonSchemaType,
13
- type TypeMeta,
14
- EchoObject,
15
- EntityKind,
16
- ObjectId,
17
- Ref as Ref$,
18
- getTypeAnnotation,
19
- getSchema,
20
- getSchemaDXN,
21
- getSchemaTypename,
22
- getSchemaVersion,
23
- isInstanceOf,
24
- } from '@dxos/echo-schema';
25
- import { create as create$, makeRef } from '@dxos/live-object';
26
-
27
- // NOTES:
28
- // - New Echo package and namespaces allow for incremental migration; vastly simplifies imports.
29
- // - Split into separate ECHO namespaces: Database, Space, Type, Query, Queue.
30
- // - Example; import { Database, Type, Query, Queue } from '@dxos/echo';
31
- // - Use `declare namespace` for types (no code is generated). See Effect pattern, where Schema is a namespace, interface, and function.
32
- // - Test with @dxos/schema/testing types.
33
- // - Define user (Composer) types in namespace (e.g., of plugin) and drop Type suffix; remove all deprecated Braneframe types.
34
-
35
- export type { TypeMeta as Meta, JsonSchemaType as JsonSchema };
36
- export {
37
- EntityKind as Kind,
38
- ObjectId,
39
- getTypeAnnotation as getMeta,
40
- getSchema,
41
- getSchemaDXN as getDXN,
42
- getSchemaTypename as getTypename,
43
- getSchemaVersion as getVersion,
44
- isInstanceOf as instanceOf,
45
- };
46
-
47
- /**
48
- * Type API.
49
- *
50
- * @category api namespace
51
- * @since 0.9.0
52
- */
53
- export declare namespace Type {
54
- /**
55
- * A schema that can be extended with arbitrary properties.
56
- */
57
- export type Expando = Expando$;
58
-
59
- export type Abstract<T = any> = BaseSchema<T>;
60
- export type ImmutableType<T> = ImmutableSchema<T>;
61
- export type MutableType<T> = EchoSchema<T>;
62
- }
63
-
64
- //
65
- // Constructors
66
- //
67
-
68
- export const ref = makeRef;
69
- export const create = create$;
70
-
71
- //
72
- // Combinators
73
- //
74
-
75
- /**
76
- * Defines an ECHO type.
77
- *
78
- * @example
79
- * ```ts
80
- * const Org = S.Struct({
81
- * name: S.String,
82
- * }).pipe(Type.def({ typename: 'example.com/type/Org', version: '1.0.0' }));
83
- * ```
84
- */
85
- export const def = (meta: TypeMeta) => EchoObject(meta);
86
-
87
- /**
88
- * Defines a reference to an ECHO object.
89
- *
90
- * @example
91
- * ```ts
92
- * import { Type } from '@dxos/echo';
93
- * const Contact = S.Struct({
94
- * name: S.String,
95
- * employer: Type.Ref(Org),
96
- * }).pipe(Type.def({ typename: 'example.com/type/Contact', version: '1.0.0' }));
97
- * ```
98
- */
99
- export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);
File without changes