@dxos/echo 0.8.2-main.5885341 → 0.8.2-main.600d381
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/index.mjs +48 -33
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +48 -29
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +48 -33
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/{Database.d.ts → experimental/database.d.ts} +1 -1
- package/dist/types/src/experimental/database.d.ts.map +1 -0
- package/dist/types/src/experimental/index.d.ts +1 -0
- package/dist/types/src/experimental/index.d.ts.map +1 -0
- package/dist/types/src/{Queue.d.ts → experimental/queue.d.ts} +1 -1
- package/dist/types/src/experimental/queue.d.ts.map +1 -0
- package/dist/types/src/{Space.d.ts → experimental/space.d.ts} +1 -1
- package/dist/types/src/experimental/space.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -6
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/query/api.d.ts +183 -0
- package/dist/types/src/query/api.d.ts.map +1 -0
- package/dist/types/src/query/ast.d.ts +146 -0
- package/dist/types/src/query/ast.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/type/Relation.d.ts +16 -0
- package/dist/types/src/type/Relation.d.ts.map +1 -0
- package/dist/types/src/type/Type.d.ts +80 -0
- package/dist/types/src/type/Type.d.ts.map +1 -0
- package/dist/types/src/type/Type.test.d.ts +2 -0
- package/dist/types/src/type/Type.test.d.ts.map +1 -0
- package/dist/types/src/type/index.d.ts +3 -0
- package/dist/types/src/type/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/{Database.ts → experimental/database.ts} +1 -1
- package/src/experimental/index.ts +7 -0
- package/src/{Queue.ts → experimental/queue.ts} +1 -1
- package/src/index.ts +3 -7
- package/src/query/api.ts +498 -0
- package/src/query/ast.ts +179 -0
- package/src/query/query.test.ts +146 -0
- package/src/type/Relation.ts +17 -0
- package/src/type/Type.test.ts +125 -0
- package/src/type/Type.ts +143 -0
- package/src/type/index.ts +6 -0
- package/dist/types/src/Database.d.ts.map +0 -1
- package/dist/types/src/Queue.d.ts.map +0 -1
- package/dist/types/src/Space.d.ts.map +0 -1
- package/dist/types/src/Type.d.ts +0 -49
- package/dist/types/src/Type.d.ts.map +0 -1
- package/dist/types/src/api.test.d.ts +0 -2
- package/dist/types/src/api.test.d.ts.map +0 -1
- package/src/Type.ts +0 -99
- package/src/api.test.ts +0 -92
- /package/src/{Space.ts → experimental/space.ts} +0 -0
package/src/api.test.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema as S } from 'effect';
|
|
6
|
-
import { describe, test } from 'vitest';
|
|
7
|
-
|
|
8
|
-
import { raise } from '@dxos/debug';
|
|
9
|
-
import { FormatEnum, FormatAnnotation } from '@dxos/echo-schema';
|
|
10
|
-
|
|
11
|
-
// Deliberately testing top-level import as if external consumer for @dxos/echo.
|
|
12
|
-
import { Type } from '.';
|
|
13
|
-
|
|
14
|
-
namespace Testing {
|
|
15
|
-
export const Organization = S.Struct({
|
|
16
|
-
id: Type.ObjectId,
|
|
17
|
-
name: S.String,
|
|
18
|
-
}).pipe(
|
|
19
|
-
Type.def({
|
|
20
|
-
typename: 'example.com/type/Organization',
|
|
21
|
-
version: '0.1.0',
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export interface Organization extends S.Schema.Type<typeof Organization> {}
|
|
26
|
-
|
|
27
|
-
export const Contact = S.Struct({
|
|
28
|
-
name: S.String,
|
|
29
|
-
dob: S.optional(S.String),
|
|
30
|
-
email: S.optional(S.String.pipe(FormatAnnotation.set(FormatEnum.Email))),
|
|
31
|
-
organization: S.optional(Type.Ref(Organization)),
|
|
32
|
-
}).pipe(
|
|
33
|
-
Type.def({
|
|
34
|
-
typename: 'example.com/type/Contact',
|
|
35
|
-
version: '0.1.0',
|
|
36
|
-
}),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
export interface Contact extends S.Schema.Type<typeof Contact> {}
|
|
40
|
-
|
|
41
|
-
export const Message = S.Struct({
|
|
42
|
-
// TODO(burdon): Support S.Date; Custom Timestamp (with defaults).
|
|
43
|
-
// TODO(burdon): Support defaults (update create and create).
|
|
44
|
-
timestamp: S.String.pipe(
|
|
45
|
-
S.propertySignature,
|
|
46
|
-
S.withConstructorDefault(() => new Date().toISOString()),
|
|
47
|
-
),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// TODO(burdon): Fix (Type.def currently removes TypeLiteral that implements the `make` function)..
|
|
51
|
-
// }).pipe(
|
|
52
|
-
// Type.def({
|
|
53
|
-
// typename: 'example.com/type/Message',
|
|
54
|
-
// version: '0.1.0',
|
|
55
|
-
// }),
|
|
56
|
-
// );
|
|
57
|
-
|
|
58
|
-
export interface Message extends S.Schema.Type<typeof Message> {}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
describe('Experimental API review', () => {
|
|
62
|
-
test('type checks', ({ expect }) => {
|
|
63
|
-
const contact = Type.create(Testing.Contact, { name: 'Test' });
|
|
64
|
-
const type: S.Schema<Testing.Contact> = Type.getSchema(contact) ?? raise(new Error('No schema found'));
|
|
65
|
-
|
|
66
|
-
expect(Type.getDXN(type)?.typename).to.eq(Testing.Contact.typename);
|
|
67
|
-
expect(Type.getTypename(type)).to.eq('example.com/type/Contact');
|
|
68
|
-
expect(Type.getVersion(type)).to.eq('0.1.0');
|
|
69
|
-
expect(Type.getMeta(type)).to.deep.eq({
|
|
70
|
-
kind: Type.Kind.Object,
|
|
71
|
-
typename: 'example.com/type/Contact',
|
|
72
|
-
version: '0.1.0',
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('instance checks', ({ expect }) => {
|
|
77
|
-
const organization = Type.create(Testing.Organization, { name: 'DXOS' });
|
|
78
|
-
const contact = Type.create(Testing.Contact, { name: 'Test', organization: Type.ref(organization) });
|
|
79
|
-
|
|
80
|
-
expect(S.is(Testing.Contact)(contact)).to.be.true;
|
|
81
|
-
expect(Testing.Contact.instanceOf(contact)).to.be.true;
|
|
82
|
-
expect(Type.instanceOf(Testing.Contact, contact)).to.be.true;
|
|
83
|
-
expect(Type.instanceOf(Testing.Organization, organization)).to.be.true;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('default props', ({ expect }) => {
|
|
87
|
-
// TODO(burdon): Doesn't work after pipe(Type.def).
|
|
88
|
-
// Property 'make' does not exist on type 'EchoObjectSchema<Struct<{ timestamp: PropertySignature<":", string, never, ":", string, true, never>; }>>'.ts(2339)
|
|
89
|
-
const message = Type.create(Testing.Message, Testing.Message.make({}));
|
|
90
|
-
expect(message.timestamp).to.exist;
|
|
91
|
-
});
|
|
92
|
-
});
|
|
File without changes
|