// This file is auto-generated by @hey-api/openapi-ts

import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
import { client } from './client.gen';
import type { AcceptUpdateRequestData, AcceptUpdateRequestResponses, CreateOrgFolderData, CreateOrgFolderResponses, CreateSkillData, CreateSkillResponses, CreateUpdateRequestCommentData, CreateUpdateRequestCommentResponses, CreateUpdateRequestData, CreateUpdateRequestResponses, CreateVersionData, CreateVersionResponses, DeleteCollaboratorData, DeleteCollaboratorResponses, DeleteFileData, DeleteFileResponses, DeleteSkillData, DeleteSkillResponses, DownloadSkillData, DownloadSkillFileData, DownloadSkillFileResponses, DownloadSkillManifestData, DownloadSkillManifestResponses, DownloadSkillResponses, GetAuthorIdentityData, GetAuthorIdentityResponses, GetDraftData, GetDraftResponses, GetFileData, GetFileResponses, GetMergeStateData, GetMergeStateResponses, GetOrgFolderData, GetOrgFolderResponses, GetSkillData, GetSkillEditDocumentData, GetSkillEditDocumentErrors, GetSkillEditDocumentResponses, GetSkillResponses, GetUpdateRequestData, GetUpdateRequestDiffData, GetUpdateRequestDiffResponses, GetUpdateRequestResponses, GetVersionManifestData, GetVersionManifestResponses, GithubStatusData, GithubStatusResponses, ListCollaboratorsData, ListCollaboratorsResponses, ListFilesData, ListFilesResponses, ListOrphanFoldersData, ListOrphanFoldersErrors, ListOrphanFoldersResponses, ListSkillsData, ListSkillsResponses, ListUpdateRequestCommentsData, ListUpdateRequestCommentsResponses, ListUpdateRequestsData, ListUpdateRequestsResponses, ListUsageEventsData, ListUsageEventsResponses, ListVersionsData, ListVersionsResponses, PublisherRootData, PublisherRootResponses, PurchaseSkillData, PurchaseSkillErrors, PurchaseSkillResponses, PutFileData, PutFileResponses, ReconcileOrphansData, ReconcileOrphansErrors, ReconcileOrphansResponses, RejectUpdateRequestData, RejectUpdateRequestResponses, ReplaceOrgFolderData, ReplaceOrgFolderResponses, ResolveConflictData, ResolveConflictResponses, RetryGithubPublishData, RetryGithubPublishResponses, SkillMdData, SkillMdResponses, SyncFromMainData, SyncFromMainResponses, TransferOrgFolderData, TransferOrgFolderErrors, TransferOrgFolderResponses, UpdateOrgFolderData, UpdateOrgFolderResponses, UpdateSkillData, UpdateSkillResponses, UpdateSponsorData, UpdateSponsorResponses, UpsertAuthorIdentityData, UpsertAuthorIdentityResponses, UpsertCollaboratorData, UpsertCollaboratorResponses, UsageSummaryData, UsageSummaryResponses } from './types.gen';

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
    /**
     * You can provide a client instance returned by `createClient()` instead of
     * individual options. This might be also useful if you want to implement a
     * custom client.
     */
    client?: Client;
    /**
     * You can pass arbitrary values through the `meta` object. This can be
     * used to access values that aren't defined as part of the SDK function.
     */
    meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
};

export const publisherRoot = <ThrowOnError extends boolean = false>(options?: Options<PublisherRootData, ThrowOnError>): RequestResult<PublisherRootResponses, unknown, ThrowOnError> => (options?.client ?? client).get<PublisherRootResponses, unknown, ThrowOnError>({ url: '/', ...options });

/**
 * Operator inventory of canonical-repo paths the gateway has no
 * claim on.
 *
 * Authorization: any caller with `X-Seren-User-Role: admin` (platform
 * admin set by Seren Core's `ADMIN_USER_IDS`). The endpoint is
 * **read-only** and does not return per-org data — every orphan is by
 * definition a path the gateway has lost track of, so scoping it to one
 * organization would defeat the visibility purpose. Unauthorized callers
 * receive 403.
 *
 * On success returns:
 *
 * ```json
 * {
 * "head_commit_sha": "...",
 * "head_tree_sha": "...",
 * "orphan_folders": [
 * {
 * "folder_slug": "org-deadbeef",
 * "skill_folder_name": "grid-trader",
 * "paths": ["org-deadbeef/grid-trader/SKILL.md", "..."]
 * }
 * ]
 * }
 * ```
 *
 * Failure modes:
 *
 * - 403 if the caller lacks `X-Seren-User-Role=admin`.
 * - 400 if GitHub publishing is not configured for this deployment.
 * - 500 if GitHub returned a truncated tree listing (we cannot
 * trust a partial view for an inventory pass — same posture as
 * `derive_orphan_paths` in `github_status`).
 */
