@doist/todoist-api-typescript 5.8.0 → 6.0.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.
Files changed (88) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/authentication.js +158 -0
  3. package/dist/cjs/consts/endpoints.js +74 -0
  4. package/dist/{index.js → cjs/index.js} +1 -1
  5. package/dist/cjs/package.json +1 -0
  6. package/dist/cjs/rest-client.js +124 -0
  7. package/dist/{testUtils → cjs/test-utils}/asserts.js +1 -1
  8. package/dist/{testUtils → cjs/test-utils}/mocks.js +8 -4
  9. package/dist/cjs/test-utils/msw-setup.js +27 -0
  10. package/dist/{testUtils/testDefaults.js → cjs/test-utils/test-defaults.js} +41 -52
  11. package/dist/cjs/todoist-api.js +1235 -0
  12. package/dist/{types → cjs/types}/entities.js +78 -31
  13. package/dist/cjs/types/errors.js +22 -0
  14. package/dist/cjs/types/http.js +22 -0
  15. package/dist/cjs/utils/case-conversion.js +69 -0
  16. package/dist/{utils → cjs/utils}/colors.js +3 -3
  17. package/dist/cjs/utils/fetch-with-retry.js +150 -0
  18. package/dist/{utils → cjs/utils}/index.js +4 -4
  19. package/dist/cjs/utils/multipart-upload.js +126 -0
  20. package/dist/{utils → cjs/utils}/processing-helpers.js +3 -3
  21. package/dist/{utils → cjs/utils}/sanitization.js +17 -28
  22. package/dist/{utils/urlHelpers.js → cjs/utils/url-helpers.js} +15 -15
  23. package/dist/{utils → cjs/utils}/validators.js +28 -1
  24. package/dist/esm/authentication.js +151 -0
  25. package/dist/esm/consts/endpoints.js +65 -0
  26. package/dist/esm/index.js +4 -0
  27. package/dist/esm/rest-client.js +119 -0
  28. package/dist/esm/test-utils/asserts.js +8 -0
  29. package/dist/esm/test-utils/mocks.js +10 -0
  30. package/dist/esm/test-utils/msw-setup.js +22 -0
  31. package/dist/esm/test-utils/test-defaults.js +198 -0
  32. package/dist/esm/todoist-api.js +1231 -0
  33. package/dist/esm/types/entities.js +366 -0
  34. package/dist/esm/types/errors.js +18 -0
  35. package/dist/esm/types/http.js +18 -0
  36. package/dist/esm/types/index.js +3 -0
  37. package/dist/esm/types/requests.js +1 -0
  38. package/dist/esm/types/sync.js +1 -0
  39. package/dist/esm/utils/activity-helpers.js +36 -0
  40. package/dist/esm/utils/case-conversion.js +61 -0
  41. package/dist/esm/utils/colors.js +215 -0
  42. package/dist/esm/utils/fetch-with-retry.js +147 -0
  43. package/dist/esm/utils/index.js +3 -0
  44. package/dist/esm/utils/multipart-upload.js +120 -0
  45. package/dist/esm/utils/processing-helpers.js +12 -0
  46. package/dist/esm/utils/sanitization.js +112 -0
  47. package/dist/esm/utils/url-helpers.js +68 -0
  48. package/dist/esm/utils/validators.js +97 -0
  49. package/dist/{authentication.d.ts → types/authentication.d.ts} +6 -1
  50. package/dist/{consts → types/consts}/endpoints.d.ts +11 -0
  51. package/dist/types/index.d.ts +4 -3
  52. package/dist/types/rest-client.d.ts +15 -0
  53. package/dist/types/test-utils/msw-setup.d.ts +3 -0
  54. package/dist/{TodoistApi.d.ts → types/todoist-api.d.ts} +91 -2
  55. package/dist/types/{entities.d.ts → types/entities.d.ts} +119 -0
  56. package/dist/types/types/http.d.ts +68 -0
  57. package/dist/types/types/index.d.ts +3 -0
  58. package/dist/types/{requests.d.ts → types/requests.d.ts} +137 -0
  59. package/dist/types/utils/case-conversion.d.ts +12 -0
  60. package/dist/types/utils/fetch-with-retry.d.ts +11 -0
  61. package/dist/types/utils/index.d.ts +3 -0
  62. package/dist/types/utils/multipart-upload.d.ts +50 -0
  63. package/dist/{utils → types/utils}/validators.d.ts +7 -1
  64. package/package.json +24 -8
  65. package/dist/TodoistApi.js +0 -1209
  66. package/dist/authentication.js +0 -199
  67. package/dist/consts/endpoints.js +0 -50
  68. package/dist/index.d.ts +0 -4
  69. package/dist/restClient.d.ts +0 -5
  70. package/dist/restClient.js +0 -170
  71. package/dist/types/errors.js +0 -39
  72. package/dist/types/http.d.ts +0 -1
  73. package/dist/types/http.js +0 -2
  74. package/dist/utils/index.d.ts +0 -3
  75. /package/dist/{types → cjs/types}/index.js +0 -0
  76. /package/dist/{types → cjs/types}/requests.js +0 -0
  77. /package/dist/{types → cjs/types}/sync.js +0 -0
  78. /package/dist/{utils → cjs/utils}/activity-helpers.js +0 -0
  79. /package/dist/{testUtils → types/test-utils}/asserts.d.ts +0 -0
  80. /package/dist/{testUtils → types/test-utils}/mocks.d.ts +0 -0
  81. /package/dist/{testUtils/testDefaults.d.ts → types/test-utils/test-defaults.d.ts} +0 -0
  82. /package/dist/types/{errors.d.ts → types/errors.d.ts} +0 -0
  83. /package/dist/types/{sync.d.ts → types/sync.d.ts} +0 -0
  84. /package/dist/{utils → types/utils}/activity-helpers.d.ts +0 -0
  85. /package/dist/{utils → types/utils}/colors.d.ts +0 -0
  86. /package/dist/{utils → types/utils}/processing-helpers.d.ts +0 -0
  87. /package/dist/{utils → types/utils}/sanitization.d.ts +0 -0
  88. /package/dist/{utils/urlHelpers.d.ts → types/utils/url-helpers.d.ts} +0 -0
