@bitsness/grapuco-cli 0.1.8 → 0.1.10
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.js +549 -342
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -986,19 +986,17 @@ var generateId;
|
|
|
986
986
|
var init_utils = __esm({
|
|
987
987
|
"src/parser/ingestion/lib/utils.ts"() {
|
|
988
988
|
"use strict";
|
|
989
|
-
generateId = (label, name) => {
|
|
990
|
-
return `${label}:${name}`;
|
|
989
|
+
generateId = (label, name, lineNumber) => {
|
|
990
|
+
return lineNumber !== void 0 ? `${label}:${name}:${lineNumber}` : `${label}:${name}`;
|
|
991
991
|
};
|
|
992
992
|
}
|
|
993
993
|
});
|
|
994
994
|
|
|
995
|
-
// src/parser/ingestion/utils.ts
|
|
996
|
-
var DEFINITION_CAPTURE_KEYS, getDefinitionNodeFromCaptures, FUNCTION_NODE_TYPES, FUNCTION_DECLARATION_TYPES, BUILT_IN_NAMES, isBuiltInOrNoise
|
|
997
|
-
var
|
|
998
|
-
"src/parser/ingestion/utils.ts"() {
|
|
995
|
+
// src/parser/ingestion/utils/ast-constants.ts
|
|
996
|
+
var DEFINITION_CAPTURE_KEYS, getDefinitionNodeFromCaptures, FUNCTION_NODE_TYPES, FUNCTION_DECLARATION_TYPES, BUILT_IN_NAMES, isBuiltInOrNoise;
|
|
997
|
+
var init_ast_constants = __esm({
|
|
998
|
+
"src/parser/ingestion/utils/ast-constants.ts"() {
|
|
999
999
|
"use strict";
|
|
1000
|
-
init_parser_loader();
|
|
1001
|
-
init_utils();
|
|
1002
1000
|
DEFINITION_CAPTURE_KEYS = [
|
|
1003
1001
|
"definition.function",
|
|
1004
1002
|
"definition.class",
|
|
@@ -1044,10 +1042,6 @@ var init_utils2 = __esm({
|
|
|
1044
1042
|
// Java
|
|
1045
1043
|
"method_declaration",
|
|
1046
1044
|
"constructor_declaration",
|
|
1047
|
-
// C/C++
|
|
1048
|
-
// 'function_definition' already included above
|
|
1049
|
-
// Go
|
|
1050
|
-
// 'method_declaration' already included from Java
|
|
1051
1045
|
// C#
|
|
1052
1046
|
"local_function_statement",
|
|
1053
1047
|
// Rust
|
|
@@ -1184,7 +1178,6 @@ var init_utils2 = __esm({
|
|
|
1184
1178
|
"append",
|
|
1185
1179
|
"extend",
|
|
1186
1180
|
"update",
|
|
1187
|
-
// NOTE: 'open', 'read', 'write', 'close' removed — these are real C POSIX syscalls
|
|
1188
1181
|
"type",
|
|
1189
1182
|
"isinstance",
|
|
1190
1183
|
"issubclass",
|
|
@@ -1230,7 +1223,6 @@ var init_utils2 = __esm({
|
|
|
1230
1223
|
"buildSet",
|
|
1231
1224
|
"repeat",
|
|
1232
1225
|
"synchronized",
|
|
1233
|
-
// Kotlin coroutine builders & scope functions
|
|
1234
1226
|
"launch",
|
|
1235
1227
|
"async",
|
|
1236
1228
|
"runBlocking",
|
|
@@ -1238,7 +1230,6 @@ var init_utils2 = __esm({
|
|
|
1238
1230
|
"coroutineScope",
|
|
1239
1231
|
"supervisorScope",
|
|
1240
1232
|
"delay",
|
|
1241
|
-
// Kotlin Flow operators
|
|
1242
1233
|
"flow",
|
|
1243
1234
|
"flowOf",
|
|
1244
1235
|
"collect",
|
|
@@ -1254,7 +1245,6 @@ var init_utils2 = __esm({
|
|
|
1254
1245
|
"stateIn",
|
|
1255
1246
|
"shareIn",
|
|
1256
1247
|
"launchIn",
|
|
1257
|
-
// Kotlin infix stdlib functions
|
|
1258
1248
|
"to",
|
|
1259
1249
|
"until",
|
|
1260
1250
|
"downTo",
|
|
@@ -1314,7 +1304,6 @@ var init_utils2 = __esm({
|
|
|
1314
1304
|
"fflush",
|
|
1315
1305
|
"fgets",
|
|
1316
1306
|
"fputs",
|
|
1317
|
-
// Linux kernel common macros/helpers (not real call targets)
|
|
1318
1307
|
"likely",
|
|
1319
1308
|
"unlikely",
|
|
1320
1309
|
"BUG",
|
|
@@ -1571,7 +1560,6 @@ var init_utils2 = __esm({
|
|
|
1571
1560
|
"numericCast",
|
|
1572
1561
|
"type",
|
|
1573
1562
|
"MemoryLayout",
|
|
1574
|
-
// Swift collection/string methods (common noise)
|
|
1575
1563
|
"map",
|
|
1576
1564
|
"flatMap",
|
|
1577
1565
|
"compactMap",
|
|
@@ -1601,7 +1589,6 @@ var init_utils2 = __esm({
|
|
|
1601
1589
|
"index",
|
|
1602
1590
|
"startIndex",
|
|
1603
1591
|
"endIndex",
|
|
1604
|
-
// UIKit/Foundation common methods (noise in call graph)
|
|
1605
1592
|
"addSubview",
|
|
1606
1593
|
"removeFromSuperview",
|
|
1607
1594
|
"layoutSubviews",
|
|
@@ -1638,7 +1625,6 @@ var init_utils2 = __esm({
|
|
|
1638
1625
|
"popToRootViewController",
|
|
1639
1626
|
"performSegue",
|
|
1640
1627
|
"prepare",
|
|
1641
|
-
// GCD / async
|
|
1642
1628
|
"DispatchQueue",
|
|
1643
1629
|
"async",
|
|
1644
1630
|
"sync",
|
|
@@ -1646,13 +1632,11 @@ var init_utils2 = __esm({
|
|
|
1646
1632
|
"Task",
|
|
1647
1633
|
"withCheckedContinuation",
|
|
1648
1634
|
"withCheckedThrowingContinuation",
|
|
1649
|
-
// Combine
|
|
1650
1635
|
"sink",
|
|
1651
1636
|
"store",
|
|
1652
1637
|
"assign",
|
|
1653
1638
|
"receive",
|
|
1654
1639
|
"subscribe",
|
|
1655
|
-
// Notification / KVO
|
|
1656
1640
|
"addObserver",
|
|
1657
1641
|
"removeObserver",
|
|
1658
1642
|
"post",
|
|
@@ -1747,7 +1731,6 @@ var init_utils2 = __esm({
|
|
|
1747
1731
|
"dup",
|
|
1748
1732
|
"tap",
|
|
1749
1733
|
"yield_self",
|
|
1750
|
-
// Ruby enumerables
|
|
1751
1734
|
"each",
|
|
1752
1735
|
"select",
|
|
1753
1736
|
"reject",
|
|
@@ -1773,6 +1756,16 @@ var init_utils2 = __esm({
|
|
|
1773
1756
|
"uniq"
|
|
1774
1757
|
]);
|
|
1775
1758
|
isBuiltInOrNoise = (name) => BUILT_IN_NAMES.has(name);
|
|
1759
|
+
}
|
|
1760
|
+
});
|
|
1761
|
+
|
|
1762
|
+
// src/parser/ingestion/utils/ast-extractors.ts
|
|
1763
|
+
var CLASS_CONTAINER_TYPES, CONTAINER_TYPE_TO_LABEL, findEnclosingClassId, extractFunctionName;
|
|
1764
|
+
var init_ast_extractors = __esm({
|
|
1765
|
+
"src/parser/ingestion/utils/ast-extractors.ts"() {
|
|
1766
|
+
"use strict";
|
|
1767
|
+
init_utils();
|
|
1768
|
+
init_ast_constants();
|
|
1776
1769
|
CLASS_CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
1777
1770
|
"class_declaration",
|
|
1778
1771
|
"abstract_class_declaration",
|
|
@@ -1923,50 +1916,14 @@ var init_utils2 = __esm({
|
|
|
1923
1916
|
}
|
|
1924
1917
|
return { funcName, label };
|
|
1925
1918
|
};
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
return null;
|
|
1938
|
-
};
|
|
1939
|
-
getLanguageFromFilename = (filename) => {
|
|
1940
|
-
if (filename.endsWith(".tsx")) return "typescript" /* TypeScript */;
|
|
1941
|
-
if (filename.endsWith(".ts")) return "typescript" /* TypeScript */;
|
|
1942
|
-
if (filename.endsWith(".jsx")) return "javascript" /* JavaScript */;
|
|
1943
|
-
if (filename.endsWith(".js")) return "javascript" /* JavaScript */;
|
|
1944
|
-
if (filename.endsWith(".py")) return "python" /* Python */;
|
|
1945
|
-
if (filename.endsWith(".java")) return "java" /* Java */;
|
|
1946
|
-
if (filename.endsWith(".c")) return "c" /* C */;
|
|
1947
|
-
if (filename.endsWith(".cpp") || filename.endsWith(".cc") || filename.endsWith(".cxx") || filename.endsWith(".h") || filename.endsWith(".hpp") || filename.endsWith(".hxx") || filename.endsWith(".hh")) return "cpp" /* CPlusPlus */;
|
|
1948
|
-
if (filename.endsWith(".cs")) return "c_sharp" /* CSharp */;
|
|
1949
|
-
if (filename.endsWith(".go")) return "go" /* Go */;
|
|
1950
|
-
if (filename.endsWith(".rs")) return "rust" /* Rust */;
|
|
1951
|
-
if (filename.endsWith(".kt") || filename.endsWith(".kts")) return "kotlin" /* Kotlin */;
|
|
1952
|
-
if (filename.endsWith(".php") || filename.endsWith(".phtml") || filename.endsWith(".php3") || filename.endsWith(".php4") || filename.endsWith(".php5") || filename.endsWith(".php8")) {
|
|
1953
|
-
return "php" /* PHP */;
|
|
1954
|
-
}
|
|
1955
|
-
if (filename.endsWith(".rb") || filename.endsWith(".rake") || filename.endsWith(".gemspec")) {
|
|
1956
|
-
return "ruby" /* Ruby */;
|
|
1957
|
-
}
|
|
1958
|
-
const basename2 = filename.split("/").pop() || filename;
|
|
1959
|
-
if (RUBY_EXTENSIONLESS_FILES.has(basename2)) {
|
|
1960
|
-
return "ruby" /* Ruby */;
|
|
1961
|
-
}
|
|
1962
|
-
if (filename.endsWith(".swift")) return "swift" /* Swift */;
|
|
1963
|
-
return null;
|
|
1964
|
-
};
|
|
1965
|
-
CALL_ARGUMENT_LIST_TYPES = /* @__PURE__ */ new Set([
|
|
1966
|
-
"arguments",
|
|
1967
|
-
"argument_list",
|
|
1968
|
-
"value_arguments"
|
|
1969
|
-
]);
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
|
|
1922
|
+
// src/parser/ingestion/utils/signature-extractors.ts
|
|
1923
|
+
var extractMethodSignature;
|
|
1924
|
+
var init_signature_extractors = __esm({
|
|
1925
|
+
"src/parser/ingestion/utils/signature-extractors.ts"() {
|
|
1926
|
+
"use strict";
|
|
1970
1927
|
extractMethodSignature = (node) => {
|
|
1971
1928
|
let parameterCount = 0;
|
|
1972
1929
|
let returnType;
|
|
@@ -2082,6 +2039,19 @@ var init_utils2 = __esm({
|
|
|
2082
2039
|
if (isVariadic) parameterCount = void 0;
|
|
2083
2040
|
return { parameterCount, returnType };
|
|
2084
2041
|
};
|
|
2042
|
+
}
|
|
2043
|
+
});
|
|
2044
|
+
|
|
2045
|
+
// src/parser/ingestion/utils/call-extractors.ts
|
|
2046
|
+
var CALL_ARGUMENT_LIST_TYPES, countCallArguments, extractCallFirstStringArgument, MEMBER_ACCESS_NODE_TYPES, CONSTRUCTOR_CALL_NODE_TYPES, SCOPED_CALL_NODE_TYPES, inferCallForm, SIMPLE_RECEIVER_TYPES, extractReceiverName;
|
|
2047
|
+
var init_call_extractors = __esm({
|
|
2048
|
+
"src/parser/ingestion/utils/call-extractors.ts"() {
|
|
2049
|
+
"use strict";
|
|
2050
|
+
CALL_ARGUMENT_LIST_TYPES = /* @__PURE__ */ new Set([
|
|
2051
|
+
"arguments",
|
|
2052
|
+
"argument_list",
|
|
2053
|
+
"value_arguments"
|
|
2054
|
+
]);
|
|
2085
2055
|
countCallArguments = (callNode) => {
|
|
2086
2056
|
if (!callNode) return void 0;
|
|
2087
2057
|
let argsNode = callNode.childForFieldName("arguments") ?? callNode.children.find((child) => CALL_ARGUMENT_LIST_TYPES.has(child.type));
|
|
@@ -2104,6 +2074,43 @@ var init_utils2 = __esm({
|
|
|
2104
2074
|
}
|
|
2105
2075
|
return count;
|
|
2106
2076
|
};
|
|
2077
|
+
extractCallFirstStringArgument = (callNode) => {
|
|
2078
|
+
if (!callNode) return void 0;
|
|
2079
|
+
let argsNode = callNode.childForFieldName("arguments") ?? callNode.children.find((child) => CALL_ARGUMENT_LIST_TYPES.has(child.type));
|
|
2080
|
+
if (!argsNode) {
|
|
2081
|
+
for (const child of callNode.children) {
|
|
2082
|
+
if (!child.isNamed) continue;
|
|
2083
|
+
const nested = child.children.find((gc) => CALL_ARGUMENT_LIST_TYPES.has(gc.type));
|
|
2084
|
+
if (nested) {
|
|
2085
|
+
argsNode = nested;
|
|
2086
|
+
break;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
if (!argsNode) return void 0;
|
|
2091
|
+
let firstArg;
|
|
2092
|
+
for (const child of argsNode.children) {
|
|
2093
|
+
if (!child.isNamed || child.type === "comment") continue;
|
|
2094
|
+
firstArg = child;
|
|
2095
|
+
break;
|
|
2096
|
+
}
|
|
2097
|
+
if (!firstArg) return void 0;
|
|
2098
|
+
const stringTypes = /* @__PURE__ */ new Set([
|
|
2099
|
+
"string",
|
|
2100
|
+
"string_literal",
|
|
2101
|
+
"interpreted_string_literal",
|
|
2102
|
+
"raw_string_literal",
|
|
2103
|
+
"encapsed_string"
|
|
2104
|
+
]);
|
|
2105
|
+
if (stringTypes.has(firstArg.type)) {
|
|
2106
|
+
let text = firstArg.text;
|
|
2107
|
+
if (text.startsWith('"') && text.endsWith('"') || text.startsWith("'") && text.endsWith("'") || text.startsWith("`") && text.endsWith("`")) {
|
|
2108
|
+
return text.substring(1, text.length - 1);
|
|
2109
|
+
}
|
|
2110
|
+
return text;
|
|
2111
|
+
}
|
|
2112
|
+
return void 0;
|
|
2113
|
+
};
|
|
2107
2114
|
MEMBER_ACCESS_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
2108
2115
|
"member_expression",
|
|
2109
2116
|
// TS/JS: obj.method()
|
|
@@ -2233,6 +2240,13 @@ var init_utils2 = __esm({
|
|
|
2233
2240
|
if (SIMPLE_RECEIVER_TYPES.has(receiver.type)) {
|
|
2234
2241
|
return receiver.text;
|
|
2235
2242
|
}
|
|
2243
|
+
if (receiver.type === "member_expression" || receiver.type === "attribute") {
|
|
2244
|
+
const obj = receiver.childForFieldName("object");
|
|
2245
|
+
const prop = receiver.childForFieldName("property") || receiver.childForFieldName("attribute");
|
|
2246
|
+
if (obj && prop && (obj.text === "this" || obj.text === "self")) {
|
|
2247
|
+
return prop.text;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2236
2250
|
if (receiver.type === "call") {
|
|
2237
2251
|
const func = receiver.childForFieldName("function");
|
|
2238
2252
|
if (func?.text === "super") return "super";
|
|
@@ -2242,6 +2256,68 @@ var init_utils2 = __esm({
|
|
|
2242
2256
|
}
|
|
2243
2257
|
});
|
|
2244
2258
|
|
|
2259
|
+
// src/parser/ingestion/utils/language-utils.ts
|
|
2260
|
+
var RUBY_EXTENSIONLESS_FILES, getLanguageFromFilename;
|
|
2261
|
+
var init_language_utils = __esm({
|
|
2262
|
+
"src/parser/ingestion/utils/language-utils.ts"() {
|
|
2263
|
+
"use strict";
|
|
2264
|
+
init_parser_loader();
|
|
2265
|
+
RUBY_EXTENSIONLESS_FILES = /* @__PURE__ */ new Set(["Rakefile", "Gemfile", "Guardfile", "Vagrantfile", "Brewfile"]);
|
|
2266
|
+
getLanguageFromFilename = (filename) => {
|
|
2267
|
+
if (filename.endsWith(".tsx")) return "typescript" /* TypeScript */;
|
|
2268
|
+
if (filename.endsWith(".ts")) return "typescript" /* TypeScript */;
|
|
2269
|
+
if (filename.endsWith(".jsx")) return "javascript" /* JavaScript */;
|
|
2270
|
+
if (filename.endsWith(".js")) return "javascript" /* JavaScript */;
|
|
2271
|
+
if (filename.endsWith(".py")) return "python" /* Python */;
|
|
2272
|
+
if (filename.endsWith(".java")) return "java" /* Java */;
|
|
2273
|
+
if (filename.endsWith(".c")) return "c" /* C */;
|
|
2274
|
+
if (filename.endsWith(".cpp") || filename.endsWith(".cc") || filename.endsWith(".cxx") || filename.endsWith(".h") || filename.endsWith(".hpp") || filename.endsWith(".hxx") || filename.endsWith(".hh")) return "cpp" /* CPlusPlus */;
|
|
2275
|
+
if (filename.endsWith(".cs")) return "c_sharp" /* CSharp */;
|
|
2276
|
+
if (filename.endsWith(".go")) return "go" /* Go */;
|
|
2277
|
+
if (filename.endsWith(".rs")) return "rust" /* Rust */;
|
|
2278
|
+
if (filename.endsWith(".kt") || filename.endsWith(".kts")) return "kotlin" /* Kotlin */;
|
|
2279
|
+
if (filename.endsWith(".php") || filename.endsWith(".phtml") || filename.endsWith(".php3") || filename.endsWith(".php4") || filename.endsWith(".php5") || filename.endsWith(".php8")) {
|
|
2280
|
+
return "php" /* PHP */;
|
|
2281
|
+
}
|
|
2282
|
+
if (filename.endsWith(".rb") || filename.endsWith(".rake") || filename.endsWith(".gemspec")) {
|
|
2283
|
+
return "ruby" /* Ruby */;
|
|
2284
|
+
}
|
|
2285
|
+
const basename2 = filename.split(/[/\\]/).pop() || filename;
|
|
2286
|
+
if (RUBY_EXTENSIONLESS_FILES.has(basename2)) {
|
|
2287
|
+
return "ruby" /* Ruby */;
|
|
2288
|
+
}
|
|
2289
|
+
if (filename.endsWith(".swift")) return "swift" /* Swift */;
|
|
2290
|
+
return null;
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
|
|
2295
|
+
// src/parser/ingestion/utils.ts
|
|
2296
|
+
var findSiblingChild;
|
|
2297
|
+
var init_utils2 = __esm({
|
|
2298
|
+
"src/parser/ingestion/utils.ts"() {
|
|
2299
|
+
"use strict";
|
|
2300
|
+
init_utils();
|
|
2301
|
+
init_ast_constants();
|
|
2302
|
+
init_ast_extractors();
|
|
2303
|
+
init_signature_extractors();
|
|
2304
|
+
init_call_extractors();
|
|
2305
|
+
init_language_utils();
|
|
2306
|
+
findSiblingChild = (parent, siblingType, childType) => {
|
|
2307
|
+
for (let i = 0; i < parent.childCount; i++) {
|
|
2308
|
+
const sibling = parent.child(i);
|
|
2309
|
+
if (sibling?.type === siblingType) {
|
|
2310
|
+
for (let j = 0; j < sibling.childCount; j++) {
|
|
2311
|
+
const child = sibling.child(j);
|
|
2312
|
+
if (child?.type === childType) return child;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
return null;
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
});
|
|
2320
|
+
|
|
2245
2321
|
// src/parser/ingestion/type-extractors/shared.ts
|
|
2246
2322
|
var extractSimpleTypeName, extractVarName, TYPED_PARAMETER_TYPES, extractRubyConstructorAssignment, hasTypeAnnotation, unwrapAwait, extractCalleeName, findChildByType;
|
|
2247
2323
|
var init_shared = __esm({
|
|
@@ -4759,10 +4835,7 @@ var init_call_routing = __esm({
|
|
|
4759
4835
|
}
|
|
4760
4836
|
});
|
|
4761
4837
|
|
|
4762
|
-
// src/parser/ingestion/workers/
|
|
4763
|
-
function generateId2(type, name) {
|
|
4764
|
-
return `${type}:${name}`;
|
|
4765
|
-
}
|
|
4838
|
+
// src/parser/ingestion/workers/extractors/laravel-routes.ts
|
|
4766
4839
|
function findDescendant(node, type) {
|
|
4767
4840
|
if (node.type === type) return node;
|
|
4768
4841
|
for (const child of node.children ?? []) {
|
|
@@ -4773,232 +4846,84 @@ function findDescendant(node, type) {
|
|
|
4773
4846
|
}
|
|
4774
4847
|
function extractStringContent(node) {
|
|
4775
4848
|
if (!node) return null;
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4849
|
+
if (node.type === "string" || node.type === "encapsed_string") {
|
|
4850
|
+
if (node.childCount >= 3 && node.children) {
|
|
4851
|
+
return node.children.slice(1, -1).map((c) => c.text).join("");
|
|
4852
|
+
}
|
|
4853
|
+
return node.text?.replace(/^['"](.*)['"]$/, "$1") ?? null;
|
|
4854
|
+
}
|
|
4779
4855
|
return null;
|
|
4780
4856
|
}
|
|
4781
|
-
function
|
|
4782
|
-
if (
|
|
4783
|
-
const
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4857
|
+
function isRouteStaticCall(node) {
|
|
4858
|
+
if (node.type !== "scoped_call_expression") return false;
|
|
4859
|
+
const obj = node.childForFieldName?.("object") ?? node.children?.[0];
|
|
4860
|
+
return obj?.text === "Route";
|
|
4861
|
+
}
|
|
4862
|
+
function getCallMethodName(node) {
|
|
4863
|
+
const nameNode = node.childForFieldName?.("name") ?? node.children?.find((c) => c.type === "name");
|
|
4864
|
+
return nameNode?.text ?? null;
|
|
4865
|
+
}
|
|
4866
|
+
function getArguments(node) {
|
|
4867
|
+
return node.children?.find((c) => c.type === "arguments") ?? null;
|
|
4868
|
+
}
|
|
4869
|
+
function findClosureBody(argsNode) {
|
|
4870
|
+
if (!argsNode) return null;
|
|
4871
|
+
for (const child of argsNode.children ?? []) {
|
|
4872
|
+
if (child.type === "argument") {
|
|
4873
|
+
for (const inner of child.children ?? []) {
|
|
4874
|
+
if (inner.type === "anonymous_function" || inner.type === "arrow_function") {
|
|
4875
|
+
return inner.childForFieldName?.("body") ?? inner.children?.find((c) => c.type === "compound_statement");
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
}
|
|
4879
|
+
if (child.type === "anonymous_function" || child.type === "arrow_function") {
|
|
4880
|
+
return child.childForFieldName?.("body") ?? child.children?.find((c) => c.type === "compound_statement");
|
|
4797
4881
|
}
|
|
4798
4882
|
}
|
|
4799
|
-
return
|
|
4883
|
+
return null;
|
|
4800
4884
|
}
|
|
4801
|
-
function
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
}
|
|
4809
|
-
for (const child of node.children ?? []) {
|
|
4810
|
-
const found = findRelationCall(child);
|
|
4811
|
-
if (found) return found;
|
|
4885
|
+
function extractFirstStringArg(argsNode) {
|
|
4886
|
+
if (!argsNode) return null;
|
|
4887
|
+
for (const child of argsNode.children ?? []) {
|
|
4888
|
+
const target = child.type === "argument" ? child.children?.[0] : child;
|
|
4889
|
+
if (!target) continue;
|
|
4890
|
+
if (target.type === "string" || target.type === "encapsed_string") {
|
|
4891
|
+
return extractStringContent(target);
|
|
4812
4892
|
}
|
|
4813
|
-
return null;
|
|
4814
4893
|
}
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
if (
|
|
4823
|
-
const
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4894
|
+
return null;
|
|
4895
|
+
}
|
|
4896
|
+
function extractMiddlewareArg(argsNode) {
|
|
4897
|
+
if (!argsNode) return [];
|
|
4898
|
+
for (const child of argsNode.children ?? []) {
|
|
4899
|
+
const target = child.type === "argument" ? child.children?.[0] : child;
|
|
4900
|
+
if (!target) continue;
|
|
4901
|
+
if (target.type === "string" || target.type === "encapsed_string") {
|
|
4902
|
+
const val = extractStringContent(target);
|
|
4903
|
+
return val ? [val] : [];
|
|
4904
|
+
}
|
|
4905
|
+
if (target.type === "array_creation_expression") {
|
|
4906
|
+
const items = [];
|
|
4907
|
+
for (const el of target.children ?? []) {
|
|
4908
|
+
if (el.type === "array_element_initializer") {
|
|
4909
|
+
const str = el.children?.find((c) => c.type === "string" || c.type === "encapsed_string");
|
|
4910
|
+
const val = str ? extractStringContent(str) : null;
|
|
4911
|
+
if (val) items.push(val);
|
|
4912
|
+
}
|
|
4828
4913
|
}
|
|
4914
|
+
return items;
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4917
|
+
return [];
|
|
4918
|
+
}
|
|
4919
|
+
function extractClassArg(argsNode) {
|
|
4920
|
+
if (!argsNode) return null;
|
|
4921
|
+
for (const child of argsNode.children ?? []) {
|
|
4922
|
+
const target = child.type === "argument" ? child.children?.[0] : child;
|
|
4923
|
+
if (target?.type === "class_constant_access_expression") {
|
|
4924
|
+
return target.children?.find((c) => c.type === "name")?.text ?? null;
|
|
4829
4925
|
}
|
|
4830
4926
|
}
|
|
4831
|
-
if (relType && targetModel) return `${relType}(${targetModel})`;
|
|
4832
|
-
if (relType) return relType;
|
|
4833
|
-
return null;
|
|
4834
|
-
}
|
|
4835
|
-
function parseDecoratorText(decoratorNode) {
|
|
4836
|
-
const text = decoratorNode.text || "";
|
|
4837
|
-
const match = text.match(/@(\w+)\s*(?:\(\s*['"]([^'"]*)['"]\s*\)|\(\s*\))?/);
|
|
4838
|
-
if (!match) return null;
|
|
4839
|
-
return { name: match[1], firstArg: match[2] ?? null };
|
|
4840
|
-
}
|
|
4841
|
-
function findDecoratorBackward(parentNode, startIdx, matchFn) {
|
|
4842
|
-
for (let i = startIdx - 1; i >= 0; i--) {
|
|
4843
|
-
const sib = parentNode.child(i);
|
|
4844
|
-
if (!sib) break;
|
|
4845
|
-
if (sib.type !== "decorator") break;
|
|
4846
|
-
const info = parseDecoratorText(sib);
|
|
4847
|
-
if (info && matchFn(info.name)) return info;
|
|
4848
|
-
}
|
|
4849
|
-
return null;
|
|
4850
|
-
}
|
|
4851
|
-
function extractNestJSRoutes(tree, filePath) {
|
|
4852
|
-
const routes = [];
|
|
4853
|
-
function processClassDeclaration(classNode, classIdx, classParent) {
|
|
4854
|
-
let controllerPrefix = null;
|
|
4855
|
-
const controllerDec = findDecoratorBackward(
|
|
4856
|
-
classParent,
|
|
4857
|
-
classIdx,
|
|
4858
|
-
(name) => NESTJS_CONTROLLER_NAMES.has(name)
|
|
4859
|
-
);
|
|
4860
|
-
if (controllerDec) {
|
|
4861
|
-
controllerPrefix = controllerDec.firstArg || "";
|
|
4862
|
-
} else {
|
|
4863
|
-
for (let i = 0; i < classNode.childCount; i++) {
|
|
4864
|
-
const child = classNode.child(i);
|
|
4865
|
-
if (child?.type === "decorator") {
|
|
4866
|
-
const info = parseDecoratorText(child);
|
|
4867
|
-
if (info && NESTJS_CONTROLLER_NAMES.has(info.name)) {
|
|
4868
|
-
controllerPrefix = info.firstArg || "";
|
|
4869
|
-
break;
|
|
4870
|
-
}
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
4873
|
-
}
|
|
4874
|
-
if (controllerPrefix === null) {
|
|
4875
|
-
const nameNode2 = classNode.childForFieldName?.("name");
|
|
4876
|
-
const className2 = nameNode2?.text || "";
|
|
4877
|
-
if (className2.endsWith("Controller")) {
|
|
4878
|
-
const fileBase = filePath.match(/([^/\\]+)\.controller\./i);
|
|
4879
|
-
controllerPrefix = fileBase ? fileBase[1] : "";
|
|
4880
|
-
} else {
|
|
4881
|
-
return;
|
|
4882
|
-
}
|
|
4883
|
-
}
|
|
4884
|
-
const nameNode = classNode.childForFieldName?.("name");
|
|
4885
|
-
const className = nameNode?.text || "";
|
|
4886
|
-
const body = classNode.childForFieldName?.("body");
|
|
4887
|
-
if (!body) return;
|
|
4888
|
-
for (let mi = 0; mi < body.childCount; mi++) {
|
|
4889
|
-
const child = body.child(mi);
|
|
4890
|
-
if (!child || child.type !== "method_definition") continue;
|
|
4891
|
-
const routeDec = findDecoratorBackward(
|
|
4892
|
-
body,
|
|
4893
|
-
mi,
|
|
4894
|
-
(name) => name in NESTJS_ROUTE_DECORATORS
|
|
4895
|
-
);
|
|
4896
|
-
if (!routeDec) continue;
|
|
4897
|
-
const methodName = child.childForFieldName?.("name")?.text || "";
|
|
4898
|
-
routes.push({
|
|
4899
|
-
filePath,
|
|
4900
|
-
httpMethod: NESTJS_ROUTE_DECORATORS[routeDec.name],
|
|
4901
|
-
routePath: routeDec.firstArg,
|
|
4902
|
-
controllerName: className,
|
|
4903
|
-
methodName,
|
|
4904
|
-
middleware: [],
|
|
4905
|
-
prefix: controllerPrefix,
|
|
4906
|
-
lineNumber: child.startPosition.row,
|
|
4907
|
-
handlerNodeId: generateId2("Method", `${filePath}:${methodName}`)
|
|
4908
|
-
});
|
|
4909
|
-
}
|
|
4910
|
-
}
|
|
4911
|
-
function walk(node) {
|
|
4912
|
-
for (let i = 0; i < (node.childCount ?? 0); i++) {
|
|
4913
|
-
const child = node.child(i);
|
|
4914
|
-
if (!child) continue;
|
|
4915
|
-
if (child.type === "class_declaration") {
|
|
4916
|
-
processClassDeclaration(child, i, node);
|
|
4917
|
-
} else if (child.type === "export_statement") {
|
|
4918
|
-
for (let j = 0; j < child.childCount; j++) {
|
|
4919
|
-
const inner = child.child(j);
|
|
4920
|
-
if (inner?.type === "class_declaration") {
|
|
4921
|
-
processClassDeclaration(inner, j, child);
|
|
4922
|
-
}
|
|
4923
|
-
}
|
|
4924
|
-
} else {
|
|
4925
|
-
walk(child);
|
|
4926
|
-
}
|
|
4927
|
-
}
|
|
4928
|
-
}
|
|
4929
|
-
walk(tree.rootNode);
|
|
4930
|
-
return routes;
|
|
4931
|
-
}
|
|
4932
|
-
function isRouteStaticCall(node) {
|
|
4933
|
-
if (node.type !== "scoped_call_expression") return false;
|
|
4934
|
-
const obj = node.childForFieldName?.("object") ?? node.children?.[0];
|
|
4935
|
-
return obj?.text === "Route";
|
|
4936
|
-
}
|
|
4937
|
-
function getCallMethodName(node) {
|
|
4938
|
-
const nameNode = node.childForFieldName?.("name") ?? node.children?.find((c) => c.type === "name");
|
|
4939
|
-
return nameNode?.text ?? null;
|
|
4940
|
-
}
|
|
4941
|
-
function getArguments(node) {
|
|
4942
|
-
return node.children?.find((c) => c.type === "arguments") ?? null;
|
|
4943
|
-
}
|
|
4944
|
-
function findClosureBody(argsNode) {
|
|
4945
|
-
if (!argsNode) return null;
|
|
4946
|
-
for (const child of argsNode.children ?? []) {
|
|
4947
|
-
if (child.type === "argument") {
|
|
4948
|
-
for (const inner of child.children ?? []) {
|
|
4949
|
-
if (inner.type === "anonymous_function" || inner.type === "arrow_function") {
|
|
4950
|
-
return inner.childForFieldName?.("body") ?? inner.children?.find((c) => c.type === "compound_statement");
|
|
4951
|
-
}
|
|
4952
|
-
}
|
|
4953
|
-
}
|
|
4954
|
-
if (child.type === "anonymous_function" || child.type === "arrow_function") {
|
|
4955
|
-
return child.childForFieldName?.("body") ?? child.children?.find((c) => c.type === "compound_statement");
|
|
4956
|
-
}
|
|
4957
|
-
}
|
|
4958
|
-
return null;
|
|
4959
|
-
}
|
|
4960
|
-
function extractFirstStringArg(argsNode) {
|
|
4961
|
-
if (!argsNode) return null;
|
|
4962
|
-
for (const child of argsNode.children ?? []) {
|
|
4963
|
-
const target = child.type === "argument" ? child.children?.[0] : child;
|
|
4964
|
-
if (!target) continue;
|
|
4965
|
-
if (target.type === "string" || target.type === "encapsed_string") {
|
|
4966
|
-
return extractStringContent(target);
|
|
4967
|
-
}
|
|
4968
|
-
}
|
|
4969
|
-
return null;
|
|
4970
|
-
}
|
|
4971
|
-
function extractMiddlewareArg(argsNode) {
|
|
4972
|
-
if (!argsNode) return [];
|
|
4973
|
-
for (const child of argsNode.children ?? []) {
|
|
4974
|
-
const target = child.type === "argument" ? child.children?.[0] : child;
|
|
4975
|
-
if (!target) continue;
|
|
4976
|
-
if (target.type === "string" || target.type === "encapsed_string") {
|
|
4977
|
-
const val = extractStringContent(target);
|
|
4978
|
-
return val ? [val] : [];
|
|
4979
|
-
}
|
|
4980
|
-
if (target.type === "array_creation_expression") {
|
|
4981
|
-
const items = [];
|
|
4982
|
-
for (const el of target.children ?? []) {
|
|
4983
|
-
if (el.type === "array_element_initializer") {
|
|
4984
|
-
const str = el.children?.find((c) => c.type === "string" || c.type === "encapsed_string");
|
|
4985
|
-
const val = str ? extractStringContent(str) : null;
|
|
4986
|
-
if (val) items.push(val);
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
|
-
return items;
|
|
4990
|
-
}
|
|
4991
|
-
}
|
|
4992
|
-
return [];
|
|
4993
|
-
}
|
|
4994
|
-
function extractClassArg(argsNode) {
|
|
4995
|
-
if (!argsNode) return null;
|
|
4996
|
-
for (const child of argsNode.children ?? []) {
|
|
4997
|
-
const target = child.type === "argument" ? child.children?.[0] : child;
|
|
4998
|
-
if (target?.type === "class_constant_access_expression") {
|
|
4999
|
-
return target.children?.find((c) => c.type === "name")?.text ?? null;
|
|
5000
|
-
}
|
|
5001
|
-
}
|
|
5002
4927
|
return null;
|
|
5003
4928
|
}
|
|
5004
4929
|
function extractControllerTarget(argsNode) {
|
|
@@ -5139,8 +5064,8 @@ function extractLaravelRoutes(tree, filePath) {
|
|
|
5139
5064
|
for (const action of actions) {
|
|
5140
5065
|
routes.push({
|
|
5141
5066
|
filePath,
|
|
5142
|
-
httpMethod,
|
|
5143
|
-
routePath,
|
|
5067
|
+
httpMethod: "ANY",
|
|
5068
|
+
routePath: routePath ? `${routePath}/${action}` : null,
|
|
5144
5069
|
controllerName: target.controller ?? effective.controller,
|
|
5145
5070
|
methodName: action,
|
|
5146
5071
|
middleware: [...effective.middleware],
|
|
@@ -5149,17 +5074,20 @@ function extractLaravelRoutes(tree, filePath) {
|
|
|
5149
5074
|
});
|
|
5150
5075
|
}
|
|
5151
5076
|
} else {
|
|
5152
|
-
const
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5077
|
+
const methods = httpMethod === "match" ? extractMiddlewareArg(argsNode) : [httpMethod];
|
|
5078
|
+
const targetCtx = ROUTE_HTTP_METHODS.has(httpMethod) || httpMethod === "match" ? extractControllerTarget(argsNode) : { controller: null, method: null };
|
|
5079
|
+
for (const method of methods) {
|
|
5080
|
+
routes.push({
|
|
5081
|
+
filePath,
|
|
5082
|
+
httpMethod: method.toUpperCase(),
|
|
5083
|
+
routePath,
|
|
5084
|
+
controllerName: targetCtx.controller ?? effective.controller,
|
|
5085
|
+
methodName: targetCtx.method,
|
|
5086
|
+
middleware: [...effective.middleware],
|
|
5087
|
+
prefix: effective.prefix,
|
|
5088
|
+
lineNumber
|
|
5089
|
+
});
|
|
5090
|
+
}
|
|
5163
5091
|
}
|
|
5164
5092
|
}
|
|
5165
5093
|
function walk(node, groupStack) {
|
|
@@ -5213,7 +5141,296 @@ function extractLaravelRoutes(tree, filePath) {
|
|
|
5213
5141
|
walk(tree.rootNode, []);
|
|
5214
5142
|
return routes;
|
|
5215
5143
|
}
|
|
5216
|
-
var
|
|
5144
|
+
var ROUTE_HTTP_METHODS, ROUTE_RESOURCE_METHODS, RESOURCE_ACTIONS, API_RESOURCE_ACTIONS;
|
|
5145
|
+
var init_laravel_routes = __esm({
|
|
5146
|
+
"src/parser/ingestion/workers/extractors/laravel-routes.ts"() {
|
|
5147
|
+
"use strict";
|
|
5148
|
+
ROUTE_HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
5149
|
+
"get",
|
|
5150
|
+
"post",
|
|
5151
|
+
"put",
|
|
5152
|
+
"patch",
|
|
5153
|
+
"delete",
|
|
5154
|
+
"options",
|
|
5155
|
+
"any",
|
|
5156
|
+
"match"
|
|
5157
|
+
]);
|
|
5158
|
+
ROUTE_RESOURCE_METHODS = /* @__PURE__ */ new Set(["resource", "apiResource"]);
|
|
5159
|
+
RESOURCE_ACTIONS = ["index", "create", "store", "show", "edit", "update", "destroy"];
|
|
5160
|
+
API_RESOURCE_ACTIONS = ["index", "store", "show", "update", "destroy"];
|
|
5161
|
+
}
|
|
5162
|
+
});
|
|
5163
|
+
|
|
5164
|
+
// src/parser/ingestion/workers/extractors/nestjs-routes.ts
|
|
5165
|
+
function parseDecoratorText(decoratorNode) {
|
|
5166
|
+
const text = decoratorNode.text || "";
|
|
5167
|
+
const match = text.match(/@(\w+)\s*(?:\(\s*['"]([^'"]*)['"]\s*\)|\(\s*\))?/);
|
|
5168
|
+
if (!match) return null;
|
|
5169
|
+
return { name: match[1], firstArg: match[2] ?? null };
|
|
5170
|
+
}
|
|
5171
|
+
function findDecoratorBackward(parentNode, startIdx, matchFn) {
|
|
5172
|
+
for (let i = startIdx - 1; i >= 0; i--) {
|
|
5173
|
+
const sib = parentNode.child(i);
|
|
5174
|
+
if (!sib) break;
|
|
5175
|
+
if (sib.type !== "decorator") break;
|
|
5176
|
+
const info = parseDecoratorText(sib);
|
|
5177
|
+
if (info && matchFn(info.name)) return info;
|
|
5178
|
+
}
|
|
5179
|
+
return null;
|
|
5180
|
+
}
|
|
5181
|
+
function extractNestJSRoutes(tree, filePath) {
|
|
5182
|
+
const routes = [];
|
|
5183
|
+
function processClassDeclaration(classNode, classIdx, classParent) {
|
|
5184
|
+
let controllerPrefix = null;
|
|
5185
|
+
const controllerDec = findDecoratorBackward(
|
|
5186
|
+
classParent,
|
|
5187
|
+
classIdx,
|
|
5188
|
+
(name) => NESTJS_CONTROLLER_NAMES.has(name)
|
|
5189
|
+
);
|
|
5190
|
+
if (controllerDec) {
|
|
5191
|
+
controllerPrefix = controllerDec.firstArg || "";
|
|
5192
|
+
} else {
|
|
5193
|
+
for (let i = 0; i < classNode.childCount; i++) {
|
|
5194
|
+
const child = classNode.child(i);
|
|
5195
|
+
if (child?.type === "decorator") {
|
|
5196
|
+
const info = parseDecoratorText(child);
|
|
5197
|
+
if (info && NESTJS_CONTROLLER_NAMES.has(info.name)) {
|
|
5198
|
+
controllerPrefix = info.firstArg || "";
|
|
5199
|
+
break;
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
if (controllerPrefix === null) {
|
|
5205
|
+
const nameNode2 = classNode.childForFieldName?.("name");
|
|
5206
|
+
const className2 = nameNode2?.text || "";
|
|
5207
|
+
if (className2.endsWith("Controller")) {
|
|
5208
|
+
const fileBase = filePath.match(/([^/\\]+)\.controller\./i);
|
|
5209
|
+
controllerPrefix = fileBase ? fileBase[1] : "";
|
|
5210
|
+
} else {
|
|
5211
|
+
return;
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
const nameNode = classNode.childForFieldName?.("name");
|
|
5215
|
+
const className = nameNode?.text || "";
|
|
5216
|
+
const body = classNode.childForFieldName?.("body");
|
|
5217
|
+
if (!body) return;
|
|
5218
|
+
for (let mi = 0; mi < body.childCount; mi++) {
|
|
5219
|
+
const child = body.child(mi);
|
|
5220
|
+
if (!child || child.type !== "method_definition") continue;
|
|
5221
|
+
const routeDec = findDecoratorBackward(
|
|
5222
|
+
body,
|
|
5223
|
+
mi,
|
|
5224
|
+
(name) => name in NESTJS_ROUTE_DECORATORS
|
|
5225
|
+
);
|
|
5226
|
+
if (!routeDec) continue;
|
|
5227
|
+
const methodName = child.childForFieldName?.("name")?.text || "";
|
|
5228
|
+
routes.push({
|
|
5229
|
+
filePath,
|
|
5230
|
+
httpMethod: NESTJS_ROUTE_DECORATORS[routeDec.name],
|
|
5231
|
+
routePath: routeDec.firstArg,
|
|
5232
|
+
controllerName: className,
|
|
5233
|
+
methodName,
|
|
5234
|
+
middleware: [],
|
|
5235
|
+
prefix: controllerPrefix,
|
|
5236
|
+
lineNumber: child.startPosition.row,
|
|
5237
|
+
handlerNodeId: generateId("Method", `${filePath}:${methodName}`)
|
|
5238
|
+
});
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
function walk(node) {
|
|
5242
|
+
for (let i = 0; i < (node.childCount ?? 0); i++) {
|
|
5243
|
+
const child = node.child(i);
|
|
5244
|
+
if (!child) continue;
|
|
5245
|
+
if (child.type === "class_declaration") {
|
|
5246
|
+
processClassDeclaration(child, i, node);
|
|
5247
|
+
} else if (child.type === "export_statement") {
|
|
5248
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
5249
|
+
const inner = child.child(j);
|
|
5250
|
+
if (inner?.type === "class_declaration") {
|
|
5251
|
+
processClassDeclaration(inner, j, child);
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
5254
|
+
} else {
|
|
5255
|
+
walk(child);
|
|
5256
|
+
}
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
walk(tree.rootNode);
|
|
5260
|
+
return routes;
|
|
5261
|
+
}
|
|
5262
|
+
var NESTJS_ROUTE_DECORATORS, NESTJS_CONTROLLER_NAMES;
|
|
5263
|
+
var init_nestjs_routes = __esm({
|
|
5264
|
+
"src/parser/ingestion/workers/extractors/nestjs-routes.ts"() {
|
|
5265
|
+
"use strict";
|
|
5266
|
+
init_utils2();
|
|
5267
|
+
NESTJS_ROUTE_DECORATORS = {
|
|
5268
|
+
"Get": "GET",
|
|
5269
|
+
"Post": "POST",
|
|
5270
|
+
"Put": "PUT",
|
|
5271
|
+
"Patch": "PATCH",
|
|
5272
|
+
"Delete": "DELETE",
|
|
5273
|
+
"Options": "OPTIONS",
|
|
5274
|
+
"Head": "HEAD",
|
|
5275
|
+
"All": "ALL"
|
|
5276
|
+
};
|
|
5277
|
+
NESTJS_CONTROLLER_NAMES = /* @__PURE__ */ new Set(["Controller", "RestController"]);
|
|
5278
|
+
}
|
|
5279
|
+
});
|
|
5280
|
+
|
|
5281
|
+
// src/parser/ingestion/workers/extractors/nestjs-events.ts
|
|
5282
|
+
var extractNestJSEvents;
|
|
5283
|
+
var init_nestjs_events = __esm({
|
|
5284
|
+
"src/parser/ingestion/workers/extractors/nestjs-events.ts"() {
|
|
5285
|
+
"use strict";
|
|
5286
|
+
extractNestJSEvents = (tree, filePath) => {
|
|
5287
|
+
const events = [];
|
|
5288
|
+
const rootNode = tree.rootNode;
|
|
5289
|
+
const walk = (node, currentClass = null) => {
|
|
5290
|
+
if (node.type === "class_declaration") {
|
|
5291
|
+
const nameNode = node.childForFieldName("name");
|
|
5292
|
+
currentClass = nameNode ? nameNode.text : null;
|
|
5293
|
+
}
|
|
5294
|
+
if (node.type === "method_definition") {
|
|
5295
|
+
const methodNameNode = node.childForFieldName("name");
|
|
5296
|
+
const methodName = methodNameNode ? methodNameNode.text : null;
|
|
5297
|
+
for (const child of node.children) {
|
|
5298
|
+
if (child.type === "decorator") {
|
|
5299
|
+
const callExp = child.children.find((c) => c.type === "call_expression");
|
|
5300
|
+
if (callExp) {
|
|
5301
|
+
const funcName = callExp.childForFieldName("function")?.text;
|
|
5302
|
+
if (funcName === "EventPattern" || funcName === "MessagePattern") {
|
|
5303
|
+
const argsNode = callExp.childForFieldName("arguments");
|
|
5304
|
+
if (argsNode) {
|
|
5305
|
+
let topicName = null;
|
|
5306
|
+
for (const arg of argsNode.children) {
|
|
5307
|
+
if (arg.type === "string") {
|
|
5308
|
+
topicName = arg.text.substring(1, arg.text.length - 1);
|
|
5309
|
+
break;
|
|
5310
|
+
}
|
|
5311
|
+
}
|
|
5312
|
+
if (topicName) {
|
|
5313
|
+
events.push({
|
|
5314
|
+
filePath,
|
|
5315
|
+
topicName,
|
|
5316
|
+
className: currentClass,
|
|
5317
|
+
methodName,
|
|
5318
|
+
framework: funcName === "EventPattern" ? "nestjs-event" : "nestjs-message",
|
|
5319
|
+
lineNumber: node.startPosition.row
|
|
5320
|
+
});
|
|
5321
|
+
}
|
|
5322
|
+
}
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
}
|
|
5326
|
+
}
|
|
5327
|
+
}
|
|
5328
|
+
for (const child of node.children) {
|
|
5329
|
+
walk(child, currentClass);
|
|
5330
|
+
}
|
|
5331
|
+
};
|
|
5332
|
+
walk(rootNode);
|
|
5333
|
+
return events;
|
|
5334
|
+
};
|
|
5335
|
+
}
|
|
5336
|
+
});
|
|
5337
|
+
|
|
5338
|
+
// src/parser/ingestion/workers/extractors/php-eloquent.ts
|
|
5339
|
+
function findDescendant2(node, type) {
|
|
5340
|
+
if (node.type === type) return node;
|
|
5341
|
+
for (const child of node.children ?? []) {
|
|
5342
|
+
const found = findDescendant2(child, type);
|
|
5343
|
+
if (found) return found;
|
|
5344
|
+
}
|
|
5345
|
+
return null;
|
|
5346
|
+
}
|
|
5347
|
+
function extractStringContent2(node) {
|
|
5348
|
+
if (!node) return null;
|
|
5349
|
+
const content = node.children?.find((c) => c.type === "string_content");
|
|
5350
|
+
if (content) return content.text;
|
|
5351
|
+
if (node.type === "string_content") return node.text;
|
|
5352
|
+
return null;
|
|
5353
|
+
}
|
|
5354
|
+
function extractPhpPropertyDescription(propName, propDeclNode) {
|
|
5355
|
+
if (!ELOQUENT_ARRAY_PROPS.has(propName)) return null;
|
|
5356
|
+
const arrayNode = findDescendant2(propDeclNode, "array_creation_expression");
|
|
5357
|
+
if (!arrayNode) return null;
|
|
5358
|
+
const items = [];
|
|
5359
|
+
for (const child of arrayNode.children ?? []) {
|
|
5360
|
+
if (child.type !== "array_element_initializer") continue;
|
|
5361
|
+
const children = child.children ?? [];
|
|
5362
|
+
const arrowIdx = children.findIndex((c) => c.type === "=>");
|
|
5363
|
+
if (arrowIdx !== -1) {
|
|
5364
|
+
const key = extractStringContent2(children[arrowIdx - 1]);
|
|
5365
|
+
const val = extractStringContent2(children[arrowIdx + 1]);
|
|
5366
|
+
if (key && val) items.push(`${key}:${val}`);
|
|
5367
|
+
} else {
|
|
5368
|
+
const val = extractStringContent2(children[0]);
|
|
5369
|
+
if (val) items.push(val);
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
return items.length > 0 ? items.join(", ") : null;
|
|
5373
|
+
}
|
|
5374
|
+
function extractEloquentRelationDescription(methodNode) {
|
|
5375
|
+
function findRelationCall(node) {
|
|
5376
|
+
if (node.type === "member_call_expression") {
|
|
5377
|
+
const children = node.children ?? [];
|
|
5378
|
+
const objectNode = children.find((c) => c.type === "variable_name" && c.text === "$this");
|
|
5379
|
+
const nameNode = children.find((c) => c.type === "name");
|
|
5380
|
+
if (objectNode && nameNode && ELOQUENT_RELATIONS.has(nameNode.text)) return node;
|
|
5381
|
+
}
|
|
5382
|
+
for (const child of node.children ?? []) {
|
|
5383
|
+
const found = findRelationCall(child);
|
|
5384
|
+
if (found) return found;
|
|
5385
|
+
}
|
|
5386
|
+
return null;
|
|
5387
|
+
}
|
|
5388
|
+
const callNode = findRelationCall(methodNode);
|
|
5389
|
+
if (!callNode) return null;
|
|
5390
|
+
const relType = callNode.children?.find((c) => c.type === "name")?.text;
|
|
5391
|
+
const argsNode = callNode.children?.find((c) => c.type === "arguments");
|
|
5392
|
+
let targetModel = null;
|
|
5393
|
+
if (argsNode) {
|
|
5394
|
+
const firstArg = argsNode.children?.find((c) => c.type === "argument");
|
|
5395
|
+
if (firstArg) {
|
|
5396
|
+
const classConstant = firstArg.children?.find(
|
|
5397
|
+
(c) => c.type === "class_constant_access_expression"
|
|
5398
|
+
);
|
|
5399
|
+
if (classConstant) {
|
|
5400
|
+
targetModel = classConstant.children?.find((c) => c.type === "name")?.text ?? null;
|
|
5401
|
+
}
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5404
|
+
if (relType && targetModel) return `${relType}(${targetModel})`;
|
|
5405
|
+
if (relType) return relType;
|
|
5406
|
+
return null;
|
|
5407
|
+
}
|
|
5408
|
+
var ELOQUENT_ARRAY_PROPS, ELOQUENT_RELATIONS;
|
|
5409
|
+
var init_php_eloquent = __esm({
|
|
5410
|
+
"src/parser/ingestion/workers/extractors/php-eloquent.ts"() {
|
|
5411
|
+
"use strict";
|
|
5412
|
+
ELOQUENT_ARRAY_PROPS = /* @__PURE__ */ new Set(["fillable", "casts", "hidden", "guarded", "with", "appends"]);
|
|
5413
|
+
ELOQUENT_RELATIONS = /* @__PURE__ */ new Set([
|
|
5414
|
+
"hasMany",
|
|
5415
|
+
"hasOne",
|
|
5416
|
+
"belongsTo",
|
|
5417
|
+
"belongsToMany",
|
|
5418
|
+
"morphTo",
|
|
5419
|
+
"morphMany",
|
|
5420
|
+
"morphOne",
|
|
5421
|
+
"morphToMany",
|
|
5422
|
+
"morphedByMany",
|
|
5423
|
+
"hasManyThrough",
|
|
5424
|
+
"hasOneThrough"
|
|
5425
|
+
]);
|
|
5426
|
+
}
|
|
5427
|
+
});
|
|
5428
|
+
|
|
5429
|
+
// src/parser/ingestion/workers/parse-worker.ts
|
|
5430
|
+
function generateId2(type, name) {
|
|
5431
|
+
return `${type}:${name}`;
|
|
5432
|
+
}
|
|
5433
|
+
var import_node_worker_threads, Parser3, import_node_module, _require, parser2, setLanguage, findEnclosingFunctionId, getLabelFromCaptures, processBatch, processFileGroup, accumulated, cumulativeProcessed, mergeResult;
|
|
5217
5434
|
var init_parse_worker = __esm({
|
|
5218
5435
|
"src/parser/ingestion/workers/parse-worker.ts"() {
|
|
5219
5436
|
"use strict";
|
|
@@ -5231,6 +5448,10 @@ var init_parse_worker = __esm({
|
|
|
5231
5448
|
init_named_binding_extraction();
|
|
5232
5449
|
init_resolvers();
|
|
5233
5450
|
init_call_routing();
|
|
5451
|
+
init_laravel_routes();
|
|
5452
|
+
init_nestjs_routes();
|
|
5453
|
+
init_nestjs_events();
|
|
5454
|
+
init_php_eloquent();
|
|
5234
5455
|
init_parser_loader();
|
|
5235
5456
|
_require = (0, import_node_module.createRequire)(__filename);
|
|
5236
5457
|
parser2 = null;
|
|
@@ -5287,6 +5508,7 @@ var init_parse_worker = __esm({
|
|
|
5287
5508
|
calls: [],
|
|
5288
5509
|
heritage: [],
|
|
5289
5510
|
routes: [],
|
|
5511
|
+
eventSubscribers: [],
|
|
5290
5512
|
constructorBindings: [],
|
|
5291
5513
|
fileCount: 0
|
|
5292
5514
|
};
|
|
@@ -5346,44 +5568,6 @@ var init_parse_worker = __esm({
|
|
|
5346
5568
|
}
|
|
5347
5569
|
return result;
|
|
5348
5570
|
};
|
|
5349
|
-
ELOQUENT_ARRAY_PROPS = /* @__PURE__ */ new Set(["fillable", "casts", "hidden", "guarded", "with", "appends"]);
|
|
5350
|
-
ELOQUENT_RELATIONS = /* @__PURE__ */ new Set([
|
|
5351
|
-
"hasMany",
|
|
5352
|
-
"hasOne",
|
|
5353
|
-
"belongsTo",
|
|
5354
|
-
"belongsToMany",
|
|
5355
|
-
"morphTo",
|
|
5356
|
-
"morphMany",
|
|
5357
|
-
"morphOne",
|
|
5358
|
-
"morphToMany",
|
|
5359
|
-
"morphedByMany",
|
|
5360
|
-
"hasManyThrough",
|
|
5361
|
-
"hasOneThrough"
|
|
5362
|
-
]);
|
|
5363
|
-
NESTJS_ROUTE_DECORATORS = {
|
|
5364
|
-
"Get": "GET",
|
|
5365
|
-
"Post": "POST",
|
|
5366
|
-
"Put": "PUT",
|
|
5367
|
-
"Patch": "PATCH",
|
|
5368
|
-
"Delete": "DELETE",
|
|
5369
|
-
"Options": "OPTIONS",
|
|
5370
|
-
"Head": "HEAD",
|
|
5371
|
-
"All": "ALL"
|
|
5372
|
-
};
|
|
5373
|
-
NESTJS_CONTROLLER_NAMES = /* @__PURE__ */ new Set(["Controller", "RestController"]);
|
|
5374
|
-
ROUTE_HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
5375
|
-
"get",
|
|
5376
|
-
"post",
|
|
5377
|
-
"put",
|
|
5378
|
-
"patch",
|
|
5379
|
-
"delete",
|
|
5380
|
-
"options",
|
|
5381
|
-
"any",
|
|
5382
|
-
"match"
|
|
5383
|
-
]);
|
|
5384
|
-
ROUTE_RESOURCE_METHODS = /* @__PURE__ */ new Set(["resource", "apiResource"]);
|
|
5385
|
-
RESOURCE_ACTIONS = ["index", "create", "store", "show", "edit", "update", "destroy"];
|
|
5386
|
-
API_RESOURCE_ACTIONS = ["index", "store", "show", "update", "destroy"];
|
|
5387
5571
|
processFileGroup = async (files, language, queryString, result, onFileProcessed) => {
|
|
5388
5572
|
let query;
|
|
5389
5573
|
try {
|
|
@@ -5532,6 +5716,18 @@ var init_parse_worker = __esm({
|
|
|
5532
5716
|
const callForm = inferCallForm(callNode, callNameNode);
|
|
5533
5717
|
const receiverName = callForm === "member" ? extractReceiverName(callNameNode) : void 0;
|
|
5534
5718
|
const receiverTypeName = receiverName ? typeEnv.lookup(receiverName, callNode) : void 0;
|
|
5719
|
+
let channelArgument;
|
|
5720
|
+
const BROKER_CALL_METHODS = /* @__PURE__ */ new Set(["publish", "emit", "sendToQueue", "produce", "send", "broadcast", "dispatch"]);
|
|
5721
|
+
const AMBIGUOUS_BROKER_METHODS = /* @__PURE__ */ new Set(["add", "enqueue"]);
|
|
5722
|
+
if (BROKER_CALL_METHODS.has(calledName)) {
|
|
5723
|
+
channelArgument = extractCallFirstStringArgument(callNode);
|
|
5724
|
+
} else if (AMBIGUOUS_BROKER_METHODS.has(calledName)) {
|
|
5725
|
+
const recName = receiverName?.toLowerCase() || "";
|
|
5726
|
+
const recType = receiverTypeName?.toLowerCase() || "";
|
|
5727
|
+
if (recName.includes("queue") || recName.includes("job") || recName.includes("mq") || recName.includes("worker") || recType.includes("queue")) {
|
|
5728
|
+
channelArgument = extractCallFirstStringArgument(callNode);
|
|
5729
|
+
}
|
|
5730
|
+
}
|
|
5535
5731
|
result.calls.push({
|
|
5536
5732
|
filePath: file.path,
|
|
5537
5733
|
calledName,
|
|
@@ -5539,7 +5735,8 @@ var init_parse_worker = __esm({
|
|
|
5539
5735
|
argCount: countCallArguments(callNode),
|
|
5540
5736
|
...callForm !== void 0 ? { callForm } : {},
|
|
5541
5737
|
...receiverName !== void 0 ? { receiverName } : {},
|
|
5542
|
-
...receiverTypeName !== void 0 ? { receiverTypeName } : {}
|
|
5738
|
+
...receiverTypeName !== void 0 ? { receiverTypeName } : {},
|
|
5739
|
+
...channelArgument !== void 0 ? { channelArgument } : {}
|
|
5543
5740
|
});
|
|
5544
5741
|
}
|
|
5545
5742
|
}
|
|
@@ -5698,6 +5895,14 @@ var init_parse_worker = __esm({
|
|
|
5698
5895
|
if (language === "typescript" /* TypeScript */ && /\.controller\./.test(file.path)) {
|
|
5699
5896
|
const nestRoutes = extractNestJSRoutes(tree, file.path);
|
|
5700
5897
|
result.routes.push(...nestRoutes);
|
|
5898
|
+
const nestEvents = extractNestJSEvents(tree, file.path);
|
|
5899
|
+
result.eventSubscribers.push(...nestEvents);
|
|
5900
|
+
}
|
|
5901
|
+
try {
|
|
5902
|
+
if (tree && typeof tree.delete === "function") {
|
|
5903
|
+
tree.delete();
|
|
5904
|
+
}
|
|
5905
|
+
} catch (e) {
|
|
5701
5906
|
}
|
|
5702
5907
|
}
|
|
5703
5908
|
};
|
|
@@ -5709,6 +5914,7 @@ var init_parse_worker = __esm({
|
|
|
5709
5914
|
calls: [],
|
|
5710
5915
|
heritage: [],
|
|
5711
5916
|
routes: [],
|
|
5917
|
+
eventSubscribers: [],
|
|
5712
5918
|
constructorBindings: [],
|
|
5713
5919
|
fileCount: 0
|
|
5714
5920
|
};
|
|
@@ -5721,6 +5927,7 @@ var init_parse_worker = __esm({
|
|
|
5721
5927
|
target.calls.push(...src.calls);
|
|
5722
5928
|
target.heritage.push(...src.heritage);
|
|
5723
5929
|
target.routes.push(...src.routes);
|
|
5930
|
+
target.eventSubscribers.push(...src.eventSubscribers);
|
|
5724
5931
|
target.constructorBindings.push(...src.constructorBindings);
|
|
5725
5932
|
target.fileCount += src.fileCount;
|
|
5726
5933
|
};
|
|
@@ -5738,7 +5945,7 @@ var init_parse_worker = __esm({
|
|
|
5738
5945
|
}
|
|
5739
5946
|
if (msg && msg.type === "flush") {
|
|
5740
5947
|
import_node_worker_threads.parentPort.postMessage({ type: "result", data: accumulated });
|
|
5741
|
-
accumulated = { nodes: [], relationships: [], symbols: [], imports: [], calls: [], heritage: [], routes: [], constructorBindings: [], fileCount: 0 };
|
|
5948
|
+
accumulated = { nodes: [], relationships: [], symbols: [], imports: [], calls: [], heritage: [], routes: [], eventSubscribers: [], constructorBindings: [], fileCount: 0 };
|
|
5742
5949
|
cumulativeProcessed = 0;
|
|
5743
5950
|
return;
|
|
5744
5951
|
}
|
|
@@ -6443,7 +6650,7 @@ var require_package = __commonJS({
|
|
|
6443
6650
|
"package.json"(exports2, module2) {
|
|
6444
6651
|
module2.exports = {
|
|
6445
6652
|
name: "@bitsness/grapuco-cli",
|
|
6446
|
-
version: "0.1.
|
|
6653
|
+
version: "0.1.10",
|
|
6447
6654
|
description: "Grapuco CLI \u2014 Parse your code locally, sync architecture to cloud. Zero source code upload.",
|
|
6448
6655
|
type: "commonjs",
|
|
6449
6656
|
bin: {
|