@doist/todoist-sdk 14.2.0 → 15.0.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/esm/types/sync/resources/index.js +1 -0
- package/dist/esm/types/sync/resources/labels.js +7 -0
- package/dist/esm/types/sync/resources/reminders.js +11 -0
- package/dist/esm/types/sync/response.js +3 -4
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/url-helpers.js +151 -23
- package/dist/types/types/sync/resources/index.d.ts +1 -0
- package/dist/types/types/sync/resources/labels.d.ts +12 -0
- package/dist/types/types/sync/resources/reminders.d.ts +87 -0
- package/dist/types/types/sync/response.d.ts +8 -7
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/url-helpers.d.ts +88 -0
- package/package.json +5 -10
- 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 -24
- 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 -198
- 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 -293
- 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
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UiExtensionClient = void 0;
|
|
4
|
-
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
-
const http_client_1 = require("../transport/http-client");
|
|
6
|
-
const multipart_upload_1 = require("../utils/multipart-upload");
|
|
7
|
-
const validators_1 = require("../utils/validators");
|
|
8
|
-
const base_client_1 = require("./base-client");
|
|
9
|
-
/**
|
|
10
|
-
* Internal sub-client handling all UI-extension endpoints for developer
|
|
11
|
-
* applications. All endpoints require the `dev:app_console` OAuth scope.
|
|
12
|
-
*
|
|
13
|
-
* Instantiated by `TodoistApi`; every public UI-extension method on
|
|
14
|
-
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing JSDoc.
|
|
15
|
-
*/
|
|
16
|
-
class UiExtensionClient extends base_client_1.BaseClient {
|
|
17
|
-
async getUiExtension(uiExtensionId, requestId) {
|
|
18
|
-
validators_1.IdSchema.parse(uiExtensionId);
|
|
19
|
-
const response = await (0, http_client_1.request)({
|
|
20
|
-
httpMethod: 'GET',
|
|
21
|
-
baseUri: this.apiRootBase,
|
|
22
|
-
relativePath: (0, endpoints_1.getUiExtensionEndpoint)(uiExtensionId),
|
|
23
|
-
apiToken: this.authToken,
|
|
24
|
-
customFetch: this.customFetch,
|
|
25
|
-
requestId: requestId,
|
|
26
|
-
});
|
|
27
|
-
return (0, validators_1.validateUiExtension)(response.data);
|
|
28
|
-
}
|
|
29
|
-
async getInstalledUiExtensions(requestId) {
|
|
30
|
-
const response = await (0, http_client_1.request)({
|
|
31
|
-
httpMethod: 'GET',
|
|
32
|
-
baseUri: this.apiRootBase,
|
|
33
|
-
relativePath: endpoints_1.ENDPOINT_REST_APPS_UI_EXTENSIONS_INSTALLED,
|
|
34
|
-
apiToken: this.authToken,
|
|
35
|
-
customFetch: this.customFetch,
|
|
36
|
-
requestId: requestId,
|
|
37
|
-
});
|
|
38
|
-
return (0, validators_1.validateUiExtensionArray)(response.data);
|
|
39
|
-
}
|
|
40
|
-
async getUiExtensionsForApp(appId, requestId) {
|
|
41
|
-
validators_1.IdSchema.parse(appId);
|
|
42
|
-
const response = await (0, http_client_1.request)({
|
|
43
|
-
httpMethod: 'GET',
|
|
44
|
-
baseUri: this.apiRootBase,
|
|
45
|
-
relativePath: (0, endpoints_1.getUiExtensionsByIntegrationEndpoint)(appId),
|
|
46
|
-
apiToken: this.authToken,
|
|
47
|
-
customFetch: this.customFetch,
|
|
48
|
-
requestId: requestId,
|
|
49
|
-
});
|
|
50
|
-
return (0, validators_1.validateUiExtensionArray)(response.data);
|
|
51
|
-
}
|
|
52
|
-
async addUiExtension(args, requestId) {
|
|
53
|
-
const response = await (0, http_client_1.request)({
|
|
54
|
-
httpMethod: 'POST',
|
|
55
|
-
baseUri: this.apiRootBase,
|
|
56
|
-
relativePath: endpoints_1.ENDPOINT_REST_APPS_UI_EXTENSIONS,
|
|
57
|
-
apiToken: this.authToken,
|
|
58
|
-
customFetch: this.customFetch,
|
|
59
|
-
payload: args,
|
|
60
|
-
requestId: requestId,
|
|
61
|
-
});
|
|
62
|
-
return (0, validators_1.validateUiExtension)(response.data);
|
|
63
|
-
}
|
|
64
|
-
async updateUiExtension(uiExtensionId, args, requestId) {
|
|
65
|
-
validators_1.IdSchema.parse(uiExtensionId);
|
|
66
|
-
const response = await (0, http_client_1.request)({
|
|
67
|
-
httpMethod: 'PATCH',
|
|
68
|
-
baseUri: this.apiRootBase,
|
|
69
|
-
relativePath: (0, endpoints_1.getUiExtensionEndpoint)(uiExtensionId),
|
|
70
|
-
apiToken: this.authToken,
|
|
71
|
-
customFetch: this.customFetch,
|
|
72
|
-
payload: args,
|
|
73
|
-
requestId: requestId,
|
|
74
|
-
});
|
|
75
|
-
return (0, validators_1.validateUiExtension)(response.data);
|
|
76
|
-
}
|
|
77
|
-
async deleteUiExtension(uiExtensionId, requestId) {
|
|
78
|
-
validators_1.IdSchema.parse(uiExtensionId);
|
|
79
|
-
const response = await (0, http_client_1.request)({
|
|
80
|
-
httpMethod: 'DELETE',
|
|
81
|
-
baseUri: this.apiRootBase,
|
|
82
|
-
relativePath: (0, endpoints_1.getUiExtensionEndpoint)(uiExtensionId),
|
|
83
|
-
apiToken: this.authToken,
|
|
84
|
-
customFetch: this.customFetch,
|
|
85
|
-
requestId: requestId,
|
|
86
|
-
});
|
|
87
|
-
return (0, http_client_1.isSuccess)(response);
|
|
88
|
-
}
|
|
89
|
-
async uploadUiExtensionIcon(args, requestId) {
|
|
90
|
-
var _a;
|
|
91
|
-
if (Buffer.isBuffer(args.file) && args.file.length === 0) {
|
|
92
|
-
throw new Error('Cannot upload empty image file');
|
|
93
|
-
}
|
|
94
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
95
|
-
baseUrl: this.apiRootBase,
|
|
96
|
-
authToken: this.authToken,
|
|
97
|
-
endpoint: (0, endpoints_1.getUiExtensionIconEndpoint)(args.uiExtensionId),
|
|
98
|
-
file: args.file,
|
|
99
|
-
fileName: args.fileName,
|
|
100
|
-
additionalFields: { file_name: (_a = args.fileName) !== null && _a !== void 0 ? _a : '' },
|
|
101
|
-
requestId: requestId,
|
|
102
|
-
customFetch: this.customFetch,
|
|
103
|
-
});
|
|
104
|
-
return (0, validators_1.validateUiExtension)(data);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.UiExtensionClient = UiExtensionClient;
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UploadClient = void 0;
|
|
4
|
-
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
-
const http_client_1 = require("../transport/http-client");
|
|
6
|
-
const file_response_1 = require("../utils/file-response");
|
|
7
|
-
const multipart_upload_1 = require("../utils/multipart-upload");
|
|
8
|
-
const validators_1 = require("../utils/validators");
|
|
9
|
-
const base_client_1 = require("./base-client");
|
|
10
|
-
/**
|
|
11
|
-
* First-party origin that serves attachment downloads behind Bearer auth.
|
|
12
|
-
* It redirects to the CDN; on the cross-origin hop the runtime drops the
|
|
13
|
-
* Authorization header, so the token never reaches the CDN.
|
|
14
|
-
*/
|
|
15
|
-
const AUTHENTICATED_ATTACHMENT_HOST = 'files.todoist.com';
|
|
16
|
-
/**
|
|
17
|
-
* CDN origins that serve attachments via pre-signed URLs. These are
|
|
18
|
-
* third-party infrastructure and must never receive the auth token.
|
|
19
|
-
*/
|
|
20
|
-
const CDN_ATTACHMENT_HOSTS = new Set(['todoist.b-cdn.net', 'd1ysz50cxb9zwl.cloudfront.net']);
|
|
21
|
-
const MAX_ATTACHMENT_REDIRECTS = 5;
|
|
22
|
-
/**
|
|
23
|
-
* Builds the request headers for an attachment fetch, attaching the Bearer
|
|
24
|
-
* token only when the URL is on the first-party authenticated host.
|
|
25
|
-
*/
|
|
26
|
-
function buildAttachmentAuthHeaders(url, authToken) {
|
|
27
|
-
return new URL(url).hostname === AUTHENTICATED_ATTACHMENT_HOST
|
|
28
|
-
? { Authorization: `Bearer ${authToken}` }
|
|
29
|
-
: {};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Fetches an attachment through a caller-supplied `customFetch` while
|
|
33
|
-
* guaranteeing the auth token is never sent across origins.
|
|
34
|
-
*
|
|
35
|
-
* A `customFetch` is an arbitrary implementation that may not honour the Fetch
|
|
36
|
-
* standard's rule of stripping `Authorization` on cross-origin redirects (older
|
|
37
|
-
* `node-fetch`, for example, does not). Because `files.todoist.com` redirects
|
|
38
|
-
* downloads to the CDN, a naive implementation could forward the token there.
|
|
39
|
-
* We therefore drive redirects with `redirect: 'manual'` and follow them
|
|
40
|
-
* ourselves, dropping the auth header whenever the origin changes.
|
|
41
|
-
*
|
|
42
|
-
* Implementations that hide the redirect behind an opaque response (status `0`,
|
|
43
|
-
* e.g. undici and browsers) can't be followed manually; for those we re-issue
|
|
44
|
-
* with normal redirect following and rely on the Fetch standard's cross-origin
|
|
45
|
-
* auth stripping, which those runtimes implement.
|
|
46
|
-
*/
|
|
47
|
-
async function customFetchFollowingRedirects(customFetch, startUrl, authToken) {
|
|
48
|
-
let currentUrl = startUrl;
|
|
49
|
-
let headers = buildAttachmentAuthHeaders(currentUrl, authToken);
|
|
50
|
-
for (let redirects = 0; redirects < MAX_ATTACHMENT_REDIRECTS; redirects++) {
|
|
51
|
-
const response = await customFetch(currentUrl, {
|
|
52
|
-
method: 'GET',
|
|
53
|
-
headers,
|
|
54
|
-
redirect: 'manual',
|
|
55
|
-
});
|
|
56
|
-
const location = response.headers['location'];
|
|
57
|
-
const isReadableRedirect = response.status >= 300 && response.status < 400 && Boolean(location);
|
|
58
|
-
if (!isReadableRedirect) {
|
|
59
|
-
// Opaque redirect (the impl hid the Location, e.g. undici): re-issue
|
|
60
|
-
// with normal following and trust the runtime to strip auth cross-origin.
|
|
61
|
-
if (response.status === 0) {
|
|
62
|
-
return customFetch(currentUrl, { method: 'GET', headers });
|
|
63
|
-
}
|
|
64
|
-
return response;
|
|
65
|
-
}
|
|
66
|
-
const nextUrl = new URL(location, currentUrl);
|
|
67
|
-
if (nextUrl.origin !== new URL(currentUrl).origin) {
|
|
68
|
-
headers = {};
|
|
69
|
-
}
|
|
70
|
-
currentUrl = nextUrl.toString();
|
|
71
|
-
}
|
|
72
|
-
throw new Error('Too many redirects while fetching attachment');
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Internal sub-client handling upload + attachment endpoints
|
|
76
|
-
* (file upload, upload delete, attachment view).
|
|
77
|
-
*
|
|
78
|
-
* Instantiated by `TodoistApi`; every public upload method on
|
|
79
|
-
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
80
|
-
* JSDoc.
|
|
81
|
-
*/
|
|
82
|
-
class UploadClient extends base_client_1.BaseClient {
|
|
83
|
-
async uploadFile(args, requestId) {
|
|
84
|
-
const additionalFields = {};
|
|
85
|
-
if (args.projectId) {
|
|
86
|
-
additionalFields.project_id = args.projectId;
|
|
87
|
-
}
|
|
88
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
89
|
-
baseUrl: this.syncApiBase,
|
|
90
|
-
authToken: this.authToken,
|
|
91
|
-
endpoint: endpoints_1.ENDPOINT_REST_UPLOADS,
|
|
92
|
-
file: args.file,
|
|
93
|
-
fileName: args.fileName,
|
|
94
|
-
additionalFields: additionalFields,
|
|
95
|
-
requestId: requestId,
|
|
96
|
-
customFetch: this.customFetch,
|
|
97
|
-
});
|
|
98
|
-
return (0, validators_1.validateAttachment)(data);
|
|
99
|
-
}
|
|
100
|
-
async deleteUpload(args, requestId) {
|
|
101
|
-
const response = await (0, http_client_1.request)({
|
|
102
|
-
httpMethod: 'DELETE',
|
|
103
|
-
baseUri: this.syncApiBase,
|
|
104
|
-
relativePath: endpoints_1.ENDPOINT_REST_UPLOADS,
|
|
105
|
-
apiToken: this.authToken,
|
|
106
|
-
customFetch: this.customFetch,
|
|
107
|
-
payload: args,
|
|
108
|
-
requestId: requestId,
|
|
109
|
-
});
|
|
110
|
-
return (0, http_client_1.isSuccess)(response);
|
|
111
|
-
}
|
|
112
|
-
async viewAttachment(commentOrUrl) {
|
|
113
|
-
var _a;
|
|
114
|
-
let fileUrl;
|
|
115
|
-
if (typeof commentOrUrl === 'string') {
|
|
116
|
-
fileUrl = commentOrUrl;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
if (!((_a = commentOrUrl.fileAttachment) === null || _a === void 0 ? void 0 : _a.fileUrl)) {
|
|
120
|
-
throw new Error('Comment does not have a file attachment');
|
|
121
|
-
}
|
|
122
|
-
fileUrl = commentOrUrl.fileAttachment.fileUrl;
|
|
123
|
-
}
|
|
124
|
-
// Only allow known attachment origins, and only attach the auth token to the
|
|
125
|
-
// first-party authenticated host. This prevents the token leaking to other
|
|
126
|
-
// todoist.com hosts (e.g. api.todoist.com) or to third-party CDN infrastructure.
|
|
127
|
-
const urlHostname = new URL(fileUrl).hostname;
|
|
128
|
-
const isAuthenticatedHost = urlHostname === AUTHENTICATED_ATTACHMENT_HOST;
|
|
129
|
-
if (!isAuthenticatedHost && !CDN_ATTACHMENT_HOSTS.has(urlHostname)) {
|
|
130
|
-
throw new Error('Attachment URLs must be on a known Todoist attachment host');
|
|
131
|
-
}
|
|
132
|
-
if (this.customFetch) {
|
|
133
|
-
// customFetch may not strip auth on cross-origin redirects, so we
|
|
134
|
-
// follow the files.todoist.com -> CDN hop ourselves to avoid leaking
|
|
135
|
-
// the token. See customFetchFollowingRedirects for details.
|
|
136
|
-
const response = await customFetchFollowingRedirects(this.customFetch, fileUrl, this.authToken);
|
|
137
|
-
if (!response.ok) {
|
|
138
|
-
throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
|
|
139
|
-
}
|
|
140
|
-
return (0, file_response_1.wrapAsFileResponse)(response, 'viewAttachment');
|
|
141
|
-
}
|
|
142
|
-
// Built-in fetch (undici) strips Authorization on cross-origin redirects
|
|
143
|
-
// per the Fetch standard, so the files.todoist.com -> CDN hop is safe here.
|
|
144
|
-
const fetchOptions = {
|
|
145
|
-
method: 'GET',
|
|
146
|
-
headers: isAuthenticatedHost ? { Authorization: `Bearer ${this.authToken}` } : {},
|
|
147
|
-
};
|
|
148
|
-
const response = await fetch(fileUrl, fetchOptions);
|
|
149
|
-
if (!response.ok) {
|
|
150
|
-
throw new Error(`Failed to fetch attachment: ${response.status} ${response.statusText}`);
|
|
151
|
-
}
|
|
152
|
-
return (0, file_response_1.wrapAsFileResponse)(response, 'viewAttachment');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.UploadClient = UploadClient;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ViewOptionsClient = void 0;
|
|
4
|
-
const sync_request_1 = require("../transport/sync-request");
|
|
5
|
-
const sync_helpers_1 = require("../utils/sync-helpers");
|
|
6
|
-
const view_options_1 = require("../utils/view-options");
|
|
7
|
-
const base_client_1 = require("./base-client");
|
|
8
|
-
/** Internal sub-client for saved view-option reads and writes. */
|
|
9
|
-
class ViewOptionsClient extends base_client_1.BaseClient {
|
|
10
|
-
async getViewOptions() {
|
|
11
|
-
var _a;
|
|
12
|
-
const response = await (0, sync_request_1.performSyncRequest)(this.syncContext, {
|
|
13
|
-
resourceTypes: ['view_options'],
|
|
14
|
-
syncToken: '*',
|
|
15
|
-
});
|
|
16
|
-
return ((_a = response.viewOptions) !== null && _a !== void 0 ? _a : []).filter(view_options_1.isActiveViewOption);
|
|
17
|
-
}
|
|
18
|
-
async setViewOptions(args, requestId) {
|
|
19
|
-
await (0, sync_request_1.performSyncRequest)(this.syncContext, { commands: [(0, sync_helpers_1.createCommand)('view_options_set', args)] }, { requestId, hasSyncCommands: true });
|
|
20
|
-
}
|
|
21
|
-
async deleteViewOptions(args, requestId) {
|
|
22
|
-
await (0, sync_request_1.performSyncRequest)(this.syncContext, { commands: [(0, sync_helpers_1.createCommand)('view_options_delete', args)] }, { requestId, hasSyncCommands: true });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.ViewOptionsClient = ViewOptionsClient;
|
|
@@ -1,366 +0,0 @@
|
|
|
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.WorkspaceClient = void 0;
|
|
15
|
-
const endpoints_1 = require("../consts/endpoints");
|
|
16
|
-
const http_client_1 = require("../transport/http-client");
|
|
17
|
-
const multipart_upload_1 = require("../utils/multipart-upload");
|
|
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 workspace-domain endpoints —
|
|
23
|
-
* workspaces, invitations, users, plans, logos, and workspace project
|
|
24
|
-
* pagination.
|
|
25
|
-
*
|
|
26
|
-
* Instantiated by `TodoistApi`; every public workspace method on
|
|
27
|
-
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
28
|
-
* JSDoc.
|
|
29
|
-
*/
|
|
30
|
-
class WorkspaceClient extends base_client_1.BaseClient {
|
|
31
|
-
async getWorkspaceInvitations(args, requestId) {
|
|
32
|
-
const response = await (0, http_client_1.request)({
|
|
33
|
-
httpMethod: 'GET',
|
|
34
|
-
baseUri: this.syncApiBase,
|
|
35
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS,
|
|
36
|
-
apiToken: this.authToken,
|
|
37
|
-
customFetch: this.customFetch,
|
|
38
|
-
payload: { workspace_id: args.workspaceId },
|
|
39
|
-
requestId: requestId,
|
|
40
|
-
});
|
|
41
|
-
return response.data;
|
|
42
|
-
}
|
|
43
|
-
async getAllWorkspaceInvitations(args = {}, requestId) {
|
|
44
|
-
const queryParams = {};
|
|
45
|
-
if (args.workspaceId) {
|
|
46
|
-
queryParams.workspace_id = args.workspaceId;
|
|
47
|
-
}
|
|
48
|
-
const response = await (0, http_client_1.request)({
|
|
49
|
-
httpMethod: 'GET',
|
|
50
|
-
baseUri: this.syncApiBase,
|
|
51
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_ALL,
|
|
52
|
-
apiToken: this.authToken,
|
|
53
|
-
customFetch: this.customFetch,
|
|
54
|
-
payload: queryParams,
|
|
55
|
-
requestId: requestId,
|
|
56
|
-
});
|
|
57
|
-
return (0, validators_1.validateWorkspaceInvitationArray)(response.data);
|
|
58
|
-
}
|
|
59
|
-
async deleteWorkspaceInvitation(args, requestId) {
|
|
60
|
-
const response = await (0, http_client_1.request)({
|
|
61
|
-
httpMethod: 'POST',
|
|
62
|
-
baseUri: this.syncApiBase,
|
|
63
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
|
|
64
|
-
apiToken: this.authToken,
|
|
65
|
-
customFetch: this.customFetch,
|
|
66
|
-
payload: {
|
|
67
|
-
workspace_id: args.workspaceId,
|
|
68
|
-
user_email: args.userEmail,
|
|
69
|
-
},
|
|
70
|
-
requestId: requestId,
|
|
71
|
-
});
|
|
72
|
-
return (0, validators_1.validateWorkspaceInvitation)(response.data);
|
|
73
|
-
}
|
|
74
|
-
async acceptWorkspaceInvitation(args, requestId) {
|
|
75
|
-
const response = await (0, http_client_1.request)({
|
|
76
|
-
httpMethod: 'PUT',
|
|
77
|
-
baseUri: this.syncApiBase,
|
|
78
|
-
relativePath: (0, endpoints_1.getWorkspaceInvitationAcceptEndpoint)(args.inviteCode),
|
|
79
|
-
apiToken: this.authToken,
|
|
80
|
-
customFetch: this.customFetch,
|
|
81
|
-
requestId: requestId,
|
|
82
|
-
});
|
|
83
|
-
return (0, validators_1.validateWorkspaceInvitation)(response.data);
|
|
84
|
-
}
|
|
85
|
-
async rejectWorkspaceInvitation(args, requestId) {
|
|
86
|
-
const response = await (0, http_client_1.request)({
|
|
87
|
-
httpMethod: 'PUT',
|
|
88
|
-
baseUri: this.syncApiBase,
|
|
89
|
-
relativePath: (0, endpoints_1.getWorkspaceInvitationRejectEndpoint)(args.inviteCode),
|
|
90
|
-
apiToken: this.authToken,
|
|
91
|
-
customFetch: this.customFetch,
|
|
92
|
-
requestId: requestId,
|
|
93
|
-
});
|
|
94
|
-
return (0, validators_1.validateWorkspaceInvitation)(response.data);
|
|
95
|
-
}
|
|
96
|
-
async joinWorkspace(args, requestId) {
|
|
97
|
-
const response = await (0, http_client_1.request)({
|
|
98
|
-
httpMethod: 'POST',
|
|
99
|
-
baseUri: this.syncApiBase,
|
|
100
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_JOIN,
|
|
101
|
-
apiToken: this.authToken,
|
|
102
|
-
customFetch: this.customFetch,
|
|
103
|
-
payload: {
|
|
104
|
-
invite_code: args.inviteCode,
|
|
105
|
-
workspace_id: args.workspaceId,
|
|
106
|
-
},
|
|
107
|
-
requestId: requestId,
|
|
108
|
-
});
|
|
109
|
-
return (0, validators_1.validateJoinWorkspaceResult)(response.data);
|
|
110
|
-
}
|
|
111
|
-
async uploadWorkspaceLogo(args, requestId) {
|
|
112
|
-
if (args.delete) {
|
|
113
|
-
// Delete logo
|
|
114
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
115
|
-
baseUrl: this.syncApiBase,
|
|
116
|
-
authToken: this.authToken,
|
|
117
|
-
endpoint: endpoints_1.ENDPOINT_WORKSPACE_LOGO,
|
|
118
|
-
file: Buffer.alloc(0), // Empty buffer for delete
|
|
119
|
-
fileName: 'delete',
|
|
120
|
-
additionalFields: {
|
|
121
|
-
workspace_id: args.workspaceId,
|
|
122
|
-
delete: true,
|
|
123
|
-
},
|
|
124
|
-
requestId: requestId,
|
|
125
|
-
customFetch: this.customFetch,
|
|
126
|
-
});
|
|
127
|
-
return data;
|
|
128
|
-
}
|
|
129
|
-
if (!args.file) {
|
|
130
|
-
throw new Error('file is required when not deleting logo');
|
|
131
|
-
}
|
|
132
|
-
// Validate buffer is not empty if it's a Buffer
|
|
133
|
-
if (Buffer.isBuffer(args.file) && args.file.length === 0) {
|
|
134
|
-
throw new Error('Cannot upload empty image file');
|
|
135
|
-
}
|
|
136
|
-
const additionalFields = {
|
|
137
|
-
workspace_id: args.workspaceId,
|
|
138
|
-
};
|
|
139
|
-
const data = await (0, multipart_upload_1.uploadMultipartFile)({
|
|
140
|
-
baseUrl: this.syncApiBase,
|
|
141
|
-
authToken: this.authToken,
|
|
142
|
-
endpoint: endpoints_1.ENDPOINT_WORKSPACE_LOGO,
|
|
143
|
-
file: args.file,
|
|
144
|
-
fileName: args.fileName,
|
|
145
|
-
additionalFields: additionalFields,
|
|
146
|
-
requestId: requestId,
|
|
147
|
-
customFetch: this.customFetch,
|
|
148
|
-
});
|
|
149
|
-
return data;
|
|
150
|
-
}
|
|
151
|
-
async getWorkspacePlanDetails(args, requestId) {
|
|
152
|
-
const response = await (0, http_client_1.request)({
|
|
153
|
-
httpMethod: 'GET',
|
|
154
|
-
baseUri: this.syncApiBase,
|
|
155
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_PLAN_DETAILS,
|
|
156
|
-
apiToken: this.authToken,
|
|
157
|
-
customFetch: this.customFetch,
|
|
158
|
-
payload: { workspace_id: args.workspaceId },
|
|
159
|
-
requestId: requestId,
|
|
160
|
-
});
|
|
161
|
-
return (0, validators_1.validateWorkspacePlanDetails)(response.data);
|
|
162
|
-
}
|
|
163
|
-
async getWorkspaceUsers(args = {}, requestId) {
|
|
164
|
-
const queryParams = {};
|
|
165
|
-
if (args.workspaceId !== undefined && args.workspaceId !== null) {
|
|
166
|
-
queryParams.workspace_id = args.workspaceId;
|
|
167
|
-
}
|
|
168
|
-
if (args.cursor) {
|
|
169
|
-
queryParams.cursor = args.cursor;
|
|
170
|
-
}
|
|
171
|
-
if (args.limit) {
|
|
172
|
-
queryParams.limit = args.limit;
|
|
173
|
-
}
|
|
174
|
-
const response = await (0, http_client_1.request)({
|
|
175
|
-
httpMethod: 'GET',
|
|
176
|
-
baseUri: this.syncApiBase,
|
|
177
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_USERS,
|
|
178
|
-
apiToken: this.authToken,
|
|
179
|
-
customFetch: this.customFetch,
|
|
180
|
-
payload: queryParams,
|
|
181
|
-
requestId: requestId,
|
|
182
|
-
});
|
|
183
|
-
return {
|
|
184
|
-
hasMore: response.data.hasMore || false,
|
|
185
|
-
nextCursor: response.data.nextCursor,
|
|
186
|
-
workspaceUsers: (0, validators_1.validateWorkspaceUserArray)(response.data.workspaceUsers || []),
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
async getWorkspaces(requestId) {
|
|
190
|
-
const response = await (0, http_client_1.request)({
|
|
191
|
-
httpMethod: 'GET',
|
|
192
|
-
baseUri: this.syncApiBase,
|
|
193
|
-
relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
|
|
194
|
-
apiToken: this.authToken,
|
|
195
|
-
customFetch: this.customFetch,
|
|
196
|
-
requestId: requestId,
|
|
197
|
-
});
|
|
198
|
-
return (0, validators_1.validateWorkspaceArray)(response.data);
|
|
199
|
-
}
|
|
200
|
-
async getWorkspace(id, requestId) {
|
|
201
|
-
validators_1.IdSchema.parse(id);
|
|
202
|
-
const response = await (0, http_client_1.request)({
|
|
203
|
-
httpMethod: 'GET',
|
|
204
|
-
baseUri: this.syncApiBase,
|
|
205
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
|
|
206
|
-
apiToken: this.authToken,
|
|
207
|
-
customFetch: this.customFetch,
|
|
208
|
-
requestId: requestId,
|
|
209
|
-
});
|
|
210
|
-
return (0, validators_1.validateWorkspace)(response.data);
|
|
211
|
-
}
|
|
212
|
-
async addWorkspace(args, requestId) {
|
|
213
|
-
const response = await (0, http_client_1.request)({
|
|
214
|
-
httpMethod: 'POST',
|
|
215
|
-
baseUri: this.syncApiBase,
|
|
216
|
-
relativePath: endpoints_1.ENDPOINT_REST_WORKSPACES,
|
|
217
|
-
apiToken: this.authToken,
|
|
218
|
-
customFetch: this.customFetch,
|
|
219
|
-
payload: args,
|
|
220
|
-
requestId: requestId,
|
|
221
|
-
});
|
|
222
|
-
return (0, validators_1.validateWorkspace)(response.data);
|
|
223
|
-
}
|
|
224
|
-
async updateWorkspace(id, args, requestId) {
|
|
225
|
-
validators_1.IdSchema.parse(id);
|
|
226
|
-
const response = await (0, http_client_1.request)({
|
|
227
|
-
httpMethod: 'POST',
|
|
228
|
-
baseUri: this.syncApiBase,
|
|
229
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
|
|
230
|
-
apiToken: this.authToken,
|
|
231
|
-
customFetch: this.customFetch,
|
|
232
|
-
payload: args,
|
|
233
|
-
requestId: requestId,
|
|
234
|
-
});
|
|
235
|
-
return (0, validators_1.validateWorkspace)(response.data);
|
|
236
|
-
}
|
|
237
|
-
async deleteWorkspace(id, requestId) {
|
|
238
|
-
validators_1.IdSchema.parse(id);
|
|
239
|
-
const response = await (0, http_client_1.request)({
|
|
240
|
-
httpMethod: 'DELETE',
|
|
241
|
-
baseUri: this.syncApiBase,
|
|
242
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_WORKSPACES, id),
|
|
243
|
-
apiToken: this.authToken,
|
|
244
|
-
customFetch: this.customFetch,
|
|
245
|
-
requestId: requestId,
|
|
246
|
-
});
|
|
247
|
-
return (0, http_client_1.isSuccess)(response);
|
|
248
|
-
}
|
|
249
|
-
async getWorkspaceMembersActivity(args, requestId) {
|
|
250
|
-
const { workspaceId } = args, queryParams = __rest(args, ["workspaceId"]);
|
|
251
|
-
const { data } = await (0, http_client_1.request)({
|
|
252
|
-
httpMethod: 'GET',
|
|
253
|
-
baseUri: this.syncApiBase,
|
|
254
|
-
relativePath: endpoints_1.ENDPOINT_WORKSPACE_MEMBERS,
|
|
255
|
-
apiToken: this.authToken,
|
|
256
|
-
customFetch: this.customFetch,
|
|
257
|
-
payload: Object.assign({ workspaceId }, queryParams),
|
|
258
|
-
requestId: requestId,
|
|
259
|
-
});
|
|
260
|
-
return {
|
|
261
|
-
members: (0, validators_1.validateMemberActivityInfoArray)(data.members),
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
async getWorkspaceUserTasks(args, requestId) {
|
|
265
|
-
const { workspaceId, userId } = args, queryParams = __rest(args, ["workspaceId", "userId"]);
|
|
266
|
-
const { data } = await (0, http_client_1.request)({
|
|
267
|
-
httpMethod: 'GET',
|
|
268
|
-
baseUri: this.syncApiBase,
|
|
269
|
-
relativePath: (0, endpoints_1.getWorkspaceUserTasksEndpoint)(workspaceId, userId),
|
|
270
|
-
apiToken: this.authToken,
|
|
271
|
-
customFetch: this.customFetch,
|
|
272
|
-
payload: queryParams,
|
|
273
|
-
requestId: requestId,
|
|
274
|
-
});
|
|
275
|
-
return {
|
|
276
|
-
tasks: (0, validators_1.validateWorkspaceUserTaskArray)(data.tasks),
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
async inviteWorkspaceUsers(args, requestId) {
|
|
280
|
-
const { workspaceId } = args, payload = __rest(args, ["workspaceId"]);
|
|
281
|
-
const { data } = await (0, http_client_1.request)({
|
|
282
|
-
httpMethod: 'POST',
|
|
283
|
-
baseUri: this.syncApiBase,
|
|
284
|
-
relativePath: (0, endpoints_1.getWorkspaceInviteUsersEndpoint)(workspaceId),
|
|
285
|
-
apiToken: this.authToken,
|
|
286
|
-
customFetch: this.customFetch,
|
|
287
|
-
payload: payload,
|
|
288
|
-
requestId: requestId,
|
|
289
|
-
});
|
|
290
|
-
return data;
|
|
291
|
-
}
|
|
292
|
-
async updateWorkspaceUser(args, requestId) {
|
|
293
|
-
const { workspaceId, userId } = args, payload = __rest(args, ["workspaceId", "userId"]);
|
|
294
|
-
const response = await (0, http_client_1.request)({
|
|
295
|
-
httpMethod: 'POST',
|
|
296
|
-
baseUri: this.syncApiBase,
|
|
297
|
-
relativePath: (0, endpoints_1.getWorkspaceUserEndpoint)(workspaceId, userId),
|
|
298
|
-
apiToken: this.authToken,
|
|
299
|
-
customFetch: this.customFetch,
|
|
300
|
-
payload: payload,
|
|
301
|
-
requestId: requestId,
|
|
302
|
-
});
|
|
303
|
-
return (0, validators_1.validateJoinWorkspaceResult)(response.data);
|
|
304
|
-
}
|
|
305
|
-
async removeWorkspaceUser(args, requestId) {
|
|
306
|
-
const { workspaceId, userId } = args;
|
|
307
|
-
const response = await (0, http_client_1.request)({
|
|
308
|
-
httpMethod: 'DELETE',
|
|
309
|
-
baseUri: this.syncApiBase,
|
|
310
|
-
relativePath: (0, endpoints_1.getWorkspaceUserEndpoint)(workspaceId, userId),
|
|
311
|
-
apiToken: this.authToken,
|
|
312
|
-
customFetch: this.customFetch,
|
|
313
|
-
requestId: requestId,
|
|
314
|
-
});
|
|
315
|
-
return (0, http_client_1.isSuccess)(response);
|
|
316
|
-
}
|
|
317
|
-
async getWorkspaceActiveProjects(args, requestId) {
|
|
318
|
-
var _a;
|
|
319
|
-
const queryParams = {};
|
|
320
|
-
if (args.cursor) {
|
|
321
|
-
queryParams.cursor = args.cursor;
|
|
322
|
-
}
|
|
323
|
-
if (args.limit) {
|
|
324
|
-
queryParams.limit = args.limit;
|
|
325
|
-
}
|
|
326
|
-
const response = await (0, http_client_1.request)({
|
|
327
|
-
httpMethod: 'GET',
|
|
328
|
-
baseUri: this.syncApiBase,
|
|
329
|
-
relativePath: (0, endpoints_1.getWorkspaceActiveProjectsEndpoint)(args.workspaceId),
|
|
330
|
-
apiToken: this.authToken,
|
|
331
|
-
customFetch: this.customFetch,
|
|
332
|
-
payload: queryParams,
|
|
333
|
-
requestId: requestId,
|
|
334
|
-
});
|
|
335
|
-
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
336
|
-
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => (0, validators_1.validateProject)(project));
|
|
337
|
-
return Object.assign(Object.assign({}, response.data), {
|
|
338
|
-
// oxlint-disable-next-line no-unsafe-assignment
|
|
339
|
-
results: validatedProjects || [] });
|
|
340
|
-
}
|
|
341
|
-
async getWorkspaceArchivedProjects(args, requestId) {
|
|
342
|
-
var _a;
|
|
343
|
-
const queryParams = {};
|
|
344
|
-
if (args.cursor) {
|
|
345
|
-
queryParams.cursor = args.cursor;
|
|
346
|
-
}
|
|
347
|
-
if (args.limit) {
|
|
348
|
-
queryParams.limit = args.limit;
|
|
349
|
-
}
|
|
350
|
-
const response = await (0, http_client_1.request)({
|
|
351
|
-
httpMethod: 'GET',
|
|
352
|
-
baseUri: this.syncApiBase,
|
|
353
|
-
relativePath: (0, endpoints_1.getWorkspaceArchivedProjectsEndpoint)(args.workspaceId),
|
|
354
|
-
apiToken: this.authToken,
|
|
355
|
-
customFetch: this.customFetch,
|
|
356
|
-
payload: queryParams,
|
|
357
|
-
requestId: requestId,
|
|
358
|
-
});
|
|
359
|
-
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
360
|
-
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => (0, validators_1.validateProject)(project));
|
|
361
|
-
return Object.assign(Object.assign({}, response.data), {
|
|
362
|
-
// oxlint-disable-next-line no-unsafe-assignment
|
|
363
|
-
results: validatedProjects || [] });
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
exports.WorkspaceClient = WorkspaceClient;
|