@dxos/assistant 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f

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 (289) hide show
  1. package/dist/lib/browser/index.mjs +1983 -64
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +1976 -63
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +1984 -64
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/{src/bin → bin}/chat.d.ts.map +1 -1
  11. package/dist/types/src/blueprint/blueprint.d.ts +79 -0
  12. package/dist/types/src/blueprint/blueprint.d.ts.map +1 -0
  13. package/dist/types/src/blueprint/blueprint.test.d.ts +2 -0
  14. package/dist/types/src/blueprint/blueprint.test.d.ts.map +1 -0
  15. package/dist/types/src/blueprint/index.d.ts +4 -0
  16. package/dist/types/src/blueprint/index.d.ts.map +1 -0
  17. package/dist/types/src/blueprint/logger.d.ts +3 -0
  18. package/dist/types/src/blueprint/logger.d.ts.map +1 -0
  19. package/dist/types/src/{ai-service/parser.d.ts → blueprint/machine.d.ts} +46 -68
  20. package/dist/types/src/blueprint/machine.d.ts.map +1 -0
  21. package/dist/types/src/blueprint/test-data.d.ts +3 -0
  22. package/dist/types/src/blueprint/test-data.d.ts.map +1 -0
  23. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +4 -0
  24. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -0
  25. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +2 -0
  26. package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +1 -0
  27. package/dist/types/src/extraction/extraction-llm-function/index.d.ts +2 -0
  28. package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +1 -0
  29. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +210 -0
  30. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -0
  31. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +2 -0
  32. package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +1 -0
  33. package/dist/types/src/extraction/extraction-ner-function/index.d.ts +3 -0
  34. package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -0
  35. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +14 -0
  36. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -0
  37. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts +2 -0
  38. package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts.map +1 -0
  39. package/dist/types/src/extraction/extraction.d.ts +242 -0
  40. package/dist/types/src/extraction/extraction.d.ts.map +1 -0
  41. package/dist/types/src/extraction/index.d.ts +5 -0
  42. package/dist/types/src/extraction/index.d.ts.map +1 -0
  43. package/dist/types/src/extraction/quotes.d.ts +15 -0
  44. package/dist/types/src/extraction/quotes.d.ts.map +1 -0
  45. package/dist/types/src/extraction/quotes.test.d.ts +2 -0
  46. package/dist/types/src/extraction/quotes.test.d.ts.map +1 -0
  47. package/dist/types/src/index.d.ts +4 -2
  48. package/dist/types/src/index.d.ts.map +1 -1
  49. package/dist/types/src/research/exa.d.ts +7 -0
  50. package/dist/types/src/research/exa.d.ts.map +1 -0
  51. package/dist/types/src/research/graph.d.ts +39 -0
  52. package/dist/types/src/research/graph.d.ts.map +1 -0
  53. package/dist/types/src/research/graph.test.d.ts +2 -0
  54. package/dist/types/src/research/graph.test.d.ts.map +1 -0
  55. package/dist/types/src/research/index.d.ts +4 -0
  56. package/dist/types/src/research/index.d.ts.map +1 -0
  57. package/dist/types/src/research/research.d.ts +10 -0
  58. package/dist/types/src/research/research.d.ts.map +1 -0
  59. package/dist/types/src/research/research.test.d.ts.map +1 -0
  60. package/dist/types/src/session/index.d.ts +0 -1
  61. package/dist/types/src/session/index.d.ts.map +1 -1
  62. package/dist/types/src/session/session.d.ts +47 -22
  63. package/dist/types/src/session/session.d.ts.map +1 -1
  64. package/dist/types/src/session/version-pin.d.ts +3 -4
  65. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  66. package/dist/types/src/summarization/summarization.test.d.ts +2 -0
  67. package/dist/types/src/summarization/summarization.test.d.ts.map +1 -0
  68. package/dist/types/src/testing/exa-search-1748337321991.d.ts +38 -0
  69. package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +1 -0
  70. package/dist/types/src/testing/exa-search-1748337331526.d.ts +37 -0
  71. package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +1 -0
  72. package/dist/types/src/testing/exa-search-1748337344119.d.ts +58 -0
  73. package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +1 -0
  74. package/dist/types/src/testing/index.d.ts +2 -7
  75. package/dist/types/src/testing/index.d.ts.map +1 -1
  76. package/dist/types/src/types.d.ts +3 -0
  77. package/dist/types/src/types.d.ts.map +1 -0
  78. package/package.json +22 -38
  79. package/src/blueprint/blueprint.test.ts +142 -0
  80. package/src/blueprint/blueprint.ts +95 -0
  81. package/src/blueprint/index.ts +7 -0
  82. package/src/blueprint/logger.ts +66 -0
  83. package/src/blueprint/machine.ts +208 -0
  84. package/src/blueprint/test-data.ts +55 -0
  85. package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +95 -0
  86. package/src/extraction/extraction-llm-function/extraction-llm-function.ts +64 -0
  87. package/src/extraction/extraction-llm-function/index.ts +5 -0
  88. package/src/extraction/extraction-llm-function/instructions.tpl +28 -0
  89. package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +115 -0
  90. package/src/extraction/extraction-ner-function/extraction-ner-function.ts +54 -0
  91. package/src/extraction/extraction-ner-function/index.ts +6 -0
  92. package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +94 -0
  93. package/src/extraction/extraction-ner-function/named-entity-recognition.ts +97 -0
  94. package/src/extraction/extraction.ts +75 -0
  95. package/src/extraction/index.ts +8 -0
  96. package/src/extraction/quotes.test.ts +27 -0
  97. package/src/extraction/quotes.ts +57 -0
  98. package/src/index.ts +4 -4
  99. package/src/research/exa.ts +100 -0
  100. package/src/research/graph.test.ts +15 -0
  101. package/src/research/graph.ts +291 -0
  102. package/src/research/index.ts +7 -0
  103. package/src/research/instructions-research.tpl +97 -0
  104. package/src/research/research.test.ts +189 -0
  105. package/src/research/research.ts +89 -0
  106. package/src/session/index.ts +0 -1
  107. package/src/session/session.test.ts +7 -7
  108. package/src/session/session.ts +46 -19
  109. package/src/session/version-pin.ts +2 -3
  110. package/src/summarization/summarization.test.ts +216 -0
  111. package/src/testing/exa-search-1748337321991.ts +131 -0
  112. package/src/testing/exa-search-1748337331526.ts +144 -0
  113. package/src/testing/exa-search-1748337344119.ts +133 -0
  114. package/src/testing/index.ts +8 -8
  115. package/src/types.ts +8 -0
  116. package/src/typings.d.ts +8 -0
  117. package/dist/lib/browser/chunk-B4HAWUFW.mjs +0 -2786
  118. package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +0 -7
  119. package/dist/lib/browser/testing/index.mjs +0 -658
  120. package/dist/lib/browser/testing/index.mjs.map +0 -7
  121. package/dist/lib/node/chunk-NOB7CIIC.cjs +0 -2791
  122. package/dist/lib/node/chunk-NOB7CIIC.cjs.map +0 -7
  123. package/dist/lib/node/testing/index.cjs +0 -672
  124. package/dist/lib/node/testing/index.cjs.map +0 -7
  125. package/dist/lib/node-esm/chunk-SAWYU3V5.mjs +0 -2788
  126. package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +0 -7
  127. package/dist/lib/node-esm/testing/index.mjs +0 -659
  128. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  129. package/dist/types/src/ai-service/client.test.d.ts +0 -2
  130. package/dist/types/src/ai-service/client.test.d.ts.map +0 -1
  131. package/dist/types/src/ai-service/defs.d.ts +0 -9
  132. package/dist/types/src/ai-service/defs.d.ts.map +0 -1
  133. package/dist/types/src/ai-service/edge-client.d.ts +0 -18
  134. package/dist/types/src/ai-service/edge-client.d.ts.map +0 -1
  135. package/dist/types/src/ai-service/index.d.ts +0 -10
  136. package/dist/types/src/ai-service/index.d.ts.map +0 -1
  137. package/dist/types/src/ai-service/message-collector.d.ts +0 -82
  138. package/dist/types/src/ai-service/message-collector.d.ts.map +0 -1
  139. package/dist/types/src/ai-service/ollama-client.d.ts +0 -43
  140. package/dist/types/src/ai-service/ollama-client.d.ts.map +0 -1
  141. package/dist/types/src/ai-service/parser.d.ts.map +0 -1
  142. package/dist/types/src/ai-service/service.d.ts +0 -25
  143. package/dist/types/src/ai-service/service.d.ts.map +0 -1
  144. package/dist/types/src/ai-service/stream.d.ts +0 -40
  145. package/dist/types/src/ai-service/stream.d.ts.map +0 -1
  146. package/dist/types/src/ai-service/stream.test.d.ts +0 -2
  147. package/dist/types/src/ai-service/stream.test.d.ts.map +0 -1
  148. package/dist/types/src/ai-service/testing/index.d.ts +0 -3
  149. package/dist/types/src/ai-service/testing/index.d.ts.map +0 -1
  150. package/dist/types/src/ai-service/testing/mock.d.ts +0 -11
  151. package/dist/types/src/ai-service/testing/mock.d.ts.map +0 -1
  152. package/dist/types/src/ai-service/testing/test-stream.d.ts +0 -7
  153. package/dist/types/src/ai-service/testing/test-stream.d.ts.map +0 -1
  154. package/dist/types/src/ai-service/transform.d.ts +0 -27
  155. package/dist/types/src/ai-service/transform.d.ts.map +0 -1
  156. package/dist/types/src/ai-service/types.d.ts +0 -210
  157. package/dist/types/src/ai-service/types.d.ts.map +0 -1
  158. package/dist/types/src/ai-service/util/index.d.ts +0 -2
  159. package/dist/types/src/ai-service/util/index.d.ts.map +0 -1
  160. package/dist/types/src/ai-service/util/sse.d.ts +0 -39
  161. package/dist/types/src/ai-service/util/sse.d.ts.map +0 -1
  162. package/dist/types/src/experimental/conversation/conversation.d.ts +0 -61
  163. package/dist/types/src/experimental/conversation/conversation.d.ts.map +0 -1
  164. package/dist/types/src/experimental/conversation/conversation.test.d.ts +0 -2
  165. package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +0 -1
  166. package/dist/types/src/experimental/conversation/index.d.ts +0 -2
  167. package/dist/types/src/experimental/conversation/index.d.ts.map +0 -1
  168. package/dist/types/src/experimental/conversation/types.d.ts +0 -78
  169. package/dist/types/src/experimental/conversation/types.d.ts.map +0 -1
  170. package/dist/types/src/experimental/cypher/ast.d.ts +0 -56
  171. package/dist/types/src/experimental/cypher/ast.d.ts.map +0 -1
  172. package/dist/types/src/experimental/cypher/combinators.d.ts +0 -14
  173. package/dist/types/src/experimental/cypher/combinators.d.ts.map +0 -1
  174. package/dist/types/src/experimental/cypher/combinators.test.d.ts +0 -2
  175. package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +0 -1
  176. package/dist/types/src/experimental/cypher/echo-data-source.d.ts +0 -16
  177. package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +0 -1
  178. package/dist/types/src/experimental/cypher/execution-plan.d.ts +0 -49
  179. package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +0 -1
  180. package/dist/types/src/experimental/cypher/execution-plan.test.d.ts +0 -2
  181. package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +0 -1
  182. package/dist/types/src/experimental/cypher/index.d.ts +0 -5
  183. package/dist/types/src/experimental/cypher/index.d.ts.map +0 -1
  184. package/dist/types/src/experimental/cypher/parjs.d.ts +0 -4
  185. package/dist/types/src/experimental/cypher/parjs.d.ts.map +0 -1
  186. package/dist/types/src/experimental/cypher/parser.d.ts +0 -6
  187. package/dist/types/src/experimental/cypher/parser.d.ts.map +0 -1
  188. package/dist/types/src/experimental/cypher/query-executor.d.ts +0 -26
  189. package/dist/types/src/experimental/cypher/query-executor.d.ts.map +0 -1
  190. package/dist/types/src/experimental/cypher/query-executor.test.d.ts +0 -2
  191. package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +0 -1
  192. package/dist/types/src/experimental/cypher/schema.d.ts +0 -12
  193. package/dist/types/src/experimental/cypher/schema.d.ts.map +0 -1
  194. package/dist/types/src/experimental/cypher/schema.test.d.ts +0 -2
  195. package/dist/types/src/experimental/cypher/schema.test.d.ts.map +0 -1
  196. package/dist/types/src/experimental/index.d.ts +0 -3
  197. package/dist/types/src/experimental/index.d.ts.map +0 -1
  198. package/dist/types/src/experimental/ner/ner.test.d.ts +0 -2
  199. package/dist/types/src/experimental/ner/ner.test.d.ts.map +0 -1
  200. package/dist/types/src/experimental/research/exa.d.ts +0 -6
  201. package/dist/types/src/experimental/research/exa.d.ts.map +0 -1
  202. package/dist/types/src/experimental/research/research.test.d.ts.map +0 -1
  203. package/dist/types/src/session/tools.d.ts +0 -18
  204. package/dist/types/src/session/tools.d.ts.map +0 -1
  205. package/dist/types/src/testing/artifacts.test.d.ts +0 -1
  206. package/dist/types/src/testing/artifacts.test.d.ts.map +0 -1
  207. package/dist/types/src/testing/data.d.ts +0 -2
  208. package/dist/types/src/testing/data.d.ts.map +0 -1
  209. package/dist/types/src/testing/defs.d.ts +0 -5
  210. package/dist/types/src/testing/defs.d.ts.map +0 -1
  211. package/dist/types/src/testing/logger.d.ts +0 -12
  212. package/dist/types/src/testing/logger.d.ts.map +0 -1
  213. package/dist/types/src/testing/object-extraction.test.d.ts +0 -1
  214. package/dist/types/src/testing/object-extraction.test.d.ts.map +0 -1
  215. package/dist/types/src/testing/ollama.d.ts +0 -6
  216. package/dist/types/src/testing/ollama.d.ts.map +0 -1
  217. package/dist/types/src/testing/printer.d.ts +0 -6
  218. package/dist/types/src/testing/printer.d.ts.map +0 -1
  219. package/dist/types/src/testing/query-promts.d.ts +0 -5
  220. package/dist/types/src/testing/query-promts.d.ts.map +0 -1
  221. package/dist/types/src/testing/query.test.d.ts +0 -2
  222. package/dist/types/src/testing/query.test.d.ts.map +0 -1
  223. package/dist/types/src/testing/test-data.d.ts +0 -29
  224. package/dist/types/src/testing/test-data.d.ts.map +0 -1
  225. package/dist/types/src/testing/test-schema.d.ts +0 -52
  226. package/dist/types/src/testing/test-schema.d.ts.map +0 -1
  227. package/dist/types/src/util/index.d.ts +0 -2
  228. package/dist/types/src/util/index.d.ts.map +0 -1
  229. package/dist/types/src/util/trim.d.ts +0 -5
  230. package/dist/types/src/util/trim.d.ts.map +0 -1
  231. package/src/ai-service/client.test.ts +0 -247
  232. package/src/ai-service/defs.ts +0 -39
  233. package/src/ai-service/edge-client.ts +0 -60
  234. package/src/ai-service/index.ts +0 -13
  235. package/src/ai-service/message-collector.ts +0 -84
  236. package/src/ai-service/ollama-client.ts +0 -506
  237. package/src/ai-service/parser.ts +0 -369
  238. package/src/ai-service/service.ts +0 -31
  239. package/src/ai-service/stream.test.ts +0 -125
  240. package/src/ai-service/stream.ts +0 -118
  241. package/src/ai-service/testing/index.ts +0 -6
  242. package/src/ai-service/testing/mock.ts +0 -30
  243. package/src/ai-service/testing/test-stream.ts +0 -93
  244. package/src/ai-service/transform.ts +0 -121
  245. package/src/ai-service/types.ts +0 -112
  246. package/src/ai-service/util/index.ts +0 -5
  247. package/src/ai-service/util/sse.ts +0 -341
  248. package/src/bin/chat.ts +0 -79
  249. package/src/experimental/conversation/conversation.test.ts +0 -73
  250. package/src/experimental/conversation/conversation.ts +0 -142
  251. package/src/experimental/conversation/index.ts +0 -5
  252. package/src/experimental/conversation/types.ts +0 -126
  253. package/src/experimental/cypher/ast.ts +0 -75
  254. package/src/experimental/cypher/combinators.test.ts +0 -137
  255. package/src/experimental/cypher/combinators.ts +0 -148
  256. package/src/experimental/cypher/echo-data-source.ts +0 -105
  257. package/src/experimental/cypher/execution-plan.test.ts +0 -44
  258. package/src/experimental/cypher/execution-plan.ts +0 -208
  259. package/src/experimental/cypher/index.ts +0 -8
  260. package/src/experimental/cypher/parjs-shims.d.ts +0 -10
  261. package/src/experimental/cypher/parjs.ts +0 -10
  262. package/src/experimental/cypher/parser.ts +0 -19
  263. package/src/experimental/cypher/query-executor.test.ts +0 -47
  264. package/src/experimental/cypher/query-executor.ts +0 -145
  265. package/src/experimental/cypher/schema.test.ts +0 -17
  266. package/src/experimental/cypher/schema.ts +0 -86
  267. package/src/experimental/index.ts +0 -6
  268. package/src/experimental/ner/ner.test.ts +0 -163
  269. package/src/experimental/research/exa.ts +0 -38
  270. package/src/experimental/research/instructions.tpl +0 -64
  271. package/src/experimental/research/research.test.ts +0 -263
  272. package/src/session/tools.ts +0 -117
  273. package/src/testing/artifacts.test.ts +0 -182
  274. package/src/testing/data.ts +0 -13
  275. package/src/testing/defs.ts +0 -9
  276. package/src/testing/logger.ts +0 -129
  277. package/src/testing/object-extraction.test.ts +0 -71
  278. package/src/testing/ollama.ts +0 -15
  279. package/src/testing/printer.ts +0 -41
  280. package/src/testing/query-promts.ts +0 -75
  281. package/src/testing/query.test.ts +0 -88
  282. package/src/testing/test-data.ts +0 -379
  283. package/src/testing/test-schema.ts +0 -79
  284. package/src/util/index.ts +0 -5
  285. package/src/util/trim.ts +0 -15
  286. package/vendor/parjs-browser.mjs +0 -4
  287. package/vendor/parjs-default.mjs +0 -8
  288. /package/dist/types/{src/bin → bin}/chat.d.ts +0 -0
  289. /package/dist/types/src/{experimental/research → research}/research.test.d.ts +0 -0
