@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.
Files changed (175) hide show
  1. package/dist/lib/browser/{chunk-B4HAWUFW.mjs → chunk-PND5VR6D.mjs} +286 -757
  2. package/dist/lib/browser/chunk-PND5VR6D.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +324 -7
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +102 -139
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/{chunk-NOB7CIIC.cjs → chunk-IBOBRBDF.cjs} +303 -768
  9. package/dist/lib/node/chunk-IBOBRBDF.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +353 -36
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +93 -128
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/lib/node-esm/{chunk-SAWYU3V5.mjs → chunk-DCQJOLSR.mjs} +286 -757
  16. package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +324 -7
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +102 -139
  21. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  22. package/dist/types/src/ai-service/edge-client.d.ts +5 -4
  23. package/dist/types/src/ai-service/edge-client.d.ts.map +1 -1
  24. package/dist/types/src/ai-service/message-collector.d.ts +6 -0
  25. package/dist/types/src/ai-service/message-collector.d.ts.map +1 -1
  26. package/dist/types/src/ai-service/ollama-client.d.ts +2 -6
  27. package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -1
  28. package/dist/types/src/ai-service/parser.d.ts +3 -0
  29. package/dist/types/src/ai-service/parser.d.ts.map +1 -1
  30. package/dist/types/src/ai-service/service.d.ts +2 -18
  31. package/dist/types/src/ai-service/service.d.ts.map +1 -1
  32. package/dist/types/src/ai-service/stream.d.ts.map +1 -1
  33. package/dist/types/src/ai-service/testing/mock.d.ts +2 -6
  34. package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
  35. package/dist/types/src/ai-service/testing/test-stream.d.ts.map +1 -1
  36. package/dist/types/src/ai-service/types.d.ts +101 -144
  37. package/dist/types/src/ai-service/types.d.ts.map +1 -1
  38. package/dist/types/src/ai-service/util/sse.d.ts.map +1 -1
  39. package/dist/types/src/{experimental/conversation → conversation}/conversation.d.ts +21 -2
  40. package/dist/types/src/conversation/conversation.d.ts.map +1 -0
  41. package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
  42. package/dist/types/src/conversation/index.d.ts.map +1 -0
  43. package/dist/types/src/{experimental/conversation → conversation}/types.d.ts +12 -11
  44. package/dist/types/src/conversation/types.d.ts.map +1 -0
  45. package/dist/types/src/cypher/ast.d.ts.map +1 -0
  46. package/dist/types/src/cypher/combinators.d.ts.map +1 -0
  47. package/dist/types/src/cypher/combinators.test.d.ts.map +1 -0
  48. package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -0
  49. package/dist/types/src/cypher/execution-plan.d.ts.map +1 -0
  50. package/dist/types/src/cypher/execution-plan.test.d.ts.map +1 -0
  51. package/dist/types/src/cypher/index.d.ts.map +1 -0
  52. package/dist/types/src/cypher/parjs.d.ts.map +1 -0
  53. package/dist/types/src/cypher/parser.d.ts.map +1 -0
  54. package/dist/types/src/cypher/query-executor.d.ts.map +1 -0
  55. package/dist/types/src/cypher/query-executor.test.d.ts.map +1 -0
  56. package/dist/types/src/cypher/schema.d.ts.map +1 -0
  57. package/dist/types/src/cypher/schema.test.d.ts.map +1 -0
  58. package/dist/types/src/index.d.ts +2 -1
  59. package/dist/types/src/index.d.ts.map +1 -1
  60. package/dist/types/src/session/index.d.ts +0 -2
  61. package/dist/types/src/session/index.d.ts.map +1 -1
  62. package/dist/types/src/session/session.d.ts +13 -33
  63. package/dist/types/src/session/session.d.ts.map +1 -1
  64. package/dist/types/src/testing/index.d.ts +0 -1
  65. package/dist/types/src/testing/index.d.ts.map +1 -1
  66. package/dist/types/src/testing/logger.d.ts +1 -1
  67. package/dist/types/src/testing/logger.d.ts.map +1 -1
  68. package/dist/types/src/testing/ollama.d.ts.map +1 -1
  69. package/dist/types/src/testing/query-promts.d.ts +4 -4
  70. package/dist/types/src/testing/query-promts.d.ts.map +1 -1
  71. package/dist/types/src/testing/test-data.d.ts +5 -5
  72. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  73. package/dist/types/src/testing/test-schema.d.ts +23 -25
  74. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  75. package/dist/types/src/util/trim.d.ts.map +1 -1
  76. package/dist/types/tsconfig.tsbuildinfo +1 -1
  77. package/package.json +14 -20
  78. package/src/ai-service/client.test.ts +73 -55
  79. package/src/ai-service/edge-client.ts +20 -13
  80. package/src/ai-service/ollama-client.ts +10 -17
  81. package/src/ai-service/parser.ts +2 -13
  82. package/src/ai-service/service.ts +3 -19
  83. package/src/ai-service/testing/mock.ts +1 -9
  84. package/src/ai-service/types.ts +15 -24
  85. package/src/bin/chat.ts +4 -4
  86. package/src/{experimental/conversation → conversation}/conversation.test.ts +5 -5
  87. package/src/{experimental/conversation → conversation}/conversation.ts +119 -4
  88. package/src/{experimental/conversation → conversation}/types.ts +14 -11
  89. package/src/{experimental/cypher → cypher}/combinators.test.ts +4 -4
  90. package/src/{experimental/cypher → cypher}/echo-data-source.ts +11 -11
  91. package/src/{experimental/cypher → cypher}/execution-plan.test.ts +1 -1
  92. package/src/{experimental/cypher → cypher}/query-executor.test.ts +2 -2
  93. package/src/{experimental/cypher → cypher}/schema.test.ts +3 -3
  94. package/src/{experimental/cypher → cypher}/schema.ts +1 -1
  95. package/src/index.ts +2 -3
  96. package/src/session/index.ts +0 -2
  97. package/src/session/session.test.ts +63 -35
  98. package/src/session/session.ts +151 -297
  99. package/src/testing/artifacts.test.ts +22 -22
  100. package/src/testing/index.ts +0 -1
  101. package/src/testing/logger.ts +1 -1
  102. package/src/testing/query-promts.ts +6 -6
  103. package/src/testing/query.test.ts +21 -18
  104. package/src/testing/test-data.ts +72 -79
  105. package/src/testing/test-schema.ts +29 -28
  106. package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +0 -7
  107. package/dist/lib/node/chunk-NOB7CIIC.cjs.map +0 -7
  108. package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +0 -7
  109. package/dist/types/src/experimental/conversation/conversation.d.ts.map +0 -1
  110. package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +0 -1
  111. package/dist/types/src/experimental/conversation/index.d.ts.map +0 -1
  112. package/dist/types/src/experimental/conversation/types.d.ts.map +0 -1
  113. package/dist/types/src/experimental/cypher/ast.d.ts.map +0 -1
  114. package/dist/types/src/experimental/cypher/combinators.d.ts.map +0 -1
  115. package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +0 -1
  116. package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +0 -1
  117. package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +0 -1
  118. package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +0 -1
  119. package/dist/types/src/experimental/cypher/index.d.ts.map +0 -1
  120. package/dist/types/src/experimental/cypher/parjs.d.ts.map +0 -1
  121. package/dist/types/src/experimental/cypher/parser.d.ts.map +0 -1
  122. package/dist/types/src/experimental/cypher/query-executor.d.ts.map +0 -1
  123. package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +0 -1
  124. package/dist/types/src/experimental/cypher/schema.d.ts.map +0 -1
  125. package/dist/types/src/experimental/cypher/schema.test.d.ts.map +0 -1
  126. package/dist/types/src/experimental/index.d.ts +0 -3
  127. package/dist/types/src/experimental/index.d.ts.map +0 -1
  128. package/dist/types/src/experimental/ner/ner.test.d.ts +0 -2
  129. package/dist/types/src/experimental/ner/ner.test.d.ts.map +0 -1
  130. package/dist/types/src/experimental/research/exa.d.ts +0 -6
  131. package/dist/types/src/experimental/research/exa.d.ts.map +0 -1
  132. package/dist/types/src/experimental/research/research.test.d.ts +0 -2
  133. package/dist/types/src/experimental/research/research.test.d.ts.map +0 -1
  134. package/dist/types/src/session/tools.d.ts +0 -18
  135. package/dist/types/src/session/tools.d.ts.map +0 -1
  136. package/dist/types/src/session/version-pin.d.ts +0 -22
  137. package/dist/types/src/session/version-pin.d.ts.map +0 -1
  138. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  139. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  140. package/dist/types/src/testing/printer.d.ts +0 -6
  141. package/dist/types/src/testing/printer.d.ts.map +0 -1
  142. package/src/experimental/index.ts +0 -6
  143. package/src/experimental/ner/ner.test.ts +0 -163
  144. package/src/experimental/research/exa.ts +0 -38
  145. package/src/experimental/research/instructions.tpl +0 -64
  146. package/src/experimental/research/research.test.ts +0 -263
  147. package/src/session/tools.ts +0 -117
  148. package/src/session/version-pin.test.ts +0 -26
  149. package/src/session/version-pin.ts +0 -49
  150. package/src/testing/printer.ts +0 -41
  151. package/src/typedefs.d.ts +0 -8
  152. /package/dist/types/src/{experimental/conversation → conversation}/conversation.test.d.ts +0 -0
  153. /package/dist/types/src/{experimental/conversation → conversation}/index.d.ts +0 -0
  154. /package/dist/types/src/{experimental/cypher → cypher}/ast.d.ts +0 -0
  155. /package/dist/types/src/{experimental/cypher → cypher}/combinators.d.ts +0 -0
  156. /package/dist/types/src/{experimental/cypher → cypher}/combinators.test.d.ts +0 -0
  157. /package/dist/types/src/{experimental/cypher → cypher}/echo-data-source.d.ts +0 -0
  158. /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.d.ts +0 -0
  159. /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.test.d.ts +0 -0
  160. /package/dist/types/src/{experimental/cypher → cypher}/index.d.ts +0 -0
  161. /package/dist/types/src/{experimental/cypher → cypher}/parjs.d.ts +0 -0
  162. /package/dist/types/src/{experimental/cypher → cypher}/parser.d.ts +0 -0
  163. /package/dist/types/src/{experimental/cypher → cypher}/query-executor.d.ts +0 -0
  164. /package/dist/types/src/{experimental/cypher → cypher}/query-executor.test.d.ts +0 -0
  165. /package/dist/types/src/{experimental/cypher → cypher}/schema.d.ts +0 -0
  166. /package/dist/types/src/{experimental/cypher → cypher}/schema.test.d.ts +0 -0
  167. /package/src/{experimental/conversation → conversation}/index.ts +0 -0
  168. /package/src/{experimental/cypher → cypher}/ast.ts +0 -0
  169. /package/src/{experimental/cypher → cypher}/combinators.ts +0 -0
  170. /package/src/{experimental/cypher → cypher}/execution-plan.ts +0 -0
  171. /package/src/{experimental/cypher → cypher}/index.ts +0 -0
  172. /package/src/{experimental/cypher → cypher}/parjs-shims.d.ts +0 -0
  173. /package/src/{experimental/cypher → cypher}/parjs.ts +0 -0
  174. /package/src/{experimental/cypher → cypher}/parser.ts +0 -0
  175. /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, Organization, Project, Task } from './test-schema';
