@vite-hub/workspace 0.0.4 → 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.
- package/README.md +225 -58
- package/dist/{ai-CjxvGqM0.d.ts → ai-BW2ZhizI.d.ts} +22 -7
- package/dist/{ai-BqCC8BpY.js → ai-BZyLwULx.js} +147 -66
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{asset-registry-8QI3ML3K.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +19 -0
- package/dist/blob-database.d.ts +521 -0
- package/dist/blob-database.js +601 -0
- package/dist/cloudflare.d.ts +5 -6
- package/dist/cloudflare.js +1 -1
- package/dist/config-B7dmzDX3.js +1112 -0
- package/dist/{config-DE9xlaIw.d.ts → config-DLKdaFWN.d.ts} +1 -2
- package/dist/error-diagnostics-A_8Kp-48.js +116 -0
- package/dist/error-diagnostics-DY5GP47p.js +96 -0
- package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +354 -0
- package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +214 -0
- package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +527 -0
- package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +248 -0
- package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +179 -0
- package/dist/file-C0_aPWSS.js +26 -0
- package/dist/file-metadata-CxDy-E2H.js +58 -0
- package/dist/{files-Q6xZjDHA.js → files-C7Px8uaC.js} +3 -3
- package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +2278 -0
- package/dist/{github-DHnjxQIX.js → github-CPxHtFB7.js} +16 -23
- package/dist/github-DtncTfmv-Du2S8lGF.js +4159 -0
- package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +2530 -0
- package/dist/glob--XcLlcml.js +22 -0
- package/dist/glob--kNYDbfU.js +30 -0
- package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +489 -0
- package/dist/{host-DJH8cuoU.js → host-CFnrTXTK.js} +97 -41
- package/dist/{hosted-RPeJOCFz.js → hosted-acMA5XyL.js} +102 -19
- package/dist/hosted-vercel-blob-DKntsHaf.js +12603 -0
- package/dist/hosted-vercel-blob.d.ts +5 -6
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +6 -7
- package/dist/hosted.js +1 -1
- package/dist/index.d.ts +57 -36
- package/dist/index.js +56 -56
- package/dist/inspect-BoObD2cJ.js +167 -0
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-BwZ7c9hb.js +596 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-BREFCmtn.js +39 -0
- package/dist/memory-BbwOqDXl.js +248 -0
- package/dist/metadata-target-DZEZQGHA.js +1588 -0
- package/dist/mountx.d.ts +4 -6
- package/dist/mountx.js +10 -8
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.d.ts +13 -12
- package/dist/nuxt.js +4 -8
- package/dist/operations-BcpWr41m.js +159 -0
- package/dist/operations-CGqY1XeG.js +965 -0
- package/dist/operations-DnOwKsJT.d.ts +136 -0
- package/dist/operations.d.ts +53 -0
- package/dist/operations.js +2 -0
- package/dist/path-CNAwN7pw.js +114 -0
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-DqQ8b4T5.d.ts +10 -0
- package/dist/provider-kXjfli9u.js +1457 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/{registry-D3yzt8HQ.js → registry-Bp-8UUfG.js} +9 -7
- package/dist/{registry-Uj6IVxes.d.ts → registry-Cg1TJVVZ.d.ts} +1 -2
- package/dist/{request-execution-B-dSFlGB.js → request-execution-Dk9rY-Yh.js} +19 -19
- package/dist/{chunk-2rV9d50f.js → rolldown-runtime-B4iAMlE-.js} +2 -2
- package/dist/runtime/assets.d.ts +3 -5
- package/dist/runtime/assets.js +7 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -2
- package/dist/runtime/empty-registry.d.ts +1 -2
- package/dist/runtime/state.d.ts +3 -3
- package/dist/runtime/state.js +6 -6
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +51 -17
- package/dist/runtime.js +320 -60
- package/dist/{search-BpiCF2Tw.js → search-CrTmXj5h.js} +10 -9
- package/dist/server-BNQ-Nbjj.js +290 -0
- package/dist/server.d.ts +22 -34
- package/dist/server.js +2 -328
- package/dist/shared-DalXdP0i.js +2158 -0
- package/dist/source-metadata.d.ts +6 -7
- package/dist/source-metadata.js +7 -7
- package/dist/{state-tYcRWEh2.d.ts → state-B8zbLi5t.d.ts} +3 -3
- package/dist/store-CXgmu-uw.js +1729 -0
- package/dist/{sync-DnTQwt8r.js → sync-CN6ec-5M.js} +61 -41
- package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +125 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{token-CVzURBxC.js → token-CO62GglH.js} +3 -3
- package/dist/{types-CYuwjJ4V.d.ts → types-DeK9GIxy.d.ts} +256 -24
- package/dist/{use-BTNDR5Rd.js → use-BQj7nSz6.js} +82 -41
- package/dist/{use-BiHzt0xA.d.ts → use-DhwhbAVV.d.ts} +16 -11
- package/dist/utils-Blrh4N2n.js +545 -0
- package/dist/vite-BEvgU2GY.js +20909 -0
- package/dist/vite-CcZmMQ7S.d.ts +476 -0
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +2 -2
- package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +1565 -0
- package/dist/{workspace-Dq08Yn72.js → workspace-6pxkOuxr.js} +361 -230
- package/dist/{workspace-Xddf4G1B.d.ts → workspace-BWJQBK1u.d.ts} +4 -3
- package/package.json +89 -55
- package/dist/collections/client.d.ts +0 -39
- package/dist/collections/client.js +0 -137
- package/dist/collections.d.ts +0 -59
- package/dist/collections.js +0 -159
- package/dist/config-Bc3c4Su1.js +0 -7904
- package/dist/config-CHLLWklZ.js +0 -36
- package/dist/file-Bc1X7pco.js +0 -23
- package/dist/glob-CEZKeZFC.js +0 -18
- package/dist/hosted-vercel-blob-d6C8ND5j.js +0 -23580
- package/dist/lifecycle-LrL3sA4n.js +0 -316
- package/dist/metadata-target-B0tOmVW7.js +0 -717
- package/dist/path-Cp59koVz.js +0 -139
- package/dist/provider-B1yLjCJJ.js +0 -746
- package/dist/publish.d.ts +0 -35
- package/dist/publish.js +0 -112
- package/dist/runtime-options-BsPSv5O7.js +0 -13
- package/dist/runtime-type-iEE6BjQJ.js +0 -34
- package/dist/shared-DTR1Hhma.js +0 -331
- package/dist/store-Dt_Jyys3.js +0 -608
- package/dist/vite-BptCrpv2.js +0 -4526
- package/dist/vite-CtA9guIM.d.ts +0 -66
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
|
|
2
|
+
import { d as withWorkspaceRuntimeOptions, u as ownSourceOption } from "./config-B7dmzDX3.js";
|
|
3
|
+
import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
|
|
4
|
+
import { glob } from "@vite-hub/source/glob";
|
|
5
|
+
//#region src/sources/glob.ts
|
|
6
|
+
var glob_exports = /* @__PURE__ */ __exportAll({ glob: () => glob$1 });
|
|
7
|
+
function glob$1(options) {
|
|
8
|
+
const source = glob({
|
|
9
|
+
...options,
|
|
10
|
+
keyCache: options.keyCache ?? !isLazySource(options)
|
|
11
|
+
});
|
|
12
|
+
return withWorkspaceRuntimeOptions(source, options);
|
|
13
|
+
}
|
|
14
|
+
function isLazySource(options) {
|
|
15
|
+
const materialize = ownSourceOption(options, "materialize");
|
|
16
|
+
if (materialize === "lazy" || materialize === "startup") return true;
|
|
17
|
+
const mount = ownSourceOption(options, "mount");
|
|
18
|
+
const mountMaterialize = hasRuntimeType(mount, "object") ? ownSourceOption(mount, "materialize") : void 0;
|
|
19
|
+
return mountMaterialize === "lazy" || mountMaterialize === "startup";
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { glob_exports as n, glob$1 as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
+
import { l as normalizeWorkspacePath } from "./path-CNAwN7pw.js";
|
|
3
|
+
import { Minimatch } from "minimatch";
|
|
4
|
+
//#region src/core/glob.ts
|
|
5
|
+
function createWorkspaceGlobMatcher(pattern, options = {}) {
|
|
6
|
+
const requestedCwd = options.cwd === "." ? "" : options.cwd;
|
|
7
|
+
let cwd;
|
|
8
|
+
try {
|
|
9
|
+
cwd = normalizeSafeWorkspacePath(requestedCwd, { allowEmpty: true });
|
|
10
|
+
} catch (error) {
|
|
11
|
+
const reservedCwd = normalizeSafeWorkspacePath(requestedCwd, {
|
|
12
|
+
allowEmpty: true,
|
|
13
|
+
allowReserved: true
|
|
14
|
+
});
|
|
15
|
+
if (reservedCwd !== ".vitehub/sources") throw error;
|
|
16
|
+
cwd = reservedCwd;
|
|
17
|
+
}
|
|
18
|
+
const prefix = cwd ? `${cwd}/` : "";
|
|
19
|
+
const matchers = pattern ? (Array.isArray(pattern) ? pattern : [pattern]).map((value) => new Minimatch(normalizeWorkspacePath(value), { dot: true })) : void 0;
|
|
20
|
+
return {
|
|
21
|
+
cwd,
|
|
22
|
+
matches(path) {
|
|
23
|
+
if (!path.startsWith(prefix)) return false;
|
|
24
|
+
const relative = normalizeWorkspacePath(path.slice(prefix.length));
|
|
25
|
+
return !matchers || matchers.some((matcher) => matcher.match(relative));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createWorkspaceGlobMatcher as t };
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { Bt as toPullStats, It as toDate } from "./shared-DalXdP0i.js";
|
|
2
|
+
import { s as eventTime } from "./webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js";
|
|
3
|
+
import { t as toAuthorAssociation } from "./association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js";
|
|
4
|
+
//#region ../forge/dist/graphql-DG5aJBT3-DceyFYdM.js
|
|
5
|
+
const FORGE = "github";
|
|
6
|
+
const ACTOR_FIELDS = `__typename login avatarUrl url ... on User { databaseId name } ... on Bot { databaseId }`;
|
|
7
|
+
const USER_FIELDS = `__typename login avatarUrl url databaseId name`;
|
|
8
|
+
const DISCUSSION_FIELDS = `id number title body closed stateReason url createdAt updatedAt closedAt locked
|
|
9
|
+
author { ${ACTOR_FIELDS} } authorAssociation
|
|
10
|
+
labels(first: 50) { nodes { name color description } }
|
|
11
|
+
comments { totalCount }`;
|
|
12
|
+
const DISCUSSION_THREAD = `query DiscussionThread($owner: String!, $name: String!, $number: Int!) {
|
|
13
|
+
repository(owner: $owner, name: $name) {
|
|
14
|
+
discussion(number: $number) {
|
|
15
|
+
${DISCUSSION_FIELDS}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}`;
|
|
19
|
+
const DISCUSSIONS_LIST = `query DiscussionsList($owner: String!, $name: String!, $first: Int!, $after: String, $field: DiscussionOrderField!, $direction: OrderDirection!) {
|
|
20
|
+
repository(owner: $owner, name: $name) {
|
|
21
|
+
discussions(first: $first, after: $after, orderBy: { field: $field, direction: $direction }) {
|
|
22
|
+
pageInfo { hasNextPage endCursor }
|
|
23
|
+
nodes {
|
|
24
|
+
${DISCUSSION_FIELDS}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}`;
|
|
29
|
+
const UPDATE_DISCUSSION = `mutation UpdateDiscussion($id: ID!, $title: String, $body: String) {
|
|
30
|
+
updateDiscussion(input: { discussionId: $id, title: $title, body: $body }) { discussion { ${DISCUSSION_FIELDS} } }
|
|
31
|
+
}`;
|
|
32
|
+
const COMMENT_FIELDS = `id databaseId body createdAt updatedAt url author { ${ACTOR_FIELDS} } authorAssociation`;
|
|
33
|
+
const UPDATE_DISCUSSION_COMMENT = `mutation UpdateDiscussionComment($id: ID!, $body: String!) {
|
|
34
|
+
updateDiscussionComment(input: { commentId: $id, body: $body }) { comment { ${COMMENT_FIELDS} } }
|
|
35
|
+
}`;
|
|
36
|
+
const DELETE_DISCUSSION_COMMENT = `mutation DeleteDiscussionComment($id: ID!) {
|
|
37
|
+
deleteDiscussionComment(input: { id: $id }) { comment { id } }
|
|
38
|
+
}`;
|
|
39
|
+
const GET_DISCUSSION_COMMENT = `query GetDiscussionComment($id: ID!) {
|
|
40
|
+
node(id: $id) { ...on DiscussionComment { ${COMMENT_FIELDS} } }
|
|
41
|
+
}`;
|
|
42
|
+
const SUBSCRIPTION_STATE = `query SubscriptionState($owner: String!, $name: String!, $number: Int!, $discussion: Boolean!) {
|
|
43
|
+
repository(owner: $owner, name: $name) {
|
|
44
|
+
issueOrPullRequest(number: $number) @skip(if: $discussion) {
|
|
45
|
+
... on Issue { id viewerSubscription }
|
|
46
|
+
... on PullRequest { id viewerSubscription }
|
|
47
|
+
}
|
|
48
|
+
discussion(number: $number) @include(if: $discussion) { id viewerSubscription }
|
|
49
|
+
}
|
|
50
|
+
}`;
|
|
51
|
+
const UPDATE_SUBSCRIPTION = `mutation UpdateSubscription($id: ID!, $state: SubscriptionState!) {
|
|
52
|
+
updateSubscription(input: { subscribableId: $id, state: $state }) { subscribable { viewerSubscription } }
|
|
53
|
+
}`;
|
|
54
|
+
const GIT_ACTOR_FIELDS = `name email date user { ${USER_FIELDS} }`;
|
|
55
|
+
const CREATE_COMMIT_ON_BRANCH = `mutation CreateCommitOnBranch($input: CreateCommitOnBranchInput!) {
|
|
56
|
+
createCommitOnBranch(input: $input) {
|
|
57
|
+
commit { oid message url author { ${GIT_ACTOR_FIELDS} } committer { ${GIT_ACTOR_FIELDS} } parents(first: 2) { nodes { oid } } }
|
|
58
|
+
}
|
|
59
|
+
}`;
|
|
60
|
+
function toCommitSignature(instance, raw) {
|
|
61
|
+
return {
|
|
62
|
+
actor: toGraphQLActor(instance, raw?.user),
|
|
63
|
+
name: raw?.name ?? void 0,
|
|
64
|
+
email: raw?.email ?? void 0,
|
|
65
|
+
date: toDate(raw?.date)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function toGraphQLCommit(repo, raw) {
|
|
69
|
+
return {
|
|
70
|
+
ref: {
|
|
71
|
+
forge: FORGE,
|
|
72
|
+
instance: repo.instance,
|
|
73
|
+
repo,
|
|
74
|
+
sha: raw.oid
|
|
75
|
+
},
|
|
76
|
+
sha: raw.oid,
|
|
77
|
+
message: raw.message,
|
|
78
|
+
author: toCommitSignature(repo.instance, raw.author),
|
|
79
|
+
committer: toCommitSignature(repo.instance, raw.committer),
|
|
80
|
+
parents: raw.parents.nodes.map((parent) => parent.oid),
|
|
81
|
+
url: raw.url,
|
|
82
|
+
raw
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const SPONSORABLE = `query Sponsorable($login: String!) {
|
|
86
|
+
repositoryOwner(login: $login) {
|
|
87
|
+
... on Sponsorable { hasSponsorsListing }
|
|
88
|
+
}
|
|
89
|
+
}`;
|
|
90
|
+
const ISSUE_FIELDS = `id number title body state stateReason createdAt updatedAt closedAt url locked
|
|
91
|
+
author { ${ACTOR_FIELDS} } authorAssociation
|
|
92
|
+
assignees(first: 20) { nodes { ${USER_FIELDS} } }
|
|
93
|
+
labels(first: 50) { nodes { name color description } }
|
|
94
|
+
comments { totalCount }
|
|
95
|
+
participants(first: 20) { nodes { ${USER_FIELDS} } }
|
|
96
|
+
milestone { number title state description dueOn url }
|
|
97
|
+
issueType { id name description color isEnabled }
|
|
98
|
+
viewerSubscription`;
|
|
99
|
+
const PULL_FIELDS = `id number title body state isDraft createdAt updatedAt closedAt mergedAt url locked
|
|
100
|
+
author { ${ACTOR_FIELDS} } authorAssociation
|
|
101
|
+
mergedBy { ${ACTOR_FIELDS} }
|
|
102
|
+
assignees(first: 20) { nodes { ${USER_FIELDS} } }
|
|
103
|
+
labels(first: 50) { nodes { name color description } }
|
|
104
|
+
comments { totalCount }
|
|
105
|
+
participants(first: 20) { nodes { ${USER_FIELDS} } }
|
|
106
|
+
milestone { number title state description dueOn url }
|
|
107
|
+
viewerSubscription
|
|
108
|
+
headRefName headRefOid baseRefName baseRefOid
|
|
109
|
+
headRepository { databaseId name owner { login } }
|
|
110
|
+
mergeCommit { oid }
|
|
111
|
+
additions deletions changedFiles
|
|
112
|
+
commits(last: 1) { totalCount nodes { commit { statusCheckRollup { state contexts { totalCount checkRunCountsByState { state count } statusContextCountsByState { state count } } } } } }
|
|
113
|
+
reviewRequests(first: 20) { nodes { requestedReviewer { __typename ... on User { login databaseId avatarUrl url } ... on Bot { login databaseId avatarUrl url } ... on Team { slug databaseId name url } } } }
|
|
114
|
+
timelineItems(itemTypes: [REVIEW_REQUESTED_EVENT], last: 20) { nodes { ... on ReviewRequestedEvent { createdAt requestedReviewer { __typename ... on User { login } ... on Bot { login } ... on Team { slug } } } } }`;
|
|
115
|
+
const REFERENCE_PAGE = "first: $first, after: $after) { pageInfo { hasNextPage endCursor }";
|
|
116
|
+
const REFERENCE_REPOSITORY = "repository { databaseId name owner { login } }";
|
|
117
|
+
const CLOSING_ISSUES = `query ClosingIssues($owner: String!, $name: String!, $number: Int!, $first: Int!, $after: String) {
|
|
118
|
+
repository(owner: $owner, name: $name) {
|
|
119
|
+
thread: pullRequest(number: $number) {
|
|
120
|
+
references: closingIssuesReferences(${REFERENCE_PAGE} nodes { __typename ${REFERENCE_REPOSITORY} ${ISSUE_FIELDS} } }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}`;
|
|
124
|
+
const CLOSING_PULL_REQUESTS = `query ClosingPullRequests($owner: String!, $name: String!, $number: Int!, $first: Int!, $after: String) {
|
|
125
|
+
repository(owner: $owner, name: $name) {
|
|
126
|
+
thread: issue(number: $number) {
|
|
127
|
+
references: closedByPullRequestsReferences(includeClosedPrs: true, ${REFERENCE_PAGE} nodes { __typename ${REFERENCE_REPOSITORY} ${PULL_FIELDS} } }
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}`;
|
|
131
|
+
/** One aliased query reading many issues, pull requests and discussions. */
|
|
132
|
+
function threadsBatchQuery(refs) {
|
|
133
|
+
const variables = {};
|
|
134
|
+
const declarations = [];
|
|
135
|
+
const fields = refs.map((ref, index) => {
|
|
136
|
+
variables[`o${index}`] = ref.repo.owner;
|
|
137
|
+
variables[`n${index}`] = ref.repo.name;
|
|
138
|
+
variables[`k${index}`] = Number(ref.number);
|
|
139
|
+
declarations.push(`$o${index}: String!`, `$n${index}: String!`, `$k${index}: Int!`);
|
|
140
|
+
return `t${index}: repository(owner: $o${index}, name: $n${index}) { ${ref.kind === "discussion" ? `discussion(number: $k${index}) { ${DISCUSSION_FIELDS} }` : `issueOrPullRequest(number: $k${index}) { __typename ... on Issue { ${ISSUE_FIELDS} } ... on PullRequest { ${PULL_FIELDS} } }`} }`;
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
query: `query ThreadsBatch(${declarations.join(", ")}) {\n ${fields.join("\n ")}\n}`,
|
|
144
|
+
variables
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** A GraphQL milestone as the model holds it. */
|
|
148
|
+
function toGraphQLMilestone(raw) {
|
|
149
|
+
return raw ? {
|
|
150
|
+
id: String(raw.number),
|
|
151
|
+
title: raw.title,
|
|
152
|
+
state: raw.state === "CLOSED" ? "closed" : "open",
|
|
153
|
+
description: raw.description ?? void 0,
|
|
154
|
+
dueOn: toDate(raw.dueOn),
|
|
155
|
+
url: raw.url,
|
|
156
|
+
raw
|
|
157
|
+
} : void 0;
|
|
158
|
+
}
|
|
159
|
+
function toGraphQLIssueType(raw) {
|
|
160
|
+
return raw ? {
|
|
161
|
+
id: raw.id,
|
|
162
|
+
name: raw.name,
|
|
163
|
+
description: raw.description || void 0,
|
|
164
|
+
colour: raw.color?.toLowerCase(),
|
|
165
|
+
enabled: raw.isEnabled,
|
|
166
|
+
raw
|
|
167
|
+
} : void 0;
|
|
168
|
+
}
|
|
169
|
+
function toViewerSubscription(value) {
|
|
170
|
+
return value === "SUBSCRIBED" ? "subscribed" : value === "IGNORED" ? "ignored" : value === "UNSUBSCRIBED" ? "none" : void 0;
|
|
171
|
+
}
|
|
172
|
+
const FAILED_RUNS = /* @__PURE__ */ new Set([
|
|
173
|
+
"FAILURE",
|
|
174
|
+
"TIMED_OUT",
|
|
175
|
+
"CANCELLED",
|
|
176
|
+
"ACTION_REQUIRED",
|
|
177
|
+
"STARTUP_FAILURE"
|
|
178
|
+
]);
|
|
179
|
+
const FAILED_STATUSES = /* @__PURE__ */ new Set(["FAILURE", "ERROR"]);
|
|
180
|
+
function toRollupSummary(rollup, url) {
|
|
181
|
+
const failed = (rollup.contexts.checkRunCountsByState ?? []).filter(({ state }) => FAILED_RUNS.has(state)).reduce((sum, { count }) => sum + count, 0) + (rollup.contexts.statusContextCountsByState ?? []).filter(({ state }) => FAILED_STATUSES.has(state)).reduce((sum, { count }) => sum + count, 0);
|
|
182
|
+
return {
|
|
183
|
+
state: rollup.state === "SUCCESS" ? "success" : rollup.state === "FAILURE" || rollup.state === "ERROR" ? "failure" : rollup.state === "PENDING" || rollup.state === "EXPECTED" ? "pending" : "unknown",
|
|
184
|
+
stateRaw: rollup.state.toLowerCase(),
|
|
185
|
+
total: rollup.contexts.totalCount,
|
|
186
|
+
failed,
|
|
187
|
+
...url ? { url: `${url}/checks` } : {}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function toGraphQLThread(ref, raw) {
|
|
191
|
+
const instance = ref.instance;
|
|
192
|
+
const isPull = raw.__typename === "PullRequest";
|
|
193
|
+
const kind = isPull ? "pull_request" : "issue";
|
|
194
|
+
const state = raw.state === "MERGED" ? "merged" : raw.state === "OPEN" ? "open" : raw.state === "CLOSED" ? "closed" : "unknown";
|
|
195
|
+
const requestedAt = /* @__PURE__ */ new Map();
|
|
196
|
+
for (const { createdAt, requestedReviewer } of raw.timelineItems?.nodes ?? []) {
|
|
197
|
+
const name = requestedReviewer?.slug ?? requestedReviewer?.login;
|
|
198
|
+
if (createdAt && name) requestedAt.set(`${requestedReviewer.__typename}:${name}`, createdAt);
|
|
199
|
+
}
|
|
200
|
+
const reviewers = (raw.reviewRequests?.nodes ?? []).flatMap(({ requestedReviewer: reviewer }) => {
|
|
201
|
+
if (!reviewer) return [];
|
|
202
|
+
const isTeam = reviewer.__typename === "Team";
|
|
203
|
+
const actor = isTeam ? {
|
|
204
|
+
forge: FORGE,
|
|
205
|
+
instance,
|
|
206
|
+
login: reviewer.slug ?? "",
|
|
207
|
+
id: String(reviewer.databaseId ?? reviewer.slug),
|
|
208
|
+
name: reviewer.name,
|
|
209
|
+
url: reviewer.url,
|
|
210
|
+
typeRaw: "Team",
|
|
211
|
+
isBotHint: false
|
|
212
|
+
} : toGraphQLActor(instance, reviewer);
|
|
213
|
+
const at = requestedAt.get(`${reviewer.__typename}:${isTeam ? reviewer.slug : reviewer.login}`);
|
|
214
|
+
return [{
|
|
215
|
+
actor,
|
|
216
|
+
state: "pending",
|
|
217
|
+
stateRaw: "requested",
|
|
218
|
+
...isTeam ? { isTeam: true } : {},
|
|
219
|
+
...at ? { requestedAt: new Date(at) } : {}
|
|
220
|
+
}];
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
ref: {
|
|
224
|
+
...ref,
|
|
225
|
+
kind,
|
|
226
|
+
externalId: raw.id
|
|
227
|
+
},
|
|
228
|
+
kind,
|
|
229
|
+
title: raw.title,
|
|
230
|
+
body: raw.body,
|
|
231
|
+
state,
|
|
232
|
+
stateRaw: raw.state.toLowerCase(),
|
|
233
|
+
stateReason: raw.stateReason?.toLowerCase() ?? void 0,
|
|
234
|
+
isDraft: raw.isDraft ?? false,
|
|
235
|
+
author: toGraphQLActor(instance, raw.author),
|
|
236
|
+
...toAuthorAssociation(raw.authorAssociation),
|
|
237
|
+
assignees: (raw.assignees?.nodes ?? []).flatMap((actor) => toGraphQLActor(instance, actor) ?? []),
|
|
238
|
+
participants: (raw.participants?.nodes ?? []).flatMap((actor) => toGraphQLActor(instance, actor) ?? []),
|
|
239
|
+
milestone: toGraphQLMilestone(raw.milestone),
|
|
240
|
+
issueType: toGraphQLIssueType(raw.issueType),
|
|
241
|
+
subscription: toViewerSubscription(raw.viewerSubscription),
|
|
242
|
+
reviewers,
|
|
243
|
+
labels: (raw.labels?.nodes ?? []).map((label) => ({
|
|
244
|
+
name: label.name,
|
|
245
|
+
colour: label.color,
|
|
246
|
+
description: label.description ?? void 0
|
|
247
|
+
})),
|
|
248
|
+
url: raw.url,
|
|
249
|
+
createdAt: toDate(raw.createdAt),
|
|
250
|
+
updatedAt: toDate(raw.updatedAt),
|
|
251
|
+
closedAt: toDate(raw.closedAt),
|
|
252
|
+
mergedAt: toDate(raw.mergedAt),
|
|
253
|
+
mergedBy: toGraphQLActor(instance, raw.mergedBy),
|
|
254
|
+
lastActivityAt: toDate(raw.updatedAt),
|
|
255
|
+
locked: raw.locked,
|
|
256
|
+
commentCount: raw.comments?.totalCount,
|
|
257
|
+
...isPull && raw.commits?.nodes[0]?.commit.statusCheckRollup ? { checks: toRollupSummary(raw.commits.nodes[0].commit.statusCheckRollup, raw.url) } : {},
|
|
258
|
+
branches: isPull && raw.headRefName && raw.baseRefName ? {
|
|
259
|
+
head: {
|
|
260
|
+
ref: raw.headRefName,
|
|
261
|
+
sha: raw.headRefOid,
|
|
262
|
+
repo: raw.headRepository ? {
|
|
263
|
+
forge: FORGE,
|
|
264
|
+
instance,
|
|
265
|
+
owner: raw.headRepository.owner.login,
|
|
266
|
+
name: raw.headRepository.name,
|
|
267
|
+
externalId: raw.headRepository.databaseId === void 0 ? void 0 : String(raw.headRepository.databaseId)
|
|
268
|
+
} : void 0
|
|
269
|
+
},
|
|
270
|
+
base: {
|
|
271
|
+
ref: raw.baseRefName,
|
|
272
|
+
sha: raw.baseRefOid
|
|
273
|
+
},
|
|
274
|
+
mergeCommitSha: raw.mergeCommit?.oid
|
|
275
|
+
} : void 0,
|
|
276
|
+
stats: toPullStats({
|
|
277
|
+
additions: raw.additions,
|
|
278
|
+
deletions: raw.deletions,
|
|
279
|
+
changedFileCount: raw.changedFiles,
|
|
280
|
+
commitCount: raw.commits?.totalCount
|
|
281
|
+
}),
|
|
282
|
+
raw
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/** Lists recent discussions in several repositories at once, for resolving notification subjects. */
|
|
286
|
+
function recentDiscussionsQuery(repos) {
|
|
287
|
+
const variables = {};
|
|
288
|
+
const declarations = [];
|
|
289
|
+
const fields = repos.map((repo, index) => {
|
|
290
|
+
variables[`o${index}`] = repo.owner;
|
|
291
|
+
variables[`n${index}`] = repo.name;
|
|
292
|
+
declarations.push(`$o${index}: String!`, `$n${index}: String!`);
|
|
293
|
+
return `r${index}: repository(owner: $o${index}, name: $n${index}) { discussions(first: 50, orderBy: { field: UPDATED_AT, direction: DESC }) { nodes { id number title updatedAt } } }`;
|
|
294
|
+
});
|
|
295
|
+
return {
|
|
296
|
+
query: `query RecentDiscussions(${declarations.join(", ")}) {\n ${fields.join("\n ")}\n}`,
|
|
297
|
+
variables
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
const DISCUSSION_COMMENTS = `query DiscussionComments($owner: String!, $name: String!, $number: Int!, $after: String) {
|
|
301
|
+
repository(owner: $owner, name: $name) {
|
|
302
|
+
discussion(number: $number) {
|
|
303
|
+
comments(first: 50, after: $after) {
|
|
304
|
+
pageInfo { hasNextPage endCursor }
|
|
305
|
+
nodes {
|
|
306
|
+
id databaseId body createdAt url
|
|
307
|
+
author { ${ACTOR_FIELDS} } authorAssociation
|
|
308
|
+
replies(first: 50) { nodes { id databaseId body createdAt url author { ${ACTOR_FIELDS} } authorAssociation } }
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}`;
|
|
314
|
+
const ADD_DISCUSSION_COMMENT = `mutation AddDiscussionComment($id: ID!, $body: String!) {
|
|
315
|
+
addDiscussionComment(input: { discussionId: $id, body: $body }) { comment { ${COMMENT_FIELDS} } }
|
|
316
|
+
}`;
|
|
317
|
+
const CLOSE_DISCUSSION = `mutation CloseDiscussion($id: ID!, $reason: DiscussionCloseReason) {
|
|
318
|
+
closeDiscussion(input: { discussionId: $id, reason: $reason }) { discussion { ${DISCUSSION_FIELDS} } }
|
|
319
|
+
}`;
|
|
320
|
+
const REOPEN_DISCUSSION = `mutation ReopenDiscussion($id: ID!) {
|
|
321
|
+
reopenDiscussion(input: { discussionId: $id }) { discussion { ${DISCUSSION_FIELDS} } }
|
|
322
|
+
}`;
|
|
323
|
+
function toGraphQLActor(instance, actor) {
|
|
324
|
+
if (!actor) return;
|
|
325
|
+
const isBot = actor.__typename === "Bot";
|
|
326
|
+
const slug = isBot ? actor.login.replace(/\[bot\]$/, "") : void 0;
|
|
327
|
+
return {
|
|
328
|
+
forge: FORGE,
|
|
329
|
+
instance,
|
|
330
|
+
login: slug ? `${slug}[bot]` : actor.login,
|
|
331
|
+
id: String(actor.databaseId ?? actor.login),
|
|
332
|
+
name: actor.name,
|
|
333
|
+
avatarUrl: actor.avatarUrl,
|
|
334
|
+
url: actor.url,
|
|
335
|
+
typeRaw: actor.__typename,
|
|
336
|
+
isBotHint: isBot || actor.login.endsWith("[bot]"),
|
|
337
|
+
...slug ? { app: { slug } } : {}
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function toDiscussionThread(ref, raw) {
|
|
341
|
+
return {
|
|
342
|
+
ref: {
|
|
343
|
+
...ref,
|
|
344
|
+
externalId: raw.id
|
|
345
|
+
},
|
|
346
|
+
kind: "discussion",
|
|
347
|
+
title: raw.title,
|
|
348
|
+
body: raw.body,
|
|
349
|
+
state: raw.closed ? "closed" : "open",
|
|
350
|
+
stateRaw: raw.closed ? "closed" : "open",
|
|
351
|
+
stateReason: raw.stateReason?.toLowerCase(),
|
|
352
|
+
isDraft: false,
|
|
353
|
+
author: toGraphQLActor(ref.instance, raw.author),
|
|
354
|
+
...toAuthorAssociation(raw.authorAssociation),
|
|
355
|
+
assignees: [],
|
|
356
|
+
reviewers: [],
|
|
357
|
+
lastActivityAt: toDate(raw.updatedAt),
|
|
358
|
+
url: raw.url,
|
|
359
|
+
createdAt: toDate(raw.createdAt),
|
|
360
|
+
updatedAt: toDate(raw.updatedAt),
|
|
361
|
+
closedAt: toDate(raw.closedAt),
|
|
362
|
+
labels: (raw.labels?.nodes ?? []).map((label) => ({
|
|
363
|
+
name: label.name,
|
|
364
|
+
colour: label.color,
|
|
365
|
+
description: label.description ?? void 0
|
|
366
|
+
})),
|
|
367
|
+
locked: raw.locked,
|
|
368
|
+
commentCount: raw.comments?.totalCount,
|
|
369
|
+
raw
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
function toDiscussionCommentEvent(ref, comment, isReply) {
|
|
373
|
+
const actor = toGraphQLActor(ref.instance, comment.author);
|
|
374
|
+
return {
|
|
375
|
+
forge: FORGE,
|
|
376
|
+
instance: ref.instance,
|
|
377
|
+
id: comment.id,
|
|
378
|
+
kind: "comment",
|
|
379
|
+
kindRaw: isReply ? "DiscussionCommentReply" : "DiscussionComment",
|
|
380
|
+
summary: `${actor?.login ?? "someone"} ${isReply ? "replied" : "commented"}`,
|
|
381
|
+
...eventTime(toDate(comment.createdAt), /* @__PURE__ */ new Date(0)),
|
|
382
|
+
actor,
|
|
383
|
+
repo: ref.repo,
|
|
384
|
+
thread: ref,
|
|
385
|
+
detail: {
|
|
386
|
+
type: "comment",
|
|
387
|
+
comment: {
|
|
388
|
+
forge: FORGE,
|
|
389
|
+
instance: ref.instance,
|
|
390
|
+
thread: ref,
|
|
391
|
+
id: comment.id
|
|
392
|
+
},
|
|
393
|
+
body: comment.body ?? void 0
|
|
394
|
+
},
|
|
395
|
+
source: "poll",
|
|
396
|
+
payload: comment
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function toDiscussionComment(thread, raw) {
|
|
400
|
+
return {
|
|
401
|
+
ref: {
|
|
402
|
+
forge: FORGE,
|
|
403
|
+
instance: thread.instance,
|
|
404
|
+
thread,
|
|
405
|
+
id: raw.id
|
|
406
|
+
},
|
|
407
|
+
body: raw.body ?? "",
|
|
408
|
+
author: toGraphQLActor(thread.instance, raw.author),
|
|
409
|
+
...toAuthorAssociation(raw.authorAssociation),
|
|
410
|
+
createdAt: toDate(raw.createdAt),
|
|
411
|
+
updatedAt: toDate(raw.updatedAt),
|
|
412
|
+
url: raw.url,
|
|
413
|
+
raw
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const REPOSITORY_ID = `query RepositoryId($owner: String!, $name: String!) {
|
|
417
|
+
repository(owner: $owner, name: $name) { id }
|
|
418
|
+
}`;
|
|
419
|
+
const UPDATE_REFS = `mutation UpdateRefs($input: UpdateRefsInput!) {
|
|
420
|
+
updateRefs(input: $input) { clientMutationId }
|
|
421
|
+
}`;
|
|
422
|
+
const TRANSFER_ISSUE = `mutation TransferIssue($issue: ID!, $repo: ID!) {
|
|
423
|
+
transferIssue(input: { issueId: $issue, repositoryId: $repo }) { issue { id number } }
|
|
424
|
+
}`;
|
|
425
|
+
const MARK_DUPLICATE = `mutation MarkDuplicate($canonical: ID!, $duplicate: ID!) {
|
|
426
|
+
closeIssue(input: { issueId: $duplicate, stateReason: DUPLICATE, duplicateIssueId: $canonical }) { issue { __typename } }
|
|
427
|
+
}`;
|
|
428
|
+
const NODE_REACTIONS = `query NodeReactions($id: ID!, $after: String) {
|
|
429
|
+
node(id: $id) {
|
|
430
|
+
... on Reactable {
|
|
431
|
+
reactions(first: 100, after: $after) {
|
|
432
|
+
totalCount
|
|
433
|
+
pageInfo { hasNextPage endCursor }
|
|
434
|
+
nodes { content createdAt user { __typename login databaseId name avatarUrl url } }
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}`;
|
|
439
|
+
const ADD_REACTION = `mutation AddReaction($id: ID!, $content: ReactionContent!) {
|
|
440
|
+
addReaction(input: { subjectId: $id, content: $content }) { reaction { content } }
|
|
441
|
+
}`;
|
|
442
|
+
const REMOVE_REACTION = `mutation RemoveReaction($id: ID!, $content: ReactionContent!) {
|
|
443
|
+
removeReaction(input: { subjectId: $id, content: $content }) { reaction { content } }
|
|
444
|
+
}`;
|
|
445
|
+
/** The GraphQL `ReactionContent` enum, by the model's name for each reaction. */
|
|
446
|
+
const REACTION_CONTENT = {
|
|
447
|
+
"+1": "THUMBS_UP",
|
|
448
|
+
"-1": "THUMBS_DOWN",
|
|
449
|
+
"laugh": "LAUGH",
|
|
450
|
+
"confused": "CONFUSED",
|
|
451
|
+
"heart": "HEART",
|
|
452
|
+
"hooray": "HOORAY",
|
|
453
|
+
"rocket": "ROCKET",
|
|
454
|
+
"eyes": "EYES"
|
|
455
|
+
};
|
|
456
|
+
/** The model's name for each GraphQL `ReactionContent` value. */
|
|
457
|
+
const GRAPHQL_REACTIONS = Object.fromEntries(Object.entries(REACTION_CONTENT).map(([content, graphql]) => [graphql, content]));
|
|
458
|
+
const REVIEW_THREADS = `query ReviewThreads($owner: String!, $name: String!, $number: Int!) {
|
|
459
|
+
repository(owner: $owner, name: $name) {
|
|
460
|
+
pullRequest(number: $number) {
|
|
461
|
+
reviewThreads(first: 100) {
|
|
462
|
+
nodes { id isResolved comments(first: 100) { nodes { databaseId } } }
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}`;
|
|
467
|
+
const RESOLVE_REVIEW_THREAD = `mutation ResolveReviewThread($id: ID!) {
|
|
468
|
+
resolveReviewThread(input: { threadId: $id }) { thread { isResolved } }
|
|
469
|
+
}`;
|
|
470
|
+
const UNRESOLVE_REVIEW_THREAD = `mutation UnresolveReviewThread($id: ID!) {
|
|
471
|
+
unresolveReviewThread(input: { threadId: $id }) { thread { isResolved } }
|
|
472
|
+
}`;
|
|
473
|
+
const LOCK_LOCKABLE = `mutation LockLockable($id: ID!) {
|
|
474
|
+
lockLockable(input: { lockableId: $id }) { lockedRecord { locked } }
|
|
475
|
+
}`;
|
|
476
|
+
const UNLOCK_LOCKABLE = `mutation UnlockLockable($id: ID!) {
|
|
477
|
+
unlockLockable(input: { lockableId: $id }) { unlockedRecord { locked } }
|
|
478
|
+
}`;
|
|
479
|
+
const MINIMIZE_COMMENT = `mutation MinimizeComment($id: ID!, $classifier: ReportedContentClassifiers!) {
|
|
480
|
+
minimizeComment(input: { subjectId: $id, classifier: $classifier }) { minimizedComment { isMinimized } }
|
|
481
|
+
}`;
|
|
482
|
+
const UNMINIMIZE_COMMENT = `mutation UnminimizeComment($id: ID!) {
|
|
483
|
+
unminimizeComment(input: { subjectId: $id }) { unminimizedComment { isMinimized } }
|
|
484
|
+
}`;
|
|
485
|
+
const UPDATE_PULL_REQUEST_BRANCH = `mutation UpdatePullRequestBranch($id: ID!, $sha: GitObjectID, $method: PullRequestBranchUpdateMethod) {
|
|
486
|
+
updatePullRequestBranch(input: { pullRequestId: $id, expectedHeadOid: $sha, updateMethod: $method }) { pullRequest { headRefOid } }
|
|
487
|
+
}`;
|
|
488
|
+
//#endregion
|
|
489
|
+
export { ADD_DISCUSSION_COMMENT, ADD_REACTION, CLOSE_DISCUSSION, CLOSING_ISSUES, CLOSING_PULL_REQUESTS, CREATE_COMMIT_ON_BRANCH, DELETE_DISCUSSION_COMMENT, DISCUSSIONS_LIST, DISCUSSION_COMMENTS, DISCUSSION_THREAD, GET_DISCUSSION_COMMENT, GRAPHQL_REACTIONS, LOCK_LOCKABLE, MARK_DUPLICATE, MINIMIZE_COMMENT, NODE_REACTIONS, REACTION_CONTENT, REMOVE_REACTION, REOPEN_DISCUSSION, REPOSITORY_ID, RESOLVE_REVIEW_THREAD, REVIEW_THREADS, SPONSORABLE, SUBSCRIPTION_STATE, TRANSFER_ISSUE, UNLOCK_LOCKABLE, UNMINIMIZE_COMMENT, UNRESOLVE_REVIEW_THREAD, UPDATE_DISCUSSION, UPDATE_DISCUSSION_COMMENT, UPDATE_PULL_REQUEST_BRANCH, UPDATE_REFS, UPDATE_SUBSCRIPTION, recentDiscussionsQuery, threadsBatchQuery, toDiscussionComment, toDiscussionCommentEvent, toDiscussionThread, toGraphQLActor, toGraphQLCommit, toGraphQLMilestone, toGraphQLThread, toViewerSubscription };
|