@rg-dev/stdlib 1.0.56 → 1.0.57

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.
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/axios-helpers.ts
31
+ var axios_helpers_exports = {};
32
+ __export(axios_helpers_exports, {
33
+ VERSION: () => VERSION,
34
+ handleAxiosError: () => handleAxiosError
35
+ });
36
+ module.exports = __toCommonJS(axios_helpers_exports);
37
+ var import_axios = __toESM(require("axios"), 1);
38
+
39
+ // src/index.ts
40
+ var VERSION = "1";
41
+
42
+ // src/axios-helpers.ts
43
+ import_axios.default.defaults.validateStatus = (status) => status < 400;
44
+ function handleAxiosError(fnName, e) {
45
+ var _a, _b;
46
+ if (e instanceof import_axios.default.AxiosError) {
47
+ fnName || (fnName = "Axios Request");
48
+ let errorData = ((_a = e == null ? void 0 : e.response) == null ? void 0 : _a.data) || "";
49
+ if (typeof errorData != "string") {
50
+ errorData = JSON.stringify(errorData);
51
+ }
52
+ const errorDetails = errorData.trim().slice(0, 300);
53
+ const msg = (e == null ? void 0 : e.message) || JSON.stringify(e);
54
+ const errorString = JSON.stringify({ error: msg, data: errorDetails, url: ((_b = e.config) == null ? void 0 : _b.url) || "" }, null, 2);
55
+ const err = new Error(`${fnName} failed: ${errorString}`);
56
+ err.stack = e.stack;
57
+ return err;
58
+ }
59
+ fnName || (fnName = "Function Error");
60
+ const nonAxiosError = String((e == null ? void 0 : e.message) || JSON.stringify(e)) || "Unknown Error";
61
+ const error = Error(`${fnName} failed: ${String(nonAxiosError)}`);
62
+ error.stack = e.stack;
63
+ return error;
64
+ }
@@ -0,0 +1,5 @@
1
+ export { VERSION } from './index.cjs';
2
+
3
+ declare function handleAxiosError(fnName: string, e: any): Error;
4
+
5
+ export { handleAxiosError };
@@ -0,0 +1,5 @@
1
+ export { VERSION } from './index.js';
2
+
3
+ declare function handleAxiosError(fnName: string, e: any): Error;
4
+
5
+ export { handleAxiosError };
@@ -0,0 +1,33 @@
1
+ // src/axios-helpers.ts
2
+ import axios from "axios";
3
+
4
+ // src/index.ts
5
+ var VERSION = "1";
6
+
7
+ // src/axios-helpers.ts
8
+ axios.defaults.validateStatus = (status) => status < 400;
9
+ function handleAxiosError(fnName, e) {
10
+ var _a, _b;
11
+ if (e instanceof axios.AxiosError) {
12
+ fnName || (fnName = "Axios Request");
13
+ let errorData = ((_a = e == null ? void 0 : e.response) == null ? void 0 : _a.data) || "";
14
+ if (typeof errorData != "string") {
15
+ errorData = JSON.stringify(errorData);
16
+ }
17
+ const errorDetails = errorData.trim().slice(0, 300);
18
+ const msg = (e == null ? void 0 : e.message) || JSON.stringify(e);
19
+ const errorString = JSON.stringify({ error: msg, data: errorDetails, url: ((_b = e.config) == null ? void 0 : _b.url) || "" }, null, 2);
20
+ const err = new Error(`${fnName} failed: ${errorString}`);
21
+ err.stack = e.stack;
22
+ return err;
23
+ }
24
+ fnName || (fnName = "Function Error");
25
+ const nonAxiosError = String((e == null ? void 0 : e.message) || JSON.stringify(e)) || "Unknown Error";
26
+ const error = Error(`${fnName} failed: ${String(nonAxiosError)}`);
27
+ error.stack = e.stack;
28
+ return error;
29
+ }
30
+ export {
31
+ VERSION,
32
+ handleAxiosError
33
+ };
package/lib/index.d.cts CHANGED
@@ -3,5 +3,6 @@ import './node-env'
3
3
  import './common-env'
4
4
  import './node-download'
5
5
  import './trpc-helpers'
6
+ import './axios-helpers'
6
7
 
7
8
  export declare const VERSION:string
package/lib/index.d.ts CHANGED
@@ -3,5 +3,6 @@ import './node-env'
3
3
  import './common-env'
4
4
  import './node-download'
5
5
  import './trpc-helpers'
6
+ import './axios-helpers'
6
7
 
7
8
  export declare const VERSION:string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -28,6 +28,9 @@
28
28
  ],
29
29
  "lib/node-download": [
30
30
  "lib/node-download.d.ts"
31
+ ],
32
+ "lib/axios-helpers": [
33
+ "lib/axios-helpers.d.ts"
31
34
  ]
32
35
  }
33
36
  },
@@ -38,6 +41,11 @@
38
41
  "import": "./lib/index.js",
39
42
  "require": "./lib/index.cjs",
40
43
  "types": "./lib/index.d.ts"
44
+ },
45
+ "./lib/axios-helpers": {
46
+ "import": "./lib/axios-helpers.js",
47
+ "require": "./lib/axios-helpers.cjs",
48
+ "types": "./lib/axios-helpers.d.ts"
41
49
  },
42
50
  "./lib/trpc-helpers": {
43
51
  "import": "./lib/trpc-helpers.js",