@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/src/type/Type.ts DELETED
@@ -1,134 +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
- type StoredSchema,
21
- type TypeMeta,
22
- getTypeAnnotation,
23
- getSchema as getSchema$,
24
- getSchemaDXN,
25
- getSchemaTypename,
26
- getSchemaVersion,
27
- isInstanceOf,
28
- isMutable as isMutable$,
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
- /**
36
- * Type System API.
37
- *
38
- * @category api namespace
39
- * @since 0.9.0
40
- */
41
-
42
- //
43
- // Keys
44
- //
45
-
46
- export const SpaceId = SpaceId$;
47
- export type SpaceId = SpaceId$;
48
-
49
- export const ObjectId = ObjectId$;
50
- export type ObjectId = ObjectId$;
51
-
52
- /**
53
- * Defines a reference to an ECHO object.
54
- *
55
- * @example
56
- * ```ts
57
- * import { Type } from '@dxos/echo';
58
- * const Person = Schema.Struct({
59
- * name: Schema.String,
60
- * organization: Type.Ref(Organization),
61
- * }).pipe(Type.def({
62
- * typename: 'example.com/type/Person',
63
- * version: '0.1.0',
64
- * }));
65
- * ```
66
- */
67
- export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);
68
-
69
- //
70
- // Objects
71
- //
72
-
73
- export const Kind = EntityKind;
74
- export type AnyObject = BaseEchoObject;
75
- export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;
76
-
77
- //
78
- // Schema
79
- //
80
-
81
- export type JsonSchema = JsonSchemaType;
82
-
83
- /**
84
- * A schema that can be extended with arbitrary properties.
85
- */
86
- export const Expando = Expando$;
87
- export type Expando = Expando$;
88
-
89
- // TODO(burdon): Review/remove.
90
- export type Abstract<T = any> = BaseSchema<T>;
91
- export type ImmutableType<T> = ImmutableSchema<T>;
92
- export type MutableType<T> = EchoSchema<T>;
93
- export type StoredType = StoredSchema;
94
-
95
- /**
96
- * Defines an ECHO type.
97
- *
98
- * @example
99
- * ```ts
100
- * import { Type } from '@dxos/echo';
101
- * const Organization = Schema.Struct({
102
- * name: Schema.String,
103
- * }).pipe(Type.def({
104
- * typename: 'example.com/type/Organization',
105
- * version: '0.1.0',
106
- * }));
107
- * ```
108
- */
109
- export const def = (meta: TypeMeta) => EchoObject(meta);
110
-
111
- //
112
- // Object utils
113
- //
114
-
115
- export const create = live$;
116
-
117
- export const getSchema = getSchema$;
118
- export const instanceOf = isInstanceOf;
119
-
120
- //
121
- // Type utils
122
- //
123
-
124
- // TODO(burdon): Reconcile getDXN and getTypename.
125
- export const getDXN = getSchemaDXN;
126
- export const getMeta = getTypeAnnotation;
127
- export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {
128
- const typename = getSchemaTypename(schema);
129
- invariant(typename, 'Invalid object');
130
- return typename;
131
- };
132
- export const getVersion = getSchemaVersion;
133
- export const isMutable = isMutable$;
134
- export const toJsonSchema = toJsonSchema$;
package/src/type/index.ts DELETED
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- export * as Obj from './Obj';
6
- export * as Ref from './Ref';
7
- export * as Relation from './Relation';
8
- export * as Type from './Type';
File without changes