pwi-plata-type 0.4.173 → 0.4.174
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/__BUILD__/index.js +1 -2
- package/__BUILD__/index.js.map +1 -1
- package/__BUILD__/libs/axios.js +0 -17
- package/__BUILD__/libs/axios.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -2
- package/src/libs/axios.ts +1 -20
package/__BUILD__/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.PlataFs = exports.PlataSql = exports.
|
|
36
|
+
exports.PlataFs = exports.PlataSql = exports.PlataAxios = exports.PlataSwagger = exports.PlataModels = exports.PlataTools = exports.PlataRoutes = exports.PlataCluster = void 0;
|
|
37
37
|
const PlataCluster = __importStar(require("./libs/cluster"));
|
|
38
38
|
exports.PlataCluster = PlataCluster;
|
|
39
39
|
const PlataRoutes = __importStar(require("./libs/router"));
|
|
@@ -50,5 +50,4 @@ const fs_1 = require("./libs/fs");
|
|
|
50
50
|
Object.defineProperty(exports, "PlataFs", { enumerable: true, get: function () { return fs_1.PlataFs; } });
|
|
51
51
|
const axios_1 = require("./libs/axios");
|
|
52
52
|
Object.defineProperty(exports, "PlataAxios", { enumerable: true, get: function () { return axios_1.PlataAxios; } });
|
|
53
|
-
Object.defineProperty(exports, "PlataAxiosUnsafe", { enumerable: true, get: function () { return axios_1.PlataAxiosUnsafe; } });
|
|
54
53
|
//# sourceMappingURL=index.js.map
|
package/__BUILD__/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAU1C,oCAAY;AAThB,2DAA4C;AAUxC,kCAAW;AATf,yDAA0C;AAUtC,gCAAU;AATd,2DAA4C;AAUxC,kCAAW;AATf,6DAA8C;AAU1C,oCAAY;AAThB,qDAAsC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAU1C,oCAAY;AAThB,2DAA4C;AAUxC,kCAAW;AATf,yDAA0C;AAUtC,gCAAU;AATd,2DAA4C;AAUxC,kCAAW;AATf,6DAA8C;AAU1C,oCAAY;AAThB,qDAAsC;AAWlC,4BAAQ;AAVZ,kCAAmC;AAW/B,wFAXK,YAAO,OAWL;AAVX,wCAAyC;AAQrC,2FARK,kBAAU,OAQL"}
|
package/__BUILD__/libs/axios.js
CHANGED
|
@@ -4,25 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PlataAxios = PlataAxios;
|
|
7
|
-
exports.PlataAxiosUnsafe = PlataAxiosUnsafe;
|
|
8
7
|
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const tools_1 = require("./tools");
|
|
10
8
|
async function PlataAxios(config) {
|
|
11
|
-
config.timeout = config.timeout ?? 1000;
|
|
12
|
-
if (config.timeout === 0) {
|
|
13
|
-
return PlataAxiosUnsafe(config);
|
|
14
|
-
}
|
|
15
|
-
const axiosPromise = PlataAxiosUnsafe(config);
|
|
16
|
-
const timeoutPromise = tools_1.PlataExtra.timeout(config.timeout, {
|
|
17
|
-
errorID: 'PLAX0003',
|
|
18
|
-
msg: 'API externa não respondeu',
|
|
19
|
-
error: {
|
|
20
|
-
stack: new Error().stack
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return Promise.race([axiosPromise, timeoutPromise]);
|
|
24
|
-
}
|
|
25
|
-
async function PlataAxiosUnsafe(config) {
|
|
26
9
|
return (0, axios_1.default)(config).then(resp => resp, err => {
|
|
27
10
|
if (err.response) {
|
|
28
11
|
return err.response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/libs/axios.ts"],"names":[],"mappings":";;;;;AAGA,
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/libs/axios.ts"],"names":[],"mappings":";;;;;AAGA,gCA6BC;AAhCD,kDAAgE;AAGzD,KAAK,UAAU,UAAU,CAAU,MAA0B;IAChE,OAAO,IAAA,eAAK,EAAC,MAAM,CAAC,CAAC,IAAI,CACrB,IAAI,CAAC,EAAE,CAAC,IAAI,EACZ,GAAG,CAAC,EAAE;QACF,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACf,OAAO,GAAG,CAAC,QAAQ,CAAA;QACvB,CAAC;QAED,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACd,OAAO;gBACH,OAAO,EAAE,UAAU;gBACnB,GAAG,EAAE,sCAAsC;gBAC3C,KAAK,EAAE;oBACH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE;oBACxB,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,IAAI,KAAK,EAAE,CAAC,KAAK;iBACzC;aACJ,CAAA;QACL,CAAC;QAED,OAAO;YACH,OAAO,EAAE,UAAU;YACnB,GAAG,EAAE,iDAAiD;YACtD,KAAK,EAAE;gBACH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE;gBACxB,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,IAAI,KAAK,EAAE,CAAC,KAAK;aACzC;SACJ,CAAA;IACL,CAAC,CACJ,CAAA;AACL,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as PlataModels from './libs/models'
|
|
|
5
5
|
import * as PlataSwagger from './libs/swagger'
|
|
6
6
|
import * as PlataSql from './libs/sql'
|
|
7
7
|
import { PlataFs } from './libs/fs'
|
|
8
|
-
import { PlataAxios
|
|
8
|
+
import { PlataAxios } from './libs/axios'
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
PlataCluster,
|
|
@@ -14,7 +14,6 @@ export {
|
|
|
14
14
|
PlataModels,
|
|
15
15
|
PlataSwagger,
|
|
16
16
|
PlataAxios,
|
|
17
|
-
PlataAxiosUnsafe,
|
|
18
17
|
PlataSql,
|
|
19
18
|
PlataFs
|
|
20
19
|
}
|
package/src/libs/axios.ts
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import axios, { AxiosResponse, AxiosRequestConfig } from 'axios'
|
|
2
|
-
import {
|
|
2
|
+
import { PlataResultado } from './tools';
|
|
3
3
|
|
|
4
4
|
export async function PlataAxios<T = any>(config: AxiosRequestConfig): Promise<PlataResultado<AxiosResponse<T>>> {
|
|
5
|
-
config.timeout = config.timeout ?? 1000
|
|
6
|
-
|
|
7
|
-
if (config.timeout === 0) {
|
|
8
|
-
return PlataAxiosUnsafe(config)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const axiosPromise = PlataAxiosUnsafe(config)
|
|
12
|
-
const timeoutPromise = PlataExtra.timeout(config.timeout, {
|
|
13
|
-
errorID: 'PLAX0003',
|
|
14
|
-
msg: 'API externa não respondeu',
|
|
15
|
-
error: {
|
|
16
|
-
stack: new Error().stack
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
return Promise.race([axiosPromise, timeoutPromise])
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function PlataAxiosUnsafe<T = any>(config: AxiosRequestConfig): Promise<PlataResultado<AxiosResponse<T>>> {
|
|
24
5
|
return axios(config).then(
|
|
25
6
|
resp => resp,
|
|
26
7
|
err => {
|