@doist/todoist-api-typescript 1.6.0 → 1.7.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.d.ts +3 -1
- package/dist/TodoistApi.js +32 -30
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.js +6 -6
- package/dist/consts/endpoints.d.ts +3 -3
- package/dist/consts/endpoints.js +21 -4
- package/package.json +5 -5
package/dist/TodoistApi.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { Task, Project, Label, User, Section, Comment } from './types/entities';
|
|
|
2
2
|
import { AddLabelArgs, AddProjectArgs, AddSectionArgs, AddProjectCommentArgs, AddTaskArgs, AddTaskCommentArgs, GetProjectCommentsArgs, GetTaskCommentsArgs, GetTasksArgs, UpdateCommentArgs, UpdateLabelArgs, UpdateProjectArgs, UpdateSectionArgs, UpdateTaskArgs, QuickAddTaskArgs } from './types/requests';
|
|
3
3
|
export declare class TodoistApi {
|
|
4
4
|
authToken: string;
|
|
5
|
-
constructor(authToken: string);
|
|
5
|
+
constructor(authToken: string, baseUrl?: string);
|
|
6
|
+
private restApiBase;
|
|
7
|
+
private syncApiBase;
|
|
6
8
|
getTask(id: number): Promise<Task>;
|
|
7
9
|
getTasks(args?: GetTasksArgs): Promise<Task[]>;
|
|
8
10
|
addTask(args: AddTaskArgs, requestId?: string): Promise<Task>;
|
package/dist/TodoistApi.js
CHANGED
|
@@ -55,8 +55,10 @@ function generatePath() {
|
|
|
55
55
|
return segments.join('/');
|
|
56
56
|
}
|
|
57
57
|
var TodoistApi = /** @class */ (function () {
|
|
58
|
-
function TodoistApi(authToken) {
|
|
58
|
+
function TodoistApi(authToken, baseUrl) {
|
|
59
59
|
this.authToken = authToken;
|
|
60
|
+
this.restApiBase = (0, endpoints_1.getRestBaseUri)(baseUrl);
|
|
61
|
+
this.syncApiBase = (0, endpoints_1.getSyncBaseUri)(baseUrl);
|
|
60
62
|
}
|
|
61
63
|
TodoistApi.prototype.getTask = function (id) {
|
|
62
64
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -65,7 +67,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
65
67
|
switch (_a.label) {
|
|
66
68
|
case 0:
|
|
67
69
|
entities_1.Int.check(id);
|
|
68
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
70
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id)), this.authToken)];
|
|
69
71
|
case 1:
|
|
70
72
|
response = _a.sent();
|
|
71
73
|
return [2 /*return*/, (0, validators_1.validateTask)(response.data)];
|
|
@@ -78,7 +80,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
78
80
|
var response;
|
|
79
81
|
return __generator(this, function (_a) {
|
|
80
82
|
switch (_a.label) {
|
|
81
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
83
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, endpoints_1.ENDPOINT_REST_TASKS, this.authToken, args)];
|
|
82
84
|
case 1:
|
|
83
85
|
response = _a.sent();
|
|
84
86
|
return [2 /*return*/, (0, validators_1.validateTaskArray)(response.data)];
|
|
@@ -91,7 +93,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
91
93
|
var response;
|
|
92
94
|
return __generator(this, function (_a) {
|
|
93
95
|
switch (_a.label) {
|
|
94
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
96
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, endpoints_1.ENDPOINT_REST_TASKS, this.authToken, args, requestId)];
|
|
95
97
|
case 1:
|
|
96
98
|
response = _a.sent();
|
|
97
99
|
return [2 /*return*/, (0, validators_1.validateTask)(response.data)];
|
|
@@ -104,7 +106,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
104
106
|
var response, task;
|
|
105
107
|
return __generator(this, function (_a) {
|
|
106
108
|
switch (_a.label) {
|
|
107
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
109
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.syncApiBase, endpoints_1.ENDPOINT_SYNC_QUICK_ADD, this.authToken, args)];
|
|
108
110
|
case 1:
|
|
109
111
|
response = _a.sent();
|
|
110
112
|
task = (0, taskConverters_1.getTaskFromQuickAddResponse)(response.data);
|
|
@@ -120,7 +122,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
120
122
|
switch (_a.label) {
|
|
121
123
|
case 0:
|
|
122
124
|
entities_1.Int.check(id);
|
|
123
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
125
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id)), this.authToken, args, requestId)];
|
|
124
126
|
case 1:
|
|
125
127
|
response = _a.sent();
|
|
126
128
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -135,7 +137,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
135
137
|
switch (_a.label) {
|
|
136
138
|
case 0:
|
|
137
139
|
entities_1.Int.check(id);
|
|
138
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
140
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id), endpoints_1.ENDPOINT_REST_TASK_CLOSE), this.authToken, undefined, requestId)];
|
|
139
141
|
case 1:
|
|
140
142
|
response = _a.sent();
|
|
141
143
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -150,7 +152,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
150
152
|
switch (_a.label) {
|
|
151
153
|
case 0:
|
|
152
154
|
entities_1.Int.check(id);
|
|
153
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
155
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id), endpoints_1.ENDPOINT_REST_TASK_REOPEN), this.authToken, undefined, requestId)];
|
|
154
156
|
case 1:
|
|
155
157
|
response = _a.sent();
|
|
156
158
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -165,7 +167,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
165
167
|
switch (_a.label) {
|
|
166
168
|
case 0:
|
|
167
169
|
entities_1.Int.check(id);
|
|
168
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE',
|
|
170
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_TASKS, String(id)), this.authToken, undefined, requestId)];
|
|
169
171
|
case 1:
|
|
170
172
|
response = _a.sent();
|
|
171
173
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -180,7 +182,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
180
182
|
switch (_a.label) {
|
|
181
183
|
case 0:
|
|
182
184
|
entities_1.Int.check(id);
|
|
183
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
185
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(id)), this.authToken)];
|
|
184
186
|
case 1:
|
|
185
187
|
response = _a.sent();
|
|
186
188
|
return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
|
|
@@ -193,7 +195,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
193
195
|
var response;
|
|
194
196
|
return __generator(this, function (_a) {
|
|
195
197
|
switch (_a.label) {
|
|
196
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
198
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, endpoints_1.ENDPOINT_REST_PROJECTS, this.authToken)];
|
|
197
199
|
case 1:
|
|
198
200
|
response = _a.sent();
|
|
199
201
|
return [2 /*return*/, (0, validators_1.validateProjectArray)(response.data)];
|
|
@@ -206,7 +208,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
206
208
|
var response;
|
|
207
209
|
return __generator(this, function (_a) {
|
|
208
210
|
switch (_a.label) {
|
|
209
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
211
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, endpoints_1.ENDPOINT_REST_PROJECTS, this.authToken, args, requestId)];
|
|
210
212
|
case 1:
|
|
211
213
|
response = _a.sent();
|
|
212
214
|
return [2 /*return*/, (0, validators_1.validateProject)(response.data)];
|
|
@@ -221,7 +223,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
221
223
|
switch (_a.label) {
|
|
222
224
|
case 0:
|
|
223
225
|
entities_1.Int.check(id);
|
|
224
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
226
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(id)), this.authToken, args, requestId)];
|
|
225
227
|
case 1:
|
|
226
228
|
response = _a.sent();
|
|
227
229
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -236,7 +238,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
236
238
|
switch (_a.label) {
|
|
237
239
|
case 0:
|
|
238
240
|
entities_1.Int.check(id);
|
|
239
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE',
|
|
241
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(id)), this.authToken, requestId)];
|
|
240
242
|
case 1:
|
|
241
243
|
response = _a.sent();
|
|
242
244
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -251,7 +253,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
251
253
|
switch (_a.label) {
|
|
252
254
|
case 0:
|
|
253
255
|
entities_1.Int.check(projectId);
|
|
254
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
256
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_PROJECTS, String(projectId), endpoints_1.ENDPOINT_REST_PROJECT_COLLABORATORS), this.authToken)];
|
|
255
257
|
case 1:
|
|
256
258
|
response = _a.sent();
|
|
257
259
|
return [2 /*return*/, (0, validators_1.validateUserArray)(response.data)];
|
|
@@ -264,7 +266,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
264
266
|
var response;
|
|
265
267
|
return __generator(this, function (_a) {
|
|
266
268
|
switch (_a.label) {
|
|
267
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
269
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, endpoints_1.ENDPOINT_REST_SECTIONS, this.authToken, projectId && { projectId: projectId })];
|
|
268
270
|
case 1:
|
|
269
271
|
response = _a.sent();
|
|
270
272
|
return [2 /*return*/, (0, validators_1.validateSectionArray)(response.data)];
|
|
@@ -279,7 +281,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
279
281
|
switch (_a.label) {
|
|
280
282
|
case 0:
|
|
281
283
|
entities_1.Int.check(id);
|
|
282
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
284
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, String(id)), this.authToken)];
|
|
283
285
|
case 1:
|
|
284
286
|
response = _a.sent();
|
|
285
287
|
return [2 /*return*/, (0, validators_1.validateSection)(response.data)];
|
|
@@ -292,7 +294,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
292
294
|
var response;
|
|
293
295
|
return __generator(this, function (_a) {
|
|
294
296
|
switch (_a.label) {
|
|
295
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
297
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, endpoints_1.ENDPOINT_REST_SECTIONS, this.authToken, args, requestId)];
|
|
296
298
|
case 1:
|
|
297
299
|
response = _a.sent();
|
|
298
300
|
return [2 /*return*/, (0, validators_1.validateSection)(response.data)];
|
|
@@ -307,7 +309,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
307
309
|
switch (_a.label) {
|
|
308
310
|
case 0:
|
|
309
311
|
entities_1.Int.check(id);
|
|
310
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
312
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, String(id)), this.authToken, args, requestId)];
|
|
311
313
|
case 1:
|
|
312
314
|
response = _a.sent();
|
|
313
315
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -322,7 +324,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
322
324
|
switch (_a.label) {
|
|
323
325
|
case 0:
|
|
324
326
|
entities_1.Int.check(id);
|
|
325
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE',
|
|
327
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_SECTIONS, String(id)), this.authToken, undefined, requestId)];
|
|
326
328
|
case 1:
|
|
327
329
|
response = _a.sent();
|
|
328
330
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -337,7 +339,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
337
339
|
switch (_a.label) {
|
|
338
340
|
case 0:
|
|
339
341
|
entities_1.Int.check(id);
|
|
340
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
342
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_LABELS, String(id)), this.authToken)];
|
|
341
343
|
case 1:
|
|
342
344
|
response = _a.sent();
|
|
343
345
|
return [2 /*return*/, (0, validators_1.validateLabel)(response.data)];
|
|
@@ -350,7 +352,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
350
352
|
var response;
|
|
351
353
|
return __generator(this, function (_a) {
|
|
352
354
|
switch (_a.label) {
|
|
353
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
355
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, endpoints_1.ENDPOINT_REST_LABELS, this.authToken)];
|
|
354
356
|
case 1:
|
|
355
357
|
response = _a.sent();
|
|
356
358
|
return [2 /*return*/, (0, validators_1.validateLabelArray)(response.data)];
|
|
@@ -363,7 +365,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
363
365
|
var response;
|
|
364
366
|
return __generator(this, function (_a) {
|
|
365
367
|
switch (_a.label) {
|
|
366
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
368
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, endpoints_1.ENDPOINT_REST_LABELS, this.authToken, args, requestId)];
|
|
367
369
|
case 1:
|
|
368
370
|
response = _a.sent();
|
|
369
371
|
return [2 /*return*/, (0, validators_1.validateLabel)(response.data)];
|
|
@@ -378,7 +380,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
378
380
|
switch (_a.label) {
|
|
379
381
|
case 0:
|
|
380
382
|
entities_1.Int.check(id);
|
|
381
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
383
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_LABELS, String(id)), this.authToken, args, requestId)];
|
|
382
384
|
case 1:
|
|
383
385
|
response = _a.sent();
|
|
384
386
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -393,7 +395,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
393
395
|
switch (_a.label) {
|
|
394
396
|
case 0:
|
|
395
397
|
entities_1.Int.check(id);
|
|
396
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE',
|
|
398
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_LABELS, String(id)), this.authToken, undefined, requestId)];
|
|
397
399
|
case 1:
|
|
398
400
|
response = _a.sent();
|
|
399
401
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -406,7 +408,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
406
408
|
var response;
|
|
407
409
|
return __generator(this, function (_a) {
|
|
408
410
|
switch (_a.label) {
|
|
409
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
411
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, endpoints_1.ENDPOINT_REST_COMMENTS, this.authToken, args)];
|
|
410
412
|
case 1:
|
|
411
413
|
response = _a.sent();
|
|
412
414
|
return [2 /*return*/, (0, validators_1.validateCommentArray)(response.data)];
|
|
@@ -421,7 +423,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
421
423
|
switch (_a.label) {
|
|
422
424
|
case 0:
|
|
423
425
|
entities_1.Int.check(id);
|
|
424
|
-
return [4 /*yield*/, (0, restClient_1.request)('GET',
|
|
426
|
+
return [4 /*yield*/, (0, restClient_1.request)('GET', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, String(id)), this.authToken)];
|
|
425
427
|
case 1:
|
|
426
428
|
response = _a.sent();
|
|
427
429
|
return [2 /*return*/, (0, validators_1.validateComment)(response.data)];
|
|
@@ -434,7 +436,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
434
436
|
var response;
|
|
435
437
|
return __generator(this, function (_a) {
|
|
436
438
|
switch (_a.label) {
|
|
437
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
439
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, endpoints_1.ENDPOINT_REST_COMMENTS, this.authToken, args, requestId)];
|
|
438
440
|
case 1:
|
|
439
441
|
response = _a.sent();
|
|
440
442
|
return [2 /*return*/, (0, validators_1.validateComment)(response.data)];
|
|
@@ -449,7 +451,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
449
451
|
switch (_a.label) {
|
|
450
452
|
case 0:
|
|
451
453
|
entities_1.Int.check(id);
|
|
452
|
-
return [4 /*yield*/, (0, restClient_1.request)('POST',
|
|
454
|
+
return [4 /*yield*/, (0, restClient_1.request)('POST', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, String(id)), this.authToken, args, requestId)];
|
|
453
455
|
case 1:
|
|
454
456
|
response = _a.sent();
|
|
455
457
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -464,7 +466,7 @@ var TodoistApi = /** @class */ (function () {
|
|
|
464
466
|
switch (_a.label) {
|
|
465
467
|
case 0:
|
|
466
468
|
entities_1.Int.check(id);
|
|
467
|
-
return [4 /*yield*/, (0, restClient_1.request)('DELETE',
|
|
469
|
+
return [4 /*yield*/, (0, restClient_1.request)('DELETE', this.restApiBase, generatePath(endpoints_1.ENDPOINT_REST_COMMENTS, String(id)), this.authToken, undefined, requestId)];
|
|
468
470
|
case 1:
|
|
469
471
|
response = _a.sent();
|
|
470
472
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
package/dist/authentication.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ export declare type RevokeAuthTokenRequestArgs = {
|
|
|
14
14
|
accessToken: string;
|
|
15
15
|
};
|
|
16
16
|
export declare function getAuthStateParameter(): string;
|
|
17
|
-
export declare function getAuthorizationUrl(clientId: string, permissions: Permission[], state: string): string;
|
|
18
|
-
export declare function getAuthToken(args: AuthTokenRequestArgs): Promise<AuthTokenResponse>;
|
|
19
|
-
export declare function revokeAuthToken(args: RevokeAuthTokenRequestArgs): Promise<boolean>;
|
|
17
|
+
export declare function getAuthorizationUrl(clientId: string, permissions: Permission[], state: string, baseUrl?: string): string;
|
|
18
|
+
export declare function getAuthToken(args: AuthTokenRequestArgs, baseUrl?: string): Promise<AuthTokenResponse>;
|
|
19
|
+
export declare function revokeAuthToken(args: RevokeAuthTokenRequestArgs, baseUrl?: string): Promise<boolean>;
|
package/dist/authentication.js
CHANGED
|
@@ -45,21 +45,21 @@ function getAuthStateParameter() {
|
|
|
45
45
|
return (0, uuid_1.v4)();
|
|
46
46
|
}
|
|
47
47
|
exports.getAuthStateParameter = getAuthStateParameter;
|
|
48
|
-
function getAuthorizationUrl(clientId, permissions, state) {
|
|
48
|
+
function getAuthorizationUrl(clientId, permissions, state, baseUrl) {
|
|
49
49
|
if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
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 "".concat(endpoints_1.
|
|
53
|
+
return "".concat((0, endpoints_1.getAuthBaseUri)(baseUrl)).concat(endpoints_1.ENDPOINT_AUTHORIZATION, "?client_id=").concat(clientId, "&scope=").concat(scope, "&state=").concat(state);
|
|
54
54
|
}
|
|
55
55
|
exports.getAuthorizationUrl = getAuthorizationUrl;
|
|
56
|
-
function getAuthToken(args) {
|
|
56
|
+
function getAuthToken(args, baseUrl) {
|
|
57
57
|
var _a;
|
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
59
|
var response;
|
|
60
60
|
return __generator(this, function (_b) {
|
|
61
61
|
switch (_b.label) {
|
|
62
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.
|
|
62
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', (0, endpoints_1.getAuthBaseUri)(baseUrl), endpoints_1.ENDPOINT_GET_TOKEN, undefined, args)];
|
|
63
63
|
case 1:
|
|
64
64
|
response = _b.sent();
|
|
65
65
|
if (response.status !== 200 || !((_a = response.data) === null || _a === void 0 ? void 0 : _a.accessToken)) {
|
|
@@ -71,12 +71,12 @@ function getAuthToken(args) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
exports.getAuthToken = getAuthToken;
|
|
74
|
-
function revokeAuthToken(args) {
|
|
74
|
+
function revokeAuthToken(args, baseUrl) {
|
|
75
75
|
return __awaiter(this, void 0, void 0, function () {
|
|
76
76
|
var response;
|
|
77
77
|
return __generator(this, function (_a) {
|
|
78
78
|
switch (_a.label) {
|
|
79
|
-
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', endpoints_1.
|
|
79
|
+
case 0: return [4 /*yield*/, (0, restClient_1.request)('POST', (0, endpoints_1.getSyncBaseUri)(baseUrl), endpoints_1.ENDPOINT_REVOKE_TOKEN, undefined, args)];
|
|
80
80
|
case 1:
|
|
81
81
|
response = _a.sent();
|
|
82
82
|
return [2 /*return*/, (0, restClient_1.isSuccess)(response)];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
1
|
+
export declare function getRestBaseUri(domainBase?: string): string;
|
|
2
|
+
export declare function getSyncBaseUri(domainBase?: string): string;
|
|
3
|
+
export declare function getAuthBaseUri(domainBase?: string): string;
|
|
4
4
|
export declare const ENDPOINT_REST_TASKS = "tasks";
|
|
5
5
|
export declare const ENDPOINT_REST_PROJECTS = "projects";
|
|
6
6
|
export declare const ENDPOINT_REST_SECTIONS = "sections";
|
package/dist/consts/endpoints.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
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_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 = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASKS = exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.ENDPOINT_REVOKE_TOKEN = exports.ENDPOINT_GET_TOKEN = exports.ENDPOINT_AUTHORIZATION = 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 = exports.ENDPOINT_REST_SECTIONS = exports.ENDPOINT_REST_PROJECTS = exports.ENDPOINT_REST_TASKS = exports.getAuthBaseUri = exports.getSyncBaseUri = exports.getRestBaseUri = void 0;
|
|
4
|
+
var BASE_URI = 'https://api.todoist.com';
|
|
5
|
+
var API_REST_BASE_URI = '/rest/v1/';
|
|
6
|
+
var API_SYNC_BASE_URI = '/sync/v8/';
|
|
7
|
+
var TODOIST_URI = 'https://todoist.com';
|
|
8
|
+
var API_AUTHORIZATION_BASE_URI = '/oauth/';
|
|
9
|
+
function getRestBaseUri(domainBase) {
|
|
10
|
+
if (domainBase === void 0) { domainBase = BASE_URI; }
|
|
11
|
+
return new URL(API_REST_BASE_URI, domainBase).toString();
|
|
12
|
+
}
|
|
13
|
+
exports.getRestBaseUri = getRestBaseUri;
|
|
14
|
+
function getSyncBaseUri(domainBase) {
|
|
15
|
+
if (domainBase === void 0) { domainBase = BASE_URI; }
|
|
16
|
+
return new URL(API_SYNC_BASE_URI, domainBase).toString();
|
|
17
|
+
}
|
|
18
|
+
exports.getSyncBaseUri = getSyncBaseUri;
|
|
19
|
+
function getAuthBaseUri(domainBase) {
|
|
20
|
+
if (domainBase === void 0) { domainBase = TODOIST_URI; }
|
|
21
|
+
return new URL(API_AUTHORIZATION_BASE_URI, domainBase).toString();
|
|
22
|
+
}
|
|
23
|
+
exports.getAuthBaseUri = getAuthBaseUri;
|
|
7
24
|
exports.ENDPOINT_REST_TASKS = 'tasks';
|
|
8
25
|
exports.ENDPOINT_REST_PROJECTS = 'projects';
|
|
9
26
|
exports.ENDPOINT_REST_SECTIONS = 'sections';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/todoist-api-typescript",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@types/axios": "0.14.0",
|
|
38
38
|
"@types/jest": "27.5.2",
|
|
39
39
|
"@types/uuid": "8.3.4",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
41
|
-
"@typescript-eslint/parser": "5.
|
|
42
|
-
"eslint": "8.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "5.36.1",
|
|
41
|
+
"@typescript-eslint/parser": "5.36.1",
|
|
42
|
+
"eslint": "8.23.0",
|
|
43
43
|
"eslint-config-prettier": "8.5.0",
|
|
44
44
|
"eslint-import-resolver-webpack": "0.13.2",
|
|
45
45
|
"eslint-plugin-import": "2.26.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"rimraf": "3.0.2",
|
|
53
53
|
"ts-jest": "28.0.8",
|
|
54
54
|
"ts-node": "10.9.1",
|
|
55
|
-
"typescript": "4.
|
|
55
|
+
"typescript": "4.8.2"
|
|
56
56
|
},
|
|
57
57
|
"prettier": "@doist/prettier-config",
|
|
58
58
|
"husky": {
|