@hasna/microservices 0.0.2 → 0.0.4
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.
- package/bin/index.js +70 -0
- package/bin/mcp.js +71 -1
- package/dist/index.js +70 -0
- package/microservices/microservice-ads/package.json +27 -0
- package/microservices/microservice-ads/src/cli/index.ts +407 -0
- package/microservices/microservice-ads/src/db/campaigns.ts +493 -0
- package/microservices/microservice-ads/src/db/database.ts +93 -0
- package/microservices/microservice-ads/src/db/migrations.ts +60 -0
- package/microservices/microservice-ads/src/index.ts +39 -0
- package/microservices/microservice-ads/src/mcp/index.ts +320 -0
- package/microservices/microservice-contracts/package.json +27 -0
- package/microservices/microservice-contracts/src/cli/index.ts +383 -0
- package/microservices/microservice-contracts/src/db/contracts.ts +496 -0
- package/microservices/microservice-contracts/src/db/database.ts +93 -0
- package/microservices/microservice-contracts/src/db/migrations.ts +58 -0
- package/microservices/microservice-contracts/src/index.ts +43 -0
- package/microservices/microservice-contracts/src/mcp/index.ts +308 -0
- package/microservices/microservice-domains/package.json +27 -0
- package/microservices/microservice-domains/src/cli/index.ts +438 -0
- package/microservices/microservice-domains/src/db/database.ts +93 -0
- package/microservices/microservice-domains/src/db/domains.ts +551 -0
- package/microservices/microservice-domains/src/db/migrations.ts +60 -0
- package/microservices/microservice-domains/src/index.ts +44 -0
- package/microservices/microservice-domains/src/mcp/index.ts +368 -0
- package/microservices/microservice-hiring/package.json +27 -0
- package/microservices/microservice-hiring/src/cli/index.ts +431 -0
- package/microservices/microservice-hiring/src/db/database.ts +93 -0
- package/microservices/microservice-hiring/src/db/hiring.ts +582 -0
- package/microservices/microservice-hiring/src/db/migrations.ts +68 -0
- package/microservices/microservice-hiring/src/index.ts +51 -0
- package/microservices/microservice-hiring/src/mcp/index.ts +464 -0
- package/microservices/microservice-payments/package.json +27 -0
- package/microservices/microservice-payments/src/cli/index.ts +357 -0
- package/microservices/microservice-payments/src/db/database.ts +93 -0
- package/microservices/microservice-payments/src/db/migrations.ts +63 -0
- package/microservices/microservice-payments/src/db/payments.ts +652 -0
- package/microservices/microservice-payments/src/index.ts +51 -0
- package/microservices/microservice-payments/src/mcp/index.ts +460 -0
- package/microservices/microservice-payroll/package.json +27 -0
- package/microservices/microservice-payroll/src/cli/index.ts +374 -0
- package/microservices/microservice-payroll/src/db/database.ts +93 -0
- package/microservices/microservice-payroll/src/db/migrations.ts +69 -0
- package/microservices/microservice-payroll/src/db/payroll.ts +741 -0
- package/microservices/microservice-payroll/src/index.ts +48 -0
- package/microservices/microservice-payroll/src/mcp/index.ts +420 -0
- package/microservices/microservice-shipping/package.json +27 -0
- package/microservices/microservice-shipping/src/cli/index.ts +398 -0
- package/microservices/microservice-shipping/src/db/database.ts +93 -0
- package/microservices/microservice-shipping/src/db/migrations.ts +61 -0
- package/microservices/microservice-shipping/src/db/shipping.ts +643 -0
- package/microservices/microservice-shipping/src/index.ts +53 -0
- package/microservices/microservice-shipping/src/mcp/index.ts +385 -0
- package/microservices/microservice-social/package.json +27 -0
- package/microservices/microservice-social/src/cli/index.ts +447 -0
- package/microservices/microservice-social/src/db/database.ts +93 -0
- package/microservices/microservice-social/src/db/migrations.ts +55 -0
- package/microservices/microservice-social/src/db/social.ts +672 -0
- package/microservices/microservice-social/src/index.ts +46 -0
- package/microservices/microservice-social/src/mcp/index.ts +435 -0
- package/microservices/microservice-subscriptions/package.json +27 -0
- package/microservices/microservice-subscriptions/src/cli/index.ts +400 -0
- package/microservices/microservice-subscriptions/src/db/database.ts +93 -0
- package/microservices/microservice-subscriptions/src/db/migrations.ts +57 -0
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +692 -0
- package/microservices/microservice-subscriptions/src/index.ts +41 -0
- package/microservices/microservice-subscriptions/src/mcp/index.ts +365 -0
- package/microservices/microservice-transcriber/package.json +28 -0
- package/microservices/microservice-transcriber/src/cli/index.ts +1347 -0
- package/microservices/microservice-transcriber/src/db/annotations.ts +37 -0
- package/microservices/microservice-transcriber/src/db/database.ts +82 -0
- package/microservices/microservice-transcriber/src/db/migrations.ts +72 -0
- package/microservices/microservice-transcriber/src/db/transcripts.ts +395 -0
- package/microservices/microservice-transcriber/src/index.ts +43 -0
- package/microservices/microservice-transcriber/src/lib/config.ts +77 -0
- package/microservices/microservice-transcriber/src/lib/diff.ts +91 -0
- package/microservices/microservice-transcriber/src/lib/downloader.ts +570 -0
- package/microservices/microservice-transcriber/src/lib/feeds.ts +62 -0
- package/microservices/microservice-transcriber/src/lib/live.ts +94 -0
- package/microservices/microservice-transcriber/src/lib/notion.ts +129 -0
- package/microservices/microservice-transcriber/src/lib/providers.ts +713 -0
- package/microservices/microservice-transcriber/src/lib/summarizer.ts +147 -0
- package/microservices/microservice-transcriber/src/lib/translator.ts +75 -0
- package/microservices/microservice-transcriber/src/lib/webhook.ts +37 -0
- package/microservices/microservice-transcriber/src/mcp/index.ts +1070 -0
- package/microservices/microservice-transcriber/src/server/index.ts +199 -0
- package/package.json +1 -1
- package/microservices/microservice-invoices/dashboard/dist/assets/index-Bngq7FNM.css +0 -1
- package/microservices/microservice-invoices/dashboard/dist/assets/index-aHW4ARZR.js +0 -124
- package/microservices/microservice-invoices/dashboard/dist/index.html +0 -13
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import {
|
|
5
|
+
createJob,
|
|
6
|
+
getJob,
|
|
7
|
+
listJobs,
|
|
8
|
+
closeJob,
|
|
9
|
+
createApplicant,
|
|
10
|
+
getApplicant,
|
|
11
|
+
listApplicants,
|
|
12
|
+
advanceApplicant,
|
|
13
|
+
rejectApplicant,
|
|
14
|
+
searchApplicants,
|
|
15
|
+
getPipeline,
|
|
16
|
+
getHiringStats,
|
|
17
|
+
createInterview,
|
|
18
|
+
listInterviews,
|
|
19
|
+
addInterviewFeedback,
|
|
20
|
+
} from "../db/hiring.js";
|
|
21
|
+
|
|
22
|
+
const program = new Command();
|
|
23
|
+
|
|
24
|
+
program
|
|
25
|
+
.name("microservice-hiring")
|
|
26
|
+
.description("Applicant tracking and recruitment microservice")
|
|
27
|
+
.version("0.0.1");
|
|
28
|
+
|
|
29
|
+
// --- Jobs ---
|
|
30
|
+
|
|
31
|
+
const jobCmd = program
|
|
32
|
+
.command("job")
|
|
33
|
+
.description("Job management");
|
|
34
|
+
|
|
35
|
+
jobCmd
|
|
36
|
+
.command("create")
|
|
37
|
+
.description("Create a new job posting")
|
|
38
|
+
.requiredOption("--title <title>", "Job title")
|
|
39
|
+
.option("--department <dept>", "Department")
|
|
40
|
+
.option("--location <loc>", "Location")
|
|
41
|
+
.option("--type <type>", "Job type (full-time/part-time/contract)", "full-time")
|
|
42
|
+
.option("--description <desc>", "Job description")
|
|
43
|
+
.option("--requirements <reqs>", "Comma-separated requirements")
|
|
44
|
+
.option("--salary-range <range>", "Salary range")
|
|
45
|
+
.option("--json", "Output as JSON", false)
|
|
46
|
+
.action((opts) => {
|
|
47
|
+
const job = createJob({
|
|
48
|
+
title: opts.title,
|
|
49
|
+
department: opts.department,
|
|
50
|
+
location: opts.location,
|
|
51
|
+
type: opts.type,
|
|
52
|
+
description: opts.description,
|
|
53
|
+
requirements: opts.requirements
|
|
54
|
+
? opts.requirements.split(",").map((r: string) => r.trim())
|
|
55
|
+
: undefined,
|
|
56
|
+
salary_range: opts.salaryRange,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (opts.json) {
|
|
60
|
+
console.log(JSON.stringify(job, null, 2));
|
|
61
|
+
} else {
|
|
62
|
+
console.log(`Created job: ${job.title} (${job.id})`);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
jobCmd
|
|
67
|
+
.command("list")
|
|
68
|
+
.description("List jobs")
|
|
69
|
+
.option("--status <status>", "Filter by status (open/closed/paused)")
|
|
70
|
+
.option("--department <dept>", "Filter by department")
|
|
71
|
+
.option("--type <type>", "Filter by type")
|
|
72
|
+
.option("--limit <n>", "Limit results")
|
|
73
|
+
.option("--json", "Output as JSON", false)
|
|
74
|
+
.action((opts) => {
|
|
75
|
+
const jobs = listJobs({
|
|
76
|
+
status: opts.status,
|
|
77
|
+
department: opts.department,
|
|
78
|
+
type: opts.type,
|
|
79
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (opts.json) {
|
|
83
|
+
console.log(JSON.stringify(jobs, null, 2));
|
|
84
|
+
} else {
|
|
85
|
+
if (jobs.length === 0) {
|
|
86
|
+
console.log("No jobs found.");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
for (const j of jobs) {
|
|
90
|
+
const dept = j.department ? ` [${j.department}]` : "";
|
|
91
|
+
console.log(` ${j.title}${dept} — ${j.status} (${j.id})`);
|
|
92
|
+
}
|
|
93
|
+
console.log(`\n${jobs.length} job(s)`);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
jobCmd
|
|
98
|
+
.command("get")
|
|
99
|
+
.description("Get a job by ID")
|
|
100
|
+
.argument("<id>", "Job ID")
|
|
101
|
+
.option("--json", "Output as JSON", false)
|
|
102
|
+
.action((id, opts) => {
|
|
103
|
+
const job = getJob(id);
|
|
104
|
+
if (!job) {
|
|
105
|
+
console.error(`Job '${id}' not found.`);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (opts.json) {
|
|
110
|
+
console.log(JSON.stringify(job, null, 2));
|
|
111
|
+
} else {
|
|
112
|
+
console.log(`${job.title}`);
|
|
113
|
+
console.log(` Status: ${job.status}`);
|
|
114
|
+
console.log(` Type: ${job.type}`);
|
|
115
|
+
if (job.department) console.log(` Department: ${job.department}`);
|
|
116
|
+
if (job.location) console.log(` Location: ${job.location}`);
|
|
117
|
+
if (job.salary_range) console.log(` Salary: ${job.salary_range}`);
|
|
118
|
+
if (job.description) console.log(` Description: ${job.description}`);
|
|
119
|
+
if (job.requirements.length) console.log(` Requirements: ${job.requirements.join(", ")}`);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
jobCmd
|
|
124
|
+
.command("close")
|
|
125
|
+
.description("Close a job posting")
|
|
126
|
+
.argument("<id>", "Job ID")
|
|
127
|
+
.option("--json", "Output as JSON", false)
|
|
128
|
+
.action((id, opts) => {
|
|
129
|
+
const job = closeJob(id);
|
|
130
|
+
if (!job) {
|
|
131
|
+
console.error(`Job '${id}' not found.`);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (opts.json) {
|
|
136
|
+
console.log(JSON.stringify(job, null, 2));
|
|
137
|
+
} else {
|
|
138
|
+
console.log(`Closed job: ${job.title}`);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// --- Applicants ---
|
|
143
|
+
|
|
144
|
+
const applicantCmd = program
|
|
145
|
+
.command("applicant")
|
|
146
|
+
.description("Applicant management");
|
|
147
|
+
|
|
148
|
+
applicantCmd
|
|
149
|
+
.command("add")
|
|
150
|
+
.description("Add a new applicant")
|
|
151
|
+
.requiredOption("--name <name>", "Applicant name")
|
|
152
|
+
.requiredOption("--job <id>", "Job ID")
|
|
153
|
+
.option("--email <email>", "Email address")
|
|
154
|
+
.option("--phone <phone>", "Phone number")
|
|
155
|
+
.option("--resume <url>", "Resume URL")
|
|
156
|
+
.option("--source <source>", "Source (linkedin, referral, etc.)")
|
|
157
|
+
.option("--notes <notes>", "Notes")
|
|
158
|
+
.option("--json", "Output as JSON", false)
|
|
159
|
+
.action((opts) => {
|
|
160
|
+
const applicant = createApplicant({
|
|
161
|
+
name: opts.name,
|
|
162
|
+
job_id: opts.job,
|
|
163
|
+
email: opts.email,
|
|
164
|
+
phone: opts.phone,
|
|
165
|
+
resume_url: opts.resume,
|
|
166
|
+
source: opts.source,
|
|
167
|
+
notes: opts.notes,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (opts.json) {
|
|
171
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
172
|
+
} else {
|
|
173
|
+
console.log(`Added applicant: ${applicant.name} (${applicant.id})`);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
applicantCmd
|
|
178
|
+
.command("list")
|
|
179
|
+
.description("List applicants")
|
|
180
|
+
.option("--job <id>", "Filter by job ID")
|
|
181
|
+
.option("--status <status>", "Filter by status")
|
|
182
|
+
.option("--source <source>", "Filter by source")
|
|
183
|
+
.option("--limit <n>", "Limit results")
|
|
184
|
+
.option("--json", "Output as JSON", false)
|
|
185
|
+
.action((opts) => {
|
|
186
|
+
const applicants = listApplicants({
|
|
187
|
+
job_id: opts.job,
|
|
188
|
+
status: opts.status,
|
|
189
|
+
source: opts.source,
|
|
190
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (opts.json) {
|
|
194
|
+
console.log(JSON.stringify(applicants, null, 2));
|
|
195
|
+
} else {
|
|
196
|
+
if (applicants.length === 0) {
|
|
197
|
+
console.log("No applicants found.");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
for (const a of applicants) {
|
|
201
|
+
const email = a.email ? ` <${a.email}>` : "";
|
|
202
|
+
console.log(` ${a.name}${email} — ${a.status} (${a.id})`);
|
|
203
|
+
}
|
|
204
|
+
console.log(`\n${applicants.length} applicant(s)`);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
applicantCmd
|
|
209
|
+
.command("get")
|
|
210
|
+
.description("Get an applicant by ID")
|
|
211
|
+
.argument("<id>", "Applicant ID")
|
|
212
|
+
.option("--json", "Output as JSON", false)
|
|
213
|
+
.action((id, opts) => {
|
|
214
|
+
const applicant = getApplicant(id);
|
|
215
|
+
if (!applicant) {
|
|
216
|
+
console.error(`Applicant '${id}' not found.`);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (opts.json) {
|
|
221
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
222
|
+
} else {
|
|
223
|
+
console.log(`${applicant.name}`);
|
|
224
|
+
console.log(` Status: ${applicant.status}`);
|
|
225
|
+
if (applicant.email) console.log(` Email: ${applicant.email}`);
|
|
226
|
+
if (applicant.phone) console.log(` Phone: ${applicant.phone}`);
|
|
227
|
+
if (applicant.source) console.log(` Source: ${applicant.source}`);
|
|
228
|
+
if (applicant.rating) console.log(` Rating: ${applicant.rating}`);
|
|
229
|
+
if (applicant.notes) console.log(` Notes: ${applicant.notes}`);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
applicantCmd
|
|
234
|
+
.command("advance")
|
|
235
|
+
.description("Advance an applicant to a new status")
|
|
236
|
+
.argument("<id>", "Applicant ID")
|
|
237
|
+
.requiredOption("--status <status>", "New status (screening/interviewing/offered/hired)")
|
|
238
|
+
.option("--json", "Output as JSON", false)
|
|
239
|
+
.action((id, opts) => {
|
|
240
|
+
const applicant = advanceApplicant(id, opts.status);
|
|
241
|
+
if (!applicant) {
|
|
242
|
+
console.error(`Applicant '${id}' not found.`);
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (opts.json) {
|
|
247
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
248
|
+
} else {
|
|
249
|
+
console.log(`Advanced ${applicant.name} to ${applicant.status}`);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
applicantCmd
|
|
254
|
+
.command("reject")
|
|
255
|
+
.description("Reject an applicant")
|
|
256
|
+
.argument("<id>", "Applicant ID")
|
|
257
|
+
.option("--reason <reason>", "Rejection reason")
|
|
258
|
+
.option("--json", "Output as JSON", false)
|
|
259
|
+
.action((id, opts) => {
|
|
260
|
+
const applicant = rejectApplicant(id, opts.reason);
|
|
261
|
+
if (!applicant) {
|
|
262
|
+
console.error(`Applicant '${id}' not found.`);
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (opts.json) {
|
|
267
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
268
|
+
} else {
|
|
269
|
+
console.log(`Rejected ${applicant.name}`);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
applicantCmd
|
|
274
|
+
.command("search")
|
|
275
|
+
.description("Search applicants")
|
|
276
|
+
.argument("<query>", "Search term")
|
|
277
|
+
.option("--json", "Output as JSON", false)
|
|
278
|
+
.action((query, opts) => {
|
|
279
|
+
const results = searchApplicants(query);
|
|
280
|
+
|
|
281
|
+
if (opts.json) {
|
|
282
|
+
console.log(JSON.stringify(results, null, 2));
|
|
283
|
+
} else {
|
|
284
|
+
if (results.length === 0) {
|
|
285
|
+
console.log(`No applicants matching "${query}".`);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
for (const a of results) {
|
|
289
|
+
console.log(` ${a.name} ${a.email ? `<${a.email}>` : ""} — ${a.status}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// --- Interviews ---
|
|
295
|
+
|
|
296
|
+
const interviewCmd = program
|
|
297
|
+
.command("interview")
|
|
298
|
+
.description("Interview management");
|
|
299
|
+
|
|
300
|
+
interviewCmd
|
|
301
|
+
.command("schedule")
|
|
302
|
+
.description("Schedule an interview")
|
|
303
|
+
.requiredOption("--applicant <id>", "Applicant ID")
|
|
304
|
+
.option("--interviewer <name>", "Interviewer name")
|
|
305
|
+
.option("--at <datetime>", "Scheduled datetime (ISO 8601)")
|
|
306
|
+
.option("--duration <min>", "Duration in minutes")
|
|
307
|
+
.option("--type <type>", "Interview type (phone/video/onsite)", "phone")
|
|
308
|
+
.option("--json", "Output as JSON", false)
|
|
309
|
+
.action((opts) => {
|
|
310
|
+
const interview = createInterview({
|
|
311
|
+
applicant_id: opts.applicant,
|
|
312
|
+
interviewer: opts.interviewer,
|
|
313
|
+
scheduled_at: opts.at,
|
|
314
|
+
duration_min: opts.duration ? parseInt(opts.duration) : undefined,
|
|
315
|
+
type: opts.type,
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
if (opts.json) {
|
|
319
|
+
console.log(JSON.stringify(interview, null, 2));
|
|
320
|
+
} else {
|
|
321
|
+
console.log(`Scheduled interview (${interview.id})`);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
interviewCmd
|
|
326
|
+
.command("list")
|
|
327
|
+
.description("List interviews")
|
|
328
|
+
.option("--applicant <id>", "Filter by applicant ID")
|
|
329
|
+
.option("--status <status>", "Filter by status")
|
|
330
|
+
.option("--type <type>", "Filter by type")
|
|
331
|
+
.option("--limit <n>", "Limit results")
|
|
332
|
+
.option("--json", "Output as JSON", false)
|
|
333
|
+
.action((opts) => {
|
|
334
|
+
const interviews = listInterviews({
|
|
335
|
+
applicant_id: opts.applicant,
|
|
336
|
+
status: opts.status,
|
|
337
|
+
type: opts.type,
|
|
338
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
if (opts.json) {
|
|
342
|
+
console.log(JSON.stringify(interviews, null, 2));
|
|
343
|
+
} else {
|
|
344
|
+
if (interviews.length === 0) {
|
|
345
|
+
console.log("No interviews found.");
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
for (const i of interviews) {
|
|
349
|
+
const when = i.scheduled_at || "TBD";
|
|
350
|
+
const who = i.interviewer || "TBD";
|
|
351
|
+
console.log(` ${i.type} with ${who} @ ${when} — ${i.status} (${i.id})`);
|
|
352
|
+
}
|
|
353
|
+
console.log(`\n${interviews.length} interview(s)`);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
interviewCmd
|
|
358
|
+
.command("feedback")
|
|
359
|
+
.description("Add feedback to an interview")
|
|
360
|
+
.argument("<id>", "Interview ID")
|
|
361
|
+
.requiredOption("--feedback <text>", "Feedback text")
|
|
362
|
+
.option("--rating <n>", "Rating (1-5)")
|
|
363
|
+
.option("--json", "Output as JSON", false)
|
|
364
|
+
.action((id, opts) => {
|
|
365
|
+
const interview = addInterviewFeedback(
|
|
366
|
+
id,
|
|
367
|
+
opts.feedback,
|
|
368
|
+
opts.rating ? parseInt(opts.rating) : undefined
|
|
369
|
+
);
|
|
370
|
+
if (!interview) {
|
|
371
|
+
console.error(`Interview '${id}' not found.`);
|
|
372
|
+
process.exit(1);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (opts.json) {
|
|
376
|
+
console.log(JSON.stringify(interview, null, 2));
|
|
377
|
+
} else {
|
|
378
|
+
console.log(`Added feedback to interview ${id}`);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// --- Pipeline & Stats ---
|
|
383
|
+
|
|
384
|
+
program
|
|
385
|
+
.command("pipeline")
|
|
386
|
+
.description("Show hiring pipeline for a job")
|
|
387
|
+
.argument("<job-id>", "Job ID")
|
|
388
|
+
.option("--json", "Output as JSON", false)
|
|
389
|
+
.action((jobId, opts) => {
|
|
390
|
+
const pipeline = getPipeline(jobId);
|
|
391
|
+
|
|
392
|
+
if (opts.json) {
|
|
393
|
+
console.log(JSON.stringify(pipeline, null, 2));
|
|
394
|
+
} else {
|
|
395
|
+
if (pipeline.length === 0) {
|
|
396
|
+
console.log("No applicants in pipeline.");
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
console.log("Pipeline:");
|
|
400
|
+
for (const p of pipeline) {
|
|
401
|
+
const bar = "#".repeat(p.count);
|
|
402
|
+
console.log(` ${p.status.padEnd(14)} ${bar} (${p.count})`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
program
|
|
408
|
+
.command("stats")
|
|
409
|
+
.description("Show hiring statistics")
|
|
410
|
+
.option("--json", "Output as JSON", false)
|
|
411
|
+
.action((opts) => {
|
|
412
|
+
const stats = getHiringStats();
|
|
413
|
+
|
|
414
|
+
if (opts.json) {
|
|
415
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
416
|
+
} else {
|
|
417
|
+
console.log("Hiring Stats:");
|
|
418
|
+
console.log(` Jobs: ${stats.total_jobs} total, ${stats.open_jobs} open`);
|
|
419
|
+
console.log(` Applicants: ${stats.total_applicants}`);
|
|
420
|
+
console.log(` Interviews: ${stats.total_interviews}`);
|
|
421
|
+
if (stats.avg_rating) console.log(` Avg Rating: ${stats.avg_rating}`);
|
|
422
|
+
if (stats.applicants_by_status.length) {
|
|
423
|
+
console.log(" By Status:");
|
|
424
|
+
for (const s of stats.applicants_by_status) {
|
|
425
|
+
console.log(` ${s.status}: ${s.count}`);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database connection for microservice-hiring
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Database } from "bun:sqlite";
|
|
6
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
7
|
+
import { dirname, join, resolve } from "node:path";
|
|
8
|
+
import { MIGRATIONS } from "./migrations.js";
|
|
9
|
+
|
|
10
|
+
let _db: Database | null = null;
|
|
11
|
+
|
|
12
|
+
function getDbPath(): string {
|
|
13
|
+
// Environment variable override
|
|
14
|
+
if (process.env["MICROSERVICES_DIR"]) {
|
|
15
|
+
return join(process.env["MICROSERVICES_DIR"], "microservice-hiring", "data.db");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Check for .microservices in current or parent directories
|
|
19
|
+
let dir = resolve(process.cwd());
|
|
20
|
+
while (true) {
|
|
21
|
+
const candidate = join(dir, ".microservices", "microservice-hiring", "data.db");
|
|
22
|
+
const msDir = join(dir, ".microservices");
|
|
23
|
+
if (existsSync(msDir)) return candidate;
|
|
24
|
+
const parent = dirname(dir);
|
|
25
|
+
if (parent === dir) break;
|
|
26
|
+
dir = parent;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Global fallback
|
|
30
|
+
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
31
|
+
return join(home, ".microservices", "microservice-hiring", "data.db");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function ensureDir(filePath: string): void {
|
|
35
|
+
const dir = dirname(resolve(filePath));
|
|
36
|
+
if (!existsSync(dir)) {
|
|
37
|
+
mkdirSync(dir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getDatabase(): Database {
|
|
42
|
+
if (_db) return _db;
|
|
43
|
+
|
|
44
|
+
const dbPath = getDbPath();
|
|
45
|
+
ensureDir(dbPath);
|
|
46
|
+
|
|
47
|
+
_db = new Database(dbPath);
|
|
48
|
+
_db.exec("PRAGMA journal_mode = WAL");
|
|
49
|
+
_db.exec("PRAGMA foreign_keys = ON");
|
|
50
|
+
|
|
51
|
+
// Create migrations table
|
|
52
|
+
_db.exec(`
|
|
53
|
+
CREATE TABLE IF NOT EXISTS _migrations (
|
|
54
|
+
id INTEGER PRIMARY KEY,
|
|
55
|
+
name TEXT NOT NULL,
|
|
56
|
+
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
57
|
+
)
|
|
58
|
+
`);
|
|
59
|
+
|
|
60
|
+
// Apply pending migrations
|
|
61
|
+
const applied = _db
|
|
62
|
+
.query("SELECT id FROM _migrations ORDER BY id")
|
|
63
|
+
.all() as { id: number }[];
|
|
64
|
+
const appliedIds = new Set(applied.map((r) => r.id));
|
|
65
|
+
|
|
66
|
+
for (const migration of MIGRATIONS) {
|
|
67
|
+
if (appliedIds.has(migration.id)) continue;
|
|
68
|
+
|
|
69
|
+
_db.exec("BEGIN");
|
|
70
|
+
try {
|
|
71
|
+
_db.exec(migration.sql);
|
|
72
|
+
_db.prepare("INSERT INTO _migrations (id, name) VALUES (?, ?)").run(
|
|
73
|
+
migration.id,
|
|
74
|
+
migration.name
|
|
75
|
+
);
|
|
76
|
+
_db.exec("COMMIT");
|
|
77
|
+
} catch (error) {
|
|
78
|
+
_db.exec("ROLLBACK");
|
|
79
|
+
throw new Error(
|
|
80
|
+
`Migration ${migration.id} (${migration.name}) failed: ${error instanceof Error ? error.message : String(error)}`
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return _db;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function closeDatabase(): void {
|
|
89
|
+
if (_db) {
|
|
90
|
+
_db.close();
|
|
91
|
+
_db = null;
|
|
92
|
+
}
|
|
93
|
+
}
|