@dxos/echo 0.8.4-main.ef1bc66f44 → 0.8.4-main.effb148878
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 +9 -9
- package/dist/lib/neutral/Annotation.mjs +7 -3
- package/dist/lib/neutral/Database.mjs +8 -4
- package/dist/lib/neutral/Entity.mjs +35 -18
- package/dist/lib/neutral/Err.mjs +3 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +54 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +25 -12
- package/dist/lib/neutral/Format.mjs +23 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Key.mjs +7 -3
- package/dist/lib/neutral/Migration.mjs +18 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +41 -23
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +21 -9
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +13 -9
- package/dist/lib/neutral/Relation.mjs +34 -23
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +14 -10
- package/dist/lib/neutral/Type.mjs +52 -36
- package/dist/lib/neutral/{chunk-K5K3Z62A.mjs → chunk-4SYHDOQA.mjs} +14 -6
- package/dist/lib/neutral/chunk-4SYHDOQA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-XAJMXQ4H.mjs → chunk-4U7OD55H.mjs} +6 -2
- package/dist/lib/neutral/chunk-4U7OD55H.mjs.map +7 -0
- package/dist/lib/neutral/chunk-52NG2XEE.mjs +34 -0
- package/dist/lib/neutral/chunk-52NG2XEE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-KB7RIVLK.mjs → chunk-A5HDDVKS.mjs} +33 -6
- package/dist/lib/neutral/chunk-A5HDDVKS.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DLPC7DHQ.mjs → chunk-EZ4XJFHJ.mjs} +9 -11
- package/dist/lib/neutral/chunk-EZ4XJFHJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZAHWXGK4.mjs → chunk-F625JEZB.mjs} +97 -19
- package/dist/lib/neutral/chunk-F625JEZB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FFCN66OF.mjs +420 -0
- package/dist/lib/neutral/chunk-FFCN66OF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RPB6V4BE.mjs → chunk-GOHDOJE3.mjs} +16 -3
- package/dist/lib/neutral/chunk-GOHDOJE3.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs +50 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J7QWJQQV.mjs +318 -0
- package/dist/lib/neutral/chunk-J7QWJQQV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QARLJVDB.mjs → chunk-JTHNDGAR.mjs} +8 -4
- package/dist/lib/neutral/chunk-JTHNDGAR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-K5RH2PBH.mjs +361 -0
- package/dist/lib/neutral/chunk-K5RH2PBH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RIMHNJ3E.mjs → chunk-KHRAQDYX.mjs} +138 -91
- package/dist/lib/neutral/chunk-KHRAQDYX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-L65CW5EI.mjs +156 -0
- package/dist/lib/neutral/chunk-L65CW5EI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LNZIPZX6.mjs +2186 -0
- package/dist/lib/neutral/chunk-LNZIPZX6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MPXUNTME.mjs +41 -0
- package/dist/lib/neutral/chunk-MPXUNTME.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7WE7SBA2.mjs → chunk-O2EOH7XQ.mjs} +152 -134
- package/dist/lib/neutral/chunk-O2EOH7XQ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MTEHHY62.mjs → chunk-Q7ID37KF.mjs} +121 -94
- package/dist/lib/neutral/chunk-Q7ID37KF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QLYEQ5VA.mjs +205 -0
- package/dist/lib/neutral/chunk-QLYEQ5VA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SSDGRJ3A.mjs +747 -0
- package/dist/lib/neutral/chunk-SSDGRJ3A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ROKO4RKJ.mjs → chunk-TTCSATUD.mjs} +2 -2
- package/dist/lib/neutral/chunk-TTCSATUD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-UEFRFUYC.mjs} +8 -4
- package/dist/lib/neutral/chunk-UEFRFUYC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UN7K472Q.mjs +132 -0
- package/dist/lib/neutral/chunk-UN7K472Q.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UQAMAXDU.mjs +243 -0
- package/dist/lib/neutral/chunk-UQAMAXDU.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-V5NE2X7Y.mjs} +1 -1
- package/dist/lib/neutral/chunk-V5NE2X7Y.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-V72DY6LU.mjs} +1 -1
- package/dist/lib/neutral/chunk-ZII2BGPM.mjs +269 -0
- package/dist/lib/neutral/chunk-ZII2BGPM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-N2QNHMT5.mjs → chunk-ZM7VFIS2.mjs} +22 -2
- package/dist/lib/neutral/chunk-ZM7VFIS2.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +56 -29
- package/dist/lib/neutral/internal/index.mjs +128 -77
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +226 -174
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +3 -3
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +15 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +27 -42
- package/dist/types/src/Database.d.ts.map +1 -1
- 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 +123 -29
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +56 -13
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +229 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +74 -11
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +3 -3
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +15 -10
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Key.d.ts +1 -1
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +72 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +201 -77
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +117 -17
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +66 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +127 -54
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +12 -13
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +4 -3
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +337 -218
- package/dist/types/src/Type.d.ts.map +1 -1
- 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/index.d.ts +8 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +98 -24
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Annotation}/sorting.d.ts +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +15 -6
- 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 +67 -0
- package/dist/types/src/internal/Entity/entity.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 +57 -0
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +3 -3
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/relation.d.ts +51 -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 +25 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Entity}/version.d.ts +1 -1
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/format.d.ts +2 -1
- 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/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +37 -37
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +3 -2
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +10 -12
- 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/{object → Obj}/index.d.ts +0 -1
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +16 -8
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/set-value.d.ts +2 -2
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/typed-object.d.ts +5 -5
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +42 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/compose.d.ts +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/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/{api → common/api}/index.d.ts +0 -4
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → common/api}/meta.d.ts +3 -3
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts +19 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts +2 -2
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +18 -2
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/base.d.ts +1 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/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/{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 +12 -1
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +58 -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 +7 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +2 -2
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +9 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +8 -8
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +77 -82
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +5 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -15
- package/src/Annotation.ts +7 -3
- package/src/Collection.ts +36 -0
- package/src/Database.ts +80 -77
- package/src/Dataset.ts +34 -0
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +181 -66
- package/src/Err.ts +25 -3
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +356 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +152 -21
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +16 -11
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/JsonSchema.ts +14 -4
- package/src/Key.ts +1 -1
- package/src/Migration.ts +114 -0
- package/src/Obj.test.ts +158 -20
- package/src/Obj.ts +451 -183
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +446 -89
- package/src/Query.ts +300 -35
- package/src/Ref.ts +83 -12
- package/src/Relation.test.ts +16 -10
- package/src/Relation.ts +236 -165
- package/src/SchemaRegistry.ts +13 -17
- package/src/Tag.ts +9 -9
- package/src/Type.test.ts +169 -24
- package/src/Type.ts +561 -354
- package/src/View.ts +101 -0
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +9 -2
- package/src/internal/Annotation/annotations.test.ts +165 -0
- package/src/internal/{annotations → Annotation}/annotations.ts +181 -101
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -4
- package/src/internal/{annotations → Annotation}/util.ts +17 -9
- package/src/internal/{api/entity.ts → Entity/api.ts} +9 -8
- package/src/internal/Entity/entity.ts +246 -0
- package/src/internal/{entities → Entity}/index.ts +4 -0
- package/src/internal/{entities → Entity}/model.ts +42 -60
- package/src/internal/{entities → Entity}/object.ts +13 -6
- package/src/internal/Entity/relation.ts +179 -0
- package/src/internal/Entity/type-kind.ts +67 -0
- package/src/internal/Entity/type-uri.ts +87 -0
- package/src/internal/Entity/util.ts +34 -0
- package/src/internal/{api → Entity}/version.ts +2 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/date.ts +0 -4
- package/src/internal/{formats → Format}/format.test.ts +1 -2
- package/src/internal/{formats → Format}/index.ts +2 -3
- package/src/internal/{formats → Format}/types.ts +2 -2
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +4 -4
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +64 -151
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +47 -28
- package/src/internal/{object → Obj}/clone.ts +10 -6
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +13 -14
- package/src/internal/Obj/create-object.ts +135 -0
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/index.ts +0 -1
- package/src/internal/{object → Obj}/inspect.ts +3 -3
- package/src/internal/Obj/json-serializer.test.ts +185 -0
- package/src/internal/{object → Obj}/json-serializer.ts +108 -45
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +31 -54
- package/src/internal/{object → Obj}/set-value.ts +3 -3
- package/src/internal/{object → Obj}/snapshot.ts +41 -23
- package/src/internal/Obj/typed-object.test.ts +32 -0
- package/src/internal/{object → Obj}/typed-object.ts +5 -5
- package/src/internal/Query.ts +156 -0
- package/src/internal/{ref → Ref}/ref-array.ts +1 -2
- package/src/internal/{ref → Ref}/ref.test.ts +16 -26
- package/src/internal/{ref → Ref}/ref.ts +117 -57
- package/src/internal/{schema → Type}/compose.test.ts +6 -5
- package/src/internal/{schema → Type}/compose.ts +1 -1
- 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/{README.md → common/README.md} +2 -2
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/{api → common/api}/meta.ts +3 -3
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change-context.ts +1 -1
- package/src/internal/{proxy → common/proxy}/change.test.ts +97 -97
- package/src/internal/{proxy → common/proxy}/errors.ts +2 -2
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -4
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +20 -14
- package/src/internal/{proxy → common/proxy}/make-object.ts +37 -15
- package/src/internal/{proxy → common/proxy}/ownership.ts +0 -1
- package/src/internal/{proxy → common/proxy}/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/{proxy → common/proxy}/reactive.ts +12 -4
- package/src/internal/common/proxy/schema.test.ts +107 -0
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +15 -15
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +75 -18
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +17 -30
- package/src/internal/{types → common/types}/base.ts +1 -1
- package/src/internal/common/types/entity.ts +133 -0
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +15 -1
- package/src/internal/common/types/model-symbols.ts +74 -0
- package/src/internal/common/types/typename.ts +91 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +15 -12
- package/src/testing/test-data.ts +158 -99
- package/src/testing/test-schema.ts +33 -67
- package/src/testing/util.ts +14 -11
- package/dist/lib/neutral/chunk-2AF5GMG6.mjs +0 -171
- package/dist/lib/neutral/chunk-2AF5GMG6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4L6DOFXP.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7WE7SBA2.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DLPC7DHQ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EBUAT5ID.mjs +0 -229
- package/dist/lib/neutral/chunk-EBUAT5ID.mjs.map +0 -7
- package/dist/lib/neutral/chunk-K5K3Z62A.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KB7RIVLK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-LKFNEFHF.mjs +0 -130
- package/dist/lib/neutral/chunk-LKFNEFHF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MTEHHY62.mjs.map +0 -7
- package/dist/lib/neutral/chunk-N2QNHMT5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-QARLJVDB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RIMHNJ3E.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TLGNKUUG.mjs +0 -3905
- package/dist/lib/neutral/chunk-TLGNKUUG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TQT6WTIJ.mjs +0 -142
- package/dist/lib/neutral/chunk-TQT6WTIJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VUQGRDRI.mjs +0 -97
- package/dist/lib/neutral/chunk-VUQGRDRI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs +0 -13
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XAJMXQ4H.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZAHWXGK4.mjs.map +0 -7
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/api/annotations.d.ts +0 -23
- package/dist/types/src/internal/api/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/api/entity.d.ts +0 -13
- package/dist/types/src/internal/api/entity.d.ts.map +0 -1
- package/dist/types/src/internal/api/index.d.ts.map +0 -1
- package/dist/types/src/internal/api/meta.d.ts.map +0 -1
- package/dist/types/src/internal/api/sorting.d.ts.map +0 -1
- package/dist/types/src/internal/api/version.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts +0 -20
- package/dist/types/src/internal/entities/entity.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 +0 -79
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts +0 -62
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/clone.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts +0 -6
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +0 -2
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change-context.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/errors.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts +0 -14
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/ownership.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/symbols.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts +0 -181
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -4
- 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 -20
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts +0 -37
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/src/internal/annotations/annotations.test.ts +0 -96
- package/src/internal/api/annotations.ts +0 -60
- package/src/internal/entities/entity.ts +0 -126
- package/src/internal/entities/relation.ts +0 -171
- package/src/internal/entities/util.ts +0 -33
- package/src/internal/object/create-object.ts +0 -95
- package/src/internal/object/ids.ts +0 -12
- package/src/internal/object/json-serializer.test.ts +0 -98
- package/src/internal/object/typed-object.test.ts +0 -34
- package/src/internal/proxy/schema.test.ts +0 -145
- package/src/internal/schema/echo-schema.ts +0 -424
- package/src/internal/schema/index.ts +0 -7
- package/src/internal/schema/persistent-schema.ts +0 -28
- package/src/internal/types/entity.ts +0 -54
- package/src/internal/types/typename.ts +0 -55
- /package/dist/lib/neutral/{chunk-OMUPQMLR.mjs.map → chunk-V72DY6LU.mjs.map} +0 -0
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/select.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/string.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/clone.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/set-value.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/snapshot.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/define-hidden-property.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/event-batch.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/index.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/json-serializer.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/ownership.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-types.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-utils.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/symbols.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/src/internal/{formats → Format}/format.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{formats → Format}/object.ts +0 -0
- /package/src/internal/{formats → Format}/select.ts +0 -0
- /package/src/internal/{formats → Format}/string.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +0 -0
- /package/src/internal/{object → Obj}/schema-validator.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/define-hidden-property.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/event-batch.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
package/dist/types/src/Type.d.ts
CHANGED
|
@@ -1,77 +1,64 @@
|
|
|
1
1
|
import * as Schema from 'effect/Schema';
|
|
2
|
+
import type * as Types from 'effect/Types';
|
|
2
3
|
import { type EncodedReference } from '@dxos/echo-protocol';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import type * as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
4
|
+
import { DXN, type ObjectId, type URI } from '@dxos/keys';
|
|
5
|
+
import type * as Database from './Database';
|
|
6
|
+
import type * as EntityModule from './Entity';
|
|
7
|
+
import * as internal from './internal';
|
|
8
|
+
import * as typeInternal from './internal/Type';
|
|
9
|
+
import type * as RelationModule from './Relation';
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Structural base shared by the three sibling type-entity interfaces
|
|
12
|
+
* ({@link Obj}, {@link Relation}, {@link Type}). NOT exported — callers
|
|
13
|
+
* should constrain on {@link AnyEntity} when they want "any of the three"
|
|
14
|
+
* and on the specific kind interface otherwise.
|
|
11
15
|
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
[ATTR_RELATION_SOURCE]: string;
|
|
32
|
-
[ATTR_RELATION_TARGET]: string;
|
|
16
|
+
interface BaseTypeEntity<A> {
|
|
17
|
+
/**
|
|
18
|
+
* Entity-kind brand of the type-entity value itself — always `EntityKind.Type`.
|
|
19
|
+
* The kind of instance the type *describes* lives on `[SchemaKindId]`
|
|
20
|
+
* (Object / Relation / Type). Lets `Obj.isObject` / `Relation.isRelation`
|
|
21
|
+
* reject type entities by a single `[KindId]` check.
|
|
22
|
+
*/
|
|
23
|
+
readonly [internal.KindId]: internal.EntityKind.Type;
|
|
24
|
+
/**
|
|
25
|
+
* Object id. Like all ECHO entities, type entities always carry an id —
|
|
26
|
+
* stamped at construction for in-memory (static) declarations and assigned by
|
|
27
|
+
* the database once persisted. The id does NOT determine the entity's URI:
|
|
28
|
+
* static types resolve to their typename DXN, persisted types to `echo:/<id>`
|
|
29
|
+
* (see `getTypeURIFromSpecifier`).
|
|
30
|
+
*/
|
|
31
|
+
readonly id: ObjectId;
|
|
32
|
+
readonly name?: string;
|
|
33
|
+
readonly jsonSchema: internal.JsonSchemaType;
|
|
34
|
+
readonly [InstancePhantomId]?: A;
|
|
33
35
|
}
|
|
34
|
-
type ObjSchemaType = Schema.Schema<any & AnyEntity & Entity$.OfKind<typeof Entity$.Kind.Object> & AnyProperties, {
|
|
35
|
-
id: string;
|
|
36
|
-
} & AnyProperties> & EchoSchemaKind<EntityKind.Object> & TypeMeta;
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
39
|
-
* Use for validation, parsing, or as a reference target for collections.
|
|
40
|
-
*
|
|
41
|
-
* NOTE: `Schema.is(Type.Obj)` does STRUCTURAL validation only (checks for `id` field).
|
|
42
|
-
* Use `Obj.isObject()` for proper ECHO instance type guards that check the KindId brand.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* // Structural type guard (accepts any object with id field)
|
|
47
|
-
* if (Schema.is(Type.Obj)(unknownValue)) { ... }
|
|
37
|
+
* TypeScript type for an ECHO object type — a `Type.Type<A>` entity.
|
|
48
38
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
39
|
+
* `T` is the instance type produced by `Obj.make(Foo, props)`. `Fields` is
|
|
40
|
+
* retained as a structural hint (the runtime value still carries `.fields`),
|
|
41
|
+
* but consumers should derive instance/encoded types via `Type.InstanceType`.
|
|
51
42
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare const Obj: ObjSchemaType;
|
|
59
|
-
/**
|
|
60
|
-
* TypeScript type for an ECHO object schema.
|
|
61
|
-
* `T` is the instance type produced by the schema.
|
|
62
|
-
* `Fields` is the optional struct fields type for introspection.
|
|
43
|
+
* **Not a `Schema.Schema`.** `Foo.ast` / `Schema.Schema.Type<typeof Foo>` /
|
|
44
|
+
* `Schema.extend(Foo)` no longer typecheck — extract the Effect Schema via
|
|
45
|
+
* `Type.getSchema(Foo)` first, or derive instance types via
|
|
46
|
+
* `Type.InstanceType<typeof Foo>`.
|
|
63
47
|
*
|
|
64
48
|
* @example
|
|
65
49
|
* ```ts
|
|
66
|
-
* const
|
|
50
|
+
* const Person = Schema.Struct({
|
|
67
51
|
* name: Schema.String,
|
|
68
|
-
* }).pipe(Type.
|
|
52
|
+
* }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
69
53
|
*
|
|
70
|
-
*
|
|
71
|
-
* Object.keys(PersonSchema.fields); // ['name']
|
|
54
|
+
* type Person = Type.InstanceType<typeof Person>;
|
|
72
55
|
* ```
|
|
73
56
|
*/
|
|
74
|
-
export interface Obj<T
|
|
57
|
+
export interface Obj<T, Fields extends Schema.Struct.Fields = Schema.Struct.Fields> extends BaseTypeEntity<T & EntityModule.OfKind<typeof EntityModule.Kind.Object>> {
|
|
58
|
+
/** Schema-kind brand (object). */
|
|
59
|
+
readonly [internal.SchemaKindId]: internal.EntityKind.Object;
|
|
60
|
+
/** Source Effect Schema — used internally by `Type.getSchema(self)`. */
|
|
61
|
+
readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
75
62
|
/**
|
|
76
63
|
* The fields defined in the original struct schema.
|
|
77
64
|
* Allows accessing field definitions for introspection.
|
|
@@ -79,70 +66,78 @@ export interface Obj<T = any, Fields extends Schema.Struct.Fields = Schema.Struc
|
|
|
79
66
|
readonly fields: Fields;
|
|
80
67
|
}
|
|
81
68
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* NOTE: Does not include the brand symbol to avoid TS4053 declaration portability issues.
|
|
85
|
-
* Use Type.isObjectSchema() for runtime type guards.
|
|
69
|
+
* Type that represents any ECHO object type — a `Type.Type` entity branded
|
|
70
|
+
* with the object entity kind, i.e. what `Type.makeObject(dxn)` produces.
|
|
86
71
|
*/
|
|
87
|
-
type
|
|
88
|
-
readonly typename: string;
|
|
89
|
-
readonly version: string;
|
|
90
|
-
};
|
|
91
|
-
export declare namespace Obj {
|
|
92
|
-
/**
|
|
93
|
-
* Type that represents any ECHO object schema.
|
|
94
|
-
* Accepts both static schemas (Type.object()) and mutable schemas (EchoSchema).
|
|
95
|
-
*/
|
|
96
|
-
type Any = ObjectSchemaBase;
|
|
97
|
-
}
|
|
72
|
+
export type AnyObj = Obj<unknown>;
|
|
98
73
|
/**
|
|
99
|
-
* Factory function to create an ECHO object
|
|
100
|
-
*
|
|
74
|
+
* Factory function to create an ECHO object type.
|
|
75
|
+
*
|
|
76
|
+
* Returns a `Type.Type` entity — a live, in-memory `TypeSchema` instance,
|
|
77
|
+
* NOT a `Schema.Schema`. Use `Type.InstanceType<typeof Foo>` for the instance
|
|
78
|
+
* type and `Type.getSchema(Foo)` to obtain the underlying Effect Schema.
|
|
101
79
|
*
|
|
102
80
|
* @example
|
|
103
81
|
* ```ts
|
|
104
82
|
* const Person = Schema.Struct({
|
|
105
83
|
* name: Schema.String,
|
|
106
|
-
* }).pipe(Type.
|
|
84
|
+
* }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
107
85
|
* ```
|
|
108
86
|
*/
|
|
109
|
-
export declare const
|
|
110
|
-
(
|
|
87
|
+
export declare const makeObject: {
|
|
88
|
+
(dxn: DXN.DXN): <Self extends Schema.Schema.Any>(self: Self) => Obj<Schema.Schema.Type<Self>>;
|
|
111
89
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
90
|
+
/**
|
|
91
|
+
* ECHO meta-schema entity — stores `{ name?, typename, version, jsonSchema }`.
|
|
92
|
+
* Type-kind sibling of `Type.makeObject(...)` / `Type.makeRelation(...)` outputs.
|
|
93
|
+
* Stored types live under this entity; filter via `Filter.type(Type.Type)`.
|
|
94
|
+
*/
|
|
95
|
+
export declare const Type: Type<typeInternal.TypeSchema>;
|
|
96
|
+
/**
|
|
97
|
+
* Common props shared by the type-kind factories. Typename and version are
|
|
98
|
+
* optional — drafts omit typename and default version to {@link DRAFT_VERSION}.
|
|
99
|
+
*/
|
|
100
|
+
type MakeTypeProps = {
|
|
101
|
+
jsonSchema: internal.JsonSchemaType;
|
|
102
|
+
typename?: string;
|
|
103
|
+
version?: string;
|
|
104
|
+
name?: string;
|
|
105
|
+
id?: ObjectId;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Construct a new object-kind type entity from raw metadata — for cases where
|
|
109
|
+
* an Effect Schema isn't available (e.g. JSON-Schema arriving over the network
|
|
110
|
+
* or from a UI editor). Parallel to {@link makeObject} but takes pre-built
|
|
111
|
+
* `jsonSchema` instead of piping through an Effect schema.
|
|
128
112
|
*
|
|
129
|
-
*
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
113
|
+
* The returned entity is in-memory; persist it with `db.add(entity)`.
|
|
114
|
+
*/
|
|
115
|
+
export declare const makeObjectFromJsonSchema: (props: MakeTypeProps) => Type<typeInternal.TypeSchema>;
|
|
116
|
+
/**
|
|
117
|
+
* Construct a new relation-kind type entity from raw metadata. Parallel to
|
|
118
|
+
* {@link makeRelation} but takes pre-built `jsonSchema` instead of piping
|
|
119
|
+
* through an Effect schema. `source` / `target` accept either a static
|
|
120
|
+
* `Type.Obj` entity or the well-known `Obj.Unknown` schema.
|
|
133
121
|
*
|
|
134
|
-
*
|
|
135
|
-
* if (Relation.isRelation(unknownValue)) { ... }
|
|
136
|
-
* ```
|
|
122
|
+
* The returned entity is in-memory; persist it with `db.add(entity)`.
|
|
137
123
|
*/
|
|
138
|
-
export declare const
|
|
124
|
+
export declare const makeRelationFromJsonSchema: (props: MakeTypeProps & {
|
|
125
|
+
source: AnyObj | internal.UnknownTypeSchema<any, typeof EntityModule.Kind.Object>;
|
|
126
|
+
target: AnyObj | internal.UnknownTypeSchema<any, typeof EntityModule.Kind.Object>;
|
|
127
|
+
}) => Type<typeInternal.TypeSchema>;
|
|
139
128
|
/**
|
|
140
|
-
* TypeScript type for an ECHO relation
|
|
141
|
-
*
|
|
142
|
-
* `
|
|
143
|
-
* `
|
|
129
|
+
* TypeScript type for an ECHO relation type — a `Type.Type<A>` entity.
|
|
130
|
+
*
|
|
131
|
+
* `T` is the instance-property type produced by `Relation.make(...)` (excluding
|
|
132
|
+
* source/target endpoints). `Source` and `Target` are the endpoint types.
|
|
133
|
+
*
|
|
134
|
+
* **Not a `Schema.Schema`.** See {@link Obj}'s note.
|
|
144
135
|
*/
|
|
145
|
-
export interface Relation<T
|
|
136
|
+
export interface Relation<T, Source, Target, Fields extends Schema.Struct.Fields = Schema.Struct.Fields> extends BaseTypeEntity<RelationModule.Endpoints<Source, Target> & T & EntityModule.OfKind<typeof EntityModule.Kind.Relation>> {
|
|
137
|
+
/** Schema-kind brand (relation). */
|
|
138
|
+
readonly [internal.SchemaKindId]: internal.EntityKind.Relation;
|
|
139
|
+
/** Source Effect Schema — used internally by `Type.getSchema(self)`. */
|
|
140
|
+
readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
146
141
|
/**
|
|
147
142
|
* The fields defined in the original struct schema.
|
|
148
143
|
* Allows accessing field definitions for introspection.
|
|
@@ -150,34 +145,10 @@ export interface Relation<T = any, Source = any, Target = any, Fields extends Sc
|
|
|
150
145
|
readonly fields: Fields;
|
|
151
146
|
}
|
|
152
147
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* NOTE: Does not include the brand symbol to avoid TS4053 declaration portability issues.
|
|
156
|
-
* Use Type.isRelationSchema() for runtime type guards.
|
|
148
|
+
* Type that represents any ECHO relation type — a `Type.Type` entity branded
|
|
149
|
+
* with the relation entity kind, i.e. what `Type.makeRelation(...)` produces.
|
|
157
150
|
*/
|
|
158
|
-
type
|
|
159
|
-
readonly typename: string;
|
|
160
|
-
readonly version: string;
|
|
161
|
-
};
|
|
162
|
-
export declare namespace Relation {
|
|
163
|
-
/**
|
|
164
|
-
* Type that represents any ECHO relation schema.
|
|
165
|
-
* Accepts static schemas (Type.relation()).
|
|
166
|
-
*/
|
|
167
|
-
type Any = RelationSchemaBase;
|
|
168
|
-
/**
|
|
169
|
-
* Get relation source type.
|
|
170
|
-
*/
|
|
171
|
-
type Source<A> = A extends Relation.Endpoints<infer S, infer _T> ? S : never;
|
|
172
|
-
/**
|
|
173
|
-
* Get relation target type.
|
|
174
|
-
*/
|
|
175
|
-
type Target<A> = A extends Relation.Endpoints<infer _S, infer T> ? T : never;
|
|
176
|
-
type Endpoints<Source, Target> = {
|
|
177
|
-
[Relation$.Source]: Source;
|
|
178
|
-
[Relation$.Target]: Target;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
151
|
+
export type AnyRelation = Relation<unknown, unknown, unknown>;
|
|
181
152
|
/**
|
|
182
153
|
* Factory function to create an ECHO relation schema.
|
|
183
154
|
* Adds relation metadata annotations to an Effect schema.
|
|
@@ -186,120 +157,268 @@ export declare namespace Relation {
|
|
|
186
157
|
* ```ts
|
|
187
158
|
* const WorksFor = Schema.Struct({
|
|
188
159
|
* role: Schema.String,
|
|
189
|
-
* }).pipe(Type.
|
|
190
|
-
*
|
|
191
|
-
* version: '0.1.0',
|
|
160
|
+
* }).pipe(Type.makeRelation({
|
|
161
|
+
* dxn: DXN.make('com.example.type.worksFor', '0.1.0'),
|
|
192
162
|
* source: Person,
|
|
193
163
|
* target: Company,
|
|
194
164
|
* }));
|
|
195
165
|
* ```
|
|
196
166
|
*/
|
|
197
|
-
export declare const
|
|
198
|
-
<
|
|
167
|
+
export declare const makeRelation: {
|
|
168
|
+
<SourceInstance, TargetInstance>(opts: {
|
|
169
|
+
dxn: DXN.DXN;
|
|
170
|
+
source: Obj<SourceInstance, any> | internal.UnknownTypeSchema<SourceInstance, typeof EntityModule.Kind.Object>;
|
|
171
|
+
target: Obj<TargetInstance, any> | internal.UnknownTypeSchema<TargetInstance, typeof EntityModule.Kind.Object>;
|
|
172
|
+
}): <Self extends Schema.Schema.Any>(self: Self) => Relation<Schema.Schema.Type<Self>, SourceInstance & EntityModule.OfKind<typeof EntityModule.Kind.Object>, TargetInstance & EntityModule.OfKind<typeof EntityModule.Kind.Object>>;
|
|
199
173
|
};
|
|
200
|
-
export declare namespace Entity {
|
|
201
|
-
/**
|
|
202
|
-
* Runtime Effect schema for any ECHO entity (object or relation).
|
|
203
|
-
* Use for validation, parsing, or type guards on unknown values.
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* ```ts
|
|
207
|
-
* if (Schema.is(Type.Entity.Any)(unknownValue)) {
|
|
208
|
-
* // unknownValue is an ECHO entity
|
|
209
|
-
* }
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
const Any: Schema.Schema<{
|
|
213
|
-
id: ObjectId;
|
|
214
|
-
} & Record<string, unknown>, {
|
|
215
|
-
id: string;
|
|
216
|
-
} & Record<string, unknown>>;
|
|
217
|
-
/**
|
|
218
|
-
* Type alias for any ECHO entity schema (object or relation).
|
|
219
|
-
* Use this in type annotations for schema parameters.
|
|
220
|
-
*/
|
|
221
|
-
type Any = Obj.Any | Relation.Any;
|
|
222
|
-
}
|
|
223
174
|
/**
|
|
224
|
-
* Type
|
|
225
|
-
*
|
|
175
|
+
* Type that represents any ECHO type-kind entity — a `Type.Type` meta-schema
|
|
176
|
+
* value (static `Type.Type` or a persisted draft from `db.add(...)`).
|
|
177
|
+
* Mirrors {@link AnyObj} / {@link AnyRelation} for the third sibling kind.
|
|
178
|
+
*/
|
|
179
|
+
export type AnyType = Type<unknown>;
|
|
180
|
+
/**
|
|
181
|
+
* Any ECHO type-entity — one of the three sibling kinds: object-kind, relation-kind,
|
|
182
|
+
* or type-kind (the meta-schema). APIs that want "any ECHO type" use this union;
|
|
183
|
+
* the underlying Effect Schema is retrieved via `Type.getSchema`.
|
|
226
184
|
*/
|
|
227
|
-
export
|
|
185
|
+
export type AnyEntity = AnyObj | AnyRelation | AnyType;
|
|
228
186
|
/**
|
|
229
|
-
* Type guard
|
|
230
|
-
*
|
|
187
|
+
* Type guard: narrows a `Type.AnyEntity` to an object-kind entity. Checks
|
|
188
|
+
* ENTITIES, not instances — use `Obj.isObject` for instances. Raw
|
|
189
|
+
* `Schema.Schema` values (including the branded `Obj.Unknown` companion)
|
|
190
|
+
* are intentionally not accepted; inspect their `TypeAnnotation` directly.
|
|
231
191
|
*/
|
|
232
|
-
export declare const
|
|
192
|
+
export declare const isObject: (entity: AnyEntity) => entity is AnyObj;
|
|
233
193
|
/**
|
|
234
|
-
*
|
|
194
|
+
* Type guard: narrows a `Type.AnyEntity` to a relation-kind entity. Checks
|
|
195
|
+
* ENTITIES, not instances — use `Relation.isRelation` for instances.
|
|
196
|
+
*/
|
|
197
|
+
export declare const isRelation: (entity: AnyEntity) => entity is AnyRelation;
|
|
198
|
+
/**
|
|
199
|
+
* Type guard: narrows a `Type.AnyEntity` to the type-kind meta-schema
|
|
200
|
+
* (e.g. `Type.Type`). Mirrors {@link isObject} / {@link isRelation}.
|
|
201
|
+
*/
|
|
202
|
+
export declare const isTypeKindSchema: (entity: AnyEntity) => entity is Type;
|
|
203
|
+
/**
|
|
204
|
+
* Narrow a `Type.AnyEntity` (e.g. one returned from `schemaRegistry.query(...)`)
|
|
205
|
+
* to `AnyObj`, throwing if it describes a relation or the type-kind
|
|
206
|
+
* meta-schema. Use at call sites that need to pass the value to `Obj.make`,
|
|
207
|
+
* `Filter.type`, or other object-only APIs.
|
|
208
|
+
*/
|
|
209
|
+
export declare const assertObject: (entity: AnyEntity) => AnyObj;
|
|
210
|
+
/** Narrow a `Type.AnyEntity` to `AnyRelation`, throwing otherwise. */
|
|
211
|
+
export declare const expectRelation: (entity: AnyEntity) => AnyRelation;
|
|
212
|
+
/** Narrow a `Type.AnyEntity` to the `Type.Type` meta-schema, throwing otherwise. */
|
|
213
|
+
export declare const expectTypeKind: (entity: AnyEntity) => Type;
|
|
214
|
+
/**
|
|
215
|
+
* Type that represents any Ref schema (with unknown target type).
|
|
216
|
+
* This is a schema type, not an instance type.
|
|
217
|
+
*/
|
|
218
|
+
export type AnyRef = Schema.Schema<internal.Ref<any>, EncodedReference>;
|
|
219
|
+
/**
|
|
220
|
+
* Returns the URI identifying a type entity. Always defined.
|
|
221
|
+
*
|
|
222
|
+
* - Static `Type.Obj` / `Type.Relation` → typename DXN (e.g. `dxn:com.example.type.person:0.1.0`).
|
|
223
|
+
* - Persisted `Type.Type` instance (has `id`) → local `EchoURI` (`echo:/<objectId>`).
|
|
224
|
+
* - In-memory `Type.Type` draft (has `id`, no typename) → local `EchoURI`.
|
|
235
225
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
226
|
+
* Only accepts `Type.AnyEntity` entities. Raw `Schema.Schema` values and the
|
|
227
|
+
* branded `Obj.Unknown` / `Relation.Unknown` schemas are intentionally not
|
|
228
|
+
* supported — use `internal.getSchemaURI` or the schema's typename annotation
|
|
229
|
+
* directly when working at the schema level.
|
|
238
230
|
*/
|
|
239
|
-
export
|
|
240
|
-
}
|
|
231
|
+
export declare const getURI: (input: AnyEntity) => URI.URI;
|
|
241
232
|
/**
|
|
242
|
-
*
|
|
243
|
-
* Use this in schema definitions to declare reference fields.
|
|
233
|
+
* @returns The typename. Example: `com.example.type.person`.
|
|
244
234
|
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
|
|
250
|
-
|
|
235
|
+
* Persisted `Type.Type` entities carry typename in `ObjectMeta.key` (the
|
|
236
|
+
* canonical registry-provenance field); unnamed drafts fall back to the
|
|
237
|
+
* entity's object id so the helper always returns a string. Any `dxn:` or
|
|
238
|
+
* `echo:/` prefix is stripped — typename is a bare identifier, not a URI.
|
|
239
|
+
*/
|
|
240
|
+
export declare const getTypename: (input: AnyEntity) => string;
|
|
241
|
+
/**
|
|
242
|
+
* Gets the version.
|
|
243
|
+
* @example 0.1.0
|
|
244
|
+
* @example 0.1.0-<heads> (in-database, versioned by automerge heads)
|
|
245
|
+
*
|
|
246
|
+
* The registry-provenance semver lives in `ObjectMeta.version`; unversioned
|
|
247
|
+
* drafts default to {@link DRAFT_VERSION} (`'0.0.0'`). In-database entities are
|
|
248
|
+
* additionally versioned by their automerge heads, which are exposed as the
|
|
249
|
+
* semver pre-release tag (`<semver>-<heads>`). In-memory declarations have no
|
|
250
|
+
* heads and surface the bare semver. Read the registry semver alone via
|
|
251
|
+
* `Type.getMeta(input).version`.
|
|
251
252
|
*/
|
|
252
|
-
export declare const
|
|
253
|
+
export declare const getVersion: (input: AnyEntity) => string;
|
|
253
254
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
255
|
+
* Type predicate: true iff the value is any type-kind ECHO entity — a static
|
|
256
|
+
* `Type.Obj` / `Type.Relation` produced by `Type.makeObject` / `Type.makeRelation`, a
|
|
257
|
+
* static meta `Type.Type`, or a persisted `Type.Type` returned by the database.
|
|
257
258
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
259
|
+
* All three branches stamp `[KindId] = Type`, so this is a single brand check.
|
|
260
|
+
* Use {@link isObject} / {@link isRelation} / {@link isTypeKindSchema}
|
|
261
|
+
* when you need to discriminate further; use {@link getDatabase} when you mean
|
|
262
|
+
* "is this a db-attached type" (vs. an in-memory declaration).
|
|
263
|
+
*/
|
|
264
|
+
export declare const isType: (value: unknown) => value is AnyEntity;
|
|
265
|
+
/**
|
|
266
|
+
* Get the database the type entity belongs to, or `undefined` if it is an
|
|
267
|
+
* in-memory declaration (`Type.makeObject` / `Type.makeRelation` result) not
|
|
268
|
+
* yet attached to a database. Mirrors `Obj.getDatabase` / `Relation.getDatabase`.
|
|
262
269
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
270
|
+
* Database attachment is the canonical discriminator between in-memory and
|
|
271
|
+
* in-database type entities — both are live reactive `TypeSchema` instances and
|
|
272
|
+
* are otherwise indistinguishable.
|
|
266
273
|
*/
|
|
267
|
-
export
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
export declare const getDatabase: (input: AnyEntity) => Database.Database | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* Mutable meta type returned by `Type.getMeta` inside a `Type.update` callback.
|
|
277
|
+
* Mirrors `Obj.Meta` / `Relation.Meta` — `Type.Type` is an Entity like its
|
|
278
|
+
* siblings, so its meta is the same `ObjectMeta` record:
|
|
279
|
+
* `{ keys, tags?, key?, version? }`.
|
|
280
|
+
*
|
|
281
|
+
* `key` / `version` here are the canonical registry-provenance pair
|
|
282
|
+
* (typename + semver) on persisted Type.Type entities; they are absent on
|
|
283
|
+
* unnamed drafts. Use {@link getTypename} / {@link getVersion} when you want
|
|
284
|
+
* a non-`undefined` value with id / {@link DRAFT_VERSION} fallbacks.
|
|
285
|
+
*/
|
|
286
|
+
export type Meta = internal.Meta;
|
|
287
|
+
/**
|
|
288
|
+
* Deeply read-only version of {@link Meta}.
|
|
289
|
+
* Prevents mutation at all nesting levels (e.g., `meta.keys.push()` is a TS error).
|
|
290
|
+
*/
|
|
291
|
+
export type ReadonlyMeta = internal.ReadonlyMeta;
|
|
292
|
+
/**
|
|
293
|
+
* Returns the entity's `ObjectMeta`. Same semantics as `Obj.getMeta` /
|
|
294
|
+
* `Relation.getMeta` — `Type.Type` is an Entity and carries the canonical
|
|
295
|
+
* `ObjectMeta` directly. Returns mutable meta when passed a mutable type
|
|
296
|
+
* (inside a `Type.update` callback), read-only meta otherwise.
|
|
297
|
+
*
|
|
298
|
+
* For persisted Type entities, `meta.key` holds the typename and
|
|
299
|
+
* `meta.version` holds the semver. Use {@link getTypename} / {@link getVersion}
|
|
300
|
+
* if you want the helpers' id / {@link DRAFT_VERSION} fallbacks for drafts.
|
|
301
|
+
*
|
|
302
|
+
* Both persisted and in-memory type entities (`Type.makeObject` /
|
|
303
|
+
* `Type.makeRelation` results) carry their `ObjectMeta` via `[MetaId]`, so the
|
|
304
|
+
* lookup is uniform.
|
|
305
|
+
*/
|
|
306
|
+
export declare function getMeta(entity: internal.Mutable<AnyEntity>): Meta;
|
|
307
|
+
export declare function getMeta(entity: Mutable): Meta;
|
|
308
|
+
export declare function getMeta(entity: AnyEntity): ReadonlyMeta;
|
|
309
|
+
/**
|
|
310
|
+
* String key used to phantom-carry the instance type produced by a `Type.Type`.
|
|
311
|
+
* Used by `Type.InstanceType<typeof Foo>` to recover the schema instance type
|
|
312
|
+
* since `Type.makeObject(dxn)` does not return a `Schema.Schema`.
|
|
313
|
+
*
|
|
314
|
+
* Re-exported from the internal types layer so both `Type.ts` and internal
|
|
315
|
+
* helpers (`makeObject`, `createObject`) reference the same phantom key.
|
|
316
|
+
*/
|
|
317
|
+
export declare const InstancePhantomId: "~@dxos/echo/Type.Instance";
|
|
318
|
+
export type InstancePhantomId = internal.InstancePhantomId;
|
|
319
|
+
/**
|
|
320
|
+
* Sibling of {@link Obj} / {@link Relation} for the third ECHO entity kind:
|
|
321
|
+
* **type-kind** entities (meta-schemas). The singleton {@link Type} const is
|
|
322
|
+
* the canonical example — it describes stored type definitions themselves.
|
|
323
|
+
*
|
|
324
|
+
* Not a `Schema.Schema`. Use `Type.getSchema(value)` to obtain the underlying
|
|
325
|
+
* Effect Schema and `Type.update(value, draft => ...)` to mutate.
|
|
326
|
+
*
|
|
327
|
+
* `A` is the instance-type phantom — what `Obj.make(value, ...)` would produce.
|
|
328
|
+
* Merged with the `Type` const value via TypeScript declaration merging.
|
|
329
|
+
*/
|
|
330
|
+
export interface Type<A = unknown> extends BaseTypeEntity<A & EntityModule.OfKind<typeof EntityModule.Kind.Type>> {
|
|
331
|
+
/** Schema-kind brand (type — the meta-schema kind). */
|
|
332
|
+
readonly [internal.SchemaKindId]: internal.EntityKind.Type;
|
|
333
|
+
/** Source Effect Schema — used internally by `Type.getSchema(self)`. */
|
|
334
|
+
readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
275
335
|
}
|
|
276
336
|
/**
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* @
|
|
280
|
-
*
|
|
337
|
+
* Instance type produced by a Type entity.
|
|
338
|
+
*
|
|
339
|
+
* Accepts ONLY {@link AnyEntity} inputs — `Type.Obj`, `Type.Relation`, or
|
|
340
|
+
* `Type.Type`. Raw Effect `Schema.Schema` values are rejected: for those, use
|
|
341
|
+
* `Schema.Schema.Type<typeof Foo>` directly. This separation keeps the type
|
|
342
|
+
* system honest about which values represent ECHO entities versus plain
|
|
343
|
+
* Effect schemas.
|
|
344
|
+
*
|
|
345
|
+
* Dispatches on the entity kind:
|
|
346
|
+
* - `Relation<Props, S, T>` → `Endpoints<S,T> & Props & OfKind<Relation>`
|
|
347
|
+
* - `Obj<A>` → `A & OfKind<Object>`
|
|
348
|
+
* - `Type<A>` → `A & OfKind<Type>`
|
|
281
349
|
*/
|
|
282
|
-
export
|
|
350
|
+
export type InstanceType<T extends AnyEntity> = T extends Relation<infer Props, infer Source, infer Target, any> ? RelationModule.Endpoints<Source, Target> & Props & EntityModule.OfKind<typeof EntityModule.Kind.Relation> : T extends Obj<infer A, any> ? A & EntityModule.OfKind<typeof EntityModule.Kind.Object> : T extends Type<infer A> ? A & EntityModule.OfKind<typeof EntityModule.Kind.Type> : never;
|
|
283
351
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
352
|
+
* Returns the Effect Schema for a type entity.
|
|
353
|
+
*
|
|
354
|
+
* - For static `Type.Obj` / `Type.Relation` entities the source Effect Schema is
|
|
355
|
+
* read from a hidden slot — these overloads preserve the instance type.
|
|
356
|
+
* - For `Type.Type` entities (the meta-schema kind) the schema is rebuilt from
|
|
357
|
+
* `type.jsonSchema`; the instance type isn't statically knowable so the wide
|
|
358
|
+
* `AnyEntity` overload widens to `Schema.Schema.AnyNoContext`.
|
|
359
|
+
*
|
|
360
|
+
* Always call this when you need to interact with the Effect Schema API
|
|
361
|
+
* (e.g. before passing to Effect.Schema functions). For ECHO-side APIs
|
|
362
|
+
* (`Obj.make`, `Filter.type`, `Ref`) pass the type entity directly.
|
|
363
|
+
*
|
|
364
|
+
* Only accepts `Type.AnyEntity` — raw `Schema.Schema` values can be used
|
|
365
|
+
* directly without unwrapping.
|
|
286
366
|
*/
|
|
287
|
-
export declare
|
|
367
|
+
export declare function getSchema<T extends AnyObj>(type: T): Schema.Schema<InstanceType<T>>;
|
|
368
|
+
export declare function getSchema<T extends AnyRelation>(type: T): Schema.Schema<InstanceType<T>>;
|
|
369
|
+
export declare function getSchema(type: AnyEntity): Schema.Schema.AnyNoContext;
|
|
288
370
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
371
|
+
* Mutable view of a `Type.Type` — the shape passed to the `Type.update` callback.
|
|
372
|
+
* Outside `Type.update`, `Type.Type` fields are read-only (both at the type level
|
|
373
|
+
* and at runtime — direct assignment throws). Use this to constrain mutation to
|
|
374
|
+
* the change context, analogous to `Obj.update(obj, (draft) => ...)`.
|
|
375
|
+
*
|
|
376
|
+
* NOTE: `typename` and `version` are intentionally absent — they live in
|
|
377
|
+
* `ObjectMeta` (`key` / `version` — the canonical registry-provenance pair).
|
|
378
|
+
* Read them via {@link getTypename} / {@link getVersion} / {@link getMeta};
|
|
379
|
+
* `typename` is treated as immutable on persisted entities.
|
|
380
|
+
*
|
|
381
|
+
* Unlike `Obj.update` — whose mutable view is inferred as `Mutable<A>` over the
|
|
382
|
+
* whole instance type because every data field is editable — a `Type.Type`
|
|
383
|
+
* exposes only `name` and `jsonSchema` for mutation. The rest of its shape
|
|
384
|
+
* (`id`, the `[KindId]` / `[SchemaKindId]` brands, and `typename` / `version`
|
|
385
|
+
* in meta) is immutable, so this view is declared explicitly rather than
|
|
386
|
+
* derived from `InstanceType<Type.Type>`.
|
|
387
|
+
*/
|
|
388
|
+
export interface Mutable {
|
|
389
|
+
name?: string;
|
|
390
|
+
jsonSchema: Types.DeepMutable<internal.JsonSchemaType>;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Perform mutations on a `Type.Type` within a change context.
|
|
394
|
+
*
|
|
395
|
+
* The callback receives a {@link Mutable} view of the type — direct mutation of
|
|
396
|
+
* a `Type.Type` outside `Type.update` throws at runtime, mirroring `Obj.update`.
|
|
397
|
+
* Delegates to the same automerge-transaction primitive `Obj.update(obj, cb)` uses.
|
|
398
|
+
*/
|
|
399
|
+
export declare const update: (type: AnyEntity, callback: (mutable: Mutable) => void) => void;
|
|
400
|
+
/**
|
|
401
|
+
* Add fields to a persisted type's schema.
|
|
402
|
+
* @throws if the type is not persisted.
|
|
291
403
|
*/
|
|
292
|
-
export declare const
|
|
404
|
+
export declare const addFields: (type: AnyEntity, fields: Schema.Struct.Fields) => void;
|
|
293
405
|
/**
|
|
294
|
-
*
|
|
406
|
+
* Replace existing fields on a persisted type's schema.
|
|
407
|
+
* @throws if the type is not persisted.
|
|
295
408
|
*/
|
|
296
|
-
export declare const
|
|
409
|
+
export declare const updateFields: (type: AnyEntity, fields: Schema.Struct.Fields) => void;
|
|
297
410
|
/**
|
|
298
|
-
*
|
|
411
|
+
* Rename a field on a persisted type's schema.
|
|
412
|
+
* @throws if the type is not persisted.
|
|
299
413
|
*/
|
|
300
|
-
export type
|
|
414
|
+
export declare const updateFieldPropertyName: (type: Type, { before, after }: {
|
|
415
|
+
before: PropertyKey;
|
|
416
|
+
after: PropertyKey;
|
|
417
|
+
}) => void;
|
|
301
418
|
/**
|
|
302
|
-
*
|
|
419
|
+
* Remove fields from a persisted type's schema.
|
|
420
|
+
* @throws if the type is not persisted.
|
|
303
421
|
*/
|
|
304
|
-
export declare const
|
|
422
|
+
export declare const removeFields: (type: AnyEntity, fieldNames: string[]) => void;
|
|
423
|
+
export {};
|
|
305
424
|
//# sourceMappingURL=Type.d.ts.map
|