@gitkraken/core-gitlens 0.68.0 → 0.69.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +1 -1
  3. package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -1
  4. package/dist/plus/integrations/index.d.ts +2 -1
  5. package/dist/plus/integrations/index.js +9 -0
  6. package/dist/plus/integrations/index.js.map +1 -1
  7. package/dist/plus/integrations/integrationService.d.ts +15 -0
  8. package/dist/plus/integrations/integrationService.js +35 -4
  9. package/dist/plus/integrations/integrationService.js.map +1 -1
  10. package/dist/plus/integrations/manager.d.ts +6 -0
  11. package/dist/plus/integrations/models/asanaTaskWrites.d.ts +155 -0
  12. package/dist/plus/integrations/models/asanaTaskWrites.js +0 -0
  13. package/dist/plus/integrations/models/issuesIntegration.d.ts +6 -1
  14. package/dist/plus/integrations/models/issuesIntegration.js +25 -0
  15. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  16. package/dist/plus/integrations/models/publicIntegration.d.ts +1 -0
  17. package/dist/plus/integrations/providers/asana.d.ts +3 -1
  18. package/dist/plus/integrations/providers/asana.js +10 -0
  19. package/dist/plus/integrations/providers/asana.js.map +1 -1
  20. package/dist/plus/integrations/providers/asanaTaskWriteTransport.d.ts +40 -0
  21. package/dist/plus/integrations/providers/asanaTaskWriteTransport.js +122 -0
  22. package/dist/plus/integrations/providers/asanaTaskWriteTransport.js.map +1 -0
  23. package/dist/plus/integrations/providers/asanaTaskWrites.d.ts +38 -0
  24. package/dist/plus/integrations/providers/asanaTaskWrites.js +521 -0
  25. package/dist/plus/integrations/providers/asanaTaskWrites.js.map +1 -0
  26. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  27. package/dist/plus/integrations/providers/trello.js +6 -23
  28. package/dist/plus/integrations/providers/trello.js.map +1 -1
  29. package/dist/plus/integrations/providers/trelloCardWriteTransport.d.ts +3 -4
  30. package/dist/plus/integrations/providers/trelloCardWriteTransport.js +19 -40
  31. package/dist/plus/integrations/providers/trelloCardWriteTransport.js.map +1 -1
  32. package/dist/plus/integrations/providers/utils/writeTransport.d.ts +28 -0
  33. package/dist/plus/integrations/providers/utils/writeTransport.js +60 -0
  34. package/dist/plus/integrations/providers/utils/writeTransport.js.map +1 -0
  35. package/dist/plus/integrations/reads/drains.d.ts +1 -0
  36. package/docs/integrations.md +25 -0
  37. package/package.json +1 -1