@@ -0,0 +1,97 @@
1
+ import { AttachmentSchema, SectionSchema, LabelSchema, CommentSchema, UserSchema, CurrentUserSchema, TaskSchema, PersonalProjectSchema, WorkspaceProjectSchema, ProductivityStatsSchema, ActivityEventSchema, WorkspaceUserSchema, WorkspaceInvitationSchema, WorkspacePlanDetailsSchema, JoinWorkspaceResultSchema, } from '../types/entities.js';
2
+ export function validateTask(input) {
3
+ return TaskSchema.parse(input);
4
+ }
5
+ export function validateTaskArray(input) {
6
+ return input.map(validateTask);
7
+ }
8
+ /**
9
+ * Type guard to check if a project is a workspace project.
10
+ * @param project The project to check
11
+ * @returns True if the project is a workspace project
12
+ */
13
+ export function isWorkspaceProject(project) {
14
+ return 'workspaceId' in project;
15
+ }
16
+ /**
17
+ * Type guard to check if a project is a personal project.
18
+ * @param project The project to check
19
+ * @returns True if the project is a personal project
20
+ */
21
+ export function isPersonalProject(project) {
22
+ return !isWorkspaceProject(project);
23
+ }
24
+ /**
25
+ * Validates and parses a project input.
26
+ * @param input The input to validate
27
+ * @returns A validated project (either PersonalProject or WorkspaceProject)
28
+ */
29
+ export function validateProject(input) {
30
+ if ('workspaceId' in input) {
31
+ return WorkspaceProjectSchema.parse(input);
32
+ }
33
+ return PersonalProjectSchema.parse(input);
34
+ }
35
+ export function validateProjectArray(input) {
36
+ return input.map(validateProject);
37
+ }
38
+ export function validateSection(input) {
39
+ return SectionSchema.parse(input);
40
+ }
41
+ export function validateSectionArray(input) {
42
+ return input.map(validateSection);
43
+ }
44
+ export function validateLabel(input) {
45
+ return LabelSchema.parse(input);
46
+ }
47
+ export function validateLabelArray(input) {
48
+ return input.map(validateLabel);
49
+ }
50
+ export function validateComment(input) {
51
+ return CommentSchema.parse(input);
52
+ }
53
+ export function validateCommentArray(input) {
54
+ return input.map(validateComment);
55
+ }
56
+ export function validateUser(input) {
57
+ return UserSchema.parse(input);
58
+ }
59
+ export function validateUserArray(input) {
60
+ return input.map(validateUser);
61
+ }
62
+ export function validateProductivityStats(input) {
63
+ return ProductivityStatsSchema.parse(input);
64
+ }
65
+ export function validateCurrentUser(input) {
66
+ return CurrentUserSchema.parse(input);
67
+ }
68
+ export function validateActivityEvent(input) {
69
+ return ActivityEventSchema.parse(input);
70
+ }
71
+ export function validateActivityEventArray(input) {
72
+ return input.map(validateActivityEvent);
73
+ }
74
+ export function validateAttachment(input) {
75
+ return AttachmentSchema.parse(input);
76
+ }
77
+ export function validateWorkspaceUser(input) {
78
+ return WorkspaceUserSchema.parse(input);
79
+ }
80
+ export function validateWorkspaceUserArray(input) {
81
+ if (!Array.isArray(input)) {
82
+ throw new Error(`Expected array for workspace users, got ${typeof input}`);
83
+ }
84
+ return input.map(validateWorkspaceUser);
85
+ }
86
+ export function validateWorkspaceInvitation(input) {
87
+ return WorkspaceInvitationSchema.parse(input);
88
+ }
89
+ export function validateWorkspaceInvitationArray(input) {
90
+ return input.map(validateWorkspaceInvitation);
91
+ }
92
+ export function validateWorkspacePlanDetails(input) {
93
+ return WorkspacePlanDetailsSchema.parse(input);
94
+ }
95
+ export function validateJoinWorkspaceResult(input) {
96
+ return JoinWorkspaceResultSchema.parse(input);
97
+ }
@@ -68,7 +68,12 @@ export declare function getAuthStateParameter(): string;
68
68
  * @returns The full authorization URL to redirect users to
