@stackone/transport 1.1.2 → 1.1.3

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/index.es.mjs CHANGED
@@ -1 +1 @@
1
- import t from"axios";import e from"qs";const r=["get","post","put","delete","patch","job"];function s(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}var n,a,o,c,i,h;"function"==typeof SuppressedError&&SuppressedError;const p=()=>t.create({maxBodyLength:1/0});class d{constructor({transportInstance:t=p()}={}){n.add(this),a.set(this,void 0),function(t,e,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?n.call(t,r):n?n.value=r:e.set(t,r)}(this,a,t,"f")}async request({headers:t={},url:e,method:r="get",maxRedirects:i=0,responseType:p,cacheTTL:d,context:l,payload:u,httpsAgent:f}){try{const d=s(this,n,"m",o).call(this,t),l=await s(this,a,"f").request({headers:d,url:e,method:r,maxRedirects:i,responseType:p,data:s(this,n,"m",h).call(this,u,d),httpsAgent:f});return{data:l.data,status:l.status,headers:s(this,n,"m",c).call(this,l.headers),requestUrl:e,responseType:l?.config?.responseType,responseTime:new Date}}catch(t){throw t}}async get({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:n}){return this.request({url:e,method:"get",headers:t,maxRedirects:r,cacheTTL:s,context:n})}async post({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:n,payload:a}){return this.request({url:e,method:"post",headers:t,maxRedirects:r,cacheTTL:s,context:n,payload:a})}}a=new WeakMap,n=new WeakSet,o=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r.toLowerCase()]=t[r]||""})),e},c=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r]=t[r]||""})),e},i=function(t){return"application/x-www-form-urlencoded"===t["content-type"]},h=function(t,r){if(t)return s(this,n,"m",i).call(this,r)?e.stringify(t):t};const l=()=>new d;class u{static async getInstance({getHttpClient:t=l}={}){return this.httpClientInstance||(this.httpClientInstance=t()),this.httpClientInstance}static resetInstance(){this.httpClientInstance=null}}u.httpClientInstance=null;export{d as HttpClient,u as HttpClientManager,r as HttpMethods};
1
+ import t from"axios";import e from"qs";const r=["get","post","put","delete","patch"];function s(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}var n,a,o,c,i,h;"function"==typeof SuppressedError&&SuppressedError;const p=()=>t.create({maxBodyLength:1/0});class d{constructor({transportInstance:t=p()}={}){n.add(this),a.set(this,void 0),function(t,e,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?n.call(t,r):n?n.value=r:e.set(t,r)}(this,a,t,"f")}async request({headers:t={},url:e,method:r="get",maxRedirects:i=0,responseType:p,cacheTTL:d,context:l,payload:u,httpsAgent:f}){try{const d=s(this,n,"m",o).call(this,t),l=await s(this,a,"f").request({headers:d,url:e,method:r,maxRedirects:i,responseType:p,data:s(this,n,"m",h).call(this,u,d),httpsAgent:f});return{data:l.data,status:l.status,headers:s(this,n,"m",c).call(this,l.headers),requestUrl:e,responseType:l?.config?.responseType,responseTime:new Date}}catch(t){throw t}}async get({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:n}){return this.request({url:e,method:"get",headers:t,maxRedirects:r,cacheTTL:s,context:n})}async post({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:n,payload:a}){return this.request({url:e,method:"post",headers:t,maxRedirects:r,cacheTTL:s,context:n,payload:a})}}a=new WeakMap,n=new WeakSet,o=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r.toLowerCase()]=t[r]||""})),e},c=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r]=t[r]||""})),e},i=function(t){return"application/x-www-form-urlencoded"===t["content-type"]},h=function(t,r){if(t)return s(this,n,"m",i).call(this,r)?e.stringify(t):t};const l=()=>new d;class u{static async getInstance({getHttpClient:t=l}={}){return this.httpClientInstance||(this.httpClientInstance=t()),this.httpClientInstance}static resetInstance(){this.httpClientInstance=null}}u.httpClientInstance=null;export{d as HttpClient,u as HttpClientManager,r as HttpMethods};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("axios"),e=require("qs");function r(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}var s,a,n,o,c,i;"function"==typeof SuppressedError&&SuppressedError;const h=()=>t.create({maxBodyLength:1/0});class p{constructor({transportInstance:t=h()}={}){s.add(this),a.set(this,void 0),function(t,e,r,s,a){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?a.call(t,r):a?a.value=r:e.set(t,r)}(this,a,t,"f")}async request({headers:t={},url:e,method:c="get",maxRedirects:h=0,responseType:p,cacheTTL:u,context:d,payload:l,httpsAgent:f}){try{const u=r(this,s,"m",n).call(this,t),d=await r(this,a,"f").request({headers:u,url:e,method:c,maxRedirects:h,responseType:p,data:r(this,s,"m",i).call(this,l,u),httpsAgent:f});return{data:d.data,status:d.status,headers:r(this,s,"m",o).call(this,d.headers),requestUrl:e,responseType:d?.config?.responseType,responseTime:new Date}}catch(t){throw t}}async get({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:a}){return this.request({url:e,method:"get",headers:t,maxRedirects:r,cacheTTL:s,context:a})}async post({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:a,payload:n}){return this.request({url:e,method:"post",headers:t,maxRedirects:r,cacheTTL:s,context:a,payload:n})}}a=new WeakMap,s=new WeakSet,n=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r.toLowerCase()]=t[r]||""})),e},o=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r]=t[r]||""})),e},c=function(t){return"application/x-www-form-urlencoded"===t["content-type"]},i=function(t,a){if(t)return r(this,s,"m",c).call(this,a)?e.stringify(t):t};const u=()=>new p;class d{static async getInstance({getHttpClient:t=u}={}){return this.httpClientInstance||(this.httpClientInstance=t()),this.httpClientInstance}static resetInstance(){this.httpClientInstance=null}}d.httpClientInstance=null,exports.HttpClient=p,exports.HttpClientManager=d,exports.HttpMethods=["get","post","put","delete","patch","job"];
1
+ "use strict";var t=require("axios"),e=require("qs");function r(t,e,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(t):s?s.value:e.get(t)}var s,a,n,o,c,i;"function"==typeof SuppressedError&&SuppressedError;const h=()=>t.create({maxBodyLength:1/0});class p{constructor({transportInstance:t=h()}={}){s.add(this),a.set(this,void 0),function(t,e,r,s,a){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?a.call(t,r):a?a.value=r:e.set(t,r)}(this,a,t,"f")}async request({headers:t={},url:e,method:c="get",maxRedirects:h=0,responseType:p,cacheTTL:u,context:d,payload:l,httpsAgent:f}){try{const u=r(this,s,"m",n).call(this,t),d=await r(this,a,"f").request({headers:u,url:e,method:c,maxRedirects:h,responseType:p,data:r(this,s,"m",i).call(this,l,u),httpsAgent:f});return{data:d.data,status:d.status,headers:r(this,s,"m",o).call(this,d.headers),requestUrl:e,responseType:d?.config?.responseType,responseTime:new Date}}catch(t){throw t}}async get({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:a}){return this.request({url:e,method:"get",headers:t,maxRedirects:r,cacheTTL:s,context:a})}async post({headers:t,url:e,maxRedirects:r,cacheTTL:s,context:a,payload:n}){return this.request({url:e,method:"post",headers:t,maxRedirects:r,cacheTTL:s,context:a,payload:n})}}a=new WeakMap,s=new WeakSet,n=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r.toLowerCase()]=t[r]||""})),e},o=function(t){if(!t)return{};const e={};return Object.keys(t).forEach((r=>{e[r]=t[r]||""})),e},c=function(t){return"application/x-www-form-urlencoded"===t["content-type"]},i=function(t,a){if(t)return r(this,s,"m",c).call(this,a)?e.stringify(t):t};const u=()=>new p;class d{static async getInstance({getHttpClient:t=u}={}){return this.httpClientInstance||(this.httpClientInstance=t()),this.httpClientInstance}static resetInstance(){this.httpClientInstance=null}}d.httpClientInstance=null,exports.HttpClient=p,exports.HttpClientManager=d,exports.HttpMethods=["get","post","put","delete","patch"];
@@ -1,6 +1,6 @@
1
1
  import https from 'https';
