@grupodiariodaregiao/bunstone 0.4.6 → 0.4.8

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/bin/cli.ts CHANGED
@@ -23,18 +23,6 @@ const THIN = "─".repeat(64);
23
23
  const args = Bun.argv.slice(2);
24
24
  const command = args[0];
25
25
 
26
- // ── Command dispatch ──────────────────────────────────────────────────────────
27
- if (command === "run") {
28
- await runCommand(args.slice(1));
29
- } else if (command === "exports") {
30
- await exportsCommand();
31
- } else if (command === "new" || (command && !args[1])) {
32
- await scaffold(command === "new" ? args[1] : command);
33
- } else {
34
- printHelp();
35
- process.exit(1);
36
- }
37
-
38
26
  // ─────────────────────────────────────────────────────────────────────────────
39
27
  // bunstone run [bun-flags...] <entrypoint>
40
28
  // ─────────────────────────────────────────────────────────────────────────────
@@ -535,3 +523,25 @@ ${cyan("Examples:")}
535
523
  bunstone run --watch src/main.ts
536
524
  `);
537
525
  }
526
+
527
+ async function main() {
528
+ if (command === "run") {
529
+ await runCommand(args.slice(1));
530
+ return;
531
+ }
532
+
533
+ if (command === "exports") {
534
+ await exportsCommand();
535
+ return;
536
+ }
537
+
538
+ if (command === "new" || (command && !args[1])) {
539
+ await scaffold(command === "new" ? args[1] : command);
540
+ return;
541
+ }
542
+
543
+ printHelp();
544
+ process.exit(1);
545
+ }
546
+
547
+ await main();
package/dist/index.js CHANGED
@@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
7
12
  var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
8
20
  target = mod != null ? __create(__getProtoOf(mod)) : {};
9
21
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
22
  for (let key of __getOwnPropNames(mod))
11
23
  if (!__hasOwnProp.call(to, key))
12
24
  __defProp(to, key, {
13
- get: () => mod[key],
25
+ get: __accessProp.bind(mod, key),
14
26
  enumerable: true
15
27
  });
28
+ if (canCache)
29
+ cache.set(mod, to);
16
30
  return to;
17
31
  };
18
32
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
19
37
  var __export = (target, all) => {
20
38
  for (var name in all)
21
39
  __defProp(target, name, {
22
40
  get: all[name],
23
41
  enumerable: true,
24
42
  configurable: true,
25
- set: (newValue) => all[name] = () => newValue
43
+ set: __exportSetter.bind(all, name)
26
44
  });
27
45
  };
28
46
  var __legacyDecorateClassTS = function(decorators, target, key, desc) {
@@ -16746,7 +16764,7 @@ WD9f
16746
16764
 
16747
16765
  // node_modules/ioredis/built/utils/index.js
16748
16766
  var require_utils2 = __commonJS((exports) => {
16749
- var __dirname = "/home/filipi.oliveira@gdc.local/poc/diario-dip/node_modules/ioredis/built/utils";
16767
+ var __dirname = "/home/almir/projects/almir/bunstone/node_modules/ioredis/built/utils";
16750
16768
  Object.defineProperty(exports, "__esModule", { value: true });
16751
16769
  exports.noop = exports.defaults = exports.Debug = exports.getPackageMeta = exports.zipMap = exports.CONNECTION_CLOSED_ERROR_MSG = exports.shuffle = exports.sample = exports.resolveTLSProfile = exports.parseURL = exports.optimizeErrorStack = exports.toArg = exports.convertMapToArray = exports.convertObjectToArray = exports.timeout = exports.packObject = exports.isInt = exports.wrapMultiResult = exports.convertBufferToString = undefined;
16752
16770
  var fs_1 = __require("fs");
@@ -17032,7 +17050,7 @@ var require_argumentParsers = __commonJS((exports) => {
17032
17050
 
17033
17051
  // node_modules/ioredis/built/Command.js
17034
17052
  var require_Command = __commonJS((exports) => {
17035
- var __dirname = "/home/filipi.oliveira@gdc.local/poc/diario-dip/node_modules/ioredis/built";
17053
+ var __dirname = "/home/almir/projects/almir/bunstone/node_modules/ioredis/built";
17036
17054
  Object.defineProperty(exports, "__esModule", { value: true });
17037
17055
  var commands_1 = require_built();
17038
17056
  var calculateSlot = require_lib();
@@ -24996,7 +25014,7 @@ var require_node_gyp_build_optional_packages = __commonJS((exports, module) => {
24996
25014
 
24997
25015
  // node_modules/msgpackr-extract/index.js
24998
25016
  var require_msgpackr_extract = __commonJS((exports, module) => {
24999
- var __dirname = "/home/filipi.oliveira@gdc.local/poc/diario-dip/node_modules/msgpackr-extract";
25017
+ var __dirname = "/home/almir/projects/almir/bunstone/node_modules/msgpackr-extract";
25000
25018
  module.exports = require_node_gyp_build_optional_packages()(__dirname);
25001
25019
  });
25002
25020
 
@@ -31911,7 +31929,7 @@ var require_pattern_validation = __commonJS((exports) => {
31911
31929
 
31912
31930
  // node_modules/node-cron/dist/esm/tasks/background-scheduled-task/background-scheduled-task.js
31913
31931
  var require_background_scheduled_task = __commonJS((exports) => {
31914
- var __dirname = "/home/filipi.oliveira@gdc.local/poc/diario-dip/node_modules/node-cron/dist/esm/tasks/background-scheduled-task";
31932
+ var __dirname = "/home/almir/projects/almir/bunstone/node_modules/node-cron/dist/esm/tasks/background-scheduled-task";
31915
31933
  var __importDefault2 = exports && exports.__importDefault || function(mod) {
31916
31934
  return mod && mod.__esModule ? mod : { default: mod };
31917
31935
  };
@@ -32135,7 +32153,7 @@ var require_background_scheduled_task = __commonJS((exports) => {
32135
32153
 
32136
32154
  // node_modules/node-cron/dist/esm/node-cron.js
32137
32155
  var require_node_cron = __commonJS((exports) => {
32138
- var __filename = "/home/filipi.oliveira@gdc.local/poc/diario-dip/node_modules/node-cron/dist/esm/node-cron.js";
32156
+ var __filename = "/home/almir/projects/almir/bunstone/node_modules/node-cron/dist/esm/node-cron.js";
32139
32157
  var __importDefault2 = exports && exports.__importDefault || function(mod) {
32140
32158
  return mod && mod.__esModule ? mod : { default: mod };
32141
32159
  };
@@ -101416,14 +101434,9 @@ class WaitingError extends Error {
101416
101434
  Object.setPrototypeOf(this, new.target.prototype);
101417
101435
  }
101418
101436
  }
101419
- // node_modules/uuid/dist/esm/stringify.js
101420
- var byteToHex = [];
101421
- for (let i = 0;i < 256; ++i) {
101422
- byteToHex.push((i + 256).toString(16).slice(1));
101423
- }
101424
- function unsafeStringify(arr, offset = 0) {
101425
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
101426
- }
101437
+ // node_modules/uuid/dist/esm/native.js
101438
+ import { randomUUID } from "crypto";
101439
+ var native_default = { randomUUID };
101427
101440
 
101428
101441
  // node_modules/uuid/dist/esm/rng.js
101429
101442
  import { randomFillSync } from "crypto";
@@ -101437,9 +101450,14 @@ function rng() {
101437
101450
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
101438
101451
  }
101439
101452
 
101440
- // node_modules/uuid/dist/esm/native.js
101441
- import { randomUUID } from "crypto";
101442
- var native_default = { randomUUID };
101453
+ // node_modules/uuid/dist/esm/stringify.js
101454
+ var byteToHex = [];
101455
+ for (let i = 0;i < 256; ++i) {
101456
+ byteToHex.push((i + 256).toString(16).slice(1));
101457
+ }
101458
+ function unsafeStringify(arr, offset = 0) {
101459
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
101460
+ }
101443
101461
 
101444
101462
  // node_modules/uuid/dist/esm/v4.js
101445
101463
  function v4(options, buf, offset) {
@@ -118183,6 +118201,13 @@ if (document.readyState === 'loading') {
118183
118201
  return raw.content.toString();
118184
118202
  }
118185
118203
  })();
118204
+ const xDeath = raw.properties.headers?.["x-death"];
118205
+ const isDeadLetter = Array.isArray(xDeath) && xDeath.length > 0;
118206
+ const isDlqQueue = queueName.toLowerCase().includes(".dlq");
118207
+ if ((isDlqQueue || descriptor.options.queue?.toLowerCase().includes(".dlq")) && !isDeadLetter) {
118208
+ channel.ack(raw);
118209
+ return;
118210
+ }
118186
118211
  const msg = {
118187
118212
  data,
118188
118213
  raw,
@@ -118195,7 +118220,7 @@ if (document.readyState === 'loading') {
118195
118220
  } catch (err) {
118196
118221
  AppStartup.logger.error(`Unhandled error in RabbitMQ handler ${providerClass.name}.${descriptor.methodName}() on exchange "${exchange}" routingKey "${routingKey}": ${err.message}`);
118197
118222
  if (!noAck) {
118198
- channel.nack(raw, false, true);
118223
+ channel.nack(raw, false, false);
118199
118224
  }
118200
118225
  }
118201
118226
  }, { noAck });
@@ -118238,6 +118263,13 @@ if (document.readyState === 'loading') {
118238
118263
  return raw.content.toString();
118239
118264
  }
118240
118265
  })();
118266
+ const xDeath = raw.properties.headers?.["x-death"];
118267
+ const isDeadLetter = Array.isArray(xDeath) && xDeath.length > 0;
118268
+ const isDlqQueue = queue2.toLowerCase().includes(".dlq");
118269
+ if (isDlqQueue && !isDeadLetter) {
118270
+ channel.ack(raw);
118271
+ return;
118272
+ }
118241
118273
  let settled = false;
118242
118274
  const settle = (fn3) => {
118243
118275
  if (!settled) {
@@ -118267,7 +118299,7 @@ if (document.readyState === 'loading') {
118267
118299
  } catch (err) {
118268
118300
  AppStartup.logger.error(`Unhandled error in RabbitMQ handler ${providerName}.${descriptor.methodName}() on queue "${queue2}": ${err.message}`);
118269
118301
  if (!handlerNoAck && !settled) {
118270
- settle(() => channel.nack(raw, false, true));
118302
+ settle(() => channel.nack(raw, false, false));
118271
118303
  }
118272
118304
  }
118273
118305
  }
@@ -1080,6 +1080,24 @@ if (document.readyState === 'loading') {
1080
1080
  }
1081
1081
  })();
1082
1082
 
1083
+ const xDeath = raw.properties.headers?.["x-death"];
1084
+ const isDeadLetter =
1085
+ Array.isArray(xDeath) && xDeath.length > 0;
1086
+ const isDlqQueue = queueName.toLowerCase().includes(".dlq");
1087
+
1088
+ // If the handler is on a DLQ or uses DeadLetterMessage type,
1089
+ // only process messages that have x-death headers.
1090
+ if (
1091
+ (isDlqQueue ||
1092
+ descriptor.options.queue
1093
+ ?.toLowerCase()
1094
+ .includes(".dlq")) &&
1095
+ !isDeadLetter
1096
+ ) {
1097
+ channel.ack(raw);
1098
+ return;
1099
+ }
1100
+
1083
1101
  const msg: RabbitMessage = {
1084
1102
  data,
1085
1103
  raw,
@@ -1095,7 +1113,7 @@ if (document.readyState === 'loading') {
1095
1113
  `Unhandled error in RabbitMQ handler ${providerClass.name}.${descriptor.methodName}() on exchange "${exchange}" routingKey "${routingKey}": ${err.message}`,
1096
1114
  );
1097
1115
  if (!noAck) {
1098
- channel.nack(raw, false, true);
1116
+ channel.nack(raw, false, false);
1099
1117
  }
1100
1118
  }
1101
1119
  },
@@ -1161,6 +1179,17 @@ if (document.readyState === 'loading') {
1161
1179
  }
1162
1180
  })();
1163
1181
 
1182
+ const xDeath = raw.properties.headers?.["x-death"];
1183
+ const isDeadLetter = Array.isArray(xDeath) && xDeath.length > 0;
1184
+ const isDlqQueue = queue.toLowerCase().includes(".dlq");
1185
+
1186
+ // If this is a DLQ, skip messages that don't have x-death headers
1187
+ // (i.e. someone published directly to the DLQ instead of it being a failed message)
1188
+ if (isDlqQueue && !isDeadLetter) {
1189
+ channel.ack(raw);
1190
+ return;
1191
+ }
1192
+
1164
1193
  // Settle guard: ack/nack/reject may only be called once per
1165
1194
  // delivery tag regardless of how many handlers invoke it.
1166
1195
  let settled = false;
@@ -1204,7 +1233,7 @@ if (document.readyState === 'loading') {
1204
1233
  `Unhandled error in RabbitMQ handler ${providerName}.${descriptor.methodName}() on queue "${queue}": ${err.message}`,
1205
1234
  );
1206
1235
  if (!handlerNoAck && !settled) {
1207
- settle(() => channel.nack(raw, false, true));
1236
+ settle(() => channel.nack(raw, false, false));
1208
1237
  }
1209
1238
  }
1210
1239
  }
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "types": "./dist/*.d.ts"
14
14
  }
15
15
  },
16
- "version": "0.4.6",
16
+ "version": "0.4.8",
17
17
  "homepage": "https://bunstone.diario.one/",
18
18
  "repository": {
19
19
  "url": "https://github.com/diariodaregiao/bunstone.git",