@springbrand/hr-cli 0.1.0 → 0.2.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.
@@ -34,6 +34,15 @@ hr approvals status <approvalId> [--wait] [--timeout seconds]
34
34
 
35
35
  `<job>` is a title, slug or id. `<reason>` is a name from `hr reasons list`, or an id.
36
36
 
37
+ ## Links
38
+
39
+ When the user asks for a link to a candidate, give the `url` from the output. Never build a link yourself.
40
+
41
+ - `talents search` and `talents show`: each talent's `url` opens their talent page; in `talents show`, each entry in `applications` has the `url` of that application.
42
+ - `screening list` and `interviews to-schedule`: each item's `url` opens that application (one candidate in one job).
43
+
44
+ If the person you need is not in a result, run the command that lists them first, for example `hr talents show <name>`.
45
+
37
46
  ## Reading the result
38
47
 
39
48
  | Output | Exit | What to do |
package/README.md CHANGED
@@ -19,4 +19,6 @@ hr screening list
19
19
  | `HR_CONFIG_DIR` | No | Where `hr login` stores its token. Default `~/.config/saas-hr`. |
20
20
  | `XDG_CONFIG_HOME` | No | Moves the default to `$XDG_CONFIG_HOME/saas-hr`. |
21
21
 
22
+ Talents and applications in the output carry `url`, their page in the HR console, on the address HR reports.
23
+
22
24
  `hr --help` lists the commands. Agents: see `.agents/skills/saas-hr-cli/SKILL.md`.
package/dist/hr.js CHANGED
@@ -76,6 +76,10 @@ var Hr = class {
76
76
  this.bearer = stored.token;
77
77
  return this.bearer;
78
78
  }
79
+ /** The console's address, as HR reports it, so page links never guess a domain. */
80
+ async appOrigin() {
81
+ return (await this.config()).appOrigin.replace(/\/+$/, "");
82
+ }
79
83
  get(pathname, query = {}) {
80
84
  const url = new URL(`${this.apiUrl}/api/v1${pathname}`);
81
85
  for (const [name, value] of Object.entries(query)) if (value !== void 0 && value !== "") url.searchParams.set(name, String(value));
@@ -181,6 +185,7 @@ Commands
181
185
  hr reasons list
182
186
  hr approvals status <id> [--wait] [--timeout seconds]
183
187
 
188
+ Talents and applications carry url, their page in the HR console.
184
189
  A command without the permission answers with data.pendingApproval: a person decides in IAM.`;
185
190
  var options = {
186
191
  "api-url": { type: "string" },
@@ -194,6 +199,18 @@ var options = {
194
199
  timeout: { type: "string" },
195
200
  help: { type: "boolean", short: "h" }
196
201
  };
202
+ async function linked(hr, records, page2) {
203
+ const origin = await hr.appOrigin();
204
+ return records.map((record) => ({ ...record, url: `${origin}/${page2}/${record.id}` }));
205
+ }
206
+ async function linkedPage(hr, result, page2) {
207
+ return { ...result, items: await linked(hr, result.items, page2) };
208
+ }
209
+ async function linkedTalent(hr, id) {
210
+ const talent = await hr.get(`/talents/${id}`);
211
+ const [withUrl] = await linked(hr, [talent], "talents");
212
+ return { ...withUrl, ...talent.applications ? { applications: await linked(hr, talent.applications, "applications") } : {} };
213
+ }
197
214
  async function jobId(hr, job) {
198
215
  if (!job || isId(job)) return job;
199
216
  const jobs = await hr.get("/jobs");
@@ -238,15 +255,15 @@ async function dispatch(args, deps) {
238
255
  case "jobs list":
239
256
  return hr.get("/jobs", { status: values.status });
240
257
  case "talents search":
241
- return hr.get("/talents", { q: rest.join(" ") || void 0, jobId: await jobId(hr, values.job), ...page2 });
258
+ return linkedPage(hr, await hr.get("/talents", { q: rest.join(" ") || void 0, jobId: await jobId(hr, values.job), ...page2 }), "talents");
242
259
  case "talents show": {
243
260
  const who = needed("a name or id", rest.join(" "));
244
- if (isId(who)) return hr.get(`/talents/${who}`);
261
+ if (isId(who)) return linkedTalent(hr, who);
245
262
  const found = await hr.get("/talents", { q: who, pageSize: 50 });
246
- return hr.get(`/talents/${pickOne(found.items, who, (item) => [item.displayName], (item) => ({ id: item.id, name: item.displayName, headline: item.headline }), "talent").id}`);
263
+ return linkedTalent(hr, pickOne(found.items, who, (item) => [item.displayName], (item) => ({ id: item.id, name: item.displayName, headline: item.headline }), "talent").id);
247
264
  }
248
265
  case "screening list":
249
- return screeningQueue(hr, values.job);
266
+ return linkedPage(hr, await screeningQueue(hr, values.job), "applications");
250
267
  case "screening pass":
251
268
  return hr.post(`/applications/${await screeningApplication(hr, needed("a candidate", rest.join(" ")), values.job)}/screening`, { decision: "pass" });
252
269
  case "screening reject": {
@@ -254,7 +271,7 @@ async function dispatch(args, deps) {
254
271
  return hr.post(`/applications/${id}/screening`, { decision: "reject", reasonId: await rejectReason(hr, values.reason) });
255
272
  }
256
273
  case "interviews to-schedule":
257
- return hr.get("/applications", { queue: "to_schedule", jobId: await jobId(hr, values.job), ...page2 });
274
+ return linkedPage(hr, await hr.get("/applications", { queue: "to_schedule", jobId: await jobId(hr, values.job), ...page2 }), "applications");
258
275
  case "reasons list":
259
276
  return hr.get("/reject-reasons");
260
277
  case "approvals status":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springbrand/hr-cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "SpringBrand HR from the command line, for people and Agents.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -24,16 +24,15 @@
24
24
  "url": "git+ssh://git@github.com/springbrand-lab/saas-hr.git",
25
25
  "directory": "packages/cli"
26
26
  },
27
- "scripts": {
28
- "build": "esbuild src/bin.ts --bundle --platform=node --format=esm --target=node24 --outfile=dist/hr.js --banner:js=\"#!/usr/bin/env node\"",
29
- "check": "tsc --noEmit",
30
- "test": "vitest run",
31
- "prepublishOnly": "pnpm run build && pnpm run test"
32
- },
33
27
  "devDependencies": {
34
28
  "@types/node": "^24.13.3",
35
29
  "esbuild": "^0.27.4",
36
30
  "typescript": "^7.0.2",
37
31
  "vitest": "^4.1.10"
32
+ },
33
+ "scripts": {
34
+ "build": "esbuild src/bin.ts --bundle --platform=node --format=esm --target=node24 --outfile=dist/hr.js --banner:js=\"#!/usr/bin/env node\"",
35
+ "check": "tsc --noEmit",
36
+ "test": "vitest run"
38
37
  }
39
- }
38
+ }