export const listOrphanFolders = <ThrowOnError extends boolean = false>(options?: Options<ListOrphanFoldersData, ThrowOnError>): RequestResult<ListOrphanFoldersResponses, ListOrphanFoldersErrors, ThrowOnError> => (options?.client ?? client).get<ListOrphanFoldersResponses, ListOrphanFoldersErrors, ThrowOnError>({ url: '/admin/skills/orphan-folders', ...options });

export const getAuthorIdentity = <ThrowOnError extends boolean = false>(options?: Options<GetAuthorIdentityData, ThrowOnError>): RequestResult<GetAuthorIdentityResponses, unknown, ThrowOnError> => (options?.client ?? client).get<GetAuthorIdentityResponses, unknown, ThrowOnError>({ url: '/git-identity', ...options });

export const upsertAuthorIdentity = <ThrowOnError extends boolean = false>(options: Options<UpsertAuthorIdentityData, ThrowOnError>): RequestResult<UpsertAuthorIdentityResponses, unknown, ThrowOnError> => (options.client ?? client).put<UpsertAuthorIdentityResponses, unknown, ThrowOnError>({
    url: '/git-identity',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const getOrgFolder = <ThrowOnError extends boolean = false>(options: Options<GetOrgFolderData, ThrowOnError>): RequestResult<GetOrgFolderResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetOrgFolderResponses, unknown, ThrowOnError>({ url: '/organizations/{org_id}/folder', ...options });

export const updateOrgFolder = <ThrowOnError extends boolean = false>(options: Options<UpdateOrgFolderData, ThrowOnError>): RequestResult<UpdateOrgFolderResponses, unknown, ThrowOnError> => (options.client ?? client).patch<UpdateOrgFolderResponses, unknown, ThrowOnError>({
    url: '/organizations/{org_id}/folder',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const createOrgFolder = <ThrowOnError extends boolean = false>(options: Options<CreateOrgFolderData, ThrowOnError>): RequestResult<CreateOrgFolderResponses, unknown, ThrowOnError> => (options.client ?? client).post<CreateOrgFolderResponses, unknown, ThrowOnError>({
    url: '/organizations/{org_id}/folder',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const replaceOrgFolder = <ThrowOnError extends boolean = false>(options: Options<ReplaceOrgFolderData, ThrowOnError>): RequestResult<ReplaceOrgFolderResponses, unknown, ThrowOnError> => (options.client ?? client).put<ReplaceOrgFolderResponses, unknown, ThrowOnError>({
    url: '/organizations/{org_id}/folder',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const transferOrgFolder = <ThrowOnError extends boolean = false>(options: Options<TransferOrgFolderData, ThrowOnError>): RequestResult<TransferOrgFolderResponses, TransferOrgFolderErrors, ThrowOnError> => (options.client ?? client).post<TransferOrgFolderResponses, TransferOrgFolderErrors, ThrowOnError>({
    url: '/organizations/{org_id}/folder/transfer',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const skillMd = <ThrowOnError extends boolean = false>(options?: Options<SkillMdData, ThrowOnError>): RequestResult<SkillMdResponses, unknown, ThrowOnError> => (options?.client ?? client).get<SkillMdResponses, unknown, ThrowOnError>({ url: '/skill.md', ...options });

export const listSkills = <ThrowOnError extends boolean = false>(options?: Options<ListSkillsData, ThrowOnError>): RequestResult<ListSkillsResponses, unknown, ThrowOnError> => (options?.client ?? client).get<ListSkillsResponses, unknown, ThrowOnError>({ url: '/skills', ...options });

export const createSkill = <ThrowOnError extends boolean = false>(options: Options<CreateSkillData, ThrowOnError>): RequestResult<CreateSkillResponses, unknown, ThrowOnError> => (options.client ?? client).post<CreateSkillResponses, unknown, ThrowOnError>({
    url: '/skills',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const deleteSkill = <ThrowOnError extends boolean = false>(options: Options<DeleteSkillData, ThrowOnError>): RequestResult<DeleteSkillResponses, unknown, ThrowOnError> => (options.client ?? client).delete<DeleteSkillResponses, unknown, ThrowOnError>({ url: '/skills/{slug}', ...options });

export const getSkill = <ThrowOnError extends boolean = false>(options: Options<GetSkillData, ThrowOnError>): RequestResult<GetSkillResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetSkillResponses, unknown, ThrowOnError>({ url: '/skills/{slug}', ...options });

export const updateSkill = <ThrowOnError extends boolean = false>(options: Options<UpdateSkillData, ThrowOnError>): RequestResult<UpdateSkillResponses, unknown, ThrowOnError> => (options.client ?? client).patch<UpdateSkillResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const listCollaborators = <ThrowOnError extends boolean = false>(options: Options<ListCollaboratorsData, ThrowOnError>): RequestResult<ListCollaboratorsResponses, unknown, ThrowOnError> => (options.client ?? client).get<ListCollaboratorsResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/collaborators', ...options });

export const deleteCollaborator = <ThrowOnError extends boolean = false>(options: Options<DeleteCollaboratorData, ThrowOnError>): RequestResult<DeleteCollaboratorResponses, unknown, ThrowOnError> => (options.client ?? client).delete<DeleteCollaboratorResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/collaborators/{user_id}', ...options });

export const upsertCollaborator = <ThrowOnError extends boolean = false>(options: Options<UpsertCollaboratorData, ThrowOnError>): RequestResult<UpsertCollaboratorResponses, unknown, ThrowOnError> => (options.client ?? client).put<UpsertCollaboratorResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}/collaborators/{user_id}',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const downloadSkill = <ThrowOnError extends boolean = false>(options: Options<DownloadSkillData, ThrowOnError>): RequestResult<DownloadSkillResponses, unknown, ThrowOnError> => (options.client ?? client).get<DownloadSkillResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/download', ...options });

export const downloadSkillFile = <ThrowOnError extends boolean = false>(options: Options<DownloadSkillFileData, ThrowOnError>): RequestResult<DownloadSkillFileResponses, unknown, ThrowOnError> => (options.client ?? client).get<DownloadSkillFileResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/download/file', ...options });

export const downloadSkillManifest = <ThrowOnError extends boolean = false>(options: Options<DownloadSkillManifestData, ThrowOnError>): RequestResult<DownloadSkillManifestResponses, unknown, ThrowOnError> => (options.client ?? client).get<DownloadSkillManifestResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/download/manifest', ...options });

export const getDraft = <ThrowOnError extends boolean = false>(options: Options<GetDraftData, ThrowOnError>): RequestResult<GetDraftResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetDraftResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/drafts/{draft_id}', ...options });

export const getMergeState = <ThrowOnError extends boolean = false>(options: Options<GetMergeStateData, ThrowOnError>): RequestResult<GetMergeStateResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetMergeStateResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/drafts/{draft_id}/merge-state', ...options });

export const resolveConflict = <ThrowOnError extends boolean = false>(options: Options<ResolveConflictData, ThrowOnError>): RequestResult<ResolveConflictResponses, unknown, ThrowOnError> => (options.client ?? client).post<ResolveConflictResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}/drafts/{draft_id}/resolve-conflict',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const getSkillEditDocument = <ThrowOnError extends boolean = false>(options: Options<GetSkillEditDocumentData, ThrowOnError>): RequestResult<GetSkillEditDocumentResponses, GetSkillEditDocumentErrors, ThrowOnError> => (options.client ?? client).get<GetSkillEditDocumentResponses, GetSkillEditDocumentErrors, ThrowOnError>({ url: '/skills/{slug}/edit', ...options });

/**
 * `GET /skills/{slug}/files` -- list every file in the current
 * version's bundle, plus a synthetic `SKILL.md` entry.
 */
export const listFiles = <ThrowOnError extends boolean = false>(options: Options<ListFilesData, ThrowOnError>): RequestResult<ListFilesResponses, unknown, ThrowOnError> => (options.client ?? client).get<ListFilesResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/files', ...options });

/**
 * `DELETE /skills/{slug}/files/{path...}` -- drop one file.
 */
export const deleteFile = <ThrowOnError extends boolean = false>(options: Options<DeleteFileData, ThrowOnError>): RequestResult<DeleteFileResponses, unknown, ThrowOnError> => (options.client ?? client).delete<DeleteFileResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}/files/{path}',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * `GET /skills/{slug}/files/{path...}` -- one file's bytes.
 */
export const getFile = <ThrowOnError extends boolean = false>(options: Options<GetFileData, ThrowOnError>): RequestResult<GetFileResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetFileResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/files/{path}', ...options });

/**
 * `PUT /skills/{slug}/files/{path...}` -- replace or add one file.
 */
export const putFile = <ThrowOnError extends boolean = false>(options: Options<PutFileData, ThrowOnError>): RequestResult<PutFileResponses, unknown, ThrowOnError> => (options.client ?? client).put<PutFileResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}/files/{path}',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const githubStatus = <ThrowOnError extends boolean = false>(options: Options<GithubStatusData, ThrowOnError>): RequestResult<GithubStatusResponses, unknown, ThrowOnError> => (options.client ?? client).get<GithubStatusResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/github', ...options });

/**
 * `POST /skills/{slug}/github/reconcile-orphans` -- ops endpoint
 * that mechanically removes canonical-repo paths the gateway no
 * longer claims for this skill. Issue #22 acceptance:
 *
 * - Owner, org-admin, or platform-admin authz (same
 * `ensure_can_operate_skill_catalog` pattern as
 * `/github/sync-from-main` and `/github/retry`).
 * - `confirm: true` is required. `false` or missing returns 409.
 * - The handler re-derives the **live** orphan-path set against the
 * canonical-repo HEAD and returns 409 if it does not match the
 * `expected_orphan_paths` payload (optimistic concurrency mirrors
 * `expected_current_version_id`).
 * - On match (and `dry_run: false`): stages one signed commit on
 * the canonical branch deleting every path. Author/committer is
 * the forward-publish bot pair so reverse-sync skips the commit
 * via `is_forward_publish_commit`.
 * - On `dry_run: true`: skips the commit and returns the planned
 * shape (paths + parent commit SHA + audit row id) without
 * touching GitHub.
 * - Records a `skill_orphan_reconciliations` audit row in both
 * modes (issue #22 acceptance criterion + migration 011).
 */
export const reconcileOrphans = <ThrowOnError extends boolean = false>(options: Options<ReconcileOrphansData, ThrowOnError>): RequestResult<ReconcileOrphansResponses, ReconcileOrphansErrors, ThrowOnError> => (options.client ?? client).post<ReconcileOrphansResponses, ReconcileOrphansErrors, ThrowOnError>({
    url: '/skills/{slug}/github/reconcile-orphans',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const retryGithubPublish = <ThrowOnError extends boolean = false>(options: Options<RetryGithubPublishData, ThrowOnError>): RequestResult<RetryGithubPublishResponses, unknown, ThrowOnError> => (options.client ?? client).post<RetryGithubPublishResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/github/retry', ...options });

/**
 * `POST /skills/{slug}/github/sync-from-main` -- ops endpoint that
 * re-fetches the canonical GitHub bundle at HEAD and reconciles it
 * into a new gateway version. No-op when the resulting
 * `content_hash_bundle` matches the current version. Requires owner,
 * org-admin, or `X-Seren-User-Role=admin`.
 */
export const syncFromMain = <ThrowOnError extends boolean = false>(options: Options<SyncFromMainData, ThrowOnError>): RequestResult<SyncFromMainResponses, unknown, ThrowOnError> => (options.client ?? client).post<SyncFromMainResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/github/sync-from-main', ...options });

export const purchaseSkill = <ThrowOnError extends boolean = false>(options: Options<PurchaseSkillData, ThrowOnError>): RequestResult<PurchaseSkillResponses, PurchaseSkillErrors, ThrowOnError> => (options.client ?? client).post<PurchaseSkillResponses, PurchaseSkillErrors, ThrowOnError>({ url: '/skills/{slug}/purchase', ...options });

export const updateSponsor = <ThrowOnError extends boolean = false>(options: Options<UpdateSponsorData, ThrowOnError>): RequestResult<UpdateSponsorResponses, unknown, ThrowOnError> => (options.client ?? client).put<UpdateSponsorResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}/sponsor',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const listUpdateRequests = <ThrowOnError extends boolean = false>(options: Options<ListUpdateRequestsData, ThrowOnError>): RequestResult<ListUpdateRequestsResponses, unknown, ThrowOnError> => (options.client ?? client).get<ListUpdateRequestsResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/update-requests', ...options });

export const createUpdateRequest = <ThrowOnError extends boolean = false>(options: Options<CreateUpdateRequestData, ThrowOnError>): RequestResult<CreateUpdateRequestResponses, unknown, ThrowOnError> => (options.client ?? client).post<CreateUpdateRequestResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}/update-requests',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const listVersions = <ThrowOnError extends boolean = false>(options: Options<ListVersionsData, ThrowOnError>): RequestResult<ListVersionsResponses, unknown, ThrowOnError> => (options.client ?? client).get<ListVersionsResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/versions', ...options });

