attio-mcp 0.1.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 (644) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/LICENSE +236 -0
  3. package/README.md +105 -0
  4. package/dist/api/attio-client.d.ts +25 -0
  5. package/dist/api/attio-client.d.ts.map +1 -0
  6. package/dist/api/attio-client.js +64 -0
  7. package/dist/api/attio-client.js.map +1 -0
  8. package/dist/api/attribute-types.d.ts +119 -0
  9. package/dist/api/attribute-types.d.ts.map +1 -0
  10. package/dist/api/attribute-types.js +320 -0
  11. package/dist/api/attribute-types.js.map +1 -0
  12. package/dist/api/client.d.ts +3 -0
  13. package/dist/api/client.d.ts.map +1 -0
  14. package/dist/api/client.js +61 -0
  15. package/dist/api/client.js.map +1 -0
  16. package/dist/api/operations/batch.d.ts +55 -0
  17. package/dist/api/operations/batch.d.ts.map +1 -0
  18. package/dist/api/operations/batch.js +176 -0
  19. package/dist/api/operations/batch.js.map +1 -0
  20. package/dist/api/operations/crud.d.ts +61 -0
  21. package/dist/api/operations/crud.d.ts.map +1 -0
  22. package/dist/api/operations/crud.js +192 -0
  23. package/dist/api/operations/crud.js.map +1 -0
  24. package/dist/api/operations/index.d.ts +14 -0
  25. package/dist/api/operations/index.d.ts.map +1 -0
  26. package/dist/api/operations/index.js +18 -0
  27. package/dist/api/operations/index.js.map +1 -0
  28. package/dist/api/operations/lists.d.ts +66 -0
  29. package/dist/api/operations/lists.d.ts.map +1 -0
  30. package/dist/api/operations/lists.js +300 -0
  31. package/dist/api/operations/lists.js.map +1 -0
  32. package/dist/api/operations/notes.d.ts +29 -0
  33. package/dist/api/operations/notes.d.ts.map +1 -0
  34. package/dist/api/operations/notes.js +63 -0
  35. package/dist/api/operations/notes.js.map +1 -0
  36. package/dist/api/operations/retry.d.ts +48 -0
  37. package/dist/api/operations/retry.d.ts.map +1 -0
  38. package/dist/api/operations/retry.js +98 -0
  39. package/dist/api/operations/retry.js.map +1 -0
  40. package/dist/api/operations/search.d.ts +37 -0
  41. package/dist/api/operations/search.d.ts.map +1 -0
  42. package/dist/api/operations/search.js +186 -0
  43. package/dist/api/operations/search.js.map +1 -0
  44. package/dist/api/operations/tasks.d.ts +20 -0
  45. package/dist/api/operations/tasks.d.ts.map +1 -0
  46. package/dist/api/operations/tasks.js +87 -0
  47. package/dist/api/operations/tasks.js.map +1 -0
  48. package/dist/api/operations/types.d.ts +61 -0
  49. package/dist/api/operations/types.d.ts.map +1 -0
  50. package/dist/api/operations/types.js +10 -0
  51. package/dist/api/operations/types.js.map +1 -0
  52. package/dist/cli/commands/attributes.d.ts +34 -0
  53. package/dist/cli/commands/attributes.d.ts.map +1 -0
  54. package/dist/cli/commands/attributes.js +171 -0
  55. package/dist/cli/commands/attributes.js.map +1 -0
  56. package/dist/cli/discover.d.ts +3 -0
  57. package/dist/cli/discover.d.ts.map +1 -0
  58. package/dist/cli/discover.js +72 -0
  59. package/dist/cli/discover.js.map +1 -0
  60. package/dist/errors/api-errors.d.ts +191 -0
  61. package/dist/errors/api-errors.d.ts.map +1 -0
  62. package/dist/errors/api-errors.js +305 -0
  63. package/dist/errors/api-errors.js.map +1 -0
  64. package/dist/errors/company-errors.d.ts +40 -0
  65. package/dist/errors/company-errors.d.ts.map +1 -0
  66. package/dist/errors/company-errors.js +62 -0
  67. package/dist/errors/company-errors.js.map +1 -0
  68. package/dist/errors/value-match-error.d.ts +15 -0
  69. package/dist/errors/value-match-error.d.ts.map +1 -0
  70. package/dist/errors/value-match-error.js +40 -0
  71. package/dist/errors/value-match-error.js.map +1 -0
  72. package/dist/handlers/error-interceptor.d.ts +6 -0
  73. package/dist/handlers/error-interceptor.d.ts.map +1 -0
  74. package/dist/handlers/error-interceptor.js +17 -0
  75. package/dist/handlers/error-interceptor.js.map +1 -0
  76. package/dist/handlers/rate-limited-handler.d.ts +17 -0
  77. package/dist/handlers/rate-limited-handler.d.ts.map +1 -0
  78. package/dist/handlers/rate-limited-handler.js +126 -0
  79. package/dist/handlers/rate-limited-handler.js.map +1 -0
  80. package/dist/handlers/resources.d.ts +11 -0
  81. package/dist/handlers/resources.d.ts.map +1 -0
  82. package/dist/handlers/resources.js +109 -0
  83. package/dist/handlers/resources.js.map +1 -0
  84. package/dist/handlers/tool-configs/companies/attributes.d.ts +85 -0
  85. package/dist/handlers/tool-configs/companies/attributes.d.ts.map +1 -0
  86. package/dist/handlers/tool-configs/companies/attributes.js +203 -0
  87. package/dist/handlers/tool-configs/companies/attributes.js.map +1 -0
  88. package/dist/handlers/tool-configs/companies/batch.d.ts +145 -0
  89. package/dist/handlers/tool-configs/companies/batch.d.ts.map +1 -0
  90. package/dist/handlers/tool-configs/companies/batch.js +249 -0
  91. package/dist/handlers/tool-configs/companies/batch.js.map +1 -0
  92. package/dist/handlers/tool-configs/companies/crud.d.ts +103 -0
  93. package/dist/handlers/tool-configs/companies/crud.d.ts.map +1 -0
  94. package/dist/handlers/tool-configs/companies/crud.js +157 -0
  95. package/dist/handlers/tool-configs/companies/crud.js.map +1 -0
  96. package/dist/handlers/tool-configs/companies/definitions.d.ts +5 -0
  97. package/dist/handlers/tool-configs/companies/definitions.d.ts.map +1 -0
  98. package/dist/handlers/tool-configs/companies/definitions.js +9 -0
  99. package/dist/handlers/tool-configs/companies/definitions.js.map +1 -0
  100. package/dist/handlers/tool-configs/companies/formatters.d.ts +42 -0
  101. package/dist/handlers/tool-configs/companies/formatters.d.ts.map +1 -0
  102. package/dist/handlers/tool-configs/companies/formatters.js +324 -0
  103. package/dist/handlers/tool-configs/companies/formatters.js.map +1 -0
  104. package/dist/handlers/tool-configs/companies/index.d.ts +642 -0
  105. package/dist/handlers/tool-configs/companies/index.d.ts.map +1 -0
  106. package/dist/handlers/tool-configs/companies/index.js +86 -0
  107. package/dist/handlers/tool-configs/companies/index.js.map +1 -0
  108. package/dist/handlers/tool-configs/companies/notes.d.ts +61 -0
  109. package/dist/handlers/tool-configs/companies/notes.d.ts.map +1 -0
  110. package/dist/handlers/tool-configs/companies/notes.js +109 -0
  111. package/dist/handlers/tool-configs/companies/notes.js.map +1 -0
  112. package/dist/handlers/tool-configs/companies/relationships.d.ts +137 -0
  113. package/dist/handlers/tool-configs/companies/relationships.d.ts.map +1 -0
  114. package/dist/handlers/tool-configs/companies/relationships.js +163 -0
  115. package/dist/handlers/tool-configs/companies/relationships.js.map +1 -0
  116. package/dist/handlers/tool-configs/companies/search.d.ts +101 -0
  117. package/dist/handlers/tool-configs/companies/search.d.ts.map +1 -0
  118. package/dist/handlers/tool-configs/companies/search.js +163 -0
  119. package/dist/handlers/tool-configs/companies/search.js.map +1 -0
  120. package/dist/handlers/tool-configs/companies/types.d.ts +6 -0
  121. package/dist/handlers/tool-configs/companies/types.d.ts.map +1 -0
  122. package/dist/handlers/tool-configs/companies/types.js +2 -0
  123. package/dist/handlers/tool-configs/companies/types.js.map +1 -0
  124. package/dist/handlers/tool-configs/index.d.ts +12 -0
  125. package/dist/handlers/tool-configs/index.d.ts.map +1 -0
  126. package/dist/handlers/tool-configs/index.js +12 -0
  127. package/dist/handlers/tool-configs/index.js.map +1 -0
  128. package/dist/handlers/tool-configs/lists.d.ts +459 -0
  129. package/dist/handlers/tool-configs/lists.d.ts.map +1 -0
  130. package/dist/handlers/tool-configs/lists.js +597 -0
  131. package/dist/handlers/tool-configs/lists.js.map +1 -0
  132. package/dist/handlers/tool-configs/paginated-people.d.ts +197 -0
  133. package/dist/handlers/tool-configs/paginated-people.d.ts.map +1 -0
  134. package/dist/handlers/tool-configs/paginated-people.js +256 -0
  135. package/dist/handlers/tool-configs/paginated-people.js.map +1 -0
  136. package/dist/handlers/tool-configs/people/activity-search.d.ts +98 -0
  137. package/dist/handlers/tool-configs/people/activity-search.d.ts.map +1 -0
  138. package/dist/handlers/tool-configs/people/activity-search.js +113 -0
  139. package/dist/handlers/tool-configs/people/activity-search.js.map +1 -0
  140. package/dist/handlers/tool-configs/people/advanced-search.d.ts +62 -0
  141. package/dist/handlers/tool-configs/people/advanced-search.d.ts.map +1 -0
  142. package/dist/handlers/tool-configs/people/advanced-search.js +74 -0
  143. package/dist/handlers/tool-configs/people/advanced-search.js.map +1 -0
  144. package/dist/handlers/tool-configs/people/crud.d.ts +63 -0
  145. package/dist/handlers/tool-configs/people/crud.d.ts.map +1 -0
  146. package/dist/handlers/tool-configs/people/crud.js +71 -0
  147. package/dist/handlers/tool-configs/people/crud.js.map +1 -0
  148. package/dist/handlers/tool-configs/people/date-search.d.ts +42 -0
  149. package/dist/handlers/tool-configs/people/date-search.d.ts.map +1 -0
  150. package/dist/handlers/tool-configs/people/date-search.js +93 -0
  151. package/dist/handlers/tool-configs/people/date-search.js.map +1 -0
  152. package/dist/handlers/tool-configs/people/formatters.d.ts +19 -0
  153. package/dist/handlers/tool-configs/people/formatters.d.ts.map +1 -0
  154. package/dist/handlers/tool-configs/people/formatters.js +98 -0
  155. package/dist/handlers/tool-configs/people/formatters.js.map +1 -0
  156. package/dist/handlers/tool-configs/people/index.d.ts +407 -0
  157. package/dist/handlers/tool-configs/people/index.d.ts.map +1 -0
  158. package/dist/handlers/tool-configs/people/index.js +30 -0
  159. package/dist/handlers/tool-configs/people/index.js.map +1 -0
  160. package/dist/handlers/tool-configs/people/notes.d.ts +38 -0
  161. package/dist/handlers/tool-configs/people/notes.d.ts.map +1 -0
  162. package/dist/handlers/tool-configs/people/notes.js +57 -0
  163. package/dist/handlers/tool-configs/people/notes.js.map +1 -0
  164. package/dist/handlers/tool-configs/people/relationships.d.ts +112 -0
  165. package/dist/handlers/tool-configs/people/relationships.d.ts.map +1 -0
  166. package/dist/handlers/tool-configs/people/relationships.js +173 -0
  167. package/dist/handlers/tool-configs/people/relationships.js.map +1 -0
  168. package/dist/handlers/tool-configs/people/search.d.ts +53 -0
  169. package/dist/handlers/tool-configs/people/search.d.ts.map +1 -0
  170. package/dist/handlers/tool-configs/people/search.js +61 -0
  171. package/dist/handlers/tool-configs/people/search.js.map +1 -0
  172. package/dist/handlers/tool-configs/people-fix-complete.d.ts +6 -0
  173. package/dist/handlers/tool-configs/people-fix-complete.d.ts.map +1 -0
  174. package/dist/handlers/tool-configs/people-fix-complete.js +76 -0
  175. package/dist/handlers/tool-configs/people-fix-complete.js.map +1 -0
  176. package/dist/handlers/tool-configs/people-fixed.d.ts +12 -0
  177. package/dist/handlers/tool-configs/people-fixed.d.ts.map +1 -0
  178. package/dist/handlers/tool-configs/people-fixed.js +58 -0
  179. package/dist/handlers/tool-configs/people-fixed.js.map +1 -0
  180. package/dist/handlers/tool-configs/people-types.d.ts +32 -0
  181. package/dist/handlers/tool-configs/people-types.d.ts.map +1 -0
  182. package/dist/handlers/tool-configs/people-types.js +5 -0
  183. package/dist/handlers/tool-configs/people-types.js.map +1 -0
  184. package/dist/handlers/tool-configs/people.d.ts +599 -0
  185. package/dist/handlers/tool-configs/people.d.ts.map +1 -0
  186. package/dist/handlers/tool-configs/people.js +817 -0
  187. package/dist/handlers/tool-configs/people.js.map +1 -0
  188. package/dist/handlers/tool-configs/prompts.d.ts +69 -0
  189. package/dist/handlers/tool-configs/prompts.d.ts.map +1 -0
  190. package/dist/handlers/tool-configs/prompts.js +90 -0
  191. package/dist/handlers/tool-configs/prompts.js.map +1 -0
  192. package/dist/handlers/tool-configs/rate-limited-people.d.ts +203 -0
  193. package/dist/handlers/tool-configs/rate-limited-people.d.ts.map +1 -0
  194. package/dist/handlers/tool-configs/rate-limited-people.js +44 -0
  195. package/dist/handlers/tool-configs/rate-limited-people.js.map +1 -0
  196. package/dist/handlers/tool-configs/records/index.d.ts +282 -0
  197. package/dist/handlers/tool-configs/records/index.d.ts.map +1 -0
  198. package/dist/handlers/tool-configs/records/index.js +277 -0
  199. package/dist/handlers/tool-configs/records/index.js.map +1 -0
  200. package/dist/handlers/tool-configs/records.d.ts +282 -0
  201. package/dist/handlers/tool-configs/records.d.ts.map +1 -0
  202. package/dist/handlers/tool-configs/records.js +277 -0
  203. package/dist/handlers/tool-configs/records.js.map +1 -0
  204. package/dist/handlers/tool-configs/resource-specific-tools.d.ts +15 -0
  205. package/dist/handlers/tool-configs/resource-specific-tools.d.ts.map +1 -0
  206. package/dist/handlers/tool-configs/resource-specific-tools.js +33 -0
  207. package/dist/handlers/tool-configs/resource-specific-tools.js.map +1 -0
  208. package/dist/handlers/tool-configs/tasks.d.ts +127 -0
  209. package/dist/handlers/tool-configs/tasks.d.ts.map +1 -0
  210. package/dist/handlers/tool-configs/tasks.js +95 -0
  211. package/dist/handlers/tool-configs/tasks.js.map +1 -0
  212. package/dist/handlers/tool-types.d.ts +47 -0
  213. package/dist/handlers/tool-types.d.ts.map +1 -0
  214. package/dist/handlers/tool-types.js +2 -0
  215. package/dist/handlers/tool-types.js.map +1 -0
  216. package/dist/handlers/tools/config-verifier.d.ts +27 -0
  217. package/dist/handlers/tools/config-verifier.d.ts.map +1 -0
  218. package/dist/handlers/tools/config-verifier.js +108 -0
  219. package/dist/handlers/tools/config-verifier.js.map +1 -0
  220. package/dist/handlers/tools/dispatcher/core.d.ts +12 -0
  221. package/dist/handlers/tools/dispatcher/core.d.ts.map +1 -0
  222. package/dist/handlers/tools/dispatcher/core.js +276 -0
  223. package/dist/handlers/tools/dispatcher/core.js.map +1 -0
  224. package/dist/handlers/tools/dispatcher/formatting.d.ts +17 -0
  225. package/dist/handlers/tools/dispatcher/formatting.d.ts.map +1 -0
  226. package/dist/handlers/tools/dispatcher/formatting.js +25 -0
  227. package/dist/handlers/tools/dispatcher/formatting.js.map +1 -0
  228. package/dist/handlers/tools/dispatcher/logging.d.ts +63 -0
  229. package/dist/handlers/tools/dispatcher/logging.d.ts.map +1 -0
  230. package/dist/handlers/tools/dispatcher/logging.js +108 -0
  231. package/dist/handlers/tools/dispatcher/logging.js.map +1 -0
  232. package/dist/handlers/tools/dispatcher/operations/batch.d.ts +29 -0
  233. package/dist/handlers/tools/dispatcher/operations/batch.d.ts.map +1 -0
  234. package/dist/handlers/tools/dispatcher/operations/batch.js +137 -0
  235. package/dist/handlers/tools/dispatcher/operations/batch.js.map +1 -0
  236. package/dist/handlers/tools/dispatcher/operations/crud.d.ts +25 -0
  237. package/dist/handlers/tools/dispatcher/operations/crud.d.ts.map +1 -0
  238. package/dist/handlers/tools/dispatcher/operations/crud.js +110 -0
  239. package/dist/handlers/tools/dispatcher/operations/crud.js.map +1 -0
  240. package/dist/handlers/tools/dispatcher/operations/details.d.ts +13 -0
  241. package/dist/handlers/tools/dispatcher/operations/details.d.ts.map +1 -0
  242. package/dist/handlers/tools/dispatcher/operations/details.js +52 -0
  243. package/dist/handlers/tools/dispatcher/operations/details.js.map +1 -0
  244. package/dist/handlers/tools/dispatcher/operations/info.d.ts +25 -0
  245. package/dist/handlers/tools/dispatcher/operations/info.d.ts.map +1 -0
  246. package/dist/handlers/tools/dispatcher/operations/info.js +82 -0
  247. package/dist/handlers/tools/dispatcher/operations/info.js.map +1 -0
  248. package/dist/handlers/tools/dispatcher/operations/lists.d.ts +62 -0
  249. package/dist/handlers/tools/dispatcher/operations/lists.d.ts.map +1 -0
  250. package/dist/handlers/tools/dispatcher/operations/lists.js +283 -0
  251. package/dist/handlers/tools/dispatcher/operations/lists.js.map +1 -0
  252. package/dist/handlers/tools/dispatcher/operations/notes.d.ts +17 -0
  253. package/dist/handlers/tools/dispatcher/operations/notes.d.ts.map +1 -0
  254. package/dist/handlers/tools/dispatcher/operations/notes.js +102 -0
  255. package/dist/handlers/tools/dispatcher/operations/notes.js.map +1 -0
  256. package/dist/handlers/tools/dispatcher/operations/search.d.ts +43 -0
  257. package/dist/handlers/tools/dispatcher/operations/search.d.ts.map +1 -0
  258. package/dist/handlers/tools/dispatcher/operations/search.js +190 -0
  259. package/dist/handlers/tools/dispatcher/operations/search.js.map +1 -0
  260. package/dist/handlers/tools/dispatcher/validation.d.ts +27 -0
  261. package/dist/handlers/tools/dispatcher/validation.d.ts.map +1 -0
  262. package/dist/handlers/tools/dispatcher/validation.js +47 -0
  263. package/dist/handlers/tools/dispatcher/validation.js.map +1 -0
  264. package/dist/handlers/tools/dispatcher.d.ts +11 -0
  265. package/dist/handlers/tools/dispatcher.d.ts.map +1 -0
  266. package/dist/handlers/tools/dispatcher.js +15 -0
  267. package/dist/handlers/tools/dispatcher.js.map +1 -0
  268. package/dist/handlers/tools/error-types.d.ts +33 -0
  269. package/dist/handlers/tools/error-types.d.ts.map +1 -0
  270. package/dist/handlers/tools/error-types.js +21 -0
  271. package/dist/handlers/tools/error-types.js.map +1 -0
  272. package/dist/handlers/tools/formatters.d.ts +43 -0
  273. package/dist/handlers/tools/formatters.d.ts.map +1 -0
  274. package/dist/handlers/tools/formatters.js +170 -0
  275. package/dist/handlers/tools/formatters.js.map +1 -0
  276. package/dist/handlers/tools/index.d.ts +15 -0
  277. package/dist/handlers/tools/index.d.ts.map +1 -0
  278. package/dist/handlers/tools/index.js +34 -0
  279. package/dist/handlers/tools/index.js.map +1 -0
  280. package/dist/handlers/tools/registry.d.ts +1874 -0
  281. package/dist/handlers/tools/registry.d.ts.map +1 -0
  282. package/dist/handlers/tools/registry.js +103 -0
  283. package/dist/handlers/tools/registry.js.map +1 -0
  284. package/dist/health/http-server.d.ts +24 -0
  285. package/dist/health/http-server.d.ts.map +1 -0
  286. package/dist/health/http-server.js +106 -0
  287. package/dist/health/http-server.js.map +1 -0
  288. package/dist/index.d.ts +3 -0
  289. package/dist/index.d.ts.map +1 -0
  290. package/dist/index.js +238 -0
  291. package/dist/index.js.map +1 -0
  292. package/dist/objects/base-operations.d.ts +41 -0
  293. package/dist/objects/base-operations.d.ts.map +1 -0
  294. package/dist/objects/base-operations.js +116 -0
  295. package/dist/objects/base-operations.js.map +1 -0
  296. package/dist/objects/batch-companies.d.ts +112 -0
  297. package/dist/objects/batch-companies.d.ts.map +1 -0
  298. package/dist/objects/batch-companies.js +347 -0
  299. package/dist/objects/batch-companies.js.map +1 -0
  300. package/dist/objects/companies/attributes.d.ts +83 -0
  301. package/dist/objects/companies/attributes.d.ts.map +1 -0
  302. package/dist/objects/companies/attributes.js +426 -0
  303. package/dist/objects/companies/attributes.js.map +1 -0
  304. package/dist/objects/companies/basic.d.ts +117 -0
  305. package/dist/objects/companies/basic.d.ts.map +1 -0
  306. package/dist/objects/companies/basic.js +367 -0
  307. package/dist/objects/companies/basic.js.map +1 -0
  308. package/dist/objects/companies/batch.d.ts +6 -0
  309. package/dist/objects/companies/batch.d.ts.map +1 -0
  310. package/dist/objects/companies/batch.js +6 -0
  311. package/dist/objects/companies/batch.js.map +1 -0
  312. package/dist/objects/companies/index.d.ts +13 -0
  313. package/dist/objects/companies/index.d.ts.map +1 -0
  314. package/dist/objects/companies/index.js +17 -0
  315. package/dist/objects/companies/index.js.map +1 -0
  316. package/dist/objects/companies/notes.d.ts +26 -0
  317. package/dist/objects/companies/notes.d.ts.map +1 -0
  318. package/dist/objects/companies/notes.js +199 -0
  319. package/dist/objects/companies/notes.js.map +1 -0
  320. package/dist/objects/companies/relationships.d.ts +41 -0
  321. package/dist/objects/companies/relationships.d.ts.map +1 -0
  322. package/dist/objects/companies/relationships.js +142 -0
  323. package/dist/objects/companies/relationships.js.map +1 -0
  324. package/dist/objects/companies/search.d.ts +158 -0
  325. package/dist/objects/companies/search.d.ts.map +1 -0
  326. package/dist/objects/companies/search.js +463 -0
  327. package/dist/objects/companies/search.js.map +1 -0
  328. package/dist/objects/companies/types.d.ts +27 -0
  329. package/dist/objects/companies/types.d.ts.map +1 -0
  330. package/dist/objects/companies/types.js +3 -0
  331. package/dist/objects/companies/types.js.map +1 -0
  332. package/dist/objects/lists.d.ts +148 -0
  333. package/dist/objects/lists.d.ts.map +1 -0
  334. package/dist/objects/lists.js +586 -0
  335. package/dist/objects/lists.js.map +1 -0
  336. package/dist/objects/paginated-people.d.ts +50 -0
  337. package/dist/objects/paginated-people.d.ts.map +1 -0
  338. package/dist/objects/paginated-people.js +171 -0
  339. package/dist/objects/paginated-people.js.map +1 -0
  340. package/dist/objects/people/basic.d.ts +90 -0
  341. package/dist/objects/people/basic.d.ts.map +1 -0
  342. package/dist/objects/people/basic.js +157 -0
  343. package/dist/objects/people/basic.js.map +1 -0
  344. package/dist/objects/people/batch.d.ts +24 -0
  345. package/dist/objects/people/batch.d.ts.map +1 -0
  346. package/dist/objects/people/batch.js +145 -0
  347. package/dist/objects/people/batch.js.map +1 -0
  348. package/dist/objects/people/index.d.ts +11 -0
  349. package/dist/objects/people/index.d.ts.map +1 -0
  350. package/dist/objects/people/index.js +17 -0
  351. package/dist/objects/people/index.js.map +1 -0
  352. package/dist/objects/people/notes.d.ts +20 -0
  353. package/dist/objects/people/notes.d.ts.map +1 -0
  354. package/dist/objects/people/notes.js +60 -0
  355. package/dist/objects/people/notes.js.map +1 -0
  356. package/dist/objects/people/relationships.d.ts +23 -0
  357. package/dist/objects/people/relationships.d.ts.map +1 -0
  358. package/dist/objects/people/relationships.js +116 -0
  359. package/dist/objects/people/relationships.js.map +1 -0
  360. package/dist/objects/people/search.d.ts +83 -0
  361. package/dist/objects/people/search.d.ts.map +1 -0
  362. package/dist/objects/people/search.js +286 -0
  363. package/dist/objects/people/search.js.map +1 -0
  364. package/dist/objects/people/types.d.ts +37 -0
  365. package/dist/objects/people/types.d.ts.map +1 -0
  366. package/dist/objects/people/types.js +71 -0
  367. package/dist/objects/people/types.js.map +1 -0
  368. package/dist/objects/people-write.d.ts +71 -0
  369. package/dist/objects/people-write.d.ts.map +1 -0
  370. package/dist/objects/people-write.js +261 -0
  371. package/dist/objects/people-write.js.map +1 -0
  372. package/dist/objects/records/formatters.d.ts +20 -0
  373. package/dist/objects/records/formatters.d.ts.map +1 -0
  374. package/dist/objects/records/formatters.js +47 -0
  375. package/dist/objects/records/formatters.js.map +1 -0
  376. package/dist/objects/records/index.d.ts +74 -0
  377. package/dist/objects/records/index.d.ts.map +1 -0
  378. package/dist/objects/records/index.js +374 -0
  379. package/dist/objects/records/index.js.map +1 -0
  380. package/dist/objects/records.d.ts +88 -0
  381. package/dist/objects/records.d.ts.map +1 -0
  382. package/dist/objects/records.js +432 -0
  383. package/dist/objects/records.js.map +1 -0
  384. package/dist/objects/tasks.d.ts +19 -0
  385. package/dist/objects/tasks.d.ts.map +1 -0
  386. package/dist/objects/tasks.js +23 -0
  387. package/dist/objects/tasks.js.map +1 -0
  388. package/dist/prompts/error-handler.d.ts +28 -0
  389. package/dist/prompts/error-handler.d.ts.map +1 -0
  390. package/dist/prompts/error-handler.js +47 -0
  391. package/dist/prompts/error-handler.js.map +1 -0
  392. package/dist/prompts/handlers.d.ts +49 -0
  393. package/dist/prompts/handlers.d.ts.map +1 -0
  394. package/dist/prompts/handlers.js +353 -0
  395. package/dist/prompts/handlers.js.map +1 -0
  396. package/dist/prompts/index.d.ts +11 -0
  397. package/dist/prompts/index.d.ts.map +1 -0
  398. package/dist/prompts/index.js +15 -0
  399. package/dist/prompts/index.js.map +1 -0
  400. package/dist/prompts/templates/companies.d.ts +10 -0
  401. package/dist/prompts/templates/companies.d.ts.map +1 -0
  402. package/dist/prompts/templates/companies.js +128 -0
  403. package/dist/prompts/templates/companies.js.map +1 -0
  404. package/dist/prompts/templates/index.d.ts +42 -0
  405. package/dist/prompts/templates/index.d.ts.map +1 -0
  406. package/dist/prompts/templates/index.js +58 -0
  407. package/dist/prompts/templates/index.js.map +1 -0
  408. package/dist/prompts/templates/lists.d.ts +10 -0
  409. package/dist/prompts/templates/lists.d.ts.map +1 -0
  410. package/dist/prompts/templates/lists.js +127 -0
  411. package/dist/prompts/templates/lists.js.map +1 -0
  412. package/dist/prompts/templates/notes.d.ts +10 -0
  413. package/dist/prompts/templates/notes.d.ts.map +1 -0
  414. package/dist/prompts/templates/notes.js +119 -0
  415. package/dist/prompts/templates/notes.js.map +1 -0
  416. package/dist/prompts/templates/people.d.ts +10 -0
  417. package/dist/prompts/templates/people.d.ts.map +1 -0
  418. package/dist/prompts/templates/people.js +127 -0
  419. package/dist/prompts/templates/people.js.map +1 -0
  420. package/dist/prompts/types.d.ts +52 -0
  421. package/dist/prompts/types.d.ts.map +1 -0
  422. package/dist/prompts/types.js +5 -0
  423. package/dist/prompts/types.js.map +1 -0
  424. package/dist/types/attio.d.ts +424 -0
  425. package/dist/types/attio.d.ts.map +1 -0
  426. package/dist/types/attio.js +116 -0
  427. package/dist/types/attio.js.map +1 -0
  428. package/dist/types/company-types.d.ts +52 -0
  429. package/dist/types/company-types.d.ts.map +1 -0
  430. package/dist/types/company-types.js +5 -0
  431. package/dist/types/company-types.js.map +1 -0
  432. package/dist/types/tool-types.d.ts +262 -0
  433. package/dist/types/tool-types.d.ts.map +1 -0
  434. package/dist/types/tool-types.js +6 -0
  435. package/dist/types/tool-types.js.map +1 -0
  436. package/dist/utils/api-fallback.d.ts +39 -0
  437. package/dist/utils/api-fallback.d.ts.map +1 -0
  438. package/dist/utils/api-fallback.js +94 -0
  439. package/dist/utils/api-fallback.js.map +1 -0
  440. package/dist/utils/attribute-mapping/attribute-mappers.d.ts +39 -0
  441. package/dist/utils/attribute-mapping/attribute-mappers.d.ts.map +1 -0
  442. package/dist/utils/attribute-mapping/attribute-mappers.js +394 -0
  443. package/dist/utils/attribute-mapping/attribute-mappers.js.map +1 -0
  444. package/dist/utils/attribute-mapping/filter-translator.d.ts +9 -0
  445. package/dist/utils/attribute-mapping/filter-translator.d.ts.map +1 -0
  446. package/dist/utils/attribute-mapping/filter-translator.js +104 -0
  447. package/dist/utils/attribute-mapping/filter-translator.js.map +1 -0
  448. package/dist/utils/attribute-mapping/index.d.ts +10 -0
  449. package/dist/utils/attribute-mapping/index.d.ts.map +1 -0
  450. package/dist/utils/attribute-mapping/index.js +12 -0
  451. package/dist/utils/attribute-mapping/index.js.map +1 -0
  452. package/dist/utils/attribute-mapping/legacy-maps.d.ts +11 -0
  453. package/dist/utils/attribute-mapping/legacy-maps.d.ts.map +1 -0
  454. package/dist/utils/attribute-mapping/legacy-maps.js +54 -0
  455. package/dist/utils/attribute-mapping/legacy-maps.js.map +1 -0
  456. package/dist/utils/attribute-mapping/mapping-utils.d.ts +90 -0
  457. package/dist/utils/attribute-mapping/mapping-utils.d.ts.map +1 -0
  458. package/dist/utils/attribute-mapping/mapping-utils.js +145 -0
  459. package/dist/utils/attribute-mapping/mapping-utils.js.map +1 -0
  460. package/dist/utils/auto-discovery.d.ts +22 -0
  461. package/dist/utils/auto-discovery.d.ts.map +1 -0
  462. package/dist/utils/auto-discovery.js +143 -0
  463. package/dist/utils/auto-discovery.js.map +1 -0
  464. package/dist/utils/cli-colors.d.ts +36 -0
  465. package/dist/utils/cli-colors.d.ts.map +1 -0
  466. package/dist/utils/cli-colors.js +35 -0
  467. package/dist/utils/cli-colors.js.map +1 -0
  468. package/dist/utils/config-loader.d.ts +41 -0
  469. package/dist/utils/config-loader.d.ts.map +1 -0
  470. package/dist/utils/config-loader.js +167 -0
  471. package/dist/utils/config-loader.js.map +1 -0
  472. package/dist/utils/config-migration.d.ts +140 -0
  473. package/dist/utils/config-migration.d.ts.map +1 -0
  474. package/dist/utils/config-migration.js +310 -0
  475. package/dist/utils/config-migration.js.map +1 -0
  476. package/dist/utils/date-utils.d.ts +63 -0
  477. package/dist/utils/date-utils.d.ts.map +1 -0
  478. package/dist/utils/date-utils.js +329 -0
  479. package/dist/utils/date-utils.js.map +1 -0
  480. package/dist/utils/debug-b2b-segment.d.ts +2 -0
  481. package/dist/utils/debug-b2b-segment.d.ts.map +1 -0
  482. package/dist/utils/debug-b2b-segment.js +67 -0
  483. package/dist/utils/debug-b2b-segment.js.map +1 -0
  484. package/dist/utils/domain-utils.d.ts +46 -0
  485. package/dist/utils/domain-utils.d.ts.map +1 -0
  486. package/dist/utils/domain-utils.js +143 -0
  487. package/dist/utils/domain-utils.js.map +1 -0
  488. package/dist/utils/dynamic-import.d.ts +33 -0
  489. package/dist/utils/dynamic-import.d.ts.map +1 -0
  490. package/dist/utils/dynamic-import.js +41 -0
  491. package/dist/utils/dynamic-import.js.map +1 -0
  492. package/dist/utils/error-enhancer.d.ts +23 -0
  493. package/dist/utils/error-enhancer.d.ts.map +1 -0
  494. package/dist/utils/error-enhancer.js +188 -0
  495. package/dist/utils/error-enhancer.js.map +1 -0
  496. package/dist/utils/error-handler.d.ts +89 -0
  497. package/dist/utils/error-handler.d.ts.map +1 -0
  498. package/dist/utils/error-handler.js +336 -0
  499. package/dist/utils/error-handler.js.map +1 -0
  500. package/dist/utils/filters/builders/activity.d.ts +13 -0
  501. package/dist/utils/filters/builders/activity.d.ts.map +1 -0
  502. package/dist/utils/filters/builders/activity.js +65 -0
  503. package/dist/utils/filters/builders/activity.js.map +1 -0
  504. package/dist/utils/filters/builders/basic.d.ts +13 -0
  505. package/dist/utils/filters/builders/basic.d.ts.map +1 -0
  506. package/dist/utils/filters/builders/basic.js +36 -0
  507. package/dist/utils/filters/builders/basic.js.map +1 -0
  508. package/dist/utils/filters/builders/complex.d.ts +31 -0
  509. package/dist/utils/filters/builders/complex.d.ts.map +1 -0
  510. package/dist/utils/filters/builders/complex.js +92 -0
  511. package/dist/utils/filters/builders/complex.js.map +1 -0
  512. package/dist/utils/filters/builders/date.d.ts +17 -0
  513. package/dist/utils/filters/builders/date.d.ts.map +1 -0
  514. package/dist/utils/filters/builders/date.js +51 -0
  515. package/dist/utils/filters/builders/date.js.map +1 -0
  516. package/dist/utils/filters/builders/index.d.ts +8 -0
  517. package/dist/utils/filters/builders/index.d.ts.map +1 -0
  518. package/dist/utils/filters/builders/index.js +8 -0
  519. package/dist/utils/filters/builders/index.js.map +1 -0
  520. package/dist/utils/filters/builders/numeric.d.ts +17 -0
  521. package/dist/utils/filters/builders/numeric.d.ts.map +1 -0
  522. package/dist/utils/filters/builders/numeric.js +61 -0
  523. package/dist/utils/filters/builders/numeric.js.map +1 -0
  524. package/dist/utils/filters/builders/text.d.ts +17 -0
  525. package/dist/utils/filters/builders/text.d.ts.map +1 -0
  526. package/dist/utils/filters/builders/text.js +47 -0
  527. package/dist/utils/filters/builders/text.js.map +1 -0
  528. package/dist/utils/filters/builders/types.d.ts +2 -0
  529. package/dist/utils/filters/builders/types.d.ts.map +1 -0
  530. package/dist/utils/filters/builders/types.js +2 -0
  531. package/dist/utils/filters/builders/types.js.map +1 -0
  532. package/dist/utils/filters/builders.d.ts +2 -0
  533. package/dist/utils/filters/builders.d.ts.map +1 -0
  534. package/dist/utils/filters/builders.js +2 -0
  535. package/dist/utils/filters/builders.js.map +1 -0
  536. package/dist/utils/filters/cache.d.ts +80 -0
  537. package/dist/utils/filters/cache.d.ts.map +1 -0
  538. package/dist/utils/filters/cache.js +212 -0
  539. package/dist/utils/filters/cache.js.map +1 -0
  540. package/dist/utils/filters/index.d.ts +51 -0
  541. package/dist/utils/filters/index.d.ts.map +1 -0
  542. package/dist/utils/filters/index.js +67 -0
  543. package/dist/utils/filters/index.js.map +1 -0
  544. package/dist/utils/filters/operators.d.ts +65 -0
  545. package/dist/utils/filters/operators.d.ts.map +1 -0
  546. package/dist/utils/filters/operators.js +214 -0
  547. package/dist/utils/filters/operators.js.map +1 -0
  548. package/dist/utils/filters/relationship.d.ts +81 -0
  549. package/dist/utils/filters/relationship.d.ts.map +1 -0
  550. package/dist/utils/filters/relationship.js +393 -0
  551. package/dist/utils/filters/relationship.js.map +1 -0
  552. package/dist/utils/filters/translators.d.ts +120 -0
  553. package/dist/utils/filters/translators.d.ts.map +1 -0
  554. package/dist/utils/filters/translators.js +397 -0
  555. package/dist/utils/filters/translators.js.map +1 -0
  556. package/dist/utils/filters/types.d.ts +77 -0
  557. package/dist/utils/filters/types.d.ts.map +1 -0
  558. package/dist/utils/filters/types.js +85 -0
  559. package/dist/utils/filters/types.js.map +1 -0
  560. package/dist/utils/filters/utils.d.ts +86 -0
  561. package/dist/utils/filters/utils.d.ts.map +1 -0
  562. package/dist/utils/filters/utils.js +142 -0
  563. package/dist/utils/filters/utils.js.map +1 -0
  564. package/dist/utils/filters/validation-utils.d.ts +123 -0
  565. package/dist/utils/filters/validation-utils.d.ts.map +1 -0
  566. package/dist/utils/filters/validation-utils.js +282 -0
  567. package/dist/utils/filters/validation-utils.js.map +1 -0
  568. package/dist/utils/filters/validators.d.ts +73 -0
  569. package/dist/utils/filters/validators.d.ts.map +1 -0
  570. package/dist/utils/filters/validators.js +311 -0
  571. package/dist/utils/filters/validators.js.map +1 -0
  572. package/dist/utils/json-serializer.d.ts +68 -0
  573. package/dist/utils/json-serializer.d.ts.map +1 -0
  574. package/dist/utils/json-serializer.js +235 -0
  575. package/dist/utils/json-serializer.js.map +1 -0
  576. package/dist/utils/logger.d.ts +226 -0
  577. package/dist/utils/logger.d.ts.map +1 -0
  578. package/dist/utils/logger.js +323 -0
  579. package/dist/utils/logger.js.map +1 -0
  580. package/dist/utils/numeric-utils.d.ts +27 -0
  581. package/dist/utils/numeric-utils.d.ts.map +1 -0
  582. package/dist/utils/numeric-utils.js +83 -0
  583. package/dist/utils/numeric-utils.js.map +1 -0
  584. package/dist/utils/pagination.d.ts +85 -0
  585. package/dist/utils/pagination.d.ts.map +1 -0
  586. package/dist/utils/pagination.js +169 -0
  587. package/dist/utils/pagination.js.map +1 -0
  588. package/dist/utils/person-lookup.d.ts +35 -0
  589. package/dist/utils/person-lookup.d.ts.map +1 -0
  590. package/dist/utils/person-lookup.js +67 -0
  591. package/dist/utils/person-lookup.js.map +1 -0
  592. package/dist/utils/rate-limiter.d.ts +82 -0
  593. package/dist/utils/rate-limiter.d.ts.map +1 -0
  594. package/dist/utils/rate-limiter.js +159 -0
  595. package/dist/utils/rate-limiter.js.map +1 -0
  596. package/dist/utils/record-utils.d.ts +74 -0
  597. package/dist/utils/record-utils.d.ts.map +1 -0
  598. package/dist/utils/record-utils.js +312 -0
  599. package/dist/utils/record-utils.js.map +1 -0
  600. package/dist/utils/relationship-utils.d.ts +61 -0
  601. package/dist/utils/relationship-utils.d.ts.map +1 -0
  602. package/dist/utils/relationship-utils.js +242 -0
  603. package/dist/utils/relationship-utils.js.map +1 -0
  604. package/dist/utils/response-formatter.d.ts +121 -0
  605. package/dist/utils/response-formatter.d.ts.map +1 -0
  606. package/dist/utils/response-formatter.js +188 -0
  607. package/dist/utils/response-formatter.js.map +1 -0
  608. package/dist/utils/uri-parser.d.ts +18 -0
  609. package/dist/utils/uri-parser.d.ts.map +1 -0
  610. package/dist/utils/uri-parser.js +31 -0
  611. package/dist/utils/uri-parser.js.map +1 -0
  612. package/dist/utils/validation.d.ts +59 -0
  613. package/dist/utils/validation.d.ts.map +1 -0
  614. package/dist/utils/validation.js +264 -0
  615. package/dist/utils/validation.js.map +1 -0
  616. package/dist/utils/value-matcher.d.ts +58 -0
  617. package/dist/utils/value-matcher.d.ts.map +1 -0
  618. package/dist/utils/value-matcher.js +131 -0
  619. package/dist/utils/value-matcher.js.map +1 -0
  620. package/dist/validators/attribute-validator.d.ts +59 -0
  621. package/dist/validators/attribute-validator.d.ts.map +1 -0
  622. package/dist/validators/attribute-validator.js +531 -0
  623. package/dist/validators/attribute-validator.js.map +1 -0
  624. package/dist/validators/company/field_detector.d.ts +5 -0
  625. package/dist/validators/company/field_detector.d.ts.map +1 -0
  626. package/dist/validators/company/field_detector.js +95 -0
  627. package/dist/validators/company/field_detector.js.map +1 -0
  628. package/dist/validators/company/index.d.ts +26 -0
  629. package/dist/validators/company/index.d.ts.map +1 -0
  630. package/dist/validators/company/index.js +433 -0
  631. package/dist/validators/company/index.js.map +1 -0
  632. package/dist/validators/company/type_cache.d.ts +14 -0
  633. package/dist/validators/company/type_cache.d.ts.map +1 -0
  634. package/dist/validators/company/type_cache.js +28 -0
  635. package/dist/validators/company/type_cache.js.map +1 -0
  636. package/dist/validators/company/types.d.ts +8 -0
  637. package/dist/validators/company/types.d.ts.map +1 -0
  638. package/dist/validators/company/types.js +2 -0
  639. package/dist/validators/company/types.js.map +1 -0
  640. package/dist/validators/company-validator.d.ts +2 -0
  641. package/dist/validators/company-validator.d.ts.map +1 -0
  642. package/dist/validators/company-validator.js +2 -0
  643. package/dist/validators/company-validator.js.map +1 -0
  644. package/package.json +167 -0
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Configuration loader for Attio MCP Server
3
+ * Handles loading and merging of configuration files
4
+ */
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ /**
8
+ * Default paths for configuration files
9
+ */
10
+ const CONFIG_PATHS = {
11
+ default: path.resolve(process.cwd(), 'config/mappings/default.json'),
12
+ user: path.resolve(process.cwd(), 'config/mappings/user.json'),
13
+ };
14
+ /**
15
+ * Deep merges two objects, with values from the source object taking precedence
16
+ *
17
+ * @param target - The target object
18
+ * @param source - The source object to merge in
19
+ * @returns The merged object
20
+ */
21
+ function deepMerge(target, source) {
22
+ const result = { ...target };
23
+ for (const key in source) {
24
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
25
+ if (source[key] &&
26
+ typeof source[key] === 'object' &&
27
+ !Array.isArray(source[key])) {
28
+ // If both target and source have an object at this key, merge them
29
+ if (result[key] &&
30
+ typeof result[key] === 'object' &&
31
+ !Array.isArray(result[key])) {
32
+ result[key] = deepMerge(result[key], source[key]);
33
+ }
34
+ else {
35
+ // Otherwise, just use the source value
36
+ result[key] = { ...source[key] };
37
+ }
38
+ }
39
+ else {
40
+ // For non-objects, use the source value
41
+ result[key] = source[key];
42
+ }
43
+ }
44
+ }
45
+ return result;
46
+ }
47
+ /**
48
+ * Creates an empty mapping configuration with default structure
49
+ *
50
+ * @returns An empty mapping configuration
51
+ */
52
+ function createEmptyConfig() {
53
+ return {
54
+ version: '1.0',
55
+ metadata: {
56
+ generated: new Date().toISOString(),
57
+ description: 'Generated empty configuration',
58
+ },
59
+ mappings: {
60
+ attributes: {
61
+ common: {},
62
+ objects: {},
63
+ custom: {},
64
+ },
65
+ objects: {},
66
+ lists: {},
67
+ relationships: {},
68
+ },
69
+ };
70
+ }
71
+ /**
72
+ * Loads a JSON configuration file
73
+ *
74
+ * @param filePath - Path to the JSON file
75
+ * @returns Parsed JSON object, or null if the file doesn't exist
76
+ */
77
+ function loadJsonFile(filePath) {
78
+ try {
79
+ if (fs.existsSync(filePath)) {
80
+ const content = fs.readFileSync(filePath, 'utf8');
81
+ return JSON.parse(content);
82
+ }
83
+ }
84
+ catch (error) {
85
+ console.warn(`Warning: Failed to load config file ${filePath}:`, error);
86
+ }
87
+ return null;
88
+ }
89
+ /**
90
+ * Loads and merges the mapping configuration from default and user files
91
+ *
92
+ * @returns The merged mapping configuration
93
+ */
94
+ export function loadMappingConfig() {
95
+ // Start with empty configuration
96
+ let config = createEmptyConfig();
97
+ // Load and merge the default configuration
98
+ const defaultConfig = loadJsonFile(CONFIG_PATHS.default);
99
+ if (defaultConfig) {
100
+ config = deepMerge(config, defaultConfig);
101
+ }
102
+ // Load and merge the user configuration
103
+ const userConfig = loadJsonFile(CONFIG_PATHS.user);
104
+ if (userConfig) {
105
+ config = deepMerge(config, userConfig);
106
+ }
107
+ return config;
108
+ }
109
+ /**
110
+ * Writes a mapping configuration to a file
111
+ *
112
+ * @param config - The configuration to write
113
+ * @param filePath - The file path to write to (defaults to user.json)
114
+ */
115
+ export async function writeMappingConfig(config, filePath = CONFIG_PATHS.user) {
116
+ try {
117
+ // Ensure the directory exists
118
+ const dir = path.dirname(filePath);
119
+ if (!fs.existsSync(dir)) {
120
+ fs.mkdirSync(dir, { recursive: true });
121
+ }
122
+ // Update metadata
123
+ if (!config.metadata) {
124
+ config.metadata = {};
125
+ }
126
+ config.metadata.generated = new Date().toISOString();
127
+ // Write the file
128
+ const content = JSON.stringify(config, null, 2);
129
+ await fs.promises.writeFile(filePath, content, 'utf8');
130
+ }
131
+ catch (error) {
132
+ throw new Error(`Failed to write config file ${filePath}: ${error}`);
133
+ }
134
+ }
135
+ /**
136
+ * Updates a specific section of the mapping configuration
137
+ *
138
+ * @param section - The section to update (e.g., 'attributes.common')
139
+ * @param mappings - The mappings to set or merge
140
+ * @param merge - Whether to merge with existing mappings (default: true)
141
+ * @param filePath - The file path to write to (defaults to user.json)
142
+ */
143
+ export async function updateMappingSection(section, mappings, merge = true, filePath = CONFIG_PATHS.user) {
144
+ // Load the current config
145
+ const config = loadMappingConfig();
146
+ // Parse the section path and navigate to the target section
147
+ const sectionParts = section.split('.');
148
+ let target = config.mappings;
149
+ for (let i = 0; i < sectionParts.length - 1; i++) {
150
+ const part = sectionParts[i];
151
+ if (!target[part]) {
152
+ target[part] = {};
153
+ }
154
+ target = target[part];
155
+ }
156
+ const finalPart = sectionParts[sectionParts.length - 1];
157
+ // Update the target section
158
+ if (merge && target[finalPart]) {
159
+ target[finalPart] = { ...target[finalPart], ...mappings };
160
+ }
161
+ else {
162
+ target[finalPart] = mappings;
163
+ }
164
+ // Write the updated config
165
+ await writeMappingConfig(config, filePath);
166
+ }
167
+ //# sourceMappingURL=config-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/utils/config-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAqBxB;;GAEG;AACH,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,8BAA8B,CAAC;IACpE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,2BAA2B,CAAC;CAC/D,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,MAAW,EAAE,MAAW;IACzC,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAE7B,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YACtD,IACE,MAAM,CAAC,GAAG,CAAC;gBACX,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ;gBAC/B,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAC3B,CAAC;gBACD,mEAAmE;gBACnE,IACE,MAAM,CAAC,GAAG,CAAC;oBACX,OAAO,MAAM,CAAC,GAAG,CAA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;QACN,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,2BAA2B;IAC3B,MAAM,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,140 @@
1
+ import { MappingConfig } from './config-loader.js';
2
+ export type { MappingConfig };
3
+ export interface MigrationResult {
4
+ success: boolean;
5
+ message: string;
6
+ backupPath?: string;
7
+ changesApplied?: string[];
8
+ errors?: string[];
9
+ }
10
+ export interface MigrationDetection {
11
+ needsMigration: boolean;
12
+ outdatedMappings: string[];
13
+ filePath: string;
14
+ exists: boolean;
15
+ }
16
+ /**
17
+ * Detects if user.json needs migration for postal code mappings
18
+ *
19
+ * Scans the user configuration file for outdated postal code mappings
20
+ * that use "zip" instead of the correct "postal_code" attribute name.
21
+ *
22
+ * @returns MigrationDetection object containing:
23
+ * - needsMigration: whether migration is required
24
+ * - outdatedMappings: array of problematic mappings found
25
+ * - filePath: path to the user config file
26
+ * - exists: whether the config file exists
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const detection = detectMigrationNeeds();
31
+ * if (detection.needsMigration) {
32
+ * console.log('Found outdated mappings:', detection.outdatedMappings);
33
+ * }
34
+ * ```
35
+ */
36
+ export declare function detectMigrationNeeds(): MigrationDetection;
37
+ /**
38
+ * Creates a timestamped backup of the user.json file
39
+ *
40
+ * Creates a backup in config/mappings/backup/ directory with ISO timestamp.
41
+ * Ensures the backup directory exists before creating the backup file.
42
+ *
43
+ * @returns Object containing:
44
+ * - success: whether backup creation succeeded
45
+ * - backupPath: path to the created backup file (if successful)
46
+ * - error: error message (if failed)
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const backup = createBackup();
51
+ * if (backup.success) {
52
+ * console.log('Backup created at:', backup.backupPath);
53
+ * } else {
54
+ * console.error('Backup failed:', backup.error);
55
+ * }
56
+ * ```
57
+ */
58
+ export declare function createBackup(): {
59
+ success: boolean;
60
+ backupPath?: string;
61
+ error?: string;
62
+ };
63
+ /**
64
+ * Applies the postal code mapping migration to user.json
65
+ *
66
+ * Performs the complete migration workflow:
67
+ * 1. Detects if migration is needed
68
+ * 2. Creates a backup of the current configuration
69
+ * 3. Applies the postal code mapping fixes
70
+ * 4. Updates metadata to track migration history
71
+ *
72
+ * @returns MigrationResult object containing:
73
+ * - success: whether the migration succeeded
74
+ * - message: descriptive message about the operation
75
+ * - backupPath: path to the backup file (if created)
76
+ * - changesApplied: array of changes that were made
77
+ * - errors: array of error messages (if any failures occurred)
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const result = applyMigration();
82
+ * if (result.success) {
83
+ * console.log('Migration completed:', result.message);
84
+ * console.log('Changes:', result.changesApplied);
85
+ * } else {
86
+ * console.error('Migration failed:', result.message);
87
+ * }
88
+ * ```
89
+ */
90
+ export declare function applyMigration(): MigrationResult;
91
+ /**
92
+ * Validates that the migration was applied correctly
93
+ *
94
+ * Checks if the user configuration still contains any outdated postal
95
+ * code mappings after migration has been applied.
96
+ *
97
+ * @returns Object containing:
98
+ * - valid: whether the configuration passes validation
99
+ * - issues: array of validation issues found (if any)
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const validation = validateMigration();
104
+ * if (!validation.valid) {
105
+ * console.error('Validation failed:', validation.issues);
106
+ * }
107
+ * ```
108
+ */
109
+ export declare function validateMigration(): {
110
+ valid: boolean;
111
+ issues: string[];
112
+ };
113
+ /**
114
+ * Complete migration workflow with validation
115
+ *
116
+ * Main entry point for the migration process. Orchestrates detection,
117
+ * migration, and validation with optional dry-run mode.
118
+ *
119
+ * @param options Configuration options for the migration:
120
+ * - dryRun: if true, only shows what would be changed without applying
121
+ *
122
+ * @returns MigrationResult object with complete operation status
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * // Preview changes without applying
127
+ * const preview = migrateUserConfig({ dryRun: true });
128
+ * console.log('Would apply:', preview.changesApplied);
129
+ *
130
+ * // Apply the migration
131
+ * const result = migrateUserConfig();
132
+ * if (result.success) {
133
+ * console.log('Migration completed successfully');
134
+ * }
135
+ * ```
136
+ */
137
+ export declare function migrateUserConfig(options?: {
138
+ dryRun?: boolean;
139
+ }): MigrationResult;
140
+ //# sourceMappingURL=config-migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-migration.d.ts","sourceRoot":"","sources":["../../src/utils/config-migration.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AA0BD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,IAAI,kBAAkB,CA6CzD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,IAAI;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAsBA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,IAAI,eAAe,CA6EhD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,IAAI;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAmBxE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,eAAe,CAmDjB"}
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Configuration migration utility for Attio MCP Server
3
+ * Handles migration of user.json files to fix outdated mappings
4
+ */
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import logger from './logger.js';
8
+ /**
9
+ * Known problematic mappings that need to be fixed
10
+ */
11
+ const MAPPINGS_TO_FIX = {
12
+ ZIP: {
13
+ from: 'zip',
14
+ to: 'postal_code',
15
+ reason: 'zip attribute does not exist in Attio schema',
16
+ },
17
+ 'Postal Code': {
18
+ from: 'zip',
19
+ to: 'postal_code',
20
+ reason: 'zip attribute does not exist in Attio schema',
21
+ },
22
+ };
23
+ /**
24
+ * Paths for configuration files
25
+ */
26
+ const CONFIG_PATHS = {
27
+ user: path.resolve(process.cwd(), 'config/mappings/user.json'),
28
+ backup: path.resolve(process.cwd(), 'config/mappings/backup'),
29
+ };
30
+ /**
31
+ * Detects if user.json needs migration for postal code mappings
32
+ *
33
+ * Scans the user configuration file for outdated postal code mappings
34
+ * that use "zip" instead of the correct "postal_code" attribute name.
35
+ *
36
+ * @returns MigrationDetection object containing:
37
+ * - needsMigration: whether migration is required
38
+ * - outdatedMappings: array of problematic mappings found
39
+ * - filePath: path to the user config file
40
+ * - exists: whether the config file exists
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const detection = detectMigrationNeeds();
45
+ * if (detection.needsMigration) {
46
+ * console.log('Found outdated mappings:', detection.outdatedMappings);
47
+ * }
48
+ * ```
49
+ */
50
+ export function detectMigrationNeeds() {
51
+ const result = {
52
+ needsMigration: false,
53
+ outdatedMappings: [],
54
+ filePath: CONFIG_PATHS.user,
55
+ exists: false,
56
+ };
57
+ // Check if user.json exists
58
+ if (!fs.existsSync(CONFIG_PATHS.user)) {
59
+ return result;
60
+ }
61
+ result.exists = true;
62
+ try {
63
+ const userConfig = JSON.parse(fs.readFileSync(CONFIG_PATHS.user, 'utf8'));
64
+ // Check common mappings for problematic postal code mappings
65
+ const commonMappings = userConfig.mappings?.attributes?.common || {};
66
+ for (const [displayName, expectedFix] of Object.entries(MAPPINGS_TO_FIX)) {
67
+ const currentMapping = commonMappings[displayName];
68
+ if (currentMapping === expectedFix.from) {
69
+ result.needsMigration = true;
70
+ result.outdatedMappings.push(`"${displayName}": "${currentMapping}" → should be "${expectedFix.to}"`);
71
+ }
72
+ }
73
+ }
74
+ catch (error) {
75
+ // If we can't parse the file, we can't migrate it
76
+ logger.warn('config-migration', 'Could not parse user configuration file for migration detection', {
77
+ filePath: CONFIG_PATHS.user,
78
+ error: error instanceof Error ? error.message : String(error),
79
+ });
80
+ }
81
+ return result;
82
+ }
83
+ /**
84
+ * Creates a timestamped backup of the user.json file
85
+ *
86
+ * Creates a backup in config/mappings/backup/ directory with ISO timestamp.
87
+ * Ensures the backup directory exists before creating the backup file.
88
+ *
89
+ * @returns Object containing:
90
+ * - success: whether backup creation succeeded
91
+ * - backupPath: path to the created backup file (if successful)
92
+ * - error: error message (if failed)
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const backup = createBackup();
97
+ * if (backup.success) {
98
+ * console.log('Backup created at:', backup.backupPath);
99
+ * } else {
100
+ * console.error('Backup failed:', backup.error);
101
+ * }
102
+ * ```
103
+ */
104
+ export function createBackup() {
105
+ try {
106
+ // Ensure backup directory exists
107
+ if (!fs.existsSync(CONFIG_PATHS.backup)) {
108
+ fs.mkdirSync(CONFIG_PATHS.backup, { recursive: true });
109
+ }
110
+ // Create timestamped backup filename
111
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
112
+ const backupFileName = `user.json.backup.${timestamp}`;
113
+ const backupPath = path.join(CONFIG_PATHS.backup, backupFileName);
114
+ // Copy the current user.json to backup
115
+ fs.copyFileSync(CONFIG_PATHS.user, backupPath);
116
+ return { success: true, backupPath };
117
+ }
118
+ catch (error) {
119
+ return {
120
+ success: false,
121
+ error: error instanceof Error ? error.message : String(error),
122
+ };
123
+ }
124
+ }
125
+ /**
126
+ * Applies the postal code mapping migration to user.json
127
+ *
128
+ * Performs the complete migration workflow:
129
+ * 1. Detects if migration is needed
130
+ * 2. Creates a backup of the current configuration
131
+ * 3. Applies the postal code mapping fixes
132
+ * 4. Updates metadata to track migration history
133
+ *
134
+ * @returns MigrationResult object containing:
135
+ * - success: whether the migration succeeded
136
+ * - message: descriptive message about the operation
137
+ * - backupPath: path to the backup file (if created)
138
+ * - changesApplied: array of changes that were made
139
+ * - errors: array of error messages (if any failures occurred)
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const result = applyMigration();
144
+ * if (result.success) {
145
+ * console.log('Migration completed:', result.message);
146
+ * console.log('Changes:', result.changesApplied);
147
+ * } else {
148
+ * console.error('Migration failed:', result.message);
149
+ * }
150
+ * ```
151
+ */
152
+ export function applyMigration() {
153
+ const detection = detectMigrationNeeds();
154
+ if (!detection.exists) {
155
+ return {
156
+ success: true,
157
+ message: 'No user.json file found - no migration needed',
158
+ };
159
+ }
160
+ if (!detection.needsMigration) {
161
+ return {
162
+ success: true,
163
+ message: 'User configuration is already up to date - no migration needed',
164
+ };
165
+ }
166
+ try {
167
+ // Create backup first
168
+ const backup = createBackup();
169
+ if (!backup.success) {
170
+ return {
171
+ success: false,
172
+ message: `Failed to create backup: ${backup.error}`,
173
+ errors: [backup.error || 'Unknown backup error'],
174
+ };
175
+ }
176
+ // Load and modify the user config
177
+ const userConfig = JSON.parse(fs.readFileSync(CONFIG_PATHS.user, 'utf8'));
178
+ const changesApplied = [];
179
+ // Apply postal code mapping fixes
180
+ if (userConfig.mappings?.attributes?.common) {
181
+ for (const [displayName, fix] of Object.entries(MAPPINGS_TO_FIX)) {
182
+ const currentMapping = userConfig.mappings.attributes.common[displayName];
183
+ if (currentMapping === fix.from) {
184
+ userConfig.mappings.attributes.common[displayName] = fix.to;
185
+ changesApplied.push(`Updated "${displayName}": "${fix.from}" → "${fix.to}"`);
186
+ }
187
+ }
188
+ }
189
+ // Update metadata to track migration
190
+ if (!userConfig.metadata) {
191
+ userConfig.metadata = {};
192
+ }
193
+ userConfig.metadata.lastMigration = new Date().toISOString();
194
+ userConfig.metadata.migratedMappings = changesApplied;
195
+ // Write the updated config back to file
196
+ fs.writeFileSync(CONFIG_PATHS.user, JSON.stringify(userConfig, null, 2), 'utf8');
197
+ return {
198
+ success: true,
199
+ message: `Migration completed successfully. Applied ${changesApplied.length} changes.`,
200
+ backupPath: backup.backupPath,
201
+ changesApplied,
202
+ };
203
+ }
204
+ catch (error) {
205
+ return {
206
+ success: false,
207
+ message: `Migration failed: ${error instanceof Error ? error.message : String(error)}`,
208
+ errors: [error instanceof Error ? error.message : String(error)],
209
+ };
210
+ }
211
+ }
212
+ /**
213
+ * Validates that the migration was applied correctly
214
+ *
215
+ * Checks if the user configuration still contains any outdated postal
216
+ * code mappings after migration has been applied.
217
+ *
218
+ * @returns Object containing:
219
+ * - valid: whether the configuration passes validation
220
+ * - issues: array of validation issues found (if any)
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * const validation = validateMigration();
225
+ * if (!validation.valid) {
226
+ * console.error('Validation failed:', validation.issues);
227
+ * }
228
+ * ```
229
+ */
230
+ export function validateMigration() {
231
+ const detection = detectMigrationNeeds();
232
+ if (!detection.exists) {
233
+ return { valid: true, issues: [] };
234
+ }
235
+ if (detection.needsMigration) {
236
+ return {
237
+ valid: false,
238
+ issues: [
239
+ `Migration incomplete. Still found outdated mappings: ${detection.outdatedMappings.join(', ')}`,
240
+ ],
241
+ };
242
+ }
243
+ return { valid: true, issues: [] };
244
+ }
245
+ /**
246
+ * Complete migration workflow with validation
247
+ *
248
+ * Main entry point for the migration process. Orchestrates detection,
249
+ * migration, and validation with optional dry-run mode.
250
+ *
251
+ * @param options Configuration options for the migration:
252
+ * - dryRun: if true, only shows what would be changed without applying
253
+ *
254
+ * @returns MigrationResult object with complete operation status
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * // Preview changes without applying
259
+ * const preview = migrateUserConfig({ dryRun: true });
260
+ * console.log('Would apply:', preview.changesApplied);
261
+ *
262
+ * // Apply the migration
263
+ * const result = migrateUserConfig();
264
+ * if (result.success) {
265
+ * console.log('Migration completed successfully');
266
+ * }
267
+ * ```
268
+ */
269
+ export function migrateUserConfig(options = {}) {
270
+ const detection = detectMigrationNeeds();
271
+ // Early return if no migration needed
272
+ if (!detection.exists) {
273
+ return {
274
+ success: true,
275
+ message: 'No user.json file found - no migration needed',
276
+ };
277
+ }
278
+ if (!detection.needsMigration) {
279
+ return {
280
+ success: true,
281
+ message: 'User configuration is already up to date - no migration needed',
282
+ };
283
+ }
284
+ // Dry run mode - just report what would be changed
285
+ if (options.dryRun) {
286
+ return {
287
+ success: true,
288
+ message: `Migration needed. Would fix: ${detection.outdatedMappings.join(', ')}`,
289
+ changesApplied: detection.outdatedMappings,
290
+ };
291
+ }
292
+ // Apply the migration
293
+ const migrationResult = applyMigration();
294
+ if (!migrationResult.success) {
295
+ return migrationResult;
296
+ }
297
+ // Validate the migration worked
298
+ const validation = validateMigration();
299
+ if (!validation.valid) {
300
+ return {
301
+ success: false,
302
+ message: `Migration applied but validation failed: ${validation.issues.join(', ')}`,
303
+ errors: validation.issues,
304
+ backupPath: migrationResult.backupPath,
305
+ changesApplied: migrationResult.changesApplied,
306
+ };
307
+ }
308
+ return migrationResult;
309
+ }
310
+ //# sourceMappingURL=config-migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-migration.js","sourceRoot":"","sources":["../../src/utils/config-migration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,MAAM,MAAM,aAAa,CAAC;AAoBjC;;GAEG;AACH,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,EAAE,EAAE,aAAa;QACjB,MAAM,EAAE,8CAA8C;KACvD;IACD,aAAa,E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