import {z} from 'zod' export type GetApiV1AccountAccountSlugProjectProjectSlugActionsActionActionIdCallsArgs = {accountSlug: string, projectSlug: string, actionId: string, page?: number | undefined, pageSize?: number | undefined, status?: (Array<'ENABLED' | 'DISABLED' | 'SUCCEEDED' | 'SUBMITTED' | 'SKIPPED' | 'FAILED' | 'PENDING' | 'RETRY' | 'TIMED_OUT' | 'RATE_LIMITED'>) | undefined, after?: string | undefined, before?: string | undefined}; export type GetApiV1AccountAccountSlugProjectProjectSlugActionsActionActionIdCallsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const web3ActionExecutionsGetResponse = z.array(z.unknown()); 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 execution history for single Web3 Action * * GET /v1/account/{accountSlug}/project/{projectSlug}/actions/action/{actionId}/calls * * Also accepts auth: BearerAuth */ export const getApiV1AccountAccountSlugProjectProjectSlugActionsActionActionIdCalls = async (args: GetApiV1AccountAccountSlugProjectProjectSlugActionsActionActionIdCallsArgs, options?: GetApiV1AccountAccountSlugProjectProjectSlugActionsActionActionIdCallsOptions) => { const {baseUrl = "https://api.tenderly.co/api", fetch: fetchFn = fetch, ApiKeyAuth} = 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.pageSize != null) query.append("pageSize", String(args.pageSize)) for (const item of args.status ?? []) query.append("status", String(item)) if (args.after != null) query.append("after", String(args.after)) if (args.before != null) query.append("before", String(args.before)) if (ApiKeyAuth !== undefined) headers.set("X-Access-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/account/${encodeURIComponent(String(args.accountSlug))}/project/${encodeURIComponent(String(args.projectSlug))}/actions/action/${encodeURIComponent(String(args.actionId))}/calls${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(web3ActionExecutionsGetResponse, await res.json()) };