@dxos/echo 0.8.4-main.7ace549 → 0.8.4-main.8360d9e660
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/lib/neutral/Annotation.mjs +37 -0
- package/dist/lib/neutral/Database.mjs +45 -0
- package/dist/lib/neutral/Entity.mjs +59 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Feed.mjs +47 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +64 -0
- package/dist/lib/neutral/Filter.mjs.map +7 -0
- package/dist/lib/neutral/Format.mjs +66 -0
- package/dist/lib/neutral/Format.mjs.map +7 -0
- package/dist/lib/neutral/JsonSchema.mjs +19 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +12 -0
- package/dist/lib/neutral/Key.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +110 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +12 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +36 -0
- package/dist/lib/neutral/Query.mjs.map +7 -0
- package/dist/lib/neutral/QueryResult.mjs +2 -0
- package/dist/lib/neutral/QueryResult.mjs.map +7 -0
- package/dist/lib/neutral/Ref.mjs +24 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +93 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/SchemaRegistry.mjs +2 -0
- package/dist/lib/neutral/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +28 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +37 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs +396 -0
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4JRI2ZJI.mjs +313 -0
- package/dist/lib/neutral/chunk-4JRI2ZJI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6DNYDXCV.mjs +159 -0
- package/dist/lib/neutral/chunk-6DNYDXCV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6GPU7XC3.mjs +283 -0
- package/dist/lib/neutral/chunk-6GPU7XC3.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6K2MVI2O.mjs +56 -0
- package/dist/lib/neutral/chunk-6K2MVI2O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7VNVH63N.mjs +106 -0
- package/dist/lib/neutral/chunk-7VNVH63N.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs +21 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs +402 -0
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs +7 -0
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs +787 -0
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-C4JZK4J7.mjs +2712 -0
- package/dist/lib/neutral/chunk-C4JZK4J7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs +45 -0
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FZO7LQO7.mjs +73 -0
- package/dist/lib/neutral/chunk-FZO7LQO7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NEGC54NE.mjs +130 -0
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs +299 -0
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OENWMTE6.mjs +45 -0
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ROAGDPV7.mjs +121 -0
- package/dist/lib/neutral/chunk-ROAGDPV7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs +355 -0
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs +51 -0
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs +42 -0
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs +27 -0
- package/dist/lib/neutral/chunk-UTBRYVQC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-W47JKR3X.mjs +298 -0
- package/dist/lib/neutral/chunk-W47JKR3X.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs +67 -0
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YMNSMKKW.mjs +97 -0
- package/dist/lib/neutral/chunk-YMNSMKKW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs +34 -0
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +97 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/internal/index.mjs +257 -123
- package/dist/lib/neutral/internal/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +97 -52
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +23 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +139 -87
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +18 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +141 -9
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/Err.d.ts +107 -0
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +165 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +3 -3
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +65 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +392 -85
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +202 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +61 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +282 -18
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/SchemaRegistry.d.ts +84 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +8 -7
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +124 -90
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/View.d.ts +68 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +12 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +83 -27
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts +24 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +14 -1
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/api.d.ts +13 -0
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/entity.d.ts +20 -0
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +8 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/model.d.ts +14 -29
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/object.d.ts +18 -0
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/relation.d.ts +35 -0
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/version.d.ts +42 -0
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/format.d.ts +4 -4
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/select.d.ts +6 -4
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/string.d.ts +4 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +7 -3
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +131 -30
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +2 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts +8 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +3 -3
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/deleted.d.ts +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/index.d.ts +3 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.d.ts +44 -0
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.d.ts +7 -0
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts +6 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts +25 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +4 -4
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +31 -9
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.d.ts +7 -0
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/echo-schema.d.ts +20 -7
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts +4 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/Type/persistent-schema.d.ts +20 -0
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/index.d.ts +11 -0
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts +42 -0
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/make-object.d.ts +2 -4
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +16 -12
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/base.d.ts +6 -16
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/entity.d.ts +37 -0
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/index.d.ts +1 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/meta.d.ts +8 -15
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +54 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/typename.d.ts +8 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +2 -2
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +9 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +146 -179
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +6 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +94 -61
- package/src/Annotation.ts +36 -5
- package/src/Collection.ts +37 -0
- package/src/Database.ts +250 -122
- package/src/Dataset.ts +26 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +197 -11
- package/src/Err.ts +40 -0
- package/src/Feed.ts +262 -0
- package/src/Filter.ts +391 -0
- package/src/Format.ts +3 -5
- package/src/Hypergraph.ts +79 -0
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +447 -0
- package/src/Obj.ts +528 -295
- package/src/Order.ts +46 -0
- package/src/Query.test.ts +632 -0
- package/src/Query.ts +522 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +79 -9
- package/src/Relation.test.ts +88 -0
- package/src/Relation.ts +439 -68
- package/src/SchemaRegistry.ts +106 -0
- package/src/Tag.ts +7 -6
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +167 -166
- package/src/View.ts +107 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +13 -5
- package/src/internal/{annotations → Annotation}/annotations.test.ts +12 -12
- package/src/internal/{annotations → Annotation}/annotations.ts +172 -64
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/Annotation/sorting.ts +52 -0
- package/src/internal/{annotations → Annotation}/util.ts +16 -1
- package/src/internal/Entity/api.ts +31 -0
- package/src/internal/{entities → Entity}/entity.ts +39 -20
- package/src/internal/{entities → Entity}/index.ts +3 -1
- package/src/internal/{entities → Entity}/model.ts +29 -49
- package/src/internal/{entities → Entity}/object.ts +23 -10
- package/src/internal/{entities → Entity}/relation.ts +42 -43
- package/src/internal/Entity/version.ts +97 -0
- package/src/internal/{formats → Format}/date.test.ts +1 -1
- package/src/internal/{formats → Format}/format.test.ts +2 -2
- package/src/internal/{formats → Format}/format.ts +7 -8
- package/src/internal/{formats → Format}/object.ts +2 -2
- package/src/internal/{formats → Format}/select.ts +6 -4
- package/src/internal/{formats → Format}/string.ts +5 -0
- package/src/internal/{formats → Format}/types.ts +12 -6
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +4 -2
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +34 -35
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +67 -65
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +18 -12
- package/src/internal/Obj/clone.ts +48 -0
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +4 -4
- package/src/internal/{object → Obj}/create-object.ts +6 -6
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/index.ts +3 -0
- package/src/internal/{object → Obj}/inspect.ts +4 -4
- package/src/internal/{object → Obj}/json-serializer.test.ts +33 -6
- package/src/internal/{object → Obj}/json-serializer.ts +69 -84
- package/src/internal/{object → Obj}/schema-validator.test.ts +3 -7
- package/src/internal/Obj/schema-validator.ts +6 -0
- package/src/internal/Obj/set-value.test.ts +281 -0
- package/src/internal/Obj/set-value.ts +165 -0
- package/src/internal/Obj/snapshot.ts +105 -0
- package/src/internal/{object → Obj}/typed-object.test.ts +12 -12
- package/src/internal/Obj/typed-object.ts +30 -0
- package/src/internal/{ref → Ref}/ref-array.ts +4 -4
- package/src/internal/{ref → Ref}/ref.test.ts +5 -5
- package/src/internal/{ref → Ref}/ref.ts +90 -43
- package/src/internal/{schema → Type}/compose.test.ts +6 -6
- package/src/internal/{schema → Type}/compose.ts +14 -10
- package/src/internal/{schema → Type}/echo-schema.ts +55 -16
- package/src/internal/{schema → Type}/index.ts +0 -2
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/Type/persistent-schema.ts +33 -0
- package/src/internal/{README.md → common/README.md} +36 -17
- package/src/internal/common/api/index.ts +15 -0
- package/src/internal/common/api/meta.ts +88 -0
- package/src/internal/common/index.ts +7 -0
- package/src/internal/common/proxy/change-context.ts +138 -0
- package/src/internal/common/proxy/change.test.ts +519 -0
- package/src/internal/common/proxy/define-hidden-property.ts +14 -0
- package/src/internal/common/proxy/errors.ts +42 -0
- package/src/internal/common/proxy/event-batch.ts +44 -0
- package/src/internal/{proxy → common/proxy}/handler.test.ts +32 -82
- package/src/internal/common/proxy/index.ts +17 -0
- package/src/internal/common/proxy/json-serializer.ts +90 -0
- package/src/internal/common/proxy/make-object.ts +106 -0
- package/src/internal/common/proxy/ownership.ts +253 -0
- package/src/internal/common/proxy/proxy-types.ts +23 -0
- package/src/internal/common/proxy/proxy-utils.ts +150 -0
- package/src/internal/common/proxy/reactive-array.ts +71 -0
- package/src/internal/common/proxy/reactive.ts +69 -0
- package/src/internal/{object → common/proxy}/schema-validator.ts +3 -1
- package/src/internal/{proxy → common/proxy}/schema.test.ts +29 -21
- package/src/internal/common/proxy/symbols.ts +7 -0
- package/src/internal/common/proxy/typed-handler.test.ts +314 -0
- package/src/internal/common/proxy/typed-handler.ts +449 -0
- package/src/internal/common/proxy/typed-object.test.ts +116 -0
- package/src/internal/{types → common/types}/base.ts +7 -22
- package/src/internal/common/types/entity.ts +54 -0
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +17 -25
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/{types → common/types}/typename.ts +10 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +32 -6
- package/src/testing/test-schema.ts +68 -41
- package/src/testing/util.ts +22 -15
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs +0 -3683
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +0 -7
- package/dist/lib/browser/chunk-E4UTVJNF.mjs +0 -1111
- package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -45
- package/dist/lib/browser/internal/index.mjs +0 -336
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +0 -1111
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs +0 -3683
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -45
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -328
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/errors.d.ts +0 -68
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts +0 -10
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- package/dist/types/src/internal/entities/expando.d.ts +0 -16
- package/dist/types/src/internal/entities/expando.d.ts.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts +0 -6
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts +0 -11
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts +0 -55
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +0 -31
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts +0 -31
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts +0 -3
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts +0 -6
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -6
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +0 -18
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
- package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
- package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts +0 -12
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/dist/types/src/query/filter.d.ts +0 -167
- package/dist/types/src/query/filter.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -5
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/order.d.ts +0 -12
- package/dist/types/src/query/order.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -112
- package/dist/types/src/query/query.d.ts.map +0 -1
- package/dist/types/src/query/query.test.d.ts +0 -2
- package/dist/types/src/query/query.test.d.ts.map +0 -1
- package/dist/types/src/query/testing.d.ts +0 -51
- package/dist/types/src/query/testing.d.ts.map +0 -1
- package/dist/types/src/query/types.d.ts +0 -17
- package/dist/types/src/query/types.d.ts.map +0 -1
- package/dist/types/src/query/util.d.ts +0 -8
- package/dist/types/src/query/util.d.ts.map +0 -1
- package/src/errors.ts +0 -18
- package/src/internal/entities/expando.ts +0 -23
- package/src/internal/object/typed-object.ts +0 -94
- package/src/internal/proxy/index.ts +0 -6
- package/src/internal/proxy/make-object.ts +0 -113
- package/src/internal/proxy/typed-handler.test.ts +0 -102
- package/src/internal/proxy/typed-handler.ts +0 -233
- package/src/internal/proxy/typed-object.test.ts +0 -105
- package/src/internal/schema/persistent-schema.ts +0 -28
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/types/entity.ts +0 -23
- package/src/query/filter.ts +0 -455
- package/src/query/index.ts +0 -9
- package/src/query/order.ts +0 -34
- package/src/query/query.test.ts +0 -334
- package/src/query/query.ts +0 -303
- package/src/query/testing.ts +0 -64
- package/src/query/types.ts +0 -23
- package/src/query/util.ts +0 -25
- /package/dist/lib/{browser/index.mjs.map → neutral/Annotation.mjs.map} +0 -0
- /package/dist/lib/{browser/internal/index.mjs.map → neutral/Database.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/Entity.mjs.map} +0 -0
- /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Err.mjs.map} +0 -0
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/index.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/ids.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/src/internal/{entities → Entity}/util.ts +0 -0
- /package/src/internal/{formats → Format}/date.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{object → Obj}/ids.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
package/src/Relation.ts
CHANGED
|
@@ -2,161 +2,532 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
5
7
|
import * as Schema from 'effect/Schema';
|
|
6
8
|
|
|
7
9
|
import { raise } from '@dxos/debug';
|
|
10
|
+
import type { ForeignKey } from '@dxos/echo-protocol';
|
|
11
|
+
import { createJsonPath } from '@dxos/effect';
|
|
8
12
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
9
13
|
import { DXN, type ObjectId } from '@dxos/keys';
|
|
10
|
-
import { type Live } from '@dxos/live-object';
|
|
11
14
|
import { assumeType } from '@dxos/util';
|
|
12
15
|
|
|
16
|
+
import type * as Database from './Database';
|
|
13
17
|
import * as Entity from './Entity';
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
ATTR_RELATION_TARGET,
|
|
17
|
-
type AnyEchoObject,
|
|
18
|
-
EntityKind,
|
|
19
|
-
type InternalObjectProps,
|
|
20
|
-
MetaId,
|
|
21
|
-
type ObjectMeta,
|
|
22
|
-
RelationSourceDXNId,
|
|
23
|
-
RelationSourceId,
|
|
24
|
-
RelationTargetDXNId,
|
|
25
|
-
RelationTargetId,
|
|
26
|
-
getObjectDXN,
|
|
27
|
-
getTypeAnnotation,
|
|
28
|
-
makeObject,
|
|
29
|
-
} from './internal';
|
|
18
|
+
import * as entityInternal from './internal/Entity';
|
|
19
|
+
import * as internal from './internal';
|
|
30
20
|
import * as Obj from './Obj';
|
|
31
|
-
import * as Type from './Type';
|
|
21
|
+
import type * as Type from './Type';
|
|
22
|
+
|
|
23
|
+
export type Endpoints<Source, Target> = {
|
|
24
|
+
[Source]: Source;
|
|
25
|
+
[Target]: Target;
|
|
26
|
+
};
|
|
32
27
|
|
|
33
28
|
/**
|
|
34
29
|
* Base type for all ECHO relations.
|
|
35
30
|
* @private
|
|
36
31
|
*/
|
|
37
32
|
interface BaseRelation<Source, Target>
|
|
38
|
-
extends
|
|
39
|
-
Type.Relation.Endpoints<Source, Target>,
|
|
40
|
-
Entity.OfKind<EntityKind.Relation> {}
|
|
33
|
+
extends internal.AnyEntity, Endpoints<Source, Target>, Entity.OfKind<internal.EntityKind.Relation> {}
|
|
41
34
|
|
|
42
35
|
/**
|
|
43
|
-
*
|
|
36
|
+
* Relation with no known properties beyond id, kind, source, and target.
|
|
37
|
+
* Use this when the relation's schema/properties are not known.
|
|
38
|
+
*
|
|
39
|
+
* NOTE: This is a TypeScript type only, not a schema.
|
|
40
|
+
* To validate that a value is an ECHO relation, use `Relation.isRelation`.
|
|
44
41
|
*/
|
|
45
|
-
export interface
|
|
42
|
+
export interface Unknown extends BaseRelation<Obj.Unknown, Obj.Unknown> {}
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Runtime Effect schema for any ECHO relation.
|
|
46
|
+
* Use for validation, parsing, or as a reference target for collections.
|
|
47
|
+
* A relation has `id`, source, and target fields plus any additional properties.
|
|
48
|
+
*
|
|
49
|
+
* NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).
|
|
50
|
+
* Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* // Structural type guard (accepts any object with id field)
|
|
55
|
+
* if (Schema.is(Type.Relation)(unknownValue)) { ... }
|
|
56
|
+
*
|
|
57
|
+
* // ECHO instance type guard (checks KindId brand)
|
|
58
|
+
* if (Relation.isRelation(unknownValue)) { ... }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
// TODO(dmaretskyi): Change ObjModule.Any to ObjModule.Unknown to have stricter types.
|
|
62
|
+
export const Unknown: Type.Relation<Unknown, Obj.Any, Obj.Any> = Schema.Struct({
|
|
63
|
+
id: Schema.String,
|
|
64
|
+
}).pipe(
|
|
65
|
+
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
|
|
66
|
+
// TODO(dmaretskyi): Clean this up.
|
|
67
|
+
// NOTE: The EchoRelationSchema annotation is required for Ref.Ref(Relation.Unknown) to work.
|
|
68
|
+
// The typename/version/source/target only satisfy ECHO schema machinery for reference targets.
|
|
69
|
+
internal.EchoRelationSchema({
|
|
70
|
+
typename: 'org.dxos.schema.any-relation',
|
|
71
|
+
version: '0.0.0',
|
|
72
|
+
source: Obj.Unknown,
|
|
73
|
+
target: Obj.Unknown,
|
|
53
74
|
}),
|
|
75
|
+
(schema) =>
|
|
76
|
+
Object.assign(schema, {
|
|
77
|
+
[internal.SchemaKindId]: (schema as any)[internal.SchemaKindId],
|
|
78
|
+
}) as unknown as Type.Relation<Unknown, Obj.Any, Obj.Any>,
|
|
54
79
|
);
|
|
55
80
|
|
|
56
81
|
/**
|
|
57
82
|
* Relation type with specific source and target types.
|
|
58
83
|
*/
|
|
59
|
-
export type
|
|
84
|
+
export type OfShape<Source extends Obj.Unknown, Target extends Obj.Unknown, Props> = BaseRelation<Source, Target> &
|
|
85
|
+
Props;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Base type for snapshot relations (has SnapshotKindId instead of KindId).
|
|
89
|
+
*/
|
|
90
|
+
interface BaseRelationSnapshot<Source, Target> extends internal.AnyEntity, Endpoints<Source, Target> {
|
|
91
|
+
readonly [Entity.SnapshotKindId]: internal.EntityKind.Relation;
|
|
92
|
+
readonly id: ObjectId;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* JSON-encoded properties for relations.
|
|
97
|
+
*/
|
|
98
|
+
export interface BaseRelationJson {
|
|
99
|
+
id: string;
|
|
100
|
+
[internal.ATTR_RELATION_SOURCE]: string;
|
|
101
|
+
[internal.ATTR_RELATION_TARGET]: string;
|
|
102
|
+
}
|
|
60
103
|
|
|
61
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Immutable snapshot of an ECHO relation.
|
|
106
|
+
* Branded with SnapshotKindId (not KindId).
|
|
107
|
+
* Property values are frozen at the time the snapshot was created.
|
|
108
|
+
* Returned by getSnapshot() and hooks.
|
|
109
|
+
*/
|
|
110
|
+
export type Snapshot<T extends Unknown = Unknown> = Omit<T, Entity.KindId> &
|
|
111
|
+
BaseRelationSnapshot<Obj.Unknown, Obj.Unknown>;
|
|
112
|
+
|
|
113
|
+
export const Source: unique symbol = entityInternal.RelationSourceId as any;
|
|
62
114
|
export type Source = typeof Source;
|
|
63
115
|
|
|
64
|
-
export const Target: unique symbol = RelationTargetId as any;
|
|
116
|
+
export const Target: unique symbol = entityInternal.RelationTargetId as any;
|
|
65
117
|
export type Target = typeof Target;
|
|
66
118
|
|
|
67
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Get relation source type.
|
|
121
|
+
*/
|
|
122
|
+
export type SourceOf<A> = A extends Endpoints<infer S, infer _T> ? S : never;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Get relation target type.
|
|
126
|
+
*/
|
|
127
|
+
export type TargetOf<A> = A extends Endpoints<infer _S, infer T> ? T : never;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Internal props type for relation instance creation.
|
|
131
|
+
*/
|
|
132
|
+
type MakePropsInternal<T extends Unknown> = {
|
|
68
133
|
id?: ObjectId;
|
|
69
|
-
[
|
|
134
|
+
[Meta]?: internal.ObjectMeta;
|
|
70
135
|
[Source]: T[Source];
|
|
71
136
|
[Target]: T[Target];
|
|
72
|
-
} &
|
|
137
|
+
} & Entity.Properties<T>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Props type for relation creation with a given schema.
|
|
141
|
+
* Takes a schema type (created with Type.Relation) and extracts the props type.
|
|
142
|
+
*/
|
|
143
|
+
export type MakeProps<S extends Type.AnyRelation> = MakePropsInternal<Schema.Schema.Type<S>>;
|
|
73
144
|
|
|
74
145
|
/**
|
|
75
146
|
* Creates new relation.
|
|
76
147
|
* @param schema - Relation schema.
|
|
77
148
|
* @param props - Relation properties. Endpoints are passed as [Relation.Source] and [Relation.Target] keys.
|
|
78
|
-
* @param meta - Relation metadata.
|
|
149
|
+
* @param meta - Relation metadata. (deprecated; use [Obj.Meta] instead)
|
|
79
150
|
* @returns
|
|
80
151
|
*/
|
|
81
152
|
// 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).
|
|
82
153
|
// TODO(dmaretskyi): Move meta into props.
|
|
83
|
-
export const make = <S extends Type.
|
|
154
|
+
export const make = <S extends Type.AnyRelation>(
|
|
84
155
|
schema: S,
|
|
85
|
-
props: NoInfer<MakeProps<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
156
|
+
props: NoInfer<MakeProps<S>>,
|
|
157
|
+
): Schema.Schema.Type<S> & Entity.OfKind<typeof Entity.Kind.Relation> => {
|
|
158
|
+
assertArgument(
|
|
159
|
+
internal.getTypeAnnotation(schema)?.kind === internal.EntityKind.Relation,
|
|
160
|
+
'schema',
|
|
161
|
+
'Expected a relation schema',
|
|
162
|
+
);
|
|
163
|
+
assertArgument(props[internal.ParentId] === undefined, 'props', 'Parent is not allowed for relations');
|
|
164
|
+
|
|
165
|
+
let meta: internal.ObjectMeta | undefined = undefined;
|
|
166
|
+
|
|
167
|
+
if (props[internal.MetaId] != null) {
|
|
168
|
+
meta = props[internal.MetaId] as any;
|
|
169
|
+
delete props[internal.MetaId];
|
|
93
170
|
}
|
|
94
171
|
|
|
95
|
-
const sourceDXN = getObjectDXN(props[Source]) ?? raise(new Error('Unresolved relation source'));
|
|
96
|
-
const targetDXN = getObjectDXN(props[Target]) ?? raise(new Error('Unresolved relation target'));
|
|
172
|
+
const sourceDXN = internal.getObjectDXN(props[Source]) ?? raise(new Error('Unresolved relation source'));
|
|
173
|
+
const targetDXN = internal.getObjectDXN(props[Target]) ?? raise(new Error('Unresolved relation target'));
|
|
97
174
|
|
|
98
|
-
(props as any)[RelationSourceDXNId] = sourceDXN;
|
|
99
|
-
(props as any)[RelationTargetDXNId] = targetDXN;
|
|
175
|
+
(props as any)[internal.RelationSourceDXNId] = sourceDXN;
|
|
176
|
+
(props as any)[internal.RelationTargetDXNId] = targetDXN;
|
|
100
177
|
|
|
101
|
-
return makeObject<Schema.Schema.Type<S>>(schema, props as any, meta);
|
|
178
|
+
return internal.makeObject<Schema.Schema.Type<S>>(schema, props as any, meta);
|
|
102
179
|
};
|
|
103
180
|
|
|
104
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Type guard for relations.
|
|
183
|
+
* Returns true for both reactive relations and relation snapshots.
|
|
184
|
+
*/
|
|
185
|
+
export const isRelation = (value: unknown): value is Unknown => {
|
|
105
186
|
if (typeof value !== 'object' || value === null) {
|
|
106
187
|
return false;
|
|
107
188
|
}
|
|
108
|
-
if (ATTR_RELATION_SOURCE in value || ATTR_RELATION_TARGET in value) {
|
|
189
|
+
if (internal.ATTR_RELATION_SOURCE in value || internal.ATTR_RELATION_TARGET in value) {
|
|
109
190
|
return true;
|
|
110
191
|
}
|
|
111
192
|
|
|
112
|
-
|
|
113
|
-
|
|
193
|
+
// Check for reactive relation (KindId) or snapshot (SnapshotKindId).
|
|
194
|
+
const kind = (value as any)[Entity.KindId] ?? (value as any)[Entity.SnapshotKindId];
|
|
195
|
+
return kind === internal.EntityKind.Relation;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const isSnapshot = (value: unknown): value is Snapshot => {
|
|
199
|
+
if (typeof value !== 'object' || value === null) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return (value as any)[Entity.SnapshotKindId] === internal.EntityKind.Relation;
|
|
114
203
|
};
|
|
115
204
|
|
|
116
205
|
/**
|
|
117
206
|
* @returns Relation source DXN.
|
|
207
|
+
* Accepts both reactive relations and snapshots.
|
|
118
208
|
* @throws If the object is not a relation.
|
|
119
209
|
*/
|
|
120
|
-
export const getSourceDXN = (value:
|
|
210
|
+
export const getSourceDXN = (value: Unknown | Snapshot): DXN => {
|
|
121
211
|
assertArgument(isRelation(value), 'Expected a relation');
|
|
122
|
-
assumeType<InternalObjectProps>(value);
|
|
123
|
-
const dxn = (value as InternalObjectProps)[RelationSourceDXNId];
|
|
212
|
+
assumeType<internal.InternalObjectProps>(value);
|
|
213
|
+
const dxn = (value as internal.InternalObjectProps)[internal.RelationSourceDXNId];
|
|
124
214
|
invariant(dxn instanceof DXN);
|
|
125
215
|
return dxn;
|
|
126
216
|
};
|
|
127
217
|
|
|
128
218
|
/**
|
|
129
219
|
* @returns Relation target DXN.
|
|
220
|
+
* Accepts both reactive relations and snapshots.
|
|
130
221
|
* @throws If the object is not a relation.
|
|
131
222
|
*/
|
|
132
|
-
export const getTargetDXN = (value:
|
|
223
|
+
export const getTargetDXN = (value: Unknown | Snapshot): DXN => {
|
|
133
224
|
assertArgument(isRelation(value), 'Expected a relation');
|
|
134
|
-
assumeType<InternalObjectProps>(value);
|
|
135
|
-
const dxn = (value as InternalObjectProps)[RelationTargetDXNId];
|
|
225
|
+
assumeType<internal.InternalObjectProps>(value);
|
|
226
|
+
const dxn = (value as internal.InternalObjectProps)[internal.RelationTargetDXNId];
|
|
136
227
|
invariant(dxn instanceof DXN);
|
|
137
228
|
return dxn;
|
|
138
229
|
};
|
|
139
230
|
|
|
140
231
|
/**
|
|
141
232
|
* @returns Relation source.
|
|
233
|
+
* Accepts both reactive relations and snapshots.
|
|
142
234
|
* @throws If the object is not a relation.
|
|
143
235
|
*/
|
|
144
|
-
export const getSource = <T extends
|
|
236
|
+
export const getSource = <T extends Unknown | Snapshot>(relation: T): SourceOf<T> => {
|
|
145
237
|
assertArgument(isRelation(relation), 'Expected a relation');
|
|
146
|
-
assumeType<InternalObjectProps>(relation);
|
|
147
|
-
const obj = (relation as InternalObjectProps)[RelationSourceId];
|
|
238
|
+
assumeType<internal.InternalObjectProps>(relation);
|
|
239
|
+
const obj = (relation as internal.InternalObjectProps)[internal.RelationSourceId];
|
|
148
240
|
invariant(obj !== undefined, `Invalid source: ${relation.id}`);
|
|
149
|
-
return obj as
|
|
241
|
+
return obj as SourceOf<T>;
|
|
150
242
|
};
|
|
151
243
|
|
|
152
244
|
/**
|
|
153
245
|
* @returns Relation target.
|
|
246
|
+
* Accepts both reactive relations and snapshots.
|
|
154
247
|
* @throws If the object is not a relation.
|
|
155
248
|
*/
|
|
156
|
-
export const getTarget = <T extends
|
|
249
|
+
export const getTarget = <T extends Unknown | Snapshot>(relation: T): TargetOf<T> => {
|
|
157
250
|
assertArgument(isRelation(relation), 'Expected a relation');
|
|
158
|
-
assumeType<InternalObjectProps>(relation);
|
|
159
|
-
const obj = (relation as InternalObjectProps)[RelationTargetId];
|
|
251
|
+
assumeType<internal.InternalObjectProps>(relation);
|
|
252
|
+
const obj = (relation as internal.InternalObjectProps)[internal.RelationTargetId];
|
|
160
253
|
invariant(obj !== undefined, `Invalid target: ${relation.id}`);
|
|
161
|
-
return obj as
|
|
254
|
+
return obj as TargetOf<T>;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
//
|
|
258
|
+
// Change
|
|
259
|
+
//
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Makes all properties mutable recursively.
|
|
263
|
+
* Used to provide a mutable view of a relation within `Relation.change`.
|
|
264
|
+
*/
|
|
265
|
+
export type Mutable<T> = internal.Mutable<T>;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Perform mutations on an echo relation within a controlled context.
|
|
269
|
+
*
|
|
270
|
+
* All mutations within the callback are batched and trigger a single notification
|
|
271
|
+
* when the callback completes. Direct mutations outside of `Relation.change` will throw
|
|
272
|
+
* an error for echo relations.
|
|
273
|
+
*
|
|
274
|
+
* @param relation - The echo relation to mutate. Use `Obj.change` for objects.
|
|
275
|
+
* @param callback - The callback that performs mutations on the relation.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* const worksFor = Relation.make(EmployedBy, {
|
|
280
|
+
* [Relation.Source]: person,
|
|
281
|
+
* [Relation.Target]: company,
|
|
282
|
+
* role: 'Engineer',
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* // Mutate within Relation.change
|
|
286
|
+
* Relation.change(worksFor, (r) => {
|
|
287
|
+
* r.role = 'Senior Engineer';
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* Note: Only accepts relations. Use `Obj.change` for objects.
|
|
292
|
+
*/
|
|
293
|
+
export const change = <T extends Unknown>(relation: T, callback: internal.ChangeCallback<T>): void => {
|
|
294
|
+
internal.change(relation, callback);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
//
|
|
298
|
+
// Snapshot
|
|
299
|
+
//
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Returns an immutable snapshot of a relation.
|
|
303
|
+
* The snapshot is branded with SnapshotKindId instead of KindId,
|
|
304
|
+
* making it distinguishable from the reactive relation at the type level.
|
|
305
|
+
*/
|
|
306
|
+
export const getSnapshot: <T extends Unknown>(rel: T) => Snapshot<T> = internal.getSnapshot as any;
|
|
307
|
+
|
|
308
|
+
//
|
|
309
|
+
// Subscribe
|
|
310
|
+
//
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Subscribe to relation updates.
|
|
314
|
+
* The callback is called synchronously when the relation is modified.
|
|
315
|
+
* Only accepts reactive relations (not snapshots).
|
|
316
|
+
* @returns Unsubscribe function.
|
|
317
|
+
*/
|
|
318
|
+
export const subscribe = (rel: Unknown, callback: () => void): (() => void) => {
|
|
319
|
+
return internal.subscribe(rel, callback);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
//
|
|
323
|
+
// Property Access
|
|
324
|
+
//
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Get a deeply nested property from a relation.
|
|
328
|
+
* Accepts both reactive relations and snapshots.
|
|
329
|
+
*/
|
|
330
|
+
export const getValue = (rel: Unknown | Snapshot, path: readonly (string | number)[]): any => {
|
|
331
|
+
return internal.getValue(rel, createJsonPath(path));
|
|
162
332
|
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Set a deeply nested property on a relation.
|
|
336
|
+
* Must be called within a `Relation.change` callback.
|
|
337
|
+
*
|
|
338
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
339
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
340
|
+
*/
|
|
341
|
+
export const setValue: (rel: Mutable<Unknown>, path: readonly (string | number)[], value: any) => void =
|
|
342
|
+
internal.setValue as any;
|
|
343
|
+
|
|
344
|
+
//
|
|
345
|
+
// Type
|
|
346
|
+
//
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Get the DXN of the relation.
|
|
350
|
+
* Accepts both reactive relations and snapshots.
|
|
351
|
+
*/
|
|
352
|
+
export const getDXN = (entity: Unknown | Snapshot): DXN => internal.getDXN(entity);
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @returns The DXN of the relation's type.
|
|
356
|
+
*/
|
|
357
|
+
export const getTypeDXN = internal.getTypeDXN;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Get the schema of the relation.
|
|
361
|
+
* Returns the branded ECHO schema used to create the relation.
|
|
362
|
+
*/
|
|
363
|
+
export const getSchema: (rel: unknown | undefined) => Type.AnyEntity | undefined = internal.getSchema as any;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* @returns The typename of the relation's type.
|
|
367
|
+
* Accepts both reactive relations and snapshots.
|
|
368
|
+
*/
|
|
369
|
+
export const getTypename = (entity: Unknown | Snapshot): string | undefined => internal.getTypename(entity);
|
|
370
|
+
|
|
371
|
+
//
|
|
372
|
+
// Database
|
|
373
|
+
//
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Get the database the relation belongs to.
|
|
377
|
+
* Accepts both reactive relations and snapshots.
|
|
378
|
+
*/
|
|
379
|
+
export const getDatabase = (entity: Unknown | Snapshot): Database.Database | undefined => internal.getDatabase(entity);
|
|
380
|
+
|
|
381
|
+
//
|
|
382
|
+
// Meta
|
|
383
|
+
//
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Property that accesses metadata for an entity.
|
|
387
|
+
*
|
|
388
|
+
* Alias for `Entity.Meta`.
|
|
389
|
+
*/
|
|
390
|
+
export const Meta = internal.MetaId;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Deeply read-only version of ObjectMeta.
|
|
394
|
+
*/
|
|
395
|
+
export type ReadonlyMeta = internal.ReadonlyMeta;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Mutable meta type returned by `Relation.getMeta` inside a `Relation.change` callback.
|
|
399
|
+
*/
|
|
400
|
+
export type Meta = internal.Meta;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Get the metadata for a relation.
|
|
404
|
+
* Returns mutable meta when passed a mutable relation (inside `Relation.change` callback).
|
|
405
|
+
* Returns read-only meta when passed a regular relation or snapshot.
|
|
406
|
+
*/
|
|
407
|
+
// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
408
|
+
export function getMeta(entity: Mutable<Unknown>): Meta;
|
|
409
|
+
export function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;
|
|
410
|
+
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): Meta | ReadonlyMeta {
|
|
411
|
+
return internal.getMetaChecked(entity);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @returns Foreign keys for the relation from the specified source.
|
|
416
|
+
* Accepts both reactive relations and snapshots.
|
|
417
|
+
*/
|
|
418
|
+
export const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Delete all keys from the relation for the specified source.
|
|
422
|
+
* Must be called within a `Relation.change` callback.
|
|
423
|
+
*
|
|
424
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
425
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
426
|
+
*/
|
|
427
|
+
export const deleteKeys = (entity: Mutable<Unknown>, source: string): void => internal.deleteKeys(entity, source);
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Add a tag to the relation.
|
|
431
|
+
* Must be called within a `Relation.change` callback.
|
|
432
|
+
*
|
|
433
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
434
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
435
|
+
*/
|
|
436
|
+
export const addTag = (entity: Mutable<Unknown>, tag: string): void => internal.addTag(entity, tag);
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Remove a tag from the relation.
|
|
440
|
+
* Must be called within a `Relation.change` callback.
|
|
441
|
+
*
|
|
442
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
443
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
444
|
+
*/
|
|
445
|
+
export const removeTag = (entity: Mutable<Unknown>, tag: string): void => internal.removeTag(entity, tag);
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Check if the relation is deleted.
|
|
449
|
+
* Accepts both reactive relations and snapshots.
|
|
450
|
+
*/
|
|
451
|
+
export const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);
|
|
452
|
+
|
|
453
|
+
//
|
|
454
|
+
// Annotations
|
|
455
|
+
//
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Get the label of the relation.
|
|
459
|
+
* Accepts both reactive relations and snapshots.
|
|
460
|
+
*/
|
|
461
|
+
export const getLabel = (entity: Unknown | Snapshot): string | undefined => internal.getLabel(entity);
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Set the label of the relation.
|
|
465
|
+
* Must be called within a `Relation.change` callback.
|
|
466
|
+
*
|
|
467
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
468
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
469
|
+
*/
|
|
470
|
+
export const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Get the description of the relation.
|
|
474
|
+
* Accepts both reactive relations and snapshots.
|
|
475
|
+
*/
|
|
476
|
+
export const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Set the description of the relation.
|
|
480
|
+
* Must be called within a `Relation.change` callback.
|
|
481
|
+
*
|
|
482
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
483
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
484
|
+
*/
|
|
485
|
+
export const setDescription = (entity: Mutable<Unknown>, description: string): void =>
|
|
486
|
+
internal.setDescription(entity, description);
|
|
487
|
+
|
|
488
|
+
//
|
|
489
|
+
// JSON
|
|
490
|
+
//
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* JSON representation of a relation.
|
|
494
|
+
*/
|
|
495
|
+
export type JSON = internal.ObjectJSON;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Converts relation to its JSON representation.
|
|
499
|
+
* Accepts both reactive relations and snapshots.
|
|
500
|
+
*/
|
|
501
|
+
export const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);
|
|
502
|
+
|
|
503
|
+
//
|
|
504
|
+
// Sorting
|
|
505
|
+
//
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Comparator function type for sorting relations.
|
|
509
|
+
* Accepts both reactive relations and snapshots.
|
|
510
|
+
*/
|
|
511
|
+
export type Comparator = internal.Comparator<Unknown | Snapshot>;
|
|
512
|
+
|
|
513
|
+
export const sortByLabel: Comparator = internal.sortByLabel as Comparator;
|
|
514
|
+
export const sortByTypename: Comparator = internal.sortByTypename as Comparator;
|
|
515
|
+
export const sort = (...comparators: Comparator[]): Comparator => internal.sort(...comparators) as Comparator;
|
|
516
|
+
|
|
517
|
+
//
|
|
518
|
+
// Version
|
|
519
|
+
//
|
|
520
|
+
|
|
521
|
+
export const VersionTypeId = internal.VersionTypeId;
|
|
522
|
+
export const isVersion = internal.isVersion;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Represent relation version.
|
|
526
|
+
*/
|
|
527
|
+
export type Version = internal.EntityVersion;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Returns the version of the relation.
|
|
531
|
+
* Accepts both reactive relations and snapshots.
|
|
532
|
+
*/
|
|
533
|
+
export const version = (entity: Unknown | Snapshot): Version => internal.version(entity);
|