@dxos/echo 0.8.4-main.ead640a → 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 +10 -11
- package/dist/lib/neutral/Annotation.mjs +39 -0
- package/dist/lib/neutral/Database.mjs +49 -0
- package/dist/lib/neutral/Entity.mjs +68 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Feed.mjs +54 -0
- package/dist/lib/neutral/Filter.mjs +74 -0
- package/dist/lib/neutral/Filter.mjs.map +7 -0
- package/dist/lib/neutral/Format.mjs +86 -0
- package/dist/lib/neutral/Format.mjs.map +7 -0
- package/dist/lib/neutral/JsonSchema.mjs +19 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +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 +114 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +12 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +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 +26 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +95 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/SchemaRegistry.mjs +2 -0
- package/dist/lib/neutral/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +29 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +63 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4SYHDOQA.mjs +48 -0
- package/dist/lib/neutral/chunk-4SYHDOQA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4U7OD55H.mjs +47 -0
- 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-A5HDDVKS.mjs +94 -0
- package/dist/lib/neutral/chunk-A5HDDVKS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-EZ4XJFHJ.mjs +54 -0
- package/dist/lib/neutral/chunk-EZ4XJFHJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-F625JEZB.mjs +365 -0
- 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-GOHDOJE3.mjs +51 -0
- 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-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.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-JTHNDGAR.mjs +27 -0
- 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-KHRAQDYX.mjs +343 -0
- 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-O2EOH7XQ.mjs +420 -0
- package/dist/lib/neutral/chunk-O2EOH7XQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Q7ID37KF.mjs +278 -0
- 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-TTCSATUD.mjs +42 -0
- package/dist/lib/neutral/chunk-TTCSATUD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UEFRFUYC.mjs +25 -0
- 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-V5NE2X7Y.mjs +7 -0
- package/dist/lib/neutral/chunk-V5NE2X7Y.mjs.map +7 -0
- package/dist/lib/neutral/chunk-V72DY6LU.mjs +7 -0
- package/dist/lib/neutral/chunk-V72DY6LU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZII2BGPM.mjs +269 -0
- package/dist/lib/neutral/chunk-ZII2BGPM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZM7VFIS2.mjs +93 -0
- package/dist/lib/neutral/chunk-ZM7VFIS2.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 +513 -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 +418 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +24 -0
- package/dist/types/src/Annotation.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 +201 -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 +236 -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/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 +183 -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 +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +65 -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 +459 -107
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +225 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +69 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +316 -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/SchemaRegistry.d.ts +83 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +18 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +378 -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 +22 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +251 -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/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts +24 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/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 +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/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 +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 +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 +6 -3
- 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/{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 +131 -30
- 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/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} +13 -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 +10 -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.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 +4 -4
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +79 -31
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.d.ts +7 -0
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/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 +42 -0
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/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 +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 +43 -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 +58 -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/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 +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- 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 +117 -66
- package/src/Annotation.ts +49 -0
- package/src/Collection.ts +36 -0
- package/src/Database.ts +356 -0
- package/src/Dataset.ts +34 -0
- package/src/Entity.test.ts +132 -0
- package/src/Entity.ts +332 -0
- package/src/Err.ts +40 -0
- 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 +507 -0
- package/src/Format.ts +9 -0
- package/src/Hypergraph.ts +79 -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 +550 -0
- package/src/Obj.ts +754 -267
- package/src/Order.ts +46 -0
- package/src/Query.test.ts +822 -0
- package/src/Query.ts +589 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +98 -10
- package/src/Relation.test.ts +88 -0
- package/src/Relation.ts +491 -67
- package/src/SchemaRegistry.ts +101 -0
- package/src/{query/tag.ts → Tag.ts} +15 -12
- package/src/Type.test.ts +197 -0
- package/src/Type.ts +605 -151
- package/src/View.ts +101 -0
- package/src/exemplars.test.ts +21 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +23 -6
- package/src/internal/Annotation/annotations.test.ts +165 -0
- package/src/internal/Annotation/annotations.ts +567 -0
- package/src/internal/Annotation/index.ts +7 -0
- package/src/internal/Annotation/sorting.ts +51 -0
- package/src/internal/Annotation/util.ts +93 -0
- package/src/internal/Entity/api.ts +30 -0
- package/src/internal/Entity/entity.ts +246 -0
- package/src/internal/Entity/index.ts +13 -0
- package/src/internal/Entity/model.ts +120 -0
- package/src/internal/Entity/object.ts +65 -0
- 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/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 +6 -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 +4 -4
- 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 +36 -36
- package/src/internal/{json → JsonSchema}/json-schema.test.ts +92 -175
- package/src/internal/{json → JsonSchema}/json-schema.ts +69 -37
- package/src/internal/Obj/clone.ts +52 -0
- package/src/internal/{object → Obj}/common.ts +3 -4
- package/src/internal/{object/create.test.ts → Obj/create-object.test.ts} +34 -37
- package/src/internal/Obj/create-object.ts +135 -0
- package/src/internal/Obj/deleted.ts +19 -0
- package/src/internal/Obj/index.ts +13 -0
- package/src/internal/{object → Obj}/inspect.ts +5 -7
- package/src/internal/Obj/json-serializer.test.ts +185 -0
- package/src/internal/Obj/json-serializer.ts +260 -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 +165 -0
- package/src/internal/Obj/snapshot.ts +111 -0
- package/src/internal/Obj/typed-object.test.ts +32 -0
- package/src/internal/Obj/typed-object.ts +30 -0
- package/src/internal/Query.ts +156 -0
- package/src/internal/{ref → Ref}/ref-array.ts +4 -5
- package/src/internal/{ref → Ref}/ref.test.ts +21 -30
- package/src/internal/{ref → Ref}/ref.ts +209 -98
- 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 +88 -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 +519 -0
- package/src/internal/common/proxy/define-hidden-property.ts +14 -0
- package/src/internal/common/proxy/errors.ts +42 -0
- package/src/internal/common/proxy/event-batch.ts +44 -0
- package/src/internal/common/proxy/handler.test.ts +121 -0
- package/src/internal/common/proxy/index.ts +17 -0
- package/src/internal/common/proxy/json-serializer.ts +93 -0
- package/src/internal/common/proxy/make-object.ts +128 -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 +507 -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 +10 -0
- package/src/internal/common/types/meta.ts +79 -0
- package/src/internal/common/types/model-symbols.ts +74 -0
- package/src/internal/common/types/typename.ts +91 -0
- package/src/internal/common/types/version.ts +19 -0
- package/src/internal/index.ts +12 -17
- package/src/testing/api.test.ts +129 -0
- package/src/testing/index.ts +3 -3
- 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-HKFCK2GL.mjs +0 -175
- package/dist/lib/browser/chunk-HKFCK2GL.mjs.map +0 -7
- package/dist/lib/browser/chunk-MAAYELT7.mjs +0 -830
- package/dist/lib/browser/chunk-MAAYELT7.mjs.map +0 -7
- package/dist/lib/browser/chunk-MB6MMNFP.mjs +0 -3857
- package/dist/lib/browser/chunk-MB6MMNFP.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -35
- package/dist/lib/browser/internal/index.mjs +0 -332
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/query/index.mjs +0 -15
- package/dist/lib/browser/testing/index.mjs +0 -298
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5NWDGIBT.mjs +0 -830
- package/dist/lib/node-esm/chunk-5NWDGIBT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AUAH4E2J.mjs +0 -175
- package/dist/lib/node-esm/chunk-AUAH4E2J.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BQRA4VLX.mjs +0 -3857
- package/dist/lib/node-esm/chunk-BQRA4VLX.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -35
- package/dist/lib/node-esm/internal/index.mjs +0 -332
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/query/index.mjs +0 -15
- package/dist/lib/node-esm/testing/index.mjs +0 -298
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/errors.d.ts +0 -72
- 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 -125
- 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.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 -455
- 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 -3
- 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/query/tag.d.ts +0 -17
- package/dist/types/src/query/tag.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 -113
- 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 -219
- 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/json/index.ts +0 -5
- package/src/internal/object/accessors.ts +0 -153
- 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/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 -211
- 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 -91
- /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/Extension.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Feed.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/{formats → Format}/object.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/Type.ts
CHANGED
|
@@ -2,244 +2,698 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
// @import-as-namespace
|
|
6
6
|
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
import type * as Types from 'effect/Types';
|
|
9
|
+
|
|
10
|
+
import { raise } from '@dxos/debug';
|
|
7
11
|
import { type EncodedReference } from '@dxos/echo-protocol';
|
|
8
12
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import type
|
|
13
|
+
import { DXN, EchoURI, type ObjectId, type URI } from '@dxos/keys';
|
|
10
14
|
|
|
11
|
-
import
|
|
12
|
-
import * as
|
|
15
|
+
import type * as Database from './Database';
|
|
16
|
+
import type * as EntityModule from './Entity';
|
|
17
|
+
import * as internal from './internal';
|
|
18
|
+
import * as typeInternal from './internal/Type';
|
|
13
19
|
import type * as RelationModule from './Relation';
|
|
14
20
|
|
|
15
21
|
//
|
|
16
|
-
//
|
|
22
|
+
// Internal types (not exported)
|
|
17
23
|
//
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Structural base shared by the three sibling type-entity interfaces
|
|
27
|
+
* ({@link Obj}, {@link Relation}, {@link Type}). NOT exported — callers
|
|
28
|
+
* should constrain on {@link AnyEntity} when they want "any of the three"
|
|
29
|
+
* and on the specific kind interface otherwise.
|
|
30
|
+
*/
|
|
31
|
+
interface BaseTypeEntity<A> {
|
|
32
|
+
/**
|
|
33
|
+
* Entity-kind brand of the type-entity value itself — always `EntityKind.Type`.
|
|
34
|
+
* The kind of instance the type *describes* lives on `[SchemaKindId]`
|
|
35
|
+
* (Object / Relation / Type). Lets `Obj.isObject` / `Relation.isRelation`
|
|
36
|
+
* reject type entities by a single `[KindId]` check.
|
|
37
|
+
*/
|
|
38
|
+
readonly [internal.KindId]: internal.EntityKind.Type;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Object id. Like all ECHO entities, type entities always carry an id —
|
|
42
|
+
* stamped at construction for in-memory (static) declarations and assigned by
|
|
43
|
+
* the database once persisted. The id does NOT determine the entity's URI:
|
|
44
|
+
* static types resolve to their typename DXN, persisted types to `echo:/<id>`
|
|
45
|
+
* (see `getTypeURIFromSpecifier`).
|
|
46
|
+
*/
|
|
47
|
+
readonly id: ObjectId;
|
|
48
|
+
|
|
49
|
+
readonly name?: string;
|
|
50
|
+
// NOTE: `typename` / `version` are intentionally NOT fields on any type-entity
|
|
51
|
+
// interface. Both static and persisted entities carry them in `ObjectMeta`
|
|
52
|
+
// (`key` / `version`); read them via `Type.getTypename(self)` /
|
|
53
|
+
// `Type.getVersion(self)` — never as a direct property.
|
|
54
|
+
readonly jsonSchema: internal.JsonSchemaType;
|
|
55
|
+
readonly [InstancePhantomId]?: A;
|
|
56
|
+
}
|
|
21
57
|
|
|
22
|
-
|
|
58
|
+
//
|
|
59
|
+
// Obj — `Type.Type` value for an ECHO object schema.
|
|
60
|
+
//
|
|
23
61
|
|
|
24
62
|
/**
|
|
25
|
-
*
|
|
63
|
+
* TypeScript type for an ECHO object type — a `Type.Type<A>` entity.
|
|
64
|
+
*
|
|
65
|
+
* `T` is the instance type produced by `Obj.make(Foo, props)`. `Fields` is
|
|
66
|
+
* retained as a structural hint (the runtime value still carries `.fields`),
|
|
67
|
+
* but consumers should derive instance/encoded types via `Type.InstanceType`.
|
|
68
|
+
*
|
|
69
|
+
* **Not a `Schema.Schema`.** `Foo.ast` / `Schema.Schema.Type<typeof Foo>` /
|
|
70
|
+
* `Schema.extend(Foo)` no longer typecheck — extract the Effect Schema via
|
|
71
|
+
* `Type.getSchema(Foo)` first, or derive instance types via
|
|
72
|
+
* `Type.InstanceType<typeof Foo>`.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const Person = Schema.Struct({
|
|
77
|
+
* name: Schema.String,
|
|
78
|
+
* }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
79
|
+
*
|
|
80
|
+
* type Person = Type.InstanceType<typeof Person>;
|
|
81
|
+
* ```
|
|
26
82
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
83
|
+
export interface Obj<T, Fields extends Schema.Struct.Fields = Schema.Struct.Fields> extends BaseTypeEntity<
|
|
84
|
+
T & EntityModule.OfKind<typeof EntityModule.Kind.Object>
|
|
85
|
+
> {
|
|
86
|
+
/** Schema-kind brand (object). */
|
|
87
|
+
readonly [internal.SchemaKindId]: internal.EntityKind.Object;
|
|
88
|
+
|
|
89
|
+
/** Source Effect Schema — used internally by `Type.getSchema(self)`. */
|
|
90
|
+
readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The fields defined in the original struct schema.
|
|
94
|
+
* Allows accessing field definitions for introspection.
|
|
95
|
+
*/
|
|
96
|
+
readonly fields: Fields;
|
|
31
97
|
}
|
|
32
98
|
|
|
33
99
|
/**
|
|
34
|
-
*
|
|
100
|
+
* Type that represents any ECHO object type — a `Type.Type` entity branded
|
|
101
|
+
* with the object entity kind, i.e. what `Type.makeObject(dxn)` produces.
|
|
35
102
|
*/
|
|
36
|
-
export type
|
|
103
|
+
export type AnyObj = Obj<unknown>;
|
|
37
104
|
|
|
38
105
|
/**
|
|
39
|
-
*
|
|
106
|
+
* Factory function to create an ECHO object type.
|
|
107
|
+
*
|
|
108
|
+
* Returns a `Type.Type` entity — a live, in-memory `TypeSchema` instance,
|
|
109
|
+
* NOT a `Schema.Schema`. Use `Type.InstanceType<typeof Foo>` for the instance
|
|
110
|
+
* type and `Type.getSchema(Foo)` to obtain the underlying Effect Schema.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const Person = Schema.Struct({
|
|
115
|
+
* name: Schema.String,
|
|
116
|
+
* }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
117
|
+
* ```
|
|
40
118
|
*/
|
|
41
|
-
export
|
|
119
|
+
export const makeObject: {
|
|
120
|
+
(dxn: DXN.DXN): <Self extends Schema.Schema.Any>(self: Self) => Obj<Schema.Schema.Type<Self>>;
|
|
121
|
+
} = internal.EchoObjectSchema as any;
|
|
42
122
|
|
|
43
123
|
//
|
|
44
|
-
//
|
|
124
|
+
// Type — the ECHO entity that holds a schema and metadata.
|
|
125
|
+
// Persisted via `db.add()`; subscribed to via `Filter.type(Type.Type)`.
|
|
45
126
|
//
|
|
46
127
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
128
|
+
/**
|
|
129
|
+
* ECHO meta-schema entity — stores `{ name?, typename, version, jsonSchema }`.
|
|
130
|
+
* Type-kind sibling of `Type.makeObject(...)` / `Type.makeRelation(...)` outputs.
|
|
131
|
+
* Stored types live under this entity; filter via `Filter.type(Type.Type)`.
|
|
132
|
+
*/
|
|
133
|
+
export const Type: Type<typeInternal.TypeSchema> = typeInternal.TypeSchema as any;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Default version stamped on draft (unnamed) types created via
|
|
137
|
+
* {@link makeObjectFromJsonSchema} / {@link makeRelationFromJsonSchema} when
|
|
138
|
+
* the caller does not supply one. Pure dynamic drafts surface as `'0.0.0'`
|
|
139
|
+
* until they are persisted, at which point automerge-heads suffix the version.
|
|
140
|
+
*/
|
|
141
|
+
const DRAFT_VERSION = '0.0.0';
|
|
50
142
|
|
|
51
143
|
/**
|
|
52
|
-
*
|
|
144
|
+
* Common props shared by the type-kind factories. Typename and version are
|
|
145
|
+
* optional — drafts omit typename and default version to {@link DRAFT_VERSION}.
|
|
146
|
+
*/
|
|
147
|
+
type MakeTypeProps = {
|
|
148
|
+
jsonSchema: internal.JsonSchemaType;
|
|
149
|
+
typename?: string;
|
|
150
|
+
version?: string;
|
|
151
|
+
name?: string;
|
|
152
|
+
id?: ObjectId;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Construct a new object-kind type entity from raw metadata — for cases where
|
|
157
|
+
* an Effect Schema isn't available (e.g. JSON-Schema arriving over the network
|
|
158
|
+
* or from a UI editor). Parallel to {@link makeObject} but takes pre-built
|
|
159
|
+
* `jsonSchema` instead of piping through an Effect schema.
|
|
53
160
|
*
|
|
54
|
-
*
|
|
55
|
-
* See Effect's note on interface types.
|
|
161
|
+
* The returned entity is in-memory; persist it with `db.add(entity)`.
|
|
56
162
|
*/
|
|
57
|
-
export
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
163
|
+
export const makeObjectFromJsonSchema = (props: MakeTypeProps): Type<typeInternal.TypeSchema> => {
|
|
164
|
+
const { typename, version, ...data } = props;
|
|
165
|
+
// `typename` / `version` are routed through `ObjectMeta` (`key` / `version`)
|
|
166
|
+
// — the canonical registry-provenance pair — not data fields. Drafts default
|
|
167
|
+
// to `'0.0.0'`; the version is omitted from meta entirely when the caller
|
|
168
|
+
// doesn't supply one so the proxy projection can apply its own default.
|
|
169
|
+
return internal.makeObject(
|
|
170
|
+
internal.getStaticTypeSchema(typeInternal.TypeSchema) as any,
|
|
171
|
+
data as any,
|
|
172
|
+
{
|
|
173
|
+
keys: [],
|
|
174
|
+
key: typename,
|
|
175
|
+
version: version ?? DRAFT_VERSION,
|
|
176
|
+
},
|
|
177
|
+
typeInternal.TypeSchema,
|
|
178
|
+
) as unknown as Type<typeInternal.TypeSchema>;
|
|
179
|
+
};
|
|
65
180
|
|
|
66
181
|
/**
|
|
67
|
-
*
|
|
182
|
+
* Construct a new relation-kind type entity from raw metadata. Parallel to
|
|
183
|
+
* {@link makeRelation} but takes pre-built `jsonSchema` instead of piping
|
|
184
|
+
* through an Effect schema. `source` / `target` accept either a static
|
|
185
|
+
* `Type.Obj` entity or the well-known `Obj.Unknown` schema.
|
|
186
|
+
*
|
|
187
|
+
* The returned entity is in-memory; persist it with `db.add(entity)`.
|
|
68
188
|
*/
|
|
69
|
-
export const
|
|
70
|
-
|
|
71
|
-
|
|
189
|
+
export const makeRelationFromJsonSchema = (
|
|
190
|
+
props: MakeTypeProps & {
|
|
191
|
+
source: AnyObj | internal.UnknownTypeSchema<any, typeof EntityModule.Kind.Object>;
|
|
192
|
+
target: AnyObj | internal.UnknownTypeSchema<any, typeof EntityModule.Kind.Object>;
|
|
193
|
+
},
|
|
194
|
+
): Type<typeInternal.TypeSchema> => {
|
|
195
|
+
const { source, target, jsonSchema, typename, version, ...rest } = props;
|
|
196
|
+
// Embed source/target DXNs + relation entity-kind into the jsonSchema so the
|
|
197
|
+
// entity round-trips correctly through `toEffectSchema` / queries / refs.
|
|
198
|
+
const sourceURI = internal.getTypeURIFromSpecifier(source);
|
|
199
|
+
const targetURI = internal.getTypeURIFromSpecifier(target);
|
|
200
|
+
const enrichedJsonSchema: internal.JsonSchemaType = {
|
|
201
|
+
...jsonSchema,
|
|
202
|
+
entityKind: internal.EntityKind.Relation,
|
|
203
|
+
relationSource: { $ref: sourceURI },
|
|
204
|
+
relationTarget: { $ref: targetURI },
|
|
205
|
+
};
|
|
206
|
+
// `typename` / `version` route through `ObjectMeta` (see
|
|
207
|
+
// {@link makeObjectFromJsonSchema}); drafts default version to `'0.0.0'`.
|
|
208
|
+
return internal.makeObject(
|
|
209
|
+
internal.getStaticTypeSchema(typeInternal.TypeSchema) as any,
|
|
210
|
+
{ ...rest, jsonSchema: enrichedJsonSchema } as any,
|
|
211
|
+
{
|
|
212
|
+
keys: [],
|
|
213
|
+
key: typename,
|
|
214
|
+
version: version ?? DRAFT_VERSION,
|
|
215
|
+
},
|
|
216
|
+
typeInternal.TypeSchema,
|
|
217
|
+
) as unknown as Type<typeInternal.TypeSchema>;
|
|
218
|
+
};
|
|
72
219
|
|
|
73
220
|
/**
|
|
74
|
-
*
|
|
221
|
+
* TypeScript type for an ECHO relation type — a `Type.Type<A>` entity.
|
|
222
|
+
*
|
|
223
|
+
* `T` is the instance-property type produced by `Relation.make(...)` (excluding
|
|
224
|
+
* source/target endpoints). `Source` and `Target` are the endpoint types.
|
|
225
|
+
*
|
|
226
|
+
* **Not a `Schema.Schema`.** See {@link Obj}'s note.
|
|
75
227
|
*/
|
|
76
|
-
export
|
|
228
|
+
export interface Relation<
|
|
229
|
+
T,
|
|
230
|
+
Source,
|
|
231
|
+
Target,
|
|
232
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
233
|
+
> extends BaseTypeEntity<
|
|
234
|
+
RelationModule.Endpoints<Source, Target> & T & EntityModule.OfKind<typeof EntityModule.Kind.Relation>
|
|
235
|
+
> {
|
|
236
|
+
/** Schema-kind brand (relation). */
|
|
237
|
+
readonly [internal.SchemaKindId]: internal.EntityKind.Relation;
|
|
238
|
+
|
|
239
|
+
/** Source Effect Schema — used internally by `Type.getSchema(self)`. */
|
|
240
|
+
readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
241
|
+
|
|
77
242
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
243
|
+
* The fields defined in the original struct schema.
|
|
244
|
+
* Allows accessing field definitions for introspection.
|
|
80
245
|
*/
|
|
81
|
-
|
|
82
|
-
// TODO(burdon): This erases the ECHO type info (e.g., id, typename).
|
|
83
|
-
export type Any = EffectSchema.Schema.AnyNoContext;
|
|
246
|
+
readonly fields: Fields;
|
|
84
247
|
}
|
|
85
248
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Type that represents any ECHO relation type — a `Type.Type` entity branded
|
|
251
|
+
* with the relation entity kind, i.e. what `Type.makeRelation(...)` produces.
|
|
252
|
+
*/
|
|
253
|
+
export type AnyRelation = Relation<unknown, unknown, unknown>;
|
|
89
254
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Factory function to create an ECHO relation schema.
|
|
257
|
+
* Adds relation metadata annotations to an Effect schema.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* const WorksFor = Schema.Struct({
|
|
262
|
+
* role: Schema.String,
|
|
263
|
+
* }).pipe(Type.makeRelation({
|
|
264
|
+
* dxn: DXN.make('com.example.type.worksFor', '0.1.0'),
|
|
265
|
+
* source: Person,
|
|
266
|
+
* target: Company,
|
|
267
|
+
* }));
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export const makeRelation: {
|
|
271
|
+
<SourceInstance, TargetInstance>(opts: {
|
|
272
|
+
dxn: DXN.DXN;
|
|
273
|
+
source: Obj<SourceInstance, any> | internal.UnknownTypeSchema<SourceInstance, typeof EntityModule.Kind.Object>;
|
|
274
|
+
target: Obj<TargetInstance, any> | internal.UnknownTypeSchema<TargetInstance, typeof EntityModule.Kind.Object>;
|
|
275
|
+
}): <Self extends Schema.Schema.Any>(
|
|
276
|
+
self: Self,
|
|
277
|
+
) => Relation<
|
|
278
|
+
Schema.Schema.Type<Self>,
|
|
279
|
+
SourceInstance & EntityModule.OfKind<typeof EntityModule.Kind.Object>,
|
|
280
|
+
TargetInstance & EntityModule.OfKind<typeof EntityModule.Kind.Object>
|
|
281
|
+
>;
|
|
282
|
+
} = internal.EchoRelationSchema as any;
|
|
94
283
|
|
|
95
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Type that represents any ECHO type-kind entity — a `Type.Type` meta-schema
|
|
286
|
+
* value (static `Type.Type` or a persisted draft from `db.add(...)`).
|
|
287
|
+
* Mirrors {@link AnyObj} / {@link AnyRelation} for the third sibling kind.
|
|
288
|
+
*/
|
|
289
|
+
export type AnyType = Type<unknown>;
|
|
96
290
|
|
|
97
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Any ECHO type-entity — one of the three sibling kinds: object-kind, relation-kind,
|
|
293
|
+
* or type-kind (the meta-schema). APIs that want "any ECHO type" use this union;
|
|
294
|
+
* the underlying Effect Schema is retrieved via `Type.getSchema`.
|
|
295
|
+
*/
|
|
296
|
+
export type AnyEntity = AnyObj | AnyRelation | AnyType;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Type guard: narrows a `Type.AnyEntity` to an object-kind entity. Checks
|
|
300
|
+
* ENTITIES, not instances — use `Obj.isObject` for instances. Raw
|
|
301
|
+
* `Schema.Schema` values (including the branded `Obj.Unknown` companion)
|
|
302
|
+
* are intentionally not accepted; inspect their `TypeAnnotation` directly.
|
|
303
|
+
*/
|
|
304
|
+
export const isObject = (entity: AnyEntity): entity is AnyObj => {
|
|
305
|
+
return internal.getSchemaKind(entity) === internal.EntityKind.Object;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Type guard: narrows a `Type.AnyEntity` to a relation-kind entity. Checks
|
|
310
|
+
* ENTITIES, not instances — use `Relation.isRelation` for instances.
|
|
311
|
+
*/
|
|
312
|
+
export const isRelation = (entity: AnyEntity): entity is AnyRelation => {
|
|
313
|
+
return internal.getSchemaKind(entity) === internal.EntityKind.Relation;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Type guard: narrows a `Type.AnyEntity` to the type-kind meta-schema
|
|
318
|
+
* (e.g. `Type.Type`). Mirrors {@link isObject} / {@link isRelation}.
|
|
319
|
+
*/
|
|
320
|
+
export const isTypeKindSchema = (entity: AnyEntity): entity is Type => {
|
|
321
|
+
return internal.getSchemaKind(entity) === internal.EntityKind.Type;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Narrow a `Type.AnyEntity` (e.g. one returned from `schemaRegistry.query(...)`)
|
|
326
|
+
* to `AnyObj`, throwing if it describes a relation or the type-kind
|
|
327
|
+
* meta-schema. Use at call sites that need to pass the value to `Obj.make`,
|
|
328
|
+
* `Filter.type`, or other object-only APIs.
|
|
329
|
+
*/
|
|
330
|
+
export const assertObject = (entity: AnyEntity): AnyObj => {
|
|
331
|
+
invariant(isObject(entity), 'Expected an object-kind Type entity.');
|
|
332
|
+
return entity;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/** Narrow a `Type.AnyEntity` to `AnyRelation`, throwing otherwise. */
|
|
336
|
+
export const expectRelation = (entity: AnyEntity): AnyRelation => {
|
|
337
|
+
invariant(isRelation(entity), 'Expected a relation-kind Type entity.');
|
|
338
|
+
return entity;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/** Narrow a `Type.AnyEntity` to the `Type.Type` meta-schema, throwing otherwise. */
|
|
342
|
+
export const expectTypeKind = (entity: AnyEntity): Type => {
|
|
343
|
+
invariant(isTypeKindSchema(entity), 'Expected a type-kind Type entity.');
|
|
344
|
+
return entity;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Type that represents any Ref schema (with unknown target type).
|
|
349
|
+
* This is a schema type, not an instance type.
|
|
350
|
+
*/
|
|
351
|
+
export type AnyRef = Schema.Schema<internal.Ref<any>, EncodedReference>;
|
|
98
352
|
|
|
99
353
|
//
|
|
100
|
-
//
|
|
354
|
+
// Schema utility functions
|
|
101
355
|
//
|
|
102
356
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
357
|
+
/**
|
|
358
|
+
* Returns the URI identifying a type entity. Always defined.
|
|
359
|
+
*
|
|
360
|
+
* - Static `Type.Obj` / `Type.Relation` → typename DXN (e.g. `dxn:com.example.type.person:0.1.0`).
|
|
361
|
+
* - Persisted `Type.Type` instance (has `id`) → local `EchoURI` (`echo:/<objectId>`).
|
|
362
|
+
* - In-memory `Type.Type` draft (has `id`, no typename) → local `EchoURI`.
|
|
363
|
+
*
|
|
364
|
+
* Only accepts `Type.AnyEntity` entities. Raw `Schema.Schema` values and the
|
|
365
|
+
* branded `Obj.Unknown` / `Relation.Unknown` schemas are intentionally not
|
|
366
|
+
* supported — use `internal.getSchemaURI` or the schema's typename annotation
|
|
367
|
+
* directly when working at the schema level.
|
|
368
|
+
*/
|
|
369
|
+
export const getURI = (input: AnyEntity): URI.URI => {
|
|
370
|
+
// For Type entities, route through `getTypeURIFromSpecifier` (id → EchoURI,
|
|
371
|
+
// typename/version → DXN). For Obj/Relation entities, unwrap to the source
|
|
372
|
+
// Effect Schema first and read its annotations.
|
|
373
|
+
if (isType(input)) {
|
|
374
|
+
return internal.getTypeURIFromSpecifier(input);
|
|
375
|
+
}
|
|
376
|
+
return internal.getSchemaURI(getSchema(input)) ?? raise(new TypeError('Type entity has no URI'));
|
|
377
|
+
};
|
|
108
378
|
|
|
109
379
|
/**
|
|
110
|
-
*
|
|
380
|
+
* @returns The typename. Example: `com.example.type.person`.
|
|
111
381
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
382
|
+
* Persisted `Type.Type` entities carry typename in `ObjectMeta.key` (the
|
|
383
|
+
* canonical registry-provenance field); unnamed drafts fall back to the
|
|
384
|
+
* entity's object id so the helper always returns a string. Any `dxn:` or
|
|
385
|
+
* `echo:/` prefix is stripped — typename is a bare identifier, not a URI.
|
|
114
386
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
387
|
+
// TODO(wittjosiah): For in-database types this should return the object id once the registry
|
|
388
|
+
// has more robust options for shadowing types (so callers can disambiguate db-stored copies).
|
|
389
|
+
export const getTypename = (input: AnyEntity): string => {
|
|
390
|
+
// Both in-memory and in-database entities carry typename in `ObjectMeta.key`
|
|
391
|
+
// — the canonical registry-provenance field. In-memory entities attach meta
|
|
392
|
+
// eagerly (see `makeEchoTypeSchema`), so a single meta-backed read covers
|
|
393
|
+
// both forms. Unnamed drafts fall back to the entity id.
|
|
394
|
+
const meta = internal.getMetaChecked(input);
|
|
395
|
+
let typename: string = (meta.key as string | undefined) ?? (input.id as string);
|
|
396
|
+
// Typename is a bare identifier — strip URI prefixes if a caller seeded
|
|
397
|
+
// meta.key with one accidentally (or if a static entity carries a DXN-
|
|
398
|
+
// style typename).
|
|
399
|
+
typename = stripTypenamePrefix(typename);
|
|
400
|
+
invariant(typeof typename === 'string' && typename.length > 0, 'Invalid typename');
|
|
401
|
+
return typename;
|
|
402
|
+
};
|
|
128
403
|
|
|
129
404
|
/**
|
|
130
|
-
*
|
|
405
|
+
* Gets the version.
|
|
406
|
+
* @example 0.1.0
|
|
407
|
+
* @example 0.1.0-<heads> (in-database, versioned by automerge heads)
|
|
408
|
+
*
|
|
409
|
+
* The registry-provenance semver lives in `ObjectMeta.version`; unversioned
|
|
410
|
+
* drafts default to {@link DRAFT_VERSION} (`'0.0.0'`). In-database entities are
|
|
411
|
+
* additionally versioned by their automerge heads, which are exposed as the
|
|
412
|
+
* semver pre-release tag (`<semver>-<heads>`). In-memory declarations have no
|
|
413
|
+
* heads and surface the bare semver. Read the registry semver alone via
|
|
414
|
+
* `Type.getMeta(input).version`.
|
|
131
415
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
416
|
+
export const getVersion = (input: AnyEntity): string => {
|
|
417
|
+
const meta = internal.getMetaChecked(input);
|
|
418
|
+
const semver = (meta.version as string | undefined) ?? DRAFT_VERSION;
|
|
419
|
+
invariant(typeof semver === 'string' && semver.match(/^\d+\.\d+\.\d+$/), 'Invalid version');
|
|
420
|
+
// In-database entities are versioned by their automerge heads; expose them as
|
|
421
|
+
// the semver pre-release tag. In-memory drafts carry no heads → bare semver.
|
|
422
|
+
const heads = internal.version(input).automergeHeads;
|
|
423
|
+
if (heads != null && heads.length > 0) {
|
|
424
|
+
return `${semver}-${[...heads].sort().join('.')}`;
|
|
425
|
+
}
|
|
426
|
+
return semver;
|
|
427
|
+
};
|
|
138
428
|
|
|
139
429
|
/**
|
|
140
|
-
*
|
|
430
|
+
* Strip URI prefixes (`dxn:`, `echo:/`, `echo://`) from a typename string.
|
|
431
|
+
* Typename is a bare identifier — callers reading from meta or from a
|
|
432
|
+
* caller-supplied seed value shouldn't propagate URI prefixes downstream.
|
|
141
433
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
434
|
+
const stripTypenamePrefix = (value: string): string => {
|
|
435
|
+
if (value.startsWith('dxn:')) {
|
|
436
|
+
return value.slice('dxn:'.length);
|
|
437
|
+
}
|
|
438
|
+
if (value.startsWith('echo://')) {
|
|
439
|
+
return value.slice('echo://'.length);
|
|
440
|
+
}
|
|
441
|
+
if (value.startsWith('echo:/')) {
|
|
442
|
+
return value.slice('echo:/'.length);
|
|
443
|
+
}
|
|
444
|
+
return value;
|
|
445
|
+
};
|
|
149
446
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
447
|
+
/**
|
|
448
|
+
* Type predicate: true iff the value is any type-kind ECHO entity — a static
|
|
449
|
+
* `Type.Obj` / `Type.Relation` produced by `Type.makeObject` / `Type.makeRelation`, a
|
|
450
|
+
* static meta `Type.Type`, or a persisted `Type.Type` returned by the database.
|
|
451
|
+
*
|
|
452
|
+
* All three branches stamp `[KindId] = Type`, so this is a single brand check.
|
|
453
|
+
* Use {@link isObject} / {@link isRelation} / {@link isTypeKindSchema}
|
|
454
|
+
* when you need to discriminate further; use {@link getDatabase} when you mean
|
|
455
|
+
* "is this a db-attached type" (vs. an in-memory declaration).
|
|
456
|
+
*/
|
|
457
|
+
export const isType = (value: unknown): value is AnyEntity =>
|
|
458
|
+
internal.getEntityKindBrand(value) === internal.EntityKind.Type;
|
|
154
459
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Get the database the type entity belongs to, or `undefined` if it is an
|
|
462
|
+
* in-memory declaration (`Type.makeObject` / `Type.makeRelation` result) not
|
|
463
|
+
* yet attached to a database. Mirrors `Obj.getDatabase` / `Relation.getDatabase`.
|
|
464
|
+
*
|
|
465
|
+
* Database attachment is the canonical discriminator between in-memory and
|
|
466
|
+
* in-database type entities — both are live reactive `TypeSchema` instances and
|
|
467
|
+
* are otherwise indistinguishable.
|
|
468
|
+
*/
|
|
469
|
+
export const getDatabase = (input: AnyEntity): Database.Database | undefined => internal.getDatabase(input);
|
|
159
470
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
471
|
+
/**
|
|
472
|
+
* Mutable meta type returned by `Type.getMeta` inside a `Type.update` callback.
|
|
473
|
+
* Mirrors `Obj.Meta` / `Relation.Meta` — `Type.Type` is an Entity like its
|
|
474
|
+
* siblings, so its meta is the same `ObjectMeta` record:
|
|
475
|
+
* `{ keys, tags?, key?, version? }`.
|
|
476
|
+
*
|
|
477
|
+
* `key` / `version` here are the canonical registry-provenance pair
|
|
478
|
+
* (typename + semver) on persisted Type.Type entities; they are absent on
|
|
479
|
+
* unnamed drafts. Use {@link getTypename} / {@link getVersion} when you want
|
|
480
|
+
* a non-`undefined` value with id / {@link DRAFT_VERSION} fallbacks.
|
|
481
|
+
*/
|
|
482
|
+
export type Meta = internal.Meta;
|
|
165
483
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
484
|
+
/**
|
|
485
|
+
* Deeply read-only version of {@link Meta}.
|
|
486
|
+
* Prevents mutation at all nesting levels (e.g., `meta.keys.push()` is a TS error).
|
|
487
|
+
*/
|
|
488
|
+
export type ReadonlyMeta = internal.ReadonlyMeta;
|
|
169
489
|
|
|
170
490
|
/**
|
|
171
|
-
*
|
|
491
|
+
* Returns the entity's `ObjectMeta`. Same semantics as `Obj.getMeta` /
|
|
492
|
+
* `Relation.getMeta` — `Type.Type` is an Entity and carries the canonical
|
|
493
|
+
* `ObjectMeta` directly. Returns mutable meta when passed a mutable type
|
|
494
|
+
* (inside a `Type.update` callback), read-only meta otherwise.
|
|
172
495
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
496
|
+
* For persisted Type entities, `meta.key` holds the typename and
|
|
497
|
+
* `meta.version` holds the semver. Use {@link getTypename} / {@link getVersion}
|
|
498
|
+
* if you want the helpers' id / {@link DRAFT_VERSION} fallbacks for drafts.
|
|
499
|
+
*
|
|
500
|
+
* Both persisted and in-memory type entities (`Type.makeObject` /
|
|
501
|
+
* `Type.makeRelation` results) carry their `ObjectMeta` via `[MetaId]`, so the
|
|
502
|
+
* lookup is uniform.
|
|
175
503
|
*/
|
|
176
|
-
export
|
|
177
|
-
|
|
504
|
+
export function getMeta(entity: internal.Mutable<AnyEntity>): Meta;
|
|
505
|
+
export function getMeta(entity: Mutable): Meta;
|
|
506
|
+
export function getMeta(entity: AnyEntity): ReadonlyMeta;
|
|
507
|
+
export function getMeta(entity: AnyEntity | internal.Mutable<AnyEntity> | Mutable): ReadonlyMeta | Meta {
|
|
508
|
+
// The `Mutable` overload accepts the narrowed view passed to `Type.update`
|
|
509
|
+
// callbacks; at runtime that draft IS the underlying persisted Type entity,
|
|
510
|
+
// so the same `MetaId` lookup works.
|
|
511
|
+
invariant(isType(entity), 'Expected a Type entity.');
|
|
512
|
+
// Both persisted and in-memory type entities carry runtime `ObjectMeta` via
|
|
513
|
+
// `[MetaId]`, so the lookup is uniform.
|
|
514
|
+
return internal.getMetaChecked(entity);
|
|
515
|
+
}
|
|
178
516
|
|
|
179
517
|
/**
|
|
180
|
-
*
|
|
518
|
+
* String key used to phantom-carry the instance type produced by a `Type.Type`.
|
|
519
|
+
* Used by `Type.InstanceType<typeof Foo>` to recover the schema instance type
|
|
520
|
+
* since `Type.makeObject(dxn)` does not return a `Schema.Schema`.
|
|
521
|
+
*
|
|
522
|
+
* Re-exported from the internal types layer so both `Type.ts` and internal
|
|
523
|
+
* helpers (`makeObject`, `createObject`) reference the same phantom key.
|
|
181
524
|
*/
|
|
182
|
-
export const
|
|
525
|
+
export const InstancePhantomId = internal.InstancePhantomId;
|
|
526
|
+
export type InstancePhantomId = internal.InstancePhantomId;
|
|
183
527
|
|
|
184
|
-
|
|
528
|
+
/**
|
|
529
|
+
* Sibling of {@link Obj} / {@link Relation} for the third ECHO entity kind:
|
|
530
|
+
* **type-kind** entities (meta-schemas). The singleton {@link Type} const is
|
|
531
|
+
* the canonical example — it describes stored type definitions themselves.
|
|
532
|
+
*
|
|
533
|
+
* Not a `Schema.Schema`. Use `Type.getSchema(value)` to obtain the underlying
|
|
534
|
+
* Effect Schema and `Type.update(value, draft => ...)` to mutate.
|
|
535
|
+
*
|
|
536
|
+
* `A` is the instance-type phantom — what `Obj.make(value, ...)` would produce.
|
|
537
|
+
* Merged with the `Type` const value via TypeScript declaration merging.
|
|
538
|
+
*/
|
|
539
|
+
export interface Type<A = unknown> extends BaseTypeEntity<A & EntityModule.OfKind<typeof EntityModule.Kind.Type>> {
|
|
540
|
+
/** Schema-kind brand (type — the meta-schema kind). */
|
|
541
|
+
readonly [internal.SchemaKindId]: internal.EntityKind.Type;
|
|
185
542
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Type that represents an arbitrary schema type of a reference.
|
|
190
|
-
* NOTE: This is not an instance type.
|
|
191
|
-
*/
|
|
192
|
-
export type Any = EffectSchema.Schema<EchoSchema.Ref<any>, EncodedReference>;
|
|
543
|
+
/** Source Effect Schema — used internally by `Type.getSchema(self)`. */
|
|
544
|
+
readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
193
545
|
}
|
|
194
546
|
|
|
195
547
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* @
|
|
199
|
-
*
|
|
548
|
+
* Instance type produced by a Type entity.
|
|
549
|
+
*
|
|
550
|
+
* Accepts ONLY {@link AnyEntity} inputs — `Type.Obj`, `Type.Relation`, or
|
|
551
|
+
* `Type.Type`. Raw Effect `Schema.Schema` values are rejected: for those, use
|
|
552
|
+
* `Schema.Schema.Type<typeof Foo>` directly. This separation keeps the type
|
|
553
|
+
* system honest about which values represent ECHO entities versus plain
|
|
554
|
+
* Effect schemas.
|
|
555
|
+
*
|
|
556
|
+
* Dispatches on the entity kind:
|
|
557
|
+
* - `Relation<Props, S, T>` → `Endpoints<S,T> & Props & OfKind<Relation>`
|
|
558
|
+
* - `Obj<A>` → `A & OfKind<Object>`
|
|
559
|
+
* - `Type<A>` → `A & OfKind<Type>`
|
|
200
560
|
*/
|
|
201
|
-
export
|
|
202
|
-
|
|
203
|
-
|
|
561
|
+
export type InstanceType<T extends AnyEntity> =
|
|
562
|
+
T extends Relation<infer Props, infer Source, infer Target, any>
|
|
563
|
+
? RelationModule.Endpoints<Source, Target> & Props & EntityModule.OfKind<typeof EntityModule.Kind.Relation>
|
|
564
|
+
: T extends Obj<infer A, any>
|
|
565
|
+
? A & EntityModule.OfKind<typeof EntityModule.Kind.Object>
|
|
566
|
+
: T extends Type<infer A>
|
|
567
|
+
? A & EntityModule.OfKind<typeof EntityModule.Kind.Type>
|
|
568
|
+
: never;
|
|
204
569
|
|
|
205
570
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
571
|
+
* Returns the Effect Schema for a type entity.
|
|
572
|
+
*
|
|
573
|
+
* - For static `Type.Obj` / `Type.Relation` entities the source Effect Schema is
|
|
574
|
+
* read from a hidden slot — these overloads preserve the instance type.
|
|
575
|
+
* - For `Type.Type` entities (the meta-schema kind) the schema is rebuilt from
|
|
576
|
+
* `type.jsonSchema`; the instance type isn't statically knowable so the wide
|
|
577
|
+
* `AnyEntity` overload widens to `Schema.Schema.AnyNoContext`.
|
|
578
|
+
*
|
|
579
|
+
* Always call this when you need to interact with the Effect Schema API
|
|
580
|
+
* (e.g. before passing to Effect.Schema functions). For ECHO-side APIs
|
|
581
|
+
* (`Obj.make`, `Filter.type`, `Ref`) pass the type entity directly.
|
|
582
|
+
*
|
|
583
|
+
* Only accepts `Type.AnyEntity` — raw `Schema.Schema` values can be used
|
|
584
|
+
* directly without unwrapping.
|
|
208
585
|
*/
|
|
209
|
-
export
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
586
|
+
export function getSchema<T extends AnyObj>(type: T): Schema.Schema<InstanceType<T>>;
|
|
587
|
+
export function getSchema<T extends AnyRelation>(type: T): Schema.Schema<InstanceType<T>>;
|
|
588
|
+
export function getSchema(type: AnyEntity): Schema.Schema.AnyNoContext;
|
|
589
|
+
export function getSchema(type: AnyEntity): Schema.Schema.AnyNoContext {
|
|
590
|
+
// Static `Type.Type` entities carry the source Effect Schema on a hidden
|
|
591
|
+
// slot so we can return it without round-tripping through JsonSchema.
|
|
592
|
+
const staticSchema = internal.getStaticTypeSchema(type);
|
|
593
|
+
if (staticSchema != null) {
|
|
594
|
+
return staticSchema;
|
|
595
|
+
}
|
|
596
|
+
invariant(isType(type), 'Expected a Type entity.');
|
|
597
|
+
// Persisted `Type.Type` entity — build the Effect Schema from its stored
|
|
598
|
+
// jsonSchema and re-attach the TypeIdentifierAnnotation so the rebuilt
|
|
599
|
+
// schema's URI (via getSchemaURI) matches the entity's local EchoURI.
|
|
600
|
+
const rebuilt = internal.toEffectSchema(type.jsonSchema);
|
|
601
|
+
if (typeof type.id === 'string') {
|
|
602
|
+
return rebuilt.annotations({
|
|
603
|
+
[internal.TypeIdentifierAnnotationId]: EchoURI.make({ objectId: type.id }),
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
return rebuilt;
|
|
607
|
+
}
|
|
214
608
|
|
|
215
609
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
610
|
+
* Mutable view of a `Type.Type` — the shape passed to the `Type.update` callback.
|
|
611
|
+
* Outside `Type.update`, `Type.Type` fields are read-only (both at the type level
|
|
612
|
+
* and at runtime — direct assignment throws). Use this to constrain mutation to
|
|
613
|
+
* the change context, analogous to `Obj.update(obj, (draft) => ...)`.
|
|
614
|
+
*
|
|
615
|
+
* NOTE: `typename` and `version` are intentionally absent — they live in
|
|
616
|
+
* `ObjectMeta` (`key` / `version` — the canonical registry-provenance pair).
|
|
617
|
+
* Read them via {@link getTypename} / {@link getVersion} / {@link getMeta};
|
|
618
|
+
* `typename` is treated as immutable on persisted entities.
|
|
619
|
+
*
|
|
620
|
+
* Unlike `Obj.update` — whose mutable view is inferred as `Mutable<A>` over the
|
|
621
|
+
* whole instance type because every data field is editable — a `Type.Type`
|
|
622
|
+
* exposes only `name` and `jsonSchema` for mutation. The rest of its shape
|
|
623
|
+
* (`id`, the `[KindId]` / `[SchemaKindId]` brands, and `typename` / `version`
|
|
624
|
+
* in meta) is immutable, so this view is declared explicitly rather than
|
|
625
|
+
* derived from `InstanceType<Type.Type>`.
|
|
218
626
|
*/
|
|
219
|
-
export
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
627
|
+
export interface Mutable {
|
|
628
|
+
name?: string;
|
|
629
|
+
// Deep-mutable within the change context — `Type.update`'s purpose is to allow
|
|
630
|
+
// mutation, so the draft exposes `jsonSchema` as writable (the readonly
|
|
631
|
+
// `JsonSchemaType` would force callers to cast).
|
|
632
|
+
jsonSchema: Types.DeepMutable<internal.JsonSchemaType>;
|
|
633
|
+
}
|
|
224
634
|
|
|
225
635
|
/**
|
|
226
|
-
*
|
|
636
|
+
* Perform mutations on a `Type.Type` within a change context.
|
|
637
|
+
*
|
|
638
|
+
* The callback receives a {@link Mutable} view of the type — direct mutation of
|
|
639
|
+
* a `Type.Type` outside `Type.update` throws at runtime, mirroring `Obj.update`.
|
|
640
|
+
* Delegates to the same automerge-transaction primitive `Obj.update(obj, cb)` uses.
|
|
227
641
|
*/
|
|
228
|
-
export const
|
|
642
|
+
export const update = (type: AnyEntity, callback: (mutable: Mutable) => void): void => {
|
|
643
|
+
// `Type.Type` is an ECHO object; the change machinery is the same as `Obj.update`.
|
|
644
|
+
internal.change(type, callback as internal.ChangeCallback<AnyEntity>);
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
//
|
|
648
|
+
// Field-level helpers for mutating persisted types.
|
|
649
|
+
// These are thin wrappers over `Type.update` plus the JsonSchema manipulation
|
|
650
|
+
// utilities. Callers pass a persisted `Type.Type` (e.g. one returned by
|
|
651
|
+
// `DatabaseSchemaRegistry.register`) and the helper drives the change context.
|
|
652
|
+
//
|
|
229
653
|
|
|
230
654
|
/**
|
|
231
|
-
*
|
|
655
|
+
* Add fields to a persisted type's schema.
|
|
656
|
+
* @throws if the type is not persisted.
|
|
232
657
|
*/
|
|
233
|
-
export
|
|
658
|
+
export const addFields = (type: AnyEntity, fields: Schema.Struct.Fields): void => {
|
|
659
|
+
const extended = typeInternal.addFieldsToSchema(getSchema(type), fields);
|
|
660
|
+
update(type, (draft) => {
|
|
661
|
+
draft.jsonSchema = internal.toJsonSchema(extended);
|
|
662
|
+
});
|
|
663
|
+
};
|
|
234
664
|
|
|
235
665
|
/**
|
|
236
|
-
*
|
|
666
|
+
* Replace existing fields on a persisted type's schema.
|
|
667
|
+
* @throws if the type is not persisted.
|
|
237
668
|
*/
|
|
238
|
-
export const
|
|
239
|
-
|
|
669
|
+
export const updateFields = (type: AnyEntity, fields: Schema.Struct.Fields): void => {
|
|
670
|
+
const updated = typeInternal.updateFieldsInSchema(getSchema(type), fields);
|
|
671
|
+
update(type, (draft) => {
|
|
672
|
+
draft.jsonSchema = internal.toJsonSchema(updated);
|
|
673
|
+
});
|
|
240
674
|
};
|
|
241
675
|
|
|
242
|
-
|
|
243
|
-
|
|
676
|
+
/**
|
|
677
|
+
* Rename a field on a persisted type's schema.
|
|
678
|
+
* @throws if the type is not persisted.
|
|
679
|
+
*/
|
|
680
|
+
export const updateFieldPropertyName = (
|
|
681
|
+
type: Type,
|
|
682
|
+
{ before, after }: { before: PropertyKey; after: PropertyKey },
|
|
683
|
+
): void => {
|
|
684
|
+
const renamed = typeInternal.updateFieldNameInSchema(getSchema(type), { before, after });
|
|
685
|
+
update(type, (draft) => {
|
|
686
|
+
draft.jsonSchema = internal.toJsonSchema(renamed);
|
|
687
|
+
});
|
|
688
|
+
};
|
|
244
689
|
|
|
245
|
-
|
|
690
|
+
/**
|
|
691
|
+
* Remove fields from a persisted type's schema.
|
|
692
|
+
* @throws if the type is not persisted.
|
|
693
|
+
*/
|
|
694
|
+
export const removeFields = (type: AnyEntity, fieldNames: string[]): void => {
|
|
695
|
+
const removed = typeInternal.removeFieldsFromSchema(getSchema(type), fieldNames);
|
|
696
|
+
update(type, (draft) => {
|
|
697
|
+
draft.jsonSchema = internal.toJsonSchema(removed);
|
|
698
|
+
});
|
|
699
|
+
};
|