@grupodiariodaregiao/bunstone 0.4.8 → 0.5.1
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 +45 -38
- package/dist/lib/database/sql-module.d.ts +7 -1
- package/lib/database/sql-module.ts +60 -6
- package/package.json +2 -1
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:
|
|
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:
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
101438
|
-
|
|
101439
|
-
|
|
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/
|
|
101454
|
-
|
|
101455
|
-
|
|
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,26 @@ 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, timezone) {
|
|
118509
|
+
if (provider === "postgresql") {
|
|
118510
|
+
return { TimeZone: timezone };
|
|
118511
|
+
}
|
|
118512
|
+
if (provider === "mysql") {
|
|
118513
|
+
const tz = timezone.toLowerCase() === "utc" ? "+00:00" : timezone;
|
|
118514
|
+
return { time_zone: tz };
|
|
118515
|
+
}
|
|
118516
|
+
return;
|
|
118517
|
+
}
|
|
118518
|
+
|
|
118517
118519
|
class SqlService {
|
|
118518
118520
|
async query(query, params) {
|
|
118519
118521
|
const sql = this.getSqlInstance();
|
|
@@ -118545,9 +118547,14 @@ SqlService = __legacyDecorateClassTS([
|
|
|
118545
118547
|
|
|
118546
118548
|
class SqlModule {
|
|
118547
118549
|
static sqlInstance;
|
|
118548
|
-
static register(connection2) {
|
|
118550
|
+
static register(connection2, timezone) {
|
|
118551
|
+
const url2 = typeof connection2 === "string" ? connection2 : `${connection2.provider}://${connection2.username}:${connection2.password}@${connection2.host}:${connection2.port}/${connection2.database}`;
|
|
118552
|
+
const provider = typeof connection2 === "string" ? detectProvider(connection2) : connection2.provider;
|
|
118553
|
+
const tz = typeof connection2 === "string" ? timezone ?? "UTC" : connection2.timezone ?? "UTC";
|
|
118554
|
+
const connectionConfig = buildConnectionConfig(provider, tz);
|
|
118549
118555
|
SqlModule.sqlInstance = new SQL({
|
|
118550
|
-
url:
|
|
118556
|
+
url: url2,
|
|
118557
|
+
...connectionConfig && { connection: connectionConfig }
|
|
118551
118558
|
});
|
|
118552
118559
|
return SqlModule;
|
|
118553
118560
|
}
|
|
@@ -6,6 +6,12 @@ type ConnectionOptions = {
|
|
|
6
6
|
password: string;
|
|
7
7
|
database: string;
|
|
8
8
|
provider: "postgresql" | "mysql" | "sqlite";
|
|
9
|
+
/**
|
|
10
|
+
* Timezone used for date/time interpretation on the database connection.
|
|
11
|
+
* Defaults to 'UTC' to ensure consistent, offset-free date handling.
|
|
12
|
+
* Set to 'local' to use the process timezone, or any valid tz identifier.
|
|
13
|
+
*/
|
|
14
|
+
timezone?: string;
|
|
9
15
|
};
|
|
10
16
|
export declare class SqlService {
|
|
11
17
|
query<T = any>(query: string, params?: any[]): Promise<T[]>;
|
|
@@ -19,7 +25,7 @@ export declare class SqlService {
|
|
|
19
25
|
export declare class SqlModule {
|
|
20
26
|
private static sqlInstance;
|
|
21
27
|
static register(connection: ConnectionOptions): typeof SqlModule;
|
|
22
|
-
static register(connection: string): typeof SqlModule;
|
|
28
|
+
static register(connection: string, timezone?: string): typeof SqlModule;
|
|
23
29
|
static getSqlInstance(): SQL;
|
|
24
30
|
}
|
|
25
31
|
export {};
|
|
@@ -10,8 +10,47 @@ type ConnectionOptions = {
|
|
|
10
10
|
password: string;
|
|
11
11
|
database: string;
|
|
12
12
|
provider: "postgresql" | "mysql" | "sqlite";
|
|
13
|
+
/**
|
|
14
|
+
* Timezone used for date/time interpretation on the database connection.
|
|
15
|
+
* Defaults to 'UTC' to ensure consistent, offset-free date handling.
|
|
16
|
+
* Set to 'local' to use the process timezone, or any valid tz identifier.
|
|
17
|
+
*/
|
|
18
|
+
timezone?: string;
|
|
13
19
|
};
|
|
14
20
|
|
|
21
|
+
type Provider = "postgresql" | "mysql" | "sqlite";
|
|
22
|
+
|
|
23
|
+
function detectProvider(url: string): Provider {
|
|
24
|
+
if (url.startsWith("mysql://") || url.startsWith("mysql2://")) {
|
|
25
|
+
return "mysql";
|
|
26
|
+
}
|
|
27
|
+
if (
|
|
28
|
+
url === ":memory:" ||
|
|
29
|
+
url.startsWith("sqlite://") ||
|
|
30
|
+
url.startsWith("sqlite:") ||
|
|
31
|
+
url.startsWith("file://") ||
|
|
32
|
+
url.startsWith("file:")
|
|
33
|
+
) {
|
|
34
|
+
return "sqlite";
|
|
35
|
+
}
|
|
36
|
+
return "postgresql";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function buildConnectionConfig(
|
|
40
|
+
provider: Provider,
|
|
41
|
+
timezone: string,
|
|
42
|
+
): Record<string, string | boolean | number> | undefined {
|
|
43
|
+
if (provider === "postgresql") {
|
|
44
|
+
return { TimeZone: timezone };
|
|
45
|
+
}
|
|
46
|
+
if (provider === "mysql") {
|
|
47
|
+
// Normalise to MySQL's expected offset format ('+00:00') or named zone
|
|
48
|
+
const tz = timezone.toLowerCase() === "utc" ? "+00:00" : timezone;
|
|
49
|
+
return { time_zone: tz };
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
15
54
|
@Injectable()
|
|
16
55
|
export class SqlService {
|
|
17
56
|
async query<T = any>(query: string, params?: any[]): Promise<T[]> {
|
|
@@ -52,13 +91,28 @@ export class SqlModule {
|
|
|
52
91
|
private static sqlInstance: SQL;
|
|
53
92
|
|
|
54
93
|
static register(connection: ConnectionOptions): typeof SqlModule;
|
|
55
|
-
static register(connection: string): typeof SqlModule;
|
|
56
|
-
static register(connection: string | ConnectionOptions) {
|
|
94
|
+
static register(connection: string, timezone?: string): typeof SqlModule;
|
|
95
|
+
static register(connection: string | ConnectionOptions, timezone?: string) {
|
|
96
|
+
const url =
|
|
97
|
+
typeof connection === "string"
|
|
98
|
+
? connection
|
|
99
|
+
: `${connection.provider}://${connection.username}:${connection.password}@${connection.host}:${connection.port}/${connection.database}`;
|
|
100
|
+
|
|
101
|
+
const provider =
|
|
102
|
+
typeof connection === "string"
|
|
103
|
+
? detectProvider(connection)
|
|
104
|
+
: connection.provider;
|
|
105
|
+
|
|
106
|
+
const tz =
|
|
107
|
+
typeof connection === "string"
|
|
108
|
+
? (timezone ?? "UTC")
|
|
109
|
+
: (connection.timezone ?? "UTC");
|
|
110
|
+
|
|
111
|
+
const connectionConfig = buildConnectionConfig(provider, tz);
|
|
112
|
+
|
|
57
113
|
SqlModule.sqlInstance = new SQL({
|
|
58
|
-
url
|
|
59
|
-
|
|
60
|
-
? connection
|
|
61
|
-
: `${connection.provider}://${connection.username}:${connection.password}@${connection.host}:${connection.port}/${connection.database}`,
|
|
114
|
+
url,
|
|
115
|
+
...(connectionConfig && { connection: connectionConfig }),
|
|
62
116
|
});
|
|
63
117
|
|
|
64
118
|
return SqlModule;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"types": "./dist/*.d.ts"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"version": "0.
|
|
16
|
+
"version": "0.5.1",
|
|
17
17
|
"homepage": "https://bunstone.diario.one/",
|
|
18
18
|
"repository": {
|
|
19
19
|
"url": "https://github.com/diariodaregiao/bunstone.git",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@types/react": "^19.2.8",
|
|
53
53
|
"@types/react-dom": "^19.2.3",
|
|
54
54
|
"autocannon": "^8.0.0",
|
|
55
|
+
"bun-types": "1.3.11",
|
|
55
56
|
"express": "^5.2.1",
|
|
56
57
|
"fastify": "^5.6.2",
|
|
57
58
|
"react": "^19.2.3",
|