@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
package/src/Query.ts
CHANGED
|
@@ -2,16 +2,27 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
5
7
|
import type * as EffectArray from 'effect/Array';
|
|
6
8
|
import type * as Schema from 'effect/Schema';
|
|
7
9
|
|
|
8
10
|
import { type QueryAST } from '@dxos/echo-protocol';
|
|
9
11
|
|
|
12
|
+
import type * as Collection from './Collection';
|
|
13
|
+
import * as Database from './Database';
|
|
14
|
+
import type * as Dataset from './Dataset';
|
|
15
|
+
import type * as Entity from './Entity';
|
|
16
|
+
import * as Feed from './Feed';
|
|
10
17
|
import * as Filter from './Filter';
|
|
11
|
-
import
|
|
18
|
+
import * as internal from './internal';
|
|
19
|
+
import * as Obj from './Obj';
|
|
12
20
|
import type * as Order from './Order';
|
|
13
21
|
import type * as Ref from './Ref';
|
|
22
|
+
import type * as Relation from './Relation';
|
|
23
|
+
// eslint-disable-next-line @dxos/rules/import-as-namespace
|
|
14
24
|
import type * as Type$ from './Type';
|
|
25
|
+
import type * as View from './View';
|
|
15
26
|
|
|
16
27
|
// TODO(dmaretskyi): Split up into interfaces for objects and relations so they can have separate verbs.
|
|
17
28
|
// TODO(dmaretskyi): Undirected relation traversals.
|
|
@@ -35,15 +46,15 @@ export interface Query<T> {
|
|
|
35
46
|
* @param filter - Filter to select the objects.
|
|
36
47
|
* @returns Query for the selected objects.
|
|
37
48
|
*/
|
|
38
|
-
select(filter: Filter.Filter<T>): Query<T>;
|
|
39
|
-
select(props: Filter.Props<T>): Query<T>;
|
|
49
|
+
'select'(filter: Filter.Filter<T>): Query<T>;
|
|
50
|
+
'select'(props: Filter.Props<T>): Query<T>;
|
|
40
51
|
|
|
41
52
|
/**
|
|
42
53
|
* Traverse an outgoing reference.
|
|
43
54
|
* @param key - Property path inside T that is a reference or optional reference.
|
|
44
55
|
* @returns Query for the target of the reference.
|
|
45
56
|
*/
|
|
46
|
-
reference<K extends RefPropKey<T>>(
|
|
57
|
+
'reference'<K extends RefPropKey<T>>(
|
|
47
58
|
key: K,
|
|
48
59
|
): Query<
|
|
49
60
|
T[K] extends Ref.Unknown
|
|
@@ -61,12 +72,12 @@ export interface Query<T> {
|
|
|
61
72
|
*/
|
|
62
73
|
// TODO(dmaretskyi): any way to enforce `Ref.Target<Schema.Schema.Type<S>[key]> == T`?
|
|
63
74
|
// TODO(dmaretskyi): Ability to go through arrays of references.
|
|
64
|
-
referencedBy<S extends
|
|
75
|
+
'referencedBy'<S extends Type$.AnyEntity>(
|
|
65
76
|
target: S | string,
|
|
66
|
-
key: RefPropKey<
|
|
67
|
-
): Query<
|
|
68
|
-
referencedBy<S extends
|
|
69
|
-
referencedBy(): Query<any>;
|
|
77
|
+
key: RefPropKey<Type$.InstanceType<S>>,
|
|
78
|
+
): Query<Type$.InstanceType<S>>;
|
|
79
|
+
'referencedBy'<S extends Type$.AnyEntity>(target: S | string): Query<Type$.InstanceType<S>>;
|
|
80
|
+
'referencedBy'(): Query<any>;
|
|
70
81
|
|
|
71
82
|
/**
|
|
72
83
|
* Find relations where this object is the source.
|
|
@@ -74,45 +85,45 @@ export interface Query<T> {
|
|
|
74
85
|
* @param relation - Schema of the relation.
|
|
75
86
|
* @param predicates - Predicates to filter the relation objects.
|
|
76
87
|
*/
|
|
77
|
-
sourceOf<
|
|
78
|
-
relation
|
|
79
|
-
predicates?: Filter.Props<
|
|
80
|
-
): Query<
|
|
88
|
+
'sourceOf'<R extends Type$.AnyRelation>(
|
|
89
|
+
relation?: R | string,
|
|
90
|
+
predicates?: Filter.Props<Type$.InstanceType<R>>,
|
|
91
|
+
): Query<Type$.InstanceType<R>>;
|
|
81
92
|
|
|
82
93
|
/**
|
|
83
94
|
* Find relations where this object is the target.
|
|
84
95
|
* @returns Query for the relation objects.
|
|
85
|
-
* @param relation -
|
|
96
|
+
* @param relation - Type entity of the relation.
|
|
86
97
|
* @param predicates - Predicates to filter the relation objects.
|
|
87
98
|
*/
|
|
88
|
-
targetOf<
|
|
89
|
-
relation
|
|
90
|
-
predicates?: Filter.Props<
|
|
91
|
-
): Query<
|
|
99
|
+
'targetOf'<R extends Type$.AnyRelation>(
|
|
100
|
+
relation?: R | string,
|
|
101
|
+
predicates?: Filter.Props<Type$.InstanceType<R>>,
|
|
102
|
+
): Query<Type$.InstanceType<R>>;
|
|
92
103
|
|
|
93
104
|
/**
|
|
94
105
|
* For a query for relations, get the source objects.
|
|
95
106
|
* @returns Query for the source objects.
|
|
96
107
|
*/
|
|
97
|
-
source(): Query<
|
|
108
|
+
'source'(): Query<Relation.SourceOf<T>>;
|
|
98
109
|
|
|
99
110
|
/**
|
|
100
111
|
* For a query for relations, get the target objects.
|
|
101
112
|
* @returns Query for the target objects.
|
|
102
113
|
*/
|
|
103
|
-
target(): Query<
|
|
114
|
+
'target'(): Query<Relation.TargetOf<T>>;
|
|
104
115
|
|
|
105
116
|
/**
|
|
106
117
|
* Get the parent object of the current selection.
|
|
107
118
|
* @returns Query for the parent objects.
|
|
108
119
|
*/
|
|
109
|
-
parent(): Query<any>;
|
|
120
|
+
'parent'(): Query<any>;
|
|
110
121
|
|
|
111
122
|
/**
|
|
112
123
|
* Get all child objects of the current selection.
|
|
113
124
|
* @returns Query for the child objects.
|
|
114
125
|
*/
|
|
115
|
-
children(): Query<any>;
|
|
126
|
+
'children'(): Query<any>;
|
|
116
127
|
|
|
117
128
|
/**
|
|
118
129
|
* Order the query results.
|
|
@@ -120,19 +131,90 @@ export interface Query<T> {
|
|
|
120
131
|
* @param order - Order to sort the results.
|
|
121
132
|
* @returns Query for the ordered results.
|
|
122
133
|
*/
|
|
123
|
-
orderBy(...order: EffectArray.NonEmptyArray<Order.Order<T>>): Query<T>;
|
|
134
|
+
'orderBy'(...order: EffectArray.NonEmptyArray<Order.Order<T>>): Query<T>;
|
|
124
135
|
|
|
125
136
|
/**
|
|
126
137
|
* Limit the number of results.
|
|
127
138
|
* @param limit - Maximum number of results to return.
|
|
128
139
|
* @returns Query for the limited results.
|
|
129
140
|
*/
|
|
130
|
-
limit(limit: number): Query<T>;
|
|
141
|
+
'limit'(limit: number): Query<T>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Query from selected databases only.
|
|
145
|
+
*
|
|
146
|
+
* Example:
|
|
147
|
+
*
|
|
148
|
+
* ```ts
|
|
149
|
+
* Query.select(Filter.type(Person)).from(db);
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
|
|
153
|
+
*/
|
|
154
|
+
'from'(database: Database.Database | Database.Database[], options?: { includeFeeds?: boolean }): Query<T>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Query from selected feeds only.
|
|
158
|
+
*
|
|
159
|
+
* Example:
|
|
160
|
+
*
|
|
161
|
+
* ```ts
|
|
162
|
+
* Query.select(Filter.type(Person)).from(feed);
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
'from'(feeds: Feed.Feed | Feed.Feed[]): Query<T>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Query from all accessible spaces.
|
|
170
|
+
*
|
|
171
|
+
* Example:
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* Query.select(Filter.type(Person)).from('all-accessible-spaces');
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
|
|
178
|
+
*/
|
|
179
|
+
'from'(allSpaces: 'all-accessible-spaces', options?: { includeFeeds?: boolean }): Query<T>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Query from a dataset.
|
|
183
|
+
* Currently only feeds are supported.
|
|
184
|
+
*
|
|
185
|
+
* Example:
|
|
186
|
+
*
|
|
187
|
+
* ```ts
|
|
188
|
+
* Query.type(Person).from(feed);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
'from'(dataset: Dataset.Dataset): Query<T>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Query from the results of another query.
|
|
195
|
+
*
|
|
196
|
+
* Example:
|
|
197
|
+
*
|
|
198
|
+
* ```ts
|
|
199
|
+
* Query.select(Filter.props({ foo: 'foo' })).from(Query.select(Filter.type(Contact)).reference('org'));
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
'from'(query: Any): Query<T>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Query from a raw scope specification.
|
|
206
|
+
*/
|
|
207
|
+
'from'(scope: QueryAST.Scope): Query<T>;
|
|
131
208
|
|
|
132
209
|
/**
|
|
133
210
|
* Add options to a query.
|
|
134
211
|
*/
|
|
135
|
-
options(options: QueryAST.QueryOptions): Query<T>;
|
|
212
|
+
'options'(options: QueryAST.QueryOptions): Query<T>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Attach a diagnostic label for logs and tooling (execution semantics unchanged).
|
|
216
|
+
*/
|
|
217
|
+
'debugLabel'(label: string): Query<T>;
|
|
136
218
|
}
|
|
137
219
|
|
|
138
220
|
export type Any = Query<any>;
|
|
@@ -140,7 +222,7 @@ export type Any = Query<any>;
|
|
|
140
222
|
export type Type<Q extends Any> = Q extends Query<infer T> ? T : never;
|
|
141
223
|
|
|
142
224
|
class QueryClass implements Any {
|
|
143
|
-
private static variance: Any['~Query'] = {} as Any['~Query'];
|
|
225
|
+
private static 'variance': Any['~Query'] = {} as Any['~Query'];
|
|
144
226
|
|
|
145
227
|
constructor(public readonly ast: QueryAST.Query) {}
|
|
146
228
|
|
|
@@ -170,31 +252,31 @@ class QueryClass implements Any {
|
|
|
170
252
|
});
|
|
171
253
|
}
|
|
172
254
|
|
|
173
|
-
referencedBy(target?:
|
|
174
|
-
const
|
|
255
|
+
referencedBy(target?: Type$.AnyEntity | string, key?: string): Any {
|
|
256
|
+
const uri = target !== undefined ? internal.getTypeURIFromSpecifier(target) : null;
|
|
175
257
|
return new QueryClass({
|
|
176
258
|
type: 'incoming-references',
|
|
177
259
|
anchor: this.ast,
|
|
178
260
|
property: key ?? null,
|
|
179
|
-
typename:
|
|
261
|
+
typename: uri ?? null,
|
|
180
262
|
});
|
|
181
263
|
}
|
|
182
264
|
|
|
183
|
-
sourceOf(relation
|
|
265
|
+
sourceOf(relation?: Type$.AnyRelation | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
184
266
|
return new QueryClass({
|
|
185
267
|
type: 'relation',
|
|
186
268
|
anchor: this.ast,
|
|
187
269
|
direction: 'outgoing',
|
|
188
|
-
filter: Filter.type(relation, predicates).ast,
|
|
270
|
+
filter: relation !== undefined ? Filter.type(relation, predicates).ast : undefined,
|
|
189
271
|
});
|
|
190
272
|
}
|
|
191
273
|
|
|
192
|
-
targetOf(relation
|
|
274
|
+
targetOf(relation?: Type$.AnyRelation | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
193
275
|
return new QueryClass({
|
|
194
276
|
type: 'relation',
|
|
195
277
|
anchor: this.ast,
|
|
196
278
|
direction: 'incoming',
|
|
197
|
-
filter: Filter.type(relation, predicates).ast,
|
|
279
|
+
filter: relation !== undefined ? Filter.type(relation, predicates).ast : undefined,
|
|
198
280
|
});
|
|
199
281
|
}
|
|
200
282
|
|
|
@@ -246,6 +328,113 @@ class QueryClass implements Any {
|
|
|
246
328
|
});
|
|
247
329
|
}
|
|
248
330
|
|
|
331
|
+
from(
|
|
332
|
+
arg:
|
|
333
|
+
| Database.Database
|
|
334
|
+
| Database.Database[]
|
|
335
|
+
| Feed.Feed
|
|
336
|
+
| Feed.Feed[]
|
|
337
|
+
| Collection.Collection
|
|
338
|
+
| View.View
|
|
339
|
+
| Any
|
|
340
|
+
| QueryAST.Scope
|
|
341
|
+
| 'all-accessible-spaces',
|
|
342
|
+
options?: { includeFeeds?: boolean },
|
|
343
|
+
): Any {
|
|
344
|
+
if (arg == null) {
|
|
345
|
+
throw new TypeError(
|
|
346
|
+
'Query.from() requires a valid data source argument (database, feed, query, scope, or "all-accessible-spaces").',
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (is(arg)) {
|
|
351
|
+
return new QueryClass({
|
|
352
|
+
type: 'from',
|
|
353
|
+
query: this.ast,
|
|
354
|
+
from: { _tag: 'query', query: arg.ast },
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (arg === 'all-accessible-spaces') {
|
|
359
|
+
return new QueryClass({
|
|
360
|
+
type: 'from',
|
|
361
|
+
query: this.ast,
|
|
362
|
+
from: {
|
|
363
|
+
_tag: 'scope',
|
|
364
|
+
scope: {
|
|
365
|
+
...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (_isScope(arg)) {
|
|
372
|
+
return new QueryClass({
|
|
373
|
+
type: 'from',
|
|
374
|
+
query: this.ast,
|
|
375
|
+
from: { _tag: 'scope', scope: arg },
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const items = Array.isArray(arg) ? arg : [arg];
|
|
380
|
+
|
|
381
|
+
if (items.length > 0 && Database.isDatabase(items[0])) {
|
|
382
|
+
const databases = items as Database.Database[];
|
|
383
|
+
return new QueryClass({
|
|
384
|
+
type: 'from',
|
|
385
|
+
query: this.ast,
|
|
386
|
+
from: {
|
|
387
|
+
_tag: 'scope',
|
|
388
|
+
scope: {
|
|
389
|
+
spaceIds: databases.map((db) => db.spaceId),
|
|
390
|
+
...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (items.length > 0) {
|
|
397
|
+
const typename = Obj.getTypename(items[0] as Obj.Unknown);
|
|
398
|
+
// TODO(dmaretskyi): Support querying from views.
|
|
399
|
+
if (typename === 'org.dxos.type.view') {
|
|
400
|
+
throw new Error('Query.from(view) is not yet supported.');
|
|
401
|
+
}
|
|
402
|
+
// TODO(dmaretskyi): Support querying from collections.
|
|
403
|
+
if (typename === 'org.dxos.type.collection') {
|
|
404
|
+
throw new Error('Query.from(collection) is not yet supported.');
|
|
405
|
+
}
|
|
406
|
+
// Validate that the items are Feed.Feed instances.
|
|
407
|
+
for (const item of items) {
|
|
408
|
+
if (!Obj.instanceOf(Feed.Feed, item)) {
|
|
409
|
+
throw new TypeError(
|
|
410
|
+
`Query.from() expects Feed objects (org.dxos.type.feed), but received an object with typename '${typename ?? 'unknown'}'.`,
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const feedItems = items as Feed.Feed[];
|
|
417
|
+
const feedUris = feedItems.map((feed) => {
|
|
418
|
+
const uri = Feed.getQueueUri(feed);
|
|
419
|
+
if (!uri) {
|
|
420
|
+
throw new TypeError(
|
|
421
|
+
`Query.from() expects persisted Feed objects with a queue URI; got feed without a space (id=${Obj.getURI(feed)}).`,
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
return uri;
|
|
425
|
+
});
|
|
426
|
+
return new QueryClass({
|
|
427
|
+
type: 'from',
|
|
428
|
+
query: this.ast,
|
|
429
|
+
from: {
|
|
430
|
+
_tag: 'scope',
|
|
431
|
+
scope: {
|
|
432
|
+
feeds: feedUris,
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
249
438
|
options(options: QueryAST.QueryOptions): Any {
|
|
250
439
|
return new QueryClass({
|
|
251
440
|
type: 'options',
|
|
@@ -253,6 +442,21 @@ class QueryClass implements Any {
|
|
|
253
442
|
options,
|
|
254
443
|
});
|
|
255
444
|
}
|
|
445
|
+
|
|
446
|
+
debugLabel(label: string): Any {
|
|
447
|
+
if (this.ast.type === 'options') {
|
|
448
|
+
return new QueryClass({
|
|
449
|
+
type: 'options',
|
|
450
|
+
query: this.ast.query,
|
|
451
|
+
options: { ...this.ast.options, debugLabel: label },
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
return new QueryClass({
|
|
455
|
+
type: 'options',
|
|
456
|
+
query: this.ast,
|
|
457
|
+
options: { debugLabel: label },
|
|
458
|
+
});
|
|
459
|
+
}
|
|
256
460
|
}
|
|
257
461
|
|
|
258
462
|
export const is = (value: unknown): value is Any => {
|
|
@@ -284,10 +488,30 @@ export const select = <F extends Filter.Any>(filter: F): Query<Filter.Type<F>> =
|
|
|
284
488
|
*
|
|
285
489
|
* Shorthand for: `Query.select(Filter.type(schema, predicates))`.
|
|
286
490
|
*/
|
|
287
|
-
|
|
491
|
+
/**
|
|
492
|
+
* Instance type for a query over `type`. Falls back to `Entity.Unknown` when the
|
|
493
|
+
* type can't be narrowed — e.g. the caller passes the wide `Type.AnyEntity` — so
|
|
494
|
+
* results aren't typed as the useless bare `OfKind<...>` union that
|
|
495
|
+
* `Type.InstanceType<Type.AnyEntity>` produces.
|
|
496
|
+
*/
|
|
497
|
+
type QueryInstance<T extends Type$.AnyEntity> = Type$.AnyEntity extends T ? Entity.Unknown : Type$.InstanceType<T>;
|
|
498
|
+
|
|
499
|
+
export const type: {
|
|
500
|
+
<T extends Type$.AnyEntity>(type: T, predicates?: Filter.Props<QueryInstance<T>>): Query<QueryInstance<T>>;
|
|
501
|
+
// Brand-narrowed schema overload — only well-known unknown schemas pass.
|
|
502
|
+
<S extends internal.UnknownTypeSchema<any, any>>(
|
|
503
|
+
schema: S,
|
|
504
|
+
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
505
|
+
): Query<Schema.Schema.Type<S>>;
|
|
506
|
+
<S extends Schema.Union<readonly Schema.Schema.AnyNoContext[]>>(
|
|
507
|
+
union: S,
|
|
508
|
+
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
509
|
+
): Query<Schema.Schema.Type<S>>;
|
|
510
|
+
(schema: string, predicates?: Filter.Props<unknown>): Query<any>;
|
|
511
|
+
} = (type: Type$.AnyEntity | string, predicates?: Filter.Props<unknown>): Any => {
|
|
288
512
|
return new QueryClass({
|
|
289
513
|
type: 'select',
|
|
290
|
-
filter: Filter.type(
|
|
514
|
+
filter: Filter.type(type, predicates).ast,
|
|
291
515
|
});
|
|
292
516
|
};
|
|
293
517
|
|
|
@@ -322,3 +546,44 @@ export const without = <T>(source: Query<T>, exclude: Query<T>): Query<T> => {
|
|
|
322
546
|
exclude: exclude.ast,
|
|
323
547
|
});
|
|
324
548
|
};
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Create a query scoped to a data source.
|
|
552
|
+
* The returned query selects everything from the source; chain `.select()` to narrow results.
|
|
553
|
+
*
|
|
554
|
+
* @param source - Data source: database, feed, 'all-accessible-spaces', or another query.
|
|
555
|
+
* @returns Query scoped to the given source.
|
|
556
|
+
*/
|
|
557
|
+
export const from = (
|
|
558
|
+
source:
|
|
559
|
+
| Database.Database
|
|
560
|
+
| Database.Database[]
|
|
561
|
+
| Feed.Feed
|
|
562
|
+
| Feed.Feed[]
|
|
563
|
+
| Any
|
|
564
|
+
| QueryAST.Scope
|
|
565
|
+
| 'all-accessible-spaces',
|
|
566
|
+
options?: { includeFeeds?: boolean },
|
|
567
|
+
): Any => {
|
|
568
|
+
const baseQuery: QueryAST.Query = {
|
|
569
|
+
type: 'select',
|
|
570
|
+
filter: Filter.everything().ast,
|
|
571
|
+
};
|
|
572
|
+
const wrapper = new QueryClass(baseQuery);
|
|
573
|
+
return wrapper.from(source as any, options);
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
const SCOPE_KEYS = new Set(['spaceIds', 'feeds', 'allFeedsFromSpaces']);
|
|
577
|
+
|
|
578
|
+
/** Detect a raw Scope object (plain object with only Scope-valid keys). */
|
|
579
|
+
const _isScope = (value: unknown): value is QueryAST.Scope => {
|
|
580
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
return Object.keys(value).every((key) => SCOPE_KEYS.has(key));
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Returns a human-readable string representation of a Query AST.
|
|
588
|
+
*/
|
|
589
|
+
export const pretty = (query: Any): string => internal.prettyQuery(query.ast);
|
package/src/Ref.ts
CHANGED
|
@@ -2,42 +2,113 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
5
7
|
import * as Option from 'effect/Option';
|
|
8
|
+
import type * as Schema from 'effect/Schema';
|
|
6
9
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
10
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
11
|
+
import { type URI } from '@dxos/keys';
|
|
12
|
+
|
|
13
|
+
import type * as Entity from './Entity';
|
|
14
|
+
import type * as internal from './internal';
|
|
15
|
+
import * as refInternal from './internal/Ref';
|
|
10
16
|
import type * as JsonSchema from './JsonSchema';
|
|
11
17
|
import type * as Obj from './Obj';
|
|
18
|
+
// eslint-disable-next-line @dxos/rules/import-as-namespace
|
|
19
|
+
import type * as TypeNs from './Type';
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Instance type for a reference.
|
|
23
|
+
*
|
|
24
|
+
* Reference can point to any object or relation.
|
|
25
|
+
* References are lazy loaded.
|
|
26
|
+
*
|
|
27
|
+
* `ref.dxn` is the DXN of the referenced object.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const taskRef: Ref<Task> = Ref.make(task);
|
|
32
|
+
*
|
|
33
|
+
* await taskRef.load(); // Returns Promise<Task>
|
|
34
|
+
* yield* Database.load(taskRef); // Effectful version.
|
|
35
|
+
*
|
|
36
|
+
* database.makeRef(dxn); // Create a ref from a DXN.
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export type Ref<T> = refInternal.Ref<T>;
|
|
40
|
+
export type Unknown = refInternal.Ref<Obj.Unknown>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Factory function to create a Ref schema for the given target schema.
|
|
44
|
+
* Use this in schema definitions to declare reference fields.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const Task = Schema.Struct({
|
|
49
|
+
* assignee: Ref.Ref(Person), // Creates a Ref schema
|
|
50
|
+
* }).pipe(Type.makeObject(DXN.make('com.example.type.task', '0.1.0')));
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export const Ref: {
|
|
54
|
+
<S extends TypeNs.AnyObj | TypeNs.AnyRelation>(type: S): RefSchema<TypeNs.InstanceType<S> & Obj.Unknown>;
|
|
15
55
|
|
|
16
|
-
|
|
56
|
+
// `Type.Type` entities (the meta-schema kind) can be referenced too — e.g. a
|
|
57
|
+
// trigger that points to a stored function/workflow definition.
|
|
58
|
+
<T extends TypeNs.Type<any>>(type: T): RefSchema<TypeNs.InstanceType<T>>;
|
|
59
|
+
|
|
60
|
+
// Schema-side overload for the well-known "any object" / "any relation" schemas.
|
|
61
|
+
// Other raw `Schema.Schema` values are intentionally rejected — callers should
|
|
62
|
+
// pass a `Type.Type` entity instead.
|
|
63
|
+
<S extends internal.UnknownTypeSchema<any, any>>(schema: S): RefSchema<Schema.Schema.Type<S> & Obj.Unknown>;
|
|
64
|
+
} = refInternal.Ref as any;
|
|
65
|
+
|
|
66
|
+
export const Array = refInternal.RefArray;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* TypeScript type for a Ref schema.
|
|
70
|
+
* This is the type of the SCHEMA itself, not the runtime ref instance.
|
|
71
|
+
* For the instance type, use `Ref.Ref<T>` from the Ref module.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* // Schema type annotation (rarely needed, usually inferred):
|
|
76
|
+
* const refSchema: Ref.RefSchema<typeof Task> = Ref.Ref(Task);
|
|
77
|
+
*
|
|
78
|
+
* // Instance type annotation (use Ref.Ref instead):
|
|
79
|
+
* const refInstance: Ref.Ref<Task> = Ref.make(task);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
// TODO(dmaretskyi): Investigate if we can remove this type.
|
|
83
|
+
// Post DX-836 it will become just `Schema.Schema<Ref.Ref<T>>`.
|
|
84
|
+
// NOTE: This could be Type.Ref<T> instead, but since it going to be removed, it's better to keep it here, self-contained.
|
|
85
|
+
export interface RefSchema<T extends Entity.Unknown> extends refInternal.RefSchema<T> {}
|
|
17
86
|
|
|
18
87
|
/**
|
|
19
88
|
* Extract reference target.
|
|
20
89
|
*/
|
|
21
|
-
export type Target<R extends Unknown> = R extends Ref
|
|
90
|
+
export type Target<R extends Unknown> = R extends refInternal.Ref<infer T> ? T : never;
|
|
22
91
|
|
|
23
92
|
/**
|
|
24
93
|
* Reference resolver.
|
|
25
94
|
*/
|
|
26
|
-
export type Resolver = RefResolver;
|
|
95
|
+
export type Resolver = refInternal.RefResolver;
|
|
96
|
+
|
|
97
|
+
export const isRef: (value: unknown) => value is Unknown = refInternal.Ref.isRef;
|
|
27
98
|
|
|
28
|
-
export const
|
|
99
|
+
export const make = refInternal.Ref.make;
|
|
29
100
|
|
|
30
|
-
|
|
101
|
+
// TODO(dmaretskyi): Consider just allowing `make` to accept URI.
|
|
102
|
+
export const fromURI = (uri: URI.URI): refInternal.Ref<any> => refInternal.Ref.fromURI(uri);
|
|
31
103
|
|
|
32
|
-
|
|
33
|
-
export const fromDXN = Ref$.fromDXN;
|
|
104
|
+
export const hasObjectId = refInternal.Ref.hasObjectId;
|
|
34
105
|
|
|
35
106
|
// TODO(wittjosiah): Factor out?
|
|
36
107
|
export const isRefType = (ast: SchemaAST.AST): boolean => {
|
|
37
108
|
return SchemaAST.getAnnotation<JsonSchema.JsonSchema>(ast, SchemaAST.JSONSchemaAnnotationId).pipe(
|
|
38
109
|
Option.flatMap((jsonSchema) => ('$id' in jsonSchema ? Option.some(jsonSchema) : Option.none())),
|
|
39
110
|
Option.flatMap((jsonSchema) => {
|
|
40
|
-
const { typename } = getSchemaReference(jsonSchema) ?? {};
|
|
111
|
+
const { typename } = refInternal.getSchemaReference(jsonSchema) ?? {};
|
|
41
112
|
return typename ? Option.some(true) : Option.some(false);
|
|
42
113
|
}),
|
|
43
114
|
Option.getOrElse(() => false),
|
package/src/Relation.test.ts
CHANGED
|
@@ -25,6 +25,12 @@ describe('Relation', () => {
|
|
|
25
25
|
expect(snapshot[SnapshotKindId]).toBe(Entity.Kind.Relation);
|
|
26
26
|
expect((snapshot as any)[Entity.KindId]).toBeUndefined();
|
|
27
27
|
|
|
28
|
+
expect(Relation.isSnapshot(snapshot)).toBe(true);
|
|
29
|
+
expect(Obj.isSnapshot(snapshot)).toBe(false);
|
|
30
|
+
|
|
31
|
+
expect(Relation.getSource(snapshot)).toEqual(obj1);
|
|
32
|
+
expect(Relation.getTarget(snapshot)).toEqual(obj2);
|
|
33
|
+
|
|
28
34
|
// Snapshot has same id.
|
|
29
35
|
expect(snapshot.id).toBe(rel.id);
|
|
30
36
|
});
|
|
@@ -38,13 +44,13 @@ describe('Relation', () => {
|
|
|
38
44
|
});
|
|
39
45
|
const snapshot = Relation.getSnapshot(rel);
|
|
40
46
|
|
|
41
|
-
//
|
|
42
|
-
expect(Relation.
|
|
43
|
-
expect(Relation.
|
|
47
|
+
// getSourceURI - works with both.
|
|
48
|
+
expect(Relation.getSourceURI(rel)).toBeDefined();
|
|
49
|
+
expect(Relation.getSourceURI(snapshot)).toBeDefined();
|
|
44
50
|
|
|
45
|
-
//
|
|
46
|
-
expect(Relation.
|
|
47
|
-
expect(Relation.
|
|
51
|
+
// getTargetURI - works with both.
|
|
52
|
+
expect(Relation.getTargetURI(rel)).toBeDefined();
|
|
53
|
+
expect(Relation.getTargetURI(snapshot)).toBeDefined();
|
|
48
54
|
|
|
49
55
|
// getSource - works with both.
|
|
50
56
|
expect(Relation.getSource(rel)).toBeDefined();
|
|
@@ -55,12 +61,12 @@ describe('Relation', () => {
|
|
|
55
61
|
expect(Relation.getTarget(snapshot)).toBeDefined();
|
|
56
62
|
|
|
57
63
|
// getDXN - works with both.
|
|
58
|
-
expect(Relation.
|
|
59
|
-
expect(Relation.
|
|
64
|
+
expect(Relation.getURI(rel)).toBeDefined();
|
|
65
|
+
expect(Relation.getURI(snapshot)).toBeDefined();
|
|
60
66
|
|
|
61
67
|
// getTypename - works with both.
|
|
62
|
-
expect(Relation.getTypename(rel)).toBe('example.
|
|
63
|
-
expect(Relation.getTypename(snapshot)).toBe('example.
|
|
68
|
+
expect(Relation.getTypename(rel)).toBe('com.example.type.hasManager');
|
|
69
|
+
expect(Relation.getTypename(snapshot)).toBe('com.example.type.hasManager');
|
|
64
70
|
|
|
65
71
|
// getMeta - works with both.
|
|
66
72
|
expect(Relation.getMeta(rel)).toBeDefined();
|