@walkeros/explorer 0.3.1 → 0.5.0
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/AGENT.md +381 -0
- package/STYLE.md +993 -0
- package/dist/chunk-WKBCYMTQ.mjs +2650 -0
- package/dist/chunk-WKBCYMTQ.mjs.map +1 -0
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +3280 -630
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1206 -619
- package/dist/index.mjs.map +1 -1
- package/dist/{monaco-types-GBPMPIMU.mjs → monaco-types-GHUJ2SZE.mjs} +2 -2
- package/dist/styles.css +70 -0
- package/package.json +41 -28
- package/dist/chunk-BEAIHYJ5.mjs +0 -587
- package/dist/chunk-BEAIHYJ5.mjs.map +0 -1
- /package/dist/{monaco-types-GBPMPIMU.mjs.map → monaco-types-GHUJ2SZE.mjs.map} +0 -0
|
@@ -0,0 +1,2650 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
// src/utils/monaco-context-types.ts
|
|
4
|
+
var FN_CONTEXT_TYPES = `
|
|
5
|
+
// WalkerOS Core Types
|
|
6
|
+
declare namespace WalkerOS {
|
|
7
|
+
// Utility types
|
|
8
|
+
type DeepPartial<T> = {
|
|
9
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type PromiseOrValue<T> = T | Promise<T>;
|
|
13
|
+
|
|
14
|
+
// Property types
|
|
15
|
+
type PropertyType = boolean | string | number | {
|
|
16
|
+
[key: string]: Property;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type Property = PropertyType | Array<PropertyType>;
|
|
20
|
+
|
|
21
|
+
interface Properties {
|
|
22
|
+
[key: string]: Property | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface OrderedProperties {
|
|
26
|
+
[key: string]: [Property, number] | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Consent
|
|
30
|
+
interface Consent {
|
|
31
|
+
[name: string]: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// User
|
|
35
|
+
interface User extends Properties {
|
|
36
|
+
id?: string;
|
|
37
|
+
device?: string;
|
|
38
|
+
session?: string;
|
|
39
|
+
hash?: string;
|
|
40
|
+
address?: string;
|
|
41
|
+
email?: string;
|
|
42
|
+
phone?: string;
|
|
43
|
+
userAgent?: string;
|
|
44
|
+
browser?: string;
|
|
45
|
+
browserVersion?: string;
|
|
46
|
+
deviceType?: string;
|
|
47
|
+
language?: string;
|
|
48
|
+
country?: string;
|
|
49
|
+
region?: string;
|
|
50
|
+
city?: string;
|
|
51
|
+
zip?: string;
|
|
52
|
+
timezone?: string;
|
|
53
|
+
os?: string;
|
|
54
|
+
osVersion?: string;
|
|
55
|
+
screenSize?: string;
|
|
56
|
+
ip?: string;
|
|
57
|
+
internal?: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Version
|
|
61
|
+
interface Version extends Properties {
|
|
62
|
+
source: string;
|
|
63
|
+
tagging: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Source
|
|
67
|
+
type SourceType = 'web' | 'server' | 'app' | 'other' | string;
|
|
68
|
+
|
|
69
|
+
interface Source extends Properties {
|
|
70
|
+
type: SourceType;
|
|
71
|
+
id: string;
|
|
72
|
+
previous_id: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Entity
|
|
76
|
+
type Entities = Array<Entity>;
|
|
77
|
+
|
|
78
|
+
interface Entity {
|
|
79
|
+
entity: string;
|
|
80
|
+
data: Properties;
|
|
81
|
+
nested: Entities;
|
|
82
|
+
context: OrderedProperties;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Event
|
|
86
|
+
interface Event {
|
|
87
|
+
name: string;
|
|
88
|
+
data: Properties;
|
|
89
|
+
context: OrderedProperties;
|
|
90
|
+
globals: Properties;
|
|
91
|
+
custom: Properties;
|
|
92
|
+
user: User;
|
|
93
|
+
nested: Entities;
|
|
94
|
+
consent: Consent;
|
|
95
|
+
id: string;
|
|
96
|
+
trigger: string;
|
|
97
|
+
entity: string;
|
|
98
|
+
action: string;
|
|
99
|
+
timestamp: number;
|
|
100
|
+
timing: number;
|
|
101
|
+
group: string;
|
|
102
|
+
count: number;
|
|
103
|
+
version: Version;
|
|
104
|
+
source: Source;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type DeepPartialEvent = DeepPartial<Event>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Mapping Types
|
|
111
|
+
declare namespace Mapping {
|
|
112
|
+
type ValueType = string | ValueConfig;
|
|
113
|
+
type Value = ValueType | Array<ValueType>;
|
|
114
|
+
type Values = Array<Value>;
|
|
115
|
+
|
|
116
|
+
interface ValueConfig {
|
|
117
|
+
condition?: Condition;
|
|
118
|
+
consent?: WalkerOS.Consent;
|
|
119
|
+
fn?: Fn;
|
|
120
|
+
key?: string;
|
|
121
|
+
loop?: Loop;
|
|
122
|
+
map?: Map;
|
|
123
|
+
set?: Value[];
|
|
124
|
+
validate?: Validate;
|
|
125
|
+
value?: WalkerOS.PropertyType;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type Loop = [Value, Value];
|
|
129
|
+
|
|
130
|
+
type Map = {
|
|
131
|
+
[key: string]: Value;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
interface Options {
|
|
135
|
+
consent?: WalkerOS.Consent;
|
|
136
|
+
collector?: Collector.Instance;
|
|
137
|
+
props?: unknown;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type Condition = (
|
|
141
|
+
value: WalkerOS.DeepPartialEvent | unknown,
|
|
142
|
+
mapping?: Value,
|
|
143
|
+
collector?: Collector.Instance
|
|
144
|
+
) => WalkerOS.PromiseOrValue<boolean>;
|
|
145
|
+
|
|
146
|
+
type Fn = (
|
|
147
|
+
value: WalkerOS.DeepPartialEvent | unknown,
|
|
148
|
+
mapping: Value,
|
|
149
|
+
options: Options
|
|
150
|
+
) => WalkerOS.PromiseOrValue<WalkerOS.Property | unknown>;
|
|
151
|
+
|
|
152
|
+
type Validate = (value?: unknown) => WalkerOS.PromiseOrValue<boolean>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Collector Types (minimal for fn context)
|
|
156
|
+
declare namespace Collector {
|
|
157
|
+
interface Instance {
|
|
158
|
+
push: any;
|
|
159
|
+
command: any;
|
|
160
|
+
allowed: boolean;
|
|
161
|
+
config: any;
|
|
162
|
+
consent: WalkerOS.Consent;
|
|
163
|
+
count: number;
|
|
164
|
+
custom: WalkerOS.Properties;
|
|
165
|
+
globals: WalkerOS.Properties;
|
|
166
|
+
group: string;
|
|
167
|
+
queue: any[];
|
|
168
|
+
round: number;
|
|
169
|
+
session: any;
|
|
170
|
+
timing: number;
|
|
171
|
+
user: WalkerOS.User;
|
|
172
|
+
version: string;
|
|
173
|
+
[key: string]: any;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Parameter declarations for fn context
|
|
178
|
+
declare const value: WalkerOS.DeepPartialEvent | unknown;
|
|
179
|
+
declare const mapping: Mapping.Value;
|
|
180
|
+
declare const options: Mapping.Options;
|
|
181
|
+
`;
|
|
182
|
+
var CONDITION_CONTEXT_TYPES = `
|
|
183
|
+
// WalkerOS Core Types
|
|
184
|
+
declare namespace WalkerOS {
|
|
185
|
+
// Utility types
|
|
186
|
+
type DeepPartial<T> = {
|
|
187
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
type PromiseOrValue<T> = T | Promise<T>;
|
|
191
|
+
|
|
192
|
+
// Property types
|
|
193
|
+
type PropertyType = boolean | string | number | {
|
|
194
|
+
[key: string]: Property;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
type Property = PropertyType | Array<PropertyType>;
|
|
198
|
+
|
|
199
|
+
interface Properties {
|
|
200
|
+
[key: string]: Property | undefined;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface OrderedProperties {
|
|
204
|
+
[key: string]: [Property, number] | undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Consent
|
|
208
|
+
interface Consent {
|
|
209
|
+
[name: string]: boolean;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// User
|
|
213
|
+
interface User extends Properties {
|
|
214
|
+
id?: string;
|
|
215
|
+
device?: string;
|
|
216
|
+
session?: string;
|
|
217
|
+
hash?: string;
|
|
218
|
+
address?: string;
|
|
219
|
+
email?: string;
|
|
220
|
+
phone?: string;
|
|
221
|
+
userAgent?: string;
|
|
222
|
+
browser?: string;
|
|
223
|
+
browserVersion?: string;
|
|
224
|
+
deviceType?: string;
|
|
225
|
+
language?: string;
|
|
226
|
+
country?: string;
|
|
227
|
+
region?: string;
|
|
228
|
+
city?: string;
|
|
229
|
+
zip?: string;
|
|
230
|
+
timezone?: string;
|
|
231
|
+
os?: string;
|
|
232
|
+
osVersion?: string;
|
|
233
|
+
screenSize?: string;
|
|
234
|
+
ip?: string;
|
|
235
|
+
internal?: boolean;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Version
|
|
239
|
+
interface Version extends Properties {
|
|
240
|
+
source: string;
|
|
241
|
+
tagging: number;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Source
|
|
245
|
+
type SourceType = 'web' | 'server' | 'app' | 'other' | string;
|
|
246
|
+
|
|
247
|
+
interface Source extends Properties {
|
|
248
|
+
type: SourceType;
|
|
249
|
+
id: string;
|
|
250
|
+
previous_id: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Entity
|
|
254
|
+
type Entities = Array<Entity>;
|
|
255
|
+
|
|
256
|
+
interface Entity {
|
|
257
|
+
entity: string;
|
|
258
|
+
data: Properties;
|
|
259
|
+
nested: Entities;
|
|
260
|
+
context: OrderedProperties;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Event
|
|
264
|
+
interface Event {
|
|
265
|
+
name: string;
|
|
266
|
+
data: Properties;
|
|
267
|
+
context: OrderedProperties;
|
|
268
|
+
globals: Properties;
|
|
269
|
+
custom: Properties;
|
|
270
|
+
user: User;
|
|
271
|
+
nested: Entities;
|
|
272
|
+
consent: Consent;
|
|
273
|
+
id: string;
|
|
274
|
+
trigger: string;
|
|
275
|
+
entity: string;
|
|
276
|
+
action: string;
|
|
277
|
+
timestamp: number;
|
|
278
|
+
timing: number;
|
|
279
|
+
group: string;
|
|
280
|
+
count: number;
|
|
281
|
+
version: Version;
|
|
282
|
+
source: Source;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
type DeepPartialEvent = DeepPartial<Event>;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Mapping Types
|
|
289
|
+
declare namespace Mapping {
|
|
290
|
+
type ValueType = string | ValueConfig;
|
|
291
|
+
type Value = ValueType | Array<ValueType>;
|
|
292
|
+
|
|
293
|
+
interface ValueConfig {
|
|
294
|
+
condition?: Condition;
|
|
295
|
+
consent?: WalkerOS.Consent;
|
|
296
|
+
fn?: Fn;
|
|
297
|
+
key?: string;
|
|
298
|
+
loop?: Loop;
|
|
299
|
+
map?: Map;
|
|
300
|
+
set?: Value[];
|
|
301
|
+
validate?: Validate;
|
|
302
|
+
value?: WalkerOS.PropertyType;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
type Loop = [Value, Value];
|
|
306
|
+
|
|
307
|
+
type Map = {
|
|
308
|
+
[key: string]: Value;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
type Condition = (
|
|
312
|
+
value: WalkerOS.DeepPartialEvent | unknown,
|
|
313
|
+
mapping?: Value,
|
|
314
|
+
collector?: Collector.Instance
|
|
315
|
+
) => WalkerOS.PromiseOrValue<boolean>;
|
|
316
|
+
|
|
317
|
+
type Fn = (
|
|
318
|
+
value: WalkerOS.DeepPartialEvent | unknown,
|
|
319
|
+
mapping: Value,
|
|
320
|
+
options: any
|
|
321
|
+
) => WalkerOS.PromiseOrValue<WalkerOS.Property | unknown>;
|
|
322
|
+
|
|
323
|
+
type Validate = (value?: unknown) => WalkerOS.PromiseOrValue<boolean>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Collector Types (full interface for condition context)
|
|
327
|
+
declare namespace Collector {
|
|
328
|
+
interface SessionData extends WalkerOS.Properties {
|
|
329
|
+
isStart: boolean;
|
|
330
|
+
storage: boolean;
|
|
331
|
+
id?: string;
|
|
332
|
+
start?: number;
|
|
333
|
+
marketing?: true;
|
|
334
|
+
updated?: number;
|
|
335
|
+
isNew?: boolean;
|
|
336
|
+
device?: string;
|
|
337
|
+
count?: number;
|
|
338
|
+
runs?: number;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
interface Config {
|
|
342
|
+
run?: boolean;
|
|
343
|
+
tagging: number;
|
|
344
|
+
globalsStatic: WalkerOS.Properties;
|
|
345
|
+
sessionStatic: Partial<SessionData>;
|
|
346
|
+
verbose: boolean;
|
|
347
|
+
onError?: any;
|
|
348
|
+
onLog?: any;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface Instance {
|
|
352
|
+
push: any;
|
|
353
|
+
command: any;
|
|
354
|
+
allowed: boolean;
|
|
355
|
+
config: Config;
|
|
356
|
+
consent: WalkerOS.Consent;
|
|
357
|
+
count: number;
|
|
358
|
+
custom: WalkerOS.Properties;
|
|
359
|
+
sources: any;
|
|
360
|
+
destinations: any;
|
|
361
|
+
globals: WalkerOS.Properties;
|
|
362
|
+
group: string;
|
|
363
|
+
hooks: any;
|
|
364
|
+
on: any;
|
|
365
|
+
queue: any[];
|
|
366
|
+
round: number;
|
|
367
|
+
session: undefined | SessionData;
|
|
368
|
+
timing: number;
|
|
369
|
+
user: WalkerOS.User;
|
|
370
|
+
version: string;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Parameter declarations for condition context
|
|
375
|
+
declare const value: WalkerOS.DeepPartialEvent | unknown;
|
|
376
|
+
declare const mapping: Mapping.Value;
|
|
377
|
+
declare const collector: Collector.Instance | undefined;
|
|
378
|
+
`;
|
|
379
|
+
var VALIDATE_CONTEXT_TYPES = `
|
|
380
|
+
// Parameter declaration for validate context
|
|
381
|
+
declare const value: unknown;
|
|
382
|
+
`;
|
|
383
|
+
function getContextTypes(contextType) {
|
|
384
|
+
switch (contextType) {
|
|
385
|
+
case "fn":
|
|
386
|
+
return FN_CONTEXT_TYPES;
|
|
387
|
+
case "condition":
|
|
388
|
+
return CONDITION_CONTEXT_TYPES;
|
|
389
|
+
case "validate":
|
|
390
|
+
return VALIDATE_CONTEXT_TYPES;
|
|
391
|
+
default:
|
|
392
|
+
return "";
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// walkeros-types:virtual:walkeros-core-types
|
|
397
|
+
var virtual_walkeros_core_types_default = `/**
|
|
398
|
+
* Core collector configuration interface
|
|
399
|
+
*/
|
|
400
|
+
interface Config$6 {
|
|
401
|
+
/** Whether to run collector automatically */
|
|
402
|
+
run?: boolean;
|
|
403
|
+
/** Version for event tagging */
|
|
404
|
+
tagging: number;
|
|
405
|
+
/** Static global properties even on a new run */
|
|
406
|
+
globalsStatic: Properties;
|
|
407
|
+
/** Static session data even on a new run */
|
|
408
|
+
sessionStatic: Partial<SessionData>;
|
|
409
|
+
/** Logger configuration */
|
|
410
|
+
logger?: Config$3;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Initialization configuration that extends Config with initial state
|
|
414
|
+
*/
|
|
415
|
+
interface InitConfig extends Partial<Config$6> {
|
|
416
|
+
/** Initial consent state */
|
|
417
|
+
consent?: Consent;
|
|
418
|
+
/** Initial user data */
|
|
419
|
+
user?: User;
|
|
420
|
+
/** Initial global properties */
|
|
421
|
+
globals?: Properties;
|
|
422
|
+
/** Source configurations */
|
|
423
|
+
sources?: InitSources;
|
|
424
|
+
/** Destination configurations */
|
|
425
|
+
destinations?: InitDestinations;
|
|
426
|
+
/** Initial custom properties */
|
|
427
|
+
custom?: Properties;
|
|
428
|
+
}
|
|
429
|
+
interface SessionData extends Properties {
|
|
430
|
+
isStart: boolean;
|
|
431
|
+
storage: boolean;
|
|
432
|
+
id?: string;
|
|
433
|
+
start?: number;
|
|
434
|
+
marketing?: true;
|
|
435
|
+
updated?: number;
|
|
436
|
+
isNew?: boolean;
|
|
437
|
+
device?: string;
|
|
438
|
+
count?: number;
|
|
439
|
+
runs?: number;
|
|
440
|
+
}
|
|
441
|
+
interface Sources {
|
|
442
|
+
[id: string]: Instance;
|
|
443
|
+
}
|
|
444
|
+
interface Destinations$1 {
|
|
445
|
+
[id: string]: Instance$2;
|
|
446
|
+
}
|
|
447
|
+
type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' | 'elb' | 'globals' | 'hook' | 'init' | 'link' | 'run' | 'user' | 'walker' | string;
|
|
448
|
+
/**
|
|
449
|
+
* Context passed to collector.push for source mapping
|
|
450
|
+
*/
|
|
451
|
+
interface PushContext$1 {
|
|
452
|
+
mapping?: Config$2;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Push function signature - handles events only
|
|
456
|
+
*/
|
|
457
|
+
interface PushFn$1 {
|
|
458
|
+
(event: DeepPartialEvent, context?: PushContext$1): Promise<PushResult>;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Command function signature - handles walker commands only
|
|
462
|
+
*/
|
|
463
|
+
interface CommandFn {
|
|
464
|
+
(command: 'config', config: Partial<Config$6>): Promise<PushResult>;
|
|
465
|
+
(command: 'consent', consent: Consent): Promise<PushResult>;
|
|
466
|
+
<T extends Types$2>(command: 'destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): Promise<PushResult>;
|
|
467
|
+
<K extends keyof Functions>(command: 'hook', name: K, hookFn: Functions[K]): Promise<PushResult>;
|
|
468
|
+
(command: 'on', type: Types$1, rules: SingleOrArray<Options>): Promise<PushResult>;
|
|
469
|
+
(command: 'user', user: User): Promise<PushResult>;
|
|
470
|
+
(command: 'run', runState?: {
|
|
471
|
+
consent?: Consent;
|
|
472
|
+
user?: User;
|
|
473
|
+
globals?: Properties;
|
|
474
|
+
custom?: Properties;
|
|
475
|
+
}): Promise<PushResult>;
|
|
476
|
+
(command: string, data?: unknown, options?: unknown): Promise<PushResult>;
|
|
477
|
+
}
|
|
478
|
+
interface Instance$3 {
|
|
479
|
+
push: PushFn$1;
|
|
480
|
+
command: CommandFn;
|
|
481
|
+
allowed: boolean;
|
|
482
|
+
config: Config$6;
|
|
483
|
+
consent: Consent;
|
|
484
|
+
count: number;
|
|
485
|
+
custom: Properties;
|
|
486
|
+
sources: Sources;
|
|
487
|
+
destinations: Destinations$1;
|
|
488
|
+
globals: Properties;
|
|
489
|
+
group: string;
|
|
490
|
+
hooks: Functions;
|
|
491
|
+
logger: Instance$1;
|
|
492
|
+
on: OnConfig;
|
|
493
|
+
queue: Events;
|
|
494
|
+
round: number;
|
|
495
|
+
session: undefined | SessionData;
|
|
496
|
+
timing: number;
|
|
497
|
+
user: User;
|
|
498
|
+
version: string;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
type collector_CommandFn = CommandFn;
|
|
502
|
+
type collector_CommandType = CommandType;
|
|
503
|
+
type collector_InitConfig = InitConfig;
|
|
504
|
+
type collector_SessionData = SessionData;
|
|
505
|
+
type collector_Sources = Sources;
|
|
506
|
+
declare namespace collector {
|
|
507
|
+
export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$6 as Config, Destinations$1 as Destinations, collector_InitConfig as InitConfig, Instance$3 as Instance, PushContext$1 as PushContext, PushFn$1 as PushFn, collector_SessionData as SessionData, collector_Sources as Sources };
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
interface Contract$1 {
|
|
511
|
+
version: string;
|
|
512
|
+
globals: Globals;
|
|
513
|
+
context: Contexts;
|
|
514
|
+
entities: Entities$1;
|
|
515
|
+
}
|
|
516
|
+
interface Globals {
|
|
517
|
+
[name: string]: Global;
|
|
518
|
+
}
|
|
519
|
+
interface Contexts {
|
|
520
|
+
[name: string]: Context$3;
|
|
521
|
+
}
|
|
522
|
+
interface Entities$1 {
|
|
523
|
+
[name: string]: Entity$1;
|
|
524
|
+
}
|
|
525
|
+
interface Properties$2 {
|
|
526
|
+
[name: string]: Property$2;
|
|
527
|
+
}
|
|
528
|
+
interface Global extends Property$2 {
|
|
529
|
+
}
|
|
530
|
+
interface Context$3 extends Property$2 {
|
|
531
|
+
}
|
|
532
|
+
interface Entity$1 {
|
|
533
|
+
data: Properties$2;
|
|
534
|
+
actions: Actions;
|
|
535
|
+
}
|
|
536
|
+
interface Actions {
|
|
537
|
+
[name: string]: Action;
|
|
538
|
+
}
|
|
539
|
+
interface Action {
|
|
540
|
+
trigger?: Trigger;
|
|
541
|
+
}
|
|
542
|
+
type Trigger = string;
|
|
543
|
+
interface Property$2 {
|
|
544
|
+
type?: PropertyType$1;
|
|
545
|
+
required?: boolean;
|
|
546
|
+
values?: PropertyValues;
|
|
547
|
+
}
|
|
548
|
+
type PropertyType$1 = 'boolean' | 'string' | 'number';
|
|
549
|
+
type PropertyValues = Array<Property>;
|
|
550
|
+
|
|
551
|
+
type data_Action = Action;
|
|
552
|
+
type data_Actions = Actions;
|
|
553
|
+
type data_Contexts = Contexts;
|
|
554
|
+
type data_Global = Global;
|
|
555
|
+
type data_Globals = Globals;
|
|
556
|
+
type data_PropertyValues = PropertyValues;
|
|
557
|
+
type data_Trigger = Trigger;
|
|
558
|
+
declare namespace data {
|
|
559
|
+
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 };
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Base environment requirements interface for walkerOS destinations
|
|
564
|
+
*
|
|
565
|
+
* This defines the core interface that destinations can use to declare
|
|
566
|
+
* their runtime environment requirements. Platform-specific extensions
|
|
567
|
+
* should extend this interface.
|
|
568
|
+
*/
|
|
569
|
+
interface BaseEnv$1 {
|
|
570
|
+
/**
|
|
571
|
+
* Generic global properties that destinations may require
|
|
572
|
+
* Platform-specific implementations can extend this interface
|
|
573
|
+
*/
|
|
574
|
+
[key: string]: unknown;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Type bundle for destination generics.
|
|
578
|
+
* Groups Settings, InitSettings, Mapping, and Env into a single type parameter.
|
|
579
|
+
*/
|
|
580
|
+
interface Types$2<S = unknown, M = unknown, E = BaseEnv$1, I = S> {
|
|
581
|
+
settings: S;
|
|
582
|
+
initSettings: I;
|
|
583
|
+
mapping: M;
|
|
584
|
+
env: E;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Generic constraint for Types - ensures T has required properties for indexed access
|
|
588
|
+
*/
|
|
589
|
+
type TypesGeneric$1 = {
|
|
590
|
+
settings: any;
|
|
591
|
+
initSettings: any;
|
|
592
|
+
mapping: any;
|
|
593
|
+
env: any;
|
|
594
|
+
};
|
|
595
|
+
/**
|
|
596
|
+
* Type extractors for consistent usage with Types bundle
|
|
597
|
+
*/
|
|
598
|
+
type Settings$1<T extends TypesGeneric$1 = Types$2> = T['settings'];
|
|
599
|
+
type InitSettings$1<T extends TypesGeneric$1 = Types$2> = T['initSettings'];
|
|
600
|
+
type Mapping$1<T extends TypesGeneric$1 = Types$2> = T['mapping'];
|
|
601
|
+
type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
|
|
602
|
+
/**
|
|
603
|
+
* Inference helper: Extract Types from Instance
|
|
604
|
+
*/
|
|
605
|
+
type TypesOf$1<I> = I extends Instance$2<infer T> ? T : never;
|
|
606
|
+
interface Instance$2<T extends TypesGeneric$1 = Types$2> {
|
|
607
|
+
config: Config$5<T>;
|
|
608
|
+
queue?: Events;
|
|
609
|
+
dlq?: DLQ;
|
|
610
|
+
type?: string;
|
|
611
|
+
env?: Env$1<T>;
|
|
612
|
+
init?: InitFn<T>;
|
|
613
|
+
push: PushFn<T>;
|
|
614
|
+
pushBatch?: PushBatchFn<T>;
|
|
615
|
+
on?: OnFn;
|
|
616
|
+
}
|
|
617
|
+
interface Config$5<T extends TypesGeneric$1 = Types$2> {
|
|
618
|
+
consent?: Consent;
|
|
619
|
+
settings?: InitSettings$1<T>;
|
|
620
|
+
data?: Value | Values;
|
|
621
|
+
env?: Env$1<T>;
|
|
622
|
+
id?: string;
|
|
623
|
+
init?: boolean;
|
|
624
|
+
loadScript?: boolean;
|
|
625
|
+
logger?: Config$3;
|
|
626
|
+
mapping?: Rules<Rule<Mapping$1<T>>>;
|
|
627
|
+
policy?: Policy$1;
|
|
628
|
+
queue?: boolean;
|
|
629
|
+
}
|
|
630
|
+
type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$5<Types$2<Partial<Settings$1<T>> | Settings$1<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$1<T>>>;
|
|
631
|
+
interface Policy$1 {
|
|
632
|
+
[key: string]: Value;
|
|
633
|
+
}
|
|
634
|
+
type Code<T extends TypesGeneric$1 = Types$2> = Instance$2<T> | true;
|
|
635
|
+
type Init$1<T extends TypesGeneric$1 = Types$2> = {
|
|
636
|
+
code: Code<T>;
|
|
637
|
+
config?: Partial<Config$5<T>>;
|
|
638
|
+
env?: Partial<Env$1<T>>;
|
|
639
|
+
};
|
|
640
|
+
interface InitDestinations {
|
|
641
|
+
[key: string]: Init$1<any>;
|
|
642
|
+
}
|
|
643
|
+
interface Destinations {
|
|
644
|
+
[key: string]: Instance$2;
|
|
645
|
+
}
|
|
646
|
+
interface Context$2<T extends TypesGeneric$1 = Types$2> {
|
|
647
|
+
collector: Instance$3;
|
|
648
|
+
config: Config$5<T>;
|
|
649
|
+
data?: Data$1;
|
|
650
|
+
env: Env$1<T>;
|
|
651
|
+
logger: Instance$1;
|
|
652
|
+
}
|
|
653
|
+
interface InitContext<T extends TypesGeneric$1 = Types$2> {
|
|
654
|
+
collector: Instance$3;
|
|
655
|
+
config: Config$5<Types$2<Partial<Settings$1<T>>, Mapping$1<T>, Env$1<T>>>;
|
|
656
|
+
data?: Data$1;
|
|
657
|
+
env: Env$1<T>;
|
|
658
|
+
logger: Instance$1;
|
|
659
|
+
}
|
|
660
|
+
interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
661
|
+
mapping?: Rule<Mapping$1<T>>;
|
|
662
|
+
}
|
|
663
|
+
interface PushBatchContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
664
|
+
mapping?: Rule<Mapping$1<T>>;
|
|
665
|
+
}
|
|
666
|
+
type InitFn<T extends TypesGeneric$1 = Types$2> = (context: InitContext<T>) => PromiseOrValue<void | false | Config$5<T>>;
|
|
667
|
+
type PushFn<T extends TypesGeneric$1 = Types$2> = (event: Event, context: PushContext<T>) => PromiseOrValue<void>;
|
|
668
|
+
type PushBatchFn<T extends TypesGeneric$1 = Types$2> = (batch: Batch<Mapping$1<T>>, context: PushBatchContext<T>) => void;
|
|
669
|
+
type PushEvent<Mapping = unknown> = {
|
|
670
|
+
event: Event;
|
|
671
|
+
mapping?: Rule<Mapping>;
|
|
672
|
+
};
|
|
673
|
+
type PushEvents<Mapping = unknown> = Array<PushEvent<Mapping>>;
|
|
674
|
+
interface Batch<Mapping> {
|
|
675
|
+
key: string;
|
|
676
|
+
events: Events;
|
|
677
|
+
data: Array<Data$1>;
|
|
678
|
+
mapping?: Rule<Mapping>;
|
|
679
|
+
}
|
|
680
|
+
type Data$1 = Property | undefined | Array<Property | undefined>;
|
|
681
|
+
type Ref = {
|
|
682
|
+
id: string;
|
|
683
|
+
destination: Instance$2;
|
|
684
|
+
};
|
|
685
|
+
type Push$1 = {
|
|
686
|
+
queue?: Events;
|
|
687
|
+
error?: unknown;
|
|
688
|
+
};
|
|
689
|
+
type DLQ = Array<[Event, unknown]>;
|
|
690
|
+
type Result$1 = {
|
|
691
|
+
successful: Array<Ref>;
|
|
692
|
+
queued: Array<Ref>;
|
|
693
|
+
failed: Array<Ref>;
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
type destination_Batch<Mapping> = Batch<Mapping>;
|
|
697
|
+
type destination_Code<T extends TypesGeneric$1 = Types$2> = Code<T>;
|
|
698
|
+
type destination_DLQ = DLQ;
|
|
699
|
+
type destination_Destinations = Destinations;
|
|
700
|
+
type destination_InitContext<T extends TypesGeneric$1 = Types$2> = InitContext<T>;
|
|
701
|
+
type destination_InitDestinations = InitDestinations;
|
|
702
|
+
type destination_InitFn<T extends TypesGeneric$1 = Types$2> = InitFn<T>;
|
|
703
|
+
type destination_PushBatchContext<T extends TypesGeneric$1 = Types$2> = PushBatchContext<T>;
|
|
704
|
+
type destination_PushBatchFn<T extends TypesGeneric$1 = Types$2> = PushBatchFn<T>;
|
|
705
|
+
type destination_PushContext<T extends TypesGeneric$1 = Types$2> = PushContext<T>;
|
|
706
|
+
type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
707
|
+
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
708
|
+
type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
|
|
709
|
+
type destination_Ref = Ref;
|
|
710
|
+
declare namespace destination {
|
|
711
|
+
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, destination_Code as Code, Config$5 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_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$2 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 };
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
interface EventFn<R = Promise<PushResult>> {
|
|
715
|
+
(partialEvent: DeepPartialEvent): R;
|
|
716
|
+
(event: string): R;
|
|
717
|
+
(event: string, data: Properties): R;
|
|
718
|
+
}
|
|
719
|
+
interface Fn$1<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, WalkerCommands<R, Config> {
|
|
720
|
+
}
|
|
721
|
+
interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
|
|
722
|
+
(event: 'walker config', config: Partial<Config>): R;
|
|
723
|
+
(event: 'walker consent', consent: Consent): R;
|
|
724
|
+
<T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): R;
|
|
725
|
+
<K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
|
|
726
|
+
(event: 'walker on', type: Types$1, rules: SingleOrArray<Options>): R;
|
|
727
|
+
(event: 'walker user', user: User): R;
|
|
728
|
+
(event: 'walker run', runState: {
|
|
729
|
+
consent?: Consent;
|
|
730
|
+
user?: User;
|
|
731
|
+
globals?: Properties;
|
|
732
|
+
custom?: Properties;
|
|
733
|
+
}): R;
|
|
734
|
+
}
|
|
735
|
+
type Event$1<R = Promise<PushResult>> = (partialEvent: DeepPartialEvent) => R;
|
|
736
|
+
type PushData<Config = unknown> = DeepPartial<Config> | Consent | User | Properties;
|
|
737
|
+
interface PushResult extends Result$1 {
|
|
738
|
+
event?: Event;
|
|
739
|
+
ok: boolean;
|
|
740
|
+
}
|
|
741
|
+
type Layer = Array<IArguments | DeepPartialEvent | unknown[]>;
|
|
742
|
+
|
|
743
|
+
type elb_EventFn<R = Promise<PushResult>> = EventFn<R>;
|
|
744
|
+
type elb_Layer = Layer;
|
|
745
|
+
type elb_PushData<Config = unknown> = PushData<Config>;
|
|
746
|
+
type elb_PushResult = PushResult;
|
|
747
|
+
type elb_WalkerCommands<R = Promise<PushResult>, Config = unknown> = WalkerCommands<R, Config>;
|
|
748
|
+
declare namespace elb {
|
|
749
|
+
export type { Event$1 as Event, elb_EventFn as EventFn, Fn$1 as Fn, elb_Layer as Layer, elb_PushData as PushData, elb_PushResult as PushResult, elb_WalkerCommands as WalkerCommands };
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Flow Configuration System
|
|
754
|
+
*
|
|
755
|
+
* Core types for walkerOS unified configuration.
|
|
756
|
+
* Platform-agnostic, runtime-focused.
|
|
757
|
+
*
|
|
758
|
+
* The Flow system enables "one config to rule them all" - a single
|
|
759
|
+
* walkeros.config.json file that manages multiple flows
|
|
760
|
+
* (web_prod, web_stage, server_prod, etc.) with shared configuration,
|
|
761
|
+
* variables, and reusable definitions.
|
|
762
|
+
*
|
|
763
|
+
* @packageDocumentation
|
|
764
|
+
*/
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Primitive value types for variables
|
|
768
|
+
*/
|
|
769
|
+
type Primitive = string | number | boolean;
|
|
770
|
+
/**
|
|
771
|
+
* Variables record type for interpolation.
|
|
772
|
+
* Used at Setup, Config, Source, and Destination levels.
|
|
773
|
+
*/
|
|
774
|
+
type Variables = Record<string, Primitive>;
|
|
775
|
+
/**
|
|
776
|
+
* Definitions record type for reusable configurations.
|
|
777
|
+
* Used at Setup, Config, Source, and Destination levels.
|
|
778
|
+
*/
|
|
779
|
+
type Definitions = Record<string, unknown>;
|
|
780
|
+
/**
|
|
781
|
+
* Packages configuration for build.
|
|
782
|
+
*/
|
|
783
|
+
type Packages = Record<string, {
|
|
784
|
+
version?: string;
|
|
785
|
+
imports?: string[];
|
|
786
|
+
path?: string;
|
|
787
|
+
}>;
|
|
788
|
+
/**
|
|
789
|
+
* Web platform configuration.
|
|
790
|
+
*
|
|
791
|
+
* @remarks
|
|
792
|
+
* Presence of this key indicates web platform (browser-based tracking).
|
|
793
|
+
* Builds to IIFE format, ES2020 target, browser platform.
|
|
794
|
+
*/
|
|
795
|
+
interface Web {
|
|
796
|
+
/**
|
|
797
|
+
* Window property name for collector instance.
|
|
798
|
+
* @default "collector"
|
|
799
|
+
*/
|
|
800
|
+
windowCollector?: string;
|
|
801
|
+
/**
|
|
802
|
+
* Window property name for elb function.
|
|
803
|
+
* @default "elb"
|
|
804
|
+
*/
|
|
805
|
+
windowElb?: string;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Server platform configuration.
|
|
809
|
+
*
|
|
810
|
+
* @remarks
|
|
811
|
+
* Presence of this key indicates server platform (Node.js).
|
|
812
|
+
* Builds to ESM format, Node18 target, node platform.
|
|
813
|
+
* Reserved for future server-specific options.
|
|
814
|
+
*/
|
|
815
|
+
interface Server {
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Complete multi-flow configuration.
|
|
819
|
+
* Root type for walkeros.config.json files.
|
|
820
|
+
*
|
|
821
|
+
* @remarks
|
|
822
|
+
* If only one flow exists, it's auto-selected without --flow flag.
|
|
823
|
+
* Convention: use "default" as the flow name for single-flow configs.
|
|
824
|
+
*
|
|
825
|
+
* @example
|
|
826
|
+
* \`\`\`json
|
|
827
|
+
* {
|
|
828
|
+
* "version": 1,
|
|
829
|
+
* "$schema": "https://walkeros.io/schema/flow/v1.json",
|
|
830
|
+
* "variables": { "CURRENCY": "USD" },
|
|
831
|
+
* "flows": {
|
|
832
|
+
* "default": { "web": {}, ... }
|
|
833
|
+
* }
|
|
834
|
+
* }
|
|
835
|
+
* \`\`\`
|
|
836
|
+
*/
|
|
837
|
+
interface Setup {
|
|
838
|
+
/**
|
|
839
|
+
* Configuration schema version.
|
|
840
|
+
*/
|
|
841
|
+
version: 1;
|
|
842
|
+
/**
|
|
843
|
+
* JSON Schema reference for IDE validation.
|
|
844
|
+
* @example "https://walkeros.io/schema/flow/v1.json"
|
|
845
|
+
*/
|
|
846
|
+
$schema?: string;
|
|
847
|
+
/**
|
|
848
|
+
* Folders to include in the bundle output.
|
|
849
|
+
* These folders are copied to dist/ during bundle, making them available
|
|
850
|
+
* at runtime for both local and Docker execution.
|
|
851
|
+
*
|
|
852
|
+
* @remarks
|
|
853
|
+
* Use for credential files, configuration, or other runtime assets.
|
|
854
|
+
* Paths are relative to the config file location.
|
|
855
|
+
* Default: \`["./shared"]\` if the folder exists, otherwise \`[]\`.
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* \`\`\`json
|
|
859
|
+
* {
|
|
860
|
+
* "include": ["./credentials", "./config"]
|
|
861
|
+
* }
|
|
862
|
+
* \`\`\`
|
|
863
|
+
*/
|
|
864
|
+
include?: string[];
|
|
865
|
+
/**
|
|
866
|
+
* Shared variables for interpolation.
|
|
867
|
+
* Resolution: process.env > Config.variables > Setup.variables > inline default
|
|
868
|
+
* Syntax: \${VAR_NAME} or \${VAR_NAME:default}
|
|
869
|
+
*/
|
|
870
|
+
variables?: Variables;
|
|
871
|
+
/**
|
|
872
|
+
* Reusable configuration definitions.
|
|
873
|
+
* Referenced via JSON Schema $ref syntax: { "$ref": "#/definitions/name" }
|
|
874
|
+
*/
|
|
875
|
+
definitions?: Definitions;
|
|
876
|
+
/**
|
|
877
|
+
* Named flow configurations.
|
|
878
|
+
* If only one flow exists, it's auto-selected.
|
|
879
|
+
*/
|
|
880
|
+
flows: Record<string, Config$4>;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Single flow configuration.
|
|
884
|
+
* Represents one deployment target (e.g., web_prod, server_stage).
|
|
885
|
+
*
|
|
886
|
+
* @remarks
|
|
887
|
+
* Platform is determined by presence of \`web\` or \`server\` key.
|
|
888
|
+
* Exactly one must be present.
|
|
889
|
+
*
|
|
890
|
+
* Variables/definitions cascade: source/destination > config > setup
|
|
891
|
+
*/
|
|
892
|
+
interface Config$4 {
|
|
893
|
+
/**
|
|
894
|
+
* Web platform configuration.
|
|
895
|
+
* Presence indicates web platform (browser-based tracking).
|
|
896
|
+
* Mutually exclusive with \`server\`.
|
|
897
|
+
*/
|
|
898
|
+
web?: Web;
|
|
899
|
+
/**
|
|
900
|
+
* Server platform configuration.
|
|
901
|
+
* Presence indicates server platform (Node.js).
|
|
902
|
+
* Mutually exclusive with \`web\`.
|
|
903
|
+
*/
|
|
904
|
+
server?: Server;
|
|
905
|
+
/**
|
|
906
|
+
* Source configurations (data capture).
|
|
907
|
+
*
|
|
908
|
+
* @remarks
|
|
909
|
+
* Sources capture events from various origins:
|
|
910
|
+
* - Browser DOM interactions (clicks, page views)
|
|
911
|
+
* - DataLayer pushes
|
|
912
|
+
* - HTTP requests (server-side)
|
|
913
|
+
* - Cloud function triggers
|
|
914
|
+
*
|
|
915
|
+
* Key = unique source identifier (arbitrary)
|
|
916
|
+
* Value = source reference with package and config
|
|
917
|
+
*
|
|
918
|
+
* @example
|
|
919
|
+
* \`\`\`json
|
|
920
|
+
* {
|
|
921
|
+
* "sources": {
|
|
922
|
+
* "browser": {
|
|
923
|
+
* "package": "@walkeros/web-source-browser",
|
|
924
|
+
* "config": {
|
|
925
|
+
* "settings": {
|
|
926
|
+
* "pageview": true,
|
|
927
|
+
* "session": true
|
|
928
|
+
* }
|
|
929
|
+
* }
|
|
930
|
+
* }
|
|
931
|
+
* }
|
|
932
|
+
* }
|
|
933
|
+
* \`\`\`
|
|
934
|
+
*/
|
|
935
|
+
sources?: Record<string, SourceReference>;
|
|
936
|
+
/**
|
|
937
|
+
* Destination configurations (data output).
|
|
938
|
+
*
|
|
939
|
+
* @remarks
|
|
940
|
+
* Destinations send processed events to external services:
|
|
941
|
+
* - Google Analytics (gtag)
|
|
942
|
+
* - Meta Pixel (fbq)
|
|
943
|
+
* - Custom APIs
|
|
944
|
+
* - Data warehouses
|
|
945
|
+
*
|
|
946
|
+
* Key = unique destination identifier (arbitrary)
|
|
947
|
+
* Value = destination reference with package and config
|
|
948
|
+
*
|
|
949
|
+
* @example
|
|
950
|
+
* \`\`\`json
|
|
951
|
+
* {
|
|
952
|
+
* "destinations": {
|
|
953
|
+
* "gtag": {
|
|
954
|
+
* "package": "@walkeros/web-destination-gtag",
|
|
955
|
+
* "config": {
|
|
956
|
+
* "settings": {
|
|
957
|
+
* "ga4": { "measurementId": "G-XXXXXXXXXX" }
|
|
958
|
+
* }
|
|
959
|
+
* }
|
|
960
|
+
* }
|
|
961
|
+
* }
|
|
962
|
+
* }
|
|
963
|
+
* \`\`\`
|
|
964
|
+
*/
|
|
965
|
+
destinations?: Record<string, DestinationReference>;
|
|
966
|
+
/**
|
|
967
|
+
* Collector configuration (event processing).
|
|
968
|
+
*
|
|
969
|
+
* @remarks
|
|
970
|
+
* The collector is the central event processing engine.
|
|
971
|
+
* Configuration includes:
|
|
972
|
+
* - Consent management
|
|
973
|
+
* - Global properties
|
|
974
|
+
* - User identification
|
|
975
|
+
* - Processing rules
|
|
976
|
+
*
|
|
977
|
+
* @see {@link Collector.InitConfig} for complete options
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* \`\`\`json
|
|
981
|
+
* {
|
|
982
|
+
* "collector": {
|
|
983
|
+
* "run": true,
|
|
984
|
+
* "tagging": 1,
|
|
985
|
+
* "consent": {
|
|
986
|
+
* "functional": true,
|
|
987
|
+
* "marketing": false
|
|
988
|
+
* },
|
|
989
|
+
* "globals": {
|
|
990
|
+
* "currency": "USD",
|
|
991
|
+
* "environment": "production"
|
|
992
|
+
* }
|
|
993
|
+
* }
|
|
994
|
+
* }
|
|
995
|
+
* \`\`\`
|
|
996
|
+
*/
|
|
997
|
+
collector?: InitConfig;
|
|
998
|
+
/**
|
|
999
|
+
* NPM packages to bundle.
|
|
1000
|
+
*/
|
|
1001
|
+
packages?: Packages;
|
|
1002
|
+
/**
|
|
1003
|
+
* Flow-level variables.
|
|
1004
|
+
* Override Setup.variables, overridden by source/destination variables.
|
|
1005
|
+
*/
|
|
1006
|
+
variables?: Variables;
|
|
1007
|
+
/**
|
|
1008
|
+
* Flow-level definitions.
|
|
1009
|
+
* Extend Setup.definitions, overridden by source/destination definitions.
|
|
1010
|
+
*/
|
|
1011
|
+
definitions?: Definitions;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Source reference with inline package syntax.
|
|
1015
|
+
*
|
|
1016
|
+
* @remarks
|
|
1017
|
+
* References a source package and provides configuration.
|
|
1018
|
+
* The package is automatically downloaded and imported during build.
|
|
1019
|
+
*/
|
|
1020
|
+
interface SourceReference {
|
|
1021
|
+
/**
|
|
1022
|
+
* Package specifier with optional version.
|
|
1023
|
+
*
|
|
1024
|
+
* @remarks
|
|
1025
|
+
* Formats:
|
|
1026
|
+
* - \`"@walkeros/web-source-browser"\` - Latest version
|
|
1027
|
+
* - \`"@walkeros/web-source-browser@2.0.0"\` - Specific version
|
|
1028
|
+
* - \`"@walkeros/web-source-browser@^2.0.0"\` - Semver range
|
|
1029
|
+
*
|
|
1030
|
+
* The CLI will:
|
|
1031
|
+
* 1. Parse the package reference
|
|
1032
|
+
* 2. Download from npm
|
|
1033
|
+
* 3. Auto-detect default or named export
|
|
1034
|
+
* 4. Generate import statement
|
|
1035
|
+
*
|
|
1036
|
+
* @example
|
|
1037
|
+
* "package": "@walkeros/web-source-browser@latest"
|
|
1038
|
+
*/
|
|
1039
|
+
package: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Resolved import variable name.
|
|
1042
|
+
*
|
|
1043
|
+
* @remarks
|
|
1044
|
+
* Auto-resolved from packages[package].imports[0] during getFlowConfig().
|
|
1045
|
+
* Can also be provided explicitly for advanced use cases.
|
|
1046
|
+
*/
|
|
1047
|
+
code?: string;
|
|
1048
|
+
/**
|
|
1049
|
+
* Source-specific configuration.
|
|
1050
|
+
*
|
|
1051
|
+
* @remarks
|
|
1052
|
+
* Structure depends on the source package.
|
|
1053
|
+
* Passed to the source's initialization function.
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
* \`\`\`json
|
|
1057
|
+
* {
|
|
1058
|
+
* "config": {
|
|
1059
|
+
* "settings": {
|
|
1060
|
+
* "pageview": true,
|
|
1061
|
+
* "session": true,
|
|
1062
|
+
* "elb": "elb",
|
|
1063
|
+
* "prefix": "data-elb"
|
|
1064
|
+
* }
|
|
1065
|
+
* }
|
|
1066
|
+
* }
|
|
1067
|
+
* \`\`\`
|
|
1068
|
+
*/
|
|
1069
|
+
config?: unknown;
|
|
1070
|
+
/**
|
|
1071
|
+
* Source environment configuration.
|
|
1072
|
+
*
|
|
1073
|
+
* @remarks
|
|
1074
|
+
* Environment-specific settings for the source.
|
|
1075
|
+
* Merged with default source environment.
|
|
1076
|
+
*/
|
|
1077
|
+
env?: unknown;
|
|
1078
|
+
/**
|
|
1079
|
+
* Mark as primary source (provides main ELB).
|
|
1080
|
+
*
|
|
1081
|
+
* @remarks
|
|
1082
|
+
* The primary source's ELB function is returned by \`startFlow()\`.
|
|
1083
|
+
* Only one source should be marked as primary per flow.
|
|
1084
|
+
*
|
|
1085
|
+
* @default false
|
|
1086
|
+
*/
|
|
1087
|
+
primary?: boolean;
|
|
1088
|
+
/**
|
|
1089
|
+
* Source-level variables (highest priority in cascade).
|
|
1090
|
+
* Overrides flow and setup variables.
|
|
1091
|
+
*/
|
|
1092
|
+
variables?: Variables;
|
|
1093
|
+
/**
|
|
1094
|
+
* Source-level definitions (highest priority in cascade).
|
|
1095
|
+
* Overrides flow and setup definitions.
|
|
1096
|
+
*/
|
|
1097
|
+
definitions?: Definitions;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Destination reference with inline package syntax.
|
|
1101
|
+
*
|
|
1102
|
+
* @remarks
|
|
1103
|
+
* References a destination package and provides configuration.
|
|
1104
|
+
* Structure mirrors SourceReference for consistency.
|
|
1105
|
+
*/
|
|
1106
|
+
interface DestinationReference {
|
|
1107
|
+
/**
|
|
1108
|
+
* Package specifier with optional version.
|
|
1109
|
+
*
|
|
1110
|
+
* @remarks
|
|
1111
|
+
* Same format as SourceReference.package
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* "package": "@walkeros/web-destination-gtag@2.0.0"
|
|
1115
|
+
*/
|
|
1116
|
+
package: string;
|
|
1117
|
+
/**
|
|
1118
|
+
* Resolved import variable name.
|
|
1119
|
+
*
|
|
1120
|
+
* @remarks
|
|
1121
|
+
* Auto-resolved from packages[package].imports[0] during getFlowConfig().
|
|
1122
|
+
* Can also be provided explicitly for advanced use cases.
|
|
1123
|
+
*/
|
|
1124
|
+
code?: string;
|
|
1125
|
+
/**
|
|
1126
|
+
* Destination-specific configuration.
|
|
1127
|
+
*
|
|
1128
|
+
* @remarks
|
|
1129
|
+
* Structure depends on the destination package.
|
|
1130
|
+
* Typically includes:
|
|
1131
|
+
* - settings: API keys, IDs, endpoints
|
|
1132
|
+
* - mapping: Event transformation rules
|
|
1133
|
+
* - consent: Required consent states
|
|
1134
|
+
* - policy: Processing rules
|
|
1135
|
+
*
|
|
1136
|
+
* @example
|
|
1137
|
+
* \`\`\`json
|
|
1138
|
+
* {
|
|
1139
|
+
* "config": {
|
|
1140
|
+
* "settings": {
|
|
1141
|
+
* "ga4": {
|
|
1142
|
+
* "measurementId": "G-XXXXXXXXXX"
|
|
1143
|
+
* }
|
|
1144
|
+
* },
|
|
1145
|
+
* "mapping": {
|
|
1146
|
+
* "page": {
|
|
1147
|
+
* "view": {
|
|
1148
|
+
* "name": "page_view",
|
|
1149
|
+
* "data": { ... }
|
|
1150
|
+
* }
|
|
1151
|
+
* }
|
|
1152
|
+
* }
|
|
1153
|
+
* }
|
|
1154
|
+
* }
|
|
1155
|
+
* \`\`\`
|
|
1156
|
+
*/
|
|
1157
|
+
config?: unknown;
|
|
1158
|
+
/**
|
|
1159
|
+
* Destination environment configuration.
|
|
1160
|
+
*
|
|
1161
|
+
* @remarks
|
|
1162
|
+
* Environment-specific settings for the destination.
|
|
1163
|
+
* Merged with default destination environment.
|
|
1164
|
+
*/
|
|
1165
|
+
env?: unknown;
|
|
1166
|
+
/**
|
|
1167
|
+
* Destination-level variables (highest priority in cascade).
|
|
1168
|
+
* Overrides flow and setup variables.
|
|
1169
|
+
*/
|
|
1170
|
+
variables?: Variables;
|
|
1171
|
+
/**
|
|
1172
|
+
* Destination-level definitions (highest priority in cascade).
|
|
1173
|
+
* Overrides flow and setup definitions.
|
|
1174
|
+
*/
|
|
1175
|
+
definitions?: Definitions;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
type flow_Definitions = Definitions;
|
|
1179
|
+
type flow_DestinationReference = DestinationReference;
|
|
1180
|
+
type flow_Packages = Packages;
|
|
1181
|
+
type flow_Primitive = Primitive;
|
|
1182
|
+
type flow_Server = Server;
|
|
1183
|
+
type flow_Setup = Setup;
|
|
1184
|
+
type flow_SourceReference = SourceReference;
|
|
1185
|
+
type flow_Variables = Variables;
|
|
1186
|
+
type flow_Web = Web;
|
|
1187
|
+
declare namespace flow {
|
|
1188
|
+
export type { Config$4 as Config, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_Variables as Variables, flow_Web as Web };
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
|
|
1192
|
+
type Functions = {
|
|
1193
|
+
[key: string]: AnyFunction$1;
|
|
1194
|
+
};
|
|
1195
|
+
interface Parameter<P extends unknown[], R> {
|
|
1196
|
+
fn: (...args: P) => R;
|
|
1197
|
+
result?: R;
|
|
1198
|
+
}
|
|
1199
|
+
type HookFn<T extends AnyFunction$1> = (params: Parameter<Parameters<T>, ReturnType<T>>, ...args: Parameters<T>) => ReturnType<T>;
|
|
1200
|
+
|
|
1201
|
+
type hooks_Functions = Functions;
|
|
1202
|
+
type hooks_HookFn<T extends AnyFunction$1> = HookFn<T>;
|
|
1203
|
+
declare namespace hooks {
|
|
1204
|
+
export type { AnyFunction$1 as AnyFunction, hooks_Functions as Functions, hooks_HookFn as HookFn };
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Log levels from most to least severe
|
|
1209
|
+
*/
|
|
1210
|
+
declare enum Level {
|
|
1211
|
+
ERROR = 0,
|
|
1212
|
+
INFO = 1,
|
|
1213
|
+
DEBUG = 2
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Normalized error context extracted from Error objects
|
|
1217
|
+
*/
|
|
1218
|
+
interface ErrorContext {
|
|
1219
|
+
message: string;
|
|
1220
|
+
name: string;
|
|
1221
|
+
stack?: string;
|
|
1222
|
+
cause?: unknown;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Context passed to log handlers
|
|
1226
|
+
* If an Error was passed, it's normalized into the error property
|
|
1227
|
+
*/
|
|
1228
|
+
interface LogContext {
|
|
1229
|
+
[key: string]: unknown;
|
|
1230
|
+
error?: ErrorContext;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Log message function signature
|
|
1234
|
+
* Accepts string or Error as message, with optional context
|
|
1235
|
+
*/
|
|
1236
|
+
type LogFn = (message: string | Error, context?: unknown | Error) => void;
|
|
1237
|
+
/**
|
|
1238
|
+
* Throw function signature - logs error then throws
|
|
1239
|
+
* Returns never as it always throws
|
|
1240
|
+
*/
|
|
1241
|
+
type ThrowFn = (message: string | Error, context?: unknown) => never;
|
|
1242
|
+
/**
|
|
1243
|
+
* Default handler function (passed to custom handlers for chaining)
|
|
1244
|
+
*/
|
|
1245
|
+
type DefaultHandler = (level: Level, message: string, context: LogContext, scope: string[]) => void;
|
|
1246
|
+
/**
|
|
1247
|
+
* Custom log handler function
|
|
1248
|
+
* Receives originalHandler to allow middleware-style chaining
|
|
1249
|
+
*/
|
|
1250
|
+
type Handler = (level: Level, message: string, context: LogContext, scope: string[], originalHandler: DefaultHandler) => void;
|
|
1251
|
+
/**
|
|
1252
|
+
* Logger instance with scoping support
|
|
1253
|
+
* All logs automatically include trace path from scoping
|
|
1254
|
+
*/
|
|
1255
|
+
interface Instance$1 {
|
|
1256
|
+
/**
|
|
1257
|
+
* Log an error message (always visible unless silenced)
|
|
1258
|
+
*/
|
|
1259
|
+
error: LogFn;
|
|
1260
|
+
/**
|
|
1261
|
+
* Log an informational message
|
|
1262
|
+
*/
|
|
1263
|
+
info: LogFn;
|
|
1264
|
+
/**
|
|
1265
|
+
* Log a debug message
|
|
1266
|
+
*/
|
|
1267
|
+
debug: LogFn;
|
|
1268
|
+
/**
|
|
1269
|
+
* Log an error message and throw an Error
|
|
1270
|
+
* Combines logging and throwing in one call
|
|
1271
|
+
*/
|
|
1272
|
+
throw: ThrowFn;
|
|
1273
|
+
/**
|
|
1274
|
+
* Create a scoped child logger with automatic trace path
|
|
1275
|
+
* @param name - Scope name (e.g., destination type, destination key)
|
|
1276
|
+
* @returns A new logger instance with the scope applied
|
|
1277
|
+
*/
|
|
1278
|
+
scope: (name: string) => Instance$1;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Logger configuration options
|
|
1282
|
+
*/
|
|
1283
|
+
interface Config$3 {
|
|
1284
|
+
/**
|
|
1285
|
+
* Minimum log level to display
|
|
1286
|
+
* @default Level.ERROR
|
|
1287
|
+
*/
|
|
1288
|
+
level?: Level | keyof typeof Level;
|
|
1289
|
+
/**
|
|
1290
|
+
* Custom log handler function
|
|
1291
|
+
* Receives originalHandler to preserve default behavior
|
|
1292
|
+
*/
|
|
1293
|
+
handler?: Handler;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Internal config with resolved values and scope
|
|
1297
|
+
*/
|
|
1298
|
+
interface InternalConfig {
|
|
1299
|
+
level: Level;
|
|
1300
|
+
handler?: Handler;
|
|
1301
|
+
scope: string[];
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Logger factory function type
|
|
1305
|
+
*/
|
|
1306
|
+
type Factory = (config?: Config$3) => Instance$1;
|
|
1307
|
+
|
|
1308
|
+
type logger_DefaultHandler = DefaultHandler;
|
|
1309
|
+
type logger_ErrorContext = ErrorContext;
|
|
1310
|
+
type logger_Factory = Factory;
|
|
1311
|
+
type logger_Handler = Handler;
|
|
1312
|
+
type logger_InternalConfig = InternalConfig;
|
|
1313
|
+
type logger_Level = Level;
|
|
1314
|
+
declare const logger_Level: typeof Level;
|
|
1315
|
+
type logger_LogContext = LogContext;
|
|
1316
|
+
type logger_LogFn = LogFn;
|
|
1317
|
+
type logger_ThrowFn = ThrowFn;
|
|
1318
|
+
declare namespace logger {
|
|
1319
|
+
export { type Config$3 as Config, type logger_DefaultHandler as DefaultHandler, type logger_ErrorContext as ErrorContext, type logger_Factory as Factory, type logger_Handler as Handler, type Instance$1 as Instance, type logger_InternalConfig as InternalConfig, logger_Level as Level, type logger_LogContext as LogContext, type logger_LogFn as LogFn, type logger_ThrowFn as ThrowFn };
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* Shared mapping configuration interface.
|
|
1324
|
+
* Used by both Source.Config and Destination.Config.
|
|
1325
|
+
*/
|
|
1326
|
+
interface Config$2<T = unknown> {
|
|
1327
|
+
consent?: Consent;
|
|
1328
|
+
data?: Value | Values;
|
|
1329
|
+
mapping?: Rules<Rule<T>>;
|
|
1330
|
+
policy?: Policy;
|
|
1331
|
+
}
|
|
1332
|
+
interface Policy {
|
|
1333
|
+
[key: string]: Value;
|
|
1334
|
+
}
|
|
1335
|
+
interface Rules<T = Rule> {
|
|
1336
|
+
[entity: string]: Record<string, T | Array<T>> | undefined;
|
|
1337
|
+
}
|
|
1338
|
+
interface Rule<Settings = unknown> {
|
|
1339
|
+
batch?: number;
|
|
1340
|
+
batchFn?: (destination: Instance$2, collector: Instance$3) => void;
|
|
1341
|
+
batched?: Batch<Settings>;
|
|
1342
|
+
condition?: Condition;
|
|
1343
|
+
consent?: Consent;
|
|
1344
|
+
settings?: Settings;
|
|
1345
|
+
data?: Data;
|
|
1346
|
+
ignore?: boolean;
|
|
1347
|
+
name?: string;
|
|
1348
|
+
policy?: Policy;
|
|
1349
|
+
}
|
|
1350
|
+
interface Result {
|
|
1351
|
+
eventMapping?: Rule;
|
|
1352
|
+
mappingKey?: string;
|
|
1353
|
+
}
|
|
1354
|
+
type Data = Value | Values;
|
|
1355
|
+
type Value = ValueType | Array<ValueType>;
|
|
1356
|
+
type Values = Array<Value>;
|
|
1357
|
+
type ValueType = string | ValueConfig;
|
|
1358
|
+
interface ValueConfig {
|
|
1359
|
+
condition?: Condition;
|
|
1360
|
+
consent?: Consent;
|
|
1361
|
+
fn?: Fn;
|
|
1362
|
+
key?: string;
|
|
1363
|
+
loop?: Loop;
|
|
1364
|
+
map?: Map;
|
|
1365
|
+
set?: Value[];
|
|
1366
|
+
validate?: Validate;
|
|
1367
|
+
value?: PropertyType;
|
|
1368
|
+
}
|
|
1369
|
+
type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$3) => PromiseOrValue<boolean>;
|
|
1370
|
+
type Fn = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
|
|
1371
|
+
type Loop = [Value, Value];
|
|
1372
|
+
type Map = {
|
|
1373
|
+
[key: string]: Value;
|
|
1374
|
+
};
|
|
1375
|
+
interface Options$1 {
|
|
1376
|
+
consent?: Consent;
|
|
1377
|
+
collector?: Instance$3;
|
|
1378
|
+
props?: unknown;
|
|
1379
|
+
}
|
|
1380
|
+
type Validate = (value?: unknown) => PromiseOrValue<boolean>;
|
|
1381
|
+
|
|
1382
|
+
type mapping_Condition = Condition;
|
|
1383
|
+
type mapping_Data = Data;
|
|
1384
|
+
type mapping_Fn = Fn;
|
|
1385
|
+
type mapping_Loop = Loop;
|
|
1386
|
+
type mapping_Map = Map;
|
|
1387
|
+
type mapping_Policy = Policy;
|
|
1388
|
+
type mapping_Result = Result;
|
|
1389
|
+
type mapping_Rule<Settings = unknown> = Rule<Settings>;
|
|
1390
|
+
type mapping_Rules<T = Rule> = Rules<T>;
|
|
1391
|
+
type mapping_Validate = Validate;
|
|
1392
|
+
type mapping_Value = Value;
|
|
1393
|
+
type mapping_ValueConfig = ValueConfig;
|
|
1394
|
+
type mapping_ValueType = ValueType;
|
|
1395
|
+
type mapping_Values = Values;
|
|
1396
|
+
declare namespace mapping {
|
|
1397
|
+
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 };
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
type Config$1 = {
|
|
1401
|
+
consent?: Array<ConsentConfig>;
|
|
1402
|
+
ready?: Array<ReadyConfig>;
|
|
1403
|
+
run?: Array<RunConfig>;
|
|
1404
|
+
session?: Array<SessionConfig>;
|
|
1405
|
+
};
|
|
1406
|
+
type Types$1 = keyof Config$1;
|
|
1407
|
+
interface EventContextMap {
|
|
1408
|
+
consent: Consent;
|
|
1409
|
+
session: SessionData;
|
|
1410
|
+
ready: undefined;
|
|
1411
|
+
run: undefined;
|
|
1412
|
+
}
|
|
1413
|
+
type EventContext<T extends Types$1> = EventContextMap[T];
|
|
1414
|
+
type AnyEventContext = EventContextMap[keyof EventContextMap];
|
|
1415
|
+
interface Context$1 {
|
|
1416
|
+
consent?: Consent;
|
|
1417
|
+
session?: unknown;
|
|
1418
|
+
}
|
|
1419
|
+
type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
|
|
1420
|
+
interface ConsentConfig {
|
|
1421
|
+
[key: string]: ConsentFn;
|
|
1422
|
+
}
|
|
1423
|
+
type ConsentFn = (collector: Instance$3, consent: Consent) => void;
|
|
1424
|
+
type ReadyConfig = ReadyFn;
|
|
1425
|
+
type ReadyFn = (collector: Instance$3) => void;
|
|
1426
|
+
type RunConfig = RunFn;
|
|
1427
|
+
type RunFn = (collector: Instance$3) => void;
|
|
1428
|
+
type SessionConfig = SessionFn;
|
|
1429
|
+
type SessionFn = (collector: Instance$3, session?: unknown) => void;
|
|
1430
|
+
interface OnConfig {
|
|
1431
|
+
consent?: ConsentConfig[];
|
|
1432
|
+
ready?: ReadyConfig[];
|
|
1433
|
+
run?: RunConfig[];
|
|
1434
|
+
session?: SessionConfig[];
|
|
1435
|
+
[key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
|
|
1436
|
+
}
|
|
1437
|
+
type OnFn<T extends TypesGeneric$1 = Types$2> = (type: Types$1, context: Context$2<T>) => PromiseOrValue<void>;
|
|
1438
|
+
type OnFnRuntime = (type: Types$1, context: Context$2) => PromiseOrValue<void>;
|
|
1439
|
+
|
|
1440
|
+
type on_AnyEventContext = AnyEventContext;
|
|
1441
|
+
type on_ConsentConfig = ConsentConfig;
|
|
1442
|
+
type on_ConsentFn = ConsentFn;
|
|
1443
|
+
type on_EventContext<T extends Types$1> = EventContext<T>;
|
|
1444
|
+
type on_EventContextMap = EventContextMap;
|
|
1445
|
+
type on_OnConfig = OnConfig;
|
|
1446
|
+
type on_OnFn<T extends TypesGeneric$1 = Types$2> = OnFn<T>;
|
|
1447
|
+
type on_OnFnRuntime = OnFnRuntime;
|
|
1448
|
+
type on_Options = Options;
|
|
1449
|
+
type on_ReadyConfig = ReadyConfig;
|
|
1450
|
+
type on_ReadyFn = ReadyFn;
|
|
1451
|
+
type on_RunConfig = RunConfig;
|
|
1452
|
+
type on_RunFn = RunFn;
|
|
1453
|
+
type on_SessionConfig = SessionConfig;
|
|
1454
|
+
type on_SessionFn = SessionFn;
|
|
1455
|
+
declare namespace on {
|
|
1456
|
+
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 };
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
interface Context {
|
|
1460
|
+
city?: string;
|
|
1461
|
+
country?: string;
|
|
1462
|
+
encoding?: string;
|
|
1463
|
+
hash?: string;
|
|
1464
|
+
ip?: string;
|
|
1465
|
+
language?: string;
|
|
1466
|
+
origin?: string;
|
|
1467
|
+
region?: string;
|
|
1468
|
+
userAgent?: string;
|
|
1469
|
+
[key: string]: string | undefined;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
type request_Context = Context;
|
|
1473
|
+
declare namespace request {
|
|
1474
|
+
export type { request_Context as Context };
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
type Contracts = Array<Contract>;
|
|
1478
|
+
type Contract = {
|
|
1479
|
+
[entity: string]: {
|
|
1480
|
+
[action: string]: Properties$1;
|
|
1481
|
+
};
|
|
1482
|
+
};
|
|
1483
|
+
type Properties$1 = {
|
|
1484
|
+
[key: string]: Property$1 | undefined;
|
|
1485
|
+
};
|
|
1486
|
+
type Property$1 = {
|
|
1487
|
+
allowedKeys?: string[];
|
|
1488
|
+
allowedValues?: unknown[];
|
|
1489
|
+
maxLength?: number;
|
|
1490
|
+
max?: number;
|
|
1491
|
+
min?: number;
|
|
1492
|
+
required?: boolean;
|
|
1493
|
+
schema?: Properties$1;
|
|
1494
|
+
strict?: boolean;
|
|
1495
|
+
type?: string;
|
|
1496
|
+
validate?: (value: unknown, key: string, event: AnyObject) => Property;
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
type schema_Contract = Contract;
|
|
1500
|
+
type schema_Contracts = Contracts;
|
|
1501
|
+
declare namespace schema {
|
|
1502
|
+
export type { schema_Contract as Contract, schema_Contracts as Contracts, Properties$1 as Properties, Property$1 as Property };
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* Base Env interface for dependency injection into sources.
|
|
1507
|
+
*
|
|
1508
|
+
* Sources receive all their dependencies through this environment object,
|
|
1509
|
+
* making them platform-agnostic and easily testable.
|
|
1510
|
+
*/
|
|
1511
|
+
interface BaseEnv {
|
|
1512
|
+
[key: string]: unknown;
|
|
1513
|
+
push: PushFn$1;
|
|
1514
|
+
command: CommandFn;
|
|
1515
|
+
sources?: Sources;
|
|
1516
|
+
elb: Fn$1;
|
|
1517
|
+
logger: Instance$1;
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Type bundle for source generics.
|
|
1521
|
+
* Groups Settings, Mapping, Push, Env, and InitSettings into a single type parameter.
|
|
1522
|
+
*
|
|
1523
|
+
* @template S - Settings configuration type
|
|
1524
|
+
* @template M - Mapping configuration type
|
|
1525
|
+
* @template P - Push function signature (flexible to support HTTP handlers, etc.)
|
|
1526
|
+
* @template E - Environment dependencies type
|
|
1527
|
+
* @template I - InitSettings configuration type (user input)
|
|
1528
|
+
*/
|
|
1529
|
+
interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> {
|
|
1530
|
+
settings: S;
|
|
1531
|
+
initSettings: I;
|
|
1532
|
+
mapping: M;
|
|
1533
|
+
push: P;
|
|
1534
|
+
env: E;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Generic constraint for Types - ensures T has required properties for indexed access
|
|
1538
|
+
*/
|
|
1539
|
+
type TypesGeneric = {
|
|
1540
|
+
settings: any;
|
|
1541
|
+
initSettings: any;
|
|
1542
|
+
mapping: any;
|
|
1543
|
+
push: any;
|
|
1544
|
+
env: any;
|
|
1545
|
+
};
|
|
1546
|
+
/**
|
|
1547
|
+
* Type extractors for consistent usage with Types bundle
|
|
1548
|
+
*/
|
|
1549
|
+
type Settings<T extends TypesGeneric = Types> = T['settings'];
|
|
1550
|
+
type InitSettings<T extends TypesGeneric = Types> = T['initSettings'];
|
|
1551
|
+
type Mapping<T extends TypesGeneric = Types> = T['mapping'];
|
|
1552
|
+
type Push<T extends TypesGeneric = Types> = T['push'];
|
|
1553
|
+
type Env<T extends TypesGeneric = Types> = T['env'];
|
|
1554
|
+
/**
|
|
1555
|
+
* Inference helper: Extract Types from Instance
|
|
1556
|
+
*/
|
|
1557
|
+
type TypesOf<I> = I extends Instance<infer T> ? T : never;
|
|
1558
|
+
interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
|
|
1559
|
+
settings?: InitSettings<T>;
|
|
1560
|
+
env?: Env<T>;
|
|
1561
|
+
id?: string;
|
|
1562
|
+
logger?: Config$3;
|
|
1563
|
+
disabled?: boolean;
|
|
1564
|
+
primary?: boolean;
|
|
1565
|
+
}
|
|
1566
|
+
type PartialConfig<T extends TypesGeneric = Types> = Config<Types<Partial<Settings<T>> | Settings<T>, Partial<Mapping<T>> | Mapping<T>, Push<T>, Env<T>>>;
|
|
1567
|
+
interface Instance<T extends TypesGeneric = Types> {
|
|
1568
|
+
type: string;
|
|
1569
|
+
config: Config<T>;
|
|
1570
|
+
push: Push<T>;
|
|
1571
|
+
destroy?(): void | Promise<void>;
|
|
1572
|
+
on?(event: Types$1, context?: unknown): void | Promise<void>;
|
|
1573
|
+
}
|
|
1574
|
+
type Init<T extends TypesGeneric = Types> = (config: Partial<Config<T>>, env: Env<T>) => Instance<T> | Promise<Instance<T>>;
|
|
1575
|
+
type InitSource<T extends TypesGeneric = Types> = {
|
|
1576
|
+
code: Init<T>;
|
|
1577
|
+
config?: Partial<Config<T>>;
|
|
1578
|
+
env?: Partial<Env<T>>;
|
|
1579
|
+
primary?: boolean;
|
|
1580
|
+
};
|
|
1581
|
+
/**
|
|
1582
|
+
* Sources configuration for collector.
|
|
1583
|
+
* Maps source IDs to their initialization configurations.
|
|
1584
|
+
*/
|
|
1585
|
+
interface InitSources {
|
|
1586
|
+
[sourceId: string]: InitSource<any>;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
type source_BaseEnv = BaseEnv;
|
|
1590
|
+
type source_Config<T extends TypesGeneric = Types> = Config<T>;
|
|
1591
|
+
type source_Env<T extends TypesGeneric = Types> = Env<T>;
|
|
1592
|
+
type source_Init<T extends TypesGeneric = Types> = Init<T>;
|
|
1593
|
+
type source_InitSettings<T extends TypesGeneric = Types> = InitSettings<T>;
|
|
1594
|
+
type source_InitSource<T extends TypesGeneric = Types> = InitSource<T>;
|
|
1595
|
+
type source_InitSources = InitSources;
|
|
1596
|
+
type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
|
|
1597
|
+
type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
|
|
1598
|
+
type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
|
|
1599
|
+
type source_Push<T extends TypesGeneric = Types> = Push<T>;
|
|
1600
|
+
type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
|
|
1601
|
+
type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> = Types<S, M, P, E, I>;
|
|
1602
|
+
type source_TypesGeneric = TypesGeneric;
|
|
1603
|
+
type source_TypesOf<I> = TypesOf<I>;
|
|
1604
|
+
declare namespace source {
|
|
1605
|
+
export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSettings as InitSettings, 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 };
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
type AnyObject<T = unknown> = Record<string, T>;
|
|
1609
|
+
type Elb = Fn$1;
|
|
1610
|
+
type AnyFunction = (...args: unknown[]) => unknown;
|
|
1611
|
+
type SingleOrArray<T> = T | Array<T>;
|
|
1612
|
+
type Events = Array<Event>;
|
|
1613
|
+
type PartialEvent = Partial<Event>;
|
|
1614
|
+
type DeepPartialEvent = DeepPartial<Event>;
|
|
1615
|
+
interface Event {
|
|
1616
|
+
name: string;
|
|
1617
|
+
data: Properties;
|
|
1618
|
+
context: OrderedProperties;
|
|
1619
|
+
globals: Properties;
|
|
1620
|
+
custom: Properties;
|
|
1621
|
+
user: User;
|
|
1622
|
+
nested: Entities;
|
|
1623
|
+
consent: Consent;
|
|
1624
|
+
id: string;
|
|
1625
|
+
trigger: string;
|
|
1626
|
+
entity: string;
|
|
1627
|
+
action: string;
|
|
1628
|
+
timestamp: number;
|
|
1629
|
+
timing: number;
|
|
1630
|
+
group: string;
|
|
1631
|
+
count: number;
|
|
1632
|
+
version: Version;
|
|
1633
|
+
source: Source;
|
|
1634
|
+
}
|
|
1635
|
+
interface Consent {
|
|
1636
|
+
[name: string]: boolean;
|
|
1637
|
+
}
|
|
1638
|
+
interface User extends Properties {
|
|
1639
|
+
id?: string;
|
|
1640
|
+
device?: string;
|
|
1641
|
+
session?: string;
|
|
1642
|
+
hash?: string;
|
|
1643
|
+
address?: string;
|
|
1644
|
+
email?: string;
|
|
1645
|
+
phone?: string;
|
|
1646
|
+
userAgent?: string;
|
|
1647
|
+
browser?: string;
|
|
1648
|
+
browserVersion?: string;
|
|
1649
|
+
deviceType?: string;
|
|
1650
|
+
language?: string;
|
|
1651
|
+
country?: string;
|
|
1652
|
+
region?: string;
|
|
1653
|
+
city?: string;
|
|
1654
|
+
zip?: string;
|
|
1655
|
+
timezone?: string;
|
|
1656
|
+
os?: string;
|
|
1657
|
+
osVersion?: string;
|
|
1658
|
+
screenSize?: string;
|
|
1659
|
+
ip?: string;
|
|
1660
|
+
internal?: boolean;
|
|
1661
|
+
}
|
|
1662
|
+
interface Version extends Properties {
|
|
1663
|
+
source: string;
|
|
1664
|
+
tagging: number;
|
|
1665
|
+
}
|
|
1666
|
+
interface Source extends Properties {
|
|
1667
|
+
type: SourceType;
|
|
1668
|
+
id: string;
|
|
1669
|
+
previous_id: string;
|
|
1670
|
+
}
|
|
1671
|
+
type SourceType = 'web' | 'server' | 'app' | 'other' | string;
|
|
1672
|
+
type PropertyType = boolean | string | number | {
|
|
1673
|
+
[key: string]: Property;
|
|
1674
|
+
};
|
|
1675
|
+
type Property = PropertyType | Array<PropertyType>;
|
|
1676
|
+
interface Properties {
|
|
1677
|
+
[key: string]: Property | undefined;
|
|
1678
|
+
}
|
|
1679
|
+
interface OrderedProperties {
|
|
1680
|
+
[key: string]: [Property, number] | undefined;
|
|
1681
|
+
}
|
|
1682
|
+
type Entities = Array<Entity>;
|
|
1683
|
+
interface Entity {
|
|
1684
|
+
entity: string;
|
|
1685
|
+
data: Properties;
|
|
1686
|
+
nested: Entities;
|
|
1687
|
+
context: OrderedProperties;
|
|
1688
|
+
}
|
|
1689
|
+
type ConsentHandler = Record<string, AnyFunction>;
|
|
1690
|
+
type ActionHandler = AnyFunction;
|
|
1691
|
+
type DeepPartial<T> = {
|
|
1692
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
1693
|
+
};
|
|
1694
|
+
type PromiseOrValue<T> = T | Promise<T>;
|
|
1695
|
+
|
|
1696
|
+
type walkeros_ActionHandler = ActionHandler;
|
|
1697
|
+
type walkeros_AnyFunction = AnyFunction;
|
|
1698
|
+
type walkeros_AnyObject<T = unknown> = AnyObject<T>;
|
|
1699
|
+
type walkeros_Consent = Consent;
|
|
1700
|
+
type walkeros_ConsentHandler = ConsentHandler;
|
|
1701
|
+
type walkeros_DeepPartial<T> = DeepPartial<T>;
|
|
1702
|
+
type walkeros_DeepPartialEvent = DeepPartialEvent;
|
|
1703
|
+
type walkeros_Elb = Elb;
|
|
1704
|
+
type walkeros_Entities = Entities;
|
|
1705
|
+
type walkeros_Entity = Entity;
|
|
1706
|
+
type walkeros_Event = Event;
|
|
1707
|
+
type walkeros_Events = Events;
|
|
1708
|
+
type walkeros_OrderedProperties = OrderedProperties;
|
|
1709
|
+
type walkeros_PartialEvent = PartialEvent;
|
|
1710
|
+
type walkeros_PromiseOrValue<T> = PromiseOrValue<T>;
|
|
1711
|
+
type walkeros_Properties = Properties;
|
|
1712
|
+
type walkeros_Property = Property;
|
|
1713
|
+
type walkeros_PropertyType = PropertyType;
|
|
1714
|
+
type walkeros_SingleOrArray<T> = SingleOrArray<T>;
|
|
1715
|
+
type walkeros_Source = Source;
|
|
1716
|
+
type walkeros_SourceType = SourceType;
|
|
1717
|
+
type walkeros_User = User;
|
|
1718
|
+
type walkeros_Version = Version;
|
|
1719
|
+
declare namespace walkeros {
|
|
1720
|
+
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_SourceType as SourceType, walkeros_User as User, walkeros_Version as Version };
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
type StorageType = 'local' | 'session' | 'cookie';
|
|
1724
|
+
declare const Const: {
|
|
1725
|
+
readonly Utils: {
|
|
1726
|
+
readonly Storage: {
|
|
1727
|
+
readonly Local: "local";
|
|
1728
|
+
readonly Session: "session";
|
|
1729
|
+
readonly Cookie: "cookie";
|
|
1730
|
+
};
|
|
1731
|
+
};
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
type SendDataValue = Property | Properties;
|
|
1735
|
+
type SendHeaders = {
|
|
1736
|
+
[key: string]: string;
|
|
1737
|
+
};
|
|
1738
|
+
interface SendResponse {
|
|
1739
|
+
ok: boolean;
|
|
1740
|
+
data?: unknown;
|
|
1741
|
+
error?: string;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* Anonymizes an IPv4 address by setting the last octet to 0.
|
|
1746
|
+
*
|
|
1747
|
+
* @param ip The IP address to anonymize.
|
|
1748
|
+
* @returns The anonymized IP address or an empty string if the IP is invalid.
|
|
1749
|
+
*/
|
|
1750
|
+
declare function anonymizeIP(ip: string): string;
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Flow Configuration Utilities
|
|
1754
|
+
*
|
|
1755
|
+
* Functions for resolving and processing Flow configurations.
|
|
1756
|
+
*
|
|
1757
|
+
* @packageDocumentation
|
|
1758
|
+
*/
|
|
1759
|
+
|
|
1760
|
+
/**
|
|
1761
|
+
* Convert package name to valid JavaScript variable name.
|
|
1762
|
+
* Used for deterministic default import naming.
|
|
1763
|
+
* @example
|
|
1764
|
+
* packageNameToVariable('@walkeros/server-destination-api')
|
|
1765
|
+
* // \u2192 '_walkerosServerDestinationApi'
|
|
1766
|
+
*/
|
|
1767
|
+
declare function packageNameToVariable(packageName: string): string;
|
|
1768
|
+
/**
|
|
1769
|
+
* Get resolved flow configuration for a named flow.
|
|
1770
|
+
*
|
|
1771
|
+
* @param setup - The complete setup configuration
|
|
1772
|
+
* @param flowName - Flow name (auto-selected if only one exists)
|
|
1773
|
+
* @returns Resolved Config with variables/definitions interpolated and $refs resolved
|
|
1774
|
+
* @throws Error if flow selection is required but not specified, or flow not found
|
|
1775
|
+
*
|
|
1776
|
+
* @example
|
|
1777
|
+
* \`\`\`typescript
|
|
1778
|
+
* import { getFlowConfig } from '@walkeros/core';
|
|
1779
|
+
*
|
|
1780
|
+
* const setup = JSON.parse(fs.readFileSync('walkeros.config.json', 'utf8'));
|
|
1781
|
+
*
|
|
1782
|
+
* // Auto-select if only one flow
|
|
1783
|
+
* const config = getFlowConfig(setup);
|
|
1784
|
+
*
|
|
1785
|
+
* // Or specify flow
|
|
1786
|
+
* const prodConfig = getFlowConfig(setup, 'production');
|
|
1787
|
+
* \`\`\`
|
|
1788
|
+
*/
|
|
1789
|
+
declare function getFlowConfig(setup: Setup, flowName?: string): Config$4;
|
|
1790
|
+
/**
|
|
1791
|
+
* Get platform from config (web or server).
|
|
1792
|
+
*
|
|
1793
|
+
* @param config - Flow configuration
|
|
1794
|
+
* @returns "web" or "server"
|
|
1795
|
+
* @throws Error if neither web nor server is present
|
|
1796
|
+
*
|
|
1797
|
+
* @example
|
|
1798
|
+
* \`\`\`typescript
|
|
1799
|
+
* import { getPlatform } from '@walkeros/core';
|
|
1800
|
+
*
|
|
1801
|
+
* const platform = getPlatform(config);
|
|
1802
|
+
* // Returns "web" or "server"
|
|
1803
|
+
* \`\`\`
|
|
1804
|
+
*/
|
|
1805
|
+
declare function getPlatform(config: Config$4): 'web' | 'server';
|
|
1806
|
+
|
|
1807
|
+
/**
|
|
1808
|
+
* @interface Assign
|
|
1809
|
+
* @description Options for the assign function.
|
|
1810
|
+
* @property merge - Merge array properties instead of overriding them.
|
|
1811
|
+
* @property shallow - Create a shallow copy instead of updating the target object.
|
|
1812
|
+
* @property extend - Extend the target with new properties instead of only updating existing ones.
|
|
1813
|
+
*/
|
|
1814
|
+
interface Assign {
|
|
1815
|
+
merge?: boolean;
|
|
1816
|
+
shallow?: boolean;
|
|
1817
|
+
extend?: boolean;
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Merges objects with advanced options.
|
|
1821
|
+
*
|
|
1822
|
+
* @template T, U
|
|
1823
|
+
* @param target - The target object to merge into.
|
|
1824
|
+
* @param obj - The source object to merge from.
|
|
1825
|
+
* @param options - Options for merging.
|
|
1826
|
+
* @returns The merged object.
|
|
1827
|
+
*/
|
|
1828
|
+
declare function assign<T extends object, U extends object>(target: T, obj?: U, options?: Assign): T & U;
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* Gets a value from an object by a dot-notation string.
|
|
1832
|
+
* Supports wildcards for arrays.
|
|
1833
|
+
*
|
|
1834
|
+
* @example
|
|
1835
|
+
* getByPath({ data: { id: 1 } }, "data.id") // Returns 1
|
|
1836
|
+
*
|
|
1837
|
+
* @param event - The object to get the value from.
|
|
1838
|
+
* @param key - The dot-notation string.
|
|
1839
|
+
* @param defaultValue - The default value to return if the key is not found.
|
|
1840
|
+
* @returns The value from the object or the default value.
|
|
1841
|
+
*/
|
|
1842
|
+
declare function getByPath(event: unknown, key?: string, defaultValue?: unknown): unknown;
|
|
1843
|
+
/**
|
|
1844
|
+
* Sets a value in an object by a dot-notation string.
|
|
1845
|
+
*
|
|
1846
|
+
* @param obj - The object to set the value in.
|
|
1847
|
+
* @param key - The dot-notation string.
|
|
1848
|
+
* @param value - The value to set.
|
|
1849
|
+
* @returns A new object with the updated value.
|
|
1850
|
+
*/
|
|
1851
|
+
declare function setByPath<T = unknown>(obj: T, key: string, value: unknown): T;
|
|
1852
|
+
|
|
1853
|
+
/**
|
|
1854
|
+
* Casts a value to a specific type.
|
|
1855
|
+
*
|
|
1856
|
+
* @param value The value to cast.
|
|
1857
|
+
* @returns The casted value.
|
|
1858
|
+
*/
|
|
1859
|
+
declare function castValue(value: unknown): PropertyType;
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* Creates a deep clone of a value.
|
|
1863
|
+
* Supports primitive values, objects, arrays, dates, and regular expressions.
|
|
1864
|
+
* Handles circular references.
|
|
1865
|
+
*
|
|
1866
|
+
* @template T
|
|
1867
|
+
* @param org - The value to clone.
|
|
1868
|
+
* @param visited - A map of visited objects to handle circular references.
|
|
1869
|
+
* @returns The cloned value.
|
|
1870
|
+
*/
|
|
1871
|
+
declare function clone<T>(org: T, visited?: WeakMap<object, unknown>): T;
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* Checks if the required consent is granted.
|
|
1875
|
+
*
|
|
1876
|
+
* @param required - The required consent states.
|
|
1877
|
+
* @param state - The current consent states.
|
|
1878
|
+
* @param individual - Individual consent states to prioritize.
|
|
1879
|
+
* @returns The granted consent states or false if not granted.
|
|
1880
|
+
*/
|
|
1881
|
+
declare function getGrantedConsent(required: Consent | undefined, state?: Consent, individual?: Consent): false | Consent;
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* Creates a new destination instance by merging a base destination with additional configuration.
|
|
1885
|
+
*
|
|
1886
|
+
* This utility enables elegant destination configuration while avoiding config side-effects
|
|
1887
|
+
* that could occur when reusing destination objects across multiple collector instances.
|
|
1888
|
+
*
|
|
1889
|
+
* @param baseDestination - The base destination to extend
|
|
1890
|
+
* @param config - Additional configuration to merge with the base destination's config
|
|
1891
|
+
* @returns A new destination instance with merged configuration
|
|
1892
|
+
*
|
|
1893
|
+
* @example
|
|
1894
|
+
* \`\`\`typescript
|
|
1895
|
+
* // Types are inferred automatically from destinationGtag
|
|
1896
|
+
* elb('walker destination', createDestination(destinationGtag, {
|
|
1897
|
+
* settings: { ga4: { measurementId: 'G-123' } }
|
|
1898
|
+
* }));
|
|
1899
|
+
* \`\`\`
|
|
1900
|
+
*/
|
|
1901
|
+
declare function createDestination<I extends Instance$2>(baseDestination: I, config: Partial<Config$5<TypesOf$1<I>>>): I;
|
|
1902
|
+
|
|
1903
|
+
/**
|
|
1904
|
+
* Creates a complete event with default values.
|
|
1905
|
+
* Used for testing and debugging.
|
|
1906
|
+
*
|
|
1907
|
+
* @param props - Properties to override the default values.
|
|
1908
|
+
* @returns A complete event.
|
|
1909
|
+
*/
|
|
1910
|
+
declare function createEvent(props?: DeepPartialEvent): Event;
|
|
1911
|
+
/**
|
|
1912
|
+
* Creates a complete event with default values based on the event name.
|
|
1913
|
+
* Used for testing and debugging.
|
|
1914
|
+
*
|
|
1915
|
+
* @param name - The name of the event to create.
|
|
1916
|
+
* @param props - Properties to override the default values.
|
|
1917
|
+
* @returns A complete event.
|
|
1918
|
+
*/
|
|
1919
|
+
declare function getEvent(name?: string, props?: DeepPartialEvent): Event;
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* Generates a random string of a given length.
|
|
1923
|
+
*
|
|
1924
|
+
* @param length - The length of the random string.
|
|
1925
|
+
* @returns The random string.
|
|
1926
|
+
*/
|
|
1927
|
+
declare function getId(length?: number): string;
|
|
1928
|
+
|
|
1929
|
+
interface MarketingParameters {
|
|
1930
|
+
[key: string]: string;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Extracts marketing parameters from a URL.
|
|
1934
|
+
*
|
|
1935
|
+
* @param url - The URL to extract the parameters from.
|
|
1936
|
+
* @param custom - Custom marketing parameters to extract.
|
|
1937
|
+
* @returns The extracted marketing parameters.
|
|
1938
|
+
*/
|
|
1939
|
+
declare function getMarketingParameters(url: URL, custom?: MarketingParameters): Properties;
|
|
1940
|
+
|
|
1941
|
+
/**
|
|
1942
|
+
* Creates a debounced function that delays invoking \`fn\` until after \`wait\`
|
|
1943
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
1944
|
+
* invoked. The debounced function comes with a \`cancel\` method to cancel
|
|
1945
|
+
* delayed \`fn\` invocations and a \`flush\` method to immediately invoke them.
|
|
1946
|
+
*
|
|
1947
|
+
* @template P, R
|
|
1948
|
+
* @param fn The function to debounce.
|
|
1949
|
+
* @param wait The number of milliseconds to delay.
|
|
1950
|
+
* @param immediate Trigger the function on the leading edge, instead of the trailing.
|
|
1951
|
+
* @returns The new debounced function.
|
|
1952
|
+
*/
|
|
1953
|
+
declare function debounce<P extends unknown[], R>(fn: (...args: P) => R, wait?: number, immediate?: boolean): (...args: P) => Promise<R>;
|
|
1954
|
+
declare function throttle<P extends unknown[], R>(fn: (...args: P) => R | undefined, delay?: number): (...args: P) => R | undefined;
|
|
1955
|
+
|
|
1956
|
+
/**
|
|
1957
|
+
* Checks if a value is an arguments object.
|
|
1958
|
+
*
|
|
1959
|
+
* @param value The value to check.
|
|
1960
|
+
* @returns True if the value is an arguments object, false otherwise.
|
|
1961
|
+
*/
|
|
1962
|
+
declare function isArguments(value: unknown): value is IArguments;
|
|
1963
|
+
/**
|
|
1964
|
+
* Checks if a value is an array.
|
|
1965
|
+
*
|
|
1966
|
+
* @param value The value to check.
|
|
1967
|
+
* @returns True if the value is an array, false otherwise.
|
|
1968
|
+
*/
|
|
1969
|
+
declare function isArray<T>(value: unknown): value is T[];
|
|
1970
|
+
/**
|
|
1971
|
+
* Checks if a value is a boolean.
|
|
1972
|
+
*
|
|
1973
|
+
* @param value The value to check.
|
|
1974
|
+
* @returns True if the value is a boolean, false otherwise.
|
|
1975
|
+
*/
|
|
1976
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
1977
|
+
/**
|
|
1978
|
+
* Checks if an entity is a walker command.
|
|
1979
|
+
*
|
|
1980
|
+
* @param entity The entity to check.
|
|
1981
|
+
* @returns True if the entity is a walker command, false otherwise.
|
|
1982
|
+
*/
|
|
1983
|
+
declare function isCommand(entity: string): entity is "walker";
|
|
1984
|
+
/**
|
|
1985
|
+
* Checks if a value is defined.
|
|
1986
|
+
*
|
|
1987
|
+
* @param value The value to check.
|
|
1988
|
+
* @returns True if the value is defined, false otherwise.
|
|
1989
|
+
*/
|
|
1990
|
+
declare function isDefined<T>(val: T | undefined): val is T;
|
|
1991
|
+
/**
|
|
1992
|
+
* Checks if a value is an element or the document.
|
|
1993
|
+
*
|
|
1994
|
+
* @param elem The value to check.
|
|
1995
|
+
* @returns True if the value is an element or the document, false otherwise.
|
|
1996
|
+
*/
|
|
1997
|
+
declare function isElementOrDocument(elem: unknown): elem is Element;
|
|
1998
|
+
/**
|
|
1999
|
+
* Checks if a value is a function.
|
|
2000
|
+
*
|
|
2001
|
+
* @param value The value to check.
|
|
2002
|
+
* @returns True if the value is a function, false otherwise.
|
|
2003
|
+
*/
|
|
2004
|
+
declare function isFunction(value: unknown): value is Function;
|
|
2005
|
+
/**
|
|
2006
|
+
* Checks if a value is a number.
|
|
2007
|
+
*
|
|
2008
|
+
* @param value The value to check.
|
|
2009
|
+
* @returns True if the value is a number, false otherwise.
|
|
2010
|
+
*/
|
|
2011
|
+
declare function isNumber(value: unknown): value is number;
|
|
2012
|
+
/**
|
|
2013
|
+
* Checks if a value is an object.
|
|
2014
|
+
*
|
|
2015
|
+
* @param value The value to check.
|
|
2016
|
+
* @returns True if the value is an object, false otherwise.
|
|
2017
|
+
*/
|
|
2018
|
+
declare function isObject(value: unknown): value is AnyObject;
|
|
2019
|
+
/**
|
|
2020
|
+
* Checks if two variables have the same type.
|
|
2021
|
+
*
|
|
2022
|
+
* @param variable The first variable.
|
|
2023
|
+
* @param type The second variable.
|
|
2024
|
+
* @returns True if the variables have the same type, false otherwise.
|
|
2025
|
+
*/
|
|
2026
|
+
declare function isSameType<T>(variable: unknown, type: T): variable is typeof type;
|
|
2027
|
+
/**
|
|
2028
|
+
* Checks if a value is a string.
|
|
2029
|
+
*
|
|
2030
|
+
* @param value The value to check.
|
|
2031
|
+
* @returns True if the value is a string, false otherwise.
|
|
2032
|
+
*/
|
|
2033
|
+
declare function isString(value: unknown): value is string;
|
|
2034
|
+
|
|
2035
|
+
/**
|
|
2036
|
+
* Create a logger instance
|
|
2037
|
+
*
|
|
2038
|
+
* @param config - Logger configuration
|
|
2039
|
+
* @returns Logger instance with all log methods and scoping support
|
|
2040
|
+
*
|
|
2041
|
+
* @example
|
|
2042
|
+
* \`\`\`typescript
|
|
2043
|
+
* // Basic usage
|
|
2044
|
+
* const logger = createLogger({ level: 'DEBUG' });
|
|
2045
|
+
* logger.info('Hello world');
|
|
2046
|
+
*
|
|
2047
|
+
* // With scoping
|
|
2048
|
+
* const destLogger = logger.scope('gtag').scope('myInstance');
|
|
2049
|
+
* destLogger.debug('Processing event'); // DEBUG [gtag:myInstance] Processing event
|
|
2050
|
+
*
|
|
2051
|
+
* // With custom handler
|
|
2052
|
+
* const logger = createLogger({
|
|
2053
|
+
* handler: (level, message, context, scope, originalHandler) => {
|
|
2054
|
+
* // Custom logic (e.g., send to Sentry)
|
|
2055
|
+
* originalHandler(level, message, context, scope);
|
|
2056
|
+
* }
|
|
2057
|
+
* });
|
|
2058
|
+
* \`\`\`
|
|
2059
|
+
*
|
|
2060
|
+
* // TODO: Consider compile-time stripping of debug logs in production builds
|
|
2061
|
+
* // e.g., if (__DEV__) { logger.debug(...) }
|
|
2062
|
+
*/
|
|
2063
|
+
declare function createLogger(config?: Config$3): Instance$1;
|
|
2064
|
+
|
|
2065
|
+
/**
|
|
2066
|
+
* Gets the mapping for an event.
|
|
2067
|
+
*
|
|
2068
|
+
* @param event The event to get the mapping for (can be partial or full).
|
|
2069
|
+
* @param mapping The mapping rules.
|
|
2070
|
+
* @returns The mapping result.
|
|
2071
|
+
*/
|
|
2072
|
+
declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules): Promise<Result>;
|
|
2073
|
+
/**
|
|
2074
|
+
* Gets a value from a mapping.
|
|
2075
|
+
*
|
|
2076
|
+
* @param value The value to get the mapping from.
|
|
2077
|
+
* @param data The mapping data.
|
|
2078
|
+
* @param options The mapping options.
|
|
2079
|
+
* @returns The mapped value.
|
|
2080
|
+
*/
|
|
2081
|
+
declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data, options?: Options$1): Promise<Property | undefined>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Processes an event through mapping configuration.
|
|
2084
|
+
*
|
|
2085
|
+
* This is the unified mapping logic used by both sources and destinations.
|
|
2086
|
+
* It applies transformations in this order:
|
|
2087
|
+
* 1. Config-level policy - modifies the event itself (global rules)
|
|
2088
|
+
* 2. Mapping rules - finds matching rule based on entity-action
|
|
2089
|
+
* 3. Event-level policy - modifies the event based on specific mapping rule
|
|
2090
|
+
* 4. Data transformation - creates context data
|
|
2091
|
+
* 5. Ignore check and name override
|
|
2092
|
+
*
|
|
2093
|
+
* Sources can pass partial events, destinations pass full events.
|
|
2094
|
+
* getMappingValue works with both partial and full events.
|
|
2095
|
+
*
|
|
2096
|
+
* @param event - The event to process (can be partial or full, will be mutated by policies)
|
|
2097
|
+
* @param config - Mapping configuration (mapping, data, policy, consent)
|
|
2098
|
+
* @param collector - Collector instance for context
|
|
2099
|
+
* @returns Object with transformed event, data, mapping rule, and ignore flag
|
|
2100
|
+
*/
|
|
2101
|
+
declare function processEventMapping<T extends DeepPartialEvent | Event>(event: T, config: Config$2, collector: Instance$3): Promise<{
|
|
2102
|
+
event: T;
|
|
2103
|
+
data?: Property;
|
|
2104
|
+
mapping?: Rule;
|
|
2105
|
+
mappingKey?: string;
|
|
2106
|
+
ignore: boolean;
|
|
2107
|
+
}>;
|
|
2108
|
+
|
|
2109
|
+
/**
|
|
2110
|
+
* Environment mocking utilities for walkerOS destinations
|
|
2111
|
+
*
|
|
2112
|
+
* Provides standardized tools for intercepting function calls in environment objects,
|
|
2113
|
+
* enabling consistent testing patterns across all destinations.
|
|
2114
|
+
*/
|
|
2115
|
+
type InterceptorFn = (path: string[], args: unknown[], original?: Function) => unknown;
|
|
2116
|
+
/**
|
|
2117
|
+
* Creates a proxied environment that intercepts function calls
|
|
2118
|
+
*
|
|
2119
|
+
* Uses Proxy to wrap environment objects and capture all function calls,
|
|
2120
|
+
* allowing for call recording, mocking, or simulation.
|
|
2121
|
+
*
|
|
2122
|
+
* @param env - The environment object to wrap
|
|
2123
|
+
* @param interceptor - Function called for each intercepted call
|
|
2124
|
+
* @returns Proxied environment with interceptor applied
|
|
2125
|
+
*
|
|
2126
|
+
* @example
|
|
2127
|
+
* \`\`\`typescript
|
|
2128
|
+
* const calls: Array<{ path: string[]; args: unknown[] }> = [];
|
|
2129
|
+
*
|
|
2130
|
+
* const testEnv = mockEnv(env.push, (path, args) => {
|
|
2131
|
+
* calls.push({ path, args });
|
|
2132
|
+
* });
|
|
2133
|
+
*
|
|
2134
|
+
* // Use testEnv with destination
|
|
2135
|
+
* await destination.push(event, { env: testEnv });
|
|
2136
|
+
*
|
|
2137
|
+
* // Analyze captured calls
|
|
2138
|
+
* expect(calls).toContainEqual({
|
|
2139
|
+
* path: ['window', 'gtag'],
|
|
2140
|
+
* args: ['event', 'purchase', { value: 99.99 }]
|
|
2141
|
+
* });
|
|
2142
|
+
* \`\`\`
|
|
2143
|
+
*/
|
|
2144
|
+
declare function mockEnv<T extends object>(env: T, interceptor: InterceptorFn): T;
|
|
2145
|
+
/**
|
|
2146
|
+
* Traverses environment object and replaces values using a replacer function
|
|
2147
|
+
*
|
|
2148
|
+
* Alternative to mockEnv for environments where Proxy is not suitable.
|
|
2149
|
+
* Performs deep traversal and allows value transformation at each level.
|
|
2150
|
+
*
|
|
2151
|
+
* @param env - The environment object to traverse
|
|
2152
|
+
* @param replacer - Function to transform values during traversal
|
|
2153
|
+
* @returns New environment object with transformed values
|
|
2154
|
+
*
|
|
2155
|
+
* @example
|
|
2156
|
+
* \`\`\`typescript
|
|
2157
|
+
* const recordedCalls: APICall[] = [];
|
|
2158
|
+
*
|
|
2159
|
+
* const recordingEnv = traverseEnv(originalEnv, (value, path) => {
|
|
2160
|
+
* if (typeof value === 'function') {
|
|
2161
|
+
* return (...args: unknown[]) => {
|
|
2162
|
+
* recordedCalls.push({
|
|
2163
|
+
* path: path.join('.'),
|
|
2164
|
+
* args: structuredClone(args)
|
|
2165
|
+
* });
|
|
2166
|
+
* return value(...args);
|
|
2167
|
+
* };
|
|
2168
|
+
* }
|
|
2169
|
+
* return value;
|
|
2170
|
+
* });
|
|
2171
|
+
* \`\`\`
|
|
2172
|
+
*/
|
|
2173
|
+
declare function traverseEnv<T extends object>(env: T, replacer: (value: unknown, path: string[]) => unknown): T;
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* Mock logger instance for testing
|
|
2177
|
+
* Includes all logger methods as jest.fn() plus tracking of scoped loggers
|
|
2178
|
+
* Extends Instance to ensure type compatibility
|
|
2179
|
+
*/
|
|
2180
|
+
interface MockLogger extends Instance$1 {
|
|
2181
|
+
error: jest.Mock;
|
|
2182
|
+
info: jest.Mock;
|
|
2183
|
+
debug: jest.Mock;
|
|
2184
|
+
throw: jest.Mock<never, [string | Error, unknown?]>;
|
|
2185
|
+
scope: jest.Mock<MockLogger, [string]>;
|
|
2186
|
+
/**
|
|
2187
|
+
* Array of all scoped loggers created by this logger
|
|
2188
|
+
* Useful for asserting on scoped logger calls in tests
|
|
2189
|
+
*/
|
|
2190
|
+
scopedLoggers: MockLogger[];
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Create a mock logger for testing
|
|
2194
|
+
* All methods are jest.fn() that can be used for assertions
|
|
2195
|
+
*
|
|
2196
|
+
* @example
|
|
2197
|
+
* \`\`\`typescript
|
|
2198
|
+
* const mockLogger = createMockLogger();
|
|
2199
|
+
*
|
|
2200
|
+
* // Use in code under test
|
|
2201
|
+
* someFunction(mockLogger);
|
|
2202
|
+
*
|
|
2203
|
+
* // Assert on calls
|
|
2204
|
+
* expect(mockLogger.error).toHaveBeenCalledWith('error message');
|
|
2205
|
+
*
|
|
2206
|
+
* // Assert on scoped logger
|
|
2207
|
+
* const scoped = mockLogger.scopedLoggers[0];
|
|
2208
|
+
* expect(scoped.debug).toHaveBeenCalledWith('debug in scope');
|
|
2209
|
+
* \`\`\`
|
|
2210
|
+
*/
|
|
2211
|
+
declare function createMockLogger(): MockLogger;
|
|
2212
|
+
|
|
2213
|
+
/**
|
|
2214
|
+
* Checks if a value is a valid property type.
|
|
2215
|
+
*
|
|
2216
|
+
* @param value The value to check.
|
|
2217
|
+
* @returns True if the value is a valid property type, false otherwise.
|
|
2218
|
+
*/
|
|
2219
|
+
declare function isPropertyType(value: unknown): value is PropertyType;
|
|
2220
|
+
/**
|
|
2221
|
+
* Filters a value to only include valid property types.
|
|
2222
|
+
*
|
|
2223
|
+
* @param value The value to filter.
|
|
2224
|
+
* @returns The filtered value or undefined.
|
|
2225
|
+
*/
|
|
2226
|
+
declare function filterValues(value: unknown): Property | undefined;
|
|
2227
|
+
/**
|
|
2228
|
+
* Casts a value to a valid property type.
|
|
2229
|
+
*
|
|
2230
|
+
* @param value The value to cast.
|
|
2231
|
+
* @returns The casted value or undefined.
|
|
2232
|
+
*/
|
|
2233
|
+
declare function castToProperty(value: unknown): Property | undefined;
|
|
2234
|
+
|
|
2235
|
+
/**
|
|
2236
|
+
* Converts a request string to a data object.
|
|
2237
|
+
*
|
|
2238
|
+
* @param parameter The request string to convert.
|
|
2239
|
+
* @returns The data object or undefined.
|
|
2240
|
+
*/
|
|
2241
|
+
declare function requestToData(parameter: unknown): AnyObject | undefined;
|
|
2242
|
+
/**
|
|
2243
|
+
* Converts a data object to a request string.
|
|
2244
|
+
*
|
|
2245
|
+
* @param data The data object to convert.
|
|
2246
|
+
* @returns The request string.
|
|
2247
|
+
*/
|
|
2248
|
+
declare function requestToParameter(data: AnyObject | PropertyType): string;
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* Transforms data to a string.
|
|
2252
|
+
*
|
|
2253
|
+
* @param data The data to transform.
|
|
2254
|
+
* @returns The transformed data.
|
|
2255
|
+
*/
|
|
2256
|
+
declare function transformData(data?: SendDataValue): string | undefined;
|
|
2257
|
+
/**
|
|
2258
|
+
* Gets the headers for a request.
|
|
2259
|
+
*
|
|
2260
|
+
* @param headers The headers to merge with the default headers.
|
|
2261
|
+
* @returns The merged headers.
|
|
2262
|
+
*/
|
|
2263
|
+
declare function getHeaders(headers?: SendHeaders): SendHeaders;
|
|
2264
|
+
|
|
2265
|
+
/**
|
|
2266
|
+
* Throws an error.
|
|
2267
|
+
*
|
|
2268
|
+
* @param error The error to throw.
|
|
2269
|
+
*/
|
|
2270
|
+
declare function throwError(error: unknown): never;
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Trims quotes and whitespaces from a string.
|
|
2274
|
+
*
|
|
2275
|
+
* @param str The string to trim.
|
|
2276
|
+
* @returns The trimmed string.
|
|
2277
|
+
*/
|
|
2278
|
+
declare function trim(str: string): string;
|
|
2279
|
+
|
|
2280
|
+
/**
|
|
2281
|
+
* A utility function that wraps a function in a try-catch block.
|
|
2282
|
+
*
|
|
2283
|
+
* @template P, R, S
|
|
2284
|
+
* @param fn The function to wrap.
|
|
2285
|
+
* @param onError A function to call when an error is caught.
|
|
2286
|
+
* @param onFinally A function to call in the finally block.
|
|
2287
|
+
* @returns The wrapped function.
|
|
2288
|
+
*/
|
|
2289
|
+
declare function tryCatch<P extends unknown[], R, S>(fn: (...args: P) => R | undefined, onError: (err: unknown) => S, onFinally?: () => void): (...args: P) => R | S;
|
|
2290
|
+
declare function tryCatch<P extends unknown[], R>(fn: (...args: P) => R | undefined, onError?: undefined, onFinally?: () => void): (...args: P) => R | undefined;
|
|
2291
|
+
/**
|
|
2292
|
+
* A utility function that wraps an async function in a try-catch block.
|
|
2293
|
+
*
|
|
2294
|
+
* @template P, R, S
|
|
2295
|
+
* @param fn The async function to wrap.
|
|
2296
|
+
* @param onError A function to call when an error is caught.
|
|
2297
|
+
* @param onFinally A function to call in the finally block.
|
|
2298
|
+
* @returns The wrapped async function.
|
|
2299
|
+
*/
|
|
2300
|
+
declare function tryCatchAsync<P extends unknown[], R, S>(fn: (...args: P) => R, onError: (err: unknown) => S, onFinally?: () => void | Promise<void>): (...args: P) => Promise<R | S>;
|
|
2301
|
+
declare function tryCatchAsync<P extends unknown[], R>(fn: (...args: P) => R, onError?: undefined, onFinally?: () => void | Promise<void>): (...args: P) => Promise<R | undefined>;
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* A utility function that wraps a function with hooks.
|
|
2305
|
+
*
|
|
2306
|
+
* @template P, R
|
|
2307
|
+
* @param fn The function to wrap.
|
|
2308
|
+
* @param name The name of the function.
|
|
2309
|
+
* @param hooks The hooks to use.
|
|
2310
|
+
* @returns The wrapped function.
|
|
2311
|
+
*/
|
|
2312
|
+
declare function useHooks<P extends unknown[], R>(fn: (...args: P) => R, name: string, hooks: Functions): (...args: P) => R;
|
|
2313
|
+
|
|
2314
|
+
/**
|
|
2315
|
+
* Parses a user agent string to extract browser, OS, and device information.
|
|
2316
|
+
*
|
|
2317
|
+
* @param userAgent The user agent string to parse.
|
|
2318
|
+
* @returns An object containing the parsed user agent information.
|
|
2319
|
+
*/
|
|
2320
|
+
declare function parseUserAgent(userAgent?: string): User;
|
|
2321
|
+
/**
|
|
2322
|
+
* Gets the browser name from a user agent string.
|
|
2323
|
+
*
|
|
2324
|
+
* @param userAgent The user agent string.
|
|
2325
|
+
* @returns The browser name or undefined.
|
|
2326
|
+
*/
|
|
2327
|
+
declare function getBrowser(userAgent: string): string | undefined;
|
|
2328
|
+
/**
|
|
2329
|
+
* Gets the browser version from a user agent string.
|
|
2330
|
+
*
|
|
2331
|
+
* @param userAgent The user agent string.
|
|
2332
|
+
* @returns The browser version or undefined.
|
|
2333
|
+
*/
|
|
2334
|
+
declare function getBrowserVersion(userAgent: string): string | undefined;
|
|
2335
|
+
/**
|
|
2336
|
+
* Gets the OS name from a user agent string.
|
|
2337
|
+
*
|
|
2338
|
+
* @param userAgent The user agent string.
|
|
2339
|
+
* @returns The OS name or undefined.
|
|
2340
|
+
*/
|
|
2341
|
+
declare function getOS(userAgent: string): string | undefined;
|
|
2342
|
+
/**
|
|
2343
|
+
* Gets the OS version from a user agent string.
|
|
2344
|
+
*
|
|
2345
|
+
* @param userAgent The user agent string.
|
|
2346
|
+
* @returns The OS version or undefined.
|
|
2347
|
+
*/
|
|
2348
|
+
declare function getOSVersion(userAgent: string): string | undefined;
|
|
2349
|
+
/**
|
|
2350
|
+
* Gets the device type from a user agent string.
|
|
2351
|
+
*
|
|
2352
|
+
* @param userAgent The user agent string.
|
|
2353
|
+
* @returns The device type or undefined.
|
|
2354
|
+
*/
|
|
2355
|
+
declare function getDeviceType(userAgent: string): string | undefined;
|
|
2356
|
+
|
|
2357
|
+
/**
|
|
2358
|
+
* Validates an event against a set of contracts.
|
|
2359
|
+
*
|
|
2360
|
+
* @param obj The event to validate.
|
|
2361
|
+
* @param customContracts The custom contracts to use.
|
|
2362
|
+
* @returns The validated event.
|
|
2363
|
+
*/
|
|
2364
|
+
declare function validateEvent(obj: unknown, customContracts?: Contracts): Event | never;
|
|
2365
|
+
/**
|
|
2366
|
+
* Validates a property against a schema.
|
|
2367
|
+
*
|
|
2368
|
+
* @param obj The object to validate.
|
|
2369
|
+
* @param key The key of the property to validate.
|
|
2370
|
+
* @param value The value of the property to validate.
|
|
2371
|
+
* @param schema The schema to validate against.
|
|
2372
|
+
* @returns The validated property.
|
|
2373
|
+
*/
|
|
2374
|
+
declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
|
|
2375
|
+
|
|
2376
|
+
/**
|
|
2377
|
+
* Inline Code Wrapping Utilities
|
|
2378
|
+
*
|
|
2379
|
+
* Converts inline code strings to executable functions.
|
|
2380
|
+
* Used for mapping properties: condition, fn, validate.
|
|
2381
|
+
*
|
|
2382
|
+
* @packageDocumentation
|
|
2383
|
+
*/
|
|
2384
|
+
|
|
2385
|
+
/**
|
|
2386
|
+
* Wrap inline code string as Condition function.
|
|
2387
|
+
*
|
|
2388
|
+
* @param code - Inline code string
|
|
2389
|
+
* @returns Condition function matching Mapping.Condition signature
|
|
2390
|
+
*
|
|
2391
|
+
* @remarks
|
|
2392
|
+
* Available parameters in code:
|
|
2393
|
+
* - \`value\` - The event or partial event being processed
|
|
2394
|
+
* - \`mapping\` - Current mapping configuration
|
|
2395
|
+
* - \`collector\` - Collector instance
|
|
2396
|
+
*
|
|
2397
|
+
* If code has no explicit return, it's auto-wrapped with \`return\`.
|
|
2398
|
+
*
|
|
2399
|
+
* @example
|
|
2400
|
+
* \`\`\`typescript
|
|
2401
|
+
* // One-liner (auto-wrapped)
|
|
2402
|
+
* const fn = wrapCondition('value.data.total > 100');
|
|
2403
|
+
* fn(event, mapping, collector); // returns boolean
|
|
2404
|
+
*
|
|
2405
|
+
* // Multi-statement (explicit return)
|
|
2406
|
+
* const fn = wrapCondition('const threshold = 100; return value.data.total > threshold');
|
|
2407
|
+
* \`\`\`
|
|
2408
|
+
*/
|
|
2409
|
+
declare function wrapCondition(code: string): Condition;
|
|
2410
|
+
/**
|
|
2411
|
+
* Wrap inline code string as Fn function.
|
|
2412
|
+
*
|
|
2413
|
+
* @param code - Inline code string
|
|
2414
|
+
* @returns Fn function matching Mapping.Fn signature
|
|
2415
|
+
*
|
|
2416
|
+
* @remarks
|
|
2417
|
+
* Available parameters in code:
|
|
2418
|
+
* - \`value\` - The event or partial event being processed
|
|
2419
|
+
* - \`mapping\` - Current mapping configuration
|
|
2420
|
+
* - \`options\` - Options object with consent and collector
|
|
2421
|
+
*
|
|
2422
|
+
* If code has no explicit return, it's auto-wrapped with \`return\`.
|
|
2423
|
+
*
|
|
2424
|
+
* @example
|
|
2425
|
+
* \`\`\`typescript
|
|
2426
|
+
* // One-liner (auto-wrapped)
|
|
2427
|
+
* const fn = wrapFn('value.user.email.split("@")[1]');
|
|
2428
|
+
* fn(event, mapping, options); // returns domain
|
|
2429
|
+
*
|
|
2430
|
+
* // Multi-statement (explicit return)
|
|
2431
|
+
* const fn = wrapFn('const parts = value.user.email.split("@"); return parts[1].toUpperCase()');
|
|
2432
|
+
* \`\`\`
|
|
2433
|
+
*/
|
|
2434
|
+
declare function wrapFn(code: string): Fn;
|
|
2435
|
+
/**
|
|
2436
|
+
* Wrap inline code string as Validate function.
|
|
2437
|
+
*
|
|
2438
|
+
* @param code - Inline code string
|
|
2439
|
+
* @returns Validate function matching Mapping.Validate signature
|
|
2440
|
+
*
|
|
2441
|
+
* @remarks
|
|
2442
|
+
* Available parameters in code:
|
|
2443
|
+
* - \`value\` - The current value being validated
|
|
2444
|
+
*
|
|
2445
|
+
* If code has no explicit return, it's auto-wrapped with \`return\`.
|
|
2446
|
+
*
|
|
2447
|
+
* @example
|
|
2448
|
+
* \`\`\`typescript
|
|
2449
|
+
* // One-liner (auto-wrapped)
|
|
2450
|
+
* const fn = wrapValidate('value && value.length > 0');
|
|
2451
|
+
* fn('hello'); // returns true
|
|
2452
|
+
*
|
|
2453
|
+
* // Multi-statement (explicit return)
|
|
2454
|
+
* const fn = wrapValidate('if (!value) return false; return value.length > 0');
|
|
2455
|
+
* \`\`\`
|
|
2456
|
+
*/
|
|
2457
|
+
declare function wrapValidate(code: string): Validate;
|
|
2458
|
+
|
|
2459
|
+
export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, hooks as Hooks, Level, logger as Logger, mapping as Mapping, type MarketingParameters, type MockLogger, 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, createLogger, createMockLogger, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowConfig, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, wrapCondition, wrapFn, wrapValidate };
|
|
2460
|
+
`;
|
|
2461
|
+
|
|
2462
|
+
// src/utils/monaco-types.ts
|
|
2463
|
+
var typeLibraries = /* @__PURE__ */ new Map();
|
|
2464
|
+
function configureMonacoTypeScript(monaco) {
|
|
2465
|
+
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
2466
|
+
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
|
2467
|
+
lib: ["es2020"],
|
|
2468
|
+
allowNonTsExtensions: true,
|
|
2469
|
+
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
2470
|
+
module: monaco.languages.typescript.ModuleKind.CommonJS,
|
|
2471
|
+
noEmit: true,
|
|
2472
|
+
esModuleInterop: true,
|
|
2473
|
+
jsx: monaco.languages.typescript.JsxEmit.React,
|
|
2474
|
+
allowJs: true,
|
|
2475
|
+
checkJs: false,
|
|
2476
|
+
strict: false,
|
|
2477
|
+
noImplicitAny: false,
|
|
2478
|
+
strictNullChecks: false
|
|
2479
|
+
});
|
|
2480
|
+
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
|
2481
|
+
noSemanticValidation: false,
|
|
2482
|
+
noSyntaxValidation: false,
|
|
2483
|
+
diagnosticCodesToIgnore: [
|
|
2484
|
+
1108,
|
|
2485
|
+
1005
|
|
2486
|
+
]
|
|
2487
|
+
});
|
|
2488
|
+
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
2489
|
+
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
|
2490
|
+
lib: ["es2020"],
|
|
2491
|
+
allowNonTsExtensions: true,
|
|
2492
|
+
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
2493
|
+
module: monaco.languages.typescript.ModuleKind.CommonJS,
|
|
2494
|
+
noEmit: true,
|
|
2495
|
+
esModuleInterop: true,
|
|
2496
|
+
jsx: monaco.languages.typescript.JsxEmit.React,
|
|
2497
|
+
strict: false
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
function addTypeLibrary(monaco, uri, content) {
|
|
2501
|
+
if (typeLibraries.has(uri)) {
|
|
2502
|
+
return false;
|
|
2503
|
+
}
|
|
2504
|
+
const jsDisposable = monaco.languages.typescript.javascriptDefaults.addExtraLib(
|
|
2505
|
+
content,
|
|
2506
|
+
uri
|
|
2507
|
+
);
|
|
2508
|
+
const tsDisposable = monaco.languages.typescript.typescriptDefaults.addExtraLib(
|
|
2509
|
+
content,
|
|
2510
|
+
uri
|
|
2511
|
+
);
|
|
2512
|
+
typeLibraries.set(uri, {
|
|
2513
|
+
uri,
|
|
2514
|
+
content,
|
|
2515
|
+
disposable: {
|
|
2516
|
+
dispose: () => {
|
|
2517
|
+
jsDisposable.dispose();
|
|
2518
|
+
tsDisposable.dispose();
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
return true;
|
|
2523
|
+
}
|
|
2524
|
+
function removeTypeLibrary(uri) {
|
|
2525
|
+
const lib = typeLibraries.get(uri);
|
|
2526
|
+
if (!lib) {
|
|
2527
|
+
return false;
|
|
2528
|
+
}
|
|
2529
|
+
lib.disposable?.dispose();
|
|
2530
|
+
typeLibraries.delete(uri);
|
|
2531
|
+
return true;
|
|
2532
|
+
}
|
|
2533
|
+
function updateTypeLibrary(monaco, uri, content) {
|
|
2534
|
+
removeTypeLibrary(uri);
|
|
2535
|
+
addTypeLibrary(monaco, uri, content);
|
|
2536
|
+
}
|
|
2537
|
+
async function loadTypeLibraryFromURL(monaco, url, uri) {
|
|
2538
|
+
try {
|
|
2539
|
+
const response = await fetch(url);
|
|
2540
|
+
if (!response.ok) {
|
|
2541
|
+
return false;
|
|
2542
|
+
}
|
|
2543
|
+
const content = await response.text();
|
|
2544
|
+
const typeUri = uri || `file:///${url}`;
|
|
2545
|
+
return addTypeLibrary(monaco, typeUri, content);
|
|
2546
|
+
} catch {
|
|
2547
|
+
return false;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
function stripExternalImports(content) {
|
|
2551
|
+
let cleaned = content.replace(
|
|
2552
|
+
/^import\s+(?:type\s+)?(?:\*\s+as\s+\w+|\{[^}]*\}|[\w$]+)(?:\s*,\s*(?:\{[^}]*\}|\*\s+as\s+\w+))?\s+from\s+['"][^'"]+['"];?\s*$/gm,
|
|
2553
|
+
""
|
|
2554
|
+
);
|
|
2555
|
+
cleaned = cleaned.replace(
|
|
2556
|
+
/^import\s+(?:type\s+)?(?:\{[^}]*\}|\*\s+as\s+\w+|[\w$]+)\s+from\s+['"][^'"]+['"];?\s*$/gms,
|
|
2557
|
+
""
|
|
2558
|
+
);
|
|
2559
|
+
cleaned = cleaned.replace(
|
|
2560
|
+
/import\s*\(\s*['"][^'"]+['"]\s*\)/g,
|
|
2561
|
+
"any"
|
|
2562
|
+
);
|
|
2563
|
+
cleaned = cleaned.replace(/\n{3,}/g, "\n\n");
|
|
2564
|
+
return cleaned;
|
|
2565
|
+
}
|
|
2566
|
+
async function loadPackageTypes(monaco, options) {
|
|
2567
|
+
const { package: packageName, version = "latest" } = options;
|
|
2568
|
+
const uri = `file:///node_modules/${packageName}/index.d.ts`;
|
|
2569
|
+
if (typeLibraries.has(uri)) {
|
|
2570
|
+
return true;
|
|
2571
|
+
}
|
|
2572
|
+
const url = `https://cdn.jsdelivr.net/npm/${packageName}@${version}/dist/index.d.ts`;
|
|
2573
|
+
try {
|
|
2574
|
+
const response = await fetch(url);
|
|
2575
|
+
if (!response.ok) {
|
|
2576
|
+
console.warn(`Failed to load types for ${packageName}@${version}: ${response.status}`);
|
|
2577
|
+
return false;
|
|
2578
|
+
}
|
|
2579
|
+
let content = await response.text();
|
|
2580
|
+
content = stripExternalImports(content);
|
|
2581
|
+
const moduleContent = `declare module '${packageName}' {
|
|
2582
|
+
${content}
|
|
2583
|
+
}`;
|
|
2584
|
+
const success = addTypeLibrary(monaco, uri, moduleContent);
|
|
2585
|
+
return success;
|
|
2586
|
+
} catch (error) {
|
|
2587
|
+
console.error(`Error loading types for ${packageName}:`, error);
|
|
2588
|
+
return false;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
function loadWalkerOSCoreTypes(monaco) {
|
|
2592
|
+
const uri = "file:///node_modules/@walkeros/core/index.d.ts";
|
|
2593
|
+
if (typeLibraries.has(uri)) {
|
|
2594
|
+
return true;
|
|
2595
|
+
}
|
|
2596
|
+
const cleanedTypes = stripExternalImports(virtual_walkeros_core_types_default);
|
|
2597
|
+
const moduleContent = `declare module '@walkeros/core' {
|
|
2598
|
+
${cleanedTypes}
|
|
2599
|
+
}`;
|
|
2600
|
+
return addTypeLibrary(monaco, uri, moduleContent);
|
|
2601
|
+
}
|
|
2602
|
+
function addFunctionContextTypes(monaco, context) {
|
|
2603
|
+
const uri = `file:///context/${context.type}.d.ts`;
|
|
2604
|
+
const contextTypes = getContextTypes(context.type);
|
|
2605
|
+
updateTypeLibrary(monaco, uri, contextTypes);
|
|
2606
|
+
}
|
|
2607
|
+
function addDestinationType(monaco, destinationId, typeDefinition) {
|
|
2608
|
+
const uri = `file:///destinations/${destinationId}.d.ts`;
|
|
2609
|
+
updateTypeLibrary(monaco, uri, typeDefinition);
|
|
2610
|
+
}
|
|
2611
|
+
function removeDestinationType(destinationId) {
|
|
2612
|
+
const uri = `file:///destinations/${destinationId}.d.ts`;
|
|
2613
|
+
removeTypeLibrary(uri);
|
|
2614
|
+
}
|
|
2615
|
+
function registerWalkerOSTypes(monaco) {
|
|
2616
|
+
configureMonacoTypeScript(monaco);
|
|
2617
|
+
loadWalkerOSCoreTypes(monaco);
|
|
2618
|
+
}
|
|
2619
|
+
function initializeMonacoTypes(monaco) {
|
|
2620
|
+
configureMonacoTypeScript(monaco);
|
|
2621
|
+
loadWalkerOSCoreTypes(monaco);
|
|
2622
|
+
addFunctionContextTypes(monaco, { type: "condition" });
|
|
2623
|
+
}
|
|
2624
|
+
function getLoadedTypeLibraries() {
|
|
2625
|
+
return Array.from(typeLibraries.keys());
|
|
2626
|
+
}
|
|
2627
|
+
function clearAllTypeLibraries() {
|
|
2628
|
+
for (const [uri, lib] of typeLibraries.entries()) {
|
|
2629
|
+
lib.disposable?.dispose();
|
|
2630
|
+
}
|
|
2631
|
+
typeLibraries.clear();
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
export {
|
|
2635
|
+
configureMonacoTypeScript,
|
|
2636
|
+
addTypeLibrary,
|
|
2637
|
+
removeTypeLibrary,
|
|
2638
|
+
updateTypeLibrary,
|
|
2639
|
+
loadTypeLibraryFromURL,
|
|
2640
|
+
loadPackageTypes,
|
|
2641
|
+
loadWalkerOSCoreTypes,
|
|
2642
|
+
addFunctionContextTypes,
|
|
2643
|
+
addDestinationType,
|
|
2644
|
+
removeDestinationType,
|
|
2645
|
+
registerWalkerOSTypes,
|
|
2646
|
+
initializeMonacoTypes,
|
|
2647
|
+
getLoadedTypeLibraries,
|
|
2648
|
+
clearAllTypeLibraries
|
|
2649
|
+
};
|
|
2650
|
+
//# sourceMappingURL=chunk-WKBCYMTQ.mjs.map
|