@go-avro/avro-js 0.1.6 → 0.1.8

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.
Files changed (92) hide show
  1. package/dist/auth/AuthManager.d.ts +2 -2
  2. package/dist/auth/AuthManager.js +2 -2
  3. package/dist/auth/storage.d.ts +1 -1
  4. package/dist/billing/fees.d.ts +1 -1
  5. package/dist/billing/fees.js +1 -1
  6. package/dist/census.d.ts +1 -1
  7. package/dist/client/AvroQueryClientProvider.d.ts +1 -1
  8. package/dist/client/QueryClient.d.ts +17 -11
  9. package/dist/client/QueryClient.js +57 -26
  10. package/dist/client/core/fetch.js +4 -4
  11. package/dist/client/core/utils.js +1 -1
  12. package/dist/client/core/xhr.js +4 -4
  13. package/dist/client/hooks/address.js +1 -1
  14. package/dist/client/hooks/analytics.js +1 -1
  15. package/dist/client/hooks/audit.js +1 -1
  16. package/dist/client/hooks/avro.js +9 -1
  17. package/dist/client/hooks/bills.js +3 -3
  18. package/dist/client/hooks/catalog_items.js +1 -1
  19. package/dist/client/hooks/chats.js +2 -2
  20. package/dist/client/hooks/checkins.js +1 -1
  21. package/dist/client/hooks/companies.js +3 -3
  22. package/dist/client/hooks/devices.js +1 -1
  23. package/dist/client/hooks/email.d.ts +1 -1
  24. package/dist/client/hooks/email.js +1 -1
  25. package/dist/client/hooks/events.js +3 -3
  26. package/dist/client/hooks/groups.js +2 -2
  27. package/dist/client/hooks/jobs.js +3 -3
  28. package/dist/client/hooks/labels.js +2 -2
  29. package/dist/client/hooks/messages.js +2 -2
  30. package/dist/client/hooks/months.js +3 -3
  31. package/dist/client/hooks/payouts.js +2 -2
  32. package/dist/client/hooks/plans.js +1 -1
  33. package/dist/client/hooks/prepayments.js +3 -3
  34. package/dist/client/hooks/proposal.js +2 -2
  35. package/dist/client/hooks/root.js +1 -1
  36. package/dist/client/hooks/routes.js +3 -3
  37. package/dist/client/hooks/sessions.js +3 -3
  38. package/dist/client/hooks/skills.js +2 -2
  39. package/dist/client/hooks/teams.js +2 -2
  40. package/dist/client/hooks/timecards.js +1 -1
  41. package/dist/client/hooks/users.js +7 -3
  42. package/dist/client/hooks/waivers.js +2 -2
  43. package/dist/client/persist.js +2 -2
  44. package/dist/client/realtime.d.ts +2 -2
  45. package/dist/client/realtime.js +4 -2
  46. package/dist/index.d.ts +52 -52
  47. package/dist/index.js +47 -47
  48. package/dist/presence.d.ts +1 -1
  49. package/dist/types/api/AdditionalCharge.d.ts +1 -1
  50. package/dist/types/api/Avro.d.ts +72 -1
  51. package/dist/types/api/Bill.d.ts +8 -8
  52. package/dist/types/api/Bill.js +1 -1
  53. package/dist/types/api/BillUser.d.ts +1 -1
  54. package/dist/types/api/CatalogItem.d.ts +1 -1
  55. package/dist/types/api/Chat.d.ts +2 -2
  56. package/dist/types/api/Company.d.ts +11 -11
  57. package/dist/types/api/CustomLineItem.d.ts +1 -1
  58. package/dist/types/api/DelayEvent.d.ts +2 -2
  59. package/dist/types/api/DelayEvent.js +1 -1
  60. package/dist/types/api/Device.d.ts +2 -2
  61. package/dist/types/api/Email.d.ts +7 -5
  62. package/dist/types/api/Group.d.ts +1 -1
  63. package/dist/types/api/Job.d.ts +7 -7
  64. package/dist/types/api/Job.js +2 -2
  65. package/dist/types/api/LineItem.d.ts +1 -1
  66. package/dist/types/api/MemberState.d.ts +1 -1
  67. package/dist/types/api/Message.d.ts +1 -1
  68. package/dist/types/api/Notification.d.ts +17 -0
  69. package/dist/types/api/Notification.js +1 -0
  70. package/dist/types/api/PaymentMethod.d.ts +1 -1
  71. package/dist/types/api/Payout.d.ts +1 -1
  72. package/dist/types/api/Prepayment.d.ts +2 -2
  73. package/dist/types/api/Prepayment.js +1 -1
  74. package/dist/types/api/ProcessingFeeLineItem.d.ts +1 -1
  75. package/dist/types/api/Route.d.ts +3 -3
  76. package/dist/types/api/Route.js +1 -1
  77. package/dist/types/api/RouteJob.d.ts +1 -1
  78. package/dist/types/api/ServiceMonth.d.ts +1 -1
  79. package/dist/types/api/Session.d.ts +2 -2
  80. package/dist/types/api/Task.d.ts +6 -6
  81. package/dist/types/api/Task.js +1 -1
  82. package/dist/types/api/Timecard.d.ts +1 -1
  83. package/dist/types/api/User.d.ts +6 -6
  84. package/dist/types/api/UserCompanyAssociation.d.ts +2 -2
  85. package/dist/types/api/_Event.d.ts +4 -4
  86. package/dist/types/api/_Event.js +1 -1
  87. package/dist/types/api.d.ts +50 -49
  88. package/dist/types/api.js +48 -47
  89. package/dist/types/cache.d.ts +1 -1
  90. package/dist/version.d.ts +1 -1
  91. package/dist/version.js +1 -1
  92. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { AuthState, Tokens } from '../types/auth';
