@walkeros/core 4.7.0-next-1790245733116 → 4.7.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.mts CHANGED
@@ -892,6 +892,13 @@ interface State {
892
892
  * validation requires it for get/set.
893
893
  */
894
894
  value?: Value;
895
+ /**
896
+ * Shapes the value read (get) or the resolved payload (set) with a full
897
+ * mapping value. Paths are relative to that value, not to { event, ingest }.
898
+ * The result merges into the target: get into the `value` path, set into
899
+ * the stored entry. Runs on a miss too, so declared fallbacks apply.
900
+ */
901
+ mapping?: Value;
895
902
  }
896
903
 
897
904
  /**
@@ -1078,6 +1085,9 @@ interface Config$5<T extends TypesGeneric$3 = Types$4> {
1078
1085
  /**
1079
1086
  * Per-destination delivery timeout in ms (default 10000); a delivery that
1080
1087
  * does not settle within this window is routed to the DLQ like a thrown push.
1088
+ * Also bounds an `on()` handler: a state handler that does not settle within
1089
+ * the window is logged, and the destination is held (its events stay queued)
1090
+ * until a later state delivery to it settles.
1081
1091
  */
1082
1092
  timeout?: number;
1083
1093
  /** Return this value instead of calling push(). Uses !== undefined check to support falsy values. */
