@gitkraken/core-gitlens 0.54.0 → 0.56.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 +21 -1
- package/dist/git/cache.js +3 -0
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +14 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +3 -1
- package/dist/git/utils/pullRequest.utils.js +9 -1
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts +2 -0
- package/dist/git-cli/providers/pausedOperations.js +104 -40
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +2 -0
- package/dist/plus/git-github/api/github.js +16 -6
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestSearchQuery.d.ts +1 -0
- package/dist/plus/git-github/api/pullRequestSearchQuery.js +29 -5
- package/dist/plus/git-github/api/pullRequestSearchQuery.js.map +1 -1
- package/dist/plus/integrations/fieldPresence.d.ts +3 -0
- package/dist/plus/integrations/fieldPresence.js +7 -1
- package/dist/plus/integrations/fieldPresence.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +3 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +11 -2
- package/dist/plus/integrations/integrationService.js +75 -3
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +17 -2
- package/dist/plus/integrations/models/bitbucketPullRequestWrites.d.ts +217 -0
- package/dist/plus/integrations/models/bitbucketPullRequestWrites.js +0 -0
- package/dist/plus/integrations/models/integration.d.ts +2 -1
- package/dist/plus/integrations/models/integration.js +6 -0
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/publicIntegration.d.ts +1 -0
- package/dist/plus/integrations/models/pullRequestReads.d.ts +2 -0
- package/dist/plus/integrations/providers/azure/writeIdentity.d.ts +0 -3
- package/dist/plus/integrations/providers/azure/writeIdentity.js +4 -12
- package/dist/plus/integrations/providers/azure/writeIdentity.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +0 -2
- package/dist/plus/integrations/providers/azureDevOps.js +1 -7
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azurePullRequestWrites.js +24 -26
- package/dist/plus/integrations/providers/azurePullRequestWrites.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +4 -3
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +22 -21
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.d.ts +4 -0
- package/dist/plus/integrations/providers/bitbucket.js +8 -0
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.d.ts +13 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.js +88 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.d.ts +14 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.js +36 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWrites.d.ts +47 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWrites.js +795 -0
- package/dist/plus/integrations/providers/bitbucketPullRequestWrites.js.map +1 -0
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/metadata.js +6 -3
- package/dist/plus/integrations/providers/metadata.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +4 -0
- package/dist/plus/integrations/providers/providersApi.js +5 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/utils/writeInputs.d.ts +7 -0
- package/dist/plus/integrations/providers/utils/writeInputs.js +17 -0
- package/dist/plus/integrations/providers/utils/writeInputs.js.map +1 -0
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/reads/filters.js +13 -1
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +3 -3
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +3 -3
- package/dist/plus/integrations/reads/searchPullRequests.js +4 -3
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +20 -6
- package/dist/plus/integrations/reads/sweeps.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +1 -0
- package/dist/plus/integrations/reads/warnings.js +7 -2
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +7 -0
- package/dist/plus/integrations/results.js.map +1 -1
- package/docs/integrations.md +188 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureWorkItemWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureWorkItemWrites.ts"],"sourcesContent":["import type {\n\tAzureServerWorkItemWriteScope,\n\tAzureServicesWorkItemWriteScope,\n\tWorkItemAddress,\n\tWorkItemCreateOptions,\n\tWorkItemCreateOptionsResult,\n\tWorkItemDeleteCapability,\n\tWorkItemDeleteOptions,\n\tWorkItemDeleteResult,\n\tWorkItemReceipt,\n\tWorkItemState,\n\tWorkItemWriteContext,\n\tWorkItemWriteField,\n\tWorkItemWriteOptions,\n\tWorkItemWriteOptionsResult,\n\tWorkItemWriteResult,\n\tWorkItemWriteTargetOptions,\n\tWorkItemWriteTargetResult,\n} from '../models/workItemWrites.js';\nimport { encodeAzurePathSegment } from './azure/models.js';\nimport type {\n\tAzureWorkItemFieldDefinition,\n\tAzureWorkItemTypeCategory,\n\tAzureWorkItemTypeField,\n\tAzureWorkItemTypeMetadata,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWorkItemBodyField,\n\tgetAzureWorkItemTransitionTargets,\n\tisAzureProjectPathField,\n\tisAzureTestArtifact,\n\ttoAzureWorkItemWriteFields,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWriteOrganizations,\n\tgetAzureWriteProfile,\n\tisAzureGuid,\n\tisAzureIdentifier,\n\tisAzurePositiveInt,\n\tsameAzureIdentifier,\n\tverifyAzureServerCollection,\n} from './azure/writeIdentity.js';\nimport {\n\ttoWorkItemWriteFailure,\n\tWorkItemWriteError,\n\tWorkItemWriteNotDispatchedError,\n} from './azureWorkItemWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.js';\n\ntype AzureWorkItem = { id: number; rev: number; fields: Readonly<Record<string, unknown>> };\ntype AzureDeletedWorkItem = {\n\tid?: unknown;\n\tproject?: unknown;\n\tdeletedDate?: unknown;\n\tcode?: unknown;\n\tresource?: { id?: unknown; rev?: unknown };\n};\ntype WorkItemMetadata = {\n\ttype: AzureWorkItemTypeMetadata;\n\tstates: readonly WorkItemState[];\n\tfields: readonly WorkItemWriteField[];\n\tcatalog: readonly AzureWorkItemFieldDefinition[];\n};\ntype Patch = { op: 'add' | 'test'; path: string; value: unknown } | { op: 'remove'; path: string };\n\nconst projectSecurityNamespaceId = '52d39943-cb85-4d7f-8fa8-c6baac873819';\n\nfunction isSameId(actual: unknown, id: number): boolean {\n\treturn actual === id || actual === String(id);\n}\n\nfunction isDeletedItem(\n\titem: AzureDeletedWorkItem | undefined,\n\tid: number,\n): item is AzureDeletedWorkItem & { project: string } {\n\tif (item == null || !isSameId(item.id, id) || !isAzureIdentifier(item.project)) return false;\n\n\treturn (\n\t\titem.code == null || item.code === 0 || (typeof item.code === 'number' && item.code >= 200 && item.code < 300)\n\t);\n}\n\nfunction getDeletedRevision(item: AzureDeletedWorkItem, id: number): number | undefined {\n\tconst resource = item.resource;\n\treturn resource != null && isSameId(resource.id, id) && isAzurePositiveInt(resource.rev) ? resource.rev : undefined;\n}\n\n// SEE: Azure reports `deletedDate` as a zone-less en-US UTC string (\"11/25/2026 6:24:35 PM\"), observed live.\nconst azureDeletedDate = /^(\\d{1,2})\\/(\\d{1,2})\\/([12]\\d{3}) (\\d{1,2}):([0-5]\\d):([0-5]\\d) (AM|PM)$/;\n\nfunction toDeletedAt(value: unknown): string | undefined {\n\tconst match = typeof value === 'string' ? azureDeletedDate.exec(value) : null;\n\tif (match == null) return undefined;\n\n\tconst [month, day, year, hour, minute, second] = match.slice(1, 7).map(Number);\n\tif (hour < 1 || hour > 12) return undefined;\n\n\tconst date = new Date(Date.UTC(year, month - 1, day, (hour % 12) + (match[7] === 'PM' ? 12 : 0), minute, second));\n\tif (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {\n\t\treturn undefined;\n\t}\n\n\treturn date.toISOString();\n}\n\nfunction readValues<T>(body: { value?: T[] } | undefined): T[] {\n\tif (!Array.isArray(body?.value)) throw new WorkItemWriteError('unknown');\n\n\treturn body.value;\n}\n\nfunction assertExistingAddress(address: WorkItemAddress): void {\n\tif (!isAzurePositiveInt(address.workItemId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertMutationIdentity(expectedAccountId: string): void {\n\tif (!isAzureIdentifier(expectedAccountId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertSameRevision(item: AzureWorkItem, expectedRevision: number): void {\n\tif (!isAzurePositiveInt(expectedRevision)) throw new WorkItemWriteError('invalid-input');\n\tif (item.rev !== expectedRevision) throw new WorkItemWriteError('conflict');\n}\n\nfunction isJsonValue(value: unknown, ancestors = new Set<object>()): boolean {\n\tif (value == null) return value === null;\n\tif (typeof value === 'string' || typeof value === 'boolean') return true;\n\tif (typeof value === 'number') return Number.isFinite(value);\n\tif (typeof value !== 'object' || ancestors.has(value)) return false;\n\tif (\n\t\t!Array.isArray(value) &&\n\t\tObject.getPrototypeOf(value) !== Object.prototype &&\n\t\tObject.getPrototypeOf(value) !== null\n\t) {\n\t\treturn false;\n\t}\n\n\tancestors.add(value);\n\tconst valid = Object.values(value).every(entry => isJsonValue(entry, ancestors));\n\tancestors.delete(value);\n\treturn valid;\n}\n\nfunction isInProjectPath(value: unknown, projectName: string): boolean {\n\tif (typeof value !== 'string') return false;\n\n\tconst root = value.split('\\\\', 1)[0];\n\treturn root.toLowerCase() === projectName.toLowerCase();\n}\n\nfunction getFieldPatches(\n\tinput: Readonly<Record<string, unknown>>,\n\tfieldMetadata: readonly WorkItemWriteField[],\n\tprojectName: string,\n\tcurrent?: Readonly<Record<string, unknown>>,\n): Patch[] {\n\tif (input == null || typeof input !== 'object' || Array.isArray(input)) {\n\t\tthrow new WorkItemWriteError('invalid-input');\n\t}\n\n\tconst fields = new Map(fieldMetadata.map(field => [field.referenceName, field]));\n\tconst errors = new Map<string, string>();\n\tconst patch: Patch[] = [];\n\tfor (const [name, value] of Object.entries(input)) {\n\t\tconst field = fields.get(name);\n\t\tif (field == null || !isJsonValue(value)) {\n\t\t\terrors.set(name, field == null ? 'Field is unavailable for writing.' : 'Expected a JSON field value.');\n\t\t\tcontinue;\n\t\t}\n\t\tif (isAzureProjectPathField(name) && !isInProjectPath(value, projectName)) {\n\t\t\terrors.set(name, 'Expected a path in the selected project.');\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst path = `/fields/${name.replaceAll('~', '~0').replaceAll('/', '~1')}`;\n\t\tif (current != null && value === null) {\n\t\t\tif (Object.hasOwn(current, name)) {\n\t\t\t\tpatch.push({ op: 'remove', path: path });\n\t\t\t}\n\t\t} else {\n\t\t\tpatch.push({ op: 'add', path: path, value: value });\n\t\t}\n\t}\n\tif (current == null) {\n\t\tfor (const field of fieldMetadata) {\n\t\t\tconst value = Object.hasOwn(input, field.referenceName) ? input[field.referenceName] : undefined;\n\t\t\tif (\n\t\t\t\tfield.required &&\n\t\t\t\t(value === null || value === '' || (value === undefined && !Object.hasOwn(field, 'defaultValue')))\n\t\t\t) {\n\t\t\t\terrors.set(field.referenceName, 'This field is required.');\n\t\t\t}\n\t\t}\n\t}\n\tif (errors.size) throw new WorkItemWriteError('invalid-input', Object.fromEntries(errors));\n\n\treturn patch;\n}\n\nasync function readProject(\n\trequest: ProviderRequestFunction,\n\theaders: { Authorization: string },\n\tcollectionUrl: string,\n\tprojectId: string,\n\tapiVersion: string,\n): Promise<{ id: string; name: string }> {\n\tconst { body: project } = await request<{ id?: unknown; name?: unknown }>({\n\t\turl: `${collectionUrl}/_apis/projects/${projectId}?api-version=${apiVersion}`,\n\t\theaders: headers,\n\t\tredirect: 'error',\n\t});\n\tif (!sameAzureIdentifier(project?.id, projectId) || !isAzureIdentifier(project?.name)) {\n\t\tthrow new WorkItemWriteError('not-found');\n\t}\n\n\treturn { id: project.id as string, name: project.name };\n}\n\nexport class AzureWorkItemWriter {\n\tstatic async connect(\n\t\trequest: ProviderRequestFunction,\n\t\tcredential: { accessToken: string; authorization: string },\n\t\toptions: AzureServicesWorkItemWriteScope,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst { body: profile } = await getAzureWriteProfile(request, credential.accessToken);\n\t\tconst accountId = profile?.id;\n\t\tif (\n\t\t\t!isAzureIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameAzureIdentifier(accountId, options.expectedAccountId))\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('no-connection');\n\t\t}\n\n\t\tconst headers = { Authorization: credential.authorization };\n\t\tconst { body: accounts } = await getAzureWriteOrganizations(request, credential.authorization, accountId);\n\t\tconst organization = readValues(accounts).find(\n\t\t\taccount =>\n\t\t\t\tsameAzureIdentifier(account.accountId, options.organizationId) &&\n\t\t\t\tsameAzureIdentifier(account.accountName, options.organizationName),\n\t\t);\n\t\tif (organization == null) throw new WorkItemWriteError('not-found');\n\n\t\tconst organizationUrl = `https://dev.azure.com/${encodeAzurePathSegment(organization.accountName)}`;\n\t\tconst project = await readProject(request, headers, organizationUrl, options.projectId, '7.1');\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\taccountId: accountId,\n\t\t\t\torganization: { id: organization.accountId, name: organization.accountName },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\torganizationUrl,\n\t\t\t'7.1',\n\t\t\t() => Promise.resolve('7.1'),\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tstatic async connectServer(\n\t\trequest: ProviderRequestFunction,\n\t\tauthorization: string,\n\t\toptions: AzureServerWorkItemWriteScope,\n\t\tcollectionUrl: string,\n\t\tresolveApiVersion: () => Promise<string | undefined>,\n\t\tresolveStatesApiVersion: () => Promise<string | undefined>,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst headers = { Authorization: authorization };\n\t\tconst collection = await verifyAzureServerCollection(request, headers, collectionUrl, options);\n\t\tif (typeof collection === 'string') throw new WorkItemWriteError(collection);\n\n\t\tconst apiVersion = await resolveApiVersion();\n\t\tif (apiVersion == null) throw new WorkItemWriteError('unsupported');\n\n\t\tconst project = await readProject(request, headers, collectionUrl, options.projectId, apiVersion);\n\t\tlet statesApiVersion: Promise<string> | undefined;\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\taccountId: collection.accountId,\n\t\t\t\torganization: { id: collection.id, name: collection.name, url: collectionUrl },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\tcollectionUrl,\n\t\t\tapiVersion,\n\t\t\t() =>\n\t\t\t\t(statesApiVersion ??= resolveStatesApiVersion().then(version => {\n\t\t\t\t\tif (version == null) throw new WorkItemWriteError('unsupported');\n\n\t\t\t\t\treturn version;\n\t\t\t\t})),\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tprivate readonly projectUrl: string;\n\n\tprivate constructor(\n\t\tprivate readonly request: ProviderRequestFunction,\n\t\tprivate readonly headers: { Authorization: string },\n\t\tprivate readonly context: WorkItemWriteContext,\n\t\tprivate readonly organizationUrl: string,\n\t\tprivate readonly apiVersion: string,\n\t\tprivate readonly getStatesApiVersion: () => Promise<string>,\n\t\tprivate readonly isSessionCurrent: () => Promise<boolean>,\n\t) {\n\t\tthis.projectUrl = `${organizationUrl}/${context.project.id}`;\n\t}\n\n\tasync getCreateOptions(options: WorkItemCreateOptions): Promise<WorkItemCreateOptionsResult> {\n\t\tif (options.workItemType === undefined) {\n\t\t\tconst types = await this.read<{ value?: AzureWorkItemTypeMetadata[] }>('/workitemtypes');\n\t\t\tconst enabled = readValues(types).filter(type => isAzureIdentifier(type.name) && !type.isDisabled);\n\t\t\treturn { ok: true, ...this.context, workItemTypes: enabled.map(type => ({ name: type.name })) };\n\t\t}\n\n\t\tconst { type, fields, states, catalog } = await this.getMetadata(options.workItemType);\n\t\tif (type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tworkItemType: type.name,\n\t\t\tfields: fields,\n\t\t\tstates: states,\n\t\t\tinitialStates: getAzureWorkItemTransitionTargets(type, states, ''),\n\t\t\tbodyField: getAzureWorkItemBodyField(fields, catalog),\n\t\t};\n\t}\n\n\tasync getWriteOptions(options: WorkItemAddress): Promise<WorkItemWriteOptionsResult> {\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\tfields: metadata.fields,\n\t\t\tavailableStates: getAzureWorkItemTransitionTargets(metadata.type, metadata.states, issue.state.name),\n\t\t\tdeleteCapability: await this.getDeleteCapability(metadata.type).catch((): WorkItemDeleteCapability => ({\n\t\t\t\tallowed: 'unknown',\n\t\t\t})),\n\t\t\tbodyField: issue.bodyField,\n\t\t};\n\t}\n\n\tasync resolveTarget(options: WorkItemWriteTargetOptions): Promise<WorkItemWriteTargetResult> {\n\t\tif (options.intent !== undefined && options.intent !== 'delete') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\tconst deleteCapability =\n\t\t\toptions.intent === 'delete' ? await this.getDeleteCapability(metadata.type) : undefined;\n\t\tif (deleteCapability?.allowed === false) throw new WorkItemWriteError(deleteCapability.reason);\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\t...(deleteCapability && { deleteCapability: deleteCapability }),\n\t\t};\n\t}\n\n\tasync write(options: WorkItemWriteOptions): Promise<WorkItemWriteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tif (options.action === 'create') return this.create(options);\n\n\t\tif (options.action !== 'edit' && options.action !== 'set-state') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst patch = getFieldPatches(options.fields ?? {}, metadata.fields, this.context.project.name, item.fields);\n\t\tif (options.action === 'set-state') {\n\t\t\tconst state = this.getReceipt(item, metadata).state.name;\n\t\t\tif (\n\t\t\t\t!getAzureWorkItemTransitionTargets(metadata.type, metadata.states, state).some(\n\t\t\t\t\ts => s.name === options.state,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new WorkItemWriteError('transition-unavailable');\n\t\t\t}\n\n\t\t\tpatch.push({ op: 'add', path: '/fields/System.State', value: options.state });\n\t\t}\n\t\tif (!patch.length) throw new WorkItemWriteError('invalid-input');\n\n\t\tpatch.unshift({ op: 'test', path: '/rev', value: options.expectedRevision });\n\t\treturn this.save('PATCH', `/workitems/${item.id}`, patch, metadata, {\n\t\t\tid: item.id,\n\t\t\tstate: options.action === 'set-state' ? options.state : undefined,\n\t\t});\n\t}\n\n\tasync delete(options: WorkItemDeleteOptions): Promise<WorkItemDeleteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst capability = await this.getDeleteCapability(metadata.type);\n\t\tif (capability.allowed === false) throw new WorkItemWriteError(capability.reason);\n\n\t\tawait this.assertSessionCurrent();\n\t\tconst current = await this.getItem(options);\n\t\tassertSameRevision(current, options.expectedRevision);\n\t\tif (this.itemType(current) !== metadata.type.name) throw new WorkItemWriteError('conflict');\n\n\t\tconst issue = this.getReceipt(current, metadata);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body, status } = await this.request<AzureDeletedWorkItem>({\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl: this.url(`/workitems/${issue.id}`),\n\t\t\t\theaders: this.headers,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tlet deleted =\n\t\t\t\tstatus === 200 && isDeletedItem(body, issue.id) && body.deletedDate != null ? body : undefined;\n\t\t\tif (deleted == null || getDeletedRevision(deleted, issue.id) === undefined) {\n\t\t\t\tconst recycled = await this.read<AzureDeletedWorkItem>(`/recyclebin/${issue.id}`).catch(\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t\tif (isDeletedItem(recycled, issue.id)) {\n\t\t\t\t\tdeleted = recycled;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (deleted == null) return { ok: false, reason: 'unknown', applied: 'maybe' };\n\n\t\t\treturn await this.toDeleteOutcome(deleted, issue, options.expectedRevision);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n\n\tprivate async toDeleteOutcome(\n\t\tdeleted: AzureDeletedWorkItem & { project: string },\n\t\tissue: WorkItemReceipt,\n\t\texpectedRevision: number,\n\t): Promise<WorkItemDeleteResult> {\n\t\tconst revision = getDeletedRevision(deleted, issue.id);\n\t\tconst deletedAt = toDeletedAt(deleted.deletedDate);\n\t\tconst deletion = {\n\t\t\tdisposition: 'recycle-bin',\n\t\t\trestorable: true,\n\t\t\t...(revision !== undefined && { revision: revision }),\n\t\t\t...(deletedAt !== undefined && { deletedAt: deletedAt }),\n\t\t} as const;\n\t\tconst project = sameAzureIdentifier(\n\t\t\tdeleted.project,\n\t\t\tisAzureGuid(deleted.project) ? this.context.project.id : this.context.project.name,\n\t\t)\n\t\t\t? this.context.project\n\t\t\t: await this.findProject(deleted.project);\n\t\tif (sameAzureIdentifier(project.id, this.context.project.id) && revision === expectedRevision + 1) {\n\t\t\treturn { ok: true, ...this.context, issue: issue, deletion: { ...deletion, revision: revision } };\n\t\t}\n\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: 'target-changed',\n\t\t\tapplied: true,\n\t\t\t...this.context,\n\t\t\tdeleted: { id: issue.id, ...(revision !== undefined && { revision: revision }), project: project },\n\t\t\tdeletion: deletion,\n\t\t};\n\t}\n\n\tprivate async findProject(nameOrId: string): Promise<{ id?: string; name: string }> {\n\t\ttry {\n\t\t\tconst project = await this.readOrganization<{ id?: unknown; name?: unknown }>(\n\t\t\t\t`/projects/${encodeAzurePathSegment(nameOrId)}`,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tisAzureGuid(project?.id) &&\n\t\t\t\tisAzureIdentifier(project.name) &&\n\t\t\t\t(sameAzureIdentifier(project.name, nameOrId) || sameAzureIdentifier(project.id, nameOrId))\n\t\t\t) {\n\t\t\t\treturn { id: project.id, name: project.name };\n\t\t\t}\n\t\t} catch {}\n\n\t\treturn { name: nameOrId };\n\t}\n\n\tprivate async create(options: Extract<WorkItemWriteOptions, { action: 'create' }>): Promise<WorkItemWriteResult> {\n\t\tconst metadata = await this.getMetadata(options.workItemType);\n\t\tif (metadata.type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\tconst patch = getFieldPatches(options.fields, metadata.fields, this.context.project.name);\n\t\treturn this.save('POST', `/workitems/$${encodeAzurePathSegment(metadata.type.name)}`, patch, metadata);\n\t}\n\n\tprivate async getDeleteCapability(type: AzureWorkItemTypeMetadata): Promise<WorkItemDeleteCapability> {\n\t\tif (isAzureTestArtifact(type)) return { allowed: false, reason: 'unsupported' };\n\n\t\tconst categories = await this.read<{ value?: AzureWorkItemTypeCategory[] }>('/workitemtypecategories');\n\t\tif (isAzureTestArtifact(type, readValues(categories))) return { allowed: false, reason: 'unsupported' };\n\n\t\ttry {\n\t\t\tconst namespaces = await this.readOrganization<{\n\t\t\t\tvalue?: { namespaceId?: unknown; actions?: { bit?: unknown; name?: unknown }[] }[];\n\t\t\t}>(`/securitynamespaces/${projectSecurityNamespaceId}`);\n\t\t\tconst bit = readValues(namespaces)\n\t\t\t\t.find(namespace => sameAzureIdentifier(namespace?.namespaceId, projectSecurityNamespaceId))\n\t\t\t\t?.actions?.find(action => action?.name === 'WORK_ITEM_DELETE')?.bit;\n\t\t\tif (!isAzurePositiveInt(bit)) return { allowed: 'unknown' };\n\n\t\t\tconst permissions = await this.readOrganization<{ value?: unknown[] }>(\n\t\t\t\t`/permissions/${projectSecurityNamespaceId}/${bit}`,\n\t\t\t\t{\n\t\t\t\t\ttokens: `$PROJECT:vstfs:///Classification/TeamProject/${this.context.project.id}`,\n\t\t\t\t\talwaysAllowAdministrators: 'false',\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst [allowed, ...rest] = readValues(permissions);\n\t\t\tif (typeof allowed !== 'boolean' || rest.length) return { allowed: 'unknown' };\n\n\t\t\treturn allowed ? { allowed: true } : { allowed: false, reason: 'forbidden' };\n\t\t} catch {\n\t\t\treturn { allowed: 'unknown' };\n\t\t}\n\t}\n\n\tprivate async getMetadata(name: string): Promise<WorkItemMetadata> {\n\t\tif (!isAzureIdentifier(name) || name === '.' || name === '..' || /[/\\\\]/.test(name)) {\n\t\t\tthrow new WorkItemWriteError('invalid-input');\n\t\t}\n\n\t\tconst path = `/workitemtypes/${encodeAzurePathSegment(name)}`;\n\t\tconst [type, typeFields, definitions] = await Promise.all([\n\t\t\tthis.read<AzureWorkItemTypeMetadata>(path),\n\t\t\tthis.read<{ value?: AzureWorkItemTypeField[] }>(`${path}/fields`, { $expand: 'All' }),\n\t\t\tthis.read<{ value?: AzureWorkItemFieldDefinition[] }>('/fields'),\n\t\t]);\n\t\tif (!sameAzureIdentifier(type?.name, name) || !isAzureIdentifier(type?.referenceName)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\t\tif (type.transitions == null || typeof type.transitions !== 'object' || Array.isArray(type.transitions)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst states =\n\t\t\tArray.isArray(type.states) && type.states.length !== 0\n\t\t\t\t? type.states\n\t\t\t\t: readValues(\n\t\t\t\t\t\tawait this.read<{ value?: WorkItemState[] }>(`${path}/states`, {\n\t\t\t\t\t\t\t'api-version': await this.getStatesApiVersion(),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\tif (states.some(state => !isAzureIdentifier(state?.name) || !isAzureIdentifier(state.category))) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst catalog = readValues(definitions);\n\t\treturn {\n\t\t\ttype: type,\n\t\t\tstates: states.map(({ name, category, color }) => ({\n\t\t\t\tname: name,\n\t\t\t\tcategory: category,\n\t\t\t\t...(typeof color === 'string' && { color: color }),\n\t\t\t})),\n\t\t\tfields: toAzureWorkItemWriteFields(readValues(typeFields), catalog),\n\t\t\tcatalog: catalog,\n\t\t};\n\t}\n\n\tprivate async getItem(options: WorkItemAddress): Promise<AzureWorkItem> {\n\t\tassertExistingAddress(options);\n\t\tconst data = await this.read<AzureWorkItem>(`/workitems/${options.workItemId}`);\n\t\tif (!this.isInProject(data) || data.id !== options.workItemId) throw new WorkItemWriteError('not-found');\n\n\t\treturn data;\n\t}\n\n\tprivate isInProject(item: AzureWorkItem | undefined): item is AzureWorkItem {\n\t\treturn sameAzureIdentifier(item?.fields?.['System.TeamProject'], this.context.project.name);\n\t}\n\n\tprivate itemType(item: AzureWorkItem): string {\n\t\tconst type = item.fields['System.WorkItemType'];\n\t\tif (!isAzureIdentifier(type)) throw new WorkItemWriteError('unknown');\n\n\t\treturn type;\n\t}\n\n\tprivate getReceipt(item: AzureWorkItem, metadata: WorkItemMetadata): WorkItemReceipt {\n\t\tconst title = item.fields['System.Title'];\n\t\tconst state = metadata.states.find(candidate => candidate.name === item.fields['System.State']);\n\t\tif (\n\t\t\t!isAzurePositiveInt(item.id) ||\n\t\t\t!isAzurePositiveInt(item.rev) ||\n\t\t\ttypeof title !== 'string' ||\n\t\t\tstate == null ||\n\t\t\tthis.itemType(item) !== metadata.type.name\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\treturn {\n\t\t\tid: item.id,\n\t\t\trevision: item.rev,\n\t\t\turl: `${this.projectUrl}/_workitems/edit/${item.id}`,\n\t\t\ttype: metadata.type.name,\n\t\t\ttitle: title,\n\t\t\tstate: { name: state.name, category: state.category },\n\t\t\tbodyField: getAzureWorkItemBodyField(metadata.fields, metadata.catalog, item.fields),\n\t\t};\n\t}\n\n\tprivate async assertSessionCurrent(): Promise<void> {\n\t\tif (!(await this.isSessionCurrent())) throw new WorkItemWriteError('no-connection');\n\t}\n\n\tprivate url(path: string, params?: Record<string, string>, base = `${this.projectUrl}/_apis/wit`): string {\n\t\treturn `${base}${path}?${new URLSearchParams({ 'api-version': this.apiVersion, ...params }).toString()}`;\n\t}\n\n\tprivate read<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params));\n\t}\n\n\tprivate readOrganization<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params, `${this.organizationUrl}/_apis`));\n\t}\n\n\tprivate async get<T>(url: string): Promise<T> {\n\t\tconst { body } = await this.request<T>({ url: url, headers: this.headers, redirect: 'error' });\n\t\treturn body;\n\t}\n\n\tprivate async save(\n\t\tmethod: 'POST' | 'PATCH',\n\t\tpath: string,\n\t\tpatch: Patch[],\n\t\tmetadata: WorkItemMetadata,\n\t\texpected?: { id: number; state?: string },\n\t): Promise<WorkItemWriteResult> {\n\t\tconst body = JSON.stringify(patch);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body: item } = await this.request<AzureWorkItem>({\n\t\t\t\tmethod: method,\n\t\t\t\turl: this.url(path),\n\t\t\t\theaders: { ...this.headers, 'Content-Type': 'application/json-patch+json' },\n\t\t\t\tbody: body,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tif (\n\t\t\t\t!this.isInProject(item) ||\n\t\t\t\t(expected != null && item.id !== expected.id) ||\n\t\t\t\t(expected?.state !== undefined && item.fields['System.State'] !== expected.state)\n\t\t\t) {\n\t\t\t\treturn { ok: false, reason: 'unknown', applied: 'maybe' };\n\t\t\t}\n\n\t\t\treturn { ok: true, ...this.context, issue: this.getReceipt(item, metadata) };\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAiEA,MAAM,6BAA6B;AAEnC,SAAS,SAAS,QAAiB,IAAqB;CACvD,OAAO,WAAW,MAAM,WAAW,OAAO,EAAE;AAC7C;AAEA,SAAS,cACR,MACA,IACqD;CACrD,IAAI,QAAQ,QAAQ,CAAC,SAAS,KAAK,IAAI,EAAE,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AoB,SAAS,OAE3E,OAAO;IAAE,IAAI;IAAO,QAAQ;IAAW,SAAS;GAAQ;GAGzD,OAAO;IAAE,IAAI;IAAM,GAAG,KAAK;IAAS,OAAO,KAAK,WAAW,MAAM,QAAQ;GAAE;EAC5E,SAAS,IAAI;GACZ,IAAI,cAAc,iCAAiC,OAAO,uBAAuB,EAAE;GAEnF,OAAO,uBAAuB,IAAI,EAAE,QAAQ,SAAS,OAAO,CAAC;EAC9D;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"azureWorkItemWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureWorkItemWrites.ts"],"sourcesContent":["import type {\n\tAzureServerWorkItemWriteScope,\n\tAzureServicesWorkItemWriteScope,\n\tWorkItemAddress,\n\tWorkItemCreateOptions,\n\tWorkItemCreateOptionsResult,\n\tWorkItemDeleteCapability,\n\tWorkItemDeleteOptions,\n\tWorkItemDeleteResult,\n\tWorkItemReceipt,\n\tWorkItemState,\n\tWorkItemWriteContext,\n\tWorkItemWriteField,\n\tWorkItemWriteOptions,\n\tWorkItemWriteOptionsResult,\n\tWorkItemWriteResult,\n\tWorkItemWriteTargetOptions,\n\tWorkItemWriteTargetResult,\n} from '../models/workItemWrites.js';\nimport { encodeAzurePathSegment } from './azure/models.js';\nimport type {\n\tAzureWorkItemFieldDefinition,\n\tAzureWorkItemTypeCategory,\n\tAzureWorkItemTypeField,\n\tAzureWorkItemTypeMetadata,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWorkItemBodyField,\n\tgetAzureWorkItemTransitionTargets,\n\tisAzureProjectPathField,\n\tisAzureTestArtifact,\n\ttoAzureWorkItemWriteFields,\n} from './azure/workItemWriteMetadata.js';\nimport {\n\tgetAzureWriteOrganizations,\n\tgetAzureWriteProfile,\n\tisAzureGuid,\n\tverifyAzureServerCollection,\n} from './azure/writeIdentity.js';\nimport {\n\ttoWorkItemWriteFailure,\n\tWorkItemWriteError,\n\tWorkItemWriteNotDispatchedError,\n} from './azureWorkItemWriteErrors.js';\nimport type { ProviderRequestFunction } from './models.js';\nimport { isPositiveInt32, isWriteIdentifier, sameIdentifier } from './utils/writeInputs.js';\n\ntype AzureWorkItem = { id: number; rev: number; fields: Readonly<Record<string, unknown>> };\ntype AzureDeletedWorkItem = {\n\tid?: unknown;\n\tproject?: unknown;\n\tdeletedDate?: unknown;\n\tcode?: unknown;\n\tresource?: { id?: unknown; rev?: unknown };\n};\ntype WorkItemMetadata = {\n\ttype: AzureWorkItemTypeMetadata;\n\tstates: readonly WorkItemState[];\n\tfields: readonly WorkItemWriteField[];\n\tcatalog: readonly AzureWorkItemFieldDefinition[];\n};\ntype Patch = { op: 'add' | 'test'; path: string; value: unknown } | { op: 'remove'; path: string };\n\nconst projectSecurityNamespaceId = '52d39943-cb85-4d7f-8fa8-c6baac873819';\n\nfunction isSameId(actual: unknown, id: number): boolean {\n\treturn actual === id || actual === String(id);\n}\n\nfunction isDeletedItem(\n\titem: AzureDeletedWorkItem | undefined,\n\tid: number,\n): item is AzureDeletedWorkItem & { project: string } {\n\tif (item == null || !isSameId(item.id, id) || !isWriteIdentifier(item.project)) return false;\n\n\treturn (\n\t\titem.code == null || item.code === 0 || (typeof item.code === 'number' && item.code >= 200 && item.code < 300)\n\t);\n}\n\nfunction getDeletedRevision(item: AzureDeletedWorkItem, id: number): number | undefined {\n\tconst resource = item.resource;\n\treturn resource != null && isSameId(resource.id, id) && isPositiveInt32(resource.rev) ? resource.rev : undefined;\n}\n\n// SEE: Azure reports `deletedDate` as a zone-less en-US UTC string (\"11/25/2026 6:24:35 PM\"), observed live.\nconst azureDeletedDate = /^(\\d{1,2})\\/(\\d{1,2})\\/([12]\\d{3}) (\\d{1,2}):([0-5]\\d):([0-5]\\d) (AM|PM)$/;\n\nfunction toDeletedAt(value: unknown): string | undefined {\n\tconst match = typeof value === 'string' ? azureDeletedDate.exec(value) : null;\n\tif (match == null) return undefined;\n\n\tconst [month, day, year, hour, minute, second] = match.slice(1, 7).map(Number);\n\tif (hour < 1 || hour > 12) return undefined;\n\n\tconst date = new Date(Date.UTC(year, month - 1, day, (hour % 12) + (match[7] === 'PM' ? 12 : 0), minute, second));\n\tif (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {\n\t\treturn undefined;\n\t}\n\n\treturn date.toISOString();\n}\n\nfunction readValues<T>(body: { value?: T[] } | undefined): T[] {\n\tif (!Array.isArray(body?.value)) throw new WorkItemWriteError('unknown');\n\n\treturn body.value;\n}\n\nfunction assertExistingAddress(address: WorkItemAddress): void {\n\tif (!isPositiveInt32(address.workItemId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertMutationIdentity(expectedAccountId: string): void {\n\tif (!isWriteIdentifier(expectedAccountId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertSameRevision(item: AzureWorkItem, expectedRevision: number): void {\n\tif (!isPositiveInt32(expectedRevision)) throw new WorkItemWriteError('invalid-input');\n\tif (item.rev !== expectedRevision) throw new WorkItemWriteError('conflict');\n}\n\nfunction isJsonValue(value: unknown, ancestors = new Set<object>()): boolean {\n\tif (value == null) return value === null;\n\tif (typeof value === 'string' || typeof value === 'boolean') return true;\n\tif (typeof value === 'number') return Number.isFinite(value);\n\tif (typeof value !== 'object' || ancestors.has(value)) return false;\n\tif (\n\t\t!Array.isArray(value) &&\n\t\tObject.getPrototypeOf(value) !== Object.prototype &&\n\t\tObject.getPrototypeOf(value) !== null\n\t) {\n\t\treturn false;\n\t}\n\n\tancestors.add(value);\n\tconst valid = Object.values(value).every(entry => isJsonValue(entry, ancestors));\n\tancestors.delete(value);\n\treturn valid;\n}\n\nfunction isInProjectPath(value: unknown, projectName: string): boolean {\n\tif (typeof value !== 'string') return false;\n\n\tconst root = value.split('\\\\', 1)[0];\n\treturn root.toLowerCase() === projectName.toLowerCase();\n}\n\nfunction getFieldPatches(\n\tinput: Readonly<Record<string, unknown>>,\n\tfieldMetadata: readonly WorkItemWriteField[],\n\tprojectName: string,\n\tcurrent?: Readonly<Record<string, unknown>>,\n): Patch[] {\n\tif (input == null || typeof input !== 'object' || Array.isArray(input)) {\n\t\tthrow new WorkItemWriteError('invalid-input');\n\t}\n\n\tconst fields = new Map(fieldMetadata.map(field => [field.referenceName, field]));\n\tconst errors = new Map<string, string>();\n\tconst patch: Patch[] = [];\n\tfor (const [name, value] of Object.entries(input)) {\n\t\tconst field = fields.get(name);\n\t\tif (field == null || !isJsonValue(value)) {\n\t\t\terrors.set(name, field == null ? 'Field is unavailable for writing.' : 'Expected a JSON field value.');\n\t\t\tcontinue;\n\t\t}\n\t\tif (isAzureProjectPathField(name) && !isInProjectPath(value, projectName)) {\n\t\t\terrors.set(name, 'Expected a path in the selected project.');\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst path = `/fields/${name.replaceAll('~', '~0').replaceAll('/', '~1')}`;\n\t\tif (current != null && value === null) {\n\t\t\tif (Object.hasOwn(current, name)) {\n\t\t\t\tpatch.push({ op: 'remove', path: path });\n\t\t\t}\n\t\t} else {\n\t\t\tpatch.push({ op: 'add', path: path, value: value });\n\t\t}\n\t}\n\tif (current == null) {\n\t\tfor (const field of fieldMetadata) {\n\t\t\tconst value = Object.hasOwn(input, field.referenceName) ? input[field.referenceName] : undefined;\n\t\t\tif (\n\t\t\t\tfield.required &&\n\t\t\t\t(value === null || value === '' || (value === undefined && !Object.hasOwn(field, 'defaultValue')))\n\t\t\t) {\n\t\t\t\terrors.set(field.referenceName, 'This field is required.');\n\t\t\t}\n\t\t}\n\t}\n\tif (errors.size) throw new WorkItemWriteError('invalid-input', Object.fromEntries(errors));\n\n\treturn patch;\n}\n\nasync function readProject(\n\trequest: ProviderRequestFunction,\n\theaders: { Authorization: string },\n\tcollectionUrl: string,\n\tprojectId: string,\n\tapiVersion: string,\n): Promise<{ id: string; name: string }> {\n\tconst { body: project } = await request<{ id?: unknown; name?: unknown }>({\n\t\turl: `${collectionUrl}/_apis/projects/${projectId}?api-version=${apiVersion}`,\n\t\theaders: headers,\n\t\tredirect: 'error',\n\t});\n\tif (!sameIdentifier(project?.id, projectId) || !isWriteIdentifier(project?.name)) {\n\t\tthrow new WorkItemWriteError('not-found');\n\t}\n\n\treturn { id: project.id as string, name: project.name };\n}\n\nexport class AzureWorkItemWriter {\n\tstatic async connect(\n\t\trequest: ProviderRequestFunction,\n\t\tcredential: { accessToken: string; authorization: string },\n\t\toptions: AzureServicesWorkItemWriteScope,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst { body: profile } = await getAzureWriteProfile(request, credential.accessToken);\n\t\tconst accountId = profile?.id;\n\t\tif (\n\t\t\t!isWriteIdentifier(accountId) ||\n\t\t\t(options.expectedAccountId !== undefined && !sameIdentifier(accountId, options.expectedAccountId))\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('no-connection');\n\t\t}\n\n\t\tconst headers = { Authorization: credential.authorization };\n\t\tconst { body: accounts } = await getAzureWriteOrganizations(request, credential.authorization, accountId);\n\t\tconst organization = readValues(accounts).find(\n\t\t\taccount =>\n\t\t\t\tsameIdentifier(account.accountId, options.organizationId) &&\n\t\t\t\tsameIdentifier(account.accountName, options.organizationName),\n\t\t);\n\t\tif (organization == null) throw new WorkItemWriteError('not-found');\n\n\t\tconst organizationUrl = `https://dev.azure.com/${encodeAzurePathSegment(organization.accountName)}`;\n\t\tconst project = await readProject(request, headers, organizationUrl, options.projectId, '7.1');\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\taccountId: accountId,\n\t\t\t\torganization: { id: organization.accountId, name: organization.accountName },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\torganizationUrl,\n\t\t\t'7.1',\n\t\t\t() => Promise.resolve('7.1'),\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tstatic async connectServer(\n\t\trequest: ProviderRequestFunction,\n\t\tauthorization: string,\n\t\toptions: AzureServerWorkItemWriteScope,\n\t\tcollectionUrl: string,\n\t\tresolveApiVersion: () => Promise<string | undefined>,\n\t\tresolveStatesApiVersion: () => Promise<string | undefined>,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst headers = { Authorization: authorization };\n\t\tconst collection = await verifyAzureServerCollection(request, headers, collectionUrl, options);\n\t\tif (typeof collection === 'string') throw new WorkItemWriteError(collection);\n\n\t\tconst apiVersion = await resolveApiVersion();\n\t\tif (apiVersion == null) throw new WorkItemWriteError('unsupported');\n\n\t\tconst project = await readProject(request, headers, collectionUrl, options.projectId, apiVersion);\n\t\tlet statesApiVersion: Promise<string> | undefined;\n\t\treturn new AzureWorkItemWriter(\n\t\t\trequest,\n\t\t\theaders,\n\t\t\t{\n\t\t\t\tproviderId: options.providerId,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\taccountId: collection.accountId,\n\t\t\t\torganization: { id: collection.id, name: collection.name, url: collectionUrl },\n\t\t\t\tproject: project,\n\t\t\t},\n\t\t\tcollectionUrl,\n\t\t\tapiVersion,\n\t\t\t() =>\n\t\t\t\t(statesApiVersion ??= resolveStatesApiVersion().then(version => {\n\t\t\t\t\tif (version == null) throw new WorkItemWriteError('unsupported');\n\n\t\t\t\t\treturn version;\n\t\t\t\t})),\n\t\t\tisSessionCurrent,\n\t\t);\n\t}\n\n\tprivate readonly projectUrl: string;\n\n\tprivate constructor(\n\t\tprivate readonly request: ProviderRequestFunction,\n\t\tprivate readonly headers: { Authorization: string },\n\t\tprivate readonly context: WorkItemWriteContext,\n\t\tprivate readonly organizationUrl: string,\n\t\tprivate readonly apiVersion: string,\n\t\tprivate readonly getStatesApiVersion: () => Promise<string>,\n\t\tprivate readonly isSessionCurrent: () => Promise<boolean>,\n\t) {\n\t\tthis.projectUrl = `${organizationUrl}/${context.project.id}`;\n\t}\n\n\tasync getCreateOptions(options: WorkItemCreateOptions): Promise<WorkItemCreateOptionsResult> {\n\t\tif (options.workItemType === undefined) {\n\t\t\tconst types = await this.read<{ value?: AzureWorkItemTypeMetadata[] }>('/workitemtypes');\n\t\t\tconst enabled = readValues(types).filter(type => isWriteIdentifier(type.name) && !type.isDisabled);\n\t\t\treturn { ok: true, ...this.context, workItemTypes: enabled.map(type => ({ name: type.name })) };\n\t\t}\n\n\t\tconst { type, fields, states, catalog } = await this.getMetadata(options.workItemType);\n\t\tif (type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tworkItemType: type.name,\n\t\t\tfields: fields,\n\t\t\tstates: states,\n\t\t\tinitialStates: getAzureWorkItemTransitionTargets(type, states, ''),\n\t\t\tbodyField: getAzureWorkItemBodyField(fields, catalog),\n\t\t};\n\t}\n\n\tasync getWriteOptions(options: WorkItemAddress): Promise<WorkItemWriteOptionsResult> {\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\tfields: metadata.fields,\n\t\t\tavailableStates: getAzureWorkItemTransitionTargets(metadata.type, metadata.states, issue.state.name),\n\t\t\tdeleteCapability: await this.getDeleteCapability(metadata.type).catch((): WorkItemDeleteCapability => ({\n\t\t\t\tallowed: 'unknown',\n\t\t\t})),\n\t\t\tbodyField: issue.bodyField,\n\t\t};\n\t}\n\n\tasync resolveTarget(options: WorkItemWriteTargetOptions): Promise<WorkItemWriteTargetResult> {\n\t\tif (options.intent !== undefined && options.intent !== 'delete') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst issue = this.getReceipt(item, metadata);\n\t\tconst deleteCapability =\n\t\t\toptions.intent === 'delete' ? await this.getDeleteCapability(metadata.type) : undefined;\n\t\tif (deleteCapability?.allowed === false) throw new WorkItemWriteError(deleteCapability.reason);\n\n\t\treturn {\n\t\t\tok: true,\n\t\t\t...this.context,\n\t\t\tissue: issue,\n\t\t\t...(deleteCapability && { deleteCapability: deleteCapability }),\n\t\t};\n\t}\n\n\tasync write(options: WorkItemWriteOptions): Promise<WorkItemWriteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tif (options.action === 'create') return this.create(options);\n\n\t\tif (options.action !== 'edit' && options.action !== 'set-state') throw new WorkItemWriteError('invalid-input');\n\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst patch = getFieldPatches(options.fields ?? {}, metadata.fields, this.context.project.name, item.fields);\n\t\tif (options.action === 'set-state') {\n\t\t\tconst state = this.getReceipt(item, metadata).state.name;\n\t\t\tif (\n\t\t\t\t!getAzureWorkItemTransitionTargets(metadata.type, metadata.states, state).some(\n\t\t\t\t\ts => s.name === options.state,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new WorkItemWriteError('transition-unavailable');\n\t\t\t}\n\n\t\t\tpatch.push({ op: 'add', path: '/fields/System.State', value: options.state });\n\t\t}\n\t\tif (!patch.length) throw new WorkItemWriteError('invalid-input');\n\n\t\tpatch.unshift({ op: 'test', path: '/rev', value: options.expectedRevision });\n\t\treturn this.save('PATCH', `/workitems/${item.id}`, patch, metadata, {\n\t\t\tid: item.id,\n\t\t\tstate: options.action === 'set-state' ? options.state : undefined,\n\t\t});\n\t}\n\n\tasync delete(options: WorkItemDeleteOptions): Promise<WorkItemDeleteResult> {\n\t\tassertMutationIdentity(options.expectedAccountId);\n\t\tconst item = await this.getItem(options);\n\t\tassertSameRevision(item, options.expectedRevision);\n\t\tconst metadata = await this.getMetadata(this.itemType(item));\n\t\tconst capability = await this.getDeleteCapability(metadata.type);\n\t\tif (capability.allowed === false) throw new WorkItemWriteError(capability.reason);\n\n\t\tawait this.assertSessionCurrent();\n\t\tconst current = await this.getItem(options);\n\t\tassertSameRevision(current, options.expectedRevision);\n\t\tif (this.itemType(current) !== metadata.type.name) throw new WorkItemWriteError('conflict');\n\n\t\tconst issue = this.getReceipt(current, metadata);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body, status } = await this.request<AzureDeletedWorkItem>({\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl: this.url(`/workitems/${issue.id}`),\n\t\t\t\theaders: this.headers,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tlet deleted =\n\t\t\t\tstatus === 200 && isDeletedItem(body, issue.id) && body.deletedDate != null ? body : undefined;\n\t\t\tif (deleted == null || getDeletedRevision(deleted, issue.id) === undefined) {\n\t\t\t\tconst recycled = await this.read<AzureDeletedWorkItem>(`/recyclebin/${issue.id}`).catch(\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t\tif (isDeletedItem(recycled, issue.id)) {\n\t\t\t\t\tdeleted = recycled;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (deleted == null) return { ok: false, reason: 'unknown', applied: 'maybe' };\n\n\t\t\treturn await this.toDeleteOutcome(deleted, issue, options.expectedRevision);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n\n\tprivate async toDeleteOutcome(\n\t\tdeleted: AzureDeletedWorkItem & { project: string },\n\t\tissue: WorkItemReceipt,\n\t\texpectedRevision: number,\n\t): Promise<WorkItemDeleteResult> {\n\t\tconst revision = getDeletedRevision(deleted, issue.id);\n\t\tconst deletedAt = toDeletedAt(deleted.deletedDate);\n\t\tconst deletion = {\n\t\t\tdisposition: 'recycle-bin',\n\t\t\trestorable: true,\n\t\t\t...(revision !== undefined && { revision: revision }),\n\t\t\t...(deletedAt !== undefined && { deletedAt: deletedAt }),\n\t\t} as const;\n\t\tconst project = sameIdentifier(\n\t\t\tdeleted.project,\n\t\t\tisAzureGuid(deleted.project) ? this.context.project.id : this.context.project.name,\n\t\t)\n\t\t\t? this.context.project\n\t\t\t: await this.findProject(deleted.project);\n\t\tif (sameIdentifier(project.id, this.context.project.id) && revision === expectedRevision + 1) {\n\t\t\treturn { ok: true, ...this.context, issue: issue, deletion: { ...deletion, revision: revision } };\n\t\t}\n\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: 'target-changed',\n\t\t\tapplied: true,\n\t\t\t...this.context,\n\t\t\tdeleted: { id: issue.id, ...(revision !== undefined && { revision: revision }), project: project },\n\t\t\tdeletion: deletion,\n\t\t};\n\t}\n\n\tprivate async findProject(nameOrId: string): Promise<{ id?: string; name: string }> {\n\t\ttry {\n\t\t\tconst project = await this.readOrganization<{ id?: unknown; name?: unknown }>(\n\t\t\t\t`/projects/${encodeAzurePathSegment(nameOrId)}`,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tisAzureGuid(project?.id) &&\n\t\t\t\tisWriteIdentifier(project.name) &&\n\t\t\t\t(sameIdentifier(project.name, nameOrId) || sameIdentifier(project.id, nameOrId))\n\t\t\t) {\n\t\t\t\treturn { id: project.id, name: project.name };\n\t\t\t}\n\t\t} catch {}\n\n\t\treturn { name: nameOrId };\n\t}\n\n\tprivate async create(options: Extract<WorkItemWriteOptions, { action: 'create' }>): Promise<WorkItemWriteResult> {\n\t\tconst metadata = await this.getMetadata(options.workItemType);\n\t\tif (metadata.type.isDisabled) throw new WorkItemWriteError('invalid-input');\n\n\t\tconst patch = getFieldPatches(options.fields, metadata.fields, this.context.project.name);\n\t\treturn this.save('POST', `/workitems/$${encodeAzurePathSegment(metadata.type.name)}`, patch, metadata);\n\t}\n\n\tprivate async getDeleteCapability(type: AzureWorkItemTypeMetadata): Promise<WorkItemDeleteCapability> {\n\t\tif (isAzureTestArtifact(type)) return { allowed: false, reason: 'unsupported' };\n\n\t\tconst categories = await this.read<{ value?: AzureWorkItemTypeCategory[] }>('/workitemtypecategories');\n\t\tif (isAzureTestArtifact(type, readValues(categories))) return { allowed: false, reason: 'unsupported' };\n\n\t\ttry {\n\t\t\tconst namespaces = await this.readOrganization<{\n\t\t\t\tvalue?: { namespaceId?: unknown; actions?: { bit?: unknown; name?: unknown }[] }[];\n\t\t\t}>(`/securitynamespaces/${projectSecurityNamespaceId}`);\n\t\t\tconst bit = readValues(namespaces)\n\t\t\t\t.find(namespace => sameIdentifier(namespace?.namespaceId, projectSecurityNamespaceId))\n\t\t\t\t?.actions?.find(action => action?.name === 'WORK_ITEM_DELETE')?.bit;\n\t\t\tif (!isPositiveInt32(bit)) return { allowed: 'unknown' };\n\n\t\t\tconst permissions = await this.readOrganization<{ value?: unknown[] }>(\n\t\t\t\t`/permissions/${projectSecurityNamespaceId}/${bit}`,\n\t\t\t\t{\n\t\t\t\t\ttokens: `$PROJECT:vstfs:///Classification/TeamProject/${this.context.project.id}`,\n\t\t\t\t\talwaysAllowAdministrators: 'false',\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst [allowed, ...rest] = readValues(permissions);\n\t\t\tif (typeof allowed !== 'boolean' || rest.length) return { allowed: 'unknown' };\n\n\t\t\treturn allowed ? { allowed: true } : { allowed: false, reason: 'forbidden' };\n\t\t} catch {\n\t\t\treturn { allowed: 'unknown' };\n\t\t}\n\t}\n\n\tprivate async getMetadata(name: string): Promise<WorkItemMetadata> {\n\t\tif (!isWriteIdentifier(name) || name === '.' || name === '..' || /[/\\\\]/.test(name)) {\n\t\t\tthrow new WorkItemWriteError('invalid-input');\n\t\t}\n\n\t\tconst path = `/workitemtypes/${encodeAzurePathSegment(name)}`;\n\t\tconst [type, typeFields, definitions] = await Promise.all([\n\t\t\tthis.read<AzureWorkItemTypeMetadata>(path),\n\t\t\tthis.read<{ value?: AzureWorkItemTypeField[] }>(`${path}/fields`, { $expand: 'All' }),\n\t\t\tthis.read<{ value?: AzureWorkItemFieldDefinition[] }>('/fields'),\n\t\t]);\n\t\tif (!sameIdentifier(type?.name, name) || !isWriteIdentifier(type?.referenceName)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\t\tif (type.transitions == null || typeof type.transitions !== 'object' || Array.isArray(type.transitions)) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst states =\n\t\t\tArray.isArray(type.states) && type.states.length !== 0\n\t\t\t\t? type.states\n\t\t\t\t: readValues(\n\t\t\t\t\t\tawait this.read<{ value?: WorkItemState[] }>(`${path}/states`, {\n\t\t\t\t\t\t\t'api-version': await this.getStatesApiVersion(),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\tif (states.some(state => !isWriteIdentifier(state?.name) || !isWriteIdentifier(state.category))) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\tconst catalog = readValues(definitions);\n\t\treturn {\n\t\t\ttype: type,\n\t\t\tstates: states.map(({ name, category, color }) => ({\n\t\t\t\tname: name,\n\t\t\t\tcategory: category,\n\t\t\t\t...(typeof color === 'string' && { color: color }),\n\t\t\t})),\n\t\t\tfields: toAzureWorkItemWriteFields(readValues(typeFields), catalog),\n\t\t\tcatalog: catalog,\n\t\t};\n\t}\n\n\tprivate async getItem(options: WorkItemAddress): Promise<AzureWorkItem> {\n\t\tassertExistingAddress(options);\n\t\tconst data = await this.read<AzureWorkItem>(`/workitems/${options.workItemId}`);\n\t\tif (!this.isInProject(data) || data.id !== options.workItemId) throw new WorkItemWriteError('not-found');\n\n\t\treturn data;\n\t}\n\n\tprivate isInProject(item: AzureWorkItem | undefined): item is AzureWorkItem {\n\t\treturn sameIdentifier(item?.fields?.['System.TeamProject'], this.context.project.name);\n\t}\n\n\tprivate itemType(item: AzureWorkItem): string {\n\t\tconst type = item.fields['System.WorkItemType'];\n\t\tif (!isWriteIdentifier(type)) throw new WorkItemWriteError('unknown');\n\n\t\treturn type;\n\t}\n\n\tprivate getReceipt(item: AzureWorkItem, metadata: WorkItemMetadata): WorkItemReceipt {\n\t\tconst title = item.fields['System.Title'];\n\t\tconst state = metadata.states.find(candidate => candidate.name === item.fields['System.State']);\n\t\tif (\n\t\t\t!isPositiveInt32(item.id) ||\n\t\t\t!isPositiveInt32(item.rev) ||\n\t\t\ttypeof title !== 'string' ||\n\t\t\tstate == null ||\n\t\t\tthis.itemType(item) !== metadata.type.name\n\t\t) {\n\t\t\tthrow new WorkItemWriteError('unknown');\n\t\t}\n\n\t\treturn {\n\t\t\tid: item.id,\n\t\t\trevision: item.rev,\n\t\t\turl: `${this.projectUrl}/_workitems/edit/${item.id}`,\n\t\t\ttype: metadata.type.name,\n\t\t\ttitle: title,\n\t\t\tstate: { name: state.name, category: state.category },\n\t\t\tbodyField: getAzureWorkItemBodyField(metadata.fields, metadata.catalog, item.fields),\n\t\t};\n\t}\n\n\tprivate async assertSessionCurrent(): Promise<void> {\n\t\tif (!(await this.isSessionCurrent())) throw new WorkItemWriteError('no-connection');\n\t}\n\n\tprivate url(path: string, params?: Record<string, string>, base = `${this.projectUrl}/_apis/wit`): string {\n\t\treturn `${base}${path}?${new URLSearchParams({ 'api-version': this.apiVersion, ...params }).toString()}`;\n\t}\n\n\tprivate read<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params));\n\t}\n\n\tprivate readOrganization<T>(path: string, params?: Record<string, string>): Promise<T> {\n\t\treturn this.get<T>(this.url(path, params, `${this.organizationUrl}/_apis`));\n\t}\n\n\tprivate async get<T>(url: string): Promise<T> {\n\t\tconst { body } = await this.request<T>({ url: url, headers: this.headers, redirect: 'error' });\n\t\treturn body;\n\t}\n\n\tprivate async save(\n\t\tmethod: 'POST' | 'PATCH',\n\t\tpath: string,\n\t\tpatch: Patch[],\n\t\tmetadata: WorkItemMetadata,\n\t\texpected?: { id: number; state?: string },\n\t): Promise<WorkItemWriteResult> {\n\t\tconst body = JSON.stringify(patch);\n\t\tawait this.assertSessionCurrent();\n\t\ttry {\n\t\t\tconst { body: item } = await this.request<AzureWorkItem>({\n\t\t\t\tmethod: method,\n\t\t\t\turl: this.url(path),\n\t\t\t\theaders: { ...this.headers, 'Content-Type': 'application/json-patch+json' },\n\t\t\t\tbody: body,\n\t\t\t\tredirect: 'error',\n\t\t\t});\n\t\t\tif (\n\t\t\t\t!this.isInProject(item) ||\n\t\t\t\t(expected != null && item.id !== expected.id) ||\n\t\t\t\t(expected?.state !== undefined && item.fields['System.State'] !== expected.state)\n\t\t\t) {\n\t\t\t\treturn { ok: false, reason: 'unknown', applied: 'maybe' };\n\t\t\t}\n\n\t\t\treturn { ok: true, ...this.context, issue: this.getReceipt(item, metadata) };\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof WorkItemWriteNotDispatchedError) return toWorkItemWriteFailure(ex);\n\n\t\t\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AA+DA,MAAM,6BAA6B;AAEnC,SAAS,SAAS,QAAiB,IAAqB;CACvD,OAAO,WAAW,MAAM,WAAW,OAAO,EAAE;AAC7C;AAEA,SAAS,cACR,MACA,IACqD;CACrD,IAAI,QAAQ,QAAQ,CAAC,SAAS,KAAK,IAAI,EAAE,KAAK,CAAC,kBAAkB,KAAK,OAAO,GAAG,OAAO;CAEvF,OACC,KAAK,QAAQ,QAAQ,KAAK,SAAS,KAAM,OAAO,KAAK,SAAS,YAAY,KAAK,QAAQ,OAAO,KAAK,OAAO;AAE5G;AAEA,SAAS,mBAAmB,MAA4B,IAAgC;CACvF,MAAM,WAAW,KAAK;CACtB,OAAO,YAAY,QAAQ,SAAS,SAAS,IAAI,EAAE,KAAK,gBAAgB,SAAS,GAAG,IAAI,SAAS,MAAM,KAAA;AACxG;AAGA,MAAM,mBAAmB;AAEzB,SAAS,YAAY,OAAoC;CACxD,MAAM,QAAQ,OAAO,UAAU,WAAW,iBAAiB,KAAK,KAAK,IAAI;CACzE,IAAI,SAAS,MAAM,OAAO,KAAA;CAE1B,MAAM,CAAC,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C;EAC1E,OAAO,KAAK,IAAO,KAAK,IAAI,MAAM,MAAM,CAAC;CAC1C;CAEA,iBAA4B,MAAc,QAA6C;EACtF,OAAO,KAAK,IAAO,KAAK,IAAI,MAAM,QAAQ,GAAG,KAAK,gBAAgB,OAAO,CAAC;CAC3E;CAEA,MAAc,IAAO,KAAyB;EAC7C,MAAM,EAAE,SAAS,MAAM,KAAK,QAAW;GAAO;GAAK,SAAS,KAAK;GAAS,UAAU;EAAQ,CAAC;EAC7F,OAAO;CACR;CAEA,MAAc,KACb,QACA,MACA,OACA,UACA,UAC+B;EAC/B,MAAM,OAAO,KAAK,UAAU,KAAK;EACjC,MAAM,KAAK,qBAAqB;EAChC,IAAI;GACH,MAAM,EAAE,MAAM,SAAS,MAAM,KAAK,QAAuB;IAChD;IACR,KAAK,KAAK,IAAI,IAAI;IAClB,SAAS;KAAE,GAAG,KAAK;KAAS,gBAAgB;IAA8B;IACpE;IACN,UAAU;GACX,CAAC;GACD,IACC,CAAC,KAAK,YAAY,IAAI,KACrB,YAAY,QAAQ,KAAK,OAAO,SAAS,MACzC,UAAU,UAAU,KAAA,KAAa,KAAK,OAAO,oBAAoB,SAAS,OAE3E,OAAO;IAAE,IAAI;IAAO,QAAQ;IAAW,SAAS;GAAQ;GAGzD,OAAO;IAAE,IAAI;IAAM,GAAG,KAAK;IAAS,OAAO,KAAK,WAAW,MAAM,QAAQ;GAAE;EAC5E,SAAS,IAAI;GACZ,IAAI,cAAc,iCAAiC,OAAO,uBAAuB,EAAE;GAEnF,OAAO,uBAAuB,IAAI,EAAE,QAAQ,SAAS,OAAO,CAAC;EAC9D;CACD;AACD"}
|
|
@@ -8,10 +8,12 @@ import { PullRequestUrlIdentity } from "../../../git/utils/pullRequest.utils.js"
|
|
|
8
8
|
import { AuthenticationSessionLike, ProviderAuthenticationSession } from "../authentication/models.js";
|
|
9
9
|
import { GitCloudHostIntegrationId } from "../constants.js";
|
|
10
10
|
import { IntegrationAuthenticationProviderDescriptor } from "../authentication/integrationAuthenticationProvider.js";
|
|
11
|
+
import { BitbucketPullRequestCreateCapabilityOptions } from "../models/bitbucketPullRequestWrites.js";
|
|
11
12
|
import { PullRequestEtagFields, PullRequestEtagInclude } from "../reads/etag.js";
|
|
12
13
|
import { ProviderOrganization } from "../results.js";
|
|
13
14
|
import { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from "../models/publicIntegration.js";
|
|
14
15
|
import { ProviderRefusal } from "../collectionMetadata.js";
|
|
16
|
+
import { BitbucketPullRequestWriter } from "./bitbucketPullRequestWrites.js";
|
|
15
17
|
import { ProviderApiPagedResult, ProviderHierarchyResult, ProviderPullRequest, ProviderRepository } from "./models.js";
|
|
16
18
|
import { GitHostIntegration } from "../models/gitHostIntegration.js";
|
|
17
19
|
import { BitbucketRepositoryDescriptor } from "./bitbucket/models.js";
|
|
@@ -23,9 +25,11 @@ export declare class BitbucketIntegration extends GitHostIntegration<GitCloudHos
|
|
|
23
25
|
readonly name: string;
|
|
24
26
|
get domain(): string;
|
|
25
27
|
protected get apiBaseUrl(): string;
|
|
28
|
+
private readonly pullRequestWriteLedger;
|
|
26
29
|
protected mergeProviderPullRequest(session: ProviderAuthenticationSession, pr: PullRequest, options?: {
|
|
27
30
|
mergeMethod?: PullRequestMergeMethod;
|
|
28
31
|
}): Promise<boolean>;
|
|
32
|
+
getPullRequestWriter(options: BitbucketPullRequestCreateCapabilityOptions): Promise<BitbucketPullRequestWriter | undefined>;
|
|
29
33
|
getRepoInfo(repo: {
|
|
30
34
|
owner: string;
|
|
31
35
|
name: string;
|
|
@@ -14,6 +14,7 @@ import { toBitbucketPullRequestEtagFields } from "./bitbucket/models.js";
|
|
|
14
14
|
import { BitbucketCommitLinksAppMissingError, BitbucketCommitNotFoundError, BitbucketCommitPullRequestsUnindexedError } from "./bitbucket/bitbucket.js";
|
|
15
15
|
import { GitHostIntegration } from "../models/gitHostIntegration.js";
|
|
16
16
|
import { getBitbucketPullRequestIdentityFromMaybeUrl } from "./bitbucket/bitbucket.utils.js";
|
|
17
|
+
import { BitbucketPullRequestWriteLedger } from "./bitbucketPullRequestWriteLedger.js";
|
|
17
18
|
//#region ../plus/integrations/src/providers/bitbucket.ts
|
|
18
19
|
const metadata = providersMetadata["bitbucket"];
|
|
19
20
|
const authProvider = Object.freeze({
|
|
@@ -31,9 +32,16 @@ var BitbucketIntegration = class extends GitHostIntegration {
|
|
|
31
32
|
get apiBaseUrl() {
|
|
32
33
|
return "https://api.bitbucket.org/2.0";
|
|
33
34
|
}
|
|
35
|
+
pullRequestWriteLedger = new BitbucketPullRequestWriteLedger();
|
|
34
36
|
async mergeProviderPullRequest(session, pr, options) {
|
|
35
37
|
return (await this.getProvidersApi()).mergePullRequest(toTokenWithInfo(this.id, session), pr, { mergeMethod: options?.mergeMethod });
|
|
36
38
|
}
|
|
39
|
+
async getPullRequestWriter(options) {
|
|
40
|
+
const session = await this.resolveReadSessionOrThrow(options.connectionId, void 0);
|
|
41
|
+
if (session?.id !== options.connectionId || !session.accessToken) return void 0;
|
|
42
|
+
const isSessionCurrent = this.trackWriteSession(session);
|
|
43
|
+
return (await this.getProvidersApi()).getBitbucketPullRequestWriter(options, session, isSessionCurrent, this.pullRequestWriteLedger);
|
|
44
|
+
}
|
|
37
45
|
async getRepoInfo(repo) {
|
|
38
46
|
const api = await this.getProvidersApi();
|
|
39
47
|
const session = await this.resolveReadSessionOrThrow(repo.connectionId, void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitbucket.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport { uniqueBy } from '@gitlens/utils/iterable.js';\nimport { batchResults, flatSettled, mapSettledBounded, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport type { ProviderRefusal } from '../collectionMetadata.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitCloudHostIntegrationId } from '../constants.js';\nimport { IntegrationReadUnavailableError } from '../errors.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/publicIntegration.js';\nimport type { PullRequestEtagFields, PullRequestEtagInclude } from '../reads/etag.js';\nimport {\n\tBitbucketCommitLinksAppMissingError,\n\tBitbucketCommitNotFoundError,\n\tBitbucketCommitPullRequestsUnindexedError,\n} from './bitbucket/bitbucket.js';\nimport { getBitbucketPullRequestIdentityFromMaybeUrl } from './bitbucket/bitbucket.utils.js';\nimport type { BitbucketRepositoryDescriptor, BitbucketWorkspaceDescriptor } from './bitbucket/models.js';\nimport { bitbucketEtagFieldsMaxIds, toBitbucketPullRequestEtagFields } from './bitbucket/models.js';\nimport { providersMetadata } from './metadata.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderApiPagedResult,\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tmergeCollectionMetadata,\n\tparsePageCursor,\n\tproviderFanOutConcurrency,\n\treadEtagFieldsByRepository,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitCloudHostIntegrationId.Bitbucket];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketIntegration extends GitHostIntegration<\n\tGitCloudHostIntegrationId.Bitbucket,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitCloudHostIntegrationId.Bitbucket;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Bitbucket';\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.bitbucket.org/2.0';\n\t}\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\tmergeMethod: options?.mergeMethod,\n\t\t});\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSessionOrThrow(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tbaseUrl: this.apiBaseUrl,\n\t\t});\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\tavatarSize: options?.avatarSize,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_email: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getDefaultBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssueOrPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\ttype: type,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot:\n\t * provider-apis has no single pull request read for Bitbucket, so this uses our own.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, c =>\n\t\t\tapi.getPullRequest(this, tokenWithInfo, c.owner, c.repo, String(c.number), this.apiBaseUrl, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tdeferFailure: true,\n\t\t\t\tprojection: 'batch',\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * The cheap check behind the batch pull request read's etags: GitLens' own client lists each repository's pull\n\t * requests by id, up to {@link bitbucketEtagFieldsMaxIds} in ONE request, where\n\t * {@link getProviderPullRequestsBatch} sends one per target, and selects only the fields its rows' etags read.\n\t * Each is converted as {@link fromBitbucketPullRequest} converts the full one, so both reads compute the same\n\t * etag. A request that throws rejects only its own targets' slots.\n\t *\n\t * The full row reads neither a mergeability nor a check rollup, so its etag sees a pull request's state, draft\n\t * flag, update time and head commit, plus its participants' review decision when included; the `mergeable` and\n\t * `checks` includes add nothing and cost nothing.\n\t */\n\tprotected override async getProviderPullRequestsEtagFields(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { etagIncludes?: readonly PullRequestEtagInclude[] },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestEtagFields | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst etagIncludes = options.etagIncludes ?? [];\n\n\t\treturn readEtagFieldsByRepository(\n\t\t\tcoordinates,\n\t\t\tbitbucketEtagFieldsMaxIds,\n\t\t\t(owner, repo, ids) =>\n\t\t\t\tapi.getPullRequestsEtagFields(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\towner,\n\t\t\t\t\trepo,\n\t\t\t\t\tids,\n\t\t\t\t\tthis.apiBaseUrl,\n\t\t\t\t\t{ etagIncludes: etagIncludes, deferFailure: true },\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\tnode => toBitbucketPullRequestEtagFields(node, etagIncludes),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently, through our own client: provider-apis' pull request list has\n\t * no source-branch filter.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(targets, providerFanOutConcurrency, t =>\n\t\t\tapi.getPullRequestsForBranch(this, tokenWithInfo, t.owner, t.repo, t.branch, this.apiBaseUrl, {\n\t\t\t\theadOwner: t.headOwner,\n\t\t\t\tlimit: options.limit,\n\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\tdeferFailure: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssue(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tbranch: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestsForCommits(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: { owner: string; repo: string; project?: string },\n\t\tshas: readonly string[],\n\t\toptions: { mergeQueue?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst slots = await super.getProviderPullRequestsForCommits(session, repo, shas, options, cancellation);\n\t\tif (slots == null) return undefined;\n\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tconst missing = slots.find(\n\t\t\t(slot): slot is PromiseRejectedResult & { reason: BitbucketCommitLinksAppMissingError } =>\n\t\t\t\tslot.status === 'rejected' && slot.reason instanceof BitbucketCommitLinksAppMissingError,\n\t\t);\n\t\tif (missing != null) {\n\t\t\tapi?.notifyCommitLinksAppMissing(repo.owner, missing.reason.commitUrl);\n\t\t}\n\n\t\tconst indexed =\n\t\t\tslots.some(slot => slot.status === 'fulfilled') ||\n\t\t\tapi?.isRepositoryIndexed(toTokenWithInfo(this.id, session), repo.owner, repo.repo) === true;\n\t\tif (!indexed) return slots;\n\n\t\treturn slots.map((slot): PromiseSettledResult<PullRequestShape | undefined> =>\n\t\t\tslot.status === 'rejected' && slot.reason instanceof BitbucketCommitNotFoundError\n\t\t\t\t? { status: 'fulfilled', value: undefined }\n\t\t\t\t: slot,\n\t\t);\n\t}\n\n\tprotected override getCommitLookupBackoff(\n\t\tex: unknown,\n\t): { scope: 'repository' | 'commit'; until?: number } | undefined {\n\t\tif (\n\t\t\tex instanceof BitbucketCommitLinksAppMissingError ||\n\t\t\tex instanceof BitbucketCommitPullRequestsUnindexedError\n\t\t) {\n\t\t\treturn { scope: 'repository' };\n\t\t}\n\n\t\treturn super.getCommitLookupBackoff(ex);\n\t}\n\n\tprotected override stopsCommitFanOut(reason: unknown, answered: boolean): boolean {\n\t\treturn (\n\t\t\treason instanceof BitbucketCommitLinksAppMissingError ||\n\t\t\treason instanceof BitbucketCommitPullRequestsUnindexedError ||\n\t\t\tsuper.stopsCommitFanOut(reason, answered)\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestForCommitInBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\treturn this.readPullRequestForCommit(session, repo, rev, true, cancellation);\n\t}\n\n\tprotected override getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn this.readPullRequestForCommit(session, repo, rev, false);\n\t}\n\n\tprivate async readPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\tdeferFailure: boolean,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) {\n\t\t\tthrow new IntegrationReadUnavailableError(this.name, 'no client to read the pull requests of a commit');\n\t\t}\n\n\t\treturn api.getPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{ deferFailure: deferFailure },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{ projection: 'point' },\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getBitbucketPullRequestIdentityFromMaybeUrl(search, this.id);\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getRepositoryMetadata(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst { accessToken } = session;\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(accessToken);\n\t\tif (cachedAccount == null) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst user = await api.getCurrentUser(toTokenWithInfo(this.id, session));\n\t\t\tthis._accounts.set(\n\t\t\t\taccessToken,\n\t\t\t\tuser\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: user.id,\n\t\t\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t\t\t\t\t\tusername: user.username ?? undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t}\n\n\t\treturn this._accounts.get(accessToken);\n\t}\n\n\t/** The profile request the account cache would otherwise answer; see `IntegrationBase.validateCredential`. */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif ((await api.getCurrentUser(toTokenWithInfo(this.id, session))) == null) {\n\t\t\tthrow new Error('Bitbucket did not confirm the credential');\n\t\t}\n\t}\n\n\t/**\n\t * Bitbucket's `403` for a token missing the OAuth scopes a request needs, which a reconnect fixes by consenting to\n\t * them again; see `IntegrationBase.isCredentialRefusal`.\n\t */\n\tprotected override isCredentialRefusal(refusal: ProviderRefusal): boolean {\n\t\treturn refusal.status === 403 && /required privilege scopes/i.test(refusal.detail ?? '');\n\t}\n\n\tprivate _workspaces: Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> | undefined;\n\tprivate async getProviderResourcesForCurrentUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> {\n\t\tthis._workspaces ??= new Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined>();\n\t\tconst { accessToken } = session;\n\t\tconst cachedResources = this._workspaces.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getBitbucketResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (resources == null) return undefined;\n\n\t\tconst values = resources.values.map(r => ({ ...r, key: r.id, name: r.name ?? r.slug }));\n\t\tconst metadata = mergeCollectionMetadata(\n\t\t\tresources.metadata,\n\t\t\tresources.paging?.truncated === true ? { completeness: 'partial' } : undefined,\n\t\t);\n\t\tconst result: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> = {\n\t\t\tvalues: values,\n\t\t\t...(metadata != null ? { metadata: metadata } : {}),\n\t\t};\n\n\t\t// A partial workspace prefix is useful to the current read but must not become authoritative cache state:\n\t\t// a transient page-2 failure must be retried on the next call rather than hiding every later workspace\n\t\t// until disconnect.\n\t\tif (metadata == null || metadata.completeness === 'complete') {\n\t\t\tthis._workspaces.set(accessToken, result);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization> | undefined> {\n\t\tconst workspaces = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspaces == null) return undefined;\n\n\t\treturn {\n\t\t\tvalues: workspaces.values.map(w => ({\n\t\t\t\tid: w.id,\n\t\t\t\tproviderId: this.id,\n\t\t\t\tname: w.slug,\n\t\t\t\turl: `https://bitbucket.org/${w.slug}`,\n\t\t\t})),\n\t\t\t...(workspaces.metadata != null ? { metadata: workspaces.metadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), org, {\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (repos != null) {\n\t\t\t// TODO: implement repos version\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst state = options?.state;\n\t\tconst states = toProviderPullRequestStates(state);\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\t// `user.id` feeds both the authored workspace reads and the reviewer BBQL clause; guard on it so we\n\t\t// never issue requests/queries with an undefined uuid. `username` isn't used here, so don't gate on it.\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) return [];\n\n\t\tconst authoredPrs = workspaces.map(async ws => {\n\t\t\tconst prs = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\tuser.id,\n\t\t\t\tws.slug,\n\t\t\t\t{ states: states },\n\t\t\t);\n\t\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' }));\n\t\t});\n\n\t\tif (!options?.includeReviewRequested) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\t// Bitbucket's reviewing PRs require a repo-scoped BBQL query; keep that sweep opt-in so the default\n\t\t// \"my pull requests\" feed stays aligned with backends that only expose authored PRs.\n\t\tconst stateClause =\n\t\t\tstate === 'closed'\n\t\t\t\t? '(state=\"DECLINED\" OR state=\"SUPERSEDED\")'\n\t\t\t\t: state === 'merged'\n\t\t\t\t\t? 'state=\"MERGED\"'\n\t\t\t\t\t: state === 'all'\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: 'state=\"OPEN\"';\n\n\t\tconst workspaceRepos = await this.getWorkspaceRepoInputs();\n\t\tif (workspaceRepos.length === 0) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\tconst reviewerClause = `reviewers.uuid=\"${user.id}\"`;\n\t\tconst reviewingPrs = api\n\t\t\t.getPullRequestsForRepos(toTokenWithInfo(this.id, session), workspaceRepos, {\n\t\t\t\tquery: stateClause ? `${stateClause} AND ${reviewerClause}` : reviewerClause,\n\t\t\t})\n\t\t\t.then(r => r.values?.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' })));\n\n\t\treturn [\n\t\t\t...uniqueBy(\n\t\t\t\tawait flatSettled([...authoredPrs, reviewingPrs]),\n\t\t\t\tpr => pr.url,\n\t\t\t\t(orig, _cur) => orig,\n\t\t\t),\n\t\t];\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: {\n\t\t\tstate?: PullRequestStateFilter[];\n\t\t\tcursor?: string;\n\t\t\tincludeReviewRequested?: boolean;\n\t\t\tfilters?: PullRequestFilter[];\n\t\t},\n\t): Promise<ProviderApiPagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) {\n\t\t\tconst incomplete =\n\t\t\t\tworkspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t\treturn {\n\t\t\t\tvalues: [],\n\t\t\t\tpaging: { cursor: '{}', more: false, truncated: incomplete || undefined },\n\t\t\t\t...(workspacesResult.metadata != null ? { metadata: workspacesResult.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\t// Account-wide \"my PRs\" for Bitbucket = the user's authored PRs across every workspace they belong to,\n\t\t// plus the PRs they've been requested to review. Bitbucket's cross-workspace read is per-workspace and\n\t\t// numbered-page, so drain each workspace fully (bounded by a defensive backstop) and concatenate.\n\t\t// There's no single cross-workspace cursor, so the aggregate is one page; `truncated` is set when a\n\t\t// workspace hit the backstop with more pages left, or when a workspace's read was dropped by a failure.\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\tconst requested = options?.filters?.length ? new Set(options.filters) : undefined;\n\t\tconst wantAuthored = requested == null || requested.has(PullRequestFilter.Author);\n\t\tconst wantReviewRequested =\n\t\t\trequested?.has(PullRequestFilter.ReviewRequested) ?? options?.includeReviewRequested === true;\n\t\tconst maxPagesPerWorkspace = 20;\n\t\tlet truncated = workspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t// Structured per-scope failures from BOTH the authored and reviewer slices. A rejected scope is recorded\n\t\t// here (never re-thrown) so successful sibling workspaces/repos survive and the ProviderBackend facade\n\t\t// maps each failure to an actionable warning + `fetchFailed` (auth/rate-limit failures still drive\n\t\t// recovery through their warning kind, matching the SDK's own collect-across-scopes model).\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tlet aggregateMetadata = workspacesResult.metadata;\n\t\tconst absorbCollectionResult = (result: ProviderHierarchyResult<unknown>): void => {\n\t\t\taggregateMetadata = mergeCollectionMetadata(aggregateMetadata, result.metadata);\n\t\t\tif (result.truncated || (result.metadata != null && result.metadata.completeness !== 'complete')) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t};\n\t\tconst settled = wantAuthored\n\t\t\t? await Promise.allSettled(\n\t\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\t\treturn collectProviderPagedResult(\n\t\t\t\t\t\t\tasync cursor => {\n\t\t\t\t\t\t\t\tconst result = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\tuser.id,\n\t\t\t\t\t\t\t\t\tws.slug,\n\t\t\t\t\t\t\t\t\t{ states: states, page: parsePageCursor(cursor) },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result == null) return undefined;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tvalues: result.data,\n\t\t\t\t\t\t\t\t\tpaging: {\n\t\t\t\t\t\t\t\t\t\tmore: result.hasMore,\n\t\t\t\t\t\t\t\t\t\tcursor:\n\t\t\t\t\t\t\t\t\t\t\tresult.hasMore && result.nextPage != null\n\t\t\t\t\t\t\t\t\t\t\t\t? toPageCursor(result.nextPage)\n\t\t\t\t\t\t\t\t\t\t\t\t: '{}',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmaxPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: [];\n\n\t\tconst prsByIdentity = new Map<string, ProviderPullRequest>();\n\t\tlet unkeyedPullRequest = 0;\n\t\tconst addPullRequest = (pr: ProviderPullRequest): void => {\n\t\t\tconst key = getProviderPullRequestIdentity(pr) ?? `unkeyed:${unkeyedPullRequest++}`;\n\t\t\tif (!prsByIdentity.has(key)) {\n\t\t\t\tprsByIdentity.set(key, pr);\n\t\t\t}\n\t\t};\n\t\t// `allSettled` preserves order, so `settled[i]` is `workspaces[i]`. A rejected workspace becomes a\n\t\t// structured failure (attributed to its slug) instead of a generic truncation or a re-throw, preserving\n\t\t// every sibling workspace's authored PRs.\n\t\tsettled.forEach((outcome, i) => {\n\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\tfailures.push(this.toWorkspaceFailure(workspaces[i].slug, outcome.reason));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tabsorbCollectionResult(outcome.value);\n\t\t\tfor (const pr of outcome.value.values) {\n\t\t\t\taddPullRequest(pr);\n\t\t\t}\n\t\t});\n\n\t\t// Bitbucket's account-wide (per-workspace) endpoint returns authored PRs only, and the SDK exposes no\n\t\t// workspace-level reviewer query — only a repo-scoped one. Adding the reviewer slice therefore requires\n\t\t// draining every workspace's full repo list and then a per-repo `getPullRequestsForRepo` with `reviewerId`\n\t\t// (O(workspaces × repos) requests), so keep it opt-in: gate it on `includeReviewRequested` so the default\n\t\t// sweep matches the gkcli baseline (authored PRs only, no reviewer fan-out) and a caller pays that cost\n\t\t// only when it deliberately asks for review-requested PRs.\n\t\tif (wantReviewRequested) {\n\t\t\t// Enumerate the account's repos by draining each resolved workspace's repository list, then drain the\n\t\t\t// real per-repo paged `getPullRequestsForRepo` for each repo with `reviewerId`, so review-requested PRs\n\t\t\t// aren't bounded to the currently-open remotes and a reviewer PR past the first page isn't dropped.\n\t\t\t// Structured per-scope failures are collected as CollectionScopeFailure so the ProviderBackend facade\n\t\t\t// maps them to actionable warnings (Step 3).\n\t\t\tconst maxReposPagesPerWorkspace = 20;\n\t\t\tconst maxPrPagesPerRepo = 20;\n\t\t\t// Bound concurrency: workspaces are few, so process them concurrently, but drain each workspace's repos\n\t\t\t// in a bounded batch rather than an unbounded Promise.all over every repo in every workspace.\n\t\t\tconst repoBatchSize = 5;\n\n\t\t\tawait Promise.all(\n\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\tlet repos: ProviderRepository[];\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst discovered = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), ws.slug, {\n\t\t\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmaxReposPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t\trepos = discovered.values;\n\t\t\t\t\t\tabsorbCollectionResult(discovered);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Record the workspace as a structured failure and keep going: the failure metadata drives\n\t\t\t\t\t\t// the warning + `fetchFailed` + incompleteness for every kind (auth/rate-limit stay\n\t\t\t\t\t\t// actionable via their warning kind), so sibling workspaces' repos are still drained.\n\t\t\t\t\t\tfailures.push(this.toWorkspaceFailure(ws.slug, ex));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst drained = await batchResults(repos, repoBatchSize, async repo => {\n\t\t\t\t\t\tconst reviewing = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getPullRequestsForRepo(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\t{ namespace: repo.namespace, name: repo.name },\n\t\t\t\t\t\t\t\t\t{ reviewerId: user.id, states: states, cursor: cursor },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tmaxPrPagesPerRepo,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tproviderId: this.id,\n\t\t\t\t\t\t\t\tresourceId: ws.slug,\n\t\t\t\t\t\t\t\trepositoryId: `${repo.namespace}/${repo.name}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn { repo: repo, reviewing: reviewing };\n\t\t\t\t\t});\n\n\t\t\t\t\tfor (let i = 0; i < drained.length; i++) {\n\t\t\t\t\t\tconst outcome = drained[i];\n\t\t\t\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\t\t\t\tconst repo = repos[i];\n\t\t\t\t\t\t\tfailures.push(\n\t\t\t\t\t\t\t\tthis.toRepositoryFailure(\n\t\t\t\t\t\t\t\t\t`${repo?.namespace ?? ws.slug}/${repo?.name ?? 'unknown'}`,\n\t\t\t\t\t\t\t\t\toutcome.reason,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst { reviewing } = outcome.value;\n\t\t\t\t\t\tabsorbCollectionResult(reviewing);\n\t\t\t\t\t\tfor (const pr of reviewing.values) {\n\t\t\t\t\t\t\taddPullRequest(pr);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Every slice that ran (authored workspaces always, reviewer workspaces/repos when opted in) records its\n\t\t// per-scope rejections as structured failures instead of re-throwing: re-throwing would discard every\n\t\t// successful sibling's PRs. Auth/rate-limit failures stay actionable through the metadata (the facade maps\n\t\t// kind `authentication` → an `auth` warning, `rate-limit` → a `rate-limit` warning) while the survivors are\n\t\t// returned with `fetchFailed`.\n\t\tconst metadata: CollectionMetadata | undefined = mergeCollectionMetadata(\n\t\t\tfailures.length > 0 ? { completeness: 'partial', failures: failures } : undefined,\n\t\t\taggregateMetadata,\n\t\t);\n\n\t\treturn {\n\t\t\tvalues: [...prsByIdentity.values()],\n\t\t\tpaging: { cursor: '{}', more: false, truncated: truncated || undefined },\n\t\t\tmetadata: metadata,\n\t\t};\n\t}\n\n\t/** Classifies a caught workspace-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toWorkspaceFailure(workspaceSlug: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, resourceId: workspaceSlug }, ex);\n\t}\n\n\t/** Classifies a caught repository-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toRepositoryFailure(repositoryId: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, repositoryId: repositoryId }, ex);\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) return undefined;\n\n\t\tconst workspaceRepos =\n\t\t\trepos != null\n\t\t\t\t? repos.map(r => ({ name: r.name, namespace: r.owner }))\n\t\t\t\t: await this.getWorkspaceRepoInputs();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t// An explicitly-empty `repos` means \"search these zero repos\" -> no results; reserve `undefined`\n\t\t// (\"scope couldn't be determined\") for when no repos were requested and none were discovered.\n\t\tif (workspaceRepos.length === 0) return repos != null ? [] : undefined;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderPullRequestStates(options?.include);\n\t\tconst providerPullRequests = await flatSettledOrThrow(\n\t\t\tworkspaceRepos.map(async repo => {\n\t\t\t\tconst result = await collectProviderPagedResult(cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\treturn api.getPullRequestsForRepo(token, repo, {\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tquery: searchQuery,\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn result.values;\n\t\t\t}),\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn providerPullRequests.map(pr => fromProviderPullRequest(pr, this, { projection: 'text-search' }));\n\t}\n\n\tprivate async getWorkspaceRepoInputs(): Promise<{ name: string; namespace: string }[]> {\n\t\tconst remotes = await this.ctx.repositories.getOpenRemotes();\n\t\tconst inputs = await nonnullSettled(\n\t\t\tremotes.map(async (r: GitRemote) => {\n\t\t\t\tconst integration = await this.authenticationService.getByRemote(r);\n\t\t\t\tif (integration !== this) return undefined;\n\n\t\t\t\t// Use the remote provider's parsing rather than splitting `r.path`, so adornments like a\n\t\t\t\t// trailing `.git` or extra path segments don't leak into the namespace/name.\n\t\t\t\tconst namespace = r.provider?.owner;\n\t\t\t\tconst name = r.provider?.repoName;\n\t\t\t\treturn namespace != null && name != null ? { name: name, namespace: namespace } : undefined;\n\t\t\t}),\n\t\t);\n\t\t// Dedupe: a repo with multiple remotes (e.g. `origin` + `upstream`) can map to the same input,\n\t\t// which would otherwise fetch and return the same PRs more than once.\n\t\treturn [...new Map(inputs.map(i => [`${i.namespace}/${i.name}`, i])).values()];\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\t// Bitbucket Cloud's legacy issues API is per-repo only — there is no account-wide search endpoint to\n\t\t// call, so an unscoped read can't be served. Returning undefined here would be indistinguishable from a\n\t\t// genuinely empty account; throw so the caller can surface this as a warning instead.\n\t\tif (repos == null || repos.length === 0) {\n\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\tthis.name,\n\t\t\t\t'there is no account-wide issue search — open a repository to list its issues.',\n\t\t\t);\n\t\t}\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.username == null) return undefined;\n\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (!api) return undefined;\n\n\t\tconst issueResult = await flatSettled(\n\t\t\trepos.map(repo => {\n\t\t\t\treturn api.getUsersIssuesForRepo(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\tuser.id,\n\t\t\t\t\trepo.owner,\n\t\t\t\t\trepo.name,\n\t\t\t\t\tthis.apiBaseUrl,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\treturn issueResult;\n\t}\n\n\t/**\n\t * Bitbucket is not an issue provider on the ProviderBackend surface: Bitbucket Cloud deprecated its issue\n\t * tracker in favor of dedicated issue integrations (e.g. Jira). The legacy per-repo `getUsersIssuesForRepo`\n\t * client is retained only for autolink/hover enrichment, not for the ProviderBackend issue reads, so the\n\t * facade reports issues as unsupported rather than serving a deprecated, partial source.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountStorageKey = md5(this._session.accessToken);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\t\tconst storedWorkspaces = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:workspaces`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\n\n\t\tconst storedWorkspacesData = storedWorkspaces?.data as\n\t\t\t| ProviderApiCollectionResult<BitbucketWorkspaceDescriptor>\n\t\t\t| BitbucketWorkspaceDescriptor[]\n\t\t\t| undefined;\n\t\tlet workspaces: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined;\n\t\tif (\n\t\t\t!Array.isArray(storedWorkspacesData) &&\n\t\t\tArray.isArray(storedWorkspacesData?.values) &&\n\t\t\t(storedWorkspacesData.metadata == null || storedWorkspacesData.metadata.completeness === 'complete')\n\t\t) {\n\t\t\tworkspaces = {\n\t\t\t\tvalues: storedWorkspacesData.values.map((o: BitbucketWorkspaceDescriptor) => ({ ...o })),\n\t\t\t\t...(storedWorkspacesData.metadata != null ? { metadata: storedWorkspacesData.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\tif (storedAccount == null) {\n\t\t\taccount = await this.getProviderCurrentAccount(this._session);\n\t\t\tif (account != null) {\n\t\t\t\t// Clear all other stored workspaces and repositories and accounts when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix(this.storagePrefix);\n\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:account`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tid: account.id,\n\t\t\t\t\t\tname: account.name,\n\t\t\t\t\t\temail: account.email,\n\t\t\t\t\t\tavatarUrl: account.avatarUrl,\n\t\t\t\t\t\tusername: account.username,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\t\tthis._accounts.set(this._session.accessToken, account);\n\n\t\tif (workspaces == null) {\n\t\t\tconst discovered = await this.getProviderResourcesForCurrentUser(this._session, true);\n\t\t\tif (discovered?.metadata == null || discovered.metadata.completeness === 'complete') {\n\t\t\t\tworkspaces = discovered;\n\t\t\t\tif (workspaces != null) {\n\t\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:workspaces`, {\n\t\t\t\t\t\tv: 2,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\tdata: workspaces,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (workspaces != null) {\n\t\t\tthis._workspaces ??= new Map<\n\t\t\t\tstring,\n\t\t\t\tProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined\n\t\t\t>();\n\t\t\tthis._workspaces.set(this._session.accessToken, workspaces);\n\t\t}\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._accounts = undefined;\n\t\tthis._workspaces = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiEA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAE/E,IAAa,uBAAb,cAA0C,mBAGxC;CACD,eAAqE;CACrE,KAAS;CACT,MAAyB,KAAK;CAC9B,OAAwB;CACxB,IAAI,SAA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D;EACA,IAAI,cAAc,MAAM;GACvB,KAAK,gCAAgB,IAAI,IAGvB;GACF,KAAK,YAAY,IAAI,KAAK,SAAS,aAAa,UAAU;EAC3D;CACD;CAEA,uBAAgD;EAC/C,KAAK,YAAY,KAAA;EACjB,KAAK,cAAc,KAAA;CACpB;AACD"}
|
|
1
|
+
{"version":3,"file":"bitbucket.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport { uniqueBy } from '@gitlens/utils/iterable.js';\nimport { batchResults, flatSettled, mapSettledBounded, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport type { ProviderRefusal } from '../collectionMetadata.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitCloudHostIntegrationId } from '../constants.js';\nimport { IntegrationReadUnavailableError } from '../errors.js';\nimport type { BitbucketPullRequestCreateCapabilityOptions } from '../models/bitbucketPullRequestWrites.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/publicIntegration.js';\nimport type { PullRequestEtagFields, PullRequestEtagInclude } from '../reads/etag.js';\nimport {\n\tBitbucketCommitLinksAppMissingError,\n\tBitbucketCommitNotFoundError,\n\tBitbucketCommitPullRequestsUnindexedError,\n} from './bitbucket/bitbucket.js';\nimport { getBitbucketPullRequestIdentityFromMaybeUrl } from './bitbucket/bitbucket.utils.js';\nimport type { BitbucketRepositoryDescriptor, BitbucketWorkspaceDescriptor } from './bitbucket/models.js';\nimport { bitbucketEtagFieldsMaxIds, toBitbucketPullRequestEtagFields } from './bitbucket/models.js';\nimport { BitbucketPullRequestWriteLedger } from './bitbucketPullRequestWriteLedger.js';\nimport type { BitbucketPullRequestWriter } from './bitbucketPullRequestWrites.js';\nimport { providersMetadata } from './metadata.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderApiPagedResult,\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tmergeCollectionMetadata,\n\tparsePageCursor,\n\tproviderFanOutConcurrency,\n\treadEtagFieldsByRepository,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitCloudHostIntegrationId.Bitbucket];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketIntegration extends GitHostIntegration<\n\tGitCloudHostIntegrationId.Bitbucket,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitCloudHostIntegrationId.Bitbucket;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Bitbucket';\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.bitbucket.org/2.0';\n\t}\n\n\tprivate readonly pullRequestWriteLedger = new BitbucketPullRequestWriteLedger();\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\tmergeMethod: options?.mergeMethod,\n\t\t});\n\t}\n\n\tasync getPullRequestWriter(\n\t\toptions: BitbucketPullRequestCreateCapabilityOptions,\n\t): Promise<BitbucketPullRequestWriter | undefined> {\n\t\tconst session = await this.resolveReadSessionOrThrow(options.connectionId, undefined);\n\t\tif (session?.id !== options.connectionId || !session.accessToken) return undefined;\n\n\t\tconst isSessionCurrent = this.trackWriteSession(session);\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketPullRequestWriter(options, session, isSessionCurrent, this.pullRequestWriteLedger);\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSessionOrThrow(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tbaseUrl: this.apiBaseUrl,\n\t\t});\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\tavatarSize: options?.avatarSize,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_email: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getDefaultBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssueOrPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\ttype: type,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot:\n\t * provider-apis has no single pull request read for Bitbucket, so this uses our own.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, c =>\n\t\t\tapi.getPullRequest(this, tokenWithInfo, c.owner, c.repo, String(c.number), this.apiBaseUrl, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tdeferFailure: true,\n\t\t\t\tprojection: 'batch',\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * The cheap check behind the batch pull request read's etags: GitLens' own client lists each repository's pull\n\t * requests by id, up to {@link bitbucketEtagFieldsMaxIds} in ONE request, where\n\t * {@link getProviderPullRequestsBatch} sends one per target, and selects only the fields its rows' etags read.\n\t * Each is converted as {@link fromBitbucketPullRequest} converts the full one, so both reads compute the same\n\t * etag. A request that throws rejects only its own targets' slots.\n\t *\n\t * The full row reads neither a mergeability nor a check rollup, so its etag sees a pull request's state, draft\n\t * flag, update time and head commit, plus its participants' review decision when included; the `mergeable` and\n\t * `checks` includes add nothing and cost nothing.\n\t */\n\tprotected override async getProviderPullRequestsEtagFields(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { etagIncludes?: readonly PullRequestEtagInclude[] },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestEtagFields | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst etagIncludes = options.etagIncludes ?? [];\n\n\t\treturn readEtagFieldsByRepository(\n\t\t\tcoordinates,\n\t\t\tbitbucketEtagFieldsMaxIds,\n\t\t\t(owner, repo, ids) =>\n\t\t\t\tapi.getPullRequestsEtagFields(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\towner,\n\t\t\t\t\trepo,\n\t\t\t\t\tids,\n\t\t\t\t\tthis.apiBaseUrl,\n\t\t\t\t\t{ etagIncludes: etagIncludes, deferFailure: true },\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\tnode => toBitbucketPullRequestEtagFields(node, etagIncludes),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently, through our own client: provider-apis' pull request list has\n\t * no source-branch filter.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(targets, providerFanOutConcurrency, t =>\n\t\t\tapi.getPullRequestsForBranch(this, tokenWithInfo, t.owner, t.repo, t.branch, this.apiBaseUrl, {\n\t\t\t\theadOwner: t.headOwner,\n\t\t\t\tlimit: options.limit,\n\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\tdeferFailure: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssue(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tbranch: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestsForCommits(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: { owner: string; repo: string; project?: string },\n\t\tshas: readonly string[],\n\t\toptions: { mergeQueue?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst slots = await super.getProviderPullRequestsForCommits(session, repo, shas, options, cancellation);\n\t\tif (slots == null) return undefined;\n\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tconst missing = slots.find(\n\t\t\t(slot): slot is PromiseRejectedResult & { reason: BitbucketCommitLinksAppMissingError } =>\n\t\t\t\tslot.status === 'rejected' && slot.reason instanceof BitbucketCommitLinksAppMissingError,\n\t\t);\n\t\tif (missing != null) {\n\t\t\tapi?.notifyCommitLinksAppMissing(repo.owner, missing.reason.commitUrl);\n\t\t}\n\n\t\tconst indexed =\n\t\t\tslots.some(slot => slot.status === 'fulfilled') ||\n\t\t\tapi?.isRepositoryIndexed(toTokenWithInfo(this.id, session), repo.owner, repo.repo) === true;\n\t\tif (!indexed) return slots;\n\n\t\treturn slots.map((slot): PromiseSettledResult<PullRequestShape | undefined> =>\n\t\t\tslot.status === 'rejected' && slot.reason instanceof BitbucketCommitNotFoundError\n\t\t\t\t? { status: 'fulfilled', value: undefined }\n\t\t\t\t: slot,\n\t\t);\n\t}\n\n\tprotected override getCommitLookupBackoff(\n\t\tex: unknown,\n\t): { scope: 'repository' | 'commit'; until?: number } | undefined {\n\t\tif (\n\t\t\tex instanceof BitbucketCommitLinksAppMissingError ||\n\t\t\tex instanceof BitbucketCommitPullRequestsUnindexedError\n\t\t) {\n\t\t\treturn { scope: 'repository' };\n\t\t}\n\n\t\treturn super.getCommitLookupBackoff(ex);\n\t}\n\n\tprotected override stopsCommitFanOut(reason: unknown, answered: boolean): boolean {\n\t\treturn (\n\t\t\treason instanceof BitbucketCommitLinksAppMissingError ||\n\t\t\treason instanceof BitbucketCommitPullRequestsUnindexedError ||\n\t\t\tsuper.stopsCommitFanOut(reason, answered)\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestForCommitInBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\treturn this.readPullRequestForCommit(session, repo, rev, true, cancellation);\n\t}\n\n\tprotected override getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn this.readPullRequestForCommit(session, repo, rev, false);\n\t}\n\n\tprivate async readPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\tdeferFailure: boolean,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) {\n\t\t\tthrow new IntegrationReadUnavailableError(this.name, 'no client to read the pull requests of a commit');\n\t\t}\n\n\t\treturn api.getPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{ deferFailure: deferFailure },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{ projection: 'point' },\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getBitbucketPullRequestIdentityFromMaybeUrl(search, this.id);\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getRepositoryMetadata(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst { accessToken } = session;\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(accessToken);\n\t\tif (cachedAccount == null) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst user = await api.getCurrentUser(toTokenWithInfo(this.id, session));\n\t\t\tthis._accounts.set(\n\t\t\t\taccessToken,\n\t\t\t\tuser\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: user.id,\n\t\t\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t\t\t\t\t\tusername: user.username ?? undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t}\n\n\t\treturn this._accounts.get(accessToken);\n\t}\n\n\t/** The profile request the account cache would otherwise answer; see `IntegrationBase.validateCredential`. */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif ((await api.getCurrentUser(toTokenWithInfo(this.id, session))) == null) {\n\t\t\tthrow new Error('Bitbucket did not confirm the credential');\n\t\t}\n\t}\n\n\t/**\n\t * Bitbucket's `403` for a token missing the OAuth scopes a request needs, which a reconnect fixes by consenting to\n\t * them again; see `IntegrationBase.isCredentialRefusal`.\n\t */\n\tprotected override isCredentialRefusal(refusal: ProviderRefusal): boolean {\n\t\treturn refusal.status === 403 && /required privilege scopes/i.test(refusal.detail ?? '');\n\t}\n\n\tprivate _workspaces: Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> | undefined;\n\tprivate async getProviderResourcesForCurrentUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> {\n\t\tthis._workspaces ??= new Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined>();\n\t\tconst { accessToken } = session;\n\t\tconst cachedResources = this._workspaces.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getBitbucketResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (resources == null) return undefined;\n\n\t\tconst values = resources.values.map(r => ({ ...r, key: r.id, name: r.name ?? r.slug }));\n\t\tconst metadata = mergeCollectionMetadata(\n\t\t\tresources.metadata,\n\t\t\tresources.paging?.truncated === true ? { completeness: 'partial' } : undefined,\n\t\t);\n\t\tconst result: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> = {\n\t\t\tvalues: values,\n\t\t\t...(metadata != null ? { metadata: metadata } : {}),\n\t\t};\n\n\t\t// A partial workspace prefix is useful to the current read but must not become authoritative cache state:\n\t\t// a transient page-2 failure must be retried on the next call rather than hiding every later workspace\n\t\t// until disconnect.\n\t\tif (metadata == null || metadata.completeness === 'complete') {\n\t\t\tthis._workspaces.set(accessToken, result);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization> | undefined> {\n\t\tconst workspaces = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspaces == null) return undefined;\n\n\t\treturn {\n\t\t\tvalues: workspaces.values.map(w => ({\n\t\t\t\tid: w.id,\n\t\t\t\tproviderId: this.id,\n\t\t\t\tname: w.slug,\n\t\t\t\turl: `https://bitbucket.org/${w.slug}`,\n\t\t\t})),\n\t\t\t...(workspaces.metadata != null ? { metadata: workspaces.metadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), org, {\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (repos != null) {\n\t\t\t// TODO: implement repos version\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst state = options?.state;\n\t\tconst states = toProviderPullRequestStates(state);\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\t// `user.id` feeds both the authored workspace reads and the reviewer BBQL clause; guard on it so we\n\t\t// never issue requests/queries with an undefined uuid. `username` isn't used here, so don't gate on it.\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) return [];\n\n\t\tconst authoredPrs = workspaces.map(async ws => {\n\t\t\tconst prs = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\tuser.id,\n\t\t\t\tws.slug,\n\t\t\t\t{ states: states },\n\t\t\t);\n\t\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' }));\n\t\t});\n\n\t\tif (!options?.includeReviewRequested) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\t// Bitbucket's reviewing PRs require a repo-scoped BBQL query; keep that sweep opt-in so the default\n\t\t// \"my pull requests\" feed stays aligned with backends that only expose authored PRs.\n\t\tconst stateClause =\n\t\t\tstate === 'closed'\n\t\t\t\t? '(state=\"DECLINED\" OR state=\"SUPERSEDED\")'\n\t\t\t\t: state === 'merged'\n\t\t\t\t\t? 'state=\"MERGED\"'\n\t\t\t\t\t: state === 'all'\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: 'state=\"OPEN\"';\n\n\t\tconst workspaceRepos = await this.getWorkspaceRepoInputs();\n\t\tif (workspaceRepos.length === 0) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\tconst reviewerClause = `reviewers.uuid=\"${user.id}\"`;\n\t\tconst reviewingPrs = api\n\t\t\t.getPullRequestsForRepos(toTokenWithInfo(this.id, session), workspaceRepos, {\n\t\t\t\tquery: stateClause ? `${stateClause} AND ${reviewerClause}` : reviewerClause,\n\t\t\t})\n\t\t\t.then(r => r.values?.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' })));\n\n\t\treturn [\n\t\t\t...uniqueBy(\n\t\t\t\tawait flatSettled([...authoredPrs, reviewingPrs]),\n\t\t\t\tpr => pr.url,\n\t\t\t\t(orig, _cur) => orig,\n\t\t\t),\n\t\t];\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: {\n\t\t\tstate?: PullRequestStateFilter[];\n\t\t\tcursor?: string;\n\t\t\tincludeReviewRequested?: boolean;\n\t\t\tfilters?: PullRequestFilter[];\n\t\t},\n\t): Promise<ProviderApiPagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) {\n\t\t\tconst incomplete =\n\t\t\t\tworkspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t\treturn {\n\t\t\t\tvalues: [],\n\t\t\t\tpaging: { cursor: '{}', more: false, truncated: incomplete || undefined },\n\t\t\t\t...(workspacesResult.metadata != null ? { metadata: workspacesResult.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\t// Account-wide \"my PRs\" for Bitbucket = the user's authored PRs across every workspace they belong to,\n\t\t// plus the PRs they've been requested to review. Bitbucket's cross-workspace read is per-workspace and\n\t\t// numbered-page, so drain each workspace fully (bounded by a defensive backstop) and concatenate.\n\t\t// There's no single cross-workspace cursor, so the aggregate is one page; `truncated` is set when a\n\t\t// workspace hit the backstop with more pages left, or when a workspace's read was dropped by a failure.\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\tconst requested = options?.filters?.length ? new Set(options.filters) : undefined;\n\t\tconst wantAuthored = requested == null || requested.has(PullRequestFilter.Author);\n\t\tconst wantReviewRequested =\n\t\t\trequested?.has(PullRequestFilter.ReviewRequested) ?? options?.includeReviewRequested === true;\n\t\tconst maxPagesPerWorkspace = 20;\n\t\tlet truncated = workspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t// Structured per-scope failures from BOTH the authored and reviewer slices. A rejected scope is recorded\n\t\t// here (never re-thrown) so successful sibling workspaces/repos survive and the ProviderBackend facade\n\t\t// maps each failure to an actionable warning + `fetchFailed` (auth/rate-limit failures still drive\n\t\t// recovery through their warning kind, matching the SDK's own collect-across-scopes model).\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tlet aggregateMetadata = workspacesResult.metadata;\n\t\tconst absorbCollectionResult = (result: ProviderHierarchyResult<unknown>): void => {\n\t\t\taggregateMetadata = mergeCollectionMetadata(aggregateMetadata, result.metadata);\n\t\t\tif (result.truncated || (result.metadata != null && result.metadata.completeness !== 'complete')) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t};\n\t\tconst settled = wantAuthored\n\t\t\t? await Promise.allSettled(\n\t\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\t\treturn collectProviderPagedResult(\n\t\t\t\t\t\t\tasync cursor => {\n\t\t\t\t\t\t\t\tconst result = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\tuser.id,\n\t\t\t\t\t\t\t\t\tws.slug,\n\t\t\t\t\t\t\t\t\t{ states: states, page: parsePageCursor(cursor) },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result == null) return undefined;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tvalues: result.data,\n\t\t\t\t\t\t\t\t\tpaging: {\n\t\t\t\t\t\t\t\t\t\tmore: result.hasMore,\n\t\t\t\t\t\t\t\t\t\tcursor:\n\t\t\t\t\t\t\t\t\t\t\tresult.hasMore && result.nextPage != null\n\t\t\t\t\t\t\t\t\t\t\t\t? toPageCursor(result.nextPage)\n\t\t\t\t\t\t\t\t\t\t\t\t: '{}',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmaxPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: [];\n\n\t\tconst prsByIdentity = new Map<string, ProviderPullRequest>();\n\t\tlet unkeyedPullRequest = 0;\n\t\tconst addPullRequest = (pr: ProviderPullRequest): void => {\n\t\t\tconst key = getProviderPullRequestIdentity(pr) ?? `unkeyed:${unkeyedPullRequest++}`;\n\t\t\tif (!prsByIdentity.has(key)) {\n\t\t\t\tprsByIdentity.set(key, pr);\n\t\t\t}\n\t\t};\n\t\t// `allSettled` preserves order, so `settled[i]` is `workspaces[i]`. A rejected workspace becomes a\n\t\t// structured failure (attributed to its slug) instead of a generic truncation or a re-throw, preserving\n\t\t// every sibling workspace's authored PRs.\n\t\tsettled.forEach((outcome, i) => {\n\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\tfailures.push(this.toWorkspaceFailure(workspaces[i].slug, outcome.reason));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tabsorbCollectionResult(outcome.value);\n\t\t\tfor (const pr of outcome.value.values) {\n\t\t\t\taddPullRequest(pr);\n\t\t\t}\n\t\t});\n\n\t\t// Bitbucket's account-wide (per-workspace) endpoint returns authored PRs only, and the SDK exposes no\n\t\t// workspace-level reviewer query — only a repo-scoped one. Adding the reviewer slice therefore requires\n\t\t// draining every workspace's full repo list and then a per-repo `getPullRequestsForRepo` with `reviewerId`\n\t\t// (O(workspaces × repos) requests), so keep it opt-in: gate it on `includeReviewRequested` so the default\n\t\t// sweep matches the gkcli baseline (authored PRs only, no reviewer fan-out) and a caller pays that cost\n\t\t// only when it deliberately asks for review-requested PRs.\n\t\tif (wantReviewRequested) {\n\t\t\t// Enumerate the account's repos by draining each resolved workspace's repository list, then drain the\n\t\t\t// real per-repo paged `getPullRequestsForRepo` for each repo with `reviewerId`, so review-requested PRs\n\t\t\t// aren't bounded to the currently-open remotes and a reviewer PR past the first page isn't dropped.\n\t\t\t// Structured per-scope failures are collected as CollectionScopeFailure so the ProviderBackend facade\n\t\t\t// maps them to actionable warnings (Step 3).\n\t\t\tconst maxReposPagesPerWorkspace = 20;\n\t\t\tconst maxPrPagesPerRepo = 20;\n\t\t\t// Bound concurrency: workspaces are few, so process them concurrently, but drain each workspace's repos\n\t\t\t// in a bounded batch rather than an unbounded Promise.all over every repo in every workspace.\n\t\t\tconst repoBatchSize = 5;\n\n\t\t\tawait Promise.all(\n\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\tlet repos: ProviderRepository[];\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst discovered = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), ws.slug, {\n\t\t\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmaxReposPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t\trepos = discovered.values;\n\t\t\t\t\t\tabsorbCollectionResult(discovered);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Record the workspace as a structured failure and keep going: the failure metadata drives\n\t\t\t\t\t\t// the warning + `fetchFailed` + incompleteness for every kind (auth/rate-limit stay\n\t\t\t\t\t\t// actionable via their warning kind), so sibling workspaces' repos are still drained.\n\t\t\t\t\t\tfailures.push(this.toWorkspaceFailure(ws.slug, ex));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst drained = await batchResults(repos, repoBatchSize, async repo => {\n\t\t\t\t\t\tconst reviewing = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getPullRequestsForRepo(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\t{ namespace: repo.namespace, name: repo.name },\n\t\t\t\t\t\t\t\t\t{ reviewerId: user.id, states: states, cursor: cursor },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tmaxPrPagesPerRepo,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tproviderId: this.id,\n\t\t\t\t\t\t\t\tresourceId: ws.slug,\n\t\t\t\t\t\t\t\trepositoryId: `${repo.namespace}/${repo.name}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn { repo: repo, reviewing: reviewing };\n\t\t\t\t\t});\n\n\t\t\t\t\tfor (let i = 0; i < drained.length; i++) {\n\t\t\t\t\t\tconst outcome = drained[i];\n\t\t\t\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\t\t\t\tconst repo = repos[i];\n\t\t\t\t\t\t\tfailures.push(\n\t\t\t\t\t\t\t\tthis.toRepositoryFailure(\n\t\t\t\t\t\t\t\t\t`${repo?.namespace ?? ws.slug}/${repo?.name ?? 'unknown'}`,\n\t\t\t\t\t\t\t\t\toutcome.reason,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst { reviewing } = outcome.value;\n\t\t\t\t\t\tabsorbCollectionResult(reviewing);\n\t\t\t\t\t\tfor (const pr of reviewing.values) {\n\t\t\t\t\t\t\taddPullRequest(pr);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Every slice that ran (authored workspaces always, reviewer workspaces/repos when opted in) records its\n\t\t// per-scope rejections as structured failures instead of re-throwing: re-throwing would discard every\n\t\t// successful sibling's PRs. Auth/rate-limit failures stay actionable through the metadata (the facade maps\n\t\t// kind `authentication` → an `auth` warning, `rate-limit` → a `rate-limit` warning) while the survivors are\n\t\t// returned with `fetchFailed`.\n\t\tconst metadata: CollectionMetadata | undefined = mergeCollectionMetadata(\n\t\t\tfailures.length > 0 ? { completeness: 'partial', failures: failures } : undefined,\n\t\t\taggregateMetadata,\n\t\t);\n\n\t\treturn {\n\t\t\tvalues: [...prsByIdentity.values()],\n\t\t\tpaging: { cursor: '{}', more: false, truncated: truncated || undefined },\n\t\t\tmetadata: metadata,\n\t\t};\n\t}\n\n\t/** Classifies a caught workspace-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toWorkspaceFailure(workspaceSlug: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, resourceId: workspaceSlug }, ex);\n\t}\n\n\t/** Classifies a caught repository-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toRepositoryFailure(repositoryId: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, repositoryId: repositoryId }, ex);\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) return undefined;\n\n\t\tconst workspaceRepos =\n\t\t\trepos != null\n\t\t\t\t? repos.map(r => ({ name: r.name, namespace: r.owner }))\n\t\t\t\t: await this.getWorkspaceRepoInputs();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t// An explicitly-empty `repos` means \"search these zero repos\" -> no results; reserve `undefined`\n\t\t// (\"scope couldn't be determined\") for when no repos were requested and none were discovered.\n\t\tif (workspaceRepos.length === 0) return repos != null ? [] : undefined;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderPullRequestStates(options?.include);\n\t\tconst providerPullRequests = await flatSettledOrThrow(\n\t\t\tworkspaceRepos.map(async repo => {\n\t\t\t\tconst result = await collectProviderPagedResult(cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\treturn api.getPullRequestsForRepo(token, repo, {\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tquery: searchQuery,\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn result.values;\n\t\t\t}),\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn providerPullRequests.map(pr => fromProviderPullRequest(pr, this, { projection: 'text-search' }));\n\t}\n\n\tprivate async getWorkspaceRepoInputs(): Promise<{ name: string; namespace: string }[]> {\n\t\tconst remotes = await this.ctx.repositories.getOpenRemotes();\n\t\tconst inputs = await nonnullSettled(\n\t\t\tremotes.map(async (r: GitRemote) => {\n\t\t\t\tconst integration = await this.authenticationService.getByRemote(r);\n\t\t\t\tif (integration !== this) return undefined;\n\n\t\t\t\t// Use the remote provider's parsing rather than splitting `r.path`, so adornments like a\n\t\t\t\t// trailing `.git` or extra path segments don't leak into the namespace/name.\n\t\t\t\tconst namespace = r.provider?.owner;\n\t\t\t\tconst name = r.provider?.repoName;\n\t\t\t\treturn namespace != null && name != null ? { name: name, namespace: namespace } : undefined;\n\t\t\t}),\n\t\t);\n\t\t// Dedupe: a repo with multiple remotes (e.g. `origin` + `upstream`) can map to the same input,\n\t\t// which would otherwise fetch and return the same PRs more than once.\n\t\treturn [...new Map(inputs.map(i => [`${i.namespace}/${i.name}`, i])).values()];\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\t// Bitbucket Cloud's legacy issues API is per-repo only — there is no account-wide search endpoint to\n\t\t// call, so an unscoped read can't be served. Returning undefined here would be indistinguishable from a\n\t\t// genuinely empty account; throw so the caller can surface this as a warning instead.\n\t\tif (repos == null || repos.length === 0) {\n\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\tthis.name,\n\t\t\t\t'there is no account-wide issue search — open a repository to list its issues.',\n\t\t\t);\n\t\t}\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.username == null) return undefined;\n\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (!api) return undefined;\n\n\t\tconst issueResult = await flatSettled(\n\t\t\trepos.map(repo => {\n\t\t\t\treturn api.getUsersIssuesForRepo(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\tuser.id,\n\t\t\t\t\trepo.owner,\n\t\t\t\t\trepo.name,\n\t\t\t\t\tthis.apiBaseUrl,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\treturn issueResult;\n\t}\n\n\t/**\n\t * Bitbucket is not an issue provider on the ProviderBackend surface: Bitbucket Cloud deprecated its issue\n\t * tracker in favor of dedicated issue integrations (e.g. Jira). The legacy per-repo `getUsersIssuesForRepo`\n\t * client is retained only for autolink/hover enrichment, not for the ProviderBackend issue reads, so the\n\t * facade reports issues as unsupported rather than serving a deprecated, partial source.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountStorageKey = md5(this._session.accessToken);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\t\tconst storedWorkspaces = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:workspaces`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\n\n\t\tconst storedWorkspacesData = storedWorkspaces?.data as\n\t\t\t| ProviderApiCollectionResult<BitbucketWorkspaceDescriptor>\n\t\t\t| BitbucketWorkspaceDescriptor[]\n\t\t\t| undefined;\n\t\tlet workspaces: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined;\n\t\tif (\n\t\t\t!Array.isArray(storedWorkspacesData) &&\n\t\t\tArray.isArray(storedWorkspacesData?.values) &&\n\t\t\t(storedWorkspacesData.metadata == null || storedWorkspacesData.metadata.completeness === 'complete')\n\t\t) {\n\t\t\tworkspaces = {\n\t\t\t\tvalues: storedWorkspacesData.values.map((o: BitbucketWorkspaceDescriptor) => ({ ...o })),\n\t\t\t\t...(storedWorkspacesData.metadata != null ? { metadata: storedWorkspacesData.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\tif (storedAccount == null) {\n\t\t\taccount = await this.getProviderCurrentAccount(this._session);\n\t\t\tif (account != null) {\n\t\t\t\t// Clear all other stored workspaces and repositories and accounts when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix(this.storagePrefix);\n\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:account`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tid: account.id,\n\t\t\t\t\t\tname: account.name,\n\t\t\t\t\t\temail: account.email,\n\t\t\t\t\t\tavatarUrl: account.avatarUrl,\n\t\t\t\t\t\tusername: account.username,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\t\tthis._accounts.set(this._session.accessToken, account);\n\n\t\tif (workspaces == null) {\n\t\t\tconst discovered = await this.getProviderResourcesForCurrentUser(this._session, true);\n\t\t\tif (discovered?.metadata == null || discovered.metadata.completeness === 'complete') {\n\t\t\t\tworkspaces = discovered;\n\t\t\t\tif (workspaces != null) {\n\t\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:workspaces`, {\n\t\t\t\t\t\tv: 2,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\tdata: workspaces,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (workspaces != null) {\n\t\t\tthis._workspaces ??= new Map<\n\t\t\t\tstring,\n\t\t\t\tProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined\n\t\t\t>();\n\t\t\tthis._workspaces.set(this._session.accessToken, workspaces);\n\t\t}\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._accounts = undefined;\n\t\tthis._workspaces = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoEA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAE/E,IAAa,uBAAb,cAA0C,mBAGxC;CACD,eAAqE;CACrE,KAAS;CACT,MAAyB,KAAK;CAC9B,OAAwB;CACxB,IAAI,SAAiB;EACpB,OAAO,SAAS;CACjB;CAEA,IAAc,aAAqB;EAClC,OAAO;CACR;CAEA,yBAA0C,IAAI,gCAAgC;CAE9E,MAAyB,yBACxB,SACA,IACA,SAGmB;EAEnB,QAAO,MADW,KAAK,gBAAgB,EAAA,CAC5B,iBAA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c,MACjB,MAAM,KAAK,IAAI,QAAQ,MAAM,GAAG,KAAK,cAAc,GAAG,kBAAkB,cAAc;KACrF,GAAG;KACH,WAAW,KAAK,IAAI;KACpB,MAAM;IACP,CAAC;GAEH;EACD;EACA,IAAI,cAAc,MAAM;GACvB,KAAK,gCAAgB,IAAI,IAGvB;GACF,KAAK,YAAY,IAAI,KAAK,SAAS,aAAa,UAAU;EAC3D;CACD;CAEA,uBAAgD;EAC/C,KAAK,YAAY,KAAA;EACjB,KAAK,cAAc,KAAA;CACpB;AACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BitbucketPullRequestWriteFailure } from "../models/bitbucketPullRequestWrites.js";
|
|
2
|
+
//#region ../plus/integrations/src/providers/bitbucketPullRequestWriteErrors.d.ts
|
|
3
|
+
type FailureReason = BitbucketPullRequestWriteFailure['reason'];
|
|
4
|
+
export declare class BitbucketPullRequestWriteError extends Error {
|
|
5
|
+
readonly reason: FailureReason;
|
|
6
|
+
constructor(reason: FailureReason);
|
|
7
|
+
}
|
|
8
|
+
export declare function toBitbucketPullRequestWriteFailure(ex: unknown, dispatched?: {
|
|
9
|
+
action: 'create' | 'edit' | 'decline' | 'merge';
|
|
10
|
+
}): BitbucketPullRequestWriteFailure;
|
|
11
|
+
export declare function getBitbucketMergeRefusal(ex: unknown): FailureReason | undefined;
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=bitbucketPullRequestWriteErrors.d.ts.map
|