@glasstrace/sdk 0.9.1 → 0.10.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.
@@ -2,10 +2,6 @@ import {
2
2
  __export
3
3
  } from "./chunk-PZ5AY32C.js";
4
4
 
5
- // src/anon-key.ts
6
- import { readFile, writeFile, mkdir, chmod } from "fs/promises";
7
- import { join } from "path";
8
-
9
5
  // ../../node_modules/zod/v4/classic/external.js
10
6
  var external_exports = {};
11
7
  __export(external_exports, {
@@ -509,7 +505,7 @@ __export(core_exports2, {
509
505
  parse: () => parse,
510
506
  parseAsync: () => parseAsync,
511
507
  prettifyError: () => prettifyError,
512
- process: () => process2,
508
+ process: () => process,
513
509
  regexes: () => regexes_exports,
514
510
  registry: () => registry,
515
511
  safeDecode: () => safeDecode,
@@ -10910,7 +10906,7 @@ function initializeContext(params) {
10910
10906
  external: params?.external ?? void 0
10911
10907
  };
10912
10908
  }
10913
- function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10909
+ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
10914
10910
  var _a2;
10915
10911
  const def = schema._zod.def;
10916
10912
  const seen = ctx.seen.get(schema);
@@ -10947,7 +10943,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10947
10943
  if (parent) {
10948
10944
  if (!result.ref)
10949
10945
  result.ref = parent;
10950
- process2(parent, ctx, params);
10946
+ process(parent, ctx, params);
10951
10947
  ctx.seen.get(parent).isParent = true;
10952
10948
  }
10953
10949
  }
@@ -11228,14 +11224,14 @@ function isTransforming(_schema, _ctx) {
11228
11224
  }
11229
11225
  var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
11230
11226
  const ctx = initializeContext({ ...params, processors });
11231
- process2(schema, ctx);
11227
+ process(schema, ctx);
11232
11228
  extractDefs(ctx, schema);
11233
11229
  return finalize(ctx, schema);
11234
11230
  };
11235
11231
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
11236
11232
  const { libraryOptions, target } = params ?? {};
11237
11233
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
11238
- process2(schema, ctx);
11234
+ process(schema, ctx);
11239
11235
  extractDefs(ctx, schema);
11240
11236
  return finalize(ctx, schema);
11241
11237
  };
@@ -11492,7 +11488,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
11492
11488
  if (typeof maximum === "number")
11493
11489
  json2.maxItems = maximum;
11494
11490
  json2.type = "array";
11495
- json2.items = process2(def.element, ctx, { ...params, path: [...params.path, "items"] });
11491
+ json2.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
11496
11492
  };
