@go-avro/avro-js 0.0.2-beta.85 → 0.0.2-beta.86

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: string;
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._fetch('POST', '/login', { username, password, code }, cancelToken);
80
+ const resp = await this.post('/login', JSON.stringify({ username, password, code }), cancelToken);
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._fetch('POST', '/logout', null, cancelToken);
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,7 @@ 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, headers)
167
+ return this._fetch('POST', `/company/${companyGuid}/jobs`, JSON.stringify(body), cancelToken, headers)
168
168
  .then(response => {
169
169
  if (!response || !Array.isArray(response)) {
170
170
  throw new StandardError(400, 'Invalid jobs response');
@@ -180,7 +180,7 @@ export class AvroQueryClient {
180
180
  if (!companyGuid || companyGuid.trim() === '') {
181
181
  return Promise.reject(new StandardError(400, 'Company GUID is required'));
182
182
  }
183
- return this._fetch('POST', `/company/${companyGuid}/chats`, body, cancelToken, headers)
183
+ return this._fetch('POST', `/company/${companyGuid}/chats`, JSON.stringify(body), cancelToken, headers)
184
184
  .then(response => {
185
185
  if (!response || !Array.isArray(response)) {
186
186
  throw new StandardError(400, 'Invalid chats response');
@@ -196,7 +196,7 @@ export class AvroQueryClient {
196
196
  if (!chatGuid || chatGuid.trim() === '') {
197
197
  return Promise.reject(new StandardError(400, 'Chat GUID is required'));
198
198
  }
199
- return this._fetch('POST', `/chat/${chatGuid}/messages`, body, cancelToken, headers)
199
+ return this._fetch('POST', `/chat/${chatGuid}/messages`, JSON.stringify(body), cancelToken, headers)
200
200
  .then(response => {
201
201
  if (!response || !Array.isArray(response)) {
202
202
  throw new StandardError(400, 'Invalid messages response');
@@ -212,7 +212,7 @@ export class AvroQueryClient {
212
212
  if (!companyGuid || companyGuid.trim() === '') {
213
213
  return Promise.reject(new StandardError(400, 'Company GUID is required'));
214
214
  }
215
- return this._fetch('POST', `/company/${companyGuid}/events`, body, cancelToken, headers)
215
+ return this._fetch('POST', `/company/${companyGuid}/events`, JSON.stringify(body), cancelToken, headers)
216
216
  .then(response => {
217
217
  if (!response || !Array.isArray(response)) {
218
218
  throw new StandardError(400, 'Invalid events response');
@@ -228,7 +228,7 @@ export class AvroQueryClient {
228
228
  if (!companyGuid || companyGuid.trim() === '') {
229
229
  return Promise.reject(new StandardError(400, 'Company GUID is required'));
230
230
  }
231
- return this._fetch('POST', `/company/${companyGuid}/months`, body, cancelToken, headers)
231
+ return this._fetch('POST', `/company/${companyGuid}/months`, JSON.stringify(body), cancelToken, headers)
232
232
  .then(response => {
233
233
  if (!response || !Array.isArray(response)) {
234
234
  throw new StandardError(400, 'Invalid months response');
@@ -244,7 +244,7 @@ export class AvroQueryClient {
244
244
  if (!companyGuid || companyGuid.trim() === '') {
245
245
  return Promise.reject(new StandardError(400, 'Company GUID is required'));
246
246
  }
247
- return this._fetch('POST', `/company/${companyGuid}/bills`, body, cancelToken, headers)
247
+ return this._fetch('POST', `/company/${companyGuid}/bills`, JSON.stringify(body), cancelToken, headers)
248
248
  .then(response => {
249
249
  if (!response || !Array.isArray(response)) {
250
250
  throw new StandardError(400, 'Invalid bills response');
@@ -260,7 +260,7 @@ export class AvroQueryClient {
260
260
  if (!companyGuid || companyGuid.trim() === '') {
261
261
  return Promise.reject(new StandardError(400, 'Company GUID is required'));
262
262
  }
263
- return this._fetch('POST', `/company/${companyGuid}/routes`, body, cancelToken, headers)
263
+ return this._fetch('POST', `/company/${companyGuid}/routes`, JSON.stringify(body), cancelToken, headers)
264
264
  .then(response => {
265
265
  if (!response || !Array.isArray(response)) {
266
266
  throw new StandardError(400, 'Invalid routes response');
@@ -276,7 +276,7 @@ export class AvroQueryClient {
276
276
  if (!companyGuid || companyGuid.trim() === '') {
277
277
  return Promise.reject(new StandardError(400, 'Company GUID is required'));
278
278
  }
279
- return this._fetch('POST', `/company/${companyGuid}/teams`, body, cancelToken, headers)
279
+ return this._fetch('POST', `/company/${companyGuid}/teams`, JSON.stringify(body), cancelToken, headers)
280
280
  .then(response => {
281
281
  if (!response || !Array.isArray(response)) {
282
282
  throw new StandardError(400, 'Invalid teams response');
@@ -24,7 +24,7 @@ AvroQueryClient.prototype._fetch = async function (method, path, body, cancelTok
24
24
  const options = {
25
25
  method,
26
26
  headers: requestHeaders,
27
- body: body ? JSON.stringify(body) : undefined,
27
+ body,
28
28
  };
29
29
  const response = await fetch(url, options);
30
30
  if (response.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.85",
3
+ "version": "0.0.2-beta.86",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",