@gitkraken/core-gitlens 0.67.0 → 0.68.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 (34) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/plus/integrations/authentication/configuredIntegrationService.js +2 -2
  3. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  4. package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +4 -2
  5. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +5 -4
  6. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  7. package/dist/plus/integrations/index.d.ts +2 -1
  8. package/dist/plus/integrations/index.js +9 -0
  9. package/dist/plus/integrations/index.js.map +1 -1
  10. package/dist/plus/integrations/integrationService.d.ts +14 -0
  11. package/dist/plus/integrations/integrationService.js +53 -0
  12. package/dist/plus/integrations/integrationService.js.map +1 -1
  13. package/dist/plus/integrations/manager.d.ts +6 -0
  14. package/dist/plus/integrations/models/publicIntegration.d.ts +0 -1
  15. package/dist/plus/integrations/models/trelloCardWrites.d.ts +117 -0
  16. package/dist/plus/integrations/models/trelloCardWrites.js +0 -0
  17. package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
  18. package/dist/plus/integrations/providers/providersApi.js +1 -4
  19. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  20. package/dist/plus/integrations/providers/trello.d.ts +3 -1
  21. package/dist/plus/integrations/providers/trello.js +28 -0
  22. package/dist/plus/integrations/providers/trello.js.map +1 -1
  23. package/dist/plus/integrations/providers/trelloApi.d.ts +5 -0
  24. package/dist/plus/integrations/providers/trelloApi.js +9 -0
  25. package/dist/plus/integrations/providers/trelloApi.js.map +1 -0
  26. package/dist/plus/integrations/providers/trelloCardWriteTransport.d.ts +28 -0
  27. package/dist/plus/integrations/providers/trelloCardWriteTransport.js +94 -0
  28. package/dist/plus/integrations/providers/trelloCardWriteTransport.js.map +1 -0
  29. package/dist/plus/integrations/providers/trelloCardWrites.d.ts +26 -0
  30. package/dist/plus/integrations/providers/trelloCardWrites.js +342 -0
  31. package/dist/plus/integrations/providers/trelloCardWrites.js.map +1 -0
  32. package/dist/plus/integrations/reads/drains.d.ts +0 -1
  33. package/docs/integrations.md +26 -0
  34. package/package.json +1 -1
