@kelpie/server 0.9.0 → 0.11.0

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 (449) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +2 -0
  3. package/dist/app.js.map +1 -1
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/actor.d.ts +3 -1
  9. package/dist/lib/actor.d.ts.map +1 -1
  10. package/dist/lib/actor.js.map +1 -1
  11. package/dist/lib/apiKeyScopes.d.ts +8 -0
  12. package/dist/lib/apiKeyScopes.d.ts.map +1 -0
  13. package/dist/lib/apiKeyScopes.js +166 -0
  14. package/dist/lib/apiKeyScopes.js.map +1 -0
  15. package/dist/modules/activities/repository.d.ts +2 -0
  16. package/dist/modules/activities/repository.d.ts.map +1 -1
  17. package/dist/modules/activities/repository.js +9 -0
  18. package/dist/modules/activities/repository.js.map +1 -1
  19. package/dist/modules/agent-tasks/repository.d.ts +2 -0
  20. package/dist/modules/agent-tasks/repository.d.ts.map +1 -1
  21. package/dist/modules/agent-tasks/repository.js +9 -0
  22. package/dist/modules/agent-tasks/repository.js.map +1 -1
  23. package/dist/modules/api-keys/routes.d.ts.map +1 -1
  24. package/dist/modules/api-keys/routes.js +4 -1
  25. package/dist/modules/api-keys/routes.js.map +1 -1
  26. package/dist/modules/api-keys/schema.d.ts +43 -0
  27. package/dist/modules/api-keys/schema.d.ts.map +1 -1
  28. package/dist/modules/api-keys/schema.js +2 -0
  29. package/dist/modules/api-keys/schema.js.map +1 -1
  30. package/dist/modules/api-keys/scopeMiddleware.d.ts +8 -0
  31. package/dist/modules/api-keys/scopeMiddleware.d.ts.map +1 -0
  32. package/dist/modules/api-keys/scopeMiddleware.js +21 -0
  33. package/dist/modules/api-keys/scopeMiddleware.js.map +1 -0
  34. package/dist/modules/api-keys/service.d.ts +3 -1
  35. package/dist/modules/api-keys/service.d.ts.map +1 -1
  36. package/dist/modules/api-keys/service.js +26 -1
  37. package/dist/modules/api-keys/service.js.map +1 -1
  38. package/dist/modules/auth/credentials.d.ts.map +1 -1
  39. package/dist/modules/auth/credentials.js +2 -0
  40. package/dist/modules/auth/credentials.js.map +1 -1
  41. package/dist/modules/consent-purposes/index.d.ts +1 -1
  42. package/dist/modules/consent-purposes/index.js +1 -1
  43. package/dist/modules/consent-purposes/schema.d.ts +3 -3
  44. package/dist/modules/consent-purposes/schema.js +3 -3
  45. package/dist/modules/consent-purposes/service.d.ts +1 -1
  46. package/dist/modules/consent-purposes/service.d.ts.map +1 -1
  47. package/dist/modules/consent-purposes/service.js +7 -16
  48. package/dist/modules/consent-purposes/service.js.map +1 -1
  49. package/dist/modules/consent-purposes/starters.d.ts +1 -1
  50. package/dist/modules/consent-purposes/tools.js +1 -1
  51. package/dist/modules/consent-purposes/tools.js.map +1 -1
  52. package/dist/modules/conversions/clearPointers.d.ts +10 -0
  53. package/dist/modules/conversions/clearPointers.d.ts.map +1 -0
  54. package/dist/modules/conversions/clearPointers.js +40 -0
  55. package/dist/modules/conversions/clearPointers.js.map +1 -0
  56. package/dist/modules/conversions/factory.d.ts +5 -0
  57. package/dist/modules/conversions/factory.d.ts.map +1 -0
  58. package/dist/modules/conversions/factory.js +18 -0
  59. package/dist/modules/conversions/factory.js.map +1 -0
  60. package/dist/modules/conversions/fieldMap.d.ts +55 -0
  61. package/dist/modules/conversions/fieldMap.d.ts.map +1 -0
  62. package/dist/modules/conversions/fieldMap.js +398 -0
  63. package/dist/modules/conversions/fieldMap.js.map +1 -0
  64. package/dist/modules/conversions/index.d.ts +7 -0
  65. package/dist/modules/conversions/index.d.ts.map +1 -0
  66. package/dist/modules/conversions/index.js +6 -0
  67. package/dist/modules/conversions/index.js.map +1 -0
  68. package/dist/modules/conversions/mcp.d.ts +7 -0
  69. package/dist/modules/conversions/mcp.d.ts.map +1 -0
  70. package/dist/modules/conversions/mcp.js +47 -0
  71. package/dist/modules/conversions/mcp.js.map +1 -0
  72. package/dist/modules/conversions/repoint.d.ts +19 -0
  73. package/dist/modules/conversions/repoint.d.ts.map +1 -0
  74. package/dist/modules/conversions/repoint.js +51 -0
  75. package/dist/modules/conversions/repoint.js.map +1 -0
  76. package/dist/modules/conversions/routes.d.ts +26 -0
  77. package/dist/modules/conversions/routes.d.ts.map +1 -0
  78. package/dist/modules/conversions/routes.js +23 -0
  79. package/dist/modules/conversions/routes.js.map +1 -0
  80. package/dist/modules/conversions/service.d.ts +28 -0
  81. package/dist/modules/conversions/service.d.ts.map +1 -0
  82. package/dist/modules/conversions/service.js +170 -0
  83. package/dist/modules/conversions/service.js.map +1 -0
  84. package/dist/modules/conversions/wire.d.ts +4 -0
  85. package/dist/modules/conversions/wire.d.ts.map +1 -0
  86. package/dist/modules/conversions/wire.js +28 -0
  87. package/dist/modules/conversions/wire.js.map +1 -0
  88. package/dist/modules/deals/events.d.ts +9 -0
  89. package/dist/modules/deals/events.d.ts.map +1 -1
  90. package/dist/modules/deals/events.js +4 -0
  91. package/dist/modules/deals/events.js.map +1 -1
  92. package/dist/modules/deals/index.d.ts.map +1 -1
  93. package/dist/modules/deals/index.js +4 -2
  94. package/dist/modules/deals/index.js.map +1 -1
  95. package/dist/modules/deals/routes.d.ts +2 -0
  96. package/dist/modules/deals/routes.d.ts.map +1 -1
  97. package/dist/modules/deals/routes.js +8 -1
  98. package/dist/modules/deals/routes.js.map +1 -1
  99. package/dist/modules/deals/schema.d.ts +34 -0
  100. package/dist/modules/deals/schema.d.ts.map +1 -1
  101. package/dist/modules/deals/schema.js +7 -2
  102. package/dist/modules/deals/schema.js.map +1 -1
  103. package/dist/modules/deals/service.d.ts.map +1 -1
  104. package/dist/modules/deals/service.js +2 -0
  105. package/dist/modules/deals/service.js.map +1 -1
  106. package/dist/modules/deals/tools.d.ts +2 -1
  107. package/dist/modules/deals/tools.d.ts.map +1 -1
  108. package/dist/modules/deals/tools.js +3 -1
  109. package/dist/modules/deals/tools.js.map +1 -1
  110. package/dist/modules/decisions/repository.d.ts +2 -1
  111. package/dist/modules/decisions/repository.d.ts.map +1 -1
  112. package/dist/modules/decisions/repository.js +9 -1
  113. package/dist/modules/decisions/repository.js.map +1 -1
  114. package/dist/modules/enquiries/events.d.ts +6 -2
  115. package/dist/modules/enquiries/events.d.ts.map +1 -1
  116. package/dist/modules/enquiries/events.js +5 -1
  117. package/dist/modules/enquiries/events.js.map +1 -1
  118. package/dist/modules/enquiries/index.d.ts.map +1 -1
  119. package/dist/modules/enquiries/index.js +4 -2
  120. package/dist/modules/enquiries/index.js.map +1 -1
  121. package/dist/modules/enquiries/routes.d.ts +2 -0
  122. package/dist/modules/enquiries/routes.d.ts.map +1 -1
  123. package/dist/modules/enquiries/routes.js +9 -9
  124. package/dist/modules/enquiries/routes.js.map +1 -1
  125. package/dist/modules/enquiries/schema.d.ts +36 -1
  126. package/dist/modules/enquiries/schema.d.ts.map +1 -1
  127. package/dist/modules/enquiries/schema.js +9 -3
  128. package/dist/modules/enquiries/schema.js.map +1 -1
  129. package/dist/modules/enquiries/service.d.ts +0 -8
  130. package/dist/modules/enquiries/service.d.ts.map +1 -1
  131. package/dist/modules/enquiries/service.js +3 -95
  132. package/dist/modules/enquiries/service.js.map +1 -1
  133. package/dist/modules/enquiries/tools.d.ts +2 -1
  134. package/dist/modules/enquiries/tools.d.ts.map +1 -1
  135. package/dist/modules/enquiries/tools.js +4 -16
  136. package/dist/modules/enquiries/tools.js.map +1 -1
  137. package/dist/modules/forms/applyMappedFields.d.ts +20 -0
  138. package/dist/modules/forms/applyMappedFields.d.ts.map +1 -0
  139. package/dist/modules/forms/applyMappedFields.js +169 -0
  140. package/dist/modules/forms/applyMappedFields.js.map +1 -0
  141. package/dist/modules/forms/applySubmissionFields.d.ts +18 -0
  142. package/dist/modules/forms/applySubmissionFields.d.ts.map +1 -0
  143. package/dist/modules/forms/applySubmissionFields.js +230 -0
  144. package/dist/modules/forms/applySubmissionFields.js.map +1 -0
  145. package/dist/modules/forms/fields.d.ts +7 -2
  146. package/dist/modules/forms/fields.d.ts.map +1 -1
  147. package/dist/modules/forms/fields.js +17 -6
  148. package/dist/modules/forms/fields.js.map +1 -1
  149. package/dist/modules/forms/mapping.d.ts +8 -2
  150. package/dist/modules/forms/mapping.d.ts.map +1 -1
  151. package/dist/modules/forms/mapping.js +11 -0
  152. package/dist/modules/forms/mapping.js.map +1 -1
  153. package/dist/modules/forms/repository.d.ts +0 -5
  154. package/dist/modules/forms/repository.d.ts.map +1 -1
  155. package/dist/modules/forms/repository.js +0 -2
  156. package/dist/modules/forms/repository.js.map +1 -1
  157. package/dist/modules/forms/routes.d.ts +2 -30
  158. package/dist/modules/forms/routes.d.ts.map +1 -1
  159. package/dist/modules/forms/routes.js +2 -2
  160. package/dist/modules/forms/routes.js.map +1 -1
  161. package/dist/modules/forms/schema.d.ts.map +1 -1
  162. package/dist/modules/forms/schema.js +1 -2
  163. package/dist/modules/forms/schema.js.map +1 -1
  164. package/dist/modules/forms/service.d.ts.map +1 -1
  165. package/dist/modules/forms/service.js +18 -3
  166. package/dist/modules/forms/service.js.map +1 -1
  167. package/dist/modules/forms/starters.d.ts +31 -0
  168. package/dist/modules/forms/starters.d.ts.map +1 -0
  169. package/dist/modules/forms/starters.js +94 -0
  170. package/dist/modules/forms/starters.js.map +1 -0
  171. package/dist/modules/forms/submission.d.ts +1 -0
  172. package/dist/modules/forms/submission.d.ts.map +1 -1
  173. package/dist/modules/forms/submission.js +58 -37
  174. package/dist/modules/forms/submission.js.map +1 -1
  175. package/dist/modules/import-export/customFieldCsv.d.ts +9 -0
  176. package/dist/modules/import-export/customFieldCsv.d.ts.map +1 -0
  177. package/dist/modules/import-export/customFieldCsv.js +39 -0
  178. package/dist/modules/import-export/customFieldCsv.js.map +1 -0
  179. package/dist/modules/import-export/customFieldImport.d.ts +19 -0
  180. package/dist/modules/import-export/customFieldImport.d.ts.map +1 -0
  181. package/dist/modules/import-export/customFieldImport.js +76 -0
  182. package/dist/modules/import-export/customFieldImport.js.map +1 -0
  183. package/dist/modules/import-export/drafts.d.ts +57 -3
  184. package/dist/modules/import-export/drafts.d.ts.map +1 -1
  185. package/dist/modules/import-export/drafts.js +65 -3
  186. package/dist/modules/import-export/drafts.js.map +1 -1
  187. package/dist/modules/import-export/exportRows.d.ts +15 -13
  188. package/dist/modules/import-export/exportRows.d.ts.map +1 -1
  189. package/dist/modules/import-export/exportRows.js +99 -26
  190. package/dist/modules/import-export/exportRows.js.map +1 -1
  191. package/dist/modules/import-export/plan.d.ts +42 -11
  192. package/dist/modules/import-export/plan.d.ts.map +1 -1
  193. package/dist/modules/import-export/plan.js +198 -56
  194. package/dist/modules/import-export/plan.js.map +1 -1
  195. package/dist/modules/import-export/repository.d.ts +58 -2
  196. package/dist/modules/import-export/repository.d.ts.map +1 -1
  197. package/dist/modules/import-export/repository.js +201 -12
  198. package/dist/modules/import-export/repository.js.map +1 -1
  199. package/dist/modules/import-export/routes.d.ts.map +1 -1
  200. package/dist/modules/import-export/routes.js +5 -5
  201. package/dist/modules/import-export/routes.js.map +1 -1
  202. package/dist/modules/import-export/service.d.ts +8 -3
  203. package/dist/modules/import-export/service.d.ts.map +1 -1
  204. package/dist/modules/import-export/service.js +133 -40
  205. package/dist/modules/import-export/service.js.map +1 -1
  206. package/dist/modules/import-export/streams.d.ts +2 -2
  207. package/dist/modules/import-export/streams.d.ts.map +1 -1
  208. package/dist/modules/import-export/streams.js +50 -9
  209. package/dist/modules/import-export/streams.js.map +1 -1
  210. package/dist/modules/import-export/tools.d.ts.map +1 -1
  211. package/dist/modules/import-export/tools.js +13 -7
  212. package/dist/modules/import-export/tools.js.map +1 -1
  213. package/dist/modules/import-export/validation.d.ts +5 -1
  214. package/dist/modules/import-export/validation.d.ts.map +1 -1
  215. package/dist/modules/import-export/validation.js +89 -2
  216. package/dist/modules/import-export/validation.js.map +1 -1
  217. package/dist/modules/import-export/writes.d.ts +2 -1
  218. package/dist/modules/import-export/writes.d.ts.map +1 -1
  219. package/dist/modules/import-export/writes.js +358 -25
  220. package/dist/modules/import-export/writes.js.map +1 -1
  221. package/dist/modules/lists/index.d.ts +38 -0
  222. package/dist/modules/lists/index.d.ts.map +1 -1
  223. package/dist/modules/lists/index.js +27 -0
  224. package/dist/modules/lists/index.js.map +1 -1
  225. package/dist/modules/lists/repository.d.ts +15 -1
  226. package/dist/modules/lists/repository.d.ts.map +1 -1
  227. package/dist/modules/lists/repository.js +19 -1
  228. package/dist/modules/lists/repository.js.map +1 -1
  229. package/dist/modules/lists/routes.d.ts +0 -2
  230. package/dist/modules/lists/routes.d.ts.map +1 -1
  231. package/dist/modules/lists/routes.js +0 -8
  232. package/dist/modules/lists/routes.js.map +1 -1
  233. package/dist/modules/lists/schema.d.ts +0 -17
  234. package/dist/modules/lists/schema.d.ts.map +1 -1
  235. package/dist/modules/lists/schema.js +0 -10
  236. package/dist/modules/lists/schema.js.map +1 -1
  237. package/dist/modules/lists/service.d.ts +2 -14
  238. package/dist/modules/lists/service.d.ts.map +1 -1
  239. package/dist/modules/lists/service.js +7 -53
  240. package/dist/modules/lists/service.js.map +1 -1
  241. package/dist/modules/lists/starters.d.ts +12 -0
  242. package/dist/modules/lists/starters.d.ts.map +1 -0
  243. package/dist/modules/lists/starters.js +4 -0
  244. package/dist/modules/lists/starters.js.map +1 -0
  245. package/dist/modules/mcp/protocol.d.ts.map +1 -1
  246. package/dist/modules/mcp/protocol.js +13 -0
  247. package/dist/modules/mcp/protocol.js.map +1 -1
  248. package/dist/modules/notes/repository.d.ts +2 -0
  249. package/dist/modules/notes/repository.d.ts.map +1 -1
  250. package/dist/modules/notes/repository.js +9 -0
  251. package/dist/modules/notes/repository.js.map +1 -1
  252. package/dist/modules/opportunities/events.d.ts +9 -0
  253. package/dist/modules/opportunities/events.d.ts.map +1 -1
  254. package/dist/modules/opportunities/events.js +4 -0
  255. package/dist/modules/opportunities/events.js.map +1 -1
  256. package/dist/modules/opportunities/index.d.ts.map +1 -1
  257. package/dist/modules/opportunities/index.js +4 -2
  258. package/dist/modules/opportunities/index.js.map +1 -1
  259. package/dist/modules/opportunities/routes.d.ts +2 -0
  260. package/dist/modules/opportunities/routes.d.ts.map +1 -1
  261. package/dist/modules/opportunities/routes.js +8 -1
  262. package/dist/modules/opportunities/routes.js.map +1 -1
  263. package/dist/modules/opportunities/schema.d.ts +34 -0
  264. package/dist/modules/opportunities/schema.d.ts.map +1 -1
  265. package/dist/modules/opportunities/schema.js +7 -2
  266. package/dist/modules/opportunities/schema.js.map +1 -1
  267. package/dist/modules/opportunities/service.d.ts.map +1 -1
  268. package/dist/modules/opportunities/service.js +2 -0
  269. package/dist/modules/opportunities/service.js.map +1 -1
  270. package/dist/modules/opportunities/tools.d.ts +2 -1
  271. package/dist/modules/opportunities/tools.d.ts.map +1 -1
  272. package/dist/modules/opportunities/tools.js +3 -1
  273. package/dist/modules/opportunities/tools.js.map +1 -1
  274. package/dist/modules/partnerships/events.d.ts +9 -0
  275. package/dist/modules/partnerships/events.d.ts.map +1 -1
  276. package/dist/modules/partnerships/events.js +4 -0
  277. package/dist/modules/partnerships/events.js.map +1 -1
  278. package/dist/modules/partnerships/index.d.ts.map +1 -1
  279. package/dist/modules/partnerships/index.js +4 -2
  280. package/dist/modules/partnerships/index.js.map +1 -1
  281. package/dist/modules/partnerships/routes.d.ts +2 -0
  282. package/dist/modules/partnerships/routes.d.ts.map +1 -1
  283. package/dist/modules/partnerships/routes.js +8 -1
  284. package/dist/modules/partnerships/routes.js.map +1 -1
  285. package/dist/modules/partnerships/schema.d.ts +34 -0
  286. package/dist/modules/partnerships/schema.d.ts.map +1 -1
  287. package/dist/modules/partnerships/schema.js +7 -2
  288. package/dist/modules/partnerships/schema.js.map +1 -1
  289. package/dist/modules/partnerships/service.d.ts.map +1 -1
  290. package/dist/modules/partnerships/service.js +2 -0
  291. package/dist/modules/partnerships/service.js.map +1 -1
  292. package/dist/modules/partnerships/tools.d.ts +2 -1
  293. package/dist/modules/partnerships/tools.d.ts.map +1 -1
  294. package/dist/modules/partnerships/tools.js +3 -1
  295. package/dist/modules/partnerships/tools.js.map +1 -1
  296. package/dist/modules/people/personConsentWrites.d.ts +1 -1
  297. package/dist/modules/people/schema.js +1 -1
  298. package/dist/modules/people/schema.js.map +1 -1
  299. package/dist/modules/plans/repository.d.ts +2 -0
  300. package/dist/modules/plans/repository.d.ts.map +1 -1
  301. package/dist/modules/plans/repository.js +9 -0
  302. package/dist/modules/plans/repository.js.map +1 -1
  303. package/dist/modules/raises/events.d.ts +9 -0
  304. package/dist/modules/raises/events.d.ts.map +1 -1
  305. package/dist/modules/raises/events.js +4 -0
  306. package/dist/modules/raises/events.js.map +1 -1
  307. package/dist/modules/raises/index.d.ts.map +1 -1
  308. package/dist/modules/raises/index.js +4 -2
  309. package/dist/modules/raises/index.js.map +1 -1
  310. package/dist/modules/raises/routes.d.ts +2 -0
  311. package/dist/modules/raises/routes.d.ts.map +1 -1
  312. package/dist/modules/raises/routes.js +8 -1
  313. package/dist/modules/raises/routes.js.map +1 -1
  314. package/dist/modules/raises/schema.d.ts +34 -0
  315. package/dist/modules/raises/schema.d.ts.map +1 -1
  316. package/dist/modules/raises/schema.js +7 -2
  317. package/dist/modules/raises/schema.js.map +1 -1
  318. package/dist/modules/raises/service.d.ts.map +1 -1
  319. package/dist/modules/raises/service.js +2 -0
  320. package/dist/modules/raises/service.js.map +1 -1
  321. package/dist/modules/raises/tools.d.ts +2 -1
  322. package/dist/modules/raises/tools.d.ts.map +1 -1
  323. package/dist/modules/raises/tools.js +3 -1
  324. package/dist/modules/raises/tools.js.map +1 -1
  325. package/dist/modules/workspace/routes.d.ts +0 -2
  326. package/dist/modules/workspace/routes.d.ts.map +1 -1
  327. package/dist/modules/workspace/routes.js +0 -6
  328. package/dist/modules/workspace/routes.js.map +1 -1
  329. package/dist/modules/workspace/schema.d.ts +0 -34
  330. package/dist/modules/workspace/schema.d.ts.map +1 -1
  331. package/dist/modules/workspace/schema.js +0 -2
  332. package/dist/modules/workspace/schema.js.map +1 -1
  333. package/dist/modules/workspace/seedStarterForms.d.ts +17 -0
  334. package/dist/modules/workspace/seedStarterForms.d.ts.map +1 -0
  335. package/dist/modules/workspace/seedStarterForms.js +71 -0
  336. package/dist/modules/workspace/seedStarterForms.js.map +1 -0
  337. package/dist/modules/workspace/service.d.ts +0 -4
  338. package/dist/modules/workspace/service.d.ts.map +1 -1
  339. package/dist/modules/workspace/service.js +20 -10
  340. package/dist/modules/workspace/service.js.map +1 -1
  341. package/dist/modules/workspace/tools.js +1 -1
  342. package/dist/modules/workspace/tools.js.map +1 -1
  343. package/dist/testing/fixtures.d.ts.map +1 -1
  344. package/dist/testing/fixtures.js +1 -0
  345. package/dist/testing/fixtures.js.map +1 -1
  346. package/migrations/0037_drop_lists_consent_purpose_id.sql +2 -0
  347. package/migrations/0038_smart_white_queen.sql +2 -0
  348. package/migrations/0039_form_map_to_open.sql +1 -0
  349. package/migrations/0040_pipeline_converted_to.sql +20 -0
  350. package/migrations/0041_api_key_scopes.sql +1 -0
  351. package/migrations/0042_drop_workspace_identity.sql +2 -0
  352. package/migrations/meta/0038_snapshot.json +6554 -0
  353. package/migrations/meta/_journal.json +42 -0
  354. package/package.json +2 -2
  355. package/src/app.ts +3 -0
  356. package/src/index.ts +6 -0
  357. package/src/lib/actor.ts +3 -1
  358. package/src/lib/apiKeyScopes.ts +213 -0
  359. package/src/modules/activities/repository.ts +24 -0
  360. package/src/modules/agent-tasks/repository.ts +24 -0
  361. package/src/modules/api-keys/routes.ts +5 -0
  362. package/src/modules/api-keys/schema.ts +2 -0
  363. package/src/modules/api-keys/scopeMiddleware.ts +30 -0
  364. package/src/modules/api-keys/service.ts +36 -2
  365. package/src/modules/auth/credentials.ts +4 -0
  366. package/src/modules/consent-purposes/index.ts +1 -1
  367. package/src/modules/consent-purposes/schema.ts +3 -3
  368. package/src/modules/consent-purposes/service.ts +7 -16
  369. package/src/modules/consent-purposes/starters.ts +1 -1
  370. package/src/modules/consent-purposes/tools.ts +1 -1
  371. package/src/modules/conversions/clearPointers.ts +81 -0
  372. package/src/modules/conversions/factory.ts +20 -0
  373. package/src/modules/conversions/fieldMap.ts +548 -0
  374. package/src/modules/conversions/index.ts +6 -0
  375. package/src/modules/conversions/mcp.ts +71 -0
  376. package/src/modules/conversions/repoint.ts +146 -0
  377. package/src/modules/conversions/routes.ts +68 -0
  378. package/src/modules/conversions/service.ts +310 -0
  379. package/src/modules/conversions/wire.ts +42 -0
  380. package/src/modules/deals/events.ts +9 -0
  381. package/src/modules/deals/index.ts +4 -2
  382. package/src/modules/deals/routes.ts +11 -1
  383. package/src/modules/deals/schema.ts +10 -2
  384. package/src/modules/deals/service.ts +3 -0
  385. package/src/modules/deals/tools.ts +9 -1
  386. package/src/modules/decisions/repository.ts +23 -1
  387. package/src/modules/enquiries/events.ts +8 -2
  388. package/src/modules/enquiries/index.ts +4 -2
  389. package/src/modules/enquiries/routes.ts +11 -13
  390. package/src/modules/enquiries/schema.ts +12 -3
  391. package/src/modules/enquiries/service.ts +3 -150
  392. package/src/modules/enquiries/tools.ts +9 -18
  393. package/src/modules/forms/applyMappedFields.ts +248 -0
  394. package/src/modules/forms/applySubmissionFields.ts +435 -0
  395. package/src/modules/forms/fields.ts +31 -7
  396. package/src/modules/forms/mapping.ts +20 -3
  397. package/src/modules/forms/repository.ts +0 -7
  398. package/src/modules/forms/routes.ts +1 -2
  399. package/src/modules/forms/schema.ts +0 -2
  400. package/src/modules/forms/service.ts +31 -4
  401. package/src/modules/forms/starters.ts +129 -0
  402. package/src/modules/forms/submission.ts +135 -69
  403. package/src/modules/import-export/customFieldCsv.ts +55 -0
  404. package/src/modules/import-export/customFieldImport.ts +111 -0
  405. package/src/modules/import-export/drafts.ts +151 -3
  406. package/src/modules/import-export/exportRows.ts +222 -68
  407. package/src/modules/import-export/plan.ts +321 -67
  408. package/src/modules/import-export/repository.ts +356 -14
  409. package/src/modules/import-export/routes.ts +8 -8
  410. package/src/modules/import-export/service.ts +208 -45
  411. package/src/modules/import-export/streams.ts +95 -13
  412. package/src/modules/import-export/tools.ts +14 -6
  413. package/src/modules/import-export/validation.ts +128 -0
  414. package/src/modules/import-export/writes.ts +559 -27
  415. package/src/modules/lists/index.ts +71 -0
  416. package/src/modules/lists/repository.ts +34 -2
  417. package/src/modules/lists/routes.ts +0 -8
  418. package/src/modules/lists/schema.ts +0 -10
  419. package/src/modules/lists/service.ts +9 -107
  420. package/src/modules/lists/starters.ts +16 -0
  421. package/src/modules/mcp/protocol.ts +18 -0
  422. package/src/modules/notes/repository.ts +24 -0
  423. package/src/modules/opportunities/events.ts +9 -0
  424. package/src/modules/opportunities/index.ts +4 -2
  425. package/src/modules/opportunities/routes.ts +11 -1
  426. package/src/modules/opportunities/schema.ts +10 -2
  427. package/src/modules/opportunities/service.ts +3 -0
  428. package/src/modules/opportunities/tools.ts +9 -1
  429. package/src/modules/partnerships/events.ts +9 -0
  430. package/src/modules/partnerships/index.ts +4 -2
  431. package/src/modules/partnerships/routes.ts +11 -1
  432. package/src/modules/partnerships/schema.ts +10 -2
  433. package/src/modules/partnerships/service.ts +3 -0
  434. package/src/modules/partnerships/tools.ts +9 -1
  435. package/src/modules/people/personConsentWrites.ts +1 -1
  436. package/src/modules/people/schema.ts +1 -1
  437. package/src/modules/plans/repository.ts +24 -0
  438. package/src/modules/raises/events.ts +9 -0
  439. package/src/modules/raises/index.ts +4 -2
  440. package/src/modules/raises/routes.ts +11 -1
  441. package/src/modules/raises/schema.ts +10 -2
  442. package/src/modules/raises/service.ts +3 -0
  443. package/src/modules/raises/tools.ts +9 -1
  444. package/src/modules/workspace/routes.ts +0 -6
  445. package/src/modules/workspace/schema.ts +0 -2
  446. package/src/modules/workspace/seedStarterForms.ts +98 -0
  447. package/src/modules/workspace/service.ts +23 -15
  448. package/src/modules/workspace/tools.ts +1 -1
  449. package/src/testing/fixtures.ts +1 -0