@@ -0,0 +1,521 @@
1
+ import { AsanaTaskWriteError, toAsanaTaskWriteFailure } from "./asanaTaskWriteTransport.js";
2
+ //#region ../plus/integrations/src/providers/asanaTaskWrites.ts
3
+ const taskFields = [
4
+ "name",
5
+ "notes",
6
+ "permalink_url",
7
+ "completed",
8
+ "modified_at",
9
+ "workspace.name",
10
+ "memberships.project.name",
11
+ "memberships.section.name",
12
+ "effective_memberships.project.name",
13
+ "assignee.name",
14
+ "assignee.photo.image_60x60"
15
+ ].join(",");
16
+ const projectFields = "name,archived,permalink_url,workspace";
17
+ const maxPages = 20;
18
+ function isGid(value) {
19
+ return typeof value === "string" && /^\d{1,64}$/.test(value);
20
+ }
21
+ function isGidSet(value) {
22
+ return Array.isArray(value) && value.length !== 0 && [...value].every(isGid) && new Set(value).size === value.length;
23
+ }
24
+ function hasText(task, name, notes) {
25
+ return (name === void 0 || task.name === name) && (notes === void 0 || task.notes === notes);
26
+ }
27
+ function isCompact(value) {
28
+ return isGid(value?.gid) && typeof value.name === "string";
29
+ }
30
+ function isAsanaTaskWriteScope(scope, mutation) {
31
+ return typeof scope.connectionId === "string" && scope.connectionId.trim() !== "" && (!mutation && scope.expectedAccountId === void 0 || isGid(scope.expectedAccountId));
32
+ }
33
+ function parseAsanaTaskReference(value) {
34
+ if (isGid(value)) return { taskId: value };
35
+ if (typeof value !== "string") return void 0;
36
+ let url;
37
+ try {
38
+ url = new URL(value);
39
+ } catch {
40
+ return;
41
+ }
42
+ if (url.protocol !== "https:" || url.hostname !== "app.asana.com" || url.port !== "" || url.username !== "" || url.password !== "") return;
43
+ const segments = url.pathname.split("/").slice(1);
44
+ if (segments.at(-1) === "f" || segments.at(-1) === "") segments.pop();
45
+ const [version, ...path] = segments;
46
+ if (version === "0") {
47
+ const [context, taskId, ...rest] = path;
48
+ return rest.length === 0 && (context === "0" || isGid(context)) && isGid(taskId) ? { taskId } : void 0;
49
+ }
50
+ if (version !== "1") return void 0;
51
+ if (path.length === 3 && isGid(path[0]) && path[1] === "task" && isGid(path[2])) return {
52
+ taskId: path[2],
53
+ workspaceId: path[0]
54
+ };
55
+ if (path.length === 5 && isGid(path[0]) && path[1] === "project" && isGid(path[2]) && path[3] === "task" && isGid(path[4])) return {
56
+ taskId: path[4],
57
+ workspaceId: path[0],
58
+ projectId: path[2]
59
+ };
60
+ }
61
+ function isTask(task) {
62
+ return isGid(task?.gid) && typeof task.name === "string" && typeof task.notes === "string" && typeof task.permalink_url === "string" && task.permalink_url.length !== 0 && typeof task.completed === "boolean" && typeof task.modified_at === "string" && Number.isFinite(Date.parse(task.modified_at)) && isCompact(task.workspace) && (task.assignee == null || isGid(task.assignee.gid)) && Array.isArray(task.memberships) && task.memberships.every((m) => m != null && (m.project == null || isCompact(m.project)) && (m.section == null || isCompact(m.section))) && (task.effective_memberships === void 0 || Array.isArray(task.effective_memberships) && task.effective_memberships.every((m) => m != null && (m.project == null || isCompact(m.project))));
63
+ }
64
+ function isProject(project) {
65
+ return isCompact(project) && typeof project.archived === "boolean" && typeof project.permalink_url === "string" && isGid(project.workspace?.gid);
66
+ }
67
+ function toCompact({ gid, name }) {
68
+ return {
69
+ id: gid,
70
+ name
71
+ };
72
+ }
73
+ const partialMembershipReceipts = /* @__PURE__ */ new WeakSet();
74
+ function toReceipt(task) {
75
+ const receipt = {
76
+ id: task.gid,
77
+ name: task.name,
78
+ notes: task.notes,
79
+ url: task.permalink_url,
80
+ completed: task.completed,
81
+ modifiedAt: task.modified_at,
82
+ workspaceId: task.workspace.gid,
83
+ memberships: task.memberships.flatMap((m) => m.project == null ? [] : [{
84
+ project: toCompact(m.project),
85
+ section: m.section == null ? null : toCompact(m.section)
86
+ }]),
87
+ ...task.assignee !== void 0 && { assignee: toAssignee(task.assignee) }
88
+ };
89
+ if (task.effective_memberships !== void 0) {
90
+ const direct = new Set(receipt.memberships.map((m) => m.project.id));
91
+ const inherited = /* @__PURE__ */ new Map();
92
+ for (const { project } of task.effective_memberships) if (project != null && !direct.has(project.gid)) inherited.set(project.gid, toCompact(project));
93
+ receipt.inheritedProjects = [...inherited.values()];
94
+ }
95
+ if (task.memberships.some((m) => m.project == null) || task.effective_memberships?.some((m) => m.project == null)) partialMembershipReceipts.add(receipt);
96
+ return receipt;
97
+ }
98
+ function toAssignee(user) {
99
+ if (user == null) return null;
100
+ return {
101
+ id: user.gid,
102
+ name: typeof user.name === "string" ? user.name : null,
103
+ avatarUrl: typeof user.photo?.image_60x60 === "string" ? user.photo.image_60x60 : null
104
+ };
105
+ }
106
+ function toProject(project, sections) {
107
+ return {
108
+ id: project.gid,
109
+ name: project.name,
110
+ archived: project.archived,
111
+ url: project.permalink_url,
112
+ workspaceId: project.workspace.gid,
113
+ ...sections != null && { sections }
114
+ };
115
+ }
116
+ function getMembership(task, projectId) {
117
+ const memberships = task.memberships.filter((m) => m.project.id === projectId);
118
+ return memberships.length === 1 ? memberships[0] : void 0;
119
+ }
120
+ function ensureAvailable(capability) {
121
+ if (capability.status === "unavailable") throw new AsanaTaskWriteError(capability.reason);
122
+ }
123
+ function deleteCapability(scopes) {
124
+ if (scopes.filter((scope) => /^[a-z_.]+:(?:read|write|delete)$/.test(scope)).length === 0 || scopes.includes("default") || scopes.includes("tasks:delete")) return { status: "unknown" };
125
+ return {
126
+ status: "unavailable",
127
+ reason: "insufficient-scope"
128
+ };
129
+ }
130
+ function validateText(name, notes, requireName) {
131
+ if (requireName && name === void 0 || name === void 0 && notes === void 0 || name !== void 0 && (typeof name !== "string" || name.trim() === "") || notes !== void 0 && typeof notes !== "string") throw new AsanaTaskWriteError("invalid-input");
132
+ }
133
+ function validateMutationTarget(options) {
134
+ if (!isGid(options.workspaceId) || !isGid(options.projectId) || !isGid(options.taskId) || options.sectionId != null && !isGid(options.sectionId)) throw new AsanaTaskWriteError("invalid-input");
135
+ }
136
+ function validateUpdate(options) {
137
+ validateMutationTarget(options);
138
+ switch (options.action) {
139
+ case "edit":
140
+ validateText(options.name, options.notes, false);
141
+ break;
142
+ case "move":
143
+ if (options.sectionId === void 0 || !isGid(options.destinationSectionId) || options.destinationSectionId === options.sectionId) throw new AsanaTaskWriteError("invalid-input");
144
+ break;
145
+ case "complete":
146
+ case "reopen": break;
147
+ default: throw new AsanaTaskWriteError("invalid-input");
148
+ }
149
+ }
150
+ var AsanaTaskWriter = class {
151
+ transport;
152
+ activeWrites;
153
+ constructor(transport, activeWrites) {
154
+ this.transport = transport;
155
+ this.activeWrites = activeWrites;
156
+ }
157
+ verify() {
158
+ return this.transport.verify();
159
+ }
160
+ getAccount(options) {
161
+ return this.getContext(options);
162
+ }
163
+ async getCreateOptions(options) {
164
+ const { workspaceId, projectIds } = options;
165
+ if (workspaceId !== void 0 && !isGid(workspaceId) || projectIds !== void 0 && (workspaceId === void 0 || !isGidSet(projectIds))) throw new AsanaTaskWriteError("invalid-input");
166
+ const context = await this.getContext(options);
167
+ let workspaces;
168
+ let workspacesComplete = true;
169
+ if (workspaceId !== void 0) workspaces = [await this.getWorkspace(workspaceId)];
170
+ else {
171
+ const { values, complete } = await this.readAll("workspaces", { opt_fields: "name" });
172
+ if (!values.every(isCompact)) throw new AsanaTaskWriteError("unknown");
173
+ workspaces = values.map(toCompact);
174
+ workspacesComplete = complete;
175
+ }
176
+ const result = [];
177
+ const failures = [];
178
+ const record = async (ex, failure) => {
179
+ const { reason } = toAsanaTaskWriteFailure(ex);
180
+ if (reason === "no-connection") await this.transport.verify();
181
+ failures.push({
182
+ ...failure,
183
+ reason
184
+ });
185
+ };
186
+ if (projectIds !== void 0) {
187
+ const workspace = workspaces[0];
188
+ const projects = [];
189
+ for (const projectId of projectIds) try {
190
+ const [project, sections] = await Promise.all([this.getProject(projectId, workspace.id), this.getSections(projectId)]);
191
+ projects.push(toProject(project, sections));
192
+ } catch (ex) {
193
+ await record(ex, {
194
+ workspaceId: workspace.id,
195
+ projectId
196
+ });
197
+ }
198
+ if (projects.length !== 0) result.push({
199
+ ...workspace,
200
+ projects,
201
+ projectsComplete: failures.length === 0
202
+ });
203
+ } else for (const workspace of workspaces) try {
204
+ const { values, complete } = await this.readAll("projects", {
205
+ workspace: workspace.id,
206
+ archived: "false",
207
+ opt_fields: projectFields
208
+ });
209
+ if (!values.every((project) => isProject(project) && project.workspace.gid === workspace.id)) throw new AsanaTaskWriteError("unknown");
210
+ result.push({
211
+ ...workspace,
212
+ projects: values.map((p) => toProject(p)),
213
+ projectsComplete: complete
214
+ });
215
+ } catch (ex) {
216
+ await record(ex, { workspaceId: workspace.id });
217
+ }
218
+ if (result.length === 0 && failures.length !== 0) return {
219
+ ok: false,
220
+ reason: failures[0].reason,
221
+ mutationDispatched: false,
222
+ projectFailures: failures
223
+ };
224
+ return {
225
+ ...context,
226
+ workspacesComplete,
227
+ workspaces: result,
228
+ ...failures.length !== 0 && { projectFailures: failures }
229
+ };
230
+ }
231
+ resolveTarget(options) {
232
+ return this.resolve(options, true);
233
+ }
234
+ async resolve(options, withSections) {
235
+ const reference = parseAsanaTaskReference(options.task);
236
+ if (reference == null || options.workspaceId !== void 0 && !isGid(options.workspaceId) || options.projectId !== void 0 && !isGid(options.projectId) || reference.workspaceId !== void 0 && options.workspaceId !== void 0 && reference.workspaceId !== options.workspaceId || reference.projectId !== void 0 && options.projectId !== void 0 && reference.projectId !== options.projectId) throw new AsanaTaskWriteError("invalid-input");
237
+ const workspaceId = options.workspaceId ?? reference.workspaceId;
238
+ const projectId = options.projectId ?? reference.projectId;
239
+ const context = await this.getContext(options);
240
+ const [apiProject, sections] = projectId === void 0 ? [] : await Promise.all([this.getProject(projectId, workspaceId), withSections ? this.getSections(projectId) : void 0]);
241
+ const { task, workspace } = await this.getTask(reference.taskId);
242
+ if (workspaceId !== void 0 && task.workspaceId !== workspaceId || apiProject != null && apiProject.workspace.gid !== task.workspaceId) throw new AsanaTaskWriteError("conflict");
243
+ const target = {
244
+ ...context,
245
+ task,
246
+ workspace
247
+ };
248
+ if (apiProject == null) return {
249
+ ...target,
250
+ capabilities: allUnavailable("project-required")
251
+ };
252
+ const project = toProject(apiProject, sections);
253
+ const membership = getMembership(task, apiProject.gid);
254
+ if (membership == null) return {
255
+ ...target,
256
+ project,
257
+ capabilities: allUnavailable("not-in-project")
258
+ };
259
+ const unknown = { status: "unknown" };
260
+ return {
261
+ ...target,
262
+ project,
263
+ membership,
264
+ capabilities: {
265
+ edit: unknown,
266
+ complete: task.completed ? {
267
+ status: "unavailable",
268
+ reason: "task-completed"
269
+ } : unknown,
270
+ reopen: task.completed ? unknown : {
271
+ status: "unavailable",
272
+ reason: "task-open"
273
+ },
274
+ move: sections?.some((section) => section.id !== membership.section?.id) !== false ? unknown : {
275
+ status: "unavailable",
276
+ reason: "section-unavailable"
277
+ },
278
+ delete: deleteCapability(this.transport.scopes)
279
+ }
280
+ };
281
+ }
282
+ async write(options) {
283
+ if (options.action === "create") return this.create(options);
284
+ validateUpdate(options);
285
+ return this.withTaskMutation(options.taskId, async () => {
286
+ const target = await this.resolveMutationTarget(options, options.action === "move");
287
+ const { action } = options;
288
+ ensureAvailable(target.capabilities[action]);
289
+ const taskId = target.task.id;
290
+ const destination = action === "move" ? target.project.sections?.find((s) => s.id === options.destinationSectionId) : void 0;
291
+ if (action === "move" && destination == null) throw new AsanaTaskWriteError("section-unavailable");
292
+ await dispatch(taskId, () => {
293
+ switch (action) {
294
+ case "edit": return this.transport.mutate("PUT", `tasks/${taskId}`, {
295
+ ...options.name !== void 0 && { name: options.name },
296
+ ...options.notes !== void 0 && { notes: options.notes }
297
+ }, { opt_fields: "gid" });
298
+ case "complete": return this.transport.sdk.closeIssue({ issue: toSdkIssue(taskId) });
299
+ case "reopen": return this.transport.sdk.reOpenIssue({ issue: toSdkIssue(taskId) });
300
+ case "move": return this.transport.sdk.setIssueStatus({
301
+ issue: toSdkIssue(taskId),
302
+ status: {
303
+ id: destination.id,
304
+ name: destination.name
305
+ }
306
+ });
307
+ }
308
+ });
309
+ const receipt = await this.readBack(target, target.project, taskId, (task, membership) => {
310
+ switch (action) {
311
+ case "complete": return task.completed;
312
+ case "reopen": return !task.completed;
313
+ case "move": return membership.section?.id === destination?.id;
314
+ case "edit": return hasText(task, options.name, options.notes);
315
+ default: return true;
316
+ }
317
+ });
318
+ return action === "move" ? {
319
+ ...receipt,
320
+ action,
321
+ sourceSection: target.membership.section,
322
+ destinationSection: destination
323
+ } : {
324
+ ...receipt,
325
+ action
326
+ };
327
+ });
328
+ }
329
+ async delete(options) {
330
+ if (options.confirmed !== true) throw new AsanaTaskWriteError("confirmation-required");
331
+ if (options.sectionId === void 0 || typeof options.completed !== "boolean" || typeof options.modifiedAt !== "string" || !Number.isFinite(Date.parse(options.modifiedAt)) || !isGidSet(options.membershipProjectIds) || !options.membershipProjectIds.includes(options.projectId)) throw new AsanaTaskWriteError("invalid-input");
332
+ validateMutationTarget(options);
333
+ return this.withTaskMutation(options.taskId, async () => {
334
+ const { capabilities, ...target } = await this.resolveMutationTarget(options, false);
335
+ const { inheritedProjects } = target.task;
336
+ if (inheritedProjects == null || partialMembershipReceipts.has(target.task)) throw new AsanaTaskWriteError("unknown");
337
+ const projectIds = /* @__PURE__ */ new Set([...target.task.memberships.map((m) => m.project.id), ...inheritedProjects.map((p) => p.id)]);
338
+ if (target.task.completed !== options.completed || Date.parse(target.task.modifiedAt) !== Date.parse(options.modifiedAt) || projectIds.size !== options.membershipProjectIds.length || !options.membershipProjectIds.every((id) => projectIds.has(id))) throw new AsanaTaskWriteError("conflict");
339
+ ensureAvailable(capabilities.delete);
340
+ await dispatch(target.task.id, () => this.transport.mutate("DELETE", `tasks/${target.task.id}`));
341
+ return {
342
+ ...target,
343
+ deletion: { trashed: true }
344
+ };
345
+ });
346
+ }
347
+ async create(options) {
348
+ const { workspaceId, projectId, sectionId, name, notes } = options;
349
+ if (!isGid(workspaceId) || !isGid(projectId) || sectionId !== void 0 && !isGid(sectionId)) throw new AsanaTaskWriteError("invalid-input");
350
+ validateText(name, notes, true);
351
+ const context = await this.getContext(options);
352
+ const [apiProject, sections] = await Promise.all([this.getProject(projectId, workspaceId), sectionId === void 0 ? void 0 : this.getSections(projectId)]);
353
+ const section = sectionId === void 0 ? void 0 : sections?.find((s) => s.id === sectionId);
354
+ if (sectionId !== void 0 && section == null) throw new AsanaTaskWriteError("section-unavailable");
355
+ const created = await this.transport.mutate("POST", "tasks", {
356
+ workspace: workspaceId,
357
+ name,
358
+ ...notes !== void 0 && { notes },
359
+ ...section == null ? { projects: [projectId] } : { memberships: [{
360
+ project: projectId,
361
+ section: section.id
362
+ }] }
363
+ }, { opt_fields: "gid" });
364
+ if (!isGid(created?.gid)) throw new AsanaTaskWriteError("unknown", "applied");
365
+ return {
366
+ ...await this.readBack({
367
+ ...context,
368
+ workspace: { id: workspaceId }
369
+ }, toProject(apiProject, sections), created.gid, (task, membership) => hasText(task, name, notes) && (section == null || membership.section?.id === section.id)),
370
+ action: "create"
371
+ };
372
+ }
373
+ async resolveMutationTarget(options, withSections) {
374
+ const target = await this.resolve({
375
+ connectionId: options.connectionId,
376
+ expectedAccountId: options.expectedAccountId,
377
+ workspaceId: options.workspaceId,
378
+ projectId: options.projectId,
379
+ task: options.taskId
380
+ }, withSections);
381
+ if (target.task.id !== options.taskId) throw new AsanaTaskWriteError("conflict");
382
+ if (target.project == null) throw new AsanaTaskWriteError("project-required");
383
+ if (target.membership == null) throw new AsanaTaskWriteError("not-in-project");
384
+ if (options.sectionId !== void 0 && (target.membership.section?.id ?? null) !== options.sectionId) throw new AsanaTaskWriteError("conflict");
385
+ return {
386
+ ...target,
387
+ project: target.project,
388
+ membership: target.membership
389
+ };
390
+ }
391
+ async readBack(target, project, taskId, matches) {
392
+ let task;
393
+ let workspace;
394
+ try {
395
+ ({task, workspace} = await this.getTask(taskId));
396
+ await this.transport.verify();
397
+ } catch (ex) {
398
+ throw new AsanaTaskWriteError(toAsanaTaskWriteFailure(ex).reason, "applied", { taskId });
399
+ }
400
+ const membership = getMembership(task, project.id);
401
+ if (task.id !== taskId || task.workspaceId !== target.workspace.id || membership == null || !matches(task, membership)) throw new AsanaTaskWriteError("conflict", "applied", { taskId });
402
+ return {
403
+ ok: true,
404
+ connectionId: target.connectionId,
405
+ accountId: target.accountId,
406
+ account: target.account,
407
+ workspace,
408
+ project,
409
+ membership,
410
+ task
411
+ };
412
+ }
413
+ async getContext(options) {
414
+ const { data: user } = await this.transport.read("users/me", { opt_fields: "name,email" });
415
+ if (!isGid(user?.gid) || typeof user.name !== "string" || user.email != null && typeof user.email !== "string") throw new AsanaTaskWriteError("unknown");
416
+ if (options.expectedAccountId !== void 0 && user.gid !== options.expectedAccountId) throw new AsanaTaskWriteError("forbidden");
417
+ return {
418
+ ok: true,
419
+ connectionId: options.connectionId,
420
+ accountId: user.gid,
421
+ account: {
422
+ id: user.gid,
423
+ name: user.name,
424
+ email: user.email ?? null
425
+ }
426
+ };
427
+ }
428
+ async getTask(taskId) {
429
+ const { data: task } = await this.transport.read(`tasks/${taskId}`, { opt_fields: taskFields });
430
+ if (!isTask(task)) throw new AsanaTaskWriteError("unknown");
431
+ if (task.gid !== taskId) throw new AsanaTaskWriteError("conflict");
432
+ return {
433
+ task: toReceipt(task),
434
+ workspace: toCompact(task.workspace)
435
+ };
436
+ }
437
+ async getWorkspace(workspaceId) {
438
+ const { data: workspace } = await this.transport.read(`workspaces/${workspaceId}`, { opt_fields: "name" });
439
+ if (!isCompact(workspace)) throw new AsanaTaskWriteError("unknown");
440
+ if (workspace.gid !== workspaceId) throw new AsanaTaskWriteError("conflict");
441
+ return toCompact(workspace);
442
+ }
443
+ async getProject(projectId, workspaceId) {
444
+ const { data: project } = await this.transport.read(`projects/${projectId}`, { opt_fields: projectFields });
445
+ if (!isProject(project)) throw new AsanaTaskWriteError("unknown");
446
+ if (project.gid !== projectId || workspaceId !== void 0 && project.workspace.gid !== workspaceId) throw new AsanaTaskWriteError("conflict");
447
+ return project;
448
+ }
449
+ async getSections(projectId) {
450
+ const { values, complete } = await this.readAll(`projects/${projectId}/sections`, { opt_fields: "name" });
451
+ if (!complete || !values.every(isCompact)) throw new AsanaTaskWriteError("unknown");
452
+ return values.map(toCompact);
453
+ }
454
+ async readAll(path, params) {
455
+ const values = [];
456
+ let offset;
457
+ for (let page = 0; page < maxPages; page++) {
458
+ const body = await this.transport.read(path, {
459
+ ...params,
460
+ limit: "100",
461
+ ...offset != null && { offset }
462
+ });
463
+ if (!Array.isArray(body.data)) throw new AsanaTaskWriteError("unknown");
464
+ values.push(...body.data);
465
+ offset = body.next_page?.offset || void 0;
466
+ if (offset == null) return {
467
+ values,
468
+ complete: true
469
+ };
470
+ }
471
+ return {
472
+ values,
473
+ complete: false
474
+ };
475
+ }
476
+ async withTaskMutation(taskId, run) {
477
+ if (this.activeWrites.has(taskId)) throw new AsanaTaskWriteError("conflict");
478
+ this.activeWrites.add(taskId);
479
+ try {
480
+ return await run();
481
+ } finally {
482
+ this.activeWrites.delete(taskId);
483
+ }
484
+ }
485
+ };
486
+ function allUnavailable(reason) {
487
+ const unavailable = {
488
+ status: "unavailable",
489
+ reason
490
+ };
491
+ return {
492
+ edit: unavailable,
493
+ complete: unavailable,
494
+ reopen: unavailable,
495
+ move: unavailable,
496
+ delete: unavailable
497
+ };
498
+ }
499
+ async function dispatch(taskId, run) {
500
+ try {
501
+ await run();
502
+ } catch (ex) {
503
+ const failure = toAsanaTaskWriteFailure(ex);
504
+ if (failure.applied !== "yes" || failure.taskId != null) throw ex;
505
+ throw new AsanaTaskWriteError(failure.reason, "applied", {
506
+ taskId,
507
+ messages: failure.messages
508
+ });
509
+ }
510
+ }
511
+ function toSdkIssue(taskId) {
512
+ return {
513
+ id: taskId,
514
+ number: taskId,
515
+ repository: null
516
+ };
517
+ }
518
+ //#endregion
519
+ export { AsanaTaskWriter, isAsanaTaskWriteScope, parseAsanaTaskReference };
520
+
521
+ //# sourceMappingURL=asanaTaskWrites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asanaTaskWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/asanaTaskWrites.ts"],"sourcesContent":["import type {\n\tAsanaTaskAssignee,\n\tAsanaTaskCreateOptions,\n\tAsanaTaskCreateOptionsResult,\n\tAsanaTaskDeleteOptions,\n\tAsanaTaskDeleteResult,\n\tAsanaTaskMembership,\n\tAsanaTaskMutationTarget,\n\tAsanaTaskReceipt,\n\tAsanaTaskWriteAccount,\n\tAsanaTaskWriteCapability,\n\tAsanaTaskWriteOptions,\n\tAsanaTaskWriteOptionsResult,\n\tAsanaTaskWriteProject,\n\tAsanaTaskWriteResult,\n\tAsanaTaskWriteScope,\n\tAsanaTaskWriteSection,\n\tAsanaTaskWriteTargetOptions,\n\tAsanaTaskWriteWorkspace,\n} from '../models/asanaTaskWrites.js';\nimport { AsanaTaskWriteError, toAsanaTaskWriteFailure } from './asanaTaskWriteTransport.js';\nimport type { AsanaTaskWriteTransport } from './asanaTaskWriteTransport.js';\n\nconst taskFields = [\n\t'name',\n\t'notes',\n\t'permalink_url',\n\t'completed',\n\t'modified_at',\n\t'workspace.name',\n\t'memberships.project.name',\n\t'memberships.section.name',\n\t'effective_memberships.project.name',\n\t'assignee.name',\n\t'assignee.photo.image_60x60',\n].join(',');\nconst projectFields = 'name,archived,permalink_url,workspace';\nconst maxPages = 20;\n\ntype Compact = { gid: string; name: string };\ntype ApiTask = {\n\tgid: string;\n\tname: string;\n\tnotes: string;\n\tpermalink_url: string;\n\tcompleted: boolean;\n\tmodified_at: string;\n\tworkspace: Compact;\n\tmemberships: { project?: Compact | null; section?: Compact | null }[];\n\teffective_memberships?: { project?: Compact | null }[];\n\tassignee?: ApiUser | null;\n};\ntype ApiUser = { gid: string; name?: string | null; photo?: { image_60x60?: string | null } | null };\ntype ApiProject = Compact & { archived: boolean; permalink_url: string; workspace: { gid: string } };\ntype Context = Awaited<ReturnType<AsanaTaskWriter['getContext']>>;\ntype ResolvedTarget = Extract<AsanaTaskWriteOptionsResult, { ok: true }>;\ntype MutationTarget = ResolvedTarget & { project: AsanaTaskWriteProject; membership: AsanaTaskMembership };\ntype TaskReference = { taskId: string; workspaceId?: string; projectId?: string };\n\nfunction isGid(value: unknown): value is string {\n\treturn typeof value === 'string' && /^\\d{1,64}$/.test(value);\n}\n\nfunction isGidSet(value: unknown): value is readonly string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length !== 0 &&\n\t\t// KEEP: spreading turns holes into undefined; every() on a sparse array skips them\n\t\t[...value].every(isGid) &&\n\t\tnew Set(value).size === value.length\n\t);\n}\n\nfunction hasText(task: AsanaTaskReceipt, name: string | undefined, notes: string | undefined): boolean {\n\treturn (name === undefined || task.name === name) && (notes === undefined || task.notes === notes);\n}\n\nfunction isCompact(value: Compact | null | undefined): value is Compact {\n\treturn isGid(value?.gid) && typeof value.name === 'string';\n}\n\nexport function isAsanaTaskWriteScope(scope: AsanaTaskWriteScope, mutation: boolean): boolean {\n\treturn (\n\t\ttypeof scope.connectionId === 'string' &&\n\t\tscope.connectionId.trim() !== '' &&\n\t\t((!mutation && scope.expectedAccountId === undefined) || isGid(scope.expectedAccountId))\n\t);\n}\n\nexport function parseAsanaTaskReference(value: unknown): TaskReference | undefined {\n\tif (isGid(value)) return { taskId: value };\n\tif (typeof value !== 'string') return undefined;\n\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (\n\t\turl.protocol !== 'https:' ||\n\t\turl.hostname !== 'app.asana.com' ||\n\t\turl.port !== '' ||\n\t\turl.username !== '' ||\n\t\turl.password !== ''\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst segments = url.pathname.split('/').slice(1);\n\tif (segments.at(-1) === 'f' || segments.at(-1) === '') {\n\t\tsegments.pop();\n\t}\n\n\tconst [version, ...path] = segments;\n\tif (version === '0') {\n\t\tconst [context, taskId, ...rest] = path;\n\t\treturn rest.length === 0 && (context === '0' || isGid(context)) && isGid(taskId)\n\t\t\t? { taskId: taskId }\n\t\t\t: undefined;\n\t}\n\tif (version !== '1') return undefined;\n\n\tif (path.length === 3 && isGid(path[0]) && path[1] === 'task' && isGid(path[2])) {\n\t\treturn { taskId: path[2], workspaceId: path[0] };\n\t}\n\tif (\n\t\tpath.length === 5 &&\n\t\tisGid(path[0]) &&\n\t\tpath[1] === 'project' &&\n\t\tisGid(path[2]) &&\n\t\tpath[3] === 'task' &&\n\t\tisGid(path[4])\n\t) {\n\t\treturn { taskId: path[4], workspaceId: path[0], projectId: path[2] };\n\t}\n\n\treturn undefined;\n}\n\nfunction isTask(task: ApiTask | null | undefined): task is ApiTask {\n\treturn (\n\t\tisGid(task?.gid) &&\n\t\ttypeof task.name === 'string' &&\n\t\ttypeof task.notes === 'string' &&\n\t\ttypeof task.permalink_url === 'string' &&\n\t\ttask.permalink_url.length !== 0 &&\n\t\ttypeof task.completed === 'boolean' &&\n\t\ttypeof task.modified_at === 'string' &&\n\t\tNumber.isFinite(Date.parse(task.modified_at)) &&\n\t\tisCompact(task.workspace) &&\n\t\t(task.assignee == null || isGid(task.assignee.gid)) &&\n\t\tArray.isArray(task.memberships) &&\n\t\ttask.memberships.every(\n\t\t\tm =>\n\t\t\t\tm != null && (m.project == null || isCompact(m.project)) && (m.section == null || isCompact(m.section)),\n\t\t) &&\n\t\t(task.effective_memberships === undefined ||\n\t\t\t(Array.isArray(task.effective_memberships) &&\n\t\t\t\ttask.effective_memberships.every(m => m != null && (m.project == null || isCompact(m.project)))))\n\t);\n}\n\nfunction isProject(project: ApiProject | null | undefined): project is ApiProject {\n\treturn (\n\t\tisCompact(project) &&\n\t\ttypeof project.archived === 'boolean' &&\n\t\ttypeof project.permalink_url === 'string' &&\n\t\tisGid(project.workspace?.gid)\n\t);\n}\n\nfunction toCompact({ gid, name }: Compact): { id: string; name: string } {\n\treturn { id: gid, name: name };\n}\n\nconst partialMembershipReceipts = new WeakSet<AsanaTaskReceipt>();\n\nfunction toReceipt(task: ApiTask): AsanaTaskReceipt {\n\tconst receipt: AsanaTaskReceipt = {\n\t\tid: task.gid,\n\t\tname: task.name,\n\t\tnotes: task.notes,\n\t\turl: task.permalink_url,\n\t\tcompleted: task.completed,\n\t\tmodifiedAt: task.modified_at,\n\t\tworkspaceId: task.workspace.gid,\n\t\tmemberships: task.memberships.flatMap(m =>\n\t\t\tm.project == null\n\t\t\t\t? []\n\t\t\t\t: [{ project: toCompact(m.project), section: m.section == null ? null : toCompact(m.section) }],\n\t\t),\n\t\t...(task.assignee !== undefined && { assignee: toAssignee(task.assignee) }),\n\t};\n\tif (task.effective_memberships !== undefined) {\n\t\tconst direct = new Set(receipt.memberships.map(m => m.project.id));\n\t\tconst inherited = new Map<string, { id: string; name: string }>();\n\t\tfor (const { project } of task.effective_memberships) {\n\t\t\tif (project != null && !direct.has(project.gid)) {\n\t\t\t\tinherited.set(project.gid, toCompact(project));\n\t\t\t}\n\t\t}\n\t\treceipt.inheritedProjects = [...inherited.values()];\n\t}\n\tif (task.memberships.some(m => m.project == null) || task.effective_memberships?.some(m => m.project == null)) {\n\t\tpartialMembershipReceipts.add(receipt);\n\t}\n\n\treturn receipt;\n}\n\nfunction toAssignee(user: ApiUser | null): AsanaTaskAssignee | null {\n\tif (user == null) return null;\n\n\treturn {\n\t\tid: user.gid,\n\t\tname: typeof user.name === 'string' ? user.name : null,\n\t\tavatarUrl: typeof user.photo?.image_60x60 === 'string' ? user.photo.image_60x60 : null,\n\t};\n}\n\nfunction toProject(project: ApiProject, sections?: readonly AsanaTaskWriteSection[]): AsanaTaskWriteProject {\n\treturn {\n\t\tid: project.gid,\n\t\tname: project.name,\n\t\tarchived: project.archived,\n\t\turl: project.permalink_url,\n\t\tworkspaceId: project.workspace.gid,\n\t\t...(sections != null && { sections: sections }),\n\t};\n}\n\nfunction getMembership(task: AsanaTaskReceipt, projectId: string): AsanaTaskMembership | undefined {\n\tconst memberships = task.memberships.filter(m => m.project.id === projectId);\n\treturn memberships.length === 1 ? memberships[0] : undefined;\n}\n\nfunction ensureAvailable(capability: AsanaTaskWriteCapability): void {\n\tif (capability.status === 'unavailable') throw new AsanaTaskWriteError(capability.reason);\n}\n\nfunction deleteCapability(scopes: readonly string[]): AsanaTaskWriteCapability {\n\tconst asanaScopes = scopes.filter(scope => /^[a-z_.]+:(?:read|write|delete)$/.test(scope));\n\tif (asanaScopes.length === 0 || scopes.includes('default') || scopes.includes('tasks:delete')) {\n\t\treturn { status: 'unknown' };\n\t}\n\n\treturn { status: 'unavailable', reason: 'insufficient-scope' };\n}\n\nfunction validateText(name: string | undefined, notes: string | undefined, requireName: boolean): void {\n\tif (\n\t\t(requireName && name === undefined) ||\n\t\t(name === undefined && notes === undefined) ||\n\t\t(name !== undefined && (typeof name !== 'string' || name.trim() === '')) ||\n\t\t(notes !== undefined && typeof notes !== 'string')\n\t) {\n\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t}\n}\n\nfunction validateMutationTarget(options: AsanaTaskMutationTarget): void {\n\tif (\n\t\t!isGid(options.workspaceId) ||\n\t\t!isGid(options.projectId) ||\n\t\t!isGid(options.taskId) ||\n\t\t(options.sectionId != null && !isGid(options.sectionId))\n\t) {\n\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t}\n}\n\nfunction validateUpdate(options: Exclude<AsanaTaskWriteOptions, { action: 'create' }>): void {\n\tvalidateMutationTarget(options);\n\tswitch (options.action) {\n\t\tcase 'edit':\n\t\t\tvalidateText(options.name, options.notes, false);\n\t\t\tbreak;\n\t\tcase 'move':\n\t\t\tif (\n\t\t\t\toptions.sectionId === undefined ||\n\t\t\t\t!isGid(options.destinationSectionId) ||\n\t\t\t\toptions.destinationSectionId === options.sectionId\n\t\t\t) {\n\t\t\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'complete':\n\t\tcase 'reopen':\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t}\n}\n\nexport class AsanaTaskWriter {\n\tconstructor(\n\t\tprivate readonly transport: AsanaTaskWriteTransport,\n\t\tprivate readonly activeWrites: Set<string>,\n\t) {}\n\n\tverify(): Promise<void> {\n\t\treturn this.transport.verify();\n\t}\n\n\tgetAccount(options: AsanaTaskWriteScope): Promise<Context> {\n\t\treturn this.getContext(options);\n\t}\n\n\tasync getCreateOptions(options: AsanaTaskCreateOptions): Promise<AsanaTaskCreateOptionsResult> {\n\t\tconst { workspaceId, projectIds } = options;\n\t\tif (\n\t\t\t(workspaceId !== undefined && !isGid(workspaceId)) ||\n\t\t\t(projectIds !== undefined && (workspaceId === undefined || !isGidSet(projectIds)))\n\t\t) {\n\t\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t\t}\n\n\t\tconst context = await this.getContext(options);\n\t\tlet workspaces: AsanaTaskWriteWorkspace[];\n\t\tlet workspacesComplete = true;\n\t\tif (workspaceId !== undefined) {\n\t\t\tworkspaces = [await this.getWorkspace(workspaceId)];\n\t\t} else {\n\t\t\tconst { values, complete } = await this.readAll<Compact>('workspaces', { opt_fields: 'name' });\n\t\t\tif (!values.every(isCompact)) throw new AsanaTaskWriteError('unknown');\n\n\t\t\tworkspaces = values.map(toCompact);\n\t\t\tworkspacesComplete = complete;\n\t\t}\n\n\t\ttype Entry = Extract<AsanaTaskCreateOptionsResult, { ok: true }>['workspaces'][number];\n\t\tconst result: Entry[] = [];\n\t\tconst failures: NonNullable<AsanaTaskCreateOptionsResult['projectFailures']>[number][] = [];\n\t\tconst record = async (ex: unknown, failure: Omit<(typeof failures)[number], 'reason'>) => {\n\t\t\tconst { reason } = toAsanaTaskWriteFailure(ex);\n\t\t\tif (reason === 'no-connection') {\n\t\t\t\tawait this.transport.verify();\n\t\t\t}\n\n\t\t\tfailures.push({ ...failure, reason: reason });\n\t\t};\n\n\t\tif (projectIds !== undefined) {\n\t\t\tconst workspace = workspaces[0];\n\t\t\tconst projects: AsanaTaskWriteProject[] = [];\n\t\t\tfor (const projectId of projectIds) {\n\t\t\t\ttry {\n\t\t\t\t\tconst [project, sections] = await Promise.all([\n\t\t\t\t\t\tthis.getProject(projectId, workspace.id),\n\t\t\t\t\t\tthis.getSections(projectId),\n\t\t\t\t\t]);\n\t\t\t\t\tprojects.push(toProject(project, sections));\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tawait record(ex, { workspaceId: workspace.id, projectId: projectId });\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (projects.length !== 0) {\n\t\t\t\tresult.push({ ...workspace, projects: projects, projectsComplete: failures.length === 0 });\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const workspace of workspaces) {\n\t\t\t\ttry {\n\t\t\t\t\tconst { values, complete } = await this.readAll<ApiProject>('projects', {\n\t\t\t\t\t\tworkspace: workspace.id,\n\t\t\t\t\t\tarchived: 'false',\n\t\t\t\t\t\topt_fields: projectFields,\n\t\t\t\t\t});\n\t\t\t\t\tif (!values.every(project => isProject(project) && project.workspace.gid === workspace.id)) {\n\t\t\t\t\t\tthrow new AsanaTaskWriteError('unknown');\n\t\t\t\t\t}\n\n\t\t\t\t\tresult.push({ ...workspace, projects: values.map(p => toProject(p)), projectsComplete: complete });\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tawait record(ex, { workspaceId: workspace.id });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (result.length === 0 && failures.length !== 0) {\n\t\t\treturn { ok: false, reason: failures[0].reason, mutationDispatched: false, projectFailures: failures };\n\t\t}\n\n\t\treturn {\n\t\t\t...context,\n\t\t\tworkspacesComplete: workspacesComplete,\n\t\t\tworkspaces: result,\n\t\t\t...(failures.length !== 0 && { projectFailures: failures }),\n\t\t};\n\t}\n\n\tresolveTarget(options: AsanaTaskWriteTargetOptions): Promise<ResolvedTarget> {\n\t\treturn this.resolve(options, true);\n\t}\n\n\tprivate async resolve(options: AsanaTaskWriteTargetOptions, withSections: boolean): Promise<ResolvedTarget> {\n\t\tconst reference = parseAsanaTaskReference(options.task);\n\t\tif (\n\t\t\treference == null ||\n\t\t\t(options.workspaceId !== undefined && !isGid(options.workspaceId)) ||\n\t\t\t(options.projectId !== undefined && !isGid(options.projectId)) ||\n\t\t\t(reference.workspaceId !== undefined &&\n\t\t\t\toptions.workspaceId !== undefined &&\n\t\t\t\treference.workspaceId !== options.workspaceId) ||\n\t\t\t(reference.projectId !== undefined &&\n\t\t\t\toptions.projectId !== undefined &&\n\t\t\t\treference.projectId !== options.projectId)\n\t\t) {\n\t\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t\t}\n\n\t\tconst workspaceId = options.workspaceId ?? reference.workspaceId;\n\t\tconst projectId = options.projectId ?? reference.projectId;\n\t\tconst context = await this.getContext(options);\n\t\tconst [apiProject, sections] =\n\t\t\tprojectId === undefined\n\t\t\t\t? []\n\t\t\t\t: await Promise.all([\n\t\t\t\t\t\tthis.getProject(projectId, workspaceId),\n\t\t\t\t\t\twithSections ? this.getSections(projectId) : undefined,\n\t\t\t\t\t]);\n\t\tconst { task, workspace } = await this.getTask(reference.taskId);\n\t\tif (\n\t\t\t(workspaceId !== undefined && task.workspaceId !== workspaceId) ||\n\t\t\t(apiProject != null && apiProject.workspace.gid !== task.workspaceId)\n\t\t) {\n\t\t\tthrow new AsanaTaskWriteError('conflict');\n\t\t}\n\n\t\tconst target = { ...context, task: task, workspace: workspace };\n\t\tif (apiProject == null) return { ...target, capabilities: allUnavailable('project-required') };\n\n\t\tconst project = toProject(apiProject, sections);\n\t\tconst membership = getMembership(task, apiProject.gid);\n\t\tif (membership == null) {\n\t\t\treturn { ...target, project: project, capabilities: allUnavailable('not-in-project') };\n\t\t}\n\n\t\tconst unknown = { status: 'unknown' } as const;\n\t\treturn {\n\t\t\t...target,\n\t\t\tproject: project,\n\t\t\tmembership: membership,\n\t\t\tcapabilities: {\n\t\t\t\tedit: unknown,\n\t\t\t\tcomplete: task.completed ? { status: 'unavailable', reason: 'task-completed' } : unknown,\n\t\t\t\treopen: task.completed ? unknown : { status: 'unavailable', reason: 'task-open' },\n\t\t\t\tmove:\n\t\t\t\t\tsections?.some(section => section.id !== membership.section?.id) !== false\n\t\t\t\t\t\t? unknown\n\t\t\t\t\t\t: { status: 'unavailable', reason: 'section-unavailable' },\n\t\t\t\tdelete: deleteCapability(this.transport.scopes),\n\t\t\t},\n\t\t};\n\t}\n\n\tasync write(options: AsanaTaskWriteOptions): Promise<AsanaTaskWriteResult> {\n\t\tif (options.action === 'create') return this.create(options);\n\n\t\tvalidateUpdate(options);\n\t\treturn this.withTaskMutation(options.taskId, async () => {\n\t\t\tconst target = await this.resolveMutationTarget(options, options.action === 'move');\n\t\t\tconst { action } = options;\n\t\t\tensureAvailable(target.capabilities[action]);\n\t\t\tconst taskId = target.task.id;\n\t\t\tconst destination =\n\t\t\t\taction === 'move'\n\t\t\t\t\t? target.project.sections?.find(s => s.id === options.destinationSectionId)\n\t\t\t\t\t: undefined;\n\t\t\tif (action === 'move' && destination == null) throw new AsanaTaskWriteError('section-unavailable');\n\n\t\t\tawait dispatch(taskId, () => {\n\t\t\t\tswitch (action) {\n\t\t\t\t\tcase 'edit':\n\t\t\t\t\t\treturn this.transport.mutate(\n\t\t\t\t\t\t\t'PUT',\n\t\t\t\t\t\t\t`tasks/${taskId}`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t...(options.name !== undefined && { name: options.name }),\n\t\t\t\t\t\t\t\t...(options.notes !== undefined && { notes: options.notes }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ opt_fields: 'gid' },\n\t\t\t\t\t\t);\n\t\t\t\t\tcase 'complete':\n\t\t\t\t\t\treturn this.transport.sdk.closeIssue({ issue: toSdkIssue(taskId) });\n\t\t\t\t\tcase 'reopen':\n\t\t\t\t\t\treturn this.transport.sdk.reOpenIssue({ issue: toSdkIssue(taskId) });\n\t\t\t\t\tcase 'move':\n\t\t\t\t\t\treturn this.transport.sdk.setIssueStatus({\n\t\t\t\t\t\t\tissue: toSdkIssue(taskId),\n\t\t\t\t\t\t\tstatus: { id: destination!.id, name: destination!.name },\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst receipt = await this.readBack(target, target.project, taskId, (task, membership) => {\n\t\t\t\tswitch (action) {\n\t\t\t\t\tcase 'complete':\n\t\t\t\t\t\treturn task.completed;\n\t\t\t\t\tcase 'reopen':\n\t\t\t\t\t\treturn !task.completed;\n\t\t\t\t\tcase 'move':\n\t\t\t\t\t\treturn membership.section?.id === destination?.id;\n\t\t\t\t\tcase 'edit':\n\t\t\t\t\t\treturn hasText(task, options.name, options.notes);\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn action === 'move'\n\t\t\t\t? {\n\t\t\t\t\t\t...receipt,\n\t\t\t\t\t\taction: action,\n\t\t\t\t\t\tsourceSection: target.membership.section,\n\t\t\t\t\t\tdestinationSection: destination!,\n\t\t\t\t\t}\n\t\t\t\t: { ...receipt, action: action };\n\t\t});\n\t}\n\n\tasync delete(options: AsanaTaskDeleteOptions): Promise<AsanaTaskDeleteResult> {\n\t\tif (options.confirmed !== true) throw new AsanaTaskWriteError('confirmation-required');\n\t\tif (\n\t\t\toptions.sectionId === undefined ||\n\t\t\ttypeof options.completed !== 'boolean' ||\n\t\t\ttypeof options.modifiedAt !== 'string' ||\n\t\t\t!Number.isFinite(Date.parse(options.modifiedAt)) ||\n\t\t\t!isGidSet(options.membershipProjectIds) ||\n\t\t\t!options.membershipProjectIds.includes(options.projectId)\n\t\t) {\n\t\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t\t}\n\n\t\tvalidateMutationTarget(options);\n\t\treturn this.withTaskMutation(options.taskId, async () => {\n\t\t\tconst { capabilities, ...target } = await this.resolveMutationTarget(options, false);\n\t\t\tconst { inheritedProjects } = target.task;\n\t\t\tif (inheritedProjects == null || partialMembershipReceipts.has(target.task)) {\n\t\t\t\tthrow new AsanaTaskWriteError('unknown');\n\t\t\t}\n\n\t\t\tconst projectIds = new Set([\n\t\t\t\t...target.task.memberships.map(m => m.project.id),\n\t\t\t\t...inheritedProjects.map(p => p.id),\n\t\t\t]);\n\t\t\tif (\n\t\t\t\ttarget.task.completed !== options.completed ||\n\t\t\t\tDate.parse(target.task.modifiedAt) !== Date.parse(options.modifiedAt) ||\n\t\t\t\tprojectIds.size !== options.membershipProjectIds.length ||\n\t\t\t\t!options.membershipProjectIds.every(id => projectIds.has(id))\n\t\t\t) {\n\t\t\t\tthrow new AsanaTaskWriteError('conflict');\n\t\t\t}\n\n\t\t\tensureAvailable(capabilities.delete);\n\t\t\tawait dispatch(target.task.id, () => this.transport.mutate('DELETE', `tasks/${target.task.id}`));\n\t\t\treturn { ...target, deletion: { trashed: true } };\n\t\t});\n\t}\n\n\tprivate async create(options: Extract<AsanaTaskWriteOptions, { action: 'create' }>): Promise<AsanaTaskWriteResult> {\n\t\tconst { workspaceId, projectId, sectionId, name, notes } = options;\n\t\tif (!isGid(workspaceId) || !isGid(projectId) || (sectionId !== undefined && !isGid(sectionId))) {\n\t\t\tthrow new AsanaTaskWriteError('invalid-input');\n\t\t}\n\n\t\tvalidateText(name, notes, true);\n\t\tconst context = await this.getContext(options);\n\t\tconst [apiProject, sections] = await Promise.all([\n\t\t\tthis.getProject(projectId, workspaceId),\n\t\t\tsectionId === undefined ? undefined : this.getSections(projectId),\n\t\t]);\n\t\tconst section = sectionId === undefined ? undefined : sections?.find(s => s.id === sectionId);\n\t\tif (sectionId !== undefined && section == null) throw new AsanaTaskWriteError('section-unavailable');\n\n\t\tconst created = await this.transport.mutate<{ gid?: unknown }>(\n\t\t\t'POST',\n\t\t\t'tasks',\n\t\t\t{\n\t\t\t\tworkspace: workspaceId,\n\t\t\t\tname: name,\n\t\t\t\t...(notes !== undefined && { notes: notes }),\n\t\t\t\t...(section == null\n\t\t\t\t\t? { projects: [projectId] }\n\t\t\t\t\t: { memberships: [{ project: projectId, section: section.id }] }),\n\t\t\t},\n\t\t\t{ opt_fields: 'gid' },\n\t\t);\n\t\tif (!isGid(created?.gid)) throw new AsanaTaskWriteError('unknown', 'applied');\n\n\t\tconst receipt = await this.readBack(\n\t\t\t{ ...context, workspace: { id: workspaceId } },\n\t\t\ttoProject(apiProject, sections),\n\t\t\tcreated.gid,\n\t\t\t(task, membership) =>\n\t\t\t\thasText(task, name, notes) && (section == null || membership.section?.id === section.id),\n\t\t);\n\t\treturn { ...receipt, action: 'create' };\n\t}\n\n\tprivate async resolveMutationTarget(\n\t\toptions: AsanaTaskMutationTarget,\n\t\twithSections: boolean,\n\t): Promise<MutationTarget> {\n\t\tconst target = await this.resolve(\n\t\t\t{\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\texpectedAccountId: options.expectedAccountId,\n\t\t\t\tworkspaceId: options.workspaceId,\n\t\t\t\tprojectId: options.projectId,\n\t\t\t\ttask: options.taskId,\n\t\t\t},\n\t\t\twithSections,\n\t\t);\n\t\tif (target.task.id !== options.taskId) throw new AsanaTaskWriteError('conflict');\n\t\tif (target.project == null) throw new AsanaTaskWriteError('project-required');\n\t\tif (target.membership == null) throw new AsanaTaskWriteError('not-in-project');\n\t\tif (options.sectionId !== undefined && (target.membership.section?.id ?? null) !== options.sectionId) {\n\t\t\tthrow new AsanaTaskWriteError('conflict');\n\t\t}\n\n\t\treturn { ...target, project: target.project, membership: target.membership };\n\t}\n\n\tprivate async readBack(\n\t\ttarget: Context & { workspace: { id: string } },\n\t\tproject: AsanaTaskWriteProject,\n\t\ttaskId: string,\n\t\tmatches: (task: AsanaTaskReceipt, membership: AsanaTaskMembership) => boolean,\n\t): Promise<Omit<MutationTarget, 'capabilities'>> {\n\t\tlet task: AsanaTaskReceipt;\n\t\tlet workspace: AsanaTaskWriteWorkspace;\n\t\ttry {\n\t\t\t({ task, workspace } = await this.getTask(taskId));\n\t\t\tawait this.transport.verify();\n\t\t} catch (ex) {\n\t\t\tthrow new AsanaTaskWriteError(toAsanaTaskWriteFailure(ex).reason, 'applied', { taskId: taskId });\n\t\t}\n\n\t\tconst membership = getMembership(task, project.id);\n\t\tif (\n\t\t\ttask.id !== taskId ||\n\t\t\ttask.workspaceId !== target.workspace.id ||\n\t\t\tmembership == null ||\n\t\t\t!matches(task, membership)\n\t\t) {\n\t\t\tthrow new AsanaTaskWriteError('conflict', 'applied', { taskId: taskId });\n\t\t}\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\tconnectionId: target.connectionId,\n\t\t\taccountId: target.accountId,\n\t\t\taccount: target.account,\n\t\t\tworkspace: workspace,\n\t\t\tproject: project,\n\t\t\tmembership: membership,\n\t\t\ttask: task,\n\t\t};\n\t}\n\n\tprivate async getContext(options: AsanaTaskWriteScope) {\n\t\tconst { data: user } = await this.transport.read<{ gid: string; name: string; email?: string | null }>(\n\t\t\t'users/me',\n\t\t\t{ opt_fields: 'name,email' },\n\t\t);\n\t\tif (\n\t\t\t!isGid(user?.gid) ||\n\t\t\ttypeof user.name !== 'string' ||\n\t\t\t(user.email != null && typeof user.email !== 'string')\n\t\t) {\n\t\t\tthrow new AsanaTaskWriteError('unknown');\n\t\t}\n\t\tif (options.expectedAccountId !== undefined && user.gid !== options.expectedAccountId) {\n\t\t\tthrow new AsanaTaskWriteError('forbidden');\n\t\t}\n\n\t\treturn {\n\t\t\tok: true as const,\n\t\t\tconnectionId: options.connectionId,\n\t\t\taccountId: user.gid,\n\t\t\taccount: { id: user.gid, name: user.name, email: user.email ?? null } satisfies AsanaTaskWriteAccount,\n\t\t};\n\t}\n\n\tprivate async getTask(taskId: string): Promise<{ task: AsanaTaskReceipt; workspace: AsanaTaskWriteWorkspace }> {\n\t\tconst { data: task } = await this.transport.read<ApiTask>(`tasks/${taskId}`, { opt_fields: taskFields });\n\t\tif (!isTask(task)) throw new AsanaTaskWriteError('unknown');\n\t\tif (task.gid !== taskId) throw new AsanaTaskWriteError('conflict');\n\n\t\treturn { task: toReceipt(task), workspace: toCompact(task.workspace) };\n\t}\n\n\tprivate async getWorkspace(workspaceId: string): Promise<AsanaTaskWriteWorkspace> {\n\t\tconst { data: workspace } = await this.transport.read<Compact>(`workspaces/${workspaceId}`, {\n\t\t\topt_fields: 'name',\n\t\t});\n\t\tif (!isCompact(workspace)) throw new AsanaTaskWriteError('unknown');\n\t\tif (workspace.gid !== workspaceId) throw new AsanaTaskWriteError('conflict');\n\n\t\treturn toCompact(workspace);\n\t}\n\n\tprivate async getProject(projectId: string, workspaceId: string | undefined): Promise<ApiProject> {\n\t\tconst { data: project } = await this.transport.read<ApiProject>(`projects/${projectId}`, {\n\t\t\topt_fields: projectFields,\n\t\t});\n\t\tif (!isProject(project)) throw new AsanaTaskWriteError('unknown');\n\t\tif (project.gid !== projectId || (workspaceId !== undefined && project.workspace.gid !== workspaceId)) {\n\t\t\tthrow new AsanaTaskWriteError('conflict');\n\t\t}\n\n\t\treturn project;\n\t}\n\n\tprivate async getSections(projectId: string): Promise<AsanaTaskWriteSection[]> {\n\t\tconst { values, complete } = await this.readAll<Compact>(`projects/${projectId}/sections`, {\n\t\t\topt_fields: 'name',\n\t\t});\n\t\tif (!complete || !values.every(isCompact)) throw new AsanaTaskWriteError('unknown');\n\n\t\treturn values.map(toCompact);\n\t}\n\n\tprivate async readAll<T>(\n\t\tpath: string,\n\t\tparams: Record<string, string>,\n\t): Promise<{ values: T[]; complete: boolean }> {\n\t\tconst values: T[] = [];\n\t\tlet offset: string | undefined;\n\t\tfor (let page = 0; page < maxPages; page++) {\n\t\t\tconst body = await this.transport.read<T[]>(path, {\n\t\t\t\t...params,\n\t\t\t\tlimit: '100',\n\t\t\t\t...(offset != null && { offset: offset }),\n\t\t\t});\n\t\t\tif (!Array.isArray(body.data)) throw new AsanaTaskWriteError('unknown');\n\n\t\t\tvalues.push(...body.data);\n\t\t\toffset = body.next_page?.offset || undefined;\n\t\t\tif (offset == null) return { values: values, complete: true };\n\t\t}\n\n\t\treturn { values: values, complete: false };\n\t}\n\n\tprivate async withTaskMutation<T>(taskId: string, run: () => Promise<T>): Promise<T> {\n\t\tif (this.activeWrites.has(taskId)) throw new AsanaTaskWriteError('conflict');\n\n\t\tthis.activeWrites.add(taskId);\n\t\ttry {\n\t\t\treturn await run();\n\t\t} finally {\n\t\t\tthis.activeWrites.delete(taskId);\n\t\t}\n\t}\n}\n\nfunction allUnavailable(\n\treason: 'project-required' | 'not-in-project',\n): Extract<AsanaTaskWriteOptionsResult, { ok: true }>['capabilities'] {\n\tconst unavailable = { status: 'unavailable', reason: reason } as const;\n\treturn { edit: unavailable, complete: unavailable, reopen: unavailable, move: unavailable, delete: unavailable };\n}\n\nasync function dispatch(taskId: string, run: () => Promise<unknown>): Promise<void> {\n\ttry {\n\t\tawait run();\n\t} catch (ex) {\n\t\tconst failure = toAsanaTaskWriteFailure(ex);\n\t\tif (failure.applied !== 'yes' || failure.taskId != null) throw ex;\n\n\t\tthrow new AsanaTaskWriteError(failure.reason, 'applied', { taskId: taskId, messages: failure.messages });\n\t}\n}\n\nfunction toSdkIssue(taskId: string): { id: string; number: string; repository: null } {\n\treturn { id: taskId, number: taskId, repository: null };\n}\n"],"mappings":";;AAuBA,MAAM,aAAa;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC,CAAC,KAAK,GAAG;AACV,MAAM,gBAAgB;AACtB,MAAM,WAAW;AAsBjB,SAAS,MAAM,OAAiC;CAC/C,OAAO,OAAO,UAAU,YAAY,aAAa,KAAK,KAAK;AAC5D;AAEA,SAAS,SAAS,OAA4C;CAC7D,OACC,MAAM,QAAQ,KAAK,KACnB,MAAM,WAAW,KAEjB,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,KAAK,KACtB,IAAI,IAAI,KAAK,CAAC,CAAC,SAAS,MAAM;A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,IAAI;EAClB,UAAU;GACT,KAAK,aAAa,OAAO,MAAM;EAChC;CACD;AACD;AAEA,SAAS,eACR,QACqE;CACrE,MAAM,cAAc;EAAE,QAAQ;EAAuB;CAAO;CAC5D,OAAO;EAAE,MAAM;EAAa,UAAU;EAAa,QAAQ;EAAa,MAAM;EAAa,QAAQ;CAAY;AAChH;AAEA,eAAe,SAAS,QAAgB,KAA4C;CACnF,IAAI;EACH,MAAM,IAAI;CACX,SAAS,IAAI;EACZ,MAAM,UAAU,wBAAwB,EAAE;EAC1C,IAAI,QAAQ,YAAY,SAAS,QAAQ,UAAU,MAAM,MAAM;EAE/D,MAAM,IAAI,oBAAoB,QAAQ,QAAQ,WAAW;GAAU;GAAQ,UAAU,QAAQ;EAAS,CAAC;CACxG;AACD;AAEA,SAAS,WAAW,QAAkE;CACrF,OAAO;EAAE,IAAI;EAAQ,QAAQ;EAAQ,YAAY;CAAK;AACvD"}
@@ -1,4 +1,5 @@
1
1
  import { IssueSorting } from "../../../git/models/issue.js";
2
+ import "../providerFilters.js";
2
3
  //#region ../plus/integrations/src/providers/issueSorts.d.ts
3
4
  /** GitHub and GHE: one `search` channel serves all three issue reads, so all three order the same way. */
4
5
  export declare const githubIssueSorts: IssueSorting[];