@doist/todoist-sdk 14.1.0 → 15.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.
- package/README.md +46 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/transport/http-dispatcher.js +25 -0
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/multipart-upload.js +171 -57
- package/dist/esm/utils/url-helpers.js +151 -23
- package/dist/types/index.d.ts +2 -1
- package/dist/types/transport/http-dispatcher.d.ts +26 -1
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/url-helpers.d.ts +88 -0
- package/package.json +6 -12
- package/dist/cjs/authentication.js +0 -317
- package/dist/cjs/clients/activity-client.js +0 -63
- package/dist/cjs/clients/app-client.js +0 -345
- package/dist/cjs/clients/backup-client.js +0 -47
- package/dist/cjs/clients/base-client.js +0 -31
- package/dist/cjs/clients/billing-client.js +0 -152
- package/dist/cjs/clients/comment-client.js +0 -91
- package/dist/cjs/clients/email-client.js +0 -43
- package/dist/cjs/clients/folder-client.js +0 -79
- package/dist/cjs/clients/id-mapping-client.js +0 -39
- package/dist/cjs/clients/insights-client.js +0 -87
- package/dist/cjs/clients/label-client.js +0 -126
- package/dist/cjs/clients/productivity-client.js +0 -27
- package/dist/cjs/clients/project-client.js +0 -235
- package/dist/cjs/clients/reminder-client.js +0 -198
- package/dist/cjs/clients/section-client.js +0 -117
- package/dist/cjs/clients/task-client.js +0 -254
- package/dist/cjs/clients/template-client.js +0 -88
- package/dist/cjs/clients/ui-extension-client.js +0 -107
- package/dist/cjs/clients/upload-client.js +0 -155
- package/dist/cjs/clients/view-options-client.js +0 -25
- package/dist/cjs/clients/workspace-client.js +0 -366
- package/dist/cjs/consts/endpoints.js +0 -224
- package/dist/cjs/index.js +0 -23
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/test-utils/asserts.js +0 -11
- package/dist/cjs/test-utils/msw-setup.js +0 -97
- package/dist/cjs/test-utils/obsidian-fetch-adapter.js +0 -54
- package/dist/cjs/test-utils/test-defaults.js +0 -371
- package/dist/cjs/test-utils/transport-seam.js +0 -17
- package/dist/cjs/test-utils/webhook-fixtures.js +0 -32
- package/dist/cjs/todoist-api.js +0 -1711
- package/dist/cjs/transport/fetch-with-retry.js +0 -219
- package/dist/cjs/transport/http-client.js +0 -134
- package/dist/cjs/transport/http-dispatcher.js +0 -173
- package/dist/cjs/transport/sync-request.js +0 -83
- package/dist/cjs/types/activity/index.js +0 -18
- package/dist/cjs/types/activity/requests.js +0 -2
- package/dist/cjs/types/activity/types.js +0 -28
- package/dist/cjs/types/apps/index.js +0 -18
- package/dist/cjs/types/apps/requests.js +0 -2
- package/dist/cjs/types/apps/types.js +0 -254
- package/dist/cjs/types/backups/index.js +0 -18
- package/dist/cjs/types/backups/requests.js +0 -2
- package/dist/cjs/types/backups/types.js +0 -8
- package/dist/cjs/types/billing/index.js +0 -18
- package/dist/cjs/types/billing/requests.js +0 -2
- package/dist/cjs/types/billing/types.js +0 -92
- package/dist/cjs/types/comments/index.js +0 -18
- package/dist/cjs/types/comments/requests.js +0 -2
- package/dist/cjs/types/comments/types.js +0 -60
- package/dist/cjs/types/common.js +0 -10
- package/dist/cjs/types/emails/index.js +0 -17
- package/dist/cjs/types/emails/requests.js +0 -5
- package/dist/cjs/types/errors.js +0 -29
- package/dist/cjs/types/folders/index.js +0 -17
- package/dist/cjs/types/folders/requests.js +0 -2
- package/dist/cjs/types/http.js +0 -24
- package/dist/cjs/types/id-mappings/index.js +0 -18
- package/dist/cjs/types/id-mappings/requests.js +0 -20
- package/dist/cjs/types/id-mappings/types.js +0 -12
- package/dist/cjs/types/index.js +0 -40
- package/dist/cjs/types/insights/index.js +0 -18
- package/dist/cjs/types/insights/requests.js +0 -2
- package/dist/cjs/types/insights/types.js +0 -80
- package/dist/cjs/types/labels/index.js +0 -18
- package/dist/cjs/types/labels/requests.js +0 -2
- package/dist/cjs/types/labels/types.js +0 -11
- package/dist/cjs/types/productivity/index.js +0 -17
- package/dist/cjs/types/productivity/types.js +0 -68
- package/dist/cjs/types/projects/index.js +0 -18
- package/dist/cjs/types/projects/requests.js +0 -2
- package/dist/cjs/types/projects/types.js +0 -66
- package/dist/cjs/types/reminders/index.js +0 -17
- package/dist/cjs/types/reminders/requests.js +0 -95
- package/dist/cjs/types/sections/index.js +0 -18
- package/dist/cjs/types/sections/requests.js +0 -2
- package/dist/cjs/types/sections/types.js +0 -25
- package/dist/cjs/types/sync/commands/calendars.js +0 -2
- package/dist/cjs/types/sync/commands/filters.js +0 -2
- package/dist/cjs/types/sync/commands/folders.js +0 -2
- package/dist/cjs/types/sync/commands/index.js +0 -34
- package/dist/cjs/types/sync/commands/labels.js +0 -5
- package/dist/cjs/types/sync/commands/notes.js +0 -2
- package/dist/cjs/types/sync/commands/notifications.js +0 -2
- package/dist/cjs/types/sync/commands/others.js +0 -2
- package/dist/cjs/types/sync/commands/project-view-options.js +0 -2
- package/dist/cjs/types/sync/commands/projects.js +0 -2
- package/dist/cjs/types/sync/commands/reminders.js +0 -2
- package/dist/cjs/types/sync/commands/sections.js +0 -2
- package/dist/cjs/types/sync/commands/shared.js +0 -20
- package/dist/cjs/types/sync/commands/sharing.js +0 -2
- package/dist/cjs/types/sync/commands/tasks.js +0 -2
- package/dist/cjs/types/sync/commands/view-options.js +0 -2
- package/dist/cjs/types/sync/commands/workspace-filters.js +0 -2
- package/dist/cjs/types/sync/commands/workspaces.js +0 -2
- package/dist/cjs/types/sync/index.js +0 -22
- package/dist/cjs/types/sync/request.js +0 -2
- package/dist/cjs/types/sync/resource-types.js +0 -39
- package/dist/cjs/types/sync/resources/calendars.js +0 -27
- package/dist/cjs/types/sync/resources/collaborators.js +0 -21
- package/dist/cjs/types/sync/resources/completed-info.js +0 -24
- package/dist/cjs/types/sync/resources/filters.js +0 -14
- package/dist/cjs/types/sync/resources/folders.js +0 -12
- package/dist/cjs/types/sync/resources/index.js +0 -32
- package/dist/cjs/types/sync/resources/live-notifications.js +0 -38
- package/dist/cjs/types/sync/resources/notes.js +0 -21
- package/dist/cjs/types/sync/resources/reminders.js +0 -50
- package/dist/cjs/types/sync/resources/suggestions.js +0 -36
- package/dist/cjs/types/sync/resources/tooltips.js +0 -8
- package/dist/cjs/types/sync/resources/user-plan-limits.js +0 -20
- package/dist/cjs/types/sync/resources/user-settings.js +0 -40
- package/dist/cjs/types/sync/resources/user.js +0 -110
- package/dist/cjs/types/sync/resources/view-options.js +0 -86
- package/dist/cjs/types/sync/resources/workspace-filters.js +0 -19
- package/dist/cjs/types/sync/resources/workspaces.js +0 -72
- package/dist/cjs/types/sync/response.js +0 -54
- package/dist/cjs/types/sync/user-preferences.js +0 -71
- package/dist/cjs/types/tasks/index.js +0 -18
- package/dist/cjs/types/tasks/requests.js +0 -2
- package/dist/cjs/types/tasks/types.js +0 -59
- package/dist/cjs/types/templates/index.js +0 -17
- package/dist/cjs/types/templates/requests.js +0 -2
- package/dist/cjs/types/ui-extensions/index.js +0 -18
- package/dist/cjs/types/ui-extensions/requests.js +0 -2
- package/dist/cjs/types/ui-extensions/types.js +0 -77
- package/dist/cjs/types/uploads/index.js +0 -17
- package/dist/cjs/types/uploads/requests.js +0 -2
- package/dist/cjs/types/users/index.js +0 -17
- package/dist/cjs/types/users/types.js +0 -51
- package/dist/cjs/types/webhooks/comments.js +0 -96
- package/dist/cjs/types/webhooks/envelope.js +0 -26
- package/dist/cjs/types/webhooks/filters.js +0 -30
- package/dist/cjs/types/webhooks/index.js +0 -25
- package/dist/cjs/types/webhooks/labels.js +0 -54
- package/dist/cjs/types/webhooks/projects.js +0 -36
- package/dist/cjs/types/webhooks/reminders.js +0 -35
- package/dist/cjs/types/webhooks/sections.js +0 -53
- package/dist/cjs/types/webhooks/tasks.js +0 -68
- package/dist/cjs/types/webhooks/types.js +0 -55
- package/dist/cjs/types/workspaces/index.js +0 -18
- package/dist/cjs/types/workspaces/requests.js +0 -2
- package/dist/cjs/types/workspaces/types.js +0 -154
- package/dist/cjs/utils/activity-helpers.js +0 -58
- package/dist/cjs/utils/case-conversion.js +0 -69
- package/dist/cjs/utils/colors.js +0 -143
- package/dist/cjs/utils/file-response.js +0 -32
- package/dist/cjs/utils/headers.js +0 -16
- package/dist/cjs/utils/index.js +0 -31
- package/dist/cjs/utils/multipart-upload.js +0 -179
- package/dist/cjs/utils/processing-helpers.js +0 -18
- package/dist/cjs/utils/project-helpers.js +0 -20
- package/dist/cjs/utils/request-helpers.js +0 -21
- package/dist/cjs/utils/sanitization.js +0 -116
- package/dist/cjs/utils/sync-helpers.js +0 -22
- package/dist/cjs/utils/task-sorting.js +0 -281
- package/dist/cjs/utils/uncompletable-helpers.js +0 -60
- package/dist/cjs/utils/url-helpers.js +0 -74
- package/dist/cjs/utils/validators.js +0 -108
- package/dist/cjs/utils/view-options.js +0 -19
- package/dist/cjs/utils/webhook-parser.js +0 -60
package/dist/cjs/utils/colors.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultColor = exports.colors = exports.taupe = exports.grey = exports.charcoal = exports.salmon = exports.magenta = exports.lavender = exports.violet = exports.grape = exports.blue = exports.lightBlue = exports.skyBlue = exports.teal = exports.mintGreen = exports.green = exports.limeGreen = exports.oliveGreen = exports.yellow = exports.orange = exports.red = exports.berryRed = void 0;
|
|
4
|
-
exports.getColorByKey = getColorByKey;
|
|
5
|
-
exports.berryRed = {
|
|
6
|
-
key: 'berry_red',
|
|
7
|
-
displayName: 'Berry Red',
|
|
8
|
-
hexValue: '#b8255f',
|
|
9
|
-
};
|
|
10
|
-
exports.red = {
|
|
11
|
-
key: 'red',
|
|
12
|
-
displayName: 'Red',
|
|
13
|
-
hexValue: '#db4035',
|
|
14
|
-
};
|
|
15
|
-
exports.orange = {
|
|
16
|
-
key: 'orange',
|
|
17
|
-
displayName: 'Orange',
|
|
18
|
-
hexValue: '#ff9933',
|
|
19
|
-
};
|
|
20
|
-
exports.yellow = {
|
|
21
|
-
key: 'yellow',
|
|
22
|
-
displayName: 'Yellow',
|
|
23
|
-
hexValue: '#fad000',
|
|
24
|
-
};
|
|
25
|
-
exports.oliveGreen = {
|
|
26
|
-
key: 'olive_green',
|
|
27
|
-
displayName: 'Olive Green',
|
|
28
|
-
hexValue: '#afb83b',
|
|
29
|
-
};
|
|
30
|
-
exports.limeGreen = {
|
|
31
|
-
key: 'lime_green',
|
|
32
|
-
displayName: 'Lime Green',
|
|
33
|
-
hexValue: '#7ecc49',
|
|
34
|
-
};
|
|
35
|
-
exports.green = {
|
|
36
|
-
key: 'green',
|
|
37
|
-
displayName: 'Green',
|
|
38
|
-
hexValue: '#299438',
|
|
39
|
-
};
|
|
40
|
-
exports.mintGreen = {
|
|
41
|
-
key: 'mint_green',
|
|
42
|
-
displayName: 'Mint Green',
|
|
43
|
-
hexValue: '#6accbc',
|
|
44
|
-
};
|
|
45
|
-
exports.teal = {
|
|
46
|
-
key: 'teal',
|
|
47
|
-
displayName: 'Teal',
|
|
48
|
-
hexValue: '#158fad',
|
|
49
|
-
};
|
|
50
|
-
exports.skyBlue = {
|
|
51
|
-
key: 'sky_blue',
|
|
52
|
-
displayName: 'Sky Blue',
|
|
53
|
-
hexValue: '#14aaf5',
|
|
54
|
-
};
|
|
55
|
-
exports.lightBlue = {
|
|
56
|
-
key: 'light_blue',
|
|
57
|
-
displayName: 'Light Blue',
|
|
58
|
-
hexValue: '#96c3eb',
|
|
59
|
-
};
|
|
60
|
-
exports.blue = {
|
|
61
|
-
key: 'blue',
|
|
62
|
-
displayName: 'Blue',
|
|
63
|
-
hexValue: '#4073ff',
|
|
64
|
-
};
|
|
65
|
-
exports.grape = {
|
|
66
|
-
key: 'grape',
|
|
67
|
-
displayName: 'Grape',
|
|
68
|
-
hexValue: '#884dff',
|
|
69
|
-
};
|
|
70
|
-
exports.violet = {
|
|
71
|
-
key: 'violet',
|
|
72
|
-
displayName: 'Violet',
|
|
73
|
-
hexValue: '#af38eb',
|
|
74
|
-
};
|
|
75
|
-
exports.lavender = {
|
|
76
|
-
key: 'lavender',
|
|
77
|
-
displayName: 'Lavender',
|
|
78
|
-
hexValue: '#eb96eb',
|
|
79
|
-
};
|
|
80
|
-
exports.magenta = {
|
|
81
|
-
key: 'magenta',
|
|
82
|
-
displayName: 'Magenta',
|
|
83
|
-
hexValue: '#e05194',
|
|
84
|
-
};
|
|
85
|
-
exports.salmon = {
|
|
86
|
-
key: 'salmon',
|
|
87
|
-
displayName: 'Salmon',
|
|
88
|
-
hexValue: '#ff8d85',
|
|
89
|
-
};
|
|
90
|
-
exports.charcoal = {
|
|
91
|
-
key: 'charcoal',
|
|
92
|
-
displayName: 'Charcoal',
|
|
93
|
-
hexValue: '#808080',
|
|
94
|
-
};
|
|
95
|
-
exports.grey = {
|
|
96
|
-
key: 'grey',
|
|
97
|
-
displayName: 'Grey',
|
|
98
|
-
hexValue: '#b8b8b8',
|
|
99
|
-
};
|
|
100
|
-
exports.taupe = {
|
|
101
|
-
key: 'taupe',
|
|
102
|
-
displayName: 'Taupe',
|
|
103
|
-
hexValue: '#ccac93',
|
|
104
|
-
};
|
|
105
|
-
exports.colors = [
|
|
106
|
-
exports.berryRed,
|
|
107
|
-
exports.red,
|
|
108
|
-
exports.orange,
|
|
109
|
-
exports.yellow,
|
|
110
|
-
exports.oliveGreen,
|
|
111
|
-
exports.limeGreen,
|
|
112
|
-
exports.green,
|
|
113
|
-
exports.mintGreen,
|
|
114
|
-
exports.teal,
|
|
115
|
-
exports.skyBlue,
|
|
116
|
-
exports.lightBlue,
|
|
117
|
-
exports.blue,
|
|
118
|
-
exports.grape,
|
|
119
|
-
exports.violet,
|
|
120
|
-
exports.lavender,
|
|
121
|
-
exports.magenta,
|
|
122
|
-
exports.salmon,
|
|
123
|
-
exports.charcoal,
|
|
124
|
-
exports.grey,
|
|
125
|
-
exports.taupe,
|
|
126
|
-
];
|
|
127
|
-
exports.defaultColor = exports.charcoal;
|
|
128
|
-
/**
|
|
129
|
-
* Retrieves a {@link Color} object by its key identifier.
|
|
130
|
-
*
|
|
131
|
-
* @param colorKey - The unique key identifier of the color to find (e.g., 'berry_red', 'sky_blue')
|
|
132
|
-
* @returns The matching Color object if found, otherwise returns the default color (charcoal)
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ```typescript
|
|
136
|
-
* const color = getColorByKey('berry_red');
|
|
137
|
-
* console.log(color.hexValue); // '#b8255f'
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
function getColorByKey(colorKey) {
|
|
141
|
-
const color = exports.colors.find((color) => color.key === colorKey);
|
|
142
|
-
return color !== null && color !== void 0 ? color : exports.defaultColor;
|
|
143
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapAsFileResponse = wrapAsFileResponse;
|
|
4
|
-
const headers_1 = require("./headers");
|
|
5
|
-
/**
|
|
6
|
-
* Wraps either a native `Response` or a `CustomFetchResponse` into the SDK's
|
|
7
|
-
* `FileResponse` shape (binary endpoints: `viewAttachment`, `downloadBackup`).
|
|
8
|
-
*
|
|
9
|
-
* `arrayBuffer()` is resolved lazily. A customFetch implementation that omits
|
|
10
|
-
* `arrayBuffer()` is still valid for callers that only read `text()`/`json()`;
|
|
11
|
-
* the descriptive error is thrown only if the caller actually requests binary
|
|
12
|
-
* bytes. This avoids the lossy `text()` → `TextEncoder` round-trip that
|
|
13
|
-
* corrupts non-UTF-8 bytes (every `0x80`-`0xFF` byte not part of a valid UTF-8
|
|
14
|
-
* sequence is replaced with `U+FFFD`).
|
|
15
|
-
*/
|
|
16
|
-
function wrapAsFileResponse(response, context) {
|
|
17
|
-
const headers = response.headers instanceof Headers ? (0, headers_1.headersToRecord)(response.headers) : response.headers;
|
|
18
|
-
return {
|
|
19
|
-
ok: response.ok,
|
|
20
|
-
status: response.status,
|
|
21
|
-
statusText: response.statusText,
|
|
22
|
-
headers,
|
|
23
|
-
text: () => response.text(),
|
|
24
|
-
json: () => response.json(),
|
|
25
|
-
arrayBuffer: () => {
|
|
26
|
-
if (typeof response.arrayBuffer !== 'function') {
|
|
27
|
-
throw new Error(`customFetch response must implement arrayBuffer() for ${context} (binary endpoint); reading the body via text() corrupts non-UTF-8 bytes`);
|
|
28
|
-
}
|
|
29
|
-
return response.arrayBuffer();
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.headersToRecord = headersToRecord;
|
|
4
|
-
/**
|
|
5
|
-
* Converts a native Fetch `Headers` object into a plain `Record<string, string>`.
|
|
6
|
-
* Used when wrapping a native `fetch` response into the SDK's `FileResponse`
|
|
7
|
-
* shape (which expects headers as a plain record for symmetry with
|
|
8
|
-
* `CustomFetchResponse`).
|
|
9
|
-
*/
|
|
10
|
-
function headersToRecord(headers) {
|
|
11
|
-
const result = {};
|
|
12
|
-
headers.forEach((value, key) => {
|
|
13
|
-
result[key] = value;
|
|
14
|
-
});
|
|
15
|
-
return result;
|
|
16
|
-
}
|
package/dist/cjs/utils/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
exports.verifyWebhookSignature = exports.parseWebhookPayload = exports.createCommand = exports.getSectionUrl = exports.getProjectUrl = exports.getTaskUrl = void 0;
|
|
18
|
-
__exportStar(require("./colors"), exports);
|
|
19
|
-
__exportStar(require("./sanitization"), exports);
|
|
20
|
-
var url_helpers_1 = require("./url-helpers");
|
|
21
|
-
Object.defineProperty(exports, "getTaskUrl", { enumerable: true, get: function () { return url_helpers_1.getTaskUrl; } });
|
|
22
|
-
Object.defineProperty(exports, "getProjectUrl", { enumerable: true, get: function () { return url_helpers_1.getProjectUrl; } });
|
|
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; } });
|
|
26
|
-
__exportStar(require("./project-helpers"), exports);
|
|
27
|
-
__exportStar(require("./task-sorting"), exports);
|
|
28
|
-
__exportStar(require("./view-options"), exports);
|
|
29
|
-
var webhook_parser_1 = require("./webhook-parser");
|
|
30
|
-
Object.defineProperty(exports, "parseWebhookPayload", { enumerable: true, get: function () { return webhook_parser_1.parseWebhookPayload; } });
|
|
31
|
-
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return webhook_parser_1.verifyWebhookSignature; } });
|
|
@@ -1,179 +0,0 @@
|
|
|
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 __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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.uploadMultipartFile = uploadMultipartFile;
|
|
37
|
-
const fetch_with_retry_1 = require("../transport/fetch-with-retry");
|
|
38
|
-
const case_conversion_1 = require("./case-conversion");
|
|
39
|
-
/**
|
|
40
|
-
* Helper function to determine content-type from filename extension.
|
|
41
|
-
* @param fileName - The filename to analyze
|
|
42
|
-
* @returns The appropriate MIME type
|
|
43
|
-
*/
|
|
44
|
-
function getContentTypeFromFileName(fileName) {
|
|
45
|
-
const extension = fileName.toLowerCase().split('.').pop();
|
|
46
|
-
switch (extension) {
|
|
47
|
-
case 'png':
|
|
48
|
-
return 'image/png';
|
|
49
|
-
case 'jpg':
|
|
50
|
-
case 'jpeg':
|
|
51
|
-
return 'image/jpeg';
|
|
52
|
-
case 'gif':
|
|
53
|
-
return 'image/gif';
|
|
54
|
-
case 'webp':
|
|
55
|
-
return 'image/webp';
|
|
56
|
-
case 'svg':
|
|
57
|
-
return 'image/svg+xml';
|
|
58
|
-
default:
|
|
59
|
-
return 'application/octet-stream';
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Uploads a file using multipart/form-data.
|
|
64
|
-
*
|
|
65
|
-
* This is a shared utility for uploading files to Todoist endpoints that require
|
|
66
|
-
* multipart/form-data content type (e.g., file uploads, workspace logo uploads).
|
|
67
|
-
*
|
|
68
|
-
* Supports both browser (Blob/File) and Node.js (Buffer/ReadableStream/path) environments.
|
|
69
|
-
*
|
|
70
|
-
* @param baseUrl - The base API URL (e.g., https://api.todoist.com/api/v1/)
|
|
71
|
-
* @param authToken - The authentication token
|
|
72
|
-
* @param endpoint - The relative endpoint path (e.g., 'uploads', 'workspaces/logo')
|
|
73
|
-
* @param file - The file content (Blob/File for browser, or Buffer/ReadableStream/path for Node)
|
|
74
|
-
* @param fileName - Optional file name (required for Buffer/Stream, optional for paths and File objects)
|
|
75
|
-
* @param additionalFields - Additional form fields to include (e.g., project_id, workspace_id)
|
|
76
|
-
* @param requestId - Optional request ID for idempotency
|
|
77
|
-
* @returns The response data from the server
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* // Upload from a file path
|
|
82
|
-
* const result = await uploadMultipartFile(
|
|
83
|
-
* 'https://api.todoist.com/api/v1/',
|
|
84
|
-
* 'my-token',
|
|
85
|
-
* 'uploads',
|
|
86
|
-
* '/path/to/file.pdf',
|
|
87
|
-
* undefined,
|
|
88
|
-
* { project_id: '12345' }
|
|
89
|
-
* )
|
|
90
|
-
*
|
|
91
|
-
* // Upload from a Buffer
|
|
92
|
-
* const buffer = Buffer.from('file content')
|
|
93
|
-
* const result = await uploadMultipartFile(
|
|
94
|
-
* 'https://api.todoist.com/api/v1/',
|
|
95
|
-
* 'my-token',
|
|
96
|
-
* 'uploads',
|
|
97
|
-
* buffer,
|
|
98
|
-
* 'document.pdf',
|
|
99
|
-
* { project_id: '12345' }
|
|
100
|
-
* )
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
async function uploadMultipartFile(args) {
|
|
104
|
-
const { baseUrl, authToken, endpoint, file, fileName, additionalFields, requestId, customFetch, } = args;
|
|
105
|
-
// Build the full URL
|
|
106
|
-
const url = `${baseUrl}${endpoint}`;
|
|
107
|
-
let body;
|
|
108
|
-
const headers = {
|
|
109
|
-
Authorization: `Bearer ${authToken}`,
|
|
110
|
-
};
|
|
111
|
-
if (requestId) {
|
|
112
|
-
headers['X-Request-Id'] = requestId;
|
|
113
|
-
}
|
|
114
|
-
if (file instanceof Blob) {
|
|
115
|
-
// Browser path: use native FormData
|
|
116
|
-
const form = new globalThis.FormData();
|
|
117
|
-
const resolvedFileName = fileName || (file instanceof File ? file.name : undefined) || 'upload';
|
|
118
|
-
form.append('file', file, resolvedFileName);
|
|
119
|
-
for (const [key, value] of Object.entries(additionalFields)) {
|
|
120
|
-
if (value !== undefined && value !== null) {
|
|
121
|
-
form.append(key, value.toString());
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// Don't set Content-Type — let fetch set it with the correct multipart boundary
|
|
125
|
-
body = form;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
// Node path: dynamically import Node-only modules
|
|
129
|
-
const [FormDataModule, fsModule, pathModule] = await Promise.all([
|
|
130
|
-
Promise.resolve().then(() => __importStar(require('form-data'))),
|
|
131
|
-
Promise.resolve().then(() => __importStar(require('fs'))),
|
|
132
|
-
Promise.resolve().then(() => __importStar(require('path'))),
|
|
133
|
-
]);
|
|
134
|
-
const FormData = FormDataModule.default;
|
|
135
|
-
const form = new FormData();
|
|
136
|
-
if (typeof file === 'string') {
|
|
137
|
-
// File path - create read stream
|
|
138
|
-
const resolvedFileName = fileName || pathModule.basename(file);
|
|
139
|
-
form.append('file', fsModule.createReadStream(file), resolvedFileName);
|
|
140
|
-
}
|
|
141
|
-
else if (Buffer.isBuffer(file)) {
|
|
142
|
-
// Buffer - require fileName
|
|
143
|
-
if (!fileName) {
|
|
144
|
-
throw new Error('fileName is required when uploading from a Buffer');
|
|
145
|
-
}
|
|
146
|
-
const contentType = getContentTypeFromFileName(fileName);
|
|
147
|
-
form.append('file', file, {
|
|
148
|
-
filename: fileName,
|
|
149
|
-
contentType: contentType,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
// Stream - require fileName
|
|
154
|
-
if (!fileName) {
|
|
155
|
-
throw new Error('fileName is required when uploading from a stream');
|
|
156
|
-
}
|
|
157
|
-
form.append('file', file, fileName);
|
|
158
|
-
}
|
|
159
|
-
for (const [key, value] of Object.entries(additionalFields)) {
|
|
160
|
-
if (value !== undefined && value !== null) {
|
|
161
|
-
form.append(key, value.toString());
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
Object.assign(headers, form.getHeaders());
|
|
165
|
-
body = form;
|
|
166
|
-
}
|
|
167
|
-
// Make the request using fetch
|
|
168
|
-
const response = await (0, fetch_with_retry_1.fetchWithRetry)({
|
|
169
|
-
url,
|
|
170
|
-
options: {
|
|
171
|
-
method: 'POST',
|
|
172
|
-
body,
|
|
173
|
-
headers,
|
|
174
|
-
timeout: 30000, // 30 second timeout for file uploads
|
|
175
|
-
},
|
|
176
|
-
customFetch,
|
|
177
|
-
});
|
|
178
|
-
return (0, case_conversion_1.camelCaseKeys)(response.data);
|
|
179
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.customCamelCase = customCamelCase;
|
|
7
|
-
const camelcase_1 = __importDefault(require("camelcase"));
|
|
8
|
-
const emoji_regex_1 = __importDefault(require("emoji-regex"));
|
|
9
|
-
function isEmojiKey(key) {
|
|
10
|
-
const regex = (0, emoji_regex_1.default)();
|
|
11
|
-
return regex.test(key);
|
|
12
|
-
}
|
|
13
|
-
function customCamelCase(input) {
|
|
14
|
-
// If the value is a solitary emoji string, return the key as-is
|
|
15
|
-
if (isEmojiKey(input))
|
|
16
|
-
return input;
|
|
17
|
-
return (0, camelcase_1.default)(input);
|
|
18
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isWorkspaceProject = isWorkspaceProject;
|
|
4
|
-
exports.isPersonalProject = isPersonalProject;
|
|
5
|
-
/**
|
|
6
|
-
* Type guard to check if a project is a workspace project.
|
|
7
|
-
* @param project The project to check
|
|
8
|
-
* @returns True if the project is a workspace project
|
|
9
|
-
*/
|
|
10
|
-
function isWorkspaceProject(project) {
|
|
11
|
-
return 'workspaceId' in project;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Type guard to check if a project is a personal project.
|
|
15
|
-
* @param project The project to check
|
|
16
|
-
* @returns True if the project is a personal project
|
|
17
|
-
*/
|
|
18
|
-
function isPersonalProject(project) {
|
|
19
|
-
return !isWorkspaceProject(project);
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generatePath = generatePath;
|
|
4
|
-
exports.spreadIfDefined = spreadIfDefined;
|
|
5
|
-
/**
|
|
6
|
-
* Joins path segments using `/` separator.
|
|
7
|
-
* @param segments A list of **valid** path segments.
|
|
8
|
-
* @returns A joined path.
|
|
9
|
-
*/
|
|
10
|
-
function generatePath(...segments) {
|
|
11
|
-
return segments.join('/');
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Returns `fn(value)` spread into an object if `value` is defined, otherwise an empty object.
|
|
15
|
-
*
|
|
16
|
-
* Used to conditionally include a property on a payload object without
|
|
17
|
-
* resorting to mutation or ternary-built object literals.
|
|
18
|
-
*/
|
|
19
|
-
function spreadIfDefined(value, fn) {
|
|
20
|
-
return value !== undefined ? fn(value) : {};
|
|
21
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSanitizedContent = getSanitizedContent;
|
|
4
|
-
exports.getSanitizedTasks = getSanitizedTasks;
|
|
5
|
-
const BOLD_FORMAT = /(^|[\s!?,;>:]+)(?:\*\*|__|!!)(.+?)(\*\*|__|!!)(?=$|[\s!?,;><:]+)/gi;
|
|
6
|
-
const ITALIC_FORMAT = /(^|[\s!?,;>:]+)(?:\*|_|!)(.+?)(\*|_|!)(?=$|[\s!?,;><:]+)/gi;
|
|
7
|
-
const BOLD_ITALIC_FORMAT = /(^|[\s!?,;>:]+)(?:\*\*\*|___|!!!)(.+?)(\*\*\*|___|!!!)(?=$|[\s!?,;><:]+)/gi;
|
|
8
|
-
const CODE_BLOCK_FORMAT = /```([\s\S]*?)```/gi;
|
|
9
|
-
const CODE_INLINE_FORMAT = /`([^`]+)`/gi;
|
|
10
|
-
const TODOIST_LINK = /((?:(?:onenote:)?[\w-]+):\/\/[^\s]+)\s+[[(]([^)]+)[\])]/gi;
|
|
11
|
-
const MARKDOWN_LINK = /\[(.+?)\]\((.+?)\)/gi;
|
|
12
|
-
const GMAIL_LINK = /\[\[gmail=(.+?),\s*(.+?)\]\]/gi;
|
|
13
|
-
const OUTLOOK_LINK = /\[\[outlook=(.+?),\s*(.+?)\]\]/gi;
|
|
14
|
-
const THUNDERBIRD_LINK = /\[\[thunderbird\n(.+)\n(.+)\n\s*\]\]/gi;
|
|
15
|
-
const FAKE_SECTION_PREFIX = '* ';
|
|
16
|
-
const FAKE_SECTION_SUFFIX = ':';
|
|
17
|
-
function removeStyleFormatting(input) {
|
|
18
|
-
if (!input.includes('!') && !input.includes('*') && !input.includes('_')) {
|
|
19
|
-
return input;
|
|
20
|
-
}
|
|
21
|
-
function removeMarkdown(_match, prefix, text) {
|
|
22
|
-
return `${prefix}${text}`;
|
|
23
|
-
}
|
|
24
|
-
input = input.replace(BOLD_ITALIC_FORMAT, removeMarkdown);
|
|
25
|
-
input = input.replace(BOLD_FORMAT, removeMarkdown);
|
|
26
|
-
input = input.replace(ITALIC_FORMAT, removeMarkdown);
|
|
27
|
-
return input;
|
|
28
|
-
}
|
|
29
|
-
function removeCodeFormatting(input) {
|
|
30
|
-
function removeMarkdown(_match, text) {
|
|
31
|
-
return text;
|
|
32
|
-
}
|
|
33
|
-
input = input.replace(CODE_BLOCK_FORMAT, removeMarkdown);
|
|
34
|
-
input = input.replace(CODE_INLINE_FORMAT, removeMarkdown);
|
|
35
|
-
return input;
|
|
36
|
-
}
|
|
37
|
-
function removeFakeSectionFormatting(input) {
|
|
38
|
-
if (input.startsWith(FAKE_SECTION_PREFIX)) {
|
|
39
|
-
input = input.slice(FAKE_SECTION_PREFIX.length);
|
|
40
|
-
}
|
|
41
|
-
if (input.endsWith(FAKE_SECTION_SUFFIX)) {
|
|
42
|
-
input = input.slice(0, input.length - FAKE_SECTION_SUFFIX.length);
|
|
43
|
-
}
|
|
44
|
-
return input;
|
|
45
|
-
}
|
|
46
|
-
function removeMarkdownLinks(input) {
|
|
47
|
-
if (!input.includes('[') || !input.includes(']')) {
|
|
48
|
-
return input;
|
|
49
|
-
}
|
|
50
|
-
function removeMarkdown(_match, text) {
|
|
51
|
-
return text;
|
|
52
|
-
}
|
|
53
|
-
return input.replace(MARKDOWN_LINK, removeMarkdown);
|
|
54
|
-
}
|
|
55
|
-
function removeTodoistLinks(input) {
|
|
56
|
-
if (!input.includes('(') || !input.includes(')')) {
|
|
57
|
-
return input;
|
|
58
|
-
}
|
|
59
|
-
function removeMarkdown(_match, _url, text) {
|
|
60
|
-
return text;
|
|
61
|
-
}
|
|
62
|
-
return input.replace(TODOIST_LINK, removeMarkdown);
|
|
63
|
-
}
|
|
64
|
-
function removeAppLinks(input) {
|
|
65
|
-
if (input.includes('gmail')) {
|
|
66
|
-
input = input.replace(GMAIL_LINK, (_match, _id, text) => text);
|
|
67
|
-
}
|
|
68
|
-
if (input.includes('outlook')) {
|
|
69
|
-
input = input.replace(OUTLOOK_LINK, (_match, _id, text) => text);
|
|
70
|
-
}
|
|
71
|
-
if (input.includes('thunderbird')) {
|
|
72
|
-
input = input.replace(THUNDERBIRD_LINK, (_match, text) => text);
|
|
73
|
-
}
|
|
74
|
-
return input;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Sanitizes a string by removing Todoist's formatting syntax (e.g. bold, italic, code blocks, links).
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* // Removes bold/italic formatting
|
|
81
|
-
* getSanitizedContent('Some **bold** and *italic*') // 'Some bold and italic'
|
|
82
|
-
*
|
|
83
|
-
* // Removes markdown links
|
|
84
|
-
* getSanitizedContent('A [markdown](http://url.com) link') // 'A markdown link'
|
|
85
|
-
*
|
|
86
|
-
* // Removes app-specific links
|
|
87
|
-
* getSanitizedContent('A [[gmail=id, link from gmail]]') // 'A link from gmail'
|
|
88
|
-
*
|
|
89
|
-
* @param input - The string to sanitize
|
|
90
|
-
* @returns The sanitized string with all formatting removed
|
|
91
|
-
*/
|
|
92
|
-
function getSanitizedContent(input) {
|
|
93
|
-
input = removeStyleFormatting(input);
|
|
94
|
-
input = removeCodeFormatting(input);
|
|
95
|
-
input = removeFakeSectionFormatting(input);
|
|
96
|
-
input = removeMarkdownLinks(input);
|
|
97
|
-
input = removeTodoistLinks(input);
|
|
98
|
-
input = removeAppLinks(input);
|
|
99
|
-
return input;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Takes an array of tasks and returns a new array with sanitized content
|
|
103
|
-
* added as 'sanitizedContent' property to each task.
|
|
104
|
-
*
|
|
105
|
-
* @see {@link getSanitizedContent}
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* const tasks = [{ content: '**Bold** task', ... }]
|
|
109
|
-
* getSanitizedTasks(tasks) // [{ content: '**Bold** task', sanitizedContent: 'Bold task', ... }]
|
|
110
|
-
*
|
|
111
|
-
* @param tasks - Array of Task objects to sanitize
|
|
112
|
-
* @returns Array of tasks with added sanitizedContent property
|
|
113
|
-
*/
|
|
114
|
-
function getSanitizedTasks(tasks) {
|
|
115
|
-
return tasks.map((task) => (Object.assign(Object.assign({}, task), { sanitizedContent: getSanitizedContent(task.content) })));
|
|
116
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|