/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ProxyPatchProxyGlobals = { /** * ID of the consumer which you want to get or push data from */ consumerId?: string | undefined; /** * The ID of your Unify application */ appId?: string | undefined; }; export type ProxyPatchProxyRequestBody3 = {}; export type ProxyPatchProxyRequestBody1 = {}; export type ProxyPatchProxyRequest = { /** * ID of the consumer which you want to get or push data from */ consumerId?: string | undefined; /** * The ID of your Unify application */ appId?: string | undefined; /** * Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API. */ serviceId: string; /** * Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used. */ unifiedApi?: string | undefined; /** * Downstream URL */ downstreamUrl: string; /** * Downstream authorization header. This will skip the Vault token injection. */ downstreamAuthorization?: string | undefined; /** * Override the default downstream request timeout in milliseconds. The default is 28000 (28 seconds). */ timeout?: number | undefined; /** * Set to `false` to opt out of the redirect to the presigned download URL. Instead of a `30x` response, you receive a `200` JSON body `{ url, expires_at }` containing the URL and its expiry, which you can fetch explicitly. Use this if your client automatically forwards the `Authorization` header onto redirects, since the downstream storage provider will reject that request. Any value other than `false` (or omitting the header) preserves the default redirect behavior. */ followRedirects?: boolean | undefined; /** * Depending on the verb/method of the request this will contain the request body you want to POST/PATCH/PUT. */ requestBody?: | ReadableStream | Blob | ArrayBuffer | Uint8Array | undefined; }; export type ProxyPatchProxyResponse = { httpMeta: components.HTTPMetadata; /** * Ok. When the request includes `x-apideck-follow-redirects: false` and the downstream response would otherwise redirect to a presigned URL (oversized responses), the body is instead an `application/json` object `{ url, expires_at }` — fetch `url` explicitly (without the Authorization header) to retrieve the payload. */ responseJson?: { [k: string]: any } | undefined; /** * Ok. When the request includes `x-apideck-follow-redirects: false` and the downstream response would otherwise redirect to a presigned URL (oversized responses), the body is instead an `application/json` object `{ url, expires_at }` — fetch `url` explicitly (without the Authorization header) to retrieve the payload. */ responseBinary?: ReadableStream | undefined; /** * Ok. When the request includes `x-apideck-follow-redirects: false` and the downstream response would otherwise redirect to a presigned URL (oversized responses), the body is instead an `application/json` object `{ url, expires_at }` — fetch `url` explicitly (without the Authorization header) to retrieve the payload. */ responsePdf?: ReadableStream | undefined; /** * Ok. When the request includes `x-apideck-follow-redirects: false` and the downstream response would otherwise redirect to a presigned URL (oversized responses), the body is instead an `application/json` object `{ url, expires_at }` — fetch `url` explicitly (without the Authorization header) to retrieve the payload. */ responseXml?: string | undefined; /** * Ok. When the request includes `x-apideck-follow-redirects: false` and the downstream response would otherwise redirect to a presigned URL (oversized responses), the body is instead an `application/json` object `{ url, expires_at }` — fetch `url` explicitly (without the Authorization header) to retrieve the payload. */ responseCsv?: string | undefined; /** * Ok. When the request includes `x-apideck-follow-redirects: false` and the downstream response would otherwise redirect to a presigned URL (oversized responses), the body is instead an `application/json` object `{ url, expires_at }` — fetch `url` explicitly (without the Authorization header) to retrieve the payload. */ responseText?: string | undefined; /** * Proxy error */ errorJson?: { [k: string]: any } | undefined; /** * Proxy error */ errorXml?: string | undefined; /** * Proxy error */ errorHtml?: string | undefined; /** * Proxy error */ errorText?: string | undefined; }; /** @internal */ export type ProxyPatchProxyRequestBody3$Outbound = {}; /** @internal */ export const ProxyPatchProxyRequestBody3$outboundSchema: z.ZodType< ProxyPatchProxyRequestBody3$Outbound, z.ZodTypeDef, ProxyPatchProxyRequestBody3 > = /* @__PURE__ */ lazySchema$(() => z.object({})); export function proxyPatchProxyRequestBody3ToJSON( proxyPatchProxyRequestBody3: ProxyPatchProxyRequestBody3, ): string { return JSON.stringify( ProxyPatchProxyRequestBody3$outboundSchema.parse( proxyPatchProxyRequestBody3, ), ); } /** @internal */ export type ProxyPatchProxyRequestBody1$Outbound = {}; /** @internal */ export const ProxyPatchProxyRequestBody1$outboundSchema: z.ZodType< ProxyPatchProxyRequestBody1$Outbound, z.ZodTypeDef, ProxyPatchProxyRequestBody1 > = /* @__PURE__ */ lazySchema$(() => z.object({})); export function proxyPatchProxyRequestBody1ToJSON( proxyPatchProxyRequestBody1: ProxyPatchProxyRequestBody1, ): string { return JSON.stringify( ProxyPatchProxyRequestBody1$outboundSchema.parse( proxyPatchProxyRequestBody1, ), ); } /** @internal */ export type ProxyPatchProxyRequest$Outbound = { consumerId?: string | undefined; appId?: string | undefined; serviceId: string; unifiedApi?: string | undefined; downstreamUrl: string; downstreamAuthorization?: string | undefined; timeout: number; followRedirects: boolean; RequestBody?: | ReadableStream | Blob | ArrayBuffer | Uint8Array | undefined; }; /** @internal */ export const ProxyPatchProxyRequest$outboundSchema: z.ZodType< ProxyPatchProxyRequest$Outbound, z.ZodTypeDef, ProxyPatchProxyRequest > = /* @__PURE__ */ lazySchema$(() => z.object({ consumerId: z.string().optional(), appId: z.string().optional(), serviceId: z.string(), unifiedApi: z.string().optional(), downstreamUrl: z.string(), downstreamAuthorization: z.string().optional(), timeout: z.number().int().default(28000), followRedirects: z.boolean().default(true), requestBody: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]).optional(), }).transform((v) => { return remap$(v, { requestBody: "RequestBody", }); }) ); export function proxyPatchProxyRequestToJSON( proxyPatchProxyRequest: ProxyPatchProxyRequest, ): string { return JSON.stringify( ProxyPatchProxyRequest$outboundSchema.parse(proxyPatchProxyRequest), ); } /** @internal */ export const ProxyPatchProxyResponse$inboundSchema: z.ZodType< ProxyPatchProxyResponse, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ HttpMeta: components.HTTPMetadata$inboundSchema, responseJson: types.optional(z.record(z.any())), responseBinary: types.optional(z.instanceof(ReadableStream)), responsePdf: types.optional(z.instanceof(ReadableStream)), responseXml: types.optional(types.string()), responseCsv: types.optional(types.string()), responseText: types.optional(types.string()), errorJson: types.optional(z.record(z.any())), errorXml: types.optional(types.string()), errorHtml: types.optional(types.string()), errorText: types.optional(types.string()), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", }); }) ); export function proxyPatchProxyResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProxyPatchProxyResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProxyPatchProxyResponse' from JSON`, ); }