@xylabs/axios 3.6.3 → 3.6.5
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/browser/index.cjs +4 -4
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +2 -3
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +2 -3
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +2 -3
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +3 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +4 -4
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +2 -3
- package/dist/neutral/index.d.cts.map +1 -1
- package/dist/neutral/index.d.mts +2 -3
- package/dist/neutral/index.d.mts.map +1 -1
- package/dist/neutral/index.d.ts +2 -3
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.js +3 -4
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +6 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -3
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +2 -3
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +2 -3
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +3 -4
- package/dist/node/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +2 -6
package/dist/browser/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -31,8 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
32
|
var src_exports = {};
|
|
32
33
|
__export(src_exports, {
|
|
33
34
|
AxiosJson: () => AxiosJson,
|
|
34
|
-
axios: () =>
|
|
35
|
-
default: () => axios,
|
|
35
|
+
axios: () => import_axios2.default,
|
|
36
36
|
gzip: () => import_pako2.gzip
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -85,7 +85,7 @@ var AxiosJson = class _AxiosJson extends import_axios.Axios {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
// src/index.ts
|
|
88
|
+
__reExport(src_exports, require("axios"), module.exports);
|
|
89
|
+
var import_axios2 = __toESM(require("axios"), 1);
|
|
88
90
|
var import_pako2 = require("pako");
|
|
89
|
-
var axios = __toESM(require("axios"), 1);
|
|
90
|
-
var axios2 = __toESM(require("axios"), 1);
|
|
91
91
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["export * from './AxiosJson.js'\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["export * from './AxiosJson.js'\nexport * from 'axios'\nexport { default as axios } from 'axios'\nexport { gzip } from 'pako'\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;;;ADtDA,wBAAc,kBADd;AAEA,IAAAC,gBAAiC;AACjC,IAAAC,eAAqB;","names":["headers","import_axios","import_pako"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/browser/index.js
CHANGED
|
@@ -46,13 +46,12 @@ var AxiosJson = class _AxiosJson extends Axios {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// src/index.ts
|
|
49
|
+
export * from "axios";
|
|
50
|
+
import { default as default2 } from "axios";
|
|
49
51
|
import { gzip as gzip2 } from "pako";
|
|
50
|
-
import * as axios from "axios";
|
|
51
|
-
import * as axios2 from "axios";
|
|
52
52
|
export {
|
|
53
53
|
AxiosJson,
|
|
54
|
-
|
|
55
|
-
axios as default,
|
|
54
|
+
default2 as axios,
|
|
56
55
|
gzip2 as gzip
|
|
57
56
|
};
|
|
58
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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","export * from './AxiosJson.js'\nexport
|
|
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","export * from './AxiosJson.js'\nexport * from 'axios'\nexport { default as axios } from 'axios'\nexport { gzip } from 'pako'\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;;;ACtDA,cAAc;AACd,SAAoB,WAAXC,gBAAwB;AACjC,SAAS,QAAAC,aAAY;","names":["headers","default","gzip"]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -31,8 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
32
|
var src_exports = {};
|
|
32
33
|
__export(src_exports, {
|
|
33
34
|
AxiosJson: () => AxiosJson,
|
|
34
|
-
axios: () =>
|
|
35
|
-
default: () => axios,
|
|
35
|
+
axios: () => import_axios2.default,
|
|
36
36
|
gzip: () => import_pako2.gzip
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -85,7 +85,7 @@ var AxiosJson = class _AxiosJson extends import_axios.Axios {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
// src/index.ts
|
|
88
|
+
__reExport(src_exports, require("axios"), module.exports);
|
|
89
|
+
var import_axios2 = __toESM(require("axios"), 1);
|
|
88
90
|
var import_pako2 = require("pako");
|
|
89
|
-
var axios = __toESM(require("axios"), 1);
|
|
90
|
-
var axios2 = __toESM(require("axios"), 1);
|
|
91
91
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["export * from './AxiosJson.js'\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["export * from './AxiosJson.js'\nexport * from 'axios'\nexport { default as axios } from 'axios'\nexport { gzip } from 'pako'\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;;;ADtDA,wBAAc,kBADd;AAEA,IAAAC,gBAAiC;AACjC,IAAAC,eAAqB;","names":["headers","import_axios","import_pako"]}
|
package/dist/neutral/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/neutral/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/neutral/index.js
CHANGED
|
@@ -46,13 +46,12 @@ var AxiosJson = class _AxiosJson extends Axios {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// src/index.ts
|
|
49
|
+
export * from "axios";
|
|
50
|
+
import { default as default2 } from "axios";
|
|
49
51
|
import { gzip as gzip2 } from "pako";
|
|
50
|
-
import * as axios from "axios";
|
|
51
|
-
import * as axios2 from "axios";
|
|
52
52
|
export {
|
|
53
53
|
AxiosJson,
|
|
54
|
-
|
|
55
|
-
axios as default,
|
|
54
|
+
default2 as axios,
|
|
56
55
|
gzip2 as gzip
|
|
57
56
|
};
|
|
58
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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","export * from './AxiosJson.js'\nexport
|
|
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","export * from './AxiosJson.js'\nexport * from 'axios'\nexport { default as axios } from 'axios'\nexport { gzip } from 'pako'\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;;;ACtDA,cAAc;AACd,SAAoB,WAAXC,gBAAwB;AACjC,SAAS,QAAAC,aAAY;","names":["headers","default","gzip"]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -31,8 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
32
|
var src_exports = {};
|
|
32
33
|
__export(src_exports, {
|
|
33
34
|
AxiosJson: () => AxiosJson,
|
|
34
|
-
axios: () =>
|
|
35
|
-
default: () => axios,
|
|
35
|
+
axios: () => import_axios2.default,
|
|
36
36
|
gzip: () => import_pako2.gzip
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -86,13 +86,14 @@ var AxiosJson = class _AxiosJson extends import_axios.Axios {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
// src/index.ts
|
|
89
|
+
__reExport(src_exports, require("axios"), module.exports);
|
|
90
|
+
var import_axios2 = __toESM(require("axios"), 1);
|
|
89
91
|
var import_pako2 = require("pako");
|
|
90
|
-
var axios = __toESM(require("axios"), 1);
|
|
91
|
-
var axios2 = __toESM(require("axios"), 1);
|
|
92
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
93
93
|
0 && (module.exports = {
|
|
94
94
|
AxiosJson,
|
|
95
95
|
axios,
|
|
96
|
-
gzip
|
|
96
|
+
gzip,
|
|
97
|
+
...require("axios")
|
|
97
98
|
});
|
|
98
99
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["export * from './AxiosJson.js'\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/AxiosJson.ts"],"sourcesContent":["export * from './AxiosJson.js'\nexport * from 'axios'\nexport { default as axios } from 'axios'\nexport { gzip } from 'pako'\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;;;ADtDA,wBAAc,kBADd;AAEA,IAAAC,gBAAiC;AACjC,IAAAC,eAAqB;","names":["headers","import_axios","import_pako"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './AxiosJson.js';
|
|
2
|
+
export * from 'axios';
|
|
3
|
+
export { default as axios } from 'axios';
|
|
2
4
|
export { gzip } from 'pako';
|
|
3
|
-
import * as axios from 'axios';
|
|
4
|
-
export * as axios from 'axios';
|
|
5
|
-
export { axios as default };
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -47,13 +47,12 @@ var AxiosJson = class _AxiosJson extends Axios {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
// src/index.ts
|
|
50
|
+
export * from "axios";
|
|
51
|
+
import { default as default2 } from "axios";
|
|
50
52
|
import { gzip as gzip2 } from "pako";
|
|
51
|
-
import * as axios from "axios";
|
|
52
|
-
import * as axios2 from "axios";
|
|
53
53
|
export {
|
|
54
54
|
AxiosJson,
|
|
55
|
-
|
|
56
|
-
axios as default,
|
|
55
|
+
default2 as axios,
|
|
57
56
|
gzip2 as gzip
|
|
58
57
|
};
|
|
59
58
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","export * from './AxiosJson.js'\nexport
|
|
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","export * from './AxiosJson.js'\nexport * from 'axios'\nexport { default as axios } from 'axios'\nexport { gzip } from 'pako'\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;;;ACtDA,cAAc;AACd,SAAoB,WAAXC,gBAAwB;AACjC,SAAS,QAAAC,aAAY;","names":["headers","default","gzip"]}
|
package/package.json
CHANGED
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@types/pako": "^2.0.3",
|
|
14
|
-
"@xylabs/logger": "^3.6.
|
|
14
|
+
"@xylabs/logger": "^3.6.5",
|
|
15
15
|
"axios": "^1.7.2",
|
|
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": "^3.12.
|
|
21
|
-
"@xylabs/tsconfig": "^3.12.
|
|
22
|
-
"typescript": "^5.5.
|
|
20
|
+
"@xylabs/ts-scripts-yarn3": "^3.12.4",
|
|
21
|
+
"@xylabs/tsconfig": "^3.12.4",
|
|
22
|
+
"typescript": "^5.5.4"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=18"
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"esm"
|
|
70
70
|
],
|
|
71
71
|
"sideEffects": false,
|
|
72
|
-
"version": "3.6.
|
|
72
|
+
"version": "3.6.5",
|
|
73
73
|
"type": "module"
|
|
74
74
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './AxiosJson.js'
|
|
2
|
+
export * from 'axios'
|
|
3
|
+
export { default as axios } from 'axios'
|
|
2
4
|
export { gzip } from 'pako'
|
|
3
|
-
|
|
4
|
-
import * as axios from 'axios'
|
|
5
|
-
export * as axios from 'axios'
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line import/no-default-export
|
|
8
|
-
export { axios as default }
|