import {z} from 'zod' export type Metadata = Record; export type ModifiedBy = string | null; export type ModifiedAt = string | null; export type AnnotationListTable = {visible?: boolean | undefined, width?: number | undefined, column_type?: ('meta' | 'schema') | undefined, schema_id?: string | undefined, data_type?: ('date' | 'number' | 'string' | 'boolean') | undefined, meta_type?: string | undefined}; export type OrganizationBase = {id?: number | undefined, name?: string | undefined, url?: string | undefined, workspaces?: Array | undefined, users?: Array | undefined, organization_group?: string | undefined, ui_settings?: Record | undefined, metadata?: Metadata | undefined, is_trial?: boolean | undefined, created_at?: string | undefined, trial_expires_at?: (string | null) | undefined, oidc_provider?: (string | null) | undefined, internal_info?: ({cs_account_classification?: (string | null) | undefined, customer_type?: (string | null) | undefined, market_category?: (string | null) | undefined, overdue_payment_date?: (string | null) | undefined, sso_active?: (boolean | null) | undefined} | null) | undefined, creator?: (string | null) | undefined, modified_by?: ModifiedBy | undefined, modified_at?: ModifiedAt | undefined, settings?: ({annotation_list_table?: ({columns?: Array | undefined}) | undefined, request_dashboard_table?: ({columns?: Array | undefined}) | undefined}) | undefined, sandbox?: boolean | undefined}; export type UpdateApiApiV1OrganizationsOrganizationIDArgs = {body: OrganizationBase}; export type UpdateApiApiV1OrganizationsOrganizationIDOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const metadata = z.object({}); export const modifiedBy = z.string().nullable(); export const modifiedAt = z.string().nullable(); export const annotationListTable = z.object({visible: z.boolean().optional(), width: z.number().optional(), column_type: z.enum(["meta", "schema"]).optional(), schema_id: z.string().optional(), data_type: z.enum(["date", "number", "string", "boolean"]).optional(), meta_type: z.string().optional()}); export const organization = z.object({id: z.number().int(), name: z.string(), url: z.string(), workspaces: z.array(z.string()), users: z.array(z.string()), organization_group: z.string(), ui_settings: z.object({}), metadata: metadata, is_trial: z.boolean(), created_at: z.string(), trial_expires_at: z.string().nullable().optional(), oidc_provider: z.string().nullable().optional(), internal_info: z.object({cs_account_classification: z.string().nullable().optional(), customer_type: z.string().nullable().optional(), market_category: z.string().nullable().optional(), overdue_payment_date: z.string().nullable().optional(), sso_active: z.boolean().nullable().optional()}).nullable().optional(), creator: z.string().nullable().optional(), modified_by: modifiedBy, modified_at: modifiedAt, settings: z.object({annotation_list_table: z.object({columns: z.array(annotationListTable).optional()}).optional(), request_dashboard_table: z.object({columns: z.array(annotationListTable).optional()}).optional()}), sandbox: z.boolean()}); 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 }; /** * Update organization * * PUT /api/v1/organizations/{organizationID} */ export const updateApiApiV1OrganizationsOrganizationID = async (args: UpdateApiApiV1OrganizationsOrganizationIDArgs, options?: UpdateApiApiV1OrganizationsOrganizationIDOptions) => { const {baseUrl = "https://example.rossum.app", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/organizations/${encodeURIComponent(String(args.organizationID))}${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(organization, await res.json()) };