@go-avro/avro-js 0.0.92 → 0.0.94
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 +7 -0
- package/dist/client/QueryClient.js +23 -19
- package/dist/client/hooks/companies.js +12 -3
- package/dist/client/hooks/users.js +12 -1
- package/dist/types/api/DelayEvent.d.ts +1 -1
- package/dist/types/api/DelayEvent.js +1 -1
- package/dist/types/api/Task.d.ts +2 -2
- package/dist/types/api/_Event.d.ts +1 -1
- package/dist/types/api/_Event.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -754,6 +754,13 @@ export declare class AvroQueryClient {
|
|
|
754
754
|
construct?: (raw: any) => any;
|
|
755
755
|
matchesQuery?: (queryKey: readonly unknown[], item: any) => ListQueryMatch;
|
|
756
756
|
}): Promise<any>;
|
|
757
|
+
/**
|
|
758
|
+
* Drop all local auth state without a server round-trip: stored
|
|
759
|
+
* tokens, cached company, query cache, socket, and auth state.
|
|
760
|
+
* The single teardown path for logout, refresh failure, and a
|
|
761
|
+
* server that no longer recognizes our identity.
|
|
762
|
+
*/
|
|
763
|
+
forceLogout(): Promise<void>;
|
|
757
764
|
useLogout(): ReturnType<typeof useMutation<void, StandardError, CancelToken | undefined>>;
|
|
758
765
|
fetchJobs(body?: {
|
|
759
766
|
amt?: number;
|
|
@@ -440,11 +440,7 @@ export class AvroQueryClient {
|
|
|
440
440
|
}
|
|
441
441
|
});
|
|
442
442
|
config.authManager.onTokenRefreshFailed(() => {
|
|
443
|
-
this.
|
|
444
|
-
this.setAuthState(AuthState.UNAUTHENTICATED);
|
|
445
|
-
if (this.socket && this.socket.connected) {
|
|
446
|
-
this.socket.disconnect();
|
|
447
|
-
}
|
|
443
|
+
void this.forceLogout();
|
|
448
444
|
});
|
|
449
445
|
}
|
|
450
446
|
emit(eventName, data) {
|
|
@@ -886,26 +882,34 @@ export class AvroQueryClient {
|
|
|
886
882
|
return undefined;
|
|
887
883
|
}
|
|
888
884
|
}
|
|
885
|
+
/**
|
|
886
|
+
* Drop all local auth state without a server round-trip: stored
|
|
887
|
+
* tokens, cached company, query cache, socket, and auth state.
|
|
888
|
+
* The single teardown path for logout, refresh failure, and a
|
|
889
|
+
* server that no longer recognizes our identity.
|
|
890
|
+
*/
|
|
891
|
+
async forceLogout() {
|
|
892
|
+
await this.clearCache();
|
|
893
|
+
this.setAuthState(AuthState.UNAUTHENTICATED);
|
|
894
|
+
if (this.socket && this.socket.connected) {
|
|
895
|
+
this.socket.disconnect();
|
|
896
|
+
}
|
|
897
|
+
this.getQueryClient().removeQueries();
|
|
898
|
+
}
|
|
889
899
|
useLogout() {
|
|
890
|
-
const queryClient = this.getQueryClient();
|
|
891
900
|
return useMutation({
|
|
892
901
|
mutationFn: async (cancelToken) => {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
902
|
+
try {
|
|
903
|
+
await this.post({
|
|
904
|
+
path: '/logout',
|
|
905
|
+
cancelToken,
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
finally {
|
|
909
|
+
await this.forceLogout();
|
|
900
910
|
}
|
|
901
|
-
},
|
|
902
|
-
onSettled: () => {
|
|
903
|
-
this.clearCache();
|
|
904
|
-
this.setAuthState(AuthState.UNAUTHENTICATED);
|
|
905
|
-
queryClient.removeQueries();
|
|
906
911
|
},
|
|
907
912
|
onError: (err) => {
|
|
908
|
-
this.clearCache();
|
|
909
913
|
console.error('Logout failed:', err);
|
|
910
914
|
throw new StandardError(500, 'Logout failed');
|
|
911
915
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { StandardError } from '../../types/error';
|
|
3
4
|
import { AuthState } from '../../types/auth';
|
|
4
5
|
AvroQueryClient.prototype.useGetCompanies = function (options = {}) {
|
|
5
6
|
return useQuery({
|
|
@@ -47,9 +48,17 @@ AvroQueryClient.prototype.useGetCurrentCompany = function () {
|
|
|
47
48
|
throw new Error('No company ID set and no companies available');
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
try {
|
|
52
|
+
this.company = await this.get({
|
|
53
|
+
path: `/company/${this.companyId}`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
if (err instanceof StandardError && err.status === 404) {
|
|
58
|
+
await this.setCompanyId('');
|
|
59
|
+
}
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
53
62
|
return this.company;
|
|
54
63
|
},
|
|
55
64
|
enabled: this.getAuthState() === AuthState.AUTHENTICATED,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { StandardError } from '../../types/error';
|
|
3
4
|
import { AuthState } from '../../types/auth';
|
|
4
5
|
AvroQueryClient.prototype.useGetUser = function (userId) {
|
|
5
6
|
return useQuery({
|
|
@@ -22,7 +23,17 @@ AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
|
|
|
22
23
|
AvroQueryClient.prototype.useGetSelf = function () {
|
|
23
24
|
return useQuery({
|
|
24
25
|
queryKey: ['user'],
|
|
25
|
-
queryFn: () =>
|
|
26
|
+
queryFn: async () => {
|
|
27
|
+
try {
|
|
28
|
+
return await this.get({ path: `/user` });
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
if (err instanceof StandardError && err.status === 404) {
|
|
32
|
+
await this.forceLogout();
|
|
33
|
+
}
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
26
37
|
enabled: this.getAuthState() === AuthState.AUTHENTICATED,
|
|
27
38
|
});
|
|
28
39
|
};
|
|
@@ -11,7 +11,7 @@ declare module '../../types/api/DelayEvent' {
|
|
|
11
11
|
*
|
|
12
12
|
* Shares the events table/endpoints with service events; the linked
|
|
13
13
|
* tasks are in `tasks`/`task_names`, and `internal_notes`/
|
|
14
|
-
* `external_notes`/`
|
|
14
|
+
* `external_notes`/`images` behave exactly as on a service event.
|
|
15
15
|
*/
|
|
16
16
|
export declare class DelayEvent extends _Event {
|
|
17
17
|
constructor(init?: Partial<DelayEvent>);
|
|
@@ -4,7 +4,7 @@ import { _Event } from '../../types/api/_Event';
|
|
|
4
4
|
*
|
|
5
5
|
* Shares the events table/endpoints with service events; the linked
|
|
6
6
|
* tasks are in `tasks`/`task_names`, and `internal_notes`/
|
|
7
|
-
* `external_notes`/`
|
|
7
|
+
* `external_notes`/`images` behave exactly as on a service event.
|
|
8
8
|
*/
|
|
9
9
|
export class DelayEvent extends _Event {
|
|
10
10
|
constructor(init) {
|
package/dist/types/api/Task.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const TaskStatus: {
|
|
|
15
15
|
export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
|
|
16
16
|
declare module '../../types/api/Task' {
|
|
17
17
|
interface Task {
|
|
18
|
-
|
|
18
|
+
enforce_image_amount: boolean;
|
|
19
19
|
events: _Event[];
|
|
20
20
|
payment_options: PaymentOption[];
|
|
21
21
|
frequency: number;
|
|
@@ -24,7 +24,7 @@ declare module '../../types/api/Task' {
|
|
|
24
24
|
name: string;
|
|
25
25
|
internal_notes: string;
|
|
26
26
|
external_notes: string;
|
|
27
|
-
|
|
27
|
+
image_amt: number;
|
|
28
28
|
images: string[];
|
|
29
29
|
time_created: number;
|
|
30
30
|
time_updated: number | null;
|
package/dist/types/api/_Event.js
CHANGED
|
@@ -8,7 +8,7 @@ export class _Event extends LineItem {
|
|
|
8
8
|
};
|
|
9
9
|
Object.assign(this, init);
|
|
10
10
|
this.breaks = init?.breaks ?? [];
|
|
11
|
-
this.
|
|
11
|
+
this.images = init?.images ?? [];
|
|
12
12
|
this.tasks = init?.tasks ?? [];
|
|
13
13
|
this.task_names = init?.task_names ?? [];
|
|
14
14
|
this.additional_charges = init?.additional_charges ?? [];
|
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.94";
|
package/dist/version.js
CHANGED