@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
|
@@ -13,23 +13,33 @@ import type * as Types from 'effect/Types';
|
|
|
13
13
|
import { raise } from '@dxos/debug';
|
|
14
14
|
import { mapAst } from '@dxos/effect';
|
|
15
15
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
16
|
-
import { DXN, ObjectId } from '@dxos/keys';
|
|
16
|
+
import { DXN, EchoURI, ObjectId } from '@dxos/keys';
|
|
17
17
|
import { log } from '@dxos/log';
|
|
18
18
|
import { clearUndefined, orderKeys, removeProperties } from '@dxos/util';
|
|
19
19
|
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
20
|
+
import type * as Type from '../../Type';
|
|
21
|
+
import {
|
|
22
|
+
type TypeAnnotation,
|
|
23
|
+
TypeAnnotationId,
|
|
24
|
+
TypeIdentifierAnnotationId,
|
|
25
|
+
makeTypeJsonSchemaAnnotation,
|
|
26
|
+
} from '../Annotation';
|
|
27
|
+
import {
|
|
28
|
+
ANY_OBJECT_TYPENAME,
|
|
29
|
+
ANY_OBJECT_VERSION,
|
|
30
|
+
EntityKind,
|
|
31
|
+
EntityKindSchema,
|
|
32
|
+
getStaticTypeSchema,
|
|
33
|
+
} from '../common/types';
|
|
34
|
+
import { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';
|
|
35
|
+
import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
|
|
22
36
|
import {
|
|
23
37
|
ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,
|
|
24
38
|
ECHO_ANNOTATIONS_NS_KEY,
|
|
25
39
|
type JsonSchemaEchoAnnotations,
|
|
26
40
|
type JsonSchemaType,
|
|
27
41
|
getNormalizedEchoAnnotations,
|
|
28
|
-
} from '
|
|
29
|
-
import { Expando, makeTypeJsonSchemaAnnotation } from '../object';
|
|
30
|
-
import { type JsonSchemaReferenceInfo, Ref, createEchoReferenceSchema } from '../ref';
|
|
31
|
-
|
|
32
|
-
import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
|
|
42
|
+
} from './json-schema-type';
|
|
33
43
|
|
|
34
44
|
// TODO(burdon): Are these values stored (can they be changed?)
|
|
35
45
|
export enum PropType {
|
|
@@ -71,11 +81,29 @@ export type JsonSchemaOptions = {
|
|
|
71
81
|
|
|
72
82
|
/**
|
|
73
83
|
* Convert effect schema to JSON Schema.
|
|
84
|
+
* NOTE: This handles custom annotations.
|
|
74
85
|
* @param schema
|
|
75
86
|
*/
|
|
76
|
-
|
|
87
|
+
// TODO(burdon): Reconcile with possibly extending @effect/Schema/JSONSchema
|
|
88
|
+
// We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
|
|
89
|
+
// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
|
|
90
|
+
export const toJsonSchema = (
|
|
91
|
+
schema: Schema.Schema.All | Type.AnyEntity,
|
|
92
|
+
options: JsonSchemaOptions = {},
|
|
93
|
+
): Types.DeepMutable<JsonSchemaType> => {
|
|
94
|
+
// Allow passing a `Type.Type` entity — use its hidden source schema (or its
|
|
95
|
+
// already-built jsonSchema as a fallback).
|
|
96
|
+
const slot = getStaticTypeSchema(schema);
|
|
97
|
+
if (slot != null) {
|
|
98
|
+
schema = slot;
|
|
99
|
+
} else if (!Schema.isSchema(schema)) {
|
|
100
|
+
const entityJsonSchema = (schema as { jsonSchema?: JsonSchemaType }).jsonSchema;
|
|
101
|
+
if (entityJsonSchema != null) {
|
|
102
|
+
return entityJsonSchema as Types.DeepMutable<JsonSchemaType>;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
77
105
|
assertArgument(Schema.isSchema(schema), 'schema');
|
|
78
|
-
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
106
|
+
let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);
|
|
79
107
|
if (options.strict) {
|
|
80
108
|
// TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).
|
|
81
109
|
jsonSchema = removeProperties(jsonSchema, (key, value) => {
|
|
@@ -96,11 +124,11 @@ export const toJsonSchema = (schema: Schema.Schema.All, options: JsonSchemaOptio
|
|
|
96
124
|
return jsonSchema;
|
|
97
125
|
};
|
|
98
126
|
|
|
99
|
-
const _toJsonSchemaAST = (ast: SchemaAST.AST): JsonSchemaType => {
|
|
127
|
+
const _toJsonSchemaAST = (ast: SchemaAST.AST): Types.DeepMutable<JsonSchemaType> => {
|
|
100
128
|
const withRefinements = withEchoRefinements(ast, '#');
|
|
101
129
|
const jsonSchema = JSONSchema.fromAST(withRefinements, {
|
|
102
130
|
definitions: {},
|
|
103
|
-
}) as JsonSchemaType
|
|
131
|
+
}) as Types.DeepMutable<JsonSchemaType>;
|
|
104
132
|
|
|
105
133
|
return normalizeJsonSchema(jsonSchema);
|
|
106
134
|
};
|
|
@@ -319,7 +347,7 @@ const objectToEffectSchema = (root: JsonSchemaType, defs: JsonSchemaType['$defs'
|
|
|
319
347
|
}
|
|
320
348
|
|
|
321
349
|
if (immutableIdField) {
|
|
322
|
-
schema = Schema.extend(
|
|
350
|
+
schema = Schema.extend(schema, Schema.Struct({ id: immutableIdField }));
|
|
323
351
|
}
|
|
324
352
|
|
|
325
353
|
const annotations = jsonSchemaFieldsToAnnotations(root);
|
|
@@ -330,9 +358,9 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
330
358
|
const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
331
359
|
// TODO(dmaretskyi): Is this branch still taken?
|
|
332
360
|
if ((echoRefinement as any)?.reference != null) {
|
|
333
|
-
const
|
|
361
|
+
const echoUri = root.$id.startsWith('echo:') || root.$id.startsWith('dxn:echo:') ? root.$id : undefined;
|
|
334
362
|
return createEchoReferenceSchema(
|
|
335
|
-
|
|
363
|
+
echoUri,
|
|
336
364
|
(echoRefinement as any).reference.typename,
|
|
337
365
|
(echoRefinement as any).reference.version,
|
|
338
366
|
);
|
|
@@ -344,21 +372,20 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
344
372
|
// TODO(dmaretskyi): Types.
|
|
345
373
|
const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
346
374
|
if (!('reference' in root)) {
|
|
347
|
-
|
|
375
|
+
// Fallback to generic object ref when no reference info is provided.
|
|
376
|
+
return createEchoReferenceSchema(undefined, ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION);
|
|
348
377
|
}
|
|
378
|
+
|
|
349
379
|
const reference: JsonSchemaReferenceInfo = root.reference;
|
|
350
380
|
if (typeof reference !== 'object') {
|
|
351
381
|
throw new Error('Invalid reference field in ref schema');
|
|
352
382
|
}
|
|
353
383
|
|
|
354
|
-
const
|
|
355
|
-
|
|
384
|
+
const ref = reference.schema.$ref;
|
|
385
|
+
const targetSchemaDXN = DXN.tryMake(ref);
|
|
386
|
+
invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);
|
|
356
387
|
|
|
357
|
-
return createEchoReferenceSchema(
|
|
358
|
-
targetSchemaDXN.toString(),
|
|
359
|
-
targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,
|
|
360
|
-
reference.schemaVersion,
|
|
361
|
-
);
|
|
388
|
+
return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
|
|
362
389
|
};
|
|
363
390
|
|
|
364
391
|
//
|
|
@@ -368,7 +395,7 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
|
368
395
|
const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Record<symbol, any> => {
|
|
369
396
|
const schemaFields: Record<string, any> = {};
|
|
370
397
|
|
|
371
|
-
const echoAnnotations: JsonSchemaEchoAnnotations = {};
|
|
398
|
+
const echoAnnotations: Types.Mutable<JsonSchemaEchoAnnotations> = {};
|
|
372
399
|
for (const [key, annotationId] of Object.entries(EchoAnnotations)) {
|
|
373
400
|
if (annotations[annotationId] != null) {
|
|
374
401
|
echoAnnotations[key as keyof JsonSchemaEchoAnnotations] = annotations[annotationId] as any;
|
|
@@ -379,10 +406,11 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
379
406
|
schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
|
|
380
407
|
}
|
|
381
408
|
|
|
409
|
+
// For stored schemas the storage URI is the definitive identifier — it overrides
|
|
410
|
+
// the typename `$id` written above.
|
|
382
411
|
const echoIdentifier = annotations[TypeIdentifierAnnotationId];
|
|
383
412
|
if (echoIdentifier) {
|
|
384
|
-
schemaFields
|
|
385
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
413
|
+
schemaFields.$id = echoIdentifier;
|
|
386
414
|
}
|
|
387
415
|
|
|
388
416
|
// Custom (at end).
|
|
@@ -397,14 +425,14 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
397
425
|
};
|
|
398
426
|
|
|
399
427
|
const decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {
|
|
400
|
-
//
|
|
401
|
-
if (schema.$id && schema.$id.startsWith('dxn:echo:')) {
|
|
428
|
+
// For stored schemas `$id` IS the storage URI (echo:/… or legacy dxn:echo:…).
|
|
429
|
+
if (schema.$id && (schema.$id.startsWith('echo:') || schema.$id.startsWith('dxn:echo:'))) {
|
|
402
430
|
return schema.$id;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
431
|
+
}
|
|
432
|
+
// Legacy: older serializations stored the EchoURI on echo.type.schemaId.
|
|
433
|
+
const legacySchemaId = schema.echo?.type?.schemaId;
|
|
434
|
+
if (legacySchemaId) {
|
|
435
|
+
return ObjectId.isValid(legacySchemaId) ? EchoURI.make({ objectId: legacySchemaId }) : legacySchemaId;
|
|
408
436
|
}
|
|
409
437
|
return undefined;
|
|
410
438
|
};
|
|
@@ -421,8 +449,8 @@ const decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefine
|
|
|
421
449
|
if (annotation.kind === EntityKind.Relation) {
|
|
422
450
|
const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));
|
|
423
451
|
const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));
|
|
424
|
-
annotation.sourceSchema = DXN.
|
|
425
|
-
annotation.targetSchema = DXN.
|
|
452
|
+
annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));
|
|
453
|
+
annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));
|
|
426
454
|
}
|
|
427
455
|
|
|
428
456
|
return annotation;
|
|
@@ -452,11 +480,15 @@ const jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annota
|
|
|
452
480
|
}
|
|
453
481
|
}
|
|
454
482
|
|
|
455
|
-
|
|
483
|
+
const typeIdentifier = decodeTypeIdentifierAnnotation(schema);
|
|
484
|
+
annotations[TypeIdentifierAnnotationId] = typeIdentifier;
|
|
456
485
|
const typeAnnotation = decodeTypeAnnotation(schema);
|
|
457
486
|
if (typeAnnotation) {
|
|
458
487
|
annotations[TypeAnnotationId] = typeAnnotation;
|
|
459
488
|
annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
489
|
+
// $id is the typename DXN — the schema's type identity. The storage EchoURI (if any)
|
|
490
|
+
// is preserved separately on TypeIdentifierAnnotation / echo.schemaId.
|
|
491
|
+
identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),
|
|
460
492
|
kind: typeAnnotation.kind,
|
|
461
493
|
typename: typeAnnotation.typename,
|
|
462
494
|
version: typeAnnotation.version,
|
|
@@ -486,7 +518,7 @@ const addJsonSchemaFields = (ast: SchemaAST.AST, schema: JsonSchemaType): Schema
|
|
|
486
518
|
* Fixes field order.
|
|
487
519
|
* Sets `$schema` prop.
|
|
488
520
|
*/
|
|
489
|
-
const normalizeJsonSchema = (jsonSchema: JsonSchemaType): JsonSchemaType => {
|
|
521
|
+
const normalizeJsonSchema = (jsonSchema: Types.DeepMutable<JsonSchemaType>): Types.DeepMutable<JsonSchemaType> => {
|
|
490
522
|
if (jsonSchema.properties && 'id' in jsonSchema.properties) {
|
|
491
523
|
jsonSchema.properties = orderKeys(jsonSchema.properties, ['id']); // Put id first.
|
|
492
524
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { invariant } from '@dxos/invariant';
|
|
6
|
+
import { deepMapValues } from '@dxos/util';
|
|
7
|
+
|
|
8
|
+
import type * as Obj from '../../Obj';
|
|
9
|
+
import { makeObject } from '../common/proxy';
|
|
10
|
+
import { getMeta, getSchema, getStaticTypeSchema, getType } from '../common/types';
|
|
11
|
+
import { Ref } from '../Ref';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Clones an object or relation.
|
|
15
|
+
* This does not clone referenced objects, only the properties in the object.
|
|
16
|
+
* @returns A new object with the same schema and properties.
|
|
17
|
+
*/
|
|
18
|
+
export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T => {
|
|
19
|
+
const { id, ...data } = obj;
|
|
20
|
+
// Prefer cloning through the type entity so the cloned instance preserves
|
|
21
|
+
// `Obj.getType` identity. Falls back to the raw schema for older instances
|
|
22
|
+
// that don't have a type-entity back-reference set (e.g. deserialized).
|
|
23
|
+
const typeEntity = getType(obj);
|
|
24
|
+
const schema = typeEntity != null ? getStaticTypeSchema(typeEntity) : getSchema(obj);
|
|
25
|
+
invariant(schema != null, 'Object should have a type or schema');
|
|
26
|
+
const props: any = deepMapValues(data, (value, recurse) => {
|
|
27
|
+
if (Ref.isRef(value)) {
|
|
28
|
+
if (opts?.deep) {
|
|
29
|
+
// TODO(dmaretskyi): Will break on circular references.
|
|
30
|
+
return Ref.make(clone(value.target!, opts));
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
return recurse(value);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (opts?.retainId) {
|
|
38
|
+
props.id = id;
|
|
39
|
+
}
|
|
40
|
+
const meta = deepMapValues(getMeta(obj), (value, recurse) => {
|
|
41
|
+
if (Ref.isRef(value)) {
|
|
42
|
+
if (opts?.deep) {
|
|
43
|
+
// TODO(dmaretskyi): Will break on circular references.
|
|
44
|
+
return Ref.make(clone(value.target!, opts));
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
return recurse(value);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return makeObject(schema, props, meta, typeEntity as object | undefined);
|
|
52
|
+
};
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { getTypename } from './typename';
|
|
7
|
+
import { getTypename } from '../Annotation';
|
|
8
|
+
import { type AnyProperties } from '../common/types';
|
|
10
9
|
|
|
11
10
|
// TODO(dmaretskyi): Rename to represent commonality between objects and relations (e.g. `entity`).
|
|
12
11
|
export type TypedObjectOptions = {
|
|
@@ -58,7 +57,7 @@ export const makeTypedEntityClass = (
|
|
|
58
57
|
static readonly pipe = baseSchema.pipe.bind(baseSchema);
|
|
59
58
|
|
|
60
59
|
// TODO(burdon): Comment required.
|
|
61
|
-
static [Symbol.hasInstance](obj:
|
|
60
|
+
static [Symbol.hasInstance](obj: AnyProperties) {
|
|
62
61
|
return obj != null && getTypename(obj) === typename;
|
|
63
62
|
}
|
|
64
63
|
|
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { inspect } from 'util';
|
|
6
|
-
|
|
7
5
|
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { inspect } from 'util';
|
|
8
7
|
import { describe, expect, test } from 'vitest';
|
|
9
8
|
|
|
10
|
-
import { DXN } from '@dxos/keys';
|
|
9
|
+
import { DXN, EchoURI } from '@dxos/keys';
|
|
11
10
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import { getSchema } from '
|
|
17
|
-
import {
|
|
11
|
+
import { Relation } from '../../index';
|
|
12
|
+
import { TestSchema } from '../../testing';
|
|
13
|
+
import * as Type from '../../Type';
|
|
14
|
+
import { getTypeURI } from '../Annotation';
|
|
15
|
+
import { ATTR_META, ATTR_TYPE, getSchema } from '../common/types';
|
|
16
|
+
import { ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET, isInstanceOf } from '../Entity';
|
|
17
|
+
import { createObject } from './create-object';
|
|
18
18
|
import { objectToJSON } from './json-serializer';
|
|
19
|
-
import { RelationSourceId, RelationTargetId } from './model';
|
|
20
|
-
import { getType } from './typename';
|
|
21
19
|
|
|
22
20
|
describe('create (static version)', () => {
|
|
23
21
|
test('defaults', ({ expect }) => {
|
|
@@ -34,7 +32,7 @@ describe('create (static version)', () => {
|
|
|
34
32
|
});
|
|
35
33
|
|
|
36
34
|
test('create static object', () => {
|
|
37
|
-
const contact =
|
|
35
|
+
const contact = createObject(TestSchema.Person, {
|
|
38
36
|
name: 'Bot',
|
|
39
37
|
email: 'bot@example.com',
|
|
40
38
|
});
|
|
@@ -43,12 +41,12 @@ describe('create (static version)', () => {
|
|
|
43
41
|
expect(contact.name).toBe('Bot');
|
|
44
42
|
expect(contact.email).toBe('bot@example.com');
|
|
45
43
|
expect((contact as any)['@type']).toBeUndefined();
|
|
46
|
-
expect(
|
|
47
|
-
expect(isInstanceOf(
|
|
44
|
+
expect(getTypeURI(contact)?.toString()).toBe(Type.getURI(TestSchema.Person).toString());
|
|
45
|
+
expect(isInstanceOf(TestSchema.Person, contact)).toBe(true);
|
|
48
46
|
});
|
|
49
47
|
|
|
50
48
|
test('JSON encoding', () => {
|
|
51
|
-
const contact =
|
|
49
|
+
const contact = createObject(TestSchema.Person, {
|
|
52
50
|
name: 'Bot',
|
|
53
51
|
email: 'bot@example.com',
|
|
54
52
|
});
|
|
@@ -56,7 +54,7 @@ describe('create (static version)', () => {
|
|
|
56
54
|
const json = JSON.parse(JSON.stringify(contact));
|
|
57
55
|
expect(json).toEqual({
|
|
58
56
|
id: contact.id,
|
|
59
|
-
'@type': DXN.
|
|
57
|
+
'@type': DXN.make(Type.getTypename(TestSchema.Person), Type.getVersion(TestSchema.Person)),
|
|
60
58
|
'@meta': {
|
|
61
59
|
keys: [],
|
|
62
60
|
},
|
|
@@ -67,52 +65,51 @@ describe('create (static version)', () => {
|
|
|
67
65
|
});
|
|
68
66
|
|
|
69
67
|
test('JSON encoding with relation', () => {
|
|
70
|
-
const
|
|
71
|
-
name: '
|
|
72
|
-
email: '
|
|
68
|
+
const person1 = createObject(TestSchema.Person, {
|
|
69
|
+
name: 'Alice',
|
|
70
|
+
email: 'alice@example.com',
|
|
73
71
|
});
|
|
74
|
-
const
|
|
75
|
-
name: '
|
|
76
|
-
email: '
|
|
72
|
+
const person2 = createObject(TestSchema.Person, {
|
|
73
|
+
name: 'Bob',
|
|
74
|
+
email: 'bob@example.com',
|
|
77
75
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
[
|
|
76
|
+
|
|
77
|
+
const manager = createObject(TestSchema.HasManager, {
|
|
78
|
+
[Relation.Source]: person1 as any,
|
|
79
|
+
[Relation.Target]: person2 as any,
|
|
81
80
|
});
|
|
82
81
|
|
|
83
|
-
const json = JSON.parse(JSON.stringify(
|
|
82
|
+
const json = JSON.parse(JSON.stringify(manager));
|
|
84
83
|
expect(json).toEqual({
|
|
85
|
-
id:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
id: manager.id,
|
|
85
|
+
[ATTR_TYPE]: DXN.make(Type.getTypename(TestSchema.HasManager), Type.getVersion(TestSchema.HasManager)),
|
|
86
|
+
[ATTR_RELATION_SOURCE]: EchoURI.make({ objectId: person1.id }),
|
|
87
|
+
[ATTR_RELATION_TARGET]: EchoURI.make({ objectId: person2.id }),
|
|
88
|
+
[ATTR_META]: {
|
|
90
89
|
keys: [],
|
|
91
90
|
},
|
|
92
91
|
});
|
|
93
92
|
});
|
|
94
93
|
|
|
95
94
|
test('getSchema', () => {
|
|
96
|
-
const contact =
|
|
95
|
+
const contact = createObject(TestSchema.Person, {
|
|
97
96
|
name: 'Bot',
|
|
98
97
|
email: 'bot@example.com',
|
|
99
98
|
});
|
|
100
99
|
|
|
101
|
-
expect(getSchema(contact)).toBe(
|
|
100
|
+
expect(getSchema(contact)).toBe(Type.getSchema(TestSchema.Person));
|
|
102
101
|
});
|
|
103
102
|
|
|
104
103
|
test('inspect', () => {
|
|
105
|
-
const contact =
|
|
104
|
+
const contact = createObject(TestSchema.Person, {
|
|
106
105
|
name: 'Bot',
|
|
107
106
|
email: 'bot@example.com',
|
|
108
107
|
});
|
|
109
108
|
|
|
110
|
-
// console.log(contact);
|
|
111
|
-
|
|
112
109
|
const text = inspect(contact);
|
|
113
110
|
expect(text).toContain('Bot');
|
|
114
111
|
expect(text).toContain('bot@example.com');
|
|
115
|
-
expect(text).toContain('example.
|
|
112
|
+
expect(text).toContain('com.example.type.person');
|
|
116
113
|
expect(text).toContain('0.1.0');
|
|
117
114
|
});
|
|
118
115
|
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { raise } from '@dxos/debug';
|
|
6
|
+
import { assertArgument, failedInvariant } from '@dxos/invariant';
|
|
7
|
+
import { ObjectId } from '@dxos/keys';
|
|
8
|
+
|
|
9
|
+
import type * as Type from '../../Type';
|
|
10
|
+
import { getSchemaURI, getTypeAnnotation, setTypename } from '../Annotation';
|
|
11
|
+
import { defineHiddenProperty } from '../common/proxy';
|
|
12
|
+
import {
|
|
13
|
+
EntityKind,
|
|
14
|
+
KindId,
|
|
15
|
+
MetaId,
|
|
16
|
+
type ObjectMeta,
|
|
17
|
+
SchemaKindId,
|
|
18
|
+
StaticTypeSchemaSlot,
|
|
19
|
+
getStaticTypeSchema,
|
|
20
|
+
setSchema,
|
|
21
|
+
setType,
|
|
22
|
+
} from '../common/types';
|
|
23
|
+
import {
|
|
24
|
+
RelationSourceDXNId,
|
|
25
|
+
RelationSourceId,
|
|
26
|
+
RelationTargetDXNId,
|
|
27
|
+
RelationTargetId,
|
|
28
|
+
assertObjectModel,
|
|
29
|
+
getObjectEchoUri,
|
|
30
|
+
} from '../Entity';
|
|
31
|
+
import { attachedTypedObjectInspector } from './inspect';
|
|
32
|
+
import { attachTypedJsonSerializer } from './json-serializer';
|
|
33
|
+
|
|
34
|
+
// Omits the brand slots — those get stamped on the instance by the entity
|
|
35
|
+
// handler (KindId via setKind, SchemaKindId derived in the proxy `get` trap
|
|
36
|
+
// from kind + jsonSchema.entityKind, StaticTypeSchemaSlot lazily via the
|
|
37
|
+
// proxy), not supplied by the caller. Allows `[Obj.Meta]` (MetaId symbol) for
|
|
38
|
+
// seeding registry-provenance meta at construction (mirrors `Obj.make`).
|
|
39
|
+
export type CreateObjectProps<T> = (T extends { id: string }
|
|
40
|
+
? Omit<T, 'id' | KindId | SchemaKindId | StaticTypeSchemaSlot> & { id?: string }
|
|
41
|
+
: Omit<T, KindId | SchemaKindId | StaticTypeSchemaSlot>) & {
|
|
42
|
+
readonly [MetaId]?: Partial<ObjectMeta>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new object instance from a schema and data, without signal reactivity.
|
|
47
|
+
* This static version creates plain JavaScript objects that are not reactive/observable.
|
|
48
|
+
* For reactive objects that automatically update UI when changed, use the regular live() function.
|
|
49
|
+
*
|
|
50
|
+
* @param schema - The Effect schema that defines the object's structure and type, piped into EchoObjectSchema
|
|
51
|
+
* @param data - The data to initialize the object with. The id and @type fields are handled automatically.
|
|
52
|
+
* @returns A new non-reactive object instance conforming to the schema
|
|
53
|
+
* @throws {Error} If the schema is not an object schema
|
|
54
|
+
* @throws {TypeError} If data contains an @type field
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const Contact = Schema.Struct({
|
|
59
|
+
* name: Schema.String,
|
|
60
|
+
* email: Schema.String,
|
|
61
|
+
* }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')))
|
|
62
|
+
*
|
|
63
|
+
* const contact = createObject(Contact, {
|
|
64
|
+
* name: "John",
|
|
65
|
+
* email: "john@example.com",
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
// TODO(burdon): Make internal.
|
|
70
|
+
export const createObject: {
|
|
71
|
+
<T extends Type.AnyEntity>(input: T, props: NoInfer<CreateObjectProps<Type.InstanceType<T>>>): Type.InstanceType<T>;
|
|
72
|
+
} = (input: any, props: any): any => {
|
|
73
|
+
// `Type.Type` entities aren't `Schema.Schema` themselves; read the source
|
|
74
|
+
// schema off the hidden slot (persisted entities synthesize it lazily via
|
|
75
|
+
// the proxy `get` trap).
|
|
76
|
+
const schema = getStaticTypeSchema(input) ?? failedInvariant('Type entity is missing its source schema');
|
|
77
|
+
const annotation = getTypeAnnotation(schema);
|
|
78
|
+
if (!annotation) {
|
|
79
|
+
throw new Error('Schema is not an ECHO schema');
|
|
80
|
+
}
|
|
81
|
+
assertArgument(!('@type' in props), 'data', '@type is not allowed');
|
|
82
|
+
assertArgument(!(RelationSourceDXNId in props), 'data', 'Relation source DXN is not allowed in the constructor');
|
|
83
|
+
assertArgument(!(RelationTargetDXNId in props), 'data', 'Relation target DXN is not allowed in the constructor');
|
|
84
|
+
assertArgument(
|
|
85
|
+
RelationSourceId in props === RelationTargetId in props,
|
|
86
|
+
'data',
|
|
87
|
+
'Relation source and target must be provided together',
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// Pull `[Obj.Meta]` (MetaId-symbol) off props before spreading so it doesn't
|
|
91
|
+
// leak into data. Callers use this to seed registry-provenance meta fields
|
|
92
|
+
// (`key`, `version`) and foreign keys / tags at construction time, mirroring
|
|
93
|
+
// `Obj.make`'s symbol-keyed meta convention.
|
|
94
|
+
const metaOverride = props[MetaId];
|
|
95
|
+
if (metaOverride !== undefined) {
|
|
96
|
+
delete props[MetaId];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Raw object.
|
|
100
|
+
const obj = { ...props, id: props.id ?? ObjectId.random() };
|
|
101
|
+
|
|
102
|
+
// Metadata. Instance-kind is read from the schema's TypeAnnotation (set by
|
|
103
|
+
// EchoObjectSchema / EchoRelationSchema / EchoTypeKindSchema): instances of
|
|
104
|
+
// a type-kind meta-schema are themselves type-kind entities, etc. The
|
|
105
|
+
// RelationSourceId-in-props check covers the legacy path where the schema
|
|
106
|
+
// annotation isn't authoritative.
|
|
107
|
+
const kind =
|
|
108
|
+
annotation.kind === EntityKind.Type
|
|
109
|
+
? EntityKind.Type
|
|
110
|
+
: annotation.kind === EntityKind.Relation || RelationSourceId in props
|
|
111
|
+
? EntityKind.Relation
|
|
112
|
+
: EntityKind.Object;
|
|
113
|
+
defineHiddenProperty(obj, KindId, kind);
|
|
114
|
+
defineHiddenProperty(obj, MetaId, { keys: [], ...metaOverride });
|
|
115
|
+
setSchema(obj, schema);
|
|
116
|
+
// If the caller passed a type entity (recognised via the schema slot), keep
|
|
117
|
+
// a reference to it on the instance for `Obj.getType` / `Relation.getType`.
|
|
118
|
+
if (input !== schema) {
|
|
119
|
+
setType(obj, input);
|
|
120
|
+
}
|
|
121
|
+
setTypename(obj, getSchemaURI(schema) ?? failedInvariant('Missing schema URI'));
|
|
122
|
+
attachTypedJsonSerializer(obj);
|
|
123
|
+
attachedTypedObjectInspector(obj);
|
|
124
|
+
|
|
125
|
+
// Relation.
|
|
126
|
+
if (kind === EntityKind.Relation) {
|
|
127
|
+
const sourceDXN = getObjectEchoUri(props[RelationSourceId]) ?? raise(new Error('Unresolved relation source'));
|
|
128
|
+
const targetDXN = getObjectEchoUri(props[RelationTargetId]) ?? raise(new Error('Unresolved relation target'));
|
|
129
|
+
defineHiddenProperty(obj, RelationSourceDXNId, sourceDXN);
|
|
130
|
+
defineHiddenProperty(obj, RelationTargetDXNId, targetDXN);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
assertObjectModel(obj);
|
|
134
|
+
return obj;
|
|
135
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type AnyProperties } from '../common/types';
|
|
6
|
+
import { ObjectDeletedId } from '../Entity';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @returns `true` if the object has been marked as deleted.
|
|
10
|
+
*/
|
|
11
|
+
export const isDeleted = (obj: AnyProperties): boolean => {
|
|
12
|
+
if ((obj as any)[ObjectDeletedId] === undefined) {
|
|
13
|
+
// TODO(dmaretskyi): Return to prior behavior of throwing.
|
|
14
|
+
// throw new Error('Object does not support deletion marker');
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (obj as any)[ObjectDeletedId] ?? false;
|
|
19
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export * from './common';
|
|
6
|
+
export * from './create-object';
|
|
7
|
+
export * from './deleted';
|
|
8
|
+
export * from './json-serializer';
|
|
9
|
+
export * from './schema-validator';
|
|
10
|
+
export * from './set-value';
|
|
11
|
+
export * from './snapshot';
|
|
12
|
+
export * from './typed-object';
|
|
13
|
+
export * from './clone';
|
|
@@ -6,10 +6,8 @@ import type { InspectOptionsStylized, inspect as inspectFn } from 'node:util';
|
|
|
6
6
|
|
|
7
7
|
import { type CustomInspectFunction, inspectCustom } from '@dxos/debug';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { ATTR_META, ATTR_TYPE, MetaId } from './model';
|
|
12
|
-
import { getType } from './typename';
|
|
9
|
+
import { getTypeURI } from '../Annotation';
|
|
10
|
+
import { ATTR_META, ATTR_TYPE, type AnyEntity, MetaId } from '../common/types';
|
|
13
11
|
|
|
14
12
|
/*
|
|
15
13
|
* @internal
|
|
@@ -29,8 +27,8 @@ export const attachedTypedObjectInspector = (obj: any) => {
|
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
// NOTE: KEEP as function.
|
|
32
|
-
const typedObjectInspectFunction: CustomInspectFunction<
|
|
33
|
-
this:
|
|
30
|
+
const typedObjectInspectFunction: CustomInspectFunction<AnyEntity> = function (
|
|
31
|
+
this: AnyEntity,
|
|
34
32
|
depth: number,
|
|
35
33
|
options: InspectOptionsStylized,
|
|
36
34
|
inspect: typeof inspectFn,
|
|
@@ -39,7 +37,7 @@ const typedObjectInspectFunction: CustomInspectFunction<AnyEchoObject> = functio
|
|
|
39
37
|
return inspect(
|
|
40
38
|
{
|
|
41
39
|
id,
|
|
42
|
-
[ATTR_TYPE]:
|
|
40
|
+
[ATTR_TYPE]: getTypeURI(this),
|
|
43
41
|
...props,
|
|
44
42
|
[ATTR_META]: (this as any)[MetaId], // TODO(dmaretskyi): Couldn't use getMeta since that throw's if the object has no meta.
|
|
45
43
|
},
|