@walkeros/core 4.7.2 → 4.8.0-next-1791496487198

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -105,15 +105,24 @@ interface Rule<Settings = unknown> {
105
105
  */
106
106
  remove?: string[];
107
107
  }
108
+ /**
109
+ * A deep partial of T as `mergeMappingRule` applies it: every object key is
110
+ * optional and a `null` clears the inherited key (JSON merge-patch delete);
111
+ * arrays and functions replace as a whole.
112
+ */
113
+ type Patch<T> = T extends readonly unknown[] ? T : T extends (...args: never[]) => unknown ? T : T extends object ? {
114
+ [K in keyof T]?: Patch<T[K]> | null;
115
+ } : T;
108
116
  /**
109
117
  * A partial Rule used by `Rule.extend`. Every field is optional, and a
110
- * `null` value clears the inherited field (JSON merge-patch delete). The
111
- * control fields `extend` and `remove` are excluded: a patch models only
112
- * direct rule fields, matching what the runtime patch schema accepts.
118
+ * `null` at any object key clears the inherited key, for example
119
+ * `{ data: { map: { tax: null } } }`. The control fields `extend` and
120
+ * `remove` are excluded: a patch models only direct rule fields, matching
121
+ * what the runtime patch schema accepts.
113
122
  */
114
123
  type RulePatchFields<Settings = unknown> = Omit<Rule<Settings>, 'extend' | 'remove'>;
115
124
  type RulePatch<Settings = unknown> = {
116
- [K in keyof RulePatchFields<Settings>]?: RulePatchFields<Settings>[K] | null;
125
+ [K in keyof RulePatchFields<Settings>]?: Patch<RulePatchFields<Settings>[K]> | null;
117
126
  };
118
127
  interface Result$2 {
119
128
  eventMapping?: Rule;
@@ -154,6 +163,13 @@ interface Context$6 {
154
163
  logger: Instance$3;
155
164
  consent?: Consent;
156
165
  }
166
+ /**
167
+ * Context for `getMappingValue`. The collector is required; the other
168
+ * Context fields are optional. `event` and `consent` override what is
169
+ * inferred from the value and the collector; the logger always comes from
170
+ * the collector.
171
+ */
172
+ type ValueContext = Pick<Context$6, 'collector'> & Partial<Omit<Context$6, 'collector'>>;
157
173
  type Fn$4 = (value: unknown, context: Context$6) => PromiseOrValue<Property | unknown>;
158
174
  type Condition = (value: unknown, context: Context$6) => PromiseOrValue<boolean>;
159
175
  type Validate = (value: unknown, context: Context$6) => PromiseOrValue<boolean>;
@@ -172,10 +188,11 @@ type mapping_Rules<T = Rule> = Rules<T>;
172
188
  type mapping_Validate = Validate;
173
189
  type mapping_Value = Value;
174
190
  type mapping_ValueConfig = ValueConfig;
191
+ type mapping_ValueContext = ValueContext;
175
192
  type mapping_ValueType = ValueType;
176
193
  type mapping_Values = Values;
177
194
  declare namespace mapping {
178
- 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_Root as Root, mapping_Rule as Rule, mapping_RulePatch as RulePatch, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
195
+ 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_Root as Root, mapping_Rule as Rule, mapping_RulePatch as RulePatch, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueContext as ValueContext, mapping_ValueType as ValueType, mapping_Values as Values };
179
196
  }
180
197
 