2
2
  import { AxiosInstance } from 'axios';
3
- import { HttpHeaders, HttpMethod, HttpResponse, IHttpClient, RequestContext } from './types';
3
+ import { HttpHeaders, HttpMethod, HttpResponse, IHttpClient } from './types';
4
4
  export declare class HttpClient implements IHttpClient {
5
5
  #private;
6
6
  constructor({ transportInstance, }?: {
@@ -13,7 +13,7 @@ export declare class HttpClient implements IHttpClient {
13
13
  maxRedirects?: number;
14
14
  responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text';
15
15
  cacheTTL?: number;
16
- context?: RequestContext;
16
+ context?: unknown;
17
17
  payload?: P;
18
18
  httpsAgent?: https.Agent;
19
19
  }): Promise<HttpResponse<T>>;
@@ -22,14 +22,14 @@ export declare class HttpClient implements IHttpClient {
22
22
  url: string;
23
23
  maxRedirects?: number;
24
24
  cacheTTL?: number;
25
- context?: RequestContext;
25
+ context?: unknown;
26
26
  }): Promise<HttpResponse<T>>;
27
27
  post<P, T>({ headers, url, maxRedirects, cacheTTL, context, payload, }: {
28
28
  headers?: HttpHeaders;
29
29
  url: string;
30
30
  maxRedirects?: number;
31
31
  cacheTTL?: number;
32
- context?: RequestContext;
32
+ context?: unknown;
33
33
  payload?: P;
34
34
  }): Promise<HttpResponse<T>>;
35
35
  }
