@apet97/clockify-cli-115 0.1.0 → 0.1.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.
@@ -11,7 +11,7 @@ export const registerClientsCommand = (program, services) => {
11
11
  .option("--limit <n>", "Items per page (default 25, max 200).", parseIntArg, 25)
12
12
  .option("--page <n>", "Page number.", parseIntArg, 1)
13
13
  .option("--name <text>", "Filter by client name substring.")
14
- .option("--archived", "Include archived clients.", false)
14
+ .option("--archived", "Show only archived clients (default lists both archived and active).", false)
15
15
  .action(async function (opts) {
16
16
  const { client, workspaceId, output } = await resolveContext(this, services);
17
17
  const req = {
@@ -63,7 +63,21 @@ export const registerExpensesCommand = (program, services) => {
63
63
  billable: e.billable === true,
64
64
  };
65
65
  });
66
- printRecords(rows, output);
66
+ const startDay = opts.start;
67
+ const endDay = opts.end;
68
+ const visible = startDay || endDay
69
+ ? rows.filter((r) => {
70
+ const day = (r.date ?? "").slice(0, 10);
71
+ if (!day)
72
+ return false;
73
+ if (startDay && day < startDay)
74
+ return false;
75
+ if (endDay && day > endDay)
76
+ return false;
77
+ return true;
78
+ })
79
+ : rows;
80
+ printRecords(visible, output);
67
81
  });
68
82
  expenses
69
83
  .command("create")