2
- import { Cache, CacheData } from '../types/cache';
1
+ import { AuthState, Tokens } from '../types/auth.js';
2
+ import { Cache, CacheData } from '../types/cache.js';
3
3
  export declare class AuthManager {
4
4
  private storages;
5
5
  private baseUrl;
@@ -1,5 +1,5 @@
1
- import { AuthState } from '../types/auth';
2
- import { StandardError } from '../types/error';
1
+ import { AuthState } from '../types/auth.js';
2
+ import { StandardError } from '../types/error.js';
3
3
  export class AuthManager {
4
4
  constructor({ baseUrl, storage }) {
5
5
  this.tokenRefreshedCallbacks = [];
@@ -1,4 +1,4 @@
1
- import { Cache, CacheData } from '../types/cache';
1
+ import { Cache, CacheData } from '../types/cache.js';
2
2
  export declare class MemoryStorage implements Cache {
3
3
  private data;
4
4
  get(key?: keyof CacheData): Promise<CacheData | string | null>;
@@ -1,2 +1,2 @@
1
- import { PaymentType } from '../types/api/PaymentType';
1
+ import { PaymentType } from '../types/api/PaymentType.js';
2
2
  export declare function defaultPassOnFeeMethod(enabledPaymentMethods: PaymentType[] | null | undefined): PaymentType | null;
@@ -1,4 +1,4 @@
1
- import { PaymentType } from '../types/api/PaymentType';
1
+ import { PaymentType } from '../types/api/PaymentType.js';
2
2
  export function defaultPassOnFeeMethod(enabledPaymentMethods) {
3
3
  if (!enabledPaymentMethods || enabledPaymentMethods.length === 0)
4
4
  return null;
package/dist/census.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AddressFeature } from './types/api';
1
+ import { AddressFeature } from './types/api.js';
2
2
  /**
3
3
  * Geocode an address with the US Census geocoder, directly from the
4
4
  * client so requests come from each user's own IP rather than funneling
@@ -1,7 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
  import { AvroQueryClient, AvroQueryClientConfig } from './QueryClient';
4
- import { AuthManager } from '../auth/AuthManager';
4
+ import { AuthManager } from '../auth/AuthManager.js';
5
5
  export interface AvroQueryClientProviderProps {
6
6
  baseUrl: string;
7
7
  authManager: AuthManager;
@@ -1,15 +1,15 @@
1
1
  import { Socket } from 'socket.io-client';
2
2
  import { InfiniteData, QueryClient, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
3
- import { AuthManager } from '../auth/AuthManager';
4
- import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
5
- import { AuthState, Tokens } from '../types/auth';
6
- import { CancelToken, ClientId, RetryStrategy } from '../types/client';
7
- import { StandardError } from '../types/error';
8
- import { CacheData } from '../types/cache';
9
- import { Waiver } from '../types/api/Waiver';
10
- import type { EmailSucceededPayload, EmailFailedPayload, EmailType } from '../types/api/EmailNotification';
11
- import type { BulkDeleteBillsResponse, BulkEmailBillsResponse } from '../client/hooks/bills';
12
- import { type QueryPersistOptions } from '../client/persist';
3
+ import { AuthManager } from '../auth/AuthManager.js';
4
+ import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, PerformanceMetrics, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api.js';
5
+ import { AuthState, Tokens } from '../types/auth.js';
6
+ import { CancelToken, ClientId, RetryStrategy } from '../types/client.js';
7
+ import { StandardError } from '../types/error.js';
8
+ import { CacheData } from '../types/cache.js';
9
+ import { Waiver } from '../types/api/Waiver.js';
10
+ import type { EmailSucceededPayload, EmailFailedPayload, EmailType } from '../types/api/EmailNotification.js';
11
+ import type { BulkDeleteBillsResponse, BulkEmailBillsResponse } from './hooks/bills.js';
12
+ import { type QueryPersistOptions } from './persist.js';
13
13
  export interface TrackEmailOptions {
14
14
  emailType?: EmailType;
15
15
  requestId?: string;
@@ -30,7 +30,7 @@ export interface AvroQueryClientConfig {
30
30
  /** Keep large query namespaces on-device across reloads (see persist.ts). */
31
31
  persistence?: QueryPersistOptions;
32
32
  }
33
- declare module '../client/QueryClient' {
33
+ declare module './QueryClient.js' {
34
34
  interface AvroQueryClient {
35
35
  _xhr<T>(method: string, path: string, body: any, cancelToken?: CancelToken, headers?: Record<string, string>, isIdempotent?: boolean, retryCount?: number, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
36
36
  _fetch<T>(method: string, path: string, body: any, cancelToken?: CancelToken, headers?: Record<string, string>, isIdempotent?: boolean, retryCount?: number): Promise<T>;
@@ -249,6 +249,10 @@ declare module '../client/QueryClient' {
249
249
  useGetAvro(): UseQueryResult<Avro, StandardError>;
250
250
  useGetStorageAnalytics(): UseQueryResult<StorageAnalytics, StandardError>;
251
251
  useGetErrorLog(limit?: number): UseQueryResult<ErrorLogEntry[], StandardError>;
252
+ useGetPerformanceMetrics(options?: {
253
+ limit?: number;
254
+ refetchInterval?: number;
255
+ }): UseQueryResult<PerformanceMetrics, StandardError>;
252
256
  useClearErrorLog(): ReturnType<typeof useMutation<{
253
257
  msg: string;
254
258
  cleared: number;
@@ -694,6 +698,8 @@ export declare class AvroQueryClient {
694
698
  private _applier;
695
699
  private _companyVersions;
696
700
  private _persister;
701
+ private _presencePending;
702
+ private _presenceTimer;
697
703
  private _restored;
698
704
  private _emailTracking;
699
705
  private _emailListenersInit;
@@ -1,12 +1,12 @@
1
1
  import io from 'socket.io-client';
2
2
  import { useMutation, useQueryClient, } from '@tanstack/react-query';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
- import { fetchCensusFeatures } from '../census';
5
- import { LoginResponse, } from '../types/api';
6
- import { AuthState } from '../types/auth';
7
- import { StandardError } from '../types/error';
8
- import { ChangeApplier, fallbackInvalidate, patchMember, patchMemberLocation, patchTeamLocation, } from '../client/realtime';
9
- import { QueryPersister } from '../client/persist';
4
+ import { fetchCensusFeatures } from '../census.js';
5
+ import { LoginResponse, } from '../types/api.js';
6
+ import { AuthState } from '../types/auth.js';
7
+ import { StandardError } from '../types/error.js';
8
+ import { ChangeApplier, fallbackInvalidate, patchMember, patchMemberLocation, patchTeamLocation, } from './realtime.js';
9
+ import { QueryPersister } from './persist.js';
10
10
  export class AvroQueryClient {
11
11
  constructor(config) {
12
12
  this._authState = AuthState.UNKNOWN;
@@ -18,6 +18,8 @@ export class AvroQueryClient {
18
18
  this._applier = null;
19
19
  this._companyVersions = new Map();
20
20
  this._persister = null;
21
+ this._presencePending = new Set();
22
+ this._presenceTimer = null;
21
23
  this._restored = null;
22
24
  this._emailTracking = new Map();
23
25
  this._emailListenersInit = false;
@@ -143,34 +145,58 @@ export class AvroQueryClient {
143
145
  if (data?.company_id && data.company_id === this.companyId)
144
146
  this.joinCompanyRoom();
145
147
  });
146
- // Presence names the member that changed; fetch and patch that
147
- // one instead of re-downloading every member for every client.
148
+ // Presence names the member that changed; coalesce a burst of
149
+ // flips (mobile sockets cycle constantly) into one bulk fetch
150
+ // and patch those members instead of re-downloading every
151
+ // member once per flip on every connected client.
152
+ const PRESENCE_COALESCE_MS = 500;
153
+ // Stale-mark only: an active refetch here turned backend
154
+ // trouble into a full-list refetch storm (every failing
155
+ // presence fetch scheduled a 400KB+ list download). The next
156
+ // mount/focus or realtime change refetches instead.
157
+ const markMembersStale = () => queryClient.invalidateQueries({
158
+ queryKey: ['users', 'company'],
159
+ refetchType: 'none',
160
+ });
148
161
  on('update_presence', (data) => {
149
162
  const userId = data?.user_id;
150
163
  if (!userId || !this.companyId) {
151
- queryClient.invalidateQueries({ queryKey: ['users', 'company'] });
164
+ markMembersStale();
152
165
  return;
153
166
  }
154
- this.post({
155
- path: `/company/${this.companyId}/users`,
156
- data: JSON.stringify({ user_ids: [userId] }),
157
- headers: { 'Content-Type': 'application/json' },
158
- })
159
- .then((members) => {
160
- const member = Array.isArray(members) ? members[0] : undefined;
161
- if (member)
162
- patchMember(queryClient, member);
163
- else
164
- queryClient.invalidateQueries({ queryKey: ['users', 'company'] });
165
- })
166
- .catch(() => {
167
- queryClient.invalidateQueries({ queryKey: ['users', 'company'] });
168
- });
167
+ this._presencePending.add(userId);
168
+ if (this._presenceTimer)
169
+ return;
170
+ this._presenceTimer = setTimeout(() => {
171
+ this._presenceTimer = null;
172
+ const userIds = [...this._presencePending];
173
+ this._presencePending.clear();
174
+ if (!this.companyId || userIds.length === 0)
175
+ return;
176
+ this.post({
177
+ path: `/company/${this.companyId}/users`,
178
+ data: JSON.stringify({ user_ids: userIds }),
179
+ headers: { 'Content-Type': 'application/json' },
180
+ })
181
+ .then((members) => {
182
+ if (!Array.isArray(members)) {
183
+ markMembersStale();
184
+ return;
185
+ }
186
+ for (const member of members)
187
+ patchMember(queryClient, member);
188
+ })
189
+ .catch(markMembersStale);
190
+ }, PRESENCE_COALESCE_MS);
169
191
  });
170
192
  on('location_update', (data) => {
171
193
  if (!data || typeof data.latitude !== 'number') {
172
- queryClient.invalidateQueries({ queryKey: ['teams'] });
173
- queryClient.invalidateQueries({ queryKey: ['users', 'company'] });
194
+ // Malformed ping: stale-mark, don't actively refetch.
195
+ queryClient.invalidateQueries({
196
+ queryKey: ['teams'],
197
+ refetchType: 'none',
198
+ });
199
+ markMembersStale();
174
200
  return;
175
201
  }
176
202
  patchTeamLocation(queryClient, data);
@@ -197,6 +223,11 @@ export class AvroQueryClient {
197
223
  this._socketInvalidationCleanup = () => {
198
224
  for (const { event, handler } of handlers)
199
225
  this.socket.off(event, handler);
226
+ if (this._presenceTimer) {
227
+ clearTimeout(this._presenceTimer);
228
+ this._presenceTimer = null;
229
+ }
230
+ this._presencePending.clear();
200
231
  applier.dispose();
201
232
  this._applier = null;
202
233
  if (this.socket.connected && this.companyId) {
@@ -1,7 +1,7 @@
1
- import { AvroQueryClient } from '../../client/QueryClient';
2
- import { StandardError } from '../../types/error';
3
- import { AuthState } from '../../types/auth';
4
- import { AVRO_JS_VERSION } from '../../version';
1
+ import { AvroQueryClient } from '../QueryClient.js';
2
+ import { StandardError } from '../../types/error.js';
3
+ import { AuthState } from '../../types/auth.js';
4
+ import { AVRO_JS_VERSION } from '../../version.js';
5
5
  AvroQueryClient.prototype._fetch = async function (method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount = 0) {
6
6
  const checkCancelled = () => {
7
7
  try {
@@ -1,4 +1,4 @@
1
- import { AvroQueryClient } from '../../client/QueryClient';
1
+ import { AvroQueryClient } from '../QueryClient.js';
2
2
  AvroQueryClient.prototype.getDelay = function (strategy, attempt) {
3
3
  if (typeof strategy === 'function') {
4
4
  return strategy(attempt);
@@ -1,7 +1,7 @@
1
- import { AvroQueryClient } from '../../client/QueryClient';
2
- import { StandardError } from '../../types/error';
3
- import { AuthState } from '../../types/auth';
4
- import { AVRO_JS_VERSION } from '../../version';
1
+ import { AvroQueryClient } from '../QueryClient.js';
2
+ import { StandardError } from '../../types/error.js';
3
+ import { AuthState } from '../../types/auth.js';
4
+ import { AVRO_JS_VERSION } from '../../version.js';
5
5
  AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount, progressUpdateCallback) {
6
6
  const maxRetries = retryCount ?? this.config.maxRetries;
7
7
  const checkCancelled = () => {
@@ -1,6 +1,6 @@
1
1
  import { keepPreviousData, useQuery } from '@tanstack/react-query';
2
2
  import { useEffect, useState } from 'react';
3
- import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { AvroQueryClient } from '../QueryClient.js';
4
4
  const useDebouncedValue = (value, delayMs) => {
5
5
  const [debounced, setDebounced] = useState(value);
6
6
  useEffect(() => {
@@ -1,5 +1,5 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  AvroQueryClient.prototype.useGetAnalytics = function () {
4
4
  return useQuery({
5
5
  queryKey: ['analytics'],
@@ -1,5 +1,5 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  const buildQuery = (params) => {
4
4
  const search = new URLSearchParams();
5
5
  if (params?.q)
@@ -1,5 +1,5 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  AvroQueryClient.prototype.useGetAvro = function () {
4
4
  return useQuery({
5
5
  queryKey: ['avro'],
@@ -24,6 +24,14 @@ AvroQueryClient.prototype.useGetErrorLog = function (limit = 200) {
24
24
  },
25
25
  });
26
26
  };
27
+ AvroQueryClient.prototype.useGetPerformanceMetrics = function ({ limit = 360, refetchInterval, } = {}) {
28
+ return useQuery({
29
+ queryKey: ['avro', 'performance', limit],
30
+ queryFn: () => this.get({ path: `/avro/performance?limit=${limit}` }),
31
+ staleTime: 0,
32
+ refetchInterval,
33
+ });
34
+ };
27
35
  AvroQueryClient.prototype.useClearErrorLog = function () {
28
36
  const queryClient = this.getQueryClient();
29
37
  return useMutation({
@@ -1,7 +1,7 @@
1
1
  import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
4
- import { Bill } from '../../types/api';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
+ import { Bill } from '../../types/api.js';
5
5
  AvroQueryClient.prototype.useGetBills = function (body) {
6
6
  const queryClient = this.getQueryClient();
7
7
  const result = useInfiniteQuery({
@@ -1,5 +1,5 @@
1
1
  import { useQuery, useMutation } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  AvroQueryClient.prototype.useCreateCatalogItem = function () {
4
4
  const queryClient = this.getQueryClient();
5
5
  return useMutation({
@@ -1,6 +1,6 @@
1
1
  import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useGetChats = function (body) {
5
5
  const queryClient = this.getQueryClient();
6
6
  const result = useInfiniteQuery({
@@ -1,5 +1,5 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  /**
4
4
  * Refresh the caches a check-in mutation touches. Socket events cover
5
5
  * connected clients, but the raw helpers run headless (background
@@ -1,7 +1,7 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { StandardError } from '../../types/error';
4
- import { AuthState } from '../../types/auth';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { StandardError } from '../../types/error.js';
4
+ import { AuthState } from '../../types/auth.js';
5
5
  AvroQueryClient.prototype.useGetCompanies = function (options = {}) {
6
6
  return useQuery({
7
7
  queryKey: ['/company/list'],
@@ -1,5 +1,5 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  AvroQueryClient.prototype.useDevices = function () {
4
4
  return useQuery({
5
5
  queryKey: ['devices'],
@@ -1,4 +1,4 @@
1
- import type { EmailFailedPayload, EmailType } from '../../types/api/EmailNotification';
1
+ import type { EmailFailedPayload, EmailType } from '../../types/api/EmailNotification.js';
2
2
  export type EmailResultStatus = 'succeeded' | 'failed' | 'timeout';
3
3
  export interface EmailResult {
4
4
  requestId: string;
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useRef, useState } from 'react';
2
- import { useAvroQueryClient } from '../../client/AvroQueryClientProvider';
2
+ import { useAvroQueryClient } from '../AvroQueryClientProvider.js';
3
3
  export function useEmailStatus(options = {}) {
4
4
  const { timeout = 30000 } = options;
5
5
  const client = useAvroQueryClient();
@@ -1,7 +1,7 @@
1
1
  import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys, matchesList } from '../../client/realtime';
4
- import { constructEvent, DelayEvent, Job, LineItemStatus, } from '../../types/api';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys, matchesList } from '../realtime.js';
4
+ import { constructEvent, DelayEvent, Job, LineItemStatus, } from '../../types/api.js';
5
5
  const isJobsQuery = (q) => q.queryKey[0] === 'jobs';
6
6
  const isEventsQuery = (q) => q.queryKey[0] === 'events';
7
7
  const isEventsQueryFor = (item) => (q) => q.queryKey[0] === 'events' && matchesList('event', q.queryKey, item) === 'match';
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useGetGroups = function (body, total, onProgress) {
5
5
  return useQuery({
6
6
  queryKey: keys.list('groups', this.companyId, {
@@ -1,7 +1,7 @@
1
1
  import { useMutation, useQuery, useInfiniteQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys, constructJob } from '../../client/realtime';
4
- import { Job } from '../../types/api';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys, constructJob } from '../realtime.js';
4
+ import { Job } from '../../types/api.js';
5
5
  AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
6
6
  const client = queryClient ?? this.peekQueryClient();
7
7
  if (!client) {
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useGetLabels = function (body, total, onProgress) {
5
5
  return useQuery({
6
6
  queryKey: keys.list('labels', this.companyId, {
@@ -1,6 +1,6 @@
1
1
  import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useGetMessages = function (chatId, body) {
5
5
  const queryClient = this.getQueryClient();
6
6
  const result = useInfiniteQuery({
@@ -1,7 +1,7 @@
1
1
  import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
4
- import { LineItemStatus } from '../../types/api';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
+ import { LineItemStatus } from '../../types/api.js';
5
5
  AvroQueryClient.prototype.useGetMonths = function (body) {
6
6
  const queryClient = this.getQueryClient();
7
7
  const result = useInfiniteQuery({
@@ -1,6 +1,6 @@
1
1
  import { useInfiniteQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useGetPayouts = function (body) {
5
5
  const queryClient = this.getQueryClient();
6
6
  const result = useInfiniteQuery({
@@ -1,5 +1,5 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  AvroQueryClient.prototype.useGetPlans = function (code) {
4
4
  return useQuery({
5
5
  queryKey: ['plans', code],
@@ -1,7 +1,7 @@
1
1
  import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
4
- import { LineItemStatus } from '../../types/api';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
+ import { LineItemStatus } from '../../types/api.js';
5
5
  AvroQueryClient.prototype.useGetPrepayments = function (body) {
6
6
  const queryClient = this.getQueryClient();
7
7
  const result = useInfiniteQuery({
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { Task } from '../../types/api/Task';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { Task } from '../../types/api/Task.js';
4
4
  AvroQueryClient.prototype.useCreateProposal = function () {
5
5
  const queryClient = this.getQueryClient();
6
6
  return useMutation({
@@ -1,5 +1,5 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  AvroQueryClient.prototype.useGetRoot = function () {
4
4
  return useQuery({
5
5
  queryKey: ['health'],
@@ -1,7 +1,7 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
4
- import { Route } from '../../types/api';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
+ import { Route } from '../../types/api.js';
5
5
  const dedupeJobTasks = (payload) => payload.jobs
6
6
  ? {
7
7
  ...payload,
@@ -1,7 +1,7 @@
1
1
  import { useMutation, useQuery, useInfiniteQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys, isListKey } from '../../client/realtime';
4
- import { Session } from '../../types/api';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys, isListKey } from '../realtime.js';
4
+ import { Session } from '../../types/api.js';
5
5
  const NS = 'sessions';
6
6
  function listFilters(body) {
7
7
  return {
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useCreateSkill = function () {
5
5
  const queryClient = this.getQueryClient();
6
6
  return useMutation({
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useGetTeams = function (body, total, onProgress) {
5
5
  return useQuery({
6
6
  queryKey: keys.list('teams', this.companyId, {
@@ -1,5 +1,5 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
3
  AvroQueryClient.prototype.useGetCompanyTimecards = function (params = {}) {
4
4
  const companyId = params.companyId ?? this.companyId;
5
5
  return useQuery({
@@ -1,7 +1,7 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { StandardError } from '../../types/error';
4
- import { AuthState } from '../../types/auth';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { StandardError } from '../../types/error.js';
4
+ import { AuthState } from '../../types/auth.js';
5
5
  AvroQueryClient.prototype.useGetUser = function (userId) {
6
6
  return useQuery({
7
7
  queryKey: ['users', userId],
@@ -188,5 +188,9 @@ AvroQueryClient.prototype.useGetCompanyUsers = function (body = {}) {
188
188
  headers: { 'Content-Type': 'application/json' },
189
189
  }),
190
190
  enabled: Boolean(this.companyId) && (body.enabled ?? true),
191
+ // Realtime `changes` / presence patches keep this list current;
192
+ // without a staleTime every mount and window focus re-fetched
193
+ // the full member payload on every consumer.
194
+ staleTime: 30000,
191
195
  });
192
196
  };
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
- import { AvroQueryClient } from '../../client/QueryClient';
3
- import { keys } from '../../client/realtime';
2
+ import { AvroQueryClient } from '../QueryClient.js';
3
+ import { keys } from '../realtime.js';
4
4
  AvroQueryClient.prototype.useCreateWaiver = function () {
5
5
  const queryClient = this.getQueryClient();
6
6
  return useMutation({
@@ -1,6 +1,6 @@
1
1
  import { dehydrate, hydrate } from '@tanstack/react-query';
2
- import { constructJob } from '../client/realtime';
3
- import { Route } from '../types/api/Route';
2
+ import { constructJob } from './realtime.js';
3
+ import { Route } from '../types/api/Route.js';
4
4
  export class MemoryKeyValueStore {
5
5
  constructor() {
6
6
  this.data = new Map();
@@ -5,8 +5,8 @@
5
5
  * detail, `keys.list/keys.infinite(ns, scope, filters)` for lists.
6
6
  */
7
7
  import { QueryClient } from '@tanstack/react-query';
8
- import type { AvroQueryClient } from '../client/QueryClient';
9
- import { Job } from '../types/api';
8
+ import type { AvroQueryClient } from './QueryClient.js';
9
+ import { Job } from '../types/api.js';
10
10
  export type Filters = Record<string, unknown>;
11
11
  export declare const keys: {
12
12
  detail: (ns: string, id: string) => readonly [string, string];