Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions actions/setup/js/add_reaction_and_edit_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { generateWorkflowIdMarker } = require("./generate_footer.cjs");
const { sanitizeContent } = require("./sanitize_content.cjs");
const { ERR_API, ERR_NOT_FOUND, ERR_VALIDATION } = require("./error_codes.cjs");
const { buildWorkflowRunUrl, EVENT_TYPE_DESCRIPTIONS } = require("./workflow_metadata_helpers.cjs");
const { createDiscussionComment, resolveTopLevelDiscussionCommentId } = require("./github_api_helpers.cjs");
const { createDiscussionComment, isRestEndpoint, resolveTopLevelDiscussionCommentId } = require("./github_api_helpers.cjs");
const { resolveInvocationContext } = require("./invocation_context_helpers.cjs");
const { addReaction, addDiscussionReaction, getDiscussionNodeId, REACTION_MAP } = require("./add_reaction.cjs");

Expand All @@ -18,14 +18,6 @@ const VALID_REACTIONS = Object.freeze(Object.keys(REACTION_MAP));
* @typedef {{ route: string, params: Record<string, unknown> }} RestEndpoint
*/

/**
* @param {unknown} endpoint
* @returns {endpoint is RestEndpoint}
*/
function isRestEndpoint(endpoint) {
return typeof endpoint === "object" && endpoint !== null && "route" in endpoint && "params" in endpoint;
}

/**
* @param {unknown} endpoint
* @param {string} endpointName
Expand Down
10 changes: 1 addition & 9 deletions actions/setup/js/add_workflow_run_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,9 @@ const { ERR_NOT_FOUND, ERR_VALIDATION } = require("./error_codes.cjs");
const { getMessages } = require("./messages_core.cjs");
const { parseBoolTemplatable } = require("./templatable.cjs");
const { buildWorkflowRunUrl, EVENT_TYPE_DESCRIPTIONS } = require("./workflow_metadata_helpers.cjs");
const { resolveTopLevelDiscussionCommentId } = require("./github_api_helpers.cjs");
const { isRestEndpoint, resolveTopLevelDiscussionCommentId } = require("./github_api_helpers.cjs");
const { resolveInvocationContext } = require("./invocation_context_helpers.cjs");

/**
* @param {unknown} endpoint
* @returns {endpoint is { route: string, params: Record<string, unknown> }}
*/
function isRestEndpoint(endpoint) {
return typeof endpoint === "object" && endpoint !== null && "route" in endpoint && "params" in endpoint;
}

/**
* @typedef {{ owner: string, repo: string }} RepoRef
* @typedef {{ id: string, url: string, repo: RepoRef }} CommentMetadata
Expand Down
11 changes: 11 additions & 0 deletions actions/setup/js/github_api_helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ async function resolveTopLevelDiscussionCommentId(github, commentNodeId) {
}
}

/**
* Type guard for a resolved REST endpoint descriptor, shared by handlers that
* choose between a REST call ({route, params}) and a GraphQL/discussion path.
* @param {unknown} endpoint
* @returns {endpoint is { route: string, params: Record<string, unknown> }}
*/
function isRestEndpoint(endpoint) {
return typeof endpoint === "object" && endpoint !== null && "route" in endpoint && "params" in endpoint;
}

/**
* Create a discussion comment with optional threaded reply target.
* @param {Object} github - GitHub API client (must support graphql)
Expand Down Expand Up @@ -217,6 +227,7 @@ module.exports = {
createDiscussionComment,
fetchAllRepoLabels,
getFileContent,
isRestEndpoint,
logGraphQLError,
resolveTopLevelDiscussionCommentId,
};
Loading