@dxos/echo 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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 +26 -76
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +25 -77
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +26 -76
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/{experimental/database.d.ts → Database.d.ts} +1 -1
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/{experimental/queue.d.ts → Queue.d.ts} +1 -1
- package/dist/types/src/Queue.d.ts.map +1 -0
- package/dist/types/src/{experimental/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/{type/api.test.d.ts.map → api.test.d.ts.map} +1 -1
- package/dist/types/src/index.d.ts +6 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/{experimental/database.ts → Database.ts} +1 -1
- package/src/{experimental/queue.ts → Queue.ts} +1 -1
- package/src/Type.ts +99 -0
- package/src/api.test.ts +94 -0
- package/src/index.ts +7 -3
- package/dist/types/src/experimental/database.d.ts.map +0 -1
- package/dist/types/src/experimental/index.d.ts +0 -1
- package/dist/types/src/experimental/index.d.ts.map +0 -1
- package/dist/types/src/experimental/queue.d.ts.map +0 -1
- package/dist/types/src/experimental/space.d.ts.map +0 -1
- package/dist/types/src/type/Obj.d.ts +0 -12
- package/dist/types/src/type/Obj.d.ts.map +0 -1
- package/dist/types/src/type/Ref.d.ts +0 -3
- package/dist/types/src/type/Ref.d.ts.map +0 -1
- package/dist/types/src/type/Relation.d.ts +0 -16
- package/dist/types/src/type/Relation.d.ts.map +0 -1
- package/dist/types/src/type/Type.d.ts +0 -77
- package/dist/types/src/type/Type.d.ts.map +0 -1
- package/dist/types/src/type/index.d.ts +0 -5
- package/dist/types/src/type/index.d.ts.map +0 -1
- package/src/experimental/index.ts +0 -7
- package/src/type/Obj.ts +0 -18
- package/src/type/Ref.ts +0 -7
- package/src/type/Relation.ts +0 -17
- package/src/type/Type.ts +0 -134
- package/src/type/api.test.ts +0 -128
- package/src/type/index.ts +0 -8
- /package/dist/types/src/{type/api.test.d.ts → api.test.d.ts} +0 -0
- /package/src/{experimental/space.ts → Space.ts} +0 -0
|
@@ -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").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.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,MAAM,GAAG,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,QAAQ,CAAC,4DAAsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../../../src/api.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export { DXN }
|
|
3
|
-
export * from './
|
|
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';
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.7.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo",
|
|
3
|
-
"version": "0.8.2-
|
|
3
|
+
"version": "0.8.2-staging.7ac8446",
|
|
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-
|
|
27
|
-
"@dxos/echo-db": "0.8.2-
|
|
28
|
-
"@dxos/echo-
|
|
29
|
-
"@dxos/echo-
|
|
30
|
-
"@dxos/echo-signals": "0.8.2-
|
|
31
|
-
"@dxos/invariant": "0.8.2-
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
25
|
+
"effect": "3.13.3",
|
|
26
|
+
"@dxos/debug": "0.8.2-staging.7ac8446",
|
|
27
|
+
"@dxos/echo-db": "0.8.2-staging.7ac8446",
|
|
28
|
+
"@dxos/echo-schema": "0.8.2-staging.7ac8446",
|
|
29
|
+
"@dxos/echo-protocol": "0.8.2-staging.7ac8446",
|
|
30
|
+
"@dxos/echo-signals": "0.8.2-staging.7ac8446",
|
|
31
|
+
"@dxos/invariant": "0.8.2-staging.7ac8446",
|
|
32
|
+
"@dxos/effect": "0.8.2-staging.7ac8446",
|
|
33
|
+
"@dxos/keys": "0.8.2-staging.7ac8446",
|
|
34
|
+
"@dxos/live-object": "0.8.2-staging.7ac8446",
|
|
35
|
+
"@dxos/node-std": "0.8.2-staging.7ac8446",
|
|
36
|
+
"@dxos/util": "0.8.2-staging.7ac8446",
|
|
37
|
+
"@dxos/log": "0.8.2-staging.7ac8446"
|
|
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 { 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);
|
package/src/api.test.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
|
+
import { describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { raise } from '@dxos/debug';
|
|
9
|
+
import { FormatEnum, FormatAnnotation } from '@dxos/echo-schema';
|
|
10
|
+
|
|
11
|
+
// Deliberately testing top-level import as if external consumer for @dxos/echo.
|
|
12
|
+
import { Type } from '.';
|
|
13
|
+
|
|
14
|
+
namespace Testing {
|
|
15
|
+
export const Org = S.Struct({
|
|
16
|
+
id: Type.ObjectId,
|
|
17
|
+
name: S.String,
|
|
18
|
+
}).pipe(
|
|
19
|
+
Type.def({
|
|
20
|
+
typename: 'example.com/type/Org',
|
|
21
|
+
version: '0.1.0',
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export interface Org extends S.Schema.Type<typeof Org> {}
|
|
26
|
+
|
|
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)),
|
|
32
|
+
}).pipe(
|
|
33
|
+
Type.def({
|
|
34
|
+
typename: 'example.com/type/Contact',
|
|
35
|
+
version: '0.1.0',
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export interface Contact extends S.Schema.Type<typeof Contact> {}
|
|
40
|
+
|
|
41
|
+
export const Message = S.Struct({
|
|
42
|
+
// 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()),
|
|
47
|
+
),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// TODO(burdon): Fix (Type.def currently removes TypeLiteral that implements the `make` function)..
|
|
51
|
+
// }).pipe(
|
|
52
|
+
// Type.def({
|
|
53
|
+
// typename: 'example.com/type/Message',
|
|
54
|
+
// version: '0.1.0',
|
|
55
|
+
// }),
|
|
56
|
+
// );
|
|
57
|
+
|
|
58
|
+
export interface Message extends S.Schema.Type<typeof Message> {}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe('Experimental API review', () => {
|
|
62
|
+
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'));
|
|
65
|
+
|
|
66
|
+
expect(Type.getDXN(type)?.typename).to.eq(Testing.Contact.typename);
|
|
67
|
+
expect(Type.getTypename(type)).to.eq('example.com/type/Contact');
|
|
68
|
+
expect(Type.getVersion(type)).to.eq('0.1.0');
|
|
69
|
+
expect(Type.getMeta(type)).to.deep.eq({
|
|
70
|
+
kind: Type.Kind.Object,
|
|
71
|
+
typename: 'example.com/type/Contact',
|
|
72
|
+
version: '0.1.0',
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
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;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('default props', ({ expect }) => {
|
|
89
|
+
// TODO(burdon): Doesn't work after pipe(Type.def).
|
|
90
|
+
// Property 'make' does not exist on type 'EchoObjectSchema<Struct<{ timestamp: PropertySignature<":", string, never, ":", string, true, never>; }>>'.ts(2339)
|
|
91
|
+
const message = Type.create(Testing.Message, Testing.Message.make({}));
|
|
92
|
+
expect(message.timestamp).to.exist;
|
|
93
|
+
});
|
|
94
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export { DXN } from '@dxos/keys';
|
|
5
|
+
import { DXN } from '@dxos/keys';
|
|
7
6
|
|
|
8
|
-
export
|
|
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/experimental/database.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,QAAQ,CAAC,GAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/experimental/index.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../src/experimental/queue.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,KAAK,CAAC,GAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../../src/experimental/space.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC,GAAE"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';
|
|
2
|
-
import { type BaseEchoObject, type BaseObject } from '@dxos/echo-schema';
|
|
3
|
-
export declare namespace Obj {
|
|
4
|
-
type Any = BaseEchoObject;
|
|
5
|
-
type Live<T extends BaseObject> = AnyLiveObject$<T>;
|
|
6
|
-
}
|
|
7
|
-
export declare const create: {
|
|
8
|
-
<T extends BaseObject>(obj: T): import("@dxos/live-object").Live<T>;
|
|
9
|
-
<T extends BaseObject>(schema: import("effect/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>;
|
|
10
|
-
};
|
|
11
|
-
export declare const getSchema: (obj: unknown | undefined) => import("effect/Schema").Schema.AnyNoContext | undefined;
|
|
12
|
-
//# sourceMappingURL=Obj.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Obj.d.ts","sourceRoot":"","sources":["../../../../src/type/Obj.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAA2B,MAAM,mBAAmB,CAAC;AAKlG,MAAM,CAAC,OAAO,WAAW,GAAG,CAAC;IAC3B,KAAY,GAAG,GAAG,cAAc,CAAC;IACjC,KAAY,IAAI,CAAC,CAAC,SAAS,UAAU,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;CAC5D;AAED,eAAO,MAAM,MAAM;;;CAAQ,CAAC;AAE5B,eAAO,MAAM,SAAS,uFAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../../../../src/type/Ref.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEhD,eAAO,MAAM,IAAI,sEAAY,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type RelationSourceTargetRefs } from '@dxos/echo-schema';
|
|
2
|
-
export declare const def: <TSource extends import("effect/Schema").Schema.AnyNoContext, TTarget extends import("effect/Schema").Schema.AnyNoContext>(options: {
|
|
3
|
-
typename: string;
|
|
4
|
-
version: string;
|
|
5
|
-
source: TSource;
|
|
6
|
-
target: TTarget;
|
|
7
|
-
}) => <Self extends import("effect/Schema").Schema.Any>(self: Self) => import("@dxos/echo-schema").EchoTypeSchema<Self, RelationSourceTargetRefs<import("effect/Schema").Schema.Type<TSource>, import("effect/Schema").Schema.Type<TTarget>>>;
|
|
8
|
-
/**
|
|
9
|
-
* Get relation target type.
|
|
10
|
-
*/
|
|
11
|
-
export type Target<A> = A extends RelationSourceTargetRefs<infer T, infer _S> ? T : never;
|
|
12
|
-
/**
|
|
13
|
-
* Get relation source type.
|
|
14
|
-
*/
|
|
15
|
-
export type Source<A> = A extends RelationSourceTargetRefs<infer _T, infer S> ? S : never;
|
|
16
|
-
//# sourceMappingURL=Relation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Relation.d.ts","sourceRoot":"","sources":["../../../../src/type/Relation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,eAAO,MAAM,GAAG;;;;;6OAAe,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,wBAAwB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,wBAAwB,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -1,77 +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$, 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 const SpaceId: Schema.Schema<SpaceId$, string, never> & {
|
|
12
|
-
byteLength: number;
|
|
13
|
-
encode: (value: Uint8Array) => SpaceId$;
|
|
14
|
-
decode: (value: SpaceId$) => Uint8Array;
|
|
15
|
-
isValid: (value: string) => value is SpaceId$;
|
|
16
|
-
random: () => SpaceId$;
|
|
17
|
-
};
|
|
18
|
-
export type SpaceId = SpaceId$;
|
|
19
|
-
export declare const ObjectId: import("@dxos/echo-schema").ObjectIdClass;
|
|
20
|
-
export type ObjectId = ObjectId$;
|
|
21
|
-
/**
|
|
22
|
-
* Defines a reference to an ECHO object.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { Type } from '@dxos/echo';
|
|
27
|
-
* const Person = Schema.Struct({
|
|
28
|
-
* name: Schema.String,
|
|
29
|
-
* organization: Type.Ref(Organization),
|
|
30
|
-
* }).pipe(Type.def({
|
|
31
|
-
* typename: 'example.com/type/Person',
|
|
32
|
-
* version: '0.1.0',
|
|
33
|
-
* }));
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare const Ref: <S extends Schema.Schema.AnyNoContext>(self: S) => import("@dxos/echo-schema").Ref$<Schema.Schema.Type<S>>;
|
|
37
|
-
export declare const Kind: typeof EntityKind;
|
|
38
|
-
export type AnyObject = BaseEchoObject;
|
|
39
|
-
export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;
|
|
40
|
-
export type JsonSchema = JsonSchemaType;
|
|
41
|
-
/**
|
|
42
|
-
* A schema that can be extended with arbitrary properties.
|
|
43
|
-
*/
|
|
44
|
-
export declare const Expando: Schema.Schema<Expando$, Expando$, never>;
|
|
45
|
-
export type Expando = Expando$;
|
|
46
|
-
export type Abstract<T = any> = BaseSchema<T>;
|
|
47
|
-
export type ImmutableType<T> = ImmutableSchema<T>;
|
|
48
|
-
export type MutableType<T> = EchoSchema<T>;
|
|
49
|
-
export type StoredType = StoredSchema;
|
|
50
|
-
/**
|
|
51
|
-
* Defines an ECHO type.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* import { Type } from '@dxos/echo';
|
|
56
|
-
* const Organization = Schema.Struct({
|
|
57
|
-
* name: Schema.String,
|
|
58
|
-
* }).pipe(Type.def({
|
|
59
|
-
* typename: 'example.com/type/Organization',
|
|
60
|
-
* version: '0.1.0',
|
|
61
|
-
* }));
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export declare const def: (meta: TypeMeta) => <Self extends Schema.Schema.Any>(self: Self) => import("@dxos/echo-schema").EchoTypeSchema<Self>;
|
|
65
|
-
export declare const create: {
|
|
66
|
-
<T extends BaseObject>(obj: T): import("@dxos/live-object").Live<T>;
|
|
67
|
-
<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>;
|
|
68
|
-
};
|
|
69
|
-
export declare const getSchema: (obj: unknown | undefined) => Schema.Schema.AnyNoContext | undefined;
|
|
70
|
-
export declare const instanceOf: <Schema extends Schema.Schema.AnyNoContext>(schema: Schema, object: any) => object is Schema.Schema.Type<Schema>;
|
|
71
|
-
export declare const getDXN: (schema: Schema.Schema.All) => import("@dxos/keys").DXN | undefined;
|
|
72
|
-
export declare const getMeta: (schema: Schema.Schema.All) => import("@dxos/echo-schema").TypeAnnotation | undefined;
|
|
73
|
-
export declare const getTypename: (schema: Schema.Schema.AnyNoContext) => string;
|
|
74
|
-
export declare const getVersion: (schema: Schema.Schema.All) => string | undefined;
|
|
75
|
-
export declare const isMutable: (schema: Schema.Schema.AnyNoContext) => boolean;
|
|
76
|
-
export declare const toJsonSchema: (schema: Schema.Schema.All) => JsonSchemaType;
|
|
77
|
-
//# sourceMappingURL=Type.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Type.d.ts","sourceRoot":"","sources":["../../../../src/type/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,EAErB,KAAK,YAAY,EACjB,KAAK,QAAQ,EASd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;GAKG;AAMH,eAAO,MAAM,OAAO;;;;;;CAAW,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC;AAE/B,eAAO,MAAM,QAAQ,2CAAY,CAAC;AAClC,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC;AAEjC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,4DAAsC,CAAC;AAMxG,eAAO,MAAM,IAAI,mBAAa,CAAC;AAC/B,MAAM,MAAM,SAAS,GAAG,cAAc,C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IAAI,MAAM,QAAQ,CAAC"}
|
package/src/type/Obj.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';
|
|
6
|
-
import { type BaseEchoObject, type BaseObject, getSchema as getSchema$ } from '@dxos/echo-schema';
|
|
7
|
-
import { live as live$ } from '@dxos/live-object';
|
|
8
|
-
|
|
9
|
-
// TODO(burdon): Remove from Type?
|
|
10
|
-
|
|
11
|
-
export declare namespace Obj {
|
|
12
|
-
export type Any = BaseEchoObject;
|
|
13
|
-
export type Live<T extends BaseObject> = AnyLiveObject$<T>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const create = live$;
|
|
17
|
-
|
|
18
|
-
export const getSchema = getSchema$;
|
package/src/type/Ref.ts
DELETED
package/src/type/Relation.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { EchoRelation, type RelationSourceTargetRefs } from '@dxos/echo-schema';
|
|
6
|
-
|
|
7
|
-
export const def = EchoRelation;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Get relation target type.
|
|
11
|
-
*/
|
|
12
|
-
export type Target<A> = A extends RelationSourceTargetRefs<infer T, infer _S> ? T : never;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get relation source type.
|
|
16
|
-
*/
|
|
17
|
-
export type Source<A> = A extends RelationSourceTargetRefs<infer _T, infer S> ? S : never;
|