@dxos/assistant 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0
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-DEIGOD4U.mjs → chunk-B4HAWUFW.mjs} +710 -246
- package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -443
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +117 -80
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-7VH7NMIM.cjs → chunk-NOB7CIIC.cjs} +716 -259
- package/dist/lib/node/chunk-NOB7CIIC.cjs.map +7 -0
- package/dist/lib/node/index.cjs +34 -470
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +104 -69
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/{chunk-7JI4MDGL.mjs → chunk-SAWYU3V5.mjs} +710 -246
- package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +4 -443
- 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 +117 -80
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/ai-service/parser.d.ts.map +1 -1
- package/dist/types/src/ai-service/stream.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 +133 -133
- 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/{conversation → experimental/conversation}/conversation.d.ts +2 -18
- package/dist/types/src/experimental/conversation/conversation.d.ts.map +1 -0
- package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +1 -0
- package/dist/types/src/experimental/conversation/index.d.ts.map +1 -0
- package/dist/types/src/{conversation → experimental/conversation}/types.d.ts +9 -9
- package/dist/types/src/experimental/conversation/types.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/ast.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/combinators.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/index.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/parjs.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/parser.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/query-executor.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/schema.d.ts.map +1 -0
- package/dist/types/src/experimental/cypher/schema.test.d.ts.map +1 -0
- package/dist/types/src/experimental/index.d.ts +3 -0
- package/dist/types/src/experimental/index.d.ts.map +1 -0
- package/dist/types/src/experimental/ner/ner.test.d.ts +2 -0
- package/dist/types/src/experimental/ner/ner.test.d.ts.map +1 -0
- package/dist/types/src/experimental/research/exa.d.ts +6 -0
- package/dist/types/src/experimental/research/exa.d.ts.map +1 -0
- package/dist/types/src/experimental/research/research.test.d.ts +2 -0
- package/dist/types/src/experimental/research/research.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/session/index.d.ts +1 -0
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +4 -3
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/tools.d.ts +18 -0
- package/dist/types/src/session/tools.d.ts.map +1 -0
- package/dist/types/src/session/version-pin.d.ts +5 -0
- package/dist/types/src/session/version-pin.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- 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/printer.d.ts +6 -0
- package/dist/types/src/testing/printer.d.ts.map +1 -0
- 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 +25 -23
- 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 +20 -14
- package/src/ai-service/client.test.ts +5 -5
- package/src/ai-service/ollama-client.ts +8 -8
- package/src/ai-service/types.ts +14 -14
- package/src/bin/chat.ts +1 -1
- package/src/{conversation → experimental/conversation}/conversation.test.ts +5 -5
- package/src/{conversation → experimental/conversation}/conversation.ts +3 -112
- package/src/{conversation → experimental/conversation}/types.ts +10 -10
- package/src/{cypher → experimental/cypher}/echo-data-source.ts +11 -10
- package/src/{cypher → experimental/cypher}/query-executor.test.ts +1 -1
- package/src/{cypher → experimental/cypher}/schema.test.ts +1 -1
- package/src/{cypher → experimental/cypher}/schema.ts +1 -1
- package/src/experimental/index.ts +6 -0
- package/src/experimental/ner/ner.test.ts +163 -0
- package/src/experimental/research/exa.ts +38 -0
- package/src/experimental/research/instructions.tpl +64 -0
- package/src/experimental/research/research.test.ts +263 -0
- package/src/index.ts +3 -2
- package/src/session/index.ts +1 -0
- package/src/session/session.test.ts +28 -57
- package/src/session/session.ts +26 -16
- package/src/session/tools.ts +117 -0
- package/src/session/version-pin.ts +6 -0
- package/src/testing/artifacts.test.ts +22 -22
- package/src/testing/index.ts +1 -0
- package/src/testing/logger.ts +1 -1
- package/src/testing/printer.ts +41 -0
- package/src/testing/query-promts.ts +6 -6
- package/src/testing/query.test.ts +1 -2
- package/src/testing/test-data.ts +58 -51
- package/src/testing/test-schema.ts +27 -28
- package/src/typedefs.d.ts +8 -0
- package/dist/lib/browser/chunk-DEIGOD4U.mjs.map +0 -7
- package/dist/lib/node/chunk-7VH7NMIM.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-7JI4MDGL.mjs.map +0 -7
- package/dist/types/src/conversation/conversation.d.ts.map +0 -1
- package/dist/types/src/conversation/conversation.test.d.ts.map +0 -1
- package/dist/types/src/conversation/index.d.ts.map +0 -1
- package/dist/types/src/conversation/types.d.ts.map +0 -1
- package/dist/types/src/cypher/ast.d.ts.map +0 -1
- package/dist/types/src/cypher/combinators.d.ts.map +0 -1
- package/dist/types/src/cypher/combinators.test.d.ts.map +0 -1
- package/dist/types/src/cypher/echo-data-source.d.ts.map +0 -1
- package/dist/types/src/cypher/execution-plan.d.ts.map +0 -1
- package/dist/types/src/cypher/execution-plan.test.d.ts.map +0 -1
- package/dist/types/src/cypher/index.d.ts.map +0 -1
- package/dist/types/src/cypher/parjs.d.ts.map +0 -1
- package/dist/types/src/cypher/parser.d.ts.map +0 -1
- package/dist/types/src/cypher/query-executor.d.ts.map +0 -1
- package/dist/types/src/cypher/query-executor.test.d.ts.map +0 -1
- package/dist/types/src/cypher/schema.d.ts.map +0 -1
- package/dist/types/src/cypher/schema.test.d.ts.map +0 -1
- /package/dist/types/src/{conversation → experimental/conversation}/conversation.test.d.ts +0 -0
- /package/dist/types/src/{conversation → experimental/conversation}/index.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/ast.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/combinators.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/combinators.test.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/echo-data-source.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/execution-plan.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/execution-plan.test.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/index.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/parjs.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/parser.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/query-executor.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/query-executor.test.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/schema.d.ts +0 -0
- /package/dist/types/src/{cypher → experimental/cypher}/schema.test.d.ts +0 -0
- /package/src/{conversation → experimental/conversation}/index.ts +0 -0
- /package/src/{cypher → experimental/cypher}/ast.ts +0 -0
- /package/src/{cypher → experimental/cypher}/combinators.test.ts +0 -0
- /package/src/{cypher → experimental/cypher}/combinators.ts +0 -0
- /package/src/{cypher → experimental/cypher}/execution-plan.test.ts +0 -0
- /package/src/{cypher → experimental/cypher}/execution-plan.ts +0 -0
- /package/src/{cypher → experimental/cypher}/index.ts +0 -0
- /package/src/{cypher → experimental/cypher}/parjs-shims.d.ts +0 -0
- /package/src/{cypher → experimental/cypher}/parjs.ts +0 -0
- /package/src/{cypher → experimental/cypher}/parser.ts +0 -0
- /package/src/{cypher → experimental/cypher}/query-executor.ts +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
|
-
import { Schema
|
|
6
|
+
import { Schema } from '@effect/schema';
|
|
7
7
|
import { describe, test } from 'vitest';
|
|
8
8
|
|
|
9
9
|
import { ObjectId, toJsonSchema } from '@dxos/echo-schema';
|
|
@@ -15,26 +15,26 @@ import { AIServiceEdgeClient, Tool } from '../ai-service';
|
|
|
15
15
|
import { defineTool, ToolResult } from '../conversation';
|
|
16
16
|
|
|
17
17
|
// TODO(dmaretskyi): Effect schema.
|
|
18
|
-
const ArtifactDef =
|
|
19
|
-
typename:
|
|
20
|
-
description:
|
|
21
|
-
schema:
|
|
22
|
-
actions:
|
|
23
|
-
}).pipe(
|
|
18
|
+
const ArtifactDef = Schema.Struct({
|
|
19
|
+
typename: Schema.String,
|
|
20
|
+
description: Schema.String,
|
|
21
|
+
schema: Schema.Any,
|
|
22
|
+
actions: Schema.Array(Tool),
|
|
23
|
+
}).pipe(Schema.mutable);
|
|
24
24
|
|
|
25
|
-
type ArtifactDef =
|
|
25
|
+
type ArtifactDef = Schema.Schema.Type<typeof ArtifactDef>;
|
|
26
26
|
|
|
27
|
-
const ListItem =
|
|
28
|
-
name:
|
|
27
|
+
const ListItem = Schema.Struct({
|
|
28
|
+
name: Schema.String,
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const ListSchema =
|
|
31
|
+
const ListSchema = Schema.Struct({
|
|
32
32
|
id: ObjectId,
|
|
33
|
-
title:
|
|
34
|
-
items:
|
|
35
|
-
}).pipe(
|
|
33
|
+
title: Schema.String,
|
|
34
|
+
items: Schema.Array(ListItem).pipe(Schema.mutable),
|
|
35
|
+
}).pipe(Schema.mutable);
|
|
36
36
|
|
|
37
|
-
type ListSchema =
|
|
37
|
+
type ListSchema = Schema.Schema.Type<typeof ListSchema>;
|
|
38
38
|
|
|
39
39
|
const list: ArtifactDef = {
|
|
40
40
|
typename: 'example.com/type/List',
|
|
@@ -44,7 +44,7 @@ const list: ArtifactDef = {
|
|
|
44
44
|
defineTool('list', {
|
|
45
45
|
name: 'query',
|
|
46
46
|
description: 'Query all lists',
|
|
47
|
-
schema:
|
|
47
|
+
schema: Schema.Struct({}),
|
|
48
48
|
execute: async ({}, context) => {
|
|
49
49
|
return ToolResult.Success(LISTS[id]);
|
|
50
50
|
},
|
|
@@ -52,7 +52,7 @@ const list: ArtifactDef = {
|
|
|
52
52
|
defineTool('list', {
|
|
53
53
|
name: 'inspect',
|
|
54
54
|
description: 'Get contents of the list',
|
|
55
|
-
schema:
|
|
55
|
+
schema: Schema.Struct({
|
|
56
56
|
id: ObjectId.annotations({ description: 'The list to inspect' }),
|
|
57
57
|
}),
|
|
58
58
|
execute: async ({ id }, context) => {
|
|
@@ -62,9 +62,9 @@ const list: ArtifactDef = {
|
|
|
62
62
|
defineTool('list', {
|
|
63
63
|
name: 'create',
|
|
64
64
|
description: 'Add one or more items to an existing list',
|
|
65
|
-
schema:
|
|
65
|
+
schema: Schema.Struct({
|
|
66
66
|
id: ObjectId.annotations({ description: 'The list to add items to' }),
|
|
67
|
-
items:
|
|
67
|
+
items: Schema.Array(ListItem).annotations({ description: 'The items to add to the list' }),
|
|
68
68
|
}),
|
|
69
69
|
execute: async ({ id, items }, context) => {
|
|
70
70
|
LISTS[id].items.push(...items);
|
|
@@ -81,7 +81,7 @@ const artifacts = [list];
|
|
|
81
81
|
const getArtifactDefinitions = defineTool('system', {
|
|
82
82
|
name: 'getArtifactDefinitions',
|
|
83
83
|
description: 'Queries the definitions and metadata of artifacts defined in the system',
|
|
84
|
-
schema:
|
|
84
|
+
schema: Schema.Any,
|
|
85
85
|
execute: async (_, context) => {
|
|
86
86
|
return ToolResult.Success(
|
|
87
87
|
artifacts.map((artifact) => ({
|
|
@@ -116,8 +116,8 @@ describe('Artifacts', () => {
|
|
|
116
116
|
name: 'custodian',
|
|
117
117
|
description: 'Custodian can tell you the password if you say the magic word',
|
|
118
118
|
parameters: toJsonSchema(
|
|
119
|
-
|
|
120
|
-
magicWord:
|
|
119
|
+
Schema.Struct({
|
|
120
|
+
magicWord: Schema.String.annotations({ description: 'The magic word. Should be exactly "pretty please"' }),
|
|
121
121
|
}),
|
|
122
122
|
),
|
|
123
123
|
};
|
package/src/testing/index.ts
CHANGED
package/src/testing/logger.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { inspect } from 'node:util';
|
|
6
|
+
|
|
7
|
+
import type { Message, MessageContentBlock } from '@dxos/artifact';
|
|
8
|
+
|
|
9
|
+
export class ConsolePrinter {
|
|
10
|
+
printMessage = (message: Message) => {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.log(`${message.role.toUpperCase()}\n`);
|
|
13
|
+
for (const content of message.content) {
|
|
14
|
+
this.printContentBlock(content);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
printContentBlock = (content: MessageContentBlock) => {
|
|
19
|
+
switch (content.type) {
|
|
20
|
+
case 'text':
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.log(content.text);
|
|
23
|
+
break;
|
|
24
|
+
case 'tool_use':
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.log(`⚙️ [Tool Use] ${content.name} ${inspect(content.input, { depth: null, colors: true })}`);
|
|
27
|
+
break;
|
|
28
|
+
case 'tool_result': {
|
|
29
|
+
let data: any;
|
|
30
|
+
try {
|
|
31
|
+
data = JSON.parse(content.content);
|
|
32
|
+
} catch {
|
|
33
|
+
data = content.content;
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.log(`⚙️ [Tool Result] ${content.toolUseId} ${inspect(data, { depth: null, colors: true })}`);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { defineTool, ToolResult } from '@dxos/artifact';
|
|
8
8
|
import { toJsonSchema } from '@dxos/echo-schema';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
|
|
11
|
-
import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../
|
|
11
|
+
import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../experimental';
|
|
12
12
|
import { trim } from '../util';
|
|
13
13
|
|
|
14
|
-
export const createCypherTool = (dataSource: DataSource, schemaTypes:
|
|
14
|
+
export const createCypherTool = (dataSource: DataSource, schemaTypes: Schema.Schema.Any[] = []) =>
|
|
15
15
|
defineTool('dxos.org/echo', {
|
|
16
16
|
name: 'query',
|
|
17
17
|
description:
|
|
18
18
|
'Query the ECHO graph database in cypher query language. Returns data from the database.' +
|
|
19
19
|
(schemaTypes.length > 0 ? `\n\n${createSystemPrompt(schemaTypes)}` : ''),
|
|
20
|
-
schema:
|
|
21
|
-
query:
|
|
20
|
+
schema: Schema.Struct({
|
|
21
|
+
query: Schema.String.annotations({
|
|
22
22
|
description: `
|
|
23
23
|
A valid cypher query string to execute.
|
|
24
24
|
Query must have one MATCH clause.
|
|
@@ -55,7 +55,7 @@ export const createCypherTool = (dataSource: DataSource, schemaTypes: S.Schema.A
|
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
export const createSystemPrompt = (schemaTypes:
|
|
58
|
+
export const createSystemPrompt = (schemaTypes: Schema.Schema.Any[]) => trim`
|
|
59
59
|
You have access to ECHO graph database. You can query the database to get data to satisfy user prompts.
|
|
60
60
|
|
|
61
61
|
Database schema is defined in pseud-cypher syntax. The schema is:
|
|
@@ -16,8 +16,7 @@ import { createCypherTool, createSystemPrompt } from './query-promts';
|
|
|
16
16
|
import { createTestData, seedTestData } from './test-data';
|
|
17
17
|
import { Contact, Organization, Project, Task } from './test-schema';
|
|
18
18
|
import { AIServiceEdgeClient, DEFAULT_EDGE_MODEL } from '../ai-service';
|
|
19
|
-
import { runLLM } from '../
|
|
20
|
-
import { EchoDataSource } from '../cypher';
|
|
19
|
+
import { runLLM, EchoDataSource } from '../experimental';
|
|
21
20
|
|
|
22
21
|
const client = new AIServiceEdgeClient({
|
|
23
22
|
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
package/src/testing/test-data.ts
CHANGED
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Schema
|
|
5
|
+
import { type Schema } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
8
|
import type { EchoDatabase } from '@dxos/echo-db';
|
|
9
|
-
import {
|
|
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';
|
|
10
17
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import { live
|
|
18
|
+
import { live } from '@dxos/live-object';
|
|
12
19
|
|
|
13
20
|
import {
|
|
14
21
|
type DataSource,
|
|
@@ -16,7 +23,7 @@ import {
|
|
|
16
23
|
type Relationship,
|
|
17
24
|
formatInferredRelationshipLabel,
|
|
18
25
|
formatNodeLabel,
|
|
19
|
-
} from '../
|
|
26
|
+
} from '../experimental';
|
|
20
27
|
import { Contact, Organization, Project, Task } from '../testing';
|
|
21
28
|
|
|
22
29
|
export const seedTestData = (db: EchoDatabase) => {
|
|
@@ -60,79 +67,79 @@ export const seedTestData = (db: EchoDatabase) => {
|
|
|
60
67
|
const _taskComposer1 = db.add(
|
|
61
68
|
live(Task, {
|
|
62
69
|
name: 'Optimize startup performance',
|
|
63
|
-
project:
|
|
64
|
-
assignee:
|
|
70
|
+
project: RefImpl.make(projectComposer),
|
|
71
|
+
assignee: RefImpl.make(contactJosiah),
|
|
65
72
|
}),
|
|
66
73
|
);
|
|
67
74
|
const _taskComposer2 = db.add(
|
|
68
75
|
live(Task, {
|
|
69
76
|
name: 'Create form builder',
|
|
70
|
-
project:
|
|
71
|
-
assignee:
|
|
77
|
+
project: RefImpl.make(projectComposer),
|
|
78
|
+
assignee: RefImpl.make(contactRich),
|
|
72
79
|
}),
|
|
73
80
|
);
|
|
74
81
|
const _taskComposer3 = db.add(
|
|
75
82
|
live(Task, {
|
|
76
83
|
name: 'Add support for custom themes',
|
|
77
|
-
project:
|
|
78
|
-
assignee:
|
|
84
|
+
project: RefImpl.make(projectComposer),
|
|
85
|
+
assignee: RefImpl.make(contactJosiah),
|
|
79
86
|
}),
|
|
80
87
|
);
|
|
81
88
|
const _taskComposer5 = db.add(
|
|
82
89
|
live(Task, {
|
|
83
90
|
name: 'Implement community plugin',
|
|
84
|
-
project:
|
|
85
|
-
assignee:
|
|
91
|
+
project: RefImpl.make(projectComposer),
|
|
92
|
+
assignee: RefImpl.make(contactFred),
|
|
86
93
|
}),
|
|
87
94
|
);
|
|
88
95
|
const _taskComposer4 = db.add(
|
|
89
96
|
live(Task, {
|
|
90
97
|
name: 'Implement dark mode',
|
|
91
|
-
project:
|
|
92
|
-
assignee:
|
|
98
|
+
project: RefImpl.make(projectComposer),
|
|
99
|
+
assignee: RefImpl.make(contactRich),
|
|
93
100
|
}),
|
|
94
101
|
);
|
|
95
102
|
const _taskEcho1 = db.add(
|
|
96
103
|
live(Task, {
|
|
97
104
|
name: 'Implement cypher query engine',
|
|
98
|
-
project:
|
|
99
|
-
assignee:
|
|
105
|
+
project: RefImpl.make(projectEcho),
|
|
106
|
+
assignee: RefImpl.make(contactDima),
|
|
100
107
|
}),
|
|
101
108
|
);
|
|
102
109
|
const _taskEcho2 = db.add(
|
|
103
110
|
live(Task, {
|
|
104
111
|
name: 'Add schema editor',
|
|
105
|
-
project:
|
|
106
|
-
assignee:
|
|
112
|
+
project: RefImpl.make(projectEcho),
|
|
113
|
+
assignee: RefImpl.make(contactRich),
|
|
107
114
|
}),
|
|
108
115
|
);
|
|
109
116
|
const _taskDoodles1 = db.add(
|
|
110
117
|
live(Task, {
|
|
111
118
|
name: 'Add support for custom themes',
|
|
112
|
-
project:
|
|
113
|
-
assignee:
|
|
119
|
+
project: RefImpl.make(projectDoodles),
|
|
120
|
+
assignee: RefImpl.make(contactFred),
|
|
114
121
|
}),
|
|
115
122
|
);
|
|
116
123
|
const _taskDoodles2 = db.add(
|
|
117
124
|
live(Task, {
|
|
118
125
|
name: 'Implement dark mode',
|
|
119
|
-
project:
|
|
120
|
-
assignee:
|
|
126
|
+
project: RefImpl.make(projectDoodles),
|
|
127
|
+
assignee: RefImpl.make(contactJosiah),
|
|
121
128
|
}),
|
|
122
129
|
);
|
|
123
130
|
|
|
124
131
|
const _orgDxos = db.add(
|
|
125
132
|
live(Organization, {
|
|
126
133
|
name: 'DXOS',
|
|
127
|
-
employees: [
|
|
128
|
-
projects: [
|
|
134
|
+
employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
|
|
135
|
+
projects: [RefImpl.make(projectEcho)],
|
|
129
136
|
}),
|
|
130
137
|
);
|
|
131
138
|
const _orgBraneframe = db.add(
|
|
132
139
|
live(Organization, {
|
|
133
140
|
name: 'Braneframe',
|
|
134
|
-
employees: [
|
|
135
|
-
projects: [
|
|
141
|
+
employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
|
|
142
|
+
projects: [RefImpl.make(projectComposer)],
|
|
136
143
|
}),
|
|
137
144
|
);
|
|
138
145
|
};
|
|
@@ -174,69 +181,69 @@ export const createTestData = (): MockDataSource => {
|
|
|
174
181
|
const _taskComposer1 = dataSource.add(Task, {
|
|
175
182
|
id: ObjectId.random(),
|
|
176
183
|
name: 'Optimize startup performance',
|
|
177
|
-
project:
|
|
178
|
-
assignee:
|
|
184
|
+
project: RefImpl.make(projectComposer),
|
|
185
|
+
assignee: RefImpl.make(contactJosiah),
|
|
179
186
|
});
|
|
180
187
|
const _taskComposer2 = dataSource.add(Task, {
|
|
181
188
|
id: ObjectId.random(),
|
|
182
189
|
name: 'Create form builder',
|
|
183
|
-
project:
|
|
184
|
-
assignee:
|
|
190
|
+
project: RefImpl.make(projectComposer),
|
|
191
|
+
assignee: RefImpl.make(contactRich),
|
|
185
192
|
});
|
|
186
193
|
const _taskComposer3 = dataSource.add(Task, {
|
|
187
194
|
id: ObjectId.random(),
|
|
188
195
|
name: 'Add support for custom themes',
|
|
189
|
-
project:
|
|
190
|
-
assignee:
|
|
196
|
+
project: RefImpl.make(projectComposer),
|
|
197
|
+
assignee: RefImpl.make(contactJosiah),
|
|
191
198
|
});
|
|
192
199
|
const _taskComposer5 = dataSource.add(Task, {
|
|
193
200
|
id: ObjectId.random(),
|
|
194
201
|
name: 'Implement community plugin',
|
|
195
|
-
project:
|
|
196
|
-
assignee:
|
|
202
|
+
project: RefImpl.make(projectComposer),
|
|
203
|
+
assignee: RefImpl.make(contactFred),
|
|
197
204
|
});
|
|
198
205
|
const _taskComposer4 = dataSource.add(Task, {
|
|
199
206
|
id: ObjectId.random(),
|
|
200
207
|
name: 'Implement dark mode',
|
|
201
|
-
project:
|
|
202
|
-
assignee:
|
|
208
|
+
project: RefImpl.make(projectComposer),
|
|
209
|
+
assignee: RefImpl.make(contactRich),
|
|
203
210
|
});
|
|
204
211
|
const _taskEcho1 = dataSource.add(Task, {
|
|
205
212
|
id: ObjectId.random(),
|
|
206
213
|
name: 'Implement cypher query engine',
|
|
207
|
-
project:
|
|
208
|
-
assignee:
|
|
214
|
+
project: RefImpl.make(projectEcho),
|
|
215
|
+
assignee: RefImpl.make(contactDima),
|
|
209
216
|
});
|
|
210
217
|
const _taskEcho2 = dataSource.add(Task, {
|
|
211
218
|
id: ObjectId.random(),
|
|
212
219
|
name: 'Add schema editor',
|
|
213
|
-
project:
|
|
214
|
-
assignee:
|
|
220
|
+
project: RefImpl.make(projectEcho),
|
|
221
|
+
assignee: RefImpl.make(contactRich),
|
|
215
222
|
});
|
|
216
223
|
const _taskDoodles1 = dataSource.add(Task, {
|
|
217
224
|
id: ObjectId.random(),
|
|
218
225
|
name: 'Add support for custom themes',
|
|
219
|
-
project:
|
|
220
|
-
assignee:
|
|
226
|
+
project: RefImpl.make(projectDoodles),
|
|
227
|
+
assignee: RefImpl.make(contactFred),
|
|
221
228
|
});
|
|
222
229
|
const _taskDoodles2 = dataSource.add(Task, {
|
|
223
230
|
id: ObjectId.random(),
|
|
224
231
|
name: 'Implement dark mode',
|
|
225
|
-
project:
|
|
226
|
-
assignee:
|
|
232
|
+
project: RefImpl.make(projectDoodles),
|
|
233
|
+
assignee: RefImpl.make(contactJosiah),
|
|
227
234
|
});
|
|
228
235
|
|
|
229
236
|
const _orgDxos = dataSource.add(Organization, {
|
|
230
237
|
id: ObjectId.random(),
|
|
231
238
|
name: 'DXOS',
|
|
232
|
-
employees: [
|
|
233
|
-
projects: [
|
|
239
|
+
employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
|
|
240
|
+
projects: [RefImpl.make(projectEcho)],
|
|
234
241
|
});
|
|
235
242
|
const _orgBraneframe = dataSource.add(Organization, {
|
|
236
243
|
id: ObjectId.random(),
|
|
237
244
|
name: 'Braneframe',
|
|
238
|
-
employees: [
|
|
239
|
-
projects: [
|
|
245
|
+
employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
|
|
246
|
+
projects: [RefImpl.make(projectComposer)],
|
|
240
247
|
});
|
|
241
248
|
dataSource.computeGraph();
|
|
242
249
|
|
|
@@ -247,7 +254,7 @@ export class MockDataSource implements DataSource {
|
|
|
247
254
|
objects: Record<
|
|
248
255
|
string,
|
|
249
256
|
{
|
|
250
|
-
schema:
|
|
257
|
+
schema: Schema.Schema.All;
|
|
251
258
|
typeDxn: string;
|
|
252
259
|
id: string;
|
|
253
260
|
data: unknown;
|
|
@@ -258,7 +265,7 @@ export class MockDataSource implements DataSource {
|
|
|
258
265
|
string,
|
|
259
266
|
{
|
|
260
267
|
json: JsonSchemaType;
|
|
261
|
-
instance:
|
|
268
|
+
instance: Schema.Schema.All;
|
|
262
269
|
}
|
|
263
270
|
> = {};
|
|
264
271
|
|
|
@@ -273,7 +280,7 @@ export class MockDataSource implements DataSource {
|
|
|
273
280
|
return this.relationships.filter((relationship) => !label || relationship.label === label);
|
|
274
281
|
}
|
|
275
282
|
|
|
276
|
-
add<S extends
|
|
283
|
+
add<S extends Schema.Schema.All>(schema: S, data: Schema.Schema.Type<S>) {
|
|
277
284
|
invariant(typeof data.id === 'string', 'Data must have an id');
|
|
278
285
|
const jsonSchema = toJsonSchema(schema);
|
|
279
286
|
if (!this.schema[jsonSchema.$id!]) {
|
|
@@ -2,22 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { EntityKind, TypeAnnotationId, Ref } from '@dxos/echo-schema';
|
|
7
|
+
import { EntityKind, TypeAnnotationId, Ref, ObjectId } from '@dxos/echo-schema';
|
|
8
8
|
|
|
9
|
-
// TODO(burdon):
|
|
10
|
-
// TODO(burdon): Convert interface to type.
|
|
9
|
+
// TODO(burdon): Remove (use @dxos/schema DataType).
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
export const Contact = S.Struct({
|
|
11
|
+
/** @deprecated */
|
|
12
|
+
export const Contact = Schema.Struct({
|
|
16
13
|
id: ObjectId,
|
|
17
|
-
name:
|
|
18
|
-
email:
|
|
14
|
+
name: Schema.String.annotations({ description: 'The name of the person.' }),
|
|
15
|
+
email: Schema.optional(Schema.String).annotations({ description: 'Email address.' }),
|
|
19
16
|
})
|
|
20
|
-
.pipe(
|
|
17
|
+
.pipe(Schema.mutable)
|
|
21
18
|
.annotations({
|
|
22
19
|
[TypeAnnotationId]: {
|
|
23
20
|
kind: EntityKind.Object,
|
|
@@ -26,14 +23,15 @@ export const Contact = S.Struct({
|
|
|
26
23
|
},
|
|
27
24
|
description: 'Contact information.',
|
|
28
25
|
});
|
|
29
|
-
export interface Contact extends
|
|
26
|
+
export interface Contact extends Schema.Schema.Type<typeof Contact> {}
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
/** @deprecated */
|
|
29
|
+
export const Project = Schema.Struct({
|
|
32
30
|
id: ObjectId,
|
|
33
|
-
name:
|
|
34
|
-
description:
|
|
31
|
+
name: Schema.String.annotations({ description: 'The name of the project.' }),
|
|
32
|
+
description: Schema.optional(Schema.String).annotations({ description: 'The description of the project.' }),
|
|
35
33
|
})
|
|
36
|
-
.pipe(
|
|
34
|
+
.pipe(Schema.mutable)
|
|
37
35
|
.annotations({
|
|
38
36
|
[TypeAnnotationId]: {
|
|
39
37
|
kind: EntityKind.Object,
|
|
@@ -42,16 +40,16 @@ export const Project = S.Struct({
|
|
|
42
40
|
},
|
|
43
41
|
description: 'Contact information.',
|
|
44
42
|
});
|
|
45
|
-
export interface Project extends
|
|
43
|
+
export interface Project extends Schema.Schema.Type<typeof Project> {}
|
|
46
44
|
|
|
47
|
-
export const Task =
|
|
45
|
+
export const Task = Schema.Struct({
|
|
48
46
|
id: ObjectId,
|
|
49
|
-
name:
|
|
50
|
-
description:
|
|
47
|
+
name: Schema.String.annotations({ description: 'The name of the task.' }),
|
|
48
|
+
description: Schema.optional(Schema.String).annotations({ description: 'The description of the task.' }),
|
|
51
49
|
project: Ref(Project),
|
|
52
50
|
assignee: Ref(Contact),
|
|
53
51
|
})
|
|
54
|
-
.pipe(
|
|
52
|
+
.pipe(Schema.mutable)
|
|
55
53
|
.annotations({
|
|
56
54
|
[TypeAnnotationId]: {
|
|
57
55
|
kind: EntityKind.Object,
|
|
@@ -60,15 +58,16 @@ export const Task = S.Struct({
|
|
|
60
58
|
},
|
|
61
59
|
description: 'Contact information.',
|
|
62
60
|
});
|
|
63
|
-
export interface Task extends
|
|
61
|
+
export interface Task extends Schema.Schema.Type<typeof Task> {}
|
|
64
62
|
|
|
65
|
-
|
|
63
|
+
/** @deprecated */
|
|
64
|
+
export const Organization = Schema.Struct({
|
|
66
65
|
id: ObjectId,
|
|
67
|
-
name:
|
|
68
|
-
projects:
|
|
69
|
-
employees:
|
|
66
|
+
name: Schema.String.annotations({ description: 'The name of the organization.' }),
|
|
67
|
+
projects: Schema.Array(Ref(Project)),
|
|
68
|
+
employees: Schema.Array(Ref(Contact)),
|
|
70
69
|
})
|
|
71
|
-
.pipe(
|
|
70
|
+
.pipe(Schema.mutable)
|
|
72
71
|
.annotations({
|
|
73
72
|
[TypeAnnotationId]: {
|
|
74
73
|
kind: EntityKind.Object,
|
|
@@ -77,4 +76,4 @@ export const Organization = S.Struct({
|
|
|
77
76
|
},
|
|
78
77
|
description: 'Contact information.',
|
|
79
78
|
});
|
|
80
|
-
export interface Organization extends
|
|
79
|
+
export interface Organization extends Schema.Schema.Type<typeof Organization> {}
|