@@ -28,11 +28,12 @@ export const registerLogCommand = (program, services) => {
28
28
  ? await resolveTagIds(client, workspaceId, opts.tag)
29
29
  : undefined;
30
30
  const seconds = parseDuration(duration);
31
- const endIso = opts.end ?? new Date().toISOString();
32
- const endMs = Date.parse(endIso);
31
+ const endInput = opts.end ?? new Date().toISOString();
32
+ const endMs = Date.parse(endInput);
33
33
  if (Number.isNaN(endMs)) {
34
34
  throw new Error(`--end ${JSON.stringify(opts.end)} is not a valid ISO 8601 timestamp`);
35
35
  }
36
+ const endIso = new Date(endMs).toISOString();
36
37
  const startIso = new Date(endMs - seconds * 1000).toISOString();
37
38
  const body = {
38
39
  start: startIso,
@@ -10,7 +10,7 @@ export const registerProjectsCommand = (program, services) => {
10
10
  .option("--limit <n>", "Items per page (default 25, max 200).", parseIntArg, 25)
11
11
  .option("--page <n>", "Page number.", parseIntArg, 1)
12
12
  .option("--name <text>", "Filter by project name substring.")
13
- .option("--archived", "Include archived projects.", false)
13
+ .option("--archived", "Show only archived projects (default lists both archived and active).", false)
14
14
  .option("--client <id>", "Filter by client ID.")
15
15
  .action(async function (opts) {
16
16
  const { client, workspaceId, output } = await resolveContext(this, services);
@@ -23,6 +23,7 @@ const SHARED_REPORT_TYPES = [
23
23
  "WEEKLY",
24
24
  "EXPENSE_DETAILED",
25
25
  "INVOICE_TIME",
26
+ "KIOSK_PIN_LIST",
26
27
  "ATTENDANCE_DETAILED",
27
28
  "ATTENDANCE_SUMMARY",
28
29
  "ASSIGNMENT_LIST",
@@ -30,7 +31,11 @@ const SHARED_REPORT_TYPES = [
30
31
  "APPROVAL_DETAILED",
31
32
  "APPROVAL_SUMMARY",
32
33
  "BALANCE_LIST",
34
+ "INVOICE_AMOUNT_LIST",
35
+ "INVOICE_DETAILED",
33
36
  "TIMEOFF_DETAILED",
37
+ "TIMEOFF_HOLIDAY",
38
+ "TIMEOFF_BALANCE",
34
39
  "EXPENSE_SUMMARY",
35
40
  ];
36
41
  function parseFilter(raw) {
@@ -35,7 +35,7 @@ export const registerStatusCommand = (program, services) => {
35
35
  description: running.description ?? "",
36
36
  projectId: running.projectId ?? "",
37
37
  startedAt: extractStart(running),
38
- elapsed: formatIsoDuration(extractIsoDuration(running)),
38
+ elapsed: formatRunningElapsed(running),
39
39
  }
40
40
  : "(no timer running)",
41
41
  }, output);
@@ -64,3 +64,27 @@ function extractIsoDuration(entry) {
64
64
  const interval = entry.timeInterval;
65
65
  return interval?.duration ?? null;
66
66
  }
67
+ function humanizeSeconds(total) {
68
+ if (total <= 0)
69
+ return "0s";
70
+ const hours = Math.floor(total / 3600);
71
+ const minutes = Math.floor((total % 3600) / 60);
72
+ const seconds = total % 60;
73
+ const parts = [];
74
+ if (hours)
75
+ parts.push(`${hours}h`);
76
+ if (minutes)
77
+ parts.push(`${minutes}m`);
78
+ if (seconds)
79
+ parts.push(`${seconds}s`);
80
+ return parts.length > 0 ? parts.join("") : "0s";
81
+ }
82
+ function formatRunningElapsed(entry) {
83
+ const iso = extractIsoDuration(entry);
84
+ if (iso)
85
+ return formatIsoDuration(iso);
86
+ const startMs = Date.parse(extractStart(entry));
87
+ if (!Number.isFinite(startMs))
88
+ return "0s";
89
+ return humanizeSeconds(Math.max(0, Math.round((Date.now() - startMs) / 1000)));
90
+ }
@@ -8,7 +8,7 @@ export const registerTagsCommand = (program, services) => {
8
8
  .option("--limit <n>", "Items per page (default 25, max 200).", parseIntArg, 25)
9
9
  .option("--page <n>", "Page number.", parseIntArg, 1)
10
10
  .option("--name <text>", "Filter by tag name substring.")
11
- .option("--archived", "Include archived tags.", false)
11
+ .option("--archived", "Show only archived tags (default lists both archived and active).", false)
12
12
  .action(async function (opts) {
13
13
  const { client, workspaceId, output } = await resolveContext(this, services);
14
14
  const req = {
@@ -37,6 +37,7 @@ export const CLOCKIFY_ERROR_CODES = [
37
37
  ],
38
38
  "retry": false,
39
39
  "surfaces": [
40
+ "sdk",
40
41
  "cli",
41
42
  "mcp"
42
43
  ],
@@ -242,7 +243,7 @@ export function errorCodeForStatus(status) {
242
243
  export function errorCodeForMessage(message) {
243
244
  if (/does(?:n'?t| not) (?:belong to|exist)/i.test(message))
244
245
  return "not_found";
245
- if (/(unauthorized|forbidden|permission|api[\s_-]?key|addon[\s_-]?token|CLOCKIFY_API_KEY|CLOCKIFY_ADDON_TOKEN)/i.test(message))
246
+ if (/(unauthorized|forbidden|permission|api[\s_-]?key|addon[\s_-]?token|CLOCKIFY_API_KEY|CLOCKIFY_ADDON_TOKEN|workspace id not set)/i.test(message))
246
247
  return "auth_or_permission";
247
248
  if (/(required|provide|missing|invalid|unknown option|unknown command|could not parse|not valid|must use|must not|confirmation token)/i.test(message)) {
248
249
  return "invalid_request";
package/dist/output.js CHANGED
@@ -99,11 +99,11 @@ export function selectValue(value, selector) {
99
99
  return current;
100
100
  }
101
101
  export function printJson(value, options = {}) {
102
- const selected = selectValue(value, options.select);
102
+ const selected = selectValue(value, options.select) ?? null;
103
103
  console.log(JSON.stringify(selected, null, options.compact ? 0 : 2));
104
104
  }
105
105
  export function printNdjson(value, options = {}) {
106
- const selected = selectValue(value, options.select);
106
+ const selected = selectValue(value, options.select) ?? null;
107
107
  if (Array.isArray(selected)) {
108
108
  for (const item of selected) {
109
109
  console.log(JSON.stringify(item));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apet97/clockify-cli-115",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Unofficial, community-built — 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ć <petkovic.aleksandar037@gmail.com>",