@gitkraken/core-gitlens 0.50.0 → 0.51.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/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/integrations/index.d.ts +2 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +5 -0
- package/dist/plus/integrations/integrationService.js +40 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +4 -0
- package/dist/plus/integrations/models/azurePullRequestWrites.d.ts +93 -0
- package/dist/plus/integrations/models/azurePullRequestWrites.js +0 -0
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/azure/models.d.ts +1 -1
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/azure/writeIdentity.d.ts +17 -0
- package/dist/plus/integrations/providers/azure/writeIdentity.js +33 -0
- package/dist/plus/integrations/providers/azure/writeIdentity.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +4 -0
- package/dist/plus/integrations/providers/azureDevOps.js +14 -3
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azurePullRequestWriteErrors.d.ts +11 -0
- package/dist/plus/integrations/providers/azurePullRequestWriteErrors.js +72 -0
- package/dist/plus/integrations/providers/azurePullRequestWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/azurePullRequestWrites.d.ts +36 -0
- package/dist/plus/integrations/providers/azurePullRequestWrites.js +443 -0
- package/dist/plus/integrations/providers/azurePullRequestWrites.js.map +1 -0
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.d.ts +0 -3
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +3 -12
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +24 -35
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +3 -0
- package/dist/plus/integrations/providers/providersApi.js +8 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +53 -0
- package/package.json +1 -1
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { AnonymousResponseError, UnexpectedHtmlResponseError, getProviderResponseBodyMessage } from "./providerErrors.js";
|
|
2
|
+
import { isAzureGuid, isAzureIdentifier } from "./azure/writeIdentity.js";
|
|
2
3
|
//#region ../plus/integrations/src/providers/azureWorkItemWriteErrors.ts
|
|
3
|
-
const guidPattern = /^[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12}$/i;
|
|
4
4
|
function isWorkItemWriteScope(options) {
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
function isGuid(value) {
|
|
8
|
-
return typeof value === "string" && guidPattern.test(value);
|
|
9
|
-
}
|
|
10
|
-
function isWorkItemIdentifier(value) {
|
|
11
|
-
return typeof value === "string" && value.length > 0 && value.trim() === value && ![...value].some((character) => character < " " || character === "");
|
|
12
|
-
}
|
|
13
|
-
function isWorkItemNumber(value) {
|
|
14
|
-
return typeof value === "number" && Number.isInteger(value) && value > 0 && value <= 2147483647;
|
|
5
|
+
return isAzureIdentifier(options.connectionId) && isAzureGuid(options.organizationId) && typeof options.organizationName === "string" && /^[a-z0-9][a-z0-9-]*$/i.test(options.organizationName) && isAzureGuid(options.projectId) && (options.expectedAccountId === void 0 || isAzureIdentifier(options.expectedAccountId));
|
|
15
6
|
}
|
|
16
7
|
var WorkItemWriteError = class extends Error {
|
|
17
8
|
reason;
|
|
@@ -95,6 +86,6 @@ function toWorkItemWriteFailure(ex, dispatched) {
|
|
|
95
86
|
};
|
|
96
87
|
}
|
|
97
88
|
//#endregion
|
|
98
|
-
export { WorkItemWriteError,
|
|
89
|
+
export { WorkItemWriteError, isWorkItemWriteScope, toWorkItemWriteFailure };
|
|
99
90
|
|
|
100
91
|
//# sourceMappingURL=azureWorkItemWriteErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureWorkItemWriteErrors.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureWorkItemWriteErrors.ts"],"sourcesContent":["import type { IssueTrackerWriteFailure } from '../models/issueTrackerWrites.js';\nimport type { WorkItemWriteField, WorkItemWriteScope } from '../models/workItemWrites.js';\nimport {\n\tAnonymousResponseError,\n\tgetProviderResponseBodyMessage,\n\tUnexpectedHtmlResponseError,\n} from './providerErrors.js';\n\
|
|
1
|
+
{"version":3,"file":"azureWorkItemWriteErrors.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureWorkItemWriteErrors.ts"],"sourcesContent":["import type { IssueTrackerWriteFailure } from '../models/issueTrackerWrites.js';\nimport type { WorkItemWriteField, WorkItemWriteScope } from '../models/workItemWrites.js';\nimport { isAzureGuid, isAzureIdentifier } from './azure/writeIdentity.js';\nimport {\n\tAnonymousResponseError,\n\tgetProviderResponseBodyMessage,\n\tUnexpectedHtmlResponseError,\n} from './providerErrors.js';\n\nexport function isWorkItemWriteScope(options: WorkItemWriteScope): boolean {\n\treturn (\n\t\tisAzureIdentifier(options.connectionId) &&\n\t\tisAzureGuid(options.organizationId) &&\n\t\ttypeof options.organizationName === 'string' &&\n\t\t/^[a-z0-9][a-z0-9-]*$/i.test(options.organizationName) &&\n\t\tisAzureGuid(options.projectId) &&\n\t\t(options.expectedAccountId === undefined || isAzureIdentifier(options.expectedAccountId))\n\t);\n}\n\nexport class WorkItemWriteError extends Error {\n\tconstructor(\n\t\treadonly reason: IssueTrackerWriteFailure['reason'],\n\t\treadonly fieldErrors?: Readonly<Record<string, string>>,\n\t) {\n\t\tsuper(reason);\n\t}\n}\n\nfunction getRuleErrors(body: unknown, fields: readonly WorkItemWriteField[]) {\n\tconst data = body as\n\t\t| {\n\t\t\t\truleValidationErrors?: unknown;\n\t\t\t\tcustomProperties?: { ruleValidationErrors?: unknown; RuleValidationErrors?: unknown };\n\t\t }\n\t\t| undefined;\n\tconst rows =\n\t\tdata?.ruleValidationErrors ??\n\t\tdata?.customProperties?.ruleValidationErrors ??\n\t\tdata?.customProperties?.RuleValidationErrors;\n\tconst message = getProviderResponseBodyMessage(body);\n\tconst messages = new Set<string>();\n\tconst fieldErrors = new Map<string, string>();\n\tif (message) {\n\t\tmessages.add(message);\n\t}\n\n\tif (Array.isArray(rows)) {\n\t\tfor (const row of rows) {\n\t\t\tconst error = row as { fieldReferenceName?: unknown; errorMessage?: unknown } | null;\n\t\t\tif (typeof error?.errorMessage !== 'string') continue;\n\n\t\t\tmessages.add(error.errorMessage);\n\t\t\tif (typeof error.fieldReferenceName === 'string') {\n\t\t\t\tfieldErrors.set(error.fieldReferenceName, error.errorMessage);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst fieldName = /TF401320:\\s*Rule Error for field (.+?)\\.\\s+Error code:/i.exec(message ?? '')?.[1];\n\tif (fieldName != null) {\n\t\tconst matches = fields.filter(field => field.name === fieldName || field.referenceName === fieldName);\n\t\tif (matches.length === 1 && message && !fieldErrors.has(matches[0].referenceName)) {\n\t\t\tfieldErrors.set(matches[0].referenceName, message);\n\t\t}\n\t}\n\treturn {\n\t\t...(messages.size && { messages: [...messages] }),\n\t\t...(fieldErrors.size && { fieldErrors: Object.fromEntries(fieldErrors) }),\n\t};\n}\n\nexport function toWorkItemWriteFailure(\n\tex: unknown,\n\tdispatched?: { fields: readonly WorkItemWriteField[] },\n): IssueTrackerWriteFailure {\n\tif (ex instanceof WorkItemWriteError && dispatched == null) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\treason: ex.reason,\n\t\t\tmutationDispatched: false,\n\t\t\t...(ex.fieldErrors && { fieldErrors: ex.fieldErrors }),\n\t\t};\n\t}\n\n\tif (dispatched == null && (UnexpectedHtmlResponseError.is(ex) || AnonymousResponseError.is(ex))) {\n\t\treturn { ok: false, reason: 'no-connection', mutationDispatched: false };\n\t}\n\n\tconst response = (\n\t\tex as\n\t\t\t| {\n\t\t\t\t\tresponse?: { status?: number; body?: unknown; headers?: Record<string, string> };\n\t\t\t }\n\t\t\t| undefined\n\t)?.response;\n\tconst status = response?.status;\n\tconst body = response?.body;\n\tconst type = (body as { typeKey?: unknown } | undefined)?.typeKey;\n\tconst message = getProviderResponseBodyMessage(body) ?? '';\n\tlet reason: IssueTrackerWriteFailure['reason'];\n\tswitch (status) {\n\t\tcase 400:\n\t\tcase 413:\n\t\tcase 422:\n\t\t\treason = type === 'WorkItemRevisionMismatchException' ? 'conflict' : 'invalid-input';\n\t\t\tbreak;\n\t\tcase 401:\n\t\tcase 403:\n\t\t\tif (\n\t\t\t\t/\\binsufficient[_ -]scope\\b|scope does not match|\\bvso\\.work_write\\b/i.test(\n\t\t\t\t\t`${response?.headers?.['www-authenticate'] ?? ''} ${message}`,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treason = 'insufficient-scope';\n\t\t\t} else {\n\t\t\t\treason = status === 401 && dispatched == null ? 'no-connection' : 'forbidden';\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 404:\n\t\t\treason = 'not-found';\n\t\t\tbreak;\n\t\tcase 409:\n\t\tcase 412:\n\t\t\treason = 'conflict';\n\t\t\tbreak;\n\t\tcase 429:\n\t\t\treason = 'rate-limit';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treason = 'unknown';\n\t}\n\n\treturn {\n\t\tok: false,\n\t\treason: reason,\n\t\t...(dispatched == null && { mutationDispatched: false }),\n\t\t...(dispatched != null && reason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egment } from "./azure/models.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getAzureWriteOrganizations, getAzureWriteProfile, isAzureGuid, isAzureIdentifier, isAzurePositiveInt, sameAzureIdentifier } from "./azure/writeIdentity.js";
|
|
3
|
+
import { WorkItemWriteError, toWorkItemWriteFailure } from "./azureWorkItemWriteErrors.js";
|
|
3
4
|
import { getAzureWorkItemBodyField, getAzureWorkItemTransitionTargets, isAzureProjectPathField, isAzureTestArtifact, toAzureWorkItemWriteFields } from "./azure/workItemWriteMetadata.js";
|
|
4
5
|
//#region ../plus/integrations/src/providers/azureWorkItemWrites.ts
|
|
5
|
-
const azureProfileApi = "https://app.vssps.visualstudio.com/_apis";
|
|
6
6
|
const projectSecurityNamespaceId = "52d39943-cb85-4d7f-8fa8-c6baac873819";
|
|
7
|
-
function sameIdentifier(actual, expected) {
|
|
8
|
-
return typeof actual === "string" && actual.toLowerCase() === expected.toLowerCase();
|
|
9
|
-
}
|
|
10
7
|
function isSameId(actual, id) {
|
|
11
8
|
return actual === id || actual === String(id);
|
|
12
9
|
}
|
|
13
10
|
function isDeletedItem(item, id) {
|
|
14
|
-
if (item == null || !isSameId(item.id, id) || !
|
|
11
|
+
if (item == null || !isSameId(item.id, id) || !isAzureIdentifier(item.project)) return false;
|
|
15
12
|
return item.code == null || item.code === 0 || typeof item.code === "number" && item.code >= 200 && item.code < 300;
|
|
16
13
|
}
|
|
17
14
|
function getDeletedRevision(item, id) {
|
|
18
15
|
const resource = item.resource;
|
|
19
|
-
return resource != null && isSameId(resource.id, id) &&
|
|
16
|
+
return resource != null && isSameId(resource.id, id) && isAzurePositiveInt(resource.rev) ? resource.rev : void 0;
|
|
20
17
|
}
|
|
21
18
|
const azureDeletedDate = /^(\d{1,2})\/(\d{1,2})\/([12]\d{3}) (\d{1,2}):([0-5]\d):([0-5]\d) (AM|PM)$/;
|
|
22
19
|
function toDeletedAt(value) {
|
|
@@ -33,13 +30,13 @@ function readValues(body) {
|
|
|
33
30
|
return body.value;
|
|
34
31
|
}
|
|
35
32
|
function assertExistingAddress(address) {
|
|
36
|
-
if (!
|
|
33
|
+
if (!isAzurePositiveInt(address.workItemId)) throw new WorkItemWriteError("invalid-input");
|
|
37
34
|
}
|
|
38
35
|
function assertMutationIdentity(expectedAccountId) {
|
|
39
|
-
if (!
|
|
36
|
+
if (!isAzureIdentifier(expectedAccountId)) throw new WorkItemWriteError("invalid-input");
|
|
40
37
|
}
|
|
41
38
|
function assertSameRevision(item, expectedRevision) {
|
|
42
|
-
if (!
|
|
39
|
+
if (!isAzurePositiveInt(expectedRevision)) throw new WorkItemWriteError("invalid-input");
|
|
43
40
|
if (item.rev !== expectedRevision) throw new WorkItemWriteError("conflict");
|
|
44
41
|
}
|
|
45
42
|
function isJsonValue(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
@@ -98,20 +95,12 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
98
95
|
organizationUrl;
|
|
99
96
|
isSessionCurrent;
|
|
100
97
|
static async connect(request, credential, options, isSessionCurrent) {
|
|
101
|
-
const { body: profile } = await request
|
|
102
|
-
url: `${azureProfileApi}/profile/profiles/me`,
|
|
103
|
-
headers: { Authorization: `Bearer ${credential.accessToken}` },
|
|
104
|
-
redirect: "error"
|
|
105
|
-
});
|
|
98
|
+
const { body: profile } = await getAzureWriteProfile(request, credential.accessToken);
|
|
106
99
|
const accountId = profile?.id;
|
|
107
|
-
if (!
|
|
100
|
+
if (!isAzureIdentifier(accountId) || options.expectedAccountId !== void 0 && !sameAzureIdentifier(accountId, options.expectedAccountId)) throw new WorkItemWriteError("no-connection");
|
|
108
101
|
const headers = { Authorization: credential.authorization };
|
|
109
|
-
const { body: accounts } = await request
|
|
110
|
-
|
|
111
|
-
headers,
|
|
112
|
-
redirect: "error"
|
|
113
|
-
});
|
|
114
|
-
const organization = readValues(accounts).find((account) => sameIdentifier(account.accountId, options.organizationId) && sameIdentifier(account.accountName, options.organizationName));
|
|
102
|
+
const { body: accounts } = await getAzureWriteOrganizations(request, credential.authorization, accountId);
|
|
103
|
+
const organization = readValues(accounts).find((account) => sameAzureIdentifier(account.accountId, options.organizationId) && sameAzureIdentifier(account.accountName, options.organizationName));
|
|
115
104
|
if (organization == null) throw new WorkItemWriteError("not-found");
|
|
116
105
|
const organizationUrl = `https://dev.azure.com/${encodeAzurePathSegment(organization.accountName)}`;
|
|
117
106
|
const { body: project } = await request({
|
|
@@ -119,7 +108,7 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
119
108
|
headers,
|
|
120
109
|
redirect: "error"
|
|
121
110
|
});
|
|
122
|
-
if (!
|
|
111
|
+
if (!sameAzureIdentifier(project?.id, options.projectId) || !isAzureIdentifier(project?.name)) throw new WorkItemWriteError("not-found");
|
|
123
112
|
return new AzureWorkItemWriter(request, headers, {
|
|
124
113
|
providerId: options.providerId,
|
|
125
114
|
connectionId: options.connectionId,
|
|
@@ -145,7 +134,7 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
145
134
|
}
|
|
146
135
|
async getCreateOptions(options) {
|
|
147
136
|
if (options.workItemType === void 0) {
|
|
148
|
-
const enabled = readValues(await this.read("/workitemtypes")).filter((type) =>
|
|
137
|
+
const enabled = readValues(await this.read("/workitemtypes")).filter((type) => isAzureIdentifier(type.name) && !type.isDisabled);
|
|
149
138
|
return {
|
|
150
139
|
ok: true,
|
|
151
140
|
...this.context,
|
|
@@ -264,8 +253,8 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
264
253
|
...revision !== void 0 && { revision },
|
|
265
254
|
...deletedAt !== void 0 && { deletedAt }
|
|
266
255
|
};
|
|
267
|
-
const project =
|
|
268
|
-
if (
|
|
256
|
+
const project = sameAzureIdentifier(deleted.project, isAzureGuid(deleted.project) ? this.context.project.id : this.context.project.name) ? this.context.project : await this.findProject(deleted.project);
|
|
257
|
+
if (sameAzureIdentifier(project.id, this.context.project.id) && revision === expectedRevision + 1) return {
|
|
269
258
|
ok: true,
|
|
270
259
|
...this.context,
|
|
271
260
|
issue,
|
|
@@ -290,7 +279,7 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
290
279
|
async findProject(nameOrId) {
|
|
291
280
|
try {
|
|
292
281
|
const project = await this.readOrganization(`/projects/${encodeAzurePathSegment(nameOrId)}`);
|
|
293
|
-
if (
|
|
282
|
+
if (isAzureGuid(project?.id) && isAzureIdentifier(project.name) && (sameAzureIdentifier(project.name, nameOrId) || sameAzureIdentifier(project.id, nameOrId))) return {
|
|
294
283
|
id: project.id,
|
|
295
284
|
name: project.name
|
|
296
285
|
};
|
|
@@ -314,8 +303,8 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
314
303
|
reason: "unsupported"
|
|
315
304
|
};
|
|
316
305
|
try {
|
|
317
|
-
const bit = readValues(await this.readOrganization(`/securitynamespaces/${projectSecurityNamespaceId}`)).find((namespace) =>
|
|
318
|
-
if (!
|
|
306
|
+
const bit = readValues(await this.readOrganization(`/securitynamespaces/${projectSecurityNamespaceId}`)).find((namespace) => sameAzureIdentifier(namespace?.namespaceId, projectSecurityNamespaceId))?.actions?.find((action) => action?.name === "WORK_ITEM_DELETE")?.bit;
|
|
307
|
+
if (!isAzurePositiveInt(bit)) return { allowed: "unknown" };
|
|
319
308
|
const [allowed, ...rest] = readValues(await this.readOrganization(`/permissions/${projectSecurityNamespaceId}/${bit}`, {
|
|
320
309
|
tokens: `$PROJECT:vstfs:///Classification/TeamProject/${this.context.project.id}`,
|
|
321
310
|
alwaysAllowAdministrators: "false"
|
|
@@ -330,17 +319,17 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
330
319
|
}
|
|
331
320
|
}
|
|
332
321
|
async getMetadata(name) {
|
|
333
|
-
if (!
|
|
322
|
+
if (!isAzureIdentifier(name) || name === "." || name === ".." || /[/\\]/.test(name)) throw new WorkItemWriteError("invalid-input");
|
|
334
323
|
const path = `/workitemtypes/${encodeAzurePathSegment(name)}`;
|
|
335
324
|
const [type, typeFields, definitions] = await Promise.all([
|
|
336
325
|
this.read(path),
|
|
337
326
|
this.read(`${path}/fields`, { $expand: "All" }),
|
|
338
327
|
this.read("/fields")
|
|
339
328
|
]);
|
|
340
|
-
if (!
|
|
329
|
+
if (!sameAzureIdentifier(type?.name, name) || !isAzureIdentifier(type?.referenceName)) throw new WorkItemWriteError("unknown");
|
|
341
330
|
if (type.transitions == null || typeof type.transitions !== "object" || Array.isArray(type.transitions)) throw new WorkItemWriteError("unknown");
|
|
342
331
|
const states = Array.isArray(type.states) && type.states.length !== 0 ? type.states : readValues(await this.read(`${path}/states`));
|
|
343
|
-
if (states.some((state) => !
|
|
332
|
+
if (states.some((state) => !isAzureIdentifier(state?.name) || !isAzureIdentifier(state.category))) throw new WorkItemWriteError("unknown");
|
|
344
333
|
const catalog = readValues(definitions);
|
|
345
334
|
return {
|
|
346
335
|
type,
|
|
@@ -360,17 +349,17 @@ var AzureWorkItemWriter = class AzureWorkItemWriter {
|
|
|
360
349
|
return data;
|
|
361
350
|
}
|
|
362
351
|
isInProject(item) {
|
|
363
|
-
return
|
|
352
|
+
return sameAzureIdentifier(item?.fields?.["System.TeamProject"], this.context.project.name);
|
|
364
353
|
}
|
|
365
354
|
itemType(item) {
|
|
366
355
|
const type = item.fields["System.WorkItemType"];
|
|
367
|
-
if (!
|
|
356
|
+
if (!isAzureIdentifier(type)) throw new WorkItemWriteError("unknown");
|
|
368
357
|
return type;
|
|
369
358
|
}
|
|
370
359
|
getReceipt(item, metadata) {
|
|
371
360
|
const title = item.fields["System.Title"];
|
|
372
361
|
const state = metadata.states.find((candidate) => candidate.name === item.fields["System.State"]);
|
|
373
|
-
if (!
|
|
362
|
+
if (!isAzurePositiveInt(item.id) || !isAzurePositiveInt(item.rev) || typeof title !== "string" || state == null || this.itemType(item) !== metadata.type.name) throw new WorkItemWriteError("unknown");
|
|
374
363
|
return {
|
|
375
364
|
id: item.id,
|
|
376
365
|
revision: item.rev,
|
|
@@ -1 +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,GAAG,KAAM,OAAO,MAAO,MAAM,OAAO,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AAO,GAAG,OAAO,KAAK,GAAG,IAAI,gBAAgB;GAAE,eAAe;GAAO,GAAG;EAAO,CAAC,CAAC,CAAC,SAAS;CAC5F;CAEA,KAAgB,MAAc,QAA6C;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,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\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\tgetAzureWriteOrganizations,\n\tgetAzureWriteProfile,\n\tisAzureGuid,\n\tisAzureIdentifier,\n\tisAzurePositiveInt,\n\tsameAzureIdentifier,\n} from './azure/writeIdentity.js';\nimport { toWorkItemWriteFailure, WorkItemWriteError } 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\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 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 { 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 (!sameAzureIdentifier(project?.id, options.projectId) || !isAzureIdentifier(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 => 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\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(await this.read<{ value?: WorkItemState[] }>(`${path}/states`));\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': '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":";;;;;AA2DA,MAAM,6BAA6B;AAEnC,SAAS,SAAS,QAAiB,IAAqB;CACvD,OAAO,WAAW,MAAM,WAAW,OAAO,EAAE;AAC7C;AAEA,SAAS,cACR,MACA,IACqD;CACrD,IAAI,QAAQ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,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,OAAO,uBAAuB,IAAI,EAAE,QAAQ,SAAS,OAAO,CAAC;EAC9D;CACD;AACD"}
|
|
@@ -4,6 +4,7 @@ import { IssueSorting } from "../../../git/models/issue.js";
|
|
|
4
4
|
import { PullRequest, PullRequestFilter, PullRequestMergeMethod } from "../../../git/models/pullRequest.js";
|
|
5
5
|
import { ProviderAuthenticationSession, TokenOptInfo, TokenWithInfo } from "../authentication/models.js";
|
|
6
6
|
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId } from "../constants.js";
|
|
7
|
+
import { AzurePullRequestCreateCapabilityOptions } from "../models/azurePullRequestWrites.js";
|
|
7
8
|
import { IssueTrackerWriteConnection } from "../models/issueTrackerWrites.js";
|
|
8
9
|
import { WorkItemWriteScope } from "../models/workItemWrites.js";
|
|
9
10
|
import { IssueFilter } from "../providerFilters.js";
|
|
@@ -12,6 +13,7 @@ import { ProviderPullRequestCount, ProviderPullRequestSearchPage } from "../mode
|
|
|
12
13
|
import { AzurePullRequest, AzureWorkItemEtagRead } from "./azure/models.js";
|
|
13
14
|
import { AzureWorkItemStatesCache } from "./azure/workItemStateCategories.js";
|
|
14
15
|
import { AzureWorkItemDescriptionsCache } from "./azure/workItemDescriptions.js";
|
|
16
|
+
import { AzurePullRequestWriter } from "./azurePullRequestWrites.js";
|
|
15
17
|
import { AzureWorkItemWriter } from "./azureWorkItemWrites.js";
|
|
16
18
|
import { countBitbucketServerPullRequests, searchBitbucketServerPullRequestsPage } from "./bitbucket-server/pullRequestSearch.js";
|
|
17
19
|
import { JiraIssueEtagResponse } from "./jiraIssueByKey.js";
|
|
@@ -181,6 +183,7 @@ export declare class ProvidersApi implements Disposable {
|
|
|
181
183
|
isPAT?: boolean;
|
|
182
184
|
baseUrl?: string;
|
|
183
185
|
}): Promise<ProviderAccount | undefined>;
|
|
186
|
+
getAzurePullRequestWriter(options: AzurePullRequestCreateCapabilityOptions, session: ProviderAuthenticationSession, isSessionCurrent: () => Promise<boolean>): Promise<AzurePullRequestWriter>;
|
|
184
187
|
getAzureWorkItemWriter(options: WorkItemWriteScope, session: ProviderAuthenticationSession, isSessionCurrent: () => Promise<boolean>): Promise<AzureWorkItemWriter>;
|
|
185
188
|
getJiraIssueWriter(options: IssueTrackerWriteConnection): Promise<JiraIssueWriter | undefined>;
|
|
186
189
|
getJiraResourcesForCurrentUser(tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Jira>): Promise<ProviderJiraResource[] | undefined>;
|
|
@@ -13,6 +13,7 @@ import { isRepoIdsInput } from "./models.js";
|
|
|
13
13
|
import { azureIssueStateCategory, azureWorkItemEtagFieldNames, encodeAzurePathSegment, fromAzureWorkItemToProviderIssue, toAzureWorkItemDescriptionFields } from "./azure/models.js";
|
|
14
14
|
import { AzureWorkItemDescriptionsCache } from "./azure/workItemDescriptions.js";
|
|
15
15
|
import { AzureWorkItemStatesCache, getAzureWorkItemTypeStatesUrl, getAzureWorkItemTypesUrl, requireAzureWorkItemStateCategories, resolveAzureWorkItemStateCategory } from "./azure/workItemStateCategories.js";
|
|
16
|
+
import { AzurePullRequestWriter } from "./azurePullRequestWrites.js";
|
|
16
17
|
import { requestJiraIssueByKey, requestJiraIssuesEtagFields } from "./jiraIssueByKey.js";
|
|
17
18
|
import { JiraIssueWriter } from "./jiraIssueWrites.js";
|
|
18
19
|
import { createProviderApiRequest } from "./providerApiClient.js";
|
|
@@ -797,6 +798,13 @@ var ProvidersApi = class {
|
|
|
797
798
|
return this.handleProviderError(tokenWithInfo, e);
|
|
798
799
|
}
|
|
799
800
|
}
|
|
801
|
+
getAzurePullRequestWriter(options, session, isSessionCurrent) {
|
|
802
|
+
return AzurePullRequestWriter.connect(this.request, {
|
|
803
|
+
accessToken: session.accessToken,
|
|
804
|
+
accountsAuthorization: azureAuthorization(session.accessToken, true),
|
|
805
|
+
gitAuthorization: azureAuthorization(session.accessToken, false)
|
|
806
|
+
}, options, isSessionCurrent);
|
|
807
|
+
}
|
|
800
808
|
getAzureWorkItemWriter(options, session, isSessionCurrent) {
|
|
801
809
|
return AzureWorkItemWriter.connect(this.request, {
|
|
802
810
|
accessToken: session.accessToken,
|