@walkeros/core 0.1.2 → 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 +550 -145
- package/dist/index.d.ts +550 -145
- 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,27 +1,18 @@
|
|
|
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
|
-
/** Initial consent state */
|
|
8
|
-
consent?: Consent;
|
|
9
|
-
/** Initial user data */
|
|
10
|
-
user?: User;
|
|
11
10
|
/** Version for event tagging */
|
|
12
11
|
tagging: number;
|
|
13
|
-
/** Initial global properties */
|
|
14
|
-
globals?: Properties;
|
|
15
12
|
/** Static global properties even on a new run */
|
|
16
13
|
globalsStatic: Properties;
|
|
17
14
|
/** Static session data even on a new run */
|
|
18
15
|
sessionStatic: Partial<SessionData>;
|
|
19
|
-
/** Source configurations */
|
|
20
|
-
sources?: InitSources;
|
|
21
|
-
/** Destination configurations */
|
|
22
|
-
destinations?: InitDestinations;
|
|
23
|
-
/** Initial custom properties */
|
|
24
|
-
custom?: Properties;
|
|
25
16
|
/** Enable verbose logging */
|
|
26
17
|
verbose: boolean;
|
|
27
18
|
/** Error handler */
|
|
@@ -29,7 +20,23 @@ interface Config$4 {
|
|
|
29
20
|
/** Log handler */
|
|
30
21
|
onLog?: Log;
|
|
31
22
|
}
|
|
32
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Initialization configuration that extends Config with initial state
|
|
25
|
+
*/
|
|
26
|
+
interface InitConfig extends Partial<Config$5> {
|
|
27
|
+
/** Initial consent state */
|
|
28
|
+
consent?: Consent;
|
|
29
|
+
/** Initial user data */
|
|
30
|
+
user?: User;
|
|
31
|
+
/** Initial global properties */
|
|
32
|
+
globals?: Properties;
|
|
33
|
+
/** Source configurations */
|
|
34
|
+
sources?: InitSources;
|
|
35
|
+
/** Destination configurations */
|
|
36
|
+
destinations?: InitDestinations;
|
|
37
|
+
/** Initial custom properties */
|
|
38
|
+
custom?: Properties;
|
|
39
|
+
}
|
|
33
40
|
interface SessionData extends Properties {
|
|
34
41
|
isStart: boolean;
|
|
35
42
|
storage: boolean;
|
|
@@ -49,10 +56,41 @@ interface Destinations$1 {
|
|
|
49
56
|
[id: string]: Instance$1;
|
|
50
57
|
}
|
|
51
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
|
+
}
|
|
52
89
|
interface Instance$2 {
|
|
53
|
-
push:
|
|
90
|
+
push: PushFn$1;
|
|
91
|
+
command: CommandFn;
|
|
54
92
|
allowed: boolean;
|
|
55
|
-
config: Config$
|
|
93
|
+
config: Config$5;
|
|
56
94
|
consent: Consent;
|
|
57
95
|
count: number;
|
|
58
96
|
custom: Properties;
|
|
@@ -70,11 +108,13 @@ interface Instance$2 {
|
|
|
70
108
|
version: string;
|
|
71
109
|
}
|
|
72
110
|
|
|
111
|
+
type collector_CommandFn = CommandFn;
|
|
73
112
|
type collector_CommandType = CommandType;
|
|
113
|
+
type collector_InitConfig = InitConfig;
|
|
74
114
|
type collector_SessionData = SessionData;
|
|
75
115
|
type collector_Sources = Sources;
|
|
76
116
|
declare namespace collector {
|
|
77
|
-
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 };
|
|
78
118
|
}
|
|
79
119
|
|
|
80
120
|
interface Contract$1 {
|
|
@@ -87,7 +127,7 @@ interface Globals {
|
|
|
87
127
|
[name: string]: Global;
|
|
88
128
|
}
|
|
89
129
|
interface Contexts {
|
|
90
|
-
[name: string]: Context$
|
|
130
|
+
[name: string]: Context$3;
|
|
91
131
|
}
|
|
92
132
|
interface Entities$1 {
|
|
93
133
|
[name: string]: Entity$1;
|
|
@@ -97,7 +137,7 @@ interface Properties$2 {
|
|
|
97
137
|
}
|
|
98
138
|
interface Global extends Property$2 {
|
|
99
139
|
}
|
|
100
|
-
interface Context$
|
|
140
|
+
interface Context$3 extends Property$2 {
|
|
101
141
|
}
|
|
102
142
|
interface Entity$1 {
|
|
103
143
|
data: Properties$2;
|
|
@@ -126,65 +166,106 @@ type data_Globals = Globals;
|
|
|
126
166
|
type data_PropertyValues = PropertyValues;
|
|
127
167
|
type data_Trigger = Trigger;
|
|
128
168
|
declare namespace data {
|
|
129
|
-
export type { data_Action as Action, data_Actions as Actions, Context$
|
|
169
|
+
export type { data_Action as Action, data_Actions as Actions, Context$3 as Context, data_Contexts as Contexts, Contract$1 as Contract, Entities$1 as Entities, Entity$1 as Entity, data_Global as Global, data_Globals as Globals, Properties$2 as Properties, Property$2 as Property, PropertyType$1 as PropertyType, data_PropertyValues as PropertyValues, data_Trigger as Trigger };
|
|
130
170
|
}
|
|
131
171
|
|
|
132
|
-
|
|
133
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Base environment requirements interface for walkerOS destinations
|
|
174
|
+
*
|
|
175
|
+
* This defines the core interface that destinations can use to declare
|
|
176
|
+
* their runtime environment requirements. Platform-specific extensions
|
|
177
|
+
* should extend this interface.
|
|
178
|
+
*/
|
|
179
|
+
interface BaseEnv$1 {
|
|
180
|
+
/**
|
|
181
|
+
* Generic global properties that destinations may require
|
|
182
|
+
* Platform-specific implementations can extend this interface
|
|
183
|
+
*/
|
|
184
|
+
[key: string]: unknown;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Type bundle for destination generics.
|
|
188
|
+
* Groups Settings, Mapping, and Env into a single type parameter.
|
|
189
|
+
*/
|
|
190
|
+
interface Types$2<S = unknown, M = unknown, E = BaseEnv$1> {
|
|
191
|
+
settings: S;
|
|
192
|
+
mapping: M;
|
|
193
|
+
env: E;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Generic constraint for Types - ensures T has required properties for indexed access
|
|
197
|
+
*/
|
|
198
|
+
type TypesGeneric$1 = {
|
|
199
|
+
settings: any;
|
|
200
|
+
mapping: any;
|
|
201
|
+
env: any;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Type extractors for consistent usage with Types bundle
|
|
205
|
+
*/
|
|
206
|
+
type Settings$1<T extends TypesGeneric$1 = Types$2> = T['settings'];
|
|
207
|
+
type Mapping$1<T extends TypesGeneric$1 = Types$2> = T['mapping'];
|
|
208
|
+
type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
|
|
209
|
+
/**
|
|
210
|
+
* Inference helper: Extract Types from Instance
|
|
211
|
+
*/
|
|
212
|
+
type TypesOf$1<I> = I extends Instance$1<infer T> ? T : never;
|
|
213
|
+
interface Instance$1<T extends TypesGeneric$1 = Types$2> {
|
|
214
|
+
config: Config$4<T>;
|
|
134
215
|
queue?: Events;
|
|
135
216
|
dlq?: DLQ;
|
|
136
217
|
type?: string;
|
|
137
|
-
env?:
|
|
138
|
-
init?: InitFn<
|
|
139
|
-
push: PushFn<
|
|
140
|
-
pushBatch?: PushBatchFn<
|
|
141
|
-
on
|
|
218
|
+
env?: Env$1<T>;
|
|
219
|
+
init?: InitFn<T>;
|
|
220
|
+
push: PushFn<T>;
|
|
221
|
+
pushBatch?: PushBatchFn<T>;
|
|
222
|
+
on?: OnFn;
|
|
142
223
|
}
|
|
143
|
-
interface Config$
|
|
224
|
+
interface Config$4<T extends TypesGeneric$1 = Types$2> {
|
|
144
225
|
consent?: Consent;
|
|
145
|
-
settings?: Settings
|
|
226
|
+
settings?: Settings$1<T>;
|
|
146
227
|
data?: Value | Values;
|
|
147
|
-
env?:
|
|
228
|
+
env?: Env$1<T>;
|
|
148
229
|
id?: string;
|
|
149
230
|
init?: boolean;
|
|
150
231
|
loadScript?: boolean;
|
|
151
|
-
mapping?: Rules<Rule<Mapping
|
|
152
|
-
policy?: Policy;
|
|
232
|
+
mapping?: Rules<Rule<Mapping$1<T>>>;
|
|
233
|
+
policy?: Policy$1;
|
|
153
234
|
queue?: boolean;
|
|
154
235
|
verbose?: boolean;
|
|
155
236
|
onError?: Error;
|
|
156
237
|
onLog?: Log;
|
|
157
238
|
}
|
|
158
|
-
type PartialConfig<
|
|
159
|
-
interface Policy {
|
|
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>>>;
|
|
240
|
+
interface Policy$1 {
|
|
160
241
|
[key: string]: Value;
|
|
161
242
|
}
|
|
162
|
-
type Init$1<
|
|
163
|
-
code: Instance$1<
|
|
164
|
-
config?: Partial<Config$
|
|
165
|
-
env?: Partial<
|
|
243
|
+
type Init$1<T extends TypesGeneric$1 = Types$2> = {
|
|
244
|
+
code: Instance$1<T>;
|
|
245
|
+
config?: Partial<Config$4<T>>;
|
|
246
|
+
env?: Partial<Env$1<T>>;
|
|
166
247
|
};
|
|
167
248
|
interface InitDestinations {
|
|
168
|
-
[key: string]: Init$1<any
|
|
249
|
+
[key: string]: Init$1<any>;
|
|
169
250
|
}
|
|
170
251
|
interface Destinations {
|
|
171
252
|
[key: string]: Instance$1;
|
|
172
253
|
}
|
|
173
|
-
interface Context$
|
|
254
|
+
interface Context$2<T extends TypesGeneric$1 = Types$2> {
|
|
174
255
|
collector: Instance$2;
|
|
175
|
-
config: Config$
|
|
256
|
+
config: Config$4<T>;
|
|
176
257
|
data?: Data$1;
|
|
177
|
-
env:
|
|
258
|
+
env: Env$1<T>;
|
|
178
259
|
}
|
|
179
|
-
interface PushContext<
|
|
180
|
-
mapping?: Rule<Mapping
|
|
260
|
+
interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
261
|
+
mapping?: Rule<Mapping$1<T>>;
|
|
181
262
|
}
|
|
182
|
-
interface PushBatchContext<
|
|
183
|
-
mapping?: Rule<Mapping
|
|
263
|
+
interface PushBatchContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
264
|
+
mapping?: Rule<Mapping$1<T>>;
|
|
184
265
|
}
|
|
185
|
-
type InitFn<
|
|
186
|
-
type PushFn<
|
|
187
|
-
type PushBatchFn<
|
|
266
|
+
type InitFn<T extends TypesGeneric$1 = Types$2> = (context: Context$2<T>) => PromiseOrValue<void | false | Config$4<T>>;
|
|
267
|
+
type PushFn<T extends TypesGeneric$1 = Types$2> = (event: Event, context: PushContext<T>) => PromiseOrValue<void>;
|
|
268
|
+
type PushBatchFn<T extends TypesGeneric$1 = Types$2> = (batch: Batch<Mapping$1<T>>, context: PushBatchContext<T>) => void;
|
|
188
269
|
type PushEvent<Mapping = unknown> = {
|
|
189
270
|
event: Event;
|
|
190
271
|
mapping?: Rule<Mapping>;
|
|
@@ -201,7 +282,7 @@ type Ref = {
|
|
|
201
282
|
id: string;
|
|
202
283
|
destination: Instance$1;
|
|
203
284
|
};
|
|
204
|
-
type Push = {
|
|
285
|
+
type Push$1 = {
|
|
205
286
|
queue?: Events;
|
|
206
287
|
error?: unknown;
|
|
207
288
|
};
|
|
@@ -211,38 +292,21 @@ type Result$1 = {
|
|
|
211
292
|
queued: Array<Ref>;
|
|
212
293
|
failed: Array<Ref>;
|
|
213
294
|
};
|
|
214
|
-
/**
|
|
215
|
-
* Base environment requirements interface for walkerOS destinations
|
|
216
|
-
*
|
|
217
|
-
* This defines the core interface that destinations can use to declare
|
|
218
|
-
* their runtime environment requirements. Platform-specific extensions
|
|
219
|
-
* should extend this interface.
|
|
220
|
-
*/
|
|
221
|
-
interface Environment$1 {
|
|
222
|
-
/**
|
|
223
|
-
* Generic global properties that destinations may require
|
|
224
|
-
* Platform-specific implementations can extend this interface
|
|
225
|
-
*/
|
|
226
|
-
[key: string]: unknown;
|
|
227
|
-
}
|
|
228
295
|
|
|
229
296
|
type destination_Batch<Mapping> = Batch<Mapping>;
|
|
230
297
|
type destination_DLQ = DLQ;
|
|
231
298
|
type destination_Destinations = Destinations;
|
|
232
299
|
type destination_InitDestinations = InitDestinations;
|
|
233
|
-
type destination_InitFn<
|
|
234
|
-
type
|
|
235
|
-
type
|
|
236
|
-
type
|
|
237
|
-
type destination_PushBatchContext<Settings = unknown, Mapping = unknown> = PushBatchContext<Settings, Mapping>;
|
|
238
|
-
type destination_PushBatchFn<Settings, Mapping> = PushBatchFn<Settings, Mapping>;
|
|
239
|
-
type destination_PushContext<Settings = unknown, Mapping = unknown> = PushContext<Settings, Mapping>;
|
|
300
|
+
type destination_InitFn<T extends TypesGeneric$1 = Types$2> = InitFn<T>;
|
|
301
|
+
type destination_PushBatchContext<T extends TypesGeneric$1 = Types$2> = PushBatchContext<T>;
|
|
302
|
+
type destination_PushBatchFn<T extends TypesGeneric$1 = Types$2> = PushBatchFn<T>;
|
|
303
|
+
type destination_PushContext<T extends TypesGeneric$1 = Types$2> = PushContext<T>;
|
|
240
304
|
type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
241
305
|
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
242
|
-
type destination_PushFn<
|
|
306
|
+
type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
|
|
243
307
|
type destination_Ref = Ref;
|
|
244
308
|
declare namespace destination {
|
|
245
|
-
export type { 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 };
|
|
246
310
|
}
|
|
247
311
|
|
|
248
312
|
interface EventFn<R = Promise<PushResult>> {
|
|
@@ -255,9 +319,9 @@ interface Fn$1<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, Wa
|
|
|
255
319
|
interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
|
|
256
320
|
(event: 'walker config', config: Partial<Config>): R;
|
|
257
321
|
(event: 'walker consent', consent: Consent): R;
|
|
258
|
-
<
|
|
322
|
+
<T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$1<T>, config?: Config$4<T>): R;
|
|
259
323
|
<K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
|
|
260
|
-
(event: 'walker on', type: Types, rules: SingleOrArray<Options>): R;
|
|
324
|
+
(event: 'walker on', type: Types$1, rules: SingleOrArray<Options>): R;
|
|
261
325
|
(event: 'walker user', user: User): R;
|
|
262
326
|
(event: 'walker run', runState: {
|
|
263
327
|
consent?: Consent;
|
|
@@ -287,15 +351,15 @@ declare namespace elb {
|
|
|
287
351
|
* Flow configuration interface for dynamic walkerOS setup
|
|
288
352
|
* Used by bundlers and other tools to configure walkerOS dynamically
|
|
289
353
|
*/
|
|
290
|
-
interface Config$
|
|
354
|
+
interface Config$3 {
|
|
291
355
|
/** Collector configuration - uses existing Collector.Config from core */
|
|
292
|
-
collector: Config$
|
|
356
|
+
collector: Config$5;
|
|
293
357
|
/** NPM packages required for this configuration */
|
|
294
358
|
packages: Record<string, string>;
|
|
295
359
|
}
|
|
296
360
|
|
|
297
361
|
declare namespace flow {
|
|
298
|
-
export type { Config$
|
|
362
|
+
export type { Config$3 as Config };
|
|
299
363
|
}
|
|
300
364
|
|
|
301
365
|
type Error = (error: unknown, state?: unknown) => void;
|
|
@@ -323,6 +387,19 @@ declare namespace hooks {
|
|
|
323
387
|
export type { AnyFunction$1 as AnyFunction, hooks_Functions as Functions, hooks_HookFn as HookFn };
|
|
324
388
|
}
|
|
325
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
|
+
}
|
|
326
403
|
interface Rules<T = Rule> {
|
|
327
404
|
[entity: string]: Record<string, T | Array<T>> | undefined;
|
|
328
405
|
}
|
|
@@ -336,6 +413,7 @@ interface Rule<Settings = unknown> {
|
|
|
336
413
|
data?: Data;
|
|
337
414
|
ignore?: boolean;
|
|
338
415
|
name?: string;
|
|
416
|
+
policy?: Policy;
|
|
339
417
|
}
|
|
340
418
|
interface Result {
|
|
341
419
|
eventMapping?: Rule;
|
|
@@ -374,6 +452,7 @@ type mapping_Data = Data;
|
|
|
374
452
|
type mapping_Fn = Fn;
|
|
375
453
|
type mapping_Loop = Loop;
|
|
376
454
|
type mapping_Map = Map;
|
|
455
|
+
type mapping_Policy = Policy;
|
|
377
456
|
type mapping_Result = Result;
|
|
378
457
|
type mapping_Rule<Settings = unknown> = Rule<Settings>;
|
|
379
458
|
type mapping_Rules<T = Rule> = Rules<T>;
|
|
@@ -383,7 +462,7 @@ type mapping_ValueConfig = ValueConfig;
|
|
|
383
462
|
type mapping_ValueType = ValueType;
|
|
384
463
|
type mapping_Values = Values;
|
|
385
464
|
declare namespace mapping {
|
|
386
|
-
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 };
|
|
387
466
|
}
|
|
388
467
|
|
|
389
468
|
type Config$1 = {
|
|
@@ -392,7 +471,19 @@ type Config$1 = {
|
|
|
392
471
|
run?: Array<RunConfig>;
|
|
393
472
|
session?: Array<SessionConfig>;
|
|
394
473
|
};
|
|
395
|
-
type Types = keyof Config$1;
|
|
474
|
+
type Types$1 = keyof Config$1;
|
|
475
|
+
interface EventContextMap {
|
|
476
|
+
consent: Consent;
|
|
477
|
+
session: SessionData;
|
|
478
|
+
ready: undefined;
|
|
479
|
+
run: undefined;
|
|
480
|
+
}
|
|
481
|
+
type EventContext<T extends Types$1> = EventContextMap[T];
|
|
482
|
+
type AnyEventContext = EventContextMap[keyof EventContextMap];
|
|
483
|
+
interface Context$1 {
|
|
484
|
+
consent?: Consent;
|
|
485
|
+
session?: unknown;
|
|
486
|
+
}
|
|
396
487
|
type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
|
|
397
488
|
interface ConsentConfig {
|
|
398
489
|
[key: string]: ConsentFn;
|
|
@@ -411,10 +502,17 @@ interface OnConfig {
|
|
|
411
502
|
session?: SessionConfig[];
|
|
412
503
|
[key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
|
|
413
504
|
}
|
|
505
|
+
type OnFn = <T extends Types$1>(event: T, context: EventContextMap[T]) => PromiseOrValue<void>;
|
|
506
|
+
type OnFnRuntime = (event: Types$1, context: AnyEventContext) => PromiseOrValue<void>;
|
|
414
507
|
|
|
508
|
+
type on_AnyEventContext = AnyEventContext;
|
|
415
509
|
type on_ConsentConfig = ConsentConfig;
|
|
416
510
|
type on_ConsentFn = ConsentFn;
|
|
511
|
+
type on_EventContext<T extends Types$1> = EventContext<T>;
|
|
512
|
+
type on_EventContextMap = EventContextMap;
|
|
417
513
|
type on_OnConfig = OnConfig;
|
|
514
|
+
type on_OnFn = OnFn;
|
|
515
|
+
type on_OnFnRuntime = OnFnRuntime;
|
|
418
516
|
type on_Options = Options;
|
|
419
517
|
type on_ReadyConfig = ReadyConfig;
|
|
420
518
|
type on_ReadyFn = ReadyFn;
|
|
@@ -422,9 +520,8 @@ type on_RunConfig = RunConfig;
|
|
|
422
520
|
type on_RunFn = RunFn;
|
|
423
521
|
type on_SessionConfig = SessionConfig;
|
|
424
522
|
type on_SessionFn = SessionFn;
|
|
425
|
-
type on_Types = Types;
|
|
426
523
|
declare namespace on {
|
|
427
|
-
export type { Config$1 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, on_OnConfig as OnConfig, on_Options as Options, on_ReadyConfig as ReadyConfig, on_ReadyFn as ReadyFn, on_RunConfig as RunConfig, on_RunFn as RunFn, on_SessionConfig as SessionConfig, on_SessionFn as SessionFn,
|
|
524
|
+
export type { on_AnyEventContext as AnyEventContext, Config$1 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, Context$1 as Context, on_EventContext as EventContext, on_EventContextMap as EventContextMap, on_OnConfig as OnConfig, on_OnFn as OnFn, on_OnFnRuntime as OnFnRuntime, on_Options as Options, on_ReadyConfig as ReadyConfig, on_ReadyFn as ReadyFn, on_RunConfig as RunConfig, on_RunFn as RunFn, on_SessionConfig as SessionConfig, on_SessionFn as SessionFn, Types$1 as Types };
|
|
428
525
|
}
|
|
429
526
|
|
|
430
527
|
interface Context {
|
|
@@ -473,55 +570,76 @@ declare namespace schema {
|
|
|
473
570
|
export type { schema_Contract as Contract, schema_Contracts as Contracts, Properties$1 as Properties, Property$1 as Property };
|
|
474
571
|
}
|
|
475
572
|
|
|
476
|
-
interface Config {
|
|
477
|
-
id?: string;
|
|
478
|
-
disabled?: boolean;
|
|
479
|
-
settings: AnyObject;
|
|
480
|
-
onError?: AnyFunction;
|
|
481
|
-
}
|
|
482
|
-
type InitConfig = Partial<Config>;
|
|
483
573
|
/**
|
|
484
|
-
*
|
|
574
|
+
* Base Env interface for dependency injection into sources.
|
|
485
575
|
*
|
|
486
576
|
* Sources receive all their dependencies through this environment object,
|
|
487
577
|
* making them platform-agnostic and easily testable.
|
|
488
578
|
*/
|
|
489
|
-
interface
|
|
490
|
-
elb: Fn$1;
|
|
579
|
+
interface BaseEnv {
|
|
491
580
|
[key: string]: unknown;
|
|
581
|
+
push: PushFn$1;
|
|
582
|
+
command: CommandFn;
|
|
583
|
+
sources?: Sources;
|
|
584
|
+
elb: Fn$1;
|
|
492
585
|
}
|
|
493
586
|
/**
|
|
494
|
-
*
|
|
587
|
+
* Type bundle for source generics.
|
|
588
|
+
* Groups Settings, Mapping, Push, and Env into a single type parameter.
|
|
495
589
|
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
590
|
+
* @template S - Settings configuration type
|
|
591
|
+
* @template M - Mapping configuration type
|
|
592
|
+
* @template P - Push function signature (flexible to support HTTP handlers, etc.)
|
|
593
|
+
* @template E - Environment dependencies type
|
|
498
594
|
*/
|
|
499
|
-
interface
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
push:
|
|
503
|
-
|
|
504
|
-
on?(event: Types, context?: unknown): void | Promise<void>;
|
|
595
|
+
interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> {
|
|
596
|
+
settings: S;
|
|
597
|
+
mapping: M;
|
|
598
|
+
push: P;
|
|
599
|
+
env: E;
|
|
505
600
|
}
|
|
506
601
|
/**
|
|
507
|
-
*
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
602
|
+
* Generic constraint for Types - ensures T has required properties for indexed access
|
|
603
|
+
*/
|
|
604
|
+
type TypesGeneric = {
|
|
605
|
+
settings: any;
|
|
606
|
+
mapping: any;
|
|
607
|
+
push: any;
|
|
608
|
+
env: any;
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* Type extractors for consistent usage with Types bundle
|
|
515
612
|
*/
|
|
516
|
-
type
|
|
613
|
+
type Settings<T extends TypesGeneric = Types> = T['settings'];
|
|
614
|
+
type Mapping<T extends TypesGeneric = Types> = T['mapping'];
|
|
615
|
+
type Push<T extends TypesGeneric = Types> = T['push'];
|
|
616
|
+
type Env<T extends TypesGeneric = Types> = T['env'];
|
|
517
617
|
/**
|
|
518
|
-
*
|
|
519
|
-
* Similar to destinations, this defines the structure for source definitions.
|
|
618
|
+
* Inference helper: Extract Types from Instance
|
|
520
619
|
*/
|
|
521
|
-
type
|
|
620
|
+
type TypesOf<I> = I extends Instance<infer T> ? T : never;
|
|
621
|
+
interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
|
|
622
|
+
settings?: Settings<T>;
|
|
623
|
+
env?: Env<T>;
|
|
624
|
+
id?: string;
|
|
625
|
+
onError?: Error;
|
|
626
|
+
disabled?: boolean;
|
|
627
|
+
primary?: boolean;
|
|
628
|
+
}
|
|
629
|
+
type PartialConfig<T extends TypesGeneric = Types> = Config<Types<Partial<Settings<T>> | Settings<T>, Partial<Mapping<T>> | Mapping<T>, Push<T>, Env<T>>>;
|
|
630
|
+
interface Instance<T extends TypesGeneric = Types> {
|
|
631
|
+
type: string;
|
|
632
|
+
config: Config<T>;
|
|
633
|
+
push: Push<T>;
|
|
634
|
+
destroy?(): void | Promise<void>;
|
|
635
|
+
on?(event: Types$1, context?: unknown): void | Promise<void>;
|
|
636
|
+
}
|
|
637
|
+
type Init<T extends TypesGeneric = Types> = (config: Partial<Config<T>>, env: Env<T>) => Instance<T> | Promise<Instance<T>>;
|
|
638
|
+
type InitSource<T extends TypesGeneric = Types> = {
|
|
522
639
|
code: Init<T>;
|
|
523
|
-
config?: T
|
|
524
|
-
env?: Partial<
|
|
640
|
+
config?: Partial<Config<T>>;
|
|
641
|
+
env?: Partial<Env<T>>;
|
|
642
|
+
primary?: boolean;
|
|
525
643
|
};
|
|
526
644
|
/**
|
|
527
645
|
* Sources configuration for collector.
|
|
@@ -531,15 +649,22 @@ interface InitSources {
|
|
|
531
649
|
[sourceId: string]: InitSource<any>;
|
|
532
650
|
}
|
|
533
651
|
|
|
534
|
-
type
|
|
535
|
-
type
|
|
536
|
-
type
|
|
537
|
-
type
|
|
538
|
-
type source_InitSource<T extends
|
|
652
|
+
type source_BaseEnv = BaseEnv;
|
|
653
|
+
type source_Config<T extends TypesGeneric = Types> = Config<T>;
|
|
654
|
+
type source_Env<T extends TypesGeneric = Types> = Env<T>;
|
|
655
|
+
type source_Init<T extends TypesGeneric = Types> = Init<T>;
|
|
656
|
+
type source_InitSource<T extends TypesGeneric = Types> = InitSource<T>;
|
|
539
657
|
type source_InitSources = InitSources;
|
|
540
|
-
type source_Instance<T extends
|
|
658
|
+
type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
|
|
659
|
+
type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
|
|
660
|
+
type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
|
|
661
|
+
type source_Push<T extends TypesGeneric = Types> = Push<T>;
|
|
662
|
+
type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
|
|
663
|
+
type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> = Types<S, M, P, E>;
|
|
664
|
+
type source_TypesGeneric = TypesGeneric;
|
|
665
|
+
type source_TypesOf<I> = TypesOf<I>;
|
|
541
666
|
declare namespace source {
|
|
542
|
-
export type {
|
|
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 };
|
|
543
668
|
}
|
|
544
669
|
|
|
545
670
|
type AnyObject<T = unknown> = Record<string, T>;
|
|
@@ -668,6 +793,210 @@ declare const Const: {
|
|
|
668
793
|
};
|
|
669
794
|
};
|
|
670
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
|
+
|
|
671
1000
|
/**
|
|
672
1001
|
* Anonymizes an IPv4 address by setting the last octet to 0.
|
|
673
1002
|
*
|
|
@@ -715,12 +1044,12 @@ declare function getByPath(event: unknown, key?: string, defaultValue?: unknown)
|
|
|
715
1044
|
/**
|
|
716
1045
|
* Sets a value in an object by a dot-notation string.
|
|
717
1046
|
*
|
|
718
|
-
* @param
|
|
1047
|
+
* @param obj - The object to set the value in.
|
|
719
1048
|
* @param key - The dot-notation string.
|
|
720
1049
|
* @param value - The value to set.
|
|
721
1050
|
* @returns A new object with the updated value.
|
|
722
1051
|
*/
|
|
723
|
-
declare function setByPath(
|
|
1052
|
+
declare function setByPath<T = unknown>(obj: T, key: string, value: unknown): T;
|
|
724
1053
|
|
|
725
1054
|
/**
|
|
726
1055
|
* Casts a value to a specific type.
|
|
@@ -758,26 +1087,19 @@ declare function getGrantedConsent(required: Consent | undefined, state?: Consen
|
|
|
758
1087
|
* This utility enables elegant destination configuration while avoiding config side-effects
|
|
759
1088
|
* that could occur when reusing destination objects across multiple collector instances.
|
|
760
1089
|
*
|
|
761
|
-
* @template Settings - The destination settings type
|
|
762
|
-
* @template Mapping - The destination mapping type
|
|
763
1090
|
* @param baseDestination - The base destination to extend
|
|
764
1091
|
* @param config - Additional configuration to merge with the base destination's config
|
|
765
1092
|
* @returns A new destination instance with merged configuration
|
|
766
1093
|
*
|
|
767
1094
|
* @example
|
|
768
1095
|
* ```typescript
|
|
769
|
-
* //
|
|
770
|
-
* elb('walker destination', destinationGtag, {
|
|
771
|
-
* settings: { ga4: { measurementId: 'G-123' } }
|
|
772
|
-
* });
|
|
773
|
-
*
|
|
774
|
-
* // You can use:
|
|
1096
|
+
* // Types are inferred automatically from destinationGtag
|
|
775
1097
|
* elb('walker destination', createDestination(destinationGtag, {
|
|
776
1098
|
* settings: { ga4: { measurementId: 'G-123' } }
|
|
777
1099
|
* }));
|
|
778
1100
|
* ```
|
|
779
1101
|
*/
|
|
780
|
-
declare function createDestination<
|
|
1102
|
+
declare function createDestination<I extends Instance$1>(baseDestination: I, config: Partial<Config$4<TypesOf$1<I>>>): I;
|
|
781
1103
|
|
|
782
1104
|
/**
|
|
783
1105
|
* Creates a complete event with default values.
|
|
@@ -914,11 +1236,11 @@ declare function isString(value: unknown): value is string;
|
|
|
914
1236
|
/**
|
|
915
1237
|
* Gets the mapping for an event.
|
|
916
1238
|
*
|
|
917
|
-
* @param event The event to get the mapping for.
|
|
1239
|
+
* @param event The event to get the mapping for (can be partial or full).
|
|
918
1240
|
* @param mapping The mapping rules.
|
|
919
1241
|
* @returns The mapping result.
|
|
920
1242
|
*/
|
|
921
|
-
declare function getMappingEvent(event: PartialEvent, mapping?: Rules): Promise<Result>;
|
|
1243
|
+
declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules): Promise<Result>;
|
|
922
1244
|
/**
|
|
923
1245
|
* Gets a value from a mapping.
|
|
924
1246
|
*
|
|
@@ -928,6 +1250,98 @@ declare function getMappingEvent(event: PartialEvent, mapping?: Rules): Promise<
|
|
|
928
1250
|
* @returns The mapped value.
|
|
929
1251
|
*/
|
|
930
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
|
+
}>;
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Environment mocking utilities for walkerOS destinations
|
|
1282
|
+
*
|
|
1283
|
+
* Provides standardized tools for intercepting function calls in environment objects,
|
|
1284
|
+
* enabling consistent testing patterns across all destinations.
|
|
1285
|
+
*/
|
|
1286
|
+
type InterceptorFn = (path: string[], args: unknown[], original?: Function) => unknown;
|
|
1287
|
+
/**
|
|
1288
|
+
* Creates a proxied environment that intercepts function calls
|
|
1289
|
+
*
|
|
1290
|
+
* Uses Proxy to wrap environment objects and capture all function calls,
|
|
1291
|
+
* allowing for call recording, mocking, or simulation.
|
|
1292
|
+
*
|
|
1293
|
+
* @param env - The environment object to wrap
|
|
1294
|
+
* @param interceptor - Function called for each intercepted call
|
|
1295
|
+
* @returns Proxied environment with interceptor applied
|
|
1296
|
+
*
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* const calls: Array<{ path: string[]; args: unknown[] }> = [];
|
|
1300
|
+
*
|
|
1301
|
+
* const testEnv = mockEnv(env.push, (path, args) => {
|
|
1302
|
+
* calls.push({ path, args });
|
|
1303
|
+
* });
|
|
1304
|
+
*
|
|
1305
|
+
* // Use testEnv with destination
|
|
1306
|
+
* await destination.push(event, { env: testEnv });
|
|
1307
|
+
*
|
|
1308
|
+
* // Analyze captured calls
|
|
1309
|
+
* expect(calls).toContainEqual({
|
|
1310
|
+
* path: ['window', 'gtag'],
|
|
1311
|
+
* args: ['event', 'purchase', { value: 99.99 }]
|
|
1312
|
+
* });
|
|
1313
|
+
* ```
|
|
1314
|
+
*/
|
|
1315
|
+
declare function mockEnv<T extends object>(env: T, interceptor: InterceptorFn): T;
|
|
1316
|
+
/**
|
|
1317
|
+
* Traverses environment object and replaces values using a replacer function
|
|
1318
|
+
*
|
|
1319
|
+
* Alternative to mockEnv for environments where Proxy is not suitable.
|
|
1320
|
+
* Performs deep traversal and allows value transformation at each level.
|
|
1321
|
+
*
|
|
1322
|
+
* @param env - The environment object to traverse
|
|
1323
|
+
* @param replacer - Function to transform values during traversal
|
|
1324
|
+
* @returns New environment object with transformed values
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```typescript
|
|
1328
|
+
* const recordedCalls: APICall[] = [];
|
|
1329
|
+
*
|
|
1330
|
+
* const recordingEnv = traverseEnv(originalEnv, (value, path) => {
|
|
1331
|
+
* if (typeof value === 'function') {
|
|
1332
|
+
* return (...args: unknown[]) => {
|
|
1333
|
+
* recordedCalls.push({
|
|
1334
|
+
* path: path.join('.'),
|
|
1335
|
+
* args: structuredClone(args)
|
|
1336
|
+
* });
|
|
1337
|
+
* return value(...args);
|
|
1338
|
+
* };
|
|
1339
|
+
* }
|
|
1340
|
+
* return value;
|
|
1341
|
+
* });
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
declare function traverseEnv<T extends object>(env: T, replacer: (value: unknown, path: string[]) => unknown): T;
|
|
931
1345
|
|
|
932
1346
|
/**
|
|
933
1347
|
* Logs a message to the console if verbose logging is enabled.
|
|
@@ -974,15 +1388,6 @@ declare function requestToData(parameter: unknown): AnyObject | undefined;
|
|
|
974
1388
|
*/
|
|
975
1389
|
declare function requestToParameter(data: AnyObject | PropertyType): string;
|
|
976
1390
|
|
|
977
|
-
type SendDataValue = Property | Properties;
|
|
978
|
-
type SendHeaders = {
|
|
979
|
-
[key: string]: string;
|
|
980
|
-
};
|
|
981
|
-
interface SendResponse {
|
|
982
|
-
ok: boolean;
|
|
983
|
-
data?: unknown;
|
|
984
|
-
error?: string;
|
|
985
|
-
}
|
|
986
1391
|
/**
|
|
987
1392
|
* Transforms data to a string.
|
|
988
1393
|
*
|
|
@@ -1109,4 +1514,4 @@ declare function validateEvent(obj: unknown, customContracts?: Contracts): Event
|
|
|
1109
1514
|
*/
|
|
1110
1515
|
declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
|
|
1111
1516
|
|
|
1112
|
-
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, onLog, parseUserAgent, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, 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 };
|