@dxos/echo 0.8.4-main.5ea62a8 → 0.8.4-main.72ec0f3
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/chunk-BIDAASFK.mjs +3727 -0
- package/dist/lib/browser/chunk-BIDAASFK.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs +410 -0
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs +585 -0
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +17 -4
- package/dist/lib/browser/internal/index.mjs +336 -0
- package/dist/lib/browser/internal/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/query/index.mjs +13 -0
- package/dist/lib/browser/query/index.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +231 -34
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs +3727 -0
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs +585 -0
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs +410 -0
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +17 -4
- package/dist/lib/node-esm/internal/index.mjs +336 -0
- package/dist/lib/node-esm/internal/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/query/index.mjs +13 -0
- package/dist/lib/node-esm/query/index.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +231 -34
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/Obj.d.ts +70 -8
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +1 -1
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +5 -4
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +17 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +16 -17
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +68 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/ast/annotation-helper.d.ts +8 -0
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +1 -0
- package/dist/types/src/internal/ast/annotations.d.ts +131 -0
- package/dist/types/src/internal/ast/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/ast/annotations.test.d.ts +2 -0
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/ast/entity-kind.d.ts +10 -0
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +1 -0
- package/dist/types/src/internal/ast/index.d.ts +5 -0
- package/dist/types/src/internal/ast/index.d.ts.map +1 -0
- package/dist/types/src/internal/ast/types.d.ts +6 -0
- package/dist/types/src/internal/ast/types.d.ts.map +1 -0
- package/dist/types/src/internal/formats/date.d.ts +63 -0
- package/dist/types/src/internal/formats/date.d.ts.map +1 -0
- package/dist/types/src/internal/formats/date.test.d.ts +2 -0
- package/dist/types/src/internal/formats/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.d.ts +30 -0
- package/dist/types/src/internal/formats/format.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.test.d.ts +2 -0
- package/dist/types/src/internal/formats/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/formats/index.d.ts +8 -0
- package/dist/types/src/internal/formats/index.d.ts.map +1 -0
- package/dist/types/src/internal/formats/number.d.ts +31 -0
- package/dist/types/src/internal/formats/number.d.ts.map +1 -0
- package/dist/types/src/internal/formats/object.d.ts +35 -0
- package/dist/types/src/internal/formats/object.d.ts.map +1 -0
- package/dist/types/src/internal/formats/select.d.ts +11 -0
- package/dist/types/src/internal/formats/select.d.ts.map +1 -0
- package/dist/types/src/internal/formats/string.d.ts +38 -0
- package/dist/types/src/internal/formats/string.d.ts.map +1 -0
- package/dist/types/src/internal/formats/types.d.ts +68 -0
- package/dist/types/src/internal/formats/types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +15 -0
- package/dist/types/src/internal/index.d.ts.map +1 -0
- package/dist/types/src/internal/json/annotations.d.ts +19 -0
- package/dist/types/src/internal/json/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/json/effect-schema.test.d.ts +2 -0
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json/index.d.ts +2 -0
- package/dist/types/src/internal/json/index.d.ts.map +1 -0
- package/dist/types/src/internal/json/json-schema.d.ts +28 -0
- package/dist/types/src/internal/json/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/json/json-schema.test.d.ts +2 -0
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +3 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts +7 -0
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts +250 -0
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/object/accessors.d.ts +37 -0
- package/dist/types/src/internal/object/accessors.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts +18 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -0
- package/dist/types/src/internal/object/create.d.ts +40 -0
- package/dist/types/src/internal/object/create.d.ts.map +1 -0
- package/dist/types/src/internal/object/create.test.d.ts +2 -0
- package/dist/types/src/internal/object/create.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/deleted.d.ts +6 -0
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/object/entity.d.ts +33 -0
- package/dist/types/src/internal/object/entity.d.ts.map +1 -0
- package/dist/types/src/internal/object/expando.d.ts +14 -0
- package/dist/types/src/internal/object/expando.d.ts.map +1 -0
- package/dist/types/src/internal/object/ids.d.ts +6 -0
- package/dist/types/src/internal/object/ids.d.ts.map +1 -0
- package/dist/types/src/internal/object/index.d.ts +16 -0
- package/dist/types/src/internal/object/index.d.ts.map +1 -0
- package/dist/types/src/internal/object/inspect.d.ts +2 -0
- package/dist/types/src/internal/object/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/object/json-serializer.d.ts +32 -0
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/object/json-serializer.test.d.ts +2 -0
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/meta.d.ts +31 -0
- package/dist/types/src/internal/object/meta.d.ts.map +1 -0
- package/dist/types/src/internal/object/model.d.ts +117 -0
- package/dist/types/src/internal/object/model.d.ts.map +1 -0
- package/dist/types/src/internal/object/relation.d.ts +17 -0
- package/dist/types/src/internal/object/relation.d.ts.map +1 -0
- package/dist/types/src/internal/object/schema-validator.d.ts +15 -0
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/object/schema-validator.test.d.ts +2 -0
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.d.ts +31 -0
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/typename.d.ts +15 -0
- package/dist/types/src/internal/object/typename.d.ts.map +1 -0
- package/dist/types/src/internal/object/version.d.ts +14 -0
- package/dist/types/src/internal/object/version.d.ts.map +1 -0
- package/dist/types/src/internal/projection/compose.d.ts +6 -0
- package/dist/types/src/internal/projection/compose.d.ts.map +1 -0
- package/dist/types/src/internal/projection/compose.test.d.ts +2 -0
- package/dist/types/src/internal/projection/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/projection/index.d.ts +2 -0
- package/dist/types/src/internal/projection/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/handler.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive-object.d.ts +15 -0
- package/dist/types/src/internal/proxy/reactive-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +44 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-object.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/query/index.d.ts +2 -0
- package/dist/types/src/internal/query/index.d.ts.map +1 -0
- package/dist/types/src/internal/query/query.d.ts +17 -0
- package/dist/types/src/internal/query/query.d.ts.map +1 -0
- package/dist/types/src/internal/ref/index.d.ts +3 -0
- package/dist/types/src/internal/ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref-array.d.ts +21 -0
- package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref.d.ts +206 -0
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref.test.d.ts +2 -0
- package/dist/types/src/internal/ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +168 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/index.d.ts +7 -0
- package/dist/types/src/internal/schema/index.d.ts.map +1 -0
- package/dist/types/src/internal/schema/manipulation.d.ts +10 -0
- package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +18 -0
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -0
- package/dist/types/src/internal/schema/snapshot.d.ts +6 -0
- package/dist/types/src/internal/schema/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/schema/stored-schema.d.ts +13 -0
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +1 -0
- package/dist/types/src/internal/testing/index.d.ts +3 -0
- package/dist/types/src/internal/testing/index.d.ts.map +1 -0
- package/dist/types/src/internal/testing/types.d.ts +381 -0
- package/dist/types/src/internal/testing/types.d.ts.map +1 -0
- package/dist/types/src/internal/testing/utils.d.ts +10 -0
- package/dist/types/src/internal/testing/utils.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +3 -0
- package/dist/types/src/internal/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/types/types.d.ts +79 -0
- package/dist/types/src/internal/types/types.d.ts.map +1 -0
- package/dist/types/src/internal/types/types.test.d.ts +2 -0
- package/dist/types/src/internal/types/types.test.d.ts.map +1 -0
- package/dist/types/src/internal/types/util.d.ts +5 -0
- package/dist/types/src/internal/types/util.d.ts.map +1 -0
- package/dist/types/src/query/index.d.ts +1 -1
- package/dist/types/src/query/index.d.ts.map +1 -1
- package/dist/types/src/query/{dsl.d.ts → query.d.ts} +52 -22
- package/dist/types/src/query/query.d.ts.map +1 -0
- package/dist/types/src/query/query.test.d.ts +2 -0
- package/dist/types/src/query/query.test.d.ts.map +1 -0
- package/dist/types/src/testing/echo-schema.d.ts +7 -0
- package/dist/types/src/testing/echo-schema.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/types.d.ts +170 -55
- package/dist/types/src/testing/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -17
- package/src/Obj.ts +195 -16
- package/src/Ref.ts +1 -2
- package/src/Relation.ts +16 -5
- package/src/Tag.ts +39 -0
- package/src/Type.ts +29 -30
- package/src/errors.ts +18 -0
- package/src/index.ts +5 -1
- package/src/internal/ast/annotation-helper.ts +22 -0
- package/src/internal/ast/annotations.test.ts +98 -0
- package/src/internal/ast/annotations.ts +226 -0
- package/src/internal/ast/entity-kind.ts +15 -0
- package/src/internal/ast/index.ts +8 -0
- package/src/internal/ast/types.ts +17 -0
- package/src/internal/formats/date.test.ts +56 -0
- package/src/internal/formats/date.ts +217 -0
- package/src/internal/formats/format.test.ts +77 -0
- package/src/internal/formats/format.ts +52 -0
- package/src/internal/formats/index.ts +12 -0
- package/src/internal/formats/number.ts +89 -0
- package/src/internal/formats/object.ts +80 -0
- package/src/internal/formats/select.ts +16 -0
- package/src/internal/formats/string.ts +76 -0
- package/src/internal/formats/types.ts +175 -0
- package/src/internal/index.ts +22 -0
- package/src/internal/json/annotations.ts +50 -0
- package/src/internal/json/effect-schema.test.ts +143 -0
- package/src/internal/json/index.ts +5 -0
- package/src/internal/json/json-schema.test.ts +849 -0
- package/src/internal/json/json-schema.ts +519 -0
- package/src/internal/json-schema/index.ts +6 -0
- package/src/internal/json-schema/json-schema-normalize.ts +109 -0
- package/src/internal/json-schema/json-schema-type.ts +403 -0
- package/src/internal/object/accessors.ts +153 -0
- package/src/internal/object/common.ts +76 -0
- package/src/internal/object/create.test.ts +118 -0
- package/src/internal/object/create.ts +96 -0
- package/src/internal/object/deleted.ts +19 -0
- package/src/internal/object/entity.ts +248 -0
- package/src/internal/object/expando.ts +21 -0
- package/src/internal/object/ids.ts +12 -0
- package/src/internal/object/index.ts +19 -0
- package/src/internal/object/inspect.ts +48 -0
- package/src/internal/object/json-serializer.test.ts +99 -0
- package/src/internal/object/json-serializer.ts +225 -0
- package/src/internal/object/meta.ts +61 -0
- package/src/internal/object/model.ts +170 -0
- package/src/internal/object/relation.ts +24 -0
- package/src/internal/object/schema-validator.test.ts +186 -0
- package/src/internal/object/schema-validator.ts +241 -0
- package/src/internal/object/typed-object.test.ts +34 -0
- package/src/internal/object/typed-object.ts +88 -0
- package/src/internal/object/typename.ts +61 -0
- package/src/internal/object/version.ts +22 -0
- package/src/internal/projection/compose.test.ts +43 -0
- package/src/internal/projection/compose.ts +36 -0
- package/src/internal/projection/index.ts +5 -0
- package/src/internal/proxy/handler.test.ts +163 -0
- package/src/internal/proxy/reactive-object.ts +108 -0
- package/src/internal/proxy/schema.test.ts +136 -0
- package/src/internal/proxy/typed-handler.test.ts +102 -0
- package/src/internal/proxy/typed-handler.ts +228 -0
- package/src/internal/proxy/typed-object.test.ts +100 -0
- package/src/internal/query/index.ts +5 -0
- package/src/internal/query/query.ts +23 -0
- package/src/internal/ref/index.ts +6 -0
- package/src/internal/ref/ref-array.ts +39 -0
- package/src/internal/ref/ref.test.ts +100 -0
- package/src/internal/ref/ref.ts +521 -0
- package/src/internal/schema/echo-schema.ts +383 -0
- package/src/internal/schema/index.ts +10 -0
- package/src/internal/schema/manipulation.ts +92 -0
- package/src/internal/schema/runtime-schema-registry.ts +78 -0
- package/src/internal/schema/snapshot.ts +25 -0
- package/src/internal/schema/stored-schema.ts +26 -0
- package/src/internal/testing/index.ts +6 -0
- package/src/internal/testing/types.ts +144 -0
- package/src/internal/testing/utils.ts +54 -0
- package/src/internal/types/index.ts +6 -0
- package/src/internal/types/types.test.ts +48 -0
- package/src/internal/types/types.ts +176 -0
- package/src/internal/types/util.ts +9 -0
- package/src/query/index.ts +2 -1
- package/src/query/query.test.ts +401 -0
- package/src/query/{dsl.ts → query.ts} +188 -45
- package/src/test/api.test.ts +16 -9
- package/src/testing/echo-schema.ts +39 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/types.ts +40 -23
- package/dist/lib/browser/chunk-2KNTYMIW.mjs +0 -697
- package/dist/lib/browser/chunk-2KNTYMIW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EXNNC62J.mjs +0 -697
- package/dist/lib/node-esm/chunk-EXNNC62J.mjs.map +0 -7
- package/dist/types/src/experimental/database.d.ts +0 -8
- 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 +0 -8
- package/dist/types/src/experimental/queue.d.ts.map +0 -1
- package/dist/types/src/experimental/space.d.ts +0 -8
- package/dist/types/src/experimental/space.d.ts.map +0 -1
- package/dist/types/src/query/dsl.d.ts.map +0 -1
- package/dist/types/src/query/dsl.test.d.ts +0 -2
- package/dist/types/src/query/dsl.test.d.ts.map +0 -1
- package/src/experimental/database.ts +0 -11
- package/src/experimental/index.ts +0 -7
- package/src/experimental/queue.ts +0 -11
- package/src/experimental/space.ts +0 -11
- package/src/query/dsl.test.ts +0 -324
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.72ec0f3",
|
|
4
4
|
"description": "ECHO API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "info@dxos.org",
|
|
9
|
-
"sideEffects":
|
|
9
|
+
"sideEffects": false,
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -39,9 +39,21 @@
|
|
|
39
39
|
"browser": "./dist/lib/browser/Ref.mjs",
|
|
40
40
|
"node": "./dist/lib/node-esm/Ref.mjs"
|
|
41
41
|
},
|
|
42
|
+
"./internal": {
|
|
43
|
+
"source": "./src/internal/index.ts",
|
|
44
|
+
"types": "./dist/types/src/internal/index.d.ts",
|
|
45
|
+
"browser": "./dist/lib/browser/internal/index.mjs",
|
|
46
|
+
"node": "./dist/lib/node-esm/internal/index.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./query": {
|
|
49
|
+
"source": "./src/query/index.ts",
|
|
50
|
+
"types": "./dist/types/src/query/index.d.ts",
|
|
51
|
+
"browser": "./dist/lib/browser/query/index.mjs",
|
|
52
|
+
"node": "./dist/lib/node-esm/query/index.mjs"
|
|
53
|
+
},
|
|
42
54
|
"./testing": {
|
|
43
|
-
"source": "./src/testing/
|
|
44
|
-
"types": "./dist/types/src/testing/
|
|
55
|
+
"source": "./src/testing/index.ts",
|
|
56
|
+
"types": "./dist/types/src/testing/index.d.ts",
|
|
45
57
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
46
58
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
47
59
|
}
|
|
@@ -71,19 +83,19 @@
|
|
|
71
83
|
"src"
|
|
72
84
|
],
|
|
73
85
|
"dependencies": {
|
|
74
|
-
"@preact/signals-core": "^1.
|
|
75
|
-
"effect": "3.
|
|
76
|
-
"@dxos/debug": "0.8.4-main.
|
|
77
|
-
"@dxos/echo-protocol": "0.8.4-main.
|
|
78
|
-
"@dxos/echo-
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/effect": "0.8.4-main.
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/
|
|
85
|
-
"@dxos/node-std": "0.8.4-main.
|
|
86
|
-
"@dxos/
|
|
86
|
+
"@preact/signals-core": "^1.12.1",
|
|
87
|
+
"effect": "3.18.3",
|
|
88
|
+
"@dxos/debug": "0.8.4-main.72ec0f3",
|
|
89
|
+
"@dxos/echo-protocol": "0.8.4-main.72ec0f3",
|
|
90
|
+
"@dxos/echo-signals": "0.8.4-main.72ec0f3",
|
|
91
|
+
"@dxos/errors": "0.8.4-main.72ec0f3",
|
|
92
|
+
"@dxos/effect": "0.8.4-main.72ec0f3",
|
|
93
|
+
"@dxos/keys": "0.8.4-main.72ec0f3",
|
|
94
|
+
"@dxos/invariant": "0.8.4-main.72ec0f3",
|
|
95
|
+
"@dxos/live-object": "0.8.4-main.72ec0f3",
|
|
96
|
+
"@dxos/log": "0.8.4-main.72ec0f3",
|
|
97
|
+
"@dxos/node-std": "0.8.4-main.72ec0f3",
|
|
98
|
+
"@dxos/util": "0.8.4-main.72ec0f3"
|
|
87
99
|
},
|
|
88
100
|
"publishConfig": {
|
|
89
101
|
"access": "public"
|
package/src/Obj.ts
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as Function from 'effect/Function';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
7
|
|
|
8
|
-
import * as EchoSchema from '@dxos/echo-schema';
|
|
9
8
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
10
9
|
import { type DXN } from '@dxos/keys';
|
|
11
|
-
import
|
|
12
|
-
import { live } from '@dxos/live-object';
|
|
10
|
+
import * as LiveObject from '@dxos/live-object';
|
|
13
11
|
import { assumeType, deepMapValues } from '@dxos/util';
|
|
14
12
|
|
|
13
|
+
import { live } from './internal';
|
|
14
|
+
import * as EchoSchema from './internal';
|
|
15
15
|
import type * as Ref from './Ref';
|
|
16
16
|
import type * as Relation from './Relation';
|
|
17
|
-
import
|
|
17
|
+
import * as Type from './Type';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* NOTE: Don't export: Obj.Any and Obj.Obj form the public API.
|
|
@@ -28,9 +28,27 @@ export type Obj<Props> = BaseObj & Props;
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Base type for all ECHO objects.
|
|
31
|
+
* This type does not define any properties.
|
|
31
32
|
*/
|
|
32
33
|
export interface Any extends BaseObj {}
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Object with arbitrary properties.
|
|
37
|
+
*
|
|
38
|
+
* NOTE: Due to how typescript works, this type is not assignable to a specific schema type.
|
|
39
|
+
* In that case, use `Obj.instanceOf` to check if an object is of a specific type.
|
|
40
|
+
*/
|
|
41
|
+
export interface AnyProps extends BaseObj {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const Any = Schema.Struct({}).pipe(
|
|
46
|
+
Type.Obj({
|
|
47
|
+
typename: 'dxos.org/types/Any',
|
|
48
|
+
version: '0.1.0',
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
|
|
34
52
|
type Props<T = any> = { id?: EchoSchema.ObjectId } & Type.Properties<T>;
|
|
35
53
|
|
|
36
54
|
export type MakeProps<T extends Type.Obj.Any> = NoInfer<Props<Schema.Schema.Type<T>>> & {
|
|
@@ -39,7 +57,9 @@ export type MakeProps<T extends Type.Obj.Any> = NoInfer<Props<Schema.Schema.Type
|
|
|
39
57
|
|
|
40
58
|
export const Meta: unique symbol = EchoSchema.MetaId as any;
|
|
41
59
|
|
|
42
|
-
|
|
60
|
+
const DEFAULT_META: EchoSchema.ObjectMeta = {
|
|
61
|
+
keys: [],
|
|
62
|
+
};
|
|
43
63
|
|
|
44
64
|
/**
|
|
45
65
|
* Creates new object.
|
|
@@ -57,19 +77,23 @@ export const Meta: unique symbol = EchoSchema.MetaId as any;
|
|
|
57
77
|
export const make = <S extends Type.Obj.Any>(
|
|
58
78
|
schema: S,
|
|
59
79
|
props: MakeProps<S>,
|
|
60
|
-
meta?: EchoSchema.ObjectMeta
|
|
80
|
+
meta?: Partial<EchoSchema.ObjectMeta>,
|
|
61
81
|
): LiveObject.Live<Schema.Schema.Type<S>> => {
|
|
62
82
|
assertArgument(
|
|
63
83
|
EchoSchema.getTypeAnnotation(schema)?.kind === EchoSchema.EntityKind.Object,
|
|
84
|
+
'schema',
|
|
64
85
|
'Expected an object schema',
|
|
65
86
|
);
|
|
66
87
|
|
|
67
88
|
if (props[EchoSchema.MetaId] != null) {
|
|
68
|
-
meta
|
|
89
|
+
// Set default fields on meta on creation.
|
|
90
|
+
meta = { ...structuredClone(DEFAULT_META), ...props[EchoSchema.MetaId] };
|
|
69
91
|
delete props[EchoSchema.MetaId];
|
|
70
92
|
}
|
|
71
93
|
|
|
72
|
-
|
|
94
|
+
const filterUndefined = Object.fromEntries(Object.entries(props).filter(([_, v]) => v !== undefined));
|
|
95
|
+
|
|
96
|
+
return live<Schema.Schema.Type<S>>(schema, filterUndefined as any, { keys: [], ...meta });
|
|
73
97
|
};
|
|
74
98
|
|
|
75
99
|
export const isObject = (obj: unknown): obj is Any => {
|
|
@@ -85,7 +109,7 @@ export const isObject = (obj: unknown): obj is Any => {
|
|
|
85
109
|
* const johnIsPerson = Obj.instanceOf(Person)(john);
|
|
86
110
|
*
|
|
87
111
|
* const isPerson = Obj.instanceOf(Person);
|
|
88
|
-
* if(isPerson(john)) {
|
|
112
|
+
* if (isPerson(john)) {
|
|
89
113
|
* // john is Person
|
|
90
114
|
* }
|
|
91
115
|
* ```
|
|
@@ -107,7 +131,7 @@ export const getSchema = EchoSchema.getSchema;
|
|
|
107
131
|
|
|
108
132
|
// TODO(dmaretskyi): Allow returning undefined.
|
|
109
133
|
export const getDXN = (obj: Any | Relation.Any): DXN => {
|
|
110
|
-
assertArgument(!Schema.isSchema(obj), 'Object should not be a schema.');
|
|
134
|
+
assertArgument(!Schema.isSchema(obj), 'obj', 'Object should not be a schema.');
|
|
111
135
|
const dxn = EchoSchema.getObjectDXN(obj);
|
|
112
136
|
invariant(dxn != null, 'Invalid object.');
|
|
113
137
|
return dxn;
|
|
@@ -115,14 +139,14 @@ export const getDXN = (obj: Any | Relation.Any): DXN => {
|
|
|
115
139
|
|
|
116
140
|
/**
|
|
117
141
|
* @returns The DXN of the object's type.
|
|
118
|
-
* @example dxn:example.com/type/
|
|
142
|
+
* @example dxn:example.com/type/Person:1.0.0
|
|
119
143
|
*/
|
|
120
144
|
// TODO(burdon): Expando does not have a type.
|
|
121
145
|
export const getTypeDXN = EchoSchema.getType;
|
|
122
146
|
|
|
123
147
|
/**
|
|
124
148
|
* @returns The typename of the object's type.
|
|
125
|
-
* @example `example.com/type/
|
|
149
|
+
* @example `example.com/type/Person`
|
|
126
150
|
*/
|
|
127
151
|
export const getTypename = (obj: Any | Relation.Any): string | undefined => {
|
|
128
152
|
const schema = getSchema(obj);
|
|
@@ -147,7 +171,7 @@ export const getMeta = (obj: Any | Relation.Any): EchoSchema.ObjectMeta => {
|
|
|
147
171
|
export const getKeys: {
|
|
148
172
|
(obj: Any | Relation.Any, source: string): EchoSchema.ForeignKey[];
|
|
149
173
|
(source: string): (obj: Any | Relation.Any) => EchoSchema.ForeignKey[];
|
|
150
|
-
} = dual(2, (obj: Any | Relation.Any, source?: string): EchoSchema.ForeignKey[] => {
|
|
174
|
+
} = Function.dual(2, (obj: Any | Relation.Any, source?: string): EchoSchema.ForeignKey[] => {
|
|
151
175
|
const meta = EchoSchema.getMeta(obj);
|
|
152
176
|
invariant(meta != null, 'Invalid object.');
|
|
153
177
|
return meta.keys.filter((key) => key.source === source);
|
|
@@ -175,7 +199,6 @@ export const isDeleted = (obj: Any | Relation.Any): boolean => {
|
|
|
175
199
|
return deleted;
|
|
176
200
|
};
|
|
177
201
|
|
|
178
|
-
// TODO(burdon): Rename "label"
|
|
179
202
|
export const getLabel = (obj: Any | Relation.Any): string | undefined => {
|
|
180
203
|
const schema = getSchema(obj);
|
|
181
204
|
if (schema != null) {
|
|
@@ -190,6 +213,68 @@ export const setLabel = (obj: Any | Relation.Any, label: string) => {
|
|
|
190
213
|
}
|
|
191
214
|
};
|
|
192
215
|
|
|
216
|
+
export const getDescription = (obj: Any | Relation.Any): string | undefined => {
|
|
217
|
+
const schema = getSchema(obj);
|
|
218
|
+
if (schema != null) {
|
|
219
|
+
return EchoSchema.getDescription(schema, obj);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export const setDescription = (obj: Any | Relation.Any, description: string) => {
|
|
224
|
+
const schema = getSchema(obj);
|
|
225
|
+
if (schema != null) {
|
|
226
|
+
EchoSchema.setDescription(schema, obj, description);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const addTag = (obj: Any | Relation.Any, tag: string) => {
|
|
231
|
+
const meta = getMeta(obj);
|
|
232
|
+
meta.tags ??= [];
|
|
233
|
+
meta.tags.push(tag);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export const removeTag = (obj: Any | Relation.Any, tag: string) => {
|
|
237
|
+
const meta = getMeta(obj);
|
|
238
|
+
if (!meta.tags) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
for (let i = 0; i < meta.tags.length; i++) {
|
|
242
|
+
if (meta.tags[i] === tag) {
|
|
243
|
+
meta.tags.splice(i, 1);
|
|
244
|
+
i--;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const compare = (a?: string, b?: string) => {
|
|
250
|
+
if (a == null) {
|
|
251
|
+
return b == null ? 0 : 1;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (b == null) {
|
|
255
|
+
return -1;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return a.localeCompare(b);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export type Comparator = (a: Any, b: Any) => number;
|
|
262
|
+
|
|
263
|
+
export const sortByLabel: Comparator = (a: Any, b: Any) => compare(getLabel(a), getLabel(b));
|
|
264
|
+
export const sortByTypename: Comparator = (a: Any, b: Any) => compare(getTypename(a), getTypename(b));
|
|
265
|
+
export const sort = (...comparators: Comparator[]): Comparator => {
|
|
266
|
+
return (a: Any, b: Any) => {
|
|
267
|
+
for (const comparator of comparators) {
|
|
268
|
+
const result = comparator(a, b);
|
|
269
|
+
if (result !== 0) {
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return 0;
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
|
|
193
278
|
/**
|
|
194
279
|
* JSON representation of an object.
|
|
195
280
|
*/
|
|
@@ -215,6 +300,11 @@ export const toJSON = (obj: Any | Relation.Any): JSON => EchoSchema.objectToJSON
|
|
|
215
300
|
export const fromJSON: (json: unknown, options?: { refResolver?: Ref.Resolver; dxn?: DXN }) => Promise<Any> =
|
|
216
301
|
EchoSchema.objectFromJSON as any;
|
|
217
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Returns an immutable snapshot of an object.
|
|
305
|
+
*/
|
|
306
|
+
export const getSnapshot: <T extends Any>(obj: Obj<T>) => T = LiveObject.getSnapshot;
|
|
307
|
+
|
|
218
308
|
export type CloneOptions = {
|
|
219
309
|
/**
|
|
220
310
|
* Retain the original object's ID.
|
|
@@ -250,3 +340,92 @@ export const clone = <T extends Any | Relation.Any>(obj: T, opts?: CloneOptions)
|
|
|
250
340
|
});
|
|
251
341
|
return make(schema, props);
|
|
252
342
|
};
|
|
343
|
+
|
|
344
|
+
export const VersionTypeId = EchoSchema.VersionTypeId;
|
|
345
|
+
export type VersionType = typeof VersionTypeId;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Represent object version.
|
|
349
|
+
* May be backed by Automerge.
|
|
350
|
+
* Objects with no history are not versioned.
|
|
351
|
+
*/
|
|
352
|
+
export interface Version {
|
|
353
|
+
[VersionTypeId]: {};
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Whether the object is versioned.
|
|
357
|
+
*/
|
|
358
|
+
versioned: boolean;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Automerge heads.
|
|
362
|
+
*/
|
|
363
|
+
automergeHeads?: string[];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const unversioned: Version = {
|
|
367
|
+
[VersionTypeId]: {},
|
|
368
|
+
versioned: false,
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Checks that `obj` is a version object.
|
|
373
|
+
*/
|
|
374
|
+
export const isVersion = (obj: unknown): obj is Version => {
|
|
375
|
+
return obj != null && typeof obj === 'object' && VersionTypeId in obj;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Returns the version of the object.
|
|
380
|
+
*/
|
|
381
|
+
export const version = (obj: Any | Relation.Any): Version => {
|
|
382
|
+
const version = (obj as any)[EchoSchema.ObjectVersionId];
|
|
383
|
+
if (version === undefined) {
|
|
384
|
+
return unversioned;
|
|
385
|
+
}
|
|
386
|
+
return version;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Checks that `version` is a valid version object.
|
|
391
|
+
*/
|
|
392
|
+
export const versionValid = (version: Version): boolean => {
|
|
393
|
+
assertArgument(isVersion(version), 'version', 'Invalid version object');
|
|
394
|
+
return !!version.versioned;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
export type VersionCompareResult = 'unversioned' | 'equal' | 'different';
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Compares two versions.
|
|
401
|
+
* @param version1
|
|
402
|
+
* @param version2
|
|
403
|
+
* @returns 'unversioned' if either object is unversioned, 'equal' if the versions are equal, 'different' if the versions are different.
|
|
404
|
+
*/
|
|
405
|
+
export const compareVersions = (version1: Version, version2: Version): VersionCompareResult => {
|
|
406
|
+
assertArgument(isVersion(version1), 'version1', 'Invalid version object');
|
|
407
|
+
assertArgument(isVersion(version2), 'version2', 'Invalid version object');
|
|
408
|
+
|
|
409
|
+
if (!versionValid(version1) || !versionValid(version2)) {
|
|
410
|
+
return 'unversioned';
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (version1.automergeHeads?.length !== version2.automergeHeads?.length) {
|
|
414
|
+
return 'different';
|
|
415
|
+
}
|
|
416
|
+
if (version1.automergeHeads?.some((head) => !version2.automergeHeads?.includes(head))) {
|
|
417
|
+
return 'different';
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return 'equal';
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export const encodeVersion = (version: Version): string => {
|
|
424
|
+
return JSON.stringify(version);
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
export const decodeVersion = (version: string): Version => {
|
|
428
|
+
const parsed = JSON.parse(version);
|
|
429
|
+
parsed[VersionTypeId] = {};
|
|
430
|
+
return parsed;
|
|
431
|
+
};
|
package/src/Ref.ts
CHANGED
package/src/Relation.ts
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import * as EchoSchema from '@dxos/echo-schema';
|
|
9
8
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
10
9
|
import { DXN } from '@dxos/keys';
|
|
11
|
-
import { type Live
|
|
10
|
+
import { type Live } from '@dxos/live-object';
|
|
12
11
|
import { assumeType } from '@dxos/util';
|
|
13
12
|
|
|
14
|
-
import
|
|
15
|
-
import
|
|
13
|
+
import { live } from './internal';
|
|
14
|
+
import * as EchoSchema from './internal';
|
|
15
|
+
import * as Obj from './Obj';
|
|
16
|
+
import * as Type from './Type';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* NOTE: Don't export: Relation.Relation and Relation.Any form the public API.
|
|
@@ -32,6 +33,15 @@ export type Relation<Source extends Obj.Any, Target extends Obj.Any, Props> = Ba
|
|
|
32
33
|
*/
|
|
33
34
|
export interface Any extends BaseRelation<Obj.Any, Obj.Any> {}
|
|
34
35
|
|
|
36
|
+
export const Any = Schema.Struct({}).pipe(
|
|
37
|
+
Type.Relation({
|
|
38
|
+
typename: 'dxos.org/types/Any',
|
|
39
|
+
version: '0.1.0',
|
|
40
|
+
source: Obj.Any,
|
|
41
|
+
target: Obj.Any,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
|
|
35
45
|
// TODO(dmaretskyi): Has to be `unique symbol`.
|
|
36
46
|
export const Source: unique symbol = EchoSchema.RelationSourceId as any;
|
|
37
47
|
export type Source = typeof Source;
|
|
@@ -60,6 +70,7 @@ export const make = <S extends Type.Relation.Any>(
|
|
|
60
70
|
): Live<Schema.Schema.Type<S> & Type.OfKind<EchoSchema.EntityKind.Relation>> => {
|
|
61
71
|
assertArgument(
|
|
62
72
|
EchoSchema.getTypeAnnotation(schema)?.kind === EchoSchema.EntityKind.Relation,
|
|
73
|
+
'schema',
|
|
63
74
|
'Expected a relation schema',
|
|
64
75
|
);
|
|
65
76
|
|
package/src/Tag.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { LabelAnnotation } from './internal';
|
|
8
|
+
import * as Obj from './Obj';
|
|
9
|
+
import * as Type from './Type';
|
|
10
|
+
|
|
11
|
+
export const Tag = Schema.Struct({
|
|
12
|
+
label: Schema.String,
|
|
13
|
+
hue: Schema.optional(Schema.String), // TODO(burdon): Color name?
|
|
14
|
+
}).pipe(
|
|
15
|
+
Type.Obj({
|
|
16
|
+
typename: 'dxos.org/type/Tag',
|
|
17
|
+
version: '0.1.0',
|
|
18
|
+
}),
|
|
19
|
+
LabelAnnotation.set(['label']),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export type Tag = Schema.Schema.Type<typeof Tag>;
|
|
23
|
+
|
|
24
|
+
export const make = (props: Obj.MakeProps<typeof Tag>) => Obj.make(Tag, props);
|
|
25
|
+
|
|
26
|
+
// TODO(burdon): Rename Map.
|
|
27
|
+
export type Map = Record<string, Tag>;
|
|
28
|
+
|
|
29
|
+
export const sortTags = ({ label: a }: Tag, { label: b }: Tag) => a.localeCompare(b);
|
|
30
|
+
|
|
31
|
+
export const createTagList = (tags: Map): Tag[] =>
|
|
32
|
+
Object.entries(tags)
|
|
33
|
+
.map(([id, tag]) => ({ ...tag, id }))
|
|
34
|
+
.sort(sortTags);
|
|
35
|
+
|
|
36
|
+
export const findTagByLabel = (tags: Map | undefined, name: string): Tag | undefined => {
|
|
37
|
+
const entry = Object.entries(tags ?? {}).find(([_, tag]) => tag.label.toLowerCase() === name.toLowerCase());
|
|
38
|
+
return entry ? { ...entry[1], id: entry[0] } : undefined;
|
|
39
|
+
};
|
package/src/Type.ts
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { type Simplify } from 'effect/Schema';
|
|
5
|
+
import type * as EffectSchema from 'effect/Schema';
|
|
7
6
|
|
|
8
7
|
import { type EncodedReference } from '@dxos/echo-protocol';
|
|
9
|
-
import * as EchoSchema from '@dxos/echo-schema';
|
|
10
|
-
import { type ToMutable } from '@dxos/echo-schema';
|
|
11
8
|
import { invariant } from '@dxos/invariant';
|
|
12
9
|
import type * as Keys from '@dxos/keys';
|
|
13
10
|
|
|
11
|
+
import { type ToMutable } from './internal';
|
|
12
|
+
import * as EchoSchema from './internal';
|
|
14
13
|
import type * as RelationModule from './Relation';
|
|
15
14
|
|
|
16
15
|
//
|
|
@@ -55,33 +54,33 @@ interface ObjJsonProps {
|
|
|
55
54
|
* This typedef avoids `TS4023` error (name from external module cannot be used named).
|
|
56
55
|
* See Effect's note on interface types.
|
|
57
56
|
*/
|
|
58
|
-
export interface obj<Self extends
|
|
57
|
+
export interface obj<Self extends EffectSchema.Schema.Any>
|
|
59
58
|
extends EchoSchema.TypeMeta,
|
|
60
|
-
|
|
59
|
+
EffectSchema.AnnotableClass<
|
|
61
60
|
obj<Self>,
|
|
62
|
-
OfKind<EchoSchema.EntityKind.Object> & ToMutable<
|
|
63
|
-
Simplify<ObjJsonProps & ToMutable<
|
|
64
|
-
|
|
61
|
+
OfKind<EchoSchema.EntityKind.Object> & ToMutable<EffectSchema.Schema.Type<Self>>,
|
|
62
|
+
EffectSchema.Simplify<ObjJsonProps & ToMutable<EffectSchema.Schema.Encoded<Self>>>,
|
|
63
|
+
EffectSchema.Schema.Context<Self>
|
|
65
64
|
> {}
|
|
66
65
|
|
|
67
66
|
/**
|
|
68
67
|
* Object schema.
|
|
69
68
|
*/
|
|
70
69
|
export const Obj: {
|
|
71
|
-
(opts: EchoSchema.TypeMeta): <Self extends
|
|
70
|
+
(opts: EchoSchema.TypeMeta): <Self extends EffectSchema.Schema.Any>(self: Self) => obj<Self>;
|
|
72
71
|
} = EchoSchema.EchoObject as any;
|
|
73
72
|
|
|
74
73
|
/**
|
|
75
74
|
* Object schema type definitions.
|
|
76
75
|
*/
|
|
77
|
-
export namespace Obj {
|
|
76
|
+
export declare namespace Obj {
|
|
78
77
|
/**
|
|
79
78
|
* Type that represents an arbitrary schema type of an object.
|
|
80
79
|
* NOTE: This is not an instance type.
|
|
81
80
|
*/
|
|
82
81
|
// TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
|
|
83
82
|
// TODO(burdon): This erases the ECHO type info (e.g., id, typename).
|
|
84
|
-
export type Any =
|
|
83
|
+
export type Any = EffectSchema.Schema.AnyNoContext;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
//
|
|
@@ -93,9 +92,9 @@ export interface Expando extends OfKind<EchoSchema.EntityKind.Object> {
|
|
|
93
92
|
[key: string]: any;
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
type ExpandoEncoded = Simplify<ObjJsonProps & { [key: string]: any }>;
|
|
95
|
+
type ExpandoEncoded = EffectSchema.Simplify<ObjJsonProps & { [key: string]: any }>;
|
|
97
96
|
|
|
98
|
-
export const Expando:
|
|
97
|
+
export const Expando: EffectSchema.Schema<Expando, ExpandoEncoded, never> = EchoSchema.Expando as any;
|
|
99
98
|
|
|
100
99
|
//
|
|
101
100
|
// Relation
|
|
@@ -114,17 +113,17 @@ interface RelationJsonProps {
|
|
|
114
113
|
* See Effect's note on interface types.
|
|
115
114
|
*/
|
|
116
115
|
export interface relation<
|
|
117
|
-
Self extends
|
|
118
|
-
SourceSchema extends
|
|
119
|
-
TargetSchema extends
|
|
116
|
+
Self extends EffectSchema.Schema.Any,
|
|
117
|
+
SourceSchema extends EffectSchema.Schema.Any,
|
|
118
|
+
TargetSchema extends EffectSchema.Schema.Any,
|
|
120
119
|
> extends EchoSchema.TypeMeta,
|
|
121
|
-
|
|
120
|
+
EffectSchema.AnnotableClass<
|
|
122
121
|
relation<Self, SourceSchema, TargetSchema>,
|
|
123
122
|
OfKind<EchoSchema.EntityKind.Relation> &
|
|
124
|
-
Relation.Endpoints<
|
|
125
|
-
ToMutable<
|
|
126
|
-
Simplify<RelationJsonProps & ToMutable<
|
|
127
|
-
|
|
123
|
+
Relation.Endpoints<EffectSchema.Schema.Type<SourceSchema>, EffectSchema.Schema.Type<TargetSchema>> &
|
|
124
|
+
ToMutable<EffectSchema.Schema.Type<Self>>,
|
|
125
|
+
EffectSchema.Simplify<RelationJsonProps & ToMutable<EffectSchema.Schema.Encoded<Self>>>,
|
|
126
|
+
EffectSchema.Schema.Context<Self>
|
|
128
127
|
> {}
|
|
129
128
|
|
|
130
129
|
/**
|
|
@@ -132,9 +131,9 @@ export interface relation<
|
|
|
132
131
|
*/
|
|
133
132
|
// TODO(dmaretskyi): I have to redefine the type here so that the definition uses symbols from @dxos/echo/Relation.
|
|
134
133
|
export const Relation: {
|
|
135
|
-
<Source extends
|
|
134
|
+
<Source extends EffectSchema.Schema.AnyNoContext, Target extends EffectSchema.Schema.AnyNoContext>(
|
|
136
135
|
opts: EchoSchema.EchoRelationOptions<Source, Target>,
|
|
137
|
-
): <Self extends
|
|
136
|
+
): <Self extends EffectSchema.Schema.Any>(self: Self) => relation<Self, Source, Target>;
|
|
138
137
|
} = EchoSchema.EchoRelation as any;
|
|
139
138
|
|
|
140
139
|
/**
|
|
@@ -146,7 +145,7 @@ export namespace Relation {
|
|
|
146
145
|
* NOTE: This is not an instance type.
|
|
147
146
|
*/
|
|
148
147
|
// TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
|
|
149
|
-
export type Any =
|
|
148
|
+
export type Any = EffectSchema.Schema.AnyNoContext;
|
|
150
149
|
|
|
151
150
|
/**
|
|
152
151
|
* Get relation source type.
|
|
@@ -174,15 +173,15 @@ export namespace Relation {
|
|
|
174
173
|
* This typedef avoids `TS4023` error (name from external module cannot be used named).
|
|
175
174
|
* See Effect's note on interface types.
|
|
176
175
|
*/
|
|
177
|
-
export interface ref<TargetSchema extends
|
|
178
|
-
extends EchoSchema.Ref$<
|
|
176
|
+
export interface ref<TargetSchema extends EffectSchema.Schema.Any>
|
|
177
|
+
extends EchoSchema.Ref$<EffectSchema.Schema.Type<TargetSchema>> {}
|
|
179
178
|
|
|
180
179
|
/**
|
|
181
180
|
* Ref schema.
|
|
182
181
|
*/
|
|
183
182
|
export const Ref: <S extends Obj.Any>(schema: S) => ref<S> = EchoSchema.Ref;
|
|
184
183
|
|
|
185
|
-
export interface Ref<T> extends
|
|
184
|
+
export interface Ref<T> extends EffectSchema.SchemaClass<EchoSchema.Ref<T>, EncodedReference> {}
|
|
186
185
|
|
|
187
186
|
// TODO(buurdon): Move to Ref?
|
|
188
187
|
export namespace Ref {
|
|
@@ -190,7 +189,7 @@ export namespace Ref {
|
|
|
190
189
|
* Type that represents an arbitrary schema type of a reference.
|
|
191
190
|
* NOTE: This is not an instance type.
|
|
192
191
|
*/
|
|
193
|
-
export type Any =
|
|
192
|
+
export type Any = EffectSchema.Schema<EchoSchema.Ref<any>, EncodedReference>;
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
/**
|
|
@@ -243,4 +242,4 @@ export const getMeta = (schema: Obj.Any | Relation.Any): Meta | undefined => {
|
|
|
243
242
|
// TODO(dmaretskyi): Remove re-exports.
|
|
244
243
|
export { SpaceId, ObjectId, DXN } from '@dxos/keys';
|
|
245
244
|
|
|
246
|
-
export { Format, JsonSchemaType as JsonSchema, toEffectSchema, toJsonSchema } from '
|
|
245
|
+
export { Format, JsonSchemaType as JsonSchema, toEffectSchema, toJsonSchema } from './internal';
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { BaseError, type BaseErrorOptions } from '@dxos/errors';
|
|
6
|
+
import { type DXN } from '@dxos/keys';
|
|
7
|
+
|
|
8
|
+
export class SchemaNotFoundError extends BaseError.extend('SCHEMA_NOT_FOUND', 'Schema not found') {
|
|
9
|
+
constructor(schema: string, options?: BaseErrorOptions) {
|
|
10
|
+
super({ context: { schema }, ...options });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ObjectNotFoundError extends BaseError.extend('OBJECT_NOT_FOUND', 'Object not found') {
|
|
15
|
+
constructor(dxn: DXN, options?: BaseErrorOptions) {
|
|
16
|
+
super({ context: { dxn }, ...options });
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export * from './errors';
|
|
6
|
+
export * from './query';
|
|
7
|
+
|
|
5
8
|
export * as Key from './Key';
|
|
6
9
|
export * as Obj from './Obj';
|
|
7
10
|
export * as Ref from './Ref';
|
|
8
11
|
export * as Relation from './Relation';
|
|
12
|
+
export * as Tag from './Tag';
|
|
9
13
|
export * as Type from './Type';
|
|
10
14
|
|
|
15
|
+
export { QueryAST } from '@dxos/echo-protocol';
|
|
11
16
|
export { DXN } from '@dxos/keys';
|
|
12
|
-
export { Filter, Query } from './query';
|
|
13
17
|
export { type Live } from '@dxos/live-object';
|