@neetru/sdk 3.2.1 → 3.2.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 +19 -0
- package/dist/auth.cjs +16 -10
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +16 -10
- package/dist/auth.mjs.map +1 -1
- package/dist/db.cjs +16 -10
- package/dist/db.cjs.map +1 -1
- package/dist/db.mjs +16 -10
- package/dist/db.mjs.map +1 -1
- package/dist/index.cjs +17 -11
- 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 +17 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/db.mjs
CHANGED
|
@@ -275,6 +275,9 @@ var init_http = __esm({
|
|
|
275
275
|
});
|
|
276
276
|
|
|
277
277
|
// src/db/sql/lease.ts
|
|
278
|
+
function hasConnectionChanged(oldLease, newLease) {
|
|
279
|
+
return oldLease.leaseId !== newLease.leaseId || oldLease.credentialVersion !== newLease.credentialVersion || oldLease.host !== newLease.host || oldLease.port !== newLease.port || oldLease.dbName !== newLease.dbName || oldLease.user !== newLease.user || oldLease.password !== newLease.password || oldLease.sslca !== newLease.sslca || oldLease.clientCert !== newLease.clientCert || oldLease.clientKey !== newLease.clientKey;
|
|
280
|
+
}
|
|
278
281
|
function mapPoolError(err) {
|
|
279
282
|
if (err instanceof NeetruDbError) return err;
|
|
280
283
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -379,21 +382,25 @@ var init_lease = __esm({
|
|
|
379
382
|
async _doRenew() {
|
|
380
383
|
if (this._closed) return;
|
|
381
384
|
try {
|
|
382
|
-
const
|
|
383
|
-
|
|
385
|
+
const withDb = (o) => {
|
|
386
|
+
if (this._deps.database !== void 0) o.database = this._deps.database;
|
|
387
|
+
return o;
|
|
384
388
|
};
|
|
385
|
-
|
|
386
|
-
|
|
389
|
+
let newLease;
|
|
390
|
+
try {
|
|
391
|
+
newLease = await this._deps.fetchLease(withDb({ leaseId: this._lease.leaseId }));
|
|
392
|
+
} catch (renewErr) {
|
|
393
|
+
newLease = await this._deps.fetchLease(withDb({}));
|
|
387
394
|
}
|
|
388
|
-
const newLease = await this._deps.fetchLease(renewOpts);
|
|
389
395
|
await this._swapPool(newLease);
|
|
390
396
|
} catch (err) {
|
|
391
397
|
this._renewalTimer = setTimeout(() => {
|
|
392
398
|
void this._doRenew();
|
|
393
399
|
}, MIN_RENEWAL_DELAY_MS);
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
400
|
+
console.warn(
|
|
401
|
+
`[SqlLeaseManager] renova\xE7\xE3o E emiss\xE3o de lease novo falharam; re-tentando em ${MIN_RENEWAL_DELAY_MS}ms (cert mTLS expira ~15min ap\xF3s o \xFAltimo swap):`,
|
|
402
|
+
err instanceof Error ? err.message : err
|
|
403
|
+
);
|
|
397
404
|
return;
|
|
398
405
|
}
|
|
399
406
|
this._scheduleRenewal();
|
|
@@ -404,8 +411,7 @@ var init_lease = __esm({
|
|
|
404
411
|
* Exposto como método protegido para testes.
|
|
405
412
|
*/
|
|
406
413
|
async _swapPool(newLease) {
|
|
407
|
-
|
|
408
|
-
if (!credRotated && newLease.leaseId === this._lease.leaseId) {
|
|
414
|
+
if (!hasConnectionChanged(this._lease, newLease)) {
|
|
409
415
|
this._lease = newLease;
|
|
410
416
|
return;
|
|
411
417
|
}
|