@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/index.cjs
CHANGED
|
@@ -278,6 +278,9 @@ var init_db_errors = __esm({
|
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
// src/db/sql/lease.ts
|
|
281
|
+
function hasConnectionChanged(oldLease, newLease) {
|
|
282
|
+
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;
|
|
283
|
+
}
|
|
281
284
|
function mapPoolError(err) {
|
|
282
285
|
if (err instanceof exports.NeetruDbError) return err;
|
|
283
286
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -382,21 +385,25 @@ var init_lease = __esm({
|
|
|
382
385
|
async _doRenew() {
|
|
383
386
|
if (this._closed) return;
|
|
384
387
|
try {
|
|
385
|
-
const
|
|
386
|
-
|
|
388
|
+
const withDb = (o) => {
|
|
389
|
+
if (this._deps.database !== void 0) o.database = this._deps.database;
|
|
390
|
+
return o;
|
|
387
391
|
};
|
|
388
|
-
|
|
389
|
-
|
|
392
|
+
let newLease;
|
|
393
|
+
try {
|
|
394
|
+
newLease = await this._deps.fetchLease(withDb({ leaseId: this._lease.leaseId }));
|
|
395
|
+
} catch (renewErr) {
|
|
396
|
+
newLease = await this._deps.fetchLease(withDb({}));
|
|
390
397
|
}
|
|
391
|
-
const newLease = await this._deps.fetchLease(renewOpts);
|
|
392
398
|
await this._swapPool(newLease);
|
|
393
399
|
} catch (err) {
|
|
394
400
|
this._renewalTimer = setTimeout(() => {
|
|
395
401
|
void this._doRenew();
|
|
396
402
|
}, MIN_RENEWAL_DELAY_MS);
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
403
|
+
console.warn(
|
|
404
|
+
`[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):`,
|
|
405
|
+
err instanceof Error ? err.message : err
|
|
406
|
+
);
|
|
400
407
|
return;
|
|
401
408
|
}
|
|
402
409
|
this._scheduleRenewal();
|
|
@@ -407,8 +414,7 @@ var init_lease = __esm({
|
|
|
407
414
|
* Exposto como método protegido para testes.
|
|
408
415
|
*/
|
|
409
416
|
async _swapPool(newLease) {
|
|
410
|
-
|
|
411
|
-
if (!credRotated && newLease.leaseId === this._lease.leaseId) {
|
|
417
|
+
if (!hasConnectionChanged(this._lease, newLease)) {
|
|
412
418
|
this._lease = newLease;
|
|
413
419
|
return;
|
|
414
420
|
}
|
|
@@ -7122,7 +7128,7 @@ function createNeetruClient(config = {}) {
|
|
|
7122
7128
|
init_errors();
|
|
7123
7129
|
init_db_errors();
|
|
7124
7130
|
init_http();
|
|
7125
|
-
var VERSION = "3.2.
|
|
7131
|
+
var VERSION = "3.2.2";
|
|
7126
7132
|
|
|
7127
7133
|
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
|
|
7128
7134
|
exports.DEV_FIXTURE_USER = DEV_FIXTURE_USER;
|