@@ -1887,7 +1897,8 @@ declare namespace Flow {
1887
1897
  /**
1888
1898
  * Arbitrary key-value settings consumed by the platform runtime.
1889
1899
  *
1890
- * For web: typical keys include `windowCollector`.
1900
+ * For web: `windowCollector` names the global the collector instance is
1901
+ * assigned to (default `walkerOS`); it must be a JavaScript identifier.
1891
1902
  * For server: reserved for future server-specific options.
1892
1903
  *
1893
1904
  * The `windowElb` key is deprecated: the browser source is the single writer
@@ -2643,6 +2654,9 @@ interface OnConfig {
2643
2654
  /**
2644
2655
  * Destination `on` handler: receives the action type and a destination context.
2645
2656
  * Already context-style; kept for compatibility with the destination interface.
2657
+ * The collector awaits the returned promise and bounds the wait by
2658
+ * `Destination.Config.timeout`; the handler's effects therefore land before
2659
+ * the destination's next push.
2646
2660
  */
2647
2661
  type OnFn<T extends TypesGeneric$3 = Types$4> = (type: Types$2, context: Context$5<T>) => PromiseOrValue<void>;
2648
2662
  type OnFnRuntime = (type: Types$2, context: Context$5) => PromiseOrValue<void>;
@@ -3376,7 +3390,8 @@ declare namespace walkeros {
3376
3390
 
3377
3391
  /**
3378
3392
  * A recorded function call made during simulation.
3379
- * Captures what a destination called on its env (e.g., window.gtag).
3393
+ * Captures what a destination called on its env (e.g., window.gtag), or a
3394
+ * walker command a source issued (`fn: 'elb'`, first argument verbatim).
3380
3395
  */
3381
3396
  interface Call {
3382
3397
  /** Dot-path of the function called: "window.gtag", "dataLayer.push" */
@@ -3386,6 +3401,22 @@ interface Call {
3386
3401
  /** Unix timestamp in ms */
3387
3402
  ts: number;
3388
3403
  }
3404
+ /**
3405
+ * Why a simulated destination sent nothing, read from the collector's own
3406
+ * records:
3407
+ * - `consent`: the event was skipped at the consent gate (or queued, with
3408
+ * `queue: true`). `required` is the destination's `config.consent`,
3409
+ * `granted` the collector consent plus the event's own consent.
3410
+ * - `pending`: the destination is still waiting for its `require` entries
3411
+ * (listed in `require`), so it never started.
3412
+ */
3413
+ interface Skipped {
3414
+ reason: 'consent' | 'pending';
3415
+ required?: Consent;
3416
+ granted?: Consent;
3417
+ /** `pending` only: the `require` entries still unmet. */
3418
+ require?: string[];
3419
+ }
3389
3420
  /**
3390
3421
  * Result of simulating a single step.
3391
3422
  * Same shape for source, transformer, collector, and destination.
@@ -3403,7 +3434,14 @@ interface Result {
3403
3434
  * - destination: [] (destinations don't produce events)
3404
3435
  */
3405
3436
  events: DeepPartialEvent[];
3406
- /** Intercepted env calls. Populated for destinations, empty [] for others. */
3437
+ /**
3438
+ * Recorded calls, in time order:
3439
+ * - source: its own walker commands (`fn: 'elb'`, e.g. a CMP's
3440
+ * `['walker consent', {...}]` or the session's `['user', {...}]`) and
3441
+ * its mock-env calls
3442
+ * - destination: its intercepted env calls
3443
+ * - transformer, collector: []
3444
+ */
3407
3445
  calls: Call[];
3408
3446
  /** Execution time in ms */
3409
3447
  duration: number;
@@ -3416,14 +3454,20 @@ interface Result {
3416
3454
  * available.
3417
3455
  */
3418
3456
  mappingKey?: string;
3457
+ /**
3458
+ * Destination simulations only: why nothing was sent, when the collector
3459
+ * recorded a consent skip or the destination is still pending.
3460
+ */
3461
+ skipped?: Skipped;
3419
3462
  /** Error if the step threw */
3420
3463
  error?: Error;
3421
3464
  }
3422
3465
 
3423
3466
  type simulation_Call = Call;
3424
3467
  type simulation_Result = Result;
3468
+ type simulation_Skipped = Skipped;
3425
3469
  declare namespace simulation {
3426
- export type { simulation_Call as Call, simulation_Result as Result };
3470
+ export type { simulation_Call as Call, simulation_Result as Result, simulation_Skipped as Skipped };
3427
3471
  }
3428
3472
 
3429
3473
  interface Code {
@@ -3786,6 +3830,18 @@ declare class FlowReferenceError extends Error {
3786
3830
  readonly reference: string;
3787
3831
  constructor(code: 'MISSING_ENV' | 'WEB_SECRET_REF', reference: string, message: string);
3788
3832
  }
3833
+ /**
3834
+ * A reference cycle the resolver cannot break. Carries a code and the chain
3835
+ * of names, so tooling can report it structurally instead of matching text.
3836
+ * - `FLOW_CYCLE`: `$flow` references that reach a flow already being
3837
+ * resolved (the entry flow included, so a flow reading itself cycles).
3838
+ * - `VAR_CYCLE`: `$var` values that reference each other.
3839
+ */
3840
+ declare class FlowCycleError extends Error {
3841
+ readonly code: 'FLOW_CYCLE' | 'VAR_CYCLE';
3842
+ readonly chain: string[];
3843
+ constructor(code: 'FLOW_CYCLE' | 'VAR_CYCLE', chain: string[]);
3844
+ }
3789
3845
  /** Sentinel prefix for deferred $env resolution. Shared with CLI bundler. */
3790
3846
  declare const ENV_MARKER_PREFIX = "__WALKEROS_ENV:";
3791
3847
  /** Sentinel prefix for deferred $secret resolution. Shared with CLI bundler. */
@@ -5060,6 +5116,25 @@ declare function getOSVersion(userAgent: string): string | undefined;
5060
5116
  */
5061
5117
  declare function getDeviceType(userAgent: string): string | undefined;
5062
5118
 
5119
+ /**
5120
+ * Globals the collector must never replace: the page's own and walkerOS's.
5121
+ */
5122
+ declare const RESERVED_WINDOW_GLOBALS: readonly string[];
5123
+ type WindowCollectorCheck = {
5124
+ ok: true;
5125
+ name: string;
5126
+ } | {
5127
+ ok: false;
5128
+ reason: string;
5129
+ };
5130
+ /**
5131
+ * Check a resolved `config.settings.windowCollector` value: the global a web
5132
+ * bundle assigns the collector to. It must be a JavaScript identifier (it is
5133
+ * interpolated into generated code) and must not replace a reserved global.
5134
+ * The `reason` completes a sentence about the value ("is not ...").
5135
+ */
5136
+ declare function checkWindowCollector(value: unknown): WindowCollectorCheck;
5137
+
5063
5138
  /**
5064
5139
  * Inline Code Wrapping Utilities
5065
5140
  *
@@ -5160,6 +5235,19 @@ interface WalkerOSPackage extends WalkerOSPackageInfo {
5160
5235
  source?: string;
5161
5236
  hintKeys: string[];
5162
5237
  exampleSummaries: ExampleSummary[];
5238
+ /**
5239
+ * Examples per export, keyed by export name. Present only for packages
5240
+ * that ship several exports; `examples` then holds the default export's.
5241
+ */
5242
+ exportExamples?: Record<string, unknown>;
5243
+ /**
5244
+ * Schemas per export, keyed by export name, each entry shaped like
5245
+ * `schemas` of a single-export package (`settings`, `mapping`, `setup`).
5246
+ * Present only for packages that ship several exports.
5247
+ */
5248
+ exportSchemas?: Record<string, Record<string, unknown>>;
5249
+ /** Declared exports (name to description) from `$meta.exports`. */
5250
+ exports?: Record<string, string>;
5163
5251
  }
5164
5252
  declare function fetchPackage(packageName: string, options?: {
5165
5253
  version?: string;
@@ -5228,6 +5316,39 @@ declare function isEnvObserve(value: unknown): value is EnvObserve;
5228
5316
  * consecutive dots) is unresolvable and yields `[]`.
5229
5317
  */
5230
5318
  declare function parseCallPath(raw: string): string[];
5319
+ interface ObservedEnv<T extends object = Record<string, unknown>> {
5320
+ /** Proxy view of the env; declared paths record, everything else passes through. */
5321
+ env: T;
5322
+ /**
5323
+ * Mutable array: each call on a declared path is pushed here once. Stays
5324
+ * empty when a `record` callback is given, which then receives every call.
5325
+ */
5326
+ calls: Call[];
5327
+ /**
5328
+ * Declared paths whose object intermediates or leaf are absent at wrap time,
5329
+ * as the post-`call:` dot-path. A path that continues through a function
5330
+ * (constructor, factory, method result) resolves lazily and is not listed.
5331
+ */
5332
+ unresolved: string[];
5333
+ }
5334
+ /**
5335
+ * Observe calls on declared dot-paths of an env without touching it.
5336
+ *
5337
+ * Returns a Proxy view of `env`. Declared paths use the `parseCallPath`
5338
+ * grammar; the recorded `fn` is the full path without `call:` and `args` are
5339
+ * the leaf call's arguments. After an object, a segment is a property of it.
5340
+ * After a function, a segment is a static (see `hasStatic`) or else continues
5341
+ * on the call result (or constructed instance); a Promise result is followed
5342
+ * with `.then`. An object whose tracked properties a Proxy may not substitute
5343
+ * (frozen, or non-writable and non-configurable) is viewed through a shadow
5344
+ * target, so its calls still record and the object itself is never changed. Apply and construct traps call the originals through
5345
+ * `Reflect`, with `this` bound to the real target, so `instanceof`, statics and
5346
+ * `#private` fields keep working and a chain that returns `this` records once.
5347
+ * Nothing on the caller's objects or prototypes is replaced. `record`, when
5348
+ * given, receives every call instead of `calls` (a long-lived view must not
5349
+ * grow an array); a throw there never stops the real call.
5350
+ */
5351
+ declare function observeEnv<T extends object = Record<string, unknown>>(env: T, paths: string[], record?: EnvObserve['record']): ObservedEnv<T>;
5231
5352
 
5232
5353
  declare function mcpResult(result: unknown, hints?: {
5233
5354
  next?: string[];
@@ -5776,9 +5897,19 @@ declare function compileState(state: State | State[]): State[];
5776
5897
  * by every event in the scope, so at a fan-out it loses per-event
5777
5898
  * attribution. `set` writes the resolved value to the store.
5778
5899
  *
5900
+ * `mapping` shapes the value read (get) or the payload (set) with paths
5901
+ * relative to that value. It runs on a miss too, so declared fallbacks apply;
5902
+ * an empty result writes nothing. An object result merges into an object
5903
+ * target (get: the `value` path, set: the stored entry), anything else
5904
+ * replaces it. The set merge reads then writes, it is not atomic. Consent
5905
+ * gates on the event's consent, not on a stored `consent` key. Exception:
5906
+ * a `loop` item is mapped like any loop item, so a `consent` key on the item
5907
+ * itself gates that item's mapping.
5908
+ *
5779
5909
  * Each entry is fail-open: a store or resolution error is logged and the
5780
- * event is left unmutated, the chain continues. A key that does not resolve
5781
- * warns; a store miss is silent. Only `FatalError` rethrows (via
5910
+ * event is left unmutated, the chain continues. An unknown store logs an
5911
+ * error and a `file: true` store is skipped with a warning. A key that does
5912
+ * not resolve warns; a store miss is silent. Only `FatalError` rethrows (via
5782
5913
  * `getMappingValue`).
5783
5914
  */
5784
5915
  declare function applyState<E extends DeepPartialEvent>(states: State[], getStore: GetStore, event: E, collector: Instance$6, ingest: Record<string, unknown> | undefined): Promise<E>;
@@ -5910,4 +6041,4 @@ declare const REF_CODE_PREFIX = "$code:";
5910
6041
  */
5911
6042
  declare function scanFlowRefs(value: unknown, into?: Set<string>): Set<string>;
5912
6043
 
5913
- export { type ActivationGrant, type AssembleJourneysOptions, type BatchResponse, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ChainContinuation, type ChainFrame, type ChainStep, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type EventOutcome, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, FlowReferenceError, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestEnvelope, type IngestMeta, InvalidEventError, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JourneyUnattributed, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, type NextSteps, type NodeLikeRequest, OBSERVE_ENV_KEY, OBSERVE_STORAGE_KEY, type Observe, type ObserveCredential, type ObserveServer, type ObserveWeb, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, type RouteContinuation, type RouteDecision, type RouteGraphNode, type RouteLabel, SECRET_MARKER_PREFIX, SESSION_STORAGE_KEY, STEP_FIELD_ROLES, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepField, type StepFieldRole, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, type Timer, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, advanceChain, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, batchResponse, branch, browserSwapActivator, buildScopeFromNodeRequest, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMappingRoot, createMockContext, createMockLogger, createRespond, createTelemetryObserver, createTimer, debounce, deepMerge, defaultClickIds, deleteByPath, deriveSpanId, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getErrorMessage, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getRouteGraph, getSpanId, getStepFieldRole, getStepRuntimeProps, getTraceId, getTraceUntil, isArguments, isArray, isBatchBody, isBoolean, isChainContinuation, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isRouteContinuation, isSameType, isSampled, isScope, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, normalizeBody, normalizeHeaders, normalizeQuery, observeFromEnv, packageNameToVariable, parseCallPath, parseGrant, parseObserveCredential, parseTraceparent, parseUserAgent, processEventMapping, pushResultToOutcome, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, startChain, stepId, storeCache, throttle, throwError, toEventList, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
6044
+ export { type ActivationGrant, type AssembleJourneysOptions, type BatchResponse, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ChainContinuation, type ChainFrame, type ChainStep, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type EventOutcome, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, FlowCycleError, FlowReferenceError, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestEnvelope, type IngestMeta, InvalidEventError, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JourneyUnattributed, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, type NextSteps, type NodeLikeRequest, OBSERVE_ENV_KEY, OBSERVE_STORAGE_KEY, type Observe, type ObserveCredential, type ObserveServer, type ObserveWeb, type ObservedEnv, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, RESERVED_WINDOW_GLOBALS, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, type RouteContinuation, type RouteDecision, type RouteGraphNode, type RouteLabel, SECRET_MARKER_PREFIX, SESSION_STORAGE_KEY, STEP_FIELD_ROLES, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepField, type StepFieldRole, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, type Timer, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, type WindowCollectorCheck, advanceChain, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, batchResponse, branch, browserSwapActivator, buildScopeFromNodeRequest, castToProperty, castValue, checkCache, checkWindowCollector, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMappingRoot, createMockContext, createMockLogger, createRespond, createTelemetryObserver, createTimer, debounce, deepMerge, defaultClickIds, deleteByPath, deriveSpanId, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getErrorMessage, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getRouteGraph, getSpanId, getStepFieldRole, getStepRuntimeProps, getTraceId, getTraceUntil, isArguments, isArray, isBatchBody, isBoolean, isChainContinuation, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isRouteContinuation, isSameType, isSampled, isScope, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, normalizeBody, normalizeHeaders, normalizeQuery, observeEnv, observeFromEnv, packageNameToVariable, parseCallPath, parseGrant, parseObserveCredential, parseTraceparent, parseUserAgent, processEventMapping, pushResultToOutcome, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, startChain, stepId, storeCache, throttle, throwError, toEventList, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
package/dist/index.d.ts CHANGED
@@ -892,6 +892,13 @@ interface State {
892
892
  * validation requires it for get/set.
893
893
  */
894
894
  value?: Value;
895
+ /**
896
+ * Shapes the value read (get) or the resolved payload (set) with a full
897
+ * mapping value. Paths are relative to that value, not to { event, ingest }.
898
+ * The result merges into the target: get into the `value` path, set into
899
+ * the stored entry. Runs on a miss too, so declared fallbacks apply.
900
+ */
901
+ mapping?: Value;
895
902
  }
896
903
 
897
904
  /**
@@ -1078,6 +1085,9 @@ interface Config$5<T extends TypesGeneric$3 = Types$4> {
1078
1085
  /**
1079
1086
  * Per-destination delivery timeout in ms (default 10000); a delivery that
1080
1087
  * does not settle within this window is routed to the DLQ like a thrown push.
1088
+ * Also bounds an `on()` handler: a state handler that does not settle within
1089
+ * the window is logged, and the destination is held (its events stay queued)
1090
+ * until a later state delivery to it settles.
1081
1091
  */
1082
1092
  timeout?: number;
1083
1093
  /** Return this value instead of calling push(). Uses !== undefined check to support falsy values. */
@@ -1887,7 +1897,8 @@ declare namespace Flow {
1887
1897
  /**
1888
1898
  * Arbitrary key-value settings consumed by the platform runtime.
1889
1899
  *
1890
- * For web: typical keys include `windowCollector`.
1900
+ * For web: `windowCollector` names the global the collector instance is
1901
+ * assigned to (default `walkerOS`); it must be a JavaScript identifier.
1891
1902
  * For server: reserved for future server-specific options.
1892
1903
  *
1893
1904
  * The `windowElb` key is deprecated: the browser source is the single writer
@@ -2643,6 +2654,9 @@ interface OnConfig {
2643
2654
  /**
2644
2655
  * Destination `on` handler: receives the action type and a destination context.
2645
2656
  * Already context-style; kept for compatibility with the destination interface.
2657
+ * The collector awaits the returned promise and bounds the wait by
2658
+ * `Destination.Config.timeout`; the handler's effects therefore land before
2659
+ * the destination's next push.
2646
2660
  */
2647
2661
  type OnFn<T extends TypesGeneric$3 = Types$4> = (type: Types$2, context: Context$5<T>) => PromiseOrValue<void>;
2648
2662
  type OnFnRuntime = (type: Types$2, context: Context$5) => PromiseOrValue<void>;
@@ -3376,7 +3390,8 @@ declare namespace walkeros {
3376
3390
 
3377
3391
  /**
3378
3392
  * A recorded function call made during simulation.
3379
- * Captures what a destination called on its env (e.g., window.gtag).
3393
+ * Captures what a destination called on its env (e.g., window.gtag), or a
3394
+ * walker command a source issued (`fn: 'elb'`, first argument verbatim).
3380
3395
  */
3381
3396
  interface Call {
3382
3397
  /** Dot-path of the function called: "window.gtag", "dataLayer.push" */
@@ -3386,6 +3401,22 @@ interface Call {
3386
3401
  /** Unix timestamp in ms */
3387
3402
  ts: number;
3388
3403
  }
3404
+ /**
3405
+ * Why a simulated destination sent nothing, read from the collector's own
3406
+ * records:
3407
+ * - `consent`: the event was skipped at the consent gate (or queued, with
3408
+ * `queue: true`). `required` is the destination's `config.consent`,
3409
+ * `granted` the collector consent plus the event's own consent.
3410
+ * - `pending`: the destination is still waiting for its `require` entries
3411
+ * (listed in `require`), so it never started.
3412
+ */
3413
+ interface Skipped {
3414
+ reason: 'consent' | 'pending';
3415
+ required?: Consent;
3416
+ granted?: Consent;
3417
+ /** `pending` only: the `require` entries still unmet. */
3418
+ require?: string[];
3419
+ }
3389
3420
  /**
3390
3421
  * Result of simulating a single step.
3391
3422
  * Same shape for source, transformer, collector, and destination.
@@ -3403,7 +3434,14 @@ interface Result {
3403
3434
  * - destination: [] (destinations don't produce events)
3404
3435
  */
3405
3436
  events: DeepPartialEvent[];
3406
- /** Intercepted env calls. Populated for destinations, empty [] for others. */
3437
+ /**
3438
+ * Recorded calls, in time order:
3439
+ * - source: its own walker commands (`fn: 'elb'`, e.g. a CMP's
3440
+ * `['walker consent', {...}]` or the session's `['user', {...}]`) and
3441
+ * its mock-env calls
3442
+ * - destination: its intercepted env calls
3443
+ * - transformer, collector: []
3444
+ */
3407
3445
  calls: Call[];
3408
3446
  /** Execution time in ms */
3409
3447
  duration: number;
@@ -3416,14 +3454,20 @@ interface Result {
3416
3454
  * available.
3417
3455
  */
3418
3456
  mappingKey?: string;
3457
+ /**
3458
+ * Destination simulations only: why nothing was sent, when the collector
3459
+ * recorded a consent skip or the destination is still pending.
3460
+ */
3461
+ skipped?: Skipped;
3419
3462
  /** Error if the step threw */
3420
3463
  error?: Error;
3421
3464
  }
3422
3465
 
3423
3466
  type simulation_Call = Call;
3424
3467
  type simulation_Result = Result;
3468
+ type simulation_Skipped = Skipped;
3425
3469
  declare namespace simulation {
3426
- export type { simulation_Call as Call, simulation_Result as Result };
3470
+ export type { simulation_Call as Call, simulation_Result as Result, simulation_Skipped as Skipped };
3427
3471
  }
3428
3472
 
3429
3473
  interface Code {
@@ -3786,6 +3830,18 @@ declare class FlowReferenceError extends Error {
3786
3830
  readonly reference: string;
3787
3831
  constructor(code: 'MISSING_ENV' | 'WEB_SECRET_REF', reference: string, message: string);
3788
3832
  }
3833
+ /**
3834
+ * A reference cycle the resolver cannot break. Carries a code and the chain
3835
+ * of names, so tooling can report it structurally instead of matching text.
3836
+ * - `FLOW_CYCLE`: `$flow` references that reach a flow already being
3837
+ * resolved (the entry flow included, so a flow reading itself cycles).
3838
+ * - `VAR_CYCLE`: `$var` values that reference each other.
3839
+ */
3840
+ declare class FlowCycleError extends Error {
3841
+ readonly code: 'FLOW_CYCLE' | 'VAR_CYCLE';
3842
+ readonly chain: string[];
3843
+ constructor(code: 'FLOW_CYCLE' | 'VAR_CYCLE', chain: string[]);
3844
+ }
3789
3845
  /** Sentinel prefix for deferred $env resolution. Shared with CLI bundler. */
3790
3846
  declare const ENV_MARKER_PREFIX = "__WALKEROS_ENV:";
3791
3847
  /** Sentinel prefix for deferred $secret resolution. Shared with CLI bundler. */
@@ -5060,6 +5116,25 @@ declare function getOSVersion(userAgent: string): string | undefined;
5060
5116
  */
5061
5117
  declare function getDeviceType(userAgent: string): string | undefined;
5062
5118
 
5119
+ /**
5120
+ * Globals the collector must never replace: the page's own and walkerOS's.
5121
+ */
5122
+ declare const RESERVED_WINDOW_GLOBALS: readonly string[];
5123
+ type WindowCollectorCheck = {
5124
+ ok: true;
5125
+ name: string;
5126
+ } | {
5127
+ ok: false;
5128
+ reason: string;
5129
+ };
5130
+ /**
5131
+ * Check a resolved `config.settings.windowCollector` value: the global a web
5132
+ * bundle assigns the collector to. It must be a JavaScript identifier (it is
5133
+ * interpolated into generated code) and must not replace a reserved global.
5134
+ * The `reason` completes a sentence about the value ("is not ...").
5135
+ */
5136
+ declare function checkWindowCollector(value: unknown): WindowCollectorCheck;
5137
+
5063
5138
  /**
5064
5139
  * Inline Code Wrapping Utilities
5065
5140
  *
@@ -5160,6 +5235,19 @@ interface WalkerOSPackage extends WalkerOSPackageInfo {
5160
5235
  source?: string;
5161
5236
  hintKeys: string[];
5162
5237
  exampleSummaries: ExampleSummary[];
5238
+ /**
5239
+ * Examples per export, keyed by export name. Present only for packages
5240
+ * that ship several exports; `examples` then holds the default export's.
5241
+ */
5242
+ exportExamples?: Record<string, unknown>;
5243
+ /**
5244
+ * Schemas per export, keyed by export name, each entry shaped like
5245
+ * `schemas` of a single-export package (`settings`, `mapping`, `setup`).
5246
+ * Present only for packages that ship several exports.
5247
+ */
5248
+ exportSchemas?: Record<string, Record<string, unknown>>;
5249
+ /** Declared exports (name to description) from `$meta.exports`. */
5250
+ exports?: Record<string, string>;
5163
5251
  }
5164
5252
  declare function fetchPackage(packageName: string, options?: {
5165
5253
  version?: string;
@@ -5228,6 +5316,39 @@ declare function isEnvObserve(value: unknown): value is EnvObserve;
5228
5316
  * consecutive dots) is unresolvable and yields `[]`.
5229
5317
  */
5230
5318
  declare function parseCallPath(raw: string): string[];
5319
+ interface ObservedEnv<T extends object = Record<string, unknown>> {
5320
+ /** Proxy view of the env; declared paths record, everything else passes through. */
5321
+ env: T;
5322
+ /**
5323
+ * Mutable array: each call on a declared path is pushed here once. Stays
5324
+ * empty when a `record` callback is given, which then receives every call.
5325
+ */
5326
+ calls: Call[];
5327
+ /**
5328
+ * Declared paths whose object intermediates or leaf are absent at wrap time,
5329
+ * as the post-`call:` dot-path. A path that continues through a function
5330
+ * (constructor, factory, method result) resolves lazily and is not listed.
5331
+ */
5332
+ unresolved: string[];
5333
+ }
5334
+ /**
5335
+ * Observe calls on declared dot-paths of an env without touching it.
5336
+ *
5337
+ * Returns a Proxy view of `env`. Declared paths use the `parseCallPath`
5338
+ * grammar; the recorded `fn` is the full path without `call:` and `args` are
5339
+ * the leaf call's arguments. After an object, a segment is a property of it.
5340
+ * After a function, a segment is a static (see `hasStatic`) or else continues
5341
+ * on the call result (or constructed instance); a Promise result is followed
5342
+ * with `.then`. An object whose tracked properties a Proxy may not substitute
5343
+ * (frozen, or non-writable and non-configurable) is viewed through a shadow
5344
+ * target, so its calls still record and the object itself is never changed. Apply and construct traps call the originals through
5345
+ * `Reflect`, with `this` bound to the real target, so `instanceof`, statics and
5346
+ * `#private` fields keep working and a chain that returns `this` records once.
5347
+ * Nothing on the caller's objects or prototypes is replaced. `record`, when
5348
+ * given, receives every call instead of `calls` (a long-lived view must not
5349
+ * grow an array); a throw there never stops the real call.
5350
+ */
5351
+ declare function observeEnv<T extends object = Record<string, unknown>>(env: T, paths: string[], record?: EnvObserve['record']): ObservedEnv<T>;
5231
5352
 
5232
5353
  declare function mcpResult(result: unknown, hints?: {
5233
5354
  next?: string[];
@@ -5776,9 +5897,19 @@ declare function compileState(state: State | State[]): State[];
5776
5897
  * by every event in the scope, so at a fan-out it loses per-event
5777
5898
  * attribution. `set` writes the resolved value to the store.
5778
5899
  *
5900
+ * `mapping` shapes the value read (get) or the payload (set) with paths
5901
+ * relative to that value. It runs on a miss too, so declared fallbacks apply;
5902
+ * an empty result writes nothing. An object result merges into an object
5903
+ * target (get: the `value` path, set: the stored entry), anything else
5904
+ * replaces it. The set merge reads then writes, it is not atomic. Consent
5905
+ * gates on the event's consent, not on a stored `consent` key. Exception:
5906
+ * a `loop` item is mapped like any loop item, so a `consent` key on the item
5907
+ * itself gates that item's mapping.
5908
+ *
5779
5909
  * Each entry is fail-open: a store or resolution error is logged and the
5780
- * event is left unmutated, the chain continues. A key that does not resolve
5781
- * warns; a store miss is silent. Only `FatalError` rethrows (via
5910
+ * event is left unmutated, the chain continues. An unknown store logs an
5911
+ * error and a `file: true` store is skipped with a warning. A key that does
5912
+ * not resolve warns; a store miss is silent. Only `FatalError` rethrows (via
5782
5913
  * `getMappingValue`).
5783
5914
  */
5784
5915
  declare function applyState<E extends DeepPartialEvent>(states: State[], getStore: GetStore, event: E, collector: Instance$6, ingest: Record<string, unknown> | undefined): Promise<E>;
@@ -5910,4 +6041,4 @@ declare const REF_CODE_PREFIX = "$code:";
5910
6041
  */
5911
6042
  declare function scanFlowRefs(value: unknown, into?: Set<string>): Set<string>;
5912
6043
 
5913
- export { type ActivationGrant, type AssembleJourneysOptions, type BatchResponse, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ChainContinuation, type ChainFrame, type ChainStep, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type EventOutcome, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, FlowReferenceError, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestEnvelope, type IngestMeta, InvalidEventError, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JourneyUnattributed, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, type NextSteps, type NodeLikeRequest, OBSERVE_ENV_KEY, OBSERVE_STORAGE_KEY, type Observe, type ObserveCredential, type ObserveServer, type ObserveWeb, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, type RouteContinuation, type RouteDecision, type RouteGraphNode, type RouteLabel, SECRET_MARKER_PREFIX, SESSION_STORAGE_KEY, STEP_FIELD_ROLES, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepField, type StepFieldRole, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, type Timer, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, advanceChain, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, batchResponse, branch, browserSwapActivator, buildScopeFromNodeRequest, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMappingRoot, createMockContext, createMockLogger, createRespond, createTelemetryObserver, createTimer, debounce, deepMerge, defaultClickIds, deleteByPath, deriveSpanId, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getErrorMessage, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getRouteGraph, getSpanId, getStepFieldRole, getStepRuntimeProps, getTraceId, getTraceUntil, isArguments, isArray, isBatchBody, isBoolean, isChainContinuation, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isRouteContinuation, isSameType, isSampled, isScope, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, normalizeBody, normalizeHeaders, normalizeQuery, observeFromEnv, packageNameToVariable, parseCallPath, parseGrant, parseObserveCredential, parseTraceparent, parseUserAgent, processEventMapping, pushResultToOutcome, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, startChain, stepId, storeCache, throttle, throwError, toEventList, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
6044
+ export { type ActivationGrant, type AssembleJourneysOptions, type BatchResponse, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ChainContinuation, type ChainFrame, type ChainStep, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type EventOutcome, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, FlowCycleError, FlowReferenceError, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestEnvelope, type IngestMeta, InvalidEventError, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JourneyUnattributed, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, type NextSteps, type NodeLikeRequest, OBSERVE_ENV_KEY, OBSERVE_STORAGE_KEY, type Observe, type ObserveCredential, type ObserveServer, type ObserveWeb, type ObservedEnv, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, RESERVED_WINDOW_GLOBALS, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, type RouteContinuation, type RouteDecision, type RouteGraphNode, type RouteLabel, SECRET_MARKER_PREFIX, SESSION_STORAGE_KEY, STEP_FIELD_ROLES, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepField, type StepFieldRole, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, type Timer, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, type WindowCollectorCheck, advanceChain, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, batchResponse, branch, browserSwapActivator, buildScopeFromNodeRequest, castToProperty, castValue, checkCache, checkWindowCollector, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMappingRoot, createMockContext, createMockLogger, createRespond, createTelemetryObserver, createTimer, debounce, deepMerge, defaultClickIds, deleteByPath, deriveSpanId, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getErrorMessage, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getRouteGraph, getSpanId, getStepFieldRole, getStepRuntimeProps, getTraceId, getTraceUntil, isArguments, isArray, isBatchBody, isBoolean, isChainContinuation, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isRouteContinuation, isSameType, isSampled, isScope, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, normalizeBody, normalizeHeaders, normalizeQuery, observeEnv, observeFromEnv, packageNameToVariable, parseCallPath, parseGrant, parseObserveCredential, parseTraceparent, parseUserAgent, processEventMapping, pushResultToOutcome, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, startChain, stepId, storeCache, throttle, throwError, toEventList, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };