import * as API from "@distilled.cloud/core/api"; // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/rest-api-description). Do not edit. import * as S from "@distilled.cloud/core/schema-lite"; import * as __L from "@distilled.cloud/core/schema-lite"; import { GithubServiceErrors } from "../errors.ts"; import { GithubProtocol, type GithubOpError, type GithubOpContext } from "../protocol.ts"; import * as Retry from "../retry.ts"; import * as T from "../traits.ts"; // Schema table, filled on first reach (see __S at the end). const __s: any[] = []; export type { GithubOpError, GithubOpContext }; /** Span facts shared by every operation (com.distilled.telemetry#service). */ const TELEMETRY = { system: "github-api", responseHeaders: [ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" }, { header: "request-id", name: "http.response.header.request-id", transform: "list" }, { header: "x-github-request-id", name: "http.response.header.x-github-request-id", transform: "list", }, ], prefix: "GitHub", service: "CodeQuality", labels: "github", propagate: "w3c", } as const; export interface GetFindingRequest { /** The account owner of the repository. The name is not case sensitive. */ owner: string; /** The name of the repository without the `.git` extension. The name is not case sensitive. */ repo: string; /** The number that identifies a finding. */ finding_number: number; } /** State of the code quality finding. */ export type CodeQualityFindingState = "open" | "dismissed"; /** The severity of the rule used to detect the finding. */ export type CodeQualityFindingRuleSeverity = "error" | "warning" | "note" | "none"; /** The category of the rule used to detect the finding. */ export type CodeQualityFindingRuleCategory = "none" | "maintainability" | "reliability"; /** Code quality rule */ export interface CodeQualityFindingRule { /** A unique identifier for the rule used to detect the finding. */ id: string; /** The name of the rule used to detect the finding. */ title: string; /** A short description of the rule used to detect the finding. */ description: string; /** A detailed description of the rule used to detect the finding. */ help?: string | undefined; /** The severity of the rule used to detect the finding. */ severity: CodeQualityFindingRuleSeverity; /** The category of the rule used to detect the finding. */ category: CodeQualityFindingRuleCategory; } /** Code quality file location */ export interface CodeQualityFindingLocation { /** The file path where the finding was detected. */ path: string; /** The line number where the finding starts. */ start_line?: number | undefined; /** The column number where the finding starts. */ start_column?: number | undefined; /** The line number where the finding ends. */ end_line?: number | undefined; /** The column number where the finding ends. */ end_column?: number | undefined; } /** Code quality finding message */ export interface CodeQualityFindingMessage { /** The message text of the code quality finding. */ text: string; /** The message text of the code quality finding in markdown format. */ markdown: string; } /** Code quality finding */ export interface CodeQualityFinding { /** The finding number. */ number: number; /** State of the code quality finding. */ state: CodeQualityFindingState; /** The REST API URL of the code quality finding resource. */ url: string; rule: CodeQualityFindingRule; location: CodeQualityFindingLocation; message: CodeQualityFindingMessage; /** The time the code quality finding was created. */ created_at?: string | undefined; } export interface GetSetupRequest { /** The account owner of the repository. The name is not case sensitive. */ owner: string; /** The name of the repository without the `.git` extension. The name is not case sensitive. */ repo: string; } /** Code quality setup has been configured or not. */ export type CodeQualitySetupState = "configured" | "not-configured"; export type CodeQualitySetupLanguagesItem = | "csharp" | "go" | "java-kotlin" | "javascript-typescript" | "python" | "ruby" | "rust"; /** Languages to be analyzed. */ export type CodeQualitySetupLanguagesList = Array; /** Runner type to be used. */ export type CodeQualitySetupRunnerType = "standard" | "labeled"; /** The frequency of the periodic analysis. */ export type CodeQualitySetupSchedule = "weekly"; /** The AI findings configuration for the repository. */ export type CodeQualitySetupAiFindingsOption = "disabled" | "on_push"; /** Configuration for code quality setup. */ export interface CodeQualitySetup { /** Code quality setup has been configured or not. */ state?: CodeQualitySetupState | undefined; /** Languages to be analyzed. */ languages?: CodeQualitySetupLanguagesList | undefined; /** Runner type to be used. */ runner_type?: CodeQualitySetupRunnerType | null | undefined; /** Runner label to be used if the runner type is labeled. */ runner_label?: string | null | undefined; /** Timestamp of latest configuration update. */ updated_at?: string | null | undefined; /** The frequency of the periodic analysis. */ schedule?: CodeQualitySetupSchedule | null | undefined; /** The AI findings configuration for the repository. */ ai_findings_option?: CodeQualitySetupAiFindingsOption | null | undefined; } export type ListFindingsForRepoRequestDirection = "asc" | "desc"; export type ListFindingsForRepoRequestState = "open" | "dismissed"; export interface ListFindingsForRepoRequest { /** The account owner of the repository. The name is not case sensitive. */ owner: string; /** The name of the repository without the `.git` extension. The name is not case sensitive. */ repo: string; /** The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)." */ per_page?: number | undefined; /** The direction to sort the results by. */ direction?: ListFindingsForRepoRequestDirection | (string & {}) | undefined; /** A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)." */ before?: string | undefined; /** A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)." */ after?: string | undefined; /** If specified, only code quality findings with this state will be returned. */ state?: ListFindingsForRepoRequestState | (string & {}) | undefined; } export type ListFindingsForRepoResponseBodyList = Array; export type ListFindingsForRepoResponse = ListFindingsForRepoResponseBodyList; /** The desired state of code quality setup. */ export type UpdateSetupRequestState = "configured" | "not-configured"; /** Runner type to be used. */ export type UpdateSetupRequestRunnerType = "standard" | "labeled"; export type UpdateSetupRequestLanguagesItem = | "csharp" | "go" | "java-kotlin" | "javascript-typescript" | "python" | "ruby"; /** Languages to be analyzed. */ export type UpdateSetupRequestLanguagesList = Array< UpdateSetupRequestLanguagesItem | (string & {}) >; /** Whether AI findings run for Code Quality on this repository. */ export type UpdateSetupRequestAiFindingsOption = "disabled" | "on_push"; export interface UpdateSetupRequest { /** The account owner of the repository. The name is not case sensitive. */ owner: string; /** The name of the repository without the `.git` extension. The name is not case sensitive. */ repo: string; /** The desired state of code quality setup. */ state?: UpdateSetupRequestState | (string & {}) | undefined; /** Runner type to be used. */ runner_type?: UpdateSetupRequestRunnerType | (string & {}) | undefined; /** Runner label to be used if the runner type is labeled. */ runner_label?: string | null | undefined; /** Languages to be analyzed. */ languages?: UpdateSetupRequestLanguagesList | undefined; /** Whether AI findings run for Code Quality on this repository. */ ai_findings_option?: UpdateSetupRequestAiFindingsOption | (string & {}) | undefined; } export type UpdateSetupResponse = unknown; export type GetFindingError = GithubOpError; /** Get a code quality finding Gets a single code quality finding. OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. */ export const getFinding: API.OperationMethod< GetFindingRequest, CodeQualityFinding, GetFindingError, GithubOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(0, __c0, 0) as any as S.Schema, output: __S(7, __c1, 3) as any as S.Schema, errors: [], serviceErrors: GithubServiceErrors, protocol: GithubProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "GetFinding", })); export type GetSetupError = GithubOpError; /** Get a code quality setup configuration Gets a code quality setup configuration. OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. */ export const getSetup: API.OperationMethod< GetSetupRequest, CodeQualitySetup, GetSetupError, GithubOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(8, __c2, 0) as any as S.Schema, output: __S(9, __c2, 1) as any as S.Schema, errors: [], serviceErrors: GithubServiceErrors, protocol: GithubProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "GetSetup", })); export type ListFindingsForRepoError = GithubOpError; /** List code quality findings for a repository Lists code quality findings for a repository. OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. */ export const listFindingsForRepo: API.OperationMethod< ListFindingsForRepoRequest, ListFindingsForRepoResponse, ListFindingsForRepoError, GithubOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(16, __c4, 0) as any as S.Schema, output: __S(18, __c4, 2) as any as S.Schema, errors: [], serviceErrors: GithubServiceErrors, protocol: GithubProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "ListFindingsForRepo", })); export type UpdateSetupError = GithubOpError; /** Update a code quality setup configuration Updates a code quality setup configuration. OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with private or public repositories, or the `public_repo` scope to use this endpoint with only public repositories. */ export const updateSetup: API.OperationMethod< UpdateSetupRequest, UpdateSetupResponse, UpdateSetupError, GithubOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(20, __c5, 0) as any as S.Schema, output: __S(21, __c5, 1) as any as S.Schema, errors: [], serviceErrors: GithubServiceErrors, protocol: GithubProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "UpdateSetup", })); // Schema builders: each runs one schema initializer, on that schema's first use. function __c0(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ owner: S.String.pipe(T.Label()), repo: S.String.pipe(T.Label()), finding_number: S.Number.pipe(T.Label()), }).pipe( T.Http({ method: "GET", uri: "/repos/{owner}/{repo}/code-quality/findings/{finding_number}", code: 200, }), ), ).annotate({ identifier: "GetFindingRequest" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.String, title: S.String, description: S.String, help: S.optional(S.String), severity: S.String, category: S.String, }), ).annotate({ identifier: "CodeQualityFindingRule" }); case 1: return S.suspend(() => S.Struct({ path: S.String, start_line: S.optional(S.Number), start_column: S.optional(S.Number), end_line: S.optional(S.Number), end_column: S.optional(S.Number), }), ).annotate({ identifier: "CodeQualityFindingLocation" }); case 2: return S.suspend(() => S.Struct({ text: S.String, markdown: S.String, }), ).annotate({ identifier: "CodeQualityFindingMessage" }); case 3: return S.suspend(() => S.Struct({ number: S.Number, state: S.String, url: S.String, rule: __S(4, __c1, 0), location: __S(5, __c1, 1), message: __S(6, __c1, 2), created_at: S.optional(S.String), }), ).annotate({ identifier: "CodeQualityFinding" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ owner: S.String.pipe(T.Label()), repo: S.String.pipe(T.Label()), }).pipe( T.Http({ method: "GET", uri: "/repos/{owner}/{repo}/code-quality/setup", code: 200 }), ), ).annotate({ identifier: "GetSetupRequest" }); case 1: return S.suspend(() => S.Struct({ state: S.optional(S.String), languages: S.optional(__S(12, __c3, 0)), runner_type: S.optional(S.NullOr(S.String)), runner_label: S.optional(S.NullOr(S.String)), updated_at: S.optional(S.NullOr(S.String)), schedule: S.optional(S.NullOr(S.String)), ai_findings_option: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "CodeQualitySetup" }); } } function __c3(j: number): any { switch (j) { case 0: return S.Array(S.String); } } function __c4(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ owner: S.String.pipe(T.Label()), repo: S.String.pipe(T.Label()), per_page: S.optional(S.Number.pipe(T.Query())), direction: S.optional(S.String.pipe(T.Query())), before: S.optional(S.String.pipe(T.Query())), after: S.optional(S.String.pipe(T.Query())), state: S.optional(S.String.pipe(T.Query())), }).pipe( T.Http({ method: "GET", uri: "/repos/{owner}/{repo}/code-quality/findings", code: 200 }), ), ).annotate({ identifier: "ListFindingsForRepoRequest" }); case 1: return S.Array(__S(7, __c1, 3)); case 2: return S.suspend(() => __S(17, __c4, 1).pipe(T.RawResponseRoot())).annotate({ identifier: "ListFindingsForRepoResponse", }); } } function __c5(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ owner: S.String.pipe(T.Label()), repo: S.String.pipe(T.Label()), state: S.optional(S.String), runner_type: S.optional(S.String), runner_label: S.optional(S.NullOr(S.String)), languages: S.optional(__S(12, __c3, 0)), ai_findings_option: S.optional(S.String), }).pipe( T.Http({ method: "PATCH", uri: "/repos/{owner}/{repo}/code-quality/setup", code: 200 }), ), ).annotate({ identifier: "UpdateSetupRequest" }); case 1: return S.suspend(() => S.Unknown.pipe(T.RawResponseRoot())).annotate({ identifier: "UpdateSetupResponse", }); } } // Schema table: entry i is schema j of builder f, made on first reach. function __S(i: number, f: (j: number) => unknown, j: number): any { return (__s[i] ??= __L.at(f, j)); }