@gitkraken/core-gitlens 0.51.1 → 0.53.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 +15 -1
- package/dist/_types/provider-apis/types/exportedTypes/github.d.ts +75 -0
- package/dist/_types/provider-apis/types/exportedTypes/types.d.ts +7 -0
- 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/git-github/api/issueWrites.js +1 -1
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.d.ts +10 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +75 -23
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.d.ts +49 -0
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.js +118 -0
- package/dist/plus/integrations/authentication/cloudIntegrationObservations.js.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +45 -25
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +409 -141
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +12 -3
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +39 -7
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/authentication/models.d.ts +6 -0
- package/dist/plus/integrations/authentication/models.js +9 -1
- package/dist/plus/integrations/authentication/models.js.map +1 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.d.ts +17 -2
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +84 -16
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.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 +182 -39
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +3 -0
- package/dist/plus/integrations/models/integration.d.ts +4 -0
- package/dist/plus/integrations/models/integration.js +61 -16
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueRelationships.d.ts +31 -0
- package/dist/plus/integrations/models/issueRelationships.js +0 -0
- package/dist/plus/integrations/models/workItemWrites.d.ts +34 -2
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +4 -3
- package/dist/plus/integrations/providers/azureDevOps.js +6 -6
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +3 -0
- package/dist/plus/integrations/providers/azureDevOpsServer.js +14 -0
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.d.ts +4 -0
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +34 -2
- package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -1
- package/dist/plus/integrations/providers/azureWorkItemWrites.d.ts +5 -2
- package/dist/plus/integrations/providers/azureWorkItemWrites.js +57 -14
- package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +8 -0
- package/dist/plus/integrations/providers/github.js +162 -2
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/providerApiClient.d.ts +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +33 -14
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providerErrors.d.ts +1 -0
- package/dist/plus/integrations/providers/providerErrors.js +1 -2
- package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +10 -4
- package/dist/plus/integrations/providers/providersApi.js +21 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +61 -0
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ function createProviderApiRequest(fetch, userAgent) {
|
|
|
12
12
|
...userAgent != null ? { "User-Agent": userAgent } : {},
|
|
13
13
|
...options.headers
|
|
14
14
|
}
|
|
15
|
-
}), () => hasAuthorization(options.headers));
|
|
15
|
+
}), () => hasAuthorization(options.headers), url);
|
|
16
16
|
});
|
|
17
17
|
} catch (ex) {
|
|
18
18
|
throw markRequestError(ex, {
|
|
@@ -22,7 +22,7 @@ function createProviderApiRequest(fetch, userAgent) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
async function parseFetchResponseForApi(response, sentCredential) {
|
|
25
|
+
async function parseFetchResponseForApi(response, sentCredential, requestUrl = response.url) {
|
|
26
26
|
const contentType = (response.headers.get("content-type") || "").toLowerCase();
|
|
27
27
|
if (response.status !== 401 && response.status !== 429 && response.status < 500 && getAuthenticatedUser(response.headers) === "anonymous" && sentCredential?.() === true) {
|
|
28
28
|
response.body?.cancel().catch(() => void 0);
|
|
@@ -33,20 +33,39 @@ async function parseFetchResponseForApi(response, sentCredential) {
|
|
|
33
33
|
}
|
|
34
34
|
let body;
|
|
35
35
|
let servedHtml = false;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
body
|
|
41
|
-
} else
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
37
|
+
try {
|
|
38
|
+
if (!response.ok && requestUrl === "https://api.github.com/graphql") {
|
|
39
|
+
body = await response.json();
|
|
40
|
+
if (body == null || typeof body !== "object" || Array.isArray(body)) throw new Error("Expected a GitHub GraphQL response object.");
|
|
41
|
+
} else if (contentType.startsWith("application/json")) {
|
|
42
|
+
const text = await response.text();
|
|
43
|
+
if (text.trimStart().startsWith("<")) {
|
|
44
|
+
servedHtml = true;
|
|
45
|
+
body = text;
|
|
46
|
+
} else body = text.trim().length > 0 ? JSON.parse(text) : null;
|
|
47
|
+
} else if (contentType.startsWith("text/") || contentType === "") {
|
|
48
|
+
body = await response.text();
|
|
49
|
+
servedHtml = contentType.startsWith("text/html") && body.trim().length > 0;
|
|
50
|
+
} else if (contentType.startsWith("application/vnd.github.raw+json")) body = await response.arrayBuffer();
|
|
51
|
+
else {
|
|
52
|
+
response.body?.cancel().catch(() => void 0);
|
|
53
|
+
throw new Error(`Unsupported content-type: ${contentType}`);
|
|
54
|
+
}
|
|
55
|
+
} catch (ex) {
|
|
56
|
+
if (response.ok) throw ex;
|
|
57
|
+
const retryAfter = response.status === 403 ? response.headers.get("retry-after") : null;
|
|
58
|
+
throw Object.assign(/* @__PURE__ */ new Error(`(${response.status}) Unable to decode the provider response.`), {
|
|
59
|
+
statusCode: response.status,
|
|
60
|
+
...retryAfter != null && { response: {
|
|
61
|
+
status: response.status,
|
|
62
|
+
headers: { "retry-after": retryAfter }
|
|
63
|
+
} }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
47
66
|
const result = {
|
|
48
67
|
body,
|
|
49
|
-
headers
|
|
68
|
+
headers,
|
|
50
69
|
status: response.status,
|
|
51
70
|
statusText: response.statusText
|
|
52
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerApiClient.js","names":[],"sources":["../../../../../plus/integrations/src/providers/providerApiClient.ts"],"sourcesContent":["import { captureProviderRead } from '@gitkraken/provider-apis/read-provenance';\nimport { getAuthenticatedUser } from '../errors.js';\nimport type { ProviderRequestFunction, ProviderRequestOptions, ProviderRequestResponse } from './models.js';\nimport {\n\tAnonymousResponseError,\n\tgetProviderResponseBodyMessage,\n\tmarkRequestError,\n\tUnexpectedHtmlResponseError,\n} from './providerErrors.js';\n\nexport function createProviderApiRequest(\n\tfetch: (input: string | URL, init?: RequestInit) => Promise<Response>,\n\tuserAgent?: string,\n): ProviderRequestFunction {\n\treturn async <T>({ url, ...options }: ProviderRequestOptions): Promise<ProviderRequestResponse<T>> => {\n\t\ttry {\n\t\t\treturn await captureProviderRead(async () => {\n\t\t\t\tconst response = await fetch(url, {\n\t\t\t\t\t...options,\n\t\t\t\t\theaders: { ...(userAgent != null ? { 'User-Agent': userAgent } : {}), ...options.headers },\n\t\t\t\t});\n\t\t\t\treturn parseFetchResponseForApi<T>(response, () => hasAuthorization(options.headers));\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tthrow markRequestError(ex, { url: url, method: options.method });\n\t\t}\n\t};\n}\n\nexport async function parseFetchResponseForApi<T>(\n\tresponse: Response,\n\tsentCredential?: () => boolean,\n): Promise<ProviderRequestResponse<T>> {\n\
|
|
1
|
+
{"version":3,"file":"providerApiClient.js","names":[],"sources":["../../../../../plus/integrations/src/providers/providerApiClient.ts"],"sourcesContent":["import { captureProviderRead } from '@gitkraken/provider-apis/read-provenance';\nimport { getAuthenticatedUser } from '../errors.js';\nimport type { ProviderRequestFunction, ProviderRequestOptions, ProviderRequestResponse } from './models.js';\nimport {\n\tAnonymousResponseError,\n\tgetProviderResponseBodyMessage,\n\tmarkRequestError,\n\tUnexpectedHtmlResponseError,\n} from './providerErrors.js';\n\nexport function createProviderApiRequest(\n\tfetch: (input: string | URL, init?: RequestInit) => Promise<Response>,\n\tuserAgent?: string,\n): ProviderRequestFunction {\n\treturn async <T>({ url, ...options }: ProviderRequestOptions): Promise<ProviderRequestResponse<T>> => {\n\t\ttry {\n\t\t\treturn await captureProviderRead(async () => {\n\t\t\t\tconst response = await fetch(url, {\n\t\t\t\t\t...options,\n\t\t\t\t\theaders: { ...(userAgent != null ? { 'User-Agent': userAgent } : {}), ...options.headers },\n\t\t\t\t});\n\t\t\t\treturn parseFetchResponseForApi<T>(response, () => hasAuthorization(options.headers), url);\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tthrow markRequestError(ex, { url: url, method: options.method });\n\t\t}\n\t};\n}\n\nexport async function parseFetchResponseForApi<T>(\n\tresponse: Response,\n\tsentCredential?: () => boolean,\n\trequestUrl = response.url,\n): Promise<ProviderRequestResponse<T>> {\n\tconst contentType = (response.headers.get('content-type') || '').toLowerCase();\n\n\tif (\n\t\tresponse.status !== 401 &&\n\t\tresponse.status !== 429 &&\n\t\tresponse.status < 500 &&\n\t\tgetAuthenticatedUser(response.headers) === 'anonymous' &&\n\t\tsentCredential?.() === true\n\t) {\n\t\tvoid response.body?.cancel().catch(() => undefined);\n\t\tthrow new AnonymousResponseError(response.status, {\n\t\t\theaders: Object.fromEntries(response.headers.entries()),\n\t\t\tstatus: response.status,\n\t\t});\n\t}\n\n\tlet body;\n\tlet servedHtml = false;\n\n\tconst headers = Object.fromEntries(response.headers.entries());\n\ttry {\n\t\tif (!response.ok && requestUrl === 'https://api.github.com/graphql') {\n\t\t\t// KEEP: GraphQL execution evidence can arrive with a missing or incorrect media type.\n\t\t\tbody = await response.json();\n\t\t\tif (body == null || typeof body !== 'object' || Array.isArray(body)) {\n\t\t\t\tthrow new Error('Expected a GitHub GraphQL response object.');\n\t\t\t}\n\t\t} else if (contentType.startsWith('application/json')) {\n\t\t\tconst text = await response.text();\n\t\t\tif (text.trimStart().startsWith('<')) {\n\t\t\t\tservedHtml = true;\n\t\t\t\tbody = text;\n\t\t\t} else {\n\t\t\t\tbody = text.trim().length > 0 ? JSON.parse(text) : null;\n\t\t\t}\n\t\t} else if (contentType.startsWith('text/') || contentType === '') {\n\t\t\tbody = await response.text();\n\t\t\tservedHtml = contentType.startsWith('text/html') && body.trim().length > 0;\n\t\t} else if (contentType.startsWith('application/vnd.github.raw+json')) {\n\t\t\tbody = await response.arrayBuffer();\n\t\t} else {\n\t\t\tvoid response.body?.cancel().catch(() => undefined);\n\t\t\tthrow new Error(`Unsupported content-type: ${contentType}`);\n\t\t}\n\t} catch (ex) {\n\t\tif (response.ok) throw ex;\n\n\t\tconst retryAfter = response.status === 403 ? response.headers.get('retry-after') : null;\n\t\tthrow Object.assign(new Error(`(${response.status}) Unable to decode the provider response.`), {\n\t\t\tstatusCode: response.status,\n\t\t\t...(retryAfter != null && {\n\t\t\t\tresponse: { status: response.status, headers: { 'retry-after': retryAfter } },\n\t\t\t}),\n\t\t});\n\t}\n\n\tconst result = {\n\t\tbody: body,\n\t\theaders: headers,\n\t\tstatus: response.status,\n\t\tstatusText: response.statusText,\n\t};\n\n\tif (response.ok && servedHtml) {\n\t\tthrow new UnexpectedHtmlResponseError(response.status, contentType, result);\n\t}\n\n\tif (!response.ok) {\n\t\tconst status = `(${response.status})${response.statusText ? ` ${response.statusText}` : ''}.`;\n\t\tconst detail = getProviderResponseBodyMessage(body);\n\t\tconst error = new Error(detail != null ? `${status} ${detail}` : status);\n\t\tObject.assign(error, { response: result });\n\t\tthrow error;\n\t}\n\n\treturn result;\n}\n\nfunction hasAuthorization(headers: ProviderRequestOptions['headers']): boolean {\n\tif (headers == null) return false;\n\n\treturn Object.entries(headers).some(([name, value]) => name.toLowerCase() === 'authorization' && Boolean(value));\n}\n"],"mappings":";;;;AAUA,SAAgB,yBACf,OACA,WAC0B;CAC1B,OAAO,OAAU,EAAE,KAAK,GAAG,cAA2E;EACrG,IAAI;GACH,OAAO,MAAM,oBAAoB,YAAY;IAK5C,OAAO,yBAA4B,MAJZ,MAAM,KAAK;KACjC,GAAG;KACH,SAAS;MAAE,GAAI,aAAa,OAAO,EAAE,cAAc,UAAU,IAAI,CAAC;MAAI,GAAG,QAAQ;KAAQ;IAC1F,CAAC,SACkD,iBAAiB,QAAQ,OAAO,GAAG,GAAG;GAC1F,CAAC;EACF,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S,YAAY;OAC5B;GACN,SAAc,MAAM,OAAO,CAAC,CAAC,YAAY,KAAA,CAAS;GAClD,MAAM,IAAI,MAAM,6BAA6B,aAAa;EAC3D;CACD,SAAS,IAAI;EACZ,IAAI,SAAS,IAAI,MAAM;EAEvB,MAAM,aAAa,SAAS,WAAW,MAAM,SAAS,QAAQ,IAAI,aAAa,IAAI;EACnF,MAAM,OAAO,uBAAO,IAAI,MAAM,IAAI,SAAS,OAAO,0CAA0C,GAAG;GAC9F,YAAY,SAAS;GACrB,GAAI,cAAc,QAAQ,EACzB,UAAU;IAAE,QAAQ,SAAS;IAAQ,SAAS,EAAE,eAAe,WAAW;GAAE,EAC7E;EACD,CAAC;CACF;CAEA,MAAM,SAAS;EACR;EACG;EACT,QAAQ,SAAS;EACjB,YAAY,SAAS;CACtB;CAEA,IAAI,SAAS,MAAM,YAClB,MAAM,IAAI,4BAA4B,SAAS,QAAQ,aAAa,MAAM;CAG3E,IAAI,CAAC,SAAS,IAAI;EACjB,MAAM,SAAS,IAAI,SAAS,OAAO,GAAG,SAAS,aAAa,IAAI,SAAS,eAAe,GAAG;EAC3F,MAAM,SAAS,+BAA+B,IAAI;EAClD,MAAM,QAAQ,IAAI,MAAM,UAAU,OAAO,GAAG,OAAO,GAAG,WAAW,MAAM;EACvE,OAAO,OAAO,OAAO,EAAE,UAAU,OAAO,CAAC;EACzC,MAAM;CACP;CAEA,OAAO;AACR;AAEA,SAAS,iBAAiB,SAAqD;CAC9E,IAAI,WAAW,MAAM,OAAO;CAE5B,OAAO,OAAO,QAAQ,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,WAAW,KAAK,YAAY,MAAM,mBAAmB,QAAQ,KAAK,CAAC;AAChH"}
|
|
@@ -76,6 +76,7 @@ type SanitizedErrorResponse = {
|
|
|
76
76
|
headers: Record<string, string>;
|
|
77
77
|
status: number;
|
|
78
78
|
};
|
|
79
|
+
export declare function sanitizeErrorResponse(status: number, response: ProviderErrorResponse | undefined): SanitizedErrorResponse;
|
|
79
80
|
export declare function isAzureProviderId(providerId: IntegrationIds): providerId is GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer;
|
|
80
81
|
export declare function isGitHubProviderId(providerId: IntegrationIds): providerId is GitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise;
|
|
81
82
|
/**
|
|
@@ -109,7 +109,6 @@ const unloggableResponseHeaders = /* @__PURE__ */ new Set([
|
|
|
109
109
|
"x-api-key",
|
|
110
110
|
"x-auth-token"
|
|
111
111
|
]);
|
|
112
|
-
/** Strips the credential-bearing headers from a response and cuts its body to a diagnostic prefix. */
|
|
113
112
|
function sanitizeErrorResponse(status, response) {
|
|
114
113
|
const headers = {};
|
|
115
114
|
for (const [name, value] of Object.entries(response?.headers ?? {})) {
|
|
@@ -274,6 +273,6 @@ function getProviderResponseBodyMessage(body) {
|
|
|
274
273
|
return message ? message.slice(0, maxProviderErrorBodyLength) : void 0;
|
|
275
274
|
}
|
|
276
275
|
//#endregion
|
|
277
|
-
export { AnonymousResponseError, CommitReadRefusedError, UnexpectedHtmlResponseError, UnexpectedResponseError, getProviderResponseBodyMessage, githubGraphQLInt32Max, isAzureProviderId, isCommitReadRefusal, isGitHubProviderId, isJiraMissingProjectError, isJiraServerMissingProjectError, isLinearRateLimitedBody, isNotFoundResponse, isProviderIssueNotFoundError, markRequestError, throwProviderError };
|
|
276
|
+
export { AnonymousResponseError, CommitReadRefusedError, UnexpectedHtmlResponseError, UnexpectedResponseError, getProviderResponseBodyMessage, githubGraphQLInt32Max, isAzureProviderId, isCommitReadRefusal, isGitHubProviderId, isJiraMissingProjectError, isJiraServerMissingProjectError, isLinearRateLimitedBody, isNotFoundResponse, isProviderIssueNotFoundError, markRequestError, sanitizeErrorResponse, throwProviderError };
|
|
278
277
|
|
|
279
278
|
//# sourceMappingURL=providerErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerErrors.js","names":[],"sources":["../../../../../plus/integrations/src/providers/providerErrors.ts"],"sourcesContent":["import { Logger } from '@gitlens/utils/logger.js';\nimport type { TokenWithInfo } from '../authentication/models.js';\nimport type { IntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { ResponseHeaders } from '../errors.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tgetAuthenticatedUser,\n\tisProviderUnreachableError,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoError,\n\ttoRateLimitError,\n} from '../errors.js';\n\nconst maxProviderErrorBodyLength = 500;\n\n/**\n * A 2xx response carrying an HTML page instead of data.\n *\n * Azure DevOps answers a rejected credential by redirecting to its sign-in page, which then returns\n * `203 text/html` rather than `401`. `response.ok` spans the whole 200-299 range, so that page used to be read as\n * a successful body and handed to provider code typed as the JSON it is not — surfacing as an opaque `TypeError`\n * deep inside a provider, or as nothing at all on a route that returns `void`, which made a bad credential look\n * like a successful write (GKDEV-3617).\n *\n * `provider-apis` 0.59.0 raises its own error for this, but only from the transport it wraps; this package passes\n * its own already-parsed request function, so the check has to live here too.\n *\n * The message carries no URL, and the attached response is stripped of its credential-bearing headers and cut to\n * a diagnostic prefix: an error is something a consumer may reasonably log or forward, and the response it is\n * built from is a sign-in page carrying a session cookie.\n */\nexport class UnexpectedHtmlResponseError extends Error {\n\tstatic is(ex: unknown): ex is UnexpectedHtmlResponseError {\n\t\treturn ex instanceof UnexpectedHtmlResponseError;\n\t}\n\n\treadonly response: SanitizedErrorResponse;\n\n\tconstructor(status: number, contentType: string, response: ProviderErrorResponse | undefined) {\n\t\tsuper(`(${status}) Expected data but the provider returned an HTML page (content-type: ${contentType})`);\n\n\t\tthis.response = sanitizeErrorResponse(status, response);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n/**\n * A provider read that failed on the data a request returned rather than on the request: `provider-apis` reads a\n * response body as the shape it expects without checking it, so a 2xx carrying anything else (a gateway's JSON\n * error, `{}`, `null`, a GraphQL answer with neither data nor errors) surfaces as a `TypeError` thrown deep inside the\n * read, such as `response.body.map is not a function` from Jira Cloud's site list or Trello's boards, or\n * `Cannot read properties of undefined (reading 'id')` from Linear's organization. See {@link throwProviderError}.\n *\n * The message is the readable one a warning carries. The `TypeError` is kept as `original`, and a log line, which\n * prints the error through `toString()`, names it too.\n */\nexport class UnexpectedResponseError extends Error {\n\tstatic is(ex: unknown): ex is UnexpectedResponseError {\n\t\treturn ex instanceof UnexpectedResponseError;\n\t}\n\n\tconstructor(readonly original: Error) {\n\t\tsuper('Expected data but the provider returned an unexpected response');\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n\n\toverride toString(): string {\n\t\treturn `${super.toString()} (${String(this.original)})`;\n\t}\n}\n\n/** What the request function `ProvidersApi` hands `provider-apis` threw itself: see {@link markRequestError}. */\nconst requestErrors = new WeakMap<object, { path: string; method: string } | undefined>();\n\n/**\n * Records an error the request function threw itself (a transport failure, or a response it refused), so\n * {@link throwProviderError} never reads it as data a read could not handle, whatever the host's fetch throws.\n * Returns `ex`, to rethrow.\n */\nexport function markRequestError(ex: unknown, request?: { url: string; method?: string }): unknown {\n\tif (ex != null && typeof ex === 'object') {\n\t\trequestErrors.set(\n\t\t\tex,\n\t\t\trequest != null && URL.canParse(request.url)\n\t\t\t\t? { path: new URL(request.url).pathname, method: (request.method ?? 'GET').toUpperCase() }\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\treturn ex;\n}\n\n/**\n * A response that names the anonymous user (`X-AUSERNAME: anonymous`) to a request that carried a credential.\n *\n * Jira Data Center serves a token it rejects as the anonymous user rather than refusing it: measured against Jira\n * Data Center 10.7.3 with a revoked token, `/rest/api/2/project` answers `200 []` and a project search answers the\n * same `400` it gives a deleted project. Read as data, that is an account with no projects, and a selected project\n * looks deleted. The server only names `anonymous` when the credential did not authenticate, so the response is the\n * credential's rejection whatever its status, except a 401, which already fails as one, and a 429 or a 5xx, which\n * prove nothing about the credential.\n *\n * Its response keeps only the status and headers, stripped like {@link UnexpectedHtmlResponseError}'s.\n */\nexport class AnonymousResponseError extends Error {\n\tstatic is(ex: unknown): ex is AnonymousResponseError {\n\t\treturn ex instanceof AnonymousResponseError;\n\t}\n\n\treadonly response: SanitizedErrorResponse;\n\n\tconstructor(status: number, response: ProviderErrorResponse | undefined) {\n\t\tsuper(`(${status}) The provider served a request sent with a credential as the anonymous user`);\n\n\t\tthis.response = sanitizeErrorResponse(status, response);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\ntype ProviderErrorResponse = { body?: unknown; headers?: Record<string, string>; status?: number };\ntype SanitizedErrorResponse = { body?: string; headers: Record<string, string>; status: number };\n\n/**\n * Response headers a rejected-credential page carries that must not ride along on an error: the session cookie it\n * sets, the challenges whose base64 payload decodes to the tenant or the internal domain, and the request-side\n * names a substituted fetch can echo back onto a response.\n */\nconst unloggableResponseHeaders = new Set([\n\t'authentication-info',\n\t'authorization',\n\t'cookie',\n\t'proxy-authenticate',\n\t'proxy-authentication-info',\n\t'proxy-authorization',\n\t'set-cookie',\n\t'www-authenticate',\n\t'x-api-key',\n\t'x-auth-token',\n]);\n\n/** Strips the credential-bearing headers from a response and cuts its body to a diagnostic prefix. */\nfunction sanitizeErrorResponse(status: number, response: ProviderErrorResponse | undefined): SanitizedErrorResponse {\n\tconst headers: Record<string, string> = {};\n\tfor (const [name, value] of Object.entries(response?.headers ?? {})) {\n\t\tif (unloggableResponseHeaders.has(name.toLowerCase())) continue;\n\n\t\theaders[name] = value;\n\t}\n\n\tconst body = response?.body;\n\treturn {\n\t\t// A sign-in page runs to tens of kilobytes and none of it is a diagnostic; keep only what identifies it.\n\t\t...(typeof body === 'string' ? { body: body.slice(0, maxProviderErrorBodyLength) } : {}),\n\t\theaders: headers,\n\t\tstatus: response?.status ?? status,\n\t};\n}\n\nconst linearIssueNotFoundMessage = /^Linear issue not found: .+$/i;\n\n/**\n * What Linear actually answers for an identifier it can't resolve: HTTP 200 with the single GraphQL error\n * `Entity not found: Issue` (`INPUT_ERROR`), which provider-apis rethrows as `Linear GraphQL errors: <messages>`, the\n * response not attached. Only that one message proves the miss; any other error, or another alongside it, is a\n * failure.\n */\nconst linearIssueEntityNotFoundMessage = /^Linear GraphQL errors: Entity not found: Issue$/;\n\ntype ProviderGraphQLError = {\n\tmessage?: unknown;\n\textensions?: { code?: unknown };\n};\n\nfunction getProviderGraphQLErrors(body: unknown): ProviderGraphQLError[] {\n\tif (body == null || typeof body !== 'object') return [];\n\n\tconst errors = (body as { errors?: unknown }).errors;\n\treturn Array.isArray(errors)\n\t\t? errors.filter((error): error is ProviderGraphQLError => error != null && typeof error === 'object')\n\t\t: [];\n}\n\nexport function isAzureProviderId(\n\tproviderId: IntegrationIds,\n): providerId is GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer {\n\treturn (\n\t\tproviderId === GitCloudHostIntegrationId.AzureDevOps ||\n\t\tproviderId === GitSelfManagedHostIntegrationId.AzureDevOpsServer\n\t);\n}\n\nexport function isGitHubProviderId(\n\tproviderId: IntegrationIds,\n): providerId is GitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise {\n\treturn (\n\t\tproviderId === GitCloudHostIntegrationId.GitHub ||\n\t\tproviderId === GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t);\n}\n\n/**\n * GitHub's GraphQL schema declares coordinate variables (issue/PR number) as `Int!`, a 32-bit signed integer.\n * A number above this coerces with no `path` on the error, which fails every aliased target in the chunk rather\n * than just the one with the bad number — so the read layer refuses the whole call up front instead.\n */\nexport const githubGraphQLInt32Max = 2147483647;\n\nfunction isGitHubGraphQLRateLimitError(providerId: IntegrationIds, ex: unknown): boolean {\n\tif (!isGitHubProviderId(providerId)) return false;\n\n\tconst errors = (ex as { graphQLErrors?: unknown } | null | undefined)?.graphQLErrors;\n\treturn (\n\t\tArray.isArray(errors) &&\n\t\terrors.some(e => {\n\t\t\tconst type = (e as { type?: unknown } | null | undefined)?.type;\n\t\t\treturn type === 'RATE_LIMITED' || type === 'RATE_LIMIT';\n\t\t})\n\t);\n}\n\nfunction isLinearRateLimitError(providerId: IntegrationIds, ex: unknown): boolean {\n\tif (providerId !== IssuesCloudHostIntegrationId.Linear) return false;\n\n\treturn isLinearRateLimitedBody((ex as { response?: { body?: unknown } }).response?.body);\n}\n\n/** Whether a Linear GraphQL response body reports throttling. */\nexport function isLinearRateLimitedBody(body: unknown): boolean {\n\treturn getProviderGraphQLErrors(body).some(error => error.extensions?.code === 'RATELIMITED');\n}\n\nexport function isProviderIssueNotFoundError(providerId: IntegrationIds, ex: unknown): boolean {\n\t// A rejected credential is not a missing issue, whatever status the server served it with.\n\tif (AnonymousResponseError.is(ex)) return false;\n\n\tif (providerId === IssuesCloudHostIntegrationId.Linear) {\n\t\treturn (\n\t\t\tex instanceof Error &&\n\t\t\t(linearIssueNotFoundMessage.test(ex.message) || linearIssueEntityNotFoundMessage.test(ex.message))\n\t\t);\n\t}\n\n\tconst response = (ex as { response?: { status?: unknown; body?: unknown } } | null | undefined)?.response;\n\tconst status = response?.status;\n\tif (\n\t\tproviderId === IssuesCloudHostIntegrationId.Jira ||\n\t\tproviderId === IssuesSelfManagedHostIntegrationId.JiraServer\n\t) {\n\t\t// SDK reads discover fields and sites first; only the issue endpoint can prove an issue's absence.\n\t\tconst request = ex != null && typeof ex === 'object' ? requestErrors.get(ex) : undefined;\n\t\tconst messages = (response?.body as { errorMessages?: unknown } | null | undefined)?.errorMessages;\n\t\treturn (\n\t\t\tstatus === 404 &&\n\t\t\trequest?.method === 'GET' &&\n\t\t\t/\\/rest\\/api\\/[23]\\/issue\\/[^/]+$/.test(request.path) &&\n\t\t\tArray.isArray(messages) &&\n\t\t\tmessages.length > 0 &&\n\t\t\tmessages.every(message => typeof message === 'string' && message.trim().length > 0)\n\t\t);\n\t}\n\n\treturn status === 404 || status === 410 || status === 422;\n}\n\nexport function isNotFoundResponse(ex: unknown): boolean {\n\treturn RequestNotFoundError.is(ex) && ex.original instanceof ProviderFetchError && ex.original.status === 404;\n}\n\nexport class CommitReadRefusedError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly original?: Error,\n\t) {\n\t\tsuper(message);\n\t}\n}\n\nexport function isCommitReadRefusal(ex: unknown): ex is AuthenticationError | RequestClientError {\n\treturn (\n\t\t(ex instanceof AuthenticationError && ex.reason === AuthenticationErrorReason.Forbidden) ||\n\t\tex instanceof RequestClientError\n\t);\n}\n\nconst jiraMissingProjectMessage = /^The value '.*' does not exist for the field 'project'\\.?$/i;\n\n/**\n * Jira's refusal of a search scoped to a project it cannot find: `400` with\n * `{\"errorMessages\":[\"The value 'KPSC290' does not exist for the field 'project'.\"]}`, measured against Jira Data\n * Center 10.7.3 for a deleted project key and for a numeric id that names no project. Jira answers a project the\n * user lost browse permission on the same way, since it will not confirm a project the user cannot see.\n *\n * Only a `400` whose EVERY message is that one: a JQL that is wrong in some other way also answers `400`, and that\n * is a real failure rather than a project that is simply gone. Accepts the SDK's error or the `RequestClientError`\n * `throwProviderError` wraps it in, whose `original` keeps the response.\n */\nexport function isJiraMissingProjectError(ex: unknown): boolean {\n\treturn getJiraMissingProjectResponse(ex) != null;\n}\n\n/**\n * {@link isJiraMissingProjectError} for Jira Data Center, which serves a credential it rejects as the anonymous user:\n * the search then names a project the anonymous user cannot see and is refused with the very same `400`, measured\n * against Jira Data Center 10.7.3 with a revoked token. Only the user it names in `X-AUSERNAME` tells the two apart,\n * so a refusal that names no user, or `anonymous`, is a failure rather than a project that is gone.\n */\nexport function isJiraServerMissingProjectError(ex: unknown): boolean {\n\tconst user = getAuthenticatedUser(getJiraMissingProjectResponse(ex)?.headers);\n\treturn user != null && user !== 'anonymous';\n}\n\nfunction getJiraMissingProjectResponse(ex: unknown): { headers?: ResponseHeaders } | undefined {\n\tfor (const candidate of [ex, (ex as { original?: unknown } | undefined)?.original]) {\n\t\tconst response = (\n\t\t\tcandidate as { response?: { status?: unknown; body?: unknown; headers?: ResponseHeaders } } | undefined\n\t\t)?.response;\n\t\tif (response?.status !== 400) continue;\n\n\t\tconst messages = (response.body as { errorMessages?: unknown } | null | undefined)?.errorMessages;\n\t\tif (!Array.isArray(messages) || messages.length === 0) continue;\n\n\t\treturn messages.every(m => typeof m === 'string' && jiraMissingProjectMessage.test(m.trim()))\n\t\t\t? response\n\t\t\t: undefined;\n\t}\n\n\treturn undefined;\n}\n\nexport function throwProviderError(tokenWithInfo: TokenWithInfo, error: unknown): never {\n\tconst { accessToken: token, ...tokenInfo } = tokenWithInfo;\n\tconst providerId = tokenWithInfo.providerId;\n\tconst normalizedError = toError(error);\n\t// A page served with a 2xx is only known to mean a rejected credential on Azure DevOps, which answers one by\n\t// redirecting to its sign-in page (GKDEV-3617). Elsewhere it is far more likely a maintenance or WAF page in\n\t// front of a provider, and calling that an authentication failure is not free: `handleProviderException`\n\t// expires a valid cloud session on one, and counts it against the budget that disconnects the integration.\n\t// So Azure gets the specific diagnosis and every other provider gets the honest one — the response was not\n\t// data, which is a protocol failure.\n\tif (UnexpectedHtmlResponseError.is(error)) {\n\t\tthrow isAzureProviderId(providerId)\n\t\t\t? new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, normalizedError)\n\t\t\t: new RequestClientError(normalizedError);\n\t}\n\n\tif (AnonymousResponseError.is(error)) {\n\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, normalizedError);\n\t}\n\n\t// Linear reports GraphQL throttling as HTTP 400, so its structured code must win over generic 4xx handling.\n\tif (isLinearRateLimitError(providerId, error)) {\n\t\tthrow toRateLimitError(normalizedError, token);\n\t}\n\n\t// GitHub reports GraphQL throttling as HTTP 200 + `errors[].type`, which the SDK throws with no `response`.\n\tif (isGitHubGraphQLRateLimitError(providerId, error)) {\n\t\tthrow toRateLimitError(normalizedError, token);\n\t}\n\n\tconst status = (error as { response?: { status?: unknown } }).response?.status;\n\tif (typeof status === 'number') {\n\t\tswitch (status) {\n\t\t\tcase 404:\n\t\t\tcase 410:\n\t\t\tcase 422:\n\t\t\t\tthrow new RequestNotFoundError(normalizedError);\n\t\t\tcase 429:\n\t\t\t\tthrow toRateLimitError(normalizedError, token);\n\t\t\tcase 401:\n\t\t\tcase 403:\n\t\t\t\t// Some hosts overload 403 for throttling; classify that before asking the user to reconnect.\n\t\t\t\tif (isRateLimitResponse({ status: status, message: normalizedError.message })) {\n\t\t\t\t\tthrow toRateLimitError(normalizedError, token);\n\t\t\t\t}\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\ttokenInfo,\n\t\t\t\t\tstatus === 401 ? AuthenticationErrorReason.Unauthorized : AuthenticationErrorReason.Forbidden,\n\t\t\t\t\tnormalizedError,\n\t\t\t\t);\n\t\t\tdefault:\n\t\t\t\tif (status >= 400 && status < 500) {\n\t\t\t\t\tthrow new RequestClientError(normalizedError);\n\t\t\t\t}\n\t\t}\n\t}\n\n\t// A `TypeError` the request function didn't throw was thrown while reading what it returned: a body that isn't the\n\t// shape the read expects (see `UnexpectedResponseError`). A transport failure that reached here some other way stays\n\t// one. Neither a session expiry nor a strike toward disconnecting, as before: nothing says the credential is at\n\t// fault, and the provider may answer properly next time. Logged here because a warning or a fan-out's scope failure\n\t// built from it carries only the readable message, and a fan-out never reaches `handleProviderException`'s log.\n\tif (error instanceof TypeError && !requestErrors.has(error) && !isProviderUnreachableError(error)) {\n\t\tconst unexpected = new UnexpectedResponseError(error);\n\t\tLogger.warn(`${tokenWithInfo.providerId}: ${String(unexpected)}`);\n\t\tthrow unexpected;\n\t}\n\n\tthrow error;\n}\n\n/** Extracts the useful provider prose from an already-parsed SDK response body. */\nexport function getProviderResponseBodyMessage(body: unknown): string | undefined {\n\tlet message: string | undefined;\n\tif (typeof body === 'string') {\n\t\tmessage = body;\n\t} else if (body != null && typeof body === 'object') {\n\t\tconst { message: direct, error } = body as { message?: unknown; error?: unknown };\n\t\tif (typeof direct === 'string') {\n\t\t\tmessage = direct;\n\t\t} else if (typeof error === 'string') {\n\t\t\tmessage = error;\n\t\t} else if (error != null && typeof error === 'object') {\n\t\t\tconst nested = (error as { message?: unknown }).message;\n\t\t\tif (typeof nested === 'string') {\n\t\t\t\tmessage = nested;\n\t\t\t}\n\t\t}\n\t\tif (message == null) {\n\t\t\tconst graphQLError = getProviderGraphQLErrors(body)[0];\n\t\t\tif (typeof graphQLError?.message === 'string') {\n\t\t\t\tmessage = graphQLError.message;\n\t\t\t} else if (typeof graphQLError?.extensions?.code === 'string') {\n\t\t\t\tmessage = graphQLError.extensions.code;\n\t\t\t}\n\t\t}\n\t}\n\n\tmessage = message?.trim();\n\treturn message ? message.slice(0, maxProviderErrorBodyLength) : undefined;\n}\n"],"mappings":";;;;;AAuBA,MAAM,6BAA6B;;;;;;;;;;;;;;;;;AAkBnC,IAAa,8BAAb,MAAa,oCAAoC,MAAM;CACtD,OAAO,GAAG,IAAgD;EACzD,OAAO,cAAc;CACtB;CAEA;CAEA,YAAY,QAAgB,aAAqB,UAA6C;EAC7F,MAAM,IAAI,OAAO,wEAAwE,YAAY,EAAE;EAEvG,KAAK,WAAW,sBAAsB,QAAQ,QAAQ;EAEtD,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;;;;;;;;;;;AAYA,IAAa,0BAAb,MAAa,gCAAgC,MAAM;CAK7B;CAJrB,OAAO,GAAG,IAA4C;EACrD,OAAO,cAAc;CACtB;CAEA,YAAY,UAA0B;EACrC,MAAM,gEAAgE;EADlD,KAAA,WAAA;EAGpB,MAAM,oBAAoB,MAAM,UAAU;CAC3C;CAEA,WAA4B;EAC3B,OAAO,GAAG,MAAM,SAAS,EAAE,IAAI,OAAO,KAAK,QAAQ,EAAE;CACtD;AACD;;AAGA,MAAM,gCAAgB,IAAI,QAA8D;;;;;;AAOxF,SAAgB,iBAAiB,IAAa,SAAqD;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C,CAAC;GACpD,IAAI,OAAO,cAAc,YAAY,UACpC,UAAU,aAAa;QACjB,IAAI,OAAO,cAAc,YAAY,SAAS,UACpD,UAAU,aAAa,WAAW;EAEpC;CACD;CAEA,UAAU,SAAS,KAAK;CACxB,OAAO,UAAU,QAAQ,MAAM,GAAG,0BAA0B,IAAI,KAAA;AACjE"}
|
|
1
|
+
{"version":3,"file":"providerErrors.js","names":[],"sources":["../../../../../plus/integrations/src/providers/providerErrors.ts"],"sourcesContent":["import { Logger } from '@gitlens/utils/logger.js';\nimport type { TokenWithInfo } from '../authentication/models.js';\nimport type { IntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { ResponseHeaders } from '../errors.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tgetAuthenticatedUser,\n\tisProviderUnreachableError,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoError,\n\ttoRateLimitError,\n} from '../errors.js';\n\nconst maxProviderErrorBodyLength = 500;\n\n/**\n * A 2xx response carrying an HTML page instead of data.\n *\n * Azure DevOps answers a rejected credential by redirecting to its sign-in page, which then returns\n * `203 text/html` rather than `401`. `response.ok` spans the whole 200-299 range, so that page used to be read as\n * a successful body and handed to provider code typed as the JSON it is not — surfacing as an opaque `TypeError`\n * deep inside a provider, or as nothing at all on a route that returns `void`, which made a bad credential look\n * like a successful write (GKDEV-3617).\n *\n * `provider-apis` 0.59.0 raises its own error for this, but only from the transport it wraps; this package passes\n * its own already-parsed request function, so the check has to live here too.\n *\n * The message carries no URL, and the attached response is stripped of its credential-bearing headers and cut to\n * a diagnostic prefix: an error is something a consumer may reasonably log or forward, and the response it is\n * built from is a sign-in page carrying a session cookie.\n */\nexport class UnexpectedHtmlResponseError extends Error {\n\tstatic is(ex: unknown): ex is UnexpectedHtmlResponseError {\n\t\treturn ex instanceof UnexpectedHtmlResponseError;\n\t}\n\n\treadonly response: SanitizedErrorResponse;\n\n\tconstructor(status: number, contentType: string, response: ProviderErrorResponse | undefined) {\n\t\tsuper(`(${status}) Expected data but the provider returned an HTML page (content-type: ${contentType})`);\n\n\t\tthis.response = sanitizeErrorResponse(status, response);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n/**\n * A provider read that failed on the data a request returned rather than on the request: `provider-apis` reads a\n * response body as the shape it expects without checking it, so a 2xx carrying anything else (a gateway's JSON\n * error, `{}`, `null`, a GraphQL answer with neither data nor errors) surfaces as a `TypeError` thrown deep inside the\n * read, such as `response.body.map is not a function` from Jira Cloud's site list or Trello's boards, or\n * `Cannot read properties of undefined (reading 'id')` from Linear's organization. See {@link throwProviderError}.\n *\n * The message is the readable one a warning carries. The `TypeError` is kept as `original`, and a log line, which\n * prints the error through `toString()`, names it too.\n */\nexport class UnexpectedResponseError extends Error {\n\tstatic is(ex: unknown): ex is UnexpectedResponseError {\n\t\treturn ex instanceof UnexpectedResponseError;\n\t}\n\n\tconstructor(readonly original: Error) {\n\t\tsuper('Expected data but the provider returned an unexpected response');\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n\n\toverride toString(): string {\n\t\treturn `${super.toString()} (${String(this.original)})`;\n\t}\n}\n\n/** What the request function `ProvidersApi` hands `provider-apis` threw itself: see {@link markRequestError}. */\nconst requestErrors = new WeakMap<object, { path: string; method: string } | undefined>();\n\n/**\n * Records an error the request function threw itself (a transport failure, or a response it refused), so\n * {@link throwProviderError} never reads it as data a read could not handle, whatever the host's fetch throws.\n * Returns `ex`, to rethrow.\n */\nexport function markRequestError(ex: unknown, request?: { url: string; method?: string }): unknown {\n\tif (ex != null && typeof ex === 'object') {\n\t\trequestErrors.set(\n\t\t\tex,\n\t\t\trequest != null && URL.canParse(request.url)\n\t\t\t\t? { path: new URL(request.url).pathname, method: (request.method ?? 'GET').toUpperCase() }\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\treturn ex;\n}\n\n/**\n * A response that names the anonymous user (`X-AUSERNAME: anonymous`) to a request that carried a credential.\n *\n * Jira Data Center serves a token it rejects as the anonymous user rather than refusing it: measured against Jira\n * Data Center 10.7.3 with a revoked token, `/rest/api/2/project` answers `200 []` and a project search answers the\n * same `400` it gives a deleted project. Read as data, that is an account with no projects, and a selected project\n * looks deleted. The server only names `anonymous` when the credential did not authenticate, so the response is the\n * credential's rejection whatever its status, except a 401, which already fails as one, and a 429 or a 5xx, which\n * prove nothing about the credential.\n *\n * Its response keeps only the status and headers, stripped like {@link UnexpectedHtmlResponseError}'s.\n */\nexport class AnonymousResponseError extends Error {\n\tstatic is(ex: unknown): ex is AnonymousResponseError {\n\t\treturn ex instanceof AnonymousResponseError;\n\t}\n\n\treadonly response: SanitizedErrorResponse;\n\n\tconstructor(status: number, response: ProviderErrorResponse | undefined) {\n\t\tsuper(`(${status}) The provider served a request sent with a credential as the anonymous user`);\n\n\t\tthis.response = sanitizeErrorResponse(status, response);\n\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\ntype ProviderErrorResponse = { body?: unknown; headers?: Record<string, string>; status?: number };\ntype SanitizedErrorResponse = { body?: string; headers: Record<string, string>; status: number };\n\n/**\n * Response headers a rejected-credential page carries that must not ride along on an error: the session cookie it\n * sets, the challenges whose base64 payload decodes to the tenant or the internal domain, and the request-side\n * names a substituted fetch can echo back onto a response.\n */\nconst unloggableResponseHeaders = new Set([\n\t'authentication-info',\n\t'authorization',\n\t'cookie',\n\t'proxy-authenticate',\n\t'proxy-authentication-info',\n\t'proxy-authorization',\n\t'set-cookie',\n\t'www-authenticate',\n\t'x-api-key',\n\t'x-auth-token',\n]);\n\nexport function sanitizeErrorResponse(\n\tstatus: number,\n\tresponse: ProviderErrorResponse | undefined,\n): SanitizedErrorResponse {\n\tconst headers: Record<string, string> = {};\n\tfor (const [name, value] of Object.entries(response?.headers ?? {})) {\n\t\tif (unloggableResponseHeaders.has(name.toLowerCase())) continue;\n\n\t\theaders[name] = value;\n\t}\n\n\tconst body = response?.body;\n\treturn {\n\t\t// A sign-in page runs to tens of kilobytes and none of it is a diagnostic; keep only what identifies it.\n\t\t...(typeof body === 'string' ? { body: body.slice(0, maxProviderErrorBodyLength) } : {}),\n\t\theaders: headers,\n\t\tstatus: response?.status ?? status,\n\t};\n}\n\nconst linearIssueNotFoundMessage = /^Linear issue not found: .+$/i;\n\n/**\n * What Linear actually answers for an identifier it can't resolve: HTTP 200 with the single GraphQL error\n * `Entity not found: Issue` (`INPUT_ERROR`), which provider-apis rethrows as `Linear GraphQL errors: <messages>`, the\n * response not attached. Only that one message proves the miss; any other error, or another alongside it, is a\n * failure.\n */\nconst linearIssueEntityNotFoundMessage = /^Linear GraphQL errors: Entity not found: Issue$/;\n\ntype ProviderGraphQLError = {\n\tmessage?: unknown;\n\textensions?: { code?: unknown };\n};\n\nfunction getProviderGraphQLErrors(body: unknown): ProviderGraphQLError[] {\n\tif (body == null || typeof body !== 'object') return [];\n\n\tconst errors = (body as { errors?: unknown }).errors;\n\treturn Array.isArray(errors)\n\t\t? errors.filter((error): error is ProviderGraphQLError => error != null && typeof error === 'object')\n\t\t: [];\n}\n\nexport function isAzureProviderId(\n\tproviderId: IntegrationIds,\n): providerId is GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer {\n\treturn (\n\t\tproviderId === GitCloudHostIntegrationId.AzureDevOps ||\n\t\tproviderId === GitSelfManagedHostIntegrationId.AzureDevOpsServer\n\t);\n}\n\nexport function isGitHubProviderId(\n\tproviderId: IntegrationIds,\n): providerId is GitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise {\n\treturn (\n\t\tproviderId === GitCloudHostIntegrationId.GitHub ||\n\t\tproviderId === GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t);\n}\n\n/**\n * GitHub's GraphQL schema declares coordinate variables (issue/PR number) as `Int!`, a 32-bit signed integer.\n * A number above this coerces with no `path` on the error, which fails every aliased target in the chunk rather\n * than just the one with the bad number — so the read layer refuses the whole call up front instead.\n */\nexport const githubGraphQLInt32Max = 2147483647;\n\nfunction isGitHubGraphQLRateLimitError(providerId: IntegrationIds, ex: unknown): boolean {\n\tif (!isGitHubProviderId(providerId)) return false;\n\n\tconst errors = (ex as { graphQLErrors?: unknown } | null | undefined)?.graphQLErrors;\n\treturn (\n\t\tArray.isArray(errors) &&\n\t\terrors.some(e => {\n\t\t\tconst type = (e as { type?: unknown } | null | undefined)?.type;\n\t\t\treturn type === 'RATE_LIMITED' || type === 'RATE_LIMIT';\n\t\t})\n\t);\n}\n\nfunction isLinearRateLimitError(providerId: IntegrationIds, ex: unknown): boolean {\n\tif (providerId !== IssuesCloudHostIntegrationId.Linear) return false;\n\n\treturn isLinearRateLimitedBody((ex as { response?: { body?: unknown } }).response?.body);\n}\n\n/** Whether a Linear GraphQL response body reports throttling. */\nexport function isLinearRateLimitedBody(body: unknown): boolean {\n\treturn getProviderGraphQLErrors(body).some(error => error.extensions?.code === 'RATELIMITED');\n}\n\nexport function isProviderIssueNotFoundError(providerId: IntegrationIds, ex: unknown): boolean {\n\t// A rejected credential is not a missing issue, whatever status the server served it with.\n\tif (AnonymousResponseError.is(ex)) return false;\n\n\tif (providerId === IssuesCloudHostIntegrationId.Linear) {\n\t\treturn (\n\t\t\tex instanceof Error &&\n\t\t\t(linearIssueNotFoundMessage.test(ex.message) || linearIssueEntityNotFoundMessage.test(ex.message))\n\t\t);\n\t}\n\n\tconst response = (ex as { response?: { status?: unknown; body?: unknown } } | null | undefined)?.response;\n\tconst status = response?.status;\n\tif (\n\t\tproviderId === IssuesCloudHostIntegrationId.Jira ||\n\t\tproviderId === IssuesSelfManagedHostIntegrationId.JiraServer\n\t) {\n\t\t// SDK reads discover fields and sites first; only the issue endpoint can prove an issue's absence.\n\t\tconst request = ex != null && typeof ex === 'object' ? requestErrors.get(ex) : undefined;\n\t\tconst messages = (response?.body as { errorMessages?: unknown } | null | undefined)?.errorMessages;\n\t\treturn (\n\t\t\tstatus === 404 &&\n\t\t\trequest?.method === 'GET' &&\n\t\t\t/\\/rest\\/api\\/[23]\\/issue\\/[^/]+$/.test(request.path) &&\n\t\t\tArray.isArray(messages) &&\n\t\t\tmessages.length > 0 &&\n\t\t\tmessages.every(message => typeof message === 'string' && message.trim().length > 0)\n\t\t);\n\t}\n\n\treturn status === 404 || status === 410 || status === 422;\n}\n\nexport function isNotFoundResponse(ex: unknown): boolean {\n\treturn RequestNotFoundError.is(ex) && ex.original instanceof ProviderFetchError && ex.original.status === 404;\n}\n\nexport class CommitReadRefusedError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly original?: Error,\n\t) {\n\t\tsuper(message);\n\t}\n}\n\nexport function isCommitReadRefusal(ex: unknown): ex is AuthenticationError | RequestClientError {\n\treturn (\n\t\t(ex instanceof AuthenticationError && ex.reason === AuthenticationErrorReason.Forbidden) ||\n\t\tex instanceof RequestClientError\n\t);\n}\n\nconst jiraMissingProjectMessage = /^The value '.*' does not exist for the field 'project'\\.?$/i;\n\n/**\n * Jira's refusal of a search scoped to a project it cannot find: `400` with\n * `{\"errorMessages\":[\"The value 'KPSC290' does not exist for the field 'project'.\"]}`, measured against Jira Data\n * Center 10.7.3 for a deleted project key and for a numeric id that names no project. Jira answers a project the\n * user lost browse permission on the same way, since it will not confirm a project the user cannot see.\n *\n * Only a `400` whose EVERY message is that one: a JQL that is wrong in some other way also answers `400`, and that\n * is a real failure rather than a project that is simply gone. Accepts the SDK's error or the `RequestClientError`\n * `throwProviderError` wraps it in, whose `original` keeps the response.\n */\nexport function isJiraMissingProjectError(ex: unknown): boolean {\n\treturn getJiraMissingProjectResponse(ex) != null;\n}\n\n/**\n * {@link isJiraMissingProjectError} for Jira Data Center, which serves a credential it rejects as the anonymous user:\n * the search then names a project the anonymous user cannot see and is refused with the very same `400`, measured\n * against Jira Data Center 10.7.3 with a revoked token. Only the user it names in `X-AUSERNAME` tells the two apart,\n * so a refusal that names no user, or `anonymous`, is a failure rather than a project that is gone.\n */\nexport function isJiraServerMissingProjectError(ex: unknown): boolean {\n\tconst user = getAuthenticatedUser(getJiraMissingProjectResponse(ex)?.headers);\n\treturn user != null && user !== 'anonymous';\n}\n\nfunction getJiraMissingProjectResponse(ex: unknown): { headers?: ResponseHeaders } | undefined {\n\tfor (const candidate of [ex, (ex as { original?: unknown } | undefined)?.original]) {\n\t\tconst response = (\n\t\t\tcandidate as { response?: { status?: unknown; body?: unknown; headers?: ResponseHeaders } } | undefined\n\t\t)?.response;\n\t\tif (response?.status !== 400) continue;\n\n\t\tconst messages = (response.body as { errorMessages?: unknown } | null | undefined)?.errorMessages;\n\t\tif (!Array.isArray(messages) || messages.length === 0) continue;\n\n\t\treturn messages.every(m => typeof m === 'string' && jiraMissingProjectMessage.test(m.trim()))\n\t\t\t? response\n\t\t\t: undefined;\n\t}\n\n\treturn undefined;\n}\n\nexport function throwProviderError(tokenWithInfo: TokenWithInfo, error: unknown): never {\n\tconst { accessToken: token, ...tokenInfo } = tokenWithInfo;\n\tconst providerId = tokenWithInfo.providerId;\n\tconst normalizedError = toError(error);\n\t// A page served with a 2xx is only known to mean a rejected credential on Azure DevOps, which answers one by\n\t// redirecting to its sign-in page (GKDEV-3617). Elsewhere it is far more likely a maintenance or WAF page in\n\t// front of a provider, and calling that an authentication failure is not free: `handleProviderException`\n\t// expires a valid cloud session on one, and counts it against the budget that disconnects the integration.\n\t// So Azure gets the specific diagnosis and every other provider gets the honest one — the response was not\n\t// data, which is a protocol failure.\n\tif (UnexpectedHtmlResponseError.is(error)) {\n\t\tthrow isAzureProviderId(providerId)\n\t\t\t? new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, normalizedError)\n\t\t\t: new RequestClientError(normalizedError);\n\t}\n\n\tif (AnonymousResponseError.is(error)) {\n\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, normalizedError);\n\t}\n\n\t// Linear reports GraphQL throttling as HTTP 400, so its structured code must win over generic 4xx handling.\n\tif (isLinearRateLimitError(providerId, error)) {\n\t\tthrow toRateLimitError(normalizedError, token);\n\t}\n\n\t// GitHub reports GraphQL throttling as HTTP 200 + `errors[].type`, which the SDK throws with no `response`.\n\tif (isGitHubGraphQLRateLimitError(providerId, error)) {\n\t\tthrow toRateLimitError(normalizedError, token);\n\t}\n\n\tconst status = (error as { response?: { status?: unknown } }).response?.status;\n\tif (typeof status === 'number') {\n\t\tswitch (status) {\n\t\t\tcase 404:\n\t\t\tcase 410:\n\t\t\tcase 422:\n\t\t\t\tthrow new RequestNotFoundError(normalizedError);\n\t\t\tcase 429:\n\t\t\t\tthrow toRateLimitError(normalizedError, token);\n\t\t\tcase 401:\n\t\t\tcase 403:\n\t\t\t\t// Some hosts overload 403 for throttling; classify that before asking the user to reconnect.\n\t\t\t\tif (isRateLimitResponse({ status: status, message: normalizedError.message })) {\n\t\t\t\t\tthrow toRateLimitError(normalizedError, token);\n\t\t\t\t}\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\ttokenInfo,\n\t\t\t\t\tstatus === 401 ? AuthenticationErrorReason.Unauthorized : AuthenticationErrorReason.Forbidden,\n\t\t\t\t\tnormalizedError,\n\t\t\t\t);\n\t\t\tdefault:\n\t\t\t\tif (status >= 400 && status < 500) {\n\t\t\t\t\tthrow new RequestClientError(normalizedError);\n\t\t\t\t}\n\t\t}\n\t}\n\n\t// A `TypeError` the request function didn't throw was thrown while reading what it returned: a body that isn't the\n\t// shape the read expects (see `UnexpectedResponseError`). A transport failure that reached here some other way stays\n\t// one. Neither a session expiry nor a strike toward disconnecting, as before: nothing says the credential is at\n\t// fault, and the provider may answer properly next time. Logged here because a warning or a fan-out's scope failure\n\t// built from it carries only the readable message, and a fan-out never reaches `handleProviderException`'s log.\n\tif (error instanceof TypeError && !requestErrors.has(error) && !isProviderUnreachableError(error)) {\n\t\tconst unexpected = new UnexpectedResponseError(error);\n\t\tLogger.warn(`${tokenWithInfo.providerId}: ${String(unexpected)}`);\n\t\tthrow unexpected;\n\t}\n\n\tthrow error;\n}\n\n/** Extracts the useful provider prose from an already-parsed SDK response body. */\nexport function getProviderResponseBodyMessage(body: unknown): string | undefined {\n\tlet message: string | undefined;\n\tif (typeof body === 'string') {\n\t\tmessage = body;\n\t} else if (body != null && typeof body === 'object') {\n\t\tconst { message: direct, error } = body as { message?: unknown; error?: unknown };\n\t\tif (typeof direct === 'string') {\n\t\t\tmessage = direct;\n\t\t} else if (typeof error === 'string') {\n\t\t\tmessage = error;\n\t\t} else if (error != null && typeof error === 'object') {\n\t\t\tconst nested = (error as { message?: unknown }).message;\n\t\t\tif (typeof nested === 'string') {\n\t\t\t\tmessage = nested;\n\t\t\t}\n\t\t}\n\t\tif (message == null) {\n\t\t\tconst graphQLError = getProviderGraphQLErrors(body)[0];\n\t\t\tif (typeof graphQLError?.message === 'string') {\n\t\t\t\tmessage = graphQLError.message;\n\t\t\t} else if (typeof graphQLError?.extensions?.code === 'string') {\n\t\t\t\tmessage = graphQLError.extensions.code;\n\t\t\t}\n\t\t}\n\t}\n\n\tmessage = message?.trim();\n\treturn message ? message.slice(0, maxProviderErrorBodyLength) : undefined;\n}\n"],"mappings":";;;;;AAuBA,MAAM,6BAA6B;;;;;;;;;;;;;;;;;AAkBnC,IAAa,8BAAb,MAAa,oCAAoC,MAAM;CACtD,OAAO,GAAG,IAAgD;EACzD,OAAO,cAAc;CACtB;CAEA;CAEA,YAAY,QAAgB,aAAqB,UAA6C;EAC7F,MAAM,IAAI,OAAO,wEAAwE,YAAY,EAAE;EAEvG,KAAK,WAAW,sBAAsB,QAAQ,QAAQ;EAEtD,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;;;;;;;;;;;AAYA,IAAa,0BAAb,MAAa,gCAAgC,MAAM;CAK7B;CAJrB,OAAO,GAAG,IAA4C;EACrD,OAAO,cAAc;CACtB;CAEA,YAAY,UAA0B;EACrC,MAAM,gEAAgE;E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UACrB,UAAU;OACJ,IAAI,OAAO,UAAU,UAC3B,UAAU;OACJ,IAAI,SAAS,QAAQ,OAAO,UAAU,UAAU;GACtD,MAAM,SAAU,MAAgC;GAChD,IAAI,OAAO,WAAW,UACrB,UAAU;EAEZ;EACA,IAAI,WAAW,MAAM;GACpB,MAAM,eAAe,yBAAyB,IAAI,CAAC,CAAC;GACpD,IAAI,OAAO,cAAc,YAAY,UACpC,UAAU,aAAa;QACjB,IAAI,OAAO,cAAc,YAAY,SAAS,UACpD,UAAU,aAAa,WAAW;EAEpC;CACD;CAEA,UAAU,SAAS,KAAK;CACxB,OAAO,UAAU,QAAQ,MAAM,GAAG,0BAA0B,IAAI,KAAA;AACjE"}
|
|
@@ -6,7 +6,7 @@ import { ProviderAuthenticationSession, TokenOptInfo, TokenWithInfo } from "../a
|
|
|
6
6
|
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId } from "../constants.js";
|
|
7
7
|
import { AzurePullRequestCreateCapabilityOptions } from "../models/azurePullRequestWrites.js";
|
|
8
8
|
import { IssueTrackerWriteConnection } from "../models/issueTrackerWrites.js";
|
|
9
|
-
import {
|
|
9
|
+
import { AzureServerWorkItemWriteScope, AzureServicesWorkItemWriteScope } from "../models/workItemWrites.js";
|
|
10
10
|
import { IssueFilter } from "../providerFilters.js";
|
|
11
11
|
import { ProviderOrganization } from "../results.js";
|
|
12
12
|
import { ProviderPullRequestCount, ProviderPullRequestSearchPage } from "../models/pullRequestReads.js";
|
|
@@ -21,8 +21,8 @@ import { JiraIssueWriter } from "./jiraIssueWrites.js";
|
|
|
21
21
|
import { LinearIssueEtagNode } from "./linearIssuesEtag.js";
|
|
22
22
|
import { PagingMode } from "./metadata.js";
|
|
23
23
|
import { GetIssuesOptions, GetPullRequestsForUserOptions, GetPullRequestsOptions, GetReposOptions, JiraIssuePage, PageInfo, PagingInput, ProviderAccount, ProviderApiCollectionResult, ProviderApiPagedResult, ProviderAsanaProject, ProviderAsanaWorkspace, ProviderAzureProject, ProviderAzureResource, ProviderBitbucketResource, ProviderGitHubOrganization, ProviderGitLabGroup, ProviderHierarchyResult, ProviderIssue, ProviderJiraProject, ProviderJiraResource, ProviderJiraServerProject, ProviderLinearOrganization, ProviderLinearProject, ProviderLinearTeam, ProviderPullRequest, ProviderRepoInput, ProviderReposInput, ProviderRepository } from "./models.js";
|
|
24
|
-
import { IntegrationAuthenticationService } from "../authentication/integrationAuthenticationService.js";
|
|
25
|
-
import { CollectionMetadata, GitIssueState, GitPullRequestState, TrelloBoard, TrelloList } from "@gitkraken/provider-apis";
|
|
24
|
+
import { IntegrationAuthenticationService, TrackedSession } from "../authentication/integrationAuthenticationService.js";
|
|
25
|
+
import { CollectionMetadata, GitHub, GitIssueState, GitPullRequestState, TrelloBoard, TrelloList } from "@gitkraken/provider-apis";
|
|
26
26
|
//#region ../plus/integrations/src/providers/providersApi.d.ts
|
|
27
27
|
/** One page of an Asana task read, by project or by the current user's workspace. */
|
|
28
28
|
export interface AsanaTaskPageOptions {
|
|
@@ -38,6 +38,7 @@ export declare class ProvidersApi implements Disposable {
|
|
|
38
38
|
private readonly azureWorkItemDescriptions;
|
|
39
39
|
private readonly providers;
|
|
40
40
|
private readonly request;
|
|
41
|
+
readonly githubRelationships: Pick<GitHub, 'getIssueRelationships' | 'writeIssueRelationship'>;
|
|
41
42
|
private azureRestApi;
|
|
42
43
|
private readonly disposable;
|
|
43
44
|
constructor(authenticationService: IntegrationAuthenticationService, azureWorkItemTypeStates?: AzureWorkItemStatesCache, azureWorkItemDescriptions?: AzureWorkItemDescriptionsCache);
|
|
@@ -173,7 +174,12 @@ export declare class ProvidersApi implements Disposable {
|
|
|
173
174
|
baseUrl?: string;
|
|
174
175
|
}): Promise<ProviderAccount | undefined>;
|
|
175
176
|
getAzurePullRequestWriter(options: AzurePullRequestCreateCapabilityOptions, session: ProviderAuthenticationSession, isSessionCurrent: () => Promise<boolean>): Promise<AzurePullRequestWriter>;
|
|
176
|
-
getAzureWorkItemWriter(options:
|
|
177
|
+
getAzureWorkItemWriter(options: AzureServicesWorkItemWriteScope, session: ProviderAuthenticationSession, isSessionCurrent: () => Promise<boolean>): Promise<AzureWorkItemWriter>;
|
|
178
|
+
getAzureServerWorkItemWriter(options: AzureServerWorkItemWriteScope, session: ProviderAuthenticationSession, route: {
|
|
179
|
+
collectionBaseUrl: string;
|
|
180
|
+
collectionUrl: string;
|
|
181
|
+
collection: string;
|
|
182
|
+
}, ignoreSSLErrors: boolean | 'force', isSessionCurrent: TrackedSession): Promise<AzureWorkItemWriter>;
|
|
177
183
|
getJiraIssueWriter(options: IssueTrackerWriteConnection): Promise<JiraIssueWriter | undefined>;
|
|
178
184
|
getJiraResourcesForCurrentUser(tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Jira>): Promise<ProviderJiraResource[] | undefined>;
|
|
179
185
|
getLinearOrganization(tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Linear>): Promise<ProviderLinearOrganization | undefined>;
|
|
@@ -14,6 +14,7 @@ import { azureIssueStateCategory, azureWorkItemEtagFieldNames, encodeAzurePathSe
|
|
|
14
14
|
import { AzureWorkItemDescriptionsCache } from "./azure/workItemDescriptions.js";
|
|
15
15
|
import { AzureWorkItemStatesCache, getAzureWorkItemTypeStatesUrl, getAzureWorkItemTypesUrl, requireAzureWorkItemStateCategories, resolveAzureWorkItemStateCategory } from "./azure/workItemStateCategories.js";
|
|
16
16
|
import { AzurePullRequestWriter } from "./azurePullRequestWrites.js";
|
|
17
|
+
import { WorkItemWriteNotDispatchedError } from "./azureWorkItemWriteErrors.js";
|
|
17
18
|
import { requestJiraIssueByKey, requestJiraIssuesEtagFields } from "./jiraIssueByKey.js";
|
|
18
19
|
import { JiraIssueWriter } from "./jiraIssueWrites.js";
|
|
19
20
|
import { createProviderApiRequest } from "./providerApiClient.js";
|
|
@@ -51,6 +52,10 @@ function isAzureNotFoundResponse(ex, typeKeys) {
|
|
|
51
52
|
function azureAuthorization(token, isPAT) {
|
|
52
53
|
return isPAT ? `Basic ${base64(`:${token}`)}` : `Bearer ${token}`;
|
|
53
54
|
}
|
|
55
|
+
function toAzureServerWorkItemApiVersion(negotiated) {
|
|
56
|
+
const major = Number(/^(\d+)\.\d+/.exec(negotiated ?? "")?.[1]);
|
|
57
|
+
return major >= 5 ? `${Math.min(major, 7)}.0` : void 0;
|
|
58
|
+
}
|
|
54
59
|
const azureDevOpsBaseUrl = "https://dev.azure.com";
|
|
55
60
|
/** The most group descriptors one identity batch read resolves. */
|
|
56
61
|
const azureIdentityBatchSize = 100;
|
|
@@ -150,6 +155,7 @@ var ProvidersApi = class {
|
|
|
150
155
|
azureWorkItemDescriptions;
|
|
151
156
|
providers;
|
|
152
157
|
request;
|
|
158
|
+
githubRelationships;
|
|
153
159
|
azureRestApi;
|
|
154
160
|
disposable;
|
|
155
161
|
constructor(authenticationService, azureWorkItemTypeStates = new AzureWorkItemStatesCache(), azureWorkItemDescriptions = new AzureWorkItemDescriptionsCache()) {
|
|
@@ -159,6 +165,7 @@ var ProvidersApi = class {
|
|
|
159
165
|
const http = authenticationService.ctx.http;
|
|
160
166
|
this.request = createProviderApiRequest((input, init) => http.fetch(input, init), http.userAgent);
|
|
161
167
|
const providerApis = makeProviderAPIs({ request: this.request });
|
|
168
|
+
this.githubRelationships = providerApis.github;
|
|
162
169
|
this.azureRestApi = providerApis.azureDevOps;
|
|
163
170
|
this.providers = {
|
|
164
171
|
["github"]: {
|
|
@@ -801,6 +808,20 @@ var ProvidersApi = class {
|
|
|
801
808
|
authorization: azureAuthorization(session.accessToken, true)
|
|
802
809
|
}, options, isSessionCurrent);
|
|
803
810
|
}
|
|
811
|
+
getAzureServerWorkItemWriter(options, session, route, ignoreSSLErrors, isSessionCurrent) {
|
|
812
|
+
const http = this.authenticationService.ctx.http;
|
|
813
|
+
const request = (o) => http.wrapForForcedInsecureSSL(ignoreSSLErrors, () => o.method != null && o.method !== "GET" && isSessionCurrent.isRetired() ? Promise.reject(new WorkItemWriteNotDispatchedError()) : this.request(o));
|
|
814
|
+
const negotiate = async (resource, version) => (await http.wrapForForcedInsecureSSL(ignoreSSLErrors, () => this.azureRestApi.getRestApiResource({
|
|
815
|
+
namespace: route.collection,
|
|
816
|
+
resource,
|
|
817
|
+
version
|
|
818
|
+
}, {
|
|
819
|
+
token: session.accessToken,
|
|
820
|
+
isPAT: true,
|
|
821
|
+
baseUrl: route.collectionBaseUrl
|
|
822
|
+
})))?.apiVersion;
|
|
823
|
+
return AzureWorkItemWriter.connectServer(request, azureAuthorization(session.accessToken, true), options, route.collectionUrl, async () => toAzureServerWorkItemApiVersion(await negotiate("workItems", "7.0")), () => negotiate("workItemTypeStates", "7.1"), isSessionCurrent);
|
|
824
|
+
}
|
|
804
825
|
async getJiraIssueWriter(options) {
|
|
805
826
|
const provider = this.providers[options.providerId];
|
|
806
827
|
if (provider == null || provider.id !== options.providerId) return void 0;
|