@dxos/echo 0.8.4-main.bc674ce → 0.8.4-main.bd9b33e6c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/lib/neutral/Annotation.mjs +8 -3
- package/dist/lib/neutral/Database.mjs +34 -6
- package/dist/lib/neutral/Entity.mjs +18 -10
- package/dist/lib/neutral/Err.mjs +3 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +45 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +17 -10
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Obj.mjs +35 -15
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +19 -9
- package/dist/lib/neutral/Ref.mjs +9 -7
- package/dist/lib/neutral/Relation.mjs +20 -11
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +13 -10
- package/dist/lib/neutral/Type.mjs +13 -23
- package/dist/lib/neutral/{chunk-HMOXCO27.mjs → chunk-35O3JYTV.mjs} +8 -3
- package/dist/lib/neutral/chunk-35O3JYTV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4BT7QVIT.mjs +34 -0
- package/dist/lib/neutral/chunk-4BT7QVIT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4O4AV6CL.mjs +787 -0
- package/dist/lib/neutral/chunk-4O4AV6CL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-62DWJ6CE.mjs → chunk-B5OXLWZL.mjs} +14 -14
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NWUO5FKZ.mjs → chunk-B7HTUIZA.mjs} +8 -2
- package/dist/lib/neutral/chunk-B7HTUIZA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-BNCCGLJN.mjs} +1 -1
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs.map → chunk-BNCCGLJN.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-3ZEAZF7T.mjs → chunk-EIX4KLES.mjs} +8 -4
- package/dist/lib/neutral/chunk-EIX4KLES.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FLSFS6UB.mjs +117 -0
- package/dist/lib/neutral/chunk-FLSFS6UB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VR4A4WGG.mjs → chunk-FXQ52LDX.mjs} +72 -23
- package/dist/lib/neutral/chunk-FXQ52LDX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4TT624YA.mjs → chunk-FZO7LQO7.mjs} +2 -2
- package/dist/lib/neutral/{chunk-4TT624YA.mjs.map → chunk-FZO7LQO7.mjs.map} +1 -1
- package/dist/lib/neutral/chunk-HIMJ3MXL.mjs +283 -0
- package/dist/lib/neutral/chunk-HIMJ3MXL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VB5HVDCA.mjs → chunk-HITCYIP2.mjs} +47 -5
- package/dist/lib/neutral/chunk-HITCYIP2.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SU2LVM7J.mjs → chunk-JJTRVYRD.mjs} +1596 -2730
- package/dist/lib/neutral/chunk-JJTRVYRD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6QPSGMEF.mjs → chunk-JX5K6AY3.mjs} +32 -8
- package/dist/lib/neutral/chunk-JX5K6AY3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-IP2GHXWA.mjs → chunk-PRQVBGFG.mjs} +5 -5
- package/dist/lib/neutral/chunk-PRQVBGFG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RUYH5REG.mjs +130 -0
- package/dist/lib/neutral/chunk-RUYH5REG.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-2MTHJ5UW.mjs → chunk-T74ABBRN.mjs} +134 -24
- package/dist/lib/neutral/chunk-T74ABBRN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-XMIDBDE6.mjs → chunk-TJRQTGXR.mjs} +11 -56
- package/dist/lib/neutral/chunk-TJRQTGXR.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RPB6V4BE.mjs → chunk-UBEZSGXY.mjs} +14 -1
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ROKO4RKJ.mjs → chunk-UI6MWK5W.mjs} +2 -2
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VF2IHN6I.mjs +396 -0
- package/dist/lib/neutral/chunk-VF2IHN6I.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YQYMWZAD.mjs → chunk-WYOKA6AE.mjs} +4 -4
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-CUDIBUM4.mjs → chunk-XEBKJROJ.mjs} +104 -25
- package/dist/lib/neutral/chunk-XEBKJROJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs +50 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZZEIMPNC.mjs +159 -0
- package/dist/lib/neutral/chunk-ZZEIMPNC.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +42 -25
- package/dist/lib/neutral/internal/index.mjs +52 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +42 -34
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +23 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +79 -84
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +19 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +41 -15
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +43 -0
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +163 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +13 -1
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +3 -3
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +8 -3
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/JsonSchema.d.ts +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +158 -43
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +101 -14
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +58 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +75 -28
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +4 -4
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +4 -3
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +51 -180
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +68 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +69 -8
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Annotation}/sorting.d.ts +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +13 -1
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api/entity.d.ts → Entity/api.d.ts} +2 -2
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/entity.d.ts +3 -3
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/model.d.ts +4 -26
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +2 -2
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/relation.d.ts +3 -30
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Entity}/version.d.ts +1 -1
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +19 -19
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +2 -2
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/deleted.d.ts +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +12 -5
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/typed-object.d.ts +4 -4
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +16 -3
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/compose.d.ts +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/echo-schema.d.ts +8 -7
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/persistent-schema.d.ts +2 -2
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/{api → common/api}/index.d.ts +0 -4
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +2 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/base.d.ts +1 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/entity.d.ts +2 -2
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/index.d.ts +1 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/meta.d.ts +2 -1
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +54 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/typename.d.ts +8 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +2 -2
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +8 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +19 -18
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/src/Annotation.ts +31 -1
- package/src/Collection.ts +37 -0
- package/src/Database.ts +154 -173
- package/src/Dataset.ts +26 -0
- package/src/Entity.ts +73 -54
- package/src/Err.ts +22 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +267 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +47 -4
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +9 -4
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +69 -8
- package/src/Obj.ts +285 -140
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +190 -15
- package/src/Query.ts +249 -23
- package/src/Ref.ts +64 -11
- package/src/Relation.test.ts +8 -2
- package/src/Relation.ts +165 -131
- package/src/SchemaRegistry.ts +5 -4
- package/src/Tag.ts +6 -5
- package/src/Type.test.ts +10 -10
- package/src/Type.ts +70 -303
- package/src/View.ts +107 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +5 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +56 -6
- package/src/internal/{annotations → Annotation}/annotations.ts +128 -10
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -3
- package/src/internal/{annotations → Annotation}/util.ts +14 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +4 -2
- package/src/internal/{entities → Entity}/entity.ts +6 -4
- package/src/internal/{entities → Entity}/index.ts +2 -0
- package/src/internal/{entities → Entity}/model.ts +17 -42
- package/src/internal/{entities → Entity}/object.ts +2 -2
- package/src/internal/{entities → Entity}/relation.ts +19 -36
- package/src/internal/{api → Entity}/version.ts +3 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -1
- package/src/internal/{formats → Format}/format.test.ts +1 -1
- package/src/internal/{formats → Format}/types.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +4 -4
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +48 -48
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +6 -4
- package/src/internal/{object → Obj}/clone.ts +3 -3
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +4 -4
- package/src/internal/{object → Obj}/create-object.ts +5 -5
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/inspect.ts +2 -2
- package/src/internal/{object → Obj}/json-serializer.test.ts +31 -8
- package/src/internal/{object → Obj}/json-serializer.ts +42 -15
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +24 -24
- package/src/internal/{object → Obj}/set-value.ts +2 -2
- package/src/internal/Obj/snapshot.ts +105 -0
- package/src/internal/{object → Obj}/typed-object.test.ts +3 -3
- package/src/internal/{object → Obj}/typed-object.ts +4 -4
- package/src/internal/{ref → Ref}/ref-array.ts +1 -1
- package/src/internal/{ref → Ref}/ref.test.ts +4 -4
- package/src/internal/{ref → Ref}/ref.ts +27 -4
- package/src/internal/{schema → Type}/compose.test.ts +5 -5
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/{schema → Type}/echo-schema.ts +11 -10
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +10 -4
- package/src/internal/{README.md → common/README.md} +1 -1
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change.test.ts +58 -58
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -2
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +6 -3
- package/src/internal/{proxy → common/proxy}/make-object.ts +13 -3
- package/src/internal/{proxy → common/proxy}/reactive.ts +1 -1
- package/src/internal/{proxy → common/proxy}/schema.test.ts +10 -10
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +6 -6
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +10 -3
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +4 -4
- package/src/internal/{types → common/types}/base.ts +1 -1
- package/src/internal/{types → common/types}/entity.ts +2 -2
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +4 -1
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/{types → common/types}/typename.ts +10 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +8 -31
- package/src/testing/api.test.ts +4 -4
- package/src/testing/test-schema.ts +20 -18
- package/dist/lib/neutral/chunk-2MTHJ5UW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3ZEAZF7T.mjs.map +0 -7
- package/dist/lib/neutral/chunk-62DWJ6CE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6QPSGMEF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CUDIBUM4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HMOXCO27.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IP2GHXWA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs +0 -132
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NWUO5FKZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SU2LVM7J.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VB5HVDCA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VR4A4WGG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs +0 -13
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs +0 -157
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XMIDBDE6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YQYMWZAD.mjs.map +0 -7
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/api/annotations.d.ts +0 -23
- package/dist/types/src/internal/api/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/api/entity.d.ts.map +0 -1
- package/dist/types/src/internal/api/index.d.ts.map +0 -1
- package/dist/types/src/internal/api/meta.d.ts.map +0 -1
- package/dist/types/src/internal/api/sorting.d.ts.map +0 -1
- package/dist/types/src/internal/api/version.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/clone.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +0 -2
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change-context.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/errors.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/ownership.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/symbols.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/src/internal/api/annotations.ts +0 -60
- package/src/internal/object/snapshot.ts +0 -70
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/index.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/select.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/string.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/clone.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/ids.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/index.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/set-value.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/snapshot.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/index.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -0
- /package/dist/types/src/internal/{api → common/api}/meta.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change-context.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/define-hidden-property.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/errors.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/event-batch.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/index.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/json-serializer.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/make-object.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/ownership.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-types.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-utils.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/reactive-array.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/symbols.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/src/internal/{entities → Entity}/util.ts +0 -0
- /package/src/internal/{formats → Format}/date.ts +0 -0
- /package/src/internal/{formats → Format}/format.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{formats → Format}/object.ts +0 -0
- /package/src/internal/{formats → Format}/select.ts +0 -0
- /package/src/internal/{formats → Format}/string.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +0 -0
- /package/src/internal/{object → Obj}/ids.ts +0 -0
- /package/src/internal/{object → Obj}/index.ts +0 -0
- /package/src/internal/{object → Obj}/schema-validator.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
- /package/src/internal/{schema → Type}/index.ts +0 -0
- /package/src/internal/{api → common/api}/meta.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/change-context.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/define-hidden-property.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/errors.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/event-batch.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/ownership.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/reactive-array.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
|
@@ -10,13 +10,15 @@ import { assertArgument, invariant } from '@dxos/invariant';
|
|
|
10
10
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
11
11
|
import { assumeType, deepMapValues, visitValues } from '@dxos/util';
|
|
12
12
|
|
|
13
|
+
import type * as Database from '../../Database';
|
|
13
14
|
import type * as Obj from '../../Obj';
|
|
14
|
-
import { getTypeDXN, setTypename } from '../
|
|
15
|
+
import { getTypeDXN, setTypename } from '../Annotation';
|
|
15
16
|
import {
|
|
16
17
|
ATTR_DELETED,
|
|
17
18
|
ATTR_RELATION_SOURCE,
|
|
18
19
|
ATTR_RELATION_TARGET,
|
|
19
20
|
ATTR_SELF_DXN,
|
|
21
|
+
ObjectDatabaseId,
|
|
20
22
|
type ObjectJSON,
|
|
21
23
|
RelationSourceDXNId,
|
|
22
24
|
RelationSourceId,
|
|
@@ -24,19 +26,21 @@ import {
|
|
|
24
26
|
RelationTargetId,
|
|
25
27
|
SelfDXNId,
|
|
26
28
|
assertObjectModel,
|
|
27
|
-
} from '../
|
|
28
|
-
import { attachTypedJsonSerializer, defineHiddenProperty, typedJsonSerializer } from '../proxy';
|
|
29
|
-
import { Ref, type RefResolver, refFromEncodedReference, setRefResolver } from '../
|
|
29
|
+
} from '../Entity';
|
|
30
|
+
import { attachTypedJsonSerializer, defineHiddenProperty, typedJsonSerializer } from '../common/proxy';
|
|
31
|
+
import { Ref, type RefResolver, refFromEncodedReference, setRefResolver } from '../Ref';
|
|
30
32
|
import {
|
|
31
33
|
ATTR_META,
|
|
34
|
+
ATTR_PARENT,
|
|
32
35
|
ATTR_TYPE,
|
|
33
36
|
type AnyEntity,
|
|
34
37
|
EntityKind,
|
|
35
38
|
KindId,
|
|
36
39
|
MetaId,
|
|
37
40
|
ObjectMetaSchema,
|
|
41
|
+
ParentId,
|
|
38
42
|
setSchema,
|
|
39
|
-
} from '../types';
|
|
43
|
+
} from '../common/types';
|
|
40
44
|
|
|
41
45
|
// Re-export for backward compatibility.
|
|
42
46
|
export { attachTypedJsonSerializer };
|
|
@@ -68,10 +72,15 @@ export const objectToJSON = <T extends AnyEntity>(obj: T): SerializedObject<T> =
|
|
|
68
72
|
* Performs schema validation.
|
|
69
73
|
* References and schema will be resolvable if the `refResolver` is provided.
|
|
70
74
|
* The function need to be async to support resolving the schema as well as the relation endpoints.
|
|
75
|
+
*
|
|
76
|
+
* @param jsonData - JSON representation of the object.
|
|
77
|
+
* @param options.refResolver - Resolver for references.
|
|
78
|
+
* @param options.dxn - Override object DXN.
|
|
79
|
+
* @param options.database - Database to associate with the object.
|
|
71
80
|
*/
|
|
72
81
|
export const objectFromJSON = async (
|
|
73
82
|
jsonData: unknown,
|
|
74
|
-
{ refResolver, dxn }: { refResolver?: RefResolver; dxn?: DXN } = {},
|
|
83
|
+
{ refResolver, dxn, database }: { refResolver?: RefResolver; dxn?: DXN; database?: Database.Database } = {},
|
|
75
84
|
): Promise<AnyEntity> => {
|
|
76
85
|
assumeType<ObjectJSON>(jsonData);
|
|
77
86
|
assertArgument(typeof jsonData === 'object' && jsonData !== null, 'jsonData', 'expect object');
|
|
@@ -81,15 +90,16 @@ export const objectFromJSON = async (
|
|
|
81
90
|
const type = DXN.parse(jsonData[ATTR_TYPE]);
|
|
82
91
|
const schema = await refResolver?.resolveSchema(type);
|
|
83
92
|
invariant(schema === undefined || Schema.isSchema(schema));
|
|
93
|
+
const decodedInput = stripInternalJsonKeys(jsonData);
|
|
84
94
|
|
|
85
95
|
let obj: any;
|
|
86
96
|
if (schema != null) {
|
|
87
|
-
obj = await schema.pipe(Schema.decodeUnknownPromise)(
|
|
97
|
+
obj = await schema.pipe(Schema.decodeUnknownPromise)(decodedInput);
|
|
88
98
|
if (refResolver) {
|
|
89
99
|
setRefResolverOnData(obj, refResolver);
|
|
90
100
|
}
|
|
91
101
|
} else {
|
|
92
|
-
obj = decodeGeneric(
|
|
102
|
+
obj = decodeGeneric(decodedInput, { refResolver });
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
invariant(ObjectId.isValid(obj.id), 'Invalid object id');
|
|
@@ -126,10 +136,20 @@ export const objectFromJSON = async (
|
|
|
126
136
|
});
|
|
127
137
|
}
|
|
128
138
|
|
|
139
|
+
if (jsonData[ATTR_PARENT]) {
|
|
140
|
+
const parentDxn = DXN.parse(jsonData[ATTR_PARENT]);
|
|
141
|
+
const parent = (await refResolver?.resolve(parentDxn)) as Obj.Unknown | undefined;
|
|
142
|
+
defineHiddenProperty(obj, ParentId, parent);
|
|
143
|
+
}
|
|
144
|
+
|
|
129
145
|
if (dxn) {
|
|
130
146
|
defineHiddenProperty(obj, SelfDXNId, dxn);
|
|
131
147
|
}
|
|
132
148
|
|
|
149
|
+
if (database) {
|
|
150
|
+
defineHiddenProperty(obj, ObjectDatabaseId, database);
|
|
151
|
+
}
|
|
152
|
+
|
|
133
153
|
assertObjectModel(obj);
|
|
134
154
|
invariant((obj as any)[ATTR_TYPE] === undefined, 'Invalid object model');
|
|
135
155
|
invariant((obj as any)[ATTR_META] === undefined, 'Invalid object model');
|
|
@@ -141,6 +161,18 @@ export const objectFromJSON = async (
|
|
|
141
161
|
};
|
|
142
162
|
|
|
143
163
|
const decodeGeneric = (jsonData: unknown, options: { refResolver?: RefResolver }) => {
|
|
164
|
+
const props = stripInternalJsonKeys(jsonData);
|
|
165
|
+
|
|
166
|
+
return deepMapValues(props, (value, visitor) => {
|
|
167
|
+
if (isEncodedReference(value)) {
|
|
168
|
+
return refFromEncodedReference(value, options.refResolver);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return visitor(value);
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const stripInternalJsonKeys = (jsonData: unknown) => {
|
|
144
176
|
const {
|
|
145
177
|
[ATTR_TYPE]: _type,
|
|
146
178
|
[ATTR_META]: _meta,
|
|
@@ -151,13 +183,7 @@ const decodeGeneric = (jsonData: unknown, options: { refResolver?: RefResolver }
|
|
|
151
183
|
...props
|
|
152
184
|
} = jsonData as any;
|
|
153
185
|
|
|
154
|
-
return
|
|
155
|
-
if (isEncodedReference(value)) {
|
|
156
|
-
return refFromEncodedReference(value, options.refResolver);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return visitor(value);
|
|
160
|
-
});
|
|
186
|
+
return props;
|
|
161
187
|
};
|
|
162
188
|
|
|
163
189
|
export const setRefResolverOnData = (obj: AnyEntity, refResolver: RefResolver) => {
|
|
@@ -182,6 +208,7 @@ export const objectStructureToJson = (objectId: string, structure: ObjectStructu
|
|
|
182
208
|
id: objectId,
|
|
183
209
|
[ATTR_TYPE]: (ObjectStructure.getTypeReference(structure)?.['/'] ?? '') as DXN.String,
|
|
184
210
|
[ATTR_DELETED]: ObjectStructure.isDeleted(structure),
|
|
211
|
+
[ATTR_PARENT]: ObjectStructure.getParent(structure)?.['/'] as DXN.String | undefined,
|
|
185
212
|
[ATTR_RELATION_SOURCE]: ObjectStructure.getRelationSource(structure)?.['/'] as DXN.String | undefined,
|
|
186
213
|
[ATTR_RELATION_TARGET]: ObjectStructure.getRelationTarget(structure)?.['/'] as DXN.String | undefined,
|
|
187
214
|
};
|
|
@@ -17,7 +17,7 @@ describe('Obj.setValue', () => {
|
|
|
17
17
|
email: 'john@example.com',
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
Obj.change(person, (
|
|
20
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['address', 'city'], 'NYC'));
|
|
21
21
|
|
|
22
22
|
expect(person.address).toBeDefined();
|
|
23
23
|
expect(person.address?.city).toBe('NYC');
|
|
@@ -30,7 +30,7 @@ describe('Obj.setValue', () => {
|
|
|
30
30
|
email: 'john@example.com',
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
Obj.change(person, (
|
|
33
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['fields', 0, 'label'], 'Phone'));
|
|
34
34
|
|
|
35
35
|
expect(Array.isArray(person.fields)).toBe(true);
|
|
36
36
|
expect(person.fields?.[0].label).toBe('Phone');
|
|
@@ -45,7 +45,7 @@ describe('Obj.setValue', () => {
|
|
|
45
45
|
email: 'john@example.com',
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
Obj.change(person, (
|
|
48
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['address', 'coordinates', 'lat'], 40.7128));
|
|
49
49
|
|
|
50
50
|
expect(person.address).toBeDefined();
|
|
51
51
|
expect(person.address?.coordinates).toBeDefined();
|
|
@@ -69,10 +69,10 @@ describe('Obj.setValue', () => {
|
|
|
69
69
|
|
|
70
70
|
const container = Obj.make(Container, { name: 'box' });
|
|
71
71
|
|
|
72
|
-
Obj.change(container, (
|
|
73
|
-
Obj.setValue(
|
|
74
|
-
Obj.setValue(
|
|
75
|
-
Obj.setValue(
|
|
72
|
+
Obj.change(container, (obj) => {
|
|
73
|
+
Obj.setValue(obj, ['items', 0, 'value'], 10);
|
|
74
|
+
Obj.setValue(obj, ['items', 1, 'value'], 20);
|
|
75
|
+
Obj.setValue(obj, ['items', 2, 'value'], 30);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
expect(container.items).toHaveLength(3);
|
|
@@ -88,7 +88,7 @@ describe('Obj.setValue', () => {
|
|
|
88
88
|
email: 'john@example.com',
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
Obj.change(person, (
|
|
91
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['age'], 25));
|
|
92
92
|
|
|
93
93
|
expect(person.age).toBe(25);
|
|
94
94
|
});
|
|
@@ -100,7 +100,7 @@ describe('Obj.setValue', () => {
|
|
|
100
100
|
email: 'john@example.com',
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
Obj.change(person, (
|
|
103
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['address', 'city'], 'NYC'));
|
|
104
104
|
|
|
105
105
|
expect(person.address).toBeDefined();
|
|
106
106
|
expect(person.address?.city).toBe('NYC');
|
|
@@ -114,8 +114,8 @@ describe('Obj.setValue', () => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
let result: any;
|
|
117
|
-
Obj.change(person, (
|
|
118
|
-
result = Obj.setValue(
|
|
117
|
+
Obj.change(person, (obj) => {
|
|
118
|
+
result = Obj.setValue(obj, ['age'], 30);
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
expect(result).toBe(30);
|
|
@@ -129,7 +129,7 @@ describe('Obj.setValue', () => {
|
|
|
129
129
|
age: 25,
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
Obj.change(person, (
|
|
132
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['age'], 30));
|
|
133
133
|
|
|
134
134
|
expect(person.age).toBe(30);
|
|
135
135
|
});
|
|
@@ -142,7 +142,7 @@ describe('Obj.setValue', () => {
|
|
|
142
142
|
address: { city: 'Boston', state: 'MA', coordinates: {} },
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
Obj.change(person, (
|
|
145
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['address', 'city'], 'NYC'));
|
|
146
146
|
|
|
147
147
|
expect(person.address?.city).toBe('NYC');
|
|
148
148
|
expect(person.address?.state).toBe('MA');
|
|
@@ -160,11 +160,11 @@ describe('Obj.setValue', () => {
|
|
|
160
160
|
|
|
161
161
|
const matrix = Obj.make(Matrix, {});
|
|
162
162
|
|
|
163
|
-
Obj.change(matrix, (
|
|
164
|
-
Obj.setValue(
|
|
165
|
-
Obj.setValue(
|
|
166
|
-
Obj.setValue(
|
|
167
|
-
Obj.setValue(
|
|
163
|
+
Obj.change(matrix, (obj) => {
|
|
164
|
+
Obj.setValue(obj, ['values', 0, 0], 1);
|
|
165
|
+
Obj.setValue(obj, ['values', 0, 1], 2);
|
|
166
|
+
Obj.setValue(obj, ['values', 1, 0], 3);
|
|
167
|
+
Obj.setValue(obj, ['values', 1, 1], 4);
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
expect(matrix.values?.[0][0]).toBe(1);
|
|
@@ -180,8 +180,8 @@ describe('Obj.setValue', () => {
|
|
|
180
180
|
email: 'john@example.com',
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
Obj.change(person, (
|
|
184
|
-
expect(() => Obj.setValue(
|
|
183
|
+
Obj.change(person, (obj) => {
|
|
184
|
+
expect(() => Obj.setValue(obj, [], 'value')).toThrow('Path must not be empty');
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
|
|
@@ -192,7 +192,7 @@ describe('Obj.setValue', () => {
|
|
|
192
192
|
email: 'john@example.com',
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
Obj.change(person, (
|
|
195
|
+
Obj.change(person, (obj) => Obj.setValue(obj, ['age'], 30));
|
|
196
196
|
|
|
197
197
|
expect(person.age).toBe(30);
|
|
198
198
|
});
|
|
@@ -215,7 +215,7 @@ describe('Obj.setValue', () => {
|
|
|
215
215
|
const container = Obj.make(Container, { name: 'box' });
|
|
216
216
|
|
|
217
217
|
// Using string '0' for array index.
|
|
218
|
-
Obj.change(container, (
|
|
218
|
+
Obj.change(container, (obj) => Obj.setValue(obj, ['items', '0', 'value'], 42));
|
|
219
219
|
|
|
220
220
|
expect(container.items?.[0].value).toBe(42);
|
|
221
221
|
});
|
|
@@ -243,7 +243,7 @@ describe('Obj.setValue', () => {
|
|
|
243
243
|
|
|
244
244
|
// This should work: setting a nested property on an array element.
|
|
245
245
|
// The required 'id' field should be initialized with a default value.
|
|
246
|
-
Obj.change(todoList, (
|
|
246
|
+
Obj.change(todoList, (obj) => Obj.setValue(obj, ['tasks', 0, 'title'], 'Buy groceries'));
|
|
247
247
|
|
|
248
248
|
expect(todoList.tasks?.[0].id).toBe(''); // Default value for required String
|
|
249
249
|
expect(todoList.tasks?.[0].title).toBe('Buy groceries');
|
|
@@ -270,7 +270,7 @@ describe('Obj.setValue', () => {
|
|
|
270
270
|
|
|
271
271
|
const container = Obj.make(Container, { name: 'box' });
|
|
272
272
|
|
|
273
|
-
Obj.change(container, (
|
|
273
|
+
Obj.change(container, (obj) => Obj.setValue(obj, ['items', 0, 'label'], 'First Item'));
|
|
274
274
|
|
|
275
275
|
// All required primitive fields should have default values.
|
|
276
276
|
expect(container.items?.[0].id).toBe('');
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
} from '@dxos/effect';
|
|
17
17
|
import { invariant } from '@dxos/invariant';
|
|
18
18
|
|
|
19
|
-
import { type Mutable } from '../proxy';
|
|
20
|
-
import { getSchema } from '../types';
|
|
19
|
+
import { type Mutable } from '../common/proxy';
|
|
20
|
+
import { getSchema } from '../common/types';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Set a deeply nested property on an object.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { assertArgument } from '@dxos/invariant';
|
|
6
|
+
import { deepMapValues } from '@dxos/util';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
KindId,
|
|
10
|
+
MetaId,
|
|
11
|
+
ObjectDatabaseId,
|
|
12
|
+
ObjectDeletedId,
|
|
13
|
+
RelationSourceDXNId,
|
|
14
|
+
RelationSourceId,
|
|
15
|
+
RelationTargetDXNId,
|
|
16
|
+
RelationTargetId,
|
|
17
|
+
SchemaId,
|
|
18
|
+
SelfDXNId,
|
|
19
|
+
SnapshotKindId,
|
|
20
|
+
TypeId,
|
|
21
|
+
} from '../common/types';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Copy a Symbol-keyed property from source to target if it has a defined value.
|
|
25
|
+
* Handles both plain objects (symbol in source) and proxies where get returns a value
|
|
26
|
+
* but has/in returns false (e.g. ObjectDatabaseId on echo-db proxies).
|
|
27
|
+
* Optional transform clones or mutates the value before assignment (e.g. for MetaId).
|
|
28
|
+
*/
|
|
29
|
+
const copySymbolProperty = (
|
|
30
|
+
source: any,
|
|
31
|
+
target: any,
|
|
32
|
+
symbol: symbol,
|
|
33
|
+
transform?: (value: unknown) => unknown,
|
|
34
|
+
): void => {
|
|
35
|
+
let value: unknown;
|
|
36
|
+
// Echo-db proxy getters (e.g. RelationSourceId, RelationTargetId) can throw in certain states.
|
|
37
|
+
try {
|
|
38
|
+
value = source[symbol];
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (value !== undefined) {
|
|
43
|
+
const finalValue = transform ? transform(value) : value;
|
|
44
|
+
Object.defineProperty(target, symbol, {
|
|
45
|
+
value: finalValue,
|
|
46
|
+
writable: false,
|
|
47
|
+
enumerable: false,
|
|
48
|
+
configurable: false,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns an immutable snapshot of the reactive object.
|
|
55
|
+
* The snapshot is branded with SnapshotKindId (not KindId).
|
|
56
|
+
*/
|
|
57
|
+
export const getSnapshot = <T extends object>(obj: T): T => {
|
|
58
|
+
assertArgument(typeof obj === 'object' && obj !== null && KindId in obj, 'obj', 'must be an entity');
|
|
59
|
+
|
|
60
|
+
const snapshot = deepMapValues(obj, (value, recurse) => {
|
|
61
|
+
// Do not recurse on references (but do recurse on arrays).
|
|
62
|
+
if (
|
|
63
|
+
typeof value === 'object' &&
|
|
64
|
+
value !== null &&
|
|
65
|
+
Object.getPrototypeOf(value) !== Object.prototype &&
|
|
66
|
+
!Array.isArray(value)
|
|
67
|
+
) {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return recurse(value);
|
|
72
|
+
}) as any;
|
|
73
|
+
|
|
74
|
+
// Add SnapshotKindId brand based on original KindId.
|
|
75
|
+
if (obj != null && typeof obj === 'object' && KindId in obj) {
|
|
76
|
+
snapshot[SnapshotKindId] = (obj as any)[KindId];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Preserve Symbol-keyed properties that are important for type introspection.
|
|
80
|
+
// These are not copied by deepMapValues since Object.keys() doesn't include symbols.
|
|
81
|
+
const source = obj as any;
|
|
82
|
+
|
|
83
|
+
// Type introspection symbols.
|
|
84
|
+
copySymbolProperty(source, snapshot, TypeId);
|
|
85
|
+
copySymbolProperty(source, snapshot, SchemaId);
|
|
86
|
+
copySymbolProperty(source, snapshot, SelfDXNId);
|
|
87
|
+
|
|
88
|
+
// Database reference (required for Obj.getDatabase to work on snapshots).
|
|
89
|
+
copySymbolProperty(source, snapshot, ObjectDatabaseId);
|
|
90
|
+
copySymbolProperty(source, snapshot, ObjectDeletedId);
|
|
91
|
+
|
|
92
|
+
// Metadata symbol. Copy arrays so the snapshot is not affected by mutations to the live meta's keys/tags.
|
|
93
|
+
copySymbolProperty(source, snapshot, MetaId, (meta: any) => ({
|
|
94
|
+
keys: [...(meta?.keys ?? [])],
|
|
95
|
+
tags: [...(meta?.tags ?? [])],
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
// Relation endpoint symbols.
|
|
99
|
+
copySymbolProperty(source, snapshot, RelationSourceDXNId);
|
|
100
|
+
copySymbolProperty(source, snapshot, RelationTargetDXNId);
|
|
101
|
+
copySymbolProperty(source, snapshot, RelationSourceId);
|
|
102
|
+
copySymbolProperty(source, snapshot, RelationTargetId);
|
|
103
|
+
|
|
104
|
+
return Object.freeze(snapshot) as T;
|
|
105
|
+
};
|
|
@@ -6,13 +6,13 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
7
|
import { describe, expect, test } from 'vitest';
|
|
8
8
|
|
|
9
|
-
import { EchoObjectSchema } from '../
|
|
9
|
+
import { EchoObjectSchema } from '../Entity';
|
|
10
10
|
|
|
11
11
|
const Organization = Schema.Struct({
|
|
12
12
|
name: Schema.String,
|
|
13
13
|
}).pipe(
|
|
14
14
|
EchoObjectSchema({
|
|
15
|
-
typename: 'example.
|
|
15
|
+
typename: 'com.example.type.organization',
|
|
16
16
|
version: '0.1.0',
|
|
17
17
|
}),
|
|
18
18
|
);
|
|
@@ -25,7 +25,7 @@ describe('EchoObjectSchema DSL', () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test('static typename accessor', async () => {
|
|
28
|
-
expect(Organization.typename).to.eq('example.
|
|
28
|
+
expect(Organization.typename).to.eq('com.example.type.organization');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
test('expect schema', async () => {
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { type TypeMeta } from '../
|
|
8
|
-
import { type AnyEntity } from '../types';
|
|
7
|
+
import { type TypeMeta } from '../Annotation';
|
|
8
|
+
import { type AnyEntity } from '../common/types';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Definition for an object type that can be stored in an ECHO database.
|
|
@@ -14,7 +14,7 @@ import { type AnyEntity } from '../types';
|
|
|
14
14
|
*
|
|
15
15
|
* In contrast to {@link EchoSchema} this definition is not recorded in the database.
|
|
16
16
|
*
|
|
17
|
-
* @deprecated Use `Type.
|
|
17
|
+
* @deprecated Use `Type.AnyObj` from `@dxos/echo` instead.
|
|
18
18
|
*/
|
|
19
19
|
export interface TypedObject<A = any, I = any> extends TypeMeta, Schema.Schema<A, I> {}
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ export interface TypedObject<A = any, I = any> extends TypeMeta, Schema.Schema<A
|
|
|
22
22
|
* Typed object that could be used as a prototype in class definitions.
|
|
23
23
|
* This is an internal API type.
|
|
24
24
|
*
|
|
25
|
-
* @deprecated Use `Type.
|
|
25
|
+
* @deprecated Use `Type.AnyObj` from `@dxos/echo` instead.
|
|
26
26
|
*/
|
|
27
27
|
export interface TypedObjectPrototype<A = any, I = any> extends TypedObject<A, I> {
|
|
28
28
|
/** Type constructor. */
|
|
@@ -7,8 +7,8 @@ import { describe, expect, test } from 'vitest';
|
|
|
7
7
|
|
|
8
8
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
9
9
|
|
|
10
|
-
import { EchoObjectSchema, getObjectDXN } from '../
|
|
11
|
-
import { createObject } from '../
|
|
10
|
+
import { EchoObjectSchema, getObjectDXN } from '../Entity';
|
|
11
|
+
import { createObject } from '../Obj';
|
|
12
12
|
|
|
13
13
|
import { Ref, getReferenceAst } from './ref';
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ const Task = Schema.Struct({
|
|
|
16
16
|
title: Schema.optional(Schema.String),
|
|
17
17
|
}).pipe(
|
|
18
18
|
EchoObjectSchema({
|
|
19
|
-
typename: 'example.
|
|
19
|
+
typename: 'com.example.type.task',
|
|
20
20
|
version: '0.1.0',
|
|
21
21
|
}),
|
|
22
22
|
);
|
|
@@ -29,7 +29,7 @@ const Contact = Schema.Struct({
|
|
|
29
29
|
tasks: Schema.Array(Ref(Task)),
|
|
30
30
|
}).pipe(
|
|
31
31
|
EchoObjectSchema({
|
|
32
|
-
typename: 'example.
|
|
32
|
+
typename: 'com.example.type.person',
|
|
33
33
|
version: '0.1.0',
|
|
34
34
|
}),
|
|
35
35
|
);
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Equal from 'effect/Equal';
|
|
7
|
+
import * as Hash from 'effect/Hash';
|
|
6
8
|
import * as Option from 'effect/Option';
|
|
7
9
|
import * as ParseResult from 'effect/ParseResult';
|
|
10
|
+
import * as Pipeable from 'effect/Pipeable';
|
|
8
11
|
import * as Schema from 'effect/Schema';
|
|
9
12
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
10
13
|
import type * as Types from 'effect/Types';
|
|
@@ -16,9 +19,9 @@ import { assertArgument, invariant } from '@dxos/invariant';
|
|
|
16
19
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
17
20
|
|
|
18
21
|
import * as Database from '../../Database';
|
|
19
|
-
import { ReferenceAnnotationId, getSchemaDXN, getTypeAnnotation, getTypeIdentifierAnnotation } from '../
|
|
20
|
-
import { type JsonSchemaType } from '../
|
|
21
|
-
import type { AnyEntity, AnyProperties } from '../types';
|
|
22
|
+
import { ReferenceAnnotationId, getSchemaDXN, getTypeAnnotation, getTypeIdentifierAnnotation } from '../Annotation';
|
|
23
|
+
import { type JsonSchemaType } from '../JsonSchema';
|
|
24
|
+
import type { AnyEntity, AnyProperties } from '../common/types';
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* The `$id` and `$ref` fields for an ECHO reference schema.
|
|
@@ -130,7 +133,7 @@ export const Ref: RefFn = <S extends Schema.Schema.Any>(schema: S): RefSchema<Sc
|
|
|
130
133
|
* Represents materialized reference to a target.
|
|
131
134
|
* This is the data type for the fields marked as ref.
|
|
132
135
|
*/
|
|
133
|
-
export interface Ref<T> {
|
|
136
|
+
export interface Ref<T> extends Pipeable.Pipeable {
|
|
134
137
|
/**
|
|
135
138
|
* Target object DXN.
|
|
136
139
|
*/
|
|
@@ -459,6 +462,21 @@ export class RefImpl<T> implements Ref<T> {
|
|
|
459
462
|
|
|
460
463
|
[RefTypeId] = refVariance;
|
|
461
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Effect Hash trait. Required for MutableHashMap-based caches (e.g., Atom.family)
|
|
467
|
+
* to deduplicate Ref instances that point to the same object.
|
|
468
|
+
* ECHO proxies return new RefImpl instances on every property access,
|
|
469
|
+
* so without this, each access would create a separate cache entry.
|
|
470
|
+
*/
|
|
471
|
+
[Hash.symbol](): number {
|
|
472
|
+
return Hash.hash(this.#dxn.toString());
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/** Effect Equal trait. See {@link Hash.symbol} for rationale. */
|
|
476
|
+
[Equal.symbol](that: Equal.Equal): boolean {
|
|
477
|
+
return that instanceof RefImpl && this.#dxn.toString() === that.dxn.toString();
|
|
478
|
+
}
|
|
479
|
+
|
|
462
480
|
/**
|
|
463
481
|
* Internal method to set the resolver.
|
|
464
482
|
*
|
|
@@ -474,6 +492,11 @@ export class RefImpl<T> implements Ref<T> {
|
|
|
474
492
|
_getSavedTarget(): T | undefined {
|
|
475
493
|
return this.#target;
|
|
476
494
|
}
|
|
495
|
+
|
|
496
|
+
pipe() {
|
|
497
|
+
// eslint-disable-next-line prefer-rest-params
|
|
498
|
+
return Pipeable.pipeArguments(this, arguments);
|
|
499
|
+
}
|
|
477
500
|
}
|
|
478
501
|
|
|
479
502
|
/**
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { describe, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import { FieldPath } from '../
|
|
9
|
-
import { EchoObjectSchema } from '../
|
|
10
|
-
import { FormatAnnotation, TypeFormat } from '../
|
|
11
|
-
import { ECHO_ANNOTATIONS_NS_KEY, toJsonSchema } from '../
|
|
8
|
+
import { FieldPath } from '../Annotation';
|
|
9
|
+
import { EchoObjectSchema } from '../Entity';
|
|
10
|
+
import { FormatAnnotation, TypeFormat } from '../Format';
|
|
11
|
+
import { ECHO_ANNOTATIONS_NS_KEY, toJsonSchema } from '../JsonSchema';
|
|
12
12
|
|
|
13
13
|
import { composeSchema } from './compose';
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ describe('schema composition', () => {
|
|
|
17
17
|
const BaseType = Schema.Struct({
|
|
18
18
|
name: Schema.String,
|
|
19
19
|
email: Schema.String,
|
|
20
|
-
}).pipe(EchoObjectSchema({ typename: 'example.
|
|
20
|
+
}).pipe(EchoObjectSchema({ typename: 'com.example.person', version: '0.1.0' }));
|
|
21
21
|
|
|
22
22
|
const OverlaySchema = Schema.Struct({
|
|
23
23
|
email: Schema.String.pipe(FieldPath('$.email'), FormatAnnotation.set(TypeFormat.Email)),
|
|
@@ -6,7 +6,7 @@ import type * as Types from 'effect/Types';
|
|
|
6
6
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
|
|
9
|
-
import { type JsonSchemaType } from '../
|
|
9
|
+
import { type JsonSchemaType } from '../JsonSchema';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Creates a composite schema from the source and projection schemas.
|
|
@@ -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 { type
|
|
13
|
-
import { type
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
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';
|
|
16
17
|
|
|
17
18
|
import {
|
|
18
19
|
addFieldsToSchema,
|
|
@@ -177,7 +178,7 @@ const schemaVariance = {
|
|
|
177
178
|
*
|
|
178
179
|
* @example
|
|
179
180
|
* ```ts
|
|
180
|
-
* export class TableType extends Schema.Struct({...}).pipe(Type.object({ typename: 'example.
|
|
181
|
+
* export class TableType extends Schema.Struct({...}).pipe(Type.object({ typename: 'com.example.type.table', version: '0.1.0' })){
|
|
181
182
|
* title: Schema.String,
|
|
182
183
|
* schema: Schema.optional(ref(EchoSchema)),
|
|
183
184
|
* props: Schema.mutable(S.Array(TablePropSchema)),
|
|
@@ -192,7 +193,7 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
192
193
|
|
|
193
194
|
/**
|
|
194
195
|
* Schema kind key that marks this as an ECHO schema.
|
|
195
|
-
* Makes EchoSchema satisfy the Type.
|
|
196
|
+
* Makes EchoSchema satisfy the Type.AnyObj type.
|
|
196
197
|
*/
|
|
197
198
|
readonly [SchemaKindId]: EntityKind.Object = EntityKind.Object;
|
|
198
199
|
|
|
@@ -304,8 +305,8 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
304
305
|
/**
|
|
305
306
|
* Reference to the underlying persistent schema object.
|
|
306
307
|
*/
|
|
307
|
-
public get persistentSchema():
|
|
308
|
-
return this._persistentSchema;
|
|
308
|
+
public get persistentSchema(): Type.PersistentType {
|
|
309
|
+
return this._persistentSchema as Type.PersistentType;
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
public getProperties(): SchemaAST.PropertySignature[] {
|
|
@@ -399,7 +400,7 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
399
400
|
*/
|
|
400
401
|
_rebuild(): void {
|
|
401
402
|
if (this._isDirty || this._schema == null) {
|
|
402
|
-
this._schema = toEffectSchema(getSnapshot(this._persistentSchema.jsonSchema)
|
|
403
|
+
this._schema = toEffectSchema(getSnapshot(this._persistentSchema).jsonSchema);
|
|
403
404
|
this._isDirty = false;
|
|
404
405
|
}
|
|
405
406
|
}
|