@go-avro/avro-js 0.0.2-beta.53 → 0.0.2-beta.55

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.
@@ -1,6 +1,7 @@
1
1
  import { InfiniteData, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
2
2
  import { AuthManager } from '../auth/AuthManager';
3
3
  import { _Event, ApiInfo, Bill, Company, Job, LineItem, Route, ServiceMonth, Session, User } from '../types/api';
4
+ import { Tokens } from '../types/auth';
4
5
  import { CancelToken, RetryStrategy } from '../types/client';
5
6
  import { StandardError } from '../types/error';
6
7
  export interface AvroQueryClientConfig {
@@ -93,6 +94,15 @@ declare module '../client/QueryClient' {
93
94
  companyId: string;
94
95
  jobData: Partial<Job>;
95
96
  }>>;
97
+ useCreateSelf(): ReturnType<typeof useMutation<{
98
+ msg: string;
99
+ }, StandardError, {
100
+ username: string;
101
+ name: string;
102
+ email: string;
103
+ password: string;
104
+ phone_number: string;
105
+ }>>;
96
106
  useUpdateEvent(): ReturnType<typeof useMutation<{
97
107
  msg: string;
98
108
  }, StandardError, {
@@ -181,6 +191,8 @@ export declare class AvroQueryClient {
181
191
  username: string;
182
192
  password: string;
183
193
  }, cancelToken?: CancelToken): Promise<Boolean>;
194
+ setTokens(tokens: Tokens): Promise<void>;
195
+ clearTokens(): Promise<void>;
184
196
  logout(cancelToken?: CancelToken): Promise<void>;
185
197
  fetchJobs(companyGuid: string, body?: {
186
198
  amt?: number;
@@ -34,6 +34,12 @@ export class AvroQueryClient {
34
34
  throw new StandardError(401, 'Login failed');
35
35
  });
36
36
  }
37
+ setTokens(tokens) {
38
+ return this.config.authManager.setTokens(tokens);
39
+ }
40
+ clearTokens() {
41
+ return this.config.authManager.clearTokens();
42
+ }
37
43
  logout(cancelToken) {
38
44
  return this._fetch('POST', '/logout', null, cancelToken)
39
45
  .then(() => this.config.authManager.clearTokens())
@@ -14,6 +14,17 @@ AvroQueryClient.prototype.useGetSelf = function () {
14
14
  enabled: Boolean(this),
15
15
  });
16
16
  };
17
+ AvroQueryClient.prototype.useCreateSelf = function () {
18
+ const queryClient = useQueryClient();
19
+ return useMutation({
20
+ mutationFn: async (data) => {
21
+ return this.post('/user', data);
22
+ },
23
+ onSettled: () => {
24
+ queryClient.invalidateQueries({ queryKey: ['user'] });
25
+ },
26
+ });
27
+ };
17
28
  AvroQueryClient.prototype.useDeleteSelf = function () {
18
29
  const queryClient = useQueryClient();
19
30
  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.53",
3
+ "version": "0.0.2-beta.55",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",