import {z} from 'zod' export type PageFacet = {FacetId: number, Field?: string | undefined, Label: string, SortOrder: number, SortBy?: string | undefined}; export type BannerPageContent = {Id?: number | undefined, Name?: string | undefined, Title?: string | undefined, BannerType?: string | undefined, Width?: number | undefined, Height?: number | undefined, Link?: string | undefined, Filename?: string | undefined, AltText?: string | undefined, HTML?: string | undefined, Target?: string | undefined, IsTrackingEnabled?: boolean | undefined, WidgetId?: number | undefined, WidgetArgs?: string | undefined, Tags?: string | undefined, IsMobile?: boolean | undefined, DateFrom?: string | undefined, DateTo?: string | undefined, MobileBannerType?: string | undefined, MobileWidth?: number | undefined, MobileHeight?: number | undefined, MobileLink?: string | undefined, MobileFilename?: string | undefined, MobileAltText?: string | undefined, MobileHTML?: string | undefined, MobileTarget?: string | undefined, MobileIsTrackingEnabled?: boolean | undefined, MobileWidgetId?: number | undefined, MobileWidgetArgs?: string | undefined, SortOrder?: number | undefined, DisableHtmlEditor?: boolean | undefined, MobileDisableHtmlEditor?: boolean | undefined, IsTablet?: boolean | undefined, TabletBannerType?: string | undefined, TabletWidth?: number | undefined, TabletHeight?: number | undefined, TabletLink?: string | undefined, TabletFilename?: string | undefined, TabletAltText?: string | undefined, TabletHTML?: string | undefined, TabletTarget?: string | undefined, TabletIsTrackingEnabled?: boolean | undefined, TabletWidgetId?: number | undefined, TabletWidgetArgs?: string | undefined, TabletDisableHtmlEditor?: boolean | undefined}; export type LandingPageZoneConfig = {BannerId?: number | undefined, CustomValue?: BannerPageContent | undefined, DateFrom?: string | undefined, DateTo?: string | undefined, SortOrder?: number | undefined, TriggerXml?: string | undefined}; export type LandingPageContentConfig = {ZoneName?: string | undefined, ZoneConfig?: Array | undefined}; export type LandingPage = {PageId?: number | undefined, SyncGuid?: string | undefined, Name: string, Title?: string | undefined, MetaDescription?: string | undefined, MetaKeywords?: string | undefined, CustomUrl: string, Breadcrumb?: string | undefined, NarrowXml?: string | undefined, IsFacetOverride: boolean, IsIncludeProducts?: boolean | undefined, SortFieldId?: number | undefined, SortDirection?: string | undefined, SelectedFacets?: Array | undefined, PageLayoutId?: number | undefined, EnableFacetAutoOrdering?: boolean | undefined, Custom?: string | undefined, Tags?: string | undefined, CanonicalUrl?: string | undefined, PageType?: string | undefined, ContentConfigList?: Array | undefined, PageHeading?: string | undefined, CustomHtml?: string | undefined, Keywords?: string | undefined, ListName?: string | undefined, Notes?: string | undefined, CreateDate?: string | undefined, ModifyDate?: string | undefined, IsNoIndex?: boolean | undefined, IsNoFollow?: boolean | undefined, StartDate?: string | undefined, EndDate?: string | undefined, CustomSortList?: string | undefined}; export type CreateApiApiV11LandingPageBulkArgs = {'X-HawkSearch-ApiKey': string, body: Array}; export type CreateApiApiV11LandingPageBulkOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiV11LandingPageBulkResponse = 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 }; /** * Add multiple landing pages * * POST /api/v11/LandingPage/bulk */ export const createApiApiV11LandingPageBulk = async (args: CreateApiApiV11LandingPageBulkArgs, options?: CreateApiApiV11LandingPageBulkOptions) => { const {baseUrl = "https://indexing-dev.hawksearch.net", 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['X-HawkSearch-ApiKey'] != null) headers.set("X-HawkSearch-ApiKey", String(args['X-HawkSearch-ApiKey'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v11/LandingPage/bulk${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(createApiApiV11LandingPageBulkResponse, await res.json()) };