@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,363 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { ENDPOINT_REST_WORKSPACES, ENDPOINT_WORKSPACE_INVITATIONS, ENDPOINT_WORKSPACE_INVITATIONS_ALL, ENDPOINT_WORKSPACE_INVITATIONS_DELETE, ENDPOINT_WORKSPACE_JOIN, ENDPOINT_WORKSPACE_LOGO, ENDPOINT_WORKSPACE_MEMBERS, ENDPOINT_WORKSPACE_PLAN_DETAILS, ENDPOINT_WORKSPACE_USERS, getWorkspaceActiveProjectsEndpoint, getWorkspaceArchivedProjectsEndpoint, getWorkspaceInvitationAcceptEndpoint, getWorkspaceInvitationRejectEndpoint, getWorkspaceInviteUsersEndpoint, getWorkspaceUserEndpoint, getWorkspaceUserTasksEndpoint, } from '../consts/endpoints.js';
|
|
14
|
+
import { isSuccess, request } from '../transport/http-client.js';
|
|
15
|
+
import { uploadMultipartFile } from '../utils/multipart-upload.js';
|
|
16
|
+
import { generatePath } from '../utils/request-helpers.js';
|
|
17
|
+
import { validateJoinWorkspaceResult, validateMemberActivityInfoArray, validateProject, validateWorkspace, validateWorkspaceArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateWorkspaceUserArray, validateWorkspaceUserTaskArray, } from '../utils/validators.js';
|
|
18
|
+
import { BaseClient } from './base-client.js';
|
|
19
|
+
/**
|
|
20
|
+
* Internal sub-client handling all workspace-domain endpoints —
|
|
21
|
+
* workspaces, invitations, users, plans, logos, and workspace project
|
|
22
|
+
* pagination.
|
|
23
|
+
*
|
|
24
|
+
* Instantiated by `TodoistApi`; every public workspace method on
|
|
25
|
+
* `TodoistApi` delegates here. See `todoist-api.ts` for user-facing
|
|
26
|
+
* JSDoc.
|
|
27
|
+
*/
|
|
28
|
+
export class WorkspaceClient extends BaseClient {
|
|
29
|
+
async getWorkspaceInvitations(args, requestId) {
|
|
30
|
+
const response = await request({
|
|
31
|
+
httpMethod: 'GET',
|
|
32
|
+
baseUri: this.syncApiBase,
|
|
33
|
+
relativePath: ENDPOINT_WORKSPACE_INVITATIONS,
|
|
34
|
+
apiToken: this.authToken,
|
|
35
|
+
customFetch: this.customFetch,
|
|
36
|
+
payload: { workspace_id: args.workspaceId },
|
|
37
|
+
requestId: requestId,
|
|
38
|
+
});
|
|
39
|
+
return response.data;
|
|
40
|
+
}
|
|
41
|
+
async getAllWorkspaceInvitations(args = {}, requestId) {
|
|
42
|
+
const queryParams = {};
|
|
43
|
+
if (args.workspaceId) {
|
|
44
|
+
queryParams.workspace_id = args.workspaceId;
|
|
45
|
+
}
|
|
46
|
+
const response = await request({
|
|
47
|
+
httpMethod: 'GET',
|
|
48
|
+
baseUri: this.syncApiBase,
|
|
49
|
+
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_ALL,
|
|
50
|
+
apiToken: this.authToken,
|
|
51
|
+
customFetch: this.customFetch,
|
|
52
|
+
payload: queryParams,
|
|
53
|
+
requestId: requestId,
|
|
54
|
+
});
|
|
55
|
+
return validateWorkspaceInvitationArray(response.data);
|
|
56
|
+
}
|
|
57
|
+
async deleteWorkspaceInvitation(args, requestId) {
|
|
58
|
+
const response = await request({
|
|
59
|
+
httpMethod: 'POST',
|
|
60
|
+
baseUri: this.syncApiBase,
|
|
61
|
+
relativePath: ENDPOINT_WORKSPACE_INVITATIONS_DELETE,
|
|
62
|
+
apiToken: this.authToken,
|
|
63
|
+
customFetch: this.customFetch,
|
|
64
|
+
payload: {
|
|
65
|
+
workspace_id: args.workspaceId,
|
|
66
|
+
user_email: args.userEmail,
|
|
67
|
+
},
|
|
68
|
+
requestId: requestId,
|
|
69
|
+
});
|
|
70
|
+
return validateWorkspaceInvitation(response.data);
|
|
71
|
+
}
|
|
72
|
+
async acceptWorkspaceInvitation(args, requestId) {
|
|
73
|
+
const response = await request({
|
|
74
|
+
httpMethod: 'PUT',
|
|
75
|
+
baseUri: this.syncApiBase,
|
|
76
|
+
relativePath: getWorkspaceInvitationAcceptEndpoint(args.inviteCode),
|
|
77
|
+
apiToken: this.authToken,
|
|
78
|
+
customFetch: this.customFetch,
|
|
79
|
+
requestId: requestId,
|
|
80
|
+
});
|
|
81
|
+
return validateWorkspaceInvitation(response.data);
|
|
82
|
+
}
|
|
83
|
+
async rejectWorkspaceInvitation(args, requestId) {
|
|
84
|
+
const response = await request({
|
|
85
|
+
httpMethod: 'PUT',
|
|
86
|
+
baseUri: this.syncApiBase,
|
|
87
|
+
relativePath: getWorkspaceInvitationRejectEndpoint(args.inviteCode),
|
|
88
|
+
apiToken: this.authToken,
|
|
89
|
+
customFetch: this.customFetch,
|
|
90
|
+
requestId: requestId,
|
|
91
|
+
});
|
|
92
|
+
return validateWorkspaceInvitation(response.data);
|
|
93
|
+
}
|
|
94
|
+
async joinWorkspace(args, requestId) {
|
|
95
|
+
const response = await request({
|
|
96
|
+
httpMethod: 'POST',
|
|
97
|
+
baseUri: this.syncApiBase,
|
|
98
|
+
relativePath: ENDPOINT_WORKSPACE_JOIN,
|
|
99
|
+
apiToken: this.authToken,
|
|
100
|
+
customFetch: this.customFetch,
|
|
101
|
+
payload: {
|
|
102
|
+
invite_code: args.inviteCode,
|
|
103
|
+
workspace_id: args.workspaceId,
|
|
104
|
+
},
|
|
105
|
+
requestId: requestId,
|
|
106
|
+
});
|
|
107
|
+
return validateJoinWorkspaceResult(response.data);
|
|
108
|
+
}
|
|
109
|
+
async uploadWorkspaceLogo(args, requestId) {
|
|
110
|
+
if (args.delete) {
|
|
111
|
+
// Delete logo
|
|
112
|
+
const data = await uploadMultipartFile({
|
|
113
|
+
baseUrl: this.syncApiBase,
|
|
114
|
+
authToken: this.authToken,
|
|
115
|
+
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
116
|
+
file: Buffer.alloc(0), // Empty buffer for delete
|
|
117
|
+
fileName: 'delete',
|
|
118
|
+
additionalFields: {
|
|
119
|
+
workspace_id: args.workspaceId,
|
|
120
|
+
delete: true,
|
|
121
|
+
},
|
|
122
|
+
requestId: requestId,
|
|
123
|
+
customFetch: this.customFetch,
|
|
124
|
+
});
|
|
125
|
+
return data;
|
|
126
|
+
}
|
|
127
|
+
if (!args.file) {
|
|
128
|
+
throw new Error('file is required when not deleting logo');
|
|
129
|
+
}
|
|
130
|
+
// Validate buffer is not empty if it's a Buffer
|
|
131
|
+
if (Buffer.isBuffer(args.file) && args.file.length === 0) {
|
|
132
|
+
throw new Error('Cannot upload empty image file');
|
|
133
|
+
}
|
|
134
|
+
const additionalFields = {
|
|
135
|
+
workspace_id: args.workspaceId,
|
|
136
|
+
};
|
|
137
|
+
const data = await uploadMultipartFile({
|
|
138
|
+
baseUrl: this.syncApiBase,
|
|
139
|
+
authToken: this.authToken,
|
|
140
|
+
endpoint: ENDPOINT_WORKSPACE_LOGO,
|
|
141
|
+
file: args.file,
|
|
142
|
+
fileName: args.fileName,
|
|
143
|
+
additionalFields: additionalFields,
|
|
144
|
+
requestId: requestId,
|
|
145
|
+
customFetch: this.customFetch,
|
|
146
|
+
});
|
|
147
|
+
return data;
|
|
148
|
+
}
|
|
149
|
+
async getWorkspacePlanDetails(args, requestId) {
|
|
150
|
+
const response = await request({
|
|
151
|
+
httpMethod: 'GET',
|
|
152
|
+
baseUri: this.syncApiBase,
|
|
153
|
+
relativePath: ENDPOINT_WORKSPACE_PLAN_DETAILS,
|
|
154
|
+
apiToken: this.authToken,
|
|
155
|
+
customFetch: this.customFetch,
|
|
156
|
+
payload: { workspace_id: args.workspaceId },
|
|
157
|
+
requestId: requestId,
|
|
158
|
+
});
|
|
159
|
+
return validateWorkspacePlanDetails(response.data);
|
|
160
|
+
}
|
|
161
|
+
async getWorkspaceUsers(args = {}, requestId) {
|
|
162
|
+
const queryParams = {};
|
|
163
|
+
if (args.workspaceId !== undefined && args.workspaceId !== null) {
|
|
164
|
+
queryParams.workspace_id = args.workspaceId;
|
|
165
|
+
}
|
|
166
|
+
if (args.cursor) {
|
|
167
|
+
queryParams.cursor = args.cursor;
|
|
168
|
+
}
|
|
169
|
+
if (args.limit) {
|
|
170
|
+
queryParams.limit = args.limit;
|
|
171
|
+
}
|
|
172
|
+
const response = await request({
|
|
173
|
+
httpMethod: 'GET',
|
|
174
|
+
baseUri: this.syncApiBase,
|
|
175
|
+
relativePath: ENDPOINT_WORKSPACE_USERS,
|
|
176
|
+
apiToken: this.authToken,
|
|
177
|
+
customFetch: this.customFetch,
|
|
178
|
+
payload: queryParams,
|
|
179
|
+
requestId: requestId,
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
hasMore: response.data.hasMore || false,
|
|
183
|
+
nextCursor: response.data.nextCursor,
|
|
184
|
+
workspaceUsers: validateWorkspaceUserArray(response.data.workspaceUsers || []),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
async getWorkspaces(requestId) {
|
|
188
|
+
const response = await request({
|
|
189
|
+
httpMethod: 'GET',
|
|
190
|
+
baseUri: this.syncApiBase,
|
|
191
|
+
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
192
|
+
apiToken: this.authToken,
|
|
193
|
+
customFetch: this.customFetch,
|
|
194
|
+
requestId: requestId,
|
|
195
|
+
});
|
|
196
|
+
return validateWorkspaceArray(response.data);
|
|
197
|
+
}
|
|
198
|
+
async getWorkspace(id, requestId) {
|
|
199
|
+
z.string().parse(id);
|
|
200
|
+
const response = await request({
|
|
201
|
+
httpMethod: 'GET',
|
|
202
|
+
baseUri: this.syncApiBase,
|
|
203
|
+
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
204
|
+
apiToken: this.authToken,
|
|
205
|
+
customFetch: this.customFetch,
|
|
206
|
+
requestId: requestId,
|
|
207
|
+
});
|
|
208
|
+
return validateWorkspace(response.data);
|
|
209
|
+
}
|
|
210
|
+
async addWorkspace(args, requestId) {
|
|
211
|
+
const response = await request({
|
|
212
|
+
httpMethod: 'POST',
|
|
213
|
+
baseUri: this.syncApiBase,
|
|
214
|
+
relativePath: ENDPOINT_REST_WORKSPACES,
|
|
215
|
+
apiToken: this.authToken,
|
|
216
|
+
customFetch: this.customFetch,
|
|
217
|
+
payload: args,
|
|
218
|
+
requestId: requestId,
|
|
219
|
+
});
|
|
220
|
+
return validateWorkspace(response.data);
|
|
221
|
+
}
|
|
222
|
+
async updateWorkspace(id, args, requestId) {
|
|
223
|
+
z.string().parse(id);
|
|
224
|
+
const response = await request({
|
|
225
|
+
httpMethod: 'POST',
|
|
226
|
+
baseUri: this.syncApiBase,
|
|
227
|
+
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
228
|
+
apiToken: this.authToken,
|
|
229
|
+
customFetch: this.customFetch,
|
|
230
|
+
payload: args,
|
|
231
|
+
requestId: requestId,
|
|
232
|
+
});
|
|
233
|
+
return validateWorkspace(response.data);
|
|
234
|
+
}
|
|
235
|
+
async deleteWorkspace(id, requestId) {
|
|
236
|
+
z.string().parse(id);
|
|
237
|
+
const response = await request({
|
|
238
|
+
httpMethod: 'DELETE',
|
|
239
|
+
baseUri: this.syncApiBase,
|
|
240
|
+
relativePath: generatePath(ENDPOINT_REST_WORKSPACES, id),
|
|
241
|
+
apiToken: this.authToken,
|
|
242
|
+
customFetch: this.customFetch,
|
|
243
|
+
requestId: requestId,
|
|
244
|
+
});
|
|
245
|
+
return isSuccess(response);
|
|
246
|
+
}
|
|
247
|
+
async getWorkspaceMembersActivity(args, requestId) {
|
|
248
|
+
const { workspaceId } = args, queryParams = __rest(args, ["workspaceId"]);
|
|
249
|
+
const { data } = await request({
|
|
250
|
+
httpMethod: 'GET',
|
|
251
|
+
baseUri: this.syncApiBase,
|
|
252
|
+
relativePath: ENDPOINT_WORKSPACE_MEMBERS,
|
|
253
|
+
apiToken: this.authToken,
|
|
254
|
+
customFetch: this.customFetch,
|
|
255
|
+
payload: Object.assign({ workspaceId }, queryParams),
|
|
256
|
+
requestId: requestId,
|
|
257
|
+
});
|
|
258
|
+
return {
|
|
259
|
+
members: validateMemberActivityInfoArray(data.members),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
async getWorkspaceUserTasks(args, requestId) {
|
|
263
|
+
const { workspaceId, userId } = args, queryParams = __rest(args, ["workspaceId", "userId"]);
|
|
264
|
+
const { data } = await request({
|
|
265
|
+
httpMethod: 'GET',
|
|
266
|
+
baseUri: this.syncApiBase,
|
|
267
|
+
relativePath: getWorkspaceUserTasksEndpoint(workspaceId, userId),
|
|
268
|
+
apiToken: this.authToken,
|
|
269
|
+
customFetch: this.customFetch,
|
|
270
|
+
payload: queryParams,
|
|
271
|
+
requestId: requestId,
|
|
272
|
+
});
|
|
273
|
+
return {
|
|
274
|
+
tasks: validateWorkspaceUserTaskArray(data.tasks),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
async inviteWorkspaceUsers(args, requestId) {
|
|
278
|
+
const { workspaceId } = args, payload = __rest(args, ["workspaceId"]);
|
|
279
|
+
const { data } = await request({
|
|
280
|
+
httpMethod: 'POST',
|
|
281
|
+
baseUri: this.syncApiBase,
|
|
282
|
+
relativePath: getWorkspaceInviteUsersEndpoint(workspaceId),
|
|
283
|
+
apiToken: this.authToken,
|
|
284
|
+
customFetch: this.customFetch,
|
|
285
|
+
payload: payload,
|
|
286
|
+
requestId: requestId,
|
|
287
|
+
});
|
|
288
|
+
return data;
|
|
289
|
+
}
|
|
290
|
+
async updateWorkspaceUser(args, requestId) {
|
|
291
|
+
const { workspaceId, userId } = args, payload = __rest(args, ["workspaceId", "userId"]);
|
|
292
|
+
const response = await request({
|
|
293
|
+
httpMethod: 'POST',
|
|
294
|
+
baseUri: this.syncApiBase,
|
|
295
|
+
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
296
|
+
apiToken: this.authToken,
|
|
297
|
+
customFetch: this.customFetch,
|
|
298
|
+
payload: payload,
|
|
299
|
+
requestId: requestId,
|
|
300
|
+
});
|
|
301
|
+
return validateJoinWorkspaceResult(response.data);
|
|
302
|
+
}
|
|
303
|
+
async removeWorkspaceUser(args, requestId) {
|
|
304
|
+
const { workspaceId, userId } = args;
|
|
305
|
+
const response = await request({
|
|
306
|
+
httpMethod: 'DELETE',
|
|
307
|
+
baseUri: this.syncApiBase,
|
|
308
|
+
relativePath: getWorkspaceUserEndpoint(workspaceId, userId),
|
|
309
|
+
apiToken: this.authToken,
|
|
310
|
+
customFetch: this.customFetch,
|
|
311
|
+
requestId: requestId,
|
|
312
|
+
});
|
|
313
|
+
return isSuccess(response);
|
|
314
|
+
}
|
|
315
|
+
async getWorkspaceActiveProjects(args, requestId) {
|
|
316
|
+
var _a;
|
|
317
|
+
const queryParams = {};
|
|
318
|
+
if (args.cursor) {
|
|
319
|
+
queryParams.cursor = args.cursor;
|
|
320
|
+
}
|
|
321
|
+
if (args.limit) {
|
|
322
|
+
queryParams.limit = args.limit;
|
|
323
|
+
}
|
|
324
|
+
const response = await request({
|
|
325
|
+
httpMethod: 'GET',
|
|
326
|
+
baseUri: this.syncApiBase,
|
|
327
|
+
relativePath: getWorkspaceActiveProjectsEndpoint(args.workspaceId),
|
|
328
|
+
apiToken: this.authToken,
|
|
329
|
+
customFetch: this.customFetch,
|
|
330
|
+
payload: queryParams,
|
|
331
|
+
requestId: requestId,
|
|
332
|
+
});
|
|
333
|
+
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
334
|
+
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
335
|
+
return Object.assign(Object.assign({}, response.data), {
|
|
336
|
+
// oxlint-disable-next-line no-unsafe-assignment
|
|
337
|
+
results: validatedProjects || [] });
|
|
338
|
+
}
|
|
339
|
+
async getWorkspaceArchivedProjects(args, requestId) {
|
|
340
|
+
var _a;
|
|
341
|
+
const queryParams = {};
|
|
342
|
+
if (args.cursor) {
|
|
343
|
+
queryParams.cursor = args.cursor;
|
|
344
|
+
}
|
|
345
|
+
if (args.limit) {
|
|
346
|
+
queryParams.limit = args.limit;
|
|
347
|
+
}
|
|
348
|
+
const response = await request({
|
|
349
|
+
httpMethod: 'GET',
|
|
350
|
+
baseUri: this.syncApiBase,
|
|
351
|
+
relativePath: getWorkspaceArchivedProjectsEndpoint(args.workspaceId),
|
|
352
|
+
apiToken: this.authToken,
|
|
353
|
+
customFetch: this.customFetch,
|
|
354
|
+
payload: queryParams,
|
|
355
|
+
requestId: requestId,
|
|
356
|
+
});
|
|
357
|
+
// oxlint-disable-next-line no-unsafe-assignment, no-unsafe-call, no-unsafe-member-access
|
|
358
|
+
const validatedProjects = (_a = response.data.results) === null || _a === void 0 ? void 0 : _a.map((project) => validateProject(project));
|
|
359
|
+
return Object.assign(Object.assign({}, response.data), {
|
|
360
|
+
// oxlint-disable-next-line no-unsafe-assignment
|
|
361
|
+
results: validatedProjects || [] });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
@@ -67,6 +67,11 @@ export const ENDPOINT_GET_TOKEN = 'access_token';
|
|
|
67
67
|
export const ENDPOINT_REVOKE = 'revoke';
|
|
68
68
|
export const ENDPOINT_REGISTER = 'register';
|
|
69
69
|
export const ENDPOINT_REST_FOLDERS = 'folders';
|
|
70
|
+
export const ENDPOINT_REST_GOALS = 'goals';
|
|
71
|
+
export const ENDPOINT_REST_GOALS_SEARCH = ENDPOINT_REST_GOALS + '/search';
|
|
72
|
+
export const GOAL_COMPLETE = 'complete';
|
|
73
|
+
export const GOAL_UNCOMPLETE = 'uncomplete';
|
|
74
|
+
export const GOAL_TASKS = 'items';
|
|
70
75
|
// Workspace endpoints
|
|
71
76
|
export const ENDPOINT_REST_WORKSPACES = 'workspaces';
|
|
72
77
|
export const ENDPOINT_WORKSPACE_INVITATIONS = 'workspaces/invitations';
|
|
@@ -277,6 +277,30 @@ export const DEFAULT_COLLABORATOR_STATE = {
|
|
|
277
277
|
state: 'active',
|
|
278
278
|
isDeleted: false,
|
|
279
279
|
};
|
|
280
|
+
export const DEFAULT_GOAL_ID = '550e8400-e29b-41d4-a716-446655440000';
|
|
281
|
+
export const DEFAULT_GOAL = {
|
|
282
|
+
id: DEFAULT_GOAL_ID,
|
|
283
|
+
ownerType: 'USER',
|
|
284
|
+
ownerId: DEFAULT_USER_ID,
|
|
285
|
+
name: 'Ship v2',
|
|
286
|
+
description: 'Launch the new version',
|
|
287
|
+
deadline: '2026-04-03',
|
|
288
|
+
parentGoalId: null,
|
|
289
|
+
childOrder: 0,
|
|
290
|
+
isCompleted: false,
|
|
291
|
+
completedAt: null,
|
|
292
|
+
responsibleUid: null,
|
|
293
|
+
isDeleted: false,
|
|
294
|
+
progress: {
|
|
295
|
+
totalTaskCount: 5,
|
|
296
|
+
completedTaskCount: 2,
|
|
297
|
+
percentage: 40,
|
|
298
|
+
},
|
|
299
|
+
creatorUid: DEFAULT_USER_ID,
|
|
300
|
+
createdAt: defaultDate(),
|
|
301
|
+
updatedAt: defaultDate(),
|
|
302
|
+
};
|
|
303
|
+
export const DEFAULT_GOAL_NO_PROGRESS = Object.assign(Object.assign({}, DEFAULT_GOAL), { id: 'e5f6g7h8-e29b-41d4-a716-446655440001', progress: undefined });
|
|
280
304
|
export const DEFAULT_NOTE = {
|
|
281
305
|
id: DEFAULT_COMMENT_ID,
|
|
282
306
|
projectId: DEFAULT_PROJECT_ID,
|