@xylabs/axios 5.0.29 → 5.0.31

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.
@@ -1,14 +1,13 @@
1
1
  import type { Logger } from '@xylabs/logger';
2
- import type { AxiosRequestConfig, AxiosResponse } from 'axios';
2
+ import type { AxiosResponse, RawAxiosRequestConfig } from 'axios';
3
3
  import { Axios } from 'axios';
4
- export type AxiosJsonRequestConfig<D = any> = AxiosRequestConfig<D> & {
4
+ export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
5
5
  compressLength?: number;
6
6
  };
7
- export type AxiosType = typeof Axios;
8
7
  export declare class AxiosJson extends Axios {
9
8
  static defaultLogger?: Logger;
10
- constructor(config?: AxiosJsonRequestConfig);
11
- static create(config?: AxiosJsonRequestConfig): Axios;
9
+ constructor(config?: RawAxiosJsonRequestConfig);
10
+ static create(config?: RawAxiosJsonRequestConfig): Axios;
12
11
  static finalPath(response: AxiosResponse): any;
13
12
  private static axiosConfig;
14
13
  private static buildHeaders;
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,KAAK,EAAgB,MAAM,OAAO,CAAA;AAI3C,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjG,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAA;AAEpC,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;gBAEjB,MAAM,CAAC,EAAE,sBAAsB;IAI3C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAChB,KAAK;IAGlC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAwB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
1
+ {"version":3,"file":"AxiosJson.d.ts","sourceRoot":"","sources":["../../src/AxiosJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,KAAK,EAAgB,MAAM,OAAO,CAAA;AAI3C,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,MAAM,CAAC,MAAM,CAAC,EAAE,yBAAyB;IAIhD,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,WAAW;IAwB1B,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
@@ -1,13 +1,13 @@
1
1
  // src/AxiosJson.ts
2
2
  import { Axios, AxiosHeaders } from "axios";
3
3
  import { gzip } from "pako";
4
- var AxiosJson = class extends Axios {
4
+ var AxiosJson = class _AxiosJson extends Axios {
5
5
  static defaultLogger;
6
6
  constructor(config) {
7
- super(config);
7
+ super(_AxiosJson.axiosConfig(config));
8
8
  }
9
9
  static create(config) {
10
- return new this(config);
10
+ return new Axios(this.axiosConfig(config));
11
11
  }
12
12
  static finalPath(response) {
13
13
  if (response.request.path) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/AxiosJson.ts","../../src/AxiosJsonUncompressed.ts","../../src/index.ts"],"sourcesContent":["import type { Logger } from '@xylabs/logger'\nimport type { AxiosRequestConfig, AxiosResponse } from 'axios'\nimport { Axios, AxiosHeaders } from 'axios'\nimport { gzip } from 'pako'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AxiosJsonRequestConfig<D = any> = AxiosRequestConfig<D> & { compressLength?: number }\n\nexport type AxiosType = typeof Axios\n\nexport class AxiosJson extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: AxiosJsonRequestConfig) {\n super(config)\n }\n\n static create(config?: AxiosJsonRequestConfig) {\n return new this(config) as Axios\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({\n compressLength, headers, ...config\n }: AxiosJsonRequestConfig = {}): AxiosJsonRequestConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data, headers) => {\n const json = JSON.stringify(data)\n if (headers !== undefined && data && json.length > (compressLength ?? 1024)) {\n headers.set('Content-Encoding', 'gzip')\n return gzip(json).buffer\n }\n return json\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: AxiosJsonRequestConfig['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 type { Logger } from '@xylabs/logger'\nimport type { AxiosRequestConfig, AxiosResponse } from 'axios'\nimport { Axios, AxiosHeaders } from 'axios'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AxiosJsonRequestUncompressedConfig<D = any> = AxiosRequestConfig<D>\n\nexport class AxiosJsonUncompressed extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: AxiosJsonRequestUncompressedConfig) {\n super(AxiosJsonUncompressed.axiosConfig(config))\n }\n\n static create(config?: AxiosJsonRequestUncompressedConfig) {\n return new this(config) as Axios\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({ headers, ...config }: AxiosJsonRequestUncompressedConfig = {}): AxiosJsonRequestUncompressedConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data) => {\n const json = JSON.stringify(data)\n return JSON.stringify(json)\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: AxiosJsonRequestUncompressedConfig['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'\nimport { AxiosJsonUncompressed } from './AxiosJsonUncompressed.ts'\n\nexport * from './AxiosJson.ts'\nexport * from './AxiosJsonUncompressed.ts'\nexport { gzip } from 'pako'\n\nexport const axios = new AxiosJson()\nexport const axiosUncompressed = new AxiosJsonUncompressed()\n"],"mappings":";AAEA,SAAS,OAAO,oBAAoB;AACpC,SAAS,YAAY;AAOd,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC,OAAO;AAAA,EAEP,YAAY,QAAiC;AAC3C,UAAM,MAAM;AAAA,EACd;AAAA,EAEA,OAAO,OAAO,QAAiC;AAC7C,WAAO,IAAI,KAAK,MAAM;AAA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ts","../../src/AxiosJsonUncompressed.ts","../../src/index.ts"],"sourcesContent":["import type { Logger } from '@xylabs/logger'\nimport type { AxiosResponse, RawAxiosRequestConfig } from 'axios'\nimport { Axios, AxiosHeaders } 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 create(config?: RawAxiosJsonRequestConfig) {\n return new Axios(this.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({\n compressLength, headers, ...config\n }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data, headers) => {\n const json = JSON.stringify(data)\n if (headers !== undefined && data && json.length > (compressLength ?? 1024)) {\n headers.set('Content-Encoding', 'gzip')\n return gzip(json).buffer\n }\n return json\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 type { Logger } from '@xylabs/logger'\nimport type { AxiosRequestConfig, AxiosResponse } from 'axios'\nimport { Axios, AxiosHeaders } from 'axios'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AxiosJsonRequestUncompressedConfig<D = any> = AxiosRequestConfig<D>\n\nexport class AxiosJsonUncompressed extends Axios {\n static defaultLogger?: Logger\n\n constructor(config?: AxiosJsonRequestUncompressedConfig) {\n super(AxiosJsonUncompressed.axiosConfig(config))\n }\n\n static create(config?: AxiosJsonRequestUncompressedConfig) {\n return new this(config) as Axios\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({ headers, ...config }: AxiosJsonRequestUncompressedConfig = {}): AxiosJsonRequestUncompressedConfig {\n return {\n headers: this.buildHeaders(headers),\n transformRequest: (data) => {\n const json = JSON.stringify(data)\n return JSON.stringify(json)\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: AxiosJsonRequestUncompressedConfig['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'\nimport { AxiosJsonUncompressed } from './AxiosJsonUncompressed.ts'\n\nexport * from './AxiosJson.ts'\nexport * from './AxiosJsonUncompressed.ts'\nexport { gzip } from 'pako'\n\nexport const axios = new AxiosJson()\nexport const axiosUncompressed = new AxiosJsonUncompressed()\n"],"mappings":";AAEA,SAAS,OAAO,oBAAoB;AACpC,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,OAAO,QAAoC;AAChD,WAAO,IAAI,MAAM,KAAK,YAA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ED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/axios",
3
- "version": "5.0.29",
3
+ "version": "5.0.31",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "axios",
@@ -42,7 +42,7 @@
42
42
  "src"
43
43
  ],
44
44
  "dependencies": {
45
- "@xylabs/logger": "~5.0.29",
45
+ "@xylabs/logger": "~5.0.31",
46
46
  "pako": "~2.1.0"
47
47
  },
48
48
  "devDependencies": {
package/src/AxiosJson.ts CHANGED
@@ -1,22 +1,20 @@
1
1
  import type { Logger } from '@xylabs/logger'
2
- import type { AxiosRequestConfig, AxiosResponse } from 'axios'
2
+ import type { AxiosResponse, RawAxiosRequestConfig } from 'axios'
3
3
  import { Axios, AxiosHeaders } from 'axios'
4
4
  import { gzip } from 'pako'
5
5
 
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- export type AxiosJsonRequestConfig<D = any> = AxiosRequestConfig<D> & { compressLength?: number }
8
-
9
- export type AxiosType = typeof Axios
7
+ export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & { compressLength?: number }
10
8
 
11
9
  export class AxiosJson extends Axios {
12
10
  static defaultLogger?: Logger
13
11
 
14
- constructor(config?: AxiosJsonRequestConfig) {
15
- super(config)
12
+ constructor(config?: RawAxiosJsonRequestConfig) {
13
+ super(AxiosJson.axiosConfig(config))
16
14
  }
17
15
 
18
- static create(config?: AxiosJsonRequestConfig) {
19
- return new this(config) as Axios
16
+ static create(config?: RawAxiosJsonRequestConfig) {
17
+ return new Axios(this.axiosConfig(config))
20
18
  }
21
19
 
22
20
  static finalPath(response: AxiosResponse) {
@@ -33,7 +31,7 @@ export class AxiosJson extends Axios {
33
31
 
34
32
  private static axiosConfig({
35
33
  compressLength, headers, ...config
36
- }: AxiosJsonRequestConfig = {}): AxiosJsonRequestConfig {
34
+ }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {
37
35
  return {
38
36
  headers: this.buildHeaders(headers),
39
37
  transformRequest: (data, headers) => {
@@ -55,7 +53,7 @@ export class AxiosJson extends Axios {
55
53
  }
56
54
  }
57
55
 
58
- private static buildHeaders(headers: AxiosJsonRequestConfig['headers']) {
56
+ private static buildHeaders(headers: RawAxiosJsonRequestConfig['headers']) {
59
57
  const axiosHeaders = new AxiosHeaders()
60
58
  axiosHeaders.set('Accept', 'application/json, text/plain, *.*')
61
59
  axiosHeaders.set('Content-Type', 'application/json')