@dxos/echo 0.8.4-staging.ac66bdf99f → 0.9.0
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/LICENSE +102 -5
- package/README.md +7 -7
- package/dist/lib/neutral/Annotation.mjs +37 -6
- package/dist/lib/neutral/Database.mjs +6 -17
- package/dist/lib/neutral/Entity.mjs +31 -20
- package/dist/lib/neutral/Err.mjs +3 -3
- package/dist/lib/neutral/Feed.mjs +23 -19
- package/dist/lib/neutral/Filter.mjs +13 -15
- package/dist/lib/neutral/Format.mjs +23 -3
- package/dist/lib/neutral/JsonSchema.mjs +7 -8
- package/dist/lib/neutral/Key.mjs +9 -5
- package/dist/lib/neutral/Migration.mjs +11 -10
- package/dist/lib/neutral/Obj.mjs +29 -20
- package/dist/lib/neutral/Order.mjs +7 -3
- package/dist/lib/neutral/Query.mjs +17 -17
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +10 -9
- package/dist/lib/neutral/Registry.mjs +14 -0
- package/dist/lib/neutral/Relation.mjs +28 -25
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Tag.mjs +17 -14
- package/dist/lib/neutral/Type.mjs +54 -26
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-35INCYOE.mjs} +1 -1
- package/dist/lib/neutral/chunk-35INCYOE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs +101 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +184 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs +108 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OS35K56T.mjs → chunk-5SUJPHAE.mjs} +3 -3
- package/dist/lib/neutral/{chunk-OS35K56T.mjs.map → chunk-5SUJPHAE.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-GZQTCRJB.mjs → chunk-6M2Z6WBH.mjs} +22 -2
- package/dist/lib/neutral/chunk-6M2Z6WBH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-V36VO5SS.mjs → chunk-6YDI3J37.mjs} +32 -40
- package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MOR5ERFM.mjs → chunk-7FPIAJIV.mjs} +701 -1256
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7LOUAPYZ.mjs} +9 -5
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-JUXPFOEI.mjs → chunk-7PI7C4EF.mjs} +48 -88
- package/dist/lib/neutral/chunk-7PI7C4EF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UBEZSGXY.mjs → chunk-BBFJWWAV.mjs} +6 -6
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UI6MWK5W.mjs → chunk-EVK6XBXO.mjs} +16 -2
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7RO7CPBZ.mjs → chunk-IGK6FN65.mjs} +2 -2
- package/dist/lib/neutral/{chunk-HBUZJNZO.mjs → chunk-LWXVKPPW.mjs} +94 -99
- package/dist/lib/neutral/chunk-LWXVKPPW.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BVOFLCVF.mjs → chunk-MZ7K3MLL.mjs} +9 -6
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TBKX6JQO.mjs → chunk-O6BH7EPN.mjs} +30 -3
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-EAMSSLZC.mjs → chunk-QQIYS74I.mjs} +83 -46
- package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs +678 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WAK4DMFV.mjs → chunk-RIVWNMSF.mjs} +12 -7
- package/dist/lib/neutral/chunk-RIVWNMSF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-T6W2LEZU.mjs → chunk-SBVFRTST.mjs} +73 -38
- package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs +251 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DQYLD2RB.mjs → chunk-TFEWTY5A.mjs} +155 -129
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B4BASU6W.mjs → chunk-TYGKCRMK.mjs} +85 -76
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4OIBYSXE.mjs → chunk-UUP46KUQ.mjs} +78 -32
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs +36 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-G3IQMKF7.mjs → chunk-WTQJHC75.mjs} +111 -112
- package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs +31 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TU3GW67D.mjs → chunk-ZGNNFYHS.mjs} +40 -40
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +47 -41
- package/dist/lib/neutral/internal/index.mjs +137 -72
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +261 -178
- package/dist/lib/neutral/testing/index.mjs.map +4 -4
- package/dist/types/src/Annotation.d.ts +108 -4
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Annotation.test.d.ts +2 -0
- package/dist/types/src/Annotation.test.d.ts.map +1 -0
- package/dist/types/src/Collection.d.ts +2 -3
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +56 -49
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +16 -6
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +101 -28
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +27 -27
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +66 -19
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +38 -12
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Format.d.ts +0 -2
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +14 -9
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +2 -2
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Key.d.ts +1 -1
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +26 -11
- package/dist/types/src/Migration.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +104 -61
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts +10 -0
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +34 -12
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +21 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +15 -7
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Registry.d.ts +131 -0
- package/dist/types/src/Registry.d.ts.map +1 -0
- package/dist/types/src/Relation.d.ts +73 -41
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Scope.d.ts +35 -0
- package/dist/types/src/Scope.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +21 -5
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +362 -95
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +9 -12
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +79 -38
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
- package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -2
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/util.d.ts +14 -5
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts +17 -3
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/entity.d.ts +72 -8
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/guard.d.ts +10 -0
- package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +21 -17
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/object.d.ts +3 -3
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/relation.d.ts +30 -7
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -1
- package/dist/types/src/internal/Format/date.d.ts.map +1 -1
- package/dist/types/src/internal/Format/format.d.ts +3 -2
- package/dist/types/src/internal/Format/format.d.ts.map +1 -1
- package/dist/types/src/internal/Format/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -1
- package/dist/types/src/internal/Format/number.d.ts.map +1 -1
- package/dist/types/src/internal/Format/object.d.ts +3 -1
- package/dist/types/src/internal/Format/object.d.ts.map +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +34 -34
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts +3 -2
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/atoms.d.ts +38 -0
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/create-object.d.ts +12 -12
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/index.d.ts +1 -1
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts +8 -8
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
- 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.d.ts → Query/pretty.d.ts} +1 -1
- package/dist/types/src/internal/Query/pretty.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/atoms.d.ts +10 -0
- package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
- package/dist/types/src/internal/Ref/ref.d.ts +50 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/utils.d.ts +8 -0
- package/dist/types/src/internal/Ref/utils.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -1
- package/dist/types/src/internal/Type/index.d.ts +1 -2
- package/dist/types/src/internal/Type/index.d.ts.map +1 -1
- package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
- package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts +14 -11
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/base.d.ts +4 -4
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/entity.d.ts +62 -5
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/index.d.ts +1 -1
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +33 -12
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/model-symbols.d.ts +15 -4
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/typename.d.ts +7 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/version.d.ts +1 -1
- package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
- package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +2 -2
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/registry.d.ts +9 -0
- package/dist/types/src/testing/registry.d.ts.map +1 -0
- package/dist/types/src/testing/test-data.d.ts +8 -8
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +83 -89
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +5 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -24
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +158 -4
- package/src/Collection.ts +5 -9
- package/src/Database.ts +93 -100
- package/src/Dataset.ts +10 -2
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +134 -32
- package/src/Err.ts +4 -4
- package/src/Feed.ts +92 -44
- package/src/Filter.ts +70 -40
- package/src/Format.ts +0 -4
- package/src/Hypergraph.ts +14 -9
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/Key.ts +1 -1
- package/src/Migration.ts +39 -19
- package/src/Obj.test.ts +122 -20
- package/src/Obj.ts +168 -91
- package/src/Order.ts +22 -0
- package/src/Query.test.ts +183 -154
- package/src/Query.ts +172 -85
- package/src/QueryResult.ts +26 -0
- package/src/Ref.ts +22 -4
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +10 -10
- package/src/Relation.ts +116 -69
- package/src/Scope.ts +50 -0
- package/src/Tag.md +88 -0
- package/src/Tag.ts +49 -6
- package/src/Type.test.ts +223 -18
- package/src/Type.ts +609 -131
- package/src/View.ts +14 -23
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +4 -4
- package/src/internal/Annotation/annotations.test.ts +31 -11
- package/src/internal/Annotation/annotations.ts +143 -111
- package/src/internal/Annotation/dictionary.ts +47 -0
- package/src/internal/Annotation/entity-dictionary.ts +74 -0
- package/src/internal/Annotation/index.ts +4 -2
- package/src/internal/Annotation/util.ts +17 -8
- package/src/internal/Entity/api.ts +54 -7
- package/src/internal/Entity/entity.ts +196 -47
- package/src/internal/Entity/guard.ts +26 -0
- package/src/internal/Entity/index.ts +2 -0
- package/src/internal/Entity/model.ts +38 -28
- package/src/internal/Entity/object.ts +21 -5
- package/src/internal/Entity/relation.ts +68 -34
- package/src/internal/Entity/type-kind.ts +75 -0
- package/src/internal/Entity/type-uri.ts +92 -0
- package/src/internal/Entity/util.ts +9 -9
- package/src/internal/Format/date.ts +0 -4
- package/src/internal/Format/format.test.ts +21 -0
- package/src/internal/Format/index.ts +2 -3
- package/src/internal/Format/object.ts +21 -4
- package/src/internal/Format/types.ts +1 -1
- package/src/internal/JsonSchema/annotations.ts +1 -1
- package/src/internal/JsonSchema/json-schema-type.ts +4 -4
- package/src/internal/JsonSchema/json-schema.test.ts +71 -145
- package/src/internal/JsonSchema/json-schema.ts +49 -35
- package/src/internal/Obj/atoms.ts +244 -0
- package/src/internal/Obj/clone.ts +9 -4
- package/src/internal/Obj/create-object.test.ts +12 -10
- package/src/internal/Obj/create-object.ts +68 -22
- package/src/internal/Obj/index.ts +1 -1
- package/src/internal/Obj/inspect.ts +5 -3
- package/src/internal/Obj/json-serializer.test.ts +101 -22
- package/src/internal/Obj/json-serializer.ts +89 -33
- package/src/internal/Obj/set-value.test.ts +22 -45
- package/src/internal/Obj/set-value.ts +12 -19
- package/src/internal/Obj/snapshot.ts +13 -4
- package/src/internal/Obj/typed-object.test.ts +9 -11
- package/src/internal/Obj/typed-object.ts +1 -1
- package/src/internal/Query/index.ts +5 -0
- package/src/internal/{Query.ts → Query/pretty.ts} +40 -12
- package/src/internal/Ref/atoms.ts +20 -0
- package/src/internal/Ref/ref-array.ts +3 -3
- package/src/internal/Ref/ref.test.ts +18 -27
- package/src/internal/Ref/ref.ts +137 -59
- package/src/internal/Ref/utils.ts +45 -0
- package/src/internal/Type/compose.test.ts +3 -1
- package/src/internal/Type/index.ts +1 -2
- package/src/internal/Type/manipulation.ts +0 -25
- package/src/internal/Type/type-schema.ts +60 -0
- package/src/internal/common/README.md +2 -2
- package/src/internal/common/api/meta.ts +19 -17
- package/src/internal/common/proxy/change-context.ts +1 -1
- package/src/internal/common/proxy/change.test.ts +91 -83
- package/src/internal/common/proxy/errors.ts +2 -2
- package/src/internal/common/proxy/handler.test.ts +1 -1
- package/src/internal/common/proxy/json-serializer.ts +27 -16
- package/src/internal/common/proxy/make-object.ts +44 -20
- package/src/internal/common/proxy/ownership.ts +2 -2
- package/src/internal/common/proxy/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/common/proxy/reactive.ts +11 -2
- package/src/internal/common/proxy/schema.test.ts +48 -86
- package/src/internal/common/proxy/typed-handler.test.ts +12 -11
- package/src/internal/common/proxy/typed-handler.ts +78 -16
- package/src/internal/common/proxy/typed-object.test.ts +16 -28
- package/src/internal/common/types/base.ts +4 -4
- package/src/internal/common/types/entity.ts +80 -1
- package/src/internal/common/types/index.ts +6 -1
- package/src/internal/common/types/meta.ts +62 -20
- package/src/internal/common/types/model-symbols.ts +24 -4
- package/src/internal/common/types/typename.ts +39 -3
- package/src/internal/common/types/well-known-types.ts +15 -0
- package/src/internal/index.ts +6 -4
- package/src/testing/api.test.ts +15 -9
- package/src/testing/index.ts +1 -0
- package/src/testing/registry.ts +44 -0
- package/src/testing/test-data.ts +159 -99
- package/src/testing/test-schema.ts +22 -58
- package/src/testing/util.ts +14 -11
- package/dist/lib/neutral/Extension.mjs +0 -18
- package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
- package/dist/lib/neutral/chunk-2KHZ36F5.mjs +0 -361
- package/dist/lib/neutral/chunk-2KHZ36F5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4OIBYSXE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs +0 -45
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-B4BASU6W.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BVOFLCVF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DQYLD2RB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EAMSSLZC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-G3IQMKF7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-GZQTCRJB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HBUZJNZO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-JUXPFOEI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MOR5ERFM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PHU22NLC.mjs +0 -136
- package/dist/lib/neutral/chunk-PHU22NLC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs +0 -97
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-T6W2LEZU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TBKX6JQO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TU3GW67D.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +0 -7
- package/dist/lib/neutral/chunk-V36VO5SS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WAK4DMFV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YAHXAYOW.mjs +0 -56
- package/dist/lib/neutral/chunk-YAHXAYOW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs +0 -50
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs.map +0 -7
- package/dist/types/src/Extension.d.ts +0 -80
- package/dist/types/src/Extension.d.ts.map +0 -1
- package/dist/types/src/Extension.test.d.ts +0 -2
- package/dist/types/src/Extension.test.d.ts.map +0 -1
- package/dist/types/src/SchemaRegistry.d.ts +0 -84
- package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
- package/dist/types/src/internal/Obj/ids.d.ts +0 -6
- package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
- package/dist/types/src/internal/Query.d.ts.map +0 -1
- package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
- package/src/Extension.test.ts +0 -235
- package/src/Extension.ts +0 -122
- package/src/SchemaRegistry.ts +0 -106
- package/src/internal/Obj/ids.ts +0 -12
- package/src/internal/Type/echo-schema.ts +0 -423
- package/src/internal/Type/persistent-schema.ts +0 -33
- /package/dist/lib/neutral/{Extension.mjs.map → Registry.mjs.map} +0 -0
- /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Scope.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-7RO7CPBZ.mjs.map → chunk-IGK6FN65.mjs.map} +0 -0
package/src/View.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
9
|
import { QueryAST } from '@dxos/echo-protocol';
|
|
10
|
-
import {
|
|
11
|
-
import { PublicKey } from '@dxos/keys';
|
|
10
|
+
import { SchemaEx } from '@dxos/effect';
|
|
11
|
+
import { DXN, PublicKey } from '@dxos/keys';
|
|
12
12
|
|
|
13
13
|
import * as Annotation from './Annotation';
|
|
14
14
|
import * as Filter from './Filter';
|
|
@@ -22,11 +22,11 @@ import * as Type from './Type';
|
|
|
22
22
|
*/
|
|
23
23
|
export const FieldSchema = Schema.Struct({
|
|
24
24
|
id: Schema.String,
|
|
25
|
-
path: JsonPath,
|
|
25
|
+
path: SchemaEx.JsonPath,
|
|
26
26
|
visible: Schema.optional(Schema.Boolean),
|
|
27
27
|
|
|
28
28
|
// TODO(wittjosiah): Presentation-specific?
|
|
29
|
-
referencePath: Schema.optional(JsonPath),
|
|
29
|
+
referencePath: Schema.optional(SchemaEx.JsonPath),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
export type FieldType = Schema.Schema.Type<typeof FieldSchema>;
|
|
@@ -44,7 +44,7 @@ export const Projection = Schema.Struct({
|
|
|
44
44
|
/**
|
|
45
45
|
* UX metadata associated with displayed fields (in table, form, etc.)
|
|
46
46
|
*/
|
|
47
|
-
// TODO(wittjosiah): Should this just be an array of JsonPath?
|
|
47
|
+
// TODO(wittjosiah): Should this just be an array of SchemaEx.JsonPath?
|
|
48
48
|
fields: Schema.Array(FieldSchema),
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -75,27 +75,18 @@ const ViewSchema = Schema.Struct({
|
|
|
75
75
|
*/
|
|
76
76
|
projection: Projection,
|
|
77
77
|
}).pipe(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}),
|
|
82
|
-
internal.SystemTypeAnnotation.set(true),
|
|
83
|
-
Annotation.IconAnnotation.set({
|
|
84
|
-
icon: 'ph--funnel--regular',
|
|
85
|
-
hue: 'green',
|
|
86
|
-
}),
|
|
78
|
+
internal.HiddenAnnotation.set(true),
|
|
79
|
+
Annotation.IconAnnotation.set({ icon: 'ph--funnel--regular', hue: 'green' }),
|
|
80
|
+
Type.makeObject(DXN.make('org.dxos.type.view', '0.1.0')),
|
|
87
81
|
);
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*/
|
|
94
|
-
// NOTE: This interface is explicitly defined rather than derived from the schema to avoid
|
|
95
|
-
// TypeScript "cannot be named" portability errors. The schema contains QueryAST.Query which
|
|
96
|
-
// references internal @dxos/echo-protocol module paths. Without this explicit interface,
|
|
97
|
-
// any schema using Ref.Ref(View) would inherit the non-portable type and fail to compile.
|
|
83
|
+
// NOTE: Declared as a named interface and the `View` const is annotated `Type.Obj<View>` so
|
|
84
|
+
// downstream consumers see a named `View` type instead of the inlined `QueryAST.Query` union.
|
|
85
|
+
// Without the named interface, embedding `Type.getSchema(View.View)` in a downstream
|
|
86
|
+
// `Schema.Struct` triggers TS2742 portability errors (e.g. plugin-kanban, plugin-table).
|
|
98
87
|
// TODO(wittjosiah): Find a better solution that doesn't require manually keeping the interface in sync.
|
|
88
|
+
export interface View extends Type.InstanceType<typeof ViewSchema> {}
|
|
89
|
+
|
|
99
90
|
export const View: Type.Obj<View> = ViewSchema as any;
|
|
100
91
|
|
|
101
92
|
export const make = (props: Partial<Obj.MakeProps<typeof View>>): View => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import * as Obj from './Obj';
|
|
8
|
+
import { TestSchema } from './testing';
|
|
9
|
+
import type * as Type from './Type';
|
|
10
|
+
|
|
11
|
+
describe('Exemplars', () => {
|
|
12
|
+
test('factory', ({ expect }) => {
|
|
13
|
+
const factory = <S extends Type.AnyObj>(schema: S) => {
|
|
14
|
+
return (props: Obj.MakeProps<S>) => Obj.make(schema, props);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const makePerson = factory(TestSchema.Person);
|
|
18
|
+
const person = makePerson({ name: 'John Doe' });
|
|
19
|
+
expect(person.name).toBe('John Doe');
|
|
20
|
+
});
|
|
21
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
export { QueryAST } from '@dxos/echo-protocol';
|
|
6
|
-
|
|
7
|
-
export { DXN } from '@dxos/keys';
|
|
6
|
+
export { DXN, EID, URI } from '@dxos/keys';
|
|
8
7
|
|
|
9
8
|
export * as Annotation from './Annotation';
|
|
10
9
|
export * as Database from './Database';
|
|
@@ -15,6 +14,7 @@ export * as Feed from './Feed';
|
|
|
15
14
|
export * as Filter from './Filter';
|
|
16
15
|
export * as Format from './Format';
|
|
17
16
|
export * as Hypergraph from './Hypergraph';
|
|
17
|
+
export * as Json from './Json';
|
|
18
18
|
export * as JsonSchema from './JsonSchema';
|
|
19
19
|
export * as Key from './Key';
|
|
20
20
|
export * as Migration from './Migration';
|
|
@@ -23,11 +23,11 @@ export * as Order from './Order';
|
|
|
23
23
|
export * as Query from './Query';
|
|
24
24
|
export * as QueryResult from './QueryResult';
|
|
25
25
|
export * as Ref from './Ref';
|
|
26
|
+
export * as Registry from './Registry';
|
|
26
27
|
export * as Relation from './Relation';
|
|
27
|
-
export * as
|
|
28
|
+
export * as Scope from './Scope';
|
|
28
29
|
export * as Tag from './Tag';
|
|
29
30
|
export * as Type from './Type';
|
|
30
31
|
export * as Collection from './Collection';
|
|
31
32
|
export * as View from './View';
|
|
32
33
|
export * as Dataset from './Dataset';
|
|
33
|
-
export * as Extension from './Extension';
|
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { describe, test } from 'vitest';
|
|
7
7
|
|
|
8
|
+
import { DXN } from '@dxos/keys';
|
|
9
|
+
|
|
10
|
+
import { createEchoSchema } from '../../testing';
|
|
11
|
+
import * as Type from '../../Type';
|
|
12
|
+
import { EntityKind } from '../common/types';
|
|
8
13
|
import { EchoObjectSchema } from '../Entity';
|
|
9
|
-
import { LabelAnnotation, TypenameSchema, VersionSchema, getLabelWithSchema } from './annotations';
|
|
14
|
+
import { LabelAnnotation, TypenameSchema, VersionSchema, getLabelWithSchema, getTypeAnnotation } from './annotations';
|
|
10
15
|
|
|
11
16
|
// TODO(dmaretskyi): Use one of the testing schemas.
|
|
12
17
|
const TestObject = Schema.Struct({
|
|
@@ -17,14 +22,9 @@ const TestObject = Schema.Struct({
|
|
|
17
22
|
|
|
18
23
|
type TestObject = Schema.Schema.Type<typeof TestObject>;
|
|
19
24
|
|
|
20
|
-
const TestEchoSchema = TestObject.pipe(
|
|
21
|
-
EchoObjectSchema({
|
|
22
|
-
typename: 'org.dxos.type.test',
|
|
23
|
-
version: '0.1.0',
|
|
24
|
-
}),
|
|
25
|
-
);
|
|
25
|
+
const TestEchoSchema = TestObject.pipe(EchoObjectSchema(DXN.make('org.dxos.type.test', '0.1.0')));
|
|
26
26
|
|
|
27
|
-
type TestEchoSchema =
|
|
27
|
+
type TestEchoSchema = Type.InstanceType<typeof TestEchoSchema>;
|
|
28
28
|
|
|
29
29
|
describe('annotations', () => {
|
|
30
30
|
describe('Typename', () => {
|
|
@@ -132,14 +132,34 @@ describe('annotations', () => {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
test('should return label from echo object', ({ expect }) => {
|
|
135
|
-
const obj
|
|
135
|
+
const obj = {
|
|
136
136
|
id: 'test',
|
|
137
137
|
name: 'Primary Name',
|
|
138
138
|
fallbackName: 'Fallback Name',
|
|
139
139
|
other: 'Other',
|
|
140
|
-
};
|
|
140
|
+
} as unknown as TestEchoSchema;
|
|
141
|
+
|
|
142
|
+
expect(getLabelWithSchema(Type.getSchema(TestEchoSchema), obj)).toEqual('Primary Name');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// `getTypeAnnotation` reads annotations from an Effect Schema. To read off a
|
|
147
|
+
// `Type.Type` entity (static or persisted), unwrap with `Type.getSchema(entity)`
|
|
148
|
+
// first — that handles both the static `StaticTypeSchemaSlot` case and the
|
|
149
|
+
// persisted `jsonSchema` rebuild case.
|
|
150
|
+
describe('getTypeAnnotation via Type.getSchema(entity)', () => {
|
|
151
|
+
test('returns TypeAnnotation for a static Type.Obj entity', ({ expect }) => {
|
|
152
|
+
const annotation = getTypeAnnotation(Type.getSchema(TestEchoSchema));
|
|
153
|
+
expect(annotation).toBeDefined();
|
|
154
|
+
expect(annotation?.kind).toBe(EntityKind.Object);
|
|
155
|
+
expect(annotation?.typename).toBe('org.dxos.type.test');
|
|
156
|
+
});
|
|
141
157
|
|
|
142
|
-
|
|
158
|
+
test('returns TypeAnnotation for a persisted Type.Type entity', ({ expect }) => {
|
|
159
|
+
const persisted = createEchoSchema(Type.getSchema(TestEchoSchema));
|
|
160
|
+
const annotation = getTypeAnnotation(Type.getSchema(persisted));
|
|
161
|
+
expect(annotation).toBeDefined();
|
|
162
|
+
expect(annotation?.typename).toBe('org.dxos.type.test');
|
|
143
163
|
});
|
|
144
164
|
});
|
|
145
165
|
});
|
|
@@ -7,15 +7,17 @@ import * as Option from 'effect/Option';
|
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import { type JsonPath, getField } from '@dxos/effect';
|
|
10
|
+
import { SchemaEx } from '@dxos/effect';
|
|
12
11
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
13
|
-
import { DXN } from '@dxos/keys';
|
|
12
|
+
import { DXN, URI } from '@dxos/keys';
|
|
14
13
|
import { type Primitive } from '@dxos/util';
|
|
15
14
|
|
|
15
|
+
import type * as Annotation from '../../Annotation';
|
|
16
16
|
import { type Mutable } from '../common/proxy';
|
|
17
17
|
import { type AnyProperties, EntityKind, TypeId, getSchema } from '../common/types';
|
|
18
|
-
import {
|
|
18
|
+
import { createAnnotationHelper } from './util';
|
|
19
|
+
|
|
20
|
+
const ANNOTATION_TYPE_ID: Annotation.TypeId = '~@dxos/echo/Annotation' as const;
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* @internal
|
|
@@ -35,7 +37,7 @@ export const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, p
|
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* ECHO identifier (for a stored schema).
|
|
38
|
-
* Must be
|
|
40
|
+
* Must be an `echo:` URI.
|
|
39
41
|
*/
|
|
40
42
|
export const TypeIdentifierAnnotationId = Symbol.for('@dxos/schema/annotation/TypeIdentifier');
|
|
41
43
|
|
|
@@ -46,39 +48,27 @@ export const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>
|
|
|
46
48
|
)(schema.ast);
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
|
-
* @returns
|
|
51
|
+
* @returns The schema's type identifier URI — whichever URI fits.
|
|
52
|
+
*
|
|
53
|
+
* - Stored (dynamic) schemas: the schema-as-object's EID, so loaded objects ride
|
|
54
|
+
* along with their schema as a strong dependency.
|
|
55
|
+
* - Non-stored (static) schemas: the typename DXN built from `TypeAnnotation`.
|
|
50
56
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
57
|
+
* This URI is what gets written to an object's `system.type`; queries that filter by
|
|
58
|
+
* type also use it (see `Filter.type` / `getTypeURIFromSpecifier`), so both sides
|
|
59
|
+
* stay symmetric without per-schema branching.
|
|
53
60
|
*/
|
|
54
|
-
export const
|
|
61
|
+
export const getSchemaURI = (schema: Schema.Schema.All): URI.URI | undefined => {
|
|
55
62
|
assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');
|
|
56
63
|
const id = getTypeIdentifierAnnotation(schema);
|
|
57
64
|
if (id) {
|
|
58
|
-
return
|
|
65
|
+
return URI.make(id);
|
|
59
66
|
}
|
|
60
|
-
|
|
61
|
-
// TODO(dmaretskyi): Add support for dynamic schema.
|
|
62
67
|
const objectAnnotation = getTypeAnnotation(schema);
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param input schema or a typename string.
|
|
72
|
-
* @return type DXN.
|
|
73
|
-
*/
|
|
74
|
-
export const getTypeDXNFromSpecifier = (input: Schema.Schema.All | string): DXN => {
|
|
75
|
-
if (Schema.isSchema(input)) {
|
|
76
|
-
return getSchemaDXN(input) ?? raise(new TypeError('Schema has no DXN'));
|
|
77
|
-
} else {
|
|
78
|
-
assertArgument(typeof input === 'string', 'input');
|
|
79
|
-
assertArgument(!input.startsWith('dxn:'), 'input');
|
|
80
|
-
return DXN.fromTypename(input);
|
|
68
|
+
if (objectAnnotation) {
|
|
69
|
+
return DXN.make(objectAnnotation.typename, objectAnnotation.version);
|
|
81
70
|
}
|
|
71
|
+
return undefined;
|
|
82
72
|
};
|
|
83
73
|
|
|
84
74
|
//
|
|
@@ -186,8 +176,15 @@ export const getTypename = (obj: AnyProperties): string | undefined => {
|
|
|
186
176
|
// Try to extract typename from DXN.
|
|
187
177
|
return getSchemaTypename(schema);
|
|
188
178
|
} else {
|
|
189
|
-
|
|
190
|
-
return
|
|
179
|
+
// `obj` may be an arbitrary value (e.g. from `isInstanceOf`); read TypeId
|
|
180
|
+
// directly so we return undefined for non-entities instead of throwing.
|
|
181
|
+
const type = (obj as any)?.[TypeId];
|
|
182
|
+
// Parse the URI string to extract typename.
|
|
183
|
+
if (DXN.isDXN(type)) {
|
|
184
|
+
const parsed = DXN.tryMake(type);
|
|
185
|
+
return parsed && DXN.getName(parsed);
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
191
188
|
}
|
|
192
189
|
};
|
|
193
190
|
|
|
@@ -195,8 +192,8 @@ export const getTypename = (obj: AnyProperties): string | undefined => {
|
|
|
195
192
|
* @internal (use Type.setTypename)
|
|
196
193
|
*/
|
|
197
194
|
// TODO(dmaretskyi): Rename setTypeDXN.
|
|
198
|
-
export const setTypename = (obj: any, typename:
|
|
199
|
-
|
|
195
|
+
export const setTypename = (obj: any, typename: URI.URI): void => {
|
|
196
|
+
assertArgument(typeof typename === 'string', 'typename', 'Invalid type.');
|
|
200
197
|
Object.defineProperty(obj, TypeId, {
|
|
201
198
|
value: typename,
|
|
202
199
|
writable: false,
|
|
@@ -206,68 +203,25 @@ export const setTypename = (obj: any, typename: DXN): void => {
|
|
|
206
203
|
};
|
|
207
204
|
|
|
208
205
|
/**
|
|
209
|
-
* @returns Object type
|
|
210
|
-
* @returns undefined if the object
|
|
206
|
+
* @returns Object type URI — either a typename {@link DXN} or an `echo:` reference to a stored Schema object.
|
|
207
|
+
* @returns undefined if the object has no registered type URI (e.g. unresolved query result).
|
|
211
208
|
* @example `dxn:com.example.type.person:1.0.0`
|
|
209
|
+
* @example `echo:/01KKKG2FHWCMTR0BY00GJSVT1X` (stored schema)
|
|
212
210
|
*
|
|
213
|
-
* @internal (use Obj.
|
|
211
|
+
* @internal (use Obj.getTypeURI)
|
|
214
212
|
*/
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (!obj) {
|
|
213
|
+
export const getTypeURI = (obj: AnyProperties): URI.URI | undefined => {
|
|
214
|
+
if (obj == null) {
|
|
218
215
|
return undefined;
|
|
219
216
|
}
|
|
220
|
-
|
|
221
217
|
const type = (obj as any)[TypeId];
|
|
222
|
-
if (
|
|
218
|
+
if (type == null) {
|
|
223
219
|
return undefined;
|
|
224
220
|
}
|
|
225
|
-
|
|
226
|
-
invariant(type instanceof DXN, 'Invalid object.');
|
|
221
|
+
invariant(URI.isURI(type), 'Invalid object.');
|
|
227
222
|
return type;
|
|
228
223
|
};
|
|
229
224
|
|
|
230
|
-
/**
|
|
231
|
-
* Checks if the object is an instance of the schema.
|
|
232
|
-
* Only typename is compared, the schema version is ignored.
|
|
233
|
-
*
|
|
234
|
-
* The following cases are considered to mean that the object is an instance of the schema:
|
|
235
|
-
* - Object was created with this exact schema.
|
|
236
|
-
* - Object was created with a different version of this schema.
|
|
237
|
-
* - Object was created with a different schema (maybe dynamic) that has the same typename.
|
|
238
|
-
*/
|
|
239
|
-
// TODO(burdon): Can we use `Schema.is`?
|
|
240
|
-
export const isInstanceOf = <Schema extends Schema.Schema.AnyNoContext>(
|
|
241
|
-
schema: Schema,
|
|
242
|
-
object: any,
|
|
243
|
-
): object is Schema.Schema.Type<Schema> => {
|
|
244
|
-
if (object == null) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const schemaDXN = getSchemaDXN(schema);
|
|
249
|
-
if (!schemaDXN) {
|
|
250
|
-
throw new Error('Schema must have an object annotation.');
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const type = getTypeDXN(object);
|
|
254
|
-
if (type && DXN.equals(type, schemaDXN)) {
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const typename = getTypename(object);
|
|
259
|
-
if (!typename) {
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const typeDXN = schemaDXN.asTypeDXN();
|
|
264
|
-
if (!typeDXN) {
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return typeDXN.type === typename;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
225
|
//
|
|
272
226
|
// PropertyMeta
|
|
273
227
|
//
|
|
@@ -286,6 +240,12 @@ export type PropertyMetaAnnotation = {
|
|
|
286
240
|
|
|
287
241
|
// TODO(wittjosiah): Align with other annotations.
|
|
288
242
|
// TODO(wittjosiah): Why is this separate from FormatAnnotation?
|
|
243
|
+
/**
|
|
244
|
+
* Apply property-level metadata to an Effect schema. Only accepts
|
|
245
|
+
* `Schema.Schema.Any` — apply BEFORE wrapping the schema with
|
|
246
|
+
* `Type.makeObject` / `Type.makeRelation`. To read property meta off a
|
|
247
|
+
* `Type.Type` entity, unwrap it first with `Type.getSchema(entity)`.
|
|
248
|
+
*/
|
|
289
249
|
export const PropertyMeta = (name: string, value: PropertyMetaValue) => {
|
|
290
250
|
return <A, I, R>(self: Schema.Schema<A, I, R>): Schema.Schema<A, I, R> => {
|
|
291
251
|
const existingMeta = self.ast.annotations[PropertyMetaAnnotationId] as PropertyMetaAnnotation;
|
|
@@ -323,10 +283,10 @@ export const SchemaMetaSymbol = Symbol.for('@dxos/schema/SchemaMeta');
|
|
|
323
283
|
export type SchemaMeta = TypeMeta & { id: string };
|
|
324
284
|
|
|
325
285
|
/**
|
|
326
|
-
* Identifies a schema as
|
|
286
|
+
* Identifies a schema as hidden from user-facing surfaces (like dotfiles — visible only via an advanced setting).
|
|
327
287
|
*/
|
|
328
|
-
export const
|
|
329
|
-
export const
|
|
288
|
+
export const HiddenAnnotationId = Symbol.for('@dxos/schema/annotation/Hidden');
|
|
289
|
+
export const HiddenAnnotation = createAnnotationHelper<boolean>(HiddenAnnotationId);
|
|
330
290
|
|
|
331
291
|
/**
|
|
332
292
|
* Identifies label property or JSON path expression.
|
|
@@ -340,7 +300,7 @@ export const LabelAnnotation = createAnnotationHelper<string[]>(LabelAnnotationI
|
|
|
340
300
|
* Lower-level version that requires explicit schema parameter.
|
|
341
301
|
* Skips empty strings and whitespace-only strings, continuing to the next field.
|
|
342
302
|
*/
|
|
343
|
-
// TODO(burdon): Convert to JsonPath?
|
|
303
|
+
// TODO(burdon): Convert to SchemaEx.JsonPath?
|
|
344
304
|
export const getLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
345
305
|
schema: S,
|
|
346
306
|
object: Schema.Schema.Type<S>,
|
|
@@ -352,7 +312,7 @@ export const getLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
|
352
312
|
'accessor',
|
|
353
313
|
'Label annotation must be a string or an array of strings',
|
|
354
314
|
);
|
|
355
|
-
const value = getField(object, accessor as JsonPath);
|
|
315
|
+
const value = SchemaEx.getField(object, accessor as SchemaEx.JsonPath);
|
|
356
316
|
switch (typeof value) {
|
|
357
317
|
case 'string': {
|
|
358
318
|
const trimmed = value.trim();
|
|
@@ -403,14 +363,14 @@ export const DescriptionAnnotation = createAnnotationHelper<string>(DescriptionA
|
|
|
403
363
|
* Returns the description for a given object based on {@link DescriptionAnnotationId}.
|
|
404
364
|
* Lower-level version that requires explicit schema parameter.
|
|
405
365
|
*/
|
|
406
|
-
// TODO(burdon): Convert to JsonPath?
|
|
366
|
+
// TODO(burdon): Convert to SchemaEx.JsonPath?
|
|
407
367
|
export const getDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
408
368
|
schema: S,
|
|
409
369
|
object: Schema.Schema.Type<S>,
|
|
410
370
|
): string | undefined => {
|
|
411
371
|
const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));
|
|
412
372
|
assertArgument(typeof accessor === 'string', 'accessor', 'Description annotation must be a string');
|
|
413
|
-
const value = getField(object, accessor as JsonPath);
|
|
373
|
+
const value = SchemaEx.getField(object, accessor as SchemaEx.JsonPath);
|
|
414
374
|
switch (typeof value) {
|
|
415
375
|
case 'string':
|
|
416
376
|
case 'number':
|
|
@@ -446,6 +406,13 @@ export const setDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
|
446
406
|
export const FormInputAnnotationId = Symbol.for('@dxos/schema/annotation/FormInput');
|
|
447
407
|
export const FormInputAnnotation = createAnnotationHelper<boolean>(FormInputAnnotationId);
|
|
448
408
|
|
|
409
|
+
/**
|
|
410
|
+
* When set on a `Ref` property, the form renders the referenced object's own
|
|
411
|
+
* fields inline (a nested form bound to the target) instead of a picker.
|
|
412
|
+
*/
|
|
413
|
+
export const FormInlineAnnotationId = Symbol.for('@dxos/schema/annotation/FormInline');
|
|
414
|
+
export const FormInlineAnnotation = createAnnotationHelper<boolean>(FormInlineAnnotationId);
|
|
415
|
+
|
|
449
416
|
/**
|
|
450
417
|
* Default field to be used on referenced schema to lookup the value.
|
|
451
418
|
*/
|
|
@@ -471,26 +438,29 @@ interface MakeAnnoationsProps<T> {
|
|
|
471
438
|
schema: Schema.Schema<T, any, never>;
|
|
472
439
|
}
|
|
473
440
|
|
|
474
|
-
//
|
|
475
|
-
|
|
441
|
+
// Annotation ids use the same NSID / reverse-DNS format as TypenameSchema —
|
|
442
|
+
// dot-separated segments, middle segments may be hyphenated, final segment may be camelCase.
|
|
443
|
+
// At least 3 segments are required (e.g. org.dxos.annotation.example).
|
|
444
|
+
export const makeUserAnnotation = <T>(props: MakeAnnoationsProps<T>): Annotation.Annotation<T> => {
|
|
476
445
|
assertArgument(
|
|
477
|
-
/^[a-
|
|
446
|
+
/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?){2,}(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)?$/.test(
|
|
447
|
+
props.id,
|
|
448
|
+
),
|
|
478
449
|
'id',
|
|
479
|
-
'Annotation id must be in the FQN format (org.dxos.annotation.example).',
|
|
450
|
+
'Annotation id must be in the FQN format (org.dxos.annotation.example or org.dxos.space.rootCollection).',
|
|
480
451
|
);
|
|
481
452
|
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
)
|
|
487
|
-
|
|
488
|
-
return {
|
|
489
|
-
get: (schema) => getFromAst(schema.ast),
|
|
490
|
-
getFromAst: (ast) => getFromAst(ast),
|
|
453
|
+
const annotation: Annotation.Annotation<T> = {
|
|
454
|
+
[ANNOTATION_TYPE_ID]: { _Type: {} as T },
|
|
455
|
+
key: props.id as Annotation.Key,
|
|
456
|
+
schema: props.schema,
|
|
457
|
+
get: (schema) => getFromAst(schema.ast, annotation),
|
|
458
|
+
getFromAst: (ast) => getFromAst(ast, annotation),
|
|
491
459
|
set: (value) =>
|
|
492
460
|
PropertyMeta(props.id, Schema.encodeSync(props.schema)(value)) as <S extends Schema.Schema.Any>(schema: S) => S,
|
|
493
461
|
};
|
|
462
|
+
|
|
463
|
+
return annotation;
|
|
494
464
|
};
|
|
495
465
|
|
|
496
466
|
const IconAnnotationSchema = Schema.Struct({
|
|
@@ -518,7 +488,6 @@ const IconAnnotationSchema = Schema.Struct({
|
|
|
518
488
|
* - 'pink'
|
|
519
489
|
* - 'rose'
|
|
520
490
|
*/
|
|
521
|
-
|
|
522
491
|
hue: Schema.optional(Schema.String),
|
|
523
492
|
});
|
|
524
493
|
|
|
@@ -532,20 +501,54 @@ export const IconAnnotation = makeUserAnnotation<IconAnnotation>({
|
|
|
532
501
|
schema: IconAnnotationSchema,
|
|
533
502
|
});
|
|
534
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Indicates that this entity's icon should be resolved from a property whose value is a `Ref`
|
|
506
|
+
* to another entity. Consumers (e.g. graph node builders) resolve the ref target and use that
|
|
507
|
+
* target's schema `IconAnnotation` in place of the static one declared on this schema.
|
|
508
|
+
*
|
|
509
|
+
* Useful for wrapper schemas that delegate their visual identity to a referenced sub-entity
|
|
510
|
+
* (e.g. a generic `Game` whose icon should come from its `variant` ref's typed state).
|
|
511
|
+
*/
|
|
512
|
+
export const IconFromRefAnnotation = makeUserAnnotation<string>({
|
|
513
|
+
id: 'org.dxos.annotation.icon.from-ref',
|
|
514
|
+
schema: Schema.String,
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Options for {@link getLabel}.
|
|
519
|
+
*/
|
|
520
|
+
export type GetLabelOptions = {
|
|
521
|
+
/**
|
|
522
|
+
* Strategy for deriving a label when the entity has no `LabelAnnotation` value.
|
|
523
|
+
* - `'typename'`: use the entity's typename (e.g. `org.dxos.type.table`).
|
|
524
|
+
* Useful for Card.Title chrome that must always display something, even
|
|
525
|
+
* for unlabeled objects.
|
|
526
|
+
*/
|
|
527
|
+
fallback?: 'typename';
|
|
528
|
+
};
|
|
529
|
+
|
|
535
530
|
/**
|
|
536
531
|
* Get the label of an entity.
|
|
537
532
|
* Accepts both reactive entities and snapshots.
|
|
533
|
+
*
|
|
534
|
+
* If `options.fallback === 'typename'` and no label is set, returns the
|
|
535
|
+
* entity's typename instead.
|
|
538
536
|
*/
|
|
539
|
-
export const getLabel = (entity: AnyProperties): string | undefined => {
|
|
537
|
+
export const getLabel = (entity: AnyProperties, options?: GetLabelOptions): string | undefined => {
|
|
540
538
|
const schema = getSchema(entity);
|
|
541
|
-
|
|
542
|
-
|
|
539
|
+
const label = schema != null ? getLabelWithSchema(schema, entity) : undefined;
|
|
540
|
+
if (label != null) {
|
|
541
|
+
return label;
|
|
542
|
+
}
|
|
543
|
+
if (options?.fallback === 'typename') {
|
|
544
|
+
return getTypename(entity);
|
|
543
545
|
}
|
|
546
|
+
return undefined;
|
|
544
547
|
};
|
|
545
548
|
|
|
546
549
|
/**
|
|
547
550
|
* Set the label of an entity.
|
|
548
|
-
* Must be called within an Obj.
|
|
551
|
+
* Must be called within an Obj.update or Relation.update callback.
|
|
549
552
|
*/
|
|
550
553
|
export const setLabel = (entity: Mutable<AnyProperties>, label: string) => {
|
|
551
554
|
const schema = getSchema(entity);
|
|
@@ -565,9 +568,29 @@ export const getDescription = (entity: AnyProperties): string | undefined => {
|
|
|
565
568
|
}
|
|
566
569
|
};
|
|
567
570
|
|
|
571
|
+
/**
|
|
572
|
+
* Get the icon annotation for an entity, resolved via its type-level `IconAnnotation`.
|
|
573
|
+
* Accepts both reactive entities and snapshots.
|
|
574
|
+
*
|
|
575
|
+
* Returns the full `{ icon, hue }` annotation so callers can use both the phosphor icon
|
|
576
|
+
* name and the suggested colour. Callers wanting just the icon name typically write
|
|
577
|
+
* `Obj.getIcon(obj)?.icon ?? 'ph--cube--regular'`.
|
|
578
|
+
*
|
|
579
|
+
* Note: this is the "static" icon from the object's own schema. It does not follow
|
|
580
|
+
* `IconFromRefAnnotation` delegation — call sites needing that (e.g. app-graph node
|
|
581
|
+
* builders) should resolve the ref themselves.
|
|
582
|
+
*/
|
|
583
|
+
export const getIcon = (entity: AnyProperties): IconAnnotation | undefined => {
|
|
584
|
+
const schema = getSchema(entity);
|
|
585
|
+
if (schema == null) {
|
|
586
|
+
return undefined;
|
|
587
|
+
}
|
|
588
|
+
return Option.getOrUndefined(IconAnnotation.get(schema));
|
|
589
|
+
};
|
|
590
|
+
|
|
568
591
|
/**
|
|
569
592
|
* Set the description of an entity.
|
|
570
|
-
* Must be called within an Obj.
|
|
593
|
+
* Must be called within an Obj.update or Relation.update callback.
|
|
571
594
|
*/
|
|
572
595
|
export const setDescription = (entity: Mutable<AnyProperties>, description: string) => {
|
|
573
596
|
const schema = getSchema(entity);
|
|
@@ -575,3 +598,12 @@ export const setDescription = (entity: Mutable<AnyProperties>, description: stri
|
|
|
575
598
|
setDescriptionWithSchema(schema, entity, description);
|
|
576
599
|
}
|
|
577
600
|
};
|
|
601
|
+
|
|
602
|
+
export { Dictionary, Key, getDictionary, setDictionary } from './dictionary';
|
|
603
|
+
|
|
604
|
+
export const getFromAst = <T>(ast: SchemaAST.AST, annotation: Annotation.Annotation<T>): Option.Option<T> => {
|
|
605
|
+
return SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(ast).pipe(
|
|
606
|
+
Option.flatMap((meta) => Option.fromNullable(meta[annotation.key])),
|
|
607
|
+
Option.map(Schema.decodeUnknownSync(annotation.schema)),
|
|
608
|
+
);
|
|
609
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Function from 'effect/Function';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
import * as Types from 'effect/Types';
|
|
9
|
+
|
|
10
|
+
import type * as Annotation from '../../Annotation';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier for an annotation.
|
|
14
|
+
*/
|
|
15
|
+
export const Key = Schema.String.pipe(Schema.brand('~@dxos/echo/AnnotationKey'));
|
|
16
|
+
export type Key = Schema.Schema.Type<typeof Key>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set of annotation values stored on entity meta or nested in schemas.
|
|
20
|
+
*/
|
|
21
|
+
export const Dictionary = Schema.Record({ key: Key, value: Schema.Unknown });
|
|
22
|
+
export interface Dictionary extends Schema.Schema.Type<typeof Dictionary> {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the value of an annotation from a dictionary.
|
|
26
|
+
*/
|
|
27
|
+
export const getDictionary = <T>(
|
|
28
|
+
values: Annotation.Dictionary,
|
|
29
|
+
annotation: Annotation.Annotation<T>,
|
|
30
|
+
): Option.Option<T> => {
|
|
31
|
+
if (!(annotation.key in values)) {
|
|
32
|
+
return Option.none();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return Function.pipe(values[annotation.key], Schema.decodeUnknownSync(annotation.schema), Option.some);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Set the value of an annotation in a dictionary.
|
|
40
|
+
*/
|
|
41
|
+
export const setDictionary = <T>(
|
|
42
|
+
values: Types.Mutable<Annotation.Dictionary>,
|
|
43
|
+
annotation: Annotation.Annotation<T>,
|
|
44
|
+
value: T,
|
|
45
|
+
): void => {
|
|
46
|
+
values[annotation.key] = Schema.encodeSync(annotation.schema)(value);
|
|
47
|
+
};
|