@dxos/echo 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (44) hide show
  1. package/README.md +116 -0
  2. package/dist/lib/browser/index.mjs +224 -65
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node/index.cjs +223 -60
  6. package/dist/lib/node/index.cjs.map +4 -4
  7. package/dist/lib/node/meta.json +1 -1
  8. package/dist/lib/node-esm/index.mjs +224 -65
  9. package/dist/lib/node-esm/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/meta.json +1 -1
  11. package/dist/types/src/Obj.d.ts +39 -0
  12. package/dist/types/src/Obj.d.ts.map +1 -0
  13. package/dist/types/src/Ref.d.ts +11 -0
  14. package/dist/types/src/Ref.d.ts.map +1 -0
  15. package/dist/types/src/Relation.d.ts +19 -0
  16. package/dist/types/src/Relation.d.ts.map +1 -0
  17. package/dist/types/src/Type.d.ts +87 -0
  18. package/dist/types/src/Type.d.ts.map +1 -0
  19. package/dist/types/src/index.d.ts +6 -3
  20. package/dist/types/src/index.d.ts.map +1 -1
  21. package/dist/types/src/{type → test}/api.test.d.ts.map +1 -1
  22. package/package.json +13 -14
  23. package/src/Obj.ts +86 -0
  24. package/src/Ref.ts +21 -0
  25. package/src/Relation.ts +45 -0
  26. package/src/Type.ts +127 -0
  27. package/src/index.ts +6 -3
  28. package/src/{type → test}/api.test.ts +14 -14
  29. package/dist/types/src/type/Obj.d.ts +0 -12
  30. package/dist/types/src/type/Obj.d.ts.map +0 -1
  31. package/dist/types/src/type/Ref.d.ts +0 -3
  32. package/dist/types/src/type/Ref.d.ts.map +0 -1
  33. package/dist/types/src/type/Relation.d.ts +0 -16
  34. package/dist/types/src/type/Relation.d.ts.map +0 -1
  35. package/dist/types/src/type/Type.d.ts +0 -77
  36. package/dist/types/src/type/Type.d.ts.map +0 -1
  37. package/dist/types/src/type/index.d.ts +0 -5
  38. package/dist/types/src/type/index.d.ts.map +0 -1
  39. package/src/type/Obj.ts +0 -18
  40. package/src/type/Ref.ts +0 -7
  41. package/src/type/Relation.ts +0 -17
  42. package/src/type/Type.ts +0 -134
  43. package/src/type/index.ts +0 -8
  44. /package/dist/types/src/{type → test}/api.test.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo",
3
- "version": "0.8.2-main.fbd8ed0",
3
+ "version": "0.8.2-staging.42af850",
4
4
  "description": "ECHO API",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -21,20 +21,19 @@
21
21
  "src"
22
22
  ],
23
23
  "dependencies": {
24
- "@preact/signals-core": "^1.6.0",
24
+ "@preact/signals-core": "^1.9.0",
25
25
  "effect": "3.14.21",
26
- "@dxos/debug": "0.8.2-main.fbd8ed0",
27
- "@dxos/echo-db": "0.8.2-main.fbd8ed0",
28
- "@dxos/echo-protocol": "0.8.2-main.fbd8ed0",
29
- "@dxos/echo-schema": "0.8.2-main.fbd8ed0",
30
- "@dxos/echo-signals": "0.8.2-main.fbd8ed0",
31
- "@dxos/invariant": "0.8.2-main.fbd8ed0",
32
- "@dxos/keys": "0.8.2-main.fbd8ed0",
33
- "@dxos/live-object": "0.8.2-main.fbd8ed0",
34
- "@dxos/log": "0.8.2-main.fbd8ed0",
35
- "@dxos/effect": "0.8.2-main.fbd8ed0",
36
- "@dxos/node-std": "0.8.2-main.fbd8ed0",
37
- "@dxos/util": "0.8.2-main.fbd8ed0"
26
+ "@dxos/debug": "0.8.2-staging.42af850",
27
+ "@dxos/echo-protocol": "0.8.2-staging.42af850",
28
+ "@dxos/effect": "0.8.2-staging.42af850",
29
+ "@dxos/echo-schema": "0.8.2-staging.42af850",
30
+ "@dxos/echo-signals": "0.8.2-staging.42af850",
31
+ "@dxos/invariant": "0.8.2-staging.42af850",
32
+ "@dxos/keys": "0.8.2-staging.42af850",
33
+ "@dxos/live-object": "0.8.2-staging.42af850",
34
+ "@dxos/log": "0.8.2-staging.42af850",
35
+ "@dxos/node-std": "0.8.2-staging.42af850",
36
+ "@dxos/util": "0.8.2-staging.42af850"
38
37
  },