17
+ import { Contact, Org, Project, Task } from './test-schema';
18
18
  import { AIServiceEdgeClient, DEFAULT_EDGE_MODEL } from '../ai-service';
19
- import { runLLM, EchoDataSource } from '../experimental';
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 = [Organization, Project, Task, Contact];
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 = [Organization, Project, Task, Contact];
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
 
@@ -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 { live } from '@dxos/live-object';
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 '../experimental';
27
- import { Contact, Organization, Project, Task } from '../testing';
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
- live(Contact, {
24
+ create(Contact, {
32
25
  name: 'Rich',
33
26
  }),
34
27
  );
35
28
  const contactJosiah = db.add(
36
- live(Contact, {
29
+ create(Contact, {
37
30
  name: 'Josiah',
38
31
  }),
39
32
  );
40
33
  const contactDima = db.add(
41
- live(Contact, {
34
+ create(Contact, {
42
35
  name: 'Dima',
43
36
  }),
44
37
  );
45
38
  const contactFred = db.add(
46
- live(Contact, {
39
+ create(Contact, {
47
40
  name: 'Fred',
48
41
  }),
49
42
  );
50
43
 
51
44
  const projectComposer = db.add(
52
- live(Project, {
45
+ create(Project, {
53
46
  name: 'Composer',
54
47
  }),
55
48
  );
56
49
  const projectEcho = db.add(
57
- live(Project, {
50
+ create(Project, {
58
51
  name: 'ECHO',
59
52
  }),
60
53
  );
61
54
  const projectDoodles = db.add(
62
- live(Project, {
55
+ create(Project, {
63
56
  name: 'Doodles',
64
57
  }),
65
58
  );
66
59
 
67
60
  const _taskComposer1 = db.add(
68
- live(Task, {
61
+ create(Task, {
69
62
  name: 'Optimize startup performance',
70
- project: RefImpl.make(projectComposer),
71
- assignee: RefImpl.make(contactJosiah),
63
+ project: makeRef(projectComposer),
64
+ assignee: makeRef(contactJosiah),
72
65
  }),
73
66
  );
74
67
  const _taskComposer2 = db.add(
75
- live(Task, {
68
+ create(Task, {
76
69
  name: 'Create form builder',
77
- project: RefImpl.make(projectComposer),
78
- assignee: RefImpl.make(contactRich),
70
+ project: makeRef(projectComposer),
71
+ assignee: makeRef(contactRich),
79
72
  }),
80
73
  );
81
74
  const _taskComposer3 = db.add(
82
- live(Task, {
75
+ create(Task, {
83
76
  name: 'Add support for custom themes',
84
- project: RefImpl.make(projectComposer),
85
- assignee: RefImpl.make(contactJosiah),
77
+ project: makeRef(projectComposer),
78
+ assignee: makeRef(contactJosiah),
86
79
  }),
87
80
  );
88
81
  const _taskComposer5 = db.add(
89
- live(Task, {
82
+ create(Task, {
90
83
  name: 'Implement community plugin',
91
- project: RefImpl.make(projectComposer),
92
- assignee: RefImpl.make(contactFred),
84
+ project: makeRef(projectComposer),
85
+ assignee: makeRef(contactFred),
93
86
  }),
94
87
  );
95
88
  const _taskComposer4 = db.add(
96
- live(Task, {
89
+ create(Task, {
97
90
  name: 'Implement dark mode',
98
- project: RefImpl.make(projectComposer),
99
- assignee: RefImpl.make(contactRich),
91
+ project: makeRef(projectComposer),
92
+ assignee: makeRef(contactRich),
100
93
  }),
101
94
  );
102
95
  const _taskEcho1 = db.add(
103
- live(Task, {
96
+ create(Task, {
104
97
  name: 'Implement cypher query engine',
105
- project: RefImpl.make(projectEcho),
106
- assignee: RefImpl.make(contactDima),
98
+ project: makeRef(projectEcho),
99
+ assignee: makeRef(contactDima),
107
100
  }),
108
101
  );
109
102
  const _taskEcho2 = db.add(
110
- live(Task, {
103
+ create(Task, {
111
104
  name: 'Add schema editor',
112
- project: RefImpl.make(projectEcho),
113
- assignee: RefImpl.make(contactRich),
105
+ project: makeRef(projectEcho),
106
+ assignee: makeRef(contactRich),
114
107
  }),
115
108
  );
116
109
  const _taskDoodles1 = db.add(
117
- live(Task, {
110
+ create(Task, {
118
111
  name: 'Add support for custom themes',
119
- project: RefImpl.make(projectDoodles),
120
- assignee: RefImpl.make(contactFred),
112
+ project: makeRef(projectDoodles),
113
+ assignee: makeRef(contactFred),
121
114
  }),
122
115
  );
123
116
  const _taskDoodles2 = db.add(
124
- live(Task, {
117
+ create(Task, {
125
118
  name: 'Implement dark mode',
126
- project: RefImpl.make(projectDoodles),
127
- assignee: RefImpl.make(contactJosiah),
119
+ project: makeRef(projectDoodles),
120
+ assignee: makeRef(contactJosiah),
128
121
  }),
129
122
  );
130
123
 
131
124
  const _orgDxos = db.add(
132
- live(Organization, {
125
+ create(Org, {
133
126
  name: 'DXOS',
134
- employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
135
- projects: [RefImpl.make(projectEcho)],
127
+ employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
128
+ projects: [makeRef(projectEcho)],
136
129
  }),
137
130
  );
138
131
  const _orgBraneframe = db.add(
139
- live(Organization, {
132
+ create(Org, {
140
133
  name: 'Braneframe',
141
- employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
142
- projects: [RefImpl.make(projectComposer)],
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: RefImpl.make(projectComposer),
185
- assignee: RefImpl.make(contactJosiah),
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: RefImpl.make(projectComposer),
191
- assignee: RefImpl.make(contactRich),
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: RefImpl.make(projectComposer),
197
- assignee: RefImpl.make(contactJosiah),
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: RefImpl.make(projectComposer),
203
- assignee: RefImpl.make(contactFred),
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: RefImpl.make(projectComposer),
209
- assignee: RefImpl.make(contactRich),
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: RefImpl.make(projectEcho),
215
- assignee: RefImpl.make(contactDima),
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: RefImpl.make(projectEcho),
221
- assignee: RefImpl.make(contactRich),
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: RefImpl.make(projectDoodles),
227
- assignee: RefImpl.make(contactFred),
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: RefImpl.make(projectDoodles),
233
- assignee: RefImpl.make(contactJosiah),
225
+ project: makeRef(projectDoodles),
226
+ assignee: makeRef(contactJosiah),
234
227
  });
235
228
 
236
- const _orgDxos = dataSource.add(Organization, {
229
+ const _orgDxos = dataSource.add(Org, {
237
230
  id: ObjectId.random(),
238
231
  name: 'DXOS',
239
- employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
240
- projects: [RefImpl.make(projectEcho)],
232
+ employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
233
+ projects: [makeRef(projectEcho)],
241
234
  });
242
- const _orgBraneframe = dataSource.add(Organization, {
235
+ const _orgBraneframe = dataSource.add(Org, {
243
236
  id: ObjectId.random(),
244
237
  name: 'Braneframe',
245
- employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
246
- projects: [RefImpl.make(projectComposer)],
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: Schema.Schema.All;
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: Schema.Schema.All;
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 Schema.Schema.All>(schema: S, data: Schema.Schema.Type<S>) {
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, ObjectId } from '@dxos/echo-schema';
7
+ import { EntityKind, TypeAnnotationId, Ref } from '@dxos/echo-schema';
8
8
 
9
- // TODO(burdon): Remove (use @dxos/schema DataType).
9
+ // TODO(burdon): Reconcile with sdk/schema/testing.
10
+ // TODO(burdon): Convert interface to type.
10
11
 
11
- /** @deprecated */
12
- export const Contact = Schema.Struct({
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: Schema.String.annotations({ description: 'The name of the person.' }),
15
- email: Schema.optional(Schema.String).annotations({ description: 'Email address.' }),
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(Schema.mutable)
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 Schema.Schema.Type<typeof Contact> {}
29
+ export interface Contact extends S.Schema.Type<typeof Contact> {}
27
30
 
28
- /** @deprecated */
29
- export const Project = Schema.Struct({
31
+ export const Project = S.Struct({
30
32
  id: ObjectId,
31
- name: Schema.String.annotations({ description: 'The name of the project.' }),
32
- description: Schema.optional(Schema.String).annotations({ description: 'The description of the project.' }),
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(Schema.mutable)
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 Schema.Schema.Type<typeof Project> {}
45
+ export interface Project extends S.Schema.Type<typeof Project> {}
44
46
 
45
- export const Task = Schema.Struct({
47
+ export const Task = S.Struct({
46
48
  id: ObjectId,
47
- name: Schema.String.annotations({ description: 'The name of the task.' }),
48
- description: Schema.optional(Schema.String).annotations({ description: 'The description of the task.' }),
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(Schema.mutable)
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 Schema.Schema.Type<typeof Task> {}
63
+ export interface Task extends S.Schema.Type<typeof Task> {}
62
64
 
63
- /** @deprecated */
64
- export const Organization = Schema.Struct({
65
+ export const Org = S.Struct({
65
66
  id: ObjectId,
66
- name: Schema.String.annotations({ description: 'The name of the organization.' }),
67
- projects: Schema.Array(Ref(Project)),
68
- employees: Schema.Array(Ref(Contact)),
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(Schema.mutable)
71
+ .pipe(S.mutable)
71
72
  .annotations({
72
73
  [TypeAnnotationId]: {
73
74
  kind: EntityKind.Object,
74
- typename: 'example.com/type/Organization',
75
+ typename: 'example.com/type/Org',
75
76
  version: '0.1.0',
76
77
  },
77
78
  description: 'Contact information.',
78
79
  });
79
- export interface Organization extends Schema.Schema.Type<typeof Organization> {}
80
+ export interface Org extends S.Schema.Type<typeof Org> {}