import {z} from 'zod' export type SubjectRef = {id?: string | undefined, type?: ('USER' | 'ROLE' | 'GROUP') | undefined}; export type TargetRef = {id?: 'Identifier of the target e.g. `name` in case it's a WORKFLOW_DEF' | undefined, type: 'WORKFLOW' | 'WORKFLOW_DEF' | 'AGENT' | 'AGENT_EXECUTION' | 'AGENT_TASK' | 'WORKFLOW_SCHEDULE' | 'EVENT_HANDLER' | 'TASK_DEF' | 'TASK_QUEUE' | 'TASK_REF_NAME' | 'TASK_ID' | 'APPLICATION' | 'USER' | 'SECRET_NAME' | 'ENV_VARIABLE' | 'TAG' | 'DOMAIN' | 'INTEGRATION_PROVIDER' | 'INTEGRATION' | 'PROMPT' | 'USER_FORM_TEMPLATE' | 'SCHEMA' | 'BUSINESS_RULE' | 'CLUSTER_CONFIG' | 'WEBHOOK' | 'API_GATEWAY_SERVICE' | 'API_GATEWAY_SERVICE_ROUTE' | 'AUTH_CONFIG' | 'GROUP' | 'ROLE' | 'SERVICE_REGISTRY'}; export type AuthorizationRequest = {access: Array<'CREATE' | 'READ' | 'EXECUTE' | 'UPDATE' | 'DELETE'>, subject: SubjectRef, target: TargetRef}; export type DeleteApiApiAuthAuthorizationArgs = {body: AuthorizationRequest}; export type DeleteApiApiAuthAuthorizationOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const response = z.object({}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Remove user's access over the target * * DELETE /api/auth/authorization */ export const deleteApiApiAuthAuthorization = async (args: DeleteApiApiAuthAuthorizationArgs, options?: DeleteApiApiAuthAuthorizationOptions) => { const {baseUrl = "https://developer.orkescloud.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/auth/authorization${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", 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 validateResponse(response, await res.json()) };