@dxos/assistant 0.8.2-main.36232bc → 0.8.2-main.5ca3450
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-OLO6SVOL.mjs} +21 -21
- package/dist/lib/browser/chunk-OLO6SVOL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +14 -14
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +76 -80
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-7VH7NMIM.cjs → chunk-CI5Q7FBG.cjs} +6 -6
- package/dist/lib/node/chunk-CI5Q7FBG.cjs.map +7 -0
- package/dist/lib/node/index.cjs +34 -34
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +64 -69
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-7JI4MDGL.mjs → chunk-Y3SYOFFJ.mjs} +21 -21
- package/dist/lib/node-esm/chunk-Y3SYOFFJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +14 -14
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +76 -80
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- 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/conversation.d.ts.map +1 -1
- package/dist/types/src/conversation/types.d.ts +9 -9
- package/dist/types/src/conversation/types.d.ts.map +1 -1
- package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -1
- package/dist/types/src/cypher/execution-plan.d.ts.map +1 -1
- package/dist/types/src/cypher/parser.d.ts.map +1 -1
- package/dist/types/src/cypher/query-executor.d.ts.map +1 -1
- package/dist/types/src/cypher/schema.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +3 -3
- package/dist/types/src/session/session.d.ts.map +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 +3 -3
- package/dist/types/src/testing/query-promts.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +4 -4
- 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 +15 -14
- package/src/ai-service/client.test.ts +5 -5
- package/src/ai-service/ollama-client.ts +7 -7
- package/src/ai-service/types.ts +14 -14
- package/src/conversation/conversation.test.ts +3 -3
- package/src/conversation/types.ts +10 -10
- package/src/cypher/echo-data-source.ts +7 -5
- package/src/session/session.test.ts +22 -16
- package/src/session/session.ts +15 -15
- package/src/testing/artifacts.test.ts +22 -22
- package/src/testing/query-promts.ts +5 -5
- package/src/testing/test-data.ts +57 -50
- package/src/testing/test-schema.ts +27 -28
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
6
|
import { inspect } from 'node:util';
|
|
7
7
|
import { describe, test } from 'vitest';
|
|
8
8
|
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
type MessageContentBlock,
|
|
16
16
|
} from '@dxos/artifact';
|
|
17
17
|
import { AIServiceEdgeClient } from '@dxos/assistant';
|
|
18
|
-
import {
|
|
18
|
+
import { Type } from '@dxos/echo';
|
|
19
|
+
import { create, ObjectId } from '@dxos/echo-schema';
|
|
19
20
|
import { DXN } from '@dxos/keys';
|
|
20
21
|
import { log } from '@dxos/log';
|
|
21
22
|
|
|
@@ -23,14 +24,19 @@ import { AISession } from './session';
|
|
|
23
24
|
import { AI_SERVICE_ENDPOINT } from '../testing';
|
|
24
25
|
|
|
25
26
|
// Define a calendar event artifact schema.
|
|
26
|
-
const CalendarEventSchema =
|
|
27
|
-
title:
|
|
28
|
-
startTime:
|
|
29
|
-
endTime:
|
|
30
|
-
description:
|
|
31
|
-
}).pipe(
|
|
27
|
+
const CalendarEventSchema = Schema.Struct({
|
|
28
|
+
title: Schema.String,
|
|
29
|
+
startTime: Schema.String,
|
|
30
|
+
endTime: Schema.String,
|
|
31
|
+
description: Schema.String,
|
|
32
|
+
}).pipe(
|
|
33
|
+
Type.def({
|
|
34
|
+
typename: 'example.com/type/CalendarEvent',
|
|
35
|
+
version: '0.1.0',
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
32
38
|
|
|
33
|
-
type CalendarEvent =
|
|
39
|
+
type CalendarEvent = Schema.Schema.Type<typeof CalendarEventSchema>;
|
|
34
40
|
|
|
35
41
|
// TODO(burdon): Flaky.
|
|
36
42
|
describe.skip('AISession with Ollama', () => {
|
|
@@ -53,7 +59,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
53
59
|
defineTool('calendar', {
|
|
54
60
|
name: 'query',
|
|
55
61
|
description: 'Query the calendar for events',
|
|
56
|
-
schema:
|
|
62
|
+
schema: Schema.Struct({}),
|
|
57
63
|
execute: async () => {
|
|
58
64
|
return ToolResult.Success(CALENDAR_EVENTS);
|
|
59
65
|
},
|
|
@@ -65,13 +71,13 @@ describe.skip('AISession with Ollama', () => {
|
|
|
65
71
|
id: 'artifact:dxos.org/plugin/table',
|
|
66
72
|
name: 'Table',
|
|
67
73
|
instructions: 'Use this to create and manage tables. Each table has a unique id.',
|
|
68
|
-
schema:
|
|
74
|
+
schema: Schema.Struct({}),
|
|
69
75
|
tools: [
|
|
70
76
|
defineTool('table', {
|
|
71
77
|
name: 'create',
|
|
72
78
|
description: 'Create a table',
|
|
73
|
-
schema:
|
|
74
|
-
data:
|
|
79
|
+
schema: Schema.Struct({
|
|
80
|
+
data: Schema.Array(Schema.Any).annotations({ description: 'Array of data payloads to add as rows' }),
|
|
75
81
|
}),
|
|
76
82
|
execute: async ({ data }) => {
|
|
77
83
|
log('create table', { data });
|
|
@@ -89,12 +95,12 @@ describe.skip('AISession with Ollama', () => {
|
|
|
89
95
|
name: 'Map',
|
|
90
96
|
instructions:
|
|
91
97
|
'Use this to create and manage maps. Maps source data from tables. Table id is required to create a map.',
|
|
92
|
-
schema:
|
|
98
|
+
schema: Schema.Struct({}),
|
|
93
99
|
tools: [
|
|
94
100
|
defineTool('map', {
|
|
95
101
|
name: 'create',
|
|
96
102
|
description: 'Create a map',
|
|
97
|
-
schema:
|
|
103
|
+
schema: Schema.Struct({
|
|
98
104
|
source: ArtifactId.annotations({
|
|
99
105
|
description: 'The table that will be used as the source of the map',
|
|
100
106
|
}),
|
|
@@ -119,7 +125,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
119
125
|
id: 'artifact:dxos.org/plugin/script',
|
|
120
126
|
name: 'Script',
|
|
121
127
|
instructions: 'Use this to create and manage scripts',
|
|
122
|
-
schema:
|
|
128
|
+
schema: Schema.Struct({}),
|
|
123
129
|
tools: [],
|
|
124
130
|
});
|
|
125
131
|
|
package/src/session/session.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Option, Schema
|
|
5
|
+
import { Option, Schema } from 'effect';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
defineTool,
|
|
@@ -230,7 +230,7 @@ export class AISession {
|
|
|
230
230
|
} catch (err) {
|
|
231
231
|
log.catch(err);
|
|
232
232
|
if (err instanceof Error && err.message.includes('Overloaded')) {
|
|
233
|
-
error = new AIServiecOverloadedError('AI service overloaded', { cause: err });
|
|
233
|
+
error = new AIServiecOverloadedError('AI service overloaded', { cause: err } as any); // TODO(dmaretskyi): Schema errors cant have cause
|
|
234
234
|
} else {
|
|
235
235
|
error = new Error('AI service error', { cause: err });
|
|
236
236
|
}
|
|
@@ -287,7 +287,7 @@ export class AISession {
|
|
|
287
287
|
return defineTool('system', {
|
|
288
288
|
name: 'query_artifact_definitions',
|
|
289
289
|
description: 'Query the available artifact definitions',
|
|
290
|
-
schema:
|
|
290
|
+
schema: Schema.Struct({}),
|
|
291
291
|
execute: async () => {
|
|
292
292
|
return ToolResult.Success({
|
|
293
293
|
artifactDefinitions: artifacts.map((artifact) => ({
|
|
@@ -308,8 +308,8 @@ export class AISession {
|
|
|
308
308
|
name: 'require_artifact_definitions',
|
|
309
309
|
description:
|
|
310
310
|
'Require the use of specific artifact definitions. This will allow the model to interact with artifact definitions and use their tools.',
|
|
311
|
-
schema:
|
|
312
|
-
artifactDefinitionIds:
|
|
311
|
+
schema: Schema.Struct({
|
|
312
|
+
artifactDefinitionIds: Schema.Array(Schema.String).annotations({
|
|
313
313
|
description: 'The ids of the artifact definitions to require',
|
|
314
314
|
examples: [['artifact:dxos.org/example/Test']],
|
|
315
315
|
}),
|
|
@@ -336,20 +336,20 @@ export class AISession {
|
|
|
336
336
|
name: 'create_plan',
|
|
337
337
|
description:
|
|
338
338
|
'Create a plan. Make sure that each step is independent and can be executed solely on the data returned by the previous step. The steps only share the data that is specified in the plan.',
|
|
339
|
-
schema:
|
|
340
|
-
goal:
|
|
341
|
-
steps:
|
|
342
|
-
|
|
343
|
-
action:
|
|
339
|
+
schema: Schema.Struct({
|
|
340
|
+
goal: Schema.String.annotations({ description: 'The goal that the plan will achieve.' }),
|
|
341
|
+
steps: Schema.Array(
|
|
342
|
+
Schema.Struct({
|
|
343
|
+
action: Schema.String.annotations({
|
|
344
344
|
description: 'Complete, detailed action to perform.',
|
|
345
345
|
}),
|
|
346
|
-
input:
|
|
346
|
+
input: Schema.String.annotations({
|
|
347
347
|
description: 'The required input data for this step. First step must not require any data.',
|
|
348
348
|
}),
|
|
349
|
-
output:
|
|
349
|
+
output: Schema.String.annotations({
|
|
350
350
|
description: 'The output data from this step. This is passed to the next step as input.',
|
|
351
351
|
}),
|
|
352
|
-
requiredArtifactIds:
|
|
352
|
+
requiredArtifactIds: Schema.Array(Schema.String).annotations({
|
|
353
353
|
description: 'The ids of the artifacts required to perform this step.',
|
|
354
354
|
examples: [['artifact:dxos.org/example/Test']],
|
|
355
355
|
}),
|
|
@@ -473,7 +473,7 @@ const createBaseInstructions = ({
|
|
|
473
473
|
${availableArtifacts.length > 0 ? `Artifacts already in context: ${availableArtifacts.join('\n')}` : ''}
|
|
474
474
|
`;
|
|
475
475
|
|
|
476
|
-
export class AIServiecOverloadedError extends
|
|
476
|
+
export class AIServiecOverloadedError extends Schema.TaggedError<AIServiecOverloadedError>()(
|
|
477
477
|
'AIServiecOverloadedError',
|
|
478
478
|
{},
|
|
479
479
|
) {}
|
|
@@ -483,7 +483,7 @@ const gatherObjectVersions = (messages: Message[]): Map<ObjectId, ObjectVersion>
|
|
|
483
483
|
for (const message of messages) {
|
|
484
484
|
for (const block of message.content) {
|
|
485
485
|
if (block.type === 'json' && block.disposition === VersionPin.DISPOSITION) {
|
|
486
|
-
const pin = VersionPin.pipe(
|
|
486
|
+
const pin = VersionPin.pipe(Schema.decodeOption)(JSON.parse(block.json)).pipe(Option.getOrUndefined);
|
|
487
487
|
if (!pin) {
|
|
488
488
|
continue;
|
|
489
489
|
}
|
|
@@ -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
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
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';
|
|
@@ -11,14 +11,14 @@ import { log } from '@dxos/log';
|
|
|
11
11
|
import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../cypher';
|
|
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:
|
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,
|
|
@@ -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> {}
|