@@ -6,11 +6,8 @@ export interface CertOptions {
6
6
  certs?: string[];
7
7
  keys?: string[];
8
8
  }
9
- export declare const HttpMethods: readonly ["get", "post", "put", "delete", "patch", "job"];
9
+ export declare const HttpMethods: readonly ["get", "post", "put", "delete", "patch"];
10
10
  export type HttpMethod = (typeof HttpMethods)[number];
11
- export type RequestContext = {
12
- accountId: string;
13
- };
14
11
  export type HttpResponse<T = any> = {
15
12
  data: T;
16
13
  status: number;
@@ -27,7 +24,7 @@ export interface IHttpClient {
27
24
  maxRedirects?: number;
28
25
  responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text';
29
26
  cacheTTL?: number;
30
- context?: RequestContext;
27
+ context?: unknown;
31
28
  payload?: P;
32
29
  httpsAgent?: https.Agent;
33
30
  }): Promise<HttpResponse<T>>;
@@ -36,14 +33,14 @@ export interface IHttpClient {
36
33
  url: string;
37
34
  maxRedirects?: number;
38
35
  cacheTTL?: number;
39
- context?: RequestContext;
36
+ context?: unknown;
40
37
  }): Promise<HttpResponse<T>>;
41
38
  post<P, T>({ headers, url, maxRedirects, cacheTTL, context, payload, }: {
42
39
  headers?: HttpHeaders;
43
40
  url: string;
44
41
  maxRedirects?: number;
45
42
  cacheTTL?: number;
46
- context?: RequestContext;
43
+ context?: unknown;
47
44
  payload?: P;
48
45
  }): Promise<HttpResponse<T>>;
49
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/transport",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.mjs",