@doist/todoist-api-typescript 5.1.2 → 5.2.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/TodoistApi.d.ts +16 -0
- package/dist/TodoistApi.js +59 -15
- package/dist/authentication.js +7 -8
- package/dist/consts/endpoints.d.ts +2 -0
- package/dist/consts/endpoints.js +5 -3
- package/dist/restClient.js +5 -6
- package/dist/testUtils/asserts.js +1 -2
- package/dist/testUtils/mocks.d.ts +0 -1
- package/dist/testUtils/mocks.js +18 -9
- package/dist/testUtils/testDefaults.d.ts +26 -25
- package/dist/testUtils/testDefaults.js +2 -0
- package/dist/types/entities.d.ts +134 -698
- package/dist/types/entities.js +5 -1
- package/dist/types/errors.d.ts +2 -2
- package/dist/utils/colors.d.ts +141 -1
- package/dist/utils/colors.js +4 -4
- package/dist/utils/processing-helpers.js +1 -2
- package/dist/utils/sanitization.js +2 -3
- package/dist/utils/urlHelpers.d.ts +8 -0
- package/dist/utils/urlHelpers.js +15 -3
- package/dist/utils/validators.js +14 -15
- package/package.json +15 -15
package/dist/TodoistApi.d.ts
CHANGED
|
@@ -164,6 +164,22 @@ export declare class TodoistApi {
|
|
|
164
164
|
* @returns A promise that resolves to `true` if successful.
|
|
165
165
|
*/
|
|
166
166
|
deleteProject(id: string, requestId?: string): Promise<boolean>;
|
|
167
|
+
/**
|
|
168
|
+
* Archives a project by its ID.
|
|
169
|
+
*
|
|
170
|
+
* @param id - The unique identifier of the project to archive.
|
|
171
|
+
* @param requestId - Optional custom identifier for the request.
|
|
172
|
+
* @returns A promise that resolves to the updated project.
|
|
173
|
+
*/
|
|
174
|
+
archiveProject(id: string, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
175
|
+
/**
|
|
176
|
+
* Unarchives a project by its ID.
|
|
177
|
+
*
|
|
178
|
+
* @param id - The unique identifier of the project to unarchive.
|
|
179
|
+
* @param requestId - Optional custom identifier for the request.
|
|
180
|
+
* @returns A promise that resolves to the updated project.
|
|
181
|
+
*/
|
|
182
|
+
unarchiveProject(id: string, requestId?: string): Promise<PersonalProject | WorkspaceProject>;
|
|
167
183
|
/**
|
|
168
184
|
* Retrieves a list of collaborators for a specific project.
|
|
169
185
|
*
|
package/dist/TodoistApi.js
CHANGED
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -128,10 +128,10 @@ var TodoistApi = /** @class */ (function () {
|
|
|
128
128
|
* @param args - Filter parameters such as project ID, label ID, or due date.
|
|
129
129
|
* @returns A promise that resolves to an array of tasks.
|
|
130
130
|
*/
|
|
131
|
-
TodoistApi.prototype.getTasks = function (
|
|
132
|
-
|
|
133
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
+
TodoistApi.prototype.getTasks = function () {
|
|
132
|
+
return __awaiter(this, arguments, void 0, function (args) {
|
|
134
133
|
var _a, results, nextCursor;
|
|
134
|
+
if (args === void 0) { args = {}; }
|
|
135
135
|
return __generator(this, function (_b) {
|
|
136
136
|
switch (_b.label) {
|
|
137
137
|
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_TASKS, this.authToken, args)];
|
|
@@ -282,9 +282,9 @@ var TodoistApi = /** @class */ (function () {
|
|
|
282
282
|
* @returns - A promise that resolves to an array of the updated tasks.
|
|
283
283
|
*/
|
|
284
284
|
TodoistApi.prototype.moveTasks = function (ids, args, requestId) {
|
|
285
|
-
var _a;
|
|
286
285
|
return __awaiter(this, void 0, void 0, function () {
|
|
287
286
|
var commands, syncRequest, response, syncTasks;
|
|
287
|
+
var _a;
|
|
288
288
|
return __generator(this, function (_b) {
|
|
289
289
|
switch (_b.label) {
|
|
290
290
|
case 0:
|
|
@@ -417,10 +417,10 @@ var TodoistApi = /** @class */ (function () {
|
|
|
417
417
|
* @param args - Optional filters for retrieving projects.
|
|
418
418
|
* @returns A promise that resolves to an array of projects.
|
|
419
419
|
*/
|
|
420
|
-
TodoistApi.prototype.getProjects = function (
|
|
421
|
-
|
|
422
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
420
|
+
TodoistApi.prototype.getProjects = function () {
|
|
421
|
+
return __awaiter(this, arguments, void 0, function (args) {
|
|
423
422
|
var _a, results, nextCursor;
|
|
423
|
+
if (args === void 0) { args = {}; }
|
|
424
424
|
return __generator(this, function (_b) {
|
|
425
425
|
switch (_b.label) {
|
|
426
426
|
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_PROJECTS, this.authToken, args)];
|
|
@@ -499,6 +499,50 @@ var TodoistApi = /** @class */ (function () {
|
|
|
499
499
|
});
|
|
500
500
|
});
|
|
501
501
|
};
|
|
502
|
+
/**
|
|
503
|
+
* Archives a project by its ID.
|
|
504
|
+
*
|
|
505
|
+
* @param id - The unique identifier of the project to archive.
|
|
506
|
+
* @param requestId - Optional custom identifier for the request.
|
|
507
|
+
* @returns A promise that resolves to the updated project.
|
|
508
|
+
*/
|
|
509
|
+
TodoistApi.prototype.archiveProject = function (id, requestId) {
|
|
510
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
511
|
+
var response;
|
|
512
|
+
return __generator(this, function (_a) {
|
|
513
|
+
switch (_a.label) {
|
|
514
|
+
case 0:
|
|
515
|
+
zod_1.z.string().parse(id);
|
|
516
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_ARCHIVE), this.authToken, undefined, requestId)];
|
|
517
|
+
case 1:
|
|
518
|
+
response = _a.sent();
|
|
519
|
+
return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Unarchives a project by its ID.
|
|
526
|
+
*
|
|
527
|
+
* @param id - The unique identifier of the project to unarchive.
|
|
528
|
+
* @param requestId - Optional custom identifier for the request.
|
|
529
|
+
* @returns A promise that resolves to the updated project.
|
|
530
|
+
*/
|
|
531
|
+
TodoistApi.prototype.unarchiveProject = function (id, requestId) {
|
|
532
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
533
|
+
var response;
|
|
534
|
+
return __generator(this, function (_a) {
|
|
535
|
+
switch (_a.label) {
|
|
536
|
+
case 0:
|
|
537
|
+
zod_1.z.string().parse(id);
|
|
538
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_UNARCHIVE), this.authToken, undefined, requestId)];
|
|
539
|
+
case 1:
|
|
540
|
+
response = _a.sent();
|
|
541
|
+
return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
};
|
|
502
546
|
/**
|
|
503
547
|
* Retrieves a list of collaborators for a specific project.
|
|
504
548
|
*
|
|
@@ -506,10 +550,10 @@ var TodoistApi = /** @class */ (function () {
|
|
|
506
550
|
* @param args - Optional parameters to filter collaborators.
|
|
507
551
|
* @returns A promise that resolves to an array of collaborators for the project.
|
|
508
552
|
*/
|
|
509
|
-
TodoistApi.prototype.getProjectCollaborators = function (
|
|
510
|
-
|
|
511
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
553
|
+
TodoistApi.prototype.getProjectCollaborators = function (projectId_1) {
|
|
554
|
+
return __awaiter(this, arguments, void 0, function (projectId, args) {
|
|
512
555
|
var _a, results, nextCursor;
|
|
556
|
+
if (args === void 0) { args = {}; }
|
|
513
557
|
return __generator(this, function (_b) {
|
|
514
558
|
switch (_b.label) {
|
|
515
559
|
case 0:
|
|
@@ -660,10 +704,10 @@ var TodoistApi = /** @class */ (function () {
|
|
|
660
704
|
* @param args - Optional filter parameters.
|
|
661
705
|
* @returns A promise that resolves to an array of labels.
|
|
662
706
|
*/
|
|
663
|
-
TodoistApi.prototype.getLabels = function (
|
|
664
|
-
|
|
665
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
707
|
+
TodoistApi.prototype.getLabels = function () {
|
|
708
|
+
return __awaiter(this, arguments, void 0, function (args) {
|
|
666
709
|
var _a, results, nextCursor;
|
|
710
|
+
if (args === void 0) { args = {}; }
|
|
667
711
|
return __generator(this, function (_b) {
|
|
668
712
|
switch (_b.label) {
|
|
669
713
|
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.syncApiBase, endpoints_1.ENDPOINT_REST_LABELS, this.authToken, args)];
|
package/dist/authentication.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -36,7 +36,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.getAuthStateParameter = getAuthStateParameter;
|
|
40
|
+
exports.getAuthorizationUrl = getAuthorizationUrl;
|
|
41
|
+
exports.getAuthToken = getAuthToken;
|
|
42
|
+
exports.revokeAuthToken = revokeAuthToken;
|
|
40
43
|
var restClient_1 = require("./restClient");
|
|
41
44
|
var uuid_1 = require("uuid");
|
|
42
45
|
var types_1 = require("./types");
|
|
@@ -57,7 +60,6 @@ var endpoints_1 = require("./consts/endpoints");
|
|
|
57
60
|
function getAuthStateParameter() {
|
|
58
61
|
return (0, uuid_1.v4)();
|
|
59
62
|
}
|
|
60
|
-
exports.getAuthStateParameter = getAuthStateParameter;
|
|
61
63
|
/**
|
|
62
64
|
* Generates the authorization URL for the OAuth2 flow.
|
|
63
65
|
*
|
|
@@ -81,7 +83,6 @@ function getAuthorizationUrl(clientId, permissions, state, baseUrl) {
|
|
|
81
83
|
var scope = permissions.join(',');
|
|
82
84
|
return "".concat((0, endpoints_1.getAuthBaseUri)(baseUrl)).concat(endpoints_1.ENDPOINT_AUTHORIZATION, "?client_id=").concat(clientId, "&scope=").concat(scope, "&state=").concat(state);
|
|
83
85
|
}
|
|
84
|
-
exports.getAuthorizationUrl = getAuthorizationUrl;
|
|
85
86
|
/**
|
|
86
87
|
* Exchanges an authorization code for an access token.
|
|
87
88
|
*
|
|
@@ -98,9 +99,9 @@ exports.getAuthorizationUrl = getAuthorizationUrl;
|
|
|
98
99
|
* @throws {@link TodoistRequestError} If the token exchange fails
|
|
99
100
|
*/
|
|
100
101
|
function getAuthToken(args, baseUrl) {
|
|
101
|
-
var _a;
|
|
102
102
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
103
|
var response;
|
|
104
|
+
var _a;
|
|
104
105
|
return __generator(this, function (_b) {
|
|
105
106
|
switch (_b.label) {
|
|
106
107
|
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', (0, endpoints_1.getAuthBaseUri)(baseUrl), endpoints_1.ENDPOINT_GET_TOKEN, undefined, args)];
|
|
@@ -114,7 +115,6 @@ function getAuthToken(args, baseUrl) {
|
|
|
114
115
|
});
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
|
-
exports.getAuthToken = getAuthToken;
|
|
118
118
|
/**
|
|
119
119
|
* Revokes an access token, making it invalid for future use.
|
|
120
120
|
*
|
|
@@ -143,4 +143,3 @@ function revokeAuthToken(args, baseUrl) {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
exports.revokeAuthToken = revokeAuthToken;
|
|
@@ -17,6 +17,8 @@ export declare const ENDPOINT_REST_COMMENTS = "comments";
|
|
|
17
17
|
export declare const ENDPOINT_REST_TASK_CLOSE = "close";
|
|
18
18
|
export declare const ENDPOINT_REST_TASK_REOPEN = "reopen";
|
|
19
19
|
export declare const ENDPOINT_REST_PROJECT_COLLABORATORS = "collaborators";
|
|
20
|
+
export declare const PROJECT_ARCHIVE = "archive";
|
|
21
|
+
export declare const PROJECT_UNARCHIVE = "unarchive";
|
|
20
22
|
export declare const ENDPOINT_SYNC_QUICK_ADD: string;
|
|
21
23
|
export declare const ENDPOINT_SYNC = "sync";
|
|
22
24
|
export declare const ENDPOINT_AUTHORIZATION = "authorize";
|
package/dist/consts/endpoints.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENDPOINT_REVOKE_TOKEN = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.
|
|
3
|
+
exports.ENDPOINT_REVOKE_TOKEN = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = exports.ENDPOINT_SYNC = exports.ENDPOINT_SYNC_QUICK_ADD = exports.PROJECT_UNARCHIVE = exports.PROJECT_ARCHIVE = exports.ENDPOINT_REST_PROJECT_COLLABORATORS = exports.ENDPOINT_REST_TASK_REOPEN = exports.ENDPOINT_REST_TASK_CLOSE = exports.ENDPOINT_REST_COMMENTS = exports.ENDPOINT_REST_LABELS_SHARED_REMOVE = exports.ENDPOINT_REST_LABELS_SHARED_RENAME = exports.ENDPOINT_REST_LABELS_SHARED = exports.ENDPOINT_REST_LABELS = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE = exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS = exports.API_BASE_URI = exports.API_VERSION = exports.TODOIST_WEB_URI = void 0;
|
|
4
|
+
exports.getSyncBaseUri = getSyncBaseUri;
|
|
5
|
+
exports.getAuthBaseUri = getAuthBaseUri;
|
|
4
6
|
var BASE_URI = 'https://api.todoist.com';
|
|
5
7
|
var TODOIST_URI = 'https://todoist.com';
|
|
6
8
|
exports.TODOIST_WEB_URI = 'https://app.todoist.com/app';
|
|
@@ -13,12 +15,10 @@ function getSyncBaseUri(domainBase) {
|
|
|
13
15
|
if (domainBase === void 0) { domainBase = BASE_URI; }
|
|
14
16
|
return new URL(exports.API_BASE_URI, domainBase).toString();
|
|
15
17
|
}
|
|
16
|
-
exports.getSyncBaseUri = getSyncBaseUri;
|
|
17
18
|
function getAuthBaseUri(domainBase) {
|
|
18
19
|
if (domainBase === void 0) { domainBase = TODOIST_URI; }
|
|
19
20
|
return new URL(API_AUTHORIZATION_BASE_URI, domainBase).toString();
|
|
20
21
|
}
|
|
21
|
-
exports.getAuthBaseUri = getAuthBaseUri;
|
|
22
22
|
exports.ENDPOINT_REST_TASKS = 'tasks';
|
|
23
23
|
exports.ENDPOINT_REST_TASKS_FILTER = exports.ENDPOINT_REST_TASKS + '/filter';
|
|
24
24
|
exports.ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE = exports.ENDPOINT_REST_TASKS + '/completed/by_completion_date';
|
|
@@ -33,6 +33,8 @@ exports.ENDPOINT_REST_COMMENTS = 'comments';
|
|
|
33
33
|
exports.ENDPOINT_REST_TASK_CLOSE = 'close';
|
|
34
34
|
exports.ENDPOINT_REST_TASK_REOPEN = 'reopen';
|
|
35
35
|
exports.ENDPOINT_REST_PROJECT_COLLABORATORS = 'collaborators';
|
|
36
|
+
exports.PROJECT_ARCHIVE = 'archive';
|
|
37
|
+
exports.PROJECT_UNARCHIVE = 'unarchive';
|
|
36
38
|
exports.ENDPOINT_SYNC_QUICK_ADD = exports.ENDPOINT_REST_TASKS + '/quick';
|
|
37
39
|
exports.ENDPOINT_SYNC = 'sync';
|
|
38
40
|
exports.ENDPOINT_AUTHORIZATION = 'authorize';
|
package/dist/restClient.js
CHANGED
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -50,7 +50,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.
|
|
53
|
+
exports.paramsSerializer = paramsSerializer;
|
|
54
|
+
exports.isSuccess = isSuccess;
|
|
55
|
+
exports.request = request;
|
|
54
56
|
// eslint-disable-next-line import/no-named-as-default
|
|
55
57
|
var axios_1 = __importDefault(require("axios"));
|
|
56
58
|
var axios_case_converter_1 = __importDefault(require("axios-case-converter"));
|
|
@@ -74,7 +76,6 @@ function paramsSerializer(params) {
|
|
|
74
76
|
});
|
|
75
77
|
return qs.toString();
|
|
76
78
|
}
|
|
77
|
-
exports.paramsSerializer = paramsSerializer;
|
|
78
79
|
var defaultHeaders = {
|
|
79
80
|
'Content-Type': 'application/json',
|
|
80
81
|
};
|
|
@@ -122,7 +123,6 @@ function getAxiosClient(baseURL, apiToken, requestId) {
|
|
|
122
123
|
function isSuccess(response) {
|
|
123
124
|
return response.status >= 200 && response.status < 300;
|
|
124
125
|
}
|
|
125
|
-
exports.isSuccess = isSuccess;
|
|
126
126
|
function request(httpMethod, baseUri, relativePath, apiToken, payload, requestId, hasSyncCommands) {
|
|
127
127
|
return __awaiter(this, void 0, void 0, function () {
|
|
128
128
|
var originalStack, axiosClient, _a, error_1;
|
|
@@ -168,4 +168,3 @@ function request(httpMethod, baseUri, relativePath, apiToken, payload, requestId
|
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
exports.request = request;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertInstance =
|
|
3
|
+
exports.assertInstance = assertInstance;
|
|
4
4
|
// Has to use 'any' to express constructor type
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
6
|
function assertInstance(value, type) {
|
|
@@ -9,4 +9,3 @@ function assertInstance(value, type) {
|
|
|
9
9
|
}
|
|
10
10
|
throw new TypeError("Unexpected type ".concat(typeof value));
|
|
11
11
|
}
|
|
12
|
-
exports.assertInstance = assertInstance;
|
package/dist/testUtils/mocks.js
CHANGED
|
@@ -15,19 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.setupRestClientMock =
|
|
36
|
+
exports.setupRestClientMock = setupRestClientMock;
|
|
27
37
|
var restClient = __importStar(require("../restClient"));
|
|
28
38
|
function setupRestClientMock(responseData, status) {
|
|
29
39
|
if (status === void 0) { status = 200; }
|
|
30
40
|
var response = { status: status, data: responseData };
|
|
31
41
|
return jest.spyOn(restClient, 'request').mockResolvedValue(response);
|
|
32
42
|
}
|
|
33
|
-
exports.setupRestClientMock = setupRestClientMock;
|
|
@@ -23,7 +23,6 @@ export declare const DEFAULT_TASK: Task;
|
|
|
23
23
|
export declare const INVALID_TASK: {
|
|
24
24
|
due: string;
|
|
25
25
|
url: string;
|
|
26
|
-
labels: string[];
|
|
27
26
|
id: string;
|
|
28
27
|
userId: string;
|
|
29
28
|
projectId: string;
|
|
@@ -32,6 +31,7 @@ export declare const INVALID_TASK: {
|
|
|
32
31
|
addedByUid: string | null;
|
|
33
32
|
assignedByUid: string | null;
|
|
34
33
|
responsibleUid: string | null;
|
|
34
|
+
labels: string[];
|
|
35
35
|
deadline: {
|
|
36
36
|
date: string;
|
|
37
37
|
lang: string;
|
|
@@ -59,45 +59,46 @@ export declare const INVALID_PROJECT: {
|
|
|
59
59
|
name: number;
|
|
60
60
|
url: string;
|
|
61
61
|
id: string;
|
|
62
|
-
parentId: string | null;
|
|
63
|
-
isDeleted: boolean;
|
|
64
|
-
updatedAt: string | null;
|
|
65
|
-
childOrder: number;
|
|
66
|
-
description: string;
|
|
67
|
-
isCollapsed: boolean;
|
|
68
62
|
canAssignTasks: boolean;
|
|
63
|
+
childOrder: number;
|
|
69
64
|
color: string;
|
|
70
65
|
createdAt: string | null;
|
|
71
66
|
isArchived: boolean;
|
|
67
|
+
isDeleted: boolean;
|
|
72
68
|
isFavorite: boolean;
|
|
73
69
|
isFrozen: boolean;
|
|
70
|
+
updatedAt: string | null;
|
|
74
71
|
viewStyle: string;
|
|
75
72
|
defaultOrder: number;
|
|
73
|
+
description: string;
|
|
74
|
+
isCollapsed: boolean;
|
|
76
75
|
isShared: boolean;
|
|
76
|
+
parentId: string | null;
|
|
77
77
|
inboxProject: boolean;
|
|
78
78
|
};
|
|
79
79
|
export declare const PROJECT_WITH_OPTIONALS_AS_NULL: PersonalProject;
|
|
80
80
|
export declare const DEFAULT_SECTION: Section;
|
|
81
81
|
export declare const INVALID_SECTION: {
|
|
82
82
|
projectId: undefined;
|
|
83
|
+
url: string;
|
|
83
84
|
id: string;
|
|
84
85
|
userId: string;
|
|
85
|
-
isDeleted: boolean;
|
|
86
86
|
addedAt: string;
|
|
87
87
|
updatedAt: string;
|
|
88
|
-
isCollapsed: boolean;
|
|
89
|
-
isArchived: boolean;
|
|
90
|
-
name: string;
|
|
91
88
|
archivedAt: string | null;
|
|
89
|
+
name: string;
|
|
92
90
|
sectionOrder: number;
|
|
91
|
+
isArchived: boolean;
|
|
92
|
+
isDeleted: boolean;
|
|
93
|
+
isCollapsed: boolean;
|
|
93
94
|
};
|
|
94
95
|
export declare const DEFAULT_LABEL: Label;
|
|
95
96
|
export declare const INVALID_LABEL: {
|
|
96
97
|
isFavorite: string;
|
|
97
98
|
id: string;
|
|
98
|
-
color: string;
|
|
99
|
-
name: string;
|
|
100
99
|
order: number | null;
|
|
100
|
+
name: string;
|
|
101
|
+
color: string;
|
|
101
102
|
};
|
|
102
103
|
export declare const DEFAULT_USER: User;
|
|
103
104
|
export declare const INVALID_USER: {
|
|
@@ -109,7 +110,6 @@ export declare const DEFAULT_ATTACHMENT: Attachment;
|
|
|
109
110
|
export declare const INVALID_ATTACHMENT: {
|
|
110
111
|
uploadState: string;
|
|
111
112
|
resourceType: string;
|
|
112
|
-
url?: string | null | undefined;
|
|
113
113
|
fileName?: string | null | undefined;
|
|
114
114
|
fileSize?: number | null | undefined;
|
|
115
115
|
fileType?: string | null | undefined;
|
|
@@ -118,6 +118,7 @@ export declare const INVALID_ATTACHMENT: {
|
|
|
118
118
|
image?: string | null | undefined;
|
|
119
119
|
imageWidth?: number | null | undefined;
|
|
120
120
|
imageHeight?: number | null | undefined;
|
|
121
|
+
url?: string | null | undefined;
|
|
121
122
|
title?: string | null | undefined;
|
|
122
123
|
};
|
|
123
124
|
export declare const DEFAULT_RAW_COMMENT: RawComment;
|
|
@@ -125,12 +126,10 @@ export declare const DEFAULT_COMMENT: {
|
|
|
125
126
|
taskId: string | undefined;
|
|
126
127
|
itemId: undefined;
|
|
127
128
|
id: string;
|
|
128
|
-
isDeleted: boolean;
|
|
129
129
|
content: string;
|
|
130
130
|
postedAt: string;
|
|
131
131
|
fileAttachment: {
|
|
132
132
|
resourceType: string;
|
|
133
|
-
url?: string | null | undefined;
|
|
134
133
|
fileName?: string | null | undefined;
|
|
135
134
|
fileSize?: number | null | undefined;
|
|
136
135
|
fileType?: string | null | undefined;
|
|
@@ -140,11 +139,13 @@ export declare const DEFAULT_COMMENT: {
|
|
|
140
139
|
image?: string | null | undefined;
|
|
141
140
|
imageWidth?: number | null | undefined;
|
|
142
141
|
imageHeight?: number | null | undefined;
|
|
142
|
+
url?: string | null | undefined;
|
|
143
143
|
title?: string | null | undefined;
|
|
144
144
|
} | null;
|
|
145
145
|
postedUid: string;
|
|
146
146
|
uidsToNotify: string[] | null;
|
|
147
147
|
reactions: Record<string, string[]> | null;
|
|
148
|
+
isDeleted: boolean;
|
|
148
149
|
projectId?: string | undefined;
|
|
149
150
|
};
|
|
150
151
|
export declare const INVALID_COMMENT: {
|
|
@@ -154,7 +155,6 @@ export declare const INVALID_COMMENT: {
|
|
|
154
155
|
postedAt: string;
|
|
155
156
|
fileAttachment: {
|
|
156
157
|
resourceType: string;
|
|
157
|
-
url?: string | null | undefined;
|
|
158
158
|
fileName?: string | null | undefined;
|
|
159
159
|
fileSize?: number | null | undefined;
|
|
160
160
|
fileType?: string | null | undefined;
|
|
@@ -164,25 +164,24 @@ export declare const INVALID_COMMENT: {
|
|
|
164
164
|
image?: string | null | undefined;
|
|
165
165
|
imageWidth?: number | null | undefined;
|
|
166
166
|
imageHeight?: number | null | undefined;
|
|
167
|
+
url?: string | null | undefined;
|
|
167
168
|
title?: string | null | undefined;
|
|
168
169
|
} | null;
|
|
169
170
|
postedUid: string;
|
|
170
171
|
uidsToNotify: string[] | null;
|
|
171
172
|
reactions: Record<string, string[]> | null;
|
|
172
|
-
projectId?: string | undefined;
|
|
173
173
|
itemId?: string | undefined;
|
|
174
|
+
projectId?: string | undefined;
|
|
174
175
|
};
|
|
175
176
|
export declare const RAW_COMMENT_WITH_OPTIONALS_AS_NULL_TASK: RawComment;
|
|
176
177
|
export declare const COMMENT_WITH_OPTIONALS_AS_NULL_TASK: {
|
|
177
178
|
taskId: string | undefined;
|
|
178
179
|
itemId: undefined;
|
|
179
180
|
id: string;
|
|
180
|
-
isDeleted: boolean;
|
|
181
181
|
content: string;
|
|
182
182
|
postedAt: string;
|
|
183
183
|
fileAttachment: {
|
|
184
184
|
resourceType: string;
|
|
185
|
-
url?: string | null | undefined;
|
|
186
185
|
fileName?: string | null | undefined;
|
|
187
186
|
fileSize?: number | null | undefined;
|
|
188
187
|
fileType?: string | null | undefined;
|
|
@@ -192,11 +191,13 @@ export declare const COMMENT_WITH_OPTIONALS_AS_NULL_TASK: {
|
|
|
192
191
|
image?: string | null | undefined;
|
|
193
192
|
imageWidth?: number | null | undefined;
|
|
194
193
|
imageHeight?: number | null | undefined;
|
|
194
|
+
url?: string | null | undefined;
|
|
195
195
|
title?: string | null | undefined;
|
|
196
196
|
} | null;
|
|
197
197
|
postedUid: string;
|
|
198
198
|
uidsToNotify: string[] | null;
|
|
199
199
|
reactions: Record<string, string[]> | null;
|
|
200
|
+
isDeleted: boolean;
|
|
200
201
|
projectId?: string | undefined;
|
|
201
202
|
};
|
|
202
203
|
export declare const RAW_COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL: RawComment;
|
|
@@ -204,12 +205,10 @@ export declare const COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL: {
|
|
|
204
205
|
taskId: string | undefined;
|
|
205
206
|
itemId: undefined;
|
|
206
207
|
id: string;
|
|
207
|
-
isDeleted: boolean;
|
|
208
208
|
content: string;
|
|
209
209
|
postedAt: string;
|
|
210
210
|
fileAttachment: {
|
|
211
211
|
resourceType: string;
|
|
212
|
-
url?: string | null | undefined;
|
|
213
212
|
fileName?: string | null | undefined;
|
|
214
213
|
fileSize?: number | null | undefined;
|
|
215
214
|
fileType?: string | null | undefined;
|
|
@@ -219,23 +218,23 @@ export declare const COMMENT_WITH_ATTACHMENT_WITH_OPTIONALS_AS_NULL: {
|
|
|
219
218
|
image?: string | null | undefined;
|
|
220
219
|
imageWidth?: number | null | undefined;
|
|
221
220
|
imageHeight?: number | null | undefined;
|
|
221
|
+
url?: string | null | undefined;
|
|
222
222
|
title?: string | null | undefined;
|
|
223
223
|
} | null;
|
|
224
224
|
postedUid: string;
|
|
225
225
|
uidsToNotify: string[] | null;
|
|
226
226
|
reactions: Record<string, string[]> | null;
|
|
227
|
+
isDeleted: boolean;
|
|
227
228
|
projectId?: string | undefined;
|
|
228
229
|
};
|
|
229
230
|
export declare const RAW_COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT: RawComment;
|
|
230
231
|
export declare const COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT: {
|
|
231
232
|
taskId: undefined;
|
|
232
233
|
id: string;
|
|
233
|
-
isDeleted: boolean;
|
|
234
234
|
content: string;
|
|
235
235
|
postedAt: string;
|
|
236
236
|
fileAttachment: {
|
|
237
237
|
resourceType: string;
|
|
238
|
-
url?: string | null | undefined;
|
|
239
238
|
fileName?: string | null | undefined;
|
|
240
239
|
fileSize?: number | null | undefined;
|
|
241
240
|
fileType?: string | null | undefined;
|
|
@@ -245,11 +244,13 @@ export declare const COMMENT_WITH_OPTIONALS_AS_NULL_PROJECT: {
|
|
|
245
244
|
image?: string | null | undefined;
|
|
246
245
|
imageWidth?: number | null | undefined;
|
|
247
246
|
imageHeight?: number | null | undefined;
|
|
247
|
+
url?: string | null | undefined;
|
|
248
248
|
title?: string | null | undefined;
|
|
249
249
|
} | null;
|
|
250
250
|
postedUid: string;
|
|
251
251
|
uidsToNotify: string[] | null;
|
|
252
252
|
reactions: Record<string, string[]> | null;
|
|
253
|
-
|
|
253
|
+
isDeleted: boolean;
|
|
254
254
|
itemId?: string | undefined;
|
|
255
|
+
projectId?: string | undefined;
|
|
255
256
|
};
|
|
@@ -46,6 +46,7 @@ var DEFAULT_IS_COLLAPSED = false;
|
|
|
46
46
|
// URL constants using the helper functions
|
|
47
47
|
var DEFAULT_TASK_URL = (0, urlHelpers_1.getTaskUrl)(exports.DEFAULT_TASK_ID, exports.DEFAULT_TASK_CONTENT);
|
|
48
48
|
var DEFAULT_PROJECT_URL = (0, urlHelpers_1.getProjectUrl)(exports.DEFAULT_PROJECT_ID, exports.DEFAULT_PROJECT_NAME);
|
|
49
|
+
var DEFAULT_SECTION_URL = (0, urlHelpers_1.getSectionUrl)(DEFAULT_SECTION_ID, DEFAULT_SECTION_NAME);
|
|
49
50
|
exports.DEFAULT_AUTH_TOKEN = 'AToken';
|
|
50
51
|
exports.DEFAULT_REQUEST_ID = 'ARequestID';
|
|
51
52
|
exports.INVALID_ENTITY_ID = 1234;
|
|
@@ -154,6 +155,7 @@ exports.DEFAULT_SECTION = {
|
|
|
154
155
|
isArchived: false,
|
|
155
156
|
isDeleted: false,
|
|
156
157
|
isCollapsed: false,
|
|
158
|
+
url: DEFAULT_SECTION_URL,
|
|
157
159
|
};
|
|
158
160
|
exports.INVALID_SECTION = __assign(__assign({}, exports.DEFAULT_SECTION), { projectId: undefined });
|
|
159
161
|
exports.DEFAULT_LABEL = {
|