@gitkraken/core-gitlens 0.67.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.
- package/CHANGELOG.md +20 -0
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +2 -2
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +4 -2
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +5 -4
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +3 -1
- package/dist/plus/integrations/index.js +18 -0
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +29 -0
- package/dist/plus/integrations/integrationService.js +84 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +12 -0
- package/dist/plus/integrations/models/asanaTaskWrites.d.ts +155 -0
- package/dist/plus/integrations/models/asanaTaskWrites.js +0 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts +6 -1
- package/dist/plus/integrations/models/issuesIntegration.js +25 -0
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/models/trelloCardWrites.d.ts +117 -0
- package/dist/plus/integrations/models/trelloCardWrites.js +0 -0
- package/dist/plus/integrations/providers/asana.d.ts +3 -1
- package/dist/plus/integrations/providers/asana.js +10 -0
- package/dist/plus/integrations/providers/asana.js.map +1 -1
- package/dist/plus/integrations/providers/asanaTaskWriteTransport.d.ts +40 -0
- package/dist/plus/integrations/providers/asanaTaskWriteTransport.js +122 -0
- package/dist/plus/integrations/providers/asanaTaskWriteTransport.js.map +1 -0
- package/dist/plus/integrations/providers/asanaTaskWrites.d.ts +38 -0
- package/dist/plus/integrations/providers/asanaTaskWrites.js +521 -0
- package/dist/plus/integrations/providers/asanaTaskWrites.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.js +1 -4
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/trello.d.ts +3 -1
- package/dist/plus/integrations/providers/trello.js +11 -0
- package/dist/plus/integrations/providers/trello.js.map +1 -1
- package/dist/plus/integrations/providers/trelloApi.d.ts +5 -0
- package/dist/plus/integrations/providers/trelloApi.js +9 -0
- package/dist/plus/integrations/providers/trelloApi.js.map +1 -0
- package/dist/plus/integrations/providers/trelloCardWriteTransport.d.ts +27 -0
- package/dist/plus/integrations/providers/trelloCardWriteTransport.js +73 -0
- package/dist/plus/integrations/providers/trelloCardWriteTransport.js.map +1 -0
- package/dist/plus/integrations/providers/trelloCardWrites.d.ts +26 -0
- package/dist/plus/integrations/providers/trelloCardWrites.js +342 -0
- package/dist/plus/integrations/providers/trelloCardWrites.js.map +1 -0
- package/dist/plus/integrations/providers/utils/writeTransport.d.ts +28 -0
- package/dist/plus/integrations/providers/utils/writeTransport.js +60 -0
- package/dist/plus/integrations/providers/utils/writeTransport.js.map +1 -0
- package/docs/integrations.md +51 -0
- package/package.json +1 -1
|
@@ -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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A+B;EAC5F,IAAI,CAAC,OAAO,MAAM,OAAO,KAAK,KAAK,OAAO,QAAQ,MAAM,IAAI,qBAAqB,UAAU;EAE3F,OAAO,OAAO,IAAI;CACnB;CAEA,MAAc,SAAS,SAAiC;EACvD,MAAM,QAAQ,MAAM,KAAK,UAAU,KAAY,UAAU,QAAQ,UAAU,aAAa;EACxF,IAAI,CAAC,QAAQ,KAAK,GAAG,MAAM,IAAI,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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ProviderRequestFunction, ProviderRequestResponse } from "../models.js";
|
|
2
|
+
//#region ../plus/integrations/src/providers/utils/writeTransport.d.ts
|
|
3
|
+
export type WriteDispatch = 'none' | 'rejected' | 'uncertain' | 'applied';
|
|
4
|
+
export type PinnedWriteConnection = {
|
|
5
|
+
isCurrent: () => Promise<boolean>;
|
|
6
|
+
isRetired: () => boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ProviderErrorLike = {
|
|
9
|
+
statusCode?: number;
|
|
10
|
+
response?: {
|
|
11
|
+
status?: number;
|
|
12
|
+
body?: unknown;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
} | null;
|
|
16
|
+
export declare function getWriteErrorStatus(ex: unknown): number | undefined;
|
|
17
|
+
export declare function getWriteStatusReason(ex: unknown): 'invalid-input' | 'not-found' | 'unsupported' | 'conflict' | 'rate-limit' | 'unknown' | undefined;
|
|
18
|
+
export declare function isPinnedWriteConnectionCurrent(connection: PinnedWriteConnection): Promise<boolean>;
|
|
19
|
+
export declare function sendPinnedWriteRequest<T, E extends Error>(request: ProviderRequestFunction, connection: PinnedWriteConnection, options: {
|
|
20
|
+
url: string;
|
|
21
|
+
method: string;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
body?: string;
|
|
24
|
+
okStatuses: readonly number[];
|
|
25
|
+
isEvidence?: (body: T) => boolean;
|
|
26
|
+
}, toError: (ex: unknown, dispatch: WriteDispatch, response?: ProviderRequestResponse<T>) => E, noConnection: (dispatch: WriteDispatch, response?: ProviderRequestResponse<T>) => E): Promise<ProviderRequestResponse<T>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//# sourceMappingURL=writeTransport.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { RequestRateLimitError } from "../../../../git/errors.js";
|
|
2
|
+
//#region ../plus/integrations/src/providers/utils/writeTransport.ts
|
|
3
|
+
function getWriteErrorStatus(ex) {
|
|
4
|
+
const error = ex;
|
|
5
|
+
return error?.response?.status ?? error?.statusCode;
|
|
6
|
+
}
|
|
7
|
+
function getWriteStatusReason(ex) {
|
|
8
|
+
if (RequestRateLimitError.is(ex)) return "rate-limit";
|
|
9
|
+
switch (getWriteErrorStatus(ex)) {
|
|
10
|
+
case 400:
|
|
11
|
+
case 413:
|
|
12
|
+
case 414:
|
|
13
|
+
case 415:
|
|
14
|
+
case 422: return "invalid-input";
|
|
15
|
+
case 404: return "not-found";
|
|
16
|
+
case 405: return "unsupported";
|
|
17
|
+
case 409: return "conflict";
|
|
18
|
+
case 429: return "rate-limit";
|
|
19
|
+
default: return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function isPinnedWriteConnectionCurrent(connection) {
|
|
23
|
+
return !connection.isRetired() && await connection.isCurrent() && !connection.isRetired();
|
|
24
|
+
}
|
|
25
|
+
async function sendPinnedWriteRequest(request, connection, options, toError, noConnection) {
|
|
26
|
+
if (!await isPinnedWriteConnectionCurrent(connection)) throw noConnection("none");
|
|
27
|
+
if (connection.isRetired()) throw noConnection("none");
|
|
28
|
+
const mutation = options.method !== "GET";
|
|
29
|
+
let response;
|
|
30
|
+
try {
|
|
31
|
+
response = await request({
|
|
32
|
+
url: options.url,
|
|
33
|
+
method: options.method,
|
|
34
|
+
redirect: "error",
|
|
35
|
+
credentials: "omit",
|
|
36
|
+
signal: AbortSignal.timeout(3e4),
|
|
37
|
+
headers: options.body == null ? options.headers : {
|
|
38
|
+
...options.headers,
|
|
39
|
+
"Content-Type": "application/json"
|
|
40
|
+
},
|
|
41
|
+
body: options.body
|
|
42
|
+
});
|
|
43
|
+
} catch (ex) {
|
|
44
|
+
throw toError(ex, mutation ? "rejected" : "none");
|
|
45
|
+
}
|
|
46
|
+
if (!mutation) return response;
|
|
47
|
+
if (!options.okStatuses.includes(response.status) || options.isEvidence?.(response.body) === false) throw toError(void 0, "uncertain");
|
|
48
|
+
let current;
|
|
49
|
+
try {
|
|
50
|
+
current = await isPinnedWriteConnectionCurrent(connection);
|
|
51
|
+
} catch (ex) {
|
|
52
|
+
throw toError(ex, "applied", response);
|
|
53
|
+
}
|
|
54
|
+
if (!current) throw noConnection("applied", response);
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { getWriteErrorStatus, getWriteStatusReason, isPinnedWriteConnectionCurrent, sendPinnedWriteRequest };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=writeTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeTransport.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/utils/writeTransport.ts"],"sourcesContent":["import { RequestRateLimitError } from '@gitlens/git/errors.js';\nimport type { ProviderRequestFunction, ProviderRequestResponse } from '../models.js';\n\nexport type WriteDispatch = 'none' | 'rejected' | 'uncertain' | 'applied';\n\nexport type PinnedWriteConnection = {\n\tisCurrent: () => Promise<boolean>;\n\tisRetired: () => boolean;\n};\n\nexport type ProviderErrorLike = {\n\tstatusCode?: number;\n\tresponse?: { status?: number; body?: unknown; headers?: Record<string, string> };\n} | null;\n\nexport function getWriteErrorStatus(ex: unknown): number | undefined {\n\tconst error = ex as ProviderErrorLike;\n\treturn error?.response?.status ?? error?.statusCode;\n}\n\nexport function getWriteStatusReason(\n\tex: unknown,\n): 'invalid-input' | 'not-found' | 'unsupported' | 'conflict' | 'rate-limit' | 'unknown' | undefined {\n\tif (RequestRateLimitError.is(ex)) return 'rate-limit';\n\n\tswitch (getWriteErrorStatus(ex)) {\n\t\tcase 400:\n\t\tcase 413:\n\t\tcase 414:\n\t\tcase 415:\n\t\tcase 422:\n\t\t\treturn 'invalid-input';\n\t\tcase 404:\n\t\t\treturn 'not-found';\n\t\tcase 405:\n\t\t\treturn 'unsupported';\n\t\tcase 409:\n\t\t\treturn 'conflict';\n\t\tcase 429:\n\t\t\treturn 'rate-limit';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport async function isPinnedWriteConnectionCurrent(connection: PinnedWriteConnection): Promise<boolean> {\n\treturn !connection.isRetired() && (await connection.isCurrent()) && !connection.isRetired();\n}\n\nexport async function sendPinnedWriteRequest<T, E extends Error>(\n\trequest: ProviderRequestFunction,\n\tconnection: PinnedWriteConnection,\n\toptions: {\n\t\turl: string;\n\t\tmethod: string;\n\t\theaders: Record<string, string>;\n\t\tbody?: string;\n\t\tokStatuses: readonly number[];\n\t\tisEvidence?: (body: T) => boolean;\n\t},\n\ttoError: (ex: unknown, dispatch: WriteDispatch, response?: ProviderRequestResponse<T>) => E,\n\tnoConnection: (dispatch: WriteDispatch, response?: ProviderRequestResponse<T>) => E,\n): Promise<ProviderRequestResponse<T>> {\n\tif (!(await isPinnedWriteConnectionCurrent(connection))) throw noConnection('none');\n\t// KEEP: re-check synchronously; the awaited check above resumes a microtask after its last isRetired()\n\tif (connection.isRetired()) throw noConnection('none');\n\n\tconst mutation = options.method !== 'GET';\n\tlet response: ProviderRequestResponse<T>;\n\ttry {\n\t\tresponse = await request<T>({\n\t\t\turl: options.url,\n\t\t\tmethod: options.method,\n\t\t\tredirect: 'error',\n\t\t\tcredentials: 'omit',\n\t\t\tsignal: AbortSignal.timeout(30_000),\n\t\t\theaders:\n\t\t\t\toptions.body == null ? options.headers : { ...options.headers, 'Content-Type': 'application/json' },\n\t\t\tbody: options.body,\n\t\t});\n\t} catch (ex) {\n\t\tthrow toError(ex, mutation ? 'rejected' : 'none');\n\t}\n\tif (!mutation) return response;\n\n\tif (!options.okStatuses.includes(response.status) || options.isEvidence?.(response.body) === false) {\n\t\tthrow toError(undefined, 'uncertain');\n\t}\n\n\tlet current: boolean;\n\ttry {\n\t\tcurrent = await isPinnedWriteConnectionCurrent(connection);\n\t} catch (ex) {\n\t\tthrow toError(ex, 'applied', response);\n\t}\n\tif (!current) throw noConnection('applied', response);\n\n\treturn response;\n}\n"],"mappings":";;AAeA,SAAgB,oBAAoB,IAAiC;CACpE,MAAM,QAAQ;CACd,OAAO,OAAO,UAAU,UAAU,OAAO;AAC1C;AAEA,SAAgB,qBACf,IACoG;CACpG,IAAI,sBAAsB,GAAG,EAAE,GAAG,OAAO;CAEzC,QAAQ,oBAAoB,EAAE,GAA9B;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,KACJ,OAAO;EACR,KAAK,KACJ,OAAO;EACR,KAAK,KACJ,OAAO;EACR,KAAK,KACJ,OAAO;EACR,KAAK,KACJ,OAAO;EACR,SACC;CACF;AACD;AAEA,eAAsB,+BAA+B,YAAqD;CACzG,OAAO,CAAC,WAAW,UAAU,KAAM,MAAM,WAAW,UAAU,KAAM,CAAC,WAAW,UAAU;AAC3F;AAEA,eAAsB,uBACrB,SACA,YACA,SAQA,SACA,cACsC;CACtC,IAAI,CAAE,MAAM,+BAA+B,UAAU,GAAI,MAAM,aAAa,MAAM;CAElF,IAAI,WAAW,UAAU,GAAG,MAAM,aAAa,MAAM;CAErD,MAAM,WAAW,QAAQ,WAAW;CACpC,IAAI;CACJ,IAAI;EACH,WAAW,MAAM,QAAW;GAC3B,KAAK,QAAQ;GACb,QAAQ,QAAQ;GAChB,UAAU;GACV,aAAa;GACb,QAAQ,YAAY,QAAQ,GAAM;GAClC,SACC,QAAQ,QAAQ,OAAO,QAAQ,UAAU;IAAE,GAAG,QAAQ;IAAS,gBAAgB;GAAmB;GACnG,MAAM,QAAQ;EACf,CAAC;CACF,SAAS,IAAI;EACZ,MAAM,QAAQ,IAAI,WAAW,aAAa,MAAM;CACjD;CACA,IAAI,CAAC,UAAU,OAAO;CAEtB,IAAI,CAAC,QAAQ,WAAW,SAAS,SAAS,MAAM,KAAK,QAAQ,aAAa,SAAS,IAAI,MAAM,OAC5F,MAAM,QAAQ,KAAA,GAAW,WAAW;CAGrC,IAAI;CACJ,IAAI;EACH,UAAU,MAAM,+BAA+B,UAAU;CAC1D,SAAS,IAAI;EACZ,MAAM,QAAQ,IAAI,WAAW,QAAQ;CACtC;CACA,IAAI,CAAC,SAAS,MAAM,aAAa,WAAW,QAAQ;CAEpD,OAAO;AACR"}
|
package/docs/integrations.md
CHANGED
|
@@ -1247,6 +1247,57 @@ 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
|
+
### Asana task writes
|
|
1251
|
+
|
|
1252
|
+
Import the Asana methods and types from `@gitkraken/core-gitlens/plus/integrations/index.js`. All calls use the explicitly selected `connectionId` and its OAuth token. Reads accept an optional `expectedAccountId`. Every mutation requires the viewer GID from `getAsanaTaskWriteAccount` or a previous read. Successful calls return the authenticated `account` with its `id`, `name`, and `email`. Every Asana identifier is a GID string.
|
|
1253
|
+
|
|
1254
|
+
| Method | Input beyond the connection and account | Success |
|
|
1255
|
+
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
1256
|
+
| `getAsanaTaskWriteAccount` | None | The current Asana user. |
|
|
1257
|
+
| `getAsanaTaskCreateOptions` | Optional `workspaceId`, and optional `projectIds` within that workspace | Workspaces with their unarchived projects, or the pinned projects with their sections. |
|
|
1258
|
+
| `resolveAsanaTaskWriteTarget` | `task` as a GID or an `app.asana.com` task URL, and optional `workspaceId` and `projectId` | Current task, workspace, every membership, the pinned project's membership, and individual capabilities. |
|
|
1259
|
+
| `writeAsanaTask` with `action: 'create'` | `workspaceId`, `projectId`, nonblank `name`, optional `notes`, and optional `sectionId` of that project | Created task and its membership in the project. |
|
|
1260
|
+
| `writeAsanaTask` with `action: 'edit'` | `workspaceId`, `projectId`, `taskId`, optional current `sectionId`, and at least one of `name` or `notes` | Updated task. An omitted value is preserved. An empty `notes` clears the notes. |
|
|
1261
|
+
| `writeAsanaTask` with `action: 'complete'` or `'reopen'` | `workspaceId`, `projectId`, `taskId`, and optional current `sectionId` | Updated task with `completed: true` or `false`, respectively. |
|
|
1262
|
+
| `writeAsanaTask` with `action: 'move'` | `workspaceId`, `projectId`, `taskId`, current `sectionId` (or `null`), and `destinationSectionId` of the same project | Updated task with both `sourceSection` and `destinationSection`. |
|
|
1263
|
+
| `deleteAsanaTask` | `workspaceId`, `projectId`, `taskId`, resolved `sectionId`, `completed`, `modifiedAt`, and `membershipProjectIds` values, and `confirmed: true` | Pre-delete task, workspace, project, and membership with `deletion.trashed: true`. |
|
|
1264
|
+
|
|
1265
|
+
Task receipts include the GID `id`, `name`, `notes`, permalink `url`, `completed`, `modifiedAt`, `workspaceId`, every direct project membership in Asana's order with its nullable section, `inheritedProjects` with the projects a subtask belongs to only through an ancestor (absent when Asana's response omits `effective_memberships`), and the `assignee` with its `id`, nullable `name`, and nullable 60×60 `avatarUrl`. `assignee` is `null` for an unassigned task and absent when Asana's response omits it. Point reads accept task URLs in the `/0/<context>/<task>`, `/1/<workspace>/task/<task>`, and `/1/<workspace>/project/<project>/task/<task>` forms. The task GID is the identity; a URL's workspace or project must agree with explicit pins. The `/0/<context>/` segment can name a project, a tag, My Tasks, or a search, so Core ignores it and mutations rely on the explicit `projectId`. A read without a project works for a generic link and reports `project-required` for every action. [Asana task API](https://developers.asana.com/reference/tasks), [URL formats](https://forum.asana.com/t/upcoming-new-v1-asana-url-format-in-the-browser/1011489)
|
|
1266
|
+
|
|
1267
|
+
A task can belong to several projects. Every mutation requires exactly one direct membership in the pinned project, or returns `not-in-project`. A project the task only inherits from an ancestor has no section placement and cannot be pinned for any action, including editing and completion, so pin one of the task's direct projects. Editing and completion change the task in every project. A move changes only the section of the pinned project's membership. The destination section must belong to the pinned project, because adding a task to a section of another project would add the task to that project. Core never requests a membership change, but Asana has no conditional move: if the task is removed from the pinned project between Core's final read and the move, the move adds it back, and the receipt cannot tell that apart from a plain move. [Add task to section](https://developers.asana.com/reference/addtaskforsection), [create a task](https://developers.asana.com/reference/createtask)
|
|
1268
|
+
|
|
1269
|
+
Asana has no per-task permission read, so allowed actions are reported as `status: 'unknown'` and Asana decides on dispatch. The GitKraken Asana authorization requests `tasks:write` but not `tasks:delete`, which `DELETE /tasks/{gid}` requires. When the scopes the GitKraken backend reports for the connection omit `tasks:delete`, the delete capability is `insufficient-scope` and `deleteAsanaTask` refuses before dispatch. A 403 is reported as `insufficient-scope` only when Asana names the missing scope; otherwise it is `forbidden`. A 402 returns `payment-required` for premium-only features, and a 451 returns `legal-block`. [OAuth scopes](https://developers.asana.com/docs/oauth-scopes), [errors](https://developers.asana.com/docs/errors)
|
|
1270
|
+
|
|
1271
|
+
For deletion, resolve the exact target before presenting it for confirmation. Call `deleteAsanaTask` only after approval and carry the resolved viewer, workspace, project, task, and current section, plus the confirmed `completed` and `modifiedAt` values and the project GIDs of every confirmed membership, both direct and in `inheritedProjects`, because a deleted subtask also disappears from the projects it inherits. Asana does not update `modified_at` when a task joins or leaves a project, so Core refuses with `conflict` when the final read shows a different set of projects, and with `unknown` when a membership in it has no readable project or the read omits `effective_memberships`. Deletion moves the task to the deleting user's trash for 30 days and removes it from every project. [Delete a task](https://developers.asana.com/reference/deletetask)
|
|
1272
|
+
|
|
1273
|
+
Core revalidates the session, viewer, project, sections when needed, and finally the task and its membership before dispatch. Asana's write endpoints have no atomic precondition, 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`, `invalid-input` (with Asana's `messages`), or `rate-limit`. A lost or ambiguous mutation response returns `applied: 'maybe'`. A confirmed mutation whose session check or read-back fails returns `applied: 'yes'` with the `taskId` when known and no receipt; a read-back that does not show the requested change returns `conflict`. A success status with an empty, malformed, HTML, or other non-JSON body, or JSON whose `data` is not an object, proves nothing about Asana and returns `applied: 'maybe'`. Reconcile both outcomes using a read before attempting another write. Completion and moves reuse provider-apis' Asana client over Core's single-attempt request. The integration runtime's `http.fetch` must send `POST /tasks`, `PUT` and `DELETE /tasks/{gid}`, and `POST /sections/{gid}/addTask` in a single attempt.
|
|
1274
|
+
|
|
1275
|
+
### Trello card writes
|
|
1276
|
+
|
|
1277
|
+
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`.
|
|
1278
|
+
|
|
1279
|
+
| Method | Input beyond the connection and account | Success |
|
|
1280
|
+
| ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
1281
|
+
| `getTrelloCardCreateOptions` | Optional `boardId` | Open boards and lists with allowed or unknown write permissions. |
|
|
1282
|
+
| `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. |
|
|
1283
|
+
| `writeTrelloCard` with `action: 'create'` | `boardId`, `listId`, nonblank `name`, and optional `description` | Created card and destination. |
|
|
1284
|
+
| `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. |
|
|
1285
|
+
| `writeTrelloCard` with `action: 'move'` | `boardId`, `listId`, canonical `cardId`, `destinationBoardId`, and `destinationListId` | Updated card with both `sourceList` and `destinationList`. |
|
|
1286
|
+
| `writeTrelloCard` with `action: 'archive'` or `'restore'` | `boardId`, `listId`, and canonical `cardId` | Updated card with `closed: true` or `false`, respectively. |
|
|
1287
|
+
| `deleteTrelloCard` | `boardId`, `listId`, canonical `cardId`, resolved `shortLink` and `closed` values, and `confirmed: true` | Pre-delete card, board, and list with `deletion.permanent: true`. |
|
|
1288
|
+
|
|
1289
|
+
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/)
|
|
1290
|
+
|
|
1291
|
+
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/)
|
|
1292
|
+
|
|
1293
|
+
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)
|
|
1294
|
+
|
|
1295
|
+
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)
|
|
1296
|
+
|
|
1297
|
+
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/)
|
|
1298
|
+
|
|
1299
|
+
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.
|
|
1300
|
+
|
|
1250
1301
|
### Azure DevOps Services work item writes
|
|
1251
1302
|
|
|
1252
1303
|
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.
|
|
4
|
+
"version": "0.69.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "GitKraken",
|