@doist/todoist-sdk 9.0.0 → 9.1.0-next.2
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/activity-client.js +63 -0
- package/dist/cjs/clients/backup-client.js +65 -0
- package/dist/cjs/clients/base-client.js +30 -0
- package/dist/cjs/clients/comment-client.js +92 -0
- package/dist/cjs/clients/email-client.js +43 -0
- package/dist/cjs/clients/folder-client.js +80 -0
- package/dist/cjs/clients/goals-client.js +145 -0
- package/dist/cjs/clients/id-mapping-client.js +39 -0
- package/dist/cjs/clients/insights-client.js +88 -0
- package/dist/cjs/clients/label-client.js +127 -0
- package/dist/cjs/clients/productivity-client.js +27 -0
- package/dist/cjs/clients/project-client.js +232 -0
- package/dist/cjs/clients/reminder-client.js +198 -0
- package/dist/cjs/clients/section-client.js +118 -0
- package/dist/cjs/clients/task-client.js +255 -0
- package/dist/cjs/clients/template-client.js +89 -0
- package/dist/cjs/clients/upload-client.js +102 -0
- package/dist/cjs/clients/workspace-client.js +367 -0
- package/dist/cjs/consts/endpoints.js +6 -1
- package/dist/cjs/test-utils/test-defaults.js +25 -1
- package/dist/cjs/todoist-api.js +186 -1537
- package/dist/cjs/transport/sync-request.js +75 -0
- package/dist/cjs/types/goals/index.js +18 -0
- package/dist/cjs/types/goals/requests.js +2 -0
- package/dist/cjs/types/goals/types.js +56 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/sync/commands/goals.js +2 -0
- package/dist/cjs/types/sync/commands/index.js +1 -0
- package/dist/cjs/types/sync/resource-types.js +1 -0
- package/dist/cjs/types/sync/response.js +12 -10
- package/dist/cjs/utils/headers.js +16 -0
- package/dist/cjs/utils/request-helpers.js +21 -0
- package/dist/cjs/utils/validators.js +48 -46
- package/dist/esm/clients/activity-client.js +59 -0
- package/dist/esm/clients/backup-client.js +61 -0
- package/dist/esm/clients/base-client.js +26 -0
- package/dist/esm/clients/comment-client.js +88 -0
- package/dist/esm/clients/email-client.js +39 -0
- package/dist/esm/clients/folder-client.js +76 -0
- package/dist/esm/clients/goals-client.js +141 -0
- package/dist/esm/clients/id-mapping-client.js +35 -0
- package/dist/esm/clients/insights-client.js +84 -0
- package/dist/esm/clients/label-client.js +123 -0
- package/dist/esm/clients/productivity-client.js +23 -0
- package/dist/esm/clients/project-client.js +228 -0
- package/dist/esm/clients/reminder-client.js +194 -0
- package/dist/esm/clients/section-client.js +114 -0
- package/dist/esm/clients/task-client.js +251 -0
- package/dist/esm/clients/template-client.js +85 -0
- package/dist/esm/clients/upload-client.js +98 -0
- package/dist/esm/clients/workspace-client.js +363 -0
- package/dist/esm/consts/endpoints.js +5 -0
- package/dist/esm/test-utils/test-defaults.js +24 -0
- package/dist/esm/todoist-api.js +189 -1540
- package/dist/esm/transport/sync-request.js +72 -0
- package/dist/esm/types/goals/index.js +2 -0
- package/dist/esm/types/goals/requests.js +1 -0
- package/dist/esm/types/goals/types.js +53 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/sync/commands/goals.js +1 -0
- package/dist/esm/types/sync/commands/index.js +1 -0
- package/dist/esm/types/sync/resource-types.js +1 -0
- package/dist/esm/types/sync/response.js +2 -0
- package/dist/esm/utils/headers.js +13 -0
- package/dist/esm/utils/request-helpers.js +17 -0
- package/dist/esm/utils/validators.js +2 -0
- package/dist/types/clients/activity-client.d.ts +12 -0
- package/dist/types/clients/backup-client.d.ts +14 -0
- package/dist/types/clients/base-client.d.ts +21 -0
- package/dist/types/clients/comment-client.d.ts +15 -0
- package/dist/types/clients/email-client.d.ts +13 -0
- package/dist/types/clients/folder-client.d.ts +16 -0
- package/dist/types/clients/goals-client.d.ts +20 -0
- package/dist/types/clients/id-mapping-client.d.ts +13 -0
- package/dist/types/clients/insights-client.d.ts +18 -0
- package/dist/types/clients/label-client.d.ts +19 -0
- package/dist/types/clients/productivity-client.d.ts +12 -0
- package/dist/types/clients/project-client.d.ts +26 -0
- package/dist/types/clients/reminder-client.d.ts +25 -0
- package/dist/types/clients/section-client.d.ts +18 -0
- package/dist/types/clients/task-client.d.ts +25 -0
- package/dist/types/clients/template-client.d.ts +17 -0
- package/dist/types/clients/upload-client.d.ts +17 -0
- package/dist/types/clients/workspace-client.d.ts +43 -0
- package/dist/types/consts/endpoints.d.ts +5 -0
- package/dist/types/test-utils/test-defaults.d.ts +4 -1
- package/dist/types/todoist-api.d.ts +48 -17
- package/dist/types/transport/sync-request.d.ts +27 -0
- package/dist/types/types/goals/index.d.ts +2 -0
- package/dist/types/types/goals/requests.d.ts +33 -0
- package/dist/types/types/goals/types.d.ts +51 -0
- package/dist/types/types/http.d.ts +7 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/sync/commands/goals.d.ts +33 -0
- package/dist/types/types/sync/commands/index.d.ts +9 -0
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +29 -4
- package/dist/types/types/tasks/requests.d.ts +1 -0
- package/dist/types/utils/headers.d.ts +7 -0
- package/dist/types/utils/request-helpers.d.ts +13 -0
- package/dist/types/utils/validators.d.ts +55 -8
- package/package.json +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LabelClient = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
6
|
+
const http_client_1 = require("../transport/http-client");
|
|
7
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
8
|
+
const validators_1 = require("../utils/validators");
|
|
9
|
+
const base_client_1 = require("./base-client");
|
|
10
|
+
/**
|
|
11
|
+
* Internal sub-client handling all label-domain endpoints.
|
|
12
|
+
*
|
|
13
|
+
* Instantiated by `TodoistApi`; every public label method on `TodoistApi`
|
|
14
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class LabelClient extends base_client_1.BaseClient {
|
|
17
|
+
async getLabel(id) {
|
|
18
|
+
zod_1.z.string().parse(id);
|
|
19
|
+
const response = await (0, http_client_1.request)({
|
|
20
|
+
httpMethod: 'GET',
|
|
21
|
+
baseUri: this.syncApiBase,
|
|
22
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LABELS, id),
|
|
23
|
+
apiToken: this.authToken,
|
|
24
|
+
customFetch: this.customFetch,
|
|
25
|
+
});
|
|
26
|
+
return (0, validators_1.validateLabel)(response.data);
|
|
27
|
+
}
|
|
28
|
+
async getLabels(args = {}) {
|
|
29
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
30
|
+
httpMethod: 'GET',
|
|
31
|
+
baseUri: this.syncApiBase,
|
|
32
|
+
relativePath: endpoints_1.ENDPOINT_REST_LABELS,
|
|
33
|
+
apiToken: this.authToken,
|
|
34
|
+
customFetch: this.customFetch,
|
|
35
|
+
payload: args,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
results: (0, validators_1.validateLabelArray)(results),
|
|
39
|
+
nextCursor,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async searchLabels(args) {
|
|
43
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
44
|
+
httpMethod: 'GET',
|
|
45
|
+
baseUri: this.syncApiBase,
|
|
46
|
+
relativePath: endpoints_1.ENDPOINT_REST_LABELS_SEARCH,
|
|
47
|
+
apiToken: this.authToken,
|
|
48
|
+
customFetch: this.customFetch,
|
|
49
|
+
payload: args,
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
results: (0, validators_1.validateLabelArray)(results),
|
|
53
|
+
nextCursor,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async addLabel(args, requestId) {
|
|
57
|
+
const response = await (0, http_client_1.request)({
|
|
58
|
+
httpMethod: 'POST',
|
|
59
|
+
baseUri: this.syncApiBase,
|
|
60
|
+
relativePath: endpoints_1.ENDPOINT_REST_LABELS,
|
|
61
|
+
apiToken: this.authToken,
|
|
62
|
+
customFetch: this.customFetch,
|
|
63
|
+
payload: args,
|
|
64
|
+
requestId: requestId,
|
|
65
|
+
});
|
|
66
|
+
return (0, validators_1.validateLabel)(response.data);
|
|
67
|
+
}
|
|
68
|
+
async updateLabel(id, args, requestId) {
|
|
69
|
+
zod_1.z.string().parse(id);
|
|
70
|
+
const response = await (0, http_client_1.request)({
|
|
71
|
+
httpMethod: 'POST',
|
|
72
|
+
baseUri: this.syncApiBase,
|
|
73
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LABELS, id),
|
|
74
|
+
apiToken: this.authToken,
|
|
75
|
+
customFetch: this.customFetch,
|
|
76
|
+
payload: args,
|
|
77
|
+
requestId: requestId,
|
|
78
|
+
});
|
|
79
|
+
return (0, validators_1.validateLabel)(response.data);
|
|
80
|
+
}
|
|
81
|
+
async deleteLabel(id, requestId) {
|
|
82
|
+
zod_1.z.string().parse(id);
|
|
83
|
+
const response = await (0, http_client_1.request)({
|
|
84
|
+
httpMethod: 'DELETE',
|
|
85
|
+
baseUri: this.syncApiBase,
|
|
86
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LABELS, id),
|
|
87
|
+
apiToken: this.authToken,
|
|
88
|
+
customFetch: this.customFetch,
|
|
89
|
+
requestId: requestId,
|
|
90
|
+
});
|
|
91
|
+
return (0, http_client_1.isSuccess)(response);
|
|
92
|
+
}
|
|
93
|
+
async getSharedLabels(args) {
|
|
94
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
95
|
+
httpMethod: 'GET',
|
|
96
|
+
baseUri: this.syncApiBase,
|
|
97
|
+
relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED,
|
|
98
|
+
apiToken: this.authToken,
|
|
99
|
+
customFetch: this.customFetch,
|
|
100
|
+
payload: args,
|
|
101
|
+
});
|
|
102
|
+
return { results, nextCursor };
|
|
103
|
+
}
|
|
104
|
+
async renameSharedLabel(args) {
|
|
105
|
+
const response = await (0, http_client_1.request)({
|
|
106
|
+
httpMethod: 'POST',
|
|
107
|
+
baseUri: this.syncApiBase,
|
|
108
|
+
relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED_RENAME,
|
|
109
|
+
apiToken: this.authToken,
|
|
110
|
+
customFetch: this.customFetch,
|
|
111
|
+
payload: args,
|
|
112
|
+
});
|
|
113
|
+
return (0, http_client_1.isSuccess)(response);
|
|
114
|
+
}
|
|
115
|
+
async removeSharedLabel(args) {
|
|
116
|
+
const response = await (0, http_client_1.request)({
|
|
117
|
+
httpMethod: 'POST',
|
|
118
|
+
baseUri: this.syncApiBase,
|
|
119
|
+
relativePath: endpoints_1.ENDPOINT_REST_LABELS_SHARED_REMOVE,
|
|
120
|
+
apiToken: this.authToken,
|
|
121
|
+
customFetch: this.customFetch,
|
|
122
|
+
payload: args,
|
|
123
|
+
});
|
|
124
|
+
return (0, http_client_1.isSuccess)(response);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.LabelClient = LabelClient;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductivityClient = void 0;
|
|
4
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
+
const http_client_1 = require("../transport/http-client");
|
|
6
|
+
const validators_1 = require("../utils/validators");
|
|
7
|
+
const base_client_1 = require("./base-client");
|
|
8
|
+
/**
|
|
9
|
+
* Internal sub-client handling the productivity-stats endpoint.
|
|
10
|
+
*
|
|
11
|
+
* Instantiated by `TodoistApi`; the public `getProductivityStats` method
|
|
12
|
+
* on `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
13
|
+
* JSDoc.
|
|
14
|
+
*/
|
|
15
|
+
class ProductivityClient extends base_client_1.BaseClient {
|
|
16
|
+
async getProductivityStats() {
|
|
17
|
+
const response = await (0, http_client_1.request)({
|
|
18
|
+
httpMethod: 'GET',
|
|
19
|
+
baseUri: this.syncApiBase,
|
|
20
|
+
relativePath: endpoints_1.ENDPOINT_REST_PRODUCTIVITY,
|
|
21
|
+
apiToken: this.authToken,
|
|
22
|
+
customFetch: this.customFetch,
|
|
23
|
+
});
|
|
24
|
+
return (0, validators_1.validateProductivityStats)(response.data);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ProductivityClient = ProductivityClient;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectClient = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
6
|
+
const http_client_1 = require("../transport/http-client");
|
|
7
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
8
|
+
const validators_1 = require("../utils/validators");
|
|
9
|
+
const base_client_1 = require("./base-client");
|
|
10
|
+
/**
|
|
11
|
+
* Internal sub-client handling all project-domain endpoints.
|
|
12
|
+
*
|
|
13
|
+
* Instantiated by `TodoistApi`; every public project method on `TodoistApi`
|
|
14
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class ProjectClient extends base_client_1.BaseClient {
|
|
17
|
+
async getProject(id) {
|
|
18
|
+
zod_1.z.string().parse(id);
|
|
19
|
+
const response = await (0, http_client_1.request)({
|
|
20
|
+
httpMethod: 'GET',
|
|
21
|
+
baseUri: this.syncApiBase,
|
|
22
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id),
|
|
23
|
+
apiToken: this.authToken,
|
|
24
|
+
customFetch: this.customFetch,
|
|
25
|
+
});
|
|
26
|
+
return (0, validators_1.validateProject)(response.data);
|
|
27
|
+
}
|
|
28
|
+
async getProjects(args = {}) {
|
|
29
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
30
|
+
httpMethod: 'GET',
|
|
31
|
+
baseUri: this.syncApiBase,
|
|
32
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS,
|
|
33
|
+
apiToken: this.authToken,
|
|
34
|
+
customFetch: this.customFetch,
|
|
35
|
+
payload: args,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
results: (0, validators_1.validateProjectArray)(results),
|
|
39
|
+
nextCursor,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async searchProjects(args) {
|
|
43
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
44
|
+
httpMethod: 'GET',
|
|
45
|
+
baseUri: this.syncApiBase,
|
|
46
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_SEARCH,
|
|
47
|
+
apiToken: this.authToken,
|
|
48
|
+
customFetch: this.customFetch,
|
|
49
|
+
payload: args,
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
results: (0, validators_1.validateProjectArray)(results),
|
|
53
|
+
nextCursor,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async getArchivedProjects(args = {}) {
|
|
57
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
58
|
+
httpMethod: 'GET',
|
|
59
|
+
baseUri: this.syncApiBase,
|
|
60
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_ARCHIVED,
|
|
61
|
+
apiToken: this.authToken,
|
|
62
|
+
customFetch: this.customFetch,
|
|
63
|
+
payload: args,
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
results: (0, validators_1.validateProjectArray)(results),
|
|
67
|
+
nextCursor,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async addProject(args, requestId) {
|
|
71
|
+
const response = await (0, http_client_1.request)({
|
|
72
|
+
httpMethod: 'POST',
|
|
73
|
+
baseUri: this.syncApiBase,
|
|
74
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS,
|
|
75
|
+
apiToken: this.authToken,
|
|
76
|
+
customFetch: this.customFetch,
|
|
77
|
+
payload: args,
|
|
78
|
+
requestId: requestId,
|
|
79
|
+
});
|
|
80
|
+
return (0, validators_1.validateProject)(response.data);
|
|
81
|
+
}
|
|
82
|
+
async updateProject(id, args, requestId) {
|
|
83
|
+
zod_1.z.string().parse(id);
|
|
84
|
+
const response = await (0, http_client_1.request)({
|
|
85
|
+
httpMethod: 'POST',
|
|
86
|
+
baseUri: this.syncApiBase,
|
|
87
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id),
|
|
88
|
+
apiToken: this.authToken,
|
|
89
|
+
customFetch: this.customFetch,
|
|
90
|
+
payload: args,
|
|
91
|
+
requestId: requestId,
|
|
92
|
+
});
|
|
93
|
+
return (0, validators_1.validateProject)(response.data);
|
|
94
|
+
}
|
|
95
|
+
async deleteProject(id, requestId) {
|
|
96
|
+
zod_1.z.string().parse(id);
|
|
97
|
+
const response = await (0, http_client_1.request)({
|
|
98
|
+
httpMethod: 'DELETE',
|
|
99
|
+
baseUri: this.syncApiBase,
|
|
100
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id),
|
|
101
|
+
apiToken: this.authToken,
|
|
102
|
+
customFetch: this.customFetch,
|
|
103
|
+
requestId: requestId,
|
|
104
|
+
});
|
|
105
|
+
return (0, http_client_1.isSuccess)(response);
|
|
106
|
+
}
|
|
107
|
+
async archiveProject(id, requestId) {
|
|
108
|
+
zod_1.z.string().parse(id);
|
|
109
|
+
const response = await (0, http_client_1.request)({
|
|
110
|
+
httpMethod: 'POST',
|
|
111
|
+
baseUri: this.syncApiBase,
|
|
112
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_ARCHIVE),
|
|
113
|
+
apiToken: this.authToken,
|
|
114
|
+
customFetch: this.customFetch,
|
|
115
|
+
requestId: requestId,
|
|
116
|
+
});
|
|
117
|
+
return (0, validators_1.validateProject)(response.data);
|
|
118
|
+
}
|
|
119
|
+
async unarchiveProject(id, requestId) {
|
|
120
|
+
zod_1.z.string().parse(id);
|
|
121
|
+
const response = await (0, http_client_1.request)({
|
|
122
|
+
httpMethod: 'POST',
|
|
123
|
+
baseUri: this.syncApiBase,
|
|
124
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.PROJECT_UNARCHIVE),
|
|
125
|
+
apiToken: this.authToken,
|
|
126
|
+
customFetch: this.customFetch,
|
|
127
|
+
requestId: requestId,
|
|
128
|
+
});
|
|
129
|
+
return (0, validators_1.validateProject)(response.data);
|
|
130
|
+
}
|
|
131
|
+
async moveProjectToWorkspace(args, requestId) {
|
|
132
|
+
const response = await (0, http_client_1.request)({
|
|
133
|
+
httpMethod: 'POST',
|
|
134
|
+
baseUri: this.syncApiBase,
|
|
135
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE,
|
|
136
|
+
apiToken: this.authToken,
|
|
137
|
+
customFetch: this.customFetch,
|
|
138
|
+
payload: args,
|
|
139
|
+
requestId: requestId,
|
|
140
|
+
});
|
|
141
|
+
return (0, validators_1.validateProject)(response.data.project);
|
|
142
|
+
}
|
|
143
|
+
async moveProjectToPersonal(args, requestId) {
|
|
144
|
+
const response = await (0, http_client_1.request)({
|
|
145
|
+
httpMethod: 'POST',
|
|
146
|
+
baseUri: this.syncApiBase,
|
|
147
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL,
|
|
148
|
+
apiToken: this.authToken,
|
|
149
|
+
customFetch: this.customFetch,
|
|
150
|
+
payload: args,
|
|
151
|
+
requestId: requestId,
|
|
152
|
+
});
|
|
153
|
+
return (0, validators_1.validateProject)(response.data.project);
|
|
154
|
+
}
|
|
155
|
+
async getArchivedProjectsCount(args = {}) {
|
|
156
|
+
const { data } = await (0, http_client_1.request)({
|
|
157
|
+
httpMethod: 'GET',
|
|
158
|
+
baseUri: this.syncApiBase,
|
|
159
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_ARCHIVED_COUNT,
|
|
160
|
+
apiToken: this.authToken,
|
|
161
|
+
customFetch: this.customFetch,
|
|
162
|
+
payload: args,
|
|
163
|
+
});
|
|
164
|
+
return data;
|
|
165
|
+
}
|
|
166
|
+
async getProjectPermissions() {
|
|
167
|
+
const { data } = await (0, http_client_1.request)({
|
|
168
|
+
httpMethod: 'GET',
|
|
169
|
+
baseUri: this.syncApiBase,
|
|
170
|
+
relativePath: endpoints_1.ENDPOINT_REST_PROJECTS_PERMISSIONS,
|
|
171
|
+
apiToken: this.authToken,
|
|
172
|
+
customFetch: this.customFetch,
|
|
173
|
+
});
|
|
174
|
+
return data;
|
|
175
|
+
}
|
|
176
|
+
async getFullProject(id, args = {}) {
|
|
177
|
+
zod_1.z.string().parse(id);
|
|
178
|
+
const { data } = await (0, http_client_1.request)({
|
|
179
|
+
httpMethod: 'GET',
|
|
180
|
+
baseUri: this.syncApiBase,
|
|
181
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.ENDPOINT_REST_PROJECT_FULL),
|
|
182
|
+
apiToken: this.authToken,
|
|
183
|
+
customFetch: this.customFetch,
|
|
184
|
+
payload: args,
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
project: data.project ? (0, validators_1.validateProject)(data.project) : null,
|
|
188
|
+
commentsCount: data.commentsCount,
|
|
189
|
+
tasks: (0, validators_1.validateTaskArray)(data.tasks),
|
|
190
|
+
sections: (0, validators_1.validateSectionArray)(data.sections),
|
|
191
|
+
collaborators: (0, validators_1.validateUserArray)(data.collaborators),
|
|
192
|
+
notes: (0, validators_1.validateCommentArray)(data.notes),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
async joinProject(id, requestId) {
|
|
196
|
+
zod_1.z.string().parse(id);
|
|
197
|
+
const { data } = await (0, http_client_1.request)({
|
|
198
|
+
httpMethod: 'POST',
|
|
199
|
+
baseUri: this.syncApiBase,
|
|
200
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, id, endpoints_1.ENDPOINT_REST_PROJECT_JOIN),
|
|
201
|
+
apiToken: this.authToken,
|
|
202
|
+
customFetch: this.customFetch,
|
|
203
|
+
requestId: requestId,
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
project: (0, validators_1.validateWorkspaceProject)(data.project),
|
|
207
|
+
tasks: (0, validators_1.validateTaskArray)(data.tasks),
|
|
208
|
+
sections: (0, validators_1.validateSectionArray)(data.sections),
|
|
209
|
+
comments: (0, validators_1.validateNoteArray)(data.comments),
|
|
210
|
+
collaborators: (0, validators_1.validateCollaboratorArray)(data.collaborators),
|
|
211
|
+
collaboratorStates: (0, validators_1.validateCollaboratorStateArray)(data.collaboratorStates),
|
|
212
|
+
folder: data.folder ? (0, validators_1.validateFolder)(data.folder) : null,
|
|
213
|
+
subprojects: (0, validators_1.validateWorkspaceProjectArray)(data.subprojects),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
async getProjectCollaborators(projectId, args = {}) {
|
|
217
|
+
zod_1.z.string().parse(projectId);
|
|
218
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
219
|
+
httpMethod: 'GET',
|
|
220
|
+
baseUri: this.syncApiBase,
|
|
221
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_PROJECTS, projectId, endpoints_1.ENDPOINT_REST_PROJECT_COLLABORATORS),
|
|
222
|
+
apiToken: this.authToken,
|
|
223
|
+
customFetch: this.customFetch,
|
|
224
|
+
payload: args,
|
|
225
|
+
});
|
|
226
|
+
return {
|
|
227
|
+
results: (0, validators_1.validateUserArray)(results),
|
|
228
|
+
nextCursor,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
exports.ProjectClient = ProjectClient;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReminderClient = void 0;
|
|
4
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
+
const http_client_1 = require("../transport/http-client");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const reminders_1 = require("../types/reminders");
|
|
8
|
+
const reminders_2 = require("../types/sync/resources/reminders");
|
|
9
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
10
|
+
const validators_1 = require("../utils/validators");
|
|
11
|
+
const base_client_1 = require("./base-client");
|
|
12
|
+
/**
|
|
13
|
+
* Internal sub-client handling all reminder-domain endpoints
|
|
14
|
+
* (both time-based and location-based reminders).
|
|
15
|
+
*
|
|
16
|
+
* Instantiated by `TodoistApi`; every public reminder method on
|
|
17
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
18
|
+
* JSDoc. The time-vs-location 404 translation is preserved here so a
|
|
19
|
+
* caller who used the wrong endpoint gets a TodoistArgumentError
|
|
20
|
+
* pointing at the correct method, rather than a bare 404.
|
|
21
|
+
*/
|
|
22
|
+
class ReminderClient extends base_client_1.BaseClient {
|
|
23
|
+
async getReminders(args = {}) {
|
|
24
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
25
|
+
httpMethod: 'GET',
|
|
26
|
+
baseUri: this.syncApiBase,
|
|
27
|
+
relativePath: endpoints_1.ENDPOINT_REST_REMINDERS,
|
|
28
|
+
apiToken: this.authToken,
|
|
29
|
+
customFetch: this.customFetch,
|
|
30
|
+
payload: args,
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
results: (0, validators_1.validateReminderArray)(results),
|
|
34
|
+
nextCursor,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async getLocationReminders(args = {}) {
|
|
38
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
39
|
+
httpMethod: 'GET',
|
|
40
|
+
baseUri: this.syncApiBase,
|
|
41
|
+
relativePath: endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS,
|
|
42
|
+
apiToken: this.authToken,
|
|
43
|
+
customFetch: this.customFetch,
|
|
44
|
+
payload: args,
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
results: (0, validators_1.validateLocationReminderArray)(results),
|
|
48
|
+
nextCursor,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async getReminder(id) {
|
|
52
|
+
reminders_1.ReminderIdSchema.parse(id);
|
|
53
|
+
try {
|
|
54
|
+
const response = await (0, http_client_1.request)({
|
|
55
|
+
httpMethod: 'GET',
|
|
56
|
+
baseUri: this.syncApiBase,
|
|
57
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_REMINDERS, id),
|
|
58
|
+
apiToken: this.authToken,
|
|
59
|
+
customFetch: this.customFetch,
|
|
60
|
+
});
|
|
61
|
+
return (0, validators_1.validateReminder)(response.data);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
throw new types_1.TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use getLocationReminder instead.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async getLocationReminder(id) {
|
|
71
|
+
reminders_1.ReminderIdSchema.parse(id);
|
|
72
|
+
try {
|
|
73
|
+
const response = await (0, http_client_1.request)({
|
|
74
|
+
httpMethod: 'GET',
|
|
75
|
+
baseUri: this.syncApiBase,
|
|
76
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
77
|
+
apiToken: this.authToken,
|
|
78
|
+
customFetch: this.customFetch,
|
|
79
|
+
});
|
|
80
|
+
return (0, validators_1.validateReminder)(response.data);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
throw new types_1.TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use getReminder instead.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async addReminder(args, requestId) {
|
|
90
|
+
const response = await (0, http_client_1.request)({
|
|
91
|
+
httpMethod: 'POST',
|
|
92
|
+
baseUri: this.syncApiBase,
|
|
93
|
+
relativePath: endpoints_1.ENDPOINT_REST_REMINDERS,
|
|
94
|
+
apiToken: this.authToken,
|
|
95
|
+
customFetch: this.customFetch,
|
|
96
|
+
payload: args,
|
|
97
|
+
requestId: requestId,
|
|
98
|
+
});
|
|
99
|
+
return (0, validators_1.validateReminder)(response.data);
|
|
100
|
+
}
|
|
101
|
+
async addLocationReminder(args, requestId) {
|
|
102
|
+
const response = await (0, http_client_1.request)({
|
|
103
|
+
httpMethod: 'POST',
|
|
104
|
+
baseUri: this.syncApiBase,
|
|
105
|
+
relativePath: endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS,
|
|
106
|
+
apiToken: this.authToken,
|
|
107
|
+
customFetch: this.customFetch,
|
|
108
|
+
payload: Object.assign(Object.assign({}, args), { reminderType: reminders_2.ReminderTypeEnum.Location }),
|
|
109
|
+
requestId: requestId,
|
|
110
|
+
});
|
|
111
|
+
return (0, validators_1.validateReminder)(response.data);
|
|
112
|
+
}
|
|
113
|
+
async updateReminder(id, args, requestId) {
|
|
114
|
+
reminders_1.ReminderIdSchema.parse(id);
|
|
115
|
+
const payload = reminders_1.UpdateReminderArgsSchema.parse(args);
|
|
116
|
+
try {
|
|
117
|
+
const response = await (0, http_client_1.request)({
|
|
118
|
+
httpMethod: 'POST',
|
|
119
|
+
baseUri: this.syncApiBase,
|
|
120
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_REMINDERS, id),
|
|
121
|
+
apiToken: this.authToken,
|
|
122
|
+
customFetch: this.customFetch,
|
|
123
|
+
payload,
|
|
124
|
+
requestId: requestId,
|
|
125
|
+
});
|
|
126
|
+
return (0, validators_1.validateReminder)(response.data);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
throw new types_1.TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use updateLocationReminder instead.`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async updateLocationReminder(id, args, requestId) {
|
|
136
|
+
reminders_1.ReminderIdSchema.parse(id);
|
|
137
|
+
const payload = reminders_1.UpdateLocationReminderArgsSchema.parse(args);
|
|
138
|
+
try {
|
|
139
|
+
const response = await (0, http_client_1.request)({
|
|
140
|
+
httpMethod: 'POST',
|
|
141
|
+
baseUri: this.syncApiBase,
|
|
142
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
143
|
+
apiToken: this.authToken,
|
|
144
|
+
customFetch: this.customFetch,
|
|
145
|
+
payload,
|
|
146
|
+
requestId: requestId,
|
|
147
|
+
});
|
|
148
|
+
return (0, validators_1.validateReminder)(response.data);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
throw new types_1.TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use updateReminder instead.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async deleteReminder(id, requestId) {
|
|
158
|
+
reminders_1.ReminderIdSchema.parse(id);
|
|
159
|
+
try {
|
|
160
|
+
const response = await (0, http_client_1.request)({
|
|
161
|
+
httpMethod: 'DELETE',
|
|
162
|
+
baseUri: this.syncApiBase,
|
|
163
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_REMINDERS, id),
|
|
164
|
+
apiToken: this.authToken,
|
|
165
|
+
customFetch: this.customFetch,
|
|
166
|
+
requestId: requestId,
|
|
167
|
+
});
|
|
168
|
+
return (0, http_client_1.isSuccess)(response);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
throw new types_1.TodoistArgumentError(`Reminder ${id} was not found on the time-based reminder endpoint. If this is a location reminder, use deleteLocationReminder instead.`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async deleteLocationReminder(id, requestId) {
|
|
178
|
+
reminders_1.ReminderIdSchema.parse(id);
|
|
179
|
+
try {
|
|
180
|
+
const response = await (0, http_client_1.request)({
|
|
181
|
+
httpMethod: 'DELETE',
|
|
182
|
+
baseUri: this.syncApiBase,
|
|
183
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_LOCATION_REMINDERS, id),
|
|
184
|
+
apiToken: this.authToken,
|
|
185
|
+
customFetch: this.customFetch,
|
|
186
|
+
requestId: requestId,
|
|
187
|
+
});
|
|
188
|
+
return (0, http_client_1.isSuccess)(response);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
if (!(error instanceof types_1.TodoistRequestError) || error.httpStatusCode !== 404) {
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
throw new types_1.TodoistArgumentError(`Location reminder ${id} was not found on the location reminder endpoint. If this is a time-based reminder, use deleteReminder instead.`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.ReminderClient = ReminderClient;
|