UNPKG

@docusign/iam-sdk

Version:

Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.

593 lines (548 loc) 18.5 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ResourceMetadata, ResourceMetadata$inboundSchema, ResourceMetadata$Outbound, ResourceMetadata$outboundSchema, } from "./resourcemetadata.js"; /** * The type of event that triggers the workflow. In this case, the workflow is initiated * * @remarks * by an HTTP request. Future iterations may support additional event types beyond HTTP. */ export const TriggerEventType = { Http: "HTTP", } as const; /** * The type of event that triggers the workflow. In this case, the workflow is initiated * * @remarks * by an HTTP request. Future iterations may support additional event types beyond HTTP. */ export type TriggerEventType = ClosedEnum<typeof TriggerEventType>; /** * The HTTP method used to trigger the workflow. This defines the type of request * * @remarks * that will initiate the workflow (e.g., GET, POST). */ export const Method = { Get: "GET", Post: "POST", Put: "PUT", Patch: "PATCH", Delete: "DELETE", } as const; /** * The HTTP method used to trigger the workflow. This defines the type of request * * @remarks * that will initiate the workflow (e.g., GET, POST). */ export type Method = ClosedEnum<typeof Method>; /** * Configuration details specific to HTTP-triggered workflows. This object describes the * * @remarks * HTTP method and URL that will trigger the workflow, providing the endpoint and method * that should be used to initiate the workflow. */ export type TriggerHttpConfig = { /** * The HTTP method used to trigger the workflow. This defines the type of request * * @remarks * that will initiate the workflow (e.g., GET, POST). */ method?: Method | undefined; url?: string | undefined; }; /** * The data type expected for the input field. This indicates whether the input should * * @remarks * be a string, number, boolean, object, or array, ensuring the data is passed in the * correct format. */ export type FieldDataType = {}; /** * The default value for the input field if one is provided. This can be a string, number, * * @remarks * boolean, object, or array. If no value is provided during the trigger, the workflow may * use this default value. */ export type DefaultValue = | string | number | boolean | { [k: string]: any } | Array<any>; /** * Array of fields required as inputs to trigger the workflow, including field names, data types, and default values. */ export type TriggerInputSchema = { /** * The name of the input field expected by the workflow. This key must match the name * * @remarks * provided in the `trigger_inputs` when triggering the workflow. */ fieldName?: string | undefined; /** * The data type expected for the input field. This indicates whether the input should * * @remarks * be a string, number, boolean, object, or array, ensuring the data is passed in the * correct format. */ fieldDataType?: FieldDataType | undefined; /** * The default value for the input field if one is provided. This can be a string, number, * * @remarks * boolean, object, or array. If no value is provided during the trigger, the workflow may * use this default value. */ defaultValue?: | string | number | boolean | { [k: string]: any } | Array<any> | undefined; }; /** * Control information and metadata for the response. */ export type WorkflowTriggerRequirementsSuccess = { triggerId?: string | null | undefined; /** * The type of event that triggers the workflow. In this case, the workflow is initiated * * @remarks * by an HTTP request. Future iterations may support additional event types beyond HTTP. */ triggerEventType?: TriggerEventType | undefined; /** * Configuration details specific to HTTP-triggered workflows. This object describes the * * @remarks * HTTP method and URL that will trigger the workflow, providing the endpoint and method * that should be used to initiate the workflow. */ triggerHttpConfig?: TriggerHttpConfig | undefined; /** * A list of input fields that define the structure of the data required to trigger the workflow. * * @remarks * Each item describes a field that must be included in the request when the workflow is triggered. * The schema includes the field name, expected data type, and any default values for the input. */ triggerInputSchema?: Array<TriggerInputSchema> | undefined; metadata?: ResourceMetadata | undefined; /** * The maximum number of items that can be returned in a single page. */ pageLimit?: number | null | undefined; /** * The continuation token used to retrieve a page in a paginated response. */ pageTokenNext?: string | null | undefined; /** * Unique identifier for the request, useful for tracking and debugging. */ requestId?: string | null | undefined; /** * The timestamp indicating when the response was generated. */ responseTimestamp?: Date | null | undefined; /** * The duration of time, in milliseconds, that the server took to process and respond * * @remarks * to the request. This is measured from the time the server received the request * until the time the response was sent. */ responseDurationMs?: number | null | undefined; }; /** @internal */ export const TriggerEventType$inboundSchema: z.ZodNativeEnum< typeof TriggerEventType > = z.nativeEnum(TriggerEventType); /** @internal */ export const TriggerEventType$outboundSchema: z.ZodNativeEnum< typeof TriggerEventType > = TriggerEventType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TriggerEventType$ { /** @deprecated use `TriggerEventType$inboundSchema` instead. */ export const inboundSchema = TriggerEventType$inboundSchema; /** @deprecated use `TriggerEventType$outboundSchema` instead. */ export const outboundSchema = TriggerEventType$outboundSchema; } /** @internal */ export const Method$inboundSchema: z.ZodNativeEnum<typeof Method> = z .nativeEnum(Method); /** @internal */ export const Method$outboundSchema: z.ZodNativeEnum<typeof Method> = Method$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Method$ { /** @deprecated use `Method$inboundSchema` instead. */ export const inboundSchema = Method$inboundSchema; /** @deprecated use `Method$outboundSchema` instead. */ export const outboundSchema = Method$outboundSchema; } /** @internal */ export const TriggerHttpConfig$inboundSchema: z.ZodType< TriggerHttpConfig, z.ZodTypeDef, unknown > = z.object({ method: Method$inboundSchema.optional(), url: z.string().optional(), }); /** @internal */ export type TriggerHttpConfig$Outbound = { method?: string | undefined; url?: string | undefined; }; /** @internal */ export const TriggerHttpConfig$outboundSchema: z.ZodType< TriggerHttpConfig$Outbound, z.ZodTypeDef, TriggerHttpConfig > = z.object({ method: Method$outboundSchema.optional(), url: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TriggerHttpConfig$ { /** @deprecated use `TriggerHttpConfig$inboundSchema` instead. */ export const inboundSchema = TriggerHttpConfig$inboundSchema; /** @deprecated use `TriggerHttpConfig$outboundSchema` instead. */ export const outboundSchema = TriggerHttpConfig$outboundSchema; /** @deprecated use `TriggerHttpConfig$Outbound` instead. */ export type Outbound = TriggerHttpConfig$Outbound; } export function triggerHttpConfigToJSON( triggerHttpConfig: TriggerHttpConfig, ): string { return JSON.stringify( TriggerHttpConfig$outboundSchema.parse(triggerHttpConfig), ); } export function triggerHttpConfigFromJSON( jsonString: string, ): SafeParseResult<TriggerHttpConfig, SDKValidationError> { return safeParse( jsonString, (x) => TriggerHttpConfig$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TriggerHttpConfig' from JSON`, ); } /** @internal */ export const FieldDataType$inboundSchema: z.ZodType< FieldDataType, z.ZodTypeDef, unknown > = z.object({}); /** @internal */ export type FieldDataType$Outbound = {}; /** @internal */ export const FieldDataType$outboundSchema: z.ZodType< FieldDataType$Outbound, z.ZodTypeDef, FieldDataType > = z.object({}); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FieldDataType$ { /** @deprecated use `FieldDataType$inboundSchema` instead. */ export const inboundSchema = FieldDataType$inboundSchema; /** @deprecated use `FieldDataType$outboundSchema` instead. */ export const outboundSchema = FieldDataType$outboundSchema; /** @deprecated use `FieldDataType$Outbound` instead. */ export type Outbound = FieldDataType$Outbound; } export function fieldDataTypeToJSON(fieldDataType: FieldDataType): string { return JSON.stringify(FieldDataType$outboundSchema.parse(fieldDataType)); } export function fieldDataTypeFromJSON( jsonString: string, ): SafeParseResult<FieldDataType, SDKValidationError> { return safeParse( jsonString, (x) => FieldDataType$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FieldDataType' from JSON`, ); } /** @internal */ export const DefaultValue$inboundSchema: z.ZodType< DefaultValue, z.ZodTypeDef, unknown > = z.union([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array(z.any()), ]); /** @internal */ export type DefaultValue$Outbound = string | number | boolean | { [k: string]: any; } | Array<any>; /** @internal */ export const DefaultValue$outboundSchema: z.ZodType< DefaultValue$Outbound, z.ZodTypeDef, DefaultValue > = z.union([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array(z.any()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace DefaultValue$ { /** @deprecated use `DefaultValue$inboundSchema` instead. */ export const inboundSchema = DefaultValue$inboundSchema; /** @deprecated use `DefaultValue$outboundSchema` instead. */ export const outboundSchema = DefaultValue$outboundSchema; /** @deprecated use `DefaultValue$Outbound` instead. */ export type Outbound = DefaultValue$Outbound; } export function defaultValueToJSON(defaultValue: DefaultValue): string { return JSON.stringify(DefaultValue$outboundSchema.parse(defaultValue)); } export function defaultValueFromJSON( jsonString: string, ): SafeParseResult<DefaultValue, SDKValidationError> { return safeParse( jsonString, (x) => DefaultValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DefaultValue' from JSON`, ); } /** @internal */ export const TriggerInputSchema$inboundSchema: z.ZodType< TriggerInputSchema, z.ZodTypeDef, unknown > = z.object({ field_name: z.string().optional(), field_data_type: z.lazy(() => FieldDataType$inboundSchema).optional(), default_value: z.union([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array(z.any()), ]).optional(), }).transform((v) => { return remap$(v, { "field_name": "fieldName", "field_data_type": "fieldDataType", "default_value": "defaultValue", }); }); /** @internal */ export type TriggerInputSchema$Outbound = { field_name?: string | undefined; field_data_type?: FieldDataType$Outbound | undefined; default_value?: | string | number | boolean | { [k: string]: any } | Array<any> | undefined; }; /** @internal */ export const TriggerInputSchema$outboundSchema: z.ZodType< TriggerInputSchema$Outbound, z.ZodTypeDef, TriggerInputSchema > = z.object({ fieldName: z.string().optional(), fieldDataType: z.lazy(() => FieldDataType$outboundSchema).optional(), defaultValue: z.union([ z.string(), z.number(), z.boolean(), z.record(z.any()), z.array(z.any()), ]).optional(), }).transform((v) => { return remap$(v, { fieldName: "field_name", fieldDataType: "field_data_type", defaultValue: "default_value", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TriggerInputSchema$ { /** @deprecated use `TriggerInputSchema$inboundSchema` instead. */ export const inboundSchema = TriggerInputSchema$inboundSchema; /** @deprecated use `TriggerInputSchema$outboundSchema` instead. */ export const outboundSchema = TriggerInputSchema$outboundSchema; /** @deprecated use `TriggerInputSchema$Outbound` instead. */ export type Outbound = TriggerInputSchema$Outbound; } export function triggerInputSchemaToJSON( triggerInputSchema: TriggerInputSchema, ): string { return JSON.stringify( TriggerInputSchema$outboundSchema.parse(triggerInputSchema), ); } export function triggerInputSchemaFromJSON( jsonString: string, ): SafeParseResult<TriggerInputSchema, SDKValidationError> { return safeParse( jsonString, (x) => TriggerInputSchema$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TriggerInputSchema' from JSON`, ); } /** @internal */ export const WorkflowTriggerRequirementsSuccess$inboundSchema: z.ZodType< WorkflowTriggerRequirementsSuccess, z.ZodTypeDef, unknown > = z.object({ trigger_id: z.nullable( z.string().default("00000000-0000-0000-0000-000000000000"), ), trigger_event_type: TriggerEventType$inboundSchema.optional(), trigger_http_config: z.lazy(() => TriggerHttpConfig$inboundSchema).optional(), trigger_input_schema: z.array(z.lazy(() => TriggerInputSchema$inboundSchema)) .optional(), metadata: ResourceMetadata$inboundSchema.optional(), page_limit: z.nullable(z.number().int()).optional(), page_token_next: z.nullable(z.string()).optional(), request_id: z.nullable(z.string()).optional(), response_timestamp: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), response_duration_ms: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { "trigger_id": "triggerId", "trigger_event_type": "triggerEventType", "trigger_http_config": "triggerHttpConfig", "trigger_input_schema": "triggerInputSchema", "page_limit": "pageLimit", "page_token_next": "pageTokenNext", "request_id": "requestId", "response_timestamp": "responseTimestamp", "response_duration_ms": "responseDurationMs", }); }); /** @internal */ export type WorkflowTriggerRequirementsSuccess$Outbound = { trigger_id: string | null; trigger_event_type?: string | undefined; trigger_http_config?: TriggerHttpConfig$Outbound | undefined; trigger_input_schema?: Array<TriggerInputSchema$Outbound> | undefined; metadata?: ResourceMetadata$Outbound | undefined; page_limit?: number | null | undefined; page_token_next?: string | null | undefined; request_id?: string | null | undefined; response_timestamp?: string | null | undefined; response_duration_ms?: number | null | undefined; }; /** @internal */ export const WorkflowTriggerRequirementsSuccess$outboundSchema: z.ZodType< WorkflowTriggerRequirementsSuccess$Outbound, z.ZodTypeDef, WorkflowTriggerRequirementsSuccess > = z.object({ triggerId: z.nullable( z.string().default("00000000-0000-0000-0000-000000000000"), ), triggerEventType: TriggerEventType$outboundSchema.optional(), triggerHttpConfig: z.lazy(() => TriggerHttpConfig$outboundSchema).optional(), triggerInputSchema: z.array(z.lazy(() => TriggerInputSchema$outboundSchema)) .optional(), metadata: ResourceMetadata$outboundSchema.optional(), pageLimit: z.nullable(z.number().int()).optional(), pageTokenNext: z.nullable(z.string()).optional(), requestId: z.nullable(z.string()).optional(), responseTimestamp: z.nullable(z.date().transform(v => v.toISOString())) .optional(), responseDurationMs: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { triggerId: "trigger_id", triggerEventType: "trigger_event_type", triggerHttpConfig: "trigger_http_config", triggerInputSchema: "trigger_input_schema", pageLimit: "page_limit", pageTokenNext: "page_token_next", requestId: "request_id", responseTimestamp: "response_timestamp", responseDurationMs: "response_duration_ms", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace WorkflowTriggerRequirementsSuccess$ { /** @deprecated use `WorkflowTriggerRequirementsSuccess$inboundSchema` instead. */ export const inboundSchema = WorkflowTriggerRequirementsSuccess$inboundSchema; /** @deprecated use `WorkflowTriggerRequirementsSuccess$outboundSchema` instead. */ export const outboundSchema = WorkflowTriggerRequirementsSuccess$outboundSchema; /** @deprecated use `WorkflowTriggerRequirementsSuccess$Outbound` instead. */ export type Outbound = WorkflowTriggerRequirementsSuccess$Outbound; } export function workflowTriggerRequirementsSuccessToJSON( workflowTriggerRequirementsSuccess: WorkflowTriggerRequirementsSuccess, ): string { return JSON.stringify( WorkflowTriggerRequirementsSuccess$outboundSchema.parse( workflowTriggerRequirementsSuccess, ), ); } export function workflowTriggerRequirementsSuccessFromJSON( jsonString: string, ): SafeParseResult<WorkflowTriggerRequirementsSuccess, SDKValidationError> { return safeParse( jsonString, (x) => WorkflowTriggerRequirementsSuccess$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WorkflowTriggerRequirementsSuccess' from JSON`, ); }