@walkeros/core 1.2.2 → 1.4.0-next-1771252576264

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.mts CHANGED
@@ -44,6 +44,25 @@ interface SessionData extends Properties {
44
44
  count?: number;
45
45
  runs?: number;
46
46
  }
47
+ interface Status {
48
+ startedAt: number;
49
+ in: number;
50
+ out: number;
51
+ failed: number;
52
+ sources: Record<string, SourceStatus>;
53
+ destinations: Record<string, DestinationStatus>;
54
+ }
55
+ interface SourceStatus {
56
+ count: number;
57
+ lastAt?: number;
58
+ duration: number;
59
+ }
60
+ interface DestinationStatus {
61
+ count: number;
62
+ failed: number;
63
+ lastAt?: number;
64
+ duration: number;
65
+ }
47
66
  interface Sources {
48
67
  [id: string]: Instance;
49
68
  }
@@ -107,19 +126,27 @@ interface Instance$4 {
107
126
  queue: Events;
108
127
  round: number;
109
128
  session: undefined | SessionData;
129
+ status: Status;
110
130
  timing: number;
111
131
  user: User;
112
132
  version: string;
133
+ pending: {
134
+ sources: InitSources;
135
+ destinations: InitDestinations;
136
+ };
113
137
  }
114
138
 
115
139
  type collector_CommandFn = CommandFn;
116
140
  type collector_CommandType = CommandType;
141
+ type collector_DestinationStatus = DestinationStatus;
117
142
  type collector_InitConfig = InitConfig;
118
143
  type collector_PushOptions = PushOptions;
119
144
  type collector_SessionData = SessionData;
145
+ type collector_SourceStatus = SourceStatus;
120
146
  type collector_Sources = Sources;
147
+ type collector_Status = Status;
121
148
  declare namespace collector {
122
- export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$7 as Config, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$4 as Instance, PushFn$1 as PushFn, collector_PushOptions as PushOptions, collector_SessionData as SessionData, collector_Sources as Sources, Transformers$1 as Transformers };
149
+ export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$7 as Config, collector_DestinationStatus as DestinationStatus, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$4 as Instance, PushFn$1 as PushFn, collector_PushOptions as PushOptions, collector_SessionData as SessionData, collector_SourceStatus as SourceStatus, collector_Sources as Sources, collector_Status as Status, Transformers$1 as Transformers };
123
150
  }
124
151
 
125
152
  /**
@@ -251,17 +278,31 @@ interface Instance$3<T extends TypesGeneric$2 = Types$3> {
251
278
  on?: OnFn;
252
279
  }
253
280
  interface Config$6<T extends TypesGeneric$2 = Types$3> {
281
+ /** Required consent states to push events; queues events when not granted. */
254
282
  consent?: Consent;
283
+ /** Implementation-specific configuration passed to the init function. */
255
284
  settings?: InitSettings$2<T>;
285
+ /** Global data transformation applied to all events; result passed as context.data to push. */
256
286
  data?: Value | Values;
287
+ /** Runtime dependencies merged from code and config env; extensible per destination. */
257
288
  env?: Env$2<T>;
289
+ /** Destination identifier; auto-generated if not provided. */
258
290
  id?: string;
291
+ /** Whether the destination has been initialized; prevents re-initialization. */
259
292
  init?: boolean;
293
+ /** Whether to load external scripts (e.g., gtag.js); destination-specific behavior. */
260
294
  loadScript?: boolean;
295
+ /** Logger configuration (level, handler) to override the collector's defaults. */
261
296
  logger?: Config$4;
297
+ /** Entity-action rules to filter, rename, transform, and batch events for this destination. */
262
298
  mapping?: Rules<Rule<Mapping$1<T>>>;
299
+ /** Pre-processing rules applied to all events before mapping; modifies events in-place. */
263
300
  policy?: Policy$1;
301
+ /** Whether to queue events when consent is not granted; defaults to true. */
264
302
  queue?: boolean;
303
+ /** Defer destination initialization until these collector events fire (e.g., `['consent']`). */
304
+ require?: string[];
305
+ /** Transformer chain to run after collector processing but before this destination. */
265
306
  before?: string | string[];
266
307
  }
267
308
  type PartialConfig$1<T extends TypesGeneric$2 = Types$3> = Config$6<Types$3<Partial<Settings$2<T>> | Settings$2<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$2<T>>>;
@@ -1192,41 +1233,57 @@ declare namespace mapping {
1192
1233
  }
