@dxos/echo 0.8.4-main.406dc2a → 0.8.4-main.40e3dcdf1b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/lib/neutral/Annotation.mjs +37 -0
- package/dist/lib/neutral/Database.mjs +45 -0
- package/dist/lib/neutral/Entity.mjs +59 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Feed.mjs +46 -0
- package/dist/lib/neutral/Filter.mjs +64 -0
- package/dist/lib/neutral/Format.mjs +66 -0
- package/dist/lib/neutral/Format.mjs.map +7 -0
- package/dist/lib/neutral/JsonSchema.mjs +19 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +12 -0
- package/dist/lib/neutral/Key.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +110 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +12 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +35 -0
- package/dist/lib/neutral/Query.mjs.map +7 -0
- package/dist/lib/neutral/QueryResult.mjs +2 -0
- package/dist/lib/neutral/QueryResult.mjs.map +7 -0
- package/dist/lib/neutral/Ref.mjs +24 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +93 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/SchemaRegistry.mjs +2 -0
- package/dist/lib/neutral/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +28 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +37 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs +396 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-724GQYEN.mjs +56 -0
- package/dist/lib/neutral/chunk-724GQYEN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs +21 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs +402 -0
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs +7 -0
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs +787 -0
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CIRHIEMW.mjs +298 -0
- package/dist/lib/neutral/chunk-CIRHIEMW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DYDJBZEG.mjs +102 -0
- package/dist/lib/neutral/chunk-DYDJBZEG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs +45 -0
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FZO7LQO7.mjs +73 -0
- package/dist/lib/neutral/chunk-FZO7LQO7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-KTAWP7GI.mjs +283 -0
- package/dist/lib/neutral/chunk-KTAWP7GI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NEGC54NE.mjs +130 -0
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NQRLRYJM.mjs +313 -0
- package/dist/lib/neutral/chunk-NQRLRYJM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs +299 -0
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OENWMTE6.mjs +45 -0
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RMLF7JOZ.mjs +97 -0
- package/dist/lib/neutral/chunk-RMLF7JOZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs +355 -0
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TQQZLKB7.mjs +2712 -0
- package/dist/lib/neutral/chunk-TQQZLKB7.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-UFDK26FO.mjs +121 -0
- package/dist/lib/neutral/chunk-UFDK26FO.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs +42 -0
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs +27 -0
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VA2F47ZC.mjs +152 -0
- package/dist/lib/neutral/chunk-VA2F47ZC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs +67 -0
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs +34 -0
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +97 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/internal/index.mjs +286 -148
- 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 +373 -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 +189 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Dataset.d.ts +18 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +168 -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/Feed.d.ts +165 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +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/Obj.d.ts +419 -101
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +202 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +61 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +288 -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 +18 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- 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 +19 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +230 -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 +44 -0
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.d.ts +7 -0
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts +6 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts +25 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +4 -4
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +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 +9 -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 +106 -65
- package/src/Annotation.ts +48 -0
- package/src/Collection.ts +32 -0
- package/src/Database.ts +317 -0
- package/src/Dataset.ts +26 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +237 -0
- package/src/Err.ts +40 -0
- package/src/Feed.ts +257 -0
- package/src/Filter.ts +391 -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/Obj.test.ts +447 -0
- package/src/Obj.ts +587 -268
- package/src/Order.ts +46 -0
- package/src/Query.test.ts +632 -0
- package/src/Query.ts +522 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +79 -9
- package/src/Relation.test.ts +88 -0
- package/src/Relation.ts +443 -58
- package/src/SchemaRegistry.ts +106 -0
- package/src/{query/tag.ts → Tag.ts} +13 -9
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +167 -153
- package/src/View.ts +102 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +20 -6
- package/src/internal/{ast → Annotation}/annotations.test.ts +20 -22
- package/src/internal/Annotation/annotations.ts +571 -0
- package/src/internal/Annotation/index.ts +7 -0
- package/src/internal/Annotation/sorting.ts +52 -0
- package/src/internal/Annotation/util.ts +85 -0
- package/src/internal/Entity/api.ts +31 -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 +58 -0
- package/src/internal/Entity/relation.ts +154 -0
- package/src/internal/Entity/util.ts +33 -0
- package/src/internal/Entity/version.ts +97 -0
- package/src/internal/{formats → Format}/date.test.ts +1 -1
- package/src/internal/{formats → Format}/date.ts +5 -5
- package/src/internal/{formats → Format}/format.test.ts +6 -6
- 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 +98 -94
- package/src/internal/{json → JsonSchema}/json-schema.ts +30 -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} +31 -33
- package/src/internal/{object/create.ts → Obj/create-object.ts} +36 -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 +121 -0
- package/src/internal/{object → Obj}/json-serializer.ts +99 -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/{ref → Ref}/ref-array.ts +4 -4
- package/src/internal/{ref → Ref}/ref.test.ts +11 -10
- package/src/internal/{ref → Ref}/ref.ts +108 -57
- package/src/internal/{projection → Type}/compose.test.ts +8 -9
- package/src/internal/{projection → Type}/compose.ts +14 -9
- package/src/internal/{schema → Type}/echo-schema.ts +74 -33
- 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 +123 -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 +106 -0
- package/src/internal/common/proxy/ownership.ts +253 -0
- package/src/internal/common/proxy/proxy-types.ts +23 -0
- package/src/internal/common/proxy/proxy-utils.ts +150 -0
- package/src/internal/common/proxy/reactive-array.ts +71 -0
- package/src/internal/common/proxy/reactive.ts +69 -0
- package/src/internal/{object → common/proxy}/schema-validator.ts +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 +314 -0
- package/src/internal/common/proxy/typed-handler.ts +449 -0
- package/src/internal/common/proxy/typed-object.test.ts +116 -0
- package/src/internal/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 +68 -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 +11 -17
- package/src/testing/api.test.ts +126 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +240 -0
- package/src/testing/util.ts +85 -0
- package/dist/lib/browser/chunk-HKFCK2GL.mjs +0 -175
- package/dist/lib/browser/chunk-HKFCK2GL.mjs.map +0 -7
- package/dist/lib/browser/chunk-MAAYELT7.mjs +0 -830
- package/dist/lib/browser/chunk-MAAYELT7.mjs.map +0 -7
- package/dist/lib/browser/chunk-MB6MMNFP.mjs +0 -3857
- package/dist/lib/browser/chunk-MB6MMNFP.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -35
- package/dist/lib/browser/internal/index.mjs +0 -332
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/query/index.mjs +0 -15
- package/dist/lib/browser/testing/index.mjs +0 -298
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5NWDGIBT.mjs +0 -830
- package/dist/lib/node-esm/chunk-5NWDGIBT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AUAH4E2J.mjs +0 -175
- package/dist/lib/node-esm/chunk-AUAH4E2J.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BQRA4VLX.mjs +0 -3857
- package/dist/lib/node-esm/chunk-BQRA4VLX.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 -15
- package/dist/lib/node-esm/testing/index.mjs +0 -298
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/errors.d.ts +0 -72
- 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 -125
- 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 -455
- 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 -3
- 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/query/tag.d.ts +0 -17
- package/dist/types/src/query/tag.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 -113
- 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.ts +0 -219
- 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 -211
- 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 -91
- /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/Feed.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Filter.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,10 +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 { type JsonSchemaType } from '../
|
|
14
|
-
import { type TypedObject, type TypedObjectPrototype } from '../
|
|
11
|
+
import type * as Type from '../../Type';
|
|
12
|
+
import { type SchemaMeta, SchemaMetaSymbol, type TypeAnnotation, getTypeAnnotation } from '../Annotation';
|
|
13
|
+
import { type JsonSchemaType, toEffectSchema, toJsonSchema } from '../JsonSchema';
|
|
14
|
+
import { type TypedObject, type TypedObjectPrototype, getSnapshot } from '../Obj';
|
|
15
|
+
import { ChangeId } from '../common/proxy';
|
|
16
|
+
import { EntityKind, SchemaKindId } from '../common/types';
|
|
15
17
|
|
|
16
18
|
import {
|
|
17
19
|
addFieldsToSchema,
|
|
@@ -20,14 +22,14 @@ import {
|
|
|
20
22
|
updateFieldNameInSchema,
|
|
21
23
|
updateFieldsInSchema,
|
|
22
24
|
} from './manipulation';
|
|
23
|
-
import {
|
|
24
|
-
import { StoredSchema } from './stored-schema';
|
|
25
|
+
import { PersistentSchema } from './persistent-schema';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Base schema type.
|
|
28
29
|
*/
|
|
29
30
|
// TODO(burdon): Merge with ImmutableSchema.
|
|
30
31
|
export interface BaseSchema<A = any, I = any> extends TypedObject<A, I> {
|
|
32
|
+
// TODO(burdon): Different from mutable?
|
|
31
33
|
get readonly(): boolean;
|
|
32
34
|
// TODO(burdon): Change to external function.
|
|
33
35
|
get mutable(): EchoSchema<A, I>;
|
|
@@ -83,6 +85,10 @@ export class ImmutableSchema<A = any, I = any> implements BaseSchema<A, I> {
|
|
|
83
85
|
// TypedObject
|
|
84
86
|
//
|
|
85
87
|
|
|
88
|
+
get kind(): EntityKind {
|
|
89
|
+
return this._objectAnnotation.kind;
|
|
90
|
+
}
|
|
91
|
+
|
|
86
92
|
get typename(): string {
|
|
87
93
|
return this._objectAnnotation.typename;
|
|
88
94
|
}
|
|
@@ -124,8 +130,10 @@ const EchoSchemaConstructor = (): TypedObjectPrototype => {
|
|
|
124
130
|
*/
|
|
125
131
|
return class {
|
|
126
132
|
private static get _schema() {
|
|
127
|
-
// The field is DynamicEchoSchema in runtime, but is serialized as
|
|
128
|
-
return Schema.Union(
|
|
133
|
+
// The field is DynamicEchoSchema in runtime, but is serialized as PersisentSchema in automerge.
|
|
134
|
+
return Schema.Union(PersistentSchema, Schema.instanceOf(EchoSchema)).annotations(
|
|
135
|
+
PersistentSchema.ast.annotations,
|
|
136
|
+
);
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
static readonly [Schema.TypeId] = schemaVariance;
|
|
@@ -159,7 +167,7 @@ const schemaVariance = {
|
|
|
159
167
|
};
|
|
160
168
|
|
|
161
169
|
/**
|
|
162
|
-
* Represents a schema that is
|
|
170
|
+
* Represents a schema that is persisted in the ECHO database.
|
|
163
171
|
* Schema can me mutable or readonly (specified by the {@link EchoSchema.readonly} field).
|
|
164
172
|
*
|
|
165
173
|
* Schema that can be modified at runtime via the API.
|
|
@@ -170,20 +178,26 @@ const schemaVariance = {
|
|
|
170
178
|
*
|
|
171
179
|
* @example
|
|
172
180
|
* ```ts
|
|
173
|
-
* export class TableType extends Schema.Struct({...}).pipe(Type.
|
|
181
|
+
* export class TableType extends Schema.Struct({...}).pipe(Type.object({ typename: 'com.example.type.table', version: '0.1.0' })){
|
|
174
182
|
* title: Schema.String,
|
|
175
183
|
* schema: Schema.optional(ref(EchoSchema)),
|
|
176
184
|
* props: Schema.mutable(S.Array(TablePropSchema)),
|
|
177
185
|
* }) {}
|
|
178
186
|
* ```
|
|
179
187
|
*
|
|
180
|
-
* The ECHO API will translate any references to
|
|
188
|
+
* The ECHO API will translate any references to PersistentSchema objects to be resolved as EchoSchema objects.
|
|
181
189
|
*/
|
|
182
190
|
export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implements BaseSchema<A, I> {
|
|
183
191
|
private _schema: Schema.Schema.AnyNoContext | undefined;
|
|
184
192
|
private _isDirty = true;
|
|
185
193
|
|
|
186
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Schema kind key that marks this as an ECHO schema.
|
|
196
|
+
* Makes EchoSchema satisfy the Type.AnyObj type.
|
|
197
|
+
*/
|
|
198
|
+
readonly [SchemaKindId]: EntityKind.Object = EntityKind.Object;
|
|
199
|
+
|
|
200
|
+
constructor(private readonly _persistentSchema: PersistentSchema) {
|
|
187
201
|
super();
|
|
188
202
|
}
|
|
189
203
|
|
|
@@ -196,11 +210,11 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
196
210
|
}
|
|
197
211
|
|
|
198
212
|
public get Type() {
|
|
199
|
-
return this.
|
|
213
|
+
return this._persistentSchema as A;
|
|
200
214
|
}
|
|
201
215
|
|
|
202
216
|
public get Encoded() {
|
|
203
|
-
return this.
|
|
217
|
+
return this._persistentSchema as I;
|
|
204
218
|
}
|
|
205
219
|
|
|
206
220
|
public get Context() {
|
|
@@ -227,12 +241,17 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
227
241
|
// BaseSchema
|
|
228
242
|
//
|
|
229
243
|
|
|
244
|
+
public get kind(): EntityKind.Object {
|
|
245
|
+
// Dynamic schemas are always object schemas.
|
|
246
|
+
return EntityKind.Object;
|
|
247
|
+
}
|
|
248
|
+
|
|
230
249
|
public get typename(): string {
|
|
231
|
-
return this.
|
|
250
|
+
return this._persistentSchema.typename;
|
|
232
251
|
}
|
|
233
252
|
|
|
234
253
|
public get version(): string {
|
|
235
|
-
return this.
|
|
254
|
+
return this._persistentSchema.version;
|
|
236
255
|
}
|
|
237
256
|
|
|
238
257
|
public get readonly(): boolean {
|
|
@@ -247,10 +266,10 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
247
266
|
}
|
|
248
267
|
|
|
249
268
|
/**
|
|
250
|
-
*
|
|
269
|
+
* Returns the JSON schema for the schema.
|
|
251
270
|
*/
|
|
252
271
|
public get jsonSchema(): JsonSchemaType {
|
|
253
|
-
return this.
|
|
272
|
+
return this._persistentSchema.jsonSchema;
|
|
254
273
|
}
|
|
255
274
|
|
|
256
275
|
/**
|
|
@@ -269,25 +288,25 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
269
288
|
* Id of the ECHO object containing the schema.
|
|
270
289
|
*/
|
|
271
290
|
public get id(): ObjectId {
|
|
272
|
-
return this.
|
|
291
|
+
return this._persistentSchema.id;
|
|
273
292
|
}
|
|
274
293
|
|
|
275
294
|
/**
|
|
276
295
|
* Short name of the schema.
|
|
277
296
|
*/
|
|
278
297
|
public get name(): string | undefined {
|
|
279
|
-
return this.
|
|
298
|
+
return this._persistentSchema.name;
|
|
280
299
|
}
|
|
281
300
|
|
|
282
301
|
public get [SchemaMetaSymbol](): SchemaMeta {
|
|
283
|
-
return { id: this.id, typename: this.typename, version: this.
|
|
302
|
+
return { id: this.id, typename: this.typename, version: this._persistentSchema.version };
|
|
284
303
|
}
|
|
285
304
|
|
|
286
305
|
/**
|
|
287
|
-
* Reference to the underlying
|
|
306
|
+
* Reference to the underlying persistent schema object.
|
|
288
307
|
*/
|
|
289
|
-
public get
|
|
290
|
-
return this.
|
|
308
|
+
public get persistentSchema(): Type.PersistentType {
|
|
309
|
+
return this._persistentSchema as Type.PersistentType;
|
|
291
310
|
}
|
|
292
311
|
|
|
293
312
|
public getProperties(): SchemaAST.PropertySignature[] {
|
|
@@ -307,8 +326,10 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
307
326
|
*/
|
|
308
327
|
public updateTypename(typename: string): void {
|
|
309
328
|
const updated = setTypenameInSchema(this._getSchema(), typename);
|
|
310
|
-
this.
|
|
311
|
-
|
|
329
|
+
this._change((schema) => {
|
|
330
|
+
schema.typename = typename;
|
|
331
|
+
schema.jsonSchema = toJsonSchema(updated);
|
|
332
|
+
});
|
|
312
333
|
}
|
|
313
334
|
|
|
314
335
|
/**
|
|
@@ -316,7 +337,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
316
337
|
*/
|
|
317
338
|
public addFields(fields: Schema.Struct.Fields): void {
|
|
318
339
|
const extended = addFieldsToSchema(this._getSchema(), fields);
|
|
319
|
-
this.
|
|
340
|
+
this._change((schema) => {
|
|
341
|
+
schema.jsonSchema = toJsonSchema(extended);
|
|
342
|
+
});
|
|
320
343
|
}
|
|
321
344
|
|
|
322
345
|
/**
|
|
@@ -324,7 +347,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
324
347
|
*/
|
|
325
348
|
public updateFields(fields: Schema.Struct.Fields): void {
|
|
326
349
|
const updated = updateFieldsInSchema(this._getSchema(), fields);
|
|
327
|
-
this.
|
|
350
|
+
this._change((schema) => {
|
|
351
|
+
schema.jsonSchema = toJsonSchema(updated);
|
|
352
|
+
});
|
|
328
353
|
}
|
|
329
354
|
|
|
330
355
|
/**
|
|
@@ -332,7 +357,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
332
357
|
*/
|
|
333
358
|
public updateFieldPropertyName({ before, after }: { before: PropertyKey; after: PropertyKey }): void {
|
|
334
359
|
const renamed = updateFieldNameInSchema(this._getSchema(), { before, after });
|
|
335
|
-
this.
|
|
360
|
+
this._change((schema) => {
|
|
361
|
+
schema.jsonSchema = toJsonSchema(renamed);
|
|
362
|
+
});
|
|
336
363
|
}
|
|
337
364
|
|
|
338
365
|
/**
|
|
@@ -340,7 +367,21 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
340
367
|
*/
|
|
341
368
|
public removeFields(fieldNames: string[]): void {
|
|
342
369
|
const removed = removeFieldsFromSchema(this._getSchema(), fieldNames);
|
|
343
|
-
this.
|
|
370
|
+
this._change((schema) => {
|
|
371
|
+
schema.jsonSchema = toJsonSchema(removed);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Wrapper for Obj.change that handles the change context for the persistent schema.
|
|
377
|
+
*/
|
|
378
|
+
private _change(callback: (schema: PersistentSchema) => void): void {
|
|
379
|
+
const changeFn = (this._persistentSchema as any)[ChangeId];
|
|
380
|
+
if (changeFn) {
|
|
381
|
+
changeFn(callback);
|
|
382
|
+
} else {
|
|
383
|
+
callback(this._persistentSchema);
|
|
384
|
+
}
|
|
344
385
|
}
|
|
345
386
|
|
|
346
387
|
//
|
|
@@ -348,7 +389,7 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
348
389
|
//
|
|
349
390
|
|
|
350
391
|
/**
|
|
351
|
-
* Called by
|
|
392
|
+
* Called by DatabaseSchemaRegistry on update.
|
|
352
393
|
*/
|
|
353
394
|
_invalidate(): void {
|
|
354
395
|
this._isDirty = true;
|
|
@@ -359,12 +400,12 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
359
400
|
*/
|
|
360
401
|
_rebuild(): void {
|
|
361
402
|
if (this._isDirty || this._schema == null) {
|
|
362
|
-
this._schema = toEffectSchema(getSnapshot(this.
|
|
403
|
+
this._schema = toEffectSchema(getSnapshot(this._persistentSchema).jsonSchema);
|
|
363
404
|
this._isDirty = false;
|
|
364
405
|
}
|
|
365
406
|
}
|
|
366
407
|
|
|
367
|
-
|
|
408
|
+
_getSchema(): Schema.Schema.AnyNoContext {
|
|
368
409
|
this._rebuild();
|
|
369
410
|
return this._schema!;
|
|
370
411
|
}
|
|
@@ -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--brackets-curly--regular',
|
|
29
|
+
hue: 'blue',
|
|
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
|
+
};
|