11497
11493
  var objectProcessor = (schema, ctx, _json, params) => {
11498
11494
  const json2 = _json;
@@ -11501,7 +11497,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11501
11497
  json2.properties = {};
11502
11498
  const shape = def.shape;
11503
11499
  for (const key in shape) {
11504
- json2.properties[key] = process2(shape[key], ctx, {
11500
+ json2.properties[key] = process(shape[key], ctx, {
11505
11501
  ...params,
11506
11502
  path: [...params.path, "properties", key]
11507
11503
  });
@@ -11524,7 +11520,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11524
11520
  if (ctx.io === "output")
11525
11521
  json2.additionalProperties = false;
11526
11522
  } else if (def.catchall) {
11527
- json2.additionalProperties = process2(def.catchall, ctx, {
11523
+ json2.additionalProperties = process(def.catchall, ctx, {
11528
11524
  ...params,
11529
11525
  path: [...params.path, "additionalProperties"]
11530
11526
  });
@@ -11533,7 +11529,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11533
11529
  var unionProcessor = (schema, ctx, json2, params) => {
11534
11530
  const def = schema._zod.def;
11535
11531
  const isExclusive = def.inclusive === false;
11536
- const options = def.options.map((x, i) => process2(x, ctx, {
11532
+ const options = def.options.map((x, i) => process(x, ctx, {
11537
11533
  ...params,
11538
11534
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
11539
11535
  }));
@@ -11545,11 +11541,11 @@ var unionProcessor = (schema, ctx, json2, params) => {
11545
11541
  };
11546
11542
  var intersectionProcessor = (schema, ctx, json2, params) => {
11547
11543
  const def = schema._zod.def;
11548
- const a = process2(def.left, ctx, {
11544
+ const a = process(def.left, ctx, {
11549
11545
  ...params,
11550
11546
  path: [...params.path, "allOf", 0]
11551
11547
  });
11552
- const b = process2(def.right, ctx, {
11548
+ const b = process(def.right, ctx, {
11553
11549
  ...params,
11554
11550
  path: [...params.path, "allOf", 1]
11555
11551
  });
@@ -11566,11 +11562,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
11566
11562
  json2.type = "array";
11567
11563
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
11568
11564
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
11569
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
11565
+ const prefixItems = def.items.map((x, i) => process(x, ctx, {
11570
11566
  ...params,
11571
11567
  path: [...params.path, prefixPath, i]
11572
11568
  }));
11573
- const rest = def.rest ? process2(def.rest, ctx, {
11569
+ const rest = def.rest ? process(def.rest, ctx, {
11574
11570
  ...params,
11575
11571
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
11576
11572
  }) : null;
@@ -11610,7 +11606,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11610
11606
  const keyBag = keyType._zod.bag;
11611
11607
  const patterns = keyBag?.patterns;
11612
11608
  if (def.mode === "loose" && patterns && patterns.size > 0) {
11613
- const valueSchema = process2(def.valueType, ctx, {
11609
+ const valueSchema = process(def.valueType, ctx, {
11614
11610
  ...params,
11615
11611
  path: [...params.path, "patternProperties", "*"]
11616
11612
  });
@@ -11620,12 +11616,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
11620
11616
  }
11621
11617
  } else {
11622
11618
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
11623
- json2.propertyNames = process2(def.keyType, ctx, {
11619
+ json2.propertyNames = process(def.keyType, ctx, {
11624
11620
  ...params,
11625
11621
  path: [...params.path, "propertyNames"]
11626
11622
  });
11627
11623
  }
11628
- json2.additionalProperties = process2(def.valueType, ctx, {
11624
+ json2.additionalProperties = process(def.valueType, ctx, {
11629
11625
  ...params,
11630
11626
  path: [...params.path, "additionalProperties"]
11631
11627
  });
@@ -11640,7 +11636,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11640
11636
  };
11641
11637
  var nullableProcessor = (schema, ctx, json2, params) => {
11642
11638
  const def = schema._zod.def;
11643
- const inner = process2(def.innerType, ctx, params);
11639
+ const inner = process(def.innerType, ctx, params);
11644
11640
  const seen = ctx.seen.get(schema);
11645
11641
  if (ctx.target === "openapi-3.0") {
11646
11642
  seen.ref = def.innerType;
@@ -11651,20 +11647,20 @@ var nullableProcessor = (schema, ctx, json2, params) => {
11651
11647
  };
11652
11648
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
11653
11649
  const def = schema._zod.def;
11654
- process2(def.innerType, ctx, params);
11650
+ process(def.innerType, ctx, params);
11655
11651
  const seen = ctx.seen.get(schema);
11656
11652
  seen.ref = def.innerType;
11657
11653
  };
11658
11654
  var defaultProcessor = (schema, ctx, json2, params) => {
11659
11655
  const def = schema._zod.def;
11660
- process2(def.innerType, ctx, params);
11656
+ process(def.innerType, ctx, params);
11661
11657
  const seen = ctx.seen.get(schema);
11662
11658
  seen.ref = def.innerType;
11663
11659
  json2.default = JSON.parse(JSON.stringify(def.defaultValue));
11664
11660
  };
11665
11661
  var prefaultProcessor = (schema, ctx, json2, params) => {
11666
11662
  const def = schema._zod.def;
11667
- process2(def.innerType, ctx, params);
11663
+ process(def.innerType, ctx, params);
11668
11664
  const seen = ctx.seen.get(schema);
11669
11665
  seen.ref = def.innerType;
11670
11666
  if (ctx.io === "input")
@@ -11672,7 +11668,7 @@ var prefaultProcessor = (schema, ctx, json2, params) => {
11672
11668
  };
11673
11669
  var catchProcessor = (schema, ctx, json2, params) => {
11674
11670
  const def = schema._zod.def;
11675
- process2(def.innerType, ctx, params);
11671
+ process(def.innerType, ctx, params);
11676
11672
  const seen = ctx.seen.get(schema);
11677
11673
  seen.ref = def.innerType;
11678
11674
  let catchValue;
@@ -11686,32 +11682,32 @@ var catchProcessor = (schema, ctx, json2, params) => {
11686
11682
  var pipeProcessor = (schema, ctx, _json, params) => {
11687
11683
  const def = schema._zod.def;
11688
11684
  const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
11689
- process2(innerType, ctx, params);
11685
+ process(innerType, ctx, params);
11690
11686
  const seen = ctx.seen.get(schema);
11691
11687
  seen.ref = innerType;
11692
11688
  };
11693
11689
  var readonlyProcessor = (schema, ctx, json2, params) => {
11694
11690
  const def = schema._zod.def;
11695
- process2(def.innerType, ctx, params);
11691
+ process(def.innerType, ctx, params);
11696
11692
  const seen = ctx.seen.get(schema);
11697
11693
  seen.ref = def.innerType;
11698
11694
  json2.readOnly = true;
11699
11695
  };
11700
11696
  var promiseProcessor = (schema, ctx, _json, params) => {
11701
11697
  const def = schema._zod.def;
11702
- process2(def.innerType, ctx, params);
11698
+ process(def.innerType, ctx, params);
11703
11699
  const seen = ctx.seen.get(schema);
11704
11700
  seen.ref = def.innerType;
11705
11701
  };
11706
11702
  var optionalProcessor = (schema, ctx, _json, params) => {
11707
11703
  const def = schema._zod.def;
11708
- process2(def.innerType, ctx, params);
11704
+ process(def.innerType, ctx, params);
11709
11705
  const seen = ctx.seen.get(schema);
11710
11706
  seen.ref = def.innerType;
11711
11707
  };
11712
11708
  var lazyProcessor = (schema, ctx, _json, params) => {
11713
11709
  const innerType = schema._zod.innerType;
11714
- process2(innerType, ctx, params);
11710
+ process(innerType, ctx, params);
11715
11711
  const seen = ctx.seen.get(schema);
11716
11712
  seen.ref = innerType;
11717
11713
  };
@@ -11763,7 +11759,7 @@ function toJSONSchema(input, params) {
11763
11759
  const defs = {};
11764
11760
  for (const entry of registry2._idmap.entries()) {
11765
11761
  const [_, schema] = entry;
11766
- process2(schema, ctx2);
11762
+ process(schema, ctx2);
11767
11763
  }
11768
11764
  const schemas = {};
11769
11765
  const external = {
@@ -11786,7 +11782,7 @@ function toJSONSchema(input, params) {
11786
11782
  return { schemas };
11787
11783
  }
11788
11784
  const ctx = initializeContext({ ...params, processors: allProcessors });
11789
- process2(input, ctx);
11785
+ process(input, ctx);
11790
11786
  extractDefs(ctx, input);
11791
11787
  return finalize(ctx, input);
11792
11788
  }
@@ -11844,7 +11840,7 @@ var JSONSchemaGenerator = class {
11844
11840
  * This must be called before emit().
11845
11841
  */
11846
11842
  process(schema, _params = { path: [], schemaPath: [] }) {
11847
- return process2(schema, this.ctx, _params);
11843
+ return process(schema, this.ctx, _params);
11848
11844
  }
11849
11845
  /**
11850
11846
  * Emit the final JSON Schema after processing.
@@ -13951,73 +13947,10 @@ var DEFAULT_CAPTURE_CONFIG = {
13951
13947
  consoleErrors: false
13952
13948
  };
13953
13949
 
13954
- // src/anon-key.ts
13955
- var GLASSTRACE_DIR = ".glasstrace";
13956
- var ANON_KEY_FILE = "anon_key";
13957
- var ephemeralKeyCache = /* @__PURE__ */ new Map();
13958
- async function readAnonKey(projectRoot) {
13959
- const root = projectRoot ?? process.cwd();
13960
- const keyPath = join(root, GLASSTRACE_DIR, ANON_KEY_FILE);
13961
- try {
13962
- const content = await readFile(keyPath, "utf-8");
13963
- const result = AnonApiKeySchema.safeParse(content);
13964
- if (result.success) {
13965
- return result.data;
13966
- }
13967
- } catch {
13968
- }
13969
- const cached2 = ephemeralKeyCache.get(root);
13970
- if (cached2 !== void 0) {
13971
- return cached2;
13972
- }
13973
- return null;
13974
- }
13975
- async function getOrCreateAnonKey(projectRoot) {
13976
- const root = projectRoot ?? process.cwd();
13977
- const dirPath = join(root, GLASSTRACE_DIR);
13978
- const keyPath = join(dirPath, ANON_KEY_FILE);
13979
- const existingKey = await readAnonKey(root);
13980
- if (existingKey !== null) {
13981
- return existingKey;
13982
- }
13983
- const cached2 = ephemeralKeyCache.get(root);
13984
- if (cached2 !== void 0) {
13985
- return cached2;
13986
- }
13987
- const newKey = createAnonApiKey();
13988
- try {
13989
- await mkdir(dirPath, { recursive: true, mode: 448 });
13990
- await writeFile(keyPath, newKey, { flag: "wx", mode: 384 });
13991
- return newKey;
13992
- } catch (err) {
13993
- const code = err.code;
13994
- if (code === "EEXIST") {
13995
- for (let attempt = 0; attempt < 3; attempt++) {
13996
- const winnerKey = await readAnonKey(root);
13997
- if (winnerKey !== null) {
13998
- return winnerKey;
13999
- }
14000
- if (attempt < 2) {
14001
- await new Promise((resolve) => setTimeout(resolve, 50));
14002
- }
14003
- }
14004
- try {
14005
- await writeFile(keyPath, newKey, { mode: 384 });
14006
- await chmod(keyPath, 384);
14007
- return newKey;
14008
- } catch {
14009
- }
14010
- }
14011
- ephemeralKeyCache.set(root, newKey);
14012
- console.warn(
14013
- `[glasstrace] Failed to persist anonymous key to ${keyPath}: ${err instanceof Error ? err.message : String(err)}. Using ephemeral key.`
14014
- );
14015
- return newKey;
14016
- }
14017
- }
14018
-
14019
13950
  export {
13951
+ AnonApiKeySchema,
14020
13952
  SessionIdSchema,
13953
+ createAnonApiKey,
14021
13954
  createBuildHash,
14022
13955
  SdkCachedConfigSchema,
14023
13956
  SdkInitResponseSchema,
@@ -14025,8 +13958,6 @@ export {
14025
13958
  PresignedUploadResponseSchema,
14026
13959
  SourceMapManifestResponseSchema,
14027
13960
  GLASSTRACE_ATTRIBUTE_NAMES,
14028
- DEFAULT_CAPTURE_CONFIG,
14029
- readAnonKey,
14030
- getOrCreateAnonKey
13961
+ DEFAULT_CAPTURE_CONFIG
14031
13962
  };
14032
- //# sourceMappingURL=chunk-PQWAKVQ5.js.map
13963
+ //# sourceMappingURL=chunk-O3Y45VGV.js.map