import {z} from 'zod' export type ComPingidentityPingoneDavinciFlowsDataFragmentGraphData = {boxSelectionEnabled?: boolean | undefined, data?: Record | undefined, elements?: ({edges?: (Array<{data: {id: string, source: string, target: string}, classes?: string | undefined, grabbable?: boolean | undefined, group?: string | undefined, locked?: boolean | undefined, pannable?: boolean | undefined, position?: {x: number, y: number} | undefined, removed?: boolean | undefined, selectable?: boolean | undefined, selected?: boolean | undefined} | {[key: string]: unknown}>) | undefined, nodes?: (Array<{data: {id: string, nodeType: string, capabilityName?: string | undefined, connectionId?: string | undefined, connectorId?: string | undefined, idUnique?: string | undefined, label?: string | undefined, name?: string | undefined, properties?: ({backgroundColor?: {value: string} | undefined, code?: {value: string} | undefined, customCSS?: {value: string} | undefined, customHTML?: {value: string} | undefined, customScript?: {value: string} | undefined, formFieldsList?: ({value: Array<{preferredDataType: Array | boolean | number | number | Record | string, propertyName: string, preferredControlType?: string | undefined, value?: string | undefined}>}) | undefined, inputSchema?: {value: string} | undefined, message?: {value: string} | undefined, nodeTitle?: {value: string} | undefined, outputSchema?: {value: string} | undefined, saveVariables?: ({value: Array<{name: string, key?: number | undefined, label?: string | undefined, nameDefault?: string | undefined, type?: string | undefined, value?: string | undefined} | {[key: string]: unknown}>}) | undefined, showContinueButton?: {value: boolean} | undefined, type?: {value: string} | undefined, variableInputList?: ({value: Array<{name: string, preferredDataType: Array | boolean | number | number | Record | string, preferredControlType?: string | undefined, value?: string | undefined}>}) | undefined} | {[key: string]: unknown}) | undefined, status?: string | undefined, type?: string | undefined} | {[key: string]: unknown}, classes?: string | undefined, grabbable?: boolean | undefined, group?: string | undefined, locked?: boolean | undefined, pannable?: boolean | undefined, position?: {x: number, y: number} | undefined, removed?: boolean | undefined, selectable?: boolean | undefined, selected?: boolean | undefined} | {[key: string]: unknown}>) | undefined} | {[key: string]: unknown}) | undefined, maxZoom?: number | undefined, minZoom?: number | undefined, pan?: {x: number, y: number} | undefined, panningEnabled?: boolean | undefined, renderer?: Record | undefined, userPanningEnabled?: boolean | undefined, userZoomingEnabled?: boolean | undefined, zoom?: number | undefined, zoomingEnabled?: boolean | undefined} | {[key: string]: unknown}; export type ComPingidentityPingoneDavinciFlowsDataFragmentInputSchema = Array<{propertyName: string, preferredDataType: 'array' | 'boolean' | 'number' | 'object' | 'string', description?: string | undefined, isExpanded?: boolean | undefined, preferredControlType?: ('button' | 'colorPicker' | 'contentEditableTextArea' | 'cssArea' | 'dropDown' | 'dropDownMultiSelect' | 'dropDownMultiSelect2' | 'dropDownWithCreate' | 'functionArgumentList' | 'keyValueList' | 'label' | 'radioSelect' | 'textArea' | 'textField' | 'textFieldArrayView' | 'toggleSwitch') | undefined, required?: boolean | undefined}>; export type ComPingidentityPingoneDavinciFlowsDataFragmentOutputSchema = {output: {properties: {[key: string]: unknown}, type: 'object', additionalProperties?: boolean | undefined}}; export type ComPingidentityPingoneDavinciFlowsDataFragmentSettings = {csp?: string | undefined, css?: string | undefined, cssLinks?: Array | undefined, customErrorScreenBrandLogoUrl?: string | undefined, customErrorShowFooter?: (boolean | 'false' | 'true') | undefined, customFaviconLink?: string | undefined, customLogoURLSelection?: number | undefined, customTitle?: string | undefined, defaultErrorScreenBrandLogo?: (boolean | 'false' | 'true') | undefined, flowHttpTimeoutInSeconds?: number | undefined, flowTimeoutInSeconds?: number | undefined, intermediateLoadingScreenCSS?: (string | Record) | undefined, intermediateLoadingScreenHTML?: (string | Record) | undefined, jsCustomFlowPlayer?: string | undefined, jsLinks?: (Array<{label: string, value: string, defer: boolean | 'false' | 'true', crossorigin: string, integrity: string, referrerpolicy: string, type: string}>) | undefined, logLevel?: number | undefined, requireAuthenticationToInitiate?: (boolean | 'false' | 'true') | undefined, scrubSensitiveInfo?: (boolean | 'false' | 'true') | undefined, sensitiveInfoFields?: Array | undefined, useCSP?: (boolean | 'false' | 'true') | undefined, useCustomCSS?: (boolean | 'false' | 'true') | undefined, useCustomFlowPlayer?: (boolean | 'false' | 'true') | undefined, useCustomScript?: (boolean | 'false' | 'true') | undefined, useIntermediateLoadingScreen?: (boolean | 'false' | 'true') | undefined, validateOnSave?: (boolean | 'false' | 'true') | undefined} | {[key: string]: unknown}; export type ComPingidentityPingoneDavinciFlowsDataFragmentTrigger = {type: 'AUTHENTICATION' | 'SCHEDULE', configuration?: {mfa: {enabled: boolean, time: number, timeFormat: string}, pwd: {enabled: boolean, time: number, timeFormat: string}} | undefined}; export type ComPingidentityPingoneDavinciFlowsDataUpdateFlow = {name: string, color?: string | undefined, description?: string | undefined, graphData?: ComPingidentityPingoneDavinciFlowsDataFragmentGraphData | undefined, inputSchema?: ComPingidentityPingoneDavinciFlowsDataFragmentInputSchema | undefined, outputSchema?: ComPingidentityPingoneDavinciFlowsDataFragmentOutputSchema | undefined, settings?: ComPingidentityPingoneDavinciFlowsDataFragmentSettings | undefined, trigger?: ComPingidentityPingoneDavinciFlowsDataFragmentTrigger | undefined} | {[key: string]: unknown}; export type UpdateApiEnvironmentsEnvironmentIDFlowsFlowIDArgs = {environmentID: string, flowID: string, 'X-Ping-External-Session-ID'?: string | undefined, 'X-Ping-External-Transaction-ID'?: string | undefined, body: ComPingidentityPingoneDavinciFlowsDataUpdateFlow}; export type UpdateApiEnvironmentsEnvironmentIDFlowsFlowIDOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; 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 comPingidentityApiRelationshipPingOneRO = z.object({id: z.string().min(1)}); export const comPingidentityApiRelationshipDaVinciRO = z.object({id: z.string().min(1)}); export const comPingidentityPingoneDavinciFlowsResponseFragmentGraphData = z.object({boxSelectionEnabled: z.boolean(), elements: z.object({nodes: z.array(z.object({data: z.object({id: z.string().min(1), nodeType: z.string().min(1), capabilityName: z.string().optional(), connectionId: z.string().optional(), connectorId: z.string().optional(), idUnique: z.string().optional(), label: z.string().optional(), linterError: z.array(z.object({code: z.string().min(1), message: z.string().min(1), type: z.string().min(1), recommendation: z.string().min(1), flowId: z.string().min(1), nodeId: z.string().optional()})).optional(), name: z.string().optional(), properties: z.object({backgroundColor: z.object({value: z.string().min(1)}).optional(), code: z.object({value: z.string().min(1)}).optional(), customCSS: z.object({value: z.string().min(1)}).optional(), customHTML: z.object({value: z.string().min(1)}).optional(), customScript: z.object({value: z.string().min(1)}).optional(), formFieldsList: z.object({value: z.array(z.object({preferredDataType: z.union([z.array(z.unknown()), z.boolean(), z.number().int(), z.number(), z.object({}), z.string()]), propertyName: z.string().min(1), preferredControlType: z.string().optional(), value: z.string().optional()}))}).optional(), inputSchema: z.object({value: z.string().min(1)}).optional(), message: z.object({value: z.string().min(1)}).optional(), nodeTitle: z.object({value: z.string().min(1)}).optional(), outputSchema: z.object({value: z.string().min(1)}).optional(), saveVariables: z.object({value: z.array(z.object({name: z.string().min(1), key: z.number().optional(), label: z.string().optional(), nameDefault: z.string().optional(), type: z.string().optional(), value: z.string().optional()}).and(z.record(z.string(), z.unknown())))}).optional(), showContinueButton: z.object({value: z.boolean()}).optional(), type: z.object({value: z.string().min(1)}).optional(), variableInputList: z.object({value: z.array(z.object({name: z.string().min(1), preferredDataType: z.union([z.array(z.unknown()), z.boolean(), z.number().int(), z.number(), z.object({}), z.string()]), preferredControlType: z.string().optional(), value: z.string().optional()}))}).optional()}).and(z.record(z.string(), z.unknown())).optional(), status: z.string().optional(), type: z.string().min(1).optional()}).and(z.record(z.string(), z.unknown())), grabbable: z.boolean(), group: z.string().min(1), locked: z.boolean(), pannable: z.boolean(), position: z.object({x: z.number(), y: z.number()}), removed: z.boolean(), selectable: z.boolean(), selected: z.boolean(), classes: z.string().optional()})), edges: z.array(z.object({data: z.object({id: z.string().min(1), source: z.string().min(1), target: z.string().min(1)}), grabbable: z.boolean(), group: z.string().min(1), locked: z.boolean(), pannable: z.boolean(), position: z.object({x: z.number(), y: z.number()}), removed: z.boolean(), selectable: z.boolean(), selected: z.boolean(), classes: z.string().optional()})).optional()}), pan: z.object({x: z.number(), y: z.number()}), panningEnabled: z.boolean(), renderer: z.object({name: z.string().min(1)}), userPanningEnabled: z.boolean(), userZoomingEnabled: z.boolean(), zoom: z.number(), allLinterErrors: z.array(z.object({code: z.string().min(1), message: z.string().min(1), type: z.string().min(1), recommendation: z.string().min(1), flowId: z.string().min(1), nodeId: z.string().optional()})).optional(), data: z.object({}).optional(), maxZoom: z.number().optional(), minZoom: z.number().optional(), zoomingEnabled: z.boolean().optional()}); export const comPingidentityPingoneDavinciFlowsResponseFragmentInputSchema = z.array(z.object({preferredControlType: z.string().min(1), preferredDataType: z.enum(["array", "boolean", "number", "object", "string"]).min(1), propertyName: z.string().min(1), description: z.string().optional(), isExpanded: z.boolean().optional(), required: z.boolean().optional()})); export const comPingidentityPingoneDavinciFlowsResponseFragmentOutputSchema = z.object({output: z.object({properties: z.record(z.string(), z.unknown()), type: z.literal("object").min(1), additionalProperties: z.boolean().optional()})}); export const comPingidentityPingoneDavinciFlowsResponseFragmentSettings = z.object({csp: z.string().optional(), css: z.string().optional(), cssLinks: z.array(z.string()).optional(), customErrorScreenBrandLogoUrl: z.string().optional(), customErrorShowFooter: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), customFaviconLink: z.string().optional(), customLogoURLSelection: z.number().int().optional(), customTitle: z.string().optional(), defaultErrorScreenBrandLogo: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), flowHttpTimeoutInSeconds: z.number().int().optional(), flowTimeoutInSeconds: z.number().optional(), intermediateLoadingScreenCSS: z.union([z.string(), z.object({})]).optional(), intermediateLoadingScreenHTML: z.union([z.string(), z.object({})]).optional(), jsCustomFlowPlayer: z.string().optional(), jsLinks: z.array(z.object({crossorigin: z.string().min(1), defer: z.union([z.boolean(), z.enum(["false", "true"])]), integrity: z.string().min(1), label: z.string().min(1), referrerpolicy: z.string().min(1), type: z.string().min(1), value: z.string().min(1)})).optional(), logLevel: z.number().int().gte(1).lte(4).optional(), requireAuthenticationToInitiate: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), scrubSensitiveInfo: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), sensitiveInfoFields: z.array(z.string()).optional(), useCSP: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), useCustomCSS: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), useCustomFlowPlayer: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), useCustomScript: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), useIntermediateLoadingScreen: z.union([z.boolean(), z.enum(["false", "true"])]).optional(), validateOnSave: z.union([z.boolean(), z.enum(["false", "true"])]).optional()}).and(z.record(z.string(), z.unknown())); export const comPingidentityPingoneDavinciFlowsResponseFragmentTrigger = z.object({type: z.enum(["AUTHENTICATION", "SCHEDULE"]).min(1), configuration: z.object({mfa: z.object({enabled: z.boolean(), time: z.number(), timeFormat: z.string().min(1)}), pwd: z.object({enabled: z.boolean(), time: z.number(), timeFormat: z.string().min(1)})}).optional()}); export const comPingidentityPingoneDavinciFlowsResponseFlowResponse = z.object({_links: z.object({environment: comPingidentityApiResponseLink, self: comPingidentityApiResponseLink, connectorInstances: comPingidentityApiResponseLink, connectors: comPingidentityApiResponseLink, "flow.deploy": comPingidentityApiResponseLink, "flow.clone": comPingidentityApiResponseLink, "flow.enabled": comPingidentityApiResponseLink, version: comPingidentityApiResponseLink, "flow.validate": comPingidentityApiResponseLink.optional()}).and(z.record(z.string(), comPingidentityApiResponseLink)), environment: comPingidentityApiRelationshipPingOneRO, id: z.string().min(1), name: z.string().min(1), color: z.string().optional(), connectors: z.array(comPingidentityApiRelationshipDaVinciRO).optional(), createdAt: z.string().optional(), currentVersion: z.number().optional(), deployedAt: z.string().optional(), description: z.string().optional(), dvlinterErrorCount: z.number().optional(), dvlinterWarningCount: z.number().optional(), enabled: z.boolean().optional(), graphData: comPingidentityPingoneDavinciFlowsResponseFragmentGraphData.optional(), inputSchema: comPingidentityPingoneDavinciFlowsResponseFragmentInputSchema.optional(), outputSchema: comPingidentityPingoneDavinciFlowsResponseFragmentOutputSchema.optional(), publishedVersion: z.number().optional(), settings: comPingidentityPingoneDavinciFlowsResponseFragmentSettings.optional(), trigger: comPingidentityPingoneDavinciFlowsResponseFragmentTrigger.optional(), updatedAt: z.string().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 }; /** * PUT /environments/{environmentID}/flows/{flowID} */ export const updateApiEnvironmentsEnvironmentIDFlowsFlowID = async (args: UpdateApiEnvironmentsEnvironmentIDFlowsFlowIDArgs, options?: UpdateApiEnvironmentsEnvironmentIDFlowsFlowIDOptions) => { const {baseUrl = "https://api.pingone.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") 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))}/flows/${encodeURIComponent(String(args.flowID))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(comPingidentityPingoneDavinciFlowsResponseFlowResponse, await res.json()) };