@dxos/echo 0.8.4-main.ef1bc66f44 → 0.8.4-main.f466a3d56e
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 +5 -5
- package/dist/lib/neutral/Annotation.mjs +7 -3
- package/dist/lib/neutral/Database.mjs +8 -4
- package/dist/lib/neutral/Entity.mjs +24 -14
- 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 +52 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +23 -10
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Key.mjs +1 -1
- package/dist/lib/neutral/Migration.mjs +17 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +34 -17
- 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 +11 -7
- package/dist/lib/neutral/Relation.mjs +23 -13
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +14 -10
- package/dist/lib/neutral/Type.mjs +13 -23
- package/dist/lib/neutral/{chunk-N2QNHMT5.mjs → chunk-44HT3MEC.mjs} +2 -2
- package/dist/lib/neutral/{chunk-N2QNHMT5.mjs.map → chunk-44HT3MEC.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-XAJMXQ4H.mjs → chunk-5SL5LDLD.mjs} +6 -2
- package/dist/lib/neutral/chunk-5SL5LDLD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7RVZT53K.mjs} +1 -1
- package/dist/lib/neutral/chunk-APHSOTIX.mjs +34 -0
- package/dist/lib/neutral/chunk-APHSOTIX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZAHWXGK4.mjs → chunk-APJKDGFL.mjs} +85 -7
- package/dist/lib/neutral/chunk-APJKDGFL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-BICZKPQG.mjs} +1 -1
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs.map → chunk-BICZKPQG.mjs.map} +1 -1
- package/dist/lib/neutral/chunk-BMB7IHGB.mjs +346 -0
- package/dist/lib/neutral/chunk-BMB7IHGB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FIWO2FZK.mjs +36 -0
- package/dist/lib/neutral/chunk-FIWO2FZK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-G54OX4IX.mjs +2452 -0
- package/dist/lib/neutral/chunk-G54OX4IX.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-LKFNEFHF.mjs → chunk-I2DARWPX.mjs} +18 -20
- package/dist/lib/neutral/chunk-I2DARWPX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J54QMAKF.mjs +421 -0
- package/dist/lib/neutral/chunk-J54QMAKF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MGSQGHOD.mjs +206 -0
- package/dist/lib/neutral/chunk-MGSQGHOD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MLS7U7AT.mjs +734 -0
- package/dist/lib/neutral/chunk-MLS7U7AT.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-KB7RIVLK.mjs → chunk-N4B7FHQT.mjs} +4 -4
- package/dist/lib/neutral/{chunk-KB7RIVLK.mjs.map → chunk-N4B7FHQT.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-K5K3Z62A.mjs → chunk-N7VOEPSV.mjs} +11 -3
- package/dist/lib/neutral/chunk-N7VOEPSV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-PSZBLH53.mjs +81 -0
- package/dist/lib/neutral/chunk-PSZBLH53.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MTEHHY62.mjs → chunk-PT37DG2F.mjs} +77 -58
- package/dist/lib/neutral/chunk-PT37DG2F.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DLPC7DHQ.mjs → chunk-Q2KKKJSV.mjs} +5 -5
- package/dist/lib/neutral/chunk-Q2KKKJSV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Q7ZL2P5H.mjs +320 -0
- package/dist/lib/neutral/chunk-Q7ZL2P5H.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QARLJVDB.mjs → chunk-QRZ2I3ZM.mjs} +8 -4
- package/dist/lib/neutral/chunk-QRZ2I3ZM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VUQGRDRI.mjs → chunk-SCPFDS2E.mjs} +40 -12
- package/dist/lib/neutral/chunk-SCPFDS2E.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RIMHNJ3E.mjs → chunk-TNBK56IN.mjs} +98 -44
- package/dist/lib/neutral/chunk-TNBK56IN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7WE7SBA2.mjs → chunk-TRPZU2HV.mjs} +13 -13
- package/dist/lib/neutral/chunk-TRPZU2HV.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-OMUPQMLR.mjs → chunk-V72DY6LU.mjs} +1 -1
- package/dist/lib/neutral/chunk-ZFACXBY6.mjs +136 -0
- package/dist/lib/neutral/chunk-ZFACXBY6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RPB6V4BE.mjs → chunk-ZISMEVKD.mjs} +14 -1
- package/dist/lib/neutral/chunk-ZISMEVKD.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +51 -28
- package/dist/lib/neutral/internal/index.mjs +52 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +199 -136
- 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 +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +21 -36
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +19 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +54 -22
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +55 -12
- 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 +206 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +55 -5
- 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 +11 -6
- 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/Migration.d.ts +69 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +163 -59
- 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 +105 -17
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +59 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +86 -40
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +4 -4
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +2 -1
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +51 -180
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +68 -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 +7 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +65 -2
- 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 +2 -2
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api/entity.d.ts → Entity/api.d.ts} +2 -2
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/entity.d.ts +3 -3
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/model.d.ts +4 -26
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +2 -2
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/relation.d.ts +3 -30
- package/dist/types/src/internal/Entity/relation.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/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/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 +1 -1
- 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 +2 -2
- 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}/ids.d.ts +1 -1
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +13 -5
- 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 +4 -4
- 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 +15 -2
- 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/{schema → Type}/echo-schema.d.ts +7 -7
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/persistent-schema.d.ts +2 -2
- package/dist/types/src/internal/Type/persistent-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.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/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/{types → common/types}/entity.d.ts +5 -5
- 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 +54 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/typename.d.ts.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 +47 -46
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- 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 +37 -0
- package/src/Database.ts +64 -65
- package/src/Dataset.ts +26 -0
- package/src/Entity.ts +87 -61
- package/src/Err.ts +22 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +335 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +116 -7
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +12 -7
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +102 -0
- package/src/JsonSchema.ts +14 -4
- package/src/Migration.ts +106 -0
- package/src/Obj.test.ts +142 -15
- package/src/Obj.ts +382 -161
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +372 -15
- package/src/Query.ts +274 -26
- package/src/Ref.ts +66 -11
- package/src/Relation.test.ts +8 -2
- package/src/Relation.ts +183 -147
- package/src/SchemaRegistry.ts +5 -4
- package/src/Tag.ts +6 -5
- package/src/Type.test.ts +10 -10
- package/src/Type.ts +70 -303
- package/src/View.ts +107 -0
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +8 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +56 -7
- package/src/internal/{annotations → Annotation}/annotations.ts +122 -19
- 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 +1 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +3 -2
- package/src/internal/{entities → Entity}/entity.ts +6 -4
- package/src/internal/{entities → Entity}/index.ts +2 -0
- package/src/internal/{entities → Entity}/model.ts +15 -42
- package/src/internal/{entities → Entity}/object.ts +2 -3
- package/src/internal/{entities → Entity}/relation.ts +19 -36
- package/src/internal/{api → Entity}/version.ts +2 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -2
- package/src/internal/{formats → Format}/format.test.ts +1 -2
- 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 +48 -49
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +6 -5
- package/src/internal/{object → Obj}/clone.ts +3 -3
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +5 -7
- package/src/internal/{object → Obj}/create-object.ts +5 -6
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/ids.ts +1 -1
- package/src/internal/{object → Obj}/inspect.ts +2 -2
- package/src/internal/{object → Obj}/json-serializer.test.ts +31 -9
- package/src/internal/{object → Obj}/json-serializer.ts +60 -35
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +24 -24
- package/src/internal/{object → Obj}/set-value.ts +3 -3
- package/src/internal/{object → Obj}/snapshot.ts +35 -23
- package/src/internal/{object → Obj}/typed-object.test.ts +3 -3
- package/src/internal/{object → Obj}/typed-object.ts +4 -4
- 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 +4 -5
- package/src/internal/{ref → Ref}/ref.ts +20 -3
- package/src/internal/{schema → Type}/compose.test.ts +5 -6
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/{schema → Type}/echo-schema.ts +9 -10
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +9 -4
- 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 +6 -3
- package/src/internal/{proxy → common/proxy}/make-object.ts +1 -2
- 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/{proxy → common/proxy}/schema.test.ts +10 -10
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +6 -7
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +10 -13
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +5 -6
- package/src/internal/{types → common/types}/base.ts +1 -1
- package/src/internal/{types → common/types}/entity.ts +2 -2
- 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 +69 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +4 -5
- package/src/testing/test-data.ts +157 -98
- package/src/testing/test-schema.ts +20 -18
- package/dist/lib/neutral/chunk-2AF5GMG6.mjs +0 -171
- package/dist/lib/neutral/chunk-2AF5GMG6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7WE7SBA2.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-LKFNEFHF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MTEHHY62.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.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.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.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- 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.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.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.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.map +0 -1
- 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.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- 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/api/annotations.ts +0 -60
- /package/dist/lib/neutral/{chunk-ANHVGJI4.mjs.map → chunk-7RVZT53K.mjs.map} +0 -0
- /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.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/index.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}/index.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/{schema → Type}/index.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.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}/make-object.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.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{types → common/types}/typename.d.ts +0 -0
- /package/src/internal/{entities → Entity}/util.ts +0 -0
- /package/src/internal/{formats → Format}/date.ts +0 -0
- /package/src/internal/{formats → Format}/format.ts +0 -0
- /package/src/internal/{formats → Format}/index.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}/index.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/{schema → Type}/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/internal/{types → common/types}/typename.ts +0 -0
package/src/Query.ts
CHANGED
|
@@ -2,16 +2,24 @@
|
|
|
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 * as Feed from './Feed';
|
|
10
16
|
import * as Filter from './Filter';
|
|
11
|
-
import
|
|
17
|
+
import * as internal from './internal';
|
|
18
|
+
import * as Obj from './Obj';
|
|
12
19
|
import type * as Order from './Order';
|
|
13
20
|
import type * as Ref from './Ref';
|
|
14
|
-
import type * as
|
|
21
|
+
import type * as Relation from './Relation';
|
|
22
|
+
import type * as View from './View';
|
|
15
23
|
|
|
16
24
|
// TODO(dmaretskyi): Split up into interfaces for objects and relations so they can have separate verbs.
|
|
17
25
|
// TODO(dmaretskyi): Undirected relation traversals.
|
|
@@ -35,15 +43,15 @@ export interface Query<T> {
|
|
|
35
43
|
* @param filter - Filter to select the objects.
|
|
36
44
|
* @returns Query for the selected objects.
|
|
37
45
|
*/
|
|
38
|
-
select(filter: Filter.Filter<T>): Query<T>;
|
|
39
|
-
select(props: Filter.Props<T>): Query<T>;
|
|
46
|
+
'select'(filter: Filter.Filter<T>): Query<T>;
|
|
47
|
+
'select'(props: Filter.Props<T>): Query<T>;
|
|
40
48
|
|
|
41
49
|
/**
|
|
42
50
|
* Traverse an outgoing reference.
|
|
43
51
|
* @param key - Property path inside T that is a reference or optional reference.
|
|
44
52
|
* @returns Query for the target of the reference.
|
|
45
53
|
*/
|
|
46
|
-
reference<K extends RefPropKey<T>>(
|
|
54
|
+
'reference'<K extends RefPropKey<T>>(
|
|
47
55
|
key: K,
|
|
48
56
|
): Query<
|
|
49
57
|
T[K] extends Ref.Unknown
|
|
@@ -61,12 +69,12 @@ export interface Query<T> {
|
|
|
61
69
|
*/
|
|
62
70
|
// TODO(dmaretskyi): any way to enforce `Ref.Target<Schema.Schema.Type<S>[key]> == T`?
|
|
63
71
|
// TODO(dmaretskyi): Ability to go through arrays of references.
|
|
64
|
-
referencedBy<S extends Schema.Schema.All>(
|
|
72
|
+
'referencedBy'<S extends Schema.Schema.All>(
|
|
65
73
|
target: S | string,
|
|
66
74
|
key: RefPropKey<Schema.Schema.Type<S>>,
|
|
67
75
|
): Query<Schema.Schema.Type<S>>;
|
|
68
|
-
referencedBy<S extends Schema.Schema.All>(target: S | string): Query<Schema.Schema.Type<S>>;
|
|
69
|
-
referencedBy(): Query<any>;
|
|
76
|
+
'referencedBy'<S extends Schema.Schema.All>(target: S | string): Query<Schema.Schema.Type<S>>;
|
|
77
|
+
'referencedBy'(): Query<any>;
|
|
70
78
|
|
|
71
79
|
/**
|
|
72
80
|
* Find relations where this object is the source.
|
|
@@ -74,8 +82,8 @@ export interface Query<T> {
|
|
|
74
82
|
* @param relation - Schema of the relation.
|
|
75
83
|
* @param predicates - Predicates to filter the relation objects.
|
|
76
84
|
*/
|
|
77
|
-
sourceOf<S extends Schema.Schema.All>(
|
|
78
|
-
relation
|
|
85
|
+
'sourceOf'<S extends Schema.Schema.All>(
|
|
86
|
+
relation?: S | string,
|
|
79
87
|
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
80
88
|
): Query<Schema.Schema.Type<S>>;
|
|
81
89
|
|
|
@@ -85,8 +93,8 @@ export interface Query<T> {
|
|
|
85
93
|
* @param relation - Schema of the relation.
|
|
86
94
|
* @param predicates - Predicates to filter the relation objects.
|
|
87
95
|
*/
|
|
88
|
-
targetOf<S extends Schema.Schema.All>(
|
|
89
|
-
relation
|
|
96
|
+
'targetOf'<S extends Schema.Schema.All>(
|
|
97
|
+
relation?: S | string,
|
|
90
98
|
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
91
99
|
): Query<Schema.Schema.Type<S>>;
|
|
92
100
|
|
|
@@ -94,25 +102,25 @@ export interface Query<T> {
|
|
|
94
102
|
* For a query for relations, get the source objects.
|
|
95
103
|
* @returns Query for the source objects.
|
|
96
104
|
*/
|
|
97
|
-
source(): Query<
|
|
105
|
+
'source'(): Query<Relation.SourceOf<T>>;
|
|
98
106
|
|
|
99
107
|
/**
|
|
100
108
|
* For a query for relations, get the target objects.
|
|
101
109
|
* @returns Query for the target objects.
|
|
102
110
|
*/
|
|
103
|
-
target(): Query<
|
|
111
|
+
'target'(): Query<Relation.TargetOf<T>>;
|
|
104
112
|
|
|
105
113
|
/**
|
|
106
114
|
* Get the parent object of the current selection.
|
|
107
115
|
* @returns Query for the parent objects.
|
|
108
116
|
*/
|
|
109
|
-
parent(): Query<any>;
|
|
117
|
+
'parent'(): Query<any>;
|
|
110
118
|
|
|
111
119
|
/**
|
|
112
120
|
* Get all child objects of the current selection.
|
|
113
121
|
* @returns Query for the child objects.
|
|
114
122
|
*/
|
|
115
|
-
children(): Query<any>;
|
|
123
|
+
'children'(): Query<any>;
|
|
116
124
|
|
|
117
125
|
/**
|
|
118
126
|
* Order the query results.
|
|
@@ -120,19 +128,90 @@ export interface Query<T> {
|
|
|
120
128
|
* @param order - Order to sort the results.
|
|
121
129
|
* @returns Query for the ordered results.
|
|
122
130
|
*/
|
|
123
|
-
orderBy(...order: EffectArray.NonEmptyArray<Order.Order<T>>): Query<T>;
|
|
131
|
+
'orderBy'(...order: EffectArray.NonEmptyArray<Order.Order<T>>): Query<T>;
|
|
124
132
|
|
|
125
133
|
/**
|
|
126
134
|
* Limit the number of results.
|
|
127
135
|
* @param limit - Maximum number of results to return.
|
|
128
136
|
* @returns Query for the limited results.
|
|
129
137
|
*/
|
|
130
|
-
limit(limit: number): Query<T>;
|
|
138
|
+
'limit'(limit: number): Query<T>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Query from selected databases only.
|
|
142
|
+
*
|
|
143
|
+
* Example:
|
|
144
|
+
*
|
|
145
|
+
* ```ts
|
|
146
|
+
* Query.select(Filter.type(Person)).from(db);
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
|
|
150
|
+
*/
|
|
151
|
+
'from'(database: Database.Database | Database.Database[], options?: { includeFeeds?: boolean }): Query<T>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Query from selected feeds only.
|
|
155
|
+
*
|
|
156
|
+
* Example:
|
|
157
|
+
*
|
|
158
|
+
* ```ts
|
|
159
|
+
* Query.select(Filter.type(Person)).from(feed);
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
'from'(feeds: Feed.Feed | Feed.Feed[]): Query<T>;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Query from all accessible spaces.
|
|
167
|
+
*
|
|
168
|
+
* Example:
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* Query.select(Filter.type(Person)).from('all-accessible-spaces');
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
|
|
175
|
+
*/
|
|
176
|
+
'from'(allSpaces: 'all-accessible-spaces', options?: { includeFeeds?: boolean }): Query<T>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Query from a dataset.
|
|
180
|
+
* Currently only feeds are supported.
|
|
181
|
+
*
|
|
182
|
+
* Example:
|
|
183
|
+
*
|
|
184
|
+
* ```ts
|
|
185
|
+
* Query.type(Person).from(feed);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
'from'(dataset: Dataset.Dataset): Query<T>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Query from the results of another query.
|
|
192
|
+
*
|
|
193
|
+
* Example:
|
|
194
|
+
*
|
|
195
|
+
* ```ts
|
|
196
|
+
* Query.select(Filter.props({ foo: 'foo' })).from(Query.select(Filter.type(Contact)).reference('org'));
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
'from'(query: Any): Query<T>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Query from a raw scope specification.
|
|
203
|
+
*/
|
|
204
|
+
'from'(scope: QueryAST.Scope): Query<T>;
|
|
131
205
|
|
|
132
206
|
/**
|
|
133
207
|
* Add options to a query.
|
|
134
208
|
*/
|
|
135
|
-
options(options: QueryAST.QueryOptions): Query<T>;
|
|
209
|
+
'options'(options: QueryAST.QueryOptions): Query<T>;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Attach a diagnostic label for logs and tooling (execution semantics unchanged).
|
|
213
|
+
*/
|
|
214
|
+
'debugLabel'(label: string): Query<T>;
|
|
136
215
|
}
|
|
137
216
|
|
|
138
217
|
export type Any = Query<any>;
|
|
@@ -140,7 +219,7 @@ export type Any = Query<any>;
|
|
|
140
219
|
export type Type<Q extends Any> = Q extends Query<infer T> ? T : never;
|
|
141
220
|
|
|
142
221
|
class QueryClass implements Any {
|
|
143
|
-
private static variance: Any['~Query'] = {} as Any['~Query'];
|
|
222
|
+
private static 'variance': Any['~Query'] = {} as Any['~Query'];
|
|
144
223
|
|
|
145
224
|
constructor(public readonly ast: QueryAST.Query) {}
|
|
146
225
|
|
|
@@ -171,7 +250,7 @@ class QueryClass implements Any {
|
|
|
171
250
|
}
|
|
172
251
|
|
|
173
252
|
referencedBy(target?: Schema.Schema.All | string, key?: string): Any {
|
|
174
|
-
const dxn = target !== undefined ? getTypeDXNFromSpecifier(target) : null;
|
|
253
|
+
const dxn = target !== undefined ? internal.getTypeDXNFromSpecifier(target) : null;
|
|
175
254
|
return new QueryClass({
|
|
176
255
|
type: 'incoming-references',
|
|
177
256
|
anchor: this.ast,
|
|
@@ -180,21 +259,21 @@ class QueryClass implements Any {
|
|
|
180
259
|
});
|
|
181
260
|
}
|
|
182
261
|
|
|
183
|
-
sourceOf(relation
|
|
262
|
+
sourceOf(relation?: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
184
263
|
return new QueryClass({
|
|
185
264
|
type: 'relation',
|
|
186
265
|
anchor: this.ast,
|
|
187
266
|
direction: 'outgoing',
|
|
188
|
-
filter: Filter.type(relation, predicates).ast,
|
|
267
|
+
filter: relation !== undefined ? Filter.type(relation, predicates).ast : undefined,
|
|
189
268
|
});
|
|
190
269
|
}
|
|
191
270
|
|
|
192
|
-
targetOf(relation
|
|
271
|
+
targetOf(relation?: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
193
272
|
return new QueryClass({
|
|
194
273
|
type: 'relation',
|
|
195
274
|
anchor: this.ast,
|
|
196
275
|
direction: 'incoming',
|
|
197
|
-
filter: Filter.type(relation, predicates).ast,
|
|
276
|
+
filter: relation !== undefined ? Filter.type(relation, predicates).ast : undefined,
|
|
198
277
|
});
|
|
199
278
|
}
|
|
200
279
|
|
|
@@ -246,6 +325,113 @@ class QueryClass implements Any {
|
|
|
246
325
|
});
|
|
247
326
|
}
|
|
248
327
|
|
|
328
|
+
from(
|
|
329
|
+
arg:
|
|
330
|
+
| Database.Database
|
|
331
|
+
| Database.Database[]
|
|
332
|
+
| Feed.Feed
|
|
333
|
+
| Feed.Feed[]
|
|
334
|
+
| Collection.Collection
|
|
335
|
+
| View.View
|
|
336
|
+
| Any
|
|
337
|
+
| QueryAST.Scope
|
|
338
|
+
| 'all-accessible-spaces',
|
|
339
|
+
options?: { includeFeeds?: boolean },
|
|
340
|
+
): Any {
|
|
341
|
+
if (arg == null) {
|
|
342
|
+
throw new TypeError(
|
|
343
|
+
'Query.from() requires a valid data source argument (database, feed, query, scope, or "all-accessible-spaces").',
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (is(arg)) {
|
|
348
|
+
return new QueryClass({
|
|
349
|
+
type: 'from',
|
|
350
|
+
query: this.ast,
|
|
351
|
+
from: { _tag: 'query', query: arg.ast },
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (arg === 'all-accessible-spaces') {
|
|
356
|
+
return new QueryClass({
|
|
357
|
+
type: 'from',
|
|
358
|
+
query: this.ast,
|
|
359
|
+
from: {
|
|
360
|
+
_tag: 'scope',
|
|
361
|
+
scope: {
|
|
362
|
+
...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (_isScope(arg)) {
|
|
369
|
+
return new QueryClass({
|
|
370
|
+
type: 'from',
|
|
371
|
+
query: this.ast,
|
|
372
|
+
from: { _tag: 'scope', scope: arg },
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const items = Array.isArray(arg) ? arg : [arg];
|
|
377
|
+
|
|
378
|
+
if (items.length > 0 && Database.isDatabase(items[0])) {
|
|
379
|
+
const databases = items as Database.Database[];
|
|
380
|
+
return new QueryClass({
|
|
381
|
+
type: 'from',
|
|
382
|
+
query: this.ast,
|
|
383
|
+
from: {
|
|
384
|
+
_tag: 'scope',
|
|
385
|
+
scope: {
|
|
386
|
+
spaceIds: databases.map((db) => db.spaceId),
|
|
387
|
+
...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (items.length > 0) {
|
|
394
|
+
const typename = Obj.getTypename(items[0] as Obj.Unknown);
|
|
395
|
+
// TODO(dmaretskyi): Support querying from views.
|
|
396
|
+
if (typename === 'org.dxos.type.view') {
|
|
397
|
+
throw new Error('Query.from(view) is not yet supported.');
|
|
398
|
+
}
|
|
399
|
+
// TODO(dmaretskyi): Support querying from collections.
|
|
400
|
+
if (typename === 'org.dxos.type.collection') {
|
|
401
|
+
throw new Error('Query.from(collection) is not yet supported.');
|
|
402
|
+
}
|
|
403
|
+
// Validate that the items are Feed.Feed instances.
|
|
404
|
+
for (const item of items) {
|
|
405
|
+
if (!Obj.instanceOf(Feed.Feed, item)) {
|
|
406
|
+
throw new TypeError(
|
|
407
|
+
`Query.from() expects Feed objects (org.dxos.type.feed), but received an object with typename '${typename ?? 'unknown'}'.`,
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const feedItems = items as Feed.Feed[];
|
|
414
|
+
const feedDXNs = feedItems.map((feed) => {
|
|
415
|
+
const dxn = Feed.getQueueDxn(feed);
|
|
416
|
+
if (!dxn) {
|
|
417
|
+
throw new TypeError(
|
|
418
|
+
`Query.from() expects persisted Feed objects with a queue DXN; got feed without a space (id=${Obj.getDXN(feed).toString()}).`,
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
return dxn.toString();
|
|
422
|
+
});
|
|
423
|
+
return new QueryClass({
|
|
424
|
+
type: 'from',
|
|
425
|
+
query: this.ast,
|
|
426
|
+
from: {
|
|
427
|
+
_tag: 'scope',
|
|
428
|
+
scope: {
|
|
429
|
+
feeds: feedDXNs,
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
249
435
|
options(options: QueryAST.QueryOptions): Any {
|
|
250
436
|
return new QueryClass({
|
|
251
437
|
type: 'options',
|
|
@@ -253,6 +439,21 @@ class QueryClass implements Any {
|
|
|
253
439
|
options,
|
|
254
440
|
});
|
|
255
441
|
}
|
|
442
|
+
|
|
443
|
+
debugLabel(label: string): Any {
|
|
444
|
+
if (this.ast.type === 'options') {
|
|
445
|
+
return new QueryClass({
|
|
446
|
+
type: 'options',
|
|
447
|
+
query: this.ast.query,
|
|
448
|
+
options: { ...this.ast.options, debugLabel: label },
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
return new QueryClass({
|
|
452
|
+
type: 'options',
|
|
453
|
+
query: this.ast,
|
|
454
|
+
options: { debugLabel: label },
|
|
455
|
+
});
|
|
456
|
+
}
|
|
256
457
|
}
|
|
257
458
|
|
|
258
459
|
export const is = (value: unknown): value is Any => {
|
|
@@ -284,7 +485,13 @@ export const select = <F extends Filter.Any>(filter: F): Query<Filter.Type<F>> =
|
|
|
284
485
|
*
|
|
285
486
|
* Shorthand for: `Query.select(Filter.type(schema, predicates))`.
|
|
286
487
|
*/
|
|
287
|
-
export const type
|
|
488
|
+
export const type: {
|
|
489
|
+
<S extends Schema.Schema.All>(
|
|
490
|
+
schema: S,
|
|
491
|
+
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
492
|
+
): Query<Schema.Schema.Type<S>>;
|
|
493
|
+
(schema: string, predicates?: Filter.Props<unknown>): Query<any>;
|
|
494
|
+
} = (schema: Schema.Schema.All | string, predicates?: Filter.Props<unknown>): Any => {
|
|
288
495
|
return new QueryClass({
|
|
289
496
|
type: 'select',
|
|
290
497
|
filter: Filter.type(schema, predicates).ast,
|
|
@@ -322,3 +529,44 @@ export const without = <T>(source: Query<T>, exclude: Query<T>): Query<T> => {
|
|
|
322
529
|
exclude: exclude.ast,
|
|
323
530
|
});
|
|
324
531
|
};
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Create a query scoped to a data source.
|
|
535
|
+
* The returned query selects everything from the source; chain `.select()` to narrow results.
|
|
536
|
+
*
|
|
537
|
+
* @param source - Data source: database, feed, 'all-accessible-spaces', or another query.
|
|
538
|
+
* @returns Query scoped to the given source.
|
|
539
|
+
*/
|
|
540
|
+
export const from = (
|
|
541
|
+
source:
|
|
542
|
+
| Database.Database
|
|
543
|
+
| Database.Database[]
|
|
544
|
+
| Feed.Feed
|
|
545
|
+
| Feed.Feed[]
|
|
546
|
+
| Any
|
|
547
|
+
| QueryAST.Scope
|
|
548
|
+
| 'all-accessible-spaces',
|
|
549
|
+
options?: { includeFeeds?: boolean },
|
|
550
|
+
): Any => {
|
|
551
|
+
const baseQuery: QueryAST.Query = {
|
|
552
|
+
type: 'select',
|
|
553
|
+
filter: Filter.everything().ast,
|
|
554
|
+
};
|
|
555
|
+
const wrapper = new QueryClass(baseQuery);
|
|
556
|
+
return wrapper.from(source as any, options);
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
const SCOPE_KEYS = new Set(['spaceIds', 'feeds', 'allFeedsFromSpaces']);
|
|
560
|
+
|
|
561
|
+
/** Detect a raw Scope object (plain object with only Scope-valid keys). */
|
|
562
|
+
const _isScope = (value: unknown): value is QueryAST.Scope => {
|
|
563
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
return Object.keys(value).every((key) => SCOPE_KEYS.has(key));
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Returns a human-readable string representation of a Query AST.
|
|
571
|
+
*/
|
|
572
|
+
export const pretty = (query: Any): string => internal.prettyQuery(query.ast);
|
package/src/Ref.ts
CHANGED
|
@@ -2,42 +2,97 @@
|
|
|
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
|
-
import
|
|
11
|
+
import type * as Entity from './Entity';
|
|
12
|
+
import * as refInternal from './internal/Ref';
|
|
10
13
|
import type * as JsonSchema from './JsonSchema';
|
|
11
14
|
import type * as Obj from './Obj';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Instance type for a reference.
|
|
18
|
+
*
|
|
19
|
+
* Reference can point to any object or relation.
|
|
20
|
+
* References are lazy loaded.
|
|
21
|
+
*
|
|
22
|
+
* `ref.dxn` is the DXN of the referenced object.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const taskRef: Ref<Task> = Ref.make(task);
|
|
27
|
+
*
|
|
28
|
+
* await taskRef.load(); // Returns Promise<Task>
|
|
29
|
+
* yield* Database.load(taskRef); // Effectful version.
|
|
30
|
+
*
|
|
31
|
+
* database.makeRef(dxn); // Create a ref from a DXN.
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export type Ref<T> = refInternal.Ref<T>;
|
|
35
|
+
export type Unknown = refInternal.Ref<Obj.Unknown>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Factory function to create a Ref schema for the given target schema.
|
|
39
|
+
* Use this in schema definitions to declare reference fields.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const Task = Schema.Struct({
|
|
44
|
+
* assignee: Ref.Ref(Person), // Creates a Ref schema
|
|
45
|
+
* }).pipe(Type.object({ typename: 'Task', version: '0.1.0' }));
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export const Ref: <S extends Schema.Schema.Any>(schema: S) => RefSchema<Schema.Schema.Type<S>> = refInternal.Ref;
|
|
49
|
+
|
|
50
|
+
export const Array = refInternal.RefArray;
|
|
15
51
|
|
|
16
|
-
|
|
52
|
+
/**
|
|
53
|
+
* TypeScript type for a Ref schema.
|
|
54
|
+
* This is the type of the SCHEMA itself, not the runtime ref instance.
|
|
55
|
+
* For the instance type, use `Ref.Ref<T>` from the Ref module.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // Schema type annotation (rarely needed, usually inferred):
|
|
60
|
+
* const refSchema: Ref.RefSchema<typeof Task> = Ref.Ref(Task);
|
|
61
|
+
*
|
|
62
|
+
* // Instance type annotation (use Ref.Ref instead):
|
|
63
|
+
* const refInstance: Ref.Ref<Task> = Ref.make(task);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
// TODO(dmaretskyi): Investigate if we can remove this type.
|
|
67
|
+
// Post DX-836 it will become just `Schema.Schema<Ref.Ref<T>>`.
|
|
68
|
+
// NOTE: This could be Type.Ref<T> instead, but since it going to be removed, it's better to keep it here, self-contained.
|
|
69
|
+
export interface RefSchema<T extends Entity.Unknown> extends refInternal.RefSchema<T> {}
|
|
17
70
|
|
|
18
71
|
/**
|
|
19
72
|
* Extract reference target.
|
|
20
73
|
*/
|
|
21
|
-
export type Target<R extends Unknown> = R extends Ref
|
|
74
|
+
export type Target<R extends Unknown> = R extends refInternal.Ref<infer T> ? T : never;
|
|
22
75
|
|
|
23
76
|
/**
|
|
24
77
|
* Reference resolver.
|
|
25
78
|
*/
|
|
26
|
-
export type Resolver = RefResolver;
|
|
79
|
+
export type Resolver = refInternal.RefResolver;
|
|
27
80
|
|
|
28
|
-
export const isRef: (value: unknown) => value is Unknown = Ref
|
|
81
|
+
export const isRef: (value: unknown) => value is Unknown = refInternal.Ref.isRef;
|
|
29
82
|
|
|
30
|
-
export const make = Ref
|
|
83
|
+
export const make = refInternal.Ref.make;
|
|
31
84
|
|
|
32
85
|
// TODO(dmaretskyi): Consider just allowing `make` to accept DXN.
|
|
33
|
-
export const fromDXN = Ref
|
|
86
|
+
export const fromDXN = refInternal.Ref.fromDXN;
|
|
87
|
+
|
|
88
|
+
export const hasObjectId = refInternal.Ref.hasObjectId;
|
|
34
89
|
|
|
35
90
|
// TODO(wittjosiah): Factor out?
|
|
36
91
|
export const isRefType = (ast: SchemaAST.AST): boolean => {
|
|
37
92
|
return SchemaAST.getAnnotation<JsonSchema.JsonSchema>(ast, SchemaAST.JSONSchemaAnnotationId).pipe(
|
|
38
93
|
Option.flatMap((jsonSchema) => ('$id' in jsonSchema ? Option.some(jsonSchema) : Option.none())),
|
|
39
94
|
Option.flatMap((jsonSchema) => {
|
|
40
|
-
const { typename } = getSchemaReference(jsonSchema) ?? {};
|
|
95
|
+
const { typename } = refInternal.getSchemaReference(jsonSchema) ?? {};
|
|
41
96
|
return typename ? Option.some(true) : Option.some(false);
|
|
42
97
|
}),
|
|
43
98
|
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
|
});
|
|
@@ -59,8 +65,8 @@ describe('Relation', () => {
|
|
|
59
65
|
expect(Relation.getDXN(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.has-manager');
|
|
69
|
+
expect(Relation.getTypename(snapshot)).toBe('com.example.type.has-manager');
|
|
64
70
|
|
|
65
71
|
// getMeta - works with both.
|
|
66
72
|
expect(Relation.getMeta(rel)).toBeDefined();
|