@@ -1,22 +1,28 @@
1
- import { OBJECT_COLUMNS } from '@kelpie/schemas'
2
- import type { ImportObject } from '@kelpie/schemas'
1
+ import { OBJECT_COLUMNS, customFieldObjectTypeForExport } from '@kelpie/schemas'
2
+ import type { CsvColumn, CustomFieldValue, ExportObject } from '@kelpie/schemas'
3
3
 
4
+ import type { CustomFieldDefinitionRecord } from '../custom-fields/repository.ts'
5
+ import { customFieldCells, customFieldDefinitionCells, customFieldHeaderKeys } from './customFieldCsv.ts'
4
6
  import { centsToMoney } from './mapping.ts'
5
7
  import type {
6
8
  ExportCompanyRow,
7
9
  ExportDealRow,
10
+ ExportEnquiryRow,
11
+ ExportOpportunityRow,
12
+ ExportPartnershipRow,
8
13
  ExportPersonRow,
9
14
  ExportPositionRow,
15
+ ExportRaiseRow,
10
16
  } from './repository.ts'
11
17
 
12
18
  /**
13
- * Records as CSV cells, in the header order of `OBJECT_COLUMNS`.
19
+ * Records as CSV cells, in the header order of `OBJECT_COLUMNS` and
20
+ * `EXPORT_ONLY_COLUMNS`, plus workspace custom field keys when the object
21
+ * carries them.
14
22
  *
15
- * An export writes what an import reads: the stage is its **slug**, which a
16
- * rename leaves alone, and the deal value is the major unit rather than cents.
17
- * That is what makes a Kelpie CSV round-trip through the import wizard with the
18
- * `custom` source and no mapping at all — every header matches a column name
19
- * exactly.
23
+ * An export writes what an import reads where import exists: the stage is its
24
+ * **slug**, and money is the major unit rather than cents. Custom field values
25
+ * append as columns named by definition key.
20
26
  *
21
27
  * Pure.
22
28
  */
