import {z} from 'zod' export type BillingLimitsSchema = {ai_credits?: (number | null) | undefined, ai_object_detection_hours?: (number | null) | undefined, automation_tasks?: (number | null) | undefined, browse_users?: (number | null) | undefined, edge_transcoders?: (number | null) | undefined, egress_gb?: (number | null) | undefined, face_recognition_hours?: (number | null) | undefined, face_recognition_images?: (number | null) | undefined, image_recognition?: (number | null) | undefined, max_portals?: (number | null) | undefined, max_storage_gateway_clusters?: (number | null) | undefined, max_storage_gateway_nodes?: (number | null) | undefined, multiregion_storage_gb?: (number | null) | undefined, power_users?: (number | null) | undefined, proxy_storage_gb?: (number | null) | undefined, regional_storage_gb?: (number | null) | undefined, shield_enabled?: (boolean | null) | undefined, standard_users?: (number | null) | undefined, sync_session_max_clients?: (number | null) | undefined, transcription_hours?: (number | null) | undefined}; export type SystemDomainSuperAdminSchema = {base_url: string, billing_limits?: (BillingLimitsSchema | null) | undefined, billing_tier?: ('PAYGO' | 'PRO' | 'ENTERPRISE' | 'ENTERPRISE_LEGACY_2025' | 'PRO_LEGACY_2025') | undefined, contract_end_date?: (string | null) | undefined, country?: (string | null) | undefined, creating_user_id?: (string | null) | undefined, custom_terms?: boolean | undefined, date_created?: string | undefined, date_modified?: string | undefined, deactivate_date?: (string | null) | undefined, description?: string | undefined, disable_ai_features?: boolean | undefined, disable_billing_page?: boolean | undefined, disable_cc_purchase?: boolean | undefined, discount_percent?: (number | null) | undefined, do_not_charge_edge_transcoder?: boolean | undefined, do_not_charge_remote_proxies?: boolean | undefined, do_not_charge_shield?: boolean | undefined, do_not_trace_ai_usage?: boolean | undefined, features?: Array | undefined, freeze_date?: (string | null) | undefined, has_preloaded_assets?: boolean | undefined, id?: string | undefined, industry?: ('ADVERTISING_MARKETING_CREATIVE' | 'AUTOMOTIVE' | 'BROADCASTER_NETWORKS' | 'CONSTRUCTION_MANUFACTURING' | 'EDUCATION' | 'ENERGY_UTILITIES' | 'FAITH_RELIGIOUS_ORGS' | 'FINANCE' | 'GAME_STUDIOS_PUBLISHERS' | 'GOVERNMENT_PUBLIC_SECTOR' | 'HEALTHCARE' | 'HOSPITALITY_FITNESS_WELLNESS' | 'LIVE_PRODUCTION_EVENTS' | 'MEDIA_CONGLOMERATES' | 'NONPROFITS_NON_RELIGIOUS' | 'ONLINE_MEDIA' | 'PUBLISHERS_NEWSPAPERS' | 'TELECOMMUNICATIONS' | 'RETAIL_CONSUMER_GOODS' | 'SOFTWARE_TECHNOLOGY' | 'SPORTS_RIGHTS_LEAGUES' | 'STUDIOS_CONTENT_PRODUCERS' | 'OTHER') | undefined, invoice_end_of_month?: boolean | undefined, is_plg?: boolean | undefined, is_template?: boolean | undefined, licensed_user_billing?: boolean | undefined, marketplace_customer_id?: (string | null) | undefined, marketplace_entitlement_id?: (string | null) | undefined, name: string, ordway_customer_id?: (string | null) | undefined, ordway_subscription_id?: (string | null) | undefined, platform_name?: string | undefined, price_list?: (string | null) | undefined, referral_code?: (string | null) | undefined, sales_force_id?: (string | null) | undefined, status?: ('ACTIVE' | 'WARNING' | 'FROZEN' | 'DEACTIVATED') | undefined, stripe_id?: (string | null) | undefined, type?: ('TRIAL' | 'CUSTOMER' | 'PARTNER' | 'INTERNAL') | undefined, warning_message?: string | undefined}; export type CreateApiV1SystemDomainsArgs = {'App-ID': string, 'Auth-Token': string, body: SystemDomainSuperAdminSchema}; export type CreateApiV1SystemDomainsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const billingLimitsSchema = z.object({ai_credits: z.number().int().nullable().optional(), ai_object_detection_hours: z.number().int().nullable().optional(), automation_tasks: z.number().int().nullable().optional(), browse_users: z.number().int().nullable().optional(), edge_transcoders: z.number().int().nullable().optional(), egress_gb: z.number().int().nullable().optional(), face_recognition_hours: z.number().int().nullable().optional(), face_recognition_images: z.number().int().nullable().optional(), image_recognition: z.number().int().nullable().optional(), max_portals: z.number().int().nullable().optional(), max_storage_gateway_clusters: z.number().int().nullable().optional(), max_storage_gateway_nodes: z.number().int().nullable().optional(), multiregion_storage_gb: z.number().int().nullable().optional(), power_users: z.number().int().nullable().optional(), proxy_storage_gb: z.number().int().nullable().optional(), regional_storage_gb: z.number().int().nullable().optional(), shield_enabled: z.boolean().nullable().optional(), standard_users: z.number().int().nullable().optional(), sync_session_max_clients: z.number().int().nullable().optional(), transcription_hours: z.number().int().nullable().optional()}); export const systemDomainSuperAdminSchema = z.object({base_url: z.string(), billing_limits: billingLimitsSchema.nullable().optional(), billing_tier: z.enum(["PAYGO", "PRO", "ENTERPRISE", "ENTERPRISE_LEGACY_2025", "PRO_LEGACY_2025"]).optional(), contract_end_date: z.string().nullable().optional(), country: z.string().nullable().optional(), creating_user_id: z.string().nullable().optional(), custom_terms: z.boolean().optional(), date_created: z.string().optional(), date_modified: z.string().optional(), deactivate_date: z.string().nullable().optional(), description: z.string().optional(), disable_ai_features: z.boolean().optional(), disable_billing_page: z.boolean().optional(), disable_cc_purchase: z.boolean().optional(), discount_percent: z.number().nullable().optional(), do_not_charge_edge_transcoder: z.boolean().optional(), do_not_charge_remote_proxies: z.boolean().optional(), do_not_charge_shield: z.boolean().optional(), do_not_trace_ai_usage: z.boolean().optional(), features: z.array(z.string()).optional(), freeze_date: z.string().nullable().optional(), has_preloaded_assets: z.boolean().optional(), id: z.string().optional(), industry: z.enum(["ADVERTISING_MARKETING_CREATIVE", "AUTOMOTIVE", "BROADCASTER_NETWORKS", "CONSTRUCTION_MANUFACTURING", "EDUCATION", "ENERGY_UTILITIES", "FAITH_RELIGIOUS_ORGS", "FINANCE", "GAME_STUDIOS_PUBLISHERS", "GOVERNMENT_PUBLIC_SECTOR", "HEALTHCARE", "HOSPITALITY_FITNESS_WELLNESS", "LIVE_PRODUCTION_EVENTS", "MEDIA_CONGLOMERATES", "NONPROFITS_NON_RELIGIOUS", "ONLINE_MEDIA", "PUBLISHERS_NEWSPAPERS", "TELECOMMUNICATIONS", "RETAIL_CONSUMER_GOODS", "SOFTWARE_TECHNOLOGY", "SPORTS_RIGHTS_LEAGUES", "STUDIOS_CONTENT_PRODUCERS", "OTHER"]).optional(), invoice_end_of_month: z.boolean().optional(), is_plg: z.boolean().optional(), is_template: z.boolean().optional(), licensed_user_billing: z.boolean().optional(), marketplace_customer_id: z.string().nullable().optional(), marketplace_entitlement_id: z.string().nullable().optional(), name: z.string(), ordway_customer_id: z.string().nullable().optional(), ordway_subscription_id: z.string().nullable().optional(), platform_name: z.string().optional(), price_list: z.string().nullable().optional(), referral_code: z.string().nullable().optional(), sales_force_id: z.string().nullable().optional(), status: z.enum(["ACTIVE", "WARNING", "FROZEN", "DEACTIVATED"]).optional(), stripe_id: z.string().nullable().optional(), type: z.enum(["TRIAL", "CUSTOMER", "PARTNER", "INTERNAL"]).optional(), warning_message: 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 }; /** * Create a new system domain * * POST /v1/system_domains/ */ export const createApiV1SystemDomains = async (args: CreateApiV1SystemDomainsArgs, options: CreateApiV1SystemDomainsOptions) => { const {baseUrl, 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['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/system_domains/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(systemDomainSuperAdminSchema, await res.json()) };