@xylabs/axios 3.6.11 → 4.0.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/neutral/index.d.ts +17 -4
- package/package.json +8 -27
- package/xy.config.ts +12 -0
- package/dist/browser/AxiosJson.d.cts +0 -13
- package/dist/browser/AxiosJson.d.cts.map +0 -1
- package/dist/browser/AxiosJson.d.mts +0 -13
- package/dist/browser/AxiosJson.d.mts.map +0 -1
- package/dist/browser/AxiosJson.d.ts +0 -13
- package/dist/browser/AxiosJson.d.ts.map +0 -1
- package/dist/browser/index.cjs +0 -79
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.d.cts +0 -5
- package/dist/browser/index.d.cts.map +0 -1
- package/dist/browser/index.d.mts +0 -5
- package/dist/browser/index.d.mts.map +0 -1
- package/dist/browser/index.d.ts +0 -5
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.mjs +0 -56
- package/dist/browser/index.mjs.map +0 -1
- package/dist/neutral/AxiosJson.d.cts +0 -13
- package/dist/neutral/AxiosJson.d.cts.map +0 -1
- package/dist/neutral/AxiosJson.d.mts +0 -13
- package/dist/neutral/AxiosJson.d.mts.map +0 -1
- package/dist/neutral/AxiosJson.d.ts +0 -13
- package/dist/neutral/AxiosJson.d.ts.map +0 -1
- package/dist/neutral/index.cjs +0 -79
- package/dist/neutral/index.cjs.map +0 -1
- package/dist/neutral/index.d.cts +0 -5
- package/dist/neutral/index.d.cts.map +0 -1
- package/dist/neutral/index.d.mts +0 -5
- package/dist/neutral/index.d.mts.map +0 -1
- package/dist/neutral/index.d.ts.map +0 -1
- package/dist/node/AxiosJson.d.cts +0 -13
- package/dist/node/AxiosJson.d.cts.map +0 -1
- package/dist/node/AxiosJson.d.mts +0 -13
- package/dist/node/AxiosJson.d.mts.map +0 -1
- package/dist/node/AxiosJson.d.ts +0 -13
- package/dist/node/AxiosJson.d.ts.map +0 -1
- package/dist/node/index.cjs +0 -86
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.d.cts +0 -5
- package/dist/node/index.d.cts.map +0 -1
- package/dist/node/index.d.mts +0 -5
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.d.ts +0 -5
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.mjs +0 -57
- package/dist/node/index.mjs.map +0 -1
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Logger } from '@xylabs/logger';
|
|
2
|
+
import { RawAxiosRequestConfig, Axios, AxiosResponse } from 'axios';
|
|
3
3
|
export { gzip } from 'pako';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
6
|
+
compressLength?: number;
|
|
7
|
+
};
|
|
8
|
+
declare class AxiosJson extends Axios {
|
|
9
|
+
static defaultLogger?: Logger;
|
|
10
|
+
constructor(config?: RawAxiosJsonRequestConfig);
|
|
11
|
+
static finalPath(response: AxiosResponse): any;
|
|
12
|
+
private static axiosConfig;
|
|
13
|
+
private static buildHeaders;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const axios: AxiosJson;
|
|
17
|
+
|
|
18
|
+
export { AxiosJson, type RawAxiosJsonRequestConfig, axios };
|
package/package.json
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@types/pako": "^2.0.3",
|
|
14
|
-
"@xylabs/logger": "^
|
|
14
|
+
"@xylabs/logger": "^4.0.0",
|
|
15
15
|
"axios": "^1.7.3",
|
|
16
16
|
"pako": "^2.1.0"
|
|
17
17
|
},
|
|
18
18
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@xylabs/ts-scripts-yarn3": "^
|
|
21
|
-
"@xylabs/tsconfig": "^
|
|
20
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.15",
|
|
21
|
+
"@xylabs/tsconfig": "^4.0.0-rc.15",
|
|
22
22
|
"typescript": "^5.5.4"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
@@ -26,32 +26,13 @@
|
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"types": "./dist/browser/index.d.cts",
|
|
32
|
-
"default": "./dist/browser/index.cjs"
|
|
33
|
-
},
|
|
34
|
-
"import": {
|
|
35
|
-
"types": "./dist/browser/index.d.ts",
|
|
36
|
-
"default": "./dist/browser/index.mjs"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"node": {
|
|
40
|
-
"require": {
|
|
41
|
-
"types": "./dist/node/index.d.cts",
|
|
42
|
-
"default": "./dist/node/index.cjs"
|
|
43
|
-
},
|
|
44
|
-
"import": {
|
|
45
|
-
"types": "./dist/node/index.d.ts",
|
|
46
|
-
"default": "./dist/node/index.mjs"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
29
|
+
"types": "./dist/neutral/index.d.ts",
|
|
30
|
+
"default": "./dist/neutral/index.mjs"
|
|
49
31
|
},
|
|
50
32
|
"./package.json": "./package.json"
|
|
51
33
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"types": "dist/node/index.d.ts",
|
|
34
|
+
"module": "dist/neutral/index.mjs",
|
|
35
|
+
"types": "dist/neutral/index.d.ts",
|
|
55
36
|
"homepage": "https://xyo.network",
|
|
56
37
|
"license": "LGPL-3.0-only",
|
|
57
38
|
"publishConfig": {
|
|
@@ -69,6 +50,6 @@
|
|
|
69
50
|
"esm"
|
|
70
51
|
],
|
|
71
52
|
"sideEffects": false,
|
|
72
|
-
"version": "
|
|
53
|
+
"version": "4.0.0",
|
|
73
54
|
"type": "module"
|
|
74
55
|
}
|
package/xy.config.ts
ADDED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
package/dist/browser/index.cjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
AxiosJson: () => AxiosJson,
|
|
24
|
-
axios: () => axios,
|
|
25
|
-
gzip: () => import_pako2.gzip
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
|
|
29
|
-
// src/AxiosJson.ts
|
|
30
|
-
var import_axios = require("axios");
|
|
31
|
-
var import_pako = require("pako");
|
|
32
|
-
var AxiosJson = class _AxiosJson extends import_axios.Axios {
|
|
33
|
-
static defaultLogger;
|
|
34
|
-
constructor(config) {
|
|
35
|
-
super(_AxiosJson.axiosConfig(config));
|
|
36
|
-
}
|
|
37
|
-
static finalPath(response) {
|
|
38
|
-
if (response.request.path) {
|
|
39
|
-
return response.request.path.split("/").pop();
|
|
40
|
-
} else if (response.request.responseURL) {
|
|
41
|
-
return response.request.responseURL.split("/").pop();
|
|
42
|
-
} else {
|
|
43
|
-
this.defaultLogger?.warn("Failed to get final path from response");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
static axiosConfig({ compressLength, headers, ...config } = {}) {
|
|
47
|
-
return {
|
|
48
|
-
headers: this.buildHeaders(headers),
|
|
49
|
-
transformRequest: (data, headers2) => {
|
|
50
|
-
const json = JSON.stringify(data);
|
|
51
|
-
if (headers2 && data && json.length > (compressLength ?? 1024)) {
|
|
52
|
-
headers2["Content-Encoding"] = "gzip";
|
|
53
|
-
return (0, import_pako.gzip)(JSON.stringify(data)).buffer;
|
|
54
|
-
}
|
|
55
|
-
return JSON.stringify(data);
|
|
56
|
-
},
|
|
57
|
-
transformResponse: (data) => {
|
|
58
|
-
try {
|
|
59
|
-
return JSON.parse(data);
|
|
60
|
-
} catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
...config
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
static buildHeaders(headers) {
|
|
68
|
-
const axiosHeaders = new import_axios.AxiosHeaders();
|
|
69
|
-
axiosHeaders.set("Accept", "application/json, text/plain, *.*");
|
|
70
|
-
axiosHeaders.set("Content-Type", "application/json");
|
|
71
|
-
for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value);
|
|
72
|
-
return axiosHeaders;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// src/index.ts
|
|
77
|
-
var import_pako2 = require("pako");
|
|
78
|
-
var axios = new AxiosJson();
|
|
79
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["import { AxiosJson } from './AxiosJson.ts'\n\nexport * from './AxiosJson.ts'\nexport { gzip } from 'pako'\n\nexport const axios = new AxiosJson()\n","import { Logger } from '@xylabs/logger'\nimport { Axios, AxiosHeaders, AxiosResponse, RawAxiosRequestConfig } from 'axios'\nimport { gzip } from 'pako'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & { compressLength?: number }\n\nexport class AxiosJson extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: RawAxiosJsonRequestConfig) {\n super(AxiosJson.axiosConfig(config))\n }\n\n static finalPath(response: AxiosResponse) {\n if (response.request.path) {\n // nodejs\n return response.request.path.split('/').pop()\n } else if (response.request.responseURL) {\n // browser\n return response.request.responseURL.split('/').pop()\n } else {\n this.defaultLogger?.warn('Failed to get final path from response')\n }\n }\n\n private static axiosConfig({ compressLength, headers, ...config }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data, headers) => {\n const json = JSON.stringify(data)\n if (headers && data && json.length > (compressLength ?? 1024)) {\n headers['Content-Encoding'] = 'gzip'\n return gzip(JSON.stringify(data)).buffer\n }\n return JSON.stringify(data)\n },\n transformResponse: (data) => {\n try {\n return JSON.parse(data)\n } catch {\n return null\n }\n },\n ...config,\n }\n }\n\n private static buildHeaders(headers: RawAxiosJsonRequestConfig['headers']) {\n const axiosHeaders = new AxiosHeaders()\n axiosHeaders.set('Accept', 'application/json, text/plain, *.*')\n axiosHeaders.set('Content-Type', 'application/json')\n for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value)\n return axiosHeaders\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAA0E;AAC1E,kBAAqB;AAKd,IAAM,YAAN,MAAM,mBAAkB,mBAAM;AAAA,EACnC,OAAO;AAAA,EAEP,YAAY,QAAoC;AAC9C,UAAM,WAAU,YAAY,MAAM,CAAC;AAAA,EACrC;AAAA,EAEA,OAAO,UAAU,UAAyB;AACxC,QAAI,SAAS,QAAQ,MAAM;AAEzB,aAAO,SAAS,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9C,WAAW,SAAS,QAAQ,aAAa;AAEvC,aAAO,SAAS,QAAQ,YAAY,MAAM,GAAG,EAAE,IAAI;AAAA,IACrD,OAAO;AACL,WAAK,eAAe,KAAK,wCAAwC;AAAA,IACnE;AAAA,EACF;AAAA,EAEA,OAAe,YAAY,EAAE,gBAAgB,SAAS,GAAG,OAAO,IAA+B,CAAC,GAA8B;AAC5H,WAAO;AAAA,MACL,SAAS,KAAK,aAAa,OAAO;AAAA,MAClC,kBAAkB,CAAC,MAAMA,aAAY;AACnC,cAAM,OAAO,KAAK,UAAU,IAAI;AAChC,YAAIA,YAAW,QAAQ,KAAK,UAAU,kBAAkB,OAAO;AAC7D,UAAAA,SAAQ,kBAAkB,IAAI;AAC9B,qBAAO,kBAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAAA,QACpC;AACA,eAAO,KAAK,UAAU,IAAI;AAAA,MAC5B;AAAA,MACA,mBAAmB,CAAC,SAAS;AAC3B,YAAI;AACF,iBAAO,KAAK,MAAM,IAAI;AAAA,QACxB,QAAQ;AACN,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,OAAe,aAAa,SAA+C;AACzE,UAAM,eAAe,IAAI,0BAAa;AACtC,iBAAa,IAAI,UAAU,mCAAmC;AAC9D,iBAAa,IAAI,gBAAgB,kBAAkB;AACnD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC,EAAG,cAAa,IAAI,KAAK,KAAK;AACrF,WAAO;AAAA,EACT;AACF;;;ADpDA,IAAAC,eAAqB;AAEd,IAAM,QAAQ,IAAI,UAAU;","names":["headers","import_pako"]}
|
package/dist/browser/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
package/dist/browser/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
package/dist/browser/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
package/dist/browser/index.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// src/AxiosJson.ts
|
|
2
|
-
import { Axios, AxiosHeaders } from "axios";
|
|
3
|
-
import { gzip } from "pako";
|
|
4
|
-
var AxiosJson = class _AxiosJson extends Axios {
|
|
5
|
-
static defaultLogger;
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super(_AxiosJson.axiosConfig(config));
|
|
8
|
-
}
|
|
9
|
-
static finalPath(response) {
|
|
10
|
-
if (response.request.path) {
|
|
11
|
-
return response.request.path.split("/").pop();
|
|
12
|
-
} else if (response.request.responseURL) {
|
|
13
|
-
return response.request.responseURL.split("/").pop();
|
|
14
|
-
} else {
|
|
15
|
-
this.defaultLogger?.warn("Failed to get final path from response");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
static axiosConfig({ compressLength, headers, ...config } = {}) {
|
|
19
|
-
return {
|
|
20
|
-
headers: this.buildHeaders(headers),
|
|
21
|
-
transformRequest: (data, headers2) => {
|
|
22
|
-
const json = JSON.stringify(data);
|
|
23
|
-
if (headers2 && data && json.length > (compressLength ?? 1024)) {
|
|
24
|
-
headers2["Content-Encoding"] = "gzip";
|
|
25
|
-
return gzip(JSON.stringify(data)).buffer;
|
|
26
|
-
}
|
|
27
|
-
return JSON.stringify(data);
|
|
28
|
-
},
|
|
29
|
-
transformResponse: (data) => {
|
|
30
|
-
try {
|
|
31
|
-
return JSON.parse(data);
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
...config
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
static buildHeaders(headers) {
|
|
40
|
-
const axiosHeaders = new AxiosHeaders();
|
|
41
|
-
axiosHeaders.set("Accept", "application/json, text/plain, *.*");
|
|
42
|
-
axiosHeaders.set("Content-Type", "application/json");
|
|
43
|
-
for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value);
|
|
44
|
-
return axiosHeaders;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/index.ts
|
|
49
|
-
import { gzip as gzip2 } from "pako";
|
|
50
|
-
var axios = new AxiosJson();
|
|
51
|
-
export {
|
|
52
|
-
AxiosJson,
|
|
53
|
-
axios,
|
|
54
|
-
gzip2 as gzip
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/AxiosJson.ts","../../src/index.ts"],"sourcesContent":["import { Logger } from '@xylabs/logger'\nimport { Axios, AxiosHeaders, AxiosResponse, RawAxiosRequestConfig } from 'axios'\nimport { gzip } from 'pako'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & { compressLength?: number }\n\nexport class AxiosJson extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: RawAxiosJsonRequestConfig) {\n super(AxiosJson.axiosConfig(config))\n }\n\n static finalPath(response: AxiosResponse) {\n if (response.request.path) {\n // nodejs\n return response.request.path.split('/').pop()\n } else if (response.request.responseURL) {\n // browser\n return response.request.responseURL.split('/').pop()\n } else {\n this.defaultLogger?.warn('Failed to get final path from response')\n }\n }\n\n private static axiosConfig({ compressLength, headers, ...config }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data, headers) => {\n const json = JSON.stringify(data)\n if (headers && data && json.length > (compressLength ?? 1024)) {\n headers['Content-Encoding'] = 'gzip'\n return gzip(JSON.stringify(data)).buffer\n }\n return JSON.stringify(data)\n },\n transformResponse: (data) => {\n try {\n return JSON.parse(data)\n } catch {\n return null\n }\n },\n ...config,\n }\n }\n\n private static buildHeaders(headers: RawAxiosJsonRequestConfig['headers']) {\n const axiosHeaders = new AxiosHeaders()\n axiosHeaders.set('Accept', 'application/json, text/plain, *.*')\n axiosHeaders.set('Content-Type', 'application/json')\n for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value)\n return axiosHeaders\n }\n}\n","import { AxiosJson } from './AxiosJson.ts'\n\nexport * from './AxiosJson.ts'\nexport { gzip } from 'pako'\n\nexport const axios = new AxiosJson()\n"],"mappings":";AACA,SAAS,OAAO,oBAA0D;AAC1E,SAAS,YAAY;AAKd,IAAM,YAAN,MAAM,mBAAkB,MAAM;AAAA,EACnC,OAAO;AAAA,EAEP,YAAY,QAAoC;AAC9C,UAAM,WAAU,YAAY,MAAM,CAAC;AAAA,EACrC;AAAA,EAEA,OAAO,UAAU,UAAyB;AACxC,QAAI,SAAS,QAAQ,MAAM;AAEzB,aAAO,SAAS,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9C,WAAW,SAAS,QAAQ,aAAa;AAEvC,aAAO,SAAS,QAAQ,YAAY,MAAM,GAAG,EAAE,IAAI;AAAA,IACrD,OAAO;AACL,WAAK,eAAe,KAAK,wCAAwC;AAAA,IACnE;AAAA,EACF;AAAA,EAEA,OAAe,YAAY,EAAE,gBAAgB,SAAS,GAAG,OAAO,IAA+B,CAAC,GAA8B;AAC5H,WAAO;AAAA,MACL,SAAS,KAAK,aAAa,OAAO;AAAA,MAClC,kBAAkB,CAAC,MAAMA,aAAY;AACnC,cAAM,OAAO,KAAK,UAAU,IAAI;AAChC,YAAIA,YAAW,QAAQ,KAAK,UAAU,kBAAkB,OAAO;AAC7D,UAAAA,SAAQ,kBAAkB,IAAI;AAC9B,iBAAO,KAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAAA,QACpC;AACA,eAAO,KAAK,UAAU,IAAI;AAAA,MAC5B;AAAA,MACA,mBAAmB,CAAC,SAAS;AAC3B,YAAI;AACF,iBAAO,KAAK,MAAM,IAAI;AAAA,QACxB,QAAQ;AACN,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,OAAe,aAAa,SAA+C;AACzE,UAAM,eAAe,IAAI,aAAa;AACtC,iBAAa,IAAI,UAAU,mCAAmC;AAC9D,iBAAa,IAAI,gBAAgB,kBAAkB;AACnD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC,EAAG,cAAa,IAAI,KAAK,KAAK;AACrF,WAAO;AAAA,EACT;AACF;;;ACpDA,SAAS,QAAAC,aAAY;AAEd,IAAM,QAAQ,IAAI,UAAU;","names":["headers","gzip"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
package/dist/neutral/index.cjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
AxiosJson: () => AxiosJson,
|
|
24
|
-
axios: () => axios,
|
|
25
|
-
gzip: () => import_pako2.gzip
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
|
|
29
|
-
// src/AxiosJson.ts
|
|
30
|
-
var import_axios = require("axios");
|
|
31
|
-
var import_pako = require("pako");
|
|
32
|
-
var AxiosJson = class _AxiosJson extends import_axios.Axios {
|
|
33
|
-
static defaultLogger;
|
|
34
|
-
constructor(config) {
|
|
35
|
-
super(_AxiosJson.axiosConfig(config));
|
|
36
|
-
}
|
|
37
|
-
static finalPath(response) {
|
|
38
|
-
if (response.request.path) {
|
|
39
|
-
return response.request.path.split("/").pop();
|
|
40
|
-
} else if (response.request.responseURL) {
|
|
41
|
-
return response.request.responseURL.split("/").pop();
|
|
42
|
-
} else {
|
|
43
|
-
this.defaultLogger?.warn("Failed to get final path from response");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
static axiosConfig({ compressLength, headers, ...config } = {}) {
|
|
47
|
-
return {
|
|
48
|
-
headers: this.buildHeaders(headers),
|
|
49
|
-
transformRequest: (data, headers2) => {
|
|
50
|
-
const json = JSON.stringify(data);
|
|
51
|
-
if (headers2 && data && json.length > (compressLength ?? 1024)) {
|
|
52
|
-
headers2["Content-Encoding"] = "gzip";
|
|
53
|
-
return (0, import_pako.gzip)(JSON.stringify(data)).buffer;
|
|
54
|
-
}
|
|
55
|
-
return JSON.stringify(data);
|
|
56
|
-
},
|
|
57
|
-
transformResponse: (data) => {
|
|
58
|
-
try {
|
|
59
|
-
return JSON.parse(data);
|
|
60
|
-
} catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
...config
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
static buildHeaders(headers) {
|
|
68
|
-
const axiosHeaders = new import_axios.AxiosHeaders();
|
|
69
|
-
axiosHeaders.set("Accept", "application/json, text/plain, *.*");
|
|
70
|
-
axiosHeaders.set("Content-Type", "application/json");
|
|
71
|
-
for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value);
|
|
72
|
-
return axiosHeaders;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// src/index.ts
|
|
77
|
-
var import_pako2 = require("pako");
|
|
78
|
-
var axios = new AxiosJson();
|
|
79
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["import { AxiosJson } from './AxiosJson.ts'\n\nexport * from './AxiosJson.ts'\nexport { gzip } from 'pako'\n\nexport const axios = new AxiosJson()\n","import { Logger } from '@xylabs/logger'\nimport { Axios, AxiosHeaders, AxiosResponse, RawAxiosRequestConfig } from 'axios'\nimport { gzip } from 'pako'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & { compressLength?: number }\n\nexport class AxiosJson extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: RawAxiosJsonRequestConfig) {\n super(AxiosJson.axiosConfig(config))\n }\n\n static finalPath(response: AxiosResponse) {\n if (response.request.path) {\n // nodejs\n return response.request.path.split('/').pop()\n } else if (response.request.responseURL) {\n // browser\n return response.request.responseURL.split('/').pop()\n } else {\n this.defaultLogger?.warn('Failed to get final path from response')\n }\n }\n\n private static axiosConfig({ compressLength, headers, ...config }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data, headers) => {\n const json = JSON.stringify(data)\n if (headers && data && json.length > (compressLength ?? 1024)) {\n headers['Content-Encoding'] = 'gzip'\n return gzip(JSON.stringify(data)).buffer\n }\n return JSON.stringify(data)\n },\n transformResponse: (data) => {\n try {\n return JSON.parse(data)\n } catch {\n return null\n }\n },\n ...config,\n }\n }\n\n private static buildHeaders(headers: RawAxiosJsonRequestConfig['headers']) {\n const axiosHeaders = new AxiosHeaders()\n axiosHeaders.set('Accept', 'application/json, text/plain, *.*')\n axiosHeaders.set('Content-Type', 'application/json')\n for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value)\n return axiosHeaders\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAA0E;AAC1E,kBAAqB;AAKd,IAAM,YAAN,MAAM,mBAAkB,mBAAM;AAAA,EACnC,OAAO;AAAA,EAEP,YAAY,QAAoC;AAC9C,UAAM,WAAU,YAAY,MAAM,CAAC;AAAA,EACrC;AAAA,EAEA,OAAO,UAAU,UAAyB;AACxC,QAAI,SAAS,QAAQ,MAAM;AAEzB,aAAO,SAAS,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9C,WAAW,SAAS,QAAQ,aAAa;AAEvC,aAAO,SAAS,QAAQ,YAAY,MAAM,GAAG,EAAE,IAAI;AAAA,IACrD,OAAO;AACL,WAAK,eAAe,KAAK,wCAAwC;AAAA,IACnE;AAAA,EACF;AAAA,EAEA,OAAe,YAAY,EAAE,gBAAgB,SAAS,GAAG,OAAO,IAA+B,CAAC,GAA8B;AAC5H,WAAO;AAAA,MACL,SAAS,KAAK,aAAa,OAAO;AAAA,MAClC,kBAAkB,CAAC,MAAMA,aAAY;AACnC,cAAM,OAAO,KAAK,UAAU,IAAI;AAChC,YAAIA,YAAW,QAAQ,KAAK,UAAU,kBAAkB,OAAO;AAC7D,UAAAA,SAAQ,kBAAkB,IAAI;AAC9B,qBAAO,kBAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAAA,QACpC;AACA,eAAO,KAAK,UAAU,IAAI;AAAA,MAC5B;AAAA,MACA,mBAAmB,CAAC,SAAS;AAC3B,YAAI;AACF,iBAAO,KAAK,MAAM,IAAI;AAAA,QACxB,QAAQ;AACN,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,OAAe,aAAa,SAA+C;AACzE,UAAM,eAAe,IAAI,0BAAa;AACtC,iBAAa,IAAI,UAAU,mCAAmC;AAC9D,iBAAa,IAAI,gBAAgB,kBAAkB;AACnD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC,EAAG,cAAa,IAAI,KAAK,KAAK;AACrF,WAAO;AAAA,EACT;AACF;;;ADpDA,IAAAC,eAAqB;AAEd,IAAM,QAAQ,IAAI,UAAU;","names":["headers","import_pako"]}
|
package/dist/neutral/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
package/dist/neutral/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
package/dist/node/AxiosJson.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@xylabs/logger';
|
|
2
|
-
import { Axios, AxiosResponse, RawAxiosRequestConfig } from 'axios';
|
|
3
|
-
export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
|
|
4
|
-
compressLength?: number;
|
|
5
|
-
};
|
|
6
|
-
export declare class AxiosJson extends Axios {
|
|
7
|
-
static defaultLogger?: Logger;
|
|
8
|
-
constructor(config?: RawAxiosJsonRequestConfig);
|
|
9
|
-
static finalPath(response: AxiosResponse): any;
|
|
10
|
-
private static axiosConfig;
|
|
11
|
-
private static buildHeaders;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=AxiosJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAgB,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvG,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,yBAAyB;IAI9C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
|
package/dist/node/index.cjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
AxiosJson: () => AxiosJson,
|
|
24
|
-
axios: () => axios,
|
|
25
|
-
gzip: () => import_pako2.gzip
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
|
|
29
|
-
// src/AxiosJson.ts
|
|
30
|
-
var import_axios = require("axios");
|
|
31
|
-
var import_pako = require("pako");
|
|
32
|
-
var AxiosJson = class _AxiosJson extends import_axios.Axios {
|
|
33
|
-
static defaultLogger;
|
|
34
|
-
constructor(config) {
|
|
35
|
-
super(_AxiosJson.axiosConfig(config));
|
|
36
|
-
}
|
|
37
|
-
static finalPath(response) {
|
|
38
|
-
var _a;
|
|
39
|
-
if (response.request.path) {
|
|
40
|
-
return response.request.path.split("/").pop();
|
|
41
|
-
} else if (response.request.responseURL) {
|
|
42
|
-
return response.request.responseURL.split("/").pop();
|
|
43
|
-
} else {
|
|
44
|
-
(_a = this.defaultLogger) == null ? void 0 : _a.warn("Failed to get final path from response");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
static axiosConfig({ compressLength, headers, ...config } = {}) {
|
|
48
|
-
return {
|
|
49
|
-
headers: this.buildHeaders(headers),
|
|
50
|
-
transformRequest: (data, headers2) => {
|
|
51
|
-
const json = JSON.stringify(data);
|
|
52
|
-
if (headers2 && data && json.length > (compressLength ?? 1024)) {
|
|
53
|
-
headers2["Content-Encoding"] = "gzip";
|
|
54
|
-
return (0, import_pako.gzip)(JSON.stringify(data)).buffer;
|
|
55
|
-
}
|
|
56
|
-
return JSON.stringify(data);
|
|
57
|
-
},
|
|
58
|
-
transformResponse: (data) => {
|
|
59
|
-
try {
|
|
60
|
-
return JSON.parse(data);
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
...config
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
static buildHeaders(headers) {
|
|
69
|
-
const axiosHeaders = new import_axios.AxiosHeaders();
|
|
70
|
-
axiosHeaders.set("Accept", "application/json, text/plain, *.*");
|
|
71
|
-
axiosHeaders.set("Content-Type", "application/json");
|
|
72
|
-
for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value);
|
|
73
|
-
return axiosHeaders;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// src/index.ts
|
|
78
|
-
var import_pako2 = require("pako");
|
|
79
|
-
var axios = new AxiosJson();
|
|
80
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
AxiosJson,
|
|
83
|
-
axios,
|
|
84
|
-
gzip
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["import { AxiosJson } from './AxiosJson.ts'\n\nexport * from './AxiosJson.ts'\nexport { gzip } from 'pako'\n\nexport const axios = new AxiosJson()\n","import { Logger } from '@xylabs/logger'\nimport { Axios, AxiosHeaders, AxiosResponse, RawAxiosRequestConfig } from 'axios'\nimport { gzip } from 'pako'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & { compressLength?: number }\n\nexport class AxiosJson extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: RawAxiosJsonRequestConfig) {\n super(AxiosJson.axiosConfig(config))\n }\n\n static finalPath(response: AxiosResponse) {\n if (response.request.path) {\n // nodejs\n return response.request.path.split('/').pop()\n } else if (response.request.responseURL) {\n // browser\n return response.request.responseURL.split('/').pop()\n } else {\n this.defaultLogger?.warn('Failed to get final path from response')\n }\n }\n\n private static axiosConfig({ compressLength, headers, ...config }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data, headers) => {\n const json = JSON.stringify(data)\n if (headers && data && json.length > (compressLength ?? 1024)) {\n headers['Content-Encoding'] = 'gzip'\n return gzip(JSON.stringify(data)).buffer\n }\n return JSON.stringify(data)\n },\n transformResponse: (data) => {\n try {\n return JSON.parse(data)\n } catch {\n return null\n }\n },\n ...config,\n }\n }\n\n private static buildHeaders(headers: RawAxiosJsonRequestConfig['headers']) {\n const axiosHeaders = new AxiosHeaders()\n axiosHeaders.set('Accept', 'application/json, text/plain, *.*')\n axiosHeaders.set('Content-Type', 'application/json')\n for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value)\n return axiosHeaders\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAA0E;AAC1E,kBAAqB;AAKd,IAAM,YAAN,MAAM,mBAAkB,mBAAM;AAAA,EACnC,OAAO;AAAA,EAEP,YAAY,QAAoC;AAC9C,UAAM,WAAU,YAAY,MAAM,CAAC;AAAA,EACrC;AAAA,EAEA,OAAO,UAAU,UAAyB;AAd5C;AAeI,QAAI,SAAS,QAAQ,MAAM;AAEzB,aAAO,SAAS,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9C,WAAW,SAAS,QAAQ,aAAa;AAEvC,aAAO,SAAS,QAAQ,YAAY,MAAM,GAAG,EAAE,IAAI;AAAA,IACrD,OAAO;AACL,iBAAK,kBAAL,mBAAoB,KAAK;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,OAAe,YAAY,EAAE,gBAAgB,SAAS,GAAG,OAAO,IAA+B,CAAC,GAA8B;AAC5H,WAAO;AAAA,MACL,SAAS,KAAK,aAAa,OAAO;AAAA,MAClC,kBAAkB,CAAC,MAAMA,aAAY;AACnC,cAAM,OAAO,KAAK,UAAU,IAAI;AAChC,YAAIA,YAAW,QAAQ,KAAK,UAAU,kBAAkB,OAAO;AAC7D,UAAAA,SAAQ,kBAAkB,IAAI;AAC9B,qBAAO,kBAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAAA,QACpC;AACA,eAAO,KAAK,UAAU,IAAI;AAAA,MAC5B;AAAA,MACA,mBAAmB,CAAC,SAAS;AAC3B,YAAI;AACF,iBAAO,KAAK,MAAM,IAAI;AAAA,QACxB,QAAQ;AACN,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,OAAe,aAAa,SAA+C;AACzE,UAAM,eAAe,IAAI,0BAAa;AACtC,iBAAa,IAAI,UAAU,mCAAmC;AAC9D,iBAAa,IAAI,gBAAgB,kBAAkB;AACnD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC,EAAG,cAAa,IAAI,KAAK,KAAK;AACrF,WAAO;AAAA,EACT;AACF;;;ADpDA,IAAAC,eAAqB;AAEd,IAAM,QAAQ,IAAI,UAAU;","names":["headers","import_pako"]}
|
package/dist/node/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
package/dist/node/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
package/dist/node/index.d.ts
DELETED
package/dist/node/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
package/dist/node/index.mjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// src/AxiosJson.ts
|
|
2
|
-
import { Axios, AxiosHeaders } from "axios";
|
|
3
|
-
import { gzip } from "pako";
|
|
4
|
-
var AxiosJson = class _AxiosJson extends Axios {
|
|
5
|
-
static defaultLogger;
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super(_AxiosJson.axiosConfig(config));
|
|
8
|
-
}
|
|
9
|
-
static finalPath(response) {
|
|
10
|
-
var _a;
|
|
11
|
-
if (response.request.path) {
|
|
12
|
-
return response.request.path.split("/").pop();
|
|
13
|
-
} else if (response.request.responseURL) {
|
|
14
|
-
return response.request.responseURL.split("/").pop();
|
|
15
|
-
} else {
|
|
16
|
-
(_a = this.defaultLogger) == null ? void 0 : _a.warn("Failed to get final path from response");
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
static axiosConfig({ compressLength, headers, ...config } = {}) {
|
|
20
|
-
return {
|
|
21
|
-
headers: this.buildHeaders(headers),
|
|
22
|
-
transformRequest: (data, headers2) => {
|
|
23
|
-
const json = JSON.stringify(data);
|
|
24
|
-
if (headers2 && data && json.length > (compressLength ?? 1024)) {
|
|
25
|
-
headers2["Content-Encoding"] = "gzip";
|
|
26
|
-
return gzip(JSON.stringify(data)).buffer;
|
|
27
|
-
}
|
|
28
|
-
return JSON.stringify(data);
|
|
29
|
-
},
|
|
30
|
-
transformResponse: (data) => {
|
|
31
|
-
try {
|
|
32
|
-
return JSON.parse(data);
|
|
33
|
-
} catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
...config
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
static buildHeaders(headers) {
|
|
41
|
-
const axiosHeaders = new AxiosHeaders();
|
|
42
|
-
axiosHeaders.set("Accept", "application/json, text/plain, *.*");
|
|
43
|
-
axiosHeaders.set("Content-Type", "application/json");
|
|
44
|
-
for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value);
|
|
45
|
-
return axiosHeaders;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// src/index.ts
|
|
50
|
-
import { gzip as gzip2 } from "pako";
|
|
51
|
-
var axios = new AxiosJson();
|
|
52
|
-
export {
|
|
53
|
-
AxiosJson,
|
|
54
|
-
axios,
|
|
55
|
-
gzip2 as gzip
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/AxiosJson.ts","../../src/index.ts"],"sourcesContent":["import { Logger } from '@xylabs/logger'\nimport { Axios, AxiosHeaders, AxiosResponse, RawAxiosRequestConfig } from 'axios'\nimport { gzip } from 'pako'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & { compressLength?: number }\n\nexport class AxiosJson extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: RawAxiosJsonRequestConfig) {\n super(AxiosJson.axiosConfig(config))\n }\n\n static finalPath(response: AxiosResponse) {\n if (response.request.path) {\n // nodejs\n return response.request.path.split('/').pop()\n } else if (response.request.responseURL) {\n // browser\n return response.request.responseURL.split('/').pop()\n } else {\n this.defaultLogger?.warn('Failed to get final path from response')\n }\n }\n\n private static axiosConfig({ compressLength, headers, ...config }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data, headers) => {\n const json = JSON.stringify(data)\n if (headers && data && json.length > (compressLength ?? 1024)) {\n headers['Content-Encoding'] = 'gzip'\n return gzip(JSON.stringify(data)).buffer\n }\n return JSON.stringify(data)\n },\n transformResponse: (data) => {\n try {\n return JSON.parse(data)\n } catch {\n return null\n }\n },\n ...config,\n }\n }\n\n private static buildHeaders(headers: RawAxiosJsonRequestConfig['headers']) {\n const axiosHeaders = new AxiosHeaders()\n axiosHeaders.set('Accept', 'application/json, text/plain, *.*')\n axiosHeaders.set('Content-Type', 'application/json')\n for (const [key, value] of Object.entries(headers ?? {})) axiosHeaders.set(key, value)\n return axiosHeaders\n }\n}\n","import { AxiosJson } from './AxiosJson.ts'\n\nexport * from './AxiosJson.ts'\nexport { gzip } from 'pako'\n\nexport const axios = new AxiosJson()\n"],"mappings":";AACA,SAAS,OAAO,oBAA0D;AAC1E,SAAS,YAAY;AAKd,IAAM,YAAN,MAAM,mBAAkB,MAAM;AAAA,EACnC,OAAO;AAAA,EAEP,YAAY,QAAoC;AAC9C,UAAM,WAAU,YAAY,MAAM,CAAC;AAAA,EACrC;AAAA,EAEA,OAAO,UAAU,UAAyB;AAd5C;AAeI,QAAI,SAAS,QAAQ,MAAM;AAEzB,aAAO,SAAS,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9C,WAAW,SAAS,QAAQ,aAAa;AAEvC,aAAO,SAAS,QAAQ,YAAY,MAAM,GAAG,EAAE,IAAI;AAAA,IACrD,OAAO;AACL,iBAAK,kBAAL,mBAAoB,KAAK;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,OAAe,YAAY,EAAE,gBAAgB,SAAS,GAAG,OAAO,IAA+B,CAAC,GAA8B;AAC5H,WAAO;AAAA,MACL,SAAS,KAAK,aAAa,OAAO;AAAA,MAClC,kBAAkB,CAAC,MAAMA,aAAY;AACnC,cAAM,OAAO,KAAK,UAAU,IAAI;AAChC,YAAIA,YAAW,QAAQ,KAAK,UAAU,kBAAkB,OAAO;AAC7D,UAAAA,SAAQ,kBAAkB,IAAI;AAC9B,iBAAO,KAAK,KAAK,UAAU,IAAI,CAAC,EAAE;AAAA,QACpC;AACA,eAAO,KAAK,UAAU,IAAI;AAAA,MAC5B;AAAA,MACA,mBAAmB,CAAC,SAAS;AAC3B,YAAI;AACF,iBAAO,KAAK,MAAM,IAAI;AAAA,QACxB,QAAQ;AACN,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EAEA,OAAe,aAAa,SAA+C;AACzE,UAAM,eAAe,IAAI,aAAa;AACtC,iBAAa,IAAI,UAAU,mCAAmC;AAC9D,iBAAa,IAAI,gBAAgB,kBAAkB;AACnD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC,EAAG,cAAa,IAAI,KAAK,KAAK;AACrF,WAAO;AAAA,EACT;AACF;;;ACpDA,SAAS,QAAAC,aAAY;AAEd,IAAM,QAAQ,IAAI,UAAU;","names":["headers","gzip"]}
|