abbot-http-client 0.0.16 → 0.0.18

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.cjs CHANGED
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AppError: () => AppError,
34
+ RestError: () => RestError,
33
35
  catchError: () => catchError,
34
36
  create: () => create
35
37
  });
@@ -167,9 +169,13 @@ var CoreHttp = class {
167
169
  createAxiosInstance(option) {
168
170
  const axios2 = axiosConf(this.config);
169
171
  const iv = Secure.createId();
172
+ console.log({
173
+ iv,
174
+ keyValue: option?.isInit ? void 0 : this.config.app.encKey
175
+ });
170
176
  const cryp = new Cryp({
171
177
  iv,
172
- keyValue: option?.isInit ? void 0 : this.config.app.ecnKey
178
+ keyValue: option?.isInit ? void 0 : this.config.app.encKey
173
179
  });
174
180
  axios2.interceptors.request.use(
175
181
  (config) => {
@@ -341,7 +347,7 @@ var cfg = {
341
347
  redirectUrl: "/login",
342
348
  apiKey: "",
343
349
  timezone: "Asia/Bangkok",
344
- ecnKey: "",
350
+ encKey: "",
345
351
  trackingId: "",
346
352
  userJwt: ""
347
353
  }
@@ -365,8 +371,23 @@ function create(config) {
365
371
  const http = new CoreHttp(cfg);
366
372
  return http;
367
373
  }
374
+
375
+ // src/error.ts
376
+ var AppError = class extends Error {
377
+ name = "App Error";
378
+ };
379
+ var RestError = class extends Error {
380
+ name = "Rest Error";
381
+ res;
382
+ constructor(rs) {
383
+ super(rs.message);
384
+ this.res = rs;
385
+ }
386
+ };
368
387
  // Annotate the CommonJS export names for ESM import in node:
369
388
  0 && (module.exports = {
389
+ AppError,
390
+ RestError,
370
391
  catchError,
371
392
  create
372
393
  });
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
2
 
3
3
  declare function catchError<T, E extends new (err?: any) => Error>(promise: Promise<T>, errorToCatch?: E[]): Promise<[undefined, T] | [InstanceType<E>]>;
4
4
 
@@ -36,10 +36,19 @@ interface AbbotConfig {
36
36
  apiKey: string;
37
37
  timezone: string;
38
38
  trackingId: string;
39
- ecnKey: string;
39
+ encKey: string;
40
40
  userJwt: string;
41
41
  };
42
42
  }
43
43
  declare function create(config: DeepPartial<AbbotConfig>): CoreHttp;
44
44
 
45
- export { type AbbotConfig, catchError, create };
45
+ declare class AppError extends Error {
46
+ name: string;
47
+ }
48
+ declare class RestError<T extends AxiosError> extends Error {
49
+ name: string;
50
+ res: T;
51
+ constructor(rs: T);
52
+ }
53
+
54
+ export { type AbbotConfig, AppError, RestError, catchError, create };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { AxiosResponse, AxiosError } from 'axios';
2
2
 
3
3
  declare function catchError<T, E extends new (err?: any) => Error>(promise: Promise<T>, errorToCatch?: E[]): Promise<[undefined, T] | [InstanceType<E>]>;
4
4
 
@@ -36,10 +36,19 @@ interface AbbotConfig {
36
36
  apiKey: string;
37
37
  timezone: string;
38
38
  trackingId: string;
39
- ecnKey: string;
39
+ encKey: string;
40
40
  userJwt: string;
41
41
  };
42
42
  }
43
43
  declare function create(config: DeepPartial<AbbotConfig>): CoreHttp;
44
44
 
45
- export { type AbbotConfig, catchError, create };
45
+ declare class AppError extends Error {
46
+ name: string;
47
+ }
48
+ declare class RestError<T extends AxiosError> extends Error {
49
+ name: string;
50
+ res: T;
51
+ constructor(rs: T);
52
+ }
53
+
54
+ export { type AbbotConfig, AppError, RestError, catchError, create };
package/dist/index.js CHANGED
@@ -130,9 +130,13 @@ var CoreHttp = class {
130
130
  createAxiosInstance(option) {
131
131
  const axios2 = axiosConf(this.config);
132
132
  const iv = Secure.createId();
133
+ console.log({
134
+ iv,
135
+ keyValue: option?.isInit ? void 0 : this.config.app.encKey
136
+ });
133
137
  const cryp = new Cryp({
134
138
  iv,
135
- keyValue: option?.isInit ? void 0 : this.config.app.ecnKey
139
+ keyValue: option?.isInit ? void 0 : this.config.app.encKey
136
140
  });
137
141
  axios2.interceptors.request.use(
138
142
  (config) => {
@@ -304,7 +308,7 @@ var cfg = {
304
308
  redirectUrl: "/login",
305
309
  apiKey: "",
306
310
  timezone: "Asia/Bangkok",
307
- ecnKey: "",
311
+ encKey: "",
308
312
  trackingId: "",
309
313
  userJwt: ""
310
314
  }
@@ -328,7 +332,22 @@ function create(config) {
328
332
  const http = new CoreHttp(cfg);
329
333
  return http;
330
334
  }
335
+
336
+ // src/error.ts
337
+ var AppError = class extends Error {
338
+ name = "App Error";
339
+ };
340
+ var RestError = class extends Error {
341
+ name = "Rest Error";
342
+ res;
343
+ constructor(rs) {
344
+ super(rs.message);
345
+ this.res = rs;
346
+ }
347
+ };
331
348
  export {
349
+ AppError,
350
+ RestError,
332
351
  catchError,
333
352
  create
334
353
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abbot-http-client",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "This package helps Abbot team to handle all the axios requests.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",