bitfab 0.38.4 → 0.38.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autoTrace.cjs +8 -1
- package/dist/autoTrace.cjs.map +1 -1
- package/dist/autoTrace.d.cts +2 -2
- package/dist/autoTrace.d.ts +2 -2
- package/dist/autoTrace.js +1 -1
- package/dist/{chunk-LHFNHB2J.js → chunk-O75EYGVO.js} +8 -3
- package/dist/chunk-O75EYGVO.js.map +1 -0
- package/dist/{chunk-PXAL7PPD.js → chunk-YCTQONNS.js} +154 -68
- package/dist/chunk-YCTQONNS.js.map +1 -0
- package/dist/{chunk-J47KPS77.js → chunk-ZUD7OFYB.js} +9 -2
- package/dist/{chunk-J47KPS77.js.map → chunk-ZUD7OFYB.js.map} +1 -1
- package/dist/index.cjs +167 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -11
- package/dist/index.d.ts +41 -11
- package/dist/index.js +5 -3
- package/dist/node.cjs +167 -67
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +5 -3
- package/dist/node.js.map +1 -1
- package/dist/{replay-BYW5MCLO.js → replay-K3UMQAKO.js} +2 -2
- package/dist/replayCli.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-LHFNHB2J.js.map +0 -1
- package/dist/chunk-PXAL7PPD.js.map +0 -1
- /package/dist/{replay-BYW5MCLO.js.map → replay-K3UMQAKO.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -147,10 +147,23 @@ interface MockOverrideCtx {
|
|
|
147
147
|
*/
|
|
148
148
|
getOriginalOutput: () => Promise<unknown>;
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Return this from a mock override resolver to decline the override for the
|
|
152
|
+
* current span. Resolution continues with the next override, then the replay's
|
|
153
|
+
* base mock strategy.
|
|
154
|
+
*/
|
|
155
|
+
declare const NO_MOCK_OVERRIDE: unique symbol;
|
|
150
156
|
/** Selects which spans an override applies to. Runs on structural metadata. */
|
|
151
157
|
type NodeMatcher = (node: SpanNodeMeta) => boolean;
|
|
152
158
|
/** The function form of {@link MockValue}, receiving the override context. */
|
|
153
159
|
type MockValueFn = (ctx: MockOverrideCtx) => unknown | Promise<unknown>;
|
|
160
|
+
/**
|
|
161
|
+
* A client-wide, keyed, or per-replay resolver. A global resolver can route on
|
|
162
|
+
* `ctx.node.traceFunctionKey`; a keyed resolver is only invoked for spans with
|
|
163
|
+
* its registered key. Return {@link NO_MOCK_OVERRIDE} for spans the resolver
|
|
164
|
+
* does not want to override.
|
|
165
|
+
*/
|
|
166
|
+
type MockOverrideResolver = (ctx: MockOverrideCtx) => unknown | Promise<unknown>;
|
|
154
167
|
/**
|
|
155
168
|
* The value injected for a matched span: either a flat value used as-is, or a
|
|
156
169
|
* function of the {@link MockOverrideCtx} that returns one (or a Promise of
|
|
@@ -168,6 +181,8 @@ interface MockOverride {
|
|
|
168
181
|
match: NodeMatcher;
|
|
169
182
|
value: MockValue;
|
|
170
183
|
}
|
|
184
|
+
/** Accepted shape for one mock override declaration. */
|
|
185
|
+
type MockOverrideInput = MockOverride | MockOverrideResolver;
|
|
171
186
|
|
|
172
187
|
/**
|
|
173
188
|
* Replay context propagation via AsyncLocalStorage.
|
|
@@ -1268,12 +1283,12 @@ interface ReplayOptions {
|
|
|
1268
1283
|
/**
|
|
1269
1284
|
* Selective mock overrides: inject custom values into specific spans during
|
|
1270
1285
|
* replay, so downstream real code runs against the substituted output. Each
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1286
|
+
* Pass `{ match, value }` pairs, or one resolver invoked for every child span.
|
|
1287
|
+
* A resolver can route on `ctx.node.traceFunctionKey` and return
|
|
1288
|
+
* `NO_MOCK_OVERRIDE` to continue to the next override and base strategy.
|
|
1289
|
+
* Per-call overrides take precedence over registrations on the client.
|
|
1275
1290
|
*/
|
|
1276
|
-
mockOverride?:
|
|
1291
|
+
mockOverride?: MockOverrideInput | MockOverrideInput[];
|
|
1277
1292
|
/**
|
|
1278
1293
|
* Run each item against a database branch restored to the state its source
|
|
1279
1294
|
* trace saw. Pass `true` to branch with the mirror project's own sizing, or a
|
|
@@ -2168,8 +2183,9 @@ declare class Bitfab {
|
|
|
2168
2183
|
* Decorate a class method as an automatically expanded trace root.
|
|
2169
2184
|
*
|
|
2170
2185
|
* Build instrumentation turns repository functions called beneath this
|
|
2171
|
-
* method into nested spans
|
|
2172
|
-
*
|
|
2186
|
+
* method into nested spans that capture inputs, outputs, and errors by
|
|
2187
|
+
* default. A confirmed capture policy can narrow rich capture to selected
|
|
2188
|
+
* function IDs.
|
|
2173
2189
|
* Without a compatible build transform, this still records the decorated
|
|
2174
2190
|
* method as a normal rich root span but cannot discover child calls.
|
|
2175
2191
|
*
|
|
@@ -2183,8 +2199,10 @@ declare class Bitfab {
|
|
|
2183
2199
|
*
|
|
2184
2200
|
* This is the function-oriented equivalent of {@link Bitfab.trace}. Build
|
|
2185
2201
|
* instrumentation turns repository functions called beneath the wrapped
|
|
2186
|
-
* function into nested spans
|
|
2187
|
-
*
|
|
2202
|
+
* function into nested spans that capture inputs, outputs, and errors by
|
|
2203
|
+
* default. A confirmed capture policy can narrow rich capture to selected
|
|
2204
|
+
* function IDs. Without a compatible transform, this still records one
|
|
2205
|
+
* normal rich root span and runs the function unchanged.
|
|
2188
2206
|
*
|
|
2189
2207
|
* @param traceFunctionKey - Groups traces and their capture policy.
|
|
2190
2208
|
* @param optionsOrFn - Options or the workflow entrypoint to wrap.
|
|
@@ -2584,10 +2602,22 @@ declare class Bitfab {
|
|
|
2584
2602
|
* (node) => node.traceFunctionKey === "classify-intent",
|
|
2585
2603
|
* ({ inputs }) => ({ label: "refund" }),
|
|
2586
2604
|
* )
|
|
2605
|
+
* // Keyed form: the resolver only sees spans for this trace function key.
|
|
2606
|
+
* bitfab.registerMockOverride("classify-intent", ({ inputs }) => ({
|
|
2607
|
+
* label: String(inputs[0]),
|
|
2608
|
+
* }))
|
|
2609
|
+
* // Or one resolver for every child span:
|
|
2610
|
+
* bitfab.registerMockOverride(({ node }) =>
|
|
2611
|
+
* node.traceFunctionKey === "classify-intent"
|
|
2612
|
+
* ? { label: "refund" }
|
|
2613
|
+
* : NO_MOCK_OVERRIDE,
|
|
2614
|
+
* )
|
|
2587
2615
|
* ```
|
|
2588
2616
|
*/
|
|
2589
2617
|
registerMockOverride(override: MockOverride): void;
|
|
2618
|
+
registerMockOverride(resolver: MockOverrideResolver): void;
|
|
2590
2619
|
registerMockOverride(match: NodeMatcher, value: MockValue): void;
|
|
2620
|
+
registerMockOverride(traceFunctionKey: string, override: MockOverride | MockOverrideResolver): void;
|
|
2591
2621
|
/** Remove all overrides registered via {@link registerMockOverride}. */
|
|
2592
2622
|
clearMockOverrides(): void;
|
|
2593
2623
|
replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
|
|
@@ -2759,7 +2789,7 @@ declare class BitfabFunction {
|
|
|
2759
2789
|
/**
|
|
2760
2790
|
* SDK version from package.json (injected at build time)
|
|
2761
2791
|
*/
|
|
2762
|
-
declare const __version__ = "0.38.
|
|
2792
|
+
declare const __version__ = "0.38.6";
|
|
2763
2793
|
|
|
2764
2794
|
/**
|
|
2765
2795
|
* Constants for the Bitfab SDK.
|
|
@@ -2862,4 +2892,4 @@ type ReplayRegistry = Record<string, ReplayRegistration>;
|
|
|
2862
2892
|
*/
|
|
2863
2893
|
declare function defineReplayRegistry<TRegistry extends ReplayRegistry>(registry: TRegistry): TRegistry;
|
|
2864
2894
|
|
|
2865
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
|
2895
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -147,10 +147,23 @@ interface MockOverrideCtx {
|
|
|
147
147
|
*/
|
|
148
148
|
getOriginalOutput: () => Promise<unknown>;
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Return this from a mock override resolver to decline the override for the
|
|
152
|
+
* current span. Resolution continues with the next override, then the replay's
|
|
153
|
+
* base mock strategy.
|
|
154
|
+
*/
|
|
155
|
+
declare const NO_MOCK_OVERRIDE: unique symbol;
|
|
150
156
|
/** Selects which spans an override applies to. Runs on structural metadata. */
|
|
151
157
|
type NodeMatcher = (node: SpanNodeMeta) => boolean;
|
|
152
158
|
/** The function form of {@link MockValue}, receiving the override context. */
|
|
153
159
|
type MockValueFn = (ctx: MockOverrideCtx) => unknown | Promise<unknown>;
|
|
160
|
+
/**
|
|
161
|
+
* A client-wide, keyed, or per-replay resolver. A global resolver can route on
|
|
162
|
+
* `ctx.node.traceFunctionKey`; a keyed resolver is only invoked for spans with
|
|
163
|
+
* its registered key. Return {@link NO_MOCK_OVERRIDE} for spans the resolver
|
|
164
|
+
* does not want to override.
|
|
165
|
+
*/
|
|
166
|
+
type MockOverrideResolver = (ctx: MockOverrideCtx) => unknown | Promise<unknown>;
|
|
154
167
|
/**
|
|
155
168
|
* The value injected for a matched span: either a flat value used as-is, or a
|
|
156
169
|
* function of the {@link MockOverrideCtx} that returns one (or a Promise of
|
|
@@ -168,6 +181,8 @@ interface MockOverride {
|
|
|
168
181
|
match: NodeMatcher;
|
|
169
182
|
value: MockValue;
|
|
170
183
|
}
|
|
184
|
+
/** Accepted shape for one mock override declaration. */
|
|
185
|
+
type MockOverrideInput = MockOverride | MockOverrideResolver;
|
|
171
186
|
|
|
172
187
|
/**
|
|
173
188
|
* Replay context propagation via AsyncLocalStorage.
|
|
@@ -1268,12 +1283,12 @@ interface ReplayOptions {
|
|
|
1268
1283
|
/**
|
|
1269
1284
|
* Selective mock overrides: inject custom values into specific spans during
|
|
1270
1285
|
* replay, so downstream real code runs against the substituted output. Each
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1286
|
+
* Pass `{ match, value }` pairs, or one resolver invoked for every child span.
|
|
1287
|
+
* A resolver can route on `ctx.node.traceFunctionKey` and return
|
|
1288
|
+
* `NO_MOCK_OVERRIDE` to continue to the next override and base strategy.
|
|
1289
|
+
* Per-call overrides take precedence over registrations on the client.
|
|
1275
1290
|
*/
|
|
1276
|
-
mockOverride?:
|
|
1291
|
+
mockOverride?: MockOverrideInput | MockOverrideInput[];
|
|
1277
1292
|
/**
|
|
1278
1293
|
* Run each item against a database branch restored to the state its source
|
|
1279
1294
|
* trace saw. Pass `true` to branch with the mirror project's own sizing, or a
|
|
@@ -2168,8 +2183,9 @@ declare class Bitfab {
|
|
|
2168
2183
|
* Decorate a class method as an automatically expanded trace root.
|
|
2169
2184
|
*
|
|
2170
2185
|
* Build instrumentation turns repository functions called beneath this
|
|
2171
|
-
* method into nested spans
|
|
2172
|
-
*
|
|
2186
|
+
* method into nested spans that capture inputs, outputs, and errors by
|
|
2187
|
+
* default. A confirmed capture policy can narrow rich capture to selected
|
|
2188
|
+
* function IDs.
|
|
2173
2189
|
* Without a compatible build transform, this still records the decorated
|
|
2174
2190
|
* method as a normal rich root span but cannot discover child calls.
|
|
2175
2191
|
*
|
|
@@ -2183,8 +2199,10 @@ declare class Bitfab {
|
|
|
2183
2199
|
*
|
|
2184
2200
|
* This is the function-oriented equivalent of {@link Bitfab.trace}. Build
|
|
2185
2201
|
* instrumentation turns repository functions called beneath the wrapped
|
|
2186
|
-
* function into nested spans
|
|
2187
|
-
*
|
|
2202
|
+
* function into nested spans that capture inputs, outputs, and errors by
|
|
2203
|
+
* default. A confirmed capture policy can narrow rich capture to selected
|
|
2204
|
+
* function IDs. Without a compatible transform, this still records one
|
|
2205
|
+
* normal rich root span and runs the function unchanged.
|
|
2188
2206
|
*
|
|
2189
2207
|
* @param traceFunctionKey - Groups traces and their capture policy.
|
|
2190
2208
|
* @param optionsOrFn - Options or the workflow entrypoint to wrap.
|
|
@@ -2584,10 +2602,22 @@ declare class Bitfab {
|
|
|
2584
2602
|
* (node) => node.traceFunctionKey === "classify-intent",
|
|
2585
2603
|
* ({ inputs }) => ({ label: "refund" }),
|
|
2586
2604
|
* )
|
|
2605
|
+
* // Keyed form: the resolver only sees spans for this trace function key.
|
|
2606
|
+
* bitfab.registerMockOverride("classify-intent", ({ inputs }) => ({
|
|
2607
|
+
* label: String(inputs[0]),
|
|
2608
|
+
* }))
|
|
2609
|
+
* // Or one resolver for every child span:
|
|
2610
|
+
* bitfab.registerMockOverride(({ node }) =>
|
|
2611
|
+
* node.traceFunctionKey === "classify-intent"
|
|
2612
|
+
* ? { label: "refund" }
|
|
2613
|
+
* : NO_MOCK_OVERRIDE,
|
|
2614
|
+
* )
|
|
2587
2615
|
* ```
|
|
2588
2616
|
*/
|
|
2589
2617
|
registerMockOverride(override: MockOverride): void;
|
|
2618
|
+
registerMockOverride(resolver: MockOverrideResolver): void;
|
|
2590
2619
|
registerMockOverride(match: NodeMatcher, value: MockValue): void;
|
|
2620
|
+
registerMockOverride(traceFunctionKey: string, override: MockOverride | MockOverrideResolver): void;
|
|
2591
2621
|
/** Remove all overrides registered via {@link registerMockOverride}. */
|
|
2592
2622
|
clearMockOverrides(): void;
|
|
2593
2623
|
replay<TReturn>(traceFunctionKey: string, fn: (...args: any[]) => TReturn | Promise<TReturn>, options?: ReplayOptions): Promise<ReplayResult<TReturn>>;
|
|
@@ -2759,7 +2789,7 @@ declare class BitfabFunction {
|
|
|
2759
2789
|
/**
|
|
2760
2790
|
* SDK version from package.json (injected at build time)
|
|
2761
2791
|
*/
|
|
2762
|
-
declare const __version__ = "0.38.
|
|
2792
|
+
declare const __version__ = "0.38.6";
|
|
2763
2793
|
|
|
2764
2794
|
/**
|
|
2765
2795
|
* Constants for the Bitfab SDK.
|
|
@@ -2862,4 +2892,4 @@ type ReplayRegistry = Record<string, ReplayRegistration>;
|
|
|
2862
2892
|
*/
|
|
2863
2893
|
declare function defineReplayRegistry<TRegistry extends ReplayRegistry>(registry: TRegistry): TRegistry;
|
|
2864
2894
|
|
|
2865
|
-
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockStrategy, type MockValue, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
|
2895
|
+
export { type ActiveSpanContext, type AdaptContext, type AdaptInputsFn, type AllowedEnvVars, BITFAB_PROGRESS_PREFIX, type BamlExecutionResult, Bitfab, BitfabClaudeAgentHandler, type BitfabConfig, BitfabError, BitfabFunction, BitfabLangGraphCallbackHandler as BitfabLangChainCallbackHandler, BitfabLangGraphCallbackHandler, type BitfabLanguageModelMiddleware, BitfabOpenAIAgentHandler, BitfabOpenAITracingProcessor, BitfabVercelAiHandler, type CaptureWhen, type CapturedSpan, type CodeChangeFile, type CurrentSpan, type CurrentTrace, DEFAULT_SERVICE_URL, type DbBranchOptions, DbBranchReplayError, type DbBranchTimings, type DbSnapshotConfig, type DbSnapshotProvider, type DbSnapshotRef, type DetachedTrace, HttpClient, type MockOverride, type MockOverrideCtx, type MockOverrideInput, type MockOverrideResolver, type MockStrategy, type MockValue, NO_MOCK_OVERRIDE, type NodeMatcher, type NodeMethodDecorator, type NodeOptions, type ProviderDefinition, ReplayBranch, ReplayError, type ReplayItem, type ReplayItemFinishProgress, type ReplayItemStartProgress, type ReplayOptions, type ReplayOptionsFactory, type ReplayProgress, type ReplayProgressItem, type ReplayRegistration, type ReplayRegistry, type ReplayRegistryContext, type ReplayRegistryOptions, type ReplayResult, SUPPORTED_PROVIDERS, type SpanLookup, type SpanMethodDecorator, type SpanMethodDecoratorContext, type SpanNodeMeta, type SpanOccurrence, type SpanOptions, type SpanType, type TokenUsage, type TraceResponse, type TracingProcessor, type VercelCallParams, type VercelGenerateResult, type VercelStreamResult, type WrapBAMLOptions, type WrappedBamlFn, __version__, defineReplayRegistry, finalizers, flushTraces, getCurrentReplayBranch, getCurrentSpan, getCurrentTrace, reportReplayProgress, serializeReplayResult };
|
package/dist/index.js
CHANGED
|
@@ -21,20 +21,21 @@ import {
|
|
|
21
21
|
getCurrentReplayBranch,
|
|
22
22
|
getCurrentSpan,
|
|
23
23
|
getCurrentTrace
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-YCTQONNS.js";
|
|
25
|
+
import "./chunk-ZUD7OFYB.js";
|
|
26
26
|
import {
|
|
27
27
|
BITFAB_PROGRESS_PREFIX,
|
|
28
28
|
BitfabError,
|
|
29
29
|
DEFAULT_SERVICE_URL,
|
|
30
30
|
DbBranchReplayError,
|
|
31
31
|
HttpClient,
|
|
32
|
+
NO_MOCK_OVERRIDE,
|
|
32
33
|
ReplayError,
|
|
33
34
|
__version__,
|
|
34
35
|
flushTraces,
|
|
35
36
|
reportReplayProgress,
|
|
36
37
|
serializeReplayResult
|
|
37
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-O75EYGVO.js";
|
|
38
39
|
import "./chunk-H6LZRFMN.js";
|
|
39
40
|
export {
|
|
40
41
|
BITFAB_PROGRESS_PREFIX,
|
|
@@ -50,6 +51,7 @@ export {
|
|
|
50
51
|
DEFAULT_SERVICE_URL,
|
|
51
52
|
DbBranchReplayError,
|
|
52
53
|
HttpClient,
|
|
54
|
+
NO_MOCK_OVERRIDE,
|
|
53
55
|
ReplayError,
|
|
54
56
|
SUPPORTED_PROVIDERS,
|
|
55
57
|
__version__,
|
package/dist/node.cjs
CHANGED
|
@@ -97,7 +97,7 @@ var __version__, __packageName__;
|
|
|
97
97
|
var init_version_generated = __esm({
|
|
98
98
|
"src/version.generated.ts"() {
|
|
99
99
|
"use strict";
|
|
100
|
-
__version__ = "0.38.
|
|
100
|
+
__version__ = "0.38.6";
|
|
101
101
|
__packageName__ = "bitfab";
|
|
102
102
|
}
|
|
103
103
|
});
|
|
@@ -2203,11 +2203,16 @@ function normalizeMockOverrides(mockOverride) {
|
|
|
2203
2203
|
if (mockOverride === void 0) {
|
|
2204
2204
|
return [];
|
|
2205
2205
|
}
|
|
2206
|
-
|
|
2206
|
+
const overrides = Array.isArray(mockOverride) ? mockOverride : [mockOverride];
|
|
2207
|
+
return overrides.map(
|
|
2208
|
+
(override) => typeof override === "function" ? { match: () => true, value: override } : override
|
|
2209
|
+
);
|
|
2207
2210
|
}
|
|
2211
|
+
var NO_MOCK_OVERRIDE;
|
|
2208
2212
|
var init_mockOverride = __esm({
|
|
2209
2213
|
"src/mockOverride.ts"() {
|
|
2210
2214
|
"use strict";
|
|
2215
|
+
NO_MOCK_OVERRIDE = /* @__PURE__ */ Symbol("bitfab.noMockOverride");
|
|
2211
2216
|
}
|
|
2212
2217
|
});
|
|
2213
2218
|
|
|
@@ -3149,6 +3154,7 @@ __export(node_exports, {
|
|
|
3149
3154
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
3150
3155
|
DbBranchReplayError: () => DbBranchReplayError,
|
|
3151
3156
|
HttpClient: () => HttpClient,
|
|
3157
|
+
NO_MOCK_OVERRIDE: () => NO_MOCK_OVERRIDE,
|
|
3152
3158
|
ReplayError: () => ReplayError,
|
|
3153
3159
|
SUPPORTED_PROVIDERS: () => SUPPORTED_PROVIDERS,
|
|
3154
3160
|
__version__: () => __version__,
|
|
@@ -3897,11 +3903,18 @@ function currentAutoTraceScope() {
|
|
|
3897
3903
|
}
|
|
3898
3904
|
function __setBitfabAutoTraceCapturePolicy(client, traceFunctionKey, functionIds) {
|
|
3899
3905
|
const policies = autoTraceState.capturePolicies.get(client) ?? /* @__PURE__ */ new Map();
|
|
3906
|
+
if (functionIds === void 0) {
|
|
3907
|
+
policies.delete(traceFunctionKey);
|
|
3908
|
+
if (policies.size === 0) {
|
|
3909
|
+
autoTraceState.capturePolicies.delete(client);
|
|
3910
|
+
}
|
|
3911
|
+
return;
|
|
3912
|
+
}
|
|
3900
3913
|
policies.set(traceFunctionKey, new Set(functionIds));
|
|
3901
3914
|
autoTraceState.capturePolicies.set(client, policies);
|
|
3902
3915
|
}
|
|
3903
3916
|
function getAutoTraceCapturePolicy(client, traceFunctionKey) {
|
|
3904
|
-
return autoTraceState.capturePolicies.get(client)?.get(traceFunctionKey)
|
|
3917
|
+
return autoTraceState.capturePolicies.get(client)?.get(traceFunctionKey);
|
|
3905
3918
|
}
|
|
3906
3919
|
|
|
3907
3920
|
// src/optionalPeer.ts
|
|
@@ -5690,8 +5703,9 @@ var Bitfab = class {
|
|
|
5690
5703
|
* Decorate a class method as an automatically expanded trace root.
|
|
5691
5704
|
*
|
|
5692
5705
|
* Build instrumentation turns repository functions called beneath this
|
|
5693
|
-
* method into nested spans
|
|
5694
|
-
*
|
|
5706
|
+
* method into nested spans that capture inputs, outputs, and errors by
|
|
5707
|
+
* default. A confirmed capture policy can narrow rich capture to selected
|
|
5708
|
+
* function IDs.
|
|
5695
5709
|
* Without a compatible build transform, this still records the decorated
|
|
5696
5710
|
* method as a normal rich root span but cannot discover child calls.
|
|
5697
5711
|
*
|
|
@@ -5901,7 +5915,7 @@ var Bitfab = class {
|
|
|
5901
5915
|
type: nodeConfiguration?.type ?? "function",
|
|
5902
5916
|
captureWhen: "nested",
|
|
5903
5917
|
functionId: definition.id,
|
|
5904
|
-
captureContent: nodeConfiguration !== void 0 || capturePolicy.has(definition.id),
|
|
5918
|
+
captureContent: nodeConfiguration !== void 0 || capturePolicy === void 0 || capturePolicy.has(definition.id),
|
|
5905
5919
|
autoTraceDefinition: definition,
|
|
5906
5920
|
...nodeConfiguration?.testRunId !== void 0 && {
|
|
5907
5921
|
testRunId: nodeConfiguration.testRunId
|
|
@@ -5966,7 +5980,11 @@ var Bitfab = class {
|
|
|
5966
5980
|
const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
|
|
5967
5981
|
(id) => typeof id === "string" && id.startsWith(`${AUTO_TRACE_PROTOCOL}:`)
|
|
5968
5982
|
).slice(0, DEFAULT_AUTO_TRACE_MAX_SPANS) : [];
|
|
5969
|
-
__setBitfabAutoTraceCapturePolicy(
|
|
5983
|
+
__setBitfabAutoTraceCapturePolicy(
|
|
5984
|
+
this,
|
|
5985
|
+
traceFunctionKey,
|
|
5986
|
+
policy.revision === null ? void 0 : functionIds
|
|
5987
|
+
);
|
|
5970
5988
|
state.refreshAfter = Date.now() + AUTO_TRACE_POLICY_REFRESH_MS;
|
|
5971
5989
|
}).catch(() => {
|
|
5972
5990
|
state.refreshAfter = Date.now() + AUTO_TRACE_POLICY_RETRY_MS;
|
|
@@ -6578,6 +6596,49 @@ var Bitfab = class {
|
|
|
6578
6596
|
} catch {
|
|
6579
6597
|
}
|
|
6580
6598
|
};
|
|
6599
|
+
const recordSpan = (result) => {
|
|
6600
|
+
if (options.finalize) {
|
|
6601
|
+
void self.httpClient.trackDeferred(
|
|
6602
|
+
Promise.resolve().then(() => options.finalize(result)).then((output) => sendSpan({ result: output })).catch(
|
|
6603
|
+
(error) => sendSpan({
|
|
6604
|
+
result: void 0,
|
|
6605
|
+
error: error instanceof Error ? `finalize failed: ${error.message}` : `finalize failed: ${String(error)}`
|
|
6606
|
+
})
|
|
6607
|
+
)
|
|
6608
|
+
);
|
|
6609
|
+
} else {
|
|
6610
|
+
void sendSpan({ result });
|
|
6611
|
+
}
|
|
6612
|
+
};
|
|
6613
|
+
executeWithContext = () => {
|
|
6614
|
+
let result;
|
|
6615
|
+
try {
|
|
6616
|
+
result = fn.apply(this, args);
|
|
6617
|
+
} catch (error) {
|
|
6618
|
+
void sendSpan({
|
|
6619
|
+
result: void 0,
|
|
6620
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6621
|
+
});
|
|
6622
|
+
throw error;
|
|
6623
|
+
}
|
|
6624
|
+
if (result instanceof Promise) {
|
|
6625
|
+
return result.then((resolvedResult) => {
|
|
6626
|
+
recordSpan(resolvedResult);
|
|
6627
|
+
return resolvedResult;
|
|
6628
|
+
}).catch((error) => {
|
|
6629
|
+
void sendSpan({
|
|
6630
|
+
result: void 0,
|
|
6631
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6632
|
+
});
|
|
6633
|
+
throw error;
|
|
6634
|
+
});
|
|
6635
|
+
}
|
|
6636
|
+
if (isAsyncGenerator(result)) {
|
|
6637
|
+
return wrapAsyncGenerator(result, newStack, sendSpan);
|
|
6638
|
+
}
|
|
6639
|
+
recordSpan(result);
|
|
6640
|
+
return result;
|
|
6641
|
+
};
|
|
6581
6642
|
const replayCtxForMock = getReplayContext();
|
|
6582
6643
|
if (replayCtxForMock?.mockTree && !isRootSpan) {
|
|
6583
6644
|
const counters = replayCtxForMock.callCounters;
|
|
@@ -6636,6 +6697,7 @@ var Bitfab = class {
|
|
|
6636
6697
|
}
|
|
6637
6698
|
return output;
|
|
6638
6699
|
};
|
|
6700
|
+
const shouldMockWithBaseStrategy = replayCtxForMock.mockStrategy === "all" || replayCtxForMock.mockStrategy === "marked" && options.mockOnReplay === true;
|
|
6639
6701
|
if (replayCtxForMock.mockOverrides?.length) {
|
|
6640
6702
|
const nodeMeta = {
|
|
6641
6703
|
traceFunctionKey,
|
|
@@ -6643,28 +6705,75 @@ var Bitfab = class {
|
|
|
6643
6705
|
type: options.type ?? "custom",
|
|
6644
6706
|
originalSpanId: mockSpan?.sourceSpanId
|
|
6645
6707
|
};
|
|
6646
|
-
const
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6708
|
+
const overrideCtx = {
|
|
6709
|
+
node: nodeMeta,
|
|
6710
|
+
inputs: args,
|
|
6711
|
+
getOriginalOutput: () => Promise.resolve(resolveRecordedOutput())
|
|
6712
|
+
};
|
|
6713
|
+
const resolveOverrideFrom = (startIndex) => {
|
|
6714
|
+
for (let index = startIndex; index < replayCtxForMock.mockOverrides.length; index += 1) {
|
|
6715
|
+
const override = replayCtxForMock.mockOverrides[index];
|
|
6716
|
+
if (!override?.match(nodeMeta)) {
|
|
6717
|
+
continue;
|
|
6718
|
+
}
|
|
6719
|
+
const injected = resolveMockValue(override.value, overrideCtx);
|
|
6720
|
+
if (injected instanceof Promise) {
|
|
6721
|
+
return injected.then(
|
|
6722
|
+
(output) => output === NO_MOCK_OVERRIDE ? resolveOverrideFrom(index + 1) : { matched: true, output }
|
|
6723
|
+
);
|
|
6724
|
+
}
|
|
6725
|
+
if (injected !== NO_MOCK_OVERRIDE) {
|
|
6726
|
+
return { matched: true, output: injected };
|
|
6727
|
+
}
|
|
6657
6728
|
}
|
|
6658
|
-
return
|
|
6729
|
+
return { matched: false };
|
|
6730
|
+
};
|
|
6731
|
+
const resolution = resolveOverrideFrom(0);
|
|
6732
|
+
if (resolution instanceof Promise) {
|
|
6733
|
+
if (!fnReturnsPromise) {
|
|
6734
|
+
throw new BitfabError(
|
|
6735
|
+
`Cannot resolve an asynchronous mock override for synchronous span "${traceFunctionKey}". Make the wrapped function async or return NO_MOCK_OVERRIDE synchronously.`
|
|
6736
|
+
);
|
|
6737
|
+
}
|
|
6738
|
+
return runWithSpanStack(newStack, async () => {
|
|
6739
|
+
const resolved = await resolution;
|
|
6740
|
+
if (resolved.matched) {
|
|
6741
|
+
void sendSpan({
|
|
6742
|
+
result: resolved.output,
|
|
6743
|
+
mocked: true,
|
|
6744
|
+
mockTarget: "output",
|
|
6745
|
+
mockSource: "override"
|
|
6746
|
+
});
|
|
6747
|
+
return resolved.output;
|
|
6748
|
+
}
|
|
6749
|
+
if (shouldMockWithBaseStrategy && !mockSpan) {
|
|
6750
|
+
throw new BitfabError(
|
|
6751
|
+
`Replay selected span "${traceFunctionKey}:${baseSpanParams.spanName}" for mocking, but recorded occurrence ${callIndex + 1} is unavailable. The real span was not executed.`
|
|
6752
|
+
);
|
|
6753
|
+
}
|
|
6754
|
+
if (shouldMockWithBaseStrategy) {
|
|
6755
|
+
const output = await resolveRecordedOutput();
|
|
6756
|
+
void sendSpan({
|
|
6757
|
+
result: output,
|
|
6758
|
+
mocked: true,
|
|
6759
|
+
mockTarget: "output",
|
|
6760
|
+
mockSource: "recorded"
|
|
6761
|
+
});
|
|
6762
|
+
return output;
|
|
6763
|
+
}
|
|
6764
|
+
return executeWithContext();
|
|
6765
|
+
});
|
|
6766
|
+
}
|
|
6767
|
+
if (resolution.matched) {
|
|
6768
|
+
return emitMock(resolution.output, "override");
|
|
6659
6769
|
}
|
|
6660
6770
|
}
|
|
6661
|
-
|
|
6662
|
-
if (shouldMock && !mockSpan) {
|
|
6771
|
+
if (shouldMockWithBaseStrategy && !mockSpan) {
|
|
6663
6772
|
throw new BitfabError(
|
|
6664
6773
|
`Replay selected span "${traceFunctionKey}:${baseSpanParams.spanName}" for mocking, but recorded occurrence ${callIndex + 1} is unavailable. The real span was not executed.`
|
|
6665
6774
|
);
|
|
6666
6775
|
}
|
|
6667
|
-
if (
|
|
6776
|
+
if (shouldMockWithBaseStrategy) {
|
|
6668
6777
|
const recorded = resolveRecordedOutput();
|
|
6669
6778
|
if (recorded instanceof Promise) {
|
|
6670
6779
|
return emitMockAsync(recorded, "recorded");
|
|
@@ -6672,49 +6781,6 @@ var Bitfab = class {
|
|
|
6672
6781
|
return emitMock(recorded, "recorded");
|
|
6673
6782
|
}
|
|
6674
6783
|
}
|
|
6675
|
-
const recordSpan = (result) => {
|
|
6676
|
-
if (options.finalize) {
|
|
6677
|
-
void self.httpClient.trackDeferred(
|
|
6678
|
-
Promise.resolve().then(() => options.finalize(result)).then((output) => sendSpan({ result: output })).catch(
|
|
6679
|
-
(error) => sendSpan({
|
|
6680
|
-
result: void 0,
|
|
6681
|
-
error: error instanceof Error ? `finalize failed: ${error.message}` : `finalize failed: ${String(error)}`
|
|
6682
|
-
})
|
|
6683
|
-
)
|
|
6684
|
-
);
|
|
6685
|
-
} else {
|
|
6686
|
-
void sendSpan({ result });
|
|
6687
|
-
}
|
|
6688
|
-
};
|
|
6689
|
-
executeWithContext = () => {
|
|
6690
|
-
let result;
|
|
6691
|
-
try {
|
|
6692
|
-
result = fn.apply(this, args);
|
|
6693
|
-
} catch (error) {
|
|
6694
|
-
void sendSpan({
|
|
6695
|
-
result: void 0,
|
|
6696
|
-
error: error instanceof Error ? error.message : String(error)
|
|
6697
|
-
});
|
|
6698
|
-
throw error;
|
|
6699
|
-
}
|
|
6700
|
-
if (result instanceof Promise) {
|
|
6701
|
-
return result.then((resolvedResult) => {
|
|
6702
|
-
recordSpan(resolvedResult);
|
|
6703
|
-
return resolvedResult;
|
|
6704
|
-
}).catch((error) => {
|
|
6705
|
-
void sendSpan({
|
|
6706
|
-
result: void 0,
|
|
6707
|
-
error: error instanceof Error ? error.message : String(error)
|
|
6708
|
-
});
|
|
6709
|
-
throw error;
|
|
6710
|
-
});
|
|
6711
|
-
}
|
|
6712
|
-
if (isAsyncGenerator(result)) {
|
|
6713
|
-
return wrapAsyncGenerator(result, newStack, sendSpan);
|
|
6714
|
-
}
|
|
6715
|
-
recordSpan(result);
|
|
6716
|
-
return result;
|
|
6717
|
-
};
|
|
6718
6784
|
} catch (setupError) {
|
|
6719
6785
|
if (registeredTraceId) {
|
|
6720
6786
|
activeTraceStates.delete(registeredTraceId);
|
|
@@ -7001,8 +7067,40 @@ var Bitfab = class {
|
|
|
7001
7067
|
...params.mockSource && { mockSource: params.mockSource }
|
|
7002
7068
|
});
|
|
7003
7069
|
}
|
|
7004
|
-
registerMockOverride(
|
|
7005
|
-
|
|
7070
|
+
registerMockOverride(overrideOrResolverOrMatch, ...values) {
|
|
7071
|
+
let override;
|
|
7072
|
+
if (typeof overrideOrResolverOrMatch === "string") {
|
|
7073
|
+
const keyedOverride = values[0];
|
|
7074
|
+
if (values.length !== 1 || keyedOverride === void 0) {
|
|
7075
|
+
throw new BitfabError(
|
|
7076
|
+
"registerMockOverride(traceFunctionKey, override) requires a resolver function or { match, value } override."
|
|
7077
|
+
);
|
|
7078
|
+
}
|
|
7079
|
+
if (typeof keyedOverride === "function") {
|
|
7080
|
+
override = {
|
|
7081
|
+
match: (node) => node.traceFunctionKey === overrideOrResolverOrMatch,
|
|
7082
|
+
value: keyedOverride
|
|
7083
|
+
};
|
|
7084
|
+
} else if (typeof keyedOverride === "object" && keyedOverride !== null && "match" in keyedOverride && "value" in keyedOverride) {
|
|
7085
|
+
override = {
|
|
7086
|
+
match: (node) => node.traceFunctionKey === overrideOrResolverOrMatch && keyedOverride.match(node),
|
|
7087
|
+
value: keyedOverride.value
|
|
7088
|
+
};
|
|
7089
|
+
} else {
|
|
7090
|
+
throw new BitfabError(
|
|
7091
|
+
"registerMockOverride(traceFunctionKey, override) requires a resolver function or { match, value } override."
|
|
7092
|
+
);
|
|
7093
|
+
}
|
|
7094
|
+
} else if (typeof overrideOrResolverOrMatch !== "function") {
|
|
7095
|
+
override = overrideOrResolverOrMatch;
|
|
7096
|
+
} else if (values.length === 0) {
|
|
7097
|
+
override = { match: () => true, value: overrideOrResolverOrMatch };
|
|
7098
|
+
} else {
|
|
7099
|
+
override = {
|
|
7100
|
+
match: overrideOrResolverOrMatch,
|
|
7101
|
+
value: values[0]
|
|
7102
|
+
};
|
|
7103
|
+
}
|
|
7006
7104
|
this.mockOverrides.push(override);
|
|
7007
7105
|
}
|
|
7008
7106
|
/** Remove all overrides registered via {@link registerMockOverride}. */
|
|
@@ -7252,6 +7350,7 @@ var finalizers = {
|
|
|
7252
7350
|
|
|
7253
7351
|
// src/index.ts
|
|
7254
7352
|
init_http();
|
|
7353
|
+
init_mockOverride();
|
|
7255
7354
|
init_replay();
|
|
7256
7355
|
|
|
7257
7356
|
// src/replayRegistry.ts
|
|
@@ -7279,6 +7378,7 @@ assertAsyncStorageRegistered();
|
|
|
7279
7378
|
DEFAULT_SERVICE_URL,
|
|
7280
7379
|
DbBranchReplayError,
|
|
7281
7380
|
HttpClient,
|
|
7381
|
+
NO_MOCK_OVERRIDE,
|
|
7282
7382
|
ReplayError,
|
|
7283
7383
|
SUPPORTED_PROVIDERS,
|
|
7284
7384
|
__version__,
|