1193
1234
 
1194
1235
  type Config$2 = {
1236
+ config?: Array<GenericConfig>;
1195
1237
  consent?: Array<ConsentConfig>;
1238
+ custom?: Array<GenericConfig>;
1239
+ globals?: Array<GenericConfig>;
1196
1240
  ready?: Array<ReadyConfig>;
1197
1241
  run?: Array<RunConfig>;
1198
1242
  session?: Array<SessionConfig>;
1243
+ user?: Array<UserConfig>;
1199
1244
  };
1200
- type Types$2 = keyof Config$2;
1245
+ type Types$2 = keyof Config$2 | (string & {});
1201
1246
  interface EventContextMap {
1247
+ config: Partial<Config$7>;
1202
1248
  consent: Consent;
1203
- session: SessionData;
1249
+ custom: Properties;
1250
+ globals: Properties;
1204
1251
  ready: undefined;
1205
1252
  run: undefined;
1253
+ session: SessionData;
1254
+ user: User;
1206
1255
  }
1207
- type EventContext<T extends Types$2> = EventContextMap[T];
1256
+ type EventContext<T extends keyof EventContextMap> = EventContextMap[T];
1208
1257
  type AnyEventContext = EventContextMap[keyof EventContextMap];
1209
1258
  interface Context$3 {
1210
1259
  consent?: Consent;
1211
1260
  session?: unknown;
1212
1261
  }
1213
- type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
1262
+ type Options = ConsentConfig | GenericConfig | ReadyConfig | RunConfig | SessionConfig | UserConfig;
1214
1263
  interface ConsentConfig {
1215
1264
  [key: string]: ConsentFn;
1216
1265
  }
1217
1266
  type ConsentFn = (collector: Instance$4, consent: Consent) => void;
1267
+ type GenericConfig = GenericFn;
1268
+ type GenericFn = (collector: Instance$4, data: unknown) => void;
1218
1269
  type ReadyConfig = ReadyFn;
1219
1270
  type ReadyFn = (collector: Instance$4) => void;
1220
1271
  type RunConfig = RunFn;
1221
1272
  type RunFn = (collector: Instance$4) => void;
1222
1273
  type SessionConfig = SessionFn;
1223
1274
  type SessionFn = (collector: Instance$4, session?: unknown) => void;
