@perspectask/sdk 0.0.5 → 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.d.ts CHANGED
@@ -322,6 +322,10 @@ type Task = {
322
322
  * Short id: the minimum unique prefix of the task UUID (e.g. "a3f"). Accepted anywhere an id is.
323
323
  */
324
324
  id?: string;
325
+ /**
326
+ * 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.
327
+ */
328
+ pr_token?: string;
325
329
  title?: string;
326
330
  description?: string;
327
331
  /**
@@ -357,6 +361,40 @@ type Task = {
357
361
  children?: Array<string | Task>;
358
362
  parents?: Array<string>;
359
363
  };
364
+ type PullRequest = {
365
+ /**
366
+ * Id of this task↔PR link. Pass it to unlink.
367
+ */
368
+ id: string;
369
+ repo: string;
370
+ number: number;
371
+ title: string;
372
+ /**
373
+ * The PR on github.com.
374
+ */
375
+ url: string;
376
+ state: 'open' | 'closed' | 'merged';
377
+ /**
378
+ * Only present when the PR is a draft.
379
+ */
380
+ draft?: true;
381
+ /**
382
+ * Combined CI result of the PR's head commit (check runs + commit statuses). Omitted when the commit has no CI.
383
+ */
384
+ checks?: 'pending' | 'success' | 'failure';
385
+ /**
386
+ * Reviewers' current decision. Omitted when nobody approved or requested changes.
387
+ */
388
+ review?: 'approved' | 'changes_requested';
389
+ /**
390
+ * Latest successful preview deployment (Vercel, Netlify, …). Omitted when there is none.
391
+ */
392
+ preview_url?: string;
393
+ /**
394
+ * `auto` = linked by the pt- code in the PR; `manual` = linked by URL.
395
+ */
396
+ linked_by: 'auto' | 'manual';
397
+ };
360
398
  type ListTasksData = {
361
399
  body?: never;
362
400
  path?: never;
@@ -523,6 +561,90 @@ type UpdateTaskResponses = {
523
561
  200: Task;
524
562
  };
525
563
  type UpdateTaskResponse = UpdateTaskResponses[keyof UpdateTaskResponses];
564
+ type ListTaskPullRequestsData = {
565
+ body?: never;
566
+ path: {
567
+ id: string;
568
+ };
569
+ query?: never;
570
+ url: '/tasks/{id}/pull-requests';
571
+ };
572
+ type ListTaskPullRequestsErrors = {
573
+ /**
574
+ * Task not found
575
+ */
576
+ 404: unknown;
577
+ };
578
+ type ListTaskPullRequestsResponses = {
579
+ /**
580
+ * Linked pull requests (oldest first)
581
+ */
582
+ 200: Array<PullRequest>;
583
+ };
584
+ type ListTaskPullRequestsResponse = ListTaskPullRequestsResponses[keyof ListTaskPullRequestsResponses];
585
+ type LinkTaskPullRequestData = {
586
+ body: {
587
+ /**
588
+ * The pull request: `https://github.com/owner/repo/pull/123` or `owner/repo#123`.
589
+ */
590
+ url: string;
591
+ };
592
+ path: {
593
+ id: string;
594
+ };
595
+ query?: never;
596
+ url: '/tasks/{id}/pull-requests';
597
+ };
598
+ type LinkTaskPullRequestErrors = {
599
+ /**
600
+ * Not a GitHub pull request URL
601
+ */
602
+ 400: unknown;
603
+ /**
604
+ * Task is encrypted
605
+ */
606
+ 403: unknown;
607
+ /**
608
+ * Task, repository access, or pull request not found
609
+ */
610
+ 404: unknown;
611
+ };
612
+ type LinkTaskPullRequestResponses = {
613
+ /**
614
+ * Linked
615
+ */
616
+ 201: PullRequest;
617
+ };
618
+ type LinkTaskPullRequestResponse = LinkTaskPullRequestResponses[keyof LinkTaskPullRequestResponses];
619
+ type UnlinkTaskPullRequestData = {
620
+ body?: never;
621
+ path: {
622
+ id: string;
623
+ /**
624
+ * The link id (`id` from the pull request list).
625
+ */
626
+ prId: string;
627
+ };
628
+ query?: never;
629
+ url: '/tasks/{id}/pull-requests/{prId}';
630
+ };
631
+ type UnlinkTaskPullRequestErrors = {
632
+ /**
633
+ * Task is encrypted
634
+ */
635
+ 403: unknown;
636
+ /**
637
+ * Task or link not found
638
+ */
639
+ 404: unknown;
640
+ };
641
+ type UnlinkTaskPullRequestResponses = {
642
+ /**
643
+ * Unlinked
644
+ */
645
+ 204: void;
646
+ };
647
+ type UnlinkTaskPullRequestResponse = UnlinkTaskPullRequestResponses[keyof UnlinkTaskPullRequestResponses];
526
648
 
527
649
  type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
528
650
  /**
@@ -555,9 +677,30 @@ declare class Tasks {
555
677
  */
556
678
  static updateTask<ThrowOnError extends boolean = false>(options: Options<UpdateTaskData, ThrowOnError>): RequestResult<UpdateTaskResponses, UpdateTaskErrors, ThrowOnError, "fields">;
557
679
  }
