@walkeros/core 4.1.0-next-1778668930820 → 4.1.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/CHANGELOG.md +1089 -0
- package/README.md +13 -413
- package/dist/dev.d.mts +1043 -358
- package/dist/dev.d.ts +1043 -358
- 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 +542 -119
- package/dist/index.d.ts +542 -119
- 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 +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -38,9 +38,15 @@ interface Rules<T = Rule> {
|
|
|
38
38
|
[entity: string]: Record<string, T | Array<T>> | undefined;
|
|
39
39
|
}
|
|
40
40
|
interface Rule<Settings = unknown> {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Batch scheduling for this event mapping. A bare number is the
|
|
43
|
+
* debounce `wait` window (legacy form). Object form supports `wait`
|
|
44
|
+
* (debounce ms), `size` (count cap), and `age` (max ms since first
|
|
45
|
+
* entry). Destination-level `config.batch` provides upper bounds
|
|
46
|
+
* applied at scheduler creation; mapping-level values override
|
|
47
|
+
* destination-level for matched events.
|
|
48
|
+
*/
|
|
49
|
+
batch?: number | BatchOptions;
|
|
44
50
|
condition?: Condition;
|
|
45
51
|
consent?: Consent;
|
|
46
52
|
settings?: Settings;
|
|
@@ -99,16 +105,21 @@ declare namespace mapping {
|
|
|
99
105
|
export type { mapping_Condition as Condition, Config$7 as Config, Context$6 as Context, Data$1 as Data, Fn$4 as Fn, mapping_Loop as Loop, mapping_Map as Map, Policy$1 as Policy, Result$2 as Result, mapping_Rule as Rule, mapping_Rules as Rules, Validate$1 as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
interface
|
|
108
|
+
interface BaseCacheRule {
|
|
103
109
|
/**
|
|
104
110
|
* Optional match expression. Omitted means always-match.
|
|
105
111
|
*/
|
|
106
112
|
match?: MatchExpression;
|
|
107
|
-
key: string[];
|
|
108
113
|
ttl: number;
|
|
114
|
+
}
|
|
115
|
+
interface EventCacheRule extends BaseCacheRule {
|
|
116
|
+
key: string[];
|
|
109
117
|
update?: Record<string, Value>;
|
|
110
118
|
}
|
|
111
|
-
interface
|
|
119
|
+
interface StoreCacheRule extends BaseCacheRule {
|
|
120
|
+
}
|
|
121
|
+
type CacheRule = EventCacheRule | StoreCacheRule;
|
|
122
|
+
interface Cache<R extends CacheRule = CacheRule> {
|
|
112
123
|
/**
|
|
113
124
|
* Stop the chain on cache HIT (default: false). When true, skip remaining steps and return cached value.
|
|
114
125
|
*/
|
|
@@ -118,13 +129,15 @@ interface Cache {
|
|
|
118
129
|
* Optional key prefix written to the store. When absent, cache keys are written directly. Same store + same key + same namespace = same cache entry.
|
|
119
130
|
*/
|
|
120
131
|
namespace?: string;
|
|
121
|
-
rules:
|
|
132
|
+
rules: R[];
|
|
122
133
|
}
|
|
123
134
|
|
|
124
|
-
type cache_Cache = Cache
|
|
135
|
+
type cache_Cache<R extends CacheRule = CacheRule> = Cache<R>;
|
|
125
136
|
type cache_CacheRule = CacheRule;
|
|
137
|
+
type cache_EventCacheRule = EventCacheRule;
|
|
138
|
+
type cache_StoreCacheRule = StoreCacheRule;
|
|
126
139
|
declare namespace cache {
|
|
127
|
-
export type { cache_Cache as Cache, cache_CacheRule as CacheRule };
|
|
140
|
+
export type { cache_Cache as Cache, cache_CacheRule as CacheRule, cache_EventCacheRule as EventCacheRule, cache_StoreCacheRule as StoreCacheRule };
|
|
128
141
|
}
|
|
129
142
|
|
|
130
143
|
/**
|
|
@@ -182,6 +195,28 @@ interface Ingest {
|
|
|
182
195
|
/** Create a fresh Ingest for a new pipeline invocation. */
|
|
183
196
|
declare function createIngest(sourceId: string): Ingest;
|
|
184
197
|
|
|
198
|
+
/** Identifies which kind of step a stepId belongs to. */
|
|
199
|
+
type StepKind = 'collector' | 'source' | 'transformer' | 'destination';
|
|
200
|
+
/**
|
|
201
|
+
* Build a stepId for use as a key in `Status.dropped` (and future
|
|
202
|
+
* status maps). The collector-level stepId is the literal "collector"
|
|
203
|
+
* (no id). Source/transformer/destination ids take the form
|
|
204
|
+
* `"<kind>.<id>"`, e.g. `"destination.ga4"`.
|
|
205
|
+
*
|
|
206
|
+
* The dot separator mirrors the vocabulary already used in collector
|
|
207
|
+
* log messages ("collector.queue overflow", "destination.dlq overflow").
|
|
208
|
+
*/
|
|
209
|
+
declare function stepId(kind: 'collector'): 'collector';
|
|
210
|
+
declare function stepId(kind: 'source' | 'transformer' | 'destination', id: string): string;
|
|
211
|
+
/**
|
|
212
|
+
* Drop counters at a single step. Each buffer is optional: a step kind
|
|
213
|
+
* may have only `queue` (collector), only `dlq`, both (destinations
|
|
214
|
+
* today), or neither. Counts are monotonic.
|
|
215
|
+
*/
|
|
216
|
+
interface DroppedCounters {
|
|
217
|
+
queue?: number;
|
|
218
|
+
dlq?: number;
|
|
219
|
+
}
|
|
185
220
|
/**
|
|
186
221
|
* Core collector configuration interface
|
|
187
222
|
*/
|
|
@@ -194,6 +229,11 @@ interface Config$6 {
|
|
|
194
229
|
sessionStatic: Partial<SessionData>;
|
|
195
230
|
/** Logger configuration */
|
|
196
231
|
logger?: Config$3;
|
|
232
|
+
/**
|
|
233
|
+
* Maximum number of events retained in `collector.queue` for late-registered
|
|
234
|
+
* destination backfill. Overflow drops oldest (FIFO). Default 1000.
|
|
235
|
+
*/
|
|
236
|
+
queueMax?: number;
|
|
197
237
|
}
|
|
198
238
|
/**
|
|
199
239
|
* Initialization configuration that extends Config with initial state
|
|
@@ -237,6 +277,16 @@ interface Status {
|
|
|
237
277
|
failed: number;
|
|
238
278
|
sources: Record<string, SourceStatus>;
|
|
239
279
|
destinations: Record<string, DestinationStatus>;
|
|
280
|
+
/**
|
|
281
|
+
* Monotonic counts of events dropped due to buffer caps, keyed by
|
|
282
|
+
* stepId. See `stepId()` for key construction.
|
|
283
|
+
*
|
|
284
|
+
* Examples:
|
|
285
|
+
* - `dropped["collector"]?.queue`: collector replay buffer drops
|
|
286
|
+
* - `dropped["destination.ga4"]?.queue`: ga4's consent-denied buffer drops
|
|
287
|
+
* - `dropped["destination.ga4"]?.dlq`: ga4's dead-letter queue drops
|
|
288
|
+
*/
|
|
289
|
+
dropped: Record<string, DroppedCounters>;
|
|
240
290
|
}
|
|
241
291
|
interface SourceStatus {
|
|
242
292
|
count: number;
|
|
@@ -248,6 +298,17 @@ interface DestinationStatus {
|
|
|
248
298
|
failed: number;
|
|
249
299
|
lastAt?: number;
|
|
250
300
|
duration: number;
|
|
301
|
+
/** Current size of the destination's queuePush buffer (point-in-time). */
|
|
302
|
+
queuePushSize: number;
|
|
303
|
+
/** Current size of the destination's DLQ (point-in-time). */
|
|
304
|
+
dlqSize: number;
|
|
305
|
+
/**
|
|
306
|
+
* Number of events buffered in batch scheduler windows but not yet
|
|
307
|
+
* delivered to `pushBatch`. Incremented on enqueue, decremented on
|
|
308
|
+
* flush (whether the flush succeeds or fails). Operators read this
|
|
309
|
+
* to spot batches that never drain.
|
|
310
|
+
*/
|
|
311
|
+
inFlightBatch?: number;
|
|
251
312
|
}
|
|
252
313
|
interface Sources {
|
|
253
314
|
[id: string]: Instance$2;
|
|
@@ -287,9 +348,15 @@ interface PushFn$1 {
|
|
|
287
348
|
interface CommandFn {
|
|
288
349
|
(command: 'config', config: Partial<Config$6>): Promise<PushResult>;
|
|
289
350
|
(command: 'consent', consent: Consent): Promise<PushResult>;
|
|
290
|
-
<T extends Types$4>(command: 'destination',
|
|
291
|
-
<K extends keyof Functions>(command: 'hook',
|
|
292
|
-
|
|
351
|
+
<T extends Types$4>(command: 'destination', init: Init$3<T>): Promise<PushResult>;
|
|
352
|
+
<K extends keyof Functions>(command: 'hook', init: {
|
|
353
|
+
name: K;
|
|
354
|
+
fn: Functions[K];
|
|
355
|
+
}): Promise<PushResult>;
|
|
356
|
+
(command: 'on', init: {
|
|
357
|
+
type: Types$2;
|
|
358
|
+
rules: SingleOrArray<Subscription>;
|
|
359
|
+
}): Promise<PushResult>;
|
|
293
360
|
(command: 'user', user: User): Promise<PushResult>;
|
|
294
361
|
(command: 'run', runState?: {
|
|
295
362
|
consent?: Consent;
|
|
@@ -297,7 +364,7 @@ interface CommandFn {
|
|
|
297
364
|
globals?: Properties;
|
|
298
365
|
custom?: Properties;
|
|
299
366
|
}): Promise<PushResult>;
|
|
300
|
-
(command: string, data?: unknown
|
|
367
|
+
(command: string, data?: unknown): Promise<PushResult>;
|
|
301
368
|
}
|
|
302
369
|
interface Instance$6 {
|
|
303
370
|
push: PushFn$1;
|
|
@@ -328,14 +395,17 @@ interface Instance$6 {
|
|
|
328
395
|
type collector_CommandFn = CommandFn;
|
|
329
396
|
type collector_CommandType = CommandType;
|
|
330
397
|
type collector_DestinationStatus = DestinationStatus;
|
|
398
|
+
type collector_DroppedCounters = DroppedCounters;
|
|
331
399
|
type collector_InitConfig = InitConfig;
|
|
332
400
|
type collector_PushOptions = PushOptions;
|
|
333
401
|
type collector_SessionData = SessionData;
|
|
334
402
|
type collector_SourceStatus = SourceStatus;
|
|
335
403
|
type collector_Sources = Sources;
|
|
336
404
|
type collector_Status = Status;
|
|
405
|
+
type collector_StepKind = StepKind;
|
|
406
|
+
declare const collector_stepId: typeof stepId;
|
|
337
407
|
declare namespace collector {
|
|
338
|
-
export type
|
|
408
|
+
export { type collector_CommandFn as CommandFn, type collector_CommandType as CommandType, type Config$6 as Config, type collector_DestinationStatus as DestinationStatus, type Destinations$1 as Destinations, type collector_DroppedCounters as DroppedCounters, type collector_InitConfig as InitConfig, type Instance$6 as Instance, type PushFn$1 as PushFn, type collector_PushOptions as PushOptions, type collector_SessionData as SessionData, type collector_SourceStatus as SourceStatus, type collector_Sources as Sources, type collector_Status as Status, type collector_StepKind as StepKind, type Stores$1 as Stores, type Transformers$1 as Transformers, collector_stepId as stepId };
|
|
339
409
|
}
|
|
340
410
|
|
|
341
411
|
/**
|
|
@@ -511,15 +581,48 @@ interface Config$5<T extends TypesGeneric$3 = Types$4> {
|
|
|
511
581
|
*/
|
|
512
582
|
setup?: boolean | SetupOptions$2<T>;
|
|
513
583
|
/** Transformer chain to run after collector processing but before this destination. */
|
|
514
|
-
before?:
|
|
584
|
+
before?: Route;
|
|
515
585
|
/** Transformer chain to run after destination push completes. Push response available at ingest._response. */
|
|
516
|
-
next?:
|
|
586
|
+
next?: Route;
|
|
517
587
|
/** Cache configuration for deduplication (step-level: skip push on HIT). */
|
|
518
588
|
cache?: Cache;
|
|
519
589
|
/** Completely skip this destination — no init, no push, no queuing. */
|
|
520
590
|
disabled?: boolean;
|
|
521
591
|
/** Return this value instead of calling push(). Uses !== undefined check to support falsy values. */
|
|
522
592
|
mock?: unknown;
|
|
593
|
+
/**
|
|
594
|
+
* Maximum number of consent-denied events retained in `queuePush` for
|
|
595
|
+
* this destination. Overflow drops oldest (FIFO). Default 1000.
|
|
596
|
+
*/
|
|
597
|
+
queueMax?: number;
|
|
598
|
+
/**
|
|
599
|
+
* Maximum number of failed-push entries retained in `dlq` for this
|
|
600
|
+
* destination. Overflow drops oldest (FIFO). Default 100.
|
|
601
|
+
*/
|
|
602
|
+
dlqMax?: number;
|
|
603
|
+
/**
|
|
604
|
+
* Per-destination batch upper bounds. Supplements the mapping-level
|
|
605
|
+
* `batch` setting on individual rules. A bare number is treated as
|
|
606
|
+
* the debounce `wait` window (legacy compat).
|
|
607
|
+
*
|
|
608
|
+
* - `wait`: debounce window in ms; the timer resets on every push.
|
|
609
|
+
* - `size`: hard count cap; flush immediately when entries reach this number. Default 1000 when batching is enabled.
|
|
610
|
+
* - `age`: time since the first entry of the current window. Forces a flush even if pushes keep arriving. Default 30000 (30s).
|
|
611
|
+
*/
|
|
612
|
+
batch?: number | BatchOptions;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Batch scheduling options. Used at both the mapping-rule layer
|
|
616
|
+
* (`Mapping.Rule.batch`) and the destination-config layer
|
|
617
|
+
* (`Destination.Config.batch`). Same shape at both layers.
|
|
618
|
+
*/
|
|
619
|
+
interface BatchOptions {
|
|
620
|
+
/** Debounce window in ms. Timer resets on every push. */
|
|
621
|
+
wait?: number;
|
|
622
|
+
/** Hard count cap. Flushes immediately at this size. */
|
|
623
|
+
size?: number;
|
|
624
|
+
/** Hard age cap in ms since first entry of current window. */
|
|
625
|
+
age?: number;
|
|
523
626
|
}
|
|
524
627
|
type PartialConfig$2<T extends TypesGeneric$3 = Types$4> = Config$5<Types$4<Partial<Settings$3<T>> | Settings$3<T>, Partial<Mapping$1<T>> | Mapping$1<T>, Env$3<T>, InitSettings$3<T>, SetupOptions$2<T>>>;
|
|
525
628
|
interface Policy {
|
|
@@ -530,8 +633,8 @@ type Init$3<T extends TypesGeneric$3 = Types$4> = {
|
|
|
530
633
|
code: Code$1<T>;
|
|
531
634
|
config?: Partial<Config$5<T>>;
|
|
532
635
|
env?: Partial<Env$3<T>>;
|
|
533
|
-
before?:
|
|
534
|
-
next?:
|
|
636
|
+
before?: Route;
|
|
637
|
+
next?: Route;
|
|
535
638
|
cache?: Cache;
|
|
536
639
|
validate?: Validate;
|
|
537
640
|
};
|
|
@@ -565,9 +668,24 @@ type PushEvent<Mapping = unknown> = {
|
|
|
565
668
|
mapping?: Rule<Mapping>;
|
|
566
669
|
};
|
|
567
670
|
type PushEvents<Mapping = unknown> = Array<PushEvent<Mapping>>;
|
|
671
|
+
interface BatchEntry<Mapping = unknown> {
|
|
672
|
+
event: Event;
|
|
673
|
+
ingest?: Ingest;
|
|
674
|
+
respond?: RespondFn;
|
|
675
|
+
rule?: Rule<Mapping>;
|
|
676
|
+
data?: Data;
|
|
677
|
+
}
|
|
568
678
|
interface Batch<Mapping> {
|
|
569
679
|
key: string;
|
|
680
|
+
/**
|
|
681
|
+
* Per-event entries carrying per-event ingest, respond, rule, and data.
|
|
682
|
+
* Destinations needing per-event metadata should read this instead of
|
|
683
|
+
* (or in addition to) `events` and `data`.
|
|
684
|
+
*/
|
|
685
|
+
entries: BatchEntry<Mapping>[];
|
|
686
|
+
/** Derived view: events from `entries`. Kept for back-compat. */
|
|
570
687
|
events: Events;
|
|
688
|
+
/** Derived view: data from `entries`. Kept for back-compat. */
|
|
571
689
|
data: Array<Data>;
|
|
572
690
|
mapping?: Rule<Mapping>;
|
|
573
691
|
}
|
|
@@ -575,6 +693,12 @@ interface BatchRegistry<Mapping> {
|
|
|
575
693
|
[mappingKey: string]: {
|
|
576
694
|
batched: Batch<Mapping>;
|
|
577
695
|
batchFn: () => void;
|
|
696
|
+
/**
|
|
697
|
+
* Force a flush of the current batch immediately. Used by shutdown
|
|
698
|
+
* drain and by tests for deterministic flushing without timer
|
|
699
|
+
* advancement. Resolves after the underlying `pushBatch` settles.
|
|
700
|
+
*/
|
|
701
|
+
flush: () => Promise<void>;
|
|
578
702
|
};
|
|
579
703
|
}
|
|
580
704
|
type Data = Property | undefined | Array<Property | undefined>;
|
|
@@ -588,8 +712,29 @@ type Push$1 = {
|
|
|
588
712
|
error?: unknown;
|
|
589
713
|
};
|
|
590
714
|
type DLQ = Array<[Event, unknown]>;
|
|
715
|
+
/**
|
|
716
|
+
* Typed accessor for destinations registered on a collector.
|
|
717
|
+
*
|
|
718
|
+
* The collector's `destinations` bag indexes to `Destination.Instance`
|
|
719
|
+
* (defaults erase the generic). Use this helper at the call site to recover
|
|
720
|
+
* the narrow type without casts.
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* type MyDestTypes = Destination.Types<MySettings, MyMapping>;
|
|
724
|
+
* const dest = getDestination<MyDestTypes>(collector, 'myDest');
|
|
725
|
+
* await dest.push(event, context);
|
|
726
|
+
*
|
|
727
|
+
* @throws Error with message `Destination not found: <id>` when the id is unknown.
|
|
728
|
+
*/
|
|
729
|
+
declare function getDestination<T extends TypesGeneric$3 = Types$4>(collector: {
|
|
730
|
+
destinations: {
|
|
731
|
+
[id: string]: Instance$5<any>;
|
|
732
|
+
};
|
|
733
|
+
}, id: string): Instance$5<T>;
|
|
591
734
|
|
|
592
735
|
type destination_Batch<Mapping> = Batch<Mapping>;
|
|
736
|
+
type destination_BatchEntry<Mapping = unknown> = BatchEntry<Mapping>;
|
|
737
|
+
type destination_BatchOptions = BatchOptions;
|
|
593
738
|
type destination_BatchRegistry<Mapping> = BatchRegistry<Mapping>;
|
|
594
739
|
type destination_DLQ = DLQ;
|
|
595
740
|
type destination_Data = Data;
|
|
@@ -603,8 +748,9 @@ type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
|
603
748
|
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
604
749
|
type destination_PushFn<T extends TypesGeneric$3 = Types$4> = PushFn<T>;
|
|
605
750
|
type destination_Ref = Ref;
|
|
751
|
+
declare const destination_getDestination: typeof getDestination;
|
|
606
752
|
declare namespace destination {
|
|
607
|
-
export type
|
|
753
|
+
export { type BaseEnv$3 as BaseEnv, type destination_Batch as Batch, type destination_BatchEntry as BatchEntry, type destination_BatchOptions as BatchOptions, type destination_BatchRegistry as BatchRegistry, type Code$1 as Code, type Config$5 as Config, type Context$5 as Context, type destination_DLQ as DLQ, type destination_Data as Data, type destination_Destinations as Destinations, type Env$3 as Env, type Init$3 as Init, type destination_InitDestinations as InitDestinations, type InitFn$2 as InitFn, type InitSettings$3 as InitSettings, type Instance$5 as Instance, type Mapping$1 as Mapping, type PartialConfig$2 as PartialConfig, type destination_Policy as Policy, type Push$1 as Push, type destination_PushBatchContext as PushBatchContext, type destination_PushBatchFn as PushBatchFn, type destination_PushContext as PushContext, type destination_PushEvent as PushEvent, type destination_PushEvents as PushEvents, type destination_PushFn as PushFn, type destination_Ref as Ref, type Settings$3 as Settings, type SetupOptions$2 as SetupOptions, type Types$4 as Types, type TypesGeneric$3 as TypesGeneric, type TypesOf$3 as TypesOf, destination_getDestination as getDestination };
|
|
608
754
|
}
|
|
609
755
|
|
|
610
756
|
interface EventFn<R = Promise<PushResult>> {
|
|
@@ -617,11 +763,17 @@ interface Fn$3<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, Wa
|
|
|
617
763
|
interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
|
|
618
764
|
(event: 'walker config', config: Partial<Config>): R;
|
|
619
765
|
(event: 'walker consent', consent: Consent): R;
|
|
620
|
-
<T extends Types$4>(event: 'walker destination',
|
|
621
|
-
<K extends keyof Functions>(event: 'walker hook',
|
|
622
|
-
|
|
766
|
+
<T extends Types$4>(event: 'walker destination', init: Init$3<T>): R;
|
|
767
|
+
<K extends keyof Functions>(event: 'walker hook', init: {
|
|
768
|
+
name: K;
|
|
769
|
+
fn: Functions[K];
|
|
770
|
+
}): R;
|
|
771
|
+
(event: 'walker on', init: {
|
|
772
|
+
type: Types$2;
|
|
773
|
+
rules: SingleOrArray<Subscription>;
|
|
774
|
+
}): R;
|
|
623
775
|
(event: 'walker user', user: User): R;
|
|
624
|
-
(event: 'walker run', runState
|
|
776
|
+
(event: 'walker run', runState?: {
|
|
625
777
|
consent?: Consent;
|
|
626
778
|
user?: User;
|
|
627
779
|
globals?: Properties;
|
|
@@ -650,38 +802,48 @@ declare namespace elb {
|
|
|
650
802
|
|
|
651
803
|
/**
|
|
652
804
|
* Unified route grammar for Flow v4. A `Route` is one of:
|
|
653
|
-
* - a
|
|
805
|
+
* - a transformer ID string (`"redact"`)
|
|
654
806
|
* - a sequence of routes (`["a", "b", "c"]` — sugar for chained `.next`)
|
|
655
807
|
* - a `RouteConfig` — a gated / dispatching node.
|
|
656
808
|
*
|
|
657
|
-
* `RouteConfig` is a disjoint union
|
|
658
|
-
* `
|
|
809
|
+
* `RouteConfig` is a disjoint union — set exactly one of `next`, `one`,
|
|
810
|
+
* `many`, or neither (pure gate). The disjointness is enforced by `never`
|
|
811
|
+
* sibling properties at the type level and `z.strictObject` at the schema
|
|
812
|
+
* level.
|
|
659
813
|
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
814
|
+
* Operators:
|
|
815
|
+
* - `next`: single continuation.
|
|
816
|
+
* - `one`: first-match dispatch (walk entries, first whose match passes wins).
|
|
817
|
+
* - `many`: all-match terminal fan-out (every matching entry spawns an
|
|
818
|
+
* independent flow; main chain terminates here). Restricted to
|
|
819
|
+
* pre-collector positions (source.next, transformer.next, transformer.before).
|
|
662
820
|
*/
|
|
663
821
|
type Route = string | Route[] | RouteConfig;
|
|
664
|
-
type RouteConfig = RouteNextConfig |
|
|
822
|
+
type RouteConfig = RouteNextConfig | RouteOneConfig | RouteManyConfig | RouteGateConfig;
|
|
665
823
|
interface RouteNextConfig {
|
|
666
824
|
match?: MatchExpression;
|
|
667
825
|
next: Route;
|
|
668
|
-
|
|
826
|
+
one?: never;
|
|
827
|
+
many?: never;
|
|
828
|
+
}
|
|
829
|
+
interface RouteOneConfig {
|
|
830
|
+
match?: MatchExpression;
|
|
831
|
+
one: Route[];
|
|
832
|
+
next?: never;
|
|
833
|
+
many?: never;
|
|
669
834
|
}
|
|
670
|
-
interface
|
|
835
|
+
interface RouteManyConfig {
|
|
671
836
|
match?: MatchExpression;
|
|
672
|
-
|
|
837
|
+
many: Route[];
|
|
673
838
|
next?: never;
|
|
839
|
+
one?: never;
|
|
674
840
|
}
|
|
675
841
|
interface RouteGateConfig {
|
|
676
842
|
match: MatchExpression;
|
|
677
843
|
next?: never;
|
|
678
|
-
|
|
844
|
+
one?: never;
|
|
845
|
+
many?: never;
|
|
679
846
|
}
|
|
680
|
-
/**
|
|
681
|
-
* Backward-compatible alias. New code should use `Route` directly.
|
|
682
|
-
* Kept for compatibility with existing imports across the codebase.
|
|
683
|
-
*/
|
|
684
|
-
type RouteSpec = Route;
|
|
685
847
|
/**
|
|
686
848
|
* Base environment interface for walkerOS transformers.
|
|
687
849
|
*
|
|
@@ -731,8 +893,8 @@ interface Config$4<T extends TypesGeneric$2 = Types$3> {
|
|
|
731
893
|
env?: Env$2<T>;
|
|
732
894
|
id?: string;
|
|
733
895
|
logger?: Config$3;
|
|
734
|
-
before?:
|
|
735
|
-
next?:
|
|
896
|
+
before?: Route;
|
|
897
|
+
next?: Route;
|
|
736
898
|
cache?: Cache;
|
|
737
899
|
init?: boolean;
|
|
738
900
|
disabled?: boolean;
|
|
@@ -776,7 +938,7 @@ interface Context$4<T extends TypesGeneric$2 = Types$3> extends Base<Config$4<T>
|
|
|
776
938
|
interface Result$1<E = DeepPartialEvent> {
|
|
777
939
|
event?: E;
|
|
778
940
|
respond?: RespondFn;
|
|
779
|
-
next?:
|
|
941
|
+
next?: Route;
|
|
780
942
|
}
|
|
781
943
|
/**
|
|
782
944
|
* Result of running a transformer chain.
|
|
@@ -846,13 +1008,13 @@ type InitTransformer<T extends TypesGeneric$2 = Types$3> = {
|
|
|
846
1008
|
*
|
|
847
1009
|
* Validation: an entry without `code` must declare at least one of
|
|
848
1010
|
* `package`, `before`, `next`, `cache`, `mapping`. Enforced by
|
|
849
|
-
* `
|
|
1011
|
+
* `validateStepEntry` in `@walkeros/core`.
|
|
850
1012
|
*/
|
|
851
1013
|
code?: Init$2<T>;
|
|
852
1014
|
config?: Partial<Config$4<T>>;
|
|
853
1015
|
env?: Partial<Env$2<T>>;
|
|
854
|
-
before?:
|
|
855
|
-
next?:
|
|
1016
|
+
before?: Route;
|
|
1017
|
+
next?: Route;
|
|
856
1018
|
cache?: Cache;
|
|
857
1019
|
mapping?: Config$7;
|
|
858
1020
|
validate?: Validate;
|
|
@@ -870,21 +1032,80 @@ interface InitTransformers {
|
|
|
870
1032
|
interface Transformers {
|
|
871
1033
|
[transformerId: string]: Instance$4;
|
|
872
1034
|
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Typed accessor for transformers registered on a collector.
|
|
1037
|
+
*
|
|
1038
|
+
* The collector's `transformers` bag indexes to `Transformer.Instance`
|
|
1039
|
+
* (defaults erase the generic). Use this helper at the call site to recover
|
|
1040
|
+
* the narrow type without casts.
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* type MyTransformerTypes = Transformer.Types<MySettings>;
|
|
1044
|
+
* const tx = getTransformer<MyTransformerTypes>(collector, 'redact');
|
|
1045
|
+
* await tx.push(event, context);
|
|
1046
|
+
*
|
|
1047
|
+
* @throws Error with message `Transformer not found: <id>` when the id is unknown.
|
|
1048
|
+
*/
|
|
1049
|
+
declare function getTransformer<T extends TypesGeneric$2 = Types$3>(collector: {
|
|
1050
|
+
transformers: {
|
|
1051
|
+
[id: string]: Instance$4<any>;
|
|
1052
|
+
};
|
|
1053
|
+
}, id: string): Instance$4<T>;
|
|
873
1054
|
|
|
874
1055
|
type transformer_ChainResult = ChainResult;
|
|
875
1056
|
type transformer_InitTransformer<T extends TypesGeneric$2 = Types$3> = InitTransformer<T>;
|
|
876
1057
|
type transformer_InitTransformers = InitTransformers;
|
|
877
1058
|
type transformer_Route = Route;
|
|
878
|
-
type transformer_RouteCaseConfig = RouteCaseConfig;
|
|
879
1059
|
type transformer_RouteConfig = RouteConfig;
|
|
880
1060
|
type transformer_RouteGateConfig = RouteGateConfig;
|
|
1061
|
+
type transformer_RouteManyConfig = RouteManyConfig;
|
|
881
1062
|
type transformer_RouteNextConfig = RouteNextConfig;
|
|
882
|
-
type
|
|
1063
|
+
type transformer_RouteOneConfig = RouteOneConfig;
|
|
883
1064
|
type transformer_Transformers = Transformers;
|
|
1065
|
+
declare const transformer_getTransformer: typeof getTransformer;
|
|
884
1066
|
declare namespace transformer {
|
|
885
|
-
export type
|
|
1067
|
+
export { type BaseEnv$2 as BaseEnv, type transformer_ChainResult as ChainResult, type Config$4 as Config, type Context$4 as Context, type Env$2 as Env, type Fn$2 as Fn, type Init$2 as Init, type InitFn$1 as InitFn, type InitSettings$2 as InitSettings, type transformer_InitTransformer as InitTransformer, type transformer_InitTransformers as InitTransformers, type Instance$4 as Instance, type Result$1 as Result, type transformer_Route as Route, type transformer_RouteConfig as RouteConfig, type transformer_RouteGateConfig as RouteGateConfig, type transformer_RouteManyConfig as RouteManyConfig, type transformer_RouteNextConfig as RouteNextConfig, type transformer_RouteOneConfig as RouteOneConfig, type Settings$2 as Settings, type transformer_Transformers as Transformers, type Types$3 as Types, type TypesGeneric$2 as TypesGeneric, type TypesOf$2 as TypesOf, transformer_getTransformer as getTransformer };
|
|
886
1068
|
}
|
|
887
1069
|
|
|
1070
|
+
/**
|
|
1071
|
+
* Flow Configuration System (v4)
|
|
1072
|
+
*
|
|
1073
|
+
* Core types for walkerOS unified configuration.
|
|
1074
|
+
* Platform-agnostic, runtime-focused.
|
|
1075
|
+
*
|
|
1076
|
+
* The Flow system enables "one config to rule them all" - a single
|
|
1077
|
+
* walkeros.config.json file that manages multiple flows
|
|
1078
|
+
* (web_prod, web_stage, server_prod, etc.) with shared configuration
|
|
1079
|
+
* and reusable variables.
|
|
1080
|
+
*
|
|
1081
|
+
* Single declaration merge: `Flow` is both the interface for one flow
|
|
1082
|
+
* and the namespace holding all related types.
|
|
1083
|
+
*
|
|
1084
|
+
* ## Connection Rules
|
|
1085
|
+
*
|
|
1086
|
+
* Sources use `next` to connect to transformers (pre-collector chain).
|
|
1087
|
+
* Sources use `before` for consent-exempt pre-source preprocessing
|
|
1088
|
+
* (decode, validate, authenticate raw input before the source.next chain).
|
|
1089
|
+
*
|
|
1090
|
+
* Destinations use `before` to connect to transformers (post-collector chain).
|
|
1091
|
+
* Destinations use `next` for post-push processing.
|
|
1092
|
+
*
|
|
1093
|
+
* Transformers use `next` to chain to other transformers. The same transformer
|
|
1094
|
+
* pool is shared by both pre-collector and post-collector chains.
|
|
1095
|
+
*
|
|
1096
|
+
* The collector is implicit - it is never referenced directly in connections.
|
|
1097
|
+
* It sits between the source chain and the destination chain automatically.
|
|
1098
|
+
*
|
|
1099
|
+
* Circular `next` references are safely handled at runtime by `walkChain()`
|
|
1100
|
+
* in the collector module (visited-set detection).
|
|
1101
|
+
*
|
|
1102
|
+
* ```
|
|
1103
|
+
* Source → [before → Preprocessing] → [next → Transformer chain] → Collector → [before → Transformer chain] → Destination → [next → Post-push]
|
|
1104
|
+
* ```
|
|
1105
|
+
*
|
|
1106
|
+
* @packageDocumentation
|
|
1107
|
+
*/
|
|
1108
|
+
|
|
888
1109
|
/**
|
|
889
1110
|
* Single flow configuration.
|
|
890
1111
|
*
|
|
@@ -1139,13 +1360,27 @@ declare namespace Flow {
|
|
|
1139
1360
|
*/
|
|
1140
1361
|
package?: string;
|
|
1141
1362
|
/**
|
|
1142
|
-
*
|
|
1363
|
+
* Inline code definition (object form only).
|
|
1364
|
+
*
|
|
1365
|
+
* Object: `{push, type?, init?}` for inline code definition.
|
|
1366
|
+
* For named-export selection from a package, use the `import` field with `package`.
|
|
1367
|
+
*/
|
|
1368
|
+
code?: Code;
|
|
1369
|
+
/**
|
|
1370
|
+
* Named export from `package` to import as this source's implementation.
|
|
1371
|
+
*
|
|
1372
|
+
* Requires `package` to be set. Mutually exclusive with `code`.
|
|
1143
1373
|
*
|
|
1144
|
-
* -
|
|
1145
|
-
*
|
|
1146
|
-
* -
|
|
1374
|
+
* - Top-level identifier only: `/^[A-Za-z_$][A-Za-z0-9_$]*$/`. No dotted paths.
|
|
1375
|
+
* - `package: "X"` alone (no `import`, no `code`) loads X's default export.
|
|
1376
|
+
* - `package: "X"` + `import: "fooFactory"` loads named export `fooFactory` from X.
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```json
|
|
1380
|
+
* { "package": "@walkeros/web-source-browser", "import": "sourceBrowser" }
|
|
1381
|
+
* ```
|
|
1147
1382
|
*/
|
|
1148
|
-
|
|
1383
|
+
import?: string;
|
|
1149
1384
|
/**
|
|
1150
1385
|
* Source-specific configuration. Structure depends on the source package.
|
|
1151
1386
|
* Passed to the source's initialization function.
|
|
@@ -1173,7 +1408,7 @@ declare namespace Flow {
|
|
|
1173
1408
|
* (decode, validate, authenticate, normalize raw input).
|
|
1174
1409
|
* Raw request data is available in context.ingest.
|
|
1175
1410
|
*/
|
|
1176
|
-
before?:
|
|
1411
|
+
before?: Route;
|
|
1177
1412
|
/**
|
|
1178
1413
|
* First transformer in pre-collector chain.
|
|
1179
1414
|
*
|
|
@@ -1182,9 +1417,9 @@ declare namespace Flow {
|
|
|
1182
1417
|
* If omitted, events route directly to the collector.
|
|
1183
1418
|
* Can be an array for explicit chain control (bypasses transformer.next resolution).
|
|
1184
1419
|
*/
|
|
1185
|
-
next?:
|
|
1420
|
+
next?: Route;
|
|
1186
1421
|
/** Cache configuration for this source. */
|
|
1187
|
-
cache?: Cache
|
|
1422
|
+
cache?: Cache<EventCacheRule>;
|
|
1188
1423
|
validate?: Validate;
|
|
1189
1424
|
/**
|
|
1190
1425
|
* Source-level variables (highest priority in cascade).
|
|
@@ -1206,8 +1441,23 @@ declare namespace Flow {
|
|
|
1206
1441
|
interface Destination {
|
|
1207
1442
|
/** Package specifier with optional version. Optional when `code` is provided. */
|
|
1208
1443
|
package?: string;
|
|
1209
|
-
/**
|
|
1210
|
-
|
|
1444
|
+
/**
|
|
1445
|
+
* Inline code definition (object form only).
|
|
1446
|
+
*
|
|
1447
|
+
* Object: `{push, type?, init?}` for inline code definition.
|
|
1448
|
+
* For named-export selection from a package, use the `import` field with `package`.
|
|
1449
|
+
*/
|
|
1450
|
+
code?: Code;
|
|
1451
|
+
/**
|
|
1452
|
+
* Named export from `package` to import as this destination's implementation.
|
|
1453
|
+
* See `Flow.Source.import` for full rules.
|
|
1454
|
+
*
|
|
1455
|
+
* @example
|
|
1456
|
+
* ```json
|
|
1457
|
+
* { "package": "@walkeros/web-destination-gtag", "import": "destinationGtag" }
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
import?: string;
|
|
1211
1461
|
/**
|
|
1212
1462
|
* Destination-specific configuration. Typically includes:
|
|
1213
1463
|
* - settings: API keys, IDs, endpoints
|
|
@@ -1225,7 +1475,7 @@ declare namespace Flow {
|
|
|
1225
1475
|
* If omitted, events are sent directly from the collector.
|
|
1226
1476
|
* Can be an array for explicit chain control.
|
|
1227
1477
|
*/
|
|
1228
|
-
before?:
|
|
1478
|
+
before?: Route;
|
|
1229
1479
|
/**
|
|
1230
1480
|
* First transformer in post-push chain.
|
|
1231
1481
|
*
|
|
@@ -1233,9 +1483,9 @@ declare namespace Flow {
|
|
|
1233
1483
|
* at context.ingest._response. Consent is inherited from the destination
|
|
1234
1484
|
* gate - no separate consent check needed.
|
|
1235
1485
|
*/
|
|
1236
|
-
next?:
|
|
1486
|
+
next?: Route;
|
|
1237
1487
|
/** Cache configuration for this destination. */
|
|
1238
|
-
cache?: Cache
|
|
1488
|
+
cache?: Cache<EventCacheRule>;
|
|
1239
1489
|
validate?: Validate;
|
|
1240
1490
|
/** Destination-level variables (highest priority in cascade). */
|
|
1241
1491
|
variables?: Variables;
|
|
@@ -1254,8 +1504,23 @@ declare namespace Flow {
|
|
|
1254
1504
|
interface Transformer {
|
|
1255
1505
|
/** Package specifier with optional version. Optional when `code` is provided. */
|
|
1256
1506
|
package?: string;
|
|
1257
|
-
/**
|
|
1258
|
-
|
|
1507
|
+
/**
|
|
1508
|
+
* Inline code definition (object form only).
|
|
1509
|
+
*
|
|
1510
|
+
* Object: `{push, type?, init?}` for inline code definition.
|
|
1511
|
+
* For named-export selection from a package, use the `import` field with `package`.
|
|
1512
|
+
*/
|
|
1513
|
+
code?: Code;
|
|
1514
|
+
/**
|
|
1515
|
+
* Named export from `package` to import as this transformer's implementation.
|
|
1516
|
+
* See `Flow.Source.import` for full rules.
|
|
1517
|
+
*
|
|
1518
|
+
* @example
|
|
1519
|
+
* ```json
|
|
1520
|
+
* { "package": "@walkeros/transformer-ga4", "import": "transformerGa4" }
|
|
1521
|
+
* ```
|
|
1522
|
+
*/
|
|
1523
|
+
import?: string;
|
|
1259
1524
|
/** Transformer-specific configuration. Structure depends on the package. */
|
|
1260
1525
|
config?: unknown;
|
|
1261
1526
|
/** Transformer environment configuration. */
|
|
@@ -1267,7 +1532,7 @@ declare namespace Flow {
|
|
|
1267
1532
|
* Enables pre-processing or context loading before the main transform.
|
|
1268
1533
|
* Uses the same chain resolution as source.next and destination.before.
|
|
1269
1534
|
*/
|
|
1270
|
-
before?:
|
|
1535
|
+
before?: Route;
|
|
1271
1536
|
/**
|
|
1272
1537
|
* Next transformer in chain.
|
|
1273
1538
|
*
|
|
@@ -1278,9 +1543,9 @@ declare namespace Flow {
|
|
|
1278
1543
|
* Array values define an explicit chain (no walking). Circular references
|
|
1279
1544
|
* are safely detected at runtime by `walkChain()`.
|
|
1280
1545
|
*/
|
|
1281
|
-
next?:
|
|
1546
|
+
next?: Route;
|
|
1282
1547
|
/** Cache configuration for this transformer. */
|
|
1283
|
-
cache?: Cache
|
|
1548
|
+
cache?: Cache<EventCacheRule>;
|
|
1284
1549
|
validate?: Validate;
|
|
1285
1550
|
/** Transformer-level variables (highest priority in cascade). */
|
|
1286
1551
|
variables?: Variables;
|
|
@@ -1300,12 +1565,35 @@ declare namespace Flow {
|
|
|
1300
1565
|
interface Store {
|
|
1301
1566
|
/** Package specifier with optional version. Optional when `code` is provided. */
|
|
1302
1567
|
package?: string;
|
|
1303
|
-
/**
|
|
1304
|
-
|
|
1568
|
+
/**
|
|
1569
|
+
* Inline code definition (object form only).
|
|
1570
|
+
*
|
|
1571
|
+
* Object: `{push, type?, init?}` for inline code definition.
|
|
1572
|
+
* For named-export selection from a package, use the `import` field with `package`.
|
|
1573
|
+
*/
|
|
1574
|
+
code?: Code;
|
|
1575
|
+
/**
|
|
1576
|
+
* Named export from `package` to import as this store's implementation.
|
|
1577
|
+
* See `Flow.Source.import` for full rules.
|
|
1578
|
+
*
|
|
1579
|
+
* @example
|
|
1580
|
+
* ```json
|
|
1581
|
+
* { "package": "@walkeros/server-store-fs", "import": "storeFs" }
|
|
1582
|
+
* ```
|
|
1583
|
+
*/
|
|
1584
|
+
import?: string;
|
|
1305
1585
|
/** Store-specific configuration. */
|
|
1306
1586
|
config?: unknown;
|
|
1307
1587
|
/** Store environment configuration. */
|
|
1308
1588
|
env?: unknown;
|
|
1589
|
+
/**
|
|
1590
|
+
* Cache configuration for this store.
|
|
1591
|
+
*
|
|
1592
|
+
* When present, the collector wraps the bare store with a cache layer
|
|
1593
|
+
* (read-through, write-through, single-flight). The cache layer may
|
|
1594
|
+
* recursively delegate to another store via `cache.store`.
|
|
1595
|
+
*/
|
|
1596
|
+
cache?: Cache<StoreCacheRule>;
|
|
1309
1597
|
/** Store-level variables (highest priority in cascade). */
|
|
1310
1598
|
variables?: Variables;
|
|
1311
1599
|
/**
|
|
@@ -1816,6 +2104,24 @@ interface Instance$2<T extends TypesGeneric$1 = Types$1> {
|
|
|
1816
2104
|
data: unknown;
|
|
1817
2105
|
}>;
|
|
1818
2106
|
}
|
|
2107
|
+
/**
|
|
2108
|
+
* Per-scope environment passed to the body of `Source.Context.withScope`.
|
|
2109
|
+
*
|
|
2110
|
+
* Each call to `withScope` builds a fresh `ScopeEnv` whose `push` captures
|
|
2111
|
+
* the per-scope `ingest` and `respond`. Concurrent scopes cannot crosstalk:
|
|
2112
|
+
* each one carries its own ingest and respond all the way through the
|
|
2113
|
+
* pipeline. Server sources MUST use `withScope` per inbound request; sources
|
|
2114
|
+
* with a single logical scope (browser tab lifetime, dataLayer) may skip it
|
|
2115
|
+
* and use the factory-scope `env.push` directly.
|
|
2116
|
+
*/
|
|
2117
|
+
type ScopeEnv<T extends TypesGeneric$1 = Types$1> = Env$1<T> & {
|
|
2118
|
+
/** Per-scope push: captures the scope's ingest and respond for this call. */
|
|
2119
|
+
push: PushFn$1;
|
|
2120
|
+
/** Ingest metadata extracted from the raw scope input (if config.ingest is set). */
|
|
2121
|
+
ingest: Ingest;
|
|
2122
|
+
/** Respond function bound to this scope (undefined for scopes without a response). */
|
|
2123
|
+
respond?: RespondFn;
|
|
2124
|
+
};
|
|
1819
2125
|
/**
|
|
1820
2126
|
* Context provided to source init function.
|
|
1821
2127
|
* Extends base context with source-specific properties.
|
|
@@ -1823,15 +2129,31 @@ interface Instance$2<T extends TypesGeneric$1 = Types$1> {
|
|
|
1823
2129
|
interface Context$1<T extends TypesGeneric$1 = Types$1> extends Base<Partial<Config$1<T>>, Env$1<T>> {
|
|
1824
2130
|
id: string;
|
|
1825
2131
|
/**
|
|
1826
|
-
*
|
|
1827
|
-
*
|
|
1828
|
-
*
|
|
2132
|
+
* Bind ingest and respond to a single scope of work (e.g. one inbound
|
|
2133
|
+
* HTTP request, one queue message). Builds a fresh `Ingest` from the
|
|
2134
|
+
* raw input via `config.ingest` mapping, wires the per-scope `respond`,
|
|
2135
|
+
* and invokes `body(scopeEnv)` with a push function that captures both.
|
|
2136
|
+
*
|
|
2137
|
+
* Server sources call this once per inbound request:
|
|
2138
|
+
*
|
|
2139
|
+
* ```ts
|
|
2140
|
+
* await context.withScope(req, createRespond(sender), async (env) => {
|
|
2141
|
+
* await env.push(parsedData);
|
|
2142
|
+
* });
|
|
2143
|
+
* ```
|
|
2144
|
+
*
|
|
2145
|
+
* Browser sources with a single tab-lifetime scope may skip `withScope`
|
|
2146
|
+
* and use `env.push` directly.
|
|
1829
2147
|
*
|
|
1830
|
-
* @param
|
|
2148
|
+
* @param rawScope - Raw input for `config.ingest` mapping (Express req,
|
|
2149
|
+
* Lambda event, fetch Request, etc.). Pass `undefined` if no ingest
|
|
2150
|
+
* mapping applies.
|
|
2151
|
+
* @param respond - Per-scope respond function, or `undefined` if the
|
|
2152
|
+
* scope produces no response.
|
|
2153
|
+
* @param body - Async callback receiving the per-scope env.
|
|
2154
|
+
* @returns The body's return value.
|
|
1831
2155
|
*/
|
|
1832
|
-
|
|
1833
|
-
/** Sets respond function for the current request. Called by source per-request. */
|
|
1834
|
-
setRespond: (fn: RespondFn | undefined) => void;
|
|
2156
|
+
withScope: <R>(rawScope: unknown, respond: RespondFn | undefined, body: (env: ScopeEnv<T>) => Promise<R>) => Promise<R>;
|
|
1835
2157
|
}
|
|
1836
2158
|
type Init$1<T extends TypesGeneric$1 = Types$1> = (context: Context$1<T>) => Instance$2<T> | Promise<Instance$2<T>>;
|
|
1837
2159
|
type InitSource<T extends TypesGeneric$1 = Types$1> = {
|
|
@@ -1839,8 +2161,8 @@ type InitSource<T extends TypesGeneric$1 = Types$1> = {
|
|
|
1839
2161
|
config?: Partial<Config$1<T>>;
|
|
1840
2162
|
env?: Partial<Env$1<T>>;
|
|
1841
2163
|
primary?: boolean;
|
|
1842
|
-
next?:
|
|
1843
|
-
before?:
|
|
2164
|
+
next?: Route;
|
|
2165
|
+
before?: Route;
|
|
1844
2166
|
cache?: Cache;
|
|
1845
2167
|
validate?: Validate;
|
|
1846
2168
|
};
|
|
@@ -1857,14 +2179,36 @@ interface InitSources {
|
|
|
1857
2179
|
* - 'codebox': Source uses a JSON/code editor (default)
|
|
1858
2180
|
*/
|
|
1859
2181
|
type Renderer = 'browser' | 'codebox';
|
|
2182
|
+
/**
|
|
2183
|
+
* Typed accessor for sources registered on a collector.
|
|
2184
|
+
*
|
|
2185
|
+
* The collector's `sources` bag indexes to `Source.Instance` (defaults erase
|
|
2186
|
+
* the generic), which collapses the source's declared `push` signature to
|
|
2187
|
+
* `Elb.Fn`. Use this helper at the call site to recover the narrow type
|
|
2188
|
+
* without casts.
|
|
2189
|
+
*
|
|
2190
|
+
* @example
|
|
2191
|
+
* type TestSourceTypes = Source.Types<unknown, unknown, TestPushFn>;
|
|
2192
|
+
* const src = getSource<TestSourceTypes>(collector, 'testSource');
|
|
2193
|
+
* await src.push({ method: 'GET', path: '/api/data' }); // typed!
|
|
2194
|
+
*
|
|
2195
|
+
* @throws Error with message `Source not found: <id>` when the id is unknown.
|
|
2196
|
+
*/
|
|
2197
|
+
declare function getSource<T extends TypesGeneric$1 = Types$1>(collector: {
|
|
2198
|
+
sources: {
|
|
2199
|
+
[id: string]: Instance$2<any>;
|
|
2200
|
+
};
|
|
2201
|
+
}, id: string): Instance$2<T>;
|
|
1860
2202
|
|
|
1861
2203
|
type source_InitSource<T extends TypesGeneric$1 = Types$1> = InitSource<T>;
|
|
1862
2204
|
type source_InitSources = InitSources;
|
|
1863
2205
|
type source_Mapping<T extends TypesGeneric$1 = Types$1> = Mapping<T>;
|
|
1864
2206
|
type source_Push<T extends TypesGeneric$1 = Types$1> = Push<T>;
|
|
1865
2207
|
type source_Renderer = Renderer;
|
|
2208
|
+
type source_ScopeEnv<T extends TypesGeneric$1 = Types$1> = ScopeEnv<T>;
|
|
2209
|
+
declare const source_getSource: typeof getSource;
|
|
1866
2210
|
declare namespace source {
|
|
1867
|
-
export type
|
|
2211
|
+
export { type BaseEnv$1 as BaseEnv, type Config$1 as Config, type Context$1 as Context, type Env$1 as Env, type Init$1 as Init, type InitSettings$1 as InitSettings, type source_InitSource as InitSource, type source_InitSources as InitSources, type Instance$2 as Instance, type source_Mapping as Mapping, type PartialConfig$1 as PartialConfig, type source_Push as Push, type source_Renderer as Renderer, type source_ScopeEnv as ScopeEnv, type Settings$1 as Settings, type SetupOptions$1 as SetupOptions, type Types$1 as Types, type TypesGeneric$1 as TypesGeneric, type TypesOf$1 as TypesOf, source_getSource as getSource };
|
|
1868
2212
|
}
|
|
1869
2213
|
|
|
1870
2214
|
interface BaseEnv {
|
|
@@ -1927,6 +2271,25 @@ interface InitStores {
|
|
|
1927
2271
|
interface Stores {
|
|
1928
2272
|
[storeId: string]: Instance$1;
|
|
1929
2273
|
}
|
|
2274
|
+
/**
|
|
2275
|
+
* Typed accessor for stores registered on a collector.
|
|
2276
|
+
*
|
|
2277
|
+
* The collector's `stores` bag indexes to `Store.Instance` (defaults erase
|
|
2278
|
+
* the generic). Use this helper at the call site to recover the narrow type
|
|
2279
|
+
* without casts.
|
|
2280
|
+
*
|
|
2281
|
+
* @example
|
|
2282
|
+
* type MyStoreTypes = Store.Types<MySettings>;
|
|
2283
|
+
* const store = getStore<MyStoreTypes>(collector, 'cache');
|
|
2284
|
+
* await store.set('key', 'value');
|
|
2285
|
+
*
|
|
2286
|
+
* @throws Error with message `Store not found: <id>` when the id is unknown.
|
|
2287
|
+
*/
|
|
2288
|
+
declare function getStore<T extends TypesGeneric = Types>(collector: {
|
|
2289
|
+
stores: {
|
|
2290
|
+
[id: string]: Instance$1<any>;
|
|
2291
|
+
};
|
|
2292
|
+
}, id: string): Instance$1<T>;
|
|
1930
2293
|
|
|
1931
2294
|
type store_BaseEnv = BaseEnv;
|
|
1932
2295
|
type store_Config<T extends TypesGeneric = Types> = Config<T>;
|
|
@@ -1947,8 +2310,9 @@ type store_Stores = Stores;
|
|
|
1947
2310
|
type store_Types<S = unknown, E = BaseEnv, I = S, U = unknown> = Types<S, E, I, U>;
|
|
1948
2311
|
type store_TypesGeneric = TypesGeneric;
|
|
1949
2312
|
type store_TypesOf<I> = TypesOf<I>;
|
|
2313
|
+
declare const store_getStore: typeof getStore;
|
|
1950
2314
|
declare namespace store {
|
|
1951
|
-
export type
|
|
2315
|
+
export { type store_BaseEnv as BaseEnv, type store_Config as Config, type store_Context as Context, type store_DeleteFn as DeleteFn, type store_Env as Env, type store_GetFn as GetFn, type store_Init as Init, type store_InitFn as InitFn, type store_InitSettings as InitSettings, type store_InitStore as InitStore, type store_InitStores as InitStores, type Instance$1 as Instance, type store_PartialConfig as PartialConfig, type store_SetFn as SetFn, type store_Settings as Settings, type store_SetupOptions as SetupOptions, type store_Stores as Stores, type store_Types as Types, type store_TypesGeneric as TypesGeneric, type store_TypesOf as TypesOf, store_getStore as getStore };
|
|
1952
2316
|
}
|
|
1953
2317
|
|
|
1954
2318
|
/**
|
|
@@ -2251,7 +2615,7 @@ interface SendResponse {
|
|
|
2251
2615
|
* Creates a TransformerResult for dynamic chain routing.
|
|
2252
2616
|
* Use this in transformer push functions to redirect the chain.
|
|
2253
2617
|
*/
|
|
2254
|
-
declare function branch(event: DeepPartialEvent, next:
|
|
2618
|
+
declare function branch(event: DeepPartialEvent, next: Route): Result$1;
|
|
2255
2619
|
|
|
2256
2620
|
/**
|
|
2257
2621
|
* Anonymizes an IPv4 address by setting the last octet to 0.
|
|
@@ -2539,20 +2903,54 @@ declare const defaultClickIds: ClickIdEntry[];
|
|
|
2539
2903
|
*/
|
|
2540
2904
|
declare function getMarketingParameters(url: URL, custom?: MarketingParameters, clickIds?: ClickIdEntry[]): Properties;
|
|
2541
2905
|
|
|
2906
|
+
/**
|
|
2907
|
+
* Options for scheduling primitives ({@link debounce}, {@link throttle}).
|
|
2908
|
+
*
|
|
2909
|
+
* - `wait`: Debounce window in ms. Timer resets on every call.
|
|
2910
|
+
* - `size`: Hard call-count cap per window. Flush immediately when call
|
|
2911
|
+
* count reaches this number. Useful for batch buffers that must not
|
|
2912
|
+
* grow unbounded.
|
|
2913
|
+
* - `age`: Hard age cap in ms since the first call of the current window.
|
|
2914
|
+
* Forces a flush even if calls keep arriving and reset the debounce.
|
|
2915
|
+
* Prevents debounce starvation under sustained load.
|
|
2916
|
+
*/
|
|
2917
|
+
interface ScheduleOptions {
|
|
2918
|
+
wait?: number;
|
|
2919
|
+
size?: number;
|
|
2920
|
+
age?: number;
|
|
2921
|
+
}
|
|
2922
|
+
/**
|
|
2923
|
+
* Returned by {@link debounce}: a callable that schedules `fn` plus
|
|
2924
|
+
* deterministic `flush` / `cancel` controls.
|
|
2925
|
+
*/
|
|
2926
|
+
interface Debounced<P extends unknown[], R> {
|
|
2927
|
+
(...args: P): Promise<R | undefined>;
|
|
2928
|
+
/** Force an immediate flush with the most recent args. Resolves after `fn` settles. */
|
|
2929
|
+
flush(): Promise<R | undefined>;
|
|
2930
|
+
/** Cancel any pending invocation. No `fn` call, pending promises resolve to undefined. */
|
|
2931
|
+
cancel(): void;
|
|
2932
|
+
/** Number of scheduled calls since the current window opened. */
|
|
2933
|
+
size(): number;
|
|
2934
|
+
}
|
|
2542
2935
|
/**
|
|
2543
2936
|
* Creates a debounced function that delays invoking `fn` until after `wait`
|
|
2544
2937
|
* milliseconds have elapsed since the last time the debounced function was
|
|
2545
2938
|
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
2546
2939
|
* delayed `fn` invocations and a `flush` method to immediately invoke them.
|
|
2547
2940
|
*
|
|
2941
|
+
* The second argument is either a `wait` number (legacy form) or a
|
|
2942
|
+
* {@link ScheduleOptions} object. The object form adds `size` (hard count
|
|
2943
|
+
* cap) and `age` (hard window-age cap) so the function flushes deterministically
|
|
2944
|
+
* under sustained load instead of letting the debounce reset forever.
|
|
2945
|
+
*
|
|
2548
2946
|
* @template P, R
|
|
2549
2947
|
* @param fn The function to debounce.
|
|
2550
|
-
* @param wait
|
|
2948
|
+
* @param opts Either a wait-ms number or a {@link ScheduleOptions} object.
|
|
2551
2949
|
* @param immediate Trigger the function on the leading edge, instead of the trailing.
|
|
2552
|
-
* @returns
|
|
2950
|
+
* @returns A {@link Debounced} callable with `flush`, `cancel`, and `size` methods.
|
|
2553
2951
|
*/
|
|
2554
|
-
declare function debounce<P extends unknown[], R>(fn: (...args: P) => R,
|
|
2555
|
-
declare function throttle<P extends unknown[], R>(fn: (...args: P) => R | undefined,
|
|
2952
|
+
declare function debounce<P extends unknown[], R>(fn: (...args: P) => R, opts?: number | ScheduleOptions, immediate?: boolean): Debounced<P, R>;
|
|
2953
|
+
declare function throttle<P extends unknown[], R>(fn: (...args: P) => R | undefined, opts?: number | ScheduleOptions): (...args: P) => R | undefined;
|
|
2556
2954
|
|
|
2557
2955
|
/**
|
|
2558
2956
|
* Checks if a value is an arguments object.
|
|
@@ -2944,6 +3342,24 @@ declare function tryCatch<P extends unknown[], R>(fn: (...args: P) => R | undefi
|
|
|
2944
3342
|
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>;
|
|
2945
3343
|
declare function tryCatchAsync<P extends unknown[], R>(fn: (...args: P) => R, onError?: undefined, onFinally?: () => void | Promise<void>): (...args: P) => Promise<R | undefined>;
|
|
2946
3344
|
|
|
3345
|
+
/**
|
|
3346
|
+
* Error subclass for invariant violations or operator-initiated aborts
|
|
3347
|
+
* that must escape the top-level boundary catches in `collector.push`
|
|
3348
|
+
* and `collector.command`.
|
|
3349
|
+
*
|
|
3350
|
+
* Standard `Error` instances are absorbed by the boundary, logged, and
|
|
3351
|
+
* counted on `collector.status.failed`. A `FatalError` rethrows so a
|
|
3352
|
+
* runtime supervisor (CLI runner, Express server, container orchestrator)
|
|
3353
|
+
* can terminate the process cleanly.
|
|
3354
|
+
*
|
|
3355
|
+
* Use sparingly. Most operational failures are recoverable and should
|
|
3356
|
+
* be plain `Error`. Reserve `FatalError` for programmer-error invariant
|
|
3357
|
+
* violations or explicit fail-stop signals.
|
|
3358
|
+
*/
|
|
3359
|
+
declare class FatalError extends Error {
|
|
3360
|
+
constructor(message: string, options?: ErrorOptions);
|
|
3361
|
+
}
|
|
3362
|
+
|
|
2947
3363
|
/**
|
|
2948
3364
|
* A utility function that wraps a function with hooks.
|
|
2949
3365
|
*
|
|
@@ -3143,40 +3559,32 @@ declare function mcpError(error: unknown, hint?: string): {
|
|
|
3143
3559
|
*/
|
|
3144
3560
|
declare function compileMatcher(expr: MatchExpression | '*' | undefined): CompiledMatcher;
|
|
3145
3561
|
|
|
3146
|
-
interface CompiledRoute {
|
|
3147
|
-
match: CompiledMatcher;
|
|
3148
|
-
next: CompiledNext;
|
|
3149
|
-
}
|
|
3150
|
-
type CompiledNext = {
|
|
3151
|
-
type: 'static';
|
|
3152
|
-
value: string;
|
|
3153
|
-
} | {
|
|
3154
|
-
type: 'chain';
|
|
3155
|
-
value: string[];
|
|
3156
|
-
} | {
|
|
3157
|
-
type: 'case';
|
|
3158
|
-
routes: CompiledRoute[];
|
|
3159
|
-
} | {
|
|
3160
|
-
type: 'gate';
|
|
3161
|
-
match: CompiledMatcher;
|
|
3162
|
-
next?: CompiledNext;
|
|
3163
|
-
} | {
|
|
3164
|
-
type: 'sequence';
|
|
3165
|
-
value: CompiledNext[];
|
|
3166
|
-
};
|
|
3167
3562
|
/**
|
|
3168
|
-
*
|
|
3169
|
-
*
|
|
3563
|
+
* Resolve a Route spec against a matcher context. Returns the immediate
|
|
3564
|
+
* next transformer IDs.
|
|
3565
|
+
*
|
|
3566
|
+
* Return shape:
|
|
3567
|
+
* [] → terminate (gate failed, empty many, all matchers failed,
|
|
3568
|
+
* undefined spec).
|
|
3569
|
+
* ["x"] → continue main chain at x.
|
|
3570
|
+
* ["a","b",…] → fan-out, only produced by `many`. Main chain terminates
|
|
3571
|
+
* at this dispatch point; each branch is an independent
|
|
3572
|
+
* flow running to its own exit.
|
|
3573
|
+
*
|
|
3574
|
+
* Reachability vs prediction: `match` rules read arbitrary event fields.
|
|
3575
|
+
* `getNextSteps` is deterministic for the SUPPLIED context only. Static
|
|
3576
|
+
* analyzers without a real event must over-approximate by treating each
|
|
3577
|
+
* match as "may pass or fail" — see `flattenRouteTargets` in the CLI
|
|
3578
|
+
* validator. This function does NOT predict the path a future event will
|
|
3579
|
+
* take; it computes the path for the event you give it.
|
|
3170
3580
|
*/
|
|
3171
|
-
declare function
|
|
3172
|
-
declare function compileNext(next: Route | undefined): CompiledNext | undefined;
|
|
3173
|
-
declare function resolveNext(compiled: CompiledNext | undefined, context?: Record<string, unknown>): string | string[] | undefined;
|
|
3581
|
+
declare function getNextSteps(spec: Route | undefined, context?: Record<string, unknown>): string[];
|
|
3174
3582
|
|
|
3175
3583
|
interface CompiledCacheRule {
|
|
3176
3584
|
match: CompiledMatcher;
|
|
3177
3585
|
key: string[];
|
|
3178
3586
|
ttl: number;
|
|
3179
|
-
update?:
|
|
3587
|
+
update?: EventCacheRule['update'];
|
|
3180
3588
|
}
|
|
3181
3589
|
interface CompiledCache {
|
|
3182
3590
|
stop: boolean;
|
|
@@ -3195,21 +3603,36 @@ interface CacheResult {
|
|
|
3195
3603
|
* Normalizes ingest (defaulting to {}) and optionally includes event.
|
|
3196
3604
|
*/
|
|
3197
3605
|
declare function buildCacheContext(ingest?: unknown, event?: unknown): Record<string, unknown>;
|
|
3198
|
-
declare function compileCache(cache: Cache): CompiledCache;
|
|
3199
|
-
declare function checkCache(compiled: CompiledCache, store: Instance$1, context: Record<string, unknown>, namespace?: string): CacheResult | null
|
|
3606
|
+
declare function compileCache(cache: Cache<EventCacheRule>): CompiledCache;
|
|
3607
|
+
declare function checkCache(compiled: CompiledCache, store: Instance$1, context: Record<string, unknown>, namespace?: string): Promise<CacheResult | null>;
|
|
3200
3608
|
declare function storeCache(store: Instance$1, key: string, value: unknown, ttlSeconds: number): void;
|
|
3201
3609
|
declare function applyUpdate(value: unknown, update: Record<string, unknown> | undefined, context: Record<string, unknown>, collector: Instance$6): Promise<unknown>;
|
|
3202
3610
|
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3611
|
+
/**
|
|
3612
|
+
* Single source of truth for step-entry validation across all four kinds.
|
|
3613
|
+
*
|
|
3614
|
+
* An empty entry (no `code`, no `package`, no `import`) is a valid no-op
|
|
3615
|
+
* step for all four kinds. The bundler emits no code; the runtime skips
|
|
3616
|
+
* registration. No error is raised for empty steps.
|
|
3617
|
+
*
|
|
3618
|
+
* Error codes:
|
|
3619
|
+
* - UNKNOWN_KEY unknown top-level key on a step entry
|
|
3620
|
+
* - CONFLICT two of {code, package, import} together, or other mutually exclusive pairs
|
|
3621
|
+
* - MISSING_PACKAGE `import` set without `package`
|
|
3622
|
+
* - OBSOLETE_CODE_STRING `code` is a string (legacy named-export shape; use `import` instead)
|
|
3623
|
+
* - INVALID_IMPORT `import` is set but is not a valid JS identifier
|
|
3624
|
+
* - INVALID_CODE_SHAPE `code` is present but is neither an object nor a string
|
|
3625
|
+
*/
|
|
3626
|
+
declare const STEP_OPERATIVE_FIELDS: Record<Flow.StepKind, readonly string[]>;
|
|
3627
|
+
type StepEntryErrorCode = 'UNKNOWN_KEY' | 'CONFLICT' | 'MISSING_PACKAGE' | 'OBSOLETE_CODE_STRING' | 'INVALID_IMPORT' | 'INVALID_CODE_SHAPE';
|
|
3628
|
+
interface StepEntryValidation {
|
|
3206
3629
|
ok: boolean;
|
|
3207
3630
|
reason?: string;
|
|
3208
|
-
code?:
|
|
3631
|
+
code?: StepEntryErrorCode;
|
|
3209
3632
|
key?: string;
|
|
3210
3633
|
}
|
|
3211
|
-
declare function
|
|
3212
|
-
declare function
|
|
3634
|
+
declare function validateStepEntry(entry: Record<string, unknown>, kind: Flow.StepKind): StepEntryValidation;
|
|
3635
|
+
declare function isPathStepEntry(entry: Record<string, unknown>, kind: Flow.StepKind): boolean;
|
|
3213
3636
|
|
|
3214
3637
|
type StepOut = Flow.StepOut;
|
|
3215
3638
|
/**
|
|
@@ -3249,4 +3672,4 @@ declare const REF_STORE: RegExp;
|
|
|
3249
3672
|
declare const REF_SECRET: RegExp;
|
|
3250
3673
|
declare const REF_CODE_PREFIX = "$code:";
|
|
3251
3674
|
|
|
3252
|
-
export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache,
|
|
3675
|
+
export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type SetupFn, simulation as Simulation, source as Source, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, type Validate, type ValidateEvents, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveSetup, setByPath, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, walkPath, wrapCondition, wrapFn, wrapValidate };
|