import {z} from 'zod' export type BudgetNotificationConfiguration = {org_id: string, paused: boolean, total_budget_amount: number, warn_at_amount: number}; export type CrossLinkField = {alias?: (string | null) | undefined, name: string}; export type CrossLink = {fields?: Array | undefined, name: string, url: string}; export type DataRetentionDefaults = {default?: number | undefined, logs?: number | undefined, metrics?: number | undefined, profiles?: number | undefined, traces?: number | undefined}; export type DomainConfig = {allow_all_users?: boolean | undefined, allowed_emails?: Array | undefined, created_at?: number | undefined, domain: string, enabled?: boolean | undefined, updated_at?: number | undefined}; export type DomainManagementConfig = {blocked_domains?: Array | undefined, blocked_emails?: Array | undefined, domains: Array, enabled: boolean, updated_at: number}; export type DomainOrgMapping = {base_role: string, create_missing_roles?: boolean | undefined, domain: string, org_id: string, role_claim_name?: (string | null) | undefined}; export type CreateApiApiOrgIdSettingsArgs = {org_id: string, body: {ai_rca_thread_tool_output?: (boolean | null) | undefined, budget_config?: (Array | null) | undefined, claim_parser_function?: (string | null) | undefined, cross_links?: (Array | null) | undefined, dark_mode_theme_color?: (string | null) | undefined, data_retention?: (DataRetentionDefaults | null) | undefined, domain_management_config?: (DomainManagementConfig | null) | undefined, domain_org_mappings?: (Array | null) | undefined, enable_streaming_search?: (boolean | null) | undefined, enforce_allowed_orgs_only?: (boolean | null) | undefined, light_mode_theme_color?: (string | null) | undefined, max_series_per_query?: (number | null) | undefined, min_auto_refresh_interval?: (number | null) | undefined, red_insights_enabled?: (boolean | null) | undefined, scrape_interval?: (number | null) | undefined, span_id_field_name?: (string | null) | undefined, streaming_aggregation_enabled?: (boolean | null) | undefined, toggle_ingestion_logs?: (boolean | null) | undefined, trace_id_field_name?: (string | null) | undefined, usage_stream_enabled?: (boolean | null) | undefined}}; export type CreateApiApiOrgIdSettingsOptions = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiOrgIdSettingsResponse = z.object({}); 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 settings * * POST /api/{org_id}/settings */ export const createApiApiOrgIdSettings = async (args: CreateApiApiOrgIdSettingsArgs, options: CreateApiApiOrgIdSettingsOptions) => { const {baseUrl, fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/api/${encodeURIComponent(String(args.org_id))}/settings${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(createApiApiOrgIdSettingsResponse, await res.json()) };