axiom 0.33.0 → 0.34.1
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/{app-scope-Ca3IbW3a.d.cts → app-scope-DPtynE6Y.d.cts} +1 -2
- package/dist/{app-scope-Ca3IbW3a.d.ts → app-scope-DPtynE6Y.d.ts} +1 -2
- package/dist/bin.cjs +198 -177
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +5 -5
- package/dist/{chunk-QD3P2FOF.js → chunk-4G7GDQ6Q.js} +14 -151
- package/dist/chunk-4G7GDQ6Q.js.map +1 -0
- package/dist/{chunk-MSHFK4M4.js → chunk-AAEGYMAU.js} +260 -93
- package/dist/chunk-AAEGYMAU.js.map +1 -0
- package/dist/{chunk-C5XDEFQ5.js → chunk-KX7Z2MF4.js} +18 -15
- package/dist/chunk-KX7Z2MF4.js.map +1 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +1 -1
- package/dist/evals.cjs +37 -70
- package/dist/evals.cjs.map +1 -1
- package/dist/evals.d.cts +1 -14
- package/dist/evals.d.ts +1 -14
- package/dist/evals.js +100 -6
- package/dist/evals.js.map +1 -1
- package/dist/index.cjs +259 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-C5XDEFQ5.js.map +0 -1
- package/dist/chunk-MSHFK4M4.js.map +0 -1
- package/dist/chunk-QD3P2FOF.js.map +0 -1
|
@@ -73,7 +73,7 @@ import { trace } from "@opentelemetry/api";
|
|
|
73
73
|
// package.json
|
|
74
74
|
var package_default = {
|
|
75
75
|
name: "axiom",
|
|
76
|
-
version: "0.
|
|
76
|
+
version: "0.34.1",
|
|
77
77
|
type: "module",
|
|
78
78
|
author: "Axiom, Inc.",
|
|
79
79
|
contributors: [
|
|
@@ -223,8 +223,8 @@ function initAxiomAI(config) {
|
|
|
223
223
|
function getGlobalTracer() {
|
|
224
224
|
const scope = globalThis[AXIOM_AI_SCOPE_KEY];
|
|
225
225
|
if (!scope) {
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
226
|
+
const isDebug = process.env.AXIOM_DEBUG === "true";
|
|
227
|
+
if (!isDebug) {
|
|
228
228
|
console.warn(
|
|
229
229
|
"[AxiomAI] AXIOM_AI_SCOPE_KEY is undefined. This probably means that initAxiomAI() was never called. Make sure to call initAxiomAI({ tracer }) in your instrumentation setup."
|
|
230
230
|
);
|
|
@@ -727,8 +727,8 @@ function isNoOpTracerProvider() {
|
|
|
727
727
|
function getTracer() {
|
|
728
728
|
const tracer = getGlobalTracer();
|
|
729
729
|
if (isNoOpTracerProvider()) {
|
|
730
|
-
const
|
|
731
|
-
if (!
|
|
730
|
+
const isDebug = process.env.AXIOM_DEBUG === "true";
|
|
731
|
+
if (!isDebug) {
|
|
732
732
|
console.warn(
|
|
733
733
|
"[AxiomAI] No TracerProvider registered - spans will be no-op. Make sure to call initAxiomAI() after your OpenTelemetry SDK has started (sdk.start())."
|
|
734
734
|
);
|
|
@@ -1039,8 +1039,8 @@ function withSpan(meta, fn, opts) {
|
|
|
1039
1039
|
const provider = trace3.getTracerProvider();
|
|
1040
1040
|
const providerIsNoOp = provider.constructor.name === "NoopTracerProvider";
|
|
1041
1041
|
if (providerIsNoOp) {
|
|
1042
|
-
const
|
|
1043
|
-
if (!
|
|
1042
|
+
const isDebug = process.env.AXIOM_DEBUG === "true";
|
|
1043
|
+
if (!isDebug) {
|
|
1044
1044
|
console.warn(
|
|
1045
1045
|
"[AxiomAI] No TracerProvider registered - spans are no-op. Make sure to call initAxiomAI() after your OpenTelemetry SDK has started."
|
|
1046
1046
|
);
|
|
@@ -2435,6 +2435,113 @@ function generateExampleForIssue(issue, path) {
|
|
|
2435
2435
|
// src/util/dot-path.ts
|
|
2436
2436
|
init_esm_shims();
|
|
2437
2437
|
import { z } from "zod";
|
|
2438
|
+
|
|
2439
|
+
// src/util/zod-internals.ts
|
|
2440
|
+
init_esm_shims();
|
|
2441
|
+
function isZodV4Schema(schema) {
|
|
2442
|
+
if (!schema || typeof schema !== "object") return false;
|
|
2443
|
+
const s = schema;
|
|
2444
|
+
return "_zod" in s;
|
|
2445
|
+
}
|
|
2446
|
+
function assertZodV4(schema, context4) {
|
|
2447
|
+
if (!isZodV4Schema(schema)) {
|
|
2448
|
+
throw new Error(
|
|
2449
|
+
`[AxiomAI] Zod v4 schemas are required (detected in ${context4}). Found unsupported Zod version.`
|
|
2450
|
+
);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
function getDef(schema) {
|
|
2454
|
+
if (!schema || typeof schema !== "object") return void 0;
|
|
2455
|
+
const s = schema;
|
|
2456
|
+
if (s._zod && typeof s._zod === "object") {
|
|
2457
|
+
const zod = s._zod;
|
|
2458
|
+
if (zod.def && typeof zod.def === "object") {
|
|
2459
|
+
return zod.def;
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
return void 0;
|
|
2463
|
+
}
|
|
2464
|
+
function getDefRawType(def) {
|
|
2465
|
+
if (!def) return void 0;
|
|
2466
|
+
const raw = def.type;
|
|
2467
|
+
if (raw == null) return void 0;
|
|
2468
|
+
return typeof raw === "string" ? raw : String(raw);
|
|
2469
|
+
}
|
|
2470
|
+
var KNOWN_KINDS = /* @__PURE__ */ new Set([
|
|
2471
|
+
"object",
|
|
2472
|
+
"optional",
|
|
2473
|
+
"default",
|
|
2474
|
+
"nullable",
|
|
2475
|
+
"readonly",
|
|
2476
|
+
"prefault",
|
|
2477
|
+
"nonoptional",
|
|
2478
|
+
"catch",
|
|
2479
|
+
"array",
|
|
2480
|
+
"record",
|
|
2481
|
+
"union",
|
|
2482
|
+
"discriminatedunion"
|
|
2483
|
+
]);
|
|
2484
|
+
function getKind(schemaOrDef) {
|
|
2485
|
+
const def = schemaOrDef && typeof schemaOrDef === "object" && "type" in schemaOrDef ? schemaOrDef : getDef(schemaOrDef);
|
|
2486
|
+
const raw = getDefRawType(def);
|
|
2487
|
+
if (!raw) return void 0;
|
|
2488
|
+
const normalized = raw.toLowerCase();
|
|
2489
|
+
return KNOWN_KINDS.has(normalized) ? normalized : "other";
|
|
2490
|
+
}
|
|
2491
|
+
function isObjectSchema(schema) {
|
|
2492
|
+
if (!schema || typeof schema !== "object") return false;
|
|
2493
|
+
if ("shape" in schema && typeof schema.shape === "object") {
|
|
2494
|
+
return true;
|
|
2495
|
+
}
|
|
2496
|
+
return getKind(schema) === "object";
|
|
2497
|
+
}
|
|
2498
|
+
function getInnerType(schema) {
|
|
2499
|
+
const def = getDef(schema);
|
|
2500
|
+
return def?.innerType;
|
|
2501
|
+
}
|
|
2502
|
+
function getArrayElement(schema) {
|
|
2503
|
+
const def = getDef(schema);
|
|
2504
|
+
return def?.element;
|
|
2505
|
+
}
|
|
2506
|
+
function getShape(schema) {
|
|
2507
|
+
if (!schema || typeof schema !== "object") return void 0;
|
|
2508
|
+
const s = schema;
|
|
2509
|
+
if (s.shape && typeof s.shape === "object") {
|
|
2510
|
+
return s.shape;
|
|
2511
|
+
}
|
|
2512
|
+
return void 0;
|
|
2513
|
+
}
|
|
2514
|
+
function getDefaultValue(schema) {
|
|
2515
|
+
const def = getDef(schema);
|
|
2516
|
+
return def?.defaultValue;
|
|
2517
|
+
}
|
|
2518
|
+
var TRANSPARENT_WRAPPERS = [
|
|
2519
|
+
"optional",
|
|
2520
|
+
"nullable",
|
|
2521
|
+
"default",
|
|
2522
|
+
"readonly",
|
|
2523
|
+
"prefault",
|
|
2524
|
+
"nonoptional",
|
|
2525
|
+
"catch"
|
|
2526
|
+
// transparent for schema structure, but alters error behavior
|
|
2527
|
+
];
|
|
2528
|
+
function unwrapTransparent(schema) {
|
|
2529
|
+
let current = schema;
|
|
2530
|
+
for (let i = 0; i < 10; i++) {
|
|
2531
|
+
const kind = getKind(current);
|
|
2532
|
+
if (!kind) break;
|
|
2533
|
+
if (TRANSPARENT_WRAPPERS.includes(kind)) {
|
|
2534
|
+
const inner = getInnerType(current);
|
|
2535
|
+
if (!inner) break;
|
|
2536
|
+
current = inner;
|
|
2537
|
+
continue;
|
|
2538
|
+
}
|
|
2539
|
+
break;
|
|
2540
|
+
}
|
|
2541
|
+
return current;
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
// src/util/dot-path.ts
|
|
2438
2545
|
function parsePath(path) {
|
|
2439
2546
|
return path.split(".");
|
|
2440
2547
|
}
|
|
@@ -2473,16 +2580,14 @@ function isValidPath(schema, segments) {
|
|
|
2473
2580
|
let currentSchema = schema;
|
|
2474
2581
|
for (let i = 0; i < segments.length; i++) {
|
|
2475
2582
|
const segment = segments[i];
|
|
2476
|
-
|
|
2583
|
+
const shape = getShape(currentSchema);
|
|
2584
|
+
if (!shape || !(segment in shape)) {
|
|
2477
2585
|
return false;
|
|
2478
2586
|
}
|
|
2479
2587
|
if (i < segments.length - 1) {
|
|
2480
|
-
const nextSchema =
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
unwrappedSchema = unwrappedSchema._def.innerType || unwrappedSchema._def.schema;
|
|
2484
|
-
}
|
|
2485
|
-
if (!unwrappedSchema || unwrappedSchema._def?.type !== "object") {
|
|
2588
|
+
const nextSchema = shape[segment];
|
|
2589
|
+
const unwrappedSchema = unwrapTransparent(nextSchema);
|
|
2590
|
+
if (!isObjectSchema(unwrappedSchema)) {
|
|
2486
2591
|
return false;
|
|
2487
2592
|
}
|
|
2488
2593
|
currentSchema = unwrappedSchema;
|
|
@@ -2504,24 +2609,30 @@ function findSchemaAtPath(rootSchema, segments) {
|
|
|
2504
2609
|
if (!rootSchema || segments.length === 0) return void 0;
|
|
2505
2610
|
let current = rootSchema;
|
|
2506
2611
|
if (segments.length > 0) {
|
|
2507
|
-
|
|
2612
|
+
const rootShape = getShape(current);
|
|
2613
|
+
if (!rootShape || !(segments[0] in rootShape)) {
|
|
2508
2614
|
return void 0;
|
|
2509
2615
|
}
|
|
2510
|
-
current =
|
|
2616
|
+
current = rootShape[segments[0]];
|
|
2511
2617
|
for (let i = 1; i < segments.length; i++) {
|
|
2512
2618
|
const segment = segments[i];
|
|
2513
|
-
|
|
2619
|
+
const def = getDef(current);
|
|
2620
|
+
if (!def) {
|
|
2514
2621
|
return void 0;
|
|
2515
2622
|
}
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
if (!nextSchema) {
|
|
2519
|
-
return void 0;
|
|
2520
|
-
}
|
|
2521
|
-
current = nextSchema;
|
|
2522
|
-
} else {
|
|
2623
|
+
current = unwrapTransparent(current);
|
|
2624
|
+
if (!isObjectSchema(current)) {
|
|
2523
2625
|
return void 0;
|
|
2524
2626
|
}
|
|
2627
|
+
const shape = getShape(current);
|
|
2628
|
+
if (!shape) {
|
|
2629
|
+
return void 0;
|
|
2630
|
+
}
|
|
2631
|
+
const nextSchema = shape[segment];
|
|
2632
|
+
if (!nextSchema) {
|
|
2633
|
+
return void 0;
|
|
2634
|
+
}
|
|
2635
|
+
current = nextSchema;
|
|
2525
2636
|
}
|
|
2526
2637
|
return current;
|
|
2527
2638
|
}
|
|
@@ -2542,8 +2653,62 @@ function buildSchemaForPath(rootSchema, segments) {
|
|
|
2542
2653
|
return currentSchema;
|
|
2543
2654
|
}
|
|
2544
2655
|
|
|
2656
|
+
// src/util/deep-partial-schema.ts
|
|
2657
|
+
init_esm_shims();
|
|
2658
|
+
import { z as z2 } from "zod";
|
|
2659
|
+
function makeDeepPartial(schema) {
|
|
2660
|
+
const shape = schema.shape;
|
|
2661
|
+
const newShape = {};
|
|
2662
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
2663
|
+
newShape[key] = makeDeepPartialField(value);
|
|
2664
|
+
}
|
|
2665
|
+
return z2.object(newShape);
|
|
2666
|
+
}
|
|
2667
|
+
function makeDeepPartialField(fieldSchema) {
|
|
2668
|
+
const kind = getKind(fieldSchema);
|
|
2669
|
+
if (isObjectSchema(fieldSchema)) {
|
|
2670
|
+
const partialObject = makeDeepPartial(fieldSchema);
|
|
2671
|
+
return partialObject.optional();
|
|
2672
|
+
}
|
|
2673
|
+
if (kind === "optional") {
|
|
2674
|
+
const inner = getInnerType(fieldSchema);
|
|
2675
|
+
if (inner && isObjectSchema(inner)) {
|
|
2676
|
+
const partialInner = makeDeepPartial(inner);
|
|
2677
|
+
return partialInner.optional();
|
|
2678
|
+
}
|
|
2679
|
+
return fieldSchema;
|
|
2680
|
+
}
|
|
2681
|
+
if (kind === "nullable") {
|
|
2682
|
+
const inner = getInnerType(fieldSchema);
|
|
2683
|
+
if (inner && isObjectSchema(inner)) {
|
|
2684
|
+
const partialInner = makeDeepPartial(inner);
|
|
2685
|
+
return partialInner.nullable().optional();
|
|
2686
|
+
}
|
|
2687
|
+
return fieldSchema.optional();
|
|
2688
|
+
}
|
|
2689
|
+
if (kind === "default") {
|
|
2690
|
+
const inner = getInnerType(fieldSchema);
|
|
2691
|
+
const defaultValue = getDefaultValue(fieldSchema);
|
|
2692
|
+
if (inner && isObjectSchema(inner)) {
|
|
2693
|
+
const partialInner = makeDeepPartial(inner);
|
|
2694
|
+
return partialInner.default(defaultValue);
|
|
2695
|
+
}
|
|
2696
|
+
return fieldSchema.optional();
|
|
2697
|
+
}
|
|
2698
|
+
if (kind === "array") {
|
|
2699
|
+
const element = getArrayElement(fieldSchema);
|
|
2700
|
+
if (element && isObjectSchema(element)) {
|
|
2701
|
+
const partialElement = makeDeepPartial(element);
|
|
2702
|
+
return z2.array(partialElement).optional();
|
|
2703
|
+
}
|
|
2704
|
+
return fieldSchema.optional();
|
|
2705
|
+
}
|
|
2706
|
+
return fieldSchema.optional();
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2545
2709
|
// src/validate-flags.ts
|
|
2546
2710
|
function validateCliFlags(flagSchema) {
|
|
2711
|
+
assertZodV4(flagSchema, "flagSchema");
|
|
2547
2712
|
const globalOverrides = getGlobalFlagOverrides();
|
|
2548
2713
|
if (Object.keys(globalOverrides).length === 0) {
|
|
2549
2714
|
return;
|
|
@@ -2561,7 +2726,8 @@ function validateFlags(flagSchema, globalOverrides) {
|
|
|
2561
2726
|
}
|
|
2562
2727
|
}
|
|
2563
2728
|
const nestedObject = dotNotationToNested(globalOverrides);
|
|
2564
|
-
const
|
|
2729
|
+
const deepPartialSchema = makeDeepPartial(flagSchema);
|
|
2730
|
+
const result = deepPartialSchema.safeParse(nestedObject);
|
|
2565
2731
|
if (!result.success) {
|
|
2566
2732
|
console.error("\u274C Invalid CLI flags:");
|
|
2567
2733
|
console.error(formatZodErrors(result.error));
|
|
@@ -2698,29 +2864,30 @@ function isPickedFlag(flagPath, pickedFlags) {
|
|
|
2698
2864
|
}
|
|
2699
2865
|
function assertNoUnions(schema, path = "schema") {
|
|
2700
2866
|
if (!schema) return;
|
|
2701
|
-
const
|
|
2702
|
-
if (!
|
|
2703
|
-
|
|
2704
|
-
|
|
2867
|
+
const kind = getKind(schema);
|
|
2868
|
+
if (!kind) return;
|
|
2869
|
+
if (kind === "default" || kind === "optional" || kind === "nullable") {
|
|
2870
|
+
const innerType = getInnerType(schema);
|
|
2705
2871
|
return assertNoUnions(innerType, path);
|
|
2706
2872
|
}
|
|
2707
|
-
if (
|
|
2873
|
+
if (kind === "union" || kind === "discriminatedunion") {
|
|
2708
2874
|
throw new Error(`[AxiomAI] Union types are not supported in flag schemas (found at "${path}")`);
|
|
2709
2875
|
}
|
|
2710
|
-
if (
|
|
2711
|
-
const shape =
|
|
2876
|
+
if (kind === "object") {
|
|
2877
|
+
const shape = getShape(schema);
|
|
2712
2878
|
if (shape) {
|
|
2713
2879
|
for (const [k, v] of Object.entries(shape)) {
|
|
2714
2880
|
assertNoUnions(v, `${path}.${k}`);
|
|
2715
2881
|
}
|
|
2716
2882
|
}
|
|
2717
|
-
} else if (
|
|
2718
|
-
const
|
|
2719
|
-
if (
|
|
2720
|
-
assertNoUnions(
|
|
2883
|
+
} else if (kind === "array") {
|
|
2884
|
+
const innerType = getInnerType(schema);
|
|
2885
|
+
if (innerType) {
|
|
2886
|
+
assertNoUnions(innerType, `${path}[]`);
|
|
2721
2887
|
}
|
|
2722
|
-
} else if (
|
|
2723
|
-
const
|
|
2888
|
+
} else if (kind === "record") {
|
|
2889
|
+
const def = getDef(schema);
|
|
2890
|
+
const valueType = def?.valueType;
|
|
2724
2891
|
if (valueType) {
|
|
2725
2892
|
assertNoUnions(valueType, `${path}{}`);
|
|
2726
2893
|
}
|
|
@@ -2730,27 +2897,28 @@ function ensureAllDefaults(schema, path = "") {
|
|
|
2730
2897
|
const missingDefaults = [];
|
|
2731
2898
|
function checkDefaults(current, currentPath) {
|
|
2732
2899
|
if (!current) return;
|
|
2733
|
-
const
|
|
2734
|
-
if (!
|
|
2735
|
-
const
|
|
2736
|
-
const hasDefault = defaultValue !== void 0;
|
|
2737
|
-
if (
|
|
2900
|
+
const kind = getKind(current);
|
|
2901
|
+
if (!kind) return;
|
|
2902
|
+
const def = getDef(current);
|
|
2903
|
+
const hasDefault = def?.defaultValue !== void 0;
|
|
2904
|
+
if (kind === "default") {
|
|
2738
2905
|
return;
|
|
2739
2906
|
}
|
|
2740
|
-
if (
|
|
2907
|
+
if (kind === "optional" || kind === "nullable") {
|
|
2908
|
+
const innerType = getInnerType(current);
|
|
2741
2909
|
return checkDefaults(innerType, currentPath);
|
|
2742
2910
|
}
|
|
2743
|
-
if (
|
|
2911
|
+
if (kind === "record") {
|
|
2744
2912
|
throw new Error(
|
|
2745
2913
|
`[AxiomAI] ZodRecord is not supported in flag schemas (found at "${currentPath || "root"}")
|
|
2746
2914
|
All flag fields must have known keys and defaults. Consider using z.object() instead.`
|
|
2747
2915
|
);
|
|
2748
2916
|
}
|
|
2749
|
-
if (
|
|
2917
|
+
if (kind === "object") {
|
|
2750
2918
|
if (hasDefault) {
|
|
2751
2919
|
return;
|
|
2752
2920
|
}
|
|
2753
|
-
const shape =
|
|
2921
|
+
const shape = getShape(current);
|
|
2754
2922
|
if (shape) {
|
|
2755
2923
|
for (const [k, v] of Object.entries(shape)) {
|
|
2756
2924
|
const nextPath = currentPath ? `${currentPath}.${k}` : k;
|
|
@@ -2759,7 +2927,7 @@ All flag fields must have known keys and defaults. Consider using z.object() ins
|
|
|
2759
2927
|
}
|
|
2760
2928
|
return;
|
|
2761
2929
|
}
|
|
2762
|
-
if (
|
|
2930
|
+
if (kind === "array") {
|
|
2763
2931
|
if (!hasDefault) {
|
|
2764
2932
|
missingDefaults.push(currentPath || "root");
|
|
2765
2933
|
}
|
|
@@ -2782,6 +2950,12 @@ Add .default(value) to these fields or to their parent objects.`
|
|
|
2782
2950
|
function createAppScope(config) {
|
|
2783
2951
|
const flagSchemaConfig = config?.flagSchema;
|
|
2784
2952
|
const factSchemaConfig = config?.factSchema;
|
|
2953
|
+
if (flagSchemaConfig) {
|
|
2954
|
+
assertZodV4(flagSchemaConfig, "flagSchema");
|
|
2955
|
+
}
|
|
2956
|
+
if (factSchemaConfig) {
|
|
2957
|
+
assertZodV4(factSchemaConfig, "factSchema");
|
|
2958
|
+
}
|
|
2785
2959
|
if (flagSchemaConfig) {
|
|
2786
2960
|
assertNoUnions(flagSchemaConfig, "flagSchema");
|
|
2787
2961
|
}
|
|
@@ -2791,51 +2965,24 @@ function createAppScope(config) {
|
|
|
2791
2965
|
if (flagSchemaConfig) {
|
|
2792
2966
|
validateCliFlags(flagSchemaConfig);
|
|
2793
2967
|
}
|
|
2794
|
-
function findSchemaAtPath2(segments) {
|
|
2795
|
-
if (!flagSchemaConfig || segments.length === 0) return void 0;
|
|
2796
|
-
let current = flagSchemaConfig;
|
|
2797
|
-
if (segments.length > 0) {
|
|
2798
|
-
if (!current.shape || !(segments[0] in current.shape)) {
|
|
2799
|
-
return void 0;
|
|
2800
|
-
}
|
|
2801
|
-
current = current.shape[segments[0]];
|
|
2802
|
-
for (let i = 1; i < segments.length; i++) {
|
|
2803
|
-
const segment = segments[i];
|
|
2804
|
-
if (!current || !current._def) {
|
|
2805
|
-
return void 0;
|
|
2806
|
-
}
|
|
2807
|
-
if (current._def.type === "object" && current.shape) {
|
|
2808
|
-
const nextSchema = current.shape[segment];
|
|
2809
|
-
if (!nextSchema) {
|
|
2810
|
-
return void 0;
|
|
2811
|
-
}
|
|
2812
|
-
current = nextSchema;
|
|
2813
|
-
} else {
|
|
2814
|
-
return void 0;
|
|
2815
|
-
}
|
|
2816
|
-
}
|
|
2817
|
-
return current;
|
|
2818
|
-
}
|
|
2819
|
-
return current;
|
|
2820
|
-
}
|
|
2821
2968
|
function isNamespaceAccess(segments) {
|
|
2822
2969
|
if (!flagSchemaConfig || segments.length === 0) return false;
|
|
2823
2970
|
if (segments.length === 1) {
|
|
2824
2971
|
return flagSchemaConfig.shape ? segments[0] in flagSchemaConfig.shape : false;
|
|
2825
2972
|
}
|
|
2826
|
-
const schema =
|
|
2827
|
-
return
|
|
2973
|
+
const schema = findSchemaAtPath(flagSchemaConfig, segments);
|
|
2974
|
+
return isObjectSchema(schema);
|
|
2828
2975
|
}
|
|
2829
2976
|
function buildObjectWithDefaults(schema) {
|
|
2830
2977
|
if (!schema) return void 0;
|
|
2831
|
-
const
|
|
2832
|
-
if (!
|
|
2978
|
+
const kind = getKind(schema);
|
|
2979
|
+
if (!kind) return void 0;
|
|
2833
2980
|
const directDefault = extractDefault(schema);
|
|
2834
2981
|
if (directDefault !== void 0) {
|
|
2835
2982
|
return directDefault;
|
|
2836
2983
|
}
|
|
2837
|
-
if (
|
|
2838
|
-
const shape =
|
|
2984
|
+
if (kind === "object") {
|
|
2985
|
+
const shape = getShape(schema);
|
|
2839
2986
|
if (shape) {
|
|
2840
2987
|
const result = {};
|
|
2841
2988
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
@@ -2848,18 +2995,17 @@ function createAppScope(config) {
|
|
|
2848
2995
|
return void 0;
|
|
2849
2996
|
}
|
|
2850
2997
|
function extractDefault(schema) {
|
|
2851
|
-
if (!schema
|
|
2998
|
+
if (!schema) return void 0;
|
|
2852
2999
|
let current = schema;
|
|
2853
|
-
|
|
2854
|
-
const def = current
|
|
3000
|
+
for (let i = 0; i < 10; i++) {
|
|
3001
|
+
const def = getDef(current);
|
|
2855
3002
|
if (!def) break;
|
|
2856
3003
|
if (def.defaultValue !== void 0) {
|
|
2857
3004
|
return typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
|
|
2858
3005
|
}
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
current = def.schema;
|
|
3006
|
+
const inner = getInnerType(current);
|
|
3007
|
+
if (inner) {
|
|
3008
|
+
current = inner;
|
|
2863
3009
|
} else {
|
|
2864
3010
|
break;
|
|
2865
3011
|
}
|
|
@@ -2869,7 +3015,7 @@ function createAppScope(config) {
|
|
|
2869
3015
|
function validateFinalFlagValue(dotPath, value) {
|
|
2870
3016
|
if (!flagSchemaConfig) return { ok: true, parsed: value };
|
|
2871
3017
|
const segments = parsePath(dotPath);
|
|
2872
|
-
const fieldSchema =
|
|
3018
|
+
const fieldSchema = findSchemaAtPath(flagSchemaConfig, segments);
|
|
2873
3019
|
if (fieldSchema) {
|
|
2874
3020
|
const direct = fieldSchema.safeParse(value);
|
|
2875
3021
|
if (direct.success) return { ok: true, parsed: direct.data };
|
|
@@ -2887,6 +3033,13 @@ function createAppScope(config) {
|
|
|
2887
3033
|
}
|
|
2888
3034
|
return { ok: true, parsed: value };
|
|
2889
3035
|
}
|
|
3036
|
+
function hasUndefinedLeaves(obj) {
|
|
3037
|
+
if (obj === void 0) return true;
|
|
3038
|
+
if (obj === null || typeof obj !== "object") return false;
|
|
3039
|
+
return Object.values(obj).some(
|
|
3040
|
+
(v) => typeof v === "object" && v !== null ? hasUndefinedLeaves(v) : v === void 0
|
|
3041
|
+
);
|
|
3042
|
+
}
|
|
2890
3043
|
function flag(path) {
|
|
2891
3044
|
const segments = parsePath(path);
|
|
2892
3045
|
const ctx = getEvalContext();
|
|
@@ -2912,9 +3065,9 @@ function createAppScope(config) {
|
|
|
2912
3065
|
console.error(`[AxiomAI] Invalid flag: "${path}"`);
|
|
2913
3066
|
return void 0;
|
|
2914
3067
|
}
|
|
2915
|
-
const schemaForPath =
|
|
3068
|
+
const schemaForPath = findSchemaAtPath(flagSchemaConfig, segments);
|
|
2916
3069
|
if (!schemaForPath) {
|
|
2917
|
-
const namespaceSchema =
|
|
3070
|
+
const namespaceSchema = findSchemaAtPath(flagSchemaConfig, [segments[0]]);
|
|
2918
3071
|
if (namespaceSchema) {
|
|
2919
3072
|
const namespaceObject = buildObjectWithDefaults(namespaceSchema);
|
|
2920
3073
|
if (namespaceObject && typeof namespaceObject === "object") {
|
|
@@ -2927,6 +3080,18 @@ function createAppScope(config) {
|
|
|
2927
3080
|
}
|
|
2928
3081
|
} else if (isNamespaceAccess(segments)) {
|
|
2929
3082
|
finalValue = buildObjectWithDefaults(schemaForPath);
|
|
3083
|
+
if (finalValue === void 0 || hasUndefinedLeaves(finalValue)) {
|
|
3084
|
+
const nsSchema = findSchemaAtPath(flagSchemaConfig, [segments[0]]);
|
|
3085
|
+
if (nsSchema) {
|
|
3086
|
+
const nsObj = buildObjectWithDefaults(nsSchema);
|
|
3087
|
+
if (nsObj && typeof nsObj === "object") {
|
|
3088
|
+
const extracted = getValueAtPath(nsObj, segments.slice(1));
|
|
3089
|
+
if (extracted !== void 0) {
|
|
3090
|
+
finalValue = extracted;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
2930
3095
|
if (finalValue === void 0) {
|
|
2931
3096
|
console.error(`[AxiomAI] Invalid flag: "${path}"`);
|
|
2932
3097
|
return void 0;
|
|
@@ -2934,7 +3099,7 @@ function createAppScope(config) {
|
|
|
2934
3099
|
} else {
|
|
2935
3100
|
finalValue = extractDefault(schemaForPath);
|
|
2936
3101
|
if (finalValue === void 0) {
|
|
2937
|
-
const nsSchema =
|
|
3102
|
+
const nsSchema = findSchemaAtPath(flagSchemaConfig, [segments[0]]);
|
|
2938
3103
|
if (nsSchema) {
|
|
2939
3104
|
const nsObj = buildObjectWithDefaults(nsSchema);
|
|
2940
3105
|
if (nsObj && typeof nsObj === "object") {
|
|
@@ -3054,10 +3219,12 @@ export {
|
|
|
3054
3219
|
getGlobalFlagOverrides,
|
|
3055
3220
|
formatZodErrors,
|
|
3056
3221
|
generateFlagExamples,
|
|
3222
|
+
assertZodV4,
|
|
3057
3223
|
parsePath,
|
|
3058
3224
|
dotNotationToNested,
|
|
3059
3225
|
flattenObject,
|
|
3060
3226
|
isValidPath,
|
|
3227
|
+
makeDeepPartial,
|
|
3061
3228
|
Attr,
|
|
3062
3229
|
createStartActiveSpan,
|
|
3063
3230
|
RedactionPolicy,
|
|
@@ -3084,4 +3251,4 @@ export {
|
|
|
3084
3251
|
withEvalContext,
|
|
3085
3252
|
getConfigScope
|
|
3086
3253
|
};
|
|
3087
|
-
//# sourceMappingURL=chunk-
|
|
3254
|
+
//# sourceMappingURL=chunk-AAEGYMAU.js.map
|