@hasna/microservices 0.0.16 → 0.0.17

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 (293) hide show
  1. package/README.md +143 -23
  2. package/bin/index.js +711 -13998
  3. package/bin/mcp.js +228 -10987
  4. package/dist/index.js +166 -10056
  5. package/package.json +25 -25
  6. package/microservices/microservice-ads/package.json +0 -28
  7. package/microservices/microservice-ads/src/cli/index.ts +0 -605
  8. package/microservices/microservice-ads/src/db/campaigns.ts +0 -797
  9. package/microservices/microservice-ads/src/db/database.ts +0 -91
  10. package/microservices/microservice-ads/src/db/migrations.ts +0 -60
  11. package/microservices/microservice-ads/src/index.ts +0 -39
  12. package/microservices/microservice-ads/src/mcp/index.ts +0 -480
  13. package/microservices/microservice-analytics/package.json +0 -28
  14. package/microservices/microservice-analytics/src/cli/index.ts +0 -373
  15. package/microservices/microservice-analytics/src/db/analytics.ts +0 -564
  16. package/microservices/microservice-analytics/src/db/database.ts +0 -91
  17. package/microservices/microservice-analytics/src/db/migrations.ts +0 -50
  18. package/microservices/microservice-analytics/src/index.ts +0 -37
  19. package/microservices/microservice-analytics/src/mcp/index.ts +0 -334
  20. package/microservices/microservice-assets/package.json +0 -28
  21. package/microservices/microservice-assets/src/cli/index.ts +0 -375
  22. package/microservices/microservice-assets/src/db/assets.ts +0 -370
  23. package/microservices/microservice-assets/src/db/database.ts +0 -91
  24. package/microservices/microservice-assets/src/db/migrations.ts +0 -51
  25. package/microservices/microservice-assets/src/index.ts +0 -32
  26. package/microservices/microservice-assets/src/mcp/index.ts +0 -346
  27. package/microservices/microservice-bookkeeping/package.json +0 -28
  28. package/microservices/microservice-bookkeeping/src/cli/index.ts +0 -386
  29. package/microservices/microservice-bookkeeping/src/db/bookkeeping.ts +0 -591
  30. package/microservices/microservice-bookkeeping/src/db/database.ts +0 -91
  31. package/microservices/microservice-bookkeeping/src/db/migrations.ts +0 -52
  32. package/microservices/microservice-bookkeeping/src/index.ts +0 -32
  33. package/microservices/microservice-bookkeeping/src/mcp/index.ts +0 -284
  34. package/microservices/microservice-calendar/package.json +0 -28
  35. package/microservices/microservice-calendar/src/cli/index.ts +0 -287
  36. package/microservices/microservice-calendar/src/db/calendar.ts +0 -328
  37. package/microservices/microservice-calendar/src/db/database.ts +0 -91
  38. package/microservices/microservice-calendar/src/db/migrations.ts +0 -47
  39. package/microservices/microservice-calendar/src/index.ts +0 -24
  40. package/microservices/microservice-calendar/src/mcp/index.ts +0 -226
  41. package/microservices/microservice-company/package.json +0 -28
  42. package/microservices/microservice-company/src/cli/index.ts +0 -1126
  43. package/microservices/microservice-company/src/db/company.ts +0 -854
  44. package/microservices/microservice-company/src/db/database.ts +0 -91
  45. package/microservices/microservice-company/src/db/migrations.ts +0 -214
  46. package/microservices/microservice-company/src/db/workflow-migrations.ts +0 -44
  47. package/microservices/microservice-company/src/index.ts +0 -60
  48. package/microservices/microservice-company/src/lib/audit.ts +0 -168
  49. package/microservices/microservice-company/src/lib/finance.ts +0 -299
  50. package/microservices/microservice-company/src/lib/settings.ts +0 -85
  51. package/microservices/microservice-company/src/lib/workflows.ts +0 -698
  52. package/microservices/microservice-company/src/mcp/index.ts +0 -991
  53. package/microservices/microservice-compliance/package.json +0 -28
  54. package/microservices/microservice-compliance/src/cli/index.ts +0 -467
  55. package/microservices/microservice-compliance/src/db/compliance.ts +0 -633
  56. package/microservices/microservice-compliance/src/db/database.ts +0 -91
  57. package/microservices/microservice-compliance/src/db/migrations.ts +0 -63
  58. package/microservices/microservice-compliance/src/index.ts +0 -46
  59. package/microservices/microservice-compliance/src/mcp/index.ts +0 -438
  60. package/microservices/microservice-contacts/package.json +0 -28
  61. package/microservices/microservice-contacts/src/cli/index.ts +0 -393
  62. package/microservices/microservice-contacts/src/db/companies.ts +0 -167
  63. package/microservices/microservice-contacts/src/db/contacts.ts +0 -249
  64. package/microservices/microservice-contacts/src/db/database.ts +0 -91
  65. package/microservices/microservice-contacts/src/db/migrations.ts +0 -71
  66. package/microservices/microservice-contacts/src/db/relationships.ts +0 -53
  67. package/microservices/microservice-contacts/src/index.ts +0 -42
  68. package/microservices/microservice-contacts/src/mcp/index.ts +0 -303
  69. package/microservices/microservice-contracts/package.json +0 -28
  70. package/microservices/microservice-contracts/src/cli/index.ts +0 -770
  71. package/microservices/microservice-contracts/src/db/contracts.ts +0 -925
  72. package/microservices/microservice-contracts/src/db/database.ts +0 -91
  73. package/microservices/microservice-contracts/src/db/migrations.ts +0 -141
  74. package/microservices/microservice-contracts/src/index.ts +0 -43
  75. package/microservices/microservice-contracts/src/mcp/index.ts +0 -617
  76. package/microservices/microservice-crm/package.json +0 -28
  77. package/microservices/microservice-crm/src/cli/index.ts +0 -396
  78. package/microservices/microservice-crm/src/db/database.ts +0 -91
  79. package/microservices/microservice-crm/src/db/migrations.ts +0 -66
  80. package/microservices/microservice-crm/src/db/pipeline.ts +0 -397
  81. package/microservices/microservice-crm/src/index.ts +0 -34
  82. package/microservices/microservice-crm/src/mcp/index.ts +0 -294
  83. package/microservices/microservice-documents/package.json +0 -28
  84. package/microservices/microservice-documents/src/cli/index.ts +0 -246
  85. package/microservices/microservice-documents/src/db/database.ts +0 -91
  86. package/microservices/microservice-documents/src/db/documents.ts +0 -316
  87. package/microservices/microservice-documents/src/db/migrations.ts +0 -49
  88. package/microservices/microservice-documents/src/index.ts +0 -24
  89. package/microservices/microservice-documents/src/mcp/index.ts +0 -202
  90. package/microservices/microservice-domains/package.json +0 -28
  91. package/microservices/microservice-domains/src/cli/index.ts +0 -1111
  92. package/microservices/microservice-domains/src/db/database.ts +0 -91
  93. package/microservices/microservice-domains/src/db/domains.ts +0 -1164
  94. package/microservices/microservice-domains/src/db/migrations.ts +0 -60
  95. package/microservices/microservice-domains/src/index.ts +0 -65
  96. package/microservices/microservice-domains/src/lib/brandsight.ts +0 -350
  97. package/microservices/microservice-domains/src/lib/godaddy.ts +0 -338
  98. package/microservices/microservice-domains/src/lib/namecheap.ts +0 -262
  99. package/microservices/microservice-domains/src/lib/registrar.ts +0 -355
  100. package/microservices/microservice-domains/src/mcp/index.ts +0 -781
  101. package/microservices/microservice-expenses/package.json +0 -28
  102. package/microservices/microservice-expenses/src/cli/index.ts +0 -267
  103. package/microservices/microservice-expenses/src/db/database.ts +0 -91
  104. package/microservices/microservice-expenses/src/db/expenses.ts +0 -345
  105. package/microservices/microservice-expenses/src/db/migrations.ts +0 -45
  106. package/microservices/microservice-expenses/src/index.ts +0 -25
  107. package/microservices/microservice-expenses/src/mcp/index.ts +0 -196
  108. package/microservices/microservice-habits/package.json +0 -28
  109. package/microservices/microservice-habits/src/cli/index.ts +0 -315
  110. package/microservices/microservice-habits/src/db/database.ts +0 -91
  111. package/microservices/microservice-habits/src/db/habits.ts +0 -451
  112. package/microservices/microservice-habits/src/db/migrations.ts +0 -46
  113. package/microservices/microservice-habits/src/index.ts +0 -31
  114. package/microservices/microservice-habits/src/mcp/index.ts +0 -313
  115. package/microservices/microservice-health/package.json +0 -28
  116. package/microservices/microservice-health/src/cli/index.ts +0 -484
  117. package/microservices/microservice-health/src/db/database.ts +0 -91
  118. package/microservices/microservice-health/src/db/health.ts +0 -708
  119. package/microservices/microservice-health/src/db/migrations.ts +0 -70
  120. package/microservices/microservice-health/src/index.ts +0 -63
  121. package/microservices/microservice-health/src/mcp/index.ts +0 -437
  122. package/microservices/microservice-hiring/package.json +0 -28
  123. package/microservices/microservice-hiring/src/cli/index.ts +0 -741
  124. package/microservices/microservice-hiring/src/db/database.ts +0 -91
  125. package/microservices/microservice-hiring/src/db/hiring.ts +0 -1085
  126. package/microservices/microservice-hiring/src/db/migrations.ts +0 -89
  127. package/microservices/microservice-hiring/src/index.ts +0 -80
  128. package/microservices/microservice-hiring/src/lib/scoring.ts +0 -206
  129. package/microservices/microservice-hiring/src/mcp/index.ts +0 -709
  130. package/microservices/microservice-inventory/package.json +0 -28
  131. package/microservices/microservice-inventory/src/cli/index.ts +0 -365
  132. package/microservices/microservice-inventory/src/db/database.ts +0 -91
  133. package/microservices/microservice-inventory/src/db/inventory.ts +0 -393
  134. package/microservices/microservice-inventory/src/db/migrations.ts +0 -54
  135. package/microservices/microservice-inventory/src/index.ts +0 -28
  136. package/microservices/microservice-inventory/src/mcp/index.ts +0 -250
  137. package/microservices/microservice-invoices/dashboard/index.html +0 -12
  138. package/microservices/microservice-invoices/dashboard/package.json +0 -29
  139. package/microservices/microservice-invoices/dashboard/tsconfig.json +0 -14
  140. package/microservices/microservice-invoices/dashboard/vite.config.ts +0 -15
  141. package/microservices/microservice-invoices/package.json +0 -31
  142. package/microservices/microservice-invoices/src/cli/index.ts +0 -308
  143. package/microservices/microservice-invoices/src/db/business.ts +0 -241
  144. package/microservices/microservice-invoices/src/db/clients.ts +0 -127
  145. package/microservices/microservice-invoices/src/db/database.ts +0 -91
  146. package/microservices/microservice-invoices/src/db/invoices.ts +0 -345
  147. package/microservices/microservice-invoices/src/db/migrations.ts +0 -184
  148. package/microservices/microservice-invoices/src/index.ts +0 -56
  149. package/microservices/microservice-invoices/src/mcp/index.ts +0 -242
  150. package/microservices/microservice-invoices/src/server/index.ts +0 -162
  151. package/microservices/microservice-leads/package.json +0 -28
  152. package/microservices/microservice-leads/src/cli/index.ts +0 -596
  153. package/microservices/microservice-leads/src/db/database.ts +0 -91
  154. package/microservices/microservice-leads/src/db/leads.ts +0 -520
  155. package/microservices/microservice-leads/src/db/lists.ts +0 -151
  156. package/microservices/microservice-leads/src/db/migrations.ts +0 -93
  157. package/microservices/microservice-leads/src/index.ts +0 -65
  158. package/microservices/microservice-leads/src/lib/enrichment.ts +0 -202
  159. package/microservices/microservice-leads/src/lib/scoring.ts +0 -134
  160. package/microservices/microservice-leads/src/mcp/index.ts +0 -533
  161. package/microservices/microservice-notes/package.json +0 -28
  162. package/microservices/microservice-notes/src/cli/index.ts +0 -63
  163. package/microservices/microservice-notes/src/db/database.ts +0 -91
  164. package/microservices/microservice-notes/src/db/migrations.ts +0 -40
  165. package/microservices/microservice-notes/src/db/notes.ts +0 -114
  166. package/microservices/microservice-notes/src/index.ts +0 -2
  167. package/microservices/microservice-notes/src/mcp/index.ts +0 -37
  168. package/microservices/microservice-notifications/package.json +0 -28
  169. package/microservices/microservice-notifications/src/cli/index.ts +0 -349
  170. package/microservices/microservice-notifications/src/db/database.ts +0 -91
  171. package/microservices/microservice-notifications/src/db/migrations.ts +0 -62
  172. package/microservices/microservice-notifications/src/db/notifications.ts +0 -509
  173. package/microservices/microservice-notifications/src/index.ts +0 -41
  174. package/microservices/microservice-notifications/src/mcp/index.ts +0 -422
  175. package/microservices/microservice-payments/package.json +0 -28
  176. package/microservices/microservice-payments/src/cli/index.ts +0 -609
  177. package/microservices/microservice-payments/src/db/database.ts +0 -91
  178. package/microservices/microservice-payments/src/db/migrations.ts +0 -81
  179. package/microservices/microservice-payments/src/db/payments.ts +0 -1204
  180. package/microservices/microservice-payments/src/index.ts +0 -51
  181. package/microservices/microservice-payments/src/mcp/index.ts +0 -683
  182. package/microservices/microservice-payroll/package.json +0 -28
  183. package/microservices/microservice-payroll/src/cli/index.ts +0 -643
  184. package/microservices/microservice-payroll/src/db/database.ts +0 -91
  185. package/microservices/microservice-payroll/src/db/migrations.ts +0 -95
  186. package/microservices/microservice-payroll/src/db/payroll.ts +0 -1377
  187. package/microservices/microservice-payroll/src/index.ts +0 -48
  188. package/microservices/microservice-payroll/src/mcp/index.ts +0 -666
  189. package/microservices/microservice-products/package.json +0 -28
  190. package/microservices/microservice-products/src/cli/index.ts +0 -416
  191. package/microservices/microservice-products/src/db/categories.ts +0 -154
  192. package/microservices/microservice-products/src/db/database.ts +0 -91
  193. package/microservices/microservice-products/src/db/migrations.ts +0 -58
  194. package/microservices/microservice-products/src/db/pricing-tiers.ts +0 -66
  195. package/microservices/microservice-products/src/db/products.ts +0 -452
  196. package/microservices/microservice-products/src/index.ts +0 -53
  197. package/microservices/microservice-products/src/mcp/index.ts +0 -453
  198. package/microservices/microservice-projects/package.json +0 -28
  199. package/microservices/microservice-projects/src/cli/index.ts +0 -480
  200. package/microservices/microservice-projects/src/db/database.ts +0 -91
  201. package/microservices/microservice-projects/src/db/migrations.ts +0 -65
  202. package/microservices/microservice-projects/src/db/projects.ts +0 -715
  203. package/microservices/microservice-projects/src/index.ts +0 -57
  204. package/microservices/microservice-projects/src/mcp/index.ts +0 -501
  205. package/microservices/microservice-proposals/package.json +0 -28
  206. package/microservices/microservice-proposals/src/cli/index.ts +0 -400
  207. package/microservices/microservice-proposals/src/db/database.ts +0 -91
  208. package/microservices/microservice-proposals/src/db/migrations.ts +0 -52
  209. package/microservices/microservice-proposals/src/db/proposals.ts +0 -532
  210. package/microservices/microservice-proposals/src/index.ts +0 -37
  211. package/microservices/microservice-proposals/src/mcp/index.ts +0 -375
  212. package/microservices/microservice-reading/package.json +0 -28
  213. package/microservices/microservice-reading/src/cli/index.ts +0 -464
  214. package/microservices/microservice-reading/src/db/database.ts +0 -91
  215. package/microservices/microservice-reading/src/db/migrations.ts +0 -59
  216. package/microservices/microservice-reading/src/db/reading.ts +0 -524
  217. package/microservices/microservice-reading/src/index.ts +0 -51
  218. package/microservices/microservice-reading/src/mcp/index.ts +0 -368
  219. package/microservices/microservice-shipping/package.json +0 -28
  220. package/microservices/microservice-shipping/src/cli/index.ts +0 -606
  221. package/microservices/microservice-shipping/src/db/database.ts +0 -91
  222. package/microservices/microservice-shipping/src/db/migrations.ts +0 -69
  223. package/microservices/microservice-shipping/src/db/shipping.ts +0 -1093
  224. package/microservices/microservice-shipping/src/index.ts +0 -53
  225. package/microservices/microservice-shipping/src/mcp/index.ts +0 -533
  226. package/microservices/microservice-social/package.json +0 -29
  227. package/microservices/microservice-social/src/cli/index.ts +0 -1583
  228. package/microservices/microservice-social/src/db/database.ts +0 -91
  229. package/microservices/microservice-social/src/db/migrations.ts +0 -160
  230. package/microservices/microservice-social/src/db/social.ts +0 -1076
  231. package/microservices/microservice-social/src/index.ts +0 -46
  232. package/microservices/microservice-social/src/lib/audience.ts +0 -353
  233. package/microservices/microservice-social/src/lib/content-ai.ts +0 -278
  234. package/microservices/microservice-social/src/lib/media.ts +0 -311
  235. package/microservices/microservice-social/src/lib/mentions.ts +0 -434
  236. package/microservices/microservice-social/src/lib/metrics-sync.ts +0 -264
  237. package/microservices/microservice-social/src/lib/publisher.ts +0 -377
  238. package/microservices/microservice-social/src/lib/scheduler.ts +0 -229
  239. package/microservices/microservice-social/src/lib/sentiment.ts +0 -256
  240. package/microservices/microservice-social/src/lib/threads.ts +0 -291
  241. package/microservices/microservice-social/src/mcp/index.ts +0 -1425
  242. package/microservices/microservice-social/src/server/index.ts +0 -441
  243. package/microservices/microservice-subscriptions/package.json +0 -28
  244. package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
  245. package/microservices/microservice-subscriptions/src/db/database.ts +0 -91
  246. package/microservices/microservice-subscriptions/src/db/migrations.ts +0 -125
  247. package/microservices/microservice-subscriptions/src/db/subscriptions.ts +0 -1256
  248. package/microservices/microservice-subscriptions/src/index.ts +0 -41
  249. package/microservices/microservice-subscriptions/src/mcp/index.ts +0 -631
  250. package/microservices/microservice-timesheets/package.json +0 -28
  251. package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
  252. package/microservices/microservice-timesheets/src/db/database.ts +0 -91
  253. package/microservices/microservice-timesheets/src/db/locale.ts +0 -217
  254. package/microservices/microservice-timesheets/src/db/migrations.ts +0 -74
  255. package/microservices/microservice-timesheets/src/db/timesheets.ts +0 -447
  256. package/microservices/microservice-timesheets/src/index.ts +0 -44
  257. package/microservices/microservice-timesheets/src/mcp/index.ts +0 -269
  258. package/microservices/microservice-transcriber/package.json +0 -29
  259. package/microservices/microservice-transcriber/src/cli/index.ts +0 -1593
  260. package/microservices/microservice-transcriber/src/db/annotations.ts +0 -37
  261. package/microservices/microservice-transcriber/src/db/comments.ts +0 -166
  262. package/microservices/microservice-transcriber/src/db/database.ts +0 -91
  263. package/microservices/microservice-transcriber/src/db/migrations.ts +0 -118
  264. package/microservices/microservice-transcriber/src/db/proofread.ts +0 -119
  265. package/microservices/microservice-transcriber/src/db/transcripts.ts +0 -395
  266. package/microservices/microservice-transcriber/src/index.ts +0 -43
  267. package/microservices/microservice-transcriber/src/lib/config.ts +0 -77
  268. package/microservices/microservice-transcriber/src/lib/diff.ts +0 -91
  269. package/microservices/microservice-transcriber/src/lib/downloader.ts +0 -638
  270. package/microservices/microservice-transcriber/src/lib/feeds.ts +0 -62
  271. package/microservices/microservice-transcriber/src/lib/live.ts +0 -94
  272. package/microservices/microservice-transcriber/src/lib/notion.ts +0 -129
  273. package/microservices/microservice-transcriber/src/lib/proofread.ts +0 -296
  274. package/microservices/microservice-transcriber/src/lib/providers.ts +0 -713
  275. package/microservices/microservice-transcriber/src/lib/summarizer.ts +0 -147
  276. package/microservices/microservice-transcriber/src/lib/translator.ts +0 -75
  277. package/microservices/microservice-transcriber/src/lib/webhook.ts +0 -37
  278. package/microservices/microservice-transcriber/src/mcp/index.ts +0 -1330
  279. package/microservices/microservice-transcriber/src/server/index.ts +0 -199
  280. package/microservices/microservice-travel/package.json +0 -28
  281. package/microservices/microservice-travel/src/cli/index.ts +0 -505
  282. package/microservices/microservice-travel/src/db/database.ts +0 -91
  283. package/microservices/microservice-travel/src/db/migrations.ts +0 -77
  284. package/microservices/microservice-travel/src/db/travel.ts +0 -802
  285. package/microservices/microservice-travel/src/index.ts +0 -60
  286. package/microservices/microservice-travel/src/mcp/index.ts +0 -495
  287. package/microservices/microservice-wiki/package.json +0 -28
  288. package/microservices/microservice-wiki/src/cli/index.ts +0 -345
  289. package/microservices/microservice-wiki/src/db/database.ts +0 -91
  290. package/microservices/microservice-wiki/src/db/migrations.ts +0 -55
  291. package/microservices/microservice-wiki/src/db/wiki.ts +0 -395
  292. package/microservices/microservice-wiki/src/index.ts +0 -32
  293. package/microservices/microservice-wiki/src/mcp/index.ts +0 -344
