@walkeros/core 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +309 -39
- package/dist/index.d.ts +309 -39
- 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 +5 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import * as zod_to_json_schema from 'zod-to-json-schema';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Core collector configuration interface
|
|
3
6
|
*/
|
|
4
|
-
interface Config$
|
|
7
|
+
interface Config$5 {
|
|
5
8
|
/** Whether to run collector automatically */
|
|
6
9
|
run?: boolean;
|
|
7
10
|
/** Version for event tagging */
|
|
@@ -20,7 +23,7 @@ interface Config$4 {
|
|
|
20
23
|
/**
|
|
21
24
|
* Initialization configuration that extends Config with initial state
|
|
22
25
|
*/
|
|
23
|
-
interface InitConfig extends Partial<Config$
|
|
26
|
+
interface InitConfig extends Partial<Config$5> {
|
|
24
27
|
/** Initial consent state */
|
|
25
28
|
consent?: Consent;
|
|
26
29
|
/** Initial user data */
|
|
@@ -53,10 +56,41 @@ interface Destinations$1 {
|
|
|
53
56
|
[id: string]: Instance$1;
|
|
54
57
|
}
|
|
55
58
|
type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' | 'elb' | 'globals' | 'hook' | 'init' | 'link' | 'run' | 'user' | 'walker' | string;
|
|
59
|
+
/**
|
|
60
|
+
* Context passed to collector.push for source mapping
|
|
61
|
+
*/
|
|
62
|
+
interface PushContext$1 {
|
|
63
|
+
mapping?: Config$2;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Push function signature - handles events only
|
|
67
|
+
*/
|
|
68
|
+
interface PushFn$1 {
|
|
69
|
+
(event: DeepPartialEvent, context?: PushContext$1): Promise<PushResult>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Command function signature - handles walker commands only
|
|
73
|
+
*/
|
|
74
|
+
interface CommandFn {
|
|
75
|
+
(command: 'config', config: Partial<Config$5>): Promise<PushResult>;
|
|
76
|
+
(command: 'consent', consent: Consent): Promise<PushResult>;
|
|
77
|
+
<T extends Types$2>(command: 'destination', destination: Init$1<T> | Instance$1<T>, config?: Config$4<T>): Promise<PushResult>;
|
|
78
|
+
<K extends keyof Functions>(command: 'hook', name: K, hookFn: Functions[K]): Promise<PushResult>;
|
|
79
|
+
(command: 'on', type: Types$1, rules: SingleOrArray<Options>): Promise<PushResult>;
|
|
80
|
+
(command: 'user', user: User): Promise<PushResult>;
|
|
81
|
+
(command: 'run', runState?: {
|
|
82
|
+
consent?: Consent;
|
|
83
|
+
user?: User;
|
|
84
|
+
globals?: Properties;
|
|
85
|
+
custom?: Properties;
|
|
86
|
+
}): Promise<PushResult>;
|
|
87
|
+
(command: string, data?: unknown, options?: unknown): Promise<PushResult>;
|
|
88
|
+
}
|
|
56
89
|
interface Instance$2 {
|
|
57
|
-
push:
|
|
90
|
+
push: PushFn$1;
|
|
91
|
+
command: CommandFn;
|
|
58
92
|
allowed: boolean;
|
|
59
|
-
config: Config$
|
|
93
|
+
config: Config$5;
|
|
60
94
|
consent: Consent;
|
|
61
95
|
count: number;
|
|
62
96
|
custom: Properties;
|
|
@@ -74,12 +108,13 @@ interface Instance$2 {
|
|
|
74
108
|
version: string;
|
|
75
109
|
}
|
|
76
110
|
|
|
111
|
+
type collector_CommandFn = CommandFn;
|
|
77
112
|
type collector_CommandType = CommandType;
|
|
78
113
|
type collector_InitConfig = InitConfig;
|
|
79
114
|
type collector_SessionData = SessionData;
|
|
80
115
|
type collector_Sources = Sources;
|
|
81
116
|
declare namespace collector {
|
|
82
|
-
export type { collector_CommandType as CommandType, Config$
|
|
117
|
+
export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$5 as Config, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$2 as Instance, PushContext$1 as PushContext, PushFn$1 as PushFn, collector_SessionData as SessionData, collector_Sources as Sources };
|
|
83
118
|
}
|
|
84
119
|
|
|
85
120
|
interface Contract$1 {
|
|
@@ -176,7 +211,7 @@ type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
|
|
|
176
211
|
*/
|
|
177
212
|
type TypesOf$1<I> = I extends Instance$1<infer T> ? T : never;
|
|
178
213
|
interface Instance$1<T extends TypesGeneric$1 = Types$2> {
|
|
179
|
-
config: Config$
|
|
214
|
+
config: Config$4<T>;
|
|
180
215
|
queue?: Events;
|
|
181
216
|
dlq?: DLQ;
|
|
182
217
|
type?: string;
|
|
@@ -186,7 +221,7 @@ interface Instance$1<T extends TypesGeneric$1 = Types$2> {
|
|
|
186
221
|
pushBatch?: PushBatchFn<T>;
|
|
187
222
|
on?: OnFn;
|
|
188
223
|
}
|
|
189
|
-
interface Config$
|
|
224
|
+
interface Config$4<T extends TypesGeneric$1 = Types$2> {
|
|
190
225
|
consent?: Consent;
|
|
191
226
|
settings?: Settings$1<T>;
|
|
192
227
|
data?: Value | Values;
|
|
@@ -201,13 +236,13 @@ interface Config$3<T extends TypesGeneric$1 = Types$2> {
|
|
|
201
236
|
onError?: Error;
|
|
202
237
|
onLog?: Log;
|
|
203
238
|
}
|
|
204
|
-
type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$
|
|
239
|
+
type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$4<Types$2<Partial<Settings$1<T>> | Settings$1<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$1<T>>>;
|
|
205
240
|
interface Policy$1 {
|
|
206
241
|
[key: string]: Value;
|
|
207
242
|
}
|
|
208
243
|
type Init$1<T extends TypesGeneric$1 = Types$2> = {
|
|
209
244
|
code: Instance$1<T>;
|
|
210
|
-
config?: Partial<Config$
|
|
245
|
+
config?: Partial<Config$4<T>>;
|
|
211
246
|
env?: Partial<Env$1<T>>;
|
|
212
247
|
};
|
|
213
248
|
interface InitDestinations {
|
|
@@ -218,7 +253,7 @@ interface Destinations {
|
|
|
218
253
|
}
|
|
219
254
|
interface Context$2<T extends TypesGeneric$1 = Types$2> {
|
|
220
255
|
collector: Instance$2;
|
|
221
|
-
config: Config$
|
|
256
|
+
config: Config$4<T>;
|
|
222
257
|
data?: Data$1;
|
|
223
258
|
env: Env$1<T>;
|
|
224
259
|
}
|
|
@@ -228,7 +263,7 @@ interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
|
228
263
|
interface PushBatchContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
229
264
|
mapping?: Rule<Mapping$1<T>>;
|
|
230
265
|
}
|
|
231
|
-
type InitFn<T extends TypesGeneric$1 = Types$2> = (context: Context$2<T>) => PromiseOrValue<void | false | Config$
|
|
266
|
+
type InitFn<T extends TypesGeneric$1 = Types$2> = (context: Context$2<T>) => PromiseOrValue<void | false | Config$4<T>>;
|
|
232
267
|
type PushFn<T extends TypesGeneric$1 = Types$2> = (event: Event, context: PushContext<T>) => PromiseOrValue<void>;
|
|
233
268
|
type PushBatchFn<T extends TypesGeneric$1 = Types$2> = (batch: Batch<Mapping$1<T>>, context: PushBatchContext<T>) => void;
|
|
234
269
|
type PushEvent<Mapping = unknown> = {
|
|
@@ -271,7 +306,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
|
271
306
|
type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
|
|
272
307
|
type destination_Ref = Ref;
|
|
273
308
|
declare namespace destination {
|
|
274
|
-
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$
|
|
309
|
+
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$4 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, Instance$1 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
|
|
275
310
|
}
|
|
276
311
|
|
|
277
312
|
interface EventFn<R = Promise<PushResult>> {
|
|
@@ -284,7 +319,7 @@ interface Fn$1<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, Wa
|
|
|
284
319
|
interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
|
|
285
320
|
(event: 'walker config', config: Partial<Config>): R;
|
|
286
321
|
(event: 'walker consent', consent: Consent): R;
|
|
287
|
-
<T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$1<T>, config?: Config$
|
|
322
|
+
<T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$1<T>, config?: Config$4<T>): R;
|
|
288
323
|
<K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
|
|
289
324
|
(event: 'walker on', type: Types$1, rules: SingleOrArray<Options>): R;
|
|
290
325
|
(event: 'walker user', user: User): R;
|
|
@@ -316,15 +351,15 @@ declare namespace elb {
|
|
|
316
351
|
* Flow configuration interface for dynamic walkerOS setup
|
|
317
352
|
* Used by bundlers and other tools to configure walkerOS dynamically
|
|
318
353
|
*/
|
|
319
|
-
interface Config$
|
|
354
|
+
interface Config$3 {
|
|
320
355
|
/** Collector configuration - uses existing Collector.Config from core */
|
|
321
|
-
collector: Config$
|
|
356
|
+
collector: Config$5;
|
|
322
357
|
/** NPM packages required for this configuration */
|
|
323
358
|
packages: Record<string, string>;
|
|
324
359
|
}
|
|
325
360
|
|
|
326
361
|
declare namespace flow {
|
|
327
|
-
export type { Config$
|
|
362
|
+
export type { Config$3 as Config };
|
|
328
363
|
}
|
|
329
364
|
|
|
330
365
|
type Error = (error: unknown, state?: unknown) => void;
|
|
@@ -352,6 +387,19 @@ declare namespace hooks {
|
|
|
352
387
|
export type { AnyFunction$1 as AnyFunction, hooks_Functions as Functions, hooks_HookFn as HookFn };
|
|
353
388
|
}
|
|
354
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Shared mapping configuration interface.
|
|
392
|
+
* Used by both Source.Config and Destination.Config.
|
|
393
|
+
*/
|
|
394
|
+
interface Config$2<T = unknown> {
|
|
395
|
+
consent?: Consent;
|
|
396
|
+
data?: Value | Values;
|
|
397
|
+
mapping?: Rules<Rule<T>>;
|
|
398
|
+
policy?: Policy;
|
|
399
|
+
}
|
|
400
|
+
interface Policy {
|
|
401
|
+
[key: string]: Value;
|
|
402
|
+
}
|
|
355
403
|
interface Rules<T = Rule> {
|
|
356
404
|
[entity: string]: Record<string, T | Array<T>> | undefined;
|
|
357
405
|
}
|
|
@@ -365,6 +413,7 @@ interface Rule<Settings = unknown> {
|
|
|
365
413
|
data?: Data;
|
|
366
414
|
ignore?: boolean;
|
|
367
415
|
name?: string;
|
|
416
|
+
policy?: Policy;
|
|
368
417
|
}
|
|
369
418
|
interface Result {
|
|
370
419
|
eventMapping?: Rule;
|
|
@@ -403,6 +452,7 @@ type mapping_Data = Data;
|
|
|
403
452
|
type mapping_Fn = Fn;
|
|
404
453
|
type mapping_Loop = Loop;
|
|
405
454
|
type mapping_Map = Map;
|
|
455
|
+
type mapping_Policy = Policy;
|
|
406
456
|
type mapping_Result = Result;
|
|
407
457
|
type mapping_Rule<Settings = unknown> = Rule<Settings>;
|
|
408
458
|
type mapping_Rules<T = Rule> = Rules<T>;
|
|
@@ -412,7 +462,7 @@ type mapping_ValueConfig = ValueConfig;
|
|
|
412
462
|
type mapping_ValueType = ValueType;
|
|
413
463
|
type mapping_Values = Values;
|
|
414
464
|
declare namespace mapping {
|
|
415
|
-
export type { mapping_Condition as Condition, mapping_Data as Data, mapping_Fn as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Result as Result, mapping_Rule as Rule, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
465
|
+
export type { mapping_Condition as Condition, Config$2 as Config, mapping_Data as Data, mapping_Fn as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Policy as Policy, mapping_Result as Result, mapping_Rule as Rule, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
416
466
|
}
|
|
417
467
|
|
|
418
468
|
type Config$1 = {
|
|
@@ -527,8 +577,11 @@ declare namespace schema {
|
|
|
527
577
|
* making them platform-agnostic and easily testable.
|
|
528
578
|
*/
|
|
529
579
|
interface BaseEnv {
|
|
530
|
-
elb: Fn$1;
|
|
531
580
|
[key: string]: unknown;
|
|
581
|
+
push: PushFn$1;
|
|
582
|
+
command: CommandFn;
|
|
583
|
+
sources?: Sources;
|
|
584
|
+
elb: Fn$1;
|
|
532
585
|
}
|
|
533
586
|
/**
|
|
534
587
|
* Type bundle for source generics.
|
|
@@ -565,7 +618,7 @@ type Env<T extends TypesGeneric = Types> = T['env'];
|
|
|
565
618
|
* Inference helper: Extract Types from Instance
|
|
566
619
|
*/
|
|
567
620
|
type TypesOf<I> = I extends Instance<infer T> ? T : never;
|
|
568
|
-
interface Config<T extends TypesGeneric = Types> {
|
|
621
|
+
interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
|
|
569
622
|
settings?: Settings<T>;
|
|
570
623
|
env?: Env<T>;
|
|
571
624
|
id?: string;
|
|
@@ -574,9 +627,6 @@ interface Config<T extends TypesGeneric = Types> {
|
|
|
574
627
|
primary?: boolean;
|
|
575
628
|
}
|
|
576
629
|
type PartialConfig<T extends TypesGeneric = Types> = Config<Types<Partial<Settings<T>> | Settings<T>, Partial<Mapping<T>> | Mapping<T>, Push<T>, Env<T>>>;
|
|
577
|
-
interface Policy {
|
|
578
|
-
[key: string]: Value;
|
|
579
|
-
}
|
|
580
630
|
interface Instance<T extends TypesGeneric = Types> {
|
|
581
631
|
type: string;
|
|
582
632
|
config: Config<T>;
|
|
@@ -608,14 +658,13 @@ type source_InitSources = InitSources;
|
|
|
608
658
|
type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
|
|
609
659
|
type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
|
|
610
660
|
type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
|
|
611
|
-
type source_Policy = Policy;
|
|
612
661
|
type source_Push<T extends TypesGeneric = Types> = Push<T>;
|
|
613
662
|
type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
|
|
614
663
|
type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> = Types<S, M, P, E>;
|
|
615
664
|
type source_TypesGeneric = TypesGeneric;
|
|
616
665
|
type source_TypesOf<I> = TypesOf<I>;
|
|
617
666
|
declare namespace source {
|
|
618
|
-
export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig,
|
|
667
|
+
export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
|
|
619
668
|
}
|
|
620
669
|
|
|
621
670
|
type AnyObject<T = unknown> = Record<string, T>;
|
|
@@ -744,6 +793,210 @@ declare const Const: {
|
|
|
744
793
|
};
|
|
745
794
|
};
|
|
746
795
|
|
|
796
|
+
type SendDataValue = Property | Properties;
|
|
797
|
+
type SendHeaders = {
|
|
798
|
+
[key: string]: string;
|
|
799
|
+
};
|
|
800
|
+
interface SendResponse {
|
|
801
|
+
ok: boolean;
|
|
802
|
+
data?: unknown;
|
|
803
|
+
error?: string;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Zod Schemas for walkerOS Mapping ValueConfig
|
|
808
|
+
*
|
|
809
|
+
* These schemas provide:
|
|
810
|
+
* 1. Runtime validation for mapping values
|
|
811
|
+
* 2. JSON Schema generation for RJSF/Explorer
|
|
812
|
+
* 3. Documentation via .describe()
|
|
813
|
+
*
|
|
814
|
+
* Note: TypeScript types remain in packages/core/src/types/mapping.ts
|
|
815
|
+
* These Zod schemas are for VALIDATION and JSON SCHEMA GENERATION only.
|
|
816
|
+
*
|
|
817
|
+
* The circular/recursive nature of Value → ValueConfig → Value makes
|
|
818
|
+
* full type inference complex, so we use z.any() with lazy evaluation
|
|
819
|
+
* and keep existing TypeScript types separate.
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* // Validate at runtime
|
|
823
|
+
* const result = ValueConfigSchema.safeParse(userInput);
|
|
824
|
+
*
|
|
825
|
+
* // Generate JSON Schema for Explorer
|
|
826
|
+
* const jsonSchema = zodToJsonSchema(ValueConfigSchema);
|
|
827
|
+
*/
|
|
828
|
+
/**
|
|
829
|
+
* Consent schema
|
|
830
|
+
* Maps consent groups to boolean states
|
|
831
|
+
*/
|
|
832
|
+
declare const ConsentSchema: z.ZodRecord<z.ZodString, z.ZodBoolean>;
|
|
833
|
+
declare const ValueSchema: z.ZodType<any, z.ZodTypeDef, any>;
|
|
834
|
+
declare const LoopSchema: z.ZodType<any, z.ZodTypeDef, any>;
|
|
835
|
+
declare const SetSchema: z.ZodType<any, z.ZodTypeDef, any>;
|
|
836
|
+
declare const MapSchema: z.ZodType<any, z.ZodTypeDef, any>;
|
|
837
|
+
declare const ValueConfigSchema: z.ZodType<any, z.ZodTypeDef, any>;
|
|
838
|
+
declare const valueConfigJsonSchema: zod_to_json_schema.JsonSchema7Type & {
|
|
839
|
+
$schema?: string | undefined;
|
|
840
|
+
definitions?: {
|
|
841
|
+
[key: string]: zod_to_json_schema.JsonSchema7Type;
|
|
842
|
+
} | undefined;
|
|
843
|
+
};
|
|
844
|
+
declare const loopJsonSchema: zod_to_json_schema.JsonSchema7Type & {
|
|
845
|
+
$schema?: string | undefined;
|
|
846
|
+
definitions?: {
|
|
847
|
+
[key: string]: zod_to_json_schema.JsonSchema7Type;
|
|
848
|
+
} | undefined;
|
|
849
|
+
};
|
|
850
|
+
declare const setJsonSchema: zod_to_json_schema.JsonSchema7Type & {
|
|
851
|
+
$schema?: string | undefined;
|
|
852
|
+
definitions?: {
|
|
853
|
+
[key: string]: zod_to_json_schema.JsonSchema7Type;
|
|
854
|
+
} | undefined;
|
|
855
|
+
};
|
|
856
|
+
declare const mapJsonSchema: zod_to_json_schema.JsonSchema7Type & {
|
|
857
|
+
$schema?: string | undefined;
|
|
858
|
+
definitions?: {
|
|
859
|
+
[key: string]: zod_to_json_schema.JsonSchema7Type;
|
|
860
|
+
} | undefined;
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* JSON Schema type
|
|
865
|
+
*/
|
|
866
|
+
type JSONSchema = Record<string, unknown>;
|
|
867
|
+
/**
|
|
868
|
+
* Schema Builder - DRY utility for creating JSON Schemas
|
|
869
|
+
*
|
|
870
|
+
* This utility allows destinations to define schemas using simple objects,
|
|
871
|
+
* without needing Zod as a dependency. The core package handles conversion.
|
|
872
|
+
*
|
|
873
|
+
* Benefits:
|
|
874
|
+
* - Single source of schema generation logic
|
|
875
|
+
* - No Zod dependency in destination packages
|
|
876
|
+
* - Simple, declarative schema definitions
|
|
877
|
+
* - Type-safe with TypeScript
|
|
878
|
+
* - Follows DRY principle
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* // In destination package (NO Zod needed!)
|
|
882
|
+
* import { createObjectSchema, createArraySchema } from '@walkeros/core/schemas';
|
|
883
|
+
*
|
|
884
|
+
* export const settingsSchema = createObjectSchema({
|
|
885
|
+
* pixelId: {
|
|
886
|
+
* type: 'string',
|
|
887
|
+
* required: true,
|
|
888
|
+
* pattern: '^[0-9]+$',
|
|
889
|
+
* description: 'Your Meta Pixel ID',
|
|
890
|
+
* },
|
|
891
|
+
* });
|
|
892
|
+
*/
|
|
893
|
+
/**
|
|
894
|
+
* Property definition for schema builder
|
|
895
|
+
*/
|
|
896
|
+
interface PropertyDef {
|
|
897
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
898
|
+
required?: boolean;
|
|
899
|
+
description?: string;
|
|
900
|
+
pattern?: string;
|
|
901
|
+
minLength?: number;
|
|
902
|
+
maxLength?: number;
|
|
903
|
+
minimum?: number;
|
|
904
|
+
maximum?: number;
|
|
905
|
+
enum?: readonly string[] | readonly number[];
|
|
906
|
+
properties?: Record<string, PropertyDef>;
|
|
907
|
+
items?: PropertyDef;
|
|
908
|
+
default?: unknown;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Create object schema from property definitions
|
|
912
|
+
*
|
|
913
|
+
* @param properties - Property definitions
|
|
914
|
+
* @param title - Optional schema title
|
|
915
|
+
* @returns JSON Schema
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
* const schema = createObjectSchema({
|
|
919
|
+
* pixelId: {
|
|
920
|
+
* type: 'string',
|
|
921
|
+
* required: true,
|
|
922
|
+
* pattern: '^[0-9]+$',
|
|
923
|
+
* description: 'Your Meta Pixel ID',
|
|
924
|
+
* },
|
|
925
|
+
* eventName: {
|
|
926
|
+
* type: 'string',
|
|
927
|
+
* enum: ['PageView', 'Purchase'],
|
|
928
|
+
* },
|
|
929
|
+
* }, 'Meta Pixel Settings');
|
|
930
|
+
*/
|
|
931
|
+
declare function createObjectSchema(properties: Record<string, PropertyDef>, title?: string): JSONSchema;
|
|
932
|
+
/**
|
|
933
|
+
* Create array schema
|
|
934
|
+
*
|
|
935
|
+
* @param itemDef - Definition for array items
|
|
936
|
+
* @param options - Optional array constraints
|
|
937
|
+
* @returns JSON Schema
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* // Simple string array
|
|
941
|
+
* const tagsSchema = createArraySchema({ type: 'string' });
|
|
942
|
+
*
|
|
943
|
+
* // Tuple (loop pattern) - exactly 2 items
|
|
944
|
+
* const loopSchema = createArraySchema(
|
|
945
|
+
* { type: 'object' },
|
|
946
|
+
* { minItems: 2, maxItems: 2 }
|
|
947
|
+
* );
|
|
948
|
+
*
|
|
949
|
+
* // Array with enum
|
|
950
|
+
* const includeSchema = createArraySchema({
|
|
951
|
+
* type: 'string',
|
|
952
|
+
* enum: ['data', 'context', 'globals'],
|
|
953
|
+
* });
|
|
954
|
+
*/
|
|
955
|
+
declare function createArraySchema(itemDef: PropertyDef, options?: {
|
|
956
|
+
minItems?: number;
|
|
957
|
+
maxItems?: number;
|
|
958
|
+
description?: string;
|
|
959
|
+
title?: string;
|
|
960
|
+
}): JSONSchema;
|
|
961
|
+
/**
|
|
962
|
+
* Create enum schema
|
|
963
|
+
*
|
|
964
|
+
* @param values - Allowed values
|
|
965
|
+
* @param type - Value type ('string' or 'number')
|
|
966
|
+
* @param options - Optional constraints
|
|
967
|
+
* @returns JSON Schema
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* const eventTypeSchema = createEnumSchema(
|
|
971
|
+
* ['PageView', 'Purchase', 'AddToCart'],
|
|
972
|
+
* 'string',
|
|
973
|
+
* { description: 'Meta Pixel standard event' }
|
|
974
|
+
* );
|
|
975
|
+
*/
|
|
976
|
+
declare function createEnumSchema(values: readonly string[] | readonly number[], type?: 'string' | 'number', options?: {
|
|
977
|
+
description?: string;
|
|
978
|
+
title?: string;
|
|
979
|
+
}): JSONSchema;
|
|
980
|
+
/**
|
|
981
|
+
* Create tuple schema (Loop pattern)
|
|
982
|
+
*
|
|
983
|
+
* Creates an array schema with exactly 2 items, which the Explorer
|
|
984
|
+
* type detector recognizes as a "loop" pattern.
|
|
985
|
+
*
|
|
986
|
+
* @param firstItem - Definition for first element (source)
|
|
987
|
+
* @param secondItem - Definition for second element (transform)
|
|
988
|
+
* @param description - Optional description
|
|
989
|
+
* @returns JSON Schema with minItems=2, maxItems=2
|
|
990
|
+
*
|
|
991
|
+
* @example
|
|
992
|
+
* const loopSchema = createTupleSchema(
|
|
993
|
+
* { type: 'string' },
|
|
994
|
+
* { type: 'object' },
|
|
995
|
+
* 'Loop: [source, transform]'
|
|
996
|
+
* );
|
|
997
|
+
*/
|
|
998
|
+
declare function createTupleSchema(firstItem: PropertyDef, secondItem: PropertyDef, description?: string): JSONSchema;
|
|
999
|
+
|
|
747
1000
|
/**
|
|
748
1001
|
* Anonymizes an IPv4 address by setting the last octet to 0.
|
|
749
1002
|
*
|
|
@@ -791,12 +1044,12 @@ declare function getByPath(event: unknown, key?: string, defaultValue?: unknown)
|
|
|
791
1044
|
/**
|
|
792
1045
|
* Sets a value in an object by a dot-notation string.
|
|
793
1046
|
*
|
|
794
|
-
* @param
|
|
1047
|
+
* @param obj - The object to set the value in.
|
|
795
1048
|
* @param key - The dot-notation string.
|
|
796
1049
|
* @param value - The value to set.
|
|
797
1050
|
* @returns A new object with the updated value.
|
|
798
1051
|
*/
|
|
799
|
-
declare function setByPath(
|
|
1052
|
+
declare function setByPath<T = unknown>(obj: T, key: string, value: unknown): T;
|
|
800
1053
|
|
|
801
1054
|
/**
|
|
802
1055
|
* Casts a value to a specific type.
|
|
@@ -846,7 +1099,7 @@ declare function getGrantedConsent(required: Consent | undefined, state?: Consen
|
|
|
846
1099
|
* }));
|
|
847
1100
|
* ```
|
|
848
1101
|
*/
|
|
849
|
-
declare function createDestination<I extends Instance$1>(baseDestination: I, config: Partial<Config$
|
|
1102
|
+
declare function createDestination<I extends Instance$1>(baseDestination: I, config: Partial<Config$4<TypesOf$1<I>>>): I;
|
|
850
1103
|
|
|
851
1104
|
/**
|
|
852
1105
|
* Creates a complete event with default values.
|
|
@@ -983,11 +1236,11 @@ declare function isString(value: unknown): value is string;
|
|
|
983
1236
|
/**
|
|
984
1237
|
* Gets the mapping for an event.
|
|
985
1238
|
*
|
|
986
|
-
* @param event The event to get the mapping for.
|
|
1239
|
+
* @param event The event to get the mapping for (can be partial or full).
|
|
987
1240
|
* @param mapping The mapping rules.
|
|
988
1241
|
* @returns The mapping result.
|
|
989
1242
|
*/
|
|
990
|
-
declare function getMappingEvent(event: PartialEvent, mapping?: Rules): Promise<Result>;
|
|
1243
|
+
declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules): Promise<Result>;
|
|
991
1244
|
/**
|
|
992
1245
|
* Gets a value from a mapping.
|
|
993
1246
|
*
|
|
@@ -997,6 +1250,32 @@ declare function getMappingEvent(event: PartialEvent, mapping?: Rules): Promise<
|
|
|
997
1250
|
* @returns The mapped value.
|
|
998
1251
|
*/
|
|
999
1252
|
declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data, options?: Options$1): Promise<Property | undefined>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Processes an event through mapping configuration.
|
|
1255
|
+
*
|
|
1256
|
+
* This is the unified mapping logic used by both sources and destinations.
|
|
1257
|
+
* It applies transformations in this order:
|
|
1258
|
+
* 1. Config-level policy - modifies the event itself (global rules)
|
|
1259
|
+
* 2. Mapping rules - finds matching rule based on entity-action
|
|
1260
|
+
* 3. Event-level policy - modifies the event based on specific mapping rule
|
|
1261
|
+
* 4. Data transformation - creates context data
|
|
1262
|
+
* 5. Ignore check and name override
|
|
1263
|
+
*
|
|
1264
|
+
* Sources can pass partial events, destinations pass full events.
|
|
1265
|
+
* getMappingValue works with both partial and full events.
|
|
1266
|
+
*
|
|
1267
|
+
* @param event - The event to process (can be partial or full, will be mutated by policies)
|
|
1268
|
+
* @param config - Mapping configuration (mapping, data, policy, consent)
|
|
1269
|
+
* @param collector - Collector instance for context
|
|
1270
|
+
* @returns Object with transformed event, data, mapping rule, and ignore flag
|
|
1271
|
+
*/
|
|
1272
|
+
declare function processEventMapping<T extends DeepPartialEvent | Event>(event: T, config: Config$2, collector: Instance$2): Promise<{
|
|
1273
|
+
event: T;
|
|
1274
|
+
data?: Property;
|
|
1275
|
+
mapping?: Rule;
|
|
1276
|
+
mappingKey?: string;
|
|
1277
|
+
ignore: boolean;
|
|
1278
|
+
}>;
|
|
1000
1279
|
|
|
1001
1280
|
/**
|
|
1002
1281
|
* Environment mocking utilities for walkerOS destinations
|
|
@@ -1109,15 +1388,6 @@ declare function requestToData(parameter: unknown): AnyObject | undefined;
|
|
|
1109
1388
|
*/
|
|
1110
1389
|
declare function requestToParameter(data: AnyObject | PropertyType): string;
|
|
1111
1390
|
|
|
1112
|
-
type SendDataValue = Property | Properties;
|
|
1113
|
-
type SendHeaders = {
|
|
1114
|
-
[key: string]: string;
|
|
1115
|
-
};
|
|
1116
|
-
interface SendResponse {
|
|
1117
|
-
ok: boolean;
|
|
1118
|
-
data?: unknown;
|
|
1119
|
-
error?: string;
|
|
1120
|
-
}
|
|
1121
1391
|
/**
|
|
1122
1392
|
* Transforms data to a string.
|
|
1123
1393
|
*
|
|
@@ -1244,4 +1514,4 @@ declare function validateEvent(obj: unknown, customContracts?: Contracts): Event
|
|
|
1244
1514
|
*/
|
|
1245
1515
|
declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
|
|
1246
1516
|
|
|
1247
|
-
export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, handler as Handler, hooks as Hooks, mapping as Mapping, type MarketingParameters, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, mockEnv, onLog, parseUserAgent, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty };
|
|
1517
|
+
export { collector as Collector, ConsentSchema, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, handler as Handler, hooks as Hooks, type JSONSchema, LoopSchema, MapSchema, mapping as Mapping, type MarketingParameters, on as On, type PropertyDef, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, SetSchema, source as Source, type StorageType, ValueConfigSchema, ValueSchema, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createArraySchema, createDestination, createEnumSchema, createEvent, createObjectSchema, createTupleSchema, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, loopJsonSchema, mapJsonSchema, mockEnv, onLog, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, setJsonSchema, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, valueConfigJsonSchema };
|