@apet97/clockify-cli-115 4.0.0 → 5.0.1
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/README.md +3 -3
- package/dist/commands/balanceAssignment.js +3 -0
- package/dist/commands/clients.js +4 -1
- package/dist/commands/doctor.js +3 -2
- package/dist/commands/helpers.js +49 -6
- package/dist/commands/log.js +7 -10
- package/dist/commands/scheduling.js +10 -8
- package/dist/commands/sharedReports.js +8 -1
- package/dist/commands/status.js +8 -3
- package/dist/commands/stop.js +9 -2
- package/dist/commands/tags.js +7 -5
- package/dist/commands/timeoff.js +13 -6
- package/dist/commands/users.js +9 -0
- package/dist/duration.js +17 -11
- package/dist/error-codes.js +2 -2
- package/dist/generated/version.js +1 -1
- package/dist/output.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Command-line interface for [Clockify](https://clockify.me/), built on
|
|
4
4
|
top of `clockify-sdk-ts-115`.
|
|
5
5
|
|
|
6
|
-
Current release: `
|
|
7
|
-
`clockify-sdk-ts-115 ^
|
|
6
|
+
Current release: `5.0.1`. Requires Node.js `>=22.13.0` and
|
|
7
|
+
`clockify-sdk-ts-115 ^5`.
|
|
8
8
|
|
|
9
9
|
Two binaries, identical behavior:
|
|
10
10
|
|
|
@@ -240,7 +240,7 @@ node dist/index.js status # smoke test (or invoke installed clk115/clockify11
|
|
|
240
240
|
```
|
|
241
241
|
|
|
242
242
|
`clockify-sdk-ts-115` is workspace-linked for local development and is a
|
|
243
|
-
`^
|
|
243
|
+
`^5` peer dependency for published consumers.
|
|
244
244
|
|
|
245
245
|
## License
|
|
246
246
|
|
|
@@ -123,6 +123,9 @@ export function registerBalanceAssignmentCommands(timeoff, services) {
|
|
|
123
123
|
.requiredOption("--policy <id>", "Time-off policy ID.")
|
|
124
124
|
.requiredOption("--note <text>", "Note explaining the deletion. The API rejects an empty note.")
|
|
125
125
|
.action(async function (opts) {
|
|
126
|
+
if (typeof opts.note !== "string" || opts.note.trim() === "") {
|
|
127
|
+
throw new Error("--note must be a non-empty note: the API rejects an empty note on balance-assignment delete.");
|
|
128
|
+
}
|
|
126
129
|
const { client, workspaceId, output } = await resolveContext(this, services);
|
|
127
130
|
await client.balanceAssignment.deleteBalanceAssignment({
|
|
128
131
|
workspaceId,
|
package/dist/commands/clients.js
CHANGED
|
@@ -3,6 +3,9 @@ import { printObject, printRecords } from "../output.js";
|
|
|
3
3
|
import { printReceipt } from "../receipt.js";
|
|
4
4
|
import { clampPageSize, parseIntArg, resolveContext } from "./helpers.js";
|
|
5
5
|
import { leafCommand } from "./leaf-command.js";
|
|
6
|
+
function quoteShellArgument(value) {
|
|
7
|
+
return `'${value.replaceAll("'", "'\"'\"'")}'`;
|
|
8
|
+
}
|
|
6
9
|
function requireClientName(value, source) {
|
|
7
10
|
if (typeof value !== "string" || value.trim() === "") {
|
|
8
11
|
throw new Error(`${source} is missing the required client name; refusing to mutate.`);
|
|
@@ -100,7 +103,7 @@ export const registerClientsCommand = (program, services) => {
|
|
|
100
103
|
changed: { created: [{ type: "client", id: data.id, name: data.name }] },
|
|
101
104
|
next: [
|
|
102
105
|
{
|
|
103
|
-
command: `clk115 projects create
|
|
106
|
+
command: `clk115 projects create ${quoteShellArgument(`Project for ${data.name}`)} --client ${quoteShellArgument(data.id)}`,
|
|
104
107
|
reason: "Create a project for this client.",
|
|
105
108
|
},
|
|
106
109
|
],
|
package/dist/commands/doctor.js
CHANGED
|
@@ -56,7 +56,8 @@ function buildDoctorReceipt(config, flags, env) {
|
|
|
56
56
|
}
|
|
57
57
|
const regionOk = routingError === undefined;
|
|
58
58
|
const subdomainOk = routingError === undefined;
|
|
59
|
-
const
|
|
59
|
+
const baseUrlOk = baseUrlClass ? baseUrlClass.allowed : true;
|
|
60
|
+
const configOk = apiKeyOk && workspaceOk && regionOk && baseUrlOk;
|
|
60
61
|
const ok = nodeOk && configOk;
|
|
61
62
|
return {
|
|
62
63
|
ok,
|
|
@@ -93,7 +94,7 @@ function buildDoctorReceipt(config, flags, env) {
|
|
|
93
94
|
}),
|
|
94
95
|
},
|
|
95
96
|
baseUrl: {
|
|
96
|
-
ok:
|
|
97
|
+
ok: baseUrlOk,
|
|
97
98
|
status: config.baseUrl ? "override" : "default",
|
|
98
99
|
source: baseUrlSource,
|
|
99
100
|
value: baseUrl,
|
package/dist/commands/helpers.js
CHANGED
|
@@ -38,19 +38,62 @@ export function splitList(value) {
|
|
|
38
38
|
.map((s) => s.trim())
|
|
39
39
|
.filter((s) => s.length > 0);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const BARE_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
42
|
+
const RFC3339_TIMESTAMP_PATTERN = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/;
|
|
43
|
+
function hasValidCalendarDate(yearText, monthText, dayText) {
|
|
44
|
+
const year = Number(yearText);
|
|
45
|
+
const month = Number(monthText);
|
|
46
|
+
const day = Number(dayText);
|
|
47
|
+
const probe = new Date(0);
|
|
48
|
+
probe.setUTCFullYear(year, month - 1, day);
|
|
49
|
+
probe.setUTCHours(0, 0, 0, 0);
|
|
50
|
+
return (probe.getUTCFullYear() === year &&
|
|
51
|
+
probe.getUTCMonth() === month - 1 &&
|
|
52
|
+
probe.getUTCDate() === day);
|
|
53
|
+
}
|
|
54
|
+
function isRfc3339Timestamp(value) {
|
|
55
|
+
const match = RFC3339_TIMESTAMP_PATTERN.exec(value);
|
|
56
|
+
if (match === null || !hasValidCalendarDate(match[1], match[2], match[3])) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const hour = Number(match[4]);
|
|
60
|
+
const minute = Number(match[5]);
|
|
61
|
+
const second = Number(match[6]);
|
|
62
|
+
const offsetHour = match[7] === undefined ? 0 : Number(match[7]);
|
|
63
|
+
const offsetMinute = match[8] === undefined ? 0 : Number(match[8]);
|
|
64
|
+
return (hour <= 23 &&
|
|
65
|
+
minute <= 59 &&
|
|
66
|
+
second <= 59 &&
|
|
67
|
+
offsetHour <= 23 &&
|
|
68
|
+
offsetMinute <= 59 &&
|
|
69
|
+
!Number.isNaN(Date.parse(value)));
|
|
70
|
+
}
|
|
71
|
+
export function requireRfc3339Timestamp(value, flag) {
|
|
72
|
+
if (!isRfc3339Timestamp(value)) {
|
|
73
|
+
throw new Error(`--${flag} ${JSON.stringify(value)} is not a valid RFC3339 timestamp; provide a value such as 2026-06-22T09:30:00Z`);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
export function requireDateOrRfc3339(value, flag) {
|
|
78
|
+
const bareDate = BARE_DATE_PATTERN.exec(value);
|
|
79
|
+
if (bareDate !== null) {
|
|
80
|
+
if (!hasValidCalendarDate(bareDate[1], bareDate[2], bareDate[3])) {
|
|
45
81
|
throw new Error(`--${flag} ${JSON.stringify(value)} is not a valid calendar date (YYYY-MM-DD); provide a real calendar date`);
|
|
46
82
|
}
|
|
47
|
-
return
|
|
83
|
+
return value;
|
|
48
84
|
}
|
|
49
|
-
if (
|
|
85
|
+
if (!isRfc3339Timestamp(value)) {
|
|
50
86
|
throw new Error(`--${flag} ${JSON.stringify(value)} is not a valid date (YYYY-MM-DD) or RFC3339 timestamp; provide YYYY-MM-DD or an RFC3339 timestamp`);
|
|
51
87
|
}
|
|
52
88
|
return value;
|
|
53
89
|
}
|
|
90
|
+
export function promoteDateBoundary(value, flag, edge) {
|
|
91
|
+
const validValue = requireDateOrRfc3339(value, flag);
|
|
92
|
+
if (BARE_DATE_PATTERN.test(validValue)) {
|
|
93
|
+
return edge === "start" ? `${value}T00:00:00Z` : `${value}T23:59:59Z`;
|
|
94
|
+
}
|
|
95
|
+
return validValue;
|
|
96
|
+
}
|
|
54
97
|
export function rootProgram(cmd) {
|
|
55
98
|
let current = cmd;
|
|
56
99
|
while (current.parent != null) {
|
package/dist/commands/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseDuration } from "../duration.js";
|
|
2
2
|
import { printReceipt } from "../receipt.js";
|
|
3
|
-
import { resolveContext } from "./helpers.js";
|
|
3
|
+
import { requireRfc3339Timestamp, resolveContext } from "./helpers.js";
|
|
4
4
|
import { leafCommand } from "./leaf-command.js";
|
|
5
5
|
import { resolveProjectId, resolveTaskId, resolveTagIds } from "./resolve-refs.js";
|
|
6
6
|
export const registerLogCommand = (program, services) => {
|
|
@@ -14,10 +14,15 @@ export const registerLogCommand = (program, services) => {
|
|
|
14
14
|
.option("--billable", "Mark the entry as billable.", false)
|
|
15
15
|
.option("--end <iso>", "End timestamp (ISO 8601). Defaults to now.")
|
|
16
16
|
.action(async function (duration, description, opts) {
|
|
17
|
-
const { client, workspaceId, output } = await resolveContext(this, services);
|
|
18
17
|
if (opts.task && !opts.project) {
|
|
19
18
|
throw new Error("--task requires --project: a task entry must be scoped to its project.");
|
|
20
19
|
}
|
|
20
|
+
const seconds = parseDuration(duration);
|
|
21
|
+
const endInput = requireRfc3339Timestamp(opts.end ?? new Date().toISOString(), "end");
|
|
22
|
+
const endMs = Date.parse(endInput);
|
|
23
|
+
const endIso = new Date(endMs).toISOString();
|
|
24
|
+
const startIso = new Date(endMs - seconds * 1000).toISOString();
|
|
25
|
+
const { client, workspaceId, output } = await resolveContext(this, services);
|
|
21
26
|
const projectId = opts.project
|
|
22
27
|
? await resolveProjectId(client, workspaceId, opts.project)
|
|
23
28
|
: undefined;
|
|
@@ -27,14 +32,6 @@ export const registerLogCommand = (program, services) => {
|
|
|
27
32
|
const tagIds = opts.tag && opts.tag.length > 0
|
|
28
33
|
? await resolveTagIds(client, workspaceId, opts.tag)
|
|
29
34
|
: undefined;
|
|
30
|
-
const seconds = parseDuration(duration);
|
|
31
|
-
const endInput = opts.end ?? new Date().toISOString();
|
|
32
|
-
const endMs = Date.parse(endInput);
|
|
33
|
-
if (Number.isNaN(endMs)) {
|
|
34
|
-
throw new Error(`--end ${JSON.stringify(opts.end)} is not a valid ISO 8601 timestamp; provide an RFC3339 timestamp`);
|
|
35
|
-
}
|
|
36
|
-
const endIso = new Date(endMs).toISOString();
|
|
37
|
-
const startIso = new Date(endMs - seconds * 1000).toISOString();
|
|
38
35
|
const body = {
|
|
39
36
|
start: startIso,
|
|
40
37
|
end: endIso,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { printRecords } from "../output.js";
|
|
2
2
|
import { printReceipt } from "../receipt.js";
|
|
3
|
-
import { clampPageSize, parseFloatArg, parseIntArg, promoteDateBoundary, resolveContext, } from "./helpers.js";
|
|
3
|
+
import { clampPageSize, parseFloatArg, parseIntArg, promoteDateBoundary, requireRfc3339Timestamp, resolveContext, } from "./helpers.js";
|
|
4
4
|
import { leafCommand } from "./leaf-command.js";
|
|
5
5
|
export const registerSchedulingCommand = (program, services) => {
|
|
6
6
|
const scheduling = program
|
|
@@ -54,13 +54,15 @@ export const registerSchedulingCommand = (program, services) => {
|
|
|
54
54
|
.option("--include-non-working-days", "Include weekends/non-working days.", false)
|
|
55
55
|
.option("--publish", "Publish immediately (default is draft).", false)
|
|
56
56
|
.action(async function (opts) {
|
|
57
|
+
const start = requireRfc3339Timestamp(opts.start, "start");
|
|
58
|
+
const end = requireRfc3339Timestamp(opts.end, "end");
|
|
57
59
|
const { client, workspaceId, output } = await resolveContext(this, services);
|
|
58
60
|
const body = {
|
|
59
61
|
userId: opts.user,
|
|
60
62
|
projectId: opts.project,
|
|
61
63
|
hoursPerDay: opts.hoursPerDay,
|
|
62
|
-
start
|
|
63
|
-
end
|
|
64
|
+
start,
|
|
65
|
+
end,
|
|
64
66
|
};
|
|
65
67
|
if (opts.task)
|
|
66
68
|
body.taskId = opts.task;
|
|
@@ -76,8 +78,8 @@ export const registerSchedulingCommand = (program, services) => {
|
|
|
76
78
|
if (opts.publish === true) {
|
|
77
79
|
await client.scheduling.publish({
|
|
78
80
|
workspaceId,
|
|
79
|
-
start
|
|
80
|
-
end
|
|
81
|
+
start,
|
|
82
|
+
end,
|
|
81
83
|
userFilter: { contains: "CONTAINS", ids: [opts.user] },
|
|
82
84
|
});
|
|
83
85
|
}
|
|
@@ -86,8 +88,8 @@ export const registerSchedulingCommand = (program, services) => {
|
|
|
86
88
|
user: created.userId ?? "",
|
|
87
89
|
project: created.projectId ?? "",
|
|
88
90
|
hoursPerDay: created.hoursPerDay ?? 0,
|
|
89
|
-
start: created.start ?? created.period?.start ??
|
|
90
|
-
end: created.end ?? created.period?.end ??
|
|
91
|
+
start: created.start ?? created.period?.start ?? start,
|
|
92
|
+
end: created.end ?? created.period?.end ?? end,
|
|
91
93
|
published: opts.publish === true,
|
|
92
94
|
};
|
|
93
95
|
printReceipt({
|
|
@@ -99,7 +101,7 @@ export const registerSchedulingCommand = (program, services) => {
|
|
|
99
101
|
changed: { created: [{ type: "scheduling_assignment", id: data.id }] },
|
|
100
102
|
next: [
|
|
101
103
|
{
|
|
102
|
-
command:
|
|
104
|
+
command: `clk115 scheduling list --from ${data.start} --to ${data.end} --json`,
|
|
103
105
|
reason: "Verify the assignment appears.",
|
|
104
106
|
},
|
|
105
107
|
],
|
|
@@ -120,6 +120,13 @@ const sharedReportBodyShape = {
|
|
|
120
120
|
};
|
|
121
121
|
const sharedReportCreateBodySchema = z.object(sharedReportBodyShape).strict();
|
|
122
122
|
const sharedReportUpdateBodySchema = z.object(sharedReportBodyShape).strict();
|
|
123
|
+
function toSharedUsersFilter(value) {
|
|
124
|
+
return {
|
|
125
|
+
...(value.contains !== undefined ? { contains: value.contains } : {}),
|
|
126
|
+
...(value.ids !== undefined ? { ids: value.ids } : {}),
|
|
127
|
+
...(value.status !== undefined ? { status: value.status } : {}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
123
130
|
function toSharedReportFilter(value) {
|
|
124
131
|
return {
|
|
125
132
|
dateRangeEnd: value.dateRangeEnd,
|
|
@@ -135,7 +142,7 @@ function toSharedReportFilter(value) {
|
|
|
135
142
|
? { pageSize: value.attendanceFilter.pageSize }
|
|
136
143
|
: {}),
|
|
137
144
|
...(value.attendanceFilter.users !== undefined
|
|
138
|
-
? { users: value.attendanceFilter.users }
|
|
145
|
+
? { users: toSharedUsersFilter(value.attendanceFilter.users) }
|
|
139
146
|
: {}),
|
|
140
147
|
},
|
|
141
148
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iterAll } from "clockify-sdk-ts-115/iter";
|
|
1
2
|
import { entityId } from "clockify-sdk-ts-115/operation-receipt";
|
|
2
3
|
import { formatIsoDuration } from "../duration.js";
|
|
3
4
|
import { printObject } from "../output.js";
|
|
@@ -21,9 +22,13 @@ export const registerStatusCommand = (program, services) => {
|
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
const workspaceId = config.workspaceId;
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
let running = null;
|
|
26
|
+
for await (const entry of iterAll(async (req) => normaliseEntries(await client.timeEntries.listInProgress(req)), { workspaceId }, { pageSize: 200, maxPages: 1000 })) {
|
|
27
|
+
if (isOwn(entry, user)) {
|
|
28
|
+
running = entry;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
27
32
|
printObject({
|
|
28
33
|
workspaceId,
|
|
29
34
|
userId: entityId(user) ?? "",
|
package/dist/commands/stop.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iterAll } from "clockify-sdk-ts-115/iter";
|
|
1
2
|
import { entityId } from "clockify-sdk-ts-115/operation-receipt";
|
|
2
3
|
import { printReceipt } from "../receipt.js";
|
|
3
4
|
import { resolveContext } from "./helpers.js";
|
|
@@ -12,8 +13,14 @@ export const registerStopCommand = (program, services) => {
|
|
|
12
13
|
if (!userId) {
|
|
13
14
|
throw new Error("could not determine user ID from getCurrentUser response");
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
const
|
|
16
|
+
let running;
|
|
17
|
+
for await (const item of iterAll((req) => client.timeEntries.listInProgress(req), { workspaceId }, { pageSize: 200, maxPages: 1000 })) {
|
|
18
|
+
const entry = item;
|
|
19
|
+
if (entry.userId === userId && entry.id) {
|
|
20
|
+
running = entry;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
17
24
|
if (!running) {
|
|
18
25
|
printReceipt({
|
|
19
26
|
ok: true,
|
package/dist/commands/tags.js
CHANGED
|
@@ -71,11 +71,13 @@ export const registerTagsCommand = (program, services) => {
|
|
|
71
71
|
throw new Error("tags.update needs a change: provide at least one tag field.");
|
|
72
72
|
}
|
|
73
73
|
const { client, workspaceId, output } = await resolveContext(this, services);
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const current = opts.name && opts.archived !== undefined
|
|
75
|
+
? {}
|
|
76
|
+
: (await client.tags.get({ workspaceId, tagId: id }));
|
|
77
|
+
const body = {
|
|
78
|
+
name: opts.name ? opts.name : (current.name ?? ""),
|
|
79
|
+
archived: opts.archived ?? current.archived ?? false,
|
|
80
|
+
};
|
|
79
81
|
const req = { workspaceId, tagId: id, body };
|
|
80
82
|
const updated = (await client.tags.update(req));
|
|
81
83
|
const data = { id: updated.id ?? id, name: updated.name ?? "" };
|
package/dist/commands/timeoff.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { printRecords } from "../output.js";
|
|
2
2
|
import { printReceipt } from "../receipt.js";
|
|
3
3
|
import { registerBalanceAssignmentCommands } from "./balanceAssignment.js";
|
|
4
|
-
import { clampPageSize, parseIntArg, resolveContext, splitList } from "./helpers.js";
|
|
4
|
+
import { clampPageSize, parseIntArg, promoteDateBoundary, requireDateOrRfc3339, requireRfc3339Timestamp, resolveContext, splitList, } from "./helpers.js";
|
|
5
5
|
import { leafCommand } from "./leaf-command.js";
|
|
6
6
|
export const registerTimeOffCommand = (program, services) => {
|
|
7
7
|
const timeoff = program.command("timeoff").description("Time-off requests.");
|
|
@@ -22,9 +22,9 @@ export const registerTimeOffCommand = (program, services) => {
|
|
|
22
22
|
pageSize: clampPageSize(opts.limit, 200),
|
|
23
23
|
};
|
|
24
24
|
if (opts.start)
|
|
25
|
-
req.start = opts.start;
|
|
25
|
+
req.start = promoteDateBoundary(opts.start, "start", "start");
|
|
26
26
|
if (opts.end)
|
|
27
|
-
req.end = opts.end;
|
|
27
|
+
req.end = promoteDateBoundary(opts.end, "end", "end");
|
|
28
28
|
if (opts.status) {
|
|
29
29
|
const statuses = splitList(opts.status).map((s) => s.toUpperCase());
|
|
30
30
|
const known = new Set(["PENDING", "APPROVED", "REJECTED", "ALL"]);
|
|
@@ -69,14 +69,21 @@ export const registerTimeOffCommand = (program, services) => {
|
|
|
69
69
|
if (opts.end === undefined && !Number.isFinite(opts.days)) {
|
|
70
70
|
throw new Error("provide --end (date-range / HOURS-unit policies) or --days (DAYS-unit policies)");
|
|
71
71
|
}
|
|
72
|
+
if (opts.end !== undefined && Number.isFinite(opts.days)) {
|
|
73
|
+
throw new Error("--end and --days are mutually exclusive: --end for HOURS-unit policies, --days for DAYS-unit policies");
|
|
74
|
+
}
|
|
72
75
|
const halfDayPeriod = opts.halfDayPeriod === undefined ? "NOT_DEFINED" : String(opts.halfDayPeriod).toUpperCase();
|
|
73
76
|
if (!["FIRST_HALF", "SECOND_HALF", "NOT_DEFINED"].includes(halfDayPeriod)) {
|
|
74
77
|
throw new Error(`--half-day-period must be FIRST_HALF, SECOND_HALF, or NOT_DEFINED (got "${String(opts.halfDayPeriod)}").`);
|
|
75
78
|
}
|
|
79
|
+
const start = requireDateOrRfc3339(opts.start, "start");
|
|
80
|
+
const end = opts.end === undefined
|
|
81
|
+
? undefined
|
|
82
|
+
: requireRfc3339Timestamp(opts.end, "end");
|
|
76
83
|
const { client, workspaceId, output } = await resolveContext(this, services);
|
|
77
|
-
const period = { start
|
|
78
|
-
if (
|
|
79
|
-
period.end =
|
|
84
|
+
const period = { start };
|
|
85
|
+
if (end !== undefined)
|
|
86
|
+
period.end = end;
|
|
80
87
|
if (Number.isFinite(opts.days))
|
|
81
88
|
period.days = opts.days;
|
|
82
89
|
const body = {
|
package/dist/commands/users.js
CHANGED
|
@@ -97,6 +97,15 @@ export const registerUsersCommand = (program, services) => {
|
|
|
97
97
|
.option("--working-days <days...>", "Working days: MONDAY, TUESDAY, ... SUNDAY (space-separated).")
|
|
98
98
|
.description("Update one user's member profile (name, image, week start, work capacity, working days).")
|
|
99
99
|
.action(async function (userId, opts) {
|
|
100
|
+
const hasChanges = opts.name !== undefined ||
|
|
101
|
+
opts.imageUrl !== undefined ||
|
|
102
|
+
opts.removeImage === true ||
|
|
103
|
+
opts.weekStart !== undefined ||
|
|
104
|
+
opts.workCapacity !== undefined ||
|
|
105
|
+
(Array.isArray(opts.workingDays) && opts.workingDays.length > 0);
|
|
106
|
+
if (!hasChanges) {
|
|
107
|
+
throw new Error("users.update-profile needs a change: provide at least one profile field.");
|
|
108
|
+
}
|
|
100
109
|
const { client, workspaceId, output } = await resolveContext(this, services);
|
|
101
110
|
const body = {};
|
|
102
111
|
if (opts.name !== undefined)
|
package/dist/duration.js
CHANGED
|
@@ -4,26 +4,32 @@ export function parseDuration(input) {
|
|
|
4
4
|
throw new Error('duration is missing; provide a form like "1h30m", "45m", "90", or ISO "PT1H30M"');
|
|
5
5
|
}
|
|
6
6
|
if (/^PT/i.test(trimmed)) {
|
|
7
|
-
return parseIsoDuration(trimmed);
|
|
7
|
+
return requirePositive(parseIsoDuration(trimmed), input);
|
|
8
8
|
}
|
|
9
9
|
if (/^\d+(?:\.\d+)?$/.test(trimmed)) {
|
|
10
|
-
return Math.round(Number(trimmed) * 60);
|
|
10
|
+
return requirePositive(Math.round(Number(trimmed) * 60), input);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
13
|
-
const re = /(\d+(?:\.\d+)?)([dhms])/gi;
|
|
12
|
+
const re = /(\d+(?:\.\d+)?)\s*([dhms])\s*/giy;
|
|
14
13
|
let total = 0;
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
let offset = 0;
|
|
15
|
+
while (offset < trimmed.length) {
|
|
16
|
+
re.lastIndex = offset;
|
|
17
|
+
const match = re.exec(trimmed);
|
|
18
|
+
if (match === null) {
|
|
19
|
+
throw new Error(`could not parse duration ${JSON.stringify(input)}; use forms like "1h30m", "45m", "90", or ISO "PT1H30M"`);
|
|
20
|
+
}
|
|
18
21
|
const value = Number(match[1]);
|
|
19
22
|
const unit = (match[2] ?? "").toLowerCase();
|
|
20
23
|
total += value * unitToSeconds(unit);
|
|
21
|
-
|
|
24
|
+
offset = re.lastIndex;
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
return requirePositive(Math.round(total), input);
|
|
27
|
+
}
|
|
28
|
+
function requirePositive(seconds, input) {
|
|
29
|
+
if (seconds <= 0) {
|
|
30
|
+
throw new Error(`duration ${JSON.stringify(input)} must be positive; a zero-length entry records nothing`);
|
|
25
31
|
}
|
|
26
|
-
return
|
|
32
|
+
return seconds;
|
|
27
33
|
}
|
|
28
34
|
function parseIsoDuration(input) {
|
|
29
35
|
const re = /^PT(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?$/i;
|
package/dist/error-codes.js
CHANGED
|
@@ -207,8 +207,8 @@ export const CLOCKIFY_ERROR_CODES = [
|
|
|
207
207
|
"cli",
|
|
208
208
|
"mcp"
|
|
209
209
|
],
|
|
210
|
-
"meaning": "A project, tag, or client with that name already exists. Archived entities keep holding their name,
|
|
211
|
-
"recovery": "List the entity type
|
|
210
|
+
"meaning": "A project, tag, or client with that name already exists. Archived entities keep holding their name, and an archived row is easy to miss in a long list even though the list call returns it. (Live probe 2026-08-07: deleting an entity releases its name immediately, so the code's own name is a misnomer kept for compatibility.)",
|
|
211
|
+
"recovery": "List the entity type and look for an archived holder — the list returns archived and active rows by default (live probe 2026-08-09) — then reuse it, rename it, or delete it. Waiting does not help: the name is held for as long as the entity exists.",
|
|
212
212
|
"reachable": false
|
|
213
213
|
},
|
|
214
214
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = "
|
|
1
|
+
export const PACKAGE_VERSION = "5.0.1";
|
package/dist/output.js
CHANGED
|
@@ -78,7 +78,7 @@ export function selectValue(value, selector) {
|
|
|
78
78
|
current = current[index];
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
|
-
if (current !== null && typeof current === "object" && part
|
|
81
|
+
if (current !== null && typeof current === "object" && Object.hasOwn(current, part)) {
|
|
82
82
|
current = current[part];
|
|
83
83
|
continue;
|
|
84
84
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apet97/clockify-cli-115",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Unofficial, community-built \u2014 not affiliated with CAKE.com or Clockify. Command-line interface for Clockify, built on clockify-sdk-ts-115.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Aleksandar Petkovi\u0107 <petkovic.aleksandar037@gmail.com>",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"zod": "^4.4.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"clockify-sdk-ts-115": "^
|
|
57
|
+
"clockify-sdk-ts-115": "^5"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^22",
|