@dxos/echo 0.8.2-main.2f9c567 → 0.8.2-main.36232bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +41 -41
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +35 -39
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +41 -41
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/{api/database.d.ts → Database.d.ts} +1 -1
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/{api/queue.d.ts → Queue.d.ts} +1 -1
- package/dist/types/src/Queue.d.ts.map +1 -0
- package/dist/types/src/{api/space.d.ts → Space.d.ts} +1 -1
- package/dist/types/src/Space.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +49 -0
- package/dist/types/src/Type.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +6 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/{api/database.ts → Database.ts} +1 -1
- package/src/{api/queue.ts → Queue.ts} +1 -1
- package/src/Type.ts +99 -0
- package/src/api.test.ts +27 -41
- package/src/index.ts +8 -1
- package/dist/types/src/api/database.d.ts.map +0 -1
- package/dist/types/src/api/index.d.ts +0 -4
- package/dist/types/src/api/index.d.ts.map +0 -1
- package/dist/types/src/api/queue.d.ts.map +0 -1
- package/dist/types/src/api/space.d.ts.map +0 -1
- package/dist/types/src/api/type.d.ts +0 -80
- package/dist/types/src/api/type.d.ts.map +0 -1
- package/src/api/index.ts +0 -12
- package/src/api/type.ts +0 -143
- /package/src/{api/space.ts → 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
|
+
};
|
|
2
7
|
|
|
3
|
-
// packages/core/echo/echo/src/
|
|
4
|
-
import { Format } from "@dxos/echo-schema";
|
|
8
|
+
// packages/core/echo/echo/src/index.ts
|
|
5
9
|
import { DXN } from "@dxos/keys";
|
|
6
10
|
|
|
7
|
-
// packages/core/echo/echo/src/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
return typename;
|
|
40
|
-
};
|
|
41
|
-
Type2.getVersion = getSchemaVersion;
|
|
42
|
-
Type2.toJsonSchema = toJsonSchema$;
|
|
43
|
-
})(Type || (Type = {}));
|
|
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 { live 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);
|
|
44
42
|
export {
|
|
45
43
|
DXN,
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
Database_exports as Database,
|
|
45
|
+
Queue_exports as Queue,
|
|
46
|
+
Space_exports as Space,
|
|
47
|
+
Type_exports as Type
|
|
48
48
|
};
|
|
49
49
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
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 { live 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 Organization = S.Struct({\n * name: S.String,\n * }).pipe(Type.def({ typename: 'example.com/type/Organization', 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 * organization: Type.Ref(Organization),\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,QAAQC,SAASC,eAAe;AA2ClC,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", "live", "create$", "makeRef", "ref", "makeRef", "create", "create$", "def", "meta", "EchoObject", "Ref", "self", "Ref$"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo/src/
|
|
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":6078,"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":4048},"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":742}},"bytes":1419}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -19,52 +19,48 @@ 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
|
-
|
|
23
|
-
|
|
22
|
+
Database: () => Database_exports,
|
|
23
|
+
Queue: () => Queue_exports,
|
|
24
|
+
Space: () => Space_exports,
|
|
25
|
+
Type: () => Type_exports
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(node_exports);
|
|
26
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
27
28
|
var import_keys = require("@dxos/keys");
|
|
28
|
-
var
|
|
29
|
-
var import_invariant = require("@dxos/invariant");
|
|
30
|
-
var import_keys2 = require("@dxos/keys");
|
|
29
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
31
30
|
var import_live_object = require("@dxos/live-object");
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return typename;
|
|
60
|
-
};
|
|
61
|
-
Type2.getVersion = import_echo_schema2.getSchemaVersion;
|
|
62
|
-
Type2.toJsonSchema = import_echo_schema2.toJsonSchema;
|
|
63
|
-
})(Type || (Type = {}));
|
|
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.live;
|
|
56
|
+
var def = (meta) => (0, import_echo_schema.EchoObject)(meta);
|
|
57
|
+
var Ref = (self) => (0, import_echo_schema.Ref)(self);
|
|
64
58
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
59
|
0 && (module.exports = {
|
|
66
60
|
DXN,
|
|
67
|
-
|
|
61
|
+
Database,
|
|
62
|
+
Queue,
|
|
63
|
+
Space,
|
|
68
64
|
Type
|
|
69
65
|
});
|
|
70
66
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
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 { live 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 Organization = S.Struct({\n * name: S.String,\n * }).pipe(Type.def({ typename: 'example.com/type/Organization', 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 * organization: Type.Ref(Organization),\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,yBAAyC;;;;;;AHxBzC,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$"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo/src/
|
|
1
|
+
{"inputs":{"packages/core/echo/echo/src/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":6078,"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":4047},"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":742}},"bytes":1386}}}
|
|
@@ -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
|
+
};
|
|
2
7
|
|
|
3
|
-
// packages/core/echo/echo/src/
|
|
4
|
-
import { Format } from "@dxos/echo-schema";
|
|
8
|
+
// packages/core/echo/echo/src/index.ts
|
|
5
9
|
import { DXN } from "@dxos/keys";
|
|
6
10
|
|
|
7
|
-
// packages/core/echo/echo/src/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
return typename;
|
|
40
|
-
};
|
|
41
|
-
Type2.getVersion = getSchemaVersion;
|
|
42
|
-
Type2.toJsonSchema = toJsonSchema$;
|
|
43
|
-
})(Type || (Type = {}));
|
|
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 { live 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);
|
|
44
42
|
export {
|
|
45
43
|
DXN,
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
Database_exports as Database,
|
|
45
|
+
Queue_exports as Queue,
|
|
46
|
+
Space_exports as Space,
|
|
47
|
+
Type_exports as Type
|
|
48
48
|
};
|
|
49
49
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
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 { live 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 Organization = S.Struct({\n * name: S.String,\n * }).pipe(Type.def({ typename: 'example.com/type/Organization', 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 * organization: Type.Ref(Organization),\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,QAAQC,SAASC,eAAe;AA2ClC,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", "live", "create$", "makeRef", "ref", "makeRef", "create", "create$", "def", "meta", "EchoObject", "Ref", "self", "Ref$"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo/src/
|
|
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":6078,"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":4048},"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":742}},"bytes":1478}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../src/Database.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC,GAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../src/Queue.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC,GAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Space.d.ts","sourceRoot":"","sources":["../../../src/Space.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC,GAAE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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").Live<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").Live<T>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Defines an ECHO type.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const Organization = S.Struct({
|
|
31
|
+
* name: S.String,
|
|
32
|
+
* }).pipe(Type.def({ typename: 'example.com/type/Organization', 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
|
+
* organization: Type.Ref(Organization),
|
|
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
|
|
@@ -0,0 +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,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo",
|
|
3
|
-
"version": "0.8.2-main.
|
|
3
|
+
"version": "0.8.2-main.36232bc",
|
|
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.
|
|
26
|
-
"@dxos/debug": "0.8.2-main.
|
|
27
|
-
"@dxos/echo-
|
|
28
|
-
"@dxos/echo-
|
|
29
|
-
"@dxos/echo-schema": "0.8.2-main.
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/node-std": "0.8.2-main.
|
|
37
|
-
"@dxos/util": "0.8.2-main.
|
|
25
|
+
"effect": "3.13.3",
|
|
26
|
+
"@dxos/debug": "0.8.2-main.36232bc",
|
|
27
|
+
"@dxos/echo-db": "0.8.2-main.36232bc",
|
|
28
|
+
"@dxos/echo-protocol": "0.8.2-main.36232bc",
|
|
29
|
+
"@dxos/echo-schema": "0.8.2-main.36232bc",
|
|
30
|
+
"@dxos/effect": "0.8.2-main.36232bc",
|
|
31
|
+
"@dxos/echo-signals": "0.8.2-main.36232bc",
|
|
32
|
+
"@dxos/invariant": "0.8.2-main.36232bc",
|
|
33
|
+
"@dxos/keys": "0.8.2-main.36232bc",
|
|
34
|
+
"@dxos/live-object": "0.8.2-main.36232bc",
|
|
35
|
+
"@dxos/log": "0.8.2-main.36232bc",
|
|
36
|
+
"@dxos/node-std": "0.8.2-main.36232bc",
|
|
37
|
+
"@dxos/util": "0.8.2-main.36232bc"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
package/src/Type.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
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 { live 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 Organization = S.Struct({
|
|
81
|
+
* name: S.String,
|
|
82
|
+
* }).pipe(Type.def({ typename: 'example.com/type/Organization', 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
|
+
* organization: Type.Ref(Organization),
|
|
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);
|
package/src/api.test.ts
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } 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
|
-
import
|
|
11
|
+
// Deliberately testing top-level import as if external consumer for @dxos/echo.
|
|
12
|
+
import { Type } from '.';
|
|
12
13
|
|
|
13
14
|
namespace Testing {
|
|
14
|
-
export const Organization =
|
|
15
|
+
export const Organization = S.Struct({
|
|
15
16
|
id: Type.ObjectId,
|
|
16
|
-
name:
|
|
17
|
+
name: S.String,
|
|
17
18
|
}).pipe(
|
|
18
19
|
Type.def({
|
|
19
20
|
typename: 'example.com/type/Organization',
|
|
@@ -21,46 +22,31 @@ namespace Testing {
|
|
|
21
22
|
}),
|
|
22
23
|
);
|
|
23
24
|
|
|
24
|
-
export interface Organization extends
|
|
25
|
+
export interface Organization extends S.Schema.Type<typeof Organization> {}
|
|
25
26
|
|
|
26
|
-
export const
|
|
27
|
-
name:
|
|
28
|
-
dob:
|
|
29
|
-
email:
|
|
30
|
-
organization:
|
|
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
|
+
organization: S.optional(Type.Ref(Organization)),
|
|
31
32
|
}).pipe(
|
|
32
33
|
Type.def({
|
|
33
|
-
typename: 'example.com/type/
|
|
34
|
+
typename: 'example.com/type/Contact',
|
|
34
35
|
version: '0.1.0',
|
|
35
36
|
}),
|
|
36
37
|
);
|
|
37
38
|
|
|
38
|
-
export interface
|
|
39
|
+
export interface Contact extends S.Schema.Type<typeof Contact> {}
|
|
39
40
|
|
|
40
|
-
export const Message =
|
|
41
|
+
export const Message = S.Struct({
|
|
41
42
|
// TODO(burdon): Support S.Date; Custom Timestamp (with defaults).
|
|
42
43
|
// TODO(burdon): Support defaults (update create and create).
|
|
43
|
-
timestamp:
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
timestamp: S.String.pipe(
|
|
45
|
+
S.propertySignature,
|
|
46
|
+
S.withConstructorDefault(() => new Date().toISOString()),
|
|
46
47
|
),
|
|
47
48
|
});
|
|
48
49
|
|
|
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
|
-
|
|
64
50
|
// TODO(burdon): Fix (Type.def currently removes TypeLiteral that implements the `make` function)..
|
|
65
51
|
// }).pipe(
|
|
66
52
|
// Type.def({
|
|
@@ -69,31 +55,31 @@ namespace Testing {
|
|
|
69
55
|
// }),
|
|
70
56
|
// );
|
|
71
57
|
|
|
72
|
-
export interface Message extends
|
|
58
|
+
export interface Message extends S.Schema.Type<typeof Message> {}
|
|
73
59
|
}
|
|
74
60
|
|
|
75
61
|
describe('Experimental API review', () => {
|
|
76
62
|
test('type checks', ({ expect }) => {
|
|
77
|
-
const contact = Type.create(Testing.
|
|
78
|
-
const type:
|
|
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'));
|
|
79
65
|
|
|
80
|
-
expect(Type.getDXN(type)?.typename).to.eq(Testing.
|
|
81
|
-
expect(Type.getTypename(type)).to.eq('example.com/type/
|
|
66
|
+
expect(Type.getDXN(type)?.typename).to.eq(Testing.Contact.typename);
|
|
67
|
+
expect(Type.getTypename(type)).to.eq('example.com/type/Contact');
|
|
82
68
|
expect(Type.getVersion(type)).to.eq('0.1.0');
|
|
83
69
|
expect(Type.getMeta(type)).to.deep.eq({
|
|
84
70
|
kind: Type.Kind.Object,
|
|
85
|
-
typename: 'example.com/type/
|
|
71
|
+
typename: 'example.com/type/Contact',
|
|
86
72
|
version: '0.1.0',
|
|
87
73
|
});
|
|
88
74
|
});
|
|
89
75
|
|
|
90
76
|
test('instance checks', ({ expect }) => {
|
|
91
77
|
const organization = Type.create(Testing.Organization, { name: 'DXOS' });
|
|
92
|
-
const contact = Type.create(Testing.
|
|
78
|
+
const contact = Type.create(Testing.Contact, { name: 'Test', organization: Type.ref(organization) });
|
|
93
79
|
|
|
94
|
-
expect(
|
|
95
|
-
expect(Testing.
|
|
96
|
-
expect(Type.instanceOf(Testing.
|
|
80
|
+
expect(S.is(Testing.Contact)(contact)).to.be.true;
|
|
81
|
+
expect(Testing.Contact.instanceOf(contact)).to.be.true;
|
|
82
|
+
expect(Type.instanceOf(Testing.Contact, contact)).to.be.true;
|
|
97
83
|
expect(Type.instanceOf(Testing.Organization, organization)).to.be.true;
|
|
98
84
|
});
|
|
99
85
|
|
package/src/index.ts
CHANGED
|
@@ -2,4 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
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';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../../src/api/database.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,QAAQ,CAAC,GAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../src/api/queue.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,KAAK,CAAC,GAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,80 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/src/api/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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';
|
package/src/api/type.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
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
|
-
}
|
|
File without changes
|