import { type SlowRequestConfig } from './endpoint-policy'; import type { RequestPolicyConfig } from './request-policy'; import { type JourneyDef, type JourneyEngine, type JourneyEvent, type JourneySink, type JourneyState, type JourneyStepOptions, type JourneyStepTarget, type Outcome, type SerializedJourneyState, type StepHandle, type StepRecord, type TagValue } from './types'; /** @internal Private — not part of the public package API. */ export interface JourneyRuntimeOptions { /** * DevTools label for this engine copy (`__stJourney.getDebugState().runtimes`). * Auto-assigned `runtime-N` from the current `__stJourney` registration count * when omitted at `registerJourneyRuntime`. */ id?: string; /** Initial sinks. Defaults to `[]` — package bootstrap installs Datadog on the module runtime. */ sinks?: readonly JourneySink[]; slowRequests?: SlowRequestConfig; /** Cap recorded steps; default 50. */ maxSteps?: number; /** Default timeout when JourneyDef.timeoutMs is omitted. 0 disables idle countdown. */ defaultJourneyIdleMs?: number; } /** @internal Read-only snapshot for DevTools (`__stJourney.getDebugState`; empty unless debugging). */ export interface JourneyRuntimeDebugSnapshot { id: string; openJourneys: readonly { name: string; team: string; group: string; service: string; verdict: Outcome; reason: string | null; tags: Record; stepsInFlight: readonly string[]; steps: readonly { name: string; outcome: 'good' | 'bad'; durationMs: number; reason?: string; attributedRequestKeys?: readonly string[]; }[]; }[]; activeStep: { journey: string; name: string; } | null; /** Which shared policy knobs this runtime overrode (false = inherit global). */ policyOverlay: { slowRequests: boolean; httpAbortedRequests: boolean; httpClientErrorRequests: boolean; autoAttributeRequests: boolean; }; } /** @internal Freeze a caller-supplied journey def + tags snapshot. */ export declare function freezeJourneyDef(config: JourneyDef, tags: Record): JourneyDef; /** * @internal Private — not part of the public package API. * Isolated journey engine (open journeys, ambient steps, sinks, request thresholds). * App code should keep using free helpers (`defineJourney`, `journeyStep`, …) — they * bind to the module runtime. Prefer `resetJourney()` in tests. */ export interface JourneyRuntime { /** DevTools id for this engine copy. Auto `runtime-N` when registered without an id. */ readonly id: string; getSlowRequests(): SlowRequestConfig; setSlowRequests(next: SlowRequestConfig): void; getMaxSteps(): number; setMaxSteps(next: number): void; getDefaultJourneyIdleMs(): number; setDefaultJourneyIdleMs(next: number): void; setSinks(next: readonly JourneySink[]): void; /** First `configureJourney({ sinks })` on this runtime wins. Returns false if already set. */ trySetConfiguredSinks(next: readonly JourneySink[]): boolean; addSink(sink: JourneySink): void; emit(payload: JourneyEvent): void; setPolicyOverlay(next: { slowRequests?: SlowRequestConfig; httpAbortedRequests?: RequestPolicyConfig; httpClientErrorRequests?: RequestPolicyConfig; autoAttributeRequests?: boolean; }): void; getAutoAttributeRequests(): boolean; getHttpAbortedRequestsPolicy(): RequestPolicyConfig; getHttpClientErrorRequestsPolicy(): RequestPolicyConfig; getOpenJourney(name: string): JourneyState | undefined; /** @internal DevTools snapshot of open journeys / ambient step. */ getDebugSnapshot(): JourneyRuntimeDebugSnapshot; firstOpenJourneyName(names: readonly string[]): string | null; setJourneyTags(name: string | null, tags: Record): void; startJourney(config: JourneyDef): void; failJourney(journey: JourneyState, reason: string): void; completeJourney(name: string | null, tags?: Record): void; completeJourneyState(journey: JourneyState, tags?: Record): void; excludeJourney(journey: JourneyState): void; updateOpenJourney(config: JourneyDef): void; /** * @internal Snapshot an open journey for cross-page transfer. Does NOT * close the journey. Returns `null` when no journey is open under `name`. */ serializeJourneyState(name: string): SerializedJourneyState | null; /** * @internal Rehydrate a serialized journey onto this runtime. Returns * `null` (after emitting a `bad` `journey-timeout` event) when the journey * already exhausted its budget in transit. */ restoreJourney(serialized: SerializedJourneyState, config: JourneyDef): JourneyState | null; activeJourneyStep(): StepRecord | null; journeyStep(journey: JourneyStepTarget, stepName: string, fn: (step: StepHandle) => T | Promise, opts?: JourneyStepOptions): Promise; journeyMountStep(journey: JourneyStepTarget, stepName: string, fn: (step: StepHandle) => T | Promise, opts?: JourneyStepOptions): Promise; reportBackendRequest(step: StepRecord | undefined, status: number | undefined, durationMs: number, requestKey: string): void; /** True when this request key is ignored for the step's journey (never changes verdict). */ shouldIgnoreRequest(journey: JourneyState, key: string): boolean; /** Close open journeys, clear ambient steps, restore default timeouts/sinks. */ reset(options?: JourneyRuntimeOptions): void; } /** @internal Bind the fail/exclude/report hooks for a journey's creating engine. */ export declare function bindJourneyEngine(api: JourneyRuntime, journey: JourneyState, shouldIgnoreRequest: (target: JourneyState, key: string) => boolean): JourneyEngine; /** * @internal Private — not part of the public package API. * Build an isolated engine. Rarely needed — apps use the default via free helpers. */ export declare function createJourneyRuntime(options?: JourneyRuntimeOptions): JourneyRuntime; /** * @internal Private — not part of the public package API. * Module-scoped engine used by free helpers. App code does not need to touch this. * Each host/MFE bundle gets its own copy when the package is duplicated. */ export declare const moduleRuntime: JourneyRuntime; /** * True when this bundle can fail/exclude/report the journey: stamped engine, or * this runtime's own unstamped object. False for a foreign older-copy journey. */ export declare function canRouteHttpToJourney(journey: JourneyState): boolean; /** * @internal Prefer the creating engine on a journey (MFE `step.stamp()` on a host transport). * Falls back to this bundle's module runtime only when this runtime owns the object. * Unstamped foreign journeys (older package copies) are a no-op so a same-named * host journey is not deleted from this map. */ export declare function resolveJourneyEngine(journey: JourneyState): JourneyEngine; /** * @internal Reset the module engine (open journeys, ambient steps, sinks, slow-request thresholds). * Intended for tests — call in `beforeEach` / `afterEach` instead of manual cleanup. */ export declare function resetJourney(options?: JourneyRuntimeOptions): void; //# sourceMappingURL=runtime.d.ts.map