1275
+ type UserConfig = UserFn;
1276
+ type UserFn = (collector: Instance$4, user: User) => void;
1224
1277
  interface OnConfig {
1278
+ config?: GenericConfig[];
1225
1279
  consent?: ConsentConfig[];
1280
+ custom?: GenericConfig[];
1281
+ globals?: GenericConfig[];
1226
1282
  ready?: ReadyConfig[];
1227
1283
  run?: RunConfig[];
1228
1284
  session?: SessionConfig[];
1229
- [key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
1285
+ user?: UserConfig[];
1286
+ [key: string]: ConsentConfig[] | GenericConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | UserConfig[] | undefined;
1230
1287
  }
1231
1288
  type OnFn<T extends TypesGeneric$2 = Types$3> = (type: Types$2, context: Context$4<T>) => PromiseOrValue<void>;
1232
1289
  type OnFnRuntime = (type: Types$2, context: Context$4) => PromiseOrValue<void>;
@@ -1234,8 +1291,10 @@ type OnFnRuntime = (type: Types$2, context: Context$4) => PromiseOrValue<void>;
1234
1291
  type on_AnyEventContext = AnyEventContext;
1235
1292
  type on_ConsentConfig = ConsentConfig;
1236
1293
  type on_ConsentFn = ConsentFn;
1237
- type on_EventContext<T extends Types$2> = EventContext<T>;
1294
+ type on_EventContext<T extends keyof EventContextMap> = EventContext<T>;
1238
1295
  type on_EventContextMap = EventContextMap;
1296
+ type on_GenericConfig = GenericConfig;
1297
+ type on_GenericFn = GenericFn;
1239
1298
  type on_OnConfig = OnConfig;
1240
1299
  type on_OnFn<T extends TypesGeneric$2 = Types$3> = OnFn<T>;
1241
1300
  type on_OnFnRuntime = OnFnRuntime;
@@ -1246,10 +1305,13 @@ type on_RunConfig = RunConfig;
1246
1305
  type on_RunFn = RunFn;
1247
1306
  type on_SessionConfig = SessionConfig;
1248
1307
  type on_SessionFn = SessionFn;
1308
+ type on_UserConfig = UserConfig;
1309
+ type on_UserFn = UserFn;
1249
1310
  declare namespace on {
1250
- export type { on_AnyEventContext as AnyEventContext, Config$2 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, Context$3 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$2 as Types };
1311
+ export type { on_AnyEventContext as AnyEventContext, Config$2 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, Context$3 as Context, on_EventContext as EventContext, on_EventContextMap as EventContextMap, on_GenericConfig as GenericConfig, on_GenericFn as GenericFn, 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$2 as Types, on_UserConfig as UserConfig, on_UserFn as UserFn };
1251
1312
  }
1252
1313
 
1314
+ type Next = string | string[];
1253
1315
  /**
1254
1316
  * Base environment interface for walkerOS transformers.
1255
1317
  *
@@ -1299,7 +1361,7 @@ interface Config$1<T extends TypesGeneric$1 = Types$1> {
1299
1361
  env?: Env$1<T>;
1300
1362
  id?: string;
1301
1363
  logger?: Config$4;
1302
- next?: string;
1364
+ next?: Next;
1303
1365
  init?: boolean;
1304
1366
  }
1305
1367
  /**
@@ -1310,6 +1372,20 @@ interface Context$2<T extends TypesGeneric$1 = Types$1> extends Base<Config$1<T>
1310
1372
  id: string;
1311
1373
  ingest?: unknown;
1312
1374
  }
1375
+ /**
1376
+ * Branch result for dynamic chain routing.
1377
+ * Returned by transformers (e.g., router) to redirect the chain.
1378
+ * The chain runner resolves `next` via walkChain() — same semantics
1379
+ * as source.next or transformer.config.next.
1380
+ *
1381
+ * IMPORTANT: Always use the `branch()` factory function to create BranchResult.
1382
+ * The `__branch` discriminant is required for reliable type detection.
1383
+ */
1384
+ interface BranchResult {
1385
+ readonly __branch: true;
1386
+ event: DeepPartialEvent;
1387
+ next: Next;
1388
+ }
1313
1389
  /**
1314
1390
  * The main transformer function.
1315
1391
  * Uses DeepPartialEvent for consistency across pre/post collector.
@@ -1320,7 +1396,7 @@ interface Context$2<T extends TypesGeneric$1 = Types$1> extends Base<Config$1<T>
1320
1396
  * @returns void - continue with current event unchanged (passthrough)
1321
1397
  * @returns false - stop chain, cancel further processing
1322
1398
  */
1323
- type Fn<T extends TypesGeneric$1 = Types$1> = (event: DeepPartialEvent, context: Context$2<T>) => PromiseOrValue<DeepPartialEvent | false | void>;
1399
+ type Fn<T extends TypesGeneric$1 = Types$1> = (event: DeepPartialEvent, context: Context$2<T>) => PromiseOrValue<DeepPartialEvent | false | void | BranchResult>;
1324
1400
  /**
1325
1401
  * Optional initialization function.
1326
1402
  * Called once before first push.
@@ -1354,6 +1430,7 @@ type InitTransformer<T extends TypesGeneric$1 = Types$1> = {
1354
1430
  code: Init$1<T>;
1355
1431
  config?: Partial<Config$1<T>>;
1356
1432
  env?: Partial<Env$1<T>>;
1433
+ next?: Next;
1357
1434
  };
1358
1435
  /**
1359
1436
  * Transformers configuration for collector.
@@ -1369,13 +1446,15 @@ interface Transformers {
1369
1446
  [transformerId: string]: Instance$1;
1370
1447
  }
1371
1448
 
1449
+ type transformer_BranchResult = BranchResult;
1372
1450
  type transformer_Fn<T extends TypesGeneric$1 = Types$1> = Fn<T>;
1373
1451
  type transformer_InitFn<T extends TypesGeneric$1 = Types$1> = InitFn<T>;
1374
1452
  type transformer_InitTransformer<T extends TypesGeneric$1 = Types$1> = InitTransformer<T>;
1375
1453
  type transformer_InitTransformers = InitTransformers;
1454
+ type transformer_Next = Next;
1376
1455
  type transformer_Transformers = Transformers;
1377
1456
  declare namespace transformer {
1378
- export type { BaseEnv$1 as BaseEnv, Config$1 as Config, Context$2 as Context, Env$1 as Env, transformer_Fn as Fn, Init$1 as Init, transformer_InitFn as InitFn, InitSettings$1 as InitSettings, transformer_InitTransformer as InitTransformer, transformer_InitTransformers as InitTransformers, Instance$1 as Instance, Settings$1 as Settings, transformer_Transformers as Transformers, Types$1 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
1457
+ export type { BaseEnv$1 as BaseEnv, transformer_BranchResult as BranchResult, Config$1 as Config, Context$2 as Context, Env$1 as Env, transformer_Fn as Fn, Init$1 as Init, transformer_InitFn as InitFn, InitSettings$1 as InitSettings, transformer_InitTransformer as InitTransformer, transformer_InitTransformers as InitTransformers, Instance$1 as Instance, transformer_Next as Next, Settings$1 as Settings, transformer_Transformers as Transformers, Types$1 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
1379
1458
  }
1380
1459
 
1381
1460
  interface Context$1 {
@@ -1477,12 +1556,18 @@ type Env<T extends TypesGeneric = Types> = T['env'];
1477
1556
  */
1478
1557
  type TypesOf<I> = I extends Instance<infer T> ? T : never;
1479
1558
  interface Config<T extends TypesGeneric = Types> extends Config$3<Mapping<T>> {
1559
+ /** Implementation-specific configuration passed to the init function. */
1480
1560
  settings?: InitSettings<T>;
1561
+ /** Runtime dependencies injected by the collector (push, command, logger, etc.). */
1481
1562
  env?: Env<T>;
1563
+ /** Source identifier; defaults to the InitSources object key. */
1482
1564
  id?: string;
1565
+ /** Logger configuration (level, handler) to override the collector's defaults. */
1483
1566
  logger?: Config$4;
1484
- disabled?: boolean;
1567
+ /** Mark as primary source; its push function becomes the exported `elb` from startFlow. */
1485
1568
  primary?: boolean;
1569
+ /** Defer source initialization until these collector events fire (e.g., `['consent']`). */
1570
+ require?: string[];
1486
1571
  /**
1487
1572
  * Ingest metadata extraction mapping.
1488
1573
  * Extracts values from raw request objects (Express req, Lambda event, etc.)
@@ -1503,7 +1588,7 @@ interface Instance<T extends TypesGeneric = Types> {
1503
1588
  config: Config<T>;
1504
1589
  push: Push<T>;
1505
1590
  destroy?(): void | Promise<void>;
1506
- on?(event: Types$2, context?: unknown): void | Promise<void>;
1591
+ on?(event: Types$2, context?: unknown): void | boolean | Promise<void | boolean>;
1507
1592
  }
1508
1593
  /**
1509
1594
  * Context provided to source init function.
@@ -1526,7 +1611,7 @@ type InitSource<T extends TypesGeneric = Types> = {
1526
1611
  config?: Partial<Config<T>>;
1527
1612
  env?: Partial<Env<T>>;
1528
1613
  primary?: boolean;
1529
- next?: string;
1614
+ next?: Next;
1530
1615
  };
1531
1616
  /**
1532
1617
  * Sources configuration for collector.
@@ -1692,6 +1777,12 @@ interface SendResponse {
1692
1777
  error?: string;
1693
1778
  }
1694
1779
 
1780
+ /**
1781
+ * Creates a BranchResult for dynamic chain routing.
1782
+ * Use this in transformer push functions to redirect the chain.
1783
+ */
1784
+ declare function branch(event: DeepPartialEvent, next: Next): BranchResult;
1785
+
1695
1786
  /**
1696
1787
  * Anonymizes an IPv4 address by setting the last octet to 0.
1697
1788
  *
@@ -2407,4 +2498,17 @@ declare function wrapFn(code: string): Fn$1;
2407
2498
  */
2408
2499
  declare function wrapValidate(code: string): Validate;
2409
2500
 
2410
- export { collector as Collector, Const, context as Context, 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, transformer as Transformer, 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 };
2501
+ interface WalkerOSPackageInfo {
2502
+ packageName: string;
2503
+ version: string;
2504
+ type?: string;
2505
+ platform?: string;
2506
+ schemas: Record<string, unknown>;
2507
+ examples: Record<string, unknown>;
2508
+ }
2509
+ declare function fetchPackageSchema(packageName: string, options?: {
2510
+ version?: string;
2511
+ timeout?: number;
2512
+ }): Promise<WalkerOSPackageInfo>;
2513
+
2514
+ export { collector as Collector, Const, context as Context, 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, transformer as Transformer, walkeros as WalkerOS, type WalkerOSPackageInfo, anonymizeIP, assign, branch, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, debounce, fetchPackageSchema, 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 };
package/dist/index.d.ts CHANGED
@@ -44,6 +44,25 @@ interface SessionData extends Properties {
44
44
  count?: number;
45
45
  runs?: number;
46
46
  }
47
+ interface Status {
48
+ startedAt: number;
49
+ in: number;
50
+ out: number;
51
+ failed: number;
52
+ sources: Record<string, SourceStatus>;
53
+ destinations: Record<string, DestinationStatus>;
54
+ }
55
+ interface SourceStatus {
56
+ count: number;
57
+ lastAt?: number;
58
+ duration: number;
59
+ }
60
+ interface DestinationStatus {
61
+ count: number;
62
+ failed: number;
63
+ lastAt?: number;
64
+ duration: number;
65
+ }
47
66
  interface Sources {
48
67
  [id: string]: Instance;
49
68
  }
@@ -107,19 +126,27 @@ interface Instance$4 {
107
126
  queue: Events;
108
127
  round: number;
109
128
  session: undefined | SessionData;
129
+ status: Status;
110
130
  timing: number;
111
131
  user: User;
112
132
  version: string;
133
+ pending: {
134
+ sources: InitSources;
135
+ destinations: InitDestinations;
136
+ };
113
137
  }
114
138
 
115
139
  type collector_CommandFn = CommandFn;
116
140
  type collector_CommandType = CommandType;
141
+ type collector_DestinationStatus = DestinationStatus;
117
142
  type collector_InitConfig = InitConfig;
118
143
  type collector_PushOptions = PushOptions;
119
144
  type collector_SessionData = SessionData;
145
+ type collector_SourceStatus = SourceStatus;
120
146
  type collector_Sources = Sources;
147
+ type collector_Status = Status;
121
148
  declare namespace collector {
122
- export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$7 as Config, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$4 as Instance, PushFn$1 as PushFn, collector_PushOptions as PushOptions, collector_SessionData as SessionData, collector_Sources as Sources, Transformers$1 as Transformers };
149
+ export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$7 as Config, collector_DestinationStatus as DestinationStatus, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$4 as Instance, PushFn$1 as PushFn, collector_PushOptions as PushOptions, collector_SessionData as SessionData, collector_SourceStatus as SourceStatus, collector_Sources as Sources, collector_Status as Status, Transformers$1 as Transformers };
123
150
  }