69
69
  * @see https://todoist.com/api/v1/docs#tag/Authorization/OAuth
70
70
  */
71
- export declare function getAuthorizationUrl(clientId: string, permissions: Permission[], state: string, baseUrl?: string): string;
71
+ export declare function getAuthorizationUrl({ clientId, permissions, state, baseUrl, }: {
72
+ clientId: string;
73
+ permissions: Permission[];
74
+ state: string;
75
+ baseUrl?: string;
76
+ }): string;
72
77
  /**
73
78
  * Exchanges an authorization code for an access token.
74
79
  *
@@ -32,3 +32,14 @@ export declare const ENDPOINT_AUTHORIZATION = "authorize";
32
32
  export declare const ENDPOINT_GET_TOKEN = "access_token";
33
33
  export declare const ENDPOINT_REVOKE_TOKEN = "access_tokens/revoke";
34
34
  export declare const ENDPOINT_REVOKE = "revoke";
35
+ export declare const ENDPOINT_WORKSPACE_INVITATIONS = "workspaces/invitations";
36
+ export declare const ENDPOINT_WORKSPACE_INVITATIONS_ALL = "workspaces/invitations/all";
37
+ export declare const ENDPOINT_WORKSPACE_INVITATIONS_DELETE = "workspaces/invitations/delete";
38
+ export declare const ENDPOINT_WORKSPACE_JOIN = "workspaces/join";
39
+ export declare const ENDPOINT_WORKSPACE_LOGO = "workspaces/logo";
40
+ export declare const ENDPOINT_WORKSPACE_PLAN_DETAILS = "workspaces/plan_details";
41
+ export declare const ENDPOINT_WORKSPACE_USERS = "workspaces/users";
42
+ export declare function getWorkspaceInvitationAcceptEndpoint(inviteCode: string): string;
43
+ export declare function getWorkspaceInvitationRejectEndpoint(inviteCode: string): string;
44
+ export declare function getWorkspaceActiveProjectsEndpoint(workspaceId: number): string;
45
+ export declare function getWorkspaceArchivedProjectsEndpoint(workspaceId: number): string;
@@ -1,3 +1,4 @@
1
- export * from './entities';
2
- export * from './errors';
3
- export * from './requests';
1
+ export * from './todoist-api';
2
+ export * from './authentication';
3
+ export * from './types';
4
+ export * from './utils';
@@ -0,0 +1,15 @@
1
+ import { HttpMethod, HttpResponse } from './types/http';
2
+ type RequestArgs = {
3
+ httpMethod: HttpMethod;
4
+ baseUri: string;
5
+ relativePath: string;
6
+ apiToken?: string;
7
+ payload?: Record<string, unknown>;
8
+ requestId?: string;
9
+ hasSyncCommands?: boolean;
10
+ customHeaders?: Record<string, string>;
11
+ };
12
+ export declare function paramsSerializer(params: Record<string, unknown>): string;
13
+ export declare function isSuccess(response: HttpResponse): boolean;
14
+ export declare function request<T>(args: RequestArgs): Promise<HttpResponse<T>>;
15
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const handlers: never[];
2
+ export declare const server: import("msw/node").SetupServerApi;
3
+ export { http, HttpResponse } from 'msw';
@@ -1,5 +1,5 @@
1
- import { Attachment, PersonalProject, WorkspaceProject, Label, Section, Comment, Task, CurrentUser, ProductivityStats } from './types/entities';
2
- import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, GetTasksByFilterArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse, type MoveTaskArgs, GetCompletedTasksByCompletionDateArgs, GetCompletedTasksByDueDateArgs, GetCompletedTasksResponse, GetArchivedProjectsArgs, GetArchivedProjectsResponse, SearchCompletedTasksArgs, GetActivityLogsArgs, GetActivityLogsResponse, UploadFileArgs, DeleteUploadArgs } from './types/requests';
1
+ import { Attachment, PersonalProject, WorkspaceProject, Label, Section, Comment, Task, CurrentUser, ProductivityStats, WorkspaceInvitation, WorkspacePlanDetails, JoinWorkspaceResult } from './types/entities';
2
+ import { AddCommentArgs, AddLabelArgs, AddProjectArgs, AddSectionArgs, AddTaskArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, GetTasksByFilterArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs, GetSharedLabelsArgs, RenameSharedLabelArgs, RemoveSharedLabelArgs, GetProjectsArgs, GetProjectCollaboratorsArgs, GetLabelsArgs, GetLabelsResponse, GetTasksResponse, GetProjectsResponse, GetProjectCollaboratorsResponse, GetSectionsArgs, GetSectionsResponse, GetSharedLabelsResponse, GetCommentsResponse, type MoveTaskArgs, GetCompletedTasksByCompletionDateArgs, GetCompletedTasksByDueDateArgs, GetCompletedTasksResponse, GetArchivedProjectsArgs, GetArchivedProjectsResponse, SearchCompletedTasksArgs, GetActivityLogsArgs, GetActivityLogsResponse, UploadFileArgs, DeleteUploadArgs, GetWorkspaceInvitationsArgs, DeleteWorkspaceInvitationArgs, WorkspaceInvitationActionArgs, JoinWorkspaceArgs, WorkspaceLogoArgs, GetWorkspacePlanDetailsArgs, GetWorkspaceUsersArgs, GetWorkspaceUsersResponse, GetWorkspaceProjectsArgs, WorkspaceInvitationsResponse, AllWorkspaceInvitationsResponse, WorkspaceLogoResponse } from './types/requests';
3
3
  /**
4
4
  * A client for interacting with the Todoist API v1.
5
5
  * This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.
@@ -422,4 +422,93 @@ export declare class TodoistApi {
422
422
  * ```
423
423
  */