@@ -26,85 +32,233 @@ function joinList(values: readonly string[]): string {
26
32
  return values.join('|')
27
33
  }
28
34
 
35
+ function baseColumnsFor(object: ExportObject): readonly CsvColumn[] {
36
+ return OBJECT_COLUMNS[object]
37
+ }
38
+
29
39
  /**
30
40
  * The header row of an export and of a template.
31
41
  *
32
- * `importOnly` columns are left out: a People import may map `company_domain`,
33
- * `company_name`, `title`, `consent_status`, and `consent_at` to drive extra
34
- * writes, but none is a field on the person row. A template also leaves out
35
- * `exportOnly` columns (`do_not_contact`, `consents`), which the export writes
36
- * for readability but a caller round-trips through the per-purpose columns and
37
- * `consent_purpose_id` on the job.
42
+ * `importOnly` columns are left out. Custom field definition keys append in
43
+ * workspace sort order when the object type carries custom fields.
38
44
  */
39
- export function headersFor(object: ImportObject): readonly string[] {
40
- return OBJECT_COLUMNS[object]
45
+ export function headersFor(
46
+ object: ExportObject,
47
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
48
+ ): readonly string[] {
49
+ const base = baseColumnsFor(object)
41
50
  .filter((column) => column.importOnly !== true)
42
51
  .map((column) => column.key)
52
+
53
+ if (customFieldObjectTypeForExport(object) === null) {
54
+ return base
55
+ }
56
+
57
+ return [...base, ...customFieldHeaderKeys(definitions)]
43
58
  }
44
59
 
45
60
  /** The template's headers — the round-trippable ones for a caller to fill in. */
46
- export function templateHeadersFor(object: ImportObject): readonly string[] {
47
- return OBJECT_COLUMNS[object]
61
+ export function templateHeadersFor(
62
+ object: ExportObject,
63
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
64
+ ): readonly string[] {
65
+ const base = baseColumnsFor(object)
48
66
  .filter((column) => column.importOnly !== true && column.exportOnly !== true)
49
67
  .map((column) => column.key)
68
+
69
+ if (customFieldObjectTypeForExport(object) === null) {
70
+ return base
71
+ }
72
+
73
+ return [...base, ...customFieldHeaderKeys(definitions)]
74
+ }
75
+
76
+ function withCustomFields(
77
+ base: readonly string[],
78
+ customFields: Readonly<Record<string, CustomFieldValue>> | undefined,
79
+ definitions: readonly CustomFieldDefinitionRecord[],
80
+ ): readonly string[] {
81
+ if (definitions.length === 0) {
82
+ return base
83
+ }
84
+
85
+ return [...base, ...customFieldCells(customFields, customFieldHeaderKeys(definitions))]
50
86
  }
51
87
 
52
- export function companyCells(row: ExportCompanyRow): readonly string[] {
53
- return [
54
- row.name,
55
- row.domain ?? '',
56
- row.industry ?? '',
57
- row.stage,
58
- row.sizeBand,
59
- row.accountType,
60
- row.icpFit,
61
- row.description,
62
- row.summary,
63
- joinList(row.tags),
64
- row.website ?? '',
65
- row.hq ?? '',
66
- ]
88
+ export function companyCells(
89
+ row: ExportCompanyRow,
90
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
91
+ ): readonly string[] {
92
+ return withCustomFields(
93
+ [
94
+ row.name,
95
+ row.domain ?? '',
96
+ row.industry ?? '',
97
+ row.stage,
98
+ row.sizeBand,
99
+ row.accountType,
100
+ row.icpFit,
101
+ row.description,
102
+ row.summary,
103
+ joinList(row.tags),
104
+ row.website ?? '',
105
+ row.hq ?? '',
106
+ ],
107
+ row.customFields,
108
+ definitions,
109
+ )
67
110
  }
68
111
 
69
- export function personCells(row: ExportPersonRow): readonly string[] {
70
- return [
71
- row.name,
72
- row.salutation ?? '',
73
- row.firstName ?? '',
74
- row.lastName ?? '',
75
- row.suffix ?? '',
76
- row.email ?? '',
77
- row.timezone ?? '',
78
- row.location ?? '',
79
- row.preferredChannel,
80
- row.influence,
81
- row.relationship,
82
- row.summary,
83
- joinList(row.tags),
84
- joinList(row.phones),
85
- row.doNotContact ? 'true' : 'false',
86
- row.consents,
87
- ]
112
+ export function personCells(
113
+ row: ExportPersonRow,
114
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
115
+ ): readonly string[] {
116
+ return withCustomFields(
117
+ [
118
+ row.name,
119
+ row.salutation ?? '',
120
+ row.firstName ?? '',
121
+ row.lastName ?? '',
122
+ row.suffix ?? '',
123
+ row.email ?? '',
124
+ row.timezone ?? '',
125
+ row.location ?? '',
126
+ row.preferredChannel,
127
+ row.influence,
128
+ row.relationship,
129
+ row.summary,
130
+ joinList(row.tags),
131
+ joinList(row.phones),
132
+ row.doNotContact ? 'true' : 'false',
133
+ row.consents,
134
+ ],
135
+ row.customFields,
136
+ definitions,
137
+ )
88
138
  }
89
139
 
90
140
  export function positionCells(row: ExportPositionRow): readonly string[] {
91
141
  return [row.personEmail ?? '', row.companyDomain ?? '', row.title]
92
142
  }
93
143
 
94
- export function dealCells(row: ExportDealRow, personEmails: readonly string[]): readonly string[] {
95
- return [
96
- row.name,
97
- row.companyDomain ?? '',
98
- row.stageSlug,
99
- centsToMoney(row.valueCents),
100
- row.ownerEmail ?? '',
101
- row.expectedClose ?? '',
102
- joinList(personEmails),
103
- joinList(row.competitors),
104
- row.risks,
105
- row.whyWin,
106
- row.summary,
107
- joinList(row.tags),
108
- row.externalId ?? '',
109
- ]
144
+ export function dealCells(
145
+ row: ExportDealRow,
146
+ personEmails: readonly string[],
147
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
148
+ ): readonly string[] {
149
+ return withCustomFields(
150
+ [
151
+ row.name,
152
+ row.companyDomain ?? '',
153
+ row.stageSlug,
154
+ centsToMoney(row.valueCents),
155
+ row.ownerEmail ?? '',
156
+ row.expectedClose ?? '',
157
+ joinList(personEmails),
158
+ joinList(row.competitors),
159
+ row.risks,
160
+ row.whyWin,
161
+ row.summary,
162
+ joinList(row.tags),
163
+ row.externalId ?? '',
164
+ ],
165
+ row.customFields,
166
+ definitions,
167
+ )
168
+ }
169
+
170
+ export function opportunityCells(
171
+ row: ExportOpportunityRow,
172
+ personEmails: readonly string[],
173
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
174
+ ): readonly string[] {
175
+ return withCustomFields(
176
+ [
177
+ row.name,
178
+ row.kind,
179
+ row.companyDomain ?? '',
180
+ row.stageSlug,
181
+ row.ownerEmail ?? '',
182
+ row.expectedClose ?? '',
183
+ joinList(personEmails),
184
+ row.summary,
185
+ joinList(row.tags),
186
+ ],
187
+ row.customFields,
188
+ definitions,
189
+ )
190
+ }
191
+
192
+ export function enquiryCells(
193
+ row: ExportEnquiryRow,
194
+ personEmails: readonly string[],
195
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
196
+ ): readonly string[] {
197
+ return withCustomFields(
198
+ [
199
+ row.name,
200
+ row.source,
201
+ row.companyDomain ?? '',
202
+ row.stageSlug,
203
+ row.ownerEmail ?? '',
204
+ joinList(personEmails),
205
+ row.summary,
206
+ joinList(row.tags),
207
+ ],
208
+ row.customFields,
209
+ definitions,
210
+ )
211
+ }
212
+
213
+ export function partnershipCells(
214
+ row: ExportPartnershipRow,
215
+ personEmails: readonly string[],
216
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
217
+ ): readonly string[] {
218
+ return withCustomFields(
219
+ [
220
+ row.name,
221
+ row.companyDomain ?? '',
222
+ row.stageSlug,
223
+ row.kind,
224
+ row.nextTouchpoint ?? '',
225
+ row.ownerEmail ?? '',
226
+ row.goals,
227
+ row.successLooksLike,
228
+ joinList(personEmails),
229
+ row.summary,
230
+ joinList(row.tags),
231
+ ],
232
+ row.customFields,
233
+ definitions,
234
+ )
235
+ }
236
+
237
+ export function raiseCells(
238
+ row: ExportRaiseRow,
239
+ personEmails: readonly string[],
240
+ definitions: readonly CustomFieldDefinitionRecord[] = [],
241
+ ): readonly string[] {
242
+ return withCustomFields(
243
+ [
244
+ row.name,
245
+ row.companyDomain ?? '',
246
+ row.stageSlug,
247
+ row.checkSizeCents === null ? '' : centsToMoney(row.checkSizeCents),
248
+ row.currency ?? '',
249
+ row.thesisFit,
250
+ row.passReason ?? '',
251
+ row.ownerEmail ?? '',
252
+ row.expectedClose ?? '',
253
+ joinList(personEmails),
254
+ row.summary,
255
+ joinList(row.tags),
256
+ ],
257
+ row.customFields,
258
+ definitions,
259
+ )
260
+ }
261
+
262
+ export function customFieldDefinitionRowCells(row: CustomFieldDefinitionRecord): readonly string[] {
263
+ return customFieldDefinitionCells(row)
110
264
  }