@dxos/echo 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963
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/dist/lib/neutral/Annotation.mjs +3 -3
- package/dist/lib/neutral/Database.mjs +8 -4
- package/dist/lib/neutral/Entity.mjs +16 -11
- package/dist/lib/neutral/Err.mjs +1 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +21 -14
- package/dist/lib/neutral/Filter.mjs +21 -10
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +8 -7
- package/dist/lib/neutral/Key.mjs +1 -1
- package/dist/lib/neutral/Migration.mjs +17 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +16 -10
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +19 -13
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +7 -7
- package/dist/lib/neutral/Relation.mjs +15 -11
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +14 -10
- package/dist/lib/neutral/Type.mjs +10 -7
- package/dist/lib/neutral/{chunk-ALOGSVBP.mjs → chunk-3U5PIVPZ.mjs} +59 -4
- package/dist/lib/neutral/chunk-3U5PIVPZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DZQSL6RW.mjs → chunk-44HT3MEC.mjs} +2 -2
- package/dist/lib/neutral/{chunk-DZQSL6RW.mjs.map → chunk-44HT3MEC.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-5ELDDYWE.mjs → chunk-4VTRFJV3.mjs} +17 -19
- package/dist/lib/neutral/chunk-4VTRFJV3.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5NR2KWDU.mjs +34 -0
- package/dist/lib/neutral/chunk-5NR2KWDU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-62RJTYOZ.mjs +346 -0
- package/dist/lib/neutral/chunk-62RJTYOZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OVUBTQLT.mjs → chunk-7OO5B5DD.mjs} +2 -2
- package/dist/lib/neutral/chunk-7OO5B5DD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7RVZT53K.mjs} +1 -1
- package/dist/lib/neutral/{chunk-GAWKQ5DZ.mjs → chunk-AG7JS76F.mjs} +5 -5
- package/dist/lib/neutral/chunk-AG7JS76F.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-PP4DNUZU.mjs → chunk-AVPYX7FF.mjs} +1399 -2882
- package/dist/lib/neutral/chunk-AVPYX7FF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZWKJ4LZJ.mjs → chunk-BCKTAKBX.mjs} +23 -51
- package/dist/lib/neutral/chunk-BCKTAKBX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-T6JEFNP6.mjs → chunk-BICZKPQG.mjs} +1 -1
- package/dist/lib/neutral/{chunk-T6JEFNP6.mjs.map → chunk-BICZKPQG.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-F7KMHDPJ.mjs → chunk-GECFB2UL.mjs} +49 -31
- package/dist/lib/neutral/chunk-GECFB2UL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs +50 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BRJSLACP.mjs → chunk-M7ET73JD.mjs} +71 -17
- package/dist/lib/neutral/chunk-M7ET73JD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4KG6IGL4.mjs → chunk-N4B7FHQT.mjs} +4 -4
- package/dist/lib/neutral/{chunk-4KG6IGL4.mjs.map → chunk-N4B7FHQT.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-KGV3QIRX.mjs → chunk-NCSIQP3L.mjs} +124 -17
- package/dist/lib/neutral/chunk-NCSIQP3L.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QXF3LGN2.mjs → chunk-NGQNU3KX.mjs} +5 -3
- package/dist/lib/neutral/chunk-NGQNU3KX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-PRCRETDK.mjs +36 -0
- package/dist/lib/neutral/chunk-PRCRETDK.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-AQP4QKYP.mjs → chunk-S4JXD2RO.mjs} +44 -9
- package/dist/lib/neutral/chunk-S4JXD2RO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-W7OP5HGZ.mjs → chunk-SVEGO3DJ.mjs} +14 -10
- package/dist/lib/neutral/chunk-SVEGO3DJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-M2KVTHZM.mjs → chunk-TRPZU2HV.mjs} +10 -10
- package/dist/lib/neutral/chunk-TRPZU2HV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZTUBYOGB.mjs → chunk-TTCSATUD.mjs} +1 -1
- package/dist/lib/neutral/chunk-TTCSATUD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-GFNCSK7F.mjs → chunk-TTUIJXGD.mjs} +54 -23
- package/dist/lib/neutral/chunk-TTUIJXGD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-V72DY6LU.mjs} +1 -1
- package/dist/lib/neutral/{chunk-T4MPQJ7X.mjs → chunk-WGMPVUUL.mjs} +6 -22
- package/dist/lib/neutral/chunk-WGMPVUUL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-O3TZFQCT.mjs → chunk-YDRLYZKW.mjs} +2 -2
- package/dist/lib/neutral/chunk-YDRLYZKW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Z25FPDXG.mjs +734 -0
- package/dist/lib/neutral/chunk-Z25FPDXG.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MXQJZCPY.mjs → chunk-ZISMEVKD.mjs} +1 -1
- package/dist/lib/neutral/chunk-ZISMEVKD.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +38 -25
- package/dist/lib/neutral/internal/index.mjs +48 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +41 -35
- package/dist/lib/neutral/testing/index.mjs.map +2 -2
- package/dist/types/src/Annotation.d.ts +3 -3
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +15 -3
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +2 -1
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +17 -11
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +18 -18
- 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 +40 -23
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +33 -4
- 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 +1 -1
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +6 -1
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +5 -5
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +57 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +45 -29
- 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 +13 -2
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +11 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +16 -16
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +1 -1
- package/dist/types/src/Tag.d.ts +2 -2
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +10 -9
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +1 -1
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +24 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -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 +23 -23
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.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 +13 -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 +2 -2
- 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 +2 -2
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +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 +15 -2
- 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 +6 -6
- 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/{api → common/api}/meta.d.ts +3 -3
- 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/{proxy → common/proxy}/change-context.d.ts +1 -1
- 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/{proxy → common/proxy}/errors.d.ts +1 -1
- 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/{proxy → common/proxy}/reactive-array.d.ts +1 -1
- 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 +2 -2
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.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/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/entity.d.ts +4 -4
- 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 +3 -3
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +54 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +1 -1
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +9 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +53 -53
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/src/Annotation.ts +5 -3
- package/src/Collection.ts +8 -1
- package/src/Database.ts +54 -17
- package/src/Dataset.ts +2 -0
- package/src/Entity.ts +20 -11
- package/src/Err.ts +2 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +86 -36
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +68 -3
- package/src/Format.ts +1 -1
- package/src/Hypergraph.ts +7 -2
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +102 -0
- package/src/JsonSchema.ts +7 -5
- package/src/Migration.ts +94 -0
- package/src/Obj.test.ts +107 -15
- package/src/Obj.ts +166 -40
- package/src/Order.ts +2 -0
- package/src/Query.test.ts +221 -31
- package/src/Query.ts +50 -3
- package/src/Ref.ts +14 -12
- package/src/Relation.test.ts +2 -2
- package/src/Relation.ts +28 -21
- package/src/SchemaRegistry.ts +1 -1
- package/src/Tag.ts +3 -1
- package/src/Type.ts +14 -11
- package/src/View.ts +9 -2
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +4 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +56 -7
- package/src/internal/{annotations → Annotation}/annotations.ts +71 -20
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -4
- package/src/internal/{annotations → Annotation}/util.ts +1 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +3 -2
- package/src/internal/{entities → Entity}/entity.ts +2 -2
- package/src/internal/{entities → Entity}/index.ts +2 -0
- package/src/internal/{entities → Entity}/model.ts +13 -42
- package/src/internal/{entities → Entity}/object.ts +2 -3
- package/src/internal/{entities → Entity}/relation.ts +19 -36
- package/src/internal/{api → Entity}/version.ts +2 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/format.test.ts +1 -2
- package/src/internal/{formats → Format}/types.ts +2 -2
- 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 -49
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +3 -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 +5 -7
- package/src/internal/{object → Obj}/create-object.ts +5 -6
- 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 +8 -9
- package/src/internal/{object → Obj}/json-serializer.ts +36 -18
- 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 +3 -3
- package/src/internal/{object → Obj}/snapshot.ts +14 -5
- package/src/internal/{object → Obj}/typed-object.test.ts +3 -3
- package/src/internal/{object → Obj}/typed-object.ts +2 -2
- package/src/internal/Query.ts +137 -0
- package/src/internal/{ref → Ref}/ref-array.ts +1 -2
- package/src/internal/{ref → Ref}/ref.test.ts +4 -5
- package/src/internal/{ref → Ref}/ref.ts +20 -3
- package/src/internal/{schema → Type}/compose.test.ts +5 -6
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/{schema → Type}/echo-schema.ts +7 -8
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +7 -7
- package/src/internal/{README.md → common/README.md} +1 -1
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/{api → common/api}/meta.ts +3 -3
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change-context.ts +1 -1
- package/src/internal/{proxy → common/proxy}/change.test.ts +97 -97
- package/src/internal/{proxy → common/proxy}/errors.ts +2 -2
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -4
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +6 -3
- package/src/internal/{proxy → common/proxy}/make-object.ts +1 -2
- package/src/internal/{proxy → common/proxy}/ownership.ts +0 -1
- package/src/internal/{proxy → common/proxy}/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/{proxy → common/proxy}/reactive.ts +12 -4
- package/src/internal/{proxy → common/proxy}/schema.test.ts +10 -10
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +6 -7
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +10 -13
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +5 -6
- package/src/internal/{types → common/types}/entity.ts +1 -1
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +1 -2
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +2 -3
- package/src/testing/test-data.ts +0 -1
- package/src/testing/test-schema.ts +9 -9
- package/dist/lib/neutral/chunk-5ELDDYWE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ALOGSVBP.mjs.map +0 -7
- package/dist/lib/neutral/chunk-AQP4QKYP.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BRJSLACP.mjs.map +0 -7
- package/dist/lib/neutral/chunk-F7KMHDPJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-GAWKQ5DZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-GFNCSK7F.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KGV3QIRX.mjs.map +0 -7
- package/dist/lib/neutral/chunk-M2KVTHZM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MXQJZCPY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-O3TZFQCT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OVUBTQLT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PP4DNUZU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-QXF3LGN2.mjs.map +0 -7
- package/dist/lib/neutral/chunk-T4MPQJ7X.mjs.map +0 -7
- package/dist/lib/neutral/chunk-W7OP5HGZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZTUBYOGB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZWKJ4LZJ.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/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/dist/lib/neutral/{chunk-ANHVGJI4.mjs.map → chunk-7RVZT53K.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-OMUPQMLR.mjs.map → chunk-V72DY6LU.mjs.map} +0 -0
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.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.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/{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}/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}/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.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{types → common/types}/base.d.ts +0 -0
- /package/dist/types/src/internal/{types → common/types}/typename.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/{proxy → common/proxy}/define-hidden-property.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}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
- /package/src/internal/{types → common/types}/base.ts +0 -0
- /package/src/internal/{types → common/types}/typename.ts +0 -0
- /package/src/internal/{types → common/types}/version.ts +0 -0
|
@@ -4,22 +4,22 @@
|
|
|
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
|
-
* Tests for Obj.
|
|
12
|
+
* Tests for Obj.update context enforcement and mutator type safety.
|
|
13
13
|
*
|
|
14
14
|
* These tests verify:
|
|
15
15
|
* 1. Mutator functions require Mutable<T> at compile-time.
|
|
16
16
|
* 2. getMeta returns ReadonlyMeta outside change callbacks and ObjectMeta inside.
|
|
17
|
-
* 3. Mutations outside Obj.
|
|
17
|
+
* 3. Mutations outside Obj.update throw at runtime.
|
|
18
18
|
* 4. Nested object/property mutations work correctly.
|
|
19
19
|
* 5. Array mutations (push, pop, splice) require change context.
|
|
20
20
|
* 6. Property delete requires change context.
|
|
21
21
|
*/
|
|
22
|
-
describe('Obj.
|
|
22
|
+
describe('Obj.update enforcement', () => {
|
|
23
23
|
describe('compile-time and runtime safety', () => {
|
|
24
24
|
test('direct property mutation outside change throws', ({ expect }) => {
|
|
25
25
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
@@ -28,7 +28,7 @@ describe('Obj.change enforcement', () => {
|
|
|
28
28
|
expect(() => {
|
|
29
29
|
// @ts-expect-error Testing runtime error for readonly property mutation.
|
|
30
30
|
obj.name = 'New Name';
|
|
31
|
-
}).toThrow(/outside of Obj.
|
|
31
|
+
}).toThrow(/outside of Obj.update/);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
test('Obj.setValue outside change throws', ({ expect }) => {
|
|
@@ -36,7 +36,7 @@ describe('Obj.change enforcement', () => {
|
|
|
36
36
|
|
|
37
37
|
// No compile-time error: TypeScript's structural typing allows readonly objects
|
|
38
38
|
// to be passed to Mutable<T> parameters. Enforcement is runtime-only.
|
|
39
|
-
expect(() => Obj.setValue(obj, ['name'], 'value')).toThrow(/outside of Obj.
|
|
39
|
+
expect(() => Obj.setValue(obj, ['name'], 'value')).toThrow(/outside of Obj.update/);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
test('Obj.addTag outside change throws', ({ expect }) => {
|
|
@@ -44,7 +44,7 @@ describe('Obj.change enforcement', () => {
|
|
|
44
44
|
|
|
45
45
|
// No compile-time error: TypeScript's structural typing allows readonly objects
|
|
46
46
|
// to be passed to Mutable<T> parameters. Enforcement is runtime-only.
|
|
47
|
-
expect(() => Obj.addTag(obj, 'tag')).toThrow(/outside of Obj.
|
|
47
|
+
expect(() => Obj.addTag(obj, 'tag')).toThrow(/outside of Obj.update/);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
test('getMeta mutation outside change throws', ({ expect }) => {
|
|
@@ -52,15 +52,15 @@ describe('Obj.change enforcement', () => {
|
|
|
52
52
|
const meta = Obj.getMeta(obj);
|
|
53
53
|
|
|
54
54
|
// Runtime errors for direct meta mutations.
|
|
55
|
-
expect(() => ((meta as any).keys = [])).toThrow(/outside of Obj.
|
|
56
|
-
expect(() => ((meta as any).tags = ['tag'])).toThrow(/outside of Obj.
|
|
55
|
+
expect(() => ((meta as any).keys = [])).toThrow(/outside of Obj.update/);
|
|
56
|
+
expect(() => ((meta as any).tags = ['tag'])).toThrow(/outside of Obj.update/);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
test('getMeta returns mutable ObjectMeta inside change callback', ({ expect }) => {
|
|
60
60
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
61
61
|
|
|
62
|
-
Obj.
|
|
63
|
-
const meta = Obj.getMeta(
|
|
62
|
+
Obj.update(obj, (obj) => {
|
|
63
|
+
const meta = Obj.getMeta(obj);
|
|
64
64
|
|
|
65
65
|
// These should compile without errors because meta is ObjectMeta (mutable).
|
|
66
66
|
meta.keys = [];
|
|
@@ -76,9 +76,9 @@ describe('Obj.change enforcement', () => {
|
|
|
76
76
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
77
77
|
|
|
78
78
|
// These should compile without errors inside change callback.
|
|
79
|
-
Obj.
|
|
80
|
-
Obj.addTag(
|
|
81
|
-
Obj.setValue(
|
|
79
|
+
Obj.update(obj, (obj) => {
|
|
80
|
+
Obj.addTag(obj, 'my-tag');
|
|
81
|
+
Obj.setValue(obj, ['name'], 'Updated');
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
expect(obj.name).toBe('Updated');
|
|
@@ -97,7 +97,7 @@ describe('Obj.change enforcement', () => {
|
|
|
97
97
|
expect(() => {
|
|
98
98
|
// @ts-expect-error Testing runtime error for readonly property mutation.
|
|
99
99
|
rel.title = 'Manager';
|
|
100
|
-
}).toThrow(/outside of Obj.
|
|
100
|
+
}).toThrow(/outside of Obj.update/);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
test('Relation.addTag outside change throws', ({ expect }) => {
|
|
@@ -110,7 +110,7 @@ describe('Obj.change enforcement', () => {
|
|
|
110
110
|
|
|
111
111
|
// No compile-time error: TypeScript's structural typing allows readonly objects
|
|
112
112
|
// to be passed to Mutable<T> parameters. Enforcement is runtime-only.
|
|
113
|
-
expect(() => Relation.addTag(rel, 'tag')).toThrow(/outside of Obj.
|
|
113
|
+
expect(() => Relation.addTag(rel, 'tag')).toThrow(/outside of Obj.update/);
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
|
|
@@ -122,8 +122,8 @@ describe('Obj.change enforcement', () => {
|
|
|
122
122
|
// Person schema uses 'name' as label field.
|
|
123
123
|
expect(Obj.getLabel(obj)).toBe('John');
|
|
124
124
|
|
|
125
|
-
Obj.
|
|
126
|
-
Obj.setLabel(
|
|
125
|
+
Obj.update(obj, (obj) => {
|
|
126
|
+
Obj.setLabel(obj, 'Jane');
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
// setLabel updates the name field.
|
|
@@ -140,8 +140,8 @@ describe('Obj.change enforcement', () => {
|
|
|
140
140
|
|
|
141
141
|
// setDescription only works if schema has description annotation.
|
|
142
142
|
// For schemas without it, this is a no-op.
|
|
143
|
-
Obj.
|
|
144
|
-
Obj.setDescription(
|
|
143
|
+
Obj.update(obj, (obj) => {
|
|
144
|
+
Obj.setDescription(obj, 'My Description');
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
// Verify setDescription doesn't throw.
|
|
@@ -153,15 +153,15 @@ describe('Obj.change enforcement', () => {
|
|
|
153
153
|
|
|
154
154
|
expect(Obj.getMeta(obj).tags).toBeUndefined();
|
|
155
155
|
|
|
156
|
-
Obj.
|
|
157
|
-
Obj.addTag(
|
|
158
|
-
Obj.addTag(
|
|
156
|
+
Obj.update(obj, (obj) => {
|
|
157
|
+
Obj.addTag(obj, 'tag-1');
|
|
158
|
+
Obj.addTag(obj, 'tag-2');
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
expect(Obj.getMeta(obj).tags).toEqual(['tag-1', 'tag-2']);
|
|
162
162
|
|
|
163
|
-
Obj.
|
|
164
|
-
Obj.removeTag(
|
|
163
|
+
Obj.update(obj, (obj) => {
|
|
164
|
+
Obj.removeTag(obj, 'tag-1');
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
expect(Obj.getMeta(obj).tags).toEqual(['tag-2']);
|
|
@@ -170,8 +170,8 @@ describe('Obj.change enforcement', () => {
|
|
|
170
170
|
test('deleteKeys removes foreign keys by source', ({ expect }) => {
|
|
171
171
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
172
172
|
|
|
173
|
-
Obj.
|
|
174
|
-
const meta = Obj.getMeta(
|
|
173
|
+
Obj.update(obj, (obj) => {
|
|
174
|
+
const meta = Obj.getMeta(obj);
|
|
175
175
|
meta.keys.push({ source: 'source-a', id: '1' });
|
|
176
176
|
meta.keys.push({ source: 'source-a', id: '2' });
|
|
177
177
|
meta.keys.push({ source: 'source-b', id: '3' });
|
|
@@ -179,8 +179,8 @@ describe('Obj.change enforcement', () => {
|
|
|
179
179
|
|
|
180
180
|
expect(Obj.getMeta(obj).keys).toHaveLength(3);
|
|
181
181
|
|
|
182
|
-
Obj.
|
|
183
|
-
Obj.deleteKeys(
|
|
182
|
+
Obj.update(obj, (obj) => {
|
|
183
|
+
Obj.deleteKeys(obj, 'source-a');
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
expect(Obj.getMeta(obj).keys).toHaveLength(1);
|
|
@@ -190,8 +190,8 @@ describe('Obj.change enforcement', () => {
|
|
|
190
190
|
test('setValue sets nested properties', ({ expect }) => {
|
|
191
191
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
192
192
|
|
|
193
|
-
Obj.
|
|
194
|
-
Obj.setValue(
|
|
193
|
+
Obj.update(obj, (obj) => {
|
|
194
|
+
Obj.setValue(obj, ['name'], 'Updated Name');
|
|
195
195
|
});
|
|
196
196
|
|
|
197
197
|
expect(obj.name).toBe('Updated Name');
|
|
@@ -200,8 +200,8 @@ describe('Obj.change enforcement', () => {
|
|
|
200
200
|
test('getMeta is mutable inside change and changes persist', ({ expect }) => {
|
|
201
201
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
202
202
|
|
|
203
|
-
Obj.
|
|
204
|
-
const meta = Obj.getMeta(
|
|
203
|
+
Obj.update(obj, (obj) => {
|
|
204
|
+
const meta = Obj.getMeta(obj);
|
|
205
205
|
meta.tags = ['tag-1', 'tag-2'];
|
|
206
206
|
meta.keys.push({ source: 'external', id: '123' });
|
|
207
207
|
});
|
|
@@ -214,12 +214,12 @@ describe('Obj.change enforcement', () => {
|
|
|
214
214
|
test('multiple mutations in single change all persist', ({ expect }) => {
|
|
215
215
|
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
216
216
|
|
|
217
|
-
Obj.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
Obj.addTag(
|
|
222
|
-
Obj.addTag(
|
|
217
|
+
Obj.update(obj, (obj) => {
|
|
218
|
+
obj.name = 'Name 1';
|
|
219
|
+
obj.name = 'Name 2';
|
|
220
|
+
obj.name = 'Name 3';
|
|
221
|
+
Obj.addTag(obj, 'tag-1');
|
|
222
|
+
Obj.addTag(obj, 'tag-2');
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
// All mutations should persist.
|
|
@@ -229,7 +229,7 @@ describe('Obj.change enforcement', () => {
|
|
|
229
229
|
});
|
|
230
230
|
|
|
231
231
|
describe('notifications', () => {
|
|
232
|
-
test('batched notifications - only one per Obj.
|
|
232
|
+
test('batched notifications - only one per Obj.update', ({ expect }) => {
|
|
233
233
|
const obj = Obj.make(TestSchema.Person, { name: 'John' });
|
|
234
234
|
|
|
235
235
|
let notificationCount = 0;
|
|
@@ -237,9 +237,9 @@ describe('Obj.change enforcement', () => {
|
|
|
237
237
|
notificationCount++;
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
Obj.
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
Obj.update(obj, (obj) => {
|
|
241
|
+
obj.name = 'Jane';
|
|
242
|
+
obj.age = 30;
|
|
243
243
|
});
|
|
244
244
|
|
|
245
245
|
// Should only fire one notification for all changes.
|
|
@@ -250,36 +250,36 @@ describe('Obj.change enforcement', () => {
|
|
|
250
250
|
});
|
|
251
251
|
|
|
252
252
|
describe('nested mutations', () => {
|
|
253
|
-
test('nested object property mutation within Obj.
|
|
253
|
+
test('nested object property mutation within Obj.update', ({ expect }) => {
|
|
254
254
|
const obj = Obj.make(TestSchema.Person, {
|
|
255
255
|
name: 'John',
|
|
256
256
|
address: { city: 'NYC', coordinates: {} },
|
|
257
257
|
});
|
|
258
258
|
|
|
259
|
-
Obj.
|
|
260
|
-
|
|
259
|
+
Obj.update(obj, (obj) => {
|
|
260
|
+
obj.address!.state = 'NY';
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
expect(obj.address?.state).toBe('NY');
|
|
264
264
|
expect(obj.address?.city).toBe('NYC');
|
|
265
265
|
});
|
|
266
266
|
|
|
267
|
-
test('deeply nested property mutation within Obj.
|
|
267
|
+
test('deeply nested property mutation within Obj.update (2 levels)', ({ expect }) => {
|
|
268
268
|
const obj = Obj.make(TestSchema.Person, {
|
|
269
269
|
name: 'John',
|
|
270
270
|
address: { city: 'NYC', coordinates: { lat: 40.7128, lng: -74.006 } },
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
-
Obj.
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
Obj.update(obj, (obj) => {
|
|
274
|
+
obj.address!.coordinates!.lat = 51.5074;
|
|
275
|
+
obj.address!.coordinates!.lng = -0.1278;
|
|
276
276
|
});
|
|
277
277
|
|
|
278
278
|
expect(obj.address?.coordinates?.lat).toBe(51.5074);
|
|
279
279
|
expect(obj.address?.coordinates?.lng).toBe(-0.1278);
|
|
280
280
|
});
|
|
281
281
|
|
|
282
|
-
test('nested object mutation outside Obj.
|
|
282
|
+
test('nested object mutation outside Obj.update throws (1 level deep)', ({ expect }) => {
|
|
283
283
|
const obj = Obj.make(TestSchema.Person, {
|
|
284
284
|
name: 'John',
|
|
285
285
|
address: { city: 'NYC', coordinates: {} },
|
|
@@ -288,10 +288,10 @@ describe('Obj.change enforcement', () => {
|
|
|
288
288
|
expect(() => {
|
|
289
289
|
// @ts-expect-error - nested property assignment is readonly.
|
|
290
290
|
obj.address!.city = 'LA';
|
|
291
|
-
}).toThrow(/outside of Obj.
|
|
291
|
+
}).toThrow(/outside of Obj.update/);
|
|
292
292
|
});
|
|
293
293
|
|
|
294
|
-
test('deeply nested mutation outside Obj.
|
|
294
|
+
test('deeply nested mutation outside Obj.update throws (2 levels deep)', ({ expect }) => {
|
|
295
295
|
const obj = Obj.make(TestSchema.Person, {
|
|
296
296
|
name: 'John',
|
|
297
297
|
address: { city: 'NYC', coordinates: { lat: 40.7128, lng: -74.006 } },
|
|
@@ -300,18 +300,18 @@ describe('Obj.change enforcement', () => {
|
|
|
300
300
|
expect(() => {
|
|
301
301
|
// @ts-expect-error - deeply nested property assignment should be caught.
|
|
302
302
|
obj.address!.coordinates!.lat = 0;
|
|
303
|
-
}).toThrow(/outside of Obj.
|
|
303
|
+
}).toThrow(/outside of Obj.update/);
|
|
304
304
|
});
|
|
305
305
|
|
|
306
|
-
test('nested Obj.
|
|
306
|
+
test('nested Obj.update calls work correctly', ({ expect }) => {
|
|
307
307
|
const obj = Obj.make(TestSchema.Person, { name: 'John' });
|
|
308
308
|
|
|
309
|
-
Obj.
|
|
310
|
-
|
|
309
|
+
Obj.update(obj, (obj) => {
|
|
310
|
+
obj.name = 'Jane';
|
|
311
311
|
|
|
312
312
|
// Nested change should work (already in change context).
|
|
313
|
-
Obj.
|
|
314
|
-
|
|
313
|
+
Obj.update(obj, (obj) => {
|
|
314
|
+
obj.age = 30;
|
|
315
315
|
});
|
|
316
316
|
});
|
|
317
317
|
|
|
@@ -323,8 +323,8 @@ describe('Obj.change enforcement', () => {
|
|
|
323
323
|
const obj = Obj.make(TestSchema.Person, { name: 'John' });
|
|
324
324
|
|
|
325
325
|
expect(() => {
|
|
326
|
-
Obj.
|
|
327
|
-
|
|
326
|
+
Obj.update(obj, (obj) => {
|
|
327
|
+
obj.name = 'Jane';
|
|
328
328
|
throw new Error('Test error');
|
|
329
329
|
});
|
|
330
330
|
}).toThrow('Test error');
|
|
@@ -333,26 +333,26 @@ describe('Obj.change enforcement', () => {
|
|
|
333
333
|
expect(() => {
|
|
334
334
|
// @ts-expect-error Testing runtime error for readonly property mutation.
|
|
335
335
|
obj.name = 'Bob';
|
|
336
|
-
}).toThrow(/outside of Obj.
|
|
336
|
+
}).toThrow(/outside of Obj.update/);
|
|
337
337
|
});
|
|
338
338
|
});
|
|
339
339
|
|
|
340
340
|
describe('array mutations', () => {
|
|
341
|
-
test('array push within Obj.
|
|
341
|
+
test('array push within Obj.update', ({ expect }) => {
|
|
342
342
|
const obj = Obj.make(TestSchema.Person, {
|
|
343
343
|
name: 'John',
|
|
344
344
|
fields: [{ label: 'tag1', value: 'val1' }],
|
|
345
345
|
});
|
|
346
346
|
|
|
347
|
-
Obj.
|
|
348
|
-
|
|
347
|
+
Obj.update(obj, (obj) => {
|
|
348
|
+
obj.fields!.push({ label: 'tag2', value: 'val2' });
|
|
349
349
|
});
|
|
350
350
|
|
|
351
351
|
expect(obj.fields).toHaveLength(2);
|
|
352
352
|
expect(obj.fields![1].label).toBe('tag2');
|
|
353
353
|
});
|
|
354
354
|
|
|
355
|
-
test('array pop within Obj.
|
|
355
|
+
test('array pop within Obj.update', ({ expect }) => {
|
|
356
356
|
const obj = Obj.make(TestSchema.Person, {
|
|
357
357
|
name: 'John',
|
|
358
358
|
fields: [
|
|
@@ -362,15 +362,15 @@ describe('Obj.change enforcement', () => {
|
|
|
362
362
|
});
|
|
363
363
|
|
|
364
364
|
let popped: any;
|
|
365
|
-
Obj.
|
|
366
|
-
popped =
|
|
365
|
+
Obj.update(obj, (obj) => {
|
|
366
|
+
popped = obj.fields!.pop();
|
|
367
367
|
});
|
|
368
368
|
|
|
369
369
|
expect(popped.label).toBe('b');
|
|
370
370
|
expect(obj.fields).toHaveLength(1);
|
|
371
371
|
});
|
|
372
372
|
|
|
373
|
-
test('array splice within Obj.
|
|
373
|
+
test('array splice within Obj.update', ({ expect }) => {
|
|
374
374
|
const obj = Obj.make(TestSchema.Person, {
|
|
375
375
|
name: 'John',
|
|
376
376
|
fields: [
|
|
@@ -380,15 +380,15 @@ describe('Obj.change enforcement', () => {
|
|
|
380
380
|
],
|
|
381
381
|
});
|
|
382
382
|
|
|
383
|
-
Obj.
|
|
384
|
-
|
|
383
|
+
Obj.update(obj, (obj) => {
|
|
384
|
+
obj.fields!.splice(1, 1, { label: 'x', value: 'x' });
|
|
385
385
|
});
|
|
386
386
|
|
|
387
387
|
expect(obj.fields).toHaveLength(3);
|
|
388
388
|
expect(obj.fields![1].label).toBe('x');
|
|
389
389
|
});
|
|
390
390
|
|
|
391
|
-
test('array push outside Obj.
|
|
391
|
+
test('array push outside Obj.update throws', ({ expect }) => {
|
|
392
392
|
const obj = Obj.make(TestSchema.Person, {
|
|
393
393
|
name: 'John',
|
|
394
394
|
fields: [{ label: 'tag1', value: 'val1' }],
|
|
@@ -397,10 +397,10 @@ describe('Obj.change enforcement', () => {
|
|
|
397
397
|
expect(() => {
|
|
398
398
|
// @ts-expect-error Testing runtime error for readonly array mutation.
|
|
399
399
|
obj.fields!.push({ label: 'tag2', value: 'val2' });
|
|
400
|
-
}).toThrow(/array\.push\(\).*outside of Obj\.
|
|
400
|
+
}).toThrow(/array\.push\(\).*outside of Obj\.update/);
|
|
401
401
|
});
|
|
402
402
|
|
|
403
|
-
test('array pop outside Obj.
|
|
403
|
+
test('array pop outside Obj.update throws', ({ expect }) => {
|
|
404
404
|
const obj = Obj.make(TestSchema.Person, {
|
|
405
405
|
name: 'John',
|
|
406
406
|
fields: [{ label: 'tag1', value: 'val1' }],
|
|
@@ -409,10 +409,10 @@ describe('Obj.change enforcement', () => {
|
|
|
409
409
|
expect(() => {
|
|
410
410
|
// @ts-expect-error Testing runtime error for readonly array mutation.
|
|
411
411
|
obj.fields!.pop();
|
|
412
|
-
}).toThrow(/array\.pop\(\).*outside of Obj\.
|
|
412
|
+
}).toThrow(/array\.pop\(\).*outside of Obj\.update/);
|
|
413
413
|
});
|
|
414
414
|
|
|
415
|
-
test('array splice outside Obj.
|
|
415
|
+
test('array splice outside Obj.update throws', ({ expect }) => {
|
|
416
416
|
const obj = Obj.make(TestSchema.Person, {
|
|
417
417
|
name: 'John',
|
|
418
418
|
fields: [{ label: 'tag1', value: 'val1' }],
|
|
@@ -421,33 +421,33 @@ describe('Obj.change enforcement', () => {
|
|
|
421
421
|
expect(() => {
|
|
422
422
|
// @ts-expect-error Testing runtime error for readonly array mutation.
|
|
423
423
|
obj.fields!.splice(0, 1);
|
|
424
|
-
}).toThrow(/array\.splice\(\).*outside of Obj\.
|
|
424
|
+
}).toThrow(/array\.splice\(\).*outside of Obj\.update/);
|
|
425
425
|
});
|
|
426
426
|
});
|
|
427
427
|
|
|
428
428
|
describe('property delete', () => {
|
|
429
|
-
test('delete property within Obj.
|
|
429
|
+
test('delete property within Obj.update', ({ expect }) => {
|
|
430
430
|
const obj = Obj.make(TestSchema.Person, { name: 'John', age: 25 });
|
|
431
431
|
|
|
432
|
-
Obj.
|
|
433
|
-
delete
|
|
432
|
+
Obj.update(obj, (obj) => {
|
|
433
|
+
delete obj.age;
|
|
434
434
|
});
|
|
435
435
|
|
|
436
436
|
expect(obj.age).toBeUndefined();
|
|
437
437
|
});
|
|
438
438
|
|
|
439
|
-
test('delete property outside Obj.
|
|
439
|
+
test('delete property outside Obj.update throws', ({ expect }) => {
|
|
440
440
|
const obj = Obj.make(TestSchema.Person, { name: 'John', age: 25 });
|
|
441
441
|
|
|
442
442
|
expect(() => {
|
|
443
443
|
// @ts-expect-error Testing runtime error for readonly property delete.
|
|
444
444
|
delete obj.age;
|
|
445
|
-
}).toThrow(/delete object property.*outside of Obj\.
|
|
445
|
+
}).toThrow(/delete object property.*outside of Obj\.update/);
|
|
446
446
|
});
|
|
447
447
|
});
|
|
448
448
|
|
|
449
449
|
describe('Relation mutators', () => {
|
|
450
|
-
test('Relation.getMeta is mutable inside Relation.
|
|
450
|
+
test('Relation.getMeta is mutable inside Relation.update', ({ expect }) => {
|
|
451
451
|
const source = Obj.make(TestSchema.Person, { name: 'Alice' });
|
|
452
452
|
const target = Obj.make(TestSchema.Person, { name: 'Bob' });
|
|
453
453
|
const rel = Relation.make(TestSchema.HasManager, {
|
|
@@ -455,8 +455,8 @@ describe('Obj.change enforcement', () => {
|
|
|
455
455
|
[Relation.Target]: target,
|
|
456
456
|
});
|
|
457
457
|
|
|
458
|
-
Relation.
|
|
459
|
-
const meta = Relation.getMeta(
|
|
458
|
+
Relation.update(rel, (rel) => {
|
|
459
|
+
const meta = Relation.getMeta(rel);
|
|
460
460
|
meta.tags = ['rel-tag'];
|
|
461
461
|
meta.keys.push({ source: 'rel-source', id: 'rel-key' });
|
|
462
462
|
});
|
|
@@ -473,14 +473,14 @@ describe('Obj.change enforcement', () => {
|
|
|
473
473
|
[Relation.Target]: target,
|
|
474
474
|
});
|
|
475
475
|
|
|
476
|
-
Relation.
|
|
477
|
-
Relation.addTag(
|
|
476
|
+
Relation.update(rel, (rel) => {
|
|
477
|
+
Relation.addTag(rel, 'important');
|
|
478
478
|
});
|
|
479
479
|
|
|
480
480
|
expect(Relation.getMeta(rel).tags).toContain('important');
|
|
481
481
|
|
|
482
|
-
Relation.
|
|
483
|
-
Relation.removeTag(
|
|
482
|
+
Relation.update(rel, (rel) => {
|
|
483
|
+
Relation.removeTag(rel, 'important');
|
|
484
484
|
});
|
|
485
485
|
|
|
486
486
|
expect(Relation.getMeta(rel).tags).not.toContain('important');
|
|
@@ -494,8 +494,8 @@ describe('Obj.change enforcement', () => {
|
|
|
494
494
|
|
|
495
495
|
// Direct assignment of root ECHO objects (created with Obj.make) is not allowed.
|
|
496
496
|
expect(() => {
|
|
497
|
-
Obj.
|
|
498
|
-
|
|
497
|
+
Obj.update(obj, (obj) => {
|
|
498
|
+
obj.other = other;
|
|
499
499
|
});
|
|
500
500
|
}).toThrow(/Object references must be wrapped with `Ref\.make`/);
|
|
501
501
|
});
|
|
@@ -504,14 +504,14 @@ describe('Obj.change enforcement', () => {
|
|
|
504
504
|
const obj = Obj.make(TestSchema.Expando, {});
|
|
505
505
|
|
|
506
506
|
// Assign a plain object (not created with Obj.make).
|
|
507
|
-
Obj.
|
|
508
|
-
|
|
507
|
+
Obj.update(obj, (obj) => {
|
|
508
|
+
obj.nested = { value: 'initial' };
|
|
509
509
|
});
|
|
510
510
|
expect(obj.nested.value).toBe('initial');
|
|
511
511
|
|
|
512
512
|
// Modify plain nested object through parent's change context.
|
|
513
|
-
Obj.
|
|
514
|
-
|
|
513
|
+
Obj.update(obj, (obj) => {
|
|
514
|
+
obj.nested.value = 'modified';
|
|
515
515
|
});
|
|
516
516
|
expect(obj.nested.value).toBe('modified');
|
|
517
517
|
});
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Error thrown when attempting to mutate an object outside of an Obj.
|
|
6
|
+
* Error thrown when attempting to mutate an object outside of an Obj.update() context.
|
|
7
7
|
*/
|
|
8
8
|
export class MutationOutsideChangeContextError extends Error {
|
|
9
9
|
constructor(operation: string, suggestion: string) {
|
|
10
10
|
super(
|
|
11
|
-
`Cannot ${operation} outside of Obj.
|
|
11
|
+
`Cannot ${operation} outside of Obj.update(). Use Obj.update(obj, (mutableObj) => { ${suggestion} }) instead.`,
|
|
12
12
|
);
|
|
13
13
|
this.name = 'MutationOutsideChangeContextError';
|
|
14
14
|
}
|
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { inspect } from 'node:util';
|
|
6
|
-
|
|
7
6
|
import { describe, expect, test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { isNode } from '@dxos/util';
|
|
10
9
|
|
|
11
|
-
import { TestSchema, updateCounter } from '
|
|
12
|
-
import { createObject } from '
|
|
10
|
+
import { TestSchema, updateCounter } from '../../../testing';
|
|
11
|
+
import { createObject } from '../../Obj';
|
|
13
12
|
import { ATTR_META } from '../types';
|
|
14
|
-
|
|
15
13
|
import { makeObject } from './make-object';
|
|
16
14
|
import { objectData } from './proxy-types';
|
|
17
15
|
import { change } from './reactive';
|
|
@@ -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,9 +6,8 @@ import type * as Schema from 'effect/Schema';
|
|
|
6
6
|
|
|
7
7
|
import { ObjectId } from '@dxos/keys';
|
|
8
8
|
|
|
9
|
-
import { getTypeAnnotation } from '
|
|
9
|
+
import { getTypeAnnotation } from '../../Annotation';
|
|
10
10
|
import { type AnyProperties, KindId, MetaId, type ObjectMeta, ObjectMetaSchema, ParentId } from '../types';
|
|
11
|
-
|
|
12
11
|
import { defineHiddenProperty } from './define-hidden-property';
|
|
13
12
|
import { attachTypedJsonSerializer } from './json-serializer';
|
|
14
13
|
import { createProxy, getProxyTarget, isValidProxyTarget } from './proxy-utils';
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { invariant } from '@dxos/invariant';
|
|
6
6
|
|
|
7
7
|
import { KindId } from '../types';
|
|
8
|
-
|
|
9
8
|
import { queueOwnerNotification } from './change-context';
|
|
10
9
|
import { defineHiddenProperty } from './define-hidden-property';
|
|
11
10
|
import { getProxyTarget, isProxy, isValidProxyTarget } from './proxy-utils';
|
|
@@ -34,7 +34,7 @@ const checkArrayMutationAllowed = (arr: any, method: string): void => {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Extends the native array to make sure that arrays methods are correctly reactive.
|
|
37
|
-
* Enforces that mutations only happen within Obj.
|
|
37
|
+
* Enforces that mutations only happen within Obj.update() context.
|
|
38
38
|
*/
|
|
39
39
|
export class ReactiveArray<T> extends Array<T> {
|
|
40
40
|
static override get [Symbol.species]() {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import * as Obj from '../../../Obj';
|
|
8
|
+
import { TestSchema } from '../../../testing';
|
|
9
|
+
|
|
10
|
+
describe('Obj.subscribe', () => {
|
|
11
|
+
test('subscribes and fires for reactive proxies', () => {
|
|
12
|
+
const obj = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
13
|
+
let calls = 0;
|
|
14
|
+
const unsubscribe = Obj.subscribe(obj, () => {
|
|
15
|
+
calls++;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
Obj.update(obj, (obj) => {
|
|
19
|
+
obj.name = 'Updated';
|
|
20
|
+
});
|
|
21
|
+
expect(calls).toBeGreaterThan(0);
|
|
22
|
+
|
|
23
|
+
unsubscribe();
|
|
24
|
+
const seen = calls;
|
|
25
|
+
Obj.update(obj, (obj) => {
|
|
26
|
+
obj.name = 'After unsubscribe';
|
|
27
|
+
});
|
|
28
|
+
expect(calls).toBe(seen);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Regression: queue-stored typed objects (e.g. ContextBinding) and other Obj-shaped values
|
|
32
|
+
// satisfy `Obj.isObject` (KindId is set) but are not wrapped in a reactive Proxy. Earlier
|
|
33
|
+
// versions invariant'd inside `getProxyTarget` when an atom body did `Obj.subscribe(obj)` on
|
|
34
|
+
// such an input. The contract is "no-op for non-reactive inputs"; verify the function
|
|
35
|
+
// returns gracefully instead of throwing.
|
|
36
|
+
test('returns a no-op unsubscribe for non-proxy inputs', () => {
|
|
37
|
+
const queueShaped: any = {
|
|
38
|
+
id: '01KQ5NKXJWSKMRPVTVG2GHV8V3',
|
|
39
|
+
blueprints: { added: [], removed: [] },
|
|
40
|
+
objects: { added: [], removed: [] },
|
|
41
|
+
};
|
|
42
|
+
const unsubscribe = Obj.subscribe(queueShaped, () => {});
|
|
43
|
+
expect(typeof unsubscribe).toBe('function');
|
|
44
|
+
expect(() => unsubscribe()).not.toThrow();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('returns a no-op unsubscribe for primitives, null, and undefined', () => {
|
|
48
|
+
for (const value of [null, undefined, 42, 'string', true]) {
|
|
49
|
+
const unsubscribe = Obj.subscribe(value as any, () => {});
|
|
50
|
+
expect(typeof unsubscribe).toBe('function');
|
|
51
|
+
expect(() => unsubscribe()).not.toThrow();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|