@go-avro/avro-js 1.6.6-rc5 → 1.6.6-rc7

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,7 +1,7 @@
1
1
  import { Socket } from 'socket.io-client';
2
2
  import { InfiniteData, QueryClient, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
3
3
  import { AuthManager } from '../auth/AuthManager.js';
4
- import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, PerformanceMetrics, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Chat, CheckIn, Company, CompanySummary, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, AppleLinkProof, AppleLoginResult, MicrosoftLoginResult, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, UserMergeSummary, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api.js';
4
+ import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, PerformanceMetrics, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Chat, CheckIn, Company, CompanySummary, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, AppleLinkProof, AppleLoginResult, MicrosoftLoginResult, LoginResponse, Message, Permission, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, UserMergeSummary, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api.js';
5
5
  import { AuthState, Tokens } from '../types/auth.js';
6
6
  import { CancelToken, ClientId, RetryStrategy } from '../types/client.js';
7
7
  import { StandardError } from '../types/error.js';
@@ -614,6 +614,8 @@ declare module './QueryClient.js' {
614
614
  user_ids?: string[];
615
615
  enabled?: boolean;
616
616
  }): UseQueryResult<UserCompanyAssociation[], StandardError>;
617
+ /** Whether the viewer's membership grants `permission`; undefined until known. */
618
+ useHasPermission(permission: Permission): boolean | undefined;
617
619
  useReportDevice(): ReturnType<typeof useMutation<Device, StandardError, DeviceInfo & {
618
620
  location_status?: LocationServicesStatus;
619
621
  }>>;
@@ -2,7 +2,10 @@ import { useMutation, useQuery } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../QueryClient.js';
3
3
  import { restoreNs, snapshotNs } from '../cache.js';
4
4
  import { keys } from '../realtime.js';
5
+ import { Permission } from '../../types/api.js';
5
6
  AvroQueryClient.prototype.useGetTeams = function (body, total, onProgress) {
7
+ // Customers and roles without team read get a 403; don't ask.
8
+ const canReadTeams = this.useHasPermission(Permission.CAN_READ_TEAMS);
6
9
  return useQuery({
7
10
  queryKey: keys.list('teams', this.companyId, {
8
11
  amt: body.amt ?? 50,
@@ -30,7 +33,7 @@ AvroQueryClient.prototype.useGetTeams = function (body, total, onProgress) {
30
33
  const teams = pages.flat();
31
34
  return teams;
32
35
  },
33
- enabled: Boolean(this.companyId),
36
+ enabled: Boolean(this.companyId) && canReadTeams !== false,
34
37
  });
35
38
  };
36
39
  AvroQueryClient.prototype.useCreateTeam = function () {
@@ -228,3 +228,16 @@ AvroQueryClient.prototype.useGetCompanyUsers = function (body = {}) {
228
228
  staleTime: 30000,
229
229
  });
230
230
  };
231
+ /**
232
+ * Whether the signed-in user's membership in the current company grants
233
+ * `permission`, directly or through a group: the check the backend makes
234
+ * before answering. `undefined` until the membership has loaded, so callers
235
+ * choose how to treat "not known yet"; gate a query with `!== false` to only
236
+ * skip it once the permission is known to be missing.
237
+ */
238
+ AvroQueryClient.prototype.useHasPermission = function (permission) {
239
+ const { data: self } = this.useGetSelf();
240
+ const { data: members } = this.useGetCompanyUsers();
241
+ const me = members?.find((member) => member.user?.id === self?.id);
242
+ return me ? (me.effective_permissions ?? []).includes(permission) : undefined;
243
+ };
@@ -236,6 +236,9 @@ export interface IntuitImportResult {
236
236
  skipped: number;
237
237
  payments_imported: number;
238
238
  payments_skipped: number;
239
+ pushed: number;
240
+ payments_pushed: number;
241
+ push_failed: number;
239
242
  }
240
243
  /**
241
244
  * A payment option on a catalog item write (backend `CreatePaymentOption`).
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "1.6.6-rc5";
1
+ export declare const AVRO_JS_VERSION = "1.6.6-rc7";
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-rc5';
3
+ export const AVRO_JS_VERSION = '1.6.6-rc7';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "1.6.6-rc5",
3
+ "version": "1.6.6-rc7",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",