124
151
 
125
152
  /**
@@ -251,17 +278,31 @@ interface Instance$3<T extends TypesGeneric$2 = Types$3> {
251
278
  on?: OnFn;
252
279
  }
253
280
  interface Config$6<T extends TypesGeneric$2 = Types$3> {
281
+ /** Required consent states to push events; queues events when not granted. */
254
282
  consent?: Consent;
283
+ /** Implementation-specific configuration passed to the init function. */
255
284
  settings?: InitSettings$2<T>;
285
+ /** Global data transformation applied to all events; result passed as context.data to push. */
256
286
  data?: Value | Values;
287
+ /** Runtime dependencies merged from code and config env; extensible per destination. */
257
288
  env?: Env$2<T>;
289
+ /** Destination identifier; auto-generated if not provided. */
258
290
  id?: string;
291
+ /** Whether the destination has been initialized; prevents re-initialization. */
259
292
  init?: boolean;
293
+ /** Whether to load external scripts (e.g., gtag.js); destination-specific behavior. */
260
294
  loadScript?: boolean;
295
+ /** Logger configuration (level, handler) to override the collector's defaults. */
261
296
  logger?: Config$4;
297
+ /** Entity-action rules to filter, rename, transform, and batch events for this destination. */
262
298
  mapping?: Rules<Rule<Mapping$1<T>>>;
