@walkeros/core 4.0.1-next-1778284185788 → 4.0.2

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
@@ -75,7 +75,7 @@ interface Context$6 {
75
75
  /** The surrounding mapping config: a Value (value-level) or a Rule (rule-level). */
76
76
  mapping: Value | Rule;
77
77
  collector: Instance$6;
78
- logger: Instance$4;
78
+ logger: Instance$3;
79
79
  consent?: Consent;
80
80
  }
81
81
  type Fn$4 = (value: unknown, context: Context$6) => PromiseOrValue<Property | unknown>;
@@ -184,7 +184,7 @@ interface Config$6 {
184
184
  /** Static session data even on a new run */
185
185
  sessionStatic: Partial<SessionData>;
186
186
  /** Logger configuration */
187
- logger?: Config$4;
187
+ logger?: Config$3;
188
188
  }
189
189
  /**
190
190
  * Initialization configuration that extends Config with initial state
@@ -247,7 +247,7 @@ interface Destinations$1 {
247
247
  [id: string]: Instance$5;
248
248
  }
249
249
  interface Transformers$1 {
250
- [id: string]: Instance$3;
250
+ [id: string]: Instance$4;
251
251
  }
252
252
  interface Stores$1 {
253
253
  [id: string]: Instance$1;
@@ -280,7 +280,7 @@ interface CommandFn {
280
280
  (command: 'consent', consent: Consent): Promise<PushResult>;
281
281
  <T extends Types$4>(command: 'destination', destination: Init$3<T> | Instance$5<T>, config?: Config$5<T>): Promise<PushResult>;
282
282
  <K extends keyof Functions>(command: 'hook', name: K, hookFn: Functions[K]): Promise<PushResult>;
283
- (command: 'on', type: Types$3, rules: SingleOrArray<Subscription>): Promise<PushResult>;
283
+ (command: 'on', type: Types$2, rules: SingleOrArray<Subscription>): Promise<PushResult>;
284
284
  (command: 'user', user: User): Promise<PushResult>;
285
285
  (command: 'run', runState?: {
286
286
  consent?: Consent;
@@ -303,7 +303,7 @@ interface Instance$6 {
303
303
  stores: Stores$1;
304
304
  globals: Properties;
305
305
  hooks: Functions;
306
- logger: Instance$4;
306
+ logger: Instance$3;
307
307
  on: OnConfig;
308
308
  queue: Events;
309
309
  round: number;
@@ -335,7 +335,7 @@ declare namespace collector {
335
335
  */
336
336
  interface Base<C = unknown, E = unknown> {
337
337
  collector: Instance$6;
338
- logger: Instance$4;
338
+ logger: Instance$3;
339
339
  config: C;
340
340
  env: E;
341
341
  }
@@ -353,7 +353,7 @@ interface LifecycleContext<C = unknown, E = unknown> {
353
353
  id: string;
354
354
  config: C;
355
355
  env: E;
356
- logger: Instance$4;
356
+ logger: Instance$3;
357
357
  }
358
358
  /**
359
359
  * Setup function signature. Called once via `walkeros setup <kind>.<name>`.
@@ -429,7 +429,7 @@ interface Instance$5<T extends TypesGeneric$3 = Types$4> {
429
429
  config: Config$5<T>;
430
430
  queuePush?: Events;
431
431
  queueOn?: Array<{
432
- type: Types$3;
432
+ type: Types$2;
433
433
  data?: unknown;
434
434
  }>;
435
435
  dlq?: DLQ;
@@ -461,7 +461,7 @@ interface Config$5<T extends TypesGeneric$3 = Types$4> {
461
461
  /** Whether to load external scripts (e.g., gtag.js); destination-specific behavior. */
462
462
  loadScript?: boolean;
463
463
  /** Logger configuration (level, handler) to override the collector's defaults. */
464
- logger?: Config$4;
464
+ logger?: Config$3;
465
465
  /** Entity-action rules to filter, rename, transform, and batch events for this destination. */
466
466
  mapping?: Rules<Rule<Mapping$1<T>>>;
467
467
  /** Pre-processing rules applied to all events before mapping; modifies events in-place. */
