@dxos/echo 0.8.4-main.40e3dcdf1b → 0.8.4-main.43cb759274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +7 -7
- package/dist/lib/neutral/Annotation.mjs +29 -6
- package/dist/lib/neutral/Database.mjs +8 -9
- package/dist/lib/neutral/Entity.mjs +29 -18
- package/dist/lib/neutral/Err.mjs +3 -3
- package/dist/lib/neutral/Feed.mjs +27 -19
- package/dist/lib/neutral/Filter.mjs +25 -15
- package/dist/lib/neutral/Format.mjs +23 -3
- package/dist/lib/neutral/JsonSchema.mjs +7 -8
- package/dist/lib/neutral/Key.mjs +9 -5
- package/dist/lib/neutral/Migration.mjs +18 -0
- package/dist/lib/neutral/Obj.mjs +25 -19
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +19 -16
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +10 -9
- package/dist/lib/neutral/Registry.mjs +14 -0
- package/dist/lib/neutral/Registry.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +26 -24
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Scope.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +17 -13
- package/dist/lib/neutral/Type.mjs +52 -26
- package/dist/lib/neutral/chunk-3DKP2EIN.mjs +31 -0
- package/dist/lib/neutral/chunk-3DKP2EIN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4BB4MFCN.mjs +154 -0
- package/dist/lib/neutral/chunk-4BB4MFCN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-CIRHIEMW.mjs → chunk-4SFPZJVA.mjs} +92 -112
- package/dist/lib/neutral/chunk-4SFPZJVA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YWXWXIE5.mjs → chunk-4Z6GET2X.mjs} +3 -3
- package/dist/lib/neutral/chunk-4Z6GET2X.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7LOUAPYZ.mjs} +9 -5
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-43Y5DOS6.mjs → chunk-7OAFN3OX.mjs} +75 -112
- package/dist/lib/neutral/chunk-7OAFN3OX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BOZZPUXE.mjs → chunk-7PRCIDHH.mjs} +41 -81
- package/dist/lib/neutral/chunk-7PRCIDHH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UBEZSGXY.mjs → chunk-BBFJWWAV.mjs} +6 -6
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BDQGMDIX.mjs +132 -0
- package/dist/lib/neutral/chunk-BDQGMDIX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CGTI5MXO.mjs +36 -0
- package/dist/lib/neutral/chunk-CGTI5MXO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-DKLUHO4T.mjs} +1 -1
- package/dist/lib/neutral/chunk-DKLUHO4T.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DMN2CKPX.mjs +93 -0
- package/dist/lib/neutral/chunk-DMN2CKPX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UTBRYVQC.mjs → chunk-G6CFWUYH.mjs} +2 -2
- package/dist/lib/neutral/chunk-H26LSXVJ.mjs +653 -0
- package/dist/lib/neutral/chunk-H26LSXVJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-FXEG7EOK.mjs → chunk-J3MNM65T.mjs} +9 -6
- package/dist/lib/neutral/chunk-J3MNM65T.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JE7AOSWF.mjs +247 -0
- package/dist/lib/neutral/chunk-JE7AOSWF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LAF3LSWI.mjs +379 -0
- package/dist/lib/neutral/chunk-LAF3LSWI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LMNRFOVB.mjs +108 -0
- package/dist/lib/neutral/chunk-LMNRFOVB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WYOKA6AE.mjs → chunk-O6BH7EPN.mjs} +31 -4
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-KTAWP7GI.mjs → chunk-OIYW7R2G.mjs} +99 -46
- package/dist/lib/neutral/chunk-OIYW7R2G.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TQQZLKB7.mjs → chunk-OYUG4FHF.mjs} +648 -1228
- package/dist/lib/neutral/chunk-OYUG4FHF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NQRLRYJM.mjs → chunk-Q5FKCVBC.mjs} +173 -60
- package/dist/lib/neutral/chunk-Q5FKCVBC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Q62IHV2N.mjs +41 -0
- package/dist/lib/neutral/chunk-Q62IHV2N.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UFDK26FO.mjs → chunk-QVJDDG44.mjs} +69 -34
- package/dist/lib/neutral/chunk-QVJDDG44.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B5OXLWZL.mjs → chunk-TFEWTY5A.mjs} +155 -129
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UI6MWK5W.mjs → chunk-TTCSATUD.mjs} +1 -1
- package/dist/lib/neutral/{chunk-FZO7LQO7.mjs → chunk-VKWOFXT2.mjs} +22 -2
- package/dist/lib/neutral/{chunk-FZO7LQO7.mjs.map → chunk-VKWOFXT2.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-NXMFBIT5.mjs → chunk-ZACMEAYV.mjs} +89 -23
- package/dist/lib/neutral/chunk-ZACMEAYV.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +58 -38
- package/dist/lib/neutral/internal/index.mjs +131 -64
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +222 -177
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +108 -4
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Annotation.test.d.ts +2 -0
- package/dist/types/src/Annotation.test.d.ts.map +1 -0
- package/dist/types/src/Collection.d.ts +2 -3
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +56 -24
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +17 -6
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +102 -26
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +27 -27
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +89 -25
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +74 -11
- 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/Hypergraph.d.ts +14 -9
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +2 -2
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Key.d.ts +1 -1
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +72 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +108 -65
- 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 +35 -10
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +9 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +15 -7
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Registry.d.ts +131 -0
- package/dist/types/src/Registry.d.ts.map +1 -0
- package/dist/types/src/Relation.d.ts +72 -44
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Scope.d.ts +34 -0
- package/dist/types/src/Scope.d.ts.map +1 -0
- package/dist/types/src/StateMap.d.ts +32 -0
- package/dist/types/src/StateMap.d.ts.map +1 -0
- package/dist/types/src/StateMap.test.d.ts +2 -0
- package/dist/types/src/StateMap.test.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +21 -5
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/TagIndex.d.ts +36 -0
- package/dist/types/src/TagIndex.d.ts.map +1 -0
- package/dist/types/src/TagIndex.test.d.ts +2 -0
- package/dist/types/src/TagIndex.test.d.ts.map +1 -0
- package/dist/types/src/Tagging.d.ts +31 -0
- package/dist/types/src/Tagging.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +357 -96
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +2 -5
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +8 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +79 -37
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
- package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -2
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/util.d.ts +14 -5
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts +3 -3
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/entity.d.ts +72 -8
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/guard.d.ts +10 -0
- package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +20 -17
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/object.d.ts +3 -3
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/relation.d.ts +30 -7
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts +25 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -1
- package/dist/types/src/internal/Format/date.d.ts.map +1 -1
- package/dist/types/src/internal/Format/format.d.ts +3 -2
- package/dist/types/src/internal/Format/format.d.ts.map +1 -1
- package/dist/types/src/internal/Format/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -1
- package/dist/types/src/internal/Format/number.d.ts.map +1 -1
- package/dist/types/src/internal/Format/object.d.ts +3 -1
- package/dist/types/src/internal/Format/object.d.ts.map +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +28 -28
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts +3 -2
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/create-object.d.ts +11 -12
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/index.d.ts +0 -1
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts +11 -10
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
- package/dist/types/src/internal/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref.d.ts +42 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -1
- package/dist/types/src/internal/Type/index.d.ts +1 -2
- package/dist/types/src/internal/Type/index.d.ts.map +1 -1
- package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
- package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts +14 -11
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/base.d.ts +4 -4
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/entity.d.ts +63 -6
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/index.d.ts +1 -1
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +23 -7
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/model-symbols.d.ts +8 -4
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/typename.d.ts +7 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/version.d.ts +1 -1
- package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
- package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +2 -0
- 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 +83 -89
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +5 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -19
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +152 -4
- package/src/Collection.ts +6 -5
- package/src/Database.ts +117 -57
- package/src/Dataset.ts +10 -2
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +130 -31
- package/src/Err.ts +4 -4
- package/src/Feed.ts +138 -43
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +143 -27
- package/src/Hypergraph.ts +14 -9
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/Key.ts +1 -1
- package/src/Migration.ts +114 -0
- package/src/Obj.test.ts +122 -19
- package/src/Obj.ts +279 -97
- package/src/Query.test.ts +317 -131
- package/src/Query.ts +181 -73
- package/src/QueryResult.ts +11 -0
- package/src/Ref.ts +22 -4
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +10 -10
- package/src/Relation.ts +112 -71
- package/src/Scope.ts +50 -0
- package/src/StateMap.test.ts +56 -0
- package/src/StateMap.ts +99 -0
- package/src/Tag.md +88 -0
- package/src/Tag.ts +49 -6
- package/src/TagIndex.test.ts +57 -0
- package/src/TagIndex.ts +110 -0
- package/src/Tagging.ts +83 -0
- package/src/Type.test.ts +223 -18
- package/src/Type.ts +602 -132
- package/src/View.ts +11 -15
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +9 -3
- package/src/internal/Annotation/annotations.test.ts +82 -13
- package/src/internal/Annotation/annotations.ts +153 -115
- package/src/internal/Annotation/dictionary.ts +47 -0
- package/src/internal/Annotation/entity-dictionary.ts +40 -0
- package/src/internal/Annotation/index.ts +4 -2
- package/src/internal/Annotation/sorting.ts +0 -1
- package/src/internal/Annotation/util.ts +17 -8
- package/src/internal/Entity/api.ts +7 -8
- package/src/internal/Entity/entity.ts +196 -47
- package/src/internal/Entity/guard.ts +26 -0
- package/src/internal/Entity/index.ts +2 -0
- package/src/internal/Entity/model.ts +37 -28
- package/src/internal/Entity/object.ts +21 -6
- package/src/internal/Entity/relation.ts +68 -34
- package/src/internal/Entity/type-kind.ts +75 -0
- package/src/internal/Entity/type-uri.ts +87 -0
- package/src/internal/Entity/util.ts +10 -9
- package/src/internal/Entity/version.ts +0 -1
- package/src/internal/Format/date.test.ts +0 -1
- package/src/internal/Format/date.ts +0 -4
- package/src/internal/Format/format.test.ts +21 -1
- package/src/internal/Format/index.ts +2 -3
- package/src/internal/Format/object.ts +21 -4
- package/src/internal/Format/types.ts +1 -1
- package/src/internal/JsonSchema/annotations.ts +1 -1
- package/src/internal/JsonSchema/json-schema-type.ts +1 -1
- package/src/internal/JsonSchema/json-schema.test.ts +55 -142
- package/src/internal/JsonSchema/json-schema.ts +44 -31
- package/src/internal/Obj/clone.ts +9 -4
- package/src/internal/Obj/create-object.test.ts +13 -13
- package/src/internal/Obj/create-object.ts +68 -24
- package/src/internal/Obj/deleted.ts +1 -1
- package/src/internal/Obj/index.ts +0 -1
- package/src/internal/Obj/inspect.ts +4 -3
- package/src/internal/Obj/json-serializer.test.ts +102 -24
- package/src/internal/Obj/json-serializer.ts +105 -43
- package/src/internal/Obj/set-value.test.ts +31 -54
- package/src/internal/Obj/set-value.ts +1 -1
- package/src/internal/Obj/snapshot.ts +11 -4
- package/src/internal/Obj/typed-object.test.ts +9 -11
- package/src/internal/Obj/typed-object.ts +1 -1
- package/src/internal/Query.ts +159 -0
- package/src/internal/Ref/ref-array.ts +3 -4
- package/src/internal/Ref/ref.test.ts +17 -27
- package/src/internal/Ref/ref.ts +124 -59
- package/src/internal/Type/compose.test.ts +3 -2
- package/src/internal/Type/index.ts +1 -2
- package/src/internal/Type/manipulation.ts +0 -25
- package/src/internal/Type/type-schema.ts +60 -0
- package/src/internal/common/README.md +2 -2
- package/src/internal/common/api/meta.ts +19 -17
- package/src/internal/common/proxy/change-context.ts +1 -1
- package/src/internal/common/proxy/change.test.ts +118 -110
- package/src/internal/common/proxy/errors.ts +2 -2
- package/src/internal/common/proxy/handler.test.ts +1 -3
- package/src/internal/common/proxy/json-serializer.ts +26 -16
- package/src/internal/common/proxy/make-object.ts +43 -21
- package/src/internal/common/proxy/ownership.ts +2 -3
- package/src/internal/common/proxy/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/common/proxy/reactive.ts +11 -3
- package/src/internal/common/proxy/schema.test.ts +48 -86
- package/src/internal/common/proxy/typed-handler.test.ts +12 -12
- package/src/internal/common/proxy/typed-handler.ts +79 -19
- package/src/internal/common/proxy/typed-object.test.ts +16 -29
- package/src/internal/common/types/base.ts +4 -4
- package/src/internal/common/types/entity.ts +81 -2
- package/src/internal/common/types/index.ts +6 -1
- package/src/internal/common/types/meta.ts +49 -15
- package/src/internal/common/types/model-symbols.ts +16 -4
- package/src/internal/common/types/typename.ts +39 -3
- package/src/internal/common/types/well-known-types.ts +15 -0
- package/src/internal/index.ts +6 -0
- package/src/testing/api.test.ts +15 -10
- package/src/testing/test-data.ts +159 -100
- package/src/testing/test-schema.ts +22 -58
- package/src/testing/util.ts +14 -11
- package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-724GQYEN.mjs +0 -56
- package/dist/lib/neutral/chunk-724GQYEN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CIRHIEMW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DYDJBZEG.mjs +0 -102
- package/dist/lib/neutral/chunk-DYDJBZEG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KTAWP7GI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NEGC54NE.mjs +0 -130
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NQRLRYJM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OENWMTE6.mjs +0 -45
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RMLF7JOZ.mjs +0 -97
- package/dist/lib/neutral/chunk-RMLF7JOZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs +0 -355
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TQQZLKB7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UFDK26FO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VA2F47ZC.mjs +0 -152
- package/dist/lib/neutral/chunk-VA2F47ZC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs.map +0 -7
- package/dist/types/src/SchemaRegistry.d.ts +0 -84
- package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
- package/dist/types/src/internal/Obj/ids.d.ts +0 -6
- package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
- package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
- package/src/SchemaRegistry.ts +0 -106
- package/src/internal/Obj/ids.ts +0 -12
- package/src/internal/Type/echo-schema.ts +0 -424
- package/src/internal/Type/persistent-schema.ts +0 -33
- /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Migration.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-UTBRYVQC.mjs.map → chunk-G6CFWUYH.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-UI6MWK5W.mjs.map → chunk-TTCSATUD.mjs.map} +0 -0
|
@@ -3,24 +3,25 @@ import {
|
|
|
3
3
|
FormatAnnotation,
|
|
4
4
|
FormatAnnotationId,
|
|
5
5
|
TypeFormat
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TFEWTY5A.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createEchoReferenceSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7OAFN3OX.mjs";
|
|
10
10
|
import {
|
|
11
11
|
GeneratorAnnotationId,
|
|
12
12
|
LabelAnnotationId,
|
|
13
13
|
PropertyMetaAnnotationId,
|
|
14
14
|
TypeAnnotationId,
|
|
15
15
|
TypeIdentifierAnnotationId
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-H26LSXVJ.mjs";
|
|
17
17
|
import {
|
|
18
18
|
ANY_OBJECT_TYPENAME,
|
|
19
19
|
ANY_OBJECT_VERSION,
|
|
20
20
|
EntityKind,
|
|
21
21
|
EntityKindSchema,
|
|
22
|
+
getStaticTypeSchema,
|
|
22
23
|
makeTypeJsonSchemaAnnotation
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-O6BH7EPN.mjs";
|
|
24
25
|
|
|
25
26
|
// src/internal/JsonSchema/annotations.ts
|
|
26
27
|
import * as SchemaAST from "effect/SchemaAST";
|
|
@@ -319,7 +320,7 @@ import * as SchemaAST2 from "effect/SchemaAST";
|
|
|
319
320
|
import { raise } from "@dxos/debug";
|
|
320
321
|
import { mapAst } from "@dxos/effect";
|
|
321
322
|
import { assertArgument, invariant } from "@dxos/invariant";
|
|
322
|
-
import { DXN,
|
|
323
|
+
import { DXN, EID, EntityId } from "@dxos/keys";
|
|
323
324
|
import { log } from "@dxos/log";
|
|
324
325
|
import { clearUndefined, orderKeys, removeProperties } from "@dxos/util";
|
|
325
326
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/JsonSchema/json-schema.ts";
|
|
@@ -354,6 +355,15 @@ var toPropType = (type) => {
|
|
|
354
355
|
};
|
|
355
356
|
var JSON_SCHEMA_URL = "http://json-schema.org/draft-07/schema#";
|
|
356
357
|
var toJsonSchema = (schema, options = {}) => {
|
|
358
|
+
const slot = getStaticTypeSchema(schema);
|
|
359
|
+
if (slot != null) {
|
|
360
|
+
schema = slot;
|
|
361
|
+
} else if (!Schema2.isSchema(schema)) {
|
|
362
|
+
const entityJsonSchema = schema.jsonSchema;
|
|
363
|
+
if (entityJsonSchema != null) {
|
|
364
|
+
return entityJsonSchema;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
357
367
|
assertArgument(Schema2.isSchema(schema), "schema");
|
|
358
368
|
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
359
369
|
if (options.strict) {
|
|
@@ -465,12 +475,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
465
475
|
if (root.allOf.length === 1) {
|
|
466
476
|
result = toEffectSchema(root.allOf[0], defs);
|
|
467
477
|
} else {
|
|
468
|
-
log.warn("allOf with multiple schemas is not supported", void 0, {
|
|
469
|
-
F: __dxlog_file,
|
|
470
|
-
L: 224,
|
|
471
|
-
S: void 0,
|
|
472
|
-
C: (f, a) => f(...a)
|
|
473
|
-
});
|
|
478
|
+
log.warn("allOf with multiple schemas is not supported", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 197, S: void 0 });
|
|
474
479
|
result = Schema2.Unknown;
|
|
475
480
|
}
|
|
476
481
|
} else if ("type" in root) {
|
|
@@ -499,15 +504,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
499
504
|
const [required, optional3] = Function.pipe(root.items, Array2.map((v) => toEffectSchema(v, defs)), Array2.splitAt(root.minItems ?? root.items.length));
|
|
500
505
|
result = Schema2.Tuple(...required, ...optional3.map(Schema2.optionalElement));
|
|
501
506
|
} else {
|
|
502
|
-
invariant(root.items, void 0, {
|
|
503
|
-
F: __dxlog_file,
|
|
504
|
-
L: 257,
|
|
505
|
-
S: void 0,
|
|
506
|
-
A: [
|
|
507
|
-
"root.items",
|
|
508
|
-
""
|
|
509
|
-
]
|
|
510
|
-
});
|
|
507
|
+
invariant(root.items, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 231, S: void 0, A: ["root.items", ""] });
|
|
511
508
|
const items = root.items;
|
|
512
509
|
result = Array2.isArray(items) ? Schema2.Tuple(...items.map((v) => toEffectSchema(v, defs))) : Schema2.Array(toEffectSchema(items, defs));
|
|
513
510
|
}
|
|
@@ -521,15 +518,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
521
518
|
} else if ("$ref" in root) {
|
|
522
519
|
const refSegments = root.$ref.split("/");
|
|
523
520
|
const jsonSchema = defs[refSegments[refSegments.length - 1]];
|
|
524
|
-
invariant(jsonSchema, `missing definition for ${root.$ref}`, {
|
|
525
|
-
F: __dxlog_file,
|
|
526
|
-
L: 273,
|
|
527
|
-
S: void 0,
|
|
528
|
-
A: [
|
|
529
|
-
"jsonSchema",
|
|
530
|
-
"`missing definition for ${root.$ref}`"
|
|
531
|
-
]
|
|
532
|
-
});
|
|
521
|
+
invariant(jsonSchema, `missing definition for ${root.$ref}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 246, S: void 0, A: ["jsonSchema", "`missing definition for ${root.$ref}`"] });
|
|
533
522
|
result = toEffectSchema(jsonSchema, defs).pipe(Schema2.annotations({
|
|
534
523
|
identifier: refSegments[refSegments.length - 1]
|
|
535
524
|
}));
|
|
@@ -539,15 +528,7 @@ var toEffectSchema = (root, _defs) => {
|
|
|
539
528
|
return result;
|
|
540
529
|
};
|
|
541
530
|
var objectToEffectSchema = (root, defs) => {
|
|
542
|
-
invariant("type" in root && root.type === "object", `not an object: ${root}`, {
|
|
543
|
-
F: __dxlog_file,
|
|
544
|
-
L: 288,
|
|
545
|
-
S: void 0,
|
|
546
|
-
A: [
|
|
547
|
-
"'type' in root && root.type === 'object'",
|
|
548
|
-
"`not an object: ${root}`"
|
|
549
|
-
]
|
|
550
|
-
});
|
|
531
|
+
invariant("type" in root && root.type === "object", `not an object: ${root}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 257, S: void 0, A: ["'type' in root && root.type === 'object'", "`not an object: ${root}`"] });
|
|
551
532
|
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
552
533
|
const isEchoObject = echoRefinement != null || "$id" in root && typeof root.$id === "string" && root.$id.startsWith("dxn:");
|
|
553
534
|
let fields = {};
|
|
@@ -565,24 +546,8 @@ var objectToEffectSchema = (root, defs) => {
|
|
|
565
546
|
}
|
|
566
547
|
let schema;
|
|
567
548
|
if (root.patternProperties) {
|
|
568
|
-
invariant(propertyList.length === 0, "pattern properties mixed with regular properties are not supported", {
|
|
569
|
-
|
|
570
|
-
L: 314,
|
|
571
|
-
S: void 0,
|
|
572
|
-
A: [
|
|
573
|
-
"propertyList.length === 0",
|
|
574
|
-
"'pattern properties mixed with regular properties are not supported'"
|
|
575
|
-
]
|
|
576
|
-
});
|
|
577
|
-
invariant(Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === "", "only one pattern property is supported", {
|
|
578
|
-
F: __dxlog_file,
|
|
579
|
-
L: 315,
|
|
580
|
-
S: void 0,
|
|
581
|
-
A: [
|
|
582
|
-
"Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === ''",
|
|
583
|
-
"'only one pattern property is supported'"
|
|
584
|
-
]
|
|
585
|
-
});
|
|
549
|
+
invariant(propertyList.length === 0, "pattern properties mixed with regular properties are not supported", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 276, S: void 0, A: ["propertyList.length === 0", "'pattern properties mixed with regular properties are not supported'"] });
|
|
550
|
+
invariant(Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === "", "only one pattern property is supported", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 277, S: void 0, A: ["Object.keys(root.patternProperties).length === 1 && Object.keys(root.patternProperties)[0] === ''", "'only one pattern property is supported'"] });
|
|
586
551
|
schema = Schema2.Record({
|
|
587
552
|
key: Schema2.String,
|
|
588
553
|
value: toEffectSchema(root.patternProperties[""], defs)
|
|
@@ -614,8 +579,8 @@ var objectToEffectSchema = (root, defs) => {
|
|
|
614
579
|
var anyToEffectSchema = (root) => {
|
|
615
580
|
const echoRefinement = root[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
616
581
|
if (echoRefinement?.reference != null) {
|
|
617
|
-
const
|
|
618
|
-
return createEchoReferenceSchema(
|
|
582
|
+
const echoUri = root.$id.startsWith("echo:") || root.$id.startsWith("dxn:echo:") ? root.$id : void 0;
|
|
583
|
+
return createEchoReferenceSchema(echoUri, echoRefinement.reference.typename, echoRefinement.reference.version);
|
|
619
584
|
}
|
|
620
585
|
return Schema2.Any;
|
|
621
586
|
};
|
|
@@ -627,17 +592,10 @@ var refToEffectSchema = (root) => {
|
|
|
627
592
|
if (typeof reference !== "object") {
|
|
628
593
|
throw new Error("Invalid reference field in ref schema");
|
|
629
594
|
}
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
S: void 0,
|
|
635
|
-
A: [
|
|
636
|
-
"targetSchemaDXN.kind === DXN.kind.TYPE",
|
|
637
|
-
""
|
|
638
|
-
]
|
|
639
|
-
});
|
|
640
|
-
return createEchoReferenceSchema(targetSchemaDXN.toString(), targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : void 0, reference.schemaVersion);
|
|
595
|
+
const ref = reference.schema.$ref;
|
|
596
|
+
const targetSchemaDXN = DXN.tryMake(ref);
|
|
597
|
+
invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 327, S: void 0, A: ["targetSchemaDXN", "`Expected a type DXN, got: ${ref}`"] });
|
|
598
|
+
return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
|
|
641
599
|
};
|
|
642
600
|
var annotations_toJsonSchemaFields = (annotations2) => {
|
|
643
601
|
const schemaFields = {};
|
|
@@ -652,8 +610,7 @@ var annotations_toJsonSchemaFields = (annotations2) => {
|
|
|
652
610
|
}
|
|
653
611
|
const echoIdentifier = annotations2[TypeIdentifierAnnotationId];
|
|
654
612
|
if (echoIdentifier) {
|
|
655
|
-
schemaFields
|
|
656
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
613
|
+
schemaFields.$id = echoIdentifier;
|
|
657
614
|
}
|
|
658
615
|
for (const [key, annotationId] of Object.entries(CustomAnnotations)) {
|
|
659
616
|
const value = annotations2[annotationId];
|
|
@@ -664,13 +621,14 @@ var annotations_toJsonSchemaFields = (annotations2) => {
|
|
|
664
621
|
return schemaFields;
|
|
665
622
|
};
|
|
666
623
|
var decodeTypeIdentifierAnnotation = (schema) => {
|
|
667
|
-
if (schema.$id && schema.$id.startsWith("dxn:echo:")) {
|
|
624
|
+
if (schema.$id && (schema.$id.startsWith("echo:") || schema.$id.startsWith("dxn:echo:"))) {
|
|
668
625
|
return schema.$id;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
626
|
+
}
|
|
627
|
+
const legacySchemaId = schema.echo?.type?.schemaId;
|
|
628
|
+
if (legacySchemaId) {
|
|
629
|
+
return EntityId.isValid(legacySchemaId) ? EID.make({
|
|
630
|
+
entityId: legacySchemaId
|
|
631
|
+
}) : legacySchemaId;
|
|
674
632
|
}
|
|
675
633
|
return void 0;
|
|
676
634
|
};
|
|
@@ -685,8 +643,8 @@ var decodeTypeAnnotation = (schema) => {
|
|
|
685
643
|
if (annotation.kind === EntityKind.Relation) {
|
|
686
644
|
const source = schema.relationSource?.$ref ?? raise(new Error("Relation source not set"));
|
|
687
645
|
const target = schema.relationTarget?.$ref ?? raise(new Error("Relation target not set"));
|
|
688
|
-
annotation.sourceSchema = DXN.
|
|
689
|
-
annotation.targetSchema = DXN.
|
|
646
|
+
annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));
|
|
647
|
+
annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));
|
|
690
648
|
}
|
|
691
649
|
return annotation;
|
|
692
650
|
}
|
|
@@ -715,7 +673,9 @@ var jsonSchemaFieldsToAnnotations = (schema) => {
|
|
|
715
673
|
if (typeAnnotation) {
|
|
716
674
|
annotations2[TypeAnnotationId] = typeAnnotation;
|
|
717
675
|
annotations2[SchemaAST2.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
718
|
-
|
|
676
|
+
// $id is the typename DXN — the schema's type identity. The storage EID (if any)
|
|
677
|
+
// is preserved separately on TypeIdentifierAnnotation / echo.schemaId.
|
|
678
|
+
identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),
|
|
719
679
|
kind: typeAnnotation.kind,
|
|
720
680
|
typename: typeAnnotation.typename,
|
|
721
681
|
version: typeAnnotation.version,
|
|
@@ -784,4 +744,4 @@ export {
|
|
|
784
744
|
toJsonSchema,
|
|
785
745
|
toEffectSchema
|
|
786
746
|
};
|
|
787
|
-
//# sourceMappingURL=chunk-
|
|
747
|
+
//# sourceMappingURL=chunk-7PRCIDHH.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/JsonSchema/annotations.ts", "../../../src/internal/JsonSchema/json-schema-type.ts", "../../../src/internal/JsonSchema/json-schema.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../Annotation/annotations';\nimport { CurrencyAnnotationId, FormatAnnotationId } from '../Format';\nimport { type JsonSchemaEchoAnnotations, type JsonSchemaType } from '../JsonSchema';\n\n//\n// This file configures annotations for JSON encoding/decoding.\n//\n\n// Go on the root level.\ntype RootJsonSchemaProperty = keyof JsonSchemaType;\n\n// Go on the namespaced `annotations` property.\ntype NamespacedJsonSchemaProperty = keyof JsonSchemaEchoAnnotations;\n\n/**\n * List of annotations for JSON encoding/decoding.\n * Omits default effect-schema annotations since they are encoded with default serializer.\n */\n// TODO(burdon): Reconcile with `EchoAnnotations`.\nexport const CustomAnnotations: Partial<Record<RootJsonSchemaProperty, symbol>> = {\n format: FormatAnnotationId,\n currency: CurrencyAnnotationId,\n};\n\n/**\n * List of annotations for JSON decoding only.\n * Includes default effect annotations.\n */\nexport const DecodedAnnotations: Partial<Record<RootJsonSchemaProperty, symbol>> = {\n title: SchemaAST.TitleAnnotationId,\n description: SchemaAST.DescriptionAnnotationId,\n};\n\n/**\n * Annotations that go into ECHO namespace in json-schema.\n */\n// TODO(dmaretskyi): Consider removing ECHO namespace and putting them at the top level.\n// TODO(dmaretskyi): Move to format.ts when circular imports are solved\nexport const EchoAnnotations: Partial<Record<NamespacedJsonSchemaProperty, symbol>> = {\n // TODO(dmaretskyi): `FieldLookupAnnotationId` might go here, but lets remove it entirely and use LabelAnnotation instead.\n meta: PropertyMetaAnnotationId,\n generator: GeneratorAnnotationId,\n labelProp: LabelAnnotationId,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { 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, EID, EntityId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { clearUndefined, orderKeys, removeProperties } from '@dxos/util';\n\nimport type * as Type from '../../Type';\nimport { type TypeAnnotation, TypeAnnotationId, TypeIdentifierAnnotationId } from '../Annotation/annotations';\nimport { makeTypeJsonSchemaAnnotation } from '../Annotation/util';\nimport {\n ANY_OBJECT_TYPENAME,\n ANY_OBJECT_VERSION,\n EntityKind,\n EntityKindSchema,\n getStaticTypeSchema,\n} from '../common/types';\nimport { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';\nimport { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';\nimport {\n ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,\n ECHO_ANNOTATIONS_NS_KEY,\n type JsonSchemaEchoAnnotations,\n type JsonSchemaType,\n getNormalizedEchoAnnotations,\n} from './json-schema-type';\n\n// TODO(burdon): Are these values stored (can they be changed?)\nexport enum PropType {\n NONE = 0,\n STRING = 1, // TODO(burdon): vs TEXT?\n NUMBER = 2,\n BOOLEAN = 3,\n DATE = 4,\n REF = 5,\n RECORD = 6,\n ENUM = 7,\n}\n\n// TODO(burdon): Reconcile with @dxos/schema.\nexport const toPropType = (type?: PropType): string => {\n switch (type) {\n case PropType.STRING:\n return 'string';\n case PropType.NUMBER:\n return 'number';\n case PropType.BOOLEAN:\n return 'boolean';\n case PropType.DATE:\n return 'date';\n case PropType.REF:\n return 'ref';\n case PropType.RECORD:\n return 'object';\n default:\n throw new Error(`Invalid type: ${type}`);\n }\n};\n\nconst JSON_SCHEMA_URL = 'http://json-schema.org/draft-07/schema#';\n\nexport type JsonSchemaOptions = {\n strict?: boolean;\n};\n\n/**\n * Convert effect schema to JSON Schema.\n * NOTE: This handles custom annotations.\n * @param schema\n */\n// TODO(burdon): Reconcile with possibly extending @effect/Schema/JSONSchema\n// We add additional propertyOrder (but the object properties ARE ordered); and type \"string\" for literals.\n// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?\nexport const toJsonSchema = (\n schema: Schema.Schema.All | Type.AnyEntity,\n options: JsonSchemaOptions = {},\n): Types.DeepMutable<JsonSchemaType> => {\n // Allow passing a `Type.Type` entity — use its hidden source schema (or its\n // already-built jsonSchema as a fallback).\n const slot = getStaticTypeSchema(schema);\n if (slot != null) {\n schema = slot;\n } else if (!Schema.isSchema(schema)) {\n const entityJsonSchema = (schema as { jsonSchema?: JsonSchemaType }).jsonSchema;\n if (entityJsonSchema != null) {\n return entityJsonSchema as Types.DeepMutable<JsonSchemaType>;\n }\n }\n assertArgument(Schema.isSchema(schema), 'schema');\n let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);\n if (options.strict) {\n // TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).\n jsonSchema = removeProperties(jsonSchema, (key, value) => {\n if (key === '$id' && value === '/schemas/any') {\n return true;\n }\n if (key === '$ref' && value === '#/$defs/dependency') {\n return true;\n }\n if (key === '$ref' && value === '#/$defs/jsonSchema') {\n return true;\n }\n\n return false;\n });\n }\n\n return jsonSchema;\n};\n\nconst _toJsonSchemaAST = (ast: SchemaAST.AST): Types.DeepMutable<JsonSchemaType> => {\n const withRefinements = withEchoRefinements(ast, '#');\n const jsonSchema = JSONSchema.fromAST(withRefinements, {\n definitions: {},\n }) as Types.DeepMutable<JsonSchemaType>;\n\n return normalizeJsonSchema(jsonSchema);\n};\n\nconst withEchoRefinements = (\n ast: SchemaAST.AST,\n path: string | undefined,\n suspendCache = new Map<SchemaAST.AST, string>(),\n): SchemaAST.AST => {\n if (path) {\n suspendCache.set(ast, path);\n }\n\n let recursiveResult: SchemaAST.AST;\n if (SchemaAST.isSuspend(ast)) {\n // Precompute JSON schema for suspended AST since effect serializer does not support it.\n const suspendedAst = ast.f();\n const cachedPath = suspendCache.get(suspendedAst);\n if (cachedPath) {\n recursiveResult = new SchemaAST.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {\n [SchemaAST.JSONSchemaAnnotationId]: {\n $ref: cachedPath,\n },\n });\n } else {\n const jsonSchema = _toJsonSchemaAST(suspendedAst);\n recursiveResult = new SchemaAST.Suspend(() => withEchoRefinements(suspendedAst, path, suspendCache), {\n [SchemaAST.JSONSchemaAnnotationId]: jsonSchema,\n });\n }\n } else if (SchemaAST.isTypeLiteral(ast)) {\n // Add property order annotations\n recursiveResult = 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 echoUri = root.$id.startsWith('echo:') || root.$id.startsWith('dxn:echo:') ? root.$id : undefined;\n return createEchoReferenceSchema(\n echoUri,\n (echoRefinement as any).reference.typename,\n (echoRefinement as any).reference.version,\n );\n }\n\n return Schema.Any;\n};\n\n// TODO(dmaretskyi): Types.\nconst refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {\n if (!('reference' in root)) {\n // Fallback to generic object ref when no reference info is provided.\n return createEchoReferenceSchema(undefined, ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION);\n }\n\n const reference: JsonSchemaReferenceInfo = root.reference;\n if (typeof reference !== 'object') {\n throw new Error('Invalid reference field in ref schema');\n }\n\n const ref = reference.schema.$ref;\n const targetSchemaDXN = DXN.tryMake(ref);\n invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);\n\n return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);\n};\n\n//\n// Annotations\n//\n\nconst annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Record<symbol, any> => {\n const schemaFields: Record<string, any> = {};\n\n const echoAnnotations: Types.Mutable<JsonSchemaEchoAnnotations> = {};\n for (const [key, annotationId] of Object.entries(EchoAnnotations)) {\n if (annotations[annotationId] != null) {\n echoAnnotations[key as keyof JsonSchemaEchoAnnotations] = annotations[annotationId] as any;\n }\n }\n if (Object.keys(echoAnnotations).length > 0) {\n // TODO(dmaretskyi): use new namespace.\n schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;\n }\n\n // For stored schemas the storage URI is the definitive identifier — it overrides\n // the typename `$id` written above.\n const echoIdentifier = annotations[TypeIdentifierAnnotationId];\n if (echoIdentifier) {\n schemaFields.$id = echoIdentifier;\n }\n\n // Custom (at end).\n for (const [key, annotationId] of Object.entries(CustomAnnotations)) {\n const value = annotations[annotationId];\n if (value != null) {\n schemaFields[key] = value;\n }\n }\n\n return schemaFields;\n};\n\nconst decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {\n // For stored schemas `$id` IS the storage URI (echo:/… or legacy dxn:echo:…).\n if (schema.$id && (schema.$id.startsWith('echo:') || schema.$id.startsWith('dxn:echo:'))) {\n return schema.$id;\n }\n // Legacy: older serializations stored the EID on echo.type.schemaId.\n const legacySchemaId = schema.echo?.type?.schemaId;\n if (legacySchemaId) {\n return EntityId.isValid(legacySchemaId) ? EID.make({ entityId: legacySchemaId }) : legacySchemaId;\n }\n return undefined;\n};\n\nconst decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefined => {\n if (schema.typename) {\n const annotation: Types.Mutable<TypeAnnotation> = {\n // TODO(dmaretskyi): Decoding default.\n kind: schema.entityKind ? Schema.decodeSync(EntityKindSchema)(schema.entityKind) : EntityKind.Object,\n typename: schema.typename,\n version: schema.version ?? '0.1.0',\n };\n\n if (annotation.kind === EntityKind.Relation) {\n const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));\n const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));\n annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));\n annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));\n }\n\n return annotation;\n }\n\n // Decode legacy schema.\n if (!schema.typename && schema?.echo?.type) {\n return {\n kind: EntityKind.Object,\n typename: schema.echo.type.typename,\n version: schema.echo.type.version,\n };\n }\n\n return undefined;\n};\n\nconst jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annotations => {\n const annotations: Types.Mutable<Schema.Annotations.Schema<any>> = {};\n\n const echoAnnotations: JsonSchemaEchoAnnotations = getNormalizedEchoAnnotations(schema) ?? {};\n if (echoAnnotations) {\n for (const [key, annotationId] of Object.entries(EchoAnnotations)) {\n if (echoAnnotations[key as keyof JsonSchemaEchoAnnotations]) {\n annotations[annotationId] = echoAnnotations[key as keyof JsonSchemaEchoAnnotations];\n }\n }\n }\n\n const typeIdentifier = decodeTypeIdentifierAnnotation(schema);\n annotations[TypeIdentifierAnnotationId] = typeIdentifier;\n const typeAnnotation = decodeTypeAnnotation(schema);\n if (typeAnnotation) {\n annotations[TypeAnnotationId] = typeAnnotation;\n annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({\n // $id is the typename DXN — the schema's type identity. The storage EID (if any)\n // is preserved separately on TypeIdentifierAnnotation / echo.schemaId.\n identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),\n kind: typeAnnotation.kind,\n typename: typeAnnotation.typename,\n version: typeAnnotation.version,\n relationSource: typeAnnotation.sourceSchema,\n relationTarget: typeAnnotation.targetSchema,\n });\n }\n\n // Custom (at end).\n for (const [key, annotationId] of Object.entries({ ...CustomAnnotations, ...DecodedAnnotations })) {\n if (key in schema) {\n annotations[annotationId] = (schema as any)[key];\n }\n }\n\n return clearUndefined(annotations);\n};\n\nconst makeAnnotatedRefinement = (ast: SchemaAST.AST, annotations: SchemaAST.Annotations): SchemaAST.Refinement => {\n return new SchemaAST.Refinement(ast, () => Option.none(), annotations);\n};\n\nconst addJsonSchemaFields = (ast: SchemaAST.AST, schema: JsonSchemaType): SchemaAST.AST =>\n makeAnnotatedRefinement(ast, { [SchemaAST.JSONSchemaAnnotationId]: schema });\n\n/**\n * Fixes field order.\n * Sets `$schema` prop.\n */\nconst normalizeJsonSchema = (jsonSchema: Types.DeepMutable<JsonSchemaType>): Types.DeepMutable<JsonSchemaType> => {\n if (jsonSchema.properties && 'id' in jsonSchema.properties) {\n jsonSchema.properties = orderKeys(jsonSchema.properties, ['id']); // Put id first.\n }\n\n // TODO(dmaretskyi): Makes sure undefined is not left on optional fields for the resulting object.\n jsonSchema.$schema = JSON_SCHEMA_URL;\n jsonSchema = orderKeys(jsonSchema, [\n '$schema',\n '$id',\n\n 'entityKind',\n 'typename',\n 'version',\n 'relationTarget',\n 'relationSource',\n\n 'type',\n 'enum',\n\n 'properties',\n 'required',\n 'propertyOrder', // Custom.\n 'items',\n 'additionalProperties',\n\n 'anyOf',\n 'oneOf',\n ]);\n return jsonSchema;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,YAAYA,eAAe;AAqBpB,IAAMC,oBAAqE;EAChFC,QAAQC;EACRC,UAAUC;AACZ;AAMO,IAAMC,qBAAsE;EACjFC,OAAiBC;EACjBC,aAAuBC;AACzB;AAOO,IAAMC,kBAAyE;;EAEpFC,MAAMC;EACNC,WAAWC;EACXC,WAAWC;AACb;;;AC7CA,YAAYC,YAAY;AAExB,SAASC,gBAA+B;AAWxC,IAAMC,cAAqBC,eAAQ,SAAS,WAAW,WAAW,QAAQ,UAAU,UAAU,QAAA;AAE9F,IAAMC,qBAA4BC,cAAOC,KAAYC,4BAAqB,CAAA,CAAA;AAE1E,IAAMC,cAAqBC,aAAaC,aAAM;AAE9C,IAAMC,sBAA6BC,aAC1BC,eAAQ,MAAMC,cAAAA,GACdC,cAAO;AAMT,IAAMC,4BAAmCC,cAAO;;;;;EAKrDC,WAAkBC,gBAAgBP,aAAMQ,UAAiBX,aAAMW,QAAAA,CAAAA,CAAAA;;;;;EAM/DC,WAAkBF,gBAAgBP,aAAaF,eAAeY,aAAaZ,eAAeL,aAAM,CAAA,CAAA;;;;EAKhGkB,MAAaJ,gB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A,gBAAA,GAAA;MACF;IAEA;EACAA;AACA,QAAM0E,iBAAiBlB,+BAAqBlF,MAAAA;AAC5C,EAAA0B,aAAI0E,0BAAgB,IAAA;QAClB1E,iBAAY2E,qBAAoBD,MAAAA;MAChC1E,gBAAYP;iBACV,gBAAA,IAAA;iBACA,iCAAA,IAAA,6BAAuE;;;MAGvE4E,YAAUK,IAAAA,KAAAA,eAAuB,UAAA,eAAA,OAAA;MACjCf,MAAAA,eAASe;MACTE,UAAAA,eAAgBF;MAChBX,SAAAA,eAAgBW;MAClB,gBAAA,eAAA;MACF,gBAAA,eAAA;IAEA,CAAA;EACA;aAA4EG,CAAAA,KAAAA,YAAkB,KAAA,OAAA,QAAA;IAAK,GAAA;IACjG,GAAA;;AAEA,QAAA,OAAA,QAAA;AACF,MAAA7E,aAAA,YAAA,IAAA,OAAA,GAAA;IAEA;EACF;AAEA,SAAM8E,eAAAA,YAA2B3F;;AAEjC,IAAA,0BAAA,CAAA,KAAAa,iBAAA;AAEA,SAAMC,IAAAA,sBAA2C3B,KAAAA,MAC/CwG,YAAAA,GAAAA,YAAwB3F;;IAAkD,sBAAA,CAAA,KAAA,WAAA,wBAAA,KAAA;EAE5E,CAAA,iCAAA,GAAA;;IAMIR,sBAAwBoG,CAAAA,eAAUpG;iBAAwB,cAAA,QAAA,WAAA,YAAA;eAAQ,aAAgB,UAAA,WAAA,YAAA;MACpF;IAEA,CAAA;EACAA;aAEE,UAAA;eACA,UAAA,YAAA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IAEA;IACA;IACA;IACA;IACA;IAEA;IACA;IACD;IACD;EACF,CAAA;;;",
|
|
6
|
+
"names": ["SchemaAST", "CustomAnnotations", "format", "FormatAnnotationId", "currency", "CurrencyAnnotationId", "DecodedAnnotations", "title", "TitleAnnotationId", "description", "DescriptionAnnotationId", "EchoAnnotations", "meta", "PropertyMetaAnnotationId", "generator", "GeneratorAnnotationId", "labelProp", "LabelAnnotationId", "Schema", "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", "EID", "EntityId", "log", "clearUndefined", "orderKeys", "removeProperties", "PropType", "schema", "slot", "Schema", "entityJsonSchema", "assertArgument", "jsonSchema", "removeProperties", "key", "_toJsonSchemaAST", "JSONSchema", "definitions", "normalizeJsonSchema", "withEchoRefinements", "ast", "suspendCache", "path", "recursiveResult", "suspendedAst", "cachedPath", "SchemaAST", "Suspend", "JSONSchemaAnnotationId", "propertyOrder", "propertySignatures", "annotationFields", "annotations_toJsonSchemaFields", "annotations", "addJsonSchemaFields", "_defs", "$defs", "objectToEffectSchema", "result", "root", "Union", "oneOf", "toEffectSchema", "v", "anyOf", "map", "defs", "length", "log", "Tuple", "required", "optional", "invariant", "items", "Array", "isArray", "identifier", "refSegments", "ECHO_ANNOTATIONS_NS_DEPRECATED_KEY", "isEchoObject", "echoRefinement", "$id", "fields", "propertyList", "Object", "properties", "immutableIdField", "value", "String", "additionalProperties", "indexValue", "anyToEffectSchema", "reference", "createEchoReferenceSchema", "echoUri", "Error", "ref", "targetSchemaDXN", "DXN", "annotationId", "echoAnnotations", "schemaFields", "ECHO_ANNOTATIONS_NS_KEY", "echoIdentifier", "decodeTypeIdentifierAnnotation", "startsWith", "isValid", "legacySchemaId", "undefined", "decodeTypeAnnotation", "kind", "entityKind", "version", "annotation", "EntityKind", "target", "relationTarget", "$ref", "sourceSchema", "source", "raise", "targetSchema", "typename", "echo", "jsonSchemaFieldsToAnnotations", "getNormalizedEchoAnnotations", "EchoAnnotations", "typeAnnotation", "TypeAnnotationId", "relationSource", "DecodedAnnotations", "makeAnnotatedRefinement", "orderKeys"]
|
|
7
|
+
}
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
// src/Err.ts
|
|
6
6
|
var Err_exports = {};
|
|
7
7
|
__export(Err_exports, {
|
|
8
|
+
EntityNotFoundError: () => EntityNotFoundError,
|
|
8
9
|
GetReactiveError: () => GetReactiveError,
|
|
9
|
-
ObjectNotFoundError: () => ObjectNotFoundError,
|
|
10
10
|
SchemaNotFoundError: () => SchemaNotFoundError
|
|
11
11
|
});
|
|
12
12
|
import { BaseError } from "@dxos/errors";
|
|
@@ -20,11 +20,11 @@ var SchemaNotFoundError = class extends BaseError.extend("SchemaNotFoundError",
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
var
|
|
24
|
-
constructor(
|
|
23
|
+
var EntityNotFoundError = class extends BaseError.extend("EntityNotFoundError", "Entity not found") {
|
|
24
|
+
constructor(uri, options) {
|
|
25
25
|
super({
|
|
26
26
|
context: {
|
|
27
|
-
|
|
27
|
+
uri
|
|
28
28
|
},
|
|
29
29
|
...options
|
|
30
30
|
});
|
|
@@ -44,8 +44,8 @@ var GetReactiveError = class extends BaseError.extend("GetReactiveError", "Faile
|
|
|
44
44
|
|
|
45
45
|
export {
|
|
46
46
|
SchemaNotFoundError,
|
|
47
|
-
|
|
47
|
+
EntityNotFoundError,
|
|
48
48
|
GetReactiveError,
|
|
49
49
|
Err_exports
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-BBFJWWAV.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Err.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\nimport { type URI } from '@dxos/keys';\n\nexport class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError', 'Schema not found') {\n constructor(schema: string, options?: BaseErrorOptions) {\n super({ context: { schema }, ...options });\n }\n}\n\nexport class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Entity not found') {\n constructor(uri: URI.URI, options?: BaseErrorOptions) {\n super({ context: { uri }, ...options });\n }\n}\n\n/**\n * Reason why getting a reactive object from a snapshot failed.\n * - `no-database`: The snapshot is not associated with a database.\n * - `object-not-found`: The object was removed or does not exist in the database.\n */\nexport type GetReactiveErrorReason = 'no-database' | 'object-not-found';\n\n/**\n * Error thrown when a reactive object cannot be resolved from a snapshot.\n * Extends `BaseError` with a `reason` and optional `snapshotId` in its context.\n */\nexport class GetReactiveError extends BaseError.extend(\n 'GetReactiveError',\n 'Failed to get reactive object from snapshot',\n) {\n constructor(options: { reason: GetReactiveErrorReason; snapshotId?: string } & BaseErrorOptions) {\n super({ context: { reason: options.reason, snapshotId: options.snapshotId }, ...options });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;AAMA,SAASA,iBAAwC;AAG1C,IAAMC,sBAAN,cAAkCD,UAAUE,OAAO,uBAAuB,kBAAA,EAAA;EAC/E,YAAYC,QAAgBC,SAA4B;AACtD,UAAM;MAAEC,SAAS;QAAEF;MAAO;MAAG,GAAGC;IAAQ,CAAA;EAC1C;AACF;AAEO,IAAME,sBAAN,cAAkCN,UAAUE,OAAO,uBAAuB,kBAAA,EAAA;EAC/E,YAAYK,KAAcH,SAA4B;AACpD,UAAM;MAAEC,SAAS;QAAEE;MAAI;MAAG,GAAGH;IAAQ,CAAA;EACvC;AACF;AAaO,IAAMI,mBAAN,cAA+BR,UAAUE,OAC9C,oBACA,6CAAA,EAAA;EAEA,YAAYE,SAAqF;AAC/F,UAAM;MAAEC,SAAS;QAAEI,QAAQL,QAAQK;QAAQC,YAAYN,QAAQM;MAAW;MAAG,GAAGN;IAAQ,CAAA;EAC1F;AACF;",
|
|
6
|
+
"names": ["BaseError", "SchemaNotFoundError", "extend", "schema", "options", "context", "EntityNotFoundError", "uri", "GetReactiveError", "reason", "snapshotId"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getURI,
|
|
3
|
+
make
|
|
4
|
+
} from "./chunk-Q5FKCVBC.mjs";
|
|
5
|
+
import {
|
|
6
|
+
makeObject
|
|
7
|
+
} from "./chunk-JE7AOSWF.mjs";
|
|
8
|
+
import {
|
|
9
|
+
FormInputAnnotation,
|
|
10
|
+
HiddenAnnotation,
|
|
11
|
+
IconAnnotation
|
|
12
|
+
} from "./chunk-H26LSXVJ.mjs";
|
|
13
|
+
import {
|
|
14
|
+
__export
|
|
15
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
16
|
+
|
|
17
|
+
// src/Feed.ts
|
|
18
|
+
var Feed_exports = {};
|
|
19
|
+
__export(Feed_exports, {
|
|
20
|
+
ContextFeedService: () => ContextFeedService,
|
|
21
|
+
Feed: () => Feed,
|
|
22
|
+
FeedService: () => FeedService,
|
|
23
|
+
Service: () => Service,
|
|
24
|
+
append: () => append,
|
|
25
|
+
cursor: () => cursor,
|
|
26
|
+
getQueueUri: () => getQueueUri,
|
|
27
|
+
getSyncState: () => getSyncState,
|
|
28
|
+
make: () => make2,
|
|
29
|
+
next: () => next,
|
|
30
|
+
nextOption: () => nextOption,
|
|
31
|
+
notAvailable: () => notAvailable,
|
|
32
|
+
query: () => query,
|
|
33
|
+
remove: () => remove,
|
|
34
|
+
runQuery: () => runQuery,
|
|
35
|
+
setRetention: () => setRetention,
|
|
36
|
+
sync: () => sync
|
|
37
|
+
});
|
|
38
|
+
import * as Context from "effect/Context";
|
|
39
|
+
import * as Effect from "effect/Effect";
|
|
40
|
+
import * as Layer from "effect/Layer";
|
|
41
|
+
import * as Schema from "effect/Schema";
|
|
42
|
+
import { DXN, EID } from "@dxos/keys";
|
|
43
|
+
var Feed = Schema.Struct({
|
|
44
|
+
/** User-facing display name. */
|
|
45
|
+
name: Schema.String.pipe(Schema.optional),
|
|
46
|
+
/** Identifier for the feed's kind (e.g., plugin id). */
|
|
47
|
+
kind: Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
48
|
+
/**
|
|
49
|
+
* Feed namespace.
|
|
50
|
+
* Controls how feed data is stored and replicated.
|
|
51
|
+
* - `data`: Data feed (default).
|
|
52
|
+
* - `trace`: Trace feed.
|
|
53
|
+
*/
|
|
54
|
+
namespace: Schema.optional(Schema.Literal("data", "trace"))
|
|
55
|
+
}).pipe(HiddenAnnotation.set(true), IconAnnotation.set({
|
|
56
|
+
icon: "ph--rows--regular",
|
|
57
|
+
hue: "yellow"
|
|
58
|
+
}), makeObject(DXN.make("org.dxos.type.feed", "0.1.0")));
|
|
59
|
+
var make2 = (props = {}) => make(Feed, props);
|
|
60
|
+
var getQueueUri = (feed) => EID.tryParse(getURI(feed));
|
|
61
|
+
var FeedService = class extends Context.Tag("@dxos/echo/Feed/FeedService")() {
|
|
62
|
+
};
|
|
63
|
+
var Service = FeedService;
|
|
64
|
+
var ContextFeedService = class _ContextFeedService extends Context.Tag("@dxos/echo/Feed/ContextFeedService")() {
|
|
65
|
+
static layer = (feed) => Layer.succeed(_ContextFeedService, {
|
|
66
|
+
feed
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
var notAvailable = Layer.succeed(FeedService, {
|
|
70
|
+
append: () => {
|
|
71
|
+
throw new Error("Feed.FeedService not available");
|
|
72
|
+
},
|
|
73
|
+
remove: () => {
|
|
74
|
+
throw new Error("Feed.FeedService not available");
|
|
75
|
+
},
|
|
76
|
+
query: () => {
|
|
77
|
+
throw new Error("Feed.FeedService not available");
|
|
78
|
+
},
|
|
79
|
+
sync: () => {
|
|
80
|
+
throw new Error("Feed.FeedService not available");
|
|
81
|
+
},
|
|
82
|
+
getSyncState: () => {
|
|
83
|
+
throw new Error("Feed.FeedService not available");
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
var append = (feed, items) => Effect.gen(function* () {
|
|
87
|
+
const service = yield* FeedService;
|
|
88
|
+
yield* Effect.promise(() => service.append(feed, items));
|
|
89
|
+
});
|
|
90
|
+
var remove = (feed, items) => Effect.gen(function* () {
|
|
91
|
+
const service = yield* FeedService;
|
|
92
|
+
const ids = items.map((item) => item.id);
|
|
93
|
+
yield* Effect.promise(() => service.remove(feed, ids));
|
|
94
|
+
});
|
|
95
|
+
var query = (feed, queryOrFilter) => FeedService.pipe(Effect.map((service) => service.query(feed, queryOrFilter)));
|
|
96
|
+
var runQuery = (feed, queryOrFilter) => query(feed, queryOrFilter).pipe(Effect.flatMap((queryResult) => Effect.promise(() => queryResult.run())));
|
|
97
|
+
var sync = (feed, options) => Effect.gen(function* () {
|
|
98
|
+
const service = yield* FeedService;
|
|
99
|
+
yield* Effect.promise(() => service.sync(feed, options));
|
|
100
|
+
});
|
|
101
|
+
var getSyncState = (feed) => Effect.gen(function* () {
|
|
102
|
+
const service = yield* FeedService;
|
|
103
|
+
return yield* Effect.promise(() => service.getSyncState(feed));
|
|
104
|
+
});
|
|
105
|
+
var cursor = (_feed) => Effect.succeed({
|
|
106
|
+
_tag: "Cursor"
|
|
107
|
+
});
|
|
108
|
+
var next = (_cursor) => Effect.die("Feed.next is not yet implemented");
|
|
109
|
+
var nextOption = (_cursor) => Effect.die("Feed.nextOption is not yet implemented");
|
|
110
|
+
var setRetention = (_feed, _options) => Effect.void;
|
|
111
|
+
|
|
112
|
+
export {
|
|
113
|
+
Feed,
|
|
114
|
+
make2 as make,
|
|
115
|
+
getQueueUri,
|
|
116
|
+
FeedService,
|
|
117
|
+
Service,
|
|
118
|
+
ContextFeedService,
|
|
119
|
+
notAvailable,
|
|
120
|
+
append,
|
|
121
|
+
remove,
|
|
122
|
+
query,
|
|
123
|
+
runQuery,
|
|
124
|
+
sync,
|
|
125
|
+
getSyncState,
|
|
126
|
+
cursor,
|
|
127
|
+
next,
|
|
128
|
+
nextOption,
|
|
129
|
+
setRetention,
|
|
130
|
+
Feed_exports
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=chunk-BDQGMDIX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Feed.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport type * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { DXN, EID } from '@dxos/keys';\n\nimport * as Annotation from './Annotation';\nimport type * as Entity from './Entity';\nimport type * as Filter from './Filter';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport type * as Query from './Query';\nimport type * as QueryResult from './QueryResult';\nimport * as Type from './Type';\n\n/**\n * Runtime schema for a Feed object.\n *\n * @example\n * ```ts\n * const feed = Obj.make(Feed.Feed, { name: 'notifications', kind: 'org.dxos.plugin.notifications.v1' });\n * ```\n */\nexport const Feed = Schema.Struct({\n /** User-facing display name. */\n name: Schema.String.pipe(Schema.optional),\n /** Identifier for the feed's kind (e.g., plugin id). */\n kind: Schema.String.pipe(internal.FormInputAnnotation.set(false), Schema.optional),\n\n /**\n * Feed namespace.\n * Controls how feed data is stored and replicated.\n * - `data`: Data feed (default).\n * - `trace`: Trace feed.\n */\n namespace: Schema.optional(Schema.Literal('data', 'trace')),\n}).pipe(\n internal.HiddenAnnotation.set(true),\n Annotation.IconAnnotation.set({ icon: 'ph--rows--regular', hue: 'yellow' }),\n Type.makeObject(DXN.make('org.dxos.type.feed', '0.1.0')),\n);\n\n/**\n * TypeScript instance type for a Feed object.\n */\nexport type Feed = Type.InstanceType<typeof Feed>;\n\n//\n// Types\n//\n\n/**\n * Opaque cursor for iterating over feed items.\n */\n// TODO(dmaretskyi): T needs to be referenced in the type structure for typescript to respect it during inference and type-checking.\nexport interface Cursor<T = Obj.Snapshot> {\n readonly _tag: 'Cursor';\n}\n\n/**\n * Retention options for a feed.\n */\nexport interface RetentionOptions {\n /** Retain items after this cursor position. */\n // TODO(wittjosiah): Use FeedCursor from @dxos/feed?\n cursor?: string;\n}\n\n/**\n * Sync options for a feed.\n */\nexport interface SyncOptions {\n /** Push local changes to the server. Defaults to true. */\n shouldPush?: boolean;\n /** Pull remote changes from the server. Defaults to true. */\n shouldPull?: boolean;\n}\n\n/**\n * Queue replication backlog for a feed namespace.\n * `0` / `0` means caught up on pull and push.\n */\nexport interface SyncState {\n /** Blocks still to pull from remote. */\n blocksToPull: number;\n /** Unpositioned blocks still to push to remote. */\n blocksToPush: number;\n /** Total blocks stored locally for the feed namespace. */\n totalBlocks: number;\n}\n\n//\n// Factory\n//\n\n/**\n * Creates a new feed object.\n *\n * @example\n * ```ts\n * const feed = Feed.make({ name: 'notifications', kind: 'org.dxos.plugin.notifications.v1' });\n * ```\n */\n// TODO(wittjosiah): How to control the feed namespace (data/trace)? Why do feeds have namespaces?\nexport const make = (props: Obj.MakeProps<typeof Feed> = {}): Feed => Obj.make(Feed, props);\n\n/**\n * Returns the feed object's EID when the feed is stored in a space.\n *\n * Used internally by the feed service layer.\n */\nexport const getQueueUri = (feed: Feed): EID.EID | undefined => EID.tryParse(Obj.getURI(feed));\n\n//\n// Service\n//\n\n/**\n * Effect service for feed operations.\n * Provides the bridge to the underlying storage implementation.\n * Must be provided by the application layer (e.g., echo-db).\n */\nexport class FeedService extends Context.Tag('@dxos/echo/Feed/FeedService')<\n FeedService,\n {\n /**\n * Appends items to a feed.\n */\n append(feed: Feed, items: Entity.Unknown[]): Promise<void>;\n\n /**\n * Removes items from a feed by ID.\n */\n remove(feed: Feed, ids: string[]): Promise<void>;\n\n /**\n * Queries items in a feed.\n */\n query: {\n <Q extends Query.Any>(feed: Feed, query: Q): QueryResult.QueryResult<Query.Type<Q>>;\n <F extends Filter.Any>(feed: Feed, filter: F): QueryResult.QueryResult<Filter.Type<F>>;\n };\n\n /**\n * Syncs the feed with the server.\n */\n sync(feed: Feed, options?: SyncOptions): Promise<void>;\n\n /**\n * Returns queue replication backlog for the feed's namespace.\n */\n getSyncState(feed: Feed): Promise<SyncState>;\n }\n>() {}\n\n/**\n * @deprecated Use `FeedService` instead.\n */\nexport type Service = FeedService;\n\n/**\n * @deprecated Use `FeedService` instead.\n */\nexport const Service = FeedService;\n\n/**\n * Effect context service that holds the current feed for a scoped operation.\n *\n * @deprecated Prefer threading a `Feed.Feed` explicitly through function signatures\n * over hiding it behind a context service.\n */\nexport class ContextFeedService extends Context.Tag('@dxos/echo/Feed/ContextFeedService')<\n ContextFeedService,\n {\n readonly feed: Feed;\n }\n>() {\n static layer = (feed: Feed): Layer.Layer<ContextFeedService> => Layer.succeed(ContextFeedService, { feed });\n}\n\n/**\n * Layer that provides a Feed service that throws when accessed.\n * Useful as a default layer when no feed service is available.\n */\nexport const notAvailable: Layer.Layer<FeedService> = Layer.succeed(FeedService, {\n append: () => {\n throw new Error('Feed.FeedService not available');\n },\n remove: () => {\n throw new Error('Feed.FeedService not available');\n },\n query: () => {\n throw new Error('Feed.FeedService not available');\n },\n sync: () => {\n throw new Error('Feed.FeedService not available');\n },\n getSyncState: () => {\n throw new Error('Feed.FeedService not available');\n },\n} as Context.Tag.Service<FeedService>);\n\n//\n// Operations\n//\n\n/**\n * Appends items to a feed.\n *\n * @example\n * ```ts\n * yield* Feed.append(feed, [Obj.make(Notification, { title: 'Hello' })]);\n * ```\n */\nexport const append = (feed: Feed, items: Entity.Unknown[]): Effect.Effect<void, never, FeedService> =>\n Effect.gen(function* () {\n const service = yield* FeedService;\n yield* Effect.promise(() => service.append(feed, items));\n });\n\n/**\n * Removes items from a feed.\n *\n * @example\n * ```ts\n * yield* Feed.remove(feed, [item]);\n * ```\n */\n// TODO(dmaretskyi): Should we allow snapshots here? - what does it mean to remove a snapshot?\nexport const remove = (feed: Feed, items: (Entity.Unknown | Obj.Snapshot)[]): Effect.Effect<void, never, FeedService> =>\n Effect.gen(function* () {\n const service = yield* FeedService;\n const ids = items.map((item) => item.id);\n yield* Effect.promise(() => service.remove(feed, ids));\n });\n\n/**\n * Creates a reactive query over items in a feed.\n *\n * @example\n * ```ts\n * const result = yield* Feed.query(feed, Filter.type(Person));\n * ```\n */\n// TODO(dmaretskyi): Suport chained queries:\n// const result = yield* feed.pipe(Feed.query(Filter.type(Person))); result.subscribe(...)\n// const objects = yield* feed.pipe(Feed.query(Filter.type(Person))).run;\n// const object = yield* feed.pipe(Feed.query(Filter.type(Person))).first;\n// ... unify for Database and schema queries.\nexport const query: {\n <Q extends Query.Any>(\n feed: Feed,\n query: Q,\n ): Effect.Effect<QueryResult.QueryResult<Query.Type<Q>>, never, FeedService>;\n <F extends Filter.Any>(\n feed: Feed,\n filter: F,\n ): Effect.Effect<QueryResult.QueryResult<Filter.Type<F>>, never, FeedService>;\n} = (feed: Feed, queryOrFilter: Query.Any | Filter.Any) =>\n FeedService.pipe(Effect.map((service) => service.query(feed, queryOrFilter as any) as QueryResult.QueryResult<any>));\n\n/**\n * Executes a feed query once and returns the results.\n *\n * @example\n * ```ts\n * const items = yield* Feed.runQuery(feed, Filter.type(Person));\n * ```\n */\nexport const runQuery: {\n <Q extends Query.Any>(feed: Feed, query: Q): Effect.Effect<Query.Type<Q>[], never, FeedService>;\n <F extends Filter.Any>(feed: Feed, filter: F): Effect.Effect<Filter.Type<F>[], never, FeedService>;\n} = (feed: Feed, queryOrFilter: Query.Any | Filter.Any) =>\n query(feed, queryOrFilter as any).pipe(Effect.flatMap((queryResult) => Effect.promise(() => queryResult.run())));\n\n/**\n * Syncs the feed with the server.\n *\n * @example\n * ```ts\n * yield* Feed.sync(feed);\n * yield* Feed.sync(feed, { shouldPush: false });\n * ```\n */\nexport const sync = (feed: Feed, options?: SyncOptions): Effect.Effect<void, never, FeedService> =>\n Effect.gen(function* () {\n const service = yield* FeedService;\n yield* Effect.promise(() => service.sync(feed, options));\n });\n\n/**\n * Returns queue replication backlog for the feed's namespace.\n *\n * @example\n * ```ts\n * const { blocksToPull, blocksToPush } = yield* Feed.getSyncState(feed);\n * ```\n */\nexport const getSyncState = (feed: Feed): Effect.Effect<SyncState, never, FeedService> =>\n Effect.gen(function* () {\n const service = yield* FeedService;\n return yield* Effect.promise(() => service.getSyncState(feed));\n });\n\n/**\n * Creates a cursor for iterating over feed items.\n * Currently stubbed — cursor operations are not yet implemented.\n *\n * @example\n * ```ts\n * const cursor = yield* Feed.cursor<Person>(feed);\n * const item = yield* Feed.next(cursor);\n * ```\n */\n// TODO(wittjosiah): Implement cursor operations. Use Effect streams?\nexport const cursor = <T = Obj.Snapshot>(_feed: Feed): Effect.Effect<Cursor<T>, never, FeedService> =>\n Effect.succeed({ _tag: 'Cursor' } as Cursor<T>);\n\n/**\n * Returns the next item from a feed cursor.\n * Currently stubbed — cursor operations are not yet implemented.\n */\nexport const next = <T = Obj.Snapshot>(_cursor: Cursor<T>): Effect.Effect<T, never, FeedService> =>\n Effect.die('Feed.next is not yet implemented');\n\n/**\n * Returns the next item from a feed cursor as an Option.\n * Currently stubbed — cursor operations are not yet implemented.\n */\nexport const nextOption = <T = Obj.Snapshot>(_cursor: Cursor<T>): Effect.Effect<Option.Option<T>, never, FeedService> =>\n Effect.die('Feed.nextOption is not yet implemented');\n\n/**\n * Sets the local retention policy for a feed.\n * Currently stubbed — feeds do not yet support retention.\n *\n * @example\n * ```ts\n * yield* Feed.setRetention(feed, { count: 1000 });\n * ```\n */\n// TODO(dmaretskyi): Implement when feed retention is supported.\nexport const setRetention = (_feed: Feed, _options: RetentionOptions): Effect.Effect<void, never, FeedService> =>\n Effect.void;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;cAAAA;EAAA;;;;;;;;;AAMA,YAAYC,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AAEvB,YAAYC,YAAY;AAExB,SAASC,KAAKC,WAAW;AAmBlB,IAAMC,OAAcC,cAAO;;EAEhCC,MAAaC,cAAOC,KAAYC,eAAQ;;EAExCC,MAAaH,cAAOC,KAAcG,oBAAoBC,IAAI,KAAA,GAAeH,eAAQ;;;;;;;EAQjFI,WAAkBJ,gBAAgBK,eAAQ,QAAQ,OAAA,CAAA;AACpD,CAAA,EAAGN,KACQO,iBAAiBH,IAAI,IAAA,GACnBI,eAAeJ,IAAI;EAAEK,MAAM;EAAqBC,KAAK;AAAS,CAAA,GACpEC,WAAWC,IAAIC,KAAK,sBAAsB,OAAA,CAAA,CAAA;AAiE1C,IAAMA,QAAO,CAACC,QAAoC,CAAC,MAAgBD,KAAKjB,MAAMkB,KAAAA;AAO9E,IAAMC,cAAc,CAACC,SAAoCC,IAAIC,SAAaC,OAAOH,IAAAA,CAAAA;AAWjF,IAAMI,cAAN,cAAkCC,YAAI,6BAAA,EAAA,EAAA;AA+BxC;AAUE,IAAMC,UAAUF;AAQhB,IAAMG,qBAAN,MAAMA,4BAAmCF,YAAI,oCAAA,EAAA,EAAA;EAMlD,OAAOG,QAAQ,CAACR,SAAsDS,cA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ACT,QAAMC,UAAU,OAAOf;AACvB,SAAO,OAAcgB,eAAQ,MAAMD,QAAQH,aAAahB,IAAAA,CAAAA;AAC1D,CAAA;AAaK,IAAM+B,SAAS,CAAmBC,UAChCvB,eAAQ;EAAEwB,MAAM;AAAS,CAAA;AAM3B,IAAMC,OAAO,CAAmBC,YAC9BC,WAAI,kCAAA;AAMN,IAAMC,aAAa,CAAmBF,YACpCC,WAAI,wCAAA;AAYN,IAAME,eAAe,CAACN,OAAaO,aACjCC;",
|
|
6
|
+
"names": ["make", "Context", "Effect", "Layer", "Schema", "DXN", "EID", "Feed", "Struct", "name", "String", "pipe", "optional", "kind", "FormInputAnnotation", "set", "namespace", "Literal", "HiddenAnnotation", "IconAnnotation", "icon", "hue", "makeObject", "DXN", "make", "props", "getQueueUri", "feed", "EID", "tryParse", "getURI", "FeedService", "Tag", "Service", "ContextFeedService", "layer", "succeed", "notAvailable", "append", "Error", "remove", "query", "sync", "getSyncState", "items", "gen", "service", "promise", "ids", "map", "item", "id", "queryOrFilter", "runQuery", "flatMap", "queryResult", "run", "options", "cursor", "_feed", "_tag", "next", "_cursor", "die", "nextOption", "setRetention", "_options", "void"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/Scope.ts
|
|
6
|
+
var Scope_exports = {};
|
|
7
|
+
__export(Scope_exports, {
|
|
8
|
+
feed: () => feed,
|
|
9
|
+
registry: () => registry,
|
|
10
|
+
space: () => space
|
|
11
|
+
});
|
|
12
|
+
var space = (spaceId, options) => ({
|
|
13
|
+
_tag: "space",
|
|
14
|
+
...spaceId !== void 0 ? {
|
|
15
|
+
spaceId
|
|
16
|
+
} : {},
|
|
17
|
+
...options?.includeAllFeeds ? {
|
|
18
|
+
includeAllFeeds: true
|
|
19
|
+
} : {}
|
|
20
|
+
});
|
|
21
|
+
var registry = (location = "local") => ({
|
|
22
|
+
_tag: "registry",
|
|
23
|
+
location
|
|
24
|
+
});
|
|
25
|
+
var feed = (feedUri) => ({
|
|
26
|
+
_tag: "feed",
|
|
27
|
+
feedUri
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
space,
|
|
32
|
+
registry,
|
|
33
|
+
feed,
|
|
34
|
+
Scope_exports
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-CGTI5MXO.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Scope.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { type QueryAST } from '@dxos/echo-protocol';\n\n/**\n * Scope targeting a space's automerge documents.\n *\n * With no `spaceId`, targets the owning space — i.e. the space of whichever database\n * executes the query — so callers can reference \"this space\" without looking up its id.\n *\n * @example\n * ```ts\n * db.query(Filter.type(Person).from(Scope.space())); // owning space\n * db.query(Filter.type(Person).from(Scope.space(otherSpaceId))); // a specific space\n * ```\n */\nexport const space = (spaceId?: string, options?: { includeAllFeeds?: boolean }): QueryAST.SpaceScope => ({\n _tag: 'space',\n ...(spaceId !== undefined ? { spaceId } : {}),\n ...(options?.includeAllFeeds ? { includeAllFeeds: true } : {}),\n});\n\n/**\n * Scope targeting a code-shipped object/type registry.\n *\n * - `'local'` — the in-process registry attached to the hypergraph (default).\n * - `'remote'` — a remote registry service (not yet implemented).\n *\n * @example\n * ```ts\n * // Discover all types — persisted in the space and code-shipped in the registry.\n * db.query(Filter.type(Type.Type).from(Scope.space(), Scope.registry()));\n * ```\n */\nexport const registry = (location: 'local' | 'remote' = 'local'): QueryAST.RegistryScope => ({\n _tag: 'registry',\n location,\n});\n\n/**\n * Scope targeting a specific feed (by its underlying queue DXN).\n */\nexport const feed = (feedUri: string): QueryAST.FeedScope => ({\n _tag: 'feed',\n feedUri,\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;AAoBO,IAAMA,QAAQ,CAACC,SAAkBC,aAAkE;EACxGC,MAAM;EACN,GAAIF,YAAYG,SAAY;IAAEH;EAAQ,IAAI,CAAC;EAC3C,GAAIC,SAASG,kBAAkB;IAAEA,iBAAiB;EAAK,IAAI,CAAC;AAC9D;AAcO,IAAMC,WAAW,CAACC,WAA+B,aAAqC;EAC3FJ,MAAM;EACNI;AACF;AAKO,IAAMC,OAAO,CAACC,aAAyC;EAC5DN,MAAM;EACNM;AACF;",
|
|
6
|
+
"names": ["space", "spaceId", "options", "_tag", "undefined", "includeAllFeeds", "registry", "location", "feed", "feedUri"]
|
|
7
|
+
}
|