@walkeros/core 0.3.0 → 0.3.1
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 +1751 -13954
- package/dist/index.d.ts +1751 -13954
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/collector.ts","../src/types/data.ts","../src/types/destination.ts","../src/types/elb.ts","../src/types/flow.ts","../src/types/handler.ts","../src/types/hooks.ts","../src/types/mapping.ts","../src/types/on.ts","../src/types/request.ts","../src/types/schema.ts","../src/types/source.ts","../src/types/walkeros.ts","../src/types/storage.ts","../src/schemas/primitives.ts","../src/schemas/patterns.ts","../src/schemas/utilities.ts","../src/schemas/walkeros.ts","../src/schemas/mapping.ts","../src/schemas/destination.ts","../src/schemas/collector.ts","../src/schemas/source.ts","../src/schemas/schema-builder.ts","../src/schemas/index.ts","../src/anonymizeIP.ts","../src/assign.ts","../src/is.ts","../src/clone.ts","../src/byPath.ts","../src/castValue.ts","../src/consent.ts","../src/createDestination.ts","../src/eventGenerator.ts","../src/getId.ts","../src/getMarketingParameters.ts","../src/invocations.ts","../src/property.ts","../src/tryCatch.ts","../src/mapping.ts","../src/mockEnv.ts","../src/onLog.ts","../src/request.ts","../src/send.ts","../src/throwError.ts","../src/trim.ts","../src/useHooks.ts","../src/userAgent.ts","../src/validate.ts"],"sourcesContent":["import type {\n Source,\n Destination,\n Elb as ElbTypes,\n Handler,\n Hooks,\n On,\n WalkerOS,\n Mapping,\n} from '.';\n\n/**\n * Core collector configuration interface\n */\nexport interface Config {\n /** Whether to run collector automatically */\n run?: boolean;\n /** Version for event tagging */\n tagging: number;\n /** Static global properties even on a new run */\n globalsStatic: WalkerOS.Properties;\n /** Static session data even on a new run */\n sessionStatic: Partial<SessionData>;\n /** Enable verbose logging */\n verbose: boolean;\n /** Error handler */\n onError?: Handler.Error;\n /** Log handler */\n onLog?: Handler.Log;\n}\n\n/**\n * Initialization configuration that extends Config with initial state\n */\nexport interface InitConfig extends Partial<Config> {\n /** Initial consent state */\n consent?: WalkerOS.Consent;\n /** Initial user data */\n user?: WalkerOS.User;\n /** Initial global properties */\n globals?: WalkerOS.Properties;\n /** Source configurations */\n sources?: Source.InitSources;\n /** Destination configurations */\n destinations?: Destination.InitDestinations;\n /** Initial custom properties */\n custom?: WalkerOS.Properties;\n}\n\nexport interface SessionData extends WalkerOS.Properties {\n isStart: boolean;\n storage: boolean;\n id?: string;\n start?: number;\n marketing?: true;\n updated?: number;\n isNew?: boolean;\n device?: string;\n count?: number;\n runs?: number;\n}\n\nexport interface Sources {\n [id: string]: Source.Instance;\n}\n\nexport interface Destinations {\n [id: string]: Destination.Instance;\n}\n\nexport type CommandType =\n | 'action'\n | 'config'\n | 'consent'\n | 'context'\n | 'destination'\n | 'elb'\n | 'globals'\n | 'hook'\n | 'init'\n | 'link'\n | 'run'\n | 'user'\n | 'walker'\n | string;\n\n/**\n * Context passed to collector.push for source mapping\n */\nexport interface PushContext {\n mapping?: Mapping.Config;\n}\n\n/**\n * Push function signature - handles events only\n */\nexport interface PushFn {\n (\n event: WalkerOS.DeepPartialEvent,\n context?: PushContext,\n ): Promise<ElbTypes.PushResult>;\n}\n\n/**\n * Command function signature - handles walker commands only\n */\nexport interface CommandFn {\n (command: 'config', config: Partial<Config>): Promise<ElbTypes.PushResult>;\n (command: 'consent', consent: WalkerOS.Consent): Promise<ElbTypes.PushResult>;\n <T extends Destination.Types>(\n command: 'destination',\n destination: Destination.Init<T> | Destination.Instance<T>,\n config?: Destination.Config<T>,\n ): Promise<ElbTypes.PushResult>;\n <K extends keyof Hooks.Functions>(\n command: 'hook',\n name: K,\n hookFn: Hooks.Functions[K],\n ): Promise<ElbTypes.PushResult>;\n (\n command: 'on',\n type: On.Types,\n rules: WalkerOS.SingleOrArray<On.Options>,\n ): Promise<ElbTypes.PushResult>;\n (command: 'user', user: WalkerOS.User): Promise<ElbTypes.PushResult>;\n (\n command: 'run',\n runState?: {\n consent?: WalkerOS.Consent;\n user?: WalkerOS.User;\n globals?: WalkerOS.Properties;\n custom?: WalkerOS.Properties;\n },\n ): Promise<ElbTypes.PushResult>;\n (\n command: string,\n data?: unknown,\n options?: unknown,\n ): Promise<ElbTypes.PushResult>;\n}\n\n// Main Collector interface\nexport interface Instance {\n push: PushFn;\n command: CommandFn;\n allowed: boolean;\n config: Config;\n consent: WalkerOS.Consent;\n count: number;\n custom: WalkerOS.Properties;\n sources: Sources;\n destinations: Destinations;\n globals: WalkerOS.Properties;\n group: string;\n hooks: Hooks.Functions;\n on: On.OnConfig;\n queue: WalkerOS.Events;\n round: number;\n session: undefined | SessionData;\n timing: number;\n user: WalkerOS.User;\n version: string;\n}\n","import type { WalkerOS } from '.';\n\nexport interface Contract {\n version: string;\n globals: Globals;\n context: Contexts;\n entities: Entities;\n // @TODO data as ref\n}\n\nexport interface Globals {\n [name: string]: Global;\n}\n\nexport interface Contexts {\n [name: string]: Context;\n}\n\nexport interface Entities {\n [name: string]: Entity;\n}\n\nexport interface Properties {\n [name: string]: Property;\n}\n\nexport interface Global extends Property {}\n\nexport interface Context extends Property {}\n\nexport interface Entity {\n data: Properties;\n actions: Actions;\n}\n\nexport interface Actions {\n [name: string]: Action;\n}\n\nexport interface Action {\n trigger?: Trigger;\n}\n\nexport type Trigger = string; // @TODO Move to web data contract\n\nexport interface Property {\n type?: PropertyType; // @TODO support multiple\n required?: boolean;\n values?: PropertyValues;\n}\n\nexport type PropertyType = 'boolean' | 'string' | 'number';\n\nexport type PropertyValues = Array<WalkerOS.Property>;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n Collector,\n Handler,\n Mapping as WalkerOSMapping,\n On,\n WalkerOS,\n} from '.';\n\n/**\n * Base environment requirements interface for walkerOS destinations\n *\n * This defines the core interface that destinations can use to declare\n * their runtime environment requirements. Platform-specific extensions\n * should extend this interface.\n */\nexport interface BaseEnv {\n /**\n * Generic global properties that destinations may require\n * Platform-specific implementations can extend this interface\n */\n [key: string]: unknown;\n}\n\n/**\n * Type bundle for destination generics.\n * Groups Settings, Mapping, and Env into a single type parameter.\n */\nexport interface Types<S = unknown, M = unknown, E = BaseEnv> {\n settings: S;\n mapping: M;\n env: E;\n}\n\n/**\n * Generic constraint for Types - ensures T has required properties for indexed access\n */\nexport type TypesGeneric = { settings: any; mapping: any; env: any };\n\n/**\n * Type extractors for consistent usage with Types bundle\n */\nexport type Settings<T extends TypesGeneric = Types> = T['settings'];\nexport type Mapping<T extends TypesGeneric = Types> = T['mapping'];\nexport type Env<T extends TypesGeneric = Types> = T['env'];\n\n/**\n * Inference helper: Extract Types from Instance\n */\nexport type TypesOf<I> = I extends Instance<infer T> ? T : never;\n\nexport interface Instance<T extends TypesGeneric = Types> {\n config: Config<T>;\n queue?: WalkerOS.Events;\n dlq?: DLQ;\n type?: string;\n env?: Env<T>;\n init?: InitFn<T>;\n push: PushFn<T>;\n pushBatch?: PushBatchFn<T>;\n on?: On.OnFn;\n}\n\nexport interface Config<T extends TypesGeneric = Types> {\n consent?: WalkerOS.Consent;\n settings?: Settings<T>;\n data?: WalkerOSMapping.Value | WalkerOSMapping.Values;\n env?: Env<T>;\n id?: string;\n init?: boolean;\n loadScript?: boolean;\n mapping?: WalkerOSMapping.Rules<WalkerOSMapping.Rule<Mapping<T>>>;\n policy?: Policy;\n queue?: boolean;\n verbose?: boolean;\n onError?: Handler.Error;\n onLog?: Handler.Log;\n}\n\nexport type PartialConfig<T extends TypesGeneric = Types> = Config<\n Types<\n Partial<Settings<T>> | Settings<T>,\n Partial<Mapping<T>> | Mapping<T>,\n Env<T>\n >\n>;\n\nexport interface Policy {\n [key: string]: WalkerOSMapping.Value;\n}\n\nexport type Init<T extends TypesGeneric = Types> = {\n code: Instance<T>;\n config?: Partial<Config<T>>;\n env?: Partial<Env<T>>;\n};\n\nexport interface InitDestinations {\n [key: string]: Init<any>;\n}\n\nexport interface Destinations {\n [key: string]: Instance;\n}\n\nexport interface Context<T extends TypesGeneric = Types> {\n collector: Collector.Instance;\n config: Config<T>;\n data?: Data;\n env: Env<T>;\n}\n\nexport interface InitContext<T extends TypesGeneric = Types> {\n collector: Collector.Instance;\n config: Config<Types<Partial<Settings<T>>, Mapping<T>, Env<T>>>;\n data?: Data;\n env: Env<T>;\n}\n\nexport interface PushContext<T extends TypesGeneric = Types>\n extends Context<T> {\n mapping?: WalkerOSMapping.Rule<Mapping<T>>;\n}\n\nexport interface PushBatchContext<T extends TypesGeneric = Types>\n extends Context<T> {\n mapping?: WalkerOSMapping.Rule<Mapping<T>>;\n}\n\nexport type InitFn<T extends TypesGeneric = Types> = (\n context: InitContext<T>,\n) => WalkerOS.PromiseOrValue<void | false | Config<T>>;\n\nexport type PushFn<T extends TypesGeneric = Types> = (\n event: WalkerOS.Event,\n context: PushContext<T>,\n) => WalkerOS.PromiseOrValue<void>;\n\nexport type PushBatchFn<T extends TypesGeneric = Types> = (\n batch: Batch<Mapping<T>>,\n context: PushBatchContext<T>,\n) => void;\n\nexport type PushEvent<Mapping = unknown> = {\n event: WalkerOS.Event;\n mapping?: WalkerOSMapping.Rule<Mapping>;\n};\nexport type PushEvents<Mapping = unknown> = Array<PushEvent<Mapping>>;\n\nexport interface Batch<Mapping> {\n key: string;\n events: WalkerOS.Events;\n data: Array<Data>;\n mapping?: WalkerOSMapping.Rule<Mapping>;\n}\n\nexport type Data =\n | WalkerOS.Property\n | undefined\n | Array<WalkerOS.Property | undefined>;\n\nexport type Ref = {\n id: string;\n destination: Instance;\n};\n\nexport type Push = {\n queue?: WalkerOS.Events;\n error?: unknown;\n};\n\nexport type DLQ = Array<[WalkerOS.Event, unknown]>;\n\nexport type Result = {\n successful: Array<Ref>;\n queued: Array<Ref>;\n failed: Array<Ref>;\n};\n","import type { Destination, Hooks, On, WalkerOS } from '.';\n\n// Event signatures only\nexport interface EventFn<R = Promise<PushResult>> {\n (partialEvent: WalkerOS.DeepPartialEvent): R;\n (event: string): R;\n (event: string, data: WalkerOS.Properties): R;\n}\n\n// Complete function interface - can be extended by other interfaces\nexport interface Fn<R = Promise<PushResult>, Config = unknown>\n extends EventFn<R>,\n WalkerCommands<R, Config> {\n // Interface intentionally empty - combines EventFn and WalkerCommands\n}\n\n// Walker commands (clear, predefined list)\nexport interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {\n (event: 'walker config', config: Partial<Config>): R;\n (event: 'walker consent', consent: WalkerOS.Consent): R;\n <T extends Destination.Types>(\n event: 'walker destination',\n destination: Destination.Init<T> | Destination.Instance<T>,\n config?: Destination.Config<T>,\n ): R;\n <K extends keyof Hooks.Functions>(\n event: 'walker hook',\n name: K,\n hookFn: Hooks.Functions[K],\n ): R;\n (\n event: 'walker on',\n type: On.Types,\n rules: WalkerOS.SingleOrArray<On.Options>,\n ): R;\n (event: 'walker user', user: WalkerOS.User): R;\n (\n event: 'walker run',\n runState: {\n consent?: WalkerOS.Consent;\n user?: WalkerOS.User;\n globals?: WalkerOS.Properties;\n custom?: WalkerOS.Properties;\n },\n ): R;\n}\n\nexport type Event<R = Promise<PushResult>> = (\n partialEvent: WalkerOS.DeepPartialEvent,\n) => R;\n\n// Simplified push data types for core collector\nexport type PushData<Config = unknown> =\n | WalkerOS.DeepPartial<Config>\n | WalkerOS.Consent\n | WalkerOS.User\n | WalkerOS.Properties;\n\nexport interface PushResult extends Destination.Result {\n event?: WalkerOS.Event;\n ok: boolean;\n}\n\n// Simplified Layer type for core collector\nexport type Layer = Array<IArguments | WalkerOS.DeepPartialEvent | unknown[]>;\n","import type { Collector } from '.';\n\n/**\n * Flow configuration interface for dynamic walkerOS setup\n * Used by bundlers and other tools to configure walkerOS dynamically\n */\nexport interface Config {\n /** Collector configuration - uses existing Collector.Config from core */\n collector: Collector.Config;\n\n /** NPM packages required for this configuration */\n packages: Record<string, string>;\n}\n","export type Error = (error: unknown, state?: unknown) => void;\n\nexport type Log = (message: string, verbose?: boolean) => void;\n","// Define a generic type for functions with specific parameters and return type\nexport type AnyFunction<P extends unknown[] = never[], R = unknown> = (\n ...args: P\n) => R;\n\n// Define a generic type for a dictionary of functions\nexport type Functions = {\n [key: string]: AnyFunction;\n};\n\n// Define a parameter interface to wrap the function and its result\ninterface Parameter<P extends unknown[], R> {\n fn: (...args: P) => R;\n result?: R;\n}\n\n// Define the HookFn type using generics for better type safety\nexport type HookFn<T extends AnyFunction> = (\n params: Parameter<Parameters<T>, ReturnType<T>>,\n ...args: Parameters<T>\n) => ReturnType<T>;\n","import type { Collector, Destination, WalkerOS } from '.';\n\n/**\n * Shared mapping configuration interface.\n * Used by both Source.Config and Destination.Config.\n */\nexport interface Config<T = unknown> {\n consent?: WalkerOS.Consent; // Required consent to process events\n data?: Value | Values; // Global data transformation\n mapping?: Rules<Rule<T>>; // Event-specific mapping rules\n policy?: Policy; // Pre-processing rules\n}\n\nexport interface Policy {\n [key: string]: Value;\n}\n\nexport interface Rules<T = Rule> {\n [entity: string]: Record<string, T | Array<T>> | undefined;\n}\n\nexport interface Rule<Settings = unknown> {\n batch?: number; // Bundle events for batch processing\n batchFn?: (\n destination: Destination.Instance,\n collector: Collector.Instance,\n ) => void;\n batched?: Destination.Batch<Settings>; // Batch of events to be processed\n condition?: Condition; // Added condition\n consent?: WalkerOS.Consent; // Required consent states process the event\n settings?: Settings; // Arbitrary but protected configurations for custom event config\n data?: Data; // Mapping of event data\n ignore?: boolean; // Choose to no process an event when set to true\n name?: string; // Use a custom event name\n policy?: Policy; // Event-level policy applied after config-level policy\n}\n\nexport interface Result {\n eventMapping?: Rule;\n mappingKey?: string;\n}\n\nexport type Data = Value | Values;\nexport type Value = ValueType | Array<ValueType>;\nexport type Values = Array<Value>;\nexport type ValueType = string | ValueConfig;\n\nexport interface ValueConfig {\n condition?: Condition;\n consent?: WalkerOS.Consent;\n fn?: Fn;\n key?: string;\n loop?: Loop;\n map?: Map;\n set?: Value[];\n validate?: Validate;\n value?: WalkerOS.PropertyType;\n}\n\nexport type Condition = (\n value: WalkerOS.DeepPartialEvent | unknown,\n mapping?: Value,\n collector?: Collector.Instance,\n) => WalkerOS.PromiseOrValue<boolean>;\n\nexport type Fn = (\n value: WalkerOS.DeepPartialEvent | unknown,\n mapping: Value,\n options: Options,\n) => WalkerOS.PromiseOrValue<WalkerOS.Property | unknown>;\n\nexport type Loop = [Value, Value];\n\nexport type Map = { [key: string]: Value };\n\nexport interface Options {\n consent?: WalkerOS.Consent;\n collector?: Collector.Instance;\n props?: unknown;\n}\n\nexport type Validate = (value?: unknown) => WalkerOS.PromiseOrValue<boolean>;\n","import type { Collector, WalkerOS } from './';\n\n// collector state for the on actions\nexport type Config = {\n consent?: Array<ConsentConfig>;\n ready?: Array<ReadyConfig>;\n run?: Array<RunConfig>;\n session?: Array<SessionConfig>;\n};\n\n// On types\nexport type Types = keyof Config;\n\n// Map each event type to its expected context type\nexport interface EventContextMap {\n consent: WalkerOS.Consent;\n session: Collector.SessionData;\n ready: undefined;\n run: undefined;\n}\n\n// Extract the context type for a specific event\nexport type EventContext<T extends Types> = EventContextMap[T];\n\n// Union of all possible context types\nexport type AnyEventContext = EventContextMap[keyof EventContextMap];\n\n// Legacy context interface (can be removed in future)\nexport interface Context {\n consent?: WalkerOS.Consent;\n session?: unknown;\n}\n\n// Parameters for the onAction function calls\nexport type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;\n\n// Consent\nexport interface ConsentConfig {\n [key: string]: ConsentFn;\n}\nexport type ConsentFn = (\n collector: Collector.Instance,\n consent: WalkerOS.Consent,\n) => void;\n\n// Ready\nexport type ReadyConfig = ReadyFn;\nexport type ReadyFn = (collector: Collector.Instance) => void;\n\n// Run\nexport type RunConfig = RunFn;\nexport type RunFn = (collector: Collector.Instance) => void;\n\n// Session\nexport type SessionConfig = SessionFn;\nexport type SessionFn = (\n collector: Collector.Instance,\n session?: unknown,\n) => void;\n\nexport interface OnConfig {\n consent?: ConsentConfig[];\n ready?: ReadyConfig[];\n run?: RunConfig[];\n session?: SessionConfig[];\n [key: string]:\n | ConsentConfig[]\n | ReadyConfig[]\n | RunConfig[]\n | SessionConfig[]\n | undefined;\n}\n\n// Destination on function type with automatic type inference\nexport type OnFn = <T extends Types>(\n event: T,\n context: EventContextMap[T],\n) => WalkerOS.PromiseOrValue<void>;\n\n// Runtime-compatible version for internal usage\nexport type OnFnRuntime = (\n event: Types,\n context: AnyEventContext,\n) => WalkerOS.PromiseOrValue<void>;\n","export interface Context {\n city?: string;\n country?: string;\n encoding?: string;\n hash?: string;\n ip?: string;\n language?: string;\n origin?: string;\n region?: string;\n userAgent?: string;\n [key: string]: string | undefined;\n}\n","import type { WalkerOS } from '.';\n\nexport type Contracts = Array<Contract>;\n\nexport type Contract = {\n [entity: string]: {\n [action: string]: Properties;\n };\n};\n\nexport type Properties = {\n [key: string]: Property | undefined;\n};\n\nexport type Property = {\n allowedKeys?: string[];\n allowedValues?: unknown[];\n // @TODO minLength?: number;\n maxLength?: number;\n max?: number;\n min?: number;\n required?: boolean;\n schema?: Properties;\n strict?: boolean;\n type?: string;\n validate?: (\n value: unknown,\n key: string,\n event: WalkerOS.AnyObject,\n ) => WalkerOS.Property;\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n Elb,\n On,\n Handler,\n Mapping as WalkerOSMapping,\n Collector,\n} from './index';\n\n/**\n * Base Env interface for dependency injection into sources.\n *\n * Sources receive all their dependencies through this environment object,\n * making them platform-agnostic and easily testable.\n */\nexport interface BaseEnv {\n [key: string]: unknown;\n push: Collector.PushFn;\n command: Collector.CommandFn;\n sources?: Collector.Sources;\n elb: Elb.Fn;\n}\n\n/**\n * Type bundle for source generics.\n * Groups Settings, Mapping, Push, and Env into a single type parameter.\n *\n * @template S - Settings configuration type\n * @template M - Mapping configuration type\n * @template P - Push function signature (flexible to support HTTP handlers, etc.)\n * @template E - Environment dependencies type\n */\nexport interface Types<S = unknown, M = unknown, P = Elb.Fn, E = BaseEnv> {\n settings: S;\n mapping: M;\n push: P;\n env: E;\n}\n\n/**\n * Generic constraint for Types - ensures T has required properties for indexed access\n */\nexport type TypesGeneric = { settings: any; mapping: any; push: any; env: any };\n\n/**\n * Type extractors for consistent usage with Types bundle\n */\nexport type Settings<T extends TypesGeneric = Types> = T['settings'];\nexport type Mapping<T extends TypesGeneric = Types> = T['mapping'];\nexport type Push<T extends TypesGeneric = Types> = T['push'];\nexport type Env<T extends TypesGeneric = Types> = T['env'];\n\n/**\n * Inference helper: Extract Types from Instance\n */\nexport type TypesOf<I> = I extends Instance<infer T> ? T : never;\n\nexport interface Config<T extends TypesGeneric = Types>\n extends WalkerOSMapping.Config<Mapping<T>> {\n settings?: Settings<T>;\n env?: Env<T>;\n id?: string;\n onError?: Handler.Error;\n disabled?: boolean;\n primary?: boolean;\n}\n\nexport type PartialConfig<T extends TypesGeneric = Types> = Config<\n Types<\n Partial<Settings<T>> | Settings<T>,\n Partial<Mapping<T>> | Mapping<T>,\n Push<T>,\n Env<T>\n >\n>;\n\nexport interface Instance<T extends TypesGeneric = Types> {\n type: string;\n config: Config<T>;\n push: Push<T>;\n destroy?(): void | Promise<void>;\n on?(event: On.Types, context?: unknown): void | Promise<void>;\n}\n\nexport type Init<T extends TypesGeneric = Types> = (\n config: Partial<Config<T>>,\n env: Env<T>,\n) => Instance<T> | Promise<Instance<T>>;\n\nexport type InitSource<T extends TypesGeneric = Types> = {\n code: Init<T>;\n config?: Partial<Config<T>>;\n env?: Partial<Env<T>>;\n primary?: boolean;\n};\n\n/**\n * Sources configuration for collector.\n * Maps source IDs to their initialization configurations.\n */\nexport interface InitSources {\n [sourceId: string]: InitSource<any>;\n}\n","import type { Elb as ElbTypes } from '.';\n\nexport type AnyObject<T = unknown> = Record<string, T>;\nexport type Elb = ElbTypes.Fn;\nexport type AnyFunction = (...args: unknown[]) => unknown;\nexport type SingleOrArray<T> = T | Array<T>;\n\nexport type Events = Array<Event>;\nexport type PartialEvent = Partial<Event>;\nexport type DeepPartialEvent = DeepPartial<Event>;\nexport interface Event {\n name: string;\n data: Properties;\n context: OrderedProperties;\n globals: Properties;\n custom: Properties;\n user: User;\n nested: Entities;\n consent: Consent;\n id: string;\n trigger: string;\n entity: string;\n action: string;\n timestamp: number;\n timing: number;\n group: string;\n count: number;\n version: Version;\n source: Source;\n}\n\nexport interface Consent {\n [name: string]: boolean; // name of consent group or tool\n}\n\nexport interface User extends Properties {\n // IDs\n id?: string;\n device?: string;\n session?: string;\n hash?: string;\n // User related\n address?: string;\n email?: string;\n phone?: string;\n userAgent?: string;\n browser?: string;\n browserVersion?: string;\n deviceType?: string;\n language?: string;\n country?: string;\n region?: string;\n city?: string;\n zip?: string;\n timezone?: string;\n os?: string;\n osVersion?: string;\n screenSize?: string;\n ip?: string;\n internal?: boolean;\n}\n\nexport interface Version extends Properties {\n source: string;\n tagging: number;\n}\n\nexport interface Source extends Properties {\n type: SourceType;\n id: string; // https://github.com/elbwalker/walkerOS\n previous_id: string; // https://www.elbwalker.com/\n}\n\nexport type SourceType = 'web' | 'server' | 'app' | 'other' | string;\n\nexport type PropertyType =\n | boolean\n | string\n | number\n | { [key: string]: Property };\n\nexport type Property = PropertyType | Array<PropertyType>;\n\nexport interface Properties {\n [key: string]: Property | undefined;\n}\nexport interface OrderedProperties {\n [key: string]: [Property, number] | undefined;\n}\n\nexport type Entities = Array<Entity>;\nexport interface Entity {\n entity: string;\n data: Properties;\n nested: Entities;\n context: OrderedProperties;\n}\n\nexport type ConsentHandler = Record<string, AnyFunction>;\nexport type ActionHandler = AnyFunction;\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\nexport type PromiseOrValue<T> = T | Promise<T>;\n","export type StorageType = 'local' | 'session' | 'cookie';\n\nexport const Storage = {\n Local: 'local' as const,\n Session: 'session' as const,\n Cookie: 'cookie' as const,\n} as const;\n\nexport const Const = {\n Utils: {\n Storage,\n },\n} as const;\n","import { z } from 'zod';\n\n/**\n * Primitive Schema Definitions\n *\n * Reusable primitive schemas following DRY principle.\n * These are the building blocks used throughout all schemas to ensure consistency.\n *\n * Benefits:\n * - Single source of truth for common patterns\n * - Consistent descriptions across all schemas\n * - Easier maintenance and updates\n * - Better IntelliSense/autocomplete\n */\n\n// ========================================\n// Basic Primitives\n// ========================================\n\n/**\n * Required string field\n * Used for required text fields throughout schemas\n */\nexport const RequiredString = z.string();\n\n/**\n * Required number field\n * Used for required numeric fields throughout schemas\n */\nexport const RequiredNumber = z.number();\n\n/**\n * Required boolean field\n * Used for required flag fields throughout schemas\n */\nexport const RequiredBoolean = z.boolean();\n\n// ========================================\n// Semantic Primitives\n// ========================================\n\n/**\n * Identifier - Required unique string identifier\n * Used for entity IDs, session IDs, etc.\n */\nexport const Identifier = z.string().min(1);\n\n/**\n * Timestamp - Unix timestamp in milliseconds\n * Used for event timestamps, session timestamps, etc.\n */\nexport const Timestamp = z.number().int().positive();\n\n/**\n * Counter - Sequential counter (non-negative integer)\n * Used for event counts, session counts, etc.\n */\nexport const Counter = z.number().int().nonnegative();\n\n/**\n * TaggingVersion - Version number for event tagging\n * Standardized description used in both Version and Config schemas\n */\nexport const TaggingVersion = z.number().describe('Tagging version number');\n\n// ========================================\n// Primitive Value Unions\n// ========================================\n\n/**\n * PrimitiveValue - Basic primitive types\n * Union of string, number, and boolean\n * Used in Property definitions and value transformations\n */\nexport const PrimitiveValue = z.union([z.string(), z.number(), z.boolean()]);\n\n/**\n * OptionalPrimitiveValue - Optional primitive value\n */\nexport const OptionalPrimitiveValue = PrimitiveValue.optional();\n","import { z } from 'zod';\nimport {} from './primitives';\nimport { ErrorHandlerSchema, LogHandlerSchema } from './utilities';\n\n/**\n * Common Schema Patterns\n *\n * Reusable schema patterns that appear across multiple domain schemas.\n * These patterns combine primitives into commonly used configurations.\n *\n * Benefits:\n * - DRY principle for complex patterns\n * - Consistent configuration interfaces\n * - Single source of truth for common configs\n * - Easier to maintain and update patterns globally\n */\n\n// ========================================\n// Handler Patterns\n// ========================================\n\n/**\n * HandlersConfig - Error and log handler configuration\n * Used in: Destination.Config, Collector.Config, Source.Config\n */\nexport const HandlersConfig = z\n .object({\n onError: ErrorHandlerSchema.optional().describe(\n 'Error handler function: (error, state?) => void',\n ),\n onLog: LogHandlerSchema.optional().describe(\n 'Log handler function: (message, verbose?) => void',\n ),\n })\n .partial();\n\n// ========================================\n// Configuration Patterns\n// ========================================\n\n/**\n * VerboseConfig - Verbose logging configuration\n * Used in: Destination.Config, Collector.Config\n */\nexport const VerboseConfig = z\n .object({\n verbose: z\n .boolean()\n .describe('Enable verbose logging for debugging')\n .optional(),\n })\n .partial();\n\n/**\n * QueueConfig - Event queueing configuration\n * Used in: Destination.Config\n */\nexport const QueueConfig = z\n .object({\n queue: z\n .boolean()\n .describe('Whether to queue events when consent is not granted')\n .optional(),\n })\n .partial();\n\n/**\n * IdConfig - ID configuration pattern\n * Used in: Destination.Config, Source.Config\n */\nexport const IdConfig = z.object({}).partial();\n\n/**\n * InitConfig - Initialization configuration pattern\n * Used in: Destination.Config\n */\nexport const InitConfig = z\n .object({\n init: z.boolean().describe('Whether to initialize immediately').optional(),\n loadScript: z\n .boolean()\n .describe('Whether to load external script (for web destinations)')\n .optional(),\n })\n .partial();\n\n/**\n * DisabledConfig - Disabled flag configuration\n * Used in: Source.Config\n */\nexport const DisabledConfig = z\n .object({\n disabled: z.boolean().describe('Set to true to disable').optional(),\n })\n .partial();\n\n/**\n * PrimaryConfig - Primary flag configuration\n * Used in: Source.Config, Source.InitSource\n */\nexport const PrimaryConfig = z\n .object({\n primary: z\n .boolean()\n .describe('Mark as primary (only one can be primary)')\n .optional(),\n })\n .partial();\n\n// ========================================\n// Generic Configuration Patterns\n// ========================================\n\n/**\n * GenericSettingsConfig - Generic settings configuration\n * Used in: Destination.Config, Source.Config, Collector runtime\n * Settings are implementation-specific and can't be validated generically\n */\nexport const GenericSettingsConfig = z\n .object({\n settings: z\n .any()\n .optional()\n .describe('Implementation-specific configuration'),\n })\n .partial();\n\n/**\n * GenericEnvConfig - Generic environment configuration\n * Used in: Destination.Config, Source.Config, Source.BaseEnv\n * Environment is platform-specific and can't be validated generically\n */\nexport const GenericEnvConfig = z\n .object({\n env: z\n .any()\n .optional()\n .describe('Environment dependencies (platform-specific)'),\n })\n .partial();\n\n// ========================================\n// Mapping Patterns\n// ========================================\n\n/**\n * DataTransformationConfig - Data transformation configuration\n * Used in: Destination.Config, Mapping.Config, Mapping.Rule\n *\n * Note: This creates a forward reference to ValueSchema/ValuesSchema\n * Import from mapping.ts to avoid circular dependencies\n */\nexport function createDataTransformationConfig(\n ValueSchema: z.ZodTypeAny,\n ValuesSchema: z.ZodTypeAny,\n) {\n return z\n .object({\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe('Data transformation rules'),\n })\n .partial();\n}\n\n/**\n * MappingRulesConfig - Mapping rules configuration\n * Used in: Destination.Config, Source.Config (via Mapping.Config)\n *\n * Note: This creates a forward reference to RulesSchema\n * Import from mapping.ts to avoid circular dependencies\n */\nexport function createMappingRulesConfig(RulesSchema: z.ZodTypeAny) {\n return z\n .object({\n mapping: RulesSchema.optional().describe('Event mapping rules'),\n })\n .partial();\n}\n\n/**\n * PolicyConfig - Policy rules configuration\n * Used in: Destination.Config, Mapping.Config, Mapping.Rule\n *\n * Note: This creates a forward reference to PolicySchema\n * Import from mapping.ts to avoid circular dependencies\n */\nexport function createPolicyConfig(PolicySchema: z.ZodTypeAny) {\n return z\n .object({\n policy: PolicySchema.optional().describe('Pre-processing policy rules'),\n })\n .partial();\n}\n\n/**\n * ConsentConfig - Consent requirements configuration\n * Used in: Destination.Config, Mapping.Config, Mapping.Rule, Event\n *\n * Note: This creates a forward reference to ConsentSchema\n * Import from walkeros.ts to avoid circular dependencies\n */\nexport function createConsentConfig(ConsentSchema: z.ZodTypeAny) {\n return z\n .object({\n consent: ConsentSchema.optional().describe('Required consent states'),\n })\n .partial();\n}\n\n// ========================================\n// Instance Patterns\n// ========================================\n\n/**\n * RuntimeInstanceConfig - Runtime instance configuration\n * Used in: Destination.Instance, Source.Instance, Collector.Instance\n *\n * Common fields for runtime instances:\n * - type: Instance type identifier\n * - config: Configuration object\n * - Functions (push, init, etc.) are instance-specific\n */\nexport const RuntimeInstanceConfig = z\n .object({\n type: z.string().optional().describe('Instance type identifier'),\n config: z.any().describe('Instance configuration'),\n })\n .partial();\n\n// ========================================\n// Context Patterns\n// ========================================\n\n/**\n * BaseContextConfig - Base context configuration\n * Used in: Destination.Context, Source contexts\n *\n * Common fields for contexts:\n * - collector: Collector instance (runtime)\n * - config: Configuration\n * - env: Environment dependencies\n */\nexport const BaseContextConfig = z\n .object({\n collector: z.any().describe('Collector instance (runtime object)'),\n config: z.any().describe('Configuration'),\n env: z.any().describe('Environment dependencies'),\n })\n .partial();\n\n// ========================================\n// Batch Patterns\n// ========================================\n\n/**\n * BatchConfig - Batch processing configuration\n * Used in: Mapping.Rule\n */\nexport const BatchConfig = z\n .object({\n batch: z\n .number()\n .optional()\n .describe('Batch size: bundle N events for batch processing'),\n batched: z.any().optional().describe('Batch of events to be processed'),\n })\n .partial();\n\n// ========================================\n// Processing Patterns\n// ========================================\n\n/**\n * ProcessingControlConfig - Processing control flags\n * Used in: Mapping.Rule\n */\nexport const ProcessingControlConfig = z\n .object({\n ignore: z.boolean().describe('Set to true to skip processing').optional(),\n condition: z\n .string()\n .optional()\n .describe('Condition function: return true to process'),\n })\n .partial();\n\n// ========================================\n// Collection Patterns\n// ========================================\n\n/**\n * SourcesMapConfig - Sources collection pattern\n * Used in: Collector.Instance\n */\nexport const SourcesMapConfig = z\n .object({\n sources: z.record(z.string(), z.any()).describe('Map of source instances'),\n })\n .partial();\n\n/**\n * DestinationsMapConfig - Destinations collection pattern\n * Used in: Collector.Instance\n */\nexport const DestinationsMapConfig = z\n .object({\n destinations: z\n .record(z.string(), z.any())\n .describe('Map of destination instances'),\n })\n .partial();\n","import { z } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\n\n/**\n * Utility Schemas\n *\n * Mirrors: types/storage.ts, types/handler.ts, and other utility types\n * Purpose: Runtime validation and JSON Schema generation for utility types\n *\n * Small, standalone schemas for utility types used throughout walkerOS:\n * - Storage types\n * - Handler functions\n * - Error/log management\n */\n\n// ========================================\n// Storage Schemas\n// ========================================\n\n/**\n * StorageType - Storage mechanism identifier\n *\n * Standard storage types:\n * - local: localStorage (persistent)\n * - session: sessionStorage (session-scoped)\n * - cookie: document.cookie (configurable expiry)\n *\n * Used for session persistence and user tracking\n */\nexport const StorageTypeSchema = z\n .enum(['local', 'session', 'cookie'])\n .describe('Storage mechanism: local, session, or cookie');\n\n/**\n * Storage - Storage type constants\n * Provides const values for type-safe storage type references\n */\nexport const StorageSchema = z\n .object({\n Local: z.literal('local'),\n Session: z.literal('session'),\n Cookie: z.literal('cookie'),\n })\n .describe('Storage type constants for type-safe references');\n\n// ========================================\n// Handler Schemas\n// ========================================\n\n/**\n * Error - Error handler function type\n *\n * Signature: (error: unknown, state?: unknown) => void\n *\n * Called when errors occur during:\n * - Event processing\n * - Destination push operations\n * - Source event handling\n * - Mapping transformations\n *\n * Parameters:\n * - error: The error that occurred\n * - state: Optional state information for debugging\n *\n * Note: Function schemas use z.any() as functions aren't serializable\n */\nexport const ErrorHandlerSchema = z\n .any()\n .describe('Error handler function: (error, state?) => void');\n\n/**\n * Log - Log handler function type\n *\n * Signature: (message: string, verbose?: boolean) => void\n *\n * Called for logging during:\n * - Event processing\n * - Configuration updates\n * - Debugging (when verbose enabled)\n *\n * Parameters:\n * - message: Log message\n * - verbose: Whether this is a verbose-only log\n *\n * Note: Function schemas use z.any() as functions aren't serializable\n */\nexport const LogHandlerSchema = z\n .any()\n .describe('Log handler function: (message, verbose?) => void');\n\n/**\n * Handler - Combined handler interface\n * Groups Error and Log handlers\n */\nexport const HandlerSchema = z\n .object({\n Error: ErrorHandlerSchema.describe('Error handler function'),\n Log: LogHandlerSchema.describe('Log handler function'),\n })\n .describe('Handler interface with error and log functions');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const storageTypeJsonSchema = zodToJsonSchema(StorageTypeSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'StorageType',\n});\n\nexport const storageJsonSchema = zodToJsonSchema(StorageSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Storage',\n});\n\nexport const errorHandlerJsonSchema = zodToJsonSchema(ErrorHandlerSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'ErrorHandler',\n});\n\nexport const logHandlerJsonSchema = zodToJsonSchema(LogHandlerSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'LogHandler',\n});\n\nexport const handlerJsonSchema = zodToJsonSchema(HandlerSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Handler',\n});\n","import { z } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport {\n RequiredString,\n RequiredNumber,\n Identifier,\n Timestamp,\n Counter,\n TaggingVersion,\n} from './primitives';\n\n/**\n * Core walkerOS Event Model Schemas\n *\n * Mirrors: types/walkeros.ts\n * Purpose: Runtime validation and JSON Schema generation for MCP tools, Explorer UI, and API boundaries\n *\n * These schemas provide:\n * 1. Runtime validation for event data\n * 2. JSON Schema generation for RJSF/Explorer\n * 3. Type documentation via .describe()\n * 4. Compile-time type checking (schemas mirror TypeScript types)\n *\n * Note: TypeScript types in types/walkeros.ts remain the source of truth for development.\n * These Zod schemas are for validation and JSON Schema generation at runtime boundaries.\n */\n\n// ========================================\n// Base Property Types (Recursive)\n// ========================================\n\n/**\n * PropertyType - Base property value types\n * Can be primitive (boolean, string, number) or nested object with Property values\n */\nexport const PropertyTypeSchema: z.ZodTypeAny = z.lazy(() =>\n z.union([\n z.boolean(),\n z.string(),\n z.number(),\n z.record(z.string(), PropertySchema),\n ]),\n);\n\n/**\n * Property - PropertyType or array of PropertyType\n * Recursive structure allows nested objects and arrays\n */\nexport const PropertySchema: z.ZodTypeAny = z.lazy(() =>\n z.union([PropertyTypeSchema, z.array(PropertyTypeSchema)]),\n);\n\n/**\n * Properties - Record of string keys to Property values\n * Used throughout event structure (data, globals, custom, etc.)\n */\nexport const PropertiesSchema = z\n .record(z.string(), PropertySchema.optional())\n .describe('Flexible property collection with optional values');\n\n/**\n * OrderedProperties - Record with [value, order] tuples\n * Used for context data where order matters\n */\nexport const OrderedPropertiesSchema = z\n .record(z.string(), z.tuple([PropertySchema, z.number()]).optional())\n .describe(\n 'Ordered properties with [value, order] tuples for priority control',\n );\n\n// ========================================\n// Enums & Union Types\n// ========================================\n\n/**\n * SourceType - Event source identifier\n * Standard types: web, server, app, other\n * Extensible: allows custom string values\n */\nexport const SourceTypeSchema = z\n .union([z.enum(['web', 'server', 'app', 'other']), z.string()])\n .describe('Source type: web, server, app, other, or custom');\n\n// ========================================\n// Event Sub-Types\n// ========================================\n\n/**\n * Consent - Consent state mapping\n * Maps consent group names to boolean states\n * Used in Event and Destination/Source configs\n */\nexport const ConsentSchema = z\n .record(z.string(), z.boolean())\n .describe('Consent requirement mapping (group name → state)');\n\n/**\n * User - User identification and attributes\n * Extends Properties with specific optional fields\n * Contains IDs, demographics, device info, and location data\n */\nexport const UserSchema = PropertiesSchema.and(\n z.object({\n // IDs\n id: z.string().optional().describe('User identifier'),\n device: z.string().optional().describe('Device identifier'),\n session: z.string().optional().describe('Session identifier'),\n hash: z.string().optional().describe('Hashed identifier'),\n // User attributes\n address: z.string().optional().describe('User address'),\n email: z.string().email().optional().describe('User email address'),\n phone: z.string().optional().describe('User phone number'),\n // Technical attributes\n userAgent: z.string().optional().describe('Browser user agent string'),\n browser: z.string().optional().describe('Browser name'),\n browserVersion: z.string().optional().describe('Browser version'),\n deviceType: z\n .string()\n .optional()\n .describe('Device type (mobile, desktop, tablet)'),\n os: z.string().optional().describe('Operating system'),\n osVersion: z.string().optional().describe('Operating system version'),\n screenSize: z.string().optional().describe('Screen dimensions'),\n // Location attributes\n language: z.string().optional().describe('User language'),\n country: z.string().optional().describe('User country'),\n region: z.string().optional().describe('User region/state'),\n city: z.string().optional().describe('User city'),\n zip: z.string().optional().describe('User postal code'),\n timezone: z.string().optional().describe('User timezone'),\n ip: z.string().optional().describe('User IP address'),\n // Flags\n internal: z\n .boolean()\n .optional()\n .describe('Internal user flag (employee, test user)'),\n }),\n).describe('User identification and properties');\n\n/**\n * Version - Walker version information\n * Tracks source implementation and tagging version\n */\nexport const VersionSchema = PropertiesSchema.and(\n z.object({\n source: RequiredString.describe(\n 'Walker implementation version (e.g., \"2.0.0\")',\n ),\n tagging: TaggingVersion,\n }),\n).describe('Walker version information');\n\n/**\n * Source - Event source information\n * Identifies where the event originated\n */\nexport const SourceSchema = PropertiesSchema.and(\n z.object({\n type: SourceTypeSchema.describe('Source type identifier'),\n id: RequiredString.describe('Source identifier (typically URL on web)'),\n previous_id: RequiredString.describe(\n 'Previous source identifier (typically referrer on web)',\n ),\n }),\n).describe('Event source information');\n\n/**\n * Entity - Nested entity structure\n * Allows events to contain related entities with their own data and context\n * Recursive: entities can contain nested entities\n */\nexport const EntitySchema: z.ZodTypeAny = z\n .lazy(() =>\n z.object({\n entity: z.string().describe('Entity name'),\n data: PropertiesSchema.describe('Entity-specific properties'),\n nested: z.array(EntitySchema).describe('Nested child entities'),\n context: OrderedPropertiesSchema.describe('Entity context data'),\n }),\n )\n .describe('Nested entity structure with recursive nesting support');\n\n/**\n * Entities - Array of Entity objects\n */\nexport const EntitiesSchema = z\n .array(EntitySchema)\n .describe('Array of nested entities');\n\n// ========================================\n// Main Event Schema\n// ========================================\n\n/**\n * Event - Complete walkerOS event structure\n *\n * Core fields:\n * - name: Event identifier in \"entity action\" format (e.g., \"page view\")\n * - data: Event-specific properties\n * - context: Ordered context properties\n * - globals: Global properties shared across events\n * - custom: Custom properties specific to implementation\n * - user: User identification and attributes\n * - nested: Related entities\n * - consent: Consent states at event time\n *\n * System-generated fields:\n * - id: Unique event identifier\n * - timestamp: Event creation time (milliseconds since epoch)\n * - entity: Parsed entity name from event.name\n * - action: Parsed action name from event.name\n * - trigger: Event trigger identifier\n * - timing: Event processing timing information\n * - group: Event grouping identifier\n * - count: Event count in session\n * - version: Walker version information\n * - source: Event source information\n */\nexport const EventSchema = z\n .object({\n // Core event identification\n name: z\n .string()\n .describe(\n 'Event name in \"entity action\" format (e.g., \"page view\", \"product add\")',\n ),\n\n // Event data\n data: PropertiesSchema.describe('Event-specific properties'),\n context: OrderedPropertiesSchema.describe(\n 'Ordered context properties with priorities',\n ),\n globals: PropertiesSchema.describe(\n 'Global properties shared across events',\n ),\n custom: PropertiesSchema.describe(\n 'Custom implementation-specific properties',\n ),\n\n // Related data\n user: UserSchema.describe('User identification and attributes'),\n nested: EntitiesSchema.describe('Related nested entities'),\n consent: ConsentSchema.describe('Consent states at event time'),\n\n // System-generated fields\n id: Identifier.describe('Unique event identifier (timestamp-based)'),\n trigger: RequiredString.describe('Event trigger identifier'),\n entity: RequiredString.describe('Parsed entity from event name'),\n action: RequiredString.describe('Parsed action from event name'),\n timestamp: Timestamp.describe('Unix timestamp in milliseconds since epoch'),\n timing: RequiredNumber.describe('Event processing timing information'),\n group: RequiredString.describe('Event grouping identifier'),\n count: Counter.describe('Event count in session'),\n\n // Version & source tracking\n version: VersionSchema.describe('Walker version information'),\n source: SourceSchema.describe('Event source information'),\n })\n .describe('Complete walkerOS event structure');\n\n/**\n * PartialEvent - Event with all fields optional\n * Used for event creation where not all fields are provided\n */\nexport const PartialEventSchema = EventSchema.partial().describe(\n 'Partial event structure with all fields optional',\n);\n\n/**\n * DeepPartialEvent - Event with deeply nested optional fields\n * Used for event updates and patches\n */\nexport const DeepPartialEventSchema: z.ZodTypeAny = z\n .lazy(() => EventSchema.deepPartial())\n .describe('Deep partial event structure with all nested fields optional');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const eventJsonSchema = zodToJsonSchema(EventSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Event',\n});\n\nexport const partialEventJsonSchema = zodToJsonSchema(PartialEventSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'PartialEvent',\n});\n\nexport const userJsonSchema = zodToJsonSchema(UserSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'User',\n});\n\nexport const propertiesJsonSchema = zodToJsonSchema(PropertiesSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Properties',\n});\n\nexport const orderedPropertiesJsonSchema = zodToJsonSchema(\n OrderedPropertiesSchema,\n {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'OrderedProperties',\n },\n);\n\nexport const entityJsonSchema = zodToJsonSchema(EntitySchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Entity',\n});\n\nexport const sourceTypeJsonSchema = zodToJsonSchema(SourceTypeSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'SourceType',\n});\n\nexport const consentJsonSchema = zodToJsonSchema(ConsentSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Consent',\n});\n","import { z } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport { ConsentSchema } from './walkeros';\n\n/**\n * Mapping System Schemas\n *\n * Mirrors: types/mapping.ts\n * Purpose: Runtime validation and JSON Schema generation for event transformation rules\n *\n * The mapping system allows flexible transformation of events as they flow through\n * the collector to destinations. This includes:\n * - Value extraction and transformation\n * - Conditional logic\n * - Data mapping and restructuring\n * - Array processing (loops)\n * - Consent-based filtering\n *\n * Key Features:\n * - Recursive value definitions (Value → ValueConfig → Value)\n * - Loop vs Set distinction via JSON Schema (minItems/maxItems)\n * - Lazy evaluation for circular dependencies\n * - Function serialization support (functions as strings)\n */\n\n// ========================================\n// Recursive Value Schemas\n// ========================================\n\n/**\n * Value - Core value type for mapping transformations\n *\n * Can be:\n * - Primitive: string, number, boolean\n * - ValueConfig: Complex transformation object\n * - Array: Multiple values/configs\n *\n * Recursive structure allows nested transformations\n */\nexport const ValueSchema: z.ZodTypeAny = z.lazy(() =>\n z.union([\n z.string().describe('String value or property path (e.g., \"data.id\")'),\n z.number().describe('Numeric value'),\n z.boolean().describe('Boolean value'),\n ValueConfigSchema,\n z.array(ValueSchema).describe('Array of values'),\n ]),\n);\n\n/**\n * Values - Array of Value objects\n * Used for multiple data transformations\n */\nexport const ValuesSchema = z\n .array(ValueSchema)\n .describe('Array of transformation values');\n\n/**\n * Loop - Tuple for array processing\n * Format: [source, transform]\n *\n * IMPORTANT: z.tuple() generates JSON Schema with minItems/maxItems = 2\n * This is how Explorer distinguishes Loop from Set\n *\n * Example: ['nested', { map: { id: 'data.id' } }]\n * Means: Iterate over event.nested array, transform each item\n */\nconst LoopSchema: z.ZodTypeAny = z\n .tuple([ValueSchema, ValueSchema])\n .describe(\n 'Loop transformation: [source, transform] tuple for array processing',\n );\n\n/**\n * Set - Array of values for selection/combination\n * Format: [value1, value2, ...]\n *\n * IMPORTANT: z.array() generates JSON Schema without minItems/maxItems\n * This distinguishes Set from Loop\n *\n * Example: ['data.firstName', ' ', 'data.lastName']\n * Means: Combine multiple values\n */\nconst SetSchema: z.ZodTypeAny = z\n .array(ValueSchema)\n .describe('Set: Array of values for selection or combination');\n\n/**\n * Map - Object mapping for data transformation\n * Format: { outputKey: value, ... }\n *\n * Example: { item_id: 'data.id', item_name: 'data.name' }\n * Means: Transform event data to destination format\n */\nconst MapSchema: z.ZodTypeAny = z\n .record(z.string(), ValueSchema)\n .describe('Map: Object mapping keys to transformation values');\n\n/**\n * ValueConfig - Configuration object for value transformations\n *\n * Supports multiple transformation strategies:\n * - key: Extract property from event (e.g., \"data.id\")\n * - value: Static primitive value\n * - fn: Custom transformation function (as string)\n * - map: Object mapping for structured output\n * - loop: Array iteration and transformation\n * - set: Value combination/selection\n * - consent: Consent-based filtering\n * - condition: Conditional transformation\n * - validate: Value validation\n *\n * At least one property must be present.\n */\nconst ValueConfigSchema: z.ZodTypeAny = z\n .object({\n key: z\n .string()\n .optional()\n .describe(\n 'Property path to extract from event (e.g., \"data.id\", \"user.email\")',\n ),\n value: z\n .union([z.string(), z.number(), z.boolean()])\n .optional()\n .describe('Static primitive value'),\n fn: z\n .string()\n .optional()\n .describe('Custom transformation function as string (serialized)'),\n map: MapSchema.optional().describe(\n 'Object mapping: transform event data to structured output',\n ),\n loop: LoopSchema.optional().describe(\n 'Loop transformation: [source, transform] for array processing',\n ),\n set: SetSchema.optional().describe(\n 'Set of values: combine or select from multiple values',\n ),\n consent: ConsentSchema.optional().describe(\n 'Required consent states to include this value',\n ),\n condition: z\n .string()\n .optional()\n .describe('Condition function as string: return true to include value'),\n validate: z\n .string()\n .optional()\n .describe('Validation function as string: return true if value is valid'),\n })\n .refine((data) => Object.keys(data).length > 0, {\n message: 'ValueConfig must have at least one property',\n })\n .describe('Value transformation configuration with multiple strategies');\n\n// Re-export for use in other schemas\nexport { ValueConfigSchema, LoopSchema, SetSchema, MapSchema };\n\n// ========================================\n// Policy Schema\n// ========================================\n\n/**\n * Policy - Pre-processing rules\n * Applied before event mapping\n * Maps policy keys to transformation values\n *\n * Example: { 'consent.marketing': true }\n * Means: Only process events with marketing consent\n */\nexport const PolicySchema = z\n .record(z.string(), ValueSchema)\n .describe('Policy rules for event pre-processing (key → value mapping)');\n\n// ========================================\n// Mapping Rule Schemas\n// ========================================\n\n/**\n * Rule - Event-specific mapping configuration\n *\n * Defines how to transform events for a specific entity-action combination\n * Can include:\n * - Batching configuration\n * - Conditional processing\n * - Consent requirements\n * - Custom settings\n * - Data transformation\n * - Event naming\n * - Policy overrides\n */\nexport const RuleSchema = z\n .object({\n batch: z\n .number()\n .optional()\n .describe('Batch size: bundle N events for batch processing'),\n // Note: batchFn and batched are runtime functions, not serializable\n condition: z\n .string()\n .optional()\n .describe('Condition function as string: return true to process event'),\n consent: ConsentSchema.optional().describe(\n 'Required consent states to process this event',\n ),\n settings: z\n .any()\n .optional()\n .describe('Destination-specific settings for this event mapping'),\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe('Data transformation rules for event'),\n ignore: z\n .boolean()\n .optional()\n .describe('Set to true to skip processing this event'),\n name: z\n .string()\n .optional()\n .describe(\n 'Custom event name override (e.g., \"view_item\" for \"product view\")',\n ),\n policy: PolicySchema.optional().describe(\n 'Event-level policy overrides (applied after config-level policy)',\n ),\n })\n .describe('Mapping rule for specific entity-action combination');\n\n/**\n * Rules - Nested mapping rules structure\n * Format: { entity: { action: Rule | Rule[], ... }, ... }\n *\n * Supports:\n * - Specific entity-action mappings\n * - Wildcard patterns (entity: *, action: *)\n * - Multiple rules per entity-action (array)\n *\n * Example:\n * {\n * product: {\n * view: { name: 'view_item' },\n * add: { name: 'add_to_cart' }\n * },\n * page: {\n * '*': { name: 'page_interaction' }\n * }\n * }\n */\nexport const RulesSchema = z\n .record(\n z.string(),\n z.record(z.string(), z.union([RuleSchema, z.array(RuleSchema)])).optional(),\n )\n .describe(\n 'Nested mapping rules: { entity: { action: Rule | Rule[] } } with wildcard support',\n );\n\n/**\n * Config - Shared mapping configuration\n * Used by both Source.Config and Destination.Config\n *\n * Provides:\n * - Consent requirements\n * - Global data transformations\n * - Entity-action mapping rules\n * - Pre-processing policies\n */\nexport const ConfigSchema = z\n .object({\n consent: ConsentSchema.optional().describe(\n 'Required consent states to process any events',\n ),\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe('Global data transformation applied to all events'),\n mapping: RulesSchema.optional().describe(\n 'Entity-action specific mapping rules',\n ),\n policy: PolicySchema.optional().describe(\n 'Pre-processing policy rules applied before mapping',\n ),\n })\n .describe('Shared mapping configuration for sources and destinations');\n\n/**\n * Result - Mapping resolution result\n * Contains the resolved mapping rule and key used\n */\nexport const ResultSchema = z\n .object({\n eventMapping: RuleSchema.optional().describe(\n 'Resolved mapping rule for event',\n ),\n mappingKey: z\n .string()\n .optional()\n .describe('Mapping key used (e.g., \"product.view\")'),\n })\n .describe('Mapping resolution result');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const valueJsonSchema = zodToJsonSchema(ValueSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Value',\n});\n\nexport const valueConfigJsonSchema = zodToJsonSchema(ValueConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'ValueConfig',\n});\n\nexport const loopJsonSchema = zodToJsonSchema(LoopSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Loop',\n});\n\nexport const setJsonSchema = zodToJsonSchema(SetSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Set',\n});\n\nexport const mapJsonSchema = zodToJsonSchema(MapSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Map',\n});\n\nexport const policyJsonSchema = zodToJsonSchema(PolicySchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Policy',\n});\n\nexport const ruleJsonSchema = zodToJsonSchema(RuleSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Rule',\n});\n\nexport const rulesJsonSchema = zodToJsonSchema(RulesSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Rules',\n});\n\nexport const configJsonSchema = zodToJsonSchema(ConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'MappingConfig',\n});\n","import { z } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport { ConsentSchema, EventSchema } from './walkeros';\nimport {\n ValueSchema,\n ValuesSchema,\n RuleSchema,\n RulesSchema,\n PolicySchema,\n} from './mapping';\nimport { Identifier } from './primitives';\nimport { ErrorHandlerSchema, LogHandlerSchema } from './utilities';\n\n/**\n * Destination Schemas\n *\n * Mirrors: types/destination.ts\n * Purpose: Runtime validation and JSON Schema generation for destination configurations\n *\n * Destinations are the endpoints where processed events are sent (analytics tools,\n * marketing platforms, data warehouses, etc.). This file defines schemas for:\n * - Destination configuration\n * - Type bundles for generic constraints\n * - Push contexts\n * - Batching structures\n */\n\n// ========================================\n// Configuration Schemas\n// ========================================\n\n/**\n * Config - Destination configuration\n *\n * Defines how a destination processes events:\n * - Consent requirements\n * - Settings (destination-specific)\n * - Data transformations\n * - Environment dependencies\n * - Initialization options\n * - Mapping rules\n * - Processing policies\n * - Queueing behavior\n * - Logging verbosity\n * - Error/log handlers\n *\n * Generic note: settings, env, and mapping can have destination-specific types\n * but for schema validation we use z.any() to allow flexibility\n */\nexport const ConfigSchema = z\n .object({\n consent: ConsentSchema.optional().describe(\n 'Required consent states to send events to this destination',\n ),\n settings: z\n .any()\n .describe('Implementation-specific configuration')\n .optional(),\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe(\n 'Global data transformation applied to all events for this destination',\n ),\n env: z\n .any()\n .describe('Environment dependencies (platform-specific)')\n .optional(),\n id: Identifier.describe(\n 'Destination instance identifier (defaults to destination key)',\n ).optional(),\n init: z.boolean().describe('Whether to initialize immediately').optional(),\n loadScript: z\n .boolean()\n .describe('Whether to load external script (for web destinations)')\n .optional(),\n mapping: RulesSchema.optional().describe(\n 'Entity-action specific mapping rules for this destination',\n ),\n policy: PolicySchema.optional().describe(\n 'Pre-processing policy rules applied before event mapping',\n ),\n queue: z\n .boolean()\n .describe('Whether to queue events when consent is not granted')\n .optional(),\n verbose: z\n .boolean()\n .describe('Enable verbose logging for debugging')\n .optional(),\n // Handler functions\n onError: ErrorHandlerSchema.optional(),\n onLog: LogHandlerSchema.optional(),\n })\n .describe('Destination configuration');\n\n/**\n * PartialConfig - Config with all fields optional and partial settings\n * Used for config updates and overrides\n */\nexport const PartialConfigSchema = ConfigSchema.deepPartial().describe(\n 'Partial destination configuration with all fields deeply optional',\n);\n\n/**\n * Policy - Processing policy rules\n * Maps policy keys to transformation values\n * Applied before event mapping\n */\nexport const DestinationPolicySchema = PolicySchema.describe(\n 'Destination policy rules for event pre-processing',\n);\n\n// ========================================\n// Context Schemas\n// ========================================\n\n/**\n * Context - Base destination context\n * Passed to init and push functions\n * Contains collector instance, config, data, and environment\n *\n * Note: collector is runtime instance, not easily serializable\n */\nexport const ContextSchema = z\n .object({\n collector: z.any().describe('Collector instance (runtime object)'),\n config: ConfigSchema.describe('Destination configuration'),\n data: z\n .union([\n z.any(), // WalkerOS.Property\n z.undefined(),\n z.array(z.union([z.any(), z.undefined()])),\n ])\n .optional()\n .describe('Transformed event data'),\n env: z.any().describe('Environment dependencies'),\n })\n .describe('Destination context for init and push functions');\n\n/**\n * PushContext - Context for push function\n * Extends Context with mapping rule information\n */\nexport const PushContextSchema = ContextSchema.extend({\n mapping: RuleSchema.optional().describe(\n 'Resolved mapping rule for this specific event',\n ),\n}).describe('Push context with event-specific mapping');\n\n/**\n * PushBatchContext - Context for pushBatch function\n * Same as PushContext but for batch processing\n */\nexport const PushBatchContextSchema = PushContextSchema.describe(\n 'Batch push context with event-specific mapping',\n);\n\n// ========================================\n// Batch Processing Schemas\n// ========================================\n\n/**\n * PushEvent - Single event with mapping in a batch\n */\nexport const PushEventSchema = z\n .object({\n event: EventSchema.describe('The event to process'),\n mapping: RuleSchema.optional().describe('Mapping rule for this event'),\n })\n .describe('Event with optional mapping for batch processing');\n\n/**\n * PushEvents - Array of PushEvent\n */\nexport const PushEventsSchema = z\n .array(PushEventSchema)\n .describe('Array of events with mappings');\n\n/**\n * Batch - Batched events for processing\n * Groups events by mapping key for efficient batch sends\n */\nexport const BatchSchema = z\n .object({\n key: z\n .string()\n .describe('Batch key (usually mapping key like \"product.view\")'),\n events: z.array(EventSchema).describe('Array of events in batch'),\n data: z\n .array(\n z.union([\n z.any(), // WalkerOS.Property\n z.undefined(),\n z.array(z.union([z.any(), z.undefined()])),\n ]),\n )\n .describe('Transformed data for each event'),\n mapping: RuleSchema.optional().describe('Shared mapping rule for batch'),\n })\n .describe('Batch of events grouped by mapping key');\n\n/**\n * Data - Transformed event data types\n * Can be single property, undefined, or array of properties\n */\nexport const DataSchema = z\n .union([\n z.any(), // WalkerOS.Property\n z.undefined(),\n z.array(z.union([z.any(), z.undefined()])),\n ])\n .describe('Transformed event data (Property, undefined, or array)');\n\n// ========================================\n// Instance Schemas\n// ========================================\n\n/**\n * Instance - Destination instance (runtime object)\n *\n * Note: This schema is primarily for documentation\n * Runtime functions (init, push, pushBatch) cannot be validated\n * Use z.any() for function fields\n */\nexport const InstanceSchema = z\n .object({\n config: ConfigSchema.describe('Destination configuration'),\n queue: z\n .array(EventSchema)\n .optional()\n .describe('Queued events awaiting consent'),\n dlq: z\n .array(z.tuple([EventSchema, z.any()]))\n .optional()\n .describe('Dead letter queue (failed events with errors)'),\n type: z.string().optional().describe('Destination type identifier'),\n env: z.any().optional().describe('Environment dependencies'),\n // Functions - not validated, use z.any()\n init: z.any().optional().describe('Initialization function'),\n push: z.any().describe('Push function for single events'),\n pushBatch: z.any().optional().describe('Batch push function'),\n on: z.any().optional().describe('Event lifecycle hook function'),\n })\n .describe('Destination instance (runtime object with functions)');\n\n/**\n * Init - Initialization config\n * Contains destination code and configuration\n */\nexport const InitSchema = z\n .object({\n code: InstanceSchema.describe('Destination instance with implementation'),\n config: PartialConfigSchema.optional().describe(\n 'Partial configuration overrides',\n ),\n env: z.any().optional().describe('Partial environment overrides'),\n })\n .describe('Destination initialization configuration');\n\n/**\n * InitDestinations - Map of destination IDs to Init configs\n */\nexport const InitDestinationsSchema = z\n .record(z.string(), InitSchema)\n .describe('Map of destination IDs to initialization configurations');\n\n/**\n * Destinations - Map of destination IDs to instances\n */\nexport const DestinationsSchema = z\n .record(z.string(), InstanceSchema)\n .describe('Map of destination IDs to runtime instances');\n\n// ========================================\n// Result Schemas\n// ========================================\n\n/**\n * Ref - Destination reference\n * Links destination ID to instance\n */\nexport const RefSchema = z\n .object({\n id: z.string().describe('Destination ID'),\n destination: InstanceSchema.describe('Destination instance'),\n })\n .describe('Destination reference (ID + instance)');\n\n/**\n * Push - Push operation result\n */\nexport const PushResultSchema = z\n .object({\n queue: z\n .array(EventSchema)\n .optional()\n .describe('Events queued (awaiting consent)'),\n error: z.any().optional().describe('Error if push failed'),\n })\n .describe('Push operation result');\n\n/**\n * Result - Overall processing result\n * Categorizes destinations by processing outcome\n */\nexport const ResultSchema = z\n .object({\n successful: z\n .array(RefSchema)\n .describe('Destinations that processed successfully'),\n queued: z.array(RefSchema).describe('Destinations that queued events'),\n failed: z.array(RefSchema).describe('Destinations that failed to process'),\n })\n .describe('Overall destination processing result');\n\n/**\n * DLQ - Dead Letter Queue\n * Array of failed events with their errors\n */\nexport const DLQSchema = z\n .array(z.tuple([EventSchema, z.any()]))\n .describe('Dead letter queue: [(event, error), ...]');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const configJsonSchema = zodToJsonSchema(ConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'DestinationConfig',\n});\n\nexport const partialConfigJsonSchema = zodToJsonSchema(PartialConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'PartialDestinationConfig',\n});\n\nexport const contextJsonSchema = zodToJsonSchema(ContextSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'DestinationContext',\n});\n\nexport const pushContextJsonSchema = zodToJsonSchema(PushContextSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'PushContext',\n});\n\nexport const batchJsonSchema = zodToJsonSchema(BatchSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'Batch',\n});\n\nexport const instanceJsonSchema = zodToJsonSchema(InstanceSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'DestinationInstance',\n});\n\nexport const resultJsonSchema = zodToJsonSchema(ResultSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'DestinationResult',\n});\n","import { z } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport {\n ConsentSchema,\n UserSchema,\n PropertiesSchema,\n EventSchema,\n} from './walkeros';\nimport { ConfigSchema as MappingConfigSchema } from './mapping';\nimport {\n RequiredBoolean,\n RequiredNumber,\n Identifier,\n Timestamp,\n Counter,\n TaggingVersion,\n} from './primitives';\nimport { ErrorHandlerSchema, LogHandlerSchema } from './utilities';\n\n/**\n * Collector Schemas\n *\n * Mirrors: types/collector.ts\n * Purpose: Runtime validation and JSON Schema generation for collector configurations\n *\n * The collector is the central event processing engine in walkerOS:\n * - Receives events from sources\n * - Processes events with consent and context\n * - Routes events to destinations\n * - Manages session state and globals\n * - Handles lifecycle hooks\n *\n * This file defines schemas for collector configuration, commands, and state management.\n */\n\n// ========================================\n// Command Type Schema\n// ========================================\n\n/**\n * CommandType - Walker command identifiers\n *\n * Standard commands:\n * - action: TODO - need documentation\n * - config: Update collector configuration\n * - consent: Update consent state\n * - context: TODO - need documentation\n * - destination: Add/update destination\n * - elb: TODO - need documentation\n * - globals: Update global properties\n * - hook: Register lifecycle hook\n * - init: Initialize collector\n * - link: TODO - need documentation\n * - run: Start/restart collector with state\n * - user: Update user data\n * - walker: TODO - need documentation\n *\n * Extensible: allows custom command strings\n */\nexport const CommandTypeSchema = z\n .union([\n z.enum([\n 'action',\n 'config',\n 'consent',\n 'context',\n 'destination',\n 'elb',\n 'globals',\n 'hook',\n 'init',\n 'link',\n 'run',\n 'user',\n 'walker',\n ]),\n z.string(), // Allow custom commands\n ])\n .describe(\n 'Collector command type: standard commands or custom string for extensions',\n );\n\n// ========================================\n// Configuration Schemas\n// ========================================\n\n/**\n * Config - Core collector configuration\n *\n * Controls collector behavior:\n * - run: Auto-run on initialization\n * - tagging: Version number for event tagging\n * - globalsStatic: Static globals (persist across runs)\n * - sessionStatic: Static session data (persist across runs)\n * - verbose: Enable verbose logging\n * - onError: Error handler\n * - onLog: Log handler\n */\nexport const ConfigSchema = z\n .object({\n run: z\n .boolean()\n .describe('Whether to run collector automatically on initialization')\n .optional(),\n tagging: TaggingVersion,\n globalsStatic: PropertiesSchema.describe(\n 'Static global properties that persist across collector runs',\n ),\n sessionStatic: z\n .record(z.any())\n .describe('Static session data that persists across collector runs'),\n verbose: z.boolean().describe('Enable verbose logging for debugging'),\n // Function handlers\n onError: ErrorHandlerSchema.optional(),\n onLog: LogHandlerSchema.optional(),\n })\n .describe('Core collector configuration');\n\n/**\n * SessionData - Session state management\n *\n * Tracks session-level information:\n * - IDs and lifecycle\n * - Storage state\n * - Marketing tracking\n * - Timestamps\n * - Counters\n *\n * Extends Properties to allow custom session data\n */\nexport const SessionDataSchema = PropertiesSchema.and(\n z.object({\n isStart: z.boolean().describe('Whether this is a new session start'),\n storage: z.boolean().describe('Whether storage is available'),\n id: Identifier.describe('Session identifier').optional(),\n start: Timestamp.describe('Session start timestamp').optional(),\n marketing: z\n .literal(true)\n .optional()\n .describe('Marketing attribution flag'),\n updated: Timestamp.describe('Last update timestamp').optional(),\n isNew: z.boolean().describe('Whether this is a new session').optional(),\n device: Identifier.describe('Device identifier').optional(),\n count: Counter.describe('Event count in session').optional(),\n runs: Counter.describe('Number of runs').optional(),\n }),\n).describe('Session state and tracking data');\n\n/**\n * InitConfig - Initialization configuration\n *\n * Extends Config with initial state:\n * - Initial consent\n * - Initial user data\n * - Initial globals\n * - Source configurations\n * - Destination configurations\n * - Initial custom properties\n */\nexport const InitConfigSchema = ConfigSchema.partial()\n .extend({\n consent: ConsentSchema.optional().describe('Initial consent state'),\n user: UserSchema.optional().describe('Initial user data'),\n globals: PropertiesSchema.optional().describe('Initial global properties'),\n // Sources and destinations are complex runtime objects\n sources: z.any().optional().describe('Source configurations'),\n destinations: z.any().optional().describe('Destination configurations'),\n custom: PropertiesSchema.optional().describe(\n 'Initial custom implementation-specific properties',\n ),\n })\n .describe('Collector initialization configuration with initial state');\n\n// ========================================\n// Context Schemas\n// ========================================\n\n/**\n * PushContext - Context for collector.push\n *\n * Provides source-level mapping configuration\n * Applied before destination-specific mappings\n */\nexport const PushContextSchema = z\n .object({\n mapping: MappingConfigSchema.optional().describe(\n 'Source-level mapping configuration',\n ),\n })\n .describe('Push context with optional source mapping');\n\n// ========================================\n// Collection Schemas\n// ========================================\n\n/**\n * Sources - Map of source IDs to instances\n */\nexport const SourcesSchema = z\n .record(z.string(), z.any())\n .describe('Map of source IDs to source instances');\n\n/**\n * Destinations - Map of destination IDs to instances\n */\nexport const DestinationsSchema = z\n .record(z.string(), z.any())\n .describe('Map of destination IDs to destination instances');\n\n// ========================================\n// Instance Schema\n// ========================================\n\n/**\n * Instance - Collector instance (runtime object)\n *\n * The main collector interface with all state and methods\n *\n * State:\n * - config: Current configuration\n * - consent: Current consent state\n * - user: Current user data\n * - globals: Current global properties\n * - custom: Custom properties\n * - session: Session state\n * - sources: Registered sources\n * - destinations: Registered destinations\n * - hooks: Lifecycle hooks\n * - on: Event lifecycle config\n * - queue: Queued events\n *\n * Flags:\n * - allowed: Processing allowed\n * - count: Event count\n * - round: Collector run count\n * - timing: Processing timing\n * - group: Event grouping ID\n *\n * Methods (not validated):\n * - push: Process events\n * - command: Execute commands\n */\nexport const InstanceSchema = z\n .object({\n // Methods (functions - not validated)\n push: z.any().describe('Push function for processing events'),\n command: z.any().describe('Command function for walker commands'),\n // State\n allowed: z.boolean().describe('Whether event processing is allowed'),\n config: ConfigSchema.describe('Current collector configuration'),\n consent: ConsentSchema.describe('Current consent state'),\n count: z.number().describe('Event count (increments with each event)'),\n custom: PropertiesSchema.describe(\n 'Custom implementation-specific properties',\n ),\n sources: SourcesSchema.describe('Registered source instances'),\n destinations: DestinationsSchema.describe(\n 'Registered destination instances',\n ),\n globals: PropertiesSchema.describe('Current global properties'),\n group: z.string().describe('Event grouping identifier'),\n hooks: z.any().describe('Lifecycle hook functions'),\n on: z.any().describe('Event lifecycle configuration'),\n queue: z.array(EventSchema).describe('Queued events awaiting processing'),\n round: z\n .number()\n .describe('Collector run count (increments with each run)'),\n session: z\n .union([z.undefined(), SessionDataSchema])\n .describe('Current session state'),\n timing: z.number().describe('Event processing timing information'),\n user: UserSchema.describe('Current user data'),\n version: z.string().describe('Walker implementation version'),\n })\n .describe('Collector instance with state and methods');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const commandTypeJsonSchema = zodToJsonSchema(CommandTypeSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'CommandType',\n});\n\nexport const configJsonSchema = zodToJsonSchema(ConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'CollectorConfig',\n});\n\nexport const sessionDataJsonSchema = zodToJsonSchema(SessionDataSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'SessionData',\n});\n\nexport const initConfigJsonSchema = zodToJsonSchema(InitConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'InitConfig',\n});\n\nexport const pushContextJsonSchema = zodToJsonSchema(PushContextSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'CollectorPushContext',\n});\n\nexport const instanceJsonSchema = zodToJsonSchema(InstanceSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'CollectorInstance',\n});\n","import { z } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport { ConfigSchema as MappingConfigSchema } from './mapping';\nimport { Identifier } from './primitives';\nimport { ErrorHandlerSchema } from './utilities';\n\n/**\n * Source Schemas\n *\n * Mirrors: types/source.ts\n * Purpose: Runtime validation and JSON Schema generation for source configurations\n *\n * Sources are the entry points where events enter walkerOS:\n * - Browser sources (DOM events, dataLayer)\n * - Server sources (HTTP handlers, cloud functions)\n * - App sources (mobile, desktop)\n *\n * Sources are platform-agnostic through dependency injection via BaseEnv.\n * All platform-specific dependencies (DOM, HTTP, etc.) are provided through\n * the env object, making sources testable and portable.\n *\n * Key concept: Source.push IS the handler - no wrappers needed\n * Example: http('handler', source.push) for direct deployment\n */\n\n// ========================================\n// Environment Schema\n// ========================================\n\n/**\n * BaseEnv - Base environment interface for dependency injection\n *\n * Sources receive all dependencies through this environment object:\n * - push: Collector push function\n * - command: Collector command function\n * - sources: Other registered sources\n * - elb: Public API function (alias for collector.push)\n *\n * Platform-specific sources extend this with their requirements\n * (e.g., window, document, fetch, req, res)\n *\n * This makes sources:\n * - Platform-agnostic (no direct dependencies)\n * - Testable (mock env for tests)\n * - Composable (share env between sources)\n */\nexport const BaseEnvSchema = z\n .object({\n push: z.any().describe('Collector push function'),\n command: z.any().describe('Collector command function'),\n sources: z.any().optional().describe('Map of registered source instances'),\n elb: z.any().describe('Public API function (alias for collector.push)'),\n })\n .catchall(z.unknown())\n .describe(\n 'Base environment for dependency injection - platform-specific sources extend this',\n );\n\n// ========================================\n// Configuration Schema\n// ========================================\n\n/**\n * Config - Source configuration\n *\n * Extends Mapping.Config with source-specific options:\n * - consent: Required consent to process events\n * - data: Global data transformations\n * - mapping: Entity-action mapping rules\n * - policy: Pre-processing policies\n * - settings: Source-specific settings\n * - env: Environment dependencies\n * - id: Source identifier\n * - onError: Error handler\n * - disabled: Disable source\n * - primary: Primary source flag (only one can be primary)\n *\n * Generic note: settings, env, and mapping can have source-specific types\n */\nexport const ConfigSchema = MappingConfigSchema.extend({\n settings: z\n .any()\n .describe('Implementation-specific configuration')\n .optional(),\n env: BaseEnvSchema.optional().describe(\n 'Environment dependencies (platform-specific)',\n ),\n id: Identifier.describe(\n 'Source identifier (defaults to source key)',\n ).optional(),\n onError: ErrorHandlerSchema.optional(),\n disabled: z.boolean().describe('Set to true to disable').optional(),\n primary: z\n .boolean()\n .describe('Mark as primary (only one can be primary)')\n .optional(),\n}).describe('Source configuration with mapping and environment');\n\n/**\n * PartialConfig - Config with all fields optional\n * Used for config updates and overrides\n */\nexport const PartialConfigSchema = ConfigSchema.deepPartial().describe(\n 'Partial source configuration with all fields deeply optional',\n);\n\n// ========================================\n// Instance Schema\n// ========================================\n\n/**\n * Instance - Source instance (runtime object)\n *\n * Contains:\n * - type: Source type identifier\n * - config: Current configuration\n * - push: Push function (THE HANDLER)\n * - destroy: Cleanup function\n * - on: Lifecycle hook function\n *\n * Key concept: push IS the handler\n * The push function signature is flexible to support different platforms:\n * - Browser: push(event, data) => Promise<void>\n * - HTTP: push(req, res) => Promise<void>\n * - Cloud: push(event, context) => Promise<void>\n *\n * This flexibility allows direct deployment without wrappers:\n * - http.createServer(source.push)\n * - functions.https.onRequest(source.push)\n * - addEventListener('click', source.push)\n */\nexport const InstanceSchema = z\n .object({\n type: z\n .string()\n .describe('Source type identifier (e.g., \"browser\", \"dataLayer\")'),\n config: ConfigSchema.describe('Current source configuration'),\n // Push function - flexible signature, not validated\n push: z\n .any()\n .describe(\n 'Push function - THE HANDLER (flexible signature for platform compatibility)',\n ),\n // Optional lifecycle methods\n destroy: z\n .any()\n .optional()\n .describe('Cleanup function called when source is removed'),\n on: z.any().optional().describe('Lifecycle hook function for event types'),\n })\n .describe('Source instance with push handler and lifecycle methods');\n\n// ========================================\n// Initialization Schemas\n// ========================================\n\n/**\n * Init - Source initialization function\n *\n * Factory function that creates a source instance:\n * (config, env) => Instance | Promise<Instance>\n *\n * Receives:\n * - config: Partial configuration\n * - env: Environment dependencies\n *\n * Returns:\n * - Source instance with push function\n *\n * The init function sets up the source (e.g., attach DOM listeners,\n * start HTTP server, subscribe to events) and returns the instance.\n */\nexport const InitSchema = z\n .any()\n .describe(\n 'Source initialization function: (config, env) => Instance | Promise<Instance>',\n );\n\n/**\n * InitSource - Initialization configuration\n *\n * Contains:\n * - code: Init function\n * - config: Partial config overrides\n * - env: Partial env overrides\n * - primary: Primary source flag\n */\nexport const InitSourceSchema = z\n .object({\n code: InitSchema.describe('Source initialization function'),\n config: PartialConfigSchema.optional().describe(\n 'Partial configuration overrides',\n ),\n env: BaseEnvSchema.partial()\n .optional()\n .describe('Partial environment overrides'),\n primary: z\n .boolean()\n .optional()\n .describe('Mark as primary source (only one can be primary)'),\n })\n .describe('Source initialization configuration');\n\n/**\n * InitSources - Map of source IDs to init configs\n */\nexport const InitSourcesSchema = z\n .record(z.string(), InitSourceSchema)\n .describe('Map of source IDs to initialization configurations');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const baseEnvJsonSchema = zodToJsonSchema(BaseEnvSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'SourceBaseEnv',\n});\n\nexport const configJsonSchema = zodToJsonSchema(ConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'SourceConfig',\n});\n\nexport const partialConfigJsonSchema = zodToJsonSchema(PartialConfigSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'PartialSourceConfig',\n});\n\nexport const instanceJsonSchema = zodToJsonSchema(InstanceSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'SourceInstance',\n});\n\nexport const initSourceJsonSchema = zodToJsonSchema(InitSourceSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'InitSource',\n});\n\nexport const initSourcesJsonSchema = zodToJsonSchema(InitSourcesSchema, {\n target: 'jsonSchema7',\n $refStrategy: 'relative',\n name: 'InitSources',\n});\n","/**\n * JSON Schema type\n */\nexport type JSONSchema = Record<string, unknown>;\n\n/**\n * Schema Builder - DRY utility for creating JSON Schemas\n *\n * This utility allows destinations to define schemas using simple objects,\n * without needing Zod as a dependency. The core package handles conversion.\n *\n * Benefits:\n * - Single source of schema generation logic\n * - No Zod dependency in destination packages\n * - Simple, declarative schema definitions\n * - Type-safe with TypeScript\n * - Follows DRY principle\n *\n * @example\n * // In destination package (NO Zod needed!)\n * import { createObjectSchema, createArraySchema } from '@walkeros/core/schemas';\n *\n * export const settingsSchema = createObjectSchema({\n * pixelId: {\n * type: 'string',\n * required: true,\n * pattern: '^[0-9]+$',\n * description: 'Your Meta Pixel ID',\n * },\n * });\n */\n\n/**\n * Property definition for schema builder\n */\nexport interface PropertyDef {\n type: 'string' | 'number' | 'boolean' | 'object' | 'array';\n required?: boolean;\n description?: string;\n pattern?: string;\n minLength?: number;\n maxLength?: number;\n minimum?: number;\n maximum?: number;\n enum?: readonly string[] | readonly number[];\n properties?: Record<string, PropertyDef>;\n items?: PropertyDef;\n default?: unknown;\n}\n\n/**\n * Create object schema from property definitions\n *\n * @param properties - Property definitions\n * @param title - Optional schema title\n * @returns JSON Schema\n *\n * @example\n * const schema = createObjectSchema({\n * pixelId: {\n * type: 'string',\n * required: true,\n * pattern: '^[0-9]+$',\n * description: 'Your Meta Pixel ID',\n * },\n * eventName: {\n * type: 'string',\n * enum: ['PageView', 'Purchase'],\n * },\n * }, 'Meta Pixel Settings');\n */\nexport function createObjectSchema(\n properties: Record<string, PropertyDef>,\n title?: string,\n): JSONSchema {\n const required: string[] = [];\n const schemaProperties: Record<string, unknown> = {};\n\n for (const [key, def] of Object.entries(properties)) {\n if (def.required) {\n required.push(key);\n }\n\n const property: Record<string, unknown> = {\n type: def.type,\n };\n\n if (def.description) property.description = def.description;\n if (def.pattern) property.pattern = def.pattern;\n if (def.minLength !== undefined) property.minLength = def.minLength;\n if (def.maxLength !== undefined) property.maxLength = def.maxLength;\n if (def.minimum !== undefined) property.minimum = def.minimum;\n if (def.maximum !== undefined) property.maximum = def.maximum;\n if (def.enum) property.enum = [...def.enum];\n if (def.default !== undefined) property.default = def.default;\n\n // Nested object\n if (def.type === 'object' && def.properties) {\n const props: Record<string, unknown> = {};\n for (const [nestedKey, nestedDef] of Object.entries(def.properties)) {\n props[nestedKey] = createPropertySchema(nestedDef);\n }\n property.properties = props;\n }\n\n // Array\n if (def.type === 'array' && def.items) {\n property.items = createPropertySchema(def.items);\n }\n\n schemaProperties[key] = property;\n }\n\n const schema: JSONSchema = {\n type: 'object',\n properties: schemaProperties,\n };\n\n if (title) schema.title = title;\n if (required.length > 0) schema.required = required;\n\n return schema;\n}\n\n/**\n * Create property schema from definition\n * Helper for nested properties\n */\nfunction createPropertySchema(def: PropertyDef): Record<string, unknown> {\n const property: Record<string, unknown> = {\n type: def.type,\n };\n\n if (def.description) property.description = def.description;\n if (def.pattern) property.pattern = def.pattern;\n if (def.minLength !== undefined) property.minLength = def.minLength;\n if (def.maxLength !== undefined) property.maxLength = def.maxLength;\n if (def.minimum !== undefined) property.minimum = def.minimum;\n if (def.maximum !== undefined) property.maximum = def.maximum;\n if (def.enum) property.enum = [...def.enum];\n if (def.default !== undefined) property.default = def.default;\n\n // Nested object\n if (def.type === 'object' && def.properties) {\n const props: Record<string, unknown> = {};\n for (const [key, nestedDef] of Object.entries(def.properties)) {\n props[key] = createPropertySchema(nestedDef);\n }\n property.properties = props;\n }\n\n // Array\n if (def.type === 'array' && def.items) {\n property.items = createPropertySchema(def.items);\n }\n\n return property;\n}\n\n/**\n * Create array schema\n *\n * @param itemDef - Definition for array items\n * @param options - Optional array constraints\n * @returns JSON Schema\n *\n * @example\n * // Simple string array\n * const tagsSchema = createArraySchema({ type: 'string' });\n *\n * // Tuple (loop pattern) - exactly 2 items\n * const loopSchema = createArraySchema(\n * { type: 'object' },\n * { minItems: 2, maxItems: 2 }\n * );\n *\n * // Array with enum\n * const includeSchema = createArraySchema({\n * type: 'string',\n * enum: ['data', 'context', 'globals'],\n * });\n */\nexport function createArraySchema(\n itemDef: PropertyDef,\n options?: {\n minItems?: number;\n maxItems?: number;\n description?: string;\n title?: string;\n },\n): JSONSchema {\n const schema: JSONSchema = {\n type: 'array',\n items: createPropertySchema(itemDef),\n };\n\n if (options?.minItems !== undefined) schema.minItems = options.minItems;\n if (options?.maxItems !== undefined) schema.maxItems = options.maxItems;\n if (options?.description) schema.description = options.description;\n if (options?.title) schema.title = options.title;\n\n return schema;\n}\n\n/**\n * Create enum schema\n *\n * @param values - Allowed values\n * @param type - Value type ('string' or 'number')\n * @param options - Optional constraints\n * @returns JSON Schema\n *\n * @example\n * const eventTypeSchema = createEnumSchema(\n * ['PageView', 'Purchase', 'AddToCart'],\n * 'string',\n * { description: 'Meta Pixel standard event' }\n * );\n */\nexport function createEnumSchema(\n values: readonly string[] | readonly number[],\n type: 'string' | 'number' = 'string',\n options?: {\n description?: string;\n title?: string;\n },\n): JSONSchema {\n const schema: JSONSchema = {\n type,\n enum: [...values],\n };\n\n if (options?.description) schema.description = options.description;\n if (options?.title) schema.title = options.title;\n\n return schema;\n}\n\n/**\n * Create tuple schema (Loop pattern)\n *\n * Creates an array schema with exactly 2 items, which the Explorer\n * type detector recognizes as a \"loop\" pattern.\n *\n * @param firstItem - Definition for first element (source)\n * @param secondItem - Definition for second element (transform)\n * @param description - Optional description\n * @returns JSON Schema with minItems=2, maxItems=2\n *\n * @example\n * const loopSchema = createTupleSchema(\n * { type: 'string' },\n * { type: 'object' },\n * 'Loop: [source, transform]'\n * );\n */\nexport function createTupleSchema(\n firstItem: PropertyDef,\n secondItem: PropertyDef,\n description?: string,\n): JSONSchema {\n return createArraySchema(\n { type: 'object' }, // Generic, items can be different\n {\n minItems: 2,\n maxItems: 2,\n description:\n description || 'Tuple with exactly 2 elements [source, transform]',\n },\n );\n}\n","/**\n * walkerOS Core Schemas\n *\n * Zod schemas for runtime validation and JSON Schema generation.\n * These schemas mirror TypeScript types in packages/core/src/types/\n * and are used for:\n * - Runtime validation at system boundaries (MCP tools, APIs, CLI)\n * - JSON Schema generation for Explorer UI (RJSF)\n * - Documentation and type metadata\n *\n * Note: TypeScript types remain the source of truth for development.\n * Schemas are for runtime validation and tooling support.\n *\n * Organization: Schema files mirror type files\n * - types/walkeros.ts → schemas/walkeros.ts\n * - types/mapping.ts → schemas/mapping.ts\n * - types/destination.ts → schemas/destination.ts\n * - types/collector.ts → schemas/collector.ts\n * - types/source.ts → schemas/source.ts\n * - types/storage.ts + types/handler.ts → schemas/utilities.ts\n *\n * Import strategy:\n * Due to overlapping schema names across domains (ConfigSchema, InstanceSchema, etc.),\n * schemas are organized into namespaces. Import either:\n * 1. From namespaces: import { WalkerOSSchemas, MappingSchemas } from '@walkeros/core/schemas'\n * 2. Direct from files: import { EventSchema } from '@walkeros/core/schemas/walkeros'\n */\n\n// ========================================\n// Primitives & Patterns (DRY building blocks)\n// ========================================\n\nexport * from './primitives';\nexport * from './patterns';\n\n// ========================================\n// Namespace Exports (prevents name collisions)\n// ========================================\n\nimport * as WalkerOSSchemas from './walkeros';\nimport * as MappingSchemas from './mapping';\nimport * as DestinationSchemas from './destination';\nimport * as CollectorSchemas from './collector';\nimport * as SourceSchemas from './source';\nimport * as UtilitySchemas from './utilities';\n\nexport {\n WalkerOSSchemas,\n MappingSchemas,\n DestinationSchemas,\n CollectorSchemas,\n SourceSchemas,\n UtilitySchemas,\n};\n\n// ========================================\n// Direct Exports (commonly used schemas)\n// ========================================\n\n// Export commonly used schemas from WalkerOS namespace directly\nexport {\n EventSchema,\n PartialEventSchema,\n DeepPartialEventSchema,\n PropertiesSchema,\n OrderedPropertiesSchema,\n UserSchema,\n EntitySchema,\n EntitiesSchema,\n ConsentSchema,\n SourceTypeSchema,\n VersionSchema,\n SourceSchema,\n PropertySchema,\n PropertyTypeSchema,\n // JSON Schemas\n eventJsonSchema,\n partialEventJsonSchema,\n userJsonSchema,\n propertiesJsonSchema,\n orderedPropertiesJsonSchema,\n entityJsonSchema,\n sourceTypeJsonSchema,\n consentJsonSchema,\n} from './walkeros';\n\n// Export commonly used schemas from Mapping namespace directly\nexport {\n ValueSchema,\n ValuesSchema,\n ValueConfigSchema,\n LoopSchema,\n SetSchema,\n MapSchema,\n PolicySchema,\n RuleSchema,\n RulesSchema,\n ResultSchema as MappingResultSchema, // Alias to avoid conflict with Destination.ResultSchema\n // JSON Schemas\n valueJsonSchema,\n valueConfigJsonSchema,\n loopJsonSchema,\n setJsonSchema,\n mapJsonSchema,\n policyJsonSchema,\n ruleJsonSchema,\n rulesJsonSchema,\n} from './mapping';\n\n// ========================================\n// Schema Builder - DRY utility for destinations\n// ========================================\n\n/**\n * Schema Builder - DRY utility for destinations\n *\n * Destinations can use these utilities to create JSON Schemas WITHOUT\n * needing Zod as a dependency. The core package handles all schema logic.\n *\n * This follows the DRY principle - write once in core, use everywhere.\n */\nexport * from './schema-builder';\n\n// ========================================\n// Deprecated: value-config.ts\n// ========================================\n\n/**\n * @deprecated Import from MappingSchemas or directly from './mapping' instead\n *\n * The value-config.ts file has been migrated to mapping.ts for better organization.\n * This export is kept for backward compatibility but will be removed in a future version.\n *\n * Migration:\n * - Old: import { ValueSchema, ValueConfigSchema } from '@walkeros/core'\n * - New: import { ValueSchema, ValueConfigSchema } from '@walkeros/core'\n * (imports now come from mapping.ts but the API is identical)\n *\n * Breaking change: The value-config.ts file will be removed in the next major version.\n * All schemas are now organized by domain (mapping, destination, collector, etc.)\n */\n// Note: Schemas are already exported above from mapping.ts\n\n/**\n * Re-export Zod and zod-to-json-schema for destinations\n *\n * Destinations can import Zod from @walkeros/core instead of adding\n * their own dependency. This ensures version consistency and reduces\n * duplicate dependencies in the monorepo.\n *\n * Usage in destinations:\n * import { z, zodToJsonSchema, zodToSchema } from '@walkeros/core';\n */\nexport { z } from 'zod';\nexport { zodToJsonSchema } from 'zod-to-json-schema';\n\nimport type { z as zod } from 'zod';\nimport { zodToJsonSchema as toJsonSchema } from 'zod-to-json-schema';\n\n/**\n * Utility to convert Zod schema to JSON Schema with consistent defaults\n *\n * This wrapper ensures all destinations use the same JSON Schema configuration:\n * - target: 'jsonSchema7' (JSON Schema Draft 7 format)\n * - $refStrategy: 'none' (inline all references, no $ref pointers)\n *\n * Usage in destinations:\n * import { zodToSchema } from '@walkeros/core';\n * export const settings = zodToSchema(SettingsSchema);\n */\nexport function zodToSchema(schema: zod.ZodTypeAny) {\n return toJsonSchema(schema, {\n target: 'jsonSchema7',\n $refStrategy: 'none',\n });\n}\n","/**\n * Anonymizes an IPv4 address by setting the last octet to 0.\n *\n * @param ip The IP address to anonymize.\n * @returns The anonymized IP address or an empty string if the IP is invalid.\n */\nexport function anonymizeIP(ip: string): string {\n const ipv4Pattern = /^(?:\\d{1,3}\\.){3}\\d{1,3}$/;\n\n if (!ipv4Pattern.test(ip)) return '';\n\n return ip.replace(/\\.\\d+$/, '.0'); // Set the last octet to 0\n}\n","/**\n * @interface Assign\n * @description Options for the assign function.\n * @property merge - Merge array properties instead of overriding them.\n * @property shallow - Create a shallow copy instead of updating the target object.\n * @property extend - Extend the target with new properties instead of only updating existing ones.\n */\ninterface Assign {\n merge?: boolean;\n shallow?: boolean;\n extend?: boolean;\n}\n\nconst defaultOptions: Assign = {\n merge: true,\n shallow: true,\n extend: true,\n};\n\n/**\n * Merges objects with advanced options.\n *\n * @template T, U\n * @param target - The target object to merge into.\n * @param obj - The source object to merge from.\n * @param options - Options for merging.\n * @returns The merged object.\n */\nexport function assign<T extends object, U extends object>(\n target: T,\n obj: U = {} as U,\n options: Assign = {},\n): T & U {\n options = { ...defaultOptions, ...options };\n\n const finalObj = Object.entries(obj).reduce((acc, [key, sourceProp]) => {\n const targetProp = target[key as keyof typeof target];\n\n // Only merge arrays\n if (\n options.merge &&\n Array.isArray(targetProp) &&\n Array.isArray(sourceProp)\n ) {\n acc[key as keyof typeof acc] = sourceProp.reduce(\n (acc, item) => {\n // Remove duplicates\n return acc.includes(item) ? acc : [...acc, item];\n },\n [...targetProp],\n );\n } else if (options.extend || key in target) {\n // Extend the target with new properties or update existing ones\n acc[key as keyof typeof acc] = sourceProp;\n }\n\n return acc;\n }, {} as U);\n\n // Handle shallow or deep copy based on options\n if (options.shallow) {\n return { ...target, ...finalObj };\n } else {\n Object.assign(target, finalObj);\n return target as T & U;\n }\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Checks if a value is an arguments object.\n *\n * @param value The value to check.\n * @returns True if the value is an arguments object, false otherwise.\n */\nexport function isArguments(value: unknown): value is IArguments {\n return Object.prototype.toString.call(value) === '[object Arguments]';\n}\n\n/**\n * Checks if a value is an array.\n *\n * @param value The value to check.\n * @returns True if the value is an array, false otherwise.\n */\nexport function isArray<T>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value The value to check.\n * @returns True if the value is a boolean, false otherwise.\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if an entity is a walker command.\n *\n * @param entity The entity to check.\n * @returns True if the entity is a walker command, false otherwise.\n */\nexport function isCommand(entity: string) {\n return entity === 'walker';\n}\n\n/**\n * Checks if a value is defined.\n *\n * @param value The value to check.\n * @returns True if the value is defined, false otherwise.\n */\nexport function isDefined<T>(val: T | undefined): val is T {\n return typeof val !== 'undefined';\n}\n\n/**\n * Checks if a value is an element or the document.\n *\n * @param elem The value to check.\n * @returns True if the value is an element or the document, false otherwise.\n */\nexport function isElementOrDocument(elem: unknown): elem is Element {\n return elem === document || elem instanceof Element;\n}\n\n/**\n * Checks if a value is a function.\n *\n * @param value The value to check.\n * @returns True if the value is a function, false otherwise.\n */\nexport function isFunction(value: unknown): value is Function {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a number.\n *\n * @param value The value to check.\n * @returns True if the value is a number, false otherwise.\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value);\n}\n\n/**\n * Checks if a value is an object.\n *\n * @param value The value to check.\n * @returns True if the value is an object, false otherwise.\n */\nexport function isObject(value: unknown): value is WalkerOS.AnyObject {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isArray(value) &&\n Object.prototype.toString.call(value) === '[object Object]'\n );\n}\n\n/**\n * Checks if two variables have the same type.\n *\n * @param variable The first variable.\n * @param type The second variable.\n * @returns True if the variables have the same type, false otherwise.\n */\nexport function isSameType<T>(\n variable: unknown,\n type: T,\n): variable is typeof type {\n return typeof variable === typeof type;\n}\n\n/**\n * Checks if a value is a string.\n *\n * @param value The value to check.\n * @returns True if the value is a string, false otherwise.\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n","/**\n * Creates a deep clone of a value.\n * Supports primitive values, objects, arrays, dates, and regular expressions.\n * Handles circular references.\n *\n * @template T\n * @param org - The value to clone.\n * @param visited - A map of visited objects to handle circular references.\n * @returns The cloned value.\n */\nexport function clone<T>(\n org: T,\n visited: WeakMap<object, unknown> = new WeakMap(),\n): T {\n // Handle primitive values and functions directly\n if (typeof org !== 'object' || org === null) return org;\n\n // Check for circular references\n if (visited.has(org)) return visited.get(org) as T;\n\n // Allow list of clonable types\n const type = Object.prototype.toString.call(org);\n if (type === '[object Object]') {\n const clonedObj = {} as Record<string | symbol, unknown>;\n visited.set(org as object, clonedObj); // Remember the reference\n\n for (const key in org as Record<string | symbol, unknown>) {\n if (Object.prototype.hasOwnProperty.call(org, key)) {\n clonedObj[key] = clone(\n (org as Record<string | symbol, unknown>)[key],\n visited,\n );\n }\n }\n return clonedObj as T;\n }\n\n if (type === '[object Array]') {\n const clonedArray = [] as unknown[];\n visited.set(org as object, clonedArray); // Remember the reference\n\n (org as unknown[]).forEach((item) => {\n clonedArray.push(clone(item, visited));\n });\n\n return clonedArray as T;\n }\n\n if (type === '[object Date]') {\n return new Date((org as unknown as Date).getTime()) as T;\n }\n\n if (type === '[object RegExp]') {\n const reg = org as unknown as RegExp;\n return new RegExp(reg.source, reg.flags) as T;\n }\n\n // Skip cloning for unsupported types and return reference\n return org;\n}\n","import type { WalkerOS } from './types';\nimport { isArray, isDefined, isObject } from './is';\nimport { clone } from './clone';\n\n/**\n * Gets a value from an object by a dot-notation string.\n * Supports wildcards for arrays.\n *\n * @example\n * getByPath({ data: { id: 1 } }, \"data.id\") // Returns 1\n *\n * @param event - The object to get the value from.\n * @param key - The dot-notation string.\n * @param defaultValue - The default value to return if the key is not found.\n * @returns The value from the object or the default value.\n */\nexport function getByPath(\n event: unknown,\n key: string = '',\n defaultValue?: unknown,\n): unknown {\n const keys = key.split('.');\n let values: unknown = event;\n\n for (let index = 0; index < keys.length; index++) {\n const k = keys[index];\n\n if (k === '*' && isArray(values)) {\n const remainingKeys = keys.slice(index + 1).join('.');\n const result: unknown[] = [];\n\n for (const item of values) {\n const value = getByPath(item, remainingKeys, defaultValue);\n result.push(value);\n }\n\n return result;\n }\n\n values =\n values instanceof Object ? values[k as keyof typeof values] : undefined;\n\n if (!values) break;\n }\n\n return isDefined(values) ? values : defaultValue;\n}\n\n/**\n * Sets a value in an object by a dot-notation string.\n *\n * @param obj - The object to set the value in.\n * @param key - The dot-notation string.\n * @param value - The value to set.\n * @returns A new object with the updated value.\n */\nexport function setByPath<T = unknown>(obj: T, key: string, value: unknown): T {\n if (!isObject(obj)) return obj;\n\n const clonedObj = clone(obj);\n const keys = key.split('.');\n let current: WalkerOS.AnyObject = clonedObj;\n\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i] as keyof typeof current;\n\n // Set the value if it's the last key\n if (i === keys.length - 1) {\n current[k] = value;\n } else {\n // Traverse to the next level\n if (\n !(k in current) ||\n typeof current[k] !== 'object' ||\n current[k] === null\n ) {\n current[k] = {};\n }\n\n // Move deeper into the object\n current = current[k] as WalkerOS.AnyObject;\n }\n }\n\n return clonedObj as T;\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Casts a value to a specific type.\n *\n * @param value The value to cast.\n * @returns The casted value.\n */\nexport function castValue(value: unknown): WalkerOS.PropertyType {\n if (value === 'true') return true;\n if (value === 'false') return false;\n\n const number = Number(value); // Converts \"\" to 0\n if (value == number && value !== '') return number;\n\n return String(value);\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Checks if the required consent is granted.\n *\n * @param required - The required consent states.\n * @param state - The current consent states.\n * @param individual - Individual consent states to prioritize.\n * @returns The granted consent states or false if not granted.\n */\nexport function getGrantedConsent(\n required: WalkerOS.Consent | undefined,\n state: WalkerOS.Consent = {},\n individual: WalkerOS.Consent = {},\n): false | WalkerOS.Consent {\n // Merge state and individual, prioritizing individual states\n const states: WalkerOS.Consent = { ...state, ...individual };\n\n const grantedStates: WalkerOS.Consent = {};\n let hasRequiredConsent = required === undefined;\n\n Object.keys(states).forEach((name) => {\n if (states[name]) {\n // consent granted\n grantedStates[name] = true;\n\n // Check if it's required and granted consent\n if (required && required[name]) hasRequiredConsent = true;\n }\n });\n\n return hasRequiredConsent ? grantedStates : false;\n}\n","import type { Destination } from './types';\nimport type { TypesOf, Config } from './types/destination';\nimport { assign } from './assign';\n\n/**\n * Creates a new destination instance by merging a base destination with additional configuration.\n *\n * This utility enables elegant destination configuration while avoiding config side-effects\n * that could occur when reusing destination objects across multiple collector instances.\n *\n * @param baseDestination - The base destination to extend\n * @param config - Additional configuration to merge with the base destination's config\n * @returns A new destination instance with merged configuration\n *\n * @example\n * ```typescript\n * // Types are inferred automatically from destinationGtag\n * elb('walker destination', createDestination(destinationGtag, {\n * settings: { ga4: { measurementId: 'G-123' } }\n * }));\n * ```\n */\nexport function createDestination<I extends Destination.Instance>(\n baseDestination: I,\n config: Partial<Config<TypesOf<I>>>,\n): I {\n // Create a shallow copy of the base destination to avoid mutations\n const newDestination = { ...baseDestination };\n\n // Deep merge the config, handling nested objects like settings and mapping\n newDestination.config = assign(baseDestination.config, config, {\n shallow: true, // Create new object, don't mutate original\n merge: true, // Merge arrays\n extend: true, // Allow new properties\n });\n\n // Handle nested settings merging if both have settings\n if (baseDestination.config.settings && config.settings) {\n newDestination.config.settings = assign(\n baseDestination.config.settings as object,\n config.settings as object,\n { shallow: true, merge: true, extend: true },\n ) as typeof newDestination.config.settings;\n }\n\n // Handle nested mapping merging if both have mapping\n if (baseDestination.config.mapping && config.mapping) {\n newDestination.config.mapping = assign(\n baseDestination.config.mapping as object,\n config.mapping as object,\n { shallow: true, merge: true, extend: true },\n ) as typeof newDestination.config.mapping;\n }\n\n return newDestination;\n}\n","import type { WalkerOS } from './types';\nimport { assign } from './assign';\n\ndeclare const __VERSION__: string;\n\n/**\n * Creates a complete event with default values.\n * Used for testing and debugging.\n *\n * @param props - Properties to override the default values.\n * @returns A complete event.\n */\nexport function createEvent(\n props: WalkerOS.DeepPartialEvent = {},\n): WalkerOS.Event {\n const timestamp = props.timestamp || new Date().setHours(0, 13, 37, 0);\n const group = props.group || 'gr0up';\n const count = props.count || 1;\n const id = `${timestamp}-${group}-${count}`;\n\n const defaultEvent: WalkerOS.Event = {\n name: 'entity action',\n data: {\n string: 'foo',\n number: 1,\n boolean: true,\n array: [0, 'text', false],\n not: undefined,\n },\n context: { dev: ['test', 1] },\n globals: { lang: 'elb' },\n custom: { completely: 'random' },\n user: { id: 'us3r', device: 'c00k13', session: 's3ss10n' },\n nested: [\n {\n entity: 'child',\n data: { is: 'subordinated' },\n nested: [],\n context: { element: ['child', 0] },\n },\n ],\n consent: { functional: true },\n id,\n trigger: 'test',\n entity: 'entity',\n action: 'action',\n timestamp,\n timing: 3.14,\n group,\n count,\n version: {\n source: __VERSION__,\n tagging: 1,\n },\n source: {\n type: 'web',\n id: 'https://localhost:80',\n previous_id: 'http://remotehost:9001',\n },\n };\n\n // Note: Always prefer the props over the defaults\n\n // Merge properties\n const event = assign(defaultEvent, props, { merge: false });\n\n // Update conditions\n\n // Entity and action from event\n if (props.name) {\n const [entity, action] = props.name.split(' ') ?? [];\n\n if (entity && action) {\n event.entity = entity;\n event.action = action;\n }\n }\n\n return event;\n}\n\n/**\n * Creates a complete event with default values based on the event name.\n * Used for testing and debugging.\n *\n * @param name - The name of the event to create.\n * @param props - Properties to override the default values.\n * @returns A complete event.\n */\nexport function getEvent(\n name: string = 'entity action',\n props: WalkerOS.DeepPartialEvent = {},\n): WalkerOS.Event {\n const timestamp = props.timestamp || new Date().setHours(0, 13, 37, 0);\n\n const quantity = 2;\n const product1 = {\n data: {\n id: 'ers',\n name: 'Everyday Ruck Snack',\n color: 'black',\n size: 'l',\n price: 420,\n },\n };\n const product2 = {\n data: {\n id: 'cc',\n name: 'Cool Cap',\n size: 'one size',\n price: 42,\n },\n };\n\n const defaultEvents: Record<string, WalkerOS.PartialEvent> = {\n 'cart view': {\n data: {\n currency: 'EUR',\n value: product1.data.price * quantity,\n },\n context: { shopping: ['cart', 0] },\n globals: { pagegroup: 'shop' },\n nested: [\n {\n entity: 'product',\n data: { ...product1.data, quantity },\n context: { shopping: ['cart', 0] },\n nested: [],\n },\n ],\n trigger: 'load',\n },\n 'checkout view': {\n data: {\n step: 'payment',\n currency: 'EUR',\n value: product1.data.price + product2.data.price,\n },\n context: { shopping: ['checkout', 0] },\n globals: { pagegroup: 'shop' },\n nested: [\n {\n entity: 'product',\n ...product1,\n context: { shopping: ['checkout', 0] },\n nested: [],\n },\n {\n entity: 'product',\n ...product2,\n context: { shopping: ['checkout', 0] },\n nested: [],\n },\n ],\n trigger: 'load',\n },\n 'order complete': {\n data: {\n id: '0rd3r1d',\n currency: 'EUR',\n shipping: 5.22,\n taxes: 73.76,\n total: 555,\n },\n context: { shopping: ['complete', 0] },\n globals: { pagegroup: 'shop' },\n nested: [\n {\n entity: 'product',\n ...product1,\n context: { shopping: ['complete', 0] },\n nested: [],\n },\n {\n entity: 'product',\n ...product2,\n context: { shopping: ['complete', 0] },\n nested: [],\n },\n {\n entity: 'gift',\n data: {\n name: 'Surprise',\n },\n context: { shopping: ['complete', 0] },\n nested: [],\n },\n ],\n trigger: 'load',\n },\n 'page view': {\n data: {\n domain: 'www.example.com',\n title: 'walkerOS documentation',\n referrer: 'https://www.elbwalker.com/',\n search: '?foo=bar',\n hash: '#hash',\n id: '/docs/',\n },\n globals: { pagegroup: 'docs' },\n trigger: 'load',\n },\n 'product add': {\n ...product1,\n context: { shopping: ['intent', 0] },\n globals: { pagegroup: 'shop' },\n nested: [],\n trigger: 'click',\n },\n 'product view': {\n ...product1,\n context: { shopping: ['detail', 0] },\n globals: { pagegroup: 'shop' },\n nested: [],\n trigger: 'load',\n },\n 'product visible': {\n data: { ...product1.data, position: 3, promo: true },\n context: { shopping: ['discover', 0] },\n globals: { pagegroup: 'shop' },\n nested: [],\n trigger: 'load',\n },\n 'promotion visible': {\n data: {\n name: 'Setting up tracking easily',\n position: 'hero',\n },\n context: { ab_test: ['engagement', 0] },\n globals: { pagegroup: 'homepage' },\n trigger: 'visible',\n },\n 'session start': {\n data: {\n id: 's3ss10n',\n start: timestamp,\n isNew: true,\n count: 1,\n runs: 1,\n isStart: true,\n storage: true,\n referrer: '',\n device: 'c00k13',\n },\n user: {\n id: 'us3r',\n device: 'c00k13',\n session: 's3ss10n',\n hash: 'h4sh',\n address: 'street number',\n email: 'user@example.com',\n phone: '+49 123 456 789',\n userAgent: 'Mozilla...',\n browser: 'Chrome',\n browserVersion: '90',\n deviceType: 'desktop',\n language: 'de-DE',\n country: 'DE',\n region: 'HH',\n city: 'Hamburg',\n zip: '20354',\n timezone: 'Berlin',\n os: 'walkerOS',\n osVersion: '1.0',\n screenSize: '1337x420',\n ip: '127.0.0.0',\n internal: true,\n custom: 'value',\n },\n },\n };\n\n return createEvent({ ...defaultEvents[name], ...props, name: name });\n}\n","/**\n * Generates a random string of a given length.\n *\n * @param length - The length of the random string.\n * @returns The random string.\n */\nexport function getId(length = 6): string {\n let str = '';\n for (let l = 36; str.length < length; )\n str += ((Math.random() * l) | 0).toString(l);\n return str;\n}\n","import type { WalkerOS } from './types';\nimport { assign } from './assign';\n\nexport interface MarketingParameters {\n [key: string]: string;\n}\n\n/**\n * Extracts marketing parameters from a URL.\n *\n * @param url - The URL to extract the parameters from.\n * @param custom - Custom marketing parameters to extract.\n * @returns The extracted marketing parameters.\n */\nexport function getMarketingParameters(\n url: URL,\n custom: MarketingParameters = {},\n): WalkerOS.Properties {\n const clickId = 'clickId';\n const data: WalkerOS.Properties = {};\n const parameters: MarketingParameters = {\n utm_campaign: 'campaign',\n utm_content: 'content',\n utm_medium: 'medium',\n utm_source: 'source',\n utm_term: 'term',\n dclid: clickId,\n fbclid: clickId,\n gclid: clickId,\n msclkid: clickId,\n ttclid: clickId,\n twclid: clickId,\n igshid: clickId,\n sclid: clickId,\n };\n\n Object.entries(assign(parameters, custom)).forEach(([key, name]) => {\n const param = url.searchParams.get(key); // Search for the parameter in the URL\n if (param) {\n if (name === clickId) {\n name = key;\n data[clickId] = key; // Reference the clickId parameter\n }\n\n data[name] = param;\n }\n });\n\n return data;\n}\n","/**\n * Creates a debounced function that delays invoking `fn` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `fn` invocations and a `flush` method to immediately invoke them.\n *\n * @template P, R\n * @param fn The function to debounce.\n * @param wait The number of milliseconds to delay.\n * @param immediate Trigger the function on the leading edge, instead of the trailing.\n * @returns The new debounced function.\n */\nexport function debounce<P extends unknown[], R>(\n fn: (...args: P) => R,\n wait = 1000,\n immediate = false,\n) {\n let timer: number | NodeJS.Timeout | null = null;\n let result: R;\n let hasCalledImmediately = false;\n\n return (...args: P): Promise<R> => {\n // Return value as promise\n return new Promise((resolve) => {\n const callNow = immediate && !hasCalledImmediately;\n\n // abort previous invocation\n if (timer) clearTimeout(timer);\n\n timer = setTimeout(() => {\n timer = null;\n if (!immediate || hasCalledImmediately) {\n result = fn(...args);\n resolve(result);\n }\n }, wait);\n\n if (callNow) {\n hasCalledImmediately = true;\n result = fn(...args);\n resolve(result);\n }\n });\n };\n}\n\n/**\n * Creates a throttled function that only invokes `fn` at most once per\n * every `delay` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `fn` invocations and a `flush` method to\n * immediately invoke them.\n *\n * @template P, R\n * @param fn The function to throttle.\n * @param delay The number of milliseconds to throttle invocations to.\n * @returns The new throttled function.\n */\n\ntype Timeout = ReturnType<typeof setTimeout>;\nexport function throttle<P extends unknown[], R>(\n fn: (...args: P) => R | undefined,\n delay = 1000,\n): (...args: P) => R | undefined {\n let isBlocked: Timeout | null = null;\n\n return function (...args: P): R | undefined {\n // Skip since function is still blocked by previous call\n if (isBlocked !== null) return;\n\n // Set a blocking timeout\n isBlocked = setTimeout(() => {\n // Unblock function\n isBlocked = null;\n }, delay) as Timeout;\n\n // Call the function\n return fn(...args);\n };\n}\n","import type { WalkerOS } from './types';\nimport {\n isArguments,\n isArray,\n isBoolean,\n isDefined,\n isNumber,\n isObject,\n isString,\n} from './is';\n\n/**\n * Checks if a value is a valid property type.\n *\n * @param value The value to check.\n * @returns True if the value is a valid property type, false otherwise.\n */\nexport function isPropertyType(value: unknown): value is WalkerOS.PropertyType {\n return (\n isBoolean(value) ||\n isString(value) ||\n isNumber(value) ||\n !isDefined(value) ||\n (isArray(value) && value.every(isPropertyType)) ||\n (isObject(value) && Object.values(value).every(isPropertyType))\n );\n}\n\n/**\n * Filters a value to only include valid property types.\n *\n * @param value The value to filter.\n * @returns The filtered value or undefined.\n */\nexport function filterValues(value: unknown): WalkerOS.Property | undefined {\n if (isBoolean(value) || isString(value) || isNumber(value)) return value;\n\n if (isArguments(value)) return filterValues(Array.from(value));\n\n if (isArray(value)) {\n return value\n .map((item) => filterValues(item))\n .filter((item): item is WalkerOS.PropertyType => item !== undefined);\n }\n\n if (isObject(value)) {\n return Object.entries(value).reduce<Record<string, WalkerOS.Property>>(\n (acc, [key, val]) => {\n const filteredValue = filterValues(val);\n if (filteredValue !== undefined) acc[key] = filteredValue;\n return acc;\n },\n {},\n );\n }\n\n return;\n}\n\n/**\n * Casts a value to a valid property type.\n *\n * @param value The value to cast.\n * @returns The casted value or undefined.\n */\nexport function castToProperty(value: unknown): WalkerOS.Property | undefined {\n return isPropertyType(value) ? value : undefined;\n}\n","/**\n * A utility function that wraps a function in a try-catch block.\n *\n * @template P, R, S\n * @param fn The function to wrap.\n * @param onError A function to call when an error is caught.\n * @param onFinally A function to call in the finally block.\n * @returns The wrapped function.\n */\n// Use function overload to support different return type depending on onError\n// Types\nexport function tryCatch<P extends unknown[], R, S>(\n fn: (...args: P) => R | undefined,\n onError: (err: unknown) => S,\n onFinally?: () => void,\n): (...args: P) => R | S;\nexport function tryCatch<P extends unknown[], R>(\n fn: (...args: P) => R | undefined,\n onError?: undefined,\n onFinally?: () => void,\n): (...args: P) => R | undefined;\n// Implementation\nexport function tryCatch<P extends unknown[], R, S>(\n fn: (...args: P) => R | undefined,\n onError?: (err: unknown) => S,\n onFinally?: () => void,\n): (...args: P) => R | S | undefined {\n return function (...args: P): R | S | undefined {\n try {\n return fn(...args);\n } catch (err) {\n if (!onError) return;\n return onError(err);\n } finally {\n onFinally?.();\n }\n };\n}\n\n/**\n * A utility function that wraps an async function in a try-catch block.\n *\n * @template P, R, S\n * @param fn The async function to wrap.\n * @param onError A function to call when an error is caught.\n * @param onFinally A function to call in the finally block.\n * @returns The wrapped async function.\n */\n// Use function overload to support different return type depending on onError\n// Types\nexport function tryCatchAsync<P extends unknown[], R, S>(\n fn: (...args: P) => R,\n onError: (err: unknown) => S,\n onFinally?: () => void | Promise<void>,\n): (...args: P) => Promise<R | S>;\nexport function tryCatchAsync<P extends unknown[], R>(\n fn: (...args: P) => R,\n onError?: undefined,\n onFinally?: () => void | Promise<void>,\n): (...args: P) => Promise<R | undefined>;\n// Implementation\nexport function tryCatchAsync<P extends unknown[], R, S>(\n fn: (...args: P) => R,\n onError?: (err: unknown) => S,\n onFinally?: () => void | Promise<void>,\n): (...args: P) => Promise<R | S | undefined> {\n return async function (...args: P): Promise<R | S | undefined> {\n try {\n return await fn(...args);\n } catch (err) {\n if (!onError) return;\n return await onError(err);\n } finally {\n await onFinally?.();\n }\n };\n}\n","import type { Mapping, WalkerOS, Collector } from './types';\nimport { getByPath, setByPath } from './byPath';\nimport { isArray, isDefined, isString, isObject } from './is';\nimport { castToProperty } from './property';\nimport { tryCatchAsync } from './tryCatch';\nimport { getGrantedConsent } from './consent';\nimport { assign } from './assign';\n\n/**\n * Gets the mapping for an event.\n *\n * @param event The event to get the mapping for (can be partial or full).\n * @param mapping The mapping rules.\n * @returns The mapping result.\n */\nexport async function getMappingEvent(\n event: WalkerOS.DeepPartialEvent | WalkerOS.PartialEvent | WalkerOS.Event,\n mapping?: Mapping.Rules,\n): Promise<Mapping.Result> {\n const [entity, action] = (event.name || '').split(' ');\n if (!mapping || !entity || !action) return {};\n\n let eventMapping: Mapping.Rule | undefined;\n let mappingKey = '';\n let entityKey = entity;\n let actionKey = action;\n\n const resolveEventMapping = (\n eventMapping?: Mapping.Rule | Mapping.Rule[],\n ) => {\n if (!eventMapping) return;\n eventMapping = isArray(eventMapping) ? eventMapping : [eventMapping];\n\n return eventMapping.find(\n (eventMapping) =>\n !eventMapping.condition || eventMapping.condition(event),\n );\n };\n\n if (!mapping[entityKey]) entityKey = '*';\n const entityMapping = mapping[entityKey];\n\n if (entityMapping) {\n if (!entityMapping[actionKey]) actionKey = '*';\n eventMapping = resolveEventMapping(entityMapping[actionKey]);\n }\n\n // Fallback to * *\n if (!eventMapping) {\n entityKey = '*';\n actionKey = '*';\n eventMapping = resolveEventMapping(mapping[entityKey]?.[actionKey]);\n }\n\n if (eventMapping) mappingKey = `${entityKey} ${actionKey}`;\n\n return { eventMapping, mappingKey };\n}\n\n/**\n * Gets a value from a mapping.\n *\n * @param value The value to get the mapping from.\n * @param data The mapping data.\n * @param options The mapping options.\n * @returns The mapped value.\n */\nexport async function getMappingValue(\n value: WalkerOS.DeepPartialEvent | unknown | undefined,\n data: Mapping.Data = {},\n options: Mapping.Options = {},\n): Promise<WalkerOS.Property | undefined> {\n if (!isDefined(value)) return;\n\n // Get consent state in priority order: value.consent > options.consent > collector?.consent\n const consentState =\n ((isObject(value) && value.consent) as WalkerOS.Consent) ||\n options.consent ||\n options.collector?.consent;\n\n const mappings = isArray(data) ? data : [data];\n\n for (const mapping of mappings) {\n const result = await tryCatchAsync(processMappingValue)(value, mapping, {\n ...options,\n consent: consentState,\n });\n if (isDefined(result)) return result;\n }\n\n return;\n}\n\nasync function processMappingValue(\n value: WalkerOS.DeepPartialEvent | unknown,\n mapping: Mapping.Value,\n options: Mapping.Options = {},\n): Promise<WalkerOS.Property | undefined> {\n const { collector, consent: consentState } = options;\n\n // Ensure mapping is an array for uniform processing\n const mappings = isArray(mapping) ? mapping : [mapping];\n\n // Loop over each mapping and return the first valid result\n return mappings.reduce(\n async (accPromise, mappingItem) => {\n const acc = await accPromise;\n if (acc) return acc; // A valid result was already found\n\n const mapping = isString(mappingItem)\n ? { key: mappingItem }\n : mappingItem;\n\n if (!Object.keys(mapping).length) return;\n\n const {\n condition,\n consent,\n fn,\n key,\n loop,\n map,\n set,\n validate,\n value: staticValue,\n } = mapping;\n\n // Check if this mapping should be used\n if (\n condition &&\n !(await tryCatchAsync(condition)(value, mappingItem, collector))\n )\n return;\n\n // Check if consent is required and granted\n if (consent && !getGrantedConsent(consent, consentState))\n return staticValue;\n\n let mappingValue: unknown = isDefined(staticValue) ? staticValue : value;\n\n // Use a custom function to get the value\n if (fn) {\n mappingValue = await tryCatchAsync(fn)(value, mappingItem, options);\n }\n\n // Get dynamic value from the event\n if (key) {\n mappingValue = getByPath(value, key, staticValue);\n }\n\n if (loop) {\n const [scope, itemMapping] = loop;\n\n const data =\n scope === 'this'\n ? [value]\n : await getMappingValue(value, scope, options);\n\n if (isArray(data)) {\n mappingValue = (\n await Promise.all(\n data.map((item) => getMappingValue(item, itemMapping, options)),\n )\n ).filter(isDefined);\n }\n } else if (map) {\n mappingValue = await Object.entries(map).reduce(\n async (mappedObjPromise, [mapKey, mapValue]) => {\n const mappedObj = await mappedObjPromise;\n const result = await getMappingValue(value, mapValue, options);\n if (isDefined(result)) mappedObj[mapKey] = result;\n return mappedObj;\n },\n Promise.resolve({} as WalkerOS.AnyObject),\n );\n } else if (set) {\n mappingValue = await Promise.all(\n set.map((item) => processMappingValue(value, item, options)),\n );\n }\n\n // Validate the value\n if (validate && !(await tryCatchAsync(validate)(mappingValue)))\n mappingValue = undefined;\n\n const property = castToProperty(mappingValue);\n\n // Finally, check and convert the type\n return isDefined(property) ? property : castToProperty(staticValue); // Always use value as a fallback\n },\n Promise.resolve(undefined as WalkerOS.Property | undefined),\n );\n}\n\n/**\n * Processes an event through mapping configuration.\n *\n * This is the unified mapping logic used by both sources and destinations.\n * It applies transformations in this order:\n * 1. Config-level policy - modifies the event itself (global rules)\n * 2. Mapping rules - finds matching rule based on entity-action\n * 3. Event-level policy - modifies the event based on specific mapping rule\n * 4. Data transformation - creates context data\n * 5. Ignore check and name override\n *\n * Sources can pass partial events, destinations pass full events.\n * getMappingValue works with both partial and full events.\n *\n * @param event - The event to process (can be partial or full, will be mutated by policies)\n * @param config - Mapping configuration (mapping, data, policy, consent)\n * @param collector - Collector instance for context\n * @returns Object with transformed event, data, mapping rule, and ignore flag\n */\nexport async function processEventMapping<\n T extends WalkerOS.DeepPartialEvent | WalkerOS.Event,\n>(\n event: T,\n config: Mapping.Config,\n collector: Collector.Instance,\n): Promise<{\n event: T;\n data?: WalkerOS.Property;\n mapping?: Mapping.Rule;\n mappingKey?: string;\n ignore: boolean;\n}> {\n // Step 1: Apply config-level policy (modifies event)\n if (config.policy) {\n await Promise.all(\n Object.entries(config.policy).map(async ([key, mapping]) => {\n const value = await getMappingValue(event, mapping, { collector });\n event = setByPath(event, key, value);\n }),\n );\n }\n\n // Step 2: Get event mapping rule\n const { eventMapping, mappingKey } = await getMappingEvent(\n event,\n config.mapping,\n );\n\n // Step 2.5: Apply event-level policy (modifies event)\n if (eventMapping?.policy) {\n await Promise.all(\n Object.entries(eventMapping.policy).map(async ([key, mapping]) => {\n const value = await getMappingValue(event, mapping, { collector });\n event = setByPath(event, key, value);\n }),\n );\n }\n\n // Step 3: Transform global data\n let data =\n config.data && (await getMappingValue(event, config.data, { collector }));\n\n if (eventMapping) {\n // Check if event should be ignored\n if (eventMapping.ignore) {\n return { event, data, mapping: eventMapping, mappingKey, ignore: true };\n }\n\n // Override event name if specified\n if (eventMapping.name) event.name = eventMapping.name;\n\n // Transform event-specific data\n if (eventMapping.data) {\n const dataEvent =\n eventMapping.data &&\n (await getMappingValue(event, eventMapping.data, { collector }));\n data =\n isObject(data) && isObject(dataEvent) // Only merge objects\n ? assign(data, dataEvent)\n : dataEvent;\n }\n }\n\n return { event, data, mapping: eventMapping, mappingKey, ignore: false };\n}\n","/**\n * Environment mocking utilities for walkerOS destinations\n *\n * Provides standardized tools for intercepting function calls in environment objects,\n * enabling consistent testing patterns across all destinations.\n */\n\ntype InterceptorFn = (\n path: string[],\n args: unknown[],\n original?: Function,\n) => unknown;\n\n/**\n * Creates a proxied environment that intercepts function calls\n *\n * Uses Proxy to wrap environment objects and capture all function calls,\n * allowing for call recording, mocking, or simulation.\n *\n * @param env - The environment object to wrap\n * @param interceptor - Function called for each intercepted call\n * @returns Proxied environment with interceptor applied\n *\n * @example\n * ```typescript\n * const calls: Array<{ path: string[]; args: unknown[] }> = [];\n *\n * const testEnv = mockEnv(env.push, (path, args) => {\n * calls.push({ path, args });\n * });\n *\n * // Use testEnv with destination\n * await destination.push(event, { env: testEnv });\n *\n * // Analyze captured calls\n * expect(calls).toContainEqual({\n * path: ['window', 'gtag'],\n * args: ['event', 'purchase', { value: 99.99 }]\n * });\n * ```\n */\nexport function mockEnv<T extends object>(\n env: T,\n interceptor: InterceptorFn,\n): T {\n const createProxy = (obj: object, path: string[] = []): object => {\n return new Proxy(obj, {\n get(target, prop: string) {\n const value = (target as Record<string, unknown>)[prop];\n const currentPath = [...path, prop];\n\n if (typeof value === 'function') {\n return (...args: unknown[]) => {\n return interceptor(currentPath, args, value);\n };\n }\n\n if (value && typeof value === 'object') {\n return createProxy(value as object, currentPath);\n }\n\n return value;\n },\n });\n };\n\n return createProxy(env) as T;\n}\n\n/**\n * Traverses environment object and replaces values using a replacer function\n *\n * Alternative to mockEnv for environments where Proxy is not suitable.\n * Performs deep traversal and allows value transformation at each level.\n *\n * @param env - The environment object to traverse\n * @param replacer - Function to transform values during traversal\n * @returns New environment object with transformed values\n *\n * @example\n * ```typescript\n * const recordedCalls: APICall[] = [];\n *\n * const recordingEnv = traverseEnv(originalEnv, (value, path) => {\n * if (typeof value === 'function') {\n * return (...args: unknown[]) => {\n * recordedCalls.push({\n * path: path.join('.'),\n * args: structuredClone(args)\n * });\n * return value(...args);\n * };\n * }\n * return value;\n * });\n * ```\n */\nexport function traverseEnv<T extends object>(\n env: T,\n replacer: (value: unknown, path: string[]) => unknown,\n): T {\n const traverse = (obj: unknown, path: string[] = []): unknown => {\n if (!obj || typeof obj !== 'object') return obj;\n\n const result: Record<string, unknown> | unknown[] = Array.isArray(obj)\n ? []\n : {};\n\n for (const [key, value] of Object.entries(obj)) {\n const currentPath = [...path, key];\n if (Array.isArray(result)) {\n result[Number(key)] = replacer(value, currentPath);\n } else {\n (result as Record<string, unknown>)[key] = replacer(value, currentPath);\n }\n\n if (value && typeof value === 'object' && typeof value !== 'function') {\n if (Array.isArray(result)) {\n result[Number(key)] = traverse(value, currentPath);\n } else {\n (result as Record<string, unknown>)[key] = traverse(\n value,\n currentPath,\n );\n }\n }\n }\n\n return result;\n };\n\n return traverse(env) as T;\n}\n","/**\n * Logs a message to the console if verbose logging is enabled.\n *\n * @param message The message to log.\n * @param verbose Whether to log the message.\n */\nexport function onLog(message: unknown, verbose = false): void {\n // eslint-disable-next-line no-console\n if (verbose) console.dir(message, { depth: 4 });\n}\n","import type { WalkerOS } from './types';\nimport { tryCatch } from './tryCatch';\nimport { castValue } from './castValue';\nimport { isArray, isObject } from './is';\n\n/**\n * Converts a request string to a data object.\n *\n * @param parameter The request string to convert.\n * @returns The data object or undefined.\n */\nexport function requestToData(\n parameter: unknown,\n): WalkerOS.AnyObject | undefined {\n const str = String(parameter);\n const queryString = str.split('?')[1] || str;\n\n return tryCatch(() => {\n const params = new URLSearchParams(queryString);\n const result: WalkerOS.AnyObject = {};\n\n params.forEach((value, key) => {\n const keys = key.split(/[[\\]]+/).filter(Boolean);\n let current: unknown = result;\n\n keys.forEach((k, i) => {\n const isLast = i === keys.length - 1;\n\n if (isArray(current)) {\n const index = parseInt(k, 10);\n if (isLast) {\n (current as Array<unknown>)[index] = castValue(value);\n } else {\n (current as Array<unknown>)[index] =\n (current as Array<unknown>)[index] ||\n (isNaN(parseInt(keys[i + 1], 10)) ? {} : []);\n current = (current as Array<unknown>)[index];\n }\n } else if (isObject(current)) {\n if (isLast) {\n (current as WalkerOS.AnyObject)[k] = castValue(value);\n } else {\n (current as WalkerOS.AnyObject)[k] =\n (current as WalkerOS.AnyObject)[k] ||\n (isNaN(parseInt(keys[i + 1], 10)) ? {} : []);\n current = (current as WalkerOS.AnyObject)[k];\n }\n }\n });\n });\n\n return result;\n })();\n}\n\n/**\n * Converts a data object to a request string.\n *\n * @param data The data object to convert.\n * @returns The request string.\n */\nexport function requestToParameter(\n data: WalkerOS.AnyObject | WalkerOS.PropertyType,\n): string {\n if (!data) return '';\n\n const params: string[] = [];\n const encode = encodeURIComponent;\n\n function addParam(key: string, value: unknown) {\n if (value === undefined || value === null) return;\n\n if (isArray(value)) {\n value.forEach((item, index) => addParam(`${key}[${index}]`, item));\n } else if (isObject(value)) {\n Object.entries(value).forEach(([subKey, subValue]) =>\n addParam(`${key}[${subKey}]`, subValue),\n );\n } else {\n params.push(`${encode(key)}=${encode(String(value))}`);\n }\n }\n\n if (typeof data === 'object') {\n Object.entries(data).forEach(([key, value]) => addParam(key, value));\n } else {\n return encode(data);\n }\n\n return params.join('&');\n}\n","import type { SendDataValue, SendHeaders } from './types/send';\nimport { isSameType } from './is';\nimport { assign } from './assign';\n\nexport type { SendDataValue, SendHeaders, SendResponse } from './types/send';\n\n/**\n * Transforms data to a string.\n *\n * @param data The data to transform.\n * @returns The transformed data.\n */\nexport function transformData(data?: SendDataValue): string | undefined {\n if (data === undefined) return data;\n\n return isSameType(data, '' as string) ? data : JSON.stringify(data);\n}\n\n/**\n * Gets the headers for a request.\n *\n * @param headers The headers to merge with the default headers.\n * @returns The merged headers.\n */\nexport function getHeaders(headers: SendHeaders = {}): SendHeaders {\n return assign(\n {\n 'Content-Type': 'application/json; charset=utf-8',\n },\n headers,\n );\n}\n","/**\n * Throws an error.\n *\n * @param error The error to throw.\n */\nexport function throwError(error: unknown): never {\n throw new Error(String(error));\n}\n","/**\n * Trims quotes and whitespaces from a string.\n *\n * @param str The string to trim.\n * @returns The trimmed string.\n */\nexport function trim(str: string): string {\n // Remove quotes and whitespaces\n return str ? str.trim().replace(/^'|'$/g, '').trim() : '';\n}\n","import type { Hooks } from './types';\n\n/**\n * A utility function that wraps a function with hooks.\n *\n * @template P, R\n * @param fn The function to wrap.\n * @param name The name of the function.\n * @param hooks The hooks to use.\n * @returns The wrapped function.\n */\nexport function useHooks<P extends unknown[], R>(\n fn: (...args: P) => R,\n name: string,\n hooks: Hooks.Functions,\n): (...args: P) => R {\n return function (...args: P): R {\n let result: R;\n const preHook = ('pre' + name) as keyof Hooks.Functions;\n const postHook = ('post' + name) as keyof Hooks.Functions;\n const preHookFn = hooks[preHook] as unknown as Hooks.HookFn<typeof fn>;\n const postHookFn = hooks[postHook] as unknown as Hooks.HookFn<typeof fn>;\n\n if (preHookFn) {\n // Call the original function within the preHook\n result = preHookFn({ fn }, ...args);\n } else {\n // Regular function call\n result = fn(...args);\n }\n\n if (postHookFn) {\n // Call the post-hook function with fn, result, and the original args\n result = postHookFn({ fn, result }, ...args);\n }\n\n return result;\n };\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Parses a user agent string to extract browser, OS, and device information.\n *\n * @param userAgent The user agent string to parse.\n * @returns An object containing the parsed user agent information.\n */\nexport function parseUserAgent(userAgent?: string): WalkerOS.User {\n if (!userAgent) return {};\n\n return {\n userAgent,\n browser: getBrowser(userAgent),\n browserVersion: getBrowserVersion(userAgent),\n os: getOS(userAgent),\n osVersion: getOSVersion(userAgent),\n deviceType: getDeviceType(userAgent),\n };\n}\n\n/**\n * Gets the browser name from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The browser name or undefined.\n */\nexport function getBrowser(userAgent: string): string | undefined {\n const browsers = [\n { name: 'Edge', substr: 'Edg' },\n { name: 'Chrome', substr: 'Chrome' },\n { name: 'Safari', substr: 'Safari', exclude: 'Chrome' },\n { name: 'Firefox', substr: 'Firefox' },\n { name: 'IE', substr: 'MSIE' },\n { name: 'IE', substr: 'Trident' },\n ];\n\n for (const browser of browsers) {\n if (\n userAgent.includes(browser.substr) &&\n (!browser.exclude || !userAgent.includes(browser.exclude))\n ) {\n return browser.name;\n }\n }\n\n return;\n}\n\n/**\n * Gets the browser version from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The browser version or undefined.\n */\nexport function getBrowserVersion(userAgent: string): string | undefined {\n const rules = [\n /Edg\\/([0-9]+)/, // Edge\n /Chrome\\/([0-9]+)/, // Chrome\n /Version\\/([0-9]+).*Safari/, // Safari\n /Firefox\\/([0-9]+)/, // Firefox\n /MSIE ([0-9]+)/, // IE 10 and older\n /rv:([0-9]+).*Trident/, // IE 11\n ];\n\n for (const regex of rules) {\n const match = userAgent.match(regex);\n if (match) {\n return match[1];\n }\n }\n\n return;\n}\n\n/**\n * Gets the OS name from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The OS name or undefined.\n */\nexport function getOS(userAgent: string): string | undefined {\n const osList = [\n { name: 'Windows', substr: 'Windows NT' },\n { name: 'macOS', substr: 'Mac OS X' },\n { name: 'Android', substr: 'Android' },\n { name: 'iOS', substr: 'iPhone OS' },\n { name: 'Linux', substr: 'Linux' },\n ];\n\n for (const os of osList) {\n if (userAgent.includes(os.substr)) {\n return os.name;\n }\n }\n\n return;\n}\n\n/**\n * Gets the OS version from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The OS version or undefined.\n */\nexport function getOSVersion(userAgent: string): string | undefined {\n const osVersionRegex = /(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/;\n const match = userAgent.match(osVersionRegex);\n return match ? match[1].replace(/_/g, '.') : undefined;\n}\n\n/**\n * Gets the device type from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The device type or undefined.\n */\nexport function getDeviceType(userAgent: string): string | undefined {\n let deviceType = 'Desktop';\n\n if (/Tablet|iPad/i.test(userAgent)) {\n deviceType = 'Tablet';\n } else if (\n /Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(\n userAgent,\n )\n ) {\n deviceType = 'Mobile';\n }\n\n return deviceType;\n}\n","import type { Schema, WalkerOS } from './types';\nimport { isSameType } from './is';\nimport { throwError } from './throwError';\nimport { tryCatch } from './tryCatch';\n\n/**\n * Validates an event against a set of contracts.\n *\n * @param obj The event to validate.\n * @param customContracts The custom contracts to use.\n * @returns The validated event.\n */\nexport function validateEvent(\n obj: unknown,\n customContracts: Schema.Contracts = [],\n): WalkerOS.Event | never {\n if (!isSameType(obj, {} as WalkerOS.AnyObject)) throwError('Invalid object');\n\n let event: string;\n let entity: string;\n let action: string;\n\n // Check if event.name is available and it's a string\n if (isSameType(obj.name, '')) {\n event = obj.name;\n [entity, action] = event.split(' ');\n if (!entity || !action) throwError('Invalid event name');\n } else if (isSameType(obj.entity, '') && isSameType(obj.action, '')) {\n entity = obj.entity;\n action = obj.action;\n event = `${entity} ${action}`;\n } else {\n throwError('Missing or invalid name, entity, or action');\n }\n\n const basicContract: Schema.Contract = {\n '*': {\n '*': {\n name: { maxLength: 255 }, // @TODO as general rule?\n user: { allowedKeys: ['id', 'device', 'session'] },\n consent: { allowedValues: [true, false] },\n timestamp: { min: 0 },\n timing: { min: 0 },\n count: { min: 0 },\n version: { allowedKeys: ['source', 'tagging'] },\n source: { allowedKeys: ['type', 'id', 'previous_id'] },\n },\n },\n };\n\n const basicEvent: WalkerOS.Event = {\n name: event,\n data: {},\n context: {},\n custom: {},\n globals: {},\n user: {},\n nested: [],\n consent: {},\n id: '',\n trigger: '',\n entity,\n action,\n timestamp: 0,\n timing: 0,\n group: '',\n count: 0,\n version: { source: '', tagging: 0 },\n source: { type: '', id: '', previous_id: '' },\n };\n\n // Collect all relevant schemas for the event\n const schemas = [basicContract]\n .concat(customContracts)\n .reduce((acc, contract) => {\n return ['*', entity].reduce((entityAcc, e) => {\n return ['*', action].reduce((actionAcc, a) => {\n const schema = contract[e]?.[a];\n return schema ? actionAcc.concat([schema]) : actionAcc;\n }, entityAcc);\n }, acc);\n }, [] as Schema.Properties[]);\n\n const result = schemas.reduce(\n (acc, schema) => {\n // Get all required properties\n const requiredKeys = Object.keys(schema).filter((key) => {\n const property = schema[key];\n return property?.required === true;\n });\n\n // Validate both, ingested and required properties but only once\n return [...Object.keys(obj), ...requiredKeys].reduce((acc, key) => {\n const propertySchema = schema[key];\n let value = obj[key];\n\n if (propertySchema) {\n // Update the value\n value = tryCatch(validateProperty, (err) => {\n throwError(String(err));\n })(acc, key, value, propertySchema);\n }\n\n // Same type check\n if (isSameType(value, acc[key])) acc[key] = value;\n\n return acc;\n }, acc);\n },\n // Not that beautiful but it works, narrowing down the type is tricky here\n // it's important that basicEvent is defined as an WalkerOS.Event\n basicEvent as unknown as WalkerOS.AnyObject,\n ) as unknown as WalkerOS.Event;\n\n // @TODO Final check for result.event === event.entity + ' ' + event.action\n\n return result;\n}\n\n/**\n * Validates a property against a schema.\n *\n * @param obj The object to validate.\n * @param key The key of the property to validate.\n * @param value The value of the property to validate.\n * @param schema The schema to validate against.\n * @returns The validated property.\n */\nexport function validateProperty(\n obj: WalkerOS.AnyObject,\n key: string,\n value: unknown,\n schema: Schema.Property,\n): WalkerOS.Property | never {\n // @TODO unknown to WalkerOS.Property\n\n // Note regarding potentially malicious values\n // Initial collection doesn't manipulate data\n // Prefer context-specific checks in the destinations\n\n // Custom validate function can change the value\n if (schema.validate)\n value = tryCatch(schema.validate, (err) => {\n throwError(String(err));\n })(value, key, obj);\n\n if (schema.required && value === undefined)\n throwError('Missing required property');\n\n // Strings\n if (isSameType(value, '' as string)) {\n if (schema.maxLength && value.length > schema.maxLength) {\n if (schema.strict) throwError('Value exceeds maxLength');\n value = value.substring(0, schema.maxLength);\n }\n }\n\n // Numbers\n else if (isSameType(value, 1 as number)) {\n if (isSameType(schema.min, 1) && value < schema.min) {\n if (schema.strict) throwError('Value below min');\n value = schema.min;\n } else if (isSameType(schema.max, 1) && value > schema.max) {\n if (schema.strict) throwError('Value exceeds max');\n value = schema.max;\n }\n }\n\n // @TODO boolean\n\n // Objects\n else if (isSameType(value, {} as WalkerOS.AnyObject)) {\n if (schema.schema) {\n const nestedSchema = schema.schema;\n\n // @TODO handle return to update value as non unknown\n // @TODO bug with multiple rules in property schema\n Object.keys(nestedSchema).reduce((acc, key) => {\n const propertySchema = nestedSchema[key];\n let value = acc[key];\n\n if (propertySchema) {\n // Type check\n if (propertySchema.type && typeof value !== propertySchema.type)\n throwError(`Type doesn't match (${key})`);\n\n // Update the value\n value = tryCatch(validateProperty, (err) => {\n throwError(String(err));\n })(acc, key, value, propertySchema);\n }\n\n return value as WalkerOS.AnyObject;\n }, value);\n }\n\n for (const objKey of Object.keys(value)) {\n // Check for allowed keys if applicable\n if (schema.allowedKeys && !schema.allowedKeys.includes(objKey)) {\n if (schema.strict) throwError('Key not allowed');\n\n delete value[objKey];\n }\n }\n }\n\n return value as WalkerOS.Property;\n}\n"],"mappings":";;;;;;;AAAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACEO,IAAM,UAAU;AAAA,EACrB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AACV;AAEO,IAAM,QAAQ;AAAA,EACnB,OAAO;AAAA,IACL;AAAA,EACF;AACF;;;ACZA,SAAS,SAAS;AAuBX,IAAM,iBAAiB,EAAE,OAAO;AAMhC,IAAM,iBAAiB,EAAE,OAAO;AAMhC,IAAM,kBAAkB,EAAE,QAAQ;AAUlC,IAAM,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAMnC,IAAM,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAM5C,IAAM,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAM7C,IAAM,iBAAiB,EAAE,OAAO,EAAE,SAAS,wBAAwB;AAWnE,IAAM,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;AAKpE,IAAM,yBAAyB,eAAe,SAAS;;;AC/E9D,SAAS,KAAAA,UAAS;;;ACAlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,KAAAC,UAAS;AAClB,SAAS,uBAAuB;AA4BzB,IAAM,oBAAoBA,GAC9B,KAAK,CAAC,SAAS,WAAW,QAAQ,CAAC,EACnC,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AAO,eAAe,CAAC,OAAO,YAAY,SAAS,MAAM,GAAG;AAC9D,YAAI,OAAO,OAAQ,YAAW,iBAAiB;AAE/C,eAAO,MAAM,MAAM;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["z","z","z","ValueSchema","ValuesSchema","RulesSchema","PolicySchema","ConsentSchema","walkeros_exports","z","zodToJsonSchema","z","zodToJsonSchema","mapping_exports","z","zodToJsonSchema","z","z","zodToJsonSchema","destination_exports","ConfigSchema","ResultSchema","configJsonSchema","z","zodToJsonSchema","ConfigSchema","z","ResultSchema","configJsonSchema","zodToJsonSchema","collector_exports","ConfigSchema","DestinationsSchema","InstanceSchema","PushContextSchema","configJsonSchema","instanceJsonSchema","pushContextJsonSchema","z","zodToJsonSchema","z","ConfigSchema","PushContextSchema","DestinationsSchema","InstanceSchema","zodToJsonSchema","configJsonSchema","pushContextJsonSchema","instanceJsonSchema","source_exports","ConfigSchema","InitSchema","InstanceSchema","PartialConfigSchema","configJsonSchema","instanceJsonSchema","partialConfigJsonSchema","z","zodToJsonSchema","z","ConfigSchema","PartialConfigSchema","InstanceSchema","InitSchema","zodToJsonSchema","configJsonSchema","partialConfigJsonSchema","instanceJsonSchema","z","zodToJsonSchema","acc","eventMapping","mapping","acc","key","value"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/collector.ts","../src/types/data.ts","../src/types/destination.ts","../src/types/elb.ts","../src/types/flow.ts","../src/types/handler.ts","../src/types/hooks.ts","../src/types/mapping.ts","../src/types/on.ts","../src/types/request.ts","../src/types/schema.ts","../src/types/source.ts","../src/types/walkeros.ts","../src/types/storage.ts","../src/schemas/validation.ts","../src/schemas/primitives.ts","../src/schemas/utilities.ts","../src/schemas/patterns.ts","../src/schemas/walkeros.ts","../src/schemas/mapping.ts","../src/schemas/destination.ts","../src/schemas/collector.ts","../src/schemas/source.ts","../src/schemas/flow.ts","../src/schemas/schema-builder.ts","../src/schemas/index.ts","../src/anonymizeIP.ts","../src/assign.ts","../src/is.ts","../src/clone.ts","../src/byPath.ts","../src/castValue.ts","../src/consent.ts","../src/createDestination.ts","../src/eventGenerator.ts","../src/getId.ts","../src/getMarketingParameters.ts","../src/invocations.ts","../src/property.ts","../src/tryCatch.ts","../src/mapping.ts","../src/mockEnv.ts","../src/onLog.ts","../src/request.ts","../src/send.ts","../src/throwError.ts","../src/trim.ts","../src/useHooks.ts","../src/userAgent.ts","../src/validate.ts"],"sourcesContent":["import type {\n Source,\n Destination,\n Elb as ElbTypes,\n Handler,\n Hooks,\n On,\n WalkerOS,\n Mapping,\n} from '.';\n\n/**\n * Core collector configuration interface\n */\nexport interface Config {\n /** Whether to run collector automatically */\n run?: boolean;\n /** Version for event tagging */\n tagging: number;\n /** Static global properties even on a new run */\n globalsStatic: WalkerOS.Properties;\n /** Static session data even on a new run */\n sessionStatic: Partial<SessionData>;\n /** Enable verbose logging */\n verbose: boolean;\n /** Error handler */\n onError?: Handler.Error;\n /** Log handler */\n onLog?: Handler.Log;\n}\n\n/**\n * Initialization configuration that extends Config with initial state\n */\nexport interface InitConfig extends Partial<Config> {\n /** Initial consent state */\n consent?: WalkerOS.Consent;\n /** Initial user data */\n user?: WalkerOS.User;\n /** Initial global properties */\n globals?: WalkerOS.Properties;\n /** Source configurations */\n sources?: Source.InitSources;\n /** Destination configurations */\n destinations?: Destination.InitDestinations;\n /** Initial custom properties */\n custom?: WalkerOS.Properties;\n}\n\nexport interface SessionData extends WalkerOS.Properties {\n isStart: boolean;\n storage: boolean;\n id?: string;\n start?: number;\n marketing?: true;\n updated?: number;\n isNew?: boolean;\n device?: string;\n count?: number;\n runs?: number;\n}\n\nexport interface Sources {\n [id: string]: Source.Instance;\n}\n\nexport interface Destinations {\n [id: string]: Destination.Instance;\n}\n\nexport type CommandType =\n | 'action'\n | 'config'\n | 'consent'\n | 'context'\n | 'destination'\n | 'elb'\n | 'globals'\n | 'hook'\n | 'init'\n | 'link'\n | 'run'\n | 'user'\n | 'walker'\n | string;\n\n/**\n * Context passed to collector.push for source mapping\n */\nexport interface PushContext {\n mapping?: Mapping.Config;\n}\n\n/**\n * Push function signature - handles events only\n */\nexport interface PushFn {\n (\n event: WalkerOS.DeepPartialEvent,\n context?: PushContext,\n ): Promise<ElbTypes.PushResult>;\n}\n\n/**\n * Command function signature - handles walker commands only\n */\nexport interface CommandFn {\n (command: 'config', config: Partial<Config>): Promise<ElbTypes.PushResult>;\n (command: 'consent', consent: WalkerOS.Consent): Promise<ElbTypes.PushResult>;\n <T extends Destination.Types>(\n command: 'destination',\n destination: Destination.Init<T> | Destination.Instance<T>,\n config?: Destination.Config<T>,\n ): Promise<ElbTypes.PushResult>;\n <K extends keyof Hooks.Functions>(\n command: 'hook',\n name: K,\n hookFn: Hooks.Functions[K],\n ): Promise<ElbTypes.PushResult>;\n (\n command: 'on',\n type: On.Types,\n rules: WalkerOS.SingleOrArray<On.Options>,\n ): Promise<ElbTypes.PushResult>;\n (command: 'user', user: WalkerOS.User): Promise<ElbTypes.PushResult>;\n (\n command: 'run',\n runState?: {\n consent?: WalkerOS.Consent;\n user?: WalkerOS.User;\n globals?: WalkerOS.Properties;\n custom?: WalkerOS.Properties;\n },\n ): Promise<ElbTypes.PushResult>;\n (\n command: string,\n data?: unknown,\n options?: unknown,\n ): Promise<ElbTypes.PushResult>;\n}\n\n// Main Collector interface\nexport interface Instance {\n push: PushFn;\n command: CommandFn;\n allowed: boolean;\n config: Config;\n consent: WalkerOS.Consent;\n count: number;\n custom: WalkerOS.Properties;\n sources: Sources;\n destinations: Destinations;\n globals: WalkerOS.Properties;\n group: string;\n hooks: Hooks.Functions;\n on: On.OnConfig;\n queue: WalkerOS.Events;\n round: number;\n session: undefined | SessionData;\n timing: number;\n user: WalkerOS.User;\n version: string;\n}\n","import type { WalkerOS } from '.';\n\nexport interface Contract {\n version: string;\n globals: Globals;\n context: Contexts;\n entities: Entities;\n // @TODO data as ref\n}\n\nexport interface Globals {\n [name: string]: Global;\n}\n\nexport interface Contexts {\n [name: string]: Context;\n}\n\nexport interface Entities {\n [name: string]: Entity;\n}\n\nexport interface Properties {\n [name: string]: Property;\n}\n\nexport interface Global extends Property {}\n\nexport interface Context extends Property {}\n\nexport interface Entity {\n data: Properties;\n actions: Actions;\n}\n\nexport interface Actions {\n [name: string]: Action;\n}\n\nexport interface Action {\n trigger?: Trigger;\n}\n\nexport type Trigger = string; // @TODO Move to web data contract\n\nexport interface Property {\n type?: PropertyType; // @TODO support multiple\n required?: boolean;\n values?: PropertyValues;\n}\n\nexport type PropertyType = 'boolean' | 'string' | 'number';\n\nexport type PropertyValues = Array<WalkerOS.Property>;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n Collector,\n Handler,\n Mapping as WalkerOSMapping,\n On,\n WalkerOS,\n} from '.';\n\n/**\n * Base environment requirements interface for walkerOS destinations\n *\n * This defines the core interface that destinations can use to declare\n * their runtime environment requirements. Platform-specific extensions\n * should extend this interface.\n */\nexport interface BaseEnv {\n /**\n * Generic global properties that destinations may require\n * Platform-specific implementations can extend this interface\n */\n [key: string]: unknown;\n}\n\n/**\n * Type bundle for destination generics.\n * Groups Settings, Mapping, and Env into a single type parameter.\n */\nexport interface Types<S = unknown, M = unknown, E = BaseEnv> {\n settings: S;\n mapping: M;\n env: E;\n}\n\n/**\n * Generic constraint for Types - ensures T has required properties for indexed access\n */\nexport type TypesGeneric = { settings: any; mapping: any; env: any };\n\n/**\n * Type extractors for consistent usage with Types bundle\n */\nexport type Settings<T extends TypesGeneric = Types> = T['settings'];\nexport type Mapping<T extends TypesGeneric = Types> = T['mapping'];\nexport type Env<T extends TypesGeneric = Types> = T['env'];\n\n/**\n * Inference helper: Extract Types from Instance\n */\nexport type TypesOf<I> = I extends Instance<infer T> ? T : never;\n\nexport interface Instance<T extends TypesGeneric = Types> {\n config: Config<T>;\n queue?: WalkerOS.Events;\n dlq?: DLQ;\n type?: string;\n env?: Env<T>;\n init?: InitFn<T>;\n push: PushFn<T>;\n pushBatch?: PushBatchFn<T>;\n on?: On.OnFn;\n}\n\nexport interface Config<T extends TypesGeneric = Types> {\n consent?: WalkerOS.Consent;\n settings?: Settings<T>;\n data?: WalkerOSMapping.Value | WalkerOSMapping.Values;\n env?: Env<T>;\n id?: string;\n init?: boolean;\n loadScript?: boolean;\n mapping?: WalkerOSMapping.Rules<WalkerOSMapping.Rule<Mapping<T>>>;\n policy?: Policy;\n queue?: boolean;\n verbose?: boolean;\n onError?: Handler.Error;\n onLog?: Handler.Log;\n}\n\nexport type PartialConfig<T extends TypesGeneric = Types> = Config<\n Types<\n Partial<Settings<T>> | Settings<T>,\n Partial<Mapping<T>> | Mapping<T>,\n Env<T>\n >\n>;\n\nexport interface Policy {\n [key: string]: WalkerOSMapping.Value;\n}\n\nexport type Init<T extends TypesGeneric = Types> = {\n code: Instance<T>;\n config?: Partial<Config<T>>;\n env?: Partial<Env<T>>;\n};\n\nexport interface InitDestinations {\n [key: string]: Init<any>;\n}\n\nexport interface Destinations {\n [key: string]: Instance;\n}\n\nexport interface Context<T extends TypesGeneric = Types> {\n collector: Collector.Instance;\n config: Config<T>;\n data?: Data;\n env: Env<T>;\n}\n\nexport interface InitContext<T extends TypesGeneric = Types> {\n collector: Collector.Instance;\n config: Config<Types<Partial<Settings<T>>, Mapping<T>, Env<T>>>;\n data?: Data;\n env: Env<T>;\n}\n\nexport interface PushContext<T extends TypesGeneric = Types>\n extends Context<T> {\n mapping?: WalkerOSMapping.Rule<Mapping<T>>;\n}\n\nexport interface PushBatchContext<T extends TypesGeneric = Types>\n extends Context<T> {\n mapping?: WalkerOSMapping.Rule<Mapping<T>>;\n}\n\nexport type InitFn<T extends TypesGeneric = Types> = (\n context: InitContext<T>,\n) => WalkerOS.PromiseOrValue<void | false | Config<T>>;\n\nexport type PushFn<T extends TypesGeneric = Types> = (\n event: WalkerOS.Event,\n context: PushContext<T>,\n) => WalkerOS.PromiseOrValue<void>;\n\nexport type PushBatchFn<T extends TypesGeneric = Types> = (\n batch: Batch<Mapping<T>>,\n context: PushBatchContext<T>,\n) => void;\n\nexport type PushEvent<Mapping = unknown> = {\n event: WalkerOS.Event;\n mapping?: WalkerOSMapping.Rule<Mapping>;\n};\nexport type PushEvents<Mapping = unknown> = Array<PushEvent<Mapping>>;\n\nexport interface Batch<Mapping> {\n key: string;\n events: WalkerOS.Events;\n data: Array<Data>;\n mapping?: WalkerOSMapping.Rule<Mapping>;\n}\n\nexport type Data =\n | WalkerOS.Property\n | undefined\n | Array<WalkerOS.Property | undefined>;\n\nexport type Ref = {\n id: string;\n destination: Instance;\n};\n\nexport type Push = {\n queue?: WalkerOS.Events;\n error?: unknown;\n};\n\nexport type DLQ = Array<[WalkerOS.Event, unknown]>;\n\nexport type Result = {\n successful: Array<Ref>;\n queued: Array<Ref>;\n failed: Array<Ref>;\n};\n","import type { Destination, Hooks, On, WalkerOS } from '.';\n\n// Event signatures only\nexport interface EventFn<R = Promise<PushResult>> {\n (partialEvent: WalkerOS.DeepPartialEvent): R;\n (event: string): R;\n (event: string, data: WalkerOS.Properties): R;\n}\n\n// Complete function interface - can be extended by other interfaces\nexport interface Fn<R = Promise<PushResult>, Config = unknown>\n extends EventFn<R>,\n WalkerCommands<R, Config> {\n // Interface intentionally empty - combines EventFn and WalkerCommands\n}\n\n// Walker commands (clear, predefined list)\nexport interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {\n (event: 'walker config', config: Partial<Config>): R;\n (event: 'walker consent', consent: WalkerOS.Consent): R;\n <T extends Destination.Types>(\n event: 'walker destination',\n destination: Destination.Init<T> | Destination.Instance<T>,\n config?: Destination.Config<T>,\n ): R;\n <K extends keyof Hooks.Functions>(\n event: 'walker hook',\n name: K,\n hookFn: Hooks.Functions[K],\n ): R;\n (\n event: 'walker on',\n type: On.Types,\n rules: WalkerOS.SingleOrArray<On.Options>,\n ): R;\n (event: 'walker user', user: WalkerOS.User): R;\n (\n event: 'walker run',\n runState: {\n consent?: WalkerOS.Consent;\n user?: WalkerOS.User;\n globals?: WalkerOS.Properties;\n custom?: WalkerOS.Properties;\n },\n ): R;\n}\n\nexport type Event<R = Promise<PushResult>> = (\n partialEvent: WalkerOS.DeepPartialEvent,\n) => R;\n\n// Simplified push data types for core collector\nexport type PushData<Config = unknown> =\n | WalkerOS.DeepPartial<Config>\n | WalkerOS.Consent\n | WalkerOS.User\n | WalkerOS.Properties;\n\nexport interface PushResult extends Destination.Result {\n event?: WalkerOS.Event;\n ok: boolean;\n}\n\n// Simplified Layer type for core collector\nexport type Layer = Array<IArguments | WalkerOS.DeepPartialEvent | unknown[]>;\n","/**\n * Flow Configuration System\n *\n * Core types for walkerOS unified configuration.\n * Platform-agnostic, runtime-focused.\n *\n * The Flow system enables \"one config to rule them all\" - a single\n * walkeros.config.json file that manages multiple environments\n * (web_prod, web_stage, server_prod, etc.) with shared configuration,\n * variables, and reusable definitions.\n *\n * @packageDocumentation\n */\n\nimport type { Source, Destination, Collector } from '.';\n\n/**\n * Primitive value types for variables\n */\nexport type Primitive = string | number | boolean;\n\n/**\n * Complete multi-environment configuration.\n * This is the root type for walkeros.config.json files.\n *\n * @remarks\n * The Setup interface represents the entire configuration file,\n * containing multiple named environments that can share variables\n * and definitions.\n *\n * @example\n * ```json\n * {\n * \"version\": 1,\n * \"$schema\": \"https://walkeros.io/schema/flow/v1.json\",\n * \"variables\": {\n * \"CURRENCY\": \"USD\"\n * },\n * \"environments\": {\n * \"web_prod\": { \"platform\": \"web\", ... },\n * \"server_prod\": { \"platform\": \"server\", ... }\n * }\n * }\n * ```\n */\nexport interface Setup {\n /**\n * Configuration schema version.\n * Used for compatibility checks and migrations.\n *\n * @remarks\n * - Version 1: Initial Flow configuration system\n * - Future versions will be documented as they're released\n */\n version: 1;\n\n /**\n * JSON Schema reference for IDE validation and autocomplete.\n *\n * @remarks\n * When set, IDEs like VSCode will provide:\n * - Autocomplete for all fields\n * - Inline documentation\n * - Validation errors before deployment\n *\n * @example\n * \"$schema\": \"https://walkeros.io/schema/flow/v1.json\"\n */\n $schema?: string;\n\n /**\n * Shared variables for interpolation across all environments.\n *\n * @remarks\n * Variables can be referenced using `${VAR_NAME:default}` syntax.\n * Resolution order:\n * 1. Environment variable (process.env.VAR_NAME)\n * 2. Config variable (config.variables.VAR_NAME)\n * 3. Inline default value\n *\n * @example\n * ```json\n * {\n * \"variables\": {\n * \"CURRENCY\": \"USD\",\n * \"GA4_ID\": \"G-DEFAULT\"\n * },\n * \"environments\": {\n * \"prod\": {\n * \"collector\": {\n * \"globals\": {\n * \"currency\": \"${CURRENCY}\"\n * }\n * }\n * }\n * }\n * }\n * ```\n */\n variables?: Record<string, Primitive>;\n\n /**\n * Reusable configuration definitions.\n *\n * @remarks\n * Definitions can be referenced using JSON Schema `$ref` syntax.\n * Useful for sharing mapping rules, common settings, etc.\n *\n * @example\n * ```json\n * {\n * \"definitions\": {\n * \"gtag_base_mapping\": {\n * \"page\": {\n * \"view\": { \"name\": \"page_view\" }\n * }\n * }\n * },\n * \"environments\": {\n * \"prod\": {\n * \"destinations\": {\n * \"gtag\": {\n * \"config\": {\n * \"mapping\": { \"$ref\": \"#/definitions/gtag_base_mapping\" }\n * }\n * }\n * }\n * }\n * }\n * }\n * ```\n */\n definitions?: Record<string, unknown>;\n\n /**\n * Named environment configurations.\n *\n * @remarks\n * Each environment represents a deployment target:\n * - web_prod, web_stage, web_dev (client-side tracking)\n * - server_prod, server_stage (server-side collection)\n *\n * Environment names are arbitrary and user-defined.\n *\n * @example\n * ```json\n * {\n * \"environments\": {\n * \"web_prod\": {\n * \"platform\": \"web\",\n * \"sources\": { ... },\n * \"destinations\": { ... }\n * },\n * \"server_prod\": {\n * \"platform\": \"server\",\n * \"destinations\": { ... }\n * }\n * }\n * }\n * ```\n */\n environments: Record<string, Config>;\n}\n\n/**\n * Single environment configuration.\n * Represents one deployment target (e.g., web_prod, server_stage).\n *\n * @remarks\n * This is the core runtime configuration used by `startFlow()`.\n * Platform-agnostic and independent of build/deployment tools.\n *\n * Extensions (build, docker, etc.) are added via `[key: string]: unknown`.\n */\nexport interface Config {\n /**\n * Target platform for this environment.\n *\n * @remarks\n * - `web`: Browser-based tracking (IIFE bundles, browser sources)\n * - `server`: Node.js server-side collection (CJS bundles, HTTP sources)\n *\n * This determines:\n * - Available packages (web-* vs server-*)\n * - Default build settings\n * - Template selection\n */\n platform: 'web' | 'server';\n\n /**\n * Source configurations (data capture).\n *\n * @remarks\n * Sources capture events from various origins:\n * - Browser DOM interactions (clicks, page views)\n * - DataLayer pushes\n * - HTTP requests (server-side)\n * - Cloud function triggers\n *\n * Key = unique source identifier (arbitrary)\n * Value = source reference with package and config\n *\n * @example\n * ```json\n * {\n * \"sources\": {\n * \"browser\": {\n * \"package\": \"@walkeros/web-source-browser\",\n * \"config\": {\n * \"settings\": {\n * \"pageview\": true,\n * \"session\": true\n * }\n * }\n * }\n * }\n * }\n * ```\n */\n sources?: Record<string, SourceReference>;\n\n /**\n * Destination configurations (data output).\n *\n * @remarks\n * Destinations send processed events to external services:\n * - Google Analytics (gtag)\n * - Meta Pixel (fbq)\n * - Custom APIs\n * - Data warehouses\n *\n * Key = unique destination identifier (arbitrary)\n * Value = destination reference with package and config\n *\n * @example\n * ```json\n * {\n * \"destinations\": {\n * \"gtag\": {\n * \"package\": \"@walkeros/web-destination-gtag\",\n * \"config\": {\n * \"settings\": {\n * \"ga4\": { \"measurementId\": \"G-XXXXXXXXXX\" }\n * }\n * }\n * }\n * }\n * }\n * ```\n */\n destinations?: Record<string, DestinationReference>;\n\n /**\n * Collector configuration (event processing).\n *\n * @remarks\n * The collector is the central event processing engine.\n * Configuration includes:\n * - Consent management\n * - Global properties\n * - User identification\n * - Processing rules\n *\n * @see {@link Collector.InitConfig} for complete options\n *\n * @example\n * ```json\n * {\n * \"collector\": {\n * \"run\": true,\n * \"tagging\": 1,\n * \"consent\": {\n * \"functional\": true,\n * \"marketing\": false\n * },\n * \"globals\": {\n * \"currency\": \"USD\",\n * \"environment\": \"production\"\n * }\n * }\n * }\n * ```\n */\n collector?: Collector.InitConfig;\n\n /**\n * Environment-specific variables.\n *\n * @remarks\n * These override root-level variables for this specific environment.\n * Useful for environment-specific API keys, endpoints, etc.\n *\n * @example\n * ```json\n * {\n * \"env\": {\n * \"API_ENDPOINT\": \"https://api.production.com\",\n * \"DEBUG\": \"false\"\n * }\n * }\n * ```\n */\n env?: Record<string, string>;\n\n /**\n * Extension point for package-specific fields.\n *\n * @remarks\n * Allows packages to add their own configuration fields:\n * - CLI adds `build` field (Bundle.Config)\n * - Docker adds `docker` field (Docker.Config)\n * - Lambda adds `lambda` field (Lambda.Config)\n *\n * Core doesn't validate these fields - packages handle validation.\n */\n [key: string]: unknown;\n}\n\n/**\n * Source reference with inline package syntax.\n *\n * @remarks\n * References a source package and provides configuration.\n * The package is automatically downloaded and imported during build.\n */\nexport interface SourceReference {\n /**\n * Package specifier with optional version.\n *\n * @remarks\n * Formats:\n * - `\"@walkeros/web-source-browser\"` - Latest version\n * - `\"@walkeros/web-source-browser@2.0.0\"` - Specific version\n * - `\"@walkeros/web-source-browser@^2.0.0\"` - Semver range\n *\n * The CLI will:\n * 1. Parse the package reference\n * 2. Download from npm\n * 3. Auto-detect default or named export\n * 4. Generate import statement\n *\n * @example\n * \"package\": \"@walkeros/web-source-browser@latest\"\n */\n package: string;\n\n /**\n * Source-specific configuration.\n *\n * @remarks\n * Structure depends on the source package.\n * Passed to the source's initialization function.\n *\n * @example\n * ```json\n * {\n * \"config\": {\n * \"settings\": {\n * \"pageview\": true,\n * \"session\": true,\n * \"elb\": \"elb\",\n * \"prefix\": \"data-elb\"\n * }\n * }\n * }\n * ```\n */\n config?: unknown;\n\n /**\n * Source environment configuration.\n *\n * @remarks\n * Environment-specific settings for the source.\n * Merged with default source environment.\n */\n env?: unknown;\n\n /**\n * Mark as primary source (provides main ELB).\n *\n * @remarks\n * The primary source's ELB function is returned by `startFlow()`.\n * Only one source should be marked as primary per environment.\n *\n * @default false\n */\n primary?: boolean;\n}\n\n/**\n * Destination reference with inline package syntax.\n *\n * @remarks\n * References a destination package and provides configuration.\n * Structure mirrors SourceReference for consistency.\n */\nexport interface DestinationReference {\n /**\n * Package specifier with optional version.\n *\n * @remarks\n * Same format as SourceReference.package\n *\n * @example\n * \"package\": \"@walkeros/web-destination-gtag@2.0.0\"\n */\n package: string;\n\n /**\n * Destination-specific configuration.\n *\n * @remarks\n * Structure depends on the destination package.\n * Typically includes:\n * - settings: API keys, IDs, endpoints\n * - mapping: Event transformation rules\n * - consent: Required consent states\n * - policy: Processing rules\n *\n * @example\n * ```json\n * {\n * \"config\": {\n * \"settings\": {\n * \"ga4\": {\n * \"measurementId\": \"G-XXXXXXXXXX\"\n * }\n * },\n * \"mapping\": {\n * \"page\": {\n * \"view\": {\n * \"name\": \"page_view\",\n * \"data\": { ... }\n * }\n * }\n * }\n * }\n * }\n * ```\n */\n config?: unknown;\n\n /**\n * Destination environment configuration.\n *\n * @remarks\n * Environment-specific settings for the destination.\n * Merged with default destination environment.\n */\n env?: unknown;\n}\n","export type Error = (error: unknown, state?: unknown) => void;\n\nexport type Log = (message: string, verbose?: boolean) => void;\n","// Define a generic type for functions with specific parameters and return type\nexport type AnyFunction<P extends unknown[] = never[], R = unknown> = (\n ...args: P\n) => R;\n\n// Define a generic type for a dictionary of functions\nexport type Functions = {\n [key: string]: AnyFunction;\n};\n\n// Define a parameter interface to wrap the function and its result\ninterface Parameter<P extends unknown[], R> {\n fn: (...args: P) => R;\n result?: R;\n}\n\n// Define the HookFn type using generics for better type safety\nexport type HookFn<T extends AnyFunction> = (\n params: Parameter<Parameters<T>, ReturnType<T>>,\n ...args: Parameters<T>\n) => ReturnType<T>;\n","import type { Collector, Destination, WalkerOS } from '.';\n\n/**\n * Shared mapping configuration interface.\n * Used by both Source.Config and Destination.Config.\n */\nexport interface Config<T = unknown> {\n consent?: WalkerOS.Consent; // Required consent to process events\n data?: Value | Values; // Global data transformation\n mapping?: Rules<Rule<T>>; // Event-specific mapping rules\n policy?: Policy; // Pre-processing rules\n}\n\nexport interface Policy {\n [key: string]: Value;\n}\n\nexport interface Rules<T = Rule> {\n [entity: string]: Record<string, T | Array<T>> | undefined;\n}\n\nexport interface Rule<Settings = unknown> {\n batch?: number; // Bundle events for batch processing\n batchFn?: (\n destination: Destination.Instance,\n collector: Collector.Instance,\n ) => void;\n batched?: Destination.Batch<Settings>; // Batch of events to be processed\n condition?: Condition; // Added condition\n consent?: WalkerOS.Consent; // Required consent states process the event\n settings?: Settings; // Arbitrary but protected configurations for custom event config\n data?: Data; // Mapping of event data\n ignore?: boolean; // Choose to no process an event when set to true\n name?: string; // Use a custom event name\n policy?: Policy; // Event-level policy applied after config-level policy\n}\n\nexport interface Result {\n eventMapping?: Rule;\n mappingKey?: string;\n}\n\nexport type Data = Value | Values;\nexport type Value = ValueType | Array<ValueType>;\nexport type Values = Array<Value>;\nexport type ValueType = string | ValueConfig;\n\nexport interface ValueConfig {\n condition?: Condition;\n consent?: WalkerOS.Consent;\n fn?: Fn;\n key?: string;\n loop?: Loop;\n map?: Map;\n set?: Value[];\n validate?: Validate;\n value?: WalkerOS.PropertyType;\n}\n\nexport type Condition = (\n value: WalkerOS.DeepPartialEvent | unknown,\n mapping?: Value,\n collector?: Collector.Instance,\n) => WalkerOS.PromiseOrValue<boolean>;\n\nexport type Fn = (\n value: WalkerOS.DeepPartialEvent | unknown,\n mapping: Value,\n options: Options,\n) => WalkerOS.PromiseOrValue<WalkerOS.Property | unknown>;\n\nexport type Loop = [Value, Value];\n\nexport type Map = { [key: string]: Value };\n\nexport interface Options {\n consent?: WalkerOS.Consent;\n collector?: Collector.Instance;\n props?: unknown;\n}\n\nexport type Validate = (value?: unknown) => WalkerOS.PromiseOrValue<boolean>;\n","import type { Collector, WalkerOS } from './';\n\n// collector state for the on actions\nexport type Config = {\n consent?: Array<ConsentConfig>;\n ready?: Array<ReadyConfig>;\n run?: Array<RunConfig>;\n session?: Array<SessionConfig>;\n};\n\n// On types\nexport type Types = keyof Config;\n\n// Map each event type to its expected context type\nexport interface EventContextMap {\n consent: WalkerOS.Consent;\n session: Collector.SessionData;\n ready: undefined;\n run: undefined;\n}\n\n// Extract the context type for a specific event\nexport type EventContext<T extends Types> = EventContextMap[T];\n\n// Union of all possible context types\nexport type AnyEventContext = EventContextMap[keyof EventContextMap];\n\n// Legacy context interface (can be removed in future)\nexport interface Context {\n consent?: WalkerOS.Consent;\n session?: unknown;\n}\n\n// Parameters for the onAction function calls\nexport type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;\n\n// Consent\nexport interface ConsentConfig {\n [key: string]: ConsentFn;\n}\nexport type ConsentFn = (\n collector: Collector.Instance,\n consent: WalkerOS.Consent,\n) => void;\n\n// Ready\nexport type ReadyConfig = ReadyFn;\nexport type ReadyFn = (collector: Collector.Instance) => void;\n\n// Run\nexport type RunConfig = RunFn;\nexport type RunFn = (collector: Collector.Instance) => void;\n\n// Session\nexport type SessionConfig = SessionFn;\nexport type SessionFn = (\n collector: Collector.Instance,\n session?: unknown,\n) => void;\n\nexport interface OnConfig {\n consent?: ConsentConfig[];\n ready?: ReadyConfig[];\n run?: RunConfig[];\n session?: SessionConfig[];\n [key: string]:\n | ConsentConfig[]\n | ReadyConfig[]\n | RunConfig[]\n | SessionConfig[]\n | undefined;\n}\n\n// Destination on function type with automatic type inference\nexport type OnFn = <T extends Types>(\n event: T,\n context: EventContextMap[T],\n) => WalkerOS.PromiseOrValue<void>;\n\n// Runtime-compatible version for internal usage\nexport type OnFnRuntime = (\n event: Types,\n context: AnyEventContext,\n) => WalkerOS.PromiseOrValue<void>;\n","export interface Context {\n city?: string;\n country?: string;\n encoding?: string;\n hash?: string;\n ip?: string;\n language?: string;\n origin?: string;\n region?: string;\n userAgent?: string;\n [key: string]: string | undefined;\n}\n","import type { WalkerOS } from '.';\n\nexport type Contracts = Array<Contract>;\n\nexport type Contract = {\n [entity: string]: {\n [action: string]: Properties;\n };\n};\n\nexport type Properties = {\n [key: string]: Property | undefined;\n};\n\nexport type Property = {\n allowedKeys?: string[];\n allowedValues?: unknown[];\n // @TODO minLength?: number;\n maxLength?: number;\n max?: number;\n min?: number;\n required?: boolean;\n schema?: Properties;\n strict?: boolean;\n type?: string;\n validate?: (\n value: unknown,\n key: string,\n event: WalkerOS.AnyObject,\n ) => WalkerOS.Property;\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type {\n Elb,\n On,\n Handler,\n Mapping as WalkerOSMapping,\n Collector,\n} from './index';\n\n/**\n * Base Env interface for dependency injection into sources.\n *\n * Sources receive all their dependencies through this environment object,\n * making them platform-agnostic and easily testable.\n */\nexport interface BaseEnv {\n [key: string]: unknown;\n push: Collector.PushFn;\n command: Collector.CommandFn;\n sources?: Collector.Sources;\n elb: Elb.Fn;\n}\n\n/**\n * Type bundle for source generics.\n * Groups Settings, Mapping, Push, and Env into a single type parameter.\n *\n * @template S - Settings configuration type\n * @template M - Mapping configuration type\n * @template P - Push function signature (flexible to support HTTP handlers, etc.)\n * @template E - Environment dependencies type\n */\nexport interface Types<S = unknown, M = unknown, P = Elb.Fn, E = BaseEnv> {\n settings: S;\n mapping: M;\n push: P;\n env: E;\n}\n\n/**\n * Generic constraint for Types - ensures T has required properties for indexed access\n */\nexport type TypesGeneric = { settings: any; mapping: any; push: any; env: any };\n\n/**\n * Type extractors for consistent usage with Types bundle\n */\nexport type Settings<T extends TypesGeneric = Types> = T['settings'];\nexport type Mapping<T extends TypesGeneric = Types> = T['mapping'];\nexport type Push<T extends TypesGeneric = Types> = T['push'];\nexport type Env<T extends TypesGeneric = Types> = T['env'];\n\n/**\n * Inference helper: Extract Types from Instance\n */\nexport type TypesOf<I> = I extends Instance<infer T> ? T : never;\n\nexport interface Config<T extends TypesGeneric = Types>\n extends WalkerOSMapping.Config<Mapping<T>> {\n settings?: Settings<T>;\n env?: Env<T>;\n id?: string;\n onError?: Handler.Error;\n disabled?: boolean;\n primary?: boolean;\n}\n\nexport type PartialConfig<T extends TypesGeneric = Types> = Config<\n Types<\n Partial<Settings<T>> | Settings<T>,\n Partial<Mapping<T>> | Mapping<T>,\n Push<T>,\n Env<T>\n >\n>;\n\nexport interface Instance<T extends TypesGeneric = Types> {\n type: string;\n config: Config<T>;\n push: Push<T>;\n destroy?(): void | Promise<void>;\n on?(event: On.Types, context?: unknown): void | Promise<void>;\n}\n\nexport type Init<T extends TypesGeneric = Types> = (\n config: Partial<Config<T>>,\n env: Env<T>,\n) => Instance<T> | Promise<Instance<T>>;\n\nexport type InitSource<T extends TypesGeneric = Types> = {\n code: Init<T>;\n config?: Partial<Config<T>>;\n env?: Partial<Env<T>>;\n primary?: boolean;\n};\n\n/**\n * Sources configuration for collector.\n * Maps source IDs to their initialization configurations.\n */\nexport interface InitSources {\n [sourceId: string]: InitSource<any>;\n}\n","import type { Elb as ElbTypes } from '.';\n\nexport type AnyObject<T = unknown> = Record<string, T>;\nexport type Elb = ElbTypes.Fn;\nexport type AnyFunction = (...args: unknown[]) => unknown;\nexport type SingleOrArray<T> = T | Array<T>;\n\nexport type Events = Array<Event>;\nexport type PartialEvent = Partial<Event>;\nexport type DeepPartialEvent = DeepPartial<Event>;\nexport interface Event {\n name: string;\n data: Properties;\n context: OrderedProperties;\n globals: Properties;\n custom: Properties;\n user: User;\n nested: Entities;\n consent: Consent;\n id: string;\n trigger: string;\n entity: string;\n action: string;\n timestamp: number;\n timing: number;\n group: string;\n count: number;\n version: Version;\n source: Source;\n}\n\nexport interface Consent {\n [name: string]: boolean; // name of consent group or tool\n}\n\nexport interface User extends Properties {\n // IDs\n id?: string;\n device?: string;\n session?: string;\n hash?: string;\n // User related\n address?: string;\n email?: string;\n phone?: string;\n userAgent?: string;\n browser?: string;\n browserVersion?: string;\n deviceType?: string;\n language?: string;\n country?: string;\n region?: string;\n city?: string;\n zip?: string;\n timezone?: string;\n os?: string;\n osVersion?: string;\n screenSize?: string;\n ip?: string;\n internal?: boolean;\n}\n\nexport interface Version extends Properties {\n source: string;\n tagging: number;\n}\n\nexport interface Source extends Properties {\n type: SourceType;\n id: string; // https://github.com/elbwalker/walkerOS\n previous_id: string; // https://www.elbwalker.com/\n}\n\nexport type SourceType = 'web' | 'server' | 'app' | 'other' | string;\n\nexport type PropertyType =\n | boolean\n | string\n | number\n | { [key: string]: Property };\n\nexport type Property = PropertyType | Array<PropertyType>;\n\nexport interface Properties {\n [key: string]: Property | undefined;\n}\nexport interface OrderedProperties {\n [key: string]: [Property, number] | undefined;\n}\n\nexport type Entities = Array<Entity>;\nexport interface Entity {\n entity: string;\n data: Properties;\n nested: Entities;\n context: OrderedProperties;\n}\n\nexport type ConsentHandler = Record<string, AnyFunction>;\nexport type ActionHandler = AnyFunction;\n\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\nexport type PromiseOrValue<T> = T | Promise<T>;\n","export type StorageType = 'local' | 'session' | 'cookie';\n\nexport const Storage = {\n Local: 'local' as const,\n Session: 'session' as const,\n Cookie: 'cookie' as const,\n} as const;\n\nexport const Const = {\n Utils: {\n Storage,\n },\n} as const;\n","/**\n * Central validation module\n * Single source of truth for validation library access\n *\n * All schema files should import from this module instead of directly\n * from zod to ensure consistent usage and easy maintenance.\n */\n\nimport { z } from 'zod';\n\n// Re-export validation tools for schema files\nexport { z };\nexport type { z as zod } from 'zod';\n\n/**\n * Standard JSON Schema conversion with consistent project defaults\n *\n * Uses Zod 4 native toJSONSchema() method for JSON Schema generation.\n * All walkerOS schemas use JSON Schema Draft 7 format.\n *\n * @param schema - Zod schema to convert\n * @param _name - Schema name (ignored in Zod 4, kept for API compatibility)\n * @param target - JSON Schema target version (default: 'draft-7')\n * @returns JSON Schema object\n */\nexport function toJsonSchema(\n schema: z.ZodTypeAny,\n _name?: string,\n target: 'draft-7' | 'draft-2020-12' | 'openapi-3.0' = 'draft-7',\n) {\n return z.toJSONSchema(schema, {\n target,\n });\n}\n\n/**\n * Legacy alias for backward compatibility\n * @deprecated Use toJsonSchema() instead\n */\nexport function zodToJsonSchema(\n schema: z.ZodTypeAny,\n options?: {\n target?: string;\n name?: string;\n $refStrategy?: string;\n definitions?: Record<string, z.ZodTypeAny>;\n },\n) {\n const target =\n options?.target === 'jsonSchema7'\n ? 'draft-7'\n : (options?.target as 'draft-7' | 'draft-2020-12' | 'openapi-3.0');\n return z.toJSONSchema(schema, {\n target: target || 'draft-7',\n });\n}\n","import { z } from './validation';\n\n/**\n * Primitive Schema Definitions\n *\n * Reusable primitive schemas following DRY principle.\n * These are the building blocks used throughout all schemas to ensure consistency.\n *\n * Benefits:\n * - Single source of truth for common patterns\n * - Consistent descriptions across all schemas\n * - Easier maintenance and updates\n * - Better IntelliSense/autocomplete\n */\n\n// ========================================\n// Basic Primitives\n// ========================================\n\n/**\n * Required string field\n * Used for required text fields throughout schemas\n */\nexport const RequiredString = z.string();\n\n/**\n * Required number field\n * Used for required numeric fields throughout schemas\n */\nexport const RequiredNumber = z.number();\n\n/**\n * Required boolean field\n * Used for required flag fields throughout schemas\n */\nexport const RequiredBoolean = z.boolean();\n\n// ========================================\n// Semantic Primitives\n// ========================================\n\n/**\n * Identifier - Required unique string identifier\n * Used for entity IDs, session IDs, etc.\n */\nexport const Identifier = z.string().min(1);\n\n/**\n * Timestamp - Unix timestamp in milliseconds\n * Used for event timestamps, session timestamps, etc.\n */\nexport const Timestamp = z.number().int().positive();\n\n/**\n * Counter - Sequential counter (non-negative integer)\n * Used for event counts, session counts, etc.\n */\nexport const Counter = z.number().int().nonnegative();\n\n/**\n * TaggingVersion - Version number for event tagging\n * Standardized description used in both Version and Config schemas\n */\nexport const TaggingVersion = z.number().describe('Tagging version number');\n\n// ========================================\n// Primitive Value Unions\n// ========================================\n\n/**\n * PrimitiveValue - Basic primitive types\n * Union of string, number, and boolean\n * Used in Property definitions and value transformations\n */\nexport const PrimitiveValue = z.union([z.string(), z.number(), z.boolean()]);\n\n/**\n * OptionalPrimitiveValue - Optional primitive value\n */\nexport const OptionalPrimitiveValue = PrimitiveValue.optional();\n","import { z, toJsonSchema } from './validation';\n\n/**\n * Utility Schemas\n *\n * Mirrors: types/storage.ts, types/handler.ts, and other utility types\n * Purpose: Runtime validation and JSON Schema generation for utility types\n *\n * Small, standalone schemas for utility types used throughout walkerOS:\n * - Storage types\n * - Handler functions\n * - Error/log management\n */\n\n// ========================================\n// Storage Schemas\n// ========================================\n\n/**\n * StorageType - Storage mechanism identifier\n *\n * Standard storage types:\n * - local: localStorage (persistent)\n * - session: sessionStorage (session-scoped)\n * - cookie: document.cookie (configurable expiry)\n *\n * Used for session persistence and user tracking\n */\nexport const StorageTypeSchema = z\n .enum(['local', 'session', 'cookie'])\n .describe('Storage mechanism: local, session, or cookie');\n\n/**\n * Storage - Storage type constants\n * Provides const values for type-safe storage type references\n */\nexport const StorageSchema = z\n .object({\n Local: z.literal('local'),\n Session: z.literal('session'),\n Cookie: z.literal('cookie'),\n })\n .describe('Storage type constants for type-safe references');\n\n// ========================================\n// Handler Schemas\n// ========================================\n\n/**\n * Error - Error handler function type\n *\n * Signature: (error: unknown, state?: unknown) => void\n *\n * Called when errors occur during:\n * - Event processing\n * - Destination push operations\n * - Source event handling\n * - Mapping transformations\n *\n * Parameters:\n * - error: The error that occurred\n * - state: Optional state information for debugging\n *\n * Note: Function schemas use z.unknown() as functions aren't serializable\n */\nexport const ErrorHandlerSchema = z\n .any()\n .describe('Error handler function: (error, state?) => void');\n\n/**\n * Log - Log handler function type\n *\n * Signature: (message: string, verbose?: boolean) => void\n *\n * Called for logging during:\n * - Event processing\n * - Configuration updates\n * - Debugging (when verbose enabled)\n *\n * Parameters:\n * - message: Log message\n * - verbose: Whether this is a verbose-only log\n *\n * Note: Function schemas use z.unknown() as functions aren't serializable\n */\nexport const LogHandlerSchema = z\n .any()\n .describe('Log handler function: (message, verbose?) => void');\n\n/**\n * Handler - Combined handler interface\n * Groups Error and Log handlers\n */\nexport const HandlerSchema = z\n .object({\n Error: ErrorHandlerSchema.describe('Error handler function'),\n Log: LogHandlerSchema.describe('Log handler function'),\n })\n .describe('Handler interface with error and log functions');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const storageTypeJsonSchema = toJsonSchema(\n StorageTypeSchema,\n 'StorageType',\n);\n\nexport const storageJsonSchema = toJsonSchema(StorageSchema, 'Storage');\n\nexport const errorHandlerJsonSchema = toJsonSchema(\n ErrorHandlerSchema,\n 'ErrorHandler',\n);\n\nexport const logHandlerJsonSchema = toJsonSchema(\n LogHandlerSchema,\n 'LogHandler',\n);\n\nexport const handlerJsonSchema = toJsonSchema(HandlerSchema, 'Handler');\n","import { z } from './validation';\nimport {} from './primitives';\nimport { ErrorHandlerSchema, LogHandlerSchema } from './utilities';\n\n/**\n * Common Schema Patterns\n *\n * Reusable schema patterns that appear across multiple domain schemas.\n * These patterns combine primitives into commonly used configurations.\n *\n * Benefits:\n * - DRY principle for complex patterns\n * - Consistent configuration interfaces\n * - Single source of truth for common configs\n * - Easier to maintain and update patterns globally\n */\n\n// ========================================\n// Handler Patterns\n// ========================================\n\n/**\n * HandlersConfig - Error and log handler configuration\n * Used in: Destination.Config, Collector.Config, Source.Config\n */\nexport const HandlersConfig = z\n .object({\n onError: ErrorHandlerSchema.optional().describe(\n 'Error handler function: (error, state?) => void',\n ),\n onLog: LogHandlerSchema.optional().describe(\n 'Log handler function: (message, verbose?) => void',\n ),\n })\n .partial();\n\n// ========================================\n// Configuration Patterns\n// ========================================\n\n/**\n * VerboseConfig - Verbose logging configuration\n * Used in: Destination.Config, Collector.Config\n */\nexport const VerboseConfig = z\n .object({\n verbose: z\n .boolean()\n .describe('Enable verbose logging for debugging')\n .optional(),\n })\n .partial();\n\n/**\n * QueueConfig - Event queueing configuration\n * Used in: Destination.Config\n */\nexport const QueueConfig = z\n .object({\n queue: z\n .boolean()\n .describe('Whether to queue events when consent is not granted')\n .optional(),\n })\n .partial();\n\n/**\n * IdConfig - ID configuration pattern\n * Used in: Destination.Config, Source.Config\n */\nexport const IdConfig = z.object({}).partial();\n\n/**\n * InitConfig - Initialization configuration pattern\n * Used in: Destination.Config\n */\nexport const InitConfig = z\n .object({\n init: z.boolean().describe('Whether to initialize immediately').optional(),\n loadScript: z\n .boolean()\n .describe('Whether to load external script (for web destinations)')\n .optional(),\n })\n .partial();\n\n/**\n * DisabledConfig - Disabled flag configuration\n * Used in: Source.Config\n */\nexport const DisabledConfig = z\n .object({\n disabled: z.boolean().describe('Set to true to disable').optional(),\n })\n .partial();\n\n/**\n * PrimaryConfig - Primary flag configuration\n * Used in: Source.Config, Source.InitSource\n */\nexport const PrimaryConfig = z\n .object({\n primary: z\n .boolean()\n .describe('Mark as primary (only one can be primary)')\n .optional(),\n })\n .partial();\n\n// ========================================\n// Generic Configuration Patterns\n// ========================================\n\n/**\n * GenericSettingsConfig - Generic settings configuration\n * Used in: Destination.Config, Source.Config, Collector runtime\n * Settings are implementation-specific and can't be validated generically\n */\nexport const GenericSettingsConfig = z\n .object({\n settings: z\n .any()\n .optional()\n .describe('Implementation-specific configuration'),\n })\n .partial();\n\n/**\n * GenericEnvConfig - Generic environment configuration\n * Used in: Destination.Config, Source.Config, Source.BaseEnv\n * Environment is platform-specific and can't be validated generically\n */\nexport const GenericEnvConfig = z\n .object({\n env: z\n .any()\n .optional()\n .describe('Environment dependencies (platform-specific)'),\n })\n .partial();\n\n// ========================================\n// Mapping Patterns\n// ========================================\n\n/**\n * DataTransformationConfig - Data transformation configuration\n * Used in: Destination.Config, Mapping.Config, Mapping.Rule\n *\n * Note: This creates a forward reference to ValueSchema/ValuesSchema\n * Import from mapping.ts to avoid circular dependencies\n */\nexport function createDataTransformationConfig(\n ValueSchema: z.ZodTypeAny,\n ValuesSchema: z.ZodTypeAny,\n) {\n return z\n .object({\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe('Data transformation rules'),\n })\n .partial();\n}\n\n/**\n * MappingRulesConfig - Mapping rules configuration\n * Used in: Destination.Config, Source.Config (via Mapping.Config)\n *\n * Note: This creates a forward reference to RulesSchema\n * Import from mapping.ts to avoid circular dependencies\n */\nexport function createMappingRulesConfig(RulesSchema: z.ZodTypeAny) {\n return z\n .object({\n mapping: RulesSchema.optional().describe('Event mapping rules'),\n })\n .partial();\n}\n\n/**\n * PolicyConfig - Policy rules configuration\n * Used in: Destination.Config, Mapping.Config, Mapping.Rule\n *\n * Note: This creates a forward reference to PolicySchema\n * Import from mapping.ts to avoid circular dependencies\n */\nexport function createPolicyConfig(PolicySchema: z.ZodTypeAny) {\n return z\n .object({\n policy: PolicySchema.optional().describe('Pre-processing policy rules'),\n })\n .partial();\n}\n\n/**\n * ConsentConfig - Consent requirements configuration\n * Used in: Destination.Config, Mapping.Config, Mapping.Rule, Event\n *\n * Note: This creates a forward reference to ConsentSchema\n * Import from walkeros.ts to avoid circular dependencies\n */\nexport function createConsentConfig(ConsentSchema: z.ZodTypeAny) {\n return z\n .object({\n consent: ConsentSchema.optional().describe('Required consent states'),\n })\n .partial();\n}\n\n// ========================================\n// Instance Patterns\n// ========================================\n\n/**\n * RuntimeInstanceConfig - Runtime instance configuration\n * Used in: Destination.Instance, Source.Instance, Collector.Instance\n *\n * Common fields for runtime instances:\n * - type: Instance type identifier\n * - config: Configuration object\n * - Functions (push, init, etc.) are instance-specific\n */\nexport const RuntimeInstanceConfig = z\n .object({\n type: z.string().optional().describe('Instance type identifier'),\n config: z.unknown().describe('Instance configuration'),\n })\n .partial();\n\n// ========================================\n// Context Patterns\n// ========================================\n\n/**\n * BaseContextConfig - Base context configuration\n * Used in: Destination.Context, Source contexts\n *\n * Common fields for contexts:\n * - collector: Collector instance (runtime)\n * - config: Configuration\n * - env: Environment dependencies\n */\nexport const BaseContextConfig = z\n .object({\n collector: z.unknown().describe('Collector instance (runtime object)'),\n config: z.unknown().describe('Configuration'),\n env: z.unknown().describe('Environment dependencies'),\n })\n .partial();\n\n// ========================================\n// Batch Patterns\n// ========================================\n\n/**\n * BatchConfig - Batch processing configuration\n * Used in: Mapping.Rule\n */\nexport const BatchConfig = z\n .object({\n batch: z\n .number()\n .optional()\n .describe('Batch size: bundle N events for batch processing'),\n batched: z.unknown().optional().describe('Batch of events to be processed'),\n })\n .partial();\n\n// ========================================\n// Processing Patterns\n// ========================================\n\n/**\n * ProcessingControlConfig - Processing control flags\n * Used in: Mapping.Rule\n */\nexport const ProcessingControlConfig = z\n .object({\n ignore: z.boolean().describe('Set to true to skip processing').optional(),\n condition: z\n .string()\n .optional()\n .describe('Condition function: return true to process'),\n })\n .partial();\n\n// ========================================\n// Collection Patterns\n// ========================================\n\n/**\n * SourcesMapConfig - Sources collection pattern\n * Used in: Collector.Instance\n */\nexport const SourcesMapConfig = z\n .object({\n sources: z\n .record(z.string(), z.unknown())\n .describe('Map of source instances'),\n })\n .partial();\n\n/**\n * DestinationsMapConfig - Destinations collection pattern\n * Used in: Collector.Instance\n */\nexport const DestinationsMapConfig = z\n .object({\n destinations: z\n .record(z.string(), z.unknown())\n .describe('Map of destination instances'),\n })\n .partial();\n","import { z, toJsonSchema } from './validation';\nimport {\n RequiredString,\n RequiredNumber,\n Identifier,\n Timestamp,\n Counter,\n TaggingVersion,\n} from './primitives';\n\n/**\n * Core walkerOS Event Model Schemas\n *\n * Mirrors: types/walkeros.ts\n * Purpose: Runtime validation and JSON Schema generation for MCP tools, Explorer UI, and API boundaries\n *\n * These schemas provide:\n * 1. Runtime validation for event data\n * 2. JSON Schema generation for RJSF/Explorer\n * 3. Type documentation via .describe()\n * 4. Compile-time type checking (schemas mirror TypeScript types)\n *\n * Note: TypeScript types in types/walkeros.ts remain the source of truth for development.\n * These Zod schemas are for validation and JSON Schema generation at runtime boundaries.\n */\n\n// ========================================\n// Base Property Types (Recursive)\n// ========================================\n\n/**\n * PropertyType - Base property value types\n * Can be primitive (boolean, string, number) or nested object with Property values\n */\nexport const PropertyTypeSchema: z.ZodTypeAny = z.lazy(() =>\n z.union([\n z.boolean(),\n z.string(),\n z.number(),\n z.record(z.string(), PropertySchema),\n ]),\n);\n\n/**\n * Property - PropertyType or array of PropertyType\n * Recursive structure allows nested objects and arrays\n */\nexport const PropertySchema: z.ZodTypeAny = z.lazy(() =>\n z.union([PropertyTypeSchema, z.array(PropertyTypeSchema)]),\n);\n\n/**\n * Properties - Record of string keys to Property values\n * Used throughout event structure (data, globals, custom, etc.)\n */\nexport const PropertiesSchema = z\n .record(z.string(), PropertySchema.optional())\n .describe('Flexible property collection with optional values');\n\n/**\n * OrderedProperties - Record with [value, order] tuples\n * Used for context data where order matters\n */\nexport const OrderedPropertiesSchema = z\n .record(z.string(), z.tuple([PropertySchema, z.number()]).optional())\n .describe(\n 'Ordered properties with [value, order] tuples for priority control',\n );\n\n// ========================================\n// Enums & Union Types\n// ========================================\n\n/**\n * SourceType - Event source identifier\n * Standard types: web, server, app, other\n * Extensible: allows custom string values\n */\nexport const SourceTypeSchema = z\n .union([z.enum(['web', 'server', 'app', 'other']), z.string()])\n .describe('Source type: web, server, app, other, or custom');\n\n// ========================================\n// Event Sub-Types\n// ========================================\n\n/**\n * Consent - Consent state mapping\n * Maps consent group names to boolean states\n * Used in Event and Destination/Source configs\n */\nexport const ConsentSchema = z\n .record(z.string(), z.boolean())\n .describe('Consent requirement mapping (group name → state)');\n\n/**\n * User - User identification and attributes\n * Extends Properties with specific optional fields\n * Contains IDs, demographics, device info, and location data\n */\nexport const UserSchema = PropertiesSchema.and(\n z.object({\n // IDs\n id: z.string().optional().describe('User identifier'),\n device: z.string().optional().describe('Device identifier'),\n session: z.string().optional().describe('Session identifier'),\n hash: z.string().optional().describe('Hashed identifier'),\n // User attributes\n address: z.string().optional().describe('User address'),\n email: z.string().email().optional().describe('User email address'),\n phone: z.string().optional().describe('User phone number'),\n // Technical attributes\n userAgent: z.string().optional().describe('Browser user agent string'),\n browser: z.string().optional().describe('Browser name'),\n browserVersion: z.string().optional().describe('Browser version'),\n deviceType: z\n .string()\n .optional()\n .describe('Device type (mobile, desktop, tablet)'),\n os: z.string().optional().describe('Operating system'),\n osVersion: z.string().optional().describe('Operating system version'),\n screenSize: z.string().optional().describe('Screen dimensions'),\n // Location attributes\n language: z.string().optional().describe('User language'),\n country: z.string().optional().describe('User country'),\n region: z.string().optional().describe('User region/state'),\n city: z.string().optional().describe('User city'),\n zip: z.string().optional().describe('User postal code'),\n timezone: z.string().optional().describe('User timezone'),\n ip: z.string().optional().describe('User IP address'),\n // Flags\n internal: z\n .boolean()\n .optional()\n .describe('Internal user flag (employee, test user)'),\n }),\n).describe('User identification and properties');\n\n/**\n * Version - Walker version information\n * Tracks source implementation and tagging version\n */\nexport const VersionSchema = PropertiesSchema.and(\n z.object({\n source: RequiredString.describe(\n 'Walker implementation version (e.g., \"2.0.0\")',\n ),\n tagging: TaggingVersion,\n }),\n).describe('Walker version information');\n\n/**\n * Source - Event source information\n * Identifies where the event originated\n */\nexport const SourceSchema = PropertiesSchema.and(\n z.object({\n type: SourceTypeSchema.describe('Source type identifier'),\n id: RequiredString.describe('Source identifier (typically URL on web)'),\n previous_id: RequiredString.describe(\n 'Previous source identifier (typically referrer on web)',\n ),\n }),\n).describe('Event source information');\n\n/**\n * Entity - Nested entity structure\n * Allows events to contain related entities with their own data and context\n * Recursive: entities can contain nested entities\n */\nexport const EntitySchema: z.ZodTypeAny = z\n .lazy(() =>\n z.object({\n entity: z.string().describe('Entity name'),\n data: PropertiesSchema.describe('Entity-specific properties'),\n nested: z.array(EntitySchema).describe('Nested child entities'),\n context: OrderedPropertiesSchema.describe('Entity context data'),\n }),\n )\n .describe('Nested entity structure with recursive nesting support');\n\n/**\n * Entities - Array of Entity objects\n */\nexport const EntitiesSchema = z\n .array(EntitySchema)\n .describe('Array of nested entities');\n\n// ========================================\n// Main Event Schema\n// ========================================\n\n/**\n * Event - Complete walkerOS event structure\n *\n * Core fields:\n * - name: Event identifier in \"entity action\" format (e.g., \"page view\")\n * - data: Event-specific properties\n * - context: Ordered context properties\n * - globals: Global properties shared across events\n * - custom: Custom properties specific to implementation\n * - user: User identification and attributes\n * - nested: Related entities\n * - consent: Consent states at event time\n *\n * System-generated fields:\n * - id: Unique event identifier\n * - timestamp: Event creation time (milliseconds since epoch)\n * - entity: Parsed entity name from event.name\n * - action: Parsed action name from event.name\n * - trigger: Event trigger identifier\n * - timing: Event processing timing information\n * - group: Event grouping identifier\n * - count: Event count in session\n * - version: Walker version information\n * - source: Event source information\n */\nexport const EventSchema = z\n .object({\n // Core event identification\n name: z\n .string()\n .describe(\n 'Event name in \"entity action\" format (e.g., \"page view\", \"product add\")',\n ),\n\n // Event data\n data: PropertiesSchema.describe('Event-specific properties'),\n context: OrderedPropertiesSchema.describe(\n 'Ordered context properties with priorities',\n ),\n globals: PropertiesSchema.describe(\n 'Global properties shared across events',\n ),\n custom: PropertiesSchema.describe(\n 'Custom implementation-specific properties',\n ),\n\n // Related data\n user: UserSchema.describe('User identification and attributes'),\n nested: EntitiesSchema.describe('Related nested entities'),\n consent: ConsentSchema.describe('Consent states at event time'),\n\n // System-generated fields\n id: Identifier.describe('Unique event identifier (timestamp-based)'),\n trigger: RequiredString.describe('Event trigger identifier'),\n entity: RequiredString.describe('Parsed entity from event name'),\n action: RequiredString.describe('Parsed action from event name'),\n timestamp: Timestamp.describe('Unix timestamp in milliseconds since epoch'),\n timing: RequiredNumber.describe('Event processing timing information'),\n group: RequiredString.describe('Event grouping identifier'),\n count: Counter.describe('Event count in session'),\n\n // Version & source tracking\n version: VersionSchema.describe('Walker version information'),\n source: SourceSchema.describe('Event source information'),\n })\n .describe('Complete walkerOS event structure');\n\n/**\n * PartialEvent - Event with all fields optional\n * Used for event creation where not all fields are provided\n */\nexport const PartialEventSchema = EventSchema.partial().describe(\n 'Partial event structure with all fields optional',\n);\n\n/**\n * DeepPartialEvent - Event with all fields optional\n * Used for event updates and patches\n *\n * Note: While the TypeScript type uses DeepPartial<Event> for compile-time validation,\n * the Zod schema uses .partial() which makes top-level fields optional. This is\n * sufficient for runtime validation as deeply nested partial objects are rarely\n * provided (users typically omit entire objects rather than providing partial nested data).\n * Zod 4 deliberately removed .deepPartial() due to internal type complexity issues.\n */\nexport const DeepPartialEventSchema: z.ZodTypeAny =\n EventSchema.partial().describe(\n 'Partial event structure with all top-level fields optional',\n );\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const eventJsonSchema = toJsonSchema(EventSchema, 'Event');\n\nexport const partialEventJsonSchema = toJsonSchema(\n PartialEventSchema,\n 'PartialEvent',\n);\n\nexport const userJsonSchema = toJsonSchema(UserSchema, 'User');\n\nexport const propertiesJsonSchema = toJsonSchema(\n PropertiesSchema,\n 'Properties',\n);\n\nexport const orderedPropertiesJsonSchema = toJsonSchema(\n OrderedPropertiesSchema,\n 'OrderedProperties',\n);\n\nexport const entityJsonSchema = toJsonSchema(EntitySchema, 'Entity');\n\nexport const sourceTypeJsonSchema = toJsonSchema(\n SourceTypeSchema,\n 'SourceType',\n);\n\nexport const consentJsonSchema = toJsonSchema(ConsentSchema, 'Consent');\n","import { z, toJsonSchema } from './validation';\nimport { ConsentSchema } from './walkeros';\n\n/**\n * Mapping System Schemas\n *\n * Mirrors: types/mapping.ts\n * Purpose: Runtime validation and JSON Schema generation for event transformation rules\n *\n * The mapping system allows flexible transformation of events as they flow through\n * the collector to destinations. This includes:\n * - Value extraction and transformation\n * - Conditional logic\n * - Data mapping and restructuring\n * - Array processing (loops)\n * - Consent-based filtering\n *\n * Key Features:\n * - Recursive value definitions (Value → ValueConfig → Value)\n * - Loop vs Set distinction via JSON Schema (minItems/maxItems)\n * - Lazy evaluation for circular dependencies\n * - Function serialization support (functions as strings)\n */\n\n// ========================================\n// Recursive Value Schemas\n// ========================================\n\n// Forward declaration for circular dependency\nlet ValueConfigSchemaLazy: z.ZodTypeAny;\n\n/**\n * Value - Core value type for mapping transformations\n *\n * Can be:\n * - Primitive: string, number, boolean\n * - ValueConfig: Complex transformation object\n * - Array: Multiple values/configs\n *\n * Recursive structure allows nested transformations\n */\nexport const ValueSchema: z.ZodTypeAny = z.lazy(() =>\n z.union([\n z.string().describe('String value or property path (e.g., \"data.id\")'),\n z.number().describe('Numeric value'),\n z.boolean().describe('Boolean value'),\n z.lazy(() => ValueConfigSchemaLazy),\n z.array(ValueSchema).describe('Array of values'),\n ]),\n);\n\n/**\n * Values - Array of Value objects\n * Used for multiple data transformations\n */\nexport const ValuesSchema = z\n .array(ValueSchema)\n .describe('Array of transformation values');\n\n/**\n * Loop - Tuple for array processing\n * Format: [source, transform]\n *\n * IMPORTANT: z.tuple() generates JSON Schema with minItems/maxItems = 2\n * This is how Explorer distinguishes Loop from Set\n *\n * Example: ['nested', { map: { id: 'data.id' } }]\n * Means: Iterate over event.nested array, transform each item\n */\nconst LoopSchema: z.ZodTypeAny = z.lazy(() =>\n z\n .tuple([ValueSchema, ValueSchema])\n .describe(\n 'Loop transformation: [source, transform] tuple for array processing',\n ),\n);\n\n/**\n * Set - Array of values for selection/combination\n * Format: [value1, value2, ...]\n *\n * IMPORTANT: z.array() generates JSON Schema without minItems/maxItems\n * This distinguishes Set from Loop\n *\n * Example: ['data.firstName', ' ', 'data.lastName']\n * Means: Combine multiple values\n */\nconst SetSchema: z.ZodTypeAny = z.lazy(() =>\n z\n .array(ValueSchema)\n .describe('Set: Array of values for selection or combination'),\n);\n\n/**\n * Map - Object mapping for data transformation\n * Format: { outputKey: value, ... }\n *\n * Example: { item_id: 'data.id', item_name: 'data.name' }\n * Means: Transform event data to destination format\n */\nconst MapSchema: z.ZodTypeAny = z.lazy(() =>\n z\n .record(z.string(), ValueSchema)\n .describe('Map: Object mapping keys to transformation values'),\n);\n\n/**\n * ValueConfig - Configuration object for value transformations\n *\n * Supports multiple transformation strategies:\n * - key: Extract property from event (e.g., \"data.id\")\n * - value: Static primitive value\n * - fn: Custom transformation function (as string)\n * - map: Object mapping for structured output\n * - loop: Array iteration and transformation\n * - set: Value combination/selection\n * - consent: Consent-based filtering\n * - condition: Conditional transformation\n * - validate: Value validation\n *\n * At least one property must be present.\n */\nValueConfigSchemaLazy = z\n .object({\n key: z\n .string()\n .optional()\n .describe(\n 'Property path to extract from event (e.g., \"data.id\", \"user.email\")',\n ),\n value: z\n .union([z.string(), z.number(), z.boolean()])\n .optional()\n .describe('Static primitive value'),\n fn: z\n .string()\n .optional()\n .describe('Custom transformation function as string (serialized)'),\n map: MapSchema.optional().describe(\n 'Object mapping: transform event data to structured output',\n ),\n loop: LoopSchema.optional().describe(\n 'Loop transformation: [source, transform] for array processing',\n ),\n set: SetSchema.optional().describe(\n 'Set of values: combine or select from multiple values',\n ),\n consent: ConsentSchema.optional().describe(\n 'Required consent states to include this value',\n ),\n condition: z\n .string()\n .optional()\n .describe('Condition function as string: return true to include value'),\n validate: z\n .string()\n .optional()\n .describe('Validation function as string: return true if value is valid'),\n })\n .refine((data) => Object.keys(data).length > 0, {\n message: 'ValueConfig must have at least one property',\n })\n .describe('Value transformation configuration with multiple strategies');\n\n// Export with original name for backward compatibility\nexport const ValueConfigSchema = ValueConfigSchemaLazy;\n\n// Re-export for use in other schemas\nexport { LoopSchema, SetSchema, MapSchema };\n\n// ========================================\n// Policy Schema\n// ========================================\n\n/**\n * Policy - Pre-processing rules\n * Applied before event mapping\n * Maps policy keys to transformation values\n *\n * Example: { 'consent.marketing': true }\n * Means: Only process events with marketing consent\n */\nexport const PolicySchema = z\n .record(z.string(), ValueSchema)\n .describe('Policy rules for event pre-processing (key → value mapping)');\n\n// ========================================\n// Mapping Rule Schemas\n// ========================================\n\n/**\n * Rule - Event-specific mapping configuration\n *\n * Defines how to transform events for a specific entity-action combination\n * Can include:\n * - Batching configuration\n * - Conditional processing\n * - Consent requirements\n * - Custom settings\n * - Data transformation\n * - Event naming\n * - Policy overrides\n */\nexport const RuleSchema = z\n .object({\n batch: z\n .number()\n .optional()\n .describe('Batch size: bundle N events for batch processing'),\n // Note: batchFn and batched are runtime functions, not serializable\n condition: z\n .string()\n .optional()\n .describe('Condition function as string: return true to process event'),\n consent: ConsentSchema.optional().describe(\n 'Required consent states to process this event',\n ),\n settings: z\n .any()\n .optional()\n .describe('Destination-specific settings for this event mapping'),\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe('Data transformation rules for event'),\n ignore: z\n .boolean()\n .optional()\n .describe('Set to true to skip processing this event'),\n name: z\n .string()\n .optional()\n .describe(\n 'Custom event name override (e.g., \"view_item\" for \"product view\")',\n ),\n policy: PolicySchema.optional().describe(\n 'Event-level policy overrides (applied after config-level policy)',\n ),\n })\n .describe('Mapping rule for specific entity-action combination');\n\n/**\n * Rules - Nested mapping rules structure\n * Format: { entity: { action: Rule | Rule[], ... }, ... }\n *\n * Supports:\n * - Specific entity-action mappings\n * - Wildcard patterns (entity: *, action: *)\n * - Multiple rules per entity-action (array)\n *\n * Example:\n * {\n * product: {\n * view: { name: 'view_item' },\n * add: { name: 'add_to_cart' }\n * },\n * page: {\n * '*': { name: 'page_interaction' }\n * }\n * }\n */\nexport const RulesSchema = z\n .record(\n z.string(),\n z.record(z.string(), z.union([RuleSchema, z.array(RuleSchema)])).optional(),\n )\n .describe(\n 'Nested mapping rules: { entity: { action: Rule | Rule[] } } with wildcard support',\n );\n\n/**\n * Config - Shared mapping configuration\n * Used by both Source.Config and Destination.Config\n *\n * Provides:\n * - Consent requirements\n * - Global data transformations\n * - Entity-action mapping rules\n * - Pre-processing policies\n */\nexport const ConfigSchema = z\n .object({\n consent: ConsentSchema.optional().describe(\n 'Required consent states to process any events',\n ),\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe('Global data transformation applied to all events'),\n mapping: RulesSchema.optional().describe(\n 'Entity-action specific mapping rules',\n ),\n policy: PolicySchema.optional().describe(\n 'Pre-processing policy rules applied before mapping',\n ),\n })\n .describe('Shared mapping configuration for sources and destinations');\n\n/**\n * Result - Mapping resolution result\n * Contains the resolved mapping rule and key used\n */\nexport const ResultSchema = z\n .object({\n eventMapping: RuleSchema.optional().describe(\n 'Resolved mapping rule for event',\n ),\n mappingKey: z\n .string()\n .optional()\n .describe('Mapping key used (e.g., \"product.view\")'),\n })\n .describe('Mapping resolution result');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const valueJsonSchema = toJsonSchema(ValueSchema, 'Value');\n\nexport const valueConfigJsonSchema = toJsonSchema(\n ValueConfigSchema,\n 'ValueConfig',\n);\n\nexport const loopJsonSchema = toJsonSchema(LoopSchema, 'Loop');\n\nexport const setJsonSchema = toJsonSchema(SetSchema, 'Set');\n\nexport const mapJsonSchema = toJsonSchema(MapSchema, 'Map');\n\nexport const policyJsonSchema = toJsonSchema(PolicySchema, 'Policy');\n\nexport const ruleJsonSchema = toJsonSchema(RuleSchema, 'Rule');\n\nexport const rulesJsonSchema = toJsonSchema(RulesSchema, 'Rules');\n\nexport const configJsonSchema = toJsonSchema(ConfigSchema, 'MappingConfig');\n","import { z, toJsonSchema } from './validation';\nimport { ConsentSchema, EventSchema } from './walkeros';\nimport {\n ValueSchema,\n ValuesSchema,\n RuleSchema,\n RulesSchema,\n PolicySchema,\n} from './mapping';\nimport { Identifier } from './primitives';\nimport { ErrorHandlerSchema, LogHandlerSchema } from './utilities';\n\n/**\n * Destination Schemas\n *\n * Mirrors: types/destination.ts\n * Purpose: Runtime validation and JSON Schema generation for destination configurations\n *\n * Destinations are the endpoints where processed events are sent (analytics tools,\n * marketing platforms, data warehouses, etc.). This file defines schemas for:\n * - Destination configuration\n * - Type bundles for generic constraints\n * - Push contexts\n * - Batching structures\n */\n\n// ========================================\n// Configuration Schemas\n// ========================================\n\n/**\n * Config - Destination configuration\n *\n * Defines how a destination processes events:\n * - Consent requirements\n * - Settings (destination-specific)\n * - Data transformations\n * - Environment dependencies\n * - Initialization options\n * - Mapping rules\n * - Processing policies\n * - Queueing behavior\n * - Logging verbosity\n * - Error/log handlers\n *\n * Generic note: settings, env, and mapping can have destination-specific types\n * but for schema validation we use z.unknown() to allow flexibility\n */\nexport const ConfigSchema = z\n .object({\n consent: ConsentSchema.optional().describe(\n 'Required consent states to send events to this destination',\n ),\n settings: z\n .any()\n .describe('Implementation-specific configuration')\n .optional(),\n data: z\n .union([ValueSchema, ValuesSchema])\n .optional()\n .describe(\n 'Global data transformation applied to all events for this destination',\n ),\n env: z\n .any()\n .describe('Environment dependencies (platform-specific)')\n .optional(),\n id: Identifier.describe(\n 'Destination instance identifier (defaults to destination key)',\n ).optional(),\n init: z.boolean().describe('Whether to initialize immediately').optional(),\n loadScript: z\n .boolean()\n .describe('Whether to load external script (for web destinations)')\n .optional(),\n mapping: RulesSchema.optional().describe(\n 'Entity-action specific mapping rules for this destination',\n ),\n policy: PolicySchema.optional().describe(\n 'Pre-processing policy rules applied before event mapping',\n ),\n queue: z\n .boolean()\n .describe('Whether to queue events when consent is not granted')\n .optional(),\n verbose: z\n .boolean()\n .describe('Enable verbose logging for debugging')\n .optional(),\n // Handler functions\n onError: ErrorHandlerSchema.optional(),\n onLog: LogHandlerSchema.optional(),\n })\n .describe('Destination configuration');\n\n/**\n * PartialConfig - Config with all fields optional\n * Used for config updates and overrides\n *\n * Note: All fields in ConfigSchema are already optional (.optional() on each field).\n * Using .partial() ensures the schema itself makes all fields optional at the type level.\n */\nexport const PartialConfigSchema = ConfigSchema.partial().describe(\n 'Partial destination configuration with all fields optional',\n);\n\n/**\n * Policy - Processing policy rules\n * Maps policy keys to transformation values\n * Applied before event mapping\n */\nexport const DestinationPolicySchema = PolicySchema.describe(\n 'Destination policy rules for event pre-processing',\n);\n\n// ========================================\n// Context Schemas\n// ========================================\n\n/**\n * Context - Base destination context\n * Passed to init and push functions\n * Contains collector instance, config, data, and environment\n *\n * Note: collector is runtime instance, not easily serializable\n */\nexport const ContextSchema = z\n .object({\n collector: z.unknown().describe('Collector instance (runtime object)'),\n config: ConfigSchema.describe('Destination configuration'),\n data: z\n .union([\n z.unknown(), // WalkerOS.Property\n z.array(z.unknown()),\n ])\n .optional()\n .describe('Transformed event data'),\n env: z.unknown().describe('Environment dependencies'),\n })\n .describe('Destination context for init and push functions');\n\n/**\n * PushContext - Context for push function\n * Extends Context with mapping rule information\n */\nexport const PushContextSchema = ContextSchema.extend({\n mapping: RuleSchema.optional().describe(\n 'Resolved mapping rule for this specific event',\n ),\n}).describe('Push context with event-specific mapping');\n\n/**\n * PushBatchContext - Context for pushBatch function\n * Same as PushContext but for batch processing\n */\nexport const PushBatchContextSchema = PushContextSchema.describe(\n 'Batch push context with event-specific mapping',\n);\n\n// ========================================\n// Batch Processing Schemas\n// ========================================\n\n/**\n * PushEvent - Single event with mapping in a batch\n */\nexport const PushEventSchema = z\n .object({\n event: EventSchema.describe('The event to process'),\n mapping: RuleSchema.optional().describe('Mapping rule for this event'),\n })\n .describe('Event with optional mapping for batch processing');\n\n/**\n * PushEvents - Array of PushEvent\n */\nexport const PushEventsSchema = z\n .array(PushEventSchema)\n .describe('Array of events with mappings');\n\n/**\n * Batch - Batched events for processing\n * Groups events by mapping key for efficient batch sends\n */\nexport const BatchSchema = z\n .object({\n key: z\n .string()\n .describe('Batch key (usually mapping key like \"product.view\")'),\n events: z.array(EventSchema).describe('Array of events in batch'),\n data: z\n .array(\n z\n .union([\n z.unknown(), // WalkerOS.Property\n z.array(z.unknown()),\n ])\n .optional(),\n )\n .describe('Transformed data for each event'),\n mapping: RuleSchema.optional().describe('Shared mapping rule for batch'),\n })\n .describe('Batch of events grouped by mapping key');\n\n/**\n * Data - Transformed event data types\n * Can be single property, undefined, or array of properties\n */\nexport const DataSchema = z\n .union([\n z.unknown(), // WalkerOS.Property\n z.array(z.unknown()),\n ])\n .optional()\n .describe('Transformed event data (Property, undefined, or array)');\n\n// ========================================\n// Instance Schemas\n// ========================================\n\n/**\n * Instance - Destination instance (runtime object)\n *\n * Note: This schema is primarily for documentation\n * Runtime functions (init, push, pushBatch) cannot be validated\n * Use z.unknown() for function fields\n */\nexport const InstanceSchema = z\n .object({\n config: ConfigSchema.describe('Destination configuration'),\n queue: z\n .array(EventSchema)\n .optional()\n .describe('Queued events awaiting consent'),\n dlq: z\n .array(z.tuple([EventSchema, z.unknown()]))\n .optional()\n .describe('Dead letter queue (failed events with errors)'),\n type: z.string().optional().describe('Destination type identifier'),\n env: z.unknown().optional().describe('Environment dependencies'),\n // Functions - not validated, use z.unknown()\n init: z.unknown().optional().describe('Initialization function'),\n push: z.unknown().describe('Push function for single events'),\n pushBatch: z.unknown().optional().describe('Batch push function'),\n on: z.unknown().optional().describe('Event lifecycle hook function'),\n })\n .describe('Destination instance (runtime object with functions)');\n\n/**\n * Init - Initialization config\n * Contains destination code and configuration\n */\nexport const InitSchema = z\n .object({\n code: InstanceSchema.describe('Destination instance with implementation'),\n config: PartialConfigSchema.optional().describe(\n 'Partial configuration overrides',\n ),\n env: z.unknown().optional().describe('Partial environment overrides'),\n })\n .describe('Destination initialization configuration');\n\n/**\n * InitDestinations - Map of destination IDs to Init configs\n */\nexport const InitDestinationsSchema = z\n .record(z.string(), InitSchema)\n .describe('Map of destination IDs to initialization configurations');\n\n/**\n * Destinations - Map of destination IDs to instances\n */\nexport const DestinationsSchema = z\n .record(z.string(), InstanceSchema)\n .describe('Map of destination IDs to runtime instances');\n\n// ========================================\n// Result Schemas\n// ========================================\n\n/**\n * Ref - Destination reference\n * Links destination ID to instance\n */\nexport const RefSchema = z\n .object({\n id: z.string().describe('Destination ID'),\n destination: InstanceSchema.describe('Destination instance'),\n })\n .describe('Destination reference (ID + instance)');\n\n/**\n * Push - Push operation result\n */\nexport const PushResultSchema = z\n .object({\n queue: z\n .array(EventSchema)\n .optional()\n .describe('Events queued (awaiting consent)'),\n error: z.unknown().optional().describe('Error if push failed'),\n })\n .describe('Push operation result');\n\n/**\n * Result - Overall processing result\n * Categorizes destinations by processing outcome\n */\nexport const ResultSchema = z\n .object({\n successful: z\n .array(RefSchema)\n .describe('Destinations that processed successfully'),\n queued: z.array(RefSchema).describe('Destinations that queued events'),\n failed: z.array(RefSchema).describe('Destinations that failed to process'),\n })\n .describe('Overall destination processing result');\n\n/**\n * DLQ - Dead Letter Queue\n * Array of failed events with their errors\n */\nexport const DLQSchema = z\n .array(z.tuple([EventSchema, z.unknown()]))\n .describe('Dead letter queue: [(event, error), ...]');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const configJsonSchema = toJsonSchema(ConfigSchema, 'DestinationConfig');\n\nexport const partialConfigJsonSchema = toJsonSchema(\n PartialConfigSchema,\n 'PartialDestinationConfig',\n);\n\nexport const contextJsonSchema = toJsonSchema(\n ContextSchema,\n 'DestinationContext',\n);\n\nexport const pushContextJsonSchema = toJsonSchema(\n PushContextSchema,\n 'PushContext',\n);\n\nexport const batchJsonSchema = toJsonSchema(BatchSchema, 'Batch');\n\nexport const instanceJsonSchema = toJsonSchema(\n InstanceSchema,\n 'DestinationInstance',\n);\n\nexport const resultJsonSchema = toJsonSchema(ResultSchema, 'DestinationResult');\n","import { z, toJsonSchema } from './validation';\nimport {\n ConsentSchema,\n UserSchema,\n PropertiesSchema,\n EventSchema,\n} from './walkeros';\nimport { ConfigSchema as MappingConfigSchema } from './mapping';\nimport {\n RequiredBoolean,\n RequiredNumber,\n Identifier,\n Timestamp,\n Counter,\n TaggingVersion,\n} from './primitives';\nimport { ErrorHandlerSchema, LogHandlerSchema } from './utilities';\n\n/**\n * Collector Schemas\n *\n * Mirrors: types/collector.ts\n * Purpose: Runtime validation and JSON Schema generation for collector configurations\n *\n * The collector is the central event processing engine in walkerOS:\n * - Receives events from sources\n * - Processes events with consent and context\n * - Routes events to destinations\n * - Manages session state and globals\n * - Handles lifecycle hooks\n *\n * This file defines schemas for collector configuration, commands, and state management.\n */\n\n// ========================================\n// Command Type Schema\n// ========================================\n\n/**\n * CommandType - Walker command identifiers\n *\n * Standard commands:\n * - action: TODO - need documentation\n * - config: Update collector configuration\n * - consent: Update consent state\n * - context: TODO - need documentation\n * - destination: Add/update destination\n * - elb: TODO - need documentation\n * - globals: Update global properties\n * - hook: Register lifecycle hook\n * - init: Initialize collector\n * - link: TODO - need documentation\n * - run: Start/restart collector with state\n * - user: Update user data\n * - walker: TODO - need documentation\n *\n * Extensible: allows custom command strings\n */\nexport const CommandTypeSchema = z\n .union([\n z.enum([\n 'action',\n 'config',\n 'consent',\n 'context',\n 'destination',\n 'elb',\n 'globals',\n 'hook',\n 'init',\n 'link',\n 'run',\n 'user',\n 'walker',\n ]),\n z.string(), // Allow custom commands\n ])\n .describe(\n 'Collector command type: standard commands or custom string for extensions',\n );\n\n// ========================================\n// Configuration Schemas\n// ========================================\n\n/**\n * Config - Core collector configuration\n *\n * Controls collector behavior:\n * - run: Auto-run on initialization\n * - tagging: Version number for event tagging\n * - globalsStatic: Static globals (persist across runs)\n * - sessionStatic: Static session data (persist across runs)\n * - verbose: Enable verbose logging\n * - onError: Error handler\n * - onLog: Log handler\n */\nexport const ConfigSchema = z\n .object({\n run: z\n .boolean()\n .describe('Whether to run collector automatically on initialization')\n .optional(),\n tagging: TaggingVersion,\n globalsStatic: PropertiesSchema.describe(\n 'Static global properties that persist across collector runs',\n ),\n sessionStatic: z\n .record(z.string(), z.unknown())\n .describe('Static session data that persists across collector runs'),\n verbose: z.boolean().describe('Enable verbose logging for debugging'),\n // Function handlers\n onError: ErrorHandlerSchema.optional(),\n onLog: LogHandlerSchema.optional(),\n })\n .describe('Core collector configuration');\n\n/**\n * SessionData - Session state management\n *\n * Tracks session-level information:\n * - IDs and lifecycle\n * - Storage state\n * - Marketing tracking\n * - Timestamps\n * - Counters\n *\n * Extends Properties to allow custom session data\n */\nexport const SessionDataSchema = PropertiesSchema.and(\n z.object({\n isStart: z.boolean().describe('Whether this is a new session start'),\n storage: z.boolean().describe('Whether storage is available'),\n id: Identifier.describe('Session identifier').optional(),\n start: Timestamp.describe('Session start timestamp').optional(),\n marketing: z\n .literal(true)\n .optional()\n .describe('Marketing attribution flag'),\n updated: Timestamp.describe('Last update timestamp').optional(),\n isNew: z.boolean().describe('Whether this is a new session').optional(),\n device: Identifier.describe('Device identifier').optional(),\n count: Counter.describe('Event count in session').optional(),\n runs: Counter.describe('Number of runs').optional(),\n }),\n).describe('Session state and tracking data');\n\n/**\n * InitConfig - Initialization configuration\n *\n * Extends Config with initial state:\n * - Initial consent\n * - Initial user data\n * - Initial globals\n * - Source configurations\n * - Destination configurations\n * - Initial custom properties\n */\nexport const InitConfigSchema = ConfigSchema.partial()\n .extend({\n consent: ConsentSchema.optional().describe('Initial consent state'),\n user: UserSchema.optional().describe('Initial user data'),\n globals: PropertiesSchema.optional().describe('Initial global properties'),\n // Sources and destinations are complex runtime objects\n sources: z.unknown().optional().describe('Source configurations'),\n destinations: z.unknown().optional().describe('Destination configurations'),\n custom: PropertiesSchema.optional().describe(\n 'Initial custom implementation-specific properties',\n ),\n })\n .describe('Collector initialization configuration with initial state');\n\n// ========================================\n// Context Schemas\n// ========================================\n\n/**\n * PushContext - Context for collector.push\n *\n * Provides source-level mapping configuration\n * Applied before destination-specific mappings\n */\nexport const PushContextSchema = z\n .object({\n mapping: MappingConfigSchema.optional().describe(\n 'Source-level mapping configuration',\n ),\n })\n .describe('Push context with optional source mapping');\n\n// ========================================\n// Collection Schemas\n// ========================================\n\n/**\n * Sources - Map of source IDs to instances\n */\nexport const SourcesSchema = z\n .record(z.string(), z.unknown())\n .describe('Map of source IDs to source instances');\n\n/**\n * Destinations - Map of destination IDs to instances\n */\nexport const DestinationsSchema = z\n .record(z.string(), z.unknown())\n .describe('Map of destination IDs to destination instances');\n\n// ========================================\n// Instance Schema\n// ========================================\n\n/**\n * Instance - Collector instance (runtime object)\n *\n * The main collector interface with all state and methods\n *\n * State:\n * - config: Current configuration\n * - consent: Current consent state\n * - user: Current user data\n * - globals: Current global properties\n * - custom: Custom properties\n * - session: Session state\n * - sources: Registered sources\n * - destinations: Registered destinations\n * - hooks: Lifecycle hooks\n * - on: Event lifecycle config\n * - queue: Queued events\n *\n * Flags:\n * - allowed: Processing allowed\n * - count: Event count\n * - round: Collector run count\n * - timing: Processing timing\n * - group: Event grouping ID\n *\n * Methods (not validated):\n * - push: Process events\n * - command: Execute commands\n */\nexport const InstanceSchema = z\n .object({\n // Methods (functions - not validated)\n push: z.unknown().describe('Push function for processing events'),\n command: z.unknown().describe('Command function for walker commands'),\n // State\n allowed: z.boolean().describe('Whether event processing is allowed'),\n config: ConfigSchema.describe('Current collector configuration'),\n consent: ConsentSchema.describe('Current consent state'),\n count: z.number().describe('Event count (increments with each event)'),\n custom: PropertiesSchema.describe(\n 'Custom implementation-specific properties',\n ),\n sources: SourcesSchema.describe('Registered source instances'),\n destinations: DestinationsSchema.describe(\n 'Registered destination instances',\n ),\n globals: PropertiesSchema.describe('Current global properties'),\n group: z.string().describe('Event grouping identifier'),\n hooks: z.unknown().describe('Lifecycle hook functions'),\n on: z.unknown().describe('Event lifecycle configuration'),\n queue: z.array(EventSchema).describe('Queued events awaiting processing'),\n round: z\n .number()\n .describe('Collector run count (increments with each run)'),\n session: z.union([SessionDataSchema]).describe('Current session state'),\n timing: z.number().describe('Event processing timing information'),\n user: UserSchema.describe('Current user data'),\n version: z.string().describe('Walker implementation version'),\n })\n .describe('Collector instance with state and methods');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const commandTypeJsonSchema = toJsonSchema(\n CommandTypeSchema,\n 'CommandType',\n);\n\nexport const configJsonSchema = toJsonSchema(ConfigSchema, 'CollectorConfig');\n\nexport const sessionDataJsonSchema = toJsonSchema(\n SessionDataSchema,\n 'SessionData',\n);\n\nexport const initConfigJsonSchema = toJsonSchema(\n InitConfigSchema,\n 'InitConfig',\n);\n\nexport const pushContextJsonSchema = toJsonSchema(\n PushContextSchema,\n 'CollectorPushContext',\n);\n\nexport const instanceJsonSchema = toJsonSchema(\n InstanceSchema,\n 'CollectorInstance',\n);\n","import { z, toJsonSchema } from './validation';\nimport { ConfigSchema as MappingConfigSchema } from './mapping';\nimport { Identifier } from './primitives';\nimport { ErrorHandlerSchema } from './utilities';\n\n/**\n * Source Schemas\n *\n * Mirrors: types/source.ts\n * Purpose: Runtime validation and JSON Schema generation for source configurations\n *\n * Sources are the entry points where events enter walkerOS:\n * - Browser sources (DOM events, dataLayer)\n * - Server sources (HTTP handlers, cloud functions)\n * - App sources (mobile, desktop)\n *\n * Sources are platform-agnostic through dependency injection via BaseEnv.\n * All platform-specific dependencies (DOM, HTTP, etc.) are provided through\n * the env object, making sources testable and portable.\n *\n * Key concept: Source.push IS the handler - no wrappers needed\n * Example: http('handler', source.push) for direct deployment\n */\n\n// ========================================\n// Environment Schema\n// ========================================\n\n/**\n * BaseEnv - Base environment interface for dependency injection\n *\n * Sources receive all dependencies through this environment object:\n * - push: Collector push function\n * - command: Collector command function\n * - sources: Other registered sources\n * - elb: Public API function (alias for collector.push)\n *\n * Platform-specific sources extend this with their requirements\n * (e.g., window, document, fetch, req, res)\n *\n * This makes sources:\n * - Platform-agnostic (no direct dependencies)\n * - Testable (mock env for tests)\n * - Composable (share env between sources)\n */\nexport const BaseEnvSchema = z\n .object({\n push: z.unknown().describe('Collector push function'),\n command: z.unknown().describe('Collector command function'),\n sources: z\n .unknown()\n .optional()\n .describe('Map of registered source instances'),\n elb: z.unknown().describe('Public API function (alias for collector.push)'),\n })\n .catchall(z.unknown())\n .describe(\n 'Base environment for dependency injection - platform-specific sources extend this',\n );\n\n// ========================================\n// Configuration Schema\n// ========================================\n\n/**\n * Config - Source configuration\n *\n * Extends Mapping.Config with source-specific options:\n * - consent: Required consent to process events\n * - data: Global data transformations\n * - mapping: Entity-action mapping rules\n * - policy: Pre-processing policies\n * - settings: Source-specific settings\n * - env: Environment dependencies\n * - id: Source identifier\n * - onError: Error handler\n * - disabled: Disable source\n * - primary: Primary source flag (only one can be primary)\n *\n * Generic note: settings, env, and mapping can have source-specific types\n */\nexport const ConfigSchema = MappingConfigSchema.extend({\n settings: z\n .any()\n .describe('Implementation-specific configuration')\n .optional(),\n env: BaseEnvSchema.optional().describe(\n 'Environment dependencies (platform-specific)',\n ),\n id: Identifier.describe(\n 'Source identifier (defaults to source key)',\n ).optional(),\n onError: ErrorHandlerSchema.optional(),\n disabled: z.boolean().describe('Set to true to disable').optional(),\n primary: z\n .boolean()\n .describe('Mark as primary (only one can be primary)')\n .optional(),\n}).describe('Source configuration with mapping and environment');\n\n/**\n * PartialConfig - Config with all fields optional\n * Used for config updates and overrides\n *\n * Note: ConfigSchema extends MappingConfigSchema with mostly optional fields.\n * Using .partial() ensures all fields are optional for config updates.\n */\nexport const PartialConfigSchema = ConfigSchema.partial().describe(\n 'Partial source configuration with all fields optional',\n);\n\n// ========================================\n// Instance Schema\n// ========================================\n\n/**\n * Instance - Source instance (runtime object)\n *\n * Contains:\n * - type: Source type identifier\n * - config: Current configuration\n * - push: Push function (THE HANDLER)\n * - destroy: Cleanup function\n * - on: Lifecycle hook function\n *\n * Key concept: push IS the handler\n * The push function signature is flexible to support different platforms:\n * - Browser: push(event, data) => Promise<void>\n * - HTTP: push(req, res) => Promise<void>\n * - Cloud: push(event, context) => Promise<void>\n *\n * This flexibility allows direct deployment without wrappers:\n * - http.createServer(source.push)\n * - functions.https.onRequest(source.push)\n * - addEventListener('click', source.push)\n */\nexport const InstanceSchema = z\n .object({\n type: z\n .string()\n .describe('Source type identifier (e.g., \"browser\", \"dataLayer\")'),\n config: ConfigSchema.describe('Current source configuration'),\n // Push function - flexible signature, not validated\n push: z\n .any()\n .describe(\n 'Push function - THE HANDLER (flexible signature for platform compatibility)',\n ),\n // Optional lifecycle methods\n destroy: z\n .any()\n .optional()\n .describe('Cleanup function called when source is removed'),\n on: z\n .unknown()\n .optional()\n .describe('Lifecycle hook function for event types'),\n })\n .describe('Source instance with push handler and lifecycle methods');\n\n// ========================================\n// Initialization Schemas\n// ========================================\n\n/**\n * Init - Source initialization function\n *\n * Factory function that creates a source instance:\n * (config, env) => Instance | Promise<Instance>\n *\n * Receives:\n * - config: Partial configuration\n * - env: Environment dependencies\n *\n * Returns:\n * - Source instance with push function\n *\n * The init function sets up the source (e.g., attach DOM listeners,\n * start HTTP server, subscribe to events) and returns the instance.\n */\nexport const InitSchema = z\n .any()\n .describe(\n 'Source initialization function: (config, env) => Instance | Promise<Instance>',\n );\n\n/**\n * InitSource - Initialization configuration\n *\n * Contains:\n * - code: Init function\n * - config: Partial config overrides\n * - env: Partial env overrides\n * - primary: Primary source flag\n */\nexport const InitSourceSchema = z\n .object({\n code: InitSchema.describe('Source initialization function'),\n config: PartialConfigSchema.optional().describe(\n 'Partial configuration overrides',\n ),\n env: BaseEnvSchema.partial()\n .optional()\n .describe('Partial environment overrides'),\n primary: z\n .boolean()\n .optional()\n .describe('Mark as primary source (only one can be primary)'),\n })\n .describe('Source initialization configuration');\n\n/**\n * InitSources - Map of source IDs to init configs\n */\nexport const InitSourcesSchema = z\n .record(z.string(), InitSourceSchema)\n .describe('Map of source IDs to initialization configurations');\n\n// ========================================\n// JSON Schema Exports (for Explorer/RJSF/MCP)\n// ========================================\n\nexport const baseEnvJsonSchema = toJsonSchema(BaseEnvSchema, 'SourceBaseEnv');\n\nexport const configJsonSchema = toJsonSchema(ConfigSchema, 'SourceConfig');\n\nexport const partialConfigJsonSchema = toJsonSchema(\n PartialConfigSchema,\n 'PartialSourceConfig',\n);\n\nexport const instanceJsonSchema = toJsonSchema(\n InstanceSchema,\n 'SourceInstance',\n);\n\nexport const initSourceJsonSchema = toJsonSchema(\n InitSourceSchema,\n 'InitSource',\n);\n\nexport const initSourcesJsonSchema = toJsonSchema(\n InitSourcesSchema,\n 'InitSources',\n);\n","/**\n * Flow Configuration System - Zod Schemas\n *\n * Mirrors: types/flow.ts\n * Purpose: Runtime validation and JSON Schema generation for Flow configurations\n *\n * The Flow system provides unified configuration across all walkerOS environments.\n * These schemas enable:\n * - Runtime validation of config files\n * - Clear error messages for configuration issues\n * - JSON Schema generation for IDE support\n * - Type-safe parsing with Zod\n *\n * @packageDocumentation\n */\n\nimport { z, toJsonSchema, zodToJsonSchema } from './validation';\n\n// ========================================\n// Primitive Type Schemas\n// ========================================\n\n/**\n * Primitive value schema for variables.\n *\n * @remarks\n * Variables can be strings, numbers, or booleans.\n * Used in Setup.variables and Config.env.\n */\nexport const PrimitiveSchema = z\n .union([z.string(), z.number(), z.boolean()])\n .describe('Primitive value: string, number, or boolean');\n\n// ========================================\n// Source Reference Schema\n// ========================================\n\n/**\n * Source reference schema.\n *\n * @remarks\n * Defines how to reference and configure a source package.\n * Sources capture events from various origins (browser, HTTP, etc.).\n */\nexport const SourceReferenceSchema = z\n .object({\n package: z\n .string()\n .min(1, 'Package name cannot be empty')\n .describe(\n 'Package specifier with optional version (e.g., \"@walkeros/web-source-browser@2.0.0\")',\n ),\n config: z\n .unknown()\n .optional()\n .describe('Source-specific configuration object'),\n env: z.unknown().optional().describe('Source environment configuration'),\n primary: z\n .boolean()\n .optional()\n .describe(\n 'Mark as primary source (provides main elb). Only one source should be primary.',\n ),\n })\n .describe('Source package reference with configuration');\n\n// ========================================\n// Destination Reference Schema\n// ========================================\n\n/**\n * Destination reference schema.\n *\n * @remarks\n * Defines how to reference and configure a destination package.\n * Destinations send processed events to external services.\n */\nexport const DestinationReferenceSchema = z\n .object({\n package: z\n .string()\n .min(1, 'Package name cannot be empty')\n .describe(\n 'Package specifier with optional version (e.g., \"@walkeros/web-destination-gtag@2.0.0\")',\n ),\n config: z\n .unknown()\n .optional()\n .describe('Destination-specific configuration object'),\n env: z\n .unknown()\n .optional()\n .describe('Destination environment configuration'),\n })\n .describe('Destination package reference with configuration');\n\n// ========================================\n// Flow Environment Configuration Schema\n// ========================================\n\n/**\n * Flow environment configuration schema.\n *\n * @remarks\n * Represents a single deployment environment (e.g., web_prod, server_stage).\n * Uses `.passthrough()` to allow package-specific extensions (build, docker, etc.).\n */\nexport const ConfigSchema = z\n .object({\n platform: z\n .enum(['web', 'server'], {\n error: 'Platform must be \"web\" or \"server\"',\n })\n .describe(\n 'Target platform: \"web\" for browser-based tracking, \"server\" for Node.js server-side collection',\n ),\n sources: z\n .record(z.string(), SourceReferenceSchema)\n .optional()\n .describe(\n 'Source configurations (data capture) keyed by unique identifier',\n ),\n destinations: z\n .record(z.string(), DestinationReferenceSchema)\n .optional()\n .describe(\n 'Destination configurations (data output) keyed by unique identifier',\n ),\n collector: z\n .unknown()\n .optional()\n .describe(\n 'Collector configuration for event processing (uses Collector.InitConfig)',\n ),\n env: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Environment-specific variables (override root-level variables)',\n ),\n })\n .passthrough() // Allow extension fields (build, docker, lambda, etc.)\n .describe('Single environment configuration for one deployment target');\n\n// ========================================\n// Flow Setup Schema (Root Configuration)\n// ========================================\n\n/**\n * Flow setup schema - root configuration.\n *\n * @remarks\n * This is the complete schema for walkeros.config.json files.\n * Contains multiple named environments with shared variables and definitions.\n */\nexport const SetupSchema = z\n .object({\n version: z\n .literal(1, {\n error: 'Only version 1 is currently supported',\n })\n .describe('Configuration schema version (currently only 1 is supported)'),\n $schema: z\n .string()\n .url('Schema URL must be a valid URL')\n .optional()\n .describe(\n 'JSON Schema reference for IDE validation (e.g., \"https://walkeros.io/schema/flow/v1.json\")',\n ),\n variables: z\n .record(z.string(), PrimitiveSchema)\n .optional()\n .describe(\n 'Shared variables for interpolation across all environments (use ${VAR_NAME:default} syntax)',\n ),\n definitions: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n 'Reusable configuration definitions (reference with JSON Schema $ref syntax)',\n ),\n environments: z\n .record(z.string(), ConfigSchema)\n .refine((envs) => Object.keys(envs).length > 0, {\n message: 'At least one environment is required',\n })\n .describe(\n 'Named environment configurations (e.g., web_prod, server_stage)',\n ),\n })\n .describe(\n 'Complete multi-environment walkerOS configuration (walkeros.config.json)',\n );\n\n// ========================================\n// Helper Functions\n// ========================================\n\n/**\n * Parse and validate Flow.Setup configuration.\n *\n * @param data - Raw JSON data from config file\n * @returns Validated Flow.Setup object\n * @throws ZodError if validation fails with detailed error messages\n *\n * @example\n * ```typescript\n * import { parseSetup } from '@walkeros/core/schemas';\n * import { readFileSync } from 'fs';\n *\n * const raw = JSON.parse(readFileSync('walkeros.config.json', 'utf8'));\n * const config = parseSetup(raw);\n * console.log(`Found ${Object.keys(config.environments).length} environments`);\n * ```\n */\nexport function parseSetup(data: unknown): z.infer<typeof SetupSchema> {\n return SetupSchema.parse(data);\n}\n\n/**\n * Safely parse Flow.Setup configuration without throwing.\n *\n * @param data - Raw JSON data from config file\n * @returns Success result with data or error result with issues\n *\n * @example\n * ```typescript\n * import { safeParseSetup } from '@walkeros/core/schemas';\n *\n * const result = safeParseSetup(rawData);\n * if (result.success) {\n * console.log('Valid config:', result.data);\n * } else {\n * console.error('Validation errors:', result.error.issues);\n * }\n * ```\n */\nexport function safeParseSetup(data: unknown) {\n return SetupSchema.safeParse(data);\n}\n\n/**\n * Parse and validate Flow.Config (single environment).\n *\n * @param data - Raw JSON data for single environment\n * @returns Validated Flow.Config object\n * @throws ZodError if validation fails\n *\n * @example\n * ```typescript\n * import { parseConfig } from '@walkeros/core/schemas';\n *\n * const envConfig = parseConfig(rawEnvData);\n * console.log(`Platform: ${envConfig.platform}`);\n * ```\n */\nexport function parseConfig(data: unknown): z.infer<typeof ConfigSchema> {\n return ConfigSchema.parse(data);\n}\n\n/**\n * Safely parse Flow.Config without throwing.\n *\n * @param data - Raw JSON data for single environment\n * @returns Success result with data or error result with issues\n */\nexport function safeParseConfig(data: unknown) {\n return ConfigSchema.safeParse(data);\n}\n\n// ========================================\n// JSON Schema Generation\n// ========================================\n\n/**\n * Generate JSON Schema for Flow.Setup.\n *\n * @remarks\n * Used for IDE validation and autocomplete.\n * Hosted at https://walkeros.io/schema/flow/v1.json\n *\n * @returns JSON Schema (Draft 7) representation of SetupSchema\n *\n * @example\n * ```typescript\n * import { setupJsonSchema } from '@walkeros/core/schemas';\n * import { writeFileSync } from 'fs';\n *\n * writeFileSync(\n * 'public/schema/flow/v1.json',\n * JSON.stringify(setupJsonSchema, null, 2)\n * );\n * ```\n */\nexport const setupJsonSchema = z.toJSONSchema(SetupSchema, {\n target: 'draft-7',\n});\n\n/**\n * Generate JSON Schema for Flow.Config.\n *\n * @remarks\n * Used for validating individual environment configurations.\n *\n * @returns JSON Schema (Draft 7) representation of ConfigSchema\n */\nexport const configJsonSchema = toJsonSchema(ConfigSchema, 'FlowConfig');\n\n/**\n * Generate JSON Schema for SourceReference.\n *\n * @remarks\n * Used for validating source package references.\n *\n * @returns JSON Schema (Draft 7) representation of SourceReferenceSchema\n */\nexport const sourceReferenceJsonSchema = toJsonSchema(\n SourceReferenceSchema,\n 'SourceReference',\n);\n\n/**\n * Generate JSON Schema for DestinationReference.\n *\n * @remarks\n * Used for validating destination package references.\n *\n * @returns JSON Schema (Draft 7) representation of DestinationReferenceSchema\n */\nexport const destinationReferenceJsonSchema = toJsonSchema(\n DestinationReferenceSchema,\n 'DestinationReference',\n);\n","/**\n * JSON Schema type\n */\nexport type JSONSchema = Record<string, unknown>;\n\n/**\n * Schema Builder - DRY utility for creating JSON Schemas\n *\n * This utility allows destinations to define schemas using simple objects,\n * without needing Zod as a dependency. The core package handles conversion.\n *\n * Benefits:\n * - Single source of schema generation logic\n * - No Zod dependency in destination packages\n * - Simple, declarative schema definitions\n * - Type-safe with TypeScript\n * - Follows DRY principle\n *\n * @example\n * // In destination package (NO Zod needed!)\n * import { createObjectSchema, createArraySchema } from '@walkeros/core/schemas';\n *\n * export const settingsSchema = createObjectSchema({\n * pixelId: {\n * type: 'string',\n * required: true,\n * pattern: '^[0-9]+$',\n * description: 'Your Meta Pixel ID',\n * },\n * });\n */\n\n/**\n * Property definition for schema builder\n */\nexport interface PropertyDef {\n type: 'string' | 'number' | 'boolean' | 'object' | 'array';\n required?: boolean;\n description?: string;\n pattern?: string;\n minLength?: number;\n maxLength?: number;\n minimum?: number;\n maximum?: number;\n enum?: readonly string[] | readonly number[];\n properties?: Record<string, PropertyDef>;\n items?: PropertyDef;\n default?: unknown;\n}\n\n/**\n * Create object schema from property definitions\n *\n * @param properties - Property definitions\n * @param title - Optional schema title\n * @returns JSON Schema\n *\n * @example\n * const schema = createObjectSchema({\n * pixelId: {\n * type: 'string',\n * required: true,\n * pattern: '^[0-9]+$',\n * description: 'Your Meta Pixel ID',\n * },\n * eventName: {\n * type: 'string',\n * enum: ['PageView', 'Purchase'],\n * },\n * }, 'Meta Pixel Settings');\n */\nexport function createObjectSchema(\n properties: Record<string, PropertyDef>,\n title?: string,\n): JSONSchema {\n const required: string[] = [];\n const schemaProperties: Record<string, unknown> = {};\n\n for (const [key, def] of Object.entries(properties)) {\n if (def.required) {\n required.push(key);\n }\n\n const property: Record<string, unknown> = {\n type: def.type,\n };\n\n if (def.description) property.description = def.description;\n if (def.pattern) property.pattern = def.pattern;\n if (def.minLength !== undefined) property.minLength = def.minLength;\n if (def.maxLength !== undefined) property.maxLength = def.maxLength;\n if (def.minimum !== undefined) property.minimum = def.minimum;\n if (def.maximum !== undefined) property.maximum = def.maximum;\n if (def.enum) property.enum = [...def.enum];\n if (def.default !== undefined) property.default = def.default;\n\n // Nested object\n if (def.type === 'object' && def.properties) {\n const props: Record<string, unknown> = {};\n for (const [nestedKey, nestedDef] of Object.entries(def.properties)) {\n props[nestedKey] = createPropertySchema(nestedDef);\n }\n property.properties = props;\n }\n\n // Array\n if (def.type === 'array' && def.items) {\n property.items = createPropertySchema(def.items);\n }\n\n schemaProperties[key] = property;\n }\n\n const schema: JSONSchema = {\n type: 'object',\n properties: schemaProperties,\n };\n\n if (title) schema.title = title;\n if (required.length > 0) schema.required = required;\n\n return schema;\n}\n\n/**\n * Create property schema from definition\n * Helper for nested properties\n */\nfunction createPropertySchema(def: PropertyDef): Record<string, unknown> {\n const property: Record<string, unknown> = {\n type: def.type,\n };\n\n if (def.description) property.description = def.description;\n if (def.pattern) property.pattern = def.pattern;\n if (def.minLength !== undefined) property.minLength = def.minLength;\n if (def.maxLength !== undefined) property.maxLength = def.maxLength;\n if (def.minimum !== undefined) property.minimum = def.minimum;\n if (def.maximum !== undefined) property.maximum = def.maximum;\n if (def.enum) property.enum = [...def.enum];\n if (def.default !== undefined) property.default = def.default;\n\n // Nested object\n if (def.type === 'object' && def.properties) {\n const props: Record<string, unknown> = {};\n for (const [key, nestedDef] of Object.entries(def.properties)) {\n props[key] = createPropertySchema(nestedDef);\n }\n property.properties = props;\n }\n\n // Array\n if (def.type === 'array' && def.items) {\n property.items = createPropertySchema(def.items);\n }\n\n return property;\n}\n\n/**\n * Create array schema\n *\n * @param itemDef - Definition for array items\n * @param options - Optional array constraints\n * @returns JSON Schema\n *\n * @example\n * // Simple string array\n * const tagsSchema = createArraySchema({ type: 'string' });\n *\n * // Tuple (loop pattern) - exactly 2 items\n * const loopSchema = createArraySchema(\n * { type: 'object' },\n * { minItems: 2, maxItems: 2 }\n * );\n *\n * // Array with enum\n * const includeSchema = createArraySchema({\n * type: 'string',\n * enum: ['data', 'context', 'globals'],\n * });\n */\nexport function createArraySchema(\n itemDef: PropertyDef,\n options?: {\n minItems?: number;\n maxItems?: number;\n description?: string;\n title?: string;\n },\n): JSONSchema {\n const schema: JSONSchema = {\n type: 'array',\n items: createPropertySchema(itemDef),\n };\n\n if (options?.minItems !== undefined) schema.minItems = options.minItems;\n if (options?.maxItems !== undefined) schema.maxItems = options.maxItems;\n if (options?.description) schema.description = options.description;\n if (options?.title) schema.title = options.title;\n\n return schema;\n}\n\n/**\n * Create enum schema\n *\n * @param values - Allowed values\n * @param type - Value type ('string' or 'number')\n * @param options - Optional constraints\n * @returns JSON Schema\n *\n * @example\n * const eventTypeSchema = createEnumSchema(\n * ['PageView', 'Purchase', 'AddToCart'],\n * 'string',\n * { description: 'Meta Pixel standard event' }\n * );\n */\nexport function createEnumSchema(\n values: readonly string[] | readonly number[],\n type: 'string' | 'number' = 'string',\n options?: {\n description?: string;\n title?: string;\n },\n): JSONSchema {\n const schema: JSONSchema = {\n type,\n enum: [...values],\n };\n\n if (options?.description) schema.description = options.description;\n if (options?.title) schema.title = options.title;\n\n return schema;\n}\n\n/**\n * Create tuple schema (Loop pattern)\n *\n * Creates an array schema with exactly 2 items, which the Explorer\n * type detector recognizes as a \"loop\" pattern.\n *\n * @param firstItem - Definition for first element (source)\n * @param secondItem - Definition for second element (transform)\n * @param description - Optional description\n * @returns JSON Schema with minItems=2, maxItems=2\n *\n * @example\n * const loopSchema = createTupleSchema(\n * { type: 'string' },\n * { type: 'object' },\n * 'Loop: [source, transform]'\n * );\n */\nexport function createTupleSchema(\n firstItem: PropertyDef,\n secondItem: PropertyDef,\n description?: string,\n): JSONSchema {\n return createArraySchema(\n { type: 'object' }, // Generic, items can be different\n {\n minItems: 2,\n maxItems: 2,\n description:\n description || 'Tuple with exactly 2 elements [source, transform]',\n },\n );\n}\n","/**\n * walkerOS Core Schemas\n *\n * Zod schemas for runtime validation and JSON Schema generation.\n * These schemas mirror TypeScript types in packages/core/src/types/\n * and are used for:\n * - Runtime validation at system boundaries (MCP tools, APIs, CLI)\n * - JSON Schema generation for Explorer UI (RJSF)\n * - Documentation and type metadata\n *\n * Note: TypeScript types remain the source of truth for development.\n * Schemas are for runtime validation and tooling support.\n *\n * Organization: Schema files mirror type files\n * - types/walkeros.ts → schemas/walkeros.ts\n * - types/mapping.ts → schemas/mapping.ts\n * - types/destination.ts → schemas/destination.ts\n * - types/collector.ts → schemas/collector.ts\n * - types/source.ts → schemas/source.ts\n * - types/flow.ts → schemas/flow.ts\n * - types/storage.ts + types/handler.ts → schemas/utilities.ts\n *\n * Import strategy:\n * Due to overlapping schema names across domains (ConfigSchema, InstanceSchema, etc.),\n * schemas are organized into namespaces. Import either:\n * 1. From namespaces: import { WalkerOSSchemas, MappingSchemas } from '@walkeros/core/schemas'\n * 2. Direct from files: import { EventSchema } from '@walkeros/core/schemas/walkeros'\n */\n\n// ========================================\n// Primitives & Patterns (DRY building blocks)\n// ========================================\n\nexport * from './primitives';\nexport * from './patterns';\n\n// ========================================\n// Namespace Exports (prevents name collisions)\n// ========================================\n\nimport * as WalkerOSSchemas from './walkeros';\nimport * as MappingSchemas from './mapping';\nimport * as DestinationSchemas from './destination';\nimport * as CollectorSchemas from './collector';\nimport * as SourceSchemas from './source';\nimport * as FlowSchemas from './flow';\nimport * as UtilitySchemas from './utilities';\n\nexport {\n WalkerOSSchemas,\n MappingSchemas,\n DestinationSchemas,\n CollectorSchemas,\n SourceSchemas,\n FlowSchemas,\n UtilitySchemas,\n};\n\n// ========================================\n// Direct Exports (commonly used schemas)\n// ========================================\n\n// Export commonly used schemas from WalkerOS namespace directly\nexport {\n EventSchema,\n PartialEventSchema,\n DeepPartialEventSchema,\n PropertiesSchema,\n OrderedPropertiesSchema,\n UserSchema,\n EntitySchema,\n EntitiesSchema,\n ConsentSchema,\n SourceTypeSchema,\n VersionSchema,\n SourceSchema,\n PropertySchema,\n PropertyTypeSchema,\n // JSON Schemas\n eventJsonSchema,\n partialEventJsonSchema,\n userJsonSchema,\n propertiesJsonSchema,\n orderedPropertiesJsonSchema,\n entityJsonSchema,\n sourceTypeJsonSchema,\n consentJsonSchema,\n} from './walkeros';\n\n// Export commonly used schemas from Mapping namespace directly\nexport {\n ValueSchema,\n ValuesSchema,\n ValueConfigSchema,\n LoopSchema,\n SetSchema,\n MapSchema,\n PolicySchema,\n RuleSchema,\n RulesSchema,\n ResultSchema as MappingResultSchema, // Alias to avoid conflict with Destination.ResultSchema\n // JSON Schemas\n valueJsonSchema,\n valueConfigJsonSchema,\n loopJsonSchema,\n setJsonSchema,\n mapJsonSchema,\n policyJsonSchema,\n ruleJsonSchema,\n rulesJsonSchema,\n} from './mapping';\n\n// Export commonly used schemas from Flow namespace directly\nexport {\n SetupSchema,\n ConfigSchema as FlowConfigSchema, // Alias to avoid conflict with other ConfigSchema exports\n SourceReferenceSchema,\n DestinationReferenceSchema,\n PrimitiveSchema,\n parseSetup,\n safeParseSetup,\n parseConfig,\n safeParseConfig,\n // JSON Schemas\n setupJsonSchema,\n configJsonSchema,\n sourceReferenceJsonSchema,\n destinationReferenceJsonSchema,\n} from './flow';\n\n// ========================================\n// Schema Builder - DRY utility for destinations\n// ========================================\n\n/**\n * Schema Builder - DRY utility for destinations\n *\n * Destinations can use these utilities to create JSON Schemas WITHOUT\n * needing Zod as a dependency. The core package handles all schema logic.\n *\n * This follows the DRY principle - write once in core, use everywhere.\n */\nexport * from './schema-builder';\n\n// ========================================\n// Deprecated: value-config.ts\n// ========================================\n\n/**\n * @deprecated Import from MappingSchemas or directly from './mapping' instead\n *\n * The value-config.ts file has been migrated to mapping.ts for better organization.\n * This export is kept for backward compatibility but will be removed in a future version.\n *\n * Migration:\n * - Old: import { ValueSchema, ValueConfigSchema } from '@walkeros/core'\n * - New: import { ValueSchema, ValueConfigSchema } from '@walkeros/core'\n * (imports now come from mapping.ts but the API is identical)\n *\n * Breaking change: The value-config.ts file will be removed in the next major version.\n * All schemas are now organized by domain (mapping, destination, collector, etc.)\n */\n// Note: Schemas are already exported above from mapping.ts\n\n/**\n * Re-export Zod and zod-to-json-schema for destinations\n *\n * Destinations can import Zod from @walkeros/core instead of adding\n * their own dependency. This ensures version consistency and reduces\n * duplicate dependencies in the monorepo.\n *\n * Usage in destinations:\n * import { z, zodToJsonSchema, zodToSchema } from '@walkeros/core';\n */\nexport { z, zodToJsonSchema } from './validation';\n\nimport type { zod } from './validation';\nimport { z, zodToJsonSchema } from './validation';\n\n/**\n * JSONSchema type for JSON Schema Draft 7 objects\n *\n * Represents a JSON Schema object as returned by Zod's toJSONSchema().\n * Uses Record<string, unknown> as JSON Schema structure is dynamic.\n */\nexport type JSONSchema = Record<string, unknown>;\n\n/**\n * Utility to convert Zod schema to JSON Schema with consistent defaults\n *\n * This wrapper ensures all destinations use the same JSON Schema configuration:\n * - target: 'draft-7' (JSON Schema Draft 7 format)\n *\n * Usage in destinations:\n * import { zodToSchema } from '@walkeros/core';\n * export const settings = zodToSchema(SettingsSchema);\n *\n * @param schema - Zod schema to convert\n * @returns JSON Schema Draft 7 object\n */\nexport function zodToSchema(schema: zod.ZodTypeAny): JSONSchema {\n return z.toJSONSchema(schema, {\n target: 'draft-7',\n }) as JSONSchema;\n}\n","/**\n * Anonymizes an IPv4 address by setting the last octet to 0.\n *\n * @param ip The IP address to anonymize.\n * @returns The anonymized IP address or an empty string if the IP is invalid.\n */\nexport function anonymizeIP(ip: string): string {\n const ipv4Pattern = /^(?:\\d{1,3}\\.){3}\\d{1,3}$/;\n\n if (!ipv4Pattern.test(ip)) return '';\n\n return ip.replace(/\\.\\d+$/, '.0'); // Set the last octet to 0\n}\n","/**\n * @interface Assign\n * @description Options for the assign function.\n * @property merge - Merge array properties instead of overriding them.\n * @property shallow - Create a shallow copy instead of updating the target object.\n * @property extend - Extend the target with new properties instead of only updating existing ones.\n */\ninterface Assign {\n merge?: boolean;\n shallow?: boolean;\n extend?: boolean;\n}\n\nconst defaultOptions: Assign = {\n merge: true,\n shallow: true,\n extend: true,\n};\n\n/**\n * Merges objects with advanced options.\n *\n * @template T, U\n * @param target - The target object to merge into.\n * @param obj - The source object to merge from.\n * @param options - Options for merging.\n * @returns The merged object.\n */\nexport function assign<T extends object, U extends object>(\n target: T,\n obj: U = {} as U,\n options: Assign = {},\n): T & U {\n options = { ...defaultOptions, ...options };\n\n const finalObj = Object.entries(obj).reduce((acc, [key, sourceProp]) => {\n const targetProp = target[key as keyof typeof target];\n\n // Only merge arrays\n if (\n options.merge &&\n Array.isArray(targetProp) &&\n Array.isArray(sourceProp)\n ) {\n acc[key as keyof typeof acc] = sourceProp.reduce(\n (acc, item) => {\n // Remove duplicates\n return acc.includes(item) ? acc : [...acc, item];\n },\n [...targetProp],\n );\n } else if (options.extend || key in target) {\n // Extend the target with new properties or update existing ones\n acc[key as keyof typeof acc] = sourceProp;\n }\n\n return acc;\n }, {} as U);\n\n // Handle shallow or deep copy based on options\n if (options.shallow) {\n return { ...target, ...finalObj };\n } else {\n Object.assign(target, finalObj);\n return target as T & U;\n }\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Checks if a value is an arguments object.\n *\n * @param value The value to check.\n * @returns True if the value is an arguments object, false otherwise.\n */\nexport function isArguments(value: unknown): value is IArguments {\n return Object.prototype.toString.call(value) === '[object Arguments]';\n}\n\n/**\n * Checks if a value is an array.\n *\n * @param value The value to check.\n * @returns True if the value is an array, false otherwise.\n */\nexport function isArray<T>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value The value to check.\n * @returns True if the value is a boolean, false otherwise.\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if an entity is a walker command.\n *\n * @param entity The entity to check.\n * @returns True if the entity is a walker command, false otherwise.\n */\nexport function isCommand(entity: string) {\n return entity === 'walker';\n}\n\n/**\n * Checks if a value is defined.\n *\n * @param value The value to check.\n * @returns True if the value is defined, false otherwise.\n */\nexport function isDefined<T>(val: T | undefined): val is T {\n return typeof val !== 'undefined';\n}\n\n/**\n * Checks if a value is an element or the document.\n *\n * @param elem The value to check.\n * @returns True if the value is an element or the document, false otherwise.\n */\nexport function isElementOrDocument(elem: unknown): elem is Element {\n return elem === document || elem instanceof Element;\n}\n\n/**\n * Checks if a value is a function.\n *\n * @param value The value to check.\n * @returns True if the value is a function, false otherwise.\n */\nexport function isFunction(value: unknown): value is Function {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a number.\n *\n * @param value The value to check.\n * @returns True if the value is a number, false otherwise.\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value);\n}\n\n/**\n * Checks if a value is an object.\n *\n * @param value The value to check.\n * @returns True if the value is an object, false otherwise.\n */\nexport function isObject(value: unknown): value is WalkerOS.AnyObject {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isArray(value) &&\n Object.prototype.toString.call(value) === '[object Object]'\n );\n}\n\n/**\n * Checks if two variables have the same type.\n *\n * @param variable The first variable.\n * @param type The second variable.\n * @returns True if the variables have the same type, false otherwise.\n */\nexport function isSameType<T>(\n variable: unknown,\n type: T,\n): variable is typeof type {\n return typeof variable === typeof type;\n}\n\n/**\n * Checks if a value is a string.\n *\n * @param value The value to check.\n * @returns True if the value is a string, false otherwise.\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n","/**\n * Creates a deep clone of a value.\n * Supports primitive values, objects, arrays, dates, and regular expressions.\n * Handles circular references.\n *\n * @template T\n * @param org - The value to clone.\n * @param visited - A map of visited objects to handle circular references.\n * @returns The cloned value.\n */\nexport function clone<T>(\n org: T,\n visited: WeakMap<object, unknown> = new WeakMap(),\n): T {\n // Handle primitive values and functions directly\n if (typeof org !== 'object' || org === null) return org;\n\n // Check for circular references\n if (visited.has(org)) return visited.get(org) as T;\n\n // Allow list of clonable types\n const type = Object.prototype.toString.call(org);\n if (type === '[object Object]') {\n const clonedObj = {} as Record<string | symbol, unknown>;\n visited.set(org as object, clonedObj); // Remember the reference\n\n for (const key in org as Record<string | symbol, unknown>) {\n if (Object.prototype.hasOwnProperty.call(org, key)) {\n clonedObj[key] = clone(\n (org as Record<string | symbol, unknown>)[key],\n visited,\n );\n }\n }\n return clonedObj as T;\n }\n\n if (type === '[object Array]') {\n const clonedArray = [] as unknown[];\n visited.set(org as object, clonedArray); // Remember the reference\n\n (org as unknown[]).forEach((item) => {\n clonedArray.push(clone(item, visited));\n });\n\n return clonedArray as T;\n }\n\n if (type === '[object Date]') {\n return new Date((org as unknown as Date).getTime()) as T;\n }\n\n if (type === '[object RegExp]') {\n const reg = org as unknown as RegExp;\n return new RegExp(reg.source, reg.flags) as T;\n }\n\n // Skip cloning for unsupported types and return reference\n return org;\n}\n","import type { WalkerOS } from './types';\nimport { isArray, isDefined, isObject } from './is';\nimport { clone } from './clone';\n\n/**\n * Gets a value from an object by a dot-notation string.\n * Supports wildcards for arrays.\n *\n * @example\n * getByPath({ data: { id: 1 } }, \"data.id\") // Returns 1\n *\n * @param event - The object to get the value from.\n * @param key - The dot-notation string.\n * @param defaultValue - The default value to return if the key is not found.\n * @returns The value from the object or the default value.\n */\nexport function getByPath(\n event: unknown,\n key: string = '',\n defaultValue?: unknown,\n): unknown {\n const keys = key.split('.');\n let values: unknown = event;\n\n for (let index = 0; index < keys.length; index++) {\n const k = keys[index];\n\n if (k === '*' && isArray(values)) {\n const remainingKeys = keys.slice(index + 1).join('.');\n const result: unknown[] = [];\n\n for (const item of values) {\n const value = getByPath(item, remainingKeys, defaultValue);\n result.push(value);\n }\n\n return result;\n }\n\n values =\n values instanceof Object ? values[k as keyof typeof values] : undefined;\n\n if (!values) break;\n }\n\n return isDefined(values) ? values : defaultValue;\n}\n\n/**\n * Sets a value in an object by a dot-notation string.\n *\n * @param obj - The object to set the value in.\n * @param key - The dot-notation string.\n * @param value - The value to set.\n * @returns A new object with the updated value.\n */\nexport function setByPath<T = unknown>(obj: T, key: string, value: unknown): T {\n if (!isObject(obj)) return obj;\n\n const clonedObj = clone(obj);\n const keys = key.split('.');\n let current: WalkerOS.AnyObject = clonedObj;\n\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i] as keyof typeof current;\n\n // Set the value if it's the last key\n if (i === keys.length - 1) {\n current[k] = value;\n } else {\n // Traverse to the next level\n if (\n !(k in current) ||\n typeof current[k] !== 'object' ||\n current[k] === null\n ) {\n current[k] = {};\n }\n\n // Move deeper into the object\n current = current[k] as WalkerOS.AnyObject;\n }\n }\n\n return clonedObj as T;\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Casts a value to a specific type.\n *\n * @param value The value to cast.\n * @returns The casted value.\n */\nexport function castValue(value: unknown): WalkerOS.PropertyType {\n if (value === 'true') return true;\n if (value === 'false') return false;\n\n const number = Number(value); // Converts \"\" to 0\n if (value == number && value !== '') return number;\n\n return String(value);\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Checks if the required consent is granted.\n *\n * @param required - The required consent states.\n * @param state - The current consent states.\n * @param individual - Individual consent states to prioritize.\n * @returns The granted consent states or false if not granted.\n */\nexport function getGrantedConsent(\n required: WalkerOS.Consent | undefined,\n state: WalkerOS.Consent = {},\n individual: WalkerOS.Consent = {},\n): false | WalkerOS.Consent {\n // Merge state and individual, prioritizing individual states\n const states: WalkerOS.Consent = { ...state, ...individual };\n\n const grantedStates: WalkerOS.Consent = {};\n let hasRequiredConsent = required === undefined;\n\n Object.keys(states).forEach((name) => {\n if (states[name]) {\n // consent granted\n grantedStates[name] = true;\n\n // Check if it's required and granted consent\n if (required && required[name]) hasRequiredConsent = true;\n }\n });\n\n return hasRequiredConsent ? grantedStates : false;\n}\n","import type { Destination } from './types';\nimport type { TypesOf, Config } from './types/destination';\nimport { assign } from './assign';\n\n/**\n * Creates a new destination instance by merging a base destination with additional configuration.\n *\n * This utility enables elegant destination configuration while avoiding config side-effects\n * that could occur when reusing destination objects across multiple collector instances.\n *\n * @param baseDestination - The base destination to extend\n * @param config - Additional configuration to merge with the base destination's config\n * @returns A new destination instance with merged configuration\n *\n * @example\n * ```typescript\n * // Types are inferred automatically from destinationGtag\n * elb('walker destination', createDestination(destinationGtag, {\n * settings: { ga4: { measurementId: 'G-123' } }\n * }));\n * ```\n */\nexport function createDestination<I extends Destination.Instance>(\n baseDestination: I,\n config: Partial<Config<TypesOf<I>>>,\n): I {\n // Create a shallow copy of the base destination to avoid mutations\n const newDestination = { ...baseDestination };\n\n // Deep merge the config, handling nested objects like settings and mapping\n newDestination.config = assign(baseDestination.config, config, {\n shallow: true, // Create new object, don't mutate original\n merge: true, // Merge arrays\n extend: true, // Allow new properties\n });\n\n // Handle nested settings merging if both have settings\n if (baseDestination.config.settings && config.settings) {\n newDestination.config.settings = assign(\n baseDestination.config.settings as object,\n config.settings as object,\n { shallow: true, merge: true, extend: true },\n ) as typeof newDestination.config.settings;\n }\n\n // Handle nested mapping merging if both have mapping\n if (baseDestination.config.mapping && config.mapping) {\n newDestination.config.mapping = assign(\n baseDestination.config.mapping as object,\n config.mapping as object,\n { shallow: true, merge: true, extend: true },\n ) as typeof newDestination.config.mapping;\n }\n\n return newDestination;\n}\n","import type { WalkerOS } from './types';\nimport { assign } from './assign';\n\ndeclare const __VERSION__: string;\n\n/**\n * Creates a complete event with default values.\n * Used for testing and debugging.\n *\n * @param props - Properties to override the default values.\n * @returns A complete event.\n */\nexport function createEvent(\n props: WalkerOS.DeepPartialEvent = {},\n): WalkerOS.Event {\n const timestamp = props.timestamp || new Date().setHours(0, 13, 37, 0);\n const group = props.group || 'gr0up';\n const count = props.count || 1;\n const id = `${timestamp}-${group}-${count}`;\n\n const defaultEvent: WalkerOS.Event = {\n name: 'entity action',\n data: {\n string: 'foo',\n number: 1,\n boolean: true,\n array: [0, 'text', false],\n not: undefined,\n },\n context: { dev: ['test', 1] },\n globals: { lang: 'elb' },\n custom: { completely: 'random' },\n user: { id: 'us3r', device: 'c00k13', session: 's3ss10n' },\n nested: [\n {\n entity: 'child',\n data: { is: 'subordinated' },\n nested: [],\n context: { element: ['child', 0] },\n },\n ],\n consent: { functional: true },\n id,\n trigger: 'test',\n entity: 'entity',\n action: 'action',\n timestamp,\n timing: 3.14,\n group,\n count,\n version: {\n source: __VERSION__,\n tagging: 1,\n },\n source: {\n type: 'web',\n id: 'https://localhost:80',\n previous_id: 'http://remotehost:9001',\n },\n };\n\n // Note: Always prefer the props over the defaults\n\n // Merge properties\n const event = assign(defaultEvent, props, { merge: false });\n\n // Update conditions\n\n // Entity and action from event\n if (props.name) {\n const [entity, action] = props.name.split(' ') ?? [];\n\n if (entity && action) {\n event.entity = entity;\n event.action = action;\n }\n }\n\n return event;\n}\n\n/**\n * Creates a complete event with default values based on the event name.\n * Used for testing and debugging.\n *\n * @param name - The name of the event to create.\n * @param props - Properties to override the default values.\n * @returns A complete event.\n */\nexport function getEvent(\n name: string = 'entity action',\n props: WalkerOS.DeepPartialEvent = {},\n): WalkerOS.Event {\n const timestamp = props.timestamp || new Date().setHours(0, 13, 37, 0);\n\n const quantity = 2;\n const product1 = {\n data: {\n id: 'ers',\n name: 'Everyday Ruck Snack',\n color: 'black',\n size: 'l',\n price: 420,\n },\n };\n const product2 = {\n data: {\n id: 'cc',\n name: 'Cool Cap',\n size: 'one size',\n price: 42,\n },\n };\n\n const defaultEvents: Record<string, WalkerOS.PartialEvent> = {\n 'cart view': {\n data: {\n currency: 'EUR',\n value: product1.data.price * quantity,\n },\n context: { shopping: ['cart', 0] },\n globals: { pagegroup: 'shop' },\n nested: [\n {\n entity: 'product',\n data: { ...product1.data, quantity },\n context: { shopping: ['cart', 0] },\n nested: [],\n },\n ],\n trigger: 'load',\n },\n 'checkout view': {\n data: {\n step: 'payment',\n currency: 'EUR',\n value: product1.data.price + product2.data.price,\n },\n context: { shopping: ['checkout', 0] },\n globals: { pagegroup: 'shop' },\n nested: [\n {\n entity: 'product',\n ...product1,\n context: { shopping: ['checkout', 0] },\n nested: [],\n },\n {\n entity: 'product',\n ...product2,\n context: { shopping: ['checkout', 0] },\n nested: [],\n },\n ],\n trigger: 'load',\n },\n 'order complete': {\n data: {\n id: '0rd3r1d',\n currency: 'EUR',\n shipping: 5.22,\n taxes: 73.76,\n total: 555,\n },\n context: { shopping: ['complete', 0] },\n globals: { pagegroup: 'shop' },\n nested: [\n {\n entity: 'product',\n ...product1,\n context: { shopping: ['complete', 0] },\n nested: [],\n },\n {\n entity: 'product',\n ...product2,\n context: { shopping: ['complete', 0] },\n nested: [],\n },\n {\n entity: 'gift',\n data: {\n name: 'Surprise',\n },\n context: { shopping: ['complete', 0] },\n nested: [],\n },\n ],\n trigger: 'load',\n },\n 'page view': {\n data: {\n domain: 'www.example.com',\n title: 'walkerOS documentation',\n referrer: 'https://www.elbwalker.com/',\n search: '?foo=bar',\n hash: '#hash',\n id: '/docs/',\n },\n globals: { pagegroup: 'docs' },\n trigger: 'load',\n },\n 'product add': {\n ...product1,\n context: { shopping: ['intent', 0] },\n globals: { pagegroup: 'shop' },\n nested: [],\n trigger: 'click',\n },\n 'product view': {\n ...product1,\n context: { shopping: ['detail', 0] },\n globals: { pagegroup: 'shop' },\n nested: [],\n trigger: 'load',\n },\n 'product visible': {\n data: { ...product1.data, position: 3, promo: true },\n context: { shopping: ['discover', 0] },\n globals: { pagegroup: 'shop' },\n nested: [],\n trigger: 'load',\n },\n 'promotion visible': {\n data: {\n name: 'Setting up tracking easily',\n position: 'hero',\n },\n context: { ab_test: ['engagement', 0] },\n globals: { pagegroup: 'homepage' },\n trigger: 'visible',\n },\n 'session start': {\n data: {\n id: 's3ss10n',\n start: timestamp,\n isNew: true,\n count: 1,\n runs: 1,\n isStart: true,\n storage: true,\n referrer: '',\n device: 'c00k13',\n },\n user: {\n id: 'us3r',\n device: 'c00k13',\n session: 's3ss10n',\n hash: 'h4sh',\n address: 'street number',\n email: 'user@example.com',\n phone: '+49 123 456 789',\n userAgent: 'Mozilla...',\n browser: 'Chrome',\n browserVersion: '90',\n deviceType: 'desktop',\n language: 'de-DE',\n country: 'DE',\n region: 'HH',\n city: 'Hamburg',\n zip: '20354',\n timezone: 'Berlin',\n os: 'walkerOS',\n osVersion: '1.0',\n screenSize: '1337x420',\n ip: '127.0.0.0',\n internal: true,\n custom: 'value',\n },\n },\n };\n\n return createEvent({ ...defaultEvents[name], ...props, name: name });\n}\n","/**\n * Generates a random string of a given length.\n *\n * @param length - The length of the random string.\n * @returns The random string.\n */\nexport function getId(length = 6): string {\n let str = '';\n for (let l = 36; str.length < length; )\n str += ((Math.random() * l) | 0).toString(l);\n return str;\n}\n","import type { WalkerOS } from './types';\nimport { assign } from './assign';\n\nexport interface MarketingParameters {\n [key: string]: string;\n}\n\n/**\n * Extracts marketing parameters from a URL.\n *\n * @param url - The URL to extract the parameters from.\n * @param custom - Custom marketing parameters to extract.\n * @returns The extracted marketing parameters.\n */\nexport function getMarketingParameters(\n url: URL,\n custom: MarketingParameters = {},\n): WalkerOS.Properties {\n const clickId = 'clickId';\n const data: WalkerOS.Properties = {};\n const parameters: MarketingParameters = {\n utm_campaign: 'campaign',\n utm_content: 'content',\n utm_medium: 'medium',\n utm_source: 'source',\n utm_term: 'term',\n dclid: clickId,\n fbclid: clickId,\n gclid: clickId,\n msclkid: clickId,\n ttclid: clickId,\n twclid: clickId,\n igshid: clickId,\n sclid: clickId,\n };\n\n Object.entries(assign(parameters, custom)).forEach(([key, name]) => {\n const param = url.searchParams.get(key); // Search for the parameter in the URL\n if (param) {\n if (name === clickId) {\n name = key;\n data[clickId] = key; // Reference the clickId parameter\n }\n\n data[name] = param;\n }\n });\n\n return data;\n}\n","/**\n * Creates a debounced function that delays invoking `fn` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `fn` invocations and a `flush` method to immediately invoke them.\n *\n * @template P, R\n * @param fn The function to debounce.\n * @param wait The number of milliseconds to delay.\n * @param immediate Trigger the function on the leading edge, instead of the trailing.\n * @returns The new debounced function.\n */\nexport function debounce<P extends unknown[], R>(\n fn: (...args: P) => R,\n wait = 1000,\n immediate = false,\n) {\n let timer: number | NodeJS.Timeout | null = null;\n let result: R;\n let hasCalledImmediately = false;\n\n return (...args: P): Promise<R> => {\n // Return value as promise\n return new Promise((resolve) => {\n const callNow = immediate && !hasCalledImmediately;\n\n // abort previous invocation\n if (timer) clearTimeout(timer);\n\n timer = setTimeout(() => {\n timer = null;\n if (!immediate || hasCalledImmediately) {\n result = fn(...args);\n resolve(result);\n }\n }, wait);\n\n if (callNow) {\n hasCalledImmediately = true;\n result = fn(...args);\n resolve(result);\n }\n });\n };\n}\n\n/**\n * Creates a throttled function that only invokes `fn` at most once per\n * every `delay` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `fn` invocations and a `flush` method to\n * immediately invoke them.\n *\n * @template P, R\n * @param fn The function to throttle.\n * @param delay The number of milliseconds to throttle invocations to.\n * @returns The new throttled function.\n */\n\ntype Timeout = ReturnType<typeof setTimeout>;\nexport function throttle<P extends unknown[], R>(\n fn: (...args: P) => R | undefined,\n delay = 1000,\n): (...args: P) => R | undefined {\n let isBlocked: Timeout | null = null;\n\n return function (...args: P): R | undefined {\n // Skip since function is still blocked by previous call\n if (isBlocked !== null) return;\n\n // Set a blocking timeout\n isBlocked = setTimeout(() => {\n // Unblock function\n isBlocked = null;\n }, delay) as Timeout;\n\n // Call the function\n return fn(...args);\n };\n}\n","import type { WalkerOS } from './types';\nimport {\n isArguments,\n isArray,\n isBoolean,\n isDefined,\n isNumber,\n isObject,\n isString,\n} from './is';\n\n/**\n * Checks if a value is a valid property type.\n *\n * @param value The value to check.\n * @returns True if the value is a valid property type, false otherwise.\n */\nexport function isPropertyType(value: unknown): value is WalkerOS.PropertyType {\n return (\n isBoolean(value) ||\n isString(value) ||\n isNumber(value) ||\n !isDefined(value) ||\n (isArray(value) && value.every(isPropertyType)) ||\n (isObject(value) && Object.values(value).every(isPropertyType))\n );\n}\n\n/**\n * Filters a value to only include valid property types.\n *\n * @param value The value to filter.\n * @returns The filtered value or undefined.\n */\nexport function filterValues(value: unknown): WalkerOS.Property | undefined {\n if (isBoolean(value) || isString(value) || isNumber(value)) return value;\n\n if (isArguments(value)) return filterValues(Array.from(value));\n\n if (isArray(value)) {\n return value\n .map((item) => filterValues(item))\n .filter((item): item is WalkerOS.PropertyType => item !== undefined);\n }\n\n if (isObject(value)) {\n return Object.entries(value).reduce<Record<string, WalkerOS.Property>>(\n (acc, [key, val]) => {\n const filteredValue = filterValues(val);\n if (filteredValue !== undefined) acc[key] = filteredValue;\n return acc;\n },\n {},\n );\n }\n\n return;\n}\n\n/**\n * Casts a value to a valid property type.\n *\n * @param value The value to cast.\n * @returns The casted value or undefined.\n */\nexport function castToProperty(value: unknown): WalkerOS.Property | undefined {\n return isPropertyType(value) ? value : undefined;\n}\n","/**\n * A utility function that wraps a function in a try-catch block.\n *\n * @template P, R, S\n * @param fn The function to wrap.\n * @param onError A function to call when an error is caught.\n * @param onFinally A function to call in the finally block.\n * @returns The wrapped function.\n */\n// Use function overload to support different return type depending on onError\n// Types\nexport function tryCatch<P extends unknown[], R, S>(\n fn: (...args: P) => R | undefined,\n onError: (err: unknown) => S,\n onFinally?: () => void,\n): (...args: P) => R | S;\nexport function tryCatch<P extends unknown[], R>(\n fn: (...args: P) => R | undefined,\n onError?: undefined,\n onFinally?: () => void,\n): (...args: P) => R | undefined;\n// Implementation\nexport function tryCatch<P extends unknown[], R, S>(\n fn: (...args: P) => R | undefined,\n onError?: (err: unknown) => S,\n onFinally?: () => void,\n): (...args: P) => R | S | undefined {\n return function (...args: P): R | S | undefined {\n try {\n return fn(...args);\n } catch (err) {\n if (!onError) return;\n return onError(err);\n } finally {\n onFinally?.();\n }\n };\n}\n\n/**\n * A utility function that wraps an async function in a try-catch block.\n *\n * @template P, R, S\n * @param fn The async function to wrap.\n * @param onError A function to call when an error is caught.\n * @param onFinally A function to call in the finally block.\n * @returns The wrapped async function.\n */\n// Use function overload to support different return type depending on onError\n// Types\nexport function tryCatchAsync<P extends unknown[], R, S>(\n fn: (...args: P) => R,\n onError: (err: unknown) => S,\n onFinally?: () => void | Promise<void>,\n): (...args: P) => Promise<R | S>;\nexport function tryCatchAsync<P extends unknown[], R>(\n fn: (...args: P) => R,\n onError?: undefined,\n onFinally?: () => void | Promise<void>,\n): (...args: P) => Promise<R | undefined>;\n// Implementation\nexport function tryCatchAsync<P extends unknown[], R, S>(\n fn: (...args: P) => R,\n onError?: (err: unknown) => S,\n onFinally?: () => void | Promise<void>,\n): (...args: P) => Promise<R | S | undefined> {\n return async function (...args: P): Promise<R | S | undefined> {\n try {\n return await fn(...args);\n } catch (err) {\n if (!onError) return;\n return await onError(err);\n } finally {\n await onFinally?.();\n }\n };\n}\n","import type { Mapping, WalkerOS, Collector } from './types';\nimport { getByPath, setByPath } from './byPath';\nimport { isArray, isDefined, isString, isObject } from './is';\nimport { castToProperty } from './property';\nimport { tryCatchAsync } from './tryCatch';\nimport { getGrantedConsent } from './consent';\nimport { assign } from './assign';\n\n/**\n * Gets the mapping for an event.\n *\n * @param event The event to get the mapping for (can be partial or full).\n * @param mapping The mapping rules.\n * @returns The mapping result.\n */\nexport async function getMappingEvent(\n event: WalkerOS.DeepPartialEvent | WalkerOS.PartialEvent | WalkerOS.Event,\n mapping?: Mapping.Rules,\n): Promise<Mapping.Result> {\n const [entity, action] = (event.name || '').split(' ');\n if (!mapping || !entity || !action) return {};\n\n let eventMapping: Mapping.Rule | undefined;\n let mappingKey = '';\n let entityKey = entity;\n let actionKey = action;\n\n const resolveEventMapping = (\n eventMapping?: Mapping.Rule | Mapping.Rule[],\n ) => {\n if (!eventMapping) return;\n eventMapping = isArray(eventMapping) ? eventMapping : [eventMapping];\n\n return eventMapping.find(\n (eventMapping) =>\n !eventMapping.condition || eventMapping.condition(event),\n );\n };\n\n if (!mapping[entityKey]) entityKey = '*';\n const entityMapping = mapping[entityKey];\n\n if (entityMapping) {\n if (!entityMapping[actionKey]) actionKey = '*';\n eventMapping = resolveEventMapping(entityMapping[actionKey]);\n }\n\n // Fallback to * *\n if (!eventMapping) {\n entityKey = '*';\n actionKey = '*';\n eventMapping = resolveEventMapping(mapping[entityKey]?.[actionKey]);\n }\n\n if (eventMapping) mappingKey = `${entityKey} ${actionKey}`;\n\n return { eventMapping, mappingKey };\n}\n\n/**\n * Gets a value from a mapping.\n *\n * @param value The value to get the mapping from.\n * @param data The mapping data.\n * @param options The mapping options.\n * @returns The mapped value.\n */\nexport async function getMappingValue(\n value: WalkerOS.DeepPartialEvent | unknown | undefined,\n data: Mapping.Data = {},\n options: Mapping.Options = {},\n): Promise<WalkerOS.Property | undefined> {\n if (!isDefined(value)) return;\n\n // Get consent state in priority order: value.consent > options.consent > collector?.consent\n const consentState =\n ((isObject(value) && value.consent) as WalkerOS.Consent) ||\n options.consent ||\n options.collector?.consent;\n\n const mappings = isArray(data) ? data : [data];\n\n for (const mapping of mappings) {\n const result = await tryCatchAsync(processMappingValue)(value, mapping, {\n ...options,\n consent: consentState,\n });\n if (isDefined(result)) return result;\n }\n\n return;\n}\n\nasync function processMappingValue(\n value: WalkerOS.DeepPartialEvent | unknown,\n mapping: Mapping.Value,\n options: Mapping.Options = {},\n): Promise<WalkerOS.Property | undefined> {\n const { collector, consent: consentState } = options;\n\n // Ensure mapping is an array for uniform processing\n const mappings = isArray(mapping) ? mapping : [mapping];\n\n // Loop over each mapping and return the first valid result\n return mappings.reduce(\n async (accPromise, mappingItem) => {\n const acc = await accPromise;\n if (acc) return acc; // A valid result was already found\n\n const mapping = isString(mappingItem)\n ? { key: mappingItem }\n : mappingItem;\n\n if (!Object.keys(mapping).length) return;\n\n const {\n condition,\n consent,\n fn,\n key,\n loop,\n map,\n set,\n validate,\n value: staticValue,\n } = mapping;\n\n // Check if this mapping should be used\n if (\n condition &&\n !(await tryCatchAsync(condition)(value, mappingItem, collector))\n )\n return;\n\n // Check if consent is required and granted\n if (consent && !getGrantedConsent(consent, consentState))\n return staticValue;\n\n let mappingValue: unknown = isDefined(staticValue) ? staticValue : value;\n\n // Use a custom function to get the value\n if (fn) {\n mappingValue = await tryCatchAsync(fn)(value, mappingItem, options);\n }\n\n // Get dynamic value from the event\n if (key) {\n mappingValue = getByPath(value, key, staticValue);\n }\n\n if (loop) {\n const [scope, itemMapping] = loop;\n\n const data =\n scope === 'this'\n ? [value]\n : await getMappingValue(value, scope, options);\n\n if (isArray(data)) {\n mappingValue = (\n await Promise.all(\n data.map((item) => getMappingValue(item, itemMapping, options)),\n )\n ).filter(isDefined);\n }\n } else if (map) {\n mappingValue = await Object.entries(map).reduce(\n async (mappedObjPromise, [mapKey, mapValue]) => {\n const mappedObj = await mappedObjPromise;\n const result = await getMappingValue(value, mapValue, options);\n if (isDefined(result)) mappedObj[mapKey] = result;\n return mappedObj;\n },\n Promise.resolve({} as WalkerOS.AnyObject),\n );\n } else if (set) {\n mappingValue = await Promise.all(\n set.map((item) => processMappingValue(value, item, options)),\n );\n }\n\n // Validate the value\n if (validate && !(await tryCatchAsync(validate)(mappingValue)))\n mappingValue = undefined;\n\n const property = castToProperty(mappingValue);\n\n // Finally, check and convert the type\n return isDefined(property) ? property : castToProperty(staticValue); // Always use value as a fallback\n },\n Promise.resolve(undefined as WalkerOS.Property | undefined),\n );\n}\n\n/**\n * Processes an event through mapping configuration.\n *\n * This is the unified mapping logic used by both sources and destinations.\n * It applies transformations in this order:\n * 1. Config-level policy - modifies the event itself (global rules)\n * 2. Mapping rules - finds matching rule based on entity-action\n * 3. Event-level policy - modifies the event based on specific mapping rule\n * 4. Data transformation - creates context data\n * 5. Ignore check and name override\n *\n * Sources can pass partial events, destinations pass full events.\n * getMappingValue works with both partial and full events.\n *\n * @param event - The event to process (can be partial or full, will be mutated by policies)\n * @param config - Mapping configuration (mapping, data, policy, consent)\n * @param collector - Collector instance for context\n * @returns Object with transformed event, data, mapping rule, and ignore flag\n */\nexport async function processEventMapping<\n T extends WalkerOS.DeepPartialEvent | WalkerOS.Event,\n>(\n event: T,\n config: Mapping.Config,\n collector: Collector.Instance,\n): Promise<{\n event: T;\n data?: WalkerOS.Property;\n mapping?: Mapping.Rule;\n mappingKey?: string;\n ignore: boolean;\n}> {\n // Step 1: Apply config-level policy (modifies event)\n if (config.policy) {\n await Promise.all(\n Object.entries(config.policy).map(async ([key, mapping]) => {\n const value = await getMappingValue(event, mapping, { collector });\n event = setByPath(event, key, value);\n }),\n );\n }\n\n // Step 2: Get event mapping rule\n const { eventMapping, mappingKey } = await getMappingEvent(\n event,\n config.mapping,\n );\n\n // Step 2.5: Apply event-level policy (modifies event)\n if (eventMapping?.policy) {\n await Promise.all(\n Object.entries(eventMapping.policy).map(async ([key, mapping]) => {\n const value = await getMappingValue(event, mapping, { collector });\n event = setByPath(event, key, value);\n }),\n );\n }\n\n // Step 3: Transform global data\n let data =\n config.data && (await getMappingValue(event, config.data, { collector }));\n\n if (eventMapping) {\n // Check if event should be ignored\n if (eventMapping.ignore) {\n return { event, data, mapping: eventMapping, mappingKey, ignore: true };\n }\n\n // Override event name if specified\n if (eventMapping.name) event.name = eventMapping.name;\n\n // Transform event-specific data\n if (eventMapping.data) {\n const dataEvent =\n eventMapping.data &&\n (await getMappingValue(event, eventMapping.data, { collector }));\n data =\n isObject(data) && isObject(dataEvent) // Only merge objects\n ? assign(data, dataEvent)\n : dataEvent;\n }\n }\n\n return { event, data, mapping: eventMapping, mappingKey, ignore: false };\n}\n","/**\n * Environment mocking utilities for walkerOS destinations\n *\n * Provides standardized tools for intercepting function calls in environment objects,\n * enabling consistent testing patterns across all destinations.\n */\n\ntype InterceptorFn = (\n path: string[],\n args: unknown[],\n original?: Function,\n) => unknown;\n\n/**\n * Creates a proxied environment that intercepts function calls\n *\n * Uses Proxy to wrap environment objects and capture all function calls,\n * allowing for call recording, mocking, or simulation.\n *\n * @param env - The environment object to wrap\n * @param interceptor - Function called for each intercepted call\n * @returns Proxied environment with interceptor applied\n *\n * @example\n * ```typescript\n * const calls: Array<{ path: string[]; args: unknown[] }> = [];\n *\n * const testEnv = mockEnv(env.push, (path, args) => {\n * calls.push({ path, args });\n * });\n *\n * // Use testEnv with destination\n * await destination.push(event, { env: testEnv });\n *\n * // Analyze captured calls\n * expect(calls).toContainEqual({\n * path: ['window', 'gtag'],\n * args: ['event', 'purchase', { value: 99.99 }]\n * });\n * ```\n */\nexport function mockEnv<T extends object>(\n env: T,\n interceptor: InterceptorFn,\n): T {\n const createProxy = (obj: object, path: string[] = []): object => {\n return new Proxy(obj, {\n get(target, prop: string) {\n const value = (target as Record<string, unknown>)[prop];\n const currentPath = [...path, prop];\n\n if (typeof value === 'function') {\n return (...args: unknown[]) => {\n return interceptor(currentPath, args, value);\n };\n }\n\n if (value && typeof value === 'object') {\n return createProxy(value as object, currentPath);\n }\n\n return value;\n },\n });\n };\n\n return createProxy(env) as T;\n}\n\n/**\n * Traverses environment object and replaces values using a replacer function\n *\n * Alternative to mockEnv for environments where Proxy is not suitable.\n * Performs deep traversal and allows value transformation at each level.\n *\n * @param env - The environment object to traverse\n * @param replacer - Function to transform values during traversal\n * @returns New environment object with transformed values\n *\n * @example\n * ```typescript\n * const recordedCalls: APICall[] = [];\n *\n * const recordingEnv = traverseEnv(originalEnv, (value, path) => {\n * if (typeof value === 'function') {\n * return (...args: unknown[]) => {\n * recordedCalls.push({\n * path: path.join('.'),\n * args: structuredClone(args)\n * });\n * return value(...args);\n * };\n * }\n * return value;\n * });\n * ```\n */\nexport function traverseEnv<T extends object>(\n env: T,\n replacer: (value: unknown, path: string[]) => unknown,\n): T {\n const traverse = (obj: unknown, path: string[] = []): unknown => {\n if (!obj || typeof obj !== 'object') return obj;\n\n const result: Record<string, unknown> | unknown[] = Array.isArray(obj)\n ? []\n : {};\n\n for (const [key, value] of Object.entries(obj)) {\n const currentPath = [...path, key];\n if (Array.isArray(result)) {\n result[Number(key)] = replacer(value, currentPath);\n } else {\n (result as Record<string, unknown>)[key] = replacer(value, currentPath);\n }\n\n if (value && typeof value === 'object' && typeof value !== 'function') {\n if (Array.isArray(result)) {\n result[Number(key)] = traverse(value, currentPath);\n } else {\n (result as Record<string, unknown>)[key] = traverse(\n value,\n currentPath,\n );\n }\n }\n }\n\n return result;\n };\n\n return traverse(env) as T;\n}\n","/**\n * Logs a message to the console if verbose logging is enabled.\n *\n * @param message The message to log.\n * @param verbose Whether to log the message.\n */\nexport function onLog(message: unknown, verbose = false): void {\n // eslint-disable-next-line no-console\n if (verbose) console.dir(message, { depth: 4 });\n}\n","import type { WalkerOS } from './types';\nimport { tryCatch } from './tryCatch';\nimport { castValue } from './castValue';\nimport { isArray, isObject } from './is';\n\n/**\n * Converts a request string to a data object.\n *\n * @param parameter The request string to convert.\n * @returns The data object or undefined.\n */\nexport function requestToData(\n parameter: unknown,\n): WalkerOS.AnyObject | undefined {\n const str = String(parameter);\n const queryString = str.split('?')[1] || str;\n\n return tryCatch(() => {\n const params = new URLSearchParams(queryString);\n const result: WalkerOS.AnyObject = {};\n\n params.forEach((value, key) => {\n const keys = key.split(/[[\\]]+/).filter(Boolean);\n let current: unknown = result;\n\n keys.forEach((k, i) => {\n const isLast = i === keys.length - 1;\n\n if (isArray(current)) {\n const index = parseInt(k, 10);\n if (isLast) {\n (current as Array<unknown>)[index] = castValue(value);\n } else {\n (current as Array<unknown>)[index] =\n (current as Array<unknown>)[index] ||\n (isNaN(parseInt(keys[i + 1], 10)) ? {} : []);\n current = (current as Array<unknown>)[index];\n }\n } else if (isObject(current)) {\n if (isLast) {\n (current as WalkerOS.AnyObject)[k] = castValue(value);\n } else {\n (current as WalkerOS.AnyObject)[k] =\n (current as WalkerOS.AnyObject)[k] ||\n (isNaN(parseInt(keys[i + 1], 10)) ? {} : []);\n current = (current as WalkerOS.AnyObject)[k];\n }\n }\n });\n });\n\n return result;\n })();\n}\n\n/**\n * Converts a data object to a request string.\n *\n * @param data The data object to convert.\n * @returns The request string.\n */\nexport function requestToParameter(\n data: WalkerOS.AnyObject | WalkerOS.PropertyType,\n): string {\n if (!data) return '';\n\n const params: string[] = [];\n const encode = encodeURIComponent;\n\n function addParam(key: string, value: unknown) {\n if (value === undefined || value === null) return;\n\n if (isArray(value)) {\n value.forEach((item, index) => addParam(`${key}[${index}]`, item));\n } else if (isObject(value)) {\n Object.entries(value).forEach(([subKey, subValue]) =>\n addParam(`${key}[${subKey}]`, subValue),\n );\n } else {\n params.push(`${encode(key)}=${encode(String(value))}`);\n }\n }\n\n if (typeof data === 'object') {\n Object.entries(data).forEach(([key, value]) => addParam(key, value));\n } else {\n return encode(data);\n }\n\n return params.join('&');\n}\n","import type { SendDataValue, SendHeaders } from './types/send';\nimport { isSameType } from './is';\nimport { assign } from './assign';\n\nexport type { SendDataValue, SendHeaders, SendResponse } from './types/send';\n\n/**\n * Transforms data to a string.\n *\n * @param data The data to transform.\n * @returns The transformed data.\n */\nexport function transformData(data?: SendDataValue): string | undefined {\n if (data === undefined) return data;\n\n return isSameType(data, '' as string) ? data : JSON.stringify(data);\n}\n\n/**\n * Gets the headers for a request.\n *\n * @param headers The headers to merge with the default headers.\n * @returns The merged headers.\n */\nexport function getHeaders(headers: SendHeaders = {}): SendHeaders {\n return assign(\n {\n 'Content-Type': 'application/json; charset=utf-8',\n },\n headers,\n );\n}\n","/**\n * Throws an error.\n *\n * @param error The error to throw.\n */\nexport function throwError(error: unknown): never {\n throw new Error(String(error));\n}\n","/**\n * Trims quotes and whitespaces from a string.\n *\n * @param str The string to trim.\n * @returns The trimmed string.\n */\nexport function trim(str: string): string {\n // Remove quotes and whitespaces\n return str ? str.trim().replace(/^'|'$/g, '').trim() : '';\n}\n","import type { Hooks } from './types';\n\n/**\n * A utility function that wraps a function with hooks.\n *\n * @template P, R\n * @param fn The function to wrap.\n * @param name The name of the function.\n * @param hooks The hooks to use.\n * @returns The wrapped function.\n */\nexport function useHooks<P extends unknown[], R>(\n fn: (...args: P) => R,\n name: string,\n hooks: Hooks.Functions,\n): (...args: P) => R {\n return function (...args: P): R {\n let result: R;\n const preHook = ('pre' + name) as keyof Hooks.Functions;\n const postHook = ('post' + name) as keyof Hooks.Functions;\n const preHookFn = hooks[preHook] as unknown as Hooks.HookFn<typeof fn>;\n const postHookFn = hooks[postHook] as unknown as Hooks.HookFn<typeof fn>;\n\n if (preHookFn) {\n // Call the original function within the preHook\n result = preHookFn({ fn }, ...args);\n } else {\n // Regular function call\n result = fn(...args);\n }\n\n if (postHookFn) {\n // Call the post-hook function with fn, result, and the original args\n result = postHookFn({ fn, result }, ...args);\n }\n\n return result;\n };\n}\n","import type { WalkerOS } from './types';\n\n/**\n * Parses a user agent string to extract browser, OS, and device information.\n *\n * @param userAgent The user agent string to parse.\n * @returns An object containing the parsed user agent information.\n */\nexport function parseUserAgent(userAgent?: string): WalkerOS.User {\n if (!userAgent) return {};\n\n return {\n userAgent,\n browser: getBrowser(userAgent),\n browserVersion: getBrowserVersion(userAgent),\n os: getOS(userAgent),\n osVersion: getOSVersion(userAgent),\n deviceType: getDeviceType(userAgent),\n };\n}\n\n/**\n * Gets the browser name from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The browser name or undefined.\n */\nexport function getBrowser(userAgent: string): string | undefined {\n const browsers = [\n { name: 'Edge', substr: 'Edg' },\n { name: 'Chrome', substr: 'Chrome' },\n { name: 'Safari', substr: 'Safari', exclude: 'Chrome' },\n { name: 'Firefox', substr: 'Firefox' },\n { name: 'IE', substr: 'MSIE' },\n { name: 'IE', substr: 'Trident' },\n ];\n\n for (const browser of browsers) {\n if (\n userAgent.includes(browser.substr) &&\n (!browser.exclude || !userAgent.includes(browser.exclude))\n ) {\n return browser.name;\n }\n }\n\n return;\n}\n\n/**\n * Gets the browser version from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The browser version or undefined.\n */\nexport function getBrowserVersion(userAgent: string): string | undefined {\n const rules = [\n /Edg\\/([0-9]+)/, // Edge\n /Chrome\\/([0-9]+)/, // Chrome\n /Version\\/([0-9]+).*Safari/, // Safari\n /Firefox\\/([0-9]+)/, // Firefox\n /MSIE ([0-9]+)/, // IE 10 and older\n /rv:([0-9]+).*Trident/, // IE 11\n ];\n\n for (const regex of rules) {\n const match = userAgent.match(regex);\n if (match) {\n return match[1];\n }\n }\n\n return;\n}\n\n/**\n * Gets the OS name from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The OS name or undefined.\n */\nexport function getOS(userAgent: string): string | undefined {\n const osList = [\n { name: 'Windows', substr: 'Windows NT' },\n { name: 'macOS', substr: 'Mac OS X' },\n { name: 'Android', substr: 'Android' },\n { name: 'iOS', substr: 'iPhone OS' },\n { name: 'Linux', substr: 'Linux' },\n ];\n\n for (const os of osList) {\n if (userAgent.includes(os.substr)) {\n return os.name;\n }\n }\n\n return;\n}\n\n/**\n * Gets the OS version from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The OS version or undefined.\n */\nexport function getOSVersion(userAgent: string): string | undefined {\n const osVersionRegex = /(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/;\n const match = userAgent.match(osVersionRegex);\n return match ? match[1].replace(/_/g, '.') : undefined;\n}\n\n/**\n * Gets the device type from a user agent string.\n *\n * @param userAgent The user agent string.\n * @returns The device type or undefined.\n */\nexport function getDeviceType(userAgent: string): string | undefined {\n let deviceType = 'Desktop';\n\n if (/Tablet|iPad/i.test(userAgent)) {\n deviceType = 'Tablet';\n } else if (\n /Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(\n userAgent,\n )\n ) {\n deviceType = 'Mobile';\n }\n\n return deviceType;\n}\n","import type { Schema, WalkerOS } from './types';\nimport { isSameType } from './is';\nimport { throwError } from './throwError';\nimport { tryCatch } from './tryCatch';\n\n/**\n * Validates an event against a set of contracts.\n *\n * @param obj The event to validate.\n * @param customContracts The custom contracts to use.\n * @returns The validated event.\n */\nexport function validateEvent(\n obj: unknown,\n customContracts: Schema.Contracts = [],\n): WalkerOS.Event | never {\n if (!isSameType(obj, {} as WalkerOS.AnyObject)) throwError('Invalid object');\n\n let event: string;\n let entity: string;\n let action: string;\n\n // Check if event.name is available and it's a string\n if (isSameType(obj.name, '')) {\n event = obj.name;\n [entity, action] = event.split(' ');\n if (!entity || !action) throwError('Invalid event name');\n } else if (isSameType(obj.entity, '') && isSameType(obj.action, '')) {\n entity = obj.entity;\n action = obj.action;\n event = `${entity} ${action}`;\n } else {\n throwError('Missing or invalid name, entity, or action');\n }\n\n const basicContract: Schema.Contract = {\n '*': {\n '*': {\n name: { maxLength: 255 }, // @TODO as general rule?\n user: { allowedKeys: ['id', 'device', 'session'] },\n consent: { allowedValues: [true, false] },\n timestamp: { min: 0 },\n timing: { min: 0 },\n count: { min: 0 },\n version: { allowedKeys: ['source', 'tagging'] },\n source: { allowedKeys: ['type', 'id', 'previous_id'] },\n },\n },\n };\n\n const basicEvent: WalkerOS.Event = {\n name: event,\n data: {},\n context: {},\n custom: {},\n globals: {},\n user: {},\n nested: [],\n consent: {},\n id: '',\n trigger: '',\n entity,\n action,\n timestamp: 0,\n timing: 0,\n group: '',\n count: 0,\n version: { source: '', tagging: 0 },\n source: { type: '', id: '', previous_id: '' },\n };\n\n // Collect all relevant schemas for the event\n const schemas = [basicContract]\n .concat(customContracts)\n .reduce((acc, contract) => {\n return ['*', entity].reduce((entityAcc, e) => {\n return ['*', action].reduce((actionAcc, a) => {\n const schema = contract[e]?.[a];\n return schema ? actionAcc.concat([schema]) : actionAcc;\n }, entityAcc);\n }, acc);\n }, [] as Schema.Properties[]);\n\n const result = schemas.reduce(\n (acc, schema) => {\n // Get all required properties\n const requiredKeys = Object.keys(schema).filter((key) => {\n const property = schema[key];\n return property?.required === true;\n });\n\n // Validate both, ingested and required properties but only once\n return [...Object.keys(obj), ...requiredKeys].reduce((acc, key) => {\n const propertySchema = schema[key];\n let value = obj[key];\n\n if (propertySchema) {\n // Update the value\n value = tryCatch(validateProperty, (err) => {\n throwError(String(err));\n })(acc, key, value, propertySchema);\n }\n\n // Same type check\n if (isSameType(value, acc[key])) acc[key] = value;\n\n return acc;\n }, acc);\n },\n // Not that beautiful but it works, narrowing down the type is tricky here\n // it's important that basicEvent is defined as an WalkerOS.Event\n basicEvent as unknown as WalkerOS.AnyObject,\n ) as unknown as WalkerOS.Event;\n\n // @TODO Final check for result.event === event.entity + ' ' + event.action\n\n return result;\n}\n\n/**\n * Validates a property against a schema.\n *\n * @param obj The object to validate.\n * @param key The key of the property to validate.\n * @param value The value of the property to validate.\n * @param schema The schema to validate against.\n * @returns The validated property.\n */\nexport function validateProperty(\n obj: WalkerOS.AnyObject,\n key: string,\n value: unknown,\n schema: Schema.Property,\n): WalkerOS.Property | never {\n // @TODO unknown to WalkerOS.Property\n\n // Note regarding potentially malicious values\n // Initial collection doesn't manipulate data\n // Prefer context-specific checks in the destinations\n\n // Custom validate function can change the value\n if (schema.validate)\n value = tryCatch(schema.validate, (err) => {\n throwError(String(err));\n })(value, key, obj);\n\n if (schema.required && value === undefined)\n throwError('Missing required property');\n\n // Strings\n if (isSameType(value, '' as string)) {\n if (schema.maxLength && value.length > schema.maxLength) {\n if (schema.strict) throwError('Value exceeds maxLength');\n value = value.substring(0, schema.maxLength);\n }\n }\n\n // Numbers\n else if (isSameType(value, 1 as number)) {\n if (isSameType(schema.min, 1) && value < schema.min) {\n if (schema.strict) throwError('Value below min');\n value = schema.min;\n } else if (isSameType(schema.max, 1) && value > schema.max) {\n if (schema.strict) throwError('Value exceeds max');\n value = schema.max;\n }\n }\n\n // @TODO boolean\n\n // Objects\n else if (isSameType(value, {} as WalkerOS.AnyObject)) {\n if (schema.schema) {\n const nestedSchema = schema.schema;\n\n // @TODO handle return to update value as non unknown\n // @TODO bug with multiple rules in property schema\n Object.keys(nestedSchema).reduce((acc, key) => {\n const propertySchema = nestedSchema[key];\n let value = acc[key];\n\n if (propertySchema) {\n // Type check\n if (propertySchema.type && typeof value !== propertySchema.type)\n throwError(`Type doesn't match (${key})`);\n\n // Update the value\n value = tryCatch(validateProperty, (err) => {\n throwError(String(err));\n })(acc, key, value, propertySchema);\n }\n\n return value as WalkerOS.AnyObject;\n }, value);\n }\n\n for (const objKey of Object.keys(value)) {\n // Check for allowed keys if applicable\n if (schema.allowedKeys && !schema.allowedKeys.includes(objKey)) {\n if (schema.strict) throwError('Key not allowed');\n\n delete value[objKey];\n }\n }\n }\n\n return value as WalkerOS.Property;\n}\n"],"mappings":";;;;;;;AAAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACEO,IAAM,UAAU;AAAA,EACrB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AACV;AAEO,IAAM,QAAQ;AAAA,EACnB,OAAO;AAAA,IACL;AAAA,EACF;AACF;;;ACJA,SAAS,SAAS;AAiBX,SAAS,aACd,QACA,OACA,SAAsD,WACtD;AACA,SAAO,EAAE,aAAa,QAAQ;AAAA,IAC5B;AAAA,EACF,CAAC;AACH;AAMO,SAAS,gBACd,QACA,SAMA;AACA,QAAM,SACJ,SAAS,WAAW,gBAChB,YACC,SAAS;AAChB,SAAO,EAAE,aAAa,QAAQ;AAAA,IAC5B,QAAQ,UAAU;AAAA,EACpB,CAAC;AACH;;;AChCO,IAAM,iBAAiB,EAAE,OAAO;AAMhC,IAAM,iBAAiB,EAAE,OAAO;AAMhC,IAAM,kBAAkB,EAAE,QAAQ;AAUlC,IAAM,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAMnC,IAAM,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAM5C,IAAM,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;AAM7C,IAAM,iBAAiB,EAAE,OAAO,EAAE,SAAS,wBAAwB;AAWnE,IAAM,iBAAiB,EAAE,MAAM,CAAC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O,OAAQ,YAAW,yBAAyB;AACvD,cAAQ,MAAM,UAAU,GAAG,OAAO,SAAS;AAAA,IAC7C;AAAA,EACF,WAGS,WAAW,OAAO,CAAW,GAAG;AACvC,QAAI,WAAW,OAAO,KAAK,CAAC,KAAK,QAAQ,OAAO,KAAK;AACnD,UAAI,OAAO,OAAQ,YAAW,iBAAiB;AAC/C,cAAQ,OAAO;AAAA,IACjB,WAAW,WAAW,OAAO,KAAK,CAAC,KAAK,QAAQ,OAAO,KAAK;AAC1D,UAAI,OAAO,OAAQ,YAAW,mBAAmB;AACjD,cAAQ,OAAO;AAAA,IACjB;AAAA,EACF,WAKS,WAAW,OAAO,CAAC,CAAuB,GAAG;AACpD,QAAI,OAAO,QAAQ;AACjB,YAAM,eAAe,OAAO;AAI5B,aAAO,KAAK,YAAY,EAAE,OAAO,CAAC,KAAKC,SAAQ;AAC7C,cAAM,iBAAiB,aAAaA,IAAG;AACvC,YAAIC,SAAQ,IAAID,IAAG;AAEnB,YAAI,gBAAgB;AAElB,cAAI,eAAe,QAAQ,OAAOC,WAAU,eAAe;AACzD,uBAAW,uBAAuBD,IAAG,GAAG;AAG1C,UAAAC,SAAQ,SAAS,kBAAkB,CAAC,QAAQ;AAC1C,uBAAW,OAAO,GAAG,CAAC;AAAA,UACxB,CAAC,EAAE,KAAKD,MAAKC,QAAO,cAAc;AAAA,QACpC;AAEA,eAAOA;AAAA,MACT,GAAG,KAAK;AAAA,IACV;AAEA,eAAW,UAAU,OAAO,KAAK,KAAK,GAAG;AAEvC,UAAI,OAAO,eAAe,CAAC,OAAO,YAAY,SAAS,MAAM,GAAG;AAC9D,YAAI,OAAO,OAAQ,YAAW,iBAAiB;AAE/C,eAAO,MAAM,MAAM;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["ValueSchema","ValuesSchema","RulesSchema","PolicySchema","ConsentSchema","walkeros_exports","mapping_exports","destination_exports","ConfigSchema","ResultSchema","configJsonSchema","ConfigSchema","ResultSchema","configJsonSchema","collector_exports","ConfigSchema","DestinationsSchema","InstanceSchema","PushContextSchema","configJsonSchema","instanceJsonSchema","pushContextJsonSchema","ConfigSchema","PushContextSchema","DestinationsSchema","InstanceSchema","configJsonSchema","pushContextJsonSchema","instanceJsonSchema","source_exports","ConfigSchema","InitSchema","InstanceSchema","PartialConfigSchema","configJsonSchema","instanceJsonSchema","partialConfigJsonSchema","ConfigSchema","PartialConfigSchema","InstanceSchema","InitSchema","configJsonSchema","partialConfigJsonSchema","instanceJsonSchema","flow_exports","ConfigSchema","configJsonSchema","ConfigSchema","configJsonSchema","acc","eventMapping","mapping","acc","key","value"]}
|