@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
|
@@ -9,6 +9,7 @@ import { ConfiguredIntegrationDescriptor } from "./authentication/models.js";
|
|
|
9
9
|
import { CloudGitSelfManagedHostIntegrationIds, GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId, SupportedCloudIntegrationIds } from "./constants.js";
|
|
10
10
|
import { Source } from "./telemetry.js";
|
|
11
11
|
import { IssueTrackerCreateOptions, IssueTrackerCreateOptionsResult, IssueTrackerDeleteOptions, IssueTrackerIssueWriteOptions, IssueTrackerIssueWriteOptionsResult, IssueTrackerWriteOptions, IssueTrackerWriteResult, IssueTrackerWriteTargetOptions, IssueTrackerWriteTargetResult } from "./models/issueTrackerWrites.js";
|
|
12
|
+
import { WorkItemAddress, WorkItemCreateOptions, WorkItemCreateOptionsResult, WorkItemDeleteOptions, WorkItemDeleteResult, WorkItemWriteOptions, WorkItemWriteOptionsResult, WorkItemWriteResult, WorkItemWriteTargetOptions, WorkItemWriteTargetResult } from "./models/workItemWrites.js";
|
|
12
13
|
import { IssueFilter, SupportedFilters } from "./providerFilters.js";
|
|
13
14
|
import { IssueEtagInclude, PullRequestEtagInclude } from "./reads/etag.js";
|
|
14
15
|
import { ConnectionStateChangeEvent, CurrentAccountResult, IssueBatchResult, IssueBatchTarget, IssueCountResult, IssueCountScope, ProviderBroadenResult, ProviderLinearProjectShape, ProviderOrganization, ProviderPagedResult, ProviderRepositoryShape, ProviderResult, ProviderSweepResult, PullRequestActivityResult, PullRequestActivityTarget, PullRequestBatchResult, PullRequestBatchTarget, PullRequestBranchResult, PullRequestBranchTarget, PullRequestCheckLogResult, PullRequestCheckLogTarget, PullRequestCountResult, PullRequestCountScope, PullRequestForCommitResult, ResolveRepositoryResult } from "./results.js";
|
|
@@ -1162,6 +1163,11 @@ export interface IntegrationManager {
|
|
|
1162
1163
|
*/
|
|
1163
1164
|
domain?: string;
|
|
1164
1165
|
}): Promise<ProviderPagedResult<IssueShape>>;
|
|
1166
|
+
getWorkItemCreateOptions(options: WorkItemCreateOptions): Promise<WorkItemCreateOptionsResult>;
|
|
1167
|
+
getWorkItemWriteOptions(options: WorkItemAddress): Promise<WorkItemWriteOptionsResult>;
|
|
1168
|
+
writeWorkItem(options: WorkItemWriteOptions): Promise<WorkItemWriteResult>;
|
|
1169
|
+
resolveWorkItemWriteTarget(options: WorkItemWriteTargetOptions): Promise<WorkItemWriteTargetResult>;
|
|
1170
|
+
deleteWorkItem(options: WorkItemDeleteOptions): Promise<WorkItemDeleteResult>;
|
|
1165
1171
|
getIssueTrackerCreateOptions(options: IssueTrackerCreateOptions): Promise<IssueTrackerCreateOptionsResult>;
|
|
1166
1172
|
getIssueTrackerIssueWriteOptions(options: IssueTrackerIssueWriteOptions): Promise<IssueTrackerIssueWriteOptionsResult>;
|
|
1167
1173
|
writeIssueTrackerIssue(options: IssueTrackerWriteOptions): Promise<IssueTrackerWriteResult>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { GitCloudHostIntegrationId } from "../constants.js";
|
|
2
|
+
import { IssueTrackerWriteFailure } from "./issueTrackerWrites.js";
|
|
3
|
+
//#region ../plus/integrations/src/models/workItemWrites.d.ts
|
|
4
|
+
export type WorkItemWriteScope = {
|
|
5
|
+
providerId: GitCloudHostIntegrationId.AzureDevOps;
|
|
6
|
+
connectionId: string;
|
|
7
|
+
organizationId: string;
|
|
8
|
+
organizationName: string;
|
|
9
|
+
projectId: string;
|
|
10
|
+
/** The verified Azure profile ID, distinct from the organization-local member ID. */
|
|
11
|
+
expectedAccountId?: string;
|
|
12
|
+
};
|
|
13
|
+
export type WorkItemAddress = WorkItemWriteScope & {
|
|
14
|
+
workItemId: number;
|
|
15
|
+
};
|
|
16
|
+
export type WorkItemCreateOptions = WorkItemWriteScope & {
|
|
17
|
+
workItemType?: string;
|
|
18
|
+
};
|
|
19
|
+
export type WorkItemWriteTargetOptions = WorkItemAddress & {
|
|
20
|
+
intent?: 'delete';
|
|
21
|
+
};
|
|
22
|
+
export type WorkItemDeleteOptions = WorkItemAddress & {
|
|
23
|
+
expectedAccountId: string;
|
|
24
|
+
expectedRevision: number;
|
|
25
|
+
};
|
|
26
|
+
export type WorkItemWriteOptions = (WorkItemWriteScope & {
|
|
27
|
+
action: 'create';
|
|
28
|
+
expectedAccountId: string;
|
|
29
|
+
workItemType: string;
|
|
30
|
+
fields: Readonly<Record<string, unknown>>;
|
|
31
|
+
}) | (WorkItemDeleteOptions & {
|
|
32
|
+
action: 'edit';
|
|
33
|
+
fields: Readonly<Record<string, unknown>>;
|
|
34
|
+
}) | (WorkItemDeleteOptions & {
|
|
35
|
+
action: 'set-state';
|
|
36
|
+
state: string;
|
|
37
|
+
fields?: Readonly<Record<string, unknown>>;
|
|
38
|
+
});
|
|
39
|
+
export type WorkItemWriteContext = {
|
|
40
|
+
providerId: GitCloudHostIntegrationId.AzureDevOps;
|
|
41
|
+
connectionId: string;
|
|
42
|
+
accountId: string;
|
|
43
|
+
organization: {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
};
|
|
47
|
+
project: {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export type WorkItemState = {
|
|
53
|
+
name: string;
|
|
54
|
+
category: string;
|
|
55
|
+
color?: string;
|
|
56
|
+
};
|
|
57
|
+
export type WorkItemWriteField = {
|
|
58
|
+
referenceName: string;
|
|
59
|
+
name: string;
|
|
60
|
+
type: string;
|
|
61
|
+
required: boolean;
|
|
62
|
+
allowedValues?: readonly unknown[];
|
|
63
|
+
defaultValue?: unknown;
|
|
64
|
+
helpText?: string;
|
|
65
|
+
};
|
|
66
|
+
export type WorkItemReceipt = {
|
|
67
|
+
id: number;
|
|
68
|
+
revision: number;
|
|
69
|
+
url: string;
|
|
70
|
+
type: string;
|
|
71
|
+
title: string;
|
|
72
|
+
state: Pick<WorkItemState, 'name' | 'category'>;
|
|
73
|
+
bodyField?: string;
|
|
74
|
+
};
|
|
75
|
+
export type WorkItemDeleteCapability = {
|
|
76
|
+
allowed: true;
|
|
77
|
+
} | {
|
|
78
|
+
allowed: false;
|
|
79
|
+
reason: 'forbidden' | 'insufficient-scope' | 'unsupported';
|
|
80
|
+
} | {
|
|
81
|
+
allowed: 'unknown';
|
|
82
|
+
};
|
|
83
|
+
export type WorkItemCreateOptionsResult = IssueTrackerWriteFailure | (WorkItemWriteContext & {
|
|
84
|
+
ok: true;
|
|
85
|
+
} & ({
|
|
86
|
+
workItemTypes: readonly {
|
|
87
|
+
name: string;
|
|
88
|
+
}[];
|
|
89
|
+
} | {
|
|
90
|
+
workItemType: string;
|
|
91
|
+
fields: readonly WorkItemWriteField[];
|
|
92
|
+
states: readonly WorkItemState[];
|
|
93
|
+
initialStates: readonly WorkItemState[];
|
|
94
|
+
bodyField?: string;
|
|
95
|
+
}));
|
|
96
|
+
type WorkItemWriteSuccess = WorkItemWriteContext & {
|
|
97
|
+
ok: true;
|
|
98
|
+
issue: WorkItemReceipt;
|
|
99
|
+
};
|
|
100
|
+
export type WorkItemWriteResult = IssueTrackerWriteFailure | WorkItemWriteSuccess;
|
|
101
|
+
export type WorkItemWriteOptionsResult = IssueTrackerWriteFailure | (WorkItemWriteSuccess & {
|
|
102
|
+
fields: readonly WorkItemWriteField[];
|
|
103
|
+
availableStates: readonly WorkItemState[];
|
|
104
|
+
deleteCapability: WorkItemDeleteCapability;
|
|
105
|
+
bodyField?: string;
|
|
106
|
+
});
|
|
107
|
+
export type WorkItemWriteTargetResult = IssueTrackerWriteFailure | (WorkItemWriteSuccess & {
|
|
108
|
+
deleteCapability?: WorkItemDeleteCapability;
|
|
109
|
+
});
|
|
110
|
+
export type WorkItemDeletion = {
|
|
111
|
+
disposition: 'recycle-bin';
|
|
112
|
+
restorable: true;
|
|
113
|
+
revision?: number;
|
|
114
|
+
deletedAt?: string;
|
|
115
|
+
};
|
|
116
|
+
export type WorkItemDeleteTargetChanged = WorkItemWriteContext & {
|
|
117
|
+
ok: false;
|
|
118
|
+
reason: 'target-changed';
|
|
119
|
+
applied: true;
|
|
120
|
+
deleted: {
|
|
121
|
+
id: number;
|
|
122
|
+
revision?: number;
|
|
123
|
+
project: {
|
|
124
|
+
id?: string;
|
|
125
|
+
name: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
deletion: WorkItemDeletion;
|
|
129
|
+
};
|
|
130
|
+
export type WorkItemDeleteResult = IssueTrackerWriteFailure | WorkItemDeleteTargetChanged | (WorkItemWriteSuccess & {
|
|
131
|
+
deletion: WorkItemDeletion & {
|
|
132
|
+
revision: number;
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
//#endregion
|
|
136
|
+
//# sourceMappingURL=workItemWrites.d.ts.map
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { WorkItemState, WorkItemWriteField } from "../../models/workItemWrites.js";
|
|
2
|
+
//#region ../plus/integrations/src/providers/azure/workItemWriteMetadata.d.ts
|
|
3
|
+
export type AzureWorkItemTypeMetadata = {
|
|
4
|
+
name: string;
|
|
5
|
+
referenceName: string;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
states?: WorkItemState[];
|
|
8
|
+
transitions?: Record<string, {
|
|
9
|
+
to: string;
|
|
10
|
+
}[]>;
|
|
11
|
+
};
|
|
12
|
+
export type AzureWorkItemTypeCategory = {
|
|
13
|
+
referenceName: string;
|
|
14
|
+
workItemTypes?: {
|
|
15
|
+
name: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export type AzureWorkItemFieldDefinition = {
|
|
19
|
+
referenceName: string;
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
readOnly: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type AzureWorkItemTypeField = {
|
|
25
|
+
referenceName: string;
|
|
26
|
+
name: string;
|
|
27
|
+
alwaysRequired?: boolean;
|
|
28
|
+
allowedValues?: unknown[];
|
|
29
|
+
defaultValue?: unknown;
|
|
30
|
+
helpText?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function isAzureProjectPathField(referenceName: string): boolean;
|
|
33
|
+
export declare function toAzureWorkItemWriteFields(typeFields: readonly AzureWorkItemTypeField[], catalog: readonly AzureWorkItemFieldDefinition[]): WorkItemWriteField[];
|
|
34
|
+
export declare function getAzureWorkItemBodyField(fields: readonly WorkItemWriteField[], catalog: readonly AzureWorkItemFieldDefinition[], values?: Readonly<Record<string, unknown>>): string | undefined;
|
|
35
|
+
export declare function getAzureWorkItemTransitionTargets(type: AzureWorkItemTypeMetadata, states: readonly WorkItemState[], from: string): WorkItemState[];
|
|
36
|
+
export declare function isAzureTestArtifact(type: AzureWorkItemTypeMetadata, categories?: readonly AzureWorkItemTypeCategory[]): boolean;
|
|
37
|
+
//#endregion
|
|
38
|
+
//# sourceMappingURL=workItemWriteMetadata.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getAzureWorkItemDescription, toAzureWorkItemHtmlFields } from "@gitkraken/provider-apis";
|
|
2
|
+
//#region ../plus/integrations/src/providers/azure/workItemWriteMetadata.ts
|
|
3
|
+
const writableSystemFields = /* @__PURE__ */ new Set([
|
|
4
|
+
"system.title",
|
|
5
|
+
"system.description",
|
|
6
|
+
"system.assignedto",
|
|
7
|
+
"system.tags",
|
|
8
|
+
"system.reason",
|
|
9
|
+
"system.history",
|
|
10
|
+
"system.areapath",
|
|
11
|
+
"system.iterationpath"
|
|
12
|
+
]);
|
|
13
|
+
function isCallerWritable(referenceName) {
|
|
14
|
+
const name = referenceName.toLowerCase();
|
|
15
|
+
return !name.startsWith("system.") || writableSystemFields.has(name);
|
|
16
|
+
}
|
|
17
|
+
const projectPathFields = /* @__PURE__ */ new Set(["system.areapath", "system.iterationpath"]);
|
|
18
|
+
function isAzureProjectPathField(referenceName) {
|
|
19
|
+
return projectPathFields.has(referenceName.toLowerCase());
|
|
20
|
+
}
|
|
21
|
+
function toAzureWorkItemWriteFields(typeFields, catalog) {
|
|
22
|
+
const definitions = new Map(catalog.map((field) => [field.referenceName, field]));
|
|
23
|
+
const editable = [];
|
|
24
|
+
for (const field of typeFields) {
|
|
25
|
+
const definition = definitions.get(field.referenceName);
|
|
26
|
+
if (definition?.readOnly !== false || !isCallerWritable(field.referenceName)) continue;
|
|
27
|
+
editable.push({
|
|
28
|
+
referenceName: field.referenceName,
|
|
29
|
+
name: field.name,
|
|
30
|
+
type: definition.type,
|
|
31
|
+
required: field.alwaysRequired === true && !isAzureProjectPathField(field.referenceName),
|
|
32
|
+
...Array.isArray(field.allowedValues) && field.allowedValues.length !== 0 && { allowedValues: structuredClone(field.allowedValues) },
|
|
33
|
+
...field.defaultValue != null && { defaultValue: structuredClone(field.defaultValue) },
|
|
34
|
+
...typeof field.helpText === "string" && { helpText: field.helpText }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return editable;
|
|
38
|
+
}
|
|
39
|
+
function getAzureWorkItemBodyField(fields, catalog, values) {
|
|
40
|
+
const html = toAzureWorkItemHtmlFields(catalog);
|
|
41
|
+
const current = getAzureWorkItemDescription(values, html)?.field.referenceName;
|
|
42
|
+
if (current != null && fields.some((field) => field.referenceName === current)) return current;
|
|
43
|
+
const available = Object.fromEntries(fields.filter((field) => field.type.toLowerCase() === "html").map((field) => [field.referenceName, field.referenceName]));
|
|
44
|
+
return getAzureWorkItemDescription(available, html)?.field.referenceName;
|
|
45
|
+
}
|
|
46
|
+
function getAzureWorkItemTransitionTargets(type, states, from) {
|
|
47
|
+
const transitions = type.transitions != null && Object.hasOwn(type.transitions, from) ? type.transitions[from] : [];
|
|
48
|
+
const targets = new Set(Array.isArray(transitions) ? transitions.map((transition) => transition?.to) : []);
|
|
49
|
+
return states.filter((state) => state.name !== from && targets.has(state.name));
|
|
50
|
+
}
|
|
51
|
+
const testArtifactTypes = /* @__PURE__ */ new Set([
|
|
52
|
+
"microsoft.vsts.workitemtypes.testplan",
|
|
53
|
+
"microsoft.vsts.workitemtypes.testsuite",
|
|
54
|
+
"microsoft.vsts.workitemtypes.testcase",
|
|
55
|
+
"microsoft.vsts.workitemtypes.sharedstep",
|
|
56
|
+
"microsoft.vsts.workitemtypes.sharedparameter"
|
|
57
|
+
]);
|
|
58
|
+
const testArtifactCategories = /* @__PURE__ */ new Set([
|
|
59
|
+
"microsoft.testplancategory",
|
|
60
|
+
"microsoft.testsuitecategory",
|
|
61
|
+
"microsoft.testcasecategory",
|
|
62
|
+
"microsoft.sharedstepcategory",
|
|
63
|
+
"microsoft.sharedparametercategory"
|
|
64
|
+
]);
|
|
65
|
+
function isAzureTestArtifact(type, categories = []) {
|
|
66
|
+
if (testArtifactTypes.has(type.referenceName.toLowerCase())) return true;
|
|
67
|
+
const name = type.name.toLowerCase();
|
|
68
|
+
return categories.some((category) => typeof category?.referenceName === "string" && testArtifactCategories.has(category.referenceName.toLowerCase()) && Array.isArray(category.workItemTypes) && category.workItemTypes.some((member) => typeof member?.name === "string" && member.name.toLowerCase() === name));
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { getAzureWorkItemBodyField, getAzureWorkItemTransitionTargets, isAzureProjectPathField, isAzureTestArtifact, toAzureWorkItemWriteFields };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=workItemWriteMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workItemWriteMetadata.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/azure/workItemWriteMetadata.ts"],"sourcesContent":["import { getAzureWorkItemDescription, toAzureWorkItemHtmlFields } from '@gitkraken/provider-apis';\nimport type { WorkItemState, WorkItemWriteField } from '../../models/workItemWrites.js';\n\nexport type AzureWorkItemTypeMetadata = {\n\tname: string;\n\treferenceName: string;\n\tisDisabled?: boolean;\n\tstates?: WorkItemState[];\n\ttransitions?: Record<string, { to: string }[]>;\n};\n\nexport type AzureWorkItemTypeCategory = { referenceName: string; workItemTypes?: { name: string }[] };\nexport type AzureWorkItemFieldDefinition = { referenceName: string; name: string; type: string; readOnly: boolean };\nexport type AzureWorkItemTypeField = {\n\treferenceName: string;\n\tname: string;\n\talwaysRequired?: boolean;\n\tallowedValues?: unknown[];\n\tdefaultValue?: unknown;\n\thelpText?: string;\n};\n\nconst writableSystemFields = new Set([\n\t'system.title',\n\t'system.description',\n\t'system.assignedto',\n\t'system.tags',\n\t'system.reason',\n\t'system.history',\n\t'system.areapath',\n\t'system.iterationpath',\n]);\n\nfunction isCallerWritable(referenceName: string): boolean {\n\tconst name = referenceName.toLowerCase();\n\treturn !name.startsWith('system.') || writableSystemFields.has(name);\n}\n\nconst projectPathFields = new Set(['system.areapath', 'system.iterationpath']);\n\nexport function isAzureProjectPathField(referenceName: string): boolean {\n\treturn projectPathFields.has(referenceName.toLowerCase());\n}\n\nexport function toAzureWorkItemWriteFields(\n\ttypeFields: readonly AzureWorkItemTypeField[],\n\tcatalog: readonly AzureWorkItemFieldDefinition[],\n): WorkItemWriteField[] {\n\tconst definitions = new Map(catalog.map(field => [field.referenceName, field]));\n\tconst editable: WorkItemWriteField[] = [];\n\tfor (const field of typeFields) {\n\t\tconst definition = definitions.get(field.referenceName);\n\t\tif (definition?.readOnly !== false || !isCallerWritable(field.referenceName)) continue;\n\n\t\teditable.push({\n\t\t\treferenceName: field.referenceName,\n\t\t\tname: field.name,\n\t\t\ttype: definition.type,\n\t\t\trequired: field.alwaysRequired === true && !isAzureProjectPathField(field.referenceName),\n\t\t\t...(Array.isArray(field.allowedValues) &&\n\t\t\t\tfield.allowedValues.length !== 0 && { allowedValues: structuredClone(field.allowedValues) }),\n\t\t\t...(field.defaultValue != null && { defaultValue: structuredClone(field.defaultValue) }),\n\t\t\t...(typeof field.helpText === 'string' && { helpText: field.helpText }),\n\t\t});\n\t}\n\treturn editable;\n}\n\nexport function getAzureWorkItemBodyField(\n\tfields: readonly WorkItemWriteField[],\n\tcatalog: readonly AzureWorkItemFieldDefinition[],\n\tvalues?: Readonly<Record<string, unknown>>,\n): string | undefined {\n\tconst html = toAzureWorkItemHtmlFields(catalog);\n\tconst current = getAzureWorkItemDescription(values, html)?.field.referenceName;\n\tif (current != null && fields.some(field => field.referenceName === current)) return current;\n\n\tconst available = Object.fromEntries(\n\t\tfields\n\t\t\t.filter(field => field.type.toLowerCase() === 'html')\n\t\t\t.map(field => [field.referenceName, field.referenceName]),\n\t);\n\treturn getAzureWorkItemDescription(available, html)?.field.referenceName;\n}\n\nexport function getAzureWorkItemTransitionTargets(\n\ttype: AzureWorkItemTypeMetadata,\n\tstates: readonly WorkItemState[],\n\tfrom: string,\n): WorkItemState[] {\n\tconst transitions = type.transitions != null && Object.hasOwn(type.transitions, from) ? type.transitions[from] : [];\n\tconst targets = new Set(Array.isArray(transitions) ? transitions.map(transition => transition?.to) : []);\n\treturn states.filter(state => state.name !== from && targets.has(state.name));\n}\n\nconst testArtifactTypes = new Set([\n\t'microsoft.vsts.workitemtypes.testplan',\n\t'microsoft.vsts.workitemtypes.testsuite',\n\t'microsoft.vsts.workitemtypes.testcase',\n\t'microsoft.vsts.workitemtypes.sharedstep',\n\t'microsoft.vsts.workitemtypes.sharedparameter',\n]);\nconst testArtifactCategories = new Set([\n\t'microsoft.testplancategory',\n\t'microsoft.testsuitecategory',\n\t'microsoft.testcasecategory',\n\t'microsoft.sharedstepcategory',\n\t'microsoft.sharedparametercategory',\n]);\n\nexport function isAzureTestArtifact(\n\ttype: AzureWorkItemTypeMetadata,\n\tcategories: readonly AzureWorkItemTypeCategory[] = [],\n): boolean {\n\tif (testArtifactTypes.has(type.referenceName.toLowerCase())) return true;\n\n\tconst name = type.name.toLowerCase();\n\treturn categories.some(\n\t\tcategory =>\n\t\t\ttypeof category?.referenceName === 'string' &&\n\t\t\ttestArtifactCategories.has(category.referenceName.toLowerCase()) &&\n\t\t\tArray.isArray(category.workItemTypes) &&\n\t\t\tcategory.workItemTypes.some(\n\t\t\t\tmember => typeof member?.name === 'string' && member.name.toLowerCase() === name,\n\t\t\t),\n\t);\n}\n"],"mappings":";;AAsBA,MAAM,uCAAuB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,SAAS,iBAAiB,eAAgC;CACzD,MAAM,OAAO,cAAc,YAAY;CACvC,OAAO,CAAC,KAAK,WAAW,SAAS,KAAK,qBAAqB,IAAI,IAAI;AACpE;AAEA,MAAM,oCAAoB,IAAI,IAAI,CAAC,mBAAmB,sBAAsB,CAAC;AAE7E,SAAgB,wBAAwB,eAAgC;CACvE,OAAO,kBAAkB,IAAI,cAAc,YAAY,CAAC;AACzD;AAEA,SAAgB,2BACf,YACA,SACuB;CACvB,MAAM,cAAc,IAAI,IAAI,QAAQ,KAAI,UAAS,CAAC,MAAM,eAAe,KAAK,CAAC,CAAC;CAC9E,MAAM,WAAiC,CAAC;CACxC,KAAK,MAAM,SAAS,YAAY;EAC/B,MAAM,aAAa,YAAY,IAAI,MAAM,aAAa;EACtD,IAAI,YAAY,aAAa,SAAS,CAAC,iBAAiB,MAAM,aAAa,GAAG;EAE9E,SAAS,KAAK;GACb,eAAe,MAAM;GACrB,MAAM,MAAM;GACZ,MAAM,WAAW;GACjB,UAAU,MAAM,mBAAmB,QAAQ,CAAC,wBAAwB,MAAM,aAAa;GACvF,GAAI,MAAM,QAAQ,MAAM,aAAa,KACpC,MAAM,cAAc,WAAW,KAAK,EAAE,eAAe,gBAAgB,MAAM,aAAa,EAAE;GAC3F,GAAI,MAAM,gBAAgB,QAAQ,EAAE,cAAc,gBAAgB,MAAM,YAAY,EAAE;GACtF,GAAI,OAAO,MAAM,aAAa,YAAY,EAAE,UAAU,MAAM,SAAS;EACtE,CAAC;CACF;CACA,OAAO;AACR;AAEA,SAAgB,0BACf,QACA,SACA,QACqB;CACrB,MAAM,OAAO,0BAA0B,OAAO;CAC9C,MAAM,UAAU,4BAA4B,QAAQ,IAAI,CAAC,EAAE,MAAM;CACjE,IAAI,WAAW,QAAQ,OAAO,MAAK,UAAS,MAAM,kBAAkB,OAAO,GAAG,OAAO;CAErF,MAAM,YAAY,OAAO,YACxB,OACE,QAAO,UAAS,MAAM,KAAK,YAAY,MAAM,MAAM,CAAC,CACpD,KAAI,UAAS,CAAC,MAAM,eAAe,MAAM,aAAa,CAAC,CAC1D;CACA,OAAO,4BAA4B,WAAW,IAAI,CAAC,EAAE,MAAM;AAC5D;AAEA,SAAgB,kCACf,MACA,QACA,MACkB;CAClB,MAAM,cAAc,KAAK,eAAe,QAAQ,OAAO,OAAO,KAAK,aAAa,IAAI,IAAI,KAAK,YAAY,QAAQ,CAAC;CAClH,MAAM,UAAU,IAAI,IAAI,MAAM,QAAQ,WAAW,IAAI,YAAY,KAAI,eAAc,YAAY,EAAE,IAAI,CAAC,CAAC;CACvG,OAAO,OAAO,QAAO,UAAS,MAAM,SAAS,QAAQ,QAAQ,IAAI,MAAM,IAAI,CAAC;AAC7E;AAEA,MAAM,oCAAoB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;AACD,CAAC;AACD,MAAM,yCAAyB,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,SAAgB,oBACf,MACA,aAAmD,CAAC,GAC1C;CACV,IAAI,kBAAkB,IAAI,KAAK,cAAc,YAAY,CAAC,GAAG,OAAO;CAEpE,MAAM,OAAO,KAAK,KAAK,YAAY;CACnC,OAAO,WAAW,MACjB,aACC,OAAO,UAAU,kBAAkB,YACnC,uBAAuB,IAAI,SAAS,cAAc,YAAY,CAAC,KAC/D,MAAM,QAAQ,SAAS,aAAa,KACpC,SAAS,cAAc,MACtB,WAAU,OAAO,QAAQ,SAAS,YAAY,OAAO,KAAK,YAAY,MAAM,IAC7E,CACF;AACD"}
|
|
@@ -9,11 +9,13 @@ import { PullRequestUrlIdentity } from "../../../git/utils/pullRequest.utils.js"
|
|
|
9
9
|
import { AuthenticationSessionLike, ProviderAuthenticationSession, TokenWithInfo } from "../authentication/models.js";
|
|
10
10
|
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from "../constants.js";
|
|
11
11
|
import { IntegrationAuthenticationProviderDescriptor } from "../authentication/integrationAuthenticationProvider.js";
|
|
12
|
+
import { WorkItemWriteScope } from "../models/workItemWrites.js";
|
|
12
13
|
import { IssueEtagFields, IssueEtagInclude, PullRequestEtagFields, PullRequestEtagInclude } from "../reads/etag.js";
|
|
13
14
|
import { ProviderOrganization, ProviderWarningCause, ProviderWarningScope } from "../results.js";
|
|
14
15
|
import { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from "../models/publicIntegration.js";
|
|
15
16
|
import { ProviderRefusal } from "../collectionMetadata.js";
|
|
16
17
|
import { AzureOrganizationDescriptor, AzureProjectDescriptor, AzureRemoteRepositoryDescriptor, AzureRepositoryDescriptor } from "./azure/models.js";
|
|
18
|
+
import { AzureWorkItemWriter } from "./azureWorkItemWrites.js";
|
|
17
19
|
import { AccountWideIssuesResult, SearchMyIssuesOptions } from "../models/issueReads.js";
|
|
18
20
|
import "../models/integration.js";
|
|
19
21
|
import { ProviderApiCollectionResult, ProviderApiPagedResult, ProviderAzureResource, ProviderHierarchyResult, ProviderIssue, ProviderPullRequest, ProviderRepository } from "./models.js";
|
|
@@ -447,6 +449,7 @@ export declare class AzureDevOpsIntegration extends AzureDevOpsIntegrationBase<G
|
|
|
447
449
|
readonly name: string;
|
|
448
450
|
get domain(): string;
|
|
449
451
|
protected apiBaseUrlFor(_session: ProviderAuthenticationSession): string;
|
|
452
|
+
getWorkItemWriter(options: WorkItemWriteScope): Promise<AzureWorkItemWriter | undefined>;
|
|
450
453
|
}
|
|
451
454
|
//#endregion
|
|
452
455
|
//# sourceMappingURL=azureDevOps.d.ts.map
|
|
@@ -10,9 +10,10 @@ import { throwIfCallerContractError, toCollectionScopeFailure } from "../collect
|
|
|
10
10
|
import "../providerFilters.js";
|
|
11
11
|
import { collectProviderPagedResult, flatSettledResultsOrThrow, mergeCollectionMetadata, resolveBranchPullRequests, selectBranchPullRequests } from "./utils/providerPaging.js";
|
|
12
12
|
import { providersMetadata } from "./metadata.js";
|
|
13
|
-
import { toTokenWithInfo } from "../authentication/models.js";
|
|
13
|
+
import { getSessionIdentity, toTokenWithInfo } from "../authentication/models.js";
|
|
14
14
|
import { fromProviderIssue, fromProviderPullRequest, getProviderPullRequestIdentity, isNativePullRequest, issueNamesPeople, providerPullRequestMatchesSearch, pullRequestNamesPeople, toIssueShape, toProviderIssueStates, toProviderPullRequestStates } from "./models.js";
|
|
15
15
|
import { toAzurePullRequestEtagFields, toAzureWorkItemEtagFields } from "./azure/models.js";
|
|
16
|
+
import { WorkItemWriteError } from "./azureWorkItemWriteErrors.js";
|
|
16
17
|
import { decodeAzurePathSegment, getAzurePullRequestIdentityFromMaybeUrl, getAzureRepositoryIdentity } from "./azure/azure.utils.js";
|
|
17
18
|
import { GitHostIntegration } from "../models/gitHostIntegration.js";
|
|
18
19
|
import { discoveryCacheTtl } from "./utils/discoveryCache.js";
|
|
@@ -1417,6 +1418,16 @@ var AzureDevOpsIntegration = class extends AzureDevOpsIntegrationBase {
|
|
|
1417
1418
|
apiBaseUrlFor(_session) {
|
|
1418
1419
|
return "https://dev.azure.com";
|
|
1419
1420
|
}
|
|
1421
|
+
async getWorkItemWriter(options) {
|
|
1422
|
+
const session = await this.resolveReadSessionOrThrow(options.connectionId, void 0);
|
|
1423
|
+
if (session?.id !== options.connectionId || !session.accessToken) return void 0;
|
|
1424
|
+
if (session.type === "pat") throw new WorkItemWriteError("unsupported");
|
|
1425
|
+
const isSessionCurrent = this.authenticationService.usesHostAuthenticationProvider(this.id) ? async () => {
|
|
1426
|
+
const current = await this.resolveReadSessionOrThrow(options.connectionId, void 0);
|
|
1427
|
+
return current != null && getSessionIdentity(current) === getSessionIdentity(session) && current.account?.id === session.account?.id;
|
|
1428
|
+
} : this.authenticationService.trackStoredSession(this.id, session);
|
|
1429
|
+
return (await this.getProvidersApi()).getAzureWorkItemWriter(options, session, isSessionCurrent);
|
|
1430
|
+
}
|
|
1420
1431
|
};
|
|
1421
1432
|
//#endregion
|
|
1422
1433
|
export { AzureDevOpsIntegration, AzureDevOpsIntegrationBase, findAzureRepositoryApiBaseUrl, getAzureRepositoryApiBaseUrl, getAzureScopeVirtualDirectory, isAzureProjectlessCandidate, markMyGroupReviews, resolveAzureProjectlessRepository, sameAzureName, toAzureReviewerReads, uniqueAzureNames };
|