@dxos/echo 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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/Feed.mjs +47 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +11 -8
- 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-43Y5DOS6.mjs +396 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-2MTHJ5UW.mjs → chunk-4JRI2ZJI.mjs} +134 -24
- package/dist/lib/neutral/chunk-4JRI2ZJI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6DNYDXCV.mjs +159 -0
- package/dist/lib/neutral/chunk-6DNYDXCV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6GPU7XC3.mjs +283 -0
- package/dist/lib/neutral/chunk-6GPU7XC3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-IP2GHXWA.mjs → chunk-6K2MVI2O.mjs} +5 -5
- package/dist/lib/neutral/chunk-6K2MVI2O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7VNVH63N.mjs +106 -0
- package/dist/lib/neutral/chunk-7VNVH63N.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-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-BOZZPUXE.mjs +787 -0
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SU2LVM7J.mjs → chunk-C4JZK4J7.mjs} +1596 -2730
- package/dist/lib/neutral/chunk-C4JZK4J7.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-HMOXCO27.mjs → chunk-FXEG7EOK.mjs} +8 -3
- package/dist/lib/neutral/chunk-FXEG7EOK.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-NEGC54NE.mjs +130 -0
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VB5HVDCA.mjs → chunk-NXMFBIT5.mjs} +16 -4
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NWUO5FKZ.mjs → chunk-OENWMTE6.mjs} +8 -2
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6QPSGMEF.mjs → chunk-ROAGDPV7.mjs} +32 -8
- package/dist/lib/neutral/chunk-ROAGDPV7.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-CUDIBUM4.mjs → chunk-SEMVAGBM.mjs} +97 -24
- package/dist/lib/neutral/chunk-SEMVAGBM.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-3ZEAZF7T.mjs → chunk-UTBRYVQC.mjs} +8 -4
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VR4A4WGG.mjs → chunk-W47JKR3X.mjs} +72 -23
- package/dist/lib/neutral/chunk-W47JKR3X.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-XMIDBDE6.mjs → chunk-YMNSMKKW.mjs} +11 -56
- package/dist/lib/neutral/chunk-YMNSMKKW.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 +39 -26
- package/dist/lib/neutral/internal/index.mjs +52 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +41 -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 +18 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +38 -12
- 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/Feed.d.ts +165 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +1 -1
- package/dist/types/src/Filter.d.ts.map +1 -1
- 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 +151 -36
- 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 +73 -26
- 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 +4 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +68 -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 +19 -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 +71 -51
- package/src/Err.ts +22 -0
- package/src/Feed.ts +262 -0
- package/src/Filter.ts +19 -4
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +9 -4
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +63 -2
- package/src/Obj.ts +278 -133
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +181 -14
- package/src/Query.ts +249 -23
- package/src/Ref.ts +64 -11
- package/src/Relation.test.ts +8 -2
- package/src/Relation.ts +163 -129
- 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 +4 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +6 -6
- package/src/internal/{annotations → Annotation}/annotations.ts +120 -9
- 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 +29 -6
- 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.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 +3 -3
- 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/{object → Obj}/set-value.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
|
@@ -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
|
}
|
|
@@ -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 = (
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { IconAnnotation } from '../Annotation';
|
|
8
|
+
import { LabelAnnotation, TypenameSchema, VersionSchema } from '../Annotation';
|
|
9
|
+
import { EchoObjectSchema } from '../Entity';
|
|
10
|
+
import { JsonSchemaType } from '../JsonSchema';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Persistent representation of a schema.
|
|
@@ -19,9 +20,14 @@ export const PersistentSchema = Schema.Struct({
|
|
|
19
20
|
jsonSchema: JsonSchemaType,
|
|
20
21
|
}).pipe(
|
|
21
22
|
EchoObjectSchema({
|
|
22
|
-
typename: 'dxos.
|
|
23
|
+
typename: 'org.dxos.type.schema',
|
|
23
24
|
version: '0.1.0',
|
|
24
25
|
}),
|
|
26
|
+
LabelAnnotation.set(['name']),
|
|
27
|
+
IconAnnotation.set({
|
|
28
|
+
icon: 'ph--database--regular',
|
|
29
|
+
hue: 'green',
|
|
30
|
+
}),
|
|
25
31
|
);
|
|
26
32
|
|
|
27
33
|
export interface PersistentSchema extends Schema.Schema.Type<typeof PersistentSchema> {}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
- [x] QueryResult namespace
|
|
32
32
|
- [x] SchemaRegistry interface
|
|
33
|
-
- [x] Schema registry should return Type.
|
|
33
|
+
- [x] Schema registry should return Type.AnyEntity instead of Schema.Schema.AnyNoContext.
|
|
34
34
|
- [x] Hypergraph interface
|
|
35
35
|
- [x] Obj.getDatabase
|
|
36
36
|
- [x] SpaceAction.AddObject target should be a db not a space.
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import * as Obj from '
|
|
8
|
-
import * as Relation from '
|
|
9
|
-
import { TestSchema } from '
|
|
7
|
+
import * as Obj from '../../../Obj';
|
|
8
|
+
import * as Relation from '../../../Relation';
|
|
9
|
+
import { TestSchema } from '../../../testing';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Tests for Obj.change context enforcement and mutator type safety.
|
|
@@ -8,8 +8,8 @@ import { describe, expect, test } from 'vitest';
|
|
|
8
8
|
|
|
9
9
|
import { isNode } from '@dxos/util';
|
|
10
10
|
|
|
11
|
-
import { TestSchema, updateCounter } from '
|
|
12
|
-
import { createObject } from '
|
|
11
|
+
import { TestSchema, updateCounter } from '../../../testing';
|
|
12
|
+
import { createObject } from '../../Obj';
|
|
13
13
|
import { ATTR_META } from '../types';
|
|
14
14
|
|
|
15
15
|
import { makeObject } from './make-object';
|
|
@@ -7,16 +7,19 @@ import { invariant } from '@dxos/invariant';
|
|
|
7
7
|
import { DXN } from '@dxos/keys';
|
|
8
8
|
import { deepMapValues } from '@dxos/util';
|
|
9
9
|
|
|
10
|
+
import { Ref } from '../../Ref';
|
|
10
11
|
import {
|
|
12
|
+
ATTR_META,
|
|
11
13
|
ATTR_RELATION_SOURCE,
|
|
12
14
|
ATTR_RELATION_TARGET,
|
|
13
15
|
ATTR_SELF_DXN,
|
|
16
|
+
ATTR_TYPE,
|
|
17
|
+
MetaId,
|
|
14
18
|
RelationSourceDXNId,
|
|
15
19
|
RelationTargetDXNId,
|
|
16
20
|
SelfDXNId,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import { ATTR_META, ATTR_TYPE, MetaId, TypeId } from '../types';
|
|
21
|
+
TypeId,
|
|
22
|
+
} from '../types';
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Attaches a toJSON method to the object for typed serialization.
|
|
@@ -6,8 +6,8 @@ import type * as Schema from 'effect/Schema';
|
|
|
6
6
|
|
|
7
7
|
import { ObjectId } from '@dxos/keys';
|
|
8
8
|
|
|
9
|
-
import { getTypeAnnotation } from '
|
|
10
|
-
import { type AnyProperties, KindId, MetaId, type ObjectMeta, ObjectMetaSchema } from '../types';
|
|
9
|
+
import { getTypeAnnotation } from '../../Annotation';
|
|
10
|
+
import { type AnyProperties, KindId, MetaId, type ObjectMeta, ObjectMetaSchema, ParentId } from '../types';
|
|
11
11
|
|
|
12
12
|
import { defineHiddenProperty } from './define-hidden-property';
|
|
13
13
|
import { attachTypedJsonSerializer } from './json-serializer';
|
|
@@ -35,7 +35,8 @@ export const makeObject: {
|
|
|
35
35
|
meta?: ObjectMeta,
|
|
36
36
|
): T;
|
|
37
37
|
} = <T extends AnyProperties>(schema: Schema.Schema<T, any>, obj: MakeObjectProps<T>, meta?: ObjectMeta): T => {
|
|
38
|
-
|
|
38
|
+
// Use Object.assign to copy symbol properties (like ParentId) that spread operator doesn't copy.
|
|
39
|
+
return createReactiveObject<T>(Object.assign({}, obj) as T, meta, schema);
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
const createReactiveObject = <T extends AnyProperties>(obj: T, meta?: ObjectMeta, schema?: Schema.Schema<T>): T => {
|
|
@@ -47,12 +48,21 @@ const createReactiveObject = <T extends AnyProperties>(obj: T, meta?: ObjectMeta
|
|
|
47
48
|
throw new Error('Schema is required for reactive objects. Use Atom for untyped reactive state.');
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
// Extract parent from props (can be set via [Obj.Parent]).
|
|
52
|
+
const parent = (obj as any)[ParentId];
|
|
53
|
+
if (parent !== undefined) {
|
|
54
|
+
delete (obj as any)[ParentId];
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
const annotation = getTypeAnnotation(schema);
|
|
51
58
|
if (annotation) {
|
|
52
59
|
setIdOnTarget(obj);
|
|
53
60
|
defineHiddenProperty(obj, KindId, annotation.kind);
|
|
54
61
|
}
|
|
55
62
|
initMeta(obj, meta);
|
|
63
|
+
if (parent !== undefined) {
|
|
64
|
+
defineHiddenProperty(obj, ParentId, parent);
|
|
65
|
+
}
|
|
56
66
|
prepareTypedTarget(obj, schema);
|
|
57
67
|
attachTypedJsonSerializer(obj);
|
|
58
68
|
const proxy = createProxy<T>(obj, TypedReactiveHandler.instance);
|
|
@@ -6,14 +6,14 @@ 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 { createEchoSchema } from '
|
|
10
|
-
import { PropertyMeta, getPropertyMetaAnnotation, getTypeAnnotation } from '
|
|
11
|
-
import { EchoObjectSchema } from '
|
|
9
|
+
import { createEchoSchema } from '../../../testing';
|
|
10
|
+
import { PropertyMeta, getPropertyMetaAnnotation, getTypeAnnotation } from '../../Annotation';
|
|
11
|
+
import { EchoObjectSchema } from '../../Entity';
|
|
12
12
|
|
|
13
13
|
// TODO(dmaretskyi): Comment.
|
|
14
14
|
const EmptySchemaType = Schema.Struct({}).pipe(
|
|
15
15
|
EchoObjectSchema({
|
|
16
|
-
typename: 'example.
|
|
16
|
+
typename: 'com.example.type.empty',
|
|
17
17
|
version: '0.1.0',
|
|
18
18
|
}),
|
|
19
19
|
);
|
|
@@ -27,7 +27,7 @@ describe('dynamic schema', () => {
|
|
|
27
27
|
field2: Schema.Boolean,
|
|
28
28
|
}).pipe(
|
|
29
29
|
EchoObjectSchema({
|
|
30
|
-
typename: 'example.
|
|
30
|
+
typename: 'com.example.type.test',
|
|
31
31
|
version: '0.1.0',
|
|
32
32
|
}),
|
|
33
33
|
);
|
|
@@ -44,7 +44,7 @@ describe('dynamic schema', () => {
|
|
|
44
44
|
field1: Schema.String,
|
|
45
45
|
}).pipe(
|
|
46
46
|
EchoObjectSchema({
|
|
47
|
-
typename: 'example.
|
|
47
|
+
typename: 'com.example.type.test',
|
|
48
48
|
version: '0.1.0',
|
|
49
49
|
}),
|
|
50
50
|
);
|
|
@@ -95,7 +95,7 @@ describe('dynamic schema', () => {
|
|
|
95
95
|
registered.updateFields({ field3: Schema.Boolean });
|
|
96
96
|
registered.removeFields(['field2']);
|
|
97
97
|
expect(getTypeAnnotation(registered)).to.deep.contain({
|
|
98
|
-
typename: 'example.
|
|
98
|
+
typename: 'com.example.type.empty',
|
|
99
99
|
version: '0.1.0',
|
|
100
100
|
});
|
|
101
101
|
expect(getPropertyMetaAnnotation(registered.getProperties()[0], metaNamespace)).to.deep.eq(metaInfo);
|
|
@@ -111,7 +111,7 @@ describe('dynamic schema', () => {
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
// First update.
|
|
114
|
-
const newTypename1 = 'example.
|
|
114
|
+
const newTypename1 = 'com.example.type.individual';
|
|
115
115
|
registered.updateTypename(newTypename1);
|
|
116
116
|
|
|
117
117
|
// Basic typename update checks.
|
|
@@ -132,13 +132,13 @@ describe('dynamic schema', () => {
|
|
|
132
132
|
expect(nameMeta).toEqual({ maxLength: 10 });
|
|
133
133
|
|
|
134
134
|
// Second update to ensure multiple updates work.
|
|
135
|
-
const newTypename2 = 'example.
|
|
135
|
+
const newTypename2 = 'com.example.type.person';
|
|
136
136
|
registered.updateTypename(newTypename2);
|
|
137
137
|
expect(registered.typename).toBe(newTypename2);
|
|
138
138
|
expect(registered.jsonSchema.$id).toBe(`dxn:type:${newTypename2}`);
|
|
139
139
|
expect(registered.jsonSchema.typename).toBe(newTypename2);
|
|
140
140
|
expect(getTypeAnnotation(registered)).to.deep.contain({
|
|
141
|
-
typename: 'example.
|
|
141
|
+
typename: 'com.example.type.person',
|
|
142
142
|
version: '0.1.0',
|
|
143
143
|
});
|
|
144
144
|
});
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { describe, expect, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import { TestSchema } from '
|
|
9
|
-
import { EchoObjectSchema } from '
|
|
10
|
-
import { setValue } from '
|
|
11
|
-
import { Ref } from '
|
|
8
|
+
import { TestSchema } from '../../../testing';
|
|
9
|
+
import { EchoObjectSchema } from '../../Entity';
|
|
10
|
+
import { setValue } from '../../Obj';
|
|
11
|
+
import { Ref } from '../../Ref';
|
|
12
12
|
import { foreignKey, getMeta } from '../types';
|
|
13
13
|
|
|
14
14
|
import { makeObject } from './make-object';
|
|
@@ -40,10 +40,10 @@ describe('complex schema validations', () => {
|
|
|
40
40
|
|
|
41
41
|
test('references', () => {
|
|
42
42
|
const Foo = Schema.Struct({ field: Schema.String }).pipe(
|
|
43
|
-
EchoObjectSchema({ typename: 'example.
|
|
43
|
+
EchoObjectSchema({ typename: 'com.example.type.foo', version: '0.1.0' }),
|
|
44
44
|
);
|
|
45
45
|
const Bar = Schema.Struct({ fooRef: Ref(Foo) }).pipe(
|
|
46
|
-
EchoObjectSchema({ typename: 'example.
|
|
46
|
+
EchoObjectSchema({ typename: 'com.example.type.bar', version: '0.1.0' }),
|
|
47
47
|
);
|
|
48
48
|
const field = 'hello';
|
|
49
49
|
expect(() => makeObject(Bar, { fooRef: { id: '1', field } as any })).to.throw();
|