@doist/todoist-api-typescript 6.5.0 → 6.6.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 (144) hide show
  1. package/dist/cjs/todoist-api.js +32 -4
  2. package/dist/cjs/types/index.js +1 -0
  3. package/dist/cjs/types/sync/commands/calendars.js +2 -0
  4. package/dist/cjs/types/sync/commands/filters.js +2 -0
  5. package/dist/cjs/types/sync/commands/folders.js +2 -0
  6. package/dist/cjs/types/sync/commands/index.js +35 -0
  7. package/dist/cjs/types/sync/commands/labels.js +2 -0
  8. package/dist/cjs/types/sync/commands/notes.js +2 -0
  9. package/dist/cjs/types/sync/commands/notifications.js +2 -0
  10. package/dist/cjs/types/sync/commands/others.js +2 -0
  11. package/dist/cjs/types/sync/commands/project-view-options.js +2 -0
  12. package/dist/cjs/types/sync/commands/projects.js +2 -0
  13. package/dist/cjs/types/sync/commands/reminders.js +2 -0
  14. package/dist/cjs/types/sync/commands/sections.js +2 -0
  15. package/dist/cjs/types/sync/commands/shared.js +5 -0
  16. package/dist/cjs/types/sync/commands/sharing.js +2 -0
  17. package/dist/cjs/types/sync/commands/tasks.js +2 -0
  18. package/dist/cjs/types/sync/commands/view-options.js +2 -0
  19. package/dist/cjs/types/sync/commands/workspace-filters.js +2 -0
  20. package/dist/cjs/types/sync/commands/workspace-goals.js +2 -0
  21. package/dist/cjs/types/sync/commands/workspaces.js +2 -0
  22. package/dist/cjs/types/sync/index.js +21 -0
  23. package/dist/cjs/types/sync/request.js +2 -0
  24. package/dist/cjs/types/{sync.js → sync/resource-types.js} +9 -0
  25. package/dist/cjs/types/sync/resources/calendars.js +27 -0
  26. package/dist/cjs/types/sync/resources/collaborators.js +23 -0
  27. package/dist/cjs/types/sync/resources/completed-info.js +30 -0
  28. package/dist/cjs/types/sync/resources/filters.js +16 -0
  29. package/dist/cjs/types/sync/resources/folders.js +14 -0
  30. package/dist/cjs/types/sync/resources/index.js +33 -0
  31. package/dist/cjs/types/sync/resources/live-notifications.js +28 -0
  32. package/dist/cjs/types/sync/resources/notes.js +23 -0
  33. package/dist/cjs/types/sync/resources/reminders.js +34 -0
  34. package/dist/cjs/types/sync/resources/suggestions.js +38 -0
  35. package/dist/cjs/types/sync/resources/tooltips.js +10 -0
  36. package/dist/cjs/types/sync/resources/user-plan-limits.js +24 -0
  37. package/dist/cjs/types/sync/resources/user-settings.js +42 -0
  38. package/dist/cjs/types/sync/resources/user.js +123 -0
  39. package/dist/cjs/types/sync/resources/view-options.js +75 -0
  40. package/dist/cjs/types/sync/resources/workspace-filters.js +21 -0
  41. package/dist/cjs/types/sync/resources/workspace-goals.js +32 -0
  42. package/dist/cjs/types/sync/resources/workspaces.js +49 -0
  43. package/dist/cjs/types/sync/response.js +2 -0
  44. package/dist/cjs/utils/index.js +3 -1
  45. package/dist/cjs/utils/multipart-upload.js +93 -42
  46. package/dist/cjs/utils/sync-helpers.js +22 -0
  47. package/dist/cjs/utils/validators.js +69 -88
  48. package/dist/esm/todoist-api.js +32 -4
  49. package/dist/esm/types/index.js +1 -0
  50. package/dist/esm/types/sync/commands/calendars.js +1 -0
  51. package/dist/esm/types/sync/commands/filters.js +1 -0
  52. package/dist/esm/types/sync/commands/folders.js +1 -0
  53. package/dist/esm/types/sync/commands/index.js +19 -0
  54. package/dist/esm/types/sync/commands/labels.js +1 -0
  55. package/dist/esm/types/sync/commands/notes.js +1 -0
  56. package/dist/esm/types/sync/commands/notifications.js +1 -0
  57. package/dist/esm/types/sync/commands/others.js +1 -0
  58. package/dist/esm/types/sync/commands/project-view-options.js +1 -0
  59. package/dist/esm/types/sync/commands/projects.js +1 -0
  60. package/dist/esm/types/sync/commands/reminders.js +1 -0
  61. package/dist/esm/types/sync/commands/sections.js +1 -0
  62. package/dist/esm/types/sync/commands/shared.js +4 -0
  63. package/dist/esm/types/sync/commands/sharing.js +1 -0
  64. package/dist/esm/types/sync/commands/tasks.js +1 -0
  65. package/dist/esm/types/sync/commands/view-options.js +1 -0
  66. package/dist/esm/types/sync/commands/workspace-filters.js +1 -0
  67. package/dist/esm/types/sync/commands/workspace-goals.js +1 -0
  68. package/dist/esm/types/sync/commands/workspaces.js +1 -0
  69. package/dist/esm/types/sync/index.js +5 -0
  70. package/dist/esm/types/sync/request.js +1 -0
  71. package/dist/esm/types/{sync.js → sync/resource-types.js} +9 -0
  72. package/dist/esm/types/sync/resources/calendars.js +24 -0
  73. package/dist/esm/types/sync/resources/collaborators.js +20 -0
  74. package/dist/esm/types/sync/resources/completed-info.js +27 -0
  75. package/dist/esm/types/sync/resources/filters.js +13 -0
  76. package/dist/esm/types/sync/resources/folders.js +11 -0
  77. package/dist/esm/types/sync/resources/index.js +17 -0
  78. package/dist/esm/types/sync/resources/live-notifications.js +25 -0
  79. package/dist/esm/types/sync/resources/notes.js +20 -0
  80. package/dist/esm/types/sync/resources/reminders.js +31 -0
  81. package/dist/esm/types/sync/resources/suggestions.js +35 -0
  82. package/dist/esm/types/sync/resources/tooltips.js +7 -0
  83. package/dist/esm/types/sync/resources/user-plan-limits.js +21 -0
  84. package/dist/esm/types/sync/resources/user-settings.js +39 -0
  85. package/dist/esm/types/sync/resources/user.js +120 -0
  86. package/dist/esm/types/sync/resources/view-options.js +72 -0
  87. package/dist/esm/types/sync/resources/workspace-filters.js +18 -0
  88. package/dist/esm/types/sync/resources/workspace-goals.js +29 -0
  89. package/dist/esm/types/sync/resources/workspaces.js +46 -0
  90. package/dist/esm/types/sync/response.js +1 -0
  91. package/dist/esm/utils/index.js +1 -0
  92. package/dist/esm/utils/multipart-upload.js +60 -39
  93. package/dist/esm/utils/sync-helpers.js +19 -0
  94. package/dist/esm/utils/validators.js +65 -64
  95. package/dist/types/todoist-api.d.ts +26 -0
  96. package/dist/types/types/index.d.ts +1 -0
  97. package/dist/types/types/requests.d.ts +3 -3
  98. package/dist/types/types/sync/commands/calendars.d.ts +14 -0
  99. package/dist/types/types/sync/commands/filters.d.ts +21 -0
  100. package/dist/types/types/sync/commands/folders.d.ts +18 -0
  101. package/dist/types/types/sync/commands/index.d.ts +172 -0
  102. package/dist/types/types/sync/commands/labels.d.ts +27 -0
  103. package/dist/types/types/sync/commands/notes.d.ts +27 -0
  104. package/dist/types/types/sync/commands/notifications.d.ts +10 -0
  105. package/dist/types/types/sync/commands/others.d.ts +14 -0
  106. package/dist/types/types/sync/commands/project-view-options.d.ts +14 -0
  107. package/dist/types/types/sync/commands/projects.d.ts +88 -0
  108. package/dist/types/types/sync/commands/reminders.d.ts +27 -0
  109. package/dist/types/types/sync/commands/sections.d.ts +31 -0
  110. package/dist/types/types/sync/commands/shared.d.ts +46 -0
  111. package/dist/types/types/sync/commands/sharing.d.ts +16 -0
  112. package/dist/types/types/sync/commands/tasks.d.ts +78 -0
  113. package/dist/types/types/sync/commands/view-options.d.ts +19 -0
  114. package/dist/types/types/sync/commands/workspace-filters.d.ts +22 -0
  115. package/dist/types/types/sync/commands/workspace-goals.d.ts +24 -0
  116. package/dist/types/types/sync/commands/workspaces.d.ts +79 -0
  117. package/dist/types/types/sync/index.d.ts +5 -0
  118. package/dist/types/types/sync/request.d.ts +7 -0
  119. package/dist/types/types/sync/resource-types.d.ts +5 -0
  120. package/dist/types/types/sync/resources/calendars.d.ts +30 -0
  121. package/dist/types/types/sync/resources/collaborators.d.ts +24 -0
  122. package/dist/types/types/sync/resources/completed-info.d.ts +33 -0
  123. package/dist/types/types/sync/resources/filters.d.ts +12 -0
  124. package/dist/types/types/sync/resources/folders.d.ts +10 -0
  125. package/dist/types/types/sync/resources/index.d.ts +17 -0
  126. package/dist/types/types/sync/resources/live-notifications.d.ts +23 -0
  127. package/dist/types/types/sync/resources/notes.d.ts +34 -0
  128. package/dist/types/types/sync/resources/reminders.d.ts +101 -0
  129. package/dist/types/types/sync/resources/suggestions.d.ts +54 -0
  130. package/dist/types/types/sync/resources/tooltips.d.ts +6 -0
  131. package/dist/types/types/sync/resources/user-plan-limits.d.ts +41 -0
  132. package/dist/types/types/sync/resources/user-settings.d.ts +32 -0
  133. package/dist/types/types/sync/resources/user.d.ts +104 -0
  134. package/dist/types/types/sync/resources/view-options.d.ts +94 -0
  135. package/dist/types/types/sync/resources/workspace-filters.d.ts +17 -0
  136. package/dist/types/types/sync/resources/workspace-goals.d.ts +29 -0
  137. package/dist/types/types/sync/resources/workspaces.d.ts +52 -0
  138. package/dist/types/types/sync/response.d.ts +47 -0
  139. package/dist/types/utils/index.d.ts +1 -0
  140. package/dist/types/utils/multipart-upload.d.ts +5 -3
  141. package/dist/types/utils/sync-helpers.d.ts +17 -0
  142. package/dist/types/utils/validators.d.ts +1163 -23
  143. package/package.json +8 -8
  144. package/dist/types/types/sync.d.ts +0 -30
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SyncUserSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const FeaturesSchema = zod_1.z
6
+ .object({
7
+ karmaDisabled: zod_1.z.boolean(),
8
+ restriction: zod_1.z.number().int(),
9
+ karmaVacation: zod_1.z.boolean(),
10
+ dateistLang: zod_1.z.any(),
11
+ beta: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
12
+ hasPushReminders: zod_1.z.boolean(),
13
+ dateistInlineDisabled: zod_1.z.boolean(),
14
+ autoInviteDisabled: zod_1.z.boolean().optional(),
15
+ goldTheme: zod_1.z.boolean().optional(),
16
+ migratedFromTdb: zod_1.z.boolean().optional(),
17
+ })
18
+ .passthrough();
19
+ const TzInfoSchema = zod_1.z
20
+ .object({
21
+ timezone: zod_1.z.string(),
22
+ hours: zod_1.z.number().int(),
23
+ minutes: zod_1.z.number().int(),
24
+ isDst: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
25
+ gmtString: zod_1.z.string(),
26
+ })
27
+ .passthrough();
28
+ const JoinableWorkspaceSchema = zod_1.z
29
+ .object({
30
+ workspaceId: zod_1.z.string(),
31
+ workspaceName: zod_1.z.string(),
32
+ memberCount: zod_1.z.number().int(),
33
+ })
34
+ .passthrough();
35
+ const GettingStartedGuideProjectSchema = zod_1.z
36
+ .object({
37
+ onboardingUseCase: zod_1.z.string(),
38
+ projectId: zod_1.z.string(),
39
+ completed: zod_1.z.boolean(),
40
+ closed: zod_1.z.boolean(),
41
+ })
42
+ .passthrough();
43
+ /**
44
+ * Sync API user resource.
45
+ *
46
+ * This is a superset of the REST `CurrentUserSchema` — the Sync API returns
47
+ * many additional fields for features, onboarding state, and account details.
48
+ */
49
+ exports.SyncUserSchema = zod_1.z
50
+ .object({
51
+ id: zod_1.z.string(),
52
+ email: zod_1.z.string(),
53
+ fullName: zod_1.z.string(),
54
+ activatedUser: zod_1.z.boolean(),
55
+ autoReminder: zod_1.z.number().int(),
56
+ avatarBig: zod_1.z.string().optional(),
57
+ avatarMedium: zod_1.z.string().optional(),
58
+ avatarS640: zod_1.z.string().optional(),
59
+ avatarSmall: zod_1.z.string().optional(),
60
+ businessAccountId: zod_1.z.string().nullable(),
61
+ dailyGoal: zod_1.z.number().int(),
62
+ dateFormat: zod_1.z.number().int(),
63
+ dateistLang: zod_1.z.string().nullable(),
64
+ daysOff: zod_1.z.array(zod_1.z.number().int()),
65
+ featureIdentifier: zod_1.z.string(),
66
+ features: FeaturesSchema,
67
+ freeTrailExpires: zod_1.z.string().optional(),
68
+ hasMagicNumber: zod_1.z.boolean(),
69
+ hasPassword: zod_1.z.boolean(),
70
+ hasStartedATrial: zod_1.z.boolean().optional(),
71
+ imageId: zod_1.z.string().nullable(),
72
+ inboxProjectId: zod_1.z.string(),
73
+ isCelebrationsEnabled: zod_1.z.boolean(),
74
+ isPremium: zod_1.z.boolean(),
75
+ joinableWorkspace: JoinableWorkspaceSchema.nullable(),
76
+ joinedAt: zod_1.z.string(),
77
+ gettingStartedGuideProjects: zod_1.z.array(GettingStartedGuideProjectSchema).nullable(),
78
+ karma: zod_1.z.number(),
79
+ karmaTrend: zod_1.z.string(),
80
+ lang: zod_1.z.string(),
81
+ mfaEnabled: zod_1.z.boolean().optional(),
82
+ mobileHost: zod_1.z.string().nullable(),
83
+ mobileNumber: zod_1.z.string().nullable(),
84
+ nextWeek: zod_1.z.number().int(),
85
+ onboardingLevel: zod_1.z.string().nullable().optional(),
86
+ onboardingRole: zod_1.z.string().nullable().optional(),
87
+ onboardingPersona: zod_1.z.string().nullable().optional(),
88
+ onboardingInitiated: zod_1.z.boolean().nullable().optional(),
89
+ onboardingCompleted: zod_1.z.boolean().nullable().optional(),
90
+ onboardingSkipped: zod_1.z.boolean().optional(),
91
+ onboardingTeamMode: zod_1.z.boolean().nullable().optional(),
92
+ onboardingUseCases: zod_1.z.array(zod_1.z.string()).nullable().optional(),
93
+ premiumStatus: zod_1.z.enum([
94
+ 'not_premium',
95
+ 'current_personal_plan',
96
+ 'legacy_personal_plan',
97
+ 'teams_business_member',
98
+ ]),
99
+ premiumUntil: zod_1.z.string().nullable(),
100
+ rambleSessionsUsage: zod_1.z
101
+ .object({
102
+ currentCount: zod_1.z.number().int(),
103
+ limit: zod_1.z.number().int(),
104
+ remaining: zod_1.z.number().int(),
105
+ resetDate: zod_1.z.string(),
106
+ })
107
+ .nullable()
108
+ .optional(),
109
+ shareLimit: zod_1.z.number().int(),
110
+ sortOrder: zod_1.z.number().int(),
111
+ startDay: zod_1.z.number().int(),
112
+ startPage: zod_1.z.string(),
113
+ themeId: zod_1.z.string(),
114
+ timeFormat: zod_1.z.number().int(),
115
+ token: zod_1.z.string(),
116
+ tzInfo: TzInfoSchema,
117
+ uniquePrefix: zod_1.z.number().int(),
118
+ verificationStatus: zod_1.z.string(),
119
+ websocketUrl: zod_1.z.string(),
120
+ weekendStartDay: zod_1.z.number().int(),
121
+ weeklyGoal: zod_1.z.number().int(),
122
+ })
123
+ .passthrough();
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectViewOptionsDefaultsSchema = exports.ViewOptionsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ViewTypeSchema = zod_1.z.enum([
6
+ 'TODAY',
7
+ 'UPCOMING',
8
+ 'PROJECT',
9
+ 'LABEL',
10
+ 'FILTER',
11
+ 'WORKSPACE_FILTER',
12
+ 'SEARCH',
13
+ 'TEMPLATE_PREVIEW',
14
+ 'TASK_DETAIL',
15
+ 'AUTOMATION',
16
+ 'ASSIGNED',
17
+ 'OVERDUE',
18
+ 'WORKSPACE_OVERVIEW',
19
+ ]);
20
+ const ViewModeSchema = zod_1.z.enum(['LIST', 'BOARD', 'CALENDAR']);
21
+ const GroupedBySchema = zod_1.z
22
+ .enum([
23
+ 'ASSIGNEE',
24
+ 'ADDED_DATE',
25
+ 'DUE_DATE',
26
+ 'DEADLINE',
27
+ 'LABEL',
28
+ 'PRIORITY',
29
+ 'PROJECT',
30
+ 'WORKSPACE',
31
+ ])
32
+ .nullable();
33
+ const SortedBySchema = zod_1.z
34
+ .enum([
35
+ 'MANUAL',
36
+ 'ALPHABETICALLY',
37
+ 'ASSIGNEE',
38
+ 'DUE_DATE',
39
+ 'DEADLINE',
40
+ 'ADDED_DATE',
41
+ 'PRIORITY',
42
+ 'PROJECT',
43
+ 'WORKSPACE',
44
+ ])
45
+ .nullable();
46
+ const SortOrderSchema = zod_1.z.enum(['ASC', 'DESC']).nullable();
47
+ const CalendarSettingsSchema = zod_1.z
48
+ .object({
49
+ layout: zod_1.z.enum(['WEEK', 'MONTH']).optional(),
50
+ })
51
+ .passthrough();
52
+ exports.ViewOptionsSchema = zod_1.z
53
+ .object({
54
+ viewType: ViewTypeSchema,
55
+ objectId: zod_1.z.string().optional(),
56
+ groupedBy: GroupedBySchema.optional(),
57
+ filteredBy: zod_1.z.string().nullable().optional(),
58
+ viewMode: ViewModeSchema.optional(),
59
+ showCompletedTasks: zod_1.z.boolean().optional(),
60
+ sortedBy: SortedBySchema.optional(),
61
+ sortOrder: SortOrderSchema.optional(),
62
+ })
63
+ .passthrough();
64
+ exports.ProjectViewOptionsDefaultsSchema = zod_1.z
65
+ .object({
66
+ projectId: zod_1.z.string(),
67
+ viewMode: ViewModeSchema.nullable().optional(),
68
+ groupedBy: GroupedBySchema.optional(),
69
+ sortedBy: SortedBySchema.optional(),
70
+ sortOrder: SortOrderSchema.optional(),
71
+ showCompletedTasks: zod_1.z.boolean().optional(),
72
+ filteredBy: zod_1.z.string().nullable().optional(),
73
+ calendarSettings: CalendarSettingsSchema.nullable().optional(),
74
+ })
75
+ .passthrough();
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkspaceFilterSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.WorkspaceFilterSchema = zod_1.z
6
+ .object({
7
+ id: zod_1.z.string(),
8
+ workspaceId: zod_1.z.string(),
9
+ name: zod_1.z.string(),
10
+ query: zod_1.z.string(),
11
+ color: zod_1.z.string(),
12
+ itemOrder: zod_1.z.number().int(),
13
+ isDeleted: zod_1.z.boolean(),
14
+ isFavorite: zod_1.z.boolean(),
15
+ isFrozen: zod_1.z.boolean(),
16
+ creatorUid: zod_1.z.string(),
17
+ updaterUid: zod_1.z.string(),
18
+ createdAt: zod_1.z.string(),
19
+ updatedAt: zod_1.z.string(),
20
+ })
21
+ .passthrough();
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkspaceGoalSchema = exports.WorkspaceGoalProgressSchema = exports.WorkspaceGoalMilestoneSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.WorkspaceGoalMilestoneSchema = zod_1.z
6
+ .object({
7
+ id: zod_1.z.string(),
8
+ title: zod_1.z.string(),
9
+ isCompleted: zod_1.z.boolean(),
10
+ })
11
+ .passthrough();
12
+ exports.WorkspaceGoalProgressSchema = zod_1.z
13
+ .object({
14
+ completedItems: zod_1.z.number().int(),
15
+ totalItems: zod_1.z.number().int(),
16
+ })
17
+ .passthrough();
18
+ exports.WorkspaceGoalSchema = zod_1.z
19
+ .object({
20
+ id: zod_1.z.string(),
21
+ workspaceId: zod_1.z.string(),
22
+ title: zod_1.z.string(),
23
+ description: zod_1.z.string().nullable(),
24
+ deadline: zod_1.z.string().nullable(),
25
+ isDeleted: zod_1.z.boolean(),
26
+ projectIds: zod_1.z.array(zod_1.z.string()),
27
+ progress: exports.WorkspaceGoalProgressSchema.nullable(),
28
+ creatorUid: zod_1.z.string(),
29
+ createdAt: zod_1.z.string(),
30
+ updatedAt: zod_1.z.string(),
31
+ })
32
+ .passthrough();
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SyncWorkspaceSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const entities_1 = require("../../entities");
6
+ /**
7
+ * Sync API workspace resource.
8
+ *
9
+ * This is a superset of the REST `WorkspaceSchema` — the Sync API returns
10
+ * additional fields like description, isDeleted, isCollapsed, member counts,
11
+ * domain settings, and sorting preferences.
12
+ */
13
+ exports.SyncWorkspaceSchema = zod_1.z
14
+ .object({
15
+ id: zod_1.z.string(),
16
+ name: zod_1.z.string(),
17
+ description: zod_1.z.string(),
18
+ logoBig: zod_1.z.string().optional(),
19
+ logoMedium: zod_1.z.string().optional(),
20
+ logoSmall: zod_1.z.string().optional(),
21
+ logoS640: zod_1.z.string().optional(),
22
+ creatorId: zod_1.z.string(),
23
+ createdAt: zod_1.z.string(),
24
+ isDeleted: zod_1.z.boolean(),
25
+ isCollapsed: zod_1.z.boolean(),
26
+ role: entities_1.WorkspaceRoleSchema,
27
+ plan: entities_1.WorkspacePlanSchema,
28
+ limits: entities_1.WorkspaceLimitsSchema,
29
+ inviteCode: zod_1.z.string().nullable().optional(),
30
+ isLinkSharingEnabled: zod_1.z.boolean().nullable().optional(),
31
+ isGuestAllowed: zod_1.z.boolean().nullable().optional(),
32
+ currentActiveProjects: zod_1.z.number().nullable(),
33
+ currentMemberCount: zod_1.z.number().nullable(),
34
+ currentTemplateCount: zod_1.z.number().nullable(),
35
+ pendingInvitations: zod_1.z.array(zod_1.z.string()).nullable().optional(),
36
+ domainName: zod_1.z.string().optional(),
37
+ domainDiscovery: zod_1.z.boolean().optional(),
38
+ restrictEmailDomains: zod_1.z.boolean().optional(),
39
+ adminSortingApplied: zod_1.z.boolean(),
40
+ projectSortPreference: zod_1.z.string().optional(),
41
+ defaultCollaborators: zod_1.z
42
+ .object({
43
+ predefinedGroupIds: zod_1.z.array(zod_1.z.string()),
44
+ userIds: zod_1.z.array(zod_1.z.number()),
45
+ })
46
+ .optional(),
47
+ properties: entities_1.WorkspacePropertiesSchema.optional(),
48
+ })
49
+ .passthrough();
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -14,10 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getSectionUrl = exports.getProjectUrl = exports.getTaskUrl = void 0;
17
+ exports.createCommand = exports.getSectionUrl = exports.getProjectUrl = exports.getTaskUrl = void 0;
18
18
  __exportStar(require("./colors"), exports);