@@ -0,0 +1,342 @@
1
+ import { TrelloCardWriteError } from "./trelloCardWriteTransport.js";
2
+ //#region ../plus/integrations/src/providers/trelloCardWrites.ts
3
+ const boardFields = "id,name,closed,url,memberships";
4
+ const cardFields = "id,idShort,shortLink,url,name,idBoard,idList,closed,desc,dateLastActivity";
5
+ const listFields = "id,name,idBoard,closed";
6
+ function isTrelloId(value) {
7
+ return typeof value === "string" && /^[a-f0-9]{24}$/.test(value);
8
+ }
9
+ function isTrelloShortLink(value) {
10
+ return typeof value === "string" && /^[a-zA-Z0-9]{8}$/.test(value);
11
+ }
12
+ function isTrelloCardWriteScope(scope, mutation) {
13
+ return typeof scope.connectionId === "string" && scope.connectionId.trim() !== "" && (!mutation && scope.expectedAccountId === void 0 || isTrelloId(scope.expectedAccountId));
14
+ }
15
+ function isBoard(board) {
16
+ return isTrelloId(board?.id) && typeof board.name === "string" && typeof board.closed === "boolean" && typeof board.url === "string" && board.url.length !== 0;
17
+ }
18
+ function isList(list, boardId) {
19
+ return isTrelloId(list?.id) && typeof list.name === "string" && list.idBoard === boardId && typeof list.closed === "boolean";
20
+ }
21
+ function isCard(card) {
22
+ return isTrelloId(card?.id) && Number.isSafeInteger(card.idShort) && card.idShort > 0 && isTrelloShortLink(card.shortLink) && typeof card.url === "string" && card.url.length !== 0 && typeof card.name === "string" && typeof card.desc === "string" && typeof card.dateLastActivity === "string" && Number.isFinite(Date.parse(card.dateLastActivity)) && isTrelloId(card.idBoard) && isTrelloId(card.idList) && typeof card.closed === "boolean";
23
+ }
24
+ function toReceipt(card) {
25
+ return {
26
+ id: card.id,
27
+ idShort: card.idShort,
28
+ shortLink: card.shortLink,
29
+ url: card.url,
30
+ name: card.name,
31
+ desc: card.desc,
32
+ dateLastActivity: card.dateLastActivity,
33
+ boardId: card.idBoard,
34
+ listId: card.idList,
35
+ closed: card.closed
36
+ };
37
+ }
38
+ function toList(list) {
39
+ return {
40
+ id: list.id,
41
+ name: list.name,
42
+ closed: list.closed
43
+ };
44
+ }
45
+ function getOpenLists(entries, boardId) {
46
+ if (!Array.isArray(entries) || !entries.every((list) => isList(list, boardId))) return void 0;
47
+ return entries.filter((list) => !list.closed).map(toList);
48
+ }
49
+ function toBoardOptions(board, permission, lists) {
50
+ return {
51
+ id: board.id,
52
+ name: board.name,
53
+ closed: board.closed,
54
+ url: board.url,
55
+ permission,
56
+ lists
57
+ };
58
+ }
59
+ function boardPermission(board, accountId) {
60
+ if (!Array.isArray(board.memberships)) return "unknown";
61
+ const membership = board.memberships.find((member) => member?.idMember === accountId);
62
+ if (membership == null) return "unknown";
63
+ if (membership.deactivated || membership.unconfirmed || membership.memberType === "observer") return "forbidden";
64
+ return membership.memberType === "admin" || membership.memberType === "normal" ? "allowed" : "unknown";
65
+ }
66
+ function boardCapability(board, permission) {
67
+ if (board.closed) return {
68
+ status: "unavailable",
69
+ reason: "board-closed"
70
+ };
71
+ if (permission === "forbidden") return {
72
+ status: "unavailable",
73
+ reason: "forbidden"
74
+ };
75
+ return { status: permission };
76
+ }
77
+ function ensureAvailable(capability) {
78
+ if (capability.status === "unavailable") throw new TrelloCardWriteError(capability.reason);
79
+ }
80
+ function validateMutationTarget(options) {
81
+ if (!isTrelloId(options.boardId) || !isTrelloId(options.listId) || !isTrelloId(options.cardId)) throw new TrelloCardWriteError("invalid-input");
82
+ }
83
+ function validateFields(name, description) {
84
+ if (name === void 0 && description === void 0 || name !== void 0 && (typeof name !== "string" || name.trim() === "") || description !== void 0 && typeof description !== "string") throw new TrelloCardWriteError("invalid-input");
85
+ }
86
+ function validateUpdate(options) {
87
+ validateMutationTarget(options);
88
+ switch (options.action) {
89
+ case "edit":
90
+ validateFields(options.name, options.description);
91
+ break;
92
+ case "move":
93
+ if (!isTrelloId(options.destinationBoardId) || !isTrelloId(options.destinationListId)) throw new TrelloCardWriteError("invalid-input");
94
+ if (options.destinationBoardId !== options.boardId) throw new TrelloCardWriteError("cross-board-move");
95
+ if (options.destinationListId === options.listId) throw new TrelloCardWriteError("invalid-input");
96
+ break;
97
+ case "archive":
98
+ case "restore": break;
99
+ default: throw new TrelloCardWriteError("invalid-input");
100
+ }
101
+ }
102
+ function validateResult(card, boardId, listId, closed, previous) {
103
+ if (!isCard(card) || card.idBoard !== boardId || card.idList !== listId || card.closed !== closed || previous != null && (card.id !== previous.id || card.idShort !== previous.idShort || card.shortLink !== previous.shortLink)) throw new TrelloCardWriteError("unknown", "uncertain");
104
+ return toReceipt(card);
105
+ }
106
+ var TrelloCardWriter = class {
107
+ transport;
108
+ activeWrites;
109
+ constructor(transport, activeWrites) {
110
+ this.transport = transport;
111
+ this.activeWrites = activeWrites;
112
+ }
113
+ verify() {
114
+ return this.transport.verify();
115
+ }
116
+ async getCreateOptions(options) {
117
+ if (options.boardId !== void 0 && !isTrelloId(options.boardId)) throw new TrelloCardWriteError("invalid-input");
118
+ const context = await this.getContext(options);
119
+ if (options.boardId !== void 0) {
120
+ const board = await this.getBoard(options.boardId);
121
+ const permission = boardPermission(board, context.accountId);
122
+ ensureAvailable(boardCapability(board, permission));
123
+ return {
124
+ ...context,
125
+ boards: [await this.getBoardOptions(board, permission)]
126
+ };
127
+ }
128
+ const candidates = await this.transport.read(`members/me/boards?filter=open&fields=${boardFields}&lists=open`);
129
+ if (!Array.isArray(candidates) || !candidates.every(isBoard)) throw new TrelloCardWriteError("unknown");
130
+ const boards = [];
131
+ const failures = [];
132
+ for (const board of candidates) {
133
+ const permission = boardPermission(board, context.accountId);
134
+ if (board.closed || permission === "forbidden") continue;
135
+ const lists = getOpenLists(board.lists, board.id);
136
+ if (lists == null) {
137
+ failures.push({
138
+ boardId: board.id,
139
+ reason: "unknown"
140
+ });
141
+ continue;
142
+ }
143
+ boards.push(toBoardOptions(board, permission, lists));
144
+ }
145
+ if (boards.length === 0 && failures.length !== 0) return {
146
+ ok: false,
147
+ reason: "unknown",
148
+ mutationDispatched: false,
149
+ boardFailures: failures
150
+ };
151
+ return {
152
+ ...context,
153
+ boards,
154
+ ...failures.length !== 0 && { boardFailures: failures }
155
+ };
156
+ }
157
+ async resolveTarget(options) {
158
+ const { boardId, listId, cardId } = options;
159
+ if (!isTrelloId(cardId) && !isTrelloShortLink(cardId) || boardId !== void 0 && !isTrelloId(boardId) || listId !== void 0 && !isTrelloId(listId)) throw new TrelloCardWriteError("invalid-input");
160
+ const context = await this.getContext(options);
161
+ let resolved;
162
+ let pinnedBoardId = boardId;
163
+ if (pinnedBoardId === void 0) {
164
+ resolved = await this.getCard(options);
165
+ pinnedBoardId = resolved.idBoard;
166
+ }
167
+ const board = await this.getBoard(pinnedBoardId);
168
+ const permission = boardPermission(board, context.accountId);
169
+ const boardOptions = await this.getBoardOptions(board, permission);
170
+ const card = resolved ?? await this.getCard(options);
171
+ const source = boardOptions.lists.find((list) => list.id === card.idList);
172
+ const list = source ?? await this.getList(card.idList, card.idBoard);
173
+ const destination = boardOptions.lists.some((list) => list.id !== card.idList);
174
+ let base = boardCapability(board, permission);
175
+ if (base.status !== "unavailable" && !source) base = {
176
+ status: "unavailable",
177
+ reason: "list-unavailable"
178
+ };
179
+ const active = base.status !== "unavailable" && card.closed ? {
180
+ status: "unavailable",
181
+ reason: "card-archived"
182
+ } : base;
183
+ return {
184
+ ...context,
185
+ board: boardOptions,
186
+ list,
187
+ card: toReceipt(card),
188
+ capabilities: {
189
+ edit: active,
190
+ move: active.status !== "unavailable" && !destination ? {
191
+ status: "unavailable",
192
+ reason: "list-unavailable"
193
+ } : active,
194
+ archive: active,
195
+ restore: base.status !== "unavailable" && !card.closed ? {
196
+ status: "unavailable",
197
+ reason: "card-open"
198
+ } : base,
199
+ delete: base
200
+ }
201
+ };
202
+ }
203
+ async write(options) {
204
+ if (options.action === "create") return this.create(options);
205
+ validateUpdate(options);
206
+ return this.withCardMutation(options.cardId, async () => {
207
+ const { card, board, list, capabilities, connectionId, accountId, account } = await this.resolveTarget(options);
208
+ const { action } = options;
209
+ ensureAvailable(capabilities[action]);
210
+ let destination = list;
211
+ let closed = card.closed;
212
+ let fields;
213
+ switch (action) {
214
+ case "edit":
215
+ fields = {
216
+ name: options.name,
217
+ desc: options.description
218
+ };
219
+ break;
220
+ case "move": {
221
+ const selected = board.lists.find((list) => list.id === options.destinationListId);
222
+ if (selected == null) throw new TrelloCardWriteError("list-unavailable");
223
+ destination = selected;
224
+ fields = { idList: destination.id };
225
+ break;
226
+ }
227
+ case "archive":
228
+ case "restore":
229
+ closed = action === "archive";
230
+ fields = { closed };
231
+ }
232
+ const receipt = {
233
+ ok: true,
234
+ connectionId,
235
+ accountId,
236
+ account,
237
+ card: validateResult(await this.transport.mutate("PUT", `cards/${card.id}`, fields), card.boardId, destination.id, closed, card),
238
+ board,
239
+ list: destination
240
+ };
241
+ return action === "move" ? {
242
+ ...receipt,
243
+ action,
244
+ sourceList: list,
245
+ destinationList: destination
246
+ } : {
247
+ ...receipt,
248
+ action
249
+ };
250
+ });
251
+ }
252
+ async delete(options) {
253
+ if (options.confirmed !== true) throw new TrelloCardWriteError("confirmation-required");
254
+ if (!isTrelloShortLink(options.shortLink) || typeof options.closed !== "boolean") throw new TrelloCardWriteError("invalid-input");
255
+ validateMutationTarget(options);
256
+ return this.withCardMutation(options.cardId, async () => {
257
+ const { capabilities, ...target } = await this.resolveTarget(options);
258
+ if (target.card.shortLink !== options.shortLink || target.card.closed !== options.closed) throw new TrelloCardWriteError("conflict");
259
+ ensureAvailable(capabilities.delete);
260
+ await this.transport.mutate("DELETE", `cards/${target.card.id}`);
261
+ return {
262
+ ...target,
263
+ deletion: { permanent: true }
264
+ };
265
+ });
266
+ }
267
+ async create(options) {
268
+ const { boardId, listId, name, description } = options;
269
+ if (!isTrelloId(boardId) || !isTrelloId(listId) || typeof name !== "string") throw new TrelloCardWriteError("invalid-input");
270
+ validateFields(name, description);
271
+ const context = await this.getContext(options);
272
+ const board = await this.getBoard(boardId);
273
+ const permission = boardPermission(board, context.accountId);
274
+ ensureAvailable(boardCapability(board, permission));
275
+ const boardOptions = await this.getBoardOptions(board, permission);
276
+ const list = boardOptions.lists.find((list) => list.id === listId);
277
+ if (list == null) throw new TrelloCardWriteError("list-unavailable");
278
+ const result = await this.transport.mutate("POST", "cards", {
279
+ idList: listId,
280
+ name,
281
+ desc: description
282
+ });
283
+ return {
284
+ ...context,
285
+ action: "create",
286
+ card: validateResult(result, boardId, listId, false),
287
+ board: boardOptions,
288
+ list
289
+ };
290
+ }
291
+ async getContext(options) {
292
+ const member = await this.transport.read("members/me?fields=id,username,fullName");
293
+ if (!isTrelloId(member?.id) || typeof member.username !== "string" || typeof member.fullName !== "string") throw new TrelloCardWriteError("unknown");
294
+ if (options.expectedAccountId !== void 0 && member.id !== options.expectedAccountId) throw new TrelloCardWriteError("forbidden");
295
+ return {
296
+ ok: true,
297
+ connectionId: options.connectionId,
298
+ accountId: member.id,
299
+ account: {
300
+ id: member.id,
301
+ username: member.username,
302
+ name: member.fullName
303
+ }
304
+ };
305
+ }
306
+ async getCard({ cardId, boardId, listId }) {
307
+ const card = await this.transport.read(`cards/${cardId}?fields=${cardFields}`);
308
+ if (!isCard(card)) throw new TrelloCardWriteError("unknown");
309
+ if ((isTrelloId(cardId) ? card.id : card.shortLink) !== cardId || boardId !== void 0 && card.idBoard !== boardId || listId !== void 0 && card.idList !== listId) throw new TrelloCardWriteError("conflict");
310
+ return card;
311
+ }
312
+ async getList(listId, boardId) {
313
+ const list = await this.transport.read(`lists/${listId}?fields=id,name,idBoard,closed`);
314
+ if (!isList(list, boardId) || list.id !== listId) throw new TrelloCardWriteError("conflict");
315
+ return toList(list);
316
+ }
317
+ async getBoard(boardId) {
318
+ const board = await this.transport.read(`boards/${boardId}?fields=${boardFields}`);
319
+ if (!isBoard(board)) throw new TrelloCardWriteError("unknown");
320
+ if (board.id !== boardId) throw new TrelloCardWriteError("conflict");
321
+ return board;
322
+ }
323
+ async getBoardOptions(board, permission) {
324
+ if (board.closed) return toBoardOptions(board, permission, []);
325
+ const lists = getOpenLists(await this.transport.read(`boards/${board.id}/lists?filter=open&fields=${listFields}`), board.id);
326
+ if (lists == null) throw new TrelloCardWriteError("unknown");
327
+ return toBoardOptions(board, permission, lists);
328
+ }
329
+ async withCardMutation(cardId, run) {
330
+ if (this.activeWrites.has(cardId)) throw new TrelloCardWriteError("conflict");
331
+ this.activeWrites.add(cardId);
332
+ try {
333
+ return await run();
334
+ } finally {
335
+ this.activeWrites.delete(cardId);
336
+ }
337
+ }
338
+ };
339
+ //#endregion
340
+ export { TrelloCardWriter, isTrelloCardWriteScope };
341
+
342
+ //# sourceMappingURL=trelloCardWrites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trelloCardWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/trelloCardWrites.ts"],"sourcesContent":["import type {\n\tTrelloCardCreateOptions,\n\tTrelloCardCreateOptionsResult,\n\tTrelloCardDeleteOptions,\n\tTrelloCardDeleteResult,\n\tTrelloCardMutationTarget,\n\tTrelloCardReceipt,\n\tTrelloCardWriteAccount,\n\tTrelloCardWriteBoard,\n\tTrelloCardWriteCapability,\n\tTrelloCardWriteList,\n\tTrelloCardWriteOptions,\n\tTrelloCardWriteOptionsResult,\n\tTrelloCardWriteResult,\n\tTrelloCardWriteScope,\n\tTrelloCardWriteTargetOptions,\n} from '../models/trelloCardWrites.js';\nimport { TrelloCardWriteError } from './trelloCardWriteTransport.js';\nimport type { TrelloCardWriteTransport } from './trelloCardWriteTransport.js';\n\nconst boardFields = 'id,name,closed,url,memberships';\nconst cardFields = 'id,idShort,shortLink,url,name,idBoard,idList,closed,desc,dateLastActivity';\nconst listFields = 'id,name,idBoard,closed';\n\ntype Board = Pick<TrelloCardWriteBoard, 'id' | 'name' | 'closed' | 'url'> & {\n\tmemberships?: { idMember: string; memberType: string; deactivated?: boolean; unconfirmed?: boolean }[];\n};\ntype List = TrelloCardWriteList & { idBoard: string };\ntype Card = Omit<TrelloCardReceipt, 'boardId' | 'listId'> & { idBoard: string; idList: string };\ntype ResolvedTarget = Extract<TrelloCardWriteOptionsResult, { ok: true }>;\n\nfunction isTrelloId(value: unknown): value is string {\n\treturn typeof value === 'string' && /^[a-f0-9]{24}$/.test(value);\n}\n\nfunction isTrelloShortLink(value: unknown): value is string {\n\treturn typeof value === 'string' && /^[a-zA-Z0-9]{8}$/.test(value);\n}\n\nexport function isTrelloCardWriteScope(scope: TrelloCardWriteScope, mutation: boolean): boolean {\n\treturn (\n\t\ttypeof scope.connectionId === 'string' &&\n\t\tscope.connectionId.trim() !== '' &&\n\t\t((!mutation && scope.expectedAccountId === undefined) || isTrelloId(scope.expectedAccountId))\n\t);\n}\n\nfunction isBoard(board: Board | null | undefined): board is Board {\n\treturn (\n\t\tisTrelloId(board?.id) &&\n\t\ttypeof board.name === 'string' &&\n\t\ttypeof board.closed === 'boolean' &&\n\t\ttypeof board.url === 'string' &&\n\t\tboard.url.length !== 0\n\t);\n}\n\nfunction isList(list: List | null | undefined, boardId: string): list is List {\n\treturn (\n\t\tisTrelloId(list?.id) &&\n\t\ttypeof list.name === 'string' &&\n\t\tlist.idBoard === boardId &&\n\t\ttypeof list.closed === 'boolean'\n\t);\n}\n\nfunction isCard(card: Card | null | undefined): card is Card {\n\treturn (\n\t\tisTrelloId(card?.id) &&\n\t\tNumber.isSafeInteger(card.idShort) &&\n\t\tcard.idShort > 0 &&\n\t\tisTrelloShortLink(card.shortLink) &&\n\t\ttypeof card.url === 'string' &&\n\t\tcard.url.length !== 0 &&\n\t\ttypeof card.name === 'string' &&\n\t\ttypeof card.desc === 'string' &&\n\t\ttypeof card.dateLastActivity === 'string' &&\n\t\tNumber.isFinite(Date.parse(card.dateLastActivity)) &&\n\t\tisTrelloId(card.idBoard) &&\n\t\tisTrelloId(card.idList) &&\n\t\ttypeof card.closed === 'boolean'\n\t);\n}\n\nfunction toReceipt(card: Card): TrelloCardReceipt {\n\treturn {\n\t\tid: card.id,\n\t\tidShort: card.idShort,\n\t\tshortLink: card.shortLink,\n\t\turl: card.url,\n\t\tname: card.name,\n\t\tdesc: card.desc,\n\t\tdateLastActivity: card.dateLastActivity,\n\t\tboardId: card.idBoard,\n\t\tlistId: card.idList,\n\t\tclosed: card.closed,\n\t};\n}\n\nfunction toList(list: List): TrelloCardWriteList {\n\treturn { id: list.id, name: list.name, closed: list.closed };\n}\n\nfunction getOpenLists(entries: List[] | undefined, boardId: string): TrelloCardWriteList[] | undefined {\n\tif (!Array.isArray(entries) || !entries.every(list => isList(list, boardId))) return undefined;\n\n\treturn entries.filter(list => !list.closed).map(toList);\n}\n\nfunction toBoardOptions(\n\tboard: Board,\n\tpermission: TrelloCardWriteBoard['permission'],\n\tlists: readonly TrelloCardWriteList[],\n): TrelloCardWriteBoard {\n\treturn {\n\t\tid: board.id,\n\t\tname: board.name,\n\t\tclosed: board.closed,\n\t\turl: board.url,\n\t\tpermission: permission,\n\t\tlists: lists,\n\t};\n}\n\nfunction boardPermission(board: Board, accountId: string): TrelloCardWriteBoard['permission'] {\n\tif (!Array.isArray(board.memberships)) return 'unknown';\n\n\tconst membership = board.memberships.find(member => member?.idMember === accountId);\n\tif (membership == null) return 'unknown';\n\tif (membership.deactivated || membership.unconfirmed || membership.memberType === 'observer') {\n\t\treturn 'forbidden';\n\t}\n\n\treturn membership.memberType === 'admin' || membership.memberType === 'normal' ? 'allowed' : 'unknown';\n}\n\nfunction boardCapability(board: Board, permission: TrelloCardWriteBoard['permission']): TrelloCardWriteCapability {\n\tif (board.closed) return { status: 'unavailable', reason: 'board-closed' };\n\tif (permission === 'forbidden') return { status: 'unavailable', reason: 'forbidden' };\n\n\treturn { status: permission };\n}\n\nfunction ensureAvailable(capability: TrelloCardWriteCapability): void {\n\tif (capability.status === 'unavailable') throw new TrelloCardWriteError(capability.reason);\n}\n\nfunction validateMutationTarget(options: TrelloCardMutationTarget): void {\n\tif (!isTrelloId(options.boardId) || !isTrelloId(options.listId) || !isTrelloId(options.cardId)) {\n\t\tthrow new TrelloCardWriteError('invalid-input');\n\t}\n}\n\nfunction validateFields(name: string | undefined, description: string | undefined): void {\n\tif (\n\t\t(name === undefined && description === undefined) ||\n\t\t(name !== undefined && (typeof name !== 'string' || name.trim() === '')) ||\n\t\t(description !== undefined && typeof description !== 'string')\n\t) {\n\t\tthrow new TrelloCardWriteError('invalid-input');\n\t}\n}\n\nfunction validateUpdate(options: Exclude<TrelloCardWriteOptions, { action: 'create' }>): void {\n\tvalidateMutationTarget(options);\n\tswitch (options.action) {\n\t\tcase 'edit':\n\t\t\tvalidateFields(options.name, options.description);\n\t\t\tbreak;\n\t\tcase 'move':\n\t\t\tif (!isTrelloId(options.destinationBoardId) || !isTrelloId(options.destinationListId)) {\n\t\t\t\tthrow new TrelloCardWriteError('invalid-input');\n\t\t\t}\n\t\t\tif (options.destinationBoardId !== options.boardId) throw new TrelloCardWriteError('cross-board-move');\n\t\t\tif (options.destinationListId === options.listId) throw new TrelloCardWriteError('invalid-input');\n\n\t\t\tbreak;\n\t\tcase 'archive':\n\t\tcase 'restore':\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new TrelloCardWriteError('invalid-input');\n\t}\n}\n\nfunction validateResult(\n\tcard: Card,\n\tboardId: string,\n\tlistId: string,\n\tclosed: boolean,\n\tprevious?: TrelloCardReceipt,\n): TrelloCardReceipt {\n\tif (\n\t\t!isCard(card) ||\n\t\tcard.idBoard !== boardId ||\n\t\tcard.idList !== listId ||\n\t\tcard.closed !== closed ||\n\t\t(previous != null &&\n\t\t\t(card.id !== previous.id || card.idShort !== previous.idShort || card.shortLink !== previous.shortLink))\n\t) {\n\t\tthrow new TrelloCardWriteError('unknown', 'uncertain');\n\t}\n\n\treturn toReceipt(card);\n}\n\nexport class TrelloCardWriter {\n\tconstructor(\n\t\tprivate readonly transport: TrelloCardWriteTransport,\n\t\tprivate readonly activeWrites: Set<string>,\n\t) {}\n\n\tverify(): Promise<void> {\n\t\treturn this.transport.verify();\n\t}\n\n\tasync getCreateOptions(options: TrelloCardCreateOptions): Promise<TrelloCardCreateOptionsResult> {\n\t\tif (options.boardId !== undefined && !isTrelloId(options.boardId)) {\n\t\t\tthrow new TrelloCardWriteError('invalid-input');\n\t\t}\n\n\t\tconst context = await this.getContext(options);\n\t\tif (options.boardId !== undefined) {\n\t\t\tconst board = await this.getBoard(options.boardId);\n\t\t\tconst permission = boardPermission(board, context.accountId);\n\t\t\tensureAvailable(boardCapability(board, permission));\n\n\t\t\treturn { ...context, boards: [await this.getBoardOptions(board, permission)] };\n\t\t}\n\n\t\tconst candidates = await this.transport.read<(Board & { lists?: List[] })[]>(\n\t\t\t`members/me/boards?filter=open&fields=${boardFields}&lists=open`,\n\t\t);\n\t\tif (!Array.isArray(candidates) || !candidates.every(isBoard)) throw new TrelloCardWriteError('unknown');\n\n\t\tconst boards: TrelloCardWriteBoard[] = [];\n\t\tconst failures: NonNullable<TrelloCardCreateOptionsResult['boardFailures']>[number][] = [];\n\t\tfor (const board of candidates) {\n\t\t\tconst permission = boardPermission(board, context.accountId);\n\t\t\tif (board.closed || permission === 'forbidden') continue;\n\n\t\t\tconst lists = getOpenLists(board.lists, board.id);\n\t\t\tif (lists == null) {\n\t\t\t\tfailures.push({ boardId: board.id, reason: 'unknown' });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tboards.push(toBoardOptions(board, permission, lists));\n\t\t}\n\n\t\tif (boards.length === 0 && failures.length !== 0) {\n\t\t\treturn { ok: false, reason: 'unknown', mutationDispatched: false, boardFailures: failures };\n\t\t}\n\n\t\treturn { ...context, boards: boards, ...(failures.length !== 0 && { boardFailures: failures }) };\n\t}\n\n\tasync resolveTarget(options: TrelloCardWriteTargetOptions): Promise<ResolvedTarget> {\n\t\tconst { boardId, listId, cardId } = options;\n\t\tif (\n\t\t\t(!isTrelloId(cardId) && !isTrelloShortLink(cardId)) ||\n\t\t\t(boardId !== undefined && !isTrelloId(boardId)) ||\n\t\t\t(listId !== undefined && !isTrelloId(listId))\n\t\t) {\n\t\t\tthrow new TrelloCardWriteError('invalid-input');\n\t\t}\n\n\t\tconst context = await this.getContext(options);\n\t\tlet resolved: Card | undefined;\n\t\tlet pinnedBoardId = boardId;\n\t\tif (pinnedBoardId === undefined) {\n\t\t\tresolved = await this.getCard(options);\n\t\t\tpinnedBoardId = resolved.idBoard;\n\t\t}\n\n\t\tconst board = await this.getBoard(pinnedBoardId);\n\t\tconst permission = boardPermission(board, context.accountId);\n\t\tconst boardOptions = await this.getBoardOptions(board, permission);\n\t\tconst card = resolved ?? (await this.getCard(options));\n\n\t\tconst source = boardOptions.lists.find(list => list.id === card.idList);\n\t\tconst list = source ?? (await this.getList(card.idList, card.idBoard));\n\t\tconst destination = boardOptions.lists.some(list => list.id !== card.idList);\n\t\tlet base = boardCapability(board, permission);\n\t\tif (base.status !== 'unavailable' && !source) {\n\t\t\tbase = { status: 'unavailable', reason: 'list-unavailable' };\n\t\t}\n\t\tconst active =\n\t\t\tbase.status !== 'unavailable' && card.closed\n\t\t\t\t? ({ status: 'unavailable', reason: 'card-archived' } as const)\n\t\t\t\t: base;\n\t\treturn {\n\t\t\t...context,\n\t\t\tboard: boardOptions,\n\t\t\tlist: list,\n\t\t\tcard: toReceipt(card),\n\t\t\tcapabilities: {\n\t\t\t\tedit: active,\n\t\t\t\tmove:\n\t\t\t\t\tactive.status !== 'unavailable' && !destination\n\t\t\t\t\t\t? { status: 'unavailable', reason: 'list-unavailable' }\n\t\t\t\t\t\t: active,\n\t\t\t\tarchive: active,\n\t\t\t\trestore:\n\t\t\t\t\tbase.status !== 'unavailable' && !card.closed\n\t\t\t\t\t\t? { status: 'unavailable', reason: 'card-open' }\n\t\t\t\t\t\t: base,\n\t\t\t\tdelete: base,\n\t\t\t},\n\t\t};\n\t}\n\n\tasync write(options: TrelloCardWriteOptions): Promise<TrelloCardWriteResult> {\n\t\tif (options.action === 'create') return this.create(options);\n\n\t\tvalidateUpdate(options);\n\t\treturn this.withCardMutation(options.cardId, async () => {\n\t\t\tconst target = await this.resolveTarget(options);\n\t\t\tconst { card, board, list, capabilities, connectionId, accountId, account } = target;\n\t\t\tconst { action } = options;\n\t\t\tensureAvailable(capabilities[action]);\n\t\t\tlet destination = list;\n\t\t\tlet closed = card.closed;\n\t\t\tlet fields: Record<string, string | boolean | undefined>;\n\t\t\tswitch (action) {\n\t\t\t\tcase 'edit':\n\t\t\t\t\tfields = { name: options.name, desc: options.description };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'move': {\n\t\t\t\t\tconst selected = board.lists.find(list => list.id === options.destinationListId);\n\t\t\t\t\tif (selected == null) throw new TrelloCardWriteError('list-unavailable');\n\n\t\t\t\t\tdestination = selected;\n\t\t\t\t\tfields = { idList: destination.id };\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'archive':\n\t\t\t\tcase 'restore':\n\t\t\t\t\tclosed = action === 'archive';\n\t\t\t\t\tfields = { closed: closed };\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst result = await this.transport.mutate<Card>('PUT', `cards/${card.id}`, fields);\n\t\t\tconst receipt = {\n\t\t\t\tok: true as const,\n\t\t\t\tconnectionId: connectionId,\n\t\t\t\taccountId: accountId,\n\t\t\t\taccount: account,\n\t\t\t\tcard: validateResult(result, card.boardId, destination.id, closed, card),\n\t\t\t\tboard: board,\n\t\t\t\tlist: destination,\n\t\t\t};\n\t\t\treturn action === 'move'\n\t\t\t\t? { ...receipt, action: action, sourceList: list, destinationList: destination }\n\t\t\t\t: { ...receipt, action: action };\n\t\t});\n\t}\n\n\tasync delete(options: TrelloCardDeleteOptions): Promise<TrelloCardDeleteResult> {\n\t\tif (options.confirmed !== true) throw new TrelloCardWriteError('confirmation-required');\n\t\tif (!isTrelloShortLink(options.shortLink) || typeof options.closed !== 'boolean') {\n\t\t\tthrow new TrelloCardWriteError('invalid-input');\n\t\t}\n\n\t\tvalidateMutationTarget(options);\n\t\treturn this.withCardMutation(options.cardId, async () => {\n\t\t\tconst { capabilities, ...target } = await this.resolveTarget(options);\n\t\t\tif (target.card.shortLink !== options.shortLink || target.card.closed !== options.closed) {\n\t\t\t\tthrow new TrelloCardWriteError('conflict');\n\t\t\t}\n\n\t\t\tensureAvailable(capabilities.delete);\n\t\t\tawait this.transport.mutate('DELETE', `cards/${target.card.id}`);\n\t\t\treturn { ...target, deletion: { permanent: true } };\n\t\t});\n\t}\n\n\tprivate async create(\n\t\toptions: Extract<TrelloCardWriteOptions, { action: 'create' }>,\n\t): Promise<TrelloCardWriteResult> {\n\t\tconst { boardId, listId, name, description } = options;\n\t\tif (!isTrelloId(boardId) || !isTrelloId(listId) || typeof name !== 'string') {\n\t\t\tthrow new TrelloCardWriteError('invalid-input');\n\t\t}\n\n\t\tvalidateFields(name, description);\n\t\tconst context = await this.getContext(options);\n\t\tconst board = await this.getBoard(boardId);\n\t\tconst permission = boardPermission(board, context.accountId);\n\t\tensureAvailable(boardCapability(board, permission));\n\t\tconst boardOptions = await this.getBoardOptions(board, permission);\n\t\tconst list = boardOptions.lists.find(list => list.id === listId);\n\t\tif (list == null) throw new TrelloCardWriteError('list-unavailable');\n\n\t\tconst result = await this.transport.mutate<Card>('POST', 'cards', {\n\t\t\tidList: listId,\n\t\t\tname: name,\n\t\t\tdesc: description,\n\t\t});\n\t\treturn {\n\t\t\t...context,\n\t\t\taction: 'create',\n\t\t\tcard: validateResult(result, boardId, listId, false),\n\t\t\tboard: boardOptions,\n\t\t\tlist: list,\n\t\t};\n\t}\n\n\tprivate async getContext(options: TrelloCardWriteScope) {\n\t\tconst member = await this.transport.read<Omit<TrelloCardWriteAccount, 'name'> & { fullName: string }>(\n\t\t\t'members/me?fields=id,username,fullName',\n\t\t);\n\t\tif (!isTrelloId(member?.id) || typeof member.username !== 'string' || typeof member.fullName !== 'string') {\n\t\t\tthrow new TrelloCardWriteError('unknown');\n\t\t}\n\t\tif (options.expectedAccountId !== undefined && member.id !== options.expectedAccountId) {\n\t\t\tthrow new TrelloCardWriteError('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: member.id,\n\t\t\taccount: { id: member.id, username: member.username, name: member.fullName },\n\t\t};\n\t}\n\n\tprivate async getCard({ cardId, boardId, listId }: TrelloCardWriteTargetOptions): Promise<Card> {\n\t\tconst card = await this.transport.read<Card>(`cards/${cardId}?fields=${cardFields}`);\n\t\tif (!isCard(card)) throw new TrelloCardWriteError('unknown');\n\n\t\tconst identity = isTrelloId(cardId) ? card.id : card.shortLink;\n\t\tif (\n\t\t\tidentity !== cardId ||\n\t\t\t(boardId !== undefined && card.idBoard !== boardId) ||\n\t\t\t(listId !== undefined && card.idList !== listId)\n\t\t) {\n\t\t\tthrow new TrelloCardWriteError('conflict');\n\t\t}\n\n\t\treturn card;\n\t}\n\n\tprivate async getList(listId: string, boardId: string): Promise<TrelloCardWriteList> {\n\t\tconst list = await this.transport.read<List>(`lists/${listId}?fields=id,name,idBoard,closed`);\n\t\tif (!isList(list, boardId) || list.id !== listId) throw new TrelloCardWriteError('conflict');\n\n\t\treturn toList(list);\n\t}\n\n\tprivate async getBoard(boardId: string): Promise<Board> {\n\t\tconst board = await this.transport.read<Board>(`boards/${boardId}?fields=${boardFields}`);\n\t\tif (!isBoard(board)) throw new TrelloCardWriteError('unknown');\n\t\tif (board.id !== boardId) throw new TrelloCardWriteError('conflict');\n\n\t\treturn board;\n\t}\n\n\tprivate async getBoardOptions(\n\t\tboard: Board,\n\t\tpermission: TrelloCardWriteBoard['permission'],\n\t): Promise<TrelloCardWriteBoard> {\n\t\tif (board.closed) return toBoardOptions(board, permission, []);\n\n\t\tconst entries = await this.transport.read<List[]>(`boards/${board.id}/lists?filter=open&fields=${listFields}`);\n\t\tconst lists = getOpenLists(entries, board.id);\n\t\tif (lists == null) throw new TrelloCardWriteError('unknown');\n\n\t\treturn toBoardOptions(board, permission, lists);\n\t}\n\n\tprivate async withCardMutation<T>(cardId: string, run: () => Promise<T>): Promise<T> {\n\t\tif (this.activeWrites.has(cardId)) throw new TrelloCardWriteError('conflict');\n\n\t\tthis.activeWrites.add(cardId);\n\t\ttry {\n\t\t\treturn await run();\n\t\t} finally {\n\t\t\tthis.activeWrites.delete(cardId);\n\t\t}\n\t}\n}\n"],"mappings":";;AAoBA,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,aAAa;AASnB,SAAS,WAAW,OAAiC;CACpD,OAAO,OAAO,UAAU,YAAY,iBAAiB,KAAK,KAAK;AAChE;AAEA,SAAS,kBAAkB,OAAiC;CAC3D,OAAO,OAAO,UAAU,YAAY,mBAAmB,KAAK,KAAK;AAClE;AAEA,SAAgB,uBAAuB,OAA6B,UAA4B;CAC/F,OACC,OAAO,MAAM,iBAAiB,YAC9B,MAAM,aAAa,KAAK,MAAM,OAC5B,CAAC,YAAY,MAAM,sBAAsB,KAAA,KAAc,WAAW,MAAM,iBAAiB;AAE7F;AAEA,SAAS,QAAQ,OAAiD;CACjE,OACC,WAAW,OAAO,EAAE,KACpB,OAAO,MAAM,SAAS,YACtB,OAAO,MAAM,WAAW,aACxB,OAAO,MAAM,QAAQ,YACrB,MAAM,IAAI,WAAW;AAEvB;AAEA,SAAS,OAAO,MAA+B,SAA+B;CAC7E,OACC,WAAW,MAAM,EAAE,KACnB,OAAO,KAAK,SAAS,YACrB,KAAK,YAAY,WACjB,OAAO,KAAK,WAAW;AAEzB;AAEA,SAAS,OAAO,MAA6C;CAC5D,OACC,WAAW,MAAM,EAAE,KACnB,OAAO,cAAc,KAAK,OAAO,KACjC,KAAK,UAAU,KACf,kBAAkB,KAAK,SAAS,KAChC,OAAO,KAAK,QAAQ,YACpB,KAAK,IAAI,WAAW,KACpB,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,SAAS,YACrB,OAAO,KAAK,qBAAqB,YACjC,OAAO,SAAS,KAAK,MAAM,KAAK,gBAAgB,C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,qBAAqB,SAAS;EAC7D,IAAI,MAAM,OAAO,SAAS,MAAM,IAAI,qBAAqB,UAAU;EAEnE,OAAO;CACR;CAEA,MAAc,gBACb,OACA,YACgC;EAChC,IAAI,MAAM,QAAQ,OAAO,eAAe,OAAO,YAAY,CAAC,CAAC;EAG7D,MAAM,QAAQ,aAAa,MADL,KAAK,UAAU,KAAa,UAAU,MAAM,GAAG,4BAA4B,YAAY,GACzE,MAAM,EAAE;EAC5C,IAAI,SAAS,MAAM,MAAM,IAAI,qBAAqB,SAAS;EAE3D,OAAO,eAAe,OAAO,YAAY,KAAK;CAC/C;CAEA,MAAc,iBAAoB,QAAgB,KAAmC;EACpF,IAAI,KAAK,aAAa,IAAI,MAAM,GAAG,MAAM,IAAI,qBAAqB,UAAU;EAE5E,KAAK,aAAa,IAAI,MAAM;EAC5B,IAAI;GACH,OAAO,MAAM,IAAI;EAClB,UAAU;GACT,KAAK,aAAa,OAAO,MAAM;EAChC;CACD;AACD"}
@@ -1,7 +1,6 @@
1
1
  import { ResourceDescriptor } from "../../../git/models/resourceDescriptor.js";
