@perspectask/sdk 1.0.0 → 1.2.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 +48 -0
- package/dist/index.cjs +457 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +934 -2
- package/dist/index.d.ts +934 -2
- package/dist/index.js +423 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,6 +202,49 @@ await pt.tasks.pullRequests.unlink('abc', prs![0].id);
|
|
|
202
202
|
|
|
203
203
|
Needs the PerspecTask GitHub app on the repository; `link` answers 404 with `code: "not_installed"` otherwise.
|
|
204
204
|
|
|
205
|
+
### KPIs
|
|
206
|
+
|
|
207
|
+
A task's KPI is a series of entries: `target` (the number to reach, optionally by a date) and `actual` (a reading at a moment, `at` required).
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
const { data: ids } = await pt.tasks.kpis.listTasks(); // ["abc", "9fb49"]: tasks that have KPIs
|
|
211
|
+
|
|
212
|
+
const { data: entries } = await pt.tasks.kpis.list('abc');
|
|
213
|
+
// [{ id, kind: "target" | "actual", at?, value?, encrypted? }], oldest first
|
|
214
|
+
|
|
215
|
+
await pt.tasks.kpis.create('abc', { kind: 'target', value: 100000, at: '2026-12-31T00:00:00Z' });
|
|
216
|
+
await pt.tasks.kpis.create('abc', { kind: 'actual', value: 42000, at: new Date().toISOString() });
|
|
217
|
+
await pt.tasks.kpis.update('abc', entries![0].id, { value: 120000 }); // `at: null` drops a target's date
|
|
218
|
+
await pt.tasks.kpis.delete('abc', entries![0].id);
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Encrypted tasks are refused (403). An entry saved encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
222
|
+
|
|
223
|
+
### Timers
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
const { data: status } = await pt.timers.status({ day_start: '2026-11-23T00:00:00+02:00' });
|
|
227
|
+
// { worked_today: 5400, running?: { id, task_id, started_at, running: true } }
|
|
228
|
+
|
|
229
|
+
const { data: started } = await pt.timers.start('abc'); // { timer, stopped?, already_running? }
|
|
230
|
+
await pt.timers.stop(); // the stopped timer (`discarded: true` under 5 s)
|
|
231
|
+
const { data: timers } = await pt.timers.list({ task_id: 'abc', limit: 50 });
|
|
232
|
+
// [{ id, task_id, started_at, ended_at?, duration?, running? }], newest first
|
|
233
|
+
await pt.timers.update(timers![0].id, { ended_at: '2026-11-23T10:30:00Z' });
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Only one timer runs at a time. Deleting a timer is only possible in the web app.
|
|
237
|
+
|
|
238
|
+
### History
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
const { data: changes } = await pt.tasks.history.list({ since: '2026-11-17T00:00:00Z' });
|
|
242
|
+
const { data: taskChanges } = await pt.tasks.history.get('abc');
|
|
243
|
+
// [{ task_id, action, at, old?, new?, reason?, actor?, encrypted? }], newest first
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Read only: it's recorded automatically on every change.
|
|
247
|
+
|
|
205
248
|
## Scopes
|
|
206
249
|
|
|
207
250
|
API keys carry scopes that control access:
|
|
@@ -211,6 +254,11 @@ API keys carry scopes that control access:
|
|
|
211
254
|
| `tasks:read` | `list`, `get`, `pullRequests.list` |
|
|
212
255
|
| `tasks:write` | `create`, `update` (including title/description), `pullRequests.link` / `unlink` |
|
|
213
256
|
| `tasks:write:meta` | `create`, `update` everything **except** editing title/description of existing tasks, plus `pullRequests.link` / `unlink`. Built for AI agents. |
|
|
257
|
+
| `kpis:read` | `kpis.listTasks`, `kpis.list` |
|
|
258
|
+
| `kpis:write` | `kpis.create`, `kpis.update`, `kpis.delete` |
|
|
259
|
+
| `timers:read` | `timers.status`, `timers.list` |
|
|
260
|
+
| `timers:write` | `timers.start`, `timers.stop`, `timers.update` |
|
|
261
|
+
| `history:read` | `tasks.history.list`, `.get` |
|
|
214
262
|
|
|
215
263
|
A call missing the required scope returns `403`.
|
|
216
264
|
|
package/dist/index.cjs
CHANGED
|
@@ -32,34 +32,67 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
CLI_CLIENT_ID: () => CLI_CLIENT_ID,
|
|
34
34
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
35
|
+
Kpis: () => Kpis,
|
|
35
36
|
OAuthTokenError: () => OAuthTokenError,
|
|
36
37
|
PerspecTask: () => PerspecTask,
|
|
37
38
|
PullRequests: () => PullRequests,
|
|
38
39
|
Tasks: () => Tasks,
|
|
40
|
+
Timers: () => Timers,
|
|
39
41
|
default: () => index_default,
|
|
40
42
|
refreshTokens: () => refreshTokens,
|
|
41
43
|
revokeTokens: () => revokeTokens,
|
|
42
44
|
startDeviceLogin: () => startDeviceLogin,
|
|
43
45
|
waitForDeviceLogin: () => waitForDeviceLogin,
|
|
44
46
|
zCreateTaskBody: () => zCreateTaskBody,
|
|
47
|
+
zCreateTaskKpiBody: () => zCreateTaskKpiBody,
|
|
48
|
+
zCreateTaskKpiPath: () => zCreateTaskKpiPath,
|
|
49
|
+
zCreateTaskKpiResponse: () => zCreateTaskKpiResponse,
|
|
45
50
|
zCreateTaskResponse: () => zCreateTaskResponse,
|
|
51
|
+
zDeleteTaskKpiPath: () => zDeleteTaskKpiPath,
|
|
52
|
+
zDeleteTaskKpiResponse: () => zDeleteTaskKpiResponse,
|
|
46
53
|
zGetTaskPath: () => zGetTaskPath,
|
|
47
54
|
zGetTaskQuery: () => zGetTaskQuery,
|
|
48
55
|
zGetTaskResponse: () => zGetTaskResponse,
|
|
56
|
+
zGetTimerStatusQuery: () => zGetTimerStatusQuery,
|
|
57
|
+
zGetTimerStatusResponse: () => zGetTimerStatusResponse,
|
|
58
|
+
zHistoryEntry: () => zHistoryEntry,
|
|
59
|
+
zKpiEntry: () => zKpiEntry,
|
|
49
60
|
zLinkTaskPullRequestBody: () => zLinkTaskPullRequestBody,
|
|
50
61
|
zLinkTaskPullRequestPath: () => zLinkTaskPullRequestPath,
|
|
51
62
|
zLinkTaskPullRequestResponse: () => zLinkTaskPullRequestResponse,
|
|
63
|
+
zListKpiTasksResponse: () => zListKpiTasksResponse,
|
|
64
|
+
zListTaskHistoryPath: () => zListTaskHistoryPath,
|
|
65
|
+
zListTaskHistoryQuery: () => zListTaskHistoryQuery,
|
|
66
|
+
zListTaskHistoryResponse: () => zListTaskHistoryResponse,
|
|
67
|
+
zListTaskKpisPath: () => zListTaskKpisPath,
|
|
68
|
+
zListTaskKpisResponse: () => zListTaskKpisResponse,
|
|
52
69
|
zListTaskPullRequestsPath: () => zListTaskPullRequestsPath,
|
|
53
70
|
zListTaskPullRequestsResponse: () => zListTaskPullRequestsResponse,
|
|
71
|
+
zListTasksHistoryQuery: () => zListTasksHistoryQuery,
|
|
72
|
+
zListTasksHistoryResponse: () => zListTasksHistoryResponse,
|
|
54
73
|
zListTasksQuery: () => zListTasksQuery,
|
|
55
74
|
zListTasksResponse: () => zListTasksResponse,
|
|
75
|
+
zListTimersQuery: () => zListTimersQuery,
|
|
76
|
+
zListTimersResponse: () => zListTimersResponse,
|
|
56
77
|
zPullRequest: () => zPullRequest,
|
|
78
|
+
zStartTaskTimerPath: () => zStartTaskTimerPath,
|
|
79
|
+
zStartTaskTimerResponse: () => zStartTaskTimerResponse,
|
|
80
|
+
zStartTimerResponse: () => zStartTimerResponse,
|
|
81
|
+
zStopTimerResponse: () => zStopTimerResponse,
|
|
57
82
|
zTask: () => zTask,
|
|
83
|
+
zTimer: () => zTimer,
|
|
84
|
+
zTimerStatus: () => zTimerStatus,
|
|
58
85
|
zUnlinkTaskPullRequestPath: () => zUnlinkTaskPullRequestPath,
|
|
59
86
|
zUnlinkTaskPullRequestResponse: () => zUnlinkTaskPullRequestResponse,
|
|
60
87
|
zUpdateTaskBody: () => zUpdateTaskBody,
|
|
88
|
+
zUpdateTaskKpiBody: () => zUpdateTaskKpiBody,
|
|
89
|
+
zUpdateTaskKpiPath: () => zUpdateTaskKpiPath,
|
|
90
|
+
zUpdateTaskKpiResponse: () => zUpdateTaskKpiResponse,
|
|
61
91
|
zUpdateTaskPath: () => zUpdateTaskPath,
|
|
62
|
-
zUpdateTaskResponse: () => zUpdateTaskResponse
|
|
92
|
+
zUpdateTaskResponse: () => zUpdateTaskResponse,
|
|
93
|
+
zUpdateTimerBody: () => zUpdateTimerBody,
|
|
94
|
+
zUpdateTimerPath: () => zUpdateTimerPath,
|
|
95
|
+
zUpdateTimerResponse: () => zUpdateTimerResponse
|
|
63
96
|
});
|
|
64
97
|
module.exports = __toCommonJS(index_exports);
|
|
65
98
|
|
|
@@ -901,6 +934,30 @@ var Tasks = class {
|
|
|
901
934
|
}
|
|
902
935
|
});
|
|
903
936
|
}
|
|
937
|
+
/**
|
|
938
|
+
* List the history of all tasks
|
|
939
|
+
*
|
|
940
|
+
* Every change to your tasks, newest first: status, priority, deadline, parents, title and description edits. Recorded automatically on every change; nobody can edit it. Changes made through the API or a connected app carry an `actor`. Encrypted and deleted tasks are left out.
|
|
941
|
+
*/
|
|
942
|
+
static listTasksHistory(options) {
|
|
943
|
+
return (options?.client ?? client).get({
|
|
944
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
945
|
+
url: "/tasks/history",
|
|
946
|
+
...options
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* List the history of a task
|
|
951
|
+
*
|
|
952
|
+
* Every change to one task, newest first. Recorded automatically on every change; nobody can edit it. Changes made through the API or a connected app carry an `actor`.
|
|
953
|
+
*/
|
|
954
|
+
static listTaskHistory(options) {
|
|
955
|
+
return (options.client ?? client).get({
|
|
956
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
957
|
+
url: "/tasks/{id}/history",
|
|
958
|
+
...options
|
|
959
|
+
});
|
|
960
|
+
}
|
|
904
961
|
};
|
|
905
962
|
var PullRequests = class {
|
|
906
963
|
/**
|
|
@@ -944,6 +1001,140 @@ var PullRequests = class {
|
|
|
944
1001
|
});
|
|
945
1002
|
}
|
|
946
1003
|
};
|
|
1004
|
+
var Kpis = class {
|
|
1005
|
+
/**
|
|
1006
|
+
* List tasks with KPIs
|
|
1007
|
+
*
|
|
1008
|
+
* Short ids of your tasks that have KPI entries. Encrypted tasks are left out. Fetch a task with `GET /tasks/{id}` for its title.
|
|
1009
|
+
*/
|
|
1010
|
+
static listKpiTasks(options) {
|
|
1011
|
+
return (options?.client ?? client).get({
|
|
1012
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1013
|
+
url: "/kpis",
|
|
1014
|
+
...options
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* List the KPI entries of a task
|
|
1019
|
+
*
|
|
1020
|
+
* The task's targets and actuals, oldest first (dateless targets first). Encrypted tasks are refused (403). An entry saved end-to-end encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
1021
|
+
*/
|
|
1022
|
+
static listTaskKpis(options) {
|
|
1023
|
+
return (options.client ?? client).get({
|
|
1024
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1025
|
+
url: "/tasks/{id}/kpis",
|
|
1026
|
+
...options
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Add a KPI entry to a task
|
|
1031
|
+
*
|
|
1032
|
+
* Add a target (the number to reach, optionally by a date) or an actual (a reading at a moment; `at` required). Encrypted tasks are refused (403). An entry saved end-to-end encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
1033
|
+
*/
|
|
1034
|
+
static createTaskKpi(options) {
|
|
1035
|
+
return (options.client ?? client).post({
|
|
1036
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1037
|
+
url: "/tasks/{id}/kpis",
|
|
1038
|
+
...options,
|
|
1039
|
+
headers: {
|
|
1040
|
+
"Content-Type": "application/json",
|
|
1041
|
+
...options.headers
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Delete a KPI entry
|
|
1047
|
+
*/
|
|
1048
|
+
static deleteTaskKpi(options) {
|
|
1049
|
+
return (options.client ?? client).delete({
|
|
1050
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1051
|
+
url: "/tasks/{id}/kpis/{kpiId}",
|
|
1052
|
+
...options
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Update a KPI entry
|
|
1057
|
+
*
|
|
1058
|
+
* Change any of `kind`, `value` and `at`. Only the fields you send change.
|
|
1059
|
+
*/
|
|
1060
|
+
static updateTaskKpi(options) {
|
|
1061
|
+
return (options.client ?? client).patch({
|
|
1062
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1063
|
+
url: "/tasks/{id}/kpis/{kpiId}",
|
|
1064
|
+
...options,
|
|
1065
|
+
headers: {
|
|
1066
|
+
"Content-Type": "application/json",
|
|
1067
|
+
...options.headers
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
var Timers = class {
|
|
1073
|
+
/**
|
|
1074
|
+
* Get the running timer and time worked today
|
|
1075
|
+
*
|
|
1076
|
+
* The running timer, if any, and the seconds of finished timers today. Pass `day_start` with the user's local midnight so today follows their time zone.
|
|
1077
|
+
*/
|
|
1078
|
+
static getTimerStatus(options) {
|
|
1079
|
+
return (options?.client ?? client).get({
|
|
1080
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1081
|
+
url: "/timers/status",
|
|
1082
|
+
...options
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* List timers
|
|
1087
|
+
*
|
|
1088
|
+
* Your work sessions, newest first: which task, when it started and ended, and its duration in seconds. Filter by task with `task_id`. Timers of encrypted tasks are included (they hold no task content).
|
|
1089
|
+
*/
|
|
1090
|
+
static listTimers(options) {
|
|
1091
|
+
return (options?.client ?? client).get({
|
|
1092
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1093
|
+
url: "/timers",
|
|
1094
|
+
...options
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Start a timer on a task
|
|
1099
|
+
*
|
|
1100
|
+
* Start tracking time on a task. Only one timer runs at a time, so a timer running on another task is stopped first (returned as `stopped`). Starting the task that already runs changes nothing (200, `already_running`). Refused for a completed or cancelled task (400) and an encrypted one (403).
|
|
1101
|
+
*/
|
|
1102
|
+
static startTaskTimer(options) {
|
|
1103
|
+
return (options.client ?? client).post({
|
|
1104
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1105
|
+
url: "/tasks/{id}/timers",
|
|
1106
|
+
...options
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Stop the running timer
|
|
1111
|
+
*
|
|
1112
|
+
* Stop whatever timer is running. A timer stopped under 5 seconds is deleted instead of kept (`discarded: true`).
|
|
1113
|
+
*/
|
|
1114
|
+
static stopTimer(options) {
|
|
1115
|
+
return (options?.client ?? client).post({
|
|
1116
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1117
|
+
url: "/timers/stop",
|
|
1118
|
+
...options
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Update a timer
|
|
1123
|
+
*
|
|
1124
|
+
* Change when a finished timer started and/or ended, e.g. to fix a forgotten stop. Refused for a running timer, a date in the future, a start after the end, or an overlap with another timer (400). Deleting a timer is only possible in the web app.
|
|
1125
|
+
*/
|
|
1126
|
+
static updateTimer(options) {
|
|
1127
|
+
return (options.client ?? client).patch({
|
|
1128
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1129
|
+
url: "/timers/{timerId}",
|
|
1130
|
+
...options,
|
|
1131
|
+
headers: {
|
|
1132
|
+
"Content-Type": "application/json",
|
|
1133
|
+
...options.headers
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
947
1138
|
|
|
948
1139
|
// src/oauth.ts
|
|
949
1140
|
var CLI_CLIENT_ID = "perspectask-cli";
|
|
@@ -1146,6 +1337,91 @@ var zPullRequest = z.object({
|
|
|
1146
1337
|
description: "`auto` = linked by the pt- code in the PR; `manual` = linked by URL."
|
|
1147
1338
|
})
|
|
1148
1339
|
});
|
|
1340
|
+
var zKpiEntry = z.object({
|
|
1341
|
+
id: z.uuid().register(z.globalRegistry, {
|
|
1342
|
+
description: "Id of this entry. Pass it to update or delete."
|
|
1343
|
+
}),
|
|
1344
|
+
kind: z.enum(["target", "actual"]).register(z.globalRegistry, {
|
|
1345
|
+
description: "`target` = the number you aim for (by `at`); `actual` = a reading of where it stands at `at`."
|
|
1346
|
+
}),
|
|
1347
|
+
at: z.optional(z.string().register(z.globalRegistry, {
|
|
1348
|
+
description: "ISO 8601 UTC instant. Omitted for a target with no date."
|
|
1349
|
+
})),
|
|
1350
|
+
value: z.optional(z.number().register(z.globalRegistry, {
|
|
1351
|
+
description: "The number. Omitted when the entry was saved end-to-end encrypted (then `encrypted` is true)."
|
|
1352
|
+
})),
|
|
1353
|
+
encrypted: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1354
|
+
description: "Only present when the value is end-to-end encrypted and so not readable over the API."
|
|
1355
|
+
}))
|
|
1356
|
+
});
|
|
1357
|
+
var zTimer = z.object({
|
|
1358
|
+
id: z.uuid().register(z.globalRegistry, {
|
|
1359
|
+
description: "Id of this timer. Pass it to update it."
|
|
1360
|
+
}),
|
|
1361
|
+
task_id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
|
|
1362
|
+
description: "The task (short id). Its title comes from `GET /tasks/{id}`."
|
|
1363
|
+
}),
|
|
1364
|
+
started_at: z.string().register(z.globalRegistry, {
|
|
1365
|
+
description: "ISO 8601 UTC instant."
|
|
1366
|
+
}),
|
|
1367
|
+
ended_at: z.optional(z.string().register(z.globalRegistry, {
|
|
1368
|
+
description: "ISO 8601 UTC instant. Omitted while it runs."
|
|
1369
|
+
})),
|
|
1370
|
+
duration: z.optional(z.int().register(z.globalRegistry, {
|
|
1371
|
+
description: "Seconds between start and end. Omitted while it runs."
|
|
1372
|
+
})),
|
|
1373
|
+
running: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1374
|
+
description: "Only present on the running timer."
|
|
1375
|
+
})),
|
|
1376
|
+
discarded: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1377
|
+
description: "Only on a stop: the timer ran under 5 seconds, so it was deleted instead of kept."
|
|
1378
|
+
}))
|
|
1379
|
+
});
|
|
1380
|
+
var zTimerStatus = z.object({
|
|
1381
|
+
worked_today: z.int().register(z.globalRegistry, {
|
|
1382
|
+
description: "Seconds of finished timers since the start of the day (`day_start`, default midnight UTC)."
|
|
1383
|
+
}),
|
|
1384
|
+
running: z.optional(z.intersection(zTimer, z.unknown().register(z.globalRegistry, {
|
|
1385
|
+
description: "The running timer. Omitted when none runs."
|
|
1386
|
+
})))
|
|
1387
|
+
});
|
|
1388
|
+
var zStartTimerResponse = z.object({
|
|
1389
|
+
timer: z.intersection(zTimer, z.unknown().register(z.globalRegistry, {
|
|
1390
|
+
description: "The running timer on this task."
|
|
1391
|
+
})),
|
|
1392
|
+
stopped: z.optional(z.intersection(zTimer, z.unknown().register(z.globalRegistry, {
|
|
1393
|
+
description: "The timer this start stopped on another task (only one runs at a time)."
|
|
1394
|
+
}))),
|
|
1395
|
+
already_running: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1396
|
+
description: "Only present when this task\u2019s timer was already running; nothing changed."
|
|
1397
|
+
}))
|
|
1398
|
+
});
|
|
1399
|
+
var zHistoryEntry = z.object({
|
|
1400
|
+
task_id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
|
|
1401
|
+
description: "The task (short id)."
|
|
1402
|
+
}),
|
|
1403
|
+
action: z.string().register(z.globalRegistry, {
|
|
1404
|
+
description: "What changed: `created`, `status`, `priority`, `scheduled`, `parent_added`, `parent_removed`, `title`, `description`, `encryption`."
|
|
1405
|
+
}),
|
|
1406
|
+
at: z.string().register(z.globalRegistry, {
|
|
1407
|
+
description: "When it changed (ISO 8601 UTC)."
|
|
1408
|
+
}),
|
|
1409
|
+
old: z.optional(z.string().register(z.globalRegistry, {
|
|
1410
|
+
description: "The value before. `status`: the label (e.g. `IN_PROGRESS`); `priority`: the number; `scheduled`: the deadline column id (e.g. `w-48-2026`); `title`/`description`: the text. Omitted when there was none."
|
|
1411
|
+
})),
|
|
1412
|
+
new: z.optional(z.string().register(z.globalRegistry, {
|
|
1413
|
+
description: "The value after, same forms as `old`. For `parent_added`/`parent_removed` it is the parent task (short id). Omitted when cleared."
|
|
1414
|
+
})),
|
|
1415
|
+
reason: z.optional(z.string().register(z.globalRegistry, {
|
|
1416
|
+
description: "The note given for the change (e.g. why a deadline moved)."
|
|
1417
|
+
})),
|
|
1418
|
+
actor: z.optional(z.string().register(z.globalRegistry, {
|
|
1419
|
+
description: "Who made it when it was not the owner in the web app: `apikey:<key prefix>` or `oauth:<app name>`. Omitted for the owner."
|
|
1420
|
+
})),
|
|
1421
|
+
encrypted: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1422
|
+
description: "Only on a `title`/`description` edit saved end-to-end encrypted: its text is omitted."
|
|
1423
|
+
}))
|
|
1424
|
+
});
|
|
1149
1425
|
var zListTasksQuery = z.object({
|
|
1150
1426
|
includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
|
|
1151
1427
|
description: "Defaults to false. In tree mode, encrypted tasks are pruned UNLESS they lie on the path to an unencrypted task \u2014 so an encrypted parent of a readable task is kept (with `encrypted: true` and no title/description keys) to preserve structure, while fully-encrypted branches are hidden. In flat mode, encrypted tasks are simply omitted. Set to true to include ALL end-to-end-encrypted tasks for full visibility."
|
|
@@ -1278,6 +1554,108 @@ var zUnlinkTaskPullRequestPath = z.object({
|
|
|
1278
1554
|
var zUnlinkTaskPullRequestResponse = z.void().register(z.globalRegistry, {
|
|
1279
1555
|
description: "Unlinked"
|
|
1280
1556
|
});
|
|
1557
|
+
var zListKpiTasksResponse = z.array(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))).register(z.globalRegistry, {
|
|
1558
|
+
description: "Short ids of the tasks that have KPI entries."
|
|
1559
|
+
});
|
|
1560
|
+
var zListTaskKpisPath = z.object({
|
|
1561
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
|
|
1562
|
+
});
|
|
1563
|
+
var zListTaskKpisResponse = z.array(zKpiEntry).register(z.globalRegistry, {
|
|
1564
|
+
description: "KPI entries"
|
|
1565
|
+
});
|
|
1566
|
+
var zCreateTaskKpiBody = z.object({
|
|
1567
|
+
kind: z.enum(["target", "actual"]),
|
|
1568
|
+
value: z.number(),
|
|
1569
|
+
at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1570
|
+
description: "When the target is due, or when the actual was measured. Required for an actual; a target may have none."
|
|
1571
|
+
}))
|
|
1572
|
+
});
|
|
1573
|
+
var zCreateTaskKpiPath = z.object({
|
|
1574
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
|
|
1575
|
+
});
|
|
1576
|
+
var zCreateTaskKpiResponse = zKpiEntry;
|
|
1577
|
+
var zDeleteTaskKpiPath = z.object({
|
|
1578
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)),
|
|
1579
|
+
kpiId: z.uuid().register(z.globalRegistry, {
|
|
1580
|
+
description: "The entry id (`id` from the KPI list)."
|
|
1581
|
+
})
|
|
1582
|
+
});
|
|
1583
|
+
var zDeleteTaskKpiResponse = z.void().register(z.globalRegistry, {
|
|
1584
|
+
description: "Deleted"
|
|
1585
|
+
});
|
|
1586
|
+
var zUpdateTaskKpiBody = z.object({
|
|
1587
|
+
kind: z.optional(z.enum(["target", "actual"])),
|
|
1588
|
+
value: z.optional(z.number()),
|
|
1589
|
+
at: z.nullish(z.iso.datetime())
|
|
1590
|
+
});
|
|
1591
|
+
var zUpdateTaskKpiPath = z.object({
|
|
1592
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)),
|
|
1593
|
+
kpiId: z.uuid().register(z.globalRegistry, {
|
|
1594
|
+
description: "The entry id (`id` from the KPI list)."
|
|
1595
|
+
})
|
|
1596
|
+
});
|
|
1597
|
+
var zUpdateTaskKpiResponse = zKpiEntry;
|
|
1598
|
+
var zGetTimerStatusQuery = z.object({
|
|
1599
|
+
day_start: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1600
|
+
description: "Start of the user's day, so `worked_today` follows their time zone, e.g. `2026-11-23T00:00:00+02:00`. Defaults to midnight UTC."
|
|
1601
|
+
}))
|
|
1602
|
+
});
|
|
1603
|
+
var zGetTimerStatusResponse = zTimerStatus;
|
|
1604
|
+
var zListTimersQuery = z.object({
|
|
1605
|
+
task_id: z.optional(z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)).register(z.globalRegistry, {
|
|
1606
|
+
description: "Only this task\u2019s timers (full UUID or short id)."
|
|
1607
|
+
})),
|
|
1608
|
+
since: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1609
|
+
description: "Only timers started at or after this instant."
|
|
1610
|
+
})),
|
|
1611
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1612
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1613
|
+
}))
|
|
1614
|
+
});
|
|
1615
|
+
var zListTimersResponse = z.array(zTimer).register(z.globalRegistry, {
|
|
1616
|
+
description: "Timers"
|
|
1617
|
+
});
|
|
1618
|
+
var zStartTaskTimerPath = z.object({
|
|
1619
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
|
|
1620
|
+
});
|
|
1621
|
+
var zStartTaskTimerResponse = zStartTimerResponse;
|
|
1622
|
+
var zStopTimerResponse = zTimer;
|
|
1623
|
+
var zUpdateTimerBody = z.object({
|
|
1624
|
+
started_at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1625
|
+
description: "New start, ISO 8601 with `Z` or an offset."
|
|
1626
|
+
})),
|
|
1627
|
+
ended_at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1628
|
+
description: "New end, ISO 8601 with `Z` or an offset."
|
|
1629
|
+
}))
|
|
1630
|
+
});
|
|
1631
|
+
var zUpdateTimerPath = z.object({
|
|
1632
|
+
timerId: z.uuid().register(z.globalRegistry, {
|
|
1633
|
+
description: "The timer id (`id` from the timer list)."
|
|
1634
|
+
})
|
|
1635
|
+
});
|
|
1636
|
+
var zUpdateTimerResponse = zTimer;
|
|
1637
|
+
var zListTasksHistoryQuery = z.object({
|
|
1638
|
+
since: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1639
|
+
description: "Only changes at or after this instant."
|
|
1640
|
+
})),
|
|
1641
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1642
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1643
|
+
}))
|
|
1644
|
+
});
|
|
1645
|
+
var zListTasksHistoryResponse = z.array(zHistoryEntry).register(z.globalRegistry, {
|
|
1646
|
+
description: "History"
|
|
1647
|
+
});
|
|
1648
|
+
var zListTaskHistoryPath = z.object({
|
|
1649
|
+
id: z.string().check(z.regex(/^[0-9a-fA-F]{3,32}$|^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))
|
|
1650
|
+
});
|
|
1651
|
+
var zListTaskHistoryQuery = z.object({
|
|
1652
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1653
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1654
|
+
}))
|
|
1655
|
+
});
|
|
1656
|
+
var zListTaskHistoryResponse = z.array(zHistoryEntry).register(z.globalRegistry, {
|
|
1657
|
+
description: "History"
|
|
1658
|
+
});
|
|
1281
1659
|
|
|
1282
1660
|
// src/index.ts
|
|
1283
1661
|
var PerspecTask = class {
|
|
@@ -1286,6 +1664,8 @@ var PerspecTask = class {
|
|
|
1286
1664
|
* is scoped to. Encrypted tasks are returned with `encrypted: true` and no title/description keys.
|
|
1287
1665
|
*/
|
|
1288
1666
|
tasks;
|
|
1667
|
+
/** Time tracking: the running timer, the list of work sessions, start, stop and edit. */
|
|
1668
|
+
timers;
|
|
1289
1669
|
constructor(options) {
|
|
1290
1670
|
const { apiKey } = options;
|
|
1291
1671
|
const client2 = createClient(
|
|
@@ -1302,6 +1682,7 @@ var PerspecTask = class {
|
|
|
1302
1682
|
});
|
|
1303
1683
|
}
|
|
1304
1684
|
this.tasks = createTasksNamespace(client2);
|
|
1685
|
+
this.timers = createTimersNamespace(client2);
|
|
1305
1686
|
}
|
|
1306
1687
|
};
|
|
1307
1688
|
function createTasksNamespace(client2) {
|
|
@@ -1326,40 +1707,114 @@ function createTasksNamespace(client2) {
|
|
|
1326
1707
|
link: (id, url) => PullRequests.linkTaskPullRequest({ client: client2, path: { id }, body: { url } }),
|
|
1327
1708
|
/** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
|
|
1328
1709
|
unlink: (id, prId) => PullRequests.unlinkTaskPullRequest({ client: client2, path: { id, prId } })
|
|
1710
|
+
},
|
|
1711
|
+
/**
|
|
1712
|
+
* The read-only log of every change to your tasks (status, priority,
|
|
1713
|
+
* deadline, parents, title, description). Needs the `history:read` scope.
|
|
1714
|
+
*/
|
|
1715
|
+
history: {
|
|
1716
|
+
/** Every change across your plaintext tasks, newest first (`{ since, limit }`). Wraps `Tasks.listTasksHistory`. */
|
|
1717
|
+
list: (query) => Tasks.listTasksHistory({ client: client2, query }),
|
|
1718
|
+
/** Every change to one task, newest first (`{ limit }`). Wraps `Tasks.listTaskHistory`. */
|
|
1719
|
+
get: (id, query) => Tasks.listTaskHistory({ client: client2, path: { id }, query })
|
|
1720
|
+
},
|
|
1721
|
+
/**
|
|
1722
|
+
* A task's KPI: `target` entries (the number to reach, optionally by a
|
|
1723
|
+
* date) and `actual` entries (readings over time). Needs the `kpis:read` /
|
|
1724
|
+
* `kpis:write` scopes.
|
|
1725
|
+
*/
|
|
1726
|
+
kpis: {
|
|
1727
|
+
/** Short ids of the tasks that have KPI entries. Wraps `Kpis.listKpiTasks`. */
|
|
1728
|
+
listTasks: () => Kpis.listKpiTasks({ client: client2 }),
|
|
1729
|
+
/** The task's entries, oldest first. Wraps `Kpis.listTaskKpis`. */
|
|
1730
|
+
list: (id) => Kpis.listTaskKpis({ client: client2, path: { id } }),
|
|
1731
|
+
/** Add a target or an actual (`at` required for an actual). Wraps `Kpis.createTaskKpi`. */
|
|
1732
|
+
create: (id, body) => Kpis.createTaskKpi({ client: client2, path: { id }, body }),
|
|
1733
|
+
/** Change an entry's kind, value or at (`at: null` drops a target's date). Wraps `Kpis.updateTaskKpi`. */
|
|
1734
|
+
update: (id, kpiId, body) => Kpis.updateTaskKpi({ client: client2, path: { id, kpiId }, body }),
|
|
1735
|
+
/** Delete an entry by its `id` from `list`. Wraps `Kpis.deleteTaskKpi`. */
|
|
1736
|
+
delete: (id, kpiId) => Kpis.deleteTaskKpi({ client: client2, path: { id, kpiId } })
|
|
1329
1737
|
}
|
|
1330
1738
|
};
|
|
1331
1739
|
}
|
|
1740
|
+
function createTimersNamespace(client2) {
|
|
1741
|
+
return {
|
|
1742
|
+
/** The running timer and the seconds worked today (`{ day_start }` = the user's local midnight). Wraps `Timers.getTimerStatus`. */
|
|
1743
|
+
status: (query) => Timers.getTimerStatus({ client: client2, query }),
|
|
1744
|
+
/** Work sessions, newest first (`{ task_id, since, limit }`). Wraps `Timers.listTimers`. */
|
|
1745
|
+
list: (query) => Timers.listTimers({ client: client2, query }),
|
|
1746
|
+
/** Start a timer on a task; a timer running elsewhere is stopped first. Wraps `Timers.startTaskTimer`. */
|
|
1747
|
+
start: (taskId) => Timers.startTaskTimer({ client: client2, path: { id: taskId } }),
|
|
1748
|
+
/** Stop the running timer. Wraps `Timers.stopTimer`. */
|
|
1749
|
+
stop: () => Timers.stopTimer({ client: client2 }),
|
|
1750
|
+
/** Change a finished timer's `started_at` and/or `ended_at`. Wraps `Timers.updateTimer`. */
|
|
1751
|
+
update: (timerId, body) => Timers.updateTimer({ client: client2, path: { timerId }, body })
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1332
1754
|
var index_default = PerspecTask;
|
|
1333
1755
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1334
1756
|
0 && (module.exports = {
|
|
1335
1757
|
CLI_CLIENT_ID,
|
|
1336
1758
|
DEFAULT_BASE_URL,
|
|
1759
|
+
Kpis,
|
|
1337
1760
|
OAuthTokenError,
|
|
1338
1761
|
PerspecTask,
|
|
1339
1762
|
PullRequests,
|
|
1340
1763
|
Tasks,
|
|
1764
|
+
Timers,
|
|
1341
1765
|
refreshTokens,
|
|
1342
1766
|
revokeTokens,
|
|
1343
1767
|
startDeviceLogin,
|
|
1344
1768
|
waitForDeviceLogin,
|
|
1345
1769
|
zCreateTaskBody,
|
|
1770
|
+
zCreateTaskKpiBody,
|
|
1771
|
+
zCreateTaskKpiPath,
|
|
1772
|
+
zCreateTaskKpiResponse,
|
|
1346
1773
|
zCreateTaskResponse,
|
|
1774
|
+
zDeleteTaskKpiPath,
|
|
1775
|
+
zDeleteTaskKpiResponse,
|
|
1347
1776
|
zGetTaskPath,
|
|
1348
1777
|
zGetTaskQuery,
|
|
1349
1778
|
zGetTaskResponse,
|
|
1779
|
+
zGetTimerStatusQuery,
|
|
1780
|
+
zGetTimerStatusResponse,
|
|
1781
|
+
zHistoryEntry,
|
|
1782
|
+
zKpiEntry,
|
|
1350
1783
|
zLinkTaskPullRequestBody,
|
|
1351
1784
|
zLinkTaskPullRequestPath,
|
|
1352
1785
|
zLinkTaskPullRequestResponse,
|
|
1786
|
+
zListKpiTasksResponse,
|
|
1787
|
+
zListTaskHistoryPath,
|
|
1788
|
+
zListTaskHistoryQuery,
|
|
1789
|
+
zListTaskHistoryResponse,
|
|
1790
|
+
zListTaskKpisPath,
|
|
1791
|
+
zListTaskKpisResponse,
|
|
1353
1792
|
zListTaskPullRequestsPath,
|
|
1354
1793
|
zListTaskPullRequestsResponse,
|
|
1794
|
+
zListTasksHistoryQuery,
|
|
1795
|
+
zListTasksHistoryResponse,
|
|
1355
1796
|
zListTasksQuery,
|
|
1356
1797
|
zListTasksResponse,
|
|
1798
|
+
zListTimersQuery,
|
|
1799
|
+
zListTimersResponse,
|
|
1357
1800
|
zPullRequest,
|
|
1801
|
+
zStartTaskTimerPath,
|
|
1802
|
+
zStartTaskTimerResponse,
|
|
1803
|
+
zStartTimerResponse,
|
|
1804
|
+
zStopTimerResponse,
|
|
1358
1805
|
zTask,
|
|
1806
|
+
zTimer,
|
|
1807
|
+
zTimerStatus,
|
|
1359
1808
|
zUnlinkTaskPullRequestPath,
|
|
1360
1809
|
zUnlinkTaskPullRequestResponse,
|
|
1361
1810
|
zUpdateTaskBody,
|
|
1811
|
+
zUpdateTaskKpiBody,
|
|
1812
|
+
zUpdateTaskKpiPath,
|
|
1813
|
+
zUpdateTaskKpiResponse,
|
|
1362
1814
|
zUpdateTaskPath,
|
|
1363
|
-
zUpdateTaskResponse
|
|
1815
|
+
zUpdateTaskResponse,
|
|
1816
|
+
zUpdateTimerBody,
|
|
1817
|
+
zUpdateTimerPath,
|
|
1818
|
+
zUpdateTimerResponse
|
|
1364
1819
|
});
|
|
1365
1820
|
//# sourceMappingURL=index.cjs.map
|