@dxos/echo 0.8.4-main.937b3ca → 0.8.4-main.9735255
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 → neutral}/Annotation.mjs +4 -5
- package/dist/lib/neutral/Database.mjs +17 -0
- package/dist/lib/{browser → neutral}/Entity.mjs +8 -9
- package/dist/lib/{browser → neutral}/Err.mjs +2 -3
- package/dist/lib/{browser → neutral}/Filter.mjs +9 -10
- package/dist/lib/{browser → neutral}/Format.mjs +4 -5
- package/dist/lib/neutral/JsonSchema.mjs +19 -0
- package/dist/lib/{browser → neutral}/Key.mjs +2 -3
- package/dist/lib/{browser → neutral}/Obj.mjs +9 -10
- package/dist/lib/{browser → neutral}/Order.mjs +2 -3
- package/dist/lib/neutral/Query.mjs +26 -0
- package/dist/lib/neutral/QueryResult.mjs +2 -0
- package/dist/lib/neutral/Ref.mjs +22 -0
- package/dist/lib/{browser → neutral}/Relation.mjs +9 -10
- package/dist/lib/neutral/SchemaRegistry.mjs +2 -0
- package/dist/lib/neutral/Tag.mjs +25 -0
- package/dist/lib/{browser → neutral}/Type.mjs +8 -9
- package/dist/lib/{browser/chunk-NOPVNWPT.mjs → neutral/chunk-2MTHJ5UW.mjs} +6 -7
- package/dist/lib/{node-esm/chunk-ILMLLM4R.mjs.map → neutral/chunk-2MTHJ5UW.mjs.map} +2 -2
- package/dist/lib/{browser/chunk-22JMFST2.mjs → neutral/chunk-3ZEAZF7T.mjs} +3 -4
- package/dist/lib/{browser/chunk-22JMFST2.mjs.map → neutral/chunk-3ZEAZF7T.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-ZHXZGIXD.mjs → neutral/chunk-4L6DOFXP.mjs} +1 -3
- package/dist/lib/{browser/chunk-ZHXZGIXD.mjs.map → neutral/chunk-4L6DOFXP.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-PQZW3S6L.mjs → neutral/chunk-4TT624YA.mjs} +3 -4
- package/dist/lib/{node-esm/chunk-Y75VU7LB.mjs.map → neutral/chunk-4TT624YA.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-FRDT7RA4.mjs → neutral/chunk-62DWJ6CE.mjs} +3 -4
- package/dist/lib/{node-esm/chunk-W6QIEBTQ.mjs.map → neutral/chunk-62DWJ6CE.mjs.map} +3 -3
- package/dist/lib/{browser/chunk-W5D2GWAW.mjs → neutral/chunk-6QPSGMEF.mjs} +5 -6
- package/dist/lib/{browser/chunk-W5D2GWAW.mjs.map → neutral/chunk-6QPSGMEF.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-INHXFXY5.mjs → neutral/chunk-ANHVGJI4.mjs} +2 -3
- package/dist/lib/{node-esm/chunk-AJEMYSIR.mjs.map → neutral/chunk-ANHVGJI4.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-RK4Z4JUZ.mjs → neutral/chunk-CUDIBUM4.mjs} +2 -3
- package/dist/lib/{node-esm/chunk-YOLH5KS4.mjs.map → neutral/chunk-CUDIBUM4.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-XDIUHAAX.mjs → neutral/chunk-HMOXCO27.mjs} +3 -4
- package/dist/lib/{node-esm/chunk-QLI2EIJ2.mjs.map → neutral/chunk-HMOXCO27.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-U2J7TA7K.mjs → neutral/chunk-IP2GHXWA.mjs} +5 -6
- package/dist/lib/{node-esm/chunk-DMR7OAFK.mjs.map → neutral/chunk-IP2GHXWA.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-CGS2ULMK.mjs → neutral/chunk-J5LGTIGS.mjs} +1 -2
- package/dist/lib/{browser/chunk-7STIBCP7.mjs → neutral/chunk-KRHDMXSU.mjs} +4 -5
- package/dist/lib/{browser/chunk-7STIBCP7.mjs.map → neutral/chunk-KRHDMXSU.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-FPOISFQK.mjs → neutral/chunk-NWUO5FKZ.mjs} +3 -4
- package/dist/lib/{node-esm/chunk-NBWL7UCZ.mjs.map → neutral/chunk-NWUO5FKZ.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-IXVWLTG7.mjs → neutral/chunk-OMUPQMLR.mjs} +1 -3
- package/dist/lib/{browser/chunk-IXVWLTG7.mjs.map → neutral/chunk-OMUPQMLR.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-JMKVF2YQ.mjs → neutral/chunk-ROKO4RKJ.mjs} +2 -3
- package/dist/lib/{node-esm/chunk-K37NA7PO.mjs.map → neutral/chunk-ROKO4RKJ.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-CJ5YELTO.mjs → neutral/chunk-RPB6V4BE.mjs} +2 -3
- package/dist/lib/{browser/chunk-CJ5YELTO.mjs.map → neutral/chunk-RPB6V4BE.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-BJPE6CIC.mjs → neutral/chunk-SU2LVM7J.mjs} +47 -48
- package/dist/lib/neutral/chunk-SU2LVM7J.mjs.map +7 -0
- package/dist/lib/{browser/chunk-ZAGAOZVY.mjs → neutral/chunk-VB5HVDCA.mjs} +4 -5
- package/dist/lib/{node-esm/chunk-QYR67VBV.mjs.map → neutral/chunk-VB5HVDCA.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-2SBB7OWV.mjs → neutral/chunk-VR4A4WGG.mjs} +5 -6
- package/dist/lib/{browser/chunk-2SBB7OWV.mjs.map → neutral/chunk-VR4A4WGG.mjs.map} +2 -2
- package/dist/lib/{browser/chunk-MYCCGG2T.mjs → neutral/chunk-X2MPMYYN.mjs} +1 -3
- package/dist/lib/{node-esm/chunk-MOWUEW5P.mjs.map → neutral/chunk-X2MPMYYN.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-6L5HHUVU.mjs → neutral/chunk-XK5OUUBY.mjs} +4 -5
- package/dist/lib/{node-esm/chunk-5OBN7GZW.mjs.map → neutral/chunk-XK5OUUBY.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-KQQGVHFN.mjs → neutral/chunk-XMIDBDE6.mjs} +5 -6
- package/dist/lib/{node-esm/chunk-NRN3ZW2T.mjs.map → neutral/chunk-XMIDBDE6.mjs.map} +1 -1
- package/dist/lib/{browser/chunk-YKTSSMDS.mjs → neutral/chunk-YQYMWZAD.mjs} +1 -3
- package/dist/lib/{node-esm/chunk-XHJRMQZD.mjs.map → neutral/chunk-YQYMWZAD.mjs.map} +1 -1
- package/dist/lib/{browser → neutral}/index.mjs +23 -24
- package/dist/lib/{browser → neutral}/internal/index.mjs +7 -8
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +23 -24
- package/dist/lib/{node-esm → neutral}/testing/index.mjs.map +1 -1
- package/dist/types/src/Obj.d.ts +2 -2
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +1 -1
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/internal/api/meta.d.ts +2 -2
- package/dist/types/src/internal/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/entities/object.d.ts.map +1 -1
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -1
- package/dist/types/src/internal/formats/select.d.ts +2 -2
- package/dist/types/src/internal/formats/select.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts +130 -29
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts +2 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +2 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/schema/compose.d.ts +2 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -1
- package/dist/types/src/internal/types/meta.d.ts +5 -5
- package/dist/types/src/internal/types/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -112
- package/src/Obj.ts +3 -3
- package/src/Relation.ts +2 -2
- package/src/internal/api/meta.ts +3 -3
- package/src/internal/entities/object.ts +1 -3
- package/src/internal/entities/relation.ts +1 -3
- package/src/internal/formats/format.test.ts +1 -1
- package/src/internal/formats/select.ts +1 -1
- package/src/internal/json-schema/json-schema-normalize.ts +4 -2
- package/src/internal/json-schema/json-schema-type.ts +30 -31
- package/src/internal/json-schema/json-schema.ts +10 -6
- package/src/internal/object/json-serializer.test.ts +3 -2
- package/src/internal/object/schema-validator.test.ts +3 -7
- package/src/internal/object/set-value.test.ts +9 -9
- package/src/internal/proxy/typed-handler.test.ts +8 -12
- package/src/internal/proxy/typed-object.test.ts +11 -11
- package/src/internal/ref/ref.test.ts +1 -1
- package/src/internal/ref/ref.ts +2 -1
- package/src/internal/schema/compose.ts +13 -8
- package/src/internal/types/meta.ts +12 -13
- package/dist/lib/browser/Database.mjs +0 -18
- package/dist/lib/browser/JsonSchema.mjs +0 -20
- package/dist/lib/browser/Query.mjs +0 -27
- package/dist/lib/browser/QueryResult.mjs +0 -3
- package/dist/lib/browser/Ref.mjs +0 -23
- package/dist/lib/browser/SchemaRegistry.mjs +0 -3
- package/dist/lib/browser/Tag.mjs +0 -26
- package/dist/lib/browser/chunk-6L5HHUVU.mjs.map +0 -7
- package/dist/lib/browser/chunk-BJPE6CIC.mjs.map +0 -7
- package/dist/lib/browser/chunk-FPOISFQK.mjs.map +0 -7
- package/dist/lib/browser/chunk-FRDT7RA4.mjs.map +0 -7
- package/dist/lib/browser/chunk-INHXFXY5.mjs.map +0 -7
- package/dist/lib/browser/chunk-JMKVF2YQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-KQQGVHFN.mjs.map +0 -7
- package/dist/lib/browser/chunk-MYCCGG2T.mjs.map +0 -7
- package/dist/lib/browser/chunk-NOPVNWPT.mjs.map +0 -7
- package/dist/lib/browser/chunk-PQZW3S6L.mjs.map +0 -7
- package/dist/lib/browser/chunk-RK4Z4JUZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-U2J7TA7K.mjs.map +0 -7
- package/dist/lib/browser/chunk-XDIUHAAX.mjs.map +0 -7
- package/dist/lib/browser/chunk-YKTSSMDS.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZAGAOZVY.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/Annotation.mjs +0 -33
- package/dist/lib/node-esm/Annotation.mjs.map +0 -7
- package/dist/lib/node-esm/Database.mjs +0 -18
- package/dist/lib/node-esm/Database.mjs.map +0 -7
- package/dist/lib/node-esm/Entity.mjs +0 -52
- package/dist/lib/node-esm/Entity.mjs.map +0 -7
- package/dist/lib/node-esm/Err.mjs +0 -11
- package/dist/lib/node-esm/Err.mjs.map +0 -7
- package/dist/lib/node-esm/Filter.mjs +0 -62
- package/dist/lib/node-esm/Filter.mjs.map +0 -7
- package/dist/lib/node-esm/Format.mjs +0 -67
- package/dist/lib/node-esm/Format.mjs.map +0 -7
- package/dist/lib/node-esm/JsonSchema.mjs +0 -20
- package/dist/lib/node-esm/JsonSchema.mjs.map +0 -7
- package/dist/lib/node-esm/Key.mjs +0 -13
- package/dist/lib/node-esm/Key.mjs.map +0 -7
- package/dist/lib/node-esm/Obj.mjs +0 -91
- package/dist/lib/node-esm/Obj.mjs.map +0 -7
- package/dist/lib/node-esm/Order.mjs +0 -13
- package/dist/lib/node-esm/Order.mjs.map +0 -7
- package/dist/lib/node-esm/Query.mjs +0 -27
- package/dist/lib/node-esm/Query.mjs.map +0 -7
- package/dist/lib/node-esm/QueryResult.mjs +0 -3
- package/dist/lib/node-esm/QueryResult.mjs.map +0 -7
- package/dist/lib/node-esm/Ref.mjs +0 -23
- package/dist/lib/node-esm/Ref.mjs.map +0 -7
- package/dist/lib/node-esm/Relation.mjs +0 -85
- package/dist/lib/node-esm/Relation.mjs.map +0 -7
- package/dist/lib/node-esm/SchemaRegistry.mjs +0 -3
- package/dist/lib/node-esm/SchemaRegistry.mjs.map +0 -7
- package/dist/lib/node-esm/Tag.mjs +0 -26
- package/dist/lib/node-esm/Tag.mjs.map +0 -7
- package/dist/lib/node-esm/Type.mjs +0 -48
- package/dist/lib/node-esm/Type.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs +0 -250
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5OBN7GZW.mjs +0 -158
- package/dist/lib/node-esm/chunk-AJEMYSIR.mjs +0 -22
- package/dist/lib/node-esm/chunk-ANLVLWME.mjs +0 -98
- package/dist/lib/node-esm/chunk-ANLVLWME.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DMR7OAFK.mjs +0 -57
- package/dist/lib/node-esm/chunk-FWTSPIFF.mjs +0 -133
- package/dist/lib/node-esm/chunk-FWTSPIFF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ILMLLM4R.mjs +0 -204
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs +0 -43
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs +0 -3847
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MOLNWFNL.mjs +0 -9
- package/dist/lib/node-esm/chunk-MOLNWFNL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MOWUEW5P.mjs +0 -15
- package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs +0 -40
- package/dist/lib/node-esm/chunk-NRN3ZW2T.mjs +0 -143
- package/dist/lib/node-esm/chunk-QLI2EIJ2.mjs +0 -41
- package/dist/lib/node-esm/chunk-QYR67VBV.mjs +0 -288
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs +0 -9
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W6QIEBTQ.mjs +0 -403
- package/dist/lib/node-esm/chunk-XHJRMQZD.mjs +0 -69
- package/dist/lib/node-esm/chunk-Y75VU7LB.mjs +0 -74
- package/dist/lib/node-esm/chunk-YOLH5KS4.mjs +0 -283
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs +0 -39
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs +0 -24
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -85
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/internal/index.mjs +0 -457
- package/dist/lib/node-esm/internal/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -367
- /package/dist/lib/{browser → neutral}/Annotation.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Database.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Entity.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Err.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Filter.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Format.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/JsonSchema.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Key.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Obj.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Order.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Query.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/QueryResult.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Ref.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Relation.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/SchemaRegistry.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Tag.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/Type.mjs.map +0 -0
- /package/dist/lib/{browser/chunk-CGS2ULMK.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{browser → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/internal/index.mjs.map +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.9735255",
|
|
4
4
|
"description": "ECHO API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,181 +16,102 @@
|
|
|
16
16
|
".": {
|
|
17
17
|
"source": "./src/index.ts",
|
|
18
18
|
"types": "./dist/types/src/index.d.ts",
|
|
19
|
-
"
|
|
20
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
19
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
21
20
|
},
|
|
22
21
|
"./internal": {
|
|
23
22
|
"source": "./src/internal/index.ts",
|
|
24
23
|
"types": "./dist/types/src/internal/index.d.ts",
|
|
25
|
-
"
|
|
26
|
-
"node": "./dist/lib/node-esm/internal/index.mjs"
|
|
24
|
+
"default": "./dist/lib/neutral/internal/index.mjs"
|
|
27
25
|
},
|
|
28
26
|
"./testing": {
|
|
29
27
|
"source": "./src/testing/index.ts",
|
|
30
28
|
"types": "./dist/types/src/testing/index.d.ts",
|
|
31
|
-
"
|
|
32
|
-
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
29
|
+
"default": "./dist/lib/neutral/testing/index.mjs"
|
|
33
30
|
},
|
|
34
31
|
"./Annotation": {
|
|
35
32
|
"source": "./src/Annotation.ts",
|
|
36
33
|
"types": "./dist/types/src/Annotation.d.ts",
|
|
37
|
-
"
|
|
38
|
-
"node": "./dist/lib/node-esm/Annotation.mjs"
|
|
34
|
+
"default": "./dist/lib/neutral/Annotation.mjs"
|
|
39
35
|
},
|
|
40
36
|
"./Database": {
|
|
41
37
|
"source": "./src/Database.ts",
|
|
42
38
|
"types": "./dist/types/src/Database.d.ts",
|
|
43
|
-
"
|
|
44
|
-
"node": "./dist/lib/node-esm/Database.mjs"
|
|
39
|
+
"default": "./dist/lib/neutral/Database.mjs"
|
|
45
40
|
},
|
|
46
41
|
"./Entity": {
|
|
47
42
|
"source": "./src/Entity.ts",
|
|
48
43
|
"types": "./dist/types/src/Entity.d.ts",
|
|
49
|
-
"
|
|
50
|
-
"node": "./dist/lib/node-esm/Entity.mjs"
|
|
44
|
+
"default": "./dist/lib/neutral/Entity.mjs"
|
|
51
45
|
},
|
|
52
46
|
"./Err": {
|
|
53
47
|
"source": "./src/Err.ts",
|
|
54
48
|
"types": "./dist/types/src/Err.d.ts",
|
|
55
|
-
"
|
|
56
|
-
"node": "./dist/lib/node-esm/Err.mjs"
|
|
49
|
+
"default": "./dist/lib/neutral/Err.mjs"
|
|
57
50
|
},
|
|
58
51
|
"./Filter": {
|
|
59
52
|
"source": "./src/Filter.ts",
|
|
60
53
|
"types": "./dist/types/src/Filter.d.ts",
|
|
61
|
-
"
|
|
62
|
-
"node": "./dist/lib/node-esm/Filter.mjs"
|
|
54
|
+
"default": "./dist/lib/neutral/Filter.mjs"
|
|
63
55
|
},
|
|
64
56
|
"./Format": {
|
|
65
57
|
"source": "./src/Format.ts",
|
|
66
58
|
"types": "./dist/types/src/Format.d.ts",
|
|
67
|
-
"
|
|
68
|
-
"node": "./dist/lib/node-esm/Format.mjs"
|
|
59
|
+
"default": "./dist/lib/neutral/Format.mjs"
|
|
69
60
|
},
|
|
70
61
|
"./JsonSchema": {
|
|
71
62
|
"source": "./src/JsonSchema.ts",
|
|
72
63
|
"types": "./dist/types/src/JsonSchema.d.ts",
|
|
73
|
-
"
|
|
74
|
-
"node": "./dist/lib/node-esm/JsonSchema.mjs"
|
|
64
|
+
"default": "./dist/lib/neutral/JsonSchema.mjs"
|
|
75
65
|
},
|
|
76
66
|
"./Key": {
|
|
77
67
|
"source": "./src/Key.ts",
|
|
78
68
|
"types": "./dist/types/src/Key.d.ts",
|
|
79
|
-
"
|
|
80
|
-
"node": "./dist/lib/node-esm/Key.mjs"
|
|
69
|
+
"default": "./dist/lib/neutral/Key.mjs"
|
|
81
70
|
},
|
|
82
71
|
"./Obj": {
|
|
83
72
|
"source": "./src/Obj.ts",
|
|
84
73
|
"types": "./dist/types/src/Obj.d.ts",
|
|
85
|
-
"
|
|
86
|
-
"node": "./dist/lib/node-esm/Obj.mjs"
|
|
74
|
+
"default": "./dist/lib/neutral/Obj.mjs"
|
|
87
75
|
},
|
|
88
76
|
"./Order": {
|
|
89
77
|
"source": "./src/Order.ts",
|
|
90
78
|
"types": "./dist/types/src/Order.d.ts",
|
|
91
|
-
"
|
|
92
|
-
"node": "./dist/lib/node-esm/Order.mjs"
|
|
79
|
+
"default": "./dist/lib/neutral/Order.mjs"
|
|
93
80
|
},
|
|
94
81
|
"./Query": {
|
|
95
82
|
"source": "./src/Query.ts",
|
|
96
83
|
"types": "./dist/types/src/Query.d.ts",
|
|
97
|
-
"
|
|
98
|
-
"node": "./dist/lib/node-esm/Query.mjs"
|
|
84
|
+
"default": "./dist/lib/neutral/Query.mjs"
|
|
99
85
|
},
|
|
100
86
|
"./QueryResult": {
|
|
101
87
|
"source": "./src/QueryResult.ts",
|
|
102
88
|
"types": "./dist/types/src/QueryResult.d.ts",
|
|
103
|
-
"
|
|
104
|
-
"node": "./dist/lib/node-esm/QueryResult.mjs"
|
|
89
|
+
"default": "./dist/lib/neutral/QueryResult.mjs"
|
|
105
90
|
},
|
|
106
91
|
"./Ref": {
|
|
107
92
|
"source": "./src/Ref.ts",
|
|
108
93
|
"types": "./dist/types/src/Ref.d.ts",
|
|
109
|
-
"
|
|
110
|
-
"node": "./dist/lib/node-esm/Ref.mjs"
|
|
94
|
+
"default": "./dist/lib/neutral/Ref.mjs"
|
|
111
95
|
},
|
|
112
96
|
"./Relation": {
|
|
113
97
|
"source": "./src/Relation.ts",
|
|
114
98
|
"types": "./dist/types/src/Relation.d.ts",
|
|
115
|
-
"
|
|
116
|
-
"node": "./dist/lib/node-esm/Relation.mjs"
|
|
99
|
+
"default": "./dist/lib/neutral/Relation.mjs"
|
|
117
100
|
},
|
|
118
101
|
"./SchemaRegistry": {
|
|
119
102
|
"source": "./src/SchemaRegistry.ts",
|
|
120
103
|
"types": "./dist/types/src/SchemaRegistry.d.ts",
|
|
121
|
-
"
|
|
122
|
-
"node": "./dist/lib/node-esm/SchemaRegistry.mjs"
|
|
104
|
+
"default": "./dist/lib/neutral/SchemaRegistry.mjs"
|
|
123
105
|
},
|
|
124
106
|
"./Tag": {
|
|
125
107
|
"source": "./src/Tag.ts",
|
|
126
108
|
"types": "./dist/types/src/Tag.d.ts",
|
|
127
|
-
"
|
|
128
|
-
"node": "./dist/lib/node-esm/Tag.mjs"
|
|
109
|
+
"default": "./dist/lib/neutral/Tag.mjs"
|
|
129
110
|
},
|
|
130
111
|
"./Type": {
|
|
131
112
|
"source": "./src/Type.ts",
|
|
132
113
|
"types": "./dist/types/src/Type.d.ts",
|
|
133
|
-
"
|
|
134
|
-
"node": "./dist/lib/node-esm/Type.mjs"
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
"types": "dist/types/src/index.d.ts",
|
|
138
|
-
"typesVersions": {
|
|
139
|
-
"*": {
|
|
140
|
-
"internal": [
|
|
141
|
-
"dist/types/src/internal/index.d.ts"
|
|
142
|
-
],
|
|
143
|
-
"testing": [
|
|
144
|
-
"dist/types/src/testing/index.d.ts"
|
|
145
|
-
],
|
|
146
|
-
"Annotation": [
|
|
147
|
-
"dist/types/src/Annotation.d.ts"
|
|
148
|
-
],
|
|
149
|
-
"Database": [
|
|
150
|
-
"dist/types/src/Database.d.ts"
|
|
151
|
-
],
|
|
152
|
-
"Entity": [
|
|
153
|
-
"dist/types/src/Entity.d.ts"
|
|
154
|
-
],
|
|
155
|
-
"Err": [
|
|
156
|
-
"dist/types/src/Err.d.ts"
|
|
157
|
-
],
|
|
158
|
-
"Filter": [
|
|
159
|
-
"dist/types/src/Filter.d.ts"
|
|
160
|
-
],
|
|
161
|
-
"Format": [
|
|
162
|
-
"dist/types/src/Format.d.ts"
|
|
163
|
-
],
|
|
164
|
-
"JsonSchema": [
|
|
165
|
-
"dist/types/src/JsonSchema.d.ts"
|
|
166
|
-
],
|
|
167
|
-
"Key": [
|
|
168
|
-
"dist/types/src/Key.d.ts"
|
|
169
|
-
],
|
|
170
|
-
"Obj": [
|
|
171
|
-
"dist/types/src/Obj.d.ts"
|
|
172
|
-
],
|
|
173
|
-
"Order": [
|
|
174
|
-
"dist/types/src/Order.d.ts"
|
|
175
|
-
],
|
|
176
|
-
"Query": [
|
|
177
|
-
"dist/types/src/Query.d.ts"
|
|
178
|
-
],
|
|
179
|
-
"QueryResult": [
|
|
180
|
-
"dist/types/src/QueryResult.d.ts"
|
|
181
|
-
],
|
|
182
|
-
"Ref": [
|
|
183
|
-
"dist/types/src/Ref.d.ts"
|
|
184
|
-
],
|
|
185
|
-
"Relation": [
|
|
186
|
-
"dist/types/src/Relation.d.ts"
|
|
187
|
-
],
|
|
188
|
-
"Tag": [
|
|
189
|
-
"dist/types/src/Tag.d.ts"
|
|
190
|
-
],
|
|
191
|
-
"Type": [
|
|
192
|
-
"dist/types/src/Type.d.ts"
|
|
193
|
-
]
|
|
114
|
+
"default": "./dist/lib/neutral/Type.mjs"
|
|
194
115
|
}
|
|
195
116
|
},
|
|
196
117
|
"files": [
|
|
@@ -199,18 +120,18 @@
|
|
|
199
120
|
],
|
|
200
121
|
"dependencies": {
|
|
201
122
|
"effect": "3.19.11",
|
|
202
|
-
"@dxos/
|
|
203
|
-
"@dxos/
|
|
204
|
-
"@dxos/
|
|
205
|
-
"@dxos/
|
|
206
|
-
"@dxos/
|
|
207
|
-
"@dxos/errors": "0.8.4-main.
|
|
208
|
-
"@dxos/
|
|
209
|
-
"@dxos/
|
|
210
|
-
"@dxos/
|
|
211
|
-
"@dxos/
|
|
212
|
-
"@dxos/protocols": "0.8.4-main.
|
|
213
|
-
"@dxos/util": "0.8.4-main.
|
|
123
|
+
"@dxos/async": "0.8.4-main.9735255",
|
|
124
|
+
"@dxos/echo-protocol": "0.8.4-main.9735255",
|
|
125
|
+
"@dxos/debug": "0.8.4-main.9735255",
|
|
126
|
+
"@dxos/effect": "0.8.4-main.9735255",
|
|
127
|
+
"@dxos/invariant": "0.8.4-main.9735255",
|
|
128
|
+
"@dxos/errors": "0.8.4-main.9735255",
|
|
129
|
+
"@dxos/context": "0.8.4-main.9735255",
|
|
130
|
+
"@dxos/log": "0.8.4-main.9735255",
|
|
131
|
+
"@dxos/node-std": "0.8.4-main.9735255",
|
|
132
|
+
"@dxos/keys": "0.8.4-main.9735255",
|
|
133
|
+
"@dxos/protocols": "0.8.4-main.9735255",
|
|
134
|
+
"@dxos/util": "0.8.4-main.9735255"
|
|
214
135
|
},
|
|
215
136
|
"publishConfig": {
|
|
216
137
|
"access": "public"
|
package/src/Obj.ts
CHANGED
|
@@ -316,7 +316,7 @@ export const getValue = (obj: Unknown | Snapshot, path: readonly (string | numbe
|
|
|
316
316
|
* @example
|
|
317
317
|
* ```ts
|
|
318
318
|
* const person = Obj.make(Person, { name: 'John' });
|
|
319
|
-
* // Person schema has: addresses: Schema.
|
|
319
|
+
* // Person schema has: addresses: Schema.Array(Address)
|
|
320
320
|
* Obj.change(person, (p) => {
|
|
321
321
|
* Obj.setValue(p, ['addresses', 0, 'street'], '123 Main St');
|
|
322
322
|
* });
|
|
@@ -436,9 +436,9 @@ export type Meta = ApiMeta;
|
|
|
436
436
|
* ```
|
|
437
437
|
*/
|
|
438
438
|
// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
439
|
-
export function getMeta(entity: Mutable<Unknown>):
|
|
439
|
+
export function getMeta(entity: Mutable<Unknown>): Meta;
|
|
440
440
|
export function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;
|
|
441
|
-
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>):
|
|
441
|
+
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): Meta | ReadonlyMeta {
|
|
442
442
|
return getMeta$(entity);
|
|
443
443
|
}
|
|
444
444
|
|
package/src/Relation.ts
CHANGED
|
@@ -372,9 +372,9 @@ export type Meta = ApiMeta;
|
|
|
372
372
|
* Returns read-only meta when passed a regular relation or snapshot.
|
|
373
373
|
*/
|
|
374
374
|
// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
375
|
-
export function getMeta(entity: Mutable<Unknown>):
|
|
375
|
+
export function getMeta(entity: Mutable<Unknown>): Meta;
|
|
376
376
|
export function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;
|
|
377
|
-
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>):
|
|
377
|
+
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): Meta | ReadonlyMeta {
|
|
378
378
|
return getMeta$(entity);
|
|
379
379
|
}
|
|
380
380
|
|
package/src/internal/api/meta.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type ReadonlyMeta = DeepReadonly<ObjectMeta>;
|
|
|
17
17
|
/**
|
|
18
18
|
* Mutable meta type received in meta mutation callbacks.
|
|
19
19
|
*/
|
|
20
|
-
export type Meta = ObjectMeta
|
|
20
|
+
export type Meta = Mutable<ObjectMeta>;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Get the metadata for an entity with validation.
|
|
@@ -26,9 +26,9 @@ export type Meta = ObjectMeta;
|
|
|
26
26
|
*
|
|
27
27
|
* TODO(burdon): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
28
28
|
*/
|
|
29
|
-
export function getMetaChecked(entity: Mutable<AnyProperties>):
|
|
29
|
+
export function getMetaChecked(entity: Mutable<AnyProperties>): Meta;
|
|
30
30
|
export function getMetaChecked(entity: AnyProperties): ReadonlyMeta;
|
|
31
|
-
export function getMetaChecked(entity: AnyProperties):
|
|
31
|
+
export function getMetaChecked(entity: AnyProperties): Meta | ReadonlyMeta {
|
|
32
32
|
assertArgument(entity, 'entity', 'Should be an entity.');
|
|
33
33
|
const meta = getMeta$(entity);
|
|
34
34
|
invariant(meta != null, 'Invalid entity.');
|
|
@@ -40,9 +40,7 @@ export const EchoObjectSchema: {
|
|
|
40
40
|
// Extract fields from the schema if available (Struct schemas have .fields).
|
|
41
41
|
const fields = ((self as any).fields ?? {}) as Fields;
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
// TODO(dmaretskyi): Do not do mutable here.
|
|
45
|
-
const schemaWithId = Schema.extend(Schema.mutable(self), Schema.Struct({ id: Schema.String }));
|
|
43
|
+
const schemaWithId = Schema.extend(self, Schema.Struct({ id: Schema.String }));
|
|
46
44
|
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
47
45
|
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
48
46
|
...self.ast.annotations,
|
|
@@ -129,9 +129,7 @@ export const EchoRelationSchema = <
|
|
|
129
129
|
// Extract fields from the schema if available (Struct schemas have .fields).
|
|
130
130
|
const fields = ((self as any).fields ?? {}) as Fields;
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
// TODO(dmaretskyi): Do not do mutable here.
|
|
134
|
-
const schemaWithId = Schema.extend(Schema.mutable(self), Schema.Struct({ id: Schema.String }));
|
|
132
|
+
const schemaWithId = Schema.extend(self, Schema.Struct({ id: Schema.String }));
|
|
135
133
|
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
136
134
|
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
137
135
|
...self.ast.annotations,
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as Types from 'effect/Types';
|
|
6
|
+
|
|
5
7
|
import { JsonSchemaFields, type JsonSchemaType } from './json-schema-type';
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -9,12 +11,12 @@ import { JsonSchemaFields, type JsonSchemaType } from './json-schema-type';
|
|
|
9
11
|
* Note: the input type does not necessarily match the {@link JsonSchemaType} type.
|
|
10
12
|
*/
|
|
11
13
|
export const normalizeSchema = (schema: JsonSchemaType): JsonSchemaType => {
|
|
12
|
-
const copy = structuredClone(schema)
|
|
14
|
+
const copy = structuredClone(schema) as Types.DeepMutable<JsonSchemaType>;
|
|
13
15
|
go(copy);
|
|
14
16
|
return copy;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
const go = (schema: JsonSchemaType) => {
|
|
19
|
+
const go = (schema: Types.DeepMutable<JsonSchemaType>) => {
|
|
18
20
|
if (typeof schema !== 'object' || schema === null) {
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
@@ -7,6 +7,7 @@ import * as Schema from 'effect/Schema';
|
|
|
7
7
|
import { JsonPath, type JsonProp } from '@dxos/effect';
|
|
8
8
|
|
|
9
9
|
import { FormatAnnotation, TypeFormat } from '../formats';
|
|
10
|
+
import { type Mutable } from '../proxy';
|
|
10
11
|
import { EntityKindSchema } from '../types';
|
|
11
12
|
|
|
12
13
|
//
|
|
@@ -18,7 +19,7 @@ const SimpleTypes = Schema.Literal('array', 'boolean', 'integer', 'null', 'numbe
|
|
|
18
19
|
|
|
19
20
|
const NonNegativeInteger = Schema.Number.pipe(Schema.greaterThanOrEqualTo(0));
|
|
20
21
|
|
|
21
|
-
const StringArray = Schema.Array(Schema.String)
|
|
22
|
+
const StringArray = Schema.Array(Schema.String);
|
|
22
23
|
|
|
23
24
|
const JsonSchemaOrBoolean = Schema.Union(
|
|
24
25
|
Schema.suspend(() => JsonSchemaType),
|
|
@@ -48,7 +49,7 @@ export const JsonSchemaEchoAnnotations = Schema.Struct({
|
|
|
48
49
|
Schema.Record({
|
|
49
50
|
key: Schema.String,
|
|
50
51
|
value: Schema.Any,
|
|
51
|
-
})
|
|
52
|
+
}),
|
|
52
53
|
),
|
|
53
54
|
|
|
54
55
|
/**
|
|
@@ -62,7 +63,7 @@ export const JsonSchemaEchoAnnotations = Schema.Struct({
|
|
|
62
63
|
|
|
63
64
|
// Not used.
|
|
64
65
|
schemaId: Schema.optional(Schema.String),
|
|
65
|
-
})
|
|
66
|
+
}),
|
|
66
67
|
),
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -72,9 +73,9 @@ export const JsonSchemaEchoAnnotations = Schema.Struct({
|
|
|
72
73
|
Schema.Record({
|
|
73
74
|
key: Schema.String,
|
|
74
75
|
value: Schema.Any,
|
|
75
|
-
})
|
|
76
|
+
}),
|
|
76
77
|
),
|
|
77
|
-
})
|
|
78
|
+
});
|
|
78
79
|
export type JsonSchemaEchoAnnotations = Schema.Schema.Type<typeof JsonSchemaEchoAnnotations>;
|
|
79
80
|
|
|
80
81
|
/**
|
|
@@ -257,23 +258,21 @@ const _JsonSchemaType = Schema.Struct({
|
|
|
257
258
|
Schema.Record({
|
|
258
259
|
key: Schema.String,
|
|
259
260
|
value: Schema.suspend(() => JsonSchemaType),
|
|
260
|
-
})
|
|
261
|
+
}),
|
|
261
262
|
),
|
|
262
263
|
patternProperties: Schema.optional(
|
|
263
264
|
Schema.Record({
|
|
264
265
|
key: Schema.String,
|
|
265
266
|
value: Schema.suspend(() => JsonSchemaType),
|
|
266
|
-
})
|
|
267
|
+
}),
|
|
267
268
|
),
|
|
268
269
|
propertyNames: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
269
270
|
|
|
270
271
|
definitions: Schema.optional(
|
|
271
|
-
Schema.
|
|
272
|
-
Schema.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}),
|
|
276
|
-
),
|
|
272
|
+
Schema.Record({
|
|
273
|
+
key: Schema.String,
|
|
274
|
+
value: Schema.suspend(() => JsonSchemaType),
|
|
275
|
+
}),
|
|
277
276
|
),
|
|
278
277
|
dependencies: Schema.optional(
|
|
279
278
|
Schema.Record({
|
|
@@ -296,12 +295,10 @@ const _JsonSchemaType = Schema.Struct({
|
|
|
296
295
|
oneOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),
|
|
297
296
|
not: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
298
297
|
$defs: Schema.optional(
|
|
299
|
-
Schema.
|
|
300
|
-
Schema.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}),
|
|
304
|
-
),
|
|
298
|
+
Schema.Record({
|
|
299
|
+
key: Schema.String,
|
|
300
|
+
value: Schema.suspend(() => JsonSchemaType),
|
|
301
|
+
}),
|
|
305
302
|
),
|
|
306
303
|
|
|
307
304
|
//
|
|
@@ -311,25 +308,23 @@ const _JsonSchemaType = Schema.Struct({
|
|
|
311
308
|
currency: Schema.optional(Schema.String),
|
|
312
309
|
|
|
313
310
|
reference: Schema.optional(
|
|
314
|
-
Schema.
|
|
315
|
-
Schema.
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}),
|
|
320
|
-
),
|
|
311
|
+
Schema.Struct({
|
|
312
|
+
schema: Schema.suspend(() => JsonSchemaType),
|
|
313
|
+
schemaVersion: Schema.optional(Schema.String),
|
|
314
|
+
schemaObject: Schema.optional(Schema.String),
|
|
315
|
+
}),
|
|
321
316
|
),
|
|
322
317
|
|
|
323
318
|
/**
|
|
324
319
|
* ECHO-specific annotations.
|
|
325
320
|
*/
|
|
326
321
|
// TODO(dmaretskyi): Since we are adding a lot of new extensions to the JSON Schema, it is safer to namespace them here.
|
|
327
|
-
annotations: Schema.optional(
|
|
322
|
+
annotations: Schema.optional(JsonSchemaEchoAnnotations),
|
|
328
323
|
|
|
329
324
|
/**
|
|
330
325
|
* @deprecated Use `annotations` instead.
|
|
331
326
|
*/
|
|
332
|
-
echo: Schema.optional(
|
|
327
|
+
echo: Schema.optional(JsonSchemaEchoAnnotations),
|
|
333
328
|
}).annotations({ identifier: 'jsonSchema', description: 'JSON Schema' });
|
|
334
329
|
|
|
335
330
|
export const JsonSchemaFields = Object.keys(_JsonSchemaType.fields);
|
|
@@ -338,9 +333,9 @@ export const JsonSchemaFields = Object.keys(_JsonSchemaType.fields);
|
|
|
338
333
|
* https://json-schema.org/draft-07/schema
|
|
339
334
|
*/
|
|
340
335
|
// TODO(burdon): Reconcile with @effect/Schema/JSONSchema
|
|
341
|
-
export interface JsonSchemaType extends Schema.Schema.Type<
|
|
336
|
+
export interface JsonSchemaType extends Schema.Schema.Type<typeof _JsonSchemaType> {}
|
|
342
337
|
|
|
343
|
-
export const JsonSchemaType: Schema.Schema<JsonSchemaType> = _JsonSchemaType
|
|
338
|
+
export const JsonSchemaType: Schema.Schema<JsonSchemaType> = _JsonSchemaType;
|
|
344
339
|
|
|
345
340
|
// TODO(burdon): Factor out JSON schema utils.
|
|
346
341
|
|
|
@@ -349,7 +344,11 @@ export const getSchemaProperty = (schema: JsonSchemaType, property: JsonProp): J
|
|
|
349
344
|
};
|
|
350
345
|
|
|
351
346
|
// TODO(burdon): Properties should be ordered.
|
|
352
|
-
export const setSchemaProperty = (
|
|
347
|
+
export const setSchemaProperty = (
|
|
348
|
+
schema: Mutable<JsonSchemaType>,
|
|
349
|
+
property: JsonProp,
|
|
350
|
+
value: Mutable<JsonSchemaType>,
|
|
351
|
+
) => {
|
|
353
352
|
schema.properties ??= {};
|
|
354
353
|
schema.properties[property] = value;
|
|
355
354
|
return schema;
|
|
@@ -80,7 +80,11 @@ export type JsonSchemaOptions = {
|
|
|
80
80
|
*/
|
|
81
81
|
// TODO(burdon): Reconcile with possibly extending @effect/Schema/JSONSchema
|
|
82
82
|
// We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
|
|
83
|
-
|
|
83
|
+
// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
|
|
84
|
+
export const toJsonSchema = (
|
|
85
|
+
schema: Schema.Schema.All,
|
|
86
|
+
options: JsonSchemaOptions = {},
|
|
87
|
+
): Types.DeepMutable<JsonSchemaType> => {
|
|
84
88
|
assertArgument(Schema.isSchema(schema), 'schema');
|
|
85
89
|
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
86
90
|
if (options.strict) {
|
|
@@ -103,11 +107,11 @@ export const toJsonSchema = (schema: Schema.Schema.All, options: JsonSchemaOptio
|
|
|
103
107
|
return jsonSchema;
|
|
104
108
|
};
|
|
105
109
|
|
|
106
|
-
const _toJsonSchemaAST = (ast: SchemaAST.AST): JsonSchemaType => {
|
|
110
|
+
const _toJsonSchemaAST = (ast: SchemaAST.AST): Types.DeepMutable<JsonSchemaType> => {
|
|
107
111
|
const withRefinements = withEchoRefinements(ast, '#');
|
|
108
112
|
const jsonSchema = JSONSchema.fromAST(withRefinements, {
|
|
109
113
|
definitions: {},
|
|
110
|
-
}) as JsonSchemaType
|
|
114
|
+
}) as Types.DeepMutable<JsonSchemaType>;
|
|
111
115
|
|
|
112
116
|
return normalizeJsonSchema(jsonSchema);
|
|
113
117
|
};
|
|
@@ -326,7 +330,7 @@ const objectToEffectSchema = (root: JsonSchemaType, defs: JsonSchemaType['$defs'
|
|
|
326
330
|
}
|
|
327
331
|
|
|
328
332
|
if (immutableIdField) {
|
|
329
|
-
schema = Schema.extend(
|
|
333
|
+
schema = Schema.extend(schema, Schema.Struct({ id: immutableIdField }));
|
|
330
334
|
}
|
|
331
335
|
|
|
332
336
|
const annotations = jsonSchemaFieldsToAnnotations(root);
|
|
@@ -377,7 +381,7 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
|
377
381
|
const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Record<symbol, any> => {
|
|
378
382
|
const schemaFields: Record<string, any> = {};
|
|
379
383
|
|
|
380
|
-
const echoAnnotations: JsonSchemaEchoAnnotations = {};
|
|
384
|
+
const echoAnnotations: Types.Mutable<JsonSchemaEchoAnnotations> = {};
|
|
381
385
|
for (const [key, annotationId] of Object.entries(EchoAnnotations)) {
|
|
382
386
|
if (annotations[annotationId] != null) {
|
|
383
387
|
echoAnnotations[key as keyof JsonSchemaEchoAnnotations] = annotations[annotationId] as any;
|
|
@@ -495,7 +499,7 @@ const addJsonSchemaFields = (ast: SchemaAST.AST, schema: JsonSchemaType): Schema
|
|
|
495
499
|
* Fixes field order.
|
|
496
500
|
* Sets `$schema` prop.
|
|
497
501
|
*/
|
|
498
|
-
const normalizeJsonSchema = (jsonSchema: JsonSchemaType): JsonSchemaType => {
|
|
502
|
+
const normalizeJsonSchema = (jsonSchema: Types.DeepMutable<JsonSchemaType>): Types.DeepMutable<JsonSchemaType> => {
|
|
499
503
|
if (jsonSchema.properties && 'id' in jsonSchema.properties) {
|
|
500
504
|
jsonSchema.properties = orderKeys(jsonSchema.properties, ['id']); // Put id first.
|
|
501
505
|
}
|
|
@@ -9,10 +9,11 @@ import { DXN } from '@dxos/keys';
|
|
|
9
9
|
import * as Obj from '../../Obj';
|
|
10
10
|
import { TestSchema } from '../../testing';
|
|
11
11
|
import { getSchemaDXN, getSchemaTypename, getTypeDXN, getTypename } from '../annotations';
|
|
12
|
+
import { getMetaChecked } from '../api';
|
|
12
13
|
import { RelationSourceId, RelationTargetId, getObjectDXN } from '../entities';
|
|
13
14
|
import { makeObject } from '../proxy';
|
|
14
15
|
import { Ref, StaticRefResolver } from '../ref';
|
|
15
|
-
import { ATTR_TYPE, EntityKind, KindId, MetaId, TypeId,
|
|
16
|
+
import { ATTR_TYPE, EntityKind, KindId, MetaId, TypeId, getSchema } from '../types';
|
|
16
17
|
|
|
17
18
|
import { createObject } from './create-object';
|
|
18
19
|
import { objectFromJSON, objectToJSON } from './json-serializer';
|
|
@@ -21,7 +22,7 @@ describe('Object JSON serializer', () => {
|
|
|
21
22
|
test('should serialize and deserialize object', async () => {
|
|
22
23
|
const contact = makeObject(TestSchema.Person, { name: 'Alice' });
|
|
23
24
|
Obj.change(contact, (c) => {
|
|
24
|
-
|
|
25
|
+
getMetaChecked(c).keys.push({ id: '12345', source: 'example.com' });
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
const task = createObject(TestSchema.Task, {
|
|
@@ -27,9 +27,7 @@ describe('schema-validator', () => {
|
|
|
27
27
|
const TestSchema: Schema.Schema.AnyNoContext = Schema.Struct({
|
|
28
28
|
name: Schema.String.annotations({ [annotationId]: annotationValue }),
|
|
29
29
|
parent: Schema.optional(Schema.suspend(() => TestSchema.annotations({ [annotationId]: annotationValue }))),
|
|
30
|
-
friends: Schema.suspend(() =>
|
|
31
|
-
Schema.mutable(Schema.Array(TestSchema.annotations({ [annotationId]: annotationValue }))),
|
|
32
|
-
),
|
|
30
|
+
friends: Schema.suspend(() => Schema.Array(TestSchema.annotations({ [annotationId]: annotationValue }))),
|
|
33
31
|
});
|
|
34
32
|
expect(SchemaValidator.hasTypeAnnotation(TestSchema, 'name', annotationId)).to.be.true;
|
|
35
33
|
expect(SchemaValidator.hasTypeAnnotation(TestSchema, 'parent', annotationId)).to.be.true;
|
|
@@ -41,7 +39,7 @@ describe('schema-validator', () => {
|
|
|
41
39
|
const Person: Schema.Schema.AnyNoContext = Schema.Struct({
|
|
42
40
|
name: Schema.String,
|
|
43
41
|
parent: Schema.optional(Schema.suspend(() => Person)),
|
|
44
|
-
friends: Schema.suspend(() => Schema.
|
|
42
|
+
friends: Schema.suspend(() => Schema.Array(Person)),
|
|
45
43
|
});
|
|
46
44
|
expect(SchemaValidator.hasTypeAnnotation(Person, 'name', annotationId)).to.be.false;
|
|
47
45
|
expect(SchemaValidator.hasTypeAnnotation(Person, 'parent', annotationId)).to.be.false;
|
|
@@ -87,9 +85,7 @@ describe('schema-validator', () => {
|
|
|
87
85
|
const annotationValue = 'bar';
|
|
88
86
|
const Person: Schema.Schema.AnyNoContext = Schema.Struct({
|
|
89
87
|
parent: Schema.optional(Schema.suspend(() => Person.annotations({ [annotationId]: annotationValue }))),
|
|
90
|
-
friends: Schema.suspend(() =>
|
|
91
|
-
Schema.mutable(Schema.Array(Person.annotations({ [annotationId]: annotationValue }))),
|
|
92
|
-
),
|
|
88
|
+
friends: Schema.suspend(() => Schema.Array(Person.annotations({ [annotationId]: annotationValue }))),
|
|
93
89
|
});
|
|
94
90
|
expect(SchemaValidator.getPropertySchema(Person, ['parent']).ast.annotations[annotationId]).to.eq(
|
|
95
91
|
annotationValue,
|