@walkeros/core 2.0.0 → 2.1.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,3 +1,30 @@
1
+ /**
2
+ * Options for responding to an HTTP request.
3
+ * Same interface for web and server — sources implement the handler.
4
+ */
5
+ interface RespondOptions {
6
+ /** Response body. Objects are JSON-serialized by source. */
7
+ body?: unknown;
8
+ /** HTTP status code (default: 200). Server-only, ignored by web sources. */
9
+ status?: number;
10
+ /** HTTP response headers. Server-only, ignored by web sources. */
11
+ headers?: Record<string, string>;
12
+ }
13
+ /**
14
+ * Standardized response function available on env for every step.
15
+ * Idempotent: first call wins, subsequent calls are no-ops.
16
+ * Created by sources via createRespond(), consumed by any step.
17
+ */
18
+ type RespondFn = (options?: RespondOptions) => void;
19
+ /**
20
+ * Creates an idempotent respond function.
21
+ * The sender callback is source-specific (Express wraps res, Fetch wraps Response, etc.).
22
+ *
23
+ * @param sender - Platform-specific function that actually sends the response
24
+ * @returns Idempotent respond function (first call wins)
25
+ */
26
+ declare function createRespond(sender: (options: RespondOptions) => void): RespondFn;
27
+
1
28
  /**
2
29
  * Core collector configuration interface
3
30
  */
@@ -80,6 +107,7 @@ type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' |
80
107
  interface PushOptions {
81
108
  id?: string;
82
109
  ingest?: unknown;
110
+ respond?: RespondFn;
83
111
  mapping?: Config$3;
84
112
  preChain?: string[];
85
113
  }