680
+ declare class PullRequests {
681
+ /**
682
+ * List pull requests linked to a task
683
+ *
684
+ * 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).
685
+ */
686
+ static listTaskPullRequests<ThrowOnError extends boolean = false>(options: Options<ListTaskPullRequestsData, ThrowOnError>): RequestResult<ListTaskPullRequestsResponses, ListTaskPullRequestsErrors, ThrowOnError, "fields">;
687
+ /**
688
+ * Link a pull request to a task
689
+ *
690
+ * 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.
691
+ */
692
+ static linkTaskPullRequest<ThrowOnError extends boolean = false>(options: Options<LinkTaskPullRequestData, ThrowOnError>): RequestResult<LinkTaskPullRequestResponses, LinkTaskPullRequestErrors, ThrowOnError, "fields">;
693
+ /**
694
+ * Unlink a pull request from a task
695
+ *
696
+ * 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.
697
+ */
698
+ static unlinkTaskPullRequest<ThrowOnError extends boolean = false>(options: Options<UnlinkTaskPullRequestData, ThrowOnError>): RequestResult<UnlinkTaskPullRequestResponses, UnlinkTaskPullRequestErrors, ThrowOnError, "fields">;
699
+ }
558
700
 
559
701
  declare const zTask: z.ZodMiniObject<{
560
702
  id: z.ZodMiniOptional<z.ZodMiniString<string>>;
703
+ pr_token: z.ZodMiniOptional<z.ZodMiniString<string>>;
561
704
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
562
705
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
563
706
  encrypted: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
@@ -580,6 +723,33 @@ declare const zTask: z.ZodMiniObject<{
580
723
  children: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniLazy<any>]>>>;
581
724
  parents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
582
725
  }, z.core.$strip>;
