@iamnnort/request 1.9.2 → 1.10.0

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.d.mts CHANGED
@@ -106,4 +106,4 @@ declare class RequestHelper {
106
106
  sleep(seconds: number): Promise<unknown>;
107
107
  }
108
108
 
109
- export { BaseRequestConfig, HttpMethods, HttpStatuses, Pagination, PaginationResponse, RawResponse, RequestBuilder, RequestConfig, RequestConfigParams, RequestDataSource, RequestHelper, RequestParams, ResponseConfig };
109
+ export { type BaseRequestConfig, HttpMethods, HttpStatuses, type Pagination, type PaginationResponse, type RawResponse, RequestBuilder, type RequestConfig, type RequestConfigParams, RequestDataSource, RequestHelper, type RequestParams, type ResponseConfig };
package/dist/index.d.ts CHANGED
@@ -106,4 +106,4 @@ declare class RequestHelper {
106
106
  sleep(seconds: number): Promise<unknown>;
107
107
  }
108
108
 
109
- export { BaseRequestConfig, HttpMethods, HttpStatuses, Pagination, PaginationResponse, RawResponse, RequestBuilder, RequestConfig, RequestConfigParams, RequestDataSource, RequestHelper, RequestParams, ResponseConfig };
109
+ export { type BaseRequestConfig, HttpMethods, HttpStatuses, type Pagination, type PaginationResponse, type RawResponse, RequestBuilder, type RequestConfig, type RequestConfigParams, RequestDataSource, RequestHelper, type RequestParams, type ResponseConfig };
package/dist/index.js CHANGED
@@ -1,79 +1,5 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __export = (target, all) => {
26
- for (var name in all)
27
- __defProp(target, name, { get: all[name], enumerable: true });
28
- };
29
- var __copyProps = (to, from, except, desc) => {
30
- if (from && typeof from === "object" || typeof from === "function") {
31
- for (let key of __getOwnPropNames(from))
32
- if (!__hasOwnProp.call(to, key) && key !== except)
33
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
- }
35
- return to;
36
- };
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
- // If the importer is in node compatibility mode or this is not an ESM
39
- // file that has been converted to a CommonJS file using a Babel-
40
- // compatible transform (i.e. "__esModule" has not been set), then set
41
- // "default" to the CommonJS "module.exports" for node compatibility.
42
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
- mod
44
- ));
45
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
- var __await = function(promise, isYieldStar) {
47
- this[0] = promise;
48
- this[1] = isYieldStar;
49
- };
50
- var __asyncGenerator = (__this, __arguments, generator) => {
51
- var resume = (k, v, yes, no) => {
52
- try {
53
- var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
54
- 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));
55
- } catch (e) {
56
- no(e);
57
- }
58
- };
59
- var method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no));
60
- var it = {};
61
- return generator = generator.apply(__this, __arguments), it[Symbol.asyncIterator] = () => it, method("next"), method("throw"), method("return"), it;
62
- };
63
-
64
- // src/index.ts
65
- var src_exports = {};
66
- __export(src_exports, {
67
- HttpMethods: () => HttpMethods,
68
- HttpStatuses: () => HttpStatuses,
69
- RequestBuilder: () => RequestBuilder,
70
- RequestDataSource: () => RequestDataSource,
71
- RequestHelper: () => RequestHelper
72
- });
73
- module.exports = __toCommonJS(src_exports);
74
-
75
- // src/builder.ts
76
- var import_qs = require("qs");
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/builder.ts
2
+ var _qs = require('qs');
77
3
 
78
4
  // src/types.ts
