@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/dist/index.d.cts CHANGED
@@ -42,6 +42,6 @@ declare function checkCoreVersionCompat(coreVersion: string): void;
42
42
  */
43
43
 
44
44
  /** Versão do SDK — exportada explicitamente pra detecção em runtime. */
45
- declare const VERSION: "3.4.1";
45
+ declare const VERSION: "3.4.3";
46
46
 
47
47
  export { VERSION, checkCoreVersionCompat };
package/dist/index.d.ts CHANGED
@@ -42,6 +42,6 @@ declare function checkCoreVersionCompat(coreVersion: string): void;
42
42
  */
43
43
 
44
44
  /** Versão do SDK — exportada explicitamente pra detecção em runtime. */
45
- declare const VERSION: "3.4.1";
45
+ declare const VERSION: "3.4.3";
46
46
 
47
47
  export { VERSION, checkCoreVersionCompat };
package/dist/index.mjs CHANGED
@@ -682,13 +682,17 @@ var init_lease = __esm({
682
682
  // src/db/sql/sql-client.ts
683
683
  var sql_client_exports = {};
684
684
  __export(sql_client_exports, {
685
+ DEFAULT_POOL_CONNECT_TIMEOUT_MS: () => DEFAULT_POOL_CONNECT_TIMEOUT_MS,
686
+ DEFAULT_POOL_IDLE_MS: () => DEFAULT_POOL_IDLE_MS,
687
+ DEFAULT_POOL_MAX: () => DEFAULT_POOL_MAX,
685
688
  LEASE_ENDPOINT: () => LEASE_ENDPOINT,
686
689
  LEASE_RENEW_ENDPOINT: () => LEASE_RENEW_ENDPOINT,
687
690
  createDrizzleHandle: () => createDrizzleHandle,
688
691
  createHttpLeaseFetcher: () => createHttpLeaseFetcher,
689
692
  createPgPool: () => createPgPool,
690
693
  createSqlClientFromConfig: () => createSqlClientFromConfig,
691
- createSqlClientWithDeps: () => createSqlClientWithDeps
694
+ createSqlClientWithDeps: () => createSqlClientWithDeps,
695
+ resolvePoolTuning: () => resolvePoolTuning
692
696
  });
693
697
  function mapEnvToCore(sdkEnv) {
694
698
  if (sdkEnv === "workspace") return "staging";
@@ -777,6 +781,30 @@ function parseLease(raw) {
777
781
  expiresAt: req("expiresAt", "string")
778
782
  };
779
783
  }
784
+ function readEnvInt(name, def, min, max) {
785
+ const raw = typeof process !== "undefined" ? process.env?.[name] : void 0;
786
+ if (raw === void 0 || raw.trim() === "") return def;
787
+ const n = Number.parseInt(raw.trim(), 10);
788
+ if (!Number.isFinite(n) || n < min || n > max) return def;
789
+ return n;
790
+ }
791
+ function resolvePoolTuning() {
792
+ return {
793
+ // Teto 100: bem abaixo do `max_client_conn = 500` do PgBouncer, com folga
794
+ // para múltiplas instâncias do app dividirem o mesmo front-door.
795
+ max: readEnvInt("NEETRU_DB_POOL_MAX", DEFAULT_POOL_MAX, 1, 100),
796
+ // Teto 15min = janela do cert; piso 1s.
797
+ idleTimeoutMillis: readEnvInt("NEETRU_DB_POOL_IDLE_MS", DEFAULT_POOL_IDLE_MS, 1e3, 9e5),
798
+ connectionTimeoutMillis: readEnvInt(
799
+ "NEETRU_DB_POOL_CONNECT_TIMEOUT_MS",
800
+ DEFAULT_POOL_CONNECT_TIMEOUT_MS,
801
+ 1e3,
802
+ 12e4
803
+ ),
804
+ keepAlive: true,
805
+ keepAliveInitialDelayMillis: 1e4
806
+ };
807
+ }
780
808
  async function createPgPool(lease) {
781
809
  const { Pool } = await import(
782
810
  /* webpackIgnore: true */
@@ -795,9 +823,7 @@ async function createPgPool(lease) {
795
823
  user: lease.user,
796
824
  password: lease.password,
797
825
  ssl,
798
- max: 3,
799
- idleTimeoutMillis: 3e4,
800
- connectionTimeoutMillis: 1e4
826
+ ...resolvePoolTuning()
801
827
  });
802
828
  }
803
829
  async function createDrizzleHandle(pool, schema) {
@@ -932,9 +958,9 @@ async function createSqlClientFromConfig(config, schema, options) {
932
958
  user: lease.user,
933
959
  password: lease.password,
934
960
  ssl,
935
- max: 3,
936
- idleTimeoutMillis: 3e4,
937
- connectionTimeoutMillis: 1e4
961
+ // Tuning centralizado (env-tunável) — ver resolvePoolTuning + auditoria
962
+ // docs/_review/AUDITORIA_DB_CONN_PERF_2026-09-06.md no Core.
963
+ ...resolvePoolTuning()
938
964
  });
939
965
  };
940
966
  const createDrizzle = (pool, s) => {
@@ -957,7 +983,7 @@ async function createSqlClientFromConfig(config, schema, options) {
957
983
  options
958
984
  );
959
985
  }
960
- var LEASE_ENDPOINT, LEASE_RENEW_ENDPOINT;
986
+ var LEASE_ENDPOINT, LEASE_RENEW_ENDPOINT, DEFAULT_POOL_MAX, DEFAULT_POOL_IDLE_MS, DEFAULT_POOL_CONNECT_TIMEOUT_MS;
961
987
  var init_sql_client = __esm({
962
988
  "src/db/sql/sql-client.ts"() {
963
989
  init_db_errors();
@@ -966,6 +992,9 @@ var init_sql_client = __esm({
966
992
  init_resilient_pool();
967
993
  LEASE_ENDPOINT = "/api/sdk/v1/db/lease";
968
994
  LEASE_RENEW_ENDPOINT = "/api/sdk/v1/db/lease/renew";
995
+ DEFAULT_POOL_MAX = 10;
996
+ DEFAULT_POOL_IDLE_MS = 6e4;
997
+ DEFAULT_POOL_CONNECT_TIMEOUT_MS = 1e4;
969
998
  }
970
999
  });
971
1000
 
@@ -8002,7 +8031,7 @@ function createNeetruClient(config = {}) {
8002
8031
  init_errors();
8003
8032
  init_db_errors();
8004
8033
  init_http();
8005
- var VERSION = "3.4.1";
8034
+ var VERSION = "3.4.3";
8006
8035
 
8007
8036
  export { DEFAULT_BASE_URL, DEV_FIXTURE_USER, MockAi, MockAuth, MockCheckout, MockDb, MockEntitlements, MockNotifications, MockSupport, MockUsage, MockWebhooks, NEETRU_SENTINEL_KEY, NeetruDbError, NeetruError, VERSION, checkCoreVersionCompat, createAiNamespace, createCheckoutNamespace, createNeetruClient, createNeetruDb, createNotificationsNamespace, createWebhooksNamespace, increment, isFieldSentinel, isIncrementSentinel, isServerTimestampSentinel, serverTimestamp, verifyWebhookRequest, verifyWebhookSignature };
8008
8037
  //# sourceMappingURL=index.mjs.map