@dxos/echo 0.8.4-staging.ac66bdf99f → 0.9.0
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/LICENSE +102 -5
- package/README.md +7 -7
- package/dist/lib/neutral/Annotation.mjs +37 -6
- package/dist/lib/neutral/Database.mjs +6 -17
- package/dist/lib/neutral/Entity.mjs +31 -20
- package/dist/lib/neutral/Err.mjs +3 -3
- package/dist/lib/neutral/Feed.mjs +23 -19
- package/dist/lib/neutral/Filter.mjs +13 -15
- package/dist/lib/neutral/Format.mjs +23 -3
- package/dist/lib/neutral/JsonSchema.mjs +7 -8
- package/dist/lib/neutral/Key.mjs +9 -5
- package/dist/lib/neutral/Migration.mjs +11 -10
- package/dist/lib/neutral/Obj.mjs +29 -20
- package/dist/lib/neutral/Order.mjs +7 -3
- package/dist/lib/neutral/Query.mjs +17 -17
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +10 -9
- package/dist/lib/neutral/Registry.mjs +14 -0
- package/dist/lib/neutral/Relation.mjs +28 -25
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Tag.mjs +17 -14
- package/dist/lib/neutral/Type.mjs +54 -26
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-35INCYOE.mjs} +1 -1
- package/dist/lib/neutral/chunk-35INCYOE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs +101 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +184 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs +108 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OS35K56T.mjs → chunk-5SUJPHAE.mjs} +3 -3
- package/dist/lib/neutral/{chunk-OS35K56T.mjs.map → chunk-5SUJPHAE.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-GZQTCRJB.mjs → chunk-6M2Z6WBH.mjs} +22 -2
- package/dist/lib/neutral/chunk-6M2Z6WBH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-V36VO5SS.mjs → chunk-6YDI3J37.mjs} +32 -40
- package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MOR5ERFM.mjs → chunk-7FPIAJIV.mjs} +701 -1256
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7LOUAPYZ.mjs} +9 -5
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-JUXPFOEI.mjs → chunk-7PI7C4EF.mjs} +48 -88
- package/dist/lib/neutral/chunk-7PI7C4EF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UBEZSGXY.mjs → chunk-BBFJWWAV.mjs} +6 -6
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UI6MWK5W.mjs → chunk-EVK6XBXO.mjs} +16 -2
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7RO7CPBZ.mjs → chunk-IGK6FN65.mjs} +2 -2
- package/dist/lib/neutral/{chunk-HBUZJNZO.mjs → chunk-LWXVKPPW.mjs} +94 -99
- package/dist/lib/neutral/chunk-LWXVKPPW.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BVOFLCVF.mjs → chunk-MZ7K3MLL.mjs} +9 -6
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TBKX6JQO.mjs → chunk-O6BH7EPN.mjs} +30 -3
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-EAMSSLZC.mjs → chunk-QQIYS74I.mjs} +83 -46
- package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs +678 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WAK4DMFV.mjs → chunk-RIVWNMSF.mjs} +12 -7
- package/dist/lib/neutral/chunk-RIVWNMSF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-T6W2LEZU.mjs → chunk-SBVFRTST.mjs} +73 -38
- package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs +251 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DQYLD2RB.mjs → chunk-TFEWTY5A.mjs} +155 -129
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B4BASU6W.mjs → chunk-TYGKCRMK.mjs} +85 -76
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4OIBYSXE.mjs → chunk-UUP46KUQ.mjs} +78 -32
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs +36 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-G3IQMKF7.mjs → chunk-WTQJHC75.mjs} +111 -112
- package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs +31 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TU3GW67D.mjs → chunk-ZGNNFYHS.mjs} +40 -40
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +47 -41
- package/dist/lib/neutral/internal/index.mjs +137 -72
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +261 -178
- package/dist/lib/neutral/testing/index.mjs.map +4 -4
- package/dist/types/src/Annotation.d.ts +108 -4
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Annotation.test.d.ts +2 -0
- package/dist/types/src/Annotation.test.d.ts.map +1 -0
- package/dist/types/src/Collection.d.ts +2 -3
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +56 -49
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +16 -6
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +101 -28
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +27 -27
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +66 -19
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +38 -12
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Format.d.ts +0 -2
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +14 -9
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +2 -2
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Key.d.ts +1 -1
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +26 -11
- package/dist/types/src/Migration.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +104 -61
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts +10 -0
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +34 -12
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +21 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +15 -7
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Registry.d.ts +131 -0
- package/dist/types/src/Registry.d.ts.map +1 -0
- package/dist/types/src/Relation.d.ts +73 -41
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Scope.d.ts +35 -0
- package/dist/types/src/Scope.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +21 -5
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +362 -95
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +9 -12
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +79 -38
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
- package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -2
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/util.d.ts +14 -5
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts +17 -3
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/entity.d.ts +72 -8
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/guard.d.ts +10 -0
- package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +21 -17
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/object.d.ts +3 -3
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/relation.d.ts +30 -7
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -1
- package/dist/types/src/internal/Format/date.d.ts.map +1 -1
- package/dist/types/src/internal/Format/format.d.ts +3 -2
- package/dist/types/src/internal/Format/format.d.ts.map +1 -1
- package/dist/types/src/internal/Format/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -1
- package/dist/types/src/internal/Format/number.d.ts.map +1 -1
- package/dist/types/src/internal/Format/object.d.ts +3 -1
- package/dist/types/src/internal/Format/object.d.ts.map +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +34 -34
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts +3 -2
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/atoms.d.ts +38 -0
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/create-object.d.ts +12 -12
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/index.d.ts +1 -1
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts +8 -8
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
- package/dist/types/src/internal/Query/index.d.ts +2 -0
- package/dist/types/src/internal/Query/index.d.ts.map +1 -0
- package/dist/types/src/internal/{Query.d.ts → Query/pretty.d.ts} +1 -1
- package/dist/types/src/internal/Query/pretty.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/atoms.d.ts +10 -0
- package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
- package/dist/types/src/internal/Ref/ref.d.ts +50 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/utils.d.ts +8 -0
- package/dist/types/src/internal/Ref/utils.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -1
- package/dist/types/src/internal/Type/index.d.ts +1 -2
- package/dist/types/src/internal/Type/index.d.ts.map +1 -1
- package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
- package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts +14 -11
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/base.d.ts +4 -4
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/entity.d.ts +62 -5
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/index.d.ts +1 -1
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +33 -12
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/model-symbols.d.ts +15 -4
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/typename.d.ts +7 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/version.d.ts +1 -1
- package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
- package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +2 -2
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/registry.d.ts +9 -0
- package/dist/types/src/testing/registry.d.ts.map +1 -0
- package/dist/types/src/testing/test-data.d.ts +8 -8
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +83 -89
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +5 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -24
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +158 -4
- package/src/Collection.ts +5 -9
- package/src/Database.ts +93 -100
- package/src/Dataset.ts +10 -2
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +134 -32
- package/src/Err.ts +4 -4
- package/src/Feed.ts +92 -44
- package/src/Filter.ts +70 -40
- package/src/Format.ts +0 -4
- package/src/Hypergraph.ts +14 -9
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/Key.ts +1 -1
- package/src/Migration.ts +39 -19
- package/src/Obj.test.ts +122 -20
- package/src/Obj.ts +168 -91
- package/src/Order.ts +22 -0
- package/src/Query.test.ts +183 -154
- package/src/Query.ts +172 -85
- package/src/QueryResult.ts +26 -0
- package/src/Ref.ts +22 -4
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +10 -10
- package/src/Relation.ts +116 -69
- package/src/Scope.ts +50 -0
- package/src/Tag.md +88 -0
- package/src/Tag.ts +49 -6
- package/src/Type.test.ts +223 -18
- package/src/Type.ts +609 -131
- package/src/View.ts +14 -23
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +4 -4
- package/src/internal/Annotation/annotations.test.ts +31 -11
- package/src/internal/Annotation/annotations.ts +143 -111
- package/src/internal/Annotation/dictionary.ts +47 -0
- package/src/internal/Annotation/entity-dictionary.ts +74 -0
- package/src/internal/Annotation/index.ts +4 -2
- package/src/internal/Annotation/util.ts +17 -8
- package/src/internal/Entity/api.ts +54 -7
- package/src/internal/Entity/entity.ts +196 -47
- package/src/internal/Entity/guard.ts +26 -0
- package/src/internal/Entity/index.ts +2 -0
- package/src/internal/Entity/model.ts +38 -28
- package/src/internal/Entity/object.ts +21 -5
- package/src/internal/Entity/relation.ts +68 -34
- package/src/internal/Entity/type-kind.ts +75 -0
- package/src/internal/Entity/type-uri.ts +92 -0
- package/src/internal/Entity/util.ts +9 -9
- package/src/internal/Format/date.ts +0 -4
- package/src/internal/Format/format.test.ts +21 -0
- package/src/internal/Format/index.ts +2 -3
- package/src/internal/Format/object.ts +21 -4
- package/src/internal/Format/types.ts +1 -1
- package/src/internal/JsonSchema/annotations.ts +1 -1
- package/src/internal/JsonSchema/json-schema-type.ts +4 -4
- package/src/internal/JsonSchema/json-schema.test.ts +71 -145
- package/src/internal/JsonSchema/json-schema.ts +49 -35
- package/src/internal/Obj/atoms.ts +244 -0
- package/src/internal/Obj/clone.ts +9 -4
- package/src/internal/Obj/create-object.test.ts +12 -10
- package/src/internal/Obj/create-object.ts +68 -22
- package/src/internal/Obj/index.ts +1 -1
- package/src/internal/Obj/inspect.ts +5 -3
- package/src/internal/Obj/json-serializer.test.ts +101 -22
- package/src/internal/Obj/json-serializer.ts +89 -33
- package/src/internal/Obj/set-value.test.ts +22 -45
- package/src/internal/Obj/set-value.ts +12 -19
- package/src/internal/Obj/snapshot.ts +13 -4
- package/src/internal/Obj/typed-object.test.ts +9 -11
- package/src/internal/Obj/typed-object.ts +1 -1
- package/src/internal/Query/index.ts +5 -0
- package/src/internal/{Query.ts → Query/pretty.ts} +40 -12
- package/src/internal/Ref/atoms.ts +20 -0
- package/src/internal/Ref/ref-array.ts +3 -3
- package/src/internal/Ref/ref.test.ts +18 -27
- package/src/internal/Ref/ref.ts +137 -59
- package/src/internal/Ref/utils.ts +45 -0
- package/src/internal/Type/compose.test.ts +3 -1
- package/src/internal/Type/index.ts +1 -2
- package/src/internal/Type/manipulation.ts +0 -25
- package/src/internal/Type/type-schema.ts +60 -0
- package/src/internal/common/README.md +2 -2
- package/src/internal/common/api/meta.ts +19 -17
- package/src/internal/common/proxy/change-context.ts +1 -1
- package/src/internal/common/proxy/change.test.ts +91 -83
- package/src/internal/common/proxy/errors.ts +2 -2
- package/src/internal/common/proxy/handler.test.ts +1 -1
- package/src/internal/common/proxy/json-serializer.ts +27 -16
- package/src/internal/common/proxy/make-object.ts +44 -20
- package/src/internal/common/proxy/ownership.ts +2 -2
- package/src/internal/common/proxy/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/common/proxy/reactive.ts +11 -2
- package/src/internal/common/proxy/schema.test.ts +48 -86
- package/src/internal/common/proxy/typed-handler.test.ts +12 -11
- package/src/internal/common/proxy/typed-handler.ts +78 -16
- package/src/internal/common/proxy/typed-object.test.ts +16 -28
- package/src/internal/common/types/base.ts +4 -4
- package/src/internal/common/types/entity.ts +80 -1
- package/src/internal/common/types/index.ts +6 -1
- package/src/internal/common/types/meta.ts +62 -20
- package/src/internal/common/types/model-symbols.ts +24 -4
- package/src/internal/common/types/typename.ts +39 -3
- package/src/internal/common/types/well-known-types.ts +15 -0
- package/src/internal/index.ts +6 -4
- package/src/testing/api.test.ts +15 -9
- package/src/testing/index.ts +1 -0
- package/src/testing/registry.ts +44 -0
- package/src/testing/test-data.ts +159 -99
- package/src/testing/test-schema.ts +22 -58
- package/src/testing/util.ts +14 -11
- package/dist/lib/neutral/Extension.mjs +0 -18
- package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
- package/dist/lib/neutral/chunk-2KHZ36F5.mjs +0 -361
- package/dist/lib/neutral/chunk-2KHZ36F5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4OIBYSXE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs +0 -45
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-B4BASU6W.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BVOFLCVF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DQYLD2RB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EAMSSLZC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-G3IQMKF7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-GZQTCRJB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HBUZJNZO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-JUXPFOEI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MOR5ERFM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PHU22NLC.mjs +0 -136
- package/dist/lib/neutral/chunk-PHU22NLC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs +0 -97
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-T6W2LEZU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TBKX6JQO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TU3GW67D.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +0 -7
- package/dist/lib/neutral/chunk-V36VO5SS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WAK4DMFV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YAHXAYOW.mjs +0 -56
- package/dist/lib/neutral/chunk-YAHXAYOW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs +0 -50
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs.map +0 -7
- package/dist/types/src/Extension.d.ts +0 -80
- package/dist/types/src/Extension.d.ts.map +0 -1
- package/dist/types/src/Extension.test.d.ts +0 -2
- package/dist/types/src/Extension.test.d.ts.map +0 -1
- package/dist/types/src/SchemaRegistry.d.ts +0 -84
- package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
- package/dist/types/src/internal/Obj/ids.d.ts +0 -6
- package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
- package/dist/types/src/internal/Query.d.ts.map +0 -1
- package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
- package/src/Extension.test.ts +0 -235
- package/src/Extension.ts +0 -122
- package/src/SchemaRegistry.ts +0 -106
- package/src/internal/Obj/ids.ts +0 -12
- package/src/internal/Type/echo-schema.ts +0 -423
- package/src/internal/Type/persistent-schema.ts +0 -33
- /package/dist/lib/neutral/{Extension.mjs.map → Registry.mjs.map} +0 -0
- /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Scope.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-7RO7CPBZ.mjs.map → chunk-IGK6FN65.mjs.map} +0 -0
|
@@ -3,24 +3,25 @@ import {
|
|
|
3
3
|
FormatAnnotation,
|
|
4
4
|
FormatAnnotationId,
|
|
5
5
|
TypeFormat
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TFEWTY5A.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createEchoReferenceSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WTQJHC75.mjs";
|
|
10
10
|
import {
|
|
11
11
|
GeneratorAnnotationId,
|
|
12
12
|
LabelAnnotationId,
|
|
13
13
|
PropertyMetaAnnotationId,
|
|
14
14
|
TypeAnnotationId,
|
|
15
15
|
TypeIdentifierAnnotationId
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-R5W6DXR4.mjs";
|
|
17
17
|
import {
|
|
18
18
|
ANY_OBJECT_TYPENAME,
|
|
19
19
|
ANY_OBJECT_VERSION,
|
|
20
20
|
EntityKind,
|
|
21
21
|
EntityKindSchema,
|
|
22
|
+
getStaticTypeSchema,
|
|
22
23
|
makeTypeJsonSchemaAnnotation
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-O6BH7EPN.mjs";
|
|
24
25
|
|
|
25
26
|
// src/internal/JsonSchema/annotations.ts
|
|
26
27
|
import * as SchemaAST from "effect/SchemaAST";
|
|
@@ -41,7 +42,7 @@ var EchoAnnotations = {
|
|
|
41
42
|
|
|
42
43
|
// src/internal/JsonSchema/json-schema-type.ts
|
|
43
44
|
import * as Schema from "effect/Schema";
|
|
44
|
-
import {
|
|
45
|
+
import { SchemaEx } from "@dxos/effect";
|
|
45
46
|
var SimpleTypes = Schema.Literal("array", "boolean", "integer", "null", "number", "object", "string");
|
|
46
47
|
var NonNegativeInteger = Schema.Number.pipe(Schema.greaterThanOrEqualTo(0));
|
|
47
48
|
var StringArray = Schema.Array(Schema.String);
|
|
@@ -51,7 +52,7 @@ var JsonSchemaEchoAnnotations = Schema.Struct({
|
|
|
51
52
|
* Label for this schema.
|
|
52
53
|
* Mapped from {@link LabelAnnotationId}.
|
|
53
54
|
*/
|
|
54
|
-
labelProp: Schema.optional(Schema.Union(JsonPath, Schema.Array(JsonPath))),
|
|
55
|
+
labelProp: Schema.optional(Schema.Union(SchemaEx.JsonPath, Schema.Array(SchemaEx.JsonPath))),
|
|
55
56
|
/**
|
|
56
57
|
* Generator function for this schema.
|
|
57
58
|
* Mapped from {@link GeneratorAnnotationId}.
|
|
@@ -317,9 +318,9 @@ import * as Option from "effect/Option";
|
|
|
317
318
|
import * as Schema2 from "effect/Schema";
|
|
318
319
|
import * as SchemaAST2 from "effect/SchemaAST";
|
|
319
320
|
import { raise } from "@dxos/debug";
|
|
320
|
-
import {
|
|
321
|
+
import { SchemaEx as SchemaEx2 } from "@dxos/effect";
|
|
321
322
|
import { assertArgument, invariant } from "@dxos/invariant";
|
|
322
|
-
import { DXN,
|
|
323
|
+
import { DXN, EID, EntityId } from "@dxos/keys";
|
|
323
324
|
import { log } from "@dxos/log";
|
|
324
325
|
import { clearUndefined, orderKeys, removeProperties } from "@dxos/util";
|
|
325
326
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/JsonSchema/json-schema.ts";
|
|
@@ -354,6 +355,15 @@ var toPropType = (type) => {
|
|
|
354
355
|
};
|
|
355
356
|
var JSON_SCHEMA_URL = "http://json-schema.org/draft-07/schema#";
|
|
356
357
|
var toJsonSchema = (schema, options = {}) => {
|
|
358
|
+
const slot = getStaticTypeSchema(schema);
|
|
359
|
+
if (slot != null) {
|
|
360
|
+
schema = slot;
|
|
361
|
+
} else if (!Schema2.isSchema(schema)) {
|
|
362
|
+
const entityJsonSchema = schema.jsonSchema;
|
|
363
|
+
if (entityJsonSchema != null) {
|
|
364
|
+
return entityJsonSchema;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
357
367
|
assertArgument(Schema2.isSchema(schema), "schema");
|
|
358
368
|
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
359
369
|
if (options.strict) {
|
|
@@ -400,7 +410,7 @@ var withEchoRefinements = (ast, path, suspendCache = /* @__PURE__ */ new Map())
|
|
|
400
410
|
});
|
|
401
411
|
}
|
|
402
412
|
} else if (SchemaAST2.isTypeLiteral(ast)) {
|
|
403
|
-
recursiveResult = mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && typeof key === "string" ? `${path}/${key}` : void 0, suspendCache));
|
|
413
|
+
recursiveResult = SchemaEx2.mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && typeof key === "string" ? `${path}/${key}` : void 0, suspendCache));
|
|
404
414
|
recursiveResult = addJsonSchemaFields(recursiveResult, {
|
|
405
415
|
propertyOrder: [
|
|
406
416
|
...ast.propertySignatures.map((p) => p.name)
|
|
@@ -409,7 +419,7 @@ var withEchoRefinements = (ast, path, suspendCache = /* @__PURE__ */ new Map())
|
|
|
409
419
|
} else if (SchemaAST2.isUndefinedKeyword(ast)) {
|
|
410
420
|
return ast;
|
|
411
421
|
} else {
|
|
412
|
-
recursiveResult = mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && (typeof key === "string" || typeof key === "number") ? `${path}/${key}` : void 0, suspendCache));
|
|
422
|
+
recursiveResult = SchemaEx2.mapAst(ast, (ast2, key) => withEchoRefinements(ast2, path && (typeof key === "string" || typeof key === "number") ? `${path}/${key}` : void 0, suspendCache));
|
|
413
423
|
}
|
|
414
424
|
const annotationFields = annotations_toJsonSchemaFields(ast.annotations);
|
|
415
425
|
if (Object.keys(annotationFields).length === 0) {
|
|
@@ -435,7 +445,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
435
445
|
}
|
|
436
446
|
}
|
|
437
447
|
} else if ("$id" in root) {
|
|
438
|
-
switch (root.$id) {
|
|
448
|
+
switch (decodeURIComponent(root.$id)) {
|
|
439
449
|
case "/schemas/any": {
|
|
440
450
|
result = anyToEffectSchema(root);
|
|
441
451
|
break;
|
|
@@ -446,7 +456,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
446
456
|
}
|
|
447
457
|
case "/schemas/{}":
|
|
448
458
|
case "/schemas/object": {
|
|
449
|
-
result = Schema2.
|
|
459
|
+
result = Schema2.Struct({});
|
|
450
460
|
break;
|
|
451
461
|
}
|
|
452
462
|
// Custom ECHO object reference.
|
|
@@ -465,12 +475,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
465
475
|
if (root.allOf.length === 1) {
|
|
466
476
|
result = toEffectSchema(root.allOf[0], defs);
|
|
467
477
|
} else {
|
|
468
|
-
log.warn("allOf with multiple schemas is not supported", void 0, {
|
|
469
|
-
F: __dxlog_file,
|
|
470
|
-
L: 223,
|
|
471
|
-
S: void 0,
|
|
472
|
-
C: (f, a) => f(...a)
|
|
473
|
-
});
|
|
478
|
+
log.warn("allOf with multiple schemas is not supported", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 197, S: void 0 });
|
|
474
479
|
result = Schema2.Unknown;
|
|
475
480
|
}
|
|
476
481
|
} else if ("type" in root) {
|
|
@@ -499,15 +504,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
499
504
|
const [required, optional3] = Function.pipe(root.items, Array2.map((v) => toEffectSchema(v, defs)), Array2.splitAt(root.minItems ?? root.items.length));
|
|
500
505
|
result = Schema2.Tuple(...required, ...optional3.map(Schema2.optionalElement));
|
|
501
506
|
} else {
|
|
502
|
-
invariant(root.items, void 0, {
|
|
503
|
-
F: __dxlog_file,
|
|
504
|
-
L: 256,
|
|
505
|
-
S: void 0,
|
|
506
|
-
A: [
|
|
507
|
-
"root.items",
|
|
508
|
-
""
|
|
509
|
-
]
|
|
510
|
-
});
|
|
507
|
+
invariant(root.items, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 231, S: void 0, A: ["root.items", ""] });
|
|
511
508
|
const items = root.items;
|
|
512
509
|
result = Array2.isArray(items) ? Schema2.Tuple(...items.map((v) => toEffectSchema(v, defs))) : Schema2.Array(toEffectSchema(items, defs));
|
|
513
510
|
}
|
|
@@ -521,15 +518,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
521
518
|
} else if ("$ref" in root) {
|
|
522
519
|
const refSegments = root.$ref.split("/");
|
|
523
520
|
const jsonSchema = defs[refSegments[refSegments.length - 1]];
|
|
524
|
-
invariant(jsonSchema, `missing definition for ${root.$ref}`, {
|
|
525
|
-
F: __dxlog_file,
|
|
526
|
-
L: 272,
|
|
527
|
-
S: void 0,
|
|
528
|
-
A: [
|
|
529
|
-
"jsonSchema",
|
|
530
|
-
"`missing definition for ${root.$ref}`"
|
|
531
|
-
]
|
|
532
|
-
});
|
|
521
|
+
invariant(jsonSchema, `missing definition for ${root.$ref}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 246, S: void 0, A: ["jsonSchema", "`missing definition for ${root.$ref}`"] });
|
|
533
522
|
result = toEffectSchema(jsonSchema, defs).pipe(Schema2.annotations({
|
|
534
523
|
identifier: refSegments[refSegments.length - 1]
|
|
535
524
|
}));
|
|
@@ -539,15 +528,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
539
528
|
return result;
|
|
540
529
|
};
|
|
541
530
|
var objectToEffectSchema = (root, defs) => {
|
|
542
|
-
invariant("type" in root && root.type === "object", `not an object: ${root}`, {
|
|
543
|
-
F: __dxlog_file,
|
|
544
|
-
L: 287,
|
|
545
|
-
S: void 0,
|
|
546
|
-
A: [
|
|
547
|
-
"'type' in root && root.type === 'object'",
|
|
548
|
-
"`not an object: ${root}`"
|
|
549
|
-
]
|
|
550
|
-
});
|
|
531
|
+
invariant("type" in root && root.type === "object", `not an object: ${root}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 257, S: void 0, A: ["'type' in root && root.type === 'object'", "`not an object: ${root}`"] });
|
|
551
532
|
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
552
533
|
const isEchoObject = echoRefinement != null || "$id" in root && typeof root.$id === "string" && root.$id.startsWith("dxn:");
|
|
553
534
|
let fields = {};
|
|
@@ -565,24 +546,8 @@ var objectToEffectSchema = (root, defs) => {
|
|
|
565
546
|
}
|
|
566
547
|
let schema;
|
|
567
548
|
if (root.patternProperties) {
|
|
568
|
-
invariant(propertyList.length === 0, "pattern properties mixed with regular properties are not supported", {
|
|
569
|
-
|
|
570
|
-
L: 313,
|
|
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: 314,
|
|
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
|
-
});
|
|
549
|
+
invariant(propertyList.length === 0, "pattern properties mixed with regular properties are not supported", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 276, S: void 0, A: ["propertyList.length === 0", "'pattern properties mixed with regular properties are not supported'"] });
|
|
550
|
+
invariant(Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === "", "only one pattern property is supported", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 277, S: void 0, A: ["Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === ''", "'only one pattern property is supported'"] });
|
|
586
551
|
schema = Schema2.Record({
|
|
587
552
|
key: Schema2.String,
|
|
588
553
|
value: toEffectSchema(root.patternProperties[""], defs)
|
|
@@ -614,8 +579,8 @@ var objectToEffectSchema = (root, defs) => {
|
|
|
614
579
|
var anyToEffectSchema = (root) => {
|
|
615
580
|
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
616
581
|
if (echoRefinement?.reference != null) {
|
|
617
|
-
const
|
|
618
|
-
return createEchoReferenceSchema(
|
|
582
|
+
const echoUri = root.$id.startsWith("echo:") ? root.$id : void 0;
|
|
583
|
+
return createEchoReferenceSchema(echoUri, echoRefinement.reference.typename, echoRefinement.reference.version);
|
|
619
584
|
}
|
|
620
585
|
return Schema2.Any;
|
|
621
586
|
};
|
|
@@ -627,17 +592,10 @@ var refToEffectSchema = (root) => {
|
|
|
627
592
|
if (typeof reference !== "object") {
|
|
628
593
|
throw new Error("Invalid reference field in ref schema");
|
|
629
594
|
}
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
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);
|
|
595
|
+
const ref = reference.schema.$ref;
|
|
596
|
+
const targetSchemaDXN = DXN.tryMake(ref);
|
|
597
|
+
invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 327, S: void 0, A: ["targetSchemaDXN", "`Expected a type DXN, got: ${ref}`"] });
|
|
598
|
+
return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
|
|
641
599
|
};
|
|
642
600
|
var annotations_toJsonSchemaFields = (annotations2) => {
|
|
643
601
|
const schemaFields = {};
|
|
@@ -652,8 +610,7 @@ var annotations_toJsonSchemaFields = (annotations2) => {
|
|
|
652
610
|
}
|
|
653
611
|
const echoIdentifier = annotations2[TypeIdentifierAnnotationId];
|
|
654
612
|
if (echoIdentifier) {
|
|
655
|
-
schemaFields
|
|
656
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
613
|
+
schemaFields.$id = echoIdentifier;
|
|
657
614
|
}
|
|
658
615
|
for (const [key, annotationId] of Object.entries(CustomAnnotations)) {
|
|
659
616
|
const value = annotations2[annotationId];
|
|
@@ -664,13 +621,14 @@ var annotations_toJsonSchemaFields = (annotations2) => {
|
|
|
664
621
|
return schemaFields;
|
|
665
622
|
};
|
|
666
623
|
var decodeTypeIdentifierAnnotation = (schema) => {
|
|
667
|
-
if (schema.$id && schema.$id.startsWith("
|
|
624
|
+
if (schema.$id && schema.$id.startsWith("echo:")) {
|
|
668
625
|
return schema.$id;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
626
|
+
}
|
|
627
|
+
const legacySchemaId = schema.echo?.type?.schemaId;
|
|
628
|
+
if (legacySchemaId) {
|
|
629
|
+
return EntityId.isValid(legacySchemaId) ? EID.make({
|
|
630
|
+
entityId: legacySchemaId
|
|
631
|
+
}) : legacySchemaId;
|
|
674
632
|
}
|
|
675
633
|
return void 0;
|
|
676
634
|
};
|
|
@@ -685,8 +643,8 @@ var decodeTypeAnnotation = (schema) => {
|
|
|
685
643
|
if (annotation.kind === EntityKind.Relation) {
|
|
686
644
|
const source = schema.relationSource?.$ref ?? raise(new Error("Relation source not set"));
|
|
687
645
|
const target = schema.relationTarget?.$ref ?? raise(new Error("Relation target not set"));
|
|
688
|
-
annotation.sourceSchema = DXN.
|
|
689
|
-
annotation.targetSchema = DXN.
|
|
646
|
+
annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));
|
|
647
|
+
annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));
|
|
690
648
|
}
|
|
691
649
|
return annotation;
|
|
692
650
|
}
|
|
@@ -715,7 +673,9 @@ var jsonSchemaFieldsToAnnotations = (schema) => {
|
|
|
715
673
|
if (typeAnnotation) {
|
|
716
674
|
annotations2[TypeAnnotationId] = typeAnnotation;
|
|
717
675
|
annotations2[SchemaAST2.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
718
|
-
|
|
676
|
+
// $id is the typename DXN — the schema's type identity. The storage EID (if any)
|
|
677
|
+
// is preserved separately on TypeIdentifierAnnotation / echo.schemaId.
|
|
678
|
+
identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),
|
|
719
679
|
kind: typeAnnotation.kind,
|
|
720
680
|
typename: typeAnnotation.typename,
|
|
721
681
|
version: typeAnnotation.version,
|
|
@@ -784,4 +744,4 @@ export {
|
|
|
784
744
|
toJsonSchema,
|
|
785
745
|
toEffectSchema
|
|
786
746
|
};
|
|
787
|
-
//# sourceMappingURL=chunk-
|
|
747
|
+
//# sourceMappingURL=chunk-7PI7C4EF.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/JsonSchema/annotations.ts", "../../../src/internal/JsonSchema/json-schema-type.ts", "../../../src/internal/JsonSchema/json-schema.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../Annotation/annotations';\nimport { CurrencyAnnotationId, FormatAnnotationId } from '../Format';\nimport { type JsonSchemaEchoAnnotations, type JsonSchemaType } from '../JsonSchema';\n\n//\n// This file configures annotations for JSON encoding/decoding.\n//\n\n// Go on the root level.\ntype RootJsonSchemaProperty = keyof JsonSchemaType;\n\n// Go on the namespaced `annotations` property.\ntype NamespacedJsonSchemaProperty = keyof JsonSchemaEchoAnnotations;\n\n/**\n * List of annotations for JSON encoding/decoding.\n * Omits default effect-schema annotations since they are encoded with default serializer.\n */\n// TODO(burdon): Reconcile with `EchoAnnotations`.\nexport const CustomAnnotations: Partial<Record<RootJsonSchemaProperty, symbol>> = {\n format: FormatAnnotationId,\n currency: CurrencyAnnotationId,\n};\n\n/**\n * List of annotations for JSON decoding only.\n * Includes default effect annotations.\n */\nexport const DecodedAnnotations: Partial<Record<RootJsonSchemaProperty, symbol>> = {\n title: SchemaAST.TitleAnnotationId,\n description: SchemaAST.DescriptionAnnotationId,\n};\n\n/**\n * Annotations that go into ECHO namespace in json-schema.\n */\n// TODO(dmaretskyi): Consider removing ECHO namespace and putting them at the top level.\n// TODO(dmaretskyi): Move to format.ts when circular imports are solved\nexport const EchoAnnotations: Partial<Record<NamespacedJsonSchemaProperty, symbol>> = {\n // TODO(dmaretskyi): `FieldLookupAnnotationId` might go here, but lets remove it entirely and use LabelAnnotation instead.\n meta: PropertyMetaAnnotationId,\n generator: GeneratorAnnotationId,\n labelProp: LabelAnnotationId,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { SchemaEx } from '@dxos/effect';\n\nimport { type Mutable } from '../common/proxy';\nimport { EntityKindSchema } from '../common/types';\nimport { FormatAnnotation, TypeFormat } from '../Format';\n\n//\n// JSON Schema\n//\n\n// TODO(burdon): Reuse/reconcile with ScalarTypeEnum (handle arrays).\nconst SimpleTypes = Schema.Literal('array', 'boolean', 'integer', 'null', 'number', 'object', 'string');\n\nconst NonNegativeInteger = Schema.Number.pipe(Schema.greaterThanOrEqualTo(0));\n\nconst StringArray = Schema.Array(Schema.String);\n\nconst JsonSchemaOrBoolean = Schema.Union(\n Schema.suspend(() => JsonSchemaType),\n Schema.Boolean,\n);\n\n/**\n * Go under the `annotations` property.\n */\nexport const JsonSchemaEchoAnnotations = Schema.Struct({\n /**\n * Label for this schema.\n * Mapped from {@link LabelAnnotationId}.\n */\n labelProp: Schema.optional(Schema.Union(SchemaEx.JsonPath, Schema.Array(SchemaEx.JsonPath))),\n\n /**\n * Generator function for this schema.\n * Mapped from {@link GeneratorAnnotationId}.\n */\n generator: Schema.optional(Schema.Union(Schema.String, Schema.Tuple(Schema.String, Schema.Number))),\n\n /**\n * {@link PropertyMeta} annotations get serialized here.\n */\n meta: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.Any,\n }),\n ),\n\n /**\n * @deprecated\n */\n // TODO(dmaretskyi): We risk old schema not passing validation due to the extra fields. Remove when we are sure this is safe.\n type: Schema.optional(\n Schema.Struct({\n typename: Schema.String,\n version: Schema.String,\n\n // Not used.\n schemaId: Schema.optional(Schema.String),\n }),\n ),\n\n /**\n * @deprecated Superseded by `meta`.\n */\n annotations: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.Any,\n }),\n ),\n});\nexport type JsonSchemaEchoAnnotations = Schema.Schema.Type<typeof JsonSchemaEchoAnnotations>;\n\n/**\n * Describes a schema for the JSON-schema objects stored in ECHO.\n * Contains extensions for ECHO (e.g., references).\n * Ref: https://json-schema.org/draft-07/schema\n */\n// TODO(burdon): Integrate with Effect Serializable?\n// TODO(dmaretskyi): Update to latest draft: https://json-schema.org/draft/2020-12\nconst _JsonSchemaType = Schema.Struct({\n /**\n * Identifier for this schema.\n * This schema might be referenced by $ref clause in other schemas.\n */\n // TODO(dmaretskyi): Specify how the ids are generated.\n // TODO(dmaretskyi): For type dxns, should this include the version?\n $id: Schema.optional(Schema.String),\n\n /**\n * Schema of this schema.\n * Set to \"https://json-schema.org/draft-07/schema\".\n */\n $schema: Schema.optional(Schema.String),\n\n /**\n * Reference to another schema.\n */\n $ref: Schema.optional(Schema.String),\n\n /**\n * Comments are ignored when interpreting the schema.\n */\n $comment: Schema.optional(Schema.String),\n\n /**\n * Defines whether this schema is an object schema or a relation schema.\n */\n entityKind: Schema.optional(EntityKindSchema),\n\n /**\n * Typename of this schema.\n * Only on schema representing an ECHO object.\n *\n * @example 'com.example.type.my-type'\n */\n typename: Schema.optional(Schema.String),\n\n /**\n * Version of this schema.\n * Custom dialect for ECHO.\n */\n version: Schema.optional(Schema.String),\n\n /**\n * Target of this relation.\n * Only for relation schemas.\n * The referenced schema must be an object schema.\n */\n relationTarget: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n\n /**\n * Source of this relation.\n * Only for relation schemas.\n * The referenced schema must be an object schema.\n */\n relationSource: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n\n /**\n * Title of this schema.\n */\n title: Schema.optional(Schema.String),\n\n /**\n * Description of this schema.\n */\n description: Schema.optional(Schema.String),\n\n /**\n * Whether this schema is read-only.\n */\n readOnly: Schema.optional(Schema.Boolean),\n\n /**\n * Whether this schema is write-only.\n */\n writeOnly: Schema.optional(Schema.Boolean),\n\n /**\n * Examples of instances of this schema.\n */\n examples: Schema.optional(Schema.Array(Schema.Any)),\n\n /**\n * Default value for this schema.\n */\n default: Schema.optional(Schema.Any),\n\n /**\n * This schema only matches values that are equal to this value.\n */\n const: Schema.optional(Schema.Any),\n\n /**\n * This schema only matches one of the values in this array.\n */\n enum: Schema.optional(Schema.Array(Schema.Any)),\n\n /**\n * Base type of the schema.\n */\n type: Schema.optional(Schema.Union(SimpleTypes, Schema.Array(SimpleTypes))),\n\n //\n // Numbers.\n //\n\n multipleOf: Schema.optional(Schema.Number.pipe(Schema.greaterThan(0))),\n maximum: Schema.optional(Schema.Number),\n exclusiveMaximum: Schema.optional(Schema.Number),\n minimum: Schema.optional(Schema.Number),\n exclusiveMinimum: Schema.optional(Schema.Number),\n\n //\n // Strings.\n //\n\n maxLength: Schema.optional(NonNegativeInteger),\n\n /**\n * Regex pattern for strings.\n */\n pattern: Schema.optional(Schema.String.pipe(FormatAnnotation.set(TypeFormat.Regex))),\n\n /**\n * Serialized from {@link FormatAnnotationId}.\n */\n format: Schema.optional(Schema.String),\n\n //\n // Arrays\n //\n\n minLength: Schema.optional(NonNegativeInteger),\n items: Schema.optional(\n Schema.Union(\n Schema.suspend(() => JsonSchemaType),\n Schema.Array(Schema.suspend(() => JsonSchemaType)),\n ),\n ),\n additionalItems: Schema.optional(\n Schema.Union(\n Schema.suspend(() => JsonSchemaType),\n Schema.Boolean,\n ),\n ),\n maxItems: Schema.optional(NonNegativeInteger),\n minItems: Schema.optional(NonNegativeInteger),\n uniqueItems: Schema.optional(Schema.Boolean),\n contains: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n\n //\n // Objects\n //\n\n maxProperties: Schema.optional(NonNegativeInteger),\n minProperties: Schema.optional(NonNegativeInteger),\n required: Schema.optional(StringArray),\n\n /**\n * Non-standard JSON Schema extension.\n * Defines the order of properties in the object.\n * The unmentioned properties are placed at the end.\n *\n * Related: https://github.com/json-schema/json-schema/issues/119\n */\n propertyOrder: Schema.optional(StringArray),\n\n additionalProperties: Schema.optional(JsonSchemaOrBoolean),\n properties: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.suspend(() => JsonSchemaType),\n }),\n ),\n patternProperties: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.suspend(() => JsonSchemaType),\n }),\n ),\n propertyNames: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n\n definitions: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.suspend(() => JsonSchemaType),\n }),\n ),\n dependencies: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.suspend(() => Schema.Union(Schema.String, StringArray, JsonSchemaType)).annotations({\n identifier: 'dependency',\n description: 'Dependency',\n }),\n }),\n ),\n\n contentMediaType: Schema.optional(Schema.String),\n contentEncoding: Schema.optional(Schema.String),\n\n if: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n then: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n else: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n allOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),\n anyOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),\n oneOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),\n not: Schema.optional(Schema.suspend(() => JsonSchemaType)),\n $defs: Schema.optional(\n Schema.Record({\n key: Schema.String,\n value: Schema.suspend(() => JsonSchemaType),\n }),\n ),\n\n //\n // ECHO extensions.\n //\n\n currency: Schema.optional(Schema.String),\n\n reference: Schema.optional(\n Schema.Struct({\n schema: Schema.suspend(() => JsonSchemaType),\n schemaVersion: Schema.optional(Schema.String),\n schemaObject: Schema.optional(Schema.String),\n }),\n ),\n\n /**\n * ECHO-specific annotations.\n */\n // TODO(dmaretskyi): Since we are adding a lot of new extensions to the JSON Schema, it is safer to namespace them here.\n annotations: Schema.optional(JsonSchemaEchoAnnotations),\n\n /**\n * @deprecated Use `annotations` instead.\n */\n echo: Schema.optional(JsonSchemaEchoAnnotations),\n}).annotations({ identifier: 'jsonSchema', description: 'JSON Schema' });\n\nexport const JsonSchemaFields = Object.keys(_JsonSchemaType.fields);\n\n/**\n * https://json-schema.org/draft-07/schema\n */\n// TODO(burdon): Reconcile with @effect/Schema/JSONSchema\nexport interface JsonSchemaType extends Schema.Schema.Type<typeof _JsonSchemaType> {}\n\nexport const JsonSchemaType: Schema.Schema<JsonSchemaType> = _JsonSchemaType;\n\n// TODO(burdon): Factor out JSON schema utils.\n\nexport const getSchemaProperty = (schema: JsonSchemaType, property: SchemaEx.JsonProp): JsonSchemaType | undefined => {\n return schema.properties?.[property];\n};\n\n// TODO(burdon): Properties should be ordered.\nexport const setSchemaProperty = (\n schema: Mutable<JsonSchemaType>,\n property: SchemaEx.JsonProp,\n value: Mutable<JsonSchemaType>,\n) => {\n schema.properties ??= {};\n schema.properties[property] = value;\n return schema;\n};\n\n/**\n * @internal\n */\nexport const ECHO_ANNOTATIONS_NS_DEPRECATED_KEY: keyof JsonSchemaType = 'echo';\n\n/**\n * @internal\n */\nexport const ECHO_ANNOTATIONS_NS_KEY = 'annotations';\n\n/**\n * @internal\n * @returns ECHO annotations namespace object in its normalized form.\n *\n * `meta` holds PropertyMeta annotations.\n * `annotations` holds other annotations.\n */\nexport const getNormalizedEchoAnnotations = (obj: JsonSchemaType): JsonSchemaEchoAnnotations | undefined => {\n if (obj[ECHO_ANNOTATIONS_NS_KEY] != null && obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {\n return normalizeEchoAnnotations({\n ...obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY],\n ...obj[ECHO_ANNOTATIONS_NS_KEY],\n });\n } else if (obj[ECHO_ANNOTATIONS_NS_KEY] != null) {\n return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_KEY]!);\n } else if (obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {\n return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY]!);\n } else {\n return undefined;\n }\n};\n\nconst normalizeEchoAnnotations = (obj: JsonSchemaEchoAnnotations): JsonSchemaEchoAnnotations => {\n if (!obj.annotations) {\n return obj;\n } else {\n const res = {\n ...obj,\n meta: {\n ...obj.annotations,\n ...(obj.meta ?? {}),\n },\n };\n delete res.annotations;\n return res;\n }\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Array from 'effect/Array';\nimport * as Function from 'effect/Function';\nimport * as JSONSchema from 'effect/JSONSchema';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport type * as Types from 'effect/Types';\n\nimport { raise } from '@dxos/debug';\nimport { SchemaEx } from '@dxos/effect';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, EID, EntityId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { clearUndefined, orderKeys, removeProperties } from '@dxos/util';\n\nimport type * as Type from '../../Type';\nimport { type TypeAnnotation, TypeAnnotationId, TypeIdentifierAnnotationId } from '../Annotation/annotations';\nimport { makeTypeJsonSchemaAnnotation } from '../Annotation/util';\nimport {\n ANY_OBJECT_TYPENAME,\n ANY_OBJECT_VERSION,\n EntityKind,\n EntityKindSchema,\n getStaticTypeSchema,\n} from '../common/types';\nimport { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';\nimport { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';\nimport {\n ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,\n ECHO_ANNOTATIONS_NS_KEY,\n type JsonSchemaEchoAnnotations,\n type JsonSchemaType,\n getNormalizedEchoAnnotations,\n} from './json-schema-type';\n\n// TODO(burdon): Are these values stored (can they be changed?)\nexport enum PropType {\n NONE = 0,\n STRING = 1, // TODO(burdon): vs TEXT?\n NUMBER = 2,\n BOOLEAN = 3,\n DATE = 4,\n REF = 5,\n RECORD = 6,\n ENUM = 7,\n}\n\n// TODO(burdon): Reconcile with @dxos/schema.\nexport const toPropType = (type?: PropType): string => {\n switch (type) {\n case PropType.STRING:\n return 'string';\n case PropType.NUMBER:\n return 'number';\n case PropType.BOOLEAN:\n return 'boolean';\n case PropType.DATE:\n return 'date';\n case PropType.REF:\n return 'ref';\n case PropType.RECORD:\n return 'object';\n default:\n throw new Error(`Invalid type: ${type}`);\n }\n};\n\nconst JSON_SCHEMA_URL = 'http://json-schema.org/draft-07/schema#';\n\nexport type JsonSchemaOptions = {\n strict?: boolean;\n};\n\n/**\n * Convert effect schema to JSON Schema.\n * NOTE: This handles custom annotations.\n * @param schema\n */\n// TODO(burdon): Reconcile with possibly extending @effect/Schema/JSONSchema\n// We add additional propertyOrder (but the object properties ARE ordered); and type \"string\" for literals.\n// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?\nexport const toJsonSchema = (\n schema: Schema.Schema.All | Type.AnyEntity,\n options: JsonSchemaOptions = {},\n): Types.DeepMutable<JsonSchemaType> => {\n // Allow passing a `Type.Type` entity — use its hidden source schema (or its\n // already-built jsonSchema as a fallback).\n const slot = getStaticTypeSchema(schema);\n if (slot != null) {\n schema = slot;\n } else if (!Schema.isSchema(schema)) {\n const entityJsonSchema = (schema as { jsonSchema?: JsonSchemaType }).jsonSchema;\n if (entityJsonSchema != null) {\n return entityJsonSchema as Types.DeepMutable<JsonSchemaType>;\n }\n }\n assertArgument(Schema.isSchema(schema), 'schema');\n let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);\n if (options.strict) {\n // TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).\n jsonSchema = removeProperties(jsonSchema, (key, value) => {\n if (key === '$id' && value === '/schemas/any') {\n return true;\n }\n if (key === '$ref' && value === '#/$defs/dependency') {\n return true;\n }\n if (key === '$ref' && value === '#/$defs/jsonSchema') {\n return true;\n }\n\n return false;\n });\n }\n\n return jsonSchema;\n};\n\nconst _toJsonSchemaAST = (ast: SchemaAST.AST): Types.DeepMutable<JsonSchemaType> => {\n const withRefinements = withEchoRefinements(ast, '#');\n const jsonSchema = JSONSchema.fromAST(withRefinements, {\n definitions: {},\n }) as Types.DeepMutable<JsonSchemaType>;\n\n return normalizeJsonSchema(jsonSchema);\n};\n\nconst withEchoRefinements = (\n ast: SchemaAST.AST,\n path: string | undefined,\n suspendCache = new Map<SchemaAST.AST, string>(),\n): SchemaAST.AST => {\n if (path) {\n suspendCache.set(ast, path);\n }\n\n let recursiveResult: SchemaAST.AST;\n if (SchemaAST.isSuspend(ast)) {\n // Precompute JSON schema for suspended AST since effect serializer does not support it.\n const suspendedAst = ast.f();\n const cachedPath = suspendCache.get(suspendedAst);\n if (cachedPath) {\n recursiveResult = new SchemaAST.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {\n [SchemaAST.JSONSchemaAnnotationId]: {\n $ref: cachedPath,\n },\n });\n } else {\n const jsonSchema = _toJsonSchemaAST(suspendedAst);\n recursiveResult = new SchemaAST.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {\n [SchemaAST.JSONSchemaAnnotationId]: jsonSchema,\n });\n }\n } else if (SchemaAST.isTypeLiteral(ast)) {\n // Add property order annotations\n recursiveResult = SchemaEx.mapAst(ast, (ast, key) =>\n withEchoRefinements(ast, path && typeof key === 'string' ? `${path}/${key}` : undefined, suspendCache),\n );\n recursiveResult = addJsonSchemaFields(recursiveResult, {\n propertyOrder: [...ast.propertySignatures.map((p) => p.name)] as string[],\n });\n } else if (SchemaAST.isUndefinedKeyword(ast)) {\n // Ignore undefined keyword that appears in the optional fields.\n return ast;\n } else {\n recursiveResult = SchemaEx.mapAst(ast, (ast, key) =>\n withEchoRefinements(\n ast,\n path && (typeof key === 'string' || typeof key === 'number') ? `${path}/${key}` : undefined,\n suspendCache,\n ),\n );\n }\n\n const annotationFields = annotations_toJsonSchemaFields(ast.annotations);\n if (Object.keys(annotationFields).length === 0) {\n return recursiveResult;\n } else {\n return addJsonSchemaFields(recursiveResult, annotationFields);\n }\n};\n\n/**\n * Convert JSON schema to effect schema.\n * @param root\n * @param definitions\n */\nexport const toEffectSchema = (root: JsonSchemaType, _defs?: JsonSchemaType['$defs']): Schema.Schema.AnyNoContext => {\n const defs = root.$defs ? { ..._defs, ...root.$defs } : (_defs ?? {});\n if ('type' in root && root.type === 'object') {\n return objectToEffectSchema(root, defs);\n }\n\n let result: Schema.Schema.AnyNoContext = Schema.Unknown;\n if ('$ref' in root) {\n switch (root.$ref) {\n case '/schemas/echo/ref': {\n result = refToEffectSchema(root);\n break;\n }\n }\n } else if ('$id' in root) {\n switch (decodeURIComponent(root.$id as string)) {\n case '/schemas/any': {\n result = anyToEffectSchema(root as JSONSchema.JsonSchema7Any);\n break;\n }\n case '/schemas/unknown': {\n result = Schema.Unknown;\n break;\n }\n case '/schemas/{}':\n case '/schemas/object': {\n result = Schema.Struct({});\n break;\n }\n // Custom ECHO object reference.\n case '/schemas/echo/ref': {\n result = refToEffectSchema(root);\n break;\n }\n }\n } else if ('enum' in root) {\n result = Schema.Union(...root.enum!.map((e) => Schema.Literal(e)));\n } else if ('oneOf' in root) {\n result = Schema.Union(...root.oneOf!.map((v) => toEffectSchema(v, defs)));\n } else if ('anyOf' in root) {\n result = Schema.Union(...root.anyOf!.map((v) => toEffectSchema(v, defs)));\n } else if ('allOf' in root) {\n if (root.allOf!.length === 1) {\n result = toEffectSchema(root.allOf![0], defs);\n } else {\n log.warn('allOf with multiple schemas is not supported');\n result = Schema.Unknown;\n }\n } else if ('type' in root) {\n switch (root.type) {\n case 'string': {\n result = Schema.String;\n if (root.pattern) {\n result = result.pipe(Schema.pattern(new RegExp(root.pattern)));\n }\n break;\n }\n case 'number': {\n result = Schema.Number;\n break;\n }\n case 'integer': {\n result = Schema.Number.pipe(Schema.int());\n break;\n }\n case 'boolean': {\n result = Schema.Boolean;\n break;\n }\n case 'array': {\n if (Array.isArray(root.items)) {\n const [required, optional] = Function.pipe(\n root.items,\n Array.map((v) => toEffectSchema(v as JsonSchemaType, defs)),\n Array.splitAt(root.minItems ?? root.items.length),\n );\n result = Schema.Tuple(...required, ...optional.map(Schema.optionalElement));\n } else {\n invariant(root.items);\n const items = root.items;\n result = Array.isArray(items)\n ? Schema.Tuple(...items.map((v) => toEffectSchema(v as JsonSchemaType, defs)))\n : Schema.Array(toEffectSchema(items as JsonSchemaType, defs));\n }\n break;\n }\n case 'null': {\n result = Schema.Null;\n break;\n }\n }\n } else if ('$ref' in root) {\n const refSegments = root.$ref!.split('/');\n const jsonSchema = defs[refSegments[refSegments.length - 1]];\n invariant(jsonSchema, `missing definition for ${root.$ref}`);\n result = toEffectSchema(jsonSchema, defs).pipe(\n Schema.annotations({ identifier: refSegments[refSegments.length - 1] }),\n );\n }\n\n const annotations = jsonSchemaFieldsToAnnotations(root);\n\n // log.info('toEffectSchema', { root, annotations });\n result = result.annotations(annotations);\n\n return result;\n};\n\nconst objectToEffectSchema = (root: JsonSchemaType, defs: JsonSchemaType['$defs']): Schema.Schema.AnyNoContext => {\n invariant('type' in root && root.type === 'object', `not an object: ${root}`);\n\n const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];\n const isEchoObject =\n echoRefinement != null || ('$id' in root && typeof root.$id === 'string' && root.$id.startsWith('dxn:'));\n\n let fields: Schema.Struct.Fields = {};\n const propertyList = Object.entries(root.properties ?? {});\n let immutableIdField: Schema.Schema.AnyNoContext | undefined;\n for (const [key, value] of propertyList) {\n if (isEchoObject && key === 'id') {\n immutableIdField = toEffectSchema(value, defs);\n } else {\n // TODO(burdon): Mutable cast.\n (fields as any)[key] = root.required?.includes(key)\n ? toEffectSchema(value, defs)\n : Schema.optional(toEffectSchema(value, defs));\n }\n }\n\n if (root.propertyOrder) {\n fields = orderKeys(fields, root.propertyOrder as any);\n }\n\n let schema: Schema.Schema<any, any, unknown>;\n if (root.patternProperties) {\n invariant(propertyList.length === 0, 'pattern properties mixed with regular properties are not supported');\n invariant(\n Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === '',\n 'only one pattern property is supported',\n );\n\n schema = Schema.Record({ key: Schema.String, value: toEffectSchema(root.patternProperties[''], defs) });\n } else if (typeof root.additionalProperties !== 'object') {\n schema = Schema.Struct(fields);\n } else {\n const indexValue = toEffectSchema(root.additionalProperties, defs);\n if (propertyList.length > 0) {\n schema = Schema.Struct(fields, { key: Schema.String, value: indexValue });\n } else {\n schema = Schema.Record({ key: Schema.String, value: indexValue });\n }\n }\n\n if (immutableIdField) {\n schema = Schema.extend(schema, Schema.Struct({ id: immutableIdField }));\n }\n\n const annotations = jsonSchemaFieldsToAnnotations(root);\n return schema.annotations(annotations) as any;\n};\n\nconst anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNoContext => {\n const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];\n // TODO(dmaretskyi): Is this branch still taken?\n if ((echoRefinement as any)?.reference != null) {\n const echoUri = root.$id.startsWith('echo:') ? root.$id : undefined;\n return createEchoReferenceSchema(\n echoUri,\n (echoRefinement as any).reference.typename,\n (echoRefinement as any).reference.version,\n );\n }\n\n return Schema.Any;\n};\n\n// TODO(dmaretskyi): Types.\nconst refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {\n if (!('reference' in root)) {\n // Fallback to generic object ref when no reference info is provided.\n return createEchoReferenceSchema(undefined, ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION);\n }\n\n const reference: JsonSchemaReferenceInfo = root.reference;\n if (typeof reference !== 'object') {\n throw new Error('Invalid reference field in ref schema');\n }\n\n const ref = reference.schema.$ref;\n const targetSchemaDXN = DXN.tryMake(ref);\n invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);\n\n return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);\n};\n\n//\n// Annotations\n//\n\nconst annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Record<symbol, any> => {\n const schemaFields: Record<string, any> = {};\n\n const echoAnnotations: Types.Mutable<JsonSchemaEchoAnnotations> = {};\n for (const [key, annotationId] of Object.entries(EchoAnnotations)) {\n if (annotations[annotationId] != null) {\n echoAnnotations[key as keyof JsonSchemaEchoAnnotations] = annotations[annotationId] as any;\n }\n }\n if (Object.keys(echoAnnotations).length > 0) {\n // TODO(dmaretskyi): use new namespace.\n schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;\n }\n\n // For stored schemas the storage URI is the definitive identifier — it overrides\n // the typename `$id` written above.\n const echoIdentifier = annotations[TypeIdentifierAnnotationId];\n if (echoIdentifier) {\n schemaFields.$id = echoIdentifier;\n }\n\n // Custom (at end).\n for (const [key, annotationId] of Object.entries(CustomAnnotations)) {\n const value = annotations[annotationId];\n if (value != null) {\n schemaFields[key] = value;\n }\n }\n\n return schemaFields;\n};\n\nconst decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {\n // For stored schemas `$id` IS the storage URI (echo:/<id>).\n if (schema.$id && schema.$id.startsWith('echo:')) {\n return schema.$id;\n }\n // Older serializations stored the EID on echo.type.schemaId.\n const legacySchemaId = schema.echo?.type?.schemaId;\n if (legacySchemaId) {\n return EntityId.isValid(legacySchemaId) ? EID.make({ entityId: legacySchemaId }) : legacySchemaId;\n }\n return undefined;\n};\n\nconst decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefined => {\n if (schema.typename) {\n const annotation: Types.Mutable<TypeAnnotation> = {\n // TODO(dmaretskyi): Decoding default.\n kind: schema.entityKind ? Schema.decodeSync(EntityKindSchema)(schema.entityKind) : EntityKind.Object,\n typename: schema.typename,\n version: schema.version ?? '0.1.0',\n };\n\n if (annotation.kind === EntityKind.Relation) {\n const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));\n const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));\n annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));\n annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));\n }\n\n return annotation;\n }\n\n // Decode legacy schema.\n if (!schema.typename && schema?.echo?.type) {\n return {\n kind: EntityKind.Object,\n typename: schema.echo.type.typename,\n version: schema.echo.type.version,\n };\n }\n\n return undefined;\n};\n\nconst jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annotations => {\n const annotations: Types.Mutable<Schema.Annotations.Schema<any>> = {};\n\n const echoAnnotations: JsonSchemaEchoAnnotations = getNormalizedEchoAnnotations(schema) ?? {};\n if (echoAnnotations) {\n for (const [key, annotationId] of Object.entries(EchoAnnotations)) {\n if (echoAnnotations[key as keyof JsonSchemaEchoAnnotations]) {\n annotations[annotationId] = echoAnnotations[key as keyof JsonSchemaEchoAnnotations];\n }\n }\n }\n\n const typeIdentifier = decodeTypeIdentifierAnnotation(schema);\n annotations[TypeIdentifierAnnotationId] = typeIdentifier;\n const typeAnnotation = decodeTypeAnnotation(schema);\n if (typeAnnotation) {\n annotations[TypeAnnotationId] = typeAnnotation;\n annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({\n // $id is the typename DXN — the schema's type identity. The storage EID (if any)\n // is preserved separately on TypeIdentifierAnnotation / echo.schemaId.\n identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),\n kind: typeAnnotation.kind,\n typename: typeAnnotation.typename,\n version: typeAnnotation.version,\n relationSource: typeAnnotation.sourceSchema,\n relationTarget: typeAnnotation.targetSchema,\n });\n }\n\n // Custom (at end).\n for (const [key, annotationId] of Object.entries({ ...CustomAnnotations, ...DecodedAnnotations })) {\n if (key in schema) {\n annotations[annotationId] = (schema as any)[key];\n }\n }\n\n return clearUndefined(annotations);\n};\n\nconst makeAnnotatedRefinement = (ast: SchemaAST.AST, annotations: SchemaAST.Annotations): SchemaAST.Refinement => {\n return new SchemaAST.Refinement(ast, () => Option.none(), annotations);\n};\n\nconst addJsonSchemaFields = (ast: SchemaAST.AST, schema: JsonSchemaType): SchemaAST.AST =>\n makeAnnotatedRefinement(ast, { [SchemaAST.JSONSchemaAnnotationId]: schema });\n\n/**\n * Fixes field order.\n * Sets `$schema` prop.\n */\nconst normalizeJsonSchema = (jsonSchema: Types.DeepMutable<JsonSchemaType>): Types.DeepMutable<JsonSchemaType> => {\n if (jsonSchema.properties && 'id' in jsonSchema.properties) {\n jsonSchema.properties = orderKeys(jsonSchema.properties, ['id']); // Put id first.\n }\n\n // TODO(dmaretskyi): Makes sure undefined is not left on optional fields for the resulting object.\n jsonSchema.$schema = JSON_SCHEMA_URL;\n jsonSchema = orderKeys(jsonSchema, [\n '$schema',\n '$id',\n\n 'entityKind',\n 'typename',\n 'version',\n 'relationTarget',\n 'relationSource',\n\n 'type',\n 'enum',\n\n 'properties',\n 'required',\n 'propertyOrder', // Custom.\n 'items',\n 'additionalProperties',\n\n 'anyOf',\n 'oneOf',\n ]);\n return jsonSchema;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,YAAYA,eAAe;AAqBpB,IAAMC,oBAAqE;EAChFC,QAAQC;EACRC,UAAUC;AACZ;AAMO,IAAMC,qBAAsE;EACjFC,OAAiBC;EACjBC,aAAuBC;AACzB;AAOO,IAAMC,kBAAyE;;EAEpFC,MAAMC;EACNC,WAAWC;EACXC,WAAWC;AACb;;;AC7CA,YAAYC,YAAY;AAExB,SAASC,gBAAgB;AAWzB,IAAMC,cAAqBC,eAAQ,SAAS,WAAW,WAAW,QAAQ,UAAU,UAAU,QAAA;AAE9F,IAAMC,qBAA4BC,cAAOC,KAAYC,4BAAqB,CAAA,CAAA;AAE1E,IAAMC,cAAqBC,aAAaC,aAAM;AAE9C,IAAMC,sBAA6BC,aAC1BC,eAAQ,MAAMC,cAAAA,GACdC,cAAO;AAMT,IAAMC,4BAAmCC,cAAO;;;;;EAKrDC,WAAkBC,gBAAgBP,aAAMQ,SAASC,UAAiBZ,aAAMW,SAASC,QAAQ,CAAA,CAAA;;;;;EAMzFC,WAAkBH,gBAAgBP,aAAaF,eAAea,aAAab,eAAeL,aAAM,CAAA,CAAA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AAzB,aAAA,YAAA,IAAA,gBAAA,GAAA;MACF;IAEA;EACAA;AACA,QAAMoD,iBAAiBlB,+BAAqBnF,MAAAA;AAC5C,EAAAiD,aAAIoD,0BAAgB,IAAA;QAClBpD,iBAAYqD,qBAAoBD,MAAAA;MAChCpD,gBAAY9B;iBACV,gBAAA,IAAA;iBACA,iCAAA,IAAA,6BAAuE;;;MAGvE6E,YAAUK,IAAAA,KAAAA,eAAuB,UAAA,eAAA,OAAA;MACjCf,MAAAA,eAASe;MACTE,UAAAA,eAAgBF;MAChBX,SAAAA,eAAgBW;MAClB,gBAAA,eAAA;MACF,gBAAA,eAAA;IAEA,CAAA;EACA;aAA4EG,CAAAA,KAAAA,YAAkB,KAAA,OAAA,QAAA;IAAK,GAAA;IACjG,GAAA;;AAEA,QAAA,OAAA,QAAA;AACF,MAAAvD,aAAA,YAAA,IAAA,OAAA,GAAA;IAEA;EACF;AAEA,SAAMwD,eAAAA,YAA2B5F;;AAEjC,IAAA,0BAAA,CAAA,KAAAoC,iBAAA;AAEA,SAAMtB,IAAAA,sBAA2C3B,KAAAA,MAC/CyG,YAAAA,GAAAA,YAAwB5F;;IAAkD,sBAAA,CAAA,KAAA,WAAA,wBAAA,KAAA;EAE5E,CAAA,iCAAA,GAAA;;IAMIR,sBAAwBqG,CAAAA,eAAUrG;iBAAwB,cAAA,QAAA,WAAA,YAAA;eAAQ,aAAgB,UAAA,WAAA,YAAA;MACpF;IAEA,CAAA;EACAA;aAEE,UAAA;eACA,UAAA,YAAA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACD;IACD;EACF,CAAA;;;",
|
|
6
|
+
"names": ["SchemaAST", "CustomAnnotations", "format", "FormatAnnotationId", "currency", "CurrencyAnnotationId", "DecodedAnnotations", "title", "TitleAnnotationId", "description", "DescriptionAnnotationId", "EchoAnnotations", "meta", "PropertyMetaAnnotationId", "generator", "GeneratorAnnotationId", "labelProp", "LabelAnnotationId", "Schema", "SchemaEx", "SimpleTypes", "Literal", "NonNegativeInteger", "Number", "pipe", "greaterThanOrEqualTo", "StringArray", "Array", "String", "JsonSchemaOrBoolean", "Union", "suspend", "JsonSchemaType", "Boolean", "JsonSchemaEchoAnnotations", "Struct", "labelProp", "optional", "SchemaEx", "JsonPath", "generator", "Tuple", "meta", "Record", "key", "value", "Any", "type", "typename", "version", "schemaId", "annotations", "_JsonSchemaType", "$id", "$schema", "$ref", "$comment", "entityKind", "EntityKindSchema", "relationTarget", "relationSource", "title", "description", "readOnly", "writeOnly", "examples", "default", "const", "enum", "multipleOf", "greaterThan", "maximum", "exclusiveMaximum", "minimum", "exclusiveMinimum", "maxLength", "pattern", "FormatAnnotation", "set", "TypeFormat", "Regex", "format", "minLength", "items", "additionalItems", "maxItems", "minItems", "uniqueItems", "contains", "maxProperties", "minProperties", "required", "propertyOrder", "additionalProperties", "properties", "patternProperties", "propertyNames", "definitions", "dependencies", "identifier", "contentMediaType", "contentEncoding", "if", "then", "else", "allOf", "anyOf", "oneOf", "not", "$defs", "currency", "reference", "schema", "schemaVersion", "schemaObject", "echo", "JsonSchemaFields", "Object", "keys", "fields", "getSchemaProperty", "property", "setSchemaProperty", "ECHO_ANNOTATIONS_NS_DEPRECATED_KEY", "ECHO_ANNOTATIONS_NS_KEY", "getNormalizedEchoAnnotations", "obj", "normalizeEchoAnnotations", "undefined", "res", "Array", "Function", "JSONSchema", "Option", "Schema", "SchemaAST", "raise", "SchemaEx", "assertArgument", "invariant", "DXN", "EID", "EntityId", "log", "clearUndefined", "orderKeys", "removeProperties", "PropType", "schema", "slot", "Schema", "entityJsonSchema", "assertArgument", "jsonSchema", "removeProperties", "key", "_toJsonSchemaAST", "JSONSchema", "definitions", "normalizeJsonSchema", "withEchoRefinements", "ast", "suspendCache", "path", "recursiveResult", "suspendedAst", "cachedPath", "SchemaAST", "Suspend", "JSONSchemaAnnotationId", "mapAst", "propertyOrder", "propertySignatures", "annotationFields", "annotations_toJsonSchemaFields", "addJsonSchemaFields", "_defs", "$defs", "objectToEffectSchema", "result", "root", "Union", "oneOf", "toEffectSchema", "v", "anyOf", "map", "defs", "length", "log", "Tuple", "required", "optional", "invariant", "items", "Array", "isArray", "annotations", "identifier", "refSegments", "ECHO_ANNOTATIONS_NS_DEPRECATED_KEY", "isEchoObject", "echoRefinement", "$id", "fields", "propertyList", "Object", "properties", "immutableIdField", "value", "String", "additionalProperties", "indexValue", "anyToEffectSchema", "reference", "createEchoReferenceSchema", "echoUri", "Error", "ref", "targetSchemaDXN", "DXN", "annotationId", "echoAnnotations", "schemaFields", "ECHO_ANNOTATIONS_NS_KEY", "echoIdentifier", "decodeTypeIdentifierAnnotation", "startsWith", "isValid", "legacySchemaId", "undefined", "decodeTypeAnnotation", "kind", "entityKind", "version", "annotation", "EntityKind", "target", "relationTarget", "$ref", "sourceSchema", "source", "raise", "targetSchema", "typename", "echo", "jsonSchemaFieldsToAnnotations", "getNormalizedEchoAnnotations", "EchoAnnotations", "typeAnnotation", "TypeAnnotationId", "relationSource", "DecodedAnnotations", "makeAnnotatedRefinement", "orderKeys"]
|
|
7
|
+
}
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
// src/Err.ts
|
|
6
6
|
var Err_exports = {};
|
|
7
7
|
__export(Err_exports, {
|
|
8
|
+
EntityNotFoundError: () => EntityNotFoundError,
|
|
8
9
|
GetReactiveError: () => GetReactiveError,
|
|
9
|
-
ObjectNotFoundError: () => ObjectNotFoundError,
|
|
10
10
|
SchemaNotFoundError: () => SchemaNotFoundError
|
|
11
11
|
});
|
|
12
12
|
import { BaseError } from "@dxos/errors";
|
|
@@ -20,11 +20,11 @@ var SchemaNotFoundError = class extends BaseError.extend("SchemaNotFoundError",
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
var
|
|
24
|
-
constructor(
|
|
23
|
+
var EntityNotFoundError = class extends BaseError.extend("EntityNotFoundError", "Entity not found") {
|
|
24
|
+
constructor(uri, options) {
|
|
25
25
|
super({
|
|
26
26
|
context: {
|
|
27
|
-
|
|
27
|
+
uri
|
|
28
28
|
},
|
|
29
29
|
...options
|
|
30
30
|
});
|
|
@@ -44,8 +44,8 @@ var GetReactiveError = class extends BaseError.extend("GetReactiveError", "Faile
|
|
|
44
44
|
|
|
45
45
|
export {
|
|
46
46
|
SchemaNotFoundError,
|
|
47
|
-
|
|
47
|
+
EntityNotFoundError,
|
|
48
48
|
GetReactiveError,
|
|
49
49
|
Err_exports
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-BBFJWWAV.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Err.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\nimport { type URI } from '@dxos/keys';\n\nexport class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError', 'Schema not found') {\n constructor(schema: string, options?: BaseErrorOptions) {\n super({ context: { schema }, ...options });\n }\n}\n\nexport class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Entity not found') {\n constructor(uri: URI.URI, options?: BaseErrorOptions) {\n super({ context: { uri }, ...options });\n }\n}\n\n/**\n * Reason why getting a reactive object from a snapshot failed.\n * - `no-database`: The snapshot is not associated with a database.\n * - `object-not-found`: The object was removed or does not exist in the database.\n */\nexport type GetReactiveErrorReason = 'no-database' | 'object-not-found';\n\n/**\n * Error thrown when a reactive object cannot be resolved from a snapshot.\n * Extends `BaseError` with a `reason` and optional `snapshotId` in its context.\n */\nexport class GetReactiveError extends BaseError.extend(\n 'GetReactiveError',\n 'Failed to get reactive object from snapshot',\n) {\n constructor(options: { reason: GetReactiveErrorReason; snapshotId?: string } & BaseErrorOptions) {\n super({ context: { reason: options.reason, snapshotId: options.snapshotId }, ...options });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;AAMA,SAASA,iBAAwC;AAG1C,IAAMC,sBAAN,cAAkCD,UAAUE,OAAO,uBAAuB,kBAAA,EAAA;EAC/E,YAAYC,QAAgBC,SAA4B;AACtD,UAAM;MAAEC,SAAS;QAAEF;MAAO;MAAG,GAAGC;IAAQ,CAAA;EAC1C;AACF;AAEO,IAAME,sBAAN,cAAkCN,UAAUE,OAAO,uBAAuB,kBAAA,EAAA;EAC/E,YAAYK,KAAcH,SAA4B;AACpD,UAAM;MAAEC,SAAS;QAAEE;MAAI;MAAG,GAAGH;IAAQ,CAAA;EACvC;AACF;AAaO,IAAMI,mBAAN,cAA+BR,UAAUE,OAC9C,oBACA,6CAAA,EAAA;EAEA,YAAYE,SAAqF;AAC/F,UAAM;MAAEC,SAAS;QAAEI,QAAQL,QAAQK;QAAQC,YAAYN,QAAQM;MAAW;MAAG,GAAGN;IAAQ,CAAA;EAC1F;AACF;",
|
|
6
|
+
"names": ["BaseError", "SchemaNotFoundError", "extend", "schema", "options", "context", "EntityNotFoundError", "uri", "GetReactiveError", "reason", "snapshotId"]
|
|
7
|
+
}
|
|
@@ -5,9 +5,11 @@ import {
|
|
|
5
5
|
// src/Order.ts
|
|
6
6
|
var Order_exports = {};
|
|
7
7
|
__export(Order_exports, {
|
|
8
|
+
created: () => created,
|
|
8
9
|
natural: () => natural,
|
|
9
10
|
property: () => property,
|
|
10
|
-
rank: () => rank
|
|
11
|
+
rank: () => rank,
|
|
12
|
+
updated: () => updated
|
|
11
13
|
});
|
|
12
14
|
var OrderClass = class _OrderClass {
|
|
13
15
|
ast;
|
|
@@ -32,11 +34,23 @@ var rank = (direction = "desc") => new OrderClass({
|
|
|
32
34
|
kind: "rank",
|
|
33
35
|
direction
|
|
34
36
|
});
|
|
37
|
+
var updated = (direction = "desc") => new OrderClass({
|
|
38
|
+
kind: "timestamp",
|
|
39
|
+
field: "updatedAt",
|
|
40
|
+
direction
|
|
41
|
+
});
|
|
42
|
+
var created = (direction = "desc") => new OrderClass({
|
|
43
|
+
kind: "timestamp",
|
|
44
|
+
field: "createdAt",
|
|
45
|
+
direction
|
|
46
|
+
});
|
|
35
47
|
|
|
36
48
|
export {
|
|
37
49
|
natural,
|
|
38
50
|
property,
|
|
39
51
|
rank,
|
|
52
|
+
updated,
|
|
53
|
+
created,
|
|
40
54
|
Order_exports
|
|
41
55
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-EVK6XBXO.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Order.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { type QueryAST } from '@dxos/echo-protocol';\n\nexport interface Order<T> {\n // TODO(dmaretskyi): See new effect-schema approach to variance.\n '~Order': { value: T };\n\n ast: QueryAST.Order;\n}\n\nexport type Any = Order<any>;\n\nclass OrderClass implements Order<any> {\n private static 'variance': Order<any>['~Order'] = {} as Order<any>['~Order'];\n\n static is(value: unknown): value is Order<any> {\n return typeof value === 'object' && value !== null && '~Order' in value;\n }\n\n constructor(public readonly ast: QueryAST.Order) {}\n\n '~Order' = OrderClass.variance;\n}\n\nexport const natural: Order<any> = new OrderClass({ kind: 'natural' });\nexport const property = <T>(property: keyof T & string, direction: QueryAST.OrderDirection): Order<T> =>\n new OrderClass({\n kind: 'property',\n property,\n direction,\n });\n\n/**\n * Order by relevance rank (for FTS/vector search results).\n * Higher rank = better match. Default direction is 'desc' (best matches first).\n */\nexport const rank = <T>(direction: QueryAST.OrderDirection = 'desc'): Order<T> =>\n new OrderClass({\n kind: 'rank',\n direction,\n });\n\n/**\n * Order by the system `updatedAt` timestamp (last re-indexed). Default direction is 'desc'\n * (most-recently-updated first). Mirrors {@link Filter.updated}.\n */\nexport const updated = <T>(direction: QueryAST.OrderDirection = 'desc'): Order<T> =>\n new OrderClass({\n kind: 'timestamp',\n field: 'updatedAt',\n direction,\n });\n\n/**\n * Order by the system `createdAt` timestamp (first indexed). Default direction is 'desc'\n * (most-recently-created first). Mirrors {@link Filter.created}.\n */\nexport const created = <T>(direction: QueryAST.OrderDirection = 'desc'): Order<T> =>\n new OrderClass({\n kind: 'timestamp',\n field: 'createdAt',\n direction,\n });\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;;;AAiBA,IAAMA,aAAN,MAAMA,YAAAA;;EACJ,OAAe,aAAmC,CAAC;EAEnD,OAAOC,GAAGC,OAAqC;AAC7C,WAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,YAAYA;EACpE;EAEA,YAA4BC,KAAqB;SAArBA,MAAAA;EAAsB;EAElD,WAAWH,YAAWI;AACxB;AAEO,IAAMC,UAAsB,IAAIL,WAAW;EAAEM,MAAM;AAAU,CAAA;AAC7D,IAAMC,WAAW,CAAIA,WAA4BC,cACtD,IAAIR,WAAW;EACbM,MAAM;EACNC,UAAAA;EACAC;AACF,CAAA;AAMK,IAAMC,OAAO,CAAID,YAAqC,WAC3D,IAAIR,WAAW;EACbM,MAAM;EACNE;AACF,CAAA;AAMK,IAAME,UAAU,CAAIF,YAAqC,WAC9D,IAAIR,WAAW;EACbM,MAAM;EACNK,OAAO;EACPH;AACF,CAAA;AAMK,IAAMI,UAAU,CAAIJ,YAAqC,WAC9D,IAAIR,WAAW;EACbM,MAAM;EACNK,OAAO;EACPH;AACF,CAAA;",
|
|
6
|
+
"names": ["OrderClass", "is", "value", "ast", "variance", "natural", "kind", "property", "direction", "rank", "updated", "field", "created"]
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
JsonSchemaType,
|
|
3
3
|
toEffectSchema,
|
|
4
4
|
toJsonSchema
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-7PI7C4EF.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__export
|
|
8
8
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -24,4 +24,4 @@ export {
|
|
|
24
24
|
JsonSchema,
|
|
25
25
|
JsonSchema_exports
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-IGK6FN65.mjs.map
|