@neetru/sdk 3.1.15 → 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 +72 -0
- package/README.md +62 -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/dist/react.cjs +90 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +43 -1
- package/dist/react.d.ts +43 -1
- package/dist/react.mjs +90 -1
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/db.cjs
CHANGED
|
@@ -277,6 +277,9 @@ var init_http = __esm({
|
|
|
277
277
|
});
|
|
278
278
|
|
|
279
279
|
// src/db/sql/lease.ts
|
|
280
|
+
function hasConnectionChanged(oldLease, newLease) {
|
|
281
|
+
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;
|
|
282
|
+
}
|
|
280
283
|
function mapPoolError(err) {
|
|
281
284
|
if (err instanceof exports.NeetruDbError) return err;
|
|
282
285
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -381,21 +384,25 @@ var init_lease = __esm({
|
|
|
381
384
|
async _doRenew() {
|
|
382
385
|
if (this._closed) return;
|
|
383
386
|
try {
|
|
384
|
-
const
|
|
385
|
-
|
|
387
|
+
const withDb = (o) => {
|
|
388
|
+
if (this._deps.database !== void 0) o.database = this._deps.database;
|
|
389
|
+
return o;
|
|
386
390
|
};
|
|
387
|
-
|
|
388
|
-
|
|
391
|
+
let newLease;
|
|
392
|
+
try {
|
|
393
|
+
newLease = await this._deps.fetchLease(withDb({ leaseId: this._lease.leaseId }));
|
|
394
|
+
} catch (renewErr) {
|
|
395
|
+
newLease = await this._deps.fetchLease(withDb({}));
|
|
389
396
|
}
|
|
390
|
-
const newLease = await this._deps.fetchLease(renewOpts);
|
|
391
397
|
await this._swapPool(newLease);
|
|
392
398
|
} catch (err) {
|
|
393
399
|
this._renewalTimer = setTimeout(() => {
|
|
394
400
|
void this._doRenew();
|
|
395
401
|
}, MIN_RENEWAL_DELAY_MS);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
402
|
+
console.warn(
|
|
403
|
+
`[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):`,
|
|
404
|
+
err instanceof Error ? err.message : err
|
|
405
|
+
);
|
|
399
406
|
return;
|
|
400
407
|
}
|
|
401
408
|
this._scheduleRenewal();
|
|
@@ -406,8 +413,7 @@ var init_lease = __esm({
|
|
|
406
413
|
* Exposto como método protegido para testes.
|
|
407
414
|
*/
|
|
408
415
|
async _swapPool(newLease) {
|
|
409
|
-
|
|
410
|
-
if (!credRotated && newLease.leaseId === this._lease.leaseId) {
|
|
416
|
+
if (!hasConnectionChanged(this._lease, newLease)) {
|
|
411
417
|
this._lease = newLease;
|
|
412
418
|
return;
|
|
413
419
|
}
|