@walkeros/core 0.4.1 → 0.5.0

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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Core collector configuration interface
3
3
  */
4
- interface Config$5 {
4
+ interface Config$6 {
5
5
  /** Whether to run collector automatically */
6
6
  run?: boolean;
7
7
  /** Version for event tagging */
@@ -10,17 +10,13 @@ interface Config$5 {
10
10
  globalsStatic: Properties;
11
11
  /** Static session data even on a new run */
12
12
  sessionStatic: Partial<SessionData>;
13
- /** Enable verbose logging */
14
- verbose: boolean;
15
- /** Error handler */
16
- onError?: Error;
17
- /** Log handler */
18
- onLog?: Log;
13
+ /** Logger configuration */
14
+ logger?: Config$3;
19
15
  }
20
16
  /**
21
17
  * Initialization configuration that extends Config with initial state
22
18
  */
23
- interface InitConfig extends Partial<Config$5> {
19
+ interface InitConfig extends Partial<Config$6> {
24
20
  /** Initial consent state */
25
21
  consent?: Consent;
26
22
  /** Initial user data */
@@ -50,7 +46,7 @@ interface Sources {
50
46
  [id: string]: Instance;
51
47
  }
52
48
  interface Destinations$1 {
53
- [id: string]: Instance$1;
49
+ [id: string]: Instance$2;
54
50
  }
55
51
  type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' | 'elb' | 'globals' | 'hook' | 'init' | 'link' | 'run' | 'user' | 'walker' | string;
56
52
  /**
@@ -69,9 +65,9 @@ interface PushFn$1 {
69
65
  * Command function signature - handles walker commands only
70
66
  */
71
67
  interface CommandFn {
72
- (command: 'config', config: Partial<Config$5>): Promise<PushResult>;
68
+ (command: 'config', config: Partial<Config$6>): Promise<PushResult>;
73
69
  (command: 'consent', consent: Consent): Promise<PushResult>;
74
- <T extends Types$2>(command: 'destination', destination: Init$1<T> | Instance$1<T>, config?: Config$4<T>): Promise<PushResult>;
70
+ <T extends Types$2>(command: 'destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): Promise<PushResult>;
75
71
  <K extends keyof Functions>(command: 'hook', name: K, hookFn: Functions[K]): Promise<PushResult>;
76
72
  (command: 'on', type: Types$1, rules: SingleOrArray<Options>): Promise<PushResult>;
77
73
  (command: 'user', user: User): Promise<PushResult>;
@@ -83,11 +79,11 @@ interface CommandFn {
83
79
  }): Promise<PushResult>;
84
80
  (command: string, data?: unknown, options?: unknown): Promise<PushResult>;
85
81
  }
86
- interface Instance$2 {
82
+ interface Instance$3 {
87
83
  push: PushFn$1;
88
84
  command: CommandFn;
89
85
  allowed: boolean;
90
- config: Config$5;
86
+ config: Config$6;
91
87
  consent: Consent;
92
88
  count: number;
93
89
  custom: Properties;
@@ -96,6 +92,7 @@ interface Instance$2 {
96
92
  globals: Properties;
97
93
  group: string;
98
94
  hooks: Functions;
95
+ logger: Instance$1;
99
96
  on: OnConfig;
100
97
  queue: Events;
101
98
  round: number;
@@ -111,7 +108,7 @@ type collector_InitConfig = InitConfig;
111
108
  type collector_SessionData = SessionData;
112
109
  type collector_Sources = Sources;
113
110
  declare namespace collector {
114
- export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$5 as Config, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$2 as Instance, PushContext$1 as PushContext, PushFn$1 as PushFn, collector_SessionData as SessionData, collector_Sources as Sources };
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 };
115
112
  }
116
113
 
117
114
  interface Contract$1 {
@@ -209,9 +206,9 @@ type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
209
206
  /**
210
207
  * Inference helper: Extract Types from Instance
211
208
  */
212
- type TypesOf$1<I> = I extends Instance$1<infer T> ? T : never;
213
- interface Instance$1<T extends TypesGeneric$1 = Types$2> {
214
- config: Config$4<T>;
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>;
215
212
  queue?: Events;
216
213
  dlq?: DLQ;
217
214
  type?: string;
@@ -221,7 +218,7 @@ interface Instance$1<T extends TypesGeneric$1 = Types$2> {
221
218
  pushBatch?: PushBatchFn<T>;
222
219
  on?: OnFn;
223
220
  }
224
- interface Config$4<T extends TypesGeneric$1 = Types$2> {
221
+ interface Config$5<T extends TypesGeneric$1 = Types$2> {
225
222
  consent?: Consent;
226
223
  settings?: InitSettings$1<T>;
227
224
  data?: Value | Values;
@@ -229,39 +226,40 @@ interface Config$4<T extends TypesGeneric$1 = Types$2> {
229
226
  id?: string;
230
227
  init?: boolean;
231
228
  loadScript?: boolean;
229
+ logger?: Config$3;
232
230
  mapping?: Rules<Rule<Mapping$1<T>>>;
233
231
  policy?: Policy$1;
234
232
  queue?: boolean;
235
- verbose?: boolean;
236
- onError?: Error;
237
- onLog?: Log;
238
233
  }
239
- type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$4<Types$2<Partial<Settings$1<T>> | Settings$1<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$1<T>>>;
234
+ 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>>>;
240
235
  interface Policy$1 {
241
236
  [key: string]: Value;
242
237
  }
238
+ type Code<T extends TypesGeneric$1 = Types$2> = Instance$2<T> | true;
243
239
  type Init$1<T extends TypesGeneric$1 = Types$2> = {
244
- code: Instance$1<T>;
245
- config?: Partial<Config$4<T>>;
240
+ code: Code<T>;
241
+ config?: Partial<Config$5<T>>;
246
242
  env?: Partial<Env$1<T>>;
247
243
  };
248
244
  interface InitDestinations {
249
245
  [key: string]: Init$1<any>;
250
246
  }
251
247
  interface Destinations {
252
- [key: string]: Instance$1;
248
+ [key: string]: Instance$2;
253
249
  }
254
250
  interface Context$2<T extends TypesGeneric$1 = Types$2> {
255
- collector: Instance$2;
256
- config: Config$4<T>;
251
+ collector: Instance$3;
252
+ config: Config$5<T>;
257
253
  data?: Data$1;
258
254
  env: Env$1<T>;
255
+ logger: Instance$1;
259
256
  }
260
257
  interface InitContext<T extends TypesGeneric$1 = Types$2> {
261
- collector: Instance$2;
262
- config: Config$4<Types$2<Partial<Settings$1<T>>, Mapping$1<T>, Env$1<T>>>;
258
+ collector: Instance$3;
259
+ config: Config$5<Types$2<Partial<Settings$1<T>>, Mapping$1<T>, Env$1<T>>>;
263
260
  data?: Data$1;
264
261
  env: Env$1<T>;
262
+ logger: Instance$1;
265
263
  }
266
264
  interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
267
265
  mapping?: Rule<Mapping$1<T>>;
@@ -269,7 +267,7 @@ interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
269
267
  interface PushBatchContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
270
268
  mapping?: Rule<Mapping$1<T>>;
271
269
  }
272
- type InitFn<T extends TypesGeneric$1 = Types$2> = (context: InitContext<T>) => PromiseOrValue<void | false | Config$4<T>>;
270
+ type InitFn<T extends TypesGeneric$1 = Types$2> = (context: InitContext<T>) => PromiseOrValue<void | false | Config$5<T>>;
273
271
  type PushFn<T extends TypesGeneric$1 = Types$2> = (event: Event, context: PushContext<T>) => PromiseOrValue<void>;
274
272
  type PushBatchFn<T extends TypesGeneric$1 = Types$2> = (batch: Batch<Mapping$1<T>>, context: PushBatchContext<T>) => void;
275
273
  type PushEvent<Mapping = unknown> = {
@@ -286,7 +284,7 @@ interface Batch<Mapping> {
286
284
  type Data$1 = Property | undefined | Array<Property | undefined>;
287
285
  type Ref = {
288
286
  id: string;
289
- destination: Instance$1;
287
+ destination: Instance$2;
290
288
  };
291
289
  type Push$1 = {
292
290
  queue?: Events;
@@ -300,6 +298,7 @@ type Result$1 = {
300
298
  };
301
299
 
302
300
  type destination_Batch<Mapping> = Batch<Mapping>;
301
+ type destination_Code<T extends TypesGeneric$1 = Types$2> = Code<T>;
303
302
  type destination_DLQ = DLQ;
304
303
  type destination_Destinations = Destinations;
305
304
  type destination_InitContext<T extends TypesGeneric$1 = Types$2> = InitContext<T>;
@@ -313,7 +312,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
313
312
  type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
314
313
  type destination_Ref = Ref;
315
314
  declare namespace destination {
316
- export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$4 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$1 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 };
315
+ export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, 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 };
317
316
  }
318
317
 
319
318
  interface EventFn<R = Promise<PushResult>> {
@@ -326,7 +325,7 @@ interface Fn$1<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, Wa
326
325
  interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
327
326
  (event: 'walker config', config: Partial<Config>): R;
328
327
  (event: 'walker consent', consent: Consent): R;
329
- <T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$1<T>, config?: Config$4<T>): R;
328
+ <T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): R;
330
329
  <K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
331
330
  (event: 'walker on', type: Types$1, rules: SingleOrArray<Options>): R;
332
331
  (event: 'walker user', user: User): R;
@@ -361,7 +360,7 @@ declare namespace elb {
361
360
  * Platform-agnostic, runtime-focused.
362
361
  *
363
362
  * The Flow system enables "one config to rule them all" - a single
364
- * walkeros.config.json file that manages multiple environments
363
+ * walkeros.config.json file that manages multiple flows
365
364
  * (web_prod, web_stage, server_prod, etc.) with shared configuration,
366
365
  * variables, and reusable definitions.
367
366
  *
@@ -373,25 +372,68 @@ declare namespace elb {
373
372
  */
374
373
  type Primitive = string | number | boolean;
375
374
  /**
376
- * Complete multi-environment configuration.
377
- * This is the root type for walkeros.config.json files.
375
+ * Variables record type for interpolation.
376
+ * Used at Setup, Config, Source, and Destination levels.
377
+ */
378
+ type Variables = Record<string, Primitive>;
379
+ /**
380
+ * Definitions record type for reusable configurations.
381
+ * Used at Setup, Config, Source, and Destination levels.
382
+ */
383
+ type Definitions = Record<string, unknown>;
384
+ /**
385
+ * Packages configuration for build.
386
+ */
387
+ type Packages = Record<string, {
388
+ version?: string;
389
+ imports?: string[];
390
+ path?: string;
391
+ }>;
392
+ /**
393
+ * Web platform configuration.
394
+ *
395
+ * @remarks
396
+ * Presence of this key indicates web platform (browser-based tracking).
397
+ * Builds to IIFE format, ES2020 target, browser platform.
398
+ */
399
+ interface Web {
400
+ /**
401
+ * Window property name for collector instance.
402
+ * @default "collector"
403
+ */
404
+ windowCollector?: string;
405
+ /**
406
+ * Window property name for elb function.
407
+ * @default "elb"
408
+ */
409
+ windowElb?: string;
410
+ }
411
+ /**
412
+ * Server platform configuration.
413
+ *
414
+ * @remarks
415
+ * Presence of this key indicates server platform (Node.js).
416
+ * Builds to ESM format, Node18 target, node platform.
417
+ * Reserved for future server-specific options.
418
+ */
419
+ interface Server {
420
+ }
421
+ /**
422
+ * Complete multi-flow configuration.
423
+ * Root type for walkeros.config.json files.
378
424
  *
379
425
  * @remarks
380
- * The Setup interface represents the entire configuration file,
381
- * containing multiple named environments that can share variables
382
- * and definitions.
426
+ * If only one flow exists, it's auto-selected without --flow flag.
427
+ * Convention: use "default" as the flow name for single-flow configs.
383
428
  *
384
429
  * @example
385
430
  * ```json
386
431
  * {
387
432
  * "version": 1,
388
433
  * "$schema": "https://walkeros.io/schema/flow/v1.json",
389
- * "variables": {
390
- * "CURRENCY": "USD"
391
- * },
392
- * "environments": {
393
- * "web_prod": { "platform": "web", ... },
394
- * "server_prod": { "platform": "server", ... }
434
+ * "variables": { "CURRENCY": "USD" },
435
+ * "flows": {
436
+ * "default": { "web": {}, ... }
395
437
  * }
396
438
  * }
397
439
  * ```
@@ -399,141 +441,71 @@ type Primitive = string | number | boolean;
399
441
  interface Setup {
400
442
  /**
401
443
  * Configuration schema version.
402
- * Used for compatibility checks and migrations.
403
- *
404
- * @remarks
405
- * - Version 1: Initial Flow configuration system
406
- * - Future versions will be documented as they're released
407
444
  */
408
445
  version: 1;
409
446
  /**
410
- * JSON Schema reference for IDE validation and autocomplete.
411
- *
412
- * @remarks
413
- * When set, IDEs like VSCode will provide:
414
- * - Autocomplete for all fields
415
- * - Inline documentation
416
- * - Validation errors before deployment
417
- *
418
- * @example
419
- * "$schema": "https://walkeros.io/schema/flow/v1.json"
447
+ * JSON Schema reference for IDE validation.
448
+ * @example "https://walkeros.io/schema/flow/v1.json"
420
449
  */
421
450
  $schema?: string;
422
451
  /**
423
- * Shared variables for interpolation across all environments.
452
+ * Folders to include in the bundle output.
453
+ * These folders are copied to dist/ during bundle, making them available
454
+ * at runtime for both local and Docker execution.
424
455
  *
425
456
  * @remarks
426
- * Variables can be referenced using `${VAR_NAME:default}` syntax.
427
- * Resolution order:
428
- * 1. Environment variable (process.env.VAR_NAME)
429
- * 2. Config variable (config.variables.VAR_NAME)
430
- * 3. Inline default value
457
+ * Use for credential files, configuration, or other runtime assets.
458
+ * Paths are relative to the config file location.
459
+ * Default: `["./shared"]` if the folder exists, otherwise `[]`.
431
460
  *
432
461
  * @example
433
462
  * ```json
434
463
  * {
435
- * "variables": {
436
- * "CURRENCY": "USD",
437
- * "GA4_ID": "G-DEFAULT"
438
- * },
439
- * "environments": {
440
- * "prod": {
441
- * "collector": {
442
- * "globals": {
443
- * "currency": "${CURRENCY}"
444
- * }
445
- * }
446
- * }
447
- * }
464
+ * "include": ["./credentials", "./config"]
448
465
  * }
449
466
  * ```
450
467
  */
451
- variables?: Record<string, Primitive>;
468
+ include?: string[];
469
+ /**
470
+ * Shared variables for interpolation.
471
+ * Resolution: process.env > Config.variables > Setup.variables > inline default
472
+ * Syntax: ${VAR_NAME} or ${VAR_NAME:default}
473
+ */
474
+ variables?: Variables;
452
475
  /**
453
476
  * Reusable configuration definitions.
454
- *
455
- * @remarks
456
- * Definitions can be referenced using JSON Schema `$ref` syntax.
457
- * Useful for sharing mapping rules, common settings, etc.
458
- *
459
- * @example
460
- * ```json
461
- * {
462
- * "definitions": {
463
- * "gtag_base_mapping": {
464
- * "page": {
465
- * "view": { "name": "page_view" }
466
- * }
467
- * }
468
- * },
469
- * "environments": {
470
- * "prod": {
471
- * "destinations": {
472
- * "gtag": {
473
- * "config": {
474
- * "mapping": { "$ref": "#/definitions/gtag_base_mapping" }
475
- * }
476
- * }
477
- * }
478
- * }
479
- * }
480
- * }
481
- * ```
477
+ * Referenced via JSON Schema $ref syntax: { "$ref": "#/definitions/name" }
482
478
  */
483
- definitions?: Record<string, unknown>;
479
+ definitions?: Definitions;
484
480
  /**
485
- * Named environment configurations.
486
- *
487
- * @remarks
488
- * Each environment represents a deployment target:
489
- * - web_prod, web_stage, web_dev (client-side tracking)
490
- * - server_prod, server_stage (server-side collection)
491
- *
492
- * Environment names are arbitrary and user-defined.
493
- *
494
- * @example
495
- * ```json
496
- * {
497
- * "environments": {
498
- * "web_prod": {
499
- * "platform": "web",
500
- * "sources": { ... },
501
- * "destinations": { ... }
502
- * },
503
- * "server_prod": {
504
- * "platform": "server",
505
- * "destinations": { ... }
506
- * }
507
- * }
508
- * }
509
- * ```
481
+ * Named flow configurations.
482
+ * If only one flow exists, it's auto-selected.
510
483
  */
511
- environments: Record<string, Config$3>;
484
+ flows: Record<string, Config$4>;
512
485
  }
513
486
  /**
514
- * Single environment configuration.
487
+ * Single flow configuration.
515
488
  * Represents one deployment target (e.g., web_prod, server_stage).
516
489
  *
517
490
  * @remarks
518
- * This is the core runtime configuration used by `startFlow()`.
519
- * Platform-agnostic and independent of build/deployment tools.
491
+ * Platform is determined by presence of `web` or `server` key.
492
+ * Exactly one must be present.
520
493
  *
521
- * Extensions (build, docker, etc.) are added via `[key: string]: unknown`.
494
+ * Variables/definitions cascade: source/destination > config > setup
522
495
  */
523
- interface Config$3 {
496
+ interface Config$4 {
524
497
  /**
525
- * Target platform for this environment.
526
- *
527
- * @remarks
528
- * - `web`: Browser-based tracking (IIFE bundles, browser sources)
529
- * - `server`: Node.js server-side collection (CJS bundles, HTTP sources)
530
- *
531
- * This determines:
532
- * - Available packages (web-* vs server-*)
533
- * - Default build settings
534
- * - Template selection
498
+ * Web platform configuration.
499
+ * Presence indicates web platform (browser-based tracking).
500
+ * Mutually exclusive with `server`.
535
501
  */
536
- platform: 'web' | 'server';
502
+ web?: Web;
503
+ /**
504
+ * Server platform configuration.
505
+ * Presence indicates server platform (Node.js).
506
+ * Mutually exclusive with `web`.
507
+ */
508
+ server?: Server;
537
509
  /**
538
510
  * Source configurations (data capture).
539
511
  *
@@ -628,35 +600,19 @@ interface Config$3 {
628
600
  */
629
601
  collector?: InitConfig;
630
602
  /**
631
- * Environment-specific variables.
632
- *
633
- * @remarks
634
- * These override root-level variables for this specific environment.
635
- * Useful for environment-specific API keys, endpoints, etc.
636
- *
637
- * @example
638
- * ```json
639
- * {
640
- * "env": {
641
- * "API_ENDPOINT": "https://api.production.com",
642
- * "DEBUG": "false"
643
- * }
644
- * }
645
- * ```
603
+ * NPM packages to bundle.
646
604
  */
647
- env?: Record<string, string>;
605
+ packages?: Packages;
648
606
  /**
649
- * Extension point for package-specific fields.
650
- *
651
- * @remarks
652
- * Allows packages to add their own configuration fields:
653
- * - CLI adds `build` field (Bundle.Config)
654
- * - Docker adds `docker` field (Docker.Config)
655
- * - Lambda adds `lambda` field (Lambda.Config)
656
- *
657
- * Core doesn't validate these fields - packages handle validation.
607
+ * Flow-level variables.
608
+ * Override Setup.variables, overridden by source/destination variables.
658
609
  */
659
- [key: string]: unknown;
610
+ variables?: Variables;
611
+ /**
612
+ * Flow-level definitions.
613
+ * Extend Setup.definitions, overridden by source/destination definitions.
614
+ */
615
+ definitions?: Definitions;
660
616
  }
661
617
  /**
662
618
  * Source reference with inline package syntax.
@@ -685,6 +641,14 @@ interface SourceReference {
685
641
  * "package": "@walkeros/web-source-browser@latest"
686
642
  */
687
643
  package: string;
644
+ /**
645
+ * Resolved import variable name.
646
+ *
647
+ * @remarks
648
+ * Auto-resolved from packages[package].imports[0] during getFlowConfig().
649
+ * Can also be provided explicitly for advanced use cases.
650
+ */
651
+ code?: string;
688
652
  /**
689
653
  * Source-specific configuration.
690
654
  *
@@ -720,11 +684,21 @@ interface SourceReference {
720
684
  *
721
685
  * @remarks
722
686
  * The primary source's ELB function is returned by `startFlow()`.
723
- * Only one source should be marked as primary per environment.
687
+ * Only one source should be marked as primary per flow.
724
688
  *
725
689
  * @default false
726
690
  */
727
691
  primary?: boolean;
692
+ /**
693
+ * Source-level variables (highest priority in cascade).
694
+ * Overrides flow and setup variables.
695
+ */
696
+ variables?: Variables;
697
+ /**
698
+ * Source-level definitions (highest priority in cascade).
699
+ * Overrides flow and setup definitions.
700
+ */
701
+ definitions?: Definitions;
728
702
  }
729
703
  /**
730
704
  * Destination reference with inline package syntax.
@@ -744,6 +718,14 @@ interface DestinationReference {
744
718
  * "package": "@walkeros/web-destination-gtag@2.0.0"
745
719
  */
746
720
  package: string;
721
+ /**
722
+ * Resolved import variable name.
723
+ *
724
+ * @remarks
725
+ * Auto-resolved from packages[package].imports[0] during getFlowConfig().
726
+ * Can also be provided explicitly for advanced use cases.
727
+ */
728
+ code?: string;
747
729
  /**
748
730
  * Destination-specific configuration.
749
731
  *
@@ -785,23 +767,29 @@ interface DestinationReference {
785
767
  * Merged with default destination environment.
786
768
  */
787
769
  env?: unknown;
770
+ /**
771
+ * Destination-level variables (highest priority in cascade).
772
+ * Overrides flow and setup variables.
773
+ */
774
+ variables?: Variables;
775
+ /**
776
+ * Destination-level definitions (highest priority in cascade).
777
+ * Overrides flow and setup definitions.
778
+ */
779
+ definitions?: Definitions;
788
780
  }
789
781
 
782
+ type flow_Definitions = Definitions;
790
783
  type flow_DestinationReference = DestinationReference;
784
+ type flow_Packages = Packages;
791
785
  type flow_Primitive = Primitive;
786
+ type flow_Server = Server;
792
787
  type flow_Setup = Setup;
793
788
  type flow_SourceReference = SourceReference;
789
+ type flow_Variables = Variables;
790
+ type flow_Web = Web;
794
791
  declare namespace flow {
795
- export type { Config$3 as Config, flow_DestinationReference as DestinationReference, flow_Primitive as Primitive, flow_Setup as Setup, flow_SourceReference as SourceReference };
796
- }
797
-
798
- type Error = (error: unknown, state?: unknown) => void;
799
- type Log = (message: string, verbose?: boolean) => void;
800
-
801
- type handler_Error = Error;
802
- type handler_Log = Log;
803
- declare namespace handler {
804
- export type { handler_Error as Error, handler_Log as Log };
792
+ 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 };
805
793
  }
806
794
 
807
795
  type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
@@ -820,6 +808,121 @@ declare namespace hooks {
820
808
  export type { AnyFunction$1 as AnyFunction, hooks_Functions as Functions, hooks_HookFn as HookFn };
821
809
  }
822
810
 
811
+ /**
812
+ * Log levels from most to least severe
813
+ */
814
+ declare enum Level {
815
+ ERROR = 0,
816
+ INFO = 1,
817
+ DEBUG = 2
818
+ }
819
+ /**
820
+ * Normalized error context extracted from Error objects
821
+ */
822
+ interface ErrorContext {
823
+ message: string;
824
+ name: string;
825
+ stack?: string;
826
+ cause?: unknown;
827
+ }
828
+ /**
829
+ * Context passed to log handlers
830
+ * If an Error was passed, it's normalized into the error property
831
+ */
832
+ interface LogContext {
833
+ [key: string]: unknown;
834
+ error?: ErrorContext;
835
+ }
836
+ /**
837
+ * Log message function signature
838
+ * Accepts string or Error as message, with optional context
839
+ */
840
+ type LogFn = (message: string | Error, context?: unknown | Error) => void;
841
+ /**
842
+ * Throw function signature - logs error then throws
843
+ * Returns never as it always throws
844
+ */
845
+ type ThrowFn = (message: string | Error, context?: unknown) => never;
846
+ /**
847
+ * Default handler function (passed to custom handlers for chaining)
848
+ */
849
+ type DefaultHandler = (level: Level, message: string, context: LogContext, scope: string[]) => void;
850
+ /**
851
+ * Custom log handler function
852
+ * Receives originalHandler to allow middleware-style chaining
853
+ */
854
+ type Handler = (level: Level, message: string, context: LogContext, scope: string[], originalHandler: DefaultHandler) => void;
855
+ /**
856
+ * Logger instance with scoping support
857
+ * All logs automatically include trace path from scoping
858
+ */
859
+ interface Instance$1 {
860
+ /**
861
+ * Log an error message (always visible unless silenced)
862
+ */
863
+ error: LogFn;
864
+ /**
865
+ * Log an informational message
866
+ */
867
+ info: LogFn;
868
+ /**
869
+ * Log a debug message
870
+ */
871
+ debug: LogFn;
872
+ /**
873
+ * Log an error message and throw an Error
874
+ * Combines logging and throwing in one call
875
+ */
876
+ throw: ThrowFn;
877
+ /**
878
+ * Create a scoped child logger with automatic trace path
879
+ * @param name - Scope name (e.g., destination type, destination key)
880
+ * @returns A new logger instance with the scope applied
881
+ */
882
+ scope: (name: string) => Instance$1;
883
+ }
884
+ /**
885
+ * Logger configuration options
886
+ */
887
+ interface Config$3 {
888
+ /**
889
+ * Minimum log level to display
890
+ * @default Level.ERROR
891
+ */
892
+ level?: Level | keyof typeof Level;
893
+ /**
894
+ * Custom log handler function
895
+ * Receives originalHandler to preserve default behavior
896
+ */
897
+ handler?: Handler;
898
+ }
899
+ /**
900
+ * Internal config with resolved values and scope
901
+ */
902
+ interface InternalConfig {
903
+ level: Level;
904
+ handler?: Handler;
905
+ scope: string[];
906
+ }
907
+ /**
908
+ * Logger factory function type
909
+ */
910
+ type Factory = (config?: Config$3) => Instance$1;
911
+
912
+ type logger_DefaultHandler = DefaultHandler;
913
+ type logger_ErrorContext = ErrorContext;
914
+ type logger_Factory = Factory;
915
+ type logger_Handler = Handler;
916
+ type logger_InternalConfig = InternalConfig;
917
+ type logger_Level = Level;
918
+ declare const logger_Level: typeof Level;
919
+ type logger_LogContext = LogContext;
920
+ type logger_LogFn = LogFn;
921
+ type logger_ThrowFn = ThrowFn;
922
+ declare namespace logger {
923
+ 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 };
924
+ }
925
+
823
926
  /**
824
927
  * Shared mapping configuration interface.
825
928
  * Used by both Source.Config and Destination.Config.
@@ -838,7 +941,7 @@ interface Rules<T = Rule> {
838
941
  }
839
942
  interface Rule<Settings = unknown> {
840
943
  batch?: number;
841
- batchFn?: (destination: Instance$1, collector: Instance$2) => void;
944
+ batchFn?: (destination: Instance$2, collector: Instance$3) => void;
842
945
  batched?: Batch<Settings>;
843
946
  condition?: Condition;
844
947
  consent?: Consent;
@@ -867,7 +970,7 @@ interface ValueConfig {
867
970
  validate?: Validate;
868
971
  value?: PropertyType;
869
972
  }
870
- type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$2) => PromiseOrValue<boolean>;
973
+ type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$3) => PromiseOrValue<boolean>;
871
974
  type Fn = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
872
975
  type Loop = [Value, Value];
873
976
  type Map = {
@@ -875,7 +978,7 @@ type Map = {
875
978
  };
876
979
  interface Options$1 {
877
980
  consent?: Consent;
878
- collector?: Instance$2;
981
+ collector?: Instance$3;
879
982
  props?: unknown;
880
983
  }
881
984
  type Validate = (value?: unknown) => PromiseOrValue<boolean>;
@@ -921,13 +1024,13 @@ type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
921
1024
  interface ConsentConfig {
922
1025
  [key: string]: ConsentFn;
923
1026
  }
924
- type ConsentFn = (collector: Instance$2, consent: Consent) => void;
1027
+ type ConsentFn = (collector: Instance$3, consent: Consent) => void;
925
1028
  type ReadyConfig = ReadyFn;
926
- type ReadyFn = (collector: Instance$2) => void;
1029
+ type ReadyFn = (collector: Instance$3) => void;
927
1030
  type RunConfig = RunFn;
928
- type RunFn = (collector: Instance$2) => void;
1031
+ type RunFn = (collector: Instance$3) => void;
929
1032
  type SessionConfig = SessionFn;
930
- type SessionFn = (collector: Instance$2, session?: unknown) => void;
1033
+ type SessionFn = (collector: Instance$3, session?: unknown) => void;
931
1034
  interface OnConfig {
932
1035
  consent?: ConsentConfig[];
933
1036
  ready?: ReadyConfig[];
@@ -935,8 +1038,8 @@ interface OnConfig {
935
1038
  session?: SessionConfig[];
936
1039
  [key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
937
1040
  }
938
- type OnFn = <T extends Types$1>(event: T, context: EventContextMap[T]) => PromiseOrValue<void>;
939
- type OnFnRuntime = (event: Types$1, context: AnyEventContext) => PromiseOrValue<void>;
1041
+ type OnFn<T extends TypesGeneric$1 = Types$2> = (type: Types$1, context: Context$2<T>) => PromiseOrValue<void>;
1042
+ type OnFnRuntime = (type: Types$1, context: Context$2) => PromiseOrValue<void>;
940
1043
 
941
1044
  type on_AnyEventContext = AnyEventContext;
942
1045
  type on_ConsentConfig = ConsentConfig;
@@ -944,7 +1047,7 @@ type on_ConsentFn = ConsentFn;
944
1047
  type on_EventContext<T extends Types$1> = EventContext<T>;
945
1048
  type on_EventContextMap = EventContextMap;
946
1049
  type on_OnConfig = OnConfig;
947
- type on_OnFn = OnFn;
1050
+ type on_OnFn<T extends TypesGeneric$1 = Types$2> = OnFn<T>;
948
1051
  type on_OnFnRuntime = OnFnRuntime;
949
1052
  type on_Options = Options;
950
1053
  type on_ReadyConfig = ReadyConfig;
@@ -1015,6 +1118,7 @@ interface BaseEnv {
1015
1118
  command: CommandFn;
1016
1119
  sources?: Sources;
1017
1120
  elb: Fn$1;
1121
+ logger: Instance$1;
1018
1122
  }
1019
1123
  /**
1020
1124
  * Type bundle for source generics.
@@ -1059,7 +1163,7 @@ interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
1059
1163
  settings?: InitSettings<T>;
1060
1164
  env?: Env<T>;
1061
1165
  id?: string;
1062
- onError?: Error;
1166
+ logger?: Config$3;
1063
1167
  disabled?: boolean;
1064
1168
  primary?: boolean;
1065
1169
  }
@@ -1249,6 +1353,61 @@ interface SendResponse {
1249
1353
  */
1250
1354
  declare function anonymizeIP(ip: string): string;
1251
1355
 
1356
+ /**
1357
+ * Flow Configuration Utilities
1358
+ *
1359
+ * Functions for resolving and processing Flow configurations.
1360
+ *
1361
+ * @packageDocumentation
1362
+ */
1363
+
1364
+ /**
1365
+ * Convert package name to valid JavaScript variable name.
1366
+ * Used for deterministic default import naming.
1367
+ * @example
1368
+ * packageNameToVariable('@walkeros/server-destination-api')
1369
+ * // → '_walkerosServerDestinationApi'
1370
+ */
1371
+ declare function packageNameToVariable(packageName: string): string;
1372
+ /**
1373
+ * Get resolved flow configuration for a named flow.
1374
+ *
1375
+ * @param setup - The complete setup configuration
1376
+ * @param flowName - Flow name (auto-selected if only one exists)
1377
+ * @returns Resolved Config with variables/definitions interpolated and $refs resolved
1378
+ * @throws Error if flow selection is required but not specified, or flow not found
1379
+ *
1380
+ * @example
1381
+ * ```typescript
1382
+ * import { getFlowConfig } from '@walkeros/core';
1383
+ *
1384
+ * const setup = JSON.parse(fs.readFileSync('walkeros.config.json', 'utf8'));
1385
+ *
1386
+ * // Auto-select if only one flow
1387
+ * const config = getFlowConfig(setup);
1388
+ *
1389
+ * // Or specify flow
1390
+ * const prodConfig = getFlowConfig(setup, 'production');
1391
+ * ```
1392
+ */
1393
+ declare function getFlowConfig(setup: Setup, flowName?: string): Config$4;
1394
+ /**
1395
+ * Get platform from config (web or server).
1396
+ *
1397
+ * @param config - Flow configuration
1398
+ * @returns "web" or "server"
1399
+ * @throws Error if neither web nor server is present
1400
+ *
1401
+ * @example
1402
+ * ```typescript
1403
+ * import { getPlatform } from '@walkeros/core';
1404
+ *
1405
+ * const platform = getPlatform(config);
1406
+ * // Returns "web" or "server"
1407
+ * ```
1408
+ */
1409
+ declare function getPlatform(config: Config$4): 'web' | 'server';
1410
+
1252
1411
  /**
1253
1412
  * @interface Assign
1254
1413
  * @description Options for the assign function.
@@ -1343,7 +1502,7 @@ declare function getGrantedConsent(required: Consent | undefined, state?: Consen
1343
1502
  * }));
1344
1503
  * ```
1345
1504
  */
1346
- declare function createDestination<I extends Instance$1>(baseDestination: I, config: Partial<Config$4<TypesOf$1<I>>>): I;
1505
+ declare function createDestination<I extends Instance$2>(baseDestination: I, config: Partial<Config$5<TypesOf$1<I>>>): I;
1347
1506
 
1348
1507
  /**
1349
1508
  * Creates a complete event with default values.
@@ -1477,6 +1636,36 @@ declare function isSameType<T>(variable: unknown, type: T): variable is typeof t
1477
1636
  */
1478
1637
  declare function isString(value: unknown): value is string;
1479
1638
 
1639
+ /**
1640
+ * Create a logger instance
1641
+ *
1642
+ * @param config - Logger configuration
1643
+ * @returns Logger instance with all log methods and scoping support
1644
+ *
1645
+ * @example
1646
+ * ```typescript
1647
+ * // Basic usage
1648
+ * const logger = createLogger({ level: 'DEBUG' });
1649
+ * logger.info('Hello world');
1650
+ *
1651
+ * // With scoping
1652
+ * const destLogger = logger.scope('gtag').scope('myInstance');
1653
+ * destLogger.debug('Processing event'); // DEBUG [gtag:myInstance] Processing event
1654
+ *
1655
+ * // With custom handler
1656
+ * const logger = createLogger({
1657
+ * handler: (level, message, context, scope, originalHandler) => {
1658
+ * // Custom logic (e.g., send to Sentry)
1659
+ * originalHandler(level, message, context, scope);
1660
+ * }
1661
+ * });
1662
+ * ```
1663
+ *
1664
+ * // TODO: Consider compile-time stripping of debug logs in production builds
1665
+ * // e.g., if (__DEV__) { logger.debug(...) }
1666
+ */
1667
+ declare function createLogger(config?: Config$3): Instance$1;
1668
+
1480
1669
  /**
1481
1670
  * Gets the mapping for an event.
1482
1671
  *
@@ -1513,7 +1702,7 @@ declare function getMappingValue(value: DeepPartialEvent | unknown | undefined,
1513
1702
  * @param collector - Collector instance for context
1514
1703
  * @returns Object with transformed event, data, mapping rule, and ignore flag
1515
1704
  */
1516
- declare function processEventMapping<T extends DeepPartialEvent | Event>(event: T, config: Config$2, collector: Instance$2): Promise<{
1705
+ declare function processEventMapping<T extends DeepPartialEvent | Event>(event: T, config: Config$2, collector: Instance$3): Promise<{
1517
1706
  event: T;
1518
1707
  data?: Property;
1519
1708
  mapping?: Rule;
@@ -1588,12 +1777,42 @@ declare function mockEnv<T extends object>(env: T, interceptor: InterceptorFn):
1588
1777
  declare function traverseEnv<T extends object>(env: T, replacer: (value: unknown, path: string[]) => unknown): T;
1589
1778
 
1590
1779
  /**
1591
- * Logs a message to the console if verbose logging is enabled.
1780
+ * Mock logger instance for testing
1781
+ * Includes all logger methods as jest.fn() plus tracking of scoped loggers
1782
+ * Extends Instance to ensure type compatibility
1783
+ */
1784
+ interface MockLogger extends Instance$1 {
1785
+ error: jest.Mock;
1786
+ info: jest.Mock;
1787
+ debug: jest.Mock;
1788
+ throw: jest.Mock<never, [string | Error, unknown?]>;
1789
+ scope: jest.Mock<MockLogger, [string]>;
1790
+ /**
1791
+ * Array of all scoped loggers created by this logger
1792
+ * Useful for asserting on scoped logger calls in tests
1793
+ */
1794
+ scopedLoggers: MockLogger[];
1795
+ }
1796
+ /**
1797
+ * Create a mock logger for testing
1798
+ * All methods are jest.fn() that can be used for assertions
1799
+ *
1800
+ * @example
1801
+ * ```typescript
1802
+ * const mockLogger = createMockLogger();
1803
+ *
1804
+ * // Use in code under test
1805
+ * someFunction(mockLogger);
1592
1806
  *
1593
- * @param message The message to log.
1594
- * @param verbose Whether to log the message.
1807
+ * // Assert on calls
1808
+ * expect(mockLogger.error).toHaveBeenCalledWith('error message');
1809
+ *
1810
+ * // Assert on scoped logger
1811
+ * const scoped = mockLogger.scopedLoggers[0];
1812
+ * expect(scoped.debug).toHaveBeenCalledWith('debug in scope');
1813
+ * ```
1595
1814
  */
1596
- declare function onLog(message: unknown, verbose?: boolean): void;
1815
+ declare function createMockLogger(): MockLogger;
1597
1816
 
1598
1817
  /**
1599
1818
  * Checks if a value is a valid property type.
@@ -1758,4 +1977,87 @@ declare function validateEvent(obj: unknown, customContracts?: Contracts): Event
1758
1977
  */
1759
1978
  declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
1760
1979
 
1761
- export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, 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, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, 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, mockEnv, onLog, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty };
1980
+ /**
1981
+ * Inline Code Wrapping Utilities
1982
+ *
1983
+ * Converts inline code strings to executable functions.
1984
+ * Used for mapping properties: condition, fn, validate.
1985
+ *
1986
+ * @packageDocumentation
1987
+ */
1988
+
1989
+ /**
1990
+ * Wrap inline code string as Condition function.
1991
+ *
1992
+ * @param code - Inline code string
1993
+ * @returns Condition function matching Mapping.Condition signature
1994
+ *
1995
+ * @remarks
1996
+ * Available parameters in code:
1997
+ * - `value` - The event or partial event being processed
1998
+ * - `mapping` - Current mapping configuration
1999
+ * - `collector` - Collector instance
2000
+ *
2001
+ * If code has no explicit return, it's auto-wrapped with `return`.
2002
+ *
2003
+ * @example
2004
+ * ```typescript
2005
+ * // One-liner (auto-wrapped)
2006
+ * const fn = wrapCondition('value.data.total > 100');
2007
+ * fn(event, mapping, collector); // returns boolean
2008
+ *
2009
+ * // Multi-statement (explicit return)
2010
+ * const fn = wrapCondition('const threshold = 100; return value.data.total > threshold');
2011
+ * ```
2012
+ */
2013
+ declare function wrapCondition(code: string): Condition;
2014
+ /**
2015
+ * Wrap inline code string as Fn function.
2016
+ *
2017
+ * @param code - Inline code string
2018
+ * @returns Fn function matching Mapping.Fn signature
2019
+ *
2020
+ * @remarks
2021
+ * Available parameters in code:
2022
+ * - `value` - The event or partial event being processed
2023
+ * - `mapping` - Current mapping configuration
2024
+ * - `options` - Options object with consent and collector
2025
+ *
2026
+ * If code has no explicit return, it's auto-wrapped with `return`.
2027
+ *
2028
+ * @example
2029
+ * ```typescript
2030
+ * // One-liner (auto-wrapped)
2031
+ * const fn = wrapFn('value.user.email.split("@")[1]');
2032
+ * fn(event, mapping, options); // returns domain
2033
+ *
2034
+ * // Multi-statement (explicit return)
2035
+ * const fn = wrapFn('const parts = value.user.email.split("@"); return parts[1].toUpperCase()');
2036
+ * ```
2037
+ */
2038
+ declare function wrapFn(code: string): Fn;
2039
+ /**
2040
+ * Wrap inline code string as Validate function.
2041
+ *
2042
+ * @param code - Inline code string
2043
+ * @returns Validate function matching Mapping.Validate signature
2044
+ *
2045
+ * @remarks
2046
+ * Available parameters in code:
2047
+ * - `value` - The current value being validated
2048
+ *
2049
+ * If code has no explicit return, it's auto-wrapped with `return`.
2050
+ *
2051
+ * @example
2052
+ * ```typescript
2053
+ * // One-liner (auto-wrapped)
2054
+ * const fn = wrapValidate('value && value.length > 0');
2055
+ * fn('hello'); // returns true
2056
+ *
2057
+ * // Multi-statement (explicit return)
2058
+ * const fn = wrapValidate('if (!value) return false; return value.length > 0');
2059
+ * ```
2060
+ */
2061
+ declare function wrapValidate(code: string): Validate;
2062
+
2063
+ 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 };