axiom 0.33.0 → 0.34.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.
@@ -1,5 +1,4 @@
1
1
  import { ZodObject, ZodDefault, z } from 'zod';
2
- import { $ZodObject } from 'zod/v4/core';
3
2
 
4
3
  type ValidChars =
5
4
  | 'a'
@@ -88,7 +87,7 @@ type HasDefaults<S> = S extends {
88
87
  defaultValue: unknown;
89
88
  };
90
89
  };
91
- } ? true : S extends $ZodObject<infer Shape> | ZodObject<infer Shape> ? {
90
+ } ? true : S extends ZodObject<infer Shape> ? {
92
91
  [K in keyof Shape]: HasDefaults<Shape[K]>;
93
92
  } extends Record<keyof Shape, true> ? true : false : false;
94
93
  type UnwrapSchema<T> = T extends ZodDefault<infer U> ? U : T;
@@ -1,5 +1,4 @@
1
1
  import { ZodObject, ZodDefault, z } from 'zod';
2
- import { $ZodObject } from 'zod/v4/core';
3
2
 
4
3
  type ValidChars =
5
4
  | 'a'
@@ -88,7 +87,7 @@ type HasDefaults<S> = S extends {
88
87
  defaultValue: unknown;
89
88
  };
90
89
  };
91
- } ? true : S extends $ZodObject<infer Shape> | ZodObject<infer Shape> ? {
90
+ } ? true : S extends ZodObject<infer Shape> ? {
92
91
  [K in keyof Shape]: HasDefaults<Shape[K]>;
93
92
  } extends Record<keyof Shape, true> ? true : false : false;
94
93
  type UnwrapSchema<T> = T extends ZodDefault<infer U> ? U : T;
