@go-avro/avro-js 0.0.94 → 0.0.96
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/client/QueryClient.d.ts +12 -1
- package/dist/client/QueryClient.js +17 -0
- package/dist/client/hooks/avro.js +27 -1
- package/dist/types/api/Avro.d.ts +56 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -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';
|
|
4
|
-
import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, 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, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
|
|
4
|
+
import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, 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, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
|
|
5
5
|
import { AuthState, Tokens } from '../types/auth';
|
|
6
6
|
import { CancelToken, ClientId, RetryStrategy } from '../types/client';
|
|
7
7
|
import { StandardError } from '../types/error';
|
|
@@ -235,6 +235,12 @@ declare module '../client/QueryClient' {
|
|
|
235
235
|
}): UseQueryResult<Timecard[], StandardError>;
|
|
236
236
|
useGetTimecard(timecardId?: string, enabled?: boolean): UseQueryResult<Timecard, StandardError>;
|
|
237
237
|
useGetAvro(): UseQueryResult<Avro, StandardError>;
|
|
238
|
+
useGetStorageAnalytics(): UseQueryResult<StorageAnalytics, StandardError>;
|
|
239
|
+
useGetErrorLog(limit?: number): UseQueryResult<ErrorLogEntry[], StandardError>;
|
|
240
|
+
useClearErrorLog(): ReturnType<typeof useMutation<{
|
|
241
|
+
msg: string;
|
|
242
|
+
cleared: number;
|
|
243
|
+
}, StandardError, void>>;
|
|
238
244
|
useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
|
|
239
245
|
useReviewProposal(proposal_id: string): ReturnType<typeof useMutation<{
|
|
240
246
|
msg: string;
|
|
@@ -682,6 +688,11 @@ export declare class AvroQueryClient {
|
|
|
682
688
|
headers?: Record<string, string>;
|
|
683
689
|
progressUpdateCallback?: (loaded: number, total: number) => void;
|
|
684
690
|
}): Promise<T>;
|
|
691
|
+
/**
|
|
692
|
+
* Report a client-side crash or error to the admin error log.
|
|
693
|
+
* Fire-and-forget: never throws, so it is safe inside error handlers.
|
|
694
|
+
*/
|
|
695
|
+
reportClientError(report: ClientErrorReport): Promise<void>;
|
|
685
696
|
post<T>({ path, data, cancelToken, headers, progressUpdateCallback, maxRetries, }: {
|
|
686
697
|
path: string;
|
|
687
698
|
data?: any;
|
|
@@ -571,6 +571,23 @@ export class AvroQueryClient {
|
|
|
571
571
|
get({ path, cancelToken, headers, progressUpdateCallback, }) {
|
|
572
572
|
return this._xhr('GET', path, null, cancelToken, headers, true, this.config.maxRetries, progressUpdateCallback);
|
|
573
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* Report a client-side crash or error to the admin error log.
|
|
576
|
+
* Fire-and-forget: never throws, so it is safe inside error handlers.
|
|
577
|
+
*/
|
|
578
|
+
async reportClientError(report) {
|
|
579
|
+
try {
|
|
580
|
+
await this.post({
|
|
581
|
+
path: '/client/error',
|
|
582
|
+
data: JSON.stringify(report),
|
|
583
|
+
headers: { 'Content-Type': 'application/json' },
|
|
584
|
+
maxRetries: 0,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
catch {
|
|
588
|
+
// Reporting must never become a second failure.
|
|
589
|
+
}
|
|
590
|
+
}
|
|
574
591
|
post({ path, data, cancelToken, headers, progressUpdateCallback, maxRetries, }) {
|
|
575
592
|
return this._xhr('POST', path, data, cancelToken, headers, false, maxRetries ?? this.config.maxRetries, progressUpdateCallback);
|
|
576
593
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
1
|
+
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
3
|
AvroQueryClient.prototype.useGetAvro = function () {
|
|
4
4
|
return useQuery({
|
|
@@ -7,3 +7,29 @@ AvroQueryClient.prototype.useGetAvro = function () {
|
|
|
7
7
|
enabled: true,
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
AvroQueryClient.prototype.useGetStorageAnalytics = function () {
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: ['avro', 'storage'],
|
|
13
|
+
queryFn: () => this.get({ path: '/avro/storage' }),
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
AvroQueryClient.prototype.useGetErrorLog = function (limit = 200) {
|
|
17
|
+
return useQuery({
|
|
18
|
+
queryKey: ['avro', 'errors', limit],
|
|
19
|
+
queryFn: async () => {
|
|
20
|
+
const res = await this.get({
|
|
21
|
+
path: `/avro/errors?limit=${limit}`,
|
|
22
|
+
});
|
|
23
|
+
return res.errors;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
AvroQueryClient.prototype.useClearErrorLog = function () {
|
|
28
|
+
const queryClient = this.getQueryClient();
|
|
29
|
+
return useMutation({
|
|
30
|
+
mutationFn: () => this.delete({ path: '/avro/errors' }),
|
|
31
|
+
onSuccess: () => {
|
|
32
|
+
queryClient.invalidateQueries({ queryKey: ['avro', 'errors'] });
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
};
|
package/dist/types/api/Avro.d.ts
CHANGED
|
@@ -9,3 +9,59 @@ export interface Avro {
|
|
|
9
9
|
billing_email_id: string;
|
|
10
10
|
join_email_id: string;
|
|
11
11
|
}
|
|
12
|
+
export interface StorageByType {
|
|
13
|
+
type: string;
|
|
14
|
+
count: number;
|
|
15
|
+
bytes: number;
|
|
16
|
+
}
|
|
17
|
+
export interface StorageByCompany {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
count: number;
|
|
21
|
+
bytes: number;
|
|
22
|
+
}
|
|
23
|
+
export interface StorageAnalytics {
|
|
24
|
+
total_bytes: number;
|
|
25
|
+
by_type: StorageByType[];
|
|
26
|
+
/** Ordered by bytes, largest first. */
|
|
27
|
+
by_company: StorageByCompany[];
|
|
28
|
+
}
|
|
29
|
+
/** A crash or error reported by a client (app or web). */
|
|
30
|
+
export interface ClientErrorReport {
|
|
31
|
+
message: string;
|
|
32
|
+
stack?: string;
|
|
33
|
+
fatal?: boolean;
|
|
34
|
+
platform?: string;
|
|
35
|
+
app_version?: string;
|
|
36
|
+
update_id?: string;
|
|
37
|
+
route?: string;
|
|
38
|
+
extra?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/** One entry in the admin error log (backend errors and client crashes). */
|
|
41
|
+
export interface ErrorLogEntry {
|
|
42
|
+
id: string;
|
|
43
|
+
time: number;
|
|
44
|
+
source: 'backend' | 'app' | 'web' | string;
|
|
45
|
+
status?: number;
|
|
46
|
+
message?: string | null;
|
|
47
|
+
traceback?: string;
|
|
48
|
+
stack?: string;
|
|
49
|
+
fatal?: boolean;
|
|
50
|
+
platform?: string;
|
|
51
|
+
app_version?: string;
|
|
52
|
+
update_id?: string;
|
|
53
|
+
route?: string;
|
|
54
|
+
method?: string;
|
|
55
|
+
path?: string;
|
|
56
|
+
endpoint?: string | null;
|
|
57
|
+
client_id?: string | null;
|
|
58
|
+
client_version?: string | null;
|
|
59
|
+
js_version?: string | null;
|
|
60
|
+
user_agent?: string | null;
|
|
61
|
+
remote_addr?: string | null;
|
|
62
|
+
user?: {
|
|
63
|
+
id: string;
|
|
64
|
+
username: string;
|
|
65
|
+
} | null;
|
|
66
|
+
extra?: Record<string, unknown>;
|
|
67
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "0.0.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "0.0.96";
|
package/dist/version.js
CHANGED