@apet97/clockify-cli-115 3.0.0 → 5.0.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.
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: `3.0.0`. Requires Node.js `>=22.13.0` and
7
- `clockify-sdk-ts-115 ^3`.
6
+ Current release: `5.0.0`. 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
- `^3` peer dependency for published consumers.
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,
@@ -37,9 +37,8 @@ function reconstructClientBody(current, suppliedName) {
37
37
  const address = optionalNullableClientString(current.address, "address");
38
38
  if (address !== undefined)
39
39
  body.address = address;
40
- const currencyCode = optionalClientString(current.currencyCode, "currencyCode");
41
- if (currencyCode !== undefined)
42
- body.currencyCode = currencyCode;
40
+ if (current.ccEmails != null)
41
+ body.ccEmails = current.ccEmails;
43
42
  const email = optionalNullableClientString(current.email, "email");
44
43
  if (email !== undefined)
45
44
  body.email = email;
@@ -101,7 +100,7 @@ export const registerClientsCommand = (program, services) => {
101
100
  changed: { created: [{ type: "client", id: data.id, name: data.name }] },
102
101
  next: [
103
102
  {
104
- command: `clk115 projects create <name> --client ${data.id}`,
103
+ command: `clk115 projects create ${JSON.stringify(`Project for ${data.name}`)} --client ${data.id}`,
105
104
  reason: "Create a project for this client.",
106
105
  },
107
106
  ],
@@ -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 configOk = apiKeyOk && workspaceOk && regionOk;
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: baseUrlClass ? baseUrlClass.allowed : true,
97
+ ok: baseUrlOk,
97
98
  status: config.baseUrl ? "override" : "default",
98
99
  source: baseUrlSource,
99
100
  value: baseUrl,
@@ -99,7 +99,7 @@ export const registerSchedulingCommand = (program, services) => {
99
99
  changed: { created: [{ type: "scheduling_assignment", id: data.id }] },
100
100
  next: [
101
101
  {
102
- command: "clk115 scheduling list --json",
102
+ command: `clk115 scheduling list --from ${data.start} --to ${data.end} --json`,
103
103
  reason: "Verify the assignment appears.",
104
104
  },
105
105
  ],
@@ -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
  }
@@ -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
- const inProgressResp = await client.timeEntries.listInProgress({ workspaceId });
25
- const entries = normaliseEntries(inProgressResp);
26
- const running = entries.find((entry) => isOwn(entry, user)) ?? null;
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) ?? "",
@@ -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
- const inProgress = (await client.timeEntries.listInProgress({ workspaceId }));
16
- const running = inProgress.find((entry) => entry.userId === userId && entry.id);
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,
@@ -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 body = {};
75
- if (opts.name)
76
- body.name = opts.name;
77
- if (opts.archived !== undefined)
78
- body.archived = opts.archived;
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 ?? "" };
@@ -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, 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,6 +69,9 @@ 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)}").`);
@@ -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,10 +4,10 @@ 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
12
  const compact = trimmed.replace(/\s+/g, "");
13
13
  const re = /(\d+(?:\.\d+)?)([dhms])/gi;
@@ -23,7 +23,13 @@ export function parseDuration(input) {
23
23
  if (consumed === 0 || consumed < compact.length) {
24
24
  throw new Error(`could not parse duration ${JSON.stringify(input)}; use forms like "1h30m", "45m", "90", or ISO "PT1H30M"`);
25
25
  }
26
- return Math.round(total);
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`);
31
+ }
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;
@@ -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, so the conflict is often with something the list call hides by default. (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 including archived rows to find the holder, then reuse it, rename it, or delete it. Waiting does not help — the name is held for as long as the entity exists.",
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 = "3.0.0";
1
+ export const PACKAGE_VERSION = "5.0.0";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { realpathSync } from "node:fs";
3
3
  import { pathToFileURL } from "node:url";
4
+ import { clockifyErrorDetail } from "clockify-sdk-ts-115/errors";
4
5
  import { Command, InvalidArgumentError } from "commander";
5
6
  import { buildClient } from "./client.js";
6
7
  import { registerApiCommand } from "./commands/api.js";
@@ -154,7 +155,7 @@ export async function main(argv, services = defaultServices) {
154
155
  if (isCommanderHelpError(err)) {
155
156
  return err.exitCode ?? 0;
156
157
  }
157
- const message = err instanceof Error ? err.message : String(err);
158
+ const message = clockifyErrorDetail(err);
158
159
  const statusCode = err.statusCode;
159
160
  const flags = resolveFlagsSafe(program);
160
161
  printError(message, { mode: flags.mode, color: flags.color }, statusCode);
@@ -194,8 +195,7 @@ if (invokedDirectly) {
194
195
  main(process.argv).then((code) => {
195
196
  process.exitCode = code;
196
197
  }, (err) => {
197
- const message = err instanceof Error ? err.message : String(err);
198
- console.error(`fatal: ${message}`);
198
+ console.error(`fatal: ${clockifyErrorDetail(err)}`);
199
199
  process.exitCode = 1;
200
200
  });
201
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apet97/clockify-cli-115",
3
- "version": "3.0.0",
3
+ "version": "5.0.0",
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": "^3"
57
+ "clockify-sdk-ts-115": "^5"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/node": "^22",