@bitsness/grapuco-cli 0.1.9 → 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 +124 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2043,7 +2043,7 @@ var init_signature_extractors = __esm({
|
|
|
2043
2043
|
});
|
|
2044
2044
|
|
|
2045
2045
|
// src/parser/ingestion/utils/call-extractors.ts
|
|
2046
|
-
var CALL_ARGUMENT_LIST_TYPES, countCallArguments, MEMBER_ACCESS_NODE_TYPES, CONSTRUCTOR_CALL_NODE_TYPES, SCOPED_CALL_NODE_TYPES, inferCallForm, SIMPLE_RECEIVER_TYPES, extractReceiverName;
|
|
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
2047
|
var init_call_extractors = __esm({
|
|
2048
2048
|
"src/parser/ingestion/utils/call-extractors.ts"() {
|
|
2049
2049
|
"use strict";
|
|
@@ -2074,6 +2074,43 @@ var init_call_extractors = __esm({
|
|
|
2074
2074
|
}
|
|
2075
2075
|
return count;
|
|
2076
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
|
+
};
|
|
2077
2114
|
MEMBER_ACCESS_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
2078
2115
|
"member_expression",
|
|
2079
2116
|
// TS/JS: obj.method()
|
|
@@ -2203,6 +2240,13 @@ var init_call_extractors = __esm({
|
|
|
2203
2240
|
if (SIMPLE_RECEIVER_TYPES.has(receiver.type)) {
|
|
2204
2241
|
return receiver.text;
|
|
2205
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
|
+
}
|
|
2206
2250
|
if (receiver.type === "call") {
|
|
2207
2251
|
const func = receiver.childForFieldName("function");
|
|
2208
2252
|
if (func?.text === "super") return "super";
|
|
@@ -5234,6 +5278,63 @@ var init_nestjs_routes = __esm({
|
|
|
5234
5278
|
}
|
|
5235
5279
|
});
|
|
5236
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
|
+
|
|
5237
5338
|
// src/parser/ingestion/workers/extractors/php-eloquent.ts
|
|
5238
5339
|
function findDescendant2(node, type) {
|
|
5239
5340
|
if (node.type === type) return node;
|
|
@@ -5349,6 +5450,7 @@ var init_parse_worker = __esm({
|
|
|
5349
5450
|
init_call_routing();
|
|
5350
5451
|
init_laravel_routes();
|
|
5351
5452
|
init_nestjs_routes();
|
|
5453
|
+
init_nestjs_events();
|
|
5352
5454
|
init_php_eloquent();
|
|
5353
5455
|
init_parser_loader();
|
|
5354
5456
|
_require = (0, import_node_module.createRequire)(__filename);
|
|
@@ -5406,6 +5508,7 @@ var init_parse_worker = __esm({
|
|
|
5406
5508
|
calls: [],
|
|
5407
5509
|
heritage: [],
|
|
5408
5510
|
routes: [],
|
|
5511
|
+
eventSubscribers: [],
|
|
5409
5512
|
constructorBindings: [],
|
|
5410
5513
|
fileCount: 0
|
|
5411
5514
|
};
|
|
@@ -5613,6 +5716,18 @@ var init_parse_worker = __esm({
|
|
|
5613
5716
|
const callForm = inferCallForm(callNode, callNameNode);
|
|
5614
5717
|
const receiverName = callForm === "member" ? extractReceiverName(callNameNode) : void 0;
|
|
5615
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
|
+
}
|
|
5616
5731
|
result.calls.push({
|
|
5617
5732
|
filePath: file.path,
|
|
5618
5733
|
calledName,
|
|
@@ -5620,7 +5735,8 @@ var init_parse_worker = __esm({
|
|
|
5620
5735
|
argCount: countCallArguments(callNode),
|
|
5621
5736
|
...callForm !== void 0 ? { callForm } : {},
|
|
5622
5737
|
...receiverName !== void 0 ? { receiverName } : {},
|
|
5623
|
-
...receiverTypeName !== void 0 ? { receiverTypeName } : {}
|
|
5738
|
+
...receiverTypeName !== void 0 ? { receiverTypeName } : {},
|
|
5739
|
+
...channelArgument !== void 0 ? { channelArgument } : {}
|
|
5624
5740
|
});
|
|
5625
5741
|
}
|
|
5626
5742
|
}
|
|
@@ -5779,6 +5895,8 @@ var init_parse_worker = __esm({
|
|
|
5779
5895
|
if (language === "typescript" /* TypeScript */ && /\.controller\./.test(file.path)) {
|
|
5780
5896
|
const nestRoutes = extractNestJSRoutes(tree, file.path);
|
|
5781
5897
|
result.routes.push(...nestRoutes);
|
|
5898
|
+
const nestEvents = extractNestJSEvents(tree, file.path);
|
|
5899
|
+
result.eventSubscribers.push(...nestEvents);
|
|
5782
5900
|
}
|
|
5783
5901
|
try {
|
|
5784
5902
|
if (tree && typeof tree.delete === "function") {
|
|
@@ -5796,6 +5914,7 @@ var init_parse_worker = __esm({
|
|
|
5796
5914
|
calls: [],
|
|
5797
5915
|
heritage: [],
|
|
5798
5916
|
routes: [],
|
|
5917
|
+
eventSubscribers: [],
|
|
5799
5918
|
constructorBindings: [],
|
|
5800
5919
|
fileCount: 0
|
|
5801
5920
|
};
|
|
@@ -5808,6 +5927,7 @@ var init_parse_worker = __esm({
|
|
|
5808
5927
|
target.calls.push(...src.calls);
|
|
5809
5928
|
target.heritage.push(...src.heritage);
|
|
5810
5929
|
target.routes.push(...src.routes);
|
|
5930
|
+
target.eventSubscribers.push(...src.eventSubscribers);
|
|
5811
5931
|
target.constructorBindings.push(...src.constructorBindings);
|
|
5812
5932
|
target.fileCount += src.fileCount;
|
|
5813
5933
|
};
|
|
@@ -5825,7 +5945,7 @@ var init_parse_worker = __esm({
|
|
|
5825
5945
|
}
|
|
5826
5946
|
if (msg && msg.type === "flush") {
|
|
5827
5947
|
import_node_worker_threads.parentPort.postMessage({ type: "result", data: accumulated });
|
|
5828
|
-
accumulated = { nodes: [], relationships: [], symbols: [], imports: [], calls: [], heritage: [], routes: [], constructorBindings: [], fileCount: 0 };
|
|
5948
|
+
accumulated = { nodes: [], relationships: [], symbols: [], imports: [], calls: [], heritage: [], routes: [], eventSubscribers: [], constructorBindings: [], fileCount: 0 };
|
|
5829
5949
|
cumulativeProcessed = 0;
|
|
5830
5950
|
return;
|
|
5831
5951
|
}
|
|
@@ -6530,7 +6650,7 @@ var require_package = __commonJS({
|
|
|
6530
6650
|
"package.json"(exports2, module2) {
|
|
6531
6651
|
module2.exports = {
|
|
6532
6652
|
name: "@bitsness/grapuco-cli",
|
|
6533
|
-
version: "0.1.
|
|
6653
|
+
version: "0.1.10",
|
|
6534
6654
|
description: "Grapuco CLI \u2014 Parse your code locally, sync architecture to cloud. Zero source code upload.",
|
|
6535
6655
|
type: "commonjs",
|
|
6536
6656
|
bin: {
|