181
198
  interface BaseCacheRule {
@@ -3440,7 +3457,12 @@ interface Event {
3440
3457
  interface Consent {
3441
3458
  [name: string]: boolean;
3442
3459
  }
3443
- interface User extends Properties {
3460
+ /**
3461
+ * Declared (named) fields of an event User. Index-free like `SourceFields`, so
3462
+ * the drift guard can compare `keyof UserFields` against
3463
+ * `keyof z.infer<typeof UserFieldsSchema>`.
3464
+ */
3465
+ interface UserFields {
3444
3466
  id?: string;
3445
3467
  device?: string;
3446
3468
  session?: string;
@@ -3463,6 +3485,9 @@ interface User extends Properties {
3463
3485
  screenSize?: string;
3464
3486
  ip?: string;
3465
3487
  internal?: boolean;
3488
+ optout?: boolean;
3489
+ }
3490
+ interface User extends Properties, UserFields {
3466
3491
  }
3467
3492
  type SourcePlatform = 'web' | 'server' | 'app' | 'ios' | 'android' | 'terminal' | string;
3468
3493
  /**
@@ -3554,8 +3579,9 @@ type walkeros_SourceFields = SourceFields;
3554
3579
  type walkeros_SourceMap = SourceMap;
3555
3580
  type walkeros_SourcePlatform = SourcePlatform;
3556
3581
  type walkeros_User = User;
3582
+ type walkeros_UserFields = UserFields;
3557
3583
  declare namespace walkeros {
3558
- export type { walkeros_ActionHandler as ActionHandler, walkeros_AnyFunction as AnyFunction, walkeros_AnyObject as AnyObject, walkeros_Consent as Consent, walkeros_ConsentHandler as ConsentHandler, walkeros_DeepPartial as DeepPartial, walkeros_DeepPartialEvent as DeepPartialEvent, walkeros_Elb as Elb, walkeros_Entities as Entities, walkeros_Entity as Entity, walkeros_Event as Event, walkeros_Events as Events, walkeros_OrderedProperties as OrderedProperties, walkeros_PartialEvent as PartialEvent, walkeros_PromiseOrValue as PromiseOrValue, walkeros_Properties as Properties, walkeros_Property as Property, walkeros_PropertyType as PropertyType, walkeros_SingleOrArray as SingleOrArray, walkeros_Source as Source, walkeros_SourceFields as SourceFields, walkeros_SourceMap as SourceMap, walkeros_SourcePlatform as SourcePlatform, walkeros_User as User };
3584
+ export type { walkeros_ActionHandler as ActionHandler, walkeros_AnyFunction as AnyFunction, walkeros_AnyObject as AnyObject, walkeros_Consent as Consent, walkeros_ConsentHandler as ConsentHandler, walkeros_DeepPartial as DeepPartial, walkeros_DeepPartialEvent as DeepPartialEvent, walkeros_Elb as Elb, walkeros_Entities as Entities, walkeros_Entity as Entity, walkeros_Event as Event, walkeros_Events as Events, walkeros_OrderedProperties as OrderedProperties, walkeros_PartialEvent as PartialEvent, walkeros_PromiseOrValue as PromiseOrValue, walkeros_Properties as Properties, walkeros_Property as Property, walkeros_PropertyType as PropertyType, walkeros_SingleOrArray as SingleOrArray, walkeros_Source as Source, walkeros_SourceFields as SourceFields, walkeros_SourceMap as SourceMap, walkeros_SourcePlatform as SourcePlatform, walkeros_User as User, walkeros_UserFields as UserFields };
3559
3585
  }
3560
3586
 
3561
3587
  /**
@@ -4513,12 +4539,12 @@ declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event,
4513
4539
  /**
4514
4540
  * Gets a value from a mapping.
4515
4541
  *
4516
- * @param value The value to get the mapping from.
4517
- * @param data The mapping data.
4518
- * @param options The mapping options.
4519
- * @returns The mapped value.
4542
+ * @param value The source to resolve the mapping against, usually an event.
4543
+ * @param data The mapping data: a key path, a value config, or a list of them.
4544
+ * @param context The collector (required), plus an optional event and consent.
4545
+ * @returns The mapped value, or undefined when the value is undefined.
4520
4546
  */
4521
- declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data$1, context?: Partial<Context$6>): Promise<Property | undefined>;
4547
+ declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data: Data$1 | undefined, context: ValueContext): Promise<Property | undefined>;
4522
4548
  /**
4523
4549
  * Processes an event through mapping configuration.
4524
4550
  *
package/dist/index.d.ts CHANGED
@@ -105,15 +105,24 @@ interface Rule<Settings = unknown> {
105
105
  */
106
106
  remove?: string[];
107
107
  }
108
+ /**
109
+ * A deep partial of T as `mergeMappingRule` applies it: every object key is
110
+ * optional and a `null` clears the inherited key (JSON merge-patch delete);
111
+ * arrays and functions replace as a whole.
112
+ */
113
+ type Patch<T> = T extends readonly unknown[] ? T : T extends (...args: never[]) => unknown ? T : T extends object ? {
114
+ [K in keyof T]?: Patch<T[K]> | null;
115
+ } : T;
108
116
  /**
109
117
  * A partial Rule used by `Rule.extend`. Every field is optional, and a
110
- * `null` value clears the inherited field (JSON merge-patch delete). The
111
- * control fields `extend` and `remove` are excluded: a patch models only
112
- * direct rule fields, matching what the runtime patch schema accepts.
118
+ * `null` at any object key clears the inherited key, for example
119
+ * `{ data: { map: { tax: null } } }`. The control fields `extend` and
120
+ * `remove` are excluded: a patch models only direct rule fields, matching
121
+ * what the runtime patch schema accepts.
113
122
  */
114
123
  type RulePatchFields<Settings = unknown> = Omit<Rule<Settings>, 'extend' | 'remove'>;
115
124
  type RulePatch<Settings = unknown> = {
116
- [K in keyof RulePatchFields<Settings>]?: RulePatchFields<Settings>[K] | null;
125
+ [K in keyof RulePatchFields<Settings>]?: Patch<RulePatchFields<Settings>[K]> | null;
117
126
  };
118
127
  interface Result$2 {
119
128
  eventMapping?: Rule;
@@ -154,6 +163,13 @@ interface Context$6 {
154
163
  logger: Instance$3;
155
164
  consent?: Consent;
156
165
  }
166
+ /**
167
+ * Context for `getMappingValue`. The collector is required; the other
168
+ * Context fields are optional. `event` and `consent` override what is
169
+ * inferred from the value and the collector; the logger always comes from
170
+ * the collector.
171
+ */
172
+ type ValueContext = Pick<Context$6, 'collector'> & Partial<Omit<Context$6, 'collector'>>;
157
173
  type Fn$4 = (value: unknown, context: Context$6) => PromiseOrValue<Property | unknown>;
158
174
  type Condition = (value: unknown, context: Context$6) => PromiseOrValue<boolean>;
159
175
  type Validate = (value: unknown, context: Context$6) => PromiseOrValue<boolean>;
@@ -172,10 +188,11 @@ type mapping_Rules<T = Rule> = Rules<T>;
172
188
  type mapping_Validate = Validate;
173
189
  type mapping_Value = Value;
174
190
  type mapping_ValueConfig = ValueConfig;
191
+ type mapping_ValueContext = ValueContext;
175
192
  type mapping_ValueType = ValueType;
176
193
  type mapping_Values = Values;
177
194
  declare namespace mapping {
178
- 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_Root as Root, mapping_Rule as Rule, mapping_RulePatch as RulePatch, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
195
+ 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_Root as Root, mapping_Rule as Rule, mapping_RulePatch as RulePatch, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueContext as ValueContext, mapping_ValueType as ValueType, mapping_Values as Values };
179
196
  }
180
197
 
181
198
  interface BaseCacheRule {
@@ -3440,7 +3457,12 @@ interface Event {
3440
3457
  interface Consent {
3441
3458
  [name: string]: boolean;
3442
3459
  }
3443
- interface User extends Properties {
3460
+ /**
3461
+ * Declared (named) fields of an event User. Index-free like `SourceFields`, so
3462
+ * the drift guard can compare `keyof UserFields` against
3463
+ * `keyof z.infer<typeof UserFieldsSchema>`.
3464
+ */
3465
+ interface UserFields {
3444
3466
  id?: string;
3445
3467
  device?: string;
3446
3468
  session?: string;
@@ -3463,6 +3485,9 @@ interface User extends Properties {
3463
3485
  screenSize?: string;
3464
3486
  ip?: string;
3465
3487
  internal?: boolean;
3488
+ optout?: boolean;
3489
+ }
3490
+ interface User extends Properties, UserFields {
3466
3491
  }
3467
3492
  type SourcePlatform = 'web' | 'server' | 'app' | 'ios' | 'android' | 'terminal' | string;
3468
3493
  /**
@@ -3554,8 +3579,9 @@ type walkeros_SourceFields = SourceFields;
3554
3579
  type walkeros_SourceMap = SourceMap;
3555
3580
  type walkeros_SourcePlatform = SourcePlatform;
3556
3581
  type walkeros_User = User;
3582
+ type walkeros_UserFields = UserFields;
3557
3583
  declare namespace walkeros {
3558
- export type { walkeros_ActionHandler as ActionHandler, walkeros_AnyFunction as AnyFunction, walkeros_AnyObject as AnyObject, walkeros_Consent as Consent, walkeros_ConsentHandler as ConsentHandler, walkeros_DeepPartial as DeepPartial, walkeros_DeepPartialEvent as DeepPartialEvent, walkeros_Elb as Elb, walkeros_Entities as Entities, walkeros_Entity as Entity, walkeros_Event as Event, walkeros_Events as Events, walkeros_OrderedProperties as OrderedProperties, walkeros_PartialEvent as PartialEvent, walkeros_PromiseOrValue as PromiseOrValue, walkeros_Properties as Properties, walkeros_Property as Property, walkeros_PropertyType as PropertyType, walkeros_SingleOrArray as SingleOrArray, walkeros_Source as Source, walkeros_SourceFields as SourceFields, walkeros_SourceMap as SourceMap, walkeros_SourcePlatform as SourcePlatform, walkeros_User as User };
3584
+ export type { walkeros_ActionHandler as ActionHandler, walkeros_AnyFunction as AnyFunction, walkeros_AnyObject as AnyObject, walkeros_Consent as Consent, walkeros_ConsentHandler as ConsentHandler, walkeros_DeepPartial as DeepPartial, walkeros_DeepPartialEvent as DeepPartialEvent, walkeros_Elb as Elb, walkeros_Entities as Entities, walkeros_Entity as Entity, walkeros_Event as Event, walkeros_Events as Events, walkeros_OrderedProperties as OrderedProperties, walkeros_PartialEvent as PartialEvent, walkeros_PromiseOrValue as PromiseOrValue, walkeros_Properties as Properties, walkeros_Property as Property, walkeros_PropertyType as PropertyType, walkeros_SingleOrArray as SingleOrArray, walkeros_Source as Source, walkeros_SourceFields as SourceFields, walkeros_SourceMap as SourceMap, walkeros_SourcePlatform as SourcePlatform, walkeros_User as User, walkeros_UserFields as UserFields };
3559
3585
  }
3560
3586
 
3561
3587
  /**
@@ -4513,12 +4539,12 @@ declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event,
4513
4539
  /**
4514
4540
  * Gets a value from a mapping.
4515
4541
  *
4516
- * @param value The value to get the mapping from.
4517
- * @param data The mapping data.
4518
- * @param options The mapping options.
4519
- * @returns The mapped value.
4542
+ * @param value The source to resolve the mapping against, usually an event.
4543
+ * @param data The mapping data: a key path, a value config, or a list of them.
4544
+ * @param context The collector (required), plus an optional event and consent.
4545
+ * @returns The mapped value, or undefined when the value is undefined.
4520
4546
  */
4521
- declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data$1, context?: Partial<Context$6>): Promise<Property | undefined>;
4547
+ declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data: Data$1 | undefined, context: ValueContext): Promise<Property | undefined>;
4522
4548
  /**
4523
4549
  * Processes an event through mapping configuration.
4524
4550
  *