export type SheetOrganizationGroup = {id: string, name: string, position: number}; export type SheetOrganizationSheet = {page_identity_id: string, sheet_group_id: string | null, position: number}; export type SaveSheetOrganizationRequest = {groups: Array, sheets: Array, deleted_group_ids?: Array | undefined}; export type UpdateApiApiV1ProjectsProjectIdSheetOrganizationArgs = {project_id: string, body: SaveSheetOrganizationRequest}; export type UpdateApiApiV1ProjectsProjectIdSheetOrganizationOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Save Sheet Organization * * PUT /api/v1/projects/{project_id}/sheet-organization */ export const updateApiApiV1ProjectsProjectIdSheetOrganization = async (args: UpdateApiApiV1ProjectsProjectIdSheetOrganizationArgs, options: UpdateApiApiV1ProjectsProjectIdSheetOrganizationOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/projects/${encodeURIComponent(String(args.project_id))}/sheet-organization${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };