@arcote.tech/arc-adapter-db-sqlite 0.7.10 → 0.7.12
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 +36 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3210,7 +3210,11 @@ class ArcCommand extends ArcContextElement {
|
|
|
3210
3210
|
if (!adapters.commandWire) {
|
|
3211
3211
|
throw new Error(`Command "${this.data.name}" has no handler and no commandWire adapter available for remote execution`);
|
|
3212
3212
|
}
|
|
3213
|
-
|
|
3213
|
+
const wireAuth = adapters.scope ? {
|
|
3214
|
+
scope: adapters.scope.scopeName,
|
|
3215
|
+
token: adapters.scope.getToken()
|
|
3216
|
+
} : undefined;
|
|
3217
|
+
return await adapters.commandWire.executeCommand(this.data.name, params, wireAuth);
|
|
3214
3218
|
};
|
|
3215
3219
|
return Object.assign(executeFunc, { params: this.data.params });
|
|
3216
3220
|
}
|
|
@@ -4282,6 +4286,7 @@ class StreamingQueryCache {
|
|
|
4282
4286
|
views = [];
|
|
4283
4287
|
activeStreams = new Map;
|
|
4284
4288
|
pendingUnsubscribes = new Map;
|
|
4289
|
+
streamScopes = new Map;
|
|
4285
4290
|
static UNSUBSCRIBE_DELAY_MS = 5000;
|
|
4286
4291
|
registerViews(views) {
|
|
4287
4292
|
this.views = views;
|
|
@@ -4340,6 +4345,7 @@ class StreamingQueryCache {
|
|
|
4340
4345
|
if (current2 && current2.refCount <= 0) {
|
|
4341
4346
|
current2.unsubscribe();
|
|
4342
4347
|
this.activeStreams.delete(viewName);
|
|
4348
|
+
this.streamScopes.delete(viewName);
|
|
4343
4349
|
}
|
|
4344
4350
|
}, StreamingQueryCache.UNSUBSCRIBE_DELAY_MS);
|
|
4345
4351
|
this.pendingUnsubscribes.set(viewName, timeout);
|
|
@@ -4347,6 +4353,8 @@ class StreamingQueryCache {
|
|
|
4347
4353
|
}
|
|
4348
4354
|
subscribeQuery(descriptor, eventWire, scope) {
|
|
4349
4355
|
const key = descriptor.element;
|
|
4356
|
+
if (scope)
|
|
4357
|
+
this.streamScopes.set(key, scope);
|
|
4350
4358
|
const { unsubscribe } = this.registerStream(key, () => {
|
|
4351
4359
|
const subId = eventWire.subscribeQuery(descriptor, (data) => {
|
|
4352
4360
|
this.setViewData(descriptor.element, data);
|
|
@@ -4355,6 +4363,28 @@ class StreamingQueryCache {
|
|
|
4355
4363
|
});
|
|
4356
4364
|
return unsubscribe;
|
|
4357
4365
|
}
|
|
4366
|
+
invalidateScope(scope) {
|
|
4367
|
+
for (const [viewName, viewScope] of this.streamScopes) {
|
|
4368
|
+
if (viewScope !== scope)
|
|
4369
|
+
continue;
|
|
4370
|
+
const pending = this.pendingUnsubscribes.get(viewName);
|
|
4371
|
+
if (pending) {
|
|
4372
|
+
clearTimeout(pending);
|
|
4373
|
+
this.pendingUnsubscribes.delete(viewName);
|
|
4374
|
+
}
|
|
4375
|
+
const stream = this.activeStreams.get(viewName);
|
|
4376
|
+
if (stream) {
|
|
4377
|
+
try {
|
|
4378
|
+
stream.unsubscribe();
|
|
4379
|
+
} catch {}
|
|
4380
|
+
this.activeStreams.delete(viewName);
|
|
4381
|
+
}
|
|
4382
|
+
this.streamScopes.delete(viewName);
|
|
4383
|
+
const store = this.stores.get(viewName);
|
|
4384
|
+
if (store)
|
|
4385
|
+
store.clear();
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4358
4388
|
setViewData(viewName, data) {
|
|
4359
4389
|
const store = this.stores.get(viewName);
|
|
4360
4390
|
if (!store)
|
|
@@ -4402,6 +4432,11 @@ class StreamingQueryCache {
|
|
|
4402
4432
|
stream.unsubscribe();
|
|
4403
4433
|
}
|
|
4404
4434
|
this.activeStreams.clear();
|
|
4435
|
+
this.streamScopes.clear();
|
|
4436
|
+
for (const timeout of this.pendingUnsubscribes.values()) {
|
|
4437
|
+
clearTimeout(timeout);
|
|
4438
|
+
}
|
|
4439
|
+
this.pendingUnsubscribes.clear();
|
|
4405
4440
|
for (const store of this.stores.values()) {
|
|
4406
4441
|
store.clear();
|
|
4407
4442
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-adapter-db-sqlite",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test": "bun test"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@arcote.tech/arc": "^0.7.
|
|
23
|
+
"@arcote.tech/arc": "^0.7.12"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"typescript": "^5.0.0"
|