@neetru/sdk 3.4.1 → 3.4.2
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 +13 -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 +41 -6
- package/dist/build-guard.cjs.map +1 -1
- package/dist/build-guard.d.cts +24 -1
- package/dist/build-guard.d.ts +24 -1
- package/dist/build-guard.mjs +40 -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 +37 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +37 -8
- 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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ All notable changes to `@neetru/sdk` will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.4.2] - 2026-09-06 — **barra de conta (app-switcher) + build-guard OIDC de PROD + pool SQL tunável**
|
|
9
|
+
|
|
10
|
+
Release **patch** (tudo aditivo/retrocompatível: nova superfície opcional, guard só-prod, tuning de pool). Nenhuma mudança de wire, nenhuma remoção de API.
|
|
11
|
+
|
|
12
|
+
### Adicionado
|
|
13
|
+
|
|
14
|
+
- **Barra de conta / app-switcher** (#17) — superfície `account-bar` que dá ao produto uma barra canônica de identidade + troca de app sem cada produto reinventar. Aditiva e opcional.
|
|
15
|
+
- **Build-guard de PROD** (#18) — `assertNeetruProdBuildEnv` **falha o build de produção** (`builtEnv === 'prod'`) quando `oidcClientId`/`productId` vêm em branco, transformando o incidente do gestovendas (env var OIDC vazia chegando em prod) em erro de build, não de runtime. Só-prod: dev/test/preview passam inalterados (sem falso-positivo).
|
|
16
|
+
|
|
17
|
+
### Alterado (performance)
|
|
18
|
+
|
|
19
|
+
- **Pool SQL** (#19) — `client.db.sql` (`pg.Pool`): `max` 3→10, `idleTimeout` 30s→60s, `keepAlive` ligado; tunável por `NEETRU_DB_POOL_MAX` / `NEETRU_DB_POOL_IDLE_MS` via `resolvePoolTuning()`. Endereça a lentidão de conexão DB↔app observada no PDV sob carga (o teto de 3 conexões serializava as queries).
|
|
20
|
+
|
|
8
21
|
## [3.4.1] - 2026-08-20 — **fix(db offline): resiliência da fila offline + honestidade do transporte Documentos**
|
|
9
22
|
|
|
10
23
|
Release **patch** (correção de resiliência + aditivos opcionais retrocompatíveis; nenhuma mudança de wire, nenhuma remoção de API). Camada offline `client.db` (Mundo Documentos).
|
package/dist/auth.cjs
CHANGED
|
@@ -684,13 +684,17 @@ var init_lease = __esm({
|
|
|
684
684
|
// src/db/sql/sql-client.ts
|
|
685
685
|
var sql_client_exports = {};
|
|
686
686
|
__export(sql_client_exports, {
|
|
687
|
+
DEFAULT_POOL_CONNECT_TIMEOUT_MS: () => DEFAULT_POOL_CONNECT_TIMEOUT_MS,
|
|
688
|
+
DEFAULT_POOL_IDLE_MS: () => DEFAULT_POOL_IDLE_MS,
|
|
689
|
+
DEFAULT_POOL_MAX: () => DEFAULT_POOL_MAX,
|
|
687
690
|
LEASE_ENDPOINT: () => LEASE_ENDPOINT,
|
|
688
691
|
LEASE_RENEW_ENDPOINT: () => LEASE_RENEW_ENDPOINT,
|
|
689
692
|
createDrizzleHandle: () => createDrizzleHandle,
|
|
690
693
|
createHttpLeaseFetcher: () => createHttpLeaseFetcher,
|
|
691
694
|
createPgPool: () => createPgPool,
|
|
692
695
|
createSqlClientFromConfig: () => createSqlClientFromConfig,
|
|
693
|
-
createSqlClientWithDeps: () => createSqlClientWithDeps
|
|
696
|
+
createSqlClientWithDeps: () => createSqlClientWithDeps,
|
|
697
|
+
resolvePoolTuning: () => resolvePoolTuning
|
|
694
698
|
});
|
|
695
699
|
function mapEnvToCore(sdkEnv) {
|
|
696
700
|
if (sdkEnv === "workspace") return "staging";
|
|
@@ -779,6 +783,30 @@ function parseLease(raw) {
|
|
|
779
783
|
expiresAt: req("expiresAt", "string")
|
|
780
784
|
};
|
|
781
785
|
}
|
|
786
|
+
function readEnvInt(name, def, min, max) {
|
|
787
|
+
const raw = typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
788
|
+
if (raw === void 0 || raw.trim() === "") return def;
|
|
789
|
+
const n = Number.parseInt(raw.trim(), 10);
|
|
790
|
+
if (!Number.isFinite(n) || n < min || n > max) return def;
|
|
791
|
+
return n;
|
|
792
|
+
}
|
|
793
|
+
function resolvePoolTuning() {
|
|
794
|
+
return {
|
|
795
|
+
// Teto 100: bem abaixo do `max_client_conn = 500` do PgBouncer, com folga
|
|
796
|
+
// para múltiplas instâncias do app dividirem o mesmo front-door.
|
|
797
|
+
max: readEnvInt("NEETRU_DB_POOL_MAX", DEFAULT_POOL_MAX, 1, 100),
|
|
798
|
+
// Teto 15min = janela do cert; piso 1s.
|
|
799
|
+
idleTimeoutMillis: readEnvInt("NEETRU_DB_POOL_IDLE_MS", DEFAULT_POOL_IDLE_MS, 1e3, 9e5),
|
|
800
|
+
connectionTimeoutMillis: readEnvInt(
|
|
801
|
+
"NEETRU_DB_POOL_CONNECT_TIMEOUT_MS",
|
|
802
|
+
DEFAULT_POOL_CONNECT_TIMEOUT_MS,
|
|
803
|
+
1e3,
|
|
804
|
+
12e4
|
|
805
|
+
),
|
|
806
|
+
keepAlive: true,
|
|
807
|
+
keepAliveInitialDelayMillis: 1e4
|
|
808
|
+
};
|
|
809
|
+
}
|
|
782
810
|
async function createPgPool(lease) {
|
|
783
811
|
const { Pool } = await import(
|
|
784
812
|
/* webpackIgnore: true */
|
|
@@ -797,9 +825,7 @@ async function createPgPool(lease) {
|
|
|
797
825
|
user: lease.user,
|
|
798
826
|
password: lease.password,
|
|
799
827
|
ssl,
|
|
800
|
-
|
|
801
|
-
idleTimeoutMillis: 3e4,
|
|
802
|
-
connectionTimeoutMillis: 1e4
|
|
828
|
+
...resolvePoolTuning()
|
|
803
829
|
});
|
|
804
830
|
}
|
|
805
831
|
async function createDrizzleHandle(pool, schema) {
|
|
@@ -934,9 +960,9 @@ async function createSqlClientFromConfig(config, schema, options) {
|
|
|
934
960
|
user: lease.user,
|
|
935
961
|
password: lease.password,
|
|
936
962
|
ssl,
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
963
|
+
// Tuning centralizado (env-tunável) — ver resolvePoolTuning + auditoria
|
|
964
|
+
// docs/_review/AUDITORIA_DB_CONN_PERF_2026-09-06.md no Core.
|
|
965
|
+
...resolvePoolTuning()
|
|
940
966
|
});
|
|
941
967
|
};
|
|
942
968
|
const createDrizzle = (pool, s) => {
|
|
@@ -959,7 +985,7 @@ async function createSqlClientFromConfig(config, schema, options) {
|
|
|
959
985
|
options
|
|
960
986
|
);
|
|
961
987
|
}
|
|
962
|
-
var LEASE_ENDPOINT, LEASE_RENEW_ENDPOINT;
|
|
988
|
+
var LEASE_ENDPOINT, LEASE_RENEW_ENDPOINT, DEFAULT_POOL_MAX, DEFAULT_POOL_IDLE_MS, DEFAULT_POOL_CONNECT_TIMEOUT_MS;
|
|
963
989
|
var init_sql_client = __esm({
|
|
964
990
|
"src/db/sql/sql-client.ts"() {
|
|
965
991
|
init_db_errors();
|
|
@@ -968,6 +994,9 @@ var init_sql_client = __esm({
|
|
|
968
994
|
init_resilient_pool();
|
|
969
995
|
LEASE_ENDPOINT = "/api/sdk/v1/db/lease";
|
|
970
996
|
LEASE_RENEW_ENDPOINT = "/api/sdk/v1/db/lease/renew";
|
|
997
|
+
DEFAULT_POOL_MAX = 10;
|
|
998
|
+
DEFAULT_POOL_IDLE_MS = 6e4;
|
|
999
|
+
DEFAULT_POOL_CONNECT_TIMEOUT_MS = 1e4;
|
|
971
1000
|
}
|
|
972
1001
|
});
|
|
973
1002
|
|