@go-avro/avro-js 0.0.8-beta.0 → 0.0.8-beta.2

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.
@@ -164,10 +164,7 @@ declare module '../client/QueryClient' {
164
164
  payment_option_id: string;
165
165
  }[];
166
166
  }>>;
167
- useCreateMessage(chatId: string, body: {
168
- content: string;
169
- sent_at?: number;
170
- }): ReturnType<typeof useMutation<{
167
+ useCreateMessage(chatId: string): ReturnType<typeof useMutation<{
171
168
  id: string;
172
169
  }, StandardError, {
173
170
  content: string;
@@ -478,10 +475,32 @@ export declare class AvroQueryClient {
478
475
  emit(eventName: string, data: unknown): void;
479
476
  on<T>(eventName: string, callback: (data: T) => void): void;
480
477
  off(eventName: string, callback?: Function): void;
481
- get<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
482
- post<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
483
- put<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
484
- delete<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
478
+ get<T>({ path, cancelToken, headers, progressUpdateCallback }: {
479
+ path: string;
480
+ cancelToken?: CancelToken;
481
+ headers?: Record<string, string>;
482
+ progressUpdateCallback?: (loaded: number, total: number) => void;
483
+ }): Promise<T>;
484
+ post<T>({ path, data, cancelToken, headers, progressUpdateCallback }: {
485
+ path: string;
486
+ data?: any;
487
+ cancelToken?: CancelToken;
488
+ headers?: Record<string, string>;
489
+ progressUpdateCallback?: (loaded: number, total: number) => void;
490
+ }): Promise<T>;
491
+ put<T>({ path, data, cancelToken, headers, progressUpdateCallback }: {
492
+ path: string;
493
+ data?: any;
494
+ cancelToken?: CancelToken;
495
+ headers?: Record<string, string>;
496
+ progressUpdateCallback?: (loaded: number, total: number) => void;
497
+ }): Promise<T>;
498
+ delete<T>({ path, cancelToken, headers, progressUpdateCallback }: {
499
+ path: string;
500
+ cancelToken?: CancelToken;
501
+ headers?: Record<string, string>;
502
+ progressUpdateCallback?: (loaded: number, total: number) => void;
503
+ }): Promise<T>;
485
504
  loginSuccess(tokens: Tokens): Promise<void>;
486
505
  useLogin(): ReturnType<typeof useMutation<LoginResponse, StandardError, {
487
506
  username: string;
@@ -70,16 +70,16 @@ export class AvroQueryClient {
70
70
  off(eventName, callback) {
71
71
  this.socket?.off(eventName, callback);
72
72
  }
73
- get(path, cancelToken, headers = {}, progressUpdateCallback) {
73
+ get({ path, cancelToken, headers, progressUpdateCallback }) {
74
74
  return this._xhr('GET', path, null, cancelToken, headers, true, this.config.maxRetries, progressUpdateCallback);
75
75
  }
76
- post(path, data, cancelToken, headers = {}, progressUpdateCallback) {
76
+ post({ path, data, cancelToken, headers, progressUpdateCallback }) {
77
77
  return this._xhr('POST', path, data, cancelToken, headers, false, this.config.maxRetries, progressUpdateCallback);
78
78
  }
79
- put(path, data, cancelToken, headers = {}, progressUpdateCallback) {
79
+ put({ path, data, cancelToken, headers, progressUpdateCallback }) {
80
80
  return this._xhr('PUT', path, data, cancelToken, headers, true, this.config.maxRetries, progressUpdateCallback);
81
81
  }
82
- delete(path, cancelToken, headers = {}, progressUpdateCallback) {
82
+ delete({ path, cancelToken, headers, progressUpdateCallback }) {
83
83
  return this._xhr('DELETE', path, null, cancelToken, headers, false, this.config.maxRetries, progressUpdateCallback);
84
84
  }
85
85
  loginSuccess(tokens) {
@@ -94,7 +94,12 @@ export class AvroQueryClient {
94
94
  const queryClient = this.getQueryClient();
95
95
  return useMutation({
96
96
  mutationFn: async ({ username, password, code, cancelToken }) => {
97
- const resp = await this.post('/login', JSON.stringify({ username, password, code }), cancelToken, { 'Content-Type': 'application/json' });
97
+ const resp = await this.post({
98
+ path: '/login',
99
+ data: JSON.stringify({ username, password, code }),
100
+ cancelToken,
101
+ headers: { 'Content-Type': 'application/json' }
102
+ });
98
103
  if (!resp || !('access_token' in resp)) {
99
104
  if (resp.msg === "TOTP required") {
100
105
  return LoginResponse.NEEDS_TOTP;
@@ -117,7 +122,12 @@ export class AvroQueryClient {
117
122
  const queryClient = this.getQueryClient();
118
123
  return useMutation({
119
124
  mutationFn: async ({ username, email, cancelToken }) => {
120
- const resp = await this.post('/code', JSON.stringify({ username, email }), cancelToken, { 'Content-Type': 'application/json' });
125
+ const resp = await this.post({
126
+ path: '/code',
127
+ data: JSON.stringify({ username, email }),
128
+ cancelToken,
129
+ headers: { 'Content-Type': 'application/json' }
130
+ });
121
131
  return resp;
122
132
  },
123
133
  onSettled: () => {
@@ -132,7 +142,12 @@ export class AvroQueryClient {
132
142
  const queryClient = this.getQueryClient();
133
143
  return useMutation({
134
144
  mutationFn: async ({ username, email, code, newPassword, cancelToken }) => {
135
- await this.post(`/user/${username ?? email}/password`, JSON.stringify({ code, password: newPassword }), cancelToken, { 'Content-Type': 'application/json' });
145
+ await this.post({
146
+ path: `/user/${username ?? email}/password`,
147
+ data: JSON.stringify({ code, password: newPassword }),
148
+ cancelToken,
149
+ headers: { 'Content-Type': 'application/json' }
150
+ });
136
151
  },
137
152
  onSettled: () => {
138
153
  queryClient.invalidateQueries();
@@ -223,7 +238,10 @@ export class AvroQueryClient {
223
238
  const queryClient = this.getQueryClient();
224
239
  return useMutation({
225
240
  mutationFn: async (cancelToken) => {
226
- await this.post('/logout', null, cancelToken);
241
+ await this.post({
242
+ path: '/logout',
243
+ cancelToken
244
+ });
227
245
  await this.config.authManager.clearCache();
228
246
  if (this.socket && this.socket.connected) {
229
247
  this.socket.disconnect();
@@ -510,7 +528,11 @@ export class AvroQueryClient {
510
528
  }
511
529
  sendEmail(emailId, formData, progressUpdateCallback) {
512
530
  try {
513
- return this.post(`/email/${emailId}`, formData, undefined, {}, progressUpdateCallback);
531
+ return this.post({
532
+ path: `/email/${emailId}`,
533
+ data: formData,
534
+ progressUpdateCallback
535
+ });
514
536
  }
515
537
  catch (error) {
516
538
  throw new StandardError(500, `Failed to send email: ${error}`);
@@ -518,7 +540,11 @@ export class AvroQueryClient {
518
540
  }
519
541
  sendBillEmail(billId, body = {}) {
520
542
  try {
521
- return this.post(`/bill/${billId}/email`, JSON.stringify(body), undefined, { 'Content-Type': 'application/json' });
543
+ return this.post({
544
+ path: `/bill/${billId}/email`,
545
+ data: JSON.stringify(body),
546
+ headers: { 'Content-Type': 'application/json' }
547
+ });
522
548
  }
523
549
  catch (error) {
524
550
  throw new StandardError(500, `Failed to send bill email: ${error}`);
@@ -3,23 +3,33 @@ import { AvroQueryClient } from "../../client/QueryClient";
3
3
  AvroQueryClient.prototype.useGetAnalytics = function () {
4
4
  return useQuery({
5
5
  queryKey: ['analytics'],
6
- queryFn: () => this.post('/avro/analytics', null),
6
+ queryFn: () => this.post({
7
+ path: '/avro/analytics',
8
+ }),
7
9
  enabled: true,
8
10
  });
9
11
  };
10
12
  AvroQueryClient.prototype.useFinanceAnalytics = function ({ periods, cumulative }) {
11
13
  return useQuery({
12
14
  queryKey: ['analytics', 'finance', this.companyId, periods, cumulative],
13
- queryFn: () => this.post(`/company/${this.companyId}/analytics/finance`, JSON.stringify({ periods, cumulative }), undefined, {
14
- 'Content-Type': 'application/json',
15
+ queryFn: () => this.post({
16
+ path: `/company/${this.companyId}/analytics/finance`,
17
+ data: JSON.stringify({ periods, cumulative }),
18
+ headers: {
19
+ 'Content-Type': 'application/json',
20
+ }
15
21
  }),
16
22
  });
17
23
  };
18
24
  AvroQueryClient.prototype.useEventAnalytics = function ({ periods }) {
19
25
  return useQuery({
20
26
  queryKey: ['analytics', 'events', this.companyId, periods],
21
- queryFn: () => this.post(`/company/${this.companyId}/analytics/events`, JSON.stringify({ periods }), undefined, {
22
- 'Content-Type': 'application/json',
27
+ queryFn: () => this.post({
28
+ path: `/company/${this.companyId}/analytics/events`,
29
+ data: JSON.stringify({ periods }),
30
+ headers: {
31
+ 'Content-Type': 'application/json',
32
+ }
23
33
  }),
24
34
  enabled: Boolean(this.companyId),
25
35
  });
@@ -3,7 +3,7 @@ import { AvroQueryClient } from "../../client/QueryClient";
3
3
  AvroQueryClient.prototype.useGetAvro = function () {
4
4
  return useQuery({
5
5
  queryKey: ['avro'],
6
- queryFn: () => this.get('/avro'),
6
+ queryFn: () => this.get({ path: '/avro' }),
7
7
  enabled: true,
8
8
  });
9
9
  };
@@ -31,7 +31,7 @@ AvroQueryClient.prototype.useGetBills = function (body) {
31
31
  AvroQueryClient.prototype.useGetBill = function (billId) {
32
32
  return useQuery({
33
33
  queryKey: ['bill', billId],
34
- queryFn: () => this.get(`/bill/${billId}`),
34
+ queryFn: () => this.get({ path: `/bill/${billId}` }),
35
35
  enabled: Boolean(billId),
36
36
  });
37
37
  };
@@ -49,8 +49,12 @@ AvroQueryClient.prototype.useCreateBill = function () {
49
49
  users: data.users,
50
50
  due_date: data.due_date,
51
51
  };
52
- return this.post(`/company/${this.companyId}/bill`, JSON.stringify(body), undefined, {
53
- 'Content-Type': 'application/json',
52
+ return this.post({
53
+ path: `/company/${this.companyId}/bill`,
54
+ data: JSON.stringify(body),
55
+ headers: {
56
+ 'Content-Type': 'application/json',
57
+ }
54
58
  });
55
59
  },
56
60
  onMutate: async () => {
@@ -76,8 +80,12 @@ AvroQueryClient.prototype.useUpdateBill = function () {
76
80
  const queryClient = this.getQueryClient();
77
81
  return useMutation({
78
82
  mutationFn: ({ billId, updates }) => {
79
- return this.put(`/bill/${billId}`, JSON.stringify(updates), undefined, {
80
- "Content-Type": "application/json",
83
+ return this.put({
84
+ path: `/bill/${billId}`,
85
+ data: JSON.stringify(updates),
86
+ headers: {
87
+ "Content-Type": "application/json",
88
+ }
81
89
  });
82
90
  },
83
91
  onMutate: async ({ billId, updates }) => {
@@ -122,7 +130,7 @@ AvroQueryClient.prototype.useDeleteBill = function () {
122
130
  const queryClient = this.getQueryClient();
123
131
  return useMutation({
124
132
  mutationFn: async ({ billId }) => {
125
- return this.delete(`/bill/${billId}`);
133
+ return this.delete({ path: `/bill/${billId}` });
126
134
  },
127
135
  onMutate: async ({ billId }) => {
128
136
  await queryClient.cancelQueries({ queryKey: ['bills'] });
@@ -146,7 +154,9 @@ AvroQueryClient.prototype.useSyncBillToIntuit = function () {
146
154
  const queryClient = this.getQueryClient();
147
155
  return useMutation({
148
156
  mutationFn: async ({ billId }) => {
149
- return this.post(`/company/${this.companyId}/bill/${billId}/intuit/sync`, null);
157
+ return this.post({
158
+ path: `/company/${this.companyId}/bill/${billId}/intuit/sync`,
159
+ });
150
160
  },
151
161
  onMutate: async ({ billId }) => {
152
162
  await queryClient.cancelQueries({ queryKey: ['bill', billId] });
@@ -166,10 +176,16 @@ AvroQueryClient.prototype.useSyncBillToIntuit = function () {
166
176
  });
167
177
  };
168
178
  AvroQueryClient.prototype.generatePDFFromBackend = function ({ billId }) {
169
- return this.get(`/company/${this.companyId}/bill/${billId}/pdf`).then((response) => {
179
+ return this.get({ path: `/company/${this.companyId}/bill/${billId}/pdf` }).then((response) => {
170
180
  return response;
171
181
  });
172
182
  };
173
183
  AvroQueryClient.prototype.sendBillingEmail = async function ({ subject, billId, recipients, }) {
174
- return this.post(`/bill/${billId}/email`, JSON.stringify({ recipients, subject }), undefined, { "Content-Type": "application/json" });
184
+ return this.post({
185
+ path: `/bill/${billId}/email`,
186
+ data: JSON.stringify({ recipients, subject }),
187
+ headers: {
188
+ "Content-Type": "application/json"
189
+ }
190
+ });
175
191
  };
@@ -4,7 +4,13 @@ AvroQueryClient.prototype.useCreateCatalogItem = function () {
4
4
  const queryClient = this.getQueryClient();
5
5
  return useMutation({
6
6
  mutationFn: async ({ data }) => {
7
- return this.post(`/company/${this.companyId}/catalog_item`, JSON.stringify(data), undefined, { 'Content-Type': 'application/json' });
7
+ return this.post({
8
+ path: `/company/${this.companyId}/catalog_item`,
9
+ data: JSON.stringify(data),
10
+ headers: {
11
+ 'Content-Type': 'application/json'
12
+ }
13
+ });
8
14
  },
9
15
  onMutate: async () => {
10
16
  await queryClient.cancelQueries({ queryKey: ['catalog_items', this.companyId] });
@@ -25,8 +31,12 @@ AvroQueryClient.prototype.useUpdateCatalogItem = function () {
25
31
  const queryClient = this.getQueryClient();
26
32
  return useMutation({
27
33
  mutationFn: ({ catalogItemId, data }) => {
28
- return this.put(`/catalog_item/${catalogItemId}`, JSON.stringify(data), undefined, {
29
- "Content-Type": "application/json",
34
+ return this.put({
35
+ path: `/catalog_item/${catalogItemId}`,
36
+ data: JSON.stringify(data),
37
+ headers: {
38
+ "Content-Type": "application/json",
39
+ }
30
40
  });
31
41
  },
32
42
  onMutate: async ({ catalogItemId, data }) => {
@@ -70,7 +80,7 @@ AvroQueryClient.prototype.useUpdateCatalogItem = function () {
70
80
  AvroQueryClient.prototype.useGetCatalogItem = function (catalogItemId) {
71
81
  return useQuery({
72
82
  queryKey: ['catalog_item', catalogItemId],
73
- queryFn: () => this.get(`/catalog_item/${catalogItemId}`),
83
+ queryFn: () => this.get({ path: `/catalog_item/${catalogItemId}` }),
74
84
  enabled: Boolean(catalogItemId),
75
85
  });
76
86
  };
@@ -78,7 +88,7 @@ AvroQueryClient.prototype.useDeleteCatalogItem = function () {
78
88
  const queryClient = this.getQueryClient();
79
89
  return useMutation({
80
90
  mutationFn: async ({ catalogItemId }) => {
81
- return this.delete(`/catalog_item/${catalogItemId}`);
91
+ return this.delete({ path: `/catalog_item/${catalogItemId}` });
82
92
  },
83
93
  onMutate: async ({ catalogItemId }) => {
84
94
  await queryClient.cancelQueries({ queryKey: ['catalog_items'] });
@@ -31,7 +31,7 @@ AvroQueryClient.prototype.useGetChats = function (body) {
31
31
  AvroQueryClient.prototype.useGetChat = function (chatId) {
32
32
  return useQuery({
33
33
  queryKey: ['chat', chatId],
34
- queryFn: () => this.get(`/chat/${chatId}`),
34
+ queryFn: () => this.get({ path: `/chat/${chatId}` }),
35
35
  enabled: Boolean(chatId),
36
36
  });
37
37
  };
@@ -5,7 +5,7 @@ AvroQueryClient.prototype.useGetCompanies = function (options = {}) {
5
5
  return useQuery({
6
6
  queryKey: ['/company/list'],
7
7
  queryFn: () => {
8
- const companiesPromise = this.get(`/company/list`);
8
+ const companiesPromise = this.get({ path: `/company/list` });
9
9
  companiesPromise.then((companies) => {
10
10
  if (!companies.find((c) => c.id === this.companyId) && companies.length > 0) {
11
11
  this.companyId = companies[0].id;
@@ -20,7 +20,7 @@ AvroQueryClient.prototype.useGetCompanies = function (options = {}) {
20
20
  AvroQueryClient.prototype.useGetCompany = function (companyId) {
21
21
  return useQuery({
22
22
  queryKey: ['company', companyId],
23
- queryFn: () => this.get(`/company/${companyId}`),
23
+ queryFn: () => this.get({ path: `/company/${companyId}` }),
24
24
  enabled: Boolean(companyId),
25
25
  });
26
26
  };
@@ -32,7 +32,7 @@ AvroQueryClient.prototype.useGetCurrentCompany = function () {
32
32
  this.companyId = await this.config.authManager.getCompanyId();
33
33
  }
34
34
  if (!this.companyId) {
35
- const companyList = await this.get(`/company/list`);
35
+ const companyList = await this.get({ path: `/company/list` });
36
36
  if (companyList.length > 0) {
37
37
  this.companyId = companyList[0].id;
38
38
  }
@@ -40,7 +40,7 @@ AvroQueryClient.prototype.useGetCurrentCompany = function () {
40
40
  throw new Error("No company ID set and no companies available");
41
41
  }
42
42
  }
43
- this.company = await this.get(`/company/${this.companyId}`);
43
+ this.company = await this.get({ path: `/company/${this.companyId}` });
44
44
  return this.company;
45
45
  },
46
46
  enabled: this.getAuthState() === AuthState.AUTHENTICATED,
@@ -50,7 +50,11 @@ AvroQueryClient.prototype.useCreateCompany = function () {
50
50
  const queryClient = this.getQueryClient();
51
51
  return useMutation({
52
52
  mutationFn: async ({ companyData }) => {
53
- return this.post(`/company`, JSON.stringify(companyData), undefined, { "Content-Type": "application/json" });
53
+ return this.post({
54
+ path: `/company`,
55
+ data: JSON.stringify(companyData),
56
+ headers: { "Content-Type": "application/json" }
57
+ });
54
58
  },
55
59
  onSettled: () => {
56
60
  queryClient.invalidateQueries({ queryKey: ['/company/list'] });
@@ -61,7 +65,11 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
61
65
  const queryClient = this.getQueryClient();
62
66
  return useMutation({
63
67
  mutationFn: async ({ companyId, companyData, }) => {
64
- return this.put(`/company/${companyId}`, JSON.stringify(companyData), undefined, { "Content-Type": "application/json" });
68
+ return this.put({
69
+ path: `/company/${companyId}`,
70
+ data: JSON.stringify(companyData),
71
+ headers: { "Content-Type": "application/json" }
72
+ });
65
73
  },
66
74
  onMutate: async ({ companyId, companyData }) => {
67
75
  await queryClient.cancelQueries({ queryKey: ['company', companyId] });
@@ -99,7 +107,11 @@ AvroQueryClient.prototype.useCreateUserCompany = function () {
99
107
  if (!user_id) {
100
108
  throw new Error("Both userId and companyId are required");
101
109
  }
102
- return this.post(`/company/${this.companyId}/user/${user_id}`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
110
+ return this.post({
111
+ path: `/company/${this.companyId}/user/${user_id}`,
112
+ data: JSON.stringify(data),
113
+ headers: { "Content-Type": "application/json" }
114
+ });
103
115
  },
104
116
  onMutate: async ({ user_id }) => {
105
117
  await queryClient.cancelQueries({ queryKey: ['company', this.companyId] });
@@ -130,7 +142,9 @@ AvroQueryClient.prototype.useRemoveUserCompany = function () {
130
142
  const queryClient = this.getQueryClient();
131
143
  return useMutation({
132
144
  mutationFn: async ({ userId }) => {
133
- return this.delete(`/company/${this.companyId}/user/${userId}`);
145
+ return this.delete({
146
+ path: `/company/${this.companyId}/user/${userId}`
147
+ });
134
148
  },
135
149
  onMutate: async ({ userId }) => {
136
150
  await queryClient.cancelQueries({ queryKey: ['company', this.companyId] });
@@ -159,7 +173,9 @@ AvroQueryClient.prototype.useDeleteCompany = function () {
159
173
  const queryClient = this.getQueryClient();
160
174
  return useMutation({
161
175
  mutationFn: async ({ companyId }) => {
162
- return this.delete(`/company/${companyId}`);
176
+ return this.delete({
177
+ path: `/company/${companyId}`
178
+ });
163
179
  },
164
180
  onMutate: async ({ companyId }) => {
165
181
  await queryClient.cancelQueries({ queryKey: ['/company/list'] });
@@ -38,7 +38,7 @@ AvroQueryClient.prototype.useGetEvents = function (body) {
38
38
  AvroQueryClient.prototype.useGetEvent = function (eventId) {
39
39
  return useQuery({
40
40
  queryKey: ['event', eventId],
41
- queryFn: () => this.get(`/event/${eventId}`).then((event) => new _Event(event)),
41
+ queryFn: () => this.get({ path: `/event/${eventId}` }).then((event) => new _Event(event)),
42
42
  enabled: Boolean(eventId),
43
43
  });
44
44
  };
@@ -46,8 +46,10 @@ AvroQueryClient.prototype.useCreateEvent = function () {
46
46
  const queryClient = this.getQueryClient();
47
47
  return useMutation({
48
48
  mutationFn: ({ eventData }) => {
49
- return this.post(`/company/${this.companyId}/event`, JSON.stringify(eventData), undefined, {
50
- "Content-Type": "application/json",
49
+ return this.post({
50
+ path: `/company/${this.companyId}/event`,
51
+ data: JSON.stringify(eventData),
52
+ headers: { "Content-Type": "application/json" }
51
53
  });
52
54
  },
53
55
  onMutate: async ({ eventData }) => {
@@ -129,8 +131,10 @@ AvroQueryClient.prototype.useUpdateEvent = function () {
129
131
  const queryClient = this.getQueryClient();
130
132
  return useMutation({
131
133
  mutationFn: ({ eventId, updates }) => {
132
- return this.put(`/event/${eventId}`, JSON.stringify(updates), undefined, {
133
- "Content-Type": "application/json",
134
+ return this.put({
135
+ path: `/event/${eventId}`,
136
+ data: JSON.stringify(updates),
137
+ headers: { "Content-Type": "application/json" }
134
138
  });
135
139
  },
136
140
  onMutate: async ({ eventId, updates }) => {
@@ -205,12 +209,14 @@ AvroQueryClient.prototype.useUpdateEvents = function () {
205
209
  return useMutation({
206
210
  mutationFn: async ({ events, action, }) => {
207
211
  const eventIds = events.map(event => event.id);
208
- return this.put(`/company/${this.companyId}/events`, JSON.stringify({
209
- events: eventIds,
210
- billed: true,
211
- status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
212
- }), undefined, {
213
- "Content-Type": "application/json",
212
+ return this.put({
213
+ path: `/company/${this.companyId}/events`,
214
+ data: JSON.stringify({
215
+ events: eventIds,
216
+ billed: true,
217
+ status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
218
+ }),
219
+ headers: { "Content-Type": "application/json" }
214
220
  });
215
221
  },
216
222
  onMutate: async ({ events, action }) => {
@@ -266,8 +272,9 @@ AvroQueryClient.prototype.useDeleteEvent = function () {
266
272
  const queryClient = this.getQueryClient();
267
273
  return useMutation({
268
274
  mutationFn: async ({ eventId, }) => {
269
- return this.delete(`/event/${eventId}`, undefined, {
270
- "Content-Type": "application/json",
275
+ return this.delete({
276
+ path: `/event/${eventId}`,
277
+ headers: { "Content-Type": "application/json" }
271
278
  });
272
279
  },
273
280
  onMutate: async ({ eventId }) => {
@@ -30,7 +30,11 @@ AvroQueryClient.prototype.useCreateGroup = function () {
30
30
  const queryClient = this.getQueryClient();
31
31
  return useMutation({
32
32
  mutationFn: async ({ groupData }) => {
33
- return this.post(`/company/${this.companyId}/group`, JSON.stringify(groupData), undefined, { "Content-Type": "application/json" });
33
+ return this.post({
34
+ path: `/company/${this.companyId}/group`,
35
+ data: JSON.stringify(groupData),
36
+ headers: { "Content-Type": "application/json" }
37
+ });
34
38
  },
35
39
  onSettled: () => {
36
40
  queryClient.invalidateQueries({ queryKey: ['company'] });
@@ -42,7 +46,11 @@ AvroQueryClient.prototype.useUpdateGroup = function () {
42
46
  const queryClient = this.getQueryClient();
43
47
  return useMutation({
44
48
  mutationFn: async ({ groupId, groupData }) => {
45
- return this.put(`/group/${groupId}`, JSON.stringify(groupData), undefined, { "Content-Type": "application/json" });
49
+ return this.put({
50
+ path: `/group/${groupId}`,
51
+ data: JSON.stringify(groupData),
52
+ headers: { "Content-Type": "application/json" }
53
+ });
46
54
  },
47
55
  onMutate: async ({ groupId, groupData }) => {
48
56
  await queryClient.cancelQueries({ queryKey: ['groups'] });
@@ -89,7 +97,9 @@ AvroQueryClient.prototype.useDeleteGroup = function () {
89
97
  const queryClient = this.getQueryClient();
90
98
  return useMutation({
91
99
  mutationFn: async ({ groupId, }) => {
92
- return this.delete(`/group/${groupId}`);
100
+ return this.delete({
101
+ path: `/group/${groupId}`
102
+ });
93
103
  },
94
104
  onMutate: async ({ groupId }) => {
95
105
  await queryClient.cancelQueries({ queryKey: ['groups'] });
@@ -78,7 +78,9 @@ AvroQueryClient.prototype.useGetJob = function (jobId) {
78
78
  return useQuery({
79
79
  queryKey: ['job', jobId],
80
80
  queryFn: async () => {
81
- const job = await this.get(`/job/${jobId}`);
81
+ const job = await this.get({
82
+ path: `/job/${jobId}`
83
+ });
82
84
  return new Job(job);
83
85
  },
84
86
  enabled: Boolean(jobId),
@@ -88,8 +90,10 @@ AvroQueryClient.prototype.useCreateJob = function () {
88
90
  const queryClient = this.getQueryClient();
89
91
  return useMutation({
90
92
  mutationFn: ({ jobData }) => {
91
- return this.post(`/company/${this.companyId}/job`, JSON.stringify(jobData), undefined, {
92
- "Content-Type": "application/json",
93
+ return this.post({
94
+ path: `/company/${this.companyId}/job`,
95
+ data: JSON.stringify(jobData),
96
+ headers: { "Content-Type": "application/json" }
93
97
  });
94
98
  },
95
99
  onMutate: async ({ jobData }) => {
@@ -129,8 +133,10 @@ AvroQueryClient.prototype.useManageJobs = function () {
129
133
  const queryClient = this.getQueryClient();
130
134
  return useMutation({
131
135
  mutationFn: ({ jobs }) => {
132
- return this.post(`/company/${this.companyId}/jobs/manage`, JSON.stringify({ jobs }), undefined, {
133
- "Content-Type": "application/json",
136
+ return this.post({
137
+ path: `/company/${this.companyId}/jobs/manage`,
138
+ data: JSON.stringify({ jobs }),
139
+ headers: { "Content-Type": "application/json" }
134
140
  });
135
141
  },
136
142
  onMutate: async ({ jobs }) => {
@@ -172,8 +178,10 @@ AvroQueryClient.prototype.useUpdateJob = function () {
172
178
  const queryClient = this.getQueryClient();
173
179
  return useMutation({
174
180
  mutationFn: ({ jobId, updates }) => {
175
- return this.put(`/job/${jobId}`, JSON.stringify(updates), undefined, {
176
- "Content-Type": "application/json",
181
+ return this.put({
182
+ path: `/job/${jobId}`,
183
+ data: JSON.stringify(updates),
184
+ headers: { "Content-Type": "application/json" }
177
185
  });
178
186
  },
179
187
  onMutate: async ({ jobId, updates }) => {
@@ -218,8 +226,10 @@ AvroQueryClient.prototype.useDeleteJobs = function () {
218
226
  const queryClient = this.getQueryClient();
219
227
  return useMutation({
220
228
  mutationFn: ({ ids }) => {
221
- return this.post(`/company/${this.companyId}/jobs/delete`, JSON.stringify({ ids }), undefined, {
222
- "Content-Type": "application/json",
229
+ return this.post({
230
+ path: `/company/${this.companyId}/jobs/delete`,
231
+ data: JSON.stringify({ ids }),
232
+ headers: { "Content-Type": "application/json" }
223
233
  });
224
234
  },
225
235
  onMutate: async ({ ids }) => {
@@ -256,8 +266,11 @@ AvroQueryClient.prototype.useDeleteJob = function () {
256
266
  const queryClient = this.getQueryClient();
257
267
  return useMutation({
258
268
  mutationFn: async ({ jobId }) => {
259
- return this.delete(`/job/${jobId}`, undefined, {
260
- "Content-Type": "application/json",
269
+ return this.delete({
270
+ path: `/job/${jobId}`,
271
+ headers: {
272
+ "Content-Type": "application/json",
273
+ }
261
274
  });
262
275
  },
263
276
  onMutate: async ({ jobId }) => {
@@ -30,7 +30,11 @@ AvroQueryClient.prototype.useCreateLabel = function () {
30
30
  const queryClient = this.getQueryClient();
31
31
  return useMutation({
32
32
  mutationFn: async ({ labelData }) => {
33
- return this.post(`/company/${this.companyId}/label`, JSON.stringify(labelData), undefined, { "Content-Type": "application/json" });
33
+ return this.post({
34
+ path: `/company/${this.companyId}/label`,
35
+ data: JSON.stringify(labelData),
36
+ headers: { "Content-Type": "application/json" }
37
+ });
34
38
  },
35
39
  onSettled: () => {
36
40
  queryClient.invalidateQueries({ queryKey: ['company'] });
@@ -42,7 +46,11 @@ AvroQueryClient.prototype.useUpdateLabel = function () {
42
46
  const queryClient = this.getQueryClient();
43
47
  return useMutation({
44
48
  mutationFn: async ({ labelId, labelData }) => {
45
- return this.put(`/label/${labelId}`, JSON.stringify(labelData), undefined, { "Content-Type": "application/json" });
49
+ return this.put({
50
+ path: `/label/${labelId}`,
51
+ data: JSON.stringify(labelData),
52
+ headers: { "Content-Type": "application/json" }
53
+ });
46
54
  },
47
55
  onMutate: async ({ labelId, labelData }) => {
48
56
  await queryClient.cancelQueries({ queryKey: ['labels'] });
@@ -89,7 +97,7 @@ AvroQueryClient.prototype.useDeleteLabel = function () {
89
97
  const queryClient = this.getQueryClient();
90
98
  return useMutation({
91
99
  mutationFn: async ({ labelId, }) => {
92
- return this.delete(`/label/${labelId}`);
100
+ return this.delete({ path: `/label/${labelId}` });
93
101
  },
94
102
  onMutate: async ({ labelId }) => {
95
103
  await queryClient.cancelQueries({ queryKey: ['labels'] });
@@ -28,15 +28,20 @@ AvroQueryClient.prototype.useGetMessages = function (chatId, body) {
28
28
  }
29
29
  return result;
30
30
  };
31
- AvroQueryClient.prototype.useCreateMessage = function (chatId, body) {
31
+ AvroQueryClient.prototype.useCreateMessage = function (chatId) {
32
32
  const queryClient = this.getQueryClient();
33
33
  return useMutation({
34
- mutationFn: async ({ content, sent_at } = body) => {
35
- const message = await this.post(`/chat/${chatId}/message`, {
36
- message: {
37
- content,
38
- sent_at: sent_at ?? Math.floor(Date.now() / 1000),
39
- },
34
+ mutationFn: async ({ content, sent_at, id }) => {
35
+ const message = await this.post({
36
+ path: `/chat/${chatId}/message`,
37
+ data: JSON.stringify({
38
+ message: {
39
+ content,
40
+ sent_at: sent_at ?? Math.floor(Date.now() / 1000),
41
+ id,
42
+ },
43
+ }),
44
+ headers: { 'Content-Type': 'application/json' }
40
45
  });
41
46
  return message;
42
47
  },
@@ -40,11 +40,15 @@ AvroQueryClient.prototype.useUpdateMonths = function () {
40
40
  return useMutation({
41
41
  mutationFn: async ({ months, action, }) => {
42
42
  const monthIds = months.map(month => month.id);
43
- return this.put(`/company/${this.companyId}/months`, JSON.stringify({
44
- months: monthIds,
45
- status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
46
- }), undefined, {
47
- "Content-Type": "application/json",
43
+ return this.put({
44
+ path: `/company/${this.companyId}/months`,
45
+ data: JSON.stringify({
46
+ months: monthIds,
47
+ status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
48
+ }),
49
+ headers: {
50
+ "Content-Type": "application/json",
51
+ }
48
52
  });
49
53
  },
50
54
  onMutate: async ({ months, action }) => {
@@ -3,6 +3,6 @@ import { AvroQueryClient } from "../../client/QueryClient";
3
3
  AvroQueryClient.prototype.useGetPlans = function (code) {
4
4
  return useQuery({
5
5
  queryKey: ['plans', code],
6
- queryFn: async () => this.get(`/plans${code ? `?code=${code}` : ''}`),
6
+ queryFn: async () => this.get({ path: `/plans${code ? `?code=${code}` : ''}` }),
7
7
  });
8
8
  };
@@ -40,11 +40,15 @@ AvroQueryClient.prototype.useUpdatePrepayments = function () {
40
40
  return useMutation({
41
41
  mutationFn: async ({ prepayments, action, }) => {
42
42
  const prepaymentIds = prepayments.map(prepayment => prepayment.id);
43
- return this.put(`/company/${this.companyId}/prepayments`, JSON.stringify({
44
- prepayments: prepaymentIds,
45
- status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
46
- }), undefined, {
47
- "Content-Type": "application/json",
43
+ return this.put({
44
+ path: `/company/${this.companyId}/prepayments`,
45
+ data: JSON.stringify({
46
+ prepayments: prepaymentIds,
47
+ status: action === "billed" ? LineItemStatus.EXTERNALLY_BILLED : LineItemStatus.EXTERNALLY_PAID,
48
+ }),
49
+ headers: {
50
+ "Content-Type": "application/json",
51
+ }
48
52
  });
49
53
  },
50
54
  onMutate: async ({ prepayments, action }) => {
@@ -4,14 +4,22 @@ import { Task } from "../../types/api/Task";
4
4
  AvroQueryClient.prototype.useCreateProposal = function () {
5
5
  return useMutation({
6
6
  mutationFn: async ({ job_id, data }) => {
7
- return this.post(`/job/${job_id}/proposal`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
7
+ return this.post({
8
+ path: `/job/${job_id}/proposal`,
9
+ data: JSON.stringify(data),
10
+ headers: { "Content-Type": "application/json" }
11
+ });
8
12
  },
9
13
  });
10
14
  };
11
15
  AvroQueryClient.prototype.useAcceptProposal = function (proposal_id) {
12
16
  return useMutation({
13
17
  mutationFn: async (data) => {
14
- return this.post(`/proposal/${proposal_id}/accept`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
18
+ return this.post({
19
+ path: `/proposal/${proposal_id}/accept`,
20
+ data: JSON.stringify(data),
21
+ headers: { "Content-Type": "application/json" }
22
+ });
15
23
  },
16
24
  });
17
25
  };
@@ -19,7 +27,7 @@ AvroQueryClient.prototype.useGetProposal = function (proposal_id) {
19
27
  return useQuery({
20
28
  queryKey: ['proposal', proposal_id],
21
29
  queryFn: async () => {
22
- const proposal = await this.get(`/proposal/${proposal_id}`);
30
+ const proposal = await this.get({ path: `/proposal/${proposal_id}` });
23
31
  if (proposal && Array.isArray(proposal.tasks)) {
24
32
  proposal.tasks = proposal.tasks.map((task) => new Task(task));
25
33
  }
@@ -3,6 +3,6 @@ import { AvroQueryClient } from '../../client/QueryClient';
3
3
  AvroQueryClient.prototype.useGetRoot = function () {
4
4
  return useQuery({
5
5
  queryKey: ['health'],
6
- queryFn: () => this.get('/'),
6
+ queryFn: () => this.get({ path: '/' }),
7
7
  });
8
8
  };
@@ -33,7 +33,7 @@ AvroQueryClient.prototype.useGetRoute = function (routeId) {
33
33
  return useQuery({
34
34
  queryKey: ['route', routeId],
35
35
  queryFn: async () => {
36
- const route = await this.get(`/route/${routeId}`);
36
+ const route = await this.get({ path: `/route/${routeId}` });
37
37
  return new Route(route);
38
38
  },
39
39
  enabled: Boolean(routeId) && routeId.length > 0,
@@ -43,7 +43,11 @@ AvroQueryClient.prototype.useCreateRoute = function () {
43
43
  const queryClient = this.getQueryClient();
44
44
  return useMutation({
45
45
  mutationFn: async ({ routeData }) => {
46
- return this.post(`/company/${this.companyId}/route`, JSON.stringify(routeData), undefined, { "Content-Type": "application/json" });
46
+ return this.post({
47
+ path: `/company/${this.companyId}/route`,
48
+ data: JSON.stringify(routeData),
49
+ headers: { "Content-Type": "application/json" }
50
+ });
47
51
  },
48
52
  onMutate: async ({ routeData }) => {
49
53
  await queryClient.cancelQueries({ queryKey: ['routes'] });
@@ -83,7 +87,11 @@ AvroQueryClient.prototype.useCreateRoute = function () {
83
87
  AvroQueryClient.prototype.useScheduleRoutes = function () {
84
88
  return useMutation({
85
89
  mutationFn: async ({ schedule }) => {
86
- return this.post(`/company/${this.companyId}/schedule`, JSON.stringify(schedule), undefined, { "Content-Type": "application/json" });
90
+ return this.post({
91
+ path: `/company/${this.companyId}/schedule`,
92
+ data: JSON.stringify(schedule),
93
+ headers: { "Content-Type": "application/json" }
94
+ });
87
95
  },
88
96
  });
89
97
  };
@@ -91,7 +99,11 @@ AvroQueryClient.prototype.useUpdateRoute = function () {
91
99
  const queryClient = this.getQueryClient();
92
100
  return useMutation({
93
101
  mutationFn: async ({ routeId, updates, }) => {
94
- return this.put(`/route/${routeId}`, JSON.stringify(updates), undefined, { "Content-Type": "application/json" });
102
+ return this.put({
103
+ path: `/route/${routeId}`,
104
+ data: JSON.stringify(updates),
105
+ headers: { "Content-Type": "application/json" }
106
+ });
95
107
  },
96
108
  onMutate: async ({ routeId, updates }) => {
97
109
  await queryClient.cancelQueries({ queryKey: ['route', routeId] });
@@ -137,7 +149,7 @@ AvroQueryClient.prototype.useDeleteRoute = function () {
137
149
  const queryClient = this.getQueryClient();
138
150
  return useMutation({
139
151
  mutationFn: async ({ routeId, }) => {
140
- return this.delete(`/route/${routeId}`);
152
+ return this.delete({ path: `/route/${routeId}` });
141
153
  },
142
154
  onMutate: async ({ routeId }) => {
143
155
  await queryClient.cancelQueries({ queryKey: ['routes'] });
@@ -3,15 +3,17 @@ import { AvroQueryClient } from "../../client/QueryClient";
3
3
  AvroQueryClient.prototype.useGetUserSessions = function () {
4
4
  return useQuery({
5
5
  queryKey: ['sessions'],
6
- queryFn: () => this.get('/session'),
6
+ queryFn: () => this.get({ path: '/session' }),
7
7
  });
8
8
  };
9
9
  AvroQueryClient.prototype.useCreateUserSession = function () {
10
10
  const queryClient = this.getQueryClient();
11
11
  return useMutation({
12
12
  mutationFn: ({ sessionData }) => {
13
- return this.post(`/company/${this.companyId}/session`, JSON.stringify(sessionData), undefined, {
14
- "Content-Type": "application/json",
13
+ return this.post({
14
+ path: `/company/${this.companyId}/session`,
15
+ data: JSON.stringify(sessionData),
16
+ headers: { "Content-Type": "application/json" }
15
17
  });
16
18
  },
17
19
  onMutate: async ({ sessionData }) => {
@@ -48,8 +50,10 @@ AvroQueryClient.prototype.useCreateSessionBreak = function () {
48
50
  const queryClient = this.getQueryClient();
49
51
  return useMutation({
50
52
  mutationFn: ({ sessionId, breakData }) => {
51
- return this.post(`/session/${sessionId}/break`, JSON.stringify(breakData), undefined, {
52
- "Content-Type": "application/json",
53
+ return this.post({
54
+ path: `/session/${sessionId}/break`,
55
+ data: JSON.stringify(breakData),
56
+ headers: { "Content-Type": "application/json" }
53
57
  });
54
58
  },
55
59
  onMutate: async ({ sessionId, breakData }) => {
@@ -91,8 +95,10 @@ AvroQueryClient.prototype.useUpdateUserSession = function () {
91
95
  const queryClient = this.getQueryClient();
92
96
  return useMutation({
93
97
  mutationFn: ({ sessionId, updates }) => {
94
- return this.put(`/session/${sessionId}`, JSON.stringify(updates), undefined, {
95
- "Content-Type": "application/json",
98
+ return this.put({
99
+ path: `/session/${sessionId}`,
100
+ data: JSON.stringify(updates),
101
+ headers: { "Content-Type": "application/json" }
96
102
  });
97
103
  },
98
104
  onMutate: async ({ sessionId, updates }) => {
@@ -122,8 +128,10 @@ AvroQueryClient.prototype.useUpdateSessionBreak = function () {
122
128
  const queryClient = this.getQueryClient();
123
129
  return useMutation({
124
130
  mutationFn: ({ breakId, updates }) => {
125
- return this.put(`/break/${breakId}`, JSON.stringify(updates), undefined, {
126
- "Content-Type": "application/json",
131
+ return this.put({
132
+ path: `/break/${breakId}`,
133
+ data: JSON.stringify(updates),
134
+ headers: { "Content-Type": "application/json" }
127
135
  });
128
136
  },
129
137
  onMutate: async ({ breakId, updates }) => {
@@ -4,8 +4,10 @@ AvroQueryClient.prototype.useCreateSkill = function () {
4
4
  const queryClient = this.getQueryClient();
5
5
  return useMutation({
6
6
  mutationFn: async ({ skillData }) => {
7
- return this.post(`/company/${this.companyId}/skill`, JSON.stringify(skillData), undefined, {
8
- "Content-Type": "application/json",
7
+ return this.post({
8
+ path: `/company/${this.companyId}/skill`,
9
+ data: JSON.stringify(skillData),
10
+ headers: { "Content-Type": "application/json" }
9
11
  });
10
12
  },
11
13
  onSettled: () => {
@@ -44,8 +46,10 @@ AvroQueryClient.prototype.useUpdateSkill = function () {
44
46
  const queryClient = this.getQueryClient();
45
47
  return useMutation({
46
48
  mutationFn: async ({ skillId, updates }) => {
47
- return this.put(`/skill/${skillId}`, JSON.stringify(updates), undefined, {
48
- "Content-Type": "application/json",
49
+ return this.put({
50
+ path: `/skill/${skillId}`,
51
+ data: JSON.stringify(updates),
52
+ headers: { "Content-Type": "application/json" }
49
53
  });
50
54
  },
51
55
  onMutate: async ({ skillId, updates }) => {
@@ -92,7 +96,7 @@ AvroQueryClient.prototype.useDeleteSkill = function () {
92
96
  const queryClient = this.getQueryClient();
93
97
  return useMutation({
94
98
  mutationFn: async ({ skillId }) => {
95
- return this.delete(`/skill/${skillId}`);
99
+ return this.delete({ path: `/skill/${skillId}` });
96
100
  },
97
101
  onMutate: async ({ skillId }) => {
98
102
  await queryClient.cancelQueries({ queryKey: ['skills'] });
@@ -30,7 +30,11 @@ AvroQueryClient.prototype.useCreateTeam = function () {
30
30
  const queryClient = this.getQueryClient();
31
31
  return useMutation({
32
32
  mutationFn: async ({ teamData }) => {
33
- return this.post(`/company/${this.companyId}/team`, JSON.stringify(teamData), undefined, { "Content-Type": "application/json" });
33
+ return this.post({
34
+ path: `/company/${this.companyId}/team`,
35
+ data: JSON.stringify(teamData),
36
+ headers: { "Content-Type": "application/json" }
37
+ });
34
38
  },
35
39
  onSettled: () => {
36
40
  queryClient.invalidateQueries({ queryKey: ['company'] });
@@ -42,7 +46,11 @@ AvroQueryClient.prototype.useUpdateTeam = function () {
42
46
  const queryClient = this.getQueryClient();
43
47
  return useMutation({
44
48
  mutationFn: async ({ teamId, teamData }) => {
45
- return this.put(`/team/${teamId}`, JSON.stringify(teamData), undefined, { "Content-Type": "application/json" });
49
+ return this.put({
50
+ path: `/team/${teamId}`,
51
+ data: JSON.stringify(teamData),
52
+ headers: { "Content-Type": "application/json" }
53
+ });
46
54
  },
47
55
  onMutate: async ({ teamId, teamData }) => {
48
56
  await queryClient.cancelQueries({ queryKey: ['teams'] });
@@ -88,7 +96,7 @@ AvroQueryClient.prototype.useDeleteTeam = function () {
88
96
  const queryClient = this.getQueryClient();
89
97
  return useMutation({
90
98
  mutationFn: async ({ teamId, }) => {
91
- return this.delete(`/team/${teamId}`);
99
+ return this.delete({ path: `/team/${teamId}` });
92
100
  },
93
101
  onMutate: async ({ teamId }) => {
94
102
  await queryClient.cancelQueries({ queryKey: ['teams'] });
@@ -4,7 +4,7 @@ import { AuthState } from "../../types/auth";
4
4
  AvroQueryClient.prototype.useGetUser = function (userId) {
5
5
  return useQuery({
6
6
  queryKey: ['user', userId],
7
- queryFn: () => this.get(`/user/${userId}`),
7
+ queryFn: () => this.get({ path: `/user/${userId}` }),
8
8
  enabled: Boolean(userId),
9
9
  });
10
10
  };
@@ -14,7 +14,7 @@ AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
14
14
  queryFn: () => {
15
15
  if (!searchUsername)
16
16
  return Promise.resolve([]);
17
- return this.get(`/user/search/${searchUsername}`);
17
+ return this.get({ path: `/user/search/${searchUsername}` });
18
18
  },
19
19
  enabled: Boolean(searchUsername),
20
20
  });
@@ -22,7 +22,7 @@ AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
22
22
  AvroQueryClient.prototype.useGetSelf = function () {
23
23
  return useQuery({
24
24
  queryKey: ['user'],
25
- queryFn: () => this.get(`/user`),
25
+ queryFn: () => this.get({ path: `/user` }),
26
26
  enabled: this.getAuthState() === AuthState.AUTHENTICATED,
27
27
  });
28
28
  };
@@ -30,7 +30,11 @@ AvroQueryClient.prototype.useCreateSelf = function () {
30
30
  const queryClient = this.getQueryClient();
31
31
  return useMutation({
32
32
  mutationFn: async (data) => {
33
- return this.post('/user', JSON.stringify(data), undefined, { "Content-Type": "application/json" });
33
+ return this.post({
34
+ path: '/user',
35
+ data: JSON.stringify(data),
36
+ headers: { "Content-Type": "application/json" }
37
+ });
34
38
  },
35
39
  onSettled: (data) => {
36
40
  queryClient.invalidateQueries({ queryKey: ['user'] });
@@ -44,7 +48,11 @@ AvroQueryClient.prototype.useCreateUser = function () {
44
48
  const queryClient = this.getQueryClient();
45
49
  return useMutation({
46
50
  mutationFn: async (data) => {
47
- return this.post('/user', JSON.stringify(data), undefined, { "Content-Type": "application/json" });
51
+ return this.post({
52
+ path: '/user',
53
+ data: JSON.stringify(data),
54
+ headers: { "Content-Type": "application/json" }
55
+ });
48
56
  },
49
57
  onSettled: (data) => {
50
58
  queryClient.invalidateQueries({ queryKey: ['user'] });
@@ -55,7 +63,11 @@ AvroQueryClient.prototype.useUpdateSelf = function () {
55
63
  const queryClient = this.getQueryClient();
56
64
  return useMutation({
57
65
  mutationFn: async (data) => {
58
- return this.put(`/user`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
66
+ return this.put({
67
+ path: `/user`,
68
+ data: JSON.stringify(data),
69
+ headers: { "Content-Type": "application/json" }
70
+ });
59
71
  },
60
72
  // Optimistically update the user data in the cache
61
73
  onMutate: async (data) => {
@@ -80,7 +92,11 @@ AvroQueryClient.prototype.useUpdateUserCompany = function () {
80
92
  const queryClient = this.getQueryClient();
81
93
  return useMutation({
82
94
  mutationFn: async ({ user_id, data }) => {
83
- return this.put(`/company/${this.companyId}/user/${user_id}`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
95
+ return this.put({
96
+ path: `/company/${this.companyId}/user/${user_id}`,
97
+ data: JSON.stringify(data),
98
+ headers: { "Content-Type": "application/json" }
99
+ });
84
100
  },
85
101
  // Optimistically update the user data and company data in the cache
86
102
  onMutate: async (data) => {
@@ -112,7 +128,7 @@ AvroQueryClient.prototype.useDeleteSelf = function () {
112
128
  const queryClient = this.getQueryClient();
113
129
  return useMutation({
114
130
  mutationFn: async () => {
115
- return this.delete(`/user`);
131
+ return this.delete({ path: `/user` });
116
132
  },
117
133
  onMutate: async () => {
118
134
  await queryClient.cancelQueries({ queryKey: ['user'] });
@@ -4,8 +4,10 @@ AvroQueryClient.prototype.useCreateWaiver = function () {
4
4
  const queryClient = this.getQueryClient();
5
5
  return useMutation({
6
6
  mutationFn: async ({ waiverData }) => {
7
- return this.post(`/company/${this.companyId}/waiver`, JSON.stringify(waiverData), undefined, {
8
- "Content-Type": "application/json",
7
+ return this.post({
8
+ path: `/company/${this.companyId}/waiver`,
9
+ data: JSON.stringify(waiverData),
10
+ headers: { "Content-Type": "application/json" }
9
11
  });
10
12
  },
11
13
  onSettled: () => {
@@ -44,8 +46,10 @@ AvroQueryClient.prototype.useUpdateWaiver = function () {
44
46
  const queryClient = this.getQueryClient();
45
47
  return useMutation({
46
48
  mutationFn: async ({ waiverId, updates }) => {
47
- return this.put(`/waiver/${waiverId}`, JSON.stringify(updates), undefined, {
48
- "Content-Type": "application/json",
49
+ return this.put({
50
+ path: `/waiver/${waiverId}`,
51
+ data: JSON.stringify(updates),
52
+ headers: { "Content-Type": "application/json" }
49
53
  });
50
54
  },
51
55
  onMutate: async ({ waiverId, updates }) => {
@@ -92,7 +96,7 @@ AvroQueryClient.prototype.useDeleteWaiver = function () {
92
96
  const queryClient = this.getQueryClient();
93
97
  return useMutation({
94
98
  mutationFn: async ({ waiverId }) => {
95
- return this.delete(`/waiver/${waiverId}`);
99
+ return this.delete({ path: `/waiver/${waiverId}` });
96
100
  },
97
101
  onMutate: async ({ waiverId }) => {
98
102
  await queryClient.cancelQueries({ queryKey: ['waivers'] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.8-beta.0",
3
+ "version": "0.0.8-beta.2",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",