@dxos/echo 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8
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 +10 -11
- package/dist/lib/neutral/Annotation.mjs +68 -0
- package/dist/lib/neutral/Database.mjs +38 -0
- package/dist/lib/neutral/Entity.mjs +72 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Feed.mjs +54 -0
- package/dist/lib/neutral/Filter.mjs +70 -0
- package/dist/lib/neutral/Format.mjs +86 -0
- package/dist/lib/neutral/Format.mjs.map +7 -0
- package/dist/lib/neutral/JsonSchema.mjs +18 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +16 -0
- package/dist/lib/neutral/Key.mjs.map +7 -0
- package/dist/lib/neutral/Migration.mjs +18 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +122 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +16 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +38 -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 +25 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Registry.mjs +14 -0
- package/dist/lib/neutral/Registry.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +97 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Scope.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +32 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +65 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-35INCYOE.mjs +7 -0
- package/dist/lib/neutral/chunk-35INCYOE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs +101 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +184 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs +108 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5SUJPHAE.mjs +34 -0
- package/dist/lib/neutral/chunk-5SUJPHAE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6M2Z6WBH.mjs +93 -0
- package/dist/lib/neutral/chunk-6M2Z6WBH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6YDI3J37.mjs +346 -0
- package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs +2279 -0
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs +25 -0
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7PI7C4EF.mjs +747 -0
- package/dist/lib/neutral/chunk-7PI7C4EF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs +51 -0
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs +56 -0
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IGK6FN65.mjs +27 -0
- package/dist/lib/neutral/chunk-IGK6FN65.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-LWXVKPPW.mjs +281 -0
- package/dist/lib/neutral/chunk-LWXVKPPW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs +48 -0
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs +94 -0
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QQIYS74I.mjs +336 -0
- package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs +678 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RIVWNMSF.mjs +41 -0
- package/dist/lib/neutral/chunk-RIVWNMSF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SBVFRTST.mjs +160 -0
- package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs +251 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs +428 -0
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs +437 -0
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs +205 -0
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs +36 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WTQJHC75.mjs +395 -0
- package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs +31 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs +132 -0
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +111 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/internal/index.mjs +539 -0
- package/dist/lib/neutral/internal/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +458 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +128 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- 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 +15 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +208 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Dataset.d.ts +29 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +247 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- 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 +229 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +175 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +2 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +70 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- 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 +16 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +2 -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 +483 -110
- 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 +26 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +231 -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 +101 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +69 -11
- 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 +321 -23
- 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/Scope.d.ts +35 -0
- package/dist/types/src/Scope.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +26 -9
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +397 -106
- 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 +65 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +21 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +272 -0
- 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/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 +6 -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/Annotation/util.d.ts +48 -0
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/api.d.ts +27 -0
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/entity.d.ts +84 -0
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- 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 +10 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/model.d.ts +59 -0
- 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 +58 -0
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts +2 -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 +7 -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/{formats → Format}/index.d.ts +2 -2
- 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/{formats → Format}/object.d.ts +3 -1
- 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 +14 -10
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json → 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 +5 -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 +136 -35
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json → JsonSchema}/json-schema.d.ts +6 -3
- 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/atoms.d.ts +38 -0
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts +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/create.d.ts → Obj/create-object.d.ts} +15 -16
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/deleted.d.ts +6 -0
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/index.d.ts +11 -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 +45 -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/Query/index.d.ts +2 -0
- package/dist/types/src/internal/Query/index.d.ts.map +1 -0
- package/dist/types/src/internal/Query/pretty.d.ts +10 -0
- package/dist/types/src/internal/Query/pretty.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/atoms.d.ts +10 -0
- package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts +21 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +88 -32
- 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/Ref/utils.d.ts +8 -0
- package/dist/types/src/internal/Ref/utils.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.d.ts +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/Type/index.d.ts +3 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- 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/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 +45 -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/common/proxy/make-object.d.ts +20 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts +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/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +64 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/base.d.ts +27 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/entity.d.ts +94 -0
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/index.d.ts +7 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/meta.d.ts +54 -0
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +65 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/typename.d.ts +28 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/version.d.ts +15 -0
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- 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 +10 -14
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +4 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/registry.d.ts +9 -0
- package/dist/types/src/testing/registry.d.ts.map +1 -0
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +298 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +23 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +119 -66
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +202 -0
- package/src/Collection.ts +33 -0
- package/src/Database.ts +345 -0
- package/src/Dataset.ts +34 -0
- package/src/Entity.test.ts +132 -0
- package/src/Entity.ts +345 -0
- package/src/Err.ts +40 -0
- package/src/Feed.ts +352 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +484 -0
- package/src/Format.ts +5 -0
- package/src/Hypergraph.ts +84 -0
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/JsonSchema.ts +26 -0
- package/src/Key.ts +4 -1
- package/src/Migration.ts +114 -0
- package/src/Obj.test.ts +641 -0
- package/src/Obj.ts +778 -281
- package/src/Order.ts +68 -0
- package/src/Query.test.ts +835 -0
- package/src/Query.ts +634 -0
- package/src/QueryResult.ts +132 -0
- package/src/Ref.ts +98 -10
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +88 -0
- package/src/Relation.ts +503 -67
- package/src/Scope.ts +50 -0
- package/src/Tag.md +88 -0
- package/src/Tag.ts +53 -8
- package/src/Type.test.ts +257 -0
- package/src/Type.ts +643 -151
- package/src/View.ts +98 -0
- package/src/exemplars.test.ts +21 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +22 -6
- package/src/internal/Annotation/annotations.test.ts +165 -0
- package/src/internal/Annotation/annotations.ts +609 -0
- package/src/internal/Annotation/dictionary.ts +47 -0
- package/src/internal/Annotation/entity-dictionary.ts +74 -0
- package/src/internal/Annotation/index.ts +9 -0
- package/src/internal/Annotation/sorting.ts +51 -0
- package/src/internal/Annotation/util.ts +94 -0
- package/src/internal/Entity/api.ts +77 -0
- package/src/internal/Entity/entity.ts +277 -0
- package/src/internal/Entity/guard.ts +26 -0
- package/src/internal/Entity/index.ts +13 -0
- package/src/internal/Entity/model.ts +119 -0
- package/src/internal/Entity/object.ts +73 -0
- package/src/internal/Entity/relation.ts +188 -0
- package/src/internal/Entity/type-kind.ts +75 -0
- package/src/internal/Entity/type-uri.ts +92 -0
- package/src/internal/Entity/util.ts +33 -0
- package/src/internal/Entity/version.ts +96 -0
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/date.ts +5 -9
- package/src/internal/{formats → Format}/format.test.ts +27 -7
- package/src/internal/{formats → Format}/format.ts +8 -6
- package/src/internal/{formats → Format}/index.ts +2 -3
- package/src/internal/{formats → Format}/number.ts +5 -5
- package/src/internal/{formats → Format}/object.ts +23 -6
- package/src/internal/{formats → Format}/select.ts +6 -4
- package/src/internal/{formats → Format}/string.ts +14 -9
- package/src/internal/{formats → Format}/types.ts +54 -43
- package/src/internal/{json → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/index.ts +2 -0
- package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +4 -2
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +39 -39
- package/src/internal/{json → JsonSchema}/json-schema.test.ts +119 -182
- package/src/internal/{json → JsonSchema}/json-schema.ts +70 -42
- package/src/internal/Obj/atoms.ts +244 -0
- package/src/internal/Obj/clone.ts +53 -0
- package/src/internal/{object → Obj}/common.ts +3 -4
- package/src/internal/Obj/create-object.test.ts +116 -0
- package/src/internal/Obj/create-object.ts +140 -0
- package/src/internal/Obj/deleted.ts +19 -0
- package/src/internal/Obj/index.ts +14 -0
- package/src/internal/{object → Obj}/inspect.ts +7 -7
- package/src/internal/Obj/json-serializer.test.ts +199 -0
- package/src/internal/Obj/json-serializer.ts +278 -0
- 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 +258 -0
- package/src/internal/Obj/set-value.ts +158 -0
- package/src/internal/Obj/snapshot.ts +114 -0
- package/src/internal/Obj/typed-object.test.ts +32 -0
- package/src/internal/Obj/typed-object.ts +30 -0
- package/src/internal/{json → Query}/index.ts +1 -1
- package/src/internal/Query/pretty.ts +162 -0
- package/src/internal/Ref/atoms.ts +20 -0
- package/src/internal/{ref → Ref}/ref-array.ts +6 -7
- package/src/internal/Ref/ref.test.ts +91 -0
- package/src/internal/{ref → Ref}/ref.ts +230 -101
- package/src/internal/Ref/utils.ts +45 -0
- package/src/internal/{projection → Type}/compose.test.ts +9 -9
- package/src/internal/{projection → Type}/compose.ts +14 -9
- package/src/internal/Type/index.ts +6 -0
- package/src/internal/{schema → Type}/manipulation.ts +0 -25
- package/src/internal/Type/type-schema.ts +60 -0
- package/src/internal/common/README.md +102 -0
- package/src/internal/common/api/index.ts +15 -0
- package/src/internal/common/api/meta.ts +90 -0
- package/src/internal/{testing → common}/index.ts +2 -1
- package/src/internal/common/proxy/change-context.ts +138 -0
- package/src/internal/common/proxy/change.test.ts +527 -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/common/proxy/handler.test.ts +121 -0
- package/src/internal/common/proxy/index.ts +17 -0
- package/src/internal/common/proxy/json-serializer.ts +101 -0
- package/src/internal/common/proxy/make-object.ts +129 -0
- package/src/internal/common/proxy/ownership.ts +252 -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.test.ts +54 -0
- package/src/internal/common/proxy/reactive.ts +77 -0
- package/src/internal/{object → common/proxy}/schema-validator.ts +6 -3
- package/src/internal/common/proxy/schema.test.ts +107 -0
- 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 +509 -0
- package/src/internal/common/proxy/typed-object.test.ts +103 -0
- package/src/internal/common/types/base.ts +43 -0
- package/src/internal/common/types/entity.ts +133 -0
- package/src/internal/common/types/index.ts +15 -0
- package/src/internal/common/types/meta.ts +109 -0
- package/src/internal/common/types/model-symbols.ts +89 -0
- package/src/internal/common/types/typename.ts +91 -0
- package/src/internal/common/types/version.ts +19 -0
- package/src/internal/common/types/well-known-types.ts +15 -0
- package/src/internal/index.ts +14 -17
- package/src/testing/api.test.ts +131 -0
- package/src/testing/index.ts +4 -3
- package/src/testing/registry.ts +44 -0
- package/src/testing/test-data.ts +189 -0
- package/src/testing/test-schema.ts +204 -0
- package/src/testing/util.ts +88 -0
- package/dist/lib/browser/chunk-BIDAASFK.mjs +0 -3727
- package/dist/lib/browser/chunk-BIDAASFK.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs +0 -410
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs +0 -585
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -35
- package/dist/lib/browser/internal/index.mjs +0 -336
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/query/index.mjs +0 -13
- package/dist/lib/browser/testing/index.mjs +0 -267
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs +0 -3727
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs +0 -585
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs +0 -410
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -35
- package/dist/lib/node-esm/internal/index.mjs +0 -336
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/query/index.mjs +0 -13
- package/dist/lib/node-esm/testing/index.mjs +0 -267
- 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/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -131
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.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/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts +0 -3
- 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/object/accessors.d.ts +0 -37
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts +0 -6
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -33
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts +0 -14
- package/dist/types/src/internal/object/expando.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts +0 -6
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts +0 -16
- 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 -32
- 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/meta.d.ts +0 -31
- package/dist/types/src/internal/object/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.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/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts +0 -14
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts +0 -6
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-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 +0 -44
- 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/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts +0 -17
- package/dist/types/src/internal/query/query.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 +0 -21
- 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/echo-schema.d.ts +0 -168
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -7
- 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/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/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -381
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts +0 -10
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts +0 -3
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -2
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -248
- 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/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -228
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/errors.ts +0 -18
- package/src/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.test.ts +0 -98
- package/src/internal/ast/annotations.ts +0 -226
- package/src/internal/ast/entity-kind.ts +0 -15
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/object/accessors.ts +0 -153
- package/src/internal/object/create.test.ts +0 -118
- package/src/internal/object/create.ts +0 -96
- package/src/internal/object/deleted.ts +0 -19
- package/src/internal/object/entity.ts +0 -248
- package/src/internal/object/expando.ts +0 -21
- package/src/internal/object/ids.ts +0 -12
- package/src/internal/object/index.ts +0 -19
- package/src/internal/object/json-serializer.test.ts +0 -99
- package/src/internal/object/json-serializer.ts +0 -225
- package/src/internal/object/meta.ts +0 -61
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typed-object.test.ts +0 -34
- package/src/internal/object/typed-object.ts +0 -88
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/proxy/handler.test.ts +0 -163
- package/src/internal/proxy/reactive-object.ts +0 -108
- package/src/internal/proxy/schema.test.ts +0 -136
- package/src/internal/proxy/typed-handler.test.ts +0 -102
- package/src/internal/proxy/typed-handler.ts +0 -228
- package/src/internal/proxy/typed-object.test.ts +0 -100
- package/src/internal/query/index.ts +0 -5
- package/src/internal/query/query.ts +0 -23
- package/src/internal/ref/ref.test.ts +0 -100
- package/src/internal/schema/echo-schema.ts +0 -383
- package/src/internal/schema/index.ts +0 -10
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/types.ts +0 -144
- package/src/internal/testing/utils.ts +0 -54
- package/src/internal/types/index.ts +0 -6
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/index.ts +0 -6
- package/src/query/query.test.ts +0 -401
- package/src/query/query.ts +0 -789
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -108
- /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/{browser/query/index.mjs.map → neutral/Entity.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/Err.mjs.map} +0 -0
- /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Feed.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Filter.mjs.map} +0 -0
- /package/dist/types/src/internal/{ast → Annotation}/annotations.test.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}/number.d.ts +0 -0
- /package/dist/types/src/internal/{json → JsonSchema}/effect-schema.test.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 → 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}/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/{projection → Type}/compose.test.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/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{json → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
package/src/Relation.ts
CHANGED
|
@@ -2,147 +2,583 @@
|
|
|
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 { SchemaEx } from '@dxos/effect';
|
|
8
12
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
9
|
-
import { DXN } from '@dxos/keys';
|
|
10
|
-
import { type Live } from '@dxos/live-object';
|
|
13
|
+
import { EID, type EntityId, type URI, DXN } from '@dxos/keys';
|
|
11
14
|
import { assumeType } from '@dxos/util';
|
|
12
15
|
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
16
|
+
import type * as Database from './Database';
|
|
17
|
+
import * as Entity from './Entity';
|
|
18
|
+
import * as internal from './internal';
|
|
19
|
+
import * as entityInternal from './internal/Entity';
|
|
20
|
+
import * as objInternal from './internal/Obj';
|
|
15
21
|
import * as Obj from './Obj';
|
|
22
|
+
import type * as Ref from './Ref';
|
|
23
|
+
import type * as Tag from './Tag';
|
|
16
24
|
import * as Type from './Type';
|
|
17
25
|
|
|
26
|
+
export type Endpoints<Source, Target> = {
|
|
27
|
+
[Source]: Source;
|
|
28
|
+
[Target]: Target;
|
|
29
|
+
};
|
|
30
|
+
|
|
18
31
|
/**
|
|
19
|
-
*
|
|
32
|
+
* Base type for all ECHO relations.
|
|
33
|
+
* @private
|
|
20
34
|
*/
|
|
21
35
|
interface BaseRelation<Source, Target>
|
|
22
|
-
extends
|
|
23
|
-
Type.Relation.Endpoints<Source, Target>,
|
|
24
|
-
Type.OfKind<EchoSchema.EntityKind.Relation> {}
|
|
36
|
+
extends internal.AnyEntity, Endpoints<Source, Target>, Entity.OfKind<internal.EntityKind.Relation> {}
|
|
25
37
|
|
|
26
38
|
/**
|
|
27
|
-
* Relation
|
|
39
|
+
* Relation with no known properties beyond id, kind, source, and target.
|
|
40
|
+
* Use this when the relation's schema/properties are not known.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: This is a TypeScript type only, not a schema.
|
|
43
|
+
* To validate that a value is an ECHO relation, use `Relation.isRelation`.
|
|
28
44
|
*/
|
|
29
|
-
export
|
|
45
|
+
export interface Unknown extends BaseRelation<Obj.Unknown, Obj.Unknown> {}
|
|
30
46
|
|
|
31
47
|
/**
|
|
32
|
-
*
|
|
48
|
+
* Runtime Effect schema for any ECHO relation.
|
|
49
|
+
* Use for validation, parsing, or as a reference target for collections.
|
|
50
|
+
* A relation has `id`, source, and target fields plus any additional properties.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).
|
|
53
|
+
* Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* // Structural type guard (accepts any object with id field)
|
|
58
|
+
* if (Schema.is(Type.Relation)(unknownValue)) { ... }
|
|
59
|
+
*
|
|
60
|
+
* // ECHO instance type guard (checks KindId brand)
|
|
61
|
+
* if (Relation.isRelation(unknownValue)) { ... }
|
|
62
|
+
* ```
|
|
33
63
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
// TODO(dmaretskyi): Change ObjModule.Any to ObjModule.Unknown to have stricter types.
|
|
65
|
+
export const Unknown: internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation> = Schema.Struct({
|
|
66
|
+
id: Schema.String,
|
|
67
|
+
}).pipe(
|
|
68
|
+
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
|
|
69
|
+
Schema.annotations({
|
|
70
|
+
[internal.TypeAnnotationId]: {
|
|
71
|
+
kind: Entity.Kind.Relation,
|
|
72
|
+
typename: 'org.dxos.schema.anyRelation',
|
|
73
|
+
version: '0.0.0',
|
|
74
|
+
sourceSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),
|
|
75
|
+
targetSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),
|
|
76
|
+
},
|
|
42
77
|
}),
|
|
43
|
-
)
|
|
78
|
+
) as unknown as internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Relation type with specific source and target types.
|
|
82
|
+
*/
|
|
83
|
+
export type OfShape<Source extends Obj.Unknown, Target extends Obj.Unknown, Props> = BaseRelation<Source, Target> &
|
|
84
|
+
Props;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Base type for snapshot relations (has SnapshotKindId instead of KindId).
|
|
88
|
+
*/
|
|
89
|
+
interface BaseRelationSnapshot<Source, Target> extends internal.AnyEntity, Endpoints<Source, Target> {
|
|
90
|
+
readonly [Entity.SnapshotKindId]: internal.EntityKind.Relation;
|
|
91
|
+
readonly id: EntityId;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* JSON-encoded properties for relations.
|
|
96
|
+
*/
|
|
97
|
+
export interface BaseRelationJson {
|
|
98
|
+
id: string;
|
|
99
|
+
[internal.ATTR_RELATION_SOURCE]: string;
|
|
100
|
+
[internal.ATTR_RELATION_TARGET]: string;
|
|
101
|
+
}
|
|
44
102
|
|
|
45
|
-
|
|
46
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Immutable snapshot of an ECHO relation.
|
|
105
|
+
* Branded with SnapshotKindId (not KindId).
|
|
106
|
+
* Property values are frozen at the time the snapshot was created.
|
|
107
|
+
* Returned by getSnapshot() and hooks.
|
|
108
|
+
*/
|
|
109
|
+
export type Snapshot<T extends Unknown = Unknown> = Omit<T, Entity.KindId> &
|
|
110
|
+
BaseRelationSnapshot<Obj.Unknown, Obj.Unknown>;
|
|
111
|
+
|
|
112
|
+
export const Source: unique symbol = entityInternal.RelationSourceId as any;
|
|
47
113
|
export type Source = typeof Source;
|
|
48
|
-
|
|
114
|
+
|
|
115
|
+
export const Target: unique symbol = entityInternal.RelationTargetId as any;
|
|
49
116
|
export type Target = typeof Target;
|
|
50
117
|
|
|
51
|
-
|
|
52
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Get relation source type.
|
|
120
|
+
*/
|
|
121
|
+
export type SourceOf<A> = A extends Endpoints<infer S, infer _T> ? S : never;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get relation target type.
|
|
125
|
+
*/
|
|
126
|
+
export type TargetOf<A> = A extends Endpoints<infer _S, infer T> ? T : never;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Internal props type for relation instance creation.
|
|
130
|
+
*/
|
|
131
|
+
type MakePropsInternal<T extends Endpoints<any, any>> = {
|
|
132
|
+
id?: EntityId;
|
|
133
|
+
[Meta]?: Partial<internal.EntityMeta>;
|
|
53
134
|
[Source]: T[Source];
|
|
54
135
|
[Target]: T[Target];
|
|
55
|
-
} &
|
|
136
|
+
} & Entity.Properties<T>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Props type for relation creation with a given schema. Accepts a `Type.AnyRelation`
|
|
140
|
+
* entity (created with `Type.makeRelation`) and derives the props shape via
|
|
141
|
+
* `Type.InstanceType`. Object-kind entities are rejected at the type level —
|
|
142
|
+
* use `Obj.MakeProps` for those.
|
|
143
|
+
*/
|
|
144
|
+
export type MakeProps<S extends Type.AnyRelation> = MakePropsInternal<Type.InstanceType<S>>;
|
|
56
145
|
|
|
57
146
|
/**
|
|
58
147
|
* Creates new relation.
|
|
59
148
|
* @param schema - Relation schema.
|
|
60
149
|
* @param props - Relation properties. Endpoints are passed as [Relation.Source] and [Relation.Target] keys.
|
|
61
|
-
* @param meta - Relation metadata.
|
|
150
|
+
* @param meta - Relation metadata. (deprecated; use [Obj.Meta] instead)
|
|
62
151
|
* @returns
|
|
63
152
|
*/
|
|
64
153
|
// 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).
|
|
65
154
|
// TODO(dmaretskyi): Move meta into props.
|
|
66
|
-
export const make = <
|
|
67
|
-
|
|
68
|
-
props: NoInfer<MakeProps<
|
|
69
|
-
|
|
70
|
-
|
|
155
|
+
export const make = <T extends Type.AnyRelation>(
|
|
156
|
+
type: T,
|
|
157
|
+
props: NoInfer<MakeProps<T>>,
|
|
158
|
+
): Type.InstanceType<T> & Entity.OfKind<typeof Entity.Kind.Relation> => {
|
|
159
|
+
const schema = Type.getSchema(type);
|
|
71
160
|
assertArgument(
|
|
72
|
-
|
|
161
|
+
internal.getTypeAnnotation(schema)?.kind === internal.EntityKind.Relation,
|
|
73
162
|
'schema',
|
|
74
163
|
'Expected a relation schema',
|
|
75
164
|
);
|
|
165
|
+
assertArgument(props[internal.ParentId] === undefined, 'props', 'Parent is not allowed for relations');
|
|
166
|
+
|
|
167
|
+
let meta: internal.EntityMeta | undefined = undefined;
|
|
76
168
|
|
|
77
|
-
if (props[
|
|
78
|
-
meta = props[
|
|
79
|
-
delete props[
|
|
169
|
+
if (props[internal.MetaId] != null) {
|
|
170
|
+
meta = props[internal.MetaId] as any;
|
|
171
|
+
delete props[internal.MetaId];
|
|
80
172
|
}
|
|
81
173
|
|
|
82
|
-
const sourceDXN =
|
|
83
|
-
const targetDXN =
|
|
84
|
-
(props as any)[EchoSchema.RelationSourceDXNId] = sourceDXN;
|
|
85
|
-
(props as any)[EchoSchema.RelationTargetDXNId] = targetDXN;
|
|
174
|
+
const sourceDXN = internal.getObjectEchoUri(props[Source]) ?? raise(new Error('Unresolved relation source'));
|
|
175
|
+
const targetDXN = internal.getObjectEchoUri(props[Target]) ?? raise(new Error('Unresolved relation target'));
|
|
86
176
|
|
|
87
|
-
|
|
177
|
+
(props as any)[internal.RelationSourceDXNId] = sourceDXN;
|
|
178
|
+
(props as any)[internal.RelationTargetDXNId] = targetDXN;
|
|
179
|
+
|
|
180
|
+
// Pass the type entity through as `typeSource` so the resulting instance
|
|
181
|
+
// carries a back-reference resolvable via `Relation.getType` / `Entity.getType`.
|
|
182
|
+
return internal.makeObject(schema as any, props as any, meta, type as any) as any;
|
|
88
183
|
};
|
|
89
184
|
|
|
90
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Test if a value is an instance of a given relation type.
|
|
187
|
+
*
|
|
188
|
+
* Mirrors `Obj.instanceOf` but only accepts `Type.AnyRelation` — use
|
|
189
|
+
* `Obj.instanceOf` for objects and `Type.isType` for `Type.Type` entities.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const isEmployedBy = Relation.instanceOf(EmployedBy);
|
|
194
|
+
* if (isEmployedBy(relation)) {
|
|
195
|
+
* // relation is EmployedBy
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
export const instanceOf: {
|
|
200
|
+
<S extends Type.AnyRelation>(schema: S): (value: unknown) => value is Type.InstanceType<S>;
|
|
201
|
+
<S extends Type.AnyRelation>(schema: S, value: unknown): value is Type.InstanceType<S>;
|
|
202
|
+
} = ((...args: [schema: Type.AnyRelation, value?: unknown]) => {
|
|
203
|
+
if (args.length === 1) {
|
|
204
|
+
return (entity: unknown) => internal.isInstanceOf(args[0], entity);
|
|
205
|
+
}
|
|
206
|
+
return internal.isInstanceOf(args[0], args[1]);
|
|
207
|
+
}) as any;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Type guard for relations.
|
|
211
|
+
* Returns true for both reactive relations and relation snapshots.
|
|
212
|
+
*/
|
|
213
|
+
export const isRelation = (value: unknown): value is Unknown => {
|
|
91
214
|
if (typeof value !== 'object' || value === null) {
|
|
92
215
|
return false;
|
|
93
216
|
}
|
|
94
|
-
if (
|
|
217
|
+
if (internal.ATTR_RELATION_SOURCE in value || internal.ATTR_RELATION_TARGET in value) {
|
|
95
218
|
return true;
|
|
96
219
|
}
|
|
97
220
|
|
|
98
|
-
|
|
99
|
-
|
|
221
|
+
// Check for reactive relation (KindId) or snapshot (SnapshotKindId).
|
|
222
|
+
const kind = (value as any)[Entity.KindId] ?? (value as any)[Entity.SnapshotKindId];
|
|
223
|
+
return kind === internal.EntityKind.Relation;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const isSnapshot = (value: unknown): value is Snapshot => {
|
|
227
|
+
if (typeof value !== 'object' || value === null) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
return (value as any)[Entity.SnapshotKindId] === internal.EntityKind.Relation;
|
|
100
231
|
};
|
|
101
232
|
|
|
102
233
|
/**
|
|
103
|
-
* @returns Relation source
|
|
234
|
+
* @returns Relation source URI.
|
|
235
|
+
* Accepts both reactive relations and snapshots.
|
|
104
236
|
* @throws If the object is not a relation.
|
|
105
237
|
*/
|
|
106
|
-
export const
|
|
238
|
+
export const getSourceURI = (value: Unknown | Snapshot): EID.EID => {
|
|
107
239
|
assertArgument(isRelation(value), 'Expected a relation');
|
|
108
|
-
assumeType<
|
|
109
|
-
const
|
|
110
|
-
invariant(
|
|
111
|
-
return
|
|
240
|
+
assumeType<internal.InternalObjectProps>(value);
|
|
241
|
+
const uri = (value as internal.InternalObjectProps)[internal.RelationSourceDXNId];
|
|
242
|
+
invariant(EID.isEID(uri));
|
|
243
|
+
return uri;
|
|
112
244
|
};
|
|
113
245
|
|
|
114
246
|
/**
|
|
115
|
-
* @returns Relation target
|
|
247
|
+
* @returns Relation target URI.
|
|
248
|
+
* Accepts both reactive relations and snapshots.
|
|
116
249
|
* @throws If the object is not a relation.
|
|
117
250
|
*/
|
|
118
|
-
export const
|
|
251
|
+
export const getTargetURI = (value: Unknown | Snapshot): EID.EID => {
|
|
119
252
|
assertArgument(isRelation(value), 'Expected a relation');
|
|
120
|
-
assumeType<
|
|
121
|
-
const
|
|
122
|
-
invariant(
|
|
123
|
-
return
|
|
253
|
+
assumeType<internal.InternalObjectProps>(value);
|
|
254
|
+
const uri = (value as internal.InternalObjectProps)[internal.RelationTargetDXNId];
|
|
255
|
+
invariant(EID.isEID(uri));
|
|
256
|
+
return uri;
|
|
124
257
|
};
|
|
125
258
|
|
|
126
259
|
/**
|
|
127
260
|
* @returns Relation source.
|
|
261
|
+
* Accepts both reactive relations and snapshots.
|
|
128
262
|
* @throws If the object is not a relation.
|
|
129
263
|
*/
|
|
130
|
-
export const getSource = <T extends
|
|
264
|
+
export const getSource = <T extends Unknown | Snapshot>(relation: T): SourceOf<T> => {
|
|
131
265
|
assertArgument(isRelation(relation), 'Expected a relation');
|
|
132
|
-
assumeType<
|
|
133
|
-
const obj = (relation as
|
|
134
|
-
|
|
135
|
-
|
|
266
|
+
assumeType<internal.InternalObjectProps>(relation);
|
|
267
|
+
const obj = (relation as internal.InternalObjectProps)[internal.RelationSourceId];
|
|
268
|
+
if (obj === undefined) {
|
|
269
|
+
throw new Error(`Relation source could not be resolved.`);
|
|
270
|
+
}
|
|
271
|
+
return obj as SourceOf<T>;
|
|
136
272
|
};
|
|
137
273
|
|
|
138
274
|
/**
|
|
139
275
|
* @returns Relation target.
|
|
276
|
+
* Accepts both reactive relations and snapshots.
|
|
140
277
|
* @throws If the object is not a relation.
|
|
141
278
|
*/
|
|
142
|
-
export const getTarget = <T extends
|
|
279
|
+
export const getTarget = <T extends Unknown | Snapshot>(relation: T): TargetOf<T> => {
|
|
143
280
|
assertArgument(isRelation(relation), 'Expected a relation');
|
|
144
|
-
assumeType<
|
|
145
|
-
const obj = (relation as
|
|
146
|
-
|
|
147
|
-
|
|
281
|
+
assumeType<internal.InternalObjectProps>(relation);
|
|
282
|
+
const obj = (relation as internal.InternalObjectProps)[internal.RelationTargetId];
|
|
283
|
+
if (obj === undefined) {
|
|
284
|
+
throw new Error(`Relation target could not be resolved.`);
|
|
285
|
+
}
|
|
286
|
+
return obj as TargetOf<T>;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
//
|
|
290
|
+
// Change
|
|
291
|
+
//
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Makes all properties mutable recursively.
|
|
295
|
+
* Used to provide a mutable view of a relation within `Relation.update`.
|
|
296
|
+
*/
|
|
297
|
+
export type Mutable<T> = internal.Mutable<T>;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Perform mutations on an echo relation within a controlled context.
|
|
301
|
+
*
|
|
302
|
+
* All mutations within the callback are batched and trigger a single notification
|
|
303
|
+
* when the callback completes. Direct mutations outside of `Relation.update` will throw
|
|
304
|
+
* an error for echo relations.
|
|
305
|
+
*
|
|
306
|
+
* @param relation - The echo relation to mutate. Use `Obj.update` for objects.
|
|
307
|
+
* @param callback - The callback that performs mutations on the relation.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```ts
|
|
311
|
+
* const worksFor = Relation.make(EmployedBy, {
|
|
312
|
+
* [Relation.Source]: person,
|
|
313
|
+
* [Relation.Target]: company,
|
|
314
|
+
* role: 'Engineer',
|
|
315
|
+
* });
|
|
316
|
+
*
|
|
317
|
+
* // Mutate within Relation.update
|
|
318
|
+
* Relation.update(worksFor, (obj) => {
|
|
319
|
+
* obj.role = 'Senior Engineer';
|
|
320
|
+
* });
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* Note: Only accepts relations. Use `Obj.update` for objects.
|
|
324
|
+
*/
|
|
325
|
+
export const update = <T extends Unknown>(relation: T, callback: internal.ChangeCallback<T>): void => {
|
|
326
|
+
internal.change(relation, callback);
|
|
148
327
|
};
|
|
328
|
+
|
|
329
|
+
//
|
|
330
|
+
// Snapshot
|
|
331
|
+
//
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Returns an immutable snapshot of a relation.
|
|
335
|
+
* The snapshot is branded with SnapshotKindId instead of KindId,
|
|
336
|
+
* making it distinguishable from the reactive relation at the type level.
|
|
337
|
+
*/
|
|
338
|
+
export const getSnapshot: <T extends Unknown>(rel: T) => Snapshot<T> = internal.getSnapshot as any;
|
|
339
|
+
|
|
340
|
+
//
|
|
341
|
+
// Subscribe
|
|
342
|
+
//
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Subscribe to relation updates.
|
|
346
|
+
* The callback is called synchronously when the relation is modified.
|
|
347
|
+
* Only accepts reactive relations (not snapshots).
|
|
348
|
+
* @returns Unsubscribe function.
|
|
349
|
+
*/
|
|
350
|
+
export const subscribe = (rel: Unknown, callback: () => void): (() => void) => {
|
|
351
|
+
return internal.subscribe(rel, callback);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
//
|
|
355
|
+
// Property Access
|
|
356
|
+
//
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Get a deeply nested property from a relation.
|
|
360
|
+
* Accepts both reactive relations and snapshots.
|
|
361
|
+
*/
|
|
362
|
+
export const getValue = (rel: Unknown | Snapshot, path: readonly (string | number)[]): any => {
|
|
363
|
+
return SchemaEx.getValue(rel, SchemaEx.createJsonPath(path));
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Set a deeply nested property on a relation.
|
|
368
|
+
* Must be called within a `Relation.update` callback.
|
|
369
|
+
*
|
|
370
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
371
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
372
|
+
*/
|
|
373
|
+
export const setValue: (rel: Mutable<Unknown>, path: readonly (string | number)[], value: any) => void =
|
|
374
|
+
internal.setValue as any;
|
|
375
|
+
|
|
376
|
+
//
|
|
377
|
+
// Type
|
|
378
|
+
//
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Get the canonical URI of the relation. Returns `URI.URI` — today always an EID,
|
|
382
|
+
* but future entity kinds may surface other URI schemes; narrow with `EID.parse(uri)`
|
|
383
|
+
* or `DXN.tryMake(uri)` at the point of use. Accepts both reactive relations and snapshots.
|
|
384
|
+
*
|
|
385
|
+
* @param options.prefer - Controls the URI form (see {@link internal.GetURIOptions}).
|
|
386
|
+
*/
|
|
387
|
+
export const getURI = (entity: Unknown | Snapshot, options?: internal.GetURIOptions): URI.URI =>
|
|
388
|
+
internal.getUri(entity, options);
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @returns The DXN of the relation's type.
|
|
392
|
+
*/
|
|
393
|
+
export const getTypeURI: (obj: internal.AnyProperties) => URI.URI | undefined = internal.getTypeURI;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Get the type entity (`Type.AnyRelation`) the relation was created from.
|
|
397
|
+
*
|
|
398
|
+
* Returns `undefined` when the relation's type isn't registered in this
|
|
399
|
+
* runtime (e.g. a freshly deserialized snapshot whose type entity hasn't been
|
|
400
|
+
* wired up yet, or a relation loaded from storage before its schema is known).
|
|
401
|
+
* To get the Effect Schema from the returned entity, use `Type.getSchema(...)`.
|
|
402
|
+
*/
|
|
403
|
+
export const getType = (relation: Unknown | Snapshot): Type.AnyRelation | undefined =>
|
|
404
|
+
internal.getType(relation) as Type.AnyRelation | undefined;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @returns The typename of the relation's type.
|
|
408
|
+
* Accepts both reactive relations and snapshots.
|
|
409
|
+
*/
|
|
410
|
+
export const getTypename = (entity: Unknown | Snapshot): string | undefined => internal.getTypename(entity);
|
|
411
|
+
|
|
412
|
+
//
|
|
413
|
+
// Database
|
|
414
|
+
//
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Get the database the relation belongs to.
|
|
418
|
+
* Accepts both reactive relations and snapshots.
|
|
419
|
+
*/
|
|
420
|
+
export const getDatabase = (entity: Unknown | Snapshot): Database.Database | undefined => internal.getDatabase(entity);
|
|
421
|
+
|
|
422
|
+
//
|
|
423
|
+
// Meta
|
|
424
|
+
//
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Property that accesses metadata for an entity.
|
|
428
|
+
*
|
|
429
|
+
* Alias for `Entity.Meta`.
|
|
430
|
+
*/
|
|
431
|
+
export const Meta = internal.MetaId;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Deeply read-only version of EntityMeta.
|
|
435
|
+
*/
|
|
436
|
+
export type ReadonlyMeta = internal.ReadonlyMeta;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Mutable meta type returned by `Relation.getMeta` inside a `Relation.update` callback.
|
|
440
|
+
*/
|
|
441
|
+
export type Meta = internal.Meta;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Get the metadata for a relation.
|
|
445
|
+
* Returns mutable meta when passed a mutable relation (inside `Relation.update` callback).
|
|
446
|
+
* Returns read-only meta when passed a regular relation or snapshot.
|
|
447
|
+
*/
|
|
448
|
+
// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
449
|
+
export function getMeta(entity: Mutable<Unknown>): Meta;
|
|
450
|
+
export function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;
|
|
451
|
+
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): Meta | ReadonlyMeta {
|
|
452
|
+
return internal.getMetaChecked(entity);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* @returns Foreign keys for the relation from the specified source.
|
|
457
|
+
* Accepts both reactive relations and snapshots.
|
|
458
|
+
*/
|
|
459
|
+
export const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Delete all keys from the relation for the specified source.
|
|
463
|
+
* Must be called within a `Relation.update` callback.
|
|
464
|
+
*
|
|
465
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
466
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
467
|
+
*/
|
|
468
|
+
export const deleteKeys = (entity: Mutable<Unknown>, source: string): void => internal.deleteKeys(entity, source);
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Add a tag to the relation.
|
|
472
|
+
* Must be called within a `Relation.update` callback.
|
|
473
|
+
*
|
|
474
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
475
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
476
|
+
*/
|
|
477
|
+
export const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Remove a tag from the relation.
|
|
481
|
+
* Must be called within a `Relation.update` callback.
|
|
482
|
+
*
|
|
483
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
484
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
485
|
+
*/
|
|
486
|
+
export const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Check if the relation is deleted.
|
|
490
|
+
* Accepts both reactive relations and snapshots.
|
|
491
|
+
*/
|
|
492
|
+
export const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);
|
|
493
|
+
|
|
494
|
+
//
|
|
495
|
+
// Annotations
|
|
496
|
+
//
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Get the label of the relation.
|
|
500
|
+
* Accepts both reactive relations and snapshots.
|
|
501
|
+
*
|
|
502
|
+
* @param options.fallback `'typename'` returns the relation's typename when no
|
|
503
|
+
* label is set (e.g. `org.dxos.type.table`).
|
|
504
|
+
*/
|
|
505
|
+
export const getLabel = (entity: Unknown | Snapshot, options?: internal.GetLabelOptions): string | undefined =>
|
|
506
|
+
internal.getLabel(entity, options);
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Set the label of the relation.
|
|
510
|
+
* Must be called within a `Relation.update` callback.
|
|
511
|
+
*
|
|
512
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
513
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
514
|
+
*/
|
|
515
|
+
export const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Get the description of the relation.
|
|
519
|
+
* Accepts both reactive relations and snapshots.
|
|
520
|
+
*/
|
|
521
|
+
export const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Set the description of the relation.
|
|
525
|
+
* Must be called within a `Relation.update` callback.
|
|
526
|
+
*
|
|
527
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
528
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
529
|
+
*/
|
|
530
|
+
export const setDescription = (entity: Mutable<Unknown>, description: string): void =>
|
|
531
|
+
internal.setDescription(entity, description);
|
|
532
|
+
|
|
533
|
+
//
|
|
534
|
+
// JSON
|
|
535
|
+
//
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* JSON representation of a relation.
|
|
539
|
+
*/
|
|
540
|
+
export type JSON = internal.ObjectJSON;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Converts relation to its JSON representation.
|
|
544
|
+
* Accepts both reactive relations and snapshots.
|
|
545
|
+
*/
|
|
546
|
+
export const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);
|
|
547
|
+
|
|
548
|
+
//
|
|
549
|
+
// Sorting
|
|
550
|
+
//
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Comparator function type for sorting relations.
|
|
554
|
+
* Accepts both reactive relations and snapshots.
|
|
555
|
+
*/
|
|
556
|
+
export type Comparator = internal.Comparator<Unknown | Snapshot>;
|
|
557
|
+
|
|
558
|
+
export const sortByLabel: Comparator = internal.sortByLabel as Comparator;
|
|
559
|
+
export const sortByTypename: Comparator = internal.sortByTypename as Comparator;
|
|
560
|
+
export const sort = (...comparators: Comparator[]): Comparator => internal.sort(...comparators) as Comparator;
|
|
561
|
+
|
|
562
|
+
//
|
|
563
|
+
// Version
|
|
564
|
+
//
|
|
565
|
+
|
|
566
|
+
export const VersionTypeId = internal.VersionTypeId;
|
|
567
|
+
export const isVersion = internal.isVersion;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Represent relation version.
|
|
571
|
+
*/
|
|
572
|
+
export type Version = internal.EntityVersion;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Returns the version of the relation.
|
|
576
|
+
* Accepts both reactive relations and snapshots.
|
|
577
|
+
*/
|
|
578
|
+
export const version = (entity: Unknown | Snapshot): Version => internal.version(entity);
|
|
579
|
+
|
|
580
|
+
//
|
|
581
|
+
// Atoms
|
|
582
|
+
//
|
|
583
|
+
|
|
584
|
+
export const atom = objInternal.makeRelation;
|