@dxos/echo 0.8.4-main.7ace549 → 0.8.4-main.8360d9e660
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/README.md +3 -4
- package/dist/lib/neutral/Annotation.mjs +37 -0
- package/dist/lib/neutral/Database.mjs +45 -0
- package/dist/lib/neutral/Entity.mjs +59 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Feed.mjs +47 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +64 -0
- package/dist/lib/neutral/Filter.mjs.map +7 -0
- package/dist/lib/neutral/Format.mjs +66 -0
- package/dist/lib/neutral/Format.mjs.map +7 -0
- package/dist/lib/neutral/JsonSchema.mjs +19 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +12 -0
- package/dist/lib/neutral/Key.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +110 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +12 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +36 -0
- package/dist/lib/neutral/Query.mjs.map +7 -0
- package/dist/lib/neutral/QueryResult.mjs +2 -0
- package/dist/lib/neutral/QueryResult.mjs.map +7 -0
- package/dist/lib/neutral/Ref.mjs +24 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +93 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/SchemaRegistry.mjs +2 -0
- package/dist/lib/neutral/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +28 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +37 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs +396 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4JRI2ZJI.mjs +313 -0
- package/dist/lib/neutral/chunk-4JRI2ZJI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6DNYDXCV.mjs +159 -0
- package/dist/lib/neutral/chunk-6DNYDXCV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6GPU7XC3.mjs +283 -0
- package/dist/lib/neutral/chunk-6GPU7XC3.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6K2MVI2O.mjs +56 -0
- package/dist/lib/neutral/chunk-6K2MVI2O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7VNVH63N.mjs +106 -0
- package/dist/lib/neutral/chunk-7VNVH63N.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs +21 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs +402 -0
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs +7 -0
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs +787 -0
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-C4JZK4J7.mjs +2712 -0
- package/dist/lib/neutral/chunk-C4JZK4J7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs +45 -0
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FZO7LQO7.mjs +73 -0
- package/dist/lib/neutral/chunk-FZO7LQO7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NEGC54NE.mjs +130 -0
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs +299 -0
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OENWMTE6.mjs +45 -0
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ROAGDPV7.mjs +121 -0
- package/dist/lib/neutral/chunk-ROAGDPV7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs +355 -0
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs +51 -0
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs +42 -0
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs +27 -0
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-W47JKR3X.mjs +298 -0
- package/dist/lib/neutral/chunk-W47JKR3X.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs +67 -0
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YMNSMKKW.mjs +97 -0
- package/dist/lib/neutral/chunk-YMNSMKKW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs +34 -0
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +97 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/internal/index.mjs +257 -123
- package/dist/lib/neutral/internal/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +97 -52
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +23 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +139 -87
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +18 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +141 -9
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/Err.d.ts +107 -0
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +165 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +3 -3
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +65 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +392 -85
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +202 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +61 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +282 -18
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/SchemaRegistry.d.ts +84 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +8 -7
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +124 -90
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/View.d.ts +68 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +12 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +83 -27
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts +24 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +14 -1
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/api.d.ts +13 -0
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/entity.d.ts +20 -0
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +8 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/model.d.ts +14 -29
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/object.d.ts +18 -0
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/relation.d.ts +35 -0
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/version.d.ts +42 -0
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/format.d.ts +4 -4
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/select.d.ts +6 -4
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/string.d.ts +4 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +7 -3
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +131 -30
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +2 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts +8 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +3 -3
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/deleted.d.ts +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/index.d.ts +3 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.d.ts +44 -0
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.d.ts +7 -0
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts +6 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts +25 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +4 -4
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +31 -9
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.d.ts +7 -0
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/echo-schema.d.ts +20 -7
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts +4 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/Type/persistent-schema.d.ts +20 -0
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/index.d.ts +11 -0
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts +42 -0
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/make-object.d.ts +2 -4
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +16 -12
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/base.d.ts +6 -16
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/entity.d.ts +37 -0
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/index.d.ts +1 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/meta.d.ts +8 -15
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +54 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/typename.d.ts +8 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +2 -2
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +9 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +146 -179
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +6 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +94 -61
- package/src/Annotation.ts +36 -5
- package/src/Collection.ts +37 -0
- package/src/Database.ts +250 -122
- package/src/Dataset.ts +26 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +197 -11
- package/src/Err.ts +40 -0
- package/src/Feed.ts +262 -0
- package/src/Filter.ts +391 -0
- package/src/Format.ts +3 -5
- package/src/Hypergraph.ts +79 -0
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +447 -0
- package/src/Obj.ts +528 -295
- package/src/Order.ts +46 -0
- package/src/Query.test.ts +632 -0
- package/src/Query.ts +522 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +79 -9
- package/src/Relation.test.ts +88 -0
- package/src/Relation.ts +439 -68
- package/src/SchemaRegistry.ts +106 -0
- package/src/Tag.ts +7 -6
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +167 -166
- package/src/View.ts +107 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +13 -5
- package/src/internal/{annotations → Annotation}/annotations.test.ts +12 -12
- package/src/internal/{annotations → Annotation}/annotations.ts +172 -64
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/Annotation/sorting.ts +52 -0
- package/src/internal/{annotations → Annotation}/util.ts +16 -1
- package/src/internal/Entity/api.ts +31 -0
- package/src/internal/{entities → Entity}/entity.ts +39 -20
- package/src/internal/{entities → Entity}/index.ts +3 -1
- package/src/internal/{entities → Entity}/model.ts +29 -49
- package/src/internal/{entities → Entity}/object.ts +23 -10
- package/src/internal/{entities → Entity}/relation.ts +42 -43
- package/src/internal/Entity/version.ts +97 -0
- package/src/internal/{formats → Format}/date.test.ts +1 -1
- package/src/internal/{formats → Format}/format.test.ts +2 -2
- package/src/internal/{formats → Format}/format.ts +7 -8
- package/src/internal/{formats → Format}/object.ts +2 -2
- package/src/internal/{formats → Format}/select.ts +6 -4
- package/src/internal/{formats → Format}/string.ts +5 -0
- package/src/internal/{formats → Format}/types.ts +12 -6
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +4 -2
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +34 -35
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +67 -65
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +18 -12
- package/src/internal/Obj/clone.ts +48 -0
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +4 -4
- package/src/internal/{object → Obj}/create-object.ts +6 -6
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/index.ts +3 -0
- package/src/internal/{object → Obj}/inspect.ts +4 -4
- package/src/internal/{object → Obj}/json-serializer.test.ts +33 -6
- package/src/internal/{object → Obj}/json-serializer.ts +69 -84
- package/src/internal/{object → Obj}/schema-validator.test.ts +3 -7
- package/src/internal/Obj/schema-validator.ts +6 -0
- package/src/internal/Obj/set-value.test.ts +281 -0
- package/src/internal/Obj/set-value.ts +165 -0
- package/src/internal/Obj/snapshot.ts +105 -0
- package/src/internal/{object → Obj}/typed-object.test.ts +12 -12
- package/src/internal/Obj/typed-object.ts +30 -0
- package/src/internal/{ref → Ref}/ref-array.ts +4 -4
- package/src/internal/{ref → Ref}/ref.test.ts +5 -5
- package/src/internal/{ref → Ref}/ref.ts +90 -43
- package/src/internal/{schema → Type}/compose.test.ts +6 -6
- package/src/internal/{schema → Type}/compose.ts +14 -10
- package/src/internal/{schema → Type}/echo-schema.ts +55 -16
- package/src/internal/{schema → Type}/index.ts +0 -2
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/Type/persistent-schema.ts +33 -0
- package/src/internal/{README.md → common/README.md} +36 -17
- package/src/internal/common/api/index.ts +15 -0
- package/src/internal/common/api/meta.ts +88 -0
- package/src/internal/common/index.ts +7 -0
- package/src/internal/common/proxy/change-context.ts +138 -0
- package/src/internal/common/proxy/change.test.ts +519 -0
- package/src/internal/common/proxy/define-hidden-property.ts +14 -0
- package/src/internal/common/proxy/errors.ts +42 -0
- package/src/internal/common/proxy/event-batch.ts +44 -0
- package/src/internal/{proxy → common/proxy}/handler.test.ts +32 -82
- package/src/internal/common/proxy/index.ts +17 -0
- package/src/internal/common/proxy/json-serializer.ts +90 -0
- package/src/internal/common/proxy/make-object.ts +106 -0
- package/src/internal/common/proxy/ownership.ts +253 -0
- package/src/internal/common/proxy/proxy-types.ts +23 -0
- package/src/internal/common/proxy/proxy-utils.ts +150 -0
- package/src/internal/common/proxy/reactive-array.ts +71 -0
- package/src/internal/common/proxy/reactive.ts +69 -0
- package/src/internal/{object → common/proxy}/schema-validator.ts +3 -1
- package/src/internal/{proxy → common/proxy}/schema.test.ts +29 -21
- package/src/internal/common/proxy/symbols.ts +7 -0
- package/src/internal/common/proxy/typed-handler.test.ts +314 -0
- package/src/internal/common/proxy/typed-handler.ts +449 -0
- package/src/internal/common/proxy/typed-object.test.ts +116 -0
- package/src/internal/{types → common/types}/base.ts +7 -22
- package/src/internal/common/types/entity.ts +54 -0
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +17 -25
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/{types → common/types}/typename.ts +10 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +32 -6
- package/src/testing/test-schema.ts +68 -41
- package/src/testing/util.ts +22 -15
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs +0 -3683
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +0 -7
- package/dist/lib/browser/chunk-E4UTVJNF.mjs +0 -1111
- package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -45
- package/dist/lib/browser/internal/index.mjs +0 -336
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +0 -1111
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs +0 -3683
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -45
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -328
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/errors.d.ts +0 -68
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts +0 -10
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- package/dist/types/src/internal/entities/expando.d.ts +0 -16
- package/dist/types/src/internal/entities/expando.d.ts.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts +0 -6
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts +0 -11
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts +0 -55
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +0 -31
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts +0 -31
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts +0 -3
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts +0 -6
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -6
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +0 -18
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
- package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
- package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts +0 -12
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/dist/types/src/query/filter.d.ts +0 -167
- package/dist/types/src/query/filter.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -5
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/order.d.ts +0 -12
- package/dist/types/src/query/order.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -112
- package/dist/types/src/query/query.d.ts.map +0 -1
- package/dist/types/src/query/query.test.d.ts +0 -2
- package/dist/types/src/query/query.test.d.ts.map +0 -1
- package/dist/types/src/query/testing.d.ts +0 -51
- package/dist/types/src/query/testing.d.ts.map +0 -1
- package/dist/types/src/query/types.d.ts +0 -17
- package/dist/types/src/query/types.d.ts.map +0 -1
- package/dist/types/src/query/util.d.ts +0 -8
- package/dist/types/src/query/util.d.ts.map +0 -1
- package/src/errors.ts +0 -18
- package/src/internal/entities/expando.ts +0 -23
- package/src/internal/object/typed-object.ts +0 -94
- package/src/internal/proxy/index.ts +0 -6
- package/src/internal/proxy/make-object.ts +0 -113
- package/src/internal/proxy/typed-handler.test.ts +0 -102
- package/src/internal/proxy/typed-handler.ts +0 -233
- package/src/internal/proxy/typed-object.test.ts +0 -105
- package/src/internal/schema/persistent-schema.ts +0 -28
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/types/entity.ts +0 -23
- package/src/query/filter.ts +0 -455
- package/src/query/index.ts +0 -9
- package/src/query/order.ts +0 -34
- package/src/query/query.test.ts +0 -334
- package/src/query/query.ts +0 -303
- package/src/query/testing.ts +0 -64
- package/src/query/types.ts +0 -23
- package/src/query/util.ts +0 -25
- /package/dist/lib/{browser/index.mjs.map → neutral/Annotation.mjs.map} +0 -0
- /package/dist/lib/{browser/internal/index.mjs.map → neutral/Database.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/Entity.mjs.map} +0 -0
- /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Err.mjs.map} +0 -0
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/index.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/ids.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/src/internal/{entities → Entity}/util.ts +0 -0
- /package/src/internal/{formats → Format}/date.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{object → Obj}/ids.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
package/src/View.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { QueryAST } from '@dxos/echo-protocol';
|
|
10
|
+
import { JsonPath } from '@dxos/effect';
|
|
11
|
+
import { PublicKey } from '@dxos/keys';
|
|
12
|
+
|
|
13
|
+
import * as Filter from './Filter';
|
|
14
|
+
import * as internal from './internal';
|
|
15
|
+
import * as Obj from './Obj';
|
|
16
|
+
import * as Query from './Query';
|
|
17
|
+
import * as Type from './Type';
|
|
18
|
+
import * as Annotation from './Annotation';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Stored field metadata (e.g., for UX).
|
|
22
|
+
*/
|
|
23
|
+
export const FieldSchema = Schema.Struct({
|
|
24
|
+
id: Schema.String,
|
|
25
|
+
path: JsonPath,
|
|
26
|
+
visible: Schema.optional(Schema.Boolean),
|
|
27
|
+
|
|
28
|
+
// TODO(wittjosiah): Presentation-specific?
|
|
29
|
+
referencePath: Schema.optional(JsonPath),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type FieldType = Schema.Schema.Type<typeof FieldSchema>;
|
|
33
|
+
|
|
34
|
+
export const KeyValueProps = Schema.Record({ key: Schema.String, value: Schema.Any });
|
|
35
|
+
|
|
36
|
+
export const createFieldId = () => PublicKey.random().truncate();
|
|
37
|
+
|
|
38
|
+
export const Projection = Schema.Struct({
|
|
39
|
+
/**
|
|
40
|
+
* Optional schema override used to customize the underlying schema.
|
|
41
|
+
*/
|
|
42
|
+
schema: internal.JsonSchemaType.pipe(Schema.optional),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* UX metadata associated with displayed fields (in table, form, etc.)
|
|
46
|
+
*/
|
|
47
|
+
// TODO(wittjosiah): Should this just be an array of JsonPath?
|
|
48
|
+
fields: Schema.Array(FieldSchema),
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The id for the field used to pivot the view.
|
|
52
|
+
* E.g., the field to use for kanban columns or the field to use for map coordinates.
|
|
53
|
+
*/
|
|
54
|
+
pivotFieldId: Schema.String.pipe(Schema.optional),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export type Projection = Schema.Schema.Type<typeof Projection>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Views are generated or user-defined projections of a schema's properties.
|
|
61
|
+
* They are used to configure the visual representation of the data.
|
|
62
|
+
*/
|
|
63
|
+
const ViewSchema = Schema.Struct({
|
|
64
|
+
/**
|
|
65
|
+
* Query used to retrieve data.
|
|
66
|
+
* Can be a user-provided query grammar string or a query AST.
|
|
67
|
+
*/
|
|
68
|
+
query: Schema.Struct({
|
|
69
|
+
raw: Schema.optional(Schema.String),
|
|
70
|
+
ast: QueryAST.Query,
|
|
71
|
+
}),
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Projection of the data returned from the query.
|
|
75
|
+
*/
|
|
76
|
+
projection: Projection,
|
|
77
|
+
}).pipe(
|
|
78
|
+
Type.object({
|
|
79
|
+
typename: 'org.dxos.type.view',
|
|
80
|
+
version: '0.1.0',
|
|
81
|
+
}),
|
|
82
|
+
internal.SystemTypeAnnotation.set(true),
|
|
83
|
+
Annotation.IconAnnotation.set({
|
|
84
|
+
icon: 'ph--funnel--regular',
|
|
85
|
+
hue: 'green',
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
export interface View extends Schema.Schema.Type<typeof ViewSchema> {}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* View instance type.
|
|
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.
|
|
98
|
+
// TODO(wittjosiah): Find a better solution that doesn't require manually keeping the interface in sync.
|
|
99
|
+
export const View: Type.Obj<View> = ViewSchema as any;
|
|
100
|
+
|
|
101
|
+
export const make = (props: Partial<Obj.MakeProps<typeof View>>): View => {
|
|
102
|
+
return Obj.make(View, {
|
|
103
|
+
query: { ast: Query.select(Filter.nothing()).ast },
|
|
104
|
+
projection: { fields: [] },
|
|
105
|
+
...props,
|
|
106
|
+
});
|
|
107
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import * as Obj from './Obj';
|
|
8
|
+
import { TestSchema } from './testing';
|
|
9
|
+
|
|
10
|
+
describe('Hierarchy', () => {
|
|
11
|
+
test('setParent and getParent', async () => {
|
|
12
|
+
const parent = Obj.make(TestSchema.Organization, { name: 'parent' });
|
|
13
|
+
const child = Obj.make(TestSchema.Person, { name: 'child' });
|
|
14
|
+
expect(Obj.getParent(child)).toBeUndefined();
|
|
15
|
+
|
|
16
|
+
Obj.setParent(child, parent);
|
|
17
|
+
expect(Obj.getParent(child)).toBe(parent);
|
|
18
|
+
|
|
19
|
+
Obj.setParent(child, undefined);
|
|
20
|
+
expect(Obj.getParent(child)).toBeUndefined();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('create object with Obj.Parent in props', () => {
|
|
24
|
+
const parent = Obj.make(TestSchema.Organization, { name: 'DXOS' });
|
|
25
|
+
const child = Obj.make(TestSchema.Person, {
|
|
26
|
+
[Obj.Parent]: parent,
|
|
27
|
+
name: 'John',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(child.name).toBe('John');
|
|
31
|
+
expect(Obj.getParent(child)).toBe(parent);
|
|
32
|
+
});
|
|
33
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -2,21 +2,29 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export { QueryAST } from '@dxos/echo-protocol';
|
|
6
|
+
// TODO(wittjosiah): Refactor DXN to not use statics similar to Query.
|
|
5
7
|
export { DXN } from '@dxos/keys';
|
|
6
8
|
|
|
7
|
-
export * from './errors';
|
|
8
|
-
|
|
9
|
-
// TODO(burdon): Separate namesapces for Query (Query.Query, Query.Filter, etc.)
|
|
10
|
-
export * from './query';
|
|
11
|
-
|
|
12
9
|
export * as Annotation from './Annotation';
|
|
13
10
|
export * as Database from './Database';
|
|
14
11
|
export * as Entity from './Entity';
|
|
12
|
+
export * as Err from './Err';
|
|
13
|
+
export * as Feed from './Feed';
|
|
14
|
+
export * as Filter from './Filter';
|
|
15
15
|
export * as Format from './Format';
|
|
16
|
+
export * as Hypergraph from './Hypergraph';
|
|
16
17
|
export * as JsonSchema from './JsonSchema';
|
|
17
18
|
export * as Key from './Key';
|
|
18
19
|
export * as Obj from './Obj';
|
|
20
|
+
export * as Order from './Order';
|
|
21
|
+
export * as Query from './Query';
|
|
22
|
+
export * as QueryResult from './QueryResult';
|
|
19
23
|
export * as Ref from './Ref';
|
|
20
24
|
export * as Relation from './Relation';
|
|
25
|
+
export * as SchemaRegistry from './SchemaRegistry';
|
|
21
26
|
export * as Tag from './Tag';
|
|
22
27
|
export * as Type from './Type';
|
|
28
|
+
export * as Collection from './Collection';
|
|
29
|
+
export * as View from './View';
|
|
30
|
+
export * as Dataset from './Dataset';
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { describe, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import { EchoObjectSchema } from '../
|
|
8
|
+
import { EchoObjectSchema } from '../Entity';
|
|
9
9
|
|
|
10
|
-
import { LabelAnnotation, TypenameSchema, VersionSchema,
|
|
10
|
+
import { LabelAnnotation, TypenameSchema, VersionSchema, getLabelWithSchema } from './annotations';
|
|
11
11
|
|
|
12
12
|
// TODO(dmaretskyi): Use one of the testing schemas.
|
|
13
13
|
const TestObject = Schema.Struct({
|
|
@@ -20,7 +20,7 @@ type TestObject = Schema.Schema.Type<typeof TestObject>;
|
|
|
20
20
|
|
|
21
21
|
const TestEchoSchema = TestObject.pipe(
|
|
22
22
|
EchoObjectSchema({
|
|
23
|
-
typename: 'dxos.
|
|
23
|
+
typename: 'org.dxos.type.test',
|
|
24
24
|
version: '0.1.0',
|
|
25
25
|
}),
|
|
26
26
|
);
|
|
@@ -30,10 +30,10 @@ type TestEchoSchema = Schema.Schema.Type<typeof TestEchoSchema>;
|
|
|
30
30
|
describe('annotations', () => {
|
|
31
31
|
describe('Typename', () => {
|
|
32
32
|
test('should validate typename', ({ expect }) => {
|
|
33
|
-
// Valid.
|
|
34
|
-
expect(TypenameSchema.make('dxos.
|
|
35
|
-
expect(TypenameSchema.make('dxos.
|
|
36
|
-
expect(TypenameSchema.make('dxos.
|
|
33
|
+
// Valid (reverse-DNS format).
|
|
34
|
+
expect(TypenameSchema.make('org.dxos.type.foo')).to.exist;
|
|
35
|
+
expect(TypenameSchema.make('org.dxos.type.foo-bar')).to.exist;
|
|
36
|
+
expect(TypenameSchema.make('org.dxos.type.foobar')).to.exist;
|
|
37
37
|
|
|
38
38
|
// Invalid.
|
|
39
39
|
expect(() => TypenameSchema.make('dxn:dxos.org')).to.throw();
|
|
@@ -51,7 +51,7 @@ describe('annotations', () => {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
describe('
|
|
54
|
+
describe('getLabelWithSchema', () => {
|
|
55
55
|
test('should return first available label value', ({ expect }) => {
|
|
56
56
|
const obj: TestObject = {
|
|
57
57
|
name: 'Primary Name',
|
|
@@ -59,7 +59,7 @@ describe('annotations', () => {
|
|
|
59
59
|
other: 'Other',
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
expect(
|
|
62
|
+
expect(getLabelWithSchema(TestObject, obj)).toEqual('Primary Name');
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
test('should fallback to second path if first is undefined', ({ expect }) => {
|
|
@@ -69,7 +69,7 @@ describe('annotations', () => {
|
|
|
69
69
|
other: 'Other',
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
expect(
|
|
72
|
+
expect(getLabelWithSchema(TestObject, obj)).toEqual('Fallback Name');
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
test('should return undefined if no label paths resolve', ({ expect }) => {
|
|
@@ -79,7 +79,7 @@ describe('annotations', () => {
|
|
|
79
79
|
other: 'Other',
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
expect(
|
|
82
|
+
expect(getLabelWithSchema(TestObject, obj)).toBeUndefined();
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
test('should return label from echo object', ({ expect }) => {
|
|
@@ -90,7 +90,7 @@ describe('annotations', () => {
|
|
|
90
90
|
other: 'Other',
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
expect(
|
|
93
|
+
expect(getLabelWithSchema(TestEchoSchema, obj)).toEqual('Primary Name');
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
96
|
});
|
|
@@ -7,15 +7,16 @@ 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 {
|
|
10
|
+
import { raise } from '@dxos/debug';
|
|
11
11
|
import { type JsonPath, getField } from '@dxos/effect';
|
|
12
12
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
13
13
|
import { DXN } from '@dxos/keys';
|
|
14
14
|
import { type Primitive } from '@dxos/util';
|
|
15
15
|
|
|
16
|
-
import { type
|
|
16
|
+
import { type Mutable } from '../common/proxy';
|
|
17
|
+
import { type AnyProperties, EntityKind, TypeId, getSchema } from '../common/types';
|
|
17
18
|
|
|
18
|
-
import { createAnnotationHelper } from './util';
|
|
19
|
+
import { type AnnotationHelper, createAnnotationHelper } from './util';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* @internal
|
|
@@ -29,6 +30,10 @@ export const FIELD_PATH_ANNOTATION = 'path';
|
|
|
29
30
|
// TODO(burdon): Field, vs. path vs. property.
|
|
30
31
|
export const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, path);
|
|
31
32
|
|
|
33
|
+
//
|
|
34
|
+
// Type
|
|
35
|
+
//
|
|
36
|
+
|
|
32
37
|
/**
|
|
33
38
|
* ECHO identifier (for a stored schema).
|
|
34
39
|
* Must be a `dxn:echo:` URI.
|
|
@@ -41,16 +46,56 @@ export const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>
|
|
|
41
46
|
Option.getOrElse(() => undefined),
|
|
42
47
|
)(schema.ast);
|
|
43
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @returns DXN of the schema.
|
|
51
|
+
*
|
|
52
|
+
* For non-stored schema returns `dxn:type:`.
|
|
53
|
+
* For stored schema returns `dxn:echo:`.
|
|
54
|
+
*/
|
|
55
|
+
export const getSchemaDXN = (schema: Schema.Schema.All): DXN | undefined => {
|
|
56
|
+
assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');
|
|
57
|
+
const id = getTypeIdentifierAnnotation(schema);
|
|
58
|
+
if (id) {
|
|
59
|
+
return DXN.parse(id);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// TODO(dmaretskyi): Add support for dynamic schema.
|
|
63
|
+
const objectAnnotation = getTypeAnnotation(schema);
|
|
64
|
+
if (!objectAnnotation) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param input schema or a typename string.
|
|
73
|
+
* @return type DXN.
|
|
74
|
+
*/
|
|
75
|
+
export const getTypeDXNFromSpecifier = (input: Schema.Schema.All | string): DXN => {
|
|
76
|
+
if (Schema.isSchema(input)) {
|
|
77
|
+
return getSchemaDXN(input) ?? raise(new TypeError('Schema has no DXN'));
|
|
78
|
+
} else {
|
|
79
|
+
assertArgument(typeof input === 'string', 'input');
|
|
80
|
+
assertArgument(!input.startsWith('dxn:'), 'input');
|
|
81
|
+
return DXN.fromTypename(input);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//
|
|
86
|
+
// TypeAnnotation
|
|
87
|
+
//
|
|
88
|
+
|
|
44
89
|
/**
|
|
45
90
|
* Fully qualified globally unique typename.
|
|
46
|
-
* Example: `dxos.
|
|
91
|
+
* Example: `org.dxos.type.message`
|
|
47
92
|
*/
|
|
48
93
|
// TODO(burdon): Reconcile with short DXN format.
|
|
49
|
-
// TODO(burdon): Change type => schema throughout.
|
|
50
|
-
export const TypenameSchema = Schema.String.pipe(Schema.pattern(/^[a-
|
|
94
|
+
// TODO(burdon): Change "type" => "schema" throughout.
|
|
95
|
+
export const TypenameSchema = Schema.String.pipe(Schema.pattern(/^[a-z][a-z0-9]*(\.[a-z][a-z0-9-]*){2,}$/)).annotations(
|
|
51
96
|
{
|
|
52
|
-
description: 'Fully qualified globally unique typename',
|
|
53
|
-
example: 'dxos.
|
|
97
|
+
description: 'Fully qualified globally unique typename in lowercase reverse-DNS form.',
|
|
98
|
+
example: 'org.dxos.type.message',
|
|
54
99
|
},
|
|
55
100
|
);
|
|
56
101
|
|
|
@@ -82,9 +127,6 @@ export const TypeAnnotation = Schema.extend(
|
|
|
82
127
|
TypeMeta,
|
|
83
128
|
Schema.Struct({
|
|
84
129
|
kind: Schema.Enums(EntityKind),
|
|
85
|
-
// kind: Schema.Enums(EntityKind),
|
|
86
|
-
// typename: Typename,
|
|
87
|
-
// version: VersionSchema,
|
|
88
130
|
|
|
89
131
|
/**
|
|
90
132
|
* If this is a relation, the schema of the source object.
|
|
@@ -102,8 +144,6 @@ export const TypeAnnotation = Schema.extend(
|
|
|
102
144
|
|
|
103
145
|
export interface TypeAnnotation extends Schema.Schema.Type<typeof TypeAnnotation> {}
|
|
104
146
|
|
|
105
|
-
// export type TypeMeta = Pick<TypeAnnotation, 'typename' | 'version'>;
|
|
106
|
-
|
|
107
147
|
/**
|
|
108
148
|
* @returns {@link TypeAnnotation} from a schema.
|
|
109
149
|
* Schema must have been created with {@link TypedObject} or {@link TypedLink} or manually assigned an appropriate annotation.
|
|
@@ -136,7 +176,7 @@ export const getSchemaVersion = (schema: Schema.Schema.All): string | undefined
|
|
|
136
176
|
/**
|
|
137
177
|
* Gets the typename of the object without the version.
|
|
138
178
|
* Returns only the name portion, not the DXN.
|
|
139
|
-
* @example "example.
|
|
179
|
+
* @example "org.example.type.contact"
|
|
140
180
|
*
|
|
141
181
|
* @internal (use Obj.getTypename)
|
|
142
182
|
*/
|
|
@@ -168,7 +208,7 @@ export const setTypename = (obj: any, typename: DXN): void => {
|
|
|
168
208
|
/**
|
|
169
209
|
* @returns Object type as {@link DXN}.
|
|
170
210
|
* @returns undefined if the object doesn't have a type.
|
|
171
|
-
* @example `dxn:example.
|
|
211
|
+
* @example `dxn:com.example.type.person:1.0.0`
|
|
172
212
|
*
|
|
173
213
|
* @internal (use Obj.getTypeDXN)
|
|
174
214
|
*/
|
|
@@ -228,6 +268,10 @@ export const isInstanceOf = <Schema extends Schema.Schema.AnyNoContext>(
|
|
|
228
268
|
return typeDXN.type === typename;
|
|
229
269
|
};
|
|
230
270
|
|
|
271
|
+
//
|
|
272
|
+
// PropertyMeta
|
|
273
|
+
//
|
|
274
|
+
|
|
231
275
|
/**
|
|
232
276
|
* PropertyMeta (metadata for dynamic schema properties).
|
|
233
277
|
* For user-defined annotations.
|
|
@@ -261,18 +305,16 @@ export const getPropertyMetaAnnotation = <T>(prop: SchemaAST.PropertySignature,
|
|
|
261
305
|
Option.getOrElse(() => undefined),
|
|
262
306
|
);
|
|
263
307
|
|
|
308
|
+
//
|
|
309
|
+
// Reference
|
|
310
|
+
//
|
|
311
|
+
|
|
264
312
|
/**
|
|
265
313
|
* Schema reference.
|
|
266
314
|
*/
|
|
267
315
|
export const ReferenceAnnotationId = Symbol.for('@dxos/schema/annotation/Reference');
|
|
268
|
-
|
|
269
316
|
export type ReferenceAnnotationValue = TypeAnnotation;
|
|
270
|
-
|
|
271
|
-
export const getReferenceAnnotation = (schema: Schema.Schema.AnyNoContext) =>
|
|
272
|
-
Function.pipe(
|
|
273
|
-
SchemaAST.getAnnotation<ReferenceAnnotationValue>(ReferenceAnnotationId)(schema.ast),
|
|
274
|
-
Option.getOrElse(() => undefined),
|
|
275
|
-
);
|
|
317
|
+
export const ReferenceAnnotation = createAnnotationHelper<ReferenceAnnotationValue>(ReferenceAnnotationId);
|
|
276
318
|
|
|
277
319
|
/**
|
|
278
320
|
* SchemaMeta.
|
|
@@ -295,9 +337,13 @@ export const LabelAnnotation = createAnnotationHelper<string[]>(LabelAnnotationI
|
|
|
295
337
|
|
|
296
338
|
/**
|
|
297
339
|
* Returns the label for a given object based on {@link LabelAnnotationId}.
|
|
340
|
+
* Lower-level version that requires explicit schema parameter.
|
|
298
341
|
*/
|
|
299
342
|
// TODO(burdon): Convert to JsonPath?
|
|
300
|
-
export const
|
|
343
|
+
export const getLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
344
|
+
schema: S,
|
|
345
|
+
object: Schema.Schema.Type<S>,
|
|
346
|
+
): string | undefined => {
|
|
301
347
|
const annotation = LabelAnnotation.get(schema).pipe(Option.getOrElse(() => ['name']));
|
|
302
348
|
for (const accessor of annotation) {
|
|
303
349
|
assertArgument(
|
|
@@ -325,8 +371,13 @@ export const getLabel = <S extends Schema.Schema.Any>(schema: S, object: Schema.
|
|
|
325
371
|
|
|
326
372
|
/**
|
|
327
373
|
* Sets the label for a given object based on {@link LabelAnnotationId}.
|
|
374
|
+
* Lower-level version that requires explicit schema parameter.
|
|
328
375
|
*/
|
|
329
|
-
export const
|
|
376
|
+
export const setLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
377
|
+
schema: S,
|
|
378
|
+
object: Schema.Schema.Type<S>,
|
|
379
|
+
label: string,
|
|
380
|
+
) => {
|
|
330
381
|
const annotation = LabelAnnotation.get(schema).pipe(
|
|
331
382
|
Option.map((field) => field[0]),
|
|
332
383
|
Option.getOrElse(() => 'name'),
|
|
@@ -342,10 +393,11 @@ export const DescriptionAnnotationId = Symbol.for('@dxos/schema/annotation/Descr
|
|
|
342
393
|
export const DescriptionAnnotation = createAnnotationHelper<string>(DescriptionAnnotationId);
|
|
343
394
|
|
|
344
395
|
/**
|
|
345
|
-
* Returns the
|
|
396
|
+
* Returns the description for a given object based on {@link DescriptionAnnotationId}.
|
|
397
|
+
* Lower-level version that requires explicit schema parameter.
|
|
346
398
|
*/
|
|
347
399
|
// TODO(burdon): Convert to JsonPath?
|
|
348
|
-
export const
|
|
400
|
+
export const getDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
349
401
|
schema: S,
|
|
350
402
|
object: Schema.Schema.Type<S>,
|
|
351
403
|
): string | undefined => {
|
|
@@ -369,8 +421,9 @@ export const getDescription = <S extends Schema.Schema.Any>(
|
|
|
369
421
|
|
|
370
422
|
/**
|
|
371
423
|
* Sets the description for a given object based on {@link DescriptionAnnotationId}.
|
|
424
|
+
* Lower-level version that requires explicit schema parameter.
|
|
372
425
|
*/
|
|
373
|
-
export const
|
|
426
|
+
export const setDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
374
427
|
schema: S,
|
|
375
428
|
object: Schema.Schema.Type<S>,
|
|
376
429
|
description: string,
|
|
@@ -407,57 +460,112 @@ export type GeneratorAnnotationValue =
|
|
|
407
460
|
|
|
408
461
|
export const GeneratorAnnotation = createAnnotationHelper<GeneratorAnnotationValue>(GeneratorAnnotationId);
|
|
409
462
|
|
|
463
|
+
interface MakeAnnoationsProps<T> {
|
|
464
|
+
id: string;
|
|
465
|
+
schema: Schema.Schema<T, any, never>;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// TODO(wittjosiah): Comment.
|
|
469
|
+
export const makeUserAnnotation = <T>(props: MakeAnnoationsProps<T>): AnnotationHelper<T> => {
|
|
470
|
+
assertArgument(
|
|
471
|
+
/^[a-z][a-z0-9]*(\.[a-z][a-z0-9-]*){2,}$/.test(props.id),
|
|
472
|
+
'id',
|
|
473
|
+
'Annotation id must be in the FQN format (org.dxos.annotation.example).',
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
const getFromAst = (ast: SchemaAST.AST) =>
|
|
477
|
+
SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(ast).pipe(
|
|
478
|
+
Option.map((meta) => meta[props.id] as unknown),
|
|
479
|
+
Option.map(Schema.decodeUnknownSync(props.schema)),
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
return {
|
|
483
|
+
get: (schema) => getFromAst(schema.ast),
|
|
484
|
+
getFromAst: (ast) => getFromAst(ast),
|
|
485
|
+
set: (value) =>
|
|
486
|
+
PropertyMeta(props.id, Schema.encodeSync(props.schema)(value)) as <S extends Schema.Schema.Any>(schema: S) => S,
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const IconAnnotationSchema = Schema.Struct({
|
|
491
|
+
/**
|
|
492
|
+
* Phosphor icon name (e.g., 'ph--user--regular', 'ph--cube--regular', 'ph--link--regular ', etc.)
|
|
493
|
+
*/
|
|
494
|
+
icon: Schema.String.pipe(Schema.pattern(/^ph--[a-z-]+--[a-z]+$/)),
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Color name.
|
|
498
|
+
*
|
|
499
|
+
* List of colors:
|
|
500
|
+
* - 'red'
|
|
501
|
+
* - 'orange'
|
|
502
|
+
* - 'amber'
|
|
503
|
+
* - 'yellow'
|
|
504
|
+
* - 'lime'
|
|
505
|
+
* - 'green'
|
|
506
|
+
* - 'emerald'
|
|
507
|
+
* - 'teal'
|
|
508
|
+
* - 'cyan'
|
|
509
|
+
* - 'violet'
|
|
510
|
+
* - 'purple'
|
|
511
|
+
* - 'fuchsia'
|
|
512
|
+
* - 'pink'
|
|
513
|
+
* - 'rose'
|
|
514
|
+
*/
|
|
515
|
+
|
|
516
|
+
hue: Schema.optional(Schema.String),
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
export interface IconAnnotation extends Schema.Schema.Type<typeof IconAnnotationSchema> {}
|
|
520
|
+
|
|
410
521
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* For non-stored schema returns `dxn:type:`.
|
|
414
|
-
* For stored schema returns `dxn:echo:`.
|
|
522
|
+
* Icon to render in the UI.
|
|
415
523
|
*/
|
|
416
|
-
export const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (id) {
|
|
421
|
-
return DXN.parse(id);
|
|
422
|
-
}
|
|
524
|
+
export const IconAnnotation = makeUserAnnotation<IconAnnotation>({
|
|
525
|
+
id: 'org.dxos.annotation.icon',
|
|
526
|
+
schema: IconAnnotationSchema,
|
|
527
|
+
});
|
|
423
528
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
529
|
+
/**
|
|
530
|
+
* Get the label of an entity.
|
|
531
|
+
* Accepts both reactive entities and snapshots.
|
|
532
|
+
*/
|
|
533
|
+
export const getLabel = (entity: AnyProperties): string | undefined => {
|
|
534
|
+
const schema = getSchema(entity);
|
|
535
|
+
if (schema != null) {
|
|
536
|
+
return getLabelWithSchema(schema, entity);
|
|
428
537
|
}
|
|
429
|
-
|
|
430
|
-
return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
|
|
431
538
|
};
|
|
432
539
|
|
|
433
540
|
/**
|
|
434
|
-
*
|
|
435
|
-
*
|
|
541
|
+
* Set the label of an entity.
|
|
542
|
+
* Must be called within an Obj.change or Relation.change callback.
|
|
436
543
|
*/
|
|
437
|
-
export const
|
|
438
|
-
|
|
439
|
-
|
|
544
|
+
export const setLabel = (entity: Mutable<AnyProperties>, label: string) => {
|
|
545
|
+
const schema = getSchema(entity);
|
|
546
|
+
if (schema != null) {
|
|
547
|
+
setLabelWithSchema(schema, entity, label);
|
|
440
548
|
}
|
|
549
|
+
};
|
|
441
550
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
551
|
+
/**
|
|
552
|
+
* Get the description of an entity.
|
|
553
|
+
* Accepts both reactive entities and snapshots.
|
|
554
|
+
*/
|
|
555
|
+
export const getDescription = (entity: AnyProperties): string | undefined => {
|
|
556
|
+
const schema = getSchema(entity);
|
|
557
|
+
if (schema != null) {
|
|
558
|
+
return getDescriptionWithSchema(schema, entity);
|
|
445
559
|
}
|
|
446
|
-
return Reference.fromDXN(schemaDXN);
|
|
447
560
|
};
|
|
448
561
|
|
|
449
562
|
/**
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
* @deprecated Use {@link getSchemaDXN} instead.
|
|
563
|
+
* Set the description of an entity.
|
|
564
|
+
* Must be called within an Obj.change or Relation.change callback.
|
|
454
565
|
*/
|
|
455
|
-
export const
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
|
|
459
|
-
throw new Error('Schema must be defined via TypedObject.');
|
|
566
|
+
export const setDescription = (entity: Mutable<AnyProperties>, description: string) => {
|
|
567
|
+
const schema = getSchema(entity);
|
|
568
|
+
if (schema != null) {
|
|
569
|
+
setDescriptionWithSchema(schema, entity, description);
|
|
460
570
|
}
|
|
461
|
-
|
|
462
|
-
return typeReference;
|
|
463
571
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { AnyEntity } from '../common/types';
|
|
6
|
+
|
|
7
|
+
import { getLabel, getTypename } from './annotations';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* String comparison helper for sorting.
|
|
11
|
+
*/
|
|
12
|
+
export const compare = (a?: string, b?: string): number => {
|
|
13
|
+
if (a == null) {
|
|
14
|
+
return b == null ? 0 : 1;
|
|
15
|
+
}
|
|
16
|
+
if (b == null) {
|
|
17
|
+
return -1;
|
|
18
|
+
}
|
|
19
|
+
return a.localeCompare(b);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Comparator function type for sorting entities.
|
|
24
|
+
* Accepts both reactive entities and snapshots.
|
|
25
|
+
*/
|
|
26
|
+
export type Comparator<T extends AnyEntity = AnyEntity> = (a: T, b: T) => number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Sort entities by label.
|
|
30
|
+
*/
|
|
31
|
+
export const sortByLabel: Comparator = (a: AnyEntity, b: AnyEntity) => compare(getLabel(a), getLabel(b));
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Sort entities by typename.
|
|
35
|
+
*/
|
|
36
|
+
export const sortByTypename: Comparator = (a: AnyEntity, b: AnyEntity) => compare(getTypename(a), getTypename(b));
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Compose multiple comparators into one.
|
|
40
|
+
* Applies comparators in order until one returns non-zero.
|
|
41
|
+
*/
|
|
42
|
+
export const sort = <T extends AnyEntity>(...comparators: Comparator<T>[]): Comparator<T> => {
|
|
43
|
+
return (a: T, b: T) => {
|
|
44
|
+
for (const comparator of comparators) {
|
|
45
|
+
const result = comparator(a, b);
|
|
46
|
+
if (result !== 0) {
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return 0;
|
|
51
|
+
};
|
|
52
|
+
};
|