@@ -1,379 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type Schema } from 'effect';
6
-
7
- import { raise } from '@dxos/debug';
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';
17
- import { invariant } from '@dxos/invariant';
18
- import { live } from '@dxos/live-object';
19
-
20
- import {
21
- type DataSource,
22
- type Node,
23
- type Relationship,
24
- formatInferredRelationshipLabel,
25
- formatNodeLabel,
26
- } from '../experimental';
27
- import { Contact, Organization, Project, Task } from '../testing';
28
-
29
- export const seedTestData = (db: EchoDatabase) => {
30
- const contactRich = db.add(
31
- live(Contact, {
32
- name: 'Rich',
33
- }),
34
- );
35
- const contactJosiah = db.add(
36
- live(Contact, {
37
- name: 'Josiah',
38
- }),
39
- );
40
- const contactDima = db.add(
41
- live(Contact, {
42
- name: 'Dima',
43
- }),
44
- );
45
- const contactFred = db.add(
46
- live(Contact, {
47
- name: 'Fred',
48
- }),
49
- );
50
-
51
- const projectComposer = db.add(
52
- live(Project, {
53
- name: 'Composer',
54
- }),
55
- );
56
- const projectEcho = db.add(
57
- live(Project, {
58
- name: 'ECHO',
59
- }),
60
- );
61
- const projectDoodles = db.add(
62
- live(Project, {
63
- name: 'Doodles',
64
- }),
65
- );
66
-
67
- const _taskComposer1 = db.add(
68
- live(Task, {
69
- name: 'Optimize startup performance',
70
- project: RefImpl.make(projectComposer),
71
- assignee: RefImpl.make(contactJosiah),
72
- }),
73
- );
74
- const _taskComposer2 = db.add(
75
- live(Task, {
76
- name: 'Create form builder',
77
- project: RefImpl.make(projectComposer),
78
- assignee: RefImpl.make(contactRich),
79
- }),
80
- );
81
- const _taskComposer3 = db.add(
82
- live(Task, {
83
- name: 'Add support for custom themes',
84
- project: RefImpl.make(projectComposer),
85
- assignee: RefImpl.make(contactJosiah),
86
- }),
87
- );
88
- const _taskComposer5 = db.add(
89
- live(Task, {
90
- name: 'Implement community plugin',
91
- project: RefImpl.make(projectComposer),
92
- assignee: RefImpl.make(contactFred),
93
- }),
94
- );
95
- const _taskComposer4 = db.add(
96
- live(Task, {
97
- name: 'Implement dark mode',
98
- project: RefImpl.make(projectComposer),
99
- assignee: RefImpl.make(contactRich),
100
- }),
101
- );
102
- const _taskEcho1 = db.add(
103
- live(Task, {
104
- name: 'Implement cypher query engine',
105
- project: RefImpl.make(projectEcho),
106
- assignee: RefImpl.make(contactDima),
107
- }),
108
- );
109
- const _taskEcho2 = db.add(
110
- live(Task, {
111
- name: 'Add schema editor',
112
- project: RefImpl.make(projectEcho),
113
- assignee: RefImpl.make(contactRich),
114
- }),
115
- );
116
- const _taskDoodles1 = db.add(
117
- live(Task, {
118
- name: 'Add support for custom themes',
119
- project: RefImpl.make(projectDoodles),
120
- assignee: RefImpl.make(contactFred),
121
- }),
122
- );
123
- const _taskDoodles2 = db.add(
124
- live(Task, {
125
- name: 'Implement dark mode',
126
- project: RefImpl.make(projectDoodles),
127
- assignee: RefImpl.make(contactJosiah),
128
- }),
129
- );
130
-
131
- const _orgDxos = db.add(
132
- live(Organization, {
133
- name: 'DXOS',
134
- employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
135
- projects: [RefImpl.make(projectEcho)],
136
- }),
137
- );
138
- const _orgBraneframe = db.add(
139
- live(Organization, {
140
- name: 'Braneframe',
141
- employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
142
- projects: [RefImpl.make(projectComposer)],
143
- }),
144
- );
145
- };
146
-
147
- // TODO(burdon): Use schema/testing.
148
- export const createTestData = (): MockDataSource => {
149
- const dataSource = new MockDataSource();
150
-
151
- const contactRich = dataSource.add(Contact, {
152
- id: ObjectId.random(),
153
- name: 'Rich',
154
- });
155
- const contactJosiah = dataSource.add(Contact, {
156
- id: ObjectId.random(),
157
- name: 'Josiah',
158
- });
159
- const contactDima = dataSource.add(Contact, {
160
- id: ObjectId.random(),
161
- name: 'Dima',
162
- });
163
- const contactFred = dataSource.add(Contact, {
164
- id: ObjectId.random(),
165
- name: 'Fred',
166
- });
167
-
168
- const projectComposer = dataSource.add(Project, {
169
- id: ObjectId.random(),
170
- name: 'Composer',
171
- });
172
- const projectEcho = dataSource.add(Project, {
173
- id: ObjectId.random(),
174
- name: 'ECHO',
175
- });
176
- const projectDoodles = dataSource.add(Project, {
177
- id: ObjectId.random(),
178
- name: 'Doodles',
179
- });
180
-
181
- const _taskComposer1 = dataSource.add(Task, {
182
- id: ObjectId.random(),
183
- name: 'Optimize startup performance',
184
- project: RefImpl.make(projectComposer),
185
- assignee: RefImpl.make(contactJosiah),
186
- });
187
- const _taskComposer2 = dataSource.add(Task, {
188
- id: ObjectId.random(),
189
- name: 'Create form builder',
190
- project: RefImpl.make(projectComposer),
191
- assignee: RefImpl.make(contactRich),
192
- });
193
- const _taskComposer3 = dataSource.add(Task, {
194
- id: ObjectId.random(),
195
- name: 'Add support for custom themes',
196
- project: RefImpl.make(projectComposer),
197
- assignee: RefImpl.make(contactJosiah),
198
- });
199
- const _taskComposer5 = dataSource.add(Task, {
200
- id: ObjectId.random(),
201
- name: 'Implement community plugin',
202
- project: RefImpl.make(projectComposer),
203
- assignee: RefImpl.make(contactFred),
204
- });
205
- const _taskComposer4 = dataSource.add(Task, {
206
- id: ObjectId.random(),
207
- name: 'Implement dark mode',
208
- project: RefImpl.make(projectComposer),
209
- assignee: RefImpl.make(contactRich),
210
- });
211
- const _taskEcho1 = dataSource.add(Task, {
212
- id: ObjectId.random(),
213
- name: 'Implement cypher query engine',
214
- project: RefImpl.make(projectEcho),
215
- assignee: RefImpl.make(contactDima),
216
- });
217
- const _taskEcho2 = dataSource.add(Task, {
218
- id: ObjectId.random(),
219
- name: 'Add schema editor',
220
- project: RefImpl.make(projectEcho),
221
- assignee: RefImpl.make(contactRich),
222
- });
223
- const _taskDoodles1 = dataSource.add(Task, {
224
- id: ObjectId.random(),
225
- name: 'Add support for custom themes',
226
- project: RefImpl.make(projectDoodles),
227
- assignee: RefImpl.make(contactFred),
228
- });
229
- const _taskDoodles2 = dataSource.add(Task, {
230
- id: ObjectId.random(),
231
- name: 'Implement dark mode',
232
- project: RefImpl.make(projectDoodles),
233
- assignee: RefImpl.make(contactJosiah),
234
- });
235
-
236
- const _orgDxos = dataSource.add(Organization, {
237
- id: ObjectId.random(),
238
- name: 'DXOS',
239
- employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
240
- projects: [RefImpl.make(projectEcho)],
241
- });
242
- const _orgBraneframe = dataSource.add(Organization, {
243
- id: ObjectId.random(),
244
- name: 'Braneframe',
245
- employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
246
- projects: [RefImpl.make(projectComposer)],
247
- });
248
- dataSource.computeGraph();
249
-
250
- return dataSource;
251
- };
252
-
253
- export class MockDataSource implements DataSource {
254
- objects: Record<
255
- string,
256
- {
257
- schema: Schema.Schema.All;
258
- typeDxn: string;
259
- id: string;
260
- data: unknown;
261
- }
262
- > = {};
263
-
264
- schema: Record<
265
- string,
266
- {
267
- json: JsonSchemaType;
268
- instance: Schema.Schema.All;
269
- }
270
- > = {};
271
-
272
- nodes: Node[] = [];
273
- relationships: Relationship[] = [];
274
-
275
- async getNodes({ label }: { label?: string }) {
276
- return this.nodes.filter((node) => !label || node.label === label);
277
- }
278
-
279
- async getRelationships({ label }: { label?: string }) {
280
- return this.relationships.filter((relationship) => !label || relationship.label === label);
281
- }
282
-
283
- add<S extends Schema.Schema.All>(schema: S, data: Schema.Schema.Type<S>) {
284
- invariant(typeof data.id === 'string', 'Data must have an id');
285
- const jsonSchema = toJsonSchema(schema);
286
- if (!this.schema[jsonSchema.$id!]) {
287
- this.schema[jsonSchema.$id!] = {
288
- json: jsonSchema,
289
- instance: schema,
290
- };
291
- }
292
-
293
- const typenameDxn = jsonSchema.$id ?? raise(new Error('Schema must have $id'));
294
-
295
- this.objects[data.id] = {
296
- schema,
297
- id: data.id,
298
- typeDxn: typenameDxn,
299
- data,
300
- };
301
-
302
- return data;
303
- }
304
-
305
- computeGraph() {
306
- this.nodes = [];
307
- this.relationships = [];
308
-
309
- for (const object of Object.values(this.objects)) {
310
- this.nodes.push({
311
- kind: 'node',
312
- id: object.id,
313
- label: formatNodeLabel(object.typeDxn),
314
- properties: object.data as any,
315
- });
316
- }
317
-
318
- for (const object of Object.values(this.objects)) {
319
- const schema = this.schema[object.typeDxn].json;
320
- const typenameDxn = schema.$id ?? raise(new Error('Schema must have $id'));
321
-
322
- for (const [name, propSchema] of Object.entries(schema.properties!)) {
323
- if (propSchema.$id === JSON_SCHEMA_ECHO_REF_ID) {
324
- const label = formatInferredRelationshipLabel(typenameDxn, name);
325
-
326
- const source = this.nodes.find((node) => node.id === object.id);
327
- if (!source) {
328
- continue;
329
- }
330
-
331
- const { id: targetId } = (object.data as any)[name].target;
332
-
333
- const target = this.nodes.find((node) => node.id === targetId);
334
- if (!target) {
335
- continue;
336
- }
337
-
338
- this.relationships.push({
339
- kind: 'relationship',
340
- id: `${object.id}-${name}-${target.id}`,
341
- label,
342
- properties: {},
343
- source,
344
- target,
345
- });
346
- } else if (
347
- propSchema.type === 'array' &&
348
- propSchema.items &&
349
- typeof propSchema.items === 'object' &&
350
- '$id' in propSchema.items &&
351
- propSchema.items.$id === JSON_SCHEMA_ECHO_REF_ID
352
- ) {
353
- const label = formatInferredRelationshipLabel(typenameDxn, name);
354
-
355
- const source = this.nodes.find((node) => node.id === object.id);
356
- if (!source) {
357
- continue;
358
- }
359
-
360
- for (const { id: targetId } of (object.data as any)[name].map((x: Ref<any>) => x.target)) {
361
- const target = this.nodes.find((node) => node.id === targetId);
362
- if (!target) {
363
- continue;
364
- }
365
-
366
- this.relationships.push({
367
- kind: 'relationship',
368
- id: `${object.id}-${name}-${targetId}`,
369
- label,
370
- properties: {},
371
- source,
372
- target,
373
- });
374
- }
375
- }
376
- }
377
- }
378
- }
379
- }
@@ -1,79 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { EntityKind, TypeAnnotationId, Ref, ObjectId } from '@dxos/echo-schema';
8
-
9
- // TODO(burdon): Remove (use @dxos/schema DataType).
10
-
11
- /** @deprecated */
12
- export const Contact = Schema.Struct({
13
- id: ObjectId,
14
- name: Schema.String.annotations({ description: 'The name of the person.' }),
15
- email: Schema.optional(Schema.String).annotations({ description: 'Email address.' }),
16
- })
17
- .pipe(Schema.mutable)
18
- .annotations({
19
- [TypeAnnotationId]: {
20
- kind: EntityKind.Object,
21
- typename: 'example.com/type/Contact',
22
- version: '0.1.0',
23
- },
24
- description: 'Contact information.',
25
- });
26
- export interface Contact extends Schema.Schema.Type<typeof Contact> {}
27
-
28
- /** @deprecated */
29
- export const Project = Schema.Struct({
30
- 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
- })
34
- .pipe(Schema.mutable)
35
- .annotations({
36
- [TypeAnnotationId]: {
37
- kind: EntityKind.Object,
38
- typename: 'example.com/type/Project',
39
- version: '0.1.0',
40
- },
41
- description: 'Contact information.',
42
- });
43
- export interface Project extends Schema.Schema.Type<typeof Project> {}
44
-
45
- export const Task = Schema.Struct({
46
- 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
- project: Ref(Project),
50
- assignee: Ref(Contact),
51
- })
52
- .pipe(Schema.mutable)
53
- .annotations({
54
- [TypeAnnotationId]: {
55
- kind: EntityKind.Object,
56
- typename: 'example.com/type/Task',
57
- version: '0.1.0',
58
- },
59
- description: 'Contact information.',
60
- });
61
- export interface Task extends Schema.Schema.Type<typeof Task> {}
62
-
63
- /** @deprecated */
64
- export const Organization = Schema.Struct({
65
- 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)),
69
- })
70
- .pipe(Schema.mutable)
71
- .annotations({
72
- [TypeAnnotationId]: {
73
- kind: EntityKind.Object,
74
- typename: 'example.com/type/Organization',
75
- version: '0.1.0',
76
- },
77
- description: 'Contact information.',
78
- });
79
- export interface Organization extends Schema.Schema.Type<typeof Organization> {}
package/src/util/index.ts DELETED
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export * from './trim';
package/src/util/trim.ts DELETED
@@ -1,15 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- /**
6
- * Trims multiline strings.
7
- */
8
- // TODO(burdon): Move to util.
9
- export const trim = (strings: TemplateStringsArray, ...values: any[]) => {
10
- const combined = strings.reduce((acc, str, i) => {
11
- return acc + str + (values[i] || '');
12
- }, '');
13
-
14
- return combined.replace('/^\n/', '').replace(/\n$/, '');
15
- };
@@ -1,4 +0,0 @@
1
- import * as parjs from 'parjs';
2
- import * as parjsCombinators from 'parjs/combinators';
3
-
4
- export { parjsCombinators, parjs };
@@ -1,8 +0,0 @@
1
- import { createRequire } from 'node:module';
2
-
3
- // TODO(dmaretskyi): Must be like this or it breaks vitest.
4
- const require = createRequire(import.meta.url);
5
- const parjs = require('parjs');
6
- const parjsCombinators = require('parjs/combinators');
7
-
8
- export { parjsCombinators, parjs };
File without changes