299
+ /** Pre-processing rules applied to all events before mapping; modifies events in-place. */
263
300
  policy?: Policy$1;
301
+ /** Whether to queue events when consent is not granted; defaults to true. */
264
302
  queue?: boolean;
303
+ /** Defer destination initialization until these collector events fire (e.g., `['consent']`). */
304
+ require?: string[];
305
+ /** Transformer chain to run after collector processing but before this destination. */
265
306
  before?: string | string[];
266
307
  }
267
308
  type PartialConfig$1<T extends TypesGeneric$2 = Types$3> = Config$6<Types$3<Partial<Settings$2<T>> | Settings$2<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$2<T>>>;
@@ -1192,41 +1233,57 @@ declare namespace mapping {
1192
1233
  }
1193
1234
 
1194
1235
  type Config$2 = {
1236
+ config?: Array<GenericConfig>;
1195
1237
  consent?: Array<ConsentConfig>;
1238
+ custom?: Array<GenericConfig>;
1239
+ globals?: Array<GenericConfig>;
1196
1240
  ready?: Array<ReadyConfig>;
1197
1241
  run?: Array<RunConfig>;
1198
1242
  session?: Array<SessionConfig>;
1243
+ user?: Array<UserConfig>;
1199
1244
  };
1200
- type Types$2 = keyof Config$2;
1245
+ type Types$2 = keyof Config$2 | (string & {});
1201
1246
  interface EventContextMap {
1247
+ config: Partial<Config$7>;
1202
1248
  consent: Consent;
1203
- session: SessionData;
1249
+ custom: Properties;
1250
+ globals: Properties;
1204
1251
  ready: undefined;
1205
1252
  run: undefined;
1253
+ session: SessionData;
1254
+ user: User;
1206
1255
  }
