@dxos/echo 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +10 -11
- package/dist/lib/neutral/Annotation.mjs +68 -0
- package/dist/lib/neutral/Database.mjs +38 -0
- package/dist/lib/neutral/Entity.mjs +72 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Feed.mjs +54 -0
- package/dist/lib/neutral/Filter.mjs +70 -0
- package/dist/lib/neutral/Format.mjs +86 -0
- package/dist/lib/neutral/Format.mjs.map +7 -0
- package/dist/lib/neutral/JsonSchema.mjs +18 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +16 -0
- package/dist/lib/neutral/Key.mjs.map +7 -0
- package/dist/lib/neutral/Migration.mjs +18 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +122 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +16 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +38 -0
- package/dist/lib/neutral/Query.mjs.map +7 -0
- package/dist/lib/neutral/QueryResult.mjs +2 -0
- package/dist/lib/neutral/QueryResult.mjs.map +7 -0
- package/dist/lib/neutral/Ref.mjs +25 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Registry.mjs +14 -0
- package/dist/lib/neutral/Registry.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +97 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Scope.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +32 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +65 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-35INCYOE.mjs +7 -0
- package/dist/lib/neutral/chunk-35INCYOE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs +101 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +184 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs +108 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5SUJPHAE.mjs +34 -0
- package/dist/lib/neutral/chunk-5SUJPHAE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6M2Z6WBH.mjs +93 -0
- package/dist/lib/neutral/chunk-6M2Z6WBH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6YDI3J37.mjs +346 -0
- package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs +2279 -0
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs +25 -0
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7PI7C4EF.mjs +747 -0
- package/dist/lib/neutral/chunk-7PI7C4EF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs +51 -0
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs +56 -0
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IGK6FN65.mjs +27 -0
- package/dist/lib/neutral/chunk-IGK6FN65.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LWXVKPPW.mjs +281 -0
- package/dist/lib/neutral/chunk-LWXVKPPW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs +48 -0
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs +94 -0
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QQIYS74I.mjs +336 -0
- package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs +678 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RIVWNMSF.mjs +41 -0
- package/dist/lib/neutral/chunk-RIVWNMSF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SBVFRTST.mjs +160 -0
- package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs +251 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs +428 -0
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs +437 -0
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs +205 -0
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs +36 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WTQJHC75.mjs +395 -0
- package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs +31 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs +132 -0
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +111 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/internal/index.mjs +539 -0
- package/dist/lib/neutral/internal/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +458 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +128 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Annotation.test.d.ts +2 -0
- package/dist/types/src/Annotation.test.d.ts.map +1 -0
- package/dist/types/src/Collection.d.ts +15 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +208 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Dataset.d.ts +29 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +247 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/Err.d.ts +107 -0
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +229 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +175 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +2 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +70 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +16 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +2 -1
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +72 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +483 -110
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +26 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +231 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +101 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +69 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Registry.d.ts +131 -0
- package/dist/types/src/Registry.d.ts.map +1 -0
- package/dist/types/src/Relation.d.ts +321 -23
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/Scope.d.ts +35 -0
- package/dist/types/src/Scope.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +26 -9
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +397 -106
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/View.d.ts +65 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +21 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +272 -0
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
- package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +6 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts +24 -0
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/util.d.ts +48 -0
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/api.d.ts +27 -0
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/entity.d.ts +84 -0
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/guard.d.ts +10 -0
- package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +10 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/model.d.ts +59 -0
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/object.d.ts +18 -0
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/relation.d.ts +58 -0
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts +2 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/version.d.ts +42 -0
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/format.d.ts +7 -4
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/object.d.ts +3 -1
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/select.d.ts +6 -4
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/string.d.ts +4 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +14 -10
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts +5 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +136 -35
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json → JsonSchema}/json-schema.d.ts +6 -3
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/atoms.d.ts +38 -0
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts +8 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object/create.d.ts → Obj/create-object.d.ts} +15 -16
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/deleted.d.ts +6 -0
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/index.d.ts +11 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.d.ts +45 -0
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.d.ts +7 -0
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts +6 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts +25 -0
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Query/index.d.ts +2 -0
- package/dist/types/src/internal/Query/index.d.ts.map +1 -0
- package/dist/types/src/internal/Query/pretty.d.ts +10 -0
- package/dist/types/src/internal/Query/pretty.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/atoms.d.ts +10 -0
- package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts +21 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +88 -32
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/utils.d.ts +8 -0
- package/dist/types/src/internal/Ref/utils.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.d.ts +7 -0
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts +3 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
- package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/index.d.ts +11 -0
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts +45 -0
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts +20 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +64 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/base.d.ts +27 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/entity.d.ts +94 -0
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/index.d.ts +7 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/meta.d.ts +54 -0
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +65 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/typename.d.ts +28 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/version.d.ts +15 -0
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
- package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +10 -14
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +4 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/registry.d.ts +9 -0
- package/dist/types/src/testing/registry.d.ts.map +1 -0
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +298 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +23 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +119 -66
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +202 -0
- package/src/Collection.ts +33 -0
- package/src/Database.ts +345 -0
- package/src/Dataset.ts +34 -0
- package/src/Entity.test.ts +132 -0
- package/src/Entity.ts +345 -0
- package/src/Err.ts +40 -0
- package/src/Feed.ts +352 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +484 -0
- package/src/Format.ts +5 -0
- package/src/Hypergraph.ts +84 -0
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/JsonSchema.ts +26 -0
- package/src/Key.ts +4 -1
- package/src/Migration.ts +114 -0
- package/src/Obj.test.ts +641 -0
- package/src/Obj.ts +778 -281
- package/src/Order.ts +68 -0
- package/src/Query.test.ts +835 -0
- package/src/Query.ts +634 -0
- package/src/QueryResult.ts +132 -0
- package/src/Ref.ts +98 -10
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +88 -0
- package/src/Relation.ts +503 -67
- package/src/Scope.ts +50 -0
- package/src/Tag.md +88 -0
- package/src/Tag.ts +53 -8
- package/src/Type.test.ts +257 -0
- package/src/Type.ts +643 -151
- package/src/View.ts +98 -0
- package/src/exemplars.test.ts +21 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +22 -6
- package/src/internal/Annotation/annotations.test.ts +165 -0
- package/src/internal/Annotation/annotations.ts +609 -0
- package/src/internal/Annotation/dictionary.ts +47 -0
- package/src/internal/Annotation/entity-dictionary.ts +74 -0
- package/src/internal/Annotation/index.ts +9 -0
- package/src/internal/Annotation/sorting.ts +51 -0
- package/src/internal/Annotation/util.ts +94 -0
- package/src/internal/Entity/api.ts +77 -0
- package/src/internal/Entity/entity.ts +277 -0
- package/src/internal/Entity/guard.ts +26 -0
- package/src/internal/Entity/index.ts +13 -0
- package/src/internal/Entity/model.ts +119 -0
- package/src/internal/Entity/object.ts +73 -0
- package/src/internal/Entity/relation.ts +188 -0
- package/src/internal/Entity/type-kind.ts +75 -0
- package/src/internal/Entity/type-uri.ts +92 -0
- package/src/internal/Entity/util.ts +33 -0
- package/src/internal/Entity/version.ts +96 -0
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/date.ts +5 -9
- package/src/internal/{formats → Format}/format.test.ts +27 -7
- package/src/internal/{formats → Format}/format.ts +8 -6
- package/src/internal/{formats → Format}/index.ts +2 -3
- package/src/internal/{formats → Format}/number.ts +5 -5
- package/src/internal/{formats → Format}/object.ts +23 -6
- package/src/internal/{formats → Format}/select.ts +6 -4
- package/src/internal/{formats → Format}/string.ts +14 -9
- package/src/internal/{formats → Format}/types.ts +54 -43
- package/src/internal/{json → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/index.ts +2 -0
- package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +4 -2
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +39 -39
- package/src/internal/{json → JsonSchema}/json-schema.test.ts +119 -182
- package/src/internal/{json → JsonSchema}/json-schema.ts +70 -42
- package/src/internal/Obj/atoms.ts +244 -0
- package/src/internal/Obj/clone.ts +53 -0
- package/src/internal/{object → Obj}/common.ts +3 -4
- package/src/internal/Obj/create-object.test.ts +116 -0
- package/src/internal/Obj/create-object.ts +140 -0
- package/src/internal/Obj/deleted.ts +19 -0
- package/src/internal/Obj/index.ts +14 -0
- package/src/internal/{object → Obj}/inspect.ts +7 -7
- package/src/internal/Obj/json-serializer.test.ts +199 -0
- package/src/internal/Obj/json-serializer.ts +278 -0
- package/src/internal/{object → Obj}/schema-validator.test.ts +3 -7
- package/src/internal/Obj/schema-validator.ts +6 -0
- package/src/internal/Obj/set-value.test.ts +258 -0
- package/src/internal/Obj/set-value.ts +158 -0
- package/src/internal/Obj/snapshot.ts +114 -0
- package/src/internal/Obj/typed-object.test.ts +32 -0
- package/src/internal/Obj/typed-object.ts +30 -0
- package/src/internal/{json → Query}/index.ts +1 -1
- package/src/internal/Query/pretty.ts +162 -0
- package/src/internal/Ref/atoms.ts +20 -0
- package/src/internal/{ref → Ref}/ref-array.ts +6 -7
- package/src/internal/Ref/ref.test.ts +91 -0
- package/src/internal/{ref → Ref}/ref.ts +230 -101
- package/src/internal/Ref/utils.ts +45 -0
- package/src/internal/{projection → Type}/compose.test.ts +9 -9
- package/src/internal/{projection → Type}/compose.ts +14 -9
- package/src/internal/Type/index.ts +6 -0
- package/src/internal/{schema → Type}/manipulation.ts +0 -25
- package/src/internal/Type/type-schema.ts +60 -0
- package/src/internal/common/README.md +102 -0
- package/src/internal/common/api/index.ts +15 -0
- package/src/internal/common/api/meta.ts +90 -0
- package/src/internal/{testing → common}/index.ts +2 -1
- package/src/internal/common/proxy/change-context.ts +138 -0
- package/src/internal/common/proxy/change.test.ts +527 -0
- package/src/internal/common/proxy/define-hidden-property.ts +14 -0
- package/src/internal/common/proxy/errors.ts +42 -0
- package/src/internal/common/proxy/event-batch.ts +44 -0
- package/src/internal/common/proxy/handler.test.ts +121 -0
- package/src/internal/common/proxy/index.ts +17 -0
- package/src/internal/common/proxy/json-serializer.ts +101 -0
- package/src/internal/common/proxy/make-object.ts +129 -0
- package/src/internal/common/proxy/ownership.ts +252 -0
- package/src/internal/common/proxy/proxy-types.ts +23 -0
- package/src/internal/common/proxy/proxy-utils.ts +150 -0
- package/src/internal/common/proxy/reactive-array.ts +71 -0
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/common/proxy/reactive.ts +77 -0
- package/src/internal/{object → common/proxy}/schema-validator.ts +6 -3
- package/src/internal/common/proxy/schema.test.ts +107 -0
- package/src/internal/common/proxy/symbols.ts +7 -0
- package/src/internal/common/proxy/typed-handler.test.ts +314 -0
- package/src/internal/common/proxy/typed-handler.ts +509 -0
- package/src/internal/common/proxy/typed-object.test.ts +103 -0
- package/src/internal/common/types/base.ts +43 -0
- package/src/internal/common/types/entity.ts +133 -0
- package/src/internal/common/types/index.ts +15 -0
- package/src/internal/common/types/meta.ts +109 -0
- package/src/internal/common/types/model-symbols.ts +89 -0
- package/src/internal/common/types/typename.ts +91 -0
- package/src/internal/common/types/version.ts +19 -0
- package/src/internal/common/types/well-known-types.ts +15 -0
- package/src/internal/index.ts +14 -17
- package/src/testing/api.test.ts +131 -0
- package/src/testing/index.ts +4 -3
- package/src/testing/registry.ts +44 -0
- package/src/testing/test-data.ts +189 -0
- package/src/testing/test-schema.ts +204 -0
- package/src/testing/util.ts +88 -0
- package/dist/lib/browser/chunk-BIDAASFK.mjs +0 -3727
- package/dist/lib/browser/chunk-BIDAASFK.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs +0 -410
- package/dist/lib/browser/chunk-ZDLCWGEW.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs +0 -585
- package/dist/lib/browser/chunk-ZFRJKT4A.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -35
- package/dist/lib/browser/internal/index.mjs +0 -336
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/query/index.mjs +0 -13
- package/dist/lib/browser/testing/index.mjs +0 -267
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs +0 -3727
- package/dist/lib/node-esm/chunk-3SVRRCUU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs +0 -585
- package/dist/lib/node-esm/chunk-CGDHRZWH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs +0 -410
- package/dist/lib/node-esm/chunk-HWS6VBQC.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -35
- package/dist/lib/node-esm/internal/index.mjs +0 -336
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/query/index.mjs +0 -13
- package/dist/lib/node-esm/testing/index.mjs +0 -267
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/errors.d.ts +0 -68
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -131
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts +0 -3
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/object/accessors.d.ts +0 -37
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts +0 -6
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -33
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts +0 -14
- package/dist/types/src/internal/object/expando.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts +0 -6
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts +0 -16
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +0 -32
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/meta.d.ts +0 -31
- package/dist/types/src/internal/object/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts +0 -31
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts +0 -14
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts +0 -6
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts +0 -44
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts +0 -17
- package/dist/types/src/internal/query/query.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts +0 -21
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts +0 -168
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -7
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
- package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
- package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -381
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts +0 -10
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts +0 -3
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -2
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -248
- package/dist/types/src/query/query.d.ts.map +0 -1
- package/dist/types/src/query/query.test.d.ts +0 -2
- package/dist/types/src/query/query.test.d.ts.map +0 -1
- package/dist/types/src/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -228
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/errors.ts +0 -18
- package/src/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.test.ts +0 -98
- package/src/internal/ast/annotations.ts +0 -226
- package/src/internal/ast/entity-kind.ts +0 -15
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/object/accessors.ts +0 -153
- package/src/internal/object/create.test.ts +0 -118
- package/src/internal/object/create.ts +0 -96
- package/src/internal/object/deleted.ts +0 -19
- package/src/internal/object/entity.ts +0 -248
- package/src/internal/object/expando.ts +0 -21
- package/src/internal/object/ids.ts +0 -12
- package/src/internal/object/index.ts +0 -19
- package/src/internal/object/json-serializer.test.ts +0 -99
- package/src/internal/object/json-serializer.ts +0 -225
- package/src/internal/object/meta.ts +0 -61
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typed-object.test.ts +0 -34
- package/src/internal/object/typed-object.ts +0 -88
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/proxy/handler.test.ts +0 -163
- package/src/internal/proxy/reactive-object.ts +0 -108
- package/src/internal/proxy/schema.test.ts +0 -136
- package/src/internal/proxy/typed-handler.test.ts +0 -102
- package/src/internal/proxy/typed-handler.ts +0 -228
- package/src/internal/proxy/typed-object.test.ts +0 -100
- package/src/internal/query/index.ts +0 -5
- package/src/internal/query/query.ts +0 -23
- package/src/internal/ref/ref.test.ts +0 -100
- package/src/internal/schema/echo-schema.ts +0 -383
- package/src/internal/schema/index.ts +0 -10
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/types.ts +0 -144
- package/src/internal/testing/utils.ts +0 -54
- package/src/internal/types/index.ts +0 -6
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/index.ts +0 -6
- package/src/query/query.test.ts +0 -401
- package/src/query/query.ts +0 -789
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -108
- /package/dist/lib/{browser/index.mjs.map → neutral/Annotation.mjs.map} +0 -0
- /package/dist/lib/{browser/internal/index.mjs.map → neutral/Database.mjs.map} +0 -0
- /package/dist/lib/{browser/query/index.mjs.map → neutral/Entity.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/Err.mjs.map} +0 -0
- /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Feed.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Filter.mjs.map} +0 -0
- /package/dist/types/src/internal/{ast → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{json → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{projection → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{json → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
|
@@ -11,25 +11,31 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
11
11
|
import type * as Types from 'effect/Types';
|
|
12
12
|
|
|
13
13
|
import { raise } from '@dxos/debug';
|
|
14
|
-
import {
|
|
14
|
+
import { SchemaEx } from '@dxos/effect';
|
|
15
15
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
16
|
-
import { DXN,
|
|
16
|
+
import { DXN, EID, EntityId } 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 { type TypeAnnotation, TypeAnnotationId, TypeIdentifierAnnotationId } from '../Annotation/annotations';
|
|
22
|
+
import { makeTypeJsonSchemaAnnotation } from '../Annotation/util';
|
|
23
|
+
import {
|
|
24
|
+
ANY_OBJECT_TYPENAME,
|
|
25
|
+
ANY_OBJECT_VERSION,
|
|
26
|
+
EntityKind,
|
|
27
|
+
EntityKindSchema,
|
|
28
|
+
getStaticTypeSchema,
|
|
29
|
+
} from '../common/types';
|
|
30
|
+
import { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';
|
|
31
|
+
import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
|
|
22
32
|
import {
|
|
23
33
|
ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,
|
|
24
34
|
ECHO_ANNOTATIONS_NS_KEY,
|
|
25
35
|
type JsonSchemaEchoAnnotations,
|
|
26
36
|
type JsonSchemaType,
|
|
27
37
|
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';
|
|
38
|
+
} from './json-schema-type';
|
|
33
39
|
|
|
34
40
|
// TODO(burdon): Are these values stored (can they be changed?)
|
|
35
41
|
export enum PropType {
|
|
@@ -71,11 +77,29 @@ export type JsonSchemaOptions = {
|
|
|
71
77
|
|
|
72
78
|
/**
|
|
73
79
|
* Convert effect schema to JSON Schema.
|
|
80
|
+
* NOTE: This handles custom annotations.
|
|
74
81
|
* @param schema
|
|
75
82
|
*/
|
|
76
|
-
|
|
83
|
+
// TODO(burdon): Reconcile with possibly extending @effect/Schema/JSONSchema
|
|
84
|
+
// We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
|
|
85
|
+
// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
|
|
86
|
+
export const toJsonSchema = (
|
|
87
|
+
schema: Schema.Schema.All | Type.AnyEntity,
|
|
88
|
+
options: JsonSchemaOptions = {},
|
|
89
|
+
): Types.DeepMutable<JsonSchemaType> => {
|
|
90
|
+
// Allow passing a `Type.Type` entity — use its hidden source schema (or its
|
|
91
|
+
// already-built jsonSchema as a fallback).
|
|
92
|
+
const slot = getStaticTypeSchema(schema);
|
|
93
|
+
if (slot != null) {
|
|
94
|
+
schema = slot;
|
|
95
|
+
} else if (!Schema.isSchema(schema)) {
|
|
96
|
+
const entityJsonSchema = (schema as { jsonSchema?: JsonSchemaType }).jsonSchema;
|
|
97
|
+
if (entityJsonSchema != null) {
|
|
98
|
+
return entityJsonSchema as Types.DeepMutable<JsonSchemaType>;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
77
101
|
assertArgument(Schema.isSchema(schema), 'schema');
|
|
78
|
-
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
102
|
+
let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);
|
|
79
103
|
if (options.strict) {
|
|
80
104
|
// TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).
|
|
81
105
|
jsonSchema = removeProperties(jsonSchema, (key, value) => {
|
|
@@ -96,11 +120,11 @@ export const toJsonSchema = (schema: Schema.Schema.All, options: JsonSchemaOptio
|
|
|
96
120
|
return jsonSchema;
|
|
97
121
|
};
|
|
98
122
|
|
|
99
|
-
const _toJsonSchemaAST = (ast: SchemaAST.AST): JsonSchemaType => {
|
|
123
|
+
const _toJsonSchemaAST = (ast: SchemaAST.AST): Types.DeepMutable<JsonSchemaType> => {
|
|
100
124
|
const withRefinements = withEchoRefinements(ast, '#');
|
|
101
125
|
const jsonSchema = JSONSchema.fromAST(withRefinements, {
|
|
102
126
|
definitions: {},
|
|
103
|
-
}) as JsonSchemaType
|
|
127
|
+
}) as Types.DeepMutable<JsonSchemaType>;
|
|
104
128
|
|
|
105
129
|
return normalizeJsonSchema(jsonSchema);
|
|
106
130
|
};
|
|
@@ -133,7 +157,7 @@ const withEchoRefinements = (
|
|
|
133
157
|
}
|
|
134
158
|
} else if (SchemaAST.isTypeLiteral(ast)) {
|
|
135
159
|
// Add property order annotations
|
|
136
|
-
recursiveResult = mapAst(ast, (ast, key) =>
|
|
160
|
+
recursiveResult = SchemaEx.mapAst(ast, (ast, key) =>
|
|
137
161
|
withEchoRefinements(ast, path && typeof key === 'string' ? `${path}/${key}` : undefined, suspendCache),
|
|
138
162
|
);
|
|
139
163
|
recursiveResult = addJsonSchemaFields(recursiveResult, {
|
|
@@ -143,7 +167,7 @@ const withEchoRefinements = (
|
|
|
143
167
|
// Ignore undefined keyword that appears in the optional fields.
|
|
144
168
|
return ast;
|
|
145
169
|
} else {
|
|
146
|
-
recursiveResult = mapAst(ast, (ast, key) =>
|
|
170
|
+
recursiveResult = SchemaEx.mapAst(ast, (ast, key) =>
|
|
147
171
|
withEchoRefinements(
|
|
148
172
|
ast,
|
|
149
173
|
path && (typeof key === 'string' || typeof key === 'number') ? `${path}/${key}` : undefined,
|
|
@@ -180,7 +204,7 @@ export const toEffectSchema = (root: JsonSchemaType, _defs?: JsonSchemaType['$de
|
|
|
180
204
|
}
|
|
181
205
|
}
|
|
182
206
|
} else if ('$id' in root) {
|
|
183
|
-
switch (root.$id as string) {
|
|
207
|
+
switch (decodeURIComponent(root.$id as string)) {
|
|
184
208
|
case '/schemas/any': {
|
|
185
209
|
result = anyToEffectSchema(root as JSONSchema.JsonSchema7Any);
|
|
186
210
|
break;
|
|
@@ -191,7 +215,7 @@ export const toEffectSchema = (root: JsonSchemaType, _defs?: JsonSchemaType['$de
|
|
|
191
215
|
}
|
|
192
216
|
case '/schemas/{}':
|
|
193
217
|
case '/schemas/object': {
|
|
194
|
-
result = Schema.
|
|
218
|
+
result = Schema.Struct({});
|
|
195
219
|
break;
|
|
196
220
|
}
|
|
197
221
|
// Custom ECHO object reference.
|
|
@@ -319,7 +343,7 @@ const objectToEffectSchema = (root: JsonSchemaType, defs: JsonSchemaType['$defs'
|
|
|
319
343
|
}
|
|
320
344
|
|
|
321
345
|
if (immutableIdField) {
|
|
322
|
-
schema = Schema.extend(
|
|
346
|
+
schema = Schema.extend(schema, Schema.Struct({ id: immutableIdField }));
|
|
323
347
|
}
|
|
324
348
|
|
|
325
349
|
const annotations = jsonSchemaFieldsToAnnotations(root);
|
|
@@ -330,9 +354,9 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
330
354
|
const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
331
355
|
// TODO(dmaretskyi): Is this branch still taken?
|
|
332
356
|
if ((echoRefinement as any)?.reference != null) {
|
|
333
|
-
const
|
|
357
|
+
const echoUri = root.$id.startsWith('echo:') ? root.$id : undefined;
|
|
334
358
|
return createEchoReferenceSchema(
|
|
335
|
-
|
|
359
|
+
echoUri,
|
|
336
360
|
(echoRefinement as any).reference.typename,
|
|
337
361
|
(echoRefinement as any).reference.version,
|
|
338
362
|
);
|
|
@@ -344,21 +368,20 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
344
368
|
// TODO(dmaretskyi): Types.
|
|
345
369
|
const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
346
370
|
if (!('reference' in root)) {
|
|
347
|
-
|
|
371
|
+
// Fallback to generic object ref when no reference info is provided.
|
|
372
|
+
return createEchoReferenceSchema(undefined, ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION);
|
|
348
373
|
}
|
|
374
|
+
|
|
349
375
|
const reference: JsonSchemaReferenceInfo = root.reference;
|
|
350
376
|
if (typeof reference !== 'object') {
|
|
351
377
|
throw new Error('Invalid reference field in ref schema');
|
|
352
378
|
}
|
|
353
379
|
|
|
354
|
-
const
|
|
355
|
-
|
|
380
|
+
const ref = reference.schema.$ref;
|
|
381
|
+
const targetSchemaDXN = DXN.tryMake(ref);
|
|
382
|
+
invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);
|
|
356
383
|
|
|
357
|
-
return createEchoReferenceSchema(
|
|
358
|
-
targetSchemaDXN.toString(),
|
|
359
|
-
targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,
|
|
360
|
-
reference.schemaVersion,
|
|
361
|
-
);
|
|
384
|
+
return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
|
|
362
385
|
};
|
|
363
386
|
|
|
364
387
|
//
|
|
@@ -368,7 +391,7 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
|
368
391
|
const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Record<symbol, any> => {
|
|
369
392
|
const schemaFields: Record<string, any> = {};
|
|
370
393
|
|
|
371
|
-
const echoAnnotations: JsonSchemaEchoAnnotations = {};
|
|
394
|
+
const echoAnnotations: Types.Mutable<JsonSchemaEchoAnnotations> = {};
|
|
372
395
|
for (const [key, annotationId] of Object.entries(EchoAnnotations)) {
|
|
373
396
|
if (annotations[annotationId] != null) {
|
|
374
397
|
echoAnnotations[key as keyof JsonSchemaEchoAnnotations] = annotations[annotationId] as any;
|
|
@@ -379,10 +402,11 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
379
402
|
schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
|
|
380
403
|
}
|
|
381
404
|
|
|
405
|
+
// For stored schemas the storage URI is the definitive identifier — it overrides
|
|
406
|
+
// the typename `$id` written above.
|
|
382
407
|
const echoIdentifier = annotations[TypeIdentifierAnnotationId];
|
|
383
408
|
if (echoIdentifier) {
|
|
384
|
-
schemaFields
|
|
385
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
409
|
+
schemaFields.$id = echoIdentifier;
|
|
386
410
|
}
|
|
387
411
|
|
|
388
412
|
// Custom (at end).
|
|
@@ -397,14 +421,14 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
397
421
|
};
|
|
398
422
|
|
|
399
423
|
const decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {
|
|
400
|
-
//
|
|
401
|
-
if (schema.$id && schema.$id.startsWith('
|
|
424
|
+
// For stored schemas `$id` IS the storage URI (echo:/<id>).
|
|
425
|
+
if (schema.$id && schema.$id.startsWith('echo:')) {
|
|
402
426
|
return schema.$id;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
427
|
+
}
|
|
428
|
+
// Older serializations stored the EID on echo.type.schemaId.
|
|
429
|
+
const legacySchemaId = schema.echo?.type?.schemaId;
|
|
430
|
+
if (legacySchemaId) {
|
|
431
|
+
return EntityId.isValid(legacySchemaId) ? EID.make({ entityId: legacySchemaId }) : legacySchemaId;
|
|
408
432
|
}
|
|
409
433
|
return undefined;
|
|
410
434
|
};
|
|
@@ -421,8 +445,8 @@ const decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefine
|
|
|
421
445
|
if (annotation.kind === EntityKind.Relation) {
|
|
422
446
|
const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));
|
|
423
447
|
const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));
|
|
424
|
-
annotation.sourceSchema = DXN.
|
|
425
|
-
annotation.targetSchema = DXN.
|
|
448
|
+
annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));
|
|
449
|
+
annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));
|
|
426
450
|
}
|
|
427
451
|
|
|
428
452
|
return annotation;
|
|
@@ -452,11 +476,15 @@ const jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annota
|
|
|
452
476
|
}
|
|
453
477
|
}
|
|
454
478
|
|
|
455
|
-
|
|
479
|
+
const typeIdentifier = decodeTypeIdentifierAnnotation(schema);
|
|
480
|
+
annotations[TypeIdentifierAnnotationId] = typeIdentifier;
|
|
456
481
|
const typeAnnotation = decodeTypeAnnotation(schema);
|
|
457
482
|
if (typeAnnotation) {
|
|
458
483
|
annotations[TypeAnnotationId] = typeAnnotation;
|
|
459
484
|
annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
485
|
+
// $id is the typename DXN — the schema's type identity. The storage EID (if any)
|
|
486
|
+
// is preserved separately on TypeIdentifierAnnotation / echo.schemaId.
|
|
487
|
+
identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),
|
|
460
488
|
kind: typeAnnotation.kind,
|
|
461
489
|
typename: typeAnnotation.typename,
|
|
462
490
|
version: typeAnnotation.version,
|
|
@@ -486,7 +514,7 @@ const addJsonSchemaFields = (ast: SchemaAST.AST, schema: JsonSchemaType): Schema
|
|
|
486
514
|
* Fixes field order.
|
|
487
515
|
* Sets `$schema` prop.
|
|
488
516
|
*/
|
|
489
|
-
const normalizeJsonSchema = (jsonSchema: JsonSchemaType): JsonSchemaType => {
|
|
517
|
+
const normalizeJsonSchema = (jsonSchema: Types.DeepMutable<JsonSchemaType>): Types.DeepMutable<JsonSchemaType> => {
|
|
490
518
|
if (jsonSchema.properties && 'id' in jsonSchema.properties) {
|
|
491
519
|
jsonSchema.properties = orderKeys(jsonSchema.properties, ['id']); // Put id first.
|
|
492
520
|
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Atom from '@effect-atom/atom/Atom';
|
|
6
|
+
import * as Result from '@effect-atom/atom/Result';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Function from 'effect/Function';
|
|
9
|
+
import * as Option from 'effect/Option';
|
|
10
|
+
|
|
11
|
+
import { assertArgument } from '@dxos/invariant';
|
|
12
|
+
|
|
13
|
+
import type * as Entity from '../../Entity';
|
|
14
|
+
import type * as Obj from '../../Obj';
|
|
15
|
+
import type * as Ref from '../../Ref';
|
|
16
|
+
import type * as Relation from '../../Relation';
|
|
17
|
+
import { subscribe } from '../common/proxy/reactive';
|
|
18
|
+
import { isEntity, getDatabase } from '../Entity';
|
|
19
|
+
import { RefTypeId } from '../Ref/ref';
|
|
20
|
+
import { loadRefTarget } from '../Ref/utils';
|
|
21
|
+
import { getSnapshot } from './snapshot';
|
|
22
|
+
|
|
23
|
+
const isRef = (obj: unknown): obj is Ref.Ref<any> =>
|
|
24
|
+
obj != null && typeof obj === 'object' && RefTypeId in (obj as object);
|
|
25
|
+
|
|
26
|
+
const getReactiveOption = <T extends Obj.Unknown>(snapshot: Obj.Snapshot<T>): Effect.Effect<Option.Option<T>, never> =>
|
|
27
|
+
Effect.gen(function* () {
|
|
28
|
+
const db = getDatabase(snapshot as any);
|
|
29
|
+
if (!db) {
|
|
30
|
+
return Option.none();
|
|
31
|
+
}
|
|
32
|
+
const obj = db.getObjectById((snapshot as any).id);
|
|
33
|
+
return obj ? Option.some(obj as T) : Option.none();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Atom family for ECHO objects.
|
|
38
|
+
* Uses object reference as key — same object returns same atom.
|
|
39
|
+
*/
|
|
40
|
+
const objectFamily = Atom.family(<T extends Obj.Unknown>(obj: T): Atom.Atom<Obj.Snapshot<T>> => {
|
|
41
|
+
return Atom.make<Obj.Snapshot<T>>((get) => {
|
|
42
|
+
const unsubscribe = subscribe(obj, () => {
|
|
43
|
+
// getSnapshot adds SnapshotKindId brand at runtime; cast bridges static types.
|
|
44
|
+
get.setSelf(getSnapshot(obj) as unknown as Obj.Snapshot<T>);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
get.addFinalizer(() => unsubscribe());
|
|
48
|
+
|
|
49
|
+
return getSnapshot(obj) as unknown as Obj.Snapshot<T>;
|
|
50
|
+
}).pipe(Atom.keepAlive);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Atom family for ECHO refs (snapshot version).
|
|
55
|
+
* Uses ref as key — same ref returns same atom.
|
|
56
|
+
* Subscribes to target object changes after loading.
|
|
57
|
+
*/
|
|
58
|
+
const refFamily = Atom.family(<T extends Obj.Unknown>(ref: Ref.Ref<T>): Atom.Atom<Obj.Snapshot<T> | undefined> => {
|
|
59
|
+
return Atom.make<Obj.Snapshot<T> | undefined>((get) => {
|
|
60
|
+
let unsubscribeTarget: (() => void) | undefined;
|
|
61
|
+
|
|
62
|
+
const setupTargetSubscription = (target: T): Obj.Snapshot<T> => {
|
|
63
|
+
unsubscribeTarget?.();
|
|
64
|
+
unsubscribeTarget = subscribe(target, () => {
|
|
65
|
+
// getSnapshot adds SnapshotKindId brand at runtime; cast bridges static types.
|
|
66
|
+
get.setSelf(getSnapshot(target) as unknown as Obj.Snapshot<T>);
|
|
67
|
+
});
|
|
68
|
+
return getSnapshot(target) as unknown as Obj.Snapshot<T>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
get.addFinalizer(() => {
|
|
72
|
+
unsubscribeTarget?.();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return loadRefTarget(ref, get, setupTargetSubscription);
|
|
76
|
+
}).pipe(Atom.keepAlive);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Snapshot a value to create a new reference for comparison and React dependency tracking.
|
|
81
|
+
*/
|
|
82
|
+
const snapshotForComparison = <V>(value: V): V => {
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
return [...value] as V;
|
|
85
|
+
}
|
|
86
|
+
if (value !== null && typeof value === 'object') {
|
|
87
|
+
return { ...value } as V;
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Atom family for ECHO object properties.
|
|
94
|
+
* Uses nested families: outer keyed by object, inner keyed by property key.
|
|
95
|
+
*/
|
|
96
|
+
const propertyFamily = Atom.family(<T extends Obj.Unknown>(obj: T) =>
|
|
97
|
+
Atom.family(<K extends keyof T>(key: K): Atom.Atom<T[K]> => {
|
|
98
|
+
return Atom.make<T[K]>((get) => {
|
|
99
|
+
let previousSnapshot = snapshotForComparison(obj[key]);
|
|
100
|
+
|
|
101
|
+
const unsubscribe2 = subscribe(obj, () => {
|
|
102
|
+
const newValue = obj[key];
|
|
103
|
+
const newSnapshot = snapshotForComparison(newValue);
|
|
104
|
+
if (newSnapshot !== previousSnapshot) {
|
|
105
|
+
previousSnapshot = newSnapshot;
|
|
106
|
+
get.setSelf(newSnapshot);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
get.addFinalizer(() => unsubscribe2());
|
|
111
|
+
|
|
112
|
+
return snapshotForComparison(obj[key]);
|
|
113
|
+
}).pipe(Atom.keepAlive);
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Atom family for ECHO objects — returns the live object, not a snapshot.
|
|
119
|
+
*/
|
|
120
|
+
const objectWithReactiveFamily = Atom.family(<T extends Obj.Unknown>(obj: T): Atom.Atom<T> => {
|
|
121
|
+
return Atom.make<T>((get) => {
|
|
122
|
+
const unsubscribe = subscribe(obj, () => {
|
|
123
|
+
get.setSelf(obj);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
get.addFinalizer(() => unsubscribe());
|
|
127
|
+
|
|
128
|
+
return obj;
|
|
129
|
+
}).pipe(Atom.keepAlive);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Atom family for ECHO refs — returns the live reactive object, not a snapshot.
|
|
134
|
+
*/
|
|
135
|
+
const refWithReactiveFamily = Atom.family(<T extends Obj.Unknown>(ref: Ref.Ref<T>): Atom.Atom<T | undefined> => {
|
|
136
|
+
const effect = (get: Atom.Context) =>
|
|
137
|
+
Effect.gen(function* () {
|
|
138
|
+
const snapshot = get(makeAtom(ref));
|
|
139
|
+
if (snapshot == null) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
const option = yield* getReactiveOption(snapshot);
|
|
143
|
+
return Option.getOrElse(option, () => undefined);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return Function.pipe(
|
|
147
|
+
Atom.make(effect),
|
|
148
|
+
Atom.map((result) => Result.getOrElse(result, () => undefined)),
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Atom family for any ECHO entity (obj or relation) — returns a snapshot.
|
|
154
|
+
*/
|
|
155
|
+
const entityFamily = Atom.family(<T extends Entity.Unknown>(entity: T): Atom.Atom<Entity.Snapshot> => {
|
|
156
|
+
return Atom.make<Entity.Snapshot>((get) => {
|
|
157
|
+
const unsubscribe = subscribe(entity, () => {
|
|
158
|
+
// getSnapshot adds SnapshotKindId brand at runtime; cast bridges static types.
|
|
159
|
+
get.setSelf(getSnapshot(entity) as unknown as Entity.Snapshot);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
get.addFinalizer(() => unsubscribe());
|
|
163
|
+
|
|
164
|
+
return getSnapshot(entity) as unknown as Entity.Snapshot;
|
|
165
|
+
}).pipe(Atom.keepAlive);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Atom family for ECHO relations — returns a typed relation snapshot.
|
|
170
|
+
*/
|
|
171
|
+
const relationFamily = Atom.family(<T extends Relation.Unknown>(relation: T): Atom.Atom<Relation.Snapshot<T>> => {
|
|
172
|
+
return Atom.make<Relation.Snapshot<T>>((get) => {
|
|
173
|
+
const unsubscribe = subscribe(relation, () => {
|
|
174
|
+
// getSnapshot adds SnapshotKindId brand at runtime; cast bridges static types.
|
|
175
|
+
get.setSelf(getSnapshot(relation) as unknown as Relation.Snapshot<T>);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
get.addFinalizer(() => unsubscribe());
|
|
179
|
+
|
|
180
|
+
return getSnapshot(relation) as unknown as Relation.Snapshot<T>;
|
|
181
|
+
}).pipe(Atom.keepAlive);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Create a read-only snapshot atom for a reactive object or ref.
|
|
186
|
+
* Updates automatically when the object is mutated.
|
|
187
|
+
* For refs, subscribes to target object changes after loading.
|
|
188
|
+
*/
|
|
189
|
+
export const makeAtom: {
|
|
190
|
+
<T extends Obj.Unknown>(obj: T): Atom.Atom<Obj.Snapshot<T>>;
|
|
191
|
+
<T extends Obj.Unknown>(ref: Ref.Ref<T>): Atom.Atom<Obj.Snapshot<T> | undefined>;
|
|
192
|
+
} = (objOrRef: Obj.Unknown | Ref.Ref<any>): Atom.Atom<any> => {
|
|
193
|
+
if (isRef(objOrRef)) {
|
|
194
|
+
return refFamily(objOrRef as any);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const obj = objOrRef as Obj.Unknown;
|
|
198
|
+
assertArgument(isEntity(obj), 'obj', 'Object must be a reactive object');
|
|
199
|
+
return objectFamily(obj as any);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Create a read-only atom for a specific property of a reactive object.
|
|
204
|
+
* Only fires updates when the property value actually changes.
|
|
205
|
+
*/
|
|
206
|
+
export const makeProperty = <T extends Obj.Unknown, K extends keyof T>(obj: T, key: K): Atom.Atom<T[K]> => {
|
|
207
|
+
assertArgument(isEntity(obj), 'obj', 'Object must be a reactive object');
|
|
208
|
+
return propertyFamily(obj)(key);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Like `makeAtom` but returns the live reactive object instead of a snapshot.
|
|
213
|
+
* Prefer `makeAtom` (snapshot) unless you need the live Obj for generic mutations.
|
|
214
|
+
*/
|
|
215
|
+
export const makeWithReactive: {
|
|
216
|
+
<T extends Obj.Unknown>(obj: T): Atom.Atom<T>;
|
|
217
|
+
<T extends Obj.Unknown>(ref: Ref.Ref<T>): Atom.Atom<T | undefined>;
|
|
218
|
+
} = (objOrRef: Obj.Unknown | Ref.Ref<any>): Atom.Atom<any> => {
|
|
219
|
+
if (isRef(objOrRef)) {
|
|
220
|
+
return refWithReactiveFamily(objOrRef as Ref.Ref<any>);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const obj = objOrRef as Obj.Unknown;
|
|
224
|
+
assertArgument(isEntity(obj), 'obj', 'Object must be a reactive object');
|
|
225
|
+
return objectWithReactiveFamily(obj);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Create a read-only snapshot atom for any ECHO entity (obj or relation).
|
|
230
|
+
* Updates automatically when the entity is mutated.
|
|
231
|
+
*/
|
|
232
|
+
export const makeEntity = <T extends Entity.Unknown>(entity: T): Atom.Atom<Entity.Snapshot> => {
|
|
233
|
+
assertArgument(isEntity(entity), 'entity', 'Must be a reactive ECHO entity');
|
|
234
|
+
return entityFamily(entity);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Create a read-only snapshot atom for a reactive relation.
|
|
239
|
+
* Updates automatically when the relation is mutated.
|
|
240
|
+
*/
|
|
241
|
+
export const makeRelation = <T extends Relation.Unknown>(relation: T): Atom.Atom<Relation.Snapshot<T>> => {
|
|
242
|
+
assertArgument(isEntity(relation), 'relation', 'Must be a reactive ECHO relation');
|
|
243
|
+
return relationFamily(relation);
|
|
244
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { getSchema, getStaticTypeSchema, getType } from '../common/types';
|
|
11
|
+
import { getMeta } from '../common/types/meta';
|
|
12
|
+
import { Ref } from '../Ref';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Clones an object or relation.
|
|
16
|
+
* This does not clone referenced objects, only the properties in the object.
|
|
17
|
+
* @returns A new object with the same schema and properties.
|
|
18
|
+
*/
|
|
19
|
+
export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T => {
|
|
20
|
+
const { id, ...data } = obj;
|
|
21
|
+
// Prefer cloning through the type entity so the cloned instance preserves
|
|
22
|
+
// `Obj.getType` identity. Falls back to the raw schema for older instances
|
|
23
|
+
// that don't have a type-entity back-reference set (e.g. deserialized).
|
|
24
|
+
const typeEntity = getType(obj);
|
|
25
|
+
const schema = typeEntity != null ? getStaticTypeSchema(typeEntity) : getSchema(obj);
|
|
26
|
+
invariant(schema != null, 'Object should have a type or schema');
|
|
27
|
+
const props: any = deepMapValues(data, (value, recurse) => {
|
|
28
|
+
if (Ref.isRef(value)) {
|
|
29
|
+
if (opts?.deep) {
|
|
30
|
+
// TODO(dmaretskyi): Will break on circular references.
|
|
31
|
+
return Ref.make(clone(value.target!, opts));
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
return recurse(value);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (opts?.retainId) {
|
|
39
|
+
props.id = id;
|
|
40
|
+
}
|
|
41
|
+
const meta = deepMapValues(getMeta(obj), (value, recurse) => {
|
|
42
|
+
if (Ref.isRef(value)) {
|
|
43
|
+
if (opts?.deep) {
|
|
44
|
+
// TODO(dmaretskyi): Will break on circular references.
|
|
45
|
+
return Ref.make(clone(value.target!, opts));
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
return recurse(value);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return makeObject(schema, props, meta, typeEntity as object | undefined);
|
|
53
|
+
};
|
|
@@ -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
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { inspect } from 'util';
|
|
7
|
+
import { describe, expect, test } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import { DXN, EID } from '@dxos/keys';
|
|
10
|
+
|
|
11
|
+
import { Relation } from '../../index';
|
|
12
|
+
import { TestSchema } from '../../testing';
|
|
13
|
+
import * as Type from '../../Type';
|
|
14
|
+
import { getTypeURI } from '../Annotation';
|
|
15
|
+
import { ATTR_TYPE, getSchema } from '../common/types';
|
|
16
|
+
import { ATTR_META } from '../common/types/meta';
|
|
17
|
+
import { ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET, isInstanceOf } from '../Entity';
|
|
18
|
+
import { createObject } from './create-object';
|
|
19
|
+
import { objectToJSON } from './json-serializer';
|
|
20
|
+
|
|
21
|
+
describe('create (static version)', () => {
|
|
22
|
+
test('defaults', ({ expect }) => {
|
|
23
|
+
const Contact = Schema.Struct({
|
|
24
|
+
name: Schema.String.pipe(
|
|
25
|
+
Schema.optional,
|
|
26
|
+
Schema.withConstructorDefault(() => 'Anonymous'),
|
|
27
|
+
),
|
|
28
|
+
email: Schema.String.pipe(Schema.optional),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const obj = Contact.make({});
|
|
32
|
+
expect(obj.name).toBe('Anonymous');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('create static object', () => {
|
|
36
|
+
const contact = createObject(TestSchema.Person, {
|
|
37
|
+
name: 'Bot',
|
|
38
|
+
email: 'bot@example.com',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(contact.id).toBeDefined();
|
|
42
|
+
expect(contact.name).toBe('Bot');
|
|
43
|
+
expect(contact.email).toBe('bot@example.com');
|
|
44
|
+
expect((contact as any)['@type']).toBeUndefined();
|
|
45
|
+
expect(getTypeURI(contact)?.toString()).toBe(Type.getURI(TestSchema.Person).toString());
|
|
46
|
+
expect(isInstanceOf(TestSchema.Person, contact)).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('JSON encoding', () => {
|
|
50
|
+
const contact = createObject(TestSchema.Person, {
|
|
51
|
+
name: 'Bot',
|
|
52
|
+
email: 'bot@example.com',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const json = JSON.parse(JSON.stringify(contact));
|
|
56
|
+
expect(json).toEqual({
|
|
57
|
+
id: contact.id,
|
|
58
|
+
'@type': DXN.make(Type.getTypename(TestSchema.Person), Type.getVersion(TestSchema.Person)),
|
|
59
|
+
'@meta': {
|
|
60
|
+
keys: [],
|
|
61
|
+
},
|
|
62
|
+
name: 'Bot',
|
|
63
|
+
email: 'bot@example.com',
|
|
64
|
+
});
|
|
65
|
+
expect(objectToJSON(contact)).toStrictEqual(json);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('JSON encoding with relation', () => {
|
|
69
|
+
const person1 = createObject(TestSchema.Person, {
|
|
70
|
+
name: 'Alice',
|
|
71
|
+
email: 'alice@example.com',
|
|
72
|
+
});
|
|
73
|
+
const person2 = createObject(TestSchema.Person, {
|
|
74
|
+
name: 'Bob',
|
|
75
|
+
email: 'bob@example.com',
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const manager = createObject(TestSchema.HasManager, {
|
|
79
|
+
[Relation.Source]: person1 as any,
|
|
80
|
+
[Relation.Target]: person2 as any,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const json = JSON.parse(JSON.stringify(manager));
|
|
84
|
+
expect(json).toEqual({
|
|
85
|
+
id: manager.id,
|
|
86
|
+
[ATTR_TYPE]: DXN.make(Type.getTypename(TestSchema.HasManager), Type.getVersion(TestSchema.HasManager)),
|
|
87
|
+
[ATTR_RELATION_SOURCE]: EID.make({ entityId: person1.id }),
|
|
88
|
+
[ATTR_RELATION_TARGET]: EID.make({ entityId: person2.id }),
|
|
89
|
+
[ATTR_META]: {
|
|
90
|
+
keys: [],
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('getSchema', () => {
|
|
96
|
+
const contact = createObject(TestSchema.Person, {
|
|
97
|
+
name: 'Bot',
|
|
98
|
+
email: 'bot@example.com',
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(getSchema(contact)).toBe(Type.getSchema(TestSchema.Person));
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('inspect', () => {
|
|
105
|
+
const contact = createObject(TestSchema.Person, {
|
|
106
|
+
name: 'Bot',
|
|
107
|
+
email: 'bot@example.com',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const text = inspect(contact);
|
|
111
|
+
expect(text).toContain('Bot');
|
|
112
|
+
expect(text).toContain('bot@example.com');
|
|
113
|
+
expect(text).toContain('com.example.type.person');
|
|
114
|
+
expect(text).toContain('0.1.0');
|
|
115
|
+
});
|
|
116
|
+
});
|