424
424
  deleteUpload(args: DeleteUploadArgs, requestId?: string): Promise<boolean>;
425
+ /**
426
+ * Gets pending invitations for a workspace.
427
+ *
428
+ * @param args - Arguments including workspace ID.
429
+ * @param requestId - Optional request ID for idempotency.
430
+ * @returns Array of email addresses with pending invitations.
431
+ */
432
+ getWorkspaceInvitations(args: GetWorkspaceInvitationsArgs, requestId?: string): Promise<WorkspaceInvitationsResponse>;
433
+ /**
434
+ * Gets all workspace invitations (admin only).
435
+ *
436
+ * @param requestId - Optional request ID for idempotency.
437
+ * @returns Array of email addresses with pending invitations.
438
+ */
439
+ getAllWorkspaceInvitations(args?: {
440
+ workspaceId?: number;
441
+ }, requestId?: string): Promise<AllWorkspaceInvitationsResponse>;
442
+ /**
443
+ * Deletes a workspace invitation (admin only).
444
+ *
445
+ * @param args - Arguments including workspace ID and user email.
446
+ * @param requestId - Optional request ID for idempotency.
447
+ * @returns The deleted invitation.
448
+ */
449
+ deleteWorkspaceInvitation(args: DeleteWorkspaceInvitationArgs, requestId?: string): Promise<WorkspaceInvitation>;
450
+ /**
451
+ * Accepts a workspace invitation.
452
+ *
453
+ * @param args - Arguments including invite code.
454
+ * @param requestId - Optional request ID for idempotency.
455
+ * @returns The accepted invitation.
456
+ */
457
+ acceptWorkspaceInvitation(args: WorkspaceInvitationActionArgs, requestId?: string): Promise<WorkspaceInvitation>;
458
+ /**
459
+ * Rejects a workspace invitation.
460
+ *
461
+ * @param args - Arguments including invite code.
462
+ * @param requestId - Optional request ID for idempotency.
463
+ * @returns The rejected invitation.
464
+ */
465
+ rejectWorkspaceInvitation(args: WorkspaceInvitationActionArgs, requestId?: string): Promise<WorkspaceInvitation>;
466
+ /**
467
+ * Joins a workspace via invitation link or domain auto-join.
468
+ *
469
+ * @param args - Arguments including invite code or workspace ID.
470
+ * @param requestId - Optional request ID for idempotency.
471
+ * @returns Workspace user information.
472
+ */
473
+ joinWorkspace(args: JoinWorkspaceArgs, requestId?: string): Promise<JoinWorkspaceResult>;
474
+ /**
475
+ * Uploads or updates a workspace logo.
476
+ *
477
+ * @param args - Arguments including workspace ID, file, and options.
478
+ * @param requestId - Optional request ID for idempotency.
479
+ * @returns Logo information or null if deleted.
480
+ */
481
+ uploadWorkspaceLogo(args: WorkspaceLogoArgs, requestId?: string): Promise<WorkspaceLogoResponse>;
482
+ /**
483
+ * Gets workspace plan and billing details.
484
+ *
485
+ * @param args - Arguments including workspace ID.
486
+ * @param requestId - Optional request ID for idempotency.
487
+ * @returns Workspace plan details.
488
+ */
489
+ getWorkspacePlanDetails(args: GetWorkspacePlanDetailsArgs, requestId?: string): Promise<WorkspacePlanDetails>;
490
+ /**
491
+ * Gets workspace users with pagination.
492
+ *
493
+ * @param args - Arguments including optional workspace ID, cursor, and limit.
494
+ * @param requestId - Optional request ID for idempotency.
495
+ * @returns Paginated list of workspace users.
496
+ */
497
+ getWorkspaceUsers(args?: GetWorkspaceUsersArgs, requestId?: string): Promise<GetWorkspaceUsersResponse>;
498
+ /**
499
+ * Gets active projects in a workspace with pagination.
500
+ *
501
+ * @param args - Arguments including workspace ID, cursor, and limit.
502
+ * @param requestId - Optional request ID for idempotency.
503
+ * @returns Paginated list of active workspace projects.
504
+ */
505
+ getWorkspaceActiveProjects(args: GetWorkspaceProjectsArgs, requestId?: string): Promise<GetProjectsResponse>;
506
+ /**
507
+ * Gets archived projects in a workspace with pagination.
508
+ *
509
+ * @param args - Arguments including workspace ID, cursor, and limit.
510
+ * @param requestId - Optional request ID for idempotency.
511
+ * @returns Paginated list of archived workspace projects.
512
+ */
513
+ getWorkspaceArchivedProjects(args: GetWorkspaceProjectsArgs, requestId?: string): Promise<GetProjectsResponse>;
425
514
  }