79
5
  var HttpMethods = /* @__PURE__ */ ((HttpMethods2) => {
@@ -99,39 +25,50 @@ var HttpStatuses = /* @__PURE__ */ ((HttpStatuses2) => {
99
25
 
100
26
  // src/builder.ts
101
27
  var RequestBuilder = class {
28
+
29
+
30
+
102
31
  constructor(params) {
103
32
  this.baseConfig = params.baseConfig;
104
33
  this.requestConfig = params.requestConfig;
105
34
  this.config = {
106
- headers: __spreadValues(__spreadValues({
35
+ headers: {
107
36
  Accept: "application/json",
108
- "Content-Type": "application/json"
109
- }, params.baseConfig.headers), params.requestConfig.headers)
37
+ "Content-Type": "application/json",
38
+ ...params.baseConfig.headers,
39
+ ...params.requestConfig.headers
40
+ }
110
41
  };
111
42
  }
112
43
  makeContentType() {
113
44
  if (this.requestConfig.multipart) {
114
- this.config = __spreadProps(__spreadValues({}, this.config), {
115
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
45
+ this.config = {
46
+ ...this.config,
47
+ headers: {
48
+ ...this.config.headers,
116
49
  "Content-Type": "multipart/form-data"
117
- })
118
- });
50
+ }
51
+ };
119
52
  return this;
120
53
  }
121
54
  if (this.requestConfig.urlencoded) {
122
- this.config = __spreadProps(__spreadValues({}, this.config), {
123
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
55
+ this.config = {
56
+ ...this.config,
57
+ headers: {
58
+ ...this.config.headers,
124
59
  "Content-Type": "application/x-www-form-urlencoded"
125
- })
126
- });
60
+ }
61
+ };
127
62
  return this;
128
63
  }
129
64
  if (this.requestConfig.xml) {
130
- this.config = __spreadProps(__spreadValues({}, this.config), {
131
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
65
+ this.config = {
66
+ ...this.config,
67
+ headers: {
68
+ ...this.config.headers,
132
69
  "Content-Type": "text/xml"
133
- })
134
- });
70
+ }
71
+ };
135
72
  return this;
136
73
  }
137
74
  return this;
@@ -139,27 +76,32 @@ var RequestBuilder = class {
139
76
  makeAuth() {
140
77
  const auth = this.requestConfig.auth || this.baseConfig.auth;
141
78
  if (auth) {
142
- this.config = __spreadProps(__spreadValues({}, this.config), {
79
+ this.config = {
80
+ ...this.config,
143
81
  auth
144
- });
82
+ };
145
83
  return this;
146
84
  }
147
85
  const bearerToken = this.requestConfig.bearerToken || this.baseConfig.bearerToken;
148
86
  if (bearerToken) {
149
- this.config = __spreadProps(__spreadValues({}, this.config), {
150
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
87
+ this.config = {
88
+ ...this.config,
89
+ headers: {
90
+ ...this.config.headers,
151
91
  Authorization: `Bearer ${bearerToken}`
152
- })
153
- });
92
+ }
93
+ };
154
94
  return this;
155
95
  }
156
96
  const apiKey = this.requestConfig.apiKey || this.baseConfig.apiKey;
157
97
  if (apiKey) {
158
- this.config = __spreadProps(__spreadValues({}, this.config), {
159
- headers: __spreadProps(__spreadValues({}, this.config.headers), {
98
+ this.config = {
99
+ ...this.config,
100
+ headers: {
101
+ ...this.config.headers,
160
102
  "x-api-key": apiKey
161
- })
162
- });
103
+ }
104
+ };
163
105
  return this;
164
106
  }
165
107
  return this;
@@ -174,24 +116,24 @@ var RequestBuilder = class {
174
116
  this.requestConfig.baseUrl,
175
117
  this.requestConfig.url,
176
118
  ...this.requestConfig.urlParts || []
177
- ].map((urlPart) => urlPart == null ? void 0 : urlPart.toString());
178
- const isSecureProtocol = urlParts.some(
179
- (urlPart) => urlPart == null ? void 0 : urlPart.includes("https")
180
- );
119
+ ].map((urlPart) => _optionalChain([urlPart, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()]));
120
+ const isSecureProtocol = urlParts.some((urlPart) => _optionalChain([urlPart, 'optionalAccess', _4 => _4.includes, 'call', _5 => _5("https")]));
181
121
  const protocol = isSecureProtocol ? "https" : "http";
182
122
  const actualUrlParts = urlParts.filter((urlPart) => urlPart).map((urlPart) => {
183
- return urlPart == null ? void 0 : urlPart.replace(/^(https?:\/\/|\/)?(.*?)(\/?)$/, "$2");
123
+ return _optionalChain([urlPart, 'optionalAccess', _6 => _6.replace, 'call', _7 => _7(/^(https?:\/\/|\/)?(.*?)(\/?)$/, "$2")]);
184
124
  });
