@dxos/echo 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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 +4 -4
- package/dist/lib/neutral/Annotation.mjs +7 -3
- package/dist/lib/neutral/Database.mjs +8 -4
- package/dist/lib/neutral/Entity.mjs +24 -14
- package/dist/lib/neutral/Err.mjs +1 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +50 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +21 -10
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Key.mjs +1 -1
- package/dist/lib/neutral/Migration.mjs +17 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +26 -17
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +21 -9
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +9 -7
- package/dist/lib/neutral/Relation.mjs +23 -13
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +14 -10
- package/dist/lib/neutral/Type.mjs +13 -23
- package/dist/lib/neutral/{chunk-N2QNHMT5.mjs → chunk-44HT3MEC.mjs} +2 -2
- package/dist/lib/neutral/{chunk-N2QNHMT5.mjs.map → chunk-44HT3MEC.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-XAJMXQ4H.mjs → chunk-5SL5LDLD.mjs} +6 -2
- package/dist/lib/neutral/chunk-5SL5LDLD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6VIJV543.mjs +34 -0
- package/dist/lib/neutral/chunk-6VIJV543.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7RVZT53K.mjs} +1 -1
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-BICZKPQG.mjs} +1 -1
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs.map → chunk-BICZKPQG.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-B4FLOYG7.mjs → chunk-FHYIM4RD.mjs} +18 -20
- package/dist/lib/neutral/chunk-FHYIM4RD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FZHVQEHN.mjs +81 -0
- package/dist/lib/neutral/chunk-FZHVQEHN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs +50 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-EXAYCLIM.mjs → chunk-HPNQTEEQ.mjs} +5 -5
- package/dist/lib/neutral/chunk-HPNQTEEQ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YPIP3WGI.mjs → chunk-LVGOVFDV.mjs} +40 -12
- package/dist/lib/neutral/chunk-LVGOVFDV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MPAI2MHO.mjs +346 -0
- package/dist/lib/neutral/chunk-MPAI2MHO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-KB7RIVLK.mjs → chunk-N4B7FHQT.mjs} +4 -4
- package/dist/lib/neutral/{chunk-KB7RIVLK.mjs.map → chunk-N4B7FHQT.mjs.map} +2 -2
- package/dist/lib/neutral/chunk-O5LRY6CO.mjs +734 -0
- package/dist/lib/neutral/chunk-O5LRY6CO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VYEWMV5U.mjs → chunk-QGMIH2SN.mjs} +8 -4
- package/dist/lib/neutral/chunk-QGMIH2SN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QXIANHKU.mjs +206 -0
- package/dist/lib/neutral/chunk-QXIANHKU.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UMECVTXM.mjs → chunk-RF7ZBZ4A.mjs} +72 -5
- package/dist/lib/neutral/chunk-RF7ZBZ4A.mjs.map +7 -0
- package/dist/lib/neutral/chunk-S7IMFVTB.mjs +132 -0
- package/dist/lib/neutral/chunk-S7IMFVTB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SJKBWMJY.mjs +2436 -0
- package/dist/lib/neutral/chunk-SJKBWMJY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SUZMWP3Y.mjs +36 -0
- package/dist/lib/neutral/chunk-SUZMWP3Y.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-HQXQWXLH.mjs → chunk-SW5CUSBY.mjs} +183 -32
- package/dist/lib/neutral/chunk-SW5CUSBY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RIMHNJ3E.mjs → chunk-TNBK56IN.mjs} +98 -44
- package/dist/lib/neutral/chunk-TNBK56IN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7WE7SBA2.mjs → chunk-TRPZU2HV.mjs} +13 -13
- package/dist/lib/neutral/chunk-TRPZU2HV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ROKO4RKJ.mjs → chunk-TTCSATUD.mjs} +2 -2
- package/dist/lib/neutral/chunk-TTCSATUD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-V72DY6LU.mjs} +1 -1
- package/dist/lib/neutral/chunk-VGKLHHRT.mjs +318 -0
- package/dist/lib/neutral/chunk-VGKLHHRT.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TMLVKIMX.mjs → chunk-VYAGNFSJ.mjs} +8 -3
- package/dist/lib/neutral/chunk-VYAGNFSJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7YWDDFPH.mjs → chunk-WRVRDZDA.mjs} +77 -58
- package/dist/lib/neutral/chunk-WRVRDZDA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MXQJZCPY.mjs → chunk-ZISMEVKD.mjs} +1 -1
- package/dist/lib/neutral/chunk-ZISMEVKD.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +51 -28
- package/dist/lib/neutral/internal/index.mjs +52 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +199 -136
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +3 -3
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +20 -35
- 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 +54 -22
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +18 -18
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +182 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +34 -5
- 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/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 +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +57 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +109 -60
- 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 +105 -17
- 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 +86 -40
- 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 +2 -1
- 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/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +7 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +65 -2
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Annotation}/sorting.d.ts +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +2 -2
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api/entity.d.ts → Entity/api.d.ts} +2 -2
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/entity.d.ts +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 +2 -26
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +2 -2
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/relation.d.ts +3 -30
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Entity}/version.d.ts +1 -1
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +37 -37
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +2 -2
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/deleted.d.ts +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +13 -5
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/set-value.d.ts +2 -2
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/typed-object.d.ts +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/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +15 -2
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/compose.d.ts +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/echo-schema.d.ts +7 -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/{api → common/api}/meta.d.ts +3 -3
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts +2 -2
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{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 +5 -5
- 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/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 +9 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- 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 +47 -46
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -14
- package/src/Annotation.ts +7 -3
- package/src/Collection.ts +37 -0
- package/src/Database.ts +63 -64
- package/src/Dataset.ts +26 -0
- package/src/Entity.ts +87 -61
- package/src/Err.ts +2 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +304 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +85 -7
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +9 -4
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +102 -0
- package/src/JsonSchema.ts +14 -4
- package/src/Migration.ts +94 -0
- package/src/Obj.test.ts +112 -15
- package/src/Obj.ts +302 -166
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +372 -15
- package/src/Query.ts +269 -26
- package/src/Ref.ts +64 -11
- package/src/Relation.test.ts +8 -2
- package/src/Relation.ts +183 -147
- 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/exemplars.test.ts +21 -0
- package/src/index.ts +8 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +56 -7
- package/src/internal/{annotations → Annotation}/annotations.ts +122 -19
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -4
- package/src/internal/{annotations → Annotation}/util.ts +1 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +3 -2
- package/src/internal/{entities → Entity}/entity.ts +6 -4
- package/src/internal/{entities → Entity}/index.ts +2 -0
- package/src/internal/{entities → Entity}/model.ts +13 -42
- package/src/internal/{entities → Entity}/object.ts +2 -3
- package/src/internal/{entities → Entity}/relation.ts +19 -36
- package/src/internal/{api → Entity}/version.ts +2 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/format.test.ts +1 -2
- package/src/internal/{formats → Format}/types.ts +2 -2
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +4 -4
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +48 -49
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +6 -5
- package/src/internal/{object → Obj}/clone.ts +3 -3
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +5 -7
- package/src/internal/{object → Obj}/create-object.ts +5 -6
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/inspect.ts +2 -2
- package/src/internal/{object → Obj}/json-serializer.test.ts +31 -9
- package/src/internal/{object → Obj}/json-serializer.ts +52 -27
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +24 -24
- package/src/internal/{object → Obj}/set-value.ts +3 -3
- package/src/internal/{object → Obj}/snapshot.ts +35 -23
- package/src/internal/{object → Obj}/typed-object.test.ts +3 -3
- package/src/internal/{object → Obj}/typed-object.ts +4 -4
- package/src/internal/Query.ts +137 -0
- package/src/internal/{ref → Ref}/ref-array.ts +1 -2
- package/src/internal/{ref → Ref}/ref.test.ts +4 -5
- package/src/internal/{ref → Ref}/ref.ts +20 -3
- package/src/internal/{schema → Type}/compose.test.ts +5 -6
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/{schema → Type}/echo-schema.ts +9 -10
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +9 -4
- package/src/internal/{README.md → common/README.md} +2 -2
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/{api → common/api}/meta.ts +3 -3
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change-context.ts +1 -1
- package/src/internal/{proxy → common/proxy}/change.test.ts +97 -97
- package/src/internal/{proxy → common/proxy}/errors.ts +2 -2
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -4
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +6 -3
- package/src/internal/{proxy → common/proxy}/make-object.ts +1 -2
- package/src/internal/{proxy → common/proxy}/ownership.ts +0 -1
- package/src/internal/{proxy → common/proxy}/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/{proxy → common/proxy}/reactive.ts +12 -4
- package/src/internal/{proxy → common/proxy}/schema.test.ts +10 -10
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +6 -7
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +10 -13
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +5 -6
- package/src/internal/{types → common/types}/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 +3 -1
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +4 -5
- package/src/testing/test-data.ts +157 -98
- package/src/testing/test-schema.ts +20 -18
- package/dist/lib/neutral/chunk-7WE7SBA2.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7YWDDFPH.mjs.map +0 -7
- package/dist/lib/neutral/chunk-B4FLOYG7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EXAYCLIM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-F6BTBXL7.mjs +0 -171
- package/dist/lib/neutral/chunk-F6BTBXL7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HQXQWXLH.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MXQJZCPY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RCBBZLVM.mjs +0 -142
- package/dist/lib/neutral/chunk-RCBBZLVM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RIMHNJ3E.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TMLVKIMX.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UMECVTXM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VJ2H5MOJ.mjs +0 -3905
- package/dist/lib/neutral/chunk-VJ2H5MOJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VYEWMV5U.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-XAJMXQ4H.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YPIP3WGI.mjs.map +0 -7
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/api/annotations.d.ts +0 -23
- package/dist/types/src/internal/api/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/api/entity.d.ts.map +0 -1
- package/dist/types/src/internal/api/index.d.ts.map +0 -1
- package/dist/types/src/internal/api/meta.d.ts.map +0 -1
- package/dist/types/src/internal/api/sorting.d.ts.map +0 -1
- package/dist/types/src/internal/api/version.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/clone.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +0 -2
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change-context.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/errors.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/ownership.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/symbols.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/src/internal/api/annotations.ts +0 -60
- /package/dist/lib/neutral/{chunk-ANHVGJI4.mjs.map → chunk-7RVZT53K.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-OMUPQMLR.mjs.map → chunk-V72DY6LU.mjs.map} +0 -0
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/index.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/select.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/string.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/clone.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/ids.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/index.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/set-value.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/snapshot.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/index.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/define-hidden-property.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/event-batch.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/index.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/json-serializer.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/make-object.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/ownership.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-types.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-utils.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/symbols.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{types → common/types}/typename.d.ts +0 -0
- /package/src/internal/{entities → Entity}/util.ts +0 -0
- /package/src/internal/{formats → Format}/date.ts +0 -0
- /package/src/internal/{formats → Format}/format.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{formats → Format}/object.ts +0 -0
- /package/src/internal/{formats → Format}/select.ts +0 -0
- /package/src/internal/{formats → Format}/string.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +0 -0
- /package/src/internal/{object → Obj}/ids.ts +0 -0
- /package/src/internal/{object → Obj}/index.ts +0 -0
- /package/src/internal/{object → Obj}/schema-validator.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
- /package/src/internal/{schema → Type}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/define-hidden-property.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/event-batch.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
- /package/src/internal/{types → common/types}/typename.ts +0 -0
|
@@ -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';\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 { JsonPath, type JsonProp } 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(JsonPath, Schema.Array(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: 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: 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 { mapAst } from '@dxos/effect';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, ObjectId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { clearUndefined, orderKeys, removeProperties } from '@dxos/util';\n\nimport {\n type TypeAnnotation,\n TypeAnnotationId,\n TypeIdentifierAnnotationId,\n makeTypeJsonSchemaAnnotation,\n} from '../Annotation';\nimport { ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION, EntityKind, EntityKindSchema } 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,\n options: JsonSchemaOptions = {},\n): Types.DeepMutable<JsonSchemaType> => {\n assertArgument(Schema.isSchema(schema), 'schema');\n let jsonSchema = _toJsonSchemaAST(schema.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 = 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 = 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 (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.Object;\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 echoId = root.$id.startsWith('dxn:echo:') ? root.$id : undefined;\n return createEchoReferenceSchema(\n echoId,\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 targetSchemaDXN = DXN.parse(reference.schema.$ref);\n invariant(targetSchemaDXN.kind === DXN.kind.TYPE);\n\n return createEchoReferenceSchema(\n targetSchemaDXN.toString(),\n targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,\n reference.schemaVersion,\n );\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 const echoIdentifier = annotations[TypeIdentifierAnnotationId];\n if (echoIdentifier) {\n schemaFields[ECHO_ANNOTATIONS_NS_KEY] ??= {};\n schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = 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 // Limit to dxn:echo: URIs.\n if (schema.$id && schema.$id.startsWith('dxn:echo:')) {\n return schema.$id;\n } else if (schema.$id && schema.$id.startsWith('dxn:type:') && schema?.echo?.type?.schemaId) {\n const id = schema?.echo?.type?.schemaId;\n if (ObjectId.isValid(id)) {\n return DXN.fromLocalObjectId(id).toString();\n }\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.parse(source).toString();\n annotation.targetSchema = DXN.parse(target).toString();\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 identifier: typeIdentifier,\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,gBAA+B;AAWxC,IAAMC,cAAqBC,eAAQ,SAAS,WAAW,WAAW,QAAQ,UAAU,UAAU,QAAA;AAE9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encyAnnotationId", "DecodedAnnotations", "title", "TitleAnnotationId", "description", "DescriptionAnnotationId", "EchoAnnotations", "meta", "PropertyMetaAnnotationId", "generator", "GeneratorAnnotationId", "labelProp", "LabelAnnotationId", "Schema", "JsonPath", "SimpleTypes", "Literal", "NonNegativeInteger", "Number", "pipe", "greaterThanOrEqualTo", "StringArray", "Array", "String", "JsonSchemaOrBoolean", "Union", "suspend", "JsonSchemaType", "Boolean", "JsonSchemaEchoAnnotations", "Struct", "labelProp", "optional", "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", "mapAst", "assertArgument", "invariant", "DXN", "ObjectId", "log", "clearUndefined", "orderKeys", "removeProperties", "PropType", "jsonSchema", "_toJsonSchemaAST", "ast", "removeProperties", "key", "JSONSchema", "definitions", "normalizeJsonSchema", "withEchoRefinements", "suspendCache", "path", "recursiveResult", "suspendedAst", "cachedPath", "SchemaAST", "Suspend", "JSONSchemaAnnotationId", "propertyOrder", "propertySignatures", "annotationFields", "annotations_toJsonSchemaFields", "annotations", "addJsonSchemaFields", "_defs", "$defs", "objectToEffectSchema", "result", "root", "Union", "oneOf", "toEffectSchema", "v", "anyOf", "map", "defs", "length", "log", "Schema", "Tuple", "required", "optional", "invariant", "items", "Array", "isArray", "identifier", "refSegments", "ECHO_ANNOTATIONS_NS_DEPRECATED_KEY", "isEchoObject", "echoRefinement", "$id", "fields", "propertyList", "Object", "properties", "immutableIdField", "value", "schema", "String", "additionalProperties", "indexValue", "anyToEffectSchema", "reference", "createEchoReferenceSchema", "echoId", "Error", "targetSchemaDXN", "toString", "annotationId", "echoAnnotations", "schemaFields", "ECHO_ANNOTATIONS_NS_KEY", "echoIdentifier", "TypeIdentifierAnnotationId", "decodeTypeIdentifierAnnotation", "startsWith", "id", "ObjectId", "isValid", "DXN", "fromLocalObjectId", "decodeTypeAnnotation", "kind", "entityKind", "version", "annotation", "EntityKind", "target", "relationTarget", "$ref", "sourceSchema", "source", "targetSchema", "typename", "echo", "jsonSchemaFieldsToAnnotations", "getNormalizedEchoAnnotations", "EchoAnnotations", "typeAnnotation", "TypeAnnotationId", "typeIdentifier", "relationSource", "DecodedAnnotations", "makeAnnotatedRefinement", "orderKeys"]
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
JsonSchemaType,
|
|
3
3
|
toEffectSchema,
|
|
4
4
|
toJsonSchema
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-O5LRY6CO.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__export
|
|
8
8
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -11,13 +11,17 @@ import {
|
|
|
11
11
|
var JsonSchema_exports = {};
|
|
12
12
|
__export(JsonSchema_exports, {
|
|
13
13
|
JsonSchema: () => JsonSchema,
|
|
14
|
-
toEffectSchema: () =>
|
|
15
|
-
toJsonSchema: () =>
|
|
14
|
+
toEffectSchema: () => toEffectSchema2,
|
|
15
|
+
toJsonSchema: () => toJsonSchema2
|
|
16
16
|
});
|
|
17
|
+
var toEffectSchema2 = toEffectSchema;
|
|
18
|
+
var toJsonSchema2 = toJsonSchema;
|
|
17
19
|
var JsonSchema = JsonSchemaType;
|
|
18
20
|
|
|
19
21
|
export {
|
|
22
|
+
toEffectSchema2 as toEffectSchema,
|
|
23
|
+
toJsonSchema2 as toJsonSchema,
|
|
20
24
|
JsonSchema,
|
|
21
25
|
JsonSchema_exports
|
|
22
26
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-QGMIH2SN.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/JsonSchema.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport * as jsonSchemaInternal from './internal/JsonSchema';\n\n/**\n * Decode JSON Schema to Effect Schema.\n */\nexport const toEffectSchema = jsonSchemaInternal.toEffectSchema;\n\n/**\n * Encode Effect Schema to JSON Schema.\n */\nexport const toJsonSchema = jsonSchemaInternal.toJsonSchema;\n\n/**\n * Serializable JsonSchema type definition.\n */\nexport type JsonSchema = jsonSchemaInternal.JsonSchemaType;\n\nexport const JsonSchema: Schema.Schema<jsonSchemaInternal.JsonSchemaType> = jsonSchemaInternal.JsonSchemaType;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAAA;;;wBAAAA;EAAA,oBAAAC;;AAaO,IAAMC,kBAAoCA;AAK1C,IAAMC,gBAAkCA;AAOxC,IAAMC,aAAkFC;",
|
|
6
|
+
"names": ["toEffectSchema", "toJsonSchema", "toEffectSchema", "toJsonSchema", "JsonSchema", "JsonSchemaType"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import {
|
|
2
|
+
select
|
|
3
|
+
} from "./chunk-VGKLHHRT.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Feed
|
|
6
|
+
} from "./chunk-S7IMFVTB.mjs";
|
|
7
|
+
import {
|
|
8
|
+
object
|
|
9
|
+
} from "./chunk-FZHVQEHN.mjs";
|
|
10
|
+
import {
|
|
11
|
+
nothing
|
|
12
|
+
} from "./chunk-RF7ZBZ4A.mjs";
|
|
13
|
+
import {
|
|
14
|
+
Unknown,
|
|
15
|
+
instanceOf,
|
|
16
|
+
make
|
|
17
|
+
} from "./chunk-SW5CUSBY.mjs";
|
|
18
|
+
import {
|
|
19
|
+
Ref
|
|
20
|
+
} from "./chunk-VYAGNFSJ.mjs";
|
|
21
|
+
import {
|
|
22
|
+
JsonSchemaType
|
|
23
|
+
} from "./chunk-O5LRY6CO.mjs";
|
|
24
|
+
import {
|
|
25
|
+
FormInputAnnotation,
|
|
26
|
+
IconAnnotation,
|
|
27
|
+
SystemTypeAnnotation
|
|
28
|
+
} from "./chunk-TNBK56IN.mjs";
|
|
29
|
+
import {
|
|
30
|
+
__export
|
|
31
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
32
|
+
|
|
33
|
+
// src/index.ts
|
|
34
|
+
import { QueryAST as QueryAST2 } from "@dxos/echo-protocol";
|
|
35
|
+
import { DXN as DXN2 } from "@dxos/keys";
|
|
36
|
+
|
|
37
|
+
// src/Hypergraph.ts
|
|
38
|
+
var Hypergraph_exports = {};
|
|
39
|
+
|
|
40
|
+
// src/Json.ts
|
|
41
|
+
var Json_exports = {};
|
|
42
|
+
__export(Json_exports, {
|
|
43
|
+
createRefReplacer: () => createRefReplacer
|
|
44
|
+
});
|
|
45
|
+
import { DXN } from "@dxos/keys";
|
|
46
|
+
var isEncodedRef = (value) => typeof value === "object" && value !== null && Object.keys(value).length === 1 && typeof value["/"] === "string";
|
|
47
|
+
var toJson = (obj) => typeof obj.toJSON === "function" ? obj.toJSON() : obj;
|
|
48
|
+
var createRefReplacer = ({ db, depth = 1 }) => {
|
|
49
|
+
const hops = /* @__PURE__ */ new WeakMap();
|
|
50
|
+
return function(key, value) {
|
|
51
|
+
const parentHops = this && typeof this === "object" ? hops.get(this) ?? 0 : 0;
|
|
52
|
+
if (isEncodedRef(value)) {
|
|
53
|
+
if (parentHops >= depth) {
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
const dxnString = value["/"];
|
|
57
|
+
if (!dxnString.startsWith("dxn:")) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
let echoId;
|
|
61
|
+
try {
|
|
62
|
+
echoId = DXN.parse(dxnString).asEchoDXN()?.echoId;
|
|
63
|
+
} catch {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
if (!echoId) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
const target = db.getObjectById(echoId);
|
|
70
|
+
if (!target) {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
const encoded = toJson(target);
|
|
74
|
+
if (encoded != null && typeof encoded === "object") {
|
|
75
|
+
hops.set(encoded, parentHops + 1);
|
|
76
|
+
}
|
|
77
|
+
return encoded;
|
|
78
|
+
}
|
|
79
|
+
if (value != null && typeof value === "object") {
|
|
80
|
+
hops.set(value, parentHops);
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/Collection.ts
|
|
87
|
+
var Collection_exports = {};
|
|
88
|
+
__export(Collection_exports, {
|
|
89
|
+
Collection: () => Collection,
|
|
90
|
+
isCollection: () => isCollection,
|
|
91
|
+
make: () => make2
|
|
92
|
+
});
|
|
93
|
+
import * as Schema from "effect/Schema";
|
|
94
|
+
var Collection = Schema.Struct({
|
|
95
|
+
name: Schema.String.pipe(Schema.optional),
|
|
96
|
+
objects: Schema.Array(Ref(Unknown)).pipe(FormInputAnnotation.set(false))
|
|
97
|
+
}).pipe(object({
|
|
98
|
+
typename: "org.dxos.type.collection",
|
|
99
|
+
version: "0.1.0"
|
|
100
|
+
}), IconAnnotation.set({
|
|
101
|
+
icon: "ph--folder--regular",
|
|
102
|
+
hue: "amber"
|
|
103
|
+
}));
|
|
104
|
+
var make2 = (props = {}) => make(Collection, {
|
|
105
|
+
objects: [],
|
|
106
|
+
...props
|
|
107
|
+
});
|
|
108
|
+
var isCollection = instanceOf(Collection);
|
|
109
|
+
|
|
110
|
+
// src/View.ts
|
|
111
|
+
var View_exports = {};
|
|
112
|
+
__export(View_exports, {
|
|
113
|
+
FieldSchema: () => FieldSchema,
|
|
114
|
+
KeyValueProps: () => KeyValueProps,
|
|
115
|
+
Projection: () => Projection,
|
|
116
|
+
View: () => View,
|
|
117
|
+
createFieldId: () => createFieldId,
|
|
118
|
+
make: () => make3
|
|
119
|
+
});
|
|
120
|
+
import * as Schema2 from "effect/Schema";
|
|
121
|
+
import { QueryAST } from "@dxos/echo-protocol";
|
|
122
|
+
import { JsonPath } from "@dxos/effect";
|
|
123
|
+
import { PublicKey } from "@dxos/keys";
|
|
124
|
+
var FieldSchema = Schema2.Struct({
|
|
125
|
+
id: Schema2.String,
|
|
126
|
+
path: JsonPath,
|
|
127
|
+
visible: Schema2.optional(Schema2.Boolean),
|
|
128
|
+
// TODO(wittjosiah): Presentation-specific?
|
|
129
|
+
referencePath: Schema2.optional(JsonPath)
|
|
130
|
+
});
|
|
131
|
+
var KeyValueProps = Schema2.Record({
|
|
132
|
+
key: Schema2.String,
|
|
133
|
+
value: Schema2.Any
|
|
134
|
+
});
|
|
135
|
+
var createFieldId = () => PublicKey.random().truncate();
|
|
136
|
+
var Projection = Schema2.Struct({
|
|
137
|
+
/**
|
|
138
|
+
* Optional schema override used to customize the underlying schema.
|
|
139
|
+
*/
|
|
140
|
+
schema: JsonSchemaType.pipe(Schema2.optional),
|
|
141
|
+
/**
|
|
142
|
+
* UX metadata associated with displayed fields (in table, form, etc.)
|
|
143
|
+
*/
|
|
144
|
+
// TODO(wittjosiah): Should this just be an array of JsonPath?
|
|
145
|
+
fields: Schema2.Array(FieldSchema),
|
|
146
|
+
/**
|
|
147
|
+
* The id for the field used to pivot the view.
|
|
148
|
+
* E.g., the field to use for kanban columns or the field to use for map coordinates.
|
|
149
|
+
*/
|
|
150
|
+
pivotFieldId: Schema2.String.pipe(Schema2.optional)
|
|
151
|
+
});
|
|
152
|
+
var ViewSchema = Schema2.Struct({
|
|
153
|
+
/**
|
|
154
|
+
* Query used to retrieve data.
|
|
155
|
+
* Can be a user-provided query grammar string or a query AST.
|
|
156
|
+
*/
|
|
157
|
+
query: Schema2.Struct({
|
|
158
|
+
raw: Schema2.optional(Schema2.String),
|
|
159
|
+
ast: QueryAST.Query
|
|
160
|
+
}),
|
|
161
|
+
/**
|
|
162
|
+
* Projection of the data returned from the query.
|
|
163
|
+
*/
|
|
164
|
+
projection: Projection
|
|
165
|
+
}).pipe(object({
|
|
166
|
+
typename: "org.dxos.type.view",
|
|
167
|
+
version: "0.1.0"
|
|
168
|
+
}), SystemTypeAnnotation.set(true), IconAnnotation.set({
|
|
169
|
+
icon: "ph--funnel--regular",
|
|
170
|
+
hue: "green"
|
|
171
|
+
}));
|
|
172
|
+
var View = ViewSchema;
|
|
173
|
+
var make3 = (props) => {
|
|
174
|
+
return make(View, {
|
|
175
|
+
query: {
|
|
176
|
+
ast: select(nothing()).ast
|
|
177
|
+
},
|
|
178
|
+
projection: {
|
|
179
|
+
fields: []
|
|
180
|
+
},
|
|
181
|
+
...props
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/Dataset.ts
|
|
186
|
+
var Dataset_exports = {};
|
|
187
|
+
__export(Dataset_exports, {
|
|
188
|
+
Dataset: () => Dataset,
|
|
189
|
+
isDataset: () => isDataset
|
|
190
|
+
});
|
|
191
|
+
import { pipe } from "effect/Function";
|
|
192
|
+
import * as Predicate from "effect/Predicate";
|
|
193
|
+
import * as Schema3 from "effect/Schema";
|
|
194
|
+
var Dataset = Schema3.Union(Feed, Collection, View);
|
|
195
|
+
var isDataset = pipe(instanceOf(Feed), Predicate.or(instanceOf(Collection)), Predicate.or(instanceOf(View)));
|
|
196
|
+
|
|
197
|
+
export {
|
|
198
|
+
Hypergraph_exports,
|
|
199
|
+
Json_exports,
|
|
200
|
+
Collection_exports,
|
|
201
|
+
View_exports,
|
|
202
|
+
Dataset_exports,
|
|
203
|
+
QueryAST2 as QueryAST,
|
|
204
|
+
DXN2 as DXN
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=chunk-QXIANHKU.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/Hypergraph.ts", "../../../src/Json.ts", "../../../src/Collection.ts", "../../../src/View.ts", "../../../src/Dataset.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { QueryAST } from '@dxos/echo-protocol';\n// TODO(wittjosiah): Refactor DXN to not use statics similar to Query.\nexport { DXN } from '@dxos/keys';\n\nexport * as Annotation from './Annotation';\nexport * as Database from './Database';\nexport * as Entity from './Entity';\n// TODO(burdon): Rename to Error (less problematic than Obj/Object).\nexport * as Err from './Err';\nexport * as Feed from './Feed';\nexport * as Filter from './Filter';\nexport * as Format from './Format';\nexport * as Hypergraph from './Hypergraph';\nexport * as Json from './Json';\nexport * as JsonSchema from './JsonSchema';\nexport * as Key from './Key';\nexport * as Migration from './Migration';\nexport * as Obj from './Obj';\nexport * as Order from './Order';\nexport * as Query from './Query';\nexport * as QueryResult from './QueryResult';\nexport * as Ref from './Ref';\nexport * as Relation from './Relation';\nexport * as SchemaRegistry from './SchemaRegistry';\nexport * as Tag from './Tag';\nexport * as Type from './Type';\nexport * as Collection from './Collection';\nexport * as View from './View';\nexport * as Dataset from './Dataset';\nexport * as Extension from './Extension';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type DXN } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as Entity from './Entity';\nimport type * as internal from './internal';\nimport type * as Key from './Key';\nimport type * as Ref from './Ref';\nimport type * as SchemaRegistry from './SchemaRegistry';\n\n/**\n * Resolution context.\n * Affects how non-absolute DXNs are resolved.\n */\nexport interface RefResolutionContext {\n /**\n * Space that the resolution is happening from.\n */\n space?: Key.SpaceId;\n\n /**\n * Queue that the resolution is happening from.\n * This queue will be searched first, and then the space it belongs to.\n */\n queue?: DXN;\n}\n\nexport interface RefResolverOptions {\n /**\n * Resolution context.\n * Affects how non-absolute DXNs are resolved.\n */\n context?: RefResolutionContext;\n\n /**\n * Middleware to change the resolved object before returning it.\n * @deprecated On track to be removed.\n */\n middleware?: (obj: internal.AnyProperties) => internal.AnyProperties;\n}\n\n/**\n * Manages cross-space database interactions.\n */\nexport interface Hypergraph extends Database.Queryable {\n get schemaRegistry(): SchemaRegistry.SchemaRegistry;\n\n /**\n * Query objects.\n */\n query: Database.QueryFn;\n\n /**\n * Creates a reference to an existing object in the database.\n *\n * NOTE: The reference may be dangling if the object is not present in the database.\n * NOTE: Difference from `Ref.fromDXN`\n * `Ref.fromDXN(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.\n * `db.makeRef(dxn)` is preferable in cases with access to the database.\n */\n makeRef<T extends Entity.Unknown = Entity.Unknown>(dxn: DXN): Ref.Ref<T>;\n\n /**\n * @param hostDb Host database for reference resolution.\n * @param middleware Called with the loaded object. The caller may change the object.\n * @returns Result of `onLoad`.\n */\n // TODO(dmaretskyi): Restructure API: Remove middleware.\n createRefResolver(options: RefResolverOptions): Ref.Resolver;\n\n /**\n * Get a database by space ID.\n * @returns The database for the given space ID, or undefined if not found.\n */\n getDatabase(spaceId: Key.SpaceId): Database.Database | undefined;\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Database from './Database';\nimport * as Obj from './Obj';\n\n/**\n * `JSON.stringify` replacer signature.\n *\n * Defined here (rather than re-imported from a UI package) so other ECHO-aware utilities can\n * share a stable signature without creating a dependency edge into the UI tree.\n */\nexport type JsonReplacer = (key: string, value: any) => any;\n\nexport type CreateRefReplacerOptions = {\n db: Database.Database;\n /** How many ref hops to follow. `0` leaves all refs as-is. Default: `1`. */\n depth?: number;\n};\n\nconst isEncodedRef = (value: unknown): value is { '/': string } =>\n typeof value === 'object' &&\n value !== null &&\n Object.keys(value as object).length === 1 &&\n typeof (value as { '/': unknown })['/'] === 'string';\n\nconst toJson = (obj: Obj.Any): unknown => (typeof (obj as any).toJSON === 'function' ? (obj as any).toJSON() : obj);\n\n/**\n * Returns a {@link JsonReplacer} that inlines ECHO ref objects (`{ \"/\": \"dxn:echo:...\" }`) up to\n * `depth` ref hops. Beyond that depth refs are left in their encoded form.\n *\n * Implemented as a per-call `JSON.stringify` replacer (not a one-shot tree walk at root) so it\n * composes with wrappers like `safeStringify` that intercept the root call. JSON.stringify\n * already drives the recursion; we only need to (a) detect a ref at the current callback,\n * (b) resolve and return the target if hop budget remains, and (c) tag the returned object\n * with its hop count so children know how far in they are.\n *\n * The hop count is tracked per-object via a `WeakMap`: a ref-resolved target's children inherit\n * `parentHops + 1`; a regular intermediate object's children inherit `parentHops`. This makes the\n * budget count *ref hops*, not tree depth — a ref deep in a tree still resolves once when\n * `depth >= 1`.\n *\n * Note: ECHO objects' `toJSON` runs before the replacer is invoked, so by the time we see a\n * value refs are already encoded as `{ \"/\": \"dxn:...\" }`.\n */\nexport const createRefReplacer = ({ db, depth = 1 }: CreateRefReplacerOptions): JsonReplacer => {\n // Per-object hop count. Set when we return an object (via ref resolution or pass-through) so\n // the child callbacks (which carry that object as `this`) can read it.\n const hops = new WeakMap<object, number>();\n\n return function (this: any, key: string, value: any) {\n // Hop count for this call: hops at the parent, or 0 for the root.\n const parentHops = this && typeof this === 'object' ? (hops.get(this) ?? 0) : 0;\n if (isEncodedRef(value)) {\n if (parentHops >= depth) {\n return value;\n }\n\n // The `{ '/': string }` shape is shared with non-DXN IPLD-style refs (e.g. CIDs);\n // an unparseable string would otherwise crash the whole `JSON.stringify`.\n // Treat any parse miss as \"leave as-is\" rather than propagating.\n const dxnString = value['/'];\n if (!dxnString.startsWith('dxn:')) {\n return value;\n }\n\n let echoId: string | undefined;\n try {\n echoId = DXN.parse(dxnString).asEchoDXN()?.echoId;\n } catch {\n return value;\n }\n\n if (!echoId) {\n return value;\n }\n const target = db.getObjectById(echoId);\n if (!target) {\n return value;\n }\n\n const encoded = toJson(target);\n if (encoded != null && typeof encoded === 'object') {\n // Children of the resolved target are one hop deeper.\n hops.set(encoded as object, parentHops + 1);\n }\n return encoded;\n }\n\n // Pass-through object: children inherit the parent's hop count (this branch doesn't burn\n // budget).\n if (value != null && typeof value === 'object') {\n hops.set(value, parentHops);\n }\n\n return value;\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Annotation from './Annotation';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport * as Ref from './Ref';\nimport * as Type from './Type';\n\n/**\n * A an ordered set of objects.\n */\nexport const Collection = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n objects: Schema.Array(Ref.Ref(Obj.Unknown)).pipe(internal.FormInputAnnotation.set(false)),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.collection',\n version: '0.1.0',\n }),\n Annotation.IconAnnotation.set({\n icon: 'ph--folder--regular',\n hue: 'amber',\n }),\n);\n\nexport interface Collection extends Schema.Schema.Type<typeof Collection> {}\n\nexport const make = (props: Partial<Obj.MakeProps<typeof Collection>> = {}): Collection =>\n Obj.make(Collection, { objects: [], ...props });\n\nexport const isCollection: (value: unknown) => value is Collection = Obj.instanceOf(Collection);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { QueryAST } from '@dxos/echo-protocol';\nimport { JsonPath } from '@dxos/effect';\nimport { PublicKey } from '@dxos/keys';\n\nimport * as Annotation from './Annotation';\nimport * as Filter from './Filter';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport * as Query from './Query';\nimport * as Type from './Type';\n\n/**\n * Stored field metadata (e.g., for UX).\n */\nexport const FieldSchema = Schema.Struct({\n id: Schema.String,\n path: JsonPath,\n visible: Schema.optional(Schema.Boolean),\n\n // TODO(wittjosiah): Presentation-specific?\n referencePath: Schema.optional(JsonPath),\n});\n\nexport type FieldType = Schema.Schema.Type<typeof FieldSchema>;\n\nexport const KeyValueProps = Schema.Record({ key: Schema.String, value: Schema.Any });\n\nexport const createFieldId = () => PublicKey.random().truncate();\n\nexport const Projection = Schema.Struct({\n /**\n * Optional schema override used to customize the underlying schema.\n */\n schema: internal.JsonSchemaType.pipe(Schema.optional),\n\n /**\n * UX metadata associated with displayed fields (in table, form, etc.)\n */\n // TODO(wittjosiah): Should this just be an array of JsonPath?\n fields: Schema.Array(FieldSchema),\n\n /**\n * The id for the field used to pivot the view.\n * E.g., the field to use for kanban columns or the field to use for map coordinates.\n */\n pivotFieldId: Schema.String.pipe(Schema.optional),\n});\n\nexport type Projection = Schema.Schema.Type<typeof Projection>;\n\n/**\n * Views are generated or user-defined projections of a schema's properties.\n * They are used to configure the visual representation of the data.\n */\nconst ViewSchema = Schema.Struct({\n /**\n * Query used to retrieve data.\n * Can be a user-provided query grammar string or a query AST.\n */\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }),\n\n /**\n * Projection of the data returned from the query.\n */\n projection: Projection,\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.view',\n version: '0.1.0',\n }),\n internal.SystemTypeAnnotation.set(true),\n Annotation.IconAnnotation.set({\n icon: 'ph--funnel--regular',\n hue: 'green',\n }),\n);\n\nexport interface View extends Schema.Schema.Type<typeof ViewSchema> {}\n\n/**\n * View instance type.\n */\n// NOTE: This interface is explicitly defined rather than derived from the schema to avoid\n// TypeScript \"cannot be named\" portability errors. The schema contains QueryAST.Query which\n// references internal @dxos/echo-protocol module paths. Without this explicit interface,\n// any schema using Ref.Ref(View) would inherit the non-portable type and fail to compile.\n// TODO(wittjosiah): Find a better solution that doesn't require manually keeping the interface in sync.\nexport const View: Type.Obj<View> = ViewSchema as any;\n\nexport const make = (props: Partial<Obj.MakeProps<typeof View>>): View => {\n return Obj.make(View, {\n query: { ast: Query.select(Filter.nothing()).ast },\n projection: { fields: [] },\n ...props,\n });\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { pipe } from 'effect/Function';\nimport * as Predicate from 'effect/Predicate';\nimport * as Schema from 'effect/Schema';\n\nimport * as Collection from './Collection';\nimport * as Feed from './Feed';\nimport * as Obj from './Obj';\nimport * as View from './View';\n\n/**\n * Abstart set of objects, represented by a view, feed, or collection.\n */\nexport const Dataset = Schema.Union(Feed.Feed, Collection.Collection, View.View);\nexport type Dataset = Feed.Feed | Collection.Collection | View.View;\n\nexport const isDataset: (value: unknown) => value is Dataset = pipe(\n Obj.instanceOf(Feed.Feed),\n Predicate.or(Obj.instanceOf(Collection.Collection)),\n Predicate.or(Obj.instanceOf(View.View)),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,YAAAA,iBAAgB;AAEzB,SAASC,OAAAA,YAAW;;;ACNpB;;;ACAA;;;;AAIA,SAASC,WAAW;AAmBpB,IAAMC,eAAe,CAACC,UACpB,OAAOA,UAAU,YACjBA,UAAU,QACVC,OAAOC,KAAKF,KAAAA,EAAiBG,WAAW,KACxC,OAAQH,MAA2B,GAAA,MAAS;AAE9C,IAAMI,SAAS,CAACC,QAA2B,OAAQA,IAAYC,WAAW,aAAcD,IAAYC,OAAM,IAAKD;AAoBxG,IAAME,oBAAoB,CAAC,EAAEC,IAAIC,QAAQ,EAAC,MAA4B;AAG3E,QAAMC,OAAO,oBAAIC,QAAAA;AAEjB,SAAO,SAAqBC,KAAaZ,OAAU;AAEjD,UAAMa,aAAa,QAAQ,OAAO,SAA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AgBH,IAAI,CAAA,CAAA;",
|
|
6
|
+
"names": ["QueryAST", "DXN", "DXN", "isEncodedRef", "value", "Object", "keys", "length", "toJson", "obj", "toJSON", "createRefReplacer", "db", "depth", "hops", "WeakMap", "key", "parentHops", "get", "dxnString", "startsWith", "echoId", "parse", "asEchoDXN", "target", "getObjectById", "encoded", "set", "make", "Schema", "Collection", "Struct", "name", "String", "pipe", "optional", "objects", "Array", "Ref", "Unknown", "FormInputAnnotation", "set", "object", "typename", "version", "IconAnnotation", "icon", "hue", "make", "props", "isCollection", "instanceOf", "make", "Schema", "QueryAST", "JsonPath", "PublicKey", "FieldSchema", "Struct", "id", "String", "path", "JsonPath", "visible", "optional", "Boolean", "referencePath", "KeyValueProps", "Record", "key", "value", "Any", "createFieldId", "PublicKey", "random", "truncate", "Projection", "schema", "JsonSchemaType", "pipe", "fields", "Array", "pivotFieldId", "ViewSchema", "query", "raw", "ast", "QueryAST", "Query", "projection", "object", "typename", "version", "SystemTypeAnnotation", "set", "IconAnnotation", "icon", "hue", "View", "make", "props", "select", "nothing", "pipe", "Predicate", "Schema", "Dataset", "Union", "Feed", "Collection", "View", "isDataset", "pipe", "instanceOf", "or"]
|
|
7
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isRef
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VYAGNFSJ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getDXN,
|
|
6
|
+
prettyFilter
|
|
7
|
+
} from "./chunk-SJKBWMJY.mjs";
|
|
4
8
|
import {
|
|
5
9
|
getTypeDXNFromSpecifier
|
|
6
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TNBK56IN.mjs";
|
|
7
11
|
import {
|
|
8
12
|
__export
|
|
9
13
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -13,7 +17,9 @@ var Filter_exports = {};
|
|
|
13
17
|
__export(Filter_exports, {
|
|
14
18
|
and: () => and,
|
|
15
19
|
between: () => between,
|
|
20
|
+
childOf: () => childOf,
|
|
16
21
|
contains: () => contains,
|
|
22
|
+
created: () => created,
|
|
17
23
|
eq: () => eq,
|
|
18
24
|
everything: () => everything,
|
|
19
25
|
foreignKeys: () => foreignKeys,
|
|
@@ -29,20 +35,23 @@ __export(Filter_exports, {
|
|
|
29
35
|
not: () => not,
|
|
30
36
|
nothing: () => nothing,
|
|
31
37
|
or: () => or,
|
|
38
|
+
pretty: () => pretty,
|
|
32
39
|
props: () => props,
|
|
33
40
|
tag: () => tag,
|
|
34
41
|
text: () => text,
|
|
35
42
|
type: () => type,
|
|
36
43
|
typeDXN: () => typeDXN,
|
|
37
|
-
typename: () => typename
|
|
44
|
+
typename: () => typename,
|
|
45
|
+
updated: () => updated
|
|
38
46
|
});
|
|
39
47
|
import * as Match from "effect/Match";
|
|
40
48
|
import * as Schema from "effect/Schema";
|
|
49
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
41
50
|
import { assertArgument } from "@dxos/invariant";
|
|
42
51
|
import { DXN, ObjectId } from "@dxos/keys";
|
|
43
52
|
var FilterClass = class _FilterClass {
|
|
44
53
|
ast;
|
|
45
|
-
static variance = {};
|
|
54
|
+
static "variance" = {};
|
|
46
55
|
constructor(ast) {
|
|
47
56
|
this.ast = ast;
|
|
48
57
|
}
|
|
@@ -84,6 +93,17 @@ var id = (...ids) => {
|
|
|
84
93
|
});
|
|
85
94
|
};
|
|
86
95
|
var type = (schema, props2) => {
|
|
96
|
+
if (Schema.isSchema(schema) && SchemaAST.isUnion(schema.ast)) {
|
|
97
|
+
const typenames = schema.ast.types.map((type2) => getTypeDXNFromSpecifier(Schema.make(type2)));
|
|
98
|
+
return new FilterClass({
|
|
99
|
+
type: "or",
|
|
100
|
+
filters: typenames.map((typename2) => ({
|
|
101
|
+
type: "object",
|
|
102
|
+
typename: typename2.toString(),
|
|
103
|
+
props: {}
|
|
104
|
+
}))
|
|
105
|
+
});
|
|
106
|
+
}
|
|
87
107
|
const dxn = getTypeDXNFromSpecifier(schema);
|
|
88
108
|
return new FilterClass({
|
|
89
109
|
type: "object",
|
|
@@ -199,6 +219,48 @@ var between = (from, to) => {
|
|
|
199
219
|
to
|
|
200
220
|
});
|
|
201
221
|
};
|
|
222
|
+
var _toUnixMs = (date) => typeof date === "number" ? date : date.getTime();
|
|
223
|
+
var _timeRangeFilter = (field, range) => {
|
|
224
|
+
const filters = [];
|
|
225
|
+
if (range.after != null) {
|
|
226
|
+
filters.push(new FilterClass({
|
|
227
|
+
type: "timestamp",
|
|
228
|
+
field,
|
|
229
|
+
operator: "gte",
|
|
230
|
+
value: _toUnixMs(range.after)
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
if (range.before != null) {
|
|
234
|
+
filters.push(new FilterClass({
|
|
235
|
+
type: "timestamp",
|
|
236
|
+
field,
|
|
237
|
+
operator: "lte",
|
|
238
|
+
value: _toUnixMs(range.before)
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
if (filters.length === 0) {
|
|
242
|
+
return everything();
|
|
243
|
+
}
|
|
244
|
+
return filters.length === 1 ? filters[0] : and(...filters);
|
|
245
|
+
};
|
|
246
|
+
var updated = (range) => _timeRangeFilter("updatedAt", range);
|
|
247
|
+
var created = (range) => _timeRangeFilter("createdAt", range);
|
|
248
|
+
var childOf = (parents, options) => {
|
|
249
|
+
const items = Array.isArray(parents) ? parents : [
|
|
250
|
+
parents
|
|
251
|
+
];
|
|
252
|
+
const dxns = items.map((item) => {
|
|
253
|
+
if (isRef(item)) {
|
|
254
|
+
return item.dxn.toString();
|
|
255
|
+
}
|
|
256
|
+
return getDXN(item).toString();
|
|
257
|
+
});
|
|
258
|
+
return new FilterClass({
|
|
259
|
+
type: "child-of",
|
|
260
|
+
parents: dxns,
|
|
261
|
+
transitive: options?.transitive ?? true
|
|
262
|
+
});
|
|
263
|
+
};
|
|
202
264
|
var not = (filter) => {
|
|
203
265
|
return new FilterClass({
|
|
204
266
|
type: "not",
|
|
@@ -256,6 +318,7 @@ var processPredicate = (predicate) => {
|
|
|
256
318
|
Match.orElse((value2) => eq(value2).ast)
|
|
257
319
|
);
|
|
258
320
|
};
|
|
321
|
+
var pretty = (filter) => prettyFilter(filter.ast);
|
|
259
322
|
|
|
260
323
|
export {
|
|
261
324
|
is,
|
|
@@ -279,9 +342,13 @@ export {
|
|
|
279
342
|
in$,
|
|
280
343
|
contains,
|
|
281
344
|
between,
|
|
345
|
+
updated,
|
|
346
|
+
created,
|
|
347
|
+
childOf,
|
|
282
348
|
not,
|
|
283
349
|
and,
|
|
284
350
|
or,
|
|
351
|
+
pretty,
|
|
285
352
|
Filter_exports
|
|
286
353
|
};
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
354
|
+
//# sourceMappingURL=chunk-RF7ZBZ4A.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Filter.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport type * as Types from 'effect/Types';\n\nimport { type ForeignKey, type QueryAST } from '@dxos/echo-protocol';\nimport { assertArgument } from '@dxos/invariant';\nimport { DXN, ObjectId } from '@dxos/keys';\n\nimport * as internal from './internal';\nimport type * as Obj from './Obj';\nimport * as Ref from './Ref';\n\nexport interface Filter<T> {\n // TODO(dmaretskyi): See new effect-schema approach to variance.\n '~Filter': { value: Types.Covariant<T> };\n\n ast: QueryAST.Filter;\n}\n\nexport type Props<T> = {\n // Predicate or a value as a shorthand for `eq`.\n [K in keyof T & string]?: Filter<T[K]> | T[K];\n};\n\nexport type Any = Filter<any>;\n\nexport type Type<F extends Any> = F extends Filter<infer T> ? T : never;\n\nclass FilterClass implements Any {\n private static 'variance': Any['~Filter'] = {} as Any['~Filter'];\n\n constructor(public readonly ast: QueryAST.Filter) {}\n\n '~Filter' = FilterClass.variance;\n}\n\nexport const is = (value: unknown): value is Any => {\n return typeof value === 'object' && value !== null && '~Filter' in value;\n};\n\n/** Construct a filter from an ast. */\nexport const fromAst = (ast: QueryAST.Filter): Any => {\n return new FilterClass(ast);\n};\n\n/**\n * Filter that matches all objects.\n */\n// TODO(dmaretskyi): `Entity.Any` would be more type-safe, but causes annoying errors in existing code\nexport const everything = (): FilterClass => {\n return new FilterClass({\n type: 'object',\n typename: null,\n props: {},\n });\n};\n\n/**\n * Filter that matches no objects.\n */\nexport const nothing = (): FilterClass => {\n return new FilterClass({\n type: 'not',\n filter: {\n type: 'object',\n typename: null,\n props: {},\n },\n });\n};\n\n/*\n * Filter by ObjectId.\n */\nexport const id = (...ids: ObjectId[]): Any => {\n assertArgument(\n ids.every((id) => ObjectId.isValid(id)),\n 'ids',\n 'ids must be valid',\n );\n\n if (ids.length === 0) {\n return nothing();\n }\n\n return new FilterClass({\n type: 'object',\n typename: null,\n id: ids,\n props: {},\n });\n};\n\n/**\n * Filter by type.\n */\nexport const type = <S extends Schema.Schema.All>(\n schema: S | string,\n props?: Props<Schema.Schema.Type<S>>,\n): Filter<Schema.Schema.Type<S>> => {\n if (Schema.isSchema(schema) && SchemaAST.isUnion(schema.ast)) {\n const typenames = schema.ast.types.map((type) => internal.getTypeDXNFromSpecifier(Schema.make(type)));\n return new FilterClass({\n type: 'or',\n filters: typenames.map((typename) => ({\n type: 'object',\n typename: typename.toString(),\n props: {},\n })),\n });\n }\n\n const dxn = internal.getTypeDXNFromSpecifier(schema);\n return new FilterClass({\n type: 'object',\n typename: dxn.toString(),\n ...propsFilterToAst(props ?? {}),\n });\n};\n\n/**\n * Filter by non-qualified typename.\n */\nexport const typename = (typename: string): Any => {\n assertArgument(!typename.startsWith('dxn:'), 'typename', 'Typename must no be qualified');\n return new FilterClass({\n type: 'object',\n typename: DXN.fromTypename(typename).toString(),\n props: {},\n });\n};\n\n/**\n * Filter by fully qualified type DXN.\n */\nexport const typeDXN = (dxn: DXN): Any => {\n return new FilterClass({\n type: 'object',\n typename: dxn.toString(),\n props: {},\n });\n};\n\n/**\n * Filter by tag.\n */\nexport const tag = (tag: string): Any => {\n return new FilterClass({\n type: 'tag',\n tag,\n });\n};\n\n/**\n * Filter by properties.\n */\nexport const props = <T>(props: Props<T>): Filter<T> => {\n return new FilterClass({\n type: 'object',\n typename: null,\n ...propsFilterToAst(props),\n });\n};\n\nexport type TextSearchOptions = {\n // TODO(dmaretskyi): Hybrid search.\n type?: 'full-text' | 'vector';\n};\n\n/**\n * Full-text or vector search.\n */\nexport const text = (\n // TODO(dmaretskyi): Consider passing a vector here, but really the embedding should be done on the query-executor side.\n text: string,\n options?: TextSearchOptions,\n): Any => {\n return new FilterClass({\n type: 'text-search',\n text,\n searchKind: options?.type,\n });\n};\n\n/**\n * Filter by foreign keys.\n */\nexport const foreignKeys = <S extends Schema.Schema.All>(\n schema: S | string,\n keys: ForeignKey[],\n): Filter<Schema.Schema.Type<S>> => {\n const dxn = internal.getTypeDXNFromSpecifier(schema);\n return new FilterClass({\n type: 'object',\n typename: dxn.toString(),\n props: {},\n foreignKeys: keys,\n });\n};\n\n/**\n * Predicate for property to be equal to the provided value.\n */\nexport const eq = <T>(value: T): Filter<T | undefined> => {\n if (!Ref.isRef(value) && typeof value === 'object' && value !== null) {\n throw new TypeError('Cannot use object as a value for eq filter');\n }\n\n return new FilterClass({\n type: 'compare',\n operator: 'eq',\n value: Ref.isRef(value) ? value.noInline().encode() : value,\n });\n};\n\n/**\n * Predicate for property to be not equal to the provided value.\n */\nexport const neq = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'neq',\n value,\n });\n};\n\n/**\n * Predicate for property to be greater than the provided value.\n */\nexport const gt = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'gt',\n value,\n });\n};\n\n/**\n * Predicate for property to be greater than or equal to the provided value.\n */\nexport const gte = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'gte',\n value,\n });\n};\n\n/**\n * Predicate for property to be less than the provided value.\n */\nexport const lt = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'lt',\n value,\n });\n};\n\n/**\n * Predicate for property to be less than or equal to the provided value.\n */\nexport const lte = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'lte',\n value,\n });\n};\n\n/**\n * Predicate for property to be in the provided array.\n * @param values - Values to check against.\n */\nconst in$ = <T>(...values: T[]): Filter<T> => {\n return new FilterClass({\n type: 'in',\n values,\n });\n};\nexport { in$ as in };\n\n/**\n * Predicate for an array property to contain the provided value.\n * @param value - Value to check against.\n */\nexport const contains = <T>(value: T): Filter<readonly T[] | undefined> => {\n return new FilterClass({\n type: 'contains',\n value,\n });\n};\n\n/**\n * Predicate for property to be in the provided range.\n * @param from - Start of the range (inclusive).\n * @param to - End of the range (exclusive).\n */\nexport const between = <T>(from: T, to: T): Filter<T> => {\n return new FilterClass({\n type: 'range',\n from,\n to,\n });\n};\n\ntype TimeRange = { after?: Date | number; before?: Date | number };\n\nconst _toUnixMs = (date: Date | number): number => (typeof date === 'number' ? date : date.getTime());\n\nconst _timeRangeFilter = (field: 'updatedAt' | 'createdAt', range: TimeRange): Any => {\n const filters: Any[] = [];\n if (range.after != null) {\n filters.push(new FilterClass({ type: 'timestamp', field, operator: 'gte', value: _toUnixMs(range.after) }));\n }\n if (range.before != null) {\n filters.push(new FilterClass({ type: 'timestamp', field, operator: 'lte', value: _toUnixMs(range.before) }));\n }\n if (filters.length === 0) {\n return everything();\n }\n return filters.length === 1 ? filters[0] : and(...filters);\n};\n\n/**\n * Filter objects by updatedAt timestamp.\n */\nexport const updated = (range: TimeRange): Any => _timeRangeFilter('updatedAt', range);\n\n/**\n * Filter objects by createdAt timestamp.\n */\nexport const created = (range: TimeRange): Any => _timeRangeFilter('createdAt', range);\n\nexport type ChildOfOptions = {\n /** Whether to match transitively (grandchildren, etc.). Defaults to true. */\n transitive?: boolean;\n};\n\n/**\n * Filter objects that are children of the specified parent(s).\n * Accepts ECHO objects, Refs, or arrays of either.\n * Refs are resolved to DXNs without loading; objects use {@link Obj.getDXN}.\n * With transitive=true (default), also matches grandchildren and beyond.\n */\nexport const childOf = (\n parents: Obj.Unknown | Ref.Unknown | readonly (Obj.Unknown | Ref.Unknown)[],\n options?: ChildOfOptions,\n): Any => {\n const items = Array.isArray(parents) ? parents : [parents];\n const dxns = items.map((item) => {\n if (Ref.isRef(item)) {\n return item.dxn.toString();\n }\n return internal.getDXN(item).toString();\n });\n return new FilterClass({\n type: 'child-of',\n parents: dxns,\n transitive: options?.transitive ?? true,\n });\n};\n\n/**\n * Negate the filter.\n */\nexport const not = <F extends Any>(filter: F): Filter<Type<F>> => {\n return new FilterClass({\n type: 'not',\n filter: filter.ast,\n });\n};\n\n/**\n * Combine filters with a logical AND.\n */\nexport const and = <Filters extends readonly Any[]>(...filters: Filters): Filter<Type<Filters[number]>> => {\n return new FilterClass({\n type: 'and',\n filters: filters.map((f) => f.ast),\n });\n};\n\n/**\n * Combine filters with a logical OR.\n */\nexport const or = <Filters extends readonly Any[]>(...filters: Filters): Filter<Type<Filters[number]>> => {\n return new FilterClass({\n type: 'or',\n filters: filters.map((f) => f.ast),\n });\n};\n\n// TODO(dmaretskyi): Add `Filter.match` to support pattern matching on string props.\n\nconst propsFilterToAst = (predicates: Props<any>): Pick<QueryAST.FilterObject, 'id' | 'props'> => {\n let idFilter: readonly ObjectId[] | undefined;\n if ('id' in predicates) {\n assertArgument(\n typeof predicates.id === 'string' || Array.isArray(predicates.id),\n 'predicates.id',\n 'invalid id filter',\n );\n idFilter = typeof predicates.id === 'string' ? [predicates.id] : predicates.id;\n Schema.Array(ObjectId).pipe(Schema.validateSync)(idFilter);\n }\n\n return {\n id: idFilter,\n props: Object.fromEntries(\n Object.entries(predicates)\n .filter(([prop, _value]) => prop !== 'id')\n .map(([prop, predicate]) => [prop, processPredicate(predicate)]),\n ) as Record<string, QueryAST.Filter>,\n };\n};\n\nconst processPredicate = (predicate: any): QueryAST.Filter => {\n return Match.value(predicate).pipe(\n Match.withReturnType<QueryAST.Filter>(),\n Match.when(is, (predicate) => predicate.ast),\n // TODO(wittjosiah): Add support for array predicates.\n Match.when(Array.isArray, (_predicate) => {\n throw new Error('Array predicates are not yet supported.');\n }),\n Match.when(\n (predicate: any) => !Ref.isRef(predicate) && typeof predicate === 'object' && predicate !== null,\n (predicate) => {\n const nestedProps = Object.fromEntries(\n Object.entries(predicate).map(([key, value]) => [key, processPredicate(value)]),\n );\n\n return {\n type: 'object',\n typename: null,\n props: nestedProps,\n };\n },\n ),\n Match.orElse((value) => eq(value).ast),\n );\n};\n\n/**\n * Returns a human-readable string representation of a Filter AST.\n */\nexport const pretty = (filter: Any): string => internal.prettyFilter(filter.ast);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAI3B,SAASC,sBAAsB;AAC/B,SAASC,KAAKC,gBAAgB;AAsB9B,IAAMC,cAAN,MAAMA,aAAAA;;EACJ,OAAe,aAA6B,CAAC;EAE7C,YAA4BC,KAAsB;SAAtBA,MAAAA;EAAuB;EAEnD,YAAYD,aAAYE;AAC1B;AAEO,IAAMC,KAAK,CAACC,WAAAA;AACjB,SAAO,OAAOA,WAAU,YAAYA,WAAU,QAAQ,aAAaA;AACrE;AAGO,IAAMC,UAAU,CAACJ,QAAAA;AACtB,SAAO,IAAID,YAAYC,GAAAA;AACzB;AAMO,IAAMK,aAAa,MAAA;AACxB,SAAO,IAAIN,YAAY;IACrBO,MAAM;IACNC,UAAU;IACVC,OAAO,CAAC;EACV,CAAA;AACF;AAKO,IAAMC,UAAU,MAAA;AACrB,SAAO,IAAIV,YAAY;IACrBO,MAAM;IACNI,QAAQ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AAS,IAAA,EACpCzB,IAAI,CAAC,CAACyB,MAAME,SAAAA,MAAe;MAACF;MAAMG,iBAAiBD,SAAAA;KAAW,CAAA;EAErE;AACF;AAEA,IAAMC,mBAAmB,CAACD,cAAAA;AACxB,SAAaxD,YAAMwD,SAAAA,EAAWR;IACtBU,qBAAc;IACdC,WAAKC,IAAI,CAACJ,eAAcA,WAAUlB,GAAG;;IAErCqB,WAAKjC,MAAMC,SAAS,CAACkC,eAAAA;AACzB,YAAM,IAAIC,MAAM,yCAAA;IAClB,CAAA;IACMH,WACJ,CAACH,eAAmB,CAAKzB,MAAMyB,UAAAA,KAAc,OAAOA,eAAc,YAAYA,eAAc,MAC5F,CAACA,eAAAA;AACC,YAAMO,cAAcZ,OAAOC,YACzBD,OAAOE,QAAQG,UAAAA,EAAW3B,IAAI,CAAC,CAACmC,KAAKhE,MAAAA,MAAW;QAACgE;QAAKP,iBAAiBzD,MAAAA;OAAO,CAAA;AAGhF,aAAO;QACLE,MAAM;QACN+D,UAAU;QACVf,OAAOa;MACT;IACF,CAAA;IAEIG,aAAO,CAAClE,WAAUmE,GAAGnE,MAAAA,EAAOsC,GAAG;EAAA;AAEzC;AAKO,IAAM8B,SAAS,CAAC/B,WAAiCgC,aAAahC,OAAOC,GAAG;",
|
|
6
|
+
"names": ["Match", "Schema", "SchemaAST", "assertArgument", "DXN", "ObjectId", "FilterClass", "ast", "variance", "is", "value", "fromAst", "everything", "type", "typename", "props", "nothing", "filter", "id", "ids", "assertArgument", "every", "ObjectId", "isValid", "length", "schema", "isSchema", "isUnion", "typenames", "types", "map", "getTypeDXNFromSpecifier", "make", "filters", "toString", "dxn", "propsFilterToAst", "startsWith", "DXN", "fromTypename", "typeDXN", "tag", "text", "options", "searchKind", "foreignKeys", "keys", "eq", "isRef", "TypeError", "operator", "noInline", "encode", "neq", "gt", "gte", "lt", "lte", "in$", "values", "contains", "value", "FilterClass", "type", "between", "from", "to", "_toUnixMs", "date", "getTime", "_timeRangeFilter", "field", "range", "filters", "after", "push", "operator", "before", "length", "everything", "and", "updated", "created", "childOf", "parents", "options", "items", "Array", "isArray", "dxns", "map", "item", "isRef", "dxn", "toString", "getDXN", "transitive", "not", "filter", "ast", "f", "or", "propsFilterToAst", "predicates", "idFilter", "assertArgument", "id", "Schema", "ObjectId", "pipe", "validateSync", "props", "Object", "fromEntries", "entries", "prop", "_value", "predicate", "processPredicate", "withReturnType", "when", "is", "_predicate", "Error", "nestedProps", "key", "typename", "orElse", "eq", "pretty", "prettyFilter"]
|
|
7
|
+
}
|