@@ -180,15 +208,15 @@ interface Contexts {
180
208
  interface Entities$1 {
181
209
  [name: string]: Entity$1;
182
210
  }
183
- interface Properties$2 {
184
- [name: string]: Property$2;
211
+ interface Properties$1 {
212
+ [name: string]: Property$1;
185
213
  }
186
- interface Global extends Property$2 {
214
+ interface Global extends Property$1 {
187
215
  }
188
- interface Context$5 extends Property$2 {
216
+ interface Context$5 extends Property$1 {
189
217
  }
190
218
  interface Entity$1 {
191
- data: Properties$2;
219
+ data: Properties$1;
192
220
  actions: Actions;
193
221
  }
194
222
  interface Actions {
@@ -198,7 +226,7 @@ interface Action {
198
226
  trigger?: Trigger;
199
227
  }
200
228
  type Trigger = string;
201
- interface Property$2 {
229
+ interface Property$1 {
202
230
  type?: PropertyType$1;
203
231
  required?: boolean;
204
232
  values?: PropertyValues;
@@ -214,7 +242,38 @@ type data_Globals = Globals;
214
242
  type data_PropertyValues = PropertyValues;
215
243
  type data_Trigger = Trigger;
216
244
  declare namespace data {
217
- export type { data_Action as Action, data_Actions as Actions, Context$5 as Context, data_Contexts as Contexts, Contract$1 as Contract, Entities$1 as Entities, Entity$1 as Entity, data_Global as Global, data_Globals as Globals, Properties$2 as Properties, Property$2 as Property, PropertyType$1 as PropertyType, data_PropertyValues as PropertyValues, data_Trigger as Trigger };
245
+ export type { data_Action as Action, data_Actions as Actions, Context$5 as Context, data_Contexts as Contexts, Contract$1 as Contract, Entities$1 as Entities, Entity$1 as Entity, data_Global as Global, data_Globals as Globals, Properties$1 as Properties, Property$1 as Property, PropertyType$1 as PropertyType, data_PropertyValues as PropertyValues, data_Trigger as Trigger };
246
+ }
247
+
248
+ /**
249
+ * Context provided to the destroy() lifecycle method.
250
+ *
251
+ * A subset of the init context — config, env, logger, and id.
252
+ * Does NOT include collector or event data. Destroy should only
253
+ * clean up resources, not interact with the event pipeline.
254
+ */
255
+ interface DestroyContext<C = unknown, E = unknown> {
256
+ /** Step instance ID. */
257
+ id: string;
258
+ /** Step configuration (contains settings with SDK clients, etc.). */
259
+ config: C;
260
+ /** Runtime environment/dependencies (DB clients, auth clients, etc.). */
261
+ env: E;
262
+ /** Scoped logger for this step instance. */
263
+ logger: Instance$2;
264
+ }
265
+ /**
266
+ * Destroy function signature for step lifecycle cleanup.
267
+ *
268
+ * Implementations should be idempotent — calling destroy() twice must not throw.
269
+ * Used for closing connections, clearing timers, releasing SDK clients.
270
+ */
271
+ type DestroyFn<C = unknown, E = unknown> = (context: DestroyContext<C, E>) => PromiseOrValue<void>;
272
+
273
+ type lifecycle_DestroyContext<C = unknown, E = unknown> = DestroyContext<C, E>;
274
+ type lifecycle_DestroyFn<C = unknown, E = unknown> = DestroyFn<C, E>;
275
+ declare namespace lifecycle {
276
+ export type { lifecycle_DestroyContext as DestroyContext, lifecycle_DestroyFn as DestroyFn };
218
277
  }
219
278
 
220
279
  /**
@@ -276,6 +335,7 @@ interface Instance$3<T extends TypesGeneric$2 = Types$3> {
276
335
  push: PushFn<T>;
277
336
  pushBatch?: PushBatchFn<T>;
278
337
  on?: OnFn;
338
+ destroy?: DestroyFn<Config$6<T>, Env$2<T>>;
279
339
  }
280
340
  interface Config$6<T extends TypesGeneric$2 = Types$3> {
281
341
  /** Required consent states to push events; queues events when not granted. */
@@ -439,9 +499,54 @@ declare namespace elb {
439
499
  * (web_prod, web_stage, server_prod, etc.) with shared configuration,
440
500
  * variables, and reusable definitions.
441
501
  *
502
+ * ## Connection Rules
503
+ *
504
+ * Sources use `next` to connect to transformers (pre-collector chain).
505
+ * Sources cannot have `before`.
506
+ *
507
+ * Destinations use `before` to connect to transformers (post-collector chain).
508
+ * Destinations cannot have `next`.
509
+ *
510
+ * Transformers use `next` to chain to other transformers. The same transformer
511
+ * pool is shared by both pre-collector and post-collector chains.
512
+ *
513
+ * The collector is implicit — it is never referenced directly in connections.
514
+ * It sits between the source chain and the destination chain automatically.
515
+ *
516
+ * Circular `next` references are safely handled at runtime by `walkChain()`
517
+ * in the collector module (visited-set detection).
518
+ *
519
+ * ```
520
+ * Source → [next → Transformer chain] → Collector → [before → Transformer chain] → Destination
521
+ * ```
522
+ *
442
523
  * @packageDocumentation
443
524
  */
444
525
 
526
+ /**
527
+ * JSON Schema object for contract entry validation.
528
+ * Standard JSON Schema with description/examples annotations.
529
+ * Compatible with AJV for runtime validation.
530
+ */
531
+ type ContractSchema = Record<string, unknown>;
532
+ /**
533
+ * Contract action entries keyed by action name.
534
+ * Each value is a JSON Schema describing the expected WalkerOS.Event shape.
535
+ * Use "*" as wildcard for all actions of an entity.
536
+ */
537
+ type ContractActions = Record<string, ContractSchema>;
538
+ /**
539
+ * Data contract definition.
540
+ * Entity → action keyed JSON Schema with additive inheritance.
541
+ *
542
+ * Special keys:
543
+ * - "$tagging": Contract version number (syncs to event.version.tagging)
544
+ * - "*": Wildcard entity/action (matches all)
545
+ */
546
+ interface Contract {
547
+ $tagging?: number;
548
+ [entity: string]: ContractActions | number | undefined;
549
+ }
445
550
  /**
446
551
  * Primitive value types for variables
447
552
  */
@@ -526,7 +631,7 @@ interface Setup {
526
631
  /**
527
632
  * Configuration schema version.
528
633
  */
529
- version: 1;
634
+ version: 1 | 2;
530
635
  /**
531
636
  * JSON Schema reference for IDE validation.
532
637
  * @example "https://walkeros.io/schema/flow/v1.json"
@@ -550,6 +655,11 @@ interface Setup {
550
655
  * ```
551
656
  */
552
657
  include?: string[];
658
+ /**
659
+ * Data contract definition (version 2+).
660
+ * Entity → action keyed JSON Schema with additive inheritance.
661
+ */
662
+ contract?: Contract;
553
663
  /**
554
664
  * Shared variables for interpolation.
555
665
  * Resolution: destination/source > Config > Setup level
@@ -590,6 +700,11 @@ interface Config$5 {
590
700
  * Mutually exclusive with `web`.
591
701
  */
592
702
  server?: Server;
703
+ /**
704
+ * Data contract definition for this flow.
705
+ * Merges on top of Setup-level contract (additive).
706
+ */
707
+ contract?: Contract;
593
708
  /**
594
709
  * Source configurations (data capture).
595
710
  *
@@ -726,6 +841,20 @@ interface Config$5 {
726
841
  */
727
842
  definitions?: Definitions;
728
843
  }
844
+ /**
845
+ * Named example pair for a step.
846
+ * `in` is the input to the step, `out` is the expected output.
847
+ * `out: false` indicates the step filters/drops this event.
848
+ */
849
+ interface StepExample {
850
+ in?: unknown;
851
+ mapping?: unknown;
852
+ out?: unknown;
853
+ }
854
+ /**
855
+ * Named step examples keyed by scenario name.
856
+ */
857
+ type StepExamples = Record<string, StepExample>;
729
858
  /**
730
859
  * Source reference with inline package syntax.
731
860
  *
@@ -825,14 +954,20 @@ interface SourceReference {
825
954
  */
826
955
  definitions?: Definitions;
827
956
  /**
828
- * First transformer in post-source chain.
957
+ * First transformer in pre-collector chain.
829
958
  *
830
959
  * @remarks
831
960
  * Name of the transformer to execute after this source captures an event.
961
+ * Creates a pre-collector transformer chain. Chain ends at the collector.
832
962
  * If omitted, events route directly to the collector.
833
963
  * Can be an array for explicit chain control (bypasses transformer.next resolution).
834
964
  */
835
965
  next?: string | string[];
966
+ /**
967
+ * Named examples for testing and documentation.
968
+ * Stripped during flow resolution (not included in bundles).
969
+ */
970
+ examples?: StepExamples;
836
971
  }
837
972
  /**
838
973
  * Transformer reference with inline package syntax.
@@ -893,10 +1028,11 @@ interface TransformerReference {
893
1028
  *
894
1029
  * @remarks
895
1030
  * Name of the next transformer to execute after this one.
896
- * If omitted:
897
- * - Pre-collector: routes to collector
898
- * - Post-collector: routes to destination
899
- * Can be an array for explicit chain control (terminates chain walking).
1031
+ * When used in a pre-collector chain (source.next), terminates at the collector.
1032
+ * When used in a post-collector chain (destination.before), terminates at the destination.
1033
+ * If omitted, the chain ends and control passes to the next pipeline stage.
1034
+ * Array values define an explicit chain (no walking). Circular references
1035
+ * are safely detected at runtime by `walkChain()`.
900
1036
  */
901
1037
  next?: string | string[];
902
1038
  /**
@@ -909,6 +1045,11 @@ interface TransformerReference {
909
1045
  * Overrides flow and setup definitions.
910
1046
  */
911
1047
  definitions?: Definitions;
1048
+ /**
1049
+ * Named examples for testing and documentation.
1050
+ * Stripped during flow resolution (not included in bundles).
1051
+ */
1052
+ examples?: StepExamples;
912
1053
  }
913
1054
  /**
914
1055
  * Destination reference with inline package syntax.
@@ -999,16 +1140,25 @@ interface DestinationReference {
999
1140
  */
1000
1141
  definitions?: Definitions;
1001
1142
  /**
1002
- * First transformer in pre-destination chain.
1143
+ * First transformer in post-collector chain.
1003
1144
  *
1004
1145
  * @remarks
1005
1146
  * Name of the transformer to execute before sending events to this destination.
1147
+ * Creates a post-collector transformer chain. Chain ends at this destination.
1006
1148
  * If omitted, events are sent directly from the collector.
1007
1149
  * Can be an array for explicit chain control (bypasses transformer.next resolution).
1008
1150
  */
1009
1151
  before?: string | string[];
1152
+ /**
1153
+ * Named examples for testing and documentation.
1154
+ * Stripped during flow resolution (not included in bundles).
1155
+ */
1156
+ examples?: StepExamples;
1010
1157
  }
1011
1158
 
1159
+ type flow_Contract = Contract;
1160
+ type flow_ContractActions = ContractActions;
1161
+ type flow_ContractSchema = ContractSchema;
1012
1162
  type flow_Definitions = Definitions;
1013
1163
  type flow_DestinationReference = DestinationReference;
1014
1164
  type flow_InlineCode = InlineCode;
@@ -1017,11 +1167,13 @@ type flow_Primitive = Primitive;
1017
1167
  type flow_Server = Server;
1018
1168
  type flow_Setup = Setup;
1019
1169
  type flow_SourceReference = SourceReference;
1170
+ type flow_StepExample = StepExample;
1171
+ type flow_StepExamples = StepExamples;
1020
1172
  type flow_TransformerReference = TransformerReference;
1021
1173
  type flow_Variables = Variables;
1022
1174
  type flow_Web = Web;
1023
1175
  declare namespace flow {
1024
- export type { Config$5 as Config, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_InlineCode as InlineCode, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_TransformerReference as TransformerReference, flow_Variables as Variables, flow_Web as Web };
1176
+ export type { Config$5 as Config, flow_Contract as Contract, flow_ContractActions as ContractActions, flow_ContractSchema as ContractSchema, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_InlineCode as InlineCode, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_StepExample as StepExample, flow_StepExamples as StepExamples, flow_TransformerReference as TransformerReference, flow_Variables as Variables, flow_Web as Web };
1025
1177
  }
1026
1178
 
1027
1179
  type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
@@ -1045,8 +1197,9 @@ declare namespace hooks {
1045
1197
  */
1046
1198
  declare enum Level {
1047
1199
  ERROR = 0,
1048
- INFO = 1,
1049
- DEBUG = 2
1200
+ WARN = 1,
1201
+ INFO = 2,
1202
+ DEBUG = 3
1050
1203
  }
1051
1204
  /**
1052
1205
  * Normalized error context extracted from Error objects
@@ -1093,6 +1246,10 @@ interface Instance$2 {
1093
1246
  * Log an error message (always visible unless silenced)
1094
1247
  */
1095
1248
  error: LogFn;
1249
+ /**
1250
+ * Log a warning (degraded state, config issues, transient failures)
1251
+ */
1252
+ warn: LogFn;
1096
1253
  /**
1097
1254
  * Log an informational message
1098
1255
  */
@@ -1106,6 +1263,10 @@ interface Instance$2 {
1106
1263
  * Combines logging and throwing in one call
1107
1264
  */
1108
1265
  throw: ThrowFn;
1266
+ /**
1267
+ * Output structured JSON data
1268
+ */
1269
+ json: (data: unknown) => void;
1109
1270
  /**
1110
1271
  * Create a scoped child logger with automatic trace path
1111
1272
  * @param name - Scope name (e.g., destination type, destination key)
@@ -1127,6 +1288,8 @@ interface Config$4 {
1127
1288
  * Receives originalHandler to preserve default behavior
1128
1289
  */
1129
1290
  handler?: Handler;
1291
+ /** Custom handler for json() output. Default: console.log(JSON.stringify(data, null, 2)) */
1292
+ jsonHandler?: (data: unknown) => void;
1130
1293
  }
1131
1294
  /**
1132
1295
  * Internal config with resolved values and scope
@@ -1134,6 +1297,7 @@ interface Config$4 {
1134
1297
  interface InternalConfig {
1135
1298
  level: Level;
1136
1299
  handler?: Handler;
1300
+ jsonHandler?: (data: unknown) => void;
1137
1301
  scope: string[];
1138
1302
  }
1139
1303
  /**
@@ -1183,7 +1347,7 @@ interface Rule<Settings = unknown> {
1183
1347
  name?: string;
1184
1348
  policy?: Policy;
1185
1349
  }
1186
- interface Result {
1350
+ interface Result$1 {
1187
1351
  eventMapping?: Rule;
1188
1352
  mappingKey?: string;
1189
1353
  }
@@ -1220,7 +1384,6 @@ type mapping_Data = Data;
1220
1384
  type mapping_Loop = Loop;
1221
1385
  type mapping_Map = Map;
1222
1386
  type mapping_Policy = Policy;
1223
- type mapping_Result = Result;
1224
1387
  type mapping_Rule<Settings = unknown> = Rule<Settings>;
1225
1388
  type mapping_Rules<T = Rule> = Rules<T>;
1226
1389
  type mapping_Validate = Validate;
@@ -1229,7 +1392,7 @@ type mapping_ValueConfig = ValueConfig;
1229
1392
  type mapping_ValueType = ValueType;
1230
1393
  type mapping_Values = Values;
1231
1394
  declare namespace mapping {
1232
- export type { mapping_Condition as Condition, Config$3 as Config, mapping_Data as Data, Fn$1 as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Policy as Policy, mapping_Result as Result, mapping_Rule as Rule, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
1395
+ export type { mapping_Condition as Condition, Config$3 as Config, mapping_Data as Data, Fn$1 as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Policy as Policy, Result$1 as Result, mapping_Rule as Rule, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
1233
1396
  }
1234
1397
 
1235
1398
  type Config$2 = {
@@ -1415,7 +1578,7 @@ interface Instance$1<T extends TypesGeneric$1 = Types$1> {
1415
1578
  config: Config$1<T>;
1416
1579
  push: Fn<T>;
1417
1580
  init?: InitFn<T>;
1418
- destroy?: () => void | Promise<void>;
1581
+ destroy?: DestroyFn<Config$1<T>, Env$1<T>>;
1419
1582
  }
1420
1583
  /**
1421
1584
  * Transformer initialization function.
@@ -1474,34 +1637,6 @@ declare namespace request {
1474
1637
  export type { Context$1 as Context };
1475
1638
  }
1476
1639
 
1477
- type Contracts = Array<Contract>;
1478
- type Contract = {
1479
- [entity: string]: {
1480
- [action: string]: Properties$1;
1481
- };
1482
- };
1483
- type Properties$1 = {
1484
- [key: string]: Property$1 | undefined;
1485
- };
1486
- type Property$1 = {
1487
- allowedKeys?: string[];
1488
- allowedValues?: unknown[];
1489
- maxLength?: number;
1490
- max?: number;
1491
- min?: number;
1492
- required?: boolean;
1493
- schema?: Properties$1;
1494
- strict?: boolean;
1495
- type?: string;
1496
- validate?: (value: unknown, key: string, event: AnyObject) => Property;
1497
- };
1498
-
1499
- type schema_Contract = Contract;
1500
- type schema_Contracts = Contracts;
1501
- declare namespace schema {
1502
- export type { schema_Contract as Contract, schema_Contracts as Contracts, Properties$1 as Properties, Property$1 as Property };
1503
- }
1504
-
1505
1640
  /**
1506
1641
  * Base Env interface for dependency injection into sources.
1507
1642
  *
@@ -1587,7 +1722,7 @@ interface Instance<T extends TypesGeneric = Types> {
1587
1722
  type: string;
1588
1723
  config: Config<T>;
1589
1724
  push: Push<T>;
1590
- destroy?(): void | Promise<void>;
1725
+ destroy?: DestroyFn<Config<T>, Env<T>>;
1591
1726
  on?(event: Types$2, context?: unknown): void | boolean | Promise<void | boolean>;
1592
1727
  }
1593
1728
  /**
@@ -1604,6 +1739,8 @@ interface Context<T extends TypesGeneric = Types> extends Base<Partial<Config<T>
1604
1739
  * @param value - Raw request object (Express req, Lambda event, etc.)
1605
1740
  */
1606
1741
  setIngest: (value: unknown) => Promise<void>;
1742
+ /** Sets respond function for the current request. Called by source per-request. */
1743
+ setRespond: (fn: RespondFn | undefined) => void;
1607
1744
  }
1608
1745
  type Init<T extends TypesGeneric = Types> = (context: Context<T>) => Instance<T> | Promise<Instance<T>>;
1609
1746
  type InitSource<T extends TypesGeneric = Types> = {
@@ -1620,6 +1757,32 @@ type InitSource<T extends TypesGeneric = Types> = {
1620
1757
  interface InitSources {
1621
1758
  [sourceId: string]: InitSource<any>;
1622
1759
  }
1760
+ /**
1761
+ * Renderer hint for source simulation UI.
1762
+ * - 'browser': Source needs a real DOM (iframe with live preview)
1763
+ * - 'codebox': Source uses a JSON/code editor (default)
1764
+ */
1765
+ type Renderer = 'browser' | 'codebox';
1766
+ /**
1767
+ * Minimal environment contract for source simulation.
1768
+ * Both JSDOM and iframe satisfy this interface.
1769
+ */
1770
+ interface SimulationEnv {
1771
+ window: Window & typeof globalThis;
1772
+ document: Document;
1773
+ localStorage: Storage;
1774
+ [key: string]: unknown;
1775
+ }
1776
+ /**
1777
+ * Setup function for source simulation.
1778
+ * Runs BEFORE startFlow() to prepare the environment
1779
+ * (dataLayer arrays, localStorage, window globals).
1780
+ *
1781
+ * Return void for sources that need no post-init action.
1782
+ * Return a () => void trigger for sources that dispatch
1783
+ * events AFTER startFlow() (e.g., usercentrics CustomEvent).
1784
+ */
1785
+ type SetupFn = (input: unknown, env: SimulationEnv) => void | (() => void);
1623
1786
 
1624
1787
  type source_BaseEnv = BaseEnv;
1625
1788
  type source_Config<T extends TypesGeneric = Types> = Config<T>;
@@ -1633,12 +1796,15 @@ type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
1633
1796
  type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
1634
1797
  type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
1635
1798
  type source_Push<T extends TypesGeneric = Types> = Push<T>;
1799
+ type source_Renderer = Renderer;
1636
1800
  type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
1801
+ type source_SetupFn = SetupFn;
1802
+ type source_SimulationEnv = SimulationEnv;
1637
1803
  type source_Types<S = unknown, M = unknown, P = Fn$2, E = BaseEnv, I = S> = Types<S, M, P, E, I>;
1638
1804
  type source_TypesGeneric = TypesGeneric;
1639
1805
  type source_TypesOf<I> = TypesOf<I>;
1640
1806
  declare namespace source {
1641
- export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Context as Context, source_Env as Env, source_Init as Init, source_InitSettings as InitSettings, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
1807
+ export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Context as Context, source_Env as Env, source_Init as Init, source_InitSettings as InitSettings, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Renderer as Renderer, source_Settings as Settings, source_SetupFn as SetupFn, source_SimulationEnv as SimulationEnv, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
1642
1808
  }
1643
1809
 
1644
1810
  type AnyObject<T = unknown> = Record<string, T>;
@@ -1756,6 +1922,48 @@ declare namespace walkeros {
1756
1922
  export type { walkeros_ActionHandler as ActionHandler, walkeros_AnyFunction as AnyFunction, walkeros_AnyObject as AnyObject, walkeros_Consent as Consent, walkeros_ConsentHandler as ConsentHandler, walkeros_DeepPartial as DeepPartial, walkeros_DeepPartialEvent as DeepPartialEvent, walkeros_Elb as Elb, walkeros_Entities as Entities, walkeros_Entity as Entity, walkeros_Event as Event, walkeros_Events as Events, walkeros_OrderedProperties as OrderedProperties, walkeros_PartialEvent as PartialEvent, walkeros_PromiseOrValue as PromiseOrValue, walkeros_Properties as Properties, walkeros_Property as Property, walkeros_PropertyType as PropertyType, walkeros_SingleOrArray as SingleOrArray, walkeros_Source as Source, walkeros_SourceType as SourceType, walkeros_User as User, walkeros_Version as Version };
1757
1923
  }
1758
1924
 
1925
+ /**
1926
+ * A recorded function call made during simulation.
1927
+ * Captures what a destination called on its env (e.g., window.gtag).
1928
+ */
1929
+ interface Call {
1930
+ /** Dot-path of the function called: "window.gtag", "dataLayer.push" */
1931
+ fn: string;
1932
+ /** Arguments passed to the function */
1933
+ args: unknown[];
1934
+ /** Unix timestamp in ms */
1935
+ ts: number;
1936
+ }
1937
+ /**
1938
+ * Result of simulating a single step.
1939
+ * Same shape for source, transformer, and destination.
1940
+ */
1941
+ interface Result {
1942
+ /** Which step type was simulated */
1943
+ step: 'source' | 'transformer' | 'destination';
1944
+ /** Step name, e.g. "gtag", "dataLayer", "enricher" */
1945
+ name: string;
1946
+ /**
1947
+ * Output events:
1948
+ * - source: captured pre-collector events
1949
+ * - transformer: [transformed event] or [] if filtered
1950
+ * - destination: [] (destinations don't produce events)
1951
+ */
1952
+ events: DeepPartialEvent[];
1953
+ /** Intercepted env calls. Populated for destinations, empty [] for others. */
1954
+ calls: Call[];
1955
+ /** Execution time in ms */
1956
+ duration: number;
1957
+ /** Error if the step threw */
1958
+ error?: Error;
1959
+ }
1960
+
1961
+ type simulation_Call = Call;
1962
+ type simulation_Result = Result;
1963
+ declare namespace simulation {
1964
+ export type { simulation_Call as Call, simulation_Result as Result };
1965
+ }
1966
+
1759
1967
  type StorageType = 'local' | 'session' | 'cookie';
1760
1968
  declare const Const: {
1761
1969
  readonly Utils: {
@@ -1799,6 +2007,11 @@ declare function anonymizeIP(ip: string): string;
1799
2007
  * @packageDocumentation
1800
2008
  */
1801
2009
 
2010
+ /** Sentinel prefix for deferred $env resolution. Shared with CLI bundler. */
2011
+ declare const ENV_MARKER_PREFIX = "__WALKEROS_ENV:";
2012
+ interface ResolveOptions {
2013
+ deferred?: boolean;
2014
+ }
1802
2015
  /**
1803
2016
  * Convert package name to valid JavaScript variable name.
1804
2017
  * Used for deterministic default import naming.
@@ -1828,7 +2041,7 @@ declare function packageNameToVariable(packageName: string): string;
1828
2041
  * const prodConfig = getFlowConfig(setup, 'production');
1829
2042
  * ```
1830
2043
  */
1831
- declare function getFlowConfig(setup: Setup, flowName?: string): Config$5;
2044
+ declare function getFlowConfig(setup: Setup, flowName?: string, options?: ResolveOptions): Config$5;
1832
2045
  /**
1833
2046
  * Get platform from config (web or server).
1834
2047
  *
@@ -2111,7 +2324,7 @@ declare function createLogger(config?: Config$4): Instance$2;
2111
2324
  * @param mapping The mapping rules.
2112
2325
  * @returns The mapping result.
2113
2326
  */
2114
- declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules): Promise<Result>;
2327
+ declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules): Promise<Result$1>;
2115
2328
  /**
2116
2329
  * Gets a value from a mapping.
2117
2330
  *
@@ -2221,9 +2434,11 @@ declare function traverseEnv<T extends object>(env: T, replacer: (value: unknown
2221
2434
  */
2222
2435
  interface MockLogger extends Instance$2 {
2223
2436
  error: jest.Mock;
2437
+ warn: jest.Mock;
2224
2438
  info: jest.Mock;
2225
2439
  debug: jest.Mock;
2226
2440
  throw: jest.Mock<never, [string | Error, unknown?]>;
2441
+ json: jest.Mock;
2227
2442
  scope: jest.Mock<MockLogger, [string]>;
2228
2443
  /**
2229
2444
  * Array of all scoped loggers created by this logger
@@ -2396,25 +2611,6 @@ declare function getOSVersion(userAgent: string): string | undefined;
2396
2611
  */
2397
2612
  declare function getDeviceType(userAgent: string): string | undefined;
2398
2613
 
2399
- /**
2400
- * Validates an event against a set of contracts.
2401
- *
2402
- * @param obj The event to validate.
2403
- * @param customContracts The custom contracts to use.
2404
- * @returns The validated event.
2405
- */
2406
- declare function validateEvent(obj: unknown, customContracts?: Contracts): Event | never;
2407
- /**
2408
- * Validates a property against a schema.
2409
- *
2410
- * @param obj The object to validate.
2411
- * @param key The key of the property to validate.
2412
- * @param value The value of the property to validate.
2413
- * @param schema The schema to validate against.
2414
- * @returns The validated property.
2415
- */
2416
- declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
2417
-
2418
2614
  /**
2419
2615
  * Inline Code Wrapping Utilities
2420
2616
  *
@@ -2498,6 +2694,13 @@ declare function wrapFn(code: string): Fn$1;
2498
2694
  */
2499
2695
  declare function wrapValidate(code: string): Validate;
2500
2696
 
2697
+ interface WalkerOSPackageMeta {
2698
+ packageName: string;
2699
+ version: string;
2700
+ description?: string;
2701
+ type?: string;
2702
+ platform?: string;
2703
+ }
2501
2704
  interface WalkerOSPackageInfo {
2502
2705
  packageName: string;
2503
2706
  version: string;
@@ -2510,5 +2713,42 @@ declare function fetchPackageSchema(packageName: string, options?: {
2510
2713
  version?: string;
2511
2714
  timeout?: number;
2512
2715
  }): Promise<WalkerOSPackageInfo>;
2716
+ declare function fetchPackageMeta(packageName: string, options?: {
2717
+ version?: string;
2718
+ timeout?: number;
2719
+ }): Promise<WalkerOSPackageMeta>;
2720
+
2721
+ /**
2722
+ * Deep merge two JSON Schema objects with additive semantics.
2723
+ * - `required` arrays: union (deduplicated)
2724
+ * - `properties`: deep merge (child wins on conflict for scalars)
2725
+ * - Scalars: child overrides parent
2726
+ */
2727
+ declare function mergeContractSchemas(parent: Record<string, unknown>, child: Record<string, unknown>): Record<string, unknown>;
2728
+ /**
2729
+ * Resolve a contract for a specific entity-action pair.
2730
+ * Merges matching levels additively:
2731
+ * 1. setup["*"]["*"]
2732
+ * 2. setup["*"][action]
2733
+ * 3. setup[entity]["*"]
2734
+ * 4. setup[entity][action]
2735
+ * 5-8. Same for config-level contract
2736
+ */
2737
+ declare function resolveContract(setup: Contract, entity: string, action: string, config?: Contract): Record<string, unknown>;
2738
+
2739
+ declare function mcpResult(result: unknown): {
2740
+ content: {
2741
+ type: "text";
2742
+ text: string;
2743
+ }[];
2744
+ structuredContent: Record<string, unknown>;
2745
+ };
2746
+ declare function mcpError(error: unknown): {
2747
+ content: {
2748
+ type: "text";
2749
+ text: string;
2750
+ }[];
2751
+ isError: true;
2752
+ };
2513
2753
 
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 };
2754
+ export { collector as Collector, Const, context as Context, data as Data, destination as Destination, ENV_MARKER_PREFIX, elb as Elb, flow as Flow, hooks as Hooks, Level, lifecycle as Lifecycle, logger as Logger, mapping as Mapping, type MarketingParameters, type MockLogger, on as On, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, type SendDataValue, type SendHeaders, type SendResponse, simulation as Simulation, source as Source, type StorageType, transformer as Transformer, walkeros as WalkerOS, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, assign, branch, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, createRespond, debounce, fetchPackageMeta, 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, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContract, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, wrapCondition, wrapFn, wrapValidate };