@grupodiariodaregiao/bunstone 0.4.8 → 0.5.0

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 CHANGED
@@ -4,43 +4,25 @@ 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;
12
7
  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
- }
20
8
  target = mod != null ? __create(__getProtoOf(mod)) : {};
21
9
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
10
  for (let key of __getOwnPropNames(mod))
23
11
  if (!__hasOwnProp.call(to, key))
24
12
  __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
13
+ get: () => mod[key],
26
14
  enumerable: true
27
15
  });
28
- if (canCache)
29
- cache.set(mod, to);
30
16
  return to;
31
17
  };
32
18
  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
- }
37
19
  var __export = (target, all) => {
38
20
  for (var name in all)
39
21
  __defProp(target, name, {
40
22
  get: all[name],
41
23
  enumerable: true,
42
24
  configurable: true,
43
- set: __exportSetter.bind(all, name)
25
+ set: (newValue) => all[name] = () => newValue
44
26
  });
45
27
  };
46
28
  var __legacyDecorateClassTS = function(decorators, target, key, desc) {
@@ -16764,7 +16746,7 @@ WD9f
16764
16746
 
16765
16747
  // node_modules/ioredis/built/utils/index.js
16766
16748
  var require_utils2 = __commonJS((exports) => {
16767
- var __dirname = "/home/almir/projects/almir/bunstone/node_modules/ioredis/built/utils";
16749
+ var __dirname = "/home/filipi.oliveira@gdc.local/poc/bunstone/node_modules/ioredis/built/utils";
16768
16750
  Object.defineProperty(exports, "__esModule", { value: true });
16769
16751
  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;
16770
16752
  var fs_1 = __require("fs");
@@ -17050,7 +17032,7 @@ var require_argumentParsers = __commonJS((exports) => {
17050
17032
 
17051
17033
  // node_modules/ioredis/built/Command.js
17052
17034
  var require_Command = __commonJS((exports) => {
17053
- var __dirname = "/home/almir/projects/almir/bunstone/node_modules/ioredis/built";
17035
+ var __dirname = "/home/filipi.oliveira@gdc.local/poc/bunstone/node_modules/ioredis/built";
17054
17036
  Object.defineProperty(exports, "__esModule", { value: true });
17055
17037
  var commands_1 = require_built();
17056
17038
  var calculateSlot = require_lib();
@@ -25014,7 +24996,7 @@ var require_node_gyp_build_optional_packages = __commonJS((exports, module) => {
25014
24996
 
25015
24997
  // node_modules/msgpackr-extract/index.js
25016
24998
  var require_msgpackr_extract = __commonJS((exports, module) => {
25017
- var __dirname = "/home/almir/projects/almir/bunstone/node_modules/msgpackr-extract";
24999
+ var __dirname = "/home/filipi.oliveira@gdc.local/poc/bunstone/node_modules/msgpackr-extract";
25018
25000
  module.exports = require_node_gyp_build_optional_packages()(__dirname);
25019
25001
  });
25020
25002
 
@@ -31929,7 +31911,7 @@ var require_pattern_validation = __commonJS((exports) => {
31929
31911
 
31930
31912
  // node_modules/node-cron/dist/esm/tasks/background-scheduled-task/background-scheduled-task.js
31931
31913
  var require_background_scheduled_task = __commonJS((exports) => {
31932
- var __dirname = "/home/almir/projects/almir/bunstone/node_modules/node-cron/dist/esm/tasks/background-scheduled-task";
31914
+ var __dirname = "/home/filipi.oliveira@gdc.local/poc/bunstone/node_modules/node-cron/dist/esm/tasks/background-scheduled-task";
31933
31915
  var __importDefault2 = exports && exports.__importDefault || function(mod) {
31934
31916
  return mod && mod.__esModule ? mod : { default: mod };
31935
31917
  };
@@ -32153,7 +32135,7 @@ var require_background_scheduled_task = __commonJS((exports) => {
32153
32135
 
32154
32136
  // node_modules/node-cron/dist/esm/node-cron.js
32155
32137
  var require_node_cron = __commonJS((exports) => {
32156
- var __filename = "/home/almir/projects/almir/bunstone/node_modules/node-cron/dist/esm/node-cron.js";
32138
+ var __filename = "/home/filipi.oliveira@gdc.local/poc/bunstone/node_modules/node-cron/dist/esm/node-cron.js";
32157
32139
  var __importDefault2 = exports && exports.__importDefault || function(mod) {
32158
32140
  return mod && mod.__esModule ? mod : { default: mod };
32159
32141
  };
@@ -101434,9 +101416,14 @@ class WaitingError extends Error {
101434
101416
  Object.setPrototypeOf(this, new.target.prototype);
101435
101417
  }
101436
101418
  }
101437
- // node_modules/uuid/dist/esm/native.js
101438
- import { randomUUID } from "crypto";
101439
- var native_default = { randomUUID };
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
+ }
101440
101427
 
101441
101428
  // node_modules/uuid/dist/esm/rng.js
101442
101429
  import { randomFillSync } from "crypto";
@@ -101450,14 +101437,9 @@ function rng() {
101450
101437
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
101451
101438
  }
101452
101439
 
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
- }
101440
+ // node_modules/uuid/dist/esm/native.js
101441
+ import { randomUUID } from "crypto";
101442
+ var native_default = { randomUUID };
101461
101443
 
101462
101444
  // node_modules/uuid/dist/esm/v4.js
101463
101445
  function v4(options, buf, offset) {
@@ -118514,6 +118496,25 @@ CqrsModule = __legacyDecorateClassTS([
118514
118496
  ], CqrsModule);
118515
118497
  // lib/database/sql-module.ts
118516
118498
  var {SQL } = globalThis.Bun;
118499
+ function detectProvider(url2) {
118500
+ if (url2.startsWith("mysql://") || url2.startsWith("mysql2://")) {
118501
+ return "mysql";
118502
+ }
118503
+ if (url2 === ":memory:" || url2.startsWith("sqlite://") || url2.startsWith("sqlite:") || url2.startsWith("file://") || url2.startsWith("file:")) {
118504
+ return "sqlite";
118505
+ }
118506
+ return "postgresql";
118507
+ }
118508
+ function buildConnectionConfig(provider) {
118509
+ if (provider === "postgresql") {
118510
+ return { TimeZone: "UTC" };
118511
+ }
118512
+ if (provider === "mysql") {
118513
+ return { time_zone: "+00:00" };
118514
+ }
118515
+ return;
118516
+ }
118517
+
118517
118518
  class SqlService {
118518
118519
  async query(query, params) {
118519
118520
  const sql = this.getSqlInstance();
@@ -118546,8 +118547,12 @@ SqlService = __legacyDecorateClassTS([
118546
118547
  class SqlModule {
118547
118548
  static sqlInstance;
118548
118549
  static register(connection2) {
118550
+ const url2 = typeof connection2 === "string" ? connection2 : `${connection2.provider}://${connection2.username}:${connection2.password}@${connection2.host}:${connection2.port}/${connection2.database}`;
118551
+ const provider = typeof connection2 === "string" ? detectProvider(connection2) : connection2.provider;
118552
+ const connectionConfig = buildConnectionConfig(provider);
118549
118553
  SqlModule.sqlInstance = new SQL({
118550
- url: typeof connection2 === "string" ? connection2 : `${connection2.provider}://${connection2.username}:${connection2.password}@${connection2.host}:${connection2.port}/${connection2.database}`
118554
+ url: url2,
118555
+ ...connectionConfig && { connection: connectionConfig }
118551
118556
  });
118552
118557
  return SqlModule;
118553
118558
  }
@@ -12,6 +12,36 @@ type ConnectionOptions = {
12
12
  provider: "postgresql" | "mysql" | "sqlite";
13
13
  };
14
14
 
15
+ type Provider = "postgresql" | "mysql" | "sqlite";
16
+
17
+ function detectProvider(url: string): Provider {
18
+ if (url.startsWith("mysql://") || url.startsWith("mysql2://")) {
19
+ return "mysql";
20
+ }
21
+ if (
22
+ url === ":memory:" ||
23
+ url.startsWith("sqlite://") ||
24
+ url.startsWith("sqlite:") ||
25
+ url.startsWith("file://") ||
26
+ url.startsWith("file:")
27
+ ) {
28
+ return "sqlite";
29
+ }
30
+ return "postgresql";
31
+ }
32
+
33
+ function buildConnectionConfig(
34
+ provider: Provider,
35
+ ): Record<string, string | boolean | number> | undefined {
36
+ if (provider === "postgresql") {
37
+ return { TimeZone: "UTC" };
38
+ }
39
+ if (provider === "mysql") {
40
+ return { time_zone: "+00:00" };
41
+ }
42
+ return undefined;
43
+ }
44
+
15
45
  @Injectable()
16
46
  export class SqlService {
17
47
  async query<T = any>(query: string, params?: any[]): Promise<T[]> {
@@ -54,11 +84,21 @@ export class SqlModule {
54
84
  static register(connection: ConnectionOptions): typeof SqlModule;
55
85
  static register(connection: string): typeof SqlModule;
56
86
  static register(connection: string | ConnectionOptions) {
87
+ const url =
88
+ typeof connection === "string"
89
+ ? connection
90
+ : `${connection.provider}://${connection.username}:${connection.password}@${connection.host}:${connection.port}/${connection.database}`;
91
+
92
+ const provider =
93
+ typeof connection === "string"
94
+ ? detectProvider(connection)
95
+ : connection.provider;
96
+
97
+ const connectionConfig = buildConnectionConfig(provider);
98
+
57
99
  SqlModule.sqlInstance = new SQL({
58
- url:
59
- typeof connection === "string"
60
- ? connection
61
- : `${connection.provider}://${connection.username}:${connection.password}@${connection.host}:${connection.port}/${connection.database}`,
100
+ url,
101
+ ...(connectionConfig && { connection: connectionConfig }),
62
102
  });
63
103
 
64
104
  return SqlModule;
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "types": "./dist/*.d.ts"
14
14
  }
15
15
  },
16
- "version": "0.4.8",
16
+ "version": "0.5.0",
17
17
  "homepage": "https://bunstone.diario.one/",
18
18
  "repository": {
19
19
  "url": "https://github.com/diariodaregiao/bunstone.git",