@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.cts 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 };