import {z} from 'zod' export type ProxyRefByName = {type?: string | undefined, name?: string | undefined}; export type ApiPlanPricingTier = {upTo?: number | undefined, pricePerCall?: number | undefined}; export type LimitProfileRef = {mode?: ('OFF' | 'PLAN') | undefined, planKey?: string | undefined}; export type ApiPlanDTO = {id?: string | undefined, referenceId?: string | undefined, prodPlanRefId?: string | undefined, productId?: string | undefined, name?: string | undefined, rateLimit?: number | undefined, quota?: number | undefined, rateLimitInterval?: ('SECOND' | 'MINUTE') | undefined, quotaInterval?: ('DAY' | 'WEEK' | 'MONTH') | undefined, approvalType?: ('AUTO' | 'MANUAL') | undefined, state?: ('ACTIVE' | 'RETIRED') | undefined, pricingType?: ('FREE' | 'FLAT' | 'METERED' | 'TIERED') | undefined, fee?: number | undefined, currency?: ('TURKISH_LIRA' | 'DOLLAR' | 'EURO') | undefined, billingPeriod?: ('MONTHLY' | 'ANNUALLY') | undefined, feePerCall?: number | undefined, tiers?: Array | undefined, exceedBehavior?: ('BLOCK' | 'CHARGE') | undefined, overageFee?: number | undefined, requestRateLimitRef?: LimitProfileRef | undefined, aiTokenBudgetRef?: LimitProfileRef | undefined, createdDate?: string | undefined, lastModifiedDate?: string | undefined, subscriptionCount?: number | undefined, requestRateLimitManaged?: boolean | undefined, limitsNotEnforced?: boolean | undefined, aiTokenBudgetName?: string | undefined, aiTokenBudgetCountsOnly?: boolean | undefined}; export type ProdProductPromoteRequestDTO = {referenceId?: string | undefined, nameDefault?: string | undefined, nameSecondary?: string | undefined, titleDefault?: string | undefined, titleSecondary?: string | undefined, descriptionDefault?: string | undefined, descriptionSecondary?: string | undefined, proxyRefs?: Array | undefined, plans?: Array | undefined, prodPortalId?: string | undefined}; export type CreateApiApiopsApiProductsPromoteArgs = {body: ProdProductPromoteRequestDTO}; export type CreateApiApiopsApiProductsPromoteOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiopsApiProductsPromoteResponse = z.string(); 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 }; /** * POST /apiops/api-products/promote */ export const createApiApiopsApiProductsPromote = async (args: CreateApiApiopsApiProductsPromoteArgs, options?: CreateApiApiopsApiProductsPromoteOptions) => { const {baseUrl = "http://167.86.118.166:32080", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/apiops/api-products/promote${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(createApiApiopsApiProductsPromoteResponse, await res.json()) };