import {z} from 'zod' export type CountryDTO = {iso2Code?: string | undefined, code?: string | undefined, name?: string | undefined, countryId?: number | undefined, isDistributionCountry?: boolean | undefined, isReportingCountry?: boolean | undefined}; export type TrackMonetizationPolicy = {trackId?: number | undefined, policyId?: number | undefined}; export type TrackRetailDTO = {trackId?: number | undefined, clearedForSale?: boolean | undefined}; export type ReleaseRetailDTO = {releaseId?: number | undefined, priceTierIds?: Array | undefined, trackDefaultPriceTierId?: number | undefined, saleStartDate?: string | undefined, saleStartTime?: string | undefined, saleStartTimezone?: number | undefined, salePreOrderDate?: string | undefined, countriesIncluded?: Array | undefined, countriesExcluded?: Array | undefined, isLockedForDistribution?: boolean | undefined, isDolbyAtmosReadOnly?: boolean | undefined, monetizationPolicyIds?: Array | undefined, trackMonetizationPolicyIds?: Array | undefined, tracks?: Array | undefined, saleStartTimezoneId?: number | undefined, autoDistroOptIn?: boolean | undefined, priceTierId?: number | undefined, archivedAt?: string | undefined, showReleaseLevelPricing?: boolean | undefined}; export type CreateApiApiEnterprisesEnterpriseIdDistributionReleasesSettingsArgs = {enterpriseId: number, body: Array}; export type CreateApiApiEnterprisesEnterpriseIdDistributionReleasesSettingsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiEnterprisesEnterpriseIdDistributionReleasesSettingsResponse = 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 }; /** * POST /api/enterprises/{enterpriseId}/distribution/releases/settings */ export const createApiApiEnterprisesEnterpriseIdDistributionReleasesSettings = async (args: CreateApiApiEnterprisesEnterpriseIdDistributionReleasesSettingsArgs, options?: CreateApiApiEnterprisesEnterpriseIdDistributionReleasesSettingsOptions) => { const {baseUrl = "http://api.revelator.com", 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(/\/+$/, '')}/api/enterprises/${encodeURIComponent(String(args.enterpriseId))}/distribution/releases/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(createApiApiEnterprisesEnterpriseIdDistributionReleasesSettingsResponse, await res.json()) };