@doist/todoist-api-typescript 1.5.0 → 1.6.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/TodoistApi.js +30 -22
- package/dist/authentication.js +1 -1
- package/dist/index.js +5 -1
- package/dist/restClient.d.ts +1 -1
- package/dist/restClient.js +10 -12
- package/dist/testUtils/asserts.js +1 -1
- package/dist/testUtils/mocks.js +6 -3
- package/dist/types/entities.d.ts +17 -17
- package/dist/types/entities.js +1 -1
- package/dist/types/index.js +5 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/sanitization.js +1 -1
- package/dist/utils/taskConverters.js +2 -2
- package/package.json +26 -28
package/dist/TodoistApi.js
CHANGED
|
@@ -35,17 +35,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
39
|
exports.TodoistApi = void 0;
|
|
43
40
|
var entities_1 = require("./types/entities");
|
|
44
41
|
var restClient_1 = require("./restClient");
|
|
45
42
|
var taskConverters_1 = require("./utils/taskConverters");
|
|
46
|
-
var url_join_1 = __importDefault(require("url-join"));
|
|
47
43
|
var endpoints_1 = require("./consts/endpoints");
|
|
48
44
|
var validators_1 = require("./utils/validators");
|
|
45
|
+
/**
|
|
46
|
+
* Joins path segments using `/` separator.
|
|
47
|
+
* @param segments A list of **valid** path segments.
|
|
48
|
+
* @returns A joined path.
|
|
49
|
+
*/
|
|
50
|
+
function generatePath() {
|
|
51
|
+
var segments = [];
|
|
52
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
53
|
+
segments[_i] = arguments[_i];
|
|
54
|
+
}
|
|
55
|
+
return segments.join('/');
|
|
56
|
+
}
|
|
49
57
|
var TodoistApi = /** @class */ (function () {
|
|
50
58
|
function TodoistApi(authToken) {
|
|
51
59
|
this.authToken = authToken;
|
|
@@ -57,7 +65,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
57
65
|
switch (_a.label) {
|
|
58
66
|
case 0:
|
|
59
67
|
entities_1.Int.check(id);
|
|
60
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, (
|
|
68
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id)), this.authToken)];
|
|
61
69
|
case 1:
|
|
62
70
|
response = _a.sent();
|
|
63
71
|
return [2 /*return*/, (0, validators_1.validateTask)(response.data)];
|
|
@@ -112,7 +120,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
112
120
|
switch (_a.label) {
|
|
113
121
|
case 0:
|
|
114
122
|
entities_1.Int.check(id);
|
|
115
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, (
|
|
123
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id)), this.authToken, args, requestId)];
|
|
116
124
|
case 1:
|
|
117
125
|
response = _a.sent();
|
|
118
126
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -127,7 +135,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
127
135
|
switch (_a.label) {
|
|
128
136
|
case 0:
|
|
129
137
|
entities_1.Int.check(id);
|
|
130
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, (
|
|
138
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id), endpoints_1.ENDPOINT_REST_TASK_CLOSE), this.authToken, undefined, requestId)];
|
|
131
139
|
case 1:
|
|
132
140
|
response = _a.sent();
|
|
133
141
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -142,7 +150,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
142
150
|
switch (_a.label) {
|
|
143
151
|
case 0:
|
|
144
152
|
entities_1.Int.check(id);
|
|
145
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, (
|
|
153
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id), endpoints_1.ENDPOINT_REST_TASK_REOPEN), this.authToken, undefined, requestId)];
|
|
146
154
|
case 1:
|
|
147
155
|
response = _a.sent();
|
|
148
156
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -157,7 +165,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
157
165
|
switch (_a.label) {
|
|
158
166
|
case 0:
|
|
159
167
|
entities_1.Int.check(id);
|
|
160
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, (
|
|
168
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id)), this.authToken, undefined, requestId)];
|
|
161
169
|
case 1:
|
|
162
170
|
response = _a.sent();
|
|
163
171
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -172,7 +180,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
172
180
|
switch (_a.label) {
|
|
173
181
|
case 0:
|
|
174
182
|
entities_1.Int.check(id);
|
|
175
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, (
|
|
183
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(id)), this.authToken)];
|
|
176
184
|
case 1:
|
|
177
185
|
response = _a.sent();
|
|
178
186
|
return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
|
|
@@ -213,7 +221,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
213
221
|
switch (_a.label) {
|
|
214
222
|
case 0:
|
|
215
223
|
entities_1.Int.check(id);
|
|
216
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, (
|
|
224
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(id)), this.authToken, args, requestId)];
|
|
217
225
|
case 1:
|
|
218
226
|
response = _a.sent();
|
|
219
227
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -228,7 +236,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
228
236
|
switch (_a.label) {
|
|
229
237
|
case 0:
|
|
230
238
|
entities_1.Int.check(id);
|
|
231
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, (
|
|
239
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(id)), this.authToken, requestId)];
|
|
232
240
|
case 1:
|
|
233
241
|
response = _a.sent();
|
|
234
242
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -243,7 +251,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
243
251
|
switch (_a.label) {
|
|
244
252
|
case 0:
|
|
245
253
|
entities_1.Int.check(projectId);
|
|
246
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, (
|
|
254
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(projectId), endpoints_1.ENDPOINT_REST_PROJECT_COLLABORATORS), this.authToken)];
|
|
247
255
|
case 1:
|
|
248
256
|
response = _a.sent();
|
|
249
257
|
return [2 /*return*/, (0, validators_1.validateUserArray)(response.data)];
|
|
@@ -271,7 +279,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
271
279
|
switch (_a.label) {
|
|
272
280
|
case 0:
|
|
273
281
|
entities_1.Int.check(id);
|
|
274
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, (
|
|
282
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, String(id)), this.authToken)];
|
|
275
283
|
case 1:
|
|
276
284
|
response = _a.sent();
|
|
277
285
|
return [2 /*return*/, (0, validators_1.validateSection)(response.data)];
|
|
@@ -299,7 +307,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
299
307
|
switch (_a.label) {
|
|
300
308
|
case 0:
|
|
301
309
|
entities_1.Int.check(id);
|
|
302
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, (
|
|
310
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, String(id)), this.authToken, args, requestId)];
|
|
303
311
|
case 1:
|
|
304
312
|
response = _a.sent();
|
|
305
313
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -314,7 +322,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
314
322
|
switch (_a.label) {
|
|
315
323
|
case 0:
|
|
316
324
|
entities_1.Int.check(id);
|
|
317
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, (
|
|
325
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, String(id)), this.authToken, undefined, requestId)];
|
|
318
326
|
case 1:
|
|
319
327
|
response = _a.sent();
|
|
320
328
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -329,7 +337,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
329
337
|
switch (_a.label) {
|
|
330
338
|
case 0:
|
|
331
339
|
entities_1.Int.check(id);
|
|
332
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, (
|
|
340
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_LABELS, String(id)), this.authToken)];
|
|
333
341
|
case 1:
|
|
334
342
|
response = _a.sent();
|
|
335
343
|
return [2 /*return*/, (0, validators_1.validateLabel)(response.data)];
|
|
@@ -370,7 +378,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
370
378
|
switch (_a.label) {
|
|
371
379
|
case 0:
|
|
372
380
|
entities_1.Int.check(id);
|
|
373
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, (
|
|
381
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_LABELS, String(id)), this.authToken, args, requestId)];
|
|
374
382
|
case 1:
|
|
375
383
|
response = _a.sent();
|
|
376
384
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -385,7 +393,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
385
393
|
switch (_a.label) {
|
|
386
394
|
case 0:
|
|
387
395
|
entities_1.Int.check(id);
|
|
388
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, (
|
|
396
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_LABELS, String(id)), this.authToken, undefined, requestId)];
|
|
389
397
|
case 1:
|
|
390
398
|
response = _a.sent();
|
|
391
399
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -413,7 +421,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
413
421
|
switch (_a.label) {
|
|
414
422
|
case 0:
|
|
415
423
|
entities_1.Int.check(id);
|
|
416
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, (
|
|
424
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, String(id)), this.authToken)];
|
|
417
425
|
case 1:
|
|
418
426
|
response = _a.sent();
|
|
419
427
|
return [2 /*return*/, (0, validators_1.validateComment)(response.data)];
|
|
@@ -441,7 +449,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
441
449
|
switch (_a.label) {
|
|
442
450
|
case 0:
|
|
443
451
|
entities_1.Int.check(id);
|
|
444
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, (
|
|
452
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, String(id)), this.authToken, args, requestId)];
|
|
445
453
|
case 1:
|
|
446
454
|
response = _a.sent();
|
|
447
455
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -456,7 +464,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
456
464
|
switch (_a.label) {
|
|
457
465
|
case 0:
|
|
458
466
|
entities_1.Int.check(id);
|
|
459
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, (
|
|
467
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', endpoints_1.API_REST_BASE_URI, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, String(id)), this.authToken, undefined, requestId)];
|
|
460
468
|
case 1:
|
|
461
469
|
response = _a.sent();
|
|
462
470
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
package/dist/authentication.js
CHANGED
|
@@ -50,7 +50,7 @@ function getAuthorizationUrl(clientId, permissions, state) {
|
|
|
50
50
|
throw new Error('At least one scope value should be passed for permissions.');
|
|
51
51
|
}
|
|
52
52
|
var scope = permissions.join(',');
|
|
53
|
-
return ""
|
|
53
|
+
return "".concat(endpoints_1.API_AUTHORIZATION_BASE_URI).concat(endpoints_1.ENDPOINT_AUTHORIZATION, "?client_id=").concat(clientId, "&scope=").concat(scope, "&state=").concat(state);
|
|
54
54
|
}
|
|
55
55
|
exports.getAuthorizationUrl = getAuthorizationUrl;
|
|
56
56
|
function getAuthToken(args) {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/restClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { HttpMethod } from './types/http';
|
|
3
3
|
export declare function isSuccess(response: AxiosResponse): boolean;
|
|
4
|
-
export declare function request<T
|
|
4
|
+
export declare function request<T>(httpMethod: HttpMethod, baseUri: string, relativePath: string, apiToken?: string, payload?: unknown, requestId?: string): Promise<AxiosResponse<T>>;
|
package/dist/restClient.js
CHANGED
|
@@ -53,7 +53,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
exports.request = exports.isSuccess = void 0;
|
|
54
54
|
var axios_1 = __importDefault(require("axios"));
|
|
55
55
|
var axios_case_converter_1 = __importDefault(require("axios-case-converter"));
|
|
56
|
-
var url_join_1 = __importDefault(require("url-join"));
|
|
57
56
|
var errors_1 = require("./types/errors");
|
|
58
57
|
var uuid_1 = require("uuid");
|
|
59
58
|
var axios_retry_1 = __importDefault(require("axios-retry"));
|
|
@@ -61,7 +60,7 @@ var defaultHeaders = {
|
|
|
61
60
|
'Content-Type': 'application/json',
|
|
62
61
|
};
|
|
63
62
|
function getAuthHeader(apiKey) {
|
|
64
|
-
return "Bearer "
|
|
63
|
+
return "Bearer ".concat(apiKey);
|
|
65
64
|
}
|
|
66
65
|
function isNetworkError(error) {
|
|
67
66
|
return Boolean(!error.response && error.code !== 'ECONNABORTED');
|
|
@@ -70,8 +69,7 @@ function getRetryDelay(retryCount) {
|
|
|
70
69
|
return retryCount === 1 ? 0 : 500;
|
|
71
70
|
}
|
|
72
71
|
function isAxiosError(error) {
|
|
73
|
-
|
|
74
|
-
return Boolean((_a = error) === null || _a === void 0 ? void 0 : _a.isAxiosError);
|
|
72
|
+
return Boolean(error === null || error === void 0 ? void 0 : error.isAxiosError);
|
|
75
73
|
}
|
|
76
74
|
function getTodoistRequestError(error, originalStack) {
|
|
77
75
|
var requestError = new errors_1.TodoistRequestError(error.message);
|
|
@@ -82,14 +80,14 @@ function getTodoistRequestError(error, originalStack) {
|
|
|
82
80
|
}
|
|
83
81
|
return requestError;
|
|
84
82
|
}
|
|
85
|
-
function getRequestConfiguration(apiToken, requestId) {
|
|
83
|
+
function getRequestConfiguration(baseURL, apiToken, requestId) {
|
|
86
84
|
var authHeader = apiToken ? { Authorization: getAuthHeader(apiToken) } : undefined;
|
|
87
85
|
var requestIdHeader = requestId ? { 'X-Request-Id': requestId } : undefined;
|
|
88
86
|
var headers = __assign(__assign(__assign({}, defaultHeaders), authHeader), requestIdHeader);
|
|
89
|
-
return { headers: headers };
|
|
87
|
+
return { baseURL: baseURL, headers: headers };
|
|
90
88
|
}
|
|
91
|
-
function getAxiosClient(apiToken, requestId) {
|
|
92
|
-
var configuration = getRequestConfiguration(apiToken, requestId);
|
|
89
|
+
function getAxiosClient(baseURL, apiToken, requestId) {
|
|
90
|
+
var configuration = getRequestConfiguration(baseURL, apiToken, requestId);
|
|
93
91
|
var client = (0, axios_case_converter_1.default)(axios_1.default.create(configuration));
|
|
94
92
|
(0, axios_retry_1.default)(client, {
|
|
95
93
|
retries: 3,
|
|
@@ -115,7 +113,7 @@ function request(httpMethod, baseUri, relativePath, apiToken, payload, requestId
|
|
|
115
113
|
if (httpMethod === 'POST' && !requestId) {
|
|
116
114
|
requestId = (0, uuid_1.v4)();
|
|
117
115
|
}
|
|
118
|
-
axiosClient = getAxiosClient(apiToken, requestId);
|
|
116
|
+
axiosClient = getAxiosClient(baseUri, apiToken, requestId);
|
|
119
117
|
_a = httpMethod;
|
|
120
118
|
switch (_a) {
|
|
121
119
|
case 'GET': return [3 /*break*/, 2];
|
|
@@ -123,11 +121,11 @@ function request(httpMethod, baseUri, relativePath, apiToken, payload, requestId
|
|
|
123
121
|
case 'DELETE': return [3 /*break*/, 6];
|
|
124
122
|
}
|
|
125
123
|
return [3 /*break*/, 8];
|
|
126
|
-
case 2: return [4 /*yield*/, axiosClient.get(
|
|
124
|
+
case 2: return [4 /*yield*/, axiosClient.get(relativePath, { params: payload })];
|
|
127
125
|
case 3: return [2 /*return*/, _b.sent()];
|
|
128
|
-
case 4: return [4 /*yield*/, axiosClient.post(
|
|
126
|
+
case 4: return [4 /*yield*/, axiosClient.post(relativePath, payload)];
|
|
129
127
|
case 5: return [2 /*return*/, _b.sent()];
|
|
130
|
-
case 6: return [4 /*yield*/, axiosClient.delete(
|
|
128
|
+
case 6: return [4 /*yield*/, axiosClient.delete(relativePath)];
|
|
131
129
|
case 7: return [2 /*return*/, _b.sent()];
|
|
132
130
|
case 8: return [3 /*break*/, 10];
|
|
133
131
|
case 9:
|
|
@@ -45,7 +45,7 @@ function assertInstance(value, type) {
|
|
|
45
45
|
if (value instanceof type) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
throw new TypeError("Unexpected type "
|
|
48
|
+
throw new TypeError("Unexpected type ".concat(typeof value));
|
|
49
49
|
}
|
|
50
50
|
exports.assertInstance = assertInstance;
|
|
51
51
|
function assertInputValidationError(apiCall) {
|
package/dist/testUtils/mocks.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -20,11 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
24
|
};
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
26
|
exports.setupRestClientMock = void 0;
|
|
23
|
-
var jest_mock_extended_1 = require("jest-mock-extended");
|
|
24
27
|
var restClient = __importStar(require("../restClient"));
|
|
25
28
|
function setupRestClientMock(responseData, status) {
|
|
26
29
|
if (status === void 0) { status = 200; }
|
|
27
|
-
var response =
|
|
30
|
+
var response = { status: status, data: responseData };
|
|
28
31
|
return jest.spyOn(restClient, 'request').mockResolvedValue(response);
|
|
29
32
|
}
|
|
30
33
|
exports.setupRestClientMock = setupRestClientMock;
|
package/dist/types/entities.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Boolean, Number as NumberRunType, String, Array, Record, Static, Partial, Literal } from 'runtypes';
|
|
1
|
+
import { Boolean, Number as NumberRunType, String, Array, Record, Static, Partial, Literal, Union } from 'runtypes';
|
|
2
2
|
export declare const Int: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
3
3
|
export declare type TodoistEntity = {
|
|
4
4
|
id: number;
|
|
@@ -9,16 +9,16 @@ export declare type OrderedEntity = TodoistEntity & {
|
|
|
9
9
|
export declare type EntityInHierarchy = OrderedEntity & {
|
|
10
10
|
parentId?: number;
|
|
11
11
|
};
|
|
12
|
-
export declare const DueDate: import("runtypes").
|
|
12
|
+
export declare const DueDate: import("runtypes").Intersect<[Record<{
|
|
13
13
|
recurring: Boolean;
|
|
14
14
|
string: String;
|
|
15
15
|
date: String;
|
|
16
16
|
}, false>, Partial<{
|
|
17
17
|
datetime: String;
|
|
18
18
|
timezone: String;
|
|
19
|
-
}, false
|
|
19
|
+
}, false>]>;
|
|
20
20
|
export declare type DueDate = Static<typeof DueDate>;
|
|
21
|
-
export declare const Task: import("runtypes").
|
|
21
|
+
export declare const Task: import("runtypes").Intersect<[Record<{
|
|
22
22
|
id: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
23
23
|
order: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
24
24
|
content: String;
|
|
@@ -33,18 +33,18 @@ export declare const Task: import("runtypes").Intersect2<Record<{
|
|
|
33
33
|
url: String;
|
|
34
34
|
}, false>, Partial<{
|
|
35
35
|
parentId: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
36
|
-
due: import("runtypes").
|
|
36
|
+
due: import("runtypes").Intersect<[Record<{
|
|
37
37
|
recurring: Boolean;
|
|
38
38
|
string: String;
|
|
39
39
|
date: String;
|
|
40
40
|
}, false>, Partial<{
|
|
41
41
|
datetime: String;
|
|
42
42
|
timezone: String;
|
|
43
|
-
}, false
|
|
43
|
+
}, false>]>;
|
|
44
44
|
assignee: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
45
|
-
}, false
|
|
45
|
+
}, false>]>;
|
|
46
46
|
export declare type Task = Static<typeof Task>;
|
|
47
|
-
export declare const Project: import("runtypes").
|
|
47
|
+
export declare const Project: import("runtypes").Intersect<[Record<{
|
|
48
48
|
id: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
49
49
|
name: String;
|
|
50
50
|
color: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
@@ -58,7 +58,7 @@ export declare const Project: import("runtypes").Intersect2<Record<{
|
|
|
58
58
|
inboxProject: Boolean;
|
|
59
59
|
teamInbox: Boolean;
|
|
60
60
|
syncId: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
61
|
-
}, false
|
|
61
|
+
}, false>]>;
|
|
62
62
|
export declare type Project = Static<typeof Project>;
|
|
63
63
|
export declare const Section: Record<{
|
|
64
64
|
id: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
@@ -75,7 +75,7 @@ export declare const Label: Record<{
|
|
|
75
75
|
favorite: Boolean;
|
|
76
76
|
}, false>;
|
|
77
77
|
export declare type Label = Static<typeof Label>;
|
|
78
|
-
export declare const Attachment: import("runtypes").
|
|
78
|
+
export declare const Attachment: import("runtypes").Intersect<[Record<{
|
|
79
79
|
resourceType: String;
|
|
80
80
|
}, false>, Partial<{
|
|
81
81
|
fileName: String;
|
|
@@ -83,22 +83,22 @@ export declare const Attachment: import("runtypes").Intersect2<Record<{
|
|
|
83
83
|
fileType: String;
|
|
84
84
|
fileUrl: String;
|
|
85
85
|
fileDuration: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
86
|
-
uploadState:
|
|
86
|
+
uploadState: Union<[Literal<"pending">, Literal<"completed">]>;
|
|
87
87
|
image: String;
|
|
88
88
|
imageWidth: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
89
89
|
imageHeight: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
90
90
|
url: String;
|
|
91
91
|
title: String;
|
|
92
|
-
}, false
|
|
92
|
+
}, false>]>;
|
|
93
93
|
export declare type Attachment = Static<typeof Attachment>;
|
|
94
|
-
export declare const Comment: import("runtypes").
|
|
94
|
+
export declare const Comment: import("runtypes").Intersect<[Record<{
|
|
95
95
|
id: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
96
96
|
content: String;
|
|
97
97
|
posted: String;
|
|
98
98
|
}, false>, Partial<{
|
|
99
99
|
taskId: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
100
100
|
projectId: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
101
|
-
attachment: import("runtypes").
|
|
101
|
+
attachment: import("runtypes").Intersect<[Record<{
|
|
102
102
|
resourceType: String;
|
|
103
103
|
}, false>, Partial<{
|
|
104
104
|
fileName: String;
|
|
@@ -106,14 +106,14 @@ export declare const Comment: import("runtypes").Intersect2<Record<{
|
|
|
106
106
|
fileType: String;
|
|
107
107
|
fileUrl: String;
|
|
108
108
|
fileDuration: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
109
|
-
uploadState:
|
|
109
|
+
uploadState: Union<[Literal<"pending">, Literal<"completed">]>;
|
|
110
110
|
image: String;
|
|
111
111
|
imageWidth: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
112
112
|
imageHeight: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
|
113
113
|
url: String;
|
|
114
114
|
title: String;
|
|
115
|
-
}, false
|
|
116
|
-
}, false
|
|
115
|
+
}, false>]>;
|
|
116
|
+
}, false>]>;
|
|
117
117
|
export declare type Comment = Static<typeof Comment>;
|
|
118
118
|
export declare const User: Record<{
|
|
119
119
|
id: import("runtypes").Constraint<NumberRunType, number, unknown>;
|
package/dist/types/entities.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.User = exports.Comment = exports.Attachment = exports.Label = exports.Section = exports.Project = exports.Task = exports.DueDate = exports.Int = void 0;
|
|
4
4
|
var runtypes_1 = require("runtypes");
|
|
5
|
-
exports.Int = runtypes_1.Number.withConstraint(function (n) { return Number.isInteger(n) || n
|
|
5
|
+
exports.Int = runtypes_1.Number.withConstraint(function (n) { return Number.isInteger(n) || "".concat(n, " is not a valid entity id. Should be an integer"); });
|
|
6
6
|
exports.DueDate = (0, runtypes_1.Record)({
|
|
7
7
|
recurring: runtypes_1.Boolean,
|
|
8
8
|
string: runtypes_1.String,
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -29,7 +29,7 @@ function removeStyleFormatting(input) {
|
|
|
29
29
|
return input;
|
|
30
30
|
}
|
|
31
31
|
function removeMarkdown(match, prefix, text) {
|
|
32
|
-
return ""
|
|
32
|
+
return "".concat(prefix).concat(text);
|
|
33
33
|
}
|
|
34
34
|
input = input.replace(BOLD_ITALIC_FORMAT, removeMarkdown);
|
|
35
35
|
input = input.replace(BOLD_FORMAT, removeMarkdown);
|
|
@@ -15,8 +15,8 @@ exports.getTaskFromQuickAddResponse = void 0;
|
|
|
15
15
|
var showTaskEndpoint = 'https://todoist.com/showTask';
|
|
16
16
|
function getTaskUrlFromQuickAddResponse(responseData) {
|
|
17
17
|
return responseData.syncId
|
|
18
|
-
? showTaskEndpoint
|
|
19
|
-
: showTaskEndpoint
|
|
18
|
+
? "".concat(showTaskEndpoint, "?id=").concat(responseData.id, "&sync_id=").concat(responseData.syncId)
|
|
19
|
+
: "".concat(showTaskEndpoint, "?id=").concat(responseData.id);
|
|
20
20
|
}
|
|
21
21
|
function getTaskFromQuickAddResponse(responseData) {
|
|
22
22
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/todoist-api-typescript",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A typescript wrapper for the Todoist REST API.",
|
|
5
5
|
"author": "Doist developers",
|
|
6
6
|
"repository": "git@github.com:doist/todoist-api-typescript.git",
|
|
7
|
+
"homepage": "https://developer.todoist.com/rest/v1/?javascript",
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"main": "dist/index.js",
|
|
9
10
|
"types": "dist/index.d.ts",
|
|
@@ -23,38 +24,35 @@
|
|
|
23
24
|
"prepare": "npm run build"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"axios": "^0.
|
|
27
|
-
"axios-case-converter": "^0.
|
|
27
|
+
"axios": "^0.27.0",
|
|
28
|
+
"axios-case-converter": "^0.9.0",
|
|
28
29
|
"axios-retry": "^3.1.9",
|
|
29
|
-
"runtypes": "^5.
|
|
30
|
+
"runtypes": "^6.5.0",
|
|
30
31
|
"ts-custom-error": "^3.2.0",
|
|
31
|
-
"url-join": "^4.0.1",
|
|
32
32
|
"uuid": "^8.3.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@doist/eslint-config": "
|
|
36
|
-
"@doist/prettier-config": "
|
|
37
|
-
"@types/axios": "
|
|
38
|
-
"@types/jest": "
|
|
39
|
-
"@types/
|
|
40
|
-
"@
|
|
41
|
-
"@typescript-eslint/
|
|
42
|
-
"
|
|
43
|
-
"eslint": "
|
|
44
|
-
"eslint-
|
|
45
|
-
"eslint-import
|
|
46
|
-
"eslint-plugin-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"ts-node": "^9.1.1",
|
|
57
|
-
"typescript": "^4.4.4"
|
|
35
|
+
"@doist/eslint-config": "7.1.2",
|
|
36
|
+
"@doist/prettier-config": "3.0.5",
|
|
37
|
+
"@types/axios": "0.14.0",
|
|
38
|
+
"@types/jest": "27.5.2",
|
|
39
|
+
"@types/uuid": "8.3.4",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "5.33.1",
|
|
41
|
+
"@typescript-eslint/parser": "5.33.1",
|
|
42
|
+
"eslint": "8.22.0",
|
|
43
|
+
"eslint-config-prettier": "8.5.0",
|
|
44
|
+
"eslint-import-resolver-webpack": "0.13.2",
|
|
45
|
+
"eslint-plugin-import": "2.26.0",
|
|
46
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
47
|
+
"husky": "8.0.1",
|
|
48
|
+
"jest": "28.1.3",
|
|
49
|
+
"lint-staged": "13.0.3",
|
|
50
|
+
"npm-run-all": "4.1.5",
|
|
51
|
+
"prettier": "2.7.1",
|
|
52
|
+
"rimraf": "3.0.2",
|
|
53
|
+
"ts-jest": "28.0.8",
|
|
54
|
+
"ts-node": "10.9.1",
|
|
55
|
+
"typescript": "4.7.4"
|
|
58
56
|
},
|
|
59
57
|
"prettier": "@doist/prettier-config",
|
|
60
58
|
"husky": {
|