@iamnnort/request 1.9.2 → 1.10.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.
package/dist/index.mjs CHANGED
@@ -1,40 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __await = function(promise, isYieldStar) {
21
- this[0] = promise;
22
- this[1] = isYieldStar;
23
- };
24
- var __asyncGenerator = (__this, __arguments, generator) => {
25
- var resume = (k, v, yes, no) => {
26
- try {
27
- var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
28
- Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
29
- } catch (e) {
30
- no(e);
31
- }
32
- };
33
- var method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no));
34
- var it = {};
35
- return generator = generator.apply(__this, __arguments), it[Symbol.asyncIterator] = () => it, method("next"), method("throw"), method("return"), it;
36
- };
37
-
38
1
  // src/builder.ts
39
2
  import { stringify } from "qs";
40
3
 
@@ -62,39 +25,50 @@ var HttpStatuses = /* @__PURE__ */ ((HttpStatuses2) => {
62
25
 
63
26
  // src/builder.ts
64
27
  var RequestBuilder = class {
28
+ baseConfig;
29
+ requestConfig;
30
+ config;
65
31
  constructor(params) {
66
32
  this.baseConfig = params.baseConfig;
67
33
  this.requestConfig = params.requestConfig;
68
34
  this.config = {
69
- headers: __spreadValues(__spreadValues({
35
+ headers: {
70
36
  Accept: "application/json",
71
- "Content-Type": "application/json"
72
- }, params.baseConfig.headers), params.requestConfig.headers)
37
+ "Content-Type": "application/json",
38
+ ...params.baseConfig.headers,
39
+ ...params.requestConfig.headers
40
+ }
73
41
  };
74
42
  }
75
43
  makeContentType() {
76
44
  if (this.requestConfig.multipart) {
77
- this.config = __spreadProps(__spreadValues({}, this.config), {
78
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
45
+ this.config = {
46
+ ...this.config,
47
+ headers: {
48
+ ...this.config.headers,
79
49
  "Content-Type": "multipart/form-data"
80
- })
81
- });
50
+ }
51
+ };
82
52
  return this;
83
53
  }
84
54
  if (this.requestConfig.urlencoded) {
85
- this.config = __spreadProps(__spreadValues({}, this.config), {
86
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
55
+ this.config = {
56
+ ...this.config,
57
+ headers: {
58
+ ...this.config.headers,
87
59
  "Content-Type": "application/x-www-form-urlencoded"
88
- })
89
- });
60
+ }
61
+ };
90
62
  return this;
91
63
  }
92
64
  if (this.requestConfig.xml) {
93
- this.config = __spreadProps(__spreadValues({}, this.config), {
94
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
65
+ this.config = {
66
+ ...this.config,
67
+ headers: {
68
+ ...this.config.headers,
95
69
  "Content-Type": "text/xml"
96
- })
97
- });
70
+ }
71
+ };
98
72
  return this;
99
73
  }
100
74
  return this;
@@ -102,27 +76,32 @@ var RequestBuilder = class {
102
76
  makeAuth() {
103
77
  const auth = this.requestConfig.auth || this.baseConfig.auth;
104
78
  if (auth) {
105
- this.config = __spreadProps(__spreadValues({}, this.config), {
79
+ this.config = {
80
+ ...this.config,
106
81
  auth
107
- });
82
+ };
108
83
  return this;
109
84
  }
110
85
  const bearerToken = this.requestConfig.bearerToken || this.baseConfig.bearerToken;
111
86
  if (bearerToken) {
112
- this.config = __spreadProps(__spreadValues({}, this.config), {
113
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
87
+ this.config = {
88
+ ...this.config,
89
+ headers: {
90
+ ...this.config.headers,
114
91
  Authorization: `Bearer ${bearerToken}`
115
- })
116
- });
92
+ }
93
+ };
117
94
  return this;
118
95
  }
119
96
  const apiKey = this.requestConfig.apiKey || this.baseConfig.apiKey;
120
97
  if (apiKey) {
121
- this.config = __spreadProps(__spreadValues({}, this.config), {
122
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
98
+ this.config = {
99
+ ...this.config,
100
+ headers: {
101
+ ...this.config.headers,
123
102
  "x-api-key": apiKey
124
- })
125
- });
103
+ }
104
+ };
126
105
  return this;
