@neetru/sdk 3.4.1 → 3.4.3
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/CHANGELOG.md +29 -0
- package/dist/auth.cjs +37 -8
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +37 -8
- package/dist/auth.mjs.map +1 -1
- package/dist/build-guard.cjs +139 -6
- package/dist/build-guard.cjs.map +1 -1
- package/dist/build-guard.d.cts +86 -1
- package/dist/build-guard.d.ts +86 -1
- package/dist/build-guard.mjs +132 -7
- package/dist/build-guard.mjs.map +1 -1
- package/dist/db.cjs +37 -8
- package/dist/db.cjs.map +1 -1
- package/dist/db.mjs +37 -8
- package/dist/db.mjs.map +1 -1
- package/dist/index.cjs +38 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +38 -9
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +593 -31
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +96 -1
- package/dist/react.d.ts +96 -1
- package/dist/react.mjs +590 -31
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/db.mjs
CHANGED
|
@@ -681,13 +681,17 @@ var init_lease = __esm({
|
|
|
681
681
|
// src/db/sql/sql-client.ts
|
|
682
682
|
var sql_client_exports = {};
|
|
683
683
|
__export(sql_client_exports, {
|
|
684
|
+
DEFAULT_POOL_CONNECT_TIMEOUT_MS: () => DEFAULT_POOL_CONNECT_TIMEOUT_MS,
|
|
685
|
+
DEFAULT_POOL_IDLE_MS: () => DEFAULT_POOL_IDLE_MS,
|
|
686
|
+
DEFAULT_POOL_MAX: () => DEFAULT_POOL_MAX,
|
|
684
687
|
LEASE_ENDPOINT: () => LEASE_ENDPOINT,
|
|
685
688
|
LEASE_RENEW_ENDPOINT: () => LEASE_RENEW_ENDPOINT,
|
|
686
689
|
createDrizzleHandle: () => createDrizzleHandle,
|
|
687
690
|
createHttpLeaseFetcher: () => createHttpLeaseFetcher,
|
|
688
691
|
createPgPool: () => createPgPool,
|
|
689
692
|
createSqlClientFromConfig: () => createSqlClientFromConfig,
|
|
690
|
-
createSqlClientWithDeps: () => createSqlClientWithDeps
|
|
693
|
+
createSqlClientWithDeps: () => createSqlClientWithDeps,
|
|
694
|
+
resolvePoolTuning: () => resolvePoolTuning
|
|
691
695
|
});
|
|
692
696
|
function mapEnvToCore(sdkEnv) {
|
|
693
697
|
if (sdkEnv === "workspace") return "staging";
|
|
@@ -776,6 +780,30 @@ function parseLease(raw) {
|
|
|
776
780
|
expiresAt: req("expiresAt", "string")
|
|
777
781
|
};
|
|
778
782
|
}
|
|
783
|
+
function readEnvInt(name, def, min, max) {
|
|
784
|
+
const raw = typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
785
|
+
if (raw === void 0 || raw.trim() === "") return def;
|
|
786
|
+
const n = Number.parseInt(raw.trim(), 10);
|
|
787
|
+
if (!Number.isFinite(n) || n < min || n > max) return def;
|
|
788
|
+
return n;
|
|
789
|
+
}
|
|
790
|
+
function resolvePoolTuning() {
|
|
791
|
+
return {
|
|
792
|
+
// Teto 100: bem abaixo do `max_client_conn = 500` do PgBouncer, com folga
|
|
793
|
+
// para múltiplas instâncias do app dividirem o mesmo front-door.
|
|
794
|
+
max: readEnvInt("NEETRU_DB_POOL_MAX", DEFAULT_POOL_MAX, 1, 100),
|
|
795
|
+
// Teto 15min = janela do cert; piso 1s.
|
|
796
|
+
idleTimeoutMillis: readEnvInt("NEETRU_DB_POOL_IDLE_MS", DEFAULT_POOL_IDLE_MS, 1e3, 9e5),
|
|
797
|
+
connectionTimeoutMillis: readEnvInt(
|
|
798
|
+
"NEETRU_DB_POOL_CONNECT_TIMEOUT_MS",
|
|
799
|
+
DEFAULT_POOL_CONNECT_TIMEOUT_MS,
|
|
800
|
+
1e3,
|
|
801
|
+
12e4
|
|
802
|
+
),
|
|
803
|
+
keepAlive: true,
|
|
804
|
+
keepAliveInitialDelayMillis: 1e4
|
|
805
|
+
};
|
|
806
|
+
}
|
|
779
807
|
async function createPgPool(lease) {
|
|
780
808
|
const { Pool } = await import(
|
|
781
809
|
/* webpackIgnore: true */
|
|
@@ -794,9 +822,7 @@ async function createPgPool(lease) {
|
|
|
794
822
|
user: lease.user,
|
|
795
823
|
password: lease.password,
|
|
796
824
|
ssl,
|
|
797
|
-
|
|
798
|
-
idleTimeoutMillis: 3e4,
|
|
799
|
-
connectionTimeoutMillis: 1e4
|
|
825
|
+
...resolvePoolTuning()
|
|
800
826
|
});
|
|
801
827
|
}
|
|
802
828
|
async function createDrizzleHandle(pool, schema) {
|
|
@@ -931,9 +957,9 @@ async function createSqlClientFromConfig(config, schema, options) {
|
|
|
931
957
|
user: lease.user,
|
|
932
958
|
password: lease.password,
|
|
933
959
|
ssl,
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
960
|
+
// Tuning centralizado (env-tunável) — ver resolvePoolTuning + auditoria
|
|
961
|
+
// docs/_review/AUDITORIA_DB_CONN_PERF_2026-09-06.md no Core.
|
|
962
|
+
...resolvePoolTuning()
|
|
937
963
|
});
|
|
938
964
|
};
|
|
939
965
|
const createDrizzle = (pool, s) => {
|
|
@@ -956,7 +982,7 @@ async function createSqlClientFromConfig(config, schema, options) {
|
|
|
956
982
|
options
|
|
957
983
|
);
|
|
958
984
|
}
|
|
959
|
-
var LEASE_ENDPOINT, LEASE_RENEW_ENDPOINT;
|
|
985
|
+
var LEASE_ENDPOINT, LEASE_RENEW_ENDPOINT, DEFAULT_POOL_MAX, DEFAULT_POOL_IDLE_MS, DEFAULT_POOL_CONNECT_TIMEOUT_MS;
|
|
960
986
|
var init_sql_client = __esm({
|
|
961
987
|
"src/db/sql/sql-client.ts"() {
|
|
962
988
|
init_db_errors();
|
|
@@ -965,6 +991,9 @@ var init_sql_client = __esm({
|
|
|
965
991
|
init_resilient_pool();
|
|
966
992
|
LEASE_ENDPOINT = "/api/sdk/v1/db/lease";
|
|
967
993
|
LEASE_RENEW_ENDPOINT = "/api/sdk/v1/db/lease/renew";
|
|
994
|
+
DEFAULT_POOL_MAX = 10;
|
|
995
|
+
DEFAULT_POOL_IDLE_MS = 6e4;
|
|
996
|
+
DEFAULT_POOL_CONNECT_TIMEOUT_MS = 1e4;
|
|
968
997
|
}
|
|
969
998
|
});
|
|
970
999
|
|