@gitkraken/core-gitlens 0.38.4 → 0.40.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 +23 -1
- package/dist/git-cli/exec/git.d.ts +21 -0
- package/dist/git-cli/exec/git.js +21 -0
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/providers/branches.js +13 -6
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/remotes.js +1 -1
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +4 -0
- package/dist/plus/git-github/api/github.js +7 -0
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +51 -0
- package/dist/plus/git-github/api/issueWrites.js +192 -0
- package/dist/plus/git-github/api/issueWrites.js.map +1 -0
- package/dist/plus/integrations/authentication/rejectedTokenTracker.d.ts +7 -8
- package/dist/plus/integrations/authentication/rejectedTokenTracker.js +7 -8
- package/dist/plus/integrations/authentication/rejectedTokenTracker.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 +7 -1
- package/dist/plus/integrations/integrationService.js +37 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +9 -0
- package/dist/plus/integrations/models/integration.d.ts +6 -4
- package/dist/plus/integrations/models/integration.js +15 -9
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/asana.d.ts +4 -5
- package/dist/plus/integrations/providers/asana.js +53 -12
- package/dist/plus/integrations/providers/asana.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +5 -1
- package/dist/plus/integrations/providers/github.js +25 -0
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/linear.js +6 -6
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/models.d.ts +6 -15
- package/dist/plus/integrations/providers/models.js +1 -1
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +1 -6
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/docs/integrations.md +19 -0
- package/package.json +2 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { RequestParameters } from "@octokit/types";
|
|
2
|
+
//#region ../plus/git-github/src/api/issueWrites.d.ts
|
|
3
|
+
type GitHubIssueWriteTarget = {
|
|
4
|
+
owner: string;
|
|
5
|
+
repo: string;
|
|
6
|
+
};
|
|
7
|
+
export type GitHubIssueDelete = GitHubIssueWriteTarget & {
|
|
8
|
+
number: number;
|
|
9
|
+
expectedNodeId: string;
|
|
10
|
+
};
|
|
11
|
+
export type GitHubIssueWrite = (GitHubIssueWriteTarget & {
|
|
12
|
+
action: 'create';
|
|
13
|
+
title: string;
|
|
14
|
+
body?: string;
|
|
15
|
+
}) | (GitHubIssueDelete & ({
|
|
16
|
+
action: 'edit';
|
|
17
|
+
title?: string;
|
|
18
|
+
body?: string;
|
|
19
|
+
} | {
|
|
20
|
+
action: 'set-state';
|
|
21
|
+
state: 'open';
|
|
22
|
+
} | {
|
|
23
|
+
action: 'set-state';
|
|
24
|
+
state: 'closed';
|
|
25
|
+
reason: 'completed' | 'not_planned';
|
|
26
|
+
}));
|
|
27
|
+
export type IssueWriteResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
issue: {
|
|
30
|
+
owner: string;
|
|
31
|
+
repo: string;
|
|
32
|
+
number: number;
|
|
33
|
+
nodeId: string;
|
|
34
|
+
url: string;
|
|
35
|
+
title: string;
|
|
36
|
+
body: string;
|
|
37
|
+
state: 'open' | 'closed';
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
ok: false;
|
|
41
|
+
reason: 'unsupported' | 'no-connection' | 'forbidden' | 'not-found' | 'invalid-input' | 'rate-limit' | 'unknown';
|
|
42
|
+
};
|
|
43
|
+
type GitHubIssueMutation = GitHubIssueWrite | (GitHubIssueDelete & {
|
|
44
|
+
action: 'delete';
|
|
45
|
+
});
|
|
46
|
+
type GraphqlRequest = <T>(query: string, variables: RequestParameters) => Promise<T | undefined>;
|
|
47
|
+
export declare function isValidGitHubIssueMutation(input: GitHubIssueMutation): boolean;
|
|
48
|
+
export declare function issueWriteFailure(ex: unknown): IssueWriteResult;
|
|
49
|
+
export declare function mutateGitHubIssue(input: GitHubIssueMutation, graphql: GraphqlRequest): Promise<IssueWriteResult>;
|
|
50
|
+
//#endregion
|
|
51
|
+
//# sourceMappingURL=issueWrites.d.ts.map
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { RequestRateLimitError } from "../../../git/errors.js";
|
|
2
|
+
import { GraphqlResponseError } from "@octokit/graphql";
|
|
3
|
+
import { RequestError } from "@octokit/request-error";
|
|
4
|
+
//#region ../plus/git-github/src/api/issueWrites.ts
|
|
5
|
+
const issueFields = `
|
|
6
|
+
id number url title body state
|
|
7
|
+
repository { id owner { login } name }
|
|
8
|
+
`;
|
|
9
|
+
function isValidGitHubIssueMutation(input) {
|
|
10
|
+
if (typeof input.owner !== "string" || !/^[a-z\d_-]+$/i.test(input.owner) || typeof input.repo !== "string" || !/^[a-z\d._-]+$/i.test(input.repo) || input.repo === "." || input.repo === "..") return false;
|
|
11
|
+
if (input.action !== "create" && (!Number.isInteger(input.number) || input.number < 1 || input.number > 2147483647 || typeof input.expectedNodeId !== "string" || !input.expectedNodeId.trim())) return false;
|
|
12
|
+
switch (input.action) {
|
|
13
|
+
case "create": return isIssueTitle(input.title) && (input.body === void 0 || typeof input.body === "string");
|
|
14
|
+
case "edit": return (input.title !== void 0 || input.body !== void 0) && (input.title === void 0 || isIssueTitle(input.title)) && (input.body === void 0 || typeof input.body === "string");
|
|
15
|
+
case "set-state": return input.state === "open" || input.state === "closed" && (input.reason === "completed" || input.reason === "not_planned");
|
|
16
|
+
case "delete": return true;
|
|
17
|
+
default: return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function isIssueTitle(title) {
|
|
21
|
+
return typeof title === "string" && title.trim().length > 0;
|
|
22
|
+
}
|
|
23
|
+
function issueWriteFailure(ex) {
|
|
24
|
+
if (RequestRateLimitError.is(ex)) return {
|
|
25
|
+
ok: false,
|
|
26
|
+
reason: "rate-limit"
|
|
27
|
+
};
|
|
28
|
+
if (ex instanceof GraphqlResponseError) {
|
|
29
|
+
if (ex.errors?.some((error) => error.type === "RATE_LIMIT" || error.type === "RATE_LIMITED")) return {
|
|
30
|
+
ok: false,
|
|
31
|
+
reason: "rate-limit"
|
|
32
|
+
};
|
|
33
|
+
switch (ex.errors?.[0]?.type) {
|
|
34
|
+
case "NOT_FOUND": return {
|
|
35
|
+
ok: false,
|
|
36
|
+
reason: "not-found"
|
|
37
|
+
};
|
|
38
|
+
case "FORBIDDEN":
|
|
39
|
+
case "INSUFFICIENT_SCOPES": return {
|
|
40
|
+
ok: false,
|
|
41
|
+
reason: "forbidden"
|
|
42
|
+
};
|
|
43
|
+
case "BAD_USER_INPUT":
|
|
44
|
+
case "UNPROCESSABLE": return {
|
|
45
|
+
ok: false,
|
|
46
|
+
reason: "invalid-input"
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (ex instanceof RequestError) switch (ex.status) {
|
|
51
|
+
case 400:
|
|
52
|
+
case 422: return {
|
|
53
|
+
ok: false,
|
|
54
|
+
reason: "invalid-input"
|
|
55
|
+
};
|
|
56
|
+
case 401: return {
|
|
57
|
+
ok: false,
|
|
58
|
+
reason: "no-connection"
|
|
59
|
+
};
|
|
60
|
+
case 403: return {
|
|
61
|
+
ok: false,
|
|
62
|
+
reason: ex.message.toLowerCase().includes("rate limit") ? "rate-limit" : "forbidden"
|
|
63
|
+
};
|
|
64
|
+
case 404:
|
|
65
|
+
case 410: return {
|
|
66
|
+
ok: false,
|
|
67
|
+
reason: "not-found"
|
|
68
|
+
};
|
|
69
|
+
case 429: return {
|
|
70
|
+
ok: false,
|
|
71
|
+
reason: "rate-limit"
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
reason: "unknown"
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async function mutateGitHubIssue(input, graphql) {
|
|
80
|
+
try {
|
|
81
|
+
const { owner, repo } = input;
|
|
82
|
+
const target = input.action === "create" ? await graphql(`
|
|
83
|
+
query IssueCreateTarget($owner: String!, $repo: String!) {
|
|
84
|
+
repository(owner: $owner, name: $repo, followRenames: false) {
|
|
85
|
+
id
|
|
86
|
+
hasIssuesEnabled
|
|
87
|
+
isArchived
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`, {
|
|
91
|
+
owner,
|
|
92
|
+
repo
|
|
93
|
+
}) : await graphql(`query IssueWriteTarget($owner: String!, $repo: String!, $expectedNodeId: ID!, $checkDelete: Boolean!) {
|
|
94
|
+
repository(owner: $owner, name: $repo, followRenames: false) {
|
|
95
|
+
id hasIssuesEnabled isArchived
|
|
96
|
+
}
|
|
97
|
+
node(id: $expectedNodeId) {
|
|
98
|
+
__typename
|
|
99
|
+
... on Issue {
|
|
100
|
+
${issueFields}
|
|
101
|
+
viewerCanDelete @include(if: $checkDelete)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}`, {
|
|
105
|
+
owner,
|
|
106
|
+
repo,
|
|
107
|
+
expectedNodeId: input.expectedNodeId,
|
|
108
|
+
checkDelete: input.action === "delete"
|
|
109
|
+
});
|
|
110
|
+
const repository = target?.repository;
|
|
111
|
+
if (repository == null) return {
|
|
112
|
+
ok: false,
|
|
113
|
+
reason: "not-found"
|
|
114
|
+
};
|
|
115
|
+
if (repository.isArchived) return {
|
|
116
|
+
ok: false,
|
|
117
|
+
reason: "forbidden"
|
|
118
|
+
};
|
|
119
|
+
if (!repository.hasIssuesEnabled) return {
|
|
120
|
+
ok: false,
|
|
121
|
+
reason: "unsupported"
|
|
122
|
+
};
|
|
123
|
+
if (input.action === "create") return await writeIssue(graphql, "createIssue", "CreateIssueInput", {
|
|
124
|
+
repositoryId: repository.id,
|
|
125
|
+
title: input.title,
|
|
126
|
+
body: input.body
|
|
127
|
+
});
|
|
128
|
+
const issue = target?.node;
|
|
129
|
+
if (issue?.__typename !== "Issue" || issue.number !== input.number || issue.repository.id !== repository.id || issue.repository.owner.login.toLowerCase() !== owner.toLowerCase() || issue.repository.name.toLowerCase() !== repo.toLowerCase()) return {
|
|
130
|
+
ok: false,
|
|
131
|
+
reason: "not-found"
|
|
132
|
+
};
|
|
133
|
+
switch (input.action) {
|
|
134
|
+
case "edit": return await writeIssue(graphql, "updateIssue", "UpdateIssueInput", {
|
|
135
|
+
id: issue.id,
|
|
136
|
+
title: input.title,
|
|
137
|
+
body: input.body
|
|
138
|
+
});
|
|
139
|
+
case "set-state": return input.state === "open" ? await writeIssue(graphql, "reopenIssue", "ReopenIssueInput", { issueId: issue.id }) : await writeIssue(graphql, "closeIssue", "CloseIssueInput", {
|
|
140
|
+
issueId: issue.id,
|
|
141
|
+
stateReason: input.reason === "completed" ? "COMPLETED" : "NOT_PLANNED"
|
|
142
|
+
});
|
|
143
|
+
case "delete":
|
|
144
|
+
if (issue.viewerCanDelete !== true) return {
|
|
145
|
+
ok: false,
|
|
146
|
+
reason: "forbidden"
|
|
147
|
+
};
|
|
148
|
+
return (await graphql(`
|
|
149
|
+
mutation DeleteIssue($issueId: ID!) {
|
|
150
|
+
deleteIssue(input: { issueId: $issueId }) {
|
|
151
|
+
repository {
|
|
152
|
+
id
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`, { issueId: issue.id }))?.deleteIssue?.repository?.id === repository.id ? toIssueWriteResult(issue) : {
|
|
157
|
+
ok: false,
|
|
158
|
+
reason: "unknown"
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
} catch (ex) {
|
|
162
|
+
return issueWriteFailure(ex);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function writeIssue(graphql, mutation, inputType, input) {
|
|
166
|
+
const result = await graphql(`mutation WriteIssue($input: ${inputType}!) {
|
|
167
|
+
change: ${mutation}(input: $input) { issue { ${issueFields} } }
|
|
168
|
+
}`, { input });
|
|
169
|
+
return result?.change?.issue != null ? toIssueWriteResult(result.change.issue) : {
|
|
170
|
+
ok: false,
|
|
171
|
+
reason: "unknown"
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function toIssueWriteResult(issue) {
|
|
175
|
+
return {
|
|
176
|
+
ok: true,
|
|
177
|
+
issue: {
|
|
178
|
+
owner: issue.repository.owner.login,
|
|
179
|
+
repo: issue.repository.name,
|
|
180
|
+
number: issue.number,
|
|
181
|
+
nodeId: issue.id,
|
|
182
|
+
url: issue.url,
|
|
183
|
+
title: issue.title,
|
|
184
|
+
body: issue.body,
|
|
185
|
+
state: issue.state === "CLOSED" ? "closed" : "open"
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { isValidGitHubIssueMutation, issueWriteFailure, mutateGitHubIssue };
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=issueWrites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issueWrites.js","names":[],"sources":["../../../../../plus/git-github/src/api/issueWrites.ts"],"sourcesContent":["import { GraphqlResponseError } from '@octokit/graphql';\nimport { RequestError } from '@octokit/request-error';\nimport type { RequestParameters } from '@octokit/types';\nimport { RequestRateLimitError } from '@gitlens/git/errors.js';\n\ntype GitHubIssueWriteTarget = { owner: string; repo: string };\n\nexport type GitHubIssueDelete = GitHubIssueWriteTarget & { number: number; expectedNodeId: string };\n\nexport type GitHubIssueWrite =\n\t| (GitHubIssueWriteTarget & { action: 'create'; title: string; body?: string })\n\t| (GitHubIssueDelete &\n\t\t\t(\n\t\t\t\t| { action: 'edit'; title?: string; body?: string }\n\t\t\t\t| { action: 'set-state'; state: 'open' }\n\t\t\t\t| { action: 'set-state'; state: 'closed'; reason: 'completed' | 'not_planned' }\n\t\t\t));\n\nexport type IssueWriteResult =\n\t| {\n\t\t\tok: true;\n\t\t\tissue: {\n\t\t\t\towner: string;\n\t\t\t\trepo: string;\n\t\t\t\tnumber: number;\n\t\t\t\tnodeId: string;\n\t\t\t\turl: string;\n\t\t\t\ttitle: string;\n\t\t\t\tbody: string;\n\t\t\t\tstate: 'open' | 'closed';\n\t\t\t};\n\t }\n\t| {\n\t\t\tok: false;\n\t\t\treason:\n\t\t\t\t| 'unsupported'\n\t\t\t\t| 'no-connection'\n\t\t\t\t| 'forbidden'\n\t\t\t\t| 'not-found'\n\t\t\t\t| 'invalid-input'\n\t\t\t\t| 'rate-limit'\n\t\t\t\t| 'unknown';\n\t };\n\ntype GitHubIssueMutation = GitHubIssueWrite | (GitHubIssueDelete & { action: 'delete' });\ntype GraphqlRequest = <T>(query: string, variables: RequestParameters) => Promise<T | undefined>;\n\nconst issueFields = `\n\tid number url title body state\n\trepository { id owner { login } name }\n`;\n\ntype IssueNode = {\n\tid: string;\n\tnumber: number;\n\turl: string;\n\ttitle: string;\n\tbody: string;\n\tstate: 'OPEN' | 'CLOSED';\n\trepository: { id: string; owner: { login: string }; name: string };\n};\n\ntype RepositoryNode = {\n\tid: string;\n\thasIssuesEnabled: boolean;\n\tisArchived: boolean;\n};\n\ntype WriteTarget = {\n\trepository: RepositoryNode | null;\n\tnode?: (IssueNode & { __typename: string; viewerCanDelete?: boolean }) | null;\n};\n\nexport function isValidGitHubIssueMutation(input: GitHubIssueMutation): boolean {\n\tif (\n\t\ttypeof input.owner !== 'string' ||\n\t\t!/^[a-z\\d_-]+$/i.test(input.owner) ||\n\t\ttypeof input.repo !== 'string' ||\n\t\t!/^[a-z\\d._-]+$/i.test(input.repo) ||\n\t\tinput.repo === '.' ||\n\t\tinput.repo === '..'\n\t) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\tinput.action !== 'create' &&\n\t\t(!Number.isInteger(input.number) ||\n\t\t\tinput.number < 1 ||\n\t\t\tinput.number > 2147483647 ||\n\t\t\ttypeof input.expectedNodeId !== 'string' ||\n\t\t\t!input.expectedNodeId.trim())\n\t) {\n\t\treturn false;\n\t}\n\n\tswitch (input.action) {\n\t\tcase 'create':\n\t\t\treturn isIssueTitle(input.title) && (input.body === undefined || typeof input.body === 'string');\n\t\tcase 'edit':\n\t\t\treturn (\n\t\t\t\t(input.title !== undefined || input.body !== undefined) &&\n\t\t\t\t(input.title === undefined || isIssueTitle(input.title)) &&\n\t\t\t\t(input.body === undefined || typeof input.body === 'string')\n\t\t\t);\n\t\tcase 'set-state':\n\t\t\treturn (\n\t\t\t\tinput.state === 'open' ||\n\t\t\t\t(input.state === 'closed' && (input.reason === 'completed' || input.reason === 'not_planned'))\n\t\t\t);\n\t\tcase 'delete':\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction isIssueTitle(title: unknown): title is string {\n\treturn typeof title === 'string' && title.trim().length > 0;\n}\n\nexport function issueWriteFailure(ex: unknown): IssueWriteResult {\n\tif (RequestRateLimitError.is(ex)) return { ok: false, reason: 'rate-limit' };\n\n\tif (ex instanceof GraphqlResponseError) {\n\t\tif (ex.errors?.some(error => error.type === 'RATE_LIMIT' || error.type === 'RATE_LIMITED')) {\n\t\t\treturn { ok: false, reason: 'rate-limit' };\n\t\t}\n\n\t\tswitch (ex.errors?.[0]?.type) {\n\t\t\tcase 'NOT_FOUND':\n\t\t\t\treturn { ok: false, reason: 'not-found' };\n\t\t\tcase 'FORBIDDEN':\n\t\t\tcase 'INSUFFICIENT_SCOPES':\n\t\t\t\treturn { ok: false, reason: 'forbidden' };\n\t\t\tcase 'BAD_USER_INPUT':\n\t\t\tcase 'UNPROCESSABLE':\n\t\t\t\treturn { ok: false, reason: 'invalid-input' };\n\t\t}\n\t}\n\n\tif (ex instanceof RequestError) {\n\t\tswitch (ex.status) {\n\t\t\tcase 400:\n\t\t\tcase 422:\n\t\t\t\treturn { ok: false, reason: 'invalid-input' };\n\t\t\tcase 401:\n\t\t\t\treturn { ok: false, reason: 'no-connection' };\n\t\t\tcase 403:\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\treason: ex.message.toLowerCase().includes('rate limit') ? 'rate-limit' : 'forbidden',\n\t\t\t\t};\n\t\t\tcase 404:\n\t\t\tcase 410:\n\t\t\t\treturn { ok: false, reason: 'not-found' };\n\t\t\tcase 429:\n\t\t\t\treturn { ok: false, reason: 'rate-limit' };\n\t\t}\n\t}\n\n\treturn { ok: false, reason: 'unknown' };\n}\n\nexport async function mutateGitHubIssue(\n\tinput: GitHubIssueMutation,\n\tgraphql: GraphqlRequest,\n): Promise<IssueWriteResult> {\n\ttry {\n\t\tconst { owner, repo } = input;\n\t\tconst target =\n\t\t\tinput.action === 'create'\n\t\t\t\t? await graphql<WriteTarget>(\n\t\t\t\t\t\t`\n\t\t\t\t\t\t\tquery IssueCreateTarget($owner: String!, $repo: String!) {\n\t\t\t\t\t\t\t\trepository(owner: $owner, name: $repo, followRenames: false) {\n\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\thasIssuesEnabled\n\t\t\t\t\t\t\t\t\tisArchived\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t`,\n\t\t\t\t\t\t{ owner: owner, repo: repo },\n\t\t\t\t\t)\n\t\t\t\t: await graphql<WriteTarget>(\n\t\t\t\t\t\t`query IssueWriteTarget($owner: String!, $repo: String!, $expectedNodeId: ID!, $checkDelete: Boolean!) {\n\t\t\t\t\t\t\trepository(owner: $owner, name: $repo, followRenames: false) {\n\t\t\t\t\t\t\t\tid hasIssuesEnabled isArchived\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnode(id: $expectedNodeId) {\n\t\t\t\t\t\t\t\t__typename\n\t\t\t\t\t\t\t\t... on Issue {\n\t\t\t\t\t\t\t\t\t${issueFields}\n\t\t\t\t\t\t\t\t\tviewerCanDelete @include(if: $checkDelete)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\towner: owner,\n\t\t\t\t\t\t\trepo: repo,\n\t\t\t\t\t\t\texpectedNodeId: input.expectedNodeId,\n\t\t\t\t\t\t\tcheckDelete: input.action === 'delete',\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\tconst repository = target?.repository;\n\t\tif (repository == null) return { ok: false, reason: 'not-found' };\n\t\tif (repository.isArchived) return { ok: false, reason: 'forbidden' };\n\t\tif (!repository.hasIssuesEnabled) return { ok: false, reason: 'unsupported' };\n\n\t\tif (input.action === 'create') {\n\t\t\treturn await writeIssue(graphql, 'createIssue', 'CreateIssueInput', {\n\t\t\t\trepositoryId: repository.id,\n\t\t\t\ttitle: input.title,\n\t\t\t\tbody: input.body,\n\t\t\t});\n\t\t}\n\n\t\tconst issue = target?.node;\n\t\tif (\n\t\t\tissue?.__typename !== 'Issue' ||\n\t\t\tissue.number !== input.number ||\n\t\t\tissue.repository.id !== repository.id ||\n\t\t\tissue.repository.owner.login.toLowerCase() !== owner.toLowerCase() ||\n\t\t\tissue.repository.name.toLowerCase() !== repo.toLowerCase()\n\t\t) {\n\t\t\treturn { ok: false, reason: 'not-found' };\n\t\t}\n\n\t\tswitch (input.action) {\n\t\t\tcase 'edit':\n\t\t\t\treturn await writeIssue(graphql, 'updateIssue', 'UpdateIssueInput', {\n\t\t\t\t\tid: issue.id,\n\t\t\t\t\ttitle: input.title,\n\t\t\t\t\tbody: input.body,\n\t\t\t\t});\n\t\t\tcase 'set-state':\n\t\t\t\treturn input.state === 'open'\n\t\t\t\t\t? await writeIssue(graphql, 'reopenIssue', 'ReopenIssueInput', { issueId: issue.id })\n\t\t\t\t\t: await writeIssue(graphql, 'closeIssue', 'CloseIssueInput', {\n\t\t\t\t\t\t\tissueId: issue.id,\n\t\t\t\t\t\t\tstateReason: input.reason === 'completed' ? 'COMPLETED' : 'NOT_PLANNED',\n\t\t\t\t\t\t});\n\t\t\tcase 'delete': {\n\t\t\t\tif (issue.viewerCanDelete !== true) return { ok: false, reason: 'forbidden' };\n\n\t\t\t\tconst result = await graphql<{ deleteIssue: { repository: { id: string } | null } | null }>(\n\t\t\t\t\t`\n\t\t\t\t\t\tmutation DeleteIssue($issueId: ID!) {\n\t\t\t\t\t\t\tdeleteIssue(input: { issueId: $issueId }) {\n\t\t\t\t\t\t\t\trepository {\n\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t`,\n\t\t\t\t\t{ issueId: issue.id },\n\t\t\t\t);\n\t\t\t\treturn result?.deleteIssue?.repository?.id === repository.id\n\t\t\t\t\t? toIssueWriteResult(issue)\n\t\t\t\t\t: { ok: false, reason: 'unknown' };\n\t\t\t}\n\t\t}\n\t} catch (ex) {\n\t\treturn issueWriteFailure(ex);\n\t}\n}\n\nasync function writeIssue(\n\tgraphql: GraphqlRequest,\n\tmutation: 'createIssue' | 'updateIssue' | 'closeIssue' | 'reopenIssue',\n\tinputType: string,\n\tinput: Record<string, string | undefined>,\n): Promise<IssueWriteResult> {\n\tconst result = await graphql<{ change: { issue: IssueNode | null } | null }>(\n\t\t`mutation WriteIssue($input: ${inputType}!) {\n\t\t\tchange: ${mutation}(input: $input) { issue { ${issueFields} } }\n\t\t}`,\n\t\t{ input: input },\n\t);\n\treturn result?.change?.issue != null ? toIssueWriteResult(result.change.issue) : { ok: false, reason: 'unknown' };\n}\n\nfunction toIssueWriteResult(issue: IssueNode): IssueWriteResult {\n\treturn {\n\t\tok: true,\n\t\tissue: {\n\t\t\towner: issue.repository.owner.login,\n\t\t\trepo: issue.repository.name,\n\t\t\tnumber: issue.number,\n\t\t\tnodeId: issue.id,\n\t\t\turl: issue.url,\n\t\t\ttitle: issue.title,\n\t\t\tbody: issue.body,\n\t\t\tstate: issue.state === 'CLOSED' ? 'closed' : 'open',\n\t\t},\n\t};\n}\n"],"mappings":"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"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Per-connection recovery state for a cloud token the provider REFUSED — a revoked grant, retired scopes, an
|
|
4
4
|
* app removed from the org. A purely predictive refresh (`expiresIn < 60`) cannot see that case, because the
|
|
5
|
-
* backend still believes the token is valid, so without this the refused token is re-sent on every
|
|
5
|
+
* backend still believes the token is valid, so without this the refused token is re-sent on every request and
|
|
6
6
|
* the failure only clears when the user reconnects by hand.
|
|
7
7
|
*
|
|
8
8
|
* One recovery refresh per connection, then the connection is the failure budget's problem:
|
|
9
|
-
* - {@link recordRejection}
|
|
9
|
+
* - {@link recordRejection} when the provider rejects the credential — arms the refresh, or reports that the rejection is
|
|
10
10
|
* not recoverable so the caller counts it as a real failure instead.
|
|
11
|
-
* - {@link claimRefresh}
|
|
12
|
-
* fires once and no further
|
|
11
|
+
* - {@link claimRefresh} when the next operation resolves its session — spends the rejection, so the refresh
|
|
12
|
+
* fires once and no further operation of that connection asks the cloud again.
|
|
13
13
|
*
|
|
14
14
|
* Deliberately NOT re-armed when the refresh hands back a different token. The GK cloud mints a new access
|
|
15
15
|
* token on every `/refresh`, so a credential the provider refuses for a reason a refresh cannot fix (retired
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
export declare class RejectedTokenTracker {
|
|
22
22
|
private readonly _rejections;
|
|
23
23
|
/**
|
|
24
|
-
* Whether
|
|
25
|
-
*
|
|
26
|
-
* that throws must not leave the refresh armed and ask the cloud again on the next read.
|
|
24
|
+
* Whether an operation on `connectionId` must force a cloud refresh of a token known to be refused. A session
|
|
25
|
+
* lookup that throws must still spend the rejection so a later operation does not ask the cloud again.
|
|
27
26
|
*/
|
|
28
27
|
claimRefresh(connectionId: string): boolean;
|
|
29
28
|
/**
|
|
@@ -35,7 +34,7 @@ export declare class RejectedTokenTracker {
|
|
|
35
34
|
recordRejection(connectionId: string): boolean;
|
|
36
35
|
/** Drops all state, for when the stored tokens a rejection could name are replaced or gone. */
|
|
37
36
|
clear(): void;
|
|
38
|
-
/** Whether any connection is holding a rejection. For assertions;
|
|
37
|
+
/** Whether any connection is holding a rejection. For assertions; session resolution uses {@link claimRefresh}. */
|
|
39
38
|
get empty(): boolean;
|
|
40
39
|
}
|
|
41
40
|
//#endregion
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Per-connection recovery state for a cloud token the provider REFUSED — a revoked grant, retired scopes, an
|
|
4
4
|
* app removed from the org. A purely predictive refresh (`expiresIn < 60`) cannot see that case, because the
|
|
5
|
-
* backend still believes the token is valid, so without this the refused token is re-sent on every
|
|
5
|
+
* backend still believes the token is valid, so without this the refused token is re-sent on every request and
|
|
6
6
|
* the failure only clears when the user reconnects by hand.
|
|
7
7
|
*
|
|
8
8
|
* One recovery refresh per connection, then the connection is the failure budget's problem:
|
|
9
|
-
* - {@link recordRejection}
|
|
9
|
+
* - {@link recordRejection} when the provider rejects the credential — arms the refresh, or reports that the rejection is
|
|
10
10
|
* not recoverable so the caller counts it as a real failure instead.
|
|
11
|
-
* - {@link claimRefresh}
|
|
12
|
-
* fires once and no further
|
|
11
|
+
* - {@link claimRefresh} when the next operation resolves its session — spends the rejection, so the refresh
|
|
12
|
+
* fires once and no further operation of that connection asks the cloud again.
|
|
13
13
|
*
|
|
14
14
|
* Deliberately NOT re-armed when the refresh hands back a different token. The GK cloud mints a new access
|
|
15
15
|
* token on every `/refresh`, so a credential the provider refuses for a reason a refresh cannot fix (retired
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
var RejectedTokenTracker = class {
|
|
22
22
|
_rejections = /* @__PURE__ */ new Map();
|
|
23
23
|
/**
|
|
24
|
-
* Whether
|
|
25
|
-
*
|
|
26
|
-
* that throws must not leave the refresh armed and ask the cloud again on the next read.
|
|
24
|
+
* Whether an operation on `connectionId` must force a cloud refresh of a token known to be refused. A session
|
|
25
|
+
* lookup that throws must still spend the rejection so a later operation does not ask the cloud again.
|
|
27
26
|
*/
|
|
28
27
|
claimRefresh(connectionId) {
|
|
29
28
|
if (this._rejections.get(connectionId) !== "armed") return false;
|
|
@@ -45,7 +44,7 @@ var RejectedTokenTracker = class {
|
|
|
45
44
|
clear() {
|
|
46
45
|
this._rejections.clear();
|
|
47
46
|
}
|
|
48
|
-
/** Whether any connection is holding a rejection. For assertions;
|
|
47
|
+
/** Whether any connection is holding a rejection. For assertions; session resolution uses {@link claimRefresh}. */
|
|
49
48
|
get empty() {
|
|
50
49
|
return this._rejections.size === 0;
|
|
51
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rejectedTokenTracker.js","names":[],"sources":["../../../../../plus/integrations/src/authentication/rejectedTokenTracker.ts"],"sourcesContent":["/**\n * Per-connection recovery state for a cloud token the provider REFUSED — a revoked grant, retired scopes, an\n * app removed from the org. A purely predictive refresh (`expiresIn < 60`) cannot see that case, because the\n * backend still believes the token is valid, so without this the refused token is re-sent on every
|
|
1
|
+
{"version":3,"file":"rejectedTokenTracker.js","names":[],"sources":["../../../../../plus/integrations/src/authentication/rejectedTokenTracker.ts"],"sourcesContent":["/**\n * Per-connection recovery state for a cloud token the provider REFUSED — a revoked grant, retired scopes, an\n * app removed from the org. A purely predictive refresh (`expiresIn < 60`) cannot see that case, because the\n * backend still believes the token is valid, so without this the refused token is re-sent on every request and\n * the failure only clears when the user reconnects by hand.\n *\n * One recovery refresh per connection, then the connection is the failure budget's problem:\n * - {@link recordRejection} when the provider rejects the credential — arms the refresh, or reports that the rejection is\n * not recoverable so the caller counts it as a real failure instead.\n * - {@link claimRefresh} when the next operation resolves its session — spends the rejection, so the refresh\n * fires once and no further operation of that connection asks the cloud again.\n *\n * Deliberately NOT re-armed when the refresh hands back a different token. The GK cloud mints a new access\n * token on every `/refresh`, so a credential the provider refuses for a reason a refresh cannot fix (retired\n * scopes being the plain case) would look \"rotated\" on each attempt: re-arming on that would refresh on every\n * read forever and the connection's failure budget — which, for the primary, disconnects and prompts a\n * reconnect — would never advance. What resets this instead is {@link clear}, called by every path that replaces\n * or removes the stored tokens; a connection that is simply working never reaches here at all.\n */\nexport class RejectedTokenTracker {\n\tprivate readonly _rejections = new Map<string, 'armed' | 'spent'>();\n\n\t/**\n\t * Whether an operation on `connectionId` must force a cloud refresh of a token known to be refused. A session\n\t * lookup that throws must still spend the rejection so a later operation does not ask the cloud again.\n\t */\n\tclaimRefresh(connectionId: string): boolean {\n\t\tif (this._rejections.get(connectionId) !== 'armed') return false;\n\n\t\tthis._rejections.set(connectionId, 'spent');\n\t\treturn true;\n\t}\n\n\t/**\n\t * Arms the recovery refresh for `connectionId`. Returns `false` once this connection has had its refresh\n\t * (or already has one pending), so the caller falls back to its own failure handling: a token still\n\t * refused after the refresh is not self-healing, and only the failure budget (the primary's) ends in a reconnect\n\t * prompt.\n\t */\n\trecordRejection(connectionId: string): boolean {\n\t\tif (this._rejections.has(connectionId)) return false;\n\n\t\tthis._rejections.set(connectionId, 'armed');\n\t\treturn true;\n\t}\n\n\t/** Drops all state, for when the stored tokens a rejection could name are replaced or gone. */\n\tclear(): void {\n\t\tthis._rejections.clear();\n\t}\n\n\t/** Whether any connection is holding a rejection. For assertions; session resolution uses {@link claimRefresh}. */\n\tget empty(): boolean {\n\t\treturn this._rejections.size === 0;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,uBAAb,MAAkC;CACjC,8BAA+B,IAAI,IAA+B;;;;;CAMlE,aAAa,cAA+B;EAC3C,IAAI,KAAK,YAAY,IAAI,YAAY,MAAM,SAAS,OAAO;EAE3D,KAAK,YAAY,IAAI,cAAc,OAAO;EAC1C,OAAO;CACR;;;;;;;CAQA,gBAAgB,cAA+B;EAC9C,IAAI,KAAK,YAAY,IAAI,YAAY,GAAG,OAAO;EAE/C,KAAK,YAAY,IAAI,cAAc,OAAO;EAC1C,OAAO;CACR;;CAGA,QAAc;EACb,KAAK,YAAY,MAAM;CACxB;;CAGA,IAAI,QAAiB;EACpB,OAAO,KAAK,YAAY,SAAS;CAClC;AACD"}
|
|
@@ -4,6 +4,7 @@ import { ProviderReference } from "../../git/models/remoteProvider.js";
|
|
|
4
4
|
import { IssueProjection, IssueSearchCapabilities, IssueSearchCriteria, IssueSearchRelationship, IssueStateFilter } from "../../git/models/issue.js";
|
|
5
5
|
import { PullRequestFilter, PullRequestProjection, PullRequestSearchCapabilities, PullRequestSearchCriteria, PullRequestStateFilter } from "../../git/models/pullRequest.js";
|
|
6
6
|
import { Account } from "../../git/models/author.js";
|
|
7
|
+
import { IssueWriteResult } from "../git-github/api/issueWrites.js";
|
|
7
8
|
import { AuthenticationSessionLike, CloudIntegrationAuthType, CloudIntegrationConnection, CloudIntegrationType, ConfiguredIntegrationDescriptor, ProviderAuthenticationSession, toCloudIntegrationType, toIntegrationId } from "./authentication/models.js";
|
|
8
9
|
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId, SupportedCloudIntegrationIds, isIntegrationId, isSupportedCloudIntegrationId } from "./constants.js";
|
|
9
10
|
import { Source, Sources } from "./telemetry.js";
|
|
@@ -16,7 +17,7 @@ import { CurrentAccountResult } from "./reads/currentAccount.js";
|
|
|
16
17
|
import { IssueBatchResult, IssueBatchTarget } from "./reads/issueBatch.js";
|
|
17
18
|
import { PullRequestBatchResult, PullRequestBatchTarget } from "./reads/pullRequestBatch.js";
|
|
18
19
|
import { PullRequestBranchResult, PullRequestBranchTarget } from "./reads/pullRequestBranches.js";
|
|
19
|
-
import { ClosedPullRequestSweepOptions, GetAutolinkReferencesOptions, IntegrationManager, ListLinearProjectsOptions, ListOrgsOptions, ListProjectsOptions, ProviderBroadenOrg, ProviderRepositoriesInput, ProviderRepositoryInput, ProviderSweepTarget, ProviderSweepTargetEvent, PullRequestSweepOptions } from "./manager.js";
|
|
20
|
+
import { ClosedPullRequestSweepOptions, GetAutolinkReferencesOptions, IntegrationManager, IssueDeleteOptions, IssueWriteOptions, ListLinearProjectsOptions, ListOrgsOptions, ListProjectsOptions, ProviderBroadenOrg, ProviderRepositoriesInput, ProviderRepositoryInput, ProviderSweepTarget, ProviderSweepTargetEvent, PullRequestSweepOptions } from "./manager.js";
|
|
20
21
|
import { IntegrationAuthenticationProvider, IntegrationAuthenticationProviderDescriptor, IntegrationAuthenticationSessionDescriptor } from "./authentication/integrationAuthenticationProvider.js";
|
|
21
22
|
import { AccountProvider, AuthenticationSessionsChangeEvent, ConfigChangeEvent, ConfigProvider, HttpProvider, IntegrationServiceHooks, IntegrationStorageProvider, IntegrationsRemoteConfig, RepositoriesProvider } from "./context.js";
|
|
22
23
|
import { ManualTokenAuthProviderOptions, createManualTokenAuthProvider } from "./authentication/manualTokenProvider.js";
|
|
@@ -80,5 +81,5 @@ export interface IntegrationManagerContext {
|
|
|
80
81
|
*/
|
|
81
82
|
export declare function createIntegrationManager(ctx: IntegrationManagerContext): IntegrationManager;
|
|
82
83
|
//#endregion
|
|
83
|
-
export { type Account, type AccountProvider, type AuthenticationSessionLike, type AuthenticationSessionsChangeEvent, type Autolink, type AutolinkReference, type ClosedPullRequestSweepOptions, type CloudIntegrationAuthType, type CloudIntegrationConnection, type CloudIntegrationType, type ConfigChangeEvent, type ConfigProvider, type ConfiguredIntegrationDescriptor, type ConfiguredIntegrationsChangeEvent, type ConnectionStateChangeEvent, type CurrentAccountResult, type DynamicAutolinkReference, type FieldPresence, type GetAutolinkReferencesOptions, GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, type HttpProvider, type IntegrationAuthenticationProvider, type IntegrationAuthenticationProviderDescriptor, type IntegrationAuthenticationSessionDescriptor, type IntegrationIds, type IntegrationManager, type IntegrationServiceHooks, type IntegrationStorageProvider, type IntegrationsRemoteConfig, type IssueBatchResult, type IssueBatchTarget, type IssueCountResult, type IssueCountScope, type IssueEtagInclude, type IssueFieldGroup, IssueFilter, type IssueProjection, type IssueSearchCapabilities, type IssueSearchCriteria, type IssueSearchRelationship, type IssueStateFilter, IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId, type ListLinearProjectsOptions, type ListOrgsOptions, type ListProjectsOptions, type ManualTokenAuthProviderOptions, type ProviderAuthenticationSession, type ProviderBroadenOrg, type ProviderBroadenResult, type ProviderLinearProjectShape, type ProviderOrganization, type ProviderPageInfo, type ProviderPagedResult, type ProviderReference, type ProviderRepositoriesInput, type ProviderRepositoryInput, type ProviderRepositoryShape, type ProviderResult, type ProviderSweepResult, type ProviderSweepTarget, type ProviderSweepTargetEvent, type ProviderSweepTargetRef, type ProviderWarning, type ProviderWarningCause, type ProviderWarningCauseReason, type ProviderWarningKind, type ProviderWarningOmission, type ProviderWarningOmissionKind, type ProviderWarningOmissionRecovery, type ProviderWarningOmissionScope, type ProviderWarningScope, type ProviderWarningSelector, type ProviderWarningUnreadableItems, type PullRequestBatchResult, type PullRequestBatchTarget, type PullRequestBranchResult, type PullRequestBranchTarget, type PullRequestCountResult, type PullRequestCountScope, type PullRequestEtagInclude, type PullRequestFieldGroup, PullRequestFilter, type PullRequestProjection, type PullRequestSearchCapabilities, type PullRequestSearchCriteria, type PullRequestStateFilter, type PullRequestSweepOptions, type RefSet, type RepositoriesProvider, type RepositoryIdentity, type RepositoryResolution, type RepositoryResolutionStatus, type ResolveRepositoryResult, type Source, type Sources, type SupportedCloudIntegrationIds, areDomainsOnSameHost, createManualTokenAuthProvider, getIssueFieldPresence, getPullRequestFieldPresence, hostFromDomain, isIntegrationId, isSupportedCloudIntegrationId, toCloudIntegrationType, toIntegrationId };
|
|
84
|
+
export { type Account, type AccountProvider, type AuthenticationSessionLike, type AuthenticationSessionsChangeEvent, type Autolink, type AutolinkReference, type ClosedPullRequestSweepOptions, type CloudIntegrationAuthType, type CloudIntegrationConnection, type CloudIntegrationType, type ConfigChangeEvent, type ConfigProvider, type ConfiguredIntegrationDescriptor, type ConfiguredIntegrationsChangeEvent, type ConnectionStateChangeEvent, type CurrentAccountResult, type DynamicAutolinkReference, type FieldPresence, type GetAutolinkReferencesOptions, GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, type HttpProvider, type IntegrationAuthenticationProvider, type IntegrationAuthenticationProviderDescriptor, type IntegrationAuthenticationSessionDescriptor, type IntegrationIds, type IntegrationManager, type IntegrationServiceHooks, type IntegrationStorageProvider, type IntegrationsRemoteConfig, type IssueBatchResult, type IssueBatchTarget, type IssueCountResult, type IssueCountScope, type IssueDeleteOptions, type IssueEtagInclude, type IssueFieldGroup, IssueFilter, type IssueProjection, type IssueSearchCapabilities, type IssueSearchCriteria, type IssueSearchRelationship, type IssueStateFilter, type IssueWriteOptions, type IssueWriteResult, IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId, type ListLinearProjectsOptions, type ListOrgsOptions, type ListProjectsOptions, type ManualTokenAuthProviderOptions, type ProviderAuthenticationSession, type ProviderBroadenOrg, type ProviderBroadenResult, type ProviderLinearProjectShape, type ProviderOrganization, type ProviderPageInfo, type ProviderPagedResult, type ProviderReference, type ProviderRepositoriesInput, type ProviderRepositoryInput, type ProviderRepositoryShape, type ProviderResult, type ProviderSweepResult, type ProviderSweepTarget, type ProviderSweepTargetEvent, type ProviderSweepTargetRef, type ProviderWarning, type ProviderWarningCause, type ProviderWarningCauseReason, type ProviderWarningKind, type ProviderWarningOmission, type ProviderWarningOmissionKind, type ProviderWarningOmissionRecovery, type ProviderWarningOmissionScope, type ProviderWarningScope, type ProviderWarningSelector, type ProviderWarningUnreadableItems, type PullRequestBatchResult, type PullRequestBatchTarget, type PullRequestBranchResult, type PullRequestBranchTarget, type PullRequestCountResult, type PullRequestCountScope, type PullRequestEtagInclude, type PullRequestFieldGroup, PullRequestFilter, type PullRequestProjection, type PullRequestSearchCapabilities, type PullRequestSearchCriteria, type PullRequestStateFilter, type PullRequestSweepOptions, type RefSet, type RepositoriesProvider, type RepositoryIdentity, type RepositoryResolution, type RepositoryResolutionStatus, type ResolveRepositoryResult, type Source, type Sources, type SupportedCloudIntegrationIds, areDomainsOnSameHost, createManualTokenAuthProvider, getIssueFieldPresence, getPullRequestFieldPresence, hostFromDomain, isIntegrationId, isSupportedCloudIntegrationId, toCloudIntegrationType, toIntegrationId };
|
|
84
85
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../plus/integrations/src/index.ts"],"sourcesContent":["// Public facade for `@gitlens/integrations`.\n//\n// External consumers should import from this entry point only, not from the\n// package's internal subpaths, with one exception: the lightweight, token-scoped\n// read API is a supported public subpath (`./lite.js`). It's kept out of this\n// facade on purpose so importing the session-managed manager doesn't eagerly pull\n// in every provider API client. The internal classes (IntegrationService,\n// IntegrationAuthenticationService, etc.) are not part of the public API and\n// may be refactored without semver bumps.\n\nimport type { Account } from '@gitlens/git/models/author.js';\nimport { CacheController } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationIds } from './constants.js';\nimport type {\n\tAccountProvider,\n\tConfigProvider,\n\tHttpProvider,\n\tIntegrationCacheProvider,\n\tIntegrationServiceHooks,\n\tIntegrationStorageProvider,\n\tRepositoriesProvider,\n} from './context.js';\nimport { createIntegrationService } from './integrationService.js';\nimport type { IntegrationManager } from './manager.js';\n\nexport type { Autolink, AutolinkReference, DynamicAutolinkReference, RefSet } from '@gitlens/git/models/autolink.js';\nexport type { ProviderReference } from '@gitlens/git/models/remoteProvider.js';\n\n/** A cached provider value, which may still be resolving. */\nexport type IntegrationManagerCacheResult<T> = Promise<T | undefined> | T | undefined;\n\n/** Produces an account value on a cache miss. */\nexport type IntegrationManagerCacheLoader<T> = (cacheable: CacheController) => {\n\tvalue: IntegrationManagerCacheResult<T>;\n\texpiresAt?: number;\n};\n\n/** Stable integration identity supplied to the consumer-owned account cache. */\nexport interface IntegrationAccountCacheDescriptor {\n\treadonly id: IntegrationIds;\n\treadonly domain?: string;\n}\n\n/** Cache controls attached to a provider account lookup. */\nexport interface IntegrationManagerCacheOptions {\n\treadonly connectionId?: string;\n\treadonly etag?: string;\n\treadonly expiryOverride?: boolean | number;\n\treadonly expireOnError?: boolean;\n}\n\n/**\n * Optional consumer-owned cache for values reused by the public manager facade.\n *\n * The manager only needs cross-call caching for provider identity lookups. Other caches used by the GitLens\n * extension host are implementation details and deliberately stay out of this contract.\n */\nexport interface IntegrationManagerCacheProvider {\n\tgetCurrentAccount(\n\t\tintegration: IntegrationAccountCacheDescriptor,\n\t\tcacheable: IntegrationManagerCacheLoader<Account>,\n\t\toptions?: IntegrationManagerCacheOptions,\n\t): IntegrationManagerCacheResult<Account>;\n}\n\nfunction loadUncached<T>(loader: IntegrationManagerCacheLoader<T>): IntegrationManagerCacheResult<T> {\n\treturn loader(new CacheController()).value;\n}\n\nconst uncachedIntegrationCacheProvider: IntegrationCacheProvider = {\n\tgetRepositoryMetadata: (_repo, _integration, loader) => loadUncached(loader),\n\tgetRepositoryDefaultBranch: (_repo, _integration, loader) => loadUncached(loader),\n\tgetPullRequestForSha: (_sha, _repo, _integration, loader) => loadUncached(loader),\n\tgetPullRequestForBranch: (_branch, _repo, _integration, loader) => loadUncached(loader),\n\tgetPullRequest: (_id, _resource, _integration, loader) => loadUncached(loader),\n\tgetIssueOrPullRequest: (_id, _type, _resource, _integration, loader) => loadUncached(loader),\n\tgetIssue: (_id, _resource, _integration, loader) => loadUncached(loader),\n\tgetCurrentAccount: (_integration, loader) => loadUncached(loader),\n\t// Nothing is cached, so there is nothing to evict.\n\tdeletePullRequests: () => {},\n};\n\nfunction toIntegrationCacheProvider(cache: IntegrationManagerCacheProvider | undefined): IntegrationCacheProvider {\n\tif (cache == null) return uncachedIntegrationCacheProvider;\n\n\treturn {\n\t\t...uncachedIntegrationCacheProvider,\n\t\tgetCurrentAccount: (integration, loader, options) =>\n\t\t\tcache.getCurrentAccount({ id: integration.id, domain: integration.domain }, loader, options),\n\t};\n}\n\n/**\n * Consumer-facing runtime for {@link createIntegrationManager}.\n *\n * External consumers may omit `cache`; reads then execute their loaders directly without cross-call caching.\n * The extension host's broader integration context remains private to the implementation.\n */\nexport interface IntegrationManagerContext {\n\treadonly storage: IntegrationStorageProvider;\n\treadonly account: AccountProvider;\n\treadonly config: ConfigProvider;\n\treadonly http: HttpProvider;\n\treadonly cache?: IntegrationManagerCacheProvider;\n\treadonly repositories: RepositoriesProvider;\n\treadonly hooks?: IntegrationServiceHooks;\n}\n\nexport type {\n\tClosedPullRequestSweepOptions,\n\tGetAutolinkReferencesOptions,\n\tIntegrationManager,\n\tListLinearProjectsOptions,\n\tListOrgsOptions,\n\tListProjectsOptions,\n\t// Every option shape a caller has to BUILD is exported, not just the ones the manager returns:\n\t// `manager.js` is not a public subpath, so a type omitted here can't be named by a consumer at all\n\t// (`broadenIssues`' `orgs` needed `ProviderBroadenOrg` and had to be re-declared downstream).\n\tProviderBroadenOrg,\n\tProviderRepositoriesInput,\n\tProviderRepositoryInput,\n\tProviderSweepTarget,\n\tProviderSweepTargetEvent,\n\tPullRequestSweepOptions,\n} from './manager.js';\n\n/**\n * Construct an `@gitlens/integrations` manager bound to the supplied runtime.\n *\n * The runtime is the **single** cross-boundary contract — anything the\n * package needs (HTTP, storage, cache, auth, subscription, telemetry, UI,\n * configuration, environment) flows through it. The package never imports\n * `vscode`, `Container`, or any consumer-internal types.\n *\n * The returned manager owns its internal services; dispose it (or its\n * containing scope) to release every cached integration plus the runtime's\n * own VS Code subscriptions.\n */\nexport function createIntegrationManager(ctx: IntegrationManagerContext): IntegrationManager {\n\treturn createIntegrationService({\n\t\t...ctx,\n\t\tcache: toIntegrationCacheProvider(ctx.cache),\n\t});\n}\n\n// Re-exports for the public API surface.\nexport type {\n\tAccountProvider,\n\tAuthenticationSessionsChangeEvent,\n\tConfigChangeEvent,\n\tConfigProvider,\n\tRepositoriesProvider,\n\tHttpProvider,\n\tIntegrationsRemoteConfig,\n\tIntegrationServiceHooks,\n\tIntegrationStorageProvider,\n} from './context.js';\nexport type { Source, Sources } from './telemetry.js';\nexport type { IntegrationIds, SupportedCloudIntegrationIds } from './constants.js';\nexport type { ConfiguredIntegrationsChangeEvent } from './authentication/configuredIntegrationService.js';\n\n// Authentication contract — what `IntegrationServiceHooks.createAuthenticationProvider`\n// implementers return. Consumers can plug in any auth strategy (manual token,\n// OAuth, host-managed) by returning an object implementing this interface from\n// the hook.\nexport type {\n\tIntegrationAuthenticationProvider,\n\tIntegrationAuthenticationProviderDescriptor,\n\tIntegrationAuthenticationSessionDescriptor,\n} from './authentication/integrationAuthenticationProvider.js';\nexport type {\n\tAuthenticationSessionLike,\n\tCloudIntegrationAuthType,\n\tCloudIntegrationConnection,\n\tCloudIntegrationType,\n\tConfiguredIntegrationDescriptor,\n\tProviderAuthenticationSession,\n} from './authentication/models.js';\n// Provider-id mapping helpers for consumers bridging their own provider ids to `IntegrationIds`\n// (e.g. mapping multi-account connections from `getConfigured` back to a provider) and vice versa.\nexport { toCloudIntegrationType, toIntegrationId } from './authentication/models.js';\n// Domain normalization is part of connection selection and repository resolution; consumers should use the\n// same implementation rather than importing an internal utility subpath or maintaining a divergent copy.\nexport { areDomainsOnSameHost, hostFromDomain } from './utils/domain.utils.js';\n\n// Convenience: wrap a static access token (env var, CLI flag, secret manager)\n// as an `IntegrationAuthenticationProvider`. For OAuth/refresh flows, implement\n// the interface directly — this helper is for non-interactive consumers only.\nexport {\n\tcreateManualTokenAuthProvider,\n\ttype ManualTokenAuthProviderOptions,\n} from './authentication/manualTokenProvider.js';\n\nexport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n\tisIntegrationId,\n\tisSupportedCloudIntegrationId,\n} from './constants.js';\n\n// Neutral pagination + warning result types the Kepler ProviderBackend adapter maps to its own DTOs.\n// These carry no `@gitkraken/provider-apis` types, so consumers depend only on `@gitkraken/core-gitlens`.\nexport type {\n\tConnectionStateChangeEvent,\n\tProviderBroadenResult,\n\tProviderPagedResult,\n\tProviderPageInfo,\n\tProviderResult,\n\tProviderSweepResult,\n\tProviderSweepTargetRef,\n\tProviderWarning,\n\tProviderWarningCause,\n\tProviderWarningCauseReason,\n\tProviderWarningKind,\n\tProviderWarningOmission,\n\tProviderWarningOmissionKind,\n\tProviderWarningOmissionRecovery,\n\tProviderWarningOmissionScope,\n\tProviderWarningScope,\n\tProviderWarningSelector,\n\tProviderWarningUnreadableItems,\n\tProviderLinearProjectShape,\n\tProviderOrganization,\n\tProviderRepositoryShape,\n\tRepositoryIdentity,\n\tRepositoryResolution,\n\tRepositoryResolutionStatus,\n\tResolveRepositoryResult,\n} from './results.js';\n// Runtime enums — re-exported as values (not `export type`) so consumers can read their members.\nexport { IssueFilter, PullRequestFilter } from './providerFilters.js';\n// The filtered issue search's criteria model and the capability table that says which of it a provider honors.\n// String unions and plain interfaces, so a consumer builds criteria without importing an internal subpath.\nexport type { IssueSearchCapabilities, IssueSearchCriteria, IssueSearchRelationship } from './providerFilters.js';\n// Account-wide pull-request search criteria and the per-provider capability table.\nexport type { PullRequestSearchCapabilities, PullRequestSearchCriteria } from './providerFilters.js';\n// The count-only issue and pull-request probes' input and result shapes.\nexport type {\n\tIssueCountResult,\n\tIssueCountScope,\n\tPullRequestCountResult,\n\tPullRequestCountScope,\n} from './reads/counts.js';\nexport type { IssueBatchResult, IssueBatchTarget } from './reads/issueBatch.js';\nexport type { PullRequestBatchResult, PullRequestBatchTarget } from './reads/pullRequestBatch.js';\nexport type { IssueEtagInclude, PullRequestEtagInclude } from './models/integration.js';\nexport type { PullRequestBranchResult, PullRequestBranchTarget } from './reads/pullRequestBranches.js';\n// The current-account read's result, and the account shape every identity-bearing read already returns.\nexport type { CurrentAccountResult } from './reads/currentAccount.js';\nexport type { Account } from '@gitlens/git/models/author.js';\n// Cross-provider PR/issue state filters (string unions in the git models).\nexport type { PullRequestStateFilter } from '@gitlens/git/models/pullRequest.js';\nexport type { IssueStateFilter } from '@gitlens/git/models/issue.js';\n// Which read produced a row, and which of its fields that read fetched.\nexport type { PullRequestProjection } from '@gitlens/git/models/pullRequest.js';\nexport type { IssueProjection } from '@gitlens/git/models/issue.js';\nexport type { FieldPresence, IssueFieldGroup, PullRequestFieldGroup } from './fieldPresence.js';\nexport { getIssueFieldPresence, getPullRequestFieldPresence } from './fieldPresence.js';\n"],"mappings":";;;;;;;;;;AAiEA,SAAS,aAAgB,QAA4E;CACpG,OAAO,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC;AACtC;AAEA,MAAM,mCAA6D;CAClE,wBAAwB,OAAO,cAAc,WAAW,aAAa,MAAM;CAC3E,6BAA6B,OAAO,cAAc,WAAW,aAAa,MAAM;CAChF,uBAAuB,MAAM,OAAO,cAAc,WAAW,aAAa,MAAM;CAChF,0BAA0B,SAAS,OAAO,cAAc,WAAW,aAAa,MAAM;CACtF,iBAAiB,KAAK,WAAW,cAAc,WAAW,aAAa,MAAM;CAC7E,wBAAwB,KAAK,OAAO,WAAW,cAAc,WAAW,aAAa,MAAM;CAC3F,WAAW,KAAK,WAAW,cAAc,WAAW,aAAa,MAAM;CACvE,oBAAoB,cAAc,WAAW,aAAa,MAAM;CAEhE,0BAA0B,CAAC;AAC5B;AAEA,SAAS,2BAA2B,OAA8E;CACjH,IAAI,SAAS,MAAM,OAAO;CAE1B,OAAO;EACN,GAAG;EACH,oBAAoB,aAAa,QAAQ,YACxC,MAAM,kBAAkB;GAAE,IAAI,YAAY;GAAI,QAAQ,YAAY;EAAO,GAAG,QAAQ,OAAO;CAC7F;AACD;;;;;;;;;;;;;AAgDA,SAAgB,yBAAyB,KAAoD;CAC5F,OAAO,yBAAyB;EAC/B,GAAG;EACH,OAAO,2BAA2B,IAAI,KAAK;CAC5C,CAAC;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../plus/integrations/src/index.ts"],"sourcesContent":["// Public facade for `@gitlens/integrations`.\n//\n// External consumers should import from this entry point only, not from the\n// package's internal subpaths, with one exception: the lightweight, token-scoped\n// read API is a supported public subpath (`./lite.js`). It's kept out of this\n// facade on purpose so importing the session-managed manager doesn't eagerly pull\n// in every provider API client. The internal classes (IntegrationService,\n// IntegrationAuthenticationService, etc.) are not part of the public API and\n// may be refactored without semver bumps.\n\nimport type { Account } from '@gitlens/git/models/author.js';\nimport { CacheController } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationIds } from './constants.js';\nimport type {\n\tAccountProvider,\n\tConfigProvider,\n\tHttpProvider,\n\tIntegrationCacheProvider,\n\tIntegrationServiceHooks,\n\tIntegrationStorageProvider,\n\tRepositoriesProvider,\n} from './context.js';\nimport { createIntegrationService } from './integrationService.js';\nimport type { IntegrationManager } from './manager.js';\n\nexport type { Autolink, AutolinkReference, DynamicAutolinkReference, RefSet } from '@gitlens/git/models/autolink.js';\nexport type { ProviderReference } from '@gitlens/git/models/remoteProvider.js';\n\n/** A cached provider value, which may still be resolving. */\nexport type IntegrationManagerCacheResult<T> = Promise<T | undefined> | T | undefined;\n\n/** Produces an account value on a cache miss. */\nexport type IntegrationManagerCacheLoader<T> = (cacheable: CacheController) => {\n\tvalue: IntegrationManagerCacheResult<T>;\n\texpiresAt?: number;\n};\n\n/** Stable integration identity supplied to the consumer-owned account cache. */\nexport interface IntegrationAccountCacheDescriptor {\n\treadonly id: IntegrationIds;\n\treadonly domain?: string;\n}\n\n/** Cache controls attached to a provider account lookup. */\nexport interface IntegrationManagerCacheOptions {\n\treadonly connectionId?: string;\n\treadonly etag?: string;\n\treadonly expiryOverride?: boolean | number;\n\treadonly expireOnError?: boolean;\n}\n\n/**\n * Optional consumer-owned cache for values reused by the public manager facade.\n *\n * The manager only needs cross-call caching for provider identity lookups. Other caches used by the GitLens\n * extension host are implementation details and deliberately stay out of this contract.\n */\nexport interface IntegrationManagerCacheProvider {\n\tgetCurrentAccount(\n\t\tintegration: IntegrationAccountCacheDescriptor,\n\t\tcacheable: IntegrationManagerCacheLoader<Account>,\n\t\toptions?: IntegrationManagerCacheOptions,\n\t): IntegrationManagerCacheResult<Account>;\n}\n\nfunction loadUncached<T>(loader: IntegrationManagerCacheLoader<T>): IntegrationManagerCacheResult<T> {\n\treturn loader(new CacheController()).value;\n}\n\nconst uncachedIntegrationCacheProvider: IntegrationCacheProvider = {\n\tgetRepositoryMetadata: (_repo, _integration, loader) => loadUncached(loader),\n\tgetRepositoryDefaultBranch: (_repo, _integration, loader) => loadUncached(loader),\n\tgetPullRequestForSha: (_sha, _repo, _integration, loader) => loadUncached(loader),\n\tgetPullRequestForBranch: (_branch, _repo, _integration, loader) => loadUncached(loader),\n\tgetPullRequest: (_id, _resource, _integration, loader) => loadUncached(loader),\n\tgetIssueOrPullRequest: (_id, _type, _resource, _integration, loader) => loadUncached(loader),\n\tgetIssue: (_id, _resource, _integration, loader) => loadUncached(loader),\n\tgetCurrentAccount: (_integration, loader) => loadUncached(loader),\n\t// Nothing is cached, so there is nothing to evict.\n\tdeletePullRequests: () => {},\n};\n\nfunction toIntegrationCacheProvider(cache: IntegrationManagerCacheProvider | undefined): IntegrationCacheProvider {\n\tif (cache == null) return uncachedIntegrationCacheProvider;\n\n\treturn {\n\t\t...uncachedIntegrationCacheProvider,\n\t\tgetCurrentAccount: (integration, loader, options) =>\n\t\t\tcache.getCurrentAccount({ id: integration.id, domain: integration.domain }, loader, options),\n\t};\n}\n\n/**\n * Consumer-facing runtime for {@link createIntegrationManager}.\n *\n * External consumers may omit `cache`; reads then execute their loaders directly without cross-call caching.\n * The extension host's broader integration context remains private to the implementation.\n */\nexport interface IntegrationManagerContext {\n\treadonly storage: IntegrationStorageProvider;\n\treadonly account: AccountProvider;\n\treadonly config: ConfigProvider;\n\treadonly http: HttpProvider;\n\treadonly cache?: IntegrationManagerCacheProvider;\n\treadonly repositories: RepositoriesProvider;\n\treadonly hooks?: IntegrationServiceHooks;\n}\n\nexport type {\n\tClosedPullRequestSweepOptions,\n\tGetAutolinkReferencesOptions,\n\tIntegrationManager,\n\tIssueDeleteOptions,\n\tIssueWriteOptions,\n\tListLinearProjectsOptions,\n\tListOrgsOptions,\n\tListProjectsOptions,\n\t// Every option shape a caller has to BUILD is exported, not just the ones the manager returns:\n\t// `manager.js` is not a public subpath, so a type omitted here can't be named by a consumer at all\n\t// (`broadenIssues`' `orgs` needed `ProviderBroadenOrg` and had to be re-declared downstream).\n\tProviderBroadenOrg,\n\tProviderRepositoriesInput,\n\tProviderRepositoryInput,\n\tProviderSweepTarget,\n\tProviderSweepTargetEvent,\n\tPullRequestSweepOptions,\n} from './manager.js';\nexport type { IssueWriteResult } from '@gitlens/git-github/api/issueWrites.js';\n\n/**\n * Construct an `@gitlens/integrations` manager bound to the supplied runtime.\n *\n * The runtime is the **single** cross-boundary contract — anything the\n * package needs (HTTP, storage, cache, auth, subscription, telemetry, UI,\n * configuration, environment) flows through it. The package never imports\n * `vscode`, `Container`, or any consumer-internal types.\n *\n * The returned manager owns its internal services; dispose it (or its\n * containing scope) to release every cached integration plus the runtime's\n * own VS Code subscriptions.\n */\nexport function createIntegrationManager(ctx: IntegrationManagerContext): IntegrationManager {\n\treturn createIntegrationService({\n\t\t...ctx,\n\t\tcache: toIntegrationCacheProvider(ctx.cache),\n\t});\n}\n\n// Re-exports for the public API surface.\nexport type {\n\tAccountProvider,\n\tAuthenticationSessionsChangeEvent,\n\tConfigChangeEvent,\n\tConfigProvider,\n\tRepositoriesProvider,\n\tHttpProvider,\n\tIntegrationsRemoteConfig,\n\tIntegrationServiceHooks,\n\tIntegrationStorageProvider,\n} from './context.js';\nexport type { Source, Sources } from './telemetry.js';\nexport type { IntegrationIds, SupportedCloudIntegrationIds } from './constants.js';\nexport type { ConfiguredIntegrationsChangeEvent } from './authentication/configuredIntegrationService.js';\n\n// Authentication contract — what `IntegrationServiceHooks.createAuthenticationProvider`\n// implementers return. Consumers can plug in any auth strategy (manual token,\n// OAuth, host-managed) by returning an object implementing this interface from\n// the hook.\nexport type {\n\tIntegrationAuthenticationProvider,\n\tIntegrationAuthenticationProviderDescriptor,\n\tIntegrationAuthenticationSessionDescriptor,\n} from './authentication/integrationAuthenticationProvider.js';\nexport type {\n\tAuthenticationSessionLike,\n\tCloudIntegrationAuthType,\n\tCloudIntegrationConnection,\n\tCloudIntegrationType,\n\tConfiguredIntegrationDescriptor,\n\tProviderAuthenticationSession,\n} from './authentication/models.js';\n// Provider-id mapping helpers for consumers bridging their own provider ids to `IntegrationIds`\n// (e.g. mapping multi-account connections from `getConfigured` back to a provider) and vice versa.\nexport { toCloudIntegrationType, toIntegrationId } from './authentication/models.js';\n// Domain normalization is part of connection selection and repository resolution; consumers should use the\n// same implementation rather than importing an internal utility subpath or maintaining a divergent copy.\nexport { areDomainsOnSameHost, hostFromDomain } from './utils/domain.utils.js';\n\n// Convenience: wrap a static access token (env var, CLI flag, secret manager)\n// as an `IntegrationAuthenticationProvider`. For OAuth/refresh flows, implement\n// the interface directly — this helper is for non-interactive consumers only.\nexport {\n\tcreateManualTokenAuthProvider,\n\ttype ManualTokenAuthProviderOptions,\n} from './authentication/manualTokenProvider.js';\n\nexport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n\tisIntegrationId,\n\tisSupportedCloudIntegrationId,\n} from './constants.js';\n\n// Neutral pagination + warning result types the Kepler ProviderBackend adapter maps to its own DTOs.\n// These carry no `@gitkraken/provider-apis` types, so consumers depend only on `@gitkraken/core-gitlens`.\nexport type {\n\tConnectionStateChangeEvent,\n\tProviderBroadenResult,\n\tProviderPagedResult,\n\tProviderPageInfo,\n\tProviderResult,\n\tProviderSweepResult,\n\tProviderSweepTargetRef,\n\tProviderWarning,\n\tProviderWarningCause,\n\tProviderWarningCauseReason,\n\tProviderWarningKind,\n\tProviderWarningOmission,\n\tProviderWarningOmissionKind,\n\tProviderWarningOmissionRecovery,\n\tProviderWarningOmissionScope,\n\tProviderWarningScope,\n\tProviderWarningSelector,\n\tProviderWarningUnreadableItems,\n\tProviderLinearProjectShape,\n\tProviderOrganization,\n\tProviderRepositoryShape,\n\tRepositoryIdentity,\n\tRepositoryResolution,\n\tRepositoryResolutionStatus,\n\tResolveRepositoryResult,\n} from './results.js';\n// Runtime enums — re-exported as values (not `export type`) so consumers can read their members.\nexport { IssueFilter, PullRequestFilter } from './providerFilters.js';\n// The filtered issue search's criteria model and the capability table that says which of it a provider honors.\n// String unions and plain interfaces, so a consumer builds criteria without importing an internal subpath.\nexport type { IssueSearchCapabilities, IssueSearchCriteria, IssueSearchRelationship } from './providerFilters.js';\n// Account-wide pull-request search criteria and the per-provider capability table.\nexport type { PullRequestSearchCapabilities, PullRequestSearchCriteria } from './providerFilters.js';\n// The count-only issue and pull-request probes' input and result shapes.\nexport type {\n\tIssueCountResult,\n\tIssueCountScope,\n\tPullRequestCountResult,\n\tPullRequestCountScope,\n} from './reads/counts.js';\nexport type { IssueBatchResult, IssueBatchTarget } from './reads/issueBatch.js';\nexport type { PullRequestBatchResult, PullRequestBatchTarget } from './reads/pullRequestBatch.js';\nexport type { IssueEtagInclude, PullRequestEtagInclude } from './models/integration.js';\nexport type { PullRequestBranchResult, PullRequestBranchTarget } from './reads/pullRequestBranches.js';\n// The current-account read's result, and the account shape every identity-bearing read already returns.\nexport type { CurrentAccountResult } from './reads/currentAccount.js';\nexport type { Account } from '@gitlens/git/models/author.js';\n// Cross-provider PR/issue state filters (string unions in the git models).\nexport type { PullRequestStateFilter } from '@gitlens/git/models/pullRequest.js';\nexport type { IssueStateFilter } from '@gitlens/git/models/issue.js';\n// Which read produced a row, and which of its fields that read fetched.\nexport type { PullRequestProjection } from '@gitlens/git/models/pullRequest.js';\nexport type { IssueProjection } from '@gitlens/git/models/issue.js';\nexport type { FieldPresence, IssueFieldGroup, PullRequestFieldGroup } from './fieldPresence.js';\nexport { getIssueFieldPresence, getPullRequestFieldPresence } from './fieldPresence.js';\n"],"mappings":";;;;;;;;;;AAiEA,SAAS,aAAgB,QAA4E;CACpG,OAAO,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC;AACtC;AAEA,MAAM,mCAA6D;CAClE,wBAAwB,OAAO,cAAc,WAAW,aAAa,MAAM;CAC3E,6BAA6B,OAAO,cAAc,WAAW,aAAa,MAAM;CAChF,uBAAuB,MAAM,OAAO,cAAc,WAAW,aAAa,MAAM;CAChF,0BAA0B,SAAS,OAAO,cAAc,WAAW,aAAa,MAAM;CACtF,iBAAiB,KAAK,WAAW,cAAc,WAAW,aAAa,MAAM;CAC7E,wBAAwB,KAAK,OAAO,WAAW,cAAc,WAAW,aAAa,MAAM;CAC3F,WAAW,KAAK,WAAW,cAAc,WAAW,aAAa,MAAM;CACvE,oBAAoB,cAAc,WAAW,aAAa,MAAM;CAEhE,0BAA0B,CAAC;AAC5B;AAEA,SAAS,2BAA2B,OAA8E;CACjH,IAAI,SAAS,MAAM,OAAO;CAE1B,OAAO;EACN,GAAG;EACH,oBAAoB,aAAa,QAAQ,YACxC,MAAM,kBAAkB;GAAE,IAAI,YAAY;GAAI,QAAQ,YAAY;EAAO,GAAG,QAAQ,OAAO;CAC7F;AACD;;;;;;;;;;;;;AAmDA,SAAgB,yBAAyB,KAAoD;CAC5F,OAAO,yBAAyB;EAC/B,GAAG;EACH,OAAO,2BAA2B,IAAI,KAAK;CAC5C,CAAC;AACF"}
|
|
@@ -6,6 +6,7 @@ import { GitRemote } from "../../git/models/remote.js";
|
|
|
6
6
|
import { IssueSearchCriteria, IssueShape, IssueSorting, IssueStateFilter } from "../../git/models/issue.js";
|
|
7
7
|
import { PullRequest, PullRequestFilter, PullRequestSearchCriteria, PullRequestShape, PullRequestStateFilter } from "../../git/models/pullRequest.js";
|
|
8
8
|
import { Account } from "../../git/models/author.js";
|
|
9
|
+
import { IssueWriteResult } from "../git-github/api/issueWrites.js";
|
|
9
10
|
import { GitHubApi } from "../git-github/api/github.js";
|
|
10
11
|
import { ConfiguredIntegrationDescriptor, SessionPublication } from "./authentication/models.js";
|
|
11
12
|
import { CloudGitSelfManagedHostIntegrationIds, GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, SupportedCloudIntegrationIds } from "./constants.js";
|
|
@@ -24,9 +25,10 @@ import { SupportedFilters } from "./reads/filters.js";
|
|
|
24
25
|
import { IssueBatchResult, IssueBatchTarget } from "./reads/issueBatch.js";
|
|
25
26
|
import { PullRequestBatchResult, PullRequestBatchTarget } from "./reads/pullRequestBatch.js";
|
|
26
27
|
import { PullRequestBranchResult, PullRequestBranchTarget } from "./reads/pullRequestBranches.js";
|
|
27
|
-
import { ClosedPullRequestSweepOptions, GetAutolinkReferencesOptions, ListLinearProjectsOptions, ListOrgsOptions, ListProjectsOptions, ProviderBroadenOrg, PullRequestSweepOptions } from "./manager.js";
|
|
28
|
+
import { ClosedPullRequestSweepOptions, GetAutolinkReferencesOptions, IssueDeleteOptions, IssueWriteOptions, ListLinearProjectsOptions, ListOrgsOptions, ListProjectsOptions, ProviderBroadenOrg, PullRequestSweepOptions } from "./manager.js";
|
|
28
29
|
import "./providers/github/github.js";
|
|
29
30
|
import { ApiClients } from "./providers/apiClients.js";
|
|
31
|
+
import { GitHubIntegration } from "./providers/github.js";
|
|
30
32
|
import { IntegrationAuthenticationService } from "./authentication/integrationAuthenticationService.js";
|
|
31
33
|
import { IntegrationServiceContext, IntegrationsRemoteConfig } from "./context.js";
|
|
32
34
|
//#region ../plus/integrations/src/integrationService.d.ts
|
|
@@ -67,6 +69,7 @@ export declare class IntegrationService implements Disposable, RepositoryResolut
|
|
|
67
69
|
* secondary for an already-connected provider.
|
|
68
70
|
*/
|
|
69
71
|
connectSecondary(id: SupportedCloudIntegrationIds, source?: Source): Promise<boolean>;
|
|
72
|
+
get(id: GitCloudHostIntegrationId.GitHub): Promise<GitHubIntegration>;
|
|
70
73
|
get(id: GitCloudHostIntegrationId): Promise<GitHostIntegration>;
|
|
71
74
|
get(id: IssuesCloudHostIntegrationId): Promise<IssuesIntegration>;
|
|
72
75
|
get(id: GitCloudHostIntegrationId | CloudGitSelfManagedHostIntegrationIds, domain?: string): Promise<GitHostIntegration | undefined>;
|
|
@@ -479,6 +482,9 @@ export declare class IntegrationService implements Disposable, RepositoryResolut
|
|
|
479
482
|
cursor?: string;
|
|
480
483
|
forceSync?: boolean;
|
|
481
484
|
}): Promise<ProviderBroadenResult<IssueShape>>;
|
|
485
|
+
writeIssue(options: IssueWriteOptions): Promise<IssueWriteResult>;
|
|
486
|
+
deleteIssue(options: IssueDeleteOptions): Promise<IssueWriteResult>;
|
|
487
|
+
private mutateIssue;
|
|
482
488
|
/**
|
|
483
489
|
* Resolves a repository from a remote URL to its provider identity, using core-gitlens' remote matcher
|
|
484
490
|
* plus the provider's `getRepo` (the equivalent of `gk repo resolve`). Supports every provider whose
|
|
@@ -742,6 +742,43 @@ var IntegrationService = class {
|
|
|
742
742
|
async broadenIssues(options) {
|
|
743
743
|
return broadenIssues(this, options);
|
|
744
744
|
}
|
|
745
|
+
async writeIssue(options) {
|
|
746
|
+
if (options?.action !== "create" && options?.action !== "edit" && options?.action !== "set-state") return {
|
|
747
|
+
ok: false,
|
|
748
|
+
reason: "invalid-input"
|
|
749
|
+
};
|
|
750
|
+
return this.mutateIssue({ ...options });
|
|
751
|
+
}
|
|
752
|
+
async deleteIssue(options) {
|
|
753
|
+
if (options == null) return {
|
|
754
|
+
ok: false,
|
|
755
|
+
reason: "invalid-input"
|
|
756
|
+
};
|
|
757
|
+
return this.mutateIssue({
|
|
758
|
+
...options,
|
|
759
|
+
action: "delete"
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
async mutateIssue(options) {
|
|
763
|
+
const { providerId, connectionId } = options;
|
|
764
|
+
if (providerId !== "github") return {
|
|
765
|
+
ok: false,
|
|
766
|
+
reason: "unsupported"
|
|
767
|
+
};
|
|
768
|
+
if (typeof connectionId !== "string" || !connectionId.trim()) return {
|
|
769
|
+
ok: false,
|
|
770
|
+
reason: "invalid-input"
|
|
771
|
+
};
|
|
772
|
+
if (!this.getConfigured(providerId).some((connection) => connection.id === connectionId)) return {
|
|
773
|
+
ok: false,
|
|
774
|
+
reason: "no-connection"
|
|
775
|
+
};
|
|
776
|
+
const integration = await this.get(providerId).catch(() => void 0);
|
|
777
|
+
return integration != null ? integration.mutateIssue(connectionId, options) : {
|
|
778
|
+
ok: false,
|
|
779
|
+
reason: "unknown"
|
|
780
|
+
};
|
|
781
|
+
}
|
|
745
782
|
/**
|
|
746
783
|
* Resolves a repository from a remote URL to its provider identity, using core-gitlens' remote matcher
|
|
747
784
|
* plus the provider's `getRepo` (the equivalent of `gk repo resolve`). Supports every provider whose
|