@dxos/echo 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
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/dist/lib/browser/{chunk-MWLA34S5.mjs → chunk-7GH6RXJ3.mjs} +2513 -2673
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +7 -0
- package/dist/lib/browser/chunk-E4UTVJNF.mjs +1111 -0
- package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -19
- package/dist/lib/browser/internal/index.mjs +55 -45
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +247 -217
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +1111 -0
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YTNLFBIK.mjs → chunk-M4B6BMD2.mjs} +2513 -2673
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -19
- package/dist/lib/node-esm/internal/index.mjs +55 -45
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +247 -217
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/Annotation.d.ts +2 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +137 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +36 -0
- package/dist/types/src/Entity.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/JsonSchema.d.ts +9 -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 +85 -62
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +10 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +14 -11
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +17 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +39 -49
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +14 -18
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +7 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +174 -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 +26 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +10 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{object → entities}/expando.d.ts +3 -1
- package/dist/types/src/internal/entities/expando.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 +70 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +11 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +55 -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 +2 -0
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/types.d.ts +7 -7
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +6 -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-type.d.ts.map +1 -1
- package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -5
- 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/common.d.ts.map +1 -1
- package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +9 -10
- 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 +3 -12
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +1 -2
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/object/typed-object.d.ts +1 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
- package/dist/types/src/internal/proxy/index.d.ts +3 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +1 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +15 -12
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- 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 +9 -9
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +3 -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 +18 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +1 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -1
- package/dist/types/src/internal/types/base.d.ts +37 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{ast/entity-kind.d.ts → types/entity.d.ts} +3 -1
- 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 +20 -11
- package/dist/types/src/internal/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/types/typename.d.ts +13 -0
- package/dist/types/src/internal/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{object → types}/version.d.ts +3 -2
- package/dist/types/src/internal/types/version.d.ts.map +1 -0
- package/dist/types/src/query/filter.d.ts +167 -0
- package/dist/types/src/query/filter.d.ts.map +1 -0
- package/dist/types/src/query/index.d.ts +3 -1
- package/dist/types/src/query/index.d.ts.map +1 -1
- package/dist/types/src/query/order.d.ts +12 -0
- package/dist/types/src/query/order.d.ts.map +1 -0
- package/dist/types/src/query/query.d.ts +9 -144
- package/dist/types/src/query/query.d.ts.map +1 -1
- package/dist/types/src/query/testing.d.ts +51 -0
- package/dist/types/src/query/testing.d.ts.map +1 -0
- package/dist/types/src/{internal/query/query.d.ts → query/types.d.ts} +1 -1
- package/dist/types/src/query/types.d.ts.map +1 -0
- package/dist/types/src/query/util.d.ts +8 -0
- package/dist/types/src/query/util.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 +337 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/{internal/testing/utils.d.ts → testing/util.d.ts} +11 -5
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -38
- package/src/Annotation.ts +17 -0
- package/src/Database.ts +189 -0
- package/src/Entity.ts +51 -0
- package/src/Format.ts +11 -0
- package/src/JsonSchema.ts +16 -0
- package/src/Key.ts +3 -0
- package/src/Obj.ts +260 -147
- package/src/Ref.ts +9 -9
- package/src/Relation.ts +58 -44
- package/src/Tag.ts +40 -0
- package/src/Type.ts +96 -83
- package/src/index.ts +10 -4
- package/src/internal/README.md +83 -0
- package/src/internal/{ast → annotations}/annotations.test.ts +13 -15
- package/src/internal/annotations/annotations.ts +463 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +70 -0
- package/src/internal/entities/entity.ts +109 -0
- package/src/internal/{object → entities}/expando.ts +7 -5
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +129 -0
- package/src/internal/entities/object.ts +45 -0
- package/src/internal/entities/relation.ts +155 -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 +5 -5
- package/src/internal/formats/format.ts +3 -0
- package/src/internal/formats/number.ts +5 -5
- package/src/internal/formats/object.ts +2 -2
- package/src/internal/formats/string.ts +9 -9
- package/src/internal/formats/types.ts +44 -39
- package/src/internal/index.ts +29 -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-type.ts +4 -3
- package/src/internal/{json → json-schema}/json-schema.test.ts +230 -97
- package/src/internal/{json → json-schema}/json-schema.ts +67 -87
- 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} +34 -35
- package/src/internal/object/deleted.ts +6 -6
- package/src/internal/object/ids.ts +1 -1
- package/src/internal/object/index.ts +3 -12
- package/src/internal/object/inspect.ts +3 -5
- package/src/internal/object/json-serializer.test.ts +33 -38
- package/src/internal/object/json-serializer.ts +43 -38
- package/src/internal/object/schema-validator.ts +3 -2
- package/src/internal/object/typed-object.test.ts +1 -1
- package/src/internal/object/typed-object.ts +17 -4
- package/src/internal/proxy/handler.test.ts +30 -20
- package/src/internal/proxy/index.ts +6 -0
- package/src/internal/proxy/{reactive-object.ts → make-object.ts} +19 -14
- package/src/internal/proxy/schema.test.ts +5 -4
- package/src/internal/proxy/typed-handler.test.ts +28 -28
- package/src/internal/proxy/typed-handler.ts +11 -6
- package/src/internal/proxy/typed-object.test.ts +17 -12
- package/src/internal/ref/ref.test.ts +9 -8
- package/src/internal/ref/ref.ts +24 -20
- package/src/internal/{projection → schema}/compose.test.ts +5 -6
- package/src/internal/{projection → schema}/compose.ts +2 -1
- package/src/internal/schema/echo-schema.ts +30 -28
- package/src/internal/schema/index.ts +3 -4
- package/src/internal/schema/manipulation.ts +7 -1
- package/src/internal/schema/persistent-schema.ts +28 -0
- package/src/internal/schema/runtime-schema-registry.ts +4 -4
- package/src/internal/types/base.ts +58 -0
- package/src/internal/{ast/entity-kind.ts → types/entity.ts} +8 -0
- package/src/internal/types/index.ts +5 -2
- package/src/internal/{object → types}/meta.ts +32 -18
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/query/filter.ts +455 -0
- package/src/query/index.ts +4 -1
- package/src/query/order.ts +34 -0
- package/src/query/query.test.ts +188 -216
- package/src/query/query.ts +24 -505
- package/src/query/testing.ts +64 -0
- package/src/query/util.ts +25 -0
- package/src/testing/api.test.ts +100 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +213 -0
- package/src/{internal/testing/utils.ts → testing/util.ts} +38 -14
- 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/query/index.mjs +0 -23
- package/dist/lib/browser/query/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.map +0 -7
- package/dist/lib/node-esm/query/index.mjs +0 -23
- package/dist/lib/node-esm/query/index.mjs.map +0 -7
- 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.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.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.map +0 -1
- 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.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.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/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/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.ts +0 -212
- 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/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/query/index.ts +0 -5
- 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/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/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/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.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/{internal/query/query.ts → query/types.ts} +0 -0
package/src/query/query.test.ts
CHANGED
|
@@ -11,187 +11,127 @@ import { log } from '@dxos/log';
|
|
|
11
11
|
|
|
12
12
|
import * as Obj from '../Obj';
|
|
13
13
|
import * as Ref from '../Ref';
|
|
14
|
-
import * as Type from '../Type';
|
|
15
14
|
|
|
16
|
-
import { Filter
|
|
15
|
+
import { Filter } from './filter';
|
|
16
|
+
import { Order } from './order';
|
|
17
|
+
import { Query } from './query';
|
|
18
|
+
import * as Test from './testing';
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// TODO(dmaretskyi): Need common set of test types.
|
|
23
|
-
const Person = Schema.Struct({
|
|
24
|
-
name: Schema.String,
|
|
25
|
-
email: Schema.optional(Schema.String),
|
|
26
|
-
age: Schema.optional(Schema.Number),
|
|
27
|
-
fields: Schema.Struct({
|
|
28
|
-
label: Schema.String,
|
|
29
|
-
value: Schema.String,
|
|
30
|
-
}).pipe(Schema.Array, Schema.optional),
|
|
31
|
-
}).pipe(
|
|
32
|
-
Type.Obj({
|
|
33
|
-
typename: 'dxos.org/type/Person',
|
|
34
|
-
version: '0.1.0',
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
37
|
-
interface Person extends Schema.Schema.Type<typeof Person> {}
|
|
38
|
-
|
|
39
|
-
const Organization = Schema.Struct({
|
|
40
|
-
name: Schema.String,
|
|
41
|
-
properties: Schema.optional(
|
|
42
|
-
Schema.Record({
|
|
43
|
-
key: Schema.String,
|
|
44
|
-
value: Schema.String,
|
|
45
|
-
}),
|
|
46
|
-
),
|
|
47
|
-
}).pipe(
|
|
48
|
-
Type.Obj({
|
|
49
|
-
typename: 'dxos.org/type/Organization',
|
|
50
|
-
version: '0.1.0',
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
53
|
-
interface Organization extends Schema.Schema.Type<typeof Organization> {}
|
|
54
|
-
|
|
55
|
-
const WorksFor = Schema.Struct({
|
|
56
|
-
since: Schema.String,
|
|
57
|
-
}).pipe(
|
|
58
|
-
Type.Relation({
|
|
59
|
-
typename: 'dxos.org/type/WorksFor',
|
|
60
|
-
version: '0.1.0',
|
|
61
|
-
source: Person,
|
|
62
|
-
target: Organization,
|
|
63
|
-
}),
|
|
64
|
-
);
|
|
65
|
-
interface WorksFor extends Schema.Schema.Type<typeof WorksFor> {}
|
|
66
|
-
|
|
67
|
-
const Task = Schema.Struct({
|
|
68
|
-
title: Schema.String,
|
|
69
|
-
createdAt: Schema.String,
|
|
70
|
-
assignee: Schema.optional(Type.Ref(Person)),
|
|
71
|
-
}).pipe(Type.Obj({ typename: 'dxos.org/type/Task', version: '0.1.0' }));
|
|
72
|
-
interface Task extends Schema.Schema.Type<typeof Task> {}
|
|
20
|
+
describe('query api', () => {
|
|
21
|
+
describe('Query', () => {
|
|
22
|
+
test('get all people', () => {
|
|
23
|
+
const getAllPeople = Query.type(Test.Person);
|
|
73
24
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
25
|
+
log('query', { ast: getAllPeople.ast });
|
|
26
|
+
Schema.validateSync(QueryAST.Query)(getAllPeople.ast);
|
|
27
|
+
log('getAllPeople', { ast: getAllPeople.ast });
|
|
28
|
+
});
|
|
77
29
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const getAllPeople = Query.type(Person);
|
|
30
|
+
test('get all people ordered by name', () => {
|
|
31
|
+
const getAllPeopleOrderedByName = Query.type(Test.Person).orderBy(Order.property('name', 'asc'));
|
|
81
32
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
33
|
+
log('query', { ast: getAllPeopleOrderedByName.ast });
|
|
34
|
+
Schema.validateSync(QueryAST.Query)(getAllPeopleOrderedByName.ast);
|
|
35
|
+
log('getAllPeopleOrderedByName', { ast: getAllPeopleOrderedByName.ast });
|
|
36
|
+
});
|
|
86
37
|
|
|
87
|
-
|
|
88
|
-
|
|
38
|
+
test('get all people named Fred', () => {
|
|
39
|
+
const PeopleNamedFred = Query.select(Filter.type(Test.Person, { name: 'Fred' }));
|
|
89
40
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
41
|
+
log('query', { ast: PeopleNamedFred.ast });
|
|
42
|
+
Schema.validateSync(QueryAST.Query)(PeopleNamedFred.ast);
|
|
43
|
+
log('PeopleNamedFred', { ast: PeopleNamedFred.ast });
|
|
44
|
+
});
|
|
94
45
|
|
|
95
|
-
|
|
96
|
-
|
|
46
|
+
test('get all people with field of "label" set to "Research"', () => {
|
|
47
|
+
const PeopleWithFieldLabelSetToResearch = Query.select(
|
|
48
|
+
Filter.type(Test.Person, { fields: Filter.contains({ label: 'label', value: 'Research' }) }),
|
|
49
|
+
);
|
|
97
50
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
51
|
+
log('query', { ast: PeopleWithFieldLabelSetToResearch.ast });
|
|
52
|
+
Schema.validateSync(QueryAST.Query)(PeopleWithFieldLabelSetToResearch.ast);
|
|
53
|
+
log('PeopleWithFieldLabelSetToResearch', { ast: PeopleWithFieldLabelSetToResearch.ast });
|
|
54
|
+
});
|
|
102
55
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
56
|
+
test('get all orgs with property "label" set to "Research"', () => {
|
|
57
|
+
const OrgsWithPropertyLabelSetToResearch = Query.select(
|
|
58
|
+
Filter.type(Test.Organization, { properties: { label: 'Research' } }),
|
|
59
|
+
);
|
|
107
60
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
61
|
+
log('query', { ast: OrgsWithPropertyLabelSetToResearch.ast });
|
|
62
|
+
Schema.validateSync(QueryAST.Query)(OrgsWithPropertyLabelSetToResearch.ast);
|
|
63
|
+
log('OrgsWithPropertyLabelSetToResearch', { ast: OrgsWithPropertyLabelSetToResearch.ast });
|
|
64
|
+
});
|
|
112
65
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Filter.type(
|
|
116
|
-
|
|
66
|
+
test('get all orgs Fred worked for since 2020', () => {
|
|
67
|
+
const fred = Obj.make(Test.Person, { name: 'Fred' });
|
|
68
|
+
const OrganizationsFredWorkedForSince2020 = Query.select(Filter.type(Test.Person, { id: fred.id }))
|
|
69
|
+
.sourceOf(Test.WorksFor, { since: Filter.gt('2020') })
|
|
70
|
+
.target();
|
|
117
71
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
72
|
+
log('query', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
73
|
+
Schema.validateSync(QueryAST.Query)(OrganizationsFredWorkedForSince2020.ast);
|
|
74
|
+
log('OrganizationsFredWorkedForSince2020', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
75
|
+
});
|
|
122
76
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
.sourceOf(WorksFor, { since: Filter.gt('2020') })
|
|
127
|
-
.target();
|
|
128
|
-
|
|
129
|
-
log('query', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
130
|
-
Schema.validateSync(QueryAST.Query)(OrganizationsFredWorkedForSince2020.ast);
|
|
131
|
-
console.log(
|
|
132
|
-
'OrganizationsFredWorkedForSince2020',
|
|
133
|
-
JSON.stringify(OrganizationsFredWorkedForSince2020.ast, null, 2),
|
|
134
|
-
);
|
|
135
|
-
});
|
|
77
|
+
test('get all tasks for Fred', () => {
|
|
78
|
+
const fred = Obj.make(Test.Person, { name: 'Fred' });
|
|
79
|
+
const TasksForFred = Query.select(Filter.type(Test.Person, { id: fred.id })).referencedBy(Test.Task, 'assignee');
|
|
136
80
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
81
|
+
log('query', { ast: TasksForFred.ast });
|
|
82
|
+
Schema.validateSync(QueryAST.Query)(TasksForFred.ast);
|
|
83
|
+
log('TasksForFred', { ast: TasksForFred.ast });
|
|
84
|
+
});
|
|
140
85
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
86
|
+
test('get all tasks for employees of Cyberdyne', () => {
|
|
87
|
+
const TasksForEmployeesOfCyberdyne = Query.select(Filter.type(Test.Organization, { name: 'Cyberdyne' }))
|
|
88
|
+
.targetOf(Test.WorksFor)
|
|
89
|
+
.source()
|
|
90
|
+
.referencedBy(Test.Task, 'assignee');
|
|
145
91
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
.referencedBy(Task, 'assignee');
|
|
92
|
+
log('query', { ast: TasksForEmployeesOfCyberdyne.ast });
|
|
93
|
+
Schema.validateSync(QueryAST.Query)(TasksForEmployeesOfCyberdyne.ast);
|
|
94
|
+
log('TasksForEmployeesOfCyberdyne', { ast: TasksForEmployeesOfCyberdyne.ast });
|
|
95
|
+
});
|
|
151
96
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
97
|
+
test('get all people or orgs', () => {
|
|
98
|
+
const PeopleOrOrganizations = Query.all(
|
|
99
|
+
Query.select(Filter.type(Test.Person)),
|
|
100
|
+
Query.select(Filter.type(Test.Organization)),
|
|
101
|
+
);
|
|
156
102
|
|
|
157
|
-
|
|
158
|
-
|
|
103
|
+
log('query', { ast: PeopleOrOrganizations.ast });
|
|
104
|
+
Schema.validateSync(QueryAST.Query)(PeopleOrOrganizations.ast);
|
|
105
|
+
log('PeopleOrOrganizations', { ast: PeopleOrOrganizations.ast });
|
|
106
|
+
});
|
|
159
107
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
108
|
+
test('get all people not in orgs', () => {
|
|
109
|
+
const PeopleNotInOrganizations = Query.without(
|
|
110
|
+
Query.select(Filter.type(Test.Person)),
|
|
111
|
+
Query.select(Filter.type(Test.Person)).sourceOf(Test.WorksFor).source(),
|
|
112
|
+
);
|
|
164
113
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
);
|
|
114
|
+
log('query', { ast: PeopleNotInOrganizations.ast });
|
|
115
|
+
Schema.validateSync(QueryAST.Query)(PeopleNotInOrganizations.ast);
|
|
116
|
+
log('PeopleNotInOrganizations', { ast: PeopleNotInOrganizations.ast });
|
|
117
|
+
});
|
|
170
118
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
119
|
+
test('get assignees of all tasks created after 2020', () => {
|
|
120
|
+
const AssigneesOfAllTasksCreatedAfter2020 = Query.select(
|
|
121
|
+
Filter.type(Test.Task, { createdAt: Filter.gt('2020') }),
|
|
122
|
+
).reference('assignee');
|
|
175
123
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
log('query', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
182
|
-
Schema.validateSync(QueryAST.Query)(AssigneesOfAllTasksCreatedAfter2020.ast);
|
|
183
|
-
console.log(
|
|
184
|
-
'AssigneesOfAllTasksCreatedAfter2020',
|
|
185
|
-
JSON.stringify(AssigneesOfAllTasksCreatedAfter2020.ast, null, 2),
|
|
186
|
-
);
|
|
187
|
-
});
|
|
124
|
+
log('query', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
125
|
+
Schema.validateSync(QueryAST.Query)(AssigneesOfAllTasksCreatedAfter2020.ast);
|
|
126
|
+
log('AssigneesOfAllTasksCreatedAfter2020', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
127
|
+
});
|
|
188
128
|
|
|
189
|
-
|
|
190
|
-
|
|
129
|
+
test('untyped full-text search', () => {
|
|
130
|
+
const contactFullTextSearch = Query.select(Filter.text('Bill'));
|
|
191
131
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
132
|
+
log('query', { ast: contactFullTextSearch.ast });
|
|
133
|
+
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
134
|
+
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
195
135
|
{
|
|
196
136
|
"filter": {
|
|
197
137
|
"searchKind": undefined,
|
|
@@ -201,14 +141,14 @@ describe('query api', () => {
|
|
|
201
141
|
"type": "select",
|
|
202
142
|
}
|
|
203
143
|
`);
|
|
204
|
-
|
|
144
|
+
});
|
|
205
145
|
|
|
206
|
-
|
|
207
|
-
|
|
146
|
+
test('typed full-text search', () => {
|
|
147
|
+
const contactFullTextSearch = Query.select(Filter.type(Test.Person)).select(Filter.text('Bill'));
|
|
208
148
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
149
|
+
log('query', { ast: contactFullTextSearch.ast });
|
|
150
|
+
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
151
|
+
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
212
152
|
{
|
|
213
153
|
"filter": {
|
|
214
154
|
"searchKind": undefined,
|
|
@@ -227,32 +167,32 @@ describe('query api', () => {
|
|
|
227
167
|
"type": "filter",
|
|
228
168
|
}
|
|
229
169
|
`);
|
|
230
|
-
|
|
170
|
+
});
|
|
231
171
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
172
|
+
test('filter by ref', () => {
|
|
173
|
+
const fred = Obj.make(Test.Person, { name: 'Fred' });
|
|
174
|
+
const tasksByFred = Filter.type(Test.Task, { assignee: Ref.make(fred) });
|
|
175
|
+
expect(tasksByFred.ast).toEqual({
|
|
176
|
+
props: {
|
|
177
|
+
assignee: {
|
|
178
|
+
operator: 'eq',
|
|
179
|
+
type: 'compare',
|
|
180
|
+
value: {
|
|
181
|
+
'/': DXN.fromLocalObjectId(fred.id).toString(),
|
|
182
|
+
},
|
|
242
183
|
},
|
|
243
184
|
},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
185
|
+
type: 'object',
|
|
186
|
+
typename: 'dxn:type:dxos.org/type/Task:0.1.0',
|
|
187
|
+
});
|
|
188
|
+
log('tasksByFred', { ast: tasksByFred.ast });
|
|
247
189
|
});
|
|
248
|
-
console.log('tasksByFred', JSON.stringify(tasksByFred.ast, null, 2));
|
|
249
|
-
});
|
|
250
190
|
|
|
251
|
-
|
|
252
|
-
|
|
191
|
+
test('select orgs and people', () => {
|
|
192
|
+
const orgsAndPeople = Query.select(Filter.or(Filter.type(Test.Organization), Filter.type(Test.Person)));
|
|
253
193
|
|
|
254
|
-
|
|
255
|
-
|
|
194
|
+
Schema.validateSync(QueryAST.Query)(orgsAndPeople.ast);
|
|
195
|
+
expect(orgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
256
196
|
{
|
|
257
197
|
"filter": {
|
|
258
198
|
"filters": [
|
|
@@ -274,15 +214,15 @@ describe('query api', () => {
|
|
|
274
214
|
"type": "select",
|
|
275
215
|
}
|
|
276
216
|
`);
|
|
277
|
-
|
|
217
|
+
});
|
|
278
218
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
219
|
+
test('select everything but orgs and people', () => {
|
|
220
|
+
const everythingButOrgsAndPeople = Query.select(
|
|
221
|
+
Filter.not(Filter.or(Filter.type(Test.Organization), Filter.type(Test.Person))),
|
|
222
|
+
);
|
|
283
223
|
|
|
284
|
-
|
|
285
|
-
|
|
224
|
+
Schema.validateSync(QueryAST.Query)(everythingButOrgsAndPeople.ast);
|
|
225
|
+
expect(everythingButOrgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
286
226
|
{
|
|
287
227
|
"filter": {
|
|
288
228
|
"filter": {
|
|
@@ -307,15 +247,15 @@ describe('query api', () => {
|
|
|
307
247
|
"type": "select",
|
|
308
248
|
}
|
|
309
249
|
`);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
test('select deleted tasks', () => {
|
|
313
|
-
const deletedTasks = Query.select(Filter.type(Task)).options({
|
|
314
|
-
deleted: 'only',
|
|
315
250
|
});
|
|
316
251
|
|
|
317
|
-
|
|
318
|
-
|
|
252
|
+
test('select deleted tasks', () => {
|
|
253
|
+
const deletedTasks = Query.select(Filter.type(Test.Task)).options({
|
|
254
|
+
deleted: 'only',
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
Schema.validateSync(QueryAST.Query)(deletedTasks.ast);
|
|
258
|
+
expect(deletedTasks.ast).toMatchInlineSnapshot(`
|
|
319
259
|
{
|
|
320
260
|
"options": {
|
|
321
261
|
"deleted": "only",
|
|
@@ -332,31 +272,63 @@ describe('query api', () => {
|
|
|
332
272
|
"type": "options",
|
|
333
273
|
}
|
|
334
274
|
`);
|
|
335
|
-
|
|
275
|
+
});
|
|
336
276
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
277
|
+
test('filter by tags', () => {
|
|
278
|
+
const query = Query.select(Filter.type(Test.Task)).select(Filter.tag('important'));
|
|
279
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
280
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
281
|
+
{
|
|
282
|
+
"filter": {
|
|
283
|
+
"tag": "important",
|
|
284
|
+
"type": "tag",
|
|
285
|
+
},
|
|
286
|
+
"selection": {
|
|
287
|
+
"filter": {
|
|
288
|
+
"id": undefined,
|
|
289
|
+
"props": {},
|
|
290
|
+
"type": "object",
|
|
291
|
+
"typename": "dxn:type:dxos.org/type/Task:0.1.0",
|
|
292
|
+
},
|
|
293
|
+
"type": "select",
|
|
294
|
+
},
|
|
295
|
+
"type": "filter",
|
|
296
|
+
}
|
|
297
|
+
`);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test.skip('chain', () => {
|
|
301
|
+
// NOTE: Can't support props without type since they can't be inferred.
|
|
302
|
+
// const f1: Filter<Person> = Filter.props({ name: 'Fred' });
|
|
303
|
+
|
|
304
|
+
// const x = Query.select(Filter.props({ id: '123' }));
|
|
305
|
+
const y = Query.select(Filter.type(Test.Person));
|
|
340
306
|
|
|
341
|
-
|
|
342
|
-
const y = Query.select(Filter.type(Person));
|
|
307
|
+
const or = Filter.or(Filter.type(Test.Person, { id: Filter.in('1', '2', '3') }), Filter.type(Test.Organization));
|
|
343
308
|
|
|
344
|
-
|
|
309
|
+
const and = Filter.and(
|
|
310
|
+
Filter.type(Test.Person, { id: Filter.in('1', '2', '3') }),
|
|
311
|
+
Filter.type(Test.Person, { name: 'Fred' }),
|
|
312
|
+
);
|
|
345
313
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
314
|
+
const q = Query
|
|
315
|
+
//
|
|
316
|
+
// NOTE: Can't support functions since they can't be serialized (to server).
|
|
317
|
+
// .filter((object) => Math.random() > 0.5)
|
|
318
|
+
.select(Filter.type(Test.Person))
|
|
319
|
+
.select(Filter.type(Test.Person, { name: 'Fred' }))
|
|
320
|
+
.select({ age: Filter.between(20, 40) })
|
|
321
|
+
.select(Filter.and(Filter.type(Test.Person), Filter.type(Test.Person, { name: Filter.in('bob', 'bill') })));
|
|
350
322
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
// .filter((object) => Math.random() > 0.5)
|
|
355
|
-
.select(Filter.type(Person))
|
|
356
|
-
.select(Filter.type(Person, { name: 'Fred' }))
|
|
357
|
-
.select({ age: Filter.between(20, 40) })
|
|
358
|
-
.select(Filter.and(Filter.type(Person), Filter.type(Person, { name: Filter.in('bob', 'bill') })));
|
|
323
|
+
log('stuff', { fOr: or, fAnd: and, q, y });
|
|
324
|
+
});
|
|
325
|
+
});
|
|
359
326
|
|
|
360
|
-
|
|
327
|
+
describe('Filter', () => {
|
|
328
|
+
test('Filter.or(Filter.typename(...))', () => {
|
|
329
|
+
const filter = Filter.or(Filter.typename('dxos.org/type/Person'));
|
|
330
|
+
// TODO(dmaretskyi): Give vitest type-tests a try.
|
|
331
|
+
const _isAssignable: Obj.Any = null as any as Filter.Type<typeof filter>;
|
|
332
|
+
});
|
|
361
333
|
});
|
|
362
334
|
});
|