@suss/adapter-typescript 0.22.0 → 0.22.2
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 +874 -478
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +872 -461
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -75,7 +75,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
75
75
|
// src/adapter.ts
|
|
76
76
|
var import_node_path10 = __toESM(require("path"), 1);
|
|
77
77
|
var import_ts_morph66 = require("ts-morph");
|
|
78
|
-
var
|
|
78
|
+
var import_behavioral_ir8 = require("@suss/behavioral-ir");
|
|
79
79
|
var import_datalog6 = require("@suss/datalog");
|
|
80
80
|
var import_extractor11 = require("@suss/extractor");
|
|
81
81
|
|
|
@@ -712,14 +712,14 @@ function parseConditionExpression(expr, depth = 0) {
|
|
|
712
712
|
if (expr.getOperatorToken() !== import_ts_morph5.SyntaxKind.ExclamationToken) {
|
|
713
713
|
return null;
|
|
714
714
|
}
|
|
715
|
-
const
|
|
716
|
-
const inner = parseConditionExpression(
|
|
715
|
+
const operand2 = expr.getOperand();
|
|
716
|
+
const inner = parseConditionExpression(operand2, depth);
|
|
717
717
|
if (inner === null) {
|
|
718
718
|
return {
|
|
719
719
|
type: "negation",
|
|
720
720
|
operand: {
|
|
721
721
|
type: "opaque",
|
|
722
|
-
sourceText:
|
|
722
|
+
sourceText: operand2.getText(),
|
|
723
723
|
reason: "complexExpression"
|
|
724
724
|
}
|
|
725
725
|
};
|
|
@@ -783,8 +783,8 @@ function parseConditionExpression(expr, depth = 0) {
|
|
|
783
783
|
const rightIsNull = isNullOrUndefined(right);
|
|
784
784
|
if (leftIsNull || rightIsNull) {
|
|
785
785
|
const subject = resolveSubject(leftIsNull ? right : left);
|
|
786
|
-
const
|
|
787
|
-
return { type: "nullCheck", subject, negated };
|
|
786
|
+
const negated2 = op === "neq";
|
|
787
|
+
return { type: "nullCheck", subject, negated: negated2 };
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
790
|
if (import_ts_morph5.Node.isTypeOfExpression(left) && import_ts_morph5.Node.isStringLiteral(right) && (opText === "===" || opText === "==")) {
|
|
@@ -2599,7 +2599,7 @@ function isNotYetPlaceholder(value) {
|
|
|
2599
2599
|
return value.getKind() === import_ts_morph14.SyntaxKind.NullKeyword || import_ts_morph14.Node.isIdentifier(value) && value.getText() === "undefined";
|
|
2600
2600
|
}
|
|
2601
2601
|
function isConstruction(value) {
|
|
2602
|
-
return import_ts_morph14.Node.isCallExpression(value) || import_ts_morph14.Node.isNewExpression(value);
|
|
2602
|
+
return import_ts_morph14.Node.isCallExpression(value) || import_ts_morph14.Node.isNewExpression(value) || import_ts_morph14.Node.isObjectLiteralExpression(value) || import_ts_morph14.Node.isArrayLiteralExpression(value);
|
|
2603
2603
|
}
|
|
2604
2604
|
function sourceOf(node) {
|
|
2605
2605
|
return node.getText().replace(/\s+/g, " ").trim();
|
|
@@ -3070,10 +3070,10 @@ function emitValue(db, table, value) {
|
|
|
3070
3070
|
}
|
|
3071
3071
|
return id;
|
|
3072
3072
|
}
|
|
3073
|
-
const
|
|
3074
|
-
if (
|
|
3075
|
-
fact(db, "fallbackBranch", id, emitValue(db, table,
|
|
3076
|
-
fact(db, "fallbackBranch", id, emitValue(db, table,
|
|
3073
|
+
const fallback2 = asFallbackExpression(expression);
|
|
3074
|
+
if (fallback2 !== null) {
|
|
3075
|
+
fact(db, "fallbackBranch", id, emitValue(db, table, fallback2.getLeft()));
|
|
3076
|
+
fact(db, "fallbackBranch", id, emitValue(db, table, fallback2.getRight()));
|
|
3077
3077
|
return id;
|
|
3078
3078
|
}
|
|
3079
3079
|
if (import_ts_morph15.Node.isCallExpression(expression) || import_ts_morph15.Node.isNewExpression(expression)) {
|
|
@@ -3161,9 +3161,9 @@ function emitBindingElementFacts(db, table, element) {
|
|
|
3161
3161
|
property.getText()
|
|
3162
3162
|
);
|
|
3163
3163
|
}
|
|
3164
|
-
const
|
|
3165
|
-
if (
|
|
3166
|
-
fact(db, "binds", id, emitValue(db, table,
|
|
3164
|
+
const fallback2 = element.getInitializer();
|
|
3165
|
+
if (fallback2 !== void 0) {
|
|
3166
|
+
fact(db, "binds", id, emitValue(db, table, fallback2));
|
|
3167
3167
|
}
|
|
3168
3168
|
return id;
|
|
3169
3169
|
}
|
|
@@ -4368,7 +4368,7 @@ function declarationOf(value) {
|
|
|
4368
4368
|
}
|
|
4369
4369
|
|
|
4370
4370
|
// src/discovery/clientCall.ts
|
|
4371
|
-
var
|
|
4371
|
+
var import_ts_morph20 = require("ts-morph");
|
|
4372
4372
|
|
|
4373
4373
|
// src/discovery/importScan.ts
|
|
4374
4374
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -4392,8 +4392,8 @@ function commonDirectoryOf(files) {
|
|
|
4392
4392
|
}
|
|
4393
4393
|
shared = shared.slice(0, i);
|
|
4394
4394
|
}
|
|
4395
|
-
const
|
|
4396
|
-
return
|
|
4395
|
+
const joined2 = shared.join(import_node_path2.default.sep);
|
|
4396
|
+
return joined2.length > 1 ? joined2 : void 0;
|
|
4397
4397
|
}
|
|
4398
4398
|
var DEFAULT_RESOLUTION = {
|
|
4399
4399
|
moduleResolution: import_ts_morph17.ts.ModuleResolutionKind.Bundler,
|
|
@@ -4660,15 +4660,594 @@ function resolveImportedLocalName(sourceFile, importModule, importName) {
|
|
|
4660
4660
|
}
|
|
4661
4661
|
|
|
4662
4662
|
// src/discovery/resolveValue.ts
|
|
4663
|
+
var import_ts_morph19 = require("ts-morph");
|
|
4664
|
+
var import_values3 = require("@suss/values");
|
|
4665
|
+
|
|
4666
|
+
// src/values/evaluator.ts
|
|
4667
|
+
var import_values2 = require("@suss/values");
|
|
4668
|
+
|
|
4669
|
+
// src/values/lowering.ts
|
|
4663
4670
|
var import_ts_morph18 = require("ts-morph");
|
|
4671
|
+
var ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set([
|
|
4672
|
+
"=",
|
|
4673
|
+
"+=",
|
|
4674
|
+
"-=",
|
|
4675
|
+
"*=",
|
|
4676
|
+
"/=",
|
|
4677
|
+
"??=",
|
|
4678
|
+
"||=",
|
|
4679
|
+
"&&="
|
|
4680
|
+
]);
|
|
4681
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
4682
|
+
"push",
|
|
4683
|
+
"pop",
|
|
4684
|
+
"shift",
|
|
4685
|
+
"unshift",
|
|
4686
|
+
"splice",
|
|
4687
|
+
"sort",
|
|
4688
|
+
"reverse",
|
|
4689
|
+
"fill",
|
|
4690
|
+
"copyWithin"
|
|
4691
|
+
]);
|
|
4692
|
+
function typescriptLowering(options) {
|
|
4693
|
+
const { resolution, rows } = options;
|
|
4694
|
+
const rowModules = [
|
|
4695
|
+
...new Set(
|
|
4696
|
+
rows.flatMap((row) => row.kind === "callee" ? [row.origin.module] : [])
|
|
4697
|
+
)
|
|
4698
|
+
];
|
|
4699
|
+
const mutatedByRoot = /* @__PURE__ */ new Map();
|
|
4700
|
+
const originOf = (callee) => {
|
|
4701
|
+
const chain = memberChainOf(callee);
|
|
4702
|
+
if (chain === null) {
|
|
4703
|
+
return null;
|
|
4704
|
+
}
|
|
4705
|
+
const name = chain.names[chain.names.length - 1] ?? null;
|
|
4706
|
+
if (name === null) {
|
|
4707
|
+
return null;
|
|
4708
|
+
}
|
|
4709
|
+
const origins = resolution?.importOriginsOf(chain.root, rowModules) ?? [];
|
|
4710
|
+
const first = origins[0];
|
|
4711
|
+
if (first !== void 0) {
|
|
4712
|
+
return { module: first.module, name };
|
|
4713
|
+
}
|
|
4714
|
+
const local = resolution !== void 0 && resolution.resolveCallable(callee) !== null;
|
|
4715
|
+
if (chain.names.length > 1 || local) {
|
|
4716
|
+
return null;
|
|
4717
|
+
}
|
|
4718
|
+
return { module: "global", name };
|
|
4719
|
+
};
|
|
4720
|
+
return {
|
|
4721
|
+
expression: (node) => expressionOf(peelValue(node), originOf),
|
|
4722
|
+
statement: statementOf2,
|
|
4723
|
+
siteOf,
|
|
4724
|
+
functionOf,
|
|
4725
|
+
writtenTo: (node) => {
|
|
4726
|
+
if (resolution === void 0) {
|
|
4727
|
+
return null;
|
|
4728
|
+
}
|
|
4729
|
+
const target = peelValue(node);
|
|
4730
|
+
return resolution.resolveWrittenValue(target) ?? resolution.resolveObject(target);
|
|
4731
|
+
},
|
|
4732
|
+
callable: (node) => {
|
|
4733
|
+
const call = peelValue(node);
|
|
4734
|
+
if (resolution === void 0 || !import_ts_morph18.Node.isCallExpression(call) && !import_ts_morph18.Node.isNewExpression(call)) {
|
|
4735
|
+
return null;
|
|
4736
|
+
}
|
|
4737
|
+
const target = resolution.resolveCallable(call.getExpression());
|
|
4738
|
+
return target !== null && import_ts_morph18.Node.isFunctionLikeDeclaration(target) ? target : null;
|
|
4739
|
+
},
|
|
4740
|
+
mutatedInNestedFunction: (root, name) => {
|
|
4741
|
+
let mutated = mutatedByRoot.get(root);
|
|
4742
|
+
if (mutated === void 0) {
|
|
4743
|
+
mutated = namesMutatedInNestedFunctions(root);
|
|
4744
|
+
mutatedByRoot.set(root, mutated);
|
|
4745
|
+
}
|
|
4746
|
+
return mutated.has(name);
|
|
4747
|
+
},
|
|
4748
|
+
freeNamesOf,
|
|
4749
|
+
holeNameOf: placeholderName,
|
|
4750
|
+
rows
|
|
4751
|
+
};
|
|
4752
|
+
}
|
|
4753
|
+
function placeholderName(expr) {
|
|
4754
|
+
if (import_ts_morph18.Node.isIdentifier(expr)) {
|
|
4755
|
+
return expr.getText();
|
|
4756
|
+
}
|
|
4757
|
+
if (import_ts_morph18.Node.isPropertyAccessExpression(expr)) {
|
|
4758
|
+
return expr.getName();
|
|
4759
|
+
}
|
|
4760
|
+
return "param";
|
|
4761
|
+
}
|
|
4762
|
+
function expressionOf(node, originOf) {
|
|
4763
|
+
if (import_ts_morph18.Node.isStringLiteral(node) || import_ts_morph18.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
4764
|
+
return { kind: "literal", value: node.getLiteralValue() };
|
|
4765
|
+
}
|
|
4766
|
+
if (import_ts_morph18.Node.isNumericLiteral(node)) {
|
|
4767
|
+
return { kind: "literal", value: node.getLiteralValue() };
|
|
4768
|
+
}
|
|
4769
|
+
if (import_ts_morph18.Node.isTrueLiteral(node)) {
|
|
4770
|
+
return { kind: "literal", value: true };
|
|
4771
|
+
}
|
|
4772
|
+
if (import_ts_morph18.Node.isFalseLiteral(node)) {
|
|
4773
|
+
return { kind: "literal", value: false };
|
|
4774
|
+
}
|
|
4775
|
+
if (import_ts_morph18.Node.isNullLiteral(node)) {
|
|
4776
|
+
return { kind: "literal", value: null };
|
|
4777
|
+
}
|
|
4778
|
+
if (import_ts_morph18.Node.isIdentifier(node)) {
|
|
4779
|
+
return node.getText() === "undefined" ? { kind: "literal", value: void 0 } : { kind: "name", text: node.getText() };
|
|
4780
|
+
}
|
|
4781
|
+
if (import_ts_morph18.Node.isTemplateExpression(node)) {
|
|
4782
|
+
return {
|
|
4783
|
+
kind: "template",
|
|
4784
|
+
parts: [
|
|
4785
|
+
{ text: node.getHead().getLiteralText() },
|
|
4786
|
+
...node.getTemplateSpans().flatMap((span) => [
|
|
4787
|
+
{ expression: span.getExpression() },
|
|
4788
|
+
{ text: span.getLiteral().getLiteralText() }
|
|
4789
|
+
])
|
|
4790
|
+
]
|
|
4791
|
+
};
|
|
4792
|
+
}
|
|
4793
|
+
if (import_ts_morph18.Node.isPropertyAccessExpression(node)) {
|
|
4794
|
+
return {
|
|
4795
|
+
kind: "member",
|
|
4796
|
+
object: node.getExpression(),
|
|
4797
|
+
name: node.getName()
|
|
4798
|
+
};
|
|
4799
|
+
}
|
|
4800
|
+
if (import_ts_morph18.Node.isElementAccessExpression(node)) {
|
|
4801
|
+
const index = node.getArgumentExpression();
|
|
4802
|
+
return index === void 0 ? { kind: "opaque" } : { kind: "element", object: node.getExpression(), index };
|
|
4803
|
+
}
|
|
4804
|
+
if (import_ts_morph18.Node.isArrayLiteralExpression(node)) {
|
|
4805
|
+
return { kind: "array", items: node.getElements().map(elementOf) };
|
|
4806
|
+
}
|
|
4807
|
+
if (import_ts_morph18.Node.isObjectLiteralExpression(node)) {
|
|
4808
|
+
return { kind: "record", fields: node.getProperties().flatMap(fieldOf) };
|
|
4809
|
+
}
|
|
4810
|
+
if (import_ts_morph18.Node.isCallExpression(node) || import_ts_morph18.Node.isNewExpression(node)) {
|
|
4811
|
+
return {
|
|
4812
|
+
kind: "call",
|
|
4813
|
+
callee: calleeOf(node.getExpression(), originOf),
|
|
4814
|
+
args: node.getArguments().map(elementOf),
|
|
4815
|
+
constructs: import_ts_morph18.Node.isNewExpression(node)
|
|
4816
|
+
};
|
|
4817
|
+
}
|
|
4818
|
+
if (import_ts_morph18.Node.isBinaryExpression(node)) {
|
|
4819
|
+
const operator = node.getOperatorToken().getText();
|
|
4820
|
+
return ASSIGNMENT_OPERATORS.has(operator) ? { kind: "opaque" } : {
|
|
4821
|
+
kind: "operator",
|
|
4822
|
+
operator,
|
|
4823
|
+
operands: [node.getLeft(), node.getRight()]
|
|
4824
|
+
};
|
|
4825
|
+
}
|
|
4826
|
+
if (import_ts_morph18.Node.isPrefixUnaryExpression(node)) {
|
|
4827
|
+
const operator = node.getOperatorToken();
|
|
4828
|
+
return operator === import_ts_morph18.SyntaxKind.ExclamationToken ? { kind: "operator", operator: "!", operands: [node.getOperand()] } : { kind: "opaque" };
|
|
4829
|
+
}
|
|
4830
|
+
if (import_ts_morph18.Node.isConditionalExpression(node)) {
|
|
4831
|
+
return {
|
|
4832
|
+
kind: "conditional",
|
|
4833
|
+
condition: node.getCondition(),
|
|
4834
|
+
whenTrue: node.getWhenTrue(),
|
|
4835
|
+
whenFalse: node.getWhenFalse()
|
|
4836
|
+
};
|
|
4837
|
+
}
|
|
4838
|
+
if (import_ts_morph18.Node.isArrowFunction(node) || import_ts_morph18.Node.isFunctionExpression(node)) {
|
|
4839
|
+
return { kind: "function", node };
|
|
4840
|
+
}
|
|
4841
|
+
return { kind: "opaque" };
|
|
4842
|
+
}
|
|
4843
|
+
function elementOf(node) {
|
|
4844
|
+
return import_ts_morph18.Node.isSpreadElement(node) ? { kind: "spread", node: node.getExpression() } : { kind: "value", node };
|
|
4845
|
+
}
|
|
4846
|
+
function fieldOf(property) {
|
|
4847
|
+
if (import_ts_morph18.Node.isSpreadAssignment(property)) {
|
|
4848
|
+
return [{ kind: "spread", node: property.getExpression() }];
|
|
4849
|
+
}
|
|
4850
|
+
if (import_ts_morph18.Node.isShorthandPropertyAssignment(property)) {
|
|
4851
|
+
const nameNode2 = property.getNameNode();
|
|
4852
|
+
return [{ kind: "field", name: nameNode2.getText(), value: nameNode2 }];
|
|
4853
|
+
}
|
|
4854
|
+
if (!import_ts_morph18.Node.isPropertyAssignment(property)) {
|
|
4855
|
+
return [];
|
|
4856
|
+
}
|
|
4857
|
+
const value = property.getInitializer();
|
|
4858
|
+
if (value === void 0) {
|
|
4859
|
+
return [];
|
|
4860
|
+
}
|
|
4861
|
+
const nameNode = property.getNameNode();
|
|
4862
|
+
if (import_ts_morph18.Node.isComputedPropertyName(nameNode)) {
|
|
4863
|
+
return [{ kind: "computed", name: nameNode.getExpression(), value }];
|
|
4864
|
+
}
|
|
4865
|
+
const name = import_ts_morph18.Node.isStringLiteral(nameNode) || import_ts_morph18.Node.isNumericLiteral(nameNode) ? String(nameNode.getLiteralValue()) : nameNode.getText();
|
|
4866
|
+
return [{ kind: "field", name, value }];
|
|
4867
|
+
}
|
|
4868
|
+
function calleeOf(expression, originOf) {
|
|
4869
|
+
const callee = peelValue(expression);
|
|
4870
|
+
if (import_ts_morph18.Node.isPropertyAccessExpression(callee)) {
|
|
4871
|
+
return {
|
|
4872
|
+
receiver: callee.getExpression(),
|
|
4873
|
+
name: callee.getName(),
|
|
4874
|
+
origin: () => originOf(callee)
|
|
4875
|
+
};
|
|
4876
|
+
}
|
|
4877
|
+
if (import_ts_morph18.Node.isIdentifier(callee)) {
|
|
4878
|
+
return {
|
|
4879
|
+
receiver: null,
|
|
4880
|
+
name: callee.getText(),
|
|
4881
|
+
origin: () => originOf(callee)
|
|
4882
|
+
};
|
|
4883
|
+
}
|
|
4884
|
+
return { receiver: null, name: null, origin: () => null };
|
|
4885
|
+
}
|
|
4886
|
+
function memberChainOf(node) {
|
|
4887
|
+
const names = [];
|
|
4888
|
+
let current2 = peelValue(node);
|
|
4889
|
+
while (import_ts_morph18.Node.isPropertyAccessExpression(current2)) {
|
|
4890
|
+
names.unshift(current2.getName());
|
|
4891
|
+
current2 = peelValue(current2.getExpression());
|
|
4892
|
+
}
|
|
4893
|
+
if (!import_ts_morph18.Node.isIdentifier(current2)) {
|
|
4894
|
+
return null;
|
|
4895
|
+
}
|
|
4896
|
+
return { root: current2, names: [current2.getText(), ...names] };
|
|
4897
|
+
}
|
|
4898
|
+
function statementOf2(node) {
|
|
4899
|
+
if (import_ts_morph18.Node.isVariableStatement(node)) {
|
|
4900
|
+
return {
|
|
4901
|
+
kind: "declare",
|
|
4902
|
+
bindings: node.getDeclarationList().getDeclarations().flatMap(
|
|
4903
|
+
(declaration) => declarationsOf2(
|
|
4904
|
+
declaration.getNameNode(),
|
|
4905
|
+
declaration.getInitializer() ?? null
|
|
4906
|
+
)
|
|
4907
|
+
)
|
|
4908
|
+
};
|
|
4909
|
+
}
|
|
4910
|
+
if (import_ts_morph18.Node.isExpressionStatement(node)) {
|
|
4911
|
+
const expression = peelValue(node.getExpression());
|
|
4912
|
+
if (import_ts_morph18.Node.isBinaryExpression(expression)) {
|
|
4913
|
+
const operator = expression.getOperatorToken().getText();
|
|
4914
|
+
if (ASSIGNMENT_OPERATORS.has(operator)) {
|
|
4915
|
+
return {
|
|
4916
|
+
kind: "assign",
|
|
4917
|
+
target: expression.getLeft(),
|
|
4918
|
+
operator: operator === "=" ? null : operator.slice(0, -1),
|
|
4919
|
+
value: expression.getRight()
|
|
4920
|
+
};
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
return { kind: "expression", value: node.getExpression() };
|
|
4924
|
+
}
|
|
4925
|
+
if (import_ts_morph18.Node.isIfStatement(node)) {
|
|
4926
|
+
const otherwise = node.getElseStatement();
|
|
4927
|
+
return {
|
|
4928
|
+
kind: "branch",
|
|
4929
|
+
condition: node.getExpression(),
|
|
4930
|
+
arms: [
|
|
4931
|
+
armOf(node.getThenStatement()),
|
|
4932
|
+
otherwise === void 0 ? [] : armOf(otherwise)
|
|
4933
|
+
]
|
|
4934
|
+
};
|
|
4935
|
+
}
|
|
4936
|
+
if (import_ts_morph18.Node.isSwitchStatement(node)) {
|
|
4937
|
+
return {
|
|
4938
|
+
kind: "branch",
|
|
4939
|
+
condition: null,
|
|
4940
|
+
arms: node.getClauses().map((clause) => clause.getStatements())
|
|
4941
|
+
};
|
|
4942
|
+
}
|
|
4943
|
+
if (import_ts_morph18.Node.isIterationStatement(node)) {
|
|
4944
|
+
return { kind: "loop", body: armOf(node.getStatement()) };
|
|
4945
|
+
}
|
|
4946
|
+
if (import_ts_morph18.Node.isReturnStatement(node)) {
|
|
4947
|
+
return { kind: "return", value: node.getExpression() ?? null };
|
|
4948
|
+
}
|
|
4949
|
+
if (import_ts_morph18.Node.isBlock(node)) {
|
|
4950
|
+
return { kind: "block", body: node.getStatements() };
|
|
4951
|
+
}
|
|
4952
|
+
if (import_ts_morph18.Node.isTryStatement(node)) {
|
|
4953
|
+
return {
|
|
4954
|
+
kind: "block",
|
|
4955
|
+
body: [
|
|
4956
|
+
...node.getTryBlock().getStatements(),
|
|
4957
|
+
...node.getFinallyBlock()?.getStatements() ?? []
|
|
4958
|
+
]
|
|
4959
|
+
};
|
|
4960
|
+
}
|
|
4961
|
+
return { kind: "opaque" };
|
|
4962
|
+
}
|
|
4963
|
+
function armOf(statement) {
|
|
4964
|
+
return import_ts_morph18.Node.isBlock(statement) ? statement.getStatements() : [statement];
|
|
4965
|
+
}
|
|
4966
|
+
function declarationsOf2(nameNode, value) {
|
|
4967
|
+
if (import_ts_morph18.Node.isIdentifier(nameNode)) {
|
|
4968
|
+
return [{ name: nameNode.getText(), value }];
|
|
4969
|
+
}
|
|
4970
|
+
if (import_ts_morph18.Node.isObjectBindingPattern(nameNode) || import_ts_morph18.Node.isArrayBindingPattern(nameNode)) {
|
|
4971
|
+
return nameNode.getElements().flatMap(
|
|
4972
|
+
(element) => import_ts_morph18.Node.isBindingElement(element) ? declarationsOf2(element.getNameNode(), null) : []
|
|
4973
|
+
);
|
|
4974
|
+
}
|
|
4975
|
+
return [];
|
|
4976
|
+
}
|
|
4977
|
+
function isRoot(node) {
|
|
4978
|
+
return import_ts_morph18.Node.isSourceFile(node) || import_ts_morph18.Node.isFunctionLikeDeclaration(node);
|
|
4979
|
+
}
|
|
4980
|
+
function isStandaloneBlock(node) {
|
|
4981
|
+
const parent = node.getParent();
|
|
4982
|
+
return parent !== void 0 && (import_ts_morph18.Node.isBlock(parent) || import_ts_morph18.Node.isSourceFile(parent) || import_ts_morph18.Node.isModuleBlock(parent) || import_ts_morph18.Node.isCaseClause(parent) || import_ts_morph18.Node.isDefaultClause(parent));
|
|
4983
|
+
}
|
|
4984
|
+
function isPathStatement(node) {
|
|
4985
|
+
if (import_ts_morph18.Node.isBlock(node)) {
|
|
4986
|
+
return isStandaloneBlock(node);
|
|
4987
|
+
}
|
|
4988
|
+
return import_ts_morph18.Node.isStatement(node) && !import_ts_morph18.Node.isFunctionDeclaration(node);
|
|
4989
|
+
}
|
|
4990
|
+
function siteOf(node) {
|
|
4991
|
+
const path14 = [];
|
|
4992
|
+
let current2 = node;
|
|
4993
|
+
for (; ; ) {
|
|
4994
|
+
const parent = current2.getParent();
|
|
4995
|
+
if (parent === void 0) {
|
|
4996
|
+
return null;
|
|
4997
|
+
}
|
|
4998
|
+
if (isPathStatement(current2)) {
|
|
4999
|
+
path14.unshift(current2);
|
|
5000
|
+
}
|
|
5001
|
+
if (isRoot(parent)) {
|
|
5002
|
+
return { root: parent, path: path14 };
|
|
5003
|
+
}
|
|
5004
|
+
current2 = parent;
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
function functionOf(node) {
|
|
5008
|
+
if (import_ts_morph18.Node.isSourceFile(node)) {
|
|
5009
|
+
return { parameters: [], body: node.getStatements() };
|
|
5010
|
+
}
|
|
5011
|
+
if (!import_ts_morph18.Node.isFunctionLikeDeclaration(node)) {
|
|
5012
|
+
return null;
|
|
5013
|
+
}
|
|
5014
|
+
const parameters = node.getParameters().flatMap((parameter) => {
|
|
5015
|
+
const nameNode = parameter.getNameNode();
|
|
5016
|
+
return import_ts_morph18.Node.isIdentifier(nameNode) ? [
|
|
5017
|
+
{
|
|
5018
|
+
name: nameNode.getText(),
|
|
5019
|
+
default: parameter.getInitializer() ?? null
|
|
5020
|
+
}
|
|
5021
|
+
] : [];
|
|
5022
|
+
});
|
|
5023
|
+
const body = import_ts_morph18.Node.isBodied(node) ? node.getBody() : import_ts_morph18.Node.isBodyable(node) ? node.getBody() : void 0;
|
|
5024
|
+
if (body === void 0) {
|
|
5025
|
+
return { parameters, body: [] };
|
|
5026
|
+
}
|
|
5027
|
+
return import_ts_morph18.Node.isBlock(body) ? { parameters, body: body.getStatements() } : { parameters, body: { expression: body } };
|
|
5028
|
+
}
|
|
5029
|
+
function namesMutatedInNestedFunctions(root) {
|
|
5030
|
+
const mutated = /* @__PURE__ */ new Set();
|
|
5031
|
+
root.forEachDescendant((descendant) => {
|
|
5032
|
+
const written = writtenNameOf(descendant);
|
|
5033
|
+
if (written !== null && enclosingRootOf(descendant) !== root) {
|
|
5034
|
+
mutated.add(written);
|
|
5035
|
+
}
|
|
5036
|
+
});
|
|
5037
|
+
return mutated;
|
|
5038
|
+
}
|
|
5039
|
+
function writtenNameOf(node) {
|
|
5040
|
+
if (import_ts_morph18.Node.isBinaryExpression(node)) {
|
|
5041
|
+
const target = peelValue(node.getLeft());
|
|
5042
|
+
return ASSIGNMENT_OPERATORS.has(node.getOperatorToken().getText()) && import_ts_morph18.Node.isIdentifier(target) ? target.getText() : null;
|
|
5043
|
+
}
|
|
5044
|
+
if (import_ts_morph18.Node.isPostfixUnaryExpression(node) || import_ts_morph18.Node.isPrefixUnaryExpression(node)) {
|
|
5045
|
+
const operand2 = peelValue(node.getOperand());
|
|
5046
|
+
return import_ts_morph18.Node.isIdentifier(operand2) ? operand2.getText() : null;
|
|
5047
|
+
}
|
|
5048
|
+
if (import_ts_morph18.Node.isCallExpression(node)) {
|
|
5049
|
+
const callee = peelValue(node.getExpression());
|
|
5050
|
+
if (!import_ts_morph18.Node.isPropertyAccessExpression(callee)) {
|
|
5051
|
+
return null;
|
|
5052
|
+
}
|
|
5053
|
+
const receiver = peelValue(callee.getExpression());
|
|
5054
|
+
return MUTATING_METHODS.has(callee.getName()) && import_ts_morph18.Node.isIdentifier(receiver) ? receiver.getText() : null;
|
|
5055
|
+
}
|
|
5056
|
+
return null;
|
|
5057
|
+
}
|
|
5058
|
+
function enclosingRootOf(node) {
|
|
5059
|
+
let current2 = node.getParent();
|
|
5060
|
+
while (current2 !== void 0 && !isRoot(current2)) {
|
|
5061
|
+
current2 = current2.getParent();
|
|
5062
|
+
}
|
|
5063
|
+
return current2;
|
|
5064
|
+
}
|
|
5065
|
+
function freeNamesOf(fn) {
|
|
5066
|
+
const declared = /* @__PURE__ */ new Set();
|
|
5067
|
+
const read2 = /* @__PURE__ */ new Set();
|
|
5068
|
+
fn.forEachDescendant((descendant) => {
|
|
5069
|
+
if (!import_ts_morph18.Node.isIdentifier(descendant)) {
|
|
5070
|
+
return;
|
|
5071
|
+
}
|
|
5072
|
+
const parent = descendant.getParent();
|
|
5073
|
+
if (import_ts_morph18.Node.isPropertyAccessExpression(parent) && parent.getNameNode() === descendant) {
|
|
5074
|
+
return;
|
|
5075
|
+
}
|
|
5076
|
+
if (import_ts_morph18.Node.isVariableDeclaration(parent) || import_ts_morph18.Node.isParameterDeclaration(parent) || import_ts_morph18.Node.isBindingElement(parent) || import_ts_morph18.Node.isFunctionDeclaration(parent)) {
|
|
5077
|
+
declared.add(descendant.getText());
|
|
5078
|
+
return;
|
|
5079
|
+
}
|
|
5080
|
+
if (import_ts_morph18.Node.isPropertyAssignment(parent) && parent.getNameNode() === descendant) {
|
|
5081
|
+
return;
|
|
5082
|
+
}
|
|
5083
|
+
read2.add(descendant.getText());
|
|
5084
|
+
});
|
|
5085
|
+
return [...read2].filter((name) => !declared.has(name));
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
// src/values/rows.ts
|
|
5089
|
+
var import_values = require("@suss/values");
|
|
5090
|
+
var PATH_MODULES = ["path", "node:path", "path/posix", "node:path/posix"];
|
|
5091
|
+
var operatorRows = [
|
|
5092
|
+
{
|
|
5093
|
+
kind: "operator",
|
|
5094
|
+
operator: "+",
|
|
5095
|
+
arity: 2,
|
|
5096
|
+
apply: ([a, b]) => (0, import_values.plus)((0, import_values.operand)(a), (0, import_values.operand)(b))
|
|
5097
|
+
},
|
|
5098
|
+
{
|
|
5099
|
+
kind: "operator",
|
|
5100
|
+
operator: "===",
|
|
5101
|
+
arity: 2,
|
|
5102
|
+
apply: ([a, b]) => (0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b))
|
|
5103
|
+
},
|
|
5104
|
+
{
|
|
5105
|
+
kind: "operator",
|
|
5106
|
+
operator: "==",
|
|
5107
|
+
arity: 2,
|
|
5108
|
+
apply: ([a, b]) => (0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b))
|
|
5109
|
+
},
|
|
5110
|
+
{
|
|
5111
|
+
kind: "operator",
|
|
5112
|
+
operator: "!==",
|
|
5113
|
+
arity: 2,
|
|
5114
|
+
apply: ([a, b]) => (0, import_values.negated)((0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b)))
|
|
5115
|
+
},
|
|
5116
|
+
{
|
|
5117
|
+
kind: "operator",
|
|
5118
|
+
operator: "!=",
|
|
5119
|
+
arity: 2,
|
|
5120
|
+
apply: ([a, b]) => (0, import_values.negated)((0, import_values.equals)((0, import_values.operand)(a), (0, import_values.operand)(b)))
|
|
5121
|
+
},
|
|
5122
|
+
{
|
|
5123
|
+
kind: "operator",
|
|
5124
|
+
operator: "!",
|
|
5125
|
+
arity: 1,
|
|
5126
|
+
apply: ([a]) => (0, import_values.negated)((0, import_values.operand)(a))
|
|
5127
|
+
},
|
|
5128
|
+
{
|
|
5129
|
+
kind: "operator",
|
|
5130
|
+
operator: "??",
|
|
5131
|
+
arity: 2,
|
|
5132
|
+
apply: ([a, b]) => (0, import_values.readableFallback)((0, import_values.operand)(a), (0, import_values.operand)(b), import_values.isPresent)
|
|
5133
|
+
},
|
|
5134
|
+
{
|
|
5135
|
+
kind: "operator",
|
|
5136
|
+
operator: "||",
|
|
5137
|
+
arity: 2,
|
|
5138
|
+
apply: ([a, b]) => (0, import_values.readableFallback)((0, import_values.operand)(a), (0, import_values.operand)(b), import_values.truthOf)
|
|
5139
|
+
},
|
|
5140
|
+
{
|
|
5141
|
+
kind: "operator",
|
|
5142
|
+
operator: "&&",
|
|
5143
|
+
arity: 2,
|
|
5144
|
+
apply: ([a, b]) => (0, import_values.fallback)((0, import_values.operand)(a), (0, import_values.operand)(b), (left) => {
|
|
5145
|
+
const truth = (0, import_values.truthOf)(left);
|
|
5146
|
+
return truth === null ? null : !truth;
|
|
5147
|
+
})
|
|
5148
|
+
}
|
|
5149
|
+
];
|
|
5150
|
+
var stringRows = [
|
|
5151
|
+
{
|
|
5152
|
+
kind: "method",
|
|
5153
|
+
method: "toString",
|
|
5154
|
+
on: "string",
|
|
5155
|
+
apply: () => ({ result: "receiver" })
|
|
5156
|
+
},
|
|
5157
|
+
{
|
|
5158
|
+
kind: "method",
|
|
5159
|
+
method: "toString",
|
|
5160
|
+
on: "constant",
|
|
5161
|
+
apply: ({ receiver }) => ({ result: (0, import_values.concat)([(0, import_values.operand)(receiver)]) })
|
|
5162
|
+
},
|
|
5163
|
+
{
|
|
5164
|
+
kind: "method",
|
|
5165
|
+
method: "concat",
|
|
5166
|
+
on: "string",
|
|
5167
|
+
apply: ({ receiver, args }) => ({
|
|
5168
|
+
result: (0, import_values.concat)([(0, import_values.operand)(receiver), ...args])
|
|
5169
|
+
})
|
|
5170
|
+
}
|
|
5171
|
+
];
|
|
5172
|
+
var sequenceRows = ["sequence", "unbounded"].flatMap((on) => [
|
|
5173
|
+
{
|
|
5174
|
+
kind: "method",
|
|
5175
|
+
method: "push",
|
|
5176
|
+
on,
|
|
5177
|
+
apply: ({ receiver, args }) => ({
|
|
5178
|
+
result: (0, import_values.constant)(0),
|
|
5179
|
+
receiver: (0, import_values.appended)((0, import_values.operand)(receiver), args)
|
|
5180
|
+
})
|
|
5181
|
+
},
|
|
5182
|
+
{
|
|
5183
|
+
kind: "method",
|
|
5184
|
+
method: "concat",
|
|
5185
|
+
on,
|
|
5186
|
+
apply: ({ receiver, args, contentOf }) => ({
|
|
5187
|
+
result: args.reduce(
|
|
5188
|
+
(sequence, other) => (0, import_values.extended)(sequence, contentOf(other)),
|
|
5189
|
+
(0, import_values.operand)(receiver)
|
|
5190
|
+
)
|
|
5191
|
+
})
|
|
5192
|
+
},
|
|
5193
|
+
{
|
|
5194
|
+
kind: "method",
|
|
5195
|
+
method: "join",
|
|
5196
|
+
on,
|
|
5197
|
+
apply: ({ receiver, args }) => ({
|
|
5198
|
+
result: (0, import_values.joined)((0, import_values.operand)(receiver), args[0])
|
|
5199
|
+
})
|
|
5200
|
+
}
|
|
5201
|
+
]);
|
|
5202
|
+
var calleeRows = [
|
|
5203
|
+
{
|
|
5204
|
+
kind: "callee",
|
|
5205
|
+
origin: { module: "global", name: "String" },
|
|
5206
|
+
apply: ({ args }) => ({ result: (0, import_values.concat)([(0, import_values.operand)(args[0])]) })
|
|
5207
|
+
},
|
|
5208
|
+
...PATH_MODULES.map(
|
|
5209
|
+
(module2) => ({
|
|
5210
|
+
kind: "callee",
|
|
5211
|
+
origin: { module: module2, name: "join" },
|
|
5212
|
+
apply: ({ args }) => ({ result: (0, import_values.joinedPath)(args) })
|
|
5213
|
+
})
|
|
5214
|
+
)
|
|
5215
|
+
];
|
|
5216
|
+
var typescriptRows = [
|
|
5217
|
+
...operatorRows,
|
|
5218
|
+
...stringRows,
|
|
5219
|
+
...sequenceRows,
|
|
5220
|
+
...calleeRows
|
|
5221
|
+
];
|
|
5222
|
+
|
|
5223
|
+
// src/values/evaluator.ts
|
|
5224
|
+
var evaluators = /* @__PURE__ */ new WeakMap();
|
|
5225
|
+
function evaluatorFor(node, resolution) {
|
|
5226
|
+
const key = resolution ?? node.getProject();
|
|
5227
|
+
let evaluator = evaluators.get(key);
|
|
5228
|
+
if (evaluator === void 0) {
|
|
5229
|
+
evaluator = new import_values2.Evaluator(
|
|
5230
|
+
typescriptLowering(
|
|
5231
|
+
resolution === void 0 ? { rows: typescriptRows } : { resolution, rows: typescriptRows }
|
|
5232
|
+
)
|
|
5233
|
+
);
|
|
5234
|
+
evaluators.set(key, evaluator);
|
|
5235
|
+
}
|
|
5236
|
+
return evaluator;
|
|
5237
|
+
}
|
|
5238
|
+
function evaluatedValue(node, resolution) {
|
|
5239
|
+
return (0, import_values2.force)(evaluatorFor(node, resolution).evaluate(node));
|
|
5240
|
+
}
|
|
5241
|
+
|
|
5242
|
+
// src/discovery/resolveValue.ts
|
|
4664
5243
|
function couldNameAValue(value) {
|
|
4665
|
-
return
|
|
5244
|
+
return import_ts_morph19.Node.isIdentifier(value) || import_ts_morph19.Node.isPropertyAccessExpression(value) || import_ts_morph19.Node.isElementAccessExpression(value) || import_ts_morph19.Node.isCallExpression(value);
|
|
4666
5245
|
}
|
|
4667
5246
|
function propertyValueOf(property) {
|
|
4668
|
-
if (
|
|
5247
|
+
if (import_ts_morph19.Node.isPropertyAssignment(property)) {
|
|
4669
5248
|
return property.getInitializer() ?? null;
|
|
4670
5249
|
}
|
|
4671
|
-
if (
|
|
5250
|
+
if (import_ts_morph19.Node.isShorthandPropertyAssignment(property)) {
|
|
4672
5251
|
return property.getNameNode();
|
|
4673
5252
|
}
|
|
4674
5253
|
return null;
|
|
@@ -4689,7 +5268,7 @@ function objectLiteralOf(value, resolution) {
|
|
|
4689
5268
|
return literalValueOf(
|
|
4690
5269
|
value,
|
|
4691
5270
|
resolution,
|
|
4692
|
-
(node) =>
|
|
5271
|
+
(node) => import_ts_morph19.Node.isObjectLiteralExpression(node)
|
|
4693
5272
|
);
|
|
4694
5273
|
}
|
|
4695
5274
|
function propertiesOf(object, resolution) {
|
|
@@ -4701,7 +5280,7 @@ function propertiesReached(object, resolution, seen) {
|
|
|
4701
5280
|
}
|
|
4702
5281
|
seen.add(object);
|
|
4703
5282
|
return object.getProperties().flatMap((property) => {
|
|
4704
|
-
if (!
|
|
5283
|
+
if (!import_ts_morph19.Node.isSpreadAssignment(property)) {
|
|
4705
5284
|
return [property];
|
|
4706
5285
|
}
|
|
4707
5286
|
const spread = objectLiteralOf(property.getExpression(), resolution);
|
|
@@ -4710,17 +5289,17 @@ function propertiesReached(object, resolution, seen) {
|
|
|
4710
5289
|
}
|
|
4711
5290
|
function writtenNodeOf(value, resolution) {
|
|
4712
5291
|
const written = factKeyOf(value);
|
|
4713
|
-
if (
|
|
5292
|
+
if (import_ts_morph19.Node.isNewExpression(written)) {
|
|
4714
5293
|
return written;
|
|
4715
5294
|
}
|
|
4716
|
-
if (
|
|
5295
|
+
if (import_ts_morph19.Node.isCallExpression(written)) {
|
|
4717
5296
|
return writtenThroughCall(written, resolution);
|
|
4718
5297
|
}
|
|
4719
5298
|
if (resolution === void 0 || !couldNameAValue(written)) {
|
|
4720
5299
|
return null;
|
|
4721
5300
|
}
|
|
4722
5301
|
const resolved = resolution.resolveWrittenValue(written);
|
|
4723
|
-
return resolved !== null &&
|
|
5302
|
+
return resolved !== null && import_ts_morph19.Node.isCallExpression(resolved) ? writtenThroughCall(resolved, resolution) : resolved;
|
|
4724
5303
|
}
|
|
4725
5304
|
function writtenThroughCall(call, resolution) {
|
|
4726
5305
|
if (resolution !== void 0 && resolution.resolveCallable(call.getExpression()) !== null) {
|
|
@@ -4732,24 +5311,21 @@ function writtenThroughCall(call, resolution) {
|
|
|
4732
5311
|
return call;
|
|
4733
5312
|
}
|
|
4734
5313
|
function stringValueOf(value, resolution) {
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
if (
|
|
5314
|
+
return (0, import_values3.literalOf)(evaluatedValue(value, resolution));
|
|
5315
|
+
}
|
|
5316
|
+
function stringPropertyOf(object, name, resolution) {
|
|
5317
|
+
const record2 = evaluatedValue(object, resolution);
|
|
5318
|
+
if (record2.kind !== "record") {
|
|
4740
5319
|
return null;
|
|
4741
5320
|
}
|
|
4742
|
-
const
|
|
4743
|
-
return
|
|
4744
|
-
}
|
|
4745
|
-
function isStringNode(node) {
|
|
4746
|
-
return import_ts_morph18.Node.isStringLiteral(node) || import_ts_morph18.Node.isNoSubstitutionTemplateLiteral(node);
|
|
5321
|
+
const field = record2.fields.get(name);
|
|
5322
|
+
return field === void 0 ? null : (0, import_values3.literalOf)((0, import_values3.force)(field.value));
|
|
4747
5323
|
}
|
|
4748
5324
|
function arrayLiteralOf(value, resolution) {
|
|
4749
5325
|
return literalValueOf(
|
|
4750
5326
|
value,
|
|
4751
5327
|
resolution,
|
|
4752
|
-
(node) =>
|
|
5328
|
+
(node) => import_ts_morph19.Node.isArrayLiteralExpression(node)
|
|
4753
5329
|
);
|
|
4754
5330
|
}
|
|
4755
5331
|
function literalValueOf(value, resolution, isWanted) {
|
|
@@ -4772,26 +5348,26 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
|
4772
5348
|
if (!isGlobal) {
|
|
4773
5349
|
for (const varDecl of sourceFile.getVariableDeclarations()) {
|
|
4774
5350
|
const init = varDecl.getInitializer();
|
|
4775
|
-
if (init !== void 0 && (
|
|
5351
|
+
if (init !== void 0 && (import_ts_morph20.Node.isCallExpression(init) || import_ts_morph20.Node.isNewExpression(init)) && isCreationCall(init, match, resolution)) {
|
|
4776
5352
|
clientVarNames.add(varDecl.getName());
|
|
4777
5353
|
}
|
|
4778
5354
|
}
|
|
4779
5355
|
}
|
|
4780
5356
|
const methodFilter = match.methodFilter !== void 0 ? new Set(match.methodFilter) : null;
|
|
4781
5357
|
sourceFile.forEachDescendant((node) => {
|
|
4782
|
-
if (!
|
|
5358
|
+
if (!import_ts_morph20.Node.isCallExpression(node)) {
|
|
4783
5359
|
return;
|
|
4784
5360
|
}
|
|
4785
5361
|
const callee = node.getExpression();
|
|
4786
5362
|
let methodName = null;
|
|
4787
5363
|
let matched = false;
|
|
4788
|
-
if (isGlobal &&
|
|
5364
|
+
if (isGlobal && import_ts_morph20.Node.isIdentifier(callee)) {
|
|
4789
5365
|
if (callee.getText() === match.importName) {
|
|
4790
5366
|
matched = true;
|
|
4791
5367
|
}
|
|
4792
|
-
} else if (
|
|
5368
|
+
} else if (import_ts_morph20.Node.isPropertyAccessExpression(callee)) {
|
|
4793
5369
|
const subject = callee.getExpression();
|
|
4794
|
-
if (
|
|
5370
|
+
if (import_ts_morph20.Node.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution)) {
|
|
4795
5371
|
methodName = callee.getName();
|
|
4796
5372
|
if (methodFilter === null || methodFilter.has(methodName)) {
|
|
4797
5373
|
matched = true;
|
|
@@ -4825,16 +5401,16 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
4825
5401
|
);
|
|
4826
5402
|
const constructedHere = /* @__PURE__ */ new Set();
|
|
4827
5403
|
sourceFile.forEachDescendant((node) => {
|
|
4828
|
-
if (
|
|
5404
|
+
if (import_ts_morph20.Node.isVariableDeclaration(node)) {
|
|
4829
5405
|
const init = node.getInitializer();
|
|
4830
|
-
if (init !== void 0 && (
|
|
5406
|
+
if (init !== void 0 && (import_ts_morph20.Node.isCallExpression(init) || import_ts_morph20.Node.isNewExpression(init)) && isCreationCall(init, match, resolution) || localName !== null && typedAsClient(node.getTypeNode(), localName)) {
|
|
4831
5407
|
constructedHere.add(node.getName());
|
|
4832
5408
|
}
|
|
4833
5409
|
return;
|
|
4834
5410
|
}
|
|
4835
|
-
if (
|
|
5411
|
+
if (import_ts_morph20.Node.isParameterDeclaration(node) && localName !== null && typedAsClient(node.getTypeNode(), localName)) {
|
|
4836
5412
|
const written = node.getNameNode();
|
|
4837
|
-
if (
|
|
5413
|
+
if (import_ts_morph20.Node.isIdentifier(written)) {
|
|
4838
5414
|
constructedHere.add(written.getText());
|
|
4839
5415
|
}
|
|
4840
5416
|
}
|
|
@@ -4845,10 +5421,10 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
4845
5421
|
importName: match.importName,
|
|
4846
5422
|
...match.factoryMethods === void 0 ? {} : { factoryMethods: match.factoryMethods }
|
|
4847
5423
|
};
|
|
4848
|
-
return (subject) => isClientImport(subject, match, resolution, true) ||
|
|
5424
|
+
return (subject) => isClientImport(subject, match, resolution, true) || import_ts_morph20.Node.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
|
|
4849
5425
|
}
|
|
4850
5426
|
function typedAsClient(typeNode, localName) {
|
|
4851
|
-
if (typeNode === void 0 || !
|
|
5427
|
+
if (typeNode === void 0 || !import_ts_morph20.Node.isTypeReference(typeNode)) {
|
|
4852
5428
|
return false;
|
|
4853
5429
|
}
|
|
4854
5430
|
return typeNode.getTypeName().getText() === localName;
|
|
@@ -4858,27 +5434,27 @@ function resolvesToKnownInstance(subject, match, resolution) {
|
|
|
4858
5434
|
return false;
|
|
4859
5435
|
}
|
|
4860
5436
|
const written = writtenNodeOf(subject, resolution);
|
|
4861
|
-
if (written === null || !
|
|
5437
|
+
if (written === null || !import_ts_morph20.Node.isCallExpression(written) && !import_ts_morph20.Node.isNewExpression(written)) {
|
|
4862
5438
|
return false;
|
|
4863
5439
|
}
|
|
4864
5440
|
return isCreationCall(written, match, resolution);
|
|
4865
5441
|
}
|
|
4866
5442
|
function isCreationCall(call, match, resolution) {
|
|
4867
5443
|
const callee = call.getExpression();
|
|
4868
|
-
if (
|
|
5444
|
+
if (import_ts_morph20.Node.isIdentifier(callee)) {
|
|
4869
5445
|
return isClientImport(callee, match, resolution, false);
|
|
4870
5446
|
}
|
|
4871
|
-
if (!
|
|
5447
|
+
if (!import_ts_morph20.Node.isPropertyAccessExpression(callee)) {
|
|
4872
5448
|
return false;
|
|
4873
5449
|
}
|
|
4874
5450
|
const base = callee.getExpression();
|
|
4875
|
-
return
|
|
5451
|
+
return import_ts_morph20.Node.isIdentifier(base) && (match.factoryMethods?.includes(callee.getName()) ?? false) && isClientImport(base, match, resolution, false);
|
|
4876
5452
|
}
|
|
4877
5453
|
function isPathShaped(specifier) {
|
|
4878
5454
|
return specifier.startsWith(".") || specifier.startsWith("/");
|
|
4879
5455
|
}
|
|
4880
5456
|
function isClientImport(subject, match, resolution, strictDefaultName) {
|
|
4881
|
-
if (!
|
|
5457
|
+
if (!import_ts_morph20.Node.isIdentifier(subject)) {
|
|
4882
5458
|
return false;
|
|
4883
5459
|
}
|
|
4884
5460
|
if (resolution === void 0) {
|
|
@@ -4926,27 +5502,27 @@ function resolvedImportLocalName(sourceFile, importModule, importName, strictDef
|
|
|
4926
5502
|
return null;
|
|
4927
5503
|
}
|
|
4928
5504
|
function clientUnitName(enclosingFunc, methodName) {
|
|
4929
|
-
if (
|
|
5505
|
+
if (import_ts_morph20.Node.isFunctionDeclaration(enclosingFunc)) {
|
|
4930
5506
|
return enclosingFunc.getName() ?? methodName ?? "anonymous";
|
|
4931
5507
|
}
|
|
4932
|
-
if (
|
|
5508
|
+
if (import_ts_morph20.Node.isMethodDeclaration(enclosingFunc)) {
|
|
4933
5509
|
return enclosingFunc.getName();
|
|
4934
5510
|
}
|
|
4935
5511
|
const parent = enclosingFunc.getParent();
|
|
4936
|
-
if (parent !== void 0 &&
|
|
5512
|
+
if (parent !== void 0 && import_ts_morph20.Node.isVariableDeclaration(parent)) {
|
|
4937
5513
|
return parent.getName();
|
|
4938
5514
|
}
|
|
4939
|
-
if (parent !== void 0 &&
|
|
5515
|
+
if (parent !== void 0 && import_ts_morph20.Node.isPropertyAssignment(parent)) {
|
|
4940
5516
|
return parent.getName();
|
|
4941
5517
|
}
|
|
4942
5518
|
return methodName ?? "anonymous";
|
|
4943
5519
|
}
|
|
4944
5520
|
|
|
4945
5521
|
// src/discovery/decoratedMethod.ts
|
|
4946
|
-
var
|
|
5522
|
+
var import_ts_morph23 = require("ts-morph");
|
|
4947
5523
|
|
|
4948
5524
|
// src/discovery/decoratedMembers.ts
|
|
4949
|
-
var
|
|
5525
|
+
var import_ts_morph21 = require("ts-morph");
|
|
4950
5526
|
function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
|
|
4951
5527
|
const localToCanonical = /* @__PURE__ */ new Map();
|
|
4952
5528
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
@@ -4966,7 +5542,7 @@ function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
|
|
|
4966
5542
|
function decoratedCallablesOf(cls, decoratorNames) {
|
|
4967
5543
|
const callables = [];
|
|
4968
5544
|
for (const member of cls.getMembers()) {
|
|
4969
|
-
if (!
|
|
5545
|
+
if (!import_ts_morph21.Node.isMethodDeclaration(member) && !import_ts_morph21.Node.isPropertyDeclaration(member)) {
|
|
4970
5546
|
continue;
|
|
4971
5547
|
}
|
|
4972
5548
|
const func = callableOf(member);
|
|
@@ -4990,7 +5566,7 @@ function decoratedCallablesOf(cls, decoratorNames) {
|
|
|
4990
5566
|
return callables;
|
|
4991
5567
|
}
|
|
4992
5568
|
function callableOf(member) {
|
|
4993
|
-
if (
|
|
5569
|
+
if (import_ts_morph21.Node.isMethodDeclaration(member)) {
|
|
4994
5570
|
return toFunctionRoot(member);
|
|
4995
5571
|
}
|
|
4996
5572
|
const held = member.getInitializer();
|
|
@@ -4998,7 +5574,7 @@ function callableOf(member) {
|
|
|
4998
5574
|
}
|
|
4999
5575
|
|
|
5000
5576
|
// src/discovery/decoratorComposition.ts
|
|
5001
|
-
var
|
|
5577
|
+
var import_ts_morph22 = require("ts-morph");
|
|
5002
5578
|
function classDecoratorStandingFor(cls, names, modules, resolution) {
|
|
5003
5579
|
for (const candidate of names) {
|
|
5004
5580
|
const decorator = cls.getDecorator(candidate);
|
|
@@ -5014,7 +5590,7 @@ function classDecoratorStandingFor(cls, names, modules, resolution) {
|
|
|
5014
5590
|
return null;
|
|
5015
5591
|
}
|
|
5016
5592
|
for (const decorator of cls.getDecorators()) {
|
|
5017
|
-
const applied = resolution.importedNamesOf(
|
|
5593
|
+
const applied = resolution.importedNamesOf(calleeOf2(decorator), modules);
|
|
5018
5594
|
const standsFor = names.find((name) => applied.includes(name));
|
|
5019
5595
|
if (standsFor === void 0) {
|
|
5020
5596
|
continue;
|
|
@@ -5032,11 +5608,11 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
5032
5608
|
if (atClass.length > 0) {
|
|
5033
5609
|
return atClass;
|
|
5034
5610
|
}
|
|
5035
|
-
const wrapper = resolution.resolveCallable(
|
|
5611
|
+
const wrapper = resolution.resolveCallable(calleeOf2(decorator));
|
|
5036
5612
|
if (wrapper === null) {
|
|
5037
5613
|
return atClass;
|
|
5038
5614
|
}
|
|
5039
|
-
for (const call of wrapper.getDescendantsOfKind(
|
|
5615
|
+
for (const call of wrapper.getDescendantsOfKind(import_ts_morph22.SyntaxKind.CallExpression)) {
|
|
5040
5616
|
const names = resolution.importedNamesOf(call.getExpression(), modules);
|
|
5041
5617
|
if (!names.includes(standsFor)) {
|
|
5042
5618
|
continue;
|
|
@@ -5047,17 +5623,17 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
5047
5623
|
return atClass;
|
|
5048
5624
|
}
|
|
5049
5625
|
function statesAValue(arg, wrapper) {
|
|
5050
|
-
const identifiers =
|
|
5626
|
+
const identifiers = import_ts_morph22.Node.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(import_ts_morph22.SyntaxKind.Identifier);
|
|
5051
5627
|
return !identifiers.some(
|
|
5052
5628
|
(identifier) => identifier.getSymbol()?.getDeclarations().some(
|
|
5053
|
-
(declaration) =>
|
|
5629
|
+
(declaration) => import_ts_morph22.Node.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
|
|
5054
5630
|
)
|
|
5055
5631
|
);
|
|
5056
5632
|
}
|
|
5057
5633
|
function isWithin(node, container) {
|
|
5058
5634
|
return node.getSourceFile() === container.getSourceFile() && node.getStart() >= container.getStart() && node.getEnd() <= container.getEnd();
|
|
5059
5635
|
}
|
|
5060
|
-
function
|
|
5636
|
+
function calleeOf2(decorator) {
|
|
5061
5637
|
const call = decorator.getCallExpression();
|
|
5062
5638
|
if (call !== void 0) {
|
|
5063
5639
|
return call.getExpression();
|
|
@@ -5070,39 +5646,39 @@ function resolverTypeName(args) {
|
|
|
5070
5646
|
return args.typeMap[args.decoratorName] ?? args.classTypeName ?? null;
|
|
5071
5647
|
}
|
|
5072
5648
|
function resolveResolverClassTypeName(decoratorArg) {
|
|
5073
|
-
if (
|
|
5649
|
+
if (import_ts_morph23.Node.isArrowFunction(decoratorArg)) {
|
|
5074
5650
|
const body = decoratorArg.getBody();
|
|
5075
|
-
if (
|
|
5651
|
+
if (import_ts_morph23.Node.isIdentifier(body)) {
|
|
5076
5652
|
return body.getText();
|
|
5077
5653
|
}
|
|
5078
5654
|
return null;
|
|
5079
5655
|
}
|
|
5080
|
-
if (
|
|
5656
|
+
if (import_ts_morph23.Node.isStringLiteral(decoratorArg)) {
|
|
5081
5657
|
return decoratorArg.getLiteralValue();
|
|
5082
5658
|
}
|
|
5083
|
-
if (
|
|
5659
|
+
if (import_ts_morph23.Node.isIdentifier(decoratorArg)) {
|
|
5084
5660
|
return decoratorArg.getText();
|
|
5085
5661
|
}
|
|
5086
5662
|
return null;
|
|
5087
5663
|
}
|
|
5088
5664
|
function resolveOperationNameOverride(decorator) {
|
|
5089
|
-
if (!
|
|
5665
|
+
if (!import_ts_morph23.Node.isDecorator(decorator)) {
|
|
5090
5666
|
return null;
|
|
5091
5667
|
}
|
|
5092
5668
|
const args = decorator.getArguments();
|
|
5093
5669
|
for (const arg of args) {
|
|
5094
|
-
if (!
|
|
5670
|
+
if (!import_ts_morph23.Node.isObjectLiteralExpression(arg)) {
|
|
5095
5671
|
continue;
|
|
5096
5672
|
}
|
|
5097
5673
|
const prop = arg.getProperty("name");
|
|
5098
|
-
if (prop === void 0 || !
|
|
5674
|
+
if (prop === void 0 || !import_ts_morph23.Node.isPropertyAssignment(prop)) {
|
|
5099
5675
|
continue;
|
|
5100
5676
|
}
|
|
5101
5677
|
const init = prop.getInitializer();
|
|
5102
5678
|
if (init === void 0) {
|
|
5103
5679
|
continue;
|
|
5104
5680
|
}
|
|
5105
|
-
if (
|
|
5681
|
+
if (import_ts_morph23.Node.isStringLiteral(init) || import_ts_morph23.Node.isNoSubstitutionTemplateLiteral(init)) {
|
|
5106
5682
|
return init.getLiteralValue();
|
|
5107
5683
|
}
|
|
5108
5684
|
}
|
|
@@ -5155,9 +5731,9 @@ function discoverDecoratedMethods(sourceFile, match, kind, resolution) {
|
|
|
5155
5731
|
}
|
|
5156
5732
|
|
|
5157
5733
|
// src/discovery/decoratedRoute.ts
|
|
5158
|
-
var
|
|
5734
|
+
var import_ts_morph24 = require("ts-morph");
|
|
5159
5735
|
function resolveRoutePathArg(decorator, resolution) {
|
|
5160
|
-
if (!
|
|
5736
|
+
if (!import_ts_morph24.Node.isDecorator(decorator)) {
|
|
5161
5737
|
return "";
|
|
5162
5738
|
}
|
|
5163
5739
|
return routePathOf(decorator.getArguments(), resolution);
|
|
@@ -5185,7 +5761,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
5185
5761
|
if (source.from === "unstated") {
|
|
5186
5762
|
return null;
|
|
5187
5763
|
}
|
|
5188
|
-
if (!
|
|
5764
|
+
if (!import_ts_morph24.Node.isDecorator(decorator)) {
|
|
5189
5765
|
return null;
|
|
5190
5766
|
}
|
|
5191
5767
|
const arg = decorator.getArguments()[source.position];
|
|
@@ -5196,7 +5772,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
5196
5772
|
return text === null || text === "" ? null : text;
|
|
5197
5773
|
}
|
|
5198
5774
|
function literalStringOf(node, resolution) {
|
|
5199
|
-
if (
|
|
5775
|
+
if (import_ts_morph24.Node.isStringLiteral(node) || import_ts_morph24.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
5200
5776
|
return node.getLiteralValue();
|
|
5201
5777
|
}
|
|
5202
5778
|
const written = resolution?.resolveWrittenValue(node) ?? null;
|
|
@@ -5266,31 +5842,31 @@ function discoverDecoratedRoutes(sourceFile, match, kind, resolution, binding) {
|
|
|
5266
5842
|
var import_picomatch = __toESM(require("picomatch"), 1);
|
|
5267
5843
|
|
|
5268
5844
|
// src/discovery/namedExport.ts
|
|
5269
|
-
var
|
|
5845
|
+
var import_ts_morph25 = require("ts-morph");
|
|
5270
5846
|
function nameWrittenAt(expression) {
|
|
5271
|
-
if (
|
|
5847
|
+
if (import_ts_morph25.Node.isIdentifier(expression)) {
|
|
5272
5848
|
return expression.getText();
|
|
5273
5849
|
}
|
|
5274
|
-
if (
|
|
5850
|
+
if (import_ts_morph25.Node.isPropertyAccessExpression(expression)) {
|
|
5275
5851
|
return expression.getName();
|
|
5276
5852
|
}
|
|
5277
5853
|
return null;
|
|
5278
5854
|
}
|
|
5279
5855
|
function resolveDefaultExportName(decl, fn) {
|
|
5280
|
-
if (
|
|
5856
|
+
if (import_ts_morph25.Node.isFunctionDeclaration(fn) || import_ts_morph25.Node.isFunctionExpression(fn)) {
|
|
5281
5857
|
const n = fn.getName?.();
|
|
5282
5858
|
if (typeof n === "string" && n.length > 0) {
|
|
5283
5859
|
return n;
|
|
5284
5860
|
}
|
|
5285
5861
|
}
|
|
5286
|
-
if (
|
|
5862
|
+
if (import_ts_morph25.Node.isVariableDeclaration(decl)) {
|
|
5287
5863
|
const name = decl.getName();
|
|
5288
5864
|
if (name.length > 0) {
|
|
5289
5865
|
return name;
|
|
5290
5866
|
}
|
|
5291
5867
|
}
|
|
5292
5868
|
const binding = fn.getParent();
|
|
5293
|
-
if (binding !== void 0 &&
|
|
5869
|
+
if (binding !== void 0 && import_ts_morph25.Node.isVariableDeclaration(binding)) {
|
|
5294
5870
|
const name = binding.getName();
|
|
5295
5871
|
if (name.length > 0) {
|
|
5296
5872
|
return name;
|
|
@@ -5345,7 +5921,7 @@ function discoverNamedExports(sourceFile, match, kind, resolution) {
|
|
|
5345
5921
|
}
|
|
5346
5922
|
continue;
|
|
5347
5923
|
}
|
|
5348
|
-
if (
|
|
5924
|
+
if (import_ts_morph25.Node.isArrowFunction(init) || import_ts_morph25.Node.isFunctionExpression(init)) {
|
|
5349
5925
|
results.push({
|
|
5350
5926
|
func: init,
|
|
5351
5927
|
kind,
|
|
@@ -5454,13 +6030,13 @@ function discoverFileConventions(sourceFile, match, kind, resolution) {
|
|
|
5454
6030
|
}
|
|
5455
6031
|
|
|
5456
6032
|
// src/discovery/graphqlHookCall.ts
|
|
5457
|
-
var
|
|
6033
|
+
var import_ts_morph28 = require("ts-morph");
|
|
5458
6034
|
|
|
5459
6035
|
// src/discovery/graphqlShared.ts
|
|
5460
6036
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
5461
6037
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
5462
6038
|
var import_graphql = require("graphql");
|
|
5463
|
-
var
|
|
6039
|
+
var import_ts_morph26 = require("ts-morph");
|
|
5464
6040
|
var DOCUMENT_TAGS = /* @__PURE__ */ new Set(["gql", "graphql"]);
|
|
5465
6041
|
var UNQUALIFIED_DOCUMENT_TAG = "gql";
|
|
5466
6042
|
function parseGraphqlOperation(source) {
|
|
@@ -5526,10 +6102,10 @@ function startAssembly(resolution) {
|
|
|
5526
6102
|
};
|
|
5527
6103
|
}
|
|
5528
6104
|
function assembledTemplateText(template, assembly) {
|
|
5529
|
-
if (
|
|
6105
|
+
if (import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(template)) {
|
|
5530
6106
|
return innerTemplateText(template);
|
|
5531
6107
|
}
|
|
5532
|
-
if (!
|
|
6108
|
+
if (!import_ts_morph26.Node.isTemplateExpression(template)) {
|
|
5533
6109
|
return null;
|
|
5534
6110
|
}
|
|
5535
6111
|
let text = template.getHead().getLiteralText();
|
|
@@ -5665,7 +6241,7 @@ function collectDanglingSpreads(selectionSet, defined, dangling) {
|
|
|
5665
6241
|
}
|
|
5666
6242
|
}
|
|
5667
6243
|
function documentTextFromExpression(node, assembly) {
|
|
5668
|
-
if (
|
|
6244
|
+
if (import_ts_morph26.Node.isTaggedTemplateExpression(node)) {
|
|
5669
6245
|
if (!isDocumentTag(node.getTag())) {
|
|
5670
6246
|
return null;
|
|
5671
6247
|
}
|
|
@@ -5675,7 +6251,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
5675
6251
|
assembly.seen.add(node);
|
|
5676
6252
|
return assembledTemplateText(node.getTemplate(), assembly);
|
|
5677
6253
|
}
|
|
5678
|
-
if (!
|
|
6254
|
+
if (!import_ts_morph26.Node.isCallExpression(node)) {
|
|
5679
6255
|
return null;
|
|
5680
6256
|
}
|
|
5681
6257
|
if (!isDocumentTag(node.getExpression())) {
|
|
@@ -5686,7 +6262,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
5686
6262
|
return null;
|
|
5687
6263
|
}
|
|
5688
6264
|
const template = stripDocumentNodeCasts(first);
|
|
5689
|
-
if (!
|
|
6265
|
+
if (!import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(template) && !import_ts_morph26.Node.isTemplateExpression(template)) {
|
|
5690
6266
|
return null;
|
|
5691
6267
|
}
|
|
5692
6268
|
if (assembly.seen.has(node)) {
|
|
@@ -5696,7 +6272,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
5696
6272
|
return assembledTemplateText(template, assembly);
|
|
5697
6273
|
}
|
|
5698
6274
|
function isDocumentTag(tag) {
|
|
5699
|
-
if (!
|
|
6275
|
+
if (!import_ts_morph26.Node.isIdentifier(tag)) {
|
|
5700
6276
|
return false;
|
|
5701
6277
|
}
|
|
5702
6278
|
if (tag.getText() === UNQUALIFIED_DOCUMENT_TAG) {
|
|
@@ -5707,14 +6283,14 @@ function isDocumentTag(tag) {
|
|
|
5707
6283
|
return false;
|
|
5708
6284
|
}
|
|
5709
6285
|
for (const declaration of symbol.getDeclarations()) {
|
|
5710
|
-
if (
|
|
6286
|
+
if (import_ts_morph26.Node.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
|
|
5711
6287
|
return true;
|
|
5712
6288
|
}
|
|
5713
6289
|
}
|
|
5714
6290
|
return false;
|
|
5715
6291
|
}
|
|
5716
6292
|
function resolveThroughFacts(arg, assembly) {
|
|
5717
|
-
if (assembly.resolution === void 0 || !
|
|
6293
|
+
if (assembly.resolution === void 0 || !import_ts_morph26.Node.isIdentifier(arg)) {
|
|
5718
6294
|
return null;
|
|
5719
6295
|
}
|
|
5720
6296
|
const written = assembly.resolution.resolveWrittenValue(arg);
|
|
@@ -5763,7 +6339,7 @@ function singleLine(text) {
|
|
|
5763
6339
|
return collapsed.length > 80 ? `${collapsed.slice(0, 79)}\u2026` : collapsed;
|
|
5764
6340
|
}
|
|
5765
6341
|
function importedVariableInitializers(identifier) {
|
|
5766
|
-
if (!
|
|
6342
|
+
if (!import_ts_morph26.Node.isIdentifier(identifier)) {
|
|
5767
6343
|
return [];
|
|
5768
6344
|
}
|
|
5769
6345
|
const symbol = identifier.getSymbol();
|
|
@@ -5773,7 +6349,7 @@ function importedVariableInitializers(identifier) {
|
|
|
5773
6349
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
5774
6350
|
const inits = [];
|
|
5775
6351
|
for (const decl of resolved.getDeclarations()) {
|
|
5776
|
-
if (
|
|
6352
|
+
if (import_ts_morph26.Node.isVariableDeclaration(decl)) {
|
|
5777
6353
|
const init = decl.getInitializer();
|
|
5778
6354
|
if (init !== void 0) {
|
|
5779
6355
|
inits.push(init);
|
|
@@ -5787,7 +6363,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
5787
6363
|
if (direct !== null) {
|
|
5788
6364
|
return direct;
|
|
5789
6365
|
}
|
|
5790
|
-
if (!
|
|
6366
|
+
if (!import_ts_morph26.Node.isIdentifier(arg)) {
|
|
5791
6367
|
return null;
|
|
5792
6368
|
}
|
|
5793
6369
|
const symbol = arg.getSymbol();
|
|
@@ -5795,7 +6371,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
5795
6371
|
return null;
|
|
5796
6372
|
}
|
|
5797
6373
|
for (const decl of symbol.getDeclarations()) {
|
|
5798
|
-
if (
|
|
6374
|
+
if (import_ts_morph26.Node.isImportClause(decl) || import_ts_morph26.Node.isImportSpecifier(decl)) {
|
|
5799
6375
|
const fromGraphqlFile = resolveGraphqlFileImport(decl);
|
|
5800
6376
|
if (fromGraphqlFile !== null) {
|
|
5801
6377
|
return fromGraphqlFile;
|
|
@@ -5814,7 +6390,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
5814
6390
|
return null;
|
|
5815
6391
|
}
|
|
5816
6392
|
function resolveTypedDocumentSource(arg) {
|
|
5817
|
-
if (!
|
|
6393
|
+
if (!import_ts_morph26.Node.isIdentifier(arg)) {
|
|
5818
6394
|
return null;
|
|
5819
6395
|
}
|
|
5820
6396
|
for (const init of importedVariableInitializers(arg)) {
|
|
@@ -5827,7 +6403,7 @@ function resolveTypedDocumentSource(arg) {
|
|
|
5827
6403
|
}
|
|
5828
6404
|
function typedDocumentSourceOf(node) {
|
|
5829
6405
|
const inner = stripDocumentNodeCasts(node);
|
|
5830
|
-
if (!
|
|
6406
|
+
if (!import_ts_morph26.Node.isObjectLiteralExpression(inner)) {
|
|
5831
6407
|
return null;
|
|
5832
6408
|
}
|
|
5833
6409
|
const evaluated = evaluateObjectLiteralAsJson(inner);
|
|
@@ -5845,7 +6421,7 @@ function typedDocumentSourceOf(node) {
|
|
|
5845
6421
|
}
|
|
5846
6422
|
}
|
|
5847
6423
|
function resolveTypedDocumentHeader(arg) {
|
|
5848
|
-
if (!
|
|
6424
|
+
if (!import_ts_morph26.Node.isIdentifier(arg)) {
|
|
5849
6425
|
return null;
|
|
5850
6426
|
}
|
|
5851
6427
|
const reference = arg.getText();
|
|
@@ -5855,7 +6431,7 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
5855
6431
|
}
|
|
5856
6432
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
5857
6433
|
for (const decl of resolved.getDeclarations()) {
|
|
5858
|
-
if (!
|
|
6434
|
+
if (!import_ts_morph26.Node.isVariableDeclaration(decl)) {
|
|
5859
6435
|
continue;
|
|
5860
6436
|
}
|
|
5861
6437
|
const init = decl.getInitializer();
|
|
@@ -5888,10 +6464,10 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
5888
6464
|
}
|
|
5889
6465
|
function documentNodeCastTypeArgs(node) {
|
|
5890
6466
|
let current2 = node;
|
|
5891
|
-
while (
|
|
5892
|
-
if (
|
|
6467
|
+
while (import_ts_morph26.Node.isAsExpression(current2) || import_ts_morph26.Node.isParenthesizedExpression(current2)) {
|
|
6468
|
+
if (import_ts_morph26.Node.isAsExpression(current2)) {
|
|
5893
6469
|
const typeNode = current2.getTypeNode();
|
|
5894
|
-
if (typeNode !== void 0 &&
|
|
6470
|
+
if (typeNode !== void 0 && import_ts_morph26.Node.isTypeReference(typeNode)) {
|
|
5895
6471
|
const name = typeNode.getTypeName().getText();
|
|
5896
6472
|
const simpleName = name.includes(".") ? name.split(".").pop() ?? name : name;
|
|
5897
6473
|
if (simpleName === "TypedDocumentNode" || simpleName === "DocumentNode") {
|
|
@@ -5904,7 +6480,7 @@ function documentNodeCastTypeArgs(node) {
|
|
|
5904
6480
|
return null;
|
|
5905
6481
|
}
|
|
5906
6482
|
function operationHeaderFromResultType(typeNode) {
|
|
5907
|
-
if (typeNode === void 0 || !
|
|
6483
|
+
if (typeNode === void 0 || !import_ts_morph26.Node.isTypeReference(typeNode)) {
|
|
5908
6484
|
return null;
|
|
5909
6485
|
}
|
|
5910
6486
|
const name = typeNode.getTypeName().getText();
|
|
@@ -5925,16 +6501,16 @@ function operationHeaderFromResultType(typeNode) {
|
|
|
5925
6501
|
}
|
|
5926
6502
|
function stripDocumentNodeCasts(node) {
|
|
5927
6503
|
let current2 = node;
|
|
5928
|
-
while (
|
|
6504
|
+
while (import_ts_morph26.Node.isAsExpression(current2) || import_ts_morph26.Node.isParenthesizedExpression(current2)) {
|
|
5929
6505
|
current2 = current2.getExpression();
|
|
5930
6506
|
}
|
|
5931
6507
|
return current2;
|
|
5932
6508
|
}
|
|
5933
6509
|
function evaluateObjectLiteralAsJson(node) {
|
|
5934
|
-
if (
|
|
6510
|
+
if (import_ts_morph26.Node.isStringLiteral(node) || import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
5935
6511
|
return node.getLiteralValue();
|
|
5936
6512
|
}
|
|
5937
|
-
if (
|
|
6513
|
+
if (import_ts_morph26.Node.isNumericLiteral(node)) {
|
|
5938
6514
|
return Number(node.getText());
|
|
5939
6515
|
}
|
|
5940
6516
|
const kind = node.getText();
|
|
@@ -5947,17 +6523,17 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
5947
6523
|
if (kind === "null") {
|
|
5948
6524
|
return null;
|
|
5949
6525
|
}
|
|
5950
|
-
if (
|
|
6526
|
+
if (import_ts_morph26.Node.isObjectLiteralExpression(node)) {
|
|
5951
6527
|
const out = {};
|
|
5952
6528
|
for (const prop of node.getProperties()) {
|
|
5953
|
-
if (!
|
|
6529
|
+
if (!import_ts_morph26.Node.isPropertyAssignment(prop)) {
|
|
5954
6530
|
return null;
|
|
5955
6531
|
}
|
|
5956
6532
|
const nameNode = prop.getNameNode();
|
|
5957
6533
|
let name;
|
|
5958
|
-
if (
|
|
6534
|
+
if (import_ts_morph26.Node.isIdentifier(nameNode)) {
|
|
5959
6535
|
name = nameNode.getText();
|
|
5960
|
-
} else if (
|
|
6536
|
+
} else if (import_ts_morph26.Node.isStringLiteral(nameNode) || import_ts_morph26.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
|
|
5961
6537
|
name = nameNode.getLiteralValue();
|
|
5962
6538
|
} else {
|
|
5963
6539
|
return null;
|
|
@@ -5974,7 +6550,7 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
5974
6550
|
}
|
|
5975
6551
|
return out;
|
|
5976
6552
|
}
|
|
5977
|
-
if (
|
|
6553
|
+
if (import_ts_morph26.Node.isArrayLiteralExpression(node)) {
|
|
5978
6554
|
const out = [];
|
|
5979
6555
|
for (const el of node.getElements()) {
|
|
5980
6556
|
const value = evaluateObjectLiteralAsJson(el);
|
|
@@ -5988,8 +6564,8 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
5988
6564
|
return void 0;
|
|
5989
6565
|
}
|
|
5990
6566
|
function resolveGraphqlFileImport(decl) {
|
|
5991
|
-
const importDecl =
|
|
5992
|
-
if (importDecl === null || importDecl === void 0 || !
|
|
6567
|
+
const importDecl = import_ts_morph26.Node.isImportSpecifier(decl) ? decl.getImportDeclaration() : import_ts_morph26.Node.isImportClause(decl) ? decl.getParent() : null;
|
|
6568
|
+
if (importDecl === null || importDecl === void 0 || !import_ts_morph26.Node.isImportDeclaration(importDecl)) {
|
|
5993
6569
|
return null;
|
|
5994
6570
|
}
|
|
5995
6571
|
const specifier = importDecl.getModuleSpecifierValue();
|
|
@@ -6008,7 +6584,7 @@ function resolveGraphqlFileImport(decl) {
|
|
|
6008
6584
|
function enclosingFunctionRoot(node) {
|
|
6009
6585
|
let current2 = node.getParent();
|
|
6010
6586
|
while (current2 !== void 0) {
|
|
6011
|
-
if (
|
|
6587
|
+
if (import_ts_morph26.Node.isFunctionDeclaration(current2) || import_ts_morph26.Node.isFunctionExpression(current2) || import_ts_morph26.Node.isArrowFunction(current2) || import_ts_morph26.Node.isMethodDeclaration(current2)) {
|
|
6012
6588
|
return current2;
|
|
6013
6589
|
}
|
|
6014
6590
|
current2 = current2.getParent();
|
|
@@ -6016,18 +6592,18 @@ function enclosingFunctionRoot(node) {
|
|
|
6016
6592
|
return null;
|
|
6017
6593
|
}
|
|
6018
6594
|
function functionNameOrAnon(func) {
|
|
6019
|
-
if (
|
|
6595
|
+
if (import_ts_morph26.Node.isFunctionDeclaration(func) || import_ts_morph26.Node.isMethodDeclaration(func)) {
|
|
6020
6596
|
return func.getName() ?? "<anon>";
|
|
6021
6597
|
}
|
|
6022
6598
|
const parent = func.getParent();
|
|
6023
|
-
if (parent !== void 0 &&
|
|
6599
|
+
if (parent !== void 0 && import_ts_morph26.Node.isVariableDeclaration(parent)) {
|
|
6024
6600
|
return parent.getName();
|
|
6025
6601
|
}
|
|
6026
6602
|
return "<anon>";
|
|
6027
6603
|
}
|
|
6028
6604
|
|
|
6029
6605
|
// src/discovery/importedCalls.ts
|
|
6030
|
-
var
|
|
6606
|
+
var import_ts_morph27 = require("ts-morph");
|
|
6031
6607
|
function callsResolvingTo(sourceFile, resolution, spec) {
|
|
6032
6608
|
return [
|
|
6033
6609
|
...callsByOriginName(
|
|
@@ -6041,11 +6617,11 @@ function callsResolvingTo(sourceFile, resolution, spec) {
|
|
|
6041
6617
|
function callsByOriginName(sourceFile, resolution, module2, names) {
|
|
6042
6618
|
const candidates = [];
|
|
6043
6619
|
sourceFile.forEachDescendant((node) => {
|
|
6044
|
-
if (!
|
|
6620
|
+
if (!import_ts_morph27.Node.isCallExpression(node) && !import_ts_morph27.Node.isNewExpression(node)) {
|
|
6045
6621
|
return;
|
|
6046
6622
|
}
|
|
6047
6623
|
const callee = node.getExpression();
|
|
6048
|
-
if (
|
|
6624
|
+
if (import_ts_morph27.Node.isIdentifier(callee) && !declaredLocally(callee)) {
|
|
6049
6625
|
candidates.push(node);
|
|
6050
6626
|
}
|
|
6051
6627
|
});
|
|
@@ -6071,7 +6647,7 @@ function callsByOriginName(sourceFile, resolution, module2, names) {
|
|
|
6071
6647
|
function declaredLocally(callee) {
|
|
6072
6648
|
const declarations = callee.getSymbol()?.getDeclarations() ?? [];
|
|
6073
6649
|
return declarations.length > 0 && declarations.every(
|
|
6074
|
-
(declaration) => (
|
|
6650
|
+
(declaration) => (import_ts_morph27.Node.isFunctionDeclaration(declaration) || import_ts_morph27.Node.isClassDeclaration(declaration)) && !declaration.getSourceFile().isInNodeModules()
|
|
6075
6651
|
);
|
|
6076
6652
|
}
|
|
6077
6653
|
|
|
@@ -6089,7 +6665,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
6089
6665
|
);
|
|
6090
6666
|
const results = [];
|
|
6091
6667
|
for (const [node, canonical] of hookCalls) {
|
|
6092
|
-
if (!
|
|
6668
|
+
if (!import_ts_morph28.Node.isCallExpression(node)) {
|
|
6093
6669
|
continue;
|
|
6094
6670
|
}
|
|
6095
6671
|
const operationType = operationTypeByHook.get(canonical);
|
|
@@ -6126,7 +6702,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
6126
6702
|
}
|
|
6127
6703
|
|
|
6128
6704
|
// src/discovery/graphqlImperativeCall.ts
|
|
6129
|
-
var
|
|
6705
|
+
var import_ts_morph29 = require("ts-morph");
|
|
6130
6706
|
function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
6131
6707
|
const isTheClient = clientReceiverCheckFor(sourceFile, match, resolution);
|
|
6132
6708
|
const methodSpec = /* @__PURE__ */ new Map();
|
|
@@ -6138,11 +6714,11 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6138
6714
|
}
|
|
6139
6715
|
const results = [];
|
|
6140
6716
|
sourceFile.forEachDescendant((node) => {
|
|
6141
|
-
if (!
|
|
6717
|
+
if (!import_ts_morph29.Node.isCallExpression(node)) {
|
|
6142
6718
|
return;
|
|
6143
6719
|
}
|
|
6144
6720
|
const callee = node.getExpression();
|
|
6145
|
-
if (!
|
|
6721
|
+
if (!import_ts_morph29.Node.isPropertyAccessExpression(callee)) {
|
|
6146
6722
|
return;
|
|
6147
6723
|
}
|
|
6148
6724
|
const methodName = callee.getName();
|
|
@@ -6154,7 +6730,7 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6154
6730
|
return;
|
|
6155
6731
|
}
|
|
6156
6732
|
const args = node.getArguments();
|
|
6157
|
-
if (args.length === 0 || !
|
|
6733
|
+
if (args.length === 0 || !import_ts_morph29.Node.isObjectLiteralExpression(args[0])) {
|
|
6158
6734
|
return;
|
|
6159
6735
|
}
|
|
6160
6736
|
const config = args[0];
|
|
@@ -6190,16 +6766,16 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6190
6766
|
return results;
|
|
6191
6767
|
}
|
|
6192
6768
|
function imperativeConfigValue(prop) {
|
|
6193
|
-
if (
|
|
6769
|
+
if (import_ts_morph29.Node.isPropertyAssignment(prop)) {
|
|
6194
6770
|
return prop.getInitializer() ?? null;
|
|
6195
6771
|
}
|
|
6196
|
-
if (
|
|
6772
|
+
if (import_ts_morph29.Node.isShorthandPropertyAssignment(prop)) {
|
|
6197
6773
|
const valueSymbol = prop.getValueSymbol();
|
|
6198
6774
|
if (valueSymbol === void 0) {
|
|
6199
6775
|
return null;
|
|
6200
6776
|
}
|
|
6201
6777
|
for (const decl of valueSymbol.getDeclarations()) {
|
|
6202
|
-
if (
|
|
6778
|
+
if (import_ts_morph29.Node.isVariableDeclaration(decl)) {
|
|
6203
6779
|
const init = decl.getInitializer();
|
|
6204
6780
|
if (init !== void 0) {
|
|
6205
6781
|
return init;
|
|
@@ -6212,7 +6788,7 @@ function imperativeConfigValue(prop) {
|
|
|
6212
6788
|
}
|
|
6213
6789
|
|
|
6214
6790
|
// src/discovery/jsxElementRoute.ts
|
|
6215
|
-
var
|
|
6791
|
+
var import_ts_morph30 = require("ts-morph");
|
|
6216
6792
|
var PATH_NOT_LITERAL = "The path this route declares is not written as a string literal, so no path is claimed and this route pairs with nothing";
|
|
6217
6793
|
var ENCLOSING_PATH_NOT_LITERAL = "A route this one is nested under declares its path as something other than a string literal, so the full path is not claimed and this route pairs with nothing";
|
|
6218
6794
|
var SPREAD_NOT_ENUMERATED = "A spread stands in for routes declared elsewhere in this array, and they are not read here, so no path is claimed for any of them";
|
|
@@ -6244,7 +6820,7 @@ function discoverJsxElementRoutes(sourceFile, match, kind, resolution) {
|
|
|
6244
6820
|
}
|
|
6245
6821
|
return;
|
|
6246
6822
|
}
|
|
6247
|
-
if (
|
|
6823
|
+
if (import_ts_morph30.Node.isCallExpression(node) && callsAFactory(node, factoryNames)) {
|
|
6248
6824
|
results.push(
|
|
6249
6825
|
...unitsForRouteArray(node, match, elementsNames, kind, resolution)
|
|
6250
6826
|
);
|
|
@@ -6266,7 +6842,7 @@ function localNamesFor(sourceFile, match, exported) {
|
|
|
6266
6842
|
return local;
|
|
6267
6843
|
}
|
|
6268
6844
|
function asRouteJsx(node, routeNames) {
|
|
6269
|
-
if (!
|
|
6845
|
+
if (!import_ts_morph30.Node.isJsxSelfClosingElement(node) && !import_ts_morph30.Node.isJsxElement(node)) {
|
|
6270
6846
|
return null;
|
|
6271
6847
|
}
|
|
6272
6848
|
return isRouteJsx(node, routeNames) ? node : null;
|
|
@@ -6276,15 +6852,15 @@ function isRouteJsx(node, routeNames) {
|
|
|
6276
6852
|
return tag !== null && routeNames.has(tag.getText());
|
|
6277
6853
|
}
|
|
6278
6854
|
function tagNameOf(node) {
|
|
6279
|
-
const tag =
|
|
6280
|
-
return
|
|
6855
|
+
const tag = import_ts_morph30.Node.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
|
|
6856
|
+
return import_ts_morph30.Node.isIdentifier(tag) ? tag : null;
|
|
6281
6857
|
}
|
|
6282
6858
|
function attributesOf(node) {
|
|
6283
|
-
return
|
|
6859
|
+
return import_ts_morph30.Node.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
|
|
6284
6860
|
}
|
|
6285
6861
|
function attributeValueOf(node, name) {
|
|
6286
6862
|
for (const attribute of attributesOf(node)) {
|
|
6287
|
-
if (!
|
|
6863
|
+
if (!import_ts_morph30.Node.isJsxAttribute(attribute)) {
|
|
6288
6864
|
continue;
|
|
6289
6865
|
}
|
|
6290
6866
|
if (attribute.getNameNode().getText() !== name) {
|
|
@@ -6295,8 +6871,8 @@ function attributeValueOf(node, name) {
|
|
|
6295
6871
|
return null;
|
|
6296
6872
|
}
|
|
6297
6873
|
function literalStringOf2(value) {
|
|
6298
|
-
const unwrapped2 =
|
|
6299
|
-
if (
|
|
6874
|
+
const unwrapped2 = import_ts_morph30.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
6875
|
+
if (import_ts_morph30.Node.isStringLiteral(unwrapped2) || import_ts_morph30.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
6300
6876
|
return unwrapped2.getLiteralValue();
|
|
6301
6877
|
}
|
|
6302
6878
|
return null;
|
|
@@ -6316,8 +6892,8 @@ function elementTargetOfValue(value) {
|
|
|
6316
6892
|
if (value === null) {
|
|
6317
6893
|
return { kind: "absent" };
|
|
6318
6894
|
}
|
|
6319
|
-
const unwrapped2 =
|
|
6320
|
-
if (!
|
|
6895
|
+
const unwrapped2 = import_ts_morph30.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
6896
|
+
if (!import_ts_morph30.Node.isJsxSelfClosingElement(unwrapped2) && !import_ts_morph30.Node.isJsxElement(unwrapped2)) {
|
|
6321
6897
|
return { kind: "unreadable" };
|
|
6322
6898
|
}
|
|
6323
6899
|
const tag = tagNameOf(unwrapped2);
|
|
@@ -6329,7 +6905,7 @@ function elementTargetOfValue(value) {
|
|
|
6329
6905
|
function composedPrefixOf(node, match, routeNames) {
|
|
6330
6906
|
const enclosing = [];
|
|
6331
6907
|
for (const ancestor of node.getAncestors()) {
|
|
6332
|
-
if (
|
|
6908
|
+
if (import_ts_morph30.Node.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
|
|
6333
6909
|
enclosing.push(ancestor);
|
|
6334
6910
|
}
|
|
6335
6911
|
}
|
|
@@ -6445,14 +7021,14 @@ function abstention(at, kind, sentence, label) {
|
|
|
6445
7021
|
}
|
|
6446
7022
|
function callsAFactory(call, factoryNames) {
|
|
6447
7023
|
const callee = call.getExpression();
|
|
6448
|
-
return
|
|
7024
|
+
return import_ts_morph30.Node.isIdentifier(callee) && factoryNames.has(callee.getText());
|
|
6449
7025
|
}
|
|
6450
7026
|
function unitsForRouteArray(call, match, elementsNames, kind, resolution) {
|
|
6451
7027
|
const first = call.getArguments()[0];
|
|
6452
7028
|
if (first === void 0) {
|
|
6453
7029
|
return [];
|
|
6454
7030
|
}
|
|
6455
|
-
if (
|
|
7031
|
+
if (import_ts_morph30.Node.isJsxElement(first) || import_ts_morph30.Node.isJsxSelfClosingElement(first) || import_ts_morph30.Node.isCallExpression(first) && callsAFactory(first, elementsNames)) {
|
|
6456
7032
|
return [];
|
|
6457
7033
|
}
|
|
6458
7034
|
const array = arrayLiteralOf(first, resolution);
|
|
@@ -6477,7 +7053,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
6477
7053
|
const nestedIn = new Set(ancestry).add(array);
|
|
6478
7054
|
const results = [];
|
|
6479
7055
|
for (const element of array.getElements()) {
|
|
6480
|
-
if (
|
|
7056
|
+
if (import_ts_morph30.Node.isSpreadElement(element)) {
|
|
6481
7057
|
results.push(
|
|
6482
7058
|
abstention(
|
|
6483
7059
|
element,
|
|
@@ -6488,7 +7064,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
6488
7064
|
);
|
|
6489
7065
|
continue;
|
|
6490
7066
|
}
|
|
6491
|
-
if (!
|
|
7067
|
+
if (!import_ts_morph30.Node.isObjectLiteralExpression(element)) {
|
|
6492
7068
|
results.push(
|
|
6493
7069
|
abstention(
|
|
6494
7070
|
element,
|
|
@@ -6577,7 +7153,7 @@ function ownPathOfObject(object, match) {
|
|
|
6577
7153
|
}
|
|
6578
7154
|
if (match.indexAttribute !== void 0) {
|
|
6579
7155
|
const indexValue = routePropertyOf(object, match.indexAttribute);
|
|
6580
|
-
if (indexValue !== null &&
|
|
7156
|
+
if (indexValue !== null && import_ts_morph30.Node.isTrueLiteral(indexValue)) {
|
|
6581
7157
|
return { kind: "inherited" };
|
|
6582
7158
|
}
|
|
6583
7159
|
}
|
|
@@ -6591,17 +7167,17 @@ function objectLabelOf(target) {
|
|
|
6591
7167
|
return target.kind === "named" ? target.identifier.getText() : "declaration";
|
|
6592
7168
|
}
|
|
6593
7169
|
function labelOfExpression(node) {
|
|
6594
|
-
if (
|
|
7170
|
+
if (import_ts_morph30.Node.isIdentifier(node)) {
|
|
6595
7171
|
return node.getText();
|
|
6596
7172
|
}
|
|
6597
|
-
if (
|
|
7173
|
+
if (import_ts_morph30.Node.isCallExpression(node)) {
|
|
6598
7174
|
return node.getExpression().getText();
|
|
6599
7175
|
}
|
|
6600
7176
|
return node.getKindName();
|
|
6601
7177
|
}
|
|
6602
7178
|
|
|
6603
7179
|
// src/discovery/packageExports.ts
|
|
6604
|
-
var
|
|
7180
|
+
var import_ts_morph32 = require("ts-morph");
|
|
6605
7181
|
|
|
6606
7182
|
// src/packageExports.ts
|
|
6607
7183
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
@@ -6793,13 +7369,13 @@ function sameDeclaration(a, b) {
|
|
|
6793
7369
|
}
|
|
6794
7370
|
|
|
6795
7371
|
// src/discovery/factorySurface.ts
|
|
6796
|
-
var
|
|
7372
|
+
var import_ts_morph31 = require("ts-morph");
|
|
6797
7373
|
var MAX_BUILDER_HOPS = 2;
|
|
6798
7374
|
function surfaceMethods(decl) {
|
|
6799
|
-
if (
|
|
7375
|
+
if (import_ts_morph31.Node.isClassDeclaration(decl)) {
|
|
6800
7376
|
return surfaceClassMethods(decl);
|
|
6801
7377
|
}
|
|
6802
|
-
if (
|
|
7378
|
+
if (import_ts_morph31.Node.isFunctionDeclaration(decl) || import_ts_morph31.Node.isFunctionExpression(decl) || import_ts_morph31.Node.isArrowFunction(decl) || import_ts_morph31.Node.isMethodDeclaration(decl)) {
|
|
6803
7379
|
return surfaceFactoryReturnMethods(decl);
|
|
6804
7380
|
}
|
|
6805
7381
|
return [];
|
|
@@ -6808,7 +7384,7 @@ function surfaceClassMethods(cls) {
|
|
|
6808
7384
|
const out = [];
|
|
6809
7385
|
const seen = /* @__PURE__ */ new Set();
|
|
6810
7386
|
for (const method of cls.getInstanceMethods()) {
|
|
6811
|
-
if (method.hasModifier(
|
|
7387
|
+
if (method.hasModifier(import_ts_morph31.SyntaxKind.PrivateKeyword)) {
|
|
6812
7388
|
continue;
|
|
6813
7389
|
}
|
|
6814
7390
|
const name = method.getName();
|
|
@@ -6819,7 +7395,7 @@ function surfaceClassMethods(cls) {
|
|
|
6819
7395
|
out.push({ func: method, name });
|
|
6820
7396
|
}
|
|
6821
7397
|
for (const method of cls.getStaticMethods()) {
|
|
6822
|
-
if (method.hasModifier(
|
|
7398
|
+
if (method.hasModifier(import_ts_morph31.SyntaxKind.PrivateKeyword)) {
|
|
6823
7399
|
continue;
|
|
6824
7400
|
}
|
|
6825
7401
|
const name = method.getName();
|
|
@@ -6838,9 +7414,9 @@ function surfaceFactoryReturnMethods(fn) {
|
|
|
6838
7414
|
return out;
|
|
6839
7415
|
}
|
|
6840
7416
|
function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
6841
|
-
if (
|
|
7417
|
+
if (import_ts_morph31.Node.isArrowFunction(fn)) {
|
|
6842
7418
|
const body2 = fn.getBody();
|
|
6843
|
-
if (
|
|
7419
|
+
if (import_ts_morph31.Node.isExpression(body2)) {
|
|
6844
7420
|
collectFromReturnValue(body2, out, seen, depth);
|
|
6845
7421
|
return;
|
|
6846
7422
|
}
|
|
@@ -6851,11 +7427,11 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
|
6851
7427
|
}
|
|
6852
7428
|
const returns = [];
|
|
6853
7429
|
body.forEachDescendant((node, traversal) => {
|
|
6854
|
-
if (
|
|
7430
|
+
if (import_ts_morph31.Node.isFunctionDeclaration(node) || import_ts_morph31.Node.isFunctionExpression(node) || import_ts_morph31.Node.isArrowFunction(node) || import_ts_morph31.Node.isMethodDeclaration(node) || import_ts_morph31.Node.isConstructorDeclaration(node) || import_ts_morph31.Node.isGetAccessorDeclaration(node) || import_ts_morph31.Node.isSetAccessorDeclaration(node)) {
|
|
6855
7431
|
traversal.skip();
|
|
6856
7432
|
return;
|
|
6857
7433
|
}
|
|
6858
|
-
if (
|
|
7434
|
+
if (import_ts_morph31.Node.isReturnStatement(node)) {
|
|
6859
7435
|
returns.push(node);
|
|
6860
7436
|
}
|
|
6861
7437
|
});
|
|
@@ -6869,15 +7445,15 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
|
6869
7445
|
}
|
|
6870
7446
|
function collectFromReturnValue(node, out, seen, depth) {
|
|
6871
7447
|
const expr = peelParens(node);
|
|
6872
|
-
if (
|
|
7448
|
+
if (import_ts_morph31.Node.isObjectLiteralExpression(expr)) {
|
|
6873
7449
|
collectFromObjectLiteral(expr, out, seen);
|
|
6874
7450
|
return;
|
|
6875
7451
|
}
|
|
6876
|
-
if (depth >= MAX_BUILDER_HOPS || !
|
|
7452
|
+
if (depth >= MAX_BUILDER_HOPS || !import_ts_morph31.Node.isCallExpression(expr)) {
|
|
6877
7453
|
return;
|
|
6878
7454
|
}
|
|
6879
7455
|
const callee = expr.getExpression();
|
|
6880
|
-
if (!
|
|
7456
|
+
if (!import_ts_morph31.Node.isIdentifier(callee)) {
|
|
6881
7457
|
return;
|
|
6882
7458
|
}
|
|
6883
7459
|
const helper = sameFileFunctionBehind(callee);
|
|
@@ -6900,12 +7476,12 @@ function functionAmong(declarations, filePath) {
|
|
|
6900
7476
|
if (decl.getSourceFile().getFilePath() !== filePath) {
|
|
6901
7477
|
continue;
|
|
6902
7478
|
}
|
|
6903
|
-
if (
|
|
7479
|
+
if (import_ts_morph31.Node.isFunctionDeclaration(decl)) {
|
|
6904
7480
|
return decl;
|
|
6905
7481
|
}
|
|
6906
|
-
if (
|
|
7482
|
+
if (import_ts_morph31.Node.isVariableDeclaration(decl)) {
|
|
6907
7483
|
const init = decl.getInitializer();
|
|
6908
|
-
if (init !== void 0 && (
|
|
7484
|
+
if (init !== void 0 && (import_ts_morph31.Node.isArrowFunction(init) || import_ts_morph31.Node.isFunctionExpression(init))) {
|
|
6909
7485
|
return init;
|
|
6910
7486
|
}
|
|
6911
7487
|
}
|
|
@@ -6914,11 +7490,11 @@ function functionAmong(declarations, filePath) {
|
|
|
6914
7490
|
}
|
|
6915
7491
|
function collectFromObjectLiteral(node, out, seen) {
|
|
6916
7492
|
const e = peelParens(node);
|
|
6917
|
-
if (!
|
|
7493
|
+
if (!import_ts_morph31.Node.isObjectLiteralExpression(e)) {
|
|
6918
7494
|
return;
|
|
6919
7495
|
}
|
|
6920
7496
|
for (const prop of e.getProperties()) {
|
|
6921
|
-
if (
|
|
7497
|
+
if (import_ts_morph31.Node.isMethodDeclaration(prop)) {
|
|
6922
7498
|
const name = prop.getName();
|
|
6923
7499
|
if (seen.has(name)) {
|
|
6924
7500
|
continue;
|
|
@@ -6927,16 +7503,16 @@ function collectFromObjectLiteral(node, out, seen) {
|
|
|
6927
7503
|
out.push({ func: prop, name });
|
|
6928
7504
|
continue;
|
|
6929
7505
|
}
|
|
6930
|
-
if (
|
|
7506
|
+
if (import_ts_morph31.Node.isPropertyAssignment(prop)) {
|
|
6931
7507
|
const init = prop.getInitializer();
|
|
6932
7508
|
if (init === void 0) {
|
|
6933
7509
|
continue;
|
|
6934
7510
|
}
|
|
6935
7511
|
let v3 = init;
|
|
6936
|
-
while (
|
|
7512
|
+
while (import_ts_morph31.Node.isParenthesizedExpression(v3)) {
|
|
6937
7513
|
v3 = v3.getExpression();
|
|
6938
7514
|
}
|
|
6939
|
-
if (
|
|
7515
|
+
if (import_ts_morph31.Node.isArrowFunction(v3) || import_ts_morph31.Node.isFunctionExpression(v3)) {
|
|
6940
7516
|
const name = prop.getName();
|
|
6941
7517
|
if (seen.has(name)) {
|
|
6942
7518
|
continue;
|
|
@@ -6945,7 +7521,7 @@ function collectFromObjectLiteral(node, out, seen) {
|
|
|
6945
7521
|
out.push({ func: v3, name });
|
|
6946
7522
|
}
|
|
6947
7523
|
}
|
|
6948
|
-
if (
|
|
7524
|
+
if (import_ts_morph31.Node.isShorthandPropertyAssignment(prop)) {
|
|
6949
7525
|
collectShorthandFunction(prop, out, seen);
|
|
6950
7526
|
}
|
|
6951
7527
|
}
|
|
@@ -7008,9 +7584,9 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
|
|
|
7008
7584
|
(decl) => sourceDeclarationsBehind(decl, resolution)
|
|
7009
7585
|
);
|
|
7010
7586
|
for (const decl of candidates) {
|
|
7011
|
-
if (
|
|
7587
|
+
if (import_ts_morph32.Node.isVariableDeclaration(decl)) {
|
|
7012
7588
|
const init = decl.getInitializer();
|
|
7013
|
-
if (init !== void 0 && (
|
|
7589
|
+
if (init !== void 0 && (import_ts_morph32.Node.isArrowFunction(init) || import_ts_morph32.Node.isFunctionExpression(init))) {
|
|
7014
7590
|
results.push(buildUnit(init, kind, exportName, entry));
|
|
7015
7591
|
for (const m of surfaceMethods(init)) {
|
|
7016
7592
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
@@ -7020,7 +7596,7 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
|
|
|
7020
7596
|
}
|
|
7021
7597
|
continue;
|
|
7022
7598
|
}
|
|
7023
|
-
if (
|
|
7599
|
+
if (import_ts_morph32.Node.isClassDeclaration(decl)) {
|
|
7024
7600
|
for (const m of surfaceMethods(decl)) {
|
|
7025
7601
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
7026
7602
|
}
|
|
@@ -7065,7 +7641,7 @@ function buildSurfacedUnit(m, kind, parentExportName, entry) {
|
|
|
7065
7641
|
}
|
|
7066
7642
|
|
|
7067
7643
|
// src/discovery/packageImport.ts
|
|
7068
|
-
var
|
|
7644
|
+
var import_ts_morph33 = require("ts-morph");
|
|
7069
7645
|
function isLanguageLib(file) {
|
|
7070
7646
|
return /[\\/]typescript[\\/]lib[\\/]lib\..*\.d\.ts$/.test(file.getFilePath());
|
|
7071
7647
|
}
|
|
@@ -7086,13 +7662,13 @@ function splitPackageSpec(spec) {
|
|
|
7086
7662
|
};
|
|
7087
7663
|
}
|
|
7088
7664
|
function enclosingFunctionName(func) {
|
|
7089
|
-
if (
|
|
7665
|
+
if (import_ts_morph33.Node.isFunctionDeclaration(func) || import_ts_morph33.Node.isMethodDeclaration(func)) {
|
|
7090
7666
|
const n = func.getName?.();
|
|
7091
7667
|
if (typeof n === "string" && n.length > 0) {
|
|
7092
7668
|
return n;
|
|
7093
7669
|
}
|
|
7094
7670
|
}
|
|
7095
|
-
if (
|
|
7671
|
+
if (import_ts_morph33.Node.isFunctionExpression(func)) {
|
|
7096
7672
|
const n = func.getName();
|
|
7097
7673
|
if (typeof n === "string" && n.length > 0) {
|
|
7098
7674
|
return n;
|
|
@@ -7100,10 +7676,10 @@ function enclosingFunctionName(func) {
|
|
|
7100
7676
|
}
|
|
7101
7677
|
const parent = func.getParent();
|
|
7102
7678
|
if (parent !== void 0) {
|
|
7103
|
-
if (
|
|
7679
|
+
if (import_ts_morph33.Node.isVariableDeclaration(parent)) {
|
|
7104
7680
|
return parent.getName();
|
|
7105
7681
|
}
|
|
7106
|
-
if (
|
|
7682
|
+
if (import_ts_morph33.Node.isPropertyAssignment(parent)) {
|
|
7107
7683
|
return parent.getName();
|
|
7108
7684
|
}
|
|
7109
7685
|
}
|
|
@@ -7122,7 +7698,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7122
7698
|
const calls = [];
|
|
7123
7699
|
const candidates = /* @__PURE__ */ new Set();
|
|
7124
7700
|
sourceFile.forEachDescendant((node) => {
|
|
7125
|
-
if (!
|
|
7701
|
+
if (!import_ts_morph33.Node.isCallExpression(node)) {
|
|
7126
7702
|
return;
|
|
7127
7703
|
}
|
|
7128
7704
|
calls.push(node);
|
|
@@ -7130,7 +7706,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7130
7706
|
if (couldBePackageLinked(callee, packages)) {
|
|
7131
7707
|
candidates.add(callee);
|
|
7132
7708
|
}
|
|
7133
|
-
if (
|
|
7709
|
+
if (import_ts_morph33.Node.isPropertyAccessExpression(callee) && couldBePackageLinked(callee.getExpression(), packages)) {
|
|
7134
7710
|
candidates.add(callee.getExpression());
|
|
7135
7711
|
}
|
|
7136
7712
|
});
|
|
@@ -7152,7 +7728,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7152
7728
|
if (direct !== null) {
|
|
7153
7729
|
return direct;
|
|
7154
7730
|
}
|
|
7155
|
-
if (!
|
|
7731
|
+
if (!import_ts_morph33.Node.isPropertyAccessExpression(callee)) {
|
|
7156
7732
|
return null;
|
|
7157
7733
|
}
|
|
7158
7734
|
const subject = originOf(callee.getExpression());
|
|
@@ -7177,7 +7753,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7177
7753
|
return results;
|
|
7178
7754
|
}
|
|
7179
7755
|
function couldBePackageLinked(value, packages) {
|
|
7180
|
-
if (!
|
|
7756
|
+
if (!import_ts_morph33.Node.isIdentifier(value)) {
|
|
7181
7757
|
return true;
|
|
7182
7758
|
}
|
|
7183
7759
|
const declarations = value.getSymbol()?.getDeclarations() ?? [];
|
|
@@ -7185,7 +7761,7 @@ function couldBePackageLinked(value, packages) {
|
|
|
7185
7761
|
return true;
|
|
7186
7762
|
}
|
|
7187
7763
|
return !declarations.every(
|
|
7188
|
-
(declaration) =>
|
|
7764
|
+
(declaration) => import_ts_morph33.Node.isFunctionDeclaration(declaration) || import_ts_morph33.Node.isMethodDeclaration(declaration) || import_ts_morph33.Node.isClassDeclaration(declaration) || import_ts_morph33.Node.isImportSpecifier(declaration) && importAimsElsewhere(declaration, packages)
|
|
7189
7765
|
);
|
|
7190
7766
|
}
|
|
7191
7767
|
function importAimsElsewhere(declaration, packages) {
|
|
@@ -7242,156 +7818,9 @@ var import_ts_morph34 = require("ts-morph");
|
|
|
7242
7818
|
var import_resolution3 = require("@suss/resolution");
|
|
7243
7819
|
|
|
7244
7820
|
// src/resolve/routePath.ts
|
|
7245
|
-
var
|
|
7246
|
-
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
7247
|
-
var URL_SCHEME = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\//;
|
|
7248
|
-
var URL_ORIGIN = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\/[^/]*/;
|
|
7249
|
-
var PROTOCOL_RELATIVE = /^\/\//;
|
|
7250
|
-
var PROTOCOL_RELATIVE_ORIGIN = /^\/\/[^/]*/;
|
|
7251
|
-
function isAbsoluteUrlLiteral(text) {
|
|
7252
|
-
return URL_SCHEME.test(text) || PROTOCOL_RELATIVE.test(text);
|
|
7253
|
-
}
|
|
7254
|
-
function stripOriginManually(text) {
|
|
7255
|
-
if (URL_SCHEME.test(text)) {
|
|
7256
|
-
return text.replace(URL_ORIGIN, "");
|
|
7257
|
-
}
|
|
7258
|
-
if (PROTOCOL_RELATIVE.test(text)) {
|
|
7259
|
-
return text.replace(PROTOCOL_RELATIVE_ORIGIN, "");
|
|
7260
|
-
}
|
|
7261
|
-
return text;
|
|
7262
|
-
}
|
|
7263
|
-
function stripQueryAndFragment(text) {
|
|
7264
|
-
const idx = text.search(/[?#]/);
|
|
7265
|
-
return idx === -1 ? text : text.slice(0, idx);
|
|
7266
|
-
}
|
|
7267
|
-
var SUBSTITUTION = "\uFFFF";
|
|
7268
|
-
var AUTHORITY_OPENER = /^(?:[-+.\uFFFFa-zA-Z0-9]+:\/\/|\/\/)/;
|
|
7269
|
-
function originEndOf(flattened) {
|
|
7270
|
-
const opener = AUTHORITY_OPENER.exec(flattened);
|
|
7271
|
-
if (opener === null) {
|
|
7272
|
-
return 0;
|
|
7273
|
-
}
|
|
7274
|
-
const slash = flattened.indexOf("/", opener[0].length);
|
|
7275
|
-
return slash === -1 ? flattened.length : slash;
|
|
7276
|
-
}
|
|
7277
|
-
function appendPathText(path14, text) {
|
|
7278
|
-
const idx = text.search(/[?#]/);
|
|
7279
|
-
if (idx === -1) {
|
|
7280
|
-
return { path: path14 + text, stop: false };
|
|
7281
|
-
}
|
|
7282
|
-
return { path: path14 + text.slice(0, idx), stop: true };
|
|
7283
|
-
}
|
|
7284
|
-
function parseAbsoluteUrl(text) {
|
|
7285
|
-
try {
|
|
7286
|
-
return new URL(text);
|
|
7287
|
-
} catch {
|
|
7288
|
-
}
|
|
7289
|
-
if (!PROTOCOL_RELATIVE.test(text)) {
|
|
7290
|
-
return void 0;
|
|
7291
|
-
}
|
|
7292
|
-
try {
|
|
7293
|
-
return new URL(`https:${text}`);
|
|
7294
|
-
} catch {
|
|
7295
|
-
return void 0;
|
|
7296
|
-
}
|
|
7297
|
-
}
|
|
7298
|
-
function pathnameOfAbsoluteLiteral(text) {
|
|
7299
|
-
const parsed = parseAbsoluteUrl(text);
|
|
7300
|
-
if (parsed !== void 0) {
|
|
7301
|
-
return parsed.pathname;
|
|
7302
|
-
}
|
|
7303
|
-
return stripQueryAndFragment(stripOriginManually(text));
|
|
7304
|
-
}
|
|
7305
|
-
function pathFromLiteralUrl(text) {
|
|
7306
|
-
const path14 = isAbsoluteUrlLiteral(text) ? pathnameOfAbsoluteLiteral(text) : stripQueryAndFragment(text);
|
|
7307
|
-
return path14 === "" ? void 0 : path14;
|
|
7308
|
-
}
|
|
7309
|
-
function pathFromTemplateUrl(arg, resolution) {
|
|
7310
|
-
const headText = arg.getHead().getLiteralText();
|
|
7311
|
-
const spans = arg.getTemplateSpans();
|
|
7312
|
-
const tails = spans.map((span) => span.getLiteral().getLiteralText());
|
|
7313
|
-
const originEnd = originEndOf([headText, ...tails].join(SUBSTITUTION));
|
|
7314
|
-
const head = appendPathText("", headText.slice(originEnd));
|
|
7315
|
-
let path14 = head.path;
|
|
7316
|
-
let stop = head.stop;
|
|
7317
|
-
let at = headText.length;
|
|
7318
|
-
for (let i = 0; i < spans.length && !stop; i++) {
|
|
7319
|
-
const span = spans[i];
|
|
7320
|
-
const tailText = tails[i];
|
|
7321
|
-
if (span === void 0 || tailText === void 0) {
|
|
7322
|
-
continue;
|
|
7323
|
-
}
|
|
7324
|
-
if (at >= originEnd) {
|
|
7325
|
-
path14 += holeText(span.getExpression(), resolution);
|
|
7326
|
-
}
|
|
7327
|
-
at += SUBSTITUTION.length;
|
|
7328
|
-
const appended = appendPathText(
|
|
7329
|
-
path14,
|
|
7330
|
-
tailText.slice(Math.max(0, originEnd - at))
|
|
7331
|
-
);
|
|
7332
|
-
path14 = appended.path;
|
|
7333
|
-
stop = appended.stop;
|
|
7334
|
-
at += tailText.length;
|
|
7335
|
-
}
|
|
7336
|
-
return path14 === "" ? void 0 : path14;
|
|
7337
|
-
}
|
|
7338
|
-
function pathFromUrlNode(node, resolution) {
|
|
7339
|
-
if (import_ts_morph33.Node.isStringLiteral(node)) {
|
|
7340
|
-
return pathFromLiteralUrl(node.getLiteralValue());
|
|
7341
|
-
}
|
|
7342
|
-
if (import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
7343
|
-
return pathFromLiteralUrl(node.getLiteralValue());
|
|
7344
|
-
}
|
|
7345
|
-
if (import_ts_morph33.Node.isTemplateExpression(node)) {
|
|
7346
|
-
return pathFromTemplateUrl(node, resolution);
|
|
7347
|
-
}
|
|
7348
|
-
if (import_ts_morph33.Node.isBinaryExpression(node)) {
|
|
7349
|
-
const joined = joinedStringOf(node, resolution);
|
|
7350
|
-
return joined === void 0 ? void 0 : pathFromLiteralUrl(joined);
|
|
7351
|
-
}
|
|
7352
|
-
return void 0;
|
|
7353
|
-
}
|
|
7354
|
-
function joinedStringOf(node, resolution) {
|
|
7355
|
-
if (import_ts_morph33.Node.isStringLiteral(node) || import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
7356
|
-
return node.getLiteralValue();
|
|
7357
|
-
}
|
|
7358
|
-
if (import_ts_morph33.Node.isBinaryExpression(node) && node.getOperatorToken().getText() === "+") {
|
|
7359
|
-
const left = joinedStringOf(node.getLeft(), resolution);
|
|
7360
|
-
const right = joinedStringOf(node.getRight(), resolution);
|
|
7361
|
-
return left === void 0 || right === void 0 ? void 0 : left + right;
|
|
7362
|
-
}
|
|
7363
|
-
const written = resolution?.resolveWrittenValue(node) ?? null;
|
|
7364
|
-
return written === null || written === node ? void 0 : joinedStringOf(written, resolution);
|
|
7365
|
-
}
|
|
7366
|
-
function placeholderName(expr) {
|
|
7367
|
-
if (import_ts_morph33.Node.isIdentifier(expr)) {
|
|
7368
|
-
return expr.getText();
|
|
7369
|
-
}
|
|
7370
|
-
if (import_ts_morph33.Node.isPropertyAccessExpression(expr)) {
|
|
7371
|
-
return expr.getName();
|
|
7372
|
-
}
|
|
7373
|
-
return "param";
|
|
7374
|
-
}
|
|
7375
|
-
function holeText(expr, resolution) {
|
|
7376
|
-
const written = resolution?.resolveWrittenValue(expr) ?? null;
|
|
7377
|
-
if (written === null) {
|
|
7378
|
-
return (0, import_behavioral_ir2.patternHole)(placeholderName(expr));
|
|
7379
|
-
}
|
|
7380
|
-
if (emptyStringLiteral(written)) {
|
|
7381
|
-
return "";
|
|
7382
|
-
}
|
|
7383
|
-
return pathFromUrlNode(written, resolution) ?? (0, import_behavioral_ir2.patternHole)(placeholderName(expr));
|
|
7384
|
-
}
|
|
7385
|
-
function emptyStringLiteral(node) {
|
|
7386
|
-
return (import_ts_morph33.Node.isStringLiteral(node) || import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(node)) && node.getLiteralValue() === "";
|
|
7387
|
-
}
|
|
7821
|
+
var import_values4 = require("@suss/values");
|
|
7388
7822
|
function pathFromArgument(arg, resolution) {
|
|
7389
|
-
|
|
7390
|
-
if (written !== void 0) {
|
|
7391
|
-
return written;
|
|
7392
|
-
}
|
|
7393
|
-
const resolved = resolution?.resolveWrittenValue(arg) ?? null;
|
|
7394
|
-
return resolved !== null ? pathFromUrlNode(resolved, resolution) : void 0;
|
|
7823
|
+
return (0, import_values4.pathOf)(evaluatedValue(arg, resolution));
|
|
7395
7824
|
}
|
|
7396
7825
|
|
|
7397
7826
|
// src/discovery/registrationCall.ts
|
|
@@ -7804,32 +8233,14 @@ function mountTargetsAmong(args, targetPosition, knownSubjectIds, resolution) {
|
|
|
7804
8233
|
}
|
|
7805
8234
|
return targets;
|
|
7806
8235
|
}
|
|
7807
|
-
function stringProperty(obj, name) {
|
|
7808
|
-
if (!import_ts_morph34.Node.isObjectLiteralExpression(obj)) {
|
|
7809
|
-
return null;
|
|
7810
|
-
}
|
|
7811
|
-
const property = obj.getProperty(name);
|
|
7812
|
-
if (property === void 0 || !import_ts_morph34.Node.isPropertyAssignment(property)) {
|
|
7813
|
-
return null;
|
|
7814
|
-
}
|
|
7815
|
-
const value = property.getInitializer();
|
|
7816
|
-
if (value !== void 0 && (import_ts_morph34.Node.isStringLiteral(value) || import_ts_morph34.Node.isNoSubstitutionTemplateLiteral(value))) {
|
|
7817
|
-
return value.getLiteralValue();
|
|
7818
|
-
}
|
|
7819
|
-
return null;
|
|
7820
|
-
}
|
|
7821
8236
|
function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
7822
8237
|
if (binding.method.type === "fromArgumentProperty" && binding.path.type === "fromArgumentProperty" && binding.method.position === binding.path.position) {
|
|
7823
8238
|
const arg = call.getArguments()[binding.method.position];
|
|
7824
8239
|
if (arg === void 0) {
|
|
7825
8240
|
return null;
|
|
7826
8241
|
}
|
|
7827
|
-
const
|
|
7828
|
-
|
|
7829
|
-
return null;
|
|
7830
|
-
}
|
|
7831
|
-
const method2 = stringProperty(routeObject, binding.method.property);
|
|
7832
|
-
const path15 = stringProperty(routeObject, binding.path.property);
|
|
8242
|
+
const method2 = stringPropertyOf(arg, binding.method.property, resolution);
|
|
8243
|
+
const path15 = stringPropertyOf(arg, binding.path.property, resolution);
|
|
7833
8244
|
if (method2 === null || path15 === null) {
|
|
7834
8245
|
return null;
|
|
7835
8246
|
}
|
|
@@ -8029,7 +8440,7 @@ var import_resolution4 = require("@suss/resolution");
|
|
|
8029
8440
|
|
|
8030
8441
|
// src/resolve/unfollowedCall.ts
|
|
8031
8442
|
var import_ts_morph36 = require("ts-morph");
|
|
8032
|
-
var
|
|
8443
|
+
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
8033
8444
|
function isInExternalCode(sourceFile) {
|
|
8034
8445
|
if (sourceFile.isDeclarationFile()) {
|
|
8035
8446
|
return true;
|
|
@@ -8684,7 +9095,7 @@ function parameterReads(func, parameterNames2, barriers = NO_BARRIERS) {
|
|
|
8684
9095
|
|
|
8685
9096
|
// src/resolve/readName.ts
|
|
8686
9097
|
var import_ts_morph41 = require("ts-morph");
|
|
8687
|
-
var
|
|
9098
|
+
var import_behavioral_ir3 = require("@suss/behavioral-ir");
|
|
8688
9099
|
var MAX_HELPER_HOPS = 2;
|
|
8689
9100
|
var UNNAMED_HOLE = "param";
|
|
8690
9101
|
function readName(expr, options = {}) {
|
|
@@ -8699,7 +9110,7 @@ function readName(expr, options = {}) {
|
|
|
8699
9110
|
return name;
|
|
8700
9111
|
}
|
|
8701
9112
|
const reference = referenceIn(expr);
|
|
8702
|
-
return reference === null ? null : (0,
|
|
9113
|
+
return reference === null ? null : (0, import_behavioral_ir3.referenceName)(reference);
|
|
8703
9114
|
}
|
|
8704
9115
|
function referenceIn(expr) {
|
|
8705
9116
|
const fromParameter = parameterPath(expr);
|
|
@@ -8948,7 +9359,7 @@ function boundOnce(expr, ctx) {
|
|
|
8948
9359
|
}
|
|
8949
9360
|
function readOrHole(expr, ctx) {
|
|
8950
9361
|
const name = read(expr, ctx);
|
|
8951
|
-
return name ?? (0,
|
|
9362
|
+
return name ?? (0, import_behavioral_ir3.patternHole)(holeName(expr, ctx));
|
|
8952
9363
|
}
|
|
8953
9364
|
function holeName(expr, ctx) {
|
|
8954
9365
|
const bound = boundOnce(expr, ctx);
|
|
@@ -9015,7 +9426,7 @@ function madeExpression(receiver) {
|
|
|
9015
9426
|
}
|
|
9016
9427
|
function callOpsFor(call, resolveWrittenValue, originatesFrom, anchorCallsOf) {
|
|
9017
9428
|
const resolve2 = resolveWrittenValue ?? (() => null);
|
|
9018
|
-
const expression =
|
|
9429
|
+
const expression = calleeOf3(call);
|
|
9019
9430
|
const callee = import_ts_morph42.Node.isPropertyAccessExpression(expression) ? expression : null;
|
|
9020
9431
|
let args = null;
|
|
9021
9432
|
const argumentsOf = () => {
|
|
@@ -9067,7 +9478,7 @@ function anchorCallBehind(subject, origin, resolve2, originatesFrom, anchorCalls
|
|
|
9067
9478
|
if (!import_ts_morph42.Node.isCallExpression(candidate) && !import_ts_morph42.Node.isNewExpression(candidate)) {
|
|
9068
9479
|
return false;
|
|
9069
9480
|
}
|
|
9070
|
-
const candidateCallee =
|
|
9481
|
+
const candidateCallee = calleeOf3(candidate);
|
|
9071
9482
|
if (origin.named !== void 0 && !origin.named.includes(constructorName(candidate))) {
|
|
9072
9483
|
return false;
|
|
9073
9484
|
}
|
|
@@ -9201,7 +9612,7 @@ function opsOverCall(value, resolve2) {
|
|
|
9201
9612
|
function isCalled(value) {
|
|
9202
9613
|
return import_ts_morph42.Node.isCallExpression(value) || import_ts_morph42.Node.isNewExpression(value) || import_ts_morph42.Node.isTaggedTemplateExpression(value);
|
|
9203
9614
|
}
|
|
9204
|
-
function
|
|
9615
|
+
function calleeOf3(call) {
|
|
9205
9616
|
return import_ts_morph42.Node.isTaggedTemplateExpression(call) ? call.getTag() : call.getExpression();
|
|
9206
9617
|
}
|
|
9207
9618
|
function argumentsIn(call) {
|
|
@@ -10609,6 +11020,7 @@ function collapseVariants2(shapes) {
|
|
|
10609
11020
|
|
|
10610
11021
|
// src/terminals/extract.ts
|
|
10611
11022
|
var import_ts_morph48 = require("ts-morph");
|
|
11023
|
+
var import_values5 = require("@suss/values");
|
|
10612
11024
|
function unwrapAs(node) {
|
|
10613
11025
|
return peelSyntax(node);
|
|
10614
11026
|
}
|
|
@@ -10665,15 +11077,11 @@ function matchConstructorCode(ctorText, codes) {
|
|
|
10665
11077
|
return null;
|
|
10666
11078
|
}
|
|
10667
11079
|
function statusOf(value, ctx) {
|
|
10668
|
-
const
|
|
10669
|
-
if (
|
|
10670
|
-
return { type: "literal", value:
|
|
10671
|
-
}
|
|
10672
|
-
const resolved = ctx.resolveWrittenValue?.(unwrapped2) ?? null;
|
|
10673
|
-
if (resolved !== null && import_ts_morph48.Node.isNumericLiteral(resolved)) {
|
|
10674
|
-
return { type: "literal", value: Number(resolved.getText()) };
|
|
11080
|
+
const status = (0, import_values5.constantOf)(evaluatedValue(value, ctx.resolution));
|
|
11081
|
+
if (typeof status === "number") {
|
|
11082
|
+
return { type: "literal", value: status };
|
|
10675
11083
|
}
|
|
10676
|
-
return { type: "dynamic", sourceText:
|
|
11084
|
+
return { type: "dynamic", sourceText: unwrapAs(value).getText() };
|
|
10677
11085
|
}
|
|
10678
11086
|
function statusFromProperty(obj, name, ctx) {
|
|
10679
11087
|
const prop = obj.getProperty(name);
|
|
@@ -11104,13 +11512,14 @@ function bindArguments(callArgs, params) {
|
|
|
11104
11512
|
|
|
11105
11513
|
// src/terminals/statusBranches.ts
|
|
11106
11514
|
var import_ts_morph50 = require("ts-morph");
|
|
11107
|
-
|
|
11515
|
+
var import_values6 = require("@suss/values");
|
|
11516
|
+
function statusChoicesOf(argument, resolution) {
|
|
11108
11517
|
const chosen = asConditional(argument);
|
|
11109
11518
|
if (chosen === null) {
|
|
11110
11519
|
return null;
|
|
11111
11520
|
}
|
|
11112
|
-
const whenTrue = numberOf(chosen.getWhenTrue());
|
|
11113
|
-
const whenFalse = numberOf(chosen.getWhenFalse());
|
|
11521
|
+
const whenTrue = numberOf(chosen.getWhenTrue(), resolution);
|
|
11522
|
+
const whenFalse = numberOf(chosen.getWhenFalse(), resolution);
|
|
11114
11523
|
if (whenTrue === null || whenFalse === null) {
|
|
11115
11524
|
return null;
|
|
11116
11525
|
}
|
|
@@ -11141,20 +11550,14 @@ function asConditional(node) {
|
|
|
11141
11550
|
return only === void 0 ? null : toConditional(only);
|
|
11142
11551
|
}
|
|
11143
11552
|
var toConditional = (node) => import_ts_morph50.Node.isConditionalExpression(node) ? node : null;
|
|
11144
|
-
function numberOf(node) {
|
|
11145
|
-
const
|
|
11146
|
-
|
|
11147
|
-
return null;
|
|
11148
|
-
}
|
|
11149
|
-
const value = Number(inner.getText());
|
|
11150
|
-
return Number.isFinite(value) ? value : null;
|
|
11151
|
-
}
|
|
11152
|
-
function unwrap(node) {
|
|
11153
|
-
return peelSyntax(node);
|
|
11553
|
+
function numberOf(node, resolution) {
|
|
11554
|
+
const value = (0, import_values6.constantOf)(evaluatedValue(node, resolution));
|
|
11555
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
11154
11556
|
}
|
|
11155
11557
|
|
|
11156
11558
|
// src/terminals/returns.ts
|
|
11157
|
-
function unwrapMethodChain(call,
|
|
11559
|
+
function unwrapMethodChain(call, match, func) {
|
|
11560
|
+
const { methodChain, parameterPosition: paramPos } = match;
|
|
11158
11561
|
if (methodChain.length === 0) {
|
|
11159
11562
|
return null;
|
|
11160
11563
|
}
|
|
@@ -11170,7 +11573,10 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
|
|
|
11170
11573
|
return null;
|
|
11171
11574
|
}
|
|
11172
11575
|
collected.unshift(current2);
|
|
11173
|
-
const subject =
|
|
11576
|
+
const subject = withoutPassThroughCalls(
|
|
11577
|
+
callee.getExpression(),
|
|
11578
|
+
match.passThroughMethods ?? []
|
|
11579
|
+
);
|
|
11174
11580
|
if (i === 0) {
|
|
11175
11581
|
if (parameterPositionOf(subject, func) !== paramPos) {
|
|
11176
11582
|
return null;
|
|
@@ -11184,11 +11590,22 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
|
|
|
11184
11590
|
}
|
|
11185
11591
|
return { calls: collected };
|
|
11186
11592
|
}
|
|
11593
|
+
function withoutPassThroughCalls(subject, passThrough) {
|
|
11594
|
+
let current2 = subject;
|
|
11595
|
+
while (import_ts_morph51.Node.isCallExpression(current2)) {
|
|
11596
|
+
const callee = current2.getExpression();
|
|
11597
|
+
if (!import_ts_morph51.Node.isPropertyAccessExpression(callee) || !passThrough.includes(callee.getName())) {
|
|
11598
|
+
break;
|
|
11599
|
+
}
|
|
11600
|
+
current2 = callee.getExpression();
|
|
11601
|
+
}
|
|
11602
|
+
return current2;
|
|
11603
|
+
}
|
|
11187
11604
|
function returnedValueOf(returnStatement) {
|
|
11188
11605
|
const written = returnStatement.getExpression();
|
|
11189
11606
|
return written === void 0 ? null : unwrapValue(written);
|
|
11190
11607
|
}
|
|
11191
|
-
function tryMatchReturnShape(node, pattern, match,
|
|
11608
|
+
function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
11192
11609
|
if (import_ts_morph51.Node.isObjectLiteralExpression(node)) {
|
|
11193
11610
|
const source = returnPositionOf(node);
|
|
11194
11611
|
if (source === null) {
|
|
@@ -11203,7 +11620,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
|
|
|
11203
11620
|
pattern,
|
|
11204
11621
|
match,
|
|
11205
11622
|
void 0,
|
|
11206
|
-
|
|
11623
|
+
resolution
|
|
11207
11624
|
);
|
|
11208
11625
|
return terminal === null ? [] : [{ ...terminal, source }];
|
|
11209
11626
|
}
|
|
@@ -11221,7 +11638,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
|
|
|
11221
11638
|
pattern,
|
|
11222
11639
|
match,
|
|
11223
11640
|
void 0,
|
|
11224
|
-
|
|
11641
|
+
resolution
|
|
11225
11642
|
);
|
|
11226
11643
|
return terminal === null ? [] : [terminal];
|
|
11227
11644
|
}
|
|
@@ -11249,7 +11666,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
|
|
|
11249
11666
|
pattern,
|
|
11250
11667
|
match,
|
|
11251
11668
|
resolved.substitutions,
|
|
11252
|
-
|
|
11669
|
+
resolution
|
|
11253
11670
|
);
|
|
11254
11671
|
if (terminal !== null) {
|
|
11255
11672
|
terminals.push(terminal);
|
|
@@ -11257,7 +11674,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
|
|
|
11257
11674
|
}
|
|
11258
11675
|
return terminals;
|
|
11259
11676
|
}
|
|
11260
|
-
function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
11677
|
+
function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions, resolution) {
|
|
11261
11678
|
const required = match.requiredProperties;
|
|
11262
11679
|
if (required !== void 0 && required.length > 0) {
|
|
11263
11680
|
const presentNames = /* @__PURE__ */ new Set();
|
|
@@ -11276,7 +11693,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11276
11693
|
extraction: pattern.extraction,
|
|
11277
11694
|
returnedObj: obj,
|
|
11278
11695
|
...substitutions !== void 0 ? { substitutions } : {},
|
|
11279
|
-
...
|
|
11696
|
+
...resolution !== void 0 ? { resolution } : {}
|
|
11280
11697
|
};
|
|
11281
11698
|
const statusCode = extractStatusCode(ctx);
|
|
11282
11699
|
let body = extractBody(ctx);
|
|
@@ -11306,16 +11723,11 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11306
11723
|
}
|
|
11307
11724
|
};
|
|
11308
11725
|
}
|
|
11309
|
-
function tryMatchParameterMethodCall(node, func, pattern, match,
|
|
11726
|
+
function tryMatchParameterMethodCall(node, func, pattern, match, resolution) {
|
|
11310
11727
|
if (!import_ts_morph51.Node.isCallExpression(node)) {
|
|
11311
11728
|
return [];
|
|
11312
11729
|
}
|
|
11313
|
-
const result = unwrapMethodChain(
|
|
11314
|
-
node,
|
|
11315
|
-
match.methodChain,
|
|
11316
|
-
func,
|
|
11317
|
-
match.parameterPosition
|
|
11318
|
-
);
|
|
11730
|
+
const result = unwrapMethodChain(node, match, func);
|
|
11319
11731
|
if (result === null) {
|
|
11320
11732
|
return [];
|
|
11321
11733
|
}
|
|
@@ -11324,7 +11736,7 @@ function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenV
|
|
|
11324
11736
|
const ctx = {
|
|
11325
11737
|
extraction: pattern.extraction,
|
|
11326
11738
|
calls,
|
|
11327
|
-
...
|
|
11739
|
+
...resolution !== void 0 ? { resolution } : {}
|
|
11328
11740
|
};
|
|
11329
11741
|
const statusCode = extractStatusCode(ctx);
|
|
11330
11742
|
const body = extractBody(ctx);
|
|
@@ -11345,7 +11757,7 @@ function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenV
|
|
|
11345
11757
|
};
|
|
11346
11758
|
const base = { node, ...source !== null ? { source } : {} };
|
|
11347
11759
|
const argument = statusArgument(calls, pattern.extraction);
|
|
11348
|
-
const choices = argument === null ? null : statusChoicesOf(argument);
|
|
11760
|
+
const choices = argument === null ? null : statusChoicesOf(argument, resolution);
|
|
11349
11761
|
if (choices === null) {
|
|
11350
11762
|
return [{ ...base, terminal }];
|
|
11351
11763
|
}
|
|
@@ -11379,12 +11791,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
|
11379
11791
|
if (pattern.match.type !== "parameterMethodCall") {
|
|
11380
11792
|
continue;
|
|
11381
11793
|
}
|
|
11382
|
-
const result = unwrapMethodChain(
|
|
11383
|
-
current2,
|
|
11384
|
-
pattern.match.methodChain,
|
|
11385
|
-
func,
|
|
11386
|
-
pattern.match.parameterPosition
|
|
11387
|
-
);
|
|
11794
|
+
const result = unwrapMethodChain(current2, pattern.match, func);
|
|
11388
11795
|
if (result !== null) {
|
|
11389
11796
|
return true;
|
|
11390
11797
|
}
|
|
@@ -11482,7 +11889,7 @@ function calleeSubject(callee) {
|
|
|
11482
11889
|
}
|
|
11483
11890
|
return null;
|
|
11484
11891
|
}
|
|
11485
|
-
function tryMatchFunctionCall(node, pattern, match,
|
|
11892
|
+
function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom) {
|
|
11486
11893
|
if (!import_ts_morph51.Node.isCallExpression(node) && !import_ts_morph51.Node.isNewExpression(node)) {
|
|
11487
11894
|
return null;
|
|
11488
11895
|
}
|
|
@@ -11501,7 +11908,7 @@ function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, origina
|
|
|
11501
11908
|
const ctx = {
|
|
11502
11909
|
extraction: pattern.extraction,
|
|
11503
11910
|
throwCallArgs: callArgs,
|
|
11504
|
-
...
|
|
11911
|
+
...resolution !== void 0 ? { resolution } : {}
|
|
11505
11912
|
};
|
|
11506
11913
|
const statusCode = extractStatusCode(ctx);
|
|
11507
11914
|
const body = extractBody(ctx);
|
|
@@ -11526,7 +11933,7 @@ function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, origina
|
|
|
11526
11933
|
|
|
11527
11934
|
// src/terminals/throws.ts
|
|
11528
11935
|
var import_ts_morph52 = require("ts-morph");
|
|
11529
|
-
function tryMatchThrowExpression(node, pattern, match,
|
|
11936
|
+
function tryMatchThrowExpression(node, pattern, match, resolution) {
|
|
11530
11937
|
if (!import_ts_morph52.Node.isThrowStatement(node)) {
|
|
11531
11938
|
return null;
|
|
11532
11939
|
}
|
|
@@ -11541,7 +11948,7 @@ function tryMatchThrowExpression(node, pattern, match, resolveWrittenValue) {
|
|
|
11541
11948
|
extraction: pattern.extraction,
|
|
11542
11949
|
...callArgs !== null ? { throwCallArgs: callArgs } : {},
|
|
11543
11950
|
...exceptionType !== null ? { exceptionType } : {},
|
|
11544
|
-
...
|
|
11951
|
+
...resolution !== void 0 ? { resolution } : {}
|
|
11545
11952
|
};
|
|
11546
11953
|
const statusCode = extractStatusCode(ctx);
|
|
11547
11954
|
const body = extractBody(ctx);
|
|
@@ -11597,7 +12004,7 @@ function classifyThrownExpression(thrown, constructorPattern) {
|
|
|
11597
12004
|
|
|
11598
12005
|
// src/terminals/index.ts
|
|
11599
12006
|
var NESTED_ESCAPING_MATCH_TYPES = /* @__PURE__ */ new Set(["parameterMethodCall"]);
|
|
11600
|
-
function findTerminals(func, patterns, barriers = NO_BARRIERS,
|
|
12007
|
+
function findTerminals(func, patterns, barriers = NO_BARRIERS, resolution, originatesFrom, resolveCallee2) {
|
|
11601
12008
|
const results = [];
|
|
11602
12009
|
func.forEachDescendant((node, traversal) => {
|
|
11603
12010
|
if (isDescentStop(node, func, barriers)) {
|
|
@@ -11615,7 +12022,7 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
|
|
|
11615
12022
|
node,
|
|
11616
12023
|
pattern,
|
|
11617
12024
|
pattern.match,
|
|
11618
|
-
|
|
12025
|
+
resolution,
|
|
11619
12026
|
resolveCallee2
|
|
11620
12027
|
);
|
|
11621
12028
|
if (matches.length > 0) {
|
|
@@ -11630,7 +12037,7 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
|
|
|
11630
12037
|
func,
|
|
11631
12038
|
pattern,
|
|
11632
12039
|
pattern.match,
|
|
11633
|
-
|
|
12040
|
+
resolution
|
|
11634
12041
|
);
|
|
11635
12042
|
if (matches.length > 0) {
|
|
11636
12043
|
results.push(...matches);
|
|
@@ -11647,14 +12054,14 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
|
|
|
11647
12054
|
node,
|
|
11648
12055
|
pattern,
|
|
11649
12056
|
pattern.match,
|
|
11650
|
-
|
|
12057
|
+
resolution
|
|
11651
12058
|
);
|
|
11652
12059
|
} else if (pattern.match.type === "functionCall") {
|
|
11653
12060
|
found = tryMatchFunctionCall(
|
|
11654
12061
|
node,
|
|
11655
12062
|
pattern,
|
|
11656
12063
|
pattern.match,
|
|
11657
|
-
|
|
12064
|
+
resolution,
|
|
11658
12065
|
originatesFrom
|
|
11659
12066
|
);
|
|
11660
12067
|
} else if (pattern.match.type === "parameterCall") {
|
|
@@ -11810,15 +12217,16 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
11810
12217
|
});
|
|
11811
12218
|
return unmatched;
|
|
11812
12219
|
}
|
|
11813
|
-
function extractRawBranches(func, terminalPatterns, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS,
|
|
12220
|
+
function extractRawBranches(func, terminalPatterns, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
|
|
11814
12221
|
const terminals = findTerminals(
|
|
11815
12222
|
func,
|
|
11816
12223
|
terminalPatterns,
|
|
11817
12224
|
barriers,
|
|
11818
|
-
|
|
12225
|
+
resolution,
|
|
11819
12226
|
originatesFrom,
|
|
11820
12227
|
resolveCallee2
|
|
11821
12228
|
);
|
|
12229
|
+
const resolveWrittenValue = resolution === void 0 ? void 0 : (value) => resolution.resolveWrittenValue(value);
|
|
11822
12230
|
const invocations = extractInvocationEffects(func, barriers);
|
|
11823
12231
|
const recognized = [
|
|
11824
12232
|
...runInvocationRecognizers(
|
|
@@ -11995,7 +12403,7 @@ function indexFunctions(sf) {
|
|
|
11995
12403
|
|
|
11996
12404
|
// src/contract.ts
|
|
11997
12405
|
var import_ts_morph56 = require("ts-morph");
|
|
11998
|
-
var
|
|
12406
|
+
var import_behavioral_ir4 = require("@suss/behavioral-ir");
|
|
11999
12407
|
function extractDeclaredBody(node) {
|
|
12000
12408
|
if (node === void 0) {
|
|
12001
12409
|
return null;
|
|
@@ -12174,7 +12582,7 @@ function extractEndpointContract(endpointNode, pattern, framework) {
|
|
|
12174
12582
|
if (responses.length === 0) {
|
|
12175
12583
|
return null;
|
|
12176
12584
|
}
|
|
12177
|
-
const boundaryBinding = method !== void 0 || path14 !== void 0 ? (0,
|
|
12585
|
+
const boundaryBinding = method !== void 0 || path14 !== void 0 ? (0, import_behavioral_ir4.restBinding)({
|
|
12178
12586
|
transport: "http",
|
|
12179
12587
|
method: method ?? null,
|
|
12180
12588
|
path: path14 ?? null,
|
|
@@ -12375,7 +12783,7 @@ function parameterName(segment, convention) {
|
|
|
12375
12783
|
// src/discovery/graphqlClientConstruction.ts
|
|
12376
12784
|
var import_picomatch2 = __toESM(require("picomatch"), 1);
|
|
12377
12785
|
var import_ts_morph57 = require("ts-morph");
|
|
12378
|
-
var
|
|
12786
|
+
var import_behavioral_ir5 = require("@suss/behavioral-ir");
|
|
12379
12787
|
function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
12380
12788
|
const scopes = compileOperationScopes(packs);
|
|
12381
12789
|
const sole = soleGraphqlClientRef(
|
|
@@ -12385,10 +12793,10 @@ function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
|
12385
12793
|
const soleClient = sole !== null ? workspace !== null ? { ...sole, workspace } : sole : null;
|
|
12386
12794
|
let registry = null;
|
|
12387
12795
|
for (const summary of summaries) {
|
|
12388
|
-
if (!(0,
|
|
12796
|
+
if (!(0, import_behavioral_ir5.isGraphqlOperationBinding)(summary.identity.boundaryBinding)) {
|
|
12389
12797
|
continue;
|
|
12390
12798
|
}
|
|
12391
|
-
const existing = (0,
|
|
12799
|
+
const existing = (0, import_behavioral_ir5.readGraphqlMetadata)(summary) ?? {};
|
|
12392
12800
|
const scoped = scopedWorkspaceFor(summary.location.file, scopes);
|
|
12393
12801
|
const client = scoped !== null ? { uri: null, uriRef: null, workspace: scoped } : soleClient;
|
|
12394
12802
|
const dangling = (existing.unresolvedFragments?.length ?? 0) > 0;
|
|
@@ -12398,7 +12806,7 @@ function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
|
12398
12806
|
if (dangling && registry === null) {
|
|
12399
12807
|
registry = fragmentRegistryStatus(sourceFiles, packs);
|
|
12400
12808
|
}
|
|
12401
|
-
summary.metadata = (0,
|
|
12809
|
+
summary.metadata = (0, import_behavioral_ir5.withGraphqlMetadata)(summary.metadata, {
|
|
12402
12810
|
...existing,
|
|
12403
12811
|
...client !== null ? { client } : {},
|
|
12404
12812
|
...dangling && registry !== null ? { fragmentRegistry: registry } : {}
|
|
@@ -13564,7 +13972,7 @@ function deriveBoundaryEffects(summaries, facts) {
|
|
|
13564
13972
|
|
|
13565
13973
|
// src/resolve/reachableClosure.ts
|
|
13566
13974
|
var import_ts_morph62 = require("ts-morph");
|
|
13567
|
-
var
|
|
13975
|
+
var import_behavioral_ir6 = require("@suss/behavioral-ir");
|
|
13568
13976
|
var import_datalog4 = require("@suss/datalog");
|
|
13569
13977
|
var import_extractor7 = require("@suss/extractor");
|
|
13570
13978
|
var reachablePack = {
|
|
@@ -13682,7 +14090,7 @@ function collectReachable(func, scan) {
|
|
|
13682
14090
|
const inFunc = { ...scan, scanning: func };
|
|
13683
14091
|
const candidates = [];
|
|
13684
14092
|
const stops = [];
|
|
13685
|
-
const placements = new
|
|
14093
|
+
const placements = new import_behavioral_ir6.TargetPlacements();
|
|
13686
14094
|
const parameterCalls = [];
|
|
13687
14095
|
const passedPositions = /* @__PURE__ */ new Set();
|
|
13688
14096
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -13690,7 +14098,7 @@ function collectReachable(func, scan) {
|
|
|
13690
14098
|
const record2 = (outcome) => {
|
|
13691
14099
|
if (outcome.kind === "stopped") {
|
|
13692
14100
|
const stopKey = `${outcome.stop.reason}:${outcome.stop.callee}`;
|
|
13693
|
-
if (!seen.has(stopKey) && (0,
|
|
14101
|
+
if (!seen.has(stopKey) && (0, import_behavioral_ir2.worthRecording)(outcome.stop.reason)) {
|
|
13694
14102
|
seen.add(stopKey);
|
|
13695
14103
|
stops.push(outcome.stop);
|
|
13696
14104
|
}
|
|
@@ -13772,9 +14180,9 @@ function extractReachableSummary(candidate, options, recognizers) {
|
|
|
13772
14180
|
recognizers.invocation,
|
|
13773
14181
|
recognizers.access,
|
|
13774
14182
|
void 0,
|
|
13775
|
-
recognizers.
|
|
14183
|
+
recognizers.resolution
|
|
13776
14184
|
);
|
|
13777
|
-
raw.boundaryBinding = (0,
|
|
14185
|
+
raw.boundaryBinding = (0, import_behavioral_ir6.functionCallBinding)({
|
|
13778
14186
|
transport: "in-process",
|
|
13779
14187
|
recognition: "reachable"
|
|
13780
14188
|
});
|
|
@@ -13979,7 +14387,7 @@ function recordStops(stopsByKey, summariesByKey, options) {
|
|
|
13979
14387
|
}
|
|
13980
14388
|
for (const [key, stops] of stopsByKey) {
|
|
13981
14389
|
for (const summary of summariesByKey.get(key) ?? []) {
|
|
13982
|
-
summary.gaps.push(...stops.map(
|
|
14390
|
+
summary.gaps.push(...stops.map(import_behavioral_ir2.unfollowedCallGap));
|
|
13983
14391
|
}
|
|
13984
14392
|
}
|
|
13985
14393
|
}
|
|
@@ -14061,7 +14469,7 @@ function recordParameterGaps(parameterCallsByKey, summariesByKey, passedPosition
|
|
|
14061
14469
|
for (const summary of summariesByKey.get(key) ?? []) {
|
|
14062
14470
|
summary.gaps.push(
|
|
14063
14471
|
...unbound.map(
|
|
14064
|
-
({ callee }) => (0,
|
|
14472
|
+
({ callee }) => (0, import_behavioral_ir2.unfollowedCallGap)({ callee, reason: "unboundParameter" })
|
|
14065
14473
|
)
|
|
14066
14474
|
);
|
|
14067
14475
|
}
|
|
@@ -14375,7 +14783,7 @@ function prefixOfExpr(expr, responseCall, depth) {
|
|
|
14375
14783
|
if (depth >= MAX_PREFIX_DEPTH) {
|
|
14376
14784
|
return null;
|
|
14377
14785
|
}
|
|
14378
|
-
const node =
|
|
14786
|
+
const node = unwrap(expr);
|
|
14379
14787
|
if (node === responseCall) {
|
|
14380
14788
|
return [];
|
|
14381
14789
|
}
|
|
@@ -14428,7 +14836,7 @@ function firstCallbackParamName(callback) {
|
|
|
14428
14836
|
const nameNode = param.getNameNode();
|
|
14429
14837
|
return import_ts_morph64.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
14430
14838
|
}
|
|
14431
|
-
function
|
|
14839
|
+
function unwrap(expr) {
|
|
14432
14840
|
let node = expr;
|
|
14433
14841
|
while (import_ts_morph64.Node.isAwaitExpression(node) || import_ts_morph64.Node.isParenthesizedExpression(node) || import_ts_morph64.Node.isAsExpression(node)) {
|
|
14434
14842
|
node = node.getExpression();
|
|
@@ -14443,7 +14851,7 @@ function chainRootedAt(expr, rootName) {
|
|
|
14443
14851
|
return import_ts_morph64.Node.isIdentifier(chain.root) && chain.root.getText() === rootName ? chain.segments : null;
|
|
14444
14852
|
}
|
|
14445
14853
|
function memberChain(expr) {
|
|
14446
|
-
let node = import_ts_morph64.Node.isExpression(expr) ?
|
|
14854
|
+
let node = import_ts_morph64.Node.isExpression(expr) ? unwrap(expr) : expr;
|
|
14447
14855
|
if (import_ts_morph64.Node.isCallExpression(node)) {
|
|
14448
14856
|
node = node.getExpression();
|
|
14449
14857
|
}
|
|
@@ -14799,7 +15207,7 @@ function readArrayLiteralText(node) {
|
|
|
14799
15207
|
|
|
14800
15208
|
// src/summaryIdentity.ts
|
|
14801
15209
|
var import_node_path8 = __toESM(require("path"), 1);
|
|
14802
|
-
var
|
|
15210
|
+
var import_behavioral_ir7 = require("@suss/behavioral-ir");
|
|
14803
15211
|
function workspaceRootFor(anchor) {
|
|
14804
15212
|
return namedPackageDirAbove(anchor) ?? import_node_path8.default.resolve(anchor);
|
|
14805
15213
|
}
|
|
@@ -14822,8 +15230,8 @@ function nameSummaries(summaries, args) {
|
|
|
14822
15230
|
}
|
|
14823
15231
|
summary.identity.id = idFor(args.workspace, file, summary);
|
|
14824
15232
|
}
|
|
14825
|
-
(0,
|
|
14826
|
-
(0,
|
|
15233
|
+
(0, import_behavioral_ir7.disambiguateSummaryIds)(summaries);
|
|
15234
|
+
(0, import_behavioral_ir7.linkCallsToSummaries)(summaries);
|
|
14827
15235
|
}
|
|
14828
15236
|
function relativeFile(file, projectRoot) {
|
|
14829
15237
|
if (projectRoot === void 0 || !import_node_path8.default.isAbsolute(file)) {
|
|
@@ -14833,7 +15241,7 @@ function relativeFile(file, projectRoot) {
|
|
|
14833
15241
|
return relative.startsWith("..") ? file : relative;
|
|
14834
15242
|
}
|
|
14835
15243
|
function idFor(workspace, file, summary) {
|
|
14836
|
-
return (0,
|
|
15244
|
+
return (0, import_behavioral_ir7.summaryIdFromParts)({
|
|
14837
15245
|
workspace: workspace ?? void 0,
|
|
14838
15246
|
file,
|
|
14839
15247
|
name: summary.identity.name,
|
|
@@ -15337,7 +15745,7 @@ function announcedBoundaryStructure(unit) {
|
|
|
15337
15745
|
declaredContract: null
|
|
15338
15746
|
};
|
|
15339
15747
|
}
|
|
15340
|
-
function extractCodeStructure(unit, pack, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS,
|
|
15748
|
+
function extractCodeStructure(unit, pack, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
|
|
15341
15749
|
const read2 = withDefinitions(
|
|
15342
15750
|
() => readCodeStructure(
|
|
15343
15751
|
unit,
|
|
@@ -15345,7 +15753,7 @@ function extractCodeStructure(unit, pack, invocationRecognizers = [], accessReco
|
|
|
15345
15753
|
invocationRecognizers,
|
|
15346
15754
|
accessRecognizers,
|
|
15347
15755
|
barriers,
|
|
15348
|
-
|
|
15756
|
+
resolution,
|
|
15349
15757
|
originatesFrom,
|
|
15350
15758
|
anchorCallsOf,
|
|
15351
15759
|
resolveCallee2
|
|
@@ -15430,7 +15838,7 @@ function terminalsFor(unit, pack) {
|
|
|
15430
15838
|
}
|
|
15431
15839
|
return [...declared, FUNCTION_FALLTHROUGH_TERMINAL];
|
|
15432
15840
|
}
|
|
15433
|
-
function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers, barriers,
|
|
15841
|
+
function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers, barriers, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
|
|
15434
15842
|
const { func, kind, name } = unit;
|
|
15435
15843
|
if (func === null) {
|
|
15436
15844
|
return announcedBoundaryStructure(unit);
|
|
@@ -15445,7 +15853,7 @@ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers,
|
|
|
15445
15853
|
invocationRecognizers,
|
|
15446
15854
|
accessRecognizers,
|
|
15447
15855
|
barriers,
|
|
15448
|
-
|
|
15856
|
+
resolution,
|
|
15449
15857
|
originatesFrom,
|
|
15450
15858
|
anchorCallsOf,
|
|
15451
15859
|
resolveCallee2
|
|
@@ -15526,7 +15934,7 @@ function extractConsumerBinding(unit, pattern, pack, resolution) {
|
|
|
15526
15934
|
}
|
|
15527
15935
|
const method = extractBindingMethod(binding, callSite, pack, resolution);
|
|
15528
15936
|
const path14 = extractBindingPath(binding, callSite, pack, resolution);
|
|
15529
|
-
return (0,
|
|
15937
|
+
return (0, import_behavioral_ir8.restBinding)({
|
|
15530
15938
|
transport: pack.protocol,
|
|
15531
15939
|
method: method ?? null,
|
|
15532
15940
|
path: path14 ?? null,
|
|
@@ -15545,7 +15953,7 @@ function fileRouteBinding(filePath, unit, binding, pack) {
|
|
|
15545
15953
|
if (method === void 0) {
|
|
15546
15954
|
return null;
|
|
15547
15955
|
}
|
|
15548
|
-
return (0,
|
|
15956
|
+
return (0, import_behavioral_ir8.restBinding)({
|
|
15549
15957
|
transport: pack.protocol,
|
|
15550
15958
|
recognition: pack.name,
|
|
15551
15959
|
method,
|
|
@@ -15567,21 +15975,9 @@ function extractBindingMethod(binding, callSite, pack, resolution) {
|
|
|
15567
15975
|
return resolveContractField(callSite, pack, "method", resolution);
|
|
15568
15976
|
}
|
|
15569
15977
|
if (m.type === "fromArgumentProperty") {
|
|
15570
|
-
const
|
|
15571
|
-
const
|
|
15572
|
-
|
|
15573
|
-
const prop = arg.getProperty(m.property);
|
|
15574
|
-
if (prop !== void 0 && import_ts_morph66.Node.isPropertyAssignment(prop)) {
|
|
15575
|
-
const init = prop.getInitializer();
|
|
15576
|
-
if (init !== void 0) {
|
|
15577
|
-
const value = stringValueOf(init, resolution);
|
|
15578
|
-
if (value !== null) {
|
|
15579
|
-
return value;
|
|
15580
|
-
}
|
|
15581
|
-
}
|
|
15582
|
-
}
|
|
15583
|
-
}
|
|
15584
|
-
return m.default;
|
|
15978
|
+
const arg = callSite.callExpression.getArguments()[m.position];
|
|
15979
|
+
const value = arg === void 0 ? null : stringPropertyOf(arg, m.property, resolution);
|
|
15980
|
+
return value ?? m.default;
|
|
15585
15981
|
}
|
|
15586
15982
|
if (m.type === "literal") {
|
|
15587
15983
|
return m.value;
|
|
@@ -15784,7 +16180,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
15784
16180
|
allInvocationRecognizers,
|
|
15785
16181
|
allAccessRecognizers,
|
|
15786
16182
|
barriers,
|
|
15787
|
-
resolution
|
|
16183
|
+
resolution,
|
|
15788
16184
|
resolution === void 0 ? void 0 : (value, module2) => resolution.importOriginsOf(value, [module2]).length > 0,
|
|
15789
16185
|
resolution === void 0 ? void 0 : (value, matches) => resolution.anchorCallsOf(value, matches),
|
|
15790
16186
|
resolution === void 0 ? void 0 : (value) => resolution.resolveCallable(value)
|
|
@@ -15798,7 +16194,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
15798
16194
|
stampWrappers(raw, unit, wrappers);
|
|
15799
16195
|
const matchedPattern = unit.pattern ?? pack.discovery.find((d) => d.kind === unit.kind);
|
|
15800
16196
|
if (unit.resolverInfo !== void 0) {
|
|
15801
|
-
raw.boundaryBinding = (0,
|
|
16197
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.graphqlResolverBinding)({
|
|
15802
16198
|
transport: pack.protocol,
|
|
15803
16199
|
recognition: pack.name,
|
|
15804
16200
|
typeName: unit.resolverInfo.typeName,
|
|
@@ -15825,26 +16221,26 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
15825
16221
|
}
|
|
15826
16222
|
}
|
|
15827
16223
|
} else if (unit.routeInfo !== void 0) {
|
|
15828
|
-
raw.boundaryBinding = (0,
|
|
16224
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.restBinding)({
|
|
15829
16225
|
transport: pack.protocol,
|
|
15830
16226
|
recognition: pack.name,
|
|
15831
16227
|
method: unit.routeInfo.method,
|
|
15832
16228
|
path: unit.routeInfo.path
|
|
15833
16229
|
});
|
|
15834
16230
|
} else if (unit.channelInfo !== void 0) {
|
|
15835
|
-
raw.boundaryBinding = (0,
|
|
16231
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.messageBusBinding)({
|
|
15836
16232
|
recognition: pack.name,
|
|
15837
16233
|
messageBus: unit.channelInfo.messageBus,
|
|
15838
16234
|
channel: unit.channelInfo.channel
|
|
15839
16235
|
});
|
|
15840
16236
|
} else if (unit.invocationInfo !== void 0) {
|
|
15841
|
-
raw.boundaryBinding = (0,
|
|
16237
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.unitInvocationBinding)({
|
|
15842
16238
|
recognition: pack.name,
|
|
15843
16239
|
deploymentTarget: unit.invocationInfo.deploymentTarget,
|
|
15844
16240
|
instanceName: unit.invocationInfo.instanceName
|
|
15845
16241
|
});
|
|
15846
16242
|
} else if (unit.operationInfo !== void 0) {
|
|
15847
|
-
raw.boundaryBinding = (0,
|
|
16243
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.graphqlOperationBinding)({
|
|
15848
16244
|
transport: pack.protocol,
|
|
15849
16245
|
recognition: pack.name,
|
|
15850
16246
|
operationType: unit.operationInfo.operationType,
|
|
@@ -15933,14 +16329,14 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
15933
16329
|
}
|
|
15934
16330
|
if (raw.boundaryBinding === null) {
|
|
15935
16331
|
if (unit.packageExportInfo !== void 0) {
|
|
15936
|
-
raw.boundaryBinding = (0,
|
|
16332
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.packageExportBinding)({
|
|
15937
16333
|
transport: pack.protocol,
|
|
15938
16334
|
recognition: pack.name,
|
|
15939
16335
|
packageName: unit.packageExportInfo.packageName,
|
|
15940
16336
|
exportPath: unit.packageExportInfo.exportPath
|
|
15941
16337
|
});
|
|
15942
16338
|
} else {
|
|
15943
|
-
raw.boundaryBinding = (0,
|
|
16339
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.functionCallBinding)({
|
|
15944
16340
|
transport: pack.protocol,
|
|
15945
16341
|
recognition: pack.name,
|
|
15946
16342
|
...unit.functionCallInfo !== void 0 ? {
|
|
@@ -15952,7 +16348,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
15952
16348
|
}
|
|
15953
16349
|
const summary = (0, import_extractor11.assembleSummary)(raw, options);
|
|
15954
16350
|
if (unit.unfollowed !== void 0 && options?.gapHandling !== "silent") {
|
|
15955
|
-
summary.gaps.push((0,
|
|
16351
|
+
summary.gaps.push((0, import_behavioral_ir2.unfollowedCallGap)(unit.unfollowed));
|
|
15956
16352
|
}
|
|
15957
16353
|
if (unit.metadata !== void 0 && Object.keys(unit.metadata).length > 0) {
|
|
15958
16354
|
summary.metadata = {
|
|
@@ -16032,14 +16428,14 @@ function fileImporting(project, modulePrefix) {
|
|
|
16032
16428
|
function liftSchemasOntoDocuments(summaries) {
|
|
16033
16429
|
const sdlByDocument = /* @__PURE__ */ new Map();
|
|
16034
16430
|
for (const summary of summaries) {
|
|
16035
|
-
const label = (0,
|
|
16036
|
-
const graphql = (0,
|
|
16431
|
+
const label = (0, import_behavioral_ir8.readSourceDocumentMetadata)(summary)?.label;
|
|
16432
|
+
const graphql = (0, import_behavioral_ir8.readGraphqlMetadata)(summary);
|
|
16037
16433
|
if (label === void 0 || graphql?.schemaSdl === void 0) {
|
|
16038
16434
|
continue;
|
|
16039
16435
|
}
|
|
16040
16436
|
sdlByDocument.set(label, graphql.schemaSdl);
|
|
16041
16437
|
const { schemaSdl: _movedToTheDocument, ...rest } = graphql;
|
|
16042
|
-
summary.metadata = (0,
|
|
16438
|
+
summary.metadata = (0, import_behavioral_ir8.withGraphqlMetadata)(summary.metadata, rest);
|
|
16043
16439
|
}
|
|
16044
16440
|
for (const [label, schemaSdl] of sdlByDocument) {
|
|
16045
16441
|
summaries.push(schemaDocumentSummary(label, schemaSdl));
|
|
@@ -16054,8 +16450,8 @@ function schemaDocumentSummary(label, schemaSdl) {
|
|
|
16054
16450
|
transitions: [],
|
|
16055
16451
|
gaps: [],
|
|
16056
16452
|
confidence: { source: "declared", level: "high" },
|
|
16057
|
-
metadata: (0,
|
|
16058
|
-
(0,
|
|
16453
|
+
metadata: (0, import_behavioral_ir8.withGraphqlMetadata)(
|
|
16454
|
+
(0, import_behavioral_ir8.withSourceDocumentMetadata)(void 0, { label }),
|
|
16059
16455
|
{ schemaSdl }
|
|
16060
16456
|
)
|
|
16061
16457
|
};
|
|
@@ -16067,7 +16463,7 @@ function libraryEnvReadMarker(pack, declared, importer) {
|
|
|
16067
16463
|
identity: {
|
|
16068
16464
|
name: `${declared.module} env reads`,
|
|
16069
16465
|
exportPath: null,
|
|
16070
|
-
boundaryBinding: (0,
|
|
16466
|
+
boundaryBinding: (0, import_behavioral_ir8.functionCallBinding)({
|
|
16071
16467
|
transport: "in-process",
|
|
16072
16468
|
recognition: pack.name
|
|
16073
16469
|
})
|
|
@@ -16278,7 +16674,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path14, options) {
|
|
|
16278
16674
|
}
|
|
16279
16675
|
};
|
|
16280
16676
|
const raw = extractCodeStructure(unit, syntheticPack);
|
|
16281
|
-
raw.boundaryBinding = (0,
|
|
16677
|
+
raw.boundaryBinding = (0, import_behavioral_ir8.restBinding)({
|
|
16282
16678
|
transport: wrapperBinding?.transport ?? "http",
|
|
16283
16679
|
method: wrapperRest?.method ?? null,
|
|
16284
16680
|
path: path14,
|
|
@@ -16618,7 +17014,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
16618
17014
|
...projectHelpers.contributedRecognizers()
|
|
16619
17015
|
],
|
|
16620
17016
|
access: collectAccessRecognizers(config.frameworks, tallies),
|
|
16621
|
-
|
|
17017
|
+
resolution,
|
|
16622
17018
|
resolveCallableSources: (value, alsoFrom) => resolution.resolveCallableSources(value, alsoFrom),
|
|
16623
17019
|
sourceDeclarationsBehind: (declaration) => sourceDeclarationsBehind(declaration, resolution)
|
|
16624
17020
|
},
|
|
@@ -16851,10 +17247,10 @@ function mergeWithReused(reused, fresh, ownersBySummary) {
|
|
|
16851
17247
|
return { summaries: [...reusedKept, ...fresh], reusedKept, reusedOwners };
|
|
16852
17248
|
}
|
|
16853
17249
|
function readsRunLevelJoins(summary) {
|
|
16854
|
-
if ((0,
|
|
17250
|
+
if ((0, import_behavioral_ir8.readSourceDocumentMetadata)(summary) !== void 0) {
|
|
16855
17251
|
return true;
|
|
16856
17252
|
}
|
|
16857
|
-
if ((0,
|
|
17253
|
+
if ((0, import_behavioral_ir8.readGraphqlMetadata)(summary)?.client !== void 0) {
|
|
16858
17254
|
return true;
|
|
16859
17255
|
}
|
|
16860
17256
|
const semantics = summary.identity.boundaryBinding?.semantics;
|