declare module "backOff" { interface BackOffOptions { maxDelay?: number; numOfAttempts?: number; } export default function backOff(callback: () => Promise, { maxDelay, numOfAttempts }: BackOffOptions): Promise; } declare module "interface" { /** * The utility type can transform a series of tuple into a type union * For example: * ConvertTupleToUnion<['a', 'b'] | ['c', 'd']> * will infer to the union type 'a' | 'b' | 'c' | 'd' */ type ConvertTupleToUnion = T extends [ infer F, ...infer Res ] ? Res extends unknown[] ? F | ConvertTupleToUnion : never : never; export type integer = number; export type BusinessClientId = string; export interface PageViewPayload { url: string; } export interface ContentIds { contentIds?: string[]; contents?: Record[]; } export interface AddToCartPayload extends ContentIds { contentCategory?: string; currency?: string; value?: number; } export interface AddToWishlistPayload extends ContentIds { contentCategory?: string; currency?: string; value?: string; } export interface CompleteRegistrationPayload { contentName?: string; currency?: string; status?: boolean; value?: number; } export interface InitiateCheckoutPayload extends ContentIds { contentCategory?: string; currency?: string; numItems?: integer; value?: number; } export interface PurchasePayload extends ContentIds { contentName?: string; contentType?: string; currency?: string; numItems?: integer; value?: number; } export interface SearchPayload extends ContentIds { contentCategory?: string; currency?: string; searchString?: string; value?: number; } export interface StartTrialPayload { currency?: string; predictedLtv?: number; value?: number; } export interface SubscribePayload { currency?: string; predictedLtv?: number; value?: number; } export interface ViewContentPayload extends ContentIds { contentCategory?: string; contentName?: string; contentType?: string; currency?: string; value?: number; } export interface BuiltinEventPayloadMap { PageView: PageViewPayload; AddToCart: AddToCartPayload; AddToWishList: AddToWishlistPayload; Contact: void; CompleteRegistration: CompleteRegistrationPayload; CustomizeProduct: void; Donate: void; FindLocation: void; InitiateCheckout: InitiateCheckoutPayload; Load: void; Purchase: PurchasePayload; Schedule: void; Search: SearchPayload; StartTrial: StartTrialPayload; SubmitApplication: void; Subscribe: SubscribePayload; ViewContent: ViewContentPayload; } export type BuiltinEventParcelDealer = { [P in keyof BuiltinEventPayloadMap]: (payload: unknown) => BuiltinEventPayloadMap[P]; }; type BuiltinEventNames = keyof BuiltinEventPayloadMap; type InitCommandParam = [BusinessClientId]; type TrackCommandParam = [E, Partial] | [E]; interface EntryInputTransformMap { entryInput: T; parcel: E; } export interface InitialParcel { createdAt: string; businessClientId: string; } export interface TrackingParcel { id: string; createdAt: string; type: BuiltinEventNames; payload: Partial; } export interface AdTrackingCommandParamMap { init: EntryInputTransformMap; track: EntryInputTransformMap, TrackingParcel>; } export type AdTrackingCommandTupleParamMap = { [P in keyof AdTrackingCommandParamMap]: [ P, ...AdTrackingCommandParamMap[P]['entryInput'] ]; }; type AdTrackingCommands = keyof AdTrackingCommandParamMap; export type CommandArgs = C extends 'init' ? InitCommandParam : C extends 'track' ? TrackCommandParam : never; export type CommandWithParamTuple = [ AdTrackingCommands, ...ConvertTupleToUnion[] ]; export interface DcardADTrackingEntry { (command: C, ...args: CommandArgs): void; queue: CommandWithParamTuple[]; } export type ParcelUnion = AdTrackingCommandParamMap[keyof AdTrackingCommandParamMap]['parcel']; interface TestingTrackUrlMetaData { times: number; } interface TestingTrackUrls { [url: string]: TestingTrackUrlMetaData; } interface TestingTrackFunctionMetaData { [name: string]: TestingTrackUrls; } global { interface Window { dadk?: DcardADTrackingEntry; sdkTestingTrack?: TestingTrackFunctionMetaData; sdkTestingBackOffPromise?: Promise[]; dadkUrlStateListenerInitiated?: boolean; } namespace NodeJS { interface ProcessEnv { OUTDATED_SDK_FILE_URL: string; SDK_FILE_URL: string; } } } } declare module "minifiedLodashUtilities" { export const isPlainObject: (x: unknown) => x is T; export function every(list: T[], predicate: (value: T, index: number, theList: T[]) => boolean): boolean; export function toPairs(collection: T): [keyof T, T[keyof T]][]; } declare module "typeGuard" { import { AdTrackingCommandTupleParamMap, InitialParcel, TrackingParcel } from "interface"; export function isTrackCommandTuple(param: unknown): param is AdTrackingCommandTupleParamMap['track']; export function isInitCommandTuple(param: unknown): param is AdTrackingCommandTupleParamMap['init']; export function isInitialParcel(parcel: unknown): parcel is InitialParcel; export function isTrackingParcel(parcel: unknown): parcel is TrackingParcel; export function isStringArray(data: unknown): data is string[]; export function isFinite(data: unknown): data is number; export function isRecordArray(data: unknown): data is Record[]; export function isObjectKey>(data: T, key: string): key is K; } declare module "storage" { export default function getAndSetDeviceId(): string; } declare module "validator" { import * as Types from "interface"; export function makeAddToCartPayload(source: Types.AddToCartPayload): Types.AddToCartPayload; export function makeAddToWishlistPayload(source: Types.AddToWishlistPayload): Types.AddToWishlistPayload; export function makeCompleteRegistrationPayload(source: Types.CompleteRegistrationPayload): Types.CompleteRegistrationPayload; export function makeInitiateCheckoutPayload(source: Types.InitiateCheckoutPayload): Types.InitiateCheckoutPayload; export function makePurchasePayload(source: Types.PurchasePayload): Types.PurchasePayload; export function makeSearchPayload(source: Types.SearchPayload): Types.SearchPayload; export function makeStartTrialPayload(source: Types.StartTrialPayload): Types.StartTrialPayload; export function makeSubscribePayload(source: Types.SubscribePayload): Types.SubscribePayload; export function makeViewContentPayload(source: Types.ViewContentPayload): Types.ViewContentPayload; export function defaultMakePayload(): Record; } declare module "parcelDealer" { import { BuiltinEventParcelDealer as BuiltinEventParcelDealerType } from "interface"; const BuiltinEventParcelDealer: BuiltinEventParcelDealerType; export default BuiltinEventParcelDealer; } declare module "entry" { import { DcardADTrackingEntry } from "interface"; export function deliverQueuedCommands(): void; export const dcardAdTrackingEntry: DcardADTrackingEntry; } declare module "urlStateListener" { function initUrlStateListener(callback: (url: string) => void): void; export default initUrlStateListener; } declare module "index" { import { dcardAdTrackingEntry } from "entry"; export default dcardAdTrackingEntry; } declare module "load_sdk" { }