@go-avro/avro-js 0.0.2-beta.114 → 0.0.2-beta.116
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.
|
@@ -94,6 +94,7 @@ declare module '../client/QueryClient' {
|
|
|
94
94
|
periods: number[][];
|
|
95
95
|
}): UseQueryResult<EventInsightData[], StandardError>;
|
|
96
96
|
useGetCompany(companyId: string): UseQueryResult<Company, StandardError>;
|
|
97
|
+
useGetCurrentCompany(): UseQueryResult<Company, StandardError>;
|
|
97
98
|
useGetJob(jobId: string): UseQueryResult<Job, StandardError>;
|
|
98
99
|
useGetEvent(eventId: string): UseQueryResult<_Event, StandardError>;
|
|
99
100
|
useGetUser(userId: string): UseQueryResult<User, StandardError>;
|
|
@@ -312,7 +313,7 @@ export declare class AvroQueryClient {
|
|
|
312
313
|
}>>;
|
|
313
314
|
setTokens(tokens: Tokens): Promise<void>;
|
|
314
315
|
setCache(data: Partial<CacheData>): Promise<void>;
|
|
315
|
-
getCache(key
|
|
316
|
+
getCache(key?: keyof CacheData | undefined): Promise<CacheData | string | null>;
|
|
316
317
|
setCompanyId(companyId: string): Promise<void[]>;
|
|
317
318
|
clearCache(): Promise<void>;
|
|
318
319
|
isAuthenticated(): boolean;
|
|
@@ -145,6 +145,7 @@ export class AvroQueryClient {
|
|
|
145
145
|
}
|
|
146
146
|
throw new StandardError(401, 'Invalid Google login response');
|
|
147
147
|
}
|
|
148
|
+
this._isAuthenticated = true;
|
|
148
149
|
this.socket.auth = { token: resp.access_token };
|
|
149
150
|
if (!this.socket.connected) {
|
|
150
151
|
this.socket.connect();
|
|
@@ -195,10 +196,11 @@ export class AvroQueryClient {
|
|
|
195
196
|
},
|
|
196
197
|
onSettled: () => {
|
|
197
198
|
this._isAuthenticated = false;
|
|
199
|
+
this.clearCache();
|
|
198
200
|
queryClient.invalidateQueries();
|
|
199
201
|
},
|
|
200
202
|
onError: (err) => {
|
|
201
|
-
this.
|
|
203
|
+
this.clearCache();
|
|
202
204
|
console.error('Logout failed:', err);
|
|
203
205
|
throw new StandardError(500, 'Logout failed');
|
|
204
206
|
}
|
|
@@ -220,7 +222,7 @@ export class AvroQueryClient {
|
|
|
220
222
|
})
|
|
221
223
|
.catch(err => {
|
|
222
224
|
console.error('Failed to fetch jobs:', err);
|
|
223
|
-
throw new StandardError(500,
|
|
225
|
+
throw new StandardError(500, `Failed to fetch jobs: ${err.message ?? err}`);
|
|
224
226
|
});
|
|
225
227
|
}
|
|
226
228
|
fetchChats(body = {}, cancelToken, headers = {}) {
|
|
@@ -14,6 +14,24 @@ AvroQueryClient.prototype.useGetCompany = function (companyId) {
|
|
|
14
14
|
enabled: Boolean(companyId),
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
+
AvroQueryClient.prototype.useGetCurrentCompany = function () {
|
|
18
|
+
return useQuery({
|
|
19
|
+
queryKey: ['company', 'current'],
|
|
20
|
+
queryFn: async () => {
|
|
21
|
+
let companyId = this.companyId;
|
|
22
|
+
if (!companyId) {
|
|
23
|
+
const companyList = await this.get(`/company/list`);
|
|
24
|
+
if (companyList.length > 0) {
|
|
25
|
+
companyId = companyList[0].id;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error("No company ID set and no companies available");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return this.get(`/company/${companyId}`);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
};
|
|
17
35
|
AvroQueryClient.prototype.useCreateCompany = function () {
|
|
18
36
|
const queryClient = useQueryClient();
|
|
19
37
|
return useMutation({
|