@go-avro/avro-js 1.6.4-rc4 → 1.6.4-rc5

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.
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQuery, useInfiniteQuery } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../QueryClient.js';
3
- import { keys, isListKey } from '../realtime.js';
3
+ import { keys, isListKey, VIEWER_SCOPE } from '../realtime.js';
4
4
  import { removeOptimisticRow, seedDetails } from '../cache.js';
5
5
  import { Session } from '../../types/api.js';
6
6
  import { withoutEmpty } from '../wire.js';
@@ -57,7 +57,7 @@ AvroQueryClient.prototype.useGetSessions = function (body = {}) {
57
57
  AvroQueryClient.prototype.useGetUserSessions = function () {
58
58
  const queryClient = this.getQueryClient();
59
59
  const result = useQuery({
60
- queryKey: keys.list(NS, 'mine', { active: true }),
60
+ queryKey: keys.list(NS, VIEWER_SCOPE, { active: true }),
61
61
  queryFn: () => this.get({ path: '/session' }).then((sessions) => seedDetails(queryClient, NS, (Array.isArray(sessions) ? sessions : []).map((s) => new Session(s)))),
62
62
  enabled: Boolean(this.companyId),
63
63
  });
@@ -16,6 +16,12 @@ export declare const keys: {
16
16
  export declare function isListKey(key: readonly unknown[]): boolean;
17
17
  export declare function isDetailKey(key: readonly unknown[]): boolean;
18
18
  export declare function listFilters(key: readonly unknown[]): Filters;
19
+ /**
20
+ * List scope for viewer-scoped lists (e.g. the caller's own open sessions
21
+ * across companies). Not a company id: change batches for any company may
22
+ * touch it, so they're never skipped by the company check.
23
+ */
24
+ export declare const VIEWER_SCOPE = "mine";
19
25
  export declare function listScope(key: readonly unknown[]): string;
20
26
  export type ChangeOp = 'create' | 'update' | 'delete' | 'invalidate';
21
27
  export interface ChangeEntry {
@@ -20,6 +20,12 @@ export function listFilters(key) {
20
20
  const f = key[3];
21
21
  return f && typeof f === 'object' ? f : {};
22
22
  }
23
+ /**
24
+ * List scope for viewer-scoped lists (e.g. the caller's own open sessions
25
+ * across companies). Not a company id: change batches for any company may
26
+ * touch it, so they're never skipped by the company check.
27
+ */
28
+ export const VIEWER_SCOPE = 'mine';
23
29
  export function listScope(key) {
24
30
  return typeof key[2] === 'string' ? key[2] : '';
25
31
  }
@@ -126,7 +132,7 @@ function matchBills(filters, item) {
126
132
  }
127
133
  function matchSessions(filters, item, scope) {
128
134
  // "mine" comes from GET /session (viewer-scoped): can't tell ownership here.
129
- if (scope === 'mine')
135
+ if (scope === VIEWER_SCOPE)
130
136
  return 'unknown';
131
137
  // `unknown_ids` on the sessions endpoint means "fetch exactly these".
132
138
  const wanted = filters.unknown_ids;
@@ -333,7 +339,7 @@ export function upsertEntity(qc, spec, item, company) {
333
339
  for (const query of lists) {
334
340
  const key = query.queryKey;
335
341
  const scope = listScope(key);
336
- if (company && scope && scope !== company)
342
+ if (company && scope && scope !== company && scope !== VIEWER_SCOPE)
337
343
  continue;
338
344
  const verdict = spec.listMatch
339
345
  ? spec.listMatch(listFilters(key), item, listScope(key))
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "1.6.4-rc4";
1
+ export declare const AVRO_JS_VERSION = "1.6.4-rc5";
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.4-rc4';
3
+ export const AVRO_JS_VERSION = '1.6.4-rc5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "1.6.4-rc4",
3
+ "version": "1.6.4-rc5",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",