@vite-hub/forge 0.0.0-stage → 0.1.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.
@@ -0,0 +1,113 @@
1
+ import { $ as toDate } from "./utils-CA_4WJhJ-DNgT61X2.js";
2
+ //#region ../../node_modules/.pnpm/forges@https+++pkg.pr.new+danielroe+forges@40d50b2f8bdc5585becfae405e1a3b8a325f7202/node_modules/forges/dist/gitee-DExkQP6X.mjs
3
+ const FORGE = "gitee";
4
+ function toActor(instance, user) {
5
+ if (!user) return;
6
+ return {
7
+ forge: FORGE,
8
+ instance,
9
+ login: user.login,
10
+ id: String(user.id),
11
+ name: user.name,
12
+ avatarUrl: user.avatar_url,
13
+ url: user.html_url,
14
+ typeRaw: user.type,
15
+ isBotHint: user.type === "Bot" || /\[bot\]$|-bot$/i.test(user.login)
16
+ };
17
+ }
18
+ function toRepoRef(instance, repo) {
19
+ const [owner = repo.namespace?.path ?? "", name = repo.path] = repo.full_name.split("/");
20
+ return {
21
+ forge: FORGE,
22
+ instance,
23
+ owner,
24
+ name,
25
+ externalId: String(repo.id)
26
+ };
27
+ }
28
+ /** Gitee issues are `open`, `progressing`, `closed` or `rejected`; progressing work is still open. */
29
+ function toLabel(raw) {
30
+ return {
31
+ name: raw.name,
32
+ colour: raw.color ?? void 0
33
+ };
34
+ }
35
+ function issueState(state) {
36
+ return state === "open" || state === "progressing" ? "open" : state === "closed" || state === "rejected" ? "closed" : "unknown";
37
+ }
38
+ function toIssueThread(ref, raw) {
39
+ const instance = ref.instance;
40
+ return {
41
+ ref: {
42
+ ...ref,
43
+ kind: "issue",
44
+ number: raw.number,
45
+ externalId: String(raw.id)
46
+ },
47
+ kind: "issue",
48
+ title: raw.title,
49
+ body: raw.body ?? void 0,
50
+ state: issueState(raw.state),
51
+ stateRaw: raw.state,
52
+ stateReason: raw.state === "rejected" ? "not_planned" : void 0,
53
+ isDraft: false,
54
+ author: toActor(instance, raw.user),
55
+ assignees: raw.assignee ? [toActor(instance, raw.assignee)] : [],
56
+ reviewers: [],
57
+ labels: (raw.labels ?? []).map(toLabel),
58
+ url: raw.html_url,
59
+ createdAt: toDate(raw.created_at),
60
+ updatedAt: toDate(raw.updated_at),
61
+ closedAt: toDate(raw.finished_at),
62
+ lastActivityAt: toDate(raw.updated_at),
63
+ commentCount: raw.comments,
64
+ raw
65
+ };
66
+ }
67
+ function toPullThread(ref, raw) {
68
+ const instance = ref.instance;
69
+ const state = raw.merged_at || raw.state === "merged" ? "merged" : raw.state === "open" ? "open" : raw.state === "closed" ? "closed" : "unknown";
70
+ return {
71
+ ref: {
72
+ ...ref,
73
+ kind: "pull_request",
74
+ number: String(raw.number),
75
+ externalId: String(raw.id)
76
+ },
77
+ kind: "pull_request",
78
+ title: raw.title,
79
+ body: raw.body ?? void 0,
80
+ state,
81
+ stateRaw: raw.state,
82
+ isDraft: raw.draft ?? false,
83
+ author: toActor(instance, raw.user),
84
+ assignees: [],
85
+ reviewers: (raw.assignees ?? []).map((reviewer) => ({
86
+ actor: toActor(instance, reviewer),
87
+ state: reviewer.accept ? "approved" : "pending",
88
+ stateRaw: reviewer.accept ? "accepted" : "requested"
89
+ })),
90
+ labels: (raw.labels ?? []).map(toLabel),
91
+ url: raw.html_url,
92
+ createdAt: toDate(raw.created_at),
93
+ updatedAt: toDate(raw.updated_at),
94
+ closedAt: toDate(raw.closed_at),
95
+ mergedAt: toDate(raw.merged_at),
96
+ lastActivityAt: toDate(raw.updated_at),
97
+ locked: raw.locked,
98
+ branches: raw.head && raw.base ? {
99
+ head: {
100
+ ref: raw.head.ref,
101
+ sha: raw.head.sha,
102
+ repo: raw.head.repo ? toRepoRef(instance, raw.head.repo) : void 0
103
+ },
104
+ base: {
105
+ ref: raw.base.ref,
106
+ sha: raw.base.sha
107
+ }
108
+ } : void 0,
109
+ raw
110
+ };
111
+ }
112
+ //#endregion
113
+ export { toRepoRef as a, toPullThread as i, toActor as n, toIssueThread as r, FORGE as t };