package/dist/bin.cjs CHANGED
@@ -245,7 +245,7 @@ function setGlobalFlagOverrides(overrides2) {
245
245
 
246
246
  // src/validate-flags.ts
247
247
  init_cjs_shims();
248
- var import_zod3 = require("zod");
248
+ var import_zod4 = require("zod");
249
249
 
250
250
  // src/cli/utils/format-zod-errors.ts
251
251
  init_cjs_shims();
@@ -349,6 +349,113 @@ function generateExampleForIssue(issue, path3) {
349
349
  // src/util/dot-path.ts
350
350
  init_cjs_shims();
351
351
  var import_zod2 = require("zod");
352
+
353
+ // src/util/zod-internals.ts
354
+ init_cjs_shims();
355
+ function isZodV4Schema(schema) {
356
+ if (!schema || typeof schema !== "object") return false;
357
+ const s2 = schema;
358
+ return "_zod" in s2;
359
+ }
360
+ function assertZodV4(schema, context5) {
361
+ if (!isZodV4Schema(schema)) {
362
+ throw new Error(
363
+ `[AxiomAI] Zod v4 schemas are required (detected in ${context5}). Found unsupported Zod version.`
364
+ );
365
+ }
366
+ }
367
+ function getDef(schema) {
368
+ if (!schema || typeof schema !== "object") return void 0;
369
+ const s2 = schema;
370
+ if (s2._zod && typeof s2._zod === "object") {
371
+ const zod = s2._zod;
372
+ if (zod.def && typeof zod.def === "object") {
373
+ return zod.def;
374
+ }
375
+ }
376
+ return void 0;
377
+ }
378
+ function getDefRawType(def) {
379
+ if (!def) return void 0;
380
+ const raw = def.type;
381
+ if (raw == null) return void 0;
382
+ return typeof raw === "string" ? raw : String(raw);
383
+ }
384
+ var KNOWN_KINDS = /* @__PURE__ */ new Set([
385
+ "object",
386
+ "optional",
387
+ "default",
388
+ "nullable",
389
+ "readonly",
390
+ "prefault",
391
+ "nonoptional",
392
+ "catch",
393
+ "array",
394
+ "record",
395
+ "union",
396
+ "discriminatedunion"
397
+ ]);
398
+ function getKind(schemaOrDef) {
399
+ const def = schemaOrDef && typeof schemaOrDef === "object" && "type" in schemaOrDef ? schemaOrDef : getDef(schemaOrDef);
400
+ const raw = getDefRawType(def);
401
+ if (!raw) return void 0;
402
+ const normalized = raw.toLowerCase();
403
+ return KNOWN_KINDS.has(normalized) ? normalized : "other";
404
+ }
405
+ function isObjectSchema(schema) {
406
+ if (!schema || typeof schema !== "object") return false;
407
+ if ("shape" in schema && typeof schema.shape === "object") {
408
+ return true;
409
+ }
410
+ return getKind(schema) === "object";
411
+ }
412
+ function getInnerType(schema) {
413
+ const def = getDef(schema);
414
+ return def?.innerType;
415
+ }
416
+ function getArrayElement(schema) {
417
+ const def = getDef(schema);
418
+ return def?.element;
419
+ }
420
+ function getShape(schema) {
421
+ if (!schema || typeof schema !== "object") return void 0;
422
+ const s2 = schema;
423
+ if (s2.shape && typeof s2.shape === "object") {
424
+ return s2.shape;
425
+ }
426
+ return void 0;
427
+ }
428
+ function getDefaultValue(schema) {
429
+ const def = getDef(schema);
430
+ return def?.defaultValue;
431
+ }
432
+ var TRANSPARENT_WRAPPERS = [
433
+ "optional",
434
+ "nullable",
435
+ "default",
436
+ "readonly",
437
+ "prefault",
438
+ "nonoptional",
439
+ "catch"
440
+ // transparent for schema structure, but alters error behavior
441
+ ];
442
+ function unwrapTransparent(schema) {
443
+ let current = schema;
444
+ for (let i = 0; i < 10; i++) {
445
+ const kind = getKind(current);
446
+ if (!kind) break;
447
+ if (TRANSPARENT_WRAPPERS.includes(kind)) {
448
+ const inner = getInnerType(current);
449
+ if (!inner) break;
450
+ current = inner;
451
+ continue;
452
+ }
453
+ break;
454
+ }
455
+ return current;
456
+ }
457
+
458
+ // src/util/dot-path.ts
352
459
  function parsePath(path3) {
353
460
  return path3.split(".");
354
461
  }
@@ -387,16 +494,14 @@ function isValidPath(schema, segments) {
387
494
  let currentSchema = schema;
388
495
  for (let i = 0; i < segments.length; i++) {
389
496
  const segment = segments[i];
390
- if (!currentSchema.shape || !(segment in currentSchema.shape)) {
497
+ const shape = getShape(currentSchema);
498
+ if (!shape || !(segment in shape)) {
391
499
  return false;
392
500
  }
393
501
  if (i < segments.length - 1) {
394
- const nextSchema = currentSchema.shape[segment];
395
- let unwrappedSchema = nextSchema;
396
- while (unwrappedSchema?._def?.innerType || unwrappedSchema?._def?.schema) {
397
- unwrappedSchema = unwrappedSchema._def.innerType || unwrappedSchema._def.schema;
398
- }
399
- if (!unwrappedSchema || unwrappedSchema._def?.type !== "object") {
502
+ const nextSchema = shape[segment];
503
+ const unwrappedSchema = unwrapTransparent(nextSchema);
504
+ if (!isObjectSchema(unwrappedSchema)) {
400
505
  return false;
401
506
  }
402
507
  currentSchema = unwrappedSchema;
@@ -405,9 +510,62 @@ function isValidPath(schema, segments) {
405
510
  return true;
406
511
  }
407
512
 
513
+ // src/util/deep-partial-schema.ts
514
+ init_cjs_shims();
515
+ var import_zod3 = require("zod");
516
+ function makeDeepPartial(schema) {
517
+ const shape = schema.shape;
518
+ const newShape = {};
519
+ for (const [key, value] of Object.entries(shape)) {
520
+ newShape[key] = makeDeepPartialField(value);
521
+ }
522
+ return import_zod3.z.object(newShape);
523
+ }
524
+ function makeDeepPartialField(fieldSchema) {
525
+ const kind = getKind(fieldSchema);
526
+ if (isObjectSchema(fieldSchema)) {
527
+ const partialObject = makeDeepPartial(fieldSchema);
528
+ return partialObject.optional();
529
+ }
530
+ if (kind === "optional") {
531
+ const inner = getInnerType(fieldSchema);
532
+ if (inner && isObjectSchema(inner)) {
533
+ const partialInner = makeDeepPartial(inner);
534
+ return partialInner.optional();
535
+ }
536
+ return fieldSchema;
537
+ }
538
+ if (kind === "nullable") {
539
+ const inner = getInnerType(fieldSchema);
540
+ if (inner && isObjectSchema(inner)) {
541
+ const partialInner = makeDeepPartial(inner);
542
+ return partialInner.nullable().optional();
543
+ }
544
+ return fieldSchema.optional();
545
+ }
546
+ if (kind === "default") {
547
+ const inner = getInnerType(fieldSchema);
548
+ const defaultValue = getDefaultValue(fieldSchema);
549
+ if (inner && isObjectSchema(inner)) {
550
+ const partialInner = makeDeepPartial(inner);
551
+ return partialInner.default(defaultValue);
552
+ }
553
+ return fieldSchema.optional();
554
+ }
555
+ if (kind === "array") {
556
+ const element = getArrayElement(fieldSchema);
557
+ if (element && isObjectSchema(element)) {
558
+ const partialElement = makeDeepPartial(element);
559
+ return import_zod3.z.array(partialElement).optional();
560
+ }
561
+ return fieldSchema.optional();
562
+ }
563
+ return fieldSchema.optional();
564
+ }
565
+
408
566
  // src/app-scope.ts
409
567
  var import_api8 = require("@opentelemetry/api");
410
- var import_zod4 = require("zod");
568
+ var import_zod5 = require("zod");
411
569
 
412
570
  // src/otel/utils/to-otel-attribute.ts
413
571
  init_cjs_shims();
@@ -448,7 +606,7 @@ var import_api4 = require("@opentelemetry/api");
448
606
  // package.json
449
607
  var package_default = {
450
608
  name: "axiom",
451
- version: "0.33.0",
609
+ version: "0.34.0",
452
610
  type: "module",
453
611
  author: "Axiom, Inc.",
454
612
  contributors: [
@@ -1433,7 +1591,7 @@ var import_defu = require("defu");
1433
1591
 
1434
1592
  // src/config/index.ts
1435
1593
  init_cjs_shims();
1436
- var import_zod5 = require("zod");
1594
+ var import_zod6 = require("zod");
1437
1595
 
1438
1596
  // src/cli/auth/index.ts
1439
1597
  init_cjs_shims();
@@ -1911,11 +2069,11 @@ function setupEvalProvider(connection) {
1911
2069
  axiomProvider = new import_sdk_trace_node.NodeTracerProvider({
1912
2070
  resource: (0, import_resources.resourceFromAttributes)({
1913
2071
  ["service.name"]: "axiom",
1914
- ["service.version"]: "0.33.0"
2072
+ ["service.version"]: "0.34.0"
1915
2073
  }),
1916
2074
  spanProcessors: [processor]
1917
2075
  });
1918
- axiomTracer = axiomProvider.getTracer("axiom", "0.33.0");
2076
+ axiomTracer = axiomProvider.getTracer("axiom", "0.34.0");
1919
2077
  }
1920
2078
  async function initInstrumentation(config) {
1921
2079
  if (initialized) {
@@ -1927,7 +2085,7 @@ async function initInstrumentation(config) {
1927
2085
  }
1928
2086
  initializationPromise = (async () => {
1929
2087
  if (!config.enabled) {
1930
- axiomTracer = import_api10.trace.getTracer("axiom", "0.33.0");
2088
+ axiomTracer = import_api10.trace.getTracer("axiom", "0.34.0");
1931
2089
  initialized = true;
1932
2090
  return;
1933
2091
  }
@@ -2147,7 +2305,7 @@ async function runEvalWithContext(overrides2, runFn) {
2147
2305
 
2148
2306
  // src/cli/utils/parse-flag-overrides.ts
2149
2307
  init_cjs_shims();
2150
- var import_zod6 = require("zod");
2308
+ var import_zod7 = require("zod");
2151
2309
  var import_node_fs2 = require("fs");
2152
2310
  var import_node_path3 = require("path");
2153
2311
  var FLAG_RE = /^--flag\.([^=]+)(?:=(.*))?$/;
@@ -2169,6 +2327,7 @@ function collectFlagValidationErrors(overrides2, flagSchema) {
2169
2327
  if (!flagSchema || Object.keys(overrides2).length === 0) {
2170
2328
  return { success: true, errors: [] };
2171
2329
  }
2330
+ assertZodV4(flagSchema, "flagSchema");
2172
2331
  const schema = flagSchema;
2173
2332
  const errors = [];
2174
2333
  for (const dotPath of Object.keys(overrides2)) {
@@ -2181,7 +2340,8 @@ function collectFlagValidationErrors(overrides2, flagSchema) {
2181
2340
  return { success: false, errors };
2182
2341
  }
2183
2342
  const nestedObject = dotNotationToNested(overrides2);
2184
- const result = schema.strict().partial().safeParse(nestedObject);
2343
+ const deepPartialSchema = makeDeepPartial(schema);
2344
+ const result = deepPartialSchema.safeParse(nestedObject);
2185
2345
  if (!result.success) {
2186
2346
  errors.push({ type: "invalid_value", zodError: result.error });
2187
2347
  }
@@ -2775,7 +2935,7 @@ var import_commander2 = require("commander");
2775
2935
  var loadVersionCommand = (program2) => {
2776
2936
  return program2.addCommand(
2777
2937
  new import_commander2.Command("version").description("cli version").action(() => {
2778
- console.log("0.33.0");
2938
+ console.log("0.34.0");
2779
2939
  })
2780
2940
  );
2781
2941
  };
@@ -2785,7 +2945,7 @@ var { loadEnvConfig } = import_env.default;
2785
2945
  loadEnvConfig(process.cwd());
2786
2946
  var { cleanedArgv, overrides } = extractOverrides(process.argv.slice(2));
2787
2947
  var program = new import_commander3.Command();
2788
- program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.33.0");
2948
+ program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.34.0");
2789
2949
  program.hook("preAction", async (_, actionCommand) => {
2790
2950
  const commandName = actionCommand.name();
2791
2951
  const parentCommand = actionCommand.parent;