1207
- type EventContext<T extends Types$2> = EventContextMap[T];
1256
+ type EventContext<T extends keyof EventContextMap> = EventContextMap[T];
1208
1257
  type AnyEventContext = EventContextMap[keyof EventContextMap];
1209
1258
  interface Context$3 {
1210
1259
  consent?: Consent;
1211
1260
  session?: unknown;
1212
1261
  }
1213
- type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
1262
+ type Options = ConsentConfig | GenericConfig | ReadyConfig | RunConfig | SessionConfig | UserConfig;
1214
1263
  interface ConsentConfig {
1215
1264
  [key: string]: ConsentFn;
1216
1265
  }
1217
1266
  type ConsentFn = (collector: Instance$4, consent: Consent) => void;
1267
+ type GenericConfig = GenericFn;
1268
+ type GenericFn = (collector: Instance$4, data: unknown) => void;
1218
1269
  type ReadyConfig = ReadyFn;
1219
1270
  type ReadyFn = (collector: Instance$4) => void;
1220
1271
  type RunConfig = RunFn;
1221
1272
  type RunFn = (collector: Instance$4) => void;
1222
1273
  type SessionConfig = SessionFn;
1223
1274
  type SessionFn = (collector: Instance$4, session?: unknown) => void;
1275
+ type UserConfig = UserFn;
1276
+ type UserFn = (collector: Instance$4, user: User) => void;
1224
1277
  interface OnConfig {
1278
+ config?: GenericConfig[];
1225
1279
  consent?: ConsentConfig[];
1280
+ custom?: GenericConfig[];
1281
+ globals?: GenericConfig[];
1226
1282
  ready?: ReadyConfig[];
1227
1283
  run?: RunConfig[];
1228
1284
  session?: SessionConfig[];
1229
- [key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
1285
+ user?: UserConfig[];
1286
+ [key: string]: ConsentConfig[] | GenericConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | UserConfig[] | undefined;
1230
1287
  }
1231
1288
  type OnFn<T extends TypesGeneric$2 = Types$3> = (type: Types$2, context: Context$4<T>) => PromiseOrValue<void>;
1232
1289
  type OnFnRuntime = (type: Types$2, context: Context$4) => PromiseOrValue<void>;
@@ -1234,8 +1291,10 @@ type OnFnRuntime = (type: Types$2, context: Context$4) => PromiseOrValue<void>;
1234
1291
  type on_AnyEventContext = AnyEventContext;
1235
1292
  type on_ConsentConfig = ConsentConfig;
1236
1293
  type on_ConsentFn = ConsentFn;
1237
- type on_EventContext<T extends Types$2> = EventContext<T>;
1294
+ type on_EventContext<T extends keyof EventContextMap> = EventContext<T>;
1238
1295
  type on_EventContextMap = EventContextMap;
1296
+ type on_GenericConfig = GenericConfig;
1297
+ type on_GenericFn = GenericFn;
1239
1298
  type on_OnConfig = OnConfig;
1240
1299
  type on_OnFn<T extends TypesGeneric$2 = Types$3> = OnFn<T>;
1241
1300
  type on_OnFnRuntime = OnFnRuntime;
@@ -1246,10 +1305,13 @@ type on_RunConfig = RunConfig;
1246
1305
  type on_RunFn = RunFn;
1247
1306
  type on_SessionConfig = SessionConfig;
1248
1307
  type on_SessionFn = SessionFn;
1308
+ type on_UserConfig = UserConfig;
1309
+ type on_UserFn = UserFn;
1249
1310
  declare namespace on {
1250
- export type { on_AnyEventContext as AnyEventContext, Config$2 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, Context$3 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$2 as Types };
1311
+ export type { on_AnyEventContext as AnyEventContext, Config$2 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, Context$3 as Context, on_EventContext as EventContext, on_EventContextMap as EventContextMap, on_GenericConfig as GenericConfig, on_GenericFn as GenericFn, 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$2 as Types, on_UserConfig as UserConfig, on_UserFn as UserFn };
1251
1312
  }
1252
1313
 
1314
+ type Next = string | string[];
1253
1315
  /**
1254
1316
  * Base environment interface for walkerOS transformers.
1255
1317
  *
@@ -1299,7 +1361,7 @@ interface Config$1<T extends TypesGeneric$1 = Types$1> {
1299
1361
  env?: Env$1<T>;
1300
1362
  id?: string;
1301
1363
  logger?: Config$4;
1302
- next?: string;
1364
+ next?: Next;
1303
1365
  init?: boolean;
1304
1366
  }
1305
1367
  /**
@@ -1310,6 +1372,20 @@ interface Context$2<T extends TypesGeneric$1 = Types$1> extends Base<Config$1<T>
1310
1372
  id: string;
1311
1373
  ingest?: unknown;
1312
1374
  }
1375
+ /**
1376
+ * Branch result for dynamic chain routing.
1377
+ * Returned by transformers (e.g., router) to redirect the chain.
1378
+ * The chain runner resolves `next` via walkChain() — same semantics
1379
+ * as source.next or transformer.config.next.
1380
+ *
1381
+ * IMPORTANT: Always use the `branch()` factory function to create BranchResult.
1382
+ * The `__branch` discriminant is required for reliable type detection.
1383
+ */
1384
+ interface BranchResult {
1385
+ readonly __branch: true;
1386
+ event: DeepPartialEvent;
1387
+ next: Next;
1388
+ }
1313
1389
  /**
1314
1390
  * The main transformer function.
1315
1391
  * Uses DeepPartialEvent for consistency across pre/post collector.
@@ -1320,7 +1396,7 @@ interface Context$2<T extends TypesGeneric$1 = Types$1> extends Base<Config$1<T>
1320
1396
  * @returns void - continue with current event unchanged (passthrough)
1321
1397
  * @returns false - stop chain, cancel further processing
1322
1398
  */
1323
- type Fn<T extends TypesGeneric$1 = Types$1> = (event: DeepPartialEvent, context: Context$2<T>) => PromiseOrValue<DeepPartialEvent | false | void>;
1399
+ type Fn<T extends TypesGeneric$1 = Types$1> = (event: DeepPartialEvent, context: Context$2<T>) => PromiseOrValue<DeepPartialEvent | false | void | BranchResult>;
1324
1400
  /**
1325
1401
  * Optional initialization function.
1326
1402
  * Called once before first push.
@@ -1354,6 +1430,7 @@ type InitTransformer<T extends TypesGeneric$1 = Types$1> = {
1354
1430
  code: Init$1<T>;
1355
1431
  config?: Partial<Config$1<T>>;
1356
1432
  env?: Partial<Env$1<T>>;
1433
+ next?: Next;
1357
1434
  };
1358
1435
  /**
1359
1436
  * Transformers configuration for collector.
@@ -1369,13 +1446,15 @@ interface Transformers {
1369
1446
  [transformerId: string]: Instance$1;
1370
1447
  }
1371
1448
 
1449
+ type transformer_BranchResult = BranchResult;
1372
1450
  type transformer_Fn<T extends TypesGeneric$1 = Types$1> = Fn<T>;
1373
1451
  type transformer_InitFn<T extends TypesGeneric$1 = Types$1> = InitFn<T>;
1374
1452
  type transformer_InitTransformer<T extends TypesGeneric$1 = Types$1> = InitTransformer<T>;
1375
1453
  type transformer_InitTransformers = InitTransformers;
1454
+ type transformer_Next = Next;
1376
1455
  type transformer_Transformers = Transformers;
1377
1456
  declare namespace transformer {
1378
- export type { BaseEnv$1 as BaseEnv, Config$1 as Config, Context$2 as Context, Env$1 as Env, transformer_Fn as Fn, Init$1 as Init, transformer_InitFn as InitFn, InitSettings$1 as InitSettings, transformer_InitTransformer as InitTransformer, transformer_InitTransformers as InitTransformers, Instance$1 as Instance, Settings$1 as Settings, transformer_Transformers as Transformers, Types$1 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
1457
+ export type { BaseEnv$1 as BaseEnv, transformer_BranchResult as BranchResult, Config$1 as Config, Context$2 as Context, Env$1 as Env, transformer_Fn as Fn, Init$1 as Init, transformer_InitFn as InitFn, InitSettings$1 as InitSettings, transformer_InitTransformer as InitTransformer, transformer_InitTransformers as InitTransformers, Instance$1 as Instance, transformer_Next as Next, Settings$1 as Settings, transformer_Transformers as Transformers, Types$1 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
1379
1458
  }
1380
1459
 
1381
1460
  interface Context$1 {
@@ -1477,12 +1556,18 @@ type Env<T extends TypesGeneric = Types> = T['env'];
1477
1556
  */
1478
1557
  type TypesOf<I> = I extends Instance<infer T> ? T : never;
1479
1558
  interface Config<T extends TypesGeneric = Types> extends Config$3<Mapping<T>> {
1559
+ /** Implementation-specific configuration passed to the init function. */
1480
1560
  settings?: InitSettings<T>;
1561
+ /** Runtime dependencies injected by the collector (push, command, logger, etc.). */
1481
1562
  env?: Env<T>;
1563
+ /** Source identifier; defaults to the InitSources object key. */
1482
1564
  id?: string;
1565
+ /** Logger configuration (level, handler) to override the collector's defaults. */
1483
1566
  logger?: Config$4;
1484
- disabled?: boolean;
1567
+ /** Mark as primary source; its push function becomes the exported `elb` from startFlow. */
1485
1568
  primary?: boolean;
1569
+ /** Defer source initialization until these collector events fire (e.g., `['consent']`). */
1570
+ require?: string[];
1486
1571
  /**
1487
1572
  * Ingest metadata extraction mapping.
1488
1573
  * Extracts values from raw request objects (Express req, Lambda event, etc.)
@@ -1503,7 +1588,7 @@ interface Instance<T extends TypesGeneric = Types> {
1503
1588
  config: Config<T>;
1504
1589
  push: Push<T>;
1505
1590
  destroy?(): void | Promise<void>;
1506
- on?(event: Types$2, context?: unknown): void | Promise<void>;
1591
+ on?(event: Types$2, context?: unknown): void | boolean | Promise<void | boolean>;
1507
1592
  }
1508
1593
  /**
1509
1594
  * Context provided to source init function.
@@ -1526,7 +1611,7 @@ type InitSource<T extends TypesGeneric = Types> = {
1526
1611
  config?: Partial<Config<T>>;
1527
1612
  env?: Partial<Env<T>>;
1528
1613
  primary?: boolean;
1529
- next?: string;
1614
+ next?: Next;
1530
1615
  };
1531
1616
  /**
1532
1617
  * Sources configuration for collector.
@@ -1692,6 +1777,12 @@ interface SendResponse {
1692
1777
  error?: string;
1693
1778
  }
1694
1779
 
1780
+ /**
1781
+ * Creates a BranchResult for dynamic chain routing.
1782
+ * Use this in transformer push functions to redirect the chain.
1783
+ */
1784
+ declare function branch(event: DeepPartialEvent, next: Next): BranchResult;
1785
+
1695
1786
  /**
1696
1787
  * Anonymizes an IPv4 address by setting the last octet to 0.
1697
1788
  *
@@ -2407,4 +2498,17 @@ declare function wrapFn(code: string): Fn$1;
2407
2498
  */
2408
2499
  declare function wrapValidate(code: string): Validate;
2409
2500
 
2410
- export { collector as Collector, Const, context as Context, 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, transformer as Transformer, 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 };
2501
+ interface WalkerOSPackageInfo {
2502
+ packageName: string;
2503
+ version: string;
2504
+ type?: string;
2505
+ platform?: string;
2506
+ schemas: Record<string, unknown>;
2507
+ examples: Record<string, unknown>;
2508
+ }
2509
+ declare function fetchPackageSchema(packageName: string, options?: {
2510
+ version?: string;
2511
+ timeout?: number;
2512
+ }): Promise<WalkerOSPackageInfo>;
2513
+
2514
+ export { collector as Collector, Const, context as Context, 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, transformer as Transformer, walkeros as WalkerOS, type WalkerOSPackageInfo, anonymizeIP, assign, branch, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, debounce, fetchPackageSchema, 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 };