@dxos/echo 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/README.md +3 -4
- package/dist/lib/neutral/Annotation.mjs +37 -0
- package/dist/lib/neutral/Database.mjs +45 -0
- package/dist/lib/neutral/Entity.mjs +56 -0
- package/dist/lib/neutral/Err.mjs +12 -0
- package/dist/lib/neutral/Feed.mjs +43 -0
- package/dist/lib/neutral/Filter.mjs +61 -0
- package/dist/lib/neutral/Format.mjs +66 -0
- package/dist/lib/neutral/Format.mjs.map +7 -0
- package/dist/lib/neutral/JsonSchema.mjs +18 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +12 -0
- package/dist/lib/neutral/Key.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +107 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +12 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +32 -0
- package/dist/lib/neutral/Query.mjs.map +7 -0
- package/dist/lib/neutral/QueryResult.mjs +2 -0
- package/dist/lib/neutral/QueryResult.mjs.map +7 -0
- package/dist/lib/neutral/Ref.mjs +24 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +90 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/SchemaRegistry.mjs +2 -0
- package/dist/lib/neutral/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +25 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +34 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4KG6IGL4.mjs +67 -0
- package/dist/lib/neutral/chunk-4KG6IGL4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5ELDDYWE.mjs +130 -0
- package/dist/lib/neutral/chunk-5ELDDYWE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ALOGSVBP.mjs +299 -0
- package/dist/lib/neutral/chunk-ALOGSVBP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs +21 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AQP4QKYP.mjs +283 -0
- package/dist/lib/neutral/chunk-AQP4QKYP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BRJSLACP.mjs +152 -0
- package/dist/lib/neutral/chunk-BRJSLACP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DZQSL6RW.mjs +73 -0
- package/dist/lib/neutral/chunk-DZQSL6RW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-F7KMHDPJ.mjs +327 -0
- package/dist/lib/neutral/chunk-F7KMHDPJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GAWKQ5DZ.mjs +56 -0
- package/dist/lib/neutral/chunk-GAWKQ5DZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GFNCSK7F.mjs +101 -0
- package/dist/lib/neutral/chunk-GFNCSK7F.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-KGV3QIRX.mjs +313 -0
- package/dist/lib/neutral/chunk-KGV3QIRX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-M2KVTHZM.mjs +402 -0
- package/dist/lib/neutral/chunk-M2KVTHZM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MXQJZCPY.mjs +51 -0
- package/dist/lib/neutral/chunk-MXQJZCPY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-O3TZFQCT.mjs +27 -0
- package/dist/lib/neutral/chunk-O3TZFQCT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OVUBTQLT.mjs +45 -0
- package/dist/lib/neutral/chunk-OVUBTQLT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-PP4DNUZU.mjs +3919 -0
- package/dist/lib/neutral/chunk-PP4DNUZU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QXF3LGN2.mjs +43 -0
- package/dist/lib/neutral/chunk-QXF3LGN2.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T4MPQJ7X.mjs +97 -0
- package/dist/lib/neutral/chunk-T4MPQJ7X.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T6JEFNP6.mjs +7 -0
- package/dist/lib/neutral/chunk-T6JEFNP6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-W7OP5HGZ.mjs +121 -0
- package/dist/lib/neutral/chunk-W7OP5HGZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZTUBYOGB.mjs +42 -0
- package/dist/lib/neutral/chunk-ZTUBYOGB.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZWKJ4LZJ.mjs +298 -0
- package/dist/lib/neutral/chunk-ZWKJ4LZJ.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +94 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/internal/index.mjs +260 -122
- package/dist/lib/neutral/internal/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +369 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +24 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Collection.d.ts +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +189 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Dataset.d.ts +18 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +168 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/Err.d.ts +107 -0
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +165 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +60 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +16 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +1 -0
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +423 -95
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +202 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +61 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +287 -21
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/SchemaRegistry.d.ts +84 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +18 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +120 -97
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/View.d.ts +68 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +19 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +209 -0
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/index.d.ts +3 -0
- package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/util.d.ts +39 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/api/annotations.d.ts +23 -0
- package/dist/types/src/internal/api/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/api/entity.d.ts +13 -0
- package/dist/types/src/internal/api/entity.d.ts.map +1 -0
- package/dist/types/src/internal/api/index.d.ts +15 -0
- package/dist/types/src/internal/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/api/meta.d.ts +42 -0
- package/dist/types/src/internal/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/api/sorting.d.ts +24 -0
- package/dist/types/src/internal/api/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/api/version.d.ts +42 -0
- package/dist/types/src/internal/api/version.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +20 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/entities/index.d.ts +6 -0
- package/dist/types/src/internal/entities/index.d.ts.map +1 -0
- package/dist/types/src/internal/entities/model.d.ts +79 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +18 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +62 -0
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
- package/dist/types/src/internal/entities/util.d.ts +2 -0
- package/dist/types/src/internal/entities/util.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.d.ts +4 -2
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/select.d.ts +6 -4
- package/dist/types/src/internal/formats/select.d.ts.map +1 -1
- package/dist/types/src/internal/formats/string.d.ts +4 -0
- package/dist/types/src/internal/formats/string.d.ts.map +1 -1
- package/dist/types/src/internal/formats/types.d.ts +13 -9
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +7 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +2 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts +130 -29
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +4 -6
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/clone.d.ts +8 -0
- package/dist/types/src/internal/object/clone.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -1
- package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +10 -11
- package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/deleted.d.ts +2 -2
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/object/ids.d.ts.map +1 -1
- package/dist/types/src/internal/object/index.d.ts +6 -12
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +14 -9
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +1 -14
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/object/set-value.d.ts +7 -0
- package/dist/types/src/internal/object/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/object/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/object/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/snapshot.d.ts +6 -0
- package/dist/types/src/internal/object/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.d.ts +8 -14
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
- package/dist/types/src/internal/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +14 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts +15 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +16 -12
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref-array.d.ts +4 -4
- package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +43 -18
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/schema/compose.d.ts +7 -0
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +25 -12
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +1 -4
- package/dist/types/src/internal/schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +20 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/types/base.d.ts +27 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/types/entity.d.ts +37 -0
- package/dist/types/src/internal/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +5 -2
- package/dist/types/src/internal/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/{object → types}/meta.d.ts +16 -14
- package/dist/types/src/internal/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/types/typename.d.ts +21 -0
- package/dist/types/src/internal/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/types/version.d.ts +15 -0
- package/dist/types/src/internal/types/version.d.ts.map +1 -0
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +304 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +21 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +106 -65
- package/src/Annotation.ts +46 -0
- package/src/Collection.ts +30 -0
- package/src/Database.ts +315 -0
- package/src/Dataset.ts +24 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +234 -0
- package/src/Err.ts +38 -0
- package/src/Feed.ts +254 -0
- package/src/Filter.ts +389 -0
- package/src/Format.ts +9 -0
- package/src/Hypergraph.ts +74 -0
- package/src/JsonSchema.ts +24 -0
- package/src/Key.ts +3 -0
- package/src/Obj.test.ts +447 -0
- package/src/Obj.ts +588 -248
- package/src/Order.ts +44 -0
- package/src/Query.test.ts +632 -0
- package/src/Query.ts +520 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +77 -9
- package/src/Relation.test.ts +88 -0
- package/src/Relation.ts +440 -58
- package/src/SchemaRegistry.ts +106 -0
- package/src/Tag.ts +39 -0
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +162 -151
- package/src/View.ts +100 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +20 -6
- package/src/internal/README.md +102 -0
- package/src/internal/{ast → annotations}/annotations.test.ts +18 -20
- package/src/internal/annotations/annotations.ts +526 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +85 -0
- package/src/internal/api/annotations.ts +60 -0
- package/src/internal/api/entity.ts +29 -0
- package/src/internal/api/index.ts +19 -0
- package/src/internal/api/meta.ts +88 -0
- package/src/internal/api/sorting.ts +53 -0
- package/src/internal/api/version.ts +96 -0
- package/src/internal/entities/entity.ts +128 -0
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +138 -0
- package/src/internal/entities/object.ts +58 -0
- package/src/internal/entities/relation.ts +171 -0
- package/src/internal/entities/util.ts +33 -0
- package/src/internal/formats/date.test.ts +1 -1
- package/src/internal/formats/date.ts +5 -5
- package/src/internal/formats/format.test.ts +6 -6
- package/src/internal/formats/format.ts +8 -6
- package/src/internal/formats/number.ts +5 -5
- package/src/internal/formats/object.ts +4 -4
- package/src/internal/formats/select.ts +6 -4
- package/src/internal/formats/string.ts +14 -9
- package/src/internal/formats/types.ts +53 -42
- package/src/internal/index.ts +30 -13
- package/src/internal/{json → json-schema}/annotations.ts +1 -1
- package/src/internal/json-schema/index.ts +2 -0
- package/src/internal/json-schema/json-schema-normalize.ts +4 -2
- package/src/internal/json-schema/json-schema-type.ts +35 -35
- package/src/internal/{json → json-schema}/json-schema.test.ts +232 -97
- package/src/internal/{json → json-schema}/json-schema.ts +79 -93
- package/src/internal/object/clone.ts +48 -0
- package/src/internal/object/common.ts +3 -4
- package/src/internal/object/{create.test.ts → create-object.test.ts} +31 -33
- package/src/internal/object/{create.ts → create-object.ts} +36 -37
- package/src/internal/object/deleted.ts +6 -6
- package/src/internal/object/ids.ts +1 -1
- package/src/internal/object/index.ts +6 -12
- package/src/internal/object/inspect.ts +5 -7
- package/src/internal/object/json-serializer.test.ts +59 -37
- package/src/internal/object/json-serializer.ts +87 -108
- package/src/internal/object/schema-validator.test.ts +3 -7
- package/src/internal/object/schema-validator.ts +2 -237
- package/src/internal/object/set-value.test.ts +281 -0
- package/src/internal/object/set-value.ts +165 -0
- package/src/internal/object/snapshot.ts +96 -0
- package/src/internal/object/typed-object.test.ts +11 -11
- package/src/internal/object/typed-object.ts +8 -59
- package/src/internal/proxy/change-context.ts +138 -0
- package/src/internal/proxy/change.test.ts +519 -0
- package/src/internal/proxy/define-hidden-property.ts +14 -0
- package/src/internal/proxy/errors.ts +42 -0
- package/src/internal/proxy/event-batch.ts +44 -0
- package/src/internal/proxy/handler.test.ts +51 -91
- package/src/internal/proxy/index.ts +17 -0
- package/src/internal/proxy/json-serializer.ts +87 -0
- package/src/internal/proxy/make-object.ts +106 -0
- package/src/internal/proxy/ownership.ts +253 -0
- package/src/internal/proxy/proxy-types.ts +23 -0
- package/src/internal/proxy/proxy-utils.ts +150 -0
- package/src/internal/proxy/reactive-array.ts +71 -0
- package/src/internal/proxy/reactive.ts +69 -0
- package/src/internal/proxy/schema-validator.ts +244 -0
- package/src/internal/proxy/schema.test.ts +27 -18
- package/src/internal/proxy/symbols.ts +7 -0
- package/src/internal/proxy/typed-handler.test.ts +260 -48
- package/src/internal/proxy/typed-handler.ts +283 -61
- package/src/internal/proxy/typed-object.test.ts +54 -38
- package/src/internal/ref/ref-array.ts +4 -4
- package/src/internal/ref/ref.test.ts +10 -9
- package/src/internal/ref/ref.ts +107 -56
- package/src/internal/{projection → schema}/compose.test.ts +8 -9
- package/src/internal/{projection → schema}/compose.ts +13 -8
- package/src/internal/schema/echo-schema.ts +74 -33
- package/src/internal/schema/index.ts +1 -4
- package/src/internal/schema/manipulation.ts +7 -1
- package/src/internal/schema/persistent-schema.ts +33 -0
- package/src/internal/types/base.ts +43 -0
- package/src/internal/types/entity.ts +54 -0
- package/src/internal/types/index.ts +5 -2
- package/src/internal/types/meta.ts +68 -0
- package/src/internal/types/typename.ts +55 -0
- package/src/internal/types/version.ts +19 -0
- package/src/testing/api.test.ts +126 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +240 -0
- package/src/testing/util.ts +85 -0
- package/dist/lib/browser/chunk-MWLA34S5.mjs +0 -3843
- package/dist/lib/browser/chunk-MWLA34S5.mjs.map +0 -7
- package/dist/lib/browser/chunk-OAZJQHVO.mjs +0 -453
- package/dist/lib/browser/chunk-OAZJQHVO.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORIE2FMS.mjs +0 -514
- package/dist/lib/browser/chunk-ORIE2FMS.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -43
- package/dist/lib/browser/internal/index.mjs +0 -326
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/query/index.mjs +0 -23
- package/dist/lib/browser/testing/index.mjs +0 -298
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AXWVDOP7.mjs +0 -453
- package/dist/lib/node-esm/chunk-AXWVDOP7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L4PBAJDP.mjs +0 -514
- package/dist/lib/node-esm/chunk-L4PBAJDP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YTNLFBIK.mjs +0 -3843
- package/dist/lib/node-esm/chunk-YTNLFBIK.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -43
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/query/index.mjs +0 -23
- package/dist/lib/node-esm/testing/index.mjs +0 -298
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/errors.d.ts +0 -72
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -119
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.d.ts.map +0 -1
- package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/accessors.d.ts +0 -29
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -22
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts +0 -14
- package/dist/types/src/internal/object/expando.d.ts.map +0 -1
- package/dist/types/src/internal/object/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-relation.d.ts +0 -32
- package/dist/types/src/internal/object/typed-relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts +0 -14
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts +0 -6
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
- package/dist/types/src/internal/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts +0 -17
- package/dist/types/src/internal/query/query.d.ts.map +0 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
- package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
- package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -455
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts +0 -10
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -3
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -247
- package/dist/types/src/query/query.d.ts.map +0 -1
- package/dist/types/src/query/query.test.d.ts +0 -2
- package/dist/types/src/query/query.test.d.ts.map +0 -1
- package/dist/types/src/query/tag.d.ts +0 -18
- package/dist/types/src/query/tag.d.ts.map +0 -1
- package/dist/types/src/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -113
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/errors.ts +0 -18
- package/src/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.ts +0 -212
- package/src/internal/ast/entity-kind.ts +0 -15
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/json/index.ts +0 -5
- package/src/internal/object/accessors.ts +0 -115
- package/src/internal/object/entity.ts +0 -204
- package/src/internal/object/expando.ts +0 -21
- package/src/internal/object/meta.ts +0 -62
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typed-relation.ts +0 -85
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/proxy/reactive-object.ts +0 -108
- package/src/internal/query/index.ts +0 -5
- package/src/internal/query/query.ts +0 -23
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/index.ts +0 -6
- package/src/internal/testing/types.ts +0 -211
- package/src/internal/testing/utils.ts +0 -54
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/index.ts +0 -6
- package/src/query/query.test.ts +0 -362
- package/src/query/query.ts +0 -784
- package/src/query/tag.ts +0 -35
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -91
- /package/dist/lib/{browser/index.mjs.map → neutral/Annotation.mjs.map} +0 -0
- /package/dist/lib/{browser/internal/index.mjs.map → neutral/Database.mjs.map} +0 -0
- /package/dist/lib/{browser/query/index.mjs.map → neutral/Entity.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/Err.mjs.map} +0 -0
- /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Feed.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Filter.mjs.map} +0 -0
- /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
package/src/Order.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type QueryAST } from '@dxos/echo-protocol';
|
|
6
|
+
|
|
7
|
+
export interface Order<T> {
|
|
8
|
+
// TODO(dmaretskyi): See new effect-schema approach to variance.
|
|
9
|
+
'~Order': { value: T };
|
|
10
|
+
|
|
11
|
+
ast: QueryAST.Order;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type Any = Order<any>;
|
|
15
|
+
|
|
16
|
+
class OrderClass implements Order<any> {
|
|
17
|
+
private static 'variance': Order<any>['~Order'] = {} as Order<any>['~Order'];
|
|
18
|
+
|
|
19
|
+
static is(value: unknown): value is Order<any> {
|
|
20
|
+
return typeof value === 'object' && value !== null && '~Order' in value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
constructor(public readonly ast: QueryAST.Order) {}
|
|
24
|
+
|
|
25
|
+
'~Order' = OrderClass.variance;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const natural: Order<any> = new OrderClass({ kind: 'natural' });
|
|
29
|
+
export const property = <T>(property: keyof T & string, direction: QueryAST.OrderDirection): Order<T> =>
|
|
30
|
+
new OrderClass({
|
|
31
|
+
kind: 'property',
|
|
32
|
+
property,
|
|
33
|
+
direction,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Order by relevance rank (for FTS/vector search results).
|
|
38
|
+
* Higher rank = better match. Default direction is 'desc' (best matches first).
|
|
39
|
+
*/
|
|
40
|
+
export const rank = <T>(direction: QueryAST.OrderDirection = 'desc'): Order<T> =>
|
|
41
|
+
new OrderClass({
|
|
42
|
+
kind: 'rank',
|
|
43
|
+
direction,
|
|
44
|
+
});
|
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { QueryAST } from '@dxos/echo-protocol';
|
|
9
|
+
import { DXN } from '@dxos/keys';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
|
|
12
|
+
import * as Dataset from './Dataset';
|
|
13
|
+
import * as Feed from './Feed';
|
|
14
|
+
import * as Filter from './Filter';
|
|
15
|
+
import * as Obj from './Obj';
|
|
16
|
+
import * as Order from './Order';
|
|
17
|
+
import * as Query from './Query';
|
|
18
|
+
import * as Ref from './Ref';
|
|
19
|
+
import { TestSchema } from './testing';
|
|
20
|
+
|
|
21
|
+
describe('query api', () => {
|
|
22
|
+
describe('Query', () => {
|
|
23
|
+
test('get all people', () => {
|
|
24
|
+
const getAllPeople = Query.type(TestSchema.Person);
|
|
25
|
+
|
|
26
|
+
log('query', { ast: getAllPeople.ast });
|
|
27
|
+
Schema.validateSync(QueryAST.Query)(getAllPeople.ast);
|
|
28
|
+
log('getAllPeople', { ast: getAllPeople.ast });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('get all people ordered by name', () => {
|
|
32
|
+
const getAllPeopleOrderedByName = Query.type(TestSchema.Person).orderBy(Order.property('name', 'asc'));
|
|
33
|
+
|
|
34
|
+
log('query', { ast: getAllPeopleOrderedByName.ast });
|
|
35
|
+
Schema.validateSync(QueryAST.Query)(getAllPeopleOrderedByName.ast);
|
|
36
|
+
log('getAllPeopleOrderedByName', { ast: getAllPeopleOrderedByName.ast });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('get all people named Fred', () => {
|
|
40
|
+
const PeopleNamedFred = Query.select(Filter.type(TestSchema.Person, { name: 'Fred' }));
|
|
41
|
+
|
|
42
|
+
log('query', { ast: PeopleNamedFred.ast });
|
|
43
|
+
Schema.validateSync(QueryAST.Query)(PeopleNamedFred.ast);
|
|
44
|
+
log('PeopleNamedFred', { ast: PeopleNamedFred.ast });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('get all people with field of "label" set to "Research"', () => {
|
|
48
|
+
const PeopleWithFieldLabelSetToResearch = Query.select(
|
|
49
|
+
Filter.type(TestSchema.Person, { fields: Filter.contains({ label: 'label', value: 'Research' }) }),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
log('query', { ast: PeopleWithFieldLabelSetToResearch.ast });
|
|
53
|
+
Schema.validateSync(QueryAST.Query)(PeopleWithFieldLabelSetToResearch.ast);
|
|
54
|
+
log('PeopleWithFieldLabelSetToResearch', { ast: PeopleWithFieldLabelSetToResearch.ast });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('get all orgs with property "label" set to "Research"', () => {
|
|
58
|
+
const OrgsWithPropertyLabelSetToResearch = Query.select(
|
|
59
|
+
Filter.type(TestSchema.Organization, { properties: { label: 'Research' } }),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
log('query', { ast: OrgsWithPropertyLabelSetToResearch.ast });
|
|
63
|
+
Schema.validateSync(QueryAST.Query)(OrgsWithPropertyLabelSetToResearch.ast);
|
|
64
|
+
log('OrgsWithPropertyLabelSetToResearch', { ast: OrgsWithPropertyLabelSetToResearch.ast });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('get all orgs Fred worked for since 2020', () => {
|
|
68
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
69
|
+
const OrganizationsFredWorkedForSince2020 = Query.select(Filter.type(TestSchema.Person, { id: fred.id }))
|
|
70
|
+
.sourceOf(TestSchema.EmployedBy, { since: Filter.gt('2020') })
|
|
71
|
+
.target();
|
|
72
|
+
|
|
73
|
+
log('query', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
74
|
+
Schema.validateSync(QueryAST.Query)(OrganizationsFredWorkedForSince2020.ast);
|
|
75
|
+
log('OrganizationsFredWorkedForSince2020', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('get all tasks for Fred', () => {
|
|
79
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
80
|
+
const TasksForFred = Query.select(Filter.type(TestSchema.Person, { id: fred.id })).referencedBy(
|
|
81
|
+
TestSchema.Task,
|
|
82
|
+
'assignee',
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
log('query', { ast: TasksForFred.ast });
|
|
86
|
+
Schema.validateSync(QueryAST.Query)(TasksForFred.ast);
|
|
87
|
+
log('TasksForFred', { ast: TasksForFred.ast });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('get all objects referencing Fred (any type, specified property)', () => {
|
|
91
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
92
|
+
const ObjectsReferencingFred = Query.select(Filter.type(TestSchema.Person, { id: fred.id })).referencedBy(
|
|
93
|
+
TestSchema.Task,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
log('query', { ast: ObjectsReferencingFred.ast });
|
|
97
|
+
Schema.validateSync(QueryAST.Query)(ObjectsReferencingFred.ast);
|
|
98
|
+
expect(ObjectsReferencingFred.ast).toMatchObject({
|
|
99
|
+
type: 'incoming-references',
|
|
100
|
+
property: null,
|
|
101
|
+
typename: 'dxn:type:example.com/type/Task:0.1.0',
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('get all objects referencing Fred (any type, any property)', () => {
|
|
106
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
107
|
+
const AllBacklinks = Query.select(Filter.type(TestSchema.Person, { id: fred.id })).referencedBy();
|
|
108
|
+
|
|
109
|
+
log('query', { ast: AllBacklinks.ast });
|
|
110
|
+
Schema.validateSync(QueryAST.Query)(AllBacklinks.ast);
|
|
111
|
+
expect(AllBacklinks.ast).toMatchObject({
|
|
112
|
+
type: 'incoming-references',
|
|
113
|
+
property: null,
|
|
114
|
+
typename: null,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('get all tasks for employees of Cyberdyne', () => {
|
|
119
|
+
const TasksForEmployeesOfCyberdyne = Query.select(Filter.type(TestSchema.Organization, { name: 'Cyberdyne' }))
|
|
120
|
+
.targetOf(TestSchema.EmployedBy)
|
|
121
|
+
.source()
|
|
122
|
+
.referencedBy(TestSchema.Task, 'assignee');
|
|
123
|
+
|
|
124
|
+
log('query', { ast: TasksForEmployeesOfCyberdyne.ast });
|
|
125
|
+
Schema.validateSync(QueryAST.Query)(TasksForEmployeesOfCyberdyne.ast);
|
|
126
|
+
log('TasksForEmployeesOfCyberdyne', { ast: TasksForEmployeesOfCyberdyne.ast });
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('get all people or orgs', () => {
|
|
130
|
+
const PeopleOrOrganizations = Query.all(
|
|
131
|
+
Query.select(Filter.type(TestSchema.Person)),
|
|
132
|
+
Query.select(Filter.type(TestSchema.Organization)),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
log('query', { ast: PeopleOrOrganizations.ast });
|
|
136
|
+
Schema.validateSync(QueryAST.Query)(PeopleOrOrganizations.ast);
|
|
137
|
+
log('PeopleOrOrganizations', { ast: PeopleOrOrganizations.ast });
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('Filter.query(Dataset.Dataset) (union of schemas)', () => {
|
|
141
|
+
const AllDatasets = Query.select(Filter.type(Dataset.Dataset));
|
|
142
|
+
|
|
143
|
+
log('query', { ast: AllDatasets.ast });
|
|
144
|
+
Schema.validateSync(QueryAST.Query)(AllDatasets.ast);
|
|
145
|
+
log('AllDatasets', { ast: AllDatasets.ast });
|
|
146
|
+
expect(AllDatasets.ast).toMatchInlineSnapshot(`
|
|
147
|
+
{
|
|
148
|
+
"filter": {
|
|
149
|
+
"filters": [
|
|
150
|
+
{
|
|
151
|
+
"props": {},
|
|
152
|
+
"type": "object",
|
|
153
|
+
"typename": "dxn:type:dxos.org/type/Feed:0.1.0",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"props": {},
|
|
157
|
+
"type": "object",
|
|
158
|
+
"typename": "dxn:type:dxos.org/type/Collection:0.1.0",
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"props": {},
|
|
162
|
+
"type": "object",
|
|
163
|
+
"typename": "dxn:type:dxos.org/type/View:0.5.0",
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
"type": "or",
|
|
167
|
+
},
|
|
168
|
+
"type": "select",
|
|
169
|
+
}
|
|
170
|
+
`);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('Query.type(Dataset.Dataset) (union of schemas)', () => {
|
|
174
|
+
const AllDatasets = Query.type(Dataset.Dataset);
|
|
175
|
+
|
|
176
|
+
log('query', { ast: AllDatasets.ast });
|
|
177
|
+
Schema.validateSync(QueryAST.Query)(AllDatasets.ast);
|
|
178
|
+
log('AllDatasets', { ast: AllDatasets.ast });
|
|
179
|
+
expect(AllDatasets.ast).toMatchInlineSnapshot(`
|
|
180
|
+
{
|
|
181
|
+
"filter": {
|
|
182
|
+
"filters": [
|
|
183
|
+
{
|
|
184
|
+
"props": {},
|
|
185
|
+
"type": "object",
|
|
186
|
+
"typename": "dxn:type:dxos.org/type/Feed:0.1.0",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"props": {},
|
|
190
|
+
"type": "object",
|
|
191
|
+
"typename": "dxn:type:dxos.org/type/Collection:0.1.0",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"props": {},
|
|
195
|
+
"type": "object",
|
|
196
|
+
"typename": "dxn:type:dxos.org/type/View:0.5.0",
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
"type": "or",
|
|
200
|
+
},
|
|
201
|
+
"type": "select",
|
|
202
|
+
}
|
|
203
|
+
`);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test('get all people not in orgs', () => {
|
|
207
|
+
const PeopleNotInOrganizations = Query.without(
|
|
208
|
+
Query.select(Filter.type(TestSchema.Person)),
|
|
209
|
+
Query.select(Filter.type(TestSchema.Person)).sourceOf(TestSchema.EmployedBy).source(),
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
log('query', { ast: PeopleNotInOrganizations.ast });
|
|
213
|
+
Schema.validateSync(QueryAST.Query)(PeopleNotInOrganizations.ast);
|
|
214
|
+
log('PeopleNotInOrganizations', { ast: PeopleNotInOrganizations.ast });
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('get assignees of all tasks created after 2020', () => {
|
|
218
|
+
const AssigneesOfAllTasksCreatedAfter2020 = Query.select(
|
|
219
|
+
Filter.type(TestSchema.Task, { deadline: Filter.gt('2020') }),
|
|
220
|
+
).reference('assignee');
|
|
221
|
+
|
|
222
|
+
log('query', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
223
|
+
Schema.validateSync(QueryAST.Query)(AssigneesOfAllTasksCreatedAfter2020.ast);
|
|
224
|
+
log('AssigneesOfAllTasksCreatedAfter2020', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test('untyped full-text search', () => {
|
|
228
|
+
const contactFullTextSearch = Query.select(Filter.text('Bill'));
|
|
229
|
+
|
|
230
|
+
log('query', { ast: contactFullTextSearch.ast });
|
|
231
|
+
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
232
|
+
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
233
|
+
{
|
|
234
|
+
"filter": {
|
|
235
|
+
"searchKind": undefined,
|
|
236
|
+
"text": "Bill",
|
|
237
|
+
"type": "text-search",
|
|
238
|
+
},
|
|
239
|
+
"type": "select",
|
|
240
|
+
}
|
|
241
|
+
`);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test('typed full-text search', () => {
|
|
245
|
+
const contactFullTextSearch = Query.select(Filter.type(TestSchema.Person)).select(Filter.text('Bill'));
|
|
246
|
+
|
|
247
|
+
log('query', { ast: contactFullTextSearch.ast });
|
|
248
|
+
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
249
|
+
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
250
|
+
{
|
|
251
|
+
"filter": {
|
|
252
|
+
"searchKind": undefined,
|
|
253
|
+
"text": "Bill",
|
|
254
|
+
"type": "text-search",
|
|
255
|
+
},
|
|
256
|
+
"selection": {
|
|
257
|
+
"filter": {
|
|
258
|
+
"id": undefined,
|
|
259
|
+
"props": {},
|
|
260
|
+
"type": "object",
|
|
261
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
262
|
+
},
|
|
263
|
+
"type": "select",
|
|
264
|
+
},
|
|
265
|
+
"type": "filter",
|
|
266
|
+
}
|
|
267
|
+
`);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test('filter by ref', () => {
|
|
271
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
272
|
+
const tasksByFred = Filter.type(TestSchema.Task, { assignee: Ref.make(fred) });
|
|
273
|
+
expect(tasksByFred.ast).toEqual({
|
|
274
|
+
props: {
|
|
275
|
+
assignee: {
|
|
276
|
+
operator: 'eq',
|
|
277
|
+
type: 'compare',
|
|
278
|
+
value: {
|
|
279
|
+
'/': DXN.fromLocalObjectId(fred.id).toString(),
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
type: 'object',
|
|
284
|
+
typename: 'dxn:type:example.com/type/Task:0.1.0',
|
|
285
|
+
});
|
|
286
|
+
log('tasksByFred', { ast: tasksByFred.ast });
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('select orgs and people', () => {
|
|
290
|
+
const orgsAndPeople = Query.select(
|
|
291
|
+
Filter.or(Filter.type(TestSchema.Organization), Filter.type(TestSchema.Person)),
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
Schema.validateSync(QueryAST.Query)(orgsAndPeople.ast);
|
|
295
|
+
expect(orgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
296
|
+
{
|
|
297
|
+
"filter": {
|
|
298
|
+
"filters": [
|
|
299
|
+
{
|
|
300
|
+
"id": undefined,
|
|
301
|
+
"props": {},
|
|
302
|
+
"type": "object",
|
|
303
|
+
"typename": "dxn:type:example.com/type/Organization:0.1.0",
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"id": undefined,
|
|
307
|
+
"props": {},
|
|
308
|
+
"type": "object",
|
|
309
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
"type": "or",
|
|
313
|
+
},
|
|
314
|
+
"type": "select",
|
|
315
|
+
}
|
|
316
|
+
`);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test('select everything but orgs and people', () => {
|
|
320
|
+
const everythingButOrgsAndPeople = Query.select(
|
|
321
|
+
Filter.not(Filter.or(Filter.type(TestSchema.Organization), Filter.type(TestSchema.Person))),
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
Schema.validateSync(QueryAST.Query)(everythingButOrgsAndPeople.ast);
|
|
325
|
+
expect(everythingButOrgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
326
|
+
{
|
|
327
|
+
"filter": {
|
|
328
|
+
"filter": {
|
|
329
|
+
"filters": [
|
|
330
|
+
{
|
|
331
|
+
"id": undefined,
|
|
332
|
+
"props": {},
|
|
333
|
+
"type": "object",
|
|
334
|
+
"typename": "dxn:type:example.com/type/Organization:0.1.0",
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"id": undefined,
|
|
338
|
+
"props": {},
|
|
339
|
+
"type": "object",
|
|
340
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
"type": "or",
|
|
344
|
+
},
|
|
345
|
+
"type": "not",
|
|
346
|
+
},
|
|
347
|
+
"type": "select",
|
|
348
|
+
}
|
|
349
|
+
`);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test('select deleted tasks', () => {
|
|
353
|
+
const deletedTasks = Query.select(Filter.type(TestSchema.Task)).options({
|
|
354
|
+
deleted: 'only',
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
Schema.validateSync(QueryAST.Query)(deletedTasks.ast);
|
|
358
|
+
expect(deletedTasks.ast).toMatchInlineSnapshot(`
|
|
359
|
+
{
|
|
360
|
+
"options": {
|
|
361
|
+
"deleted": "only",
|
|
362
|
+
},
|
|
363
|
+
"query": {
|
|
364
|
+
"filter": {
|
|
365
|
+
"id": undefined,
|
|
366
|
+
"props": {},
|
|
367
|
+
"type": "object",
|
|
368
|
+
"typename": "dxn:type:example.com/type/Task:0.1.0",
|
|
369
|
+
},
|
|
370
|
+
"type": "select",
|
|
371
|
+
},
|
|
372
|
+
"type": "options",
|
|
373
|
+
}
|
|
374
|
+
`);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
test('filter by tags', () => {
|
|
378
|
+
const query = Query.select(Filter.type(TestSchema.Task)).select(Filter.tag('important'));
|
|
379
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
380
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
381
|
+
{
|
|
382
|
+
"filter": {
|
|
383
|
+
"tag": "important",
|
|
384
|
+
"type": "tag",
|
|
385
|
+
},
|
|
386
|
+
"selection": {
|
|
387
|
+
"filter": {
|
|
388
|
+
"id": undefined,
|
|
389
|
+
"props": {},
|
|
390
|
+
"type": "object",
|
|
391
|
+
"typename": "dxn:type:example.com/type/Task:0.1.0",
|
|
392
|
+
},
|
|
393
|
+
"type": "select",
|
|
394
|
+
},
|
|
395
|
+
"type": "filter",
|
|
396
|
+
}
|
|
397
|
+
`);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
test('limit results', () => {
|
|
401
|
+
const query = Query.select(Filter.type(TestSchema.Task)).limit(10);
|
|
402
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
403
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
404
|
+
{
|
|
405
|
+
"limit": 10,
|
|
406
|
+
"query": {
|
|
407
|
+
"filter": {
|
|
408
|
+
"id": undefined,
|
|
409
|
+
"props": {},
|
|
410
|
+
"type": "object",
|
|
411
|
+
"typename": "dxn:type:example.com/type/Task:0.1.0",
|
|
412
|
+
},
|
|
413
|
+
"type": "select",
|
|
414
|
+
},
|
|
415
|
+
"type": "limit",
|
|
416
|
+
}
|
|
417
|
+
`);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
test('ordered and limited results', () => {
|
|
421
|
+
const query = Query.select(Filter.type(TestSchema.Task)).orderBy(Order.property('title', 'asc')).limit(10);
|
|
422
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
423
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
424
|
+
{
|
|
425
|
+
"limit": 10,
|
|
426
|
+
"query": {
|
|
427
|
+
"order": [
|
|
428
|
+
{
|
|
429
|
+
"direction": "asc",
|
|
430
|
+
"kind": "property",
|
|
431
|
+
"property": "title",
|
|
432
|
+
},
|
|
433
|
+
],
|
|
434
|
+
"query": {
|
|
435
|
+
"filter": {
|
|
436
|
+
"id": undefined,
|
|
437
|
+
"props": {},
|
|
438
|
+
"type": "object",
|
|
439
|
+
"typename": "dxn:type:example.com/type/Task:0.1.0",
|
|
440
|
+
},
|
|
441
|
+
"type": "select",
|
|
442
|
+
},
|
|
443
|
+
"type": "order",
|
|
444
|
+
},
|
|
445
|
+
"type": "limit",
|
|
446
|
+
}
|
|
447
|
+
`);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
test('union of limited queries', () => {
|
|
451
|
+
const query = Query.all(
|
|
452
|
+
Query.select(Filter.type(TestSchema.Person)).limit(5),
|
|
453
|
+
Query.select(Filter.type(TestSchema.Organization)).limit(5),
|
|
454
|
+
);
|
|
455
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
456
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
457
|
+
{
|
|
458
|
+
"queries": [
|
|
459
|
+
{
|
|
460
|
+
"limit": 5,
|
|
461
|
+
"query": {
|
|
462
|
+
"filter": {
|
|
463
|
+
"id": undefined,
|
|
464
|
+
"props": {},
|
|
465
|
+
"type": "object",
|
|
466
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
467
|
+
},
|
|
468
|
+
"type": "select",
|
|
469
|
+
},
|
|
470
|
+
"type": "limit",
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"limit": 5,
|
|
474
|
+
"query": {
|
|
475
|
+
"filter": {
|
|
476
|
+
"id": undefined,
|
|
477
|
+
"props": {},
|
|
478
|
+
"type": "object",
|
|
479
|
+
"typename": "dxn:type:example.com/type/Organization:0.1.0",
|
|
480
|
+
},
|
|
481
|
+
"type": "select",
|
|
482
|
+
},
|
|
483
|
+
"type": "limit",
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
"type": "union",
|
|
487
|
+
}
|
|
488
|
+
`);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
test('from all accessible spaces', () => {
|
|
492
|
+
const query = Query.select(Filter.type(TestSchema.Person)).from('all-accessible-spaces');
|
|
493
|
+
|
|
494
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
495
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
496
|
+
{
|
|
497
|
+
"from": {
|
|
498
|
+
"_tag": "scope",
|
|
499
|
+
"scope": {},
|
|
500
|
+
},
|
|
501
|
+
"query": {
|
|
502
|
+
"filter": {
|
|
503
|
+
"id": undefined,
|
|
504
|
+
"props": {},
|
|
505
|
+
"type": "object",
|
|
506
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
507
|
+
},
|
|
508
|
+
"type": "select",
|
|
509
|
+
},
|
|
510
|
+
"type": "from",
|
|
511
|
+
}
|
|
512
|
+
`);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
test('from all accessible spaces with feeds', () => {
|
|
516
|
+
const query = Query.select(Filter.type(TestSchema.Person)).from('all-accessible-spaces', {
|
|
517
|
+
includeFeeds: true,
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
521
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
522
|
+
{
|
|
523
|
+
"from": {
|
|
524
|
+
"_tag": "scope",
|
|
525
|
+
"scope": {
|
|
526
|
+
"allQueuesFromSpaces": true,
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
"query": {
|
|
530
|
+
"filter": {
|
|
531
|
+
"id": undefined,
|
|
532
|
+
"props": {},
|
|
533
|
+
"type": "object",
|
|
534
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
535
|
+
},
|
|
536
|
+
"type": "select",
|
|
537
|
+
},
|
|
538
|
+
"type": "from",
|
|
539
|
+
}
|
|
540
|
+
`);
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
test('from all accessible spaces with ordering and limit', () => {
|
|
544
|
+
const query = Query.select(Filter.type(TestSchema.Person))
|
|
545
|
+
.orderBy(Order.property('name', 'asc'))
|
|
546
|
+
.limit(10)
|
|
547
|
+
.from('all-accessible-spaces');
|
|
548
|
+
|
|
549
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
550
|
+
expect(query.ast).toMatchObject({
|
|
551
|
+
type: 'from',
|
|
552
|
+
from: { _tag: 'scope', scope: {} },
|
|
553
|
+
query: {
|
|
554
|
+
type: 'limit',
|
|
555
|
+
limit: 10,
|
|
556
|
+
query: {
|
|
557
|
+
type: 'order',
|
|
558
|
+
},
|
|
559
|
+
},
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
test('Query.type(...).from(feed) sets queue scope', () => {
|
|
564
|
+
const feed = Feed.make({ name: 'test-feed' });
|
|
565
|
+
const queueDxn = DXN.parse('dxn:echo:test-space:test-queue');
|
|
566
|
+
Obj.change(feed, (mutable) => {
|
|
567
|
+
Obj.getMeta(mutable).keys.push({ source: Feed.DXN_KEY, id: queueDxn.toString() });
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
const query = Query.type(TestSchema.Person).from(feed);
|
|
571
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
572
|
+
expect(query.ast).toMatchObject({
|
|
573
|
+
type: 'from',
|
|
574
|
+
from: {
|
|
575
|
+
_tag: 'scope',
|
|
576
|
+
scope: {
|
|
577
|
+
queues: [queueDxn.toString()],
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
query: {
|
|
581
|
+
type: 'select',
|
|
582
|
+
filter: {
|
|
583
|
+
type: 'object',
|
|
584
|
+
typename: 'dxn:type:example.com/type/Person:0.1.0',
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
test.skip('chain', () => {
|
|
591
|
+
// NOTE: Can't support props without type since they can't be inferred.
|
|
592
|
+
// const f1: Filter<Person> = Filter.props({ name: 'Fred' });
|
|
593
|
+
|
|
594
|
+
// const x = Query.select(Filter.props({ id: '123' }));
|
|
595
|
+
const y = Query.select(Filter.type(TestSchema.Person));
|
|
596
|
+
|
|
597
|
+
const or = Filter.or(
|
|
598
|
+
Filter.type(TestSchema.Person, { id: Filter.in('1', '2', '3') }),
|
|
599
|
+
Filter.type(TestSchema.Organization),
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
const and = Filter.and(
|
|
603
|
+
Filter.type(TestSchema.Person, { id: Filter.in('1', '2', '3') }),
|
|
604
|
+
Filter.type(TestSchema.Person, { name: 'Fred' }),
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
const q = Query
|
|
608
|
+
//
|
|
609
|
+
// NOTE: Can't support functions since they can't be serialized (to server).
|
|
610
|
+
// .filter((object) => Math.random() > 0.5)
|
|
611
|
+
.select(Filter.type(TestSchema.Person))
|
|
612
|
+
.select(Filter.type(TestSchema.Person, { name: 'Fred' }))
|
|
613
|
+
.select({ age: Filter.between(20, 40) })
|
|
614
|
+
.select(
|
|
615
|
+
Filter.and(
|
|
616
|
+
Filter.type(TestSchema.Person),
|
|
617
|
+
Filter.type(TestSchema.Person, { name: Filter.in('bob', 'bill') }),
|
|
618
|
+
),
|
|
619
|
+
);
|
|
620
|
+
|
|
621
|
+
log('stuff', { fOr: or, fAnd: and, q, y });
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
describe('Filter', () => {
|
|
626
|
+
test('Filter.or(Filter.typename(...))', () => {
|
|
627
|
+
const filter = Filter.or(Filter.typename('example.com/type/Person'));
|
|
628
|
+
// TODO(dmaretskyi): Give vitest type-tests a try.
|
|
629
|
+
const _isAssignable: Obj.Unknown = null as any as Filter.Type<typeof filter>;
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
});
|