@dxos/assistant 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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-B4HAWUFW.mjs → chunk-PND5VR6D.mjs} +286 -757
- package/dist/lib/browser/chunk-PND5VR6D.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +324 -7
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +102 -139
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-NOB7CIIC.cjs → chunk-IBOBRBDF.cjs} +303 -768
- package/dist/lib/node/chunk-IBOBRBDF.cjs.map +7 -0
- package/dist/lib/node/index.cjs +353 -36
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +93 -128
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/{chunk-SAWYU3V5.mjs → chunk-DCQJOLSR.mjs} +286 -757
- package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +324 -7
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +102 -139
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/ai-service/edge-client.d.ts +5 -4
- package/dist/types/src/ai-service/edge-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/message-collector.d.ts +6 -0
- package/dist/types/src/ai-service/message-collector.d.ts.map +1 -1
- package/dist/types/src/ai-service/ollama-client.d.ts +2 -6
- package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/parser.d.ts +3 -0
- package/dist/types/src/ai-service/parser.d.ts.map +1 -1
- package/dist/types/src/ai-service/service.d.ts +2 -18
- package/dist/types/src/ai-service/service.d.ts.map +1 -1
- package/dist/types/src/ai-service/stream.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/mock.d.ts +2 -6
- package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/test-stream.d.ts.map +1 -1
- package/dist/types/src/ai-service/types.d.ts +101 -144
- package/dist/types/src/ai-service/types.d.ts.map +1 -1
- package/dist/types/src/ai-service/util/sse.d.ts.map +1 -1
- package/dist/types/src/{experimental/conversation → conversation}/conversation.d.ts +21 -2
- package/dist/types/src/conversation/conversation.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
- package/dist/types/src/conversation/index.d.ts.map +1 -0
- package/dist/types/src/{experimental/conversation → conversation}/types.d.ts +12 -11
- package/dist/types/src/conversation/types.d.ts.map +1 -0
- package/dist/types/src/cypher/ast.d.ts.map +1 -0
- package/dist/types/src/cypher/combinators.d.ts.map +1 -0
- package/dist/types/src/cypher/combinators.test.d.ts.map +1 -0
- package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -0
- package/dist/types/src/cypher/execution-plan.d.ts.map +1 -0
- package/dist/types/src/cypher/execution-plan.test.d.ts.map +1 -0
- package/dist/types/src/cypher/index.d.ts.map +1 -0
- package/dist/types/src/cypher/parjs.d.ts.map +1 -0
- package/dist/types/src/cypher/parser.d.ts.map +1 -0
- package/dist/types/src/cypher/query-executor.d.ts.map +1 -0
- package/dist/types/src/cypher/query-executor.test.d.ts.map +1 -0
- package/dist/types/src/cypher/schema.d.ts.map +1 -0
- package/dist/types/src/cypher/schema.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/session/index.d.ts +0 -2
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +13 -33
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/logger.d.ts +1 -1
- package/dist/types/src/testing/logger.d.ts.map +1 -1
- package/dist/types/src/testing/ollama.d.ts.map +1 -1
- package/dist/types/src/testing/query-promts.d.ts +4 -4
- package/dist/types/src/testing/query-promts.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +5 -5
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +23 -25
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/util/trim.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -20
- package/src/ai-service/client.test.ts +73 -55
- package/src/ai-service/edge-client.ts +20 -13
- package/src/ai-service/ollama-client.ts +10 -17
- package/src/ai-service/parser.ts +2 -13
- package/src/ai-service/service.ts +3 -19
- package/src/ai-service/testing/mock.ts +1 -9
- package/src/ai-service/types.ts +15 -24
- package/src/bin/chat.ts +4 -4
- package/src/{experimental/conversation → conversation}/conversation.test.ts +5 -5
- package/src/{experimental/conversation → conversation}/conversation.ts +119 -4
- package/src/{experimental/conversation → conversation}/types.ts +14 -11
- package/src/{experimental/cypher → cypher}/combinators.test.ts +4 -4
- package/src/{experimental/cypher → cypher}/echo-data-source.ts +11 -11
- package/src/{experimental/cypher → cypher}/execution-plan.test.ts +1 -1
- package/src/{experimental/cypher → cypher}/query-executor.test.ts +2 -2
- package/src/{experimental/cypher → cypher}/schema.test.ts +3 -3
- package/src/{experimental/cypher → cypher}/schema.ts +1 -1
- package/src/index.ts +2 -3
- package/src/session/index.ts +0 -2
- package/src/session/session.test.ts +63 -35
- package/src/session/session.ts +151 -297
- package/src/testing/artifacts.test.ts +22 -22
- package/src/testing/index.ts +0 -1
- package/src/testing/logger.ts +1 -1
- package/src/testing/query-promts.ts +6 -6
- package/src/testing/query.test.ts +21 -18
- package/src/testing/test-data.ts +72 -79
- package/src/testing/test-schema.ts +29 -28
- package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +0 -7
- package/dist/lib/node/chunk-NOB7CIIC.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +0 -7
- package/dist/types/src/experimental/conversation/conversation.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/index.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/types.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/ast.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/index.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parjs.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parser.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.test.d.ts.map +0 -1
- package/dist/types/src/experimental/index.d.ts +0 -3
- package/dist/types/src/experimental/index.d.ts.map +0 -1
- package/dist/types/src/experimental/ner/ner.test.d.ts +0 -2
- package/dist/types/src/experimental/ner/ner.test.d.ts.map +0 -1
- package/dist/types/src/experimental/research/exa.d.ts +0 -6
- package/dist/types/src/experimental/research/exa.d.ts.map +0 -1
- package/dist/types/src/experimental/research/research.test.d.ts +0 -2
- package/dist/types/src/experimental/research/research.test.d.ts.map +0 -1
- package/dist/types/src/session/tools.d.ts +0 -18
- package/dist/types/src/session/tools.d.ts.map +0 -1
- package/dist/types/src/session/version-pin.d.ts +0 -22
- package/dist/types/src/session/version-pin.d.ts.map +0 -1
- package/dist/types/src/session/version-pin.test.d.ts +0 -2
- package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
- package/dist/types/src/testing/printer.d.ts +0 -6
- package/dist/types/src/testing/printer.d.ts.map +0 -1
- package/src/experimental/index.ts +0 -6
- package/src/experimental/ner/ner.test.ts +0 -163
- package/src/experimental/research/exa.ts +0 -38
- package/src/experimental/research/instructions.tpl +0 -64
- package/src/experimental/research/research.test.ts +0 -263
- package/src/session/tools.ts +0 -117
- package/src/session/version-pin.test.ts +0 -26
- package/src/session/version-pin.ts +0 -49
- package/src/testing/printer.ts +0 -41
- package/src/typedefs.d.ts +0 -8
- /package/dist/types/src/{experimental/conversation → conversation}/conversation.test.d.ts +0 -0
- /package/dist/types/src/{experimental/conversation → conversation}/index.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/ast.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/combinators.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/combinators.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/echo-data-source.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/index.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/parjs.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/parser.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/query-executor.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/query-executor.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/schema.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/schema.test.d.ts +0 -0
- /package/src/{experimental/conversation → conversation}/index.ts +0 -0
- /package/src/{experimental/cypher → cypher}/ast.ts +0 -0
- /package/src/{experimental/cypher → cypher}/combinators.ts +0 -0
- /package/src/{experimental/cypher → cypher}/execution-plan.ts +0 -0
- /package/src/{experimental/cypher → cypher}/index.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parjs-shims.d.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parjs.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parser.ts +0 -0
- /package/src/{experimental/cypher → cypher}/query-executor.ts +0 -0
|
@@ -14,9 +14,10 @@ import { AI_SERVICE_ENDPOINT } from './defs';
|
|
|
14
14
|
import { createLogger } from './logger';
|
|
15
15
|
import { createCypherTool, createSystemPrompt } from './query-promts';
|
|
16
16
|
import { createTestData, seedTestData } from './test-data';
|
|
17
|
-
import { Contact,
|
|
17
|
+
import { Contact, Org, Project, Task } from './test-schema';
|
|
18
18
|
import { AIServiceEdgeClient, DEFAULT_EDGE_MODEL } from '../ai-service';
|
|
19
|
-
import { runLLM
|
|
19
|
+
import { runLLM } from '../conversation';
|
|
20
|
+
import { EchoDataSource } from '../cypher';
|
|
20
21
|
|
|
21
22
|
const client = new AIServiceEdgeClient({
|
|
22
23
|
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
@@ -24,26 +25,27 @@ const client = new AIServiceEdgeClient({
|
|
|
24
25
|
|
|
25
26
|
test.skip('cypher query', async () => {
|
|
26
27
|
const dataSource = createTestData();
|
|
27
|
-
const schemaTypes = [
|
|
28
|
+
const schemaTypes = [Org, Project, Task, Contact];
|
|
28
29
|
|
|
29
30
|
const cypherTool = createCypherTool(dataSource);
|
|
30
31
|
|
|
31
32
|
const spaceId = SpaceId.random();
|
|
32
33
|
const threadId = ObjectId.random();
|
|
33
34
|
|
|
35
|
+
await client.appendMessages([
|
|
36
|
+
createUserMessage(
|
|
37
|
+
spaceId,
|
|
38
|
+
threadId,
|
|
39
|
+
'Query the database and give me all employees from DXOS organization that work on Composer and what their tasks are.',
|
|
40
|
+
),
|
|
41
|
+
]);
|
|
42
|
+
|
|
34
43
|
const result = await runLLM({
|
|
35
44
|
model: DEFAULT_EDGE_MODEL,
|
|
36
45
|
tools: [cypherTool],
|
|
37
46
|
spaceId,
|
|
38
47
|
threadId,
|
|
39
48
|
system: createSystemPrompt(schemaTypes),
|
|
40
|
-
history: [
|
|
41
|
-
createUserMessage(
|
|
42
|
-
spaceId,
|
|
43
|
-
threadId,
|
|
44
|
-
'Query the database and give me all employees from DXOS organization that work on Composer and what their tasks are.',
|
|
45
|
-
),
|
|
46
|
-
],
|
|
47
49
|
client,
|
|
48
50
|
logger: createLogger({ stream: false }),
|
|
49
51
|
});
|
|
@@ -55,7 +57,7 @@ test.skip('query ECHO', async () => {
|
|
|
55
57
|
await using builder = await new EchoTestBuilder().open();
|
|
56
58
|
const { db, graph } = await builder.createDatabase();
|
|
57
59
|
|
|
58
|
-
const schemaTypes = [
|
|
60
|
+
const schemaTypes = [Org, Project, Task, Contact];
|
|
59
61
|
graph.schemaRegistry.addSchema(schemaTypes);
|
|
60
62
|
|
|
61
63
|
seedTestData(db);
|
|
@@ -67,6 +69,14 @@ test.skip('query ECHO', async () => {
|
|
|
67
69
|
const spaceId = SpaceId.random();
|
|
68
70
|
const threadId = ObjectId.random();
|
|
69
71
|
|
|
72
|
+
await client.appendMessages([
|
|
73
|
+
createUserMessage(
|
|
74
|
+
spaceId,
|
|
75
|
+
threadId,
|
|
76
|
+
'Query the database and give me all employees from DXOS organization that work on Composer and what their tasks are.',
|
|
77
|
+
),
|
|
78
|
+
]);
|
|
79
|
+
|
|
70
80
|
const result = await runLLM({
|
|
71
81
|
model: DEFAULT_EDGE_MODEL,
|
|
72
82
|
tools: [cypherTool],
|
|
@@ -74,13 +84,6 @@ test.skip('query ECHO', async () => {
|
|
|
74
84
|
threadId,
|
|
75
85
|
system: createSystemPrompt(schemaTypes),
|
|
76
86
|
client,
|
|
77
|
-
history: [
|
|
78
|
-
createUserMessage(
|
|
79
|
-
spaceId,
|
|
80
|
-
threadId,
|
|
81
|
-
'Query the database and give me all employees from DXOS organization that work on Composer and what their tasks are.',
|
|
82
|
-
),
|
|
83
|
-
],
|
|
84
87
|
logger: createLogger({ stream: false }),
|
|
85
88
|
});
|
|
86
89
|
|
package/src/testing/test-data.ts
CHANGED
|
@@ -2,20 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Schema } from 'effect';
|
|
5
|
+
import { type Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
8
|
import type { EchoDatabase } from '@dxos/echo-db';
|
|
9
|
-
import {
|
|
10
|
-
JSON_SCHEMA_ECHO_REF_ID,
|
|
11
|
-
ObjectId,
|
|
12
|
-
toJsonSchema,
|
|
13
|
-
type JsonSchemaType,
|
|
14
|
-
type Ref,
|
|
15
|
-
Ref as RefImpl,
|
|
16
|
-
} from '@dxos/echo-schema';
|
|
9
|
+
import { JSON_SCHEMA_ECHO_REF_ID, ObjectId, toJsonSchema, type JsonSchemaType, type Ref } from '@dxos/echo-schema';
|
|
17
10
|
import { invariant } from '@dxos/invariant';
|
|
18
|
-
import {
|
|
11
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
19
12
|
|
|
20
13
|
import {
|
|
21
14
|
type DataSource,
|
|
@@ -23,123 +16,123 @@ import {
|
|
|
23
16
|
type Relationship,
|
|
24
17
|
formatInferredRelationshipLabel,
|
|
25
18
|
formatNodeLabel,
|
|
26
|
-
} from '../
|
|
27
|
-
import { Contact,
|
|
19
|
+
} from '../cypher';
|
|
20
|
+
import { Contact, Org, Project, Task } from '../testing';
|
|
28
21
|
|
|
29
22
|
export const seedTestData = (db: EchoDatabase) => {
|
|
30
23
|
const contactRich = db.add(
|
|
31
|
-
|
|
24
|
+
create(Contact, {
|
|
32
25
|
name: 'Rich',
|
|
33
26
|
}),
|
|
34
27
|
);
|
|
35
28
|
const contactJosiah = db.add(
|
|
36
|
-
|
|
29
|
+
create(Contact, {
|
|
37
30
|
name: 'Josiah',
|
|
38
31
|
}),
|
|
39
32
|
);
|
|
40
33
|
const contactDima = db.add(
|
|
41
|
-
|
|
34
|
+
create(Contact, {
|
|
42
35
|
name: 'Dima',
|
|
43
36
|
}),
|
|
44
37
|
);
|
|
45
38
|
const contactFred = db.add(
|
|
46
|
-
|
|
39
|
+
create(Contact, {
|
|
47
40
|
name: 'Fred',
|
|
48
41
|
}),
|
|
49
42
|
);
|
|
50
43
|
|
|
51
44
|
const projectComposer = db.add(
|
|
52
|
-
|
|
45
|
+
create(Project, {
|
|
53
46
|
name: 'Composer',
|
|
54
47
|
}),
|
|
55
48
|
);
|
|
56
49
|
const projectEcho = db.add(
|
|
57
|
-
|
|
50
|
+
create(Project, {
|
|
58
51
|
name: 'ECHO',
|
|
59
52
|
}),
|
|
60
53
|
);
|
|
61
54
|
const projectDoodles = db.add(
|
|
62
|
-
|
|
55
|
+
create(Project, {
|
|
63
56
|
name: 'Doodles',
|
|
64
57
|
}),
|
|
65
58
|
);
|
|
66
59
|
|
|
67
60
|
const _taskComposer1 = db.add(
|
|
68
|
-
|
|
61
|
+
create(Task, {
|
|
69
62
|
name: 'Optimize startup performance',
|
|
70
|
-
project:
|
|
71
|
-
assignee:
|
|
63
|
+
project: makeRef(projectComposer),
|
|
64
|
+
assignee: makeRef(contactJosiah),
|
|
72
65
|
}),
|
|
73
66
|
);
|
|
74
67
|
const _taskComposer2 = db.add(
|
|
75
|
-
|
|
68
|
+
create(Task, {
|
|
76
69
|
name: 'Create form builder',
|
|
77
|
-
project:
|
|
78
|
-
assignee:
|
|
70
|
+
project: makeRef(projectComposer),
|
|
71
|
+
assignee: makeRef(contactRich),
|
|
79
72
|
}),
|
|
80
73
|
);
|
|
81
74
|
const _taskComposer3 = db.add(
|
|
82
|
-
|
|
75
|
+
create(Task, {
|
|
83
76
|
name: 'Add support for custom themes',
|
|
84
|
-
project:
|
|
85
|
-
assignee:
|
|
77
|
+
project: makeRef(projectComposer),
|
|
78
|
+
assignee: makeRef(contactJosiah),
|
|
86
79
|
}),
|
|
87
80
|
);
|
|
88
81
|
const _taskComposer5 = db.add(
|
|
89
|
-
|
|
82
|
+
create(Task, {
|
|
90
83
|
name: 'Implement community plugin',
|
|
91
|
-
project:
|
|
92
|
-
assignee:
|
|
84
|
+
project: makeRef(projectComposer),
|
|
85
|
+
assignee: makeRef(contactFred),
|
|
93
86
|
}),
|
|
94
87
|
);
|
|
95
88
|
const _taskComposer4 = db.add(
|
|
96
|
-
|
|
89
|
+
create(Task, {
|
|
97
90
|
name: 'Implement dark mode',
|
|
98
|
-
project:
|
|
99
|
-
assignee:
|
|
91
|
+
project: makeRef(projectComposer),
|
|
92
|
+
assignee: makeRef(contactRich),
|
|
100
93
|
}),
|
|
101
94
|
);
|
|
102
95
|
const _taskEcho1 = db.add(
|
|
103
|
-
|
|
96
|
+
create(Task, {
|
|
104
97
|
name: 'Implement cypher query engine',
|
|
105
|
-
project:
|
|
106
|
-
assignee:
|
|
98
|
+
project: makeRef(projectEcho),
|
|
99
|
+
assignee: makeRef(contactDima),
|
|
107
100
|
}),
|
|
108
101
|
);
|
|
109
102
|
const _taskEcho2 = db.add(
|
|
110
|
-
|
|
103
|
+
create(Task, {
|
|
111
104
|
name: 'Add schema editor',
|
|
112
|
-
project:
|
|
113
|
-
assignee:
|
|
105
|
+
project: makeRef(projectEcho),
|
|
106
|
+
assignee: makeRef(contactRich),
|
|
114
107
|
}),
|
|
115
108
|
);
|
|
116
109
|
const _taskDoodles1 = db.add(
|
|
117
|
-
|
|
110
|
+
create(Task, {
|
|
118
111
|
name: 'Add support for custom themes',
|
|
119
|
-
project:
|
|
120
|
-
assignee:
|
|
112
|
+
project: makeRef(projectDoodles),
|
|
113
|
+
assignee: makeRef(contactFred),
|
|
121
114
|
}),
|
|
122
115
|
);
|
|
123
116
|
const _taskDoodles2 = db.add(
|
|
124
|
-
|
|
117
|
+
create(Task, {
|
|
125
118
|
name: 'Implement dark mode',
|
|
126
|
-
project:
|
|
127
|
-
assignee:
|
|
119
|
+
project: makeRef(projectDoodles),
|
|
120
|
+
assignee: makeRef(contactJosiah),
|
|
128
121
|
}),
|
|
129
122
|
);
|
|
130
123
|
|
|
131
124
|
const _orgDxos = db.add(
|
|
132
|
-
|
|
125
|
+
create(Org, {
|
|
133
126
|
name: 'DXOS',
|
|
134
|
-
employees: [
|
|
135
|
-
projects: [
|
|
127
|
+
employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
|
|
128
|
+
projects: [makeRef(projectEcho)],
|
|
136
129
|
}),
|
|
137
130
|
);
|
|
138
131
|
const _orgBraneframe = db.add(
|
|
139
|
-
|
|
132
|
+
create(Org, {
|
|
140
133
|
name: 'Braneframe',
|
|
141
|
-
employees: [
|
|
142
|
-
projects: [
|
|
134
|
+
employees: [makeRef(contactJosiah), makeRef(contactRich)],
|
|
135
|
+
projects: [makeRef(projectComposer)],
|
|
143
136
|
}),
|
|
144
137
|
);
|
|
145
138
|
};
|
|
@@ -181,69 +174,69 @@ export const createTestData = (): MockDataSource => {
|
|
|
181
174
|
const _taskComposer1 = dataSource.add(Task, {
|
|
182
175
|
id: ObjectId.random(),
|
|
183
176
|
name: 'Optimize startup performance',
|
|
184
|
-
project:
|
|
185
|
-
assignee:
|
|
177
|
+
project: makeRef(projectComposer),
|
|
178
|
+
assignee: makeRef(contactJosiah),
|
|
186
179
|
});
|
|
187
180
|
const _taskComposer2 = dataSource.add(Task, {
|
|
188
181
|
id: ObjectId.random(),
|
|
189
182
|
name: 'Create form builder',
|
|
190
|
-
project:
|
|
191
|
-
assignee:
|
|
183
|
+
project: makeRef(projectComposer),
|
|
184
|
+
assignee: makeRef(contactRich),
|
|
192
185
|
});
|
|
193
186
|
const _taskComposer3 = dataSource.add(Task, {
|
|
194
187
|
id: ObjectId.random(),
|
|
195
188
|
name: 'Add support for custom themes',
|
|
196
|
-
project:
|
|
197
|
-
assignee:
|
|
189
|
+
project: makeRef(projectComposer),
|
|
190
|
+
assignee: makeRef(contactJosiah),
|
|
198
191
|
});
|
|
199
192
|
const _taskComposer5 = dataSource.add(Task, {
|
|
200
193
|
id: ObjectId.random(),
|
|
201
194
|
name: 'Implement community plugin',
|
|
202
|
-
project:
|
|
203
|
-
assignee:
|
|
195
|
+
project: makeRef(projectComposer),
|
|
196
|
+
assignee: makeRef(contactFred),
|
|
204
197
|
});
|
|
205
198
|
const _taskComposer4 = dataSource.add(Task, {
|
|
206
199
|
id: ObjectId.random(),
|
|
207
200
|
name: 'Implement dark mode',
|
|
208
|
-
project:
|
|
209
|
-
assignee:
|
|
201
|
+
project: makeRef(projectComposer),
|
|
202
|
+
assignee: makeRef(contactRich),
|
|
210
203
|
});
|
|
211
204
|
const _taskEcho1 = dataSource.add(Task, {
|
|
212
205
|
id: ObjectId.random(),
|
|
213
206
|
name: 'Implement cypher query engine',
|
|
214
|
-
project:
|
|
215
|
-
assignee:
|
|
207
|
+
project: makeRef(projectEcho),
|
|
208
|
+
assignee: makeRef(contactDima),
|
|
216
209
|
});
|
|
217
210
|
const _taskEcho2 = dataSource.add(Task, {
|
|
218
211
|
id: ObjectId.random(),
|
|
219
212
|
name: 'Add schema editor',
|
|
220
|
-
project:
|
|
221
|
-
assignee:
|
|
213
|
+
project: makeRef(projectEcho),
|
|
214
|
+
assignee: makeRef(contactRich),
|
|
222
215
|
});
|
|
223
216
|
const _taskDoodles1 = dataSource.add(Task, {
|
|
224
217
|
id: ObjectId.random(),
|
|
225
218
|
name: 'Add support for custom themes',
|
|
226
|
-
project:
|
|
227
|
-
assignee:
|
|
219
|
+
project: makeRef(projectDoodles),
|
|
220
|
+
assignee: makeRef(contactFred),
|
|
228
221
|
});
|
|
229
222
|
const _taskDoodles2 = dataSource.add(Task, {
|
|
230
223
|
id: ObjectId.random(),
|
|
231
224
|
name: 'Implement dark mode',
|
|
232
|
-
project:
|
|
233
|
-
assignee:
|
|
225
|
+
project: makeRef(projectDoodles),
|
|
226
|
+
assignee: makeRef(contactJosiah),
|
|
234
227
|
});
|
|
235
228
|
|
|
236
|
-
const _orgDxos = dataSource.add(
|
|
229
|
+
const _orgDxos = dataSource.add(Org, {
|
|
237
230
|
id: ObjectId.random(),
|
|
238
231
|
name: 'DXOS',
|
|
239
|
-
employees: [
|
|
240
|
-
projects: [
|
|
232
|
+
employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
|
|
233
|
+
projects: [makeRef(projectEcho)],
|
|
241
234
|
});
|
|
242
|
-
const _orgBraneframe = dataSource.add(
|
|
235
|
+
const _orgBraneframe = dataSource.add(Org, {
|
|
243
236
|
id: ObjectId.random(),
|
|
244
237
|
name: 'Braneframe',
|
|
245
|
-
employees: [
|
|
246
|
-
projects: [
|
|
238
|
+
employees: [makeRef(contactJosiah), makeRef(contactRich)],
|
|
239
|
+
projects: [makeRef(projectComposer)],
|
|
247
240
|
});
|
|
248
241
|
dataSource.computeGraph();
|
|
249
242
|
|
|
@@ -254,7 +247,7 @@ export class MockDataSource implements DataSource {
|
|
|
254
247
|
objects: Record<
|
|
255
248
|
string,
|
|
256
249
|
{
|
|
257
|
-
schema:
|
|
250
|
+
schema: S.Schema.All;
|
|
258
251
|
typeDxn: string;
|
|
259
252
|
id: string;
|
|
260
253
|
data: unknown;
|
|
@@ -265,7 +258,7 @@ export class MockDataSource implements DataSource {
|
|
|
265
258
|
string,
|
|
266
259
|
{
|
|
267
260
|
json: JsonSchemaType;
|
|
268
|
-
instance:
|
|
261
|
+
instance: S.Schema.All;
|
|
269
262
|
}
|
|
270
263
|
> = {};
|
|
271
264
|
|
|
@@ -280,7 +273,7 @@ export class MockDataSource implements DataSource {
|
|
|
280
273
|
return this.relationships.filter((relationship) => !label || relationship.label === label);
|
|
281
274
|
}
|
|
282
275
|
|
|
283
|
-
add<S extends
|
|
276
|
+
add<S extends S.Schema.All>(schema: S, data: S.Schema.Type<S>) {
|
|
284
277
|
invariant(typeof data.id === 'string', 'Data must have an id');
|
|
285
278
|
const jsonSchema = toJsonSchema(schema);
|
|
286
279
|
if (!this.schema[jsonSchema.$id!]) {
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { EntityKind, TypeAnnotationId, Ref
|
|
7
|
+
import { EntityKind, TypeAnnotationId, Ref } from '@dxos/echo-schema';
|
|
8
8
|
|
|
9
|
-
// TODO(burdon):
|
|
9
|
+
// TODO(burdon): Reconcile with sdk/schema/testing.
|
|
10
|
+
// TODO(burdon): Convert interface to type.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
export const
|
|
12
|
+
// TODO(dmaretskyi): Extract.
|
|
13
|
+
export const ObjectId = S.String.annotations({ description: 'The unique object identifier.' });
|
|
14
|
+
|
|
15
|
+
export const Contact = S.Struct({
|
|
13
16
|
id: ObjectId,
|
|
14
|
-
name:
|
|
15
|
-
email:
|
|
17
|
+
name: S.String.annotations({ description: 'The name of the person.' }),
|
|
18
|
+
email: S.optional(S.String).annotations({ description: 'Email address.' }),
|
|
16
19
|
})
|
|
17
|
-
.pipe(
|
|
20
|
+
.pipe(S.mutable)
|
|
18
21
|
.annotations({
|
|
19
22
|
[TypeAnnotationId]: {
|
|
20
23
|
kind: EntityKind.Object,
|
|
@@ -23,15 +26,14 @@ export const Contact = Schema.Struct({
|
|
|
23
26
|
},
|
|
24
27
|
description: 'Contact information.',
|
|
25
28
|
});
|
|
26
|
-
export interface Contact extends
|
|
29
|
+
export interface Contact extends S.Schema.Type<typeof Contact> {}
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
export const Project = Schema.Struct({
|
|
31
|
+
export const Project = S.Struct({
|
|
30
32
|
id: ObjectId,
|
|
31
|
-
name:
|
|
32
|
-
description:
|
|
33
|
+
name: S.String.annotations({ description: 'The name of the project.' }),
|
|
34
|
+
description: S.optional(S.String).annotations({ description: 'The description of the project.' }),
|
|
33
35
|
})
|
|
34
|
-
.pipe(
|
|
36
|
+
.pipe(S.mutable)
|
|
35
37
|
.annotations({
|
|
36
38
|
[TypeAnnotationId]: {
|
|
37
39
|
kind: EntityKind.Object,
|
|
@@ -40,16 +42,16 @@ export const Project = Schema.Struct({
|
|
|
40
42
|
},
|
|
41
43
|
description: 'Contact information.',
|
|
42
44
|
});
|
|
43
|
-
export interface Project extends
|
|
45
|
+
export interface Project extends S.Schema.Type<typeof Project> {}
|
|
44
46
|
|
|
45
|
-
export const Task =
|
|
47
|
+
export const Task = S.Struct({
|
|
46
48
|
id: ObjectId,
|
|
47
|
-
name:
|
|
48
|
-
description:
|
|
49
|
+
name: S.String.annotations({ description: 'The name of the task.' }),
|
|
50
|
+
description: S.optional(S.String).annotations({ description: 'The description of the task.' }),
|
|
49
51
|
project: Ref(Project),
|
|
50
52
|
assignee: Ref(Contact),
|
|
51
53
|
})
|
|
52
|
-
.pipe(
|
|
54
|
+
.pipe(S.mutable)
|
|
53
55
|
.annotations({
|
|
54
56
|
[TypeAnnotationId]: {
|
|
55
57
|
kind: EntityKind.Object,
|
|
@@ -58,22 +60,21 @@ export const Task = Schema.Struct({
|
|
|
58
60
|
},
|
|
59
61
|
description: 'Contact information.',
|
|
60
62
|
});
|
|
61
|
-
export interface Task extends
|
|
63
|
+
export interface Task extends S.Schema.Type<typeof Task> {}
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
export const Organization = Schema.Struct({
|
|
65
|
+
export const Org = S.Struct({
|
|
65
66
|
id: ObjectId,
|
|
66
|
-
name:
|
|
67
|
-
projects:
|
|
68
|
-
employees:
|
|
67
|
+
name: S.String.annotations({ description: 'The name of the organization.' }),
|
|
68
|
+
projects: S.Array(Ref(Project)),
|
|
69
|
+
employees: S.Array(Ref(Contact)),
|
|
69
70
|
})
|
|
70
|
-
.pipe(
|
|
71
|
+
.pipe(S.mutable)
|
|
71
72
|
.annotations({
|
|
72
73
|
[TypeAnnotationId]: {
|
|
73
74
|
kind: EntityKind.Object,
|
|
74
|
-
typename: 'example.com/type/
|
|
75
|
+
typename: 'example.com/type/Org',
|
|
75
76
|
version: '0.1.0',
|
|
76
77
|
},
|
|
77
78
|
description: 'Contact information.',
|
|
78
79
|
});
|
|
79
|
-
export interface
|
|
80
|
+
export interface Org extends S.Schema.Type<typeof Org> {}
|