@@ -713,4 +713,123 @@ export declare const ActivityEventSchema: z.ZodObject<{
713
713
  * Represents an activity log event in Todoist.
714
714
  */
715
715
  export type ActivityEvent = z.infer<typeof ActivityEventSchema>;
716
+ /**
717
+ * Available workspace roles.
718
+ */
719
+ export declare const WORKSPACE_ROLES: readonly ["ADMIN", "MEMBER", "GUEST"];
720
+ /**
721
+ * Role of a user within a workspace.
722
+ */
723
+ export type WorkspaceRole = (typeof WORKSPACE_ROLES)[number];
724
+ export declare const WorkspaceRoleSchema: z.ZodEnum<{
725
+ ADMIN: "ADMIN";
726
+ MEMBER: "MEMBER";
727
+ GUEST: "GUEST";
728
+ }>;
729
+ export declare const WorkspaceUserSchema: z.ZodObject<{
730
+ userId: z.ZodString;
731
+ workspaceId: z.ZodString;
732
+ userEmail: z.ZodString;
733
+ fullName: z.ZodString;
734
+ timezone: z.ZodString;
735
+ role: z.ZodEnum<{
736
+ ADMIN: "ADMIN";
737
+ MEMBER: "MEMBER";
738
+ GUEST: "GUEST";
739
+ }>;
740
+ imageId: z.ZodNullable<z.ZodString>;
741
+ isDeleted: z.ZodDefault<z.ZodBoolean>;
742
+ }, z.core.$strip>;
743
+ /**
744
+ * Represents a user within a workspace (MemberView from API).
745
+ */
746
+ export type WorkspaceUser = z.infer<typeof WorkspaceUserSchema>;
747
+ export declare const WorkspaceInvitationSchema: z.ZodObject<{
748
+ id: z.ZodDefault<z.ZodString>;
749
+ inviterId: z.ZodString;
750
+ userEmail: z.ZodString;
751
+ workspaceId: z.ZodString;
752
+ role: z.ZodEnum<{
753
+ ADMIN: "ADMIN";
754
+ MEMBER: "MEMBER";
755
+ GUEST: "GUEST";
756
+ }>;
757
+ isExistingUser: z.ZodBoolean;
758
+ }, z.core.$strip>;
759
+ /**
760
+ * Represents a workspace invitation.
761
+ */
762
+ export type WorkspaceInvitation = z.infer<typeof WorkspaceInvitationSchema>;
763
+ export declare const PlanPriceSchema: z.ZodObject<{
764
+ currency: z.ZodString;
765
+ amount: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
766
+ interval: z.ZodOptional<z.ZodString>;
767
+ }, z.core.$strip>;
768
+ /**
769
+ * Plan pricing information.
770
+ */
771
+ export type PlanPrice = z.infer<typeof PlanPriceSchema>;
772
+ export declare const FormattedPriceListingSchema: z.ZodObject<{
773
+ currency: z.ZodOptional<z.ZodString>;
774
+ amount: z.ZodOptional<z.ZodNumber>;
775
+ interval: z.ZodOptional<z.ZodString>;
776
+ formatted: z.ZodOptional<z.ZodString>;
777
+ }, z.core.$strip>;
778
+ /**
779
+ * Formatted price listing for workspace plans.
780
+ */
781
+ export type FormattedPriceListing = z.infer<typeof FormattedPriceListingSchema>;
782
+ export declare const WorkspacePlanDetailsSchema: z.ZodObject<{
783
+ currentMemberCount: z.ZodNumber;
784
+ currentPlan: z.ZodEnum<{
785
+ Business: "Business";
786
+ Starter: "Starter";
787
+ }>;
788
+ currentPlanStatus: z.ZodEnum<{
789
+ Active: "Active";
790
+ Downgraded: "Downgraded";
791
+ Cancelled: "Cancelled";
792
+ NeverSubscribed: "NeverSubscribed";
793
+ }>;
794
+ downgradeAt: z.ZodNullable<z.ZodString>;
795
+ currentActiveProjects: z.ZodNumber;
796
+ maximumActiveProjects: z.ZodNumber;
797
+ priceList: z.ZodArray<z.ZodObject<{
798
+ currency: z.ZodOptional<z.ZodString>;
799
+ amount: z.ZodOptional<z.ZodNumber>;
800
+ interval: z.ZodOptional<z.ZodString>;
801
+ formatted: z.ZodOptional<z.ZodString>;
802
+ }, z.core.$strip>>;
803
+ workspaceId: z.ZodNumber;
804
+ isTrialing: z.ZodBoolean;
805
+ trialEndsAt: z.ZodNullable<z.ZodString>;
806
+ cancelAtPeriodEnd: z.ZodBoolean;
807
+ hasTrialed: z.ZodBoolean;
808
+ planPrice: z.ZodNullable<z.ZodObject<{
809
+ currency: z.ZodString;
810
+ amount: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
811
+ interval: z.ZodOptional<z.ZodString>;
812
+ }, z.core.$strip>>;
813
+ hasBillingPortal: z.ZodBoolean;
814
+ hasBillingPortalSwitchToAnnual: z.ZodBoolean;
815
+ }, z.core.$strip>;
816
+ /**
817
+ * Represents workspace plan and billing details.
818
+ */
819
+ export type WorkspacePlanDetails = z.infer<typeof WorkspacePlanDetailsSchema>;
820
+ export declare const JoinWorkspaceResultSchema: z.ZodObject<{
821
+ custom_sorting_applied: z.ZodBoolean;
822
+ project_sort_preference: z.ZodString;
823
+ role: z.ZodEnum<{
824
+ ADMIN: "ADMIN";
825
+ MEMBER: "MEMBER";
826
+ GUEST: "GUEST";
827
+ }>;
828
+ user_id: z.ZodString;
829
+ workspace_id: z.ZodString;
830
+ }, z.core.$strip>;
831
+ /**
832
+ * Result returned when successfully joining a workspace.
833
+ */
834
+ export type JoinWorkspaceResult = z.infer<typeof JoinWorkspaceResultSchema>;
716
835
  export {};
@@ -0,0 +1,68 @@
1
+ export type HttpMethod = 'POST' | 'GET' | 'DELETE' | 'PUT';
2
+ /**
3
+ * HTTP response type that replaces AxiosResponse
4
+ */
5
+ export type HttpResponse<T = unknown> = {
6
+ data: T;
7
+ status: number;
8
+ statusText: string;
9
+ headers: Record<string, string>;
10
+ };
11
+ /**
12
+ * HTTP request configuration
13
+ */
14
+ export type HttpRequestConfig = {
15
+ method?: HttpMethod;
16
+ headers?: Record<string, string>;
17
+ timeout?: number;
18
+ signal?: AbortSignal;
19
+ };
20
+ /**
21
+ * Internal HTTP request options
22
+ */
23
+ export type HttpRequestOptions = HttpRequestConfig & {
24
+ url: string;
25
+ params?: Record<string, unknown>;
26
+ data?: unknown;
27
+ };
28
+ /**
29
+ * Configuration for retry behavior
30
+ */
31
+ export type RetryConfig = {
32
+ retries: number;
33
+ retryCondition: (error: Error) => boolean;
34
+ retryDelay: (retryNumber: number) => number;
35
+ };
36
+ /**
37
+ * Configuration for the HTTP client
38
+ */
39
+ export type HttpClientConfig = {
40
+ baseURL?: string;
41
+ headers?: Record<string, string>;
42
+ timeout?: number;
43
+ retry?: RetryConfig;
44
+ };
45
+ /**
46
+ * Network error type for retry logic
47
+ */
48
+ export type NetworkError = Error & {
49
+ code?: string;
50
+ isNetworkError: true;
51
+ };
52
+ /**
53
+ * HTTP error with status code and response data
54
+ */
55
+ export type HttpError = Error & {
56
+ status?: number;
57
+ statusText?: string;
58
+ response?: HttpResponse<unknown>;
59
+ data?: unknown;
60
+ };
61
+ /**
62
+ * Type guard to check if an error is a network error
63
+ */
64
+ export declare function isNetworkError(error: Error): error is NetworkError;
65
+ /**
66
+ * Type guard to check if an error is an HTTP error
67
+ */
68
+ export declare function isHttpError(error: Error): error is HttpError;
@@ -0,0 +1,3 @@
1
+ export * from './entities';
2
+ export * from './errors';
3
+ export * from './requests';
@@ -510,4 +510,141 @@ export type DeleteUploadArgs = {
510
510
  */
511
511
  fileUrl: string;
512
512
  };
513
+ /**
514
+ * Arguments for getting workspace invitations.
515
+ */
516
+ export type GetWorkspaceInvitationsArgs = {
517
+ /**
518
+ * The workspace ID to get invitations for.
519
+ */
520
+ workspaceId: number;
521
+ };
522
+ /**
523
+ * Arguments for deleting a workspace invitation.
524
+ */
525
+ export type DeleteWorkspaceInvitationArgs = {
526
+ /**
527
+ * The workspace ID.
528
+ */
529
+ workspaceId: number;
530
+ /**
531
+ * The email address of the invitation to delete.
532
+ */
533
+ userEmail: string;
534
+ };
535
+ /**
536
+ * Arguments for accepting/rejecting a workspace invitation.
537
+ */
538
+ export type WorkspaceInvitationActionArgs = {
539
+ /**
540
+ * The invitation code from the email.
541
+ */
542
+ inviteCode: string;
543
+ };
544
+ /**
545
+ * Arguments for joining a workspace.
546
+ */
547
+ export type JoinWorkspaceArgs = {
548
+ /**
549
+ * Optional invitation code/link to join via.
550
+ */
551
+ inviteCode?: string | null;
552
+ /**
553
+ * Optional workspace ID to join via domain auto-join.
554
+ */
555
+ workspaceId?: number | null;
556
+ };
557
+ /**
558
+ * Arguments for uploading/updating workspace logo.
559
+ */
560
+ export type WorkspaceLogoArgs = {
561
+ /**
562
+ * The workspace ID.
563
+ */
564
+ workspaceId: number;
565
+ /**
566
+ * The image file to upload (Buffer, Stream, or file path).
567
+ */
568
+ file?: Buffer | NodeJS.ReadableStream | string;
569
+ /**
570
+ * The file name (required for Buffer/Stream uploads).
571
+ */
572
+ fileName?: string;
573
+ /**
574
+ * Whether to delete the logo instead of updating it.
575
+ */
576
+ delete?: boolean;
577
+ };
578
+ /**
579
+ * Arguments for getting workspace plan details.
580
+ */
581
+ export type GetWorkspacePlanDetailsArgs = {
582
+ /**
583
+ * The workspace ID.
584
+ */
585
+ workspaceId: number;
586
+ };
587
+ /**
588
+ * Arguments for getting workspace users (paginated).
589
+ */
590
+ export type GetWorkspaceUsersArgs = {
591
+ /**
592
+ * Optional workspace ID. If not provided, returns users for all workspaces.
593
+ */
594
+ workspaceId?: number | null;
595
+ /**
596
+ * Cursor for pagination.
597
+ */
598
+ cursor?: string | null;
599
+ /**
600
+ * Maximum number of users to return (default: 100).
601
+ */
602
+ limit?: number;
603
+ };
604
+ /**
605
+ * Arguments for getting workspace projects (paginated).
606
+ */
607
+ export type GetWorkspaceProjectsArgs = {
608
+ /**
609
+ * The workspace ID.
610
+ */
611
+ workspaceId: number;
612
+ /**
613
+ * Cursor for pagination.
614
+ */
615
+ cursor?: string | null;
616
+ /**
617
+ * Maximum number of projects to return (default: 100).
618
+ */
619
+ limit?: number;
620
+ };
621
+ /**
622
+ * Paginated response for workspace users.
623
+ */
624
+ export type GetWorkspaceUsersResponse = {
625
+ /**
626
+ * Whether there are more users available.
627
+ */
628
+ hasMore: boolean;
629
+ /**
630
+ * Cursor for the next page of results.
631
+ */
632
+ nextCursor?: string;
633
+ /**
634
+ * Array of workspace users.
635
+ */
636
+ workspaceUsers: import('./entities').WorkspaceUser[];
637
+ };
638
+ /**
639
+ * Response type for workspace invitations endpoint (simple email list).
640
+ */
641
+ export type WorkspaceInvitationsResponse = string[];
642
+ /**
643
+ * Response type for all workspace invitations endpoint (detailed objects).
644
+ */
645
+ export type AllWorkspaceInvitationsResponse = import('./entities').WorkspaceInvitation[];
646
+ /**
647
+ * Response type for workspace logo upload.
648
+ */
649
+ export type WorkspaceLogoResponse = Record<string, unknown> | null;
513
650
  export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Custom camelCase function that preserves emoji strings
3
+ */
4
+ export declare function customCamelCase(input: string): string;
5
+ /**
6
+ * Converts object keys from snake_case to camelCase recursively
7
+ */
8
+ export declare function camelCaseKeys<T>(obj: T): T;
9
+ /**
10
+ * Converts object keys from camelCase to snake_case recursively
11
+ */
12
+ export declare function snakeCaseKeys<T>(obj: T): T;
@@ -0,0 +1,11 @@
1
+ import type { HttpResponse, RetryConfig } from '../types/http';
2
+ /**
3
+ * Performs a fetch request with retry logic and timeout support
4
+ */
5
+ export declare function fetchWithRetry<T = unknown>(args: {
6
+ url: string;
7
+ options?: RequestInit & {
8
+ timeout?: number;
9
+ };
10
+ retryConfig?: Partial<RetryConfig>;
11
+ }): Promise<HttpResponse<T>>;
@@ -0,0 +1,3 @@
1
+ export * from './colors';
2
+ export * from './sanitization';
3
+ export { getTaskUrl, getProjectUrl, getSectionUrl } from './url-helpers';
@@ -0,0 +1,50 @@
1
+ type UploadMultipartFileArgs = {
2
+ baseUrl: string;
3
+ authToken: string;
4
+ endpoint: string;
5
+ file: Buffer | NodeJS.ReadableStream | string;
6
+ fileName?: string;
7
+ additionalFields: Record<string, string | number | boolean>;
8
+ requestId?: string;
9
+ };
10
+ /**
11
+ * Uploads a file using multipart/form-data.
12
+ *
13
+ * This is a shared utility for uploading files to Todoist endpoints that require
14
+ * multipart/form-data content type (e.g., file uploads, workspace logo uploads).
15
+ *
16
+ * @param baseUrl - The base API URL (e.g., https://api.todoist.com/api/v1/)
17
+ * @param authToken - The authentication token
18
+ * @param endpoint - The relative endpoint path (e.g., 'uploads', 'workspaces/logo')
19
+ * @param file - The file content (Buffer, ReadableStream, or file system path)
20
+ * @param fileName - Optional file name (required for Buffer/Stream, optional for paths)
21
+ * @param additionalFields - Additional form fields to include (e.g., project_id, workspace_id)
22
+ * @param requestId - Optional request ID for idempotency
23
+ * @returns The response data from the server
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // Upload from a file path
28
+ * const result = await uploadMultipartFile(
29
+ * 'https://api.todoist.com/api/v1/',
30
+ * 'my-token',
31
+ * 'uploads',
32
+ * '/path/to/file.pdf',
33
+ * undefined,
34
+ * { project_id: '12345' }
35
+ * )
36
+ *
37
+ * // Upload from a Buffer
38
+ * const buffer = Buffer.from('file content')
39
+ * const result = await uploadMultipartFile(
40
+ * 'https://api.todoist.com/api/v1/',
41
+ * 'my-token',
42
+ * 'uploads',
43
+ * buffer,
44
+ * 'document.pdf',
45
+ * { project_id: '12345' }
46
+ * )
47
+ * ```
48
+ */
49
+ export declare function uploadMultipartFile<T>(args: UploadMultipartFileArgs): Promise<T>;
50
+ export {};