@bitsness/grapuco-cli 0.1.10 → 0.1.12

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.
Files changed (2) hide show
  1. package/dist/index.js +83 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -138,10 +138,11 @@ var init_config = __esm({
138
138
  });
139
139
 
140
140
  // src/lib/api-client.ts
141
- var ApiClient;
141
+ var import_node_zlib, ApiClient;
142
142
  var init_api_client = __esm({
143
143
  "src/lib/api-client.ts"() {
144
144
  "use strict";
145
+ import_node_zlib = require("zlib");
145
146
  init_config();
146
147
  ApiClient = class {
147
148
  server;
@@ -160,11 +161,22 @@ var init_api_client = __esm({
160
161
  "X-Api-Key": this.apiKey,
161
162
  "Content-Type": "application/json"
162
163
  };
164
+ let requestBody;
165
+ if (body) {
166
+ const json = JSON.stringify(body);
167
+ if (json.length > 1e6) {
168
+ const compressed = (0, import_node_zlib.gzipSync)(Buffer.from(json));
169
+ requestBody = new Blob([compressed]);
170
+ headers["Content-Encoding"] = "gzip";
171
+ } else {
172
+ requestBody = json;
173
+ }
174
+ }
163
175
  try {
164
176
  const res = await fetch(url, {
165
177
  method,
166
178
  headers,
167
- body: body ? JSON.stringify(body) : void 0
179
+ body: requestBody
168
180
  });
169
181
  let data;
170
182
  const contentType = res.headers.get("content-type") || "";
@@ -5279,10 +5291,71 @@ var init_nestjs_routes = __esm({
5279
5291
  });
5280
5292
 
5281
5293
  // src/parser/ingestion/workers/extractors/nestjs-events.ts
5282
- var extractNestJSEvents;
5294
+ function detectClassLevelSubscriber(classNode, className, filePath, events) {
5295
+ for (const child of classNode.children) {
5296
+ if (child.type !== "decorator") continue;
5297
+ const callExp = child.children.find((c) => c.type === "call_expression");
5298
+ if (!callExp) continue;
5299
+ const funcName = callExp.childForFieldName("function")?.text;
5300
+ if (!funcName || !CLASS_SUBSCRIBER_DECORATORS.has(funcName)) continue;
5301
+ const argsNode = callExp.childForFieldName("arguments");
5302
+ if (!argsNode) continue;
5303
+ let topicName = null;
5304
+ for (const arg of argsNode.children) {
5305
+ if (arg.type === "string") {
5306
+ topicName = arg.text.substring(1, arg.text.length - 1);
5307
+ break;
5308
+ }
5309
+ }
5310
+ if (!topicName) continue;
5311
+ const classBody = classNode.childForFieldName("body");
5312
+ if (!classBody) continue;
5313
+ let handlerMethodName = null;
5314
+ let handlerLine = classNode.startPosition.row;
5315
+ for (const member of classBody.children) {
5316
+ if (member.type === "method_definition") {
5317
+ const mName = member.childForFieldName("name")?.text;
5318
+ if (mName && HANDLER_METHOD_NAMES.has(mName)) {
5319
+ handlerMethodName = mName;
5320
+ handlerLine = member.startPosition.row;
5321
+ break;
5322
+ }
5323
+ }
5324
+ }
5325
+ events.push({
5326
+ filePath,
5327
+ topicName,
5328
+ className,
5329
+ methodName: handlerMethodName || className,
5330
+ framework: `bullmq-${funcName.toLowerCase()}`,
5331
+ lineNumber: handlerLine
5332
+ });
5333
+ }
5334
+ }
5335
+ var CLASS_SUBSCRIBER_DECORATORS, HANDLER_METHOD_NAMES, extractNestJSEvents;
5283
5336
  var init_nestjs_events = __esm({
5284
5337
  "src/parser/ingestion/workers/extractors/nestjs-events.ts"() {
5285
5338
  "use strict";
5339
+ CLASS_SUBSCRIBER_DECORATORS = /* @__PURE__ */ new Set([
5340
+ "Processor",
5341
+ // BullMQ @Processor('queueName')
5342
+ "WorkerHost",
5343
+ // BullMQ alternate pattern
5344
+ "Consumer",
5345
+ // KafkaJS / custom consumers
5346
+ "RabbitSubscribe"
5347
+ // @golevelup/nestjs-rabbitmq
5348
+ ]);
5349
+ HANDLER_METHOD_NAMES = /* @__PURE__ */ new Set([
5350
+ "process",
5351
+ // BullMQ WorkerHost.process()
5352
+ "handleMessage",
5353
+ // Generic consumer pattern
5354
+ "handle",
5355
+ // Generic handler
5356
+ "execute"
5357
+ // CQRS-style
5358
+ ]);
5286
5359
  extractNestJSEvents = (tree, filePath) => {
5287
5360
  const events = [];
5288
5361
  const rootNode = tree.rootNode;
@@ -5290,6 +5363,7 @@ var init_nestjs_events = __esm({
5290
5363
  if (node.type === "class_declaration") {
5291
5364
  const nameNode = node.childForFieldName("name");
5292
5365
  currentClass = nameNode ? nameNode.text : null;
5366
+ detectClassLevelSubscriber(node, currentClass, filePath, events);
5293
5367
  }
5294
5368
  if (node.type === "method_definition") {
5295
5369
  const methodNameNode = node.childForFieldName("name");
@@ -6506,6 +6580,11 @@ async function ingestCommand(opts) {
6506
6580
  console.log(import_chalk3.default.gray(" Hash cache updated for future delta detection.\n"));
6507
6581
  return;
6508
6582
  }
6583
+ const payloadEst = JSON.stringify(parseResult).length;
6584
+ const payloadMB = (payloadEst / 1e6).toFixed(1);
6585
+ if (payloadEst > 1e6) {
6586
+ console.log(import_chalk3.default.gray(` Payload: ~${payloadMB}MB raw \u2192 will be gzip compressed for upload`));
6587
+ }
6509
6588
  const pushSpinner = (0, import_ora.default)("Uploading architecture map to server...").start();
6510
6589
  const client = new ApiClient({ server: creds.server, apiKey: creds.apiKey });
6511
6590
  const result = await client.cliIngest(config.repoId, {
@@ -6650,7 +6729,7 @@ var require_package = __commonJS({
6650
6729
  "package.json"(exports2, module2) {
6651
6730
  module2.exports = {
6652
6731
  name: "@bitsness/grapuco-cli",
6653
- version: "0.1.10",
6732
+ version: "0.1.12",
6654
6733
  description: "Grapuco CLI \u2014 Parse your code locally, sync architecture to cloud. Zero source code upload.",
6655
6734
  type: "commonjs",
6656
6735
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitsness/grapuco-cli",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Grapuco CLI — Parse your code locally, sync architecture to cloud. Zero source code upload.",
5
5
  "type": "commonjs",
6
6
  "bin": {