@walkeros/core 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -0
- package/dist/index.d.mts +1122 -0
- package/dist/index.d.ts +1122 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core collector configuration interface
|
|
3
|
+
*/
|
|
4
|
+
interface Config$4 {
|
|
5
|
+
/** Run in dry mode without executing events */
|
|
6
|
+
dryRun: boolean;
|
|
7
|
+
/** Whether to run collector automatically */
|
|
8
|
+
run?: boolean;
|
|
9
|
+
/** Initial consent state */
|
|
10
|
+
consent?: Consent;
|
|
11
|
+
/** Initial user data */
|
|
12
|
+
user?: User;
|
|
13
|
+
/** Version for event tagging */
|
|
14
|
+
tagging: number;
|
|
15
|
+
/** Initial global properties */
|
|
16
|
+
globals?: Properties;
|
|
17
|
+
/** Static global properties even on a new run */
|
|
18
|
+
globalsStatic: Properties;
|
|
19
|
+
/** Static session data even on a new run */
|
|
20
|
+
sessionStatic: Partial<SessionData>;
|
|
21
|
+
/** Destination configurations */
|
|
22
|
+
destinations?: InitDestinations;
|
|
23
|
+
/** Initial custom properties */
|
|
24
|
+
custom?: Properties;
|
|
25
|
+
/** Enable verbose logging */
|
|
26
|
+
verbose: boolean;
|
|
27
|
+
/** Error handler */
|
|
28
|
+
onError?: Error;
|
|
29
|
+
/** Log handler */
|
|
30
|
+
onLog?: Log;
|
|
31
|
+
}
|
|
32
|
+
type InitConfig$1 = Partial<Config$4>;
|
|
33
|
+
interface SessionData extends Properties {
|
|
34
|
+
isStart: boolean;
|
|
35
|
+
storage: boolean;
|
|
36
|
+
id?: string;
|
|
37
|
+
start?: number;
|
|
38
|
+
marketing?: true;
|
|
39
|
+
updated?: number;
|
|
40
|
+
isNew?: boolean;
|
|
41
|
+
device?: string;
|
|
42
|
+
count?: number;
|
|
43
|
+
runs?: number;
|
|
44
|
+
}
|
|
45
|
+
interface Sources {
|
|
46
|
+
[id: string]: CollectorSource;
|
|
47
|
+
}
|
|
48
|
+
interface Destinations$1 {
|
|
49
|
+
[id: string]: Instance$1;
|
|
50
|
+
}
|
|
51
|
+
interface CollectorSource {
|
|
52
|
+
type: string;
|
|
53
|
+
mapping?: unknown;
|
|
54
|
+
settings?: Record<string, unknown>;
|
|
55
|
+
elb?: AnyFunction;
|
|
56
|
+
}
|
|
57
|
+
type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' | 'elb' | 'globals' | 'hook' | 'init' | 'link' | 'run' | 'user' | 'walker' | string;
|
|
58
|
+
interface Instance$2 {
|
|
59
|
+
push: Fn$2;
|
|
60
|
+
allowed: boolean;
|
|
61
|
+
config: Config$4;
|
|
62
|
+
consent: Consent;
|
|
63
|
+
count: number;
|
|
64
|
+
custom: Properties;
|
|
65
|
+
sources: Sources;
|
|
66
|
+
destinations: Destinations$1;
|
|
67
|
+
globals: Properties;
|
|
68
|
+
group: string;
|
|
69
|
+
hooks: Functions;
|
|
70
|
+
on: OnConfig;
|
|
71
|
+
queue: Events;
|
|
72
|
+
round: number;
|
|
73
|
+
session: undefined | SessionData;
|
|
74
|
+
timing: number;
|
|
75
|
+
user: User;
|
|
76
|
+
version: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type collector_CollectorSource = CollectorSource;
|
|
80
|
+
type collector_CommandType = CommandType;
|
|
81
|
+
type collector_SessionData = SessionData;
|
|
82
|
+
type collector_Sources = Sources;
|
|
83
|
+
declare namespace collector {
|
|
84
|
+
export type { collector_CollectorSource as CollectorSource, collector_CommandType as CommandType, Config$4 as Config, Destinations$1 as Destinations, InitConfig$1 as InitConfig, Instance$2 as Instance, collector_SessionData as SessionData, collector_Sources as Sources };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface Contract$1 {
|
|
88
|
+
version: string;
|
|
89
|
+
globals: Globals;
|
|
90
|
+
context: Contexts;
|
|
91
|
+
entities: Entities$1;
|
|
92
|
+
}
|
|
93
|
+
interface Globals {
|
|
94
|
+
[name: string]: Global;
|
|
95
|
+
}
|
|
96
|
+
interface Contexts {
|
|
97
|
+
[name: string]: Context$2;
|
|
98
|
+
}
|
|
99
|
+
interface Entities$1 {
|
|
100
|
+
[name: string]: Entity$1;
|
|
101
|
+
}
|
|
102
|
+
interface Properties$2 {
|
|
103
|
+
[name: string]: Property$2;
|
|
104
|
+
}
|
|
105
|
+
interface Global extends Property$2 {
|
|
106
|
+
}
|
|
107
|
+
interface Context$2 extends Property$2 {
|
|
108
|
+
}
|
|
109
|
+
interface Entity$1 {
|
|
110
|
+
data: Properties$2;
|
|
111
|
+
actions: Actions;
|
|
112
|
+
}
|
|
113
|
+
interface Actions {
|
|
114
|
+
[name: string]: Action;
|
|
115
|
+
}
|
|
116
|
+
interface Action {
|
|
117
|
+
trigger?: Trigger;
|
|
118
|
+
}
|
|
119
|
+
type Trigger = string;
|
|
120
|
+
interface Property$2 {
|
|
121
|
+
type?: PropertyType$1;
|
|
122
|
+
required?: boolean;
|
|
123
|
+
values?: PropertyValues;
|
|
124
|
+
}
|
|
125
|
+
type PropertyType$1 = 'boolean' | 'string' | 'number';
|
|
126
|
+
type PropertyValues = Array<Property>;
|
|
127
|
+
|
|
128
|
+
type data_Action = Action;
|
|
129
|
+
type data_Actions = Actions;
|
|
130
|
+
type data_Contexts = Contexts;
|
|
131
|
+
type data_Global = Global;
|
|
132
|
+
type data_Globals = Globals;
|
|
133
|
+
type data_PropertyValues = PropertyValues;
|
|
134
|
+
type data_Trigger = Trigger;
|
|
135
|
+
declare namespace data {
|
|
136
|
+
export type { data_Action as Action, data_Actions as Actions, Context$2 as Context, data_Contexts as Contexts, Contract$1 as Contract, Entities$1 as Entities, Entity$1 as Entity, data_Global as Global, data_Globals as Globals, Properties$2 as Properties, Property$2 as Property, PropertyType$1 as PropertyType, data_PropertyValues as PropertyValues, data_Trigger as Trigger };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface Instance$1<Settings = unknown, Mapping = unknown> {
|
|
140
|
+
config: Config$3<Settings, Mapping>;
|
|
141
|
+
queue?: Events;
|
|
142
|
+
dlq?: DLQ;
|
|
143
|
+
type?: string;
|
|
144
|
+
init?: InitFn<Settings, Mapping>;
|
|
145
|
+
push: PushFn<Settings, Mapping>;
|
|
146
|
+
pushBatch?: PushBatchFn<Settings, Mapping>;
|
|
147
|
+
}
|
|
148
|
+
interface Config$3<Settings = unknown, Mapping = unknown> {
|
|
149
|
+
consent?: Consent;
|
|
150
|
+
settings?: Settings;
|
|
151
|
+
data?: Value | Values;
|
|
152
|
+
dryRun?: boolean;
|
|
153
|
+
id?: string;
|
|
154
|
+
init?: boolean;
|
|
155
|
+
loadScript?: boolean;
|
|
156
|
+
mapping?: Rules<Rule<Mapping>>;
|
|
157
|
+
on?: Config$2;
|
|
158
|
+
policy?: Policy;
|
|
159
|
+
queue?: boolean;
|
|
160
|
+
verbose?: boolean;
|
|
161
|
+
wrapper?: Config;
|
|
162
|
+
onError?: Error;
|
|
163
|
+
onLog?: Log;
|
|
164
|
+
}
|
|
165
|
+
type PartialConfig<Settings = unknown, Mapping = unknown> = Config$3<Partial<Settings> | Settings, Partial<Mapping> | Mapping>;
|
|
166
|
+
interface Policy {
|
|
167
|
+
[key: string]: Value;
|
|
168
|
+
}
|
|
169
|
+
type Init$1 = Partial<Omit<Instance$1, 'push'>> & Pick<Instance$1, 'push'>;
|
|
170
|
+
type InitDestination<Settings = unknown, Mapping = unknown> = Omit<Instance$1<Settings, Mapping>, 'config'> & {
|
|
171
|
+
config?: Config$3<Settings, Mapping>;
|
|
172
|
+
};
|
|
173
|
+
interface InitDestinations {
|
|
174
|
+
[key: string]: InitDestination<any, any>;
|
|
175
|
+
}
|
|
176
|
+
interface Destinations {
|
|
177
|
+
[key: string]: Instance$1;
|
|
178
|
+
}
|
|
179
|
+
interface Context$1<Settings = unknown, Mapping = unknown> {
|
|
180
|
+
collector: Instance$2;
|
|
181
|
+
config: Config$3<Settings, Mapping>;
|
|
182
|
+
data?: Data$1;
|
|
183
|
+
wrap: Wrap;
|
|
184
|
+
}
|
|
185
|
+
interface PushContext<Settings = unknown, Mapping = unknown> extends Context$1<Settings, Mapping> {
|
|
186
|
+
mapping?: Rule<Mapping>;
|
|
187
|
+
}
|
|
188
|
+
interface PushBatchContext<Settings = unknown, Mapping = unknown> extends Context$1<Settings, Mapping> {
|
|
189
|
+
mapping?: Rule<Mapping>;
|
|
190
|
+
}
|
|
191
|
+
type InitFn<Settings, Mapping> = (context: Context$1<Settings, Mapping>) => PromiseOrValue<void | false | Config$3<Settings, Mapping>>;
|
|
192
|
+
type PushFn<Settings, Mapping> = (event: Event, context: PushContext<Settings, Mapping>) => PromiseOrValue<void>;
|
|
193
|
+
type PushBatchFn<Settings, Mapping> = (batch: Batch<Mapping>, context: PushBatchContext<Settings, Mapping>) => void;
|
|
194
|
+
type PushEvent<Mapping = unknown> = {
|
|
195
|
+
event: Event;
|
|
196
|
+
mapping?: Rule<Mapping>;
|
|
197
|
+
};
|
|
198
|
+
type PushEvents<Mapping = unknown> = Array<PushEvent<Mapping>>;
|
|
199
|
+
interface Batch<Mapping> {
|
|
200
|
+
key: string;
|
|
201
|
+
events: Events;
|
|
202
|
+
data: Array<Data$1>;
|
|
203
|
+
mapping?: Rule<Mapping>;
|
|
204
|
+
}
|
|
205
|
+
type Data$1 = Property | undefined | Array<Property | undefined>;
|
|
206
|
+
type Ref = {
|
|
207
|
+
id: string;
|
|
208
|
+
destination: Instance$1;
|
|
209
|
+
};
|
|
210
|
+
type Push = {
|
|
211
|
+
queue?: Events;
|
|
212
|
+
error?: unknown;
|
|
213
|
+
};
|
|
214
|
+
type DLQ = Array<[Event, unknown]>;
|
|
215
|
+
type Result$1 = {
|
|
216
|
+
successful: Array<Ref>;
|
|
217
|
+
queued: Array<Ref>;
|
|
218
|
+
failed: Array<Ref>;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type destination_Batch<Mapping> = Batch<Mapping>;
|
|
222
|
+
type destination_DLQ = DLQ;
|
|
223
|
+
type destination_Destinations = Destinations;
|
|
224
|
+
type destination_InitDestination<Settings = unknown, Mapping = unknown> = InitDestination<Settings, Mapping>;
|
|
225
|
+
type destination_InitDestinations = InitDestinations;
|
|
226
|
+
type destination_InitFn<Settings, Mapping> = InitFn<Settings, Mapping>;
|
|
227
|
+
type destination_PartialConfig<Settings = unknown, Mapping = unknown> = PartialConfig<Settings, Mapping>;
|
|
228
|
+
type destination_Policy = Policy;
|
|
229
|
+
type destination_Push = Push;
|
|
230
|
+
type destination_PushBatchContext<Settings = unknown, Mapping = unknown> = PushBatchContext<Settings, Mapping>;
|
|
231
|
+
type destination_PushBatchFn<Settings, Mapping> = PushBatchFn<Settings, Mapping>;
|
|
232
|
+
type destination_PushContext<Settings = unknown, Mapping = unknown> = PushContext<Settings, Mapping>;
|
|
233
|
+
type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
234
|
+
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
235
|
+
type destination_PushFn<Settings, Mapping> = PushFn<Settings, Mapping>;
|
|
236
|
+
type destination_Ref = Ref;
|
|
237
|
+
declare namespace destination {
|
|
238
|
+
export type { destination_Batch as Batch, Config$3 as Config, Context$1 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Init$1 as Init, destination_InitDestination as InitDestination, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, Instance$1 as Instance, destination_PartialConfig as PartialConfig, destination_Policy as Policy, destination_Push as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result };
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
interface EventFn<R = Promise<PushResult>> {
|
|
242
|
+
(partialEvent: DeepPartialEvent): R;
|
|
243
|
+
(event: string): R;
|
|
244
|
+
(event: string, data: Properties): R;
|
|
245
|
+
}
|
|
246
|
+
interface Fn$2<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, WalkerCommands<R, Config> {
|
|
247
|
+
}
|
|
248
|
+
interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
|
|
249
|
+
(event: 'walker config', config: Partial<Config>): R;
|
|
250
|
+
(event: 'walker consent', consent: Consent): R;
|
|
251
|
+
(event: 'walker destination', destination: Init$1 | Instance$1, config?: Config$3): R;
|
|
252
|
+
<K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
|
|
253
|
+
(event: 'walker on', type: Types, rules: SingleOrArray<Options>): R;
|
|
254
|
+
(event: 'walker user', user: User): R;
|
|
255
|
+
(event: 'walker run', runState: {
|
|
256
|
+
consent?: Consent;
|
|
257
|
+
user?: User;
|
|
258
|
+
globals?: Properties;
|
|
259
|
+
custom?: Properties;
|
|
260
|
+
}): R;
|
|
261
|
+
}
|
|
262
|
+
type Event$1<R = Promise<PushResult>> = (partialEvent: DeepPartialEvent) => R;
|
|
263
|
+
type PushData<Config = unknown> = DeepPartial<Config> | Consent | User | Properties;
|
|
264
|
+
interface PushResult extends Result$1 {
|
|
265
|
+
event?: Event;
|
|
266
|
+
ok: boolean;
|
|
267
|
+
}
|
|
268
|
+
type Layer = Array<IArguments | DeepPartialEvent | unknown[]>;
|
|
269
|
+
interface RegisterDestination<Destination, Config> {
|
|
270
|
+
(event: 'walker destination', destination: Destination, config?: Config): Promise<PushResult>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
type elb_EventFn<R = Promise<PushResult>> = EventFn<R>;
|
|
274
|
+
type elb_Layer = Layer;
|
|
275
|
+
type elb_PushData<Config = unknown> = PushData<Config>;
|
|
276
|
+
type elb_PushResult = PushResult;
|
|
277
|
+
type elb_RegisterDestination<Destination, Config> = RegisterDestination<Destination, Config>;
|
|
278
|
+
type elb_WalkerCommands<R = Promise<PushResult>, Config = unknown> = WalkerCommands<R, Config>;
|
|
279
|
+
declare namespace elb {
|
|
280
|
+
export type { Event$1 as Event, elb_EventFn as EventFn, Fn$2 as Fn, elb_Layer as Layer, elb_PushData as PushData, elb_PushResult as PushResult, elb_RegisterDestination as RegisterDestination, elb_WalkerCommands as WalkerCommands };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
type Error = (error: unknown, state?: unknown) => void;
|
|
284
|
+
type Log = (message: string, verbose?: boolean) => void;
|
|
285
|
+
|
|
286
|
+
type handler_Error = Error;
|
|
287
|
+
type handler_Log = Log;
|
|
288
|
+
declare namespace handler {
|
|
289
|
+
export type { handler_Error as Error, handler_Log as Log };
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
|
|
293
|
+
type Functions = {
|
|
294
|
+
[key: string]: AnyFunction$1;
|
|
295
|
+
};
|
|
296
|
+
interface Parameter<P extends unknown[], R> {
|
|
297
|
+
fn: (...args: P) => R;
|
|
298
|
+
result?: R;
|
|
299
|
+
}
|
|
300
|
+
type HookFn<T extends AnyFunction$1> = (params: Parameter<Parameters<T>, ReturnType<T>>, ...args: Parameters<T>) => ReturnType<T>;
|
|
301
|
+
|
|
302
|
+
type hooks_Functions = Functions;
|
|
303
|
+
type hooks_HookFn<T extends AnyFunction$1> = HookFn<T>;
|
|
304
|
+
declare namespace hooks {
|
|
305
|
+
export type { AnyFunction$1 as AnyFunction, hooks_Functions as Functions, hooks_HookFn as HookFn };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
interface Rules<T = Rule> {
|
|
309
|
+
[entity: string]: Record<string, T | Array<T>> | undefined;
|
|
310
|
+
}
|
|
311
|
+
interface Rule<Settings = unknown> {
|
|
312
|
+
batch?: number;
|
|
313
|
+
batchFn?: (destination: Instance$1, collector: Instance$2) => void;
|
|
314
|
+
batched?: Batch<Settings>;
|
|
315
|
+
condition?: Condition;
|
|
316
|
+
consent?: Consent;
|
|
317
|
+
settings?: Settings;
|
|
318
|
+
data?: Data;
|
|
319
|
+
ignore?: boolean;
|
|
320
|
+
name?: string;
|
|
321
|
+
}
|
|
322
|
+
interface Result {
|
|
323
|
+
eventMapping?: Rule;
|
|
324
|
+
mappingKey?: string;
|
|
325
|
+
}
|
|
326
|
+
type Data = Value | Values;
|
|
327
|
+
type Value = ValueType | Array<ValueType>;
|
|
328
|
+
type Values = Array<Value>;
|
|
329
|
+
type ValueType = string | ValueConfig;
|
|
330
|
+
interface ValueConfig {
|
|
331
|
+
condition?: Condition;
|
|
332
|
+
consent?: Consent;
|
|
333
|
+
fn?: Fn$1;
|
|
334
|
+
key?: string;
|
|
335
|
+
loop?: Loop;
|
|
336
|
+
map?: Map;
|
|
337
|
+
set?: Value[];
|
|
338
|
+
validate?: Validate;
|
|
339
|
+
value?: PropertyType;
|
|
340
|
+
}
|
|
341
|
+
type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$2) => PromiseOrValue<boolean>;
|
|
342
|
+
type Fn$1 = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
|
|
343
|
+
type Loop = [Value, Value];
|
|
344
|
+
type Map = {
|
|
345
|
+
[key: string]: Value;
|
|
346
|
+
};
|
|
347
|
+
interface Options$1 {
|
|
348
|
+
consent?: Consent;
|
|
349
|
+
collector?: Instance$2;
|
|
350
|
+
props?: unknown;
|
|
351
|
+
}
|
|
352
|
+
type Validate = (value?: unknown) => PromiseOrValue<boolean>;
|
|
353
|
+
|
|
354
|
+
type mapping_Condition = Condition;
|
|
355
|
+
type mapping_Data = Data;
|
|
356
|
+
type mapping_Loop = Loop;
|
|
357
|
+
type mapping_Map = Map;
|
|
358
|
+
type mapping_Result = Result;
|
|
359
|
+
type mapping_Rule<Settings = unknown> = Rule<Settings>;
|
|
360
|
+
type mapping_Rules<T = Rule> = Rules<T>;
|
|
361
|
+
type mapping_Validate = Validate;
|
|
362
|
+
type mapping_Value = Value;
|
|
363
|
+
type mapping_ValueConfig = ValueConfig;
|
|
364
|
+
type mapping_ValueType = ValueType;
|
|
365
|
+
type mapping_Values = Values;
|
|
366
|
+
declare namespace mapping {
|
|
367
|
+
export type { mapping_Condition as Condition, mapping_Data as Data, Fn$1 as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Result as Result, mapping_Rule as Rule, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
type Config$2 = {
|
|
371
|
+
consent?: Array<ConsentConfig>;
|
|
372
|
+
ready?: Array<ReadyConfig>;
|
|
373
|
+
run?: Array<RunConfig>;
|
|
374
|
+
session?: Array<SessionConfig>;
|
|
375
|
+
};
|
|
376
|
+
type Types = keyof Config$2;
|
|
377
|
+
type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
|
|
378
|
+
interface ConsentConfig {
|
|
379
|
+
[key: string]: ConsentFn;
|
|
380
|
+
}
|
|
381
|
+
type ConsentFn = (collector: Instance$2, consent: Consent) => void;
|
|
382
|
+
type ReadyConfig = ReadyFn;
|
|
383
|
+
type ReadyFn = (collector: Instance$2) => void;
|
|
384
|
+
type RunConfig = RunFn;
|
|
385
|
+
type RunFn = (collector: Instance$2) => void;
|
|
386
|
+
type SessionConfig = SessionFn;
|
|
387
|
+
type SessionFn = (collector: Instance$2, session?: unknown) => void;
|
|
388
|
+
interface OnConfig {
|
|
389
|
+
consent?: ConsentConfig[];
|
|
390
|
+
ready?: ReadyConfig[];
|
|
391
|
+
run?: RunConfig[];
|
|
392
|
+
session?: SessionConfig[];
|
|
393
|
+
[key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
type on_ConsentConfig = ConsentConfig;
|
|
397
|
+
type on_ConsentFn = ConsentFn;
|
|
398
|
+
type on_OnConfig = OnConfig;
|
|
399
|
+
type on_Options = Options;
|
|
400
|
+
type on_ReadyConfig = ReadyConfig;
|
|
401
|
+
type on_ReadyFn = ReadyFn;
|
|
402
|
+
type on_RunConfig = RunConfig;
|
|
403
|
+
type on_RunFn = RunFn;
|
|
404
|
+
type on_SessionConfig = SessionConfig;
|
|
405
|
+
type on_SessionFn = SessionFn;
|
|
406
|
+
type on_Types = Types;
|
|
407
|
+
declare namespace on {
|
|
408
|
+
export type { Config$2 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, on_OnConfig as OnConfig, on_Options as Options, on_ReadyConfig as ReadyConfig, on_ReadyFn as ReadyFn, on_RunConfig as RunConfig, on_RunFn as RunFn, on_SessionConfig as SessionConfig, on_SessionFn as SessionFn, on_Types as Types };
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
interface Context {
|
|
412
|
+
city?: string;
|
|
413
|
+
country?: string;
|
|
414
|
+
encoding?: string;
|
|
415
|
+
hash?: string;
|
|
416
|
+
ip?: string;
|
|
417
|
+
language?: string;
|
|
418
|
+
origin?: string;
|
|
419
|
+
region?: string;
|
|
420
|
+
userAgent?: string;
|
|
421
|
+
[key: string]: string | undefined;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
type request_Context = Context;
|
|
425
|
+
declare namespace request {
|
|
426
|
+
export type { request_Context as Context };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
type Contracts = Array<Contract>;
|
|
430
|
+
type Contract = {
|
|
431
|
+
[entity: string]: {
|
|
432
|
+
[action: string]: Properties$1;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
type Properties$1 = {
|
|
436
|
+
[key: string]: Property$1 | undefined;
|
|
437
|
+
};
|
|
438
|
+
type Property$1 = {
|
|
439
|
+
allowedKeys?: string[];
|
|
440
|
+
allowedValues?: unknown[];
|
|
441
|
+
maxLength?: number;
|
|
442
|
+
max?: number;
|
|
443
|
+
min?: number;
|
|
444
|
+
required?: boolean;
|
|
445
|
+
schema?: Properties$1;
|
|
446
|
+
strict?: boolean;
|
|
447
|
+
type?: string;
|
|
448
|
+
validate?: (value: unknown, key: string, event: AnyObject) => Property;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
type schema_Contract = Contract;
|
|
452
|
+
type schema_Contracts = Contracts;
|
|
453
|
+
declare namespace schema {
|
|
454
|
+
export type { schema_Contract as Contract, schema_Contracts as Contracts, Properties$1 as Properties, Property$1 as Property };
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
interface Config$1 {
|
|
458
|
+
type: string;
|
|
459
|
+
id?: string;
|
|
460
|
+
disabled?: boolean;
|
|
461
|
+
settings: AnyObject;
|
|
462
|
+
onError?: AnyFunction;
|
|
463
|
+
}
|
|
464
|
+
type InitConfig = Partial<Config$1>;
|
|
465
|
+
interface Init<T extends Config$1 = Config$1, E = AnyFunction> {
|
|
466
|
+
(collector: Instance$2, config: T): CreateSource<T, E> | Promise<CreateSource<T, E>>;
|
|
467
|
+
}
|
|
468
|
+
interface CreateSource<T extends Config$1 = Config$1, E = AnyFunction> {
|
|
469
|
+
source?: Instance<T>;
|
|
470
|
+
elb?: E;
|
|
471
|
+
}
|
|
472
|
+
interface Instance<T extends Config$1 = Config$1> {
|
|
473
|
+
type: string;
|
|
474
|
+
config: T;
|
|
475
|
+
collector: Instance$2;
|
|
476
|
+
destroy?(): void | Promise<void>;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
type source_CreateSource<T extends Config$1 = Config$1, E = AnyFunction> = CreateSource<T, E>;
|
|
480
|
+
type source_Init<T extends Config$1 = Config$1, E = AnyFunction> = Init<T, E>;
|
|
481
|
+
type source_InitConfig = InitConfig;
|
|
482
|
+
type source_Instance<T extends Config$1 = Config$1> = Instance<T>;
|
|
483
|
+
declare namespace source {
|
|
484
|
+
export type { Config$1 as Config, source_CreateSource as CreateSource, source_Init as Init, source_InitConfig as InitConfig, source_Instance as Instance };
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
type AnyObject<T = unknown> = Record<string, T>;
|
|
488
|
+
type Elb = globalThis.WalkerOS.Elb;
|
|
489
|
+
type AnyFunction = (...args: unknown[]) => unknown;
|
|
490
|
+
type SingleOrArray<T> = T | Array<T>;
|
|
491
|
+
declare global {
|
|
492
|
+
namespace WalkerOS {
|
|
493
|
+
interface Elb extends Fn$2 {
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
type Events = Array<Event>;
|
|
498
|
+
type PartialEvent = Partial<Event>;
|
|
499
|
+
type DeepPartialEvent = DeepPartial<Event>;
|
|
500
|
+
interface Event {
|
|
501
|
+
event: string;
|
|
502
|
+
data: Properties;
|
|
503
|
+
context: OrderedProperties;
|
|
504
|
+
globals: Properties;
|
|
505
|
+
custom: Properties;
|
|
506
|
+
user: User;
|
|
507
|
+
nested: Entities;
|
|
508
|
+
consent: Consent;
|
|
509
|
+
id: string;
|
|
510
|
+
trigger: string;
|
|
511
|
+
entity: string;
|
|
512
|
+
action: string;
|
|
513
|
+
timestamp: number;
|
|
514
|
+
timing: number;
|
|
515
|
+
group: string;
|
|
516
|
+
count: number;
|
|
517
|
+
version: Version;
|
|
518
|
+
source: Source;
|
|
519
|
+
}
|
|
520
|
+
interface Consent {
|
|
521
|
+
[name: string]: boolean;
|
|
522
|
+
}
|
|
523
|
+
interface User extends Properties {
|
|
524
|
+
id?: string;
|
|
525
|
+
device?: string;
|
|
526
|
+
session?: string;
|
|
527
|
+
hash?: string;
|
|
528
|
+
address?: string;
|
|
529
|
+
email?: string;
|
|
530
|
+
phone?: string;
|
|
531
|
+
userAgent?: string;
|
|
532
|
+
browser?: string;
|
|
533
|
+
browserVersion?: string;
|
|
534
|
+
deviceType?: string;
|
|
535
|
+
language?: string;
|
|
536
|
+
country?: string;
|
|
537
|
+
region?: string;
|
|
538
|
+
city?: string;
|
|
539
|
+
zip?: string;
|
|
540
|
+
timezone?: string;
|
|
541
|
+
os?: string;
|
|
542
|
+
osVersion?: string;
|
|
543
|
+
screenSize?: string;
|
|
544
|
+
ip?: string;
|
|
545
|
+
internal?: boolean;
|
|
546
|
+
}
|
|
547
|
+
interface Version extends Properties {
|
|
548
|
+
source: string;
|
|
549
|
+
tagging: number;
|
|
550
|
+
}
|
|
551
|
+
interface Source extends Properties {
|
|
552
|
+
type: SourceType;
|
|
553
|
+
id: string;
|
|
554
|
+
previous_id: string;
|
|
555
|
+
}
|
|
556
|
+
type SourceType = 'web' | 'server' | 'app' | 'other' | string;
|
|
557
|
+
type PropertyType = boolean | string | number | {
|
|
558
|
+
[key: string]: Property;
|
|
559
|
+
};
|
|
560
|
+
type Property = PropertyType | Array<PropertyType>;
|
|
561
|
+
interface Properties {
|
|
562
|
+
[key: string]: Property | undefined;
|
|
563
|
+
}
|
|
564
|
+
interface OrderedProperties {
|
|
565
|
+
[key: string]: [Property, number] | undefined;
|
|
566
|
+
}
|
|
567
|
+
type Entities = Array<Entity>;
|
|
568
|
+
interface Entity {
|
|
569
|
+
type: string;
|
|
570
|
+
data: Properties;
|
|
571
|
+
nested: Entities;
|
|
572
|
+
context: OrderedProperties;
|
|
573
|
+
}
|
|
574
|
+
type ConsentHandler = Record<string, AnyFunction>;
|
|
575
|
+
type ActionHandler = AnyFunction;
|
|
576
|
+
type DeepPartial<T> = {
|
|
577
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
578
|
+
};
|
|
579
|
+
type PromiseOrValue<T> = T | Promise<T>;
|
|
580
|
+
|
|
581
|
+
type walkeros_ActionHandler = ActionHandler;
|
|
582
|
+
type walkeros_AnyFunction = AnyFunction;
|
|
583
|
+
type walkeros_AnyObject<T = unknown> = AnyObject<T>;
|
|
584
|
+
type walkeros_Consent = Consent;
|
|
585
|
+
type walkeros_ConsentHandler = ConsentHandler;
|
|
586
|
+
type walkeros_DeepPartial<T> = DeepPartial<T>;
|
|
587
|
+
type walkeros_DeepPartialEvent = DeepPartialEvent;
|
|
588
|
+
type walkeros_Elb = Elb;
|
|
589
|
+
type walkeros_Entities = Entities;
|
|
590
|
+
type walkeros_Entity = Entity;
|
|
591
|
+
type walkeros_Event = Event;
|
|
592
|
+
type walkeros_Events = Events;
|
|
593
|
+
type walkeros_OrderedProperties = OrderedProperties;
|
|
594
|
+
type walkeros_PartialEvent = PartialEvent;
|
|
595
|
+
type walkeros_PromiseOrValue<T> = PromiseOrValue<T>;
|
|
596
|
+
type walkeros_Properties = Properties;
|
|
597
|
+
type walkeros_Property = Property;
|
|
598
|
+
type walkeros_PropertyType = PropertyType;
|
|
599
|
+
type walkeros_SingleOrArray<T> = SingleOrArray<T>;
|
|
600
|
+
type walkeros_Source = Source;
|
|
601
|
+
type walkeros_SourceType = SourceType;
|
|
602
|
+
type walkeros_User = User;
|
|
603
|
+
type walkeros_Version = Version;
|
|
604
|
+
declare namespace walkeros {
|
|
605
|
+
export type { walkeros_ActionHandler as ActionHandler, walkeros_AnyFunction as AnyFunction, walkeros_AnyObject as AnyObject, walkeros_Consent as Consent, walkeros_ConsentHandler as ConsentHandler, walkeros_DeepPartial as DeepPartial, walkeros_DeepPartialEvent as DeepPartialEvent, walkeros_Elb as Elb, walkeros_Entities as Entities, walkeros_Entity as Entity, walkeros_Event as Event, walkeros_Events as Events, walkeros_OrderedProperties as OrderedProperties, walkeros_PartialEvent as PartialEvent, walkeros_PromiseOrValue as PromiseOrValue, walkeros_Properties as Properties, walkeros_Property as Property, walkeros_PropertyType as PropertyType, walkeros_SingleOrArray as SingleOrArray, walkeros_Source as Source, walkeros_SourceType as SourceType, walkeros_User as User, walkeros_Version as Version };
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
interface Fn {
|
|
609
|
+
name: string;
|
|
610
|
+
type?: string;
|
|
611
|
+
}
|
|
612
|
+
type OnCall = (context: Fn, args: unknown[]) => void;
|
|
613
|
+
interface Config {
|
|
614
|
+
dryRun?: boolean;
|
|
615
|
+
mockReturn?: unknown;
|
|
616
|
+
onCall?: OnCall;
|
|
617
|
+
}
|
|
618
|
+
type Wrap = <T>(name: string, originalFn: T) => T;
|
|
619
|
+
|
|
620
|
+
type wrapper_Config = Config;
|
|
621
|
+
type wrapper_Fn = Fn;
|
|
622
|
+
type wrapper_OnCall = OnCall;
|
|
623
|
+
type wrapper_Wrap = Wrap;
|
|
624
|
+
declare namespace wrapper {
|
|
625
|
+
export type { wrapper_Config as Config, wrapper_Fn as Fn, wrapper_OnCall as OnCall, wrapper_Wrap as Wrap };
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
type StorageType = 'local' | 'session' | 'cookie';
|
|
629
|
+
declare const Const: {
|
|
630
|
+
readonly Utils: {
|
|
631
|
+
readonly Storage: {
|
|
632
|
+
readonly Local: "local";
|
|
633
|
+
readonly Session: "session";
|
|
634
|
+
readonly Cookie: "cookie";
|
|
635
|
+
};
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Anonymizes an IPv4 address by setting the last octet to 0.
|
|
641
|
+
*
|
|
642
|
+
* @param ip The IP address to anonymize.
|
|
643
|
+
* @returns The anonymized IP address or an empty string if the IP is invalid.
|
|
644
|
+
*/
|
|
645
|
+
declare function anonymizeIP(ip: string): string;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @interface Assign
|
|
649
|
+
* @description Options for the assign function.
|
|
650
|
+
* @property merge - Merge array properties instead of overriding them.
|
|
651
|
+
* @property shallow - Create a shallow copy instead of updating the target object.
|
|
652
|
+
* @property extend - Extend the target with new properties instead of only updating existing ones.
|
|
653
|
+
*/
|
|
654
|
+
interface Assign {
|
|
655
|
+
merge?: boolean;
|
|
656
|
+
shallow?: boolean;
|
|
657
|
+
extend?: boolean;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Merges objects with advanced options.
|
|
661
|
+
*
|
|
662
|
+
* @template T, U
|
|
663
|
+
* @param target - The target object to merge into.
|
|
664
|
+
* @param obj - The source object to merge from.
|
|
665
|
+
* @param options - Options for merging.
|
|
666
|
+
* @returns The merged object.
|
|
667
|
+
*/
|
|
668
|
+
declare function assign<T extends object, U extends object>(target: T, obj?: U, options?: Assign): T & U;
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Gets a value from an object by a dot-notation string.
|
|
672
|
+
* Supports wildcards for arrays.
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* getByPath({ data: { id: 1 } }, "data.id") // Returns 1
|
|
676
|
+
*
|
|
677
|
+
* @param event - The object to get the value from.
|
|
678
|
+
* @param key - The dot-notation string.
|
|
679
|
+
* @param defaultValue - The default value to return if the key is not found.
|
|
680
|
+
* @returns The value from the object or the default value.
|
|
681
|
+
*/
|
|
682
|
+
declare function getByPath(event: unknown, key?: string, defaultValue?: unknown): unknown;
|
|
683
|
+
/**
|
|
684
|
+
* Sets a value in an object by a dot-notation string.
|
|
685
|
+
*
|
|
686
|
+
* @param event - The object to set the value in.
|
|
687
|
+
* @param key - The dot-notation string.
|
|
688
|
+
* @param value - The value to set.
|
|
689
|
+
* @returns A new object with the updated value.
|
|
690
|
+
*/
|
|
691
|
+
declare function setByPath(event: Event, key: string, value: unknown): Event;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Casts a value to a specific type.
|
|
695
|
+
*
|
|
696
|
+
* @param value The value to cast.
|
|
697
|
+
* @returns The casted value.
|
|
698
|
+
*/
|
|
699
|
+
declare function castValue(value: unknown): PropertyType;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Creates a deep clone of a value.
|
|
703
|
+
* Supports primitive values, objects, arrays, dates, and regular expressions.
|
|
704
|
+
* Handles circular references.
|
|
705
|
+
*
|
|
706
|
+
* @template T
|
|
707
|
+
* @param org - The value to clone.
|
|
708
|
+
* @param visited - A map of visited objects to handle circular references.
|
|
709
|
+
* @returns The cloned value.
|
|
710
|
+
*/
|
|
711
|
+
declare function clone<T>(org: T, visited?: WeakMap<object, unknown>): T;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Checks if the required consent is granted.
|
|
715
|
+
*
|
|
716
|
+
* @param required - The required consent states.
|
|
717
|
+
* @param state - The current consent states.
|
|
718
|
+
* @param individual - Individual consent states to prioritize.
|
|
719
|
+
* @returns The granted consent states or false if not granted.
|
|
720
|
+
*/
|
|
721
|
+
declare function getGrantedConsent(required: Consent | undefined, state?: Consent, individual?: Consent): false | Consent;
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Creates a new destination instance by merging a base destination with additional configuration.
|
|
725
|
+
*
|
|
726
|
+
* This utility enables elegant destination configuration while avoiding config side-effects
|
|
727
|
+
* that could occur when reusing destination objects across multiple collector instances.
|
|
728
|
+
*
|
|
729
|
+
* @template Settings - The destination settings type
|
|
730
|
+
* @template Mapping - The destination mapping type
|
|
731
|
+
* @param baseDestination - The base destination to extend
|
|
732
|
+
* @param config - Additional configuration to merge with the base destination's config
|
|
733
|
+
* @returns A new destination instance with merged configuration
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```typescript
|
|
737
|
+
* // Instead of:
|
|
738
|
+
* elb('walker destination', destinationGtag, {
|
|
739
|
+
* settings: { ga4: { measurementId: 'G-123' } }
|
|
740
|
+
* });
|
|
741
|
+
*
|
|
742
|
+
* // You can use:
|
|
743
|
+
* elb('walker destination', createDestination(destinationGtag, {
|
|
744
|
+
* settings: { ga4: { measurementId: 'G-123' } }
|
|
745
|
+
* }));
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
declare function createDestination<Settings = unknown, Mapping = unknown>(baseDestination: Instance$1<Settings, Mapping>, config: Partial<Config$3<Settings, Mapping>>): Instance$1<Settings, Mapping>;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Creates a new source function by merging a base source with additional configuration.
|
|
752
|
+
*
|
|
753
|
+
* This utility enables elegant source configuration while avoiding config side-effects
|
|
754
|
+
* that could occur when reusing source functions across multiple collector instances.
|
|
755
|
+
*
|
|
756
|
+
* @template T - The source config type extending Source.Config
|
|
757
|
+
* @template E - The source elb function type
|
|
758
|
+
* @param source - The base source function to extend
|
|
759
|
+
* @param config - Additional configuration to merge with the source's config
|
|
760
|
+
* @returns A new source function with merged configuration
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```typescript
|
|
764
|
+
* import { createSource } from '@walkeros/core';
|
|
765
|
+
* import { sourceBrowser } from '@walkeros/web-source-browser';
|
|
766
|
+
*
|
|
767
|
+
* const configuredSource = createSource(sourceBrowser, {
|
|
768
|
+
* settings: {
|
|
769
|
+
* scope: document.body,
|
|
770
|
+
* session: true
|
|
771
|
+
* }
|
|
772
|
+
* });
|
|
773
|
+
*
|
|
774
|
+
* const { elb } = await createCollector({
|
|
775
|
+
* sources: {
|
|
776
|
+
* browser: configuredSource
|
|
777
|
+
* }
|
|
778
|
+
* });
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
declare function createSource<T extends Config$1, E = unknown>(source: Init<T, E>, config: Partial<T>): Init<T, E>;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Creates a complete event with default values.
|
|
785
|
+
* Used for testing and debugging.
|
|
786
|
+
*
|
|
787
|
+
* @param props - Properties to override the default values.
|
|
788
|
+
* @returns A complete event.
|
|
789
|
+
*/
|
|
790
|
+
declare function createEvent(props?: DeepPartialEvent): Event;
|
|
791
|
+
/**
|
|
792
|
+
* Creates a complete event with default values based on the event name.
|
|
793
|
+
* Used for testing and debugging.
|
|
794
|
+
*
|
|
795
|
+
* @param name - The name of the event to create.
|
|
796
|
+
* @param props - Properties to override the default values.
|
|
797
|
+
* @returns A complete event.
|
|
798
|
+
*/
|
|
799
|
+
declare function getEvent(name?: string, props?: DeepPartialEvent): Event;
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Generates a random string of a given length.
|
|
803
|
+
*
|
|
804
|
+
* @param length - The length of the random string.
|
|
805
|
+
* @returns The random string.
|
|
806
|
+
*/
|
|
807
|
+
declare function getId(length?: number): string;
|
|
808
|
+
|
|
809
|
+
interface MarketingParameters {
|
|
810
|
+
[key: string]: string;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Extracts marketing parameters from a URL.
|
|
814
|
+
*
|
|
815
|
+
* @param url - The URL to extract the parameters from.
|
|
816
|
+
* @param custom - Custom marketing parameters to extract.
|
|
817
|
+
* @returns The extracted marketing parameters.
|
|
818
|
+
*/
|
|
819
|
+
declare function getMarketingParameters(url: URL, custom?: MarketingParameters): Properties;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Creates a debounced function that delays invoking `fn` until after `wait`
|
|
823
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
824
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
825
|
+
* delayed `fn` invocations and a `flush` method to immediately invoke them.
|
|
826
|
+
*
|
|
827
|
+
* @template P, R
|
|
828
|
+
* @param fn The function to debounce.
|
|
829
|
+
* @param wait The number of milliseconds to delay.
|
|
830
|
+
* @param immediate Trigger the function on the leading edge, instead of the trailing.
|
|
831
|
+
* @returns The new debounced function.
|
|
832
|
+
*/
|
|
833
|
+
declare function debounce<P extends unknown[], R>(fn: (...args: P) => R, wait?: number, immediate?: boolean): (...args: P) => Promise<R>;
|
|
834
|
+
declare function throttle<P extends unknown[], R>(fn: (...args: P) => R | undefined, delay?: number): (...args: P) => R | undefined;
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Checks if a value is an arguments object.
|
|
838
|
+
*
|
|
839
|
+
* @param value The value to check.
|
|
840
|
+
* @returns True if the value is an arguments object, false otherwise.
|
|
841
|
+
*/
|
|
842
|
+
declare function isArguments(value: unknown): value is IArguments;
|
|
843
|
+
/**
|
|
844
|
+
* Checks if a value is an array.
|
|
845
|
+
*
|
|
846
|
+
* @param value The value to check.
|
|
847
|
+
* @returns True if the value is an array, false otherwise.
|
|
848
|
+
*/
|
|
849
|
+
declare function isArray<T>(value: unknown): value is T[];
|
|
850
|
+
/**
|
|
851
|
+
* Checks if a value is a boolean.
|
|
852
|
+
*
|
|
853
|
+
* @param value The value to check.
|
|
854
|
+
* @returns True if the value is a boolean, false otherwise.
|
|
855
|
+
*/
|
|
856
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
857
|
+
/**
|
|
858
|
+
* Checks if an entity is a walker command.
|
|
859
|
+
*
|
|
860
|
+
* @param entity The entity to check.
|
|
861
|
+
* @returns True if the entity is a walker command, false otherwise.
|
|
862
|
+
*/
|
|
863
|
+
declare function isCommand(entity: string): entity is "walker";
|
|
864
|
+
/**
|
|
865
|
+
* Checks if a value is defined.
|
|
866
|
+
*
|
|
867
|
+
* @param value The value to check.
|
|
868
|
+
* @returns True if the value is defined, false otherwise.
|
|
869
|
+
*/
|
|
870
|
+
declare function isDefined<T>(val: T | undefined): val is T;
|
|
871
|
+
/**
|
|
872
|
+
* Checks if a value is an element or the document.
|
|
873
|
+
*
|
|
874
|
+
* @param elem The value to check.
|
|
875
|
+
* @returns True if the value is an element or the document, false otherwise.
|
|
876
|
+
*/
|
|
877
|
+
declare function isElementOrDocument(elem: unknown): elem is Element;
|
|
878
|
+
/**
|
|
879
|
+
* Checks if a value is a function.
|
|
880
|
+
*
|
|
881
|
+
* @param value The value to check.
|
|
882
|
+
* @returns True if the value is a function, false otherwise.
|
|
883
|
+
*/
|
|
884
|
+
declare function isFunction(value: unknown): value is Function;
|
|
885
|
+
/**
|
|
886
|
+
* Checks if a value is a number.
|
|
887
|
+
*
|
|
888
|
+
* @param value The value to check.
|
|
889
|
+
* @returns True if the value is a number, false otherwise.
|
|
890
|
+
*/
|
|
891
|
+
declare function isNumber(value: unknown): value is number;
|
|
892
|
+
/**
|
|
893
|
+
* Checks if a value is an object.
|
|
894
|
+
*
|
|
895
|
+
* @param value The value to check.
|
|
896
|
+
* @returns True if the value is an object, false otherwise.
|
|
897
|
+
*/
|
|
898
|
+
declare function isObject(value: unknown): value is AnyObject;
|
|
899
|
+
/**
|
|
900
|
+
* Checks if two variables have the same type.
|
|
901
|
+
*
|
|
902
|
+
* @param variable The first variable.
|
|
903
|
+
* @param type The second variable.
|
|
904
|
+
* @returns True if the variables have the same type, false otherwise.
|
|
905
|
+
*/
|
|
906
|
+
declare function isSameType<T>(variable: unknown, type: T): variable is typeof type;
|
|
907
|
+
/**
|
|
908
|
+
* Checks if a value is a string.
|
|
909
|
+
*
|
|
910
|
+
* @param value The value to check.
|
|
911
|
+
* @returns True if the value is a string, false otherwise.
|
|
912
|
+
*/
|
|
913
|
+
declare function isString(value: unknown): value is string;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Gets the mapping for an event.
|
|
917
|
+
*
|
|
918
|
+
* @param event The event to get the mapping for.
|
|
919
|
+
* @param mapping The mapping rules.
|
|
920
|
+
* @returns The mapping result.
|
|
921
|
+
*/
|
|
922
|
+
declare function getMappingEvent(event: PartialEvent, mapping?: Rules): Promise<Result>;
|
|
923
|
+
/**
|
|
924
|
+
* Gets a value from a mapping.
|
|
925
|
+
*
|
|
926
|
+
* @param value The value to get the mapping from.
|
|
927
|
+
* @param data The mapping data.
|
|
928
|
+
* @param options The mapping options.
|
|
929
|
+
* @returns The mapped value.
|
|
930
|
+
*/
|
|
931
|
+
declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data, options?: Options$1): Promise<Property | undefined>;
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Logs a message to the console if verbose logging is enabled.
|
|
935
|
+
*
|
|
936
|
+
* @param message The message to log.
|
|
937
|
+
* @param verbose Whether to log the message.
|
|
938
|
+
*/
|
|
939
|
+
declare function onLog(message: unknown, verbose?: boolean): void;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Checks if a value is a valid property type.
|
|
943
|
+
*
|
|
944
|
+
* @param value The value to check.
|
|
945
|
+
* @returns True if the value is a valid property type, false otherwise.
|
|
946
|
+
*/
|
|
947
|
+
declare function isPropertyType(value: unknown): value is PropertyType;
|
|
948
|
+
/**
|
|
949
|
+
* Filters a value to only include valid property types.
|
|
950
|
+
*
|
|
951
|
+
* @param value The value to filter.
|
|
952
|
+
* @returns The filtered value or undefined.
|
|
953
|
+
*/
|
|
954
|
+
declare function filterValues(value: unknown): Property | undefined;
|
|
955
|
+
/**
|
|
956
|
+
* Casts a value to a valid property type.
|
|
957
|
+
*
|
|
958
|
+
* @param value The value to cast.
|
|
959
|
+
* @returns The casted value or undefined.
|
|
960
|
+
*/
|
|
961
|
+
declare function castToProperty(value: unknown): Property | undefined;
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Converts a request string to a data object.
|
|
965
|
+
*
|
|
966
|
+
* @param parameter The request string to convert.
|
|
967
|
+
* @returns The data object or undefined.
|
|
968
|
+
*/
|
|
969
|
+
declare function requestToData(parameter: unknown): AnyObject | undefined;
|
|
970
|
+
/**
|
|
971
|
+
* Converts a data object to a request string.
|
|
972
|
+
*
|
|
973
|
+
* @param data The data object to convert.
|
|
974
|
+
* @returns The request string.
|
|
975
|
+
*/
|
|
976
|
+
declare function requestToParameter(data: AnyObject | PropertyType): string;
|
|
977
|
+
|
|
978
|
+
type SendDataValue = Property | Properties;
|
|
979
|
+
type SendHeaders = {
|
|
980
|
+
[key: string]: string;
|
|
981
|
+
};
|
|
982
|
+
interface SendResponse {
|
|
983
|
+
ok: boolean;
|
|
984
|
+
data?: unknown;
|
|
985
|
+
error?: string;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Transforms data to a string.
|
|
989
|
+
*
|
|
990
|
+
* @param data The data to transform.
|
|
991
|
+
* @returns The transformed data.
|
|
992
|
+
*/
|
|
993
|
+
declare function transformData(data?: SendDataValue): string | undefined;
|
|
994
|
+
/**
|
|
995
|
+
* Gets the headers for a request.
|
|
996
|
+
*
|
|
997
|
+
* @param headers The headers to merge with the default headers.
|
|
998
|
+
* @returns The merged headers.
|
|
999
|
+
*/
|
|
1000
|
+
declare function getHeaders(headers?: SendHeaders): SendHeaders;
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Throws an error.
|
|
1004
|
+
*
|
|
1005
|
+
* @param error The error to throw.
|
|
1006
|
+
*/
|
|
1007
|
+
declare function throwError(error: unknown): never;
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Trims quotes and whitespaces from a string.
|
|
1011
|
+
*
|
|
1012
|
+
* @param str The string to trim.
|
|
1013
|
+
* @returns The trimmed string.
|
|
1014
|
+
*/
|
|
1015
|
+
declare function trim(str: string): string;
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* A utility function that wraps a function in a try-catch block.
|
|
1019
|
+
*
|
|
1020
|
+
* @template P, R, S
|
|
1021
|
+
* @param fn The function to wrap.
|
|
1022
|
+
* @param onError A function to call when an error is caught.
|
|
1023
|
+
* @param onFinally A function to call in the finally block.
|
|
1024
|
+
* @returns The wrapped function.
|
|
1025
|
+
*/
|
|
1026
|
+
declare function tryCatch<P extends unknown[], R, S>(fn: (...args: P) => R | undefined, onError: (err: unknown) => S, onFinally?: () => void): (...args: P) => R | S;
|
|
1027
|
+
declare function tryCatch<P extends unknown[], R>(fn: (...args: P) => R | undefined, onError?: undefined, onFinally?: () => void): (...args: P) => R | undefined;
|
|
1028
|
+
/**
|
|
1029
|
+
* A utility function that wraps an async function in a try-catch block.
|
|
1030
|
+
*
|
|
1031
|
+
* @template P, R, S
|
|
1032
|
+
* @param fn The async function to wrap.
|
|
1033
|
+
* @param onError A function to call when an error is caught.
|
|
1034
|
+
* @param onFinally A function to call in the finally block.
|
|
1035
|
+
* @returns The wrapped async function.
|
|
1036
|
+
*/
|
|
1037
|
+
declare function tryCatchAsync<P extends unknown[], R, S>(fn: (...args: P) => R, onError: (err: unknown) => S, onFinally?: () => void | Promise<void>): (...args: P) => Promise<R | S>;
|
|
1038
|
+
declare function tryCatchAsync<P extends unknown[], R>(fn: (...args: P) => R, onError?: undefined, onFinally?: () => void | Promise<void>): (...args: P) => Promise<R | undefined>;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* A utility function that wraps a function with hooks.
|
|
1042
|
+
*
|
|
1043
|
+
* @template P, R
|
|
1044
|
+
* @param fn The function to wrap.
|
|
1045
|
+
* @param name The name of the function.
|
|
1046
|
+
* @param hooks The hooks to use.
|
|
1047
|
+
* @returns The wrapped function.
|
|
1048
|
+
*/
|
|
1049
|
+
declare function useHooks<P extends unknown[], R>(fn: (...args: P) => R, name: string, hooks: Functions): (...args: P) => R;
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Parses a user agent string to extract browser, OS, and device information.
|
|
1053
|
+
*
|
|
1054
|
+
* @param userAgent The user agent string to parse.
|
|
1055
|
+
* @returns An object containing the parsed user agent information.
|
|
1056
|
+
*/
|
|
1057
|
+
declare function parseUserAgent(userAgent?: string): User;
|
|
1058
|
+
/**
|
|
1059
|
+
* Gets the browser name from a user agent string.
|
|
1060
|
+
*
|
|
1061
|
+
* @param userAgent The user agent string.
|
|
1062
|
+
* @returns The browser name or undefined.
|
|
1063
|
+
*/
|
|
1064
|
+
declare function getBrowser(userAgent: string): string | undefined;
|
|
1065
|
+
/**
|
|
1066
|
+
* Gets the browser version from a user agent string.
|
|
1067
|
+
*
|
|
1068
|
+
* @param userAgent The user agent string.
|
|
1069
|
+
* @returns The browser version or undefined.
|
|
1070
|
+
*/
|
|
1071
|
+
declare function getBrowserVersion(userAgent: string): string | undefined;
|
|
1072
|
+
/**
|
|
1073
|
+
* Gets the OS name from a user agent string.
|
|
1074
|
+
*
|
|
1075
|
+
* @param userAgent The user agent string.
|
|
1076
|
+
* @returns The OS name or undefined.
|
|
1077
|
+
*/
|
|
1078
|
+
declare function getOS(userAgent: string): string | undefined;
|
|
1079
|
+
/**
|
|
1080
|
+
* Gets the OS version from a user agent string.
|
|
1081
|
+
*
|
|
1082
|
+
* @param userAgent The user agent string.
|
|
1083
|
+
* @returns The OS version or undefined.
|
|
1084
|
+
*/
|
|
1085
|
+
declare function getOSVersion(userAgent: string): string | undefined;
|
|
1086
|
+
/**
|
|
1087
|
+
* Gets the device type from a user agent string.
|
|
1088
|
+
*
|
|
1089
|
+
* @param userAgent The user agent string.
|
|
1090
|
+
* @returns The device type or undefined.
|
|
1091
|
+
*/
|
|
1092
|
+
declare function getDeviceType(userAgent: string): string | undefined;
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Validates an event against a set of contracts.
|
|
1096
|
+
*
|
|
1097
|
+
* @param obj The event to validate.
|
|
1098
|
+
* @param customContracts The custom contracts to use.
|
|
1099
|
+
* @returns The validated event.
|
|
1100
|
+
*/
|
|
1101
|
+
declare function validateEvent(obj: unknown, customContracts?: Contracts): Event | never;
|
|
1102
|
+
/**
|
|
1103
|
+
* Validates a property against a schema.
|
|
1104
|
+
*
|
|
1105
|
+
* @param obj The object to validate.
|
|
1106
|
+
* @param key The key of the property to validate.
|
|
1107
|
+
* @param value The value of the property to validate.
|
|
1108
|
+
* @param schema The schema to validate against.
|
|
1109
|
+
* @returns The validated property.
|
|
1110
|
+
*/
|
|
1111
|
+
declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Creates a wrapper function that can be used to wrap other functions.
|
|
1115
|
+
*
|
|
1116
|
+
* @param type The type of the wrapper.
|
|
1117
|
+
* @param config The configuration for the wrapper.
|
|
1118
|
+
* @returns A wrapper function.
|
|
1119
|
+
*/
|
|
1120
|
+
declare function createWrapper(type?: string, { dryRun, mockReturn, onCall }?: Config): Wrap;
|
|
1121
|
+
|
|
1122
|
+
export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, handler as Handler, hooks as Hooks, mapping as Mapping, type MarketingParameters, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, wrapper as Wrapper, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createSource, createWrapper, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, onLog, parseUserAgent, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty };
|