@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEchoReferenceSchema
|
|
3
|
+
} from "./chunk-7OAFN3OX.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Dictionary,
|
|
6
|
+
getDictionary,
|
|
7
|
+
setDictionary
|
|
8
|
+
} from "./chunk-H26LSXVJ.mjs";
|
|
9
|
+
import {
|
|
10
|
+
KindId,
|
|
11
|
+
SnapshotKindId
|
|
12
|
+
} from "./chunk-O6BH7EPN.mjs";
|
|
13
|
+
|
|
14
|
+
// src/internal/common/types/well-known-types.ts
|
|
15
|
+
import { DXN } from "@dxos/keys";
|
|
16
|
+
var TagTypeDXN = DXN.make("org.dxos.type.tag", "0.1.0");
|
|
17
|
+
|
|
18
|
+
// src/internal/common/types/meta.ts
|
|
19
|
+
import * as Schema from "effect/Schema";
|
|
20
|
+
import { ForeignKey } from "@dxos/echo-protocol";
|
|
21
|
+
import { invariant } from "@dxos/invariant";
|
|
22
|
+
import { DXN as DXN2 } from "@dxos/keys";
|
|
23
|
+
import { intersection } from "@dxos/util";
|
|
24
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/types/meta.ts";
|
|
25
|
+
var ATTR_META = "@meta";
|
|
26
|
+
var MetaId = /* @__PURE__ */ Symbol.for("@dxos/echo/Meta");
|
|
27
|
+
var TagRefSchema = Schema.suspend(() => (
|
|
28
|
+
// The factory yields a loosely-typed `Ref<any>` schema; narrow it to the Tag-typed ref.
|
|
29
|
+
createEchoReferenceSchema(void 0, DXN2.getName(TagTypeDXN), DXN2.getVersion(TagTypeDXN))
|
|
30
|
+
));
|
|
31
|
+
var EntityMetaSchema = Schema.Struct({
|
|
32
|
+
keys: Schema.Array(ForeignKey),
|
|
33
|
+
/**
|
|
34
|
+
* Tags applied to this entity, as references to {@link Tag} objects.
|
|
35
|
+
*/
|
|
36
|
+
tags: Schema.Array(TagRefSchema),
|
|
37
|
+
/**
|
|
38
|
+
* Fully-qualified registry key for the object (FQN format, e.g. `org.example.type.foo`).
|
|
39
|
+
* Identifies the canonical registry entry the object instance was created from.
|
|
40
|
+
*/
|
|
41
|
+
key: Schema.optional(Schema.String),
|
|
42
|
+
/**
|
|
43
|
+
* Semantic version of the registry entry the object was created from.
|
|
44
|
+
* Must be a valid semver string (e.g. `1.2.3`).
|
|
45
|
+
*/
|
|
46
|
+
version: Schema.optional(Schema.String),
|
|
47
|
+
/**
|
|
48
|
+
* Dictionary of annotations to this entity.
|
|
49
|
+
*/
|
|
50
|
+
annotations: Dictionary
|
|
51
|
+
});
|
|
52
|
+
var getMeta = (obj) => {
|
|
53
|
+
const metadata = obj[MetaId];
|
|
54
|
+
invariant(metadata, "EntityMeta not found.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 57, S: void 0, A: ["metadata", "'EntityMeta not found.'"] });
|
|
55
|
+
return metadata;
|
|
56
|
+
};
|
|
57
|
+
var foreignKey = (source, id) => ({
|
|
58
|
+
source,
|
|
59
|
+
id
|
|
60
|
+
});
|
|
61
|
+
var foreignKeyEquals = (a, b) => a.source === b.source && a.id === b.id;
|
|
62
|
+
var compareForeignKeys = (a, b) => intersection(getMeta(a).keys, getMeta(b).keys, foreignKeyEquals).length > 0;
|
|
63
|
+
|
|
64
|
+
// src/internal/common/api/meta.ts
|
|
65
|
+
import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
|
|
66
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/common/api/meta.ts";
|
|
67
|
+
function getMetaChecked(entity) {
|
|
68
|
+
assertArgument(entity, "entity", "Should be an entity.");
|
|
69
|
+
const meta = getMeta(entity);
|
|
70
|
+
invariant2(meta != null, "Invalid entity.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 9, S: this, A: ["meta != null", "'Invalid entity.'"] });
|
|
71
|
+
return meta;
|
|
72
|
+
}
|
|
73
|
+
var getKeys = (entity, source) => {
|
|
74
|
+
assertArgument(entity, "entity", "Should be an entity.");
|
|
75
|
+
const meta = getMetaChecked(entity);
|
|
76
|
+
invariant2(meta != null, "Invalid entity.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 18, S: void 0, A: ["meta != null", "'Invalid entity.'"] });
|
|
77
|
+
return meta.keys.filter((key) => key.source === source);
|
|
78
|
+
};
|
|
79
|
+
var deleteKeys = (entity, source) => {
|
|
80
|
+
const meta = getMetaChecked(entity);
|
|
81
|
+
for (let i = 0; i < meta.keys.length; i++) {
|
|
82
|
+
if (meta.keys[i].source === source) {
|
|
83
|
+
meta.keys.splice(i, 1);
|
|
84
|
+
i--;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var addTag = (entity, tag) => {
|
|
89
|
+
const meta = getMetaChecked(entity);
|
|
90
|
+
if (!meta.tags.some((existing) => existing.uri === tag.uri)) {
|
|
91
|
+
meta.tags.push(tag);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var removeTag = (entity, tag) => {
|
|
95
|
+
const meta = getMetaChecked(entity);
|
|
96
|
+
for (let i = 0; i < meta.tags.length; i++) {
|
|
97
|
+
if (meta.tags[i].uri === tag.uri) {
|
|
98
|
+
meta.tags.splice(i, 1);
|
|
99
|
+
i--;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/internal/Entity/guard.ts
|
|
105
|
+
var isEntity = (value) => {
|
|
106
|
+
if (typeof value !== "object" || value === null) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return value[KindId] !== void 0;
|
|
110
|
+
};
|
|
111
|
+
var isSnapshot = (value) => {
|
|
112
|
+
if (typeof value !== "object" || value === null) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return value[SnapshotKindId] !== void 0;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/internal/Annotation/entity-dictionary.ts
|
|
119
|
+
var get = (target, annotation) => {
|
|
120
|
+
if (isEntity(target) || isSnapshot(target)) {
|
|
121
|
+
const meta = getMetaChecked(target);
|
|
122
|
+
return getDictionary(meta.annotations, annotation);
|
|
123
|
+
} else {
|
|
124
|
+
throw new TypeError("Target is not an annotation target.");
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
var set = (target, annotation, value) => {
|
|
128
|
+
if (isEntity(target)) {
|
|
129
|
+
const meta = getMetaChecked(target);
|
|
130
|
+
setDictionary(meta.annotations, annotation, value);
|
|
131
|
+
} else {
|
|
132
|
+
throw new TypeError("Target is not an annotation target.");
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
TagTypeDXN,
|
|
138
|
+
ATTR_META,
|
|
139
|
+
MetaId,
|
|
140
|
+
EntityMetaSchema,
|
|
141
|
+
getMeta,
|
|
142
|
+
foreignKey,
|
|
143
|
+
foreignKeyEquals,
|
|
144
|
+
compareForeignKeys,
|
|
145
|
+
getMetaChecked,
|
|
146
|
+
getKeys,
|
|
147
|
+
deleteKeys,
|
|
148
|
+
addTag,
|
|
149
|
+
removeTag,
|
|
150
|
+
isEntity,
|
|
151
|
+
get,
|
|
152
|
+
set
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=chunk-4BB4MFCN.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/common/types/well-known-types.ts", "../../../src/internal/common/types/meta.ts", "../../../src/internal/common/api/meta.ts", "../../../src/internal/Entity/guard.ts", "../../../src/internal/Annotation/entity-dictionary.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { DXN } from '@dxos/keys';\n\n/**\n * DXN identity of the system {@link Tag} type.\n *\n * Defined in this low-level leaf so it can be shared by the public `Tag` type (which brands the\n * schema with this DXN) and by `EntityMetaSchema.tags` (which builds a `Ref<Tag>` schema from it)\n * without either importing the other — `Tag` is top-level and `meta` is deep-internal, so a direct\n * dependency between them would form an eval-order cycle.\n */\nexport const TagTypeDXN = DXN.make('org.dxos.type.tag', '0.1.0');\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { type EncodedReference, ForeignKey } from '@dxos/echo-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { DXN } from '@dxos/keys';\nimport { type Comparator, intersection } from '@dxos/util';\n\nimport type * as Entity from '../../../Entity';\nimport type * as Tag from '../../../Tag';\nimport { Dictionary } from '../../Annotation/dictionary';\n// `meta` is no longer re-exported from the `common/types` barrel (see ./index.ts), so importing the\n// Ref schema builder here no longer forms an eval-order cycle with `Annotation`/`Database`.\nimport { type Ref, createEchoReferenceSchema } from '../../Ref/ref';\nimport { type AnyProperties } from './base';\nimport { TagTypeDXN } from './well-known-types';\n\n/**\n * Property name for meta when object is serialized to JSON.\n */\nexport const ATTR_META = '@meta';\n\n/**\n * Metadata section.\n */\nexport const MetaId: Entity.Meta = Symbol.for('@dxos/echo/Meta') as any;\n\n//\n// EntityMeta\n//\n\n/**\n * Schema for references to {@link Tag} objects stored in {@link EntityMetaSchema.tags}.\n *\n * Built from the shared {@link createEchoReferenceSchema} (the same builder `Ref.Ref` uses) via\n * `Schema.suspend`, so it reuses the canonical ref codec rather than duplicating it. The Tag type\n * identity comes from the shared {@link TagTypeDXN} constant; `suspend` defers construction until\n * first use, and `Tag` is referenced type-only, so no `Tag` value import is needed.\n */\nconst TagRefSchema = Schema.suspend(\n (): Schema.Schema<Ref<Tag.Tag>, EncodedReference> =>\n // The factory yields a loosely-typed `Ref<any>` schema; narrow it to the Tag-typed ref.\n createEchoReferenceSchema(undefined, DXN.getName(TagTypeDXN), DXN.getVersion(TagTypeDXN)) as Schema.Schema<\n Ref<Tag.Tag>,\n EncodedReference\n >,\n);\n\nexport const EntityMetaSchema = Schema.Struct({\n keys: Schema.Array(ForeignKey),\n\n /**\n * Tags applied to this entity, as references to {@link Tag} objects.\n */\n tags: Schema.Array(TagRefSchema),\n\n /**\n * Fully-qualified registry key for the object (FQN format, e.g. `org.example.type.foo`).\n * Identifies the canonical registry entry the object instance was created from.\n */\n key: Schema.optional(Schema.String),\n\n /**\n * Semantic version of the registry entry the object was created from.\n * Must be a valid semver string (e.g. `1.2.3`).\n */\n version: Schema.optional(Schema.String),\n\n /**\n * Dictionary of annotations to this entity.\n */\n annotations: Dictionary,\n});\n\nexport type EntityMeta = Schema.Schema.Type<typeof EntityMetaSchema>;\n\n/*\n * Get metadata from object.\n * Only callable on the object root.\n *\n * @internal (use Obj.getMeta or Relation.getMeta)\n */\n// TODO(burdon): Refine type to BaseObj.\nexport const getMeta = (obj: AnyProperties): EntityMeta => {\n const metadata = (obj as any)[MetaId];\n invariant(metadata, 'EntityMeta not found.');\n return metadata;\n};\n\n//\n// Foreign keys\n//\n\nexport const foreignKey = (source: string, id: string): ForeignKey => ({ source, id });\nexport const foreignKeyEquals = (a: ForeignKey, b: ForeignKey) => a.source === b.source && a.id === b.id;\n\n// TODO(dmaretskyi): Move to echo-schema.\nexport const compareForeignKeys: Comparator<AnyProperties> = (a: AnyProperties, b: AnyProperties) =>\n intersection(getMeta(a).keys, getMeta(b).keys, foreignKeyEquals).length > 0;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport type { DeepReadonly } from '@dxos/util';\n\nimport type * as Tag from '../../../Tag';\nimport type { Ref } from '../../Ref/ref';\nimport { type Mutable } from '../proxy';\nimport { type AnyProperties } from '../types';\nimport { type EntityMeta, getMeta as getMeta$ } from '../types/meta';\n\n/**\n * Deeply read-only version of EntityMeta.\n */\nexport type ReadonlyMeta = DeepReadonly<EntityMeta>;\n\n/**\n * Mutable meta type received in meta mutation callbacks.\n */\nexport type Meta = Mutable<EntityMeta>;\n\n/**\n * Get the metadata for an entity with validation.\n * Returns mutable meta when passed a mutable entity (inside change callback).\n * Returns read-only meta when passed a regular entity or snapshot.\n *\n * TODO(burdon): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.\n */\nexport function getMetaChecked(entity: Mutable<AnyProperties>): Meta;\nexport function getMetaChecked(entity: AnyProperties): ReadonlyMeta;\nexport function getMetaChecked(entity: AnyProperties): Meta | ReadonlyMeta {\n assertArgument(entity, 'entity', 'Should be an entity.');\n const meta = getMeta$(entity);\n invariant(meta != null, 'Invalid entity.');\n return meta;\n}\n\n/**\n * @returns Foreign keys for the entity from the specified source.\n * Accepts both reactive entities and snapshots.\n */\nexport const getKeys = (entity: AnyProperties, source: string): ForeignKey[] => {\n assertArgument(entity, 'entity', 'Should be an entity.');\n const meta = getMetaChecked(entity);\n invariant(meta != null, 'Invalid entity.');\n return meta.keys.filter((key) => key.source === source);\n};\n\n/**\n * Delete all keys from the entity for the specified source.\n * Must be called within an Obj.update or Relation.update callback.\n */\nexport const deleteKeys = (entity: Mutable<AnyProperties>, source: string) => {\n const meta = getMetaChecked(entity);\n for (let i = 0; i < meta.keys.length; i++) {\n if (meta.keys[i].source === source) {\n meta.keys.splice(i, 1);\n i--;\n }\n }\n};\n\n/**\n * Add a tag (a reference to a {@link Tag} object) to the entity. Idempotent.\n * Must be called within an Obj.update or Relation.update callback.\n */\nexport const addTag = (entity: Mutable<AnyProperties>, tag: Ref<Tag.Tag>) => {\n const meta = getMetaChecked(entity);\n // Two refs to the same target are not `===`; dedupe by URI.\n if (!meta.tags.some((existing) => existing.uri === tag.uri)) {\n meta.tags.push(tag);\n }\n};\n\n/**\n * Remove a tag (a reference to a {@link Tag} object) from the entity. No-op when not present.\n * Must be called within an Obj.update or Relation.update callback.\n */\nexport const removeTag = (entity: Mutable<AnyProperties>, tag: Ref<Tag.Tag>) => {\n const meta = getMetaChecked(entity);\n for (let i = 0; i < meta.tags.length; i++) {\n if (meta.tags[i].uri === tag.uri) {\n meta.tags.splice(i, 1);\n i--;\n }\n }\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as Entity from '../../Entity';\nimport { KindId, SnapshotKindId } from '../common/types';\n\n/**\n * Returns true if the value is an ECHO entity instance (object or relation).\n */\nexport const isEntity = (value: unknown): value is Entity.Unknown => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n return (value as any)[KindId] !== undefined;\n};\n\n/**\n * Returns true if the value is an ECHO entity snapshot.\n */\nexport const isSnapshot = (value: unknown): value is Entity.Snapshot => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n return (value as any)[SnapshotKindId] !== undefined;\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\n\nimport type * as Annotation from '../../Annotation';\nimport type * as Entity from '../../Entity';\nimport { getMetaChecked } from '../common/api/meta';\nimport { type Mutable } from '../common/proxy/reactive';\nimport { isEntity, isSnapshot } from '../Entity/guard';\nimport { getDictionary, setDictionary } from './dictionary';\n\n/**\n * Get the value of an annotation from an entity instance or snapshot.\n */\nexport const get = <T>(\n target: Entity.Unknown | Entity.Snapshot,\n annotation: Annotation.Annotation<T>,\n): Option.Option<T> => {\n if (isEntity(target) || isSnapshot(target)) {\n const meta = getMetaChecked(target);\n return getDictionary(meta.annotations, annotation);\n } else {\n throw new TypeError('Target is not an annotation target.');\n }\n};\n\n/**\n * Set the value of an annotation on an entity instance.\n * Must be called with a mutable entity — i.e. inside an `Obj.update` callback.\n */\nexport const set = <T>(target: Mutable<Entity.Unknown>, annotation: Annotation.Annotation<T>, value: T): void => {\n if (isEntity(target)) {\n const meta = getMetaChecked(target);\n setDictionary(meta.annotations, annotation, value);\n } else {\n throw new TypeError('Target is not an annotation target.');\n }\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["DXN", "TagTypeDXN", "make", "Schema", "ForeignKey", "invariant", "DXN", "intersection", "Schema", "Struct", "keys", "ForeignKey", "invariant", "metadata", "id", "compareForeignKeys", "a", "b", "intersection", "getMeta", "assertArgument", "invariant", "__dxlog_file", "getMetaChecked", "meta", "entity", "invariant", "keys", "key", "source", "splice", "i", "tags", "existing", "length", "uri", "isEntity", "value", "KindId", "undefined", "isSnapshot", "SnapshotKindId", "get", "target", "annotation", "isEntity", "isSnapshot", "meta", "getMetaChecked", "getDictionary", "annotations", "TypeError", "set", "value", "setDictionary"]
|
|
7
|
+
}
|
|
@@ -1,57 +1,62 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-NQRLRYJM.mjs";
|
|
4
|
-
import {
|
|
2
|
+
Kind,
|
|
5
3
|
KindId,
|
|
6
4
|
SnapshotKindId
|
|
7
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QVJDDG44.mjs";
|
|
6
|
+
import {
|
|
7
|
+
getSchema
|
|
8
|
+
} from "./chunk-JE7AOSWF.mjs";
|
|
8
9
|
import {
|
|
9
|
-
ATTR_RELATION_SOURCE,
|
|
10
|
-
ATTR_RELATION_TARGET,
|
|
11
|
-
EchoRelationSchema,
|
|
12
|
-
MetaId,
|
|
13
|
-
RelationSourceDXNId,
|
|
14
|
-
RelationSourceId,
|
|
15
|
-
RelationTargetDXNId,
|
|
16
|
-
RelationTargetId,
|
|
17
10
|
VersionTypeId,
|
|
18
|
-
addTag,
|
|
19
11
|
change,
|
|
20
|
-
deleteKeys,
|
|
21
|
-
getDXN,
|
|
22
|
-
getDatabase,
|
|
23
|
-
getKeys,
|
|
24
|
-
getMetaChecked,
|
|
25
|
-
getObjectDXN,
|
|
26
12
|
getSnapshot,
|
|
27
13
|
getValue,
|
|
28
14
|
isDeleted,
|
|
29
15
|
isVersion,
|
|
30
16
|
makeObject,
|
|
31
17
|
objectToJSON,
|
|
32
|
-
removeTag,
|
|
33
18
|
setValue,
|
|
34
19
|
sort,
|
|
35
20
|
sortByLabel,
|
|
36
21
|
sortByTypename,
|
|
37
22
|
subscribe,
|
|
38
23
|
version
|
|
39
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-OYUG4FHF.mjs";
|
|
25
|
+
import {
|
|
26
|
+
MetaId,
|
|
27
|
+
addTag,
|
|
28
|
+
deleteKeys,
|
|
29
|
+
getKeys,
|
|
30
|
+
getMetaChecked,
|
|
31
|
+
removeTag
|
|
32
|
+
} from "./chunk-4BB4MFCN.mjs";
|
|
40
33
|
import {
|
|
34
|
+
ATTR_RELATION_SOURCE,
|
|
35
|
+
ATTR_RELATION_TARGET,
|
|
41
36
|
ParentId,
|
|
37
|
+
RelationSourceDXNId,
|
|
38
|
+
RelationSourceId,
|
|
39
|
+
RelationTargetDXNId,
|
|
40
|
+
RelationTargetId,
|
|
41
|
+
TypeAnnotationId,
|
|
42
|
+
getDatabase,
|
|
42
43
|
getDescription,
|
|
43
44
|
getLabel,
|
|
44
|
-
|
|
45
|
+
getObjectEchoUri,
|
|
46
|
+
getType,
|
|
45
47
|
getTypeAnnotation,
|
|
46
|
-
|
|
48
|
+
getTypeURI,
|
|
47
49
|
getTypename,
|
|
50
|
+
getUri,
|
|
51
|
+
isInstanceOf,
|
|
48
52
|
setDescription,
|
|
49
53
|
setLabel
|
|
50
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-H26LSXVJ.mjs";
|
|
51
55
|
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
ANY_OBJECT_TYPENAME,
|
|
57
|
+
ANY_OBJECT_VERSION,
|
|
58
|
+
EntityKind
|
|
59
|
+
} from "./chunk-O6BH7EPN.mjs";
|
|
55
60
|
import {
|
|
56
61
|
__export
|
|
57
62
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -62,26 +67,26 @@ __export(Relation_exports, {
|
|
|
62
67
|
Meta: () => Meta,
|
|
63
68
|
Source: () => Source,
|
|
64
69
|
Target: () => Target,
|
|
65
|
-
Unknown: () =>
|
|
70
|
+
Unknown: () => Unknown2,
|
|
66
71
|
VersionTypeId: () => VersionTypeId2,
|
|
67
72
|
addTag: () => addTag2,
|
|
68
|
-
change: () => change2,
|
|
69
73
|
deleteKeys: () => deleteKeys2,
|
|
70
|
-
getDXN: () => getDXN2,
|
|
71
74
|
getDatabase: () => getDatabase2,
|
|
72
75
|
getDescription: () => getDescription2,
|
|
73
76
|
getKeys: () => getKeys2,
|
|
74
77
|
getLabel: () => getLabel2,
|
|
75
78
|
getMeta: () => getMeta,
|
|
76
|
-
getSchema: () => getSchema2,
|
|
77
79
|
getSnapshot: () => getSnapshot2,
|
|
78
80
|
getSource: () => getSource,
|
|
79
|
-
|
|
81
|
+
getSourceURI: () => getSourceURI,
|
|
80
82
|
getTarget: () => getTarget,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
getTargetURI: () => getTargetURI,
|
|
84
|
+
getType: () => getType2,
|
|
85
|
+
getTypeURI: () => getTypeURI2,
|
|
83
86
|
getTypename: () => getTypename2,
|
|
87
|
+
getURI: () => getURI,
|
|
84
88
|
getValue: () => getValue2,
|
|
89
|
+
instanceOf: () => instanceOf,
|
|
85
90
|
isDeleted: () => isDeleted2,
|
|
86
91
|
isRelation: () => isRelation,
|
|
87
92
|
isSnapshot: () => isSnapshot,
|
|
@@ -96,38 +101,34 @@ __export(Relation_exports, {
|
|
|
96
101
|
sortByTypename: () => sortByTypename2,
|
|
97
102
|
subscribe: () => subscribe2,
|
|
98
103
|
toJSON: () => toJSON,
|
|
104
|
+
update: () => update,
|
|
99
105
|
version: () => version2
|
|
100
106
|
});
|
|
101
107
|
import * as Schema from "effect/Schema";
|
|
102
108
|
import { raise } from "@dxos/debug";
|
|
103
109
|
import { createJsonPath } from "@dxos/effect";
|
|
104
110
|
import { assertArgument, invariant } from "@dxos/invariant";
|
|
105
|
-
import { DXN } from "@dxos/keys";
|
|
111
|
+
import { EID, DXN } from "@dxos/keys";
|
|
106
112
|
import { assumeType } from "@dxos/util";
|
|
107
113
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/Relation.ts";
|
|
108
|
-
var
|
|
114
|
+
var Unknown2 = Schema.Struct({
|
|
109
115
|
id: Schema.String
|
|
110
|
-
}).pipe(
|
|
111
|
-
Schema.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// The typename/version/source/target only satisfy ECHO schema machinery for reference targets.
|
|
118
|
-
EchoRelationSchema({
|
|
119
|
-
typename: "org.dxos.schema.any-relation",
|
|
116
|
+
}).pipe(Schema.extend(Schema.Record({
|
|
117
|
+
key: Schema.String,
|
|
118
|
+
value: Schema.Unknown
|
|
119
|
+
})), Schema.annotations({
|
|
120
|
+
[TypeAnnotationId]: {
|
|
121
|
+
kind: Kind.Relation,
|
|
122
|
+
typename: "org.dxos.schema.anyRelation",
|
|
120
123
|
version: "0.0.0",
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
[SchemaKindId]: schema[SchemaKindId]
|
|
126
|
-
})
|
|
127
|
-
);
|
|
124
|
+
sourceSchema: DXN.make(ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION),
|
|
125
|
+
targetSchema: DXN.make(ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION)
|
|
126
|
+
}
|
|
127
|
+
}));
|
|
128
128
|
var Source = RelationSourceId;
|
|
129
129
|
var Target = RelationTargetId;
|
|
130
|
-
var make = (
|
|
130
|
+
var make = (type, props) => {
|
|
131
|
+
const schema = getSchema(type);
|
|
131
132
|
assertArgument(getTypeAnnotation(schema)?.kind === EntityKind.Relation, "schema", "Expected a relation schema");
|
|
132
133
|
assertArgument(props[ParentId] === void 0, "props", "Parent is not allowed for relations");
|
|
133
134
|
let meta = void 0;
|
|
@@ -135,11 +136,17 @@ var make = (schema, props) => {
|
|
|
135
136
|
meta = props[MetaId];
|
|
136
137
|
delete props[MetaId];
|
|
137
138
|
}
|
|
138
|
-
const sourceDXN =
|
|
139
|
-
const targetDXN =
|
|
139
|
+
const sourceDXN = getObjectEchoUri(props[Source]) ?? raise(new Error("Unresolved relation source"));
|
|
140
|
+
const targetDXN = getObjectEchoUri(props[Target]) ?? raise(new Error("Unresolved relation target"));
|
|
140
141
|
props[RelationSourceDXNId] = sourceDXN;
|
|
141
142
|
props[RelationTargetDXNId] = targetDXN;
|
|
142
|
-
return makeObject(schema, props, meta);
|
|
143
|
+
return makeObject(schema, props, meta, type);
|
|
144
|
+
};
|
|
145
|
+
var instanceOf = (...args) => {
|
|
146
|
+
if (args.length === 1) {
|
|
147
|
+
return (entity) => isInstanceOf(args[0], entity);
|
|
148
|
+
}
|
|
149
|
+
return isInstanceOf(args[0], args[1]);
|
|
143
150
|
};
|
|
144
151
|
var isRelation = (value) => {
|
|
145
152
|
if (typeof value !== "object" || value === null) {
|
|
@@ -157,67 +164,39 @@ var isSnapshot = (value) => {
|
|
|
157
164
|
}
|
|
158
165
|
return value[SnapshotKindId] === EntityKind.Relation;
|
|
159
166
|
};
|
|
160
|
-
var
|
|
167
|
+
var getSourceURI = (value) => {
|
|
161
168
|
assertArgument(isRelation(value), "Expected a relation");
|
|
162
169
|
assumeType(value);
|
|
163
|
-
const
|
|
164
|
-
invariant(
|
|
165
|
-
|
|
166
|
-
L: 214,
|
|
167
|
-
S: void 0,
|
|
168
|
-
A: [
|
|
169
|
-
"dxn instanceof DXN",
|
|
170
|
-
""
|
|
171
|
-
]
|
|
172
|
-
});
|
|
173
|
-
return dxn;
|
|
170
|
+
const uri = value[RelationSourceDXNId];
|
|
171
|
+
invariant(EID.isEID(uri), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 120, S: void 0, A: ["EID.isEID(uri)", ""] });
|
|
172
|
+
return uri;
|
|
174
173
|
};
|
|
175
|
-
var
|
|
174
|
+
var getTargetURI = (value) => {
|
|
176
175
|
assertArgument(isRelation(value), "Expected a relation");
|
|
177
176
|
assumeType(value);
|
|
178
|
-
const
|
|
179
|
-
invariant(
|
|
180
|
-
|
|
181
|
-
L: 227,
|
|
182
|
-
S: void 0,
|
|
183
|
-
A: [
|
|
184
|
-
"dxn instanceof DXN",
|
|
185
|
-
""
|
|
186
|
-
]
|
|
187
|
-
});
|
|
188
|
-
return dxn;
|
|
177
|
+
const uri = value[RelationTargetDXNId];
|
|
178
|
+
invariant(EID.isEID(uri), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 131, S: void 0, A: ["EID.isEID(uri)", ""] });
|
|
179
|
+
return uri;
|
|
189
180
|
};
|
|
190
181
|
var getSource = (relation) => {
|
|
191
182
|
assertArgument(isRelation(relation), "Expected a relation");
|
|
192
183
|
assumeType(relation);
|
|
193
184
|
const obj = relation[RelationSourceId];
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
S: void 0,
|
|
198
|
-
A: [
|
|
199
|
-
"obj !== undefined",
|
|
200
|
-
"`Invalid source: ${relation.id}`"
|
|
201
|
-
]
|
|
202
|
-
});
|
|
185
|
+
if (obj === void 0) {
|
|
186
|
+
throw new Error(`Relation source could not be resolved.`);
|
|
187
|
+
}
|
|
203
188
|
return obj;
|
|
204
189
|
};
|
|
205
190
|
var getTarget = (relation) => {
|
|
206
191
|
assertArgument(isRelation(relation), "Expected a relation");
|
|
207
192
|
assumeType(relation);
|
|
208
193
|
const obj = relation[RelationTargetId];
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
S: void 0,
|
|
213
|
-
A: [
|
|
214
|
-
"obj !== undefined",
|
|
215
|
-
"`Invalid target: ${relation.id}`"
|
|
216
|
-
]
|
|
217
|
-
});
|
|
194
|
+
if (obj === void 0) {
|
|
195
|
+
throw new Error(`Relation target could not be resolved.`);
|
|
196
|
+
}
|
|
218
197
|
return obj;
|
|
219
198
|
};
|
|
220
|
-
var
|
|
199
|
+
var update = (relation, callback) => {
|
|
221
200
|
change(relation, callback);
|
|
222
201
|
};
|
|
223
202
|
var getSnapshot2 = getSnapshot;
|
|
@@ -228,9 +207,9 @@ var getValue2 = (rel, path) => {
|
|
|
228
207
|
return getValue(rel, createJsonPath(path));
|
|
229
208
|
};
|
|
230
209
|
var setValue2 = setValue;
|
|
231
|
-
var
|
|
232
|
-
var
|
|
233
|
-
var
|
|
210
|
+
var getURI = (entity) => getUri(entity);
|
|
211
|
+
var getTypeURI2 = getTypeURI;
|
|
212
|
+
var getType2 = (relation) => getType(relation);
|
|
234
213
|
var getTypename2 = (entity) => getTypename(entity);
|
|
235
214
|
var getDatabase2 = (entity) => getDatabase(entity);
|
|
236
215
|
var Meta = MetaId;
|
|
@@ -242,7 +221,7 @@ var deleteKeys2 = (entity, source) => deleteKeys(entity, source);
|
|
|
242
221
|
var addTag2 = (entity, tag) => addTag(entity, tag);
|
|
243
222
|
var removeTag2 = (entity, tag) => removeTag(entity, tag);
|
|
244
223
|
var isDeleted2 = (entity) => isDeleted(entity);
|
|
245
|
-
var getLabel2 = (entity) => getLabel(entity);
|
|
224
|
+
var getLabel2 = (entity, options) => getLabel(entity, options);
|
|
246
225
|
var setLabel2 = (entity, label) => setLabel(entity, label);
|
|
247
226
|
var getDescription2 = (entity) => getDescription(entity);
|
|
248
227
|
var setDescription2 = (entity, description) => setDescription(entity, description);
|
|
@@ -255,24 +234,25 @@ var isVersion2 = isVersion;
|
|
|
255
234
|
var version2 = (entity) => version(entity);
|
|
256
235
|
|
|
257
236
|
export {
|
|
258
|
-
|
|
237
|
+
Unknown2 as Unknown,
|
|
259
238
|
Source,
|
|
260
239
|
Target,
|
|
261
240
|
make,
|
|
241
|
+
instanceOf,
|
|
262
242
|
isRelation,
|
|
263
243
|
isSnapshot,
|
|
264
|
-
|
|
265
|
-
|
|
244
|
+
getSourceURI,
|
|
245
|
+
getTargetURI,
|
|
266
246
|
getSource,
|
|
267
247
|
getTarget,
|
|
268
|
-
|
|
248
|
+
update,
|
|
269
249
|
getSnapshot2 as getSnapshot,
|
|
270
250
|
subscribe2 as subscribe,
|
|
271
251
|
getValue2 as getValue,
|
|
272
252
|
setValue2 as setValue,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
253
|
+
getURI,
|
|
254
|
+
getTypeURI2 as getTypeURI,
|
|
255
|
+
getType2 as getType,
|
|
276
256
|
getTypename2 as getTypename,
|
|
277
257
|
getDatabase2 as getDatabase,
|
|
278
258
|
Meta,
|
|
@@ -295,4 +275,4 @@ export {
|
|
|
295
275
|
version2 as version,
|
|
296
276
|
Relation_exports
|
|
297
277
|
};
|
|
298
|
-
//# sourceMappingURL=chunk-
|
|
278
|
+
//# sourceMappingURL=chunk-4SFPZJVA.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Relation.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { raise } from '@dxos/debug';\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport { createJsonPath } from '@dxos/effect';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { EID, type EntityId, type URI, DXN } from '@dxos/keys';\nimport { assumeType } from '@dxos/util';\n\nimport type * as Database from './Database';\nimport * as Entity from './Entity';\nimport * as internal from './internal';\nimport * as entityInternal from './internal/Entity';\nimport * as Obj from './Obj';\nimport type * as Ref from './Ref';\nimport type * as Tag from './Tag';\nimport * as Type from './Type';\n\nexport type Endpoints<Source, Target> = {\n [Source]: Source;\n [Target]: Target;\n};\n\n/**\n * Base type for all ECHO relations.\n * @private\n */\ninterface BaseRelation<Source, Target>\n extends internal.AnyEntity, Endpoints<Source, Target>, Entity.OfKind<internal.EntityKind.Relation> {}\n\n/**\n * Relation with no known properties beyond id, kind, source, and target.\n * Use this when the relation's schema/properties are not known.\n *\n * NOTE: This is a TypeScript type only, not a schema.\n * To validate that a value is an ECHO relation, use `Relation.isRelation`.\n */\nexport interface Unknown extends BaseRelation<Obj.Unknown, Obj.Unknown> {}\n\n/**\n * Runtime Effect schema for any ECHO relation.\n * Use for validation, parsing, or as a reference target for collections.\n * A relation has `id`, source, and target fields plus any additional properties.\n *\n * NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).\n * Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.\n *\n * @example\n * ```ts\n * // Structural type guard (accepts any object with id field)\n * if (Schema.is(Type.Relation)(unknownValue)) { ... }\n *\n * // ECHO instance type guard (checks KindId brand)\n * if (Relation.isRelation(unknownValue)) { ... }\n * ```\n */\n// TODO(dmaretskyi): Change ObjModule.Any to ObjModule.Unknown to have stricter types.\nexport const Unknown: internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation> = Schema.Struct({\n id: Schema.String,\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n Schema.annotations({\n [internal.TypeAnnotationId]: {\n kind: Entity.Kind.Relation,\n typename: 'org.dxos.schema.anyRelation',\n version: '0.0.0',\n sourceSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),\n targetSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),\n },\n }),\n) as unknown as internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation>;\n\n/**\n * Relation type with specific source and target types.\n */\nexport type OfShape<Source extends Obj.Unknown, Target extends Obj.Unknown, Props> = BaseRelation<Source, Target> &\n Props;\n\n/**\n * Base type for snapshot relations (has SnapshotKindId instead of KindId).\n */\ninterface BaseRelationSnapshot<Source, Target> extends internal.AnyEntity, Endpoints<Source, Target> {\n readonly [Entity.SnapshotKindId]: internal.EntityKind.Relation;\n readonly id: EntityId;\n}\n\n/**\n * JSON-encoded properties for relations.\n */\nexport interface BaseRelationJson {\n id: string;\n [internal.ATTR_RELATION_SOURCE]: string;\n [internal.ATTR_RELATION_TARGET]: string;\n}\n\n/**\n * Immutable snapshot of an ECHO relation.\n * Branded with SnapshotKindId (not KindId).\n * Property values are frozen at the time the snapshot was created.\n * Returned by getSnapshot() and hooks.\n */\nexport type Snapshot<T extends Unknown = Unknown> = Omit<T, Entity.KindId> &\n BaseRelationSnapshot<Obj.Unknown, Obj.Unknown>;\n\nexport const Source: unique symbol = entityInternal.RelationSourceId as any;\nexport type Source = typeof Source;\n\nexport const Target: unique symbol = entityInternal.RelationTargetId as any;\nexport type Target = typeof Target;\n\n/**\n * Get relation source type.\n */\nexport type SourceOf<A> = A extends Endpoints<infer S, infer _T> ? S : never;\n\n/**\n * Get relation target type.\n */\nexport type TargetOf<A> = A extends Endpoints<infer _S, infer T> ? T : never;\n\n/**\n * Internal props type for relation instance creation.\n */\ntype MakePropsInternal<T extends Endpoints<any, any>> = {\n id?: EntityId;\n [Meta]?: Partial<internal.EntityMeta>;\n [Source]: T[Source];\n [Target]: T[Target];\n} & Entity.Properties<T>;\n\n/**\n * Props type for relation creation with a given schema. Accepts a `Type.AnyRelation`\n * entity (created with `Type.makeRelation`) and derives the props shape via\n * `Type.InstanceType`. Object-kind entities are rejected at the type level —\n * use `Obj.MakeProps` for those.\n */\nexport type MakeProps<S extends Type.AnyRelation> = MakePropsInternal<Type.InstanceType<S>>;\n\n/**\n * Creates new relation.\n * @param schema - Relation schema.\n * @param props - Relation properties. Endpoints are passed as [Relation.Source] and [Relation.Target] keys.\n * @param meta - Relation metadata. (deprecated; use [Obj.Meta] instead)\n * @returns\n */\n// NOTE: Writing the definition this way (with generic over schema) makes typescript perfer to infer the type from the first param (this schema) rather than the second param (the props).\n// TODO(dmaretskyi): Move meta into props.\nexport const make = <T extends Type.AnyRelation>(\n type: T,\n props: NoInfer<MakeProps<T>>,\n): Type.InstanceType<T> & Entity.OfKind<typeof Entity.Kind.Relation> => {\n const schema = Type.getSchema(type);\n assertArgument(\n internal.getTypeAnnotation(schema)?.kind === internal.EntityKind.Relation,\n 'schema',\n 'Expected a relation schema',\n );\n assertArgument(props[internal.ParentId] === undefined, 'props', 'Parent is not allowed for relations');\n\n let meta: internal.EntityMeta | undefined = undefined;\n\n if (props[internal.MetaId] != null) {\n meta = props[internal.MetaId] as any;\n delete props[internal.MetaId];\n }\n\n const sourceDXN = internal.getObjectEchoUri(props[Source]) ?? raise(new Error('Unresolved relation source'));\n const targetDXN = internal.getObjectEchoUri(props[Target]) ?? raise(new Error('Unresolved relation target'));\n\n (props as any)[internal.RelationSourceDXNId] = sourceDXN;\n (props as any)[internal.RelationTargetDXNId] = targetDXN;\n\n // Pass the type entity through as `typeSource` so the resulting instance\n // carries a back-reference resolvable via `Relation.getType` / `Entity.getType`.\n return internal.makeObject(schema as any, props as any, meta, type as any) as any;\n};\n\n/**\n * Test if a value is an instance of a given relation type.\n *\n * Mirrors `Obj.instanceOf` but only accepts `Type.AnyRelation` — use\n * `Obj.instanceOf` for objects and `Type.isType` for `Type.Type` entities.\n *\n * @example\n * ```ts\n * const isEmployedBy = Relation.instanceOf(EmployedBy);\n * if (isEmployedBy(relation)) {\n * // relation is EmployedBy\n * }\n * ```\n */\nexport const instanceOf: {\n <S extends Type.AnyRelation>(schema: S): (value: unknown) => value is Type.InstanceType<S>;\n <S extends Type.AnyRelation>(schema: S, value: unknown): value is Type.InstanceType<S>;\n} = ((...args: [schema: Type.AnyRelation, value?: unknown]) => {\n if (args.length === 1) {\n return (entity: unknown) => internal.isInstanceOf(args[0], entity);\n }\n return internal.isInstanceOf(args[0], args[1]);\n}) as any;\n\n/**\n * Type guard for relations.\n * Returns true for both reactive relations and relation snapshots.\n */\nexport const isRelation = (value: unknown): value is Unknown => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (internal.ATTR_RELATION_SOURCE in value || internal.ATTR_RELATION_TARGET in value) {\n return true;\n }\n\n // Check for reactive relation (KindId) or snapshot (SnapshotKindId).\n const kind = (value as any)[Entity.KindId] ?? (value as any)[Entity.SnapshotKindId];\n return kind === internal.EntityKind.Relation;\n};\n\nexport const isSnapshot = (value: unknown): value is Snapshot => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n return (value as any)[Entity.SnapshotKindId] === internal.EntityKind.Relation;\n};\n\n/**\n * @returns Relation source URI.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getSourceURI = (value: Unknown | Snapshot): EID.EID => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(value);\n const uri = (value as internal.InternalObjectProps)[internal.RelationSourceDXNId];\n invariant(EID.isEID(uri));\n return uri;\n};\n\n/**\n * @returns Relation target URI.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getTargetURI = (value: Unknown | Snapshot): EID.EID => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(value);\n const uri = (value as internal.InternalObjectProps)[internal.RelationTargetDXNId];\n invariant(EID.isEID(uri));\n return uri;\n};\n\n/**\n * @returns Relation source.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getSource = <T extends Unknown | Snapshot>(relation: T): SourceOf<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(relation);\n const obj = (relation as internal.InternalObjectProps)[internal.RelationSourceId];\n if (obj === undefined) {\n throw new Error(`Relation source could not be resolved.`);\n }\n return obj as SourceOf<T>;\n};\n\n/**\n * @returns Relation target.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getTarget = <T extends Unknown | Snapshot>(relation: T): TargetOf<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(relation);\n const obj = (relation as internal.InternalObjectProps)[internal.RelationTargetId];\n if (obj === undefined) {\n throw new Error(`Relation target could not be resolved.`);\n }\n return obj as TargetOf<T>;\n};\n\n//\n// Change\n//\n\n/**\n * Makes all properties mutable recursively.\n * Used to provide a mutable view of a relation within `Relation.update`.\n */\nexport type Mutable<T> = internal.Mutable<T>;\n\n/**\n * Perform mutations on an echo relation within a controlled context.\n *\n * All mutations within the callback are batched and trigger a single notification\n * when the callback completes. Direct mutations outside of `Relation.update` will throw\n * an error for echo relations.\n *\n * @param relation - The echo relation to mutate. Use `Obj.update` for objects.\n * @param callback - The callback that performs mutations on the relation.\n *\n * @example\n * ```ts\n * const worksFor = Relation.make(EmployedBy, {\n * [Relation.Source]: person,\n * [Relation.Target]: company,\n * role: 'Engineer',\n * });\n *\n * // Mutate within Relation.update\n * Relation.update(worksFor, (obj) => {\n * obj.role = 'Senior Engineer';\n * });\n * ```\n *\n * Note: Only accepts relations. Use `Obj.update` for objects.\n */\nexport const update = <T extends Unknown>(relation: T, callback: internal.ChangeCallback<T>): void => {\n internal.change(relation, callback);\n};\n\n//\n// Snapshot\n//\n\n/**\n * Returns an immutable snapshot of a relation.\n * The snapshot is branded with SnapshotKindId instead of KindId,\n * making it distinguishable from the reactive relation at the type level.\n */\nexport const getSnapshot: <T extends Unknown>(rel: T) => Snapshot<T> = internal.getSnapshot as any;\n\n//\n// Subscribe\n//\n\n/**\n * Subscribe to relation updates.\n * The callback is called synchronously when the relation is modified.\n * Only accepts reactive relations (not snapshots).\n * @returns Unsubscribe function.\n */\nexport const subscribe = (rel: Unknown, callback: () => void): (() => void) => {\n return internal.subscribe(rel, callback);\n};\n\n//\n// Property Access\n//\n\n/**\n * Get a deeply nested property from a relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const getValue = (rel: Unknown | Snapshot, path: readonly (string | number)[]): any => {\n return internal.getValue(rel, createJsonPath(path));\n};\n\n/**\n * Set a deeply nested property on a relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setValue: (rel: Mutable<Unknown>, path: readonly (string | number)[], value: any) => void =\n internal.setValue as any;\n\n//\n// Type\n//\n\n/**\n * Get the canonical URI of the relation. Returns `URI.URI` — today always an EID,\n * but future entity kinds may surface other URI schemes; narrow with `EID.parse(uri)`\n * or `DXN.tryMake(uri)` at the point of use. Accepts both reactive relations and snapshots.\n */\nexport const getURI = (entity: Unknown | Snapshot): URI.URI => internal.getUri(entity);\n\n/**\n * @returns The DXN of the relation's type.\n */\nexport const getTypeURI: (obj: internal.AnyProperties) => URI.URI | undefined = internal.getTypeURI;\n\n/**\n * Get the type entity (`Type.AnyRelation`) the relation was created from.\n *\n * Returns `undefined` when the relation's type isn't registered in this\n * runtime (e.g. a freshly deserialized snapshot whose type entity hasn't been\n * wired up yet, or a relation loaded from storage before its schema is known).\n * To get the Effect Schema from the returned entity, use `Type.getSchema(...)`.\n */\nexport const getType = (relation: Unknown | Snapshot): Type.AnyRelation | undefined =>\n internal.getType(relation) as Type.AnyRelation | undefined;\n\n/**\n * @returns The typename of the relation's type.\n * Accepts both reactive relations and snapshots.\n */\nexport const getTypename = (entity: Unknown | Snapshot): string | undefined => internal.getTypename(entity);\n\n//\n// Database\n//\n\n/**\n * Get the database the relation belongs to.\n * Accepts both reactive relations and snapshots.\n */\nexport const getDatabase = (entity: Unknown | Snapshot): Database.Database | undefined => internal.getDatabase(entity);\n\n//\n// Meta\n//\n\n/**\n * Property that accesses metadata for an entity.\n *\n * Alias for `Entity.Meta`.\n */\nexport const Meta = internal.MetaId;\n\n/**\n * Deeply read-only version of EntityMeta.\n */\nexport type ReadonlyMeta = internal.ReadonlyMeta;\n\n/**\n * Mutable meta type returned by `Relation.getMeta` inside a `Relation.update` callback.\n */\nexport type Meta = internal.Meta;\n\n/**\n * Get the metadata for a relation.\n * Returns mutable meta when passed a mutable relation (inside `Relation.update` callback).\n * Returns read-only meta when passed a regular relation or snapshot.\n */\n// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.\nexport function getMeta(entity: Mutable<Unknown>): Meta;\nexport function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;\nexport function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): Meta | ReadonlyMeta {\n return internal.getMetaChecked(entity);\n}\n\n/**\n * @returns Foreign keys for the relation from the specified source.\n * Accepts both reactive relations and snapshots.\n */\nexport const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);\n\n/**\n * Delete all keys from the relation for the specified source.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const deleteKeys = (entity: Mutable<Unknown>, source: string): void => internal.deleteKeys(entity, source);\n\n/**\n * Add a tag to the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);\n\n/**\n * Remove a tag from the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);\n\n/**\n * Check if the relation is deleted.\n * Accepts both reactive relations and snapshots.\n */\nexport const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);\n\n//\n// Annotations\n//\n\n/**\n * Get the label of the relation.\n * Accepts both reactive relations and snapshots.\n *\n * @param options.fallback `'typename'` returns the relation's typename when no\n * label is set (e.g. `org.dxos.type.table`).\n */\nexport const getLabel = (entity: Unknown | Snapshot, options?: internal.GetLabelOptions): string | undefined =>\n internal.getLabel(entity, options);\n\n/**\n * Set the label of the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);\n\n/**\n * Get the description of the relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);\n\n/**\n * Set the description of the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setDescription = (entity: Mutable<Unknown>, description: string): void =>\n internal.setDescription(entity, description);\n\n//\n// JSON\n//\n\n/**\n * JSON representation of a relation.\n */\nexport type JSON = internal.ObjectJSON;\n\n/**\n * Converts relation to its JSON representation.\n * Accepts both reactive relations and snapshots.\n */\nexport const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);\n\n//\n// Sorting\n//\n\n/**\n * Comparator function type for sorting relations.\n * Accepts both reactive relations and snapshots.\n */\nexport type Comparator = internal.Comparator<Unknown | Snapshot>;\n\nexport const sortByLabel: Comparator = internal.sortByLabel as Comparator;\nexport const sortByTypename: Comparator = internal.sortByTypename as Comparator;\nexport const sort = (...comparators: Comparator[]): Comparator => internal.sort(...comparators) as Comparator;\n\n//\n// Version\n//\n\nexport const VersionTypeId = internal.VersionTypeId;\nexport const isVersion = internal.isVersion;\n\n/**\n * Represent relation version.\n */\nexport type Version = internal.EntityVersion;\n\n/**\n * Returns the version of the relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const version = (entity: Unknown | Snapshot): Version => internal.version(entity);\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Unknown", "VersionTypeId", "addTag", "deleteKeys", "getDatabase", "getDescription", "getKeys", "getLabel", "getSnapshot", "getType", "getTypeURI", "getTypename", "getValue", "isDeleted", "isVersion", "removeTag", "setDescription", "setLabel", "setValue", "sort", "sortByLabel", "sortByTypename", "subscribe", "version", "Schema", "raise", "createJsonPath", "assertArgument", "invariant", "EID", "DXN", "assumeType", "Schema", "Record", "key", "annotations", "TypeAnnotationId", "kind", "Kind", "typename", "version", "sourceSchema", "targetSchema", "assertArgument", "internal", "getTypeAnnotation", "ParentId", "undefined", "meta", "props", "MetaId", "sourceDXN", "getObjectEchoUri", "RelationSourceDXNId", "RelationTargetDXNId", "targetDXN", "entity", "isInstanceOf", "args", "value", "assumeType", "invariant", "EID", "isEID", "uri", "relation", "RelationSourceId", "obj", "RelationTargetId", "getSnapshot", "subscribe", "getValue", "setValue", "getTypename", "getDatabase", "getMetaChecked", "isDeleted", "sortByTypename", "sort", "comparators", "VersionTypeId"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Ref
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7OAFN3OX.mjs";
|
|
4
4
|
|
|
5
5
|
// src/internal/Ref/ref-array.ts
|
|
6
6
|
import { isNonNullable } from "@dxos/util";
|
|
@@ -21,7 +21,7 @@ var RefArray = Object.freeze({
|
|
|
21
21
|
* Removes the ref with the given id.
|
|
22
22
|
*/
|
|
23
23
|
removeById: (refs, id) => {
|
|
24
|
-
const index = refs.findIndex(Ref.
|
|
24
|
+
const index = refs.findIndex(Ref.hasEntityId(id));
|
|
25
25
|
if (index >= 0) {
|
|
26
26
|
refs.splice(index, 1);
|
|
27
27
|
}
|
|
@@ -31,4 +31,4 @@ var RefArray = Object.freeze({
|
|
|
31
31
|
export {
|
|
32
32
|
RefArray
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-4Z6GET2X.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/Ref/ref-array.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type EntityId } from '@dxos/keys';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type AnyEntity } from '../common/types';\nimport { Ref } from './ref';\n\n/**\n * Helper functions for working with arrays of refs.\n */\nexport const RefArray = Object.freeze({\n /**\n * @returns all resolved targets.\n */\n targets: <T extends AnyEntity>(refs: readonly Ref<T>[]): T[] => {\n return refs.map((ref) => ref.target).filter(isNonNullable);\n },\n\n /**\n * Load all referenced objects.\n */\n loadAll: <T extends AnyEntity>(refs: readonly Ref<T>[]): Promise<T[]> => {\n return Promise.all(refs.map((ref) => ref.load()));\n },\n\n /**\n * Removes the ref with the given id.\n */\n removeById: (refs: Ref<AnyEntity>[], id: EntityId) => {\n const index = refs.findIndex(Ref.hasEntityId(id));\n if (index >= 0) {\n refs.splice(index, 1);\n }\n },\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAKA,SAASA,qBAAqB;AAQvB,IAAMC,WAAWC,OAAOC,OAAO;;;;EAIpCC,SAAS,CAAsBC,SAAAA;AAC7B,WAAOA,KAAKC,IAAI,CAACC,QAAQA,IAAIC,MAAM,EAAEC,OAAOC,aAAAA;EAC9C;;;;EAKAC,SAAS,CAAsBN,SAAAA;AAC7B,WAAOO,QAAQC,IAAIR,KAAKC,IAAI,CAACC,QAAQA,IAAIO,KAAI,CAAA,CAAA;EAC/C;;;;EAKAC,YAAY,CAACV,MAAwBW,OAAAA;AACnC,UAAMC,QAAQZ,KAAKa,UAAUC,IAAIC,YAAYJ,EAAAA,CAAAA;AAC7C,QAAIC,SAAS,GAAG;AACdZ,WAAKgB,OAAOJ,OAAO,CAAA;IACrB;EACF;AACF,CAAA;",
|
|
6
|
+
"names": ["isNonNullable", "RefArray", "Object", "freeze", "targets", "refs", "map", "ref", "target", "filter", "isNonNullable", "loadAll", "Promise", "all", "load", "removeById", "id", "index", "findIndex", "Ref", "hasEntityId", "splice"]
|
|
7
|
+
}
|
|
@@ -5,17 +5,21 @@ import {
|
|
|
5
5
|
// src/Key.ts
|
|
6
6
|
var Key_exports = {};
|
|
7
7
|
__export(Key_exports, {
|
|
8
|
+
EID: () => EID,
|
|
9
|
+
EntityId: () => EntityId,
|
|
8
10
|
ForeignKey: () => ForeignKey,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
SpaceId: () => SpaceId,
|
|
12
|
+
URI: () => URI
|
|
11
13
|
});
|
|
12
14
|
import { ForeignKey } from "@dxos/echo-protocol";
|
|
13
|
-
import { SpaceId,
|
|
15
|
+
import { EID, EntityId, SpaceId, URI } from "@dxos/keys";
|
|
14
16
|
|
|
15
17
|
export {
|
|
16
18
|
Key_exports,
|
|
17
19
|
ForeignKey,
|
|
20
|
+
EID,
|
|
21
|
+
EntityId,
|
|
18
22
|
SpaceId,
|
|
19
|
-
|
|
23
|
+
URI
|
|
20
24
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-7LOUAPYZ.mjs.map
|