@doist/todoist-sdk 9.2.0 → 9.4.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/dist/cjs/clients/app-client.js +17 -17
- package/dist/cjs/clients/comment-client.js +3 -4
- package/dist/cjs/clients/folder-client.js +3 -4
- package/dist/cjs/clients/insights-client.js +6 -7
- package/dist/cjs/clients/label-client.js +3 -4
- package/dist/cjs/clients/project-client.js +8 -9
- package/dist/cjs/clients/section-client.js +5 -6
- package/dist/cjs/clients/task-client.js +6 -7
- package/dist/cjs/clients/ui-extension-client.js +4 -5
- package/dist/cjs/clients/workspace-client.js +3 -4
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/webhooks/envelope.js +26 -0
- package/dist/cjs/types/webhooks/index.js +19 -0
- package/dist/cjs/types/webhooks/tasks.js +68 -0
- package/dist/cjs/types/webhooks/types.js +34 -0
- package/dist/cjs/utils/index.js +4 -1
- package/dist/cjs/utils/validators.js +7 -2
- package/dist/cjs/utils/webhook-parser.js +60 -0
- package/dist/esm/clients/app-client.js +18 -18
- package/dist/esm/clients/comment-client.js +4 -5
- package/dist/esm/clients/folder-client.js +4 -5
- package/dist/esm/clients/insights-client.js +7 -8
- package/dist/esm/clients/label-client.js +4 -5
- package/dist/esm/clients/project-client.js +9 -10
- package/dist/esm/clients/section-client.js +6 -7
- package/dist/esm/clients/task-client.js +7 -8
- package/dist/esm/clients/ui-extension-client.js +5 -6
- package/dist/esm/clients/workspace-client.js +4 -5
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/webhooks/envelope.js +23 -0
- package/dist/esm/types/webhooks/index.js +3 -0
- package/dist/esm/types/webhooks/tasks.js +65 -0
- package/dist/esm/types/webhooks/types.js +31 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/validators.js +5 -0
- package/dist/esm/utils/webhook-parser.js +56 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/webhooks/envelope.d.ts +34 -0
- package/dist/types/types/webhooks/index.d.ts +3 -0
- package/dist/types/types/webhooks/tasks.d.ts +981 -0
- package/dist/types/types/webhooks/types.d.ts +893 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/validators.d.ts +2 -0
- package/dist/types/utils/webhook-parser.d.ts +48 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskDeletedPayloadSchema = exports.TaskUncompletedPayloadSchema = exports.TaskCompletedPayloadSchema = exports.TaskUpdatedPayloadSchema = exports.TaskAddedPayloadSchema = exports.TaskUpdatedExtraSchema = exports.UpdateIntentSchema = exports.UPDATE_INTENTS = exports.TASK_WEBHOOK_EVENTS = exports.TaskWebhookEventEnum = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const types_1 = require("../tasks/types");
|
|
6
|
+
const envelope_1 = require("./envelope");
|
|
7
|
+
/**
|
|
8
|
+
* Enum-like object of task (`item:*`) webhook event names. Single source of
|
|
9
|
+
* truth for the discriminator values — `TASK_WEBHOOK_EVENTS` and every
|
|
10
|
+
* `z.literal()` below derive from it.
|
|
11
|
+
*/
|
|
12
|
+
exports.TaskWebhookEventEnum = {
|
|
13
|
+
Added: 'item:added',
|
|
14
|
+
Updated: 'item:updated',
|
|
15
|
+
Completed: 'item:completed',
|
|
16
|
+
Uncompleted: 'item:uncompleted',
|
|
17
|
+
Deleted: 'item:deleted',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Webhook events that carry a {@link Task} as their `eventData`.
|
|
21
|
+
*
|
|
22
|
+
* The on-the-wire event names remain `item:*` for historical reasons; the
|
|
23
|
+
* SDK types call them `Task*` to match the rest of the public API where the
|
|
24
|
+
* resource is named `Task`.
|
|
25
|
+
*/
|
|
26
|
+
exports.TASK_WEBHOOK_EVENTS = [
|
|
27
|
+
exports.TaskWebhookEventEnum.Added,
|
|
28
|
+
exports.TaskWebhookEventEnum.Updated,
|
|
29
|
+
exports.TaskWebhookEventEnum.Completed,
|
|
30
|
+
exports.TaskWebhookEventEnum.Uncompleted,
|
|
31
|
+
exports.TaskWebhookEventEnum.Deleted,
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Possible values for the `updateIntent` field on `item:updated`'s
|
|
35
|
+
* `eventDataExtra`. `item_updated` is the default; the others narrow the
|
|
36
|
+
* reason for the update (for example, a recurring completion or a change of
|
|
37
|
+
* assignee).
|
|
38
|
+
*
|
|
39
|
+
* @see https://developer.todoist.com/sync/v1/#webhooks (Events Extra)
|
|
40
|
+
*/
|
|
41
|
+
exports.UPDATE_INTENTS = [
|
|
42
|
+
'item_updated',
|
|
43
|
+
'item_completed',
|
|
44
|
+
'item_uncompleted',
|
|
45
|
+
'responsible_uid_changed',
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* An unrecognised value from a future backend release degrades gracefully to
|
|
49
|
+
* `'item_updated'` rather than crashing the whole payload parse.
|
|
50
|
+
*/
|
|
51
|
+
exports.UpdateIntentSchema = zod_1.z.enum(exports.UPDATE_INTENTS).catch('item_updated');
|
|
52
|
+
/**
|
|
53
|
+
* Extra info delivered alongside an `item:updated` event when the initiator
|
|
54
|
+
* is the acting user. Contains the pre-update task state plus the reason for
|
|
55
|
+
* the update — useful for diffing or for distinguishing manual edits from
|
|
56
|
+
* recurring-task completions.
|
|
57
|
+
*
|
|
58
|
+
* @see https://developer.todoist.com/sync/v1/#webhooks (Events Extra)
|
|
59
|
+
*/
|
|
60
|
+
exports.TaskUpdatedExtraSchema = zod_1.z.object({
|
|
61
|
+
oldItem: types_1.TaskSchema,
|
|
62
|
+
updateIntent: exports.UpdateIntentSchema,
|
|
63
|
+
});
|
|
64
|
+
exports.TaskAddedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Added), eventData: types_1.TaskSchema }));
|
|
65
|
+
exports.TaskUpdatedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Updated), eventData: types_1.TaskSchema, eventDataExtra: exports.TaskUpdatedExtraSchema.optional() }));
|
|
66
|
+
exports.TaskCompletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Completed), eventData: types_1.TaskSchema }));
|
|
67
|
+
exports.TaskUncompletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Uncompleted), eventData: types_1.TaskSchema }));
|
|
68
|
+
exports.TaskDeletedPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.literal(exports.TaskWebhookEventEnum.Deleted), eventData: types_1.TaskSchema }));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookEventSchema = exports.WebhookPayloadSchema = exports.UntypedWebhookPayloadSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const types_1 = require("../apps/types");
|
|
6
|
+
Object.defineProperty(exports, "WebhookEventSchema", { enumerable: true, get: function () { return types_1.WebhookEventSchema; } });
|
|
7
|
+
const envelope_1 = require("./envelope");
|
|
8
|
+
const tasks_1 = require("./tasks");
|
|
9
|
+
const untypedEventNames = types_1.WEBHOOK_EVENTS.filter((event) => !tasks_1.TASK_WEBHOOK_EVENTS.includes(event));
|
|
10
|
+
/**
|
|
11
|
+
* A single branch covering every event whose payload has not yet been typed
|
|
12
|
+
* per resource. Follow-up PRs will replace slices of this with dedicated
|
|
13
|
+
* variants (notes, projects, sections, labels, filters, reminders).
|
|
14
|
+
*/
|
|
15
|
+
exports.UntypedWebhookPayloadSchema = zod_1.z.object(Object.assign(Object.assign({}, envelope_1.BaseWebhookEnvelopeShape), { eventName: zod_1.z.enum(untypedEventNames), eventData: zod_1.z.unknown(), eventDataExtra: zod_1.z.unknown().optional() }));
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper schema for an incoming webhook payload.
|
|
18
|
+
*
|
|
19
|
+
* The backend sends snake_case keys and uses the public event form
|
|
20
|
+
* (`item:added`) in the `event_name` field, so consumers using
|
|
21
|
+
* `parseWebhookPayload` receive camelCase fields directly.
|
|
22
|
+
*
|
|
23
|
+
* Typed today: `item:*` events carry a parsed {@link Task}. Other events
|
|
24
|
+
* still expose `eventData` as `unknown`; they will be narrowed in follow-up
|
|
25
|
+
* PRs (notes, projects, sections, labels, filters, reminders).
|
|
26
|
+
*/
|
|
27
|
+
exports.WebhookPayloadSchema = zod_1.z.discriminatedUnion('eventName', [
|
|
28
|
+
tasks_1.TaskAddedPayloadSchema,
|
|
29
|
+
tasks_1.TaskUpdatedPayloadSchema,
|
|
30
|
+
tasks_1.TaskCompletedPayloadSchema,
|
|
31
|
+
tasks_1.TaskUncompletedPayloadSchema,
|
|
32
|
+
tasks_1.TaskDeletedPayloadSchema,
|
|
33
|
+
exports.UntypedWebhookPayloadSchema,
|
|
34
|
+
]);
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createCommand = exports.getSectionUrl = exports.getProjectUrl = exports.getTaskUrl = void 0;
|
|
17
|
+
exports.verifyWebhookSignature = exports.parseWebhookPayload = exports.createCommand = exports.getSectionUrl = exports.getProjectUrl = exports.getTaskUrl = void 0;
|
|
18
18
|
__exportStar(require("./colors"), exports);
|
|
19
19
|
__exportStar(require("./sanitization"), exports);
|
|
20
20
|
var url_helpers_1 = require("./url-helpers");
|
|
@@ -24,3 +24,6 @@ Object.defineProperty(exports, "getSectionUrl", { enumerable: true, get: functio
|
|
|
24
24
|
var sync_helpers_1 = require("./sync-helpers");
|
|
25
25
|
Object.defineProperty(exports, "createCommand", { enumerable: true, get: function () { return sync_helpers_1.createCommand; } });
|
|
26
26
|
__exportStar(require("./project-helpers"), exports);
|
|
27
|
+
var webhook_parser_1 = require("./webhook-parser");
|
|
28
|
+
Object.defineProperty(exports, "parseWebhookPayload", { enumerable: true, get: function () { return webhook_parser_1.parseWebhookPayload; } });
|
|
29
|
+
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return webhook_parser_1.verifyWebhookSignature; } });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
exports.validateUiExtensionArray = exports.validateUiExtension = exports.validateUserAuthorizationArray = exports.validateUserAuthorization = exports.validateAppInstallationArray = exports.validateAppInstallation = exports.validateAppWebhook = exports.validateAppByDistributionToken = exports.validateAppDistributionToken = exports.validateAppTestToken = exports.validateAppVerificationToken = exports.validateAppSecrets = exports.validateAppWithUserCount = exports.validateAppArray = exports.validateApp = exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = exports.validateNote = void 0;
|
|
4
|
+
exports.validateFolder = exports.validateCollaboratorStateArray = exports.validateCollaboratorState = exports.validateCollaboratorArray = exports.validateCollaborator = exports.validateFilterArray = exports.validateFilter = exports.validateMovedIdArray = exports.validateMovedId = exports.validateIdMappingArray = exports.validateIdMapping = exports.validateBackupArray = exports.validateBackup = exports.validateWorkspaceInsights = exports.validateProjectProgress = exports.validateProjectHealthContext = exports.validateProjectHealth = exports.validateProjectActivityStats = exports.validateWorkspaceUserTaskArray = exports.validateWorkspaceUserTask = exports.validateMemberActivityInfoArray = exports.validateMemberActivityInfo = exports.validateWorkspaceArray = exports.validateWorkspace = exports.validateJoinWorkspaceResult = exports.validateWorkspacePlanDetails = exports.validateWorkspaceInvitationArray = exports.validateWorkspaceInvitation = exports.validateWorkspaceUserArray = exports.validateWorkspaceUser = exports.validateAttachment = exports.validateActivityEventArray = exports.validateActivityEvent = exports.validateCurrentUser = exports.validateProductivityStats = exports.validateUserArray = exports.validateUser = exports.validateCommentArray = exports.validateComment = exports.validateLabelArray = exports.validateLabel = exports.validateSectionArray = exports.validateSection = exports.validateWorkspaceProjectArray = exports.validateWorkspaceProject = exports.validateProjectArray = exports.validateProject = exports.validateTaskArray = exports.validateTask = exports.IdSchema = void 0;
|
|
5
|
+
exports.validateUiExtensionArray = exports.validateUiExtension = exports.validateUserAuthorizationArray = exports.validateUserAuthorization = exports.validateAppInstallationArray = exports.validateAppInstallation = exports.validateAppWebhook = exports.validateAppByDistributionToken = exports.validateAppDistributionToken = exports.validateAppTestToken = exports.validateAppVerificationToken = exports.validateAppSecrets = exports.validateAppWithUserCount = exports.validateAppArray = exports.validateApp = exports.validateSuggestionArray = exports.validateSuggestion = exports.validateUserSettings = exports.validateSyncUser = exports.validateSyncWorkspaceArray = exports.validateSyncWorkspace = exports.validateLiveNotificationArray = exports.validateLiveNotification = exports.validateUserPlanLimits = exports.validateProjectViewOptionsDefaultsArray = exports.validateProjectViewOptionsDefaults = exports.validateViewOptionsArray = exports.validateViewOptions = exports.validateCompletedInfoArray = exports.validateCompletedInfo = exports.validateLocationReminderArray = exports.validateLocationReminder = exports.validateReminderArray = exports.validateReminder = exports.validateCalendarAccountArray = exports.validateCalendarAccount = exports.validateCalendarArray = exports.validateCalendar = exports.validateWorkspaceGoalArray = exports.validateWorkspaceGoal = exports.validateWorkspaceFilterArray = exports.validateWorkspaceFilter = exports.validateTooltips = exports.validateNoteArray = exports.validateNote = exports.validateFolderArray = void 0;
|
|
6
6
|
exports.parseSyncResponse = parseSyncResponse;
|
|
7
7
|
const zod_1 = require("zod");
|
|
8
8
|
const types_1 = require("../types/activity/types");
|
|
@@ -27,6 +27,11 @@ function createValidator(schema) {
|
|
|
27
27
|
validateArray: (input) => zod_1.z.array(schema).parse(input),
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
const TMP_ID_MESSAGE = 'This looks like a client-side placeholder — wait for sync to complete before calling the API.';
|
|
31
|
+
exports.IdSchema = zod_1.z
|
|
32
|
+
.string()
|
|
33
|
+
.min(1)
|
|
34
|
+
.refine((id) => !id.startsWith('tmp-'), { message: TMP_ID_MESSAGE });
|
|
30
35
|
// Entity validators
|
|
31
36
|
_a = createValidator(types_11.TaskSchema), exports.validateTask = _a.validate, exports.validateTaskArray = _a.validateArray;
|
|
32
37
|
/**
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseWebhookPayload = parseWebhookPayload;
|
|
4
|
+
exports.verifyWebhookSignature = verifyWebhookSignature;
|
|
5
|
+
const types_1 = require("../types/webhooks/types");
|
|
6
|
+
const case_conversion_1 = require("./case-conversion");
|
|
7
|
+
/**
|
|
8
|
+
* Parses an incoming webhook request body into a typed payload.
|
|
9
|
+
*
|
|
10
|
+
* The backend sends snake_case keys (e.g. `event_name`, `user_id`, `added_at`);
|
|
11
|
+
* this converts them to camelCase and validates against
|
|
12
|
+
* {@link WebhookPayloadSchema}. Event-specific `eventData` is returned as
|
|
13
|
+
* `unknown` for events that are not yet narrowed per-resource.
|
|
14
|
+
*
|
|
15
|
+
* Pass the parsed JSON body (or any unknown value) — validation throws on
|
|
16
|
+
* unexpected shape.
|
|
17
|
+
*/
|
|
18
|
+
function parseWebhookPayload(raw) {
|
|
19
|
+
return types_1.WebhookPayloadSchema.parse((0, case_conversion_1.camelCaseKeys)(raw));
|
|
20
|
+
}
|
|
21
|
+
const encoder = new TextEncoder();
|
|
22
|
+
function base64ToBytes(base64) {
|
|
23
|
+
const binary = atob(base64);
|
|
24
|
+
const bytes = new Uint8Array(binary.length);
|
|
25
|
+
for (let i = 0; i < binary.length; i++) {
|
|
26
|
+
bytes[i] = binary.charCodeAt(i);
|
|
27
|
+
}
|
|
28
|
+
return bytes;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Verifies a webhook request's HMAC signature.
|
|
32
|
+
*
|
|
33
|
+
* Todoist signs webhook deliveries with an HMAC-SHA256 of the raw request body
|
|
34
|
+
* using the app's `client_secret` as the key, base64-encoded in the
|
|
35
|
+
* `X-Todoist-Hmac-SHA256` header.
|
|
36
|
+
*
|
|
37
|
+
* Uses the Web Crypto API (`crypto.subtle`), which is available in Node ≥ 20,
|
|
38
|
+
* modern browsers, React Native (with polyfills), and edge runtimes. The
|
|
39
|
+
* comparison is constant-time.
|
|
40
|
+
*
|
|
41
|
+
* @returns `true` when the signature is valid, `false` otherwise. Never throws
|
|
42
|
+
* on malformed input.
|
|
43
|
+
*/
|
|
44
|
+
async function verifyWebhookSignature({ rawBody, signature, clientSecret, }) {
|
|
45
|
+
let provided;
|
|
46
|
+
try {
|
|
47
|
+
provided = base64ToBytes(signature);
|
|
48
|
+
}
|
|
49
|
+
catch (_a) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const key = await crypto.subtle.importKey('raw', encoder.encode(clientSecret), { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']);
|
|
53
|
+
const body = typeof rawBody === 'string' ? encoder.encode(rawBody) : rawBody;
|
|
54
|
+
try {
|
|
55
|
+
return await crypto.subtle.verify('HMAC', key, provided, body);
|
|
56
|
+
}
|
|
57
|
+
catch (_b) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -15,7 +15,7 @@ import { isSuccess, request } from '../transport/http-client.js';
|
|
|
15
15
|
import { webhookEventToWireName } from '../types/apps/index.js';
|
|
16
16
|
import { camelCaseKeys } from '../utils/case-conversion.js';
|
|
17
17
|
import { uploadMultipartFile } from '../utils/multipart-upload.js';
|
|
18
|
-
import { validateApp, validateAppArray, validateAppByDistributionToken, validateAppDistributionToken, validateAppInstallation, validateAppInstallationArray, validateAppSecrets, validateAppTestToken, validateAppVerificationToken, validateAppWebhook, validateAppWithUserCount, validateUserAuthorizationArray, } from '../utils/validators.js';
|
|
18
|
+
import { IdSchema, validateApp, validateAppArray, validateAppByDistributionToken, validateAppDistributionToken, validateAppInstallation, validateAppInstallationArray, validateAppSecrets, validateAppTestToken, validateAppVerificationToken, validateAppWebhook, validateAppWithUserCount, validateUserAuthorizationArray, } from '../utils/validators.js';
|
|
19
19
|
import { BaseClient } from './base-client.js';
|
|
20
20
|
/**
|
|
21
21
|
* Internal sub-client handling all developer-app management endpoints
|
|
@@ -38,7 +38,7 @@ export class AppClient extends BaseClient {
|
|
|
38
38
|
return validateAppArray(response.data);
|
|
39
39
|
}
|
|
40
40
|
async getApp(appId, requestId) {
|
|
41
|
-
|
|
41
|
+
IdSchema.parse(appId);
|
|
42
42
|
const response = await request({
|
|
43
43
|
httpMethod: 'GET',
|
|
44
44
|
baseUri: this.apiRootBase,
|
|
@@ -62,7 +62,7 @@ export class AppClient extends BaseClient {
|
|
|
62
62
|
return validateApp(response.data);
|
|
63
63
|
}
|
|
64
64
|
async updateApp(appId, args, requestId) {
|
|
65
|
-
|
|
65
|
+
IdSchema.parse(appId);
|
|
66
66
|
const { appTokenScopes } = args, rest = __rest(args, ["appTokenScopes"]);
|
|
67
67
|
const payload = Object.assign({}, rest);
|
|
68
68
|
if (appTokenScopes !== undefined) {
|
|
@@ -80,7 +80,7 @@ export class AppClient extends BaseClient {
|
|
|
80
80
|
return validateAppWithUserCount(response.data);
|
|
81
81
|
}
|
|
82
82
|
async deleteApp(appId, requestId) {
|
|
83
|
-
|
|
83
|
+
IdSchema.parse(appId);
|
|
84
84
|
const response = await request({
|
|
85
85
|
httpMethod: 'DELETE',
|
|
86
86
|
baseUri: this.apiRootBase,
|
|
@@ -92,7 +92,7 @@ export class AppClient extends BaseClient {
|
|
|
92
92
|
return isSuccess(response);
|
|
93
93
|
}
|
|
94
94
|
async getAppSecrets(appId, requestId) {
|
|
95
|
-
|
|
95
|
+
IdSchema.parse(appId);
|
|
96
96
|
const response = await request({
|
|
97
97
|
httpMethod: 'GET',
|
|
98
98
|
baseUri: this.apiRootBase,
|
|
@@ -104,7 +104,7 @@ export class AppClient extends BaseClient {
|
|
|
104
104
|
return validateAppSecrets(response.data);
|
|
105
105
|
}
|
|
106
106
|
async resetAppClientSecret(appId, requestId) {
|
|
107
|
-
|
|
107
|
+
IdSchema.parse(appId);
|
|
108
108
|
const response = await request({
|
|
109
109
|
httpMethod: 'DELETE',
|
|
110
110
|
baseUri: this.apiRootBase,
|
|
@@ -116,7 +116,7 @@ export class AppClient extends BaseClient {
|
|
|
116
116
|
return validateAppWithUserCount(response.data);
|
|
117
117
|
}
|
|
118
118
|
async revokeAppTokens(appId, requestId) {
|
|
119
|
-
|
|
119
|
+
IdSchema.parse(appId);
|
|
120
120
|
const response = await request({
|
|
121
121
|
httpMethod: 'DELETE',
|
|
122
122
|
baseUri: this.apiRootBase,
|
|
@@ -128,7 +128,7 @@ export class AppClient extends BaseClient {
|
|
|
128
128
|
return validateAppWithUserCount(response.data);
|
|
129
129
|
}
|
|
130
130
|
async uploadAppIcon({ appId, file, fileName = '', size = 'medium' }, requestId) {
|
|
131
|
-
|
|
131
|
+
IdSchema.parse(appId);
|
|
132
132
|
if (Buffer.isBuffer(file) && file.length === 0) {
|
|
133
133
|
throw new Error('Cannot upload empty image file');
|
|
134
134
|
}
|
|
@@ -145,7 +145,7 @@ export class AppClient extends BaseClient {
|
|
|
145
145
|
return validateAppWithUserCount(camelCaseKeys(data));
|
|
146
146
|
}
|
|
147
147
|
async getAppTestToken(appId, requestId) {
|
|
148
|
-
|
|
148
|
+
IdSchema.parse(appId);
|
|
149
149
|
const response = await request({
|
|
150
150
|
httpMethod: 'GET',
|
|
151
151
|
baseUri: this.apiRootBase,
|
|
@@ -157,7 +157,7 @@ export class AppClient extends BaseClient {
|
|
|
157
157
|
return validateAppTestToken(response.data);
|
|
158
158
|
}
|
|
159
159
|
async createAppTestToken(appId, requestId) {
|
|
160
|
-
|
|
160
|
+
IdSchema.parse(appId);
|
|
161
161
|
const response = await request({
|
|
162
162
|
httpMethod: 'PUT',
|
|
163
163
|
baseUri: this.apiRootBase,
|
|
@@ -169,7 +169,7 @@ export class AppClient extends BaseClient {
|
|
|
169
169
|
return validateAppTestToken(response.data);
|
|
170
170
|
}
|
|
171
171
|
async getAppDistributionToken(appId, requestId) {
|
|
172
|
-
|
|
172
|
+
IdSchema.parse(appId);
|
|
173
173
|
const response = await request({
|
|
174
174
|
httpMethod: 'GET',
|
|
175
175
|
baseUri: this.apiRootBase,
|
|
@@ -181,7 +181,7 @@ export class AppClient extends BaseClient {
|
|
|
181
181
|
return validateAppDistributionToken(response.data);
|
|
182
182
|
}
|
|
183
183
|
async getAppVerificationToken(appId, requestId) {
|
|
184
|
-
|
|
184
|
+
IdSchema.parse(appId);
|
|
185
185
|
const response = await request({
|
|
186
186
|
httpMethod: 'GET',
|
|
187
187
|
baseUri: this.apiRootBase,
|
|
@@ -193,7 +193,7 @@ export class AppClient extends BaseClient {
|
|
|
193
193
|
return validateAppVerificationToken(response.data);
|
|
194
194
|
}
|
|
195
195
|
async resetAppVerificationToken(appId, requestId) {
|
|
196
|
-
|
|
196
|
+
IdSchema.parse(appId);
|
|
197
197
|
const response = await request({
|
|
198
198
|
httpMethod: 'DELETE',
|
|
199
199
|
baseUri: this.apiRootBase,
|
|
@@ -218,7 +218,7 @@ export class AppClient extends BaseClient {
|
|
|
218
218
|
}
|
|
219
219
|
// --- App webhooks ---
|
|
220
220
|
async getAppWebhook(appId, requestId) {
|
|
221
|
-
|
|
221
|
+
IdSchema.parse(appId);
|
|
222
222
|
const response = await request({
|
|
223
223
|
httpMethod: 'GET',
|
|
224
224
|
baseUri: this.apiRootBase,
|
|
@@ -243,7 +243,7 @@ export class AppClient extends BaseClient {
|
|
|
243
243
|
return validateAppWebhook(response.data);
|
|
244
244
|
}
|
|
245
245
|
async deleteAppWebhook(appId, requestId) {
|
|
246
|
-
|
|
246
|
+
IdSchema.parse(appId);
|
|
247
247
|
const response = await request({
|
|
248
248
|
httpMethod: 'DELETE',
|
|
249
249
|
baseUri: this.apiRootBase,
|
|
@@ -279,7 +279,7 @@ export class AppClient extends BaseClient {
|
|
|
279
279
|
return validateAppInstallation(response.data);
|
|
280
280
|
}
|
|
281
281
|
async getAppInstallation(installationId, requestId) {
|
|
282
|
-
|
|
282
|
+
IdSchema.parse(installationId);
|
|
283
283
|
const response = await request({
|
|
284
284
|
httpMethod: 'GET',
|
|
285
285
|
baseUri: this.apiRootBase,
|
|
@@ -291,7 +291,7 @@ export class AppClient extends BaseClient {
|
|
|
291
291
|
return validateAppInstallation(response.data);
|
|
292
292
|
}
|
|
293
293
|
async updateAppInstallation(installationId, args, requestId) {
|
|
294
|
-
|
|
294
|
+
IdSchema.parse(installationId);
|
|
295
295
|
const response = await request({
|
|
296
296
|
httpMethod: 'POST',
|
|
297
297
|
baseUri: this.apiRootBase,
|
|
@@ -304,7 +304,7 @@ export class AppClient extends BaseClient {
|
|
|
304
304
|
return validateAppInstallation(response.data);
|
|
305
305
|
}
|
|
306
306
|
async uninstallApp(installationId, requestId) {
|
|
307
|
-
|
|
307
|
+
IdSchema.parse(installationId);
|
|
308
308
|
const response = await request({
|
|
309
309
|
httpMethod: 'DELETE',
|
|
310
310
|
baseUri: this.apiRootBase,
|
|
@@ -9,11 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { z } from 'zod';
|
|
13
12
|
import { ENDPOINT_REST_COMMENTS } from '../consts/endpoints.js';
|
|
14
13
|
import { isSuccess, request } from '../transport/http-client.js';
|
|
15
14
|
import { generatePath } from '../utils/request-helpers.js';
|
|
16
|
-
import { validateComment, validateCommentArray } from '../utils/validators.js';
|
|
15
|
+
import { IdSchema, validateComment, validateCommentArray } from '../utils/validators.js';
|
|
17
16
|
import { BaseClient } from './base-client.js';
|
|
18
17
|
/**
|
|
19
18
|
* Internal sub-client handling all comment-domain endpoints.
|
|
@@ -37,7 +36,7 @@ export class CommentClient extends BaseClient {
|
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
async getComment(id) {
|
|
40
|
-
|
|
39
|
+
IdSchema.parse(id);
|
|
41
40
|
const response = await request({
|
|
42
41
|
httpMethod: 'GET',
|
|
43
42
|
baseUri: this.syncApiBase,
|
|
@@ -61,7 +60,7 @@ export class CommentClient extends BaseClient {
|
|
|
61
60
|
return validateComment(response.data);
|
|
62
61
|
}
|
|
63
62
|
async updateComment(id, args, requestId) {
|
|
64
|
-
|
|
63
|
+
IdSchema.parse(id);
|
|
65
64
|
const response = await request({
|
|
66
65
|
httpMethod: 'POST',
|
|
67
66
|
baseUri: this.syncApiBase,
|
|
@@ -74,7 +73,7 @@ export class CommentClient extends BaseClient {
|
|
|
74
73
|
return validateComment(response.data);
|
|
75
74
|
}
|
|
76
75
|
async deleteComment(id, requestId) {
|
|
77
|
-
|
|
76
|
+
IdSchema.parse(id);
|
|
78
77
|
const response = await request({
|
|
79
78
|
httpMethod: 'DELETE',
|
|
80
79
|
baseUri: this.syncApiBase,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { ENDPOINT_REST_FOLDERS } from '../consts/endpoints.js';
|
|
3
2
|
import { isSuccess, request } from '../transport/http-client.js';
|
|
4
3
|
import { generatePath } from '../utils/request-helpers.js';
|
|
5
|
-
import { validateFolder, validateFolderArray } from '../utils/validators.js';
|
|
4
|
+
import { IdSchema, validateFolder, validateFolderArray } from '../utils/validators.js';
|
|
6
5
|
import { BaseClient } from './base-client.js';
|
|
7
6
|
/**
|
|
8
7
|
* Internal sub-client handling all folder-domain endpoints.
|
|
@@ -26,7 +25,7 @@ export class FolderClient extends BaseClient {
|
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
27
|
async getFolder(id) {
|
|
29
|
-
|
|
28
|
+
IdSchema.parse(id);
|
|
30
29
|
const response = await request({
|
|
31
30
|
httpMethod: 'GET',
|
|
32
31
|
baseUri: this.syncApiBase,
|
|
@@ -49,7 +48,7 @@ export class FolderClient extends BaseClient {
|
|
|
49
48
|
return validateFolder(response.data);
|
|
50
49
|
}
|
|
51
50
|
async updateFolder(id, args, requestId) {
|
|
52
|
-
|
|
51
|
+
IdSchema.parse(id);
|
|
53
52
|
const response = await request({
|
|
54
53
|
httpMethod: 'POST',
|
|
55
54
|
baseUri: this.syncApiBase,
|
|
@@ -62,7 +61,7 @@ export class FolderClient extends BaseClient {
|
|
|
62
61
|
return validateFolder(response.data);
|
|
63
62
|
}
|
|
64
63
|
async deleteFolder(id, requestId) {
|
|
65
|
-
|
|
64
|
+
IdSchema.parse(id);
|
|
66
65
|
const response = await request({
|
|
67
66
|
httpMethod: 'DELETE',
|
|
68
67
|
baseUri: this.syncApiBase,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { getProjectInsightsActivityStatsEndpoint, getProjectInsightsHealthAnalyzeEndpoint, getProjectInsightsHealthContextEndpoint, getProjectInsightsHealthEndpoint, getProjectInsightsProgressEndpoint, getWorkspaceInsightsEndpoint, } from '../consts/endpoints.js';
|
|
3
2
|
import { request } from '../transport/http-client.js';
|
|
4
|
-
import { validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, } from '../utils/validators.js';
|
|
3
|
+
import { IdSchema, validateProjectActivityStats, validateProjectHealth, validateProjectHealthContext, validateProjectProgress, validateWorkspaceInsights, } from '../utils/validators.js';
|
|
5
4
|
import { BaseClient } from './base-client.js';
|
|
6
5
|
/**
|
|
7
6
|
* Internal sub-client handling all insights-domain endpoints
|
|
@@ -13,7 +12,7 @@ import { BaseClient } from './base-client.js';
|
|
|
13
12
|
*/
|
|
14
13
|
export class InsightsClient extends BaseClient {
|
|
15
14
|
async getProjectActivityStats(projectId, args = {}) {
|
|
16
|
-
|
|
15
|
+
IdSchema.parse(projectId);
|
|
17
16
|
const response = await request({
|
|
18
17
|
httpMethod: 'GET',
|
|
19
18
|
baseUri: this.syncApiBase,
|
|
@@ -25,7 +24,7 @@ export class InsightsClient extends BaseClient {
|
|
|
25
24
|
return validateProjectActivityStats(response.data);
|
|
26
25
|
}
|
|
27
26
|
async getProjectHealth(projectId) {
|
|
28
|
-
|
|
27
|
+
IdSchema.parse(projectId);
|
|
29
28
|
const response = await request({
|
|
30
29
|
httpMethod: 'GET',
|
|
31
30
|
baseUri: this.syncApiBase,
|
|
@@ -36,7 +35,7 @@ export class InsightsClient extends BaseClient {
|
|
|
36
35
|
return validateProjectHealth(response.data);
|
|
37
36
|
}
|
|
38
37
|
async getProjectHealthContext(projectId) {
|
|
39
|
-
|
|
38
|
+
IdSchema.parse(projectId);
|
|
40
39
|
const response = await request({
|
|
41
40
|
httpMethod: 'GET',
|
|
42
41
|
baseUri: this.syncApiBase,
|
|
@@ -47,7 +46,7 @@ export class InsightsClient extends BaseClient {
|
|
|
47
46
|
return validateProjectHealthContext(response.data);
|
|
48
47
|
}
|
|
49
48
|
async getProjectProgress(projectId) {
|
|
50
|
-
|
|
49
|
+
IdSchema.parse(projectId);
|
|
51
50
|
const response = await request({
|
|
52
51
|
httpMethod: 'GET',
|
|
53
52
|
baseUri: this.syncApiBase,
|
|
@@ -58,7 +57,7 @@ export class InsightsClient extends BaseClient {
|
|
|
58
57
|
return validateProjectProgress(response.data);
|
|
59
58
|
}
|
|
60
59
|
async getWorkspaceInsights(workspaceId, args = {}) {
|
|
61
|
-
|
|
60
|
+
IdSchema.parse(workspaceId);
|
|
62
61
|
const response = await request({
|
|
63
62
|
httpMethod: 'GET',
|
|
64
63
|
baseUri: this.syncApiBase,
|
|
@@ -70,7 +69,7 @@ export class InsightsClient extends BaseClient {
|
|
|
70
69
|
return validateWorkspaceInsights(response.data);
|
|
71
70
|
}
|
|
72
71
|
async analyzeProjectHealth(projectId, requestId) {
|
|
73
|
-
|
|
72
|
+
IdSchema.parse(projectId);
|
|
74
73
|
const response = await request({
|
|
75
74
|
httpMethod: 'POST',
|
|
76
75
|
baseUri: this.syncApiBase,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { ENDPOINT_REST_LABELS, ENDPOINT_REST_LABELS_SEARCH, ENDPOINT_REST_LABELS_SHARED, ENDPOINT_REST_LABELS_SHARED_REMOVE, ENDPOINT_REST_LABELS_SHARED_RENAME, } from '../consts/endpoints.js';
|
|
3
2
|
import { isSuccess, request } from '../transport/http-client.js';
|
|
4
3
|
import { generatePath } from '../utils/request-helpers.js';
|
|
5
|
-
import { validateLabel, validateLabelArray } from '../utils/validators.js';
|
|
4
|
+
import { IdSchema, validateLabel, validateLabelArray } from '../utils/validators.js';
|
|
6
5
|
import { BaseClient } from './base-client.js';
|
|
7
6
|
/**
|
|
8
7
|
* Internal sub-client handling all label-domain endpoints.
|
|
@@ -12,7 +11,7 @@ import { BaseClient } from './base-client.js';
|
|
|
12
11
|
*/
|
|
13
12
|
export class LabelClient extends BaseClient {
|
|
14
13
|
async getLabel(id) {
|
|
15
|
-
|
|
14
|
+
IdSchema.parse(id);
|
|
16
15
|
const response = await request({
|
|
17
16
|
httpMethod: 'GET',
|
|
18
17
|
baseUri: this.syncApiBase,
|
|
@@ -63,7 +62,7 @@ export class LabelClient extends BaseClient {
|
|
|
63
62
|
return validateLabel(response.data);
|
|
64
63
|
}
|
|
65
64
|
async updateLabel(id, args, requestId) {
|
|
66
|
-
|
|
65
|
+
IdSchema.parse(id);
|
|
67
66
|
const response = await request({
|
|
68
67
|
httpMethod: 'POST',
|
|
69
68
|
baseUri: this.syncApiBase,
|
|
@@ -76,7 +75,7 @@ export class LabelClient extends BaseClient {
|
|
|
76
75
|
return validateLabel(response.data);
|
|
77
76
|
}
|
|
78
77
|
async deleteLabel(id, requestId) {
|
|
79
|
-
|
|
78
|
+
IdSchema.parse(id);
|
|
80
79
|
const response = await request({
|
|
81
80
|
httpMethod: 'DELETE',
|
|
82
81
|
baseUri: this.syncApiBase,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { ENDPOINT_REST_PROJECTS, ENDPOINT_REST_PROJECTS_ARCHIVED, ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT, ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL, ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE, ENDPOINT_REST_PROJECTS_PERMISSIONS, ENDPOINT_REST_PROJECTS_SEARCH, ENDPOINT_REST_PROJECT_COLLABORATORS, ENDPOINT_REST_PROJECT_FULL, ENDPOINT_REST_PROJECT_JOIN, PROJECT_ARCHIVE, PROJECT_UNARCHIVE, } from '../consts/endpoints.js';
|
|
3
2
|
import { isSuccess, request } from '../transport/http-client.js';
|
|
4
3
|
import { generatePath } from '../utils/request-helpers.js';
|
|
5
|
-
import { validateCollaboratorArray, validateCollaboratorStateArray, validateCommentArray, validateFolder, validateNoteArray, validateProject, validateProjectArray, validateSectionArray, validateTaskArray, validateUserArray, validateWorkspaceProject, validateWorkspaceProjectArray, } from '../utils/validators.js';
|
|
4
|
+
import { IdSchema, validateCollaboratorArray, validateCollaboratorStateArray, validateCommentArray, validateFolder, validateNoteArray, validateProject, validateProjectArray, validateSectionArray, validateTaskArray, validateUserArray, validateWorkspaceProject, validateWorkspaceProjectArray, } from '../utils/validators.js';
|
|
6
5
|
import { BaseClient } from './base-client.js';
|
|
7
6
|
/**
|
|
8
7
|
* Internal sub-client handling all project-domain endpoints.
|
|
@@ -12,7 +11,7 @@ import { BaseClient } from './base-client.js';
|
|
|
12
11
|
*/
|
|
13
12
|
export class ProjectClient extends BaseClient {
|
|
14
13
|
async getProject(id) {
|
|
15
|
-
|
|
14
|
+
IdSchema.parse(id);
|
|
16
15
|
const response = await request({
|
|
17
16
|
httpMethod: 'GET',
|
|
18
17
|
baseUri: this.syncApiBase,
|
|
@@ -77,7 +76,7 @@ export class ProjectClient extends BaseClient {
|
|
|
77
76
|
return validateProject(response.data);
|
|
78
77
|
}
|
|
79
78
|
async updateProject(id, args, requestId) {
|
|
80
|
-
|
|
79
|
+
IdSchema.parse(id);
|
|
81
80
|
const response = await request({
|
|
82
81
|
httpMethod: 'POST',
|
|
83
82
|
baseUri: this.syncApiBase,
|
|
@@ -90,7 +89,7 @@ export class ProjectClient extends BaseClient {
|
|
|
90
89
|
return validateProject(response.data);
|
|
91
90
|
}
|
|
92
91
|
async deleteProject(id, requestId) {
|
|
93
|
-
|
|
92
|
+
IdSchema.parse(id);
|
|
94
93
|
const response = await request({
|
|
95
94
|
httpMethod: 'DELETE',
|
|
96
95
|
baseUri: this.syncApiBase,
|
|
@@ -102,7 +101,7 @@ export class ProjectClient extends BaseClient {
|
|
|
102
101
|
return isSuccess(response);
|
|
103
102
|
}
|
|
104
103
|
async archiveProject(id, requestId) {
|
|
105
|
-
|
|
104
|
+
IdSchema.parse(id);
|
|
106
105
|
const response = await request({
|
|
107
106
|
httpMethod: 'POST',
|
|
108
107
|
baseUri: this.syncApiBase,
|
|
@@ -114,7 +113,7 @@ export class ProjectClient extends BaseClient {
|
|
|
114
113
|
return validateProject(response.data);
|
|
115
114
|
}
|
|
116
115
|
async unarchiveProject(id, requestId) {
|
|
117
|
-
|
|
116
|
+
IdSchema.parse(id);
|
|
118
117
|
const response = await request({
|
|
119
118
|
httpMethod: 'POST',
|
|
120
119
|
baseUri: this.syncApiBase,
|
|
@@ -171,7 +170,7 @@ export class ProjectClient extends BaseClient {
|
|
|
171
170
|
return data;
|
|
172
171
|
}
|
|
173
172
|
async getFullProject(id, args = {}) {
|
|
174
|
-
|
|
173
|
+
IdSchema.parse(id);
|
|
175
174
|
const { data } = await request({
|
|
176
175
|
httpMethod: 'GET',
|
|
177
176
|
baseUri: this.syncApiBase,
|
|
@@ -190,7 +189,7 @@ export class ProjectClient extends BaseClient {
|
|
|
190
189
|
};
|
|
191
190
|
}
|
|
192
191
|
async joinProject(id, requestId) {
|
|
193
|
-
|
|
192
|
+
IdSchema.parse(id);
|
|
194
193
|
const { data } = await request({
|
|
195
194
|
httpMethod: 'POST',
|
|
196
195
|
baseUri: this.syncApiBase,
|
|
@@ -211,7 +210,7 @@ export class ProjectClient extends BaseClient {
|
|
|
211
210
|
};
|
|
212
211
|
}
|
|
213
212
|
async getProjectCollaborators(projectId, args = {}) {
|
|
214
|
-
|
|
213
|
+
IdSchema.parse(projectId);
|
|
215
214
|
const { data: { results, nextCursor }, } = await request({
|
|
216
215
|
httpMethod: 'GET',
|
|
217
216
|
baseUri: this.syncApiBase,
|