127
106
  }
128
107
  return this;
@@ -137,24 +116,24 @@ var RequestBuilder = class {
137
116
  this.requestConfig.baseUrl,
138
117
  this.requestConfig.url,
139
118
  ...this.requestConfig.urlParts || []
140
- ].map((urlPart) => urlPart == null ? void 0 : urlPart.toString());
141
- const isSecureProtocol = urlParts.some(
142
- (urlPart) => urlPart == null ? void 0 : urlPart.includes("https")
143
- );
119
+ ].map((urlPart) => urlPart?.toString());
120
+ const isSecureProtocol = urlParts.some((urlPart) => urlPart?.includes("https"));
144
121
  const protocol = isSecureProtocol ? "https" : "http";
145
122
  const actualUrlParts = urlParts.filter((urlPart) => urlPart).map((urlPart) => {
146
- return urlPart == null ? void 0 : urlPart.replace(/^(https?:\/\/|\/)?(.*?)(\/?)$/, "$2");
123
+ return urlPart?.replace(/^(https?:\/\/|\/)?(.*?)(\/?)$/, "$2");
147
124
  });
148
125
  const url = `${protocol}://${actualUrlParts.join("/")}`;
149
- this.config = __spreadProps(__spreadValues({}, this.config), {
126
+ this.config = {
127
+ ...this.config,
150
128
  url
151
- });
129
+ };
152
130
  return this;
153
131
  }
154
132
  makeMethod() {
155
- this.config = __spreadProps(__spreadValues({}, this.config), {
133
+ this.config = {
134
+ ...this.config,
156
135
  method: this.requestConfig.method
157
- });
136
+ };
158
137
  return this;
159
138
  }
160
139
  makeData() {
@@ -162,31 +141,34 @@ var RequestBuilder = class {
162
141
  return this;
163
142
  }
164
143
  if (this.requestConfig.urlencoded) {
165
- this.config = __spreadProps(__spreadValues({}, this.config), {
144
+ this.config = {
145
+ ...this.config,
166
146
  data: stringify(this.requestConfig.data)
167
- });
147
+ };
168
148
  return this;
169
149
  }
170
- this.config = __spreadProps(__spreadValues({}, this.config), {
150
+ this.config = {
151
+ ...this.config,
171
152
  data: this.requestConfig.data
172
- });
153
+ };
173
154
  return this;
174
155
  }
175
156
  makeParams() {
176
- this.config = __spreadProps(__spreadValues({}, this.config), {
157
+ this.config = {
158
+ ...this.config,
177
159
  params: this.requestConfig.params
178
- });
160
+ };
179
161
  return this;
180
162
  }
181
163
  makeSerializer() {
182
- this.config = __spreadProps(__spreadValues({}, this.config), {
164
+ this.config = {
165
+ ...this.config,
183
166
  paramsSerializer: (params) => {
184
- var _a;
185
167
  return stringify(params, {
186
- arrayFormat: (_a = this.baseConfig.serializer) == null ? void 0 : _a.array
168
+ arrayFormat: this.baseConfig.serializer?.array
187
169
  });
188
170
  }
189
- });
171
+ };
190
172
  return this;
191
173
  }
