@go-avro/avro-js 0.1.6 → 0.1.7
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/auth/AuthManager.d.ts +2 -2
- package/dist/auth/AuthManager.js +2 -2
- package/dist/auth/storage.d.ts +1 -1
- package/dist/billing/fees.d.ts +1 -1
- package/dist/billing/fees.js +1 -1
- package/dist/census.d.ts +1 -1
- package/dist/client/AvroQueryClientProvider.d.ts +1 -1
- package/dist/client/QueryClient.d.ts +17 -11
- package/dist/client/QueryClient.js +57 -26
- package/dist/client/core/fetch.js +4 -4
- package/dist/client/core/utils.js +1 -1
- package/dist/client/core/xhr.js +4 -4
- package/dist/client/hooks/address.js +1 -1
- package/dist/client/hooks/analytics.js +1 -1
- package/dist/client/hooks/audit.js +1 -1
- package/dist/client/hooks/avro.js +9 -1
- package/dist/client/hooks/bills.js +3 -3
- package/dist/client/hooks/catalog_items.js +1 -1
- package/dist/client/hooks/chats.js +2 -2
- package/dist/client/hooks/checkins.js +1 -1
- package/dist/client/hooks/companies.js +3 -3
- package/dist/client/hooks/devices.js +1 -1
- package/dist/client/hooks/email.d.ts +1 -1
- package/dist/client/hooks/email.js +1 -1
- package/dist/client/hooks/events.js +3 -3
- package/dist/client/hooks/groups.js +2 -2
- package/dist/client/hooks/jobs.js +3 -3
- package/dist/client/hooks/labels.js +2 -2
- package/dist/client/hooks/messages.js +2 -2
- package/dist/client/hooks/months.js +3 -3
- package/dist/client/hooks/payouts.js +2 -2
- package/dist/client/hooks/plans.js +1 -1
- package/dist/client/hooks/prepayments.js +3 -3
- package/dist/client/hooks/proposal.js +2 -2
- package/dist/client/hooks/root.js +1 -1
- package/dist/client/hooks/routes.js +3 -3
- package/dist/client/hooks/sessions.js +3 -3
- package/dist/client/hooks/skills.js +2 -2
- package/dist/client/hooks/teams.js +2 -2
- package/dist/client/hooks/timecards.js +1 -1
- package/dist/client/hooks/users.js +7 -3
- package/dist/client/hooks/waivers.js +2 -2
- package/dist/client/persist.js +2 -2
- package/dist/client/realtime.d.ts +2 -2
- package/dist/client/realtime.js +4 -2
- package/dist/index.d.ts +52 -52
- package/dist/index.js +47 -47
- package/dist/presence.d.ts +1 -1
- package/dist/types/api/AdditionalCharge.d.ts +1 -1
- package/dist/types/api/Avro.d.ts +72 -1
- package/dist/types/api/Bill.d.ts +8 -8
- package/dist/types/api/Bill.js +1 -1
- package/dist/types/api/BillUser.d.ts +1 -1
- package/dist/types/api/CatalogItem.d.ts +1 -1
- package/dist/types/api/Chat.d.ts +2 -2
- package/dist/types/api/Company.d.ts +11 -11
- package/dist/types/api/CustomLineItem.d.ts +1 -1
- package/dist/types/api/DelayEvent.d.ts +2 -2
- package/dist/types/api/DelayEvent.js +1 -1
- package/dist/types/api/Device.d.ts +2 -2
- package/dist/types/api/Email.d.ts +1 -1
- package/dist/types/api/Group.d.ts +1 -1
- package/dist/types/api/Job.d.ts +7 -7
- package/dist/types/api/Job.js +2 -2
- package/dist/types/api/LineItem.d.ts +1 -1
- package/dist/types/api/MemberState.d.ts +1 -1
- package/dist/types/api/Message.d.ts +1 -1
- package/dist/types/api/PaymentMethod.d.ts +1 -1
- package/dist/types/api/Payout.d.ts +1 -1
- package/dist/types/api/Prepayment.d.ts +2 -2
- package/dist/types/api/Prepayment.js +1 -1
- package/dist/types/api/ProcessingFeeLineItem.d.ts +1 -1
- package/dist/types/api/Route.d.ts +3 -3
- package/dist/types/api/Route.js +1 -1
- package/dist/types/api/RouteJob.d.ts +1 -1
- package/dist/types/api/ServiceMonth.d.ts +1 -1
- package/dist/types/api/Session.d.ts +2 -2
- package/dist/types/api/Task.d.ts +6 -6
- package/dist/types/api/Task.js +1 -1
- package/dist/types/api/Timecard.d.ts +1 -1
- package/dist/types/api/User.d.ts +6 -6
- package/dist/types/api/UserCompanyAssociation.d.ts +2 -2
- package/dist/types/api/_Event.d.ts +4 -4
- package/dist/types/api/_Event.js +1 -1
- package/dist/types/api.d.ts +49 -49
- package/dist/types/api.js +47 -47
- package/dist/types/cache.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- 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;
|
package/dist/auth/AuthManager.js
CHANGED
|
@@ -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 = [];
|
package/dist/auth/storage.d.ts
CHANGED
package/dist/billing/fees.d.ts
CHANGED
|
@@ -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;
|
package/dist/billing/fees.js
CHANGED
package/dist/census.d.ts
CHANGED
|
@@ -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 '
|
|
12
|
-
import { type QueryPersistOptions } from '
|
|
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 '
|
|
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 '
|
|
9
|
-
import { QueryPersister } from '
|
|
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;
|
|
147
|
-
//
|
|
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
|
-
|
|
164
|
+
markMembersStale();
|
|
152
165
|
return;
|
|
153
166
|
}
|
|
154
|
-
this.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
173
|
-
queryClient.invalidateQueries({
|
|
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 '
|
|
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 {
|
package/dist/client/core/xhr.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AvroQueryClient } from '
|
|
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 '
|
|
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 '
|
|
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 { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { AvroQueryClient } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
3
|
-
import { keys, matchesList } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
3
|
-
import { keys, constructJob } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
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,7 +1,7 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { AvroQueryClient } from '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
3
|
-
import { keys, isListKey } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
3
|
-
import { keys } from '
|
|
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({
|
package/dist/client/persist.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dehydrate, hydrate } from '@tanstack/react-query';
|
|
2
|
-
import { constructJob } from '
|
|
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 '
|
|
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];
|