@dxos/echo 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0
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 +47 -0
- package/dist/lib/neutral/Entity.mjs +59 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +48 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +70 -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 +113 -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 +38 -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 +94 -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 +29 -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-2U2BZDLU.mjs +121 -0
- package/dist/lib/neutral/chunk-2U2BZDLU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-46QNGNTY.mjs +45 -0
- package/dist/lib/neutral/chunk-46QNGNTY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-66GBFH43.mjs +298 -0
- package/dist/lib/neutral/chunk-66GBFH43.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6URFBQJH.mjs +361 -0
- package/dist/lib/neutral/chunk-6URFBQJH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7QQMUDE6.mjs +159 -0
- package/dist/lib/neutral/chunk-7QQMUDE6.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-BNCCGLJN.mjs +7 -0
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DQYLD2RB.mjs +402 -0
- package/dist/lib/neutral/chunk-DQYLD2RB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-E5PBQJWV.mjs +27 -0
- package/dist/lib/neutral/chunk-E5PBQJWV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-EBVB5NOH.mjs +133 -0
- package/dist/lib/neutral/chunk-EBVB5NOH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FNEFSO2C.mjs +787 -0
- package/dist/lib/neutral/chunk-FNEFSO2C.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GZQTCRJB.mjs +73 -0
- package/dist/lib/neutral/chunk-GZQTCRJB.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-KPY6FC5I.mjs +415 -0
- package/dist/lib/neutral/chunk-KPY6FC5I.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MYMU4TWK.mjs +299 -0
- package/dist/lib/neutral/chunk-MYMU4TWK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MZXWVR3T.mjs +97 -0
- package/dist/lib/neutral/chunk-MZXWVR3T.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-QWAOTFCY.mjs +396 -0
- package/dist/lib/neutral/chunk-QWAOTFCY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R72KFH2X.mjs +34 -0
- package/dist/lib/neutral/chunk-R72KFH2X.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TBKX6JQO.mjs +67 -0
- package/dist/lib/neutral/chunk-TBKX6JQO.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-VCAP4OOT.mjs +120 -0
- package/dist/lib/neutral/chunk-VCAP4OOT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WMFVS4KR.mjs +2830 -0
- package/dist/lib/neutral/chunk-WMFVS4KR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XZJUNTML.mjs +335 -0
- package/dist/lib/neutral/chunk-XZJUNTML.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XZM7FERR.mjs +56 -0
- package/dist/lib/neutral/chunk-XZM7FERR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs +50 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZIXGDU6F.mjs +45 -0
- package/dist/lib/neutral/chunk-ZIXGDU6F.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +101 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/internal/index.mjs +261 -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 +98 -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 +146 -87
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +19 -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/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +171 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +136 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.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 +403 -84
- 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 +209 -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 +281 -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 +13 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +84 -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/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.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 +10 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.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 +99 -61
- package/src/Annotation.ts +36 -5
- package/src/Collection.ts +37 -0
- package/src/Database.ts +263 -122
- package/src/Dataset.ts +26 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +196 -11
- package/src/Err.ts +40 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +283 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +424 -0
- package/src/Format.ts +3 -5
- package/src/Hypergraph.ts +79 -0
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +539 -0
- package/src/Obj.ts +639 -289
- package/src/Order.ts +46 -0
- package/src/Query.test.ts +698 -0
- package/src/Query.ts +547 -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 +14 -5
- package/src/internal/{annotations → Annotation}/annotations.test.ts +62 -13
- package/src/internal/{annotations → Annotation}/annotations.ts +186 -71
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/Annotation/sorting.ts +51 -0
- package/src/internal/{annotations → Annotation}/util.ts +16 -1
- package/src/internal/Entity/api.ts +30 -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 -11
- package/src/internal/{entities → Entity}/relation.ts +42 -43
- package/src/internal/Entity/version.ts +96 -0
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/format.test.ts +2 -3
- 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 -66
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +18 -13
- 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 +5 -7
- package/src/internal/{object → Obj}/create-object.ts +6 -7
- 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 -7
- package/src/internal/{object → Obj}/json-serializer.ts +77 -92
- 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/Query.ts +132 -0
- package/src/internal/{ref → Ref}/ref-array.ts +4 -5
- package/src/internal/{ref → Ref}/ref.test.ts +5 -6
- package/src/internal/{ref → Ref}/ref.ts +90 -43
- package/src/internal/{schema → Type}/compose.test.ts +6 -7
- package/src/internal/{schema → Type}/compose.ts +14 -10
- package/src/internal/{schema → Type}/echo-schema.ts +55 -17
- 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 -84
- 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 +105 -0
- package/src/internal/common/proxy/ownership.ts +252 -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 +68 -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 +313 -0
- package/src/internal/common/proxy/typed-handler.ts +447 -0
- package/src/internal/common/proxy/typed-object.test.ts +115 -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 +16 -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 +10 -31
- package/src/testing/api.test.ts +32 -7
- package/src/testing/test-data.ts +0 -1
- 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
|
@@ -7,15 +7,15 @@ 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
|
|
17
|
-
|
|
18
|
-
import { createAnnotationHelper } from './util';
|
|
16
|
+
import { type Mutable } from '../common/proxy';
|
|
17
|
+
import { type AnyProperties, EntityKind, TypeId, getSchema } from '../common/types';
|
|
18
|
+
import { type AnnotationHelper, createAnnotationHelper } from './util';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @internal
|
|
@@ -29,6 +29,10 @@ export const FIELD_PATH_ANNOTATION = 'path';
|
|
|
29
29
|
// TODO(burdon): Field, vs. path vs. property.
|
|
30
30
|
export const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, path);
|
|
31
31
|
|
|
32
|
+
//
|
|
33
|
+
// Type
|
|
34
|
+
//
|
|
35
|
+
|
|
32
36
|
/**
|
|
33
37
|
* ECHO identifier (for a stored schema).
|
|
34
38
|
* Must be a `dxn:echo:` URI.
|
|
@@ -41,18 +45,59 @@ export const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>
|
|
|
41
45
|
Option.getOrElse(() => undefined),
|
|
42
46
|
)(schema.ast);
|
|
43
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @returns DXN of the schema.
|
|
50
|
+
*
|
|
51
|
+
* For non-stored schema returns `dxn:type:`.
|
|
52
|
+
* For stored schema returns `dxn:echo:`.
|
|
53
|
+
*/
|
|
54
|
+
export const getSchemaDXN = (schema: Schema.Schema.All): DXN | undefined => {
|
|
55
|
+
assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');
|
|
56
|
+
const id = getTypeIdentifierAnnotation(schema);
|
|
57
|
+
if (id) {
|
|
58
|
+
return DXN.parse(id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// TODO(dmaretskyi): Add support for dynamic schema.
|
|
62
|
+
const objectAnnotation = getTypeAnnotation(schema);
|
|
63
|
+
if (!objectAnnotation) {
|
|
64
|
+
return undefined;
|
|
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);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//
|
|
85
|
+
// TypeAnnotation
|
|
86
|
+
//
|
|
87
|
+
|
|
44
88
|
/**
|
|
45
89
|
* Fully qualified globally unique typename.
|
|
46
|
-
* Example: `dxos.
|
|
47
|
-
*/
|
|
48
|
-
// TODO(
|
|
49
|
-
// TODO(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
90
|
+
* Example: `org.dxos.type.message`
|
|
91
|
+
*/
|
|
92
|
+
// TODO(wittjosiah): Factor out to DXN spec.
|
|
93
|
+
// TODO(wittjosiah): Switch to atproto NSID regex once legacy typenames are fully migrated:
|
|
94
|
+
// /^[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])?)+(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)$/
|
|
95
|
+
export const TypenameSchema = Schema.String.pipe(
|
|
96
|
+
Schema.pattern(/^[a-zA-Z][a-zA-Z0-9]*(\.[a-zA-Z][a-zA-Z0-9-]*){2,}$/),
|
|
97
|
+
).annotations({
|
|
98
|
+
description: 'Fully qualified globally unique typename in reverse-DNS form.',
|
|
99
|
+
example: 'org.dxos.type.message',
|
|
100
|
+
});
|
|
56
101
|
|
|
57
102
|
/**
|
|
58
103
|
* Semantic version format: `major.minor.patch`
|
|
@@ -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,14 @@ 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.
|
|
341
|
+
* Skips empty strings and whitespace-only strings, continuing to the next field.
|
|
298
342
|
*/
|
|
299
343
|
// TODO(burdon): Convert to JsonPath?
|
|
300
|
-
export const
|
|
344
|
+
export const getLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
345
|
+
schema: S,
|
|
346
|
+
object: Schema.Schema.Type<S>,
|
|
347
|
+
): string | undefined => {
|
|
301
348
|
const annotation = LabelAnnotation.get(schema).pipe(Option.getOrElse(() => ['name']));
|
|
302
349
|
for (const accessor of annotation) {
|
|
303
350
|
assertArgument(
|
|
@@ -307,7 +354,13 @@ export const getLabel = <S extends Schema.Schema.Any>(schema: S, object: Schema.
|
|
|
307
354
|
);
|
|
308
355
|
const value = getField(object, accessor as JsonPath);
|
|
309
356
|
switch (typeof value) {
|
|
310
|
-
case 'string':
|
|
357
|
+
case 'string': {
|
|
358
|
+
const trimmed = value.trim();
|
|
359
|
+
if (trimmed.length > 0) {
|
|
360
|
+
return value;
|
|
361
|
+
}
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
311
364
|
case 'number':
|
|
312
365
|
case 'boolean':
|
|
313
366
|
case 'bigint':
|
|
@@ -325,8 +378,13 @@ export const getLabel = <S extends Schema.Schema.Any>(schema: S, object: Schema.
|
|
|
325
378
|
|
|
326
379
|
/**
|
|
327
380
|
* Sets the label for a given object based on {@link LabelAnnotationId}.
|
|
381
|
+
* Lower-level version that requires explicit schema parameter.
|
|
328
382
|
*/
|
|
329
|
-
export const
|
|
383
|
+
export const setLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
384
|
+
schema: S,
|
|
385
|
+
object: Schema.Schema.Type<S>,
|
|
386
|
+
label: string,
|
|
387
|
+
) => {
|
|
330
388
|
const annotation = LabelAnnotation.get(schema).pipe(
|
|
331
389
|
Option.map((field) => field[0]),
|
|
332
390
|
Option.getOrElse(() => 'name'),
|
|
@@ -342,10 +400,11 @@ export const DescriptionAnnotationId = Symbol.for('@dxos/schema/annotation/Descr
|
|
|
342
400
|
export const DescriptionAnnotation = createAnnotationHelper<string>(DescriptionAnnotationId);
|
|
343
401
|
|
|
344
402
|
/**
|
|
345
|
-
* Returns the
|
|
403
|
+
* Returns the description for a given object based on {@link DescriptionAnnotationId}.
|
|
404
|
+
* Lower-level version that requires explicit schema parameter.
|
|
346
405
|
*/
|
|
347
406
|
// TODO(burdon): Convert to JsonPath?
|
|
348
|
-
export const
|
|
407
|
+
export const getDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
349
408
|
schema: S,
|
|
350
409
|
object: Schema.Schema.Type<S>,
|
|
351
410
|
): string | undefined => {
|
|
@@ -369,8 +428,9 @@ export const getDescription = <S extends Schema.Schema.Any>(
|
|
|
369
428
|
|
|
370
429
|
/**
|
|
371
430
|
* Sets the description for a given object based on {@link DescriptionAnnotationId}.
|
|
431
|
+
* Lower-level version that requires explicit schema parameter.
|
|
372
432
|
*/
|
|
373
|
-
export const
|
|
433
|
+
export const setDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
374
434
|
schema: S,
|
|
375
435
|
object: Schema.Schema.Type<S>,
|
|
376
436
|
description: string,
|
|
@@ -407,57 +467,112 @@ export type GeneratorAnnotationValue =
|
|
|
407
467
|
|
|
408
468
|
export const GeneratorAnnotation = createAnnotationHelper<GeneratorAnnotationValue>(GeneratorAnnotationId);
|
|
409
469
|
|
|
470
|
+
interface MakeAnnoationsProps<T> {
|
|
471
|
+
id: string;
|
|
472
|
+
schema: Schema.Schema<T, any, never>;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// TODO(wittjosiah): Comment.
|
|
476
|
+
export const makeUserAnnotation = <T>(props: MakeAnnoationsProps<T>): AnnotationHelper<T> => {
|
|
477
|
+
assertArgument(
|
|
478
|
+
/^[a-z][a-z0-9]*(\.[a-z][a-z0-9-]*){2,}$/.test(props.id),
|
|
479
|
+
'id',
|
|
480
|
+
'Annotation id must be in the FQN format (org.dxos.annotation.example).',
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
const getFromAst = (ast: SchemaAST.AST) =>
|
|
484
|
+
SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(ast).pipe(
|
|
485
|
+
Option.map((meta) => meta[props.id] as unknown),
|
|
486
|
+
Option.map(Schema.decodeUnknownSync(props.schema)),
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
return {
|
|
490
|
+
get: (schema) => getFromAst(schema.ast),
|
|
491
|
+
getFromAst: (ast) => getFromAst(ast),
|
|
492
|
+
set: (value) =>
|
|
493
|
+
PropertyMeta(props.id, Schema.encodeSync(props.schema)(value)) as <S extends Schema.Schema.Any>(schema: S) => S,
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
const IconAnnotationSchema = Schema.Struct({
|
|
498
|
+
/**
|
|
499
|
+
* Phosphor icon name (e.g., 'ph--user--regular', 'ph--cube--regular', 'ph--link--regular ', etc.)
|
|
500
|
+
*/
|
|
501
|
+
icon: Schema.String.pipe(Schema.pattern(/^ph--[a-z-]+--[a-z]+$/)),
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Color name.
|
|
505
|
+
*
|
|
506
|
+
* List of colors:
|
|
507
|
+
* - 'red'
|
|
508
|
+
* - 'orange'
|
|
509
|
+
* - 'amber'
|
|
510
|
+
* - 'yellow'
|
|
511
|
+
* - 'lime'
|
|
512
|
+
* - 'green'
|
|
513
|
+
* - 'emerald'
|
|
514
|
+
* - 'teal'
|
|
515
|
+
* - 'cyan'
|
|
516
|
+
* - 'violet'
|
|
517
|
+
* - 'purple'
|
|
518
|
+
* - 'fuchsia'
|
|
519
|
+
* - 'pink'
|
|
520
|
+
* - 'rose'
|
|
521
|
+
*/
|
|
522
|
+
|
|
523
|
+
hue: Schema.optional(Schema.String),
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
export interface IconAnnotation extends Schema.Schema.Type<typeof IconAnnotationSchema> {}
|
|
527
|
+
|
|
410
528
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* For non-stored schema returns `dxn:type:`.
|
|
414
|
-
* For stored schema returns `dxn:echo:`.
|
|
529
|
+
* Icon to render in the UI.
|
|
415
530
|
*/
|
|
416
|
-
export const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (id) {
|
|
421
|
-
return DXN.parse(id);
|
|
422
|
-
}
|
|
531
|
+
export const IconAnnotation = makeUserAnnotation<IconAnnotation>({
|
|
532
|
+
id: 'org.dxos.annotation.icon',
|
|
533
|
+
schema: IconAnnotationSchema,
|
|
534
|
+
});
|
|
423
535
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
536
|
+
/**
|
|
537
|
+
* Get the label of an entity.
|
|
538
|
+
* Accepts both reactive entities and snapshots.
|
|
539
|
+
*/
|
|
540
|
+
export const getLabel = (entity: AnyProperties): string | undefined => {
|
|
541
|
+
const schema = getSchema(entity);
|
|
542
|
+
if (schema != null) {
|
|
543
|
+
return getLabelWithSchema(schema, entity);
|
|
428
544
|
}
|
|
429
|
-
|
|
430
|
-
return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
|
|
431
545
|
};
|
|
432
546
|
|
|
433
547
|
/**
|
|
434
|
-
*
|
|
435
|
-
*
|
|
548
|
+
* Set the label of an entity.
|
|
549
|
+
* Must be called within an Obj.change or Relation.change callback.
|
|
436
550
|
*/
|
|
437
|
-
export const
|
|
438
|
-
|
|
439
|
-
|
|
551
|
+
export const setLabel = (entity: Mutable<AnyProperties>, label: string) => {
|
|
552
|
+
const schema = getSchema(entity);
|
|
553
|
+
if (schema != null) {
|
|
554
|
+
setLabelWithSchema(schema, entity, label);
|
|
440
555
|
}
|
|
556
|
+
};
|
|
441
557
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
558
|
+
/**
|
|
559
|
+
* Get the description of an entity.
|
|
560
|
+
* Accepts both reactive entities and snapshots.
|
|
561
|
+
*/
|
|
562
|
+
export const getDescription = (entity: AnyProperties): string | undefined => {
|
|
563
|
+
const schema = getSchema(entity);
|
|
564
|
+
if (schema != null) {
|
|
565
|
+
return getDescriptionWithSchema(schema, entity);
|
|
445
566
|
}
|
|
446
|
-
return Reference.fromDXN(schemaDXN);
|
|
447
567
|
};
|
|
448
568
|
|
|
449
569
|
/**
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
* @deprecated Use {@link getSchemaDXN} instead.
|
|
570
|
+
* Set the description of an entity.
|
|
571
|
+
* Must be called within an Obj.change or Relation.change callback.
|
|
454
572
|
*/
|
|
455
|
-
export const
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
|
|
459
|
-
throw new Error('Schema must be defined via TypedObject.');
|
|
573
|
+
export const setDescription = (entity: Mutable<AnyProperties>, description: string) => {
|
|
574
|
+
const schema = getSchema(entity);
|
|
575
|
+
if (schema != null) {
|
|
576
|
+
setDescriptionWithSchema(schema, entity, description);
|
|
460
577
|
}
|
|
461
|
-
|
|
462
|
-
return typeReference;
|
|
463
578
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { AnyEntity } from '../common/types';
|
|
6
|
+
import { getLabel, getTypename } from './annotations';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* String comparison helper for sorting.
|
|
10
|
+
*/
|
|
11
|
+
export const compare = (a?: string, b?: string): number => {
|
|
12
|
+
if (a == null) {
|
|
13
|
+
return b == null ? 0 : 1;
|
|
14
|
+
}
|
|
15
|
+
if (b == null) {
|
|
16
|
+
return -1;
|
|
17
|
+
}
|
|
18
|
+
return a.localeCompare(b);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Comparator function type for sorting entities.
|
|
23
|
+
* Accepts both reactive entities and snapshots.
|
|
24
|
+
*/
|
|
25
|
+
export type Comparator<T extends AnyEntity = AnyEntity> = (a: T, b: T) => number;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Sort entities by label.
|
|
29
|
+
*/
|
|
30
|
+
export const sortByLabel: Comparator = (a: AnyEntity, b: AnyEntity) => compare(getLabel(a), getLabel(b));
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Sort entities by typename.
|
|
34
|
+
*/
|
|
35
|
+
export const sortByTypename: Comparator = (a: AnyEntity, b: AnyEntity) => compare(getTypename(a), getTypename(b));
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Compose multiple comparators into one.
|
|
39
|
+
* Applies comparators in order until one returns non-zero.
|
|
40
|
+
*/
|
|
41
|
+
export const sort = <T extends AnyEntity>(...comparators: Comparator<T>[]): Comparator<T> => {
|
|
42
|
+
return (a: T, b: T) => {
|
|
43
|
+
for (const comparator of comparators) {
|
|
44
|
+
const result = comparator(a, b);
|
|
45
|
+
if (result !== 0) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -9,16 +9,31 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
9
9
|
import { assertArgument } from '@dxos/invariant';
|
|
10
10
|
import { DXN } from '@dxos/keys';
|
|
11
11
|
|
|
12
|
-
import { EntityKind } from '../types';
|
|
12
|
+
import { EntityKind } from '../common/types';
|
|
13
13
|
|
|
14
14
|
export interface AnnotationHelper<T> {
|
|
15
|
+
/**
|
|
16
|
+
* Get the annotation value from the schema.
|
|
17
|
+
*/
|
|
15
18
|
get: (schema: Schema.Schema.Any) => Option.Option<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the annotation value from the AST.
|
|
21
|
+
*/
|
|
22
|
+
getFromAst: (ast: SchemaAST.AST) => Option.Option<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Set the annotation value on the schema.
|
|
25
|
+
*/
|
|
16
26
|
set: (value: T) => <S extends Schema.Schema.Any>(schema: S) => S;
|
|
17
27
|
}
|
|
18
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Note: only for system annotations.
|
|
31
|
+
*/
|
|
32
|
+
// TODO(dmaretskyi): Rename to createSystemAnnotationHelper.
|
|
19
33
|
export const createAnnotationHelper = <T>(id: symbol): AnnotationHelper<T> => {
|
|
20
34
|
return {
|
|
21
35
|
get: (schema) => SchemaAST.getAnnotation(schema.ast, id),
|
|
36
|
+
getFromAst: (ast) => SchemaAST.getAnnotation(ast, id),
|
|
22
37
|
set:
|
|
23
38
|
(value) =>
|
|
24
39
|
<S extends Schema.Schema.Any>(schema: S) =>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { invariant } from '@dxos/invariant';
|
|
6
|
+
import { type DXN } from '@dxos/keys';
|
|
7
|
+
import { assumeType } from '@dxos/util';
|
|
8
|
+
|
|
9
|
+
import type { AnyEntity } from '../common/types';
|
|
10
|
+
import { type InternalObjectProps, ObjectDatabaseId } from './model';
|
|
11
|
+
import { getObjectDXN } from './util';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the DXN of an entity.
|
|
15
|
+
* Accepts both reactive entities and snapshots.
|
|
16
|
+
*/
|
|
17
|
+
export const getDXN = (entity: AnyEntity): DXN => {
|
|
18
|
+
const dxn = getObjectDXN(entity);
|
|
19
|
+
invariant(dxn != null, 'Invalid entity.');
|
|
20
|
+
return dxn;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get the database the entity belongs to.
|
|
25
|
+
* Accepts both reactive entities and snapshots.
|
|
26
|
+
*/
|
|
27
|
+
export const getDatabase = (entity: AnyEntity): any | undefined => {
|
|
28
|
+
assumeType<InternalObjectProps>(entity);
|
|
29
|
+
return entity[ObjectDatabaseId];
|
|
30
|
+
};
|
|
@@ -8,34 +8,45 @@ import type * as Types from 'effect/Types';
|
|
|
8
8
|
|
|
9
9
|
import { type ToMutable } from '@dxos/util';
|
|
10
10
|
|
|
11
|
-
import { type TypeMeta } from '../
|
|
12
|
-
import { type
|
|
11
|
+
import { type TypeMeta } from '../Annotation';
|
|
12
|
+
import { type AnyEntity, type EntityKind, SchemaKindId } from '../common/types';
|
|
13
13
|
|
|
14
14
|
// TODO(burdon): Define Schema type for `typename` and use consistently for all DXN-like properties.
|
|
15
15
|
|
|
16
16
|
// type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
|
|
17
|
-
export type EchoTypeSchemaProps<T, ExtraFields = {}> = Types.Simplify<
|
|
17
|
+
export type EchoTypeSchemaProps<T, ExtraFields = {}> = Types.Simplify<AnyEntity & ToMutable<T> & ExtraFields>;
|
|
18
18
|
|
|
19
19
|
// TODO(burdon): Rename EchoEntitySchema.
|
|
20
|
-
export interface EchoTypeSchema<
|
|
21
|
-
extends
|
|
20
|
+
export interface EchoTypeSchema<
|
|
21
|
+
Self extends Schema.Schema.Any,
|
|
22
|
+
ExtraFields = {},
|
|
23
|
+
K extends EntityKind = EntityKind,
|
|
24
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
25
|
+
>
|
|
26
|
+
extends
|
|
27
|
+
TypeMeta,
|
|
22
28
|
Schema.AnnotableClass<
|
|
23
|
-
EchoTypeSchema<Self, ExtraFields>,
|
|
29
|
+
EchoTypeSchema<Self, ExtraFields, K, Fields>,
|
|
24
30
|
EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields>,
|
|
25
31
|
EchoTypeSchemaProps<Schema.Schema.Encoded<Self>, ExtraFields>,
|
|
26
32
|
Schema.Schema.Context<Self>
|
|
27
33
|
> {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Schema kind key that marks this as an ECHO schema and indicates its kind.
|
|
36
|
+
* Makes EchoTypeSchema satisfy the Type.AnyObj or Type.Relation.Any type.
|
|
37
|
+
*/
|
|
38
|
+
readonly [SchemaKindId]: K;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The fields defined in the original struct schema.
|
|
42
|
+
* Allows accessing field definitions for introspection.
|
|
43
|
+
*/
|
|
44
|
+
readonly fields: Fields;
|
|
34
45
|
|
|
35
46
|
instanceOf(value: unknown): boolean;
|
|
36
47
|
}
|
|
37
48
|
|
|
38
|
-
// type
|
|
49
|
+
// type MakeProps =
|
|
39
50
|
// | boolean
|
|
40
51
|
// | {
|
|
41
52
|
// readonly disableValidation?: boolean;
|
|
@@ -63,18 +74,24 @@ export interface EchoTypeSchema<Self extends Schema.Schema.Any, ExtraFields = {}
|
|
|
63
74
|
// return out;
|
|
64
75
|
// };
|
|
65
76
|
|
|
66
|
-
// const _getDisableValidationMakeOption = (options:
|
|
77
|
+
// const _getDisableValidationMakeOption = (options: MakeProps | undefined): boolean =>
|
|
67
78
|
// Predicate.isBoolean(options) ? options : options?.disableValidation ?? false;
|
|
68
79
|
|
|
69
80
|
/**
|
|
70
81
|
* @internal
|
|
71
82
|
*/
|
|
72
|
-
export const makeEchoTypeSchema = <
|
|
73
|
-
|
|
83
|
+
export const makeEchoTypeSchema = <
|
|
84
|
+
Self extends Schema.Schema.Any,
|
|
85
|
+
K extends EntityKind = EntityKind,
|
|
86
|
+
// TODO(wittjosiah): Can this be inferred from the schema?
|
|
87
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
88
|
+
>(
|
|
89
|
+
fields: Fields,
|
|
74
90
|
ast: SchemaAST.AST,
|
|
75
91
|
typename: string,
|
|
76
92
|
version: string,
|
|
77
|
-
|
|
93
|
+
kind: K,
|
|
94
|
+
): EchoTypeSchema<Self, {}, K, Fields> => {
|
|
78
95
|
return class EchoObjectSchemaClass extends Schema.make<
|
|
79
96
|
EchoTypeSchemaProps<Schema.Schema.Type<Self>>,
|
|
80
97
|
EchoTypeSchemaProps<Schema.Schema.Encoded<Self>>,
|
|
@@ -82,19 +99,21 @@ export const makeEchoTypeSchema = <Self extends Schema.Schema.Any>(
|
|
|
82
99
|
>(ast) {
|
|
83
100
|
static readonly typename = typename;
|
|
84
101
|
static readonly version = version;
|
|
102
|
+
static readonly [SchemaKindId] = kind;
|
|
103
|
+
static readonly fields = fields;
|
|
85
104
|
|
|
86
105
|
static override annotations(
|
|
87
106
|
annotations: Schema.Annotations.GenericSchema<EchoTypeSchemaProps<Schema.Schema.Type<Self>>>,
|
|
88
|
-
): EchoTypeSchema<Self> {
|
|
107
|
+
): EchoTypeSchema<Self, {}, K, Fields> {
|
|
89
108
|
const schema = Schema.make<EchoTypeSchemaProps<Schema.Schema.Type<Self>>>(ast).annotations(annotations);
|
|
90
|
-
return makeEchoTypeSchema<Self>(
|
|
109
|
+
return makeEchoTypeSchema<Self, K, Fields>(fields, schema.ast, typename, version, kind);
|
|
91
110
|
}
|
|
92
111
|
|
|
93
112
|
// static make(
|
|
94
113
|
// props: RequiredKeys<Schema.TypeLiteral.Constructor<Fields, []>> extends never
|
|
95
114
|
// ? void | Simplify<Schema.TypeLiteral.Constructor<Fields, []>>
|
|
96
115
|
// : Simplify<Schema.TypeLiteral.Constructor<Fields, []>>,
|
|
97
|
-
// options?:
|
|
116
|
+
// options?: MakeProps,
|
|
98
117
|
// ): Simplify<Schema.TypeLiteral.Type<Fields, []>> {
|
|
99
118
|
// const propsWithDefaults: any = _lazilyMergeDefaults(fields, { ...(props as any) });
|
|
100
119
|
// return _getDisableValidationMakeOption(options)
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './api';
|
|
6
|
+
export * from './entity';
|
|
6
7
|
export * from './model'; // TODO(burdon): Rename.
|
|
7
8
|
export * from './object';
|
|
8
9
|
export * from './relation';
|
|
9
10
|
export * from './util';
|
|
11
|
+
export * from './version';
|