@doist/todoist-sdk 9.1.0-next.1 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/authentication.js +1 -0
- package/dist/cjs/clients/activity-client.js +63 -0
- package/dist/cjs/clients/app-client.js +347 -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/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/ui-extension-client.js +109 -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 +66 -6
- package/dist/cjs/test-utils/test-defaults.js +77 -1
- package/dist/cjs/todoist-api.js +422 -1665
- package/dist/cjs/transport/http-client.js +1 -0
- package/dist/cjs/transport/sync-request.js +75 -0
- package/dist/cjs/types/apps/types.js +253 -0
- package/dist/cjs/types/index.js +2 -1
- package/dist/cjs/types/sync/commands/index.js +0 -1
- package/dist/cjs/types/sync/resource-types.js +0 -1
- package/dist/cjs/types/sync/response.js +10 -12
- package/dist/cjs/types/ui-extensions/index.js +18 -0
- package/dist/cjs/types/ui-extensions/types.js +77 -0
- package/dist/cjs/utils/headers.js +16 -0
- package/dist/cjs/utils/request-helpers.js +21 -0
- package/dist/cjs/utils/validators.js +45 -33
- package/dist/esm/authentication.js +1 -0
- package/dist/esm/clients/activity-client.js +59 -0
- package/dist/esm/clients/app-client.js +343 -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/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/ui-extension-client.js +105 -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 +51 -5
- package/dist/esm/test-utils/test-defaults.js +75 -0
- package/dist/esm/todoist-api.js +425 -1668
- package/dist/esm/transport/http-client.js +1 -0
- package/dist/esm/transport/sync-request.js +72 -0
- package/dist/esm/types/apps/types.js +248 -0
- package/dist/esm/types/index.js +2 -1
- package/dist/esm/types/sync/commands/index.js +0 -1
- package/dist/esm/types/sync/resource-types.js +0 -1
- package/dist/esm/types/sync/response.js +0 -2
- package/dist/esm/types/ui-extensions/types.js +74 -0
- package/dist/esm/utils/headers.js +13 -0
- package/dist/esm/utils/request-helpers.js +17 -0
- package/dist/esm/utils/validators.js +14 -2
- package/dist/types/authentication.d.ts +1 -1
- package/dist/types/clients/activity-client.d.ts +12 -0
- package/dist/types/clients/app-client.d.ts +37 -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/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/ui-extension-client.d.ts +18 -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 +24 -5
- package/dist/types/test-utils/test-defaults.d.ts +16 -1
- package/dist/types/todoist-api.d.ts +238 -28
- package/dist/types/transport/sync-request.d.ts +27 -0
- package/dist/types/types/apps/index.d.ts +2 -0
- package/dist/types/types/apps/requests.d.ts +89 -0
- package/dist/types/types/apps/types.d.ts +414 -0
- package/dist/types/types/http.d.ts +8 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/sync/commands/index.d.ts +0 -9
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/user.d.ts +2 -2
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +6 -31
- package/dist/types/types/sync/user-preferences.d.ts +1 -1
- package/dist/types/types/tasks/requests.d.ts +0 -1
- package/dist/types/types/ui-extensions/index.d.ts +2 -0
- package/dist/types/types/ui-extensions/requests.d.ts +108 -0
- package/dist/types/types/ui-extensions/types.d.ts +185 -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 +231 -55
- package/package.json +1 -1
- package/dist/cjs/types/goals/types.js +0 -29
- package/dist/esm/types/goals/types.js +0 -26
- package/dist/types/types/goals/requests.d.ts +0 -33
- package/dist/types/types/goals/types.d.ts +0 -41
- package/dist/types/types/sync/commands/goals.d.ts +0 -33
- /package/dist/cjs/types/{goals → apps}/index.js +0 -0
- /package/dist/cjs/types/{goals → apps}/requests.js +0 -0
- /package/dist/cjs/types/{sync/commands/goals.js → ui-extensions/requests.js} +0 -0
- /package/dist/esm/types/{goals → apps}/index.js +0 -0
- /package/dist/esm/types/{goals → apps}/requests.js +0 -0
- /package/dist/{types/types/goals/index.d.ts → esm/types/ui-extensions/index.js} +0 -0
- /package/dist/esm/types/{sync/commands/goals.js → ui-extensions/requests.js} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FolderClient = 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 folder-domain endpoints.
|
|
12
|
+
*
|
|
13
|
+
* Instantiated by `TodoistApi`; every public folder method on `TodoistApi`
|
|
14
|
+
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class FolderClient extends base_client_1.BaseClient {
|
|
17
|
+
async getFolders(args) {
|
|
18
|
+
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
19
|
+
httpMethod: 'GET',
|
|
20
|
+
baseUri: this.syncApiBase,
|
|
21
|
+
relativePath: endpoints_1.ENDPOINT_REST_FOLDERS,
|
|
22
|
+
apiToken: this.authToken,
|
|
23
|
+
customFetch: this.customFetch,
|
|
24
|
+
payload: args,
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
results: (0, validators_1.validateFolderArray)(results),
|
|
28
|
+
nextCursor,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async getFolder(id) {
|
|
32
|
+
zod_1.z.string().parse(id);
|
|
33
|
+
const response = await (0, http_client_1.request)({
|
|
34
|
+
httpMethod: 'GET',
|
|
35
|
+
baseUri: this.syncApiBase,
|
|
36
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
|
|
37
|
+
apiToken: this.authToken,
|
|
38
|
+
customFetch: this.customFetch,
|
|
39
|
+
});
|
|
40
|
+
return (0, validators_1.validateFolder)(response.data);
|
|
41
|
+
}
|
|
42
|
+
async addFolder(args, requestId) {
|
|
43
|
+
const response = await (0, http_client_1.request)({
|
|
44
|
+
httpMethod: 'POST',
|
|
45
|
+
baseUri: this.syncApiBase,
|
|
46
|
+
relativePath: endpoints_1.ENDPOINT_REST_FOLDERS,
|
|
47
|
+
apiToken: this.authToken,
|
|
48
|
+
customFetch: this.customFetch,
|
|
49
|
+
payload: args,
|
|
50
|
+
requestId: requestId,
|
|
51
|
+
});
|
|
52
|
+
return (0, validators_1.validateFolder)(response.data);
|
|
53
|
+
}
|
|
54
|
+
async updateFolder(id, args, requestId) {
|
|
55
|
+
zod_1.z.string().parse(id);
|
|
56
|
+
const response = await (0, http_client_1.request)({
|
|
57
|
+
httpMethod: 'POST',
|
|
58
|
+
baseUri: this.syncApiBase,
|
|
59
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
|
|
60
|
+
apiToken: this.authToken,
|
|
61
|
+
customFetch: this.customFetch,
|
|
62
|
+
payload: args,
|
|
63
|
+
requestId: requestId,
|
|
64
|
+
});
|
|
65
|
+
return (0, validators_1.validateFolder)(response.data);
|
|
66
|
+
}
|
|
67
|
+
async deleteFolder(id, requestId) {
|
|
68
|
+
zod_1.z.string().parse(id);
|
|
69
|
+
const response = await (0, http_client_1.request)({
|
|
70
|
+
httpMethod: 'DELETE',
|
|
71
|
+
baseUri: this.syncApiBase,
|
|
72
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_FOLDERS, id),
|
|
73
|
+
apiToken: this.authToken,
|
|
74
|
+
customFetch: this.customFetch,
|
|
75
|
+
requestId: requestId,
|
|
76
|
+
});
|
|
77
|
+
return (0, http_client_1.isSuccess)(response);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.FolderClient = FolderClient;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdMappingClient = void 0;
|
|
4
|
+
const endpoints_1 = require("../consts/endpoints");
|
|
5
|
+
const http_client_1 = require("../transport/http-client");
|
|
6
|
+
const request_helpers_1 = require("../utils/request-helpers");
|
|
7
|
+
const validators_1 = require("../utils/validators");
|
|
8
|
+
const base_client_1 = require("./base-client");
|
|
9
|
+
/**
|
|
10
|
+
* Internal sub-client handling ID-mapping endpoints.
|
|
11
|
+
*
|
|
12
|
+
* Instantiated by `TodoistApi`; every public id-mapping method on
|
|
13
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
14
|
+
* JSDoc.
|
|
15
|
+
*/
|
|
16
|
+
class IdMappingClient extends base_client_1.BaseClient {
|
|
17
|
+
async getIdMappings(args) {
|
|
18
|
+
const response = await (0, http_client_1.request)({
|
|
19
|
+
httpMethod: 'GET',
|
|
20
|
+
baseUri: this.syncApiBase,
|
|
21
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_ID_MAPPINGS, args.objName, args.objIds.join(',')),
|
|
22
|
+
apiToken: this.authToken,
|
|
23
|
+
customFetch: this.customFetch,
|
|
24
|
+
});
|
|
25
|
+
return (0, validators_1.validateIdMappingArray)(response.data);
|
|
26
|
+
}
|
|
27
|
+
async getMovedIds(args) {
|
|
28
|
+
const response = await (0, http_client_1.request)({
|
|
29
|
+
httpMethod: 'GET',
|
|
30
|
+
baseUri: this.syncApiBase,
|
|
31
|
+
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_MOVED_IDS, args.objName),
|
|
32
|
+
apiToken: this.authToken,
|
|
33
|
+
customFetch: this.customFetch,
|
|
34
|
+
payload: args.oldIds ? { oldIds: args.oldIds.join(',') } : undefined,
|
|
35
|
+
});
|
|
36
|
+
return (0, validators_1.validateMovedIdArray)(response.data);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.IdMappingClient = IdMappingClient;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsightsClient = 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 validators_1 = require("../utils/validators");
|
|
8
|
+
const base_client_1 = require("./base-client");
|
|
9
|
+
/**
|
|
10
|
+
* Internal sub-client handling all insights-domain endpoints
|
|
11
|
+
* (project activity stats, health, progress, workspace insights).
|
|
12
|
+
*
|
|
13
|
+
* Instantiated by `TodoistApi`; every public insights method on
|
|
14
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
15
|
+
* JSDoc.
|
|
16
|
+
*/
|
|
17
|
+
class InsightsClient extends base_client_1.BaseClient {
|
|
18
|
+
async getProjectActivityStats(projectId, args = {}) {
|
|
19
|
+
zod_1.z.string().parse(projectId);
|
|
20
|
+
const response = await (0, http_client_1.request)({
|
|
21
|
+
httpMethod: 'GET',
|
|
22
|
+
baseUri: this.syncApiBase,
|
|
23
|
+
relativePath: (0, endpoints_1.getProjectInsightsActivityStatsEndpoint)(projectId),
|
|
24
|
+
apiToken: this.authToken,
|
|
25
|
+
customFetch: this.customFetch,
|
|
26
|
+
payload: Object.assign({ objectType: 'ITEM', eventType: 'COMPLETED' }, args),
|
|
27
|
+
});
|
|
28
|
+
return (0, validators_1.validateProjectActivityStats)(response.data);
|
|
29
|
+
}
|
|
30
|
+
async getProjectHealth(projectId) {
|
|
31
|
+
zod_1.z.string().parse(projectId);
|
|
32
|
+
const response = await (0, http_client_1.request)({
|
|
33
|
+
httpMethod: 'GET',
|
|
34
|
+
baseUri: this.syncApiBase,
|
|
35
|
+
relativePath: (0, endpoints_1.getProjectInsightsHealthEndpoint)(projectId),
|
|
36
|
+
apiToken: this.authToken,
|
|
37
|
+
customFetch: this.customFetch,
|
|
38
|
+
});
|
|
39
|
+
return (0, validators_1.validateProjectHealth)(response.data);
|
|
40
|
+
}
|
|
41
|
+
async getProjectHealthContext(projectId) {
|
|
42
|
+
zod_1.z.string().parse(projectId);
|
|
43
|
+
const response = await (0, http_client_1.request)({
|
|
44
|
+
httpMethod: 'GET',
|
|
45
|
+
baseUri: this.syncApiBase,
|
|
46
|
+
relativePath: (0, endpoints_1.getProjectInsightsHealthContextEndpoint)(projectId),
|
|
47
|
+
apiToken: this.authToken,
|
|
48
|
+
customFetch: this.customFetch,
|
|
49
|
+
});
|
|
50
|
+
return (0, validators_1.validateProjectHealthContext)(response.data);
|
|
51
|
+
}
|
|
52
|
+
async getProjectProgress(projectId) {
|
|
53
|
+
zod_1.z.string().parse(projectId);
|
|
54
|
+
const response = await (0, http_client_1.request)({
|
|
55
|
+
httpMethod: 'GET',
|
|
56
|
+
baseUri: this.syncApiBase,
|
|
57
|
+
relativePath: (0, endpoints_1.getProjectInsightsProgressEndpoint)(projectId),
|
|
58
|
+
apiToken: this.authToken,
|
|
59
|
+
customFetch: this.customFetch,
|
|
60
|
+
});
|
|
61
|
+
return (0, validators_1.validateProjectProgress)(response.data);
|
|
62
|
+
}
|
|
63
|
+
async getWorkspaceInsights(workspaceId, args = {}) {
|
|
64
|
+
zod_1.z.string().parse(workspaceId);
|
|
65
|
+
const response = await (0, http_client_1.request)({
|
|
66
|
+
httpMethod: 'GET',
|
|
67
|
+
baseUri: this.syncApiBase,
|
|
68
|
+
relativePath: (0, endpoints_1.getWorkspaceInsightsEndpoint)(workspaceId),
|
|
69
|
+
apiToken: this.authToken,
|
|
70
|
+
customFetch: this.customFetch,
|
|
71
|
+
payload: Object.assign(Object.assign({}, args), (args.projectIds ? { projectIds: args.projectIds.join(',') } : {})),
|
|
72
|
+
});
|
|
73
|
+
return (0, validators_1.validateWorkspaceInsights)(response.data);
|
|
74
|
+
}
|
|
75
|
+
async analyzeProjectHealth(projectId, requestId) {
|
|
76
|
+
zod_1.z.string().parse(projectId);
|
|
77
|
+
const response = await (0, http_client_1.request)({
|
|
78
|
+
httpMethod: 'POST',
|
|
79
|
+
baseUri: this.syncApiBase,
|
|
80
|
+
relativePath: (0, endpoints_1.getProjectInsightsHealthAnalyzeEndpoint)(projectId),
|
|
81
|
+
apiToken: this.authToken,
|
|
82
|
+
customFetch: this.customFetch,
|
|
83
|
+
requestId: requestId,
|
|
84
|
+
});
|
|
85
|
+
return (0, validators_1.validateProjectHealth)(response.data);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.InsightsClient = InsightsClient;
|
|
@@ -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;
|