@grupodiariodaregiao/bunstone 0.5.0 → 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
CHANGED
|
@@ -118505,12 +118505,13 @@ function detectProvider(url2) {
|
|
|
118505
118505
|
}
|
|
118506
118506
|
return "postgresql";
|
|
118507
118507
|
}
|
|
118508
|
-
function buildConnectionConfig(provider) {
|
|
118508
|
+
function buildConnectionConfig(provider, timezone) {
|
|
118509
118509
|
if (provider === "postgresql") {
|
|
118510
|
-
return { TimeZone:
|
|
118510
|
+
return { TimeZone: timezone };
|
|
118511
118511
|
}
|
|
118512
118512
|
if (provider === "mysql") {
|
|
118513
|
-
|
|
118513
|
+
const tz = timezone.toLowerCase() === "utc" ? "+00:00" : timezone;
|
|
118514
|
+
return { time_zone: tz };
|
|
118514
118515
|
}
|
|
118515
118516
|
return;
|
|
118516
118517
|
}
|
|
@@ -118546,10 +118547,11 @@ SqlService = __legacyDecorateClassTS([
|
|
|
118546
118547
|
|
|
118547
118548
|
class SqlModule {
|
|
118548
118549
|
static sqlInstance;
|
|
118549
|
-
static register(connection2) {
|
|
118550
|
+
static register(connection2, timezone) {
|
|
118550
118551
|
const url2 = typeof connection2 === "string" ? connection2 : `${connection2.provider}://${connection2.username}:${connection2.password}@${connection2.host}:${connection2.port}/${connection2.database}`;
|
|
118551
118552
|
const provider = typeof connection2 === "string" ? detectProvider(connection2) : connection2.provider;
|
|
118552
|
-
const
|
|
118553
|
+
const tz = typeof connection2 === "string" ? timezone ?? "UTC" : connection2.timezone ?? "UTC";
|
|
118554
|
+
const connectionConfig = buildConnectionConfig(provider, tz);
|
|
118553
118555
|
SqlModule.sqlInstance = new SQL({
|
|
118554
118556
|
url: url2,
|
|
118555
118557
|
...connectionConfig && { connection: connectionConfig }
|
|
@@ -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,6 +10,12 @@ 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
|
|
|
15
21
|
type Provider = "postgresql" | "mysql" | "sqlite";
|
|
@@ -32,12 +38,15 @@ function detectProvider(url: string): Provider {
|
|
|
32
38
|
|
|
33
39
|
function buildConnectionConfig(
|
|
34
40
|
provider: Provider,
|
|
41
|
+
timezone: string,
|
|
35
42
|
): Record<string, string | boolean | number> | undefined {
|
|
36
43
|
if (provider === "postgresql") {
|
|
37
|
-
return { TimeZone:
|
|
44
|
+
return { TimeZone: timezone };
|
|
38
45
|
}
|
|
39
46
|
if (provider === "mysql") {
|
|
40
|
-
|
|
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 };
|
|
41
50
|
}
|
|
42
51
|
return undefined;
|
|
43
52
|
}
|
|
@@ -82,8 +91,8 @@ export class SqlModule {
|
|
|
82
91
|
private static sqlInstance: SQL;
|
|
83
92
|
|
|
84
93
|
static register(connection: ConnectionOptions): typeof SqlModule;
|
|
85
|
-
static register(connection: string): typeof SqlModule;
|
|
86
|
-
static register(connection: string | ConnectionOptions) {
|
|
94
|
+
static register(connection: string, timezone?: string): typeof SqlModule;
|
|
95
|
+
static register(connection: string | ConnectionOptions, timezone?: string) {
|
|
87
96
|
const url =
|
|
88
97
|
typeof connection === "string"
|
|
89
98
|
? connection
|
|
@@ -94,7 +103,12 @@ export class SqlModule {
|
|
|
94
103
|
? detectProvider(connection)
|
|
95
104
|
: connection.provider;
|
|
96
105
|
|
|
97
|
-
const
|
|
106
|
+
const tz =
|
|
107
|
+
typeof connection === "string"
|
|
108
|
+
? (timezone ?? "UTC")
|
|
109
|
+
: (connection.timezone ?? "UTC");
|
|
110
|
+
|
|
111
|
+
const connectionConfig = buildConnectionConfig(provider, tz);
|
|
98
112
|
|
|
99
113
|
SqlModule.sqlInstance = new SQL({
|
|
100
114
|
url,
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"types": "./dist/*.d.ts"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"version": "0.5.
|
|
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",
|