@walkeros/core 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.d.mts +122 -33
- package/dist/dev.d.ts +122 -33
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.d.mts +511 -211
- package/dist/index.d.ts +511 -211
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core collector configuration interface
|
|
3
3
|
*/
|
|
4
|
-
interface Config$
|
|
4
|
+
interface Config$6 {
|
|
5
5
|
/** Whether to run collector automatically */
|
|
6
6
|
run?: boolean;
|
|
7
7
|
/** Version for event tagging */
|
|
@@ -10,17 +10,13 @@ interface Config$5 {
|
|
|
10
10
|
globalsStatic: Properties;
|
|
11
11
|
/** Static session data even on a new run */
|
|
12
12
|
sessionStatic: Partial<SessionData>;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/** Error handler */
|
|
16
|
-
onError?: Error;
|
|
17
|
-
/** Log handler */
|
|
18
|
-
onLog?: Log;
|
|
13
|
+
/** Logger configuration */
|
|
14
|
+
logger?: Config$3;
|
|
19
15
|
}
|
|
20
16
|
/**
|
|
21
17
|
* Initialization configuration that extends Config with initial state
|
|
22
18
|
*/
|
|
23
|
-
interface InitConfig extends Partial<Config$
|
|
19
|
+
interface InitConfig extends Partial<Config$6> {
|
|
24
20
|
/** Initial consent state */
|
|
25
21
|
consent?: Consent;
|
|
26
22
|
/** Initial user data */
|
|
@@ -50,7 +46,7 @@ interface Sources {
|
|
|
50
46
|
[id: string]: Instance;
|
|
51
47
|
}
|
|
52
48
|
interface Destinations$1 {
|
|
53
|
-
[id: string]: Instance$
|
|
49
|
+
[id: string]: Instance$2;
|
|
54
50
|
}
|
|
55
51
|
type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' | 'elb' | 'globals' | 'hook' | 'init' | 'link' | 'run' | 'user' | 'walker' | string;
|
|
56
52
|
/**
|
|
@@ -69,9 +65,9 @@ interface PushFn$1 {
|
|
|
69
65
|
* Command function signature - handles walker commands only
|
|
70
66
|
*/
|
|
71
67
|
interface CommandFn {
|
|
72
|
-
(command: 'config', config: Partial<Config$
|
|
68
|
+
(command: 'config', config: Partial<Config$6>): Promise<PushResult>;
|
|
73
69
|
(command: 'consent', consent: Consent): Promise<PushResult>;
|
|
74
|
-
<T extends Types$2>(command: 'destination', destination: Init$1<T> | Instance$
|
|
70
|
+
<T extends Types$2>(command: 'destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): Promise<PushResult>;
|
|
75
71
|
<K extends keyof Functions>(command: 'hook', name: K, hookFn: Functions[K]): Promise<PushResult>;
|
|
76
72
|
(command: 'on', type: Types$1, rules: SingleOrArray<Options>): Promise<PushResult>;
|
|
77
73
|
(command: 'user', user: User): Promise<PushResult>;
|
|
@@ -83,11 +79,11 @@ interface CommandFn {
|
|
|
83
79
|
}): Promise<PushResult>;
|
|
84
80
|
(command: string, data?: unknown, options?: unknown): Promise<PushResult>;
|
|
85
81
|
}
|
|
86
|
-
interface Instance$
|
|
82
|
+
interface Instance$3 {
|
|
87
83
|
push: PushFn$1;
|
|
88
84
|
command: CommandFn;
|
|
89
85
|
allowed: boolean;
|
|
90
|
-
config: Config$
|
|
86
|
+
config: Config$6;
|
|
91
87
|
consent: Consent;
|
|
92
88
|
count: number;
|
|
93
89
|
custom: Properties;
|
|
@@ -96,6 +92,7 @@ interface Instance$2 {
|
|
|
96
92
|
globals: Properties;
|
|
97
93
|
group: string;
|
|
98
94
|
hooks: Functions;
|
|
95
|
+
logger: Instance$1;
|
|
99
96
|
on: OnConfig;
|
|
100
97
|
queue: Events;
|
|
101
98
|
round: number;
|
|
@@ -111,7 +108,7 @@ type collector_InitConfig = InitConfig;
|
|
|
111
108
|
type collector_SessionData = SessionData;
|
|
112
109
|
type collector_Sources = Sources;
|
|
113
110
|
declare namespace collector {
|
|
114
|
-
export type { collector_CommandFn as CommandFn, collector_CommandType as CommandType, Config$
|
|
111
|
+
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 };
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
interface Contract$1 {
|
|
@@ -182,10 +179,11 @@ interface BaseEnv$1 {
|
|
|
182
179
|
}
|
|
183
180
|
/**
|
|
184
181
|
* Type bundle for destination generics.
|
|
185
|
-
* Groups Settings, Mapping, and Env into a single type parameter.
|
|
182
|
+
* Groups Settings, InitSettings, Mapping, and Env into a single type parameter.
|
|
186
183
|
*/
|
|
187
|
-
interface Types$2<S = unknown, M = unknown, E = BaseEnv$1> {
|
|
184
|
+
interface Types$2<S = unknown, M = unknown, E = BaseEnv$1, I = S> {
|
|
188
185
|
settings: S;
|
|
186
|
+
initSettings: I;
|
|
189
187
|
mapping: M;
|
|
190
188
|
env: E;
|
|
191
189
|
}
|
|
@@ -194,6 +192,7 @@ interface Types$2<S = unknown, M = unknown, E = BaseEnv$1> {
|
|
|
194
192
|
*/
|
|
195
193
|
type TypesGeneric$1 = {
|
|
196
194
|
settings: any;
|
|
195
|
+
initSettings: any;
|
|
197
196
|
mapping: any;
|
|
198
197
|
env: any;
|
|
199
198
|
};
|
|
@@ -201,14 +200,15 @@ type TypesGeneric$1 = {
|
|
|
201
200
|
* Type extractors for consistent usage with Types bundle
|
|
202
201
|
*/
|
|
203
202
|
type Settings$1<T extends TypesGeneric$1 = Types$2> = T['settings'];
|
|
203
|
+
type InitSettings$1<T extends TypesGeneric$1 = Types$2> = T['initSettings'];
|
|
204
204
|
type Mapping$1<T extends TypesGeneric$1 = Types$2> = T['mapping'];
|
|
205
205
|
type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
|
|
206
206
|
/**
|
|
207
207
|
* Inference helper: Extract Types from Instance
|
|
208
208
|
*/
|
|
209
|
-
type TypesOf$1<I> = I extends Instance$
|
|
210
|
-
interface Instance$
|
|
211
|
-
config: Config$
|
|
209
|
+
type TypesOf$1<I> = I extends Instance$2<infer T> ? T : never;
|
|
210
|
+
interface Instance$2<T extends TypesGeneric$1 = Types$2> {
|
|
211
|
+
config: Config$5<T>;
|
|
212
212
|
queue?: Events;
|
|
213
213
|
dlq?: DLQ;
|
|
214
214
|
type?: string;
|
|
@@ -218,47 +218,47 @@ interface Instance$1<T extends TypesGeneric$1 = Types$2> {
|
|
|
218
218
|
pushBatch?: PushBatchFn<T>;
|
|
219
219
|
on?: OnFn;
|
|
220
220
|
}
|
|
221
|
-
interface Config$
|
|
221
|
+
interface Config$5<T extends TypesGeneric$1 = Types$2> {
|
|
222
222
|
consent?: Consent;
|
|
223
|
-
settings?:
|
|
223
|
+
settings?: InitSettings$1<T>;
|
|
224
224
|
data?: Value | Values;
|
|
225
225
|
env?: Env$1<T>;
|
|
226
226
|
id?: string;
|
|
227
227
|
init?: boolean;
|
|
228
228
|
loadScript?: boolean;
|
|
229
|
+
logger?: Config$3;
|
|
229
230
|
mapping?: Rules<Rule<Mapping$1<T>>>;
|
|
230
231
|
policy?: Policy$1;
|
|
231
232
|
queue?: boolean;
|
|
232
|
-
verbose?: boolean;
|
|
233
|
-
onError?: Error;
|
|
234
|
-
onLog?: Log;
|
|
235
233
|
}
|
|
236
|
-
type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$
|
|
234
|
+
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>>>;
|
|
237
235
|
interface Policy$1 {
|
|
238
236
|
[key: string]: Value;
|
|
239
237
|
}
|
|
240
238
|
type Init$1<T extends TypesGeneric$1 = Types$2> = {
|
|
241
|
-
code: Instance$
|
|
242
|
-
config?: Partial<Config$
|
|
239
|
+
code: Instance$2<T>;
|
|
240
|
+
config?: Partial<Config$5<T>>;
|
|
243
241
|
env?: Partial<Env$1<T>>;
|
|
244
242
|
};
|
|
245
243
|
interface InitDestinations {
|
|
246
244
|
[key: string]: Init$1<any>;
|
|
247
245
|
}
|
|
248
246
|
interface Destinations {
|
|
249
|
-
[key: string]: Instance$
|
|
247
|
+
[key: string]: Instance$2;
|
|
250
248
|
}
|
|
251
249
|
interface Context$2<T extends TypesGeneric$1 = Types$2> {
|
|
252
|
-
collector: Instance$
|
|
253
|
-
config: Config$
|
|
250
|
+
collector: Instance$3;
|
|
251
|
+
config: Config$5<T>;
|
|
254
252
|
data?: Data$1;
|
|
255
253
|
env: Env$1<T>;
|
|
254
|
+
logger: Instance$1;
|
|
256
255
|
}
|
|
257
256
|
interface InitContext<T extends TypesGeneric$1 = Types$2> {
|
|
258
|
-
collector: Instance$
|
|
259
|
-
config: Config$
|
|
257
|
+
collector: Instance$3;
|
|
258
|
+
config: Config$5<Types$2<Partial<Settings$1<T>>, Mapping$1<T>, Env$1<T>>>;
|
|
260
259
|
data?: Data$1;
|
|
261
260
|
env: Env$1<T>;
|
|
261
|
+
logger: Instance$1;
|
|
262
262
|
}
|
|
263
263
|
interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
264
264
|
mapping?: Rule<Mapping$1<T>>;
|
|
@@ -266,7 +266,7 @@ interface PushContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
|
266
266
|
interface PushBatchContext<T extends TypesGeneric$1 = Types$2> extends Context$2<T> {
|
|
267
267
|
mapping?: Rule<Mapping$1<T>>;
|
|
268
268
|
}
|
|
269
|
-
type InitFn<T extends TypesGeneric$1 = Types$2> = (context: InitContext<T>) => PromiseOrValue<void | false | Config$
|
|
269
|
+
type InitFn<T extends TypesGeneric$1 = Types$2> = (context: InitContext<T>) => PromiseOrValue<void | false | Config$5<T>>;
|
|
270
270
|
type PushFn<T extends TypesGeneric$1 = Types$2> = (event: Event, context: PushContext<T>) => PromiseOrValue<void>;
|
|
271
271
|
type PushBatchFn<T extends TypesGeneric$1 = Types$2> = (batch: Batch<Mapping$1<T>>, context: PushBatchContext<T>) => void;
|
|
272
272
|
type PushEvent<Mapping = unknown> = {
|
|
@@ -283,7 +283,7 @@ interface Batch<Mapping> {
|
|
|
283
283
|
type Data$1 = Property | undefined | Array<Property | undefined>;
|
|
284
284
|
type Ref = {
|
|
285
285
|
id: string;
|
|
286
|
-
destination: Instance$
|
|
286
|
+
destination: Instance$2;
|
|
287
287
|
};
|
|
288
288
|
type Push$1 = {
|
|
289
289
|
queue?: Events;
|
|
@@ -310,7 +310,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
|
310
310
|
type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
|
|
311
311
|
type destination_Ref = Ref;
|
|
312
312
|
declare namespace destination {
|
|
313
|
-
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$
|
|
313
|
+
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, 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 };
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
interface EventFn<R = Promise<PushResult>> {
|
|
@@ -323,7 +323,7 @@ interface Fn$1<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, Wa
|
|
|
323
323
|
interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
|
|
324
324
|
(event: 'walker config', config: Partial<Config>): R;
|
|
325
325
|
(event: 'walker consent', consent: Consent): R;
|
|
326
|
-
<T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$
|
|
326
|
+
<T extends Types$2>(event: 'walker destination', destination: Init$1<T> | Instance$2<T>, config?: Config$5<T>): R;
|
|
327
327
|
<K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
|
|
328
328
|
(event: 'walker on', type: Types$1, rules: SingleOrArray<Options>): R;
|
|
329
329
|
(event: 'walker user', user: User): R;
|
|
@@ -358,7 +358,7 @@ declare namespace elb {
|
|
|
358
358
|
* Platform-agnostic, runtime-focused.
|
|
359
359
|
*
|
|
360
360
|
* The Flow system enables "one config to rule them all" - a single
|
|
361
|
-
* walkeros.config.json file that manages multiple
|
|
361
|
+
* walkeros.config.json file that manages multiple flows
|
|
362
362
|
* (web_prod, web_stage, server_prod, etc.) with shared configuration,
|
|
363
363
|
* variables, and reusable definitions.
|
|
364
364
|
*
|
|
@@ -370,25 +370,68 @@ declare namespace elb {
|
|
|
370
370
|
*/
|
|
371
371
|
type Primitive = string | number | boolean;
|
|
372
372
|
/**
|
|
373
|
-
*
|
|
374
|
-
*
|
|
373
|
+
* Variables record type for interpolation.
|
|
374
|
+
* Used at Setup, Config, Source, and Destination levels.
|
|
375
|
+
*/
|
|
376
|
+
type Variables = Record<string, Primitive>;
|
|
377
|
+
/**
|
|
378
|
+
* Definitions record type for reusable configurations.
|
|
379
|
+
* Used at Setup, Config, Source, and Destination levels.
|
|
380
|
+
*/
|
|
381
|
+
type Definitions = Record<string, unknown>;
|
|
382
|
+
/**
|
|
383
|
+
* Packages configuration for build.
|
|
384
|
+
*/
|
|
385
|
+
type Packages = Record<string, {
|
|
386
|
+
version?: string;
|
|
387
|
+
imports?: string[];
|
|
388
|
+
path?: string;
|
|
389
|
+
}>;
|
|
390
|
+
/**
|
|
391
|
+
* Web platform configuration.
|
|
392
|
+
*
|
|
393
|
+
* @remarks
|
|
394
|
+
* Presence of this key indicates web platform (browser-based tracking).
|
|
395
|
+
* Builds to IIFE format, ES2020 target, browser platform.
|
|
396
|
+
*/
|
|
397
|
+
interface Web {
|
|
398
|
+
/**
|
|
399
|
+
* Window property name for collector instance.
|
|
400
|
+
* @default "collector"
|
|
401
|
+
*/
|
|
402
|
+
windowCollector?: string;
|
|
403
|
+
/**
|
|
404
|
+
* Window property name for elb function.
|
|
405
|
+
* @default "elb"
|
|
406
|
+
*/
|
|
407
|
+
windowElb?: string;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Server platform configuration.
|
|
411
|
+
*
|
|
412
|
+
* @remarks
|
|
413
|
+
* Presence of this key indicates server platform (Node.js).
|
|
414
|
+
* Builds to ESM format, Node18 target, node platform.
|
|
415
|
+
* Reserved for future server-specific options.
|
|
416
|
+
*/
|
|
417
|
+
interface Server {
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Complete multi-flow configuration.
|
|
421
|
+
* Root type for walkeros.config.json files.
|
|
375
422
|
*
|
|
376
423
|
* @remarks
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* and definitions.
|
|
424
|
+
* If only one flow exists, it's auto-selected without --flow flag.
|
|
425
|
+
* Convention: use "default" as the flow name for single-flow configs.
|
|
380
426
|
*
|
|
381
427
|
* @example
|
|
382
428
|
* ```json
|
|
383
429
|
* {
|
|
384
430
|
* "version": 1,
|
|
385
431
|
* "$schema": "https://walkeros.io/schema/flow/v1.json",
|
|
386
|
-
* "variables": {
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* "environments": {
|
|
390
|
-
* "web_prod": { "platform": "web", ... },
|
|
391
|
-
* "server_prod": { "platform": "server", ... }
|
|
432
|
+
* "variables": { "CURRENCY": "USD" },
|
|
433
|
+
* "flows": {
|
|
434
|
+
* "default": { "web": {}, ... }
|
|
392
435
|
* }
|
|
393
436
|
* }
|
|
394
437
|
* ```
|
|
@@ -396,141 +439,71 @@ type Primitive = string | number | boolean;
|
|
|
396
439
|
interface Setup {
|
|
397
440
|
/**
|
|
398
441
|
* Configuration schema version.
|
|
399
|
-
* Used for compatibility checks and migrations.
|
|
400
|
-
*
|
|
401
|
-
* @remarks
|
|
402
|
-
* - Version 1: Initial Flow configuration system
|
|
403
|
-
* - Future versions will be documented as they're released
|
|
404
442
|
*/
|
|
405
443
|
version: 1;
|
|
406
444
|
/**
|
|
407
|
-
* JSON Schema reference for IDE validation
|
|
408
|
-
*
|
|
409
|
-
* @remarks
|
|
410
|
-
* When set, IDEs like VSCode will provide:
|
|
411
|
-
* - Autocomplete for all fields
|
|
412
|
-
* - Inline documentation
|
|
413
|
-
* - Validation errors before deployment
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* "$schema": "https://walkeros.io/schema/flow/v1.json"
|
|
445
|
+
* JSON Schema reference for IDE validation.
|
|
446
|
+
* @example "https://walkeros.io/schema/flow/v1.json"
|
|
417
447
|
*/
|
|
418
448
|
$schema?: string;
|
|
419
449
|
/**
|
|
420
|
-
*
|
|
450
|
+
* Folders to include in the bundle output.
|
|
451
|
+
* These folders are copied to dist/ during bundle, making them available
|
|
452
|
+
* at runtime for both local and Docker execution.
|
|
421
453
|
*
|
|
422
454
|
* @remarks
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
* 2. Config variable (config.variables.VAR_NAME)
|
|
427
|
-
* 3. Inline default value
|
|
455
|
+
* Use for credential files, configuration, or other runtime assets.
|
|
456
|
+
* Paths are relative to the config file location.
|
|
457
|
+
* Default: `["./shared"]` if the folder exists, otherwise `[]`.
|
|
428
458
|
*
|
|
429
459
|
* @example
|
|
430
460
|
* ```json
|
|
431
461
|
* {
|
|
432
|
-
* "
|
|
433
|
-
* "CURRENCY": "USD",
|
|
434
|
-
* "GA4_ID": "G-DEFAULT"
|
|
435
|
-
* },
|
|
436
|
-
* "environments": {
|
|
437
|
-
* "prod": {
|
|
438
|
-
* "collector": {
|
|
439
|
-
* "globals": {
|
|
440
|
-
* "currency": "${CURRENCY}"
|
|
441
|
-
* }
|
|
442
|
-
* }
|
|
443
|
-
* }
|
|
444
|
-
* }
|
|
462
|
+
* "include": ["./credentials", "./config"]
|
|
445
463
|
* }
|
|
446
464
|
* ```
|
|
447
465
|
*/
|
|
448
|
-
|
|
466
|
+
include?: string[];
|
|
467
|
+
/**
|
|
468
|
+
* Shared variables for interpolation.
|
|
469
|
+
* Resolution: process.env > Config.variables > Setup.variables > inline default
|
|
470
|
+
* Syntax: ${VAR_NAME} or ${VAR_NAME:default}
|
|
471
|
+
*/
|
|
472
|
+
variables?: Variables;
|
|
449
473
|
/**
|
|
450
474
|
* Reusable configuration definitions.
|
|
451
|
-
*
|
|
452
|
-
* @remarks
|
|
453
|
-
* Definitions can be referenced using JSON Schema `$ref` syntax.
|
|
454
|
-
* Useful for sharing mapping rules, common settings, etc.
|
|
455
|
-
*
|
|
456
|
-
* @example
|
|
457
|
-
* ```json
|
|
458
|
-
* {
|
|
459
|
-
* "definitions": {
|
|
460
|
-
* "gtag_base_mapping": {
|
|
461
|
-
* "page": {
|
|
462
|
-
* "view": { "name": "page_view" }
|
|
463
|
-
* }
|
|
464
|
-
* }
|
|
465
|
-
* },
|
|
466
|
-
* "environments": {
|
|
467
|
-
* "prod": {
|
|
468
|
-
* "destinations": {
|
|
469
|
-
* "gtag": {
|
|
470
|
-
* "config": {
|
|
471
|
-
* "mapping": { "$ref": "#/definitions/gtag_base_mapping" }
|
|
472
|
-
* }
|
|
473
|
-
* }
|
|
474
|
-
* }
|
|
475
|
-
* }
|
|
476
|
-
* }
|
|
477
|
-
* }
|
|
478
|
-
* ```
|
|
475
|
+
* Referenced via JSON Schema $ref syntax: { "$ref": "#/definitions/name" }
|
|
479
476
|
*/
|
|
480
|
-
definitions?:
|
|
477
|
+
definitions?: Definitions;
|
|
481
478
|
/**
|
|
482
|
-
* Named
|
|
483
|
-
*
|
|
484
|
-
* @remarks
|
|
485
|
-
* Each environment represents a deployment target:
|
|
486
|
-
* - web_prod, web_stage, web_dev (client-side tracking)
|
|
487
|
-
* - server_prod, server_stage (server-side collection)
|
|
488
|
-
*
|
|
489
|
-
* Environment names are arbitrary and user-defined.
|
|
490
|
-
*
|
|
491
|
-
* @example
|
|
492
|
-
* ```json
|
|
493
|
-
* {
|
|
494
|
-
* "environments": {
|
|
495
|
-
* "web_prod": {
|
|
496
|
-
* "platform": "web",
|
|
497
|
-
* "sources": { ... },
|
|
498
|
-
* "destinations": { ... }
|
|
499
|
-
* },
|
|
500
|
-
* "server_prod": {
|
|
501
|
-
* "platform": "server",
|
|
502
|
-
* "destinations": { ... }
|
|
503
|
-
* }
|
|
504
|
-
* }
|
|
505
|
-
* }
|
|
506
|
-
* ```
|
|
479
|
+
* Named flow configurations.
|
|
480
|
+
* If only one flow exists, it's auto-selected.
|
|
507
481
|
*/
|
|
508
|
-
|
|
482
|
+
flows: Record<string, Config$4>;
|
|
509
483
|
}
|
|
510
484
|
/**
|
|
511
|
-
* Single
|
|
485
|
+
* Single flow configuration.
|
|
512
486
|
* Represents one deployment target (e.g., web_prod, server_stage).
|
|
513
487
|
*
|
|
514
488
|
* @remarks
|
|
515
|
-
*
|
|
516
|
-
*
|
|
489
|
+
* Platform is determined by presence of `web` or `server` key.
|
|
490
|
+
* Exactly one must be present.
|
|
517
491
|
*
|
|
518
|
-
*
|
|
492
|
+
* Variables/definitions cascade: source/destination > config > setup
|
|
519
493
|
*/
|
|
520
|
-
interface Config$
|
|
494
|
+
interface Config$4 {
|
|
521
495
|
/**
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
* - Template selection
|
|
496
|
+
* Web platform configuration.
|
|
497
|
+
* Presence indicates web platform (browser-based tracking).
|
|
498
|
+
* Mutually exclusive with `server`.
|
|
499
|
+
*/
|
|
500
|
+
web?: Web;
|
|
501
|
+
/**
|
|
502
|
+
* Server platform configuration.
|
|
503
|
+
* Presence indicates server platform (Node.js).
|
|
504
|
+
* Mutually exclusive with `web`.
|
|
532
505
|
*/
|
|
533
|
-
|
|
506
|
+
server?: Server;
|
|
534
507
|
/**
|
|
535
508
|
* Source configurations (data capture).
|
|
536
509
|
*
|
|
@@ -625,35 +598,19 @@ interface Config$3 {
|
|
|
625
598
|
*/
|
|
626
599
|
collector?: InitConfig;
|
|
627
600
|
/**
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
* @remarks
|
|
631
|
-
* These override root-level variables for this specific environment.
|
|
632
|
-
* Useful for environment-specific API keys, endpoints, etc.
|
|
633
|
-
*
|
|
634
|
-
* @example
|
|
635
|
-
* ```json
|
|
636
|
-
* {
|
|
637
|
-
* "env": {
|
|
638
|
-
* "API_ENDPOINT": "https://api.production.com",
|
|
639
|
-
* "DEBUG": "false"
|
|
640
|
-
* }
|
|
641
|
-
* }
|
|
642
|
-
* ```
|
|
601
|
+
* NPM packages to bundle.
|
|
643
602
|
*/
|
|
644
|
-
|
|
603
|
+
packages?: Packages;
|
|
645
604
|
/**
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
* @remarks
|
|
649
|
-
* Allows packages to add their own configuration fields:
|
|
650
|
-
* - CLI adds `build` field (Bundle.Config)
|
|
651
|
-
* - Docker adds `docker` field (Docker.Config)
|
|
652
|
-
* - Lambda adds `lambda` field (Lambda.Config)
|
|
653
|
-
*
|
|
654
|
-
* Core doesn't validate these fields - packages handle validation.
|
|
605
|
+
* Flow-level variables.
|
|
606
|
+
* Override Setup.variables, overridden by source/destination variables.
|
|
655
607
|
*/
|
|
656
|
-
|
|
608
|
+
variables?: Variables;
|
|
609
|
+
/**
|
|
610
|
+
* Flow-level definitions.
|
|
611
|
+
* Extend Setup.definitions, overridden by source/destination definitions.
|
|
612
|
+
*/
|
|
613
|
+
definitions?: Definitions;
|
|
657
614
|
}
|
|
658
615
|
/**
|
|
659
616
|
* Source reference with inline package syntax.
|
|
@@ -682,6 +639,14 @@ interface SourceReference {
|
|
|
682
639
|
* "package": "@walkeros/web-source-browser@latest"
|
|
683
640
|
*/
|
|
684
641
|
package: string;
|
|
642
|
+
/**
|
|
643
|
+
* Resolved import variable name.
|
|
644
|
+
*
|
|
645
|
+
* @remarks
|
|
646
|
+
* Auto-resolved from packages[package].imports[0] during getFlowConfig().
|
|
647
|
+
* Can also be provided explicitly for advanced use cases.
|
|
648
|
+
*/
|
|
649
|
+
code?: string;
|
|
685
650
|
/**
|
|
686
651
|
* Source-specific configuration.
|
|
687
652
|
*
|
|
@@ -717,11 +682,21 @@ interface SourceReference {
|
|
|
717
682
|
*
|
|
718
683
|
* @remarks
|
|
719
684
|
* The primary source's ELB function is returned by `startFlow()`.
|
|
720
|
-
* Only one source should be marked as primary per
|
|
685
|
+
* Only one source should be marked as primary per flow.
|
|
721
686
|
*
|
|
722
687
|
* @default false
|
|
723
688
|
*/
|
|
724
689
|
primary?: boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Source-level variables (highest priority in cascade).
|
|
692
|
+
* Overrides flow and setup variables.
|
|
693
|
+
*/
|
|
694
|
+
variables?: Variables;
|
|
695
|
+
/**
|
|
696
|
+
* Source-level definitions (highest priority in cascade).
|
|
697
|
+
* Overrides flow and setup definitions.
|
|
698
|
+
*/
|
|
699
|
+
definitions?: Definitions;
|
|
725
700
|
}
|
|
726
701
|
/**
|
|
727
702
|
* Destination reference with inline package syntax.
|
|
@@ -741,6 +716,14 @@ interface DestinationReference {
|
|
|
741
716
|
* "package": "@walkeros/web-destination-gtag@2.0.0"
|
|
742
717
|
*/
|
|
743
718
|
package: string;
|
|
719
|
+
/**
|
|
720
|
+
* Resolved import variable name.
|
|
721
|
+
*
|
|
722
|
+
* @remarks
|
|
723
|
+
* Auto-resolved from packages[package].imports[0] during getFlowConfig().
|
|
724
|
+
* Can also be provided explicitly for advanced use cases.
|
|
725
|
+
*/
|
|
726
|
+
code?: string;
|
|
744
727
|
/**
|
|
745
728
|
* Destination-specific configuration.
|
|
746
729
|
*
|
|
@@ -782,23 +765,29 @@ interface DestinationReference {
|
|
|
782
765
|
* Merged with default destination environment.
|
|
783
766
|
*/
|
|
784
767
|
env?: unknown;
|
|
768
|
+
/**
|
|
769
|
+
* Destination-level variables (highest priority in cascade).
|
|
770
|
+
* Overrides flow and setup variables.
|
|
771
|
+
*/
|
|
772
|
+
variables?: Variables;
|
|
773
|
+
/**
|
|
774
|
+
* Destination-level definitions (highest priority in cascade).
|
|
775
|
+
* Overrides flow and setup definitions.
|
|
776
|
+
*/
|
|
777
|
+
definitions?: Definitions;
|
|
785
778
|
}
|
|
786
779
|
|
|
780
|
+
type flow_Definitions = Definitions;
|
|
787
781
|
type flow_DestinationReference = DestinationReference;
|
|
782
|
+
type flow_Packages = Packages;
|
|
788
783
|
type flow_Primitive = Primitive;
|
|
784
|
+
type flow_Server = Server;
|
|
789
785
|
type flow_Setup = Setup;
|
|
790
786
|
type flow_SourceReference = SourceReference;
|
|
787
|
+
type flow_Variables = Variables;
|
|
788
|
+
type flow_Web = Web;
|
|
791
789
|
declare namespace flow {
|
|
792
|
-
export type { Config$
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
type Error = (error: unknown, state?: unknown) => void;
|
|
796
|
-
type Log = (message: string, verbose?: boolean) => void;
|
|
797
|
-
|
|
798
|
-
type handler_Error = Error;
|
|
799
|
-
type handler_Log = Log;
|
|
800
|
-
declare namespace handler {
|
|
801
|
-
export type { handler_Error as Error, handler_Log as Log };
|
|
790
|
+
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 };
|
|
802
791
|
}
|
|
803
792
|
|
|
804
793
|
type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
|
|
@@ -817,6 +806,121 @@ declare namespace hooks {
|
|
|
817
806
|
export type { AnyFunction$1 as AnyFunction, hooks_Functions as Functions, hooks_HookFn as HookFn };
|
|
818
807
|
}
|
|
819
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Log levels from most to least severe
|
|
811
|
+
*/
|
|
812
|
+
declare enum Level {
|
|
813
|
+
ERROR = 0,
|
|
814
|
+
INFO = 1,
|
|
815
|
+
DEBUG = 2
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Normalized error context extracted from Error objects
|
|
819
|
+
*/
|
|
820
|
+
interface ErrorContext {
|
|
821
|
+
message: string;
|
|
822
|
+
name: string;
|
|
823
|
+
stack?: string;
|
|
824
|
+
cause?: unknown;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Context passed to log handlers
|
|
828
|
+
* If an Error was passed, it's normalized into the error property
|
|
829
|
+
*/
|
|
830
|
+
interface LogContext {
|
|
831
|
+
[key: string]: unknown;
|
|
832
|
+
error?: ErrorContext;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Log message function signature
|
|
836
|
+
* Accepts string or Error as message, with optional context
|
|
837
|
+
*/
|
|
838
|
+
type LogFn = (message: string | Error, context?: unknown | Error) => void;
|
|
839
|
+
/**
|
|
840
|
+
* Throw function signature - logs error then throws
|
|
841
|
+
* Returns never as it always throws
|
|
842
|
+
*/
|
|
843
|
+
type ThrowFn = (message: string | Error, context?: unknown) => never;
|
|
844
|
+
/**
|
|
845
|
+
* Default handler function (passed to custom handlers for chaining)
|
|
846
|
+
*/
|
|
847
|
+
type DefaultHandler = (level: Level, message: string, context: LogContext, scope: string[]) => void;
|
|
848
|
+
/**
|
|
849
|
+
* Custom log handler function
|
|
850
|
+
* Receives originalHandler to allow middleware-style chaining
|
|
851
|
+
*/
|
|
852
|
+
type Handler = (level: Level, message: string, context: LogContext, scope: string[], originalHandler: DefaultHandler) => void;
|
|
853
|
+
/**
|
|
854
|
+
* Logger instance with scoping support
|
|
855
|
+
* All logs automatically include trace path from scoping
|
|
856
|
+
*/
|
|
857
|
+
interface Instance$1 {
|
|
858
|
+
/**
|
|
859
|
+
* Log an error message (always visible unless silenced)
|
|
860
|
+
*/
|
|
861
|
+
error: LogFn;
|
|
862
|
+
/**
|
|
863
|
+
* Log an informational message
|
|
864
|
+
*/
|
|
865
|
+
info: LogFn;
|
|
866
|
+
/**
|
|
867
|
+
* Log a debug message
|
|
868
|
+
*/
|
|
869
|
+
debug: LogFn;
|
|
870
|
+
/**
|
|
871
|
+
* Log an error message and throw an Error
|
|
872
|
+
* Combines logging and throwing in one call
|
|
873
|
+
*/
|
|
874
|
+
throw: ThrowFn;
|
|
875
|
+
/**
|
|
876
|
+
* Create a scoped child logger with automatic trace path
|
|
877
|
+
* @param name - Scope name (e.g., destination type, destination key)
|
|
878
|
+
* @returns A new logger instance with the scope applied
|
|
879
|
+
*/
|
|
880
|
+
scope: (name: string) => Instance$1;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Logger configuration options
|
|
884
|
+
*/
|
|
885
|
+
interface Config$3 {
|
|
886
|
+
/**
|
|
887
|
+
* Minimum log level to display
|
|
888
|
+
* @default Level.ERROR
|
|
889
|
+
*/
|
|
890
|
+
level?: Level | keyof typeof Level;
|
|
891
|
+
/**
|
|
892
|
+
* Custom log handler function
|
|
893
|
+
* Receives originalHandler to preserve default behavior
|
|
894
|
+
*/
|
|
895
|
+
handler?: Handler;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Internal config with resolved values and scope
|
|
899
|
+
*/
|
|
900
|
+
interface InternalConfig {
|
|
901
|
+
level: Level;
|
|
902
|
+
handler?: Handler;
|
|
903
|
+
scope: string[];
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Logger factory function type
|
|
907
|
+
*/
|
|
908
|
+
type Factory = (config?: Config$3) => Instance$1;
|
|
909
|
+
|
|
910
|
+
type logger_DefaultHandler = DefaultHandler;
|
|
911
|
+
type logger_ErrorContext = ErrorContext;
|
|
912
|
+
type logger_Factory = Factory;
|
|
913
|
+
type logger_Handler = Handler;
|
|
914
|
+
type logger_InternalConfig = InternalConfig;
|
|
915
|
+
type logger_Level = Level;
|
|
916
|
+
declare const logger_Level: typeof Level;
|
|
917
|
+
type logger_LogContext = LogContext;
|
|
918
|
+
type logger_LogFn = LogFn;
|
|
919
|
+
type logger_ThrowFn = ThrowFn;
|
|
920
|
+
declare namespace logger {
|
|
921
|
+
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 };
|
|
922
|
+
}
|
|
923
|
+
|
|
820
924
|
/**
|
|
821
925
|
* Shared mapping configuration interface.
|
|
822
926
|
* Used by both Source.Config and Destination.Config.
|
|
@@ -835,7 +939,7 @@ interface Rules<T = Rule> {
|
|
|
835
939
|
}
|
|
836
940
|
interface Rule<Settings = unknown> {
|
|
837
941
|
batch?: number;
|
|
838
|
-
batchFn?: (destination: Instance$
|
|
942
|
+
batchFn?: (destination: Instance$2, collector: Instance$3) => void;
|
|
839
943
|
batched?: Batch<Settings>;
|
|
840
944
|
condition?: Condition;
|
|
841
945
|
consent?: Consent;
|
|
@@ -864,7 +968,7 @@ interface ValueConfig {
|
|
|
864
968
|
validate?: Validate;
|
|
865
969
|
value?: PropertyType;
|
|
866
970
|
}
|
|
867
|
-
type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$
|
|
971
|
+
type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$3) => PromiseOrValue<boolean>;
|
|
868
972
|
type Fn = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
|
|
869
973
|
type Loop = [Value, Value];
|
|
870
974
|
type Map = {
|
|
@@ -872,7 +976,7 @@ type Map = {
|
|
|
872
976
|
};
|
|
873
977
|
interface Options$1 {
|
|
874
978
|
consent?: Consent;
|
|
875
|
-
collector?: Instance$
|
|
979
|
+
collector?: Instance$3;
|
|
876
980
|
props?: unknown;
|
|
877
981
|
}
|
|
878
982
|
type Validate = (value?: unknown) => PromiseOrValue<boolean>;
|
|
@@ -918,13 +1022,13 @@ type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
|
|
|
918
1022
|
interface ConsentConfig {
|
|
919
1023
|
[key: string]: ConsentFn;
|
|
920
1024
|
}
|
|
921
|
-
type ConsentFn = (collector: Instance$
|
|
1025
|
+
type ConsentFn = (collector: Instance$3, consent: Consent) => void;
|
|
922
1026
|
type ReadyConfig = ReadyFn;
|
|
923
|
-
type ReadyFn = (collector: Instance$
|
|
1027
|
+
type ReadyFn = (collector: Instance$3) => void;
|
|
924
1028
|
type RunConfig = RunFn;
|
|
925
|
-
type RunFn = (collector: Instance$
|
|
1029
|
+
type RunFn = (collector: Instance$3) => void;
|
|
926
1030
|
type SessionConfig = SessionFn;
|
|
927
|
-
type SessionFn = (collector: Instance$
|
|
1031
|
+
type SessionFn = (collector: Instance$3, session?: unknown) => void;
|
|
928
1032
|
interface OnConfig {
|
|
929
1033
|
consent?: ConsentConfig[];
|
|
930
1034
|
ready?: ReadyConfig[];
|
|
@@ -1012,18 +1116,21 @@ interface BaseEnv {
|
|
|
1012
1116
|
command: CommandFn;
|
|
1013
1117
|
sources?: Sources;
|
|
1014
1118
|
elb: Fn$1;
|
|
1119
|
+
logger: Instance$1;
|
|
1015
1120
|
}
|
|
1016
1121
|
/**
|
|
1017
1122
|
* Type bundle for source generics.
|
|
1018
|
-
* Groups Settings, Mapping, Push, and
|
|
1123
|
+
* Groups Settings, Mapping, Push, Env, and InitSettings into a single type parameter.
|
|
1019
1124
|
*
|
|
1020
1125
|
* @template S - Settings configuration type
|
|
1021
1126
|
* @template M - Mapping configuration type
|
|
1022
1127
|
* @template P - Push function signature (flexible to support HTTP handlers, etc.)
|
|
1023
1128
|
* @template E - Environment dependencies type
|
|
1129
|
+
* @template I - InitSettings configuration type (user input)
|
|
1024
1130
|
*/
|
|
1025
|
-
interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> {
|
|
1131
|
+
interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> {
|
|
1026
1132
|
settings: S;
|
|
1133
|
+
initSettings: I;
|
|
1027
1134
|
mapping: M;
|
|
1028
1135
|
push: P;
|
|
1029
1136
|
env: E;
|
|
@@ -1033,6 +1140,7 @@ interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> {
|
|
|
1033
1140
|
*/
|
|
1034
1141
|
type TypesGeneric = {
|
|
1035
1142
|
settings: any;
|
|
1143
|
+
initSettings: any;
|
|
1036
1144
|
mapping: any;
|
|
1037
1145
|
push: any;
|
|
1038
1146
|
env: any;
|
|
@@ -1041,6 +1149,7 @@ type TypesGeneric = {
|
|
|
1041
1149
|
* Type extractors for consistent usage with Types bundle
|
|
1042
1150
|
*/
|
|
1043
1151
|
type Settings<T extends TypesGeneric = Types> = T['settings'];
|
|
1152
|
+
type InitSettings<T extends TypesGeneric = Types> = T['initSettings'];
|
|
1044
1153
|
type Mapping<T extends TypesGeneric = Types> = T['mapping'];
|
|
1045
1154
|
type Push<T extends TypesGeneric = Types> = T['push'];
|
|
1046
1155
|
type Env<T extends TypesGeneric = Types> = T['env'];
|
|
@@ -1049,10 +1158,10 @@ type Env<T extends TypesGeneric = Types> = T['env'];
|
|
|
1049
1158
|
*/
|
|
1050
1159
|
type TypesOf<I> = I extends Instance<infer T> ? T : never;
|
|
1051
1160
|
interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
|
|
1052
|
-
settings?:
|
|
1161
|
+
settings?: InitSettings<T>;
|
|
1053
1162
|
env?: Env<T>;
|
|
1054
1163
|
id?: string;
|
|
1055
|
-
|
|
1164
|
+
logger?: Config$3;
|
|
1056
1165
|
disabled?: boolean;
|
|
1057
1166
|
primary?: boolean;
|
|
1058
1167
|
}
|
|
@@ -1083,6 +1192,7 @@ type source_BaseEnv = BaseEnv;
|
|
|
1083
1192
|
type source_Config<T extends TypesGeneric = Types> = Config<T>;
|
|
1084
1193
|
type source_Env<T extends TypesGeneric = Types> = Env<T>;
|
|
1085
1194
|
type source_Init<T extends TypesGeneric = Types> = Init<T>;
|
|
1195
|
+
type source_InitSettings<T extends TypesGeneric = Types> = InitSettings<T>;
|
|
1086
1196
|
type source_InitSource<T extends TypesGeneric = Types> = InitSource<T>;
|
|
1087
1197
|
type source_InitSources = InitSources;
|
|
1088
1198
|
type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
|
|
@@ -1090,11 +1200,11 @@ type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
|
|
|
1090
1200
|
type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
|
|
1091
1201
|
type source_Push<T extends TypesGeneric = Types> = Push<T>;
|
|
1092
1202
|
type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
|
|
1093
|
-
type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> = Types<S, M, P, E>;
|
|
1203
|
+
type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> = Types<S, M, P, E, I>;
|
|
1094
1204
|
type source_TypesGeneric = TypesGeneric;
|
|
1095
1205
|
type source_TypesOf<I> = TypesOf<I>;
|
|
1096
1206
|
declare namespace source {
|
|
1097
|
-
export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
|
|
1207
|
+
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 };
|
|
1098
1208
|
}
|
|
1099
1209
|
|
|
1100
1210
|
type AnyObject<T = unknown> = Record<string, T>;
|
|
@@ -1241,6 +1351,53 @@ interface SendResponse {
|
|
|
1241
1351
|
*/
|
|
1242
1352
|
declare function anonymizeIP(ip: string): string;
|
|
1243
1353
|
|
|
1354
|
+
/**
|
|
1355
|
+
* Flow Configuration Utilities
|
|
1356
|
+
*
|
|
1357
|
+
* Functions for resolving and processing Flow configurations.
|
|
1358
|
+
*
|
|
1359
|
+
* @packageDocumentation
|
|
1360
|
+
*/
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Get resolved flow configuration for a named flow.
|
|
1364
|
+
*
|
|
1365
|
+
* @param setup - The complete setup configuration
|
|
1366
|
+
* @param flowName - Flow name (auto-selected if only one exists)
|
|
1367
|
+
* @returns Resolved Config with variables/definitions interpolated and $refs resolved
|
|
1368
|
+
* @throws Error if flow selection is required but not specified, or flow not found
|
|
1369
|
+
*
|
|
1370
|
+
* @example
|
|
1371
|
+
* ```typescript
|
|
1372
|
+
* import { getFlowConfig } from '@walkeros/core';
|
|
1373
|
+
*
|
|
1374
|
+
* const setup = JSON.parse(fs.readFileSync('walkeros.config.json', 'utf8'));
|
|
1375
|
+
*
|
|
1376
|
+
* // Auto-select if only one flow
|
|
1377
|
+
* const config = getFlowConfig(setup);
|
|
1378
|
+
*
|
|
1379
|
+
* // Or specify flow
|
|
1380
|
+
* const prodConfig = getFlowConfig(setup, 'production');
|
|
1381
|
+
* ```
|
|
1382
|
+
*/
|
|
1383
|
+
declare function getFlowConfig(setup: Setup, flowName?: string): Config$4;
|
|
1384
|
+
/**
|
|
1385
|
+
* Get platform from config (web or server).
|
|
1386
|
+
*
|
|
1387
|
+
* @param config - Flow configuration
|
|
1388
|
+
* @returns "web" or "server"
|
|
1389
|
+
* @throws Error if neither web nor server is present
|
|
1390
|
+
*
|
|
1391
|
+
* @example
|
|
1392
|
+
* ```typescript
|
|
1393
|
+
* import { getPlatform } from '@walkeros/core';
|
|
1394
|
+
*
|
|
1395
|
+
* const platform = getPlatform(config);
|
|
1396
|
+
* // Returns "web" or "server"
|
|
1397
|
+
* ```
|
|
1398
|
+
*/
|
|
1399
|
+
declare function getPlatform(config: Config$4): 'web' | 'server';
|
|
1400
|
+
|
|
1244
1401
|
/**
|
|
1245
1402
|
* @interface Assign
|
|
1246
1403
|
* @description Options for the assign function.
|
|
@@ -1335,7 +1492,7 @@ declare function getGrantedConsent(required: Consent | undefined, state?: Consen
|
|
|
1335
1492
|
* }));
|
|
1336
1493
|
* ```
|
|
1337
1494
|
*/
|
|
1338
|
-
declare function createDestination<I extends Instance$
|
|
1495
|
+
declare function createDestination<I extends Instance$2>(baseDestination: I, config: Partial<Config$5<TypesOf$1<I>>>): I;
|
|
1339
1496
|
|
|
1340
1497
|
/**
|
|
1341
1498
|
* Creates a complete event with default values.
|
|
@@ -1469,6 +1626,36 @@ declare function isSameType<T>(variable: unknown, type: T): variable is typeof t
|
|
|
1469
1626
|
*/
|
|
1470
1627
|
declare function isString(value: unknown): value is string;
|
|
1471
1628
|
|
|
1629
|
+
/**
|
|
1630
|
+
* Create a logger instance
|
|
1631
|
+
*
|
|
1632
|
+
* @param config - Logger configuration
|
|
1633
|
+
* @returns Logger instance with all log methods and scoping support
|
|
1634
|
+
*
|
|
1635
|
+
* @example
|
|
1636
|
+
* ```typescript
|
|
1637
|
+
* // Basic usage
|
|
1638
|
+
* const logger = createLogger({ level: 'DEBUG' });
|
|
1639
|
+
* logger.info('Hello world');
|
|
1640
|
+
*
|
|
1641
|
+
* // With scoping
|
|
1642
|
+
* const destLogger = logger.scope('gtag').scope('myInstance');
|
|
1643
|
+
* destLogger.debug('Processing event'); // DEBUG [gtag:myInstance] Processing event
|
|
1644
|
+
*
|
|
1645
|
+
* // With custom handler
|
|
1646
|
+
* const logger = createLogger({
|
|
1647
|
+
* handler: (level, message, context, scope, originalHandler) => {
|
|
1648
|
+
* // Custom logic (e.g., send to Sentry)
|
|
1649
|
+
* originalHandler(level, message, context, scope);
|
|
1650
|
+
* }
|
|
1651
|
+
* });
|
|
1652
|
+
* ```
|
|
1653
|
+
*
|
|
1654
|
+
* // TODO: Consider compile-time stripping of debug logs in production builds
|
|
1655
|
+
* // e.g., if (__DEV__) { logger.debug(...) }
|
|
1656
|
+
*/
|
|
1657
|
+
declare function createLogger(config?: Config$3): Instance$1;
|
|
1658
|
+
|
|
1472
1659
|
/**
|
|
1473
1660
|
* Gets the mapping for an event.
|
|
1474
1661
|
*
|
|
@@ -1505,7 +1692,7 @@ declare function getMappingValue(value: DeepPartialEvent | unknown | undefined,
|
|
|
1505
1692
|
* @param collector - Collector instance for context
|
|
1506
1693
|
* @returns Object with transformed event, data, mapping rule, and ignore flag
|
|
1507
1694
|
*/
|
|
1508
|
-
declare function processEventMapping<T extends DeepPartialEvent | Event>(event: T, config: Config$2, collector: Instance$
|
|
1695
|
+
declare function processEventMapping<T extends DeepPartialEvent | Event>(event: T, config: Config$2, collector: Instance$3): Promise<{
|
|
1509
1696
|
event: T;
|
|
1510
1697
|
data?: Property;
|
|
1511
1698
|
mapping?: Rule;
|
|
@@ -1580,12 +1767,42 @@ declare function mockEnv<T extends object>(env: T, interceptor: InterceptorFn):
|
|
|
1580
1767
|
declare function traverseEnv<T extends object>(env: T, replacer: (value: unknown, path: string[]) => unknown): T;
|
|
1581
1768
|
|
|
1582
1769
|
/**
|
|
1583
|
-
*
|
|
1770
|
+
* Mock logger instance for testing
|
|
1771
|
+
* Includes all logger methods as jest.fn() plus tracking of scoped loggers
|
|
1772
|
+
* Extends Instance to ensure type compatibility
|
|
1773
|
+
*/
|
|
1774
|
+
interface MockLogger extends Instance$1 {
|
|
1775
|
+
error: jest.Mock;
|
|
1776
|
+
info: jest.Mock;
|
|
1777
|
+
debug: jest.Mock;
|
|
1778
|
+
throw: jest.Mock<never, [string | Error, unknown?]>;
|
|
1779
|
+
scope: jest.Mock<MockLogger, [string]>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Array of all scoped loggers created by this logger
|
|
1782
|
+
* Useful for asserting on scoped logger calls in tests
|
|
1783
|
+
*/
|
|
1784
|
+
scopedLoggers: MockLogger[];
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Create a mock logger for testing
|
|
1788
|
+
* All methods are jest.fn() that can be used for assertions
|
|
1789
|
+
*
|
|
1790
|
+
* @example
|
|
1791
|
+
* ```typescript
|
|
1792
|
+
* const mockLogger = createMockLogger();
|
|
1584
1793
|
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
1794
|
+
* // Use in code under test
|
|
1795
|
+
* someFunction(mockLogger);
|
|
1796
|
+
*
|
|
1797
|
+
* // Assert on calls
|
|
1798
|
+
* expect(mockLogger.error).toHaveBeenCalledWith('error message');
|
|
1799
|
+
*
|
|
1800
|
+
* // Assert on scoped logger
|
|
1801
|
+
* const scoped = mockLogger.scopedLoggers[0];
|
|
1802
|
+
* expect(scoped.debug).toHaveBeenCalledWith('debug in scope');
|
|
1803
|
+
* ```
|
|
1587
1804
|
*/
|
|
1588
|
-
declare function
|
|
1805
|
+
declare function createMockLogger(): MockLogger;
|
|
1589
1806
|
|
|
1590
1807
|
/**
|
|
1591
1808
|
* Checks if a value is a valid property type.
|
|
@@ -1750,4 +1967,87 @@ declare function validateEvent(obj: unknown, customContracts?: Contracts): Event
|
|
|
1750
1967
|
*/
|
|
1751
1968
|
declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
|
|
1752
1969
|
|
|
1753
|
-
|
|
1970
|
+
/**
|
|
1971
|
+
* Inline Code Wrapping Utilities
|
|
1972
|
+
*
|
|
1973
|
+
* Converts inline code strings to executable functions.
|
|
1974
|
+
* Used for mapping properties: condition, fn, validate.
|
|
1975
|
+
*
|
|
1976
|
+
* @packageDocumentation
|
|
1977
|
+
*/
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* Wrap inline code string as Condition function.
|
|
1981
|
+
*
|
|
1982
|
+
* @param code - Inline code string
|
|
1983
|
+
* @returns Condition function matching Mapping.Condition signature
|
|
1984
|
+
*
|
|
1985
|
+
* @remarks
|
|
1986
|
+
* Available parameters in code:
|
|
1987
|
+
* - `value` - The event or partial event being processed
|
|
1988
|
+
* - `mapping` - Current mapping configuration
|
|
1989
|
+
* - `collector` - Collector instance
|
|
1990
|
+
*
|
|
1991
|
+
* If code has no explicit return, it's auto-wrapped with `return`.
|
|
1992
|
+
*
|
|
1993
|
+
* @example
|
|
1994
|
+
* ```typescript
|
|
1995
|
+
* // One-liner (auto-wrapped)
|
|
1996
|
+
* const fn = wrapCondition('value.data.total > 100');
|
|
1997
|
+
* fn(event, mapping, collector); // returns boolean
|
|
1998
|
+
*
|
|
1999
|
+
* // Multi-statement (explicit return)
|
|
2000
|
+
* const fn = wrapCondition('const threshold = 100; return value.data.total > threshold');
|
|
2001
|
+
* ```
|
|
2002
|
+
*/
|
|
2003
|
+
declare function wrapCondition(code: string): Condition;
|
|
2004
|
+
/**
|
|
2005
|
+
* Wrap inline code string as Fn function.
|
|
2006
|
+
*
|
|
2007
|
+
* @param code - Inline code string
|
|
2008
|
+
* @returns Fn function matching Mapping.Fn signature
|
|
2009
|
+
*
|
|
2010
|
+
* @remarks
|
|
2011
|
+
* Available parameters in code:
|
|
2012
|
+
* - `value` - The event or partial event being processed
|
|
2013
|
+
* - `mapping` - Current mapping configuration
|
|
2014
|
+
* - `options` - Options object with consent and collector
|
|
2015
|
+
*
|
|
2016
|
+
* If code has no explicit return, it's auto-wrapped with `return`.
|
|
2017
|
+
*
|
|
2018
|
+
* @example
|
|
2019
|
+
* ```typescript
|
|
2020
|
+
* // One-liner (auto-wrapped)
|
|
2021
|
+
* const fn = wrapFn('value.user.email.split("@")[1]');
|
|
2022
|
+
* fn(event, mapping, options); // returns domain
|
|
2023
|
+
*
|
|
2024
|
+
* // Multi-statement (explicit return)
|
|
2025
|
+
* const fn = wrapFn('const parts = value.user.email.split("@"); return parts[1].toUpperCase()');
|
|
2026
|
+
* ```
|
|
2027
|
+
*/
|
|
2028
|
+
declare function wrapFn(code: string): Fn;
|
|
2029
|
+
/**
|
|
2030
|
+
* Wrap inline code string as Validate function.
|
|
2031
|
+
*
|
|
2032
|
+
* @param code - Inline code string
|
|
2033
|
+
* @returns Validate function matching Mapping.Validate signature
|
|
2034
|
+
*
|
|
2035
|
+
* @remarks
|
|
2036
|
+
* Available parameters in code:
|
|
2037
|
+
* - `value` - The current value being validated
|
|
2038
|
+
*
|
|
2039
|
+
* If code has no explicit return, it's auto-wrapped with `return`.
|
|
2040
|
+
*
|
|
2041
|
+
* @example
|
|
2042
|
+
* ```typescript
|
|
2043
|
+
* // One-liner (auto-wrapped)
|
|
2044
|
+
* const fn = wrapValidate('value && value.length > 0');
|
|
2045
|
+
* fn('hello'); // returns true
|
|
2046
|
+
*
|
|
2047
|
+
* // Multi-statement (explicit return)
|
|
2048
|
+
* const fn = wrapValidate('if (!value) return false; return value.length > 0');
|
|
2049
|
+
* ```
|
|
2050
|
+
*/
|
|
2051
|
+
declare function wrapValidate(code: string): Validate;
|
|
2052
|
+
|
|
2053
|
+
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, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, wrapCondition, wrapFn, wrapValidate };
|