@perspectask/sdk 1.1.0 → 1.3.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 +28 -0
- package/dist/index.cjs +294 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +592 -5
- package/dist/index.d.ts +592 -5
- package/dist/index.js +273 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -220,6 +220,31 @@ await pt.tasks.kpis.delete('abc', entries![0].id);
|
|
|
220
220
|
|
|
221
221
|
Encrypted tasks are refused (403). An entry saved encrypted in the web app comes back with `encrypted: true` and no `value`.
|
|
222
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
|
+
|
|
223
248
|
## Scopes
|
|
224
249
|
|
|
225
250
|
API keys carry scopes that control access:
|
|
@@ -231,6 +256,9 @@ API keys carry scopes that control access:
|
|
|
231
256
|
| `tasks:write:meta` | `create`, `update` everything **except** editing title/description of existing tasks, plus `pullRequests.link` / `unlink`. Built for AI agents. |
|
|
232
257
|
| `kpis:read` | `kpis.listTasks`, `kpis.list` |
|
|
233
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` |
|
|
234
262
|
|
|
235
263
|
A call missing the required scope returns `403`.
|
|
236
264
|
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
PerspecTask: () => PerspecTask,
|
|
38
38
|
PullRequests: () => PullRequests,
|
|
39
39
|
Tasks: () => Tasks,
|
|
40
|
+
Timers: () => Timers,
|
|
40
41
|
default: () => index_default,
|
|
41
42
|
refreshTokens: () => refreshTokens,
|
|
42
43
|
revokeTokens: () => revokeTokens,
|
|
@@ -52,19 +53,35 @@ __export(index_exports, {
|
|
|
52
53
|
zGetTaskPath: () => zGetTaskPath,
|
|
53
54
|
zGetTaskQuery: () => zGetTaskQuery,
|
|
54
55
|
zGetTaskResponse: () => zGetTaskResponse,
|
|
56
|
+
zGetTimerStatusQuery: () => zGetTimerStatusQuery,
|
|
57
|
+
zGetTimerStatusResponse: () => zGetTimerStatusResponse,
|
|
58
|
+
zHistoryEntry: () => zHistoryEntry,
|
|
55
59
|
zKpiEntry: () => zKpiEntry,
|
|
56
60
|
zLinkTaskPullRequestBody: () => zLinkTaskPullRequestBody,
|
|
57
61
|
zLinkTaskPullRequestPath: () => zLinkTaskPullRequestPath,
|
|
58
62
|
zLinkTaskPullRequestResponse: () => zLinkTaskPullRequestResponse,
|
|
59
63
|
zListKpiTasksResponse: () => zListKpiTasksResponse,
|
|
64
|
+
zListTaskHistoryPath: () => zListTaskHistoryPath,
|
|
65
|
+
zListTaskHistoryQuery: () => zListTaskHistoryQuery,
|
|
66
|
+
zListTaskHistoryResponse: () => zListTaskHistoryResponse,
|
|
60
67
|
zListTaskKpisPath: () => zListTaskKpisPath,
|
|
61
68
|
zListTaskKpisResponse: () => zListTaskKpisResponse,
|
|
62
69
|
zListTaskPullRequestsPath: () => zListTaskPullRequestsPath,
|
|
63
70
|
zListTaskPullRequestsResponse: () => zListTaskPullRequestsResponse,
|
|
71
|
+
zListTasksHistoryQuery: () => zListTasksHistoryQuery,
|
|
72
|
+
zListTasksHistoryResponse: () => zListTasksHistoryResponse,
|
|
64
73
|
zListTasksQuery: () => zListTasksQuery,
|
|
65
74
|
zListTasksResponse: () => zListTasksResponse,
|
|
75
|
+
zListTimersQuery: () => zListTimersQuery,
|
|
76
|
+
zListTimersResponse: () => zListTimersResponse,
|
|
66
77
|
zPullRequest: () => zPullRequest,
|
|
78
|
+
zStartTaskTimerPath: () => zStartTaskTimerPath,
|
|
79
|
+
zStartTaskTimerResponse: () => zStartTaskTimerResponse,
|
|
80
|
+
zStartTimerResponse: () => zStartTimerResponse,
|
|
81
|
+
zStopTimerResponse: () => zStopTimerResponse,
|
|
67
82
|
zTask: () => zTask,
|
|
83
|
+
zTimer: () => zTimer,
|
|
84
|
+
zTimerStatus: () => zTimerStatus,
|
|
68
85
|
zUnlinkTaskPullRequestPath: () => zUnlinkTaskPullRequestPath,
|
|
69
86
|
zUnlinkTaskPullRequestResponse: () => zUnlinkTaskPullRequestResponse,
|
|
70
87
|
zUpdateTaskBody: () => zUpdateTaskBody,
|
|
@@ -72,7 +89,10 @@ __export(index_exports, {
|
|
|
72
89
|
zUpdateTaskKpiPath: () => zUpdateTaskKpiPath,
|
|
73
90
|
zUpdateTaskKpiResponse: () => zUpdateTaskKpiResponse,
|
|
74
91
|
zUpdateTaskPath: () => zUpdateTaskPath,
|
|
75
|
-
zUpdateTaskResponse: () => zUpdateTaskResponse
|
|
92
|
+
zUpdateTaskResponse: () => zUpdateTaskResponse,
|
|
93
|
+
zUpdateTimerBody: () => zUpdateTimerBody,
|
|
94
|
+
zUpdateTimerPath: () => zUpdateTimerPath,
|
|
95
|
+
zUpdateTimerResponse: () => zUpdateTimerResponse
|
|
76
96
|
});
|
|
77
97
|
module.exports = __toCommonJS(index_exports);
|
|
78
98
|
|
|
@@ -914,6 +934,30 @@ var Tasks = class {
|
|
|
914
934
|
}
|
|
915
935
|
});
|
|
916
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
|
+
}
|
|
917
961
|
};
|
|
918
962
|
var PullRequests = class {
|
|
919
963
|
/**
|
|
@@ -1025,6 +1069,72 @@ var Kpis = class {
|
|
|
1025
1069
|
});
|
|
1026
1070
|
}
|
|
1027
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
|
+
};
|
|
1028
1138
|
|
|
1029
1139
|
// src/oauth.ts
|
|
1030
1140
|
var CLI_CLIENT_ID = "perspectask-cli";
|
|
@@ -1244,6 +1354,74 @@ var zKpiEntry = z.object({
|
|
|
1244
1354
|
description: "Only present when the value is end-to-end encrypted and so not readable over the API."
|
|
1245
1355
|
}))
|
|
1246
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
|
+
});
|
|
1247
1425
|
var zListTasksQuery = z.object({
|
|
1248
1426
|
includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
|
|
1249
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."
|
|
@@ -1311,9 +1489,7 @@ var zGetTaskResponse = zTask;
|
|
|
1311
1489
|
var zUpdateTaskBody = z.object({
|
|
1312
1490
|
title: z.optional(z.string()),
|
|
1313
1491
|
description: z.optional(z.string()),
|
|
1314
|
-
deadline: z.
|
|
1315
|
-
description: "When this task is due \u2014 same shorthand grammar as on create (today, lifetime, q-2-2026, q2, d-20-11, \u2026)."
|
|
1316
|
-
})),
|
|
1492
|
+
deadline: z.nullish(z.string()),
|
|
1317
1493
|
status: z.optional(z.enum([
|
|
1318
1494
|
"ACTIVE",
|
|
1319
1495
|
"COMPLETED",
|
|
@@ -1417,6 +1593,67 @@ var zUpdateTaskKpiPath = z.object({
|
|
|
1417
1593
|
})
|
|
1418
1594
|
});
|
|
1419
1595
|
var zUpdateTaskKpiResponse = zKpiEntry;
|
|
1596
|
+
var zGetTimerStatusQuery = z.object({
|
|
1597
|
+
day_start: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1598
|
+
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."
|
|
1599
|
+
}))
|
|
1600
|
+
});
|
|
1601
|
+
var zGetTimerStatusResponse = zTimerStatus;
|
|
1602
|
+
var zListTimersQuery = z.object({
|
|
1603
|
+
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, {
|
|
1604
|
+
description: "Only this task\u2019s timers (full UUID or short id)."
|
|
1605
|
+
})),
|
|
1606
|
+
since: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1607
|
+
description: "Only timers started at or after this instant."
|
|
1608
|
+
})),
|
|
1609
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1610
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1611
|
+
}))
|
|
1612
|
+
});
|
|
1613
|
+
var zListTimersResponse = z.array(zTimer).register(z.globalRegistry, {
|
|
1614
|
+
description: "Timers"
|
|
1615
|
+
});
|
|
1616
|
+
var zStartTaskTimerPath = z.object({
|
|
1617
|
+
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}$/))
|
|
1618
|
+
});
|
|
1619
|
+
var zStartTaskTimerResponse = zStartTimerResponse;
|
|
1620
|
+
var zStopTimerResponse = zTimer;
|
|
1621
|
+
var zUpdateTimerBody = z.object({
|
|
1622
|
+
started_at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1623
|
+
description: "New start, ISO 8601 with `Z` or an offset."
|
|
1624
|
+
})),
|
|
1625
|
+
ended_at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1626
|
+
description: "New end, ISO 8601 with `Z` or an offset."
|
|
1627
|
+
}))
|
|
1628
|
+
});
|
|
1629
|
+
var zUpdateTimerPath = z.object({
|
|
1630
|
+
timerId: z.uuid().register(z.globalRegistry, {
|
|
1631
|
+
description: "The timer id (`id` from the timer list)."
|
|
1632
|
+
})
|
|
1633
|
+
});
|
|
1634
|
+
var zUpdateTimerResponse = zTimer;
|
|
1635
|
+
var zListTasksHistoryQuery = z.object({
|
|
1636
|
+
since: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1637
|
+
description: "Only changes at or after this instant."
|
|
1638
|
+
})),
|
|
1639
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1640
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1641
|
+
}))
|
|
1642
|
+
});
|
|
1643
|
+
var zListTasksHistoryResponse = z.array(zHistoryEntry).register(z.globalRegistry, {
|
|
1644
|
+
description: "History"
|
|
1645
|
+
});
|
|
1646
|
+
var zListTaskHistoryPath = z.object({
|
|
1647
|
+
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}$/))
|
|
1648
|
+
});
|
|
1649
|
+
var zListTaskHistoryQuery = z.object({
|
|
1650
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1651
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1652
|
+
}))
|
|
1653
|
+
});
|
|
1654
|
+
var zListTaskHistoryResponse = z.array(zHistoryEntry).register(z.globalRegistry, {
|
|
1655
|
+
description: "History"
|
|
1656
|
+
});
|
|
1420
1657
|
|
|
1421
1658
|
// src/index.ts
|
|
1422
1659
|
var PerspecTask = class {
|
|
@@ -1425,6 +1662,8 @@ var PerspecTask = class {
|
|
|
1425
1662
|
* is scoped to. Encrypted tasks are returned with `encrypted: true` and no title/description keys.
|
|
1426
1663
|
*/
|
|
1427
1664
|
tasks;
|
|
1665
|
+
/** Time tracking: the running timer, the list of work sessions, start, stop and edit. */
|
|
1666
|
+
timers;
|
|
1428
1667
|
constructor(options) {
|
|
1429
1668
|
const { apiKey } = options;
|
|
1430
1669
|
const client2 = createClient(
|
|
@@ -1441,6 +1680,7 @@ var PerspecTask = class {
|
|
|
1441
1680
|
});
|
|
1442
1681
|
}
|
|
1443
1682
|
this.tasks = createTasksNamespace(client2);
|
|
1683
|
+
this.timers = createTimersNamespace(client2);
|
|
1444
1684
|
}
|
|
1445
1685
|
};
|
|
1446
1686
|
function createTasksNamespace(client2) {
|
|
@@ -1462,10 +1702,24 @@ function createTasksNamespace(client2) {
|
|
|
1462
1702
|
/** List the task's linked PRs (state, checks, review, preview). Wraps `PullRequests.listTaskPullRequests`. */
|
|
1463
1703
|
list: (id) => PullRequests.listTaskPullRequests({ client: client2, path: { id } }),
|
|
1464
1704
|
/** Link a PR by URL (`https://github.com/o/r/pull/12` or `o/r#12`). Wraps `PullRequests.linkTaskPullRequest`. */
|
|
1465
|
-
link: (id, url) => PullRequests.linkTaskPullRequest({
|
|
1705
|
+
link: (id, url) => PullRequests.linkTaskPullRequest({
|
|
1706
|
+
client: client2,
|
|
1707
|
+
path: { id },
|
|
1708
|
+
body: { url }
|
|
1709
|
+
}),
|
|
1466
1710
|
/** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
|
|
1467
1711
|
unlink: (id, prId) => PullRequests.unlinkTaskPullRequest({ client: client2, path: { id, prId } })
|
|
1468
1712
|
},
|
|
1713
|
+
/**
|
|
1714
|
+
* The read-only log of every change to your tasks (status, priority,
|
|
1715
|
+
* deadline, parents, title, description). Needs the `history:read` scope.
|
|
1716
|
+
*/
|
|
1717
|
+
history: {
|
|
1718
|
+
/** Every change across your plaintext tasks, newest first (`{ since, limit }`). Wraps `Tasks.listTasksHistory`. */
|
|
1719
|
+
list: (query) => Tasks.listTasksHistory({ client: client2, query }),
|
|
1720
|
+
/** Every change to one task, newest first (`{ limit }`). Wraps `Tasks.listTaskHistory`. */
|
|
1721
|
+
get: (id, query) => Tasks.listTaskHistory({ client: client2, path: { id }, query })
|
|
1722
|
+
},
|
|
1469
1723
|
/**
|
|
1470
1724
|
* A task's KPI: `target` entries (the number to reach, optionally by a
|
|
1471
1725
|
* date) and `actual` entries (readings over time). Needs the `kpis:read` /
|
|
@@ -1485,6 +1739,20 @@ function createTasksNamespace(client2) {
|
|
|
1485
1739
|
}
|
|
1486
1740
|
};
|
|
1487
1741
|
}
|
|
1742
|
+
function createTimersNamespace(client2) {
|
|
1743
|
+
return {
|
|
1744
|
+
/** The running timer and the seconds worked today (`{ day_start }` = the user's local midnight). Wraps `Timers.getTimerStatus`. */
|
|
1745
|
+
status: (query) => Timers.getTimerStatus({ client: client2, query }),
|
|
1746
|
+
/** Work sessions, newest first (`{ task_id, since, limit }`). Wraps `Timers.listTimers`. */
|
|
1747
|
+
list: (query) => Timers.listTimers({ client: client2, query }),
|
|
1748
|
+
/** Start a timer on a task; a timer running elsewhere is stopped first. Wraps `Timers.startTaskTimer`. */
|
|
1749
|
+
start: (taskId) => Timers.startTaskTimer({ client: client2, path: { id: taskId } }),
|
|
1750
|
+
/** Stop the running timer. Wraps `Timers.stopTimer`. */
|
|
1751
|
+
stop: () => Timers.stopTimer({ client: client2 }),
|
|
1752
|
+
/** Change a finished timer's `started_at` and/or `ended_at`. Wraps `Timers.updateTimer`. */
|
|
1753
|
+
update: (timerId, body) => Timers.updateTimer({ client: client2, path: { timerId }, body })
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1488
1756
|
var index_default = PerspecTask;
|
|
1489
1757
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1490
1758
|
0 && (module.exports = {
|
|
@@ -1495,6 +1763,7 @@ var index_default = PerspecTask;
|
|
|
1495
1763
|
PerspecTask,
|
|
1496
1764
|
PullRequests,
|
|
1497
1765
|
Tasks,
|
|
1766
|
+
Timers,
|
|
1498
1767
|
refreshTokens,
|
|
1499
1768
|
revokeTokens,
|
|
1500
1769
|
startDeviceLogin,
|
|
@@ -1509,19 +1778,35 @@ var index_default = PerspecTask;
|
|
|
1509
1778
|
zGetTaskPath,
|
|
1510
1779
|
zGetTaskQuery,
|
|
1511
1780
|
zGetTaskResponse,
|
|
1781
|
+
zGetTimerStatusQuery,
|
|
1782
|
+
zGetTimerStatusResponse,
|
|
1783
|
+
zHistoryEntry,
|
|
1512
1784
|
zKpiEntry,
|
|
1513
1785
|
zLinkTaskPullRequestBody,
|
|
1514
1786
|
zLinkTaskPullRequestPath,
|
|
1515
1787
|
zLinkTaskPullRequestResponse,
|
|
1516
1788
|
zListKpiTasksResponse,
|
|
1789
|
+
zListTaskHistoryPath,
|
|
1790
|
+
zListTaskHistoryQuery,
|
|
1791
|
+
zListTaskHistoryResponse,
|
|
1517
1792
|
zListTaskKpisPath,
|
|
1518
1793
|
zListTaskKpisResponse,
|
|
1519
1794
|
zListTaskPullRequestsPath,
|
|
1520
1795
|
zListTaskPullRequestsResponse,
|
|
1796
|
+
zListTasksHistoryQuery,
|
|
1797
|
+
zListTasksHistoryResponse,
|
|
1521
1798
|
zListTasksQuery,
|
|
1522
1799
|
zListTasksResponse,
|
|
1800
|
+
zListTimersQuery,
|
|
1801
|
+
zListTimersResponse,
|
|
1523
1802
|
zPullRequest,
|
|
1803
|
+
zStartTaskTimerPath,
|
|
1804
|
+
zStartTaskTimerResponse,
|
|
1805
|
+
zStartTimerResponse,
|
|
1806
|
+
zStopTimerResponse,
|
|
1524
1807
|
zTask,
|
|
1808
|
+
zTimer,
|
|
1809
|
+
zTimerStatus,
|
|
1525
1810
|
zUnlinkTaskPullRequestPath,
|
|
1526
1811
|
zUnlinkTaskPullRequestResponse,
|
|
1527
1812
|
zUpdateTaskBody,
|
|
@@ -1529,6 +1814,9 @@ var index_default = PerspecTask;
|
|
|
1529
1814
|
zUpdateTaskKpiPath,
|
|
1530
1815
|
zUpdateTaskKpiResponse,
|
|
1531
1816
|
zUpdateTaskPath,
|
|
1532
|
-
zUpdateTaskResponse
|
|
1817
|
+
zUpdateTaskResponse,
|
|
1818
|
+
zUpdateTimerBody,
|
|
1819
|
+
zUpdateTimerPath,
|
|
1820
|
+
zUpdateTimerResponse
|
|
1533
1821
|
});
|
|
1534
1822
|
//# sourceMappingURL=index.cjs.map
|