@doist/todoist-sdk 9.0.0 → 9.1.0-next.2
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/clients/activity-client.js +63 -0
- package/dist/cjs/clients/backup-client.js +65 -0
- package/dist/cjs/clients/base-client.js +30 -0
- package/dist/cjs/clients/comment-client.js +92 -0
- package/dist/cjs/clients/email-client.js +43 -0
- package/dist/cjs/clients/folder-client.js +80 -0
- package/dist/cjs/clients/goals-client.js +145 -0
- package/dist/cjs/clients/id-mapping-client.js +39 -0
- package/dist/cjs/clients/insights-client.js +88 -0
- package/dist/cjs/clients/label-client.js +127 -0
- package/dist/cjs/clients/productivity-client.js +27 -0
- package/dist/cjs/clients/project-client.js +232 -0
- package/dist/cjs/clients/reminder-client.js +198 -0
- package/dist/cjs/clients/section-client.js +118 -0
- package/dist/cjs/clients/task-client.js +255 -0
- package/dist/cjs/clients/template-client.js +89 -0
- package/dist/cjs/clients/upload-client.js +102 -0
- package/dist/cjs/clients/workspace-client.js +367 -0
- package/dist/cjs/consts/endpoints.js +6 -1
- package/dist/cjs/test-utils/test-defaults.js +25 -1
- package/dist/cjs/todoist-api.js +186 -1537
- package/dist/cjs/transport/sync-request.js +75 -0
- package/dist/cjs/types/goals/index.js +18 -0
- package/dist/cjs/types/goals/requests.js +2 -0
- package/dist/cjs/types/goals/types.js +56 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/sync/commands/goals.js +2 -0
- package/dist/cjs/types/sync/commands/index.js +1 -0
- package/dist/cjs/types/sync/resource-types.js +1 -0
- package/dist/cjs/types/sync/response.js +12 -10
- package/dist/cjs/utils/headers.js +16 -0
- package/dist/cjs/utils/request-helpers.js +21 -0
- package/dist/cjs/utils/validators.js +48 -46
- package/dist/esm/clients/activity-client.js +59 -0
- package/dist/esm/clients/backup-client.js +61 -0
- package/dist/esm/clients/base-client.js +26 -0
- package/dist/esm/clients/comment-client.js +88 -0
- package/dist/esm/clients/email-client.js +39 -0
- package/dist/esm/clients/folder-client.js +76 -0
- package/dist/esm/clients/goals-client.js +141 -0
- package/dist/esm/clients/id-mapping-client.js +35 -0
- package/dist/esm/clients/insights-client.js +84 -0
- package/dist/esm/clients/label-client.js +123 -0
- package/dist/esm/clients/productivity-client.js +23 -0
- package/dist/esm/clients/project-client.js +228 -0
- package/dist/esm/clients/reminder-client.js +194 -0
- package/dist/esm/clients/section-client.js +114 -0
- package/dist/esm/clients/task-client.js +251 -0
- package/dist/esm/clients/template-client.js +85 -0
- package/dist/esm/clients/upload-client.js +98 -0
- package/dist/esm/clients/workspace-client.js +363 -0
- package/dist/esm/consts/endpoints.js +5 -0
- package/dist/esm/test-utils/test-defaults.js +24 -0
- package/dist/esm/todoist-api.js +189 -1540
- package/dist/esm/transport/sync-request.js +72 -0
- package/dist/esm/types/goals/index.js +2 -0
- package/dist/esm/types/goals/requests.js +1 -0
- package/dist/esm/types/goals/types.js +53 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/sync/commands/goals.js +1 -0
- package/dist/esm/types/sync/commands/index.js +1 -0
- package/dist/esm/types/sync/resource-types.js +1 -0
- package/dist/esm/types/sync/response.js +2 -0
- package/dist/esm/utils/headers.js +13 -0
- package/dist/esm/utils/request-helpers.js +17 -0
- package/dist/esm/utils/validators.js +2 -0
- package/dist/types/clients/activity-client.d.ts +12 -0
- package/dist/types/clients/backup-client.d.ts +14 -0
- package/dist/types/clients/base-client.d.ts +21 -0
- package/dist/types/clients/comment-client.d.ts +15 -0
- package/dist/types/clients/email-client.d.ts +13 -0
- package/dist/types/clients/folder-client.d.ts +16 -0
- package/dist/types/clients/goals-client.d.ts +20 -0
- package/dist/types/clients/id-mapping-client.d.ts +13 -0
- package/dist/types/clients/insights-client.d.ts +18 -0
- package/dist/types/clients/label-client.d.ts +19 -0
- package/dist/types/clients/productivity-client.d.ts +12 -0
- package/dist/types/clients/project-client.d.ts +26 -0
- package/dist/types/clients/reminder-client.d.ts +25 -0
- package/dist/types/clients/section-client.d.ts +18 -0
- package/dist/types/clients/task-client.d.ts +25 -0
- package/dist/types/clients/template-client.d.ts +17 -0
- package/dist/types/clients/upload-client.d.ts +17 -0
- package/dist/types/clients/workspace-client.d.ts +43 -0
- package/dist/types/consts/endpoints.d.ts +5 -0
- package/dist/types/test-utils/test-defaults.d.ts +4 -1
- package/dist/types/todoist-api.d.ts +48 -17
- package/dist/types/transport/sync-request.d.ts +27 -0
- package/dist/types/types/goals/index.d.ts +2 -0
- package/dist/types/types/goals/requests.d.ts +33 -0
- package/dist/types/types/goals/types.d.ts +51 -0
- package/dist/types/types/http.d.ts +7 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/sync/commands/goals.d.ts +33 -0
- package/dist/types/types/sync/commands/index.d.ts +9 -0
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +29 -4
- package/dist/types/types/tasks/requests.d.ts +1 -0
- package/dist/types/utils/headers.d.ts +7 -0
- package/dist/types/utils/request-helpers.d.ts +13 -0
- package/dist/types/utils/validators.d.ts +55 -8
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ActivityClient = void 0;
|
|
15
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
16
|
+
const http_client_1 = require("../transport/http-client");
|
|
17
|
+
const activity_helpers_1 = require("../utils/activity-helpers");
|
|
18
|
+
const url_helpers_1 = require("../utils/url-helpers");
|
|
19
|
+
const validators_1 = require("../utils/validators");
|
|
20
|
+
const base_client_1 = require("./base-client");
|
|
21
|
+
/**
|
|
22
|
+
* Internal sub-client handling the activity-log endpoint.
|
|
23
|
+
*
|
|
24
|
+
* Instantiated by `TodoistApi`; the public `getActivityLogs` method on
|
|
25
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
26
|
+
* JSDoc.
|
|
27
|
+
*/
|
|
28
|
+
class ActivityClient extends base_client_1.BaseClient {
|
|
29
|
+
async getActivityLogs(args = {}) {
|
|
30
|
+
// Convert Date objects to YYYY-MM-DD strings
|
|
31
|
+
const dateFrom = args.dateFrom instanceof Date ? (0, url_helpers_1.formatDateToYYYYMMDD)(args.dateFrom) : args.dateFrom;
|
|
32
|
+
const dateTo = args.dateTo instanceof Date ? (0, url_helpers_1.formatDateToYYYYMMDD)(args.dateTo) : args.dateTo;
|
|
33
|
+
// Destructure out raw date, filter-type, and removed legacy fields so they don't leak into payload
|
|
34
|
+
const _a = args, { dateFrom: _dateFrom, dateTo: _dateTo, objectEventTypes, objectType: _objectType, eventType: _eventType, since: _since, until: _until } = _a, rest = __rest(_a, ["dateFrom", "dateTo", "objectEventTypes", "objectType", "eventType", "since", "until"]);
|
|
35
|
+
// Build normalized objectEventTypes for the API
|
|
36
|
+
let normalizedObjectEventTypes;
|
|
37
|
+
if (objectEventTypes !== undefined) {
|
|
38
|
+
const arr = Array.isArray(objectEventTypes) ? objectEventTypes : [objectEventTypes];
|
|
39
|
+
normalizedObjectEventTypes = arr.map(activity_helpers_1.normalizeObjectEventTypeForApi);
|
|
40
|
+
}
|
|
41
|
+
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), (normalizedObjectEventTypes !== undefined
|
|
42
|
+
? { objectEventTypes: normalizedObjectEventTypes }
|
|
43
|
+
: {}));
|
|
44
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
45
|
+
httpMethod: 'GET',
|
|
46
|
+
baseUri: this.syncApiBase,
|
|
47
|
+
relativePath: endpoints_1.ENDPOINT_REST_ACTIVITIES,
|
|
48
|
+
apiToken: this.authToken,
|
|
49
|
+
customFetch: this.customFetch,
|
|
50
|
+
payload: processedArgs,
|
|
51
|
+
});
|
|
52
|
+
// Convert legacy API object types back to modern SDK types
|
|
53
|
+
const normalizedResults = results.map((event) => {
|
|
54
|
+
const normalizedType = (0, activity_helpers_1.denormalizeObjectTypeFromApi)(event.objectType);
|
|
55
|
+
return Object.assign(Object.assign({}, event), { objectType: normalizedType || event.objectType });
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
results: (0, validators_1.validateActivityEventArray)(normalizedResults),
|
|
59
|
+
nextCursor,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.ActivityClient = ActivityClient;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackupClient = void 0;
|
|
4
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
+
const http_client_1 = require("../transport/http-client");
|
|
6
|
+
const headers_1 = require("../utils/headers");
|
|
7
|
+
const validators_1 = require("../utils/validators");
|
|
8
|
+
const base_client_1 = require("./base-client");
|
|
9
|
+
/**
|
|
10
|
+
* Internal sub-client handling backup-domain endpoints.
|
|
11
|
+
*
|
|
12
|
+
* Instantiated by `TodoistApi`; every public backup method on
|
|
13
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
14
|
+
* JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class BackupClient extends base_client_1.BaseClient {
|
|
17
|
+
async getBackups(args = {}) {
|
|
18
|
+
const response = await (0, http_client_1.request)({
|
|
19
|
+
httpMethod: 'GET',
|
|
20
|
+
baseUri: this.syncApiBase,
|
|
21
|
+
relativePath: endpoints_1.ENDPOINT_REST_BACKUPS,
|
|
22
|
+
apiToken: this.authToken,
|
|
23
|
+
customFetch: this.customFetch,
|
|
24
|
+
payload: args,
|
|
25
|
+
});
|
|
26
|
+
return (0, validators_1.validateBackupArray)(response.data);
|
|
27
|
+
}
|
|
28
|
+
async downloadBackup(args) {
|
|
29
|
+
const url = `${this.syncApiBase}${endpoints_1.ENDPOINT_REST_BACKUPS_DOWNLOAD}?file=${encodeURIComponent(args.file)}`;
|
|
30
|
+
const fetchOptions = {
|
|
31
|
+
headers: { Authorization: `Bearer ${this.authToken}` },
|
|
32
|
+
};
|
|
33
|
+
if (this.customFetch) {
|
|
34
|
+
const response = await this.customFetch(url, fetchOptions);
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
37
|
+
}
|
|
38
|
+
const text = await response.text();
|
|
39
|
+
const buffer = new TextEncoder().encode(text).buffer;
|
|
40
|
+
return {
|
|
41
|
+
ok: response.ok,
|
|
42
|
+
status: response.status,
|
|
43
|
+
statusText: response.statusText,
|
|
44
|
+
headers: response.headers,
|
|
45
|
+
text: () => Promise.resolve(text),
|
|
46
|
+
json: () => response.json(),
|
|
47
|
+
arrayBuffer: () => Promise.resolve(buffer),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const response = await fetch(url, fetchOptions);
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw new Error(`Failed to download backup: ${response.status} ${response.statusText}`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
ok: response.ok,
|
|
56
|
+
status: response.status,
|
|
57
|
+
statusText: response.statusText,
|
|
58
|
+
headers: (0, headers_1.headersToRecord)(response.headers),
|
|
59
|
+
text: () => response.text(),
|
|
60
|
+
json: () => response.json(),
|
|
61
|
+
arrayBuffer: () => response.arrayBuffer(),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.BackupClient = BackupClient;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Internal base class for every domain sub-client (tasks, projects, …).
|
|
6
|
+
*
|
|
7
|
+
* Not exported from the package — sub-clients are an implementation detail
|
|
8
|
+
* of `TodoistApi`. Holds the three pieces of HTTP identity every sub-client
|
|
9
|
+
* needs and exposes a typed accessor to feed the Sync API helper.
|
|
10
|
+
*
|
|
11
|
+
* The constructor takes a {@link SyncRequestContext} — the same record
|
|
12
|
+
* shape used by `performSyncRequest` — so there is a single type describing
|
|
13
|
+
* "the HTTP identity an SDK component needs", not two types that must stay
|
|
14
|
+
* in sync.
|
|
15
|
+
*/
|
|
16
|
+
class BaseClient {
|
|
17
|
+
constructor(context) {
|
|
18
|
+
this.authToken = context.authToken;
|
|
19
|
+
this.syncApiBase = context.syncApiBase;
|
|
20
|
+
this.customFetch = context.customFetch;
|
|
21
|
+
}
|
|
22
|
+
get syncContext() {
|
|
23
|
+
return {
|
|
24
|
+
authToken: this.authToken,
|
|
25
|
+
syncApiBase: this.syncApiBase,
|
|
26
|
+
customFetch: this.customFetch,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.BaseClient = BaseClient;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.CommentClient = void 0;
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
17
|
+
const http_client_1 = require("../transport/http-client");
|
|
18
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
19
|
+
const validators_1 = require("../utils/validators");
|
|
20
|
+
const base_client_1 = require("./base-client");
|
|
21
|
+
/**
|
|
22
|
+
* Internal sub-client handling all comment-domain endpoints.
|
|
23
|
+
*
|
|
24
|
+
* Instantiated by `TodoistApi`; every public comment method on `TodoistApi`
|
|
25
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
26
|
+
*/
|
|
27
|
+
class CommentClient extends base_client_1.BaseClient {
|
|
28
|
+
async getComments(args) {
|
|
29
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
30
|
+
httpMethod: 'GET',
|
|
31
|
+
baseUri: this.syncApiBase,
|
|
32
|
+
relativePath: endpoints_1.ENDPOINT_REST_COMMENTS,
|
|
33
|
+
apiToken: this.authToken,
|
|
34
|
+
customFetch: this.customFetch,
|
|
35
|
+
payload: args,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
results: (0, validators_1.validateCommentArray)(results),
|
|
39
|
+
nextCursor,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async getComment(id) {
|
|
43
|
+
zod_1.z.string().parse(id);
|
|
44
|
+
const response = await (0, http_client_1.request)({
|
|
45
|
+
httpMethod: 'GET',
|
|
46
|
+
baseUri: this.syncApiBase,
|
|
47
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_COMMENTS, id),
|
|
48
|
+
apiToken: this.authToken,
|
|
49
|
+
customFetch: this.customFetch,
|
|
50
|
+
});
|
|
51
|
+
return (0, validators_1.validateComment)(response.data);
|
|
52
|
+
}
|
|
53
|
+
async addComment(args, requestId) {
|
|
54
|
+
const { uidsToNotify } = args, rest = __rest(args, ["uidsToNotify"]);
|
|
55
|
+
const response = await (0, http_client_1.request)({
|
|
56
|
+
httpMethod: 'POST',
|
|
57
|
+
baseUri: this.syncApiBase,
|
|
58
|
+
relativePath: endpoints_1.ENDPOINT_REST_COMMENTS,
|
|
59
|
+
apiToken: this.authToken,
|
|
60
|
+
customFetch: this.customFetch,
|
|
61
|
+
payload: Object.assign(Object.assign({}, rest), (uidsToNotify ? { uidsToNotify: uidsToNotify.join(',') } : {})),
|
|
62
|
+
requestId: requestId,
|
|
63
|
+
});
|
|
64
|
+
return (0, validators_1.validateComment)(response.data);
|
|
65
|
+
}
|
|
66
|
+
async updateComment(id, args, requestId) {
|
|
67
|
+
zod_1.z.string().parse(id);
|
|
68
|
+
const response = await (0, http_client_1.request)({
|
|
69
|
+
httpMethod: 'POST',
|
|
70
|
+
baseUri: this.syncApiBase,
|
|
71
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_COMMENTS, id),
|
|
72
|
+
apiToken: this.authToken,
|
|
73
|
+
customFetch: this.customFetch,
|
|
74
|
+
payload: args,
|
|
75
|
+
requestId: requestId,
|
|
76
|
+
});
|
|
77
|
+
return (0, validators_1.validateComment)(response.data);
|
|
78
|
+
}
|
|
79
|
+
async deleteComment(id, requestId) {
|
|
80
|
+
zod_1.z.string().parse(id);
|
|
81
|
+
const response = await (0, http_client_1.request)({
|
|
82
|
+
httpMethod: 'DELETE',
|
|
83
|
+
baseUri: this.syncApiBase,
|
|
84
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_COMMENTS, id),
|
|
85
|
+
apiToken: this.authToken,
|
|
86
|
+
customFetch: this.customFetch,
|
|
87
|
+
requestId: requestId,
|
|
88
|
+
});
|
|
89
|
+
return (0, http_client_1.isSuccess)(response);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.CommentClient = CommentClient;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailClient = void 0;
|
|
4
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
+
const http_client_1 = require("../transport/http-client");
|
|
6
|
+
const base_client_1 = require("./base-client");
|
|
7
|
+
/**
|
|
8
|
+
* Internal sub-client handling email-forwarding endpoints.
|
|
9
|
+
*
|
|
10
|
+
* Instantiated by `TodoistApi`; every public email-forwarding method on
|
|
11
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
12
|
+
* JSDoc.
|
|
13
|
+
*/
|
|
14
|
+
class EmailClient extends base_client_1.BaseClient {
|
|
15
|
+
async getOrCreateEmailForwarding(args, requestId) {
|
|
16
|
+
const { data } = await (0, http_client_1.request)({
|
|
17
|
+
httpMethod: 'PUT',
|
|
18
|
+
baseUri: this.syncApiBase,
|
|
19
|
+
relativePath: endpoints_1.ENDPOINT_REST_EMAILS,
|
|
20
|
+
apiToken: this.authToken,
|
|
21
|
+
customFetch: this.customFetch,
|
|
22
|
+
payload: args,
|
|
23
|
+
requestId: requestId,
|
|
24
|
+
});
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
async disableEmailForwarding(args, requestId) {
|
|
28
|
+
const queryParams = new URLSearchParams({
|
|
29
|
+
obj_type: args.objType,
|
|
30
|
+
obj_id: args.objId,
|
|
31
|
+
});
|
|
32
|
+
const response = await (0, http_client_1.request)({
|
|
33
|
+
httpMethod: 'DELETE',
|
|
34
|
+
baseUri: this.syncApiBase,
|
|
35
|
+
relativePath: `${endpoints_1.ENDPOINT_REST_EMAILS}?${queryParams.toString()}`,
|
|
36
|
+
apiToken: this.authToken,
|
|
37
|
+
customFetch: this.customFetch,
|
|
38
|
+
requestId: requestId,
|
|
39
|
+
});
|
|
40
|
+
return (0, http_client_1.isSuccess)(response);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.EmailClient = EmailClient;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FolderClient = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
6
|
+
const http_client_1 = require("../transport/http-client");
|
|
7
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
8
|
+
const validators_1 = require("../utils/validators");
|
|
9
|
+
const base_client_1 = require("./base-client");
|
|
10
|
+
/**
|
|
11
|
+
* Internal sub-client handling all folder-domain endpoints.
|
|
12
|
+
*
|
|
13
|
+
* Instantiated by `TodoistApi`; every public folder method on `TodoistApi`
|
|
14
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class FolderClient extends base_client_1.BaseClient {
|
|
17
|
+
async getFolders(args) {
|
|
18
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
19
|
+
httpMethod: 'GET',
|
|
20
|
+
baseUri: this.syncApiBase,
|
|
21
|
+
relativePath: endpoints_1.ENDPOINT_REST_FOLDERS,
|
|
22
|
+
apiToken: this.authToken,
|
|
23
|
+
customFetch: this.customFetch,
|
|
24
|
+
payload: args,
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
results: (0, validators_1.validateFolderArray)(results),
|
|
28
|
+
nextCursor,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async getFolder(id) {
|
|
32
|
+
zod_1.z.string().parse(id);
|
|
33
|
+
const response = await (0, http_client_1.request)({
|
|
34
|
+
httpMethod: 'GET',
|
|
35
|
+
baseUri: this.syncApiBase,
|
|
36
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
|
|
37
|
+
apiToken: this.authToken,
|
|
38
|
+
customFetch: this.customFetch,
|
|
39
|
+
});
|
|
40
|
+
return (0, validators_1.validateFolder)(response.data);
|
|
41
|
+
}
|
|
42
|
+
async addFolder(args, requestId) {
|
|
43
|
+
const response = await (0, http_client_1.request)({
|
|
44
|
+
httpMethod: 'POST',
|
|
45
|
+
baseUri: this.syncApiBase,
|
|
46
|
+
relativePath: endpoints_1.ENDPOINT_REST_FOLDERS,
|
|
47
|
+
apiToken: this.authToken,
|
|
48
|
+
customFetch: this.customFetch,
|
|
49
|
+
payload: args,
|
|
50
|
+
requestId: requestId,
|
|
51
|
+
});
|
|
52
|
+
return (0, validators_1.validateFolder)(response.data);
|
|
53
|
+
}
|
|
54
|
+
async updateFolder(id, args, requestId) {
|
|
55
|
+
zod_1.z.string().parse(id);
|
|
56
|
+
const response = await (0, http_client_1.request)({
|
|
57
|
+
httpMethod: 'POST',
|
|
58
|
+
baseUri: this.syncApiBase,
|
|
59
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
|
|
60
|
+
apiToken: this.authToken,
|
|
61
|
+
customFetch: this.customFetch,
|
|
62
|
+
payload: args,
|
|
63
|
+
requestId: requestId,
|
|
64
|
+
});
|
|
65
|
+
return (0, validators_1.validateFolder)(response.data);
|
|
66
|
+
}
|
|
67
|
+
async deleteFolder(id, requestId) {
|
|
68
|
+
zod_1.z.string().parse(id);
|
|
69
|
+
const response = await (0, http_client_1.request)({
|
|
70
|
+
httpMethod: 'DELETE',
|
|
71
|
+
baseUri: this.syncApiBase,
|
|
72
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
|
|
73
|
+
apiToken: this.authToken,
|
|
74
|
+
customFetch: this.customFetch,
|
|
75
|
+
requestId: requestId,
|
|
76
|
+
});
|
|
77
|
+
return (0, http_client_1.isSuccess)(response);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.FolderClient = FolderClient;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GoalsClient = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
6
|
+
const http_client_1 = require("../transport/http-client");
|
|
7
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
8
|
+
const validators_1 = require("../utils/validators");
|
|
9
|
+
const base_client_1 = require("./base-client");
|
|
10
|
+
/**
|
|
11
|
+
* Internal sub-client handling all goal-domain endpoints.
|
|
12
|
+
*
|
|
13
|
+
* Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
|
|
14
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class GoalsClient extends base_client_1.BaseClient {
|
|
17
|
+
async getGoals(args) {
|
|
18
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
19
|
+
httpMethod: 'GET',
|
|
20
|
+
baseUri: this.syncApiBase,
|
|
21
|
+
relativePath: endpoints_1.ENDPOINT_REST_GOALS,
|
|
22
|
+
apiToken: this.authToken,
|
|
23
|
+
customFetch: this.customFetch,
|
|
24
|
+
payload: args,
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
results: (0, validators_1.validateGoalArray)(results),
|
|
28
|
+
nextCursor,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async searchGoals(args) {
|
|
32
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
33
|
+
httpMethod: 'GET',
|
|
34
|
+
baseUri: this.syncApiBase,
|
|
35
|
+
relativePath: endpoints_1.ENDPOINT_REST_GOALS_SEARCH,
|
|
36
|
+
apiToken: this.authToken,
|
|
37
|
+
customFetch: this.customFetch,
|
|
38
|
+
payload: args,
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
results: (0, validators_1.validateGoalArray)(results),
|
|
42
|
+
nextCursor,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async getGoal(id) {
|
|
46
|
+
zod_1.z.string().parse(id);
|
|
47
|
+
const response = await (0, http_client_1.request)({
|
|
48
|
+
httpMethod: 'GET',
|
|
49
|
+
baseUri: this.syncApiBase,
|
|
50
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
|
|
51
|
+
apiToken: this.authToken,
|
|
52
|
+
customFetch: this.customFetch,
|
|
53
|
+
});
|
|
54
|
+
return (0, validators_1.validateGoal)(response.data);
|
|
55
|
+
}
|
|
56
|
+
async addGoal(args, requestId) {
|
|
57
|
+
const response = await (0, http_client_1.request)({
|
|
58
|
+
httpMethod: 'POST',
|
|
59
|
+
baseUri: this.syncApiBase,
|
|
60
|
+
relativePath: endpoints_1.ENDPOINT_REST_GOALS,
|
|
61
|
+
apiToken: this.authToken,
|
|
62
|
+
customFetch: this.customFetch,
|
|
63
|
+
payload: args,
|
|
64
|
+
requestId: requestId,
|
|
65
|
+
});
|
|
66
|
+
return (0, validators_1.validateGoal)(response.data);
|
|
67
|
+
}
|
|
68
|
+
async updateGoal(id, args, requestId) {
|
|
69
|
+
zod_1.z.string().parse(id);
|
|
70
|
+
const response = await (0, http_client_1.request)({
|
|
71
|
+
httpMethod: 'POST',
|
|
72
|
+
baseUri: this.syncApiBase,
|
|
73
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
|
|
74
|
+
apiToken: this.authToken,
|
|
75
|
+
customFetch: this.customFetch,
|
|
76
|
+
payload: args,
|
|
77
|
+
requestId: requestId,
|
|
78
|
+
});
|
|
79
|
+
return (0, validators_1.validateGoal)(response.data);
|
|
80
|
+
}
|
|
81
|
+
async deleteGoal(id, requestId) {
|
|
82
|
+
zod_1.z.string().parse(id);
|
|
83
|
+
const response = await (0, http_client_1.request)({
|
|
84
|
+
httpMethod: 'DELETE',
|
|
85
|
+
baseUri: this.syncApiBase,
|
|
86
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
|
|
87
|
+
apiToken: this.authToken,
|
|
88
|
+
customFetch: this.customFetch,
|
|
89
|
+
requestId: requestId,
|
|
90
|
+
});
|
|
91
|
+
return (0, http_client_1.isSuccess)(response);
|
|
92
|
+
}
|
|
93
|
+
async completeGoal(id, requestId) {
|
|
94
|
+
zod_1.z.string().parse(id);
|
|
95
|
+
const response = await (0, http_client_1.request)({
|
|
96
|
+
httpMethod: 'POST',
|
|
97
|
+
baseUri: this.syncApiBase,
|
|
98
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_COMPLETE),
|
|
99
|
+
apiToken: this.authToken,
|
|
100
|
+
customFetch: this.customFetch,
|
|
101
|
+
requestId: requestId,
|
|
102
|
+
});
|
|
103
|
+
return (0, validators_1.validateGoal)(response.data);
|
|
104
|
+
}
|
|
105
|
+
async uncompleteGoal(id, requestId) {
|
|
106
|
+
zod_1.z.string().parse(id);
|
|
107
|
+
const response = await (0, http_client_1.request)({
|
|
108
|
+
httpMethod: 'POST',
|
|
109
|
+
baseUri: this.syncApiBase,
|
|
110
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_UNCOMPLETE),
|
|
111
|
+
apiToken: this.authToken,
|
|
112
|
+
customFetch: this.customFetch,
|
|
113
|
+
requestId: requestId,
|
|
114
|
+
});
|
|
115
|
+
return (0, validators_1.validateGoal)(response.data);
|
|
116
|
+
}
|
|
117
|
+
async linkTaskToGoal({ goalId, taskId }, requestId) {
|
|
118
|
+
zod_1.z.string().parse(goalId);
|
|
119
|
+
zod_1.z.string().parse(taskId);
|
|
120
|
+
const response = await (0, http_client_1.request)({
|
|
121
|
+
httpMethod: 'POST',
|
|
122
|
+
baseUri: this.syncApiBase,
|
|
123
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS),
|
|
124
|
+
apiToken: this.authToken,
|
|
125
|
+
customFetch: this.customFetch,
|
|
126
|
+
payload: { itemId: taskId },
|
|
127
|
+
requestId: requestId,
|
|
128
|
+
});
|
|
129
|
+
return (0, validators_1.validateGoal)(response.data);
|
|
130
|
+
}
|
|
131
|
+
async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
|
|
132
|
+
zod_1.z.string().parse(goalId);
|
|
133
|
+
zod_1.z.string().parse(taskId);
|
|
134
|
+
const response = await (0, http_client_1.request)({
|
|
135
|
+
httpMethod: 'DELETE',
|
|
136
|
+
baseUri: this.syncApiBase,
|
|
137
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS, taskId),
|
|
138
|
+
apiToken: this.authToken,
|
|
139
|
+
customFetch: this.customFetch,
|
|
140
|
+
requestId: requestId,
|
|
141
|
+
});
|
|
142
|
+
return (0, http_client_1.isSuccess)(response);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.GoalsClient = GoalsClient;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdMappingClient = void 0;
|
|
4
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
+
const http_client_1 = require("../transport/http-client");
|
|
6
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
7
|
+
const validators_1 = require("../utils/validators");
|
|
8
|
+
const base_client_1 = require("./base-client");
|
|
9
|
+
/**
|
|
10
|
+
* Internal sub-client handling ID-mapping endpoints.
|
|
11
|
+
*
|
|
12
|
+
* Instantiated by `TodoistApi`; every public id-mapping method on
|
|
13
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
14
|
+
* JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class IdMappingClient extends base_client_1.BaseClient {
|
|
17
|
+
async getIdMappings(args) {
|
|
18
|
+
const response = await (0, http_client_1.request)({
|
|
19
|
+
httpMethod: 'GET',
|
|
20
|
+
baseUri: this.syncApiBase,
|
|
21
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_ID_MAPPINGS, args.objName, args.objIds.join(',')),
|
|
22
|
+
apiToken: this.authToken,
|
|
23
|
+
customFetch: this.customFetch,
|
|
24
|
+
});
|
|
25
|
+
return (0, validators_1.validateIdMappingArray)(response.data);
|
|
26
|
+
}
|
|
27
|
+
async getMovedIds(args) {
|
|
28
|
+
const response = await (0, http_client_1.request)({
|
|
29
|
+
httpMethod: 'GET',
|
|
30
|
+
baseUri: this.syncApiBase,
|
|
31
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_MOVED_IDS, args.objName),
|
|
32
|
+
apiToken: this.authToken,
|
|
33
|
+
customFetch: this.customFetch,
|
|
34
|
+
payload: args.oldIds ? { oldIds: args.oldIds.join(',') } : undefined,
|
|
35
|
+
});
|
|
36
|
+
return (0, validators_1.validateMovedIdArray)(response.data);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.IdMappingClient = IdMappingClient;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsightsClient = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
6
|
+
const http_client_1 = require("../transport/http-client");
|
|
7
|
+
const validators_1 = require("../utils/validators");
|
|
8
|
+
const base_client_1 = require("./base-client");
|
|
9
|
+
/**
|
|
10
|
+
* Internal sub-client handling all insights-domain endpoints
|
|
11
|
+
* (project activity stats, health, progress, workspace insights).
|
|
12
|
+
*
|
|
13
|
+
* Instantiated by `TodoistApi`; every public insights method on
|
|
14
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
15
|
+
* JSDoc.
|
|
16
|
+
*/
|
|
17
|
+
class InsightsClient extends base_client_1.BaseClient {
|
|
18
|
+
async getProjectActivityStats(projectId, args = {}) {
|
|
19
|
+
zod_1.z.string().parse(projectId);
|
|
20
|
+
const response = await (0, http_client_1.request)({
|
|
21
|
+
httpMethod: 'GET',
|
|
22
|
+
baseUri: this.syncApiBase,
|
|
23
|
+
relativePath: (0, endpoints_1.getProjectInsightsActivityStatsEndpoint)(projectId),
|
|
24
|
+
apiToken: this.authToken,
|
|
25
|
+
customFetch: this.customFetch,
|
|
26
|
+
payload: Object.assign({ objectType: 'ITEM', eventType: 'COMPLETED' }, args),
|
|
27
|
+
});
|
|
28
|
+
return (0, validators_1.validateProjectActivityStats)(response.data);
|
|
29
|
+
}
|
|
30
|
+
async getProjectHealth(projectId) {
|
|
31
|
+
zod_1.z.string().parse(projectId);
|
|
32
|
+
const response = await (0, http_client_1.request)({
|
|
33
|
+
httpMethod: 'GET',
|
|
34
|
+
baseUri: this.syncApiBase,
|
|
35
|
+
relativePath: (0, endpoints_1.getProjectInsightsHealthEndpoint)(projectId),
|
|
36
|
+
apiToken: this.authToken,
|
|
37
|
+
customFetch: this.customFetch,
|
|
38
|
+
});
|
|
39
|
+
return (0, validators_1.validateProjectHealth)(response.data);
|
|
40
|
+
}
|
|
41
|
+
async getProjectHealthContext(projectId) {
|
|
42
|
+
zod_1.z.string().parse(projectId);
|
|
43
|
+
const response = await (0, http_client_1.request)({
|
|
44
|
+
httpMethod: 'GET',
|
|
45
|
+
baseUri: this.syncApiBase,
|
|
46
|
+
relativePath: (0, endpoints_1.getProjectInsightsHealthContextEndpoint)(projectId),
|
|
47
|
+
apiToken: this.authToken,
|
|
48
|
+
customFetch: this.customFetch,
|
|
49
|
+
});
|
|
50
|
+
return (0, validators_1.validateProjectHealthContext)(response.data);
|
|
51
|
+
}
|
|
52
|
+
async getProjectProgress(projectId) {
|
|
53
|
+
zod_1.z.string().parse(projectId);
|
|
54
|
+
const response = await (0, http_client_1.request)({
|
|
55
|
+
httpMethod: 'GET',
|
|
56
|
+
baseUri: this.syncApiBase,
|
|
57
|
+
relativePath: (0, endpoints_1.getProjectInsightsProgressEndpoint)(projectId),
|
|
58
|
+
apiToken: this.authToken,
|
|
59
|
+
customFetch: this.customFetch,
|
|
60
|
+
});
|
|
61
|
+
return (0, validators_1.validateProjectProgress)(response.data);
|
|
62
|
+
}
|
|
63
|
+
async getWorkspaceInsights(workspaceId, args = {}) {
|
|
64
|
+
zod_1.z.string().parse(workspaceId);
|
|
65
|
+
const response = await (0, http_client_1.request)({
|
|
66
|
+
httpMethod: 'GET',
|
|
67
|
+
baseUri: this.syncApiBase,
|
|
68
|
+
relativePath: (0, endpoints_1.getWorkspaceInsightsEndpoint)(workspaceId),
|
|
69
|
+
apiToken: this.authToken,
|
|
70
|
+
customFetch: this.customFetch,
|
|
71
|
+
payload: Object.assign(Object.assign({}, args), (args.projectIds ? { projectIds: args.projectIds.join(',') } : {})),
|
|
72
|
+
});
|
|
73
|
+
return (0, validators_1.validateWorkspaceInsights)(response.data);
|
|
74
|
+
}
|
|
75
|
+
async analyzeProjectHealth(projectId, requestId) {
|
|
76
|
+
zod_1.z.string().parse(projectId);
|
|
77
|
+
const response = await (0, http_client_1.request)({
|
|
78
|
+
httpMethod: 'POST',
|
|
79
|
+
baseUri: this.syncApiBase,
|
|
80
|
+
relativePath: (0, endpoints_1.getProjectInsightsHealthAnalyzeEndpoint)(projectId),
|
|
81
|
+
apiToken: this.authToken,
|
|
82
|
+
customFetch: this.customFetch,
|
|
83
|
+
requestId: requestId,
|
|
84
|
+
});
|
|
85
|
+
return (0, validators_1.validateProjectHealth)(response.data);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.InsightsClient = InsightsClient;
|