@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/dist/index.js
CHANGED
|
@@ -846,6 +846,30 @@ var Tasks = class {
|
|
|
846
846
|
}
|
|
847
847
|
});
|
|
848
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* List the history of all tasks
|
|
851
|
+
*
|
|
852
|
+
* 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.
|
|
853
|
+
*/
|
|
854
|
+
static listTasksHistory(options) {
|
|
855
|
+
return (options?.client ?? client).get({
|
|
856
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
857
|
+
url: "/tasks/history",
|
|
858
|
+
...options
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* List the history of a task
|
|
863
|
+
*
|
|
864
|
+
* 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`.
|
|
865
|
+
*/
|
|
866
|
+
static listTaskHistory(options) {
|
|
867
|
+
return (options.client ?? client).get({
|
|
868
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
869
|
+
url: "/tasks/{id}/history",
|
|
870
|
+
...options
|
|
871
|
+
});
|
|
872
|
+
}
|
|
849
873
|
};
|
|
850
874
|
var PullRequests = class {
|
|
851
875
|
/**
|
|
@@ -889,6 +913,140 @@ var PullRequests = class {
|
|
|
889
913
|
});
|
|
890
914
|
}
|
|
891
915
|
};
|
|
916
|
+
var Kpis = class {
|
|
917
|
+
/**
|
|
918
|
+
* List tasks with KPIs
|
|
919
|
+
*
|
|
920
|
+
* Short ids of your tasks that have KPI entries. Encrypted tasks are left out. Fetch a task with `GET /tasks/{id}` for its title.
|
|
921
|
+
*/
|
|
922
|
+
static listKpiTasks(options) {
|
|
923
|
+
return (options?.client ?? client).get({
|
|
924
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
925
|
+
url: "/kpis",
|
|
926
|
+
...options
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* List the KPI entries of a task
|
|
931
|
+
*
|
|
932
|
+
* 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`.
|
|
933
|
+
*/
|
|
934
|
+
static listTaskKpis(options) {
|
|
935
|
+
return (options.client ?? client).get({
|
|
936
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
937
|
+
url: "/tasks/{id}/kpis",
|
|
938
|
+
...options
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Add a KPI entry to a task
|
|
943
|
+
*
|
|
944
|
+
* 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`.
|
|
945
|
+
*/
|
|
946
|
+
static createTaskKpi(options) {
|
|
947
|
+
return (options.client ?? client).post({
|
|
948
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
949
|
+
url: "/tasks/{id}/kpis",
|
|
950
|
+
...options,
|
|
951
|
+
headers: {
|
|
952
|
+
"Content-Type": "application/json",
|
|
953
|
+
...options.headers
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Delete a KPI entry
|
|
959
|
+
*/
|
|
960
|
+
static deleteTaskKpi(options) {
|
|
961
|
+
return (options.client ?? client).delete({
|
|
962
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
963
|
+
url: "/tasks/{id}/kpis/{kpiId}",
|
|
964
|
+
...options
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Update a KPI entry
|
|
969
|
+
*
|
|
970
|
+
* Change any of `kind`, `value` and `at`. Only the fields you send change.
|
|
971
|
+
*/
|
|
972
|
+
static updateTaskKpi(options) {
|
|
973
|
+
return (options.client ?? client).patch({
|
|
974
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
975
|
+
url: "/tasks/{id}/kpis/{kpiId}",
|
|
976
|
+
...options,
|
|
977
|
+
headers: {
|
|
978
|
+
"Content-Type": "application/json",
|
|
979
|
+
...options.headers
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
var Timers = class {
|
|
985
|
+
/**
|
|
986
|
+
* Get the running timer and time worked today
|
|
987
|
+
*
|
|
988
|
+
* 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.
|
|
989
|
+
*/
|
|
990
|
+
static getTimerStatus(options) {
|
|
991
|
+
return (options?.client ?? client).get({
|
|
992
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
993
|
+
url: "/timers/status",
|
|
994
|
+
...options
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* List timers
|
|
999
|
+
*
|
|
1000
|
+
* 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).
|
|
1001
|
+
*/
|
|
1002
|
+
static listTimers(options) {
|
|
1003
|
+
return (options?.client ?? client).get({
|
|
1004
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1005
|
+
url: "/timers",
|
|
1006
|
+
...options
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Start a timer on a task
|
|
1011
|
+
*
|
|
1012
|
+
* 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).
|
|
1013
|
+
*/
|
|
1014
|
+
static startTaskTimer(options) {
|
|
1015
|
+
return (options.client ?? client).post({
|
|
1016
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1017
|
+
url: "/tasks/{id}/timers",
|
|
1018
|
+
...options
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Stop the running timer
|
|
1023
|
+
*
|
|
1024
|
+
* Stop whatever timer is running. A timer stopped under 5 seconds is deleted instead of kept (`discarded: true`).
|
|
1025
|
+
*/
|
|
1026
|
+
static stopTimer(options) {
|
|
1027
|
+
return (options?.client ?? client).post({
|
|
1028
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1029
|
+
url: "/timers/stop",
|
|
1030
|
+
...options
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Update a timer
|
|
1035
|
+
*
|
|
1036
|
+
* 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.
|
|
1037
|
+
*/
|
|
1038
|
+
static updateTimer(options) {
|
|
1039
|
+
return (options.client ?? client).patch({
|
|
1040
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1041
|
+
url: "/timers/{timerId}",
|
|
1042
|
+
...options,
|
|
1043
|
+
headers: {
|
|
1044
|
+
"Content-Type": "application/json",
|
|
1045
|
+
...options.headers
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
892
1050
|
|
|
893
1051
|
// src/generated/zod.gen.ts
|
|
894
1052
|
import * as z from "zod/mini";
|
|
@@ -981,6 +1139,91 @@ var zPullRequest = z.object({
|
|
|
981
1139
|
description: "`auto` = linked by the pt- code in the PR; `manual` = linked by URL."
|
|
982
1140
|
})
|
|
983
1141
|
});
|
|
1142
|
+
var zKpiEntry = z.object({
|
|
1143
|
+
id: z.uuid().register(z.globalRegistry, {
|
|
1144
|
+
description: "Id of this entry. Pass it to update or delete."
|
|
1145
|
+
}),
|
|
1146
|
+
kind: z.enum(["target", "actual"]).register(z.globalRegistry, {
|
|
1147
|
+
description: "`target` = the number you aim for (by `at`); `actual` = a reading of where it stands at `at`."
|
|
1148
|
+
}),
|
|
1149
|
+
at: z.optional(z.string().register(z.globalRegistry, {
|
|
1150
|
+
description: "ISO 8601 UTC instant. Omitted for a target with no date."
|
|
1151
|
+
})),
|
|
1152
|
+
value: z.optional(z.number().register(z.globalRegistry, {
|
|
1153
|
+
description: "The number. Omitted when the entry was saved end-to-end encrypted (then `encrypted` is true)."
|
|
1154
|
+
})),
|
|
1155
|
+
encrypted: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1156
|
+
description: "Only present when the value is end-to-end encrypted and so not readable over the API."
|
|
1157
|
+
}))
|
|
1158
|
+
});
|
|
1159
|
+
var zTimer = z.object({
|
|
1160
|
+
id: z.uuid().register(z.globalRegistry, {
|
|
1161
|
+
description: "Id of this timer. Pass it to update it."
|
|
1162
|
+
}),
|
|
1163
|
+
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, {
|
|
1164
|
+
description: "The task (short id). Its title comes from `GET /tasks/{id}`."
|
|
1165
|
+
}),
|
|
1166
|
+
started_at: z.string().register(z.globalRegistry, {
|
|
1167
|
+
description: "ISO 8601 UTC instant."
|
|
1168
|
+
}),
|
|
1169
|
+
ended_at: z.optional(z.string().register(z.globalRegistry, {
|
|
1170
|
+
description: "ISO 8601 UTC instant. Omitted while it runs."
|
|
1171
|
+
})),
|
|
1172
|
+
duration: z.optional(z.int().register(z.globalRegistry, {
|
|
1173
|
+
description: "Seconds between start and end. Omitted while it runs."
|
|
1174
|
+
})),
|
|
1175
|
+
running: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1176
|
+
description: "Only present on the running timer."
|
|
1177
|
+
})),
|
|
1178
|
+
discarded: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1179
|
+
description: "Only on a stop: the timer ran under 5 seconds, so it was deleted instead of kept."
|
|
1180
|
+
}))
|
|
1181
|
+
});
|
|
1182
|
+
var zTimerStatus = z.object({
|
|
1183
|
+
worked_today: z.int().register(z.globalRegistry, {
|
|
1184
|
+
description: "Seconds of finished timers since the start of the day (`day_start`, default midnight UTC)."
|
|
1185
|
+
}),
|
|
1186
|
+
running: z.optional(z.intersection(zTimer, z.unknown().register(z.globalRegistry, {
|
|
1187
|
+
description: "The running timer. Omitted when none runs."
|
|
1188
|
+
})))
|
|
1189
|
+
});
|
|
1190
|
+
var zStartTimerResponse = z.object({
|
|
1191
|
+
timer: z.intersection(zTimer, z.unknown().register(z.globalRegistry, {
|
|
1192
|
+
description: "The running timer on this task."
|
|
1193
|
+
})),
|
|
1194
|
+
stopped: z.optional(z.intersection(zTimer, z.unknown().register(z.globalRegistry, {
|
|
1195
|
+
description: "The timer this start stopped on another task (only one runs at a time)."
|
|
1196
|
+
}))),
|
|
1197
|
+
already_running: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1198
|
+
description: "Only present when this task\u2019s timer was already running; nothing changed."
|
|
1199
|
+
}))
|
|
1200
|
+
});
|
|
1201
|
+
var zHistoryEntry = z.object({
|
|
1202
|
+
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, {
|
|
1203
|
+
description: "The task (short id)."
|
|
1204
|
+
}),
|
|
1205
|
+
action: z.string().register(z.globalRegistry, {
|
|
1206
|
+
description: "What changed: `created`, `status`, `priority`, `scheduled`, `parent_added`, `parent_removed`, `title`, `description`, `encryption`."
|
|
1207
|
+
}),
|
|
1208
|
+
at: z.string().register(z.globalRegistry, {
|
|
1209
|
+
description: "When it changed (ISO 8601 UTC)."
|
|
1210
|
+
}),
|
|
1211
|
+
old: z.optional(z.string().register(z.globalRegistry, {
|
|
1212
|
+
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."
|
|
1213
|
+
})),
|
|
1214
|
+
new: z.optional(z.string().register(z.globalRegistry, {
|
|
1215
|
+
description: "The value after, same forms as `old`. For `parent_added`/`parent_removed` it is the parent task (short id). Omitted when cleared."
|
|
1216
|
+
})),
|
|
1217
|
+
reason: z.optional(z.string().register(z.globalRegistry, {
|
|
1218
|
+
description: "The note given for the change (e.g. why a deadline moved)."
|
|
1219
|
+
})),
|
|
1220
|
+
actor: z.optional(z.string().register(z.globalRegistry, {
|
|
1221
|
+
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."
|
|
1222
|
+
})),
|
|
1223
|
+
encrypted: z.optional(z.literal(true).register(z.globalRegistry, {
|
|
1224
|
+
description: "Only on a `title`/`description` edit saved end-to-end encrypted: its text is omitted."
|
|
1225
|
+
}))
|
|
1226
|
+
});
|
|
984
1227
|
var zListTasksQuery = z.object({
|
|
985
1228
|
includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
|
|
986
1229
|
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."
|
|
@@ -1113,6 +1356,108 @@ var zUnlinkTaskPullRequestPath = z.object({
|
|
|
1113
1356
|
var zUnlinkTaskPullRequestResponse = z.void().register(z.globalRegistry, {
|
|
1114
1357
|
description: "Unlinked"
|
|
1115
1358
|
});
|
|
1359
|
+
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, {
|
|
1360
|
+
description: "Short ids of the tasks that have KPI entries."
|
|
1361
|
+
});
|
|
1362
|
+
var zListTaskKpisPath = z.object({
|
|
1363
|
+
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}$/))
|
|
1364
|
+
});
|
|
1365
|
+
var zListTaskKpisResponse = z.array(zKpiEntry).register(z.globalRegistry, {
|
|
1366
|
+
description: "KPI entries"
|
|
1367
|
+
});
|
|
1368
|
+
var zCreateTaskKpiBody = z.object({
|
|
1369
|
+
kind: z.enum(["target", "actual"]),
|
|
1370
|
+
value: z.number(),
|
|
1371
|
+
at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1372
|
+
description: "When the target is due, or when the actual was measured. Required for an actual; a target may have none."
|
|
1373
|
+
}))
|
|
1374
|
+
});
|
|
1375
|
+
var zCreateTaskKpiPath = z.object({
|
|
1376
|
+
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}$/))
|
|
1377
|
+
});
|
|
1378
|
+
var zCreateTaskKpiResponse = zKpiEntry;
|
|
1379
|
+
var zDeleteTaskKpiPath = z.object({
|
|
1380
|
+
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}$/)),
|
|
1381
|
+
kpiId: z.uuid().register(z.globalRegistry, {
|
|
1382
|
+
description: "The entry id (`id` from the KPI list)."
|
|
1383
|
+
})
|
|
1384
|
+
});
|
|
1385
|
+
var zDeleteTaskKpiResponse = z.void().register(z.globalRegistry, {
|
|
1386
|
+
description: "Deleted"
|
|
1387
|
+
});
|
|
1388
|
+
var zUpdateTaskKpiBody = z.object({
|
|
1389
|
+
kind: z.optional(z.enum(["target", "actual"])),
|
|
1390
|
+
value: z.optional(z.number()),
|
|
1391
|
+
at: z.nullish(z.iso.datetime())
|
|
1392
|
+
});
|
|
1393
|
+
var zUpdateTaskKpiPath = z.object({
|
|
1394
|
+
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}$/)),
|
|
1395
|
+
kpiId: z.uuid().register(z.globalRegistry, {
|
|
1396
|
+
description: "The entry id (`id` from the KPI list)."
|
|
1397
|
+
})
|
|
1398
|
+
});
|
|
1399
|
+
var zUpdateTaskKpiResponse = zKpiEntry;
|
|
1400
|
+
var zGetTimerStatusQuery = z.object({
|
|
1401
|
+
day_start: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1402
|
+
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."
|
|
1403
|
+
}))
|
|
1404
|
+
});
|
|
1405
|
+
var zGetTimerStatusResponse = zTimerStatus;
|
|
1406
|
+
var zListTimersQuery = z.object({
|
|
1407
|
+
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, {
|
|
1408
|
+
description: "Only this task\u2019s timers (full UUID or short id)."
|
|
1409
|
+
})),
|
|
1410
|
+
since: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1411
|
+
description: "Only timers started at or after this instant."
|
|
1412
|
+
})),
|
|
1413
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1414
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1415
|
+
}))
|
|
1416
|
+
});
|
|
1417
|
+
var zListTimersResponse = z.array(zTimer).register(z.globalRegistry, {
|
|
1418
|
+
description: "Timers"
|
|
1419
|
+
});
|
|
1420
|
+
var zStartTaskTimerPath = z.object({
|
|
1421
|
+
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}$/))
|
|
1422
|
+
});
|
|
1423
|
+
var zStartTaskTimerResponse = zStartTimerResponse;
|
|
1424
|
+
var zStopTimerResponse = zTimer;
|
|
1425
|
+
var zUpdateTimerBody = z.object({
|
|
1426
|
+
started_at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1427
|
+
description: "New start, ISO 8601 with `Z` or an offset."
|
|
1428
|
+
})),
|
|
1429
|
+
ended_at: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1430
|
+
description: "New end, ISO 8601 with `Z` or an offset."
|
|
1431
|
+
}))
|
|
1432
|
+
});
|
|
1433
|
+
var zUpdateTimerPath = z.object({
|
|
1434
|
+
timerId: z.uuid().register(z.globalRegistry, {
|
|
1435
|
+
description: "The timer id (`id` from the timer list)."
|
|
1436
|
+
})
|
|
1437
|
+
});
|
|
1438
|
+
var zUpdateTimerResponse = zTimer;
|
|
1439
|
+
var zListTasksHistoryQuery = z.object({
|
|
1440
|
+
since: z.optional(z.iso.datetime().register(z.globalRegistry, {
|
|
1441
|
+
description: "Only changes at or after this instant."
|
|
1442
|
+
})),
|
|
1443
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1444
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1445
|
+
}))
|
|
1446
|
+
});
|
|
1447
|
+
var zListTasksHistoryResponse = z.array(zHistoryEntry).register(z.globalRegistry, {
|
|
1448
|
+
description: "History"
|
|
1449
|
+
});
|
|
1450
|
+
var zListTaskHistoryPath = z.object({
|
|
1451
|
+
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}$/))
|
|
1452
|
+
});
|
|
1453
|
+
var zListTaskHistoryQuery = z.object({
|
|
1454
|
+
limit: z.optional(z.int().check(z.gte(1), z.lte(1e3)).register(z.globalRegistry, {
|
|
1455
|
+
description: "Most entries to return, newest first. Defaults to 200, at most 1000."
|
|
1456
|
+
}))
|
|
1457
|
+
});
|
|
1458
|
+
var zListTaskHistoryResponse = z.array(zHistoryEntry).register(z.globalRegistry, {
|
|
1459
|
+
description: "History"
|
|
1460
|
+
});
|
|
1116
1461
|
|
|
1117
1462
|
// src/index.ts
|
|
1118
1463
|
var PerspecTask = class {
|
|
@@ -1121,6 +1466,8 @@ var PerspecTask = class {
|
|
|
1121
1466
|
* is scoped to. Encrypted tasks are returned with `encrypted: true` and no title/description keys.
|
|
1122
1467
|
*/
|
|
1123
1468
|
tasks;
|
|
1469
|
+
/** Time tracking: the running timer, the list of work sessions, start, stop and edit. */
|
|
1470
|
+
timers;
|
|
1124
1471
|
constructor(options) {
|
|
1125
1472
|
const { apiKey } = options;
|
|
1126
1473
|
const client2 = createClient(
|
|
@@ -1137,6 +1484,7 @@ var PerspecTask = class {
|
|
|
1137
1484
|
});
|
|
1138
1485
|
}
|
|
1139
1486
|
this.tasks = createTasksNamespace(client2);
|
|
1487
|
+
this.timers = createTimersNamespace(client2);
|
|
1140
1488
|
}
|
|
1141
1489
|
};
|
|
1142
1490
|
function createTasksNamespace(client2) {
|
|
@@ -1161,40 +1509,114 @@ function createTasksNamespace(client2) {
|
|
|
1161
1509
|
link: (id, url) => PullRequests.linkTaskPullRequest({ client: client2, path: { id }, body: { url } }),
|
|
1162
1510
|
/** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
|
|
1163
1511
|
unlink: (id, prId) => PullRequests.unlinkTaskPullRequest({ client: client2, path: { id, prId } })
|
|
1512
|
+
},
|
|
1513
|
+
/**
|
|
1514
|
+
* The read-only log of every change to your tasks (status, priority,
|
|
1515
|
+
* deadline, parents, title, description). Needs the `history:read` scope.
|
|
1516
|
+
*/
|
|
1517
|
+
history: {
|
|
1518
|
+
/** Every change across your plaintext tasks, newest first (`{ since, limit }`). Wraps `Tasks.listTasksHistory`. */
|
|
1519
|
+
list: (query) => Tasks.listTasksHistory({ client: client2, query }),
|
|
1520
|
+
/** Every change to one task, newest first (`{ limit }`). Wraps `Tasks.listTaskHistory`. */
|
|
1521
|
+
get: (id, query) => Tasks.listTaskHistory({ client: client2, path: { id }, query })
|
|
1522
|
+
},
|
|
1523
|
+
/**
|
|
1524
|
+
* A task's KPI: `target` entries (the number to reach, optionally by a
|
|
1525
|
+
* date) and `actual` entries (readings over time). Needs the `kpis:read` /
|
|
1526
|
+
* `kpis:write` scopes.
|
|
1527
|
+
*/
|
|
1528
|
+
kpis: {
|
|
1529
|
+
/** Short ids of the tasks that have KPI entries. Wraps `Kpis.listKpiTasks`. */
|
|
1530
|
+
listTasks: () => Kpis.listKpiTasks({ client: client2 }),
|
|
1531
|
+
/** The task's entries, oldest first. Wraps `Kpis.listTaskKpis`. */
|
|
1532
|
+
list: (id) => Kpis.listTaskKpis({ client: client2, path: { id } }),
|
|
1533
|
+
/** Add a target or an actual (`at` required for an actual). Wraps `Kpis.createTaskKpi`. */
|
|
1534
|
+
create: (id, body) => Kpis.createTaskKpi({ client: client2, path: { id }, body }),
|
|
1535
|
+
/** Change an entry's kind, value or at (`at: null` drops a target's date). Wraps `Kpis.updateTaskKpi`. */
|
|
1536
|
+
update: (id, kpiId, body) => Kpis.updateTaskKpi({ client: client2, path: { id, kpiId }, body }),
|
|
1537
|
+
/** Delete an entry by its `id` from `list`. Wraps `Kpis.deleteTaskKpi`. */
|
|
1538
|
+
delete: (id, kpiId) => Kpis.deleteTaskKpi({ client: client2, path: { id, kpiId } })
|
|
1164
1539
|
}
|
|
1165
1540
|
};
|
|
1166
1541
|
}
|
|
1542
|
+
function createTimersNamespace(client2) {
|
|
1543
|
+
return {
|
|
1544
|
+
/** The running timer and the seconds worked today (`{ day_start }` = the user's local midnight). Wraps `Timers.getTimerStatus`. */
|
|
1545
|
+
status: (query) => Timers.getTimerStatus({ client: client2, query }),
|
|
1546
|
+
/** Work sessions, newest first (`{ task_id, since, limit }`). Wraps `Timers.listTimers`. */
|
|
1547
|
+
list: (query) => Timers.listTimers({ client: client2, query }),
|
|
1548
|
+
/** Start a timer on a task; a timer running elsewhere is stopped first. Wraps `Timers.startTaskTimer`. */
|
|
1549
|
+
start: (taskId) => Timers.startTaskTimer({ client: client2, path: { id: taskId } }),
|
|
1550
|
+
/** Stop the running timer. Wraps `Timers.stopTimer`. */
|
|
1551
|
+
stop: () => Timers.stopTimer({ client: client2 }),
|
|
1552
|
+
/** Change a finished timer's `started_at` and/or `ended_at`. Wraps `Timers.updateTimer`. */
|
|
1553
|
+
update: (timerId, body) => Timers.updateTimer({ client: client2, path: { timerId }, body })
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1167
1556
|
var index_default = PerspecTask;
|
|
1168
1557
|
export {
|
|
1169
1558
|
CLI_CLIENT_ID,
|
|
1170
1559
|
DEFAULT_BASE_URL,
|
|
1560
|
+
Kpis,
|
|
1171
1561
|
OAuthTokenError,
|
|
1172
1562
|
PerspecTask,
|
|
1173
1563
|
PullRequests,
|
|
1174
1564
|
Tasks,
|
|
1565
|
+
Timers,
|
|
1175
1566
|
index_default as default,
|
|
1176
1567
|
refreshTokens,
|
|
1177
1568
|
revokeTokens,
|
|
1178
1569
|
startDeviceLogin,
|
|
1179
1570
|
waitForDeviceLogin,
|
|
1180
1571
|
zCreateTaskBody,
|
|
1572
|
+
zCreateTaskKpiBody,
|
|
1573
|
+
zCreateTaskKpiPath,
|
|
1574
|
+
zCreateTaskKpiResponse,
|
|
1181
1575
|
zCreateTaskResponse,
|
|
1576
|
+
zDeleteTaskKpiPath,
|
|
1577
|
+
zDeleteTaskKpiResponse,
|
|
1182
1578
|
zGetTaskPath,
|
|
1183
1579
|
zGetTaskQuery,
|
|
1184
1580
|
zGetTaskResponse,
|
|
1581
|
+
zGetTimerStatusQuery,
|
|
1582
|
+
zGetTimerStatusResponse,
|
|
1583
|
+
zHistoryEntry,
|
|
1584
|
+
zKpiEntry,
|
|
1185
1585
|
zLinkTaskPullRequestBody,
|
|
1186
1586
|
zLinkTaskPullRequestPath,
|
|
1187
1587
|
zLinkTaskPullRequestResponse,
|
|
1588
|
+
zListKpiTasksResponse,
|
|
1589
|
+
zListTaskHistoryPath,
|
|
1590
|
+
zListTaskHistoryQuery,
|
|
1591
|
+
zListTaskHistoryResponse,
|
|
1592
|
+
zListTaskKpisPath,
|
|
1593
|
+
zListTaskKpisResponse,
|
|
1188
1594
|
zListTaskPullRequestsPath,
|
|
1189
1595
|
zListTaskPullRequestsResponse,
|
|
1596
|
+
zListTasksHistoryQuery,
|
|
1597
|
+
zListTasksHistoryResponse,
|
|
1190
1598
|
zListTasksQuery,
|
|
1191
1599
|
zListTasksResponse,
|
|
1600
|
+
zListTimersQuery,
|
|
1601
|
+
zListTimersResponse,
|
|
1192
1602
|
zPullRequest,
|
|
1603
|
+
zStartTaskTimerPath,
|
|
1604
|
+
zStartTaskTimerResponse,
|
|
1605
|
+
zStartTimerResponse,
|
|
1606
|
+
zStopTimerResponse,
|
|
1193
1607
|
zTask,
|
|
1608
|
+
zTimer,
|
|
1609
|
+
zTimerStatus,
|
|
1194
1610
|
zUnlinkTaskPullRequestPath,
|
|
1195
1611
|
zUnlinkTaskPullRequestResponse,
|
|
1196
1612
|
zUpdateTaskBody,
|
|
1613
|
+
zUpdateTaskKpiBody,
|
|
1614
|
+
zUpdateTaskKpiPath,
|
|
1615
|
+
zUpdateTaskKpiResponse,
|
|
1197
1616
|
zUpdateTaskPath,
|
|
1198
|
-
zUpdateTaskResponse
|
|
1617
|
+
zUpdateTaskResponse,
|
|
1618
|
+
zUpdateTimerBody,
|
|
1619
|
+
zUpdateTimerPath,
|
|
1620
|
+
zUpdateTimerResponse
|
|
1199
1621
|
};
|
|
1200
1622
|
//# sourceMappingURL=index.js.map
|