@suss/adapter-typescript 0.24.3 → 0.25.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.
- package/dist/index.cjs +113 -87
- package/dist/index.js +113 -87
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -77,7 +77,7 @@ __export(index_exports, {
|
|
|
77
77
|
module.exports = __toCommonJS(index_exports);
|
|
78
78
|
|
|
79
79
|
// src/adapter.ts
|
|
80
|
-
var
|
|
80
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
81
81
|
var import_ts_morph67 = require("ts-morph");
|
|
82
82
|
var import_behavioral_ir8 = require("@suss/behavioral-ir");
|
|
83
83
|
var import_datalog6 = require("@suss/datalog");
|
|
@@ -1913,8 +1913,8 @@ function loadImportGraphsDepthFirstFromPaths(project, rootPaths) {
|
|
|
1913
1913
|
stack.pop();
|
|
1914
1914
|
loadOrder.push(top.path);
|
|
1915
1915
|
let deepest = 0;
|
|
1916
|
-
for (const
|
|
1917
|
-
deepest = Math.max(deepest, chainDepth.get(
|
|
1916
|
+
for (const path15 of top.deps) {
|
|
1917
|
+
deepest = Math.max(deepest, chainDepth.get(path15) ?? 0);
|
|
1918
1918
|
}
|
|
1919
1919
|
chainDepth.set(top.path, deepest + 1);
|
|
1920
1920
|
}
|
|
@@ -2266,11 +2266,11 @@ function walkAndWarm(root, reach) {
|
|
|
2266
2266
|
if (warmedFiles.get(target) !== void 0) {
|
|
2267
2267
|
continue;
|
|
2268
2268
|
}
|
|
2269
|
-
const
|
|
2270
|
-
if (visited.has(
|
|
2269
|
+
const path15 = target.getFilePath();
|
|
2270
|
+
if (visited.has(path15)) {
|
|
2271
2271
|
continue;
|
|
2272
2272
|
}
|
|
2273
|
-
visited.add(
|
|
2273
|
+
visited.add(path15);
|
|
2274
2274
|
stack.push(frameOf(target, reach));
|
|
2275
2275
|
continue;
|
|
2276
2276
|
}
|
|
@@ -2287,7 +2287,7 @@ function sitsOnWarmChains(file) {
|
|
|
2287
2287
|
return false;
|
|
2288
2288
|
}
|
|
2289
2289
|
const imported = importedFilePathsOf(project, file.getFilePath());
|
|
2290
|
-
return imported.length > 0 && imported.every((
|
|
2290
|
+
return imported.length > 0 && imported.every((path15) => warmed.has(path15));
|
|
2291
2291
|
}
|
|
2292
2292
|
function markWarmed(file) {
|
|
2293
2293
|
warmedFiles.set(file, true);
|
|
@@ -4528,7 +4528,6 @@ function buildExtractionReport(args) {
|
|
|
4528
4528
|
unitsInGatedFiles: tally.unitsInGatedFiles,
|
|
4529
4529
|
effectsRecognized: tally.effectsRecognized,
|
|
4530
4530
|
unitsClaimed: tally.unitsClaimed,
|
|
4531
|
-
selfCollisions: tally.selfCollisions,
|
|
4532
4531
|
summariesProduced: tally.summariesProduced,
|
|
4533
4532
|
failures: tally.failures,
|
|
4534
4533
|
helpersUnmatched: helpersWithNoCall(
|
|
@@ -5039,7 +5038,7 @@ function isPathStatement(node) {
|
|
|
5039
5038
|
return import_ts_morph18.Node.isStatement(node) && !import_ts_morph18.Node.isFunctionDeclaration(node);
|
|
5040
5039
|
}
|
|
5041
5040
|
function siteOf(node) {
|
|
5042
|
-
const
|
|
5041
|
+
const path15 = [];
|
|
5043
5042
|
let current2 = node;
|
|
5044
5043
|
for (; ; ) {
|
|
5045
5044
|
const parent = current2.getParent();
|
|
@@ -5047,10 +5046,10 @@ function siteOf(node) {
|
|
|
5047
5046
|
return null;
|
|
5048
5047
|
}
|
|
5049
5048
|
if (isPathStatement(current2)) {
|
|
5050
|
-
|
|
5049
|
+
path15.unshift(current2);
|
|
5051
5050
|
}
|
|
5052
5051
|
if (isRoot(parent)) {
|
|
5053
|
-
return { root: parent, path:
|
|
5052
|
+
return { root: parent, path: path15 };
|
|
5054
5053
|
}
|
|
5055
5054
|
current2 = parent;
|
|
5056
5055
|
}
|
|
@@ -7042,14 +7041,14 @@ function unitForJsxRoute(node, match, routeNames, kind, resolution) {
|
|
|
7042
7041
|
}
|
|
7043
7042
|
return routeUnit(node, kind, match.method, resolved.path, target, resolution);
|
|
7044
7043
|
}
|
|
7045
|
-
function routeUnit(at, kind, method,
|
|
7046
|
-
const routeInfo = { method, path:
|
|
7044
|
+
function routeUnit(at, kind, method, path15, target, resolution) {
|
|
7045
|
+
const routeInfo = { method, path: path15 };
|
|
7047
7046
|
if (target.kind === "unreadable") {
|
|
7048
7047
|
return {
|
|
7049
7048
|
func: null,
|
|
7050
7049
|
announcedAt: at,
|
|
7051
7050
|
kind,
|
|
7052
|
-
name:
|
|
7051
|
+
name: path15,
|
|
7053
7052
|
nameKind: "label",
|
|
7054
7053
|
routeInfo
|
|
7055
7054
|
};
|
|
@@ -8313,11 +8312,11 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8313
8312
|
return null;
|
|
8314
8313
|
}
|
|
8315
8314
|
const method2 = stringPropertyOf(arg, binding.method.property, resolution);
|
|
8316
|
-
const
|
|
8317
|
-
if (method2 === null ||
|
|
8315
|
+
const path16 = stringPropertyOf(arg, binding.path.property, resolution);
|
|
8316
|
+
if (method2 === null || path16 === null) {
|
|
8318
8317
|
return null;
|
|
8319
8318
|
}
|
|
8320
|
-
return { method: method2.toUpperCase(), path:
|
|
8319
|
+
return { method: method2.toUpperCase(), path: path16 };
|
|
8321
8320
|
}
|
|
8322
8321
|
if (binding.method.type !== "fromRegistration" || binding.path.type !== "fromArgument") {
|
|
8323
8322
|
return null;
|
|
@@ -8334,8 +8333,8 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8334
8333
|
method = arg.getLiteralValue().toUpperCase();
|
|
8335
8334
|
}
|
|
8336
8335
|
const pathArg = call.getArguments()[binding.path.position];
|
|
8337
|
-
const
|
|
8338
|
-
return
|
|
8336
|
+
const path15 = pathArg === void 0 ? void 0 : pathFromArgument(pathArg, resolution);
|
|
8337
|
+
return path15 === void 0 ? null : { method, path: path15 };
|
|
8339
8338
|
}
|
|
8340
8339
|
|
|
8341
8340
|
// src/discovery/registrationLoop.ts
|
|
@@ -8467,7 +8466,7 @@ function bodyCallsOnRoutable(loop, guard, resolution) {
|
|
|
8467
8466
|
}
|
|
8468
8467
|
function readRouteSpec(element, shape, resolution) {
|
|
8469
8468
|
let method = null;
|
|
8470
|
-
let
|
|
8469
|
+
let path15 = null;
|
|
8471
8470
|
let handler = null;
|
|
8472
8471
|
for (const prop of element.getProperties()) {
|
|
8473
8472
|
if (import_ts_morph35.Node.isMethodDeclaration(prop) && prop.getName() === shape.handlerKey) {
|
|
@@ -8485,16 +8484,16 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8485
8484
|
if (name === shape.methodKey) {
|
|
8486
8485
|
method = readStringLiteralValue(init);
|
|
8487
8486
|
} else if (name === shape.pathKey) {
|
|
8488
|
-
|
|
8487
|
+
path15 = readStringLiteralValue(init);
|
|
8489
8488
|
} else if (name === shape.handlerKey) {
|
|
8490
8489
|
const func = functionValueOf(init, resolution);
|
|
8491
8490
|
handler = func === null ? null : { func, name: handlerName(init) };
|
|
8492
8491
|
}
|
|
8493
8492
|
}
|
|
8494
|
-
if (method === null ||
|
|
8493
|
+
if (method === null || path15 === null || handler === null) {
|
|
8495
8494
|
return null;
|
|
8496
8495
|
}
|
|
8497
|
-
return { method, path:
|
|
8496
|
+
return { method, path: path15, handler: handler.func, handlerName: handler.name };
|
|
8498
8497
|
}
|
|
8499
8498
|
function readStringLiteralValue(node) {
|
|
8500
8499
|
if (import_ts_morph35.Node.isStringLiteral(node) || import_ts_morph35.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
@@ -8609,8 +8608,8 @@ function discoverRegistrationTemplates(sourceFile, match, kind, resolution, moun
|
|
|
8609
8608
|
const subject = subjectOfCall(sourceFile, args, match, resolution);
|
|
8610
8609
|
const prefix = subject === void 0 ? "" : mountPrefixes?.effectivePrefixFor(subject) ?? "";
|
|
8611
8610
|
for (const reg of match.registrations) {
|
|
8612
|
-
const
|
|
8613
|
-
if (
|
|
8611
|
+
const path15 = substitutePath(reg.pathTemplate, args);
|
|
8612
|
+
if (path15 === null) {
|
|
8614
8613
|
continue;
|
|
8615
8614
|
}
|
|
8616
8615
|
const handler = resolveHandler(reg.handlerArg, args, resolution);
|
|
@@ -8624,7 +8623,7 @@ function discoverRegistrationTemplates(sourceFile, match, kind, resolution, moun
|
|
|
8624
8623
|
...subject === void 0 ? {} : { registrationSubjectId: nodeId(subject) },
|
|
8625
8624
|
routeInfo: {
|
|
8626
8625
|
method: reg.method.toUpperCase(),
|
|
8627
|
-
path: prefix === "" ?
|
|
8626
|
+
path: prefix === "" ? path15 : (0, import_resolution4.joinMountedPath)(prefix, path15)
|
|
8628
8627
|
}
|
|
8629
8628
|
});
|
|
8630
8629
|
}
|
|
@@ -9087,24 +9086,24 @@ function declName(decl) {
|
|
|
9087
9086
|
|
|
9088
9087
|
// src/parameterReads.ts
|
|
9089
9088
|
function pathAbove(reference) {
|
|
9090
|
-
const
|
|
9089
|
+
const path15 = [];
|
|
9091
9090
|
let current2 = reference;
|
|
9092
9091
|
for (; ; ) {
|
|
9093
9092
|
const parent = current2.getParent();
|
|
9094
9093
|
if (parent !== void 0 && import_ts_morph40.Node.isPropertyAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9095
|
-
|
|
9094
|
+
path15.push(parent.getName());
|
|
9096
9095
|
current2 = parent;
|
|
9097
9096
|
continue;
|
|
9098
9097
|
}
|
|
9099
9098
|
if (parent !== void 0 && import_ts_morph40.Node.isElementAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9100
9099
|
const argument = parent.getArgumentExpression();
|
|
9101
9100
|
if (argument !== void 0 && import_ts_morph40.Node.isStringLiteral(argument)) {
|
|
9102
|
-
|
|
9101
|
+
path15.push(argument.getLiteralValue());
|
|
9103
9102
|
current2 = parent;
|
|
9104
9103
|
continue;
|
|
9105
9104
|
}
|
|
9106
9105
|
}
|
|
9107
|
-
return
|
|
9106
|
+
return path15;
|
|
9108
9107
|
}
|
|
9109
9108
|
}
|
|
9110
9109
|
function declaresParameterOf(node, func) {
|
|
@@ -12450,9 +12449,9 @@ function createSourceFileLookup(project) {
|
|
|
12450
12449
|
if (sf === null) {
|
|
12451
12450
|
return null;
|
|
12452
12451
|
}
|
|
12453
|
-
const
|
|
12454
|
-
const index = functionsByFile.get(
|
|
12455
|
-
functionsByFile.set(
|
|
12452
|
+
const path15 = sf.getFilePath();
|
|
12453
|
+
const index = functionsByFile.get(path15) ?? indexFunctions(sf);
|
|
12454
|
+
functionsByFile.set(path15, index);
|
|
12456
12455
|
if (location.span !== void 0) {
|
|
12457
12456
|
const bySpan = index.get(spanKey(location.span));
|
|
12458
12457
|
if (bySpan !== void 0) {
|
|
@@ -12639,7 +12638,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12639
12638
|
}
|
|
12640
12639
|
const responses = [];
|
|
12641
12640
|
let method;
|
|
12642
|
-
let
|
|
12641
|
+
let path15;
|
|
12643
12642
|
for (const prop of endpointNode.getProperties()) {
|
|
12644
12643
|
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12645
12644
|
continue;
|
|
@@ -12654,7 +12653,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12654
12653
|
if (propName === pattern.pathProperty) {
|
|
12655
12654
|
const val = prop.getInitializer();
|
|
12656
12655
|
if (val !== void 0 && import_ts_morph57.Node.isStringLiteral(val)) {
|
|
12657
|
-
|
|
12656
|
+
path15 = val.getLiteralValue();
|
|
12658
12657
|
}
|
|
12659
12658
|
}
|
|
12660
12659
|
if (propName === pattern.responseExtraction.property) {
|
|
@@ -12679,10 +12678,10 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12679
12678
|
if (responses.length === 0) {
|
|
12680
12679
|
return null;
|
|
12681
12680
|
}
|
|
12682
|
-
const boundaryBinding = method !== void 0 ||
|
|
12681
|
+
const boundaryBinding = method !== void 0 || path15 !== void 0 ? (0, import_behavioral_ir4.restBinding)({
|
|
12683
12682
|
transport: "http",
|
|
12684
12683
|
method: method ?? null,
|
|
12685
|
-
path:
|
|
12684
|
+
path: path15 ?? null,
|
|
12686
12685
|
recognition: framework
|
|
12687
12686
|
}) : null;
|
|
12688
12687
|
return {
|
|
@@ -12893,6 +12892,8 @@ function parameterName(segment, convention) {
|
|
|
12893
12892
|
}
|
|
12894
12893
|
|
|
12895
12894
|
// src/discovery/graphqlClientConstruction.ts
|
|
12895
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
12896
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
12896
12897
|
var import_graphql2 = require("graphql");
|
|
12897
12898
|
var import_picomatch2 = __toESM(require("picomatch"), 1);
|
|
12898
12899
|
var import_ts_morph58 = require("ts-morph");
|
|
@@ -12947,8 +12948,36 @@ function fragmentsRegisteredIn(sourceFiles) {
|
|
|
12947
12948
|
}
|
|
12948
12949
|
});
|
|
12949
12950
|
}
|
|
12951
|
+
for (const text of graphqlFileTextsNear(sourceFiles)) {
|
|
12952
|
+
for (const name of fragmentOnlyDocumentNames(text)) {
|
|
12953
|
+
registered.add(name);
|
|
12954
|
+
}
|
|
12955
|
+
}
|
|
12950
12956
|
return registered;
|
|
12951
12957
|
}
|
|
12958
|
+
function graphqlFileTextsNear(sourceFiles) {
|
|
12959
|
+
const roots = new Set(
|
|
12960
|
+
sourceFiles.map((sourceFile) => import_node_path8.default.dirname(sourceFile.getFilePath()))
|
|
12961
|
+
);
|
|
12962
|
+
const texts = [];
|
|
12963
|
+
for (const root of roots) {
|
|
12964
|
+
let entries;
|
|
12965
|
+
try {
|
|
12966
|
+
entries = import_node_fs3.default.readdirSync(root, { withFileTypes: true });
|
|
12967
|
+
} catch {
|
|
12968
|
+
continue;
|
|
12969
|
+
}
|
|
12970
|
+
for (const entry of entries) {
|
|
12971
|
+
if (entry.isFile() && /\.(graphql|gql)$/.test(entry.name)) {
|
|
12972
|
+
try {
|
|
12973
|
+
texts.push(import_node_fs3.default.readFileSync(import_node_path8.default.join(root, entry.name), "utf8"));
|
|
12974
|
+
} catch {
|
|
12975
|
+
}
|
|
12976
|
+
}
|
|
12977
|
+
}
|
|
12978
|
+
}
|
|
12979
|
+
return texts;
|
|
12980
|
+
}
|
|
12952
12981
|
function fragmentOnlyDocumentNames(text) {
|
|
12953
12982
|
if (!text.includes("fragment")) {
|
|
12954
12983
|
return [];
|
|
@@ -13386,8 +13415,8 @@ function noteExpanded(expanded, readings, discovery) {
|
|
|
13386
13415
|
const paths = new Set(match.registrations.map((one) => one.pathTemplate));
|
|
13387
13416
|
const methods = expanded.get(reading.declarationId) ?? /* @__PURE__ */ new Set();
|
|
13388
13417
|
for (const sink of reading.helper.sinks) {
|
|
13389
|
-
const
|
|
13390
|
-
if (sink.method !== null &&
|
|
13418
|
+
const path15 = sink.arguments[0];
|
|
13419
|
+
if (sink.method !== null && path15?.as === "text" && paths.has(path15.text)) {
|
|
13391
13420
|
methods.add(sink.method);
|
|
13392
13421
|
}
|
|
13393
13422
|
}
|
|
@@ -15513,10 +15542,10 @@ function readArrayLiteralText(node) {
|
|
|
15513
15542
|
}
|
|
15514
15543
|
|
|
15515
15544
|
// src/summaryIdentity.ts
|
|
15516
|
-
var
|
|
15545
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
15517
15546
|
var import_behavioral_ir7 = require("@suss/behavioral-ir");
|
|
15518
15547
|
function workspaceRootFor(anchor) {
|
|
15519
|
-
return namedPackageDirAbove(anchor) ??
|
|
15548
|
+
return namedPackageDirAbove(anchor) ?? import_node_path9.default.resolve(anchor);
|
|
15520
15549
|
}
|
|
15521
15550
|
function workspaceNameFor(root) {
|
|
15522
15551
|
if (root === void 0) {
|
|
@@ -15526,7 +15555,7 @@ function workspaceNameFor(root) {
|
|
|
15526
15555
|
if (dir !== null) {
|
|
15527
15556
|
return packageNameAt(dir);
|
|
15528
15557
|
}
|
|
15529
|
-
const folder =
|
|
15558
|
+
const folder = import_node_path9.default.basename(import_node_path9.default.resolve(root));
|
|
15530
15559
|
return folder.length > 0 ? folder : null;
|
|
15531
15560
|
}
|
|
15532
15561
|
function nameSummaries(summaries, args) {
|
|
@@ -15541,10 +15570,10 @@ function nameSummaries(summaries, args) {
|
|
|
15541
15570
|
(0, import_behavioral_ir7.linkCallsToSummaries)(summaries);
|
|
15542
15571
|
}
|
|
15543
15572
|
function relativeFile(file, projectRoot) {
|
|
15544
|
-
if (projectRoot === void 0 || !
|
|
15573
|
+
if (projectRoot === void 0 || !import_node_path9.default.isAbsolute(file)) {
|
|
15545
15574
|
return file;
|
|
15546
15575
|
}
|
|
15547
|
-
const relative =
|
|
15576
|
+
const relative = import_node_path9.default.relative(projectRoot, file);
|
|
15548
15577
|
return relative.startsWith("..") ? file : relative;
|
|
15549
15578
|
}
|
|
15550
15579
|
function idFor(workspace, file, summary) {
|
|
@@ -15576,11 +15605,11 @@ function declineWhenRunFromSource(cacheDir) {
|
|
|
15576
15605
|
}
|
|
15577
15606
|
|
|
15578
15607
|
// src/workspacePatterns.ts
|
|
15579
|
-
var
|
|
15580
|
-
var
|
|
15608
|
+
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
15609
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
15581
15610
|
function readJson(filePath) {
|
|
15582
15611
|
try {
|
|
15583
|
-
return JSON.parse(
|
|
15612
|
+
return JSON.parse(import_node_fs4.default.readFileSync(filePath, "utf8"));
|
|
15584
15613
|
} catch {
|
|
15585
15614
|
return void 0;
|
|
15586
15615
|
}
|
|
@@ -15607,7 +15636,7 @@ function pnpmWorkspaceGlobs(yamlText) {
|
|
|
15607
15636
|
return globs;
|
|
15608
15637
|
}
|
|
15609
15638
|
function workspaceGlobsAt(dir) {
|
|
15610
|
-
const pkg = readJson(
|
|
15639
|
+
const pkg = readJson(import_node_path10.default.join(dir, "package.json"));
|
|
15611
15640
|
if (typeof pkg === "object" && pkg !== null && "workspaces" in pkg) {
|
|
15612
15641
|
const ws = pkg.workspaces;
|
|
15613
15642
|
if (Array.isArray(ws)) {
|
|
@@ -15619,10 +15648,10 @@ function workspaceGlobsAt(dir) {
|
|
|
15619
15648
|
);
|
|
15620
15649
|
}
|
|
15621
15650
|
}
|
|
15622
|
-
const pnpmPath =
|
|
15623
|
-
if (
|
|
15651
|
+
const pnpmPath = import_node_path10.default.join(dir, "pnpm-workspace.yaml");
|
|
15652
|
+
if (import_node_fs4.default.existsSync(pnpmPath)) {
|
|
15624
15653
|
try {
|
|
15625
|
-
return pnpmWorkspaceGlobs(
|
|
15654
|
+
return pnpmWorkspaceGlobs(import_node_fs4.default.readFileSync(pnpmPath, "utf8"));
|
|
15626
15655
|
} catch {
|
|
15627
15656
|
return null;
|
|
15628
15657
|
}
|
|
@@ -15631,14 +15660,14 @@ function workspaceGlobsAt(dir) {
|
|
|
15631
15660
|
}
|
|
15632
15661
|
function isDirectory(candidate) {
|
|
15633
15662
|
try {
|
|
15634
|
-
return
|
|
15663
|
+
return import_node_fs4.default.statSync(candidate).isDirectory();
|
|
15635
15664
|
} catch {
|
|
15636
15665
|
return false;
|
|
15637
15666
|
}
|
|
15638
15667
|
}
|
|
15639
15668
|
function subdirectoriesOf(dir) {
|
|
15640
15669
|
try {
|
|
15641
|
-
return
|
|
15670
|
+
return import_node_fs4.default.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).filter((name) => !name.startsWith(".") && name !== "node_modules");
|
|
15642
15671
|
} catch {
|
|
15643
15672
|
return [];
|
|
15644
15673
|
}
|
|
@@ -15656,13 +15685,13 @@ function directoriesMatchingGlob(root, glob) {
|
|
|
15656
15685
|
for (const dir of current2) {
|
|
15657
15686
|
for (const entry of subdirectoriesOf(dir)) {
|
|
15658
15687
|
if (pattern.test(entry)) {
|
|
15659
|
-
next.push(
|
|
15688
|
+
next.push(import_node_path10.default.join(dir, entry));
|
|
15660
15689
|
}
|
|
15661
15690
|
}
|
|
15662
15691
|
}
|
|
15663
15692
|
} else {
|
|
15664
15693
|
for (const dir of current2) {
|
|
15665
|
-
next.push(
|
|
15694
|
+
next.push(import_node_path10.default.join(dir, segment));
|
|
15666
15695
|
}
|
|
15667
15696
|
}
|
|
15668
15697
|
current2 = next.filter(isDirectory);
|
|
@@ -15670,7 +15699,7 @@ function directoriesMatchingGlob(root, glob) {
|
|
|
15670
15699
|
return current2;
|
|
15671
15700
|
}
|
|
15672
15701
|
function packageAt(dir) {
|
|
15673
|
-
const packageJsonPath =
|
|
15702
|
+
const packageJsonPath = import_node_path10.default.join(dir, "package.json");
|
|
15674
15703
|
const pkg = readJson(packageJsonPath);
|
|
15675
15704
|
if (typeof pkg === "object" && pkg !== null && typeof pkg.name === "string") {
|
|
15676
15705
|
return { name: pkg.name, packageJsonPath };
|
|
@@ -15678,7 +15707,7 @@ function packageAt(dir) {
|
|
|
15678
15707
|
return null;
|
|
15679
15708
|
}
|
|
15680
15709
|
function workspacePackagesFrom(anchor) {
|
|
15681
|
-
let dir =
|
|
15710
|
+
let dir = import_node_path10.default.resolve(anchor);
|
|
15682
15711
|
for (; ; ) {
|
|
15683
15712
|
const globs = workspaceGlobsAt(dir);
|
|
15684
15713
|
if (globs !== null) {
|
|
@@ -15698,7 +15727,7 @@ function workspacePackagesFrom(anchor) {
|
|
|
15698
15727
|
(a, b) => a.packageJsonPath.localeCompare(b.packageJsonPath)
|
|
15699
15728
|
);
|
|
15700
15729
|
}
|
|
15701
|
-
const parent =
|
|
15730
|
+
const parent = import_node_path10.default.dirname(dir);
|
|
15702
15731
|
if (parent === dir) {
|
|
15703
15732
|
return [];
|
|
15704
15733
|
}
|
|
@@ -16240,11 +16269,11 @@ function extractConsumerBinding(unit, pattern, pack, resolution) {
|
|
|
16240
16269
|
return null;
|
|
16241
16270
|
}
|
|
16242
16271
|
const method = extractBindingMethod(binding, callSite, pack, resolution);
|
|
16243
|
-
const
|
|
16272
|
+
const path15 = extractBindingPath(binding, callSite, pack, resolution);
|
|
16244
16273
|
return (0, import_behavioral_ir8.restBinding)({
|
|
16245
16274
|
transport: pack.protocol,
|
|
16246
16275
|
method: method ?? null,
|
|
16247
|
-
path:
|
|
16276
|
+
path: path15 ?? null,
|
|
16248
16277
|
recognition: pack.name
|
|
16249
16278
|
});
|
|
16250
16279
|
}
|
|
@@ -16453,9 +16482,6 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16453
16482
|
const claimKey = unitDedupKey(unit);
|
|
16454
16483
|
const claimant = claimed.get(claimKey);
|
|
16455
16484
|
if (claimant !== void 0) {
|
|
16456
|
-
if (claimant.pack === pack.name && claimant.file === sourceFile.getFilePath() && tally !== void 0) {
|
|
16457
|
-
tally.selfCollisions += 1;
|
|
16458
|
-
}
|
|
16459
16485
|
if (claimant.file !== sourceFile.getFilePath()) {
|
|
16460
16486
|
recordFileDependency(claimant.file);
|
|
16461
16487
|
}
|
|
@@ -16891,8 +16917,8 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16891
16917
|
if (pathArg === void 0) {
|
|
16892
16918
|
continue;
|
|
16893
16919
|
}
|
|
16894
|
-
const
|
|
16895
|
-
if (
|
|
16920
|
+
const path15 = pathFromArgument(pathArg, resolution);
|
|
16921
|
+
if (path15 === void 0) {
|
|
16896
16922
|
continue;
|
|
16897
16923
|
}
|
|
16898
16924
|
const callerFunc = enclosingFunction(callExpr);
|
|
@@ -16904,7 +16930,7 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16904
16930
|
continue;
|
|
16905
16931
|
}
|
|
16906
16932
|
seen.add(dedupKey);
|
|
16907
|
-
out.push(buildCallerSummary(wrapper, callerFunc, callExpr,
|
|
16933
|
+
out.push(buildCallerSummary(wrapper, callerFunc, callExpr, path15, options));
|
|
16908
16934
|
}
|
|
16909
16935
|
return out;
|
|
16910
16936
|
}
|
|
@@ -16961,7 +16987,7 @@ function callerName(func) {
|
|
|
16961
16987
|
}
|
|
16962
16988
|
return "anonymous";
|
|
16963
16989
|
}
|
|
16964
|
-
function buildCallerSummary(wrapper, callerFunc, callExpr,
|
|
16990
|
+
function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
16965
16991
|
const wrapperBinding = wrapper.summary.identity.boundaryBinding;
|
|
16966
16992
|
const wrapperRest = wrapperBinding?.semantics.name === "rest" ? wrapperBinding.semantics : null;
|
|
16967
16993
|
const syntheticPack = {
|
|
@@ -16993,7 +17019,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path14, options) {
|
|
|
16993
17019
|
raw.boundaryBinding = (0, import_behavioral_ir8.restBinding)({
|
|
16994
17020
|
transport: wrapperBinding?.transport ?? "http",
|
|
16995
17021
|
method: wrapperRest?.method ?? null,
|
|
16996
|
-
path:
|
|
17022
|
+
path: path15,
|
|
16997
17023
|
recognition: wrapperBinding?.recognition ?? "unknown"
|
|
16998
17024
|
});
|
|
16999
17025
|
const summary = (0, import_extractor11.assembleSummary)(raw, options);
|
|
@@ -17051,7 +17077,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17051
17077
|
...suppliedConfig,
|
|
17052
17078
|
frameworks: expandWorkspacePatterns(
|
|
17053
17079
|
suppliedConfig.frameworks,
|
|
17054
|
-
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ?
|
|
17080
|
+
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ? import_node_path11.default.dirname(suppliedConfig.tsConfigFilePath) : void 0)
|
|
17055
17081
|
)
|
|
17056
17082
|
};
|
|
17057
17083
|
const project = config.project ?? new import_ts_morph67.Project(
|
|
@@ -17060,11 +17086,11 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17060
17086
|
skipAddingFilesFromTsConfig: true
|
|
17061
17087
|
} : { skipAddingFilesFromTsConfig: true }
|
|
17062
17088
|
);
|
|
17063
|
-
const runRoot = config.projectRoot ?? (config.tsConfigFilePath !== void 0 ? workspaceRootFor(
|
|
17089
|
+
const runRoot = config.projectRoot ?? (config.tsConfigFilePath !== void 0 ? workspaceRootFor(import_node_path11.default.dirname(config.tsConfigFilePath)) : void 0);
|
|
17064
17090
|
let lazyBootstrapped = false;
|
|
17065
17091
|
let projectFileSet;
|
|
17066
17092
|
const cacheDir = declineWhenRunFromSource(
|
|
17067
|
-
config.cacheDir === null ? null : config.cacheDir ?? (config.tsConfigFilePath !== void 0 ?
|
|
17093
|
+
config.cacheDir === null ? null : config.cacheDir ?? (config.tsConfigFilePath !== void 0 ? import_node_path11.default.join(import_node_path11.default.dirname(config.tsConfigFilePath), ".suss", "cache") : null)
|
|
17068
17094
|
);
|
|
17069
17095
|
const cache = (0, import_extractor11.createCacheLayer)(cacheDir);
|
|
17070
17096
|
const packsDigest = `${computeAdapterPacksDigest(
|
|
@@ -17768,8 +17794,8 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17768
17794
|
}
|
|
17769
17795
|
|
|
17770
17796
|
// src/bootstrap/noTsconfigProject.ts
|
|
17771
|
-
var
|
|
17772
|
-
var
|
|
17797
|
+
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
17798
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
17773
17799
|
var import_ts_morph68 = require("ts-morph");
|
|
17774
17800
|
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
17775
17801
|
".ts",
|
|
@@ -17800,7 +17826,7 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17800
17826
|
const found = [];
|
|
17801
17827
|
let entries;
|
|
17802
17828
|
try {
|
|
17803
|
-
entries =
|
|
17829
|
+
entries = import_node_fs5.default.readdirSync(rootDir, { withFileTypes: true });
|
|
17804
17830
|
} catch {
|
|
17805
17831
|
return [];
|
|
17806
17832
|
}
|
|
@@ -17808,10 +17834,10 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17808
17834
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name)) {
|
|
17809
17835
|
continue;
|
|
17810
17836
|
}
|
|
17811
|
-
const full =
|
|
17837
|
+
const full = import_node_path12.default.join(rootDir, entry.name);
|
|
17812
17838
|
if (entry.isDirectory()) {
|
|
17813
17839
|
found.push(...findSourceFiles(full, depth + 1));
|
|
17814
|
-
} else if (SOURCE_EXTENSIONS.has(
|
|
17840
|
+
} else if (SOURCE_EXTENSIONS.has(import_node_path12.default.extname(entry.name)) && !entry.name.endsWith(".d.ts")) {
|
|
17815
17841
|
found.push(full);
|
|
17816
17842
|
}
|
|
17817
17843
|
}
|
|
@@ -17846,15 +17872,15 @@ function createProjectWithoutTsconfig(rootDir) {
|
|
|
17846
17872
|
return { project, files };
|
|
17847
17873
|
}
|
|
17848
17874
|
function findNearestTsconfig(startDir) {
|
|
17849
|
-
let dir =
|
|
17875
|
+
let dir = import_node_path12.default.resolve(startDir);
|
|
17850
17876
|
while (true) {
|
|
17851
17877
|
for (const name of ["tsconfig.json", "jsconfig.json"]) {
|
|
17852
|
-
const candidate =
|
|
17853
|
-
if (
|
|
17878
|
+
const candidate = import_node_path12.default.join(dir, name);
|
|
17879
|
+
if (import_node_fs5.default.existsSync(candidate)) {
|
|
17854
17880
|
return candidate;
|
|
17855
17881
|
}
|
|
17856
17882
|
}
|
|
17857
|
-
const parent =
|
|
17883
|
+
const parent = import_node_path12.default.dirname(dir);
|
|
17858
17884
|
if (parent === dir) {
|
|
17859
17885
|
return null;
|
|
17860
17886
|
}
|
|
@@ -17863,7 +17889,7 @@ function findNearestTsconfig(startDir) {
|
|
|
17863
17889
|
}
|
|
17864
17890
|
|
|
17865
17891
|
// src/facts/why.ts
|
|
17866
|
-
var
|
|
17892
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
17867
17893
|
var import_ts_morph69 = require("ts-morph");
|
|
17868
17894
|
var import_resolution7 = require("@suss/resolution");
|
|
17869
17895
|
var JS_PHRASES = {
|
|
@@ -17876,7 +17902,7 @@ var TypeScriptWhySession = class {
|
|
|
17876
17902
|
store;
|
|
17877
17903
|
root;
|
|
17878
17904
|
constructor(options) {
|
|
17879
|
-
this.root =
|
|
17905
|
+
this.root = import_node_path13.default.resolve(options.dir);
|
|
17880
17906
|
const tsconfig = findNearestTsconfig(this.root);
|
|
17881
17907
|
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new import_ts_morph69.Project({ tsConfigFilePath: tsconfig });
|
|
17882
17908
|
this.store = new ResolutionStore();
|
|
@@ -17965,7 +17991,7 @@ var TypeScriptWhySession = class {
|
|
|
17965
17991
|
};
|
|
17966
17992
|
}
|
|
17967
17993
|
sourceFileAt(file) {
|
|
17968
|
-
const absolute =
|
|
17994
|
+
const absolute = import_node_path13.default.resolve(this.root, file);
|
|
17969
17995
|
const loaded = this.project.getSourceFile(absolute);
|
|
17970
17996
|
if (loaded !== void 0) {
|
|
17971
17997
|
return loaded;
|
|
@@ -17979,7 +18005,7 @@ var TypeScriptWhySession = class {
|
|
|
17979
18005
|
/** A module key: a file path said relative to the root, or a package name. */
|
|
17980
18006
|
displayPath(key) {
|
|
17981
18007
|
if (key.startsWith(this.root)) {
|
|
17982
|
-
return
|
|
18008
|
+
return import_node_path13.default.relative(this.root, key);
|
|
17983
18009
|
}
|
|
17984
18010
|
return key;
|
|
17985
18011
|
}
|
|
@@ -18008,7 +18034,7 @@ function displayNameOf(node) {
|
|
|
18008
18034
|
}
|
|
18009
18035
|
|
|
18010
18036
|
// src/stubEvidence.ts
|
|
18011
|
-
var
|
|
18037
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
18012
18038
|
var import_ts_morph70 = require("ts-morph");
|
|
18013
18039
|
function stubEvidenceIn(project, packageName, root) {
|
|
18014
18040
|
const resolution = new ResolutionStore();
|
|
@@ -18024,7 +18050,7 @@ function stubEvidenceIn(project, packageName, root) {
|
|
|
18024
18050
|
calls: []
|
|
18025
18051
|
};
|
|
18026
18052
|
entry.calls.push({
|
|
18027
|
-
file:
|
|
18053
|
+
file: import_node_path14.default.relative(root, sourceFile.getFilePath()).split(import_node_path14.default.sep).join("/"),
|
|
18028
18054
|
line: one.call.getStartLineNumber(),
|
|
18029
18055
|
args: one.call.getArguments().map((arg) => effectArgOf(arg))
|
|
18030
18056
|
});
|
|
@@ -18039,7 +18065,7 @@ function stubEvidence(options) {
|
|
|
18039
18065
|
const project = new import_ts_morph70.Project(
|
|
18040
18066
|
options.tsConfigFilePath !== void 0 ? { tsConfigFilePath: options.tsConfigFilePath } : { compilerOptions: { allowJs: true } }
|
|
18041
18067
|
);
|
|
18042
|
-
const root = options.tsConfigFilePath !== void 0 ?
|
|
18068
|
+
const root = options.tsConfigFilePath !== void 0 ? import_node_path14.default.dirname(options.tsConfigFilePath) : import_node_path14.default.resolve(options.directory ?? process.cwd());
|
|
18043
18069
|
if (options.tsConfigFilePath === void 0) {
|
|
18044
18070
|
project.addSourceFilesAtPaths([
|
|
18045
18071
|
`${root}/**/*.{ts,tsx,js,jsx}`,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/adapter.ts
|
|
2
|
-
import
|
|
2
|
+
import path11 from "path";
|
|
3
3
|
import {
|
|
4
4
|
Node as Node64,
|
|
5
5
|
Project,
|
|
@@ -1871,8 +1871,8 @@ function loadImportGraphsDepthFirstFromPaths(project, rootPaths) {
|
|
|
1871
1871
|
stack.pop();
|
|
1872
1872
|
loadOrder.push(top.path);
|
|
1873
1873
|
let deepest = 0;
|
|
1874
|
-
for (const
|
|
1875
|
-
deepest = Math.max(deepest, chainDepth.get(
|
|
1874
|
+
for (const path15 of top.deps) {
|
|
1875
|
+
deepest = Math.max(deepest, chainDepth.get(path15) ?? 0);
|
|
1876
1876
|
}
|
|
1877
1877
|
chainDepth.set(top.path, deepest + 1);
|
|
1878
1878
|
}
|
|
@@ -2224,11 +2224,11 @@ function walkAndWarm(root, reach) {
|
|
|
2224
2224
|
if (warmedFiles.get(target) !== void 0) {
|
|
2225
2225
|
continue;
|
|
2226
2226
|
}
|
|
2227
|
-
const
|
|
2228
|
-
if (visited.has(
|
|
2227
|
+
const path15 = target.getFilePath();
|
|
2228
|
+
if (visited.has(path15)) {
|
|
2229
2229
|
continue;
|
|
2230
2230
|
}
|
|
2231
|
-
visited.add(
|
|
2231
|
+
visited.add(path15);
|
|
2232
2232
|
stack.push(frameOf(target, reach));
|
|
2233
2233
|
continue;
|
|
2234
2234
|
}
|
|
@@ -2245,7 +2245,7 @@ function sitsOnWarmChains(file) {
|
|
|
2245
2245
|
return false;
|
|
2246
2246
|
}
|
|
2247
2247
|
const imported = importedFilePathsOf(project, file.getFilePath());
|
|
2248
|
-
return imported.length > 0 && imported.every((
|
|
2248
|
+
return imported.length > 0 && imported.every((path15) => warmed.has(path15));
|
|
2249
2249
|
}
|
|
2250
2250
|
function markWarmed(file) {
|
|
2251
2251
|
warmedFiles.set(file, true);
|
|
@@ -4513,7 +4513,6 @@ function buildExtractionReport(args) {
|
|
|
4513
4513
|
unitsInGatedFiles: tally.unitsInGatedFiles,
|
|
4514
4514
|
effectsRecognized: tally.effectsRecognized,
|
|
4515
4515
|
unitsClaimed: tally.unitsClaimed,
|
|
4516
|
-
selfCollisions: tally.selfCollisions,
|
|
4517
4516
|
summariesProduced: tally.summariesProduced,
|
|
4518
4517
|
failures: tally.failures,
|
|
4519
4518
|
helpersUnmatched: helpersWithNoCall(
|
|
@@ -5024,7 +5023,7 @@ function isPathStatement(node) {
|
|
|
5024
5023
|
return Node16.isStatement(node) && !Node16.isFunctionDeclaration(node);
|
|
5025
5024
|
}
|
|
5026
5025
|
function siteOf(node) {
|
|
5027
|
-
const
|
|
5026
|
+
const path15 = [];
|
|
5028
5027
|
let current2 = node;
|
|
5029
5028
|
for (; ; ) {
|
|
5030
5029
|
const parent = current2.getParent();
|
|
@@ -5032,10 +5031,10 @@ function siteOf(node) {
|
|
|
5032
5031
|
return null;
|
|
5033
5032
|
}
|
|
5034
5033
|
if (isPathStatement(current2)) {
|
|
5035
|
-
|
|
5034
|
+
path15.unshift(current2);
|
|
5036
5035
|
}
|
|
5037
5036
|
if (isRoot(parent)) {
|
|
5038
|
-
return { root: parent, path:
|
|
5037
|
+
return { root: parent, path: path15 };
|
|
5039
5038
|
}
|
|
5040
5039
|
current2 = parent;
|
|
5041
5040
|
}
|
|
@@ -7048,14 +7047,14 @@ function unitForJsxRoute(node, match, routeNames, kind, resolution) {
|
|
|
7048
7047
|
}
|
|
7049
7048
|
return routeUnit(node, kind, match.method, resolved.path, target, resolution);
|
|
7050
7049
|
}
|
|
7051
|
-
function routeUnit(at, kind, method,
|
|
7052
|
-
const routeInfo = { method, path:
|
|
7050
|
+
function routeUnit(at, kind, method, path15, target, resolution) {
|
|
7051
|
+
const routeInfo = { method, path: path15 };
|
|
7053
7052
|
if (target.kind === "unreadable") {
|
|
7054
7053
|
return {
|
|
7055
7054
|
func: null,
|
|
7056
7055
|
announcedAt: at,
|
|
7057
7056
|
kind,
|
|
7058
|
-
name:
|
|
7057
|
+
name: path15,
|
|
7059
7058
|
nameKind: "label",
|
|
7060
7059
|
routeInfo
|
|
7061
7060
|
};
|
|
@@ -8321,11 +8320,11 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8321
8320
|
return null;
|
|
8322
8321
|
}
|
|
8323
8322
|
const method2 = stringPropertyOf(arg, binding.method.property, resolution);
|
|
8324
|
-
const
|
|
8325
|
-
if (method2 === null ||
|
|
8323
|
+
const path16 = stringPropertyOf(arg, binding.path.property, resolution);
|
|
8324
|
+
if (method2 === null || path16 === null) {
|
|
8326
8325
|
return null;
|
|
8327
8326
|
}
|
|
8328
|
-
return { method: method2.toUpperCase(), path:
|
|
8327
|
+
return { method: method2.toUpperCase(), path: path16 };
|
|
8329
8328
|
}
|
|
8330
8329
|
if (binding.method.type !== "fromRegistration" || binding.path.type !== "fromArgument") {
|
|
8331
8330
|
return null;
|
|
@@ -8342,8 +8341,8 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8342
8341
|
method = arg.getLiteralValue().toUpperCase();
|
|
8343
8342
|
}
|
|
8344
8343
|
const pathArg = call.getArguments()[binding.path.position];
|
|
8345
|
-
const
|
|
8346
|
-
return
|
|
8344
|
+
const path15 = pathArg === void 0 ? void 0 : pathFromArgument(pathArg, resolution);
|
|
8345
|
+
return path15 === void 0 ? null : { method, path: path15 };
|
|
8347
8346
|
}
|
|
8348
8347
|
|
|
8349
8348
|
// src/discovery/registrationLoop.ts
|
|
@@ -8475,7 +8474,7 @@ function bodyCallsOnRoutable(loop, guard, resolution) {
|
|
|
8475
8474
|
}
|
|
8476
8475
|
function readRouteSpec(element, shape, resolution) {
|
|
8477
8476
|
let method = null;
|
|
8478
|
-
let
|
|
8477
|
+
let path15 = null;
|
|
8479
8478
|
let handler = null;
|
|
8480
8479
|
for (const prop of element.getProperties()) {
|
|
8481
8480
|
if (Node33.isMethodDeclaration(prop) && prop.getName() === shape.handlerKey) {
|
|
@@ -8493,16 +8492,16 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8493
8492
|
if (name === shape.methodKey) {
|
|
8494
8493
|
method = readStringLiteralValue(init);
|
|
8495
8494
|
} else if (name === shape.pathKey) {
|
|
8496
|
-
|
|
8495
|
+
path15 = readStringLiteralValue(init);
|
|
8497
8496
|
} else if (name === shape.handlerKey) {
|
|
8498
8497
|
const func = functionValueOf(init, resolution);
|
|
8499
8498
|
handler = func === null ? null : { func, name: handlerName(init) };
|
|
8500
8499
|
}
|
|
8501
8500
|
}
|
|
8502
|
-
if (method === null ||
|
|
8501
|
+
if (method === null || path15 === null || handler === null) {
|
|
8503
8502
|
return null;
|
|
8504
8503
|
}
|
|
8505
|
-
return { method, path:
|
|
8504
|
+
return { method, path: path15, handler: handler.func, handlerName: handler.name };
|
|
8506
8505
|
}
|
|
8507
8506
|
function readStringLiteralValue(node) {
|
|
8508
8507
|
if (Node33.isStringLiteral(node) || Node33.isNoSubstitutionTemplateLiteral(node)) {
|
|
@@ -8623,8 +8622,8 @@ function discoverRegistrationTemplates(sourceFile, match, kind, resolution, moun
|
|
|
8623
8622
|
const subject = subjectOfCall(sourceFile, args, match, resolution);
|
|
8624
8623
|
const prefix = subject === void 0 ? "" : mountPrefixes?.effectivePrefixFor(subject) ?? "";
|
|
8625
8624
|
for (const reg of match.registrations) {
|
|
8626
|
-
const
|
|
8627
|
-
if (
|
|
8625
|
+
const path15 = substitutePath(reg.pathTemplate, args);
|
|
8626
|
+
if (path15 === null) {
|
|
8628
8627
|
continue;
|
|
8629
8628
|
}
|
|
8630
8629
|
const handler = resolveHandler(reg.handlerArg, args, resolution);
|
|
@@ -8638,7 +8637,7 @@ function discoverRegistrationTemplates(sourceFile, match, kind, resolution, moun
|
|
|
8638
8637
|
...subject === void 0 ? {} : { registrationSubjectId: nodeId(subject) },
|
|
8639
8638
|
routeInfo: {
|
|
8640
8639
|
method: reg.method.toUpperCase(),
|
|
8641
|
-
path: prefix === "" ?
|
|
8640
|
+
path: prefix === "" ? path15 : joinMountedPath2(prefix, path15)
|
|
8642
8641
|
}
|
|
8643
8642
|
});
|
|
8644
8643
|
}
|
|
@@ -9101,24 +9100,24 @@ function declName(decl) {
|
|
|
9101
9100
|
|
|
9102
9101
|
// src/parameterReads.ts
|
|
9103
9102
|
function pathAbove(reference) {
|
|
9104
|
-
const
|
|
9103
|
+
const path15 = [];
|
|
9105
9104
|
let current2 = reference;
|
|
9106
9105
|
for (; ; ) {
|
|
9107
9106
|
const parent = current2.getParent();
|
|
9108
9107
|
if (parent !== void 0 && Node38.isPropertyAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9109
|
-
|
|
9108
|
+
path15.push(parent.getName());
|
|
9110
9109
|
current2 = parent;
|
|
9111
9110
|
continue;
|
|
9112
9111
|
}
|
|
9113
9112
|
if (parent !== void 0 && Node38.isElementAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9114
9113
|
const argument = parent.getArgumentExpression();
|
|
9115
9114
|
if (argument !== void 0 && Node38.isStringLiteral(argument)) {
|
|
9116
|
-
|
|
9115
|
+
path15.push(argument.getLiteralValue());
|
|
9117
9116
|
current2 = parent;
|
|
9118
9117
|
continue;
|
|
9119
9118
|
}
|
|
9120
9119
|
}
|
|
9121
|
-
return
|
|
9120
|
+
return path15;
|
|
9122
9121
|
}
|
|
9123
9122
|
}
|
|
9124
9123
|
function declaresParameterOf(node, func) {
|
|
@@ -12471,9 +12470,9 @@ function createSourceFileLookup(project) {
|
|
|
12471
12470
|
if (sf === null) {
|
|
12472
12471
|
return null;
|
|
12473
12472
|
}
|
|
12474
|
-
const
|
|
12475
|
-
const index = functionsByFile.get(
|
|
12476
|
-
functionsByFile.set(
|
|
12473
|
+
const path15 = sf.getFilePath();
|
|
12474
|
+
const index = functionsByFile.get(path15) ?? indexFunctions(sf);
|
|
12475
|
+
functionsByFile.set(path15, index);
|
|
12477
12476
|
if (location.span !== void 0) {
|
|
12478
12477
|
const bySpan = index.get(spanKey(location.span));
|
|
12479
12478
|
if (bySpan !== void 0) {
|
|
@@ -12660,7 +12659,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12660
12659
|
}
|
|
12661
12660
|
const responses = [];
|
|
12662
12661
|
let method;
|
|
12663
|
-
let
|
|
12662
|
+
let path15;
|
|
12664
12663
|
for (const prop of endpointNode.getProperties()) {
|
|
12665
12664
|
if (!Node54.isPropertyAssignment(prop)) {
|
|
12666
12665
|
continue;
|
|
@@ -12675,7 +12674,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12675
12674
|
if (propName === pattern.pathProperty) {
|
|
12676
12675
|
const val = prop.getInitializer();
|
|
12677
12676
|
if (val !== void 0 && Node54.isStringLiteral(val)) {
|
|
12678
|
-
|
|
12677
|
+
path15 = val.getLiteralValue();
|
|
12679
12678
|
}
|
|
12680
12679
|
}
|
|
12681
12680
|
if (propName === pattern.responseExtraction.property) {
|
|
@@ -12700,10 +12699,10 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12700
12699
|
if (responses.length === 0) {
|
|
12701
12700
|
return null;
|
|
12702
12701
|
}
|
|
12703
|
-
const boundaryBinding = method !== void 0 ||
|
|
12702
|
+
const boundaryBinding = method !== void 0 || path15 !== void 0 ? restBinding({
|
|
12704
12703
|
transport: "http",
|
|
12705
12704
|
method: method ?? null,
|
|
12706
|
-
path:
|
|
12705
|
+
path: path15 ?? null,
|
|
12707
12706
|
recognition: framework
|
|
12708
12707
|
}) : null;
|
|
12709
12708
|
return {
|
|
@@ -12914,6 +12913,8 @@ function parameterName(segment, convention) {
|
|
|
12914
12913
|
}
|
|
12915
12914
|
|
|
12916
12915
|
// src/discovery/graphqlClientConstruction.ts
|
|
12916
|
+
import fs4 from "fs";
|
|
12917
|
+
import path8 from "path";
|
|
12917
12918
|
import {
|
|
12918
12919
|
parse as graphqlParse2
|
|
12919
12920
|
} from "graphql";
|
|
@@ -12976,8 +12977,36 @@ function fragmentsRegisteredIn(sourceFiles) {
|
|
|
12976
12977
|
}
|
|
12977
12978
|
});
|
|
12978
12979
|
}
|
|
12980
|
+
for (const text of graphqlFileTextsNear(sourceFiles)) {
|
|
12981
|
+
for (const name of fragmentOnlyDocumentNames(text)) {
|
|
12982
|
+
registered.add(name);
|
|
12983
|
+
}
|
|
12984
|
+
}
|
|
12979
12985
|
return registered;
|
|
12980
12986
|
}
|
|
12987
|
+
function graphqlFileTextsNear(sourceFiles) {
|
|
12988
|
+
const roots = new Set(
|
|
12989
|
+
sourceFiles.map((sourceFile) => path8.dirname(sourceFile.getFilePath()))
|
|
12990
|
+
);
|
|
12991
|
+
const texts = [];
|
|
12992
|
+
for (const root of roots) {
|
|
12993
|
+
let entries;
|
|
12994
|
+
try {
|
|
12995
|
+
entries = fs4.readdirSync(root, { withFileTypes: true });
|
|
12996
|
+
} catch {
|
|
12997
|
+
continue;
|
|
12998
|
+
}
|
|
12999
|
+
for (const entry of entries) {
|
|
13000
|
+
if (entry.isFile() && /\.(graphql|gql)$/.test(entry.name)) {
|
|
13001
|
+
try {
|
|
13002
|
+
texts.push(fs4.readFileSync(path8.join(root, entry.name), "utf8"));
|
|
13003
|
+
} catch {
|
|
13004
|
+
}
|
|
13005
|
+
}
|
|
13006
|
+
}
|
|
13007
|
+
}
|
|
13008
|
+
return texts;
|
|
13009
|
+
}
|
|
12981
13010
|
function fragmentOnlyDocumentNames(text) {
|
|
12982
13011
|
if (!text.includes("fragment")) {
|
|
12983
13012
|
return [];
|
|
@@ -13415,8 +13444,8 @@ function noteExpanded(expanded, readings, discovery) {
|
|
|
13415
13444
|
const paths = new Set(match.registrations.map((one) => one.pathTemplate));
|
|
13416
13445
|
const methods = expanded.get(reading.declarationId) ?? /* @__PURE__ */ new Set();
|
|
13417
13446
|
for (const sink of reading.helper.sinks) {
|
|
13418
|
-
const
|
|
13419
|
-
if (sink.method !== null &&
|
|
13447
|
+
const path15 = sink.arguments[0];
|
|
13448
|
+
if (sink.method !== null && path15?.as === "text" && paths.has(path15.text)) {
|
|
13420
13449
|
methods.add(sink.method);
|
|
13421
13450
|
}
|
|
13422
13451
|
}
|
|
@@ -15551,14 +15580,14 @@ function readArrayLiteralText(node) {
|
|
|
15551
15580
|
}
|
|
15552
15581
|
|
|
15553
15582
|
// src/summaryIdentity.ts
|
|
15554
|
-
import
|
|
15583
|
+
import path9 from "path";
|
|
15555
15584
|
import {
|
|
15556
15585
|
disambiguateSummaryIds,
|
|
15557
15586
|
linkCallsToSummaries,
|
|
15558
15587
|
summaryIdFromParts
|
|
15559
15588
|
} from "@suss/behavioral-ir";
|
|
15560
15589
|
function workspaceRootFor(anchor) {
|
|
15561
|
-
return namedPackageDirAbove(anchor) ??
|
|
15590
|
+
return namedPackageDirAbove(anchor) ?? path9.resolve(anchor);
|
|
15562
15591
|
}
|
|
15563
15592
|
function workspaceNameFor(root) {
|
|
15564
15593
|
if (root === void 0) {
|
|
@@ -15568,7 +15597,7 @@ function workspaceNameFor(root) {
|
|
|
15568
15597
|
if (dir !== null) {
|
|
15569
15598
|
return packageNameAt(dir);
|
|
15570
15599
|
}
|
|
15571
|
-
const folder =
|
|
15600
|
+
const folder = path9.basename(path9.resolve(root));
|
|
15572
15601
|
return folder.length > 0 ? folder : null;
|
|
15573
15602
|
}
|
|
15574
15603
|
function nameSummaries(summaries, args) {
|
|
@@ -15583,10 +15612,10 @@ function nameSummaries(summaries, args) {
|
|
|
15583
15612
|
linkCallsToSummaries(summaries);
|
|
15584
15613
|
}
|
|
15585
15614
|
function relativeFile(file, projectRoot) {
|
|
15586
|
-
if (projectRoot === void 0 || !
|
|
15615
|
+
if (projectRoot === void 0 || !path9.isAbsolute(file)) {
|
|
15587
15616
|
return file;
|
|
15588
15617
|
}
|
|
15589
|
-
const relative =
|
|
15618
|
+
const relative = path9.relative(projectRoot, file);
|
|
15590
15619
|
return relative.startsWith("..") ? file : relative;
|
|
15591
15620
|
}
|
|
15592
15621
|
function idFor(workspace, file, summary) {
|
|
@@ -15621,11 +15650,11 @@ function declineWhenRunFromSource(cacheDir) {
|
|
|
15621
15650
|
}
|
|
15622
15651
|
|
|
15623
15652
|
// src/workspacePatterns.ts
|
|
15624
|
-
import
|
|
15625
|
-
import
|
|
15653
|
+
import fs5 from "fs";
|
|
15654
|
+
import path10 from "path";
|
|
15626
15655
|
function readJson(filePath) {
|
|
15627
15656
|
try {
|
|
15628
|
-
return JSON.parse(
|
|
15657
|
+
return JSON.parse(fs5.readFileSync(filePath, "utf8"));
|
|
15629
15658
|
} catch {
|
|
15630
15659
|
return void 0;
|
|
15631
15660
|
}
|
|
@@ -15652,7 +15681,7 @@ function pnpmWorkspaceGlobs(yamlText) {
|
|
|
15652
15681
|
return globs;
|
|
15653
15682
|
}
|
|
15654
15683
|
function workspaceGlobsAt(dir) {
|
|
15655
|
-
const pkg = readJson(
|
|
15684
|
+
const pkg = readJson(path10.join(dir, "package.json"));
|
|
15656
15685
|
if (typeof pkg === "object" && pkg !== null && "workspaces" in pkg) {
|
|
15657
15686
|
const ws = pkg.workspaces;
|
|
15658
15687
|
if (Array.isArray(ws)) {
|
|
@@ -15664,10 +15693,10 @@ function workspaceGlobsAt(dir) {
|
|
|
15664
15693
|
);
|
|
15665
15694
|
}
|
|
15666
15695
|
}
|
|
15667
|
-
const pnpmPath =
|
|
15668
|
-
if (
|
|
15696
|
+
const pnpmPath = path10.join(dir, "pnpm-workspace.yaml");
|
|
15697
|
+
if (fs5.existsSync(pnpmPath)) {
|
|
15669
15698
|
try {
|
|
15670
|
-
return pnpmWorkspaceGlobs(
|
|
15699
|
+
return pnpmWorkspaceGlobs(fs5.readFileSync(pnpmPath, "utf8"));
|
|
15671
15700
|
} catch {
|
|
15672
15701
|
return null;
|
|
15673
15702
|
}
|
|
@@ -15676,14 +15705,14 @@ function workspaceGlobsAt(dir) {
|
|
|
15676
15705
|
}
|
|
15677
15706
|
function isDirectory(candidate) {
|
|
15678
15707
|
try {
|
|
15679
|
-
return
|
|
15708
|
+
return fs5.statSync(candidate).isDirectory();
|
|
15680
15709
|
} catch {
|
|
15681
15710
|
return false;
|
|
15682
15711
|
}
|
|
15683
15712
|
}
|
|
15684
15713
|
function subdirectoriesOf(dir) {
|
|
15685
15714
|
try {
|
|
15686
|
-
return
|
|
15715
|
+
return fs5.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).filter((name) => !name.startsWith(".") && name !== "node_modules");
|
|
15687
15716
|
} catch {
|
|
15688
15717
|
return [];
|
|
15689
15718
|
}
|
|
@@ -15701,13 +15730,13 @@ function directoriesMatchingGlob(root, glob) {
|
|
|
15701
15730
|
for (const dir of current2) {
|
|
15702
15731
|
for (const entry of subdirectoriesOf(dir)) {
|
|
15703
15732
|
if (pattern.test(entry)) {
|
|
15704
|
-
next.push(
|
|
15733
|
+
next.push(path10.join(dir, entry));
|
|
15705
15734
|
}
|
|
15706
15735
|
}
|
|
15707
15736
|
}
|
|
15708
15737
|
} else {
|
|
15709
15738
|
for (const dir of current2) {
|
|
15710
|
-
next.push(
|
|
15739
|
+
next.push(path10.join(dir, segment));
|
|
15711
15740
|
}
|
|
15712
15741
|
}
|
|
15713
15742
|
current2 = next.filter(isDirectory);
|
|
@@ -15715,7 +15744,7 @@ function directoriesMatchingGlob(root, glob) {
|
|
|
15715
15744
|
return current2;
|
|
15716
15745
|
}
|
|
15717
15746
|
function packageAt(dir) {
|
|
15718
|
-
const packageJsonPath =
|
|
15747
|
+
const packageJsonPath = path10.join(dir, "package.json");
|
|
15719
15748
|
const pkg = readJson(packageJsonPath);
|
|
15720
15749
|
if (typeof pkg === "object" && pkg !== null && typeof pkg.name === "string") {
|
|
15721
15750
|
return { name: pkg.name, packageJsonPath };
|
|
@@ -15723,7 +15752,7 @@ function packageAt(dir) {
|
|
|
15723
15752
|
return null;
|
|
15724
15753
|
}
|
|
15725
15754
|
function workspacePackagesFrom(anchor) {
|
|
15726
|
-
let dir =
|
|
15755
|
+
let dir = path10.resolve(anchor);
|
|
15727
15756
|
for (; ; ) {
|
|
15728
15757
|
const globs = workspaceGlobsAt(dir);
|
|
15729
15758
|
if (globs !== null) {
|
|
@@ -15743,7 +15772,7 @@ function workspacePackagesFrom(anchor) {
|
|
|
15743
15772
|
(a, b) => a.packageJsonPath.localeCompare(b.packageJsonPath)
|
|
15744
15773
|
);
|
|
15745
15774
|
}
|
|
15746
|
-
const parent =
|
|
15775
|
+
const parent = path10.dirname(dir);
|
|
15747
15776
|
if (parent === dir) {
|
|
15748
15777
|
return [];
|
|
15749
15778
|
}
|
|
@@ -16285,11 +16314,11 @@ function extractConsumerBinding(unit, pattern, pack, resolution) {
|
|
|
16285
16314
|
return null;
|
|
16286
16315
|
}
|
|
16287
16316
|
const method = extractBindingMethod(binding, callSite, pack, resolution);
|
|
16288
|
-
const
|
|
16317
|
+
const path15 = extractBindingPath(binding, callSite, pack, resolution);
|
|
16289
16318
|
return restBinding2({
|
|
16290
16319
|
transport: pack.protocol,
|
|
16291
16320
|
method: method ?? null,
|
|
16292
|
-
path:
|
|
16321
|
+
path: path15 ?? null,
|
|
16293
16322
|
recognition: pack.name
|
|
16294
16323
|
});
|
|
16295
16324
|
}
|
|
@@ -16498,9 +16527,6 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16498
16527
|
const claimKey = unitDedupKey(unit);
|
|
16499
16528
|
const claimant = claimed.get(claimKey);
|
|
16500
16529
|
if (claimant !== void 0) {
|
|
16501
|
-
if (claimant.pack === pack.name && claimant.file === sourceFile.getFilePath() && tally !== void 0) {
|
|
16502
|
-
tally.selfCollisions += 1;
|
|
16503
|
-
}
|
|
16504
16530
|
if (claimant.file !== sourceFile.getFilePath()) {
|
|
16505
16531
|
recordFileDependency(claimant.file);
|
|
16506
16532
|
}
|
|
@@ -16936,8 +16962,8 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16936
16962
|
if (pathArg === void 0) {
|
|
16937
16963
|
continue;
|
|
16938
16964
|
}
|
|
16939
|
-
const
|
|
16940
|
-
if (
|
|
16965
|
+
const path15 = pathFromArgument(pathArg, resolution);
|
|
16966
|
+
if (path15 === void 0) {
|
|
16941
16967
|
continue;
|
|
16942
16968
|
}
|
|
16943
16969
|
const callerFunc = enclosingFunction(callExpr);
|
|
@@ -16949,7 +16975,7 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16949
16975
|
continue;
|
|
16950
16976
|
}
|
|
16951
16977
|
seen.add(dedupKey);
|
|
16952
|
-
out.push(buildCallerSummary(wrapper, callerFunc, callExpr,
|
|
16978
|
+
out.push(buildCallerSummary(wrapper, callerFunc, callExpr, path15, options));
|
|
16953
16979
|
}
|
|
16954
16980
|
return out;
|
|
16955
16981
|
}
|
|
@@ -17006,7 +17032,7 @@ function callerName(func) {
|
|
|
17006
17032
|
}
|
|
17007
17033
|
return "anonymous";
|
|
17008
17034
|
}
|
|
17009
|
-
function buildCallerSummary(wrapper, callerFunc, callExpr,
|
|
17035
|
+
function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
17010
17036
|
const wrapperBinding = wrapper.summary.identity.boundaryBinding;
|
|
17011
17037
|
const wrapperRest = wrapperBinding?.semantics.name === "rest" ? wrapperBinding.semantics : null;
|
|
17012
17038
|
const syntheticPack = {
|
|
@@ -17038,7 +17064,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path14, options) {
|
|
|
17038
17064
|
raw.boundaryBinding = restBinding2({
|
|
17039
17065
|
transport: wrapperBinding?.transport ?? "http",
|
|
17040
17066
|
method: wrapperRest?.method ?? null,
|
|
17041
|
-
path:
|
|
17067
|
+
path: path15,
|
|
17042
17068
|
recognition: wrapperBinding?.recognition ?? "unknown"
|
|
17043
17069
|
});
|
|
17044
17070
|
const summary = assembleSummary3(raw, options);
|
|
@@ -17096,7 +17122,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17096
17122
|
...suppliedConfig,
|
|
17097
17123
|
frameworks: expandWorkspacePatterns(
|
|
17098
17124
|
suppliedConfig.frameworks,
|
|
17099
|
-
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ?
|
|
17125
|
+
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ? path11.dirname(suppliedConfig.tsConfigFilePath) : void 0)
|
|
17100
17126
|
)
|
|
17101
17127
|
};
|
|
17102
17128
|
const project = config.project ?? new Project(
|
|
@@ -17105,11 +17131,11 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17105
17131
|
skipAddingFilesFromTsConfig: true
|
|
17106
17132
|
} : { skipAddingFilesFromTsConfig: true }
|
|
17107
17133
|
);
|
|
17108
|
-
const runRoot = config.projectRoot ?? (config.tsConfigFilePath !== void 0 ? workspaceRootFor(
|
|
17134
|
+
const runRoot = config.projectRoot ?? (config.tsConfigFilePath !== void 0 ? workspaceRootFor(path11.dirname(config.tsConfigFilePath)) : void 0);
|
|
17109
17135
|
let lazyBootstrapped = false;
|
|
17110
17136
|
let projectFileSet;
|
|
17111
17137
|
const cacheDir = declineWhenRunFromSource(
|
|
17112
|
-
config.cacheDir === null ? null : config.cacheDir ?? (config.tsConfigFilePath !== void 0 ?
|
|
17138
|
+
config.cacheDir === null ? null : config.cacheDir ?? (config.tsConfigFilePath !== void 0 ? path11.join(path11.dirname(config.tsConfigFilePath), ".suss", "cache") : null)
|
|
17113
17139
|
);
|
|
17114
17140
|
const cache = createCacheLayer(cacheDir);
|
|
17115
17141
|
const packsDigest = `${computeAdapterPacksDigest(
|
|
@@ -17813,8 +17839,8 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17813
17839
|
}
|
|
17814
17840
|
|
|
17815
17841
|
// src/bootstrap/noTsconfigProject.ts
|
|
17816
|
-
import
|
|
17817
|
-
import
|
|
17842
|
+
import fs6 from "fs";
|
|
17843
|
+
import path12 from "path";
|
|
17818
17844
|
import {
|
|
17819
17845
|
ModuleKind,
|
|
17820
17846
|
ModuleResolutionKind,
|
|
@@ -17850,7 +17876,7 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17850
17876
|
const found = [];
|
|
17851
17877
|
let entries;
|
|
17852
17878
|
try {
|
|
17853
|
-
entries =
|
|
17879
|
+
entries = fs6.readdirSync(rootDir, { withFileTypes: true });
|
|
17854
17880
|
} catch {
|
|
17855
17881
|
return [];
|
|
17856
17882
|
}
|
|
@@ -17858,10 +17884,10 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17858
17884
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name)) {
|
|
17859
17885
|
continue;
|
|
17860
17886
|
}
|
|
17861
|
-
const full =
|
|
17887
|
+
const full = path12.join(rootDir, entry.name);
|
|
17862
17888
|
if (entry.isDirectory()) {
|
|
17863
17889
|
found.push(...findSourceFiles(full, depth + 1));
|
|
17864
|
-
} else if (SOURCE_EXTENSIONS.has(
|
|
17890
|
+
} else if (SOURCE_EXTENSIONS.has(path12.extname(entry.name)) && !entry.name.endsWith(".d.ts")) {
|
|
17865
17891
|
found.push(full);
|
|
17866
17892
|
}
|
|
17867
17893
|
}
|
|
@@ -17896,15 +17922,15 @@ function createProjectWithoutTsconfig(rootDir) {
|
|
|
17896
17922
|
return { project, files };
|
|
17897
17923
|
}
|
|
17898
17924
|
function findNearestTsconfig(startDir) {
|
|
17899
|
-
let dir =
|
|
17925
|
+
let dir = path12.resolve(startDir);
|
|
17900
17926
|
while (true) {
|
|
17901
17927
|
for (const name of ["tsconfig.json", "jsconfig.json"]) {
|
|
17902
|
-
const candidate =
|
|
17903
|
-
if (
|
|
17928
|
+
const candidate = path12.join(dir, name);
|
|
17929
|
+
if (fs6.existsSync(candidate)) {
|
|
17904
17930
|
return candidate;
|
|
17905
17931
|
}
|
|
17906
17932
|
}
|
|
17907
|
-
const parent =
|
|
17933
|
+
const parent = path12.dirname(dir);
|
|
17908
17934
|
if (parent === dir) {
|
|
17909
17935
|
return null;
|
|
17910
17936
|
}
|
|
@@ -17913,7 +17939,7 @@ function findNearestTsconfig(startDir) {
|
|
|
17913
17939
|
}
|
|
17914
17940
|
|
|
17915
17941
|
// src/facts/why.ts
|
|
17916
|
-
import
|
|
17942
|
+
import path13 from "path";
|
|
17917
17943
|
import { Node as Node65, Project as Project3, SyntaxKind as SyntaxKind13 } from "ts-morph";
|
|
17918
17944
|
import { explainResolutionProof, renderExplanation } from "@suss/resolution";
|
|
17919
17945
|
var JS_PHRASES = {
|
|
@@ -17926,7 +17952,7 @@ var TypeScriptWhySession = class {
|
|
|
17926
17952
|
store;
|
|
17927
17953
|
root;
|
|
17928
17954
|
constructor(options) {
|
|
17929
|
-
this.root =
|
|
17955
|
+
this.root = path13.resolve(options.dir);
|
|
17930
17956
|
const tsconfig = findNearestTsconfig(this.root);
|
|
17931
17957
|
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new Project3({ tsConfigFilePath: tsconfig });
|
|
17932
17958
|
this.store = new ResolutionStore();
|
|
@@ -18015,7 +18041,7 @@ var TypeScriptWhySession = class {
|
|
|
18015
18041
|
};
|
|
18016
18042
|
}
|
|
18017
18043
|
sourceFileAt(file) {
|
|
18018
|
-
const absolute =
|
|
18044
|
+
const absolute = path13.resolve(this.root, file);
|
|
18019
18045
|
const loaded = this.project.getSourceFile(absolute);
|
|
18020
18046
|
if (loaded !== void 0) {
|
|
18021
18047
|
return loaded;
|
|
@@ -18029,7 +18055,7 @@ var TypeScriptWhySession = class {
|
|
|
18029
18055
|
/** A module key: a file path said relative to the root, or a package name. */
|
|
18030
18056
|
displayPath(key) {
|
|
18031
18057
|
if (key.startsWith(this.root)) {
|
|
18032
|
-
return
|
|
18058
|
+
return path13.relative(this.root, key);
|
|
18033
18059
|
}
|
|
18034
18060
|
return key;
|
|
18035
18061
|
}
|
|
@@ -18058,7 +18084,7 @@ function displayNameOf(node) {
|
|
|
18058
18084
|
}
|
|
18059
18085
|
|
|
18060
18086
|
// src/stubEvidence.ts
|
|
18061
|
-
import
|
|
18087
|
+
import path14 from "path";
|
|
18062
18088
|
import { Project as Project4 } from "ts-morph";
|
|
18063
18089
|
function stubEvidenceIn(project, packageName, root) {
|
|
18064
18090
|
const resolution = new ResolutionStore();
|
|
@@ -18074,7 +18100,7 @@ function stubEvidenceIn(project, packageName, root) {
|
|
|
18074
18100
|
calls: []
|
|
18075
18101
|
};
|
|
18076
18102
|
entry.calls.push({
|
|
18077
|
-
file:
|
|
18103
|
+
file: path14.relative(root, sourceFile.getFilePath()).split(path14.sep).join("/"),
|
|
18078
18104
|
line: one.call.getStartLineNumber(),
|
|
18079
18105
|
args: one.call.getArguments().map((arg) => effectArgOf(arg))
|
|
18080
18106
|
});
|
|
@@ -18089,7 +18115,7 @@ function stubEvidence(options) {
|
|
|
18089
18115
|
const project = new Project4(
|
|
18090
18116
|
options.tsConfigFilePath !== void 0 ? { tsConfigFilePath: options.tsConfigFilePath } : { compilerOptions: { allowJs: true } }
|
|
18091
18117
|
);
|
|
18092
|
-
const root = options.tsConfigFilePath !== void 0 ?
|
|
18118
|
+
const root = options.tsConfigFilePath !== void 0 ? path14.dirname(options.tsConfigFilePath) : path14.resolve(options.directory ?? process.cwd());
|
|
18093
18119
|
if (options.tsConfigFilePath === void 0) {
|
|
18094
18120
|
project.addSourceFilesAtPaths([
|
|
18095
18121
|
`${root}/**/*.{ts,tsx,js,jsx}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/adapter-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Read a TypeScript or JavaScript codebase with suss and check what each handler returns against every caller, spec and template it can see.",
|
|
6
6
|
"keywords": [
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@suss/behavioral-ir": "0.
|
|
52
|
-
"@suss/datalog": "0.
|
|
53
|
-
"@suss/extractor": "0.
|
|
54
|
-
"@suss/resolution": "0.
|
|
55
|
-
"@suss/values": "0.
|
|
51
|
+
"@suss/behavioral-ir": "0.25.0",
|
|
52
|
+
"@suss/datalog": "0.25.0",
|
|
53
|
+
"@suss/extractor": "0.25.0",
|
|
54
|
+
"@suss/resolution": "0.25.0",
|
|
55
|
+
"@suss/values": "0.25.0",
|
|
56
56
|
"graphql": "^16.8.0",
|
|
57
57
|
"picomatch": "^4.0.4",
|
|
58
58
|
"ts-morph": "^23.0.0",
|