@go-avro/avro-js 1.6.6-rc1 → 1.6.6-rc2
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/client/QueryClient.js +7 -2
- package/dist/client/realtime.d.ts +7 -0
- package/dist/client/realtime.js +14 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { LoginResponse, } from '../types/api.js';
|
|
|
7
7
|
import { AuthState } from '../types/auth.js';
|
|
8
8
|
import { StandardError } from '../types/error.js';
|
|
9
9
|
import { withoutEmpty } from './wire.js';
|
|
10
|
-
import { ChangeApplier, fallbackInvalidate, patchMember, patchMemberLocation, patchTeamLocation, } from './realtime.js';
|
|
10
|
+
import { ChangeApplier, fallbackInvalidate, patchMember, patchMemberLocation, patchTeamLocation, retryDenied, } from './realtime.js';
|
|
11
11
|
import { QueryPersister } from './persist.js';
|
|
12
12
|
/** Keep the original status (401/403/404/0…) when surfacing a list-fetch failure. */
|
|
13
13
|
function fetchError(err, context) {
|
|
@@ -319,9 +319,14 @@ export class AvroQueryClient {
|
|
|
319
319
|
}
|
|
320
320
|
applier.apply(payload);
|
|
321
321
|
});
|
|
322
|
+
// Sent to each member whose access changed (a grant, a group
|
|
323
|
+
// join/leave, or an edit to one of their groups): rejoin, and
|
|
324
|
+
// retry whatever the old permissions were refused.
|
|
322
325
|
on('rejoin_company', (data) => {
|
|
323
|
-
if (data?.company_id && data.company_id === this.companyId)
|
|
326
|
+
if (data?.company_id && data.company_id === this.companyId) {
|
|
324
327
|
this.joinCompanyRoom();
|
|
328
|
+
retryDenied(queryClient);
|
|
329
|
+
}
|
|
325
330
|
});
|
|
326
331
|
// Sent before a chat room is closed after a membership change;
|
|
327
332
|
// the server re-checks membership, so removed members stay out.
|
|
@@ -58,6 +58,13 @@ export declare function removeEntity(qc: QueryClient, ns: string, id: string): v
|
|
|
58
58
|
export declare function upsertEntity(qc: QueryClient, spec: EntitySpec, item: any, company?: string | null): void;
|
|
59
59
|
export declare function matchesList(type: string, key: readonly unknown[], item: any): ListMatch;
|
|
60
60
|
export declare function invalidateType(qc: QueryClient, spec: EntitySpec): void;
|
|
61
|
+
/**
|
|
62
|
+
* Refetch every query the server refused with a 403. Called when a
|
|
63
|
+
* membership changes: the viewer may have just been granted the
|
|
64
|
+
* permission, and nothing else would retry a denied list until the next
|
|
65
|
+
* focus, remount, or reload.
|
|
66
|
+
*/
|
|
67
|
+
export declare function retryDenied(qc: QueryClient): void;
|
|
61
68
|
export declare class ChangeApplier {
|
|
62
69
|
private client;
|
|
63
70
|
private qc;
|
package/dist/client/realtime.js
CHANGED
|
@@ -373,6 +373,18 @@ export function invalidateType(qc, spec) {
|
|
|
373
373
|
qc.invalidateQueries({ queryKey: [spec.ns] });
|
|
374
374
|
spec.alsoInvalidate?.forEach((k) => qc.invalidateQueries({ queryKey: [...k] }));
|
|
375
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Refetch every query the server refused with a 403. Called when a
|
|
378
|
+
* membership changes: the viewer may have just been granted the
|
|
379
|
+
* permission, and nothing else would retry a denied list until the next
|
|
380
|
+
* focus, remount, or reload.
|
|
381
|
+
*/
|
|
382
|
+
export function retryDenied(qc) {
|
|
383
|
+
qc.invalidateQueries({
|
|
384
|
+
predicate: (q) => q.state.status === 'error' &&
|
|
385
|
+
q.state.error?.status === 403,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
376
388
|
// ─── Applying batches ───────────────────────────────────────────────
|
|
377
389
|
const FETCH_COALESCE_MS = 50;
|
|
378
390
|
const FETCH_CHUNK = 100;
|
|
@@ -425,6 +437,8 @@ export class ChangeApplier {
|
|
|
425
437
|
continue;
|
|
426
438
|
if (entry.op === 'invalidate' || spec.invalidateOnly) {
|
|
427
439
|
invalidateType(this.qc, spec);
|
|
440
|
+
if (entry.type === 'member')
|
|
441
|
+
retryDenied(this.qc);
|
|
428
442
|
if (spec.ns === 'users' && entry.id) {
|
|
429
443
|
this.qc.invalidateQueries({ queryKey: keys.detail('users', entry.id) });
|
|
430
444
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "1.6.6-
|
|
1
|
+
export declare const AVRO_JS_VERSION = "1.6.6-rc2";
|
package/dist/version.js
CHANGED