@apet97/clockify-cli-115 0.3.0 → 0.3.2

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,7 +3,7 @@
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: `0.3.0`. Requires Node.js `>=22.13.0` and
6
+ Current release: `0.3.2`. Requires Node.js `>=22.13.0` and
7
7
  `clockify-sdk-ts-115 >=0.12.0 <1`.
8
8
 
9
9
  Two binaries, identical behavior:
@@ -104,7 +104,7 @@ Legacy top-level fields such as `id` remain for simple shell scripts.
104
104
  | `clk115 webhooks delete <id>` | Delete a webhook subscription. |
105
105
  | `clk115 invoices list` | List invoices in the workspace. |
106
106
  | `clk115 invoices create --client id --number N --currency USD --issued YYYY-MM-DD --due YYYY-MM-DD [--time-view-mode mode]` | Create an invoice draft. |
107
- | `clk115 expenses list [--limit N] [--page N] [--start YYYY-MM-DD] [--end YYYY-MM-DD]` | List workspace expenses. |
107
+ | `clk115 expenses list [--limit N] [--page-size N] [--max-pages N] [--page N] [--start date] [--end date]` | List workspace expenses; date bounds are applied client-side across bounded pages. |
108
108
  | `clk115 expenses get <id>` | Get one expense by ID. |
109
109
  | `clk115 expenses create --amount N --category id --date YYYY-MM-DD [--user id] [--project id] [--task id] [--notes text] [--billable\|--no-billable]` | Create an expense (scalar body; --user defaults to the API-key owner). |
110
110
  | `clk115 expenses update <id> --amount N --category id --date YYYY-MM-DD --user id [--project id] [--task id] [--notes text] [--billable\|--no-billable]` | Update an expense (full replace of amount, category, date). |
package/dist/client.js CHANGED
@@ -4,7 +4,7 @@ export async function buildClient(config) {
4
4
  const { createClockifyClient } = await import("clockify-sdk-ts-115");
5
5
  return createClockifyClient({
6
6
  apiKey,
7
- allowInsecureBaseUrl: false,
7
+ allowNonClockifyHttpsHost: false,
8
8
  ...(config.baseUrl !== undefined ? { environment: config.baseUrl } : {}),
9
9
  });
10
10
  }