192
174
  build() {
@@ -197,246 +179,283 @@ var RequestBuilder = class {
197
179
  // src/data-source.ts
198
180
  import axios from "axios";
199
181
 
200
- // src/logger/logger.ts
182
+ // src/logger/builder.ts
201
183
  import { stringify as stringify2 } from "qs";
202
- var makeType = (type) => {
203
- return `[${type}]`;
204
- };
205
- var makeUrl = (dto = {}) => {
206
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
207
- const url = ((_a = dto.request) == null ? void 0 : _a.url) || ((_c = (_b = dto.response) == null ? void 0 : _b.config) == null ? void 0 : _c.url) || ((_e = (_d = dto.error) == null ? void 0 : _d.response) == null ? void 0 : _e.config.url);
208
- const params = ((_f = dto.request) == null ? void 0 : _f.params) || ((_h = (_g = dto.response) == null ? void 0 : _g.config) == null ? void 0 : _h.params) || ((_j = (_i = dto.error) == null ? void 0 : _i.response) == null ? void 0 : _j.config.params);
209
- if (!url) {
210
- return "";
211
- }
212
- if (params) {
213
- delete params["0"];
214
- return [url, stringify2(params)].filter((_) => _).join("?");
215
- } else {
216
- return url;
184
+ var MessageBuilder = class {
185
+ printQueue;
186
+ request;
187
+ response;
188
+ error;
189
+ constructor() {
190
+ this.printQueue = [];
217
191
  }
218
- };
219
- var makeMethod = (dto = {}) => {
220
- var _a, _b, _c, _d, _e;
221
- const method = ((_a = dto.request) == null ? void 0 : _a.method) || ((_c = (_b = dto.response) == null ? void 0 : _b.config) == null ? void 0 : _c.method) || ((_e = (_d = dto.error) == null ? void 0 : _d.response) == null ? void 0 : _e.config.method);
222
- if (!method) {
223
- return "get" /* GET */;
192
+ setRequest(request) {
193
+ this.request = request;
194
+ return this;
224
195
  }
225
- return method.toLowerCase();
226
- };
227
- var makeMethodText = (dto = {}) => {
228
- var _a, _b, _c, _d, _e;
229
- const method = ((_a = dto.request) == null ? void 0 : _a.method) || ((_c = (_b = dto.response) == null ? void 0 : _b.config) == null ? void 0 : _c.method) || ((_e = (_d = dto.error) == null ? void 0 : _d.response) == null ? void 0 : _e.config.method);
230
- if (!method) {
231
- return "";
196
+ setResponse(response) {
197
+ this.response = response;
198
+ return this;
232
199
  }
233
- return method.toUpperCase();
234
- };
235
- var makeRequestData = (dto = {}) => {
236
- var _a, _b, _c, _d, _e, _f;
237
- const data = ((_a = dto.request) == null ? void 0 : _a.body) || ((_b = dto.request) == null ? void 0 : _b.data) || ((_d = (_c = dto.response) == null ? void 0 : _c.config) == null ? void 0 : _d.data) || ((_f = (_e = dto.error) == null ? void 0 : _e.response) == null ? void 0 : _f.config.data);
238
- if (!data) {
239
- return "";
200
+ setError(error) {
201
+ this.error = error;
202
+ return this;
240
203
  }
241
- if (typeof data === "string") {
242
- return data;
204
+ makeType(type) {
205
+ this.printQueue.push(`[${type}]`);
206
+ return this;
243
207
  }
244
- return JSON.stringify(data);
245
- };
246
- var makeResponseData = (dto = {}) => {
247
- var _a, _b, _c;
248
- const data = ((_a = dto.response) == null ? void 0 : _a.data) || ((_c = (_b = dto.error) == null ? void 0 : _b.response) == null ? void 0 : _c.data);
249
- if (!data) {
250
- return "";
208
+ makeUrl() {
209
+ const url = this.request?.url || this.response?.config?.url || this.error?.response?.config.url;
210
+ const params = this.request?.params || this.response?.config?.params || this.error?.response?.config.params;
211
+ if (url) {
212
+ if (params) {
213
+ delete params["0"];
214
+ this.printQueue.push([url, stringify2(params)].filter((_) => _).join("?"));
215
+ } else {
216
+ this.printQueue.push(url);
217
+ }
218
+ }
219
+ return this;
251
220
  }
252
- if (typeof data === "string") {
253
- return data;
221
+ makeMethodText() {
222
+ const method = this.request?.method || this.response?.config?.method || this.error?.response?.config.method;
223
+ if (method) {
224
+ this.printQueue.push(method.toUpperCase());
225
+ }
226
+ return this;
254
227
  }
255
- return JSON.stringify(data);
256
- };
257
- var makeStatus = (dto = {}) => {
258
- var _a, _b, _c;
259
- const status = ((_a = dto.response) == null ? void 0 : _a.status) || ((_c = (_b = dto.error) == null ? void 0 : _b.response) == null ? void 0 : _c.status);
260
- if (!status) {
261
- return 500 /* INTERNAL_SERVER_ERROR */;
228
+ makeRequestData() {
229
+ const data = this.request?.data || this.response?.config?.data || this.error?.response?.config.data;
230
+ if (data) {
231
+ if (typeof data === "string") {
232
+ this.printQueue.push(data);
233
+ return this;
234
+ }
235
+ if (Object.keys(data).length) {
236
+ this.printQueue.push(JSON.stringify(data));
237
+ return this;
238
+ }
239
+ }
240
+ return this;
262
241
  }
263
- return status;
264
- };
265
- var makeStatusText = (dto = {}) => {
266
- var _a, _b, _c, _d, _e, _f;
267
- const status = ((_a = dto.response) == null ? void 0 : _a.status) || ((_c = (_b = dto.error) == null ? void 0 : _b.response) == null ? void 0 : _c.status);
268
- if (!status) {
269
- return "";
242
+ makeResponseDataText() {
243
+ const data = this.response?.data || this.error?.response?.data;
244
+ if (data) {
245
+ if (typeof data === "string") {
246
+ this.printQueue.push(data);
247
+ return this;
248
+ }
249
+ if (Object.keys(data).length) {
250
+ this.printQueue.push(JSON.stringify(data));
251
+ return this;
252
+ }
253
+ }
254
+ return this;
270
255
  }
271
- const statusText = ((_d = dto.response) == null ? void 0 : _d.statusText) || ((_f = (_e = dto.error) == null ? void 0 : _e.response) == null ? void 0 : _f.statusText);
272
- if (statusText) {
273
- return `${status} ${statusText}`;
256
+ makeStatusText() {
257
+ const status = this.response?.status || this.error?.response?.status;
258
+ if (status) {
259
+ this.printQueue.push(`${status}`);
260
+ const statusText = this.response?.statusText || this.error?.response?.statusText;
261
+ if (statusText) {
262
+ this.printQueue.push(statusText);
263
+ }
264
+ }
265
+ return this;
266
+ }
267
+ build() {
268
+ return this.printQueue.join(" ");
269
+ }
270
+ makeMethod() {
271
+ const method = this.request?.method || this.response?.config?.method || this.error?.response?.config.method;
272
+ if (!method) {
273
+ return "get" /* GET */;
274
+ }
275
+ return method.toLowerCase();
276
+ }
277
+ makeResponseData() {
278
+ const data = this.response?.data || this.error?.response?.data;
279
+ if (!data) {
280
+ return "";
281
+ }
282
+ if (typeof data === "string") {
283
+ return data;
284
+ }
285
+ return JSON.stringify(data);
286
+ }
287
+ makeStatus() {
288
+ const status = this.response?.status || this.error?.response?.status;
289
+ if (!status) {
290
+ return 500 /* INTERNAL_SERVER_ERROR */;
291
+ }
292
+ return status;
293
+ }
294
+ makeResponse() {
295
+ return {
296
+ success: this.error === void 0,
297
+ status: this.makeStatus(),
298
+ method: this.makeMethod(),
299
+ data: this.makeResponseData()
300
+ };
274
301
  }
275
- return `${status}`;
276
- };
277
- var makeResponse = (dto = {}) => {
278
- return {
279
- success: dto.error === void 0,
280
- status: makeStatus(dto),
281
- method: makeMethod(dto),
282
- data: makeResponseData(dto)
283
- };
284
- };
285
- var logRequest = (request) => {
286
- log([
287
- makeType("Request"),
288
- makeMethodText({ request }),
289
- makeUrl({ request }),
290
- makeRequestData({ request })
291
- ]);
292
- };
293
- var logResponse = (response) => {
294
- log([
295
- makeType("Response"),
296
- makeMethodText({ response }),
297
- makeUrl({ response }),
298
- makeRequestData({ response }),
299
- makeStatusText({ response }),
300
- makeResponseData({ response })
301
- ]);
302
- };
303
- var logRequestError = (error) => {
304
- log([
305
- makeType("Error"),
306
- makeMethodText({ error }),
307
- makeUrl({ error }),
308
- makeRequestData({ error }),
309
- makeStatusText({ error }),
310
- makeResponseData({ error })
311
- ]);
312
- };
313
- var log = (messageParts) => {
314
- const message = messageParts.filter((_) => _).join(" ");
315
- console.log(message);
316
302
  };
317
- var loggerHelper = {
318
- makeType,
319
- makeUrl,
320
- makeMethod,
321
- makeMethodText,
322
- makeRequestData,
323
- makeResponseData,
324
- makeStatus,
325
- makeStatusText,
326
- makeResponse,
327
- logRequest,
328
- logResponse,
329
- logRequestError
303
+
304
+ // src/logger/service.ts
305
+ var LoggerService = class {
306
+ context = "";
307
+ constructor(context = "") {
308
+ this.context = context;
309
+ }
310
+ log(message, context) {
311
+ const ctx = context || this.context || "";
312
+ if (ctx) {
313
+ return console.log(`[${ctx}] ${message}`);
314
+ }
315
+ return console.log(message);
316
+ }
317
+ logRequest(request) {
318
+ const loggerMessageBuilder = new MessageBuilder();
319
+ const message = loggerMessageBuilder.setRequest(request).makeType("Request").makeMethodText().makeUrl().makeRequestData().build();
320
+ return this.log(message);
321
+ }
322
+ logResponse(response) {
323
+ const loggerMessageBuilder = new MessageBuilder();
324
+ const message = loggerMessageBuilder.setResponse(response).makeType("Response").makeMethodText().makeUrl().makeRequestData().makeStatusText().makeResponseDataText().build();
325
+ return this.log(message);
326
+ }
327
+ logRequestError(error) {
328
+ const loggerMessageBuilder = new MessageBuilder();
329
+ const message = loggerMessageBuilder.setError(error).makeType("Error").makeMethodText().makeUrl().makeRequestData().makeStatusText().makeResponseDataText().build();
330
+ return this.log(message);
331
+ }
332
+ makeResponse(response) {
333
+ const loggerMessageBuilder = new MessageBuilder();
334
+ const responseData = loggerMessageBuilder.setResponse(response).makeResponse();
335
+ return responseData;
336
+ }
337
+ makeErrorResponse(error) {
338
+ const loggerMessageBuilder = new MessageBuilder();
339
+ const errorResponseData = loggerMessageBuilder.setError(error).makeResponse();
340
+ return errorResponseData;
341
+ }
330
342
  };
331
343
 
332
344
  // src/data-source.ts
333
345
  var RequestDataSource = class {
346
+ baseRequestConfig;
334
347
  constructor(baseRequestConfig) {
335
348
  this.baseRequestConfig = baseRequestConfig;
336
349
  }
337
350
  common(requestConfig, responseConfig = {}) {
351
+ const loggerService = new LoggerService(this.baseRequestConfig.name);
338
352
  const requestBuilder = new RequestBuilder({
339
353
  baseConfig: this.baseRequestConfig,
340
354
  requestConfig
341
355
  });
342
356
  const request = requestBuilder.makeContentType().makeAuth().makeUrl().makeMethod().makeParams().makeData().makeSerializer().build();
343
357
  if (this.baseRequestConfig.logger) {
344
- loggerHelper.logRequest(request);
358
+ loggerService.logRequest(request);
345
359
  }
346
360
  return axios.request(request).then((response) => {
347
361
  if (this.baseRequestConfig.logger) {
348
- loggerHelper.logResponse(response);
362
+ loggerService.logResponse(response);
349
363
  }
350
364
  if (responseConfig.raw) {
351
- return loggerHelper.makeResponse({ response });
365
+ return loggerService.makeResponse(response);
352
366
  }
353
367
  return response.data;
354
368
  }).catch((error) => {
355
- var _a;
356
369
  if (this.baseRequestConfig.debug) {
357
370
  console.log("Error:", error);
358
371
  }
359
372
  if (this.baseRequestConfig.logger) {
360
- loggerHelper.logRequestError(error);
373
+ loggerService.logRequestError(error);
361
374
  }
362
375
  if (responseConfig.raw) {
363
- return loggerHelper.makeResponse({ error });
376
+ return loggerService.makeErrorResponse(error);
364
377
  }
365
- throw ((_a = error.response) == null ? void 0 : _a.data) || error.response || new Error(error.message);
378
+ throw error.response?.data || error.response || new Error(error.message);
366
379
  });
367
380
  }
368
381
  search(config = {}) {
369
- return this.common(__spreadProps(__spreadValues({}, config), {
382
+ return this.common({
383
+ ...config,
370
384
  method: "get" /* GET */
371
- }));
372
- }
373
- bulkSearch() {
374
- return __asyncGenerator(this, arguments, function* (config = {}) {
375
- var _a, _b, _c;
376
- let pagination = {
377
- total: 0,
378
- currentPage: ((_a = config.params) == null ? void 0 : _a.page) || 0,
379
- lastPage: 0,
380
- from: 0,
381
- to: 0,
382
- pageSize: ((_b = config.params) == null ? void 0 : _b.pageSize) || 30
383
- };
384
- do {
385
- const response = yield new __await(this.common(__spreadProps(__spreadValues({}, config), {
386
- method: "get" /* GET */,
387
- params: __spreadProps(__spreadValues({}, config.params), {
388
- page: pagination.currentPage + 1,
389
- pageSize: pagination.pageSize
390
- })
391
- })));
392
- if (!((_c = response.data) == null ? void 0 : _c.length)) {
393
- return [];
394
- }
395
- yield response.data;
396
- pagination = response.pagination;
397
- } while (pagination.currentPage !== pagination.lastPage);
398
385
  });
399
386
  }
387
+ async *bulkSearch(config = {}) {
388
+ let pagination = {
389
+ total: 0,
390
+ currentPage: config.params?.page || 0,
391
+ lastPage: 0,
392
+ from: 0,
393
+ to: 0,
394
+ pageSize: config.params?.pageSize || 30
395
+ };
396
+ do {
397
+ const response = await this.common({
398
+ ...config,
399
+ method: "get" /* GET */,
400
+ params: {
401
+ ...config.params,
402
+ page: pagination.currentPage + 1,
403
+ pageSize: pagination.pageSize
404
+ }
405
+ });
406
+ if (!response.data?.length) {
407
+ return [];
408
+ }
409
+ yield response.data;
410
+ pagination = response.pagination;
411
+ } while (pagination.currentPage !== pagination.lastPage);
412
+ }
400
413
  get(id, config = {}) {
401
- return this.common(__spreadProps(__spreadValues({}, config), {
414
+ return this.common({
415
+ ...config,
402
416
  method: "get" /* GET */,
403
417
  url: id
404
- }));
418
+ });
405
419
  }
406
420
  create(config) {
407
- return this.common(__spreadProps(__spreadValues({}, config), {
421
+ return this.common({
422
+ ...config,
408
423
  method: "post" /* POST */
409
- }));
424
+ });
410
425
  }
411
426
  bulkCreate(config) {
412
- return this.common(__spreadProps(__spreadValues({}, config), {
427
+ return this.common({
428
+ ...config,
413
429
  method: "post" /* POST */,
414
430
  url: "/bulk",
415
431
  data: {
416
432
  bulk: config.data
417
433
  }
418
- }));
434
+ });
419
435
  }
420
436
  update(id, config) {
421
- return this.common(__spreadProps(__spreadValues({}, config), {
437
+ return this.common({
438
+ ...config,
422
439
  method: "put" /* PUT */,
423
440
  url: id
424
- }));
441
+ });
425
442
  }
426
443
  bulkUpdate(config) {
427
- return this.common(__spreadProps(__spreadValues({}, config), {
444
+ return this.common({
445
+ ...config,
428
446
  method: "put" /* PUT */,
429
447
  url: "/bulk",
430
448
  data: {
431
449
  bulk: config.data
432
450
  }
433
- }));
451
+ });
434
452
  }
435
453
  remove(id, config = {}) {
436
- return this.common(__spreadProps(__spreadValues({}, config), {
454
+ return this.common({
455
+ ...config,
437
456
  method: "delete" /* DELETE */,
438
457
  url: id
439
- }));
458
+ });
440
459
  }
441
460
  };
442
461