@vite-hub/forge 0.1.0 → 0.3.1
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/README.md +43 -7
- package/dist/{association-Cm0dUTDU-CDDhJnIh.js → association-Ds6Tgs0W-Cu9_YCGq.js} +1 -1
- package/dist/build/node.d.ts +12 -0
- package/dist/build/node.js +106 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.js +2 -0
- package/dist/{events-saDWbqbf-VX_k8jtr.js → events-C6C7lk1x-J8VCAjEX.js} +4 -4
- package/dist/{events-DudKM7vq-Cj_PCDdt.js → events-DW3SFUDA-D2rhS9D-.js} +4 -4
- package/dist/{events-CeChclTf-CX-gD8oy.js → events-DjRw3KSr-C72gY7Vu.js} +4 -4
- package/dist/{events-CRaLy7U3-3PNNp5WZ.js → events-DmSWTdpS-BdJBABfI.js} +4 -4
- package/dist/{events-7EBoeIPd-A2RUkJi5.js → events-uCMi3LHU-Bz79PQtq.js} +4 -4
- package/dist/{feed-Dyf730Ys-D0HgBba6.js → feed-BlzdKdNv-DbxuSgsx.js} +4 -4
- package/dist/{feed-DsC7Vws1-M_de2nSK.js → feed-BwdcTgZq-Bm_c8br8.js} +4 -4
- package/dist/{feed-CmBoYS3Z-CuC4i0fH.js → feed-CIaAZINm-Dpe9DxwK.js} +4 -4
- package/dist/{forgejo-BN8ItCfl.js → forgejo-UNPc42cY.js} +50 -8
- package/dist/{gitee-DExkQP6X-BxJS2dRY.js → gitee-BXyl2_3W-dQOAjWqr.js} +2 -2
- package/dist/{github-DtncTfmv.js → github-CUiEF2FK.js} +65 -40
- package/dist/{gitlab-BoDm8-BC.js → gitlab-zvWb9zOi.js} +65 -8
- package/dist/{graphql-DG5aJBT3-DceyFYdM.js → graphql-BDhuP5jN-BSpB8lWf.js} +59 -7
- package/dist/identity-CNTWZZuv.d.ts +27 -0
- package/dist/identity-CmVEBLP5.js +38 -0
- package/dist/index.d.ts +332 -110
- package/dist/index.js +815 -313
- package/dist/{knot-BpyTK9D7-CVIsX4I2.js → knot-bGebBK_B-CeDHcJUz.js} +16 -9
- package/dist/{tangled-DPt_0u21-zS41xdG5.js → tangled-8lg_73Wi-bSufNXiN.js} +1 -1
- package/dist/{templates-Bn8a-pd2-D9DhJEVD.js → templates-BGDqQMu4-PSB43E1j.js} +2 -2
- package/dist/{utils-CA_4WJhJ-DNgT61X2.js → utils-DC7MBR65-B7Vr2hFm.js} +3 -306
- package/dist/{webhooks-DgHwxxYz-D1V2LOr1.js → webhooks-Bc6QhmI8-CNgCERCq.js} +326 -5
- package/package.json +19 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as forgeIterable, L as memo, M as isFirstPage, P as iteratePages, S as createFetcher, _ as WebhookVerificationError,
|
|
2
|
-
//#region ../../node_modules/.pnpm/forges@
|
|
1
|
+
import { D as forgeIterable, L as memo, M as isFirstPage, P as iteratePages, S as createFetcher, _ as WebhookVerificationError, d as NotFoundError, dt as namespaceRef, ft as normaliseRepoName, g as UnsupportedOperationError, lt as isResolvedThread, p as ReadOnlyError, r as ContentNotTextError, ut as isUnsupported, w as createRequest } from "./utils-DC7MBR65-B7Vr2hFm.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/crypto-DydCoK4e.mjs
|
|
3
3
|
const encoder = new TextEncoder();
|
|
4
4
|
function toBytes(value) {
|
|
5
5
|
return typeof value === "string" ? encoder.encode(value) : value;
|
|
@@ -122,7 +122,313 @@ function bodyText(body) {
|
|
|
122
122
|
return typeof body === "string" ? body : new TextDecoder().decode(body);
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
|
-
//#region ../../node_modules/.pnpm/forges@
|
|
125
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/web-De5LwgO3.mjs
|
|
126
|
+
function sameRepo(a, b) {
|
|
127
|
+
if (!b || a.forge !== b.forge || a.instance !== b.instance) return false;
|
|
128
|
+
const [left, right] = [normaliseRepoName(a), normaliseRepoName(b)];
|
|
129
|
+
return left.owner === right.owner && left.name === right.name;
|
|
130
|
+
}
|
|
131
|
+
function lineOf(value) {
|
|
132
|
+
const line = Number.parseInt(value ?? "", 10);
|
|
133
|
+
return line > 0 ? { line } : {};
|
|
134
|
+
}
|
|
135
|
+
/** Reads `base...head` or `base..head`. Git forbids `..` in a ref name, so the first `..` separates the two. */
|
|
136
|
+
function rangeOf(value) {
|
|
137
|
+
const at = value.indexOf("..");
|
|
138
|
+
const base = value.slice(0, at);
|
|
139
|
+
const head = value.slice(value[at + 2] === "." ? at + 3 : at + 2);
|
|
140
|
+
return at > 0 && head ? { compare: {
|
|
141
|
+
base,
|
|
142
|
+
head
|
|
143
|
+
} } : {};
|
|
144
|
+
}
|
|
145
|
+
function encodePath(path) {
|
|
146
|
+
return path.split("/").map(encodeURIComponent).join("/");
|
|
147
|
+
}
|
|
148
|
+
function webUrlFor(web, target) {
|
|
149
|
+
if (("file" in target ? target.file : "raw" in target ? target.raw : "commit" in target ? target.commit : "compare" in target ? target.compare : void 0)?.repo.kind === "namespace") return;
|
|
150
|
+
let path;
|
|
151
|
+
if ("repo" in target) path = "section" in target && target.section ? web.section?.(target.repo, target.section) : web.repo(target.repo);
|
|
152
|
+
else if ("thread" in target) path = isResolvedThread(target.thread) || target.thread.displayNumber ? web.thread(target.thread) : void 0;
|
|
153
|
+
else if ("comment" in target) {
|
|
154
|
+
const { comment } = target;
|
|
155
|
+
path = isResolvedThread(comment.thread) ? web.comment?.(comment) : void 0;
|
|
156
|
+
} else if ("release" in target) path = web.release?.(target.release);
|
|
157
|
+
else if ("file" in target) path = web.file?.(target.file.repo, target.file.path, target.file.at ?? "HEAD", target.file.line);
|
|
158
|
+
else if ("raw" in target) path = web.raw?.(target.raw.repo, target.raw.path, target.raw.at ?? "HEAD");
|
|
159
|
+
else if ("commit" in target) path = target.commit.sha ? web.commit?.(target.commit.repo, target.commit.sha) : void 0;
|
|
160
|
+
else path = web.compare?.(target.compare.repo, target.compare.base, target.compare.head);
|
|
161
|
+
return path === void 0 ? void 0 : path.startsWith("/") ? `${web.baseUrl}${path}` : path;
|
|
162
|
+
}
|
|
163
|
+
/** `ssh://user@host:port/path` or `git://host:port/path` with the host in group 1, or `user@host:path` with it in group 2; the path is group 3. */
|
|
164
|
+
const CLONE_URL_RE = /^(?:(?:ssh|git):\/\/(?:[^@/]+@)?([^:/]+)(?::\d+)?\/|(?:[^@/\s]+@)?([^:/\s]+):(?!\/))(.+)$/i;
|
|
165
|
+
/** The `git+` that npm's `repository` field writes before a transport scheme. */
|
|
166
|
+
const GIT_PLUS_RE = /^git\+(?=[a-z]+:\/\/)/i;
|
|
167
|
+
/** The npm `repository` shorthand, https://docs.npmjs.com/cli/configuring-npm/package-json#repository */
|
|
168
|
+
const SHORTHAND_RE = /^(github|gitlab|bitbucket):(?!\/)/i;
|
|
169
|
+
const SHORTHAND_HOSTS = {
|
|
170
|
+
github: "github.com",
|
|
171
|
+
gitlab: "gitlab.com",
|
|
172
|
+
bitbucket: "bitbucket.org"
|
|
173
|
+
};
|
|
174
|
+
function parseWebUrl(web, input, origin) {
|
|
175
|
+
const base = new URL(web.baseUrl);
|
|
176
|
+
const prefix = base.pathname.replace(/\/$/, "");
|
|
177
|
+
const source = String(input).replace(GIT_PLUS_RE, "").replace(SHORTHAND_RE, (_, forge) => `https://${SHORTHAND_HOSTS[forge.toLowerCase()]}/`);
|
|
178
|
+
const clone = CLONE_URL_RE.exec(source);
|
|
179
|
+
let url;
|
|
180
|
+
try {
|
|
181
|
+
url = new URL(clone && (clone[1] ?? clone[2]).toLowerCase() === base.hostname ? `${base.origin}${prefix}/${clone[3]}` : source);
|
|
182
|
+
} catch {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (url.protocol !== "http:" && url.protocol !== "https:" || url.host !== base.host && !web.hosts?.includes(url.host) || url.username || url.password) return;
|
|
186
|
+
if (prefix && !url.pathname.startsWith(`${prefix}/`)) return;
|
|
187
|
+
let segments;
|
|
188
|
+
try {
|
|
189
|
+
segments = url.pathname.slice(prefix.length).split("/").filter(Boolean).map(decodeURIComponent);
|
|
190
|
+
} catch {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
return web.parse(segments, url, origin);
|
|
194
|
+
}
|
|
195
|
+
function referenceFor(web, ref, options = {}) {
|
|
196
|
+
if (!web || !("sha" in ref || isResolvedThread(ref) || ref.displayNumber)) return;
|
|
197
|
+
return web.reference?.(ref, sameRepo(ref.repo, options.from), options.expand ?? false) ?? webUrlFor(web, "sha" in ref ? { commit: ref } : { thread: ref });
|
|
198
|
+
}
|
|
199
|
+
/** `owner/name`, for forges that nest no deeper. */
|
|
200
|
+
const OWNER_NAME = String.raw`[\w.-]+\/[\w.-]+`;
|
|
201
|
+
/** What cannot come right before a reference, so that a path, an email address or a word does not read as one. */
|
|
202
|
+
const BEFORE = String.raw`(?<![\w/.@#~&!+-])`;
|
|
203
|
+
/** What cannot come right after a reference: a word character, or a dot, slash or `@` that continues a word. */
|
|
204
|
+
const AFTER = String.raw`(?![\w-]|[./@]\w)`;
|
|
205
|
+
const SHA = "[0-9a-f]{7,40}";
|
|
206
|
+
const SCHEME_CHAR = /[\w+.-]/;
|
|
207
|
+
const LETTER = /[a-z]/i;
|
|
208
|
+
const SPACE = /\s/;
|
|
209
|
+
const rules = /* @__PURE__ */ new WeakMap();
|
|
210
|
+
function repoIn(slug, origin) {
|
|
211
|
+
const at = slug.lastIndexOf("/");
|
|
212
|
+
return {
|
|
213
|
+
...origin,
|
|
214
|
+
owner: slug.slice(0, at),
|
|
215
|
+
name: slug.slice(at + 1)
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/** The spans of URLs in `text`, each from its scheme to the next whitespace. */
|
|
219
|
+
function urlSpans(text) {
|
|
220
|
+
const spans = [];
|
|
221
|
+
for (let at = text.indexOf("://"); at !== -1; at = text.indexOf("://", at + 1)) {
|
|
222
|
+
let start = at;
|
|
223
|
+
while (start > 0 && SCHEME_CHAR.test(text[start - 1])) start--;
|
|
224
|
+
while (start < at && !LETTER.test(text[start])) start++;
|
|
225
|
+
if (start === at || at + 3 >= text.length || SPACE.test(text[at + 3])) continue;
|
|
226
|
+
let end = at + 4;
|
|
227
|
+
while (end < text.length && !SPACE.test(text[end])) end++;
|
|
228
|
+
spans.push([start, end]);
|
|
229
|
+
at = end;
|
|
230
|
+
}
|
|
231
|
+
return spans;
|
|
232
|
+
}
|
|
233
|
+
/** A bare sha needs a letter and a digit, so that neither a number nor a word reads as one. */
|
|
234
|
+
function isBareSha(value) {
|
|
235
|
+
return /[a-f]/.test(value) && /\d/.test(value);
|
|
236
|
+
}
|
|
237
|
+
function rulesFor(syntax) {
|
|
238
|
+
const cached = rules.get(syntax);
|
|
239
|
+
if (cached) return cached;
|
|
240
|
+
const compiled = [];
|
|
241
|
+
const rule = (source, read) => compiled.push({
|
|
242
|
+
pattern: new RegExp(`${BEFORE}${source}${AFTER}`, "g"),
|
|
243
|
+
read
|
|
244
|
+
});
|
|
245
|
+
const suffix = syntax.suffix ? `(?:${syntax.suffix})?` : "";
|
|
246
|
+
for (const { prefix, kind, number = String.raw`[1-9]\d*`, displayNumber, sameRepo: local, namespace } of syntax.threads) {
|
|
247
|
+
const thread = `${prefix.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}(?<id>${number})${suffix}`;
|
|
248
|
+
rule(thread, ({ id }, from, origin) => ({
|
|
249
|
+
...origin,
|
|
250
|
+
repo: namespace ? namespaceRef(origin, from.owner) : from,
|
|
251
|
+
kind,
|
|
252
|
+
...displayNumber ? { displayNumber: id } : { number: id }
|
|
253
|
+
}));
|
|
254
|
+
if (syntax.repo && !local) rule(`(?<slug>${syntax.repo})${thread}`, ({ slug, id }, _, origin) => ({
|
|
255
|
+
...origin,
|
|
256
|
+
repo: repoIn(slug, origin),
|
|
257
|
+
kind,
|
|
258
|
+
...displayNumber ? { displayNumber: id } : { number: id }
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
if (syntax.commits) {
|
|
262
|
+
rule(`(?<sha>${SHA})`, ({ sha }, from, origin) => isBareSha(sha) ? {
|
|
263
|
+
...origin,
|
|
264
|
+
repo: from,
|
|
265
|
+
sha
|
|
266
|
+
} : void 0);
|
|
267
|
+
if (syntax.repo) rule(`(?<slug>${syntax.repo})@(?<sha>${SHA})`, ({ slug, sha }, _, origin) => ({
|
|
268
|
+
...origin,
|
|
269
|
+
repo: repoIn(slug, origin),
|
|
270
|
+
sha
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
rules.set(syntax, compiled);
|
|
274
|
+
return compiled;
|
|
275
|
+
}
|
|
276
|
+
function parseReferences(web, text, from, origin) {
|
|
277
|
+
if (!web?.references || from.forge !== origin.forge || from.instance !== origin.instance) return [];
|
|
278
|
+
const urls = urlSpans(text);
|
|
279
|
+
const found = [];
|
|
280
|
+
for (const { pattern, read } of rulesFor(web.references)) for (const match of text.matchAll(pattern)) {
|
|
281
|
+
const ref = urls.some(([start, end]) => match.index >= start && match.index < end) ? void 0 : read(match.groups, from, origin);
|
|
282
|
+
if (ref) found.push({
|
|
283
|
+
start: match.index,
|
|
284
|
+
end: match.index + match[0].length,
|
|
285
|
+
ref
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
found.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
289
|
+
let end = 0;
|
|
290
|
+
return found.filter((match) => {
|
|
291
|
+
if (match.start < end) return false;
|
|
292
|
+
end = match.end;
|
|
293
|
+
return true;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/** Reads GitHub's file route, `blob/{at}/{path}`. */
|
|
297
|
+
function parseGitHubFile([route, at, ...path]) {
|
|
298
|
+
return route === "blob" && at && path.length ? {
|
|
299
|
+
at,
|
|
300
|
+
path: path.join("/")
|
|
301
|
+
} : void 0;
|
|
302
|
+
}
|
|
303
|
+
/** Web links for forges laid out like GitHub: `/{owner}/{name}/issues/{n}` and friends. */
|
|
304
|
+
function githubShapedWeb(baseUrl, shape) {
|
|
305
|
+
const repoPath = (repo) => `/${encodePath(repo.owner)}/${encodeURIComponent(repo.name)}`;
|
|
306
|
+
const kindPath = {
|
|
307
|
+
issue: "issues",
|
|
308
|
+
pull_request: shape.pull,
|
|
309
|
+
...shape.discussions ? { discussion: "discussions" } : {}
|
|
310
|
+
};
|
|
311
|
+
const commitPath = shape.commit ?? "commit";
|
|
312
|
+
const kindOf = new Map(Object.entries(kindPath).map(([kind, path]) => [path, kind]));
|
|
313
|
+
const reserved = new Set(shape.reserved?.map((segment) => segment.toLowerCase()));
|
|
314
|
+
const parseFile = shape.parseFile ?? parseGitHubFile;
|
|
315
|
+
return {
|
|
316
|
+
baseUrl,
|
|
317
|
+
repo: repoPath,
|
|
318
|
+
section: (repo, section) => {
|
|
319
|
+
if (repo.kind === "namespace") return;
|
|
320
|
+
const path = shape.sections?.[section];
|
|
321
|
+
if (path === null) return;
|
|
322
|
+
return `${repoPath(repo)}/${path ?? (section === "pullRequests" ? "pulls" : section)}`;
|
|
323
|
+
},
|
|
324
|
+
thread: (ref) => kindPath[ref.kind] && ref.number ? `${repoPath(ref.repo)}/${kindPath[ref.kind]}/${encodeURIComponent(ref.number)}` : void 0,
|
|
325
|
+
comment: (ref) => kindPath[ref.thread.kind] && `${repoPath(ref.thread.repo)}/${kindPath[ref.thread.kind]}/${encodeURIComponent(ref.thread.number)}#${shape.commentFragment}${ref.id}`,
|
|
326
|
+
commit: (repo, sha) => `${repoPath(repo)}/${commitPath}/${encodeURIComponent(sha)}`,
|
|
327
|
+
release: (ref) => ref.tag ? `${repoPath(ref.repo)}/releases/tag/${encodeURIComponent(ref.tag)}` : void 0,
|
|
328
|
+
file: (repo, path, at, line) => `${repoPath(repo)}${shape.file(at)}/${encodePath(path)}${line ? `#${shape.lineFragment(line)}` : ""}`,
|
|
329
|
+
raw: (repo, path, at) => shape.raw === false ? void 0 : shape.rawOrigin ? `${shape.rawOrigin}${repoPath(repo)}/${encodeURIComponent(at)}/${encodePath(path)}` : `${repoPath(repo)}/raw/${encodeURIComponent(at)}/${encodePath(path)}`,
|
|
330
|
+
compare: (repo, base, head) => `${repoPath(repo)}/compare/${encodeURIComponent(base)}...${encodeURIComponent(head)}`,
|
|
331
|
+
parse: (segments, url, from) => {
|
|
332
|
+
const [owner, name, section, id] = segments;
|
|
333
|
+
if (!owner || !name || reserved.has(owner.toLowerCase())) return;
|
|
334
|
+
const repo = {
|
|
335
|
+
...from,
|
|
336
|
+
owner,
|
|
337
|
+
name: name.replace(/\.git$/, "")
|
|
338
|
+
};
|
|
339
|
+
const file = parseFile(segments.slice(2));
|
|
340
|
+
if (file) return {
|
|
341
|
+
repo,
|
|
342
|
+
file: {
|
|
343
|
+
...file,
|
|
344
|
+
...lineOf(url.hash.replace(/^#L/, ""))
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const kind = section ? kindOf.get(section) : void 0;
|
|
348
|
+
if (section === "releases" && id === "tag" && segments[4]) return {
|
|
349
|
+
repo,
|
|
350
|
+
release: {
|
|
351
|
+
...from,
|
|
352
|
+
repo,
|
|
353
|
+
id: segments[4],
|
|
354
|
+
tag: segments[4]
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
if (section === commitPath && id) return {
|
|
358
|
+
repo,
|
|
359
|
+
commit: {
|
|
360
|
+
...from,
|
|
361
|
+
repo,
|
|
362
|
+
sha: id
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
if (section === "compare" && id) return {
|
|
366
|
+
repo,
|
|
367
|
+
...rangeOf(segments.slice(3).join("/"))
|
|
368
|
+
};
|
|
369
|
+
if (!kind || !id) return { repo };
|
|
370
|
+
const thread = {
|
|
371
|
+
...from,
|
|
372
|
+
repo,
|
|
373
|
+
kind,
|
|
374
|
+
number: id
|
|
375
|
+
};
|
|
376
|
+
if (kind === "pull_request" && segments[4] === "commits" && segments[5]) return {
|
|
377
|
+
repo,
|
|
378
|
+
thread,
|
|
379
|
+
commit: {
|
|
380
|
+
...from,
|
|
381
|
+
repo,
|
|
382
|
+
sha: segments[5]
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
const comment = url.hash.startsWith(`#${shape.commentFragment}`) ? url.hash.slice(shape.commentFragment.length + 1) : void 0;
|
|
386
|
+
return {
|
|
387
|
+
repo,
|
|
388
|
+
thread,
|
|
389
|
+
...comment ? { comment: {
|
|
390
|
+
...from,
|
|
391
|
+
thread,
|
|
392
|
+
id: comment
|
|
393
|
+
} } : {}
|
|
394
|
+
};
|
|
395
|
+
},
|
|
396
|
+
reference: (ref, same) => {
|
|
397
|
+
if ("sha" in ref) return same ? ref.sha.slice(0, 7) : `${ref.repo.owner}/${ref.repo.name}@${ref.sha.slice(0, 7)}`;
|
|
398
|
+
if (!ref.number) return;
|
|
399
|
+
const prefix = ref.kind === "pull_request" && shape.pullPrefix ? shape.pullPrefix : "#";
|
|
400
|
+
return `${same ? "" : `${ref.repo.owner}/${ref.repo.name}`}${prefix}${ref.number}`;
|
|
401
|
+
},
|
|
402
|
+
references: shape.references ?? {
|
|
403
|
+
threads: [{
|
|
404
|
+
prefix: "#",
|
|
405
|
+
kind: "issue"
|
|
406
|
+
}, ...shape.pullPrefix ? [{
|
|
407
|
+
prefix: shape.pullPrefix,
|
|
408
|
+
kind: "pull_request"
|
|
409
|
+
}] : []],
|
|
410
|
+
repo: OWNER_NAME,
|
|
411
|
+
commits: true
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
/** The API base URL and the instance that `options` select. */
|
|
416
|
+
function resolveInstance(definition, options) {
|
|
417
|
+
const root = (options.baseUrl ?? definition.baseUrl).replace(/\/$/, "");
|
|
418
|
+
const baseUrl = definition.apiPath && !root.endsWith(definition.apiPath) ? `${root}${definition.apiPath}` : root;
|
|
419
|
+
let host;
|
|
420
|
+
try {
|
|
421
|
+
host = new URL(baseUrl).host;
|
|
422
|
+
} catch (cause) {
|
|
423
|
+
throw new TypeError(`Invalid baseUrl for ${definition.forge}: ${JSON.stringify(baseUrl)}`, { cause });
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
baseUrl,
|
|
427
|
+
instance: options.instance ?? definition.instance?.(host) ?? host
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/define-BRQZP-ft.mjs
|
|
126
432
|
/** Decodes base64, tolerating the newlines GitHub and Gitea wrap it in. */
|
|
127
433
|
function fromBase64(value) {
|
|
128
434
|
const binary = atob(value.replaceAll(/\s/g, ""));
|
|
@@ -496,6 +802,10 @@ const CAPABILITY_TABLE = [
|
|
|
496
802
|
capability: "threads.replyToReviewComment",
|
|
497
803
|
write: true
|
|
498
804
|
},
|
|
805
|
+
{
|
|
806
|
+
capability: "threads.reviewThreads",
|
|
807
|
+
listing: true
|
|
808
|
+
},
|
|
499
809
|
{
|
|
500
810
|
capability: "threads.resolveReviewThread",
|
|
501
811
|
write: true,
|
|
@@ -1275,6 +1585,7 @@ function createProvider(definition, givenOptions, givenState) {
|
|
|
1275
1585
|
const installationsSupported = () => Boolean(declaredInstallations?.run && !isUnsupported(resolve(declaredInstallations.support, env)));
|
|
1276
1586
|
const listThreads = kindGate("threads.list", spec.threads.listPage.kinds, spec.threads.listPage.run);
|
|
1277
1587
|
const listOwnerRepos = gate("repos.byOwner", spec.repos.byOwnerPage?.support, spec.repos.byOwnerPage?.run);
|
|
1588
|
+
const listReviewThreads = gate("threads.reviewThreads", spec.threads.reviewThreadsPage?.support, spec.threads.reviewThreadsPage?.run);
|
|
1278
1589
|
const listComments = kindGate("threads.comments", spec.threads.commentsPage.kinds, spec.threads.commentsPage.run);
|
|
1279
1590
|
const listEvents = kindGate("threads.events", Object.fromEntries(KINDS.map((kind) => [kind, (kindEnv) => threadEventKinds(spec, kindEnv)[kind]])), spec.threads.eventsPage.run);
|
|
1280
1591
|
const native = spec.search?.queryRaw;
|
|
@@ -1364,6 +1675,16 @@ function createProvider(definition, givenOptions, givenState) {
|
|
|
1364
1675
|
};
|
|
1365
1676
|
}, listOptions.cursor);
|
|
1366
1677
|
},
|
|
1678
|
+
"threads.reviewThreadsPage": (ref, { state, ...listOptions } = {}) => nonEmptyPage(async (cursor) => {
|
|
1679
|
+
const page = await listReviewThreads(ref, {
|
|
1680
|
+
...listOptions,
|
|
1681
|
+
cursor
|
|
1682
|
+
});
|
|
1683
|
+
return !state || state === "all" ? page : {
|
|
1684
|
+
...page,
|
|
1685
|
+
items: page.items.filter((thread) => thread.resolved === (state === "resolved"))
|
|
1686
|
+
};
|
|
1687
|
+
}, listOptions.cursor),
|
|
1367
1688
|
"threads.getComment": kindGate("threads.getComment", Object.fromEntries(KINDS.map((kind) => [kind, (kindEnv) => getCommentKinds(spec, kindEnv)[kind]])), (ref, options) => !isUnsupported(resolve(spec.threads.getComment?.kinds[ref.thread.kind], env)) ? spec.threads.getComment.run(ref, options) : listed(call("threads.comments")(ref.thread, options), ref.id, "Comment")),
|
|
1368
1689
|
"threads.getReview": gate("threads.getReview", (reviewEnv) => getReviewSupport(spec, reviewEnv), (ref, options) => !isUnsupported(resolve(spec.threads.getReview?.support, env)) ? spec.threads.getReview.run(ref, options) : listed(call("threads.reviews")(ref.thread, options), ref.id, "Review")),
|
|
1369
1690
|
"ci.getJob": gate("ci.getJob", (jobEnv) => ciJobSupport(spec, jobEnv), (ref, options) => {
|
|
@@ -1496,7 +1817,7 @@ function defineForgeProvider(definition) {
|
|
|
1496
1817
|
return ((options = {}) => createProvider(definition, options));
|
|
1497
1818
|
}
|
|
1498
1819
|
//#endregion
|
|
1499
|
-
//#region ../../node_modules/.pnpm/forges@
|
|
1820
|
+
//#region ../../node_modules/.pnpm/forges@0.3.1/node_modules/forges/dist/webhooks-Bc6QhmI8.mjs
|
|
1500
1821
|
/** The first of `names` the delivery carries a non-empty value for. */
|
|
1501
1822
|
function firstHeader(delivery, names) {
|
|
1502
1823
|
for (const name of typeof names === "string" ? [names] : names) {
|
|
@@ -1566,4 +1887,4 @@ function eventKindsOf(map, nativeEvents) {
|
|
|
1566
1887
|
return [...kinds];
|
|
1567
1888
|
}
|
|
1568
1889
|
//#endregion
|
|
1569
|
-
export { verb as C,
|
|
1890
|
+
export { headerValue as A, verb as C, rangeOf as D, lineOf as E, webUrlFor as O, toFileContent as S, githubShapedWeb as T, reviewState as _, verifyHmacSignature as a, supportOnly as b, changeBase64 as c, eventTime as d, existingFiles as f, perKind as g, isSha as h, refEvent as i, signRs256Jwt as j, bodyText as k, defineForgeProvider as l, inDirectories as m, firstHeader as n, verifySharedToken as o, fromBase64 as p, nativeEventsFor as r, WRITE_VERBS as s, eventKindsOf as t, eventAction as u, snapshotOfThread as v, OWNER_NAME as w, threadSnapshot as x, splitMessage as y };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/forge",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "One Forge
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "One Forge identity for ViteHub apps: GitHub App installation tokens and GitHub, GitLab and Forgejo providers from one set of env names.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"forge",
|
|
7
7
|
"forgejo",
|
|
@@ -33,27 +33,38 @@
|
|
|
33
33
|
"import": "./dist/index.js",
|
|
34
34
|
"default": "./dist/index.js"
|
|
35
35
|
},
|
|
36
|
+
"./build": {
|
|
37
|
+
"types": "./dist/build.d.ts",
|
|
38
|
+
"import": "./dist/build.js",
|
|
39
|
+
"default": "./dist/build.js"
|
|
40
|
+
},
|
|
41
|
+
"./build/node": {
|
|
42
|
+
"types": "./dist/build/node.d.ts",
|
|
43
|
+
"import": "./dist/build/node.js",
|
|
44
|
+
"default": "./dist/build/node.js"
|
|
45
|
+
},
|
|
36
46
|
"./package.json": "./package.json"
|
|
37
47
|
},
|
|
38
48
|
"dependencies": {
|
|
39
|
-
"
|
|
49
|
+
"@vite-hub/runtime": "0.3.1",
|
|
50
|
+
"nostics": "1.4.0"
|
|
40
51
|
},
|
|
41
52
|
"devDependencies": {
|
|
42
53
|
"@types/node": "^24.19.1",
|
|
43
|
-
"
|
|
54
|
+
"@vite-hub/internal": "0.0.1",
|
|
55
|
+
"forges": "0.3.1",
|
|
44
56
|
"publint": "^0.3.25",
|
|
45
57
|
"typescript": "^6.0.3",
|
|
46
58
|
"vite-plus": "^0.3.3",
|
|
47
|
-
"vitest": "^4.1.11"
|
|
48
|
-
"@vite-hub/internal": "0.0.1"
|
|
59
|
+
"vitest": "^4.1.11"
|
|
49
60
|
},
|
|
50
61
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
62
|
+
"node": ">=22.18.0"
|
|
52
63
|
},
|
|
53
64
|
"scripts": {
|
|
54
65
|
"build": "vp pack",
|
|
55
66
|
"dev": "vp pack --watch",
|
|
56
67
|
"typecheck": "vp run --cache -t @vite-hub/forge#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
|
|
57
|
-
"test": "vp run -t @vite-hub/forge#build && vp test"
|
|
68
|
+
"test": "vp run --cache -t @vite-hub/forge#build && vp test"
|
|
58
69
|
}
|
|
59
70
|
}
|