185
125
  const url = `${protocol}://${actualUrlParts.join("/")}`;
186
- this.config = __spreadProps(__spreadValues({}, this.config), {
126
+ this.config = {
127
+ ...this.config,
187
128
  url
188
- });
129
+ };
189
130
  return this;
190
131
  }
191
132
  makeMethod() {
192
- this.config = __spreadProps(__spreadValues({}, this.config), {
133
+ this.config = {
134
+ ...this.config,
193
135
  method: this.requestConfig.method
194
- });
136
+ };
195
137
  return this;
196
138
  }
197
139
  makeData() {
@@ -199,31 +141,34 @@ var RequestBuilder = class {
199
141
  return this;
200
142
  }
201
143
  if (this.requestConfig.urlencoded) {
202
- this.config = __spreadProps(__spreadValues({}, this.config), {
203
- data: (0, import_qs.stringify)(this.requestConfig.data)
204
- });
144
+ this.config = {
145
+ ...this.config,
146
+ data: _qs.stringify.call(void 0, this.requestConfig.data)
147
+ };
205
148
  return this;
206
149
  }
207
- this.config = __spreadProps(__spreadValues({}, this.config), {
150
+ this.config = {
151
+ ...this.config,
208
152
  data: this.requestConfig.data
209
- });
153
+ };
210
154
  return this;
211
155
  }
212
156
  makeParams() {
213
- this.config = __spreadProps(__spreadValues({}, this.config), {
157
+ this.config = {
158
+ ...this.config,
214
159
  params: this.requestConfig.params
215
- });
160
+ };
216
161
  return this;
217
162
  }
218
163
  makeSerializer() {
219
- this.config = __spreadProps(__spreadValues({}, this.config), {
164
+ this.config = {
165
+ ...this.config,
220
166
  paramsSerializer: (params) => {
221
- var _a;
222
- return (0, import_qs.stringify)(params, {
223
- arrayFormat: (_a = this.baseConfig.serializer) == null ? void 0 : _a.array
167
+ return _qs.stringify.call(void 0, params, {
168
+ arrayFormat: _optionalChain([this, 'access', _8 => _8.baseConfig, 'access', _9 => _9.serializer, 'optionalAccess', _10 => _10.array])
224
169
  });
225
170
  }
226
- });
171
+ };
227
172
  return this;
228
173
  }
229
174
  build() {
@@ -232,46 +177,42 @@ var RequestBuilder = class {
232
177
  };
233
178
 
234
179
  // src/data-source.ts
235
- var import_axios = __toESM(require("axios"));
180
+ var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
236
181
 
237
182
  // src/logger/logger.ts
238
- var import_qs2 = require("qs");
183
+
239
184
  var makeType = (type) => {
240
185
  return `[${type}]`;
241
186
  };
242
187
  var makeUrl = (dto = {}) => {
243
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
244
- 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);
245
- 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);
188
+ const url = _optionalChain([dto, 'access', _11 => _11.request, 'optionalAccess', _12 => _12.url]) || _optionalChain([dto, 'access', _13 => _13.response, 'optionalAccess', _14 => _14.config, 'optionalAccess', _15 => _15.url]) || _optionalChain([dto, 'access', _16 => _16.error, 'optionalAccess', _17 => _17.response, 'optionalAccess', _18 => _18.config, 'access', _19 => _19.url]);
189
+ const params = _optionalChain([dto, 'access', _20 => _20.request, 'optionalAccess', _21 => _21.params]) || _optionalChain([dto, 'access', _22 => _22.response, 'optionalAccess', _23 => _23.config, 'optionalAccess', _24 => _24.params]) || _optionalChain([dto, 'access', _25 => _25.error, 'optionalAccess', _26 => _26.response, 'optionalAccess', _27 => _27.config, 'access', _28 => _28.params]);
246
190
  if (!url) {
247
191
  return "";
248
192
  }
249
193
  if (params) {
250
194
  delete params["0"];
251
- return [url, (0, import_qs2.stringify)(params)].filter((_) => _).join("?");
195
+ return [url, _qs.stringify.call(void 0, params)].filter((_) => _).join("?");
252
196
  } else {
253
197
  return url;
254
198
  }
255
199
  };
256
200
  var makeMethod = (dto = {}) => {
257
- var _a, _b, _c, _d, _e;
258
- 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);
201
+ const method = _optionalChain([dto, 'access', _29 => _29.request, 'optionalAccess', _30 => _30.method]) || _optionalChain([dto, 'access', _31 => _31.response, 'optionalAccess', _32 => _32.config, 'optionalAccess', _33 => _33.method]) || _optionalChain([dto, 'access', _34 => _34.error, 'optionalAccess', _35 => _35.response, 'optionalAccess', _36 => _36.config, 'access', _37 => _37.method]);
259
202
  if (!method) {
260
203
  return "get" /* GET */;
261
204
  }
262
205
  return method.toLowerCase();
263
206
  };