@@ -471,14 +471,14 @@ interface Config$5<T extends TypesGeneric$3 = Types$4> {
471
471
  /** Defer destination initialization until these collector events fire (e.g., `['consent']`). */
472
472
  require?: string[];
473
473
  /**
474
- * Provisioning options for `walker setup`. `boolean | object`.
474
+ * Provisioning options for `walkeros setup`. `boolean | object`.
475
475
  * Triggered only by explicit CLI invocation; never automatic.
476
476
  */
477
477
  setup?: boolean | SetupOptions$2<T>;
478
478
  /** Transformer chain to run after collector processing but before this destination. */
479
- before?: Next;
479
+ before?: RouteSpec;
480
480
  /** Transformer chain to run after destination push completes. Push response available at ingest._response. */
481
- next?: Next;
481
+ next?: RouteSpec;
482
482
  /** Cache configuration for deduplication (step-level: skip push on HIT). */
483
483
  cache?: Cache;
484
484
  /** Completely skip this destination — no init, no push, no queuing. */
@@ -495,8 +495,8 @@ type Init$3<T extends TypesGeneric$3 = Types$4> = {
495
495
  code: Code$1<T>;
496
496
  config?: Partial<Config$5<T>>;
497
497
  env?: Partial<Env$3<T>>;
498
- before?: Next;
499
- next?: Next;
498
+ before?: RouteSpec;
499
+ next?: RouteSpec;
500
500
  cache?: Cache;
501
501
  };
502
502
  interface InitDestinations {
@@ -583,7 +583,7 @@ interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
583
583
  (event: 'walker consent', consent: Consent): R;
584
584
  <T extends Types$4>(event: 'walker destination', destination: Init$3<T> | Instance$5<T>, config?: Config$5<T>): R;
585
585
  <K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
586
- (event: 'walker on', type: Types$3, rules: SingleOrArray<Subscription>): R;
586
+ (event: 'walker on', type: Types$2, rules: SingleOrArray<Subscription>): R;
587
587
  (event: 'walker user', user: User): R;
588
588
  (event: 'walker run', runState: {
589
589
  consent?: Consent;
@@ -612,6 +612,194 @@ declare namespace elb {
612
612
  export type { Event$1 as Event, elb_EventFn as EventFn, Fn$3 as Fn, elb_Layer as Layer, elb_PushData as PushData, elb_PushResult as PushResult, elb_WalkerCommands as WalkerCommands };
613
613
  }
614
614
 
615
+ /**
616
+ * A single conditional routing rule. Pairs a `match` expression (or `'*'`
617
+ * wildcard) against ingest metadata with a `next` step to follow when the
618
+ * match fires. Used inside `Route[]` arrays on `Flow.Source.next`,
619
+ * `Flow.Source.before`, `Flow.Transformer.next/before`, and
620
+ * `Flow.Destination.next/before`. Routes are evaluated in order, first match
621
+ * wins, no match falls through unchanged. The `next` field of a Route
622
+ * mirrors the outer-position `next` semantics: it points to whatever comes
623
+ * downstream when this rule fires.
624
+ */
625
+ interface Route {
626
+ match: MatchExpression | '*';
627
+ next: RouteSpec;
628
+ }
629
+ /**
630
+ * The union accepted at every chain-routing boundary. A plain `string`
631
+ * targets one step by ID; `string[]` declares an explicit sequence ignoring
632
+ * per-step `next`; `Route[]` enables conditional routing on ingest metadata.
633
+ * At runtime, `compileNext()` collapses any RouteSpec into a `CompiledNext`
634
+ * (static, chain, or routes form) for hot-path evaluation. Surfaces via
635
+ * `Flow.Source.before/next`, `Flow.Transformer.before/next`,
636
+ * `Flow.Destination.before/next`.
637
+ */
638
+ type RouteSpec = string | string[] | Route[];
639
+ /**
640
+ * Base environment interface for walkerOS transformers.
641
+ *
642
+ * Minimal like Destination - just an extensible object.
643
+ * Transformers receive dependencies through context, not env.
644
+ */
645
+ interface BaseEnv$2 {
646
+ [key: string]: unknown;
647
+ }
648
+ /**
649
+ * Type bundle for transformer generics.
650
+ * Groups Settings, InitSettings, and Env into a single type parameter.
651
+ * Follows the Source/Destination pattern.
652
+ *
653
+ * @template S - Settings configuration type
654
+ * @template E - Environment type
655
+ * @template I - InitSettings configuration type (user input)
656
+ */
657
+ interface Types$3<S = unknown, E = BaseEnv$2, I = S> {
658
+ settings: S;
659
+ initSettings: I;
660
+ env: E;
661
+ }
662
+ /**
663
+ * Generic constraint for Types - ensures T has required properties for indexed access.
664
+ */
665
+ type TypesGeneric$2 = {
666
+ settings: any;
667
+ initSettings: any;
668
+ env: any;
669
+ };
670
+ /**
671
+ * Type extractors for consistent usage with Types bundle.
672
+ */
673
+ type Settings$2<T extends TypesGeneric$2 = Types$3> = T['settings'];
674
+ type InitSettings$2<T extends TypesGeneric$2 = Types$3> = T['initSettings'];
675
+ type Env$2<T extends TypesGeneric$2 = Types$3> = T['env'];
676
+ /**
677
+ * Inference helper: Extract Types from Instance.
678
+ */
679
+ type TypesOf$2<I> = I extends Instance$4<infer T> ? T : never;
680
+ /**
681
+ * Transformer configuration.
682
+ */
683
+ interface Config$4<T extends TypesGeneric$2 = Types$3> {
684
+ settings?: InitSettings$2<T>;
685
+ env?: Env$2<T>;
686
+ id?: string;
687
+ logger?: Config$3;
688
+ before?: RouteSpec;
689
+ next?: RouteSpec;
690
+ cache?: Cache;
691
+ init?: boolean;
692
+ disabled?: boolean;
693
+ /** Return this value instead of calling push(). Global mock for all chains. */
694
+ mock?: unknown;
695
+ /** Path-specific mock values keyed by chain path (e.g., "destination.ga4.before"). Takes precedence over global mock. */
696
+ chainMocks?: Record<string, unknown>;
697
+ }
698
+ /**
699
+ * Context provided to transformer functions.
700
+ * Extends base context with transformer-specific properties.
701
+ */
702
+ interface Context$4<T extends TypesGeneric$2 = Types$3> extends Base<Config$4<T>, Env$2<T>> {
703
+ id: string;
704
+ ingest: Ingest;
705
+ }
706
+ /**
707
+ * Unified result type for transformer functions.
708
+ * Replaces the old union return type with a structured object.
709
+ *
710
+ * @field event - Modified event to continue with
711
+ * @field respond - Wrapped respond function for downstream transformers
712
+ * @field next - Branch to a different chain (replaces BranchResult)
713
+ */
714
+ interface Result$1<E = DeepPartialEvent> {
715
+ event?: E;
716
+ respond?: RespondFn;
717
+ next?: RouteSpec;
718
+ }
719
+ /**
720
+ * Result of running a transformer chain.
721
+ * Returns the processed event (singular, fan-out array, or null if dropped)
722
+ * alongside the potentially wrapped respond function.
723
+ */
724
+ interface ChainResult {
725
+ event: DeepPartialEvent | DeepPartialEvent[] | null;
726
+ respond?: RespondFn;
727
+ }
728
+ /**
729
+ * The main transformer function.
730
+ *
731
+ * Pre-collector transformers use default E = DeepPartialEvent.
732
+ * Post-collector transformers can use E = Event for type-safe access.
733
+ * A transformer written for DeepPartialEvent works in both positions
734
+ * because Event is a subtype of DeepPartialEvent.
735
+ *
736
+ * @returns Result - structured result with event, respond, next
737
+ * @returns Result[] - fan-out: each Result continues independently through remaining chain
738
+ * @returns void - continue with current event unchanged (passthrough)
739
+ * @returns false - stop chain, cancel further processing
740
+ */
741
+ type Fn$2<T extends TypesGeneric$2 = Types$3, E = DeepPartialEvent> = (event: E, context: Context$4<T>) => PromiseOrValue<Result$1<E> | Result$1<E>[] | false | void>;
742
+ /**
743
+ * Optional initialization function.
744
+ * Called once before first push.
745
+ *
746
+ * @param context - Transformer context
747
+ * @returns void - initialization successful
748
+ * @returns false - initialization failed, skip this transformer
749
+ * @returns Config<T> - return updated config
750
+ */
751
+ type InitFn$1<T extends TypesGeneric$2 = Types$3> = (context: Context$4<T>) => PromiseOrValue<void | false | Config$4<T>>;
752
+ /**
753
+ * Transformer instance returned by Init function.
754
+ */
755
+ interface Instance$4<T extends TypesGeneric$2 = Types$3> {
756
+ type: string;
757
+ config: Config$4<T>;
758
+ push: Fn$2<T>;
759
+ init?: InitFn$1<T>;
760
+ destroy?: DestroyFn<Config$4<T>, Env$2<T>>;
761
+ }
762
+ /**
763
+ * Transformer initialization function.
764
+ * Creates a transformer instance from context.
765
+ */
766
+ type Init$2<T extends TypesGeneric$2 = Types$3> = (context: Context$4<Types$3<Partial<Settings$2<T>>, Env$2<T>, InitSettings$2<T>>>) => Instance$4<T> | Promise<Instance$4<T>>;
767
+ /**
768
+ * Configuration for initializing a transformer.
769
+ * Used in collector registration.
770
+ */
771
+ type InitTransformer<T extends TypesGeneric$2 = Types$3> = {
772
+ code: Init$2<T>;
773
+ config?: Partial<Config$4<T>>;
774
+ env?: Partial<Env$2<T>>;
775
+ before?: RouteSpec;
776
+ next?: RouteSpec;
777
+ cache?: Cache;
778
+ };
779
+ /**
780
+ * Transformers configuration for collector.
781
+ * Maps transformer IDs to their initialization configurations.
782
+ */
783
+ interface InitTransformers {
784
+ [transformerId: string]: InitTransformer<any>;
785
+ }
786
+ /**
787
+ * Active transformer instances registry.
788
+ */
789
+ interface Transformers {
790
+ [transformerId: string]: Instance$4;
791
+ }
792
+
793
+ type transformer_ChainResult = ChainResult;
794
+ type transformer_InitTransformer<T extends TypesGeneric$2 = Types$3> = InitTransformer<T>;
795
+ type transformer_InitTransformers = InitTransformers;
796
+ type transformer_Route = Route;
797
+ type transformer_RouteSpec = RouteSpec;
798
+ type transformer_Transformers = Transformers;
799
+ declare namespace transformer {
800
+ export type { BaseEnv$2 as BaseEnv, transformer_ChainResult as ChainResult, Config$4 as Config, Context$4 as Context, Env$2 as Env, Fn$2 as Fn, Init$2 as Init, InitFn$1 as InitFn, InitSettings$2 as InitSettings, transformer_InitTransformer as InitTransformer, transformer_InitTransformers as InitTransformers, Instance$4 as Instance, Result$1 as Result, transformer_Route as Route, transformer_RouteSpec as RouteSpec, Settings$2 as Settings, transformer_Transformers as Transformers, Types$3 as Types, TypesGeneric$2 as TypesGeneric, TypesOf$2 as TypesOf };
801
+ }
802
+
615
803
  /**
616
804
  * Single flow configuration.
617
805
  *
@@ -900,7 +1088,7 @@ declare namespace Flow {
900
1088
  * (decode, validate, authenticate, normalize raw input).
901
1089
  * Raw request data is available in context.ingest.
902
1090
  */
903
- before?: string | string[];
1091
+ before?: RouteSpec;
904
1092
  /**
905
1093
  * First transformer in pre-collector chain.
906
1094
  *
@@ -909,7 +1097,7 @@ declare namespace Flow {
909
1097
  * If omitted, events route directly to the collector.
910
1098
  * Can be an array for explicit chain control (bypasses transformer.next resolution).
911
1099
  */
912
- next?: string | string[];
1100
+ next?: RouteSpec;
913
1101
  /** Cache configuration for this source. */
914
1102
  cache?: Cache;
915
1103
  /**
@@ -951,7 +1139,7 @@ declare namespace Flow {
951
1139
  * If omitted, events are sent directly from the collector.
952
1140
  * Can be an array for explicit chain control.
953
1141
  */
954
- before?: string | string[];
1142
+ before?: RouteSpec;
955
1143
  /**
956
1144
  * First transformer in post-push chain.
957
1145
  *
@@ -959,7 +1147,7 @@ declare namespace Flow {
959
1147
  * at context.ingest._response. Consent is inherited from the destination
960
1148
  * gate - no separate consent check needed.
961
1149
  */
962
- next?: string | string[];
1150
+ next?: RouteSpec;
963
1151
  /** Cache configuration for this destination. */
964
1152
  cache?: Cache;
965
1153
  /** Destination-level variables (highest priority in cascade). */
@@ -992,7 +1180,7 @@ declare namespace Flow {
992
1180
  * Enables pre-processing or context loading before the main transform.
993
1181
  * Uses the same chain resolution as source.next and destination.before.
994
1182
  */
995
- before?: string | string[];
1183
+ before?: RouteSpec;
996
1184
  /**
997
1185
  * Next transformer in chain.
998
1186
  *
@@ -1003,7 +1191,7 @@ declare namespace Flow {
1003
1191
  * Array values define an explicit chain (no walking). Circular references
1004
1192
  * are safely detected at runtime by `walkChain()`.
1005
1193
  */
1006
- next?: string | string[];
1194
+ next?: RouteSpec;
1007
1195
  /** Cache configuration for this transformer. */
1008
1196
  cache?: Cache;
1009
1197
  /** Transformer-level variables (highest priority in cascade). */
@@ -1223,7 +1411,7 @@ type Handler = (level: Level, message: string, context: LogContext, scope: strin
1223
1411
  * Logger instance with scoping support
1224
1412
  * All logs automatically include trace path from scoping
1225
1413
  */
1226
- interface Instance$4 {
1414
+ interface Instance$3 {
1227
1415
  /**
1228
1416
  * Log an error message (always visible unless silenced)
1229
1417
  */
@@ -1254,12 +1442,12 @@ interface Instance$4 {
1254
1442
  * @param name - Scope name (e.g., destination type, destination key)
1255
1443
  * @returns A new logger instance with the scope applied
1256
1444
  */
1257
- scope: (name: string) => Instance$4;
1445
+ scope: (name: string) => Instance$3;
1258
1446
  }
1259
1447
  /**
1260
1448
  * Logger configuration options
1261
1449
  */
1262
- interface Config$4 {
1450
+ interface Config$3 {
1263
1451
  /**
1264
1452
  * Minimum log level to display
1265
1453
  * @default Level.ERROR
@@ -1285,7 +1473,7 @@ interface InternalConfig {
1285
1473
  /**
1286
1474
  * Logger factory function type
1287
1475
  */
1288
- type Factory = (config?: Config$4) => Instance$4;
1476
+ type Factory = (config?: Config$3) => Instance$3;
1289
1477
 
1290
1478
  type logger_DefaultHandler = DefaultHandler;
1291
1479
  type logger_ErrorContext = ErrorContext;
@@ -1298,11 +1486,11 @@ type logger_LogContext = LogContext;
1298
1486
  type logger_LogFn = LogFn;
1299
1487
  type logger_ThrowFn = ThrowFn;
1300
1488
  declare namespace logger {
1301
- export { type Config$4 as Config, type logger_DefaultHandler as DefaultHandler, type logger_ErrorContext as ErrorContext, type logger_Factory as Factory, type logger_Handler as Handler, type Instance$4 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 };
1489
+ 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$3 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 };
1302
1490
  }
1303
1491
 
1304
1492
  /** Collector state mapping for the `on` actions. */
1305
- type Config$3 = {
1493
+ type Config$2 = {
1306
1494
  config?: Array<GenericFn>;
1307
1495
  consent?: Array<ConsentRule>;
1308
1496
  custom?: Array<GenericFn>;
@@ -1313,7 +1501,7 @@ type Config$3 = {
1313
1501
  user?: Array<UserFn>;
1314
1502
  };
1315
1503
  /** Allow arbitrary string events via `(string & {})`. */
1316
- type Types$3 = keyof Config$3 | (string & {});
1504
+ type Types$2 = keyof Config$2 | (string & {});
1317
1505
  /** Map each event type to its expected data payload type. */
1318
1506
  interface EventDataMap {
1319
1507
  config: Partial<Config$6>;
@@ -1334,19 +1522,19 @@ type AnyEventData = EventDataMap[keyof EventDataMap];
1334
1522
  * Same posture as Mapping.Context: collector + logger only;
1335
1523
  * subscriptions are a collector-level concern, not a stage-level one.
1336
1524
  */
1337
- interface Context$4 {
1525
+ interface Context$3 {
1338
1526
  collector: Instance$6;
1339
- logger: Instance$4;
1527
+ logger: Instance$3;
1340
1528
  }
1341
1529
  /** Unified subscription callback shape. */
1342
- type Fn$2<TData = unknown> = (data: TData, context: Context$4) => PromiseOrValue<void>;
1530
+ type Fn$1<TData = unknown> = (data: TData, context: Context$3) => PromiseOrValue<void>;
1343
1531
  /** Typed-data variants for readability and IntelliSense. All reduce to Fn<TData>. */
1344
- type ConsentFn = Fn$2<Consent>;
1345
- type GenericFn = Fn$2<unknown>;
1346
- type ReadyFn = Fn$2<void>;
1347
- type RunFn = Fn$2<void>;
1348
- type SessionFn = Fn$2<SessionData | undefined>;
1349
- type UserFn = Fn$2<User>;
1532
+ type ConsentFn = Fn$1<Consent>;
1533
+ type GenericFn = Fn$1<unknown>;
1534
+ type ReadyFn = Fn$1<void>;
1535
+ type RunFn = Fn$1<void>;
1536
+ type SessionFn = Fn$1<SessionData | undefined>;
1537
+ type UserFn = Fn$1<User>;
1350
1538
  /**
1351
1539
  * Consent rule: a record of `{ [consentKey]: ConsentFn }`.
1352
1540
  * Only the consent action uses this shape (per-key handler dispatch).
@@ -1371,8 +1559,8 @@ interface OnConfig {
1371
1559
  * Destination `on` handler: receives the action type and a destination context.
1372
1560
  * Already context-style; kept for compatibility with the destination interface.
1373
1561
  */
1374
- type OnFn<T extends TypesGeneric$3 = Types$4> = (type: Types$3, context: Context$5<T>) => PromiseOrValue<void>;
1375
- type OnFnRuntime = (type: Types$3, context: Context$5) => PromiseOrValue<void>;
1562
+ type OnFn<T extends TypesGeneric$3 = Types$4> = (type: Types$2, context: Context$5<T>) => PromiseOrValue<void>;
1563
+ type OnFnRuntime = (type: Types$2, context: Context$5) => PromiseOrValue<void>;
1376
1564
 
1377
1565
  type on_AnyEventData = AnyEventData;
1378
1566
  type on_ConsentFn = ConsentFn;
@@ -1389,176 +1577,7 @@ type on_SessionFn = SessionFn;
1389
1577
  type on_Subscription = Subscription;
1390
1578
  type on_UserFn = UserFn;
1391
1579
  declare namespace on {
1392
- export type { on_AnyEventData as AnyEventData, Config$3 as Config, on_ConsentFn as ConsentFn, on_ConsentRule as ConsentRule, Context$4 as Context, on_EventData as EventData, on_EventDataMap as EventDataMap, Fn$2 as Fn, on_GenericFn as GenericFn, on_OnConfig as OnConfig, on_OnFn as OnFn, on_OnFnRuntime as OnFnRuntime, on_ReadyFn as ReadyFn, on_RunFn as RunFn, on_SessionFn as SessionFn, on_Subscription as Subscription, Types$3 as Types, on_UserFn as UserFn };
1393
- }
1394
-
1395
- interface NextRule {
1396
- match: MatchExpression | '*';
1397
- next: Next;
1398
- }
1399
- type Next = string | string[] | NextRule[];
1400
- /**
1401
- * Base environment interface for walkerOS transformers.
1402
- *
1403
- * Minimal like Destination - just an extensible object.
1404
- * Transformers receive dependencies through context, not env.
1405
- */
1406
- interface BaseEnv$2 {
1407
- [key: string]: unknown;
1408
- }
1409
- /**
1410
- * Type bundle for transformer generics.
1411
- * Groups Settings, InitSettings, and Env into a single type parameter.
1412
- * Follows the Source/Destination pattern.
1413
- *
1414
- * @template S - Settings configuration type
1415
- * @template E - Environment type
1416
- * @template I - InitSettings configuration type (user input)
1417
- */
1418
- interface Types$2<S = unknown, E = BaseEnv$2, I = S> {
1419
- settings: S;
1420
- initSettings: I;
1421
- env: E;
1422
- }
1423
- /**
1424
- * Generic constraint for Types - ensures T has required properties for indexed access.
1425
- */
1426
- type TypesGeneric$2 = {
1427
- settings: any;
1428
- initSettings: any;
1429
- env: any;
1430
- };
1431
- /**
1432
- * Type extractors for consistent usage with Types bundle.
1433
- */
1434
- type Settings$2<T extends TypesGeneric$2 = Types$2> = T['settings'];
1435
- type InitSettings$2<T extends TypesGeneric$2 = Types$2> = T['initSettings'];
1436
- type Env$2<T extends TypesGeneric$2 = Types$2> = T['env'];
1437
- /**
1438
- * Inference helper: Extract Types from Instance.
1439
- */
1440
- type TypesOf$2<I> = I extends Instance$3<infer T> ? T : never;
1441
- /**
1442
- * Transformer configuration.
1443
- */
1444
- interface Config$2<T extends TypesGeneric$2 = Types$2> {
1445
- settings?: InitSettings$2<T>;
1446
- env?: Env$2<T>;
1447
- id?: string;
1448
- logger?: Config$4;
1449
- before?: Next;
1450
- next?: Next;
1451
- cache?: Cache;
1452
- init?: boolean;
1453
- disabled?: boolean;
1454
- /** Return this value instead of calling push(). Global mock for all chains. */
1455
- mock?: unknown;
1456
- /** Path-specific mock values keyed by chain path (e.g., "destination.ga4.before"). Takes precedence over global mock. */
1457
- chainMocks?: Record<string, unknown>;
1458
- }
1459
- /**
1460
- * Context provided to transformer functions.
1461
- * Extends base context with transformer-specific properties.
1462
- */
1463
- interface Context$3<T extends TypesGeneric$2 = Types$2> extends Base<Config$2<T>, Env$2<T>> {
1464
- id: string;
1465
- ingest: Ingest;
1466
- }
1467
- /**
1468
- * Unified result type for transformer functions.
1469
- * Replaces the old union return type with a structured object.
1470
- *
1471
- * @field event - Modified event to continue with
1472
- * @field respond - Wrapped respond function for downstream transformers
1473
- * @field next - Branch to a different chain (replaces BranchResult)
1474
- */
1475
- interface Result$1<E = DeepPartialEvent> {
1476
- event?: E;
1477
- respond?: RespondFn;
1478
- next?: Next;
1479
- }
1480
- /**
1481
- * Result of running a transformer chain.
1482
- * Returns the processed event (singular, fan-out array, or null if dropped)
1483
- * alongside the potentially wrapped respond function.
1484
- */
1485
- interface ChainResult {
1486
- event: DeepPartialEvent | DeepPartialEvent[] | null;
1487
- respond?: RespondFn;
1488
- }
1489
- /**
1490
- * The main transformer function.
1491
- *
1492
- * Pre-collector transformers use default E = DeepPartialEvent.
1493
- * Post-collector transformers can use E = Event for type-safe access.
1494
- * A transformer written for DeepPartialEvent works in both positions
1495
- * because Event is a subtype of DeepPartialEvent.
1496
- *
1497
- * @returns Result - structured result with event, respond, next
1498
- * @returns Result[] - fan-out: each Result continues independently through remaining chain
1499
- * @returns void - continue with current event unchanged (passthrough)
1500
- * @returns false - stop chain, cancel further processing
1501
- */
1502
- type Fn$1<T extends TypesGeneric$2 = Types$2, E = DeepPartialEvent> = (event: E, context: Context$3<T>) => PromiseOrValue<Result$1<E> | Result$1<E>[] | false | void>;
1503
- /**
1504
- * Optional initialization function.
1505
- * Called once before first push.
1506
- *
1507
- * @param context - Transformer context
1508
- * @returns void - initialization successful
1509
- * @returns false - initialization failed, skip this transformer
1510
- * @returns Config<T> - return updated config
1511
- */
1512
- type InitFn$1<T extends TypesGeneric$2 = Types$2> = (context: Context$3<T>) => PromiseOrValue<void | false | Config$2<T>>;
1513
- /**
1514
- * Transformer instance returned by Init function.
1515
- */
1516
- interface Instance$3<T extends TypesGeneric$2 = Types$2> {
1517
- type: string;
1518
- config: Config$2<T>;
1519
- push: Fn$1<T>;
1520
- init?: InitFn$1<T>;
1521
- destroy?: DestroyFn<Config$2<T>, Env$2<T>>;
1522
- }
1523
- /**
1524
- * Transformer initialization function.
1525
- * Creates a transformer instance from context.
1526
- */
1527
- type Init$2<T extends TypesGeneric$2 = Types$2> = (context: Context$3<Types$2<Partial<Settings$2<T>>, Env$2<T>, InitSettings$2<T>>>) => Instance$3<T> | Promise<Instance$3<T>>;
1528
- /**
1529
- * Configuration for initializing a transformer.
1530
- * Used in collector registration.
1531
- */
1532
- type InitTransformer<T extends TypesGeneric$2 = Types$2> = {
1533
- code: Init$2<T>;
1534
- config?: Partial<Config$2<T>>;
1535
- env?: Partial<Env$2<T>>;
1536
- before?: Next;
1537
- next?: Next;
1538
- cache?: Cache;
1539
- };
1540
- /**
1541
- * Transformers configuration for collector.
1542
- * Maps transformer IDs to their initialization configurations.
1543
- */
1544
- interface InitTransformers {
1545
- [transformerId: string]: InitTransformer<any>;
1546
- }
1547
- /**
1548
- * Active transformer instances registry.
1549
- */
1550
- interface Transformers {
1551
- [transformerId: string]: Instance$3;
1552
- }
1553
-
1554
- type transformer_ChainResult = ChainResult;
1555
- type transformer_InitTransformer<T extends TypesGeneric$2 = Types$2> = InitTransformer<T>;
1556
- type transformer_InitTransformers = InitTransformers;
1557
- type transformer_Next = Next;
1558
- type transformer_NextRule = NextRule;
1559
- type transformer_Transformers = Transformers;
1560
- declare namespace transformer {
1561
- export type { BaseEnv$2 as BaseEnv, transformer_ChainResult as ChainResult, Config$2 as Config, Context$3 as Context, Env$2 as Env, Fn$1 as Fn, Init$2 as Init, InitFn$1 as InitFn, InitSettings$2 as InitSettings, transformer_InitTransformer as InitTransformer, transformer_InitTransformers as InitTransformers, Instance$3 as Instance, transformer_Next as Next, transformer_NextRule as NextRule, Result$1 as Result, Settings$2 as Settings, transformer_Transformers as Transformers, Types$2 as Types, TypesGeneric$2 as TypesGeneric, TypesOf$2 as TypesOf };
1580
+ export type { on_AnyEventData as AnyEventData, Config$2 as Config, on_ConsentFn as ConsentFn, on_ConsentRule as ConsentRule, Context$3 as Context, on_EventData as EventData, on_EventDataMap as EventDataMap, Fn$1 as Fn, on_GenericFn as GenericFn, on_OnConfig as OnConfig, on_OnFn as OnFn, on_OnFnRuntime as OnFnRuntime, on_ReadyFn as ReadyFn, on_RunFn as RunFn, on_SessionFn as SessionFn, on_Subscription as Subscription, Types$2 as Types, on_UserFn as UserFn };
1562
1581
  }
1563
1582
 
1564
1583
  interface Context$2 {
@@ -1590,7 +1609,7 @@ interface BaseEnv$1 {
1590
1609
  command: CommandFn;
1591
1610
  sources?: Sources;
1592
1611
  elb: Fn$3;
1593
- logger: Instance$4;
1612
+ logger: Instance$3;
1594
1613
  }
1595
1614
  /**
1596
1615
  * Type bundle for source generics.
@@ -1601,7 +1620,7 @@ interface BaseEnv$1 {
1601
1620
  * @template P - Push function signature (flexible to support HTTP handlers, etc.)
1602
1621
  * @template E - Environment dependencies type
1603
1622
  * @template I - InitSettings configuration type (user input)
1604
- * @template U - Setup options type (provisioning options for `walker setup`)
1623
+ * @template U - Setup options type (provisioning options for `walkeros setup`)
1605
1624
  */
1606
1625
  interface Types$1<S = unknown, M = unknown, P = Fn$3, E = BaseEnv$1, I = S, U = unknown> {
1607
1626
  settings: S;
@@ -1643,13 +1662,13 @@ interface Config$1<T extends TypesGeneric$1 = Types$1> extends Config$7<Mapping<
1643
1662
  /** Source identifier; defaults to the InitSources object key. */
1644
1663
  id?: string;
1645
1664
  /** Logger configuration (level, handler) to override the collector's defaults. */
1646
- logger?: Config$4;
1665
+ logger?: Config$3;
1647
1666
  /** Mark as primary source; its push function becomes the exported `elb` from startFlow. */
1648
1667
  primary?: boolean;
1649
1668
  /** Defer source initialization until these collector events fire (e.g., `['consent']`). */
1650
1669
  require?: string[];
1651
1670
  /**
1652
- * Provisioning options for `walker setup`. `boolean | object`.
1671
+ * Provisioning options for `walkeros setup`. `boolean | object`.
1653
1672
  * Triggered only by explicit CLI invocation; never automatic.
1654
1673
  */
1655
1674
  setup?: boolean | SetupOptions$1<T>;
@@ -1683,7 +1702,7 @@ interface Instance$2<T extends TypesGeneric$1 = Types$1> {
1683
1702
  setup?: SetupFn<Config$1<T>, Env$1<T>>;
1684
1703
  push: Push<T>;
1685
1704
  destroy?: DestroyFn<Config$1<T>, Env$1<T>>;
1686
- on?(event: Types$3, context?: unknown): void | boolean | Promise<void | boolean>;
1705
+ on?(event: Types$2, context?: unknown): void | boolean | Promise<void | boolean>;
1687
1706
  /**
1688
1707
  * Optional setup hook. Called by the collector eagerly after all source
1689
1708
  * factories have run, regardless of `config.require`. Use for prep work
@@ -1698,7 +1717,7 @@ interface Instance$2<T extends TypesGeneric$1 = Types$1> {
1698
1717
  * Flushed by the collector when the source becomes started.
1699
1718
  */
1700
1719
  queueOn?: Array<{
1701
- type: Types$3;
1720
+ type: Types$2;
1702
1721
  data: unknown;
1703
1722
  }>;
1704
1723
  }
@@ -1725,8 +1744,8 @@ type InitSource<T extends TypesGeneric$1 = Types$1> = {
1725
1744
  config?: Partial<Config$1<T>>;
1726
1745
  env?: Partial<Env$1<T>>;
1727
1746
  primary?: boolean;
1728
- next?: Next;
1729
- before?: Next;
1747
+ next?: RouteSpec;
1748
+ before?: RouteSpec;
1730
1749
  cache?: Cache;
1731
1750
  };
1732
1751
  /**
@@ -1776,9 +1795,9 @@ interface Config<T extends TypesGeneric = Types> {
1776
1795
  settings?: InitSettings<T>;
1777
1796
  env?: Env<T>;
1778
1797
  id?: string;
1779
- logger?: Config$4;
1798
+ logger?: Config$3;
1780
1799
  /**
1781
- * Provisioning options for `walker setup`. `boolean | object`.
1800
+ * Provisioning options for `walkeros setup`. `boolean | object`.
1782
1801
  * Triggered only by explicit CLI invocation; never automatic.
1783
1802
  */
1784
1803
  setup?: boolean | SetupOptions<T>;
@@ -2136,7 +2155,7 @@ interface SendResponse {
2136
2155
  * Creates a TransformerResult for dynamic chain routing.
2137
2156
  * Use this in transformer push functions to redirect the chain.
2138
2157
  */
2139
- declare function branch(event: DeepPartialEvent, next: Next): Result$1;
2158
+ declare function branch(event: DeepPartialEvent, next: RouteSpec): Result$1;
2140
2159
 
2141
2160
  /**
2142
2161
  * Anonymizes an IPv4 address by setting the last octet to 0.
@@ -2546,7 +2565,7 @@ declare function isString(value: unknown): value is string;
2546
2565
  * // TODO: Consider compile-time stripping of debug logs in production builds
2547
2566
  * // e.g., if (__DEV__) { logger.debug(...) }
2548
2567
  */
2549
- declare function createLogger(config?: Config$4): Instance$4;
2568
+ declare function createLogger(config?: Config$3): Instance$3;
2550
2569
 
2551
2570
  /**
2552
2571
  * Gets the mapping for an event.
@@ -2681,21 +2700,21 @@ declare function traverseEnv<T extends object>(env: T, replacer: (value: unknown
2681
2700
  * const ctx = createMockContext({ ingest: { ...createIngest('test'), path: '/api' } });
2682
2701
  * ```
2683
2702
  */
2684
- declare function createMockContext<T extends TypesGeneric$2 = Types$2>(overrides?: Partial<Omit<Context$3<T>, 'config' | 'ingest'> & {
2685
- config?: Config$2<T> | Config$5<TypesGeneric$3>;
2703
+ declare function createMockContext<T extends TypesGeneric$2 = Types$3>(overrides?: Partial<Omit<Context$4<T>, 'config' | 'ingest'> & {
2704
+ config?: Config$4<T> | Config$5<TypesGeneric$3>;
2686
2705
  ingest?: Ingest | (Record<string, unknown> & {
2687
2706
  _meta: Ingest['_meta'];
2688
2707
  });
2689
2708
  data?: unknown;
2690
2709
  rule?: unknown;
2691
- }>): Context$3<T> & PushContext<TypesGeneric$3>;
2710
+ }>): Context$4<T> & PushContext<TypesGeneric$3>;
2692
2711
 
2693
2712
  /**
2694
2713
  * Mock logger instance for testing
2695
2714
  * Includes all logger methods as jest.fn() plus tracking of scoped loggers
2696
2715
  * Extends Instance to ensure type compatibility
2697
2716
  */
2698
- interface MockLogger extends Instance$4 {
2717
+ interface MockLogger extends Instance$3 {
2699
2718
  error: jest.Mock;
2700
2719
  warn: jest.Mock;
2701
2720
  info: jest.Mock;
@@ -2844,7 +2863,7 @@ declare function tryCatchAsync<P extends unknown[], R>(fn: (...args: P) => R, on
2844
2863
  * `console.warn` when not provided.
2845
2864
  * @returns The wrapped function.
2846
2865
  */
2847
- declare function useHooks<P extends unknown[], R>(fn: (...args: P) => R, name: string, hooks: Functions, logger?: Instance$4): (...args: P) => R;
2866
+ declare function useHooks<P extends unknown[], R>(fn: (...args: P) => R, name: string, hooks: Functions, logger?: Instance$3): (...args: P) => R;
2848
2867
 
2849
2868
  /**
2850
2869
  * Parses a user agent string to extract browser, OS, and device information.
@@ -3042,8 +3061,8 @@ type CompiledNext = {
3042
3061
  type: 'routes';
3043
3062
  routes: CompiledRoute[];
3044
3063
  };
3045
- declare function isRouteArray(next: Next): next is NextRule[];
3046
- declare function compileNext(next: Next | undefined): CompiledNext | undefined;
3064
+ declare function isRouteArray(next: RouteSpec): next is Route[];
3065
+ declare function compileNext(next: RouteSpec | undefined): CompiledNext | undefined;
3047
3066
  declare function resolveNext(compiled: CompiledNext | undefined, context?: Record<string, unknown>): string | string[] | undefined;
3048
3067
 
3049
3068
  interface CompiledCacheRule {