UNPKG

@builder.io/sdk

Version:

135 lines (134 loc) 4.81 kB
/// <reference types="node" /> import { BehaviorSubject, Observable, Observer } from 'rxjs'; import { Url } from 'url'; import 'whatwg-fetch'; import { Animator } from './classes/animator.class'; import { EventCapturer } from './classes/event-capturer.class'; import { nextTick } from './functions/next-tick.function'; export declare const isBrowser: boolean; export declare const isIframe: boolean; export interface ParamsMap { [key: string]: undefined | string | string[]; } export interface UserAttributes { urlPath?: string; queryString?: string | ParamsMap; device?: 'mobile' | 'tablet' | 'desktop'; location?: any; userAgent?: string; referrer?: string; entryMedium?: string; language?: string; browser?: string; cookie?: string; newVisitor?: boolean; operatingSystem?: string; } export interface GetContentOptions { queryString?: string | ParamsMap; userAttributes?: UserAttributes; limit?: number; cachebust?: boolean; simulateDate?: Date | string; publishedState?: 'published' | 'draft' | 'archived' | 'all'; filterDates?: boolean; includeTests?: boolean; dev?: boolean; initialContent?: any; } export declare type Class = { name: string; new (...args: any[]): any; }; export interface Input { name: string; friendlyName?: string; description?: string; defaultValue?: any; type: string; required?: boolean; subFields?: Input[]; helperText?: string; allowedFileTypes?: string[]; imageHeight?: number; imageWidth?: number; mediaHeight?: number; mediaWidth?: number; hideFromUI?: boolean; modelId?: string; enum?: string[]; } export interface Component { name: string; description?: string; image?: string; inputs?: Input[]; class?: Class; type?: 'angular' | 'webcomponent' | 'react'; } export declare function BuilderComponent(info?: Partial<Component>): (component: Class) => void; export declare class Builder { protected apiKey: string | null; static eventCapturer: EventCapturer | null; static animator: Animator; static components: Component[]; static nextTick: typeof nextTick; static loadGoogleFont(fontName: string): void; private static _editingPage; static isIframe: boolean; static isBrowser: boolean; static editingPage: boolean; static component(info?: Partial<Component>): (component: Class) => void; static readonly Component: typeof Builder.component; private eventsQueue; private throttledClearEventsQueue; private processEventsQueue(); protected isUsed: boolean; sessionId: string; readonly browserTrackingDisabled: boolean; canTrack: boolean; private canTrack$; editingMode: boolean; editingMode$: BehaviorSubject<boolean>; editingModel: string | null; private findParentElement(target, callback, checkElement?); private findBuilderParent(target); editingModel$: BehaviorSubject<string | null>; setUserAgent(userAgent: string): void; userAgent: string; track(eventName: string, properties?: any): void; getSessionId(): string; trackImpression(contentId: string, variationId?: string): void; autoTrack: boolean; private readonly isDevelopmentEnv; trackInteraction(contentId: string, variationId?: string, alreadyTrackedOne?: boolean, event?: MouseEvent): void; static overrideUserAttributes: Partial<UserAttributes>; component(info?: Partial<Component>): (component: Class) => void; constructor(apiKey?: string | null); private messageFrameLoaded(); private blockContentLoading; private bindMessageListeners(); observersByModelType: { [key: string]: Observer<any> | undefined; }; init(apiKey: string, canTrack?: boolean): this; getLocation(): Url; getUserAttributes(userAgent?: string): UserAttributes; setUserAttributes(options: object): void; private getContentQueue; private priorContentQueue; private loadFullStory(); queueGetContent(modelName: string, options?: GetContentOptions): Observable<any[]>; requestUrl(url: string): Promise<any>; env: 'production' | 'development'; readonly host: string; private flushGetContentQueue(usePastQueue?); private testCookiePrefix; private processResultsForTests(results); private getTestCookie(contentId); private cookieQueue; private setTestCookie(contentId, variationId); protected getCookie(name: string): any; protected setCookie(name: string, value: any, options?: any): void; getContent(modelName: string, options?: GetContentOptions): Observable<any[]>; }