@go-avro/avro-js 1.6.6-rc1 → 1.6.6-rc3

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.
@@ -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;
@@ -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
  }
@@ -274,6 +274,8 @@ export interface CatalogItemUpdatePayload {
274
274
  recommended_expire_on?: number | null;
275
275
  /** Skill GUIDs; replaces the item's skills. */
276
276
  skills?: string[];
277
+ /** ProposalTerms GUIDs; replaces the item's suggested terms. */
278
+ terms?: string[];
277
279
  /** Replaces the item's payment options. */
278
280
  payment_options?: PaymentOptionInput[];
279
281
  }
@@ -284,7 +286,7 @@ export type CatalogItemCreatePayload = CatalogItemUpdatePayload & {
284
286
  /**
285
287
  * Body of `POST /job/<id>/proposal` and `PUT /proposal/<id>` (backend
286
288
  * `CreateProposal` / `UpdateProposal`); omitted fields are unchanged, and
287
- * null clears `expire_on` / `terms_version_id` / `prepay_due_date`.
289
+ * null clears `expire_on` / `prepay_due_date`.
288
290
  */
289
291
  export interface ProposalWritePayload {
290
292
  /**
@@ -292,8 +294,8 @@ export interface ProposalWritePayload {
292
294
  * null means never.
293
295
  */
294
296
  expire_on?: number | null;
295
- /** Terms version GUID; null detaches. */
296
- terms_version_id?: string | null;
297
+ /** Terms version GUIDs; replaces the attached terms (`[]` detaches all). */
298
+ terms_version_ids?: string[];
297
299
  /** Unix seconds (>= 0); null clears. */
298
300
  prepay_due_date?: number | null;
299
301
  /** Replaces the proposal's tasks (only `id` is read). */
@@ -329,8 +331,11 @@ export interface ProposalReviewTask {
329
331
  /** Body of `POST /proposal/<id>/review` (backend `ReviewProposal`). */
330
332
  export interface ProposalReviewPayload {
331
333
  tasks?: ProposalReviewTask[];
332
- /** Required when the proposal has terms and any task is accepted. */
333
- terms_version_id?: string | null;
334
+ /**
335
+ * The terms version GUIDs agreed to; must be exactly the proposal's when
336
+ * it has terms and any task is accepted.
337
+ */
338
+ terms_version_ids?: string[];
334
339
  pay_in_cash?: boolean;
335
340
  }
336
341
  /**
@@ -14,6 +14,6 @@ export interface CatalogItem {
14
14
  recommended_expire_on: number | null;
15
15
  time_created: number | null;
16
16
  time_updated: number | null;
17
- /** Skill GUIDs. */
18
17
  skills: string[];
18
+ terms: string[];
19
19
  }
@@ -6,7 +6,7 @@ export interface Proposal {
6
6
  job_id: string;
7
7
  expire_on: number | null;
8
8
  expired: boolean;
9
- terms: ProposalTermsVersion | null;
9
+ terms: ProposalTermsVersion[];
10
10
  accepted_at: number | null;
11
11
  tasks: Task[];
12
12
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "1.6.6-rc1";
1
+ export declare const AVRO_JS_VERSION = "1.6.6-rc3";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Regenerated from package.json by the `prebuild` npm hook.
3
- export const AVRO_JS_VERSION = '1.6.6-rc1';
3
+ export const AVRO_JS_VERSION = '1.6.6-rc3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "1.6.6-rc1",
3
+ "version": "1.6.6-rc3",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",