@dxos/echo 0.8.4-main.fffef41 → 0.8.4-staging.ac66bdf99f
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 +49 -0
- package/dist/lib/neutral/Entity.mjs +61 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Feed.mjs +50 -0
- package/dist/lib/neutral/Filter.mjs +72 -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/Migration.mjs +17 -0
- package/dist/lib/neutral/Migration.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-2KHZ36F5.mjs +361 -0
- package/dist/lib/neutral/chunk-2KHZ36F5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4OIBYSXE.mjs +159 -0
- package/dist/lib/neutral/chunk-4OIBYSXE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs +45 -0
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7RO7CPBZ.mjs +27 -0
- package/dist/lib/neutral/chunk-7RO7CPBZ.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-B4BASU6W.mjs +428 -0
- package/dist/lib/neutral/chunk-B4BASU6W.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-BVOFLCVF.mjs +45 -0
- package/dist/lib/neutral/chunk-BVOFLCVF.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-EAMSSLZC.mjs +299 -0
- package/dist/lib/neutral/chunk-EAMSSLZC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-G3IQMKF7.mjs +396 -0
- package/dist/lib/neutral/chunk-G3IQMKF7.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-HBUZJNZO.mjs +286 -0
- package/dist/lib/neutral/chunk-HBUZJNZO.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-JUXPFOEI.mjs +787 -0
- package/dist/lib/neutral/chunk-JUXPFOEI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MOR5ERFM.mjs +2834 -0
- package/dist/lib/neutral/chunk-MOR5ERFM.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-OS35K56T.mjs +34 -0
- package/dist/lib/neutral/chunk-OS35K56T.mjs.map +7 -0
- package/dist/lib/neutral/chunk-PHU22NLC.mjs +136 -0
- package/dist/lib/neutral/chunk-PHU22NLC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs +97 -0
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T6W2LEZU.mjs +125 -0
- package/dist/lib/neutral/chunk-T6W2LEZU.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-TU3GW67D.mjs +132 -0
- package/dist/lib/neutral/chunk-TU3GW67D.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-V36VO5SS.mjs +354 -0
- package/dist/lib/neutral/chunk-V36VO5SS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WAK4DMFV.mjs +36 -0
- package/dist/lib/neutral/chunk-WAK4DMFV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YAHXAYOW.mjs +56 -0
- package/dist/lib/neutral/chunk-YAHXAYOW.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/index.mjs +105 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/internal/index.mjs +290 -152
- package/dist/lib/neutral/internal/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +375 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +24 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- 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 +201 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- 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 +174 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- 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 +182 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +149 -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 +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- 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 +16 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +1 -0
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +57 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +434 -104
- 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 +287 -21
- 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 +123 -99
- 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 +20 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +231 -0
- 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/Annotation/util.d.ts +39 -0
- 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/Entity/model.d.ts +55 -0
- 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 +2 -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 -2
- 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 +14 -10
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json → 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 +5 -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 → JsonSchema}/json-schema.d.ts +4 -2
- 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/create.d.ts → Obj/create-object.d.ts} +10 -11
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/deleted.d.ts +6 -0
- 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 +11 -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 +45 -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 +44 -19
- 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 +27 -14
- 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/common/proxy/make-object.d.ts +14 -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 +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/common/types/base.d.ts +27 -0
- 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/common/types/index.d.ts +7 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/{object → common/types}/meta.d.ts +18 -16
- 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/common/types/typename.d.ts +21 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/version.d.ts +15 -0
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +10 -14
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +304 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +21 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +116 -65
- package/src/Annotation.ts +48 -0
- package/src/Collection.ts +37 -0
- package/src/Database.ts +352 -0
- package/src/Dataset.ts +26 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +243 -0
- package/src/Err.ts +40 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +304 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +454 -0
- package/src/Format.ts +9 -0
- package/src/Hypergraph.ts +79 -0
- package/src/JsonSchema.ts +26 -0
- package/src/Key.ts +3 -0
- package/src/Migration.ts +94 -0
- package/src/Obj.test.ts +539 -0
- package/src/Obj.ts +697 -277
- package/src/Order.ts +46 -0
- package/src/Query.test.ts +806 -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 +449 -60
- package/src/SchemaRegistry.ts +106 -0
- package/src/Tag.ts +7 -5
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +167 -153
- package/src/View.ts +107 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +22 -6
- package/src/internal/Annotation/annotations.test.ts +145 -0
- package/src/internal/Annotation/annotations.ts +577 -0
- package/src/internal/Annotation/index.ts +7 -0
- package/src/internal/Annotation/sorting.ts +51 -0
- package/src/internal/Annotation/util.ts +85 -0
- package/src/internal/Entity/api.ts +30 -0
- package/src/internal/Entity/entity.ts +128 -0
- package/src/internal/Entity/index.ts +11 -0
- package/src/internal/Entity/model.ts +109 -0
- package/src/internal/Entity/object.ts +57 -0
- package/src/internal/Entity/relation.ts +154 -0
- package/src/internal/Entity/util.ts +33 -0
- package/src/internal/Entity/version.ts +96 -0
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/date.ts +5 -5
- package/src/internal/{formats → Format}/format.test.ts +6 -7
- package/src/internal/{formats → Format}/format.ts +8 -6
- package/src/internal/{formats → Format}/number.ts +5 -5
- package/src/internal/{formats → Format}/object.ts +4 -4
- package/src/internal/{formats → Format}/select.ts +6 -4
- package/src/internal/{formats → Format}/string.ts +14 -9
- package/src/internal/{formats → Format}/types.ts +54 -43
- package/src/internal/{json → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/index.ts +2 -0
- package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +4 -2
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +36 -36
- package/src/internal/{json → JsonSchema}/json-schema.test.ts +106 -95
- package/src/internal/{json → JsonSchema}/json-schema.ts +29 -15
- package/src/internal/Obj/clone.ts +48 -0
- package/src/internal/{object → Obj}/common.ts +3 -4
- package/src/internal/{object/create.test.ts → Obj/create-object.test.ts} +32 -36
- package/src/internal/{object/create.ts → Obj/create-object.ts} +35 -37
- package/src/internal/Obj/deleted.ts +19 -0
- package/src/internal/{object → Obj}/ids.ts +1 -1
- package/src/internal/Obj/index.ts +14 -0
- package/src/internal/{object → Obj}/inspect.ts +5 -7
- package/src/internal/Obj/json-serializer.test.ts +120 -0
- package/src/internal/{object → Obj}/json-serializer.ts +106 -109
- 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 +134 -0
- package/src/internal/{ref → Ref}/ref-array.ts +4 -5
- package/src/internal/{ref → Ref}/ref.test.ts +11 -11
- package/src/internal/{ref → Ref}/ref.ts +108 -57
- package/src/internal/{projection → Type}/compose.test.ts +8 -10
- package/src/internal/{projection → Type}/compose.ts +14 -9
- package/src/internal/{schema → Type}/echo-schema.ts +74 -34
- package/src/internal/Type/index.ts +7 -0
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/Type/persistent-schema.ts +33 -0
- package/src/internal/common/README.md +102 -0
- package/src/internal/common/api/index.ts +15 -0
- package/src/internal/common/api/meta.ts +88 -0
- package/src/internal/{testing → common}/index.ts +2 -1
- 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/common/proxy/handler.test.ts +121 -0
- 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 +6 -3
- package/src/internal/{proxy → common/proxy}/schema.test.ts +31 -22
- 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/common/types/base.ts +43 -0
- package/src/internal/common/types/entity.ts +54 -0
- package/src/internal/common/types/index.ts +10 -0
- package/src/internal/common/types/meta.ts +67 -0
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/common/types/typename.ts +55 -0
- package/src/internal/common/types/version.ts +19 -0
- package/src/internal/index.ts +12 -17
- package/src/testing/api.test.ts +125 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +129 -0
- package/src/testing/test-schema.ts +240 -0
- package/src/testing/util.ts +85 -0
- package/dist/lib/browser/chunk-BIDAASFK.mjs +0 -3727
- package/dist/lib/browser/chunk-BIDAASFK.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs +0 -410
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs +0 -585
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -35
- package/dist/lib/browser/internal/index.mjs +0 -336
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/query/index.mjs +0 -13
- package/dist/lib/browser/testing/index.mjs +0 -267
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs +0 -3727
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs +0 -585
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs +0 -410
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -35
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/query/index.mjs +0 -13
- package/dist/lib/node-esm/testing/index.mjs +0 -267
- 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/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -131
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.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/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts +0 -3
- 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/object/accessors.d.ts +0 -37
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts +0 -6
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -33
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts +0 -14
- package/dist/types/src/internal/object/expando.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 +0 -16
- 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 -32
- 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/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.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/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts +0 -14
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts +0 -6
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-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/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts +0 -17
- package/dist/types/src/internal/query/query.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/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -7
- 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/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/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -381
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts +0 -10
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts +0 -3
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -2
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -248
- 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/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -228
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/errors.ts +0 -18
- package/src/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.test.ts +0 -98
- package/src/internal/ast/annotations.ts +0 -226
- package/src/internal/ast/entity-kind.ts +0 -15
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/json/index.ts +0 -5
- package/src/internal/object/accessors.ts +0 -153
- package/src/internal/object/deleted.ts +0 -19
- package/src/internal/object/entity.ts +0 -248
- package/src/internal/object/expando.ts +0 -21
- package/src/internal/object/index.ts +0 -19
- package/src/internal/object/json-serializer.test.ts +0 -99
- package/src/internal/object/meta.ts +0 -61
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typed-object.ts +0 -88
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/proxy/handler.test.ts +0 -163
- package/src/internal/proxy/reactive-object.ts +0 -108
- package/src/internal/proxy/typed-handler.test.ts +0 -102
- package/src/internal/proxy/typed-handler.ts +0 -228
- package/src/internal/proxy/typed-object.test.ts +0 -100
- package/src/internal/query/index.ts +0 -5
- package/src/internal/query/query.ts +0 -23
- package/src/internal/schema/index.ts +0 -10
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/types.ts +0 -144
- package/src/internal/testing/utils.ts +0 -54
- package/src/internal/types/index.ts +0 -6
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/index.ts +0 -6
- package/src/query/query.test.ts +0 -401
- package/src/query/query.ts +0 -789
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -108
- /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/{browser/query/index.mjs.map → neutral/Entity.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/Err.mjs.map} +0 -0
- /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Extension.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Feed.mjs.map} +0 -0
- /package/dist/types/src/internal/{ast → Annotation}/annotations.test.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 → JsonSchema}/effect-schema.test.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 → 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}/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/{projection → 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/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{json → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
|
@@ -8,11 +8,12 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { type ObjectId } from '@dxos/keys';
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
11
|
+
import type * as Type from '../../Type';
|
|
12
|
+
import { type SchemaMeta, SchemaMetaSymbol, type TypeAnnotation, getTypeAnnotation } from '../Annotation';
|
|
13
|
+
import { ChangeId } from '../common/proxy';
|
|
14
|
+
import { EntityKind, SchemaKindId } from '../common/types';
|
|
15
|
+
import { type JsonSchemaType, toEffectSchema, toJsonSchema } from '../JsonSchema';
|
|
16
|
+
import { type TypedObject, type TypedObjectPrototype, getSnapshot } from '../Obj';
|
|
16
17
|
import {
|
|
17
18
|
addFieldsToSchema,
|
|
18
19
|
removeFieldsFromSchema,
|
|
@@ -20,14 +21,14 @@ import {
|
|
|
20
21
|
updateFieldNameInSchema,
|
|
21
22
|
updateFieldsInSchema,
|
|
22
23
|
} from './manipulation';
|
|
23
|
-
import {
|
|
24
|
-
import { StoredSchema } from './stored-schema';
|
|
24
|
+
import { PersistentSchema } from './persistent-schema';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Base schema type.
|
|
28
28
|
*/
|
|
29
29
|
// TODO(burdon): Merge with ImmutableSchema.
|
|
30
30
|
export interface BaseSchema<A = any, I = any> extends TypedObject<A, I> {
|
|
31
|
+
// TODO(burdon): Different from mutable?
|
|
31
32
|
get readonly(): boolean;
|
|
32
33
|
// TODO(burdon): Change to external function.
|
|
33
34
|
get mutable(): EchoSchema<A, I>;
|
|
@@ -83,6 +84,10 @@ export class ImmutableSchema<A = any, I = any> implements BaseSchema<A, I> {
|
|
|
83
84
|
// TypedObject
|
|
84
85
|
//
|
|
85
86
|
|
|
87
|
+
get kind(): EntityKind {
|
|
88
|
+
return this._objectAnnotation.kind;
|
|
89
|
+
}
|
|
90
|
+
|
|
86
91
|
get typename(): string {
|
|
87
92
|
return this._objectAnnotation.typename;
|
|
88
93
|
}
|
|
@@ -124,8 +129,10 @@ const EchoSchemaConstructor = (): TypedObjectPrototype => {
|
|
|
124
129
|
*/
|
|
125
130
|
return class {
|
|
126
131
|
private static get _schema() {
|
|
127
|
-
// The field is DynamicEchoSchema in runtime, but is serialized as
|
|
128
|
-
return Schema.Union(
|
|
132
|
+
// The field is DynamicEchoSchema in runtime, but is serialized as PersisentSchema in automerge.
|
|
133
|
+
return Schema.Union(PersistentSchema, Schema.instanceOf(EchoSchema)).annotations(
|
|
134
|
+
PersistentSchema.ast.annotations,
|
|
135
|
+
);
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
static readonly [Schema.TypeId] = schemaVariance;
|
|
@@ -159,7 +166,7 @@ const schemaVariance = {
|
|
|
159
166
|
};
|
|
160
167
|
|
|
161
168
|
/**
|
|
162
|
-
* Represents a schema that is
|
|
169
|
+
* Represents a schema that is persisted in the ECHO database.
|
|
163
170
|
* Schema can me mutable or readonly (specified by the {@link EchoSchema.readonly} field).
|
|
164
171
|
*
|
|
165
172
|
* Schema that can be modified at runtime via the API.
|
|
@@ -170,20 +177,26 @@ const schemaVariance = {
|
|
|
170
177
|
*
|
|
171
178
|
* @example
|
|
172
179
|
* ```ts
|
|
173
|
-
* export class TableType extends Schema.Struct({...}).pipe(Type.
|
|
180
|
+
* export class TableType extends Schema.Struct({...}).pipe(Type.object({ typename: 'com.example.type.table', version: '0.1.0' })){
|
|
174
181
|
* title: Schema.String,
|
|
175
182
|
* schema: Schema.optional(ref(EchoSchema)),
|
|
176
183
|
* props: Schema.mutable(S.Array(TablePropSchema)),
|
|
177
184
|
* }) {}
|
|
178
185
|
* ```
|
|
179
186
|
*
|
|
180
|
-
* The ECHO API will translate any references to
|
|
187
|
+
* The ECHO API will translate any references to PersistentSchema objects to be resolved as EchoSchema objects.
|
|
181
188
|
*/
|
|
182
189
|
export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implements BaseSchema<A, I> {
|
|
183
190
|
private _schema: Schema.Schema.AnyNoContext | undefined;
|
|
184
191
|
private _isDirty = true;
|
|
185
192
|
|
|
186
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Schema kind key that marks this as an ECHO schema.
|
|
195
|
+
* Makes EchoSchema satisfy the Type.AnyObj type.
|
|
196
|
+
*/
|
|
197
|
+
readonly [SchemaKindId]: EntityKind.Object = EntityKind.Object;
|
|
198
|
+
|
|
199
|
+
constructor(private readonly _persistentSchema: PersistentSchema) {
|
|
187
200
|
super();
|
|
188
201
|
}
|
|
189
202
|
|
|
@@ -196,11 +209,11 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
196
209
|
}
|
|
197
210
|
|
|
198
211
|
public get Type() {
|
|
199
|
-
return this.
|
|
212
|
+
return this._persistentSchema as A;
|
|
200
213
|
}
|
|
201
214
|
|
|
202
215
|
public get Encoded() {
|
|
203
|
-
return this.
|
|
216
|
+
return this._persistentSchema as I;
|
|
204
217
|
}
|
|
205
218
|
|
|
206
219
|
public get Context() {
|
|
@@ -227,12 +240,17 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
227
240
|
// BaseSchema
|
|
228
241
|
//
|
|
229
242
|
|
|
243
|
+
public get kind(): EntityKind.Object {
|
|
244
|
+
// Dynamic schemas are always object schemas.
|
|
245
|
+
return EntityKind.Object;
|
|
246
|
+
}
|
|
247
|
+
|
|
230
248
|
public get typename(): string {
|
|
231
|
-
return this.
|
|
249
|
+
return this._persistentSchema.typename;
|
|
232
250
|
}
|
|
233
251
|
|
|
234
252
|
public get version(): string {
|
|
235
|
-
return this.
|
|
253
|
+
return this._persistentSchema.version;
|
|
236
254
|
}
|
|
237
255
|
|
|
238
256
|
public get readonly(): boolean {
|
|
@@ -247,10 +265,10 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
247
265
|
}
|
|
248
266
|
|
|
249
267
|
/**
|
|
250
|
-
*
|
|
268
|
+
* Returns the JSON schema for the schema.
|
|
251
269
|
*/
|
|
252
270
|
public get jsonSchema(): JsonSchemaType {
|
|
253
|
-
return this.
|
|
271
|
+
return this._persistentSchema.jsonSchema;
|
|
254
272
|
}
|
|
255
273
|
|
|
256
274
|
/**
|
|
@@ -269,25 +287,25 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
269
287
|
* Id of the ECHO object containing the schema.
|
|
270
288
|
*/
|
|
271
289
|
public get id(): ObjectId {
|
|
272
|
-
return this.
|
|
290
|
+
return this._persistentSchema.id;
|
|
273
291
|
}
|
|
274
292
|
|
|
275
293
|
/**
|
|
276
294
|
* Short name of the schema.
|
|
277
295
|
*/
|
|
278
296
|
public get name(): string | undefined {
|
|
279
|
-
return this.
|
|
297
|
+
return this._persistentSchema.name;
|
|
280
298
|
}
|
|
281
299
|
|
|
282
300
|
public get [SchemaMetaSymbol](): SchemaMeta {
|
|
283
|
-
return { id: this.id, typename: this.typename, version: this.
|
|
301
|
+
return { id: this.id, typename: this.typename, version: this._persistentSchema.version };
|
|
284
302
|
}
|
|
285
303
|
|
|
286
304
|
/**
|
|
287
|
-
* Reference to the underlying
|
|
305
|
+
* Reference to the underlying persistent schema object.
|
|
288
306
|
*/
|
|
289
|
-
public get
|
|
290
|
-
return this.
|
|
307
|
+
public get persistentSchema(): Type.PersistentType {
|
|
308
|
+
return this._persistentSchema as Type.PersistentType;
|
|
291
309
|
}
|
|
292
310
|
|
|
293
311
|
public getProperties(): SchemaAST.PropertySignature[] {
|
|
@@ -307,8 +325,10 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
307
325
|
*/
|
|
308
326
|
public updateTypename(typename: string): void {
|
|
309
327
|
const updated = setTypenameInSchema(this._getSchema(), typename);
|
|
310
|
-
this.
|
|
311
|
-
|
|
328
|
+
this._change((schema) => {
|
|
329
|
+
schema.typename = typename;
|
|
330
|
+
schema.jsonSchema = toJsonSchema(updated);
|
|
331
|
+
});
|
|
312
332
|
}
|
|
313
333
|
|
|
314
334
|
/**
|
|
@@ -316,7 +336,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
316
336
|
*/
|
|
317
337
|
public addFields(fields: Schema.Struct.Fields): void {
|
|
318
338
|
const extended = addFieldsToSchema(this._getSchema(), fields);
|
|
319
|
-
this.
|
|
339
|
+
this._change((schema) => {
|
|
340
|
+
schema.jsonSchema = toJsonSchema(extended);
|
|
341
|
+
});
|
|
320
342
|
}
|
|
321
343
|
|
|
322
344
|
/**
|
|
@@ -324,7 +346,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
324
346
|
*/
|
|
325
347
|
public updateFields(fields: Schema.Struct.Fields): void {
|
|
326
348
|
const updated = updateFieldsInSchema(this._getSchema(), fields);
|
|
327
|
-
this.
|
|
349
|
+
this._change((schema) => {
|
|
350
|
+
schema.jsonSchema = toJsonSchema(updated);
|
|
351
|
+
});
|
|
328
352
|
}
|
|
329
353
|
|
|
330
354
|
/**
|
|
@@ -332,7 +356,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
332
356
|
*/
|
|
333
357
|
public updateFieldPropertyName({ before, after }: { before: PropertyKey; after: PropertyKey }): void {
|
|
334
358
|
const renamed = updateFieldNameInSchema(this._getSchema(), { before, after });
|
|
335
|
-
this.
|
|
359
|
+
this._change((schema) => {
|
|
360
|
+
schema.jsonSchema = toJsonSchema(renamed);
|
|
361
|
+
});
|
|
336
362
|
}
|
|
337
363
|
|
|
338
364
|
/**
|
|
@@ -340,7 +366,21 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
340
366
|
*/
|
|
341
367
|
public removeFields(fieldNames: string[]): void {
|
|
342
368
|
const removed = removeFieldsFromSchema(this._getSchema(), fieldNames);
|
|
343
|
-
this.
|
|
369
|
+
this._change((schema) => {
|
|
370
|
+
schema.jsonSchema = toJsonSchema(removed);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Wrapper for Obj.change that handles the change context for the persistent schema.
|
|
376
|
+
*/
|
|
377
|
+
private _change(callback: (schema: PersistentSchema) => void): void {
|
|
378
|
+
const changeFn = (this._persistentSchema as any)[ChangeId];
|
|
379
|
+
if (changeFn) {
|
|
380
|
+
changeFn(callback);
|
|
381
|
+
} else {
|
|
382
|
+
callback(this._persistentSchema);
|
|
383
|
+
}
|
|
344
384
|
}
|
|
345
385
|
|
|
346
386
|
//
|
|
@@ -348,7 +388,7 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
348
388
|
//
|
|
349
389
|
|
|
350
390
|
/**
|
|
351
|
-
* Called by
|
|
391
|
+
* Called by DatabaseSchemaRegistry on update.
|
|
352
392
|
*/
|
|
353
393
|
_invalidate(): void {
|
|
354
394
|
this._isDirty = true;
|
|
@@ -359,12 +399,12 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
359
399
|
*/
|
|
360
400
|
_rebuild(): void {
|
|
361
401
|
if (this._isDirty || this._schema == null) {
|
|
362
|
-
this._schema = toEffectSchema(getSnapshot(this.
|
|
402
|
+
this._schema = toEffectSchema(getSnapshot(this._persistentSchema).jsonSchema);
|
|
363
403
|
this._isDirty = false;
|
|
364
404
|
}
|
|
365
405
|
}
|
|
366
406
|
|
|
367
|
-
|
|
407
|
+
_getSchema(): Schema.Schema.AnyNoContext {
|
|
368
408
|
this._rebuild();
|
|
369
409
|
return this._schema!;
|
|
370
410
|
}
|
|
@@ -8,7 +8,7 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { DXN } from '@dxos/keys';
|
|
10
10
|
|
|
11
|
-
import { type TypeAnnotation, TypeAnnotationId, TypeIdentifierAnnotationId } from '../
|
|
11
|
+
import { type TypeAnnotation, TypeAnnotationId, TypeIdentifierAnnotationId } from '../Annotation';
|
|
12
12
|
|
|
13
13
|
// TODO(ZaymonFC): Do this one at a time. This might be dangerous.
|
|
14
14
|
export const addFieldsToSchema = (
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { IconAnnotation } from '../Annotation';
|
|
8
|
+
import { LabelAnnotation, TypenameSchema, VersionSchema } from '../Annotation';
|
|
9
|
+
import { EchoObjectSchema } from '../Entity';
|
|
10
|
+
import { JsonSchemaType } from '../JsonSchema';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Persistent representation of a schema.
|
|
14
|
+
*/
|
|
15
|
+
// TODO(burdon): Move.
|
|
16
|
+
export const PersistentSchema = Schema.Struct({
|
|
17
|
+
name: Schema.optional(Schema.String),
|
|
18
|
+
typename: TypenameSchema,
|
|
19
|
+
version: VersionSchema,
|
|
20
|
+
jsonSchema: JsonSchemaType,
|
|
21
|
+
}).pipe(
|
|
22
|
+
EchoObjectSchema({
|
|
23
|
+
typename: 'org.dxos.type.schema',
|
|
24
|
+
version: '0.1.0',
|
|
25
|
+
}),
|
|
26
|
+
LabelAnnotation.set(['name']),
|
|
27
|
+
IconAnnotation.set({
|
|
28
|
+
icon: 'ph--database--regular',
|
|
29
|
+
hue: 'green',
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export interface PersistentSchema extends Schema.Schema.Type<typeof PersistentSchema> {}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
## Refactor
|
|
2
|
+
|
|
3
|
+
1. Remove access from outisde of @dxos/echo-db
|
|
4
|
+
|
|
5
|
+
- [x] completely restructure @dxos/echo src/internal
|
|
6
|
+
- [x] Remove import "." and ".."! (create lint rule).
|
|
7
|
+
- [x] Unify FOUR different nests of test schema.
|
|
8
|
+
- [x] Remove @deprecated from internal methods and mark @internal (e.g., getSchemaDXN).
|
|
9
|
+
- NOTE: Internal methods should not use the import \* from Obj/Type APIs.
|
|
10
|
+
- [x] import ObjectId => @dxos/keys
|
|
11
|
+
- [x] Entity.Any = Obj.Any | Relation.Any
|
|
12
|
+
- NOTE: Relation does not extend (in not polymorphic with) Obj.
|
|
13
|
+
- [x] import LabelAnnotation => Annotation.LabelAnnotation
|
|
14
|
+
- [x] import Expando => @dxos/schema (Expando.Expando)
|
|
15
|
+
- [x] live => Obj.make
|
|
16
|
+
- [x] Rename live => makeObject
|
|
17
|
+
- [x] Rename {EchoObject, EchoRelation} => {EchoObjecSchema, EchoRelationSchema}
|
|
18
|
+
- [x] Rename AnyProperties => AnyProperties
|
|
19
|
+
- [x] Created Entity.Any (=> AnyEchoObject).
|
|
20
|
+
- [x] TypeFormat => TypeFormat
|
|
21
|
+
- [x] JsonSchemaType defs
|
|
22
|
+
- [x] Fix database.add() input/output types and search for "Obj.Any = db.add" (also QueryResult types).
|
|
23
|
+
- [x] TODO(burdon): FIX!!!
|
|
24
|
+
- [x] Fix failing tests.
|
|
25
|
+
- [x] Reconcile types/version with entities/model/version
|
|
26
|
+
- [x] Expando moved to @dxos/schema
|
|
27
|
+
- [x] Narrow QueryResult and match Schema and Object generics.
|
|
28
|
+
|
|
29
|
+
2. Clean-up
|
|
30
|
+
|
|
31
|
+
- [x] QueryResult namespace
|
|
32
|
+
- [x] SchemaRegistry interface
|
|
33
|
+
- [x] Schema registry should return Type.AnyEntity instead of Schema.Schema.AnyNoContext.
|
|
34
|
+
- [x] Hypergraph interface
|
|
35
|
+
- [x] Obj.getDatabase
|
|
36
|
+
- [x] SpaceAction.AddObject target should be a db not a space.
|
|
37
|
+
- [x] Add Relation.MakeProps
|
|
38
|
+
- [x] Add Obj.Unknown and Relation.Unknown to match Entity.Unknown.
|
|
39
|
+
- [x] TODO(wittjosiah): Should be Type.obj<...> or equivalent.
|
|
40
|
+
- [x] TODO(wittjosiah): Find a simpler way to define this type.
|
|
41
|
+
- [x] Ref.Array.targets doesn't satisfy Obj.Any because it uses AnyEchoObject.
|
|
42
|
+
- [x] Remove echo-db/AnyLiveObject<T> => Obj.Obj<T>
|
|
43
|
+
- [x] Rename AnyEchoObject => AnyEntity
|
|
44
|
+
- [x] Remove WithId => AnyEntity
|
|
45
|
+
- [x] Remove WithMeta => AnyEntity
|
|
46
|
+
- [x] Obj.Any => Obj.Unknown
|
|
47
|
+
- [x] Relation.Any => Relation.Unknown
|
|
48
|
+
- [x] Ref.Any => Ref.Unknown
|
|
49
|
+
- [x] Obj.AnyProps => Obj.Any
|
|
50
|
+
- [x] Factor Expando out of @dxos/echo (moved to @dxos/schema)
|
|
51
|
+
- [x] Obj.instanceOf works with Expando (tested in @dxos/schema)
|
|
52
|
+
- [x] Obj.Snapshot should be same shape as Obj.Obj but with a different brand
|
|
53
|
+
- [x] Mutators should only work on object after it is made mutable
|
|
54
|
+
|
|
55
|
+
- [ ] Review usage of Obj.Any, see if it could be stricter
|
|
56
|
+
- [ ] Type.Obj should validate using the echo object brand
|
|
57
|
+
- [ ] Mutable could be a branded type to fix "NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`"
|
|
58
|
+
- [ ] space properties, queues, messagins preventing getSpace from being removed
|
|
59
|
+
- [ ] Schema registry should use Query.Query.
|
|
60
|
+
- [ ] Move EchoSchemaRegistry into hypergraph
|
|
61
|
+
- [ ] Narrow QueryResult and match Schema and Object generics.
|
|
62
|
+
- [ ] BaseSchema
|
|
63
|
+
- [ ] Directly import JSONPath, etc. from @dxos/effect.
|
|
64
|
+
- [ ] Promote parts of src/internal/ref to Ref.ts
|
|
65
|
+
- [ ] JsonPath, JsonProp, getValue, setValue => Json.Path?
|
|
66
|
+
- [ ] DISCUSS: Standradize $ suffix to disambuguate imports (GPT recommended).
|
|
67
|
+
|
|
68
|
+
3. Audit usage from @dxos/echo-db
|
|
69
|
+
|
|
70
|
+
- [ ] Ability to extract Struct from Type.Obj
|
|
71
|
+
- [ ] created/updated system props (const { created } = Obj.getTimestamps)?
|
|
72
|
+
- [ ] QueryFn, QueryOptions => Database
|
|
73
|
+
- [ ] Datatbase.query() options?
|
|
74
|
+
- [ ] Expando type is used as a fallback in many plance.
|
|
75
|
+
- [ ] Standardize '@automerge/automerge' imports (A vs. next).
|
|
76
|
+
|
|
77
|
+
## NOTES
|
|
78
|
+
|
|
79
|
+
- Marking types as @internal (even for unexported types) erases type information.
|
|
80
|
+
|
|
81
|
+
## 0.9.0
|
|
82
|
+
|
|
83
|
+
- [ ] Database, Queue, Space, Type, namespaces.
|
|
84
|
+
- [ ] Support class variant for types.
|
|
85
|
+
- [ ] Support defaults.
|
|
86
|
+
- [ ] Support effect Date, Timestamp formats.
|
|
87
|
+
- [ ] Metadata for created, updated timestamps.
|
|
88
|
+
- [ ] Effect team design review.
|
|
89
|
+
- [ ] @category annotations to group types in the API.
|
|
90
|
+
- [ ] TSdoc and LLM training for function generation.
|
|
91
|
+
- [ ] Rename TypeFormat => Primitive?
|
|
92
|
+
- [ ] Don't re-export effect?
|
|
93
|
+
|
|
94
|
+
## Issues
|
|
95
|
+
|
|
96
|
+
- [ ] Build error when changing from TypedObject using Ref$: Type 'Task' does not satisfy the constraint 'WithId' (see echo-schema/testing/schema.ts)
|
|
97
|
+
- [ ] Reconcile all schema variants (Base, Immutable, TypedObject, EchoObject, etc.)
|
|
98
|
+
- [ ] Consolidate getters (getType, getSchema, getTypename, getSchemaTypename, etc.)
|
|
99
|
+
- [ ] ReactiveObject should specify id property? Reconcile AnyProperties, ReactiveObject, HasId, WithId, etc.
|
|
100
|
+
- [ ] Can we us S.is(MyType) to detect objects with our types system? (Branding?)
|
|
101
|
+
- [ ] Type.Expando doesn't work with AtomQuery result type (have to use Obj.Any instead).
|
|
102
|
+
- [ ] Obj.Any doesn't work with Obj.change callback types (have to use `any` for the mutable parameter).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared API helpers for Obj and Relation modules.
|
|
7
|
+
* These implementations use generic Entity types.
|
|
8
|
+
* Obj and Relation modules re-export with strongly-typed signatures.
|
|
9
|
+
*
|
|
10
|
+
* TODO(wittjosiah): Could this become the new "internal" where we slowly refactor
|
|
11
|
+
* existing internal modules into here? This would provide a cleaner boundary
|
|
12
|
+
* and prevent external packages from using internals directly.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export * from './meta';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { ForeignKey } from '@dxos/echo-protocol';
|
|
6
|
+
import { assertArgument, invariant } from '@dxos/invariant';
|
|
7
|
+
import type { DeepReadonly } from '@dxos/util';
|
|
8
|
+
|
|
9
|
+
import { type Mutable } from '../proxy';
|
|
10
|
+
import { type AnyProperties, type ObjectMeta, getMeta as getMeta$ } from '../types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Deeply read-only version of ObjectMeta.
|
|
14
|
+
*/
|
|
15
|
+
export type ReadonlyMeta = DeepReadonly<ObjectMeta>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Mutable meta type received in meta mutation callbacks.
|
|
19
|
+
*/
|
|
20
|
+
export type Meta = Mutable<ObjectMeta>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get the metadata for an entity with validation.
|
|
24
|
+
* Returns mutable meta when passed a mutable entity (inside change callback).
|
|
25
|
+
* Returns read-only meta when passed a regular entity or snapshot.
|
|
26
|
+
*
|
|
27
|
+
* TODO(burdon): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
28
|
+
*/
|
|
29
|
+
export function getMetaChecked(entity: Mutable<AnyProperties>): Meta;
|
|
30
|
+
export function getMetaChecked(entity: AnyProperties): ReadonlyMeta;
|
|
31
|
+
export function getMetaChecked(entity: AnyProperties): Meta | ReadonlyMeta {
|
|
32
|
+
assertArgument(entity, 'entity', 'Should be an entity.');
|
|
33
|
+
const meta = getMeta$(entity);
|
|
34
|
+
invariant(meta != null, 'Invalid entity.');
|
|
35
|
+
return meta;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @returns Foreign keys for the entity from the specified source.
|
|
40
|
+
* Accepts both reactive entities and snapshots.
|
|
41
|
+
*/
|
|
42
|
+
export const getKeys = (entity: AnyProperties, source: string): ForeignKey[] => {
|
|
43
|
+
assertArgument(entity, 'entity', 'Should be an entity.');
|
|
44
|
+
const meta = getMetaChecked(entity);
|
|
45
|
+
invariant(meta != null, 'Invalid entity.');
|
|
46
|
+
return meta.keys.filter((key) => key.source === source);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Delete all keys from the entity for the specified source.
|
|
51
|
+
* Must be called within an Obj.change or Relation.change callback.
|
|
52
|
+
*/
|
|
53
|
+
export const deleteKeys = (entity: Mutable<AnyProperties>, source: string) => {
|
|
54
|
+
const meta = getMetaChecked(entity);
|
|
55
|
+
for (let i = 0; i < meta.keys.length; i++) {
|
|
56
|
+
if (meta.keys[i].source === source) {
|
|
57
|
+
meta.keys.splice(i, 1);
|
|
58
|
+
i--;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Add a tag to the entity.
|
|
65
|
+
* Must be called within an Obj.change or Relation.change callback.
|
|
66
|
+
*/
|
|
67
|
+
export const addTag = (entity: Mutable<AnyProperties>, tag: string) => {
|
|
68
|
+
const meta = getMetaChecked(entity);
|
|
69
|
+
meta.tags ??= [];
|
|
70
|
+
meta.tags.push(tag);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Remove a tag from the entity.
|
|
75
|
+
* Must be called within an Obj.change or Relation.change callback.
|
|
76
|
+
*/
|
|
77
|
+
export const removeTag = (entity: Mutable<AnyProperties>, tag: string) => {
|
|
78
|
+
const meta = getMetaChecked(entity);
|
|
79
|
+
if (!meta.tags) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
for (let i = 0; i < meta.tags.length; i++) {
|
|
83
|
+
if (meta.tags[i] === tag) {
|
|
84
|
+
meta.tags.splice(i, 1);
|
|
85
|
+
i--;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { batchEvents } from './event-batch';
|
|
6
|
+
import { EventId } from './symbols';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generic change context tracking.
|
|
10
|
+
* Only one object can be in a change context at a time (synchronous changes).
|
|
11
|
+
*
|
|
12
|
+
* This module provides a unified change context mechanism used by both:
|
|
13
|
+
* - TypedReactiveHandler (for non-database objects, using target as key)
|
|
14
|
+
* - EchoReactiveHandler (for database objects, using ObjectCore as key)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The object currently in a change context.
|
|
19
|
+
* Can be a target object (for typed reactive) or ObjectCore (for database objects).
|
|
20
|
+
*/
|
|
21
|
+
let currentChangeContext: object | null = null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The primary object that has pending notifications, if any.
|
|
25
|
+
* This uses the contextKey (target or ObjectCore).
|
|
26
|
+
*/
|
|
27
|
+
let pendingNotificationKey: object | null = null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Additional objects (owner chain) that need notifications.
|
|
31
|
+
* These are separate from the primary notification because they use EventId directly.
|
|
32
|
+
*/
|
|
33
|
+
const pendingOwnerNotifications = new Set<object>();
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Enter a change context for the given key.
|
|
37
|
+
* While in a change context, mutations are allowed on the associated object.
|
|
38
|
+
* Nested Obj.change calls are not supported.
|
|
39
|
+
*
|
|
40
|
+
* @param key - The key to enter the change context for (target object or ObjectCore).
|
|
41
|
+
* @returns A cleanup function that exits the change context.
|
|
42
|
+
*/
|
|
43
|
+
export const enterChangeContext = (key: object): (() => void) => {
|
|
44
|
+
currentChangeContext = key;
|
|
45
|
+
return () => {
|
|
46
|
+
currentChangeContext = null;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Check if the given key is currently in a change context.
|
|
52
|
+
*
|
|
53
|
+
* @param key - The key to check (target object or ObjectCore).
|
|
54
|
+
* @returns True if the key is in a change context, false otherwise.
|
|
55
|
+
*/
|
|
56
|
+
export const isInChangeContext = (key: object): boolean => {
|
|
57
|
+
return currentChangeContext === key;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Queue a notification for the given key to be fired when the change context exits.
|
|
62
|
+
*
|
|
63
|
+
* @param key - The key to queue a notification for.
|
|
64
|
+
*/
|
|
65
|
+
export const queueNotification = (key: object): void => {
|
|
66
|
+
if (currentChangeContext === key) {
|
|
67
|
+
pendingNotificationKey = key;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Queue an owner notification. Owner notifications are for objects in the ownership
|
|
73
|
+
* chain that should be notified when a nested object changes.
|
|
74
|
+
* These objects have EventId and emit directly.
|
|
75
|
+
* Skip if the target is already the current change context (to avoid duplicate notifications).
|
|
76
|
+
*
|
|
77
|
+
* @param target - The owner target that has EventId.
|
|
78
|
+
*/
|
|
79
|
+
export const queueOwnerNotification = (target: object): void => {
|
|
80
|
+
// Skip if this is the object already being changed (primary notification handles it).
|
|
81
|
+
if (currentChangeContext !== null && target !== currentChangeContext) {
|
|
82
|
+
pendingOwnerNotifications.add(target);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Check if there are any pending notifications for the given key.
|
|
88
|
+
*
|
|
89
|
+
* @param key - The key to check.
|
|
90
|
+
* @returns True if there are pending notifications, false otherwise.
|
|
91
|
+
*/
|
|
92
|
+
export const hasPendingNotifications = (key: object): boolean => {
|
|
93
|
+
return pendingNotificationKey === key;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Clear any pending notifications for the given key.
|
|
98
|
+
*
|
|
99
|
+
* @param key - The key to clear notifications for.
|
|
100
|
+
*/
|
|
101
|
+
export const clearPendingNotifications = (key: object): void => {
|
|
102
|
+
if (pendingNotificationKey === key) {
|
|
103
|
+
pendingNotificationKey = null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Execute a callback within a change context.
|
|
109
|
+
* This is the shared implementation used by both TypedReactiveHandler and EchoReactiveHandler.
|
|
110
|
+
*
|
|
111
|
+
* @param contextKey - The key for the change context (target for typed, ObjectCore for db).
|
|
112
|
+
* @param eventTarget - The object that has the EventId for notifications.
|
|
113
|
+
* @param proxy - The proxy object to pass to the callback.
|
|
114
|
+
* @param callback - The callback to execute with mutations allowed.
|
|
115
|
+
*/
|
|
116
|
+
export const executeChange = (
|
|
117
|
+
contextKey: object,
|
|
118
|
+
eventTarget: object,
|
|
119
|
+
proxy: any,
|
|
120
|
+
callback: (proxy: any) => void,
|
|
121
|
+
): void => {
|
|
122
|
+
const exitContext = enterChangeContext(contextKey);
|
|
123
|
+
try {
|
|
124
|
+
batchEvents(() => callback(proxy));
|
|
125
|
+
} finally {
|
|
126
|
+
exitContext();
|
|
127
|
+
// Fire primary notification.
|
|
128
|
+
if (hasPendingNotifications(contextKey)) {
|
|
129
|
+
clearPendingNotifications(contextKey);
|
|
130
|
+
(eventTarget as any)[EventId]?.emit();
|
|
131
|
+
}
|
|
132
|
+
// Fire owner chain notifications.
|
|
133
|
+
for (const ownerTarget of pendingOwnerNotifications) {
|
|
134
|
+
(ownerTarget as any)[EventId]?.emit();
|
|
135
|
+
}
|
|
136
|
+
pendingOwnerNotifications.clear();
|
|
137
|
+
}
|
|
138
|
+
};
|