39
38
  "publishConfig": {
40
39
  "access": "public"
package/src/Obj.ts ADDED
@@ -0,0 +1,86 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Schema } from 'effect';
6
+
7
+ import * as EchoSchema from '@dxos/echo-schema';
8
+ import { assertArgument, invariant } from '@dxos/invariant';
9
+ import type { DXN } from '@dxos/keys';
10
+ import * as LiveObject from '@dxos/live-object';
11
+
12
+ import type * as Type from './Type';
13
+
14
+ export type Any = EchoSchema.AnyEchoObject;
15
+
16
+ export const make = LiveObject.live;
17
+
18
+ // TODO(dmaretskyi): Currently broken
19
+ export const isObject = (obj: unknown): obj is Any => {
20
+ return LiveObject.isLiveObject(obj);
21
+ };
22
+
23
+ /**
24
+ * Check that object or relation is an instance of a schema.
25
+ * @example
26
+ * ```ts
27
+ * const person = Obj.make(Person, { name: 'John' });
28
+ * const isPerson = Obj.instanceOf(Person);
29
+ * isPerson(person); // true
30
+ * ```
31
+ */
32
+ export const instanceOf: {
33
+ <S extends Type.Relation.Any | Type.Obj.Any>(schema: S): (value: unknown) => value is S;
34
+ <S extends Type.Relation.Any | Type.Obj.Any>(schema: S, value: unknown): value is S;
35
+ } = ((...args: any[]) => {
36
+ if (args.length === 1) {
37
+ return (obj: unknown) => EchoSchema.isInstanceOf(args[0], obj);
38
+ }
39
+
40
+ return EchoSchema.isInstanceOf(args[0], args[1]);
41
+ }) as any;
42
+
43
+ export const getSchema = EchoSchema.getSchema;
44
+
45
+ export const getDXN = (obj: Any): DXN => {
46
+ assertArgument(!Schema.isSchema(obj), 'Object should not be a schema.');
47
+ const dxn = EchoSchema.getDXN(obj);
48
+ invariant(dxn != null, 'Invalid object.');
49
+ return dxn;
50
+ };
51
+
52
+ /**
53
+ * @returns The DXN of the object's type.
54
+ * @example dxn:example.com/type/Contact:1.0.0
55
+ */
56
+ export const getSchemaDXN = (obj: Any): DXN => {
57
+ const type = EchoSchema.getType(obj);
58
+ invariant(type != null, 'Invalid object.');
59
+ return type;
60
+ };
61
+
62
+ /**
63
+ * @returns The typename of the object's type.
64
+ * @example `example.com/type/Contact`
65
+ */
66
+ export const getTypename = (obj: Any): string | undefined => {
67
+ const schema = getSchema(obj);
68
+ if (schema == null) {
69
+ // Try to extract typename from DXN.
70
+ return getSchemaDXN(obj)?.asTypeDXN()?.type;
71
+ }
72
+
73
+ return EchoSchema.getTypename(schema);
74
+ };
75
+
76
+ export const getMeta = (obj: Any): EchoSchema.ObjectMeta => {
77
+ const meta = EchoSchema.getMeta(obj);
78
+ invariant(meta != null, 'Invalid object.');
79
+ return meta;
80
+ };
81
+
82
+ export const isDeleted = (obj: Any): boolean => {
83
+ const deleted = EchoSchema.isDeleted(obj);
84
+ invariant(typeof deleted === 'boolean', 'Invalid object.');
85
+ return deleted;
86
+ };
package/src/Ref.ts ADDED
@@ -0,0 +1,21 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as EchoSchema from '@dxos/echo-schema';
6
+
7
+ import type * as Obj from './Obj';
8
+
9
+ export type Any = EchoSchema.Ref<Obj.Any>;
10
+
11
+ export const make = EchoSchema.Ref.make;
12
+
13
+ export const isRef: (value: unknown) => value is Any = EchoSchema.Ref.isRef;
14
+
15
+ // TODO(dmaretskyi): Consider just allowing `make` to accept DXN.
16
+ export const fromDXN = EchoSchema.Ref.fromDXN;
17
+
18
+ /**
19
+ * Extract reference target.
20
+ */
21
+ export type Target<R extends Any> = R extends EchoSchema.Ref<infer T> ? T : never;
@@ -0,0 +1,45 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as EchoSchema from '@dxos/echo-schema';
6
+ import { invariant } from '@dxos/invariant';
7
+ import * as LiveObject from '@dxos/live-object';
8
+
9
+ export type Any = EchoSchema.AnyEchoObject & EchoSchema.RelationSourceTargetRefs;
10
+
11
+ export const make = LiveObject.live;
12
+
13
+ export const isRelation = (value: unknown): value is Any => {
14
+ if (typeof value !== 'object' || value === null) {
15
+ return false;
16
+ }
17
+ if (EchoSchema.ATTR_RELATION_SOURCE in value || EchoSchema.ATTR_RELATION_TARGET in value) {
18
+ return true;
19
+ }
20
+
21
+ const kind = (value as any)[EchoSchema.EntityKindPropertyId];
22
+ return kind === EchoSchema.EntityKind.Relation;
23
+ };
24
+
25
+ /**
26
+ * @returns Relation source.
27
+ * @throws If the object is not a relation.
28
+ */
29
+ export const getSource = <T extends Any>(relation: T): EchoSchema.RelationSource<T> => {
30
+ invariant(isRelation(relation));
31
+ const obj = relation[EchoSchema.RelationSourceId];
32
+ invariant(obj !== undefined, `Invalid source: ${relation.id}`);
33
+ return obj;
34
+ };
35
+
36
+ /**
37
+ * @returns Relation target.
38
+ * @throws If the object is not a relation.
39
+ */
40
+ export const getTarget = <T extends Any>(relation: T): EchoSchema.RelationTarget<T> => {
41
+ invariant(isRelation(relation));
42
+ const obj = relation[EchoSchema.RelationTargetId];
43
+ invariant(obj !== undefined, `Invalid target: ${relation.id}`);
44
+ return obj;
45
+ };
package/src/Type.ts ADDED
@@ -0,0 +1,127 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Schema } from 'effect';
6
+
7
+ import type { EncodedReference } from '@dxos/echo-protocol';
8
+ import * as EchoSchema from '@dxos/echo-schema';
9
+ import { invariant } from '@dxos/invariant';
10
+ import type * as Keys from '@dxos/keys';
11
+
12
+ /**
13
+ * ECHO schema.
14
+ */
15
+ export type Schema = EchoSchema.EchoSchema;
16
+
17
+ /**
18
+ * EchoObject schema.
19
+ */
20
+ export const Obj = EchoSchema.EchoObject;
21
+
22
+ /**
23
+ * EchoRelation schema.
24
+ */
25
+ export const Relation = EchoSchema.EchoRelation;
26
+
27
+ /**
28
+ * Ref schema.
29
+ */
30
+ export const Ref: <S extends Obj.Any>(schema: S) => EchoSchema.Ref$<Schema.Schema.Type<S>> = EchoSchema.Ref;
31
+
32
+ export namespace Obj {
33
+ /**
34
+ * Type that represents an arbitrary schema type of an object.
35
+ * NOTE: This is not an instance type.
36
+ */
37
+ // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
38
+ export type Any = Schema.Schema.AnyNoContext;
39
+ }
40
+
41
+ export namespace Relation {
42
+ /**
43
+ * Type that represents an arbitrary schema type of a relation.
44
+ * NOTE: This is not an instance type.
45
+ */
46
+ // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
47
+ export type Any = Schema.Schema.AnyNoContext;
48
+
49
+ /**
50
+ * Get relation target type.
51
+ */
52
+ export type Target<A> = A extends EchoSchema.RelationSourceTargetRefs<infer T, infer _S> ? T : never;
53
+
54
+ /**
55
+ * Get relation source type.
56
+ */
57
+ export type Source<A> = A extends EchoSchema.RelationSourceTargetRefs<infer _T, infer S> ? S : never;
58
+ }
59
+
60
+ export namespace Ref {
61
+ /**
62
+ * Type that represents an arbitrary schema type of a reference.
63
+ * NOTE: This is not an instance type.
64
+ */
65
+ export type Any = Schema.Schema<EchoSchema.Ref<any>, EncodedReference>;
66
+ }
67
+
68
+ /**
69
+ * Gets the full DXN of the schema.
70
+ * Will include the version if it's a `type` DXN.
71
+ * @example "dxn:example.com/type/Person:0.1.0"
72
+ * @example "dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX"
73
+ */
74
+ export const getDXN = (schema: Obj.Any | Relation.Any): Keys.DXN | undefined => {
75
+ return EchoSchema.getSchemaDXN(schema);
76
+ };
77
+
78
+ /**
79
+ * @param schema - Schema to get the typename from.
80
+ * @returns The typename of the schema. Example: `example.com/type/Person`.
81
+ */
82
+ export const getTypename = (schema: Obj.Any | Relation.Any): string => {
83
+ const typename = EchoSchema.getSchemaTypename(schema);
84
+ invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');
85
+ return typename;
86
+ };
87
+
88
+ /**
89
+ * Gets the version of the schema.
90
+ * @example 0.1.0
91
+ */
92
+ export const getVersion = (schema: Obj.Any | Relation.Any): string => {
93
+ const version = EchoSchema.getSchemaVersion(schema);
94
+ invariant(typeof version === 'string' && version.match(/^\d+\.\d+\.\d+$/), 'Invalid version');
95
+ return version;
96
+ };
97
+
98
+ /**
99
+ * ECHO type metadata.
100
+ */
101
+ export type Meta = EchoSchema.TypeAnnotation;
102
+
103
+ /**
104
+ * Gets the meta data of the schema.
105
+ */
106
+ export const getMeta = (schema: Obj.Any | Relation.Any): Meta | undefined => {
107
+ return EchoSchema.getTypeAnnotation(schema);
108
+ };
109
+
110
+ export { EntityKind as Kind } from '@dxos/echo-schema';
111
+
112
+ /**
113
+ * @returns True if the schema is mutable.
114
+ */
115
+ export const isMutable = (schema: Obj.Any | Relation.Any): boolean => {
116
+ return EchoSchema.isMutable(schema);
117
+ };
118
+
119
+ export { SpaceId, ObjectId, DXN } from '@dxos/keys';
120
+
121
+ export {
122
+ //
123
+ Expando,
124
+ JsonSchemaType as JsonSchema,
125
+ toJsonSchema,
126
+ Format,
127
+ } from '@dxos/echo-schema';
package/src/index.ts CHANGED
@@ -2,7 +2,10 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export { Format, FormatEnum } from '@dxos/echo-schema';
6
- export { DXN } from '@dxos/keys';
5
+ export * as Type from './Type';
6
+ export * as Obj from './Obj';
7
+ export * as Relation from './Relation';
8
+ export * as Ref from './Ref';
7
9
 
