@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
|
@@ -9,75 +9,49 @@ import { invariant } from '@dxos/invariant';
|
|
|
9
9
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
10
10
|
import { assumeType } from '@dxos/util';
|
|
11
11
|
|
|
12
|
+
import type * as Database from '../../Database';
|
|
12
13
|
import {
|
|
13
14
|
type ATTR_META,
|
|
15
|
+
type ATTR_PARENT,
|
|
14
16
|
type ATTR_TYPE,
|
|
17
|
+
ATTR_DELETED,
|
|
18
|
+
ATTR_RELATION_SOURCE,
|
|
19
|
+
ATTR_RELATION_TARGET,
|
|
20
|
+
ATTR_SELF_DXN,
|
|
15
21
|
EntityKind,
|
|
16
22
|
KindId,
|
|
17
23
|
type MetaId,
|
|
24
|
+
ObjectDatabaseId,
|
|
25
|
+
ObjectDeletedId,
|
|
18
26
|
type ObjectMeta,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type Version,
|
|
22
|
-
} from '../types';
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
type ATTR_RELATION_SOURCE,
|
|
26
|
-
type ATTR_RELATION_TARGET,
|
|
27
|
+
ObjectVersionId,
|
|
28
|
+
type ParentId,
|
|
27
29
|
RelationSourceDXNId,
|
|
28
30
|
RelationSourceId,
|
|
29
31
|
RelationTargetDXNId,
|
|
30
32
|
RelationTargetId,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Property name for self DXN when object is serialized to JSON.
|
|
39
|
-
*/
|
|
40
|
-
export const ATTR_SELF_DXN = '@dxn';
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* DXN to the object itself.
|
|
44
|
-
*/
|
|
45
|
-
export const SelfDXNId = Symbol.for('@dxos/echo/DXN');
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Property name for deleted when object is serialized to JSON.
|
|
49
|
-
*/
|
|
50
|
-
export const ATTR_DELETED = '@deleted';
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Deletion marker.
|
|
54
|
-
*/
|
|
55
|
-
export const ObjectDeletedId = Symbol.for('@dxos/echo/Deleted');
|
|
33
|
+
type SchemaId,
|
|
34
|
+
SelfDXNId,
|
|
35
|
+
TypeId,
|
|
36
|
+
type Version,
|
|
37
|
+
} from '../common/types';
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
* Object version accessor symbol.
|
|
59
|
-
*/
|
|
60
|
-
export const ObjectVersionId: unique symbol = Symbol.for('@dxos/echo/Version');
|
|
39
|
+
export { ATTR_DELETED, ATTR_SELF_DXN, ObjectDatabaseId, ObjectDeletedId, ObjectVersionId, SelfDXNId };
|
|
61
40
|
|
|
62
41
|
/**
|
|
63
42
|
* Internal runtime representation of an object.
|
|
64
43
|
* The fields are accessed through getter functions.
|
|
65
44
|
*/
|
|
45
|
+
// NOTE: Each symbol has a jsdoc describing its purpose.
|
|
66
46
|
export interface InternalObjectProps {
|
|
67
|
-
id: ObjectId;
|
|
68
|
-
|
|
69
|
-
// Echo supports untyped objects O_O.
|
|
70
|
-
readonly [TypeId]?: DXN;
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
readonly [SelfDXNId]?: DXN;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Returns the schema for the object.
|
|
77
|
-
*/
|
|
78
|
-
readonly [SchemaId]?: Schema.Schema.AnyNoContext;
|
|
47
|
+
readonly id: ObjectId;
|
|
48
|
+
readonly [SelfDXNId]: DXN;
|
|
79
49
|
readonly [KindId]: EntityKind;
|
|
50
|
+
readonly [SchemaId]: Schema.Schema.AnyNoContext;
|
|
51
|
+
readonly [TypeId]: DXN;
|
|
80
52
|
readonly [MetaId]?: ObjectMeta;
|
|
53
|
+
[ParentId]?: InternalObjectProps;
|
|
54
|
+
readonly [ObjectDatabaseId]?: Database.Database;
|
|
81
55
|
readonly [ObjectDeletedId]?: boolean;
|
|
82
56
|
readonly [ObjectVersionId]?: Version;
|
|
83
57
|
readonly [RelationSourceDXNId]?: DXN;
|
|
@@ -101,10 +75,16 @@ export interface ObjectJSON {
|
|
|
101
75
|
id: string;
|
|
102
76
|
[ATTR_TYPE]: DXN.String;
|
|
103
77
|
[ATTR_SELF_DXN]?: DXN.String;
|
|
78
|
+
[ATTR_PARENT]?: string; // Encoded reference
|
|
104
79
|
[ATTR_DELETED]?: boolean;
|
|
105
80
|
[ATTR_META]?: ObjectMetaJSON;
|
|
106
81
|
[ATTR_RELATION_SOURCE]?: DXN.String;
|
|
107
82
|
[ATTR_RELATION_TARGET]?: DXN.String;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Application-specific properties.
|
|
86
|
+
*/
|
|
87
|
+
[key: string]: unknown;
|
|
108
88
|
}
|
|
109
89
|
|
|
110
90
|
/**
|
|
@@ -7,27 +7,39 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
7
7
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
|
|
10
|
-
import { type TypeAnnotation, TypeAnnotationId, type TypeMeta, makeTypeJsonSchemaAnnotation } from '../
|
|
11
|
-
import { EntityKind } from '../types';
|
|
12
|
-
|
|
10
|
+
import { type TypeAnnotation, TypeAnnotationId, type TypeMeta, makeTypeJsonSchemaAnnotation } from '../Annotation';
|
|
11
|
+
import { EntityKind } from '../common/types';
|
|
13
12
|
import { type EchoTypeSchema, makeEchoTypeSchema } from './entity';
|
|
14
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Object schema type with kind marker.
|
|
16
|
+
*/
|
|
17
|
+
export type EchoObjectSchema<
|
|
18
|
+
Self extends Schema.Schema.Any,
|
|
19
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
20
|
+
> = EchoTypeSchema<Self, {}, EntityKind.Object, Fields>;
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* Schema for Obj entity types.
|
|
17
24
|
* Pipeable function to add ECHO object annotations to a schema.
|
|
18
25
|
*/
|
|
19
26
|
export const EchoObjectSchema: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
(
|
|
28
|
+
meta: TypeMeta,
|
|
29
|
+
): <Self extends Schema.Schema.Any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>(
|
|
30
|
+
self: Self & { fields?: Fields },
|
|
31
|
+
) => EchoObjectSchema<Self, Fields>;
|
|
23
32
|
} = ({ typename, version }) => {
|
|
24
|
-
return <Self extends Schema.Schema.Any
|
|
33
|
+
return <Self extends Schema.Schema.Any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>(
|
|
34
|
+
self: Self & { fields?: Fields },
|
|
35
|
+
): EchoObjectSchema<Self, Fields> => {
|
|
25
36
|
invariant(typeof TypeAnnotationId === 'symbol', 'Sanity.');
|
|
26
37
|
invariant(SchemaAST.isTypeLiteral(self.ast), 'Schema must be a TypeLiteral.');
|
|
27
38
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
// Extract fields from the schema if available (Struct schemas have .fields).
|
|
40
|
+
const fields = ((self as any).fields ?? {}) as Fields;
|
|
41
|
+
|
|
42
|
+
const schemaWithId = Schema.extend(self, Schema.Struct({ id: Schema.String }));
|
|
31
43
|
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
32
44
|
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
33
45
|
...self.ast.annotations,
|
|
@@ -40,6 +52,6 @@ export const EchoObjectSchema: {
|
|
|
40
52
|
}),
|
|
41
53
|
});
|
|
42
54
|
|
|
43
|
-
return makeEchoTypeSchema<Self>(
|
|
55
|
+
return makeEchoTypeSchema<Self, EntityKind.Object, Fields>(fields, ast, typename, version, EntityKind.Object);
|
|
44
56
|
};
|
|
45
57
|
};
|
|
@@ -17,45 +17,28 @@ import {
|
|
|
17
17
|
getSchemaTypename,
|
|
18
18
|
getTypeIdentifierAnnotation,
|
|
19
19
|
makeTypeJsonSchemaAnnotation,
|
|
20
|
-
} from '../
|
|
21
|
-
import {
|
|
20
|
+
} from '../Annotation';
|
|
21
|
+
import {
|
|
22
|
+
ATTR_RELATION_SOURCE,
|
|
23
|
+
ATTR_RELATION_TARGET,
|
|
24
|
+
EntityKind,
|
|
25
|
+
RelationSourceDXNId,
|
|
26
|
+
RelationSourceId,
|
|
27
|
+
RelationTargetDXNId,
|
|
28
|
+
RelationTargetId,
|
|
29
|
+
} from '../common/types';
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
ATTR_RELATION_SOURCE,
|
|
33
|
+
ATTR_RELATION_TARGET,
|
|
34
|
+
RelationSourceDXNId,
|
|
35
|
+
RelationSourceId,
|
|
36
|
+
RelationTargetDXNId,
|
|
37
|
+
RelationTargetId,
|
|
38
|
+
};
|
|
22
39
|
|
|
23
40
|
import { type EchoTypeSchema, makeEchoTypeSchema } from './entity';
|
|
24
41
|
|
|
25
|
-
/**
|
|
26
|
-
* Property name for relation source when object is serialized to JSON.
|
|
27
|
-
*/
|
|
28
|
-
export const ATTR_RELATION_SOURCE = '@relationSource';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Used to access relation source ref on live ECHO objects.
|
|
32
|
-
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
33
|
-
*/
|
|
34
|
-
export const RelationSourceId: unique symbol = Symbol.for('@dxos/echo/RelationSource');
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Used to access relation source ref on live ECHO objects.
|
|
38
|
-
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
39
|
-
*/
|
|
40
|
-
export const RelationSourceDXNId: unique symbol = Symbol.for('@dxos/echo/RelationSourceDXN');
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Property name for relation target when object is serialized to JSON.
|
|
44
|
-
*/
|
|
45
|
-
export const ATTR_RELATION_TARGET = '@relationTarget';
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Used to access relation target ref on live ECHO objects.
|
|
49
|
-
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
50
|
-
*/
|
|
51
|
-
export const RelationTargetId: unique symbol = Symbol.for('@dxos/echo/RelationTarget');
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Used to access relation target ref on live ECHO objects.
|
|
55
|
-
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
56
|
-
*/
|
|
57
|
-
export const RelationTargetDXNId: unique symbol = Symbol.for('@dxos/echo/RelationTargetDXN');
|
|
58
|
-
|
|
59
42
|
/**
|
|
60
43
|
* Source and target props on relations.
|
|
61
44
|
*/
|
|
@@ -83,6 +66,21 @@ export type EchoRelationSchemaOptions<
|
|
|
83
66
|
target: TTarget;
|
|
84
67
|
};
|
|
85
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Relation schema type with kind marker.
|
|
71
|
+
*/
|
|
72
|
+
export type EchoRelationSchema<
|
|
73
|
+
Self extends Schema.Schema.Any,
|
|
74
|
+
Source extends Schema.Schema.AnyNoContext,
|
|
75
|
+
Target extends Schema.Schema.AnyNoContext,
|
|
76
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
77
|
+
> = EchoTypeSchema<
|
|
78
|
+
Self,
|
|
79
|
+
RelationSourceTargetRefs<Schema.Schema.Type<Source>, Schema.Schema.Type<Target>>,
|
|
80
|
+
EntityKind.Relation,
|
|
81
|
+
Fields
|
|
82
|
+
>;
|
|
83
|
+
|
|
86
84
|
/**
|
|
87
85
|
* Schema for Relation entity types.
|
|
88
86
|
*/
|
|
@@ -106,14 +104,15 @@ export const EchoRelationSchema = <
|
|
|
106
104
|
raise(new Error('Target schema must be an echo object schema.'));
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
return <Self extends Schema.Schema.Any>(
|
|
110
|
-
self: Self,
|
|
111
|
-
):
|
|
107
|
+
return <Self extends Schema.Schema.Any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>(
|
|
108
|
+
self: Self & { fields?: Fields },
|
|
109
|
+
): EchoRelationSchema<Self, Source, Target, Fields> => {
|
|
112
110
|
invariant(SchemaAST.isTypeLiteral(self.ast), 'Schema must be a TypeLiteral.');
|
|
113
111
|
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
// Extract fields from the schema if available (Struct schemas have .fields).
|
|
113
|
+
const fields = ((self as any).fields ?? {}) as Fields;
|
|
114
|
+
|
|
115
|
+
const schemaWithId = Schema.extend(self, Schema.Struct({ id: Schema.String }));
|
|
117
116
|
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
118
117
|
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
119
118
|
...self.ast.annotations,
|
|
@@ -135,7 +134,7 @@ export const EchoRelationSchema = <
|
|
|
135
134
|
}),
|
|
136
135
|
});
|
|
137
136
|
|
|
138
|
-
return makeEchoTypeSchema<Self>(
|
|
137
|
+
return makeEchoTypeSchema<Self, EntityKind.Relation, Fields>(fields, ast, typename, version, EntityKind.Relation);
|
|
139
138
|
};
|
|
140
139
|
};
|
|
141
140
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { assertArgument } from '@dxos/invariant';
|
|
6
|
+
|
|
7
|
+
import { type AnyEntity, VersionTypeId } from '../common/types';
|
|
8
|
+
import { ObjectVersionId } from './model';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represent entity version.
|
|
12
|
+
* May be backed by Automerge.
|
|
13
|
+
* Entities with no history are not versioned.
|
|
14
|
+
* Named EntityVersion to avoid conflict with types/version.ts.
|
|
15
|
+
*/
|
|
16
|
+
export interface EntityVersion {
|
|
17
|
+
[VersionTypeId]: {};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Whether the entity is versioned.
|
|
21
|
+
*/
|
|
22
|
+
versioned: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Automerge heads.
|
|
26
|
+
*/
|
|
27
|
+
automergeHeads?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const unversioned: EntityVersion = {
|
|
31
|
+
[VersionTypeId]: {},
|
|
32
|
+
versioned: false,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Checks that `obj` is a version object.
|
|
37
|
+
*/
|
|
38
|
+
export const isVersion = (entity: unknown): entity is EntityVersion => {
|
|
39
|
+
return entity != null && typeof entity === 'object' && VersionTypeId in entity;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the version of an entity.
|
|
44
|
+
* Accepts both reactive entities and snapshots.
|
|
45
|
+
*/
|
|
46
|
+
export const version = (entity: AnyEntity): EntityVersion => {
|
|
47
|
+
const ver = (entity as any)[ObjectVersionId];
|
|
48
|
+
if (ver === undefined) {
|
|
49
|
+
return unversioned;
|
|
50
|
+
}
|
|
51
|
+
return ver;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Checks that `version` is a valid version object.
|
|
56
|
+
*/
|
|
57
|
+
export const versionValid = (ver: EntityVersion): boolean => {
|
|
58
|
+
assertArgument(isVersion(ver), 'version', 'Invalid version object');
|
|
59
|
+
return !!ver.versioned;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type VersionCompareResult = 'unversioned' | 'equal' | 'different';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Compares two versions.
|
|
66
|
+
* @param version1
|
|
67
|
+
* @param version2
|
|
68
|
+
* @returns 'unversioned' if either entity is unversioned, 'equal' if the versions are equal, 'different' if the versions are different.
|
|
69
|
+
*/
|
|
70
|
+
export const compareVersions = (version1: EntityVersion, version2: EntityVersion): VersionCompareResult => {
|
|
71
|
+
assertArgument(isVersion(version1), 'version1', 'Invalid version object');
|
|
72
|
+
assertArgument(isVersion(version2), 'version2', 'Invalid version object');
|
|
73
|
+
|
|
74
|
+
if (!versionValid(version1) || !versionValid(version2)) {
|
|
75
|
+
return 'unversioned';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (version1.automergeHeads?.length !== version2.automergeHeads?.length) {
|
|
79
|
+
return 'different';
|
|
80
|
+
}
|
|
81
|
+
if (version1.automergeHeads?.some((head) => !version2.automergeHeads?.includes(head))) {
|
|
82
|
+
return 'different';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return 'equal';
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const encodeVersion = (ver: EntityVersion): string => {
|
|
89
|
+
return JSON.stringify(ver);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const decodeVersion = (ver: string): EntityVersion => {
|
|
93
|
+
const parsed = JSON.parse(ver);
|
|
94
|
+
parsed[VersionTypeId] = {};
|
|
95
|
+
return parsed;
|
|
96
|
+
};
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { describe, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import { toJsonSchema } from '../
|
|
9
|
-
|
|
8
|
+
import { toJsonSchema } from '../JsonSchema';
|
|
10
9
|
import { Format } from './format';
|
|
11
10
|
import { TypeEnum, TypeFormat, getTypeEnum } from './types';
|
|
12
11
|
|
|
@@ -20,7 +19,7 @@ describe('formats', () => {
|
|
|
20
19
|
birthday: Schema.optional(Format.Date),
|
|
21
20
|
started: Schema.optional(Format.DateTime),
|
|
22
21
|
active: Schema.optional(Schema.Boolean),
|
|
23
|
-
})
|
|
22
|
+
});
|
|
24
23
|
|
|
25
24
|
type TestType = Schema.Schema.Type<typeof TestSchema>;
|
|
26
25
|
|
|
@@ -10,11 +10,10 @@ import * as DateUtil from './date';
|
|
|
10
10
|
import * as NumberUtil from './number';
|
|
11
11
|
import * as ObjectUtil from './object';
|
|
12
12
|
import * as StringUtil from './string';
|
|
13
|
-
import { TypeFormat as
|
|
13
|
+
import { TypeFormat as TypeFormat$ } from './types';
|
|
14
14
|
|
|
15
|
-
// TODO(burdon): Consider factoring out to separate `@dxos/json-schema`
|
|
16
15
|
// TODO(burdon): Media encoding.
|
|
17
|
-
//
|
|
16
|
+
// - https://json-schema.org/understanding-json-schema/reference/non_json_data
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Formats.
|
|
@@ -23,9 +22,9 @@ import { TypeFormat as TypeFormatEnum } from './types';
|
|
|
23
22
|
*/
|
|
24
23
|
// TODO(burdon): Add fields for `examples`, `message`, etc.
|
|
25
24
|
export namespace Format {
|
|
26
|
-
export import TypeFormat =
|
|
25
|
+
export import TypeFormat = TypeFormat$;
|
|
27
26
|
|
|
28
|
-
//
|
|
27
|
+
// String
|
|
29
28
|
export const DXN = Keys.DXN.Schema;
|
|
30
29
|
export const Email = StringUtil.Email;
|
|
31
30
|
export const Formula = StringUtil.Formula;
|
|
@@ -44,12 +43,12 @@ export namespace Format {
|
|
|
44
43
|
export const Timestamp = NumberUtil.Timestamp;
|
|
45
44
|
|
|
46
45
|
// Dates and times
|
|
47
|
-
export const DateTime = DateUtil.DateTime;
|
|
48
46
|
export const Date = DateUtil.DateOnly;
|
|
49
|
-
export const
|
|
47
|
+
export const DateTime = DateUtil.DateTime;
|
|
50
48
|
export const Duration = DateUtil.Duration;
|
|
49
|
+
export const Time = DateUtil.TimeOnly;
|
|
51
50
|
|
|
52
51
|
// Objects
|
|
53
52
|
export const GeoPoint = ObjectUtil.GeoPoint;
|
|
54
|
-
export type GeoPoint = ObjectUtil.GeoPoint;
|
|
53
|
+
export type GeoPoint = ObjectUtil.GeoPoint; // TODO(burdon): Export types.
|
|
55
54
|
}
|
|
@@ -21,8 +21,8 @@ import { FormatAnnotation, TypeFormat } from './types';
|
|
|
21
21
|
* Note: optional third element for altitude.
|
|
22
22
|
*/
|
|
23
23
|
export const GeoPoint = Schema.Tuple(
|
|
24
|
-
Schema.Number.pipe(Schema.annotations({ title: 'Longitude' }), Schema.clamp(-180, 180), Schema.multipleOf(0.
|
|
25
|
-
Schema.Number.pipe(Schema.annotations({ title: 'Latitude' }), Schema.clamp(-90, 90), Schema.multipleOf(0.
|
|
24
|
+
Schema.Number.pipe(Schema.annotations({ title: 'Longitude' }), Schema.clamp(-180, 180), Schema.multipleOf(0.000001)),
|
|
25
|
+
Schema.Number.pipe(Schema.annotations({ title: 'Latitude' }), Schema.clamp(-90, 90), Schema.multipleOf(0.000001)),
|
|
26
26
|
Schema.optionalElement(Schema.Number).annotations({
|
|
27
27
|
title: 'Height ASL (m)',
|
|
28
28
|
}),
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Schema for a single select option. Used to define choices in a {single|multi}-select field.
|
|
9
|
+
*/
|
|
10
|
+
export const SelectOption = Schema.Struct({
|
|
9
11
|
/** Stable identifier for the option. */
|
|
10
12
|
id: Schema.NonEmptyString,
|
|
11
13
|
title: Schema.String,
|
|
12
14
|
/** Color palette used for visual styling. */
|
|
13
15
|
color: Schema.String,
|
|
14
|
-
})
|
|
16
|
+
});
|
|
15
17
|
|
|
16
|
-
export type SelectOption = Schema.Schema.Type<typeof
|
|
18
|
+
export type SelectOption = Schema.Schema.Type<typeof SelectOption>;
|
|
@@ -52,6 +52,11 @@ export const Markdown = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Markd
|
|
|
52
52
|
// TODO(burdon): Implement.
|
|
53
53
|
export const Regex = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Regex));
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Multi-line text.
|
|
57
|
+
*/
|
|
58
|
+
export const Text = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Text));
|
|
59
|
+
|
|
55
60
|
/**
|
|
56
61
|
* https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.3
|
|
57
62
|
*/
|
|
@@ -7,8 +7,8 @@ import type * as JSONSchema from 'effect/JSONSchema';
|
|
|
7
7
|
import * as Option from 'effect/Option';
|
|
8
8
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
9
9
|
|
|
10
|
-
import { createAnnotationHelper } from '../
|
|
11
|
-
import { type JsonSchemaType } from '../
|
|
10
|
+
import { createAnnotationHelper } from '../Annotation';
|
|
11
|
+
import { type JsonSchemaType } from '../JsonSchema';
|
|
12
12
|
|
|
13
13
|
// TODO(burdon): Rename PropertyType.
|
|
14
14
|
export type ScalarType =
|
|
@@ -55,6 +55,7 @@ export const FormatAnnotationId = Symbol.for('@dxos/schema/annotation/Format');
|
|
|
55
55
|
|
|
56
56
|
export const FormatAnnotation = createAnnotationHelper<TypeFormat>(FormatAnnotationId);
|
|
57
57
|
|
|
58
|
+
/** @deprecated */
|
|
58
59
|
export const getFormatAnnotation = (node: SchemaAST.AST): TypeFormat | undefined =>
|
|
59
60
|
Function.pipe(SchemaAST.getAnnotation<TypeFormat>(FormatAnnotationId)(node), Option.getOrUndefined);
|
|
60
61
|
|
|
@@ -84,6 +85,7 @@ export enum TypeFormat {
|
|
|
84
85
|
Markdown = 'markdown',
|
|
85
86
|
Regex = 'regex',
|
|
86
87
|
SingleSelect = 'single-select',
|
|
88
|
+
Text = 'text',
|
|
87
89
|
MultiSelect = 'multi-select',
|
|
88
90
|
URL = 'url',
|
|
89
91
|
UUID = 'uuid',
|
|
@@ -133,7 +135,7 @@ export const typeToFormat: Partial<Record<TypeEnum, TypeFormat>> = {
|
|
|
133
135
|
* Map of format to type.
|
|
134
136
|
*/
|
|
135
137
|
export const formatToType: Record<TypeFormat, TypeEnum> = {
|
|
136
|
-
[TypeFormat.None]:
|
|
138
|
+
[TypeFormat.None]: TypeEnum.String,
|
|
137
139
|
[TypeFormat.String]: TypeEnum.String,
|
|
138
140
|
[TypeFormat.Number]: TypeEnum.Number,
|
|
139
141
|
[TypeFormat.Boolean]: TypeEnum.Boolean,
|
|
@@ -151,6 +153,7 @@ export const formatToType: Record<TypeFormat, TypeEnum> = {
|
|
|
151
153
|
[TypeFormat.URL]: TypeEnum.String,
|
|
152
154
|
[TypeFormat.UUID]: TypeEnum.String,
|
|
153
155
|
[TypeFormat.SingleSelect]: TypeEnum.String,
|
|
156
|
+
[TypeFormat.Text]: TypeEnum.String,
|
|
154
157
|
[TypeFormat.MultiSelect]: TypeEnum.Object,
|
|
155
158
|
|
|
156
159
|
// Dates
|
|
@@ -174,7 +177,10 @@ export const formatToType: Record<TypeFormat, TypeEnum> = {
|
|
|
174
177
|
*/
|
|
175
178
|
export const OptionsAnnotationId = Symbol.for('@dxos/schema/annotation/Options');
|
|
176
179
|
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
// TODO(wittjosiah): Reconcile with `SelectOption`.
|
|
181
|
+
export type Options = string | number;
|
|
182
|
+
export const OptionsAnnotation = createAnnotationHelper<Options[]>(OptionsAnnotationId);
|
|
179
183
|
|
|
180
|
-
|
|
184
|
+
/** @deprecated */
|
|
185
|
+
export const getOptionsAnnotation = (node: SchemaAST.AST): Options[] | undefined =>
|
|
186
|
+
Function.pipe(SchemaAST.getAnnotation<Options[]>(OptionsAnnotationId)(node), Option.getOrUndefined);
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
6
|
|
|
7
|
-
import { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../
|
|
8
|
-
import { CurrencyAnnotationId, FormatAnnotationId } from '../
|
|
9
|
-
import { type JsonSchemaEchoAnnotations, type JsonSchemaType } from '../
|
|
7
|
+
import { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../Annotation';
|
|
8
|
+
import { CurrencyAnnotationId, FormatAnnotationId } from '../Format';
|
|
9
|
+
import { type JsonSchemaEchoAnnotations, type JsonSchemaType } from '../JsonSchema';
|
|
10
10
|
|
|
11
11
|
//
|
|
12
12
|
// This file configures annotations for JSON encoding/decoding.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as Types from 'effect/Types';
|
|
6
|
+
|
|
5
7
|
import { JsonSchemaFields, type JsonSchemaType } from './json-schema-type';
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -9,12 +11,12 @@ import { JsonSchemaFields, type JsonSchemaType } from './json-schema-type';
|
|
|
9
11
|
* Note: the input type does not necessarily match the {@link JsonSchemaType} type.
|
|
10
12
|
*/
|
|
11
13
|
export const normalizeSchema = (schema: JsonSchemaType): JsonSchemaType => {
|
|
12
|
-
const copy = structuredClone(schema)
|
|
14
|
+
const copy = structuredClone(schema) as Types.DeepMutable<JsonSchemaType>;
|
|
13
15
|
go(copy);
|
|
14
16
|
return copy;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
const go = (schema: JsonSchemaType) => {
|
|
19
|
+
const go = (schema: Types.DeepMutable<JsonSchemaType>) => {
|
|
18
20
|
if (typeof schema !== 'object' || schema === null) {
|
|
19
21
|
return;
|
|
20
22
|
}
|