@dxos/echo 0.8.4-main.bc674ce → 0.8.4-main.bd9b33e6c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/lib/neutral/Annotation.mjs +8 -3
- package/dist/lib/neutral/Database.mjs +34 -6
- package/dist/lib/neutral/Entity.mjs +18 -10
- package/dist/lib/neutral/Err.mjs +3 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +45 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +17 -10
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Obj.mjs +35 -15
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +19 -9
- package/dist/lib/neutral/Ref.mjs +9 -7
- package/dist/lib/neutral/Relation.mjs +20 -11
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +13 -10
- package/dist/lib/neutral/Type.mjs +13 -23
- package/dist/lib/neutral/{chunk-HMOXCO27.mjs → chunk-35O3JYTV.mjs} +8 -3
- package/dist/lib/neutral/chunk-35O3JYTV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4BT7QVIT.mjs +34 -0
- package/dist/lib/neutral/chunk-4BT7QVIT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4O4AV6CL.mjs +787 -0
- package/dist/lib/neutral/chunk-4O4AV6CL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-62DWJ6CE.mjs → chunk-B5OXLWZL.mjs} +14 -14
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NWUO5FKZ.mjs → chunk-B7HTUIZA.mjs} +8 -2
- package/dist/lib/neutral/chunk-B7HTUIZA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-BNCCGLJN.mjs} +1 -1
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs.map → chunk-BNCCGLJN.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-3ZEAZF7T.mjs → chunk-EIX4KLES.mjs} +8 -4
- package/dist/lib/neutral/chunk-EIX4KLES.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FLSFS6UB.mjs +117 -0
- package/dist/lib/neutral/chunk-FLSFS6UB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VR4A4WGG.mjs → chunk-FXQ52LDX.mjs} +72 -23
- package/dist/lib/neutral/chunk-FXQ52LDX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4TT624YA.mjs → chunk-FZO7LQO7.mjs} +2 -2
- package/dist/lib/neutral/{chunk-4TT624YA.mjs.map → chunk-FZO7LQO7.mjs.map} +1 -1
- package/dist/lib/neutral/chunk-HIMJ3MXL.mjs +283 -0
- package/dist/lib/neutral/chunk-HIMJ3MXL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VB5HVDCA.mjs → chunk-HITCYIP2.mjs} +47 -5
- package/dist/lib/neutral/chunk-HITCYIP2.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SU2LVM7J.mjs → chunk-JJTRVYRD.mjs} +1596 -2730
- package/dist/lib/neutral/chunk-JJTRVYRD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6QPSGMEF.mjs → chunk-JX5K6AY3.mjs} +32 -8
- package/dist/lib/neutral/chunk-JX5K6AY3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-IP2GHXWA.mjs → chunk-PRQVBGFG.mjs} +5 -5
- package/dist/lib/neutral/chunk-PRQVBGFG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RUYH5REG.mjs +130 -0
- package/dist/lib/neutral/chunk-RUYH5REG.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-2MTHJ5UW.mjs → chunk-T74ABBRN.mjs} +134 -24
- package/dist/lib/neutral/chunk-T74ABBRN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-XMIDBDE6.mjs → chunk-TJRQTGXR.mjs} +11 -56
- package/dist/lib/neutral/chunk-TJRQTGXR.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RPB6V4BE.mjs → chunk-UBEZSGXY.mjs} +14 -1
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ROKO4RKJ.mjs → chunk-UI6MWK5W.mjs} +2 -2
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VF2IHN6I.mjs +396 -0
- package/dist/lib/neutral/chunk-VF2IHN6I.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YQYMWZAD.mjs → chunk-WYOKA6AE.mjs} +4 -4
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-CUDIBUM4.mjs → chunk-XEBKJROJ.mjs} +104 -25
- package/dist/lib/neutral/chunk-XEBKJROJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs +50 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZZEIMPNC.mjs +159 -0
- package/dist/lib/neutral/chunk-ZZEIMPNC.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +42 -25
- package/dist/lib/neutral/internal/index.mjs +52 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +42 -34
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +23 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +79 -84
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +19 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +41 -15
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +43 -0
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +163 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +13 -1
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +3 -3
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +8 -3
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/JsonSchema.d.ts +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +158 -43
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +101 -14
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +58 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +75 -28
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +4 -4
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +4 -3
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +51 -180
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +68 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +69 -8
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Annotation}/sorting.d.ts +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +13 -1
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api/entity.d.ts → Entity/api.d.ts} +2 -2
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/entity.d.ts +3 -3
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/model.d.ts +4 -26
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +2 -2
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/relation.d.ts +3 -30
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Entity}/version.d.ts +1 -1
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +19 -19
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +2 -2
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/deleted.d.ts +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +12 -5
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/typed-object.d.ts +4 -4
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +16 -3
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/compose.d.ts +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/echo-schema.d.ts +8 -7
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/persistent-schema.d.ts +2 -2
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/{api → common/api}/index.d.ts +0 -4
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +2 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/base.d.ts +1 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/entity.d.ts +2 -2
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/index.d.ts +1 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/meta.d.ts +2 -1
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +54 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/typename.d.ts +8 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +2 -2
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +8 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +19 -18
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/src/Annotation.ts +31 -1
- package/src/Collection.ts +37 -0
- package/src/Database.ts +154 -173
- package/src/Dataset.ts +26 -0
- package/src/Entity.ts +73 -54
- package/src/Err.ts +22 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +267 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +47 -4
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +9 -4
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +69 -8
- package/src/Obj.ts +285 -140
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +190 -15
- package/src/Query.ts +249 -23
- package/src/Ref.ts +64 -11
- package/src/Relation.test.ts +8 -2
- package/src/Relation.ts +165 -131
- package/src/SchemaRegistry.ts +5 -4
- package/src/Tag.ts +6 -5
- package/src/Type.test.ts +10 -10
- package/src/Type.ts +70 -303
- package/src/View.ts +107 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +5 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +56 -6
- package/src/internal/{annotations → Annotation}/annotations.ts +128 -10
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -3
- package/src/internal/{annotations → Annotation}/util.ts +14 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +4 -2
- package/src/internal/{entities → Entity}/entity.ts +6 -4
- package/src/internal/{entities → Entity}/index.ts +2 -0
- package/src/internal/{entities → Entity}/model.ts +17 -42
- package/src/internal/{entities → Entity}/object.ts +2 -2
- package/src/internal/{entities → Entity}/relation.ts +19 -36
- package/src/internal/{api → Entity}/version.ts +3 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -1
- package/src/internal/{formats → Format}/format.test.ts +1 -1
- package/src/internal/{formats → Format}/types.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +4 -4
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +48 -48
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +6 -4
- package/src/internal/{object → Obj}/clone.ts +3 -3
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +4 -4
- package/src/internal/{object → Obj}/create-object.ts +5 -5
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/inspect.ts +2 -2
- package/src/internal/{object → Obj}/json-serializer.test.ts +31 -8
- package/src/internal/{object → Obj}/json-serializer.ts +42 -15
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +24 -24
- package/src/internal/{object → Obj}/set-value.ts +2 -2
- package/src/internal/Obj/snapshot.ts +105 -0
- package/src/internal/{object → Obj}/typed-object.test.ts +3 -3
- package/src/internal/{object → Obj}/typed-object.ts +4 -4
- package/src/internal/{ref → Ref}/ref-array.ts +1 -1
- package/src/internal/{ref → Ref}/ref.test.ts +4 -4
- package/src/internal/{ref → Ref}/ref.ts +27 -4
- package/src/internal/{schema → Type}/compose.test.ts +5 -5
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/{schema → Type}/echo-schema.ts +11 -10
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +10 -4
- package/src/internal/{README.md → common/README.md} +1 -1
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change.test.ts +58 -58
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -2
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +6 -3
- package/src/internal/{proxy → common/proxy}/make-object.ts +13 -3
- package/src/internal/{proxy → common/proxy}/reactive.ts +1 -1
- package/src/internal/{proxy → common/proxy}/schema.test.ts +10 -10
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +6 -6
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +10 -3
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +4 -4
- package/src/internal/{types → common/types}/base.ts +1 -1
- package/src/internal/{types → common/types}/entity.ts +2 -2
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +4 -1
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/{types → common/types}/typename.ts +10 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +8 -31
- package/src/testing/api.test.ts +4 -4
- package/src/testing/test-schema.ts +20 -18
- package/dist/lib/neutral/chunk-2MTHJ5UW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3ZEAZF7T.mjs.map +0 -7
- package/dist/lib/neutral/chunk-62DWJ6CE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6QPSGMEF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CUDIBUM4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HMOXCO27.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IP2GHXWA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs +0 -132
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NWUO5FKZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SU2LVM7J.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VB5HVDCA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VR4A4WGG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs +0 -13
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs +0 -157
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XMIDBDE6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YQYMWZAD.mjs.map +0 -7
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/api/annotations.d.ts +0 -23
- package/dist/types/src/internal/api/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/api/entity.d.ts.map +0 -1
- package/dist/types/src/internal/api/index.d.ts.map +0 -1
- package/dist/types/src/internal/api/meta.d.ts.map +0 -1
- package/dist/types/src/internal/api/sorting.d.ts.map +0 -1
- package/dist/types/src/internal/api/version.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/clone.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +0 -2
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change-context.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/errors.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/ownership.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/symbols.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/src/internal/api/annotations.ts +0 -60
- package/src/internal/object/snapshot.ts +0 -70
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/index.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/select.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/string.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/clone.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/ids.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/index.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/set-value.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/snapshot.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/index.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -0
- /package/dist/types/src/internal/{api → common/api}/meta.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change-context.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/define-hidden-property.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/errors.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/event-batch.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/index.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/json-serializer.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/make-object.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/ownership.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-types.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-utils.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/reactive-array.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/symbols.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/src/internal/{entities → Entity}/util.ts +0 -0
- /package/src/internal/{formats → Format}/date.ts +0 -0
- /package/src/internal/{formats → Format}/format.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{formats → Format}/object.ts +0 -0
- /package/src/internal/{formats → Format}/select.ts +0 -0
- /package/src/internal/{formats → Format}/string.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +0 -0
- /package/src/internal/{object → Obj}/ids.ts +0 -0
- /package/src/internal/{object → Obj}/index.ts +0 -0
- /package/src/internal/{object → Obj}/schema-validator.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
- /package/src/internal/{schema → Type}/index.ts +0 -0
- /package/src/internal/{api → common/api}/meta.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/change-context.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/define-hidden-property.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/errors.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/event-batch.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/ownership.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/reactive-array.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
|
@@ -0,0 +1,787 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CurrencyAnnotationId,
|
|
3
|
+
FormatAnnotation,
|
|
4
|
+
FormatAnnotationId,
|
|
5
|
+
TypeFormat
|
|
6
|
+
} from "./chunk-B5OXLWZL.mjs";
|
|
7
|
+
import {
|
|
8
|
+
createEchoReferenceSchema
|
|
9
|
+
} from "./chunk-VF2IHN6I.mjs";
|
|
10
|
+
import {
|
|
11
|
+
GeneratorAnnotationId,
|
|
12
|
+
LabelAnnotationId,
|
|
13
|
+
PropertyMetaAnnotationId,
|
|
14
|
+
TypeAnnotationId,
|
|
15
|
+
TypeIdentifierAnnotationId
|
|
16
|
+
} from "./chunk-XEBKJROJ.mjs";
|
|
17
|
+
import {
|
|
18
|
+
ANY_OBJECT_TYPENAME,
|
|
19
|
+
ANY_OBJECT_VERSION,
|
|
20
|
+
EntityKind,
|
|
21
|
+
EntityKindSchema,
|
|
22
|
+
makeTypeJsonSchemaAnnotation
|
|
23
|
+
} from "./chunk-WYOKA6AE.mjs";
|
|
24
|
+
|
|
25
|
+
// src/internal/JsonSchema/annotations.ts
|
|
26
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
27
|
+
var CustomAnnotations = {
|
|
28
|
+
format: FormatAnnotationId,
|
|
29
|
+
currency: CurrencyAnnotationId
|
|
30
|
+
};
|
|
31
|
+
var DecodedAnnotations = {
|
|
32
|
+
title: SchemaAST.TitleAnnotationId,
|
|
33
|
+
description: SchemaAST.DescriptionAnnotationId
|
|
34
|
+
};
|
|
35
|
+
var EchoAnnotations = {
|
|
36
|
+
// TODO(dmaretskyi): `FieldLookupAnnotationId` might go here, but lets remove it entirely and use LabelAnnotation instead.
|
|
37
|
+
meta: PropertyMetaAnnotationId,
|
|
38
|
+
generator: GeneratorAnnotationId,
|
|
39
|
+
labelProp: LabelAnnotationId
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/internal/JsonSchema/json-schema-type.ts
|
|
43
|
+
import * as Schema from "effect/Schema";
|
|
44
|
+
import { JsonPath } from "@dxos/effect";
|
|
45
|
+
var SimpleTypes = Schema.Literal("array", "boolean", "integer", "null", "number", "object", "string");
|
|
46
|
+
var NonNegativeInteger = Schema.Number.pipe(Schema.greaterThanOrEqualTo(0));
|
|
47
|
+
var StringArray = Schema.Array(Schema.String);
|
|
48
|
+
var JsonSchemaOrBoolean = Schema.Union(Schema.suspend(() => JsonSchemaType), Schema.Boolean);
|
|
49
|
+
var JsonSchemaEchoAnnotations = Schema.Struct({
|
|
50
|
+
/**
|
|
51
|
+
* Label for this schema.
|
|
52
|
+
* Mapped from {@link LabelAnnotationId}.
|
|
53
|
+
*/
|
|
54
|
+
labelProp: Schema.optional(Schema.Union(JsonPath, Schema.Array(JsonPath))),
|
|
55
|
+
/**
|
|
56
|
+
* Generator function for this schema.
|
|
57
|
+
* Mapped from {@link GeneratorAnnotationId}.
|
|
58
|
+
*/
|
|
59
|
+
generator: Schema.optional(Schema.Union(Schema.String, Schema.Tuple(Schema.String, Schema.Number))),
|
|
60
|
+
/**
|
|
61
|
+
* {@link PropertyMeta} annotations get serialized here.
|
|
62
|
+
*/
|
|
63
|
+
meta: Schema.optional(Schema.Record({
|
|
64
|
+
key: Schema.String,
|
|
65
|
+
value: Schema.Any
|
|
66
|
+
})),
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated
|
|
69
|
+
*/
|
|
70
|
+
// TODO(dmaretskyi): We risk old schema not passing validation due to the extra fields. Remove when we are sure this is safe.
|
|
71
|
+
type: Schema.optional(Schema.Struct({
|
|
72
|
+
typename: Schema.String,
|
|
73
|
+
version: Schema.String,
|
|
74
|
+
// Not used.
|
|
75
|
+
schemaId: Schema.optional(Schema.String)
|
|
76
|
+
})),
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated Superseded by `meta`.
|
|
79
|
+
*/
|
|
80
|
+
annotations: Schema.optional(Schema.Record({
|
|
81
|
+
key: Schema.String,
|
|
82
|
+
value: Schema.Any
|
|
83
|
+
}))
|
|
84
|
+
});
|
|
85
|
+
var _JsonSchemaType = Schema.Struct({
|
|
86
|
+
/**
|
|
87
|
+
* Identifier for this schema.
|
|
88
|
+
* This schema might be referenced by $ref clause in other schemas.
|
|
89
|
+
*/
|
|
90
|
+
// TODO(dmaretskyi): Specify how the ids are generated.
|
|
91
|
+
// TODO(dmaretskyi): For type dxns, should this include the version?
|
|
92
|
+
$id: Schema.optional(Schema.String),
|
|
93
|
+
/**
|
|
94
|
+
* Schema of this schema.
|
|
95
|
+
* Set to "https://json-schema.org/draft-07/schema".
|
|
96
|
+
*/
|
|
97
|
+
$schema: Schema.optional(Schema.String),
|
|
98
|
+
/**
|
|
99
|
+
* Reference to another schema.
|
|
100
|
+
*/
|
|
101
|
+
$ref: Schema.optional(Schema.String),
|
|
102
|
+
/**
|
|
103
|
+
* Comments are ignored when interpreting the schema.
|
|
104
|
+
*/
|
|
105
|
+
$comment: Schema.optional(Schema.String),
|
|
106
|
+
/**
|
|
107
|
+
* Defines whether this schema is an object schema or a relation schema.
|
|
108
|
+
*/
|
|
109
|
+
entityKind: Schema.optional(EntityKindSchema),
|
|
110
|
+
/**
|
|
111
|
+
* Typename of this schema.
|
|
112
|
+
* Only on schema representing an ECHO object.
|
|
113
|
+
*
|
|
114
|
+
* @example 'com.example.type.my-type'
|
|
115
|
+
*/
|
|
116
|
+
typename: Schema.optional(Schema.String),
|
|
117
|
+
/**
|
|
118
|
+
* Version of this schema.
|
|
119
|
+
* Custom dialect for ECHO.
|
|
120
|
+
*/
|
|
121
|
+
version: Schema.optional(Schema.String),
|
|
122
|
+
/**
|
|
123
|
+
* Target of this relation.
|
|
124
|
+
* Only for relation schemas.
|
|
125
|
+
* The referenced schema must be an object schema.
|
|
126
|
+
*/
|
|
127
|
+
relationTarget: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
128
|
+
/**
|
|
129
|
+
* Source of this relation.
|
|
130
|
+
* Only for relation schemas.
|
|
131
|
+
* The referenced schema must be an object schema.
|
|
132
|
+
*/
|
|
133
|
+
relationSource: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
134
|
+
/**
|
|
135
|
+
* Title of this schema.
|
|
136
|
+
*/
|
|
137
|
+
title: Schema.optional(Schema.String),
|
|
138
|
+
/**
|
|
139
|
+
* Description of this schema.
|
|
140
|
+
*/
|
|
141
|
+
description: Schema.optional(Schema.String),
|
|
142
|
+
/**
|
|
143
|
+
* Whether this schema is read-only.
|
|
144
|
+
*/
|
|
145
|
+
readOnly: Schema.optional(Schema.Boolean),
|
|
146
|
+
/**
|
|
147
|
+
* Whether this schema is write-only.
|
|
148
|
+
*/
|
|
149
|
+
writeOnly: Schema.optional(Schema.Boolean),
|
|
150
|
+
/**
|
|
151
|
+
* Examples of instances of this schema.
|
|
152
|
+
*/
|
|
153
|
+
examples: Schema.optional(Schema.Array(Schema.Any)),
|
|
154
|
+
/**
|
|
155
|
+
* Default value for this schema.
|
|
156
|
+
*/
|
|
157
|
+
default: Schema.optional(Schema.Any),
|
|
158
|
+
/**
|
|
159
|
+
* This schema only matches values that are equal to this value.
|
|
160
|
+
*/
|
|
161
|
+
const: Schema.optional(Schema.Any),
|
|
162
|
+
/**
|
|
163
|
+
* This schema only matches one of the values in this array.
|
|
164
|
+
*/
|
|
165
|
+
enum: Schema.optional(Schema.Array(Schema.Any)),
|
|
166
|
+
/**
|
|
167
|
+
* Base type of the schema.
|
|
168
|
+
*/
|
|
169
|
+
type: Schema.optional(Schema.Union(SimpleTypes, Schema.Array(SimpleTypes))),
|
|
170
|
+
//
|
|
171
|
+
// Numbers.
|
|
172
|
+
//
|
|
173
|
+
multipleOf: Schema.optional(Schema.Number.pipe(Schema.greaterThan(0))),
|
|
174
|
+
maximum: Schema.optional(Schema.Number),
|
|
175
|
+
exclusiveMaximum: Schema.optional(Schema.Number),
|
|
176
|
+
minimum: Schema.optional(Schema.Number),
|
|
177
|
+
exclusiveMinimum: Schema.optional(Schema.Number),
|
|
178
|
+
//
|
|
179
|
+
// Strings.
|
|
180
|
+
//
|
|
181
|
+
maxLength: Schema.optional(NonNegativeInteger),
|
|
182
|
+
/**
|
|
183
|
+
* Regex pattern for strings.
|
|
184
|
+
*/
|
|
185
|
+
pattern: Schema.optional(Schema.String.pipe(FormatAnnotation.set(TypeFormat.Regex))),
|
|
186
|
+
/**
|
|
187
|
+
* Serialized from {@link FormatAnnotationId}.
|
|
188
|
+
*/
|
|
189
|
+
format: Schema.optional(Schema.String),
|
|
190
|
+
//
|
|
191
|
+
// Arrays
|
|
192
|
+
//
|
|
193
|
+
minLength: Schema.optional(NonNegativeInteger),
|
|
194
|
+
items: Schema.optional(Schema.Union(Schema.suspend(() => JsonSchemaType), Schema.Array(Schema.suspend(() => JsonSchemaType)))),
|
|
195
|
+
additionalItems: Schema.optional(Schema.Union(Schema.suspend(() => JsonSchemaType), Schema.Boolean)),
|
|
196
|
+
maxItems: Schema.optional(NonNegativeInteger),
|
|
197
|
+
minItems: Schema.optional(NonNegativeInteger),
|
|
198
|
+
uniqueItems: Schema.optional(Schema.Boolean),
|
|
199
|
+
contains: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
200
|
+
//
|
|
201
|
+
// Objects
|
|
202
|
+
//
|
|
203
|
+
maxProperties: Schema.optional(NonNegativeInteger),
|
|
204
|
+
minProperties: Schema.optional(NonNegativeInteger),
|
|
205
|
+
required: Schema.optional(StringArray),
|
|
206
|
+
/**
|
|
207
|
+
* Non-standard JSON Schema extension.
|
|
208
|
+
* Defines the order of properties in the object.
|
|
209
|
+
* The unmentioned properties are placed at the end.
|
|
210
|
+
*
|
|
211
|
+
* Related: https://github.com/json-schema/json-schema/issues/119
|
|
212
|
+
*/
|
|
213
|
+
propertyOrder: Schema.optional(StringArray),
|
|
214
|
+
additionalProperties: Schema.optional(JsonSchemaOrBoolean),
|
|
215
|
+
properties: Schema.optional(Schema.Record({
|
|
216
|
+
key: Schema.String,
|
|
217
|
+
value: Schema.suspend(() => JsonSchemaType)
|
|
218
|
+
})),
|
|
219
|
+
patternProperties: Schema.optional(Schema.Record({
|
|
220
|
+
key: Schema.String,
|
|
221
|
+
value: Schema.suspend(() => JsonSchemaType)
|
|
222
|
+
})),
|
|
223
|
+
propertyNames: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
224
|
+
definitions: Schema.optional(Schema.Record({
|
|
225
|
+
key: Schema.String,
|
|
226
|
+
value: Schema.suspend(() => JsonSchemaType)
|
|
227
|
+
})),
|
|
228
|
+
dependencies: Schema.optional(Schema.Record({
|
|
229
|
+
key: Schema.String,
|
|
230
|
+
value: Schema.suspend(() => Schema.Union(Schema.String, StringArray, JsonSchemaType)).annotations({
|
|
231
|
+
identifier: "dependency",
|
|
232
|
+
description: "Dependency"
|
|
233
|
+
})
|
|
234
|
+
})),
|
|
235
|
+
contentMediaType: Schema.optional(Schema.String),
|
|
236
|
+
contentEncoding: Schema.optional(Schema.String),
|
|
237
|
+
if: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
238
|
+
then: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
239
|
+
else: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
240
|
+
allOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),
|
|
241
|
+
anyOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),
|
|
242
|
+
oneOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),
|
|
243
|
+
not: Schema.optional(Schema.suspend(() => JsonSchemaType)),
|
|
244
|
+
$defs: Schema.optional(Schema.Record({
|
|
245
|
+
key: Schema.String,
|
|
246
|
+
value: Schema.suspend(() => JsonSchemaType)
|
|
247
|
+
})),
|
|
248
|
+
//
|
|
249
|
+
// ECHO extensions.
|
|
250
|
+
//
|
|
251
|
+
currency: Schema.optional(Schema.String),
|
|
252
|
+
reference: Schema.optional(Schema.Struct({
|
|
253
|
+
schema: Schema.suspend(() => JsonSchemaType),
|
|
254
|
+
schemaVersion: Schema.optional(Schema.String),
|
|
255
|
+
schemaObject: Schema.optional(Schema.String)
|
|
256
|
+
})),
|
|
257
|
+
/**
|
|
258
|
+
* ECHO-specific annotations.
|
|
259
|
+
*/
|
|
260
|
+
// TODO(dmaretskyi): Since we are adding a lot of new extensions to the JSON Schema, it is safer to namespace them here.
|
|
261
|
+
annotations: Schema.optional(JsonSchemaEchoAnnotations),
|
|
262
|
+
/**
|
|
263
|
+
* @deprecated Use `annotations` instead.
|
|
264
|
+
*/
|
|
265
|
+
echo: Schema.optional(JsonSchemaEchoAnnotations)
|
|
266
|
+
}).annotations({
|
|
267
|
+
identifier: "jsonSchema",
|
|
268
|
+
description: "JSON Schema"
|
|
269
|
+
});
|
|
270
|
+
var JsonSchemaFields = Object.keys(_JsonSchemaType.fields);
|
|
271
|
+
var JsonSchemaType = _JsonSchemaType;
|
|
272
|
+
var getSchemaProperty = (schema, property) => {
|
|
273
|
+
return schema.properties?.[property];
|
|
274
|
+
};
|
|
275
|
+
var setSchemaProperty = (schema, property, value) => {
|
|
276
|
+
schema.properties ??= {};
|
|
277
|
+
schema.properties[property] = value;
|
|
278
|
+
return schema;
|
|
279
|
+
};
|
|
280
|
+
var ECHO_ANNOTATIONS_NS_DEPRECATED_KEY = "echo";
|
|
281
|
+
var ECHO_ANNOTATIONS_NS_KEY = "annotations";
|
|
282
|
+
var getNormalizedEchoAnnotations = (obj) => {
|
|
283
|
+
if (obj[ECHO_ANNOTATIONS_NS_KEY] != null && obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {
|
|
284
|
+
return normalizeEchoAnnotations({
|
|
285
|
+
...obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY],
|
|
286
|
+
...obj[ECHO_ANNOTATIONS_NS_KEY]
|
|
287
|
+
});
|
|
288
|
+
} else if (obj[ECHO_ANNOTATIONS_NS_KEY] != null) {
|
|
289
|
+
return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_KEY]);
|
|
290
|
+
} else if (obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {
|
|
291
|
+
return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY]);
|
|
292
|
+
} else {
|
|
293
|
+
return void 0;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
var normalizeEchoAnnotations = (obj) => {
|
|
297
|
+
if (!obj.annotations) {
|
|
298
|
+
return obj;
|
|
299
|
+
} else {
|
|
300
|
+
const res = {
|
|
301
|
+
...obj,
|
|
302
|
+
meta: {
|
|
303
|
+
...obj.annotations,
|
|
304
|
+
...obj.meta ?? {}
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
delete res.annotations;
|
|
308
|
+
return res;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// src/internal/JsonSchema/json-schema.ts
|
|
313
|
+
import * as Array2 from "effect/Array";
|
|
314
|
+
import * as Function from "effect/Function";
|
|
315
|
+
import * as JSONSchema from "effect/JSONSchema";
|
|
316
|
+
import * as Option from "effect/Option";
|
|
317
|
+
import * as Schema2 from "effect/Schema";
|
|
318
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
319
|
+
import { raise } from "@dxos/debug";
|
|
320
|
+
import { mapAst } from "@dxos/effect";
|
|
321
|
+
import { assertArgument, invariant } from "@dxos/invariant";
|
|
322
|
+
import { DXN, ObjectId } from "@dxos/keys";
|
|
323
|
+
import { log } from "@dxos/log";
|
|
324
|
+
import { clearUndefined, orderKeys, removeProperties } from "@dxos/util";
|
|
325
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/JsonSchema/json-schema.ts";
|
|
326
|
+
var PropType = /* @__PURE__ */ (function(PropType2) {
|
|
327
|
+
PropType2[PropType2["NONE"] = 0] = "NONE";
|
|
328
|
+
PropType2[PropType2["STRING"] = 1] = "STRING";
|
|
329
|
+
PropType2[PropType2["NUMBER"] = 2] = "NUMBER";
|
|
330
|
+
PropType2[PropType2["BOOLEAN"] = 3] = "BOOLEAN";
|
|
331
|
+
PropType2[PropType2["DATE"] = 4] = "DATE";
|
|
332
|
+
PropType2[PropType2["REF"] = 5] = "REF";
|
|
333
|
+
PropType2[PropType2["RECORD"] = 6] = "RECORD";
|
|
334
|
+
PropType2[PropType2["ENUM"] = 7] = "ENUM";
|
|
335
|
+
return PropType2;
|
|
336
|
+
})({});
|
|
337
|
+
var toPropType = (type) => {
|
|
338
|
+
switch (type) {
|
|
339
|
+
case 1:
|
|
340
|
+
return "string";
|
|
341
|
+
case 2:
|
|
342
|
+
return "number";
|
|
343
|
+
case 3:
|
|
344
|
+
return "boolean";
|
|
345
|
+
case 4:
|
|
346
|
+
return "date";
|
|
347
|
+
case 5:
|
|
348
|
+
return "ref";
|
|
349
|
+
case 6:
|
|
350
|
+
return "object";
|
|
351
|
+
default:
|
|
352
|
+
throw new Error(`Invalid type: ${type}`);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
var JSON_SCHEMA_URL = "http://json-schema.org/draft-07/schema#";
|
|
356
|
+
var toJsonSchema = (schema, options = {}) => {
|
|
357
|
+
assertArgument(Schema2.isSchema(schema), "schema");
|
|
358
|
+
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
359
|
+
if (options.strict) {
|
|
360
|
+
jsonSchema = removeProperties(jsonSchema, (key, value) => {
|
|
361
|
+
if (key === "$id" && value === "/schemas/any") {
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
if (key === "$ref" && value === "#/$defs/dependency") {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
if (key === "$ref" && value === "#/$defs/jsonSchema") {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return jsonSchema;
|
|
374
|
+
};
|
|
375
|
+
var _toJsonSchemaAST = (ast) => {
|
|
376
|
+
const withRefinements = withEchoRefinements(ast, "#");
|
|
377
|
+
const jsonSchema = JSONSchema.fromAST(withRefinements, {
|
|
378
|
+
definitions: {}
|
|
379
|
+
});
|
|
380
|
+
return normalizeJsonSchema(jsonSchema);
|
|
381
|
+
};
|
|
382
|
+
var withEchoRefinements = (ast, path, suspendCache = /* @__PURE__ */ new Map()) => {
|
|
383
|
+
if (path) {
|
|
384
|
+
suspendCache.set(ast, path);
|
|
385
|
+
}
|
|
386
|
+
let recursiveResult;
|
|
387
|
+
if (SchemaAST2.isSuspend(ast)) {
|
|
388
|
+
const suspendedAst = ast.f();
|
|
389
|
+
const cachedPath = suspendCache.get(suspendedAst);
|
|
390
|
+
if (cachedPath) {
|
|
391
|
+
recursiveResult = new SchemaAST2.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {
|
|
392
|
+
[SchemaAST2.JSONSchemaAnnotationId]: {
|
|
393
|
+
$ref: cachedPath
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
} else {
|
|
397
|
+
const jsonSchema = _toJsonSchemaAST(suspendedAst);
|
|
398
|
+
recursiveResult = new SchemaAST2.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {
|
|
399
|
+
[SchemaAST2.JSONSchemaAnnotationId]: jsonSchema
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
} else if (SchemaAST2.isTypeLiteral(ast)) {
|
|
403
|
+
recursiveResult = mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && typeof key === "string" ? `${path}/${key}` : void 0, suspendCache));
|
|
404
|
+
recursiveResult = addJsonSchemaFields(recursiveResult, {
|
|
405
|
+
propertyOrder: [
|
|
406
|
+
...ast.propertySignatures.map((p) => p.name)
|
|
407
|
+
]
|
|
408
|
+
});
|
|
409
|
+
} else if (SchemaAST2.isUndefinedKeyword(ast)) {
|
|
410
|
+
return ast;
|
|
411
|
+
} else {
|
|
412
|
+
recursiveResult = mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && (typeof key === "string" || typeof key === "number") ? `${path}/${key}` : void 0, suspendCache));
|
|
413
|
+
}
|
|
414
|
+
const annotationFields = annotations_toJsonSchemaFields(ast.annotations);
|
|
415
|
+
if (Object.keys(annotationFields).length === 0) {
|
|
416
|
+
return recursiveResult;
|
|
417
|
+
} else {
|
|
418
|
+
return addJsonSchemaFields(recursiveResult, annotationFields);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
var toEffectSchema = (root, _defs) => {
|
|
422
|
+
const defs = root.$defs ? {
|
|
423
|
+
..._defs,
|
|
424
|
+
...root.$defs
|
|
425
|
+
} : _defs ?? {};
|
|
426
|
+
if ("type" in root && root.type === "object") {
|
|
427
|
+
return objectToEffectSchema(root, defs);
|
|
428
|
+
}
|
|
429
|
+
let result = Schema2.Unknown;
|
|
430
|
+
if ("$ref" in root) {
|
|
431
|
+
switch (root.$ref) {
|
|
432
|
+
case "/schemas/echo/ref": {
|
|
433
|
+
result = refToEffectSchema(root);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
} else if ("$id" in root) {
|
|
438
|
+
switch (root.$id) {
|
|
439
|
+
case "/schemas/any": {
|
|
440
|
+
result = anyToEffectSchema(root);
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
case "/schemas/unknown": {
|
|
444
|
+
result = Schema2.Unknown;
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
case "/schemas/{}":
|
|
448
|
+
case "/schemas/object": {
|
|
449
|
+
result = Schema2.Object;
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
// Custom ECHO object reference.
|
|
453
|
+
case "/schemas/echo/ref": {
|
|
454
|
+
result = refToEffectSchema(root);
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
} else if ("enum" in root) {
|
|
459
|
+
result = Schema2.Union(...root.enum.map((e) => Schema2.Literal(e)));
|
|
460
|
+
} else if ("oneOf" in root) {
|
|
461
|
+
result = Schema2.Union(...root.oneOf.map((v) => toEffectSchema(v, defs)));
|
|
462
|
+
} else if ("anyOf" in root) {
|
|
463
|
+
result = Schema2.Union(...root.anyOf.map((v) => toEffectSchema(v, defs)));
|
|
464
|
+
} else if ("allOf" in root) {
|
|
465
|
+
if (root.allOf.length === 1) {
|
|
466
|
+
result = toEffectSchema(root.allOf[0], defs);
|
|
467
|
+
} else {
|
|
468
|
+
log.warn("allOf with multiple schemas is not supported", void 0, {
|
|
469
|
+
F: __dxlog_file,
|
|
470
|
+
L: 224,
|
|
471
|
+
S: void 0,
|
|
472
|
+
C: (f, a) => f(...a)
|
|
473
|
+
});
|
|
474
|
+
result = Schema2.Unknown;
|
|
475
|
+
}
|
|
476
|
+
} else if ("type" in root) {
|
|
477
|
+
switch (root.type) {
|
|
478
|
+
case "string": {
|
|
479
|
+
result = Schema2.String;
|
|
480
|
+
if (root.pattern) {
|
|
481
|
+
result = result.pipe(Schema2.pattern(new RegExp(root.pattern)));
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
case "number": {
|
|
486
|
+
result = Schema2.Number;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
case "integer": {
|
|
490
|
+
result = Schema2.Number.pipe(Schema2.int());
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
case "boolean": {
|
|
494
|
+
result = Schema2.Boolean;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
case "array": {
|
|
498
|
+
if (Array2.isArray(root.items)) {
|
|
499
|
+
const [required, optional3] = Function.pipe(root.items, Array2.map((v) => toEffectSchema(v, defs)), Array2.splitAt(root.minItems ?? root.items.length));
|
|
500
|
+
result = Schema2.Tuple(...required, ...optional3.map(Schema2.optionalElement));
|
|
501
|
+
} else {
|
|
502
|
+
invariant(root.items, void 0, {
|
|
503
|
+
F: __dxlog_file,
|
|
504
|
+
L: 257,
|
|
505
|
+
S: void 0,
|
|
506
|
+
A: [
|
|
507
|
+
"root.items",
|
|
508
|
+
""
|
|
509
|
+
]
|
|
510
|
+
});
|
|
511
|
+
const items = root.items;
|
|
512
|
+
result = Array2.isArray(items) ? Schema2.Tuple(...items.map((v) => toEffectSchema(v, defs))) : Schema2.Array(toEffectSchema(items, defs));
|
|
513
|
+
}
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
case "null": {
|
|
517
|
+
result = Schema2.Null;
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
} else if ("$ref" in root) {
|
|
522
|
+
const refSegments = root.$ref.split("/");
|
|
523
|
+
const jsonSchema = defs[refSegments[refSegments.length - 1]];
|
|
524
|
+
invariant(jsonSchema, `missing definition for ${root.$ref}`, {
|
|
525
|
+
F: __dxlog_file,
|
|
526
|
+
L: 273,
|
|
527
|
+
S: void 0,
|
|
528
|
+
A: [
|
|
529
|
+
"jsonSchema",
|
|
530
|
+
"`missing definition for ${root.$ref}`"
|
|
531
|
+
]
|
|
532
|
+
});
|
|
533
|
+
result = toEffectSchema(jsonSchema, defs).pipe(Schema2.annotations({
|
|
534
|
+
identifier: refSegments[refSegments.length - 1]
|
|
535
|
+
}));
|
|
536
|
+
}
|
|
537
|
+
const annotations2 = jsonSchemaFieldsToAnnotations(root);
|
|
538
|
+
result = result.annotations(annotations2);
|
|
539
|
+
return result;
|
|
540
|
+
};
|
|
541
|
+
var objectToEffectSchema = (root, defs) => {
|
|
542
|
+
invariant("type" in root && root.type === "object", `not an object: ${root}`, {
|
|
543
|
+
F: __dxlog_file,
|
|
544
|
+
L: 288,
|
|
545
|
+
S: void 0,
|
|
546
|
+
A: [
|
|
547
|
+
"'type' in root && root.type === 'object'",
|
|
548
|
+
"`not an object: ${root}`"
|
|
549
|
+
]
|
|
550
|
+
});
|
|
551
|
+
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
552
|
+
const isEchoObject = echoRefinement != null || "$id" in root && typeof root.$id === "string" && root.$id.startsWith("dxn:");
|
|
553
|
+
let fields = {};
|
|
554
|
+
const propertyList = Object.entries(root.properties ?? {});
|
|
555
|
+
let immutableIdField;
|
|
556
|
+
for (const [key, value] of propertyList) {
|
|
557
|
+
if (isEchoObject && key === "id") {
|
|
558
|
+
immutableIdField = toEffectSchema(value, defs);
|
|
559
|
+
} else {
|
|
560
|
+
fields[key] = root.required?.includes(key) ? toEffectSchema(value, defs) : Schema2.optional(toEffectSchema(value, defs));
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (root.propertyOrder) {
|
|
564
|
+
fields = orderKeys(fields, root.propertyOrder);
|
|
565
|
+
}
|
|
566
|
+
let schema;
|
|
567
|
+
if (root.patternProperties) {
|
|
568
|
+
invariant(propertyList.length === 0, "pattern properties mixed with regular properties are not supported", {
|
|
569
|
+
F: __dxlog_file,
|
|
570
|
+
L: 314,
|
|
571
|
+
S: void 0,
|
|
572
|
+
A: [
|
|
573
|
+
"propertyList.length === 0",
|
|
574
|
+
"'pattern properties mixed with regular properties are not supported'"
|
|
575
|
+
]
|
|
576
|
+
});
|
|
577
|
+
invariant(Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === "", "only one pattern property is supported", {
|
|
578
|
+
F: __dxlog_file,
|
|
579
|
+
L: 315,
|
|
580
|
+
S: void 0,
|
|
581
|
+
A: [
|
|
582
|
+
"Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === ''",
|
|
583
|
+
"'only one pattern property is supported'"
|
|
584
|
+
]
|
|
585
|
+
});
|
|
586
|
+
schema = Schema2.Record({
|
|
587
|
+
key: Schema2.String,
|
|
588
|
+
value: toEffectSchema(root.patternProperties[""], defs)
|
|
589
|
+
});
|
|
590
|
+
} else if (typeof root.additionalProperties !== "object") {
|
|
591
|
+
schema = Schema2.Struct(fields);
|
|
592
|
+
} else {
|
|
593
|
+
const indexValue = toEffectSchema(root.additionalProperties, defs);
|
|
594
|
+
if (propertyList.length > 0) {
|
|
595
|
+
schema = Schema2.Struct(fields, {
|
|
596
|
+
key: Schema2.String,
|
|
597
|
+
value: indexValue
|
|
598
|
+
});
|
|
599
|
+
} else {
|
|
600
|
+
schema = Schema2.Record({
|
|
601
|
+
key: Schema2.String,
|
|
602
|
+
value: indexValue
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (immutableIdField) {
|
|
607
|
+
schema = Schema2.extend(schema, Schema2.Struct({
|
|
608
|
+
id: immutableIdField
|
|
609
|
+
}));
|
|
610
|
+
}
|
|
611
|
+
const annotations2 = jsonSchemaFieldsToAnnotations(root);
|
|
612
|
+
return schema.annotations(annotations2);
|
|
613
|
+
};
|
|
614
|
+
var anyToEffectSchema = (root) => {
|
|
615
|
+
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
616
|
+
if (echoRefinement?.reference != null) {
|
|
617
|
+
const echoId = root.$id.startsWith("dxn:echo:") ? root.$id : void 0;
|
|
618
|
+
return createEchoReferenceSchema(echoId, echoRefinement.reference.typename, echoRefinement.reference.version);
|
|
619
|
+
}
|
|
620
|
+
return Schema2.Any;
|
|
621
|
+
};
|
|
622
|
+
var refToEffectSchema = (root) => {
|
|
623
|
+
if (!("reference" in root)) {
|
|
624
|
+
return createEchoReferenceSchema(void 0, ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION);
|
|
625
|
+
}
|
|
626
|
+
const reference = root.reference;
|
|
627
|
+
if (typeof reference !== "object") {
|
|
628
|
+
throw new Error("Invalid reference field in ref schema");
|
|
629
|
+
}
|
|
630
|
+
const targetSchemaDXN = DXN.parse(reference.schema.$ref);
|
|
631
|
+
invariant(targetSchemaDXN.kind === DXN.kind.TYPE, void 0, {
|
|
632
|
+
F: __dxlog_file,
|
|
633
|
+
L: 368,
|
|
634
|
+
S: void 0,
|
|
635
|
+
A: [
|
|
636
|
+
"targetSchemaDXN.kind === DXN.kind.TYPE",
|
|
637
|
+
""
|
|
638
|
+
]
|
|
639
|
+
});
|
|
640
|
+
return createEchoReferenceSchema(targetSchemaDXN.toString(), targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : void 0, reference.schemaVersion);
|
|
641
|
+
};
|
|
642
|
+
var annotations_toJsonSchemaFields = (annotations2) => {
|
|
643
|
+
const schemaFields = {};
|
|
644
|
+
const echoAnnotations = {};
|
|
645
|
+
for (const [key, annotationId] of Object.entries(EchoAnnotations)) {
|
|
646
|
+
if (annotations2[annotationId] != null) {
|
|
647
|
+
echoAnnotations[key] = annotations2[annotationId];
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (Object.keys(echoAnnotations).length > 0) {
|
|
651
|
+
schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
|
|
652
|
+
}
|
|
653
|
+
const echoIdentifier = annotations2[TypeIdentifierAnnotationId];
|
|
654
|
+
if (echoIdentifier) {
|
|
655
|
+
schemaFields[ECHO_ANNOTATIONS_NS_KEY] ??= {};
|
|
656
|
+
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
657
|
+
}
|
|
658
|
+
for (const [key, annotationId] of Object.entries(CustomAnnotations)) {
|
|
659
|
+
const value = annotations2[annotationId];
|
|
660
|
+
if (value != null) {
|
|
661
|
+
schemaFields[key] = value;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return schemaFields;
|
|
665
|
+
};
|
|
666
|
+
var decodeTypeIdentifierAnnotation = (schema) => {
|
|
667
|
+
if (schema.$id && schema.$id.startsWith("dxn:echo:")) {
|
|
668
|
+
return schema.$id;
|
|
669
|
+
} else if (schema.$id && schema.$id.startsWith("dxn:type:") && schema?.echo?.type?.schemaId) {
|
|
670
|
+
const id = schema?.echo?.type?.schemaId;
|
|
671
|
+
if (ObjectId.isValid(id)) {
|
|
672
|
+
return DXN.fromLocalObjectId(id).toString();
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return void 0;
|
|
676
|
+
};
|
|
677
|
+
var decodeTypeAnnotation = (schema) => {
|
|
678
|
+
if (schema.typename) {
|
|
679
|
+
const annotation = {
|
|
680
|
+
// TODO(dmaretskyi): Decoding default.
|
|
681
|
+
kind: schema.entityKind ? Schema2.decodeSync(EntityKindSchema)(schema.entityKind) : EntityKind.Object,
|
|
682
|
+
typename: schema.typename,
|
|
683
|
+
version: schema.version ?? "0.1.0"
|
|
684
|
+
};
|
|
685
|
+
if (annotation.kind === EntityKind.Relation) {
|
|
686
|
+
const source = schema.relationSource?.$ref ?? raise(new Error("Relation source not set"));
|
|
687
|
+
const target = schema.relationTarget?.$ref ?? raise(new Error("Relation target not set"));
|
|
688
|
+
annotation.sourceSchema = DXN.parse(source).toString();
|
|
689
|
+
annotation.targetSchema = DXN.parse(target).toString();
|
|
690
|
+
}
|
|
691
|
+
return annotation;
|
|
692
|
+
}
|
|
693
|
+
if (!schema.typename && schema?.echo?.type) {
|
|
694
|
+
return {
|
|
695
|
+
kind: EntityKind.Object,
|
|
696
|
+
typename: schema.echo.type.typename,
|
|
697
|
+
version: schema.echo.type.version
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
return void 0;
|
|
701
|
+
};
|
|
702
|
+
var jsonSchemaFieldsToAnnotations = (schema) => {
|
|
703
|
+
const annotations2 = {};
|
|
704
|
+
const echoAnnotations = getNormalizedEchoAnnotations(schema) ?? {};
|
|
705
|
+
if (echoAnnotations) {
|
|
706
|
+
for (const [key, annotationId] of Object.entries(EchoAnnotations)) {
|
|
707
|
+
if (echoAnnotations[key]) {
|
|
708
|
+
annotations2[annotationId] = echoAnnotations[key];
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
const typeIdentifier = decodeTypeIdentifierAnnotation(schema);
|
|
713
|
+
annotations2[TypeIdentifierAnnotationId] = typeIdentifier;
|
|
714
|
+
const typeAnnotation = decodeTypeAnnotation(schema);
|
|
715
|
+
if (typeAnnotation) {
|
|
716
|
+
annotations2[TypeAnnotationId] = typeAnnotation;
|
|
717
|
+
annotations2[SchemaAST2.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
718
|
+
identifier: typeIdentifier,
|
|
719
|
+
kind: typeAnnotation.kind,
|
|
720
|
+
typename: typeAnnotation.typename,
|
|
721
|
+
version: typeAnnotation.version,
|
|
722
|
+
relationSource: typeAnnotation.sourceSchema,
|
|
723
|
+
relationTarget: typeAnnotation.targetSchema
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
for (const [key, annotationId] of Object.entries({
|
|
727
|
+
...CustomAnnotations,
|
|
728
|
+
...DecodedAnnotations
|
|
729
|
+
})) {
|
|
730
|
+
if (key in schema) {
|
|
731
|
+
annotations2[annotationId] = schema[key];
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
return clearUndefined(annotations2);
|
|
735
|
+
};
|
|
736
|
+
var makeAnnotatedRefinement = (ast, annotations2) => {
|
|
737
|
+
return new SchemaAST2.Refinement(ast, () => Option.none(), annotations2);
|
|
738
|
+
};
|
|
739
|
+
var addJsonSchemaFields = (ast, schema) => makeAnnotatedRefinement(ast, {
|
|
740
|
+
[SchemaAST2.JSONSchemaAnnotationId]: schema
|
|
741
|
+
});
|
|
742
|
+
var normalizeJsonSchema = (jsonSchema) => {
|
|
743
|
+
if (jsonSchema.properties && "id" in jsonSchema.properties) {
|
|
744
|
+
jsonSchema.properties = orderKeys(jsonSchema.properties, [
|
|
745
|
+
"id"
|
|
746
|
+
]);
|
|
747
|
+
}
|
|
748
|
+
jsonSchema.$schema = JSON_SCHEMA_URL;
|
|
749
|
+
jsonSchema = orderKeys(jsonSchema, [
|
|
750
|
+
"$schema",
|
|
751
|
+
"$id",
|
|
752
|
+
"entityKind",
|
|
753
|
+
"typename",
|
|
754
|
+
"version",
|
|
755
|
+
"relationTarget",
|
|
756
|
+
"relationSource",
|
|
757
|
+
"type",
|
|
758
|
+
"enum",
|
|
759
|
+
"properties",
|
|
760
|
+
"required",
|
|
761
|
+
"propertyOrder",
|
|
762
|
+
"items",
|
|
763
|
+
"additionalProperties",
|
|
764
|
+
"anyOf",
|
|
765
|
+
"oneOf"
|
|
766
|
+
]);
|
|
767
|
+
return jsonSchema;
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
export {
|
|
771
|
+
CustomAnnotations,
|
|
772
|
+
DecodedAnnotations,
|
|
773
|
+
EchoAnnotations,
|
|
774
|
+
JsonSchemaEchoAnnotations,
|
|
775
|
+
JsonSchemaFields,
|
|
776
|
+
JsonSchemaType,
|
|
777
|
+
getSchemaProperty,
|
|
778
|
+
setSchemaProperty,
|
|
779
|
+
ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,
|
|
780
|
+
ECHO_ANNOTATIONS_NS_KEY,
|
|
781
|
+
getNormalizedEchoAnnotations,
|
|
782
|
+
PropType,
|
|
783
|
+
toPropType,
|
|
784
|
+
toJsonSchema,
|
|
785
|
+
toEffectSchema
|
|
786
|
+
};
|
|
787
|
+
//# sourceMappingURL=chunk-4O4AV6CL.mjs.map
|