@gitkraken/core-gitlens 0.49.0 → 0.50.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 +8 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +3 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.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 +9 -0
- package/dist/plus/integrations/integrationService.js +43 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +6 -0
- package/dist/plus/integrations/models/workItemWrites.d.ts +136 -0
- package/dist/plus/integrations/models/workItemWrites.js +0 -0
- package/dist/plus/integrations/providers/azure/workItemWriteMetadata.d.ts +38 -0
- package/dist/plus/integrations/providers/azure/workItemWriteMetadata.js +73 -0
- package/dist/plus/integrations/providers/azure/workItemWriteMetadata.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +3 -0
- package/dist/plus/integrations/providers/azureDevOps.js +12 -1
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.d.ts +17 -0
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +100 -0
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/azureWorkItemWrites.d.ts +38 -0
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +442 -0
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.d.ts +4 -1
- package/dist/plus/integrations/providers/providersApi.js +7 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/docs/integrations.md +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureWorkItemWrites.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureWorkItemWrites.ts"],"sourcesContent":["import type {\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\tWorkItemWriteScope,\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\tisGuid,\n\tisWorkItemIdentifier,\n\tisWorkItemNumber,\n\ttoWorkItemWriteFailure,\n\tWorkItemWriteError,\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 azureProfileApi = 'https://app.vssps.visualstudio.com/_apis';\nconst projectSecurityNamespaceId = '52d39943-cb85-4d7f-8fa8-c6baac873819';\n\nfunction sameIdentifier(actual: unknown, expected: string): boolean {\n\treturn typeof actual === 'string' && actual.toLowerCase() === expected.toLowerCase();\n}\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) || !isWorkItemIdentifier(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) && isWorkItemNumber(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 (!isWorkItemNumber(address.workItemId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertMutationIdentity(expectedAccountId: string): void {\n\tif (!isWorkItemIdentifier(expectedAccountId)) throw new WorkItemWriteError('invalid-input');\n}\n\nfunction assertSameRevision(item: AzureWorkItem, expectedRevision: number): void {\n\tif (!isWorkItemNumber(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\nexport class AzureWorkItemWriter {\n\tstatic async connect(\n\t\trequest: ProviderRequestFunction,\n\t\tcredential: { accessToken: string; authorization: string },\n\t\toptions: WorkItemWriteScope,\n\t\tisSessionCurrent: () => Promise<boolean>,\n\t): Promise<AzureWorkItemWriter> {\n\t\tconst { body: profile } = await request<{ id?: string }>({\n\t\t\turl: `${azureProfileApi}/profile/profiles/me`,\n\t\t\theaders: { Authorization: `Bearer ${credential.accessToken}` },\n\t\t\tredirect: 'error',\n\t\t});\n\t\tconst accountId = profile?.id;\n\t\tif (\n\t\t\t!isWorkItemIdentifier(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 request<{ value?: { accountId: string; accountName: string }[] }>({\n\t\t\turl: `${azureProfileApi}/accounts?memberId=${encodeURIComponent(accountId)}&api-version=7.1`,\n\t\t\theaders: headers,\n\t\t\tredirect: 'error',\n\t\t});\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 { body: project } = await request<{ id: string; name: string }>({\n\t\t\turl: `${organizationUrl}/_apis/projects/${options.projectId}?api-version=7.1`,\n\t\t\theaders: headers,\n\t\t\tredirect: 'error',\n\t\t});\n\t\tif (!sameIdentifier(project?.id, options.projectId) || !isWorkItemIdentifier(project?.name)) {\n\t\t\tthrow new WorkItemWriteError('not-found');\n\t\t}\n\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: { id: project.id, name: project.name },\n\t\t\t},\n\t\t\torganizationUrl,\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 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 => isWorkItemIdentifier(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\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\tisGuid(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\tisGuid(project?.id) &&\n\t\t\t\tisWorkItemIdentifier(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 (!isWorkItemNumber(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 (!isWorkItemIdentifier(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) || !isWorkItemIdentifier(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(await this.read<{ value?: WorkItemState[] }>(`${path}/states`));\n\t\tif (states.some(state => !isWorkItemIdentifier(state?.name) || !isWorkItemIdentifier(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 (!isWorkItemIdentifier(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!isWorkItemNumber(item.id) ||\n\t\t\t!isWorkItemNumber(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': '7.1', ...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\treturn toWorkItemWriteFailure(ex, { fields: metadata.fields });\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAyDA,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AAEnC,SAAS,eAAe,QAAiB,UAA2B;CACnE,OAAO,OAAO,WAAW,YAAY,OAAO,YAAY,MAAM,SAAS,YAAY;AACpF;AAEA,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,qBAAqB,KAAK,OAAO,GAAG,OAAO;CAE1F,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,iBAAiB,SAAS,GAAG,IAAI,SAAS,MAAM,KAAA;AACzG;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,OAAO,KAAK,MAAM,MAAM,QAAQ,UAAU,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM;CAC7E,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAA;CAElC,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,MAAM,QAAQ,GAA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import { IssueSorting } from "../../../git/models/issue.js";
|
|
4
4
|
import { PullRequest, PullRequestFilter, PullRequestMergeMethod } from "../../../git/models/pullRequest.js";
|
|
5
|
-
import { TokenOptInfo, TokenWithInfo } from "../authentication/models.js";
|
|
5
|
+
import { ProviderAuthenticationSession, TokenOptInfo, TokenWithInfo } from "../authentication/models.js";
|
|
6
6
|
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId } from "../constants.js";
|
|
7
7
|
import { IssueTrackerWriteConnection } from "../models/issueTrackerWrites.js";
|
|
8
|
+
import { WorkItemWriteScope } from "../models/workItemWrites.js";
|
|
8
9
|
import { IssueFilter } from "../providerFilters.js";
|
|
9
10
|
import { ProviderOrganization } from "../results.js";
|
|
10
11
|
import { ProviderPullRequestCount, ProviderPullRequestSearchPage } from "../models/pullRequestReads.js";
|
|
11
12
|
import { AzurePullRequest, AzureWorkItemEtagRead } from "./azure/models.js";
|
|
12
13
|
import { AzureWorkItemStatesCache } from "./azure/workItemStateCategories.js";
|
|
13
14
|
import { AzureWorkItemDescriptionsCache } from "./azure/workItemDescriptions.js";
|
|
15
|
+
import { AzureWorkItemWriter } from "./azureWorkItemWrites.js";
|
|
14
16
|
import { countBitbucketServerPullRequests, searchBitbucketServerPullRequestsPage } from "./bitbucket-server/pullRequestSearch.js";
|
|
15
17
|
import { JiraIssueEtagResponse } from "./jiraIssueByKey.js";
|
|
16
18
|
import { JiraIssueWriter } from "./jiraIssueWrites.js";
|
|
@@ -179,6 +181,7 @@ export declare class ProvidersApi implements Disposable {
|
|
|
179
181
|
isPAT?: boolean;
|
|
180
182
|
baseUrl?: string;
|
|
181
183
|
}): Promise<ProviderAccount | undefined>;
|
|
184
|
+
getAzureWorkItemWriter(options: WorkItemWriteScope, session: ProviderAuthenticationSession, isSessionCurrent: () => Promise<boolean>): Promise<AzureWorkItemWriter>;
|
|
182
185
|
getJiraIssueWriter(options: IssueTrackerWriteConnection): Promise<JiraIssueWriter | undefined>;
|
|
183
186
|
getJiraResourcesForCurrentUser(tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Jira>): Promise<ProviderJiraResource[] | undefined>;
|
|
184
187
|
getLinearOrganization(tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Linear>): Promise<ProviderLinearOrganization | undefined>;
|
|
@@ -16,6 +16,7 @@ import { AzureWorkItemStatesCache, getAzureWorkItemTypeStatesUrl, getAzureWorkIt
|
|
|
16
16
|
import { requestJiraIssueByKey, requestJiraIssuesEtagFields } from "./jiraIssueByKey.js";
|
|
17
17
|
import { JiraIssueWriter } from "./jiraIssueWrites.js";
|
|
18
18
|
import { createProviderApiRequest } from "./providerApiClient.js";
|
|
19
|
+
import { AzureWorkItemWriter } from "./azureWorkItemWrites.js";
|
|
19
20
|
import { requestLinearIssuesEtagFields } from "./linearIssuesEtag.js";
|
|
20
21
|
import { requestBitbucketServerProjects, requestBitbucketServerRepositories } from "./bitbucket-server/discovery.js";
|
|
21
22
|
import { countBitbucketServerPullRequests, searchBitbucketServerPullRequestsPage } from "./bitbucket-server/pullRequestSearch.js";
|
|
@@ -796,6 +797,12 @@ var ProvidersApi = class {
|
|
|
796
797
|
return this.handleProviderError(tokenWithInfo, e);
|
|
797
798
|
}
|
|
798
799
|
}
|
|
800
|
+
getAzureWorkItemWriter(options, session, isSessionCurrent) {
|
|
801
|
+
return AzureWorkItemWriter.connect(this.request, {
|
|
802
|
+
accessToken: session.accessToken,
|
|
803
|
+
authorization: azureAuthorization(session.accessToken, true)
|
|
804
|
+
}, options, isSessionCurrent);
|
|
805
|
+
}
|
|
799
806
|
async getJiraIssueWriter(options) {
|
|
800
807
|
const provider = this.providers[options.providerId];
|
|
801
808
|
if (provider == null || provider.id !== options.providerId) return void 0;
|