726
+ declare const zPullRequest: z.ZodMiniObject<{
727
+ id: z.ZodMiniUUID;
728
+ repo: z.ZodMiniString<string>;
729
+ number: z.ZodMiniNumberFormat;
730
+ title: z.ZodMiniString<string>;
731
+ url: z.ZodMiniString<string>;
732
+ state: z.ZodMiniEnum<{
733
+ open: "open";
734
+ closed: "closed";
735
+ merged: "merged";
736
+ }>;
737
+ draft: z.ZodMiniOptional<z.ZodMiniLiteral<true>>;
738
+ checks: z.ZodMiniOptional<z.ZodMiniEnum<{
739
+ pending: "pending";
740
+ success: "success";
741
+ failure: "failure";
742
+ }>>;
743
+ review: z.ZodMiniOptional<z.ZodMiniEnum<{
744
+ approved: "approved";
745
+ changes_requested: "changes_requested";
746
+ }>>;
747
+ preview_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
748
+ linked_by: z.ZodMiniEnum<{
749
+ auto: "auto";
750
+ manual: "manual";
751
+ }>;
752
+ }, z.core.$strip>;
583
753
  declare const zListTasksQuery: z.ZodMiniObject<{
584
754
  includeEncrypted: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
585
755
  tree: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
@@ -593,6 +763,7 @@ declare const zListTasksQuery: z.ZodMiniObject<{
593
763
  */
594
764
  declare const zListTasksResponse: z.ZodMiniArray<z.ZodMiniObject<{
595
765
  id: z.ZodMiniOptional<z.ZodMiniString<string>>;
766
+ pr_token: z.ZodMiniOptional<z.ZodMiniString<string>>;
596
767
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
597
768
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
598
769
  encrypted: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
@@ -627,6 +798,7 @@ declare const zCreateTaskBody: z.ZodMiniObject<{
627
798
  */
628
799
  declare const zCreateTaskResponse: z.ZodMiniObject<{
629
800
  id: z.ZodMiniOptional<z.ZodMiniString<string>>;
801
+ pr_token: z.ZodMiniOptional<z.ZodMiniString<string>>;
630
802
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
631
803
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
632
804
  encrypted: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
@@ -665,6 +837,7 @@ declare const zGetTaskQuery: z.ZodMiniObject<{
665
837
  */
666
838
  declare const zGetTaskResponse: z.ZodMiniObject<{
667
839
  id: z.ZodMiniOptional<z.ZodMiniString<string>>;
840
+ pr_token: z.ZodMiniOptional<z.ZodMiniString<string>>;
668
841
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
669
842
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
670
843
  encrypted: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
@@ -716,6 +889,7 @@ declare const zUpdateTaskPath: z.ZodMiniObject<{
716
889
  */
717
890
  declare const zUpdateTaskResponse: z.ZodMiniObject<{
718
891
  id: z.ZodMiniOptional<z.ZodMiniString<string>>;
892
+ pr_token: z.ZodMiniOptional<z.ZodMiniString<string>>;
719
893
  title: z.ZodMiniOptional<z.ZodMiniString<string>>;
720
894
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
721
895
  encrypted: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
@@ -738,6 +912,83 @@ declare const zUpdateTaskResponse: z.ZodMiniObject<{
738
912
  children: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniLazy<any>]>>>;
739
913
  parents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
740
914
  }, z.core.$strip>;
915
+ declare const zListTaskPullRequestsPath: z.ZodMiniObject<{
916
+ id: z.ZodMiniString<string>;
917
+ }, z.core.$strip>;
918
+ /**
919
+ * Linked pull requests (oldest first)
920
+ */
921
+ declare const zListTaskPullRequestsResponse: z.ZodMiniArray<z.ZodMiniObject<{
922
+ id: z.ZodMiniUUID;
923
+ repo: z.ZodMiniString<string>;
924
+ number: z.ZodMiniNumberFormat;
925
+ title: z.ZodMiniString<string>;
926
+ url: z.ZodMiniString<string>;
927
+ state: z.ZodMiniEnum<{
928
+ open: "open";
929
+ closed: "closed";
930
+ merged: "merged";
931
+ }>;
932
+ draft: z.ZodMiniOptional<z.ZodMiniLiteral<true>>;
933
+ checks: z.ZodMiniOptional<z.ZodMiniEnum<{
934
+ pending: "pending";
935
+ success: "success";
936
+ failure: "failure";
937
+ }>>;
938
+ review: z.ZodMiniOptional<z.ZodMiniEnum<{
939
+ approved: "approved";
940
+ changes_requested: "changes_requested";
941
+ }>>;
942
+ preview_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
943
+ linked_by: z.ZodMiniEnum<{
944
+ auto: "auto";
945
+ manual: "manual";
946
+ }>;
947
+ }, z.core.$strip>>;
948
+ declare const zLinkTaskPullRequestBody: z.ZodMiniObject<{
949
+ url: z.ZodMiniString<string>;
950
+ }, z.core.$strip>;
951
+ declare const zLinkTaskPullRequestPath: z.ZodMiniObject<{
952
+ id: z.ZodMiniString<string>;
953
+ }, z.core.$strip>;
954
+ /**
955
+ * Linked
956
+ */
957
+ declare const zLinkTaskPullRequestResponse: z.ZodMiniObject<{
958
+ id: z.ZodMiniUUID;
959
+ repo: z.ZodMiniString<string>;
960
+ number: z.ZodMiniNumberFormat;
961
+ title: z.ZodMiniString<string>;
962
+ url: z.ZodMiniString<string>;
963
+ state: z.ZodMiniEnum<{
964
+ open: "open";
965
+ closed: "closed";
966
+ merged: "merged";
967
+ }>;
968
+ draft: z.ZodMiniOptional<z.ZodMiniLiteral<true>>;
969
+ checks: z.ZodMiniOptional<z.ZodMiniEnum<{
970
+ pending: "pending";
971
+ success: "success";
972
+ failure: "failure";
973
+ }>>;
974
+ review: z.ZodMiniOptional<z.ZodMiniEnum<{
975
+ approved: "approved";
976
+ changes_requested: "changes_requested";
977
+ }>>;
978
+ preview_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
979
+ linked_by: z.ZodMiniEnum<{
980
+ auto: "auto";
981
+ manual: "manual";
982
+ }>;
983
+ }, z.core.$strip>;
984
+ declare const zUnlinkTaskPullRequestPath: z.ZodMiniObject<{
985
+ id: z.ZodMiniString<string>;
986
+ prId: z.ZodMiniUUID;
987
+ }, z.core.$strip>;
988
+ /**
989
+ * Unlinked
990
+ */
991
+ declare const zUnlinkTaskPullRequestResponse: z.ZodMiniVoid;
741
992
 
742
993
  interface PerspecTaskOptions {
743
994
  /**
@@ -821,6 +1072,46 @@ declare function createTasksNamespace(client: Client): {
821
1072
  request?: Request;
822
1073
  response?: Response;
823
1074
  }>;
1075
+ /**
1076
+ * GitHub pull requests linked to a task. Usually you don't need these: put
1077
+ * the task's `pr_token` (e.g. `pt-a3f91c2`, on `tasks.get`) in a PR title
1078
+ * or branch name and the PR links itself.
1079
+ */
1080
+ pullRequests: {
1081
+ /** List the task's linked PRs (state, checks, review, preview). Wraps `PullRequests.listTaskPullRequests`. */
1082
+ list: (id: string) => Promise<({
1083
+ data: PullRequest[];
1084
+ error: undefined;
1085
+ } | {
1086
+ data: undefined;
1087
+ error: unknown;
1088
+ }) & {
1089
+ request?: Request;
1090
+ response?: Response;
1091
+ }>;
1092
+ /** Link a PR by URL (`https://github.com/o/r/pull/12` or `o/r#12`). Wraps `PullRequests.linkTaskPullRequest`. */
1093
+ link: (id: string, url: string) => Promise<({
1094
+ data: PullRequest;
1095
+ error: undefined;
1096
+ } | {
1097
+ data: undefined;
1098
+ error: unknown;
1099
+ }) & {
1100
+ request?: Request;
1101
+ response?: Response;
1102
+ }>;
1103
+ /** Unlink by the link `id` from `list`. Wraps `PullRequests.unlinkTaskPullRequest`. */
1104
+ unlink: (id: string, prId: string) => Promise<({
1105
+ data: void;
1106
+ error: undefined;
1107
+ } | {
1108
+ data: undefined;
1109
+ error: unknown;
1110
+ }) & {
1111
+ request?: Request;
1112
+ response?: Response;
1113
+ }>;
1114
+ };
824
1115
  };
825
1116
 
826
- export { type ClientOptions, type CreateTaskData, type CreateTaskResponse, type CreateTaskResponses, type GetTaskData, type GetTaskErrors, type GetTaskResponse, type GetTaskResponses, type ListTasksData, type ListTasksResponse, type ListTasksResponses, type Options, PerspecTask, type PerspecTaskOptions, type Task, Tasks, type UpdateTaskData, type UpdateTaskErrors, type UpdateTaskResponse, type UpdateTaskResponses, PerspecTask as default, zCreateTaskBody, zCreateTaskResponse, zGetTaskPath, zGetTaskQuery, zGetTaskResponse, zListTasksQuery, zListTasksResponse, zTask, zUpdateTaskBody, zUpdateTaskPath, zUpdateTaskResponse };
1117
+ export { type ClientOptions, type CreateTaskData, type CreateTaskResponse, type CreateTaskResponses, type GetTaskData, type GetTaskErrors, type GetTaskResponse, type GetTaskResponses, type LinkTaskPullRequestData, type LinkTaskPullRequestErrors, type LinkTaskPullRequestResponse, type LinkTaskPullRequestResponses, type ListTaskPullRequestsData, type ListTaskPullRequestsErrors, type ListTaskPullRequestsResponse, type ListTaskPullRequestsResponses, type ListTasksData, type ListTasksResponse, type ListTasksResponses, type Options, PerspecTask, type PerspecTaskOptions, type PullRequest, PullRequests, type Task, Tasks, type UnlinkTaskPullRequestData, type UnlinkTaskPullRequestErrors, type UnlinkTaskPullRequestResponse, type UnlinkTaskPullRequestResponses, type UpdateTaskData, type UpdateTaskErrors, type UpdateTaskResponse, type UpdateTaskResponses, PerspecTask as default, zCreateTaskBody, zCreateTaskResponse, zGetTaskPath, zGetTaskQuery, zGetTaskResponse, zLinkTaskPullRequestBody, zLinkTaskPullRequestPath, zLinkTaskPullRequestResponse, zListTaskPullRequestsPath, zListTaskPullRequestsResponse, zListTasksQuery, zListTasksResponse, zPullRequest, zTask, zUnlinkTaskPullRequestPath, zUnlinkTaskPullRequestResponse, zUpdateTaskBody, zUpdateTaskPath, zUpdateTaskResponse };
package/dist/index.js CHANGED
@@ -837,6 +837,48 @@ 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
+ };
840
882
 
841
883
  // src/generated/zod.gen.ts
842
884
  import * as z from "zod/mini";
@@ -844,6 +886,9 @@ var zTask = z.object({
844
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, {
845
887
  description: 'Short id: the minimum unique prefix of the task UUID (e.g. "a3f"). Accepted anywhere an id is.'
846
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
+ })),
847
892
  title: z.optional(z.string()),
848
893
  description: z.optional(z.string()),
849
894
  encrypted: z.optional(z.boolean().register(z.globalRegistry, {
@@ -884,6 +929,41 @@ var zTask = z.object({
884
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)]))),
885
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}$/))))
886
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
+ });
887
967
  var zListTasksQuery = z.object({
888
968
  includeEncrypted: z.optional(z.boolean().register(z.globalRegistry, {
889
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."
@@ -992,6 +1072,30 @@ var zUpdateTaskPath = z.object({
992
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}$/))
993
1073
  });
994
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
+ });
995
1099
 
