@dxos/echo 0.8.4-staging.ac66bdf99f → 0.9.1-main.c7dcc2e112
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 +45 -6
- package/dist/lib/neutral/Database.mjs +10 -17
- package/dist/lib/neutral/Entity.mjs +35 -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 +33 -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-4OIBYSXE.mjs → chunk-3JXQUMUI.mjs} +78 -32
- package/dist/lib/neutral/chunk-3JXQUMUI.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-G3IQMKF7.mjs → chunk-4TPQZPLY.mjs} +130 -119
- package/dist/lib/neutral/chunk-4TPQZPLY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TU3GW67D.mjs → chunk-5GAIWRQB.mjs} +40 -40
- package/dist/lib/neutral/chunk-5GAIWRQB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B4BASU6W.mjs → chunk-6CEISA3V.mjs} +93 -76
- package/dist/lib/neutral/chunk-6CEISA3V.mjs.map +7 -0
- 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-ANHVGJI4.mjs → chunk-7LOUAPYZ.mjs} +9 -5
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WAK4DMFV.mjs → chunk-A53NTBHE.mjs} +12 -7
- package/dist/lib/neutral/chunk-A53NTBHE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-EAMSSLZC.mjs → chunk-AFANXSGV.mjs} +83 -46
- package/dist/lib/neutral/chunk-AFANXSGV.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-E7IOTOZD.mjs +108 -0
- package/dist/lib/neutral/chunk-E7IOTOZD.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-HGWQR5KH.mjs +259 -0
- package/dist/lib/neutral/chunk-HGWQR5KH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JZ6LFQU5.mjs +109 -0
- package/dist/lib/neutral/chunk-JZ6LFQU5.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-JUXPFOEI.mjs → chunk-K3S7D5PR.mjs} +48 -88
- package/dist/lib/neutral/chunk-K3S7D5PR.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OS35K56T.mjs → chunk-L3OBWBV2.mjs} +3 -3
- package/dist/lib/neutral/{chunk-OS35K56T.mjs.map → chunk-L3OBWBV2.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-V36VO5SS.mjs → chunk-NOL7O3BL.mjs} +32 -40
- package/dist/lib/neutral/chunk-NOL7O3BL.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-7RO7CPBZ.mjs → chunk-PLDMJJJC.mjs} +2 -2
- package/dist/lib/neutral/{chunk-HBUZJNZO.mjs → chunk-SZ5WB6HF.mjs} +94 -99
- package/dist/lib/neutral/chunk-SZ5WB6HF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BVOFLCVF.mjs → chunk-TF5BSLF6.mjs} +9 -6
- package/dist/lib/neutral/chunk-TF5BSLF6.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-MOR5ERFM.mjs → chunk-VQYL2OQF.mjs} +771 -1252
- package/dist/lib/neutral/chunk-VQYL2OQF.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-WU3GIANS.mjs +31 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WZ32BF53.mjs +702 -0
- package/dist/lib/neutral/chunk-WZ32BF53.mjs.map +7 -0
- package/dist/lib/neutral/chunk-X3NUUON4.mjs +184 -0
- package/dist/lib/neutral/chunk-X3NUUON4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Z3WMRRAZ.mjs +168 -0
- package/dist/lib/neutral/chunk-Z3WMRRAZ.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +47 -41
- package/dist/lib/neutral/internal/index.mjs +157 -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 +78 -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 +103 -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 +69 -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 +106 -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 +366 -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 +120 -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 +43 -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/index.d.ts +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
- package/dist/types/src/internal/Ref/ref.d.ts +114 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/strong-deps.d.ts +35 -0
- package/dist/types/src/internal/Ref/strong-deps.d.ts.map +1 -0
- 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 +163 -4
- package/src/Collection.ts +5 -9
- package/src/Database.ts +126 -101
- package/src/Dataset.ts +10 -2
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +136 -32
- package/src/Err.ts +4 -4
- package/src/Feed.ts +95 -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 +170 -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 +50 -6
- package/src/Type.test.ts +223 -18
- package/src/Type.ts +623 -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 +199 -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 +275 -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 +92 -36
- 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/index.ts +1 -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 +224 -69
- package/src/internal/Ref/strong-deps.ts +107 -0
- 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 +0 -125
- 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-PLDMJJJC.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,54 @@ 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
|
+
|
|
416
|
+
/**
|
|
417
|
+
* When set on an array property, the form renders it as an ordered,
|
|
418
|
+
* drag-to-reorder list (drag handles per row). Element order is meaningful and
|
|
419
|
+
* user-controllable; reordering rewrites the array.
|
|
420
|
+
*/
|
|
421
|
+
export const FormOrderedAnnotationId = Symbol.for('@dxos/schema/annotation/FormOrdered');
|
|
422
|
+
export const FormOrderedAnnotation = createAnnotationHelper<boolean>(FormOrderedAnnotationId);
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Annotation carrying one or more named layout DSL templates that control how a
|
|
426
|
+
* form arranges a schema's fields (consumed by `@dxos/react-ui-form`'s
|
|
427
|
+
* `Form.Layout` / `Form.FieldSet`). Callers select a variant by name; the
|
|
428
|
+
* implicit name is `DEFAULT_LAYOUT_NAME` (`'default'`).
|
|
429
|
+
*
|
|
430
|
+
* Templates use a minimal XML grammar. Example:
|
|
431
|
+
*
|
|
432
|
+
* FormLayoutAnnotation.set({
|
|
433
|
+
* default: `
|
|
434
|
+
* <grid cols="2">
|
|
435
|
+
* <field name="origin"/>
|
|
436
|
+
* <field name="destination"/>
|
|
437
|
+
* <field name="provider" span="2"/>
|
|
438
|
+
* </grid>
|
|
439
|
+
* `,
|
|
440
|
+
* card: `
|
|
441
|
+
* <grid cols="1">
|
|
442
|
+
* <field name="provider"/>
|
|
443
|
+
* <field name="number"/>
|
|
444
|
+
* </grid>
|
|
445
|
+
* `,
|
|
446
|
+
* })
|
|
447
|
+
*/
|
|
448
|
+
export const FormLayoutAnnotationId = Symbol.for('@dxos/react-ui-form/annotation/Layout');
|
|
449
|
+
|
|
450
|
+
export type FormLayoutMap = Record<string, string>;
|
|
451
|
+
|
|
452
|
+
export const FormLayoutAnnotation = createAnnotationHelper<FormLayoutMap>(FormLayoutAnnotationId);
|
|
453
|
+
|
|
454
|
+
/** Name used when no explicit form-layout variant is requested. */
|
|
455
|
+
export const DEFAULT_LAYOUT_NAME = 'default';
|
|
456
|
+
|
|
449
457
|
/**
|
|
450
458
|
* Default field to be used on referenced schema to lookup the value.
|
|
451
459
|
*/
|
|
@@ -471,26 +479,29 @@ interface MakeAnnoationsProps<T> {
|
|
|
471
479
|
schema: Schema.Schema<T, any, never>;
|
|
472
480
|
}
|
|
473
481
|
|
|
474
|
-
//
|
|
475
|
-
|
|
482
|
+
// Annotation ids use the same NSID / reverse-DNS format as TypenameSchema —
|
|
483
|
+
// dot-separated segments, middle segments may be hyphenated, final segment may be camelCase.
|
|
484
|
+
// At least 3 segments are required (e.g. org.dxos.annotation.example).
|
|
485
|
+
export const makeUserAnnotation = <T>(props: MakeAnnoationsProps<T>): Annotation.Annotation<T> => {
|
|
476
486
|
assertArgument(
|
|
477
|
-
/^[a-
|
|
487
|
+
/^[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(
|
|
488
|
+
props.id,
|
|
489
|
+
),
|
|
478
490
|
'id',
|
|
479
|
-
'Annotation id must be in the FQN format (org.dxos.annotation.example).',
|
|
491
|
+
'Annotation id must be in the FQN format (org.dxos.annotation.example or org.dxos.space.rootCollection).',
|
|
480
492
|
);
|
|
481
493
|
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
)
|
|
487
|
-
|
|
488
|
-
return {
|
|
489
|
-
get: (schema) => getFromAst(schema.ast),
|
|
490
|
-
getFromAst: (ast) => getFromAst(ast),
|
|
494
|
+
const annotation: Annotation.Annotation<T> = {
|
|
495
|
+
[ANNOTATION_TYPE_ID]: { _Type: {} as T },
|
|
496
|
+
key: props.id as Annotation.Key,
|
|
497
|
+
schema: props.schema,
|
|
498
|
+
get: (schema) => getFromAst(schema.ast, annotation),
|
|
499
|
+
getFromAst: (ast) => getFromAst(ast, annotation),
|
|
491
500
|
set: (value) =>
|
|
492
501
|
PropertyMeta(props.id, Schema.encodeSync(props.schema)(value)) as <S extends Schema.Schema.Any>(schema: S) => S,
|
|
493
502
|
};
|
|
503
|
+
|
|
504
|
+
return annotation;
|
|
494
505
|
};
|
|
495
506
|
|
|
496
507
|
const IconAnnotationSchema = Schema.Struct({
|
|
@@ -518,7 +529,6 @@ const IconAnnotationSchema = Schema.Struct({
|
|
|
518
529
|
* - 'pink'
|
|
519
530
|
* - 'rose'
|
|
520
531
|
*/
|
|
521
|
-
|
|
522
532
|
hue: Schema.optional(Schema.String),
|
|
523
533
|
});
|
|
524
534
|
|
|
@@ -532,20 +542,54 @@ export const IconAnnotation = makeUserAnnotation<IconAnnotation>({
|
|
|
532
542
|
schema: IconAnnotationSchema,
|
|
533
543
|
});
|
|
534
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Indicates that this entity's icon should be resolved from a property whose value is a `Ref`
|
|
547
|
+
* to another entity. Consumers (e.g. graph node builders) resolve the ref target and use that
|
|
548
|
+
* target's schema `IconAnnotation` in place of the static one declared on this schema.
|
|
549
|
+
*
|
|
550
|
+
* Useful for wrapper schemas that delegate their visual identity to a referenced sub-entity
|
|
551
|
+
* (e.g. a generic `Game` whose icon should come from its `variant` ref's typed state).
|
|
552
|
+
*/
|
|
553
|
+
export const IconFromRefAnnotation = makeUserAnnotation<string>({
|
|
554
|
+
id: 'org.dxos.annotation.icon.from-ref',
|
|
555
|
+
schema: Schema.String,
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Options for {@link getLabel}.
|
|
560
|
+
*/
|
|
561
|
+
export type GetLabelOptions = {
|
|
562
|
+
/**
|
|
563
|
+
* Strategy for deriving a label when the entity has no `LabelAnnotation` value.
|
|
564
|
+
* - `'typename'`: use the entity's typename (e.g. `org.dxos.type.table`).
|
|
565
|
+
* Useful for Card.Title chrome that must always display something, even
|
|
566
|
+
* for unlabeled objects.
|
|
567
|
+
*/
|
|
568
|
+
fallback?: 'typename';
|
|
569
|
+
};
|
|
570
|
+
|
|
535
571
|
/**
|
|
536
572
|
* Get the label of an entity.
|
|
537
573
|
* Accepts both reactive entities and snapshots.
|
|
574
|
+
*
|
|
575
|
+
* If `options.fallback === 'typename'` and no label is set, returns the
|
|
576
|
+
* entity's typename instead.
|
|
538
577
|
*/
|
|
539
|
-
export const getLabel = (entity: AnyProperties): string | undefined => {
|
|
578
|
+
export const getLabel = (entity: AnyProperties, options?: GetLabelOptions): string | undefined => {
|
|
540
579
|
const schema = getSchema(entity);
|
|
541
|
-
|
|
542
|
-
|
|
580
|
+
const label = schema != null ? getLabelWithSchema(schema, entity) : undefined;
|
|
581
|
+
if (label != null) {
|
|
582
|
+
return label;
|
|
583
|
+
}
|
|
584
|
+
if (options?.fallback === 'typename') {
|
|
585
|
+
return getTypename(entity);
|
|
543
586
|
}
|
|
587
|
+
return undefined;
|
|
544
588
|
};
|
|
545
589
|
|
|
546
590
|
/**
|
|
547
591
|
* Set the label of an entity.
|
|
548
|
-
* Must be called within an Obj.
|
|
592
|
+
* Must be called within an Obj.update or Relation.update callback.
|
|
549
593
|
*/
|
|
550
594
|
export const setLabel = (entity: Mutable<AnyProperties>, label: string) => {
|
|
551
595
|
const schema = getSchema(entity);
|
|
@@ -554,6 +598,21 @@ export const setLabel = (entity: Mutable<AnyProperties>, label: string) => {
|
|
|
554
598
|
}
|
|
555
599
|
};
|
|
556
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Returns the primary label property key for an entity.
|
|
603
|
+
* Reads the first accessor from {@link LabelAnnotation}, defaulting to 'name'.
|
|
604
|
+
*/
|
|
605
|
+
export const getLabelProperty = (entity: AnyProperties): string => {
|
|
606
|
+
const schema = getSchema(entity);
|
|
607
|
+
if (schema == null) {
|
|
608
|
+
return 'name';
|
|
609
|
+
}
|
|
610
|
+
return LabelAnnotation.get(schema).pipe(
|
|
611
|
+
Option.flatMap((fields) => Option.fromNullable(fields[0])),
|
|
612
|
+
Option.getOrElse(() => 'name'),
|
|
613
|
+
);
|
|
614
|
+
};
|
|
615
|
+
|
|
557
616
|
/**
|
|
558
617
|
* Get the description of an entity.
|
|
559
618
|
* Accepts both reactive entities and snapshots.
|
|
@@ -565,9 +624,29 @@ export const getDescription = (entity: AnyProperties): string | undefined => {
|
|
|
565
624
|
}
|
|
566
625
|
};
|
|
567
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Get the icon annotation for an entity, resolved via its type-level `IconAnnotation`.
|
|
629
|
+
* Accepts both reactive entities and snapshots.
|
|
630
|
+
*
|
|
631
|
+
* Returns the full `{ icon, hue }` annotation so callers can use both the phosphor icon
|
|
632
|
+
* name and the suggested colour. Callers wanting just the icon name typically write
|
|
633
|
+
* `Obj.getIcon(obj)?.icon ?? 'ph--cube--regular'`.
|
|
634
|
+
*
|
|
635
|
+
* Note: this is the "static" icon from the object's own schema. It does not follow
|
|
636
|
+
* `IconFromRefAnnotation` delegation — call sites needing that (e.g. app-graph node
|
|
637
|
+
* builders) should resolve the ref themselves.
|
|
638
|
+
*/
|
|
639
|
+
export const getIcon = (entity: AnyProperties): IconAnnotation | undefined => {
|
|
640
|
+
const schema = getSchema(entity);
|
|
641
|
+
if (schema == null) {
|
|
642
|
+
return undefined;
|
|
643
|
+
}
|
|
644
|
+
return Option.getOrUndefined(IconAnnotation.get(schema));
|
|
645
|
+
};
|
|
646
|
+
|
|
568
647
|
/**
|
|
569
648
|
* Set the description of an entity.
|
|
570
|
-
* Must be called within an Obj.
|
|
649
|
+
* Must be called within an Obj.update or Relation.update callback.
|
|
571
650
|
*/
|
|
572
651
|
export const setDescription = (entity: Mutable<AnyProperties>, description: string) => {
|
|
573
652
|
const schema = getSchema(entity);
|
|
@@ -575,3 +654,12 @@ export const setDescription = (entity: Mutable<AnyProperties>, description: stri
|
|
|
575
654
|
setDescriptionWithSchema(schema, entity, description);
|
|
576
655
|
}
|
|
577
656
|
};
|
|
657
|
+
|
|
658
|
+
export { Dictionary, Key, getDictionary, setDictionary } from './dictionary';
|
|
659
|
+
|
|
660
|
+
export const getFromAst = <T>(ast: SchemaAST.AST, annotation: Annotation.Annotation<T>): Option.Option<T> => {
|
|
661
|
+
return SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(ast).pipe(
|
|
662
|
+
Option.flatMap((meta) => Option.fromNullable(meta[annotation.key])),
|
|
663
|
+
Option.map(Schema.decodeUnknownSync(annotation.schema)),
|
|
664
|
+
);
|
|
665
|
+
};
|