Skip to content

Commit

Permalink
Clean up type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshino committed Feb 2, 2025
1 parent cdff03b commit 9ca252f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/lib/services/backends/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,20 @@ const fetchFileList = async () => {
return blobs.filter(({ type }) => type === 'blob').map(({ path, sha }) => ({ path, sha }));
};

/**
* @typedef {object} GitLabUserInfo
* @property {string} [id] - GitLab user ID.
* @property {string} [username] - GitLab user username.
*/

/**
* @typedef {object} GitLabCommit
* @property {?GitLabUserInfo} author - Commit author’s GitLab user info.
* @property {string} authorName - Commit author’s full name.
* @property {string} authorEmail - Commit author’s email.
* @property {string} committedDate - Committed date.
*/

/**
* Fetch the metadata of entry/asset files as well as text file contents.
* @param {(BaseEntryListItem | BaseAssetListItem)[]} fetchingFiles - Base entry/asset list items.
Expand Down Expand Up @@ -491,12 +505,7 @@ const fetchFileContents = async (fetchingFiles) => {

dataLoadedProgress.set(undefined);

/**
* @type {{
* author: { id?: string, username?: string } | null,
* authorName: string, authorEmail: string, committedDate: string
* }[]}
*/
/** @type {GitLabCommit[]} */
const commits = [];

// Fetch commit info only when there aren’t many files, because it’s costly
Expand All @@ -507,10 +516,9 @@ const fetchFileContents = async (fetchingFiles) => {
for (;;) {
const result = //
/**
* @type {{ project: { repository: { [tree_index: string]: { lastCommit: {
* author: { id?: string, username?: string } | null,
* authorName: string, authorEmail: string, committedDate: string
* } } } } } }}
* @type {{ project: { repository: { [tree_index: string]: {
* lastCommit: GitLabCommit
* } } } } }}
*/ (
await fetchGraphQL(
`
Expand Down

0 comments on commit 9ca252f

Please sign in to comment.