@dxos/echo 0.8.4-main.c85a9c8dae → 0.8.4-main.d05673bc65
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 +4 -4
- package/dist/lib/neutral/Entity.mjs +10 -7
- package/dist/lib/neutral/Err.mjs +1 -1
- package/dist/lib/neutral/Feed.mjs +13 -10
- package/dist/lib/neutral/Filter.mjs +11 -8
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +8 -7
- package/dist/lib/neutral/Obj.mjs +11 -8
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +16 -13
- package/dist/lib/neutral/Ref.mjs +7 -7
- package/dist/lib/neutral/Relation.mjs +12 -9
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +13 -10
- package/dist/lib/neutral/Type.mjs +10 -7
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs +396 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-GAWKQ5DZ.mjs → chunk-724GQYEN.mjs} +5 -5
- package/dist/lib/neutral/chunk-724GQYEN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-M2KVTHZM.mjs → chunk-B5OXLWZL.mjs} +10 -10
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-T6JEFNP6.mjs → chunk-BNCCGLJN.mjs} +1 -1
- package/dist/lib/neutral/{chunk-T6JEFNP6.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-ZWKJ4LZJ.mjs → chunk-CIRHIEMW.mjs} +16 -16
- package/dist/lib/neutral/chunk-CIRHIEMW.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-GFNCSK7F.mjs → chunk-DYDJBZEG.mjs} +10 -9
- package/dist/lib/neutral/chunk-DYDJBZEG.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QXF3LGN2.mjs → chunk-FXEG7EOK.mjs} +5 -3
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DZQSL6RW.mjs → chunk-FZO7LQO7.mjs} +2 -2
- package/dist/lib/neutral/{chunk-DZQSL6RW.mjs.map → chunk-FZO7LQO7.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-AQP4QKYP.mjs → chunk-KTAWP7GI.mjs} +8 -8
- package/dist/lib/neutral/chunk-KTAWP7GI.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-5ELDDYWE.mjs → chunk-NEGC54NE.mjs} +4 -4
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-KGV3QIRX.mjs → chunk-NQRLRYJM.mjs} +11 -11
- package/dist/lib/neutral/chunk-NQRLRYJM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ALOGSVBP.mjs → chunk-NXMFBIT5.mjs} +3 -3
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OVUBTQLT.mjs → chunk-OENWMTE6.mjs} +2 -2
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-T4MPQJ7X.mjs → chunk-RMLF7JOZ.mjs} +6 -6
- package/dist/lib/neutral/chunk-RMLF7JOZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-F7KMHDPJ.mjs → chunk-SEMVAGBM.mjs} +41 -13
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-PP4DNUZU.mjs → chunk-TQQZLKB7.mjs} +1541 -2748
- package/dist/lib/neutral/chunk-TQQZLKB7.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MXQJZCPY.mjs → chunk-UBEZSGXY.mjs} +1 -1
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-W7OP5HGZ.mjs → chunk-UFDK26FO.mjs} +6 -6
- package/dist/lib/neutral/chunk-UFDK26FO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZTUBYOGB.mjs → chunk-UI6MWK5W.mjs} +1 -1
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-O3TZFQCT.mjs → chunk-UTBRYVQC.mjs} +2 -2
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BRJSLACP.mjs → chunk-VA2F47ZC.mjs} +12 -12
- package/dist/lib/neutral/chunk-VA2F47ZC.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4KG6IGL4.mjs → chunk-WYOKA6AE.mjs} +4 -4
- package/dist/lib/neutral/{chunk-4KG6IGL4.mjs.map → chunk-WYOKA6AE.mjs.map} +2 -2
- 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 +24 -21
- package/dist/lib/neutral/internal/index.mjs +44 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +35 -31
- 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 +3 -3
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +4 -4
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts.map +1 -1
- 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/JsonSchema.d.ts +5 -5
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +4 -2
- 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.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 +2 -1
- 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.map +1 -1
- package/dist/types/src/Type.d.ts +12 -11
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +23 -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 +1 -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 +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/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 +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/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 +2 -2
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts.map +1 -1
- 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 +5 -5
- 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/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 +1 -1
- 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/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 +7 -7
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/Annotation.ts +5 -3
- package/src/Collection.ts +3 -1
- package/src/Database.ts +6 -4
- package/src/Dataset.ts +2 -0
- package/src/Entity.ts +3 -0
- package/src/Err.ts +2 -0
- package/src/Feed.ts +8 -5
- package/src/Filter.ts +2 -0
- package/src/Format.ts +1 -1
- package/src/Hypergraph.ts +7 -2
- package/src/JsonSchema.ts +7 -5
- package/src/Obj.test.ts +2 -2
- package/src/Obj.ts +15 -9
- package/src/Order.ts +2 -0
- package/src/Query.test.ts +23 -23
- package/src/Query.ts +4 -2
- package/src/Ref.ts +14 -12
- package/src/Relation.test.ts +2 -2
- package/src/Relation.ts +6 -3
- package/src/SchemaRegistry.ts +1 -1
- package/src/Tag.ts +3 -1
- package/src/Type.ts +14 -11
- package/src/View.ts +4 -2
- package/src/internal/{annotations → Annotation}/annotations.test.ts +6 -6
- package/src/internal/{annotations → Annotation}/annotations.ts +56 -11
- 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 +1 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +4 -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 -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 +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 -48
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +3 -3
- 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 +6 -6
- package/src/internal/{object → Obj}/json-serializer.ts +17 -6
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.ts +2 -2
- 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/{ref → Ref}/ref-array.ts +1 -1
- package/src/internal/{ref → Ref}/ref.test.ts +4 -4
- package/src/internal/{ref → Ref}/ref.ts +3 -3
- 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 +6 -6
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +5 -5
- 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 +1 -1
- 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 +2 -3
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +4 -4
- 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 -1
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/index.ts +8 -31
- package/src/testing/api.test.ts +2 -2
- 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/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.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/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.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/dist/types/src/internal/{types → common/types}/version.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/{README.md → common/README.md} +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
- /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
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
2
|
+
JsonSchemaFields,
|
|
3
|
+
JsonSchemaType,
|
|
4
|
+
toEffectSchema,
|
|
5
|
+
toJsonSchema
|
|
6
|
+
} from "./chunk-BOZZPUXE.mjs";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Ref,
|
|
9
|
+
refFromEncodedReference,
|
|
10
|
+
setRefResolver
|
|
11
|
+
} from "./chunk-43Y5DOS6.mjs";
|
|
10
12
|
import {
|
|
11
13
|
ATTR_PARENT,
|
|
12
14
|
ATTR_TYPE,
|
|
13
|
-
GeneratorAnnotationId,
|
|
14
15
|
IconAnnotation,
|
|
15
16
|
LabelAnnotation,
|
|
16
|
-
LabelAnnotationId,
|
|
17
17
|
ParentId,
|
|
18
|
-
PropertyMetaAnnotationId,
|
|
19
|
-
ReferenceAnnotationId,
|
|
20
18
|
SchemaId,
|
|
21
19
|
SchemaMetaSymbol,
|
|
22
20
|
TypeAnnotationId,
|
|
@@ -24,9 +22,8 @@ import {
|
|
|
24
22
|
TypeIdentifierAnnotationId,
|
|
25
23
|
TypenameSchema,
|
|
26
24
|
VersionSchema,
|
|
27
|
-
getDescriptionWithSchema,
|
|
28
25
|
getEntityKind,
|
|
29
|
-
|
|
26
|
+
getLabel,
|
|
30
27
|
getSchema,
|
|
31
28
|
getSchemaDXN,
|
|
32
29
|
getSchemaTypename,
|
|
@@ -34,26 +31,21 @@ import {
|
|
|
34
31
|
getTypeDXN,
|
|
35
32
|
getTypeIdentifierAnnotation,
|
|
36
33
|
getTypename,
|
|
37
|
-
setDescriptionWithSchema,
|
|
38
|
-
setLabelWithSchema,
|
|
39
34
|
setSchema,
|
|
40
35
|
setTypename
|
|
41
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-SEMVAGBM.mjs";
|
|
42
37
|
import {
|
|
43
|
-
ANY_OBJECT_TYPENAME,
|
|
44
|
-
ANY_OBJECT_VERSION,
|
|
45
38
|
EntityKind,
|
|
46
|
-
EntityKindSchema,
|
|
47
39
|
KindId,
|
|
48
40
|
SchemaKindId,
|
|
49
41
|
SnapshotKindId,
|
|
50
42
|
makeTypeJsonSchemaAnnotation
|
|
51
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-WYOKA6AE.mjs";
|
|
52
44
|
|
|
53
45
|
// src/internal/index.ts
|
|
54
|
-
import { JsonPath
|
|
46
|
+
import { JsonPath, JsonProp, getValue, splitJsonPath } from "@dxos/effect";
|
|
55
47
|
|
|
56
|
-
// src/internal/types/base.ts
|
|
48
|
+
// src/internal/common/types/base.ts
|
|
57
49
|
import * as Schema from "effect/Schema";
|
|
58
50
|
import * as SchemaAST from "effect/SchemaAST";
|
|
59
51
|
var RawObject = (schema) => {
|
|
@@ -62,12 +54,12 @@ var RawObject = (schema) => {
|
|
|
62
54
|
]));
|
|
63
55
|
};
|
|
64
56
|
|
|
65
|
-
// src/internal/types/meta.ts
|
|
57
|
+
// src/internal/common/types/meta.ts
|
|
66
58
|
import * as Schema2 from "effect/Schema";
|
|
67
59
|
import { ForeignKey } from "@dxos/echo-protocol";
|
|
68
60
|
import { invariant } from "@dxos/invariant";
|
|
69
61
|
import { intersection } from "@dxos/util";
|
|
70
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/types/meta.ts";
|
|
62
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/types/meta.ts";
|
|
71
63
|
var ATTR_META = "@meta";
|
|
72
64
|
var MetaId = /* @__PURE__ */ Symbol.for("@dxos/echo/Meta");
|
|
73
65
|
var ObjectMetaSchema = Schema2.Struct({
|
|
@@ -102,2801 +94,1631 @@ var foreignKey = (source, id) => ({
|
|
|
102
94
|
var foreignKeyEquals = (a, b) => a.source === b.source && a.id === b.id;
|
|
103
95
|
var compareForeignKeys = (a, b) => intersection(getMeta(a).keys, getMeta(b).keys, foreignKeyEquals).length > 0;
|
|
104
96
|
|
|
105
|
-
// src/internal/types/
|
|
97
|
+
// src/internal/common/types/model-symbols.ts
|
|
98
|
+
var ATTR_SELF_DXN = "@dxn";
|
|
99
|
+
var SelfDXNId = /* @__PURE__ */ Symbol.for("@dxos/echo/DXN");
|
|
100
|
+
var ATTR_DELETED = "@deleted";
|
|
101
|
+
var ObjectDeletedId = /* @__PURE__ */ Symbol.for("@dxos/echo/Deleted");
|
|
102
|
+
var ObjectVersionId = /* @__PURE__ */ Symbol.for("@dxos/echo/Version");
|
|
103
|
+
var ObjectDatabaseId = /* @__PURE__ */ Symbol.for("@dxos/echo/Database");
|
|
104
|
+
var ATTR_RELATION_SOURCE = "@relationSource";
|
|
105
|
+
var RelationSourceId = /* @__PURE__ */ Symbol.for("@dxos/echo/RelationSource");
|
|
106
|
+
var RelationSourceDXNId = /* @__PURE__ */ Symbol.for("@dxos/echo/RelationSourceDXN");
|
|
107
|
+
var ATTR_RELATION_TARGET = "@relationTarget";
|
|
108
|
+
var RelationTargetId = /* @__PURE__ */ Symbol.for("@dxos/echo/RelationTarget");
|
|
109
|
+
var RelationTargetDXNId = /* @__PURE__ */ Symbol.for("@dxos/echo/RelationTargetDXN");
|
|
110
|
+
|
|
111
|
+
// src/internal/common/types/version.ts
|
|
106
112
|
var VersionTypeId = "~@dxos/echo/VersionTypeId";
|
|
107
113
|
|
|
108
|
-
// src/internal/
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return getLabelWithSchema(schema, entity);
|
|
114
|
+
// src/internal/Annotation/sorting.ts
|
|
115
|
+
var compare = (a, b) => {
|
|
116
|
+
if (a == null) {
|
|
117
|
+
return b == null ? 0 : 1;
|
|
113
118
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const schema = getSchema(entity);
|
|
117
|
-
if (schema != null) {
|
|
118
|
-
setLabelWithSchema(schema, entity, label);
|
|
119
|
+
if (b == null) {
|
|
120
|
+
return -1;
|
|
119
121
|
}
|
|
122
|
+
return a.localeCompare(b);
|
|
120
123
|
};
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
var sortByLabel = (a, b) => compare(getLabel(a), getLabel(b));
|
|
125
|
+
var sortByTypename = (a, b) => compare(getTypename(a), getTypename(b));
|
|
126
|
+
var sort = (...comparators) => {
|
|
127
|
+
return (a, b) => {
|
|
128
|
+
for (const comparator of comparators) {
|
|
129
|
+
const result = comparator(a, b);
|
|
130
|
+
if (result !== 0) {
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return 0;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/internal/common/api/meta.ts
|
|
139
|
+
import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
|
|
140
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/api/meta.ts";
|
|
141
|
+
function getMetaChecked(entity) {
|
|
142
|
+
assertArgument(entity, "entity", "Should be an entity.");
|
|
143
|
+
const meta = getMeta(entity);
|
|
144
|
+
invariant2(meta != null, "Invalid entity.", {
|
|
145
|
+
F: __dxlog_file2,
|
|
146
|
+
L: 34,
|
|
147
|
+
S: this,
|
|
148
|
+
A: [
|
|
149
|
+
"meta != null",
|
|
150
|
+
"'Invalid entity.'"
|
|
151
|
+
]
|
|
152
|
+
});
|
|
153
|
+
return meta;
|
|
154
|
+
}
|
|
155
|
+
var getKeys = (entity, source) => {
|
|
156
|
+
assertArgument(entity, "entity", "Should be an entity.");
|
|
157
|
+
const meta = getMetaChecked(entity);
|
|
158
|
+
invariant2(meta != null, "Invalid entity.", {
|
|
159
|
+
F: __dxlog_file2,
|
|
160
|
+
L: 45,
|
|
161
|
+
S: void 0,
|
|
162
|
+
A: [
|
|
163
|
+
"meta != null",
|
|
164
|
+
"'Invalid entity.'"
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
return meta.keys.filter((key) => key.source === source);
|
|
168
|
+
};
|
|
169
|
+
var deleteKeys = (entity, source) => {
|
|
170
|
+
const meta = getMetaChecked(entity);
|
|
171
|
+
for (let i = 0; i < meta.keys.length; i++) {
|
|
172
|
+
if (meta.keys[i].source === source) {
|
|
173
|
+
meta.keys.splice(i, 1);
|
|
174
|
+
i--;
|
|
175
|
+
}
|
|
125
176
|
}
|
|
126
177
|
};
|
|
127
|
-
var
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
178
|
+
var addTag = (entity, tag) => {
|
|
179
|
+
const meta = getMetaChecked(entity);
|
|
180
|
+
meta.tags ??= [];
|
|
181
|
+
meta.tags.push(tag);
|
|
182
|
+
};
|
|
183
|
+
var removeTag = (entity, tag) => {
|
|
184
|
+
const meta = getMetaChecked(entity);
|
|
185
|
+
if (!meta.tags) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
for (let i = 0; i < meta.tags.length; i++) {
|
|
189
|
+
if (meta.tags[i] === tag) {
|
|
190
|
+
meta.tags.splice(i, 1);
|
|
191
|
+
i--;
|
|
192
|
+
}
|
|
131
193
|
}
|
|
132
194
|
};
|
|
133
195
|
|
|
134
|
-
// src/internal/
|
|
135
|
-
|
|
136
|
-
|
|
196
|
+
// src/internal/common/proxy/symbols.ts
|
|
197
|
+
var EventId = /* @__PURE__ */ Symbol.for("@dxos/live-object/EventId");
|
|
198
|
+
var ChangeId = /* @__PURE__ */ Symbol.for("@dxos/live-object/ChangeId");
|
|
137
199
|
|
|
138
|
-
// src/internal/
|
|
139
|
-
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// ? void | Simplify<Schema.TypeLiteral.Constructor<Fields, []>>
|
|
153
|
-
// : Simplify<Schema.TypeLiteral.Constructor<Fields, []>>,
|
|
154
|
-
// options?: MakeProps,
|
|
155
|
-
// ): Simplify<Schema.TypeLiteral.Type<Fields, []>> {
|
|
156
|
-
// const propsWithDefaults: any = _lazilyMergeDefaults(fields, { ...(props as any) });
|
|
157
|
-
// return _getDisableValidationMakeOption(options)
|
|
158
|
-
// ? propsWithDefaults
|
|
159
|
-
// : ParseResult.validateSync(this)(propsWithDefaults);
|
|
160
|
-
// }
|
|
161
|
-
static instanceOf(value2) {
|
|
162
|
-
return Schema3.is(this)(value2);
|
|
200
|
+
// src/internal/common/proxy/event-batch.ts
|
|
201
|
+
var eventBatchDepth = 0;
|
|
202
|
+
var pendingEventTargets = /* @__PURE__ */ new Set();
|
|
203
|
+
var batchEvents = (callback) => {
|
|
204
|
+
eventBatchDepth++;
|
|
205
|
+
try {
|
|
206
|
+
callback();
|
|
207
|
+
} finally {
|
|
208
|
+
eventBatchDepth--;
|
|
209
|
+
if (eventBatchDepth === 0) {
|
|
210
|
+
for (const target of pendingEventTargets) {
|
|
211
|
+
target[EventId]?.emit();
|
|
212
|
+
}
|
|
213
|
+
pendingEventTargets.clear();
|
|
163
214
|
}
|
|
164
|
-
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var emitEvent = (target) => {
|
|
218
|
+
if (eventBatchDepth > 0) {
|
|
219
|
+
pendingEventTargets.add(target);
|
|
220
|
+
} else {
|
|
221
|
+
target[EventId]?.emit();
|
|
222
|
+
}
|
|
165
223
|
};
|
|
166
224
|
|
|
167
|
-
// src/internal/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
var RelationTargetId = /* @__PURE__ */ Symbol.for("@dxos/echo/RelationTarget");
|
|
184
|
-
var RelationTargetDXNId = /* @__PURE__ */ Symbol.for("@dxos/echo/RelationTargetDXN");
|
|
185
|
-
var EchoRelationSchema = ({ source, target, typename, version: version2 }) => {
|
|
186
|
-
assertArgument(Schema4.isSchema(source), "source");
|
|
187
|
-
assertArgument(Schema4.isSchema(target), "target");
|
|
188
|
-
const sourceDXN = getDXNForRelationSchemaRef(source);
|
|
189
|
-
const targetDXN = getDXNForRelationSchemaRef(target);
|
|
190
|
-
if (getEntityKind(source) !== EntityKind.Object) {
|
|
191
|
-
raise(new Error("Source schema must be an echo object schema."));
|
|
225
|
+
// src/internal/common/proxy/change-context.ts
|
|
226
|
+
var currentChangeContext = null;
|
|
227
|
+
var pendingNotificationKey = null;
|
|
228
|
+
var pendingOwnerNotifications = /* @__PURE__ */ new Set();
|
|
229
|
+
var enterChangeContext = (key) => {
|
|
230
|
+
currentChangeContext = key;
|
|
231
|
+
return () => {
|
|
232
|
+
currentChangeContext = null;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
var isInChangeContext = (key) => {
|
|
236
|
+
return currentChangeContext === key;
|
|
237
|
+
};
|
|
238
|
+
var queueNotification = (key) => {
|
|
239
|
+
if (currentChangeContext === key) {
|
|
240
|
+
pendingNotificationKey = key;
|
|
192
241
|
}
|
|
193
|
-
|
|
194
|
-
|
|
242
|
+
};
|
|
243
|
+
var queueOwnerNotification = (target) => {
|
|
244
|
+
if (currentChangeContext !== null && target !== currentChangeContext) {
|
|
245
|
+
pendingOwnerNotifications.add(target);
|
|
195
246
|
}
|
|
196
|
-
return (self) => {
|
|
197
|
-
invariant2(SchemaAST2.isTypeLiteral(self.ast), "Schema must be a TypeLiteral.", {
|
|
198
|
-
F: __dxlog_file2,
|
|
199
|
-
L: 127,
|
|
200
|
-
S: void 0,
|
|
201
|
-
A: [
|
|
202
|
-
"SchemaAST.isTypeLiteral(self.ast)",
|
|
203
|
-
"'Schema must be a TypeLiteral.'"
|
|
204
|
-
]
|
|
205
|
-
});
|
|
206
|
-
const fields = self.fields ?? {};
|
|
207
|
-
const schemaWithId = Schema4.extend(self, Schema4.Struct({
|
|
208
|
-
id: Schema4.String
|
|
209
|
-
}));
|
|
210
|
-
const ast = SchemaAST2.annotations(schemaWithId.ast, {
|
|
211
|
-
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
212
|
-
...self.ast.annotations,
|
|
213
|
-
[TypeAnnotationId]: {
|
|
214
|
-
kind: EntityKind.Relation,
|
|
215
|
-
typename,
|
|
216
|
-
version: version2,
|
|
217
|
-
sourceSchema: sourceDXN,
|
|
218
|
-
targetSchema: targetDXN
|
|
219
|
-
},
|
|
220
|
-
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
221
|
-
[SchemaAST2.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
222
|
-
kind: EntityKind.Relation,
|
|
223
|
-
typename,
|
|
224
|
-
version: version2,
|
|
225
|
-
relationSource: sourceDXN,
|
|
226
|
-
relationTarget: targetDXN
|
|
227
|
-
})
|
|
228
|
-
});
|
|
229
|
-
return makeEchoTypeSchema(fields, ast, typename, version2, EntityKind.Relation);
|
|
230
|
-
};
|
|
231
247
|
};
|
|
232
|
-
var
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
248
|
+
var hasPendingNotifications = (key) => {
|
|
249
|
+
return pendingNotificationKey === key;
|
|
250
|
+
};
|
|
251
|
+
var clearPendingNotifications = (key) => {
|
|
252
|
+
if (pendingNotificationKey === key) {
|
|
253
|
+
pendingNotificationKey = null;
|
|
237
254
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
255
|
+
};
|
|
256
|
+
var executeChange = (contextKey, eventTarget, proxy, callback) => {
|
|
257
|
+
const exitContext = enterChangeContext(contextKey);
|
|
258
|
+
try {
|
|
259
|
+
batchEvents(() => callback(proxy));
|
|
260
|
+
} finally {
|
|
261
|
+
exitContext();
|
|
262
|
+
if (hasPendingNotifications(contextKey)) {
|
|
263
|
+
clearPendingNotifications(contextKey);
|
|
264
|
+
eventTarget[EventId]?.emit();
|
|
265
|
+
}
|
|
266
|
+
for (const ownerTarget of pendingOwnerNotifications) {
|
|
267
|
+
ownerTarget[EventId]?.emit();
|
|
268
|
+
}
|
|
269
|
+
pendingOwnerNotifications.clear();
|
|
241
270
|
}
|
|
242
|
-
return DXN.fromTypename(typename).toString();
|
|
243
271
|
};
|
|
244
272
|
|
|
245
|
-
// src/internal/
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var ObjectVersionId = /* @__PURE__ */ Symbol.for("@dxos/echo/Version");
|
|
252
|
-
var ObjectDatabaseId = /* @__PURE__ */ Symbol.for("@dxos/echo/Database");
|
|
253
|
-
function assertObjectModel(obj) {
|
|
254
|
-
invariant3(typeof obj === "object" && obj !== null, "Invalid object model: not an object", {
|
|
255
|
-
F: __dxlog_file3,
|
|
256
|
-
L: 123,
|
|
257
|
-
S: this,
|
|
258
|
-
A: [
|
|
259
|
-
"typeof obj === 'object' && obj !== null",
|
|
260
|
-
"'Invalid object model: not an object'"
|
|
261
|
-
]
|
|
262
|
-
});
|
|
263
|
-
assumeType(obj);
|
|
264
|
-
invariant3(ObjectId.isValid(obj.id), "Invalid object model: invalid id", {
|
|
265
|
-
F: __dxlog_file3,
|
|
266
|
-
L: 125,
|
|
267
|
-
S: this,
|
|
268
|
-
A: [
|
|
269
|
-
"ObjectId.isValid(obj.id)",
|
|
270
|
-
"'Invalid object model: invalid id'"
|
|
271
|
-
]
|
|
273
|
+
// src/internal/common/proxy/define-hidden-property.ts
|
|
274
|
+
var defineHiddenProperty = (object, key, value2) => {
|
|
275
|
+
Object.defineProperty(object, key, {
|
|
276
|
+
enumerable: false,
|
|
277
|
+
configurable: true,
|
|
278
|
+
value: value2
|
|
272
279
|
});
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
// src/internal/common/proxy/errors.ts
|
|
283
|
+
var MutationOutsideChangeContextError = class extends Error {
|
|
284
|
+
constructor(operation, suggestion) {
|
|
285
|
+
super(`Cannot ${operation} outside of Obj.change(). Use Obj.change(obj, (mutableObj) => { ${suggestion} }) instead.`);
|
|
286
|
+
this.name = "MutationOutsideChangeContextError";
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
var createPropertySetError = (prop) => {
|
|
290
|
+
return new MutationOutsideChangeContextError(`modify object property "${String(prop)}"`, `mutableObj.${String(prop)} = value;`);
|
|
291
|
+
};
|
|
292
|
+
var createPropertyDeleteError = (prop) => {
|
|
293
|
+
return new MutationOutsideChangeContextError(`delete object property "${String(prop)}"`, `delete mutableObj.${String(prop)};`);
|
|
294
|
+
};
|
|
295
|
+
var createArrayMethodError = (method) => {
|
|
296
|
+
return new MutationOutsideChangeContextError(`call array.${method}()`, `mutableObj.array.${method}(...);`);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// src/internal/common/proxy/json-serializer.ts
|
|
300
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
301
|
+
import { DXN } from "@dxos/keys";
|
|
302
|
+
import { deepMapValues } from "@dxos/util";
|
|
303
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/proxy/json-serializer.ts";
|
|
304
|
+
var attachTypedJsonSerializer = (obj) => {
|
|
305
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, "toJSON");
|
|
306
|
+
if (descriptor) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
Object.defineProperty(obj, "toJSON", {
|
|
310
|
+
value: typedJsonSerializer,
|
|
311
|
+
writable: false,
|
|
312
|
+
enumerable: false,
|
|
313
|
+
// Setting `configurable` to false breaks proxy invariants, should be fixable.
|
|
314
|
+
configurable: true
|
|
290
315
|
});
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
});
|
|
310
|
-
invariant3(!(obj[RelationSourceId] instanceof DXN2), "Invalid object model: source pointer is a DXN", {
|
|
316
|
+
};
|
|
317
|
+
var typedJsonSerializer = function() {
|
|
318
|
+
const { id, ...rest } = this;
|
|
319
|
+
const result = {
|
|
320
|
+
id
|
|
321
|
+
};
|
|
322
|
+
if (this[TypeId]) {
|
|
323
|
+
result[ATTR_TYPE] = this[TypeId].toString();
|
|
324
|
+
}
|
|
325
|
+
if (this[MetaId]) {
|
|
326
|
+
result[ATTR_META] = serializeMeta(this[MetaId]);
|
|
327
|
+
}
|
|
328
|
+
if (this[SelfDXNId]) {
|
|
329
|
+
result[ATTR_SELF_DXN] = this[SelfDXNId].toString();
|
|
330
|
+
}
|
|
331
|
+
if (this[RelationSourceDXNId]) {
|
|
332
|
+
const sourceDXN = this[RelationSourceDXNId];
|
|
333
|
+
invariant3(sourceDXN instanceof DXN, void 0, {
|
|
311
334
|
F: __dxlog_file3,
|
|
312
|
-
L:
|
|
335
|
+
L: 64,
|
|
313
336
|
S: this,
|
|
314
337
|
A: [
|
|
315
|
-
"
|
|
316
|
-
"
|
|
338
|
+
"sourceDXN instanceof DXN",
|
|
339
|
+
""
|
|
317
340
|
]
|
|
318
341
|
});
|
|
319
|
-
|
|
342
|
+
result[ATTR_RELATION_SOURCE] = sourceDXN.toString();
|
|
343
|
+
}
|
|
344
|
+
if (this[RelationTargetDXNId]) {
|
|
345
|
+
const targetDXN = this[RelationTargetDXNId];
|
|
346
|
+
invariant3(targetDXN instanceof DXN, void 0, {
|
|
320
347
|
F: __dxlog_file3,
|
|
321
|
-
L:
|
|
348
|
+
L: 69,
|
|
322
349
|
S: this,
|
|
323
350
|
A: [
|
|
324
|
-
"
|
|
325
|
-
"
|
|
351
|
+
"targetDXN instanceof DXN",
|
|
352
|
+
""
|
|
326
353
|
]
|
|
327
354
|
});
|
|
355
|
+
result[ATTR_RELATION_TARGET] = targetDXN.toString();
|
|
328
356
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
// src/internal/entities/object.ts
|
|
332
|
-
import * as Schema5 from "effect/Schema";
|
|
333
|
-
import * as SchemaAST3 from "effect/SchemaAST";
|
|
334
|
-
import { invariant as invariant4 } from "@dxos/invariant";
|
|
335
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/entities/object.ts";
|
|
336
|
-
var EchoObjectSchema = ({ typename, version: version2 }) => {
|
|
337
|
-
return (self) => {
|
|
338
|
-
invariant4(typeof TypeAnnotationId === "symbol", "Sanity.", {
|
|
339
|
-
F: __dxlog_file4,
|
|
340
|
-
L: 37,
|
|
341
|
-
S: void 0,
|
|
342
|
-
A: [
|
|
343
|
-
"typeof TypeAnnotationId === 'symbol'",
|
|
344
|
-
"'Sanity.'"
|
|
345
|
-
]
|
|
346
|
-
});
|
|
347
|
-
invariant4(SchemaAST3.isTypeLiteral(self.ast), "Schema must be a TypeLiteral.", {
|
|
348
|
-
F: __dxlog_file4,
|
|
349
|
-
L: 38,
|
|
350
|
-
S: void 0,
|
|
351
|
-
A: [
|
|
352
|
-
"SchemaAST.isTypeLiteral(self.ast)",
|
|
353
|
-
"'Schema must be a TypeLiteral.'"
|
|
354
|
-
]
|
|
355
|
-
});
|
|
356
|
-
const fields = self.fields ?? {};
|
|
357
|
-
const schemaWithId = Schema5.extend(self, Schema5.Struct({
|
|
358
|
-
id: Schema5.String
|
|
359
|
-
}));
|
|
360
|
-
const ast = SchemaAST3.annotations(schemaWithId.ast, {
|
|
361
|
-
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
362
|
-
...self.ast.annotations,
|
|
363
|
-
[TypeAnnotationId]: {
|
|
364
|
-
kind: EntityKind.Object,
|
|
365
|
-
typename,
|
|
366
|
-
version: version2
|
|
367
|
-
},
|
|
368
|
-
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
369
|
-
[SchemaAST3.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
370
|
-
kind: EntityKind.Object,
|
|
371
|
-
typename,
|
|
372
|
-
version: version2
|
|
373
|
-
})
|
|
374
|
-
});
|
|
375
|
-
return makeEchoTypeSchema(fields, ast, typename, version2, EntityKind.Object);
|
|
376
|
-
};
|
|
357
|
+
Object.assign(result, serializeData(rest));
|
|
358
|
+
return result;
|
|
377
359
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/entities/util.ts";
|
|
385
|
-
var getObjectDXN = (object) => {
|
|
386
|
-
invariant5(!Schema6.isSchema(object), "schema not allowed in this function", {
|
|
387
|
-
F: __dxlog_file5,
|
|
388
|
-
L: 19,
|
|
389
|
-
S: void 0,
|
|
390
|
-
A: [
|
|
391
|
-
"!Schema.isSchema(object)",
|
|
392
|
-
"'schema not allowed in this function'"
|
|
393
|
-
]
|
|
360
|
+
var serializeData = (data) => {
|
|
361
|
+
return deepMapValues(data, (value2, recurse) => {
|
|
362
|
+
if (Ref.isRef(value2)) {
|
|
363
|
+
return value2.noInline().encode();
|
|
364
|
+
}
|
|
365
|
+
return recurse(value2);
|
|
394
366
|
});
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
367
|
+
};
|
|
368
|
+
var serializeMeta = (meta) => {
|
|
369
|
+
return deepMapValues(meta, (value2, recurse) => recurse(value2));
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// src/internal/common/proxy/make-object.ts
|
|
373
|
+
import { ObjectId } from "@dxos/keys";
|
|
374
|
+
|
|
375
|
+
// src/internal/common/proxy/proxy-utils.ts
|
|
376
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
377
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/proxy/proxy-utils.ts";
|
|
378
|
+
var symbolIsProxy = /* @__PURE__ */ Symbol.for("@dxos/schema/Proxy");
|
|
379
|
+
var isProxy = (value2) => !!value2?.[symbolIsProxy];
|
|
380
|
+
var isValidProxyTarget = (value2) => {
|
|
381
|
+
if (value2 == null || value2[symbolIsProxy]) {
|
|
382
|
+
return false;
|
|
408
383
|
}
|
|
409
|
-
if (
|
|
410
|
-
|
|
384
|
+
if (Array.isArray(value2)) {
|
|
385
|
+
return true;
|
|
411
386
|
}
|
|
412
|
-
return
|
|
387
|
+
return typeof value2 === "object" && Object.getPrototypeOf(value2) === Object.prototype;
|
|
413
388
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
invariant6(dxn != null, "Invalid entity.", {
|
|
420
|
-
F: __dxlog_file6,
|
|
421
|
-
L: 18,
|
|
389
|
+
var getProxySlot = (proxy) => {
|
|
390
|
+
const value2 = proxy[symbolIsProxy];
|
|
391
|
+
invariant4(value2 instanceof ProxyHandlerSlot, void 0, {
|
|
392
|
+
F: __dxlog_file4,
|
|
393
|
+
L: 32,
|
|
422
394
|
S: void 0,
|
|
423
395
|
A: [
|
|
424
|
-
"
|
|
425
|
-
"
|
|
396
|
+
"value instanceof ProxyHandlerSlot",
|
|
397
|
+
""
|
|
426
398
|
]
|
|
427
399
|
});
|
|
428
|
-
return
|
|
429
|
-
};
|
|
430
|
-
var getDatabase = (entity) => {
|
|
431
|
-
assumeType3(entity);
|
|
432
|
-
return entity[ObjectDatabaseId];
|
|
400
|
+
return value2;
|
|
433
401
|
};
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
import { assertArgument as assertArgument3, invariant as invariant7 } from "@dxos/invariant";
|
|
437
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/api/meta.ts";
|
|
438
|
-
function getMetaChecked(entity) {
|
|
439
|
-
assertArgument3(entity, "entity", "Should be an entity.");
|
|
440
|
-
const meta = getMeta(entity);
|
|
441
|
-
invariant7(meta != null, "Invalid entity.", {
|
|
442
|
-
F: __dxlog_file7,
|
|
443
|
-
L: 34,
|
|
444
|
-
S: this,
|
|
445
|
-
A: [
|
|
446
|
-
"meta != null",
|
|
447
|
-
"'Invalid entity.'"
|
|
448
|
-
]
|
|
449
|
-
});
|
|
450
|
-
return meta;
|
|
451
|
-
}
|
|
452
|
-
var getKeys = (entity, source) => {
|
|
453
|
-
assertArgument3(entity, "entity", "Should be an entity.");
|
|
454
|
-
const meta = getMetaChecked(entity);
|
|
455
|
-
invariant7(meta != null, "Invalid entity.", {
|
|
456
|
-
F: __dxlog_file7,
|
|
457
|
-
L: 45,
|
|
458
|
-
S: void 0,
|
|
459
|
-
A: [
|
|
460
|
-
"meta != null",
|
|
461
|
-
"'Invalid entity.'"
|
|
462
|
-
]
|
|
463
|
-
});
|
|
464
|
-
return meta.keys.filter((key) => key.source === source);
|
|
402
|
+
var getProxyTarget = (proxy) => {
|
|
403
|
+
return getProxySlot(proxy).target;
|
|
465
404
|
};
|
|
466
|
-
var
|
|
467
|
-
|
|
468
|
-
for (let i = 0; i < meta.keys.length; i++) {
|
|
469
|
-
if (meta.keys[i].source === source) {
|
|
470
|
-
meta.keys.splice(i, 1);
|
|
471
|
-
i--;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
405
|
+
var getProxyHandler = (proxy) => {
|
|
406
|
+
return getProxySlot(proxy).handler;
|
|
474
407
|
};
|
|
475
|
-
var
|
|
476
|
-
|
|
477
|
-
meta.tags ??= [];
|
|
478
|
-
meta.tags.push(tag);
|
|
408
|
+
var dangerouslySetProxyId = (obj, id) => {
|
|
409
|
+
getProxySlot(obj).target.id = id;
|
|
479
410
|
};
|
|
480
|
-
var
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
for (let i = 0; i < meta.tags.length; i++) {
|
|
486
|
-
if (meta.tags[i] === tag) {
|
|
487
|
-
meta.tags.splice(i, 1);
|
|
488
|
-
i--;
|
|
489
|
-
}
|
|
411
|
+
var createProxy = (target, handler) => {
|
|
412
|
+
const existingProxy = handler._proxyMap.get(target);
|
|
413
|
+
if (existingProxy) {
|
|
414
|
+
return existingProxy;
|
|
490
415
|
}
|
|
416
|
+
const proxy = new Proxy(target, new ProxyHandlerSlot(target, handler));
|
|
417
|
+
handler.init(target);
|
|
418
|
+
handler._proxyMap.set(target, proxy);
|
|
419
|
+
return proxy;
|
|
491
420
|
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
421
|
+
var ProxyHandlerSlot = class {
|
|
422
|
+
target;
|
|
423
|
+
_handler;
|
|
424
|
+
/**
|
|
425
|
+
* @param target Original object.
|
|
426
|
+
* @param _handler Handles intercepted operations.
|
|
427
|
+
*/
|
|
428
|
+
constructor(target, _handler) {
|
|
429
|
+
this.target = target;
|
|
430
|
+
this._handler = _handler;
|
|
500
431
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
432
|
+
get handler() {
|
|
433
|
+
invariant4(this._handler, void 0, {
|
|
434
|
+
F: __dxlog_file4,
|
|
435
|
+
L: 91,
|
|
436
|
+
S: this,
|
|
437
|
+
A: [
|
|
438
|
+
"this._handler",
|
|
439
|
+
""
|
|
440
|
+
]
|
|
441
|
+
});
|
|
442
|
+
return this._handler;
|
|
443
|
+
}
|
|
444
|
+
// TODO(burdon): Requires comment.
|
|
445
|
+
setHandler(handler) {
|
|
446
|
+
this._handler = handler;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Get value.
|
|
450
|
+
*/
|
|
451
|
+
get(target, prop, receiver) {
|
|
452
|
+
if (prop === symbolIsProxy) {
|
|
453
|
+
return this;
|
|
454
|
+
}
|
|
455
|
+
if (!this._handler || !this._handler.get) {
|
|
456
|
+
return Reflect.get(target, prop, receiver);
|
|
457
|
+
}
|
|
458
|
+
return this._handler.get(target, prop, receiver);
|
|
459
|
+
}
|
|
460
|
+
static {
|
|
461
|
+
const TRAPS = [
|
|
462
|
+
"apply",
|
|
463
|
+
"construct",
|
|
464
|
+
"defineProperty",
|
|
465
|
+
"deleteProperty",
|
|
466
|
+
"get",
|
|
467
|
+
"getOwnPropertyDescriptor",
|
|
468
|
+
"getPrototypeOf",
|
|
469
|
+
"has",
|
|
470
|
+
"isExtensible",
|
|
471
|
+
"ownKeys",
|
|
472
|
+
"preventExtensions",
|
|
473
|
+
"set",
|
|
474
|
+
"setPrototypeOf"
|
|
475
|
+
];
|
|
476
|
+
for (const trap of TRAPS) {
|
|
477
|
+
if (trap === "get") {
|
|
478
|
+
continue;
|
|
511
479
|
}
|
|
480
|
+
Object.defineProperty(this.prototype, trap, {
|
|
481
|
+
enumerable: false,
|
|
482
|
+
value: function(...args) {
|
|
483
|
+
if (!this._handler || !this._handler[trap]) {
|
|
484
|
+
return Reflect[trap](...args);
|
|
485
|
+
}
|
|
486
|
+
return this._handler[trap].apply(this._handler, args);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
512
489
|
}
|
|
513
|
-
|
|
514
|
-
};
|
|
490
|
+
}
|
|
515
491
|
};
|
|
516
492
|
|
|
517
|
-
// src/internal/
|
|
518
|
-
import
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
|
|
493
|
+
// src/internal/common/proxy/typed-handler.ts
|
|
494
|
+
import * as Schema4 from "effect/Schema";
|
|
495
|
+
import * as SchemaAST3 from "effect/SchemaAST";
|
|
496
|
+
import { Event } from "@dxos/async";
|
|
497
|
+
import { inspectCustom } from "@dxos/debug";
|
|
498
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
499
|
+
|
|
500
|
+
// src/internal/common/proxy/ownership.ts
|
|
501
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
502
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/proxy/ownership.ts";
|
|
503
|
+
var EchoOwner = /* @__PURE__ */ Symbol.for("@dxos/echo/Owner");
|
|
504
|
+
var getRawTarget = (value2) => {
|
|
505
|
+
return isProxy(value2) ? getProxyTarget(value2) : value2;
|
|
525
506
|
};
|
|
526
|
-
var
|
|
527
|
-
|
|
528
|
-
if (ver === void 0) {
|
|
529
|
-
return unversioned;
|
|
530
|
-
}
|
|
531
|
-
return ver;
|
|
507
|
+
var getOwner = (value2) => {
|
|
508
|
+
return value2?.[EchoOwner];
|
|
532
509
|
};
|
|
533
|
-
var
|
|
534
|
-
|
|
535
|
-
return !!ver.versioned;
|
|
510
|
+
var setMetaOwner = (metaTarget, parent) => {
|
|
511
|
+
defineHiddenProperty(metaTarget, EchoOwner, parent);
|
|
536
512
|
};
|
|
537
|
-
var
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
return "unversioned";
|
|
513
|
+
var setOwnerRecursive = (value2, owner, options = {}) => {
|
|
514
|
+
const { visited = /* @__PURE__ */ new Set(), depth = 0, allowedPreviousOwner } = options;
|
|
515
|
+
if (value2 == null || typeof value2 !== "object") {
|
|
516
|
+
return;
|
|
542
517
|
}
|
|
543
|
-
|
|
544
|
-
|
|
518
|
+
const actualValue = getRawTarget(value2);
|
|
519
|
+
if (visited.has(actualValue)) {
|
|
520
|
+
return;
|
|
545
521
|
}
|
|
546
|
-
|
|
547
|
-
|
|
522
|
+
visited.add(actualValue);
|
|
523
|
+
const existingOwner = getOwner(actualValue);
|
|
524
|
+
const isRootEchoObject = EventId in actualValue;
|
|
525
|
+
let newAllowedPreviousOwner = allowedPreviousOwner;
|
|
526
|
+
if (isRootEchoObject && depth === 0) {
|
|
527
|
+
newAllowedPreviousOwner = actualValue;
|
|
548
528
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
// src/internal/json-schema/annotations.ts
|
|
561
|
-
import * as SchemaAST4 from "effect/SchemaAST";
|
|
562
|
-
var CustomAnnotations = {
|
|
563
|
-
format: FormatAnnotationId,
|
|
564
|
-
currency: CurrencyAnnotationId
|
|
565
|
-
};
|
|
566
|
-
var DecodedAnnotations = {
|
|
567
|
-
title: SchemaAST4.TitleAnnotationId,
|
|
568
|
-
description: SchemaAST4.DescriptionAnnotationId
|
|
569
|
-
};
|
|
570
|
-
var EchoAnnotations = {
|
|
571
|
-
// TODO(dmaretskyi): `FieldLookupAnnotationId` might go here, but lets remove it entirely and use LabelAnnotation instead.
|
|
572
|
-
meta: PropertyMetaAnnotationId,
|
|
573
|
-
generator: GeneratorAnnotationId,
|
|
574
|
-
labelProp: LabelAnnotationId
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
// src/internal/json-schema/json-schema-type.ts
|
|
578
|
-
import * as Schema7 from "effect/Schema";
|
|
579
|
-
import { JsonPath } from "@dxos/effect";
|
|
580
|
-
var SimpleTypes = Schema7.Literal("array", "boolean", "integer", "null", "number", "object", "string");
|
|
581
|
-
var NonNegativeInteger = Schema7.Number.pipe(Schema7.greaterThanOrEqualTo(0));
|
|
582
|
-
var StringArray = Schema7.Array(Schema7.String);
|
|
583
|
-
var JsonSchemaOrBoolean = Schema7.Union(Schema7.suspend(() => JsonSchemaType), Schema7.Boolean);
|
|
584
|
-
var JsonSchemaEchoAnnotations = Schema7.Struct({
|
|
585
|
-
/**
|
|
586
|
-
* Label for this schema.
|
|
587
|
-
* Mapped from {@link LabelAnnotationId}.
|
|
588
|
-
*/
|
|
589
|
-
labelProp: Schema7.optional(Schema7.Union(JsonPath, Schema7.Array(JsonPath))),
|
|
590
|
-
/**
|
|
591
|
-
* Generator function for this schema.
|
|
592
|
-
* Mapped from {@link GeneratorAnnotationId}.
|
|
593
|
-
*/
|
|
594
|
-
generator: Schema7.optional(Schema7.Union(Schema7.String, Schema7.Tuple(Schema7.String, Schema7.Number))),
|
|
595
|
-
/**
|
|
596
|
-
* {@link PropertyMeta} annotations get serialized here.
|
|
597
|
-
*/
|
|
598
|
-
meta: Schema7.optional(Schema7.Record({
|
|
599
|
-
key: Schema7.String,
|
|
600
|
-
value: Schema7.Any
|
|
601
|
-
})),
|
|
602
|
-
/**
|
|
603
|
-
* @deprecated
|
|
604
|
-
*/
|
|
605
|
-
// TODO(dmaretskyi): We risk old schema not passing validation due to the extra fields. Remove when we are sure this is safe.
|
|
606
|
-
type: Schema7.optional(Schema7.Struct({
|
|
607
|
-
typename: Schema7.String,
|
|
608
|
-
version: Schema7.String,
|
|
609
|
-
// Not used.
|
|
610
|
-
schemaId: Schema7.optional(Schema7.String)
|
|
611
|
-
})),
|
|
612
|
-
/**
|
|
613
|
-
* @deprecated Superseded by `meta`.
|
|
614
|
-
*/
|
|
615
|
-
annotations: Schema7.optional(Schema7.Record({
|
|
616
|
-
key: Schema7.String,
|
|
617
|
-
value: Schema7.Any
|
|
618
|
-
}))
|
|
619
|
-
});
|
|
620
|
-
var _JsonSchemaType = Schema7.Struct({
|
|
621
|
-
/**
|
|
622
|
-
* Identifier for this schema.
|
|
623
|
-
* This schema might be referenced by $ref clause in other schemas.
|
|
624
|
-
*/
|
|
625
|
-
// TODO(dmaretskyi): Specify how the ids are generated.
|
|
626
|
-
// TODO(dmaretskyi): For type dxns, should this include the version?
|
|
627
|
-
$id: Schema7.optional(Schema7.String),
|
|
628
|
-
/**
|
|
629
|
-
* Schema of this schema.
|
|
630
|
-
* Set to "https://json-schema.org/draft-07/schema".
|
|
631
|
-
*/
|
|
632
|
-
$schema: Schema7.optional(Schema7.String),
|
|
633
|
-
/**
|
|
634
|
-
* Reference to another schema.
|
|
635
|
-
*/
|
|
636
|
-
$ref: Schema7.optional(Schema7.String),
|
|
637
|
-
/**
|
|
638
|
-
* Comments are ignored when interpreting the schema.
|
|
639
|
-
*/
|
|
640
|
-
$comment: Schema7.optional(Schema7.String),
|
|
641
|
-
/**
|
|
642
|
-
* Defines whether this schema is an object schema or a relation schema.
|
|
643
|
-
*/
|
|
644
|
-
entityKind: Schema7.optional(EntityKindSchema),
|
|
645
|
-
/**
|
|
646
|
-
* Typename of this schema.
|
|
647
|
-
* Only on schema representing an ECHO object.
|
|
648
|
-
*
|
|
649
|
-
* @example 'example.com/type/MyType'
|
|
650
|
-
*/
|
|
651
|
-
typename: Schema7.optional(Schema7.String),
|
|
652
|
-
/**
|
|
653
|
-
* Version of this schema.
|
|
654
|
-
* Custom dialect for ECHO.
|
|
655
|
-
*/
|
|
656
|
-
version: Schema7.optional(Schema7.String),
|
|
657
|
-
/**
|
|
658
|
-
* Target of this relation.
|
|
659
|
-
* Only for relation schemas.
|
|
660
|
-
* The referenced schema must be an object schema.
|
|
661
|
-
*/
|
|
662
|
-
relationTarget: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
663
|
-
/**
|
|
664
|
-
* Source of this relation.
|
|
665
|
-
* Only for relation schemas.
|
|
666
|
-
* The referenced schema must be an object schema.
|
|
667
|
-
*/
|
|
668
|
-
relationSource: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
669
|
-
/**
|
|
670
|
-
* Title of this schema.
|
|
671
|
-
*/
|
|
672
|
-
title: Schema7.optional(Schema7.String),
|
|
673
|
-
/**
|
|
674
|
-
* Description of this schema.
|
|
675
|
-
*/
|
|
676
|
-
description: Schema7.optional(Schema7.String),
|
|
677
|
-
/**
|
|
678
|
-
* Whether this schema is read-only.
|
|
679
|
-
*/
|
|
680
|
-
readOnly: Schema7.optional(Schema7.Boolean),
|
|
681
|
-
/**
|
|
682
|
-
* Whether this schema is write-only.
|
|
683
|
-
*/
|
|
684
|
-
writeOnly: Schema7.optional(Schema7.Boolean),
|
|
685
|
-
/**
|
|
686
|
-
* Examples of instances of this schema.
|
|
687
|
-
*/
|
|
688
|
-
examples: Schema7.optional(Schema7.Array(Schema7.Any)),
|
|
689
|
-
/**
|
|
690
|
-
* Default value for this schema.
|
|
691
|
-
*/
|
|
692
|
-
default: Schema7.optional(Schema7.Any),
|
|
693
|
-
/**
|
|
694
|
-
* This schema only matches values that are equal to this value.
|
|
695
|
-
*/
|
|
696
|
-
const: Schema7.optional(Schema7.Any),
|
|
697
|
-
/**
|
|
698
|
-
* This schema only matches one of the values in this array.
|
|
699
|
-
*/
|
|
700
|
-
enum: Schema7.optional(Schema7.Array(Schema7.Any)),
|
|
701
|
-
/**
|
|
702
|
-
* Base type of the schema.
|
|
703
|
-
*/
|
|
704
|
-
type: Schema7.optional(Schema7.Union(SimpleTypes, Schema7.Array(SimpleTypes))),
|
|
705
|
-
//
|
|
706
|
-
// Numbers.
|
|
707
|
-
//
|
|
708
|
-
multipleOf: Schema7.optional(Schema7.Number.pipe(Schema7.greaterThan(0))),
|
|
709
|
-
maximum: Schema7.optional(Schema7.Number),
|
|
710
|
-
exclusiveMaximum: Schema7.optional(Schema7.Number),
|
|
711
|
-
minimum: Schema7.optional(Schema7.Number),
|
|
712
|
-
exclusiveMinimum: Schema7.optional(Schema7.Number),
|
|
713
|
-
//
|
|
714
|
-
// Strings.
|
|
715
|
-
//
|
|
716
|
-
maxLength: Schema7.optional(NonNegativeInteger),
|
|
717
|
-
/**
|
|
718
|
-
* Regex pattern for strings.
|
|
719
|
-
*/
|
|
720
|
-
pattern: Schema7.optional(Schema7.String.pipe(FormatAnnotation.set(TypeFormat.Regex))),
|
|
721
|
-
/**
|
|
722
|
-
* Serialized from {@link FormatAnnotationId}.
|
|
723
|
-
*/
|
|
724
|
-
format: Schema7.optional(Schema7.String),
|
|
725
|
-
//
|
|
726
|
-
// Arrays
|
|
727
|
-
//
|
|
728
|
-
minLength: Schema7.optional(NonNegativeInteger),
|
|
729
|
-
items: Schema7.optional(Schema7.Union(Schema7.suspend(() => JsonSchemaType), Schema7.Array(Schema7.suspend(() => JsonSchemaType)))),
|
|
730
|
-
additionalItems: Schema7.optional(Schema7.Union(Schema7.suspend(() => JsonSchemaType), Schema7.Boolean)),
|
|
731
|
-
maxItems: Schema7.optional(NonNegativeInteger),
|
|
732
|
-
minItems: Schema7.optional(NonNegativeInteger),
|
|
733
|
-
uniqueItems: Schema7.optional(Schema7.Boolean),
|
|
734
|
-
contains: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
735
|
-
//
|
|
736
|
-
// Objects
|
|
737
|
-
//
|
|
738
|
-
maxProperties: Schema7.optional(NonNegativeInteger),
|
|
739
|
-
minProperties: Schema7.optional(NonNegativeInteger),
|
|
740
|
-
required: Schema7.optional(StringArray),
|
|
741
|
-
/**
|
|
742
|
-
* Non-standard JSON Schema extension.
|
|
743
|
-
* Defines the order of properties in the object.
|
|
744
|
-
* The unmentioned properties are placed at the end.
|
|
745
|
-
*
|
|
746
|
-
* Related: https://github.com/json-schema/json-schema/issues/119
|
|
747
|
-
*/
|
|
748
|
-
propertyOrder: Schema7.optional(StringArray),
|
|
749
|
-
additionalProperties: Schema7.optional(JsonSchemaOrBoolean),
|
|
750
|
-
properties: Schema7.optional(Schema7.Record({
|
|
751
|
-
key: Schema7.String,
|
|
752
|
-
value: Schema7.suspend(() => JsonSchemaType)
|
|
753
|
-
})),
|
|
754
|
-
patternProperties: Schema7.optional(Schema7.Record({
|
|
755
|
-
key: Schema7.String,
|
|
756
|
-
value: Schema7.suspend(() => JsonSchemaType)
|
|
757
|
-
})),
|
|
758
|
-
propertyNames: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
759
|
-
definitions: Schema7.optional(Schema7.Record({
|
|
760
|
-
key: Schema7.String,
|
|
761
|
-
value: Schema7.suspend(() => JsonSchemaType)
|
|
762
|
-
})),
|
|
763
|
-
dependencies: Schema7.optional(Schema7.Record({
|
|
764
|
-
key: Schema7.String,
|
|
765
|
-
value: Schema7.suspend(() => Schema7.Union(Schema7.String, StringArray, JsonSchemaType)).annotations({
|
|
766
|
-
identifier: "dependency",
|
|
767
|
-
description: "Dependency"
|
|
768
|
-
})
|
|
769
|
-
})),
|
|
770
|
-
contentMediaType: Schema7.optional(Schema7.String),
|
|
771
|
-
contentEncoding: Schema7.optional(Schema7.String),
|
|
772
|
-
if: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
773
|
-
then: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
774
|
-
else: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
775
|
-
allOf: Schema7.optional(Schema7.Array(Schema7.suspend(() => JsonSchemaType))),
|
|
776
|
-
anyOf: Schema7.optional(Schema7.Array(Schema7.suspend(() => JsonSchemaType))),
|
|
777
|
-
oneOf: Schema7.optional(Schema7.Array(Schema7.suspend(() => JsonSchemaType))),
|
|
778
|
-
not: Schema7.optional(Schema7.suspend(() => JsonSchemaType)),
|
|
779
|
-
$defs: Schema7.optional(Schema7.Record({
|
|
780
|
-
key: Schema7.String,
|
|
781
|
-
value: Schema7.suspend(() => JsonSchemaType)
|
|
782
|
-
})),
|
|
783
|
-
//
|
|
784
|
-
// ECHO extensions.
|
|
785
|
-
//
|
|
786
|
-
currency: Schema7.optional(Schema7.String),
|
|
787
|
-
reference: Schema7.optional(Schema7.Struct({
|
|
788
|
-
schema: Schema7.suspend(() => JsonSchemaType),
|
|
789
|
-
schemaVersion: Schema7.optional(Schema7.String),
|
|
790
|
-
schemaObject: Schema7.optional(Schema7.String)
|
|
791
|
-
})),
|
|
792
|
-
/**
|
|
793
|
-
* ECHO-specific annotations.
|
|
794
|
-
*/
|
|
795
|
-
// TODO(dmaretskyi): Since we are adding a lot of new extensions to the JSON Schema, it is safer to namespace them here.
|
|
796
|
-
annotations: Schema7.optional(JsonSchemaEchoAnnotations),
|
|
797
|
-
/**
|
|
798
|
-
* @deprecated Use `annotations` instead.
|
|
799
|
-
*/
|
|
800
|
-
echo: Schema7.optional(JsonSchemaEchoAnnotations)
|
|
801
|
-
}).annotations({
|
|
802
|
-
identifier: "jsonSchema",
|
|
803
|
-
description: "JSON Schema"
|
|
804
|
-
});
|
|
805
|
-
var JsonSchemaFields = Object.keys(_JsonSchemaType.fields);
|
|
806
|
-
var JsonSchemaType = _JsonSchemaType;
|
|
807
|
-
var getSchemaProperty = (schema, property) => {
|
|
808
|
-
return schema.properties?.[property];
|
|
809
|
-
};
|
|
810
|
-
var setSchemaProperty = (schema, property, value2) => {
|
|
811
|
-
schema.properties ??= {};
|
|
812
|
-
schema.properties[property] = value2;
|
|
813
|
-
return schema;
|
|
814
|
-
};
|
|
815
|
-
var ECHO_ANNOTATIONS_NS_DEPRECATED_KEY = "echo";
|
|
816
|
-
var ECHO_ANNOTATIONS_NS_KEY = "annotations";
|
|
817
|
-
var getNormalizedEchoAnnotations = (obj) => {
|
|
818
|
-
if (obj[ECHO_ANNOTATIONS_NS_KEY] != null && obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {
|
|
819
|
-
return normalizeEchoAnnotations({
|
|
820
|
-
...obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY],
|
|
821
|
-
...obj[ECHO_ANNOTATIONS_NS_KEY]
|
|
529
|
+
if (!isRootEchoObject) {
|
|
530
|
+
const ownershipAllowed = existingOwner == null || existingOwner === owner || existingOwner === newAllowedPreviousOwner;
|
|
531
|
+
invariant5(ownershipAllowed, "Cannot reassign ownership of a nested record to a different ECHO object. Use deep copy first.", {
|
|
532
|
+
F: __dxlog_file5,
|
|
533
|
+
L: 102,
|
|
534
|
+
S: void 0,
|
|
535
|
+
A: [
|
|
536
|
+
"ownershipAllowed",
|
|
537
|
+
"'Cannot reassign ownership of a nested record to a different ECHO object. Use deep copy first.'"
|
|
538
|
+
]
|
|
822
539
|
});
|
|
823
|
-
} else if (obj[ECHO_ANNOTATIONS_NS_KEY] != null) {
|
|
824
|
-
return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_KEY]);
|
|
825
|
-
} else if (obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {
|
|
826
|
-
return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY]);
|
|
827
|
-
} else {
|
|
828
|
-
return void 0;
|
|
829
540
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
541
|
+
defineHiddenProperty(actualValue, EchoOwner, owner);
|
|
542
|
+
const recursiveOptions = {
|
|
543
|
+
visited,
|
|
544
|
+
depth: depth + 1,
|
|
545
|
+
allowedPreviousOwner: newAllowedPreviousOwner
|
|
546
|
+
};
|
|
547
|
+
if (Array.isArray(actualValue)) {
|
|
548
|
+
for (const item of actualValue) {
|
|
549
|
+
if (isValidProxyTarget(item) || isProxy(item)) {
|
|
550
|
+
setOwnerRecursive(item, owner, recursiveOptions);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
834
553
|
} else {
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
554
|
+
for (const key in actualValue) {
|
|
555
|
+
if (Object.prototype.hasOwnProperty.call(actualValue, key)) {
|
|
556
|
+
const nested = actualValue[key];
|
|
557
|
+
if (isValidProxyTarget(nested) || isProxy(nested)) {
|
|
558
|
+
setOwnerRecursive(nested, owner, recursiveOptions);
|
|
559
|
+
}
|
|
840
560
|
}
|
|
841
|
-
}
|
|
842
|
-
delete res.annotations;
|
|
843
|
-
return res;
|
|
561
|
+
}
|
|
844
562
|
}
|
|
845
563
|
};
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
const copy = structuredClone(schema);
|
|
850
|
-
go(copy);
|
|
851
|
-
return copy;
|
|
852
|
-
};
|
|
853
|
-
var go = (schema) => {
|
|
854
|
-
if (typeof schema !== "object" || schema === null) {
|
|
855
|
-
return;
|
|
856
|
-
}
|
|
857
|
-
if (schema.exclusiveMaximum === true) {
|
|
858
|
-
schema.exclusiveMaximum = schema.maximum;
|
|
859
|
-
delete schema.exclusiveMaximum;
|
|
860
|
-
} else if (schema.exclusiveMaximum === false) {
|
|
861
|
-
delete schema.exclusiveMaximum;
|
|
862
|
-
}
|
|
863
|
-
if (schema.exclusiveMinimum === true) {
|
|
864
|
-
schema.exclusiveMinimum = schema.minimum;
|
|
865
|
-
delete schema.exclusiveMinimum;
|
|
866
|
-
} else if (schema.exclusiveMinimum === false) {
|
|
867
|
-
delete schema.exclusiveMinimum;
|
|
868
|
-
}
|
|
869
|
-
for (const key of Object.keys(schema)) {
|
|
870
|
-
if (!JsonSchemaFields.includes(key)) {
|
|
871
|
-
delete schema[key];
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
if (schema.properties) {
|
|
875
|
-
goOnRecord(schema.properties);
|
|
876
|
-
}
|
|
877
|
-
if (schema.patternProperties) {
|
|
878
|
-
goOnRecord(schema.patternProperties);
|
|
879
|
-
}
|
|
880
|
-
if (schema.propertyNames) {
|
|
881
|
-
go(schema.propertyNames);
|
|
882
|
-
}
|
|
883
|
-
if (schema.definitions) {
|
|
884
|
-
goOnRecord(schema.definitions);
|
|
885
|
-
}
|
|
886
|
-
if (schema.items) {
|
|
887
|
-
maybeGoOnArray(schema.items);
|
|
888
|
-
}
|
|
889
|
-
if (schema.additionalItems) {
|
|
890
|
-
maybeGoOnArray(schema.additionalItems);
|
|
891
|
-
}
|
|
892
|
-
if (schema.contains) {
|
|
893
|
-
go(schema.contains);
|
|
894
|
-
}
|
|
895
|
-
if (schema.if) {
|
|
896
|
-
go(schema.if);
|
|
897
|
-
}
|
|
898
|
-
if (schema.then) {
|
|
899
|
-
go(schema.then);
|
|
900
|
-
}
|
|
901
|
-
if (schema.else) {
|
|
902
|
-
go(schema.else);
|
|
903
|
-
}
|
|
904
|
-
if (schema.allOf) {
|
|
905
|
-
maybeGoOnArray(schema.allOf);
|
|
906
|
-
}
|
|
907
|
-
if (schema.anyOf) {
|
|
908
|
-
maybeGoOnArray(schema.anyOf);
|
|
909
|
-
}
|
|
910
|
-
if (schema.oneOf) {
|
|
911
|
-
maybeGoOnArray(schema.oneOf);
|
|
912
|
-
}
|
|
913
|
-
if (schema.not) {
|
|
914
|
-
go(schema.not);
|
|
564
|
+
var traverseObjectGraph = (value2, visitor, visited = /* @__PURE__ */ new Set()) => {
|
|
565
|
+
if (value2 == null || typeof value2 !== "object") {
|
|
566
|
+
return false;
|
|
915
567
|
}
|
|
916
|
-
|
|
917
|
-
|
|
568
|
+
const actualValue = getRawTarget(value2);
|
|
569
|
+
if (visited.has(actualValue)) {
|
|
570
|
+
return false;
|
|
918
571
|
}
|
|
919
|
-
|
|
920
|
-
|
|
572
|
+
visited.add(actualValue);
|
|
573
|
+
if (visitor(actualValue)) {
|
|
574
|
+
return true;
|
|
921
575
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
576
|
+
if (Array.isArray(actualValue)) {
|
|
577
|
+
for (const item of actualValue) {
|
|
578
|
+
if (traverseObjectGraph(item, visitor, visited)) {
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
927
581
|
}
|
|
928
|
-
} else
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
go(record[key]);
|
|
935
|
-
}
|
|
936
|
-
};
|
|
937
|
-
|
|
938
|
-
// src/internal/json-schema/json-schema.ts
|
|
939
|
-
import * as Array4 from "effect/Array";
|
|
940
|
-
import * as Function from "effect/Function";
|
|
941
|
-
import * as JSONSchema from "effect/JSONSchema";
|
|
942
|
-
import * as Option2 from "effect/Option";
|
|
943
|
-
import * as Schema9 from "effect/Schema";
|
|
944
|
-
import * as SchemaAST6 from "effect/SchemaAST";
|
|
945
|
-
import { raise as raise2 } from "@dxos/debug";
|
|
946
|
-
import { mapAst } from "@dxos/effect";
|
|
947
|
-
import { assertArgument as assertArgument6, invariant as invariant9 } from "@dxos/invariant";
|
|
948
|
-
import { DXN as DXN5, ObjectId as ObjectId4 } from "@dxos/keys";
|
|
949
|
-
import { log } from "@dxos/log";
|
|
950
|
-
import { clearUndefined, orderKeys, removeProperties } from "@dxos/util";
|
|
951
|
-
|
|
952
|
-
// src/internal/ref/ref.ts
|
|
953
|
-
import * as Effect from "effect/Effect";
|
|
954
|
-
import * as Equal from "effect/Equal";
|
|
955
|
-
import * as Hash from "effect/Hash";
|
|
956
|
-
import * as Option from "effect/Option";
|
|
957
|
-
import * as ParseResult from "effect/ParseResult";
|
|
958
|
-
import * as Pipeable from "effect/Pipeable";
|
|
959
|
-
import * as Schema8 from "effect/Schema";
|
|
960
|
-
import * as SchemaAST5 from "effect/SchemaAST";
|
|
961
|
-
import { Event } from "@dxos/async";
|
|
962
|
-
import { inspectCustom } from "@dxos/debug";
|
|
963
|
-
import { EncodedReference } from "@dxos/echo-protocol";
|
|
964
|
-
import { assertArgument as assertArgument5, invariant as invariant8 } from "@dxos/invariant";
|
|
965
|
-
import { DXN as DXN4, ObjectId as ObjectId3 } from "@dxos/keys";
|
|
966
|
-
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/ref/ref.ts";
|
|
967
|
-
var JSON_SCHEMA_ECHO_REF_ID = "/schemas/echo/ref";
|
|
968
|
-
var getSchemaReference = (property) => {
|
|
969
|
-
const { $id, reference: { schema: { $ref } = {} } = {} } = property;
|
|
970
|
-
if ($id === JSON_SCHEMA_ECHO_REF_ID && $ref) {
|
|
971
|
-
return {
|
|
972
|
-
typename: DXN4.parse($ref).typename
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
};
|
|
976
|
-
var createSchemaReference = (typename) => {
|
|
977
|
-
return {
|
|
978
|
-
$id: JSON_SCHEMA_ECHO_REF_ID,
|
|
979
|
-
reference: {
|
|
980
|
-
schema: {
|
|
981
|
-
$ref: DXN4.fromTypename(typename).toString()
|
|
582
|
+
} else {
|
|
583
|
+
for (const key in actualValue) {
|
|
584
|
+
if (Object.prototype.hasOwnProperty.call(actualValue, key)) {
|
|
585
|
+
if (traverseObjectGraph(actualValue[key], visitor, visited)) {
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
982
588
|
}
|
|
983
589
|
}
|
|
984
|
-
};
|
|
985
|
-
};
|
|
986
|
-
var getReferenceAst = (ast) => {
|
|
987
|
-
if (ast._tag !== "Declaration" || !ast.annotations[ReferenceAnnotationId]) {
|
|
988
|
-
return void 0;
|
|
989
590
|
}
|
|
990
|
-
return
|
|
991
|
-
typename: ast.annotations[ReferenceAnnotationId].typename,
|
|
992
|
-
version: ast.annotations[ReferenceAnnotationId].version
|
|
993
|
-
};
|
|
591
|
+
return false;
|
|
994
592
|
};
|
|
995
|
-
var
|
|
996
|
-
var
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
throw new Error("Reference target must be an ECHO schema.");
|
|
593
|
+
var wouldCreateCycle = (targetRoot, value2) => traverseObjectGraph(value2, (v) => v === targetRoot);
|
|
594
|
+
var hasForeignOwner = (value2, target) => traverseObjectGraph(value2, (v) => {
|
|
595
|
+
const owner = getOwner(v);
|
|
596
|
+
if (owner != null && owner !== target) {
|
|
597
|
+
return true;
|
|
1001
598
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
Ref.isRef = (obj) => {
|
|
1005
|
-
return obj && typeof obj === "object" && RefTypeId in obj;
|
|
1006
|
-
};
|
|
1007
|
-
Ref.hasObjectId = (id) => (ref) => ref.dxn.isLocalObjectId() && ref.dxn.parts[1] === id;
|
|
1008
|
-
Ref.isRefSchema = (schema) => {
|
|
1009
|
-
return Ref.isRefSchemaAST(schema.ast);
|
|
1010
|
-
};
|
|
1011
|
-
Ref.isRefSchemaAST = (ast) => {
|
|
1012
|
-
return SchemaAST5.getAnnotation(ast, ReferenceAnnotationId).pipe(Option.isSome);
|
|
1013
|
-
};
|
|
1014
|
-
Ref.make = (obj) => {
|
|
1015
|
-
if (typeof obj !== "object" || obj === null) {
|
|
1016
|
-
throw new TypeError("Expected: ECHO object.");
|
|
599
|
+
if (EventId in v && v !== target) {
|
|
600
|
+
return true;
|
|
1017
601
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
602
|
+
return false;
|
|
603
|
+
});
|
|
604
|
+
var MAX_OWNER_DEPTH = 100;
|
|
605
|
+
var getEchoRoot = (target, depth = 0) => {
|
|
606
|
+
invariant5(depth < MAX_OWNER_DEPTH, "Owner chain too deep - possible circular ownership", {
|
|
607
|
+
F: __dxlog_file5,
|
|
608
|
+
L: 221,
|
|
1022
609
|
S: void 0,
|
|
1023
610
|
A: [
|
|
1024
|
-
"
|
|
1025
|
-
"'
|
|
611
|
+
"depth < MAX_OWNER_DEPTH",
|
|
612
|
+
"'Owner chain too deep - possible circular ownership'"
|
|
1026
613
|
]
|
|
1027
614
|
});
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
};
|
|
1031
|
-
Ref.fromDXN = (dxn) => {
|
|
1032
|
-
assertArgument5(dxn instanceof DXN4, "dxn", "Expected DXN");
|
|
1033
|
-
return new RefImpl(dxn);
|
|
1034
|
-
};
|
|
1035
|
-
var createEchoReferenceSchema = (echoId, typename, version2) => {
|
|
1036
|
-
if (!echoId && !typename) {
|
|
1037
|
-
throw new TypeError("Either echoId or typename must be provided.");
|
|
615
|
+
if (KindId in target) {
|
|
616
|
+
return target;
|
|
1038
617
|
}
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
schemaVersion: version2
|
|
1045
|
-
};
|
|
1046
|
-
const refSchema = Schema8.declare([], {
|
|
1047
|
-
encode: () => {
|
|
1048
|
-
return (value2) => Effect.gen(function* () {
|
|
1049
|
-
if (Ref.isRef(value2)) {
|
|
1050
|
-
return EncodedReference.fromDXN(value2.dxn);
|
|
1051
|
-
} else if (EncodedReference.isEncodedReference(value2)) {
|
|
1052
|
-
return value2;
|
|
1053
|
-
}
|
|
1054
|
-
throw new Error("Invalid reference");
|
|
1055
|
-
});
|
|
1056
|
-
},
|
|
1057
|
-
decode: () => {
|
|
1058
|
-
return (value2) => Effect.gen(function* () {
|
|
1059
|
-
const dbService = yield* Effect.serviceOption(Service);
|
|
1060
|
-
if (Ref.isRef(value2)) {
|
|
1061
|
-
if (Option.isSome(dbService)) {
|
|
1062
|
-
return dbService.value.db.makeRef(value2.dxn);
|
|
1063
|
-
} else {
|
|
1064
|
-
return value2;
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
if (!EncodedReference.isEncodedReference(value2)) {
|
|
1068
|
-
return yield* Effect.fail(new ParseResult.Unexpected(value2, "reference"));
|
|
1069
|
-
}
|
|
1070
|
-
if (Option.isSome(dbService)) {
|
|
1071
|
-
return dbService.value.db.makeRef(EncodedReference.toDXN(value2));
|
|
1072
|
-
} else {
|
|
1073
|
-
return Ref.fromDXN(EncodedReference.toDXN(value2));
|
|
1074
|
-
}
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
}, {
|
|
1078
|
-
jsonSchema: {
|
|
1079
|
-
// TODO(dmaretskyi): We should remove `$id` and keep `$ref` with a fully qualified name.
|
|
1080
|
-
$id: JSON_SCHEMA_ECHO_REF_ID,
|
|
1081
|
-
$ref: JSON_SCHEMA_ECHO_REF_ID,
|
|
1082
|
-
reference: referenceInfo
|
|
1083
|
-
},
|
|
1084
|
-
[ReferenceAnnotationId]: {
|
|
1085
|
-
typename: typename ?? "",
|
|
1086
|
-
version: version2
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
return refSchema;
|
|
618
|
+
const owner = getOwner(target);
|
|
619
|
+
if (owner) {
|
|
620
|
+
return getEchoRoot(owner, depth + 1);
|
|
621
|
+
}
|
|
622
|
+
return target;
|
|
1090
623
|
};
|
|
1091
|
-
var
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
* Target is set when the reference is created from a specific object.
|
|
1097
|
-
* In this case, the target might not be in the database.
|
|
1098
|
-
*/
|
|
1099
|
-
#target = void 0;
|
|
1100
|
-
/**
|
|
1101
|
-
* Callback to issue a reactive notification when object is resolved.
|
|
1102
|
-
*/
|
|
1103
|
-
#resolverCallback = () => {
|
|
1104
|
-
this.#resolved.emit();
|
|
1105
|
-
};
|
|
1106
|
-
constructor(dxn, target) {
|
|
1107
|
-
this.#dxn = dxn;
|
|
1108
|
-
this.#target = target;
|
|
624
|
+
var notifyOwnerChain = (target) => {
|
|
625
|
+
const owner = getOwner(target);
|
|
626
|
+
if (owner) {
|
|
627
|
+
queueOwnerNotification(getEchoRoot(owner));
|
|
628
|
+
notifyOwnerChain(owner);
|
|
1109
629
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
// src/internal/common/proxy/proxy-types.ts
|
|
633
|
+
var objectData = /* @__PURE__ */ Symbol.for("@dxos/live-object/objectData");
|
|
634
|
+
|
|
635
|
+
// src/internal/common/proxy/reactive-array.ts
|
|
636
|
+
var checkArrayMutationAllowed = (arr, method) => {
|
|
637
|
+
const target = isProxy(arr) ? getProxyTarget(arr) : arr;
|
|
638
|
+
const echoRoot = getEchoRoot(target);
|
|
639
|
+
const isInitialized = echoRoot[ChangeId] === true || EventId in echoRoot;
|
|
640
|
+
if (!isInitialized) {
|
|
641
|
+
return;
|
|
1115
642
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
*/
|
|
1119
|
-
get isAvailable() {
|
|
1120
|
-
return this.#target !== void 0 || this.#resolver !== void 0;
|
|
643
|
+
if (!isInChangeContext(echoRoot)) {
|
|
644
|
+
throw createArrayMethodError(method);
|
|
1121
645
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
if (this.#target) {
|
|
1127
|
-
return this.#target;
|
|
1128
|
-
}
|
|
1129
|
-
invariant8(this.#resolver, "Resolver is not set", {
|
|
1130
|
-
F: __dxlog_file8,
|
|
1131
|
-
L: 393,
|
|
1132
|
-
S: this,
|
|
1133
|
-
A: [
|
|
1134
|
-
"this.#resolver",
|
|
1135
|
-
"'Resolver is not set'"
|
|
1136
|
-
]
|
|
1137
|
-
});
|
|
1138
|
-
return this.#resolver.resolveSync(this.#dxn, true, this.#resolverCallback);
|
|
646
|
+
};
|
|
647
|
+
var ReactiveArray = class extends Array {
|
|
648
|
+
static get [Symbol.species]() {
|
|
649
|
+
return Array;
|
|
1139
650
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
651
|
+
static {
|
|
652
|
+
const BATCHED_METHODS = [
|
|
653
|
+
"push",
|
|
654
|
+
"pop",
|
|
655
|
+
"shift",
|
|
656
|
+
"unshift",
|
|
657
|
+
"splice",
|
|
658
|
+
"sort",
|
|
659
|
+
"reverse"
|
|
660
|
+
];
|
|
661
|
+
for (const method of BATCHED_METHODS) {
|
|
662
|
+
Object.defineProperty(this.prototype, method, {
|
|
663
|
+
enumerable: false,
|
|
664
|
+
value: function(...args) {
|
|
665
|
+
checkArrayMutationAllowed(this, method);
|
|
666
|
+
let result;
|
|
667
|
+
batchEvents(() => {
|
|
668
|
+
result = Array.prototype[method].apply(this, args);
|
|
669
|
+
});
|
|
670
|
+
return result;
|
|
671
|
+
}
|
|
672
|
+
});
|
|
1159
673
|
}
|
|
1160
|
-
return obj;
|
|
1161
674
|
}
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
// src/internal/common/proxy/schema-validator.ts
|
|
678
|
+
import * as Schema3 from "effect/Schema";
|
|
679
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
680
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
681
|
+
import { log } from "@dxos/log";
|
|
682
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/proxy/schema-validator.ts";
|
|
683
|
+
var SchemaValidator = class {
|
|
1162
684
|
/**
|
|
1163
|
-
*
|
|
685
|
+
* Recursively check that schema specifies constructions we can handle.
|
|
686
|
+
* Validates there are no ambiguous discriminated union types.
|
|
1164
687
|
*/
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
688
|
+
static validateSchema(schema) {
|
|
689
|
+
const visitAll = (nodes) => nodes.forEach((node) => this.validateSchema(Schema3.make(node)));
|
|
690
|
+
if (SchemaAST2.isUnion(schema.ast)) {
|
|
691
|
+
const typeAstList = schema.ast.types.filter((type) => SchemaAST2.isTypeLiteral(type));
|
|
692
|
+
if (typeAstList.length > 1) {
|
|
693
|
+
getTypeDiscriminators(typeAstList);
|
|
694
|
+
}
|
|
695
|
+
visitAll(typeAstList);
|
|
696
|
+
} else if (SchemaAST2.isTupleType(schema.ast)) {
|
|
697
|
+
const positionalTypes = schema.ast.elements.map((t) => t.type);
|
|
698
|
+
const allTypes = positionalTypes.concat(schema.ast.rest.map((t) => t.type));
|
|
699
|
+
visitAll(allTypes);
|
|
700
|
+
} else if (SchemaAST2.isTypeLiteral(schema.ast)) {
|
|
701
|
+
visitAll(SchemaAST2.getPropertySignatures(schema.ast).map((p) => p.type));
|
|
1168
702
|
}
|
|
1169
|
-
invariant8(this.#resolver, "Resolver is not set", {
|
|
1170
|
-
F: __dxlog_file8,
|
|
1171
|
-
L: 419,
|
|
1172
|
-
S: this,
|
|
1173
|
-
A: [
|
|
1174
|
-
"this.#resolver",
|
|
1175
|
-
"'Resolver is not set'"
|
|
1176
|
-
]
|
|
1177
|
-
});
|
|
1178
|
-
return await this.#resolver.resolve(this.#dxn);
|
|
1179
|
-
}
|
|
1180
|
-
/**
|
|
1181
|
-
* Do not inline the target object in the reference.
|
|
1182
|
-
* Makes .target unavailable unless the reference is connected to a database context.
|
|
1183
|
-
* Clones the reference object.
|
|
1184
|
-
*/
|
|
1185
|
-
noInline() {
|
|
1186
|
-
const ref = new _RefImpl(this.#dxn, void 0);
|
|
1187
|
-
ref.#resolver = this.#resolver;
|
|
1188
|
-
return ref;
|
|
1189
703
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
* The serialization format is compatible with the IPLD-style encoded references.
|
|
1201
|
-
* When a reference has a saved target (i.e. the target or object holding the reference is not in the database),
|
|
1202
|
-
* the target is included in the serialized object.
|
|
1203
|
-
*/
|
|
1204
|
-
toJSON() {
|
|
1205
|
-
return this.encode();
|
|
1206
|
-
}
|
|
1207
|
-
toString() {
|
|
1208
|
-
if (this.#target) {
|
|
1209
|
-
return `Ref(${this.#target.toString()})`;
|
|
1210
|
-
}
|
|
1211
|
-
return `Ref(${this.#dxn.toString()})`;
|
|
1212
|
-
}
|
|
1213
|
-
[inspectCustom] = (depth, options, inspect) => {
|
|
1214
|
-
return this.toString();
|
|
1215
|
-
};
|
|
1216
|
-
[RefTypeId] = refVariance;
|
|
1217
|
-
/**
|
|
1218
|
-
* Effect Hash trait. Required for MutableHashMap-based caches (e.g., Atom.family)
|
|
1219
|
-
* to deduplicate Ref instances that point to the same object.
|
|
1220
|
-
* ECHO proxies return new RefImpl instances on every property access,
|
|
1221
|
-
* so without this, each access would create a separate cache entry.
|
|
1222
|
-
*/
|
|
1223
|
-
[Hash.symbol]() {
|
|
1224
|
-
return Hash.hash(this.#dxn.toString());
|
|
1225
|
-
}
|
|
1226
|
-
/** Effect Equal trait. See {@link Hash.symbol} for rationale. */
|
|
1227
|
-
[Equal.symbol](that) {
|
|
1228
|
-
return that instanceof _RefImpl && this.#dxn.toString() === that.dxn.toString();
|
|
1229
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
* Internal method to set the resolver.
|
|
1232
|
-
*
|
|
1233
|
-
* @internal
|
|
1234
|
-
*/
|
|
1235
|
-
_setResolver(resolver) {
|
|
1236
|
-
this.#resolver = resolver;
|
|
1237
|
-
}
|
|
1238
|
-
/**
|
|
1239
|
-
* @internal
|
|
1240
|
-
*/
|
|
1241
|
-
_getSavedTarget() {
|
|
1242
|
-
return this.#target;
|
|
1243
|
-
}
|
|
1244
|
-
pipe() {
|
|
1245
|
-
return Pipeable.pipeArguments(this, arguments);
|
|
1246
|
-
}
|
|
1247
|
-
};
|
|
1248
|
-
var setRefResolver = (ref, resolver) => {
|
|
1249
|
-
invariant8(ref instanceof RefImpl, "Ref is not an instance of RefImpl", {
|
|
1250
|
-
F: __dxlog_file8,
|
|
1251
|
-
L: 506,
|
|
1252
|
-
S: void 0,
|
|
1253
|
-
A: [
|
|
1254
|
-
"ref instanceof RefImpl",
|
|
1255
|
-
"'Ref is not an instance of RefImpl'"
|
|
1256
|
-
]
|
|
1257
|
-
});
|
|
1258
|
-
ref._setResolver(resolver);
|
|
1259
|
-
};
|
|
1260
|
-
var getRefSavedTarget = (ref) => {
|
|
1261
|
-
invariant8(ref instanceof RefImpl, "Ref is not an instance of RefImpl", {
|
|
1262
|
-
F: __dxlog_file8,
|
|
1263
|
-
L: 514,
|
|
1264
|
-
S: void 0,
|
|
1265
|
-
A: [
|
|
1266
|
-
"ref instanceof RefImpl",
|
|
1267
|
-
"'Ref is not an instance of RefImpl'"
|
|
1268
|
-
]
|
|
1269
|
-
});
|
|
1270
|
-
return ref._getSavedTarget();
|
|
1271
|
-
};
|
|
1272
|
-
var refVariance = {
|
|
1273
|
-
_T: null
|
|
1274
|
-
};
|
|
1275
|
-
var refFromEncodedReference = (encodedReference, resolver) => {
|
|
1276
|
-
const dxn = DXN4.parse(encodedReference["/"]);
|
|
1277
|
-
const ref = new RefImpl(dxn);
|
|
1278
|
-
if (resolver) {
|
|
1279
|
-
setRefResolver(ref, resolver);
|
|
1280
|
-
}
|
|
1281
|
-
return ref;
|
|
1282
|
-
};
|
|
1283
|
-
var StaticRefResolver = class {
|
|
1284
|
-
objects = /* @__PURE__ */ new Map();
|
|
1285
|
-
schemas = /* @__PURE__ */ new Map();
|
|
1286
|
-
addObject(obj) {
|
|
1287
|
-
this.objects.set(obj.id, obj);
|
|
1288
|
-
return this;
|
|
1289
|
-
}
|
|
1290
|
-
addSchema(schema) {
|
|
1291
|
-
const dxn = getSchemaDXN(schema);
|
|
1292
|
-
invariant8(dxn, "Schema has no DXN", {
|
|
1293
|
-
F: __dxlog_file8,
|
|
1294
|
-
L: 546,
|
|
1295
|
-
S: this,
|
|
1296
|
-
A: [
|
|
1297
|
-
"dxn",
|
|
1298
|
-
"'Schema has no DXN'"
|
|
1299
|
-
]
|
|
1300
|
-
});
|
|
1301
|
-
this.schemas.set(dxn.toString(), schema);
|
|
1302
|
-
return this;
|
|
1303
|
-
}
|
|
1304
|
-
resolveSync(dxn, _load, _onLoad) {
|
|
1305
|
-
const id = dxn?.asEchoDXN()?.echoId;
|
|
1306
|
-
if (id == null) {
|
|
1307
|
-
return void 0;
|
|
1308
|
-
}
|
|
1309
|
-
return this.objects.get(id);
|
|
1310
|
-
}
|
|
1311
|
-
async resolve(dxn) {
|
|
1312
|
-
const id = dxn?.asEchoDXN()?.echoId;
|
|
1313
|
-
if (id == null) {
|
|
1314
|
-
return void 0;
|
|
1315
|
-
}
|
|
1316
|
-
return this.objects.get(id);
|
|
1317
|
-
}
|
|
1318
|
-
async resolveSchema(dxn) {
|
|
1319
|
-
return this.schemas.get(dxn.toString());
|
|
1320
|
-
}
|
|
1321
|
-
};
|
|
1322
|
-
|
|
1323
|
-
// src/internal/ref/ref-array.ts
|
|
1324
|
-
import { isNonNullable } from "@dxos/util";
|
|
1325
|
-
var RefArray = Object.freeze({
|
|
1326
|
-
/**
|
|
1327
|
-
* @returns all resolved targets.
|
|
1328
|
-
*/
|
|
1329
|
-
targets: (refs) => {
|
|
1330
|
-
return refs.map((ref) => ref.target).filter(isNonNullable);
|
|
1331
|
-
},
|
|
1332
|
-
/**
|
|
1333
|
-
* Load all referenced objects.
|
|
1334
|
-
*/
|
|
1335
|
-
loadAll: (refs) => {
|
|
1336
|
-
return Promise.all(refs.map((ref) => ref.load()));
|
|
1337
|
-
},
|
|
1338
|
-
/**
|
|
1339
|
-
* Removes the ref with the given id.
|
|
1340
|
-
*/
|
|
1341
|
-
removeById: (refs, id) => {
|
|
1342
|
-
const index = refs.findIndex(Ref.hasObjectId(id));
|
|
1343
|
-
if (index >= 0) {
|
|
1344
|
-
refs.splice(index, 1);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
});
|
|
1348
|
-
|
|
1349
|
-
// src/internal/json-schema/json-schema.ts
|
|
1350
|
-
var __dxlog_file9 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/json-schema/json-schema.ts";
|
|
1351
|
-
var PropType = /* @__PURE__ */ (function(PropType2) {
|
|
1352
|
-
PropType2[PropType2["NONE"] = 0] = "NONE";
|
|
1353
|
-
PropType2[PropType2["STRING"] = 1] = "STRING";
|
|
1354
|
-
PropType2[PropType2["NUMBER"] = 2] = "NUMBER";
|
|
1355
|
-
PropType2[PropType2["BOOLEAN"] = 3] = "BOOLEAN";
|
|
1356
|
-
PropType2[PropType2["DATE"] = 4] = "DATE";
|
|
1357
|
-
PropType2[PropType2["REF"] = 5] = "REF";
|
|
1358
|
-
PropType2[PropType2["RECORD"] = 6] = "RECORD";
|
|
1359
|
-
PropType2[PropType2["ENUM"] = 7] = "ENUM";
|
|
1360
|
-
return PropType2;
|
|
1361
|
-
})({});
|
|
1362
|
-
var toPropType = (type) => {
|
|
1363
|
-
switch (type) {
|
|
1364
|
-
case 1:
|
|
1365
|
-
return "string";
|
|
1366
|
-
case 2:
|
|
1367
|
-
return "number";
|
|
1368
|
-
case 3:
|
|
1369
|
-
return "boolean";
|
|
1370
|
-
case 4:
|
|
1371
|
-
return "date";
|
|
1372
|
-
case 5:
|
|
1373
|
-
return "ref";
|
|
1374
|
-
case 6:
|
|
1375
|
-
return "object";
|
|
1376
|
-
default:
|
|
1377
|
-
throw new Error(`Invalid type: ${type}`);
|
|
1378
|
-
}
|
|
1379
|
-
};
|
|
1380
|
-
var JSON_SCHEMA_URL = "http://json-schema.org/draft-07/schema#";
|
|
1381
|
-
var toJsonSchema = (schema, options = {}) => {
|
|
1382
|
-
assertArgument6(Schema9.isSchema(schema), "schema");
|
|
1383
|
-
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
1384
|
-
if (options.strict) {
|
|
1385
|
-
jsonSchema = removeProperties(jsonSchema, (key, value2) => {
|
|
1386
|
-
if (key === "$id" && value2 === "/schemas/any") {
|
|
1387
|
-
return true;
|
|
1388
|
-
}
|
|
1389
|
-
if (key === "$ref" && value2 === "#/$defs/dependency") {
|
|
1390
|
-
return true;
|
|
1391
|
-
}
|
|
1392
|
-
if (key === "$ref" && value2 === "#/$defs/jsonSchema") {
|
|
1393
|
-
return true;
|
|
704
|
+
static hasTypeAnnotation(rootObjectSchema, property, annotation) {
|
|
705
|
+
try {
|
|
706
|
+
let type = this.getPropertySchema(rootObjectSchema, [
|
|
707
|
+
property
|
|
708
|
+
]);
|
|
709
|
+
if (SchemaAST2.isTupleType(type.ast)) {
|
|
710
|
+
type = this.getPropertySchema(rootObjectSchema, [
|
|
711
|
+
property,
|
|
712
|
+
"0"
|
|
713
|
+
]);
|
|
1394
714
|
}
|
|
715
|
+
return type.ast.annotations[annotation] != null;
|
|
716
|
+
} catch {
|
|
1395
717
|
return false;
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
return jsonSchema;
|
|
1399
|
-
};
|
|
1400
|
-
var _toJsonSchemaAST = (ast) => {
|
|
1401
|
-
const withRefinements = withEchoRefinements(ast, "#");
|
|
1402
|
-
const jsonSchema = JSONSchema.fromAST(withRefinements, {
|
|
1403
|
-
definitions: {}
|
|
1404
|
-
});
|
|
1405
|
-
return normalizeJsonSchema(jsonSchema);
|
|
1406
|
-
};
|
|
1407
|
-
var withEchoRefinements = (ast, path, suspendCache = /* @__PURE__ */ new Map()) => {
|
|
1408
|
-
if (path) {
|
|
1409
|
-
suspendCache.set(ast, path);
|
|
1410
|
-
}
|
|
1411
|
-
let recursiveResult;
|
|
1412
|
-
if (SchemaAST6.isSuspend(ast)) {
|
|
1413
|
-
const suspendedAst = ast.f();
|
|
1414
|
-
const cachedPath = suspendCache.get(suspendedAst);
|
|
1415
|
-
if (cachedPath) {
|
|
1416
|
-
recursiveResult = new SchemaAST6.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {
|
|
1417
|
-
[SchemaAST6.JSONSchemaAnnotationId]: {
|
|
1418
|
-
$ref: cachedPath
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
} else {
|
|
1422
|
-
const jsonSchema = _toJsonSchemaAST(suspendedAst);
|
|
1423
|
-
recursiveResult = new SchemaAST6.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {
|
|
1424
|
-
[SchemaAST6.JSONSchemaAnnotationId]: jsonSchema
|
|
1425
|
-
});
|
|
1426
718
|
}
|
|
1427
|
-
} else if (SchemaAST6.isTypeLiteral(ast)) {
|
|
1428
|
-
recursiveResult = mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && typeof key === "string" ? `${path}/${key}` : void 0, suspendCache));
|
|
1429
|
-
recursiveResult = addJsonSchemaFields(recursiveResult, {
|
|
1430
|
-
propertyOrder: [
|
|
1431
|
-
...ast.propertySignatures.map((p) => p.name)
|
|
1432
|
-
]
|
|
1433
|
-
});
|
|
1434
|
-
} else if (SchemaAST6.isUndefinedKeyword(ast)) {
|
|
1435
|
-
return ast;
|
|
1436
|
-
} else {
|
|
1437
|
-
recursiveResult = mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && (typeof key === "string" || typeof key === "number") ? `${path}/${key}` : void 0, suspendCache));
|
|
1438
719
|
}
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
} else if ("$id" in root) {
|
|
1463
|
-
switch (root.$id) {
|
|
1464
|
-
case "/schemas/any": {
|
|
1465
|
-
result = anyToEffectSchema(root);
|
|
1466
|
-
break;
|
|
1467
|
-
}
|
|
1468
|
-
case "/schemas/unknown": {
|
|
1469
|
-
result = Schema9.Unknown;
|
|
1470
|
-
break;
|
|
1471
|
-
}
|
|
1472
|
-
case "/schemas/{}":
|
|
1473
|
-
case "/schemas/object": {
|
|
1474
|
-
result = Schema9.Object;
|
|
1475
|
-
break;
|
|
1476
|
-
}
|
|
1477
|
-
// Custom ECHO object reference.
|
|
1478
|
-
case "/schemas/echo/ref": {
|
|
1479
|
-
result = refToEffectSchema(root);
|
|
1480
|
-
break;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
} else if ("enum" in root) {
|
|
1484
|
-
result = Schema9.Union(...root.enum.map((e) => Schema9.Literal(e)));
|
|
1485
|
-
} else if ("oneOf" in root) {
|
|
1486
|
-
result = Schema9.Union(...root.oneOf.map((v) => toEffectSchema(v, defs)));
|
|
1487
|
-
} else if ("anyOf" in root) {
|
|
1488
|
-
result = Schema9.Union(...root.anyOf.map((v) => toEffectSchema(v, defs)));
|
|
1489
|
-
} else if ("allOf" in root) {
|
|
1490
|
-
if (root.allOf.length === 1) {
|
|
1491
|
-
result = toEffectSchema(root.allOf[0], defs);
|
|
1492
|
-
} else {
|
|
1493
|
-
log.warn("allOf with multiple schemas is not supported", void 0, {
|
|
1494
|
-
F: __dxlog_file9,
|
|
1495
|
-
L: 224,
|
|
1496
|
-
S: void 0,
|
|
1497
|
-
C: (f, a) => f(...a)
|
|
1498
|
-
});
|
|
1499
|
-
result = Schema9.Unknown;
|
|
1500
|
-
}
|
|
1501
|
-
} else if ("type" in root) {
|
|
1502
|
-
switch (root.type) {
|
|
1503
|
-
case "string": {
|
|
1504
|
-
result = Schema9.String;
|
|
1505
|
-
if (root.pattern) {
|
|
1506
|
-
result = result.pipe(Schema9.pattern(new RegExp(root.pattern)));
|
|
1507
|
-
}
|
|
1508
|
-
break;
|
|
1509
|
-
}
|
|
1510
|
-
case "number": {
|
|
1511
|
-
result = Schema9.Number;
|
|
1512
|
-
break;
|
|
1513
|
-
}
|
|
1514
|
-
case "integer": {
|
|
1515
|
-
result = Schema9.Number.pipe(Schema9.int());
|
|
1516
|
-
break;
|
|
1517
|
-
}
|
|
1518
|
-
case "boolean": {
|
|
1519
|
-
result = Schema9.Boolean;
|
|
1520
|
-
break;
|
|
1521
|
-
}
|
|
1522
|
-
case "array": {
|
|
1523
|
-
if (Array4.isArray(root.items)) {
|
|
1524
|
-
const [required, optional5] = Function.pipe(root.items, Array4.map((v) => toEffectSchema(v, defs)), Array4.splitAt(root.minItems ?? root.items.length));
|
|
1525
|
-
result = Schema9.Tuple(...required, ...optional5.map(Schema9.optionalElement));
|
|
1526
|
-
} else {
|
|
1527
|
-
invariant9(root.items, void 0, {
|
|
1528
|
-
F: __dxlog_file9,
|
|
1529
|
-
L: 257,
|
|
1530
|
-
S: void 0,
|
|
1531
|
-
A: [
|
|
1532
|
-
"root.items",
|
|
1533
|
-
""
|
|
1534
|
-
]
|
|
720
|
+
static getPropertySchema(rootObjectSchema, propertyPath, getProperty = () => null) {
|
|
721
|
+
let schema = rootObjectSchema;
|
|
722
|
+
for (let i = 0; i < propertyPath.length; i++) {
|
|
723
|
+
const propertyName = propertyPath[i];
|
|
724
|
+
const tupleAst = unwrapArray(schema.ast);
|
|
725
|
+
if (tupleAst != null) {
|
|
726
|
+
schema = getArrayElementSchema(tupleAst, propertyName);
|
|
727
|
+
} else {
|
|
728
|
+
const propertyType = getPropertyType(schema.ast, propertyName.toString(), (propertyName2) => getProperty([
|
|
729
|
+
...propertyPath.slice(0, i),
|
|
730
|
+
propertyName2
|
|
731
|
+
]));
|
|
732
|
+
if (propertyType == null) {
|
|
733
|
+
log.warn("unknown property", {
|
|
734
|
+
path: propertyPath,
|
|
735
|
+
property: propertyName
|
|
736
|
+
}, {
|
|
737
|
+
F: __dxlog_file6,
|
|
738
|
+
L: 71,
|
|
739
|
+
S: this,
|
|
740
|
+
C: (f, a) => f(...a)
|
|
1535
741
|
});
|
|
1536
|
-
|
|
1537
|
-
result = Array4.isArray(items) ? Schema9.Tuple(...items.map((v) => toEffectSchema(v, defs))) : Schema9.Array(toEffectSchema(items, defs));
|
|
742
|
+
continue;
|
|
1538
743
|
}
|
|
1539
|
-
|
|
1540
|
-
}
|
|
1541
|
-
case "null": {
|
|
1542
|
-
result = Schema9.Null;
|
|
1543
|
-
break;
|
|
744
|
+
schema = Schema3.make(propertyType).annotations(propertyType.annotations);
|
|
1544
745
|
}
|
|
1545
746
|
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
747
|
+
return schema;
|
|
748
|
+
}
|
|
749
|
+
static getTargetPropertySchema(target, prop) {
|
|
750
|
+
const schema = target[SchemaId];
|
|
751
|
+
invariant6(schema, "target has no schema", {
|
|
752
|
+
F: __dxlog_file6,
|
|
753
|
+
L: 84,
|
|
754
|
+
S: this,
|
|
1553
755
|
A: [
|
|
1554
|
-
"
|
|
1555
|
-
"
|
|
756
|
+
"schema",
|
|
757
|
+
"'target has no schema'"
|
|
1556
758
|
]
|
|
1557
759
|
});
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
}
|
|
1562
|
-
const annotations4 = jsonSchemaFieldsToAnnotations(root);
|
|
1563
|
-
result = result.annotations(annotations4);
|
|
1564
|
-
return result;
|
|
1565
|
-
};
|
|
1566
|
-
var objectToEffectSchema = (root, defs) => {
|
|
1567
|
-
invariant9("type" in root && root.type === "object", `not an object: ${root}`, {
|
|
1568
|
-
F: __dxlog_file9,
|
|
1569
|
-
L: 288,
|
|
1570
|
-
S: void 0,
|
|
1571
|
-
A: [
|
|
1572
|
-
"'type' in root && root.type === 'object'",
|
|
1573
|
-
"`not an object: ${root}`"
|
|
1574
|
-
]
|
|
1575
|
-
});
|
|
1576
|
-
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
1577
|
-
const isEchoObject = echoRefinement != null || "$id" in root && typeof root.$id === "string" && root.$id.startsWith("dxn:");
|
|
1578
|
-
let fields = {};
|
|
1579
|
-
const propertyList = Object.entries(root.properties ?? {});
|
|
1580
|
-
let immutableIdField;
|
|
1581
|
-
for (const [key, value2] of propertyList) {
|
|
1582
|
-
if (isEchoObject && key === "id") {
|
|
1583
|
-
immutableIdField = toEffectSchema(value2, defs);
|
|
1584
|
-
} else {
|
|
1585
|
-
fields[key] = root.required?.includes(key) ? toEffectSchema(value2, defs) : Schema9.optional(toEffectSchema(value2, defs));
|
|
760
|
+
const arrayAst = unwrapArray(schema.ast);
|
|
761
|
+
if (arrayAst != null) {
|
|
762
|
+
return getArrayElementSchema(arrayAst, prop);
|
|
1586
763
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
L: 314,
|
|
1596
|
-
S: void 0,
|
|
764
|
+
const propertyType = getPropertyType(schema.ast, prop.toString(), (prop2) => target[prop2]);
|
|
765
|
+
if (propertyType == null) {
|
|
766
|
+
return Schema3.Any;
|
|
767
|
+
}
|
|
768
|
+
invariant6(propertyType, `invalid property: ${prop.toString()}`, {
|
|
769
|
+
F: __dxlog_file6,
|
|
770
|
+
L: 95,
|
|
771
|
+
S: this,
|
|
1597
772
|
A: [
|
|
1598
|
-
"
|
|
1599
|
-
"
|
|
773
|
+
"propertyType",
|
|
774
|
+
"`invalid property: ${prop.toString()}`"
|
|
1600
775
|
]
|
|
1601
776
|
});
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
777
|
+
return Schema3.make(propertyType);
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
var getArrayElementSchema = (tupleAst, property) => {
|
|
781
|
+
const elementIndex = typeof property === "string" ? parseInt(property, 10) : Number.NaN;
|
|
782
|
+
if (Number.isNaN(elementIndex)) {
|
|
783
|
+
invariant6(property === "length", `invalid array property: ${String(property)}`, {
|
|
784
|
+
F: __dxlog_file6,
|
|
785
|
+
L: 111,
|
|
1605
786
|
S: void 0,
|
|
1606
787
|
A: [
|
|
1607
|
-
"
|
|
1608
|
-
"
|
|
788
|
+
"property === 'length'",
|
|
789
|
+
"`invalid array property: ${String(property)}`"
|
|
1609
790
|
]
|
|
1610
791
|
});
|
|
1611
|
-
|
|
1612
|
-
key: Schema9.String,
|
|
1613
|
-
value: toEffectSchema(root.patternProperties[""], defs)
|
|
1614
|
-
});
|
|
1615
|
-
} else if (typeof root.additionalProperties !== "object") {
|
|
1616
|
-
schema = Schema9.Struct(fields);
|
|
1617
|
-
} else {
|
|
1618
|
-
const indexValue = toEffectSchema(root.additionalProperties, defs);
|
|
1619
|
-
if (propertyList.length > 0) {
|
|
1620
|
-
schema = Schema9.Struct(fields, {
|
|
1621
|
-
key: Schema9.String,
|
|
1622
|
-
value: indexValue
|
|
1623
|
-
});
|
|
1624
|
-
} else {
|
|
1625
|
-
schema = Schema9.Record({
|
|
1626
|
-
key: Schema9.String,
|
|
1627
|
-
value: indexValue
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
792
|
+
return Schema3.Number;
|
|
1630
793
|
}
|
|
1631
|
-
if (
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
}));
|
|
1635
|
-
}
|
|
1636
|
-
const annotations4 = jsonSchemaFieldsToAnnotations(root);
|
|
1637
|
-
return schema.annotations(annotations4);
|
|
1638
|
-
};
|
|
1639
|
-
var anyToEffectSchema = (root) => {
|
|
1640
|
-
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
1641
|
-
if (echoRefinement?.reference != null) {
|
|
1642
|
-
const echoId = root.$id.startsWith("dxn:echo:") ? root.$id : void 0;
|
|
1643
|
-
return createEchoReferenceSchema(echoId, echoRefinement.reference.typename, echoRefinement.reference.version);
|
|
794
|
+
if (elementIndex < tupleAst.elements.length) {
|
|
795
|
+
const elementType = tupleAst.elements[elementIndex].type;
|
|
796
|
+
return Schema3.make(elementType).annotations(elementType.annotations);
|
|
1644
797
|
}
|
|
1645
|
-
|
|
798
|
+
const restType = tupleAst.rest;
|
|
799
|
+
return Schema3.make(restType[0].type).annotations(restType[0].annotations);
|
|
1646
800
|
};
|
|
1647
|
-
var
|
|
1648
|
-
|
|
1649
|
-
|
|
801
|
+
var flattenUnion = (typeAst) => SchemaAST2.isUnion(typeAst) ? typeAst.types.flatMap(flattenUnion) : [
|
|
802
|
+
typeAst
|
|
803
|
+
];
|
|
804
|
+
var getProperties = (typeAst, getTargetPropertyFn) => {
|
|
805
|
+
const astCandidates = flattenUnion(typeAst);
|
|
806
|
+
const typeAstList = astCandidates.filter((type) => SchemaAST2.isTypeLiteral(type));
|
|
807
|
+
if (typeAstList.length === 0) {
|
|
808
|
+
return [];
|
|
1650
809
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
throw new Error("Invalid reference field in ref schema");
|
|
810
|
+
if (typeAstList.length === 1) {
|
|
811
|
+
return SchemaAST2.getPropertySignatures(typeAstList[0]);
|
|
1654
812
|
}
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
813
|
+
const typeDiscriminators = getTypeDiscriminators(typeAstList);
|
|
814
|
+
const targetPropertyValue = getTargetPropertyFn(String(typeDiscriminators[0].name));
|
|
815
|
+
const typeIndex = typeDiscriminators.findIndex((p) => targetPropertyValue === p.type.literal);
|
|
816
|
+
invariant6(typeIndex !== -1, "discriminator field not set on target", {
|
|
817
|
+
F: __dxlog_file6,
|
|
818
|
+
L: 142,
|
|
1659
819
|
S: void 0,
|
|
1660
820
|
A: [
|
|
1661
|
-
"
|
|
1662
|
-
""
|
|
821
|
+
"typeIndex !== -1",
|
|
822
|
+
"'discriminator field not set on target'"
|
|
1663
823
|
]
|
|
1664
824
|
});
|
|
1665
|
-
return
|
|
825
|
+
return SchemaAST2.getPropertySignatures(typeAstList[typeIndex]);
|
|
1666
826
|
};
|
|
1667
|
-
var
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
if (annotations4[annotationId] != null) {
|
|
1672
|
-
echoAnnotations[key] = annotations4[annotationId];
|
|
1673
|
-
}
|
|
827
|
+
var getPropertyType = (ast, propertyName, getTargetPropertyFn) => {
|
|
828
|
+
const anyOrObject = unwrapAst(ast, (candidate) => SchemaAST2.isAnyKeyword(candidate) || SchemaAST2.isObjectKeyword(candidate));
|
|
829
|
+
if (anyOrObject != null) {
|
|
830
|
+
return ast;
|
|
1674
831
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
832
|
+
const typeOrDiscriminatedUnion = unwrapAst(ast, (t) => {
|
|
833
|
+
return SchemaAST2.isTypeLiteral(t) || SchemaAST2.isUnion(t) && t.types.some((t2) => SchemaAST2.isTypeLiteral(t2));
|
|
834
|
+
});
|
|
835
|
+
if (typeOrDiscriminatedUnion == null) {
|
|
836
|
+
return null;
|
|
1677
837
|
}
|
|
1678
|
-
const
|
|
1679
|
-
if (
|
|
1680
|
-
|
|
1681
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
838
|
+
const targetProperty = getProperties(typeOrDiscriminatedUnion, getTargetPropertyFn).find((p) => p.name === propertyName);
|
|
839
|
+
if (targetProperty != null) {
|
|
840
|
+
return unwrapAst(targetProperty.type);
|
|
1682
841
|
}
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
schemaFields[key] = value2;
|
|
1687
|
-
}
|
|
842
|
+
const indexSignatureType = unwrapAst(ast, SchemaAST2.isTypeLiteral);
|
|
843
|
+
if (indexSignatureType && SchemaAST2.isTypeLiteral(indexSignatureType) && indexSignatureType.indexSignatures.length > 0) {
|
|
844
|
+
return unwrapAst(indexSignatureType.indexSignatures[0].type);
|
|
1688
845
|
}
|
|
1689
|
-
return
|
|
846
|
+
return null;
|
|
1690
847
|
};
|
|
1691
|
-
var
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
848
|
+
var getTypeDiscriminators = (typeAstList) => {
|
|
849
|
+
const discriminatorPropCandidates = typeAstList.flatMap(SchemaAST2.getPropertySignatures).filter((p) => SchemaAST2.isLiteral(p.type));
|
|
850
|
+
const propertyName = discriminatorPropCandidates[0].name;
|
|
851
|
+
const isValidDiscriminator = discriminatorPropCandidates.every((p) => p.name === propertyName && !p.isOptional);
|
|
852
|
+
const everyTypeHasDiscriminator = discriminatorPropCandidates.length === typeAstList.length;
|
|
853
|
+
const isDiscriminatedUnion = isValidDiscriminator && everyTypeHasDiscriminator;
|
|
854
|
+
invariant6(isDiscriminatedUnion, "type ambiguity: every type in a union must have a single unique-literal field", {
|
|
855
|
+
F: __dxlog_file6,
|
|
856
|
+
L: 193,
|
|
857
|
+
S: void 0,
|
|
858
|
+
A: [
|
|
859
|
+
"isDiscriminatedUnion",
|
|
860
|
+
"'type ambiguity: every type in a union must have a single unique-literal field'"
|
|
861
|
+
]
|
|
862
|
+
});
|
|
863
|
+
return discriminatorPropCandidates;
|
|
1701
864
|
};
|
|
1702
|
-
var
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
typename: schema.typename,
|
|
1708
|
-
version: schema.version ?? "0.1.0"
|
|
1709
|
-
};
|
|
1710
|
-
if (annotation.kind === EntityKind.Relation) {
|
|
1711
|
-
const source = schema.relationSource?.$ref ?? raise2(new Error("Relation source not set"));
|
|
1712
|
-
const target = schema.relationTarget?.$ref ?? raise2(new Error("Relation target not set"));
|
|
1713
|
-
annotation.sourceSchema = DXN5.parse(source).toString();
|
|
1714
|
-
annotation.targetSchema = DXN5.parse(target).toString();
|
|
865
|
+
var unwrapAst = (rootAst, predicate) => {
|
|
866
|
+
let ast = rootAst;
|
|
867
|
+
while (ast != null) {
|
|
868
|
+
if (predicate?.(ast)) {
|
|
869
|
+
return ast;
|
|
1715
870
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
typename: schema.echo.type.typename,
|
|
1722
|
-
version: schema.echo.type.version
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
return void 0;
|
|
1726
|
-
};
|
|
1727
|
-
var jsonSchemaFieldsToAnnotations = (schema) => {
|
|
1728
|
-
const annotations4 = {};
|
|
1729
|
-
const echoAnnotations = getNormalizedEchoAnnotations(schema) ?? {};
|
|
1730
|
-
if (echoAnnotations) {
|
|
1731
|
-
for (const [key, annotationId] of Object.entries(EchoAnnotations)) {
|
|
1732
|
-
if (echoAnnotations[key]) {
|
|
1733
|
-
annotations4[annotationId] = echoAnnotations[key];
|
|
871
|
+
if (SchemaAST2.isUnion(ast)) {
|
|
872
|
+
const next = ast.types.find((t) => predicate != null && predicate(t) || SchemaAST2.isSuspend(t));
|
|
873
|
+
if (next != null) {
|
|
874
|
+
ast = next;
|
|
875
|
+
continue;
|
|
1734
876
|
}
|
|
1735
877
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
if (typeAnnotation) {
|
|
1741
|
-
annotations4[TypeAnnotationId] = typeAnnotation;
|
|
1742
|
-
annotations4[SchemaAST6.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
1743
|
-
identifier: typeIdentifier,
|
|
1744
|
-
kind: typeAnnotation.kind,
|
|
1745
|
-
typename: typeAnnotation.typename,
|
|
1746
|
-
version: typeAnnotation.version,
|
|
1747
|
-
relationSource: typeAnnotation.sourceSchema,
|
|
1748
|
-
relationTarget: typeAnnotation.targetSchema
|
|
1749
|
-
});
|
|
1750
|
-
}
|
|
1751
|
-
for (const [key, annotationId] of Object.entries({
|
|
1752
|
-
...CustomAnnotations,
|
|
1753
|
-
...DecodedAnnotations
|
|
1754
|
-
})) {
|
|
1755
|
-
if (key in schema) {
|
|
1756
|
-
annotations4[annotationId] = schema[key];
|
|
878
|
+
if (SchemaAST2.isSuspend(ast)) {
|
|
879
|
+
ast = ast.f();
|
|
880
|
+
} else {
|
|
881
|
+
return predicate == null ? ast : null;
|
|
1757
882
|
}
|
|
1758
883
|
}
|
|
1759
|
-
return
|
|
1760
|
-
};
|
|
1761
|
-
var makeAnnotatedRefinement = (ast, annotations4) => {
|
|
1762
|
-
return new SchemaAST6.Refinement(ast, () => Option2.none(), annotations4);
|
|
1763
|
-
};
|
|
1764
|
-
var addJsonSchemaFields = (ast, schema) => makeAnnotatedRefinement(ast, {
|
|
1765
|
-
[SchemaAST6.JSONSchemaAnnotationId]: schema
|
|
1766
|
-
});
|
|
1767
|
-
var normalizeJsonSchema = (jsonSchema) => {
|
|
1768
|
-
if (jsonSchema.properties && "id" in jsonSchema.properties) {
|
|
1769
|
-
jsonSchema.properties = orderKeys(jsonSchema.properties, [
|
|
1770
|
-
"id"
|
|
1771
|
-
]);
|
|
1772
|
-
}
|
|
1773
|
-
jsonSchema.$schema = JSON_SCHEMA_URL;
|
|
1774
|
-
jsonSchema = orderKeys(jsonSchema, [
|
|
1775
|
-
"$schema",
|
|
1776
|
-
"$id",
|
|
1777
|
-
"entityKind",
|
|
1778
|
-
"typename",
|
|
1779
|
-
"version",
|
|
1780
|
-
"relationTarget",
|
|
1781
|
-
"relationSource",
|
|
1782
|
-
"type",
|
|
1783
|
-
"enum",
|
|
1784
|
-
"properties",
|
|
1785
|
-
"required",
|
|
1786
|
-
"propertyOrder",
|
|
1787
|
-
"items",
|
|
1788
|
-
"additionalProperties",
|
|
1789
|
-
"anyOf",
|
|
1790
|
-
"oneOf"
|
|
1791
|
-
]);
|
|
1792
|
-
return jsonSchema;
|
|
884
|
+
return null;
|
|
1793
885
|
};
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
// TODO(burdon): Comment required.
|
|
1809
|
-
static [Symbol.hasInstance](obj) {
|
|
1810
|
-
return obj != null && getTypename(obj) === typename;
|
|
1811
|
-
}
|
|
1812
|
-
// TODO(burdon): Throw APIError.
|
|
1813
|
-
constructor() {
|
|
1814
|
-
throw new Error("Use live(Typename, { ...fields }) to instantiate an object.");
|
|
1815
|
-
}
|
|
1816
|
-
};
|
|
1817
|
-
};
|
|
1818
|
-
var schemaVariance = {
|
|
1819
|
-
_A: (_) => _,
|
|
1820
|
-
_I: (_) => _,
|
|
1821
|
-
_R: (_) => _
|
|
1822
|
-
};
|
|
1823
|
-
|
|
1824
|
-
// src/internal/object/create-object.ts
|
|
1825
|
-
import { raise as raise4 } from "@dxos/debug";
|
|
1826
|
-
import { assertArgument as assertArgument8, failedInvariant } from "@dxos/invariant";
|
|
1827
|
-
import { ObjectId as ObjectId7 } from "@dxos/keys";
|
|
1828
|
-
|
|
1829
|
-
// src/internal/proxy/symbols.ts
|
|
1830
|
-
var EventId = /* @__PURE__ */ Symbol.for("@dxos/live-object/EventId");
|
|
1831
|
-
var ChangeId = /* @__PURE__ */ Symbol.for("@dxos/live-object/ChangeId");
|
|
1832
|
-
|
|
1833
|
-
// src/internal/proxy/event-batch.ts
|
|
1834
|
-
var eventBatchDepth = 0;
|
|
1835
|
-
var pendingEventTargets = /* @__PURE__ */ new Set();
|
|
1836
|
-
var batchEvents = (callback) => {
|
|
1837
|
-
eventBatchDepth++;
|
|
1838
|
-
try {
|
|
1839
|
-
callback();
|
|
1840
|
-
} finally {
|
|
1841
|
-
eventBatchDepth--;
|
|
1842
|
-
if (eventBatchDepth === 0) {
|
|
1843
|
-
for (const target of pendingEventTargets) {
|
|
1844
|
-
target[EventId]?.emit();
|
|
1845
|
-
}
|
|
1846
|
-
pendingEventTargets.clear();
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
};
|
|
1850
|
-
var emitEvent = (target) => {
|
|
1851
|
-
if (eventBatchDepth > 0) {
|
|
1852
|
-
pendingEventTargets.add(target);
|
|
1853
|
-
} else {
|
|
1854
|
-
target[EventId]?.emit();
|
|
886
|
+
var unwrapArray = (ast) => unwrapAst(ast, SchemaAST2.isTupleType);
|
|
887
|
+
var checkIdNotPresentOnSchema = (schema) => {
|
|
888
|
+
invariant6(SchemaAST2.isTypeLiteral(schema.ast), void 0, {
|
|
889
|
+
F: __dxlog_file6,
|
|
890
|
+
L: 236,
|
|
891
|
+
S: void 0,
|
|
892
|
+
A: [
|
|
893
|
+
"SchemaAST.isTypeLiteral(schema.ast)",
|
|
894
|
+
""
|
|
895
|
+
]
|
|
896
|
+
});
|
|
897
|
+
const idProperty = SchemaAST2.getPropertySignatures(schema.ast).find((prop) => prop.name === "id");
|
|
898
|
+
if (idProperty != null) {
|
|
899
|
+
throw new Error('"id" property name is reserved');
|
|
1855
900
|
}
|
|
1856
901
|
};
|
|
1857
902
|
|
|
1858
|
-
// src/internal/proxy/
|
|
1859
|
-
var
|
|
1860
|
-
var
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
currentChangeContext = key;
|
|
1864
|
-
return () => {
|
|
1865
|
-
currentChangeContext = null;
|
|
1866
|
-
};
|
|
1867
|
-
};
|
|
1868
|
-
var isInChangeContext = (key) => {
|
|
1869
|
-
return currentChangeContext === key;
|
|
1870
|
-
};
|
|
1871
|
-
var queueNotification = (key) => {
|
|
1872
|
-
if (currentChangeContext === key) {
|
|
1873
|
-
pendingNotificationKey = key;
|
|
1874
|
-
}
|
|
1875
|
-
};
|
|
1876
|
-
var queueOwnerNotification = (target) => {
|
|
1877
|
-
if (currentChangeContext !== null && target !== currentChangeContext) {
|
|
1878
|
-
pendingOwnerNotifications.add(target);
|
|
903
|
+
// src/internal/common/proxy/typed-handler.ts
|
|
904
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/proxy/typed-handler.ts";
|
|
905
|
+
var deepCopy = (value2, visited = /* @__PURE__ */ new Map()) => {
|
|
906
|
+
if (value2 == null || typeof value2 !== "object") {
|
|
907
|
+
return value2;
|
|
1879
908
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
};
|
|
1884
|
-
var clearPendingNotifications = (key) => {
|
|
1885
|
-
if (pendingNotificationKey === key) {
|
|
1886
|
-
pendingNotificationKey = null;
|
|
909
|
+
const actualValue = getRawTarget(value2);
|
|
910
|
+
if (visited.has(actualValue)) {
|
|
911
|
+
return visited.get(actualValue);
|
|
1887
912
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
} finally {
|
|
1894
|
-
exitContext();
|
|
1895
|
-
if (hasPendingNotifications(contextKey)) {
|
|
1896
|
-
clearPendingNotifications(contextKey);
|
|
1897
|
-
eventTarget[EventId]?.emit();
|
|
1898
|
-
}
|
|
1899
|
-
for (const ownerTarget of pendingOwnerNotifications) {
|
|
1900
|
-
ownerTarget[EventId]?.emit();
|
|
913
|
+
if (actualValue instanceof ReactiveArray) {
|
|
914
|
+
const copy2 = new ReactiveArray();
|
|
915
|
+
visited.set(actualValue, copy2);
|
|
916
|
+
for (const item of actualValue) {
|
|
917
|
+
copy2.push(deepCopy(item, visited));
|
|
1901
918
|
}
|
|
1902
|
-
|
|
919
|
+
copyHiddenProperties(actualValue, copy2);
|
|
920
|
+
return copy2;
|
|
1903
921
|
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
var defineHiddenProperty = (object, key, value2) => {
|
|
1908
|
-
Object.defineProperty(object, key, {
|
|
1909
|
-
enumerable: false,
|
|
1910
|
-
configurable: true,
|
|
1911
|
-
value: value2
|
|
1912
|
-
});
|
|
1913
|
-
};
|
|
1914
|
-
|
|
1915
|
-
// src/internal/proxy/errors.ts
|
|
1916
|
-
var MutationOutsideChangeContextError = class extends Error {
|
|
1917
|
-
constructor(operation, suggestion) {
|
|
1918
|
-
super(`Cannot ${operation} outside of Obj.change(). Use Obj.change(obj, (mutableObj) => { ${suggestion} }) instead.`);
|
|
1919
|
-
this.name = "MutationOutsideChangeContextError";
|
|
922
|
+
const proto = Object.getPrototypeOf(actualValue);
|
|
923
|
+
if (proto !== Object.prototype && proto !== Array.prototype && proto !== null) {
|
|
924
|
+
return value2;
|
|
1920
925
|
}
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
var createArrayMethodError = (method) => {
|
|
1929
|
-
return new MutationOutsideChangeContextError(`call array.${method}()`, `mutableObj.array.${method}(...);`);
|
|
1930
|
-
};
|
|
1931
|
-
|
|
1932
|
-
// src/internal/proxy/json-serializer.ts
|
|
1933
|
-
import { invariant as invariant10 } from "@dxos/invariant";
|
|
1934
|
-
import { DXN as DXN6 } from "@dxos/keys";
|
|
1935
|
-
import { deepMapValues } from "@dxos/util";
|
|
1936
|
-
var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/proxy/json-serializer.ts";
|
|
1937
|
-
var attachTypedJsonSerializer = (obj) => {
|
|
1938
|
-
const descriptor = Object.getOwnPropertyDescriptor(obj, "toJSON");
|
|
1939
|
-
if (descriptor) {
|
|
1940
|
-
return;
|
|
926
|
+
if (Array.isArray(actualValue)) {
|
|
927
|
+
const copy2 = new ReactiveArray();
|
|
928
|
+
visited.set(actualValue, copy2);
|
|
929
|
+
for (const item of actualValue) {
|
|
930
|
+
copy2.push(deepCopy(item, visited));
|
|
931
|
+
}
|
|
932
|
+
return copy2;
|
|
1941
933
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
934
|
+
const copy = {};
|
|
935
|
+
visited.set(actualValue, copy);
|
|
936
|
+
for (const key of Object.keys(actualValue)) {
|
|
937
|
+
copy[key] = deepCopy(actualValue[key], visited);
|
|
938
|
+
}
|
|
939
|
+
copyHiddenProperties(actualValue, copy);
|
|
940
|
+
return copy;
|
|
1949
941
|
};
|
|
1950
|
-
var
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
id
|
|
1954
|
-
};
|
|
1955
|
-
if (this[TypeId]) {
|
|
1956
|
-
result[ATTR_TYPE] = this[TypeId].toString();
|
|
942
|
+
var copyHiddenProperties = (source, target) => {
|
|
943
|
+
if (SchemaId in source) {
|
|
944
|
+
defineHiddenProperty(target, SchemaId, source[SchemaId]);
|
|
1957
945
|
}
|
|
1958
|
-
if (
|
|
1959
|
-
|
|
946
|
+
if (TypeId in source) {
|
|
947
|
+
defineHiddenProperty(target, TypeId, source[TypeId]);
|
|
1960
948
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
949
|
+
};
|
|
950
|
+
var TypedReactiveHandler = class _TypedReactiveHandler {
|
|
951
|
+
static instance = new _TypedReactiveHandler();
|
|
952
|
+
_proxyMap = /* @__PURE__ */ new WeakMap();
|
|
953
|
+
_inSet = false;
|
|
954
|
+
constructor() {
|
|
1963
955
|
}
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
L: 61,
|
|
956
|
+
init(target) {
|
|
957
|
+
invariant7(typeof target === "object" && target !== null, void 0, {
|
|
958
|
+
F: __dxlog_file7,
|
|
959
|
+
L: 147,
|
|
1969
960
|
S: this,
|
|
1970
961
|
A: [
|
|
1971
|
-
"
|
|
962
|
+
"typeof target === 'object' && target !== null",
|
|
1972
963
|
""
|
|
1973
964
|
]
|
|
1974
965
|
});
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
const targetDXN = this[RelationTargetDXNId];
|
|
1979
|
-
invariant10(targetDXN instanceof DXN6, void 0, {
|
|
1980
|
-
F: __dxlog_file10,
|
|
1981
|
-
L: 66,
|
|
966
|
+
invariant7(SchemaId in target, "Schema is not defined for the target", {
|
|
967
|
+
F: __dxlog_file7,
|
|
968
|
+
L: 148,
|
|
1982
969
|
S: this,
|
|
1983
970
|
A: [
|
|
1984
|
-
"
|
|
1985
|
-
""
|
|
971
|
+
"SchemaId in target",
|
|
972
|
+
"'Schema is not defined for the target'"
|
|
1986
973
|
]
|
|
1987
974
|
});
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
return result;
|
|
1992
|
-
};
|
|
1993
|
-
var serializeData = (data) => {
|
|
1994
|
-
return deepMapValues(data, (value2, recurse) => {
|
|
1995
|
-
if (Ref.isRef(value2)) {
|
|
1996
|
-
return value2.noInline().encode();
|
|
975
|
+
const hasOwner = !!getOwner(target);
|
|
976
|
+
if (!(EventId in target) && !hasOwner) {
|
|
977
|
+
defineHiddenProperty(target, EventId, new Event());
|
|
1997
978
|
}
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
979
|
+
defineHiddenProperty(target, ObjectDeletedId, false);
|
|
980
|
+
if (!hasOwner && !(ChangeId in target)) {
|
|
981
|
+
defineHiddenProperty(target, ChangeId, true);
|
|
982
|
+
}
|
|
983
|
+
if (!hasOwner) {
|
|
984
|
+
for (const key in target) {
|
|
985
|
+
if (target[symbolIsProxy]) {
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
let value2 = target[key];
|
|
989
|
+
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
990
|
+
if (hasForeignOwner(value2, target)) {
|
|
991
|
+
value2 = deepCopy(value2);
|
|
992
|
+
target[key] = value2;
|
|
993
|
+
}
|
|
994
|
+
setOwnerRecursive(value2, target);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
Object.defineProperty(target, inspectCustom, {
|
|
999
|
+
enumerable: false,
|
|
1000
|
+
configurable: true,
|
|
1001
|
+
value: this._inspect.bind(target)
|
|
1002
|
+
});
|
|
2016
1003
|
}
|
|
2017
|
-
if (Array.isArray(value2)) {
|
|
2018
|
-
return true;
|
|
2019
|
-
}
|
|
2020
|
-
return typeof value2 === "object" && Object.getPrototypeOf(value2) === Object.prototype;
|
|
2021
|
-
};
|
|
2022
|
-
var getProxySlot = (proxy) => {
|
|
2023
|
-
const value2 = proxy[symbolIsProxy];
|
|
2024
|
-
invariant11(value2 instanceof ProxyHandlerSlot, void 0, {
|
|
2025
|
-
F: __dxlog_file11,
|
|
2026
|
-
L: 32,
|
|
2027
|
-
S: void 0,
|
|
2028
|
-
A: [
|
|
2029
|
-
"value instanceof ProxyHandlerSlot",
|
|
2030
|
-
""
|
|
2031
|
-
]
|
|
2032
|
-
});
|
|
2033
|
-
return value2;
|
|
2034
|
-
};
|
|
2035
|
-
var getProxyTarget = (proxy) => {
|
|
2036
|
-
return getProxySlot(proxy).target;
|
|
2037
|
-
};
|
|
2038
|
-
var getProxyHandler = (proxy) => {
|
|
2039
|
-
return getProxySlot(proxy).handler;
|
|
2040
|
-
};
|
|
2041
|
-
var dangerouslySetProxyId = (obj, id) => {
|
|
2042
|
-
getProxySlot(obj).target.id = id;
|
|
2043
|
-
};
|
|
2044
|
-
var createProxy = (target, handler) => {
|
|
2045
|
-
const existingProxy = handler._proxyMap.get(target);
|
|
2046
|
-
if (existingProxy) {
|
|
2047
|
-
return existingProxy;
|
|
2048
|
-
}
|
|
2049
|
-
const proxy = new Proxy(target, new ProxyHandlerSlot(target, handler));
|
|
2050
|
-
handler.init(target);
|
|
2051
|
-
handler._proxyMap.set(target, proxy);
|
|
2052
|
-
return proxy;
|
|
2053
|
-
};
|
|
2054
|
-
var ProxyHandlerSlot = class {
|
|
2055
|
-
target;
|
|
2056
|
-
_handler;
|
|
2057
|
-
/**
|
|
2058
|
-
* @param target Original object.
|
|
2059
|
-
* @param _handler Handles intercepted operations.
|
|
2060
|
-
*/
|
|
2061
|
-
constructor(target, _handler) {
|
|
2062
|
-
this.target = target;
|
|
2063
|
-
this._handler = _handler;
|
|
2064
|
-
}
|
|
2065
|
-
get handler() {
|
|
2066
|
-
invariant11(this._handler, void 0, {
|
|
2067
|
-
F: __dxlog_file11,
|
|
2068
|
-
L: 91,
|
|
2069
|
-
S: this,
|
|
2070
|
-
A: [
|
|
2071
|
-
"this._handler",
|
|
2072
|
-
""
|
|
2073
|
-
]
|
|
2074
|
-
});
|
|
2075
|
-
return this._handler;
|
|
2076
|
-
}
|
|
2077
|
-
// TODO(burdon): Requires comment.
|
|
2078
|
-
setHandler(handler) {
|
|
2079
|
-
this._handler = handler;
|
|
2080
|
-
}
|
|
2081
|
-
/**
|
|
2082
|
-
* Get value.
|
|
2083
|
-
*/
|
|
2084
1004
|
get(target, prop, receiver) {
|
|
2085
|
-
|
|
2086
|
-
|
|
1005
|
+
switch (prop) {
|
|
1006
|
+
// TODO(burdon): Remove?
|
|
1007
|
+
case objectData: {
|
|
1008
|
+
return toJSON(target);
|
|
1009
|
+
}
|
|
1010
|
+
case ChangeId: {
|
|
1011
|
+
if (target[ChangeId] !== true) {
|
|
1012
|
+
return void 0;
|
|
1013
|
+
}
|
|
1014
|
+
return (callback) => executeChange(target, target, receiver, callback);
|
|
1015
|
+
}
|
|
2087
1016
|
}
|
|
2088
|
-
if (
|
|
1017
|
+
if (Object.getOwnPropertyDescriptor(target, prop)?.get) {
|
|
2089
1018
|
return Reflect.get(target, prop, receiver);
|
|
2090
1019
|
}
|
|
2091
|
-
|
|
1020
|
+
const value2 = Reflect.get(target, prop, receiver);
|
|
1021
|
+
if (isValidProxyTarget(value2)) {
|
|
1022
|
+
return createProxy(value2, this);
|
|
1023
|
+
}
|
|
1024
|
+
return value2;
|
|
2092
1025
|
}
|
|
2093
|
-
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
"
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
for (const trap of TRAPS) {
|
|
2110
|
-
if (trap === "get") {
|
|
2111
|
-
continue;
|
|
2112
|
-
}
|
|
2113
|
-
Object.defineProperty(this.prototype, trap, {
|
|
2114
|
-
enumerable: false,
|
|
2115
|
-
value: function(...args) {
|
|
2116
|
-
if (!this._handler || !this._handler[trap]) {
|
|
2117
|
-
return Reflect[trap](...args);
|
|
2118
|
-
}
|
|
2119
|
-
return this._handler[trap].apply(this._handler, args);
|
|
1026
|
+
set(target, prop, value2, receiver) {
|
|
1027
|
+
const echoRoot = getEchoRoot(target);
|
|
1028
|
+
const isInitialized = ChangeId in echoRoot || EventId in echoRoot;
|
|
1029
|
+
const isSymbolProp = typeof prop === "symbol";
|
|
1030
|
+
if (isInitialized && !isSymbolProp && !isInChangeContext(echoRoot)) {
|
|
1031
|
+
throw new Error(`Cannot modify object property "${String(prop)}" outside of Obj.change(). Use Obj.change(obj, (mutableObj) => { mutableObj.property = value; }) instead.`);
|
|
1032
|
+
}
|
|
1033
|
+
let result = false;
|
|
1034
|
+
this._inSet = true;
|
|
1035
|
+
try {
|
|
1036
|
+
batchEvents(() => {
|
|
1037
|
+
const { echoRoot: _, preparedValue } = this._prepareValueForAssignment(target, prop, value2);
|
|
1038
|
+
result = Reflect.set(target, prop, preparedValue, receiver);
|
|
1039
|
+
if (isInitialized) {
|
|
1040
|
+
queueNotification(echoRoot);
|
|
1041
|
+
notifyOwnerChain(target);
|
|
2120
1042
|
}
|
|
2121
1043
|
});
|
|
1044
|
+
} finally {
|
|
1045
|
+
this._inSet = false;
|
|
2122
1046
|
}
|
|
1047
|
+
return result;
|
|
2123
1048
|
}
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
// src/internal/proxy/typed-handler.ts
|
|
2127
|
-
import * as Schema12 from "effect/Schema";
|
|
2128
|
-
import * as SchemaAST8 from "effect/SchemaAST";
|
|
2129
|
-
import { Event as Event2 } from "@dxos/async";
|
|
2130
|
-
import { inspectCustom as inspectCustom2 } from "@dxos/debug";
|
|
2131
|
-
import { invariant as invariant14 } from "@dxos/invariant";
|
|
2132
|
-
|
|
2133
|
-
// src/internal/proxy/ownership.ts
|
|
2134
|
-
import { invariant as invariant12 } from "@dxos/invariant";
|
|
2135
|
-
var __dxlog_file12 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/proxy/ownership.ts";
|
|
2136
|
-
var EchoOwner = /* @__PURE__ */ Symbol.for("@dxos/echo/Owner");
|
|
2137
|
-
var getRawTarget = (value2) => {
|
|
2138
|
-
return isProxy(value2) ? getProxyTarget(value2) : value2;
|
|
2139
|
-
};
|
|
2140
|
-
var getOwner = (value2) => {
|
|
2141
|
-
return value2?.[EchoOwner];
|
|
2142
|
-
};
|
|
2143
|
-
var setMetaOwner = (metaTarget, parent) => {
|
|
2144
|
-
defineHiddenProperty(metaTarget, EchoOwner, parent);
|
|
2145
|
-
};
|
|
2146
|
-
var setOwnerRecursive = (value2, owner, options = {}) => {
|
|
2147
|
-
const { visited = /* @__PURE__ */ new Set(), depth = 0, allowedPreviousOwner } = options;
|
|
2148
|
-
if (value2 == null || typeof value2 !== "object") {
|
|
2149
|
-
return;
|
|
2150
|
-
}
|
|
2151
|
-
const actualValue = getRawTarget(value2);
|
|
2152
|
-
if (visited.has(actualValue)) {
|
|
2153
|
-
return;
|
|
1049
|
+
ownKeys(target) {
|
|
1050
|
+
return Reflect.ownKeys(target);
|
|
2154
1051
|
}
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
1052
|
+
deleteProperty(target, property) {
|
|
1053
|
+
const echoRoot = getEchoRoot(target);
|
|
1054
|
+
const isInitialized = echoRoot[ChangeId] === true || EventId in echoRoot;
|
|
1055
|
+
const isSymbolProp = typeof property === "symbol";
|
|
1056
|
+
if (isInitialized && !isSymbolProp && !isInChangeContext(echoRoot)) {
|
|
1057
|
+
throw createPropertyDeleteError(property);
|
|
1058
|
+
}
|
|
1059
|
+
const result = Reflect.deleteProperty(target, property);
|
|
1060
|
+
if (isInitialized) {
|
|
1061
|
+
queueNotification(echoRoot);
|
|
1062
|
+
}
|
|
1063
|
+
return result;
|
|
2161
1064
|
}
|
|
2162
|
-
|
|
2163
|
-
const
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
1065
|
+
defineProperty(target, property, attributes) {
|
|
1066
|
+
const echoRoot = getEchoRoot(target);
|
|
1067
|
+
const isInitialized = ChangeId in echoRoot || EventId in echoRoot;
|
|
1068
|
+
const isSymbolProp = typeof property === "symbol";
|
|
1069
|
+
if (isInitialized && !isSymbolProp && !isInChangeContext(echoRoot)) {
|
|
1070
|
+
throw new Error(`Cannot modify object property "${String(property)}" outside of Obj.change(). Use Obj.change(obj, (mutableObj) => { mutableObj.property = value; }) instead.`);
|
|
1071
|
+
}
|
|
1072
|
+
const { echoRoot: _, preparedValue } = this._prepareValueForAssignment(target, property, attributes.value);
|
|
1073
|
+
const result = Reflect.defineProperty(target, property, {
|
|
1074
|
+
...attributes,
|
|
1075
|
+
value: preparedValue
|
|
2172
1076
|
});
|
|
1077
|
+
if (!this._inSet && isInitialized) {
|
|
1078
|
+
queueNotification(echoRoot);
|
|
1079
|
+
}
|
|
1080
|
+
return result;
|
|
2173
1081
|
}
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Prepare a value for assignment to a typed object property.
|
|
1084
|
+
* Handles cycle detection, copy-on-assign, array conversion, validation, and ownership.
|
|
1085
|
+
*/
|
|
1086
|
+
_prepareValueForAssignment(target, prop, value2) {
|
|
1087
|
+
const echoRoot = getEchoRoot(target);
|
|
1088
|
+
if (prop === ParentId) {
|
|
1089
|
+
return {
|
|
1090
|
+
echoRoot,
|
|
1091
|
+
preparedValue: value2
|
|
1092
|
+
};
|
|
2185
1093
|
}
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
const nested = actualValue[key];
|
|
2190
|
-
if (isValidProxyTarget(nested) || isProxy(nested)) {
|
|
2191
|
-
setOwnerRecursive(nested, owner, recursiveOptions);
|
|
2192
|
-
}
|
|
1094
|
+
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
1095
|
+
if (wouldCreateCycle(echoRoot, value2)) {
|
|
1096
|
+
throw new Error("Cannot create cycles in typed object graph. Consider using Ref for circular references.");
|
|
2193
1097
|
}
|
|
2194
1098
|
}
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
}
|
|
2201
|
-
const actualValue = getRawTarget(value2);
|
|
2202
|
-
if (visited.has(actualValue)) {
|
|
2203
|
-
return false;
|
|
2204
|
-
}
|
|
2205
|
-
visited.add(actualValue);
|
|
2206
|
-
if (visitor(actualValue)) {
|
|
2207
|
-
return true;
|
|
2208
|
-
}
|
|
2209
|
-
if (Array.isArray(actualValue)) {
|
|
2210
|
-
for (const item of actualValue) {
|
|
2211
|
-
if (traverseObjectGraph(item, visitor, visited)) {
|
|
2212
|
-
return true;
|
|
1099
|
+
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
1100
|
+
const actualValue = getRawTarget(value2);
|
|
1101
|
+
const isRootEchoObject = EventId in actualValue;
|
|
1102
|
+
if (isRootEchoObject) {
|
|
1103
|
+
throw new Error("Object references must be wrapped with `Ref.make`");
|
|
2213
1104
|
}
|
|
2214
1105
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
}
|
|
1106
|
+
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
1107
|
+
const actualValue = getRawTarget(value2);
|
|
1108
|
+
const existingOwner = getOwner(actualValue);
|
|
1109
|
+
if (existingOwner != null && existingOwner !== echoRoot) {
|
|
1110
|
+
value2 = deepCopy(value2);
|
|
2221
1111
|
}
|
|
2222
1112
|
}
|
|
1113
|
+
if (Array.isArray(value2) && !(value2 instanceof ReactiveArray)) {
|
|
1114
|
+
value2 = ReactiveArray.from(value2);
|
|
1115
|
+
}
|
|
1116
|
+
const validatedValue = this._validateValue(target, prop, value2);
|
|
1117
|
+
if (isValidProxyTarget(validatedValue) || isProxy(validatedValue)) {
|
|
1118
|
+
setOwnerRecursive(validatedValue, echoRoot);
|
|
1119
|
+
}
|
|
1120
|
+
return {
|
|
1121
|
+
echoRoot,
|
|
1122
|
+
preparedValue: validatedValue
|
|
1123
|
+
};
|
|
2223
1124
|
}
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
return
|
|
2234
|
-
}
|
|
2235
|
-
return false;
|
|
2236
|
-
});
|
|
2237
|
-
var MAX_OWNER_DEPTH = 100;
|
|
2238
|
-
var getEchoRoot = (target, depth = 0) => {
|
|
2239
|
-
invariant12(depth < MAX_OWNER_DEPTH, "Owner chain too deep - possible circular ownership", {
|
|
2240
|
-
F: __dxlog_file12,
|
|
2241
|
-
L: 221,
|
|
2242
|
-
S: void 0,
|
|
2243
|
-
A: [
|
|
2244
|
-
"depth < MAX_OWNER_DEPTH",
|
|
2245
|
-
"'Owner chain too deep - possible circular ownership'"
|
|
2246
|
-
]
|
|
2247
|
-
});
|
|
2248
|
-
if (KindId in target) {
|
|
2249
|
-
return target;
|
|
1125
|
+
_validateValue(target, prop, value2) {
|
|
1126
|
+
if (prop === ParentId) {
|
|
1127
|
+
return value2;
|
|
1128
|
+
}
|
|
1129
|
+
const schema = SchemaValidator.getTargetPropertySchema(target, prop);
|
|
1130
|
+
const _ = Schema4.asserts(schema)(value2);
|
|
1131
|
+
if (isValidProxyTarget(value2)) {
|
|
1132
|
+
setSchemaProperties(value2, schema);
|
|
1133
|
+
}
|
|
1134
|
+
return value2;
|
|
2250
1135
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
1136
|
+
_inspect(_, options, inspectFn) {
|
|
1137
|
+
const inspected = inspectFn(this, {
|
|
1138
|
+
...options,
|
|
1139
|
+
showHidden: false,
|
|
1140
|
+
customInspect: false
|
|
1141
|
+
});
|
|
1142
|
+
return `Typed ${inspected}`;
|
|
2254
1143
|
}
|
|
2255
|
-
return target;
|
|
2256
1144
|
};
|
|
2257
|
-
var
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
}
|
|
1145
|
+
var toJSON = (target) => {
|
|
1146
|
+
return {
|
|
1147
|
+
"@type": "TypedReactiveObject",
|
|
1148
|
+
...target
|
|
1149
|
+
};
|
|
2263
1150
|
};
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
// src/internal/proxy/reactive-array.ts
|
|
2269
|
-
var checkArrayMutationAllowed = (arr, method) => {
|
|
2270
|
-
const target = isProxy(arr) ? getProxyTarget(arr) : arr;
|
|
2271
|
-
const echoRoot = getEchoRoot(target);
|
|
2272
|
-
const isInitialized = echoRoot[ChangeId] === true || EventId in echoRoot;
|
|
2273
|
-
if (!isInitialized) {
|
|
2274
|
-
return;
|
|
1151
|
+
var setSchemaProperties = (obj, schema) => {
|
|
1152
|
+
const schemaType = getSchemaDXN(schema);
|
|
1153
|
+
if (schemaType != null) {
|
|
1154
|
+
defineHiddenProperty(obj, TypeId, schemaType);
|
|
2275
1155
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
1156
|
+
defineHiddenProperty(obj, SchemaId, schema);
|
|
1157
|
+
for (const key in obj) {
|
|
1158
|
+
if (isValidProxyTarget(obj[key])) {
|
|
1159
|
+
const elementSchema = SchemaValidator.getTargetPropertySchema(obj, key);
|
|
1160
|
+
if (elementSchema != null) {
|
|
1161
|
+
setSchemaProperties(obj[key], elementSchema);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
2278
1164
|
}
|
|
2279
1165
|
};
|
|
2280
|
-
var
|
|
2281
|
-
|
|
2282
|
-
|
|
1166
|
+
var prepareTypedTarget = (target, schema) => {
|
|
1167
|
+
if (!SchemaAST3.isTypeLiteral(schema.ast)) {
|
|
1168
|
+
throw new Error("schema has to describe an object type");
|
|
2283
1169
|
}
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
let result;
|
|
2300
|
-
batchEvents(() => {
|
|
2301
|
-
result = Array.prototype[method].apply(this, args);
|
|
2302
|
-
});
|
|
2303
|
-
return result;
|
|
2304
|
-
}
|
|
2305
|
-
});
|
|
1170
|
+
SchemaValidator.validateSchema(schema);
|
|
1171
|
+
const _ = Schema4.asserts(schema)(target);
|
|
1172
|
+
makeArraysReactive(target);
|
|
1173
|
+
setSchemaProperties(target, schema);
|
|
1174
|
+
};
|
|
1175
|
+
var makeArraysReactive = (target) => {
|
|
1176
|
+
for (const key in target) {
|
|
1177
|
+
if (target[symbolIsProxy]) {
|
|
1178
|
+
continue;
|
|
1179
|
+
}
|
|
1180
|
+
if (Array.isArray(target[key])) {
|
|
1181
|
+
target[key] = ReactiveArray.from(target[key]);
|
|
1182
|
+
}
|
|
1183
|
+
if (typeof target[key] === "object") {
|
|
1184
|
+
makeArraysReactive(target[key]);
|
|
2306
1185
|
}
|
|
2307
1186
|
}
|
|
2308
1187
|
};
|
|
2309
1188
|
|
|
2310
|
-
// src/internal/proxy/
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
/**
|
|
2318
|
-
* Recursively check that schema specifies constructions we can handle.
|
|
2319
|
-
* Validates there are no ambiguous discriminated union types.
|
|
2320
|
-
*/
|
|
2321
|
-
static validateSchema(schema) {
|
|
2322
|
-
const visitAll = (nodes) => nodes.forEach((node) => this.validateSchema(Schema11.make(node)));
|
|
2323
|
-
if (SchemaAST7.isUnion(schema.ast)) {
|
|
2324
|
-
const typeAstList = schema.ast.types.filter((type) => SchemaAST7.isTypeLiteral(type));
|
|
2325
|
-
if (typeAstList.length > 1) {
|
|
2326
|
-
getTypeDiscriminators(typeAstList);
|
|
2327
|
-
}
|
|
2328
|
-
visitAll(typeAstList);
|
|
2329
|
-
} else if (SchemaAST7.isTupleType(schema.ast)) {
|
|
2330
|
-
const positionalTypes = schema.ast.elements.map((t) => t.type);
|
|
2331
|
-
const allTypes = positionalTypes.concat(schema.ast.rest.map((t) => t.type));
|
|
2332
|
-
visitAll(allTypes);
|
|
2333
|
-
} else if (SchemaAST7.isTypeLiteral(schema.ast)) {
|
|
2334
|
-
visitAll(SchemaAST7.getPropertySignatures(schema.ast).map((p) => p.type));
|
|
2335
|
-
}
|
|
1189
|
+
// src/internal/common/proxy/make-object.ts
|
|
1190
|
+
var makeObject = (schema, obj, meta) => {
|
|
1191
|
+
return createReactiveObject(Object.assign({}, obj), meta, schema);
|
|
1192
|
+
};
|
|
1193
|
+
var createReactiveObject = (obj, meta, schema) => {
|
|
1194
|
+
if (!isValidProxyTarget(obj)) {
|
|
1195
|
+
throw new Error("Value cannot be made into a reactive object.");
|
|
2336
1196
|
}
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
let type = this.getPropertySchema(rootObjectSchema, [
|
|
2340
|
-
property
|
|
2341
|
-
]);
|
|
2342
|
-
if (SchemaAST7.isTupleType(type.ast)) {
|
|
2343
|
-
type = this.getPropertySchema(rootObjectSchema, [
|
|
2344
|
-
property,
|
|
2345
|
-
"0"
|
|
2346
|
-
]);
|
|
2347
|
-
}
|
|
2348
|
-
return type.ast.annotations[annotation] != null;
|
|
2349
|
-
} catch {
|
|
2350
|
-
return false;
|
|
2351
|
-
}
|
|
1197
|
+
if (!schema) {
|
|
1198
|
+
throw new Error("Schema is required for reactive objects. Use Atom for untyped reactive state.");
|
|
2352
1199
|
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
const propertyName = propertyPath[i];
|
|
2357
|
-
const tupleAst = unwrapArray(schema.ast);
|
|
2358
|
-
if (tupleAst != null) {
|
|
2359
|
-
schema = getArrayElementSchema(tupleAst, propertyName);
|
|
2360
|
-
} else {
|
|
2361
|
-
const propertyType = getPropertyType(schema.ast, propertyName.toString(), (propertyName2) => getProperty([
|
|
2362
|
-
...propertyPath.slice(0, i),
|
|
2363
|
-
propertyName2
|
|
2364
|
-
]));
|
|
2365
|
-
if (propertyType == null) {
|
|
2366
|
-
log2.warn("unknown property", {
|
|
2367
|
-
path: propertyPath,
|
|
2368
|
-
property: propertyName
|
|
2369
|
-
}, {
|
|
2370
|
-
F: __dxlog_file13,
|
|
2371
|
-
L: 71,
|
|
2372
|
-
S: this,
|
|
2373
|
-
C: (f, a) => f(...a)
|
|
2374
|
-
});
|
|
2375
|
-
continue;
|
|
2376
|
-
}
|
|
2377
|
-
schema = Schema11.make(propertyType).annotations(propertyType.annotations);
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
return schema;
|
|
1200
|
+
const parent = obj[ParentId];
|
|
1201
|
+
if (parent !== void 0) {
|
|
1202
|
+
delete obj[ParentId];
|
|
2381
1203
|
}
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
1204
|
+
const annotation = getTypeAnnotation(schema);
|
|
1205
|
+
if (annotation) {
|
|
1206
|
+
setIdOnTarget(obj);
|
|
1207
|
+
defineHiddenProperty(obj, KindId, annotation.kind);
|
|
1208
|
+
}
|
|
1209
|
+
initMeta(obj, meta);
|
|
1210
|
+
if (parent !== void 0) {
|
|
1211
|
+
defineHiddenProperty(obj, ParentId, parent);
|
|
1212
|
+
}
|
|
1213
|
+
prepareTypedTarget(obj, schema);
|
|
1214
|
+
attachTypedJsonSerializer(obj);
|
|
1215
|
+
const proxy = createProxy(obj, TypedReactiveHandler.instance);
|
|
1216
|
+
const metaProxy = obj[MetaId];
|
|
1217
|
+
if (metaProxy) {
|
|
1218
|
+
const metaTarget = getProxyTarget(metaProxy);
|
|
1219
|
+
if (metaTarget) {
|
|
1220
|
+
setMetaOwner(metaTarget, obj);
|
|
2396
1221
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
1222
|
+
}
|
|
1223
|
+
return proxy;
|
|
1224
|
+
};
|
|
1225
|
+
var setIdOnTarget = (target) => {
|
|
1226
|
+
if ("id" in target && target.id !== void 0 && target.id !== null) {
|
|
1227
|
+
if (!ObjectId.isValid(target.id)) {
|
|
1228
|
+
throw new Error("Invalid object id format.");
|
|
2400
1229
|
}
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
L: 95,
|
|
2404
|
-
S: this,
|
|
2405
|
-
A: [
|
|
2406
|
-
"propertyType",
|
|
2407
|
-
"`invalid property: ${prop.toString()}`"
|
|
2408
|
-
]
|
|
2409
|
-
});
|
|
2410
|
-
return Schema11.make(propertyType);
|
|
1230
|
+
} else {
|
|
1231
|
+
target.id = ObjectId.random();
|
|
2411
1232
|
}
|
|
2412
1233
|
};
|
|
2413
|
-
var
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
L: 111,
|
|
2419
|
-
S: void 0,
|
|
2420
|
-
A: [
|
|
2421
|
-
"property === 'length'",
|
|
2422
|
-
"`invalid array property: ${String(property)}`"
|
|
2423
|
-
]
|
|
2424
|
-
});
|
|
2425
|
-
return Schema11.Number;
|
|
2426
|
-
}
|
|
2427
|
-
if (elementIndex < tupleAst.elements.length) {
|
|
2428
|
-
const elementType = tupleAst.elements[elementIndex].type;
|
|
2429
|
-
return Schema11.make(elementType).annotations(elementType.annotations);
|
|
2430
|
-
}
|
|
2431
|
-
const restType = tupleAst.rest;
|
|
2432
|
-
return Schema11.make(restType[0].type).annotations(restType[0].annotations);
|
|
1234
|
+
var initMeta = (obj, meta = {
|
|
1235
|
+
keys: []
|
|
1236
|
+
}) => {
|
|
1237
|
+
prepareTypedTarget(meta, ObjectMetaSchema);
|
|
1238
|
+
defineHiddenProperty(obj, MetaId, createProxy(meta, TypedReactiveHandler.instance));
|
|
2433
1239
|
};
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
if (typeAstList.length === 0) {
|
|
2441
|
-
return [];
|
|
1240
|
+
|
|
1241
|
+
// src/internal/common/proxy/reactive.ts
|
|
1242
|
+
var subscribe = (obj, callback) => {
|
|
1243
|
+
const target = getProxyTarget(obj);
|
|
1244
|
+
if (target && EventId in target) {
|
|
1245
|
+
return target[EventId].on(callback);
|
|
2442
1246
|
}
|
|
2443
|
-
|
|
2444
|
-
|
|
1247
|
+
return () => {
|
|
1248
|
+
};
|
|
1249
|
+
};
|
|
1250
|
+
var change = (obj, callback) => {
|
|
1251
|
+
const changeFn = obj[ChangeId];
|
|
1252
|
+
if (changeFn) {
|
|
1253
|
+
changeFn(callback);
|
|
1254
|
+
} else {
|
|
1255
|
+
callback(obj);
|
|
2445
1256
|
}
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
// src/internal/Entity/api.ts
|
|
1260
|
+
import { invariant as invariant10 } from "@dxos/invariant";
|
|
1261
|
+
import { assumeType as assumeType3 } from "@dxos/util";
|
|
1262
|
+
|
|
1263
|
+
// src/internal/Entity/model.ts
|
|
1264
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1265
|
+
import { DXN as DXN2, ObjectId as ObjectId2 } from "@dxos/keys";
|
|
1266
|
+
import { assumeType } from "@dxos/util";
|
|
1267
|
+
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Entity/model.ts";
|
|
1268
|
+
function assertObjectModel(obj) {
|
|
1269
|
+
invariant8(typeof obj === "object" && obj !== null, "Invalid object model: not an object", {
|
|
1270
|
+
F: __dxlog_file8,
|
|
1271
|
+
L: 94,
|
|
1272
|
+
S: this,
|
|
2453
1273
|
A: [
|
|
2454
|
-
"
|
|
2455
|
-
"'
|
|
1274
|
+
"typeof obj === 'object' && obj !== null",
|
|
1275
|
+
"'Invalid object model: not an object'"
|
|
2456
1276
|
]
|
|
2457
1277
|
});
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
1278
|
+
assumeType(obj);
|
|
1279
|
+
invariant8(ObjectId2.isValid(obj.id), "Invalid object model: invalid id", {
|
|
1280
|
+
F: __dxlog_file8,
|
|
1281
|
+
L: 96,
|
|
1282
|
+
S: this,
|
|
1283
|
+
A: [
|
|
1284
|
+
"ObjectId.isValid(obj.id)",
|
|
1285
|
+
"'Invalid object model: invalid id'"
|
|
1286
|
+
]
|
|
2467
1287
|
});
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
if (targetProperty != null) {
|
|
2473
|
-
return unwrapAst(targetProperty.type);
|
|
2474
|
-
}
|
|
2475
|
-
const indexSignatureType = unwrapAst(ast, SchemaAST7.isTypeLiteral);
|
|
2476
|
-
if (indexSignatureType && SchemaAST7.isTypeLiteral(indexSignatureType) && indexSignatureType.indexSignatures.length > 0) {
|
|
2477
|
-
return unwrapAst(indexSignatureType.indexSignatures[0].type);
|
|
2478
|
-
}
|
|
2479
|
-
return null;
|
|
2480
|
-
};
|
|
2481
|
-
var getTypeDiscriminators = (typeAstList) => {
|
|
2482
|
-
const discriminatorPropCandidates = typeAstList.flatMap(SchemaAST7.getPropertySignatures).filter((p) => SchemaAST7.isLiteral(p.type));
|
|
2483
|
-
const propertyName = discriminatorPropCandidates[0].name;
|
|
2484
|
-
const isValidDiscriminator = discriminatorPropCandidates.every((p) => p.name === propertyName && !p.isOptional);
|
|
2485
|
-
const everyTypeHasDiscriminator = discriminatorPropCandidates.length === typeAstList.length;
|
|
2486
|
-
const isDiscriminatedUnion = isValidDiscriminator && everyTypeHasDiscriminator;
|
|
2487
|
-
invariant13(isDiscriminatedUnion, "type ambiguity: every type in a union must have a single unique-literal field", {
|
|
2488
|
-
F: __dxlog_file13,
|
|
2489
|
-
L: 193,
|
|
2490
|
-
S: void 0,
|
|
1288
|
+
invariant8(obj[TypeId] === void 0 || obj[TypeId] instanceof DXN2, "Invalid object model: invalid type", {
|
|
1289
|
+
F: __dxlog_file8,
|
|
1290
|
+
L: 97,
|
|
1291
|
+
S: this,
|
|
2491
1292
|
A: [
|
|
2492
|
-
"
|
|
2493
|
-
"'
|
|
1293
|
+
"obj[TypeId] === undefined || obj[TypeId] instanceof DXN",
|
|
1294
|
+
"'Invalid object model: invalid type'"
|
|
2494
1295
|
]
|
|
2495
1296
|
});
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
while (ast != null) {
|
|
2501
|
-
if (predicate?.(ast)) {
|
|
2502
|
-
return ast;
|
|
2503
|
-
}
|
|
2504
|
-
if (SchemaAST7.isUnion(ast)) {
|
|
2505
|
-
const next = ast.types.find((t) => predicate != null && predicate(t) || SchemaAST7.isSuspend(t));
|
|
2506
|
-
if (next != null) {
|
|
2507
|
-
ast = next;
|
|
2508
|
-
continue;
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
if (SchemaAST7.isSuspend(ast)) {
|
|
2512
|
-
ast = ast.f();
|
|
2513
|
-
} else {
|
|
2514
|
-
return predicate == null ? ast : null;
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
return null;
|
|
2518
|
-
};
|
|
2519
|
-
var unwrapArray = (ast) => unwrapAst(ast, SchemaAST7.isTupleType);
|
|
2520
|
-
var checkIdNotPresentOnSchema = (schema) => {
|
|
2521
|
-
invariant13(SchemaAST7.isTypeLiteral(schema.ast), void 0, {
|
|
2522
|
-
F: __dxlog_file13,
|
|
2523
|
-
L: 236,
|
|
2524
|
-
S: void 0,
|
|
1297
|
+
invariant8(obj[KindId] === EntityKind.Object || obj[KindId] === EntityKind.Relation, "Invalid object model: invalid entity kind", {
|
|
1298
|
+
F: __dxlog_file8,
|
|
1299
|
+
L: 98,
|
|
1300
|
+
S: this,
|
|
2525
1301
|
A: [
|
|
2526
|
-
"
|
|
2527
|
-
""
|
|
1302
|
+
"obj[KindId] === EntityKind.Object || obj[KindId] === EntityKind.Relation",
|
|
1303
|
+
"'Invalid object model: invalid entity kind'"
|
|
2528
1304
|
]
|
|
2529
1305
|
});
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
};
|
|
2535
|
-
|
|
2536
|
-
// src/internal/proxy/typed-handler.ts
|
|
2537
|
-
var __dxlog_file14 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/proxy/typed-handler.ts";
|
|
2538
|
-
var deepCopy = (value2, visited = /* @__PURE__ */ new Map()) => {
|
|
2539
|
-
if (value2 == null || typeof value2 !== "object") {
|
|
2540
|
-
return value2;
|
|
2541
|
-
}
|
|
2542
|
-
const actualValue = getRawTarget(value2);
|
|
2543
|
-
if (visited.has(actualValue)) {
|
|
2544
|
-
return visited.get(actualValue);
|
|
2545
|
-
}
|
|
2546
|
-
if (actualValue instanceof ReactiveArray) {
|
|
2547
|
-
const copy2 = new ReactiveArray();
|
|
2548
|
-
visited.set(actualValue, copy2);
|
|
2549
|
-
for (const item of actualValue) {
|
|
2550
|
-
copy2.push(deepCopy(item, visited));
|
|
2551
|
-
}
|
|
2552
|
-
copyHiddenProperties(actualValue, copy2);
|
|
2553
|
-
return copy2;
|
|
2554
|
-
}
|
|
2555
|
-
const proto = Object.getPrototypeOf(actualValue);
|
|
2556
|
-
if (proto !== Object.prototype && proto !== Array.prototype && proto !== null) {
|
|
2557
|
-
return value2;
|
|
2558
|
-
}
|
|
2559
|
-
if (Array.isArray(actualValue)) {
|
|
2560
|
-
const copy2 = new ReactiveArray();
|
|
2561
|
-
visited.set(actualValue, copy2);
|
|
2562
|
-
for (const item of actualValue) {
|
|
2563
|
-
copy2.push(deepCopy(item, visited));
|
|
2564
|
-
}
|
|
2565
|
-
return copy2;
|
|
2566
|
-
}
|
|
2567
|
-
const copy = {};
|
|
2568
|
-
visited.set(actualValue, copy);
|
|
2569
|
-
for (const key of Object.keys(actualValue)) {
|
|
2570
|
-
copy[key] = deepCopy(actualValue[key], visited);
|
|
2571
|
-
}
|
|
2572
|
-
copyHiddenProperties(actualValue, copy);
|
|
2573
|
-
return copy;
|
|
2574
|
-
};
|
|
2575
|
-
var copyHiddenProperties = (source, target) => {
|
|
2576
|
-
if (SchemaId in source) {
|
|
2577
|
-
defineHiddenProperty(target, SchemaId, source[SchemaId]);
|
|
2578
|
-
}
|
|
2579
|
-
if (TypeId in source) {
|
|
2580
|
-
defineHiddenProperty(target, TypeId, source[TypeId]);
|
|
2581
|
-
}
|
|
2582
|
-
};
|
|
2583
|
-
var TypedReactiveHandler = class _TypedReactiveHandler {
|
|
2584
|
-
static instance = new _TypedReactiveHandler();
|
|
2585
|
-
_proxyMap = /* @__PURE__ */ new WeakMap();
|
|
2586
|
-
_inSet = false;
|
|
2587
|
-
constructor() {
|
|
2588
|
-
}
|
|
2589
|
-
init(target) {
|
|
2590
|
-
invariant14(typeof target === "object" && target !== null, void 0, {
|
|
2591
|
-
F: __dxlog_file14,
|
|
2592
|
-
L: 148,
|
|
1306
|
+
if (obj[KindId] === EntityKind.Relation) {
|
|
1307
|
+
invariant8(obj[RelationSourceDXNId] instanceof DXN2, "Invalid object model: invalid relation source", {
|
|
1308
|
+
F: __dxlog_file8,
|
|
1309
|
+
L: 104,
|
|
2593
1310
|
S: this,
|
|
2594
1311
|
A: [
|
|
2595
|
-
"
|
|
2596
|
-
""
|
|
1312
|
+
"obj[RelationSourceDXNId] instanceof DXN",
|
|
1313
|
+
"'Invalid object model: invalid relation source'"
|
|
1314
|
+
]
|
|
1315
|
+
});
|
|
1316
|
+
invariant8(obj[RelationTargetDXNId] instanceof DXN2, "Invalid object model: invalid relation target", {
|
|
1317
|
+
F: __dxlog_file8,
|
|
1318
|
+
L: 105,
|
|
1319
|
+
S: this,
|
|
1320
|
+
A: [
|
|
1321
|
+
"obj[RelationTargetDXNId] instanceof DXN",
|
|
1322
|
+
"'Invalid object model: invalid relation target'"
|
|
2597
1323
|
]
|
|
2598
1324
|
});
|
|
2599
|
-
|
|
2600
|
-
F:
|
|
2601
|
-
L:
|
|
1325
|
+
invariant8(!(obj[RelationSourceId] instanceof DXN2), "Invalid object model: source pointer is a DXN", {
|
|
1326
|
+
F: __dxlog_file8,
|
|
1327
|
+
L: 106,
|
|
2602
1328
|
S: this,
|
|
2603
1329
|
A: [
|
|
2604
|
-
"
|
|
2605
|
-
"'
|
|
1330
|
+
"!(obj[RelationSourceId] instanceof DXN)",
|
|
1331
|
+
"'Invalid object model: source pointer is a DXN'"
|
|
2606
1332
|
]
|
|
2607
1333
|
});
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
if (!hasOwner) {
|
|
2617
|
-
for (const key in target) {
|
|
2618
|
-
if (target[symbolIsProxy]) {
|
|
2619
|
-
continue;
|
|
2620
|
-
}
|
|
2621
|
-
let value2 = target[key];
|
|
2622
|
-
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
2623
|
-
if (hasForeignOwner(value2, target)) {
|
|
2624
|
-
value2 = deepCopy(value2);
|
|
2625
|
-
target[key] = value2;
|
|
2626
|
-
}
|
|
2627
|
-
setOwnerRecursive(value2, target);
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
}
|
|
2631
|
-
Object.defineProperty(target, inspectCustom2, {
|
|
2632
|
-
enumerable: false,
|
|
2633
|
-
configurable: true,
|
|
2634
|
-
value: this._inspect.bind(target)
|
|
1334
|
+
invariant8(!(obj[RelationTargetId] instanceof DXN2), "Invalid object model: target pointer is a DXN", {
|
|
1335
|
+
F: __dxlog_file8,
|
|
1336
|
+
L: 107,
|
|
1337
|
+
S: this,
|
|
1338
|
+
A: [
|
|
1339
|
+
"!(obj[RelationTargetId] instanceof DXN)",
|
|
1340
|
+
"'Invalid object model: target pointer is a DXN'"
|
|
1341
|
+
]
|
|
2635
1342
|
});
|
|
2636
1343
|
}
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
try {
|
|
2669
|
-
batchEvents(() => {
|
|
2670
|
-
const { echoRoot: _, preparedValue } = this._prepareValueForAssignment(target, prop, value2);
|
|
2671
|
-
result = Reflect.set(target, prop, preparedValue, receiver);
|
|
2672
|
-
if (isInitialized) {
|
|
2673
|
-
queueNotification(echoRoot);
|
|
2674
|
-
notifyOwnerChain(target);
|
|
2675
|
-
}
|
|
2676
|
-
});
|
|
2677
|
-
} finally {
|
|
2678
|
-
this._inSet = false;
|
|
2679
|
-
}
|
|
2680
|
-
return result;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// src/internal/Entity/util.ts
|
|
1347
|
+
import * as Schema5 from "effect/Schema";
|
|
1348
|
+
import { assertArgument as assertArgument2, invariant as invariant9 } from "@dxos/invariant";
|
|
1349
|
+
import { DXN as DXN3, ObjectId as ObjectId3 } from "@dxos/keys";
|
|
1350
|
+
import { assumeType as assumeType2 } from "@dxos/util";
|
|
1351
|
+
var __dxlog_file9 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Entity/util.ts";
|
|
1352
|
+
var getObjectDXN = (object) => {
|
|
1353
|
+
invariant9(!Schema5.isSchema(object), "schema not allowed in this function", {
|
|
1354
|
+
F: __dxlog_file9,
|
|
1355
|
+
L: 19,
|
|
1356
|
+
S: void 0,
|
|
1357
|
+
A: [
|
|
1358
|
+
"!Schema.isSchema(object)",
|
|
1359
|
+
"'schema not allowed in this function'"
|
|
1360
|
+
]
|
|
1361
|
+
});
|
|
1362
|
+
assertArgument2(typeof object === "object" && object != null, "object", "expected object");
|
|
1363
|
+
assumeType2(object);
|
|
1364
|
+
if (object[SelfDXNId]) {
|
|
1365
|
+
invariant9(object[SelfDXNId] instanceof DXN3, "Invalid object model: invalid self dxn", {
|
|
1366
|
+
F: __dxlog_file9,
|
|
1367
|
+
L: 24,
|
|
1368
|
+
S: void 0,
|
|
1369
|
+
A: [
|
|
1370
|
+
"object[SelfDXNId] instanceof DXN",
|
|
1371
|
+
"'Invalid object model: invalid self dxn'"
|
|
1372
|
+
]
|
|
1373
|
+
});
|
|
1374
|
+
return object[SelfDXNId];
|
|
2681
1375
|
}
|
|
2682
|
-
|
|
2683
|
-
|
|
1376
|
+
if (!ObjectId3.isValid(object.id)) {
|
|
1377
|
+
throw new TypeError("Object id is not valid.");
|
|
2684
1378
|
}
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
1379
|
+
return DXN3.fromLocalObjectId(object.id);
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
// src/internal/Entity/api.ts
|
|
1383
|
+
var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Entity/api.ts";
|
|
1384
|
+
var getDXN = (entity) => {
|
|
1385
|
+
const dxn = getObjectDXN(entity);
|
|
1386
|
+
invariant10(dxn != null, "Invalid entity.", {
|
|
1387
|
+
F: __dxlog_file10,
|
|
1388
|
+
L: 20,
|
|
1389
|
+
S: void 0,
|
|
1390
|
+
A: [
|
|
1391
|
+
"dxn != null",
|
|
1392
|
+
"'Invalid entity.'"
|
|
1393
|
+
]
|
|
1394
|
+
});
|
|
1395
|
+
return dxn;
|
|
1396
|
+
};
|
|
1397
|
+
var getDatabase = (entity) => {
|
|
1398
|
+
assumeType3(entity);
|
|
1399
|
+
return entity[ObjectDatabaseId];
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
// src/internal/Entity/entity.ts
|
|
1403
|
+
import * as Schema6 from "effect/Schema";
|
|
1404
|
+
var makeEchoTypeSchema = (fields, ast, typename, version2, kind) => {
|
|
1405
|
+
return class EchoObjectSchemaClass extends Schema6.make(ast) {
|
|
1406
|
+
static typename = typename;
|
|
1407
|
+
static version = version2;
|
|
1408
|
+
static [SchemaKindId] = kind;
|
|
1409
|
+
static fields = fields;
|
|
1410
|
+
static annotations(annotations3) {
|
|
1411
|
+
const schema = Schema6.make(ast).annotations(annotations3);
|
|
1412
|
+
return makeEchoTypeSchema(fields, schema.ast, typename, version2, kind);
|
|
2691
1413
|
}
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
1414
|
+
// static make(
|
|
1415
|
+
// props: RequiredKeys<Schema.TypeLiteral.Constructor<Fields, []>> extends never
|
|
1416
|
+
// ? void | Simplify<Schema.TypeLiteral.Constructor<Fields, []>>
|
|
1417
|
+
// : Simplify<Schema.TypeLiteral.Constructor<Fields, []>>,
|
|
1418
|
+
// options?: MakeProps,
|
|
1419
|
+
// ): Simplify<Schema.TypeLiteral.Type<Fields, []>> {
|
|
1420
|
+
// const propsWithDefaults: any = _lazilyMergeDefaults(fields, { ...(props as any) });
|
|
1421
|
+
// return _getDisableValidationMakeOption(options)
|
|
1422
|
+
// ? propsWithDefaults
|
|
1423
|
+
// : ParseResult.validateSync(this)(propsWithDefaults);
|
|
1424
|
+
// }
|
|
1425
|
+
static instanceOf(value2) {
|
|
1426
|
+
return Schema6.is(this)(value2);
|
|
2695
1427
|
}
|
|
2696
|
-
|
|
1428
|
+
};
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
// src/internal/Entity/object.ts
|
|
1432
|
+
import * as Schema7 from "effect/Schema";
|
|
1433
|
+
import * as SchemaAST4 from "effect/SchemaAST";
|
|
1434
|
+
import { invariant as invariant11 } from "@dxos/invariant";
|
|
1435
|
+
var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Entity/object.ts";
|
|
1436
|
+
var EchoObjectSchema = ({ typename, version: version2 }) => {
|
|
1437
|
+
return (self) => {
|
|
1438
|
+
invariant11(typeof TypeAnnotationId === "symbol", "Sanity.", {
|
|
1439
|
+
F: __dxlog_file11,
|
|
1440
|
+
L: 37,
|
|
1441
|
+
S: void 0,
|
|
1442
|
+
A: [
|
|
1443
|
+
"typeof TypeAnnotationId === 'symbol'",
|
|
1444
|
+
"'Sanity.'"
|
|
1445
|
+
]
|
|
1446
|
+
});
|
|
1447
|
+
invariant11(SchemaAST4.isTypeLiteral(self.ast), "Schema must be a TypeLiteral.", {
|
|
1448
|
+
F: __dxlog_file11,
|
|
1449
|
+
L: 38,
|
|
1450
|
+
S: void 0,
|
|
1451
|
+
A: [
|
|
1452
|
+
"SchemaAST.isTypeLiteral(self.ast)",
|
|
1453
|
+
"'Schema must be a TypeLiteral.'"
|
|
1454
|
+
]
|
|
1455
|
+
});
|
|
1456
|
+
const fields = self.fields ?? {};
|
|
1457
|
+
const schemaWithId = Schema7.extend(self, Schema7.Struct({
|
|
1458
|
+
id: Schema7.String
|
|
1459
|
+
}));
|
|
1460
|
+
const ast = SchemaAST4.annotations(schemaWithId.ast, {
|
|
1461
|
+
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
1462
|
+
...self.ast.annotations,
|
|
1463
|
+
[TypeAnnotationId]: {
|
|
1464
|
+
kind: EntityKind.Object,
|
|
1465
|
+
typename,
|
|
1466
|
+
version: version2
|
|
1467
|
+
},
|
|
1468
|
+
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
1469
|
+
[SchemaAST4.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
1470
|
+
kind: EntityKind.Object,
|
|
1471
|
+
typename,
|
|
1472
|
+
version: version2
|
|
1473
|
+
})
|
|
1474
|
+
});
|
|
1475
|
+
return makeEchoTypeSchema(fields, ast, typename, version2, EntityKind.Object);
|
|
1476
|
+
};
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1479
|
+
// src/internal/Entity/relation.ts
|
|
1480
|
+
import * as Schema8 from "effect/Schema";
|
|
1481
|
+
import * as SchemaAST5 from "effect/SchemaAST";
|
|
1482
|
+
import { raise } from "@dxos/debug";
|
|
1483
|
+
import { assertArgument as assertArgument3, invariant as invariant12 } from "@dxos/invariant";
|
|
1484
|
+
import { DXN as DXN4 } from "@dxos/keys";
|
|
1485
|
+
var __dxlog_file12 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Entity/relation.ts";
|
|
1486
|
+
var EchoRelationSchema = ({ source, target, typename, version: version2 }) => {
|
|
1487
|
+
assertArgument3(Schema8.isSchema(source), "source");
|
|
1488
|
+
assertArgument3(Schema8.isSchema(target), "target");
|
|
1489
|
+
const sourceDXN = getDXNForRelationSchemaRef(source);
|
|
1490
|
+
const targetDXN = getDXNForRelationSchemaRef(target);
|
|
1491
|
+
if (getEntityKind(source) !== EntityKind.Object) {
|
|
1492
|
+
raise(new Error("Source schema must be an echo object schema."));
|
|
2697
1493
|
}
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
1494
|
+
if (getEntityKind(target) !== EntityKind.Object) {
|
|
1495
|
+
raise(new Error("Target schema must be an echo object schema."));
|
|
1496
|
+
}
|
|
1497
|
+
return (self) => {
|
|
1498
|
+
invariant12(SchemaAST5.isTypeLiteral(self.ast), "Schema must be a TypeLiteral.", {
|
|
1499
|
+
F: __dxlog_file12,
|
|
1500
|
+
L: 110,
|
|
1501
|
+
S: void 0,
|
|
1502
|
+
A: [
|
|
1503
|
+
"SchemaAST.isTypeLiteral(self.ast)",
|
|
1504
|
+
"'Schema must be a TypeLiteral.'"
|
|
1505
|
+
]
|
|
2709
1506
|
});
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
1507
|
+
const fields = self.fields ?? {};
|
|
1508
|
+
const schemaWithId = Schema8.extend(self, Schema8.Struct({
|
|
1509
|
+
id: Schema8.String
|
|
1510
|
+
}));
|
|
1511
|
+
const ast = SchemaAST5.annotations(schemaWithId.ast, {
|
|
1512
|
+
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
1513
|
+
...self.ast.annotations,
|
|
1514
|
+
[TypeAnnotationId]: {
|
|
1515
|
+
kind: EntityKind.Relation,
|
|
1516
|
+
typename,
|
|
1517
|
+
version: version2,
|
|
1518
|
+
sourceSchema: sourceDXN,
|
|
1519
|
+
targetSchema: targetDXN
|
|
1520
|
+
},
|
|
1521
|
+
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
1522
|
+
[SchemaAST5.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
1523
|
+
kind: EntityKind.Relation,
|
|
1524
|
+
typename,
|
|
1525
|
+
version: version2,
|
|
1526
|
+
relationSource: sourceDXN,
|
|
1527
|
+
relationTarget: targetDXN
|
|
1528
|
+
})
|
|
1529
|
+
});
|
|
1530
|
+
return makeEchoTypeSchema(fields, ast, typename, version2, EntityKind.Relation);
|
|
1531
|
+
};
|
|
1532
|
+
};
|
|
1533
|
+
var getDXNForRelationSchemaRef = (schema) => {
|
|
1534
|
+
assertArgument3(Schema8.isSchema(schema), "schema");
|
|
1535
|
+
const identifier = getTypeIdentifierAnnotation(schema);
|
|
1536
|
+
if (identifier) {
|
|
1537
|
+
return identifier;
|
|
2714
1538
|
}
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
*/
|
|
2719
|
-
_prepareValueForAssignment(target, prop, value2) {
|
|
2720
|
-
const echoRoot = getEchoRoot(target);
|
|
2721
|
-
if (prop === ParentId) {
|
|
2722
|
-
return {
|
|
2723
|
-
echoRoot,
|
|
2724
|
-
preparedValue: value2
|
|
2725
|
-
};
|
|
2726
|
-
}
|
|
2727
|
-
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
2728
|
-
if (wouldCreateCycle(echoRoot, value2)) {
|
|
2729
|
-
throw new Error("Cannot create cycles in typed object graph. Consider using Ref for circular references.");
|
|
2730
|
-
}
|
|
2731
|
-
}
|
|
2732
|
-
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
2733
|
-
const actualValue = getRawTarget(value2);
|
|
2734
|
-
const isRootEchoObject = EventId in actualValue;
|
|
2735
|
-
if (isRootEchoObject) {
|
|
2736
|
-
throw new Error("Object references must be wrapped with `Ref.make`");
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
if (isValidProxyTarget(value2) || isProxy(value2)) {
|
|
2740
|
-
const actualValue = getRawTarget(value2);
|
|
2741
|
-
const existingOwner = getOwner(actualValue);
|
|
2742
|
-
if (existingOwner != null && existingOwner !== echoRoot) {
|
|
2743
|
-
value2 = deepCopy(value2);
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
if (Array.isArray(value2) && !(value2 instanceof ReactiveArray)) {
|
|
2747
|
-
value2 = ReactiveArray.from(value2);
|
|
2748
|
-
}
|
|
2749
|
-
const validatedValue = this._validateValue(target, prop, value2);
|
|
2750
|
-
if (isValidProxyTarget(validatedValue) || isProxy(validatedValue)) {
|
|
2751
|
-
setOwnerRecursive(validatedValue, echoRoot);
|
|
2752
|
-
}
|
|
2753
|
-
return {
|
|
2754
|
-
echoRoot,
|
|
2755
|
-
preparedValue: validatedValue
|
|
2756
|
-
};
|
|
1539
|
+
const typename = getSchemaTypename(schema);
|
|
1540
|
+
if (!typename) {
|
|
1541
|
+
throw new Error("Schema must have a typename");
|
|
2757
1542
|
}
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
1543
|
+
return DXN4.fromTypename(typename).toString();
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
// src/internal/Entity/version.ts
|
|
1547
|
+
import { assertArgument as assertArgument4 } from "@dxos/invariant";
|
|
1548
|
+
var unversioned = {
|
|
1549
|
+
[VersionTypeId]: {},
|
|
1550
|
+
versioned: false
|
|
1551
|
+
};
|
|
1552
|
+
var isVersion = (entity) => {
|
|
1553
|
+
return entity != null && typeof entity === "object" && VersionTypeId in entity;
|
|
1554
|
+
};
|
|
1555
|
+
var version = (entity) => {
|
|
1556
|
+
const ver = entity[ObjectVersionId];
|
|
1557
|
+
if (ver === void 0) {
|
|
1558
|
+
return unversioned;
|
|
1559
|
+
}
|
|
1560
|
+
return ver;
|
|
1561
|
+
};
|
|
1562
|
+
var versionValid = (ver) => {
|
|
1563
|
+
assertArgument4(isVersion(ver), "version", "Invalid version object");
|
|
1564
|
+
return !!ver.versioned;
|
|
1565
|
+
};
|
|
1566
|
+
var compareVersions = (version1, version2) => {
|
|
1567
|
+
assertArgument4(isVersion(version1), "version1", "Invalid version object");
|
|
1568
|
+
assertArgument4(isVersion(version2), "version2", "Invalid version object");
|
|
1569
|
+
if (!versionValid(version1) || !versionValid(version2)) {
|
|
1570
|
+
return "unversioned";
|
|
1571
|
+
}
|
|
1572
|
+
if (version1.automergeHeads?.length !== version2.automergeHeads?.length) {
|
|
1573
|
+
return "different";
|
|
1574
|
+
}
|
|
1575
|
+
if (version1.automergeHeads?.some((head) => !version2.automergeHeads?.includes(head))) {
|
|
1576
|
+
return "different";
|
|
1577
|
+
}
|
|
1578
|
+
return "equal";
|
|
1579
|
+
};
|
|
1580
|
+
var encodeVersion = (ver) => {
|
|
1581
|
+
return JSON.stringify(ver);
|
|
1582
|
+
};
|
|
1583
|
+
var decodeVersion = (ver) => {
|
|
1584
|
+
const parsed = JSON.parse(ver);
|
|
1585
|
+
parsed[VersionTypeId] = {};
|
|
1586
|
+
return parsed;
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
// src/internal/JsonSchema/json-schema-normalize.ts
|
|
1590
|
+
var normalizeSchema = (schema) => {
|
|
1591
|
+
const copy = structuredClone(schema);
|
|
1592
|
+
go(copy);
|
|
1593
|
+
return copy;
|
|
1594
|
+
};
|
|
1595
|
+
var go = (schema) => {
|
|
1596
|
+
if (typeof schema !== "object" || schema === null) {
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
if (schema.exclusiveMaximum === true) {
|
|
1600
|
+
schema.exclusiveMaximum = schema.maximum;
|
|
1601
|
+
delete schema.exclusiveMaximum;
|
|
1602
|
+
} else if (schema.exclusiveMaximum === false) {
|
|
1603
|
+
delete schema.exclusiveMaximum;
|
|
1604
|
+
}
|
|
1605
|
+
if (schema.exclusiveMinimum === true) {
|
|
1606
|
+
schema.exclusiveMinimum = schema.minimum;
|
|
1607
|
+
delete schema.exclusiveMinimum;
|
|
1608
|
+
} else if (schema.exclusiveMinimum === false) {
|
|
1609
|
+
delete schema.exclusiveMinimum;
|
|
1610
|
+
}
|
|
1611
|
+
for (const key of Object.keys(schema)) {
|
|
1612
|
+
if (!JsonSchemaFields.includes(key)) {
|
|
1613
|
+
delete schema[key];
|
|
2766
1614
|
}
|
|
2767
|
-
return value2;
|
|
2768
1615
|
}
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
1616
|
+
if (schema.properties) {
|
|
1617
|
+
goOnRecord(schema.properties);
|
|
1618
|
+
}
|
|
1619
|
+
if (schema.patternProperties) {
|
|
1620
|
+
goOnRecord(schema.patternProperties);
|
|
1621
|
+
}
|
|
1622
|
+
if (schema.propertyNames) {
|
|
1623
|
+
go(schema.propertyNames);
|
|
1624
|
+
}
|
|
1625
|
+
if (schema.definitions) {
|
|
1626
|
+
goOnRecord(schema.definitions);
|
|
2776
1627
|
}
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
return {
|
|
2780
|
-
"@type": "TypedReactiveObject",
|
|
2781
|
-
...target
|
|
2782
|
-
};
|
|
2783
|
-
};
|
|
2784
|
-
var setSchemaProperties = (obj, schema) => {
|
|
2785
|
-
const schemaType = getSchemaDXN(schema);
|
|
2786
|
-
if (schemaType != null) {
|
|
2787
|
-
defineHiddenProperty(obj, TypeId, schemaType);
|
|
1628
|
+
if (schema.items) {
|
|
1629
|
+
maybeGoOnArray(schema.items);
|
|
2788
1630
|
}
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
if (isValidProxyTarget(obj[key])) {
|
|
2792
|
-
const elementSchema = SchemaValidator.getTargetPropertySchema(obj, key);
|
|
2793
|
-
if (elementSchema != null) {
|
|
2794
|
-
setSchemaProperties(obj[key], elementSchema);
|
|
2795
|
-
}
|
|
2796
|
-
}
|
|
1631
|
+
if (schema.additionalItems) {
|
|
1632
|
+
maybeGoOnArray(schema.additionalItems);
|
|
2797
1633
|
}
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
if (!SchemaAST8.isTypeLiteral(schema.ast)) {
|
|
2801
|
-
throw new Error("schema has to describe an object type");
|
|
1634
|
+
if (schema.contains) {
|
|
1635
|
+
go(schema.contains);
|
|
2802
1636
|
}
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
makeArraysReactive(target);
|
|
2806
|
-
setSchemaProperties(target, schema);
|
|
2807
|
-
};
|
|
2808
|
-
var makeArraysReactive = (target) => {
|
|
2809
|
-
for (const key in target) {
|
|
2810
|
-
if (target[symbolIsProxy]) {
|
|
2811
|
-
continue;
|
|
2812
|
-
}
|
|
2813
|
-
if (Array.isArray(target[key])) {
|
|
2814
|
-
target[key] = ReactiveArray.from(target[key]);
|
|
2815
|
-
}
|
|
2816
|
-
if (typeof target[key] === "object") {
|
|
2817
|
-
makeArraysReactive(target[key]);
|
|
2818
|
-
}
|
|
1637
|
+
if (schema.if) {
|
|
1638
|
+
go(schema.if);
|
|
2819
1639
|
}
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
// src/internal/proxy/make-object.ts
|
|
2823
|
-
var makeObject = (schema, obj, meta) => {
|
|
2824
|
-
return createReactiveObject(Object.assign({}, obj), meta, schema);
|
|
2825
|
-
};
|
|
2826
|
-
var createReactiveObject = (obj, meta, schema) => {
|
|
2827
|
-
if (!isValidProxyTarget(obj)) {
|
|
2828
|
-
throw new Error("Value cannot be made into a reactive object.");
|
|
1640
|
+
if (schema.then) {
|
|
1641
|
+
go(schema.then);
|
|
2829
1642
|
}
|
|
2830
|
-
if (
|
|
2831
|
-
|
|
1643
|
+
if (schema.else) {
|
|
1644
|
+
go(schema.else);
|
|
2832
1645
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
delete obj[ParentId];
|
|
1646
|
+
if (schema.allOf) {
|
|
1647
|
+
maybeGoOnArray(schema.allOf);
|
|
2836
1648
|
}
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
setIdOnTarget(obj);
|
|
2840
|
-
defineHiddenProperty(obj, KindId, annotation.kind);
|
|
1649
|
+
if (schema.anyOf) {
|
|
1650
|
+
maybeGoOnArray(schema.anyOf);
|
|
2841
1651
|
}
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
defineHiddenProperty(obj, ParentId, parent);
|
|
1652
|
+
if (schema.oneOf) {
|
|
1653
|
+
maybeGoOnArray(schema.oneOf);
|
|
2845
1654
|
}
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
}
|
|
1655
|
+
if (schema.not) {
|
|
1656
|
+
go(schema.not);
|
|
1657
|
+
}
|
|
1658
|
+
if (schema.$defs) {
|
|
1659
|
+
goOnRecord(schema.$defs);
|
|
1660
|
+
}
|
|
1661
|
+
if (schema.reference) {
|
|
1662
|
+
go(schema.reference.schema);
|
|
2855
1663
|
}
|
|
2856
|
-
return proxy;
|
|
2857
1664
|
};
|
|
2858
|
-
var
|
|
2859
|
-
if (
|
|
2860
|
-
|
|
2861
|
-
|
|
1665
|
+
var maybeGoOnArray = (value2) => {
|
|
1666
|
+
if (Array.isArray(value2)) {
|
|
1667
|
+
for (const item of value2) {
|
|
1668
|
+
go(item);
|
|
2862
1669
|
}
|
|
2863
|
-
} else {
|
|
2864
|
-
|
|
1670
|
+
} else if (typeof value2 === "object" && value2 !== null) {
|
|
1671
|
+
go(value2);
|
|
2865
1672
|
}
|
|
2866
1673
|
};
|
|
2867
|
-
var
|
|
2868
|
-
keys
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
defineHiddenProperty(obj, MetaId, createProxy(meta, TypedReactiveHandler.instance));
|
|
1674
|
+
var goOnRecord = (record) => {
|
|
1675
|
+
for (const key of Object.keys(record)) {
|
|
1676
|
+
go(record[key]);
|
|
1677
|
+
}
|
|
2872
1678
|
};
|
|
2873
1679
|
|
|
2874
|
-
// src/internal/
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
1680
|
+
// src/internal/Obj/common.ts
|
|
1681
|
+
import * as Schema9 from "effect/Schema";
|
|
1682
|
+
var makeTypedEntityClass = (typename, version2, baseSchema) => {
|
|
1683
|
+
return class {
|
|
1684
|
+
// Implement TypedObject properties.
|
|
1685
|
+
static typename = typename;
|
|
1686
|
+
static version = version2;
|
|
1687
|
+
// Implement Schema.Schema properties.
|
|
1688
|
+
// TODO(burdon): Comment required.
|
|
1689
|
+
static [Schema9.TypeId] = schemaVariance;
|
|
1690
|
+
static ast = baseSchema.ast;
|
|
1691
|
+
static annotations = baseSchema.annotations.bind(baseSchema);
|
|
1692
|
+
static pipe = baseSchema.pipe.bind(baseSchema);
|
|
1693
|
+
// TODO(burdon): Comment required.
|
|
1694
|
+
static [Symbol.hasInstance](obj) {
|
|
1695
|
+
return obj != null && getTypename(obj) === typename;
|
|
1696
|
+
}
|
|
1697
|
+
// TODO(burdon): Throw APIError.
|
|
1698
|
+
constructor() {
|
|
1699
|
+
throw new Error("Use live(Typename, { ...fields }) to instantiate an object.");
|
|
1700
|
+
}
|
|
2881
1701
|
};
|
|
2882
1702
|
};
|
|
2883
|
-
var
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
} else {
|
|
2888
|
-
callback(obj);
|
|
2889
|
-
}
|
|
1703
|
+
var schemaVariance = {
|
|
1704
|
+
_A: (_) => _,
|
|
1705
|
+
_I: (_) => _,
|
|
1706
|
+
_R: (_) => _
|
|
2890
1707
|
};
|
|
2891
1708
|
|
|
2892
|
-
// src/internal/object
|
|
2893
|
-
import {
|
|
1709
|
+
// src/internal/Obj/create-object.ts
|
|
1710
|
+
import { raise as raise3 } from "@dxos/debug";
|
|
1711
|
+
import { assertArgument as assertArgument6, failedInvariant } from "@dxos/invariant";
|
|
1712
|
+
import { ObjectId as ObjectId5 } from "@dxos/keys";
|
|
1713
|
+
|
|
1714
|
+
// src/internal/Obj/inspect.ts
|
|
1715
|
+
import { inspectCustom as inspectCustom2 } from "@dxos/debug";
|
|
2894
1716
|
var attachedTypedObjectInspector = (obj) => {
|
|
2895
|
-
const descriptor = Object.getOwnPropertyDescriptor(obj,
|
|
1717
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, inspectCustom2);
|
|
2896
1718
|
if (descriptor) {
|
|
2897
1719
|
return;
|
|
2898
1720
|
}
|
|
2899
|
-
Object.defineProperty(obj,
|
|
1721
|
+
Object.defineProperty(obj, inspectCustom2, {
|
|
2900
1722
|
value: typedObjectInspectFunction,
|
|
2901
1723
|
writable: false,
|
|
2902
1724
|
enumerable: false,
|
|
@@ -2913,19 +1735,19 @@ var typedObjectInspectFunction = function(depth, options, inspect) {
|
|
|
2913
1735
|
}, options);
|
|
2914
1736
|
};
|
|
2915
1737
|
|
|
2916
|
-
// src/internal/
|
|
2917
|
-
import * as
|
|
2918
|
-
import { raise as
|
|
1738
|
+
// src/internal/Obj/json-serializer.ts
|
|
1739
|
+
import * as Schema10 from "effect/Schema";
|
|
1740
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
2919
1741
|
import { ObjectStructure, isEncodedReference } from "@dxos/echo-protocol";
|
|
2920
|
-
import { assertArgument as
|
|
2921
|
-
import { DXN as
|
|
1742
|
+
import { assertArgument as assertArgument5, invariant as invariant13 } from "@dxos/invariant";
|
|
1743
|
+
import { DXN as DXN5, ObjectId as ObjectId4 } from "@dxos/keys";
|
|
2922
1744
|
import { assumeType as assumeType4, deepMapValues as deepMapValues2, visitValues } from "@dxos/util";
|
|
2923
|
-
var
|
|
1745
|
+
var __dxlog_file13 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Obj/json-serializer.ts";
|
|
2924
1746
|
var objectToJSON = (obj) => {
|
|
2925
1747
|
const typename = getTypeDXN(obj)?.toString();
|
|
2926
|
-
|
|
2927
|
-
F:
|
|
2928
|
-
L:
|
|
1748
|
+
invariant13(typename && typeof typename === "string", void 0, {
|
|
1749
|
+
F: __dxlog_file13,
|
|
1750
|
+
L: 66,
|
|
2929
1751
|
S: void 0,
|
|
2930
1752
|
A: [
|
|
2931
1753
|
"typename && typeof typename === 'string'",
|
|
@@ -2934,16 +1756,16 @@ var objectToJSON = (obj) => {
|
|
|
2934
1756
|
});
|
|
2935
1757
|
return typedJsonSerializer.call(obj);
|
|
2936
1758
|
};
|
|
2937
|
-
var objectFromJSON = async (jsonData, { refResolver, dxn } = {}) => {
|
|
1759
|
+
var objectFromJSON = async (jsonData, { refResolver, dxn, database } = {}) => {
|
|
2938
1760
|
assumeType4(jsonData);
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
const type =
|
|
1761
|
+
assertArgument5(typeof jsonData === "object" && jsonData !== null, "jsonData", "expect object");
|
|
1762
|
+
assertArgument5(typeof jsonData[ATTR_TYPE] === "string", "jsonData[ATTR_TYPE]", "expected object to have a type");
|
|
1763
|
+
assertArgument5(typeof jsonData.id === "string", "jsonData.id", "expected object to have an id");
|
|
1764
|
+
const type = DXN5.parse(jsonData[ATTR_TYPE]);
|
|
2943
1765
|
const schema = await refResolver?.resolveSchema(type);
|
|
2944
|
-
|
|
2945
|
-
F:
|
|
2946
|
-
L:
|
|
1766
|
+
invariant13(schema === void 0 || Schema10.isSchema(schema), void 0, {
|
|
1767
|
+
F: __dxlog_file13,
|
|
1768
|
+
L: 92,
|
|
2947
1769
|
S: void 0,
|
|
2948
1770
|
A: [
|
|
2949
1771
|
"schema === undefined || Schema.isSchema(schema)",
|
|
@@ -2953,7 +1775,7 @@ var objectFromJSON = async (jsonData, { refResolver, dxn } = {}) => {
|
|
|
2953
1775
|
const decodedInput = stripInternalJsonKeys(jsonData);
|
|
2954
1776
|
let obj;
|
|
2955
1777
|
if (schema != null) {
|
|
2956
|
-
obj = await schema.pipe(
|
|
1778
|
+
obj = await schema.pipe(Schema10.decodeUnknownPromise)(decodedInput);
|
|
2957
1779
|
if (refResolver) {
|
|
2958
1780
|
setRefResolverOnData(obj, refResolver);
|
|
2959
1781
|
}
|
|
@@ -2962,9 +1784,9 @@ var objectFromJSON = async (jsonData, { refResolver, dxn } = {}) => {
|
|
|
2962
1784
|
refResolver
|
|
2963
1785
|
});
|
|
2964
1786
|
}
|
|
2965
|
-
|
|
2966
|
-
F:
|
|
2967
|
-
L:
|
|
1787
|
+
invariant13(ObjectId4.isValid(obj.id), "Invalid object id", {
|
|
1788
|
+
F: __dxlog_file13,
|
|
1789
|
+
L: 105,
|
|
2968
1790
|
S: void 0,
|
|
2969
1791
|
A: [
|
|
2970
1792
|
"ObjectId.isValid(obj.id)",
|
|
@@ -2977,8 +1799,8 @@ var objectFromJSON = async (jsonData, { refResolver, dxn } = {}) => {
|
|
|
2977
1799
|
}
|
|
2978
1800
|
const isRelation = typeof jsonData[ATTR_RELATION_SOURCE] === "string" || typeof jsonData[ATTR_RELATION_TARGET] === "string";
|
|
2979
1801
|
if (isRelation) {
|
|
2980
|
-
const sourceDxn =
|
|
2981
|
-
const targetDxn =
|
|
1802
|
+
const sourceDxn = DXN5.parse(jsonData[ATTR_RELATION_SOURCE] ?? raise2(new TypeError("Missing relation source")));
|
|
1803
|
+
const targetDxn = DXN5.parse(jsonData[ATTR_RELATION_TARGET] ?? raise2(new TypeError("Missing relation target")));
|
|
2982
1804
|
const source = await refResolver?.resolve(sourceDxn);
|
|
2983
1805
|
const target = await refResolver?.resolve(targetDxn);
|
|
2984
1806
|
defineHiddenProperty(obj, KindId, EntityKind.Relation);
|
|
@@ -2990,10 +1812,10 @@ var objectFromJSON = async (jsonData, { refResolver, dxn } = {}) => {
|
|
|
2990
1812
|
defineHiddenProperty(obj, KindId, EntityKind.Object);
|
|
2991
1813
|
}
|
|
2992
1814
|
if (typeof jsonData[ATTR_META] === "object") {
|
|
2993
|
-
const meta = await ObjectMetaSchema.pipe(
|
|
2994
|
-
|
|
2995
|
-
F:
|
|
2996
|
-
L:
|
|
1815
|
+
const meta = await ObjectMetaSchema.pipe(Schema10.decodeUnknownPromise)(jsonData[ATTR_META]);
|
|
1816
|
+
invariant13(Array.isArray(meta.keys), void 0, {
|
|
1817
|
+
F: __dxlog_file13,
|
|
1818
|
+
L: 131,
|
|
2997
1819
|
S: void 0,
|
|
2998
1820
|
A: [
|
|
2999
1821
|
"Array.isArray(meta.keys)",
|
|
@@ -3007,62 +1829,65 @@ var objectFromJSON = async (jsonData, { refResolver, dxn } = {}) => {
|
|
|
3007
1829
|
});
|
|
3008
1830
|
}
|
|
3009
1831
|
if (jsonData[ATTR_PARENT]) {
|
|
3010
|
-
const parentDxn =
|
|
1832
|
+
const parentDxn = DXN5.parse(jsonData[ATTR_PARENT]);
|
|
3011
1833
|
const parent = await refResolver?.resolve(parentDxn);
|
|
3012
1834
|
defineHiddenProperty(obj, ParentId, parent);
|
|
3013
1835
|
}
|
|
3014
1836
|
if (dxn) {
|
|
3015
1837
|
defineHiddenProperty(obj, SelfDXNId, dxn);
|
|
3016
1838
|
}
|
|
1839
|
+
if (database) {
|
|
1840
|
+
defineHiddenProperty(obj, ObjectDatabaseId, database);
|
|
1841
|
+
}
|
|
3017
1842
|
assertObjectModel(obj);
|
|
3018
|
-
|
|
3019
|
-
F:
|
|
3020
|
-
L:
|
|
1843
|
+
invariant13(obj[ATTR_TYPE] === void 0, "Invalid object model", {
|
|
1844
|
+
F: __dxlog_file13,
|
|
1845
|
+
L: 154,
|
|
3021
1846
|
S: void 0,
|
|
3022
1847
|
A: [
|
|
3023
1848
|
"(obj as any)[ATTR_TYPE] === undefined",
|
|
3024
1849
|
"'Invalid object model'"
|
|
3025
1850
|
]
|
|
3026
1851
|
});
|
|
3027
|
-
|
|
3028
|
-
F:
|
|
3029
|
-
L:
|
|
1852
|
+
invariant13(obj[ATTR_META] === void 0, "Invalid object model", {
|
|
1853
|
+
F: __dxlog_file13,
|
|
1854
|
+
L: 155,
|
|
3030
1855
|
S: void 0,
|
|
3031
1856
|
A: [
|
|
3032
1857
|
"(obj as any)[ATTR_META] === undefined",
|
|
3033
1858
|
"'Invalid object model'"
|
|
3034
1859
|
]
|
|
3035
1860
|
});
|
|
3036
|
-
|
|
3037
|
-
F:
|
|
3038
|
-
L:
|
|
1861
|
+
invariant13(obj[ATTR_DELETED] === void 0, "Invalid object model", {
|
|
1862
|
+
F: __dxlog_file13,
|
|
1863
|
+
L: 156,
|
|
3039
1864
|
S: void 0,
|
|
3040
1865
|
A: [
|
|
3041
1866
|
"(obj as any)[ATTR_DELETED] === undefined",
|
|
3042
1867
|
"'Invalid object model'"
|
|
3043
1868
|
]
|
|
3044
1869
|
});
|
|
3045
|
-
|
|
3046
|
-
F:
|
|
3047
|
-
L:
|
|
1870
|
+
invariant13(obj[ATTR_SELF_DXN] === void 0, "Invalid object model", {
|
|
1871
|
+
F: __dxlog_file13,
|
|
1872
|
+
L: 157,
|
|
3048
1873
|
S: void 0,
|
|
3049
1874
|
A: [
|
|
3050
1875
|
"(obj as any)[ATTR_SELF_DXN] === undefined",
|
|
3051
1876
|
"'Invalid object model'"
|
|
3052
1877
|
]
|
|
3053
1878
|
});
|
|
3054
|
-
|
|
3055
|
-
F:
|
|
3056
|
-
L:
|
|
1879
|
+
invariant13(obj[ATTR_RELATION_SOURCE] === void 0, "Invalid object model", {
|
|
1880
|
+
F: __dxlog_file13,
|
|
1881
|
+
L: 158,
|
|
3057
1882
|
S: void 0,
|
|
3058
1883
|
A: [
|
|
3059
1884
|
"(obj as any)[ATTR_RELATION_SOURCE] === undefined",
|
|
3060
1885
|
"'Invalid object model'"
|
|
3061
1886
|
]
|
|
3062
1887
|
});
|
|
3063
|
-
|
|
3064
|
-
F:
|
|
3065
|
-
L:
|
|
1888
|
+
invariant13(obj[ATTR_RELATION_TARGET] === void 0, "Invalid object model", {
|
|
1889
|
+
F: __dxlog_file13,
|
|
1890
|
+
L: 159,
|
|
3066
1891
|
S: void 0,
|
|
3067
1892
|
A: [
|
|
3068
1893
|
"(obj as any)[ATTR_RELATION_TARGET] === undefined",
|
|
@@ -3106,19 +1931,19 @@ var objectStructureToJson = (objectId, structure) => {
|
|
|
3106
1931
|
};
|
|
3107
1932
|
};
|
|
3108
1933
|
|
|
3109
|
-
// src/internal/
|
|
1934
|
+
// src/internal/Obj/create-object.ts
|
|
3110
1935
|
var createObject = (schema, props) => {
|
|
3111
1936
|
const annotation = getTypeAnnotation(schema);
|
|
3112
1937
|
if (!annotation) {
|
|
3113
1938
|
throw new Error("Schema is not an ECHO schema");
|
|
3114
1939
|
}
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
1940
|
+
assertArgument6(!("@type" in props), "data", "@type is not allowed");
|
|
1941
|
+
assertArgument6(!(RelationSourceDXNId in props), "data", "Relation source DXN is not allowed in the constructor");
|
|
1942
|
+
assertArgument6(!(RelationTargetDXNId in props), "data", "Relation target DXN is not allowed in the constructor");
|
|
1943
|
+
assertArgument6(RelationSourceId in props === RelationTargetId in props, "data", "Relation source and target must be provided together");
|
|
3119
1944
|
const obj = {
|
|
3120
1945
|
...props,
|
|
3121
|
-
id: props.id ??
|
|
1946
|
+
id: props.id ?? ObjectId5.random()
|
|
3122
1947
|
};
|
|
3123
1948
|
const kind = RelationSourceId in props ? EntityKind.Relation : EntityKind.Object;
|
|
3124
1949
|
defineHiddenProperty(obj, KindId, kind);
|
|
@@ -3130,8 +1955,8 @@ var createObject = (schema, props) => {
|
|
|
3130
1955
|
attachTypedJsonSerializer(obj);
|
|
3131
1956
|
attachedTypedObjectInspector(obj);
|
|
3132
1957
|
if (kind === EntityKind.Relation) {
|
|
3133
|
-
const sourceDXN = getObjectDXN(props[RelationSourceId]) ??
|
|
3134
|
-
const targetDXN = getObjectDXN(props[RelationTargetId]) ??
|
|
1958
|
+
const sourceDXN = getObjectDXN(props[RelationSourceId]) ?? raise3(new Error("Unresolved relation source"));
|
|
1959
|
+
const targetDXN = getObjectDXN(props[RelationTargetId]) ?? raise3(new Error("Unresolved relation target"));
|
|
3135
1960
|
defineHiddenProperty(obj, RelationSourceDXNId, sourceDXN);
|
|
3136
1961
|
defineHiddenProperty(obj, RelationTargetDXNId, targetDXN);
|
|
3137
1962
|
}
|
|
@@ -3139,7 +1964,7 @@ var createObject = (schema, props) => {
|
|
|
3139
1964
|
return obj;
|
|
3140
1965
|
};
|
|
3141
1966
|
|
|
3142
|
-
// src/internal/
|
|
1967
|
+
// src/internal/Obj/deleted.ts
|
|
3143
1968
|
var isDeleted = (obj) => {
|
|
3144
1969
|
if (obj[ObjectDeletedId] === void 0) {
|
|
3145
1970
|
return false;
|
|
@@ -3147,24 +1972,24 @@ var isDeleted = (obj) => {
|
|
|
3147
1972
|
return obj[ObjectDeletedId] ?? false;
|
|
3148
1973
|
};
|
|
3149
1974
|
|
|
3150
|
-
// src/internal/
|
|
3151
|
-
import { DXN as
|
|
3152
|
-
var createQueueDXN = (spaceId = SpaceId.random(), queueId =
|
|
1975
|
+
// src/internal/Obj/ids.ts
|
|
1976
|
+
import { DXN as DXN6, ObjectId as ObjectId6, QueueSubspaceTags, SpaceId } from "@dxos/keys";
|
|
1977
|
+
var createQueueDXN = (spaceId = SpaceId.random(), queueId = ObjectId6.random()) => new DXN6(DXN6.kind.QUEUE, [
|
|
3153
1978
|
QueueSubspaceTags.DATA,
|
|
3154
1979
|
spaceId,
|
|
3155
1980
|
queueId
|
|
3156
1981
|
]);
|
|
3157
1982
|
|
|
3158
|
-
// src/internal/
|
|
1983
|
+
// src/internal/Obj/set-value.ts
|
|
3159
1984
|
import * as Match from "effect/Match";
|
|
3160
|
-
import * as
|
|
3161
|
-
import * as
|
|
1985
|
+
import * as Option from "effect/Option";
|
|
1986
|
+
import * as SchemaAST6 from "effect/SchemaAST";
|
|
3162
1987
|
import { getArrayElementType, getBaseType, getProperties as getProperties2, isArrayType, isNestedType } from "@dxos/effect";
|
|
3163
|
-
import { invariant as
|
|
3164
|
-
var
|
|
1988
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
1989
|
+
var __dxlog_file14 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Obj/set-value.ts";
|
|
3165
1990
|
var setValue = (obj, path, value2) => {
|
|
3166
|
-
|
|
3167
|
-
F:
|
|
1991
|
+
invariant14(path.length > 0, "Path must not be empty", {
|
|
1992
|
+
F: __dxlog_file14,
|
|
3168
1993
|
L: 27,
|
|
3169
1994
|
S: void 0,
|
|
3170
1995
|
A: [
|
|
@@ -3173,8 +1998,8 @@ var setValue = (obj, path, value2) => {
|
|
|
3173
1998
|
]
|
|
3174
1999
|
});
|
|
3175
2000
|
const schema = getSchema(obj);
|
|
3176
|
-
|
|
3177
|
-
F:
|
|
2001
|
+
invariant14(schema != null, "Object must have a schema", {
|
|
2002
|
+
F: __dxlog_file14,
|
|
3178
2003
|
L: 30,
|
|
3179
2004
|
S: void 0,
|
|
3180
2005
|
A: [
|
|
@@ -3235,8 +2060,8 @@ var getDefaultValueForType = (ast) => {
|
|
|
3235
2060
|
if (!ast) {
|
|
3236
2061
|
return void 0;
|
|
3237
2062
|
}
|
|
3238
|
-
const defaultValue =
|
|
3239
|
-
if (
|
|
2063
|
+
const defaultValue = SchemaAST6.getDefaultAnnotation(ast);
|
|
2064
|
+
if (Option.isSome(defaultValue)) {
|
|
3240
2065
|
return defaultValue.value;
|
|
3241
2066
|
}
|
|
3242
2067
|
return Match.value(ast).pipe(Match.when({
|
|
@@ -3264,19 +2089,19 @@ var createObjectWithDefaults = (ast) => {
|
|
|
3264
2089
|
return obj;
|
|
3265
2090
|
};
|
|
3266
2091
|
|
|
3267
|
-
// src/internal/
|
|
3268
|
-
import { assertArgument as
|
|
2092
|
+
// src/internal/Obj/snapshot.ts
|
|
2093
|
+
import { assertArgument as assertArgument7 } from "@dxos/invariant";
|
|
3269
2094
|
import { deepMapValues as deepMapValues3 } from "@dxos/util";
|
|
3270
|
-
var copySymbolProperty = (source, target,
|
|
2095
|
+
var copySymbolProperty = (source, target, symbol, transform) => {
|
|
3271
2096
|
let value2;
|
|
3272
2097
|
try {
|
|
3273
|
-
value2 = source[
|
|
2098
|
+
value2 = source[symbol];
|
|
3274
2099
|
} catch {
|
|
3275
2100
|
return;
|
|
3276
2101
|
}
|
|
3277
2102
|
if (value2 !== void 0) {
|
|
3278
2103
|
const finalValue = transform ? transform(value2) : value2;
|
|
3279
|
-
Object.defineProperty(target,
|
|
2104
|
+
Object.defineProperty(target, symbol, {
|
|
3280
2105
|
value: finalValue,
|
|
3281
2106
|
writable: false,
|
|
3282
2107
|
enumerable: false,
|
|
@@ -3285,7 +2110,7 @@ var copySymbolProperty = (source, target, symbol3, transform) => {
|
|
|
3285
2110
|
}
|
|
3286
2111
|
};
|
|
3287
2112
|
var getSnapshot = (obj) => {
|
|
3288
|
-
|
|
2113
|
+
assertArgument7(typeof obj === "object" && obj !== null && KindId in obj, "obj", "must be an entity");
|
|
3289
2114
|
const snapshot = deepMapValues3(obj, (value2, recurse) => {
|
|
3290
2115
|
if (typeof value2 === "object" && value2 !== null && Object.getPrototypeOf(value2) !== Object.prototype && !Array.isArray(value2)) {
|
|
3291
2116
|
return value2;
|
|
@@ -3316,15 +2141,15 @@ var getSnapshot = (obj) => {
|
|
|
3316
2141
|
return Object.freeze(snapshot);
|
|
3317
2142
|
};
|
|
3318
2143
|
|
|
3319
|
-
// src/internal/
|
|
3320
|
-
import { invariant as
|
|
2144
|
+
// src/internal/Obj/clone.ts
|
|
2145
|
+
import { invariant as invariant15 } from "@dxos/invariant";
|
|
3321
2146
|
import { deepMapValues as deepMapValues4 } from "@dxos/util";
|
|
3322
|
-
var
|
|
2147
|
+
var __dxlog_file15 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Obj/clone.ts";
|
|
3323
2148
|
var clone = (obj, opts) => {
|
|
3324
2149
|
const { id, ...data } = obj;
|
|
3325
2150
|
const schema = getSchema(obj);
|
|
3326
|
-
|
|
3327
|
-
F:
|
|
2151
|
+
invariant15(schema != null, "Object should have a schema", {
|
|
2152
|
+
F: __dxlog_file15,
|
|
3328
2153
|
L: 21,
|
|
3329
2154
|
S: void 0,
|
|
3330
2155
|
A: [
|
|
@@ -3356,25 +2181,25 @@ var clone = (obj, opts) => {
|
|
|
3356
2181
|
return makeObject(schema, props, meta);
|
|
3357
2182
|
};
|
|
3358
2183
|
|
|
3359
|
-
// src/internal/
|
|
3360
|
-
import * as
|
|
3361
|
-
import * as
|
|
3362
|
-
import { invariant as
|
|
2184
|
+
// src/internal/Type/echo-schema.ts
|
|
2185
|
+
import * as Schema13 from "effect/Schema";
|
|
2186
|
+
import * as SchemaAST8 from "effect/SchemaAST";
|
|
2187
|
+
import { invariant as invariant17 } from "@dxos/invariant";
|
|
3363
2188
|
|
|
3364
|
-
// src/internal/
|
|
3365
|
-
import * as
|
|
3366
|
-
import * as
|
|
3367
|
-
import { invariant as
|
|
3368
|
-
import { DXN as
|
|
3369
|
-
var
|
|
2189
|
+
// src/internal/Type/manipulation.ts
|
|
2190
|
+
import * as Schema11 from "effect/Schema";
|
|
2191
|
+
import * as SchemaAST7 from "effect/SchemaAST";
|
|
2192
|
+
import { invariant as invariant16 } from "@dxos/invariant";
|
|
2193
|
+
import { DXN as DXN7 } from "@dxos/keys";
|
|
2194
|
+
var __dxlog_file16 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Type/manipulation.ts";
|
|
3370
2195
|
var addFieldsToSchema = (schema, fields) => {
|
|
3371
|
-
const schemaExtension =
|
|
3372
|
-
return
|
|
2196
|
+
const schemaExtension = Schema11.partial(Schema11.Struct(fields));
|
|
2197
|
+
return Schema11.extend(schema, schemaExtension).annotations(schema.ast.annotations);
|
|
3373
2198
|
};
|
|
3374
2199
|
var updateFieldsInSchema = (schema, fields) => {
|
|
3375
2200
|
const ast = schema.ast;
|
|
3376
|
-
|
|
3377
|
-
F:
|
|
2201
|
+
invariant16(SchemaAST7.isTypeLiteral(ast), void 0, {
|
|
2202
|
+
F: __dxlog_file16,
|
|
3378
2203
|
L: 29,
|
|
3379
2204
|
S: void 0,
|
|
3380
2205
|
A: [
|
|
@@ -3385,7 +2210,7 @@ var updateFieldsInSchema = (schema, fields) => {
|
|
|
3385
2210
|
const updatedProperties = [
|
|
3386
2211
|
...ast.propertySignatures
|
|
3387
2212
|
];
|
|
3388
|
-
const propertiesToUpdate =
|
|
2213
|
+
const propertiesToUpdate = Schema11.partial(Schema11.Struct(fields)).ast.propertySignatures;
|
|
3389
2214
|
for (const property of propertiesToUpdate) {
|
|
3390
2215
|
const index = updatedProperties.findIndex((p) => p.name === property.name);
|
|
3391
2216
|
if (index !== -1) {
|
|
@@ -3394,15 +2219,15 @@ var updateFieldsInSchema = (schema, fields) => {
|
|
|
3394
2219
|
updatedProperties.push(property);
|
|
3395
2220
|
}
|
|
3396
2221
|
}
|
|
3397
|
-
return
|
|
2222
|
+
return Schema11.make(new SchemaAST7.TypeLiteral(updatedProperties, ast.indexSignatures, ast.annotations));
|
|
3398
2223
|
};
|
|
3399
2224
|
var removeFieldsFromSchema = (schema, fieldNames) => {
|
|
3400
|
-
return
|
|
2225
|
+
return Schema11.make(SchemaAST7.omit(schema.ast, fieldNames)).annotations(schema.ast.annotations);
|
|
3401
2226
|
};
|
|
3402
2227
|
var updateFieldNameInSchema = (schema, { before, after }) => {
|
|
3403
2228
|
const ast = schema.ast;
|
|
3404
|
-
|
|
3405
|
-
F:
|
|
2229
|
+
invariant16(SchemaAST7.isTypeLiteral(ast), void 0, {
|
|
2230
|
+
F: __dxlog_file16,
|
|
3406
2231
|
L: 57,
|
|
3407
2232
|
S: void 0,
|
|
3408
2233
|
A: [
|
|
@@ -3410,12 +2235,12 @@ var updateFieldNameInSchema = (schema, { before, after }) => {
|
|
|
3410
2235
|
""
|
|
3411
2236
|
]
|
|
3412
2237
|
});
|
|
3413
|
-
return
|
|
2238
|
+
return Schema11.make(new SchemaAST7.TypeLiteral(ast.propertySignatures.map((p) => p.name === before ? new SchemaAST7.PropertySignature(after, p.type, p.isOptional, p.isReadonly, p.annotations) : p), ast.indexSignatures, ast.annotations));
|
|
3414
2239
|
};
|
|
3415
2240
|
var setTypenameInSchema = (schema, typename) => {
|
|
3416
2241
|
const existingAnnotation = schema.ast.annotations[TypeAnnotationId];
|
|
3417
|
-
|
|
3418
|
-
F:
|
|
2242
|
+
invariant16(existingAnnotation, `Missing ${String(TypeAnnotationId)}`, {
|
|
2243
|
+
F: __dxlog_file16,
|
|
3419
2244
|
L: 77,
|
|
3420
2245
|
S: void 0,
|
|
3421
2246
|
A: [
|
|
@@ -3430,23 +2255,23 @@ var setTypenameInSchema = (schema, typename) => {
|
|
|
3430
2255
|
typename,
|
|
3431
2256
|
version: existingAnnotation.version
|
|
3432
2257
|
},
|
|
3433
|
-
[
|
|
3434
|
-
...schema.ast.annotations[
|
|
3435
|
-
$id: schema.ast.annotations[TypeIdentifierAnnotationId] ??
|
|
2258
|
+
[SchemaAST7.JSONSchemaAnnotationId]: {
|
|
2259
|
+
...schema.ast.annotations[SchemaAST7.JSONSchemaAnnotationId] ?? {},
|
|
2260
|
+
$id: schema.ast.annotations[TypeIdentifierAnnotationId] ?? DXN7.fromTypename(typename).toString(),
|
|
3436
2261
|
typename
|
|
3437
2262
|
}
|
|
3438
2263
|
});
|
|
3439
2264
|
};
|
|
3440
2265
|
|
|
3441
|
-
// src/internal/
|
|
3442
|
-
import * as
|
|
3443
|
-
var PersistentSchema =
|
|
3444
|
-
name:
|
|
2266
|
+
// src/internal/Type/persistent-schema.ts
|
|
2267
|
+
import * as Schema12 from "effect/Schema";
|
|
2268
|
+
var PersistentSchema = Schema12.Struct({
|
|
2269
|
+
name: Schema12.optional(Schema12.String),
|
|
3445
2270
|
typename: TypenameSchema,
|
|
3446
2271
|
version: VersionSchema,
|
|
3447
2272
|
jsonSchema: JsonSchemaType
|
|
3448
2273
|
}).pipe(EchoObjectSchema({
|
|
3449
|
-
typename: "dxos.
|
|
2274
|
+
typename: "org.dxos.type.schema",
|
|
3450
2275
|
version: "0.1.0"
|
|
3451
2276
|
}), LabelAnnotation.set([
|
|
3452
2277
|
"name"
|
|
@@ -3455,16 +2280,16 @@ var PersistentSchema = Schema15.Struct({
|
|
|
3455
2280
|
hue: "blue"
|
|
3456
2281
|
}));
|
|
3457
2282
|
|
|
3458
|
-
// src/internal/
|
|
3459
|
-
var
|
|
2283
|
+
// src/internal/Type/echo-schema.ts
|
|
2284
|
+
var __dxlog_file17 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Type/echo-schema.ts";
|
|
3460
2285
|
var ImmutableSchema = class {
|
|
3461
2286
|
_schema;
|
|
3462
2287
|
_objectAnnotation;
|
|
3463
2288
|
constructor(_schema) {
|
|
3464
2289
|
this._schema = _schema;
|
|
3465
2290
|
this._objectAnnotation = getTypeAnnotation(this._schema);
|
|
3466
|
-
|
|
3467
|
-
F:
|
|
2291
|
+
invariant17(this._objectAnnotation, void 0, {
|
|
2292
|
+
F: __dxlog_file17,
|
|
3468
2293
|
L: 49,
|
|
3469
2294
|
S: this,
|
|
3470
2295
|
A: [
|
|
@@ -3476,7 +2301,7 @@ var ImmutableSchema = class {
|
|
|
3476
2301
|
//
|
|
3477
2302
|
// Effect Schema (push to abstract base class).
|
|
3478
2303
|
//
|
|
3479
|
-
get [
|
|
2304
|
+
get [Schema13.TypeId]() {
|
|
3480
2305
|
return schemaVariance2;
|
|
3481
2306
|
}
|
|
3482
2307
|
get Type() {
|
|
@@ -3529,9 +2354,9 @@ var ImmutableSchema = class {
|
|
|
3529
2354
|
var EchoSchemaConstructor = () => {
|
|
3530
2355
|
return class {
|
|
3531
2356
|
static get _schema() {
|
|
3532
|
-
return
|
|
2357
|
+
return Schema13.Union(PersistentSchema, Schema13.instanceOf(EchoSchema)).annotations(PersistentSchema.ast.annotations);
|
|
3533
2358
|
}
|
|
3534
|
-
static [
|
|
2359
|
+
static [Schema13.TypeId] = schemaVariance2;
|
|
3535
2360
|
static get ast() {
|
|
3536
2361
|
const schema = this._schema;
|
|
3537
2362
|
return schema.ast;
|
|
@@ -3569,7 +2394,7 @@ var EchoSchema = class extends EchoSchemaConstructor() {
|
|
|
3569
2394
|
//
|
|
3570
2395
|
// Effect Schema (push to abstract base class).
|
|
3571
2396
|
//
|
|
3572
|
-
get [
|
|
2397
|
+
get [Schema13.TypeId]() {
|
|
3573
2398
|
return schemaVariance2;
|
|
3574
2399
|
}
|
|
3575
2400
|
get Type() {
|
|
@@ -3625,8 +2450,8 @@ var EchoSchema = class extends EchoSchemaConstructor() {
|
|
|
3625
2450
|
* Returns a mutable schema.
|
|
3626
2451
|
*/
|
|
3627
2452
|
get mutable() {
|
|
3628
|
-
|
|
3629
|
-
F:
|
|
2453
|
+
invariant17(!this.readonly, "Schema is not mutable", {
|
|
2454
|
+
F: __dxlog_file17,
|
|
3630
2455
|
L: 279,
|
|
3631
2456
|
S: this,
|
|
3632
2457
|
A: [
|
|
@@ -3666,8 +2491,8 @@ var EchoSchema = class extends EchoSchemaConstructor() {
|
|
|
3666
2491
|
}
|
|
3667
2492
|
getProperties() {
|
|
3668
2493
|
const ast = this._getSchema().ast;
|
|
3669
|
-
|
|
3670
|
-
F:
|
|
2494
|
+
invariant17(SchemaAST8.isTypeLiteral(ast), void 0, {
|
|
2495
|
+
F: __dxlog_file17,
|
|
3671
2496
|
L: 314,
|
|
3672
2497
|
S: this,
|
|
3673
2498
|
A: [
|
|
@@ -3768,12 +2593,12 @@ var EchoSchema = class extends EchoSchemaConstructor() {
|
|
|
3768
2593
|
}
|
|
3769
2594
|
};
|
|
3770
2595
|
var unwrapOptionality = (property) => {
|
|
3771
|
-
if (!
|
|
2596
|
+
if (!SchemaAST8.isUnion(property.type)) {
|
|
3772
2597
|
return property;
|
|
3773
2598
|
}
|
|
3774
2599
|
return {
|
|
3775
2600
|
...property,
|
|
3776
|
-
type: property.type.types.find((type) => !
|
|
2601
|
+
type: property.type.types.find((type) => !SchemaAST8.isUndefinedKeyword(type))
|
|
3777
2602
|
};
|
|
3778
2603
|
};
|
|
3779
2604
|
|
|
@@ -3786,75 +2611,28 @@ export {
|
|
|
3786
2611
|
foreignKey,
|
|
3787
2612
|
foreignKeyEquals,
|
|
3788
2613
|
compareForeignKeys,
|
|
3789
|
-
VersionTypeId,
|
|
3790
|
-
getLabel,
|
|
3791
|
-
setLabel,
|
|
3792
|
-
getDescription,
|
|
3793
|
-
setDescription,
|
|
3794
|
-
makeEchoTypeSchema,
|
|
3795
|
-
ATTR_RELATION_SOURCE,
|
|
3796
|
-
RelationSourceId,
|
|
3797
|
-
RelationSourceDXNId,
|
|
3798
|
-
ATTR_RELATION_TARGET,
|
|
3799
|
-
RelationTargetId,
|
|
3800
|
-
RelationTargetDXNId,
|
|
3801
|
-
EchoRelationSchema,
|
|
3802
2614
|
ATTR_SELF_DXN,
|
|
3803
2615
|
SelfDXNId,
|
|
3804
2616
|
ATTR_DELETED,
|
|
3805
2617
|
ObjectDeletedId,
|
|
3806
2618
|
ObjectVersionId,
|
|
3807
2619
|
ObjectDatabaseId,
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
2620
|
+
ATTR_RELATION_SOURCE,
|
|
2621
|
+
RelationSourceId,
|
|
2622
|
+
RelationSourceDXNId,
|
|
2623
|
+
ATTR_RELATION_TARGET,
|
|
2624
|
+
RelationTargetId,
|
|
2625
|
+
RelationTargetDXNId,
|
|
2626
|
+
VersionTypeId,
|
|
2627
|
+
compare,
|
|
2628
|
+
sortByLabel,
|
|
2629
|
+
sortByTypename,
|
|
2630
|
+
sort,
|
|
3813
2631
|
getMetaChecked,
|
|
3814
2632
|
getKeys,
|
|
3815
2633
|
deleteKeys,
|
|
3816
2634
|
addTag,
|
|
3817
2635
|
removeTag,
|
|
3818
|
-
compare,
|
|
3819
|
-
sortByLabel,
|
|
3820
|
-
sortByTypename,
|
|
3821
|
-
sort,
|
|
3822
|
-
isVersion,
|
|
3823
|
-
version,
|
|
3824
|
-
versionValid,
|
|
3825
|
-
compareVersions,
|
|
3826
|
-
encodeVersion,
|
|
3827
|
-
decodeVersion,
|
|
3828
|
-
CustomAnnotations,
|
|
3829
|
-
DecodedAnnotations,
|
|
3830
|
-
EchoAnnotations,
|
|
3831
|
-
JsonSchemaEchoAnnotations,
|
|
3832
|
-
JsonSchemaFields,
|
|
3833
|
-
JsonSchemaType,
|
|
3834
|
-
getSchemaProperty,
|
|
3835
|
-
setSchemaProperty,
|
|
3836
|
-
ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,
|
|
3837
|
-
ECHO_ANNOTATIONS_NS_KEY,
|
|
3838
|
-
getNormalizedEchoAnnotations,
|
|
3839
|
-
normalizeSchema,
|
|
3840
|
-
JSON_SCHEMA_ECHO_REF_ID,
|
|
3841
|
-
getSchemaReference,
|
|
3842
|
-
createSchemaReference,
|
|
3843
|
-
getReferenceAst,
|
|
3844
|
-
RefTypeId,
|
|
3845
|
-
Ref,
|
|
3846
|
-
createEchoReferenceSchema,
|
|
3847
|
-
RefImpl,
|
|
3848
|
-
setRefResolver,
|
|
3849
|
-
getRefSavedTarget,
|
|
3850
|
-
refFromEncodedReference,
|
|
3851
|
-
StaticRefResolver,
|
|
3852
|
-
RefArray,
|
|
3853
|
-
PropType,
|
|
3854
|
-
toPropType,
|
|
3855
|
-
toJsonSchema,
|
|
3856
|
-
toEffectSchema,
|
|
3857
|
-
makeTypedEntityClass,
|
|
3858
2636
|
EventId,
|
|
3859
2637
|
ChangeId,
|
|
3860
2638
|
batchEvents,
|
|
@@ -3892,6 +2670,21 @@ export {
|
|
|
3892
2670
|
makeObject,
|
|
3893
2671
|
subscribe,
|
|
3894
2672
|
change,
|
|
2673
|
+
assertObjectModel,
|
|
2674
|
+
getObjectDXN,
|
|
2675
|
+
getDXN,
|
|
2676
|
+
getDatabase,
|
|
2677
|
+
makeEchoTypeSchema,
|
|
2678
|
+
EchoObjectSchema,
|
|
2679
|
+
EchoRelationSchema,
|
|
2680
|
+
isVersion,
|
|
2681
|
+
version,
|
|
2682
|
+
versionValid,
|
|
2683
|
+
compareVersions,
|
|
2684
|
+
encodeVersion,
|
|
2685
|
+
decodeVersion,
|
|
2686
|
+
normalizeSchema,
|
|
2687
|
+
makeTypedEntityClass,
|
|
3895
2688
|
objectToJSON,
|
|
3896
2689
|
objectFromJSON,
|
|
3897
2690
|
setRefResolverOnData,
|
|
@@ -3911,9 +2704,9 @@ export {
|
|
|
3911
2704
|
ImmutableSchema,
|
|
3912
2705
|
isMutable,
|
|
3913
2706
|
EchoSchema,
|
|
3914
|
-
|
|
2707
|
+
JsonPath,
|
|
3915
2708
|
JsonProp,
|
|
3916
2709
|
getValue,
|
|
3917
2710
|
splitJsonPath
|
|
3918
2711
|
};
|
|
3919
|
-
//# sourceMappingURL=chunk-
|
|
2712
|
+
//# sourceMappingURL=chunk-TQQZLKB7.mjs.map
|