@go-avro/avro-js 0.0.2-beta.115 → 0.0.2-beta.117

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>;
@@ -196,10 +196,11 @@ export class AvroQueryClient {
196
196
  },
197
197
  onSettled: () => {
198
198
  this._isAuthenticated = false;
199
+ this.clearCache();
199
200
  queryClient.invalidateQueries();
200
201
  },
201
202
  onError: (err) => {
202
- this.config.authManager.clearCache();
203
+ this.clearCache();
203
204
  console.error('Logout failed:', err);
204
205
  throw new StandardError(500, 'Logout failed');
205
206
  }
@@ -14,6 +14,23 @@ 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
+ if (!this.companyId) {
22
+ const companyList = await this.get(`/company/list`);
23
+ if (companyList.length > 0) {
24
+ this.companyId = companyList[0].id;
25
+ }
26
+ else {
27
+ throw new Error("No company ID set and no companies available");
28
+ }
29
+ }
30
+ return this.get(`/company/${this.companyId}`);
31
+ },
32
+ });
33
+ };
17
34
  AvroQueryClient.prototype.useCreateCompany = function () {
18
35
  const queryClient = useQueryClient();
19
36
  return useMutation({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.115",
3
+ "version": "0.0.2-beta.117",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",