import {z} from 'zod' export type GetApiEnvironmentsEnvironmentIDConnectorsConnectorIDDetailsArgs = {environmentID: string, connectorID: string, 'X-Ping-External-Session-ID'?: string | undefined, 'X-Ping-External-Transaction-ID'?: string | undefined}; export type GetApiEnvironmentsEnvironmentIDConnectorsConnectorIDDetailsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const comPingidentityApiRelationshipPingOneRO = z.object({id: z.string().min(1)}); export const comPingidentityApiResponseLink = z.object({href: z.string().min(1), name: z.string().optional(), profile: z.string().optional(), title: z.string().optional(), type: z.string().optional()}); export const comPingidentityPingoneDavinciConnectorsResponseConnectorDetailsResponse = z.object({environment: comPingidentityApiRelationshipPingOneRO, _links: z.object({environment: comPingidentityApiResponseLink, self: comPingidentityApiResponseLink}).and(z.record(z.string(), comPingidentityApiResponseLink)).optional(), accountConfigView: z.object({items: z.array(z.record(z.string(), z.unknown())), componentViewSize: z.string().optional()}).optional(), capabilities: z.record(z.string(), z.object({})).optional(), credentialsView: z.object({items: z.array(z.record(z.string(), z.unknown()))}).optional(), flowSections: z.array(z.object({name: z.string().min(1), value: z.string().min(1)})).optional(), properties: z.record(z.string(), z.unknown()).optional(), sections: z.array(z.object({name: z.string().min(1), value: z.string().min(1), default: z.boolean().optional()})).optional()}); 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 /environments/{environmentID}/connectors/{connectorID}/details */ export const getApiEnvironmentsEnvironmentIDConnectorsConnectorIDDetails = async (args: GetApiEnvironmentsEnvironmentIDConnectorsConnectorIDDetailsArgs, options?: GetApiEnvironmentsEnvironmentIDConnectorsConnectorIDDetailsOptions) => { const {baseUrl = "https://api.pingone.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['X-Ping-External-Session-ID'] != null) headers.set("X-Ping-External-Session-ID", String(args['X-Ping-External-Session-ID'])) if (args['X-Ping-External-Transaction-ID'] != null) headers.set("X-Ping-External-Transaction-ID", String(args['X-Ping-External-Transaction-ID'])) const url = `${baseUrl.replace(/\/+$/, '')}/environments/${encodeURIComponent(String(args.environmentID))}/connectors/${encodeURIComponent(String(args.connectorID))}/details${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(comPingidentityPingoneDavinciConnectorsResponseConnectorDetailsResponse, await res.json()) };