264
207
  var makeMethodText = (dto = {}) => {
265
- var _a, _b, _c, _d, _e;
266
- 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);
208
+ const method = _optionalChain([dto, 'access', _38 => _38.request, 'optionalAccess', _39 => _39.method]) || _optionalChain([dto, 'access', _40 => _40.response, 'optionalAccess', _41 => _41.config, 'optionalAccess', _42 => _42.method]) || _optionalChain([dto, 'access', _43 => _43.error, 'optionalAccess', _44 => _44.response, 'optionalAccess', _45 => _45.config, 'access', _46 => _46.method]);
267
209
  if (!method) {
268
210
  return "";
269
211
  }
270
212
  return method.toUpperCase();
271
213
  };
272
214
  var makeRequestData = (dto = {}) => {
273
- var _a, _b, _c, _d, _e, _f;
274
- 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);
215
+ const data = _optionalChain([dto, 'access', _47 => _47.request, 'optionalAccess', _48 => _48.body]) || _optionalChain([dto, 'access', _49 => _49.request, 'optionalAccess', _50 => _50.data]) || _optionalChain([dto, 'access', _51 => _51.response, 'optionalAccess', _52 => _52.config, 'optionalAccess', _53 => _53.data]) || _optionalChain([dto, 'access', _54 => _54.error, 'optionalAccess', _55 => _55.response, 'optionalAccess', _56 => _56.config, 'access', _57 => _57.data]);
275
216
  if (!data) {
276
217
  return "";
277
218
  }
@@ -281,8 +222,7 @@ var makeRequestData = (dto = {}) => {
281
222
  return JSON.stringify(data);
282
223
  };
