@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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Option from 'effect/Option';
|
|
6
|
+
import type * as Schema from 'effect/Schema';
|
|
7
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
8
|
+
|
|
9
|
+
import { assertArgument } from '@dxos/invariant';
|
|
10
|
+
import { DXN } from '@dxos/keys';
|
|
11
|
+
|
|
12
|
+
import { EntityKind } from '../common/types';
|
|
13
|
+
|
|
14
|
+
export interface AnnotationHelper<T> {
|
|
15
|
+
/**
|
|
16
|
+
* Get the annotation value from an Effect schema.
|
|
17
|
+
*
|
|
18
|
+
* Only accepts `Schema.Schema.Any` — to read an annotation off a `Type.Type`
|
|
19
|
+
* entity, unwrap it first with `Type.getSchema(entity)`. This keeps the
|
|
20
|
+
* annotation pipeline single-shaped and forces annotations to live on the
|
|
21
|
+
* source schema, not on the post-construction Type entity.
|
|
22
|
+
*/
|
|
23
|
+
get: (schema: Schema.Schema.Any) => Option.Option<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Get the annotation value from the AST.
|
|
26
|
+
*/
|
|
27
|
+
getFromAst: (ast: SchemaAST.AST) => Option.Option<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Set the annotation on an Effect schema.
|
|
30
|
+
*
|
|
31
|
+
* Only accepts `Schema.Schema.Any` — annotations must be applied to the
|
|
32
|
+
* source schema BEFORE wrapping it with `Type.makeObject` / `Type.makeRelation`.
|
|
33
|
+
* In a pipe, place every `Annotation.X.set(...)` before the `Type.make...` step.
|
|
34
|
+
*/
|
|
35
|
+
set: (value: T) => <S extends Schema.Schema.Any>(schema: S) => S;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Note: only for system annotations.
|
|
40
|
+
*/
|
|
41
|
+
// TODO(dmaretskyi): Rename to createSystemAnnotationHelper.
|
|
42
|
+
export const createAnnotationHelper = <T>(id: symbol): AnnotationHelper<T> => {
|
|
43
|
+
return {
|
|
44
|
+
get: (schema) => SchemaAST.getAnnotation(schema.ast, id),
|
|
45
|
+
getFromAst: (ast) => SchemaAST.getAnnotation(ast, id),
|
|
46
|
+
set:
|
|
47
|
+
(value) =>
|
|
48
|
+
<S extends Schema.Schema.Any>(schema: S): S =>
|
|
49
|
+
schema.annotations({ [id]: value }) as S,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* If property is optional returns the nested property, otherwise returns the property.
|
|
55
|
+
*/
|
|
56
|
+
// TODO(wittjosiah): Is there a way to do this as a generic?
|
|
57
|
+
export const unwrapOptional = (property: SchemaAST.PropertySignature) => {
|
|
58
|
+
if (!property.isOptional || !SchemaAST.isUnion(property.type)) {
|
|
59
|
+
return property;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return property.type.types[0];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @see JSONSchemaAnnotationId
|
|
67
|
+
* @returns JSON-schema annotation so that the schema can be serialized with correct parameters.
|
|
68
|
+
*/
|
|
69
|
+
// TODO(burdon): Required type.
|
|
70
|
+
export const makeTypeJsonSchemaAnnotation = (options: {
|
|
71
|
+
identifier?: string;
|
|
72
|
+
kind: EntityKind;
|
|
73
|
+
typename: string;
|
|
74
|
+
version: string;
|
|
75
|
+
relationSource?: string;
|
|
76
|
+
relationTarget?: string;
|
|
77
|
+
}) => {
|
|
78
|
+
assertArgument(!!options.relationSource === (options.kind === EntityKind.Relation), 'relationSource');
|
|
79
|
+
assertArgument(!!options.relationTarget === (options.kind === EntityKind.Relation), 'relationTarget');
|
|
80
|
+
|
|
81
|
+
const obj: Record<string, unknown> = {
|
|
82
|
+
$id: options.identifier ?? DXN.make(options.typename, options.version),
|
|
83
|
+
entityKind: options.kind,
|
|
84
|
+
version: options.version,
|
|
85
|
+
typename: options.typename,
|
|
86
|
+
};
|
|
87
|
+
if (options.kind === EntityKind.Relation) {
|
|
88
|
+
obj.relationSource = { $ref: options.relationSource };
|
|
89
|
+
obj.relationTarget = { $ref: options.relationTarget };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return obj;
|
|
93
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { invariant } from '@dxos/invariant';
|
|
6
|
+
import { type EchoURI } from '@dxos/keys';
|
|
7
|
+
import { assumeType } from '@dxos/util';
|
|
8
|
+
|
|
9
|
+
import type { AnyEntity } from '../common/types';
|
|
10
|
+
import { type InternalObjectProps, ObjectDatabaseId } from './model';
|
|
11
|
+
import { getObjectEchoUri } from './util';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the canonical EchoURI of an entity.
|
|
15
|
+
* Accepts both reactive entities and snapshots.
|
|
16
|
+
*/
|
|
17
|
+
export const getUri = (entity: AnyEntity): EchoURI.EchoURI => {
|
|
18
|
+
const uri = getObjectEchoUri(entity);
|
|
19
|
+
invariant(uri != null, 'Invalid entity.');
|
|
20
|
+
return uri;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get the database the entity belongs to.
|
|
25
|
+
* Accepts both reactive entities and snapshots.
|
|
26
|
+
*/
|
|
27
|
+
export const getDatabase = (entity: AnyEntity): any | undefined => {
|
|
28
|
+
assumeType<InternalObjectProps>(entity);
|
|
29
|
+
return entity[ObjectDatabaseId];
|
|
30
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
|
+
import type * as Types from 'effect/Types';
|
|
8
|
+
|
|
9
|
+
import { DXN, ObjectId } from '@dxos/keys';
|
|
10
|
+
import { type ToMutable } from '@dxos/util';
|
|
11
|
+
|
|
12
|
+
import { type TypeAnnotation, TypeAnnotationId, makeTypeJsonSchemaAnnotation } from '../Annotation';
|
|
13
|
+
import { defineHiddenProperty } from '../common/proxy/define-hidden-property';
|
|
14
|
+
import { makeObject } from '../common/proxy/make-object';
|
|
15
|
+
import { getProxyTarget } from '../common/proxy/proxy-utils';
|
|
16
|
+
import {
|
|
17
|
+
type AnyEntity,
|
|
18
|
+
EntityKind,
|
|
19
|
+
InstancePhantomId,
|
|
20
|
+
KindId,
|
|
21
|
+
type ObjectMeta,
|
|
22
|
+
SchemaKindId,
|
|
23
|
+
StaticTypeSchemaSlot,
|
|
24
|
+
} from '../common/types';
|
|
25
|
+
import { JsonSchemaType } from '../JsonSchema';
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Define Schema type for `typename` and use consistently for all DXN-like properties.
|
|
28
|
+
|
|
29
|
+
// type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
|
|
30
|
+
export type EchoTypeSchemaProps<T, ExtraFields = {}> = Types.Simplify<AnyEntity & ToMutable<T> & ExtraFields>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* In-memory `Type.Type` entity shape produced by `Type.makeObject(dxn)` /
|
|
34
|
+
* `Type.makeRelation({...})`. A live reactive `TypeSchema` instance —
|
|
35
|
+
* identical to a persisted `Type.Type` except for database attachment.
|
|
36
|
+
*
|
|
37
|
+
* NOT a `Schema.Schema`. The underlying Effect Schema is cached on the hidden
|
|
38
|
+
* `StaticTypeSchemaSlot` slot — retrieve it via `Type.getSchema(...)`.
|
|
39
|
+
*/
|
|
40
|
+
// TODO(burdon): Rename EchoEntitySchema.
|
|
41
|
+
export interface EchoTypeSchema<
|
|
42
|
+
Self extends Schema.Schema.Any,
|
|
43
|
+
ExtraFields = {},
|
|
44
|
+
K extends EntityKind = EntityKind,
|
|
45
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
46
|
+
> {
|
|
47
|
+
/**
|
|
48
|
+
* Entity-kind brand. Type entities are their own kind (`Type`) regardless of
|
|
49
|
+
* the kind of instance they describe — `[SchemaKindId]` carries the latter.
|
|
50
|
+
* This lets predicates like `Obj.isObject` / `Relation.isRelation` cleanly
|
|
51
|
+
* reject type entities without also having to inspect `[SchemaKindId]`.
|
|
52
|
+
*/
|
|
53
|
+
readonly [KindId]: EntityKind.Type;
|
|
54
|
+
|
|
55
|
+
/** Schema-kind brand indicating what kind of instance this type describes. */
|
|
56
|
+
readonly [SchemaKindId]: K;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Entity id. Always present — stamped at construction — but NOT the type's
|
|
60
|
+
* identity while in-memory: an unattached type resolves its URI to the typename
|
|
61
|
+
* DXN, switching to `echo:/<id>` only once attached to a database (see
|
|
62
|
+
* `getTypeURIFromSpecifier`, which discriminates by database attachment).
|
|
63
|
+
*/
|
|
64
|
+
readonly id: ObjectId;
|
|
65
|
+
|
|
66
|
+
/** Source Effect Schema (kept on a hidden slot for `Type.getSchema`). */
|
|
67
|
+
readonly [StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
68
|
+
|
|
69
|
+
// NOTE: `typename` / `version` are intentionally NOT fields. They live in
|
|
70
|
+
// `ObjectMeta` (`key` / `version`); read via `Type.getTypename(self)` /
|
|
71
|
+
// `Type.getVersion(self)`.
|
|
72
|
+
readonly jsonSchema: JsonSchemaType;
|
|
73
|
+
|
|
74
|
+
/** Struct fields for introspection. */
|
|
75
|
+
readonly fields: Fields;
|
|
76
|
+
|
|
77
|
+
/** Phantom — instance type produced by `Obj.make(self, ...)`. */
|
|
78
|
+
readonly _instance?: EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Phantom slot mirroring `Type<A>` so internal helpers (`makeObject`,
|
|
82
|
+
* `createObject`, `Ref.make`) infer the instance type uniformly whether
|
|
83
|
+
* the caller passes an `EchoTypeSchema` or a top-level `Type.Type` entity.
|
|
84
|
+
*
|
|
85
|
+
* Includes the instance-kind brand (`[KindId]`) so the phantom is assignable
|
|
86
|
+
* to the matching public-side interface in `Type.ts` (`Type.Obj` /
|
|
87
|
+
* `Type.Relation` / `Type.Type`). Each kind projects identity: instances of
|
|
88
|
+
* an object-kind schema are object-kind entities, type-kind schemas produce
|
|
89
|
+
* type-kind (persisted Type.Type) entities — the latter additionally carry
|
|
90
|
+
* the `[SchemaKindId]` / `[StaticTypeSchemaSlot]` brands the echo-handler
|
|
91
|
+
* proxy exposes on persisted Type entities.
|
|
92
|
+
*/
|
|
93
|
+
readonly [InstancePhantomId]?: EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields> & {
|
|
94
|
+
readonly [KindId]: K;
|
|
95
|
+
} & (K extends EntityKind.Type
|
|
96
|
+
? {
|
|
97
|
+
readonly [SchemaKindId]: EntityKind.Type;
|
|
98
|
+
readonly [StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
99
|
+
}
|
|
100
|
+
: {});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// type MakeProps =
|
|
104
|
+
// | boolean
|
|
105
|
+
// | {
|
|
106
|
+
// readonly disableValidation?: boolean;
|
|
107
|
+
// };
|
|
108
|
+
|
|
109
|
+
// NOTE: Utils copied from Effect `Schema.ts`.
|
|
110
|
+
// const _ownKeys = (o: object): Array<PropertyKey> =>
|
|
111
|
+
// (Object.keys(o) as Array<PropertyKey>).concat(Object.getOwnPropertySymbols(o));
|
|
112
|
+
|
|
113
|
+
// const _lazilyMergeDefaults = (
|
|
114
|
+
// fields: Schema.Struct.Fields,
|
|
115
|
+
// out: Record<PropertyKey, unknown>,
|
|
116
|
+
// ): { [x: string | symbol]: unknown } => {
|
|
117
|
+
// const ownKeys = _ownKeys(fields);
|
|
118
|
+
// for (const key of ownKeys) {
|
|
119
|
+
// const field = fields[key];
|
|
120
|
+
// if (out[key] === undefined && Schema.isPropertySignature(field)) {
|
|
121
|
+
// const ast = field.ast;
|
|
122
|
+
// const defaultValue = ast._tag === 'PropertySignatureDeclaration' ? ast.defaultValue : ast.to.defaultValue;
|
|
123
|
+
// if (defaultValue !== undefined) {
|
|
124
|
+
// out[key] = defaultValue();
|
|
125
|
+
// }
|
|
126
|
+
// }
|
|
127
|
+
// }
|
|
128
|
+
// return out;
|
|
129
|
+
// };
|
|
130
|
+
|
|
131
|
+
// const _getDisableValidationMakeOption = (options: MakeProps | undefined): boolean =>
|
|
132
|
+
// Predicate.isBoolean(options) ? options : options?.disableValidation ?? false;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Identity (typename + version) of the type meta-schema — the `Type.Type` that
|
|
136
|
+
* every ECHO type entity is itself an instance of. Shared by the materialisation
|
|
137
|
+
* vehicle ({@link persistentEntitySchema}) and `TypeSchema` so the two cannot
|
|
138
|
+
* drift on identity.
|
|
139
|
+
*/
|
|
140
|
+
export const TypeMetaSchemaDXN = DXN.make('org.dxos.type.schema', '0.1.0');
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Effect Schema that every `Type.Type` entity is an instance of: the meta-schema
|
|
144
|
+
* struct `{ name?, jsonSchema, id }` branded as a type-kind ECHO entity. This is
|
|
145
|
+
* the materialisation vehicle for `makeObject` below — the canonical user-facing
|
|
146
|
+
* entity is `Type/type-schema.ts`'s `TypeSchema`, which carries the same shape
|
|
147
|
+
* plus UI annotations.
|
|
148
|
+
*
|
|
149
|
+
* Kept self-contained (no import of `TypeSchema`) to avoid a bootstrap cycle:
|
|
150
|
+
* `TypeSchema` is itself produced via `makeEchoTypeSchema`, so this builder must
|
|
151
|
+
* not depend on it. `jsonSchema` is declared optional here (only on the
|
|
152
|
+
* materialisation vehicle — the canonical `TypeSchema` keeps it required) so the
|
|
153
|
+
* construction-time `Schema.asserts` does not force the field before it is
|
|
154
|
+
* attached; it is populated immediately after via a lazy accessor (see
|
|
155
|
+
* `makeEchoTypeSchema`).
|
|
156
|
+
*/
|
|
157
|
+
// TODO(wittjosiah): Reconcile with `TypeSchema` (`Type/type-schema.ts`).
|
|
158
|
+
// Both describe the same `org.dxos.type.schema` shape.
|
|
159
|
+
const persistentEntitySchema: Schema.Schema.AnyNoContext = (() => {
|
|
160
|
+
const typename = DXN.getName(TypeMetaSchemaDXN);
|
|
161
|
+
const version = DXN.getVersion(TypeMetaSchemaDXN)!;
|
|
162
|
+
const struct = Schema.Struct({
|
|
163
|
+
name: Schema.optional(Schema.String),
|
|
164
|
+
jsonSchema: JsonSchemaType.pipe(Schema.optional),
|
|
165
|
+
id: ObjectId,
|
|
166
|
+
});
|
|
167
|
+
const ast = SchemaAST.annotations(struct.ast, {
|
|
168
|
+
[TypeAnnotationId]: { kind: EntityKind.Type, typename, version } satisfies TypeAnnotation,
|
|
169
|
+
[SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({ kind: EntityKind.Type, typename, version }),
|
|
170
|
+
});
|
|
171
|
+
return Schema.make(ast);
|
|
172
|
+
})();
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @internal
|
|
176
|
+
*
|
|
177
|
+
* Build an in-memory `Type.Type` entity (the value returned by `Type.makeObject`
|
|
178
|
+
* / `Type.makeRelation`). The result is a LIVE reactive `TypeSchema`
|
|
179
|
+
* instance — identical in every respect to a persisted `Type.Type` except that
|
|
180
|
+
* it is not yet attached to a database. It is mutable via `Type.update`, can be
|
|
181
|
+
* passed to `db.add(...)` (which keeps the same proxy and swaps the handler),
|
|
182
|
+
* and round-trips through `jsonSchema`.
|
|
183
|
+
*
|
|
184
|
+
* The source Effect Schema describing the user's type is cached on
|
|
185
|
+
* `[StaticTypeSchemaSlot]` so `Type.getSchema(...)` returns it without a
|
|
186
|
+
* jsonSchema round-trip; the cache is invalidated by the proxy set-trap when
|
|
187
|
+
* `jsonSchema` is mutated (see `typed-handler.ts`).
|
|
188
|
+
*/
|
|
189
|
+
export const makeEchoTypeSchema = <
|
|
190
|
+
Self extends Schema.Schema.Any,
|
|
191
|
+
K extends EntityKind = EntityKind,
|
|
192
|
+
// TODO(wittjosiah): Can this be inferred from the schema?
|
|
193
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
194
|
+
>(
|
|
195
|
+
fields: Fields,
|
|
196
|
+
ast: SchemaAST.AST,
|
|
197
|
+
typename: string,
|
|
198
|
+
version: string,
|
|
199
|
+
kind: K,
|
|
200
|
+
computeJsonSchema: () => JsonSchemaType,
|
|
201
|
+
): EchoTypeSchema<Self, {}, K, Fields> => {
|
|
202
|
+
// Source Effect Schema describing the user's type — cached for `Type.getSchema`.
|
|
203
|
+
const sourceSchema = Schema.make<
|
|
204
|
+
EchoTypeSchemaProps<Schema.Schema.Type<Self>>,
|
|
205
|
+
EchoTypeSchemaProps<Schema.Schema.Encoded<Self>>,
|
|
206
|
+
Schema.Schema.Context<Self>
|
|
207
|
+
>(ast);
|
|
208
|
+
|
|
209
|
+
// `typename` / `version` route through `ObjectMeta` (`key` / `version`) — the
|
|
210
|
+
// canonical registry-provenance pair — not data fields. `keys` is empty for
|
|
211
|
+
// in-memory declarations until persisted.
|
|
212
|
+
const meta: ObjectMeta = { keys: [], key: typename, version };
|
|
213
|
+
|
|
214
|
+
// Materialise as a live reactive meta-schema instance. `jsonSchema` is attached
|
|
215
|
+
// below as a getter (not passed here as data) for two reasons; see that accessor.
|
|
216
|
+
const entity = makeObject(persistentEntitySchema, {} as any, meta);
|
|
217
|
+
|
|
218
|
+
const target = getProxyTarget(entity)!;
|
|
219
|
+
// `jsonSchema` is always available, but computed once on first read rather than at
|
|
220
|
+
// construction: serializing the AST walks `Schema.suspend(...)` thunks, and for a
|
|
221
|
+
// self-referential type (`Schema.suspend(() => Self)`) that thunk hits `Self`'s TDZ
|
|
222
|
+
// while we're still inside its `const` initializer. A getter also lets reads return
|
|
223
|
+
// the raw object instead of a child reactive proxy.
|
|
224
|
+
let memoizedJsonSchema: JsonSchemaType | undefined;
|
|
225
|
+
Object.defineProperty(target, 'jsonSchema', {
|
|
226
|
+
configurable: true,
|
|
227
|
+
enumerable: true,
|
|
228
|
+
get() {
|
|
229
|
+
return (memoizedJsonSchema ??= computeJsonSchema());
|
|
230
|
+
},
|
|
231
|
+
set(value: JsonSchemaType) {
|
|
232
|
+
memoizedJsonSchema = value;
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
// Cache the source Effect Schema (read by `Type.getSchema` via the proxy's
|
|
236
|
+
// `[StaticTypeSchemaSlot]` get-trap; invalidated on `jsonSchema` mutation).
|
|
237
|
+
defineHiddenProperty(target, StaticTypeSchemaSlot, sourceSchema);
|
|
238
|
+
// Schema-kind brand: what kind of instance this type describes. There is no
|
|
239
|
+
// database handler to derive it for in-memory entities, so stamp it directly.
|
|
240
|
+
defineHiddenProperty(target, SchemaKindId, kind);
|
|
241
|
+
// Struct fields for introspection. A getter (not a data property) so reads return
|
|
242
|
+
// the raw fields object rather than a child reactive proxy.
|
|
243
|
+
Object.defineProperty(target, 'fields', { configurable: true, enumerable: false, get: () => fields });
|
|
244
|
+
|
|
245
|
+
return entity as unknown as EchoTypeSchema<Self, {}, K, Fields>;
|
|
246
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export * from './api';
|
|
6
|
+
export * from './entity';
|
|
7
|
+
export * from './model'; // TODO(burdon): Rename.
|
|
8
|
+
export * from './object';
|
|
9
|
+
export * from './relation';
|
|
10
|
+
export * from './type-kind';
|
|
11
|
+
export * from './type-uri';
|
|
12
|
+
export * from './util';
|
|
13
|
+
export * from './version';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { type ForeignKey } from '@dxos/echo-protocol';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { EchoURI, ObjectId, type URI } from '@dxos/keys';
|
|
10
|
+
import { assumeType } from '@dxos/util';
|
|
11
|
+
|
|
12
|
+
import type * as Database from '../../Database';
|
|
13
|
+
import {
|
|
14
|
+
type ATTR_META,
|
|
15
|
+
type ATTR_PARENT,
|
|
16
|
+
type ATTR_TYPE,
|
|
17
|
+
ATTR_DELETED,
|
|
18
|
+
ATTR_RELATION_SOURCE,
|
|
19
|
+
ATTR_RELATION_TARGET,
|
|
20
|
+
ATTR_SELF_URI,
|
|
21
|
+
ATTR_SELF_URI_LEGACY,
|
|
22
|
+
EntityKind,
|
|
23
|
+
KindId,
|
|
24
|
+
type MetaId,
|
|
25
|
+
ObjectDatabaseId,
|
|
26
|
+
ObjectDeletedId,
|
|
27
|
+
type ObjectMeta,
|
|
28
|
+
ObjectVersionId,
|
|
29
|
+
type ParentId,
|
|
30
|
+
RelationSourceDXNId,
|
|
31
|
+
RelationSourceId,
|
|
32
|
+
RelationTargetDXNId,
|
|
33
|
+
RelationTargetId,
|
|
34
|
+
type SchemaId,
|
|
35
|
+
SelfURIId,
|
|
36
|
+
TypeId,
|
|
37
|
+
type Version,
|
|
38
|
+
} from '../common/types';
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
ATTR_DELETED,
|
|
42
|
+
ATTR_SELF_URI,
|
|
43
|
+
ATTR_SELF_URI_LEGACY,
|
|
44
|
+
ObjectDatabaseId,
|
|
45
|
+
ObjectDeletedId,
|
|
46
|
+
ObjectVersionId,
|
|
47
|
+
SelfURIId,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Internal runtime representation of an object.
|
|
52
|
+
* The fields are accessed through getter functions.
|
|
53
|
+
*/
|
|
54
|
+
// NOTE: Each symbol has a jsdoc describing its purpose.
|
|
55
|
+
export interface InternalObjectProps {
|
|
56
|
+
readonly id: ObjectId;
|
|
57
|
+
readonly [SelfURIId]: EchoURI.EchoURI;
|
|
58
|
+
readonly [KindId]: EntityKind;
|
|
59
|
+
readonly [SchemaId]: Schema.Schema.AnyNoContext;
|
|
60
|
+
readonly [TypeId]: URI.URI;
|
|
61
|
+
readonly [MetaId]?: ObjectMeta;
|
|
62
|
+
[ParentId]?: InternalObjectProps;
|
|
63
|
+
readonly [ObjectDatabaseId]?: Database.Database;
|
|
64
|
+
readonly [ObjectDeletedId]?: boolean;
|
|
65
|
+
readonly [ObjectVersionId]?: Version;
|
|
66
|
+
readonly [RelationSourceDXNId]?: EchoURI.EchoURI;
|
|
67
|
+
readonly [RelationTargetDXNId]?: EchoURI.EchoURI;
|
|
68
|
+
readonly [RelationSourceId]?: InternalObjectProps;
|
|
69
|
+
readonly [RelationTargetId]?: InternalObjectProps;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Entity metadata.
|
|
74
|
+
*/
|
|
75
|
+
export interface ObjectMetaJSON {
|
|
76
|
+
keys: ForeignKey[];
|
|
77
|
+
tags?: string[];
|
|
78
|
+
key?: string;
|
|
79
|
+
version?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* JSON representation of an object or relation metadata.
|
|
84
|
+
*/
|
|
85
|
+
export interface ObjectJSON {
|
|
86
|
+
id: ObjectId;
|
|
87
|
+
[ATTR_TYPE]?: URI.URI;
|
|
88
|
+
[ATTR_SELF_URI]?: EchoURI.EchoURI;
|
|
89
|
+
[ATTR_PARENT]?: EchoURI.EchoURI; // Encoded reference
|
|
90
|
+
[ATTR_DELETED]?: boolean;
|
|
91
|
+
[ATTR_META]?: ObjectMetaJSON;
|
|
92
|
+
[ATTR_RELATION_SOURCE]?: EchoURI.EchoURI;
|
|
93
|
+
[ATTR_RELATION_TARGET]?: EchoURI.EchoURI;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Application-specific properties.
|
|
97
|
+
*/
|
|
98
|
+
[key: string]: unknown;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* NOTE: Keep as `function` to avoid type inference issues.
|
|
103
|
+
*/
|
|
104
|
+
export function assertObjectModel(obj: unknown): asserts obj is InternalObjectProps {
|
|
105
|
+
invariant(typeof obj === 'object' && obj !== null, 'Invalid object model: not an object');
|
|
106
|
+
assumeType<InternalObjectProps>(obj);
|
|
107
|
+
invariant(ObjectId.isValid(obj.id), 'Invalid object model: invalid id');
|
|
108
|
+
invariant(obj[TypeId] === undefined || typeof obj[TypeId] === 'string', 'Invalid object model: invalid type');
|
|
109
|
+
invariant(
|
|
110
|
+
obj[KindId] === EntityKind.Object || obj[KindId] === EntityKind.Relation || obj[KindId] === EntityKind.Type,
|
|
111
|
+
'Invalid object model: invalid entity kind',
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
if (obj[KindId] === EntityKind.Relation) {
|
|
115
|
+
invariant(EchoURI.isEchoURI(obj[RelationSourceDXNId]), 'Invalid object model: invalid relation source');
|
|
116
|
+
invariant(EchoURI.isEchoURI(obj[RelationTargetDXNId]), 'Invalid object model: invalid relation target');
|
|
117
|
+
invariant(!EchoURI.isEchoURI(obj[RelationSourceId]), 'Invalid object model: source pointer is a DXN');
|
|
118
|
+
invariant(!EchoURI.isEchoURI(obj[RelationTargetId]), 'Invalid object model: target pointer is a DXN');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
|
+
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { DXN } from '@dxos/keys';
|
|
10
|
+
|
|
11
|
+
import { type TypeAnnotation, TypeAnnotationId, makeTypeJsonSchemaAnnotation } from '../Annotation';
|
|
12
|
+
import { EntityKind } from '../common/types';
|
|
13
|
+
import { toJsonSchema } from '../JsonSchema';
|
|
14
|
+
import { type EchoTypeSchema, makeEchoTypeSchema } from './entity';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Object schema type with kind marker.
|
|
18
|
+
*/
|
|
19
|
+
export type EchoObjectSchema<
|
|
20
|
+
Self extends Schema.Schema.Any,
|
|
21
|
+
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
22
|
+
> = EchoTypeSchema<Self, {}, EntityKind.Object, Fields>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Schema for Obj entity types.
|
|
26
|
+
* Pipeable function to add ECHO object annotations to a schema.
|
|
27
|
+
*/
|
|
28
|
+
export const EchoObjectSchema: {
|
|
29
|
+
(
|
|
30
|
+
dxn: DXN.DXN,
|
|
31
|
+
): <Self extends Schema.Schema.Any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>(
|
|
32
|
+
self: Self & { fields?: Fields },
|
|
33
|
+
) => EchoObjectSchema<Self, Fields>;
|
|
34
|
+
} = (dxn) => {
|
|
35
|
+
const typename = DXN.getName(dxn);
|
|
36
|
+
const version = DXN.getVersion(dxn);
|
|
37
|
+
invariant(version, `Type.makeObject requires a versioned DXN: ${dxn}`);
|
|
38
|
+
|
|
39
|
+
return <Self extends Schema.Schema.Any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>(
|
|
40
|
+
self: Self & { fields?: Fields },
|
|
41
|
+
): EchoObjectSchema<Self, Fields> => {
|
|
42
|
+
invariant(typeof TypeAnnotationId === 'symbol', 'Sanity.');
|
|
43
|
+
invariant(SchemaAST.isTypeLiteral(self.ast), 'Schema must be a TypeLiteral.');
|
|
44
|
+
|
|
45
|
+
// Extract fields from the schema if available (Struct schemas have .fields).
|
|
46
|
+
const fields = ((self as any).fields ?? {}) as Fields;
|
|
47
|
+
|
|
48
|
+
const schemaWithId = Schema.extend(self, Schema.Struct({ id: Schema.String }));
|
|
49
|
+
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
50
|
+
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
51
|
+
...self.ast.annotations,
|
|
52
|
+
[TypeAnnotationId]: { kind: EntityKind.Object, typename, version } satisfies TypeAnnotation,
|
|
53
|
+
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
54
|
+
[SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
55
|
+
kind: EntityKind.Object,
|
|
56
|
+
typename,
|
|
57
|
+
version,
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return makeEchoTypeSchema<Self, EntityKind.Object, Fields>(fields, ast, typename, version, EntityKind.Object, () =>
|
|
62
|
+
toJsonSchema(Schema.make(ast)),
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
};
|