@naturalcycles/js-lib 14.119.0 → 14.119.1

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.
@@ -124,8 +124,10 @@ export declare class Fetcher {
124
124
  static create(cfg?: FetcherCfg & FetcherOptions): Fetcher;
125
125
  getJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T>;
126
126
  postJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T>;
127
+ putJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T>;
128
+ patchJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T>;
129
+ deleteJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T>;
127
130
  getText(url: string, opt?: FetcherOptions): Promise<string>;
128
- postText(url: string, opt?: FetcherOptions): Promise<string>;
129
131
  fetch<T = unknown>(url: string, opt?: FetcherOptions): Promise<T>;
130
132
  rawFetch<T = unknown>(url: string, rawOpt?: FetcherOptions): Promise<FetcherResponse<T>>;
131
133
  private processRetry;
@@ -28,33 +28,47 @@ class Fetcher {
28
28
  static create(cfg = {}) {
29
29
  return new Fetcher(cfg);
30
30
  }
31
- async getJson(url, opt = {}) {
31
+ async getJson(url, opt) {
32
32
  return await this.fetch(url, {
33
33
  ...opt,
34
34
  mode: 'json',
35
35
  });
36
36
  }
37
- async postJson(url, opt = {}) {
37
+ async postJson(url, opt) {
38
38
  return await this.fetch(url, {
39
39
  ...opt,
40
40
  method: 'post',
41
41
  mode: 'json',
42
42
  });
43
43
  }
44
- async getText(url, opt = {}) {
44
+ async putJson(url, opt) {
45
45
  return await this.fetch(url, {
46
46
  ...opt,
47
- mode: 'text',
47
+ method: 'put',
48
+ mode: 'json',
48
49
  });
49
50
  }
50
- async postText(url, opt = {}) {
51
+ async patchJson(url, opt) {
52
+ return await this.fetch(url, {
53
+ ...opt,
54
+ method: 'patch',
55
+ mode: 'json',
56
+ });
57
+ }
58
+ async deleteJson(url, opt) {
59
+ return await this.fetch(url, {
60
+ ...opt,
61
+ method: 'delete',
62
+ mode: 'json',
63
+ });
64
+ }
65
+ async getText(url, opt) {
51
66
  return await this.fetch(url, {
52
67
  ...opt,
53
- method: 'post',
54
68
  mode: 'text',
55
69
  });
56
70
  }
57
- async fetch(url, opt = {}) {
71
+ async fetch(url, opt) {
58
72
  const res = await this.rawFetch(url, opt);
59
73
  if (res.err) {
60
74
  if (res.req.throwHttpErrors)
@@ -25,19 +25,25 @@ export class Fetcher {
25
25
  static create(cfg = {}) {
26
26
  return new Fetcher(cfg);
27
27
  }
28
- async getJson(url, opt = {}) {
28
+ async getJson(url, opt) {
29
29
  return await this.fetch(url, Object.assign(Object.assign({}, opt), { mode: 'json' }));
30
30
  }
31
- async postJson(url, opt = {}) {
31
+ async postJson(url, opt) {
32
32
  return await this.fetch(url, Object.assign(Object.assign({}, opt), { method: 'post', mode: 'json' }));
33
33
  }
34
- async getText(url, opt = {}) {
35
- return await this.fetch(url, Object.assign(Object.assign({}, opt), { mode: 'text' }));
34
+ async putJson(url, opt) {
35
+ return await this.fetch(url, Object.assign(Object.assign({}, opt), { method: 'put', mode: 'json' }));
36
+ }
37
+ async patchJson(url, opt) {
38
+ return await this.fetch(url, Object.assign(Object.assign({}, opt), { method: 'patch', mode: 'json' }));
36
39
  }
37
- async postText(url, opt = {}) {
38
- return await this.fetch(url, Object.assign(Object.assign({}, opt), { method: 'post', mode: 'text' }));
40
+ async deleteJson(url, opt) {
41
+ return await this.fetch(url, Object.assign(Object.assign({}, opt), { method: 'delete', mode: 'json' }));
42
+ }
43
+ async getText(url, opt) {
44
+ return await this.fetch(url, Object.assign(Object.assign({}, opt), { mode: 'text' }));
39
45
  }
40
- async fetch(url, opt = {}) {
46
+ async fetch(url, opt) {
41
47
  const res = await this.rawFetch(url, opt);
42
48
  if (res.err) {
43
49
  if (res.req.throwHttpErrors)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.119.0",
3
+ "version": "14.119.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -167,37 +167,49 @@ export class Fetcher {
167
167
  return new Fetcher(cfg)
168
168
  }
169
169
 
170
- async getJson<T = unknown>(url: string, opt: FetcherOptions = {}): Promise<T> {
170
+ async getJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T> {
171
171
  return await this.fetch<T>(url, {
172
172
  ...opt,
173
173
  mode: 'json',
174
174
  })
175
175
  }
176
-
177
- async postJson<T = unknown>(url: string, opt: FetcherOptions = {}): Promise<T> {
176
+ async postJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T> {
178
177
  return await this.fetch<T>(url, {
179
178
  ...opt,
180
179
  method: 'post',
181
180
  mode: 'json',
182
181
  })
183
182
  }
184
-
185
- async getText(url: string, opt: FetcherOptions = {}): Promise<string> {
186
- return await this.fetch<string>(url, {
183
+ async putJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T> {
184
+ return await this.fetch<T>(url, {
187
185
  ...opt,
188
- mode: 'text',
186
+ method: 'put',
187
+ mode: 'json',
188
+ })
189
+ }
190
+ async patchJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T> {
191
+ return await this.fetch<T>(url, {
192
+ ...opt,
193
+ method: 'patch',
194
+ mode: 'json',
195
+ })
196
+ }
197
+ async deleteJson<T = unknown>(url: string, opt?: FetcherOptions): Promise<T> {
198
+ return await this.fetch<T>(url, {
199
+ ...opt,
200
+ method: 'delete',
201
+ mode: 'json',
189
202
  })
190
203
  }
191
204
 
192
- async postText(url: string, opt: FetcherOptions = {}): Promise<string> {
205
+ async getText(url: string, opt?: FetcherOptions): Promise<string> {
193
206
  return await this.fetch<string>(url, {
194
207
  ...opt,
195
- method: 'post',
196
208
  mode: 'text',
197
209
  })
198
210
  }
199
211
 
200
- async fetch<T = unknown>(url: string, opt: FetcherOptions = {}): Promise<T> {
212
+ async fetch<T = unknown>(url: string, opt?: FetcherOptions): Promise<T> {
201
213
  const res = await this.rawFetch<T>(url, opt)
202
214
  if (res.err) {
203
215
  if (res.req.throwHttpErrors) throw res.err