bamboohr-cli 1.0.21-gefab789.2 → 1.0.22
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/dist/index.js +17 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -60,10 +60,17 @@ function readPackageVersion(importMetaUrl) {
|
|
|
60
60
|
|
|
61
61
|
// ../../cli-utils/dist/validators.js
|
|
62
62
|
import { InvalidArgumentError } from "commander";
|
|
63
|
+
function nonNegativeInt(raw) {
|
|
64
|
+
const n = parseInt(raw, 10);
|
|
65
|
+
if (Number.isNaN(n) || n < 0) {
|
|
66
|
+
throw new InvalidArgumentError("Must be a non-negative integer.");
|
|
67
|
+
}
|
|
68
|
+
return n;
|
|
69
|
+
}
|
|
63
70
|
function positiveInt(raw) {
|
|
64
71
|
const n = parseInt(raw, 10);
|
|
65
72
|
if (Number.isNaN(n) || n < 1) {
|
|
66
|
-
throw new InvalidArgumentError(
|
|
73
|
+
throw new InvalidArgumentError("Must be a positive integer.");
|
|
67
74
|
}
|
|
68
75
|
return n;
|
|
69
76
|
}
|
|
@@ -73,7 +80,7 @@ function text(raw) {
|
|
|
73
80
|
function date(raw) {
|
|
74
81
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw);
|
|
75
82
|
if (!m) {
|
|
76
|
-
throw new InvalidArgumentError(
|
|
83
|
+
throw new InvalidArgumentError("Must be a date in YYYY-MM-DD format.");
|
|
77
84
|
}
|
|
78
85
|
const [, y, mo, d] = m;
|
|
79
86
|
const year = Number(y);
|
|
@@ -81,23 +88,20 @@ function date(raw) {
|
|
|
81
88
|
const day = Number(d);
|
|
82
89
|
const dt = new Date(Date.UTC(year, month - 1, day));
|
|
83
90
|
if (dt.getUTCFullYear() !== year || dt.getUTCMonth() !== month - 1 || dt.getUTCDate() !== day) {
|
|
84
|
-
throw new InvalidArgumentError(
|
|
91
|
+
throw new InvalidArgumentError("Not a real calendar date.");
|
|
85
92
|
}
|
|
86
93
|
return raw;
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
// ../../cli-utils/dist/json.js
|
|
90
97
|
import { InvalidArgumentError as InvalidArgumentError2 } from "commander";
|
|
91
|
-
function truncate(s, max = 80) {
|
|
92
|
-
return s.length > max ? `${s.slice(0, max)}\u2026` : s;
|
|
93
|
-
}
|
|
94
98
|
function jsonShape(schema) {
|
|
95
99
|
return (raw) => {
|
|
96
100
|
let parsed;
|
|
97
101
|
try {
|
|
98
102
|
parsed = JSON.parse(raw);
|
|
99
103
|
} catch {
|
|
100
|
-
throw new InvalidArgumentError2(
|
|
104
|
+
throw new InvalidArgumentError2("Must be valid JSON.");
|
|
101
105
|
}
|
|
102
106
|
const result = schema.safeParse(parsed);
|
|
103
107
|
if (!result.success) {
|
|
@@ -558,7 +562,7 @@ function directory(parent) {
|
|
|
558
562
|
|
|
559
563
|
// src/commands/employee/get.ts
|
|
560
564
|
function get(parent) {
|
|
561
|
-
const cmd = parent.command("get").description("Get employee data by ID (default: current user)").argument("[employeeId]", "Employee ID (
|
|
565
|
+
const cmd = parent.command("get").description("Get employee data by ID (default: current user)").argument("[employeeId]", "Employee ID (0 or omitted = current user)", nonNegativeInt).option("--fields <fields>", "Comma-separated field names", text, "firstName,lastName,email,jobTitle").option("--include-future", "Include future-dated values from history fields").option("--with-photos", "Include the employee's signed photo URL and photoUploaded flag");
|
|
562
566
|
examples(cmd, [
|
|
563
567
|
"",
|
|
564
568
|
"123",
|
|
@@ -591,7 +595,7 @@ function mergeFields(existing, extra) {
|
|
|
591
595
|
import { Option as Option2 } from "commander";
|
|
592
596
|
var GOAL_FILTERS = ["open", "closed", "all"];
|
|
593
597
|
function goals(parent) {
|
|
594
|
-
const cmd = parent.command("goals").description("Get employee performance goals").argument("<employeeId>", "Employee ID",
|
|
598
|
+
const cmd = parent.command("goals").description("Get employee performance goals").argument("<employeeId>", "Employee ID (0 = current user)", nonNegativeInt).addOption(new Option2("--filter <filter>", "Filter goals by status").choices(GOAL_FILTERS).default("all"));
|
|
595
599
|
examples(cmd, ["123", ["123 --filter open", "only open goals"], ["123 --filter closed", "only closed goals"]]);
|
|
596
600
|
cmd.action(async (employeeId, opts) => {
|
|
597
601
|
const client = getClient();
|
|
@@ -608,7 +612,7 @@ import { writeFileSync as writeFileSync2 } from "fs";
|
|
|
608
612
|
import { Option as Option3 } from "commander";
|
|
609
613
|
var PHOTO_SIZES = ["original", "large", "medium", "small", "xs", "tiny"];
|
|
610
614
|
function photo(parent) {
|
|
611
|
-
const cmd = parent.command("photo").description("Download employee photo").argument("<employeeId>", "Employee ID",
|
|
615
|
+
const cmd = parent.command("photo").description("Download employee photo").argument("<employeeId>", "Employee ID (0 = current user)", nonNegativeInt).requiredOption("--output <path>", "File path to save photo", text).addOption(new Option3("--size <size>", "Photo size").choices(PHOTO_SIZES).default("medium"));
|
|
612
616
|
examples(cmd, [["123 --output ./photo.jpg", "medium size (default)"], "123 --output ./photo.jpg --size large"]);
|
|
613
617
|
cmd.action(async (employeeId, opts) => {
|
|
614
618
|
const client = getClient();
|
|
@@ -785,7 +789,7 @@ function registerMetaCommands(program) {
|
|
|
785
789
|
|
|
786
790
|
// src/commands/timeoff/balance.ts
|
|
787
791
|
function balance(parent) {
|
|
788
|
-
const cmd = parent.command("balance").description("Estimate time off balance (defaults to current user)").argument("[employeeId]", "Employee ID (
|
|
792
|
+
const cmd = parent.command("balance").description("Estimate time off balance (defaults to current user)").argument("[employeeId]", "Employee ID (0 or omitted = current user)", nonNegativeInt).option("--date <date>", "Future date to estimate balance for (YYYY-MM-DD)", date);
|
|
789
793
|
examples(cmd, ["", "123", ["--date 2026-06-30", "balance at a future date"]]);
|
|
790
794
|
cmd.action(async (employeeId, opts) => {
|
|
791
795
|
const client = getClient();
|
|
@@ -856,7 +860,7 @@ var datesSchema = z.array(
|
|
|
856
860
|
})
|
|
857
861
|
).min(1, "must be a non-empty array");
|
|
858
862
|
function create(parent) {
|
|
859
|
-
const cmd = parent.command("create").description("Create a time off request (defaults to current user)").argument("[employeeId]", "Employee ID (
|
|
863
|
+
const cmd = parent.command("create").description("Create a time off request (defaults to current user)").argument("[employeeId]", "Employee ID (0 or omitted = current user)", nonNegativeInt).requiredOption("--start-date <date>", "Start date (YYYY-MM-DD)", date).requiredOption("--end-date <date>", "End date (YYYY-MM-DD)", date).requiredOption("--type-id <id>", 'Time off type ID (use "timeoff types" to find IDs)', positiveInt).addOption(
|
|
860
864
|
new Option4("--status <status>", "Request status").choices(["requested", "approved"]).default("requested")
|
|
861
865
|
).option(
|
|
862
866
|
"--dates <json>",
|
|
@@ -927,7 +931,7 @@ function create(parent) {
|
|
|
927
931
|
// src/commands/timeoff/requests.ts
|
|
928
932
|
import { Option as Option5 } from "commander";
|
|
929
933
|
function requests(parent) {
|
|
930
|
-
const cmd = parent.command("requests").description("Get time off requests (defaults to current user)").option("--request-id <id>", "Specific request ID", positiveInt).addOption(new Option5("--action <action>", "Access level filter").choices(["view", "approve"])).option("--employee-id <id>", "Filter by employee ID",
|
|
934
|
+
const cmd = parent.command("requests").description("Get time off requests (defaults to current user)").option("--request-id <id>", "Specific request ID", positiveInt).addOption(new Option5("--action <action>", "Access level filter").choices(["view", "approve"])).option("--employee-id <id>", "Filter by employee ID (0 = current user)", nonNegativeInt).option("--all", "Show all visible requests instead of just current user").option("--start-date <date>", "Start date (YYYY-MM-DD)", date).option("--end-date <date>", "End date (YYYY-MM-DD)", date).addOption(
|
|
931
935
|
new Option5("--status <status>", "Filter by request status").choices([
|
|
932
936
|
"approved",
|
|
933
937
|
"denied",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bamboohr-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"publish": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"tsx": "^4.19.2",
|
|
24
24
|
"typescript": "^5.7.2",
|
|
25
25
|
"vitest": "^4.0.16",
|
|
26
|
-
"config-eslint": "0.0.0",
|
|
27
26
|
"cli-utils": "1.0.0",
|
|
27
|
+
"config-eslint": "0.0.0",
|
|
28
28
|
"config-typescript": "0.0.0"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|