@xylabs/axios 5.0.31 → 5.0.32

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.
@@ -7,9 +7,9 @@ export type RawAxiosJsonRequestConfig<D = any> = RawAxiosRequestConfig<D> & {
7
7
  export declare class AxiosJson extends Axios {
8
8
  static defaultLogger?: Logger;
9
9
  constructor(config?: RawAxiosJsonRequestConfig);
10
+ static axiosConfig({ compressLength, headers, ...config }?: RawAxiosJsonRequestConfig): RawAxiosJsonRequestConfig;
10
11
  static create(config?: RawAxiosJsonRequestConfig): Axios;
11
12
  static finalPath(response: AxiosResponse): any;
12
- private static axiosConfig;
13
13
  private static buildHeaders;
14
14
  }
15
15
  //# sourceMappingURL=AxiosJson.d.ts.map
@@ -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,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
+ {"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,WAAW,CAAC,EACjB,cAAc,EAAE,OAAO,EAAE,GAAG,MAAM,EACnC,GAAE,yBAA8B,GAAG,yBAAyB;IAsB7D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,yBAAyB;IAIhD,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa;IAYxC,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
@@ -6,18 +6,6 @@ var AxiosJson = class _AxiosJson extends Axios {
6
6
  constructor(config) {
7
7
  super(_AxiosJson.axiosConfig(config));
8
8
  }
9
- static create(config) {
10
- return new Axios(this.axiosConfig(config));
11
- }
12
- static finalPath(response) {
13
- if (response.request.path) {
14
- return response.request.path.split("/").pop();
15
- } else if (response.request.responseURL) {
16
- return response.request.responseURL.split("/").pop();
17
- } else {
18
- this.defaultLogger?.warn("Failed to get final path from response");
19
- }
20
- }
21
9
  static axiosConfig({
22
10
  compressLength,
23
11
  headers,
@@ -43,6 +31,18 @@ var AxiosJson = class _AxiosJson extends Axios {
43
31
  ...config
44
32
  };
45
33
  }
34
+ static create(config) {
35
+ return new Axios(this.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
46
  static buildHeaders(headers) {
47
47
  const axiosHeaders = new AxiosHeaders();
48
48
  axiosHeaders.set("Accept", "application/json, text/plain, *.*");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/AxiosJson.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 A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kB;AACnD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC,EAAG,cAAa,IAAI,KAAK,KAAK;AACrF,WAAO;AAAA,EACT;AACF;;;AClDA,SAAS,QAAAC,aAAY;AAEd,IAAM,QAAQ,IAAI,UAAU;AAC5B,IAAM,oBAAoB,IAAI,sBAAsB;","names":["headers","Axios","AxiosHeaders","gzip"]}
1
+ {"version":3,"sources":["../../src/AxiosJson.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 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 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 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()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IAAI,gBAAgB,kBAAkB;AACnD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,CAAC,CAAC,EAAG,cAAa,IAAI,KAAK,KAAK;AACrF,WAAO;AAAA,EACT;AACF;;;AClDA,SAAS,QAAAC,aAAY;AAEd,IAAM,QAAQ,IAAI,UAAU;AAC5B,IAAM,oBAAoB,IAAI,sBAAsB;","names":["headers","Axios","AxiosHeaders","gzip"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/axios",
3
- "version": "5.0.31",
3
+ "version": "5.0.32",
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.31",
45
+ "@xylabs/logger": "~5.0.32",
46
46
  "pako": "~2.1.0"
47
47
  },
48
48
  "devDependencies": {
package/src/AxiosJson.ts CHANGED
@@ -13,23 +13,7 @@ export class AxiosJson extends Axios {
13
13
  super(AxiosJson.axiosConfig(config))
14
14
  }
15
15
 
16
- static create(config?: RawAxiosJsonRequestConfig) {
17
- return new Axios(this.axiosConfig(config))
18
- }
19
-
20
- static finalPath(response: AxiosResponse) {
21
- if (response.request.path) {
22
- // nodejs
23
- return response.request.path.split('/').pop()
24
- } else if (response.request.responseURL) {
25
- // browser
26
- return response.request.responseURL.split('/').pop()
27
- } else {
28
- this.defaultLogger?.warn('Failed to get final path from response')
29
- }
30
- }
31
-
32
- private static axiosConfig({
16
+ static axiosConfig({
33
17
  compressLength, headers, ...config
34
18
  }: RawAxiosJsonRequestConfig = {}): RawAxiosJsonRequestConfig {
35
19
  return {
@@ -53,6 +37,22 @@ export class AxiosJson extends Axios {
53
37
  }
54
38
  }
55
39
 
40
+ static create(config?: RawAxiosJsonRequestConfig) {
41
+ return new Axios(this.axiosConfig(config))
42
+ }
43
+
44
+ static finalPath(response: AxiosResponse) {
45
+ if (response.request.path) {
46
+ // nodejs
47
+ return response.request.path.split('/').pop()
48
+ } else if (response.request.responseURL) {
49
+ // browser
50
+ return response.request.responseURL.split('/').pop()
51
+ } else {
52
+ this.defaultLogger?.warn('Failed to get final path from response')
53
+ }
54
+ }
55
+
56
56
  private static buildHeaders(headers: RawAxiosJsonRequestConfig['headers']) {
57
57
  const axiosHeaders = new AxiosHeaders()
58
58
  axiosHeaders.set('Accept', 'application/json, text/plain, *.*')