@@ -180,7 +180,23 @@ export const registerClientsCommand = (program, services) => {
180
180
  .description("Delete a client by ID (archives first; an active client cannot be deleted).")
181
181
  .action(async function (id) {
182
182
  const { client, workspaceId, output } = await resolveContext(this, services);
183
- await archiveThenDeleteClient({ workspaceId, id, resource: client.clients });
183
+ await archiveThenDeleteClient({
184
+ workspaceId,
185
+ id,
186
+ adapter: {
187
+ getCurrent: ({ workspaceId: currentWorkspaceId, id: clientId }) => client.clients.get({ workspaceId: currentWorkspaceId, clientId }),
188
+ archive: async ({ workspaceId: currentWorkspaceId, id: clientId, current }) => {
189
+ await client.clients.update({
190
+ workspaceId: currentWorkspaceId,
191
+ clientId,
192
+ body: reconstructClientBody({ ...current, archived: true }),
193
+ });
194
+ },
195
+ delete: async ({ workspaceId: currentWorkspaceId, id: clientId }) => {
196
+ await client.clients.delete({ workspaceId: currentWorkspaceId, clientId });
197
+ },
198
+ },
199
+ });
184
200
  printReceipt({
185
201
  ok: true,
186
202
  action: "clients.delete",
@@ -1,3 +1,4 @@
1
+ import { listExpensesFiltered } from "clockify-sdk-ts-115/expense-list";
1
2
  import { entityId } from "clockify-sdk-ts-115/operation-receipt";
2
3
  import { printObject, printRecords } from "../output.js";
3
4
  import { printReceipt } from "../receipt.js";
@@ -21,27 +22,23 @@ export const registerExpensesCommand = (program, services) => {
21
22
  const expenses = program.command("expenses").description("Inspect workspace expenses.");
22
23
  leafCommand(expenses, "list", "read")
23
24
  .description("List expenses in the workspace.")
24
- .option("--limit <n>", "Items per page (default 25, max 200).", parseIntArg, 25)
25
+ .option("--limit <n>", "Total records to return (default 25, max 10000).", parseIntArg, 25)
26
+ .option("--page-size <n>", "Records fetched per page (default 50, max 200).", parseIntArg, 50)
27
+ .option("--max-pages <n>", "Maximum pages to scan (default 100, max 1000).", parseIntArg, 100)
25
28
  .option("--page <n>", "Page number.", parseIntArg, 1)
26
- .option("--start <date>", "Start of the date range (YYYY-MM-DD).")
27
- .option("--end <date>", "End of the date range (YYYY-MM-DD).")
29
+ .option("--start <date>", "Inclusive start bound (YYYY-MM-DD or RFC3339 with explicit Z/offset).")
30
+ .option("--end <date>", "Inclusive end bound (YYYY-MM-DD or RFC3339 with explicit Z/offset).")
28
31
  .action(async function (opts) {
29
32
  const { client, workspaceId, output } = await resolveContext(this, services);
30
- const req = {
31
- workspaceId,
33
+ const result = await listExpensesFiltered(client.expenses.list.bind(client.expenses), { workspaceId }, {
32
34
  page: opts.page,
33
- "page-size": clampPageSize(opts.limit, 200),
34
- };
35
- const response = (await client.expenses.list(req));
36
- const items = (() => {
37
- const inner = response.expenses;
38
- if (Array.isArray(inner))
39
- return inner;
40
- if (inner && Array.isArray(inner.expenses))
41
- return inner.expenses;
42
- return [];
43
- })();
44
- const rows = items.map((raw) => {
35
+ pageSize: clampPageSize(opts.pageSize, 200),
36
+ limit: opts.limit,
37
+ maxPages: opts.maxPages,
38
+ ...(opts.start !== undefined ? { start: opts.start } : {}),
39
+ ...(opts.end !== undefined ? { end: opts.end } : {}),
40
+ });
41
+ const rows = result.items.map((raw) => {
45
42
  const e = raw;
46
43
  const category = typeof e.category === "object" && e.category !== null
47
44
  ? (e.category.name ?? "")
@@ -58,21 +55,9 @@ export const registerExpensesCommand = (program, services) => {
58
55
  billable: e.billable === true,
59
56
  };
60
57
  });
61
- const startDay = opts.start;
62
- const endDay = opts.end;
63
- const visible = startDay || endDay
64
- ? rows.filter((r) => {
65
- const day = (r.date ?? "").slice(0, 10);
66
- if (!day)
67
- return false;
68
- if (startDay && day < startDay)
69
- return false;
70
- if (endDay && day > endDay)
71
- return false;
72
- return true;
73
- })
74
- : rows;
75
- printRecords(visible, output);
58
+ for (const warning of result.warnings)
59
+ console.error(`WARN ${warning}`);
60
+ printRecords(rows, output);
76
61
  });
77
62
  leafCommand(expenses, "create", "write")
78
63
  .requiredOption("--amount <n>", "Amount.", parseFloatArg)
@@ -135,7 +135,27 @@ export const registerProjectsCommand = (program, services) => {
135
135
  .description("Delete a project by ID (archives first; an active project cannot be deleted).")
136
136
  .action(async function (id) {
137
137
  const { client, workspaceId, output } = await resolveContext(this, services);
138
- await archiveThenDeleteProject({ workspaceId, id, resource: client.projects });
138
+ await archiveThenDeleteProject({
139
+ workspaceId,
140
+ id,
141
+ adapter: {
142
+ getCurrent: ({ workspaceId: currentWorkspaceId, id: projectId }) => client.projects.get({ workspaceId: currentWorkspaceId, projectId }),
143
+ archive: async ({ workspaceId: currentWorkspaceId, id: projectId, current, }) => {
144
+ await client.projects.update({
145
+ workspaceId: currentWorkspaceId,
146
+ projectId,
147
+ name: current.name,
148
+ archived: true,
149
+ });
150
+ },
151
+ delete: async ({ workspaceId: currentWorkspaceId, id: projectId }) => {
152
+ await client.projects.delete({
153
+ workspaceId: currentWorkspaceId,
154
+ projectId,
155
+ });
156
+ },
157
+ },
158
+ });
139
159
  printReceipt({
140
160
  ok: true,
141
161
  action: "projects.delete",
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = "0.3.0";
1
+ export const PACKAGE_VERSION = "0.3.2";
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ import { parseCompletionShell, renderCompletion } from "./completions.js";
26
26
  import { loadConfig } from "./config.js";
27
27
  import { PACKAGE_VERSION } from "./generated/version.js";
28
28
  import { printError } from "./output.js";
29
- export const defaultServices = {
29
+ const defaultServices = {
30
30
  loadConfig,
31
31
  buildClient,
32
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apet97/clockify-cli-115",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
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>",
@@ -41,10 +41,11 @@
41
41
  "test": "node ../scripts/generate-package-versions.mjs && vitest run",
42
42
  "test:coverage": "node ../scripts/generate-package-versions.mjs && vitest run --coverage",
43
43
  "test:watch": "node ../scripts/generate-package-versions.mjs && vitest",
44
+ "mutation": "node ../scripts/generate-package-versions.mjs && npm run build -w clockify-sdk-ts-115 && cd .. && CLOCKIFY_API_KEY='' CLOCKIFY_WORKSPACE_ID='' stryker run cli/stryker.conf.json",
44
45
  "type-check": "node ../scripts/generate-package-versions.mjs && tsc -p tsconfig.json --noEmit",
45
46
  "lint": "eslint .",
46
47
  "lint:fix": "eslint . --fix",
47
- "prepublishOnly": "npm run type-check && npm test && npm run build"
48
+ "prepublishOnly": "npm run type-check && npm test && npm run build && node ../scripts/pack-consumer-smoke.mjs --package=cli"
48
49
  },
49
50
  "dependencies": {
50
51
  "cli-table3": "^0.6.5",
@@ -57,14 +58,14 @@
57
58
  },
58
59
  "devDependencies": {
59
60
  "@types/node": "^22",
60
- "@vitest/coverage-v8": "^4.1.9",
61
+ "@vitest/coverage-v8": "^4.1.10",
61
62
  "clockify-sdk-ts-115": "*",
62
63
  "eslint": "^10.5.0",
63
- "eslint-plugin-import-x": "^4.16.2",
64
+ "eslint-plugin-import-x": "^4.17.1",
64
65
  "tsx": "^4.19.2",
65
66
  "typescript": "^5.7.0",
66
- "typescript-eslint": "^8.59.4",
67
- "vitest": "^4.1.4"
67
+ "typescript-eslint": "^8.64.0",
68
+ "vitest": "^4.1.10"
68
69
  },
69
70
  "publishConfig": {
70
71
  "access": "public",