@go-avro/avro-js 0.0.97 → 0.0.98

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.
@@ -632,7 +632,7 @@ export class AvroQueryClient {
632
632
  },
633
633
  onError: (err) => {
634
634
  this.config.authManager.clearCache();
635
- throw new StandardError(401, err.message || 'Login failed');
635
+ console.error('Login failed:', err);
636
636
  },
637
637
  });
638
638
  }
@@ -652,7 +652,7 @@ export class AvroQueryClient {
652
652
  queryClient.invalidateQueries();
653
653
  },
654
654
  onError: (err) => {
655
- throw new StandardError(err.status, err.message || 'Request code failed');
655
+ console.error('Request code failed:', err);
656
656
  },
657
657
  });
658
658
  }
@@ -671,7 +671,7 @@ export class AvroQueryClient {
671
671
  queryClient.invalidateQueries();
672
672
  },
673
673
  onError: (err) => {
674
- throw new StandardError(err.status, err.message || 'Update password failed');
674
+ console.error('Update password failed:', err);
675
675
  },
676
676
  });
677
677
  }
@@ -702,7 +702,7 @@ export class AvroQueryClient {
702
702
  },
703
703
  onError: (err) => {
704
704
  this.config.authManager.clearCache();
705
- throw new StandardError(err.status, err.message || 'Google Login failed');
705
+ console.error('Google Login failed:', err);
706
706
  },
707
707
  });
708
708
  }
@@ -733,7 +733,7 @@ export class AvroQueryClient {
733
733
  },
734
734
  onError: (err) => {
735
735
  this.config.authManager.clearCache();
736
- throw new StandardError(err.status, err.message || 'Apple Login failed');
736
+ console.error('Apple Login failed:', err);
737
737
  },
738
738
  });
739
739
  }
@@ -794,7 +794,9 @@ export class AvroQueryClient {
794
794
  return this.config.authManager.isAuthenticated();
795
795
  }
796
796
  getQueryClient() {
797
- return useQueryClient();
797
+ const queryClient = useQueryClient();
798
+ this._queryClient ?? (this._queryClient = queryClient);
799
+ return queryClient;
798
800
  }
799
801
  attachQueryClient(queryClient) {
800
802
  this._queryClient ?? (this._queryClient = queryClient);
@@ -911,7 +913,7 @@ export class AvroQueryClient {
911
913
  if (this.socket && this.socket.connected) {
912
914
  this.socket.disconnect();
913
915
  }
914
- this.getQueryClient().removeQueries();
916
+ this.peekQueryClient()?.removeQueries();
915
917
  }
916
918
  useLogout() {
917
919
  return useMutation({
@@ -922,13 +924,17 @@ export class AvroQueryClient {
922
924
  cancelToken,
923
925
  });
924
926
  }
927
+ catch (err) {
928
+ throw err instanceof StandardError
929
+ ? err
930
+ : new StandardError(500, 'Logout failed');
931
+ }
925
932
  finally {
926
933
  await this.forceLogout();
927
934
  }
928
935
  },
929
936
  onError: (err) => {
930
937
  console.error('Logout failed:', err);
931
- throw new StandardError(500, 'Logout failed');
932
938
  },
933
939
  });
934
940
  }
@@ -2,10 +2,11 @@ import { useMutation, useQuery, useInfiniteQuery } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../../client/QueryClient';
3
3
  import { Job } from '../../types/api';
4
4
  AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
5
- if (!queryClient) {
6
- queryClient = this.getQueryClient();
5
+ const client = queryClient ?? this.peekQueryClient();
6
+ if (!client) {
7
+ return [];
7
8
  }
8
- return queryClient.getQueryData(['jobs', this.companyId, this.company?.num_jobs]) ?? [];
9
+ return client.getQueryData(['jobs', this.companyId, this.company?.num_jobs]) ?? [];
9
10
  };
10
11
  AvroQueryClient.prototype.useGetJobs = function (params) {
11
12
  const queryClient = this.getQueryClient();
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "0.0.97";
1
+ export declare const AVRO_JS_VERSION = "0.0.98";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Regenerated from package.json by the `prebuild` npm hook.
3
- export const AVRO_JS_VERSION = '0.0.97';
3
+ export const AVRO_JS_VERSION = '0.0.98';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",