UNPKG

@valantic/spartacus-mock

Version:

This project offers you the possibility to mock the OCC Endpoints of your Composable Storefront (Spartacus). It uses the Mock Service Worker to mock the API calls.

124 lines (123 loc) 3.33 kB
import { HttpHandler } from 'msw'; import { Voucher } from '@spartacus/cart/base/root'; import { BackendConfig, Occ, OccConfig, Page as SpartacusPage } from '@spartacus/core'; import { TranslationResources } from '@spartacus/core/src/i18n/translation-resources'; declare module '@spartacus/core' { namespace Occ { interface Component { uuid?: string; linkName?: string; url?: string; target?: string; external?: boolean; contentPage?: string; contentPageLabelOrId?: string; [key: string]: string | boolean | object | undefined; } interface ContentSlot { slotUuid?: string; } } } export interface Pages { [key: string]: Occ.CMSPage; } export interface ActiveCartEntry { code: string; quantity: number; } export interface LocalStorageMockData { activeCartEntries: ActiveCartEntry[]; activeVouchers: Voucher[]; isGuestCheckout: boolean; } export declare const LOCAL_STORAGE_KEY = "spartacus\u26BF\u26BFmock-data"; export interface Page extends SpartacusPage { uid?: string; uuid?: string; } export interface ContentSlot extends Occ.ContentSlot { slotId?: string; slotUuid?: string; } export interface Component extends Occ.Component { uuid: string; [key: string]: string | boolean | object | undefined; } export interface CmsComponentAdditionalData { [key: string]: string | boolean | object | undefined; } export interface ContentPages { [key: string]: Page; } export interface Environment extends OccConfig { backend: BackendConfig; } export interface MockRequest { url: string; requestFunction: 'get' | 'post' | 'put' | 'delete' | 'head'; } export interface MockConfig { enableWorker: boolean; environment: Environment; enableDefaultData?: boolean; passThroughRequests?: MockRequest[]; handlers?: HttpHandler[]; contentPages?: ContentPages; productDetailPage?: Page; productCategoryPage?: Page; homePage?: Page; customSlots?: Occ.ContentSlot[]; translations?: TranslationResources; inclusionMode?: boolean; mockedRequests?: MockRequest[]; mockedPageIds?: string[]; quiet?: boolean; debug?: boolean; } export interface ProductSearchPageModifier { query?: string; pageSize?: number; sort?: string; currentPage?: number; } export interface SearchStateModifier { query?: string; activeSort?: string; } export interface FacetValueModifier extends SearchStateModifier { } export interface ProductReferenceListModifier { referenceType?: string; } export interface ImageModifier { width?: number; height?: number; } export interface PriceModifier { valueMin?: number; valueMax?: number; } export interface TranslationChunks { address?: object; common?: object; myAccount?: object; payment?: object; product?: object; pwa?: object; user?: object; video?: object; pdf?: object; cart?: object; importExport?: object; quickOrder?: object; savedCart?: object; wishlist?: object; checkout?: object; order?: object; bulkPricing?: object; productImageZoom?: object; storeFinder?: object; userAccount?: object; userProfile?: object; }