@dxos/echo 0.8.4-main.ef1bc66f44 → 0.8.4-main.effb148878
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +9 -9
- package/dist/lib/neutral/Annotation.mjs +7 -3
- package/dist/lib/neutral/Database.mjs +8 -4
- package/dist/lib/neutral/Entity.mjs +35 -18
- package/dist/lib/neutral/Err.mjs +3 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +54 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +25 -12
- package/dist/lib/neutral/Format.mjs +23 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Key.mjs +7 -3
- package/dist/lib/neutral/Migration.mjs +18 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +41 -23
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +21 -9
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +13 -9
- package/dist/lib/neutral/Relation.mjs +34 -23
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +14 -10
- package/dist/lib/neutral/Type.mjs +52 -36
- package/dist/lib/neutral/{chunk-K5K3Z62A.mjs → chunk-4SYHDOQA.mjs} +14 -6
- package/dist/lib/neutral/chunk-4SYHDOQA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-XAJMXQ4H.mjs → chunk-4U7OD55H.mjs} +6 -2
- package/dist/lib/neutral/chunk-4U7OD55H.mjs.map +7 -0
- package/dist/lib/neutral/chunk-52NG2XEE.mjs +34 -0
- package/dist/lib/neutral/chunk-52NG2XEE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-KB7RIVLK.mjs → chunk-A5HDDVKS.mjs} +33 -6
- package/dist/lib/neutral/chunk-A5HDDVKS.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DLPC7DHQ.mjs → chunk-EZ4XJFHJ.mjs} +9 -11
- package/dist/lib/neutral/chunk-EZ4XJFHJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZAHWXGK4.mjs → chunk-F625JEZB.mjs} +97 -19
- package/dist/lib/neutral/chunk-F625JEZB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FFCN66OF.mjs +420 -0
- package/dist/lib/neutral/chunk-FFCN66OF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RPB6V4BE.mjs → chunk-GOHDOJE3.mjs} +16 -3
- package/dist/lib/neutral/chunk-GOHDOJE3.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs +50 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J7QWJQQV.mjs +318 -0
- package/dist/lib/neutral/chunk-J7QWJQQV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QARLJVDB.mjs → chunk-JTHNDGAR.mjs} +8 -4
- package/dist/lib/neutral/chunk-JTHNDGAR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-K5RH2PBH.mjs +361 -0
- package/dist/lib/neutral/chunk-K5RH2PBH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RIMHNJ3E.mjs → chunk-KHRAQDYX.mjs} +138 -91
- package/dist/lib/neutral/chunk-KHRAQDYX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-L65CW5EI.mjs +156 -0
- package/dist/lib/neutral/chunk-L65CW5EI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LNZIPZX6.mjs +2186 -0
- package/dist/lib/neutral/chunk-LNZIPZX6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MPXUNTME.mjs +41 -0
- package/dist/lib/neutral/chunk-MPXUNTME.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7WE7SBA2.mjs → chunk-O2EOH7XQ.mjs} +152 -134
- package/dist/lib/neutral/chunk-O2EOH7XQ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MTEHHY62.mjs → chunk-Q7ID37KF.mjs} +121 -94
- package/dist/lib/neutral/chunk-Q7ID37KF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QLYEQ5VA.mjs +205 -0
- package/dist/lib/neutral/chunk-QLYEQ5VA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SSDGRJ3A.mjs +747 -0
- package/dist/lib/neutral/chunk-SSDGRJ3A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ROKO4RKJ.mjs → chunk-TTCSATUD.mjs} +2 -2
- package/dist/lib/neutral/chunk-TTCSATUD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-UEFRFUYC.mjs} +8 -4
- package/dist/lib/neutral/chunk-UEFRFUYC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UN7K472Q.mjs +132 -0
- package/dist/lib/neutral/chunk-UN7K472Q.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UQAMAXDU.mjs +243 -0
- package/dist/lib/neutral/chunk-UQAMAXDU.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-V5NE2X7Y.mjs} +1 -1
- package/dist/lib/neutral/chunk-V5NE2X7Y.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-V72DY6LU.mjs} +1 -1
- package/dist/lib/neutral/chunk-ZII2BGPM.mjs +269 -0
- package/dist/lib/neutral/chunk-ZII2BGPM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-N2QNHMT5.mjs → chunk-ZM7VFIS2.mjs} +22 -2
- package/dist/lib/neutral/chunk-ZM7VFIS2.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +56 -29
- package/dist/lib/neutral/internal/index.mjs +128 -77
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +226 -174
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +3 -3
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +15 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +27 -42
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +29 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +123 -29
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +56 -13
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +229 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +74 -11
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +3 -3
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +15 -10
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Key.d.ts +1 -1
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +72 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +201 -77
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +117 -17
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +66 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +127 -54
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +12 -13
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +4 -3
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +337 -218
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +65 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +8 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +98 -24
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Annotation}/sorting.d.ts +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +15 -6
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/api.d.ts +13 -0
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/entity.d.ts +67 -0
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +10 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/model.d.ts +57 -0
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +3 -3
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/relation.d.ts +51 -0
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts +25 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Entity}/version.d.ts +1 -1
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/format.d.ts +2 -1
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +37 -37
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +3 -2
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +10 -12
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/deleted.d.ts +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/index.d.ts +0 -1
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +16 -8
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/set-value.d.ts +2 -2
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/typed-object.d.ts +5 -5
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +42 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/compose.d.ts +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts +3 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
- package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
- package/dist/types/src/internal/{api → common/api}/index.d.ts +0 -4
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → common/api}/meta.d.ts +3 -3
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts +19 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts +2 -2
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +18 -2
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/base.d.ts +1 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/entity.d.ts +94 -0
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/index.d.ts +1 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/meta.d.ts +12 -1
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +58 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/typename.d.ts +7 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +2 -2
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +9 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +8 -8
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +77 -82
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +5 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -15
- package/src/Annotation.ts +7 -3
- package/src/Collection.ts +36 -0
- package/src/Database.ts +80 -77
- package/src/Dataset.ts +34 -0
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +181 -66
- package/src/Err.ts +25 -3
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +356 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +152 -21
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +16 -11
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/JsonSchema.ts +14 -4
- package/src/Key.ts +1 -1
- package/src/Migration.ts +114 -0
- package/src/Obj.test.ts +158 -20
- package/src/Obj.ts +451 -183
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +446 -89
- package/src/Query.ts +300 -35
- package/src/Ref.ts +83 -12
- package/src/Relation.test.ts +16 -10
- package/src/Relation.ts +236 -165
- package/src/SchemaRegistry.ts +13 -17
- package/src/Tag.ts +9 -9
- package/src/Type.test.ts +169 -24
- package/src/Type.ts +561 -354
- package/src/View.ts +101 -0
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +9 -2
- package/src/internal/Annotation/annotations.test.ts +165 -0
- package/src/internal/{annotations → Annotation}/annotations.ts +181 -101
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -4
- package/src/internal/{annotations → Annotation}/util.ts +17 -9
- package/src/internal/{api/entity.ts → Entity/api.ts} +9 -8
- package/src/internal/Entity/entity.ts +246 -0
- package/src/internal/{entities → Entity}/index.ts +4 -0
- package/src/internal/{entities → Entity}/model.ts +42 -60
- package/src/internal/{entities → Entity}/object.ts +13 -6
- package/src/internal/Entity/relation.ts +179 -0
- package/src/internal/Entity/type-kind.ts +67 -0
- package/src/internal/Entity/type-uri.ts +87 -0
- package/src/internal/Entity/util.ts +34 -0
- package/src/internal/{api → Entity}/version.ts +2 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/date.ts +0 -4
- package/src/internal/{formats → Format}/format.test.ts +1 -2
- package/src/internal/{formats → Format}/index.ts +2 -3
- package/src/internal/{formats → Format}/types.ts +2 -2
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +4 -4
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +64 -151
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +47 -28
- package/src/internal/{object → Obj}/clone.ts +10 -6
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +13 -14
- package/src/internal/Obj/create-object.ts +135 -0
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/index.ts +0 -1
- package/src/internal/{object → Obj}/inspect.ts +3 -3
- package/src/internal/Obj/json-serializer.test.ts +185 -0
- package/src/internal/{object → Obj}/json-serializer.ts +108 -45
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +31 -54
- package/src/internal/{object → Obj}/set-value.ts +3 -3
- package/src/internal/{object → Obj}/snapshot.ts +41 -23
- package/src/internal/Obj/typed-object.test.ts +32 -0
- package/src/internal/{object → Obj}/typed-object.ts +5 -5
- package/src/internal/Query.ts +156 -0
- package/src/internal/{ref → Ref}/ref-array.ts +1 -2
- package/src/internal/{ref → Ref}/ref.test.ts +16 -26
- package/src/internal/{ref → Ref}/ref.ts +117 -57
- package/src/internal/{schema → Type}/compose.test.ts +6 -5
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/Type/index.ts +6 -0
- package/src/internal/{schema → Type}/manipulation.ts +0 -25
- package/src/internal/Type/type-schema.ts +60 -0
- package/src/internal/{README.md → common/README.md} +2 -2
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/{api → common/api}/meta.ts +3 -3
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change-context.ts +1 -1
- package/src/internal/{proxy → common/proxy}/change.test.ts +97 -97
- package/src/internal/{proxy → common/proxy}/errors.ts +2 -2
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -4
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +20 -14
- package/src/internal/{proxy → common/proxy}/make-object.ts +37 -15
- package/src/internal/{proxy → common/proxy}/ownership.ts +0 -1
- package/src/internal/{proxy → common/proxy}/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/{proxy → common/proxy}/reactive.ts +12 -4
- package/src/internal/common/proxy/schema.test.ts +107 -0
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +15 -15
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +75 -18
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +17 -30
- package/src/internal/{types → common/types}/base.ts +1 -1
- package/src/internal/common/types/entity.ts +133 -0
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +15 -1
- package/src/internal/common/types/model-symbols.ts +74 -0
- package/src/internal/common/types/typename.ts +91 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +15 -12
- package/src/testing/test-data.ts +158 -99
- package/src/testing/test-schema.ts +33 -67
- package/src/testing/util.ts +14 -11
- package/dist/lib/neutral/chunk-2AF5GMG6.mjs +0 -171
- package/dist/lib/neutral/chunk-2AF5GMG6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4L6DOFXP.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7WE7SBA2.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DLPC7DHQ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EBUAT5ID.mjs +0 -229
- package/dist/lib/neutral/chunk-EBUAT5ID.mjs.map +0 -7
- package/dist/lib/neutral/chunk-K5K3Z62A.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KB7RIVLK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-LKFNEFHF.mjs +0 -130
- package/dist/lib/neutral/chunk-LKFNEFHF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MTEHHY62.mjs.map +0 -7
- package/dist/lib/neutral/chunk-N2QNHMT5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-QARLJVDB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RIMHNJ3E.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TLGNKUUG.mjs +0 -3905
- package/dist/lib/neutral/chunk-TLGNKUUG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TQT6WTIJ.mjs +0 -142
- package/dist/lib/neutral/chunk-TQT6WTIJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VUQGRDRI.mjs +0 -97
- package/dist/lib/neutral/chunk-VUQGRDRI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs +0 -13
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XAJMXQ4H.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZAHWXGK4.mjs.map +0 -7
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/api/annotations.d.ts +0 -23
- package/dist/types/src/internal/api/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/api/entity.d.ts +0 -13
- package/dist/types/src/internal/api/entity.d.ts.map +0 -1
- package/dist/types/src/internal/api/index.d.ts.map +0 -1
- package/dist/types/src/internal/api/meta.d.ts.map +0 -1
- package/dist/types/src/internal/api/sorting.d.ts.map +0 -1
- package/dist/types/src/internal/api/version.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts +0 -20
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts +0 -6
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- package/dist/types/src/internal/entities/model.d.ts +0 -79
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts +0 -62
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/clone.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts +0 -6
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +0 -2
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change-context.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/errors.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts +0 -14
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/ownership.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/symbols.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts +0 -181
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -4
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +0 -20
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts +0 -37
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/src/internal/annotations/annotations.test.ts +0 -96
- package/src/internal/api/annotations.ts +0 -60
- package/src/internal/entities/entity.ts +0 -126
- package/src/internal/entities/relation.ts +0 -171
- package/src/internal/entities/util.ts +0 -33
- package/src/internal/object/create-object.ts +0 -95
- package/src/internal/object/ids.ts +0 -12
- package/src/internal/object/json-serializer.test.ts +0 -98
- package/src/internal/object/typed-object.test.ts +0 -34
- package/src/internal/proxy/schema.test.ts +0 -145
- package/src/internal/schema/echo-schema.ts +0 -424
- package/src/internal/schema/index.ts +0 -7
- package/src/internal/schema/persistent-schema.ts +0 -28
- package/src/internal/types/entity.ts +0 -54
- package/src/internal/types/typename.ts +0 -55
- /package/dist/lib/neutral/{chunk-OMUPQMLR.mjs.map → chunk-V72DY6LU.mjs.map} +0 -0
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/select.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/string.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/clone.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/set-value.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/snapshot.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/define-hidden-property.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/event-batch.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/index.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/json-serializer.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/ownership.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-types.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-utils.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/symbols.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/src/internal/{formats → Format}/format.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{formats → Format}/object.ts +0 -0
- /package/src/internal/{formats → Format}/select.ts +0 -0
- /package/src/internal/{formats → Format}/string.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +0 -0
- /package/src/internal/{object → Obj}/schema-validator.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/define-hidden-property.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/event-batch.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
|
@@ -8,7 +8,7 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
8
8
|
import { describe, expect, test } from 'vitest';
|
|
9
9
|
|
|
10
10
|
import { type JsonProp, findAnnotation } from '@dxos/effect';
|
|
11
|
-
import { ObjectId } from '@dxos/keys';
|
|
11
|
+
import { DXN, ObjectId } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
13
|
|
|
14
14
|
import { TestSchema, prepareAstForCompare } from '../../testing';
|
|
@@ -20,14 +20,13 @@ import {
|
|
|
20
20
|
PropertyMeta,
|
|
21
21
|
getTypeAnnotation,
|
|
22
22
|
getTypeIdentifierAnnotation,
|
|
23
|
-
} from '../
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
23
|
+
} from '../Annotation';
|
|
24
|
+
import { EntityKind } from '../common/types';
|
|
25
|
+
import { EchoObjectSchema } from '../Entity';
|
|
26
|
+
import { Email, FormatAnnotation, TypeFormat } from '../Format';
|
|
27
|
+
import { JsonSchemaType, getNormalizedEchoAnnotations, getSchemaProperty, setSchemaProperty } from '../JsonSchema';
|
|
28
|
+
import { Ref, createSchemaReference, getReferenceAst, getSchemaReference } from '../Ref';
|
|
29
|
+
import { TypeSchema } from '../Type';
|
|
31
30
|
import { toEffectSchema, toJsonSchema } from './json-schema';
|
|
32
31
|
|
|
33
32
|
const EXAMPLE_NAMESPACE = '@example';
|
|
@@ -35,26 +34,18 @@ const EXAMPLE_NAMESPACE = '@example';
|
|
|
35
34
|
describe('effect-to-json', () => {
|
|
36
35
|
test('type annotation', () => {
|
|
37
36
|
const Test = Schema.Struct({ name: Schema.String }).pipe(
|
|
38
|
-
Type.
|
|
39
|
-
typename: 'example.com/type/Test',
|
|
40
|
-
version: '0.1.0',
|
|
41
|
-
}),
|
|
37
|
+
Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
|
|
42
38
|
);
|
|
43
39
|
const jsonSchema = toJsonSchema(Test);
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
40
|
+
expect(jsonSchema.$id).toEqual('dxn:com.example.type.test:0.1.0');
|
|
41
|
+
expect(jsonSchema.version).toEqual('0.1.0');
|
|
46
42
|
});
|
|
47
43
|
|
|
48
44
|
test('property meta annotation', () => {
|
|
49
45
|
const meta = { maxLength: 0 };
|
|
50
46
|
const Test = Schema.Struct({
|
|
51
47
|
name: Schema.String.pipe(PropertyMeta(EXAMPLE_NAMESPACE, meta)),
|
|
52
|
-
}).pipe(
|
|
53
|
-
Type.object({
|
|
54
|
-
typename: 'example.com/type/Test',
|
|
55
|
-
version: '0.1.0',
|
|
56
|
-
}),
|
|
57
|
-
);
|
|
48
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
58
49
|
const jsonSchema = toJsonSchema(Test);
|
|
59
50
|
expect(getNormalizedEchoAnnotations(jsonSchema.properties!.name!)!.meta![EXAMPLE_NAMESPACE]).to.deep.eq(meta);
|
|
60
51
|
});
|
|
@@ -62,20 +53,10 @@ describe('effect-to-json', () => {
|
|
|
62
53
|
test('reference annotation', () => {
|
|
63
54
|
const Nested = Schema.Struct({
|
|
64
55
|
name: Schema.String,
|
|
65
|
-
}).pipe(
|
|
66
|
-
Type.object({
|
|
67
|
-
typename: 'example.com/type/TestNested',
|
|
68
|
-
version: '0.1.0',
|
|
69
|
-
}),
|
|
70
|
-
);
|
|
56
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
71
57
|
const Test = Schema.Struct({
|
|
72
58
|
name: Ref(Nested),
|
|
73
|
-
}).pipe(
|
|
74
|
-
Type.object({
|
|
75
|
-
typename: 'example.com/type/Test',
|
|
76
|
-
version: '0.1.0',
|
|
77
|
-
}),
|
|
78
|
-
);
|
|
59
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
79
60
|
const jsonSchema = toJsonSchema(Test);
|
|
80
61
|
// log.info('schema', { jsonSchema });
|
|
81
62
|
const nested = jsonSchema.properties!.name;
|
|
@@ -87,20 +68,10 @@ describe('effect-to-json', () => {
|
|
|
87
68
|
test.skip('reference annotation with lookup property', () => {
|
|
88
69
|
const Nested = Schema.Struct({
|
|
89
70
|
name: Schema.String,
|
|
90
|
-
}).pipe(
|
|
91
|
-
Type.object({
|
|
92
|
-
typename: 'example.com/type/TestNested',
|
|
93
|
-
version: '0.1.0',
|
|
94
|
-
}),
|
|
95
|
-
);
|
|
71
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
96
72
|
const Test = Schema.Struct({
|
|
97
73
|
name: Ref(Nested).annotations({ [FieldLookupAnnotationId]: 'name' }),
|
|
98
|
-
}).pipe(
|
|
99
|
-
Type.object({
|
|
100
|
-
typename: 'example.com/type/Test',
|
|
101
|
-
version: '0.1.0',
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
74
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
104
75
|
const jsonSchema = toJsonSchema(Test);
|
|
105
76
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
106
77
|
|
|
@@ -111,20 +82,10 @@ describe('effect-to-json', () => {
|
|
|
111
82
|
test('array of references', () => {
|
|
112
83
|
const Nested = Schema.Struct({
|
|
113
84
|
name: Schema.String,
|
|
114
|
-
}).pipe(
|
|
115
|
-
Type.object({
|
|
116
|
-
typename: 'example.com/type/TestNested',
|
|
117
|
-
version: '0.1.0',
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
85
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
120
86
|
const Test = Schema.Struct({
|
|
121
87
|
name: Schema.Array(Ref(Nested)),
|
|
122
|
-
}).pipe(
|
|
123
|
-
Type.object({
|
|
124
|
-
typename: 'example.com/type/Test',
|
|
125
|
-
version: '0.1.0',
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
88
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
128
89
|
|
|
129
90
|
const jsonSchema = toJsonSchema(Test);
|
|
130
91
|
expectReferenceAnnotation((jsonSchema.properties!.name as any).items);
|
|
@@ -133,20 +94,10 @@ describe('effect-to-json', () => {
|
|
|
133
94
|
test('optional references', () => {
|
|
134
95
|
const Nested = Schema.Struct({
|
|
135
96
|
name: Schema.String,
|
|
136
|
-
}).pipe(
|
|
137
|
-
Type.object({
|
|
138
|
-
typename: 'example.com/type/TestNested',
|
|
139
|
-
version: '0.1.0',
|
|
140
|
-
}),
|
|
141
|
-
);
|
|
97
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
142
98
|
const Test = Schema.Struct({
|
|
143
99
|
name: Schema.optional(Ref(Nested)),
|
|
144
|
-
}).pipe(
|
|
145
|
-
Type.object({
|
|
146
|
-
typename: 'example.com/type/Test',
|
|
147
|
-
version: '0.1.0',
|
|
148
|
-
}),
|
|
149
|
-
);
|
|
100
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
150
101
|
const jsonSchema = toJsonSchema(Test);
|
|
151
102
|
expectReferenceAnnotation(jsonSchema.properties!.name);
|
|
152
103
|
});
|
|
@@ -164,20 +115,15 @@ describe('effect-to-json', () => {
|
|
|
164
115
|
email: Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email)).annotations({
|
|
165
116
|
description: 'Email address',
|
|
166
117
|
}),
|
|
167
|
-
}).pipe(
|
|
168
|
-
Type.object({
|
|
169
|
-
typename: 'example.com/type/Person',
|
|
170
|
-
version: '0.1.0',
|
|
171
|
-
}),
|
|
172
|
-
);
|
|
118
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
173
119
|
|
|
174
120
|
const jsonSchema = toJsonSchema(TempSchema);
|
|
175
121
|
expect(jsonSchema).to.deep.eq({
|
|
176
122
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
177
|
-
$id: 'dxn:type:
|
|
123
|
+
$id: 'dxn:com.example.type.person:0.1.0',
|
|
178
124
|
|
|
179
125
|
entityKind: EntityKind.Object,
|
|
180
|
-
typename: 'example.
|
|
126
|
+
typename: 'com.example.type.person',
|
|
181
127
|
version: '0.1.0',
|
|
182
128
|
|
|
183
129
|
type: 'object',
|
|
@@ -215,32 +161,22 @@ describe('effect-to-json', () => {
|
|
|
215
161
|
test('reference property by ref', () => {
|
|
216
162
|
const Organization = Schema.Struct({
|
|
217
163
|
field: Schema.String,
|
|
218
|
-
}).pipe(
|
|
219
|
-
Type.object({
|
|
220
|
-
typename: 'example.com/type/Organization',
|
|
221
|
-
version: '0.1.0',
|
|
222
|
-
}),
|
|
223
|
-
);
|
|
164
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
224
165
|
|
|
225
166
|
const Contact = Schema.Struct({
|
|
226
167
|
name: Schema.String,
|
|
227
168
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
228
|
-
}).pipe(
|
|
229
|
-
Type.object({
|
|
230
|
-
typename: 'example.com/type/Person',
|
|
231
|
-
version: '0.1.0',
|
|
232
|
-
}),
|
|
233
|
-
);
|
|
169
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
234
170
|
|
|
235
171
|
// log.info('Contact', { ast: Contact.ast });
|
|
236
172
|
|
|
237
173
|
const jsonSchema = toJsonSchema(Contact);
|
|
238
174
|
expect(jsonSchema).toEqual({
|
|
239
175
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
240
|
-
$id: 'dxn:type:
|
|
176
|
+
$id: 'dxn:com.example.type.person:0.1.0',
|
|
241
177
|
|
|
242
178
|
entityKind: EntityKind.Object,
|
|
243
|
-
typename: 'example.
|
|
179
|
+
typename: 'com.example.type.person',
|
|
244
180
|
version: '0.1.0',
|
|
245
181
|
|
|
246
182
|
type: 'object',
|
|
@@ -260,7 +196,7 @@ describe('effect-to-json', () => {
|
|
|
260
196
|
$ref: '/schemas/echo/ref',
|
|
261
197
|
reference: {
|
|
262
198
|
schema: {
|
|
263
|
-
$ref: 'dxn:
|
|
199
|
+
$ref: 'dxn:com.example.type.organization',
|
|
264
200
|
},
|
|
265
201
|
schemaVersion: '0.1.0',
|
|
266
202
|
},
|
|
@@ -277,31 +213,21 @@ describe('effect-to-json', () => {
|
|
|
277
213
|
test('add reference property', () => {
|
|
278
214
|
const Organization = Schema.Struct({
|
|
279
215
|
field: Schema.String,
|
|
280
|
-
}).pipe(
|
|
281
|
-
Type.object({
|
|
282
|
-
typename: 'example.com/type/Organization',
|
|
283
|
-
version: '0.1.0',
|
|
284
|
-
}),
|
|
285
|
-
);
|
|
216
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
286
217
|
|
|
287
218
|
const Contact = Schema.Struct({
|
|
288
219
|
name: Schema.String,
|
|
289
220
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
290
|
-
}).pipe(
|
|
291
|
-
Type.object({
|
|
292
|
-
typename: 'example.com/type/Person',
|
|
293
|
-
version: '0.1.0',
|
|
294
|
-
}),
|
|
295
|
-
);
|
|
221
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
296
222
|
|
|
297
223
|
const jsonSchema = toJsonSchema(Contact);
|
|
298
|
-
setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Organization
|
|
224
|
+
setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Type.getTypename(Organization)));
|
|
299
225
|
const { typename } = getSchemaReference(getSchemaProperty(jsonSchema, 'organization' as JsonProp) ?? {}) ?? {};
|
|
300
|
-
expect(typename).to.eq(Organization
|
|
226
|
+
expect(typename).to.eq(Type.getTypename(Organization));
|
|
301
227
|
});
|
|
302
228
|
|
|
303
|
-
test('serialize circular schema (
|
|
304
|
-
const jsonSchema = toJsonSchema(
|
|
229
|
+
test('serialize circular schema (TypeSchema)', () => {
|
|
230
|
+
const jsonSchema = toJsonSchema(TypeSchema);
|
|
305
231
|
expect(Object.keys(jsonSchema.properties!).length).toBeGreaterThan(0);
|
|
306
232
|
|
|
307
233
|
// TODO(dmaretskyi): Currently unable to deserialize.
|
|
@@ -350,18 +276,18 @@ describe('effect-to-json', () => {
|
|
|
350
276
|
const schema = TestSchema.EmployedBy;
|
|
351
277
|
const jsonSchema = toJsonSchema(schema);
|
|
352
278
|
expect(jsonSchema).toEqual({
|
|
353
|
-
$id: 'dxn:type:
|
|
279
|
+
$id: 'dxn:com.example.type.employedBy:0.1.0',
|
|
354
280
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
355
281
|
entityKind: 'relation',
|
|
356
|
-
typename: 'example.
|
|
282
|
+
typename: 'com.example.type.employedBy',
|
|
357
283
|
version: '0.1.0',
|
|
358
284
|
relationSource: {
|
|
359
285
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
360
|
-
$ref: 'dxn:
|
|
286
|
+
$ref: 'dxn:com.example.type.person',
|
|
361
287
|
},
|
|
362
288
|
relationTarget: {
|
|
363
289
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
364
|
-
$ref: 'dxn:
|
|
290
|
+
$ref: 'dxn:com.example.type.organization',
|
|
365
291
|
},
|
|
366
292
|
type: 'object',
|
|
367
293
|
properties: {
|
|
@@ -385,19 +311,13 @@ describe('effect-to-json', () => {
|
|
|
385
311
|
const Organization = Schema.Struct({
|
|
386
312
|
id: ObjectId,
|
|
387
313
|
name: Schema.String,
|
|
388
|
-
}).pipe(
|
|
389
|
-
EchoObjectSchema({
|
|
390
|
-
typename: 'example.com/type/Organization',
|
|
391
|
-
version: '0.1.0',
|
|
392
|
-
}),
|
|
393
|
-
LabelAnnotation.set(['name']),
|
|
394
|
-
);
|
|
314
|
+
}).pipe(LabelAnnotation.set(['name']), EchoObjectSchema(DXN.make('com.example.type.organization', '0.1.0')));
|
|
395
315
|
|
|
396
316
|
const jsonSchema = toJsonSchema(Organization);
|
|
397
317
|
expect(jsonSchema).toEqual({
|
|
398
|
-
$id: 'dxn:type:
|
|
318
|
+
$id: 'dxn:com.example.type.organization:0.1.0',
|
|
399
319
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
400
|
-
typename: 'example.
|
|
320
|
+
typename: 'com.example.type.organization',
|
|
401
321
|
version: '0.1.0',
|
|
402
322
|
entityKind: 'object',
|
|
403
323
|
type: 'object',
|
|
@@ -468,7 +388,7 @@ describe('effect-to-json', () => {
|
|
|
468
388
|
const expectReferenceAnnotation = (object: JsonSchemaType) => {
|
|
469
389
|
expect(object.reference).to.deep.eq({
|
|
470
390
|
schema: {
|
|
471
|
-
$ref: 'dxn:
|
|
391
|
+
$ref: 'dxn:com.example.type.testNested',
|
|
472
392
|
},
|
|
473
393
|
schemaVersion: '0.1.0',
|
|
474
394
|
});
|
|
@@ -495,12 +415,7 @@ describe('json-to-effect', () => {
|
|
|
495
415
|
test(`deserialized equals original ${partial ? 'with partial' : ''}`, () => {
|
|
496
416
|
const Organization = Schema.Struct({
|
|
497
417
|
field: Schema.String,
|
|
498
|
-
}).pipe(
|
|
499
|
-
Type.object({
|
|
500
|
-
typename: 'example.com/type/Organization',
|
|
501
|
-
version: '0.1.0',
|
|
502
|
-
}),
|
|
503
|
-
);
|
|
418
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
504
419
|
|
|
505
420
|
const fields = {
|
|
506
421
|
string: Schema.String,
|
|
@@ -517,10 +432,7 @@ describe('json-to-effect', () => {
|
|
|
517
432
|
} as const;
|
|
518
433
|
|
|
519
434
|
const Test = (partial ? Schema.partial(Schema.Struct(fields)) : Schema.Struct(fields)).pipe(
|
|
520
|
-
Type.
|
|
521
|
-
typename: 'example.com/type/Test',
|
|
522
|
-
version: '0.1.0',
|
|
523
|
-
}),
|
|
435
|
+
Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
|
|
524
436
|
);
|
|
525
437
|
|
|
526
438
|
const jsonSchema = toJsonSchema(Test);
|
|
@@ -528,11 +440,12 @@ describe('json-to-effect', () => {
|
|
|
528
440
|
|
|
529
441
|
const schema = toEffectSchema(jsonSchema);
|
|
530
442
|
|
|
531
|
-
|
|
532
|
-
expect(() => expect(
|
|
533
|
-
expect(() => expect(
|
|
443
|
+
const testAst = Type.getSchema(Test).ast;
|
|
444
|
+
expect(() => expect(schema.ast).to.deep.eq(testAst)).to.throw();
|
|
445
|
+
expect(() => expect(prepareAstForCompare(testAst)).to.deep.eq(testAst)).to.throw();
|
|
446
|
+
expect(() => expect(schema.ast).to.deep.eq(prepareAstForCompare(testAst))).to.throw();
|
|
534
447
|
// log.info('', { original: prepareAstForCompare(Schema.ast), deserialized: prepareAstForCompare(schema.ast) });
|
|
535
|
-
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(
|
|
448
|
+
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(testAst));
|
|
536
449
|
|
|
537
450
|
// TODO(dmaretskyi): Fix.
|
|
538
451
|
// expect(
|
|
@@ -545,13 +458,13 @@ describe('json-to-effect', () => {
|
|
|
545
458
|
|
|
546
459
|
test('legacy schema with dxn:type $id gets decoded', () => {
|
|
547
460
|
const jsonSchema: JsonSchemaType = {
|
|
548
|
-
$id: 'dxn:type:example.
|
|
461
|
+
$id: 'dxn:type:com.example.type.project',
|
|
549
462
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
550
463
|
additionalProperties: false,
|
|
551
464
|
echo: {
|
|
552
465
|
type: {
|
|
553
466
|
schemaId: '01JERV1HQCQZDQ4NVCJ42QB38F',
|
|
554
|
-
typename: 'example.
|
|
467
|
+
typename: 'com.example.type.project',
|
|
555
468
|
version: '0.1.0',
|
|
556
469
|
},
|
|
557
470
|
},
|
|
@@ -577,10 +490,10 @@ describe('json-to-effect', () => {
|
|
|
577
490
|
const schema = toEffectSchema(jsonSchema);
|
|
578
491
|
expect(getTypeAnnotation(schema)).to.deep.eq({
|
|
579
492
|
kind: EntityKind.Object,
|
|
580
|
-
typename: 'example.
|
|
493
|
+
typename: 'com.example.type.project',
|
|
581
494
|
version: '0.1.0',
|
|
582
495
|
});
|
|
583
|
-
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('
|
|
496
|
+
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('echo:/01JERV1HQCQZDQ4NVCJ42QB38F');
|
|
584
497
|
});
|
|
585
498
|
|
|
586
499
|
test('symbol annotations get compared', () => {
|
|
@@ -603,7 +516,7 @@ describe('json-to-effect', () => {
|
|
|
603
516
|
const schema = TestSchema.HasManager;
|
|
604
517
|
const jsonSchema = toJsonSchema(schema);
|
|
605
518
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
606
|
-
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(schema.ast));
|
|
519
|
+
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(Type.getSchema(schema).ast));
|
|
607
520
|
});
|
|
608
521
|
|
|
609
522
|
test('generator annotation', () => {
|
|
@@ -715,7 +628,7 @@ describe('json-to-effect', () => {
|
|
|
715
628
|
"$ref": "/schemas/echo/ref",
|
|
716
629
|
"reference": {
|
|
717
630
|
"schema": {
|
|
718
|
-
"$ref": "dxn:
|
|
631
|
+
"$ref": "dxn:com.example.type.person",
|
|
719
632
|
},
|
|
720
633
|
"schemaVersion": "0.1.0",
|
|
721
634
|
},
|
|
@@ -736,9 +649,9 @@ describe('json-to-effect', () => {
|
|
|
736
649
|
test('object nested inside another struct', () => {
|
|
737
650
|
const Contact = Schema.Struct({
|
|
738
651
|
name: Schema.String,
|
|
739
|
-
}).pipe(EchoObjectSchema(
|
|
652
|
+
}).pipe(EchoObjectSchema(DXN.make('com.example.type.person', '0.1.0')));
|
|
740
653
|
const input = Schema.Struct({
|
|
741
|
-
contact: Contact,
|
|
654
|
+
contact: Type.getSchema(Contact),
|
|
742
655
|
});
|
|
743
656
|
const jsonSchema = toJsonSchema(input);
|
|
744
657
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
@@ -747,7 +660,7 @@ describe('json-to-effect', () => {
|
|
|
747
660
|
"additionalProperties": false,
|
|
748
661
|
"properties": {
|
|
749
662
|
"contact": {
|
|
750
|
-
"$id": "dxn:type:
|
|
663
|
+
"$id": "dxn:com.example.type.person:0.1.0",
|
|
751
664
|
"additionalProperties": false,
|
|
752
665
|
"entityKind": "object",
|
|
753
666
|
"properties": {
|
|
@@ -767,7 +680,7 @@ describe('json-to-effect', () => {
|
|
|
767
680
|
"id",
|
|
768
681
|
],
|
|
769
682
|
"type": "object",
|
|
770
|
-
"typename": "example.
|
|
683
|
+
"typename": "com.example.type.person",
|
|
771
684
|
"version": "0.1.0",
|
|
772
685
|
},
|
|
773
686
|
},
|
|
@@ -796,7 +709,7 @@ describe('reference', () => {
|
|
|
796
709
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
797
710
|
reference: {
|
|
798
711
|
schema: {
|
|
799
|
-
$ref: 'dxn:
|
|
712
|
+
$ref: 'dxn:com.example.type.person',
|
|
800
713
|
},
|
|
801
714
|
schemaVersion: '0.1.0',
|
|
802
715
|
},
|
|
@@ -814,7 +727,7 @@ describe('reference', () => {
|
|
|
814
727
|
$ref: '/schemas/echo/ref',
|
|
815
728
|
reference: {
|
|
816
729
|
schema: {
|
|
817
|
-
$ref: 'dxn:
|
|
730
|
+
$ref: 'dxn:com.example.type.person',
|
|
818
731
|
},
|
|
819
732
|
schemaVersion: '0.1.0',
|
|
820
733
|
},
|
|
@@ -835,7 +748,7 @@ describe('reference', () => {
|
|
|
835
748
|
$ref: '/schemas/echo/ref',
|
|
836
749
|
reference: {
|
|
837
750
|
schema: {
|
|
838
|
-
$ref: 'dxn:
|
|
751
|
+
$ref: 'dxn:com.example.type.person',
|
|
839
752
|
},
|
|
840
753
|
schemaVersion: '0.1.0',
|
|
841
754
|
},
|
|
@@ -854,8 +767,8 @@ describe('reference', () => {
|
|
|
854
767
|
const deserializedSchema = toEffectSchema(jsonSchema);
|
|
855
768
|
const refAst = getReferenceAst(deserializedSchema.ast);
|
|
856
769
|
expect(refAst).toEqual({
|
|
857
|
-
typename: TestSchema.Person
|
|
858
|
-
version: TestSchema.Person
|
|
770
|
+
typename: Type.getTypename(TestSchema.Person),
|
|
771
|
+
version: Type.getVersion(TestSchema.Person),
|
|
859
772
|
});
|
|
860
773
|
});
|
|
861
774
|
});
|
|
@@ -13,19 +13,25 @@ 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 type * as Type from '../../Type';
|
|
20
21
|
import {
|
|
21
22
|
type TypeAnnotation,
|
|
22
23
|
TypeAnnotationId,
|
|
23
24
|
TypeIdentifierAnnotationId,
|
|
24
25
|
makeTypeJsonSchemaAnnotation,
|
|
25
|
-
} from '../
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
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';
|
|
29
35
|
import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
|
|
30
36
|
import {
|
|
31
37
|
ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,
|
|
@@ -82,11 +88,22 @@ export type JsonSchemaOptions = {
|
|
|
82
88
|
// We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
|
|
83
89
|
// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
|
|
84
90
|
export const toJsonSchema = (
|
|
85
|
-
schema: Schema.Schema.All,
|
|
91
|
+
schema: Schema.Schema.All | Type.AnyEntity,
|
|
86
92
|
options: JsonSchemaOptions = {},
|
|
87
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
|
+
}
|
|
88
105
|
assertArgument(Schema.isSchema(schema), 'schema');
|
|
89
|
-
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
106
|
+
let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);
|
|
90
107
|
if (options.strict) {
|
|
91
108
|
// TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).
|
|
92
109
|
jsonSchema = removeProperties(jsonSchema, (key, value) => {
|
|
@@ -341,9 +358,9 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
341
358
|
const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
342
359
|
// TODO(dmaretskyi): Is this branch still taken?
|
|
343
360
|
if ((echoRefinement as any)?.reference != null) {
|
|
344
|
-
const
|
|
361
|
+
const echoUri = root.$id.startsWith('echo:') || root.$id.startsWith('dxn:echo:') ? root.$id : undefined;
|
|
345
362
|
return createEchoReferenceSchema(
|
|
346
|
-
|
|
363
|
+
echoUri,
|
|
347
364
|
(echoRefinement as any).reference.typename,
|
|
348
365
|
(echoRefinement as any).reference.version,
|
|
349
366
|
);
|
|
@@ -364,14 +381,11 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
|
364
381
|
throw new Error('Invalid reference field in ref schema');
|
|
365
382
|
}
|
|
366
383
|
|
|
367
|
-
const
|
|
368
|
-
|
|
384
|
+
const ref = reference.schema.$ref;
|
|
385
|
+
const targetSchemaDXN = DXN.tryMake(ref);
|
|
386
|
+
invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);
|
|
369
387
|
|
|
370
|
-
return createEchoReferenceSchema(
|
|
371
|
-
targetSchemaDXN.toString(),
|
|
372
|
-
targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,
|
|
373
|
-
reference.schemaVersion,
|
|
374
|
-
);
|
|
388
|
+
return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
|
|
375
389
|
};
|
|
376
390
|
|
|
377
391
|
//
|
|
@@ -392,10 +406,11 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
392
406
|
schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
|
|
393
407
|
}
|
|
394
408
|
|
|
409
|
+
// For stored schemas the storage URI is the definitive identifier — it overrides
|
|
410
|
+
// the typename `$id` written above.
|
|
395
411
|
const echoIdentifier = annotations[TypeIdentifierAnnotationId];
|
|
396
412
|
if (echoIdentifier) {
|
|
397
|
-
schemaFields
|
|
398
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
413
|
+
schemaFields.$id = echoIdentifier;
|
|
399
414
|
}
|
|
400
415
|
|
|
401
416
|
// Custom (at end).
|
|
@@ -410,14 +425,14 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
410
425
|
};
|
|
411
426
|
|
|
412
427
|
const decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {
|
|
413
|
-
//
|
|
414
|
-
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:'))) {
|
|
415
430
|
return schema.$id;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
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;
|
|
421
436
|
}
|
|
422
437
|
return undefined;
|
|
423
438
|
};
|
|
@@ -434,8 +449,8 @@ const decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefine
|
|
|
434
449
|
if (annotation.kind === EntityKind.Relation) {
|
|
435
450
|
const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));
|
|
436
451
|
const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));
|
|
437
|
-
annotation.sourceSchema = DXN.
|
|
438
|
-
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}`));
|
|
439
454
|
}
|
|
440
455
|
|
|
441
456
|
return annotation;
|
|
@@ -465,11 +480,15 @@ const jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annota
|
|
|
465
480
|
}
|
|
466
481
|
}
|
|
467
482
|
|
|
468
|
-
|
|
483
|
+
const typeIdentifier = decodeTypeIdentifierAnnotation(schema);
|
|
484
|
+
annotations[TypeIdentifierAnnotationId] = typeIdentifier;
|
|
469
485
|
const typeAnnotation = decodeTypeAnnotation(schema);
|
|
470
486
|
if (typeAnnotation) {
|
|
471
487
|
annotations[TypeAnnotationId] = typeAnnotation;
|
|
472
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),
|
|
473
492
|
kind: typeAnnotation.kind,
|
|
474
493
|
typename: typeAnnotation.typename,
|
|
475
494
|
version: typeAnnotation.version,
|
|
@@ -6,9 +6,9 @@ import { invariant } from '@dxos/invariant';
|
|
|
6
6
|
import { deepMapValues } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
import type * as Obj from '../../Obj';
|
|
9
|
-
import { makeObject } from '../proxy';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { makeObject } from '../common/proxy';
|
|
10
|
+
import { getMeta, getSchema, getStaticTypeSchema, getType } from '../common/types';
|
|
11
|
+
import { Ref } from '../Ref';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Clones an object or relation.
|
|
@@ -17,8 +17,12 @@ import { getMeta, getSchema } from '../types';
|
|
|
17
17
|
*/
|
|
18
18
|
export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T => {
|
|
19
19
|
const { id, ...data } = obj;
|
|
20
|
-
|
|
21
|
-
|
|
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');
|
|
22
26
|
const props: any = deepMapValues(data, (value, recurse) => {
|
|
23
27
|
if (Ref.isRef(value)) {
|
|
24
28
|
if (opts?.deep) {
|
|
@@ -44,5 +48,5 @@ export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T =>
|
|
|
44
48
|
return recurse(value);
|
|
45
49
|
});
|
|
46
50
|
|
|
47
|
-
return makeObject(schema, props, meta);
|
|
51
|
+
return makeObject(schema, props, meta, typeEntity as object | undefined);
|
|
48
52
|
};
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { getTypename } from '../
|
|
8
|
-
import { type AnyProperties } from '../types';
|
|
7
|
+
import { getTypename } from '../Annotation';
|
|
8
|
+
import { type AnyProperties } from '../common/types';
|
|
9
9
|
|
|
10
10
|
// TODO(dmaretskyi): Rename to represent commonality between objects and relations (e.g. `entity`).
|
|
11
11
|
export type TypedObjectOptions = {
|