@@ -1,89 +0,0 @@
1
- export interface MigrationEntry {
2
- id: number;
3
- name: string;
4
- sql: string;
5
- }
6
-
7
- export const MIGRATIONS: MigrationEntry[] = [
8
- {
9
- id: 1,
10
- name: "initial_schema",
11
- sql: `
12
- CREATE TABLE IF NOT EXISTS jobs (
13
- id TEXT PRIMARY KEY,
14
- title TEXT NOT NULL,
15
- department TEXT,
16
- location TEXT,
17
- type TEXT NOT NULL DEFAULT 'full-time' CHECK (type IN ('full-time', 'part-time', 'contract')),
18
- status TEXT NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'closed', 'paused')),
19
- description TEXT,
20
- requirements TEXT NOT NULL DEFAULT '[]',
21
- salary_range TEXT,
22
- posted_at TEXT,
23
- closed_at TEXT,
24
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
25
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
26
- );
27
-
28
- CREATE TABLE IF NOT EXISTS applicants (
29
- id TEXT PRIMARY KEY,
30
- job_id TEXT NOT NULL REFERENCES jobs(id) ON DELETE CASCADE,
31
- name TEXT NOT NULL,
32
- email TEXT,
33
- phone TEXT,
34
- resume_url TEXT,
35
- status TEXT NOT NULL DEFAULT 'applied' CHECK (status IN ('applied', 'screening', 'interviewing', 'offered', 'hired', 'rejected')),
36
- stage TEXT,
37
- rating INTEGER,
38
- notes TEXT,
39
- source TEXT,
40
- applied_at TEXT NOT NULL DEFAULT (datetime('now')),
41
- metadata TEXT NOT NULL DEFAULT '{}',
42
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
43
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
44
- );
45
-
46
- CREATE TABLE IF NOT EXISTS interviews (
47
- id TEXT PRIMARY KEY,
48
- applicant_id TEXT NOT NULL REFERENCES applicants(id) ON DELETE CASCADE,
49
- interviewer TEXT,
50
- scheduled_at TEXT,
51
- duration_min INTEGER,
52
- type TEXT NOT NULL DEFAULT 'phone' CHECK (type IN ('phone', 'video', 'onsite')),
53
- status TEXT NOT NULL DEFAULT 'scheduled' CHECK (status IN ('scheduled', 'completed', 'canceled')),
54
- feedback TEXT,
55
- rating INTEGER,
56
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
57
- );
58
-
59
- CREATE INDEX IF NOT EXISTS idx_jobs_status ON jobs(status);
60
- CREATE INDEX IF NOT EXISTS idx_jobs_department ON jobs(department);
61
- CREATE INDEX IF NOT EXISTS idx_applicants_job_id ON applicants(job_id);
62
- CREATE INDEX IF NOT EXISTS idx_applicants_status ON applicants(status);
63
- CREATE INDEX IF NOT EXISTS idx_applicants_email ON applicants(email);
64
- CREATE INDEX IF NOT EXISTS idx_interviews_applicant_id ON interviews(applicant_id);
65
- CREATE INDEX IF NOT EXISTS idx_interviews_status ON interviews(status);
66
- `,
67
- },
68
- {
69
- id: 2,
70
- name: "add_job_templates",
71
- sql: `
72
- CREATE TABLE IF NOT EXISTS job_templates (
73
- id TEXT PRIMARY KEY,
74
- name TEXT NOT NULL UNIQUE,
75
- title TEXT NOT NULL,
76
- department TEXT,
77
- location TEXT,
78
- type TEXT NOT NULL DEFAULT 'full-time' CHECK (type IN ('full-time', 'part-time', 'contract')),
79
- description TEXT,
80
- requirements TEXT NOT NULL DEFAULT '[]',
81
- salary_range TEXT,
82
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
83
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
84
- );
85
-
86
- CREATE INDEX IF NOT EXISTS idx_job_templates_name ON job_templates(name);
87
- `,
88
- },
89
- ];
@@ -1,80 +0,0 @@
1
- /**
2
- * microservice-hiring — Applicant tracking and recruitment microservice
3
- */
4
-
5
- export {
6
- createJob,
7
- getJob,
8
- listJobs,
9
- updateJob,
10
- closeJob,
11
- deleteJob,
12
- type Job,
13
- type CreateJobInput,
14
- type UpdateJobInput,
15
- type ListJobsOptions,
16
- } from "./db/hiring.js";
17
-
18
- export {
19
- createApplicant,
20
- getApplicant,
21
- listApplicants,
22
- updateApplicant,
23
- advanceApplicant,
24
- rejectApplicant,
25
- deleteApplicant,
26
- searchApplicants,
27
- listByStage,
28
- getPipeline,
29
- getHiringStats,
30
- type Applicant,
31
- type CreateApplicantInput,
32
- type UpdateApplicantInput,
33
- type ListApplicantsOptions,
34
- type PipelineEntry,
35
- type HiringStats,
36
- } from "./db/hiring.js";
37
-
38
- export {
39
- createInterview,
40
- getInterview,
41
- listInterviews,
42
- updateInterview,
43
- addInterviewFeedback,
44
- deleteInterview,
45
- type Interview,
46
- type CreateInterviewInput,
47
- type UpdateInterviewInput,
48
- type ListInterviewsOptions,
49
- } from "./db/hiring.js";
50
-
51
- export {
52
- bulkImportApplicants,
53
- generateOffer,
54
- getHiringForecast,
55
- submitStructuredFeedback,
56
- bulkReject,
57
- getReferralStats,
58
- saveJobAsTemplate,
59
- getJobTemplate,
60
- getJobTemplateByName,
61
- listJobTemplates,
62
- createJobFromTemplate,
63
- deleteJobTemplate,
64
- type BulkImportResult,
65
- type OfferDetails,
66
- type HiringForecast,
67
- type StructuredFeedback,
68
- type BulkRejectResult,
69
- type ReferralStats,
70
- type JobTemplate,
71
- } from "./db/hiring.js";
72
-
73
- export {
74
- scoreApplicant,
75
- rankApplicants,
76
- type ScoreResult,
77
- type RankEntry,
78
- } from "./lib/scoring.js";
79
-
80
- export { getDatabase, closeDatabase } from "./db/database.js";
@@ -1,206 +0,0 @@
1
- /**
2
- * AI resume scoring — uses OpenAI or Anthropic to evaluate applicant fit
3
- */
4
-
5
- import { getApplicant, getJob, updateApplicant } from "../db/hiring.js";
6
- import type { Applicant, Job } from "../db/hiring.js";
7
-
8
- export interface ScoreResult {
9
- match_pct: number;
10
- strengths: string[];
11
- gaps: string[];
12
- recommendation: string;
13
- }
14
-
15
- export interface RankEntry {
16
- applicant: Applicant;
17
- score: ScoreResult;
18
- }
19
-
20
- // ---- Provider abstraction ----
21
-
22
- async function callAI(prompt: string): Promise<string> {
23
- // Try Anthropic first, then OpenAI
24
- const anthropicKey = process.env["ANTHROPIC_API_KEY"];
25
- const openaiKey = process.env["OPENAI_API_KEY"];
26
-
27
- if (anthropicKey) {
28
- return callAnthropic(anthropicKey, prompt);
29
- }
30
- if (openaiKey) {
31
- return callOpenAI(openaiKey, prompt);
32
- }
33
-
34
- throw new Error(
35
- "No AI API key found. Set ANTHROPIC_API_KEY or OPENAI_API_KEY environment variable."
36
- );
37
- }
38
-
39
- async function callAnthropic(apiKey: string, prompt: string): Promise<string> {
40
- const response = await fetch("https://api.anthropic.com/v1/messages", {
41
- method: "POST",
42
- headers: {
43
- "Content-Type": "application/json",
44
- "x-api-key": apiKey,
45
- "anthropic-version": "2023-06-01",
46
- },
47
- body: JSON.stringify({
48
- model: "claude-sonnet-4-20250514",
49
- max_tokens: 1024,
50
- messages: [{ role: "user", content: prompt }],
51
- }),
52
- });
53
-
54
- if (!response.ok) {
55
- const text = await response.text();
56
- throw new Error(`Anthropic API error ${response.status}: ${text}`);
57
- }
58
-
59
- const data = (await response.json()) as {
60
- content: Array<{ type: string; text: string }>;
61
- };
62
- return data.content[0]?.text || "";
63
- }
64
-
65
- async function callOpenAI(apiKey: string, prompt: string): Promise<string> {
66
- const response = await fetch("https://api.openai.com/v1/chat/completions", {
67
- method: "POST",
68
- headers: {
69
- "Content-Type": "application/json",
70
- Authorization: `Bearer ${apiKey}`,
71
- },
72
- body: JSON.stringify({
73
- model: "gpt-4o-mini",
74
- messages: [{ role: "user", content: prompt }],
75
- max_tokens: 1024,
76
- }),
77
- });
78
-
79
- if (!response.ok) {
80
- const text = await response.text();
81
- throw new Error(`OpenAI API error ${response.status}: ${text}`);
82
- }
83
-
84
- const data = (await response.json()) as {
85
- choices: Array<{ message: { content: string } }>;
86
- };
87
- return data.choices[0]?.message?.content || "";
88
- }
89
-
90
- // ---- Scoring ----
91
-
92
- function buildScoringPrompt(job: Job, applicant: Applicant): string {
93
- const requirements = job.requirements.length
94
- ? job.requirements.join(", ")
95
- : "No specific requirements listed";
96
-
97
- const applicantInfo = [
98
- `Name: ${applicant.name}`,
99
- applicant.resume_url ? `Resume: ${applicant.resume_url}` : null,
100
- applicant.notes ? `Notes/Summary: ${applicant.notes}` : null,
101
- applicant.source ? `Source: ${applicant.source}` : null,
102
- applicant.stage ? `Current stage: ${applicant.stage}` : null,
103
- Object.keys(applicant.metadata).length > 0
104
- ? `Additional info: ${JSON.stringify(applicant.metadata)}`
105
- : null,
106
- ]
107
- .filter(Boolean)
108
- .join("\n");
109
-
110
- return `You are an expert hiring evaluator. Analyze this applicant against the job requirements and return a JSON assessment.
111
-
112
- JOB:
113
- Title: ${job.title}
114
- Department: ${job.department || "N/A"}
115
- Description: ${job.description || "N/A"}
116
- Requirements: ${requirements}
117
- Salary Range: ${job.salary_range || "N/A"}
118
-
119
- APPLICANT:
120
- ${applicantInfo}
121
-
122
- Return ONLY a valid JSON object (no markdown, no code fences) with this exact structure:
123
- {
124
- "match_pct": <number 0-100>,
125
- "strengths": ["strength1", "strength2"],
126
- "gaps": ["gap1", "gap2"],
127
- "recommendation": "<hire/strong_hire/no_hire/maybe> — brief explanation"
128
- }`;
129
- }
130
-
131
- function parseScoreResponse(text: string): ScoreResult {
132
- // Strip markdown code fences if present
133
- let cleaned = text.trim();
134
- if (cleaned.startsWith("```")) {
135
- cleaned = cleaned.replace(/^```(?:json)?\s*\n?/, "").replace(/\n?```\s*$/, "");
136
- }
137
-
138
- try {
139
- const parsed = JSON.parse(cleaned);
140
- return {
141
- match_pct: Math.max(0, Math.min(100, Number(parsed.match_pct) || 0)),
142
- strengths: Array.isArray(parsed.strengths) ? parsed.strengths : [],
143
- gaps: Array.isArray(parsed.gaps) ? parsed.gaps : [],
144
- recommendation: String(parsed.recommendation || "Unable to determine"),
145
- };
146
- } catch {
147
- return {
148
- match_pct: 0,
149
- strengths: [],
150
- gaps: [],
151
- recommendation: `AI response could not be parsed: ${text.slice(0, 200)}`,
152
- };
153
- }
154
- }
155
-
156
- export async function scoreApplicant(applicantId: string): Promise<ScoreResult> {
157
- const applicant = getApplicant(applicantId);
158
- if (!applicant) throw new Error(`Applicant '${applicantId}' not found`);
159
-
160
- const job = getJob(applicant.job_id);
161
- if (!job) throw new Error(`Job '${applicant.job_id}' not found`);
162
-
163
- const prompt = buildScoringPrompt(job, applicant);
164
- const response = await callAI(prompt);
165
- const score = parseScoreResponse(response);
166
-
167
- // Store in applicant metadata
168
- const metadata = { ...applicant.metadata, ai_score: score, scored_at: new Date().toISOString() };
169
- updateApplicant(applicantId, { metadata });
170
-
171
- return score;
172
- }
173
-
174
- export async function rankApplicants(jobId: string): Promise<RankEntry[]> {
175
- const job = getJob(jobId);
176
- if (!job) throw new Error(`Job '${jobId}' not found`);
177
-
178
- const applicants = (await import("../db/hiring.js")).listApplicants({ job_id: jobId });
179
-
180
- const results: RankEntry[] = [];
181
-
182
- for (const applicant of applicants) {
183
- // Use cached score if available and recent (less than 24h old)
184
- const cached = applicant.metadata?.ai_score as ScoreResult | undefined;
185
- const cachedAt = applicant.metadata?.scored_at as string | undefined;
186
- const isFresh =
187
- cachedAt && Date.now() - new Date(cachedAt).getTime() < 24 * 60 * 60 * 1000;
188
-
189
- if (cached && isFresh) {
190
- results.push({ applicant, score: cached });
191
- } else {
192
- const score = await scoreApplicant(applicant.id);
193
- // Re-fetch to get updated metadata
194
- const updated = getApplicant(applicant.id)!;
195
- results.push({ applicant: updated, score });
196
- }
197
- }
198
-
199
- // Sort by match_pct descending
200
- results.sort((a, b) => b.score.match_pct - a.score.match_pct);
201
-
202
- return results;
203
- }
204
-
205
- // Exported for testing
206
- export { buildScoringPrompt, parseScoreResponse, callAI };