@perspectask/sdk 1.1.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 +28 -0
- package/dist/index.cjs +288 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +589 -2
- package/dist/index.d.ts +589 -2
- package/dist/index.js +267 -1
- 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."
|
|
@@ -1417,6 +1595,67 @@ var zUpdateTaskKpiPath = z.object({
|
|
|
1417
1595
|
})
|
|
1418
1596
|
});
|
|
1419
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
|
+
});
|
|
1420
1659
|
|
|
1421
1660
|
// src/index.ts
|
|
1422
1661
|
var PerspecTask = class {
|
|
@@ -1425,6 +1664,8 @@ var PerspecTask = class {
|
|
|
1425
1664
|
* is scoped to. Encrypted tasks are returned with `encrypted: true` and no title/description keys.
|
|
1426
1665
|
*/
|
|
1427
1666
|
tasks;
|
|
1667
|
+
/** Time tracking: the running timer, the list of work sessions, start, stop and edit. */
|
|
1668
|
+
timers;
|
|
1428
1669
|
constructor(options) {
|
|
1429
1670
|
const { apiKey } = options;
|
|
1430
1671
|
const client2 = createClient(
|
|
@@ -1441,6 +1682,7 @@ var PerspecTask = class {
|
|
|
1441
1682
|
});
|
|
1442
1683
|
}
|
|
1443
1684
|
this.tasks = createTasksNamespace(client2);
|
|
1685
|
+
this.timers = createTimersNamespace(client2);
|
|
1444
1686
|
}
|
|
1445
1687
|
};
|
|
1446
1688
|
function createTasksNamespace(client2) {
|
|
@@ -1466,6 +1708,16 @@ function createTasksNamespace(client2) {
|
|
|
1466
1708
|
/** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
|
|
1467
1709
|
unlink: (id, prId) => PullRequests.unlinkTaskPullRequest({ client: client2, path: { id, prId } })
|
|
1468
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
|
+
},
|
|
1469
1721
|
/**
|
|
1470
1722
|
* A task's KPI: `target` entries (the number to reach, optionally by a
|
|
1471
1723
|
* date) and `actual` entries (readings over time). Needs the `kpis:read` /
|
|
@@ -1485,6 +1737,20 @@ function createTasksNamespace(client2) {
|
|
|
1485
1737
|
}
|
|
1486
1738
|
};
|
|
1487
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
|
+
}
|
|
1488
1754
|
var index_default = PerspecTask;
|
|
1489
1755
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1490
1756
|
0 && (module.exports = {
|
|
@@ -1495,6 +1761,7 @@ var index_default = PerspecTask;
|
|
|
1495
1761
|
PerspecTask,
|
|
1496
1762
|
PullRequests,
|
|
1497
1763
|
Tasks,
|
|
1764
|
+
Timers,
|
|
1498
1765
|
refreshTokens,
|
|
1499
1766
|
revokeTokens,
|
|
1500
1767
|
startDeviceLogin,
|
|
@@ -1509,19 +1776,35 @@ var index_default = PerspecTask;
|
|
|
1509
1776
|
zGetTaskPath,
|
|
1510
1777
|
zGetTaskQuery,
|
|
1511
1778
|
zGetTaskResponse,
|
|
1779
|
+
zGetTimerStatusQuery,
|
|
1780
|
+
zGetTimerStatusResponse,
|
|
1781
|
+
zHistoryEntry,
|
|
1512
1782
|
zKpiEntry,
|
|
1513
1783
|
zLinkTaskPullRequestBody,
|
|
1514
1784
|
zLinkTaskPullRequestPath,
|
|
1515
1785
|
zLinkTaskPullRequestResponse,
|
|
1516
1786
|
zListKpiTasksResponse,
|
|
1787
|
+
zListTaskHistoryPath,
|
|
1788
|
+
zListTaskHistoryQuery,
|
|
1789
|
+
zListTaskHistoryResponse,
|
|
1517
1790
|
zListTaskKpisPath,
|
|
1518
1791
|
zListTaskKpisResponse,
|
|
1519
1792
|
zListTaskPullRequestsPath,
|
|
1520
1793
|
zListTaskPullRequestsResponse,
|
|
1794
|
+
zListTasksHistoryQuery,
|
|
1795
|
+
zListTasksHistoryResponse,
|
|
1521
1796
|
zListTasksQuery,
|
|
1522
1797
|
zListTasksResponse,
|
|
1798
|
+
zListTimersQuery,
|
|
1799
|
+
zListTimersResponse,
|
|
1523
1800
|
zPullRequest,
|
|
1801
|
+
zStartTaskTimerPath,
|
|
1802
|
+
zStartTaskTimerResponse,
|
|
1803
|
+
zStartTimerResponse,
|
|
1804
|
+
zStopTimerResponse,
|
|
1524
1805
|
zTask,
|
|
1806
|
+
zTimer,
|
|
1807
|
+
zTimerStatus,
|
|
1525
1808
|
zUnlinkTaskPullRequestPath,
|
|
1526
1809
|
zUnlinkTaskPullRequestResponse,
|
|
1527
1810
|
zUpdateTaskBody,
|
|
@@ -1529,6 +1812,9 @@ var index_default = PerspecTask;
|
|
|
1529
1812
|
zUpdateTaskKpiPath,
|
|
1530
1813
|
zUpdateTaskKpiResponse,
|
|
1531
1814
|
zUpdateTaskPath,
|
|
1532
|
-
zUpdateTaskResponse
|
|
1815
|
+
zUpdateTaskResponse,
|
|
1816
|
+
zUpdateTimerBody,
|
|
1817
|
+
zUpdateTimerPath,
|
|
1818
|
+
zUpdateTimerResponse
|
|
1533
1819
|
});
|
|
1534
1820
|
//# sourceMappingURL=index.cjs.map
|