@walkeros/core 4.4.0-next-1785285516008 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -1
- package/dist/dev.d.mts +114 -36
- package/dist/dev.d.ts +114 -36
- 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 +290 -33
- package/dist/index.d.ts +290 -33
- 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
|
@@ -553,6 +553,14 @@ interface SourceStatus {
|
|
|
553
553
|
count: number;
|
|
554
554
|
lastAt?: number;
|
|
555
555
|
duration: number;
|
|
556
|
+
/**
|
|
557
|
+
* Monotonic count of inbound input rejected before entering the pipeline:
|
|
558
|
+
* the source bumps it for HTTP-boundary rejections (unparseable body,
|
|
559
|
+
* oversized payload, unsupported charset), the collector bumps it for
|
|
560
|
+
* events rejected as invalid at the pipeline gate. Absent means no
|
|
561
|
+
* rejections were tracked.
|
|
562
|
+
*/
|
|
563
|
+
rejected?: number;
|
|
556
564
|
}
|
|
557
565
|
interface DestinationStatus {
|
|
558
566
|
count: number;
|
|
@@ -672,6 +680,15 @@ interface Instance$6 {
|
|
|
672
680
|
logger: Instance$3;
|
|
673
681
|
on: OnConfig;
|
|
674
682
|
queue: Events;
|
|
683
|
+
/**
|
|
684
|
+
* Events pushed while `allowed === false`, held raw (pre-pipeline) and
|
|
685
|
+
* replayed FIFO by the run command. Bounded by `config.queueMax`
|
|
686
|
+
* (drop-oldest). RECORD-immediate/DELIVER-gated, extended to events.
|
|
687
|
+
*/
|
|
688
|
+
preRunQueue: Array<{
|
|
689
|
+
event: DeepPartialEvent;
|
|
690
|
+
options: PushOptions;
|
|
691
|
+
}>;
|
|
675
692
|
round: number;
|
|
676
693
|
/** Run-scoped W3C trace id, minted on each run and stamped onto events. */
|
|
677
694
|
trace?: string;
|
|
@@ -1311,6 +1328,10 @@ interface PushResult {
|
|
|
1311
1328
|
failed?: Record<string, Ref>;
|
|
1312
1329
|
/** Event was intentionally not forwarded: a transformer chain stopped it. */
|
|
1313
1330
|
dropped?: boolean;
|
|
1331
|
+
/** Event was rejected as invalid input: a client/producer fault, not a pipeline failure. */
|
|
1332
|
+
invalid?: boolean;
|
|
1333
|
+
/** Human-readable failure reason when ok is false. */
|
|
1334
|
+
error?: string;
|
|
1314
1335
|
}
|
|
1315
1336
|
type Layer = Array<IArguments | DeepPartialEvent | unknown[]>;
|
|
1316
1337
|
|
|
@@ -2560,8 +2581,12 @@ declare namespace request {
|
|
|
2560
2581
|
/**
|
|
2561
2582
|
* Base Env interface for dependency injection into sources.
|
|
2562
2583
|
*
|
|
2563
|
-
*
|
|
2564
|
-
* making
|
|
2584
|
+
* `env` is the author's dependency bag: platform and vendor dependencies are
|
|
2585
|
+
* injected here, making sources platform-agnostic. The five capabilities the
|
|
2586
|
+
* collector provides (`push`, `command`, `sources`, `elb`, `logger`) are
|
|
2587
|
+
* runtime-owned and applied last, so author values for them are ignored. To
|
|
2588
|
+
* mock the collector boundary in a test, call the factory directly with a
|
|
2589
|
+
* hand-built `Context`, or declare `InitSource.terminus`.
|
|
2565
2590
|
*/
|
|
2566
2591
|
interface BaseEnv$1 {
|
|
2567
2592
|
[key: string]: unknown;
|
|
@@ -2636,17 +2661,18 @@ interface Config$1<T extends TypesGeneric$1 = Types$1> extends Config$7<Mapping<
|
|
|
2636
2661
|
/**
|
|
2637
2662
|
* Respond-first acknowledgement for response-producing server sources.
|
|
2638
2663
|
*
|
|
2639
|
-
*
|
|
2640
|
-
*
|
|
2641
|
-
*
|
|
2642
|
-
*
|
|
2643
|
-
*
|
|
2644
|
-
*
|
|
2664
|
+
* `true` responds 2xx ("accepted") before the event is delivered to the
|
|
2665
|
+
* collector, so the client is not blocked on backend delivery; `false`
|
|
2666
|
+
* waits for delivery to settle before responding and lets the response
|
|
2667
|
+
* reflect the outcome. A record configures this per source-defined key:
|
|
2668
|
+
* the express source keys it by HTTP method (`GET`/`POST`) and defaults
|
|
2669
|
+
* to `{ GET: false, POST: true }`, so a step can serve real content on
|
|
2670
|
+
* GET while POST acks fast. A 2xx means "accepted", not "delivered".
|
|
2645
2671
|
*
|
|
2646
2672
|
* Browser and dataLayer sources have no HTTP response to defer and ignore
|
|
2647
|
-
* this flag.
|
|
2673
|
+
* this flag. Defaults are per source type.
|
|
2648
2674
|
*/
|
|
2649
|
-
async?: boolean
|
|
2675
|
+
async?: boolean | Record<string, boolean>;
|
|
2650
2676
|
/** Mark as primary source; its push function becomes the exported `elb` from startFlow. */
|
|
2651
2677
|
primary?: boolean;
|
|
2652
2678
|
/** Defer source initialization until these collector events fire (e.g., `['consent']`). */
|
|
@@ -2658,14 +2684,15 @@ interface Config$1<T extends TypesGeneric$1 = Types$1> extends Config$7<Mapping<
|
|
|
2658
2684
|
setup?: boolean | SetupOptions$1<T>;
|
|
2659
2685
|
/**
|
|
2660
2686
|
* Ingest metadata extraction mapping.
|
|
2661
|
-
* Extracts values from
|
|
2662
|
-
*
|
|
2687
|
+
* Extracts values from the normalized `Scope` the source built, using
|
|
2688
|
+
* walkerOS mapping syntax. Extracted data flows to transformers and
|
|
2689
|
+
* destinations. Paths resolve against the scope's fields, with no prefix.
|
|
2663
2690
|
*
|
|
2664
2691
|
* @example
|
|
2665
2692
|
* ingest: {
|
|
2666
|
-
* ip: '
|
|
2667
|
-
* ua: '
|
|
2668
|
-
* origin: '
|
|
2693
|
+
* ip: 'ip',
|
|
2694
|
+
* ua: 'headers.user-agent',
|
|
2695
|
+
* origin: 'headers.origin'
|
|
2669
2696
|
* }
|
|
2670
2697
|
*/
|
|
2671
2698
|
ingest?: Data$1;
|
|
@@ -2725,6 +2752,36 @@ type ScopeEnv<T extends TypesGeneric$1 = Types$1> = Env$1<T> & {
|
|
|
2725
2752
|
/** Respond function bound to this scope (undefined for scopes without a response). */
|
|
2726
2753
|
respond?: RespondFn;
|
|
2727
2754
|
};
|
|
2755
|
+
/**
|
|
2756
|
+
* The normalized shape every source builds from its platform's request before
|
|
2757
|
+
* calling withScope. Downstream config.ingest mappings, transformers and
|
|
2758
|
+
* destinations read this shape and nothing else, so a mapping written once
|
|
2759
|
+
* resolves the same on every source.
|
|
2760
|
+
*
|
|
2761
|
+
* A value a platform does not supply is never guessed. `ip` is the one optional
|
|
2762
|
+
* field and is simply absent there; the required fields carry a documented
|
|
2763
|
+
* empty value instead (`url` is `''` when the platform cannot form one). `raw`
|
|
2764
|
+
* carries the untouched platform object for the cases normalization
|
|
2765
|
+
* deliberately does not cover.
|
|
2766
|
+
*/
|
|
2767
|
+
interface Scope {
|
|
2768
|
+
/** Uppercase HTTP method. */
|
|
2769
|
+
method: string;
|
|
2770
|
+
/** Absolute request URL when the platform knows it, else ''. */
|
|
2771
|
+
url: string;
|
|
2772
|
+
/** Pathname only, no query string, leading slash. */
|
|
2773
|
+
path: string;
|
|
2774
|
+
/** Query parameters. Repeated keys joined with ','. */
|
|
2775
|
+
query: Record<string, string>;
|
|
2776
|
+
/** Header bag. Keys lowercased. Repeated values joined with ', '. */
|
|
2777
|
+
headers: Record<string, string>;
|
|
2778
|
+
/** Parsed body when it parses as JSON, the raw string when it does not, undefined when there is none. */
|
|
2779
|
+
body: unknown;
|
|
2780
|
+
/** Client IP as the platform reports it. Absent when the platform does not report one. */
|
|
2781
|
+
ip?: string;
|
|
2782
|
+
/** The untouched platform object. Escape hatch, never read by walkerOS itself. */
|
|
2783
|
+
raw: unknown;
|
|
2784
|
+
}
|
|
2728
2785
|
/**
|
|
2729
2786
|
* Context provided to source init function.
|
|
2730
2787
|
* Extends base context with source-specific properties.
|
|
@@ -2734,29 +2791,32 @@ interface Context$1<T extends TypesGeneric$1 = Types$1> extends Base<Partial<Con
|
|
|
2734
2791
|
/**
|
|
2735
2792
|
* Bind ingest and respond to a single scope of work (e.g. one inbound
|
|
2736
2793
|
* HTTP request, one queue message). Builds a fresh `Ingest` from the
|
|
2737
|
-
*
|
|
2738
|
-
* and invokes `body(scopeEnv)` with a push function that
|
|
2794
|
+
* normalized scope via `config.ingest` mapping, wires the per-scope
|
|
2795
|
+
* `respond`, and invokes `body(scopeEnv)` with a push function that
|
|
2796
|
+
* captures both.
|
|
2739
2797
|
*
|
|
2740
|
-
* Server sources
|
|
2798
|
+
* Server sources normalize their platform's request into a `Scope` first,
|
|
2799
|
+
* then call this once per inbound request:
|
|
2741
2800
|
*
|
|
2742
2801
|
* ```ts
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
2802
|
+
* const scope = buildScope(req);
|
|
2803
|
+
*
|
|
2804
|
+
* await context.withScope(scope, createRespond(sender), async (env) => {
|
|
2805
|
+
* for (const event of toEventList(scope.body)) await env.push(event);
|
|
2745
2806
|
* });
|
|
2746
2807
|
* ```
|
|
2747
2808
|
*
|
|
2748
2809
|
* Browser sources with a single tab-lifetime scope may skip `withScope`
|
|
2749
2810
|
* and use `env.push` directly.
|
|
2750
2811
|
*
|
|
2751
|
-
* @param rawScope -
|
|
2752
|
-
*
|
|
2753
|
-
* mapping applies.
|
|
2812
|
+
* @param rawScope - The normalized scope the source built from its
|
|
2813
|
+
* platform's request. Pass `undefined` if no ingest mapping applies.
|
|
2754
2814
|
* @param respond - Per-scope respond function, or `undefined` if the
|
|
2755
2815
|
* scope produces no response.
|
|
2756
2816
|
* @param body - Async callback receiving the per-scope env.
|
|
2757
2817
|
* @returns The body's return value.
|
|
2758
2818
|
*/
|
|
2759
|
-
withScope: <R>(rawScope:
|
|
2819
|
+
withScope: <R>(rawScope: Scope | undefined, respond: RespondFn | undefined, body: (env: ScopeEnv<T>) => Promise<R>) => Promise<R>;
|
|
2760
2820
|
}
|
|
2761
2821
|
type Init$1<T extends TypesGeneric$1 = Types$1> = (context: Context$1<T>) => Instance$2<T> | Promise<Instance$2<T>>;
|
|
2762
2822
|
type InitSource<T extends TypesGeneric$1 = Types$1> = {
|
|
@@ -2766,6 +2826,21 @@ type InitSource<T extends TypesGeneric$1 = Types$1> = {
|
|
|
2766
2826
|
primary?: boolean;
|
|
2767
2827
|
next?: Route;
|
|
2768
2828
|
before?: Route;
|
|
2829
|
+
/**
|
|
2830
|
+
* Replace the collector at the END of this source's pipeline.
|
|
2831
|
+
*
|
|
2832
|
+
* A terminus receives the event exactly as the source emitted it and the
|
|
2833
|
+
* entire pipeline is skipped: no `before`/`next` chains, no source `cache`,
|
|
2834
|
+
* no `state`, no `mapping`, no minted span id, no per-source ingest, no
|
|
2835
|
+
* `respond`, no `status.sources` counting and no observability records.
|
|
2836
|
+
*
|
|
2837
|
+
* This is a TOTAL bypass, deliberately, so there is one thing to know rather
|
|
2838
|
+
* than a list of exceptions. It exists for deterministic capture at the
|
|
2839
|
+
* source→collector boundary (step examples, dev tooling). Production flows
|
|
2840
|
+
* leave it unset. Runtime-only: stored-flow validation rejects unknown
|
|
2841
|
+
* source keys, so a persisted flow cannot carry it.
|
|
2842
|
+
*/
|
|
2843
|
+
terminus?: PushFn$1;
|
|
2769
2844
|
cache?: Cache;
|
|
2770
2845
|
state?: State | State[];
|
|
2771
2846
|
};
|
|
@@ -2808,10 +2883,11 @@ type source_InitSources = InitSources;
|
|
|
2808
2883
|
type source_Mapping<T extends TypesGeneric$1 = Types$1> = Mapping<T>;
|
|
2809
2884
|
type source_Push<T extends TypesGeneric$1 = Types$1> = Push<T>;
|
|
2810
2885
|
type source_Renderer = Renderer;
|
|
2886
|
+
type source_Scope = Scope;
|
|
2811
2887
|
type source_ScopeEnv<T extends TypesGeneric$1 = Types$1> = ScopeEnv<T>;
|
|
2812
2888
|
declare const source_getSource: typeof getSource;
|
|
2813
2889
|
declare namespace source {
|
|
2814
|
-
export { type BaseEnv$1 as BaseEnv, type Config$1 as Config, type Context$1 as Context, type Credentials$1 as Credentials, 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 };
|
|
2890
|
+
export { type BaseEnv$1 as BaseEnv, type Config$1 as Config, type Context$1 as Context, type Credentials$1 as Credentials, 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_Scope as Scope, 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 };
|
|
2815
2891
|
}
|
|
2816
2892
|
|
|
2817
2893
|
interface BaseEnv {
|
|
@@ -4356,6 +4432,17 @@ declare class FatalError extends Error {
|
|
|
4356
4432
|
constructor(message: string, options?: ErrorOptions);
|
|
4357
4433
|
}
|
|
4358
4434
|
|
|
4435
|
+
/**
|
|
4436
|
+
* Inbound event rejected as invalid input (e.g. missing or malformed name)
|
|
4437
|
+
* after the pre-collector transformer chain had its chance to enrich it.
|
|
4438
|
+
* A client/producer fault, not a pipeline failure: the collector resolves
|
|
4439
|
+
* it as `{ ok: false, invalid: true }` instead of an error-logged crash,
|
|
4440
|
+
* and HTTP sources map it to a 400-class response.
|
|
4441
|
+
*/
|
|
4442
|
+
declare class InvalidEventError extends Error {
|
|
4443
|
+
constructor(message: string);
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4359
4446
|
/**
|
|
4360
4447
|
* A utility function that wraps a function with hooks.
|
|
4361
4448
|
*
|
|
@@ -4929,10 +5016,12 @@ declare function fetchPackageSchema(packageName: string, options?: {
|
|
|
4929
5016
|
/** Options for {@link resolveContracts}. */
|
|
4930
5017
|
interface ResolveContractsOptions {
|
|
4931
5018
|
/**
|
|
4932
|
-
* When true (default), annotation
|
|
4933
|
-
* `$comment`) are stripped from event schemas
|
|
4934
|
-
*
|
|
4935
|
-
*
|
|
5019
|
+
* When true (default), annotation keywords (`description`, `examples`,
|
|
5020
|
+
* `title`, `$comment`) are stripped from event schemas. Validators ignore
|
|
5021
|
+
* annotations, so this never changes a validation verdict; it only trims
|
|
5022
|
+
* resolved artifacts, e.g. contracts inlined into shipped bundles. Set to
|
|
5023
|
+
* false to keep annotations (e.g. for IntelliSense that surfaces property
|
|
5024
|
+
* descriptions).
|
|
4936
5025
|
*/
|
|
4937
5026
|
stripAnnotations?: boolean;
|
|
4938
5027
|
}
|
|
@@ -4943,9 +5032,8 @@ interface ResolveContractsOptions {
|
|
|
4943
5032
|
* Returns a fully resolved map where each contract entry has inherited
|
|
4944
5033
|
* properties merged in and wildcards expanded into concrete actions.
|
|
4945
5034
|
*
|
|
4946
|
-
* By default annotations are stripped
|
|
4947
|
-
*
|
|
4948
|
-
* on event schemas.
|
|
5035
|
+
* By default annotations are stripped. Pass `{ stripAnnotations: false }` to
|
|
5036
|
+
* preserve `description`/`examples`/`title` on event schemas.
|
|
4949
5037
|
*/
|
|
4950
5038
|
declare function resolveContracts(contracts: Flow.Contract, options?: ResolveContractsOptions): Record<string, Flow.ContractRule>;
|
|
4951
5039
|
/**
|
|
@@ -4995,6 +5083,175 @@ declare function mcpError(error: unknown, hint?: string): {
|
|
|
4995
5083
|
isError: true;
|
|
4996
5084
|
};
|
|
4997
5085
|
|
|
5086
|
+
/**
|
|
5087
|
+
* Normalizes a platform header collection into a plain bag with lowercased
|
|
5088
|
+
* keys and string values.
|
|
5089
|
+
*
|
|
5090
|
+
* Accepts a Fetch `Headers` instance, a Node style header bag whose values may
|
|
5091
|
+
* be arrays, or anything else, which yields an empty bag. Repeated values are
|
|
5092
|
+
* joined with ', ' following the RFC 9110 rule for combining field values, so
|
|
5093
|
+
* a consumer never has to branch on the value type.
|
|
5094
|
+
*
|
|
5095
|
+
* @param input The platform header collection.
|
|
5096
|
+
* @returns Header names lowercased, values as strings.
|
|
5097
|
+
*/
|
|
5098
|
+
declare function normalizeHeaders(input: unknown): Record<string, string>;
|
|
5099
|
+
/**
|
|
5100
|
+
* Normalizes a query string into a flat bag of string values.
|
|
5101
|
+
*
|
|
5102
|
+
* One algorithm on every platform, so a mapping resolves the same everywhere.
|
|
5103
|
+
* Repeated keys are joined with ',' rather than kept as arrays, matching the
|
|
5104
|
+
* single string value type the scope contract promises. Structured parsing
|
|
5105
|
+
* stays available through the scope's `raw`.
|
|
5106
|
+
*
|
|
5107
|
+
* @param queryString The query string, with or without a leading '?'.
|
|
5108
|
+
* @returns Query parameters as strings.
|
|
5109
|
+
*/
|
|
5110
|
+
declare function normalizeQuery(queryString: string): Record<string, string>;
|
|
5111
|
+
/**
|
|
5112
|
+
* Normalizes a request body into the value it represents.
|
|
5113
|
+
*
|
|
5114
|
+
* Parsing happens once, at the source boundary, so `ingest.body` and the event
|
|
5115
|
+
* the pipeline receives can never disagree. A body that does not parse as JSON
|
|
5116
|
+
* is returned unchanged, which is what lets a `source.before` transformer
|
|
5117
|
+
* decode raw input.
|
|
5118
|
+
*
|
|
5119
|
+
* @param body The raw body.
|
|
5120
|
+
* @param base64 Whether the body is base64 encoded and must be decoded first.
|
|
5121
|
+
* @returns The parsed value, or the input unchanged when it does not parse.
|
|
5122
|
+
*/
|
|
5123
|
+
declare function normalizeBody(body: unknown, base64?: boolean): unknown;
|
|
5124
|
+
/**
|
|
5125
|
+
* Reports whether a value satisfies the scope contract's shape.
|
|
5126
|
+
*
|
|
5127
|
+
* Sources can be user authored, so a consumer that must not assume the type
|
|
5128
|
+
* holds at runtime uses this rather than trusting the declaration.
|
|
5129
|
+
*
|
|
5130
|
+
* @param value The value to check.
|
|
5131
|
+
* @returns True when the value carries the required scope fields.
|
|
5132
|
+
*/
|
|
5133
|
+
declare function isScope(value: unknown): value is Scope;
|
|
5134
|
+
/**
|
|
5135
|
+
* The fields a Node style request exposes that scope construction reads.
|
|
5136
|
+
*
|
|
5137
|
+
* Structural, so core stays free of any framework dependency. Express and the
|
|
5138
|
+
* GCP Functions Framework both satisfy it; the Functions Framework hands the
|
|
5139
|
+
* handler an Express request.
|
|
5140
|
+
*/
|
|
5141
|
+
interface NodeLikeRequest {
|
|
5142
|
+
method?: string;
|
|
5143
|
+
headers?: unknown;
|
|
5144
|
+
originalUrl?: string;
|
|
5145
|
+
url?: string;
|
|
5146
|
+
path?: string;
|
|
5147
|
+
protocol?: string;
|
|
5148
|
+
ip?: string;
|
|
5149
|
+
get?: (name: string) => string | undefined;
|
|
5150
|
+
}
|
|
5151
|
+
/**
|
|
5152
|
+
* Builds the normalized scope from a Node style request.
|
|
5153
|
+
*
|
|
5154
|
+
* Every read tolerates a partial request: sub-app mounting changes which of
|
|
5155
|
+
* `originalUrl` and `url` carries the full path, and a scope that throws on a
|
|
5156
|
+
* missing optional would turn scope construction into a 500 for the whole
|
|
5157
|
+
* request. A missing field yields the contract's empty value.
|
|
5158
|
+
*
|
|
5159
|
+
* The body is supplied by the caller rather than read here, because each
|
|
5160
|
+
* platform decides whether it arrives already parsed.
|
|
5161
|
+
*
|
|
5162
|
+
* @param req The request.
|
|
5163
|
+
* @param options `body` is the resolved request body. `defaultProtocol` is used
|
|
5164
|
+
* when the request and its headers name none.
|
|
5165
|
+
* @returns The normalized scope.
|
|
5166
|
+
*/
|
|
5167
|
+
declare function buildScopeFromNodeRequest(req: NodeLikeRequest, options: {
|
|
5168
|
+
body: unknown;
|
|
5169
|
+
defaultProtocol: string;
|
|
5170
|
+
}): Scope;
|
|
5171
|
+
|
|
5172
|
+
/**
|
|
5173
|
+
* Normalize an inbound request body into the list of events it carries.
|
|
5174
|
+
*
|
|
5175
|
+
* Four rules, in order:
|
|
5176
|
+
* 1. A bare top-level array is N events.
|
|
5177
|
+
* 2. An object with an array `batch` key is N events, the canonical envelope.
|
|
5178
|
+
* 3. Any other object is one event, forwarded verbatim.
|
|
5179
|
+
* 4. Anything else (a string, a number, null, an unparseable body) is raw
|
|
5180
|
+
* input, yielding a single empty event so a `source.before` chain can
|
|
5181
|
+
* decode it from `ingest.body`.
|
|
5182
|
+
*
|
|
5183
|
+
* Validation is not performed here: an object that is not a valid event
|
|
5184
|
+
* reaches the collector's gate, which is the one place that decides what an
|
|
5185
|
+
* event is. An explicit empty batch is a well-formed request carrying zero
|
|
5186
|
+
* events, so it yields an empty list rather than a raw-input event.
|
|
5187
|
+
*
|
|
5188
|
+
* @param body The parsed request body.
|
|
5189
|
+
* @returns The events the body carries.
|
|
5190
|
+
*/
|
|
5191
|
+
declare function toEventList(body: unknown): DeepPartialEvent[];
|
|
5192
|
+
/**
|
|
5193
|
+
* Reports whether a body used a batch form, independently of how many events
|
|
5194
|
+
* it carries.
|
|
5195
|
+
*
|
|
5196
|
+
* Form and count are two different questions. A one element batch is still a
|
|
5197
|
+
* batch, and answers with the batch response shape, so a caller must not infer
|
|
5198
|
+
* the form from the event count.
|
|
5199
|
+
*
|
|
5200
|
+
* @param body The parsed request body.
|
|
5201
|
+
* @returns True for a bare array or an object with an array `batch` key.
|
|
5202
|
+
*/
|
|
5203
|
+
declare function isBatchBody(body: unknown): boolean;
|
|
5204
|
+
/**
|
|
5205
|
+
* The outcome of delivering one event of a batch.
|
|
5206
|
+
*
|
|
5207
|
+
* `id` is present when the event was accepted and minted one. `error` is
|
|
5208
|
+
* present when it was not accepted.
|
|
5209
|
+
*/
|
|
5210
|
+
interface EventOutcome {
|
|
5211
|
+
id?: string;
|
|
5212
|
+
error?: string;
|
|
5213
|
+
}
|
|
5214
|
+
/** A batch response: the status to answer with, and the body to send. */
|
|
5215
|
+
interface BatchResponse {
|
|
5216
|
+
status: 200 | 207;
|
|
5217
|
+
body: {
|
|
5218
|
+
success: boolean;
|
|
5219
|
+
processed: number;
|
|
5220
|
+
failed?: number;
|
|
5221
|
+
ids?: (string | null)[];
|
|
5222
|
+
errors?: Array<{
|
|
5223
|
+
index: number;
|
|
5224
|
+
error: string;
|
|
5225
|
+
}>;
|
|
5226
|
+
};
|
|
5227
|
+
}
|
|
5228
|
+
/**
|
|
5229
|
+
* Builds the shared batch response from per event outcomes.
|
|
5230
|
+
*
|
|
5231
|
+
* One assembly for every source, so the status, the field names and the index
|
|
5232
|
+
* alignment cannot drift apart. `ids` is index aligned with the submitted
|
|
5233
|
+
* batch: an accepted event with no id is `null` rather than omitted, so
|
|
5234
|
+
* `ids[i]` always describes the caller's `i`th event.
|
|
5235
|
+
*
|
|
5236
|
+
* @param outcomes One entry per event, in submission order.
|
|
5237
|
+
* @returns The status and body to answer with.
|
|
5238
|
+
*/
|
|
5239
|
+
declare function batchResponse(outcomes: EventOutcome[]): BatchResponse;
|
|
5240
|
+
/**
|
|
5241
|
+
* Maps a collector push result onto a batch event outcome.
|
|
5242
|
+
*
|
|
5243
|
+
* @param result The push result, or undefined when the push returned none.
|
|
5244
|
+
* @returns The outcome for this event.
|
|
5245
|
+
*/
|
|
5246
|
+
declare function pushResultToOutcome(result: {
|
|
5247
|
+
ok?: boolean;
|
|
5248
|
+
invalid?: boolean;
|
|
5249
|
+
error?: string;
|
|
5250
|
+
event?: {
|
|
5251
|
+
id?: string;
|
|
5252
|
+
};
|
|
5253
|
+
}): EventOutcome;
|
|
5254
|
+
|
|
4998
5255
|
/**
|
|
4999
5256
|
* Compiles a match expression into a closure for fast runtime evaluation.
|
|
5000
5257
|
* Regex patterns are compiled once. Numeric comparisons are parsed once.
|
|
@@ -5227,4 +5484,4 @@ declare const REF_CODE_PREFIX = "$code:";
|
|
|
5227
5484
|
*/
|
|
5228
5485
|
declare function scanFlowRefs(value: unknown, into?: Set<string>): Set<string>;
|
|
5229
5486
|
|
|
5230
|
-
export { type ActivationGrant, type AssembleJourneysOptions, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestEnvelope, type IngestMeta, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JourneyUnattributed, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, OBSERVE_ENV_KEY, OBSERVE_STORAGE_KEY, type Observe, type ObserveCredential, type ObserveServer, type ObserveWeb, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, SECRET_MARKER_PREFIX, SESSION_STORAGE_KEY, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, branch, browserSwapActivator, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, createTelemetryObserver, debounce, deepMerge, defaultClickIds, deleteByPath, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, getTraceId, getTraceUntil, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isSameType, isSampled, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, observeFromEnv, packageNameToVariable, parseCallPath, parseGrant, parseObserveCredential, parseTraceparent, parseUserAgent, processEventMapping, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
|
|
5487
|
+
export { type ActivationGrant, type AssembleJourneysOptions, type BatchResponse, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type EventOutcome, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestEnvelope, type IngestMeta, InvalidEventError, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JourneyUnattributed, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, type NodeLikeRequest, OBSERVE_ENV_KEY, OBSERVE_STORAGE_KEY, type Observe, type ObserveCredential, type ObserveServer, type ObserveWeb, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, SECRET_MARKER_PREFIX, SESSION_STORAGE_KEY, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, batchResponse, branch, browserSwapActivator, buildCacheContext, buildScopeFromNodeRequest, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, createTelemetryObserver, debounce, deepMerge, defaultClickIds, deleteByPath, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, getTraceId, getTraceUntil, isArguments, isArray, isBatchBody, isBoolean, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isSameType, isSampled, isScope, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, normalizeBody, normalizeHeaders, normalizeQuery, observeFromEnv, packageNameToVariable, parseCallPath, parseGrant, parseObserveCredential, parseTraceparent, parseUserAgent, processEventMapping, pushResultToOutcome, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, stepId, storeCache, throttle, throwError, toEventList, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
|