19
19
  __exportStar(require("./sanitization"), exports);
20
20
  var url_helpers_1 = require("./url-helpers");
21
21
  Object.defineProperty(exports, "getTaskUrl", { enumerable: true, get: function () { return url_helpers_1.getTaskUrl; } });
22
22
  Object.defineProperty(exports, "getProjectUrl", { enumerable: true, get: function () { return url_helpers_1.getProjectUrl; } });
23
23
  Object.defineProperty(exports, "getSectionUrl", { enumerable: true, get: function () { return url_helpers_1.getSectionUrl; } });
24
+ var sync_helpers_1 = require("./sync-helpers");
25
+ Object.defineProperty(exports, "createCommand", { enumerable: true, get: function () { return sync_helpers_1.createCommand; } });
@@ -1,12 +1,39 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.uploadMultipartFile = uploadMultipartFile;
7
- const form_data_1 = __importDefault(require("form-data"));
8
- const fs_1 = require("fs");
9
- const path_1 = require("path");
10
37
  const fetch_with_retry_1 = require("./fetch-with-retry");
11
38
  /**
12
39
  * Helper function to determine content-type from filename extension.
@@ -37,11 +64,13 @@ function getContentTypeFromFileName(fileName) {
37
64
  * This is a shared utility for uploading files to Todoist endpoints that require
38
65
  * multipart/form-data content type (e.g., file uploads, workspace logo uploads).
39
66
  *
67
+ * Supports both browser (Blob/File) and Node.js (Buffer/ReadableStream/path) environments.
68
+ *
40
69
  * @param baseUrl - The base API URL (e.g., https://api.todoist.com/api/v1/)
41
70
  * @param authToken - The authentication token
42
71
  * @param endpoint - The relative endpoint path (e.g., 'uploads', 'workspaces/logo')
43
- * @param file - The file content (Buffer, ReadableStream, or file system path)
44
- * @param fileName - Optional file name (required for Buffer/Stream, optional for paths)
72
+ * @param file - The file content (Blob/File for browser, or Buffer/ReadableStream/path for Node)
73
+ * @param fileName - Optional file name (required for Buffer/Stream, optional for paths and File objects)
45
74
  * @param additionalFields - Additional form fields to include (e.g., project_id, workspace_id)
46
75
  * @param requestId - Optional request ID for idempotency
47
76
  * @returns The response data from the server
@@ -72,52 +101,74 @@ function getContentTypeFromFileName(fileName) {
72
101
  */
