@perspectask/sdk 0.0.4 → 0.0.6

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/dist/index.js CHANGED
@@ -837,6 +837,265 @@ var Tasks = class {
837
837
  });
838
838
  }
839
839
  };
840
+ var PullRequests = class {
841
+ /**
842
+ * List pull requests linked to a task
843
+ *
844
+ * The GitHub pull requests linked to this task, with their state, CI result, review decision and preview deploy, kept up to date by GitHub webhooks. Needs the PerspecTask GitHub app installed on the repository (Account → GitHub in the web app).
845
+ */
846
+ static listTaskPullRequests(options) {
847
+ return (options.client ?? client).get({
848
+ security: [{ scheme: "bearer", type: "http" }],
849
+ url: "/tasks/{id}/pull-requests",
850
+ ...options
851
+ });
852
+ }
853
+ /**
854
+ * Link a pull request to a task
855
+ *
856
+ * Link a PR by its URL. Usually unnecessary: a PR whose title, branch or description contains the task's `pr_token` links itself. Linking an already-linked PR refreshes it. Needs the PerspecTask GitHub app installed on the repository (Account → GitHub in the web app). Answers 404 with `code: "not_installed"` when the app isn't on that repository or your GitHub account can't read it.
857
+ */
858
+ static linkTaskPullRequest(options) {
859
+ return (options.client ?? client).post({
860
+ security: [{ scheme: "bearer", type: "http" }],
861
+ url: "/tasks/{id}/pull-requests",
862
+ ...options,
863
+ headers: {
864
+ "Content-Type": "application/json",
865
+ ...options.headers
866
+ }
867
+ });
868
+ }
869
+ /**
870
+ * Unlink a pull request from a task
871
+ *
872
+ * Remove a link (`prId` is the `id` from the list). It stays unlinked: later pushes to the PR do not link it again, only linking it by URL does.
873
+ */
874
+ static unlinkTaskPullRequest(options) {
875
+ return (options.client ?? client).delete({
876
+ security: [{ scheme: "bearer", type: "http" }],
877
+ url: "/tasks/{id}/pull-requests/{prId}",
878
+ ...options
879
+ });
880
+ }
881
+ };
882
+
883
+ // src/generated/zod.gen.ts
884
+ import * as z from "zod/mini";
885
+ var zTask = z.object({
886
+ 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, {
887
+ description: 'Short id: the minimum unique prefix of the task UUID (e.g. "a3f"). Accepted anywhere an id is.'
888
+ })),
889
+ pr_token: z.optional(z.string().check(z.regex(/^pt-[0-9a-f]{7,32}$/)).register(z.globalRegistry, {
890
+ description: 'Put this code (e.g. "pt-a3f91c2") in a GitHub pull request title or branch name and the PR links itself to this task (needs the PerspecTask GitHub app on the repo). It is longer than the short id on purpose, so it stays unambiguous as more tasks are added. Returned on single-task responses (get, create, update), not on lists.'
891
+ })),
892
+ title: z.optional(z.string()),
893
+ description: z.optional(z.string()),
894
+ encrypted: z.optional(z.boolean().register(z.globalRegistry, {
895
+ description: "True for end-to-end-encrypted tasks. Their title and description are omitted over this API (the keys are absent, not empty) \u2014 decrypt them in the web app."
896
+ })),
897
+ deadline: z.optional(z.string().register(z.globalRegistry, {
898
+ description: `The task's column id \u2014 d-20-11-2026, w-23-2026, m-6-2026, q-2-2026, y-2026, or "l" (lifetime). This is the same canonical form accepted as input on create/update.`
899
+ })),
900
+ deadline_date: z.optional(z.iso.datetime().register(z.globalRegistry, {
901
+ description: "The actual end-of-period timestamp (e.g. Sunday 23:59:59 for a weekly task). Omitted for lifetime tasks and tasks without a schedule."
902
+ })),
903
+ status: z.optional(z.enum([
904
+ "ACTIVE",
905
+ "COMPLETED",
906
+ "CANCELLED",
907
+ "READY",
908
+ "IN_PROGRESS",
909
+ "WAITING",
910
+ "DELEGATED"
911
+ ])),
912
+ completion: z.optional(z.string().register(z.globalRegistry, {
913
+ description: 'Percentage complete (e.g. "52%"), computed recursively over the ENTIRE subtree \u2014 children, their children, and so on to the leaves \u2014 not just direct children. PerspecTask maintains this automatically so the user sees true progress at a glance. It can read 100% when every descendant is completed even if this task itself is not yet checked. Conversely, if this task is itself marked completed, its completion is forced to 100% regardless of any unfinished descendants (the task-level status overrides the rollup). Only present when the task has children.'
914
+ })),
915
+ worked_time: z.optional(z.number().register(z.globalRegistry, {
916
+ description: "Total time tracked on this task, in seconds, summed across all its timers. Only present when greater than 0."
917
+ })),
918
+ priority: z.nullish(z.union([
919
+ z.literal(1),
920
+ z.literal(2),
921
+ z.literal(3)
922
+ ])),
923
+ created: z.optional(z.string().register(z.globalRegistry, {
924
+ description: 'When the task was created. Omitted by default. Present only when requested: `?showCreated=true` returns a relative time (e.g. "5 minutes ago"), `?showCreatedDate=true` returns an absolute ISO 8601 timestamp.'
925
+ })),
926
+ blocked_by: z.optional(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, {
927
+ description: "Tasks that should be done before this one (short ids), set with `block` / `removeBlock` on update. Just a flag, nothing is enforced. Only present when the task is blocked."
928
+ })),
929
+ children: z.optional(z.array(z.union([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}$/)), z.lazy(() => zTask)]))),
930
+ parents: z.optional(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}$/))))
931
+ });
932
+ var zPullRequest = z.object({
933
+ id: z.uuid().register(z.globalRegistry, {
934
+ description: "Id of this task\u2194PR link. Pass it to unlink."
935
+ }),
936
+ repo: z.string(),
937
+ number: z.int(),
938
+ title: z.string(),
939
+ url: z.string().register(z.globalRegistry, {
940
+ description: "The PR on github.com."
941
+ }),
942
+ state: z.enum([
943
+ "open",
944
+ "closed",
945
+ "merged"
946
+ ]),
947
+ draft: z.optional(z.literal(true).register(z.globalRegistry, {
948
+ description: "Only present when the PR is a draft."
949
+ })),
950
+ checks: z.optional(z.enum([
951
+ "pending",
952
+ "success",
953
+ "failure"
954
+ ]).register(z.globalRegistry, {
955
+ description: "Combined CI result of the PR's head commit (check runs + commit statuses). Omitted when the commit has no CI."
956
+ })),
957
+ review: z.optional(z.enum(["approved", "changes_requested"]).register(z.globalRegistry, {
958
+ description: "Reviewers' current decision. Omitted when nobody approved or requested changes."
959
+ })),
960
+ preview_url: z.optional(z.string().register(z.globalRegistry, {
961
+ description: "Latest successful preview deployment (Vercel, Netlify, \u2026). Omitted when there is none."
962
+ })),
963
+ linked_by: z.enum(["auto", "manual"]).register(z.globalRegistry, {
964
+ description: "`auto` = linked by the pt- code in the PR; `manual` = linked by URL."
965
+ })
966
+ });
967
+ var zListTasksQuery = z.object({
968
+ includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
969
+ 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."
970
+ })),
971
+ tree: z.optional(z.boolean().register(z.globalRegistry, {
972
+ description: "Defaults to false. When true, each task's `children` are returned as full nested task objects (recursively) instead of id strings. A task that was already expanded elsewhere in the tree will not be expanded again \u2014 only its short id string will appear in the `children` array of subsequent parent tasks, preserving the relationship without repeating the full object."
973
+ })),
974
+ treeFull: z.optional(z.boolean().register(z.globalRegistry, {
975
+ description: "Like `tree` but without deduplication: a task with multiple parents appears under each parent. Mutually exclusive with `tree`."
976
+ })),
977
+ showCreated: z.optional(z.boolean().register(z.globalRegistry, {
978
+ description: 'Defaults to false. Set to true to include `created` as a human-friendly relative time (e.g. "5 minutes ago"). Ignored when `showCreatedDate` is true.'
979
+ })),
980
+ showCreatedDate: z.optional(z.boolean().register(z.globalRegistry, {
981
+ description: "Defaults to false. Set to true to include `created` as an absolute ISO 8601 timestamp. Takes precedence over `showCreated` when both are set."
982
+ })),
983
+ showCompleted: z.optional(z.boolean().register(z.globalRegistry, {
984
+ description: "Defaults to false. By default the list omits done tasks (status COMPLETED and CANCELLED) so an agent sees only open work and to save context. Set to true to include all completed and cancelled tasks. Exception in tree mode: a completed task is kept if any of its descendants is still open \u2014 this preserves the path/context to that open task even when showCompleted is false."
985
+ }))
986
+ });
987
+ var zListTasksResponse = z.array(zTask).register(z.globalRegistry, {
988
+ description: "List of tasks"
989
+ });
990
+ var zCreateTaskBody = z.object({
991
+ title: z.string().check(z.minLength(1)),
992
+ description: z.optional(z.string()),
993
+ priority: z.optional(z.union([
994
+ z.literal(0),
995
+ z.literal(1),
996
+ z.literal(2),
997
+ z.literal(3)
998
+ ])),
999
+ deadline: z.optional(z.string().register(z.globalRegistry, {
1000
+ description: "When this task is due. A single shorthand token that sets both the period type and the date. Accepts: today, tomorrow, this/next week|month|quarter|year, lifetime, the bare letters d/w/m/q/y/l (= today, this week, this month, this quarter, this year, lifetime), or a column id (d-20-11-2026, w-23-2026, m-6-2026, q-2-2026, y-2026; trailing parts may be omitted to default to current month/year; the first number may be glued: q2, w23, d20)."
1001
+ })),
1002
+ parent_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, {
1003
+ description: "Parent task id \u2014 full UUID or a short id prefix."
1004
+ }))
1005
+ });
1006
+ var zCreateTaskResponse = zTask;
1007
+ var zGetTaskPath = z.object({
1008
+ 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}$/))
1009
+ });
1010
+ var zGetTaskQuery = z.object({
1011
+ includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
1012
+ description: "Defaults to false. In tree mode, encrypted descendants are pruned unless they lie on the path to an unencrypted task (so you see the structure leading to a task you can read). Set to true to keep ALL encrypted tasks in the subtree (returned with `encrypted: true` and no title/description keys). The requested task itself is always returned regardless."
1013
+ })),
1014
+ tree: z.optional(z.boolean().register(z.globalRegistry, {
1015
+ description: "Defaults to false. When true, this task's `children` are returned as full nested task objects (recursively) instead of id strings. A task that was already expanded elsewhere in the subtree will not be expanded again \u2014 only its short id string will appear in subsequent parents' `children`, preserving the relationship without repeating the full object."
1016
+ })),
1017
+ treeFull: z.optional(z.boolean().register(z.globalRegistry, {
1018
+ description: "Like `tree` but without deduplication: a task with multiple parents appears under each parent. Mutually exclusive with `tree`."
1019
+ })),
1020
+ showCreated: z.optional(z.boolean().register(z.globalRegistry, {
1021
+ description: 'Defaults to false. Set to true to include `created` as a human-friendly relative time (e.g. "5 minutes ago"). Ignored when `showCreatedDate` is true.'
1022
+ })),
1023
+ showCreatedDate: z.optional(z.boolean().register(z.globalRegistry, {
1024
+ description: "Defaults to false. Set to true to include `created` as an absolute ISO 8601 timestamp. Takes precedence over `showCreated` when both are set."
1025
+ })),
1026
+ showCompleted: z.optional(z.boolean().register(z.globalRegistry, {
1027
+ description: "Defaults to false. By default completed and cancelled subtasks are pruned from the tree. Exception: a completed task is kept if any of its descendants is still open (to preserve context/path). Set to true to include all completed and cancelled tasks regardless."
1028
+ }))
1029
+ });
1030
+ var zGetTaskResponse = zTask;
1031
+ var zUpdateTaskBody = z.object({
1032
+ title: z.optional(z.string()),
1033
+ description: z.optional(z.string()),
1034
+ deadline: z.optional(z.string().register(z.globalRegistry, {
1035
+ description: "When this task is due \u2014 same shorthand grammar as on create (today, lifetime, q-2-2026, q2, d-20-11, \u2026)."
1036
+ })),
1037
+ status: z.optional(z.enum([
1038
+ "ACTIVE",
1039
+ "COMPLETED",
1040
+ "CANCELLED",
1041
+ "READY",
1042
+ "IN_PROGRESS",
1043
+ "WAITING",
1044
+ "DELEGATED"
1045
+ ])),
1046
+ priority: z.optional(z.union([
1047
+ z.literal(0),
1048
+ z.literal(1),
1049
+ z.literal(2),
1050
+ z.literal(3)
1051
+ ])),
1052
+ add_parent: 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, {
1053
+ description: "Attach this task as a child of the given parent (full UUID or short id prefix)."
1054
+ })),
1055
+ remove_parent: 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, {
1056
+ description: "Detach this task from the given parent (full UUID or short id prefix)."
1057
+ })),
1058
+ replace_parent: 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, {
1059
+ description: "Replace the task's existing parent with this new one (full UUID or short id prefix). If the task has exactly one parent, that one is replaced. If it has multiple, you must also pass `replace_parent_from` to say which to replace."
1060
+ })),
1061
+ replace_parent_from: 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, {
1062
+ description: "When replacing among multiple parents, the existing parent to replace (full UUID or short id prefix; used with `replace_parent`)."
1063
+ })),
1064
+ block: 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, {
1065
+ description: "Mark the given task as blocking this one \u2014 it should be done first (full UUID or short id prefix). Just a flag; nothing is enforced."
1066
+ })),
1067
+ removeBlock: 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, {
1068
+ description: 'Remove the given task from this task\u2019s "blocked by" list (full UUID or short id prefix).'
1069
+ }))
1070
+ });
1071
+ var zUpdateTaskPath = z.object({
1072
+ 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}$/))
1073
+ });
1074
+ var zUpdateTaskResponse = zTask;
1075
+ var zListTaskPullRequestsPath = z.object({
1076
+ 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}$/))
1077
+ });
1078
+ var zListTaskPullRequestsResponse = z.array(zPullRequest).register(z.globalRegistry, {
1079
+ description: "Linked pull requests (oldest first)"
1080
+ });
1081
+ var zLinkTaskPullRequestBody = z.object({
1082
+ url: z.string().check(z.minLength(1)).register(z.globalRegistry, {
1083
+ description: "The pull request: `https://github.com/owner/repo/pull/123` or `owner/repo#123`."
1084
+ })
1085
+ });
1086
+ var zLinkTaskPullRequestPath = z.object({
1087
+ 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}$/))
1088
+ });
1089
+ var zLinkTaskPullRequestResponse = zPullRequest;
1090
+ var zUnlinkTaskPullRequestPath = z.object({
1091
+ 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}$/)),
1092
+ prId: z.uuid().register(z.globalRegistry, {
1093
+ description: "The link id (`id` from the pull request list)."
1094
+ })
1095
+ });
1096
+ var zUnlinkTaskPullRequestResponse = z.void().register(z.globalRegistry, {
1097
+ description: "Unlinked"
1098
+ });
840
1099
 