283
224
  var makeResponseData = (dto = {}) => {
284
- var _a, _b, _c;
285
- const data = ((_a = dto.response) == null ? void 0 : _a.data) || ((_c = (_b = dto.error) == null ? void 0 : _b.response) == null ? void 0 : _c.data);
225
+ const data = _optionalChain([dto, 'access', _58 => _58.response, 'optionalAccess', _59 => _59.data]) || _optionalChain([dto, 'access', _60 => _60.error, 'optionalAccess', _61 => _61.response, 'optionalAccess', _62 => _62.data]);
286
226
  if (!data) {
287
227
  return "";
288
228
  }
@@ -292,20 +232,18 @@ var makeResponseData = (dto = {}) => {
292
232
  return JSON.stringify(data);
293
233
  };
294
234
  var makeStatus = (dto = {}) => {
295
- var _a, _b, _c;
296
- const status = ((_a = dto.response) == null ? void 0 : _a.status) || ((_c = (_b = dto.error) == null ? void 0 : _b.response) == null ? void 0 : _c.status);
235
+ const status = _optionalChain([dto, 'access', _63 => _63.response, 'optionalAccess', _64 => _64.status]) || _optionalChain([dto, 'access', _65 => _65.error, 'optionalAccess', _66 => _66.response, 'optionalAccess', _67 => _67.status]);
297
236
  if (!status) {
298
237
  return 500 /* INTERNAL_SERVER_ERROR */;
299
238
  }
300
239
  return status;
301
240
  };
302
241
  var makeStatusText = (dto = {}) => {
303
- var _a, _b, _c, _d, _e, _f;
304
- const status = ((_a = dto.response) == null ? void 0 : _a.status) || ((_c = (_b = dto.error) == null ? void 0 : _b.response) == null ? void 0 : _c.status);
242
+ const status = _optionalChain([dto, 'access', _68 => _68.response, 'optionalAccess', _69 => _69.status]) || _optionalChain([dto, 'access', _70 => _70.error, 'optionalAccess', _71 => _71.response, 'optionalAccess', _72 => _72.status]);
305
243
  if (!status) {
306
244
  return "";
307
245
  }
308
- const statusText = ((_d = dto.response) == null ? void 0 : _d.statusText) || ((_f = (_e = dto.error) == null ? void 0 : _e.response) == null ? void 0 : _f.statusText);
246
+ const statusText = _optionalChain([dto, 'access', _73 => _73.response, 'optionalAccess', _74 => _74.statusText]) || _optionalChain([dto, 'access', _75 => _75.error, 'optionalAccess', _76 => _76.response, 'optionalAccess', _77 => _77.statusText]);
309
247
  if (statusText) {
310
248
  return `${status} ${statusText}`;
311
249
  }
@@ -320,12 +258,7 @@ var makeResponse = (dto = {}) => {
320
258
  };
321
259
  };
322
260
  var logRequest = (request) => {
323
- log([
324
- makeType("Request"),
325
- makeMethodText({ request }),
326
- makeUrl({ request }),
327
- makeRequestData({ request })
328
- ]);
261
+ log([makeType("Request"), makeMethodText({ request }), makeUrl({ request }), makeRequestData({ request })]);
329
262
  };
330
263
  var logResponse = (response) => {
331
264
  log([
@@ -368,6 +301,7 @@ var loggerHelper = {
368
301
 
369
302
  // src/data-source.ts
370
303
  var RequestDataSource = class {
304
+
371
305
  constructor(baseRequestConfig) {
372
306
  this.baseRequestConfig = baseRequestConfig;
373
307
  }
@@ -380,7 +314,7 @@ var RequestDataSource = class {
380
314
  if (this.baseRequestConfig.logger) {
381
315
  loggerHelper.logRequest(request);
382
316
  }
383
- return import_axios.default.request(request).then((response) => {
317
+ return _axios2.default.request(request).then((response) => {
384
318
  if (this.baseRequestConfig.logger) {
385
319
  loggerHelper.logResponse(response);
386
320
  }
@@ -389,7 +323,6 @@ var RequestDataSource = class {
389
323
  }
390
324
  return response.data;
391
325
  }).catch((error) => {
392
- var _a;
393
326
  if (this.baseRequestConfig.debug) {
394
327
  console.log("Error:", error);
395
328
  }
@@ -399,81 +332,87 @@ var RequestDataSource = class {
399
332
  if (responseConfig.raw) {
400
333
  return loggerHelper.makeResponse({ error });
401
334
  }
402
- throw ((_a = error.response) == null ? void 0 : _a.data) || error.response || new Error(error.message);
335
+ throw _optionalChain([error, 'access', _78 => _78.response, 'optionalAccess', _79 => _79.data]) || error.response || new Error(error.message);
403
336
  });
404
337
  }
405
338
  search(config = {}) {
406
- return this.common(__spreadProps(__spreadValues({}, config), {
339
+ return this.common({
340
+ ...config,
407
341
  method: "get" /* GET */
408
- }));
342
+ });
409
343
  }
410
- bulkSearch() {
411
- return __asyncGenerator(this, arguments, function* (config = {}) {
412
- var _a, _b, _c;
413
- let pagination = {
414
- total: 0,
415
- currentPage: ((_a = config.params) == null ? void 0 : _a.page) || 0,
416
- lastPage: 0,
417
- from: 0,
418
- to: 0,
419
- pageSize: ((_b = config.params) == null ? void 0 : _b.pageSize) || 30
420
- };
421
- do {
422
- const response = yield new __await(this.common(__spreadProps(__spreadValues({}, config), {
423
- method: "get" /* GET */,
424
- params: __spreadProps(__spreadValues({}, config.params), {
425
- page: pagination.currentPage + 1,
426
- pageSize: pagination.pageSize
427
- })
428
- })));
429
- if (!((_c = response.data) == null ? void 0 : _c.length)) {
430
- return [];
344
+ async *bulkSearch(config = {}) {
345
+ let pagination = {
346
+ total: 0,
347
+ currentPage: _optionalChain([config, 'access', _80 => _80.params, 'optionalAccess', _81 => _81.page]) || 0,
348
+ lastPage: 0,
349
+ from: 0,
350
+ to: 0,
351
+ pageSize: _optionalChain([config, 'access', _82 => _82.params, 'optionalAccess', _83 => _83.pageSize]) || 30
352
+ };
353
+ do {
354
+ const response = await this.common({
355
+ ...config,
356
+ method: "get" /* GET */,
357
+ params: {
358
+ ...config.params,
359
+ page: pagination.currentPage + 1,
360
+ pageSize: pagination.pageSize
431
361
  }
432
- yield response.data;
433
- pagination = response.pagination;
434
- } while (pagination.currentPage !== pagination.lastPage);
435
- });
362
+ });
363
+ if (!_optionalChain([response, 'access', _84 => _84.data, 'optionalAccess', _85 => _85.length])) {
364
+ return [];
365
+ }
366
+ yield response.data;
367
+ pagination = response.pagination;
368
+ } while (pagination.currentPage !== pagination.lastPage);
436
369
  }
437
370
  get(id, config = {}) {
438
- return this.common(__spreadProps(__spreadValues({}, config), {
371
+ return this.common({
372
+ ...config,
439
373
  method: "get" /* GET */,
440
374
  url: id
441
- }));
375
+ });
442
376
  }
443
377
  create(config) {
444
- return this.common(__spreadProps(__spreadValues({}, config), {
378
+ return this.common({
379
+ ...config,
445
380
  method: "post" /* POST */
446
- }));
381
+ });
447
382
  }
448
383
  bulkCreate(config) {
449
- return this.common(__spreadProps(__spreadValues({}, config), {
384
+ return this.common({
385
+ ...config,
450
386
  method: "post" /* POST */,
451
387
  url: "/bulk",
452
388
  data: {
453
389
  bulk: config.data
454
390
  }
455
- }));
391
+ });
456
392
  }
457
393
  update(id, config) {
458
- return this.common(__spreadProps(__spreadValues({}, config), {
394
+ return this.common({
395
+ ...config,
459
396
  method: "put" /* PUT */,
460
397
  url: id
461
- }));
398
+ });
462
399
  }
463
400
  bulkUpdate(config) {
464
- return this.common(__spreadProps(__spreadValues({}, config), {
401
+ return this.common({
402
+ ...config,
465
403
  method: "put" /* PUT */,
466
404
  url: "/bulk",
467
405
  data: {
468
406
  bulk: config.data
469
407
  }
470
- }));
408
+ });
471
409
  }
472
410
  remove(id, config = {}) {
473
- return this.common(__spreadProps(__spreadValues({}, config), {
411
+ return this.common({
412
+ ...config,
474
413
  method: "delete" /* DELETE */,
475
414
  url: id
476
- }));
415
+ });
477
416
  }
478
417
  };
479
418
 
@@ -485,12 +424,11 @@ var RequestHelper = class {
485
424
  });
486
425
  }
487
426
  };
488
- // Annotate the CommonJS export names for ESM import in node:
489
- 0 && (module.exports = {
490
- HttpMethods,
491
- HttpStatuses,
492
- RequestBuilder,
493
- RequestDataSource,
494
- RequestHelper
495
- });
427
+
428
+
429
+
430
+
431
+
432
+
433
+ exports.HttpMethods = HttpMethods; exports.HttpStatuses = HttpStatuses; exports.RequestBuilder = RequestBuilder; exports.RequestDataSource = RequestDataSource; exports.RequestHelper = RequestHelper;
496
434
  //# sourceMappingURL=index.js.map