@doist/todoist-api-typescript 7.5.0 → 7.6.1
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/cjs/authentication.js +46 -2
- package/dist/cjs/consts/endpoints.js +54 -2
- package/dist/cjs/todoist-api.js +524 -6
- package/dist/cjs/types/activity/index.js +18 -0
- package/dist/cjs/types/activity/requests.js +2 -0
- package/dist/cjs/types/activity/types.js +28 -0
- package/dist/cjs/types/backups/index.js +18 -0
- package/dist/cjs/types/backups/requests.js +2 -0
- package/dist/cjs/types/backups/types.js +8 -0
- package/dist/cjs/types/comments/index.js +18 -0
- package/dist/cjs/types/comments/requests.js +2 -0
- package/dist/cjs/types/comments/types.js +60 -0
- package/dist/cjs/types/common.js +2 -0
- package/dist/cjs/types/emails/index.js +17 -0
- package/dist/cjs/types/emails/requests.js +5 -0
- package/dist/cjs/types/id-mappings/index.js +18 -0
- package/dist/cjs/types/id-mappings/requests.js +20 -0
- package/dist/cjs/types/id-mappings/types.js +12 -0
- package/dist/cjs/types/index.js +16 -2
- package/dist/cjs/types/insights/index.js +18 -0
- package/dist/cjs/types/insights/requests.js +2 -0
- package/dist/cjs/types/insights/types.js +84 -0
- package/dist/cjs/types/labels/index.js +18 -0
- package/dist/cjs/types/labels/requests.js +2 -0
- package/dist/cjs/types/labels/types.js +11 -0
- package/dist/cjs/types/productivity/index.js +17 -0
- package/dist/cjs/types/productivity/types.js +67 -0
- package/dist/cjs/types/projects/index.js +18 -0
- package/dist/cjs/types/projects/requests.js +2 -0
- package/dist/cjs/types/projects/types.js +56 -0
- package/dist/cjs/types/reminders/index.js +17 -0
- package/dist/cjs/types/sections/index.js +18 -0
- package/dist/cjs/types/sections/requests.js +2 -0
- package/dist/cjs/types/sections/types.js +22 -0
- package/dist/cjs/types/sync/commands/shared.js +2 -2
- package/dist/cjs/types/sync/resources/collaborators.js +2 -2
- package/dist/cjs/types/sync/resources/notes.js +2 -2
- package/dist/cjs/types/sync/resources/reminders.js +3 -3
- package/dist/cjs/types/sync/resources/user.js +2 -2
- package/dist/cjs/types/sync/resources/workspaces.js +5 -5
- package/dist/cjs/types/tasks/index.js +18 -0
- package/dist/cjs/types/tasks/requests.js +2 -0
- package/dist/cjs/types/tasks/types.js +59 -0
- package/dist/cjs/types/templates/index.js +17 -0
- package/dist/cjs/types/templates/requests.js +2 -0
- package/dist/cjs/types/uploads/index.js +17 -0
- package/dist/cjs/types/uploads/requests.js +2 -0
- package/dist/cjs/types/users/index.js +17 -0
- package/dist/cjs/types/users/types.js +51 -0
- package/dist/cjs/types/workspaces/index.js +18 -0
- package/dist/cjs/types/workspaces/requests.js +2 -0
- package/dist/cjs/types/workspaces/types.js +137 -0
- package/dist/cjs/utils/validators.js +47 -19
- package/dist/esm/authentication.js +46 -3
- package/dist/esm/consts/endpoints.js +43 -0
- package/dist/esm/todoist-api.js +522 -4
- package/dist/esm/types/activity/index.js +2 -0
- package/dist/esm/types/activity/requests.js +1 -0
- package/dist/esm/types/activity/types.js +25 -0
- package/dist/esm/types/backups/index.js +2 -0
- package/dist/esm/types/backups/requests.js +1 -0
- package/dist/esm/types/backups/types.js +5 -0
- package/dist/esm/types/comments/index.js +2 -0
- package/dist/esm/types/comments/requests.js +1 -0
- package/dist/esm/types/comments/types.js +57 -0
- package/dist/esm/types/common.js +1 -0
- package/dist/esm/types/emails/index.js +1 -0
- package/dist/esm/types/emails/requests.js +2 -0
- package/dist/esm/types/id-mappings/index.js +2 -0
- package/dist/esm/types/id-mappings/requests.js +17 -0
- package/dist/esm/types/id-mappings/types.js +9 -0
- package/dist/esm/types/index.js +16 -2
- package/dist/esm/types/insights/index.js +2 -0
- package/dist/esm/types/insights/requests.js +1 -0
- package/dist/esm/types/insights/types.js +81 -0
- package/dist/esm/types/labels/index.js +2 -0
- package/dist/esm/types/labels/requests.js +1 -0
- package/dist/esm/types/labels/types.js +8 -0
- package/dist/esm/types/productivity/index.js +1 -0
- package/dist/esm/types/productivity/types.js +64 -0
- package/dist/esm/types/projects/index.js +2 -0
- package/dist/esm/types/projects/requests.js +1 -0
- package/dist/esm/types/projects/types.js +53 -0
- package/dist/esm/types/reminders/index.js +1 -0
- package/dist/esm/types/sections/index.js +2 -0
- package/dist/esm/types/sections/requests.js +1 -0
- package/dist/esm/types/sections/types.js +19 -0
- package/dist/esm/types/sync/commands/shared.js +1 -1
- package/dist/esm/types/sync/resources/collaborators.js +1 -1
- package/dist/esm/types/sync/resources/notes.js +1 -1
- package/dist/esm/types/sync/resources/reminders.js +1 -1
- package/dist/esm/types/sync/resources/user.js +1 -1
- package/dist/esm/types/sync/resources/workspaces.js +1 -1
- package/dist/esm/types/tasks/index.js +2 -0
- package/dist/esm/types/tasks/requests.js +1 -0
- package/dist/esm/types/tasks/types.js +56 -0
- package/dist/esm/types/templates/index.js +1 -0
- package/dist/esm/types/templates/requests.js +1 -0
- package/dist/esm/types/uploads/index.js +1 -0
- package/dist/esm/types/uploads/requests.js +1 -0
- package/dist/esm/types/users/index.js +1 -0
- package/dist/esm/types/users/types.js +48 -0
- package/dist/esm/types/workspaces/index.js +2 -0
- package/dist/esm/types/workspaces/requests.js +1 -0
- package/dist/esm/types/workspaces/types.js +134 -0
- package/dist/esm/utils/validators.js +30 -2
- package/dist/types/authentication.d.ts +51 -6
- package/dist/types/consts/endpoints.d.ts +22 -0
- package/dist/types/test-utils/test-defaults.d.ts +5 -5
- package/dist/types/todoist-api.d.ts +209 -4
- package/dist/types/types/activity/index.d.ts +2 -0
- package/dist/types/types/activity/requests.d.ts +85 -0
- package/dist/types/types/activity/types.d.ts +49 -0
- package/dist/types/types/backups/index.d.ts +2 -0
- package/dist/types/types/backups/requests.d.ts +16 -0
- package/dist/types/types/backups/types.d.ts +7 -0
- package/dist/types/types/comments/index.d.ts +2 -0
- package/dist/types/types/comments/requests.d.ts +63 -0
- package/dist/types/types/comments/types.d.ts +141 -0
- package/dist/types/types/common.d.ts +6 -0
- package/dist/types/types/emails/index.d.ts +1 -0
- package/dist/types/types/emails/requests.d.ts +30 -0
- package/dist/types/types/id-mappings/index.d.ts +2 -0
- package/dist/types/types/id-mappings/requests.d.ts +28 -0
- package/dist/types/types/id-mappings/types.d.ts +13 -0
- package/dist/types/types/index.d.ts +16 -2
- package/dist/types/types/insights/index.d.ts +2 -0
- package/dist/types/types/insights/requests.d.ts +26 -0
- package/dist/types/types/insights/types.d.ts +186 -0
- package/dist/types/types/labels/index.d.ts +2 -0
- package/dist/types/types/labels/requests.d.ts +75 -0
- package/dist/types/types/labels/types.d.ts +13 -0
- package/dist/types/types/productivity/index.d.ts +1 -0
- package/dist/types/types/productivity/types.d.ts +115 -0
- package/dist/types/types/projects/index.d.ts +2 -0
- package/dist/types/types/projects/requests.d.ts +169 -0
- package/dist/types/types/projects/types.d.ts +201 -0
- package/dist/types/types/reminders/index.d.ts +1 -0
- package/dist/types/types/reminders/requests.d.ts +91 -0
- package/dist/types/types/sections/index.d.ts +2 -0
- package/dist/types/types/sections/requests.d.ts +41 -0
- package/dist/types/types/sections/types.d.ts +44 -0
- package/dist/types/types/sync/commands/projects.d.ts +2 -1
- package/dist/types/types/sync/commands/shared.d.ts +2 -2
- package/dist/types/types/sync/commands/workspaces.d.ts +1 -1
- package/dist/types/types/sync/resources/notes.d.ts +1 -1
- package/dist/types/types/sync/resources/user.d.ts +2 -2
- package/dist/types/types/sync/resources/view-options.d.ts +5 -5
- package/dist/types/types/sync/response.d.ts +5 -1
- package/dist/types/types/sync/user-preferences.d.ts +1 -1
- package/dist/types/types/tasks/index.d.ts +2 -0
- package/dist/types/types/tasks/requests.d.ts +197 -0
- package/dist/types/types/tasks/types.d.ts +162 -0
- package/dist/types/types/templates/index.d.ts +1 -0
- package/dist/types/types/templates/requests.d.ts +92 -0
- package/dist/types/types/uploads/index.d.ts +1 -0
- package/dist/types/types/uploads/requests.d.ts +32 -0
- package/dist/types/types/users/index.d.ts +1 -0
- package/dist/types/types/users/types.d.ts +66 -0
- package/dist/types/types/workspaces/index.d.ts +2 -0
- package/dist/types/types/workspaces/requests.d.ts +260 -0
- package/dist/types/types/workspaces/types.d.ts +225 -0
- package/dist/types/utils/colors.d.ts +1 -1
- package/dist/types/utils/validators.d.ts +205 -12
- package/package.json +1 -1
- package/dist/cjs/types/entities.js +0 -437
- package/dist/esm/types/entities.js +0 -434
- package/dist/types/types/entities.d.ts +0 -971
- package/dist/types/types/requests.d.ts +0 -856
- /package/dist/cjs/types/{requests.js → reminders/requests.js} +0 -0
- /package/dist/esm/types/{requests.js → reminders/requests.js} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncUserSchema = exports.GettingStartedGuideProjectSchema = exports.JoinableWorkspaceSchema = exports.TzInfoSchema = exports.FeaturesSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const types_1 = require("../../users/types");
|
|
6
6
|
const user_preferences_1 = require("../user-preferences");
|
|
7
7
|
exports.FeaturesSchema = zod_1.z
|
|
8
8
|
.object({
|
|
@@ -92,7 +92,7 @@ exports.SyncUserSchema = zod_1.z
|
|
|
92
92
|
onboardingSkipped: zod_1.z.boolean().optional(),
|
|
93
93
|
onboardingTeamMode: zod_1.z.boolean().nullable().optional(),
|
|
94
94
|
onboardingUseCases: zod_1.z.array(zod_1.z.string()).nullable().optional(),
|
|
95
|
-
premiumStatus: zod_1.z.enum(
|
|
95
|
+
premiumStatus: zod_1.z.enum(types_1.PREMIUM_STATUSES),
|
|
96
96
|
premiumUntil: zod_1.z.string().nullable(),
|
|
97
97
|
rambleSessionsUsage: zod_1.z
|
|
98
98
|
.object({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncWorkspaceSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const types_1 = require("../../workspaces/types");
|
|
6
6
|
/**
|
|
7
7
|
* Sync API workspace resource.
|
|
8
8
|
*
|
|
@@ -23,9 +23,9 @@ exports.SyncWorkspaceSchema = zod_1.z
|
|
|
23
23
|
createdAt: zod_1.z.string(),
|
|
24
24
|
isDeleted: zod_1.z.boolean(),
|
|
25
25
|
isCollapsed: zod_1.z.boolean(),
|
|
26
|
-
role:
|
|
27
|
-
plan:
|
|
28
|
-
limits:
|
|
26
|
+
role: types_1.WorkspaceRoleSchema,
|
|
27
|
+
plan: types_1.WorkspacePlanSchema,
|
|
28
|
+
limits: types_1.WorkspaceLimitsSchema,
|
|
29
29
|
inviteCode: zod_1.z.string().nullable().optional(),
|
|
30
30
|
isLinkSharingEnabled: zod_1.z.boolean().nullable().optional(),
|
|
31
31
|
isGuestAllowed: zod_1.z.boolean().nullable().optional(),
|
|
@@ -51,6 +51,6 @@ exports.SyncWorkspaceSchema = zod_1.z
|
|
|
51
51
|
userIds: zod_1.z.array(zod_1.z.number()),
|
|
52
52
|
})
|
|
53
53
|
.optional(),
|
|
54
|
-
properties:
|
|
54
|
+
properties: types_1.WorkspacePropertiesSchema.optional(),
|
|
55
55
|
})
|
|
56
56
|
.passthrough();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./requests"), exports);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DURATION_UNITS = exports.DueDateSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const url_helpers_1 = require("../../utils/url-helpers");
|
|
6
|
+
const uncompletable_helpers_1 = require("../../utils/uncompletable-helpers");
|
|
7
|
+
exports.DueDateSchema = zod_1.z
|
|
8
|
+
.object({
|
|
9
|
+
isRecurring: zod_1.z.boolean(),
|
|
10
|
+
string: zod_1.z.string(),
|
|
11
|
+
date: zod_1.z.string(),
|
|
12
|
+
})
|
|
13
|
+
.extend({
|
|
14
|
+
datetime: zod_1.z.string().nullable().optional(),
|
|
15
|
+
timezone: zod_1.z.string().nullable().optional(),
|
|
16
|
+
lang: zod_1.z.string().nullable().optional(),
|
|
17
|
+
});
|
|
18
|
+
/** Available duration units for task deadlines. */
|
|
19
|
+
exports.DURATION_UNITS = ['minute', 'day'];
|
|
20
|
+
exports.DurationSchema = zod_1.z.object({
|
|
21
|
+
amount: zod_1.z.number().positive('Value should be greater than zero'),
|
|
22
|
+
unit: zod_1.z.enum(exports.DURATION_UNITS),
|
|
23
|
+
});
|
|
24
|
+
exports.DeadlineSchema = zod_1.z.object({
|
|
25
|
+
date: zod_1.z.string(),
|
|
26
|
+
lang: zod_1.z.string(),
|
|
27
|
+
});
|
|
28
|
+
exports.TaskSchema = zod_1.z
|
|
29
|
+
.object({
|
|
30
|
+
id: zod_1.z.string(),
|
|
31
|
+
userId: zod_1.z.string(),
|
|
32
|
+
projectId: zod_1.z.string(),
|
|
33
|
+
sectionId: zod_1.z.string().nullable(),
|
|
34
|
+
parentId: zod_1.z.string().nullable(),
|
|
35
|
+
addedByUid: zod_1.z.string().nullable(),
|
|
36
|
+
assignedByUid: zod_1.z.string().nullable(),
|
|
37
|
+
responsibleUid: zod_1.z.string().nullable(),
|
|
38
|
+
labels: zod_1.z.array(zod_1.z.string()),
|
|
39
|
+
deadline: exports.DeadlineSchema.nullable(),
|
|
40
|
+
duration: exports.DurationSchema.nullable(),
|
|
41
|
+
checked: zod_1.z.boolean(),
|
|
42
|
+
isDeleted: zod_1.z.boolean(),
|
|
43
|
+
addedAt: zod_1.z.string().nullable(),
|
|
44
|
+
completedAt: zod_1.z.string().nullable(),
|
|
45
|
+
updatedAt: zod_1.z.string().nullable(),
|
|
46
|
+
due: exports.DueDateSchema.nullable(),
|
|
47
|
+
priority: zod_1.z.number().int(),
|
|
48
|
+
childOrder: zod_1.z.number().int(),
|
|
49
|
+
content: zod_1.z.string(),
|
|
50
|
+
description: zod_1.z.string(),
|
|
51
|
+
dayOrder: zod_1.z.number().int(),
|
|
52
|
+
isCollapsed: zod_1.z.boolean(),
|
|
53
|
+
isUncompletable: zod_1.z.boolean().default(false),
|
|
54
|
+
})
|
|
55
|
+
.transform((data) => {
|
|
56
|
+
// Auto-detect uncompletable status from content prefix
|
|
57
|
+
const isUncompletable = (0, uncompletable_helpers_1.hasUncompletablePrefix)(data.content);
|
|
58
|
+
return Object.assign(Object.assign({}, data), { isUncompletable, url: (0, url_helpers_1.getTaskUrl)(data.id, data.content) });
|
|
59
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUserSchema = exports.PREMIUM_STATUSES = exports.TimezoneInfoSchema = exports.UserSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.UserSchema = zod_1.z.object({
|
|
6
|
+
id: zod_1.z.string(),
|
|
7
|
+
name: zod_1.z.string(),
|
|
8
|
+
email: zod_1.z.string(),
|
|
9
|
+
});
|
|
10
|
+
exports.TimezoneInfoSchema = zod_1.z.object({
|
|
11
|
+
gmtString: zod_1.z.string(),
|
|
12
|
+
hours: zod_1.z.number().int(),
|
|
13
|
+
isDst: zod_1.z.number().int(),
|
|
14
|
+
minutes: zod_1.z.number().int(),
|
|
15
|
+
timezone: zod_1.z.string(),
|
|
16
|
+
});
|
|
17
|
+
/** Available user premium statuses. */
|
|
18
|
+
exports.PREMIUM_STATUSES = [
|
|
19
|
+
'not_premium',
|
|
20
|
+
'current_personal_plan',
|
|
21
|
+
'legacy_personal_plan',
|
|
22
|
+
'teams_business_member',
|
|
23
|
+
];
|
|
24
|
+
exports.CurrentUserSchema = zod_1.z.object({
|
|
25
|
+
id: zod_1.z.string(),
|
|
26
|
+
email: zod_1.z.string(),
|
|
27
|
+
fullName: zod_1.z.string(),
|
|
28
|
+
avatarBig: zod_1.z.string().nullish(),
|
|
29
|
+
avatarMedium: zod_1.z.string().nullish(),
|
|
30
|
+
avatarS640: zod_1.z.string().nullish(),
|
|
31
|
+
avatarSmall: zod_1.z.string().nullish(),
|
|
32
|
+
businessAccountId: zod_1.z.string().nullable(),
|
|
33
|
+
isPremium: zod_1.z.boolean(),
|
|
34
|
+
premiumStatus: zod_1.z.enum(exports.PREMIUM_STATUSES),
|
|
35
|
+
dateFormat: zod_1.z.number().int(),
|
|
36
|
+
timeFormat: zod_1.z.number().int(),
|
|
37
|
+
weeklyGoal: zod_1.z.number().int(),
|
|
38
|
+
dailyGoal: zod_1.z.number().int(),
|
|
39
|
+
completedCount: zod_1.z.number().int(),
|
|
40
|
+
completedToday: zod_1.z.number().int(),
|
|
41
|
+
karma: zod_1.z.number(),
|
|
42
|
+
karmaTrend: zod_1.z.string(),
|
|
43
|
+
lang: zod_1.z.string(),
|
|
44
|
+
nextWeek: zod_1.z.number().int(),
|
|
45
|
+
startDay: zod_1.z.number().int(),
|
|
46
|
+
startPage: zod_1.z.string(),
|
|
47
|
+
tzInfo: exports.TimezoneInfoSchema,
|
|
48
|
+
inboxProjectId: zod_1.z.string(),
|
|
49
|
+
daysOff: zod_1.z.array(zod_1.z.number().int()),
|
|
50
|
+
weekendStartDay: zod_1.z.number().int(),
|
|
51
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./requests"), exports);
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkspaceUserTaskSchema = exports.MemberActivityInfoSchema = exports.WorkspaceSchema = exports.WorkspacePropertiesSchema = exports.WorkspaceLimitsSchema = exports.WorkspacePlanSchema = exports.WORKSPACE_PLANS = exports.JoinWorkspaceResultSchema = exports.WorkspacePlanDetailsSchema = exports.WORKSPACE_PLAN_STATUSES = exports.WORKSPACE_CURRENT_PLANS = exports.FormattedPriceListingSchema = exports.PlanPriceSchema = exports.WorkspaceInvitationSchema = exports.WorkspaceUserSchema = exports.WorkspaceRoleSchema = exports.WORKSPACE_ROLES = exports.COLLABORATOR_ROLES = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const types_1 = require("../tasks/types");
|
|
6
|
+
/** Available project collaborator roles. */
|
|
7
|
+
exports.COLLABORATOR_ROLES = [
|
|
8
|
+
'CREATOR',
|
|
9
|
+
'ADMIN',
|
|
10
|
+
'READ_WRITE',
|
|
11
|
+
'EDIT_ONLY',
|
|
12
|
+
'COMPLETE_ONLY',
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Available workspace roles.
|
|
16
|
+
*/
|
|
17
|
+
exports.WORKSPACE_ROLES = ['ADMIN', 'MEMBER', 'GUEST'];
|
|
18
|
+
exports.WorkspaceRoleSchema = zod_1.z.enum(exports.WORKSPACE_ROLES);
|
|
19
|
+
exports.WorkspaceUserSchema = zod_1.z.object({
|
|
20
|
+
userId: zod_1.z.string(),
|
|
21
|
+
workspaceId: zod_1.z.string(),
|
|
22
|
+
userEmail: zod_1.z.string(),
|
|
23
|
+
fullName: zod_1.z.string(),
|
|
24
|
+
timezone: zod_1.z.string(),
|
|
25
|
+
role: exports.WorkspaceRoleSchema,
|
|
26
|
+
imageId: zod_1.z.string().nullable(),
|
|
27
|
+
isDeleted: zod_1.z.boolean().default(false),
|
|
28
|
+
});
|
|
29
|
+
exports.WorkspaceInvitationSchema = zod_1.z.object({
|
|
30
|
+
id: zod_1.z.string().default('0'),
|
|
31
|
+
inviterId: zod_1.z.string(),
|
|
32
|
+
userEmail: zod_1.z.string(),
|
|
33
|
+
workspaceId: zod_1.z.string(),
|
|
34
|
+
role: exports.WorkspaceRoleSchema,
|
|
35
|
+
isExistingUser: zod_1.z.boolean(),
|
|
36
|
+
});
|
|
37
|
+
exports.PlanPriceSchema = zod_1.z.object({
|
|
38
|
+
currency: zod_1.z.string(),
|
|
39
|
+
amount: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
|
|
40
|
+
interval: zod_1.z.string().optional(),
|
|
41
|
+
});
|
|
42
|
+
exports.FormattedPriceListingSchema = zod_1.z.object({
|
|
43
|
+
currency: zod_1.z.string().optional(),
|
|
44
|
+
amount: zod_1.z.number().optional(),
|
|
45
|
+
interval: zod_1.z.string().optional(),
|
|
46
|
+
formatted: zod_1.z.string().optional(),
|
|
47
|
+
});
|
|
48
|
+
/** Available workspace plan names. */
|
|
49
|
+
exports.WORKSPACE_CURRENT_PLANS = ['Business', 'Starter'];
|
|
50
|
+
/** Available workspace plan statuses. */
|
|
51
|
+
exports.WORKSPACE_PLAN_STATUSES = [
|
|
52
|
+
'Active',
|
|
53
|
+
'Downgraded',
|
|
54
|
+
'Cancelled',
|
|
55
|
+
'NeverSubscribed',
|
|
56
|
+
];
|
|
57
|
+
exports.WorkspacePlanDetailsSchema = zod_1.z.object({
|
|
58
|
+
currentMemberCount: zod_1.z.number(),
|
|
59
|
+
currentPlan: zod_1.z.enum(exports.WORKSPACE_CURRENT_PLANS),
|
|
60
|
+
currentPlanStatus: zod_1.z.enum(exports.WORKSPACE_PLAN_STATUSES),
|
|
61
|
+
downgradeAt: zod_1.z.string().nullable(),
|
|
62
|
+
currentActiveProjects: zod_1.z.number(),
|
|
63
|
+
maximumActiveProjects: zod_1.z.number(),
|
|
64
|
+
priceList: zod_1.z.array(exports.FormattedPriceListingSchema),
|
|
65
|
+
workspaceId: zod_1.z.number(),
|
|
66
|
+
isTrialing: zod_1.z.boolean(),
|
|
67
|
+
trialEndsAt: zod_1.z.string().nullable(),
|
|
68
|
+
cancelAtPeriodEnd: zod_1.z.boolean(),
|
|
69
|
+
hasTrialed: zod_1.z.boolean(),
|
|
70
|
+
planPrice: exports.PlanPriceSchema.nullable(),
|
|
71
|
+
hasBillingPortal: zod_1.z.boolean(),
|
|
72
|
+
hasBillingPortalSwitchToAnnual: zod_1.z.boolean(),
|
|
73
|
+
});
|
|
74
|
+
exports.JoinWorkspaceResultSchema = zod_1.z.object({
|
|
75
|
+
customSortingApplied: zod_1.z.boolean(),
|
|
76
|
+
projectSortPreference: zod_1.z.string(),
|
|
77
|
+
role: exports.WorkspaceRoleSchema,
|
|
78
|
+
userId: zod_1.z.string(),
|
|
79
|
+
workspaceId: zod_1.z.string(),
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Available workspace plans.
|
|
83
|
+
*/
|
|
84
|
+
exports.WORKSPACE_PLANS = ['STARTER', 'BUSINESS'];
|
|
85
|
+
exports.WorkspacePlanSchema = zod_1.z.enum(exports.WORKSPACE_PLANS);
|
|
86
|
+
/**
|
|
87
|
+
* Workspace resource limits.
|
|
88
|
+
*/
|
|
89
|
+
exports.WorkspaceLimitsSchema = zod_1.z
|
|
90
|
+
.object({
|
|
91
|
+
current: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable(),
|
|
92
|
+
next: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable(),
|
|
93
|
+
})
|
|
94
|
+
.catchall(zod_1.z.any());
|
|
95
|
+
/**
|
|
96
|
+
* Workspace properties (flexible object for unknown fields).
|
|
97
|
+
*/
|
|
98
|
+
exports.WorkspacePropertiesSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
99
|
+
/**
|
|
100
|
+
* Represents a workspace in Todoist.
|
|
101
|
+
*/
|
|
102
|
+
exports.WorkspaceSchema = zod_1.z.object({
|
|
103
|
+
id: zod_1.z.string(),
|
|
104
|
+
name: zod_1.z.string(),
|
|
105
|
+
plan: exports.WorkspacePlanSchema,
|
|
106
|
+
role: exports.WorkspaceRoleSchema,
|
|
107
|
+
inviteCode: zod_1.z.string(),
|
|
108
|
+
isLinkSharingEnabled: zod_1.z.boolean(),
|
|
109
|
+
isGuestAllowed: zod_1.z.boolean(),
|
|
110
|
+
limits: exports.WorkspaceLimitsSchema,
|
|
111
|
+
logoBig: zod_1.z.string().nullish(),
|
|
112
|
+
logoMedium: zod_1.z.string().nullish(),
|
|
113
|
+
logoSmall: zod_1.z.string().nullish(),
|
|
114
|
+
logoS640: zod_1.z.string().nullish(),
|
|
115
|
+
createdAt: zod_1.z.string(),
|
|
116
|
+
creatorId: zod_1.z.string(),
|
|
117
|
+
properties: exports.WorkspacePropertiesSchema,
|
|
118
|
+
});
|
|
119
|
+
exports.MemberActivityInfoSchema = zod_1.z.object({
|
|
120
|
+
userId: zod_1.z.string(),
|
|
121
|
+
tasksAssigned: zod_1.z.number().int(),
|
|
122
|
+
tasksOverdue: zod_1.z.number().int(),
|
|
123
|
+
});
|
|
124
|
+
exports.WorkspaceUserTaskSchema = zod_1.z.object({
|
|
125
|
+
id: zod_1.z.string(),
|
|
126
|
+
content: zod_1.z.string(),
|
|
127
|
+
responsibleUid: zod_1.z.string().nullable(),
|
|
128
|
+
due: types_1.DueDateSchema.nullable(),
|
|
129
|
+
deadline: types_1.DeadlineSchema.nullable(),
|
|
130
|
+
labels: zod_1.z.array(zod_1.z.string()),
|
|
131
|
+
notesCount: zod_1.z.number().int(),
|
|
132
|
+
projectId: zod_1.z.string(),
|
|
133
|
+
projectName: zod_1.z.string(),
|
|
134
|
+
priority: zod_1.z.number().int(),
|
|
135
|
+
description: zod_1.z.string(),
|
|
136
|
+
isOverdue: zod_1.z.boolean(),
|
|
137
|
+
});
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = void 0;
|
|
3
|
+
exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = exports.validateNote = exports.validateFolderArray = exports.validateFolder = exports.validateCollaboratorStateArray = exports.validateCollaboratorState = exports.validateCollaboratorArray = exports.validateCollaborator = exports.validateFilterArray = exports.validateFilter = exports.validateMovedIdArray = exports.validateMovedId = exports.validateIdMappingArray = exports.validateIdMapping = exports.validateBackupArray = exports.validateBackup = exports.validateWorkspaceInsights = exports.validateProjectProgress = exports.validateProjectHealthContext = exports.validateProjectHealth = exports.validateProjectActivityStats = exports.validateWorkspaceUserTaskArray = exports.validateWorkspaceUserTask = exports.validateMemberActivityInfoArray = exports.validateMemberActivityInfo = exports.validateWorkspaceArray = exports.validateWorkspace = exports.validateJoinWorkspaceResult = exports.validateWorkspacePlanDetails = exports.validateWorkspaceInvitationArray = exports.validateWorkspaceInvitation = exports.validateWorkspaceUser = exports.validateAttachment = exports.validateActivityEventArray = exports.validateActivityEvent = exports.validateCurrentUser = exports.validateProductivityStats = exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateTaskArray = exports.validateTask = void 0;
|
|
4
|
+
exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = void 0;
|
|
5
5
|
exports.isWorkspaceProject = isWorkspaceProject;
|
|
6
6
|
exports.isPersonalProject = isPersonalProject;
|
|
7
7
|
exports.validateProject = validateProject;
|
|
8
8
|
exports.validateProjectArray = validateProjectArray;
|
|
9
9
|
exports.validateWorkspaceUserArray = validateWorkspaceUserArray;
|
|
10
|
-
const
|
|
10
|
+
const types_1 = require("../types/tasks/types");
|
|
11
|
+
const types_2 = require("../types/projects/types");
|
|
12
|
+
const types_3 = require("../types/sections/types");
|
|
13
|
+
const types_4 = require("../types/labels/types");
|
|
14
|
+
const types_5 = require("../types/comments/types");
|
|
15
|
+
const types_6 = require("../types/users/types");
|
|
16
|
+
const types_7 = require("../types/productivity/types");
|
|
17
|
+
const types_8 = require("../types/activity/types");
|
|
18
|
+
const types_9 = require("../types/workspaces/types");
|
|
19
|
+
const types_10 = require("../types/insights/types");
|
|
20
|
+
const types_11 = require("../types/backups/types");
|
|
21
|
+
const types_12 = require("../types/id-mappings/types");
|
|
11
22
|
const resources_1 = require("../types/sync/resources");
|
|
12
23
|
function createValidator(schema) {
|
|
13
24
|
return (input) => schema.parse(input);
|
|
@@ -16,7 +27,7 @@ function createArrayValidator(validateItem) {
|
|
|
16
27
|
return (input) => input.map(validateItem);
|
|
17
28
|
}
|
|
18
29
|
// Entity validators
|
|
19
|
-
exports.validateTask = createValidator(
|
|
30
|
+
exports.validateTask = createValidator(types_1.TaskSchema);
|
|
20
31
|
exports.validateTaskArray = createArrayValidator(exports.validateTask);
|
|
21
32
|
/**
|
|
22
33
|
* Type guard to check if a project is a workspace project.
|
|
@@ -41,39 +52,54 @@ function isPersonalProject(project) {
|
|
|
41
52
|
*/
|
|
42
53
|
function validateProject(input) {
|
|
43
54
|
if ('workspaceId' in input) {
|
|
44
|
-
return
|
|
55
|
+
return types_2.WorkspaceProjectSchema.parse(input);
|
|
45
56
|
}
|
|
46
|
-
return
|
|
57
|
+
return types_2.PersonalProjectSchema.parse(input);
|
|
47
58
|
}
|
|
48
59
|
function validateProjectArray(input) {
|
|
49
60
|
return input.map(validateProject);
|
|
50
61
|
}
|
|
51
|
-
exports.validateSection = createValidator(
|
|
62
|
+
exports.validateSection = createValidator(types_3.SectionSchema);
|
|
52
63
|
exports.validateSectionArray = createArrayValidator(exports.validateSection);
|
|
53
|
-
exports.validateLabel = createValidator(
|
|
64
|
+
exports.validateLabel = createValidator(types_4.LabelSchema);
|
|
54
65
|
exports.validateLabelArray = createArrayValidator(exports.validateLabel);
|
|
55
|
-
exports.validateComment = createValidator(
|
|
66
|
+
exports.validateComment = createValidator(types_5.CommentSchema);
|
|
56
67
|
exports.validateCommentArray = createArrayValidator(exports.validateComment);
|
|
57
|
-
exports.validateUser = createValidator(
|
|
68
|
+
exports.validateUser = createValidator(types_6.UserSchema);
|
|
58
69
|
exports.validateUserArray = createArrayValidator(exports.validateUser);
|
|
59
|
-
exports.validateProductivityStats = createValidator(
|
|
60
|
-
exports.validateCurrentUser = createValidator(
|
|
61
|
-
exports.validateActivityEvent = createValidator(
|
|
70
|
+
exports.validateProductivityStats = createValidator(types_7.ProductivityStatsSchema);
|
|
71
|
+
exports.validateCurrentUser = createValidator(types_6.CurrentUserSchema);
|
|
72
|
+
exports.validateActivityEvent = createValidator(types_8.ActivityEventSchema);
|
|
62
73
|
exports.validateActivityEventArray = createArrayValidator(exports.validateActivityEvent);
|
|
63
|
-
exports.validateAttachment = createValidator(
|
|
64
|
-
exports.validateWorkspaceUser = createValidator(
|
|
74
|
+
exports.validateAttachment = createValidator(types_5.AttachmentSchema);
|
|
75
|
+
exports.validateWorkspaceUser = createValidator(types_9.WorkspaceUserSchema);
|
|
65
76
|
function validateWorkspaceUserArray(input) {
|
|
66
77
|
if (!Array.isArray(input)) {
|
|
67
78
|
throw new Error(`Expected array for workspace users, got ${typeof input}`);
|
|
68
79
|
}
|
|
69
80
|
return input.map(exports.validateWorkspaceUser);
|
|
70
81
|
}
|
|
71
|
-
exports.validateWorkspaceInvitation = createValidator(
|
|
82
|
+
exports.validateWorkspaceInvitation = createValidator(types_9.WorkspaceInvitationSchema);
|
|
72
83
|
exports.validateWorkspaceInvitationArray = createArrayValidator(exports.validateWorkspaceInvitation);
|
|
73
|
-
exports.validateWorkspacePlanDetails = createValidator(
|
|
74
|
-
exports.validateJoinWorkspaceResult = createValidator(
|
|
75
|
-
exports.validateWorkspace = createValidator(
|
|
84
|
+
exports.validateWorkspacePlanDetails = createValidator(types_9.WorkspacePlanDetailsSchema);
|
|
85
|
+
exports.validateJoinWorkspaceResult = createValidator(types_9.JoinWorkspaceResultSchema);
|
|
86
|
+
exports.validateWorkspace = createValidator(types_9.WorkspaceSchema);
|
|
76
87
|
exports.validateWorkspaceArray = createArrayValidator(exports.validateWorkspace);
|
|
88
|
+
exports.validateMemberActivityInfo = createValidator(types_9.MemberActivityInfoSchema);
|
|
89
|
+
exports.validateMemberActivityInfoArray = createArrayValidator(exports.validateMemberActivityInfo);
|
|
90
|
+
exports.validateWorkspaceUserTask = createValidator(types_9.WorkspaceUserTaskSchema);
|
|
91
|
+
exports.validateWorkspaceUserTaskArray = createArrayValidator(exports.validateWorkspaceUserTask);
|
|
92
|
+
exports.validateProjectActivityStats = createValidator(types_10.ProjectActivityStatsSchema);
|
|
93
|
+
exports.validateProjectHealth = createValidator(types_10.ProjectHealthSchema);
|
|
94
|
+
exports.validateProjectHealthContext = createValidator(types_10.ProjectHealthContextSchema);
|
|
95
|
+
exports.validateProjectProgress = createValidator(types_10.ProjectProgressSchema);
|
|
96
|
+
exports.validateWorkspaceInsights = createValidator(types_10.WorkspaceInsightsSchema);
|
|
97
|
+
exports.validateBackup = createValidator(types_11.BackupSchema);
|
|
98
|
+
exports.validateBackupArray = createArrayValidator(exports.validateBackup);
|
|
99
|
+
exports.validateIdMapping = createValidator(types_12.IdMappingSchema);
|
|
100
|
+
exports.validateIdMappingArray = createArrayValidator(exports.validateIdMapping);
|
|
101
|
+
exports.validateMovedId = createValidator(types_12.MovedIdSchema);
|
|
102
|
+
exports.validateMovedIdArray = createArrayValidator(exports.validateMovedId);
|
|
77
103
|
// Sync resource validators
|
|
78
104
|
exports.validateFilter = createValidator(resources_1.FilterSchema);
|
|
79
105
|
exports.validateFilterArray = createArrayValidator(exports.validateFilter);
|
|
@@ -96,6 +122,8 @@ exports.validateCalendarAccount = createValidator(resources_1.CalendarAccountSch
|
|
|
96
122
|
exports.validateCalendarAccountArray = createArrayValidator(exports.validateCalendarAccount);
|
|
97
123
|
exports.validateReminder = createValidator(resources_1.ReminderSchema);
|
|
98
124
|
exports.validateReminderArray = createArrayValidator(exports.validateReminder);
|
|
125
|
+
exports.validateLocationReminder = createValidator(resources_1.LocationReminderSchema);
|
|
126
|
+
exports.validateLocationReminderArray = createArrayValidator(exports.validateLocationReminder);
|
|
99
127
|
exports.validateCompletedInfo = createValidator(resources_1.CompletedInfoSchema);
|
|
100
128
|
exports.validateCompletedInfoArray = createArrayValidator(exports.validateCompletedInfo);
|
|
101
129
|
exports.validateViewOptions = createValidator(resources_1.ViewOptionsSchema);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { request, isSuccess } from './transport/http-client.js';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
3
|
import { TodoistRequestError } from './types/index.js';
|
|
4
|
-
import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN, ENDPOINT_REVOKE, } from './consts/endpoints.js';
|
|
4
|
+
import { getAuthBaseUri, getSyncBaseUri, ENDPOINT_AUTHORIZATION, ENDPOINT_GET_TOKEN, ENDPOINT_REVOKE, ENDPOINT_REST_ACCESS_TOKENS_MIGRATE, } from './consts/endpoints.js';
|
|
5
5
|
/** Available OAuth2 permission scopes. */
|
|
6
6
|
export const PERMISSIONS = [
|
|
7
7
|
'task:add',
|
|
@@ -51,7 +51,7 @@ export function getAuthStateParameter() {
|
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
53
|
* @returns The full authorization URL to redirect users to
|
|
54
|
-
* @see https://todoist.com/api/v1
|
|
54
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization/OAuth
|
|
55
55
|
*/
|
|
56
56
|
export function getAuthorizationUrl({ clientId, permissions, state, baseUrl, }) {
|
|
57
57
|
if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
@@ -119,7 +119,7 @@ export async function getAuthToken(args, options) {
|
|
|
119
119
|
*
|
|
120
120
|
* @returns True if revocation was successful
|
|
121
121
|
* @see https://datatracker.ietf.org/doc/html/rfc7009
|
|
122
|
-
* @see https://todoist.com/api/v1
|
|
122
|
+
* @see https://developer.todoist.com/api/v1/#tag/Authorization
|
|
123
123
|
*/
|
|
124
124
|
export async function revokeToken(args, options) {
|
|
125
125
|
if (typeof options === 'string') {
|
|
@@ -151,3 +151,46 @@ export async function revokeToken(args, options) {
|
|
|
151
151
|
});
|
|
152
152
|
return isSuccess(response);
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Migrates a personal API token to an OAuth access token.
|
|
156
|
+
*
|
|
157
|
+
* This allows applications to transition users from personal API tokens
|
|
158
|
+
* to proper OAuth tokens without requiring the user to go through the
|
|
159
|
+
* full OAuth authorization flow.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const { accessToken } = await migratePersonalToken({
|
|
164
|
+
* clientId: 'your-client-id',
|
|
165
|
+
* clientSecret: 'your-client-secret',
|
|
166
|
+
* personalToken: 'user-personal-token',
|
|
167
|
+
* scope: 'data:read_write,data:delete'
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @returns The new OAuth token response
|
|
172
|
+
* @throws {@link TodoistRequestError} If the migration fails
|
|
173
|
+
*/
|
|
174
|
+
export async function migratePersonalToken(args, options) {
|
|
175
|
+
var _a;
|
|
176
|
+
const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
|
|
177
|
+
const customFetch = options === null || options === void 0 ? void 0 : options.customFetch;
|
|
178
|
+
try {
|
|
179
|
+
const response = await request({
|
|
180
|
+
httpMethod: 'POST',
|
|
181
|
+
baseUri: getSyncBaseUri(baseUrl),
|
|
182
|
+
relativePath: ENDPOINT_REST_ACCESS_TOKENS_MIGRATE,
|
|
183
|
+
apiToken: undefined,
|
|
184
|
+
payload: Object.assign(Object.assign({}, args), { scope: args.scope.join(',') }),
|
|
185
|
+
customFetch,
|
|
186
|
+
});
|
|
187
|
+
if (response.status !== 200 || !((_a = response.data) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
188
|
+
throw new TodoistRequestError('Personal token migration failed.', response.status, response.data);
|
|
189
|
+
}
|
|
190
|
+
return response.data;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
const err = error;
|
|
194
|
+
throw new TodoistRequestError('Personal token migration failed.', err.httpStatusCode, err.responseData);
|
|
195
|
+
}
|
|
196
|
+
}
|