@go-avro/avro-js 0.0.2-beta.85 → 0.0.2-beta.87
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.
|
@@ -259,7 +259,7 @@ export declare class AvroQueryClient {
|
|
|
259
259
|
delete<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
|
|
260
260
|
useLogin(): ReturnType<typeof useMutation<LoginResponse, StandardError, {
|
|
261
261
|
username: string;
|
|
262
|
-
password
|
|
262
|
+
password?: string;
|
|
263
263
|
code?: string;
|
|
264
264
|
cancelToken?: CancelToken;
|
|
265
265
|
}>>;
|
|
@@ -77,7 +77,7 @@ export class AvroQueryClient {
|
|
|
77
77
|
const queryClient = useQueryClient();
|
|
78
78
|
return useMutation({
|
|
79
79
|
mutationFn: async ({ username, password, code, cancelToken }) => {
|
|
80
|
-
const resp = await this.
|
|
80
|
+
const resp = await this.post('/login', JSON.stringify({ username, password, code }), cancelToken, { 'Content-Type': 'application/json' });
|
|
81
81
|
if (!resp || !('access_token' in resp)) {
|
|
82
82
|
if (resp.msg === "TOTP email sent") {
|
|
83
83
|
return LoginResponse.NEEDS_TOTP;
|
|
@@ -143,7 +143,7 @@ export class AvroQueryClient {
|
|
|
143
143
|
const queryClient = useQueryClient();
|
|
144
144
|
return useMutation({
|
|
145
145
|
mutationFn: async (cancelToken) => {
|
|
146
|
-
await this.
|
|
146
|
+
await this.post('/logout', null, cancelToken);
|
|
147
147
|
await this.config.authManager.clearTokens();
|
|
148
148
|
if (this.socket && this.socket.connected) {
|
|
149
149
|
this.socket.disconnect();
|
|
@@ -164,7 +164,10 @@ export class AvroQueryClient {
|
|
|
164
164
|
if (!companyGuid || companyGuid.trim() === '') {
|
|
165
165
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
166
166
|
}
|
|
167
|
-
return this._fetch('POST', `/company/${companyGuid}/jobs`, body, cancelToken,
|
|
167
|
+
return this._fetch('POST', `/company/${companyGuid}/jobs`, JSON.stringify(body), cancelToken, {
|
|
168
|
+
...headers,
|
|
169
|
+
'Content-Type': 'application/json',
|
|
170
|
+
})
|
|
168
171
|
.then(response => {
|
|
169
172
|
if (!response || !Array.isArray(response)) {
|
|
170
173
|
throw new StandardError(400, 'Invalid jobs response');
|
|
@@ -180,7 +183,10 @@ export class AvroQueryClient {
|
|
|
180
183
|
if (!companyGuid || companyGuid.trim() === '') {
|
|
181
184
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
182
185
|
}
|
|
183
|
-
return this._fetch('POST', `/company/${companyGuid}/chats`, body, cancelToken,
|
|
186
|
+
return this._fetch('POST', `/company/${companyGuid}/chats`, JSON.stringify(body), cancelToken, {
|
|
187
|
+
...headers,
|
|
188
|
+
'Content-Type': 'application/json',
|
|
189
|
+
})
|
|
184
190
|
.then(response => {
|
|
185
191
|
if (!response || !Array.isArray(response)) {
|
|
186
192
|
throw new StandardError(400, 'Invalid chats response');
|
|
@@ -196,7 +202,10 @@ export class AvroQueryClient {
|
|
|
196
202
|
if (!chatGuid || chatGuid.trim() === '') {
|
|
197
203
|
return Promise.reject(new StandardError(400, 'Chat GUID is required'));
|
|
198
204
|
}
|
|
199
|
-
return this._fetch('POST', `/chat/${chatGuid}/messages`, body, cancelToken,
|
|
205
|
+
return this._fetch('POST', `/chat/${chatGuid}/messages`, JSON.stringify(body), cancelToken, {
|
|
206
|
+
...headers,
|
|
207
|
+
'Content-Type': 'application/json',
|
|
208
|
+
})
|
|
200
209
|
.then(response => {
|
|
201
210
|
if (!response || !Array.isArray(response)) {
|
|
202
211
|
throw new StandardError(400, 'Invalid messages response');
|
|
@@ -212,7 +221,10 @@ export class AvroQueryClient {
|
|
|
212
221
|
if (!companyGuid || companyGuid.trim() === '') {
|
|
213
222
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
214
223
|
}
|
|
215
|
-
return this._fetch('POST', `/company/${companyGuid}/events`, body, cancelToken,
|
|
224
|
+
return this._fetch('POST', `/company/${companyGuid}/events`, JSON.stringify(body), cancelToken, {
|
|
225
|
+
...headers,
|
|
226
|
+
'Content-Type': 'application/json',
|
|
227
|
+
})
|
|
216
228
|
.then(response => {
|
|
217
229
|
if (!response || !Array.isArray(response)) {
|
|
218
230
|
throw new StandardError(400, 'Invalid events response');
|
|
@@ -228,7 +240,10 @@ export class AvroQueryClient {
|
|
|
228
240
|
if (!companyGuid || companyGuid.trim() === '') {
|
|
229
241
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
230
242
|
}
|
|
231
|
-
return this._fetch('POST', `/company/${companyGuid}/months`, body, cancelToken,
|
|
243
|
+
return this._fetch('POST', `/company/${companyGuid}/months`, JSON.stringify(body), cancelToken, {
|
|
244
|
+
...headers,
|
|
245
|
+
'Content-Type': 'application/json',
|
|
246
|
+
})
|
|
232
247
|
.then(response => {
|
|
233
248
|
if (!response || !Array.isArray(response)) {
|
|
234
249
|
throw new StandardError(400, 'Invalid months response');
|
|
@@ -244,7 +259,10 @@ export class AvroQueryClient {
|
|
|
244
259
|
if (!companyGuid || companyGuid.trim() === '') {
|
|
245
260
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
246
261
|
}
|
|
247
|
-
return this._fetch('POST', `/company/${companyGuid}/bills`, body, cancelToken,
|
|
262
|
+
return this._fetch('POST', `/company/${companyGuid}/bills`, JSON.stringify(body), cancelToken, {
|
|
263
|
+
...headers,
|
|
264
|
+
'Content-Type': 'application/json',
|
|
265
|
+
})
|
|
248
266
|
.then(response => {
|
|
249
267
|
if (!response || !Array.isArray(response)) {
|
|
250
268
|
throw new StandardError(400, 'Invalid bills response');
|
|
@@ -260,7 +278,10 @@ export class AvroQueryClient {
|
|
|
260
278
|
if (!companyGuid || companyGuid.trim() === '') {
|
|
261
279
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
262
280
|
}
|
|
263
|
-
return this._fetch('POST', `/company/${companyGuid}/routes`, body, cancelToken,
|
|
281
|
+
return this._fetch('POST', `/company/${companyGuid}/routes`, JSON.stringify(body), cancelToken, {
|
|
282
|
+
...headers,
|
|
283
|
+
'Content-Type': 'application/json',
|
|
284
|
+
})
|
|
264
285
|
.then(response => {
|
|
265
286
|
if (!response || !Array.isArray(response)) {
|
|
266
287
|
throw new StandardError(400, 'Invalid routes response');
|
|
@@ -276,7 +297,10 @@ export class AvroQueryClient {
|
|
|
276
297
|
if (!companyGuid || companyGuid.trim() === '') {
|
|
277
298
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
278
299
|
}
|
|
279
|
-
return this._fetch('POST', `/company/${companyGuid}/teams`, body, cancelToken,
|
|
300
|
+
return this._fetch('POST', `/company/${companyGuid}/teams`, JSON.stringify(body), cancelToken, {
|
|
301
|
+
...headers,
|
|
302
|
+
'Content-Type': 'application/json',
|
|
303
|
+
})
|
|
280
304
|
.then(response => {
|
|
281
305
|
if (!response || !Array.isArray(response)) {
|
|
282
306
|
throw new StandardError(400, 'Invalid teams response');
|
|
@@ -17,14 +17,13 @@ AvroQueryClient.prototype._fetch = async function (method, path, body, cancelTok
|
|
|
17
17
|
checkCancelled();
|
|
18
18
|
const url = this.config.baseUrl + path;
|
|
19
19
|
const requestHeaders = {
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
20
|
Authorization: `Bearer ${token}`,
|
|
22
21
|
...headers,
|
|
23
22
|
};
|
|
24
23
|
const options = {
|
|
25
24
|
method,
|
|
26
25
|
headers: requestHeaders,
|
|
27
|
-
body
|
|
26
|
+
body,
|
|
28
27
|
};
|
|
29
28
|
const response = await fetch(url, options);
|
|
30
29
|
if (response.ok) {
|