841
1100
  // src/index.ts
842
1101
  var PerspecTask = class {
@@ -866,13 +1125,46 @@ function createTasksNamespace(client2) {
866
1125
  /** Create a task (`title` required). Wraps `Tasks.createTask`. */
867
1126
  create: (body) => Tasks.createTask({ client: client2, body }),
868
1127
  /** Update editable fields on a task by id. Wraps `Tasks.updateTask`. */
869
- update: (id, body) => Tasks.updateTask({ client: client2, path: { id }, body })
1128
+ update: (id, body) => Tasks.updateTask({ client: client2, path: { id }, body }),
1129
+ /**
1130
+ * GitHub pull requests linked to a task. Usually you don't need these: put
1131
+ * the task's `pr_token` (e.g. `pt-a3f91c2`, on `tasks.get`) in a PR title
1132
+ * or branch name and the PR links itself.
1133
+ */
1134
+ pullRequests: {
1135
+ /** List the task's linked PRs (state, checks, review, preview). Wraps `PullRequests.listTaskPullRequests`. */
1136
+ list: (id) => PullRequests.listTaskPullRequests({ client: client2, path: { id } }),
1137
+ /** Link a PR by URL (`https://github.com/o/r/pull/12` or `o/r#12`). Wraps `PullRequests.linkTaskPullRequest`. */
1138
+ link: (id, url) => PullRequests.linkTaskPullRequest({ client: client2, path: { id }, body: { url } }),
1139
+ /** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
1140
+ unlink: (id, prId) => PullRequests.unlinkTaskPullRequest({ client: client2, path: { id, prId } })
1141
+ }
870
1142
  };
871
1143
  }
872
1144
  var index_default = PerspecTask;
873
1145
  export {
874
1146
  PerspecTask,
1147
+ PullRequests,
875
1148
  Tasks,
876
- index_default as default
1149
+ index_default as default,
1150
+ zCreateTaskBody,
1151
+ zCreateTaskResponse,
1152
+ zGetTaskPath,
1153
+ zGetTaskQuery,
1154
+ zGetTaskResponse,
1155
+ zLinkTaskPullRequestBody,
1156
+ zLinkTaskPullRequestPath,
1157
+ zLinkTaskPullRequestResponse,
1158
+ zListTaskPullRequestsPath,
1159
+ zListTaskPullRequestsResponse,
1160
+ zListTasksQuery,
1161
+ zListTasksResponse,
1162
+ zPullRequest,
1163
+ zTask,
1164
+ zUnlinkTaskPullRequestPath,
1165
+ zUnlinkTaskPullRequestResponse,
1166
+ zUpdateTaskBody,
1167
+ zUpdateTaskPath,
1168
+ zUpdateTaskResponse
877
1169
  };
878
1170
  //# sourceMappingURL=index.js.map