import {z} from 'zod' export type GetApiApiV1ToolToolIdLinkToolUserArgs = {tool_id: string, page?: number | undefined, size?: number | undefined}; export type GetApiApiV1ToolToolIdLinkToolUserOptions = {baseUrl: string, YourAPIKey?: string | undefined, fetch?: typeof fetch | undefined}; export const iLinkToolUserRead = z.object({org_id: z.string().nullable().optional(), tool_id: z.string().nullable().optional(), credentials: z.record(z.string(), z.unknown()), name: z.string().nullable(), attributes: z.record(z.string(), z.unknown()).nullable().optional(), id: z.string()}); export const pageBaseILinkToolUserRead = z.object({items: z.array(iLinkToolUserRead), total: z.number().int().gte(0).nullable(), page: z.number().int().gte(1).nullable(), size: z.number().int().gte(1).nullable(), pages: z.number().int().gte(0).nullable().optional(), previous_page: z.number().int().nullable().optional(), next_page: z.number().int().nullable().optional()}); export const iGetResponsePaginatedILinkToolUserRead = z.object({message: z.string().nullable().optional(), meta: z.record(z.string(), z.unknown()).optional(), data: pageBaseILinkToolUserRead}); 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 }; /** * Get Link Tool User * * GET /api/v1/tool/{tool_id}/LinkToolUser * * Also accepts auth: HTTPBearer */ export const getApiApiV1ToolToolIdLinkToolUser = async (args: GetApiApiV1ToolToolIdLinkToolUserArgs, options: GetApiApiV1ToolToolIdLinkToolUserOptions) => { const {baseUrl, fetch: fetchFn = fetch, YourAPIKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.size != null) query.append("size", String(args.size)) if (YourAPIKey !== undefined) query.set("api_key", YourAPIKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/tool/${encodeURIComponent(String(args.tool_id))}/LinkToolUser${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(iGetResponsePaginatedILinkToolUserRead, await res.json()) };