73
102
  async function uploadMultipartFile(args) {
74
103
  const { baseUrl, authToken, endpoint, file, fileName, additionalFields, requestId, customFetch, } = args;
75
- const form = new form_data_1.default();
76
- // Determine file type and add to form data
77
- if (typeof file === 'string') {
78
- // File path - create read stream
79
- const filePath = file;
80
- const resolvedFileName = fileName || (0, path_1.basename)(filePath);
81
- form.append('file', (0, fs_1.createReadStream)(filePath), resolvedFileName);
104
+ // Build the full URL
105
+ const url = `${baseUrl}${endpoint}`;
106
+ let body;
107
+ const headers = {
108
+ Authorization: `Bearer ${authToken}`,
109
+ };
110
+ if (requestId) {
111
+ headers['X-Request-Id'] = requestId;
82
112
  }
83
- else if (Buffer.isBuffer(file)) {
84
- // Buffer - require fileName
85
- if (!fileName) {
86
- throw new Error('fileName is required when uploading from a Buffer');
113
+ if (file instanceof Blob) {
114
+ // Browser path: use native FormData
115
+ const form = new globalThis.FormData();
116
+ const resolvedFileName = fileName || (file instanceof File ? file.name : undefined) || 'upload';
117
+ form.append('file', file, resolvedFileName);
118
+ for (const [key, value] of Object.entries(additionalFields)) {
119
+ if (value !== undefined && value !== null) {
120
+ form.append(key, value.toString());
121
+ }
87
122
  }
88
- // Detect content-type from filename extension
89
- const contentType = getContentTypeFromFileName(fileName);
90
- form.append('file', file, {
91
- filename: fileName,
92
- contentType: contentType,
93
- });
123
+ // Don't set Content-Type let fetch set it with the correct multipart boundary
124
+ body = form;
94
125
  }
95
126
  else {
96
- // Stream - require fileName
97
- if (!fileName) {
98
- throw new Error('fileName is required when uploading from a stream');
127
+ // Node path: dynamically import Node-only modules
128
+ const [FormDataModule, fsModule, pathModule] = await Promise.all([
129
+ Promise.resolve().then(() => __importStar(require('form-data'))),
130
+ Promise.resolve().then(() => __importStar(require('fs'))),
131
+ Promise.resolve().then(() => __importStar(require('path'))),
132
+ ]);
133
+ const FormData = FormDataModule.default;
134
+ const form = new FormData();
135
+ if (typeof file === 'string') {
136
+ // File path - create read stream
137
+ const resolvedFileName = fileName || pathModule.basename(file);
138
+ form.append('file', fsModule.createReadStream(file), resolvedFileName);
99
139
  }
100
- form.append('file', file, fileName);
101
- }
102
- // Add additional fields to the form
103
- for (const [key, value] of Object.entries(additionalFields)) {
104
- if (value !== undefined && value !== null) {
105
- form.append(key, value.toString());
140
+ else if (Buffer.isBuffer(file)) {
141
+ // Buffer - require fileName
142
+ if (!fileName) {
143
+ throw new Error('fileName is required when uploading from a Buffer');
144
+ }
145
+ const contentType = getContentTypeFromFileName(fileName);
146
+ form.append('file', file, {
147
+ filename: fileName,
148
+ contentType: contentType,
149
+ });
106
150
  }
107
- }
108
- // Build the full URL
109
- const url = `${baseUrl}${endpoint}`;
110
- // Prepare headers
111
- const headers = Object.assign({ Authorization: `Bearer ${authToken}` }, form.getHeaders());
112
- if (requestId) {
113
- headers['X-Request-Id'] = requestId;
151
+ else {
152
+ // Stream - require fileName
153
+ if (!fileName) {
154
+ throw new Error('fileName is required when uploading from a stream');
155
+ }
156
+ form.append('file', file, fileName);
157
+ }
158
+ for (const [key, value] of Object.entries(additionalFields)) {
159
+ if (value !== undefined && value !== null) {
160
+ form.append(key, value.toString());
161
+ }
162
+ }
163
+ Object.assign(headers, form.getHeaders());
164
+ body = form;
114
165
  }
115
166
  // Make the request using fetch
116
167
  const response = await (0, fetch_with_retry_1.fetchWithRetry)({
117
168
  url,
118
169
  options: {
119
170
  method: 'POST',
120
- body: form, // FormData from 'form-data' package is compatible with fetch
171
+ body,
121
172
  headers,
122
173
  timeout: 30000, // 30 second timeout for file uploads
123
174
  },
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCommand = createCommand;
4
+ const uuid_1 = require("uuid");
5
+ /**
6
+ * Creates a strongly-typed Sync API command with an auto-generated UUID.
7
+ *
8
+ * @param type - The command type (e.g. `'item_add'`, `'project_update'`).
9
+ * @param args - The command arguments, constrained by the command type.
10
+ * @param tempId - Optional temporary ID for referencing the created resource in subsequent commands.
11
+ * @returns A fully formed `SyncCommand` ready to include in a sync request.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const cmd = createCommand('item_add', { content: 'Buy milk', priority: 2 })
16
+ * // cmd.type === 'item_add'
17
+ * // cmd.args is typed as TaskAddArgs
18
+ * ```
19
+ */
20
+ function createCommand(type, args, tempId) {
21
+ return Object.assign({ type, uuid: (0, uuid_1.v4)(), args: args }, (tempId !== undefined ? { tempId } : {}));
22
+ }