@dxos/echo 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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 +2 -2
- package/dist/lib/neutral/Annotation.mjs +8 -3
- package/dist/lib/neutral/Database.mjs +36 -6
- package/dist/lib/neutral/Entity.mjs +18 -10
- package/dist/lib/neutral/Err.mjs +3 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +45 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +19 -10
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Obj.mjs +35 -15
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +21 -9
- package/dist/lib/neutral/Ref.mjs +9 -7
- package/dist/lib/neutral/Relation.mjs +20 -11
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +13 -10
- package/dist/lib/neutral/Type.mjs +13 -23
- package/dist/lib/neutral/chunk-24XI6DOL.mjs +34 -0
- package/dist/lib/neutral/chunk-24XI6DOL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VB5HVDCA.mjs → chunk-4YAAHG3E.mjs} +53 -5
- package/dist/lib/neutral/chunk-4YAAHG3E.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-CUDIBUM4.mjs → chunk-4ZRIO2QF.mjs} +104 -25
- package/dist/lib/neutral/chunk-4ZRIO2QF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SU2LVM7J.mjs → chunk-7C2A2RP6.mjs} +1731 -2747
- package/dist/lib/neutral/chunk-7C2A2RP6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-BNCCGLJN.mjs} +1 -1
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs.map → chunk-BNCCGLJN.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-2MTHJ5UW.mjs → chunk-CAB5PWUF.mjs} +134 -24
- package/dist/lib/neutral/chunk-CAB5PWUF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-62DWJ6CE.mjs → chunk-DQYLD2RB.mjs} +14 -14
- package/dist/lib/neutral/chunk-DQYLD2RB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-XMIDBDE6.mjs → chunk-DUTD5HFU.mjs} +11 -56
- package/dist/lib/neutral/chunk-DUTD5HFU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-EKQJGGA3.mjs +396 -0
- package/dist/lib/neutral/chunk-EKQJGGA3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VR4A4WGG.mjs → chunk-EOIR5O5I.mjs} +72 -23
- package/dist/lib/neutral/chunk-EOIR5O5I.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-HMOXCO27.mjs → chunk-GVY6O76A.mjs} +8 -3
- package/dist/lib/neutral/chunk-GVY6O76A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4TT624YA.mjs → chunk-GZQTCRJB.mjs} +2 -2
- package/dist/lib/neutral/{chunk-4TT624YA.mjs.map → chunk-GZQTCRJB.mjs.map} +1 -1
- package/dist/lib/neutral/chunk-HGHJ36DH.mjs +117 -0
- package/dist/lib/neutral/chunk-HGHJ36DH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-3ZEAZF7T.mjs → chunk-IICPQK3M.mjs} +8 -4
- package/dist/lib/neutral/chunk-IICPQK3M.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-IP2GHXWA.mjs → chunk-NKPWM67P.mjs} +5 -5
- package/dist/lib/neutral/chunk-NKPWM67P.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6QPSGMEF.mjs → chunk-OPMZTWI3.mjs} +32 -8
- package/dist/lib/neutral/chunk-OPMZTWI3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NWUO5FKZ.mjs → chunk-OPQEHU36.mjs} +8 -2
- package/dist/lib/neutral/chunk-OPQEHU36.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QDV7C7VM.mjs +299 -0
- package/dist/lib/neutral/chunk-QDV7C7VM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YQYMWZAD.mjs → chunk-TBKX6JQO.mjs} +4 -4
- package/dist/lib/neutral/chunk-TBKX6JQO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RPB6V4BE.mjs → chunk-UBEZSGXY.mjs} +14 -1
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ROKO4RKJ.mjs → chunk-UI6MWK5W.mjs} +2 -2
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XV5R2XZH.mjs +133 -0
- package/dist/lib/neutral/chunk-XV5R2XZH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YPGDBRPH.mjs +159 -0
- package/dist/lib/neutral/chunk-YPGDBRPH.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-ZCBOJ6I7.mjs +787 -0
- package/dist/lib/neutral/chunk-ZCBOJ6I7.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +42 -25
- package/dist/lib/neutral/internal/index.mjs +56 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +42 -34
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- 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 +86 -84
- 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 +41 -15
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +43 -0
- package/dist/types/src/Err.d.ts.map +1 -1
- 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 +163 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +21 -5
- package/dist/types/src/Filter.d.ts.map +1 -1
- 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 +8 -3
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- 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 +158 -43
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +109 -15
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +58 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +75 -28
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +4 -4
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +4 -3
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +51 -180
- package/dist/types/src/Type.d.ts.map +1 -1
- 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 +5 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +69 -8
- 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/{api → Annotation}/sorting.d.ts +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +13 -1
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api/entity.d.ts → Entity/api.d.ts} +2 -2
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/entity.d.ts +3 -3
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/model.d.ts +4 -26
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +2 -2
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/relation.d.ts +3 -30
- 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/{api → Entity}/version.d.ts +1 -1
- 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/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/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +1 -1
- 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 +19 -19
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- 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.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 +2 -2
- 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/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +12 -5
- 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/{object → Obj}/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/typed-object.d.ts +4 -4
- 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 +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +16 -3
- 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/{schema → Type}/compose.d.ts +1 -1
- 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 +8 -7
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -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/{schema → Type}/persistent-schema.d.ts +2 -2
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/{api → common/api}/index.d.ts +0 -4
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -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.map +1 -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.map +1 -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.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.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -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.map +1 -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.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts +1 -1
- 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.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +2 -1
- 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 +1 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/entity.d.ts +2 -2
- 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 +2 -1
- 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 +19 -18
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/src/Annotation.ts +31 -1
- package/src/Collection.ts +37 -0
- package/src/Database.ts +167 -173
- package/src/Dataset.ts +26 -0
- package/src/Entity.ts +73 -54
- package/src/Err.ts +22 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +268 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +55 -7
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +9 -4
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +69 -8
- package/src/Obj.ts +285 -140
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +248 -15
- package/src/Query.ts +275 -24
- package/src/Ref.ts +64 -11
- package/src/Relation.test.ts +8 -2
- package/src/Relation.ts +165 -131
- package/src/SchemaRegistry.ts +5 -4
- package/src/Tag.ts +6 -5
- package/src/Type.test.ts +10 -10
- package/src/Type.ts +70 -303
- package/src/View.ts +107 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +5 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +56 -6
- package/src/internal/{annotations → Annotation}/annotations.ts +134 -15
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -3
- package/src/internal/{annotations → Annotation}/util.ts +14 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +4 -2
- package/src/internal/{entities → Entity}/entity.ts +6 -4
- package/src/internal/{entities → Entity}/index.ts +2 -0
- package/src/internal/{entities → Entity}/model.ts +17 -42
- package/src/internal/{entities → Entity}/object.ts +2 -2
- package/src/internal/{entities → Entity}/relation.ts +19 -36
- package/src/internal/{api → Entity}/version.ts +3 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -1
- package/src/internal/{formats → Format}/format.test.ts +1 -1
- package/src/internal/{formats → Format}/types.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +4 -4
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +48 -48
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +6 -4
- package/src/internal/{object → Obj}/clone.ts +3 -3
- 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 +5 -5
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/inspect.ts +2 -2
- package/src/internal/{object → Obj}/json-serializer.test.ts +31 -8
- package/src/internal/{object → Obj}/json-serializer.ts +42 -15
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +24 -24
- package/src/internal/{object → Obj}/set-value.ts +2 -2
- package/src/internal/Obj/snapshot.ts +105 -0
- package/src/internal/{object → Obj}/typed-object.test.ts +3 -3
- package/src/internal/{object → Obj}/typed-object.ts +4 -4
- package/src/internal/Query.ts +132 -0
- package/src/internal/{ref → Ref}/ref-array.ts +1 -1
- package/src/internal/{ref → Ref}/ref.test.ts +4 -4
- package/src/internal/{ref → Ref}/ref.ts +27 -4
- package/src/internal/{schema → Type}/compose.test.ts +5 -5
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/{schema → Type}/echo-schema.ts +11 -10
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +10 -4
- package/src/internal/{README.md → common/README.md} +1 -1
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change.test.ts +58 -58
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -2
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +6 -3
- package/src/internal/{proxy → common/proxy}/make-object.ts +13 -3
- package/src/internal/{proxy → common/proxy}/reactive.ts +1 -1
- package/src/internal/{proxy → common/proxy}/schema.test.ts +10 -10
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +6 -6
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +10 -3
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +4 -4
- package/src/internal/{types → common/types}/base.ts +1 -1
- package/src/internal/{types → common/types}/entity.ts +2 -2
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +4 -1
- 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 +4 -4
- package/src/testing/test-schema.ts +20 -18
- package/dist/lib/neutral/chunk-2MTHJ5UW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3ZEAZF7T.mjs.map +0 -7
- package/dist/lib/neutral/chunk-62DWJ6CE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6QPSGMEF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CUDIBUM4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HMOXCO27.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IP2GHXWA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs +0 -132
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NWUO5FKZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SU2LVM7J.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VB5HVDCA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VR4A4WGG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs +0 -13
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs +0 -157
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XMIDBDE6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YQYMWZAD.mjs.map +0 -7
- 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/api/annotations.d.ts +0 -23
- package/dist/types/src/internal/api/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/api/entity.d.ts.map +0 -1
- package/dist/types/src/internal/api/index.d.ts.map +0 -1
- package/dist/types/src/internal/api/meta.d.ts.map +0 -1
- package/dist/types/src/internal/api/sorting.d.ts.map +0 -1
- package/dist/types/src/internal/api/version.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- 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.map +0 -1
- 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/clone.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.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 +0 -2
- 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/set-value.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/snapshot.d.ts.map +0 -1
- 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/change-context.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/errors.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/event-batch.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.map +0 -1
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/ownership.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/symbols.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.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.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.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- 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/src/internal/api/annotations.ts +0 -60
- package/src/internal/object/snapshot.ts +0 -70
- /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.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/{formats → Format}/select.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/string.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.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}/clone.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}/index.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}/set-value.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/snapshot.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}/index.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -0
- /package/dist/types/src/internal/{api → common/api}/meta.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change-context.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/define-hidden-property.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/errors.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/event-batch.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/index.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/json-serializer.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/make-object.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/ownership.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-types.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-utils.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/reactive-array.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → 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}/symbols.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}/format.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{formats → Format}/object.ts +0 -0
- /package/src/internal/{formats → Format}/select.ts +0 -0
- /package/src/internal/{formats → Format}/string.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/{json-schema → JsonSchema}/json-schema-normalize.ts +0 -0
- /package/src/internal/{object → Obj}/ids.ts +0 -0
- /package/src/internal/{object → Obj}/index.ts +0 -0
- /package/src/internal/{object → Obj}/schema-validator.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
- /package/src/internal/{schema → Type}/index.ts +0 -0
- /package/src/internal/{api → common/api}/meta.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/change-context.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/define-hidden-property.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/errors.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/event-batch.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/ownership.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/reactive-array.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
package/src/Type.test.ts
CHANGED
|
@@ -11,42 +11,42 @@ import { TestSchema } from './testing';
|
|
|
11
11
|
import * as Type from './Type';
|
|
12
12
|
|
|
13
13
|
describe('Type', () => {
|
|
14
|
-
describe('
|
|
14
|
+
describe('Obj.Unknown schema', () => {
|
|
15
15
|
test('has SchemaKindId for schema type checking', ({ expect }) => {
|
|
16
16
|
// Type.isObjectSchema uses SchemaKindId to check if a schema is an object schema.
|
|
17
|
-
expect(Type.isObjectSchema(
|
|
17
|
+
expect(Type.isObjectSchema(Obj.Unknown)).toBe(true);
|
|
18
18
|
expect(Type.isObjectSchema(TestSchema.Person)).toBe(true);
|
|
19
|
-
expect(Type.isObjectSchema(
|
|
19
|
+
expect(Type.isObjectSchema(Relation.Unknown)).toBe(false);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
test('Schema.is validates structural compatibility only', ({ expect }) => {
|
|
23
23
|
// Schema.is does structural validation (has id field).
|
|
24
24
|
// It accepts both ECHO objects and plain objects with compatible structure.
|
|
25
|
-
expect(Schema.is(
|
|
25
|
+
expect(Schema.is(Obj.Unknown)({ id: 'plain-object' })).toBe(true);
|
|
26
26
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
27
|
-
expect(Schema.is(
|
|
27
|
+
expect(Schema.is(Obj.Unknown)(obj)).toBe(true);
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
describe('
|
|
31
|
+
describe('Relation.Unknown schema', () => {
|
|
32
32
|
test('has SchemaKindId for schema type checking', ({ expect }) => {
|
|
33
33
|
// Type.isRelationSchema uses SchemaKindId to check if a schema is a relation schema.
|
|
34
|
-
expect(Type.isRelationSchema(
|
|
34
|
+
expect(Type.isRelationSchema(Relation.Unknown)).toBe(true);
|
|
35
35
|
expect(Type.isRelationSchema(TestSchema.HasManager)).toBe(true);
|
|
36
|
-
expect(Type.isRelationSchema(
|
|
36
|
+
expect(Type.isRelationSchema(Obj.Unknown)).toBe(false);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test('Schema.is validates structural compatibility only', ({ expect }) => {
|
|
40
40
|
// Schema.is does structural validation (has id field).
|
|
41
41
|
// It accepts both ECHO relations and plain objects with compatible structure.
|
|
42
|
-
expect(Schema.is(
|
|
42
|
+
expect(Schema.is(Relation.Unknown)({ id: 'plain-object' })).toBe(true);
|
|
43
43
|
const obj1 = Obj.make(TestSchema.Person, { name: 'Alice' });
|
|
44
44
|
const obj2 = Obj.make(TestSchema.Person, { name: 'Bob' });
|
|
45
45
|
const rel = Relation.make(TestSchema.HasManager, {
|
|
46
46
|
[Relation.Source]: obj1,
|
|
47
47
|
[Relation.Target]: obj2,
|
|
48
48
|
});
|
|
49
|
-
expect(Schema.is(
|
|
49
|
+
expect(Schema.is(Relation.Unknown)(rel)).toBe(true);
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
});
|
package/src/Type.ts
CHANGED
|
@@ -2,50 +2,30 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import type * as Schema from 'effect/Schema';
|
|
6
8
|
|
|
7
9
|
import { type EncodedReference } from '@dxos/echo-protocol';
|
|
8
10
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { type DXN
|
|
11
|
+
import { type DXN } from '@dxos/keys';
|
|
10
12
|
import { type ToMutable } from '@dxos/util';
|
|
11
13
|
|
|
12
|
-
import type * as Entity
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type ATTR_RELATION_TARGET,
|
|
18
|
-
type AnyEntity,
|
|
19
|
-
type AnyProperties,
|
|
20
|
-
EchoObjectSchema,
|
|
21
|
-
EchoRelationSchema,
|
|
22
|
-
type EchoRelationSchemaOptions,
|
|
23
|
-
EchoSchema,
|
|
24
|
-
EntityKind,
|
|
25
|
-
PersistentSchema,
|
|
26
|
-
Ref as Ref$,
|
|
27
|
-
type RefFn,
|
|
28
|
-
type RefSchema,
|
|
29
|
-
SchemaKindId,
|
|
30
|
-
type TypeAnnotation,
|
|
31
|
-
type TypeMeta,
|
|
32
|
-
getSchemaDXN,
|
|
33
|
-
getSchemaTypename,
|
|
34
|
-
getSchemaVersion,
|
|
35
|
-
getTypeAnnotation,
|
|
36
|
-
isMutable as isMutable$,
|
|
37
|
-
toEffectSchema,
|
|
38
|
-
toJsonSchema,
|
|
39
|
-
} from './internal';
|
|
40
|
-
import type * as Relation$ from './Relation';
|
|
14
|
+
import type * as Entity from './Entity';
|
|
15
|
+
import * as typeInternal from './internal/Type';
|
|
16
|
+
import * as internal from './internal';
|
|
17
|
+
import type * as ObjModule from './Obj';
|
|
18
|
+
import type * as RelationModule from './Relation';
|
|
41
19
|
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Dynamic type that can be constructed, mutated, and persisted in the ECHO database.
|
|
22
|
+
*/
|
|
23
|
+
export const RuntimeType = typeInternal.EchoSchema;
|
|
44
24
|
|
|
45
25
|
/**
|
|
46
|
-
*
|
|
26
|
+
* Dynamic type that can be constructed, mutated, and persisted in the ECHO database.
|
|
47
27
|
*/
|
|
48
|
-
export type
|
|
28
|
+
export type RuntimeType = typeInternal.EchoSchema;
|
|
49
29
|
|
|
50
30
|
//
|
|
51
31
|
// Internal types (not exported)
|
|
@@ -55,83 +35,14 @@ export type Properties<T = any> = Omit<T, 'id' | Entity$.KindId | Relation$.Sour
|
|
|
55
35
|
* Type that marks a schema as an ECHO schema.
|
|
56
36
|
* The value indicates the entity kind (Object or Relation).
|
|
57
37
|
*/
|
|
58
|
-
type EchoSchemaKind<K extends EntityKind = EntityKind> = {
|
|
59
|
-
readonly [SchemaKindId]: K;
|
|
38
|
+
type EchoSchemaKind<K extends internal.EntityKind = internal.EntityKind> = {
|
|
39
|
+
readonly [internal.SchemaKindId]: K;
|
|
60
40
|
};
|
|
61
41
|
|
|
62
|
-
/**
|
|
63
|
-
* JSON-encoded properties for objects.
|
|
64
|
-
*/
|
|
65
|
-
interface ObjJsonProps {
|
|
66
|
-
id: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* JSON-encoded properties for relations.
|
|
71
|
-
*/
|
|
72
|
-
interface RelationJsonProps {
|
|
73
|
-
id: string;
|
|
74
|
-
[ATTR_RELATION_SOURCE]: string;
|
|
75
|
-
[ATTR_RELATION_TARGET]: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
42
|
//
|
|
79
43
|
// Obj - Runtime schema for any ECHO object
|
|
80
44
|
//
|
|
81
45
|
|
|
82
|
-
// Internal type for the Obj schema constant.
|
|
83
|
-
// NOTE: The `any` in the type intersection is intentional - it makes this type bidirectionally
|
|
84
|
-
// assignable with specific object types (e.g., Type.Obj can be assigned to/from Meeting.Meeting).
|
|
85
|
-
// This is needed because operation schemas erase type information.
|
|
86
|
-
// TODO(wittjosiah): Consider alternatives to the `any` intersection hack:
|
|
87
|
-
// - Generic operation schemas that preserve input type in output
|
|
88
|
-
// - Branded types that specific schemas also carry
|
|
89
|
-
// - Accept the limitation and require explicit type narrowing at call sites
|
|
90
|
-
type ObjSchemaType = Schema.Schema<
|
|
91
|
-
any & AnyEntity & Entity$.OfKind<typeof Entity$.Kind.Object> & AnyProperties,
|
|
92
|
-
{ id: string } & AnyProperties
|
|
93
|
-
> &
|
|
94
|
-
EchoSchemaKind<EntityKind.Object> &
|
|
95
|
-
TypeMeta;
|
|
96
|
-
|
|
97
|
-
// Internal schema definition.
|
|
98
|
-
// NOTE: The EchoObjectSchema annotation is required for Type.Ref(Type.Obj) to work.
|
|
99
|
-
// The typename/version only satisfy ECHO schema machinery for reference targets.
|
|
100
|
-
const ObjSchema = Schema.Struct({
|
|
101
|
-
id: Schema.String,
|
|
102
|
-
}).pipe(
|
|
103
|
-
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
|
|
104
|
-
EchoObjectSchema({ typename: ANY_OBJECT_TYPENAME, version: ANY_OBJECT_VERSION }),
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Runtime Effect schema for any ECHO object.
|
|
109
|
-
* Use for validation, parsing, or as a reference target for collections.
|
|
110
|
-
*
|
|
111
|
-
* NOTE: `Schema.is(Type.Obj)` does STRUCTURAL validation only (checks for `id` field).
|
|
112
|
-
* Use `Obj.isObject()` for proper ECHO instance type guards that check the KindId brand.
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* // Structural type guard (accepts any object with id field)
|
|
117
|
-
* if (Schema.is(Type.Obj)(unknownValue)) { ... }
|
|
118
|
-
*
|
|
119
|
-
* // ECHO instance type guard (checks KindId brand)
|
|
120
|
-
* if (Obj.isObject(unknownValue)) { ... }
|
|
121
|
-
*
|
|
122
|
-
* // Reference to any object type
|
|
123
|
-
* const Collection = Schema.Struct({
|
|
124
|
-
* objects: Schema.Array(Type.Ref(Type.Obj)),
|
|
125
|
-
* }).pipe(Type.object({ typename: 'Collection', version: '0.1.0' }));
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
// TODO(wittjosiah): Investigate if Schema.filter can validate KindId on ECHO instances.
|
|
129
|
-
// Effect Schema normalizes proxy objects to plain objects before calling filter predicates.
|
|
130
|
-
// Possible approaches: custom Schema.declare, AST manipulation, or upstream contribution.
|
|
131
|
-
export const Obj: ObjSchemaType = Object.assign(ObjSchema, {
|
|
132
|
-
[SchemaKindId]: (ObjSchema as any)[SchemaKindId],
|
|
133
|
-
}) as unknown as ObjSchemaType;
|
|
134
|
-
|
|
135
46
|
/**
|
|
136
47
|
* TypeScript type for an ECHO object schema.
|
|
137
48
|
* `T` is the instance type produced by the schema.
|
|
@@ -147,13 +58,14 @@ export const Obj: ObjSchemaType = Object.assign(ObjSchema, {
|
|
|
147
58
|
* Object.keys(PersonSchema.fields); // ['name']
|
|
148
59
|
* ```
|
|
149
60
|
*/
|
|
150
|
-
export interface Obj<T
|
|
151
|
-
extends
|
|
152
|
-
|
|
61
|
+
export interface Obj<T, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>
|
|
62
|
+
extends
|
|
63
|
+
internal.TypeMeta,
|
|
64
|
+
EchoSchemaKind<internal.EntityKind.Object>,
|
|
153
65
|
Schema.AnnotableClass<
|
|
154
66
|
Obj<T, Fields>,
|
|
155
|
-
Entity
|
|
156
|
-
Schema.Simplify<
|
|
67
|
+
Entity.OfKind<typeof Entity.Kind.Object> & T,
|
|
68
|
+
Schema.Simplify<ObjModule.BaseObjJson & ToMutable<T>>,
|
|
157
69
|
never
|
|
158
70
|
> {
|
|
159
71
|
/**
|
|
@@ -174,13 +86,11 @@ type ObjectSchemaBase = Schema.Schema.AnyNoContext & {
|
|
|
174
86
|
readonly version: string;
|
|
175
87
|
};
|
|
176
88
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
export type Any = ObjectSchemaBase;
|
|
183
|
-
}
|
|
89
|
+
/**
|
|
90
|
+
* Type that represents any ECHO object schema.
|
|
91
|
+
* Accepts both static schemas (Type.object()) and mutable schemas (EchoSchema).
|
|
92
|
+
*/
|
|
93
|
+
export type AnyObj = ObjectSchemaBase;
|
|
184
94
|
|
|
185
95
|
/**
|
|
186
96
|
* Factory function to create an ECHO object schema.
|
|
@@ -190,88 +100,35 @@ export namespace Obj {
|
|
|
190
100
|
* ```ts
|
|
191
101
|
* const Person = Schema.Struct({
|
|
192
102
|
* name: Schema.String,
|
|
193
|
-
* }).pipe(Type.object({ typename: 'example.
|
|
103
|
+
* }).pipe(Type.object({ typename: 'com.example.type.person', version: '0.1.0' }));
|
|
194
104
|
* ```
|
|
195
105
|
*/
|
|
196
106
|
export const object: {
|
|
197
|
-
(opts: TypeMeta): <Self extends Schema.Schema.Any>(self: Self) => Obj<Schema.Schema.Type<Self>>;
|
|
198
|
-
} = EchoObjectSchema as any;
|
|
107
|
+
(opts: internal.TypeMeta): <Self extends Schema.Schema.Any>(self: Self) => Obj<Schema.Schema.Type<Self>>;
|
|
108
|
+
} = internal.EchoObjectSchema as any;
|
|
199
109
|
|
|
200
110
|
//
|
|
201
111
|
// PersistentType (Schema stored in database)
|
|
202
112
|
//
|
|
203
113
|
|
|
204
|
-
export const PersistentType: Obj<PersistentSchema> = PersistentSchema as any;
|
|
114
|
+
export const PersistentType: Obj<typeInternal.PersistentSchema> = typeInternal.PersistentSchema as any;
|
|
205
115
|
|
|
206
116
|
export interface PersistentType extends Schema.Schema.Type<typeof PersistentType> {}
|
|
207
117
|
|
|
208
|
-
export { EchoSchema as RuntimeType };
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
// Relation - Runtime schema for any ECHO relation
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
// Internal type for the Relation schema constant.
|
|
215
|
-
type RelationSchemaType = Schema.Schema<
|
|
216
|
-
{ id: ObjectId } & Record<string, unknown>,
|
|
217
|
-
{ id: string } & Record<string, unknown>
|
|
218
|
-
> &
|
|
219
|
-
EchoSchemaKind<EntityKind.Relation> &
|
|
220
|
-
TypeMeta;
|
|
221
|
-
|
|
222
|
-
// Internal schema definition.
|
|
223
|
-
// NOTE: The EchoRelationSchema annotation is required for Type.Ref(Type.Relation) to work.
|
|
224
|
-
// The typename/version/source/target only satisfy ECHO schema machinery for reference targets.
|
|
225
|
-
const RelationSchema = Schema.Struct({
|
|
226
|
-
id: Schema.String,
|
|
227
|
-
}).pipe(
|
|
228
|
-
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
|
|
229
|
-
EchoRelationSchema({
|
|
230
|
-
typename: 'dxos.org/schema/AnyRelation',
|
|
231
|
-
version: '0.0.0',
|
|
232
|
-
source: ObjSchema,
|
|
233
|
-
target: ObjSchema,
|
|
234
|
-
}),
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Runtime Effect schema for any ECHO relation.
|
|
239
|
-
* Use for validation, parsing, or as a reference target for collections.
|
|
240
|
-
* A relation has `id`, source, and target fields plus any additional properties.
|
|
241
|
-
*
|
|
242
|
-
* NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).
|
|
243
|
-
* Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.
|
|
244
|
-
*
|
|
245
|
-
* @example
|
|
246
|
-
* ```ts
|
|
247
|
-
* // Structural type guard (accepts any object with id field)
|
|
248
|
-
* if (Schema.is(Type.Relation)(unknownValue)) { ... }
|
|
249
|
-
*
|
|
250
|
-
* // ECHO instance type guard (checks KindId brand)
|
|
251
|
-
* if (Relation.isRelation(unknownValue)) { ... }
|
|
252
|
-
* ```
|
|
253
|
-
*/
|
|
254
|
-
export const Relation: RelationSchemaType = Object.assign(RelationSchema, {
|
|
255
|
-
[SchemaKindId]: (RelationSchema as any)[SchemaKindId],
|
|
256
|
-
}) as unknown as RelationSchemaType;
|
|
257
|
-
|
|
258
118
|
/**
|
|
259
119
|
* TypeScript type for an ECHO relation schema.
|
|
260
120
|
* `T` is the instance type produced by the schema (excluding source/target).
|
|
261
121
|
* `Source` and `Target` are the endpoint types.
|
|
262
122
|
* `Fields` is the optional struct fields type for introspection.
|
|
263
123
|
*/
|
|
264
|
-
export interface Relation<
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
269
|
-
> extends TypeMeta,
|
|
270
|
-
EchoSchemaKind<EntityKind.Relation>,
|
|
124
|
+
export interface Relation<T, Source, Target, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>
|
|
125
|
+
extends
|
|
126
|
+
internal.TypeMeta,
|
|
127
|
+
EchoSchemaKind<internal.EntityKind.Relation>,
|
|
271
128
|
Schema.AnnotableClass<
|
|
272
129
|
Relation<T, Source, Target, Fields>,
|
|
273
|
-
Entity
|
|
274
|
-
Schema.Simplify<
|
|
130
|
+
Entity.OfKind<typeof Entity.Kind.Relation> & RelationModule.Endpoints<Source, Target> & T,
|
|
131
|
+
Schema.Simplify<RelationModule.BaseRelationJson & ToMutable<T>>,
|
|
275
132
|
never
|
|
276
133
|
> {
|
|
277
134
|
/**
|
|
@@ -292,28 +149,11 @@ type RelationSchemaBase = Schema.Schema.AnyNoContext & {
|
|
|
292
149
|
readonly version: string;
|
|
293
150
|
};
|
|
294
151
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
export type Any = RelationSchemaBase;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Get relation source type.
|
|
304
|
-
*/
|
|
305
|
-
export type Source<A> = A extends Relation.Endpoints<infer S, infer _T> ? S : never;
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Get relation target type.
|
|
309
|
-
*/
|
|
310
|
-
export type Target<A> = A extends Relation.Endpoints<infer _S, infer T> ? T : never;
|
|
311
|
-
|
|
312
|
-
export type Endpoints<Source, Target> = {
|
|
313
|
-
[Relation$.Source]: Source;
|
|
314
|
-
[Relation$.Target]: Target;
|
|
315
|
-
};
|
|
316
|
-
}
|
|
152
|
+
/**
|
|
153
|
+
* Type that represents any ECHO relation schema.
|
|
154
|
+
* Accepts static schemas (Type.relation()).
|
|
155
|
+
*/
|
|
156
|
+
export type AnyRelation = RelationSchemaBase;
|
|
317
157
|
|
|
318
158
|
/**
|
|
319
159
|
* Factory function to create an ECHO relation schema.
|
|
@@ -324,7 +164,7 @@ export namespace Relation {
|
|
|
324
164
|
* const WorksFor = Schema.Struct({
|
|
325
165
|
* role: Schema.String,
|
|
326
166
|
* }).pipe(Type.relation({
|
|
327
|
-
* typename: 'example.
|
|
167
|
+
* typename: 'com.example.type.works-for',
|
|
328
168
|
* version: '0.1.0',
|
|
329
169
|
* source: Person,
|
|
330
170
|
* target: Company,
|
|
@@ -333,112 +173,39 @@ export namespace Relation {
|
|
|
333
173
|
*/
|
|
334
174
|
export const relation: {
|
|
335
175
|
<SourceSchema extends Schema.Schema.AnyNoContext, TargetSchema extends Schema.Schema.AnyNoContext>(
|
|
336
|
-
opts: EchoRelationSchemaOptions<SourceSchema, TargetSchema>,
|
|
176
|
+
opts: internal.EchoRelationSchemaOptions<SourceSchema, TargetSchema>,
|
|
337
177
|
): <Self extends Schema.Schema.Any>(
|
|
338
178
|
self: Self,
|
|
339
179
|
) => Relation<Schema.Schema.Type<Self>, Schema.Schema.Type<SourceSchema>, Schema.Schema.Type<TargetSchema>>;
|
|
340
|
-
} = EchoRelationSchema as any;
|
|
341
|
-
|
|
342
|
-
//
|
|
343
|
-
// Entity - Entity schema types (union of Object | Relation)
|
|
344
|
-
//
|
|
180
|
+
} = internal.EchoRelationSchema as any;
|
|
345
181
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
* @example
|
|
352
|
-
* ```ts
|
|
353
|
-
* if (Schema.is(Type.Entity.Any)(unknownValue)) {
|
|
354
|
-
* // unknownValue is an ECHO entity
|
|
355
|
-
* }
|
|
356
|
-
* ```
|
|
357
|
-
*/
|
|
358
|
-
export const Any: Schema.Schema<
|
|
359
|
-
{ id: ObjectId } & Record<string, unknown>,
|
|
360
|
-
{ id: string } & Record<string, unknown>
|
|
361
|
-
> = Schema.Union(Obj, Relation);
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Type alias for any ECHO entity schema (object or relation).
|
|
365
|
-
* Use this in type annotations for schema parameters.
|
|
366
|
-
*/
|
|
367
|
-
export type Any = Obj.Any | Relation.Any;
|
|
368
|
-
}
|
|
182
|
+
/**
|
|
183
|
+
* Type alias for any ECHO entity schema (object or relation).
|
|
184
|
+
* Use this in type annotations for schema parameters.
|
|
185
|
+
*/
|
|
186
|
+
export type AnyEntity = AnyObj | AnyRelation;
|
|
369
187
|
|
|
370
188
|
/**
|
|
371
189
|
* Type guard to check if a schema is an object schema.
|
|
372
190
|
* NOTE: This checks SCHEMAS, not instances. Use Obj.isObject for instances.
|
|
373
191
|
*/
|
|
374
|
-
export const isObjectSchema = (schema:
|
|
375
|
-
return (schema as any)[SchemaKindId] === EntityKind.Object;
|
|
192
|
+
export const isObjectSchema = (schema: AnyEntity): schema is AnyObj => {
|
|
193
|
+
return (schema as any)[internal.SchemaKindId] === internal.EntityKind.Object;
|
|
376
194
|
};
|
|
377
195
|
|
|
378
196
|
/**
|
|
379
197
|
* Type guard to check if a schema is a relation schema.
|
|
380
198
|
* NOTE: This checks SCHEMAS, not instances. Use Relation.isRelation for instances.
|
|
381
199
|
*/
|
|
382
|
-
export const isRelationSchema = (schema:
|
|
383
|
-
return (schema as any)[SchemaKindId] === EntityKind.Relation;
|
|
200
|
+
export const isRelationSchema = (schema: AnyEntity): schema is AnyRelation => {
|
|
201
|
+
return (schema as any)[internal.SchemaKindId] === internal.EntityKind.Relation;
|
|
384
202
|
};
|
|
385
203
|
|
|
386
|
-
//
|
|
387
|
-
// Ref
|
|
388
|
-
//
|
|
389
|
-
// NOTE: `Type.Ref` vs `Ref.Ref`:
|
|
390
|
-
// - `Type.Ref<T>` is the SCHEMA type - a schema that produces `Ref.Ref<T>` instances.
|
|
391
|
-
// - `Ref.Ref<T>` is the INSTANCE type - the actual runtime ref object.
|
|
392
|
-
//
|
|
393
|
-
// Example:
|
|
394
|
-
// const taskRef: Ref.Ref<Task> = Ref.make(task); // Instance
|
|
395
|
-
// const schema: Type.Ref<Task> = Type.Ref(Task); // Schema
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Return type of the `Ref` schema constructor.
|
|
400
|
-
*
|
|
401
|
-
* This typedef avoids `TS4023` error (name from external module cannot be used named).
|
|
402
|
-
* See Effect's note on interface types.
|
|
403
|
-
*/
|
|
404
|
-
export interface ref<TargetSchema extends Schema.Schema.Any> extends RefSchema<Schema.Schema.Type<TargetSchema>> {}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Factory function to create a Ref schema for the given target schema.
|
|
408
|
-
* Use this in schema definitions to declare reference fields.
|
|
409
|
-
*
|
|
410
|
-
* @example
|
|
411
|
-
* ```ts
|
|
412
|
-
* const Task = Schema.Struct({
|
|
413
|
-
* assignee: Type.Ref(Person), // Creates a Ref schema
|
|
414
|
-
* }).pipe(Type.object({ typename: 'Task', version: '0.1.0' }));
|
|
415
|
-
* ```
|
|
416
|
-
*/
|
|
417
|
-
export const Ref: RefFn = Ref$;
|
|
418
|
-
|
|
419
204
|
/**
|
|
420
|
-
*
|
|
421
|
-
* This is
|
|
422
|
-
* For the instance type, use `Ref.Ref<T>` from the Ref module.
|
|
423
|
-
*
|
|
424
|
-
* @example
|
|
425
|
-
* ```ts
|
|
426
|
-
* // Schema type annotation (rarely needed, usually inferred):
|
|
427
|
-
* const refSchema: Type.Ref<Task> = Type.Ref(Task);
|
|
428
|
-
*
|
|
429
|
-
* // Instance type annotation (use Ref.Ref instead):
|
|
430
|
-
* const refInstance: Ref.Ref<Task> = Ref.make(task);
|
|
431
|
-
* ```
|
|
205
|
+
* Type that represents any Ref schema (with unknown target type).
|
|
206
|
+
* This is a schema type, not an instance type.
|
|
432
207
|
*/
|
|
433
|
-
export
|
|
434
|
-
|
|
435
|
-
export namespace Ref {
|
|
436
|
-
/**
|
|
437
|
-
* Type that represents any Ref schema (with unknown target type).
|
|
438
|
-
* This is a schema type, not an instance type.
|
|
439
|
-
*/
|
|
440
|
-
export type Any = Schema.Schema<Ref$<any>, EncodedReference>;
|
|
441
|
-
}
|
|
208
|
+
export type AnyRef = Schema.Schema<internal.Ref<any>, EncodedReference>;
|
|
442
209
|
|
|
443
210
|
//
|
|
444
211
|
// Schema utility functions
|
|
@@ -447,19 +214,19 @@ export namespace Ref {
|
|
|
447
214
|
/**
|
|
448
215
|
* Gets the full DXN of the schema.
|
|
449
216
|
* Will include the version if it's a `type` DXN.
|
|
450
|
-
* @example "dxn:example.
|
|
217
|
+
* @example "dxn:com.example.type.person:0.1.0"
|
|
451
218
|
* @example "dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX"
|
|
452
219
|
*/
|
|
453
|
-
export const getDXN = (schema:
|
|
454
|
-
return getSchemaDXN(schema);
|
|
220
|
+
export const getDXN = (schema: AnyEntity): DXN | undefined => {
|
|
221
|
+
return internal.getSchemaDXN(schema);
|
|
455
222
|
};
|
|
456
223
|
|
|
457
224
|
/**
|
|
458
225
|
* @param schema - Schema to get the typename from.
|
|
459
|
-
* @returns The typename of the schema. Example: `example.
|
|
226
|
+
* @returns The typename of the schema. Example: `com.example.type.person`.
|
|
460
227
|
*/
|
|
461
|
-
export const getTypename = (schema:
|
|
462
|
-
const typename = getSchemaTypename(schema);
|
|
228
|
+
export const getTypename = (schema: AnyEntity): string => {
|
|
229
|
+
const typename = internal.getSchemaTypename(schema);
|
|
463
230
|
invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');
|
|
464
231
|
return typename;
|
|
465
232
|
};
|
|
@@ -468,8 +235,8 @@ export const getTypename = (schema: Entity.Any): string => {
|
|
|
468
235
|
* Gets the version of the schema.
|
|
469
236
|
* @example 0.1.0
|
|
470
237
|
*/
|
|
471
|
-
export const getVersion = (schema:
|
|
472
|
-
const version = getSchemaVersion(schema);
|
|
238
|
+
export const getVersion = (schema: AnyEntity): string => {
|
|
239
|
+
const version = internal.getSchemaVersion(schema);
|
|
473
240
|
invariant(typeof version === 'string' && version.match(/^\d+\.\d+\.\d+$/), 'Invalid version');
|
|
474
241
|
return version;
|
|
475
242
|
};
|
|
@@ -477,16 +244,16 @@ export const getVersion = (schema: Entity.Any): string => {
|
|
|
477
244
|
/**
|
|
478
245
|
* @returns True if the schema is mutable.
|
|
479
246
|
*/
|
|
480
|
-
export const isMutable = isMutable
|
|
247
|
+
export const isMutable = typeInternal.isMutable;
|
|
481
248
|
|
|
482
249
|
/**
|
|
483
250
|
* ECHO type metadata.
|
|
484
251
|
*/
|
|
485
|
-
export type Meta = TypeAnnotation;
|
|
252
|
+
export type Meta = internal.TypeAnnotation;
|
|
486
253
|
|
|
487
254
|
/**
|
|
488
255
|
* Gets the meta data of the schema.
|
|
489
256
|
*/
|
|
490
|
-
export const getMeta = (schema:
|
|
491
|
-
return getTypeAnnotation(schema);
|
|
257
|
+
export const getMeta = (schema: AnyEntity): Meta | undefined => {
|
|
258
|
+
return internal.getTypeAnnotation(schema);
|
|
492
259
|
};
|
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
|
+
};
|