@walkeros/core 4.1.0 → 4.1.1-next-1779485810490
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/CHANGELOG.md +12 -0
- package/dist/dev.d.mts +942 -60
- package/dist/dev.d.ts +942 -60
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.d.mts +49 -7
- package/dist/index.d.ts +49 -7
- 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 +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -56,7 +56,31 @@ interface Rule<Settings = unknown> {
|
|
|
56
56
|
silent?: boolean;
|
|
57
57
|
name?: string;
|
|
58
58
|
policy?: Policy$1;
|
|
59
|
+
/**
|
|
60
|
+
* Merge mode (config layer): a partial Rule deep-merged onto the
|
|
61
|
+
* package-shipped default rule at the same key, instead of replacing it.
|
|
62
|
+
* Resolved at the consuming package's init via `mergeMappingRule`; not
|
|
63
|
+
* seen by the runtime evaluator. A `null` value clears an inherited field.
|
|
64
|
+
* Presence of `extend` or `remove` switches this rule from replace to merge.
|
|
65
|
+
*/
|
|
66
|
+
extend?: RulePatch<Settings>;
|
|
67
|
+
/**
|
|
68
|
+
* Output layer: dotted paths stripped from the produced data payload
|
|
69
|
+
* after evaluation, regardless of how each field was produced. Applied
|
|
70
|
+
* last, so it always wins.
|
|
71
|
+
*/
|
|
72
|
+
remove?: string[];
|
|
59
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* A partial Rule used by `Rule.extend`. Every field is optional, and a
|
|
76
|
+
* `null` value clears the inherited field (JSON merge-patch delete). The
|
|
77
|
+
* control fields `extend` and `remove` are excluded: a patch models only
|
|
78
|
+
* direct rule fields, matching what the runtime patch schema accepts.
|
|
79
|
+
*/
|
|
80
|
+
type RulePatchFields<Settings = unknown> = Omit<Rule<Settings>, 'extend' | 'remove'>;
|
|
81
|
+
type RulePatch<Settings = unknown> = {
|
|
82
|
+
[K in keyof RulePatchFields<Settings>]?: RulePatchFields<Settings>[K] | null;
|
|
83
|
+
};
|
|
60
84
|
interface Result$2 {
|
|
61
85
|
eventMapping?: Rule;
|
|
62
86
|
mappingKey?: string;
|
|
@@ -96,13 +120,14 @@ type mapping_Condition = Condition;
|
|
|
96
120
|
type mapping_Loop = Loop;
|
|
97
121
|
type mapping_Map = Map;
|
|
98
122
|
type mapping_Rule<Settings = unknown> = Rule<Settings>;
|
|
123
|
+
type mapping_RulePatch<Settings = unknown> = RulePatch<Settings>;
|
|
99
124
|
type mapping_Rules<T = Rule> = Rules<T>;
|
|
100
125
|
type mapping_Value = Value;
|
|
101
126
|
type mapping_ValueConfig = ValueConfig;
|
|
102
127
|
type mapping_ValueType = ValueType;
|
|
103
128
|
type mapping_Values = Values;
|
|
104
129
|
declare namespace mapping {
|
|
105
|
-
export type { mapping_Condition as Condition, Config$7 as Config, Context$6 as Context, Data$1 as Data, Fn$4 as Fn, mapping_Loop as Loop, mapping_Map as Map, Policy$1 as Policy, Result$2 as Result, mapping_Rule as Rule, mapping_Rules as Rules, Validate$1 as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
130
|
+
export type { mapping_Condition as Condition, Config$7 as Config, Context$6 as Context, Data$1 as Data, Fn$4 as Fn, mapping_Loop as Loop, mapping_Map as Map, Policy$1 as Policy, Result$2 as Result, mapping_Rule as Rule, mapping_RulePatch as RulePatch, mapping_Rules as Rules, Validate$1 as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
106
131
|
}
|
|
107
132
|
|
|
108
133
|
interface BaseCacheRule {
|
|
@@ -1625,8 +1650,8 @@ declare namespace Flow {
|
|
|
1625
1650
|
* ```json
|
|
1626
1651
|
* {
|
|
1627
1652
|
* "default": { "globals": { ... }, "consent": { ... } },
|
|
1628
|
-
* "web": { "
|
|
1629
|
-
* "server": { "
|
|
1653
|
+
* "web": { "extend": "default", "events": { ... } },
|
|
1654
|
+
* "server": { "extend": "default", "events": { ... } }
|
|
1630
1655
|
* }
|
|
1631
1656
|
* ```
|
|
1632
1657
|
*/
|
|
@@ -1638,11 +1663,11 @@ declare namespace Flow {
|
|
|
1638
1663
|
* globals, context, custom, user, consent.
|
|
1639
1664
|
* Entity-action schemas live under `events`.
|
|
1640
1665
|
*
|
|
1641
|
-
* Use `
|
|
1666
|
+
* Use `extend` to inherit from another named contract (additive merge).
|
|
1642
1667
|
*/
|
|
1643
1668
|
interface ContractRule {
|
|
1644
1669
|
/** Inherit from another named contract entry. */
|
|
1645
|
-
|
|
1670
|
+
extend?: string;
|
|
1646
1671
|
/** Contract revision marker. */
|
|
1647
1672
|
tagging?: number;
|
|
1648
1673
|
/** Human-readable note. */
|
|
@@ -2772,6 +2797,14 @@ declare function getByPath(event: unknown, key?: string, defaultValue?: unknown)
|
|
|
2772
2797
|
* @returns A new object with the updated value.
|
|
2773
2798
|
*/
|
|
2774
2799
|
declare function setByPath<T = unknown>(obj: T, key: string, value: unknown): T;
|
|
2800
|
+
/**
|
|
2801
|
+
* Deletes a value in an object by a dot-notation string.
|
|
2802
|
+
* Returns a new object; the input is not mutated. No-op when the path is
|
|
2803
|
+
* absent or the target is neither an object nor an array. Numeric segments
|
|
2804
|
+
* index into arrays; a final numeric segment splices the element out so no
|
|
2805
|
+
* empty slot is left behind.
|
|
2806
|
+
*/
|
|
2807
|
+
declare function deleteByPath<T = unknown>(obj: T, key: string): T;
|
|
2775
2808
|
|
|
2776
2809
|
declare function flattenIncludeSections(event: DeepPartialEvent, sections: string[]): Record<string, unknown>;
|
|
2777
2810
|
|
|
@@ -3107,6 +3140,15 @@ declare function processEventMapping<T extends DeepPartialEvent | Event>(event:
|
|
|
3107
3140
|
silent: boolean;
|
|
3108
3141
|
}>;
|
|
3109
3142
|
|
|
3143
|
+
/**
|
|
3144
|
+
* Resolve a user mapping rule against a package-shipped default rule.
|
|
3145
|
+
* - No extend/remove → replace (clone of override; today's behavior).
|
|
3146
|
+
* - extend → partial rule deep-merged onto base (null clears a field).
|
|
3147
|
+
* - remove → carried onto the merged rule for eval-time output stripping.
|
|
3148
|
+
* The returned rule never contains `extend`.
|
|
3149
|
+
*/
|
|
3150
|
+
declare function mergeMappingRule(base: Rule, override: Rule): Rule;
|
|
3151
|
+
|
|
3110
3152
|
/**
|
|
3111
3153
|
* Environment mocking utilities for walkerOS destinations
|
|
3112
3154
|
*
|
|
@@ -3518,7 +3560,7 @@ declare function fetchPackageSchema(packageName: string, options?: {
|
|
|
3518
3560
|
}): Promise<WalkerOSPackageInfo>;
|
|
3519
3561
|
|
|
3520
3562
|
/**
|
|
3521
|
-
* Resolve all named contracts: process
|
|
3563
|
+
* Resolve all named contracts: process extend chains, expand wildcards,
|
|
3522
3564
|
* strip annotations from event schemas.
|
|
3523
3565
|
*
|
|
3524
3566
|
* Returns a fully resolved map where each contract entry has inherited
|
|
@@ -3672,4 +3714,4 @@ declare const REF_STORE: RegExp;
|
|
|
3672
3714
|
declare const REF_SECRET: RegExp;
|
|
3673
3715
|
declare const REF_CODE_PREFIX = "$code:";
|
|
3674
3716
|
|
|
3675
|
-
export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type SetupFn, simulation as Simulation, source as Source, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, type Validate, type ValidateEvents, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveSetup, setByPath, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, walkPath, wrapCondition, wrapFn, wrapValidate };
|
|
3717
|
+
export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type SetupFn, simulation as Simulation, source as Source, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, type Validate, type ValidateEvents, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, deleteByPath, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveSetup, setByPath, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, walkPath, wrapCondition, wrapFn, wrapValidate };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,31 @@ interface Rule<Settings = unknown> {
|
|
|
56
56
|
silent?: boolean;
|
|
57
57
|
name?: string;
|
|
58
58
|
policy?: Policy$1;
|
|
59
|
+
/**
|
|
60
|
+
* Merge mode (config layer): a partial Rule deep-merged onto the
|
|
61
|
+
* package-shipped default rule at the same key, instead of replacing it.
|
|
62
|
+
* Resolved at the consuming package's init via `mergeMappingRule`; not
|
|
63
|
+
* seen by the runtime evaluator. A `null` value clears an inherited field.
|
|
64
|
+
* Presence of `extend` or `remove` switches this rule from replace to merge.
|
|
65
|
+
*/
|
|
66
|
+
extend?: RulePatch<Settings>;
|
|
67
|
+
/**
|
|
68
|
+
* Output layer: dotted paths stripped from the produced data payload
|
|
69
|
+
* after evaluation, regardless of how each field was produced. Applied
|
|
70
|
+
* last, so it always wins.
|
|
71
|
+
*/
|
|
72
|
+
remove?: string[];
|
|
59
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* A partial Rule used by `Rule.extend`. Every field is optional, and a
|
|
76
|
+
* `null` value clears the inherited field (JSON merge-patch delete). The
|
|
77
|
+
* control fields `extend` and `remove` are excluded: a patch models only
|
|
78
|
+
* direct rule fields, matching what the runtime patch schema accepts.
|
|
79
|
+
*/
|
|
80
|
+
type RulePatchFields<Settings = unknown> = Omit<Rule<Settings>, 'extend' | 'remove'>;
|
|
81
|
+
type RulePatch<Settings = unknown> = {
|
|
82
|
+
[K in keyof RulePatchFields<Settings>]?: RulePatchFields<Settings>[K] | null;
|
|
83
|
+
};
|
|
60
84
|
interface Result$2 {
|
|
61
85
|
eventMapping?: Rule;
|
|
62
86
|
mappingKey?: string;
|
|
@@ -96,13 +120,14 @@ type mapping_Condition = Condition;
|
|
|
96
120
|
type mapping_Loop = Loop;
|
|
97
121
|
type mapping_Map = Map;
|
|
98
122
|
type mapping_Rule<Settings = unknown> = Rule<Settings>;
|
|
123
|
+
type mapping_RulePatch<Settings = unknown> = RulePatch<Settings>;
|
|
99
124
|
type mapping_Rules<T = Rule> = Rules<T>;
|
|
100
125
|
type mapping_Value = Value;
|
|
101
126
|
type mapping_ValueConfig = ValueConfig;
|
|
102
127
|
type mapping_ValueType = ValueType;
|
|
103
128
|
type mapping_Values = Values;
|
|
104
129
|
declare namespace mapping {
|
|
105
|
-
export type { mapping_Condition as Condition, Config$7 as Config, Context$6 as Context, Data$1 as Data, Fn$4 as Fn, mapping_Loop as Loop, mapping_Map as Map, Policy$1 as Policy, Result$2 as Result, mapping_Rule as Rule, mapping_Rules as Rules, Validate$1 as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
130
|
+
export type { mapping_Condition as Condition, Config$7 as Config, Context$6 as Context, Data$1 as Data, Fn$4 as Fn, mapping_Loop as Loop, mapping_Map as Map, Policy$1 as Policy, Result$2 as Result, mapping_Rule as Rule, mapping_RulePatch as RulePatch, mapping_Rules as Rules, Validate$1 as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
106
131
|
}
|
|
107
132
|
|
|
108
133
|
interface BaseCacheRule {
|
|
@@ -1625,8 +1650,8 @@ declare namespace Flow {
|
|
|
1625
1650
|
* ```json
|
|
1626
1651
|
* {
|
|
1627
1652
|
* "default": { "globals": { ... }, "consent": { ... } },
|
|
1628
|
-
* "web": { "
|
|
1629
|
-
* "server": { "
|
|
1653
|
+
* "web": { "extend": "default", "events": { ... } },
|
|
1654
|
+
* "server": { "extend": "default", "events": { ... } }
|
|
1630
1655
|
* }
|
|
1631
1656
|
* ```
|
|
1632
1657
|
*/
|
|
@@ -1638,11 +1663,11 @@ declare namespace Flow {
|
|
|
1638
1663
|
* globals, context, custom, user, consent.
|
|
1639
1664
|
* Entity-action schemas live under `events`.
|
|
1640
1665
|
*
|
|
1641
|
-
* Use `
|
|
1666
|
+
* Use `extend` to inherit from another named contract (additive merge).
|
|
1642
1667
|
*/
|
|
1643
1668
|
interface ContractRule {
|
|
1644
1669
|
/** Inherit from another named contract entry. */
|
|
1645
|
-
|
|
1670
|
+
extend?: string;
|
|
1646
1671
|
/** Contract revision marker. */
|
|
1647
1672
|
tagging?: number;
|
|
1648
1673
|
/** Human-readable note. */
|
|
@@ -2772,6 +2797,14 @@ declare function getByPath(event: unknown, key?: string, defaultValue?: unknown)
|
|
|
2772
2797
|
* @returns A new object with the updated value.
|
|
2773
2798
|
*/
|
|
2774
2799
|
declare function setByPath<T = unknown>(obj: T, key: string, value: unknown): T;
|
|
2800
|
+
/**
|
|
2801
|
+
* Deletes a value in an object by a dot-notation string.
|
|
2802
|
+
* Returns a new object; the input is not mutated. No-op when the path is
|
|
2803
|
+
* absent or the target is neither an object nor an array. Numeric segments
|
|
2804
|
+
* index into arrays; a final numeric segment splices the element out so no
|
|
2805
|
+
* empty slot is left behind.
|
|
2806
|
+
*/
|
|
2807
|
+
declare function deleteByPath<T = unknown>(obj: T, key: string): T;
|
|
2775
2808
|
|
|
2776
2809
|
declare function flattenIncludeSections(event: DeepPartialEvent, sections: string[]): Record<string, unknown>;
|
|
2777
2810
|
|
|
@@ -3107,6 +3140,15 @@ declare function processEventMapping<T extends DeepPartialEvent | Event>(event:
|
|
|
3107
3140
|
silent: boolean;
|
|
3108
3141
|
}>;
|
|
3109
3142
|
|
|
3143
|
+
/**
|
|
3144
|
+
* Resolve a user mapping rule against a package-shipped default rule.
|
|
3145
|
+
* - No extend/remove → replace (clone of override; today's behavior).
|
|
3146
|
+
* - extend → partial rule deep-merged onto base (null clears a field).
|
|
3147
|
+
* - remove → carried onto the merged rule for eval-time output stripping.
|
|
3148
|
+
* The returned rule never contains `extend`.
|
|
3149
|
+
*/
|
|
3150
|
+
declare function mergeMappingRule(base: Rule, override: Rule): Rule;
|
|
3151
|
+
|
|
3110
3152
|
/**
|
|
3111
3153
|
* Environment mocking utilities for walkerOS destinations
|
|
3112
3154
|
*
|
|
@@ -3518,7 +3560,7 @@ declare function fetchPackageSchema(packageName: string, options?: {
|
|
|
3518
3560
|
}): Promise<WalkerOSPackageInfo>;
|
|
3519
3561
|
|
|
3520
3562
|
/**
|
|
3521
|
-
* Resolve all named contracts: process
|
|
3563
|
+
* Resolve all named contracts: process extend chains, expand wildcards,
|
|
3522
3564
|
* strip annotations from event schemas.
|
|
3523
3565
|
*
|
|
3524
3566
|
* Returns a fully resolved map where each contract entry has inherited
|
|
@@ -3672,4 +3714,4 @@ declare const REF_STORE: RegExp;
|
|
|
3672
3714
|
declare const REF_SECRET: RegExp;
|
|
3673
3715
|
declare const REF_CODE_PREFIX = "$code:";
|
|
3674
3716
|
|
|
3675
|
-
export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type SetupFn, simulation as Simulation, source as Source, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, type Validate, type ValidateEvents, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveSetup, setByPath, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, walkPath, wrapCondition, wrapFn, wrapValidate };
|
|
3717
|
+
export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type SetupFn, simulation as Simulation, source as Source, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, type Validate, type ValidateEvents, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, deleteByPath, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveSetup, setByPath, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, walkPath, wrapCondition, wrapFn, wrapValidate };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},i={};a(i,{Cache:()=>s,Collector:()=>c,Const:()=>P,Context:()=>u,Destination:()=>f,ENV_MARKER_PREFIX:()=>X,Elb:()=>d,FatalError:()=>We,Hint:()=>N,Hooks:()=>m,Level:()=>y,Lifecycle:()=>A,Logger:()=>g,Mapping:()=>h,Matcher:()=>C,On:()=>v,REF_CODE_PREFIX:()=>J,REF_CONTRACT:()=>W,REF_ENV:()=>H,REF_FLOW:()=>B,REF_SECRET:()=>K,REF_STORE:()=>q,REF_VAR_FULL:()=>U,REF_VAR_INLINE:()=>Z,Request:()=>k,STEP_OPERATIVE_FIELDS:()=>zt,Simulation:()=>_,Source:()=>$,Store:()=>x,Transformer:()=>b,Trigger:()=>S,WalkerOS:()=>E,anonymizeIP:()=>I,applyUpdate:()=>Ft,assign:()=>ae,branch:()=>R,buildCacheContext:()=>Tt,castToProperty:()=>Ue,castValue:()=>$e,checkCache:()=>It,clone:()=>he,compileCache:()=>Rt,compileMatcher:()=>St,createDestination:()=>xe,createEvent:()=>Ae,createIngest:()=>T,createLogger:()=>ze,createMockContext:()=>Qe,createMockLogger:()=>Ye,createRespond:()=>Ot,debounce:()=>Te,deepMerge:()=>Oe,defaultClickIds:()=>Ce,fetchPackage:()=>wt,fetchPackageSchema:()=>$t,filterValues:()=>Le,flattenIncludeSections:()=>ke,formatOut:()=>Ht,getBrowser:()=>ct,getBrowserVersion:()=>lt,getByPath:()=>ve,getDeviceType:()=>pt,getEvent:()=>Ee,getFlowSettings:()=>ne,getGrantedConsent:()=>je,getHeaders:()=>rt,getId:()=>_e,getMappingEvent:()=>Be,getMappingValue:()=>qe,getMarketingParameters:()=>Ne,getNextSteps:()=>Nt,getOS:()=>ut,getOSVersion:()=>ft,getPlatform:()=>re,getSpanId:()=>Se,isArguments:()=>ie,isArray:()=>se,isBoolean:()=>ce,isCommand:()=>le,isDefined:()=>ue,isElementOrDocument:()=>fe,isFunction:()=>pe,isNumber:()=>de,isObject:()=>me,isPathStepEntry:()=>Zt,isPropertyType:()=>Ve,isSameType:()=>ge,isString:()=>ye,mcpError:()=>xt,mcpResult:()=>jt,mergeContractSchemas:()=>D,mockEnv:()=>Ge,packageNameToVariable:()=>te,parseUserAgent:()=>st,processEventMapping:()=>Je,requestToData:()=>et,requestToParameter:()=>tt,resolveContracts:()=>z,resolveSetup:()=>ot,setByPath:()=>be,stepId:()=>l,storeCache:()=>Mt,throttle:()=>Re,throwError:()=>M,transformData:()=>nt,traverseEnv:()=>Xe,trim:()=>at,tryCatch:()=>Ze,tryCatchAsync:()=>He,useHooks:()=>it,validateStepEntry:()=>Ut,walkPath:()=>Q,wrapCondition:()=>mt,wrapFn:()=>gt,wrapValidate:()=>yt}),module.exports=(e=i,((e,a,i,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let c of r(a))o.call(e,c)||c===i||t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={},c={};function l(e,t){if("collector"===e)return"collector";if(!t)throw new Error(`stepId(${e}) requires an id`);return`${e}.${t}`}a(c,{stepId:()=>l});var u={},f={};function p(e,t){const n=e.destinations[t];if(!n)throw new Error(`Destination not found: ${t}`);return n}a(f,{getDestination:()=>p});var d={},m={},g={};a(g,{Level:()=>y});var y=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(y||{}),h={},v={},b={};function w(e,t){const n=e.transformers[t];if(!n)throw new Error(`Transformer not found: ${t}`);return n}a(b,{getTransformer:()=>w});var k={},$={};function j(e,t){const n=e.sources[t];if(!n)throw new Error(`Source not found: ${t}`);return n}a($,{getSource:()=>j});var x={};function O(e,t){const n=e.stores[t];if(!n)throw new Error(`Store not found: ${t}`);return n}a(x,{getStore:()=>O});var S={},A={},E={},_={},C={},N={},P={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function T(e){return{_meta:{hops:0,path:[e]}}}function R(e,t){return{event:e,next:t}}function I(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function M(e){throw new Error(String(e))}var F=new Set(["description","examples","title","$comment"]);function z(e){const t={},n=new Set;function r(o){if(t[o])return t[o];n.has(o)&&M(`Circular extends chain detected: ${[...n,o].join(" → ")}`);const a=e[o];a||M(`Contract "${o}" not found`),n.add(o);let i={};if(a.extends){i=function(e,t){const n={};void 0===e.tagging&&void 0===t.tagging||(n.tagging=t.tagging??e.tagging);void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);e.schema&&t.schema?n.schema=D(e.schema,t.schema):(e.schema||t.schema)&&(n.schema={...e.schema||t.schema});if(e.events||t.events){const r={},o=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of o){const o=e.events?.[n]||{},a=t.events?.[n]||{},i=new Set([...Object.keys(o),...Object.keys(a)]);r[n]={};for(const e of i){const t=o[e],i=a[e];r[n][e]=t&&i?D(t,i):{...t||i}}}n.events=r}return n}(r(a.extends),a)}else i={...a};if(delete i.extends,i.events&&(i.events=function(e){const t={};for(const n of Object.keys(e))if("*"!==n){t[n]={};for(const r of Object.keys(e[n]||{})){let o={};const a=e["*"]?.["*"];a&&(o=D(o,a));const i=e["*"]?.[r];i&&"*"!==r&&(o=D(o,i));const s=e[n]?.["*"];s&&"*"!==r&&(o=D(o,s));const c=e[n]?.[r];c&&(o=D(o,c)),t[n][r]=o}}e["*"]&&(t["*"]={...e["*"]});return t}(i.events)),i.events){const e={};for(const[t,n]of Object.entries(i.events)){e[t]={};for(const[r,o]of Object.entries(n))e[t][r]=V(o)}i.events=e}return n.delete(o),t[o]=i,i}for(const t of Object.keys(e))r(t);return t}function D(e,t){const n={...e};for(const r of Object.keys(t)){const o=e[r],a=t[r];"required"===r&&Array.isArray(o)&&Array.isArray(a)?n[r]=[...new Set([...o,...a])]:L(o)&&L(a)?n[r]=D(o,a):n[r]=a}return n}function V(e){const t={};for(const[n,r]of Object.entries(e))F.has(n)||(null===r||"object"!=typeof r||Array.isArray(r)?t[n]=r:t[n]=V(r));return t}function L(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var U=/^\$var\.([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)$/,Z=/\$var\.([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)/g,H=/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,W=/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,B=/^\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?$/,q=/^\$store\.([a-zA-Z_][a-zA-Z0-9_]*)$/,K=/^\$secret\.([A-Z0-9_]+)$/,J="$code:";function G(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var X="__WALKEROS_ENV:";function Y(e,t,n){const r=`$flow.${e}${t?`.${t}`:""}`;if("unknown-flow"===n)return`${r} cannot resolve: flow "${e}" does not exist in this config.`;return`${r} is empty. Set ${t?`flows.${e}.config.${t}`:`flows.${e}.config`}, or run \`walkeros deploy ${e}\` first.`}function Q(e,t,n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const a=r[e];if(null==o||"object"!=typeof o){const o=r.slice(0,e).join(".");M(`Path "${t}" not found in "${n}": "${a}" does not exist${o?` in "${o}"`:""}`)}const i=o;if(!(a in i)){const o=r.slice(0,e).join(".");M(`Path "${t}" not found in "${n}": "${a}" does not exist${o?` in "${o}"`:""}`)}o=i[a]}return o}function ee(e,t,n,r,o,a){if("string"==typeof e){const i=e.match(U);if(i){const e=i[1].split("."),s=e[0],c=e.slice(1).join(".");void 0===t[s]&&M(`Variable "${s}" not found`);const l=a??new Set;if(l.has(s)){M(`Cyclic $var reference: ${[...l,s].join(" -> ")}`)}let u;l.add(s);try{u=ee(t[s],t,n,r,o,l)}finally{l.delete(s)}return c&&(u=Q(u,c,`$var.${s}`)),u}const s=e.match(W);if(s&&r){const e=s[1],t=s[2];e in r||M(`Contract "${e}" not found`);let n=r[e];return t&&(n=Q(n,t,`$contract.${e}`)),n}const c=e.match(B);if(c){const t=c[1],r=c[2],a=!1===n?.strictFlowRefs;o||M(`$flow.${t}${r?`.${r}`:""} cannot be resolved without a flow resolver`);const i=o(t);if(!i){if(a)return n?.onWarning?.(Y(t,r,"unknown-flow")),e;M(`Flow "${t}" not found in $flow.${t}`)}let s=i;if(r)if(a){try{s=Q(s,r,`$flow.${t}`)}catch{return n?.onWarning?.(Y(t,r,"missing-key")),e}if(null==s||""===s)return n?.onWarning?.(Y(t,r,"missing-key")),e}else s=Q(s,r,`$flow.${t}`);return s}let l=e.replace(Z,(e,i)=>{const s=i.split("."),c=s[0],l=s.slice(1).join(".");void 0===t[c]&&M(`Variable "${c}" not found`);const u=a??new Set;if(u.has(c)){M(`Cyclic $var reference: ${[...u,c].join(" -> ")}`)}let f;u.add(c);try{f=ee(t[c],t,n,r,o,u)}finally{u.delete(c)}if(l&&(f=Q(f,l,`$var.${c}`)),null===f||"string"!=typeof f&&"number"!=typeof f&&"boolean"!=typeof f){M(`Variable "${i}" resolves to non-scalar (${Array.isArray(f)?"array":typeof f}) and cannot be inlined into a string. Use it as a whole-string reference: "$var.${i}"`)}return String(f)});return l=l.replace(H,(e,t,r)=>n?.deferred?void 0!==r?`${X}${t}:${r}`:`${X}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==r?r:void M(`Environment variable "${t}" not found and no default provided`)),l}if(Array.isArray(e))return e.map(e=>ee(e,t,n,r,o,a));if(null!==e&&"object"==typeof e){const i={};for(const[s,c]of Object.entries(e))i[s]=ee(c,t,n,r,o,a);return i}return e}function te(e){const t=e.startsWith("@"),n=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return t?"_"+n:n}function ne(e,t,n){const r=new Map,o=new Set,a=[],i=t=>{if(r.has(t))return r.get(t);const s=e.flows[t];if(s){if(o.has(t)){M(`Cyclic $flow reference: ${[...a,t].join(" -> ")}`)}o.add(t),a.push(t);try{const o=G(e.variables,s.variables),a=ee(s.config??{},o,n,void 0,i);return r.set(t,a),a}finally{o.delete(t),a.pop()}}},s=Object.keys(e.flows);t||(1===s.length?t=s[0]:M(`Multiple flows found (${s.join(", ")}). Please specify a flow.`));const c=e.flows[t];c||M(`Flow "${t}" not found. Available: ${s.join(", ")}`),o.add(t),a.push(t);try{return function(e,t,n,r){const o=JSON.parse(JSON.stringify(t));let a;if(e.contract){const o=G(e.variables,t.variables);a=z(ee(e.contract,o,n,void 0,r))}if(o.config){const i=G(e.variables,t.variables);o.config=ee(o.config,i,n,a,r)}if(o.sources)for(const[i,s]of Object.entries(o.sources)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.sources[i]={package:s.package,import:s.import,config:l,env:u,primary:s.primary,variables:s.variables,before:s.before,next:s.next,cache:s.cache,validate:s.validate,code:s.code}}if(o.destinations)for(const[i,s]of Object.entries(o.destinations)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.destinations[i]={package:s.package,import:s.import,config:l,env:u,variables:s.variables,before:s.before,next:s.next,cache:s.cache,validate:s.validate,code:s.code}}if(o.stores)for(const[i,s]of Object.entries(o.stores)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.stores[i]={package:s.package,import:s.import,config:l,env:u,cache:s.cache,variables:s.variables,code:s.code}}if(o.transformers)for(const[i,s]of Object.entries(o.transformers)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.transformers[i]={package:s.package,import:s.import,config:l,env:u,variables:s.variables,before:s.before,next:s.next,cache:s.cache,validate:s.validate,code:s.code}}if(o.collector){const i=G(e.variables,t.variables),s=ee(o.collector,i,n,a,r);o.collector=s}return o}(e,c,n,i)}finally{o.delete(t),a.pop()}}function re(e){const t=e.config?.platform;if("web"===t||"server"===t)return t;M('Flow must have config.platform set to "web" or "server"')}var oe={merge:!0,shallow:!0,extend:!0};function ae(e,t={},n={}){n={...oe,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const a=e[r];return n.merge&&Array.isArray(a)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...a]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function ie(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function se(e){return Array.isArray(e)}function ce(e){return"boolean"==typeof e}function le(e){return"walker"===e}function ue(e){return void 0!==e}function fe(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function pe(e){return"function"==typeof e}function de(e){return"number"==typeof e&&!Number.isNaN(e)}function me(e){return"object"==typeof e&&null!==e&&!se(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ge(e,t){return typeof e==typeof t}function ye(e){return"string"==typeof e}function he(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=he(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(he(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function ve(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&se(o)){const t=r.slice(e+1).join("."),a=[];for(const e of o){const r=ve(e,t,n);a.push(r)}return a}if(o=me(o)||se(o)?o[t]:void 0,void 0===o)break}return ue(o)?o:n}function be(e,t,n){if(!me(e))return e;const r=he(e),o=t.split(".");let a=r;for(let e=0;e<o.length;e++){const t=o[e];e===o.length-1?a[t]=n:(t in a&&"object"==typeof a[t]&&null!==a[t]||(a[t]={}),a=a[t])}return r}var we={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,timing:e.timing})};function ke(e,t){const n={},r=t.includes("all")?Object.keys(we):t;for(const t of r){const r=we[t];if(!r)continue;const o=r(e);if(me(o))for(const[e,r]of Object.entries(o)){if(void 0===r)continue;const o="context"===t&&Array.isArray(r)?r[0]:r;n[`${t}_${e}`]=o}}return n}function $e(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function je(e,t={},n={}){const r={...t,...n},o={};let a=!e||0===Object.keys(e).length;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(a=!0))}),!!a&&o}function xe(e,t){const n={...e};return n.config=ae(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=ae(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=ae(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function Oe(e,t){if(!me(t))return e;for(const n of Object.keys(t)){const r=t[n];void 0!==r&&(me(r)&&me(e[n])?Oe(e[n],r):e[n]=r)}return e}function Se(){let e="";for(let t=0;t<16;t++)e+=(16*Math.random()|0).toString(16);return e}function Ae(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=ae({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"}}],consent:{functional:!0},id:e.id||Se(),trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,source:{type:"collector",schema:"4"}},e,{merge:!1});if(e.name){const[t,r]=e.name.split(" ")??[];t&&r&&(n.entity=t,n.action=r)}return n}function Ee(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),r={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return Ae({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...r.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:r.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.walkeros.io/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...r,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...r,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...r.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function _e(e=6,t){if(t){const n=t.length;let r="";for(let o=0;o<e;o++)r+=t[Math.random()*n|0];return r}let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}var Ce=[{param:"gclid",platform:"google"},{param:"wbraid",platform:"google"},{param:"gbraid",platform:"google"},{param:"dclid",platform:"google"},{param:"gclsrc",platform:"google"},{param:"fbclid",platform:"meta"},{param:"igshid",platform:"meta"},{param:"msclkid",platform:"microsoft"},{param:"ttclid",platform:"tiktok"},{param:"twclid",platform:"twitter"},{param:"li_fat_id",platform:"linkedin"},{param:"epik",platform:"pinterest"},{param:"sclid",platform:"snapchat"},{param:"sccid",platform:"snapchat"},{param:"rdt_cid",platform:"reddit"},{param:"qclid",platform:"quora"},{param:"yclid",platform:"yandex"},{param:"ymclid",platform:"yandex"},{param:"ysclid",platform:"yandex"},{param:"dicbo",platform:"outbrain"},{param:"obclid",platform:"outbrain"},{param:"tblci",platform:"taboola"},{param:"mc_cid",platform:"mailchimp"},{param:"mc_eid",platform:"mailchimp"},{param:"_kx",platform:"klaviyo"},{param:"_hsenc",platform:"hubspot"},{param:"_hsmi",platform:"hubspot"},{param:"s_kwcid",platform:"adobe"},{param:"ef_id",platform:"adobe"},{param:"mkt_tok",platform:"adobe"},{param:"irclickid",platform:"impact"},{param:"cjevent",platform:"cj"},{param:"_branch_match_id",platform:"branch"}];function Ne(e,t={},n=[]){const r={};Object.entries(ae({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const o=e.searchParams.get(t);o&&(r[n]=o)});const o=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(Ce.map(e=>e.param));return[...Ce.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):Ce,a=new Map;e.searchParams.forEach((e,t)=>{e&&a.set(t.toLowerCase(),e)});for(const e of o){const t=a.get(e.param);t&&(r[e.param]=t,r.clickId||(r.clickId=e.param,r.platform=e.platform))}return r}function Pe(e,t){return"number"==typeof e?{wait:e}:e?{wait:e.wait??t,size:e.size,age:e.age}:{wait:t}}function Te(e,t=1e3,n=!1){const{wait:r,size:o,age:a}=Pe(t,1e3);let i,s,c=null,l=null,u=!1,f=[],p=0;const d=()=>{c&&(clearTimeout(c),c=null),l&&(clearTimeout(l),l=null),p=0,s=void 0},m=()=>{const t=s,n=f;if(d(),f=[],t)return i=e(...t),n.forEach(e=>e(i)),i;n.forEach(e=>e(void 0))},g=(...t)=>new Promise(d=>{const g=n&&!u;if(s=t,p+=1,f.push(d),c&&clearTimeout(c),c=setTimeout(()=>{c=null,n&&!u||m()},r),void 0===a||l||(l=setTimeout(()=>{l=null,m()},a)),void 0!==o&&p>=o)m();else if(g){u=!0,i=e(...t);const n=f;f=[],n.forEach(e=>e(i))}});return g.flush=()=>s||0!==f.length?new Promise(e=>{f.push(e),m()}):Promise.resolve(void 0),g.cancel=()=>{const e=f;f=[],d(),e.forEach(e=>e(void 0))},g.size=()=>p,g}function Re(e,t=1e3){const{wait:n}=Pe(t,1e3);let r=null;return function(...t){if(null===r)return r=setTimeout(()=>{r=null},n),e(...t)}}function Ie(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Me(e,t){let n,r={};return e instanceof Error?(n=e.message,r.error=Ie(e)):n=e,void 0!==t&&(t instanceof Error?r.error=Ie(t):"object"==typeof t&&null!==t?(r={...r,...t},"error"in r&&r.error instanceof Error&&(r.error=Ie(r.error))):r.value=t),{message:n,context:r}}var Fe=(e,t,n,r)=>{const o=`${y[e]}${r.length>0?` [${r.join(":")}]`:""}`,a=Object.keys(n).length>0,i=0===e?console.error:1===e?console.warn:console.log;a?i(o,t,n):i(o,t)};function ze(e={}){return De({level:void 0!==e.level?function(e){return"string"==typeof e?y[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function De(e){const{level:t,handler:n,jsonHandler:r,scope:o}=e,a=(e,r,a)=>{if(e<=t){const t=Me(r,a);n?n(e,t.message,t.context,o,Fe):Fe(e,t.message,t.context,o)}};return{error:(e,t)=>a(0,e,t),warn:(e,t)=>a(1,e,t),info:(e,t)=>a(2,e,t),debug:(e,t)=>a(3,e,t),throw:(e,t)=>{const r=Me(e,t);throw n?n(0,r.message,r.context,o,Fe):Fe(0,r.message,r.context,o),new Error(r.message)},json:e=>{r?r(e):console.log(JSON.stringify(e,null,2))},scope:e=>De({level:t,handler:n,jsonHandler:r,scope:[...o,e]})}}function Ve(e){return ce(e)||ye(e)||de(e)||!ue(e)||se(e)&&e.every(Ve)||me(e)&&Object.values(e).every(Ve)}function Le(e){return ce(e)||ye(e)||de(e)?e:ie(e)?Le(Array.from(e)):se(e)?e.map(e=>Le(e)).filter(e=>void 0!==e):me(e)?Object.entries(e).reduce((e,[t,n])=>{const r=Le(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function Ue(e){return Ve(e)?e:void 0}function Ze(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function He(e,t,n){return async function(...r){try{return await e(...r)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}var We=class e extends Error{constructor(t,n){super(t,n),this.name="FatalError",Object.setPrototypeOf(this,e.prototype)}};async function Be(e,t,n){const[r,o]=(e.name||"").split(" ");if(!t||!r||!o)return{};let a,i="",s=r,c=o;const l=t=>{if(!t)return;return(se(t)?t:[t]).find(t=>{if(!t.condition)return!0;if(!n)return Boolean(t.condition(e,void 0));const r={event:e,mapping:t,collector:n,logger:n.logger,consent:me(e)&&e.consent||n.consent};return Boolean(t.condition(e,r))})};t[s]||(s="*");const u=t[s];return u&&(u[c]||(c="*"),a=l(u[c])),a||(s="*",c="*",a=l(t[s]?.[c])),a&&(i=`${s} ${c}`),{eventMapping:a,mappingKey:i}}async function qe(e,t={},n={}){if(!ue(e))return;const r=me(e)&&e.consent||n.consent||n.collector?.consent,o=n.event??(me(e)?e:{});if(!n.collector)throw new Error("getMappingValue: context.collector is required");const a={event:o,mapping:t,collector:n.collector,logger:n.collector.logger,consent:r},i=se(t)?t:[t];for(const t of i){const r=await He(Ke,e=>{if(e instanceof We)throw e;n.collector&&n.collector.status.failed++,a.logger.error("mapping processing failed",{event:o,error:e})})(e,t,{...a,mapping:t});if(ue(r))return r}}async function Ke(e,t,n){return(se(t)?t:[t]).reduce(async(t,r)=>{const o=await t;if(o)return o;const a=ye(r)?{key:r}:r;if(!Object.keys(a).length)return;const{condition:i,consent:s,fn:c,key:l,loop:u,map:f,set:p,validate:d,value:m}=a,g={...n,mapping:r};if(i&&!await He(i,e=>{if(e instanceof We)throw e;return g.logger.error("mapping condition failed",{event:g.event,error:e}),!1})(e,g))return;if(s&&!je(s,g.consent))return m;let y=ue(m)?m:e;if(c&&(y=await He(c,e=>{if(e instanceof We)throw e;g.logger.error("mapping fn failed",{event:g.event,error:e})})(e,g)),l&&(y=ve(e,l,m)),u){const[t,n]=u,r="this"===t?[e]:await qe(e,t,g);se(r)&&(y=(await Promise.all(r.map(e=>qe(e,n,g)))).filter(ue))}else f?y=await Object.entries(f).reduce(async(t,[n,r])=>{const o=await t,a=await qe(e,r,g);return ue(a)&&(o[n]=a),o},Promise.resolve({})):p&&(y=await Promise.all(p.map(t=>Ke(e,t,g))));d&&!await He(d,e=>{if(e instanceof We)throw e;return g.logger.error("mapping validate failed",{event:g.event,error:e}),!1})(y,g)&&(y=void 0);const h=Ue(y);return ue(h)?h:Ue(m)},Promise.resolve(void 0))}async function Je(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await qe(e,r,{collector:n,event:e});e=be(e,t,o)}));const{eventMapping:r,mappingKey:o}=await Be(e,t.mapping,n);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await qe(e,r,{collector:n,event:e});e=be(e,t,o)}));let a=t.data&&await qe(e,t.data,{collector:n,event:e});const i=Boolean(r?.silent);if(r){if(r.ignore)return{event:e,data:a,mapping:r,mappingKey:o,ignore:!0,silent:i};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await qe(e,r.data,{collector:n,event:e});a=me(a)&&me(t)?ae(a,t):t}}const s=r?.include??t.include;if(s&&s.length>0){const t=ke(e,s);Object.keys(t).length>0&&(a=me(a)?ae(t,a):a??t)}return{event:e,data:a,mapping:r,mappingKey:o,ignore:!1,silent:i}}function Ge(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const a=e[o],i=[...r,o];return"function"==typeof a?a.prototype&&a.prototype.constructor===a?a:(...e)=>{const r=t(i,e,a);if(r&&"object"==typeof r)return n(r,i);const o=a(...e);return o&&"object"==typeof o?n(o,i):r}:a&&"object"==typeof a?n(a,i):a}});return n(e)}function Xe(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[a,i]of Object.entries(e)){const e=[...r,a];Array.isArray(o)?o[Number(a)]=t(i,e):o[a]=t(i,e),i&&"object"==typeof i&&"function"!=typeof i&&(Array.isArray(o)?o[Number(a)]=n(i,e):o[a]=n(i,e))}return o};return n(e)}function Ye(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=Ye();return e.push(n),n});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,json:jest.fn(),scope:n,scopedLoggers:e}}function Qe(e={}){return{collector:{},config:{},env:{},logger:Ye(),id:"test",ingest:T("test"),...e}}function et(e){const t=String(e),n=t.split("?")[1]||t;return Ze(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const r=n.split(/[[\]]+/).filter(Boolean);let o=t;r.forEach((t,n)=>{const a=n===r.length-1;if(se(o)){const i=parseInt(t,10);a?o[i]=$e(e):(o[i]=o[i]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[i])}else me(o)&&(a?o[t]=$e(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function tt(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(se(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):me(o)?Object.entries(o).forEach(([t,n])=>r(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(o))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>r(e,t)),t.join("&"))}function nt(e){return void 0===e||ge(e,"")?e:JSON.stringify(e)}function rt(e={}){return ae({"Content-Type":"application/json; charset=utf-8"},e)}function ot(e,t){return!1===e||void 0===e?null:!0===e?t:{...t,...e}}function at(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function it(e,t,n,r){return function(...o){let a;const i="pre"+t,s="post"+t,c=n[i],l=n[s],u=(e,t)=>{r?r.warn(e,{error:t}):console.warn(e,t)};if(c)try{a=c({fn:e},...o)}catch(t){u(`Hook ${String(i)} failed, falling back to original function`,t),a=e(...o)}else a=e(...o);if(l)try{a=l({fn:e,result:a},...o)}catch(e){u(`Hook ${String(s)} failed, keeping original result`,e)}return a}}function st(e){return e?{userAgent:e,browser:ct(e),browserVersion:lt(e),os:ut(e),osVersion:ft(e),deviceType:pt(e)}:{}}function ct(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function lt(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function ut(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function ft(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function pt(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function dt(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function mt(e){const t=dt(e);return new Function("value","context",t)}function gt(e){const t=dt(e);return new Function("value","context",t)}function yt(e){const t=dt(e);return new Function("value","context",t)}var ht="https://cdn.jsdelivr.net/npm",vt="dist/walkerOS.json";function bt(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function wt(e,t){const n=t?.version||"latest",r=t?.timeout||1e4,o=new AbortController,a=setTimeout(()=>o.abort(),r),i=o.signal,s=t?.client?{"X-Walkeros-Client":t.client}:void 0;try{if(t?.baseUrl){const r=`${t.baseUrl}/api/packages/${encodeURIComponent(e)}?version=${encodeURIComponent(n)}&expand=all`,o=await fetch(r,{signal:i,...s&&{headers:s}});if(!o.ok)throw new Error(`Failed to fetch ${r} (HTTP ${o.status})`);return function(e,t,n){const r=n.schemas||{},o=n.examples||{},a=n.hints,i=n.hintKeys??(a?Object.keys(a):[]),s=n.exampleSummaries??[],c=n.platform;return{packageName:n.package||e,version:"string"==typeof n.version?n.version:t,...void 0!==n.description&&{description:n.description},...void 0!==n.type&&{type:n.type},...void 0!==c&&{platform:c},schemas:r,examples:o,...void 0!==n.docs&&{docs:n.docs},...void 0!==n.source&&{source:n.source},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:i,exampleSummaries:s}}(e,n,await o.json())}const r=`${ht}/${e}@${n}`,o=await kt(`${r}/package.json`,i,s);return function(e,t,n,r){const o=r.$meta||{},a=r.schemas||{},i=r.examples||{},s=r.hints,c=s?Object.keys(s):[],l=[],u=i.step||{};for(const[e,t]of Object.entries(u)){const n=t,r={name:e};"string"==typeof n?.description&&(r.description=n.description),l.push(r)}const f="string"==typeof o.docs?o.docs:void 0,p="string"==typeof o.source?o.source:void 0;return{packageName:e,version:"string"==typeof n.version?n.version:t,description:"string"==typeof n.description?n.description:void 0,type:"string"==typeof o.type?o.type:void 0,platform:bt(o.platform),schemas:a,examples:i,...f?{docs:f}:{},...p?{source:p}:{},...s&&Object.keys(s).length>0?{hints:s}:{},hintKeys:c,exampleSummaries:l}}(e,n,o,await kt(`${r}/${vt}`,i,s))}finally{clearTimeout(a)}}async function kt(e,t,n){const r=await fetch(e,{signal:t,...n&&{headers:n}});if(!r.ok)throw new Error(`Failed to fetch ${e} (HTTP ${r.status})`);return await r.json()}async function $t(e,t){const n=await wt(e,t);return{packageName:n.packageName,version:n.version,type:n.type,platform:n.platform,schemas:n.schemas,examples:n.examples,...n.hints?{hints:n.hints}:{}}}function jt(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function xt(e,t){let n,r,o,a;if(e instanceof Error){n=e.message;const t=e;t.code&&(o=t.code),Array.isArray(t.details)&&(a=t.details)}else if("string"==typeof e)n=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const t=e.issues;n=t.map(e=>e.message).join("; "),r=t[0]?.path?.join(".")||void 0}else n=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const i={error:n};return t&&(i.hint=t),r&&(i.path=r),o&&(i.code=o),a&&(i.details=a),{content:[{type:"text",text:JSON.stringify(i)}],structuredContent:i,isError:!0}}function Ot(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function St(e){if(void 0===e||"*"===e)return()=>!0;if("and"in e){const t=e.and.map(St);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(St);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:r,not:o}=e,a=function(e,t){switch(e){case"eq":return e=>String(e??"")===t;case"contains":return e=>String(e??"").includes(t);case"prefix":return e=>String(e??"").startsWith(t);case"suffix":return e=>String(e??"").endsWith(t);case"regex":{const e=new RegExp(t);return t=>e.test(String(t??""))}case"gt":{const e=Number(t);return t=>Number(t)>e}case"lt":{const e=Number(t);return t=>Number(t)<e}case"exists":return e=>null!=e}}(n,r);return e=>{const n=ve(e,t),r=a(n);return o?!r:r}}(e)}function At(e){return Array.isArray(e)&&e.length>0&&e.every(e=>function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&("match"in e||"next"in e||"one"in e||"many"in e)}(e))}function Et(e){return e.map(e=>{if("string"==typeof e)return{match:()=>!0,next:{type:"static",value:e}};if(Array.isArray(e))return{match:()=>!0,next:_t(e)??{type:"chain",value:[]}};const t=e;return{match:t.match?St(t.match):()=>!0,next:_t(t)??{type:"chain",value:[]}}})}function _t(e){if(null==e)return;if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(At(e))return _t({one:e});if(e.every(e=>"string"==typeof e))return{type:"chain",value:e};const t=[];for(const n of e){const e=_t(n);void 0!==e&&t.push(e)}if(0===t.length)return;return{type:"sequence",value:t}}const t=e;if("next"in t&&void 0!==t.next)return t.match?{type:"gate",match:St(t.match),next:_t(t.next)}:_t(t.next);if("one"in t&&t.one){const e=Et(t.one);return t.match?{type:"gate",match:St(t.match),next:{type:"one",routes:e}}:{type:"one",routes:e}}if("many"in t&&t.many){const e=Et(t.many);return t.match?{type:"gate",match:St(t.match),next:{type:"many",routes:e}}:{type:"many",routes:e}}return t.match?{type:"gate",match:St(t.match)}:void 0}var Ct=new WeakMap;function Nt(e,t={}){if(null==e)return[];let n;if("object"==typeof e){const t=Ct.get(e);t?n=t:(n=_t(e),n&&Ct.set(e,n))}else n=_t(e);if(!n)return[];const r=Pt(n,t);return void 0===r?[]:Array.isArray(r)?r:[r]}function Pt(e,t={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;if("gate"===e.type){if(!e.match(t))return;return Pt(e.next,t)}if("sequence"===e.type){const n=[];for(const r of e.value){const e=Pt(r,t);void 0!==e&&(Array.isArray(e)?n.push(...e):n.push(e))}return n.length>0?n:void 0}if("many"===e.type){const n=[];for(const r of e.routes){if(!r.match(t))continue;const e=Pt(r.next,t);void 0!==e&&(Array.isArray(e)?n.push(...e):n.push(e))}return n.length>0?n:void 0}for(const n of e.routes)if(n.match(t))return Pt(n.next,t)}}function Tt(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function Rt(e){return{stop:e.stop??!1,storeId:e.store,namespace:e.namespace,rules:e.rules.map(e=>({match:e.match?St(e.match):()=>!0,key:e.key,ttl:e.ttl,update:e.update}))}}async function It(e,t,n,r){const o=e.rules.find(e=>e.match(n));if(!o)return null;const a=o.key.map(e=>String(ve(n,e)??""));if(a.every(e=>""===e))return null;const i=a.join(":"),s=r??e.namespace,c=s?`${s}:${i}`:i,l=await t.get(c);return void 0!==l?{status:"HIT",key:c,value:l,rule:o}:{status:"MISS",key:c,rule:o}}function Mt(e,t,n,r){e.set(t,n,1e3*r)}async function Ft(e,t,n,r){if(!t)return e;let o=e;for(const[e,a]of Object.entries(t)){o=be(o,e,await qe(n,a,{collector:r}))}return o}var zt={Source:["code","package","import","before","next","cache"],Transformer:["code","package","import","before","next","cache","mapping"],Destination:["code","package","import","before","next","cache"],Store:["code","package","import","cache"]},Dt=["config","env","validate","variables","examples","disabled","id","logger","mock","chainMocks"],Vt={Source:["primary"],Transformer:[],Destination:[],Store:[]},Lt=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Ut(e,t){const n=function(e){return new Set([...zt[e],...Dt,...Vt[e]])}(t);for(const r of Object.keys(e))if(!n.has(r))return{ok:!1,code:"UNKNOWN_KEY",key:r,reason:`Unknown key "${r}" on ${t}. Allowed: ${[...n].sort().join(", ")}.`};const r=void 0!==e.package,o=void 0!==e.import,a=void 0!==e.code;return a&&"string"==typeof e.code?{ok:!1,code:"OBSOLETE_CODE_STRING",key:"code",reason:`code: "<name>" is no longer supported. Use import: "${e.code}" with the package field instead.`}:a&&("object"!=typeof e.code&&"function"!=typeof e.code||null===e.code||Array.isArray(e.code))?{ok:!1,code:"INVALID_CODE_SHAPE",key:"code",reason:"code must be an object ({ push, type?, init? }) or a resolved function value."}:a&&r?{ok:!1,code:"CONFLICT",key:"package",reason:"Cannot specify both `code` and `package`. Use one or the other."}:a&&o?{ok:!1,code:"CONFLICT",key:"import",reason:"Cannot specify both `code` and `import`."}:o&&!r?{ok:!1,code:"MISSING_PACKAGE",key:"import",reason:"`import` requires `package` to be set."}:!o||"string"==typeof e.import&&Lt.test(e.import)?{ok:!0}:{ok:!1,code:"INVALID_IMPORT",key:"import",reason:`import must match ${Lt.source}. Got: ${JSON.stringify(e.import)}.`}}function Zt(e,t){return"Transformer"===t&&(void 0===e.code&&void 0===e.package&&void 0===e.import&&(void 0!==e.before||void 0!==e.next||void 0!==e.cache||void 0!==e.mapping))}function Ht(e){return 0===e.length?"// no output":e.map(Wt).join(";\n\n")}function Wt(e){const[t,...n]=e,r=n.map(Bt).join(", ");return"return"===t?r?`return ${r}`:"return":`${t}(${r})`}function Bt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},i={};a(i,{Cache:()=>s,Collector:()=>c,Const:()=>P,Context:()=>u,Destination:()=>f,ENV_MARKER_PREFIX:()=>X,Elb:()=>d,FatalError:()=>Be,Hint:()=>N,Hooks:()=>m,Level:()=>y,Lifecycle:()=>A,Logger:()=>g,Mapping:()=>h,Matcher:()=>C,On:()=>v,REF_CODE_PREFIX:()=>J,REF_CONTRACT:()=>W,REF_ENV:()=>H,REF_FLOW:()=>B,REF_SECRET:()=>K,REF_STORE:()=>q,REF_VAR_FULL:()=>U,REF_VAR_INLINE:()=>Z,Request:()=>k,STEP_OPERATIVE_FIELDS:()=>Lt,Simulation:()=>_,Source:()=>$,Store:()=>x,Transformer:()=>b,Trigger:()=>S,WalkerOS:()=>E,anonymizeIP:()=>I,applyUpdate:()=>Vt,assign:()=>ae,branch:()=>R,buildCacheContext:()=>Mt,castToProperty:()=>Ze,castValue:()=>je,checkCache:()=>zt,clone:()=>he,compileCache:()=>Ft,compileMatcher:()=>_t,createDestination:()=>Oe,createEvent:()=>Ee,createIngest:()=>T,createLogger:()=>De,createMockContext:()=>nt,createMockLogger:()=>tt,createRespond:()=>Et,debounce:()=>Re,deepMerge:()=>Se,defaultClickIds:()=>Ne,deleteByPath:()=>we,fetchPackage:()=>jt,fetchPackageSchema:()=>Ot,filterValues:()=>Ue,flattenIncludeSections:()=>$e,formatOut:()=>qt,getBrowser:()=>ft,getBrowserVersion:()=>pt,getByPath:()=>ve,getDeviceType:()=>gt,getEvent:()=>_e,getFlowSettings:()=>ne,getGrantedConsent:()=>xe,getHeaders:()=>it,getId:()=>Ce,getMappingEvent:()=>qe,getMappingValue:()=>Ke,getMarketingParameters:()=>Pe,getNextSteps:()=>Rt,getOS:()=>dt,getOSVersion:()=>mt,getPlatform:()=>re,getSpanId:()=>Ae,isArguments:()=>ie,isArray:()=>se,isBoolean:()=>ce,isCommand:()=>le,isDefined:()=>ue,isElementOrDocument:()=>fe,isFunction:()=>pe,isNumber:()=>de,isObject:()=>me,isPathStepEntry:()=>Bt,isPropertyType:()=>Le,isSameType:()=>ge,isString:()=>ye,mcpError:()=>At,mcpResult:()=>St,mergeContractSchemas:()=>D,mergeMappingRule:()=>Ye,mockEnv:()=>Qe,packageNameToVariable:()=>te,parseUserAgent:()=>ut,processEventMapping:()=>Ge,requestToData:()=>rt,requestToParameter:()=>ot,resolveContracts:()=>z,resolveSetup:()=>st,setByPath:()=>be,stepId:()=>l,storeCache:()=>Dt,throttle:()=>Ie,throwError:()=>M,transformData:()=>at,traverseEnv:()=>et,trim:()=>ct,tryCatch:()=>He,tryCatchAsync:()=>We,useHooks:()=>lt,validateStepEntry:()=>Wt,walkPath:()=>Q,wrapCondition:()=>ht,wrapFn:()=>vt,wrapValidate:()=>bt}),module.exports=(e=i,((e,a,i,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let c of r(a))o.call(e,c)||c===i||t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={},c={};function l(e,t){if("collector"===e)return"collector";if(!t)throw new Error(`stepId(${e}) requires an id`);return`${e}.${t}`}a(c,{stepId:()=>l});var u={},f={};function p(e,t){const n=e.destinations[t];if(!n)throw new Error(`Destination not found: ${t}`);return n}a(f,{getDestination:()=>p});var d={},m={},g={};a(g,{Level:()=>y});var y=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(y||{}),h={},v={},b={};function w(e,t){const n=e.transformers[t];if(!n)throw new Error(`Transformer not found: ${t}`);return n}a(b,{getTransformer:()=>w});var k={},$={};function j(e,t){const n=e.sources[t];if(!n)throw new Error(`Source not found: ${t}`);return n}a($,{getSource:()=>j});var x={};function O(e,t){const n=e.stores[t];if(!n)throw new Error(`Store not found: ${t}`);return n}a(x,{getStore:()=>O});var S={},A={},E={},_={},C={},N={},P={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function T(e){return{_meta:{hops:0,path:[e]}}}function R(e,t){return{event:e,next:t}}function I(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function M(e){throw new Error(String(e))}var F=new Set(["description","examples","title","$comment"]);function z(e){const t={},n=new Set;function r(o){if(t[o])return t[o];n.has(o)&&M(`Circular extend chain detected: ${[...n,o].join(" → ")}`);const a=e[o];a||M(`Contract "${o}" not found`),n.add(o);let i={};if(a.extend){i=function(e,t){const n={};void 0===e.tagging&&void 0===t.tagging||(n.tagging=t.tagging??e.tagging);void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);e.schema&&t.schema?n.schema=D(e.schema,t.schema):(e.schema||t.schema)&&(n.schema={...e.schema||t.schema});if(e.events||t.events){const r={},o=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of o){const o=e.events?.[n]||{},a=t.events?.[n]||{},i=new Set([...Object.keys(o),...Object.keys(a)]);r[n]={};for(const e of i){const t=o[e],i=a[e];r[n][e]=t&&i?D(t,i):{...t||i}}}n.events=r}return n}(r(a.extend),a)}else i={...a};if(delete i.extend,i.events&&(i.events=function(e){const t={};for(const n of Object.keys(e))if("*"!==n){t[n]={};for(const r of Object.keys(e[n]||{})){let o={};const a=e["*"]?.["*"];a&&(o=D(o,a));const i=e["*"]?.[r];i&&"*"!==r&&(o=D(o,i));const s=e[n]?.["*"];s&&"*"!==r&&(o=D(o,s));const c=e[n]?.[r];c&&(o=D(o,c)),t[n][r]=o}}e["*"]&&(t["*"]={...e["*"]});return t}(i.events)),i.events){const e={};for(const[t,n]of Object.entries(i.events)){e[t]={};for(const[r,o]of Object.entries(n))e[t][r]=V(o)}i.events=e}return n.delete(o),t[o]=i,i}for(const t of Object.keys(e))r(t);return t}function D(e,t){const n={...e};for(const r of Object.keys(t)){const o=e[r],a=t[r];"required"===r&&Array.isArray(o)&&Array.isArray(a)?n[r]=[...new Set([...o,...a])]:L(o)&&L(a)?n[r]=D(o,a):n[r]=a}return n}function V(e){const t={};for(const[n,r]of Object.entries(e))F.has(n)||(null===r||"object"!=typeof r||Array.isArray(r)?t[n]=r:t[n]=V(r));return t}function L(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var U=/^\$var\.([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)$/,Z=/\$var\.([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)/g,H=/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,W=/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,B=/^\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?$/,q=/^\$store\.([a-zA-Z_][a-zA-Z0-9_]*)$/,K=/^\$secret\.([A-Z0-9_]+)$/,J="$code:";function G(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var X="__WALKEROS_ENV:";function Y(e,t,n){const r=`$flow.${e}${t?`.${t}`:""}`;if("unknown-flow"===n)return`${r} cannot resolve: flow "${e}" does not exist in this config.`;return`${r} is empty. Set ${t?`flows.${e}.config.${t}`:`flows.${e}.config`}, or run \`walkeros deploy ${e}\` first.`}function Q(e,t,n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const a=r[e];if(null==o||"object"!=typeof o){const o=r.slice(0,e).join(".");M(`Path "${t}" not found in "${n}": "${a}" does not exist${o?` in "${o}"`:""}`)}const i=o;if(!(a in i)){const o=r.slice(0,e).join(".");M(`Path "${t}" not found in "${n}": "${a}" does not exist${o?` in "${o}"`:""}`)}o=i[a]}return o}function ee(e,t,n,r,o,a){if("string"==typeof e){const i=e.match(U);if(i){const e=i[1].split("."),s=e[0],c=e.slice(1).join(".");void 0===t[s]&&M(`Variable "${s}" not found`);const l=a??new Set;if(l.has(s)){M(`Cyclic $var reference: ${[...l,s].join(" -> ")}`)}let u;l.add(s);try{u=ee(t[s],t,n,r,o,l)}finally{l.delete(s)}return c&&(u=Q(u,c,`$var.${s}`)),u}const s=e.match(W);if(s&&r){const e=s[1],t=s[2];e in r||M(`Contract "${e}" not found`);let n=r[e];return t&&(n=Q(n,t,`$contract.${e}`)),n}const c=e.match(B);if(c){const t=c[1],r=c[2],a=!1===n?.strictFlowRefs;o||M(`$flow.${t}${r?`.${r}`:""} cannot be resolved without a flow resolver`);const i=o(t);if(!i){if(a)return n?.onWarning?.(Y(t,r,"unknown-flow")),e;M(`Flow "${t}" not found in $flow.${t}`)}let s=i;if(r)if(a){try{s=Q(s,r,`$flow.${t}`)}catch{return n?.onWarning?.(Y(t,r,"missing-key")),e}if(null==s||""===s)return n?.onWarning?.(Y(t,r,"missing-key")),e}else s=Q(s,r,`$flow.${t}`);return s}let l=e.replace(Z,(e,i)=>{const s=i.split("."),c=s[0],l=s.slice(1).join(".");void 0===t[c]&&M(`Variable "${c}" not found`);const u=a??new Set;if(u.has(c)){M(`Cyclic $var reference: ${[...u,c].join(" -> ")}`)}let f;u.add(c);try{f=ee(t[c],t,n,r,o,u)}finally{u.delete(c)}if(l&&(f=Q(f,l,`$var.${c}`)),null===f||"string"!=typeof f&&"number"!=typeof f&&"boolean"!=typeof f){M(`Variable "${i}" resolves to non-scalar (${Array.isArray(f)?"array":typeof f}) and cannot be inlined into a string. Use it as a whole-string reference: "$var.${i}"`)}return String(f)});return l=l.replace(H,(e,t,r)=>n?.deferred?void 0!==r?`${X}${t}:${r}`:`${X}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==r?r:void M(`Environment variable "${t}" not found and no default provided`)),l}if(Array.isArray(e))return e.map(e=>ee(e,t,n,r,o,a));if(null!==e&&"object"==typeof e){const i={};for(const[s,c]of Object.entries(e))i[s]=ee(c,t,n,r,o,a);return i}return e}function te(e){const t=e.startsWith("@"),n=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return t?"_"+n:n}function ne(e,t,n){const r=new Map,o=new Set,a=[],i=t=>{if(r.has(t))return r.get(t);const s=e.flows[t];if(s){if(o.has(t)){M(`Cyclic $flow reference: ${[...a,t].join(" -> ")}`)}o.add(t),a.push(t);try{const o=G(e.variables,s.variables),a=ee(s.config??{},o,n,void 0,i);return r.set(t,a),a}finally{o.delete(t),a.pop()}}},s=Object.keys(e.flows);t||(1===s.length?t=s[0]:M(`Multiple flows found (${s.join(", ")}). Please specify a flow.`));const c=e.flows[t];c||M(`Flow "${t}" not found. Available: ${s.join(", ")}`),o.add(t),a.push(t);try{return function(e,t,n,r){const o=JSON.parse(JSON.stringify(t));let a;if(e.contract){const o=G(e.variables,t.variables);a=z(ee(e.contract,o,n,void 0,r))}if(o.config){const i=G(e.variables,t.variables);o.config=ee(o.config,i,n,a,r)}if(o.sources)for(const[i,s]of Object.entries(o.sources)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.sources[i]={package:s.package,import:s.import,config:l,env:u,primary:s.primary,variables:s.variables,before:s.before,next:s.next,cache:s.cache,validate:s.validate,code:s.code}}if(o.destinations)for(const[i,s]of Object.entries(o.destinations)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.destinations[i]={package:s.package,import:s.import,config:l,env:u,variables:s.variables,before:s.before,next:s.next,cache:s.cache,validate:s.validate,code:s.code}}if(o.stores)for(const[i,s]of Object.entries(o.stores)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.stores[i]={package:s.package,import:s.import,config:l,env:u,cache:s.cache,variables:s.variables,code:s.code}}if(o.transformers)for(const[i,s]of Object.entries(o.transformers)){const c=G(e.variables,t.variables,s.variables),l=ee(s.config,c,n,a,r),u=ee(s.env,c,n,a,r);o.transformers[i]={package:s.package,import:s.import,config:l,env:u,variables:s.variables,before:s.before,next:s.next,cache:s.cache,validate:s.validate,code:s.code}}if(o.collector){const i=G(e.variables,t.variables),s=ee(o.collector,i,n,a,r);o.collector=s}return o}(e,c,n,i)}finally{o.delete(t),a.pop()}}function re(e){const t=e.config?.platform;if("web"===t||"server"===t)return t;M('Flow must have config.platform set to "web" or "server"')}var oe={merge:!0,shallow:!0,extend:!0};function ae(e,t={},n={}){n={...oe,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const a=e[r];return n.merge&&Array.isArray(a)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...a]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function ie(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function se(e){return Array.isArray(e)}function ce(e){return"boolean"==typeof e}function le(e){return"walker"===e}function ue(e){return void 0!==e}function fe(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function pe(e){return"function"==typeof e}function de(e){return"number"==typeof e&&!Number.isNaN(e)}function me(e){return"object"==typeof e&&null!==e&&!se(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ge(e,t){return typeof e==typeof t}function ye(e){return"string"==typeof e}function he(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=he(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(he(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function ve(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&se(o)){const t=r.slice(e+1).join("."),a=[];for(const e of o){const r=ve(e,t,n);a.push(r)}return a}if(o=me(o)||se(o)?o[t]:void 0,void 0===o)break}return ue(o)?o:n}function be(e,t,n){if(!me(e))return e;const r=he(e),o=t.split(".");let a=r;for(let e=0;e<o.length;e++){const t=o[e];e===o.length-1?a[t]=n:(t in a&&"object"==typeof a[t]&&null!==a[t]||(a[t]={}),a=a[t])}return r}function we(e,t){if(!me(e)&&!se(e))return e;const n=he(e),r=t.split(".");let o=n;for(let e=0;e<r.length;e++){const t=r[e],a=e===r.length-1;if(se(o)){const e=Number(t);if(!Number.isInteger(e)||e<0||e>=o.length)return n;if(a)o.splice(e,1);else{const t=o[e];if(!me(t)&&!se(t))return n;o=t}}else if(a)delete o[t];else{const e=o[t];if(!me(e)&&!se(e))return n;o=e}}return n}var ke={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,timing:e.timing})};function $e(e,t){const n={},r=t.includes("all")?Object.keys(ke):t;for(const t of r){const r=ke[t];if(!r)continue;const o=r(e);if(me(o))for(const[e,r]of Object.entries(o)){if(void 0===r)continue;const o="context"===t&&Array.isArray(r)?r[0]:r;n[`${t}_${e}`]=o}}return n}function je(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function xe(e,t={},n={}){const r={...t,...n},o={};let a=!e||0===Object.keys(e).length;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(a=!0))}),!!a&&o}function Oe(e,t){const n={...e};return n.config=ae(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=ae(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=ae(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function Se(e,t){if(!me(t))return e;for(const n of Object.keys(t)){const r=t[n];void 0!==r&&(me(r)&&me(e[n])?Se(e[n],r):e[n]=r)}return e}function Ae(){let e="";for(let t=0;t<16;t++)e+=(16*Math.random()|0).toString(16);return e}function Ee(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=ae({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"}}],consent:{functional:!0},id:e.id||Ae(),trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,source:{type:"collector",schema:"4"}},e,{merge:!1});if(e.name){const[t,r]=e.name.split(" ")??[];t&&r&&(n.entity=t,n.action=r)}return n}function _e(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),r={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return Ee({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...r.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:r.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.walkeros.io/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...r,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...r,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...r.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function Ce(e=6,t){if(t){const n=t.length;let r="";for(let o=0;o<e;o++)r+=t[Math.random()*n|0];return r}let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}var Ne=[{param:"gclid",platform:"google"},{param:"wbraid",platform:"google"},{param:"gbraid",platform:"google"},{param:"dclid",platform:"google"},{param:"gclsrc",platform:"google"},{param:"fbclid",platform:"meta"},{param:"igshid",platform:"meta"},{param:"msclkid",platform:"microsoft"},{param:"ttclid",platform:"tiktok"},{param:"twclid",platform:"twitter"},{param:"li_fat_id",platform:"linkedin"},{param:"epik",platform:"pinterest"},{param:"sclid",platform:"snapchat"},{param:"sccid",platform:"snapchat"},{param:"rdt_cid",platform:"reddit"},{param:"qclid",platform:"quora"},{param:"yclid",platform:"yandex"},{param:"ymclid",platform:"yandex"},{param:"ysclid",platform:"yandex"},{param:"dicbo",platform:"outbrain"},{param:"obclid",platform:"outbrain"},{param:"tblci",platform:"taboola"},{param:"mc_cid",platform:"mailchimp"},{param:"mc_eid",platform:"mailchimp"},{param:"_kx",platform:"klaviyo"},{param:"_hsenc",platform:"hubspot"},{param:"_hsmi",platform:"hubspot"},{param:"s_kwcid",platform:"adobe"},{param:"ef_id",platform:"adobe"},{param:"mkt_tok",platform:"adobe"},{param:"irclickid",platform:"impact"},{param:"cjevent",platform:"cj"},{param:"_branch_match_id",platform:"branch"}];function Pe(e,t={},n=[]){const r={};Object.entries(ae({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const o=e.searchParams.get(t);o&&(r[n]=o)});const o=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(Ne.map(e=>e.param));return[...Ne.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):Ne,a=new Map;e.searchParams.forEach((e,t)=>{e&&a.set(t.toLowerCase(),e)});for(const e of o){const t=a.get(e.param);t&&(r[e.param]=t,r.clickId||(r.clickId=e.param,r.platform=e.platform))}return r}function Te(e,t){return"number"==typeof e?{wait:e}:e?{wait:e.wait??t,size:e.size,age:e.age}:{wait:t}}function Re(e,t=1e3,n=!1){const{wait:r,size:o,age:a}=Te(t,1e3);let i,s,c=null,l=null,u=!1,f=[],p=0;const d=()=>{c&&(clearTimeout(c),c=null),l&&(clearTimeout(l),l=null),p=0,s=void 0},m=()=>{const t=s,n=f;if(d(),f=[],t)return i=e(...t),n.forEach(e=>e(i)),i;n.forEach(e=>e(void 0))},g=(...t)=>new Promise(d=>{const g=n&&!u;if(s=t,p+=1,f.push(d),c&&clearTimeout(c),c=setTimeout(()=>{c=null,n&&!u||m()},r),void 0===a||l||(l=setTimeout(()=>{l=null,m()},a)),void 0!==o&&p>=o)m();else if(g){u=!0,i=e(...t);const n=f;f=[],n.forEach(e=>e(i))}});return g.flush=()=>s||0!==f.length?new Promise(e=>{f.push(e),m()}):Promise.resolve(void 0),g.cancel=()=>{const e=f;f=[],d(),e.forEach(e=>e(void 0))},g.size=()=>p,g}function Ie(e,t=1e3){const{wait:n}=Te(t,1e3);let r=null;return function(...t){if(null===r)return r=setTimeout(()=>{r=null},n),e(...t)}}function Me(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Fe(e,t){let n,r={};return e instanceof Error?(n=e.message,r.error=Me(e)):n=e,void 0!==t&&(t instanceof Error?r.error=Me(t):"object"==typeof t&&null!==t?(r={...r,...t},"error"in r&&r.error instanceof Error&&(r.error=Me(r.error))):r.value=t),{message:n,context:r}}var ze=(e,t,n,r)=>{const o=`${y[e]}${r.length>0?` [${r.join(":")}]`:""}`,a=Object.keys(n).length>0,i=0===e?console.error:1===e?console.warn:console.log;a?i(o,t,n):i(o,t)};function De(e={}){return Ve({level:void 0!==e.level?function(e){return"string"==typeof e?y[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function Ve(e){const{level:t,handler:n,jsonHandler:r,scope:o}=e,a=(e,r,a)=>{if(e<=t){const t=Fe(r,a);n?n(e,t.message,t.context,o,ze):ze(e,t.message,t.context,o)}};return{error:(e,t)=>a(0,e,t),warn:(e,t)=>a(1,e,t),info:(e,t)=>a(2,e,t),debug:(e,t)=>a(3,e,t),throw:(e,t)=>{const r=Fe(e,t);throw n?n(0,r.message,r.context,o,ze):ze(0,r.message,r.context,o),new Error(r.message)},json:e=>{r?r(e):console.log(JSON.stringify(e,null,2))},scope:e=>Ve({level:t,handler:n,jsonHandler:r,scope:[...o,e]})}}function Le(e){return ce(e)||ye(e)||de(e)||!ue(e)||se(e)&&e.every(Le)||me(e)&&Object.values(e).every(Le)}function Ue(e){return ce(e)||ye(e)||de(e)?e:ie(e)?Ue(Array.from(e)):se(e)?e.map(e=>Ue(e)).filter(e=>void 0!==e):me(e)?Object.entries(e).reduce((e,[t,n])=>{const r=Ue(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function Ze(e){return Le(e)?e:void 0}function He(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function We(e,t,n){return async function(...r){try{return await e(...r)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}var Be=class e extends Error{constructor(t,n){super(t,n),this.name="FatalError",Object.setPrototypeOf(this,e.prototype)}};async function qe(e,t,n){const[r,o]=(e.name||"").split(" ");if(!t||!r||!o)return{};let a,i="",s=r,c=o;const l=t=>{if(!t)return;return(se(t)?t:[t]).find(t=>{if(!t.condition)return!0;if(!n)return Boolean(t.condition(e,void 0));const r={event:e,mapping:t,collector:n,logger:n.logger,consent:me(e)&&e.consent||n.consent};return Boolean(t.condition(e,r))})};t[s]||(s="*");const u=t[s];return u&&(u[c]||(c="*"),a=l(u[c])),a||(s="*",c="*",a=l(t[s]?.[c])),a&&(i=`${s} ${c}`),{eventMapping:a,mappingKey:i}}async function Ke(e,t={},n={}){if(!ue(e))return;const r=me(e)&&e.consent||n.consent||n.collector?.consent,o=n.event??(me(e)?e:{});if(!n.collector)throw new Error("getMappingValue: context.collector is required");const a={event:o,mapping:t,collector:n.collector,logger:n.collector.logger,consent:r},i=se(t)?t:[t];for(const t of i){const r=await We(Je,e=>{if(e instanceof Be)throw e;n.collector&&n.collector.status.failed++,a.logger.error("mapping processing failed",{event:o,error:e})})(e,t,{...a,mapping:t});if(ue(r))return r}}async function Je(e,t,n){return(se(t)?t:[t]).reduce(async(t,r)=>{const o=await t;if(o)return o;const a=ye(r)?{key:r}:r;if(!Object.keys(a).length)return;const{condition:i,consent:s,fn:c,key:l,loop:u,map:f,set:p,validate:d,value:m}=a,g={...n,mapping:r};if(i&&!await We(i,e=>{if(e instanceof Be)throw e;return g.logger.error("mapping condition failed",{event:g.event,error:e}),!1})(e,g))return;if(s&&!xe(s,g.consent))return m;let y=ue(m)?m:e;if(c&&(y=await We(c,e=>{if(e instanceof Be)throw e;g.logger.error("mapping fn failed",{event:g.event,error:e})})(e,g)),l&&(y=ve(e,l,m)),u){const[t,n]=u,r="this"===t?[e]:await Ke(e,t,g);se(r)&&(y=(await Promise.all(r.map(e=>Ke(e,n,g)))).filter(ue))}else f?y=await Object.entries(f).reduce(async(t,[n,r])=>{const o=await t,a=await Ke(e,r,g);return ue(a)&&(o[n]=a),o},Promise.resolve({})):p&&(y=await Promise.all(p.map(t=>Je(e,t,g))));d&&!await We(d,e=>{if(e instanceof Be)throw e;return g.logger.error("mapping validate failed",{event:g.event,error:e}),!1})(y,g)&&(y=void 0);const h=Ze(y);return ue(h)?h:Ze(m)},Promise.resolve(void 0))}async function Ge(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await Ke(e,r,{collector:n,event:e});e=be(e,t,o)}));const{eventMapping:r,mappingKey:o}=await qe(e,t.mapping,n);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await Ke(e,r,{collector:n,event:e});e=be(e,t,o)}));let a=t.data&&await Ke(e,t.data,{collector:n,event:e});const i=Boolean(r?.silent);if(r){if(r.ignore)return{event:e,data:a,mapping:r,mappingKey:o,ignore:!0,silent:i};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await Ke(e,r.data,{collector:n,event:e});a=me(a)&&me(t)?ae(a,t):t}}const s=r?.include??t.include;if(s&&s.length>0){const t=$e(e,s);Object.keys(t).length>0&&(a=me(a)?ae(t,a):a??t)}if(r?.remove&&me(a))for(const e of r.remove)a=we(a,e);return{event:e,data:a,mapping:r,mappingKey:o,ignore:!1,silent:i}}function Xe(e,t){for(const n of Object.keys(t)){const r=t[n];if(void 0===r)continue;if(null===r){delete e[n];continue}const o=e[n];me(r)&&me(o)?Xe(o,r):e[n]=r}return e}function Ye(e,t){if(void 0===t.extend&&void 0===t.remove)return he(t);const n={...he(e)};if(t.extend){Xe(n,{...t.extend})}return delete n.extend,t.remove?n.remove=[...t.remove]:delete n.remove,n}function Qe(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const a=e[o],i=[...r,o];return"function"==typeof a?a.prototype&&a.prototype.constructor===a?a:(...e)=>{const r=t(i,e,a);if(r&&"object"==typeof r)return n(r,i);const o=a(...e);return o&&"object"==typeof o?n(o,i):r}:a&&"object"==typeof a?n(a,i):a}});return n(e)}function et(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[a,i]of Object.entries(e)){const e=[...r,a];Array.isArray(o)?o[Number(a)]=t(i,e):o[a]=t(i,e),i&&"object"==typeof i&&"function"!=typeof i&&(Array.isArray(o)?o[Number(a)]=n(i,e):o[a]=n(i,e))}return o};return n(e)}function tt(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=tt();return e.push(n),n});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,json:jest.fn(),scope:n,scopedLoggers:e}}function nt(e={}){return{collector:{},config:{},env:{},logger:tt(),id:"test",ingest:T("test"),...e}}function rt(e){const t=String(e),n=t.split("?")[1]||t;return He(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const r=n.split(/[[\]]+/).filter(Boolean);let o=t;r.forEach((t,n)=>{const a=n===r.length-1;if(se(o)){const i=parseInt(t,10);a?o[i]=je(e):(o[i]=o[i]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[i])}else me(o)&&(a?o[t]=je(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function ot(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(se(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):me(o)?Object.entries(o).forEach(([t,n])=>r(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(o))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>r(e,t)),t.join("&"))}function at(e){return void 0===e||ge(e,"")?e:JSON.stringify(e)}function it(e={}){return ae({"Content-Type":"application/json; charset=utf-8"},e)}function st(e,t){return!1===e||void 0===e?null:!0===e?t:{...t,...e}}function ct(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function lt(e,t,n,r){return function(...o){let a;const i="pre"+t,s="post"+t,c=n[i],l=n[s],u=(e,t)=>{r?r.warn(e,{error:t}):console.warn(e,t)};if(c)try{a=c({fn:e},...o)}catch(t){u(`Hook ${String(i)} failed, falling back to original function`,t),a=e(...o)}else a=e(...o);if(l)try{a=l({fn:e,result:a},...o)}catch(e){u(`Hook ${String(s)} failed, keeping original result`,e)}return a}}function ut(e){return e?{userAgent:e,browser:ft(e),browserVersion:pt(e),os:dt(e),osVersion:mt(e),deviceType:gt(e)}:{}}function ft(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function pt(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function dt(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function mt(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function gt(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function yt(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function ht(e){const t=yt(e);return new Function("value","context",t)}function vt(e){const t=yt(e);return new Function("value","context",t)}function bt(e){const t=yt(e);return new Function("value","context",t)}var wt="https://cdn.jsdelivr.net/npm",kt="dist/walkerOS.json";function $t(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function jt(e,t){const n=t?.version||"latest",r=t?.timeout||1e4,o=new AbortController,a=setTimeout(()=>o.abort(),r),i=o.signal,s=t?.client?{"X-Walkeros-Client":t.client}:void 0;try{if(t?.baseUrl){const r=`${t.baseUrl}/api/packages/${encodeURIComponent(e)}?version=${encodeURIComponent(n)}&expand=all`,o=await fetch(r,{signal:i,...s&&{headers:s}});if(!o.ok)throw new Error(`Failed to fetch ${r} (HTTP ${o.status})`);return function(e,t,n){const r=n.schemas||{},o=n.examples||{},a=n.hints,i=n.hintKeys??(a?Object.keys(a):[]),s=n.exampleSummaries??[],c=n.platform;return{packageName:n.package||e,version:"string"==typeof n.version?n.version:t,...void 0!==n.description&&{description:n.description},...void 0!==n.type&&{type:n.type},...void 0!==c&&{platform:c},schemas:r,examples:o,...void 0!==n.docs&&{docs:n.docs},...void 0!==n.source&&{source:n.source},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:i,exampleSummaries:s}}(e,n,await o.json())}const r=`${wt}/${e}@${n}`,o=await xt(`${r}/package.json`,i,s);return function(e,t,n,r){const o=r.$meta||{},a=r.schemas||{},i=r.examples||{},s=r.hints,c=s?Object.keys(s):[],l=[],u=i.step||{};for(const[e,t]of Object.entries(u)){const n=t,r={name:e};"string"==typeof n?.description&&(r.description=n.description),l.push(r)}const f="string"==typeof o.docs?o.docs:void 0,p="string"==typeof o.source?o.source:void 0;return{packageName:e,version:"string"==typeof n.version?n.version:t,description:"string"==typeof n.description?n.description:void 0,type:"string"==typeof o.type?o.type:void 0,platform:$t(o.platform),schemas:a,examples:i,...f?{docs:f}:{},...p?{source:p}:{},...s&&Object.keys(s).length>0?{hints:s}:{},hintKeys:c,exampleSummaries:l}}(e,n,o,await xt(`${r}/${kt}`,i,s))}finally{clearTimeout(a)}}async function xt(e,t,n){const r=await fetch(e,{signal:t,...n&&{headers:n}});if(!r.ok)throw new Error(`Failed to fetch ${e} (HTTP ${r.status})`);return await r.json()}async function Ot(e,t){const n=await jt(e,t);return{packageName:n.packageName,version:n.version,type:n.type,platform:n.platform,schemas:n.schemas,examples:n.examples,...n.hints?{hints:n.hints}:{}}}function St(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function At(e,t){let n,r,o,a;if(e instanceof Error){n=e.message;const t=e;t.code&&(o=t.code),Array.isArray(t.details)&&(a=t.details)}else if("string"==typeof e)n=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const t=e.issues;n=t.map(e=>e.message).join("; "),r=t[0]?.path?.join(".")||void 0}else n=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const i={error:n};return t&&(i.hint=t),r&&(i.path=r),o&&(i.code=o),a&&(i.details=a),{content:[{type:"text",text:JSON.stringify(i)}],structuredContent:i,isError:!0}}function Et(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function _t(e){if(void 0===e||"*"===e)return()=>!0;if("and"in e){const t=e.and.map(_t);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(_t);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:r,not:o}=e,a=function(e,t){switch(e){case"eq":return e=>String(e??"")===t;case"contains":return e=>String(e??"").includes(t);case"prefix":return e=>String(e??"").startsWith(t);case"suffix":return e=>String(e??"").endsWith(t);case"regex":{const e=new RegExp(t);return t=>e.test(String(t??""))}case"gt":{const e=Number(t);return t=>Number(t)>e}case"lt":{const e=Number(t);return t=>Number(t)<e}case"exists":return e=>null!=e}}(n,r);return e=>{const n=ve(e,t),r=a(n);return o?!r:r}}(e)}function Ct(e){return Array.isArray(e)&&e.length>0&&e.every(e=>function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&("match"in e||"next"in e||"one"in e||"many"in e)}(e))}function Nt(e){return e.map(e=>{if("string"==typeof e)return{match:()=>!0,next:{type:"static",value:e}};if(Array.isArray(e))return{match:()=>!0,next:Pt(e)??{type:"chain",value:[]}};const t=e;return{match:t.match?_t(t.match):()=>!0,next:Pt(t)??{type:"chain",value:[]}}})}function Pt(e){if(null==e)return;if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(Ct(e))return Pt({one:e});if(e.every(e=>"string"==typeof e))return{type:"chain",value:e};const t=[];for(const n of e){const e=Pt(n);void 0!==e&&t.push(e)}if(0===t.length)return;return{type:"sequence",value:t}}const t=e;if("next"in t&&void 0!==t.next)return t.match?{type:"gate",match:_t(t.match),next:Pt(t.next)}:Pt(t.next);if("one"in t&&t.one){const e=Nt(t.one);return t.match?{type:"gate",match:_t(t.match),next:{type:"one",routes:e}}:{type:"one",routes:e}}if("many"in t&&t.many){const e=Nt(t.many);return t.match?{type:"gate",match:_t(t.match),next:{type:"many",routes:e}}:{type:"many",routes:e}}return t.match?{type:"gate",match:_t(t.match)}:void 0}var Tt=new WeakMap;function Rt(e,t={}){if(null==e)return[];let n;if("object"==typeof e){const t=Tt.get(e);t?n=t:(n=Pt(e),n&&Tt.set(e,n))}else n=Pt(e);if(!n)return[];const r=It(n,t);return void 0===r?[]:Array.isArray(r)?r:[r]}function It(e,t={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;if("gate"===e.type){if(!e.match(t))return;return It(e.next,t)}if("sequence"===e.type){const n=[];for(const r of e.value){const e=It(r,t);void 0!==e&&(Array.isArray(e)?n.push(...e):n.push(e))}return n.length>0?n:void 0}if("many"===e.type){const n=[];for(const r of e.routes){if(!r.match(t))continue;const e=It(r.next,t);void 0!==e&&(Array.isArray(e)?n.push(...e):n.push(e))}return n.length>0?n:void 0}for(const n of e.routes)if(n.match(t))return It(n.next,t)}}function Mt(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function Ft(e){return{stop:e.stop??!1,storeId:e.store,namespace:e.namespace,rules:e.rules.map(e=>({match:e.match?_t(e.match):()=>!0,key:e.key,ttl:e.ttl,update:e.update}))}}async function zt(e,t,n,r){const o=e.rules.find(e=>e.match(n));if(!o)return null;const a=o.key.map(e=>String(ve(n,e)??""));if(a.every(e=>""===e))return null;const i=a.join(":"),s=r??e.namespace,c=s?`${s}:${i}`:i,l=await t.get(c);return void 0!==l?{status:"HIT",key:c,value:l,rule:o}:{status:"MISS",key:c,rule:o}}function Dt(e,t,n,r){e.set(t,n,1e3*r)}async function Vt(e,t,n,r){if(!t)return e;let o=e;for(const[e,a]of Object.entries(t)){o=be(o,e,await Ke(n,a,{collector:r}))}return o}var Lt={Source:["code","package","import","before","next","cache"],Transformer:["code","package","import","before","next","cache","mapping"],Destination:["code","package","import","before","next","cache"],Store:["code","package","import","cache"]},Ut=["config","env","validate","variables","examples","disabled","id","logger","mock","chainMocks"],Zt={Source:["primary"],Transformer:[],Destination:[],Store:[]},Ht=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Wt(e,t){const n=function(e){return new Set([...Lt[e],...Ut,...Zt[e]])}(t);for(const r of Object.keys(e))if(!n.has(r))return{ok:!1,code:"UNKNOWN_KEY",key:r,reason:`Unknown key "${r}" on ${t}. Allowed: ${[...n].sort().join(", ")}.`};const r=void 0!==e.package,o=void 0!==e.import,a=void 0!==e.code;return a&&"string"==typeof e.code?{ok:!1,code:"OBSOLETE_CODE_STRING",key:"code",reason:`code: "<name>" is no longer supported. Use import: "${e.code}" with the package field instead.`}:a&&("object"!=typeof e.code&&"function"!=typeof e.code||null===e.code||Array.isArray(e.code))?{ok:!1,code:"INVALID_CODE_SHAPE",key:"code",reason:"code must be an object ({ push, type?, init? }) or a resolved function value."}:a&&r?{ok:!1,code:"CONFLICT",key:"package",reason:"Cannot specify both `code` and `package`. Use one or the other."}:a&&o?{ok:!1,code:"CONFLICT",key:"import",reason:"Cannot specify both `code` and `import`."}:o&&!r?{ok:!1,code:"MISSING_PACKAGE",key:"import",reason:"`import` requires `package` to be set."}:!o||"string"==typeof e.import&&Ht.test(e.import)?{ok:!0}:{ok:!1,code:"INVALID_IMPORT",key:"import",reason:`import must match ${Ht.source}. Got: ${JSON.stringify(e.import)}.`}}function Bt(e,t){return"Transformer"===t&&(void 0===e.code&&void 0===e.package&&void 0===e.import&&(void 0!==e.before||void 0!==e.next||void 0!==e.cache||void 0!==e.mapping))}function qt(e){return 0===e.length?"// no output":e.map(Kt).join(";\n\n")}function Kt(e){const[t,...n]=e,r=n.map(Jt).join(", ");return"return"===t?r?`return ${r}`:"return":`${t}(${r})`}function Jt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}//# sourceMappingURL=index.js.map
|