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