export const createVersion = <ThrowOnError extends boolean = false>(options: Options<CreateVersionData, ThrowOnError>): RequestResult<CreateVersionResponses, unknown, ThrowOnError> => (options.client ?? client).post<CreateVersionResponses, unknown, ThrowOnError>({
    url: '/skills/{slug}/versions',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const getVersionManifest = <ThrowOnError extends boolean = false>(options: Options<GetVersionManifestData, ThrowOnError>): RequestResult<GetVersionManifestResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetVersionManifestResponses, unknown, ThrowOnError>({ url: '/skills/{slug}/versions/{version}/manifest', ...options });

export const getUpdateRequest = <ThrowOnError extends boolean = false>(options: Options<GetUpdateRequestData, ThrowOnError>): RequestResult<GetUpdateRequestResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetUpdateRequestResponses, unknown, ThrowOnError>({ url: '/update-requests/{request_id}', ...options });

export const acceptUpdateRequest = <ThrowOnError extends boolean = false>(options: Options<AcceptUpdateRequestData, ThrowOnError>): RequestResult<AcceptUpdateRequestResponses, unknown, ThrowOnError> => (options.client ?? client).post<AcceptUpdateRequestResponses, unknown, ThrowOnError>({
    url: '/update-requests/{request_id}/accept',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const listUpdateRequestComments = <ThrowOnError extends boolean = false>(options: Options<ListUpdateRequestCommentsData, ThrowOnError>): RequestResult<ListUpdateRequestCommentsResponses, unknown, ThrowOnError> => (options.client ?? client).get<ListUpdateRequestCommentsResponses, unknown, ThrowOnError>({ url: '/update-requests/{request_id}/comments', ...options });

export const createUpdateRequestComment = <ThrowOnError extends boolean = false>(options: Options<CreateUpdateRequestCommentData, ThrowOnError>): RequestResult<CreateUpdateRequestCommentResponses, unknown, ThrowOnError> => (options.client ?? client).post<CreateUpdateRequestCommentResponses, unknown, ThrowOnError>({
    url: '/update-requests/{request_id}/comments',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

export const getUpdateRequestDiff = <ThrowOnError extends boolean = false>(options: Options<GetUpdateRequestDiffData, ThrowOnError>): RequestResult<GetUpdateRequestDiffResponses, unknown, ThrowOnError> => (options.client ?? client).get<GetUpdateRequestDiffResponses, unknown, ThrowOnError>({ url: '/update-requests/{request_id}/diff', ...options });

export const rejectUpdateRequest = <ThrowOnError extends boolean = false>(options: Options<RejectUpdateRequestData, ThrowOnError>): RequestResult<RejectUpdateRequestResponses, unknown, ThrowOnError> => (options.client ?? client).post<RejectUpdateRequestResponses, unknown, ThrowOnError>({ url: '/update-requests/{request_id}/reject', ...options });

export const listUsageEvents = <ThrowOnError extends boolean = false>(options?: Options<ListUsageEventsData, ThrowOnError>): RequestResult<ListUsageEventsResponses, unknown, ThrowOnError> => (options?.client ?? client).get<ListUsageEventsResponses, unknown, ThrowOnError>({ url: '/usage', ...options });

export const usageSummary = <ThrowOnError extends boolean = false>(options?: Options<UsageSummaryData, ThrowOnError>): RequestResult<UsageSummaryResponses, unknown, ThrowOnError> => (options?.client ?? client).get<UsageSummaryResponses, unknown, ThrowOnError>({ url: '/usage/summary', ...options });