2
2
  import { PullRequest, PullRequestFilter, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
3
3
  import { IntegrationIds } from "../constants.js";
4
- import "../providerFilters.js";
5
4
  import { ProviderWarning } from "../results.js";
6
5
  import { ProviderSweepTarget, PullRequestSweepOptions } from "../manager.js";
7
6
  import { IntegrationResult } from "../models/publicIntegration.js";
@@ -1247,6 +1247,32 @@ Core sends each mutation once. See [Linear's GraphQL API](https://linear.app/dev
1247
1247
  [GraphQL schema](https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference/objects/Mutation)
1248
1248
  and [delete and archive guidance](https://linear.app/docs/delete-archive-issues).
1249
1249
 
1250
+ ### Trello card writes
1251
+
1252
+ Import the Trello methods and types from `@gitkraken/core-gitlens/plus/integrations/index.js`. All calls use the explicitly selected `connectionId` and its paired Trello app key and token. Discovery and point reads accept an optional `expectedAccountId`. Every mutation requires the Trello member ID from discovery or the read path. Successful calls return the authenticated `account` with its `id`, `username`, and `name`.
1253
+
1254
+ | Method | Input beyond the connection and account | Success |
1255
+ | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
1256
+ | `getTrelloCardCreateOptions` | Optional `boardId` | Open boards and lists with allowed or unknown write permissions. |
1257
+ | `getTrelloCardWriteOptions`, `resolveTrelloCardWriteTarget` | `cardId` as a canonical 24-character hexadecimal ID or case-sensitive short link, and optional `boardId` and `listId` | Current card, board, list, the board's open lists, and individual action capabilities. |
1258
+ | `writeTrelloCard` with `action: 'create'` | `boardId`, `listId`, nonblank `name`, and optional `description` | Created card and destination. |
1259
+ | `writeTrelloCard` with `action: 'edit'` | `boardId`, `listId`, canonical `cardId`, and at least one of `name` or `description` | Updated card. An omitted description preserves its value. An empty string clears it. |
1260
+ | `writeTrelloCard` with `action: 'move'` | `boardId`, `listId`, canonical `cardId`, `destinationBoardId`, and `destinationListId` | Updated card with both `sourceList` and `destinationList`. |
1261
+ | `writeTrelloCard` with `action: 'archive'` or `'restore'` | `boardId`, `listId`, and canonical `cardId` | Updated card with `closed: true` or `false`, respectively. |
1262
+ | `deleteTrelloCard` | `boardId`, `listId`, canonical `cardId`, resolved `shortLink` and `closed` values, and `confirmed: true` | Pre-delete card, board, and list with `deletion.permanent: true`. |
1263
+
1264
+ Card receipts include the canonical `id`, board-local `idShort`, `shortLink`, `url`, `name`, `desc`, `dateLastActivity`, `boardId`, `listId`, and `closed`. Use the canonical `id` for every mutation. Point reads accept the `shortLink` from the `/c/<shortLink>/…` URL and work on visible archived cards and read-only boards. Supplied board and list pins must match the provider's current card coordinates. [Trello card REST operations](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/), [Trello object definitions](https://developer.atlassian.com/cloud/trello/guides/rest-api/object-definitions/)
1265
+
1266
+ The GitKraken Trello authorization requests `read`, `write`, and `account`. Active normal members and board admins have board-role permission to write. Trello can still refuse a request under Workspace restrictions. Explicit board observers and inactive or unconfirmed memberships receive `forbidden`. An absent or inconclusive board role is reported as `permission: 'unknown'` or capability `status: 'unknown'`. A paid Workspace admin can edit boards without direct membership, so Trello decides whether to allow those writes. [Trello authorization](https://developer.atlassian.com/cloud/trello/guides/rest-api/authorization/), [board permissions](https://support.atlassian.com/trello/docs/changing-permissions-on-a-board/), [Workspace admin permissions](https://support.atlassian.com/trello/docs/workspace-admin-capabilities/), [Workspace collaborator limits](https://support.atlassian.com/trello/docs/workspace-user-limit/)
1267
+
1268
+ Create discovery reads the member's open boards with their embedded open lists in one request. It includes boards where write permission is unknown. To check a board outside the member's board listing, pass its canonical `boardId`. A pinned board returns a typed failure if it is missing, closed, or inaccessible. Invalid embedded list data is reported in `boardFailures` by board ID. If every candidate has invalid list data, discovery returns `ok: false`, `reason: 'unknown'` and all board failures. An `unknown` failure reason covers unexpected provider responses or an unclassified transport failure. It is separate from the `unknown` board role or action capability reported on a successful discovery. [Member boards API](https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-boards-get), [nested lists](https://developer.atlassian.com/cloud/trello/guides/rest-api/nested-resources/#lists-nested-resource), [board lists API](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-lists-get), [list API](https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-get)
1269
+
1270
+ Moves use the card update endpoint with `idList` and preserve the canonical ID, short link, and board-local number. Destinations must be different open lists on the pinned board. A different destination board returns `cross-board-move`. A move to the current list returns `invalid-input` before preflight. Restore an archived card before editing or moving it. Cards on a closed board or in a closed list remain resolvable, with mutations refused as `board-closed` or `list-unavailable`. Restore keeps the original list. [Trello card update API](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put)
1271
+
1272
+ For permanent deletion, resolve the exact target before presenting it for confirmation. Call `deleteTrelloCard` only after approval and carry the resolved member, board, list, and card IDs, plus the confirmed short link and archived state. The same confirmation applies to open and archived cards. A successful delete is permanent. [Trello delete API](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-delete), [Trello archive and delete guidance](https://support.atlassian.com/trello/docs/archiving-and-deleting-cards/)
1273
+
1274
+ Core revalidates the pins and session before dispatch. Trello's write endpoints have no atomic precondition for the card's current board or list, so an external change can race the final read. A preflight refusal returns `mutationDispatched: false`. A definitive provider rejection returns a typed reason such as `forbidden`, `not-found`, or `rate-limit`. A lost or ambiguous mutation response returns `applied: 'maybe'`. Reconcile that outcome using a read before attempting another write. The integration runtime's `http.fetch` must send these Trello mutations in a single attempt. Follow-up proxy or connection-recovery attempts would bypass Core's preflight.
1275
+
1250
1276
  ### Azure DevOps Services work item writes
1251
1277
 
1252
1278
  Use the work item methods on `IntegrationManager` from `@gitkraken/core-gitlens/plus/integrations/index.js`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitkraken/core-gitlens",
3
3
  "description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
4
- "version": "0.67.0",
4
+ "version": "0.68.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",