996
1100
  // src/index.ts
997
1101
  var PerspecTask = class {
@@ -1021,12 +1125,26 @@ function createTasksNamespace(client2) {
1021
1125
  /** Create a task (`title` required). Wraps `Tasks.createTask`. */
1022
1126
  create: (body) => Tasks.createTask({ client: client2, body }),
1023
1127
  /** Update editable fields on a task by id. Wraps `Tasks.updateTask`. */
1024
- 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
+ }
1025
1142
  };
1026
1143
  }
1027
1144
  var index_default = PerspecTask;
1028
1145
  export {
1029
1146
  PerspecTask,
1147
+ PullRequests,
1030
1148
  Tasks,
1031
1149
  index_default as default,
1032
1150
  zCreateTaskBody,
@@ -1034,9 +1152,17 @@ export {
1034
1152
  zGetTaskPath,
1035
1153
  zGetTaskQuery,
1036
1154
  zGetTaskResponse,
1155
+ zLinkTaskPullRequestBody,
1156
+ zLinkTaskPullRequestPath,
1157
+ zLinkTaskPullRequestResponse,
1158
+ zListTaskPullRequestsPath,
1159
+ zListTaskPullRequestsResponse,
1037
1160
  zListTasksQuery,
1038
1161
  zListTasksResponse,
1162
+ zPullRequest,
1039
1163
  zTask,
1164
+ zUnlinkTaskPullRequestPath,
1165
+ zUnlinkTaskPullRequestResponse,
1040
1166
  zUpdateTaskBody,
1041
1167
  zUpdateTaskPath,
1042
1168
  zUpdateTaskResponse