@arcote.tech/arc-adapter-db-postgres 0.7.16 → 0.7.17
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.js +37 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1470,6 +1470,42 @@ class AuthAdapter {
|
|
|
1470
1470
|
this.scopes.clear();
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
|
+
var DEFAULT_TIMEOUT_MS = 8000;
|
|
1474
|
+
var provider = null;
|
|
1475
|
+
var latestSync = null;
|
|
1476
|
+
var syncSeq = 0;
|
|
1477
|
+
function triggerModuleSync(scope, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
1478
|
+
if (!provider) {
|
|
1479
|
+
latestSync = Promise.resolve();
|
|
1480
|
+
return latestSync;
|
|
1481
|
+
}
|
|
1482
|
+
const seq = ++syncSeq;
|
|
1483
|
+
const run = (async () => {
|
|
1484
|
+
try {
|
|
1485
|
+
await provider(scope);
|
|
1486
|
+
} catch (err) {
|
|
1487
|
+
console.warn("[arc] module sync failed during setToken:", err);
|
|
1488
|
+
}
|
|
1489
|
+
})();
|
|
1490
|
+
const guarded = new Promise((resolve) => {
|
|
1491
|
+
let settled = false;
|
|
1492
|
+
const done = () => {
|
|
1493
|
+
if (settled)
|
|
1494
|
+
return;
|
|
1495
|
+
settled = true;
|
|
1496
|
+
resolve();
|
|
1497
|
+
};
|
|
1498
|
+
const timer = setTimeout(() => {
|
|
1499
|
+
console.warn(`[arc] module sync did not complete within ${timeoutMs}ms; proceeding anyway.`);
|
|
1500
|
+
done();
|
|
1501
|
+
}, timeoutMs);
|
|
1502
|
+
timer?.unref?.();
|
|
1503
|
+
run.then(done, done).finally(() => clearTimeout(timer));
|
|
1504
|
+
});
|
|
1505
|
+
if (seq === syncSeq)
|
|
1506
|
+
latestSync = guarded;
|
|
1507
|
+
return guarded;
|
|
1508
|
+
}
|
|
1473
1509
|
var eventWireInstanceCounter = 0;
|
|
1474
1510
|
|
|
1475
1511
|
class EventWire {
|
|
@@ -4237,6 +4273,7 @@ class ScopedModel {
|
|
|
4237
4273
|
for (const listener4 of this.tokenListeners) {
|
|
4238
4274
|
listener4();
|
|
4239
4275
|
}
|
|
4276
|
+
return triggerModuleSync(this.scopeName);
|
|
4240
4277
|
}
|
|
4241
4278
|
getToken() {
|
|
4242
4279
|
return this.authAdapter.getToken();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-adapter-db-postgres",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"postgres": "^3.4.4"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@arcote.tech/arc": "^0.7.
|
|
26
|
+
"@arcote.tech/arc": "^0.7.17"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/pg": "^8.11.0",
|