@glasstrace/sdk 0.2.3 → 0.4.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/{chunk-CUFIV225.js → chunk-EC5IINUT.js} +86 -201
- package/dist/chunk-EC5IINUT.js.map +1 -0
- package/dist/chunk-LAMTBURS.js +178 -0
- package/dist/chunk-LAMTBURS.js.map +1 -0
- package/dist/chunk-STECO33B.js +675 -0
- package/dist/chunk-STECO33B.js.map +1 -0
- package/dist/cli/init.cjs +12476 -10881
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +193 -184
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +14651 -0
- package/dist/cli/mcp-add.cjs.map +1 -0
- package/dist/cli/mcp-add.d.cts +46 -0
- package/dist/cli/mcp-add.d.ts +46 -0
- package/dist/cli/mcp-add.js +243 -0
- package/dist/cli/mcp-add.js.map +1 -0
- package/dist/index.cjs +54 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +59 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-CUFIV225.js.map +0 -1
|
@@ -2,11 +2,9 @@ import {
|
|
|
2
2
|
__export
|
|
3
3
|
} from "./chunk-PZ5AY32C.js";
|
|
4
4
|
|
|
5
|
-
// src/
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import * as path from "path";
|
|
9
|
-
import * as crypto2 from "crypto";
|
|
5
|
+
// src/anon-key.ts
|
|
6
|
+
import { readFile, writeFile, mkdir, chmod } from "fs/promises";
|
|
7
|
+
import { join } from "path";
|
|
10
8
|
|
|
11
9
|
// ../../node_modules/zod/v4/classic/external.js
|
|
12
10
|
var external_exports = {};
|
|
@@ -511,7 +509,7 @@ __export(core_exports2, {
|
|
|
511
509
|
parse: () => parse,
|
|
512
510
|
parseAsync: () => parseAsync,
|
|
513
511
|
prettifyError: () => prettifyError,
|
|
514
|
-
process: () =>
|
|
512
|
+
process: () => process2,
|
|
515
513
|
regexes: () => regexes_exports,
|
|
516
514
|
registry: () => registry,
|
|
517
515
|
safeDecode: () => safeDecode,
|
|
@@ -775,10 +773,10 @@ function mergeDefs(...defs) {
|
|
|
775
773
|
function cloneDef(schema) {
|
|
776
774
|
return mergeDefs(schema._zod.def);
|
|
777
775
|
}
|
|
778
|
-
function getElementAtPath(obj,
|
|
779
|
-
if (!
|
|
776
|
+
function getElementAtPath(obj, path) {
|
|
777
|
+
if (!path)
|
|
780
778
|
return obj;
|
|
781
|
-
return
|
|
779
|
+
return path.reduce((acc, key) => acc?.[key], obj);
|
|
782
780
|
}
|
|
783
781
|
function promiseAllObject(promisesObj) {
|
|
784
782
|
const keys = Object.keys(promisesObj);
|
|
@@ -1161,11 +1159,11 @@ function aborted(x, startIndex = 0) {
|
|
|
1161
1159
|
}
|
|
1162
1160
|
return false;
|
|
1163
1161
|
}
|
|
1164
|
-
function prefixIssues(
|
|
1162
|
+
function prefixIssues(path, issues) {
|
|
1165
1163
|
return issues.map((iss) => {
|
|
1166
1164
|
var _a2;
|
|
1167
1165
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
1168
|
-
iss.path.unshift(
|
|
1166
|
+
iss.path.unshift(path);
|
|
1169
1167
|
return iss;
|
|
1170
1168
|
});
|
|
1171
1169
|
}
|
|
@@ -1348,7 +1346,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
1348
1346
|
}
|
|
1349
1347
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
1350
1348
|
const result = { errors: [] };
|
|
1351
|
-
const processError = (error49,
|
|
1349
|
+
const processError = (error49, path = []) => {
|
|
1352
1350
|
var _a2, _b;
|
|
1353
1351
|
for (const issue2 of error49.issues) {
|
|
1354
1352
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -1358,7 +1356,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
1358
1356
|
} else if (issue2.code === "invalid_element") {
|
|
1359
1357
|
processError({ issues: issue2.issues }, issue2.path);
|
|
1360
1358
|
} else {
|
|
1361
|
-
const fullpath = [...
|
|
1359
|
+
const fullpath = [...path, ...issue2.path];
|
|
1362
1360
|
if (fullpath.length === 0) {
|
|
1363
1361
|
result.errors.push(mapper(issue2));
|
|
1364
1362
|
continue;
|
|
@@ -1390,8 +1388,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
1390
1388
|
}
|
|
1391
1389
|
function toDotPath(_path) {
|
|
1392
1390
|
const segs = [];
|
|
1393
|
-
const
|
|
1394
|
-
for (const seg of
|
|
1391
|
+
const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1392
|
+
for (const seg of path) {
|
|
1395
1393
|
if (typeof seg === "number")
|
|
1396
1394
|
segs.push(`[${seg}]`);
|
|
1397
1395
|
else if (typeof seg === "symbol")
|
|
@@ -10912,7 +10910,7 @@ function initializeContext(params) {
|
|
|
10912
10910
|
external: params?.external ?? void 0
|
|
10913
10911
|
};
|
|
10914
10912
|
}
|
|
10915
|
-
function
|
|
10913
|
+
function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
10916
10914
|
var _a2;
|
|
10917
10915
|
const def = schema._zod.def;
|
|
10918
10916
|
const seen = ctx.seen.get(schema);
|
|
@@ -10949,7 +10947,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
10949
10947
|
if (parent) {
|
|
10950
10948
|
if (!result.ref)
|
|
10951
10949
|
result.ref = parent;
|
|
10952
|
-
|
|
10950
|
+
process2(parent, ctx, params);
|
|
10953
10951
|
ctx.seen.get(parent).isParent = true;
|
|
10954
10952
|
}
|
|
10955
10953
|
}
|
|
@@ -11230,14 +11228,14 @@ function isTransforming(_schema, _ctx) {
|
|
|
11230
11228
|
}
|
|
11231
11229
|
var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
11232
11230
|
const ctx = initializeContext({ ...params, processors });
|
|
11233
|
-
|
|
11231
|
+
process2(schema, ctx);
|
|
11234
11232
|
extractDefs(ctx, schema);
|
|
11235
11233
|
return finalize(ctx, schema);
|
|
11236
11234
|
};
|
|
11237
11235
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
11238
11236
|
const { libraryOptions, target } = params ?? {};
|
|
11239
11237
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
11240
|
-
|
|
11238
|
+
process2(schema, ctx);
|
|
11241
11239
|
extractDefs(ctx, schema);
|
|
11242
11240
|
return finalize(ctx, schema);
|
|
11243
11241
|
};
|
|
@@ -11494,7 +11492,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
11494
11492
|
if (typeof maximum === "number")
|
|
11495
11493
|
json2.maxItems = maximum;
|
|
11496
11494
|
json2.type = "array";
|
|
11497
|
-
json2.items =
|
|
11495
|
+
json2.items = process2(def.element, ctx, { ...params, path: [...params.path, "items"] });
|
|
11498
11496
|
};
|
|
11499
11497
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
11500
11498
|
const json2 = _json;
|
|
@@ -11503,7 +11501,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11503
11501
|
json2.properties = {};
|
|
11504
11502
|
const shape = def.shape;
|
|
11505
11503
|
for (const key in shape) {
|
|
11506
|
-
json2.properties[key] =
|
|
11504
|
+
json2.properties[key] = process2(shape[key], ctx, {
|
|
11507
11505
|
...params,
|
|
11508
11506
|
path: [...params.path, "properties", key]
|
|
11509
11507
|
});
|
|
@@ -11526,7 +11524,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11526
11524
|
if (ctx.io === "output")
|
|
11527
11525
|
json2.additionalProperties = false;
|
|
11528
11526
|
} else if (def.catchall) {
|
|
11529
|
-
json2.additionalProperties =
|
|
11527
|
+
json2.additionalProperties = process2(def.catchall, ctx, {
|
|
11530
11528
|
...params,
|
|
11531
11529
|
path: [...params.path, "additionalProperties"]
|
|
11532
11530
|
});
|
|
@@ -11535,7 +11533,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11535
11533
|
var unionProcessor = (schema, ctx, json2, params) => {
|
|
11536
11534
|
const def = schema._zod.def;
|
|
11537
11535
|
const isExclusive = def.inclusive === false;
|
|
11538
|
-
const options = def.options.map((x, i) =>
|
|
11536
|
+
const options = def.options.map((x, i) => process2(x, ctx, {
|
|
11539
11537
|
...params,
|
|
11540
11538
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
11541
11539
|
}));
|
|
@@ -11547,11 +11545,11 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
11547
11545
|
};
|
|
11548
11546
|
var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
11549
11547
|
const def = schema._zod.def;
|
|
11550
|
-
const a =
|
|
11548
|
+
const a = process2(def.left, ctx, {
|
|
11551
11549
|
...params,
|
|
11552
11550
|
path: [...params.path, "allOf", 0]
|
|
11553
11551
|
});
|
|
11554
|
-
const b =
|
|
11552
|
+
const b = process2(def.right, ctx, {
|
|
11555
11553
|
...params,
|
|
11556
11554
|
path: [...params.path, "allOf", 1]
|
|
11557
11555
|
});
|
|
@@ -11568,11 +11566,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
11568
11566
|
json2.type = "array";
|
|
11569
11567
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
11570
11568
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
11571
|
-
const prefixItems = def.items.map((x, i) =>
|
|
11569
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
11572
11570
|
...params,
|
|
11573
11571
|
path: [...params.path, prefixPath, i]
|
|
11574
11572
|
}));
|
|
11575
|
-
const rest = def.rest ?
|
|
11573
|
+
const rest = def.rest ? process2(def.rest, ctx, {
|
|
11576
11574
|
...params,
|
|
11577
11575
|
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
11578
11576
|
}) : null;
|
|
@@ -11612,7 +11610,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
11612
11610
|
const keyBag = keyType._zod.bag;
|
|
11613
11611
|
const patterns = keyBag?.patterns;
|
|
11614
11612
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
11615
|
-
const valueSchema =
|
|
11613
|
+
const valueSchema = process2(def.valueType, ctx, {
|
|
11616
11614
|
...params,
|
|
11617
11615
|
path: [...params.path, "patternProperties", "*"]
|
|
11618
11616
|
});
|
|
@@ -11622,12 +11620,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
11622
11620
|
}
|
|
11623
11621
|
} else {
|
|
11624
11622
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
11625
|
-
json2.propertyNames =
|
|
11623
|
+
json2.propertyNames = process2(def.keyType, ctx, {
|
|
11626
11624
|
...params,
|
|
11627
11625
|
path: [...params.path, "propertyNames"]
|
|
11628
11626
|
});
|
|
11629
11627
|
}
|
|
11630
|
-
json2.additionalProperties =
|
|
11628
|
+
json2.additionalProperties = process2(def.valueType, ctx, {
|
|
11631
11629
|
...params,
|
|
11632
11630
|
path: [...params.path, "additionalProperties"]
|
|
11633
11631
|
});
|
|
@@ -11642,7 +11640,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
11642
11640
|
};
|
|
11643
11641
|
var nullableProcessor = (schema, ctx, json2, params) => {
|
|
11644
11642
|
const def = schema._zod.def;
|
|
11645
|
-
const inner =
|
|
11643
|
+
const inner = process2(def.innerType, ctx, params);
|
|
11646
11644
|
const seen = ctx.seen.get(schema);
|
|
11647
11645
|
if (ctx.target === "openapi-3.0") {
|
|
11648
11646
|
seen.ref = def.innerType;
|
|
@@ -11653,20 +11651,20 @@ var nullableProcessor = (schema, ctx, json2, params) => {
|
|
|
11653
11651
|
};
|
|
11654
11652
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
11655
11653
|
const def = schema._zod.def;
|
|
11656
|
-
|
|
11654
|
+
process2(def.innerType, ctx, params);
|
|
11657
11655
|
const seen = ctx.seen.get(schema);
|
|
11658
11656
|
seen.ref = def.innerType;
|
|
11659
11657
|
};
|
|
11660
11658
|
var defaultProcessor = (schema, ctx, json2, params) => {
|
|
11661
11659
|
const def = schema._zod.def;
|
|
11662
|
-
|
|
11660
|
+
process2(def.innerType, ctx, params);
|
|
11663
11661
|
const seen = ctx.seen.get(schema);
|
|
11664
11662
|
seen.ref = def.innerType;
|
|
11665
11663
|
json2.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
11666
11664
|
};
|
|
11667
11665
|
var prefaultProcessor = (schema, ctx, json2, params) => {
|
|
11668
11666
|
const def = schema._zod.def;
|
|
11669
|
-
|
|
11667
|
+
process2(def.innerType, ctx, params);
|
|
11670
11668
|
const seen = ctx.seen.get(schema);
|
|
11671
11669
|
seen.ref = def.innerType;
|
|
11672
11670
|
if (ctx.io === "input")
|
|
@@ -11674,7 +11672,7 @@ var prefaultProcessor = (schema, ctx, json2, params) => {
|
|
|
11674
11672
|
};
|
|
11675
11673
|
var catchProcessor = (schema, ctx, json2, params) => {
|
|
11676
11674
|
const def = schema._zod.def;
|
|
11677
|
-
|
|
11675
|
+
process2(def.innerType, ctx, params);
|
|
11678
11676
|
const seen = ctx.seen.get(schema);
|
|
11679
11677
|
seen.ref = def.innerType;
|
|
11680
11678
|
let catchValue;
|
|
@@ -11688,32 +11686,32 @@ var catchProcessor = (schema, ctx, json2, params) => {
|
|
|
11688
11686
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
11689
11687
|
const def = schema._zod.def;
|
|
11690
11688
|
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
11691
|
-
|
|
11689
|
+
process2(innerType, ctx, params);
|
|
11692
11690
|
const seen = ctx.seen.get(schema);
|
|
11693
11691
|
seen.ref = innerType;
|
|
11694
11692
|
};
|
|
11695
11693
|
var readonlyProcessor = (schema, ctx, json2, params) => {
|
|
11696
11694
|
const def = schema._zod.def;
|
|
11697
|
-
|
|
11695
|
+
process2(def.innerType, ctx, params);
|
|
11698
11696
|
const seen = ctx.seen.get(schema);
|
|
11699
11697
|
seen.ref = def.innerType;
|
|
11700
11698
|
json2.readOnly = true;
|
|
11701
11699
|
};
|
|
11702
11700
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
11703
11701
|
const def = schema._zod.def;
|
|
11704
|
-
|
|
11702
|
+
process2(def.innerType, ctx, params);
|
|
11705
11703
|
const seen = ctx.seen.get(schema);
|
|
11706
11704
|
seen.ref = def.innerType;
|
|
11707
11705
|
};
|
|
11708
11706
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
11709
11707
|
const def = schema._zod.def;
|
|
11710
|
-
|
|
11708
|
+
process2(def.innerType, ctx, params);
|
|
11711
11709
|
const seen = ctx.seen.get(schema);
|
|
11712
11710
|
seen.ref = def.innerType;
|
|
11713
11711
|
};
|
|
11714
11712
|
var lazyProcessor = (schema, ctx, _json, params) => {
|
|
11715
11713
|
const innerType = schema._zod.innerType;
|
|
11716
|
-
|
|
11714
|
+
process2(innerType, ctx, params);
|
|
11717
11715
|
const seen = ctx.seen.get(schema);
|
|
11718
11716
|
seen.ref = innerType;
|
|
11719
11717
|
};
|
|
@@ -11765,7 +11763,7 @@ function toJSONSchema(input, params) {
|
|
|
11765
11763
|
const defs = {};
|
|
11766
11764
|
for (const entry of registry2._idmap.entries()) {
|
|
11767
11765
|
const [_, schema] = entry;
|
|
11768
|
-
|
|
11766
|
+
process2(schema, ctx2);
|
|
11769
11767
|
}
|
|
11770
11768
|
const schemas = {};
|
|
11771
11769
|
const external = {
|
|
@@ -11788,7 +11786,7 @@ function toJSONSchema(input, params) {
|
|
|
11788
11786
|
return { schemas };
|
|
11789
11787
|
}
|
|
11790
11788
|
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
11791
|
-
|
|
11789
|
+
process2(input, ctx);
|
|
11792
11790
|
extractDefs(ctx, input);
|
|
11793
11791
|
return finalize(ctx, input);
|
|
11794
11792
|
}
|
|
@@ -11846,7 +11844,7 @@ var JSONSchemaGenerator = class {
|
|
|
11846
11844
|
* This must be called before emit().
|
|
11847
11845
|
*/
|
|
11848
11846
|
process(schema, _params = { path: [], schemaPath: [] }) {
|
|
11849
|
-
return
|
|
11847
|
+
return process2(schema, this.ctx, _params);
|
|
11850
11848
|
}
|
|
11851
11849
|
/**
|
|
11852
11850
|
* Emit the final JSON Schema after processing.
|
|
@@ -13368,13 +13366,13 @@ function resolveRef(ref, ctx) {
|
|
|
13368
13366
|
if (!ref.startsWith("#")) {
|
|
13369
13367
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
13370
13368
|
}
|
|
13371
|
-
const
|
|
13372
|
-
if (
|
|
13369
|
+
const path = ref.slice(1).split("/").filter(Boolean);
|
|
13370
|
+
if (path.length === 0) {
|
|
13373
13371
|
return ctx.rootSchema;
|
|
13374
13372
|
}
|
|
13375
13373
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
13376
|
-
if (
|
|
13377
|
-
const key =
|
|
13374
|
+
if (path[0] === defsKey) {
|
|
13375
|
+
const key = path[1];
|
|
13378
13376
|
if (!key || !ctx.defs[key]) {
|
|
13379
13377
|
throw new Error(`Reference not found: ${ref}`);
|
|
13380
13378
|
}
|
|
@@ -13909,175 +13907,62 @@ var DEFAULT_CAPTURE_CONFIG = {
|
|
|
13909
13907
|
consoleErrors: false
|
|
13910
13908
|
};
|
|
13911
13909
|
|
|
13912
|
-
// src/
|
|
13913
|
-
var
|
|
13914
|
-
var
|
|
13915
|
-
var
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
function globToRegExp(glob) {
|
|
13920
|
-
const DOUBLE_STAR_PLACEHOLDER = "\0DSTAR\0";
|
|
13921
|
-
const regexStr = glob.replace(/\*\*\//g, DOUBLE_STAR_PLACEHOLDER).replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]+").replace(new RegExp(DOUBLE_STAR_PLACEHOLDER.replace(/\0/g, "\\0"), "g"), "(?:.+/)?");
|
|
13922
|
-
return new RegExp("^" + regexStr + "$");
|
|
13923
|
-
}
|
|
13924
|
-
function loadCustomTestPatterns(projectRoot) {
|
|
13925
|
-
const configNames = [
|
|
13926
|
-
"vitest.config.ts",
|
|
13927
|
-
"vitest.config.js",
|
|
13928
|
-
"vitest.config.mts",
|
|
13929
|
-
"vitest.config.mjs",
|
|
13930
|
-
"vite.config.ts",
|
|
13931
|
-
"vite.config.js",
|
|
13932
|
-
"vite.config.mts",
|
|
13933
|
-
"vite.config.mjs",
|
|
13934
|
-
"jest.config.ts",
|
|
13935
|
-
"jest.config.js",
|
|
13936
|
-
"jest.config.mts",
|
|
13937
|
-
"jest.config.mjs"
|
|
13938
|
-
];
|
|
13939
|
-
for (const name of configNames) {
|
|
13940
|
-
const configPath = path.join(projectRoot, name);
|
|
13941
|
-
let content;
|
|
13942
|
-
try {
|
|
13943
|
-
content = fsSync.readFileSync(configPath, "utf-8");
|
|
13944
|
-
} catch {
|
|
13945
|
-
continue;
|
|
13946
|
-
}
|
|
13947
|
-
try {
|
|
13948
|
-
const isJest = name.startsWith("jest.");
|
|
13949
|
-
let includeMatch = null;
|
|
13950
|
-
if (isJest) {
|
|
13951
|
-
includeMatch = /testMatch\s*:\s*\[([^\]]*)\]/s.exec(content);
|
|
13952
|
-
} else {
|
|
13953
|
-
const testBlockMatch = /\btest\s*[:{]\s*/s.exec(content);
|
|
13954
|
-
if (testBlockMatch) {
|
|
13955
|
-
const afterTest = content.slice(testBlockMatch.index, testBlockMatch.index + 500);
|
|
13956
|
-
includeMatch = /include\s*:\s*\[([^\]]*)\]/s.exec(afterTest);
|
|
13957
|
-
}
|
|
13958
|
-
}
|
|
13959
|
-
if (!includeMatch) {
|
|
13960
|
-
continue;
|
|
13961
|
-
}
|
|
13962
|
-
const arrayContent = includeMatch[1];
|
|
13963
|
-
const stringRegex = /['"]([^'"]+)['"]/g;
|
|
13964
|
-
const patterns = [];
|
|
13965
|
-
let match;
|
|
13966
|
-
match = stringRegex.exec(arrayContent);
|
|
13967
|
-
while (match !== null) {
|
|
13968
|
-
patterns.push(globToRegExp(match[1]));
|
|
13969
|
-
match = stringRegex.exec(arrayContent);
|
|
13970
|
-
}
|
|
13971
|
-
if (patterns.length > 0) {
|
|
13972
|
-
return patterns;
|
|
13973
|
-
}
|
|
13974
|
-
} catch {
|
|
13975
|
-
continue;
|
|
13976
|
-
}
|
|
13977
|
-
}
|
|
13978
|
-
return [];
|
|
13979
|
-
}
|
|
13980
|
-
async function discoverTestFiles(projectRoot) {
|
|
13981
|
-
const customPatterns = loadCustomTestPatterns(projectRoot);
|
|
13982
|
-
const testPatterns = [...DEFAULT_TEST_PATTERNS, ...customPatterns];
|
|
13983
|
-
const results = [];
|
|
13910
|
+
// src/anon-key.ts
|
|
13911
|
+
var GLASSTRACE_DIR = ".glasstrace";
|
|
13912
|
+
var ANON_KEY_FILE = "anon_key";
|
|
13913
|
+
var ephemeralKeyCache = /* @__PURE__ */ new Map();
|
|
13914
|
+
async function readAnonKey(projectRoot) {
|
|
13915
|
+
const root = projectRoot ?? process.cwd();
|
|
13916
|
+
const keyPath = join(root, GLASSTRACE_DIR, ANON_KEY_FILE);
|
|
13984
13917
|
try {
|
|
13985
|
-
await
|
|
13986
|
-
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
}
|
|
13991
|
-
async function walkForTests(baseDir, currentDir, results, testPatterns) {
|
|
13992
|
-
if (results.length >= MAX_TEST_FILES) {
|
|
13993
|
-
return;
|
|
13994
|
-
}
|
|
13995
|
-
let entries;
|
|
13996
|
-
try {
|
|
13997
|
-
entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
13918
|
+
const content = await readFile(keyPath, "utf-8");
|
|
13919
|
+
const result = AnonApiKeySchema.safeParse(content);
|
|
13920
|
+
if (result.success) {
|
|
13921
|
+
return result.data;
|
|
13922
|
+
}
|
|
13998
13923
|
} catch {
|
|
13999
|
-
return;
|
|
14000
13924
|
}
|
|
14001
|
-
|
|
14002
|
-
|
|
14003
|
-
|
|
14004
|
-
}
|
|
14005
|
-
const fullPath = path.join(currentDir, entry.name);
|
|
14006
|
-
if (entry.isDirectory()) {
|
|
14007
|
-
if (EXCLUDED_DIRS.has(entry.name)) {
|
|
14008
|
-
continue;
|
|
14009
|
-
}
|
|
14010
|
-
await walkForTests(baseDir, fullPath, results, testPatterns);
|
|
14011
|
-
} else if (entry.isFile()) {
|
|
14012
|
-
const relativePath = path.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
14013
|
-
const isTestFile = testPatterns.some((p) => p.test(entry.name) || p.test(relativePath)) || relativePath.includes("__tests__");
|
|
14014
|
-
if (isTestFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"))) {
|
|
14015
|
-
results.push(relativePath);
|
|
14016
|
-
}
|
|
14017
|
-
}
|
|
13925
|
+
const cached2 = ephemeralKeyCache.get(root);
|
|
13926
|
+
if (cached2 !== void 0) {
|
|
13927
|
+
return cached2;
|
|
14018
13928
|
}
|
|
13929
|
+
return null;
|
|
14019
13930
|
}
|
|
14020
|
-
function
|
|
14021
|
-
const
|
|
14022
|
-
const
|
|
14023
|
-
const
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
-
}
|
|
14028
|
-
};
|
|
14029
|
-
const esImportRegex = /import\s+(?:(?:[\w*{}\s,]+)\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
14030
|
-
let match;
|
|
14031
|
-
match = esImportRegex.exec(fileContent);
|
|
14032
|
-
while (match !== null) {
|
|
14033
|
-
addUnique(match[1]);
|
|
14034
|
-
match = esImportRegex.exec(fileContent);
|
|
13931
|
+
async function getOrCreateAnonKey(projectRoot) {
|
|
13932
|
+
const root = projectRoot ?? process.cwd();
|
|
13933
|
+
const dirPath = join(root, GLASSTRACE_DIR);
|
|
13934
|
+
const keyPath = join(dirPath, ANON_KEY_FILE);
|
|
13935
|
+
const existingKey = await readAnonKey(root);
|
|
13936
|
+
if (existingKey !== null) {
|
|
13937
|
+
return existingKey;
|
|
14035
13938
|
}
|
|
14036
|
-
const
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
addUnique(match[1]);
|
|
14040
|
-
match = requireRegex.exec(fileContent);
|
|
13939
|
+
const cached2 = ephemeralKeyCache.get(root);
|
|
13940
|
+
if (cached2 !== void 0) {
|
|
13941
|
+
return cached2;
|
|
14041
13942
|
}
|
|
14042
|
-
const
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
}
|
|
14048
|
-
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
const graph = {};
|
|
14053
|
-
for (const testFile of testFiles) {
|
|
14054
|
-
const fullPath = path.join(projectRoot, testFile);
|
|
14055
|
-
try {
|
|
14056
|
-
const content = await fs.readFile(fullPath, "utf-8");
|
|
14057
|
-
const imports = extractImports(content);
|
|
14058
|
-
graph[testFile] = imports;
|
|
14059
|
-
} catch {
|
|
14060
|
-
continue;
|
|
14061
|
-
}
|
|
13943
|
+
const newKey = createAnonApiKey();
|
|
13944
|
+
try {
|
|
13945
|
+
await mkdir(dirPath, { recursive: true, mode: 448 });
|
|
13946
|
+
await writeFile(keyPath, newKey, "utf-8");
|
|
13947
|
+
await chmod(keyPath, 384);
|
|
13948
|
+
} catch (err) {
|
|
13949
|
+
ephemeralKeyCache.set(root, newKey);
|
|
13950
|
+
console.warn(
|
|
13951
|
+
`[glasstrace] Failed to persist anonymous key to ${keyPath}: ${err instanceof Error ? err.message : String(err)}. Using ephemeral key.`
|
|
13952
|
+
);
|
|
14062
13953
|
}
|
|
14063
|
-
|
|
14064
|
-
const serialized = sortedKeys.map((key) => `${key}:${JSON.stringify(graph[key])}`).join("\n");
|
|
14065
|
-
const hashHex = crypto2.createHash("sha256").update(serialized).digest("hex");
|
|
14066
|
-
const buildHash = createBuildHash(hashHex);
|
|
14067
|
-
return { buildHash, graph };
|
|
13954
|
+
return newKey;
|
|
14068
13955
|
}
|
|
14069
13956
|
|
|
14070
13957
|
export {
|
|
14071
|
-
AnonApiKeySchema,
|
|
14072
13958
|
SessionIdSchema,
|
|
14073
|
-
|
|
13959
|
+
createBuildHash,
|
|
14074
13960
|
SdkCachedConfigSchema,
|
|
14075
13961
|
SdkInitResponseSchema,
|
|
14076
13962
|
SourceMapUploadResponseSchema,
|
|
14077
13963
|
GLASSTRACE_ATTRIBUTE_NAMES,
|
|
14078
13964
|
DEFAULT_CAPTURE_CONFIG,
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
buildImportGraph
|
|
13965
|
+
readAnonKey,
|
|
13966
|
+
getOrCreateAnonKey
|
|
14082
13967
|
};
|
|
14083
|
-
//# sourceMappingURL=chunk-
|
|
13968
|
+
//# sourceMappingURL=chunk-EC5IINUT.js.map
|