8
- export * from './type';
10
+ export { type Live } from '@dxos/live-object';
11
+ export { Filter, Query } from '@dxos/echo-schema';
@@ -8,14 +8,14 @@ import { describe, test } from 'vitest';
8
8
  import { raise } from '@dxos/debug';
9
9
  import { FormatEnum, FormatAnnotation } from '@dxos/echo-schema';
10
10
 
11
- import { Obj, Ref, Type } from '.';
11
+ import { Obj, Ref, Type, type Live } from '../index';
12
12
 
13
13
  namespace Testing {
14
14
  export const Organization = Schema.Struct({
15
15
  id: Type.ObjectId,
16
16
  name: Schema.String,
17
17
  }).pipe(
18
- Type.def({
18
+ Type.Obj({
19
19
  typename: 'example.com/type/Organization',
20
20
  version: '0.1.0',
21
21
  }),
@@ -29,7 +29,7 @@ namespace Testing {
29
29
  email: Schema.optional(Schema.String.pipe(FormatAnnotation.set(FormatEnum.Email))),
30
30
  organization: Schema.optional(Type.Ref(Organization)),
31
31
  }).pipe(
32
- Type.def({
32
+ Type.Obj({
33
33
  typename: 'example.com/type/Person',
34
34
  version: '0.1.0',
35
35
  }),
@@ -45,7 +45,7 @@ namespace Testing {
45
45
  // ...Provenance({ source: 'duckduckgo.com', confidence: 0.9 }), // keys
46
46
  // ...Relation.make({ source: Contact, target: Organization }),
47
47
  // }).pipe(
48
- // Relation.def({
48
+ // Type.Relation({
49
49
  // typename: 'example.com/relation/WorksFor',
50
50
  // version: '0.1.0',
51
51
  // }),
@@ -61,8 +61,8 @@ namespace Testing {
61
61
  // id: Type.ObjectId,
62
62
  role: Schema.String,
63
63
  }).pipe(
64
- // Relation.def
65
- Type.def({
64
+ // Type.Relation
65
+ Type.Obj({
66
66
  typename: 'example.com/type/WorksFor',
67
67
  version: '0.1.0',
68
68
  // source: Person,
@@ -72,7 +72,7 @@ namespace Testing {
72
72
 
73
73
  export interface WorksFor extends Schema.Schema.Type<typeof WorksFor> {}
74
74
 
75
- // TODO(burdon): Fix (Type.def currently removes TypeLiteral that implements the `make` function).
75
+ // TODO(burdon): Fix (Type.Obj currently removes TypeLiteral that implements the `make` function).
76
76
  // Property 'make' does not exist on type 'EchoObjectSchema<Struct<{ timestamp: PropertySignature<":", string, never, ":", string, true, never>; }>>'.ts(2339)
77
77
  export const MessageStruct = Schema.Struct({
78
78
  // TODO(burdon): Support S.Date; Custom Timestamp (with defaults).
@@ -84,7 +84,7 @@ namespace Testing {
84
84
  });
85
85
 
86
86
  export const Message = MessageStruct.pipe(
87
- Type.def({
87
+ Type.Obj({
88
88
  typename: 'example.com/type/Message',
89
89
  version: '0.1.0',
90
90
  }),
@@ -95,7 +95,7 @@ namespace Testing {
95
95
 
96
96
  describe('Experimental API review', () => {
97
97
  test('type checks', ({ expect }) => {
98
- const contact = Obj.create(Testing.Person, { name: 'Test' });
98
+ const contact = Obj.make(Testing.Person, { name: 'Test' });
99
99
  const type: Schema.Schema<Testing.Person> = Obj.getSchema(contact) ?? raise(new Error('No schema found'));
100
100
 
101
101
  expect(Type.getDXN(type)?.typename).to.eq(Testing.Person.typename);
@@ -109,20 +109,20 @@ describe('Experimental API review', () => {
109
109
  });
110
110
 
111
111
  test('instance checks', ({ expect }) => {
112
- const organization: Obj.Obj.Live<Testing.Organization> = Obj.create(Testing.Organization, { name: 'DXOS' });
113
- const contact: Obj.Obj.Live<Testing.Person> = Obj.create(Testing.Person, {
112
+ const organization: Live<Testing.Organization> = Obj.make(Testing.Organization, { name: 'DXOS' });
113
+ const contact: Live<Testing.Person> = Obj.make(Testing.Person, {
114
114
  name: 'Test',
115
115
  organization: Ref.make(organization),
116
116
  });
117
117
 
118
118
  expect(Schema.is(Testing.Person)(contact)).to.be.true;
119
119
  expect(Testing.Person.instanceOf(contact)).to.be.true;
120
- expect(Type.instanceOf(Testing.Person, contact)).to.be.true;
121
- expect(Type.instanceOf(Testing.Organization, organization)).to.be.true;
120
+ expect(Obj.instanceOf(Testing.Person)(contact)).to.be.true;
121
+ expect(Obj.instanceOf(Testing.Organization)(organization)).to.be.true;
122
122
  });
123
123
 
124
124
  test('default props', ({ expect }) => {
125
- const message = Obj.create(Testing.Message, Testing.MessageStruct.make({}));
125
+ const message = Obj.make(Testing.Message, Testing.MessageStruct.make({}));
126
126
  expect(message.timestamp).to.exist;
127
127
  });
128
128
  });
@@ -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,3 +0,0 @@
1
- import { Ref as Ref$ } from '@dxos/echo-schema';
2
- export declare const make: <T extends import("@dxos/echo-schema").WithId>(object: T) => Ref$<T>;
3
- //# sourceMappingURL=Ref.d.ts.map
@@ -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,CAAC;AACvC,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;AAMpE,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,OAAO,0CAAW,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC;AAG/B,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AAC9C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;AAClD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;AAC3C,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC;AAEtC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,GAAG,GAAI,MAAM,QAAQ,qGAAqB,CAAC;AAMxD,eAAO,MAAM,MAAM;;;CAAQ,CAAC;AAE5B,eAAO,MAAM,SAAS,sEAAa,CAAC;AACpC,eAAO,MAAM,UAAU,kHAAe,CAAC;AAOvC,eAAO,MAAM,MAAM,qEAAe,CAAC;AACnC,eAAO,MAAM,OAAO,uFAAoB,CAAC;AACzC,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,YAAY,KAAG,MAIhE,CAAC;AACF,eAAO,MAAM,UAAU,mDAAmB,CAAC;AAC3C,eAAO,MAAM,SAAS,iDAAa,CAAC;AACpC,eAAO,MAAM,YAAY,+CAAgB,CAAC"}
@@ -1,5 +0,0 @@
1
- export * as Obj from './Obj';
2
- export * as Ref from './Ref';
3
- export * as Relation from './Relation';
4
- export * as Type from './Type';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/type/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,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
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Ref as Ref$ } from '@dxos/echo-schema';
6
-
7
- export const make = Ref$.make;
@@ -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;