@c-rex/core 0.0.1 → 0.0.2
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.d.mts +4 -37
- package/dist/index.d.ts +4 -37
- package/dist/index.js +55 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -2842,73 +2842,13 @@ var require_winston_transport = __commonJS({
|
|
|
2842
2842
|
}
|
|
2843
2843
|
});
|
|
2844
2844
|
|
|
2845
|
-
// src/requests.ts
|
|
2846
|
-
import axios from "axios";
|
|
2847
|
-
|
|
2848
|
-
// src/constants.ts
|
|
2849
|
-
var ALL = "*";
|
|
2850
|
-
var LOG_LEVELS = {
|
|
2851
|
-
critical: 2,
|
|
2852
|
-
error: 3,
|
|
2853
|
-
warning: 4,
|
|
2854
|
-
info: 6,
|
|
2855
|
-
debug: 7
|
|
2856
|
-
};
|
|
2857
|
-
var API = {
|
|
2858
|
-
MAX_RETRY: 3,
|
|
2859
|
-
API_TIMEOUT: 1e4,
|
|
2860
|
-
API_HEADERS: {
|
|
2861
|
-
"content-Type": "application/json"
|
|
2862
|
-
}
|
|
2863
|
-
};
|
|
2864
|
-
|
|
2865
|
-
// src/requests.ts
|
|
2866
|
-
var CrexApi = class {
|
|
2867
|
-
apiClient;
|
|
2868
|
-
logger;
|
|
2869
|
-
constructor(baseUrl, logger) {
|
|
2870
|
-
this.apiClient = axios.create({
|
|
2871
|
-
baseURL: baseUrl,
|
|
2872
|
-
headers: {
|
|
2873
|
-
"content-Type": "application/json"
|
|
2874
|
-
}
|
|
2875
|
-
});
|
|
2876
|
-
this.logger = logger;
|
|
2877
|
-
}
|
|
2878
|
-
async execute({
|
|
2879
|
-
url,
|
|
2880
|
-
method,
|
|
2881
|
-
params,
|
|
2882
|
-
body,
|
|
2883
|
-
headers
|
|
2884
|
-
}) {
|
|
2885
|
-
let response = void 0;
|
|
2886
|
-
for (let retry = 0; retry < API.MAX_RETRY; retry++) {
|
|
2887
|
-
try {
|
|
2888
|
-
response = await this.apiClient.request({
|
|
2889
|
-
url,
|
|
2890
|
-
method,
|
|
2891
|
-
data: body,
|
|
2892
|
-
params,
|
|
2893
|
-
headers
|
|
2894
|
-
});
|
|
2895
|
-
} catch (error) {
|
|
2896
|
-
this.logger.log("error", `API.execute error when request ${url}. Error: ${error}`);
|
|
2897
|
-
throw error;
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
if (response) {
|
|
2901
|
-
return response;
|
|
2902
|
-
}
|
|
2903
|
-
throw new Error("API.execute error: Failed to retrieve a valid response");
|
|
2904
|
-
}
|
|
2905
|
-
};
|
|
2906
|
-
|
|
2907
2845
|
// src/logger.ts
|
|
2908
2846
|
import winston from "winston";
|
|
2847
|
+
import { LOG_LEVELS } from "@c-rex/constants";
|
|
2909
2848
|
|
|
2910
2849
|
// src/transports/matomo.ts
|
|
2911
2850
|
var import_winston_transport = __toESM(require_winston_transport());
|
|
2851
|
+
import { ALL } from "@c-rex/constants";
|
|
2912
2852
|
var MatomoTransport = class extends import_winston_transport.default {
|
|
2913
2853
|
matomoTransport;
|
|
2914
2854
|
constructor(opts) {
|
|
@@ -2927,6 +2867,7 @@ var MatomoTransport = class extends import_winston_transport.default {
|
|
|
2927
2867
|
// src/transports/graylog.ts
|
|
2928
2868
|
var import_winston_transport2 = __toESM(require_winston_transport());
|
|
2929
2869
|
import Graylog2Transport from "winston-graylog2";
|
|
2870
|
+
import { ALL as ALL2 } from "@c-rex/constants";
|
|
2930
2871
|
var GraylogTransport = class extends import_winston_transport2.default {
|
|
2931
2872
|
graylogTransport;
|
|
2932
2873
|
constructor(opts) {
|
|
@@ -2943,7 +2884,7 @@ var GraylogTransport = class extends import_winston_transport2.default {
|
|
|
2943
2884
|
log(info, callback) {
|
|
2944
2885
|
const SDK = CrexSDK.getInstance();
|
|
2945
2886
|
const graylogCategory = SDK.customerConfig.logs.graylog.categoriesLevel;
|
|
2946
|
-
if (graylogCategory.includes(info.category) || graylogCategory.includes(
|
|
2887
|
+
if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL2)) {
|
|
2947
2888
|
this.graylogTransport.log(info, callback);
|
|
2948
2889
|
}
|
|
2949
2890
|
}
|
|
@@ -2981,7 +2922,51 @@ var CrexLogger = class {
|
|
|
2981
2922
|
}
|
|
2982
2923
|
};
|
|
2983
2924
|
|
|
2984
|
-
// src/
|
|
2925
|
+
// src/requests.ts
|
|
2926
|
+
import axios from "axios";
|
|
2927
|
+
import { API } from "@c-rex/constants";
|
|
2928
|
+
var CrexApi = class {
|
|
2929
|
+
apiClient;
|
|
2930
|
+
logger;
|
|
2931
|
+
constructor(baseUrl, logger) {
|
|
2932
|
+
this.apiClient = axios.create({
|
|
2933
|
+
baseURL: baseUrl,
|
|
2934
|
+
headers: {
|
|
2935
|
+
"content-Type": "application/json"
|
|
2936
|
+
}
|
|
2937
|
+
});
|
|
2938
|
+
this.logger = logger;
|
|
2939
|
+
}
|
|
2940
|
+
async execute({
|
|
2941
|
+
url,
|
|
2942
|
+
method,
|
|
2943
|
+
params,
|
|
2944
|
+
body,
|
|
2945
|
+
headers
|
|
2946
|
+
}) {
|
|
2947
|
+
let response = void 0;
|
|
2948
|
+
for (let retry = 0; retry < API.MAX_RETRY; retry++) {
|
|
2949
|
+
try {
|
|
2950
|
+
response = await this.apiClient.request({
|
|
2951
|
+
url,
|
|
2952
|
+
method,
|
|
2953
|
+
data: body,
|
|
2954
|
+
params,
|
|
2955
|
+
headers
|
|
2956
|
+
});
|
|
2957
|
+
} catch (error) {
|
|
2958
|
+
this.logger.log("error", `API.execute error when request ${url}. Error: ${error}`);
|
|
2959
|
+
throw error;
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
if (response) {
|
|
2963
|
+
return response;
|
|
2964
|
+
}
|
|
2965
|
+
throw new Error("API.execute error: Failed to retrieve a valid response");
|
|
2966
|
+
}
|
|
2967
|
+
};
|
|
2968
|
+
|
|
2969
|
+
// src/sdk.ts
|
|
2985
2970
|
var CrexSDK = class _CrexSDK {
|
|
2986
2971
|
static instance;
|
|
2987
2972
|
customerConfig;
|
|
@@ -3004,6 +2989,8 @@ var CrexSDK = class _CrexSDK {
|
|
|
3004
2989
|
}
|
|
3005
2990
|
};
|
|
3006
2991
|
export {
|
|
2992
|
+
CrexApi,
|
|
2993
|
+
CrexLogger,
|
|
3007
2994
|
CrexSDK
|
|
3008
2995
|
};
|
|
3009
2996
|
/*! Bundled license information:
|