@walkeros/core 0.0.0-next-20251219153324

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.
@@ -0,0 +1,2071 @@
1
+ /**
2
+ * Core collector configuration interface
3
+ */
4
+ interface Config$6 {
5
+ /** Whether to run collector automatically */
6
+ run?: boolean;
7
+ /** Version for event tagging */
8
+ tagging: number;
9
+ /** Static global properties even on a new run */
10
+ globalsStatic: Properties;
11
+ /** Static session data even on a new run */
12
+ sessionStatic: Partial<SessionData>;
13
+ /** Logger configuration */
14
+ logger?: Config$3;
15
+ }
16
+ /**
17
+ * Initialization configuration that extends Config with initial state
18
+ */
19
+ interface InitConfig extends Partial<Config$6> {
20
+ /** Initial consent state */
21
+ consent?: Consent;
22
+ /** Initial user data */
23
+ user?: User;
24
+ /** Initial global properties */
25
+ globals?: Properties;
26
+ /** Source configurations */
27
+ sources?: InitSources;
28
+ /** Destination configurations */
29
+ destinations?: InitDestinations;
30
+ /** Initial custom properties */
31
+ custom?: Properties;
32
+ }
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]: Instance;
47
+ }
48
+ interface Destinations$1 {
49
+ [id: string]: Instance$2;
50
+ }
51
+ type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' | 'elb' | 'globals' | 'hook' | 'init' | 'link' | 'run' | 'user' | 'walker' | string;
52
+ /**
53
+ * Context passed to collector.push for source mapping
54
+ */
55
+ interface PushContext$1 {
56
+ mapping?: Config$2;
57
+ }
58
+ /**
59
+ * Push function signature - handles events only
60
+ */
61
+ interface PushFn$1 {
62
+ (event: DeepPartialEvent, context?: PushContext$1): Promise<PushResult>;
63
+ }
64
+ /**
65
+ * Command function signature - handles walker commands only
66
+ */
67
+ interface CommandFn {
68
+ (command: 'config', config: Partial<Config$6>): Promise<PushResult>;
69
+ (command: 'consent', consent: Consent): Promise<PushResult>;
70
+ <T extends Types$2>(command: 'destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): Promise<PushResult>;
71
+ <K extends keyof Functions>(command: 'hook', name: K, hookFn: Functions[K]): Promise<PushResult>;
72
+ (command: 'on', type: Types$1, rules: SingleOrArray<Options>): Promise<PushResult>;
73
+ (command: 'user', user: User): Promise<PushResult>;
74
+ (command: 'run', runState?: {
75
+ consent?: Consent;
76
+ user?: User;
77
+ globals?: Properties;
78
+ custom?: Properties;
79
+ }): Promise<PushResult>;
80
+ (command: string, data?: unknown, options?: unknown): Promise<PushResult>;
81
+ }
82
+ interface Instance$3 {
83
+ push: PushFn$1;
84
+ command: CommandFn;
85
+ allowed: boolean;
86
+ config: Config$6;
87
+ consent: Consent;
88
+ count: number;
89
+ custom: Properties;
90
+ sources: Sources;
91
+ destinations: Destinations$1;
92
+ globals: Properties;
93
+ group: string;
94
+ hooks: Functions;
95
+ logger: Instance$1;
96
+ on: OnConfig;
97
+ queue: Events;
98
+ round: number;
99
+ session: undefined | SessionData;
100
+ timing: number;
101
+ user: User;
102
+ version: string;
103
+ }
104
+
105
+ type collector_CommandFn = CommandFn;
106
+ type collector_CommandType = CommandType;
107
+ type collector_InitConfig = InitConfig;
108
+ type collector_SessionData = SessionData;
109
+ type collector_Sources = Sources;
110
+ declare namespace collector {
111
+ export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$6 as Config, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$3 as Instance, PushContext$1 as PushContext, PushFn$1 as PushFn, collector_SessionData as SessionData, collector_Sources as Sources };
112
+ }
113
+
114
+ interface Contract$1 {
115
+ version: string;
116
+ globals: Globals;
117
+ context: Contexts;
118
+ entities: Entities$1;
119
+ }
120
+ interface Globals {
121
+ [name: string]: Global;
122
+ }
123
+ interface Contexts {
124
+ [name: string]: Context$3;
125
+ }
126
+ interface Entities$1 {
127
+ [name: string]: Entity$1;
128
+ }
129
+ interface Properties$2 {
130
+ [name: string]: Property$2;
131
+ }
132
+ interface Global extends Property$2 {
133
+ }
134
+ interface Context$3 extends Property$2 {
135
+ }
136
+ interface Entity$1 {
137
+ data: Properties$2;
138
+ actions: Actions;
139
+ }
140
+ interface Actions {
141
+ [name: string]: Action;
142
+ }
143
+ interface Action {
144
+ trigger?: Trigger;
145
+ }
146
+ type Trigger = string;
147
+ interface Property$2 {
148
+ type?: PropertyType$1;
149
+ required?: boolean;
150
+ values?: PropertyValues;
151
+ }
152
+ type PropertyType$1 = 'boolean' | 'string' | 'number';
153
+ type PropertyValues = Array<Property>;
154
+
155
+ type data_Action = Action;
156
+ type data_Actions = Actions;
157
+ type data_Contexts = Contexts;
158
+ type data_Global = Global;
159
+ type data_Globals = Globals;
160
+ type data_PropertyValues = PropertyValues;
161
+ type data_Trigger = Trigger;
162
+ declare namespace data {
163
+ export type { data_Action as Action, data_Actions as Actions, Context$3 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 };
164
+ }
165
+
166
+ /**
167
+ * Base environment requirements interface for walkerOS destinations
168
+ *
169
+ * This defines the core interface that destinations can use to declare
170
+ * their runtime environment requirements. Platform-specific extensions
171
+ * should extend this interface.
172
+ */
173
+ interface BaseEnv$1 {
174
+ /**
175
+ * Generic global properties that destinations may require
176
+ * Platform-specific implementations can extend this interface
177
+ */
178
+ [key: string]: unknown;
179
+ }
180
+ /**
181
+ * Type bundle for destination generics.
182
+ * Groups Settings, InitSettings, Mapping, and Env into a single type parameter.
183
+ */
184
+ interface Types$2<S = unknown, M = unknown, E = BaseEnv$1, I = S> {
185
+ settings: S;
186
+ initSettings: I;
187
+ mapping: M;
188
+ env: E;
189
+ }
190
+ /**
191
+ * Generic constraint for Types - ensures T has required properties for indexed access
192
+ */
193
+ type TypesGeneric$1 = {
194
+ settings: any;
195
+ initSettings: any;
196
+ mapping: any;
197
+ env: any;
198
+ };
199
+ /**
200
+ * Type extractors for consistent usage with Types bundle
201
+ */
202
+ type Settings$1<T extends TypesGeneric$1 = Types$2> = T['settings'];
203
+ type InitSettings$1<T extends TypesGeneric$1 = Types$2> = T['initSettings'];
204
+ type Mapping$1<T extends TypesGeneric$1 = Types$2> = T['mapping'];
205
+ type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
206
+ /**
207
+ * Inference helper: Extract Types from Instance
208
+ */
209
+ type TypesOf$1<I> = I extends Instance$2<infer T> ? T : never;
210
+ interface Instance$2<T extends TypesGeneric$1 = Types$2> {
211
+ config: Config$5<T>;
212
+ queue?: Events;
213
+ dlq?: DLQ;
214
+ batches?: BatchRegistry<Mapping$1<T>>;
215
+ type?: string;
216
+ env?: Env$1<T>;
217
+ init?: InitFn<T>;
218
+ push: PushFn<T>;
219
+ pushBatch?: PushBatchFn<T>;
220
+ on?: OnFn;
221
+ }
222
+ interface Config$5<T extends TypesGeneric$1 = Types$2> {
223
+ consent?: Consent;
224
+ settings?: InitSettings$1<T>;
225
+ data?: Value | Values;
226
+ env?: Env$1<T>;
227
+ id?: string;
228
+ init?: boolean;
229
+ loadScript?: boolean;
230
+ logger?: Config$3;
231
+ mapping?: Rules<Rule<Mapping$1<T>>>;
232
+ policy?: Policy$1;
233
+ queue?: boolean;
234
+ }
235
+ type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$5<Types$2<Partial<Settings$1<T>> | Settings$1<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$1<T>>>;
236
+ interface Policy$1 {
237
+ [key: string]: Value;
238
+ }
239
+ type Code<T extends TypesGeneric$1 = Types$2> = Instance$2<T> | true;
240
+ type Init$1<T extends TypesGeneric$1 = Types$2> = {
241
+ code: Code<T>;
242
+ config?: Partial<Config$5<T>>;
243
+ env?: Partial<Env$1<T>>;
244
+ };
245
+ interface InitDestinations {
246
+ [key: string]: Init$1<any>;
247
+ }
248
+ interface Destinations {
249
+ [key: string]: Instance$2;
250
+ }
251
+ interface Context$2<T extends TypesGeneric$1 = Types$2> {
252
+ collector: Instance$3;
253
+ config: Config$5<T>;
254
+ data?: Data$1;
255
+ env: Env$1<T>;
256
+ logger: Instance$1;
257
+ }
258
+ interface InitContext<T extends TypesGeneric$1 = Types$2> {
259
+ collector: Instance$3;
260
+ config: Config$5<Types$2<Partial<Settings$1<T>>, Mapping$1<T>, Env$1<T>>>;
261
+ data?: Data$1;
262
+ env: Env$1<T>;
263
+ logger: Instance$1;
264
+ }
265
+ interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
266
+ mapping?: Rule<Mapping$1<T>>;
267
+ }
268
+ interface PushBatchContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
269
+ mapping?: Rule<Mapping$1<T>>;
270
+ }
271
+ type InitFn<T extends TypesGeneric$1 = Types$2> = (context: InitContext<T>) => PromiseOrValue<void | false | Config$5<T>>;
272
+ type PushFn<T extends TypesGeneric$1 = Types$2> = (event: Event, context: PushContext<T>) => PromiseOrValue<void>;
273
+ type PushBatchFn<T extends TypesGeneric$1 = Types$2> = (batch: Batch<Mapping$1<T>>, context: PushBatchContext<T>) => void;
274
+ type PushEvent<Mapping = unknown> = {
275
+ event: Event;
276
+ mapping?: Rule<Mapping>;
277
+ };
278
+ type PushEvents<Mapping = unknown> = Array<PushEvent<Mapping>>;
279
+ interface Batch<Mapping> {
280
+ key: string;
281
+ events: Events;
282
+ data: Array<Data$1>;
283
+ mapping?: Rule<Mapping>;
284
+ }
285
+ interface BatchRegistry<Mapping> {
286
+ [mappingKey: string]: {
287
+ batched: Batch<Mapping>;
288
+ batchFn: () => void;
289
+ };
290
+ }
291
+ type Data$1 = Property | undefined | Array<Property | undefined>;
292
+ type Ref = {
293
+ id: string;
294
+ destination: Instance$2;
295
+ };
296
+ type Push$1 = {
297
+ queue?: Events;
298
+ error?: unknown;
299
+ };
300
+ type DLQ = Array<[Event, unknown]>;
301
+ type Result$1 = {
302
+ successful: Array<Ref>;
303
+ queued: Array<Ref>;
304
+ failed: Array<Ref>;
305
+ };
306
+
307
+ type destination_Batch<Mapping> = Batch<Mapping>;
308
+ type destination_BatchRegistry<Mapping> = BatchRegistry<Mapping>;
309
+ type destination_Code<T extends TypesGeneric$1 = Types$2> = Code<T>;
310
+ type destination_DLQ = DLQ;
311
+ type destination_Destinations = Destinations;
312
+ type destination_InitContext<T extends TypesGeneric$1 = Types$2> = InitContext<T>;
313
+ type destination_InitDestinations = InitDestinations;
314
+ type destination_InitFn<T extends TypesGeneric$1 = Types$2> = InitFn<T>;
315
+ type destination_PushBatchContext<T extends TypesGeneric$1 = Types$2> = PushBatchContext<T>;
316
+ type destination_PushBatchFn<T extends TypesGeneric$1 = Types$2> = PushBatchFn<T>;
317
+ type destination_PushContext<T extends TypesGeneric$1 = Types$2> = PushContext<T>;
318
+ type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
319
+ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
320
+ type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
321
+ type destination_Ref = Ref;
322
+ declare namespace destination {
323
+ export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, destination_BatchRegistry as BatchRegistry, destination_Code as Code, Config$5 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$2 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 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, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
324
+ }
325
+
326
+ interface EventFn<R = Promise<PushResult>> {
327
+ (partialEvent: DeepPartialEvent): R;
328
+ (event: string): R;
329
+ (event: string, data: Properties): R;
330
+ }
331
+ interface Fn$1<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, WalkerCommands<R, Config> {
332
+ }
333
+ interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
334
+ (event: 'walker config', config: Partial<Config>): R;
335
+ (event: 'walker consent', consent: Consent): R;
336
+ <T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): R;
337
+ <K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
338
+ (event: 'walker on', type: Types$1, rules: SingleOrArray<Options>): R;
339
+ (event: 'walker user', user: User): R;
340
+ (event: 'walker run', runState: {
341
+ consent?: Consent;
342
+ user?: User;
343
+ globals?: Properties;
344
+ custom?: Properties;
345
+ }): R;
346
+ }
347
+ type Event$1<R = Promise<PushResult>> = (partialEvent: DeepPartialEvent) => R;
348
+ type PushData<Config = unknown> = DeepPartial<Config> | Consent | User | Properties;
349
+ interface PushResult extends Result$1 {
350
+ event?: Event;
351
+ ok: boolean;
352
+ }
353
+ type Layer = Array<IArguments | DeepPartialEvent | unknown[]>;
354
+
355
+ type elb_EventFn<R = Promise<PushResult>> = EventFn<R>;
356
+ type elb_Layer = Layer;
357
+ type elb_PushData<Config = unknown> = PushData<Config>;
358
+ type elb_PushResult = PushResult;
359
+ type elb_WalkerCommands<R = Promise<PushResult>, Config = unknown> = WalkerCommands<R, Config>;
360
+ declare namespace elb {
361
+ export type { Event$1 as Event, elb_EventFn as EventFn, Fn$1 as Fn, elb_Layer as Layer, elb_PushData as PushData, elb_PushResult as PushResult, elb_WalkerCommands as WalkerCommands };
362
+ }
363
+
364
+ /**
365
+ * Flow Configuration System
366
+ *
367
+ * Core types for walkerOS unified configuration.
368
+ * Platform-agnostic, runtime-focused.
369
+ *
370
+ * The Flow system enables "one config to rule them all" - a single
371
+ * walkeros.config.json file that manages multiple flows
372
+ * (web_prod, web_stage, server_prod, etc.) with shared configuration,
373
+ * variables, and reusable definitions.
374
+ *
375
+ * @packageDocumentation
376
+ */
377
+
378
+ /**
379
+ * Primitive value types for variables
380
+ */
381
+ type Primitive = string | number | boolean;
382
+ /**
383
+ * Variables record type for interpolation.
384
+ * Used at Setup, Config, Source, and Destination levels.
385
+ */
386
+ type Variables = Record<string, Primitive>;
387
+ /**
388
+ * Definitions record type for reusable configurations.
389
+ * Used at Setup, Config, Source, and Destination levels.
390
+ */
391
+ type Definitions = Record<string, unknown>;
392
+ /**
393
+ * Packages configuration for build.
394
+ */
395
+ type Packages = Record<string, {
396
+ version?: string;
397
+ imports?: string[];
398
+ path?: string;
399
+ }>;
400
+ /**
401
+ * Web platform configuration.
402
+ *
403
+ * @remarks
404
+ * Presence of this key indicates web platform (browser-based tracking).
405
+ * Builds to IIFE format, ES2020 target, browser platform.
406
+ */
407
+ interface Web {
408
+ /**
409
+ * Window property name for collector instance.
410
+ * @default "collector"
411
+ */
412
+ windowCollector?: string;
413
+ /**
414
+ * Window property name for elb function.
415
+ * @default "elb"
416
+ */
417
+ windowElb?: string;
418
+ }
419
+ /**
420
+ * Server platform configuration.
421
+ *
422
+ * @remarks
423
+ * Presence of this key indicates server platform (Node.js).
424
+ * Builds to ESM format, Node18 target, node platform.
425
+ * Reserved for future server-specific options.
426
+ */
427
+ interface Server {
428
+ }
429
+ /**
430
+ * Complete multi-flow configuration.
431
+ * Root type for walkeros.config.json files.
432
+ *
433
+ * @remarks
434
+ * If only one flow exists, it's auto-selected without --flow flag.
435
+ * Convention: use "default" as the flow name for single-flow configs.
436
+ *
437
+ * @example
438
+ * ```json
439
+ * {
440
+ * "version": 1,
441
+ * "$schema": "https://walkeros.io/schema/flow/v1.json",
442
+ * "variables": { "CURRENCY": "USD" },
443
+ * "flows": {
444
+ * "default": { "web": {}, ... }
445
+ * }
446
+ * }
447
+ * ```
448
+ */
449
+ interface Setup {
450
+ /**
451
+ * Configuration schema version.
452
+ */
453
+ version: 1;
454
+ /**
455
+ * JSON Schema reference for IDE validation.
456
+ * @example "https://walkeros.io/schema/flow/v1.json"
457
+ */
458
+ $schema?: string;
459
+ /**
460
+ * Folders to include in the bundle output.
461
+ * These folders are copied to dist/ during bundle, making them available
462
+ * at runtime for both local and Docker execution.
463
+ *
464
+ * @remarks
465
+ * Use for credential files, configuration, or other runtime assets.
466
+ * Paths are relative to the config file location.
467
+ * Default: `["./shared"]` if the folder exists, otherwise `[]`.
468
+ *
469
+ * @example
470
+ * ```json
471
+ * {
472
+ * "include": ["./credentials", "./config"]
473
+ * }
474
+ * ```
475
+ */
476
+ include?: string[];
477
+ /**
478
+ * Shared variables for interpolation.
479
+ * Resolution: process.env > Config.variables > Setup.variables > inline default
480
+ * Syntax: ${VAR_NAME} or ${VAR_NAME:default}
481
+ */
482
+ variables?: Variables;
483
+ /**
484
+ * Reusable configuration definitions.
485
+ * Referenced via JSON Schema $ref syntax: { "$ref": "#/definitions/name" }
486
+ */
487
+ definitions?: Definitions;
488
+ /**
489
+ * Named flow configurations.
490
+ * If only one flow exists, it's auto-selected.
491
+ */
492
+ flows: Record<string, Config$4>;
493
+ }
494
+ /**
495
+ * Single flow configuration.
496
+ * Represents one deployment target (e.g., web_prod, server_stage).
497
+ *
498
+ * @remarks
499
+ * Platform is determined by presence of `web` or `server` key.
500
+ * Exactly one must be present.
501
+ *
502
+ * Variables/definitions cascade: source/destination > config > setup
503
+ */
504
+ interface Config$4 {
505
+ /**
506
+ * Web platform configuration.
507
+ * Presence indicates web platform (browser-based tracking).
508
+ * Mutually exclusive with `server`.
509
+ */
510
+ web?: Web;
511
+ /**
512
+ * Server platform configuration.
513
+ * Presence indicates server platform (Node.js).
514
+ * Mutually exclusive with `web`.
515
+ */
516
+ server?: Server;
517
+ /**
518
+ * Source configurations (data capture).
519
+ *
520
+ * @remarks
521
+ * Sources capture events from various origins:
522
+ * - Browser DOM interactions (clicks, page views)
523
+ * - DataLayer pushes
524
+ * - HTTP requests (server-side)
525
+ * - Cloud function triggers
526
+ *
527
+ * Key = unique source identifier (arbitrary)
528
+ * Value = source reference with package and config
529
+ *
530
+ * @example
531
+ * ```json
532
+ * {
533
+ * "sources": {
534
+ * "browser": {
535
+ * "package": "@walkeros/web-source-browser",
536
+ * "config": {
537
+ * "settings": {
538
+ * "pageview": true,
539
+ * "session": true
540
+ * }
541
+ * }
542
+ * }
543
+ * }
544
+ * }
545
+ * ```
546
+ */
547
+ sources?: Record<string, SourceReference>;
548
+ /**
549
+ * Destination configurations (data output).
550
+ *
551
+ * @remarks
552
+ * Destinations send processed events to external services:
553
+ * - Google Analytics (gtag)
554
+ * - Meta Pixel (fbq)
555
+ * - Custom APIs
556
+ * - Data warehouses
557
+ *
558
+ * Key = unique destination identifier (arbitrary)
559
+ * Value = destination reference with package and config
560
+ *
561
+ * @example
562
+ * ```json
563
+ * {
564
+ * "destinations": {
565
+ * "gtag": {
566
+ * "package": "@walkeros/web-destination-gtag",
567
+ * "config": {
568
+ * "settings": {
569
+ * "ga4": { "measurementId": "G-XXXXXXXXXX" }
570
+ * }
571
+ * }
572
+ * }
573
+ * }
574
+ * }
575
+ * ```
576
+ */
577
+ destinations?: Record<string, DestinationReference>;
578
+ /**
579
+ * Collector configuration (event processing).
580
+ *
581
+ * @remarks
582
+ * The collector is the central event processing engine.
583
+ * Configuration includes:
584
+ * - Consent management
585
+ * - Global properties
586
+ * - User identification
587
+ * - Processing rules
588
+ *
589
+ * @see {@link Collector.InitConfig} for complete options
590
+ *
591
+ * @example
592
+ * ```json
593
+ * {
594
+ * "collector": {
595
+ * "run": true,
596
+ * "tagging": 1,
597
+ * "consent": {
598
+ * "functional": true,
599
+ * "marketing": false
600
+ * },
601
+ * "globals": {
602
+ * "currency": "USD",
603
+ * "environment": "production"
604
+ * }
605
+ * }
606
+ * }
607
+ * ```
608
+ */
609
+ collector?: InitConfig;
610
+ /**
611
+ * NPM packages to bundle.
612
+ */
613
+ packages?: Packages;
614
+ /**
615
+ * Flow-level variables.
616
+ * Override Setup.variables, overridden by source/destination variables.
617
+ */
618
+ variables?: Variables;
619
+ /**
620
+ * Flow-level definitions.
621
+ * Extend Setup.definitions, overridden by source/destination definitions.
622
+ */
623
+ definitions?: Definitions;
624
+ }
625
+ /**
626
+ * Source reference with inline package syntax.
627
+ *
628
+ * @remarks
629
+ * References a source package and provides configuration.
630
+ * The package is automatically downloaded and imported during build.
631
+ */
632
+ interface SourceReference {
633
+ /**
634
+ * Package specifier with optional version.
635
+ *
636
+ * @remarks
637
+ * Formats:
638
+ * - `"@walkeros/web-source-browser"` - Latest version
639
+ * - `"@walkeros/web-source-browser@2.0.0"` - Specific version
640
+ * - `"@walkeros/web-source-browser@^2.0.0"` - Semver range
641
+ *
642
+ * The CLI will:
643
+ * 1. Parse the package reference
644
+ * 2. Download from npm
645
+ * 3. Auto-detect default or named export
646
+ * 4. Generate import statement
647
+ *
648
+ * @example
649
+ * "package": "@walkeros/web-source-browser@latest"
650
+ */
651
+ package: string;
652
+ /**
653
+ * Resolved import variable name.
654
+ *
655
+ * @remarks
656
+ * Auto-resolved from packages[package].imports[0] during getFlowConfig().
657
+ * Can also be provided explicitly for advanced use cases.
658
+ */
659
+ code?: string;
660
+ /**
661
+ * Source-specific configuration.
662
+ *
663
+ * @remarks
664
+ * Structure depends on the source package.
665
+ * Passed to the source's initialization function.
666
+ *
667
+ * @example
668
+ * ```json
669
+ * {
670
+ * "config": {
671
+ * "settings": {
672
+ * "pageview": true,
673
+ * "session": true,
674
+ * "elb": "elb",
675
+ * "prefix": "data-elb"
676
+ * }
677
+ * }
678
+ * }
679
+ * ```
680
+ */
681
+ config?: unknown;
682
+ /**
683
+ * Source environment configuration.
684
+ *
685
+ * @remarks
686
+ * Environment-specific settings for the source.
687
+ * Merged with default source environment.
688
+ */
689
+ env?: unknown;
690
+ /**
691
+ * Mark as primary source (provides main ELB).
692
+ *
693
+ * @remarks
694
+ * The primary source's ELB function is returned by `startFlow()`.
695
+ * Only one source should be marked as primary per flow.
696
+ *
697
+ * @default false
698
+ */
699
+ primary?: boolean;
700
+ /**
701
+ * Source-level variables (highest priority in cascade).
702
+ * Overrides flow and setup variables.
703
+ */
704
+ variables?: Variables;
705
+ /**
706
+ * Source-level definitions (highest priority in cascade).
707
+ * Overrides flow and setup definitions.
708
+ */
709
+ definitions?: Definitions;
710
+ }
711
+ /**
712
+ * Destination reference with inline package syntax.
713
+ *
714
+ * @remarks
715
+ * References a destination package and provides configuration.
716
+ * Structure mirrors SourceReference for consistency.
717
+ */
718
+ interface DestinationReference {
719
+ /**
720
+ * Package specifier with optional version.
721
+ *
722
+ * @remarks
723
+ * Same format as SourceReference.package
724
+ *
725
+ * @example
726
+ * "package": "@walkeros/web-destination-gtag@2.0.0"
727
+ */
728
+ package: string;
729
+ /**
730
+ * Resolved import variable name.
731
+ *
732
+ * @remarks
733
+ * Auto-resolved from packages[package].imports[0] during getFlowConfig().
734
+ * Can also be provided explicitly for advanced use cases.
735
+ */
736
+ code?: string;
737
+ /**
738
+ * Destination-specific configuration.
739
+ *
740
+ * @remarks
741
+ * Structure depends on the destination package.
742
+ * Typically includes:
743
+ * - settings: API keys, IDs, endpoints
744
+ * - mapping: Event transformation rules
745
+ * - consent: Required consent states
746
+ * - policy: Processing rules
747
+ *
748
+ * @example
749
+ * ```json
750
+ * {
751
+ * "config": {
752
+ * "settings": {
753
+ * "ga4": {
754
+ * "measurementId": "G-XXXXXXXXXX"
755
+ * }
756
+ * },
757
+ * "mapping": {
758
+ * "page": {
759
+ * "view": {
760
+ * "name": "page_view",
761
+ * "data": { ... }
762
+ * }
763
+ * }
764
+ * }
765
+ * }
766
+ * }
767
+ * ```
768
+ */
769
+ config?: unknown;
770
+ /**
771
+ * Destination environment configuration.
772
+ *
773
+ * @remarks
774
+ * Environment-specific settings for the destination.
775
+ * Merged with default destination environment.
776
+ */
777
+ env?: unknown;
778
+ /**
779
+ * Destination-level variables (highest priority in cascade).
780
+ * Overrides flow and setup variables.
781
+ */
782
+ variables?: Variables;
783
+ /**
784
+ * Destination-level definitions (highest priority in cascade).
785
+ * Overrides flow and setup definitions.
786
+ */
787
+ definitions?: Definitions;
788
+ }
789
+
790
+ type flow_Definitions = Definitions;
791
+ type flow_DestinationReference = DestinationReference;
792
+ type flow_Packages = Packages;
793
+ type flow_Primitive = Primitive;
794
+ type flow_Server = Server;
795
+ type flow_Setup = Setup;
796
+ type flow_SourceReference = SourceReference;
797
+ type flow_Variables = Variables;
798
+ type flow_Web = Web;
799
+ declare namespace flow {
800
+ export type { Config$4 as Config, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_Variables as Variables, flow_Web as Web };
801
+ }
802
+
803
+ type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
804
+ type Functions = {
805
+ [key: string]: AnyFunction$1;
806
+ };
807
+ interface Parameter<P extends unknown[], R> {
808
+ fn: (...args: P) => R;
809
+ result?: R;
810
+ }
811
+ type HookFn<T extends AnyFunction$1> = (params: Parameter<Parameters<T>, ReturnType<T>>, ...args: Parameters<T>) => ReturnType<T>;
812
+
813
+ type hooks_Functions = Functions;
814
+ type hooks_HookFn<T extends AnyFunction$1> = HookFn<T>;
815
+ declare namespace hooks {
816
+ export type { AnyFunction$1 as AnyFunction, hooks_Functions as Functions, hooks_HookFn as HookFn };
817
+ }
818
+
819
+ /**
820
+ * Log levels from most to least severe
821
+ */
822
+ declare enum Level {
823
+ ERROR = 0,
824
+ INFO = 1,
825
+ DEBUG = 2
826
+ }
827
+ /**
828
+ * Normalized error context extracted from Error objects
829
+ */
830
+ interface ErrorContext {
831
+ message: string;
832
+ name: string;
833
+ stack?: string;
834
+ cause?: unknown;
835
+ }
836
+ /**
837
+ * Context passed to log handlers
838
+ * If an Error was passed, it's normalized into the error property
839
+ */
840
+ interface LogContext {
841
+ [key: string]: unknown;
842
+ error?: ErrorContext;
843
+ }
844
+ /**
845
+ * Log message function signature
846
+ * Accepts string or Error as message, with optional context
847
+ */
848
+ type LogFn = (message: string | Error, context?: unknown | Error) => void;
849
+ /**
850
+ * Throw function signature - logs error then throws
851
+ * Returns never as it always throws
852
+ */
853
+ type ThrowFn = (message: string | Error, context?: unknown) => never;
854
+ /**
855
+ * Default handler function (passed to custom handlers for chaining)
856
+ */
857
+ type DefaultHandler = (level: Level, message: string, context: LogContext, scope: string[]) => void;
858
+ /**
859
+ * Custom log handler function
860
+ * Receives originalHandler to allow middleware-style chaining
861
+ */
862
+ type Handler = (level: Level, message: string, context: LogContext, scope: string[], originalHandler: DefaultHandler) => void;
863
+ /**
864
+ * Logger instance with scoping support
865
+ * All logs automatically include trace path from scoping
866
+ */
867
+ interface Instance$1 {
868
+ /**
869
+ * Log an error message (always visible unless silenced)
870
+ */
871
+ error: LogFn;
872
+ /**
873
+ * Log an informational message
874
+ */
875
+ info: LogFn;
876
+ /**
877
+ * Log a debug message
878
+ */
879
+ debug: LogFn;
880
+ /**
881
+ * Log an error message and throw an Error
882
+ * Combines logging and throwing in one call
883
+ */
884
+ throw: ThrowFn;
885
+ /**
886
+ * Create a scoped child logger with automatic trace path
887
+ * @param name - Scope name (e.g., destination type, destination key)
888
+ * @returns A new logger instance with the scope applied
889
+ */
890
+ scope: (name: string) => Instance$1;
891
+ }
892
+ /**
893
+ * Logger configuration options
894
+ */
895
+ interface Config$3 {
896
+ /**
897
+ * Minimum log level to display
898
+ * @default Level.ERROR
899
+ */
900
+ level?: Level | keyof typeof Level;
901
+ /**
902
+ * Custom log handler function
903
+ * Receives originalHandler to preserve default behavior
904
+ */
905
+ handler?: Handler;
906
+ }
907
+ /**
908
+ * Internal config with resolved values and scope
909
+ */
910
+ interface InternalConfig {
911
+ level: Level;
912
+ handler?: Handler;
913
+ scope: string[];
914
+ }
915
+ /**
916
+ * Logger factory function type
917
+ */
918
+ type Factory = (config?: Config$3) => Instance$1;
919
+
920
+ type logger_DefaultHandler = DefaultHandler;
921
+ type logger_ErrorContext = ErrorContext;
922
+ type logger_Factory = Factory;
923
+ type logger_Handler = Handler;
924
+ type logger_InternalConfig = InternalConfig;
925
+ type logger_Level = Level;
926
+ declare const logger_Level: typeof Level;
927
+ type logger_LogContext = LogContext;
928
+ type logger_LogFn = LogFn;
929
+ type logger_ThrowFn = ThrowFn;
930
+ declare namespace logger {
931
+ export { type Config$3 as Config, type logger_DefaultHandler as DefaultHandler, type logger_ErrorContext as ErrorContext, type logger_Factory as Factory, type logger_Handler as Handler, type Instance$1 as Instance, type logger_InternalConfig as InternalConfig, logger_Level as Level, type logger_LogContext as LogContext, type logger_LogFn as LogFn, type logger_ThrowFn as ThrowFn };
932
+ }
933
+
934
+ /**
935
+ * Shared mapping configuration interface.
936
+ * Used by both Source.Config and Destination.Config.
937
+ */
938
+ interface Config$2<T = unknown> {
939
+ consent?: Consent;
940
+ data?: Value | Values;
941
+ mapping?: Rules<Rule<T>>;
942
+ policy?: Policy;
943
+ }
944
+ interface Policy {
945
+ [key: string]: Value;
946
+ }
947
+ interface Rules<T = Rule> {
948
+ [entity: string]: Record<string, T | Array<T>> | undefined;
949
+ }
950
+ interface Rule<Settings = unknown> {
951
+ batch?: number;
952
+ batchFn?: (destination: Instance$2, collector: Instance$3) => void;
953
+ batched?: Batch<Settings>;
954
+ condition?: Condition;
955
+ consent?: Consent;
956
+ settings?: Settings;
957
+ data?: Data;
958
+ ignore?: boolean;
959
+ name?: string;
960
+ policy?: Policy;
961
+ }
962
+ interface Result {
963
+ eventMapping?: Rule;
964
+ mappingKey?: string;
965
+ }
966
+ type Data = Value | Values;
967
+ type Value = ValueType | Array<ValueType>;
968
+ type Values = Array<Value>;
969
+ type ValueType = string | ValueConfig;
970
+ interface ValueConfig {
971
+ condition?: Condition;
972
+ consent?: Consent;
973
+ fn?: Fn;
974
+ key?: string;
975
+ loop?: Loop;
976
+ map?: Map;
977
+ set?: Value[];
978
+ validate?: Validate;
979
+ value?: PropertyType;
980
+ }
981
+ type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$3) => PromiseOrValue<boolean>;
982
+ type Fn = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
983
+ type Loop = [Value, Value];
984
+ type Map = {
985
+ [key: string]: Value;
986
+ };
987
+ interface Options$1 {
988
+ consent?: Consent;
989
+ collector?: Instance$3;
990
+ props?: unknown;
991
+ }
992
+ type Validate = (value?: unknown) => PromiseOrValue<boolean>;
993
+
994
+ type mapping_Condition = Condition;
995
+ type mapping_Data = Data;
996
+ type mapping_Fn = Fn;
997
+ type mapping_Loop = Loop;
998
+ type mapping_Map = Map;
999
+ type mapping_Policy = Policy;
1000
+ type mapping_Result = Result;
1001
+ type mapping_Rule<Settings = unknown> = Rule<Settings>;
1002
+ type mapping_Rules<T = Rule> = Rules<T>;
1003
+ type mapping_Validate = Validate;
1004
+ type mapping_Value = Value;
1005
+ type mapping_ValueConfig = ValueConfig;
1006
+ type mapping_ValueType = ValueType;
1007
+ type mapping_Values = Values;
1008
+ declare namespace mapping {
1009
+ export type { mapping_Condition as Condition, Config$2 as Config, mapping_Data as Data, mapping_Fn as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Policy as Policy, 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 };
1010
+ }
1011
+
1012
+ type Config$1 = {
1013
+ consent?: Array<ConsentConfig>;
1014
+ ready?: Array<ReadyConfig>;
1015
+ run?: Array<RunConfig>;
1016
+ session?: Array<SessionConfig>;
1017
+ };
1018
+ type Types$1 = keyof Config$1;
1019
+ interface EventContextMap {
1020
+ consent: Consent;
1021
+ session: SessionData;
1022
+ ready: undefined;
1023
+ run: undefined;
1024
+ }
1025
+ type EventContext<T extends Types$1> = EventContextMap[T];
1026
+ type AnyEventContext = EventContextMap[keyof EventContextMap];
1027
+ interface Context$1 {
1028
+ consent?: Consent;
1029
+ session?: unknown;
1030
+ }
1031
+ type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
1032
+ interface ConsentConfig {
1033
+ [key: string]: ConsentFn;
1034
+ }
1035
+ type ConsentFn = (collector: Instance$3, consent: Consent) => void;
1036
+ type ReadyConfig = ReadyFn;
1037
+ type ReadyFn = (collector: Instance$3) => void;
1038
+ type RunConfig = RunFn;
1039
+ type RunFn = (collector: Instance$3) => void;
1040
+ type SessionConfig = SessionFn;
1041
+ type SessionFn = (collector: Instance$3, session?: unknown) => void;
1042
+ interface OnConfig {
1043
+ consent?: ConsentConfig[];
1044
+ ready?: ReadyConfig[];
1045
+ run?: RunConfig[];
1046
+ session?: SessionConfig[];
1047
+ [key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
1048
+ }
1049
+ type OnFn<T extends TypesGeneric$1 = Types$2> = (type: Types$1, context: Context$2<T>) => PromiseOrValue<void>;
1050
+ type OnFnRuntime = (type: Types$1, context: Context$2) => PromiseOrValue<void>;
1051
+
1052
+ type on_AnyEventContext = AnyEventContext;
1053
+ type on_ConsentConfig = ConsentConfig;
1054
+ type on_ConsentFn = ConsentFn;
1055
+ type on_EventContext<T extends Types$1> = EventContext<T>;
1056
+ type on_EventContextMap = EventContextMap;
1057
+ type on_OnConfig = OnConfig;
1058
+ type on_OnFn<T extends TypesGeneric$1 = Types$2> = OnFn<T>;
1059
+ type on_OnFnRuntime = OnFnRuntime;
1060
+ type on_Options = Options;
1061
+ type on_ReadyConfig = ReadyConfig;
1062
+ type on_ReadyFn = ReadyFn;
1063
+ type on_RunConfig = RunConfig;
1064
+ type on_RunFn = RunFn;
1065
+ type on_SessionConfig = SessionConfig;
1066
+ type on_SessionFn = SessionFn;
1067
+ declare namespace on {
1068
+ export type { on_AnyEventContext as AnyEventContext, Config$1 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, Context$1 as Context, on_EventContext as EventContext, on_EventContextMap as EventContextMap, on_OnConfig as OnConfig, on_OnFn as OnFn, on_OnFnRuntime as OnFnRuntime, 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, Types$1 as Types };
1069
+ }
1070
+
1071
+ interface Context {
1072
+ city?: string;
1073
+ country?: string;
1074
+ encoding?: string;
1075
+ hash?: string;
1076
+ ip?: string;
1077
+ language?: string;
1078
+ origin?: string;
1079
+ region?: string;
1080
+ userAgent?: string;
1081
+ [key: string]: string | undefined;
1082
+ }
1083
+
1084
+ type request_Context = Context;
1085
+ declare namespace request {
1086
+ export type { request_Context as Context };
1087
+ }
1088
+
1089
+ type Contracts = Array<Contract>;
1090
+ type Contract = {
1091
+ [entity: string]: {
1092
+ [action: string]: Properties$1;
1093
+ };
1094
+ };
1095
+ type Properties$1 = {
1096
+ [key: string]: Property$1 | undefined;
1097
+ };
1098
+ type Property$1 = {
1099
+ allowedKeys?: string[];
1100
+ allowedValues?: unknown[];
1101
+ maxLength?: number;
1102
+ max?: number;
1103
+ min?: number;
1104
+ required?: boolean;
1105
+ schema?: Properties$1;
1106
+ strict?: boolean;
1107
+ type?: string;
1108
+ validate?: (value: unknown, key: string, event: AnyObject) => Property;
1109
+ };
1110
+
1111
+ type schema_Contract = Contract;
1112
+ type schema_Contracts = Contracts;
1113
+ declare namespace schema {
1114
+ export type { schema_Contract as Contract, schema_Contracts as Contracts, Properties$1 as Properties, Property$1 as Property };
1115
+ }
1116
+
1117
+ /**
1118
+ * Base Env interface for dependency injection into sources.
1119
+ *
1120
+ * Sources receive all their dependencies through this environment object,
1121
+ * making them platform-agnostic and easily testable.
1122
+ */
1123
+ interface BaseEnv {
1124
+ [key: string]: unknown;
1125
+ push: PushFn$1;
1126
+ command: CommandFn;
1127
+ sources?: Sources;
1128
+ elb: Fn$1;
1129
+ logger: Instance$1;
1130
+ }
1131
+ /**
1132
+ * Type bundle for source generics.
1133
+ * Groups Settings, Mapping, Push, Env, and InitSettings into a single type parameter.
1134
+ *
1135
+ * @template S - Settings configuration type
1136
+ * @template M - Mapping configuration type
1137
+ * @template P - Push function signature (flexible to support HTTP handlers, etc.)
1138
+ * @template E - Environment dependencies type
1139
+ * @template I - InitSettings configuration type (user input)
1140
+ */
1141
+ interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> {
1142
+ settings: S;
1143
+ initSettings: I;
1144
+ mapping: M;
1145
+ push: P;
1146
+ env: E;
1147
+ }
1148
+ /**
1149
+ * Generic constraint for Types - ensures T has required properties for indexed access
1150
+ */
1151
+ type TypesGeneric = {
1152
+ settings: any;
1153
+ initSettings: any;
1154
+ mapping: any;
1155
+ push: any;
1156
+ env: any;
1157
+ };
1158
+ /**
1159
+ * Type extractors for consistent usage with Types bundle
1160
+ */
1161
+ type Settings<T extends TypesGeneric = Types> = T['settings'];
1162
+ type InitSettings<T extends TypesGeneric = Types> = T['initSettings'];
1163
+ type Mapping<T extends TypesGeneric = Types> = T['mapping'];
1164
+ type Push<T extends TypesGeneric = Types> = T['push'];
1165
+ type Env<T extends TypesGeneric = Types> = T['env'];
1166
+ /**
1167
+ * Inference helper: Extract Types from Instance
1168
+ */
1169
+ type TypesOf<I> = I extends Instance<infer T> ? T : never;
1170
+ interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
1171
+ settings?: InitSettings<T>;
1172
+ env?: Env<T>;
1173
+ id?: string;
1174
+ logger?: Config$3;
1175
+ disabled?: boolean;
1176
+ primary?: boolean;
1177
+ }
1178
+ type PartialConfig<T extends TypesGeneric = Types> = Config<Types<Partial<Settings<T>> | Settings<T>, Partial<Mapping<T>> | Mapping<T>, Push<T>, Env<T>>>;
1179
+ interface Instance<T extends TypesGeneric = Types> {
1180
+ type: string;
1181
+ config: Config<T>;
1182
+ push: Push<T>;
1183
+ destroy?(): void | Promise<void>;
1184
+ on?(event: Types$1, context?: unknown): void | Promise<void>;
1185
+ }
1186
+ type Init<T extends TypesGeneric = Types> = (config: Partial<Config<T>>, env: Env<T>) => Instance<T> | Promise<Instance<T>>;
1187
+ type InitSource<T extends TypesGeneric = Types> = {
1188
+ code: Init<T>;
1189
+ config?: Partial<Config<T>>;
1190
+ env?: Partial<Env<T>>;
1191
+ primary?: boolean;
1192
+ };
1193
+ /**
1194
+ * Sources configuration for collector.
1195
+ * Maps source IDs to their initialization configurations.
1196
+ */
1197
+ interface InitSources {
1198
+ [sourceId: string]: InitSource<any>;
1199
+ }
1200
+
1201
+ type source_BaseEnv = BaseEnv;
1202
+ type source_Config<T extends TypesGeneric = Types> = Config<T>;
1203
+ type source_Env<T extends TypesGeneric = Types> = Env<T>;
1204
+ type source_Init<T extends TypesGeneric = Types> = Init<T>;
1205
+ type source_InitSettings<T extends TypesGeneric = Types> = InitSettings<T>;
1206
+ type source_InitSource<T extends TypesGeneric = Types> = InitSource<T>;
1207
+ type source_InitSources = InitSources;
1208
+ type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
1209
+ type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
1210
+ type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
1211
+ type source_Push<T extends TypesGeneric = Types> = Push<T>;
1212
+ type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
1213
+ type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> = Types<S, M, P, E, I>;
1214
+ type source_TypesGeneric = TypesGeneric;
1215
+ type source_TypesOf<I> = TypesOf<I>;
1216
+ declare namespace source {
1217
+ export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSettings as InitSettings, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
1218
+ }
1219
+
1220
+ type AnyObject<T = unknown> = Record<string, T>;
1221
+ type Elb = Fn$1;
1222
+ type AnyFunction = (...args: unknown[]) => unknown;
1223
+ type SingleOrArray<T> = T | Array<T>;
1224
+ type Events = Array<Event>;
1225
+ type PartialEvent = Partial<Event>;
1226
+ type DeepPartialEvent = DeepPartial<Event>;
1227
+ interface Event {
1228
+ name: string;
1229
+ data: Properties;
1230
+ context: OrderedProperties;
1231
+ globals: Properties;
1232
+ custom: Properties;
1233
+ user: User;
1234
+ nested: Entities;
1235
+ consent: Consent;
1236
+ id: string;
1237
+ trigger: string;
1238
+ entity: string;
1239
+ action: string;
1240
+ timestamp: number;
1241
+ timing: number;
1242
+ group: string;
1243
+ count: number;
1244
+ version: Version;
1245
+ source: Source;
1246
+ }
1247
+ interface Consent {
1248
+ [name: string]: boolean;
1249
+ }
1250
+ interface User extends Properties {
1251
+ id?: string;
1252
+ device?: string;
1253
+ session?: string;
1254
+ hash?: string;
1255
+ address?: string;
1256
+ email?: string;
1257
+ phone?: string;
1258
+ userAgent?: string;
1259
+ browser?: string;
1260
+ browserVersion?: string;
1261
+ deviceType?: string;
1262
+ language?: string;
1263
+ country?: string;
1264
+ region?: string;
1265
+ city?: string;
1266
+ zip?: string;
1267
+ timezone?: string;
1268
+ os?: string;
1269
+ osVersion?: string;
1270
+ screenSize?: string;
1271
+ ip?: string;
1272
+ internal?: boolean;
1273
+ }
1274
+ interface Version extends Properties {
1275
+ source: string;
1276
+ tagging: number;
1277
+ }
1278
+ interface Source extends Properties {
1279
+ type: SourceType;
1280
+ id: string;
1281
+ previous_id: string;
1282
+ }
1283
+ type SourceType = 'web' | 'server' | 'app' | 'other' | string;
1284
+ type PropertyType = boolean | string | number | {
1285
+ [key: string]: Property;
1286
+ };
1287
+ type Property = PropertyType | Array<PropertyType>;
1288
+ interface Properties {
1289
+ [key: string]: Property | undefined;
1290
+ }
1291
+ interface OrderedProperties {
1292
+ [key: string]: [Property, number] | undefined;
1293
+ }
1294
+ type Entities = Array<Entity>;
1295
+ interface Entity {
1296
+ entity: string;
1297
+ data: Properties;
1298
+ nested: Entities;
1299
+ context: OrderedProperties;
1300
+ }
1301
+ type ConsentHandler = Record<string, AnyFunction>;
1302
+ type ActionHandler = AnyFunction;
1303
+ type DeepPartial<T> = {
1304
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
1305
+ };
1306
+ type PromiseOrValue<T> = T | Promise<T>;
1307
+
1308
+ type walkeros_ActionHandler = ActionHandler;
1309
+ type walkeros_AnyFunction = AnyFunction;
1310
+ type walkeros_AnyObject<T = unknown> = AnyObject<T>;
1311
+ type walkeros_Consent = Consent;
1312
+ type walkeros_ConsentHandler = ConsentHandler;
1313
+ type walkeros_DeepPartial<T> = DeepPartial<T>;
1314
+ type walkeros_DeepPartialEvent = DeepPartialEvent;
1315
+ type walkeros_Elb = Elb;
1316
+ type walkeros_Entities = Entities;
1317
+ type walkeros_Entity = Entity;
1318
+ type walkeros_Event = Event;
1319
+ type walkeros_Events = Events;
1320
+ type walkeros_OrderedProperties = OrderedProperties;
1321
+ type walkeros_PartialEvent = PartialEvent;
1322
+ type walkeros_PromiseOrValue<T> = PromiseOrValue<T>;
1323
+ type walkeros_Properties = Properties;
1324
+ type walkeros_Property = Property;
1325
+ type walkeros_PropertyType = PropertyType;
1326
+ type walkeros_SingleOrArray<T> = SingleOrArray<T>;
1327
+ type walkeros_Source = Source;
1328
+ type walkeros_SourceType = SourceType;
1329
+ type walkeros_User = User;
1330
+ type walkeros_Version = Version;
1331
+ declare namespace walkeros {
1332
+ 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 };
1333
+ }
1334
+
1335
+ type StorageType = 'local' | 'session' | 'cookie';
1336
+ declare const Const: {
1337
+ readonly Utils: {
1338
+ readonly Storage: {
1339
+ readonly Local: "local";
1340
+ readonly Session: "session";
1341
+ readonly Cookie: "cookie";
1342
+ };
1343
+ };
1344
+ };
1345
+
1346
+ type SendDataValue = Property | Properties;
1347
+ type SendHeaders = {
1348
+ [key: string]: string;
1349
+ };
1350
+ interface SendResponse {
1351
+ ok: boolean;
1352
+ data?: unknown;
1353
+ error?: string;
1354
+ }
1355
+
1356
+ /**
1357
+ * Anonymizes an IPv4 address by setting the last octet to 0.
1358
+ *
1359
+ * @param ip The IP address to anonymize.
1360
+ * @returns The anonymized IP address or an empty string if the IP is invalid.
1361
+ */
1362
+ declare function anonymizeIP(ip: string): string;
1363
+
1364
+ /**
1365
+ * Flow Configuration Utilities
1366
+ *
1367
+ * Functions for resolving and processing Flow configurations.
1368
+ *
1369
+ * @packageDocumentation
1370
+ */
1371
+
1372
+ /**
1373
+ * Convert package name to valid JavaScript variable name.
1374
+ * Used for deterministic default import naming.
1375
+ * @example
1376
+ * packageNameToVariable('@walkeros/server-destination-api')
1377
+ * // → '_walkerosServerDestinationApi'
1378
+ */
1379
+ declare function packageNameToVariable(packageName: string): string;
1380
+ /**
1381
+ * Get resolved flow configuration for a named flow.
1382
+ *
1383
+ * @param setup - The complete setup configuration
1384
+ * @param flowName - Flow name (auto-selected if only one exists)
1385
+ * @returns Resolved Config with variables/definitions interpolated and $refs resolved
1386
+ * @throws Error if flow selection is required but not specified, or flow not found
1387
+ *
1388
+ * @example
1389
+ * ```typescript
1390
+ * import { getFlowConfig } from '@walkeros/core';
1391
+ *
1392
+ * const setup = JSON.parse(fs.readFileSync('walkeros.config.json', 'utf8'));
1393
+ *
1394
+ * // Auto-select if only one flow
1395
+ * const config = getFlowConfig(setup);
1396
+ *
1397
+ * // Or specify flow
1398
+ * const prodConfig = getFlowConfig(setup, 'production');
1399
+ * ```
1400
+ */
1401
+ declare function getFlowConfig(setup: Setup, flowName?: string): Config$4;
1402
+ /**
1403
+ * Get platform from config (web or server).
1404
+ *
1405
+ * @param config - Flow configuration
1406
+ * @returns "web" or "server"
1407
+ * @throws Error if neither web nor server is present
1408
+ *
1409
+ * @example
1410
+ * ```typescript
1411
+ * import { getPlatform } from '@walkeros/core';
1412
+ *
1413
+ * const platform = getPlatform(config);
1414
+ * // Returns "web" or "server"
1415
+ * ```
1416
+ */
1417
+ declare function getPlatform(config: Config$4): 'web' | 'server';
1418
+
1419
+ /**
1420
+ * @interface Assign
1421
+ * @description Options for the assign function.
1422
+ * @property merge - Merge array properties instead of overriding them.
1423
+ * @property shallow - Create a shallow copy instead of updating the target object.
1424
+ * @property extend - Extend the target with new properties instead of only updating existing ones.
1425
+ */
1426
+ interface Assign {
1427
+ merge?: boolean;
1428
+ shallow?: boolean;
1429
+ extend?: boolean;
1430
+ }
1431
+ /**
1432
+ * Merges objects with advanced options.
1433
+ *
1434
+ * @template T, U
1435
+ * @param target - The target object to merge into.
1436
+ * @param obj - The source object to merge from.
1437
+ * @param options - Options for merging.
1438
+ * @returns The merged object.
1439
+ */
1440
+ declare function assign<T extends object, U extends object>(target: T, obj?: U, options?: Assign): T & U;
1441
+
1442
+ /**
1443
+ * Gets a value from an object by a dot-notation string.
1444
+ * Supports wildcards for arrays.
1445
+ *
1446
+ * @example
1447
+ * getByPath({ data: { id: 1 } }, "data.id") // Returns 1
1448
+ *
1449
+ * @param event - The object to get the value from.
1450
+ * @param key - The dot-notation string.
1451
+ * @param defaultValue - The default value to return if the key is not found.
1452
+ * @returns The value from the object or the default value.
1453
+ */
1454
+ declare function getByPath(event: unknown, key?: string, defaultValue?: unknown): unknown;
1455
+ /**
1456
+ * Sets a value in an object by a dot-notation string.
1457
+ *
1458
+ * @param obj - The object to set the value in.
1459
+ * @param key - The dot-notation string.
1460
+ * @param value - The value to set.
1461
+ * @returns A new object with the updated value.
1462
+ */
1463
+ declare function setByPath<T = unknown>(obj: T, key: string, value: unknown): T;
1464
+
1465
+ /**
1466
+ * Casts a value to a specific type.
1467
+ *
1468
+ * @param value The value to cast.
1469
+ * @returns The casted value.
1470
+ */
1471
+ declare function castValue(value: unknown): PropertyType;
1472
+
1473
+ /**
1474
+ * Creates a deep clone of a value.
1475
+ * Supports primitive values, objects, arrays, dates, and regular expressions.
1476
+ * Handles circular references.
1477
+ *
1478
+ * @template T
1479
+ * @param org - The value to clone.
1480
+ * @param visited - A map of visited objects to handle circular references.
1481
+ * @returns The cloned value.
1482
+ */
1483
+ declare function clone<T>(org: T, visited?: WeakMap<object, unknown>): T;
1484
+
1485
+ /**
1486
+ * Checks if the required consent is granted.
1487
+ *
1488
+ * @param required - The required consent states.
1489
+ * @param state - The current consent states.
1490
+ * @param individual - Individual consent states to prioritize.
1491
+ * @returns The granted consent states or false if not granted.
1492
+ */
1493
+ declare function getGrantedConsent(required: Consent | undefined, state?: Consent, individual?: Consent): false | Consent;
1494
+
1495
+ /**
1496
+ * Creates a new destination instance by merging a base destination with additional configuration.
1497
+ *
1498
+ * This utility enables elegant destination configuration while avoiding config side-effects
1499
+ * that could occur when reusing destination objects across multiple collector instances.
1500
+ *
1501
+ * @param baseDestination - The base destination to extend
1502
+ * @param config - Additional configuration to merge with the base destination's config
1503
+ * @returns A new destination instance with merged configuration
1504
+ *
1505
+ * @example
1506
+ * ```typescript
1507
+ * // Types are inferred automatically from destinationGtag
1508
+ * elb('walker destination', createDestination(destinationGtag, {
1509
+ * settings: { ga4: { measurementId: 'G-123' } }
1510
+ * }));
1511
+ * ```
1512
+ */
1513
+ declare function createDestination<I extends Instance$2>(baseDestination: I, config: Partial<Config$5<TypesOf$1<I>>>): I;
1514
+
1515
+ /**
1516
+ * Creates a complete event with default values.
1517
+ * Used for testing and debugging.
1518
+ *
1519
+ * @param props - Properties to override the default values.
1520
+ * @returns A complete event.
1521
+ */
1522
+ declare function createEvent(props?: DeepPartialEvent): Event;
1523
+ /**
1524
+ * Creates a complete event with default values based on the event name.
1525
+ * Used for testing and debugging.
1526
+ *
1527
+ * @param name - The name of the event to create.
1528
+ * @param props - Properties to override the default values.
1529
+ * @returns A complete event.
1530
+ */
1531
+ declare function getEvent(name?: string, props?: DeepPartialEvent): Event;
1532
+
1533
+ /**
1534
+ * Generates a random string of a given length.
1535
+ *
1536
+ * @param length - The length of the random string.
1537
+ * @returns The random string.
1538
+ */
1539
+ declare function getId(length?: number): string;
1540
+
1541
+ interface MarketingParameters {
1542
+ [key: string]: string;
1543
+ }
1544
+ /**
1545
+ * Extracts marketing parameters from a URL.
1546
+ *
1547
+ * @param url - The URL to extract the parameters from.
1548
+ * @param custom - Custom marketing parameters to extract.
1549
+ * @returns The extracted marketing parameters.
1550
+ */
1551
+ declare function getMarketingParameters(url: URL, custom?: MarketingParameters): Properties;
1552
+
1553
+ /**
1554
+ * Creates a debounced function that delays invoking `fn` until after `wait`
1555
+ * milliseconds have elapsed since the last time the debounced function was
1556
+ * invoked. The debounced function comes with a `cancel` method to cancel
1557
+ * delayed `fn` invocations and a `flush` method to immediately invoke them.
1558
+ *
1559
+ * @template P, R
1560
+ * @param fn The function to debounce.
1561
+ * @param wait The number of milliseconds to delay.
1562
+ * @param immediate Trigger the function on the leading edge, instead of the trailing.
1563
+ * @returns The new debounced function.
1564
+ */
1565
+ declare function debounce<P extends unknown[], R>(fn: (...args: P) => R, wait?: number, immediate?: boolean): (...args: P) => Promise<R>;
1566
+ declare function throttle<P extends unknown[], R>(fn: (...args: P) => R | undefined, delay?: number): (...args: P) => R | undefined;
1567
+
1568
+ /**
1569
+ * Checks if a value is an arguments object.
1570
+ *
1571
+ * @param value The value to check.
1572
+ * @returns True if the value is an arguments object, false otherwise.
1573
+ */
1574
+ declare function isArguments(value: unknown): value is IArguments;
1575
+ /**
1576
+ * Checks if a value is an array.
1577
+ *
1578
+ * @param value The value to check.
1579
+ * @returns True if the value is an array, false otherwise.
1580
+ */
1581
+ declare function isArray<T>(value: unknown): value is T[];
1582
+ /**
1583
+ * Checks if a value is a boolean.
1584
+ *
1585
+ * @param value The value to check.
1586
+ * @returns True if the value is a boolean, false otherwise.
1587
+ */
1588
+ declare function isBoolean(value: unknown): value is boolean;
1589
+ /**
1590
+ * Checks if an entity is a walker command.
1591
+ *
1592
+ * @param entity The entity to check.
1593
+ * @returns True if the entity is a walker command, false otherwise.
1594
+ */
1595
+ declare function isCommand(entity: string): entity is "walker";
1596
+ /**
1597
+ * Checks if a value is defined.
1598
+ *
1599
+ * @param value The value to check.
1600
+ * @returns True if the value is defined, false otherwise.
1601
+ */
1602
+ declare function isDefined<T>(val: T | undefined): val is T;
1603
+ /**
1604
+ * Checks if a value is an element or the document.
1605
+ *
1606
+ * @param elem The value to check.
1607
+ * @returns True if the value is an element or the document, false otherwise.
1608
+ */
1609
+ declare function isElementOrDocument(elem: unknown): elem is Element;
1610
+ /**
1611
+ * Checks if a value is a function.
1612
+ *
1613
+ * @param value The value to check.
1614
+ * @returns True if the value is a function, false otherwise.
1615
+ */
1616
+ declare function isFunction(value: unknown): value is Function;
1617
+ /**
1618
+ * Checks if a value is a number.
1619
+ *
1620
+ * @param value The value to check.
1621
+ * @returns True if the value is a number, false otherwise.
1622
+ */
1623
+ declare function isNumber(value: unknown): value is number;
1624
+ /**
1625
+ * Checks if a value is an object.
1626
+ *
1627
+ * @param value The value to check.
1628
+ * @returns True if the value is an object, false otherwise.
1629
+ */
1630
+ declare function isObject(value: unknown): value is AnyObject;
1631
+ /**
1632
+ * Checks if two variables have the same type.
1633
+ *
1634
+ * @param variable The first variable.
1635
+ * @param type The second variable.
1636
+ * @returns True if the variables have the same type, false otherwise.
1637
+ */
1638
+ declare function isSameType<T>(variable: unknown, type: T): variable is typeof type;
1639
+ /**
1640
+ * Checks if a value is a string.
1641
+ *
1642
+ * @param value The value to check.
1643
+ * @returns True if the value is a string, false otherwise.
1644
+ */
1645
+ declare function isString(value: unknown): value is string;
1646
+
1647
+ /**
1648
+ * Create a logger instance
1649
+ *
1650
+ * @param config - Logger configuration
1651
+ * @returns Logger instance with all log methods and scoping support
1652
+ *
1653
+ * @example
1654
+ * ```typescript
1655
+ * // Basic usage
1656
+ * const logger = createLogger({ level: 'DEBUG' });
1657
+ * logger.info('Hello world');
1658
+ *
1659
+ * // With scoping
1660
+ * const destLogger = logger.scope('gtag').scope('myInstance');
1661
+ * destLogger.debug('Processing event'); // DEBUG [gtag:myInstance] Processing event
1662
+ *
1663
+ * // With custom handler
1664
+ * const logger = createLogger({
1665
+ * handler: (level, message, context, scope, originalHandler) => {
1666
+ * // Custom logic (e.g., send to Sentry)
1667
+ * originalHandler(level, message, context, scope);
1668
+ * }
1669
+ * });
1670
+ * ```
1671
+ *
1672
+ * // TODO: Consider compile-time stripping of debug logs in production builds
1673
+ * // e.g., if (__DEV__) { logger.debug(...) }
1674
+ */
1675
+ declare function createLogger(config?: Config$3): Instance$1;
1676
+
1677
+ /**
1678
+ * Gets the mapping for an event.
1679
+ *
1680
+ * @param event The event to get the mapping for (can be partial or full).
1681
+ * @param mapping The mapping rules.
1682
+ * @returns The mapping result.
1683
+ */
1684
+ declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules): Promise<Result>;
1685
+ /**
1686
+ * Gets a value from a mapping.
1687
+ *
1688
+ * @param value The value to get the mapping from.
1689
+ * @param data The mapping data.
1690
+ * @param options The mapping options.
1691
+ * @returns The mapped value.
1692
+ */
1693
+ declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data, options?: Options$1): Promise<Property | undefined>;
1694
+ /**
1695
+ * Processes an event through mapping configuration.
1696
+ *
1697
+ * This is the unified mapping logic used by both sources and destinations.
1698
+ * It applies transformations in this order:
1699
+ * 1. Config-level policy - modifies the event itself (global rules)
1700
+ * 2. Mapping rules - finds matching rule based on entity-action
1701
+ * 3. Event-level policy - modifies the event based on specific mapping rule
1702
+ * 4. Data transformation - creates context data
1703
+ * 5. Ignore check and name override
1704
+ *
1705
+ * Sources can pass partial events, destinations pass full events.
1706
+ * getMappingValue works with both partial and full events.
1707
+ *
1708
+ * @param event - The event to process (can be partial or full, will be mutated by policies)
1709
+ * @param config - Mapping configuration (mapping, data, policy, consent)
1710
+ * @param collector - Collector instance for context
1711
+ * @returns Object with transformed event, data, mapping rule, and ignore flag
1712
+ */
1713
+ declare function processEventMapping<T extends DeepPartialEvent | Event>(event: T, config: Config$2, collector: Instance$3): Promise<{
1714
+ event: T;
1715
+ data?: Property;
1716
+ mapping?: Rule;
1717
+ mappingKey?: string;
1718
+ ignore: boolean;
1719
+ }>;
1720
+
1721
+ /**
1722
+ * Environment mocking utilities for walkerOS destinations
1723
+ *
1724
+ * Provides standardized tools for intercepting function calls in environment objects,
1725
+ * enabling consistent testing patterns across all destinations.
1726
+ */
1727
+ type InterceptorFn = (path: string[], args: unknown[], original?: Function) => unknown;
1728
+ /**
1729
+ * Creates a proxied environment that intercepts function calls
1730
+ *
1731
+ * Uses Proxy to wrap environment objects and capture all function calls,
1732
+ * allowing for call recording, mocking, or simulation.
1733
+ *
1734
+ * @param env - The environment object to wrap
1735
+ * @param interceptor - Function called for each intercepted call
1736
+ * @returns Proxied environment with interceptor applied
1737
+ *
1738
+ * @example
1739
+ * ```typescript
1740
+ * const calls: Array<{ path: string[]; args: unknown[] }> = [];
1741
+ *
1742
+ * const testEnv = mockEnv(env.push, (path, args) => {
1743
+ * calls.push({ path, args });
1744
+ * });
1745
+ *
1746
+ * // Use testEnv with destination
1747
+ * await destination.push(event, { env: testEnv });
1748
+ *
1749
+ * // Analyze captured calls
1750
+ * expect(calls).toContainEqual({
1751
+ * path: ['window', 'gtag'],
1752
+ * args: ['event', 'purchase', { value: 99.99 }]
1753
+ * });
1754
+ * ```
1755
+ */
1756
+ declare function mockEnv<T extends object>(env: T, interceptor: InterceptorFn): T;
1757
+ /**
1758
+ * Traverses environment object and replaces values using a replacer function
1759
+ *
1760
+ * Alternative to mockEnv for environments where Proxy is not suitable.
1761
+ * Performs deep traversal and allows value transformation at each level.
1762
+ *
1763
+ * @param env - The environment object to traverse
1764
+ * @param replacer - Function to transform values during traversal
1765
+ * @returns New environment object with transformed values
1766
+ *
1767
+ * @example
1768
+ * ```typescript
1769
+ * const recordedCalls: APICall[] = [];
1770
+ *
1771
+ * const recordingEnv = traverseEnv(originalEnv, (value, path) => {
1772
+ * if (typeof value === 'function') {
1773
+ * return (...args: unknown[]) => {
1774
+ * recordedCalls.push({
1775
+ * path: path.join('.'),
1776
+ * args: structuredClone(args)
1777
+ * });
1778
+ * return value(...args);
1779
+ * };
1780
+ * }
1781
+ * return value;
1782
+ * });
1783
+ * ```
1784
+ */
1785
+ declare function traverseEnv<T extends object>(env: T, replacer: (value: unknown, path: string[]) => unknown): T;
1786
+
1787
+ /**
1788
+ * Mock logger instance for testing
1789
+ * Includes all logger methods as jest.fn() plus tracking of scoped loggers
1790
+ * Extends Instance to ensure type compatibility
1791
+ */
1792
+ interface MockLogger extends Instance$1 {
1793
+ error: jest.Mock;
1794
+ info: jest.Mock;
1795
+ debug: jest.Mock;
1796
+ throw: jest.Mock<never, [string | Error, unknown?]>;
1797
+ scope: jest.Mock<MockLogger, [string]>;
1798
+ /**
1799
+ * Array of all scoped loggers created by this logger
1800
+ * Useful for asserting on scoped logger calls in tests
1801
+ */
1802
+ scopedLoggers: MockLogger[];
1803
+ }
1804
+ /**
1805
+ * Create a mock logger for testing
1806
+ * All methods are jest.fn() that can be used for assertions
1807
+ *
1808
+ * @example
1809
+ * ```typescript
1810
+ * const mockLogger = createMockLogger();
1811
+ *
1812
+ * // Use in code under test
1813
+ * someFunction(mockLogger);
1814
+ *
1815
+ * // Assert on calls
1816
+ * expect(mockLogger.error).toHaveBeenCalledWith('error message');
1817
+ *
1818
+ * // Assert on scoped logger
1819
+ * const scoped = mockLogger.scopedLoggers[0];
1820
+ * expect(scoped.debug).toHaveBeenCalledWith('debug in scope');
1821
+ * ```
1822
+ */
1823
+ declare function createMockLogger(): MockLogger;
1824
+
1825
+ /**
1826
+ * Checks if a value is a valid property type.
1827
+ *
1828
+ * @param value The value to check.
1829
+ * @returns True if the value is a valid property type, false otherwise.
1830
+ */
1831
+ declare function isPropertyType(value: unknown): value is PropertyType;
1832
+ /**
1833
+ * Filters a value to only include valid property types.
1834
+ *
1835
+ * @param value The value to filter.
1836
+ * @returns The filtered value or undefined.
1837
+ */
1838
+ declare function filterValues(value: unknown): Property | undefined;
1839
+ /**
1840
+ * Casts a value to a valid property type.
1841
+ *
1842
+ * @param value The value to cast.
1843
+ * @returns The casted value or undefined.
1844
+ */
1845
+ declare function castToProperty(value: unknown): Property | undefined;
1846
+
1847
+ /**
1848
+ * Converts a request string to a data object.
1849
+ *
1850
+ * @param parameter The request string to convert.
1851
+ * @returns The data object or undefined.
1852
+ */
1853
+ declare function requestToData(parameter: unknown): AnyObject | undefined;
1854
+ /**
1855
+ * Converts a data object to a request string.
1856
+ *
1857
+ * @param data The data object to convert.
1858
+ * @returns The request string.
1859
+ */
1860
+ declare function requestToParameter(data: AnyObject | PropertyType): string;
1861
+
1862
+ /**
1863
+ * Transforms data to a string.
1864
+ *
1865
+ * @param data The data to transform.
1866
+ * @returns The transformed data.
1867
+ */
1868
+ declare function transformData(data?: SendDataValue): string | undefined;
1869
+ /**
1870
+ * Gets the headers for a request.
1871
+ *
1872
+ * @param headers The headers to merge with the default headers.
1873
+ * @returns The merged headers.
1874
+ */
1875
+ declare function getHeaders(headers?: SendHeaders): SendHeaders;
1876
+
1877
+ /**
1878
+ * Throws an error.
1879
+ *
1880
+ * @param error The error to throw.
1881
+ */
1882
+ declare function throwError(error: unknown): never;
1883
+
1884
+ /**
1885
+ * Trims quotes and whitespaces from a string.
1886
+ *
1887
+ * @param str The string to trim.
1888
+ * @returns The trimmed string.
1889
+ */
1890
+ declare function trim(str: string): string;
1891
+
1892
+ /**
1893
+ * A utility function that wraps a function in a try-catch block.
1894
+ *
1895
+ * @template P, R, S
1896
+ * @param fn The function to wrap.
1897
+ * @param onError A function to call when an error is caught.
1898
+ * @param onFinally A function to call in the finally block.
1899
+ * @returns The wrapped function.
1900
+ */
1901
+ declare function tryCatch<P extends unknown[], R, S>(fn: (...args: P) => R | undefined, onError: (err: unknown) => S, onFinally?: () => void): (...args: P) => R | S;
1902
+ declare function tryCatch<P extends unknown[], R>(fn: (...args: P) => R | undefined, onError?: undefined, onFinally?: () => void): (...args: P) => R | undefined;
1903
+ /**
1904
+ * A utility function that wraps an async function in a try-catch block.
1905
+ *
1906
+ * @template P, R, S
1907
+ * @param fn The async function to wrap.
1908
+ * @param onError A function to call when an error is caught.
1909
+ * @param onFinally A function to call in the finally block.
1910
+ * @returns The wrapped async function.
1911
+ */
1912
+ 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>;
1913
+ declare function tryCatchAsync<P extends unknown[], R>(fn: (...args: P) => R, onError?: undefined, onFinally?: () => void | Promise<void>): (...args: P) => Promise<R | undefined>;
1914
+
1915
+ /**
1916
+ * A utility function that wraps a function with hooks.
1917
+ *
1918
+ * @template P, R
1919
+ * @param fn The function to wrap.
1920
+ * @param name The name of the function.
1921
+ * @param hooks The hooks to use.
1922
+ * @returns The wrapped function.
1923
+ */
1924
+ declare function useHooks<P extends unknown[], R>(fn: (...args: P) => R, name: string, hooks: Functions): (...args: P) => R;
1925
+
1926
+ /**
1927
+ * Parses a user agent string to extract browser, OS, and device information.
1928
+ *
1929
+ * @param userAgent The user agent string to parse.
1930
+ * @returns An object containing the parsed user agent information.
1931
+ */
1932
+ declare function parseUserAgent(userAgent?: string): User;
1933
+ /**
1934
+ * Gets the browser name from a user agent string.
1935
+ *
1936
+ * @param userAgent The user agent string.
1937
+ * @returns The browser name or undefined.
1938
+ */
1939
+ declare function getBrowser(userAgent: string): string | undefined;
1940
+ /**
1941
+ * Gets the browser version from a user agent string.
1942
+ *
1943
+ * @param userAgent The user agent string.
1944
+ * @returns The browser version or undefined.
1945
+ */
1946
+ declare function getBrowserVersion(userAgent: string): string | undefined;
1947
+ /**
1948
+ * Gets the OS name from a user agent string.
1949
+ *
1950
+ * @param userAgent The user agent string.
1951
+ * @returns The OS name or undefined.
1952
+ */
1953
+ declare function getOS(userAgent: string): string | undefined;
1954
+ /**
1955
+ * Gets the OS version from a user agent string.
1956
+ *
1957
+ * @param userAgent The user agent string.
1958
+ * @returns The OS version or undefined.
1959
+ */
1960
+ declare function getOSVersion(userAgent: string): string | undefined;
1961
+ /**
1962
+ * Gets the device type from a user agent string.
1963
+ *
1964
+ * @param userAgent The user agent string.
1965
+ * @returns The device type or undefined.
1966
+ */
1967
+ declare function getDeviceType(userAgent: string): string | undefined;
1968
+
1969
+ /**
1970
+ * Validates an event against a set of contracts.
1971
+ *
1972
+ * @param obj The event to validate.
1973
+ * @param customContracts The custom contracts to use.
1974
+ * @returns The validated event.
1975
+ */
1976
+ declare function validateEvent(obj: unknown, customContracts?: Contracts): Event | never;
1977
+ /**
1978
+ * Validates a property against a schema.
1979
+ *
1980
+ * @param obj The object to validate.
1981
+ * @param key The key of the property to validate.
1982
+ * @param value The value of the property to validate.
1983
+ * @param schema The schema to validate against.
1984
+ * @returns The validated property.
1985
+ */
1986
+ declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
1987
+
1988
+ /**
1989
+ * Inline Code Wrapping Utilities
1990
+ *
1991
+ * Converts inline code strings to executable functions.
1992
+ * Used for mapping properties: condition, fn, validate.
1993
+ *
1994
+ * @packageDocumentation
1995
+ */
1996
+
1997
+ /**
1998
+ * Wrap inline code string as Condition function.
1999
+ *
2000
+ * @param code - Inline code string
2001
+ * @returns Condition function matching Mapping.Condition signature
2002
+ *
2003
+ * @remarks
2004
+ * Available parameters in code:
2005
+ * - `value` - The event or partial event being processed
2006
+ * - `mapping` - Current mapping configuration
2007
+ * - `collector` - Collector instance
2008
+ *
2009
+ * If code has no explicit return, it's auto-wrapped with `return`.
2010
+ *
2011
+ * @example
2012
+ * ```typescript
2013
+ * // One-liner (auto-wrapped)
2014
+ * const fn = wrapCondition('value.data.total > 100');
2015
+ * fn(event, mapping, collector); // returns boolean
2016
+ *
2017
+ * // Multi-statement (explicit return)
2018
+ * const fn = wrapCondition('const threshold = 100; return value.data.total > threshold');
2019
+ * ```
2020
+ */
2021
+ declare function wrapCondition(code: string): Condition;
2022
+ /**
2023
+ * Wrap inline code string as Fn function.
2024
+ *
2025
+ * @param code - Inline code string
2026
+ * @returns Fn function matching Mapping.Fn signature
2027
+ *
2028
+ * @remarks
2029
+ * Available parameters in code:
2030
+ * - `value` - The event or partial event being processed
2031
+ * - `mapping` - Current mapping configuration
2032
+ * - `options` - Options object with consent and collector
2033
+ *
2034
+ * If code has no explicit return, it's auto-wrapped with `return`.
2035
+ *
2036
+ * @example
2037
+ * ```typescript
2038
+ * // One-liner (auto-wrapped)
2039
+ * const fn = wrapFn('value.user.email.split("@")[1]');
2040
+ * fn(event, mapping, options); // returns domain
2041
+ *
2042
+ * // Multi-statement (explicit return)
2043
+ * const fn = wrapFn('const parts = value.user.email.split("@"); return parts[1].toUpperCase()');
2044
+ * ```
2045
+ */
2046
+ declare function wrapFn(code: string): Fn;
2047
+ /**
2048
+ * Wrap inline code string as Validate function.
2049
+ *
2050
+ * @param code - Inline code string
2051
+ * @returns Validate function matching Mapping.Validate signature
2052
+ *
2053
+ * @remarks
2054
+ * Available parameters in code:
2055
+ * - `value` - The current value being validated
2056
+ *
2057
+ * If code has no explicit return, it's auto-wrapped with `return`.
2058
+ *
2059
+ * @example
2060
+ * ```typescript
2061
+ * // One-liner (auto-wrapped)
2062
+ * const fn = wrapValidate('value && value.length > 0');
2063
+ * fn('hello'); // returns true
2064
+ *
2065
+ * // Multi-statement (explicit return)
2066
+ * const fn = wrapValidate('if (!value) return false; return value.length > 0');
2067
+ * ```
2068
+ */
2069
+ declare function wrapValidate(code: string): Validate;
2070
+
2071
+ export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, hooks as Hooks, Level, logger as Logger, mapping as Mapping, type MarketingParameters, type MockLogger, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowConfig, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, wrapCondition, wrapFn, wrapValidate };