@nizza/core 0.6.2-beta.0 → 0.6.2-beta.1
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.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +132 -132
- package/dist/index.mjs.map +1 -1
- package/dist/lib/clean-architecture/infrastructure/clients/http-axios.client.d.ts +5 -5
- package/dist/lib/clean-architecture/infrastructure/clients/http-axios.client.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5373,138 +5373,6 @@ W.formToJSON = (t) => Vo(y.isHTMLForm(t) ? new FormData(t) : t);
|
|
|
5373
5373
|
W.getAdapter = Bo.getAdapter;
|
|
5374
5374
|
W.HttpStatusCode = nr;
|
|
5375
5375
|
W.default = W;
|
|
5376
|
-
class zg {
|
|
5377
|
-
constructor(e) {
|
|
5378
|
-
w(this, "logger");
|
|
5379
|
-
w(this, "axiosInstance");
|
|
5380
|
-
this.logger = e.logger, this.axiosInstance = W.create({
|
|
5381
|
-
baseURL: e.baseUrl,
|
|
5382
|
-
headers: e.accessToken ? { Authorization: `Bearer ${e.accessToken}` } : {}
|
|
5383
|
-
});
|
|
5384
|
-
}
|
|
5385
|
-
/**
|
|
5386
|
-
* Performs a GET request to the specified path.
|
|
5387
|
-
*
|
|
5388
|
-
* @param {string} path - The endpoint path.
|
|
5389
|
-
* @returns {Promise<T>} - The response data.
|
|
5390
|
-
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
5391
|
-
*/
|
|
5392
|
-
async get(e) {
|
|
5393
|
-
try {
|
|
5394
|
-
return (await this.axiosInstance.get(e)).data;
|
|
5395
|
-
} catch (n) {
|
|
5396
|
-
throw this.handleError(n);
|
|
5397
|
-
}
|
|
5398
|
-
}
|
|
5399
|
-
/**
|
|
5400
|
-
* Performs a POST request to the specified path with the provided data.
|
|
5401
|
-
*
|
|
5402
|
-
* @param {string} path - The endpoint path.
|
|
5403
|
-
* @param {PostRequestInput} input - The request config.
|
|
5404
|
-
* @returns {Promise<T>} - The response data.
|
|
5405
|
-
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
5406
|
-
*/
|
|
5407
|
-
async post(e, n) {
|
|
5408
|
-
var a;
|
|
5409
|
-
const { data: i = {}, ignoreError: r = !1 } = n;
|
|
5410
|
-
try {
|
|
5411
|
-
return (await this.axiosInstance.post(
|
|
5412
|
-
e,
|
|
5413
|
-
i
|
|
5414
|
-
)).data;
|
|
5415
|
-
} catch (s) {
|
|
5416
|
-
if (r && W.isAxiosError(s))
|
|
5417
|
-
return (a = s.response) == null ? void 0 : a.data;
|
|
5418
|
-
throw this.handleError(s);
|
|
5419
|
-
}
|
|
5420
|
-
}
|
|
5421
|
-
/**
|
|
5422
|
-
* Performs a PUT request to the specified path with the provided data.
|
|
5423
|
-
*
|
|
5424
|
-
* @param {string} path - The endpoint path.
|
|
5425
|
-
* @param {PostRequestInput} input - The request config.
|
|
5426
|
-
* @returns {Promise<T>} - The response data.
|
|
5427
|
-
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
5428
|
-
*/
|
|
5429
|
-
async put(e, n) {
|
|
5430
|
-
var a;
|
|
5431
|
-
const { data: i = {}, ignoreError: r = !1 } = n;
|
|
5432
|
-
try {
|
|
5433
|
-
return (await this.axiosInstance.put(
|
|
5434
|
-
e,
|
|
5435
|
-
i
|
|
5436
|
-
)).data;
|
|
5437
|
-
} catch (s) {
|
|
5438
|
-
if (r && W.isAxiosError(s))
|
|
5439
|
-
return (a = s.response) == null ? void 0 : a.data;
|
|
5440
|
-
throw this.handleError(s);
|
|
5441
|
-
}
|
|
5442
|
-
}
|
|
5443
|
-
/**
|
|
5444
|
-
* Performs a DELETE request to the specified path.
|
|
5445
|
-
*
|
|
5446
|
-
* @param {string} path - The endpoint path.
|
|
5447
|
-
* @returns {Promise<T>} - The response data.
|
|
5448
|
-
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
5449
|
-
*/
|
|
5450
|
-
async delete(e) {
|
|
5451
|
-
try {
|
|
5452
|
-
return (await this.axiosInstance.delete(e)).data;
|
|
5453
|
-
} catch (n) {
|
|
5454
|
-
throw this.handleError(n);
|
|
5455
|
-
}
|
|
5456
|
-
}
|
|
5457
|
-
/**
|
|
5458
|
-
* Handles errors from Axios requests, logging them and returning a user-friendly error message.
|
|
5459
|
-
*
|
|
5460
|
-
* @param {unknown} error - The error object from Axios.
|
|
5461
|
-
* @returns {Error} - A new error with a user-friendly message.
|
|
5462
|
-
*/
|
|
5463
|
-
handleError(e) {
|
|
5464
|
-
var r;
|
|
5465
|
-
let n = te.GENERAL_ERROR;
|
|
5466
|
-
if (W.isAxiosError(e))
|
|
5467
|
-
if (e.response)
|
|
5468
|
-
switch (e.response.status) {
|
|
5469
|
-
case 400:
|
|
5470
|
-
n = te.BAD_REQUEST;
|
|
5471
|
-
break;
|
|
5472
|
-
case 401:
|
|
5473
|
-
n = te.UNAUTHORIZED;
|
|
5474
|
-
break;
|
|
5475
|
-
case 403:
|
|
5476
|
-
n = te.FORBIDDEN;
|
|
5477
|
-
break;
|
|
5478
|
-
case 404:
|
|
5479
|
-
n = te.NOT_FOUND;
|
|
5480
|
-
break;
|
|
5481
|
-
case 409:
|
|
5482
|
-
n = te.CONFLICT;
|
|
5483
|
-
break;
|
|
5484
|
-
case 410:
|
|
5485
|
-
n = te.GONE;
|
|
5486
|
-
break;
|
|
5487
|
-
case 415:
|
|
5488
|
-
n = te.UNSUPPORTED_MEDIA_TYPE;
|
|
5489
|
-
break;
|
|
5490
|
-
case 429:
|
|
5491
|
-
n = te.TOO_MANY_REQUESTS;
|
|
5492
|
-
break;
|
|
5493
|
-
case 500:
|
|
5494
|
-
n = te.INTERNAL_SERVER_ERROR;
|
|
5495
|
-
break;
|
|
5496
|
-
case 503:
|
|
5497
|
-
n = te.SERVICE_UNAVAILABLE;
|
|
5498
|
-
break;
|
|
5499
|
-
default:
|
|
5500
|
-
n = te.SERVER_ERROR;
|
|
5501
|
-
}
|
|
5502
|
-
else
|
|
5503
|
-
e.request ? n = te.NETWORK_ERROR : n = te.CONFIG_ERROR;
|
|
5504
|
-
const i = uh(n);
|
|
5505
|
-
return this.logger.error("Error Code:", n, "Message:", i), this.logger.error("Result Data:", (r = e.response) == null ? void 0 : r.data), new Error(i);
|
|
5506
|
-
}
|
|
5507
|
-
}
|
|
5508
5376
|
const Mf = {
|
|
5509
5377
|
type: "logger",
|
|
5510
5378
|
log(t) {
|
|
@@ -7067,6 +6935,138 @@ ee.hasLoadedNamespace;
|
|
|
7067
6935
|
ee.loadNamespaces;
|
|
7068
6936
|
ee.loadLanguages;
|
|
7069
6937
|
const uh = (t) => Fa(t ? `errorCodes.${t}` : "errorCodes.DEFAULT");
|
|
6938
|
+
class zg {
|
|
6939
|
+
constructor(e) {
|
|
6940
|
+
w(this, "logger");
|
|
6941
|
+
w(this, "axiosInstance");
|
|
6942
|
+
this.logger = e.logger, this.axiosInstance = W.create({
|
|
6943
|
+
baseURL: e.baseUrl,
|
|
6944
|
+
headers: e.accessToken ? { Authorization: `Bearer ${e.accessToken}` } : {}
|
|
6945
|
+
});
|
|
6946
|
+
}
|
|
6947
|
+
/**
|
|
6948
|
+
* Performs a GET request to the specified path.
|
|
6949
|
+
*
|
|
6950
|
+
* @param {string} path - The endpoint path.
|
|
6951
|
+
* @returns {Promise<T>} - The response data.
|
|
6952
|
+
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
6953
|
+
*/
|
|
6954
|
+
async get(e) {
|
|
6955
|
+
try {
|
|
6956
|
+
return (await this.axiosInstance.get(e)).data;
|
|
6957
|
+
} catch (n) {
|
|
6958
|
+
throw this.handleError(n);
|
|
6959
|
+
}
|
|
6960
|
+
}
|
|
6961
|
+
/**
|
|
6962
|
+
* Performs a POST request to the specified path with the provided data.
|
|
6963
|
+
*
|
|
6964
|
+
* @param {string} path - The endpoint path.
|
|
6965
|
+
* @param {PostRequestInput} input - The request config.
|
|
6966
|
+
* @returns {Promise<T>} - The response data.
|
|
6967
|
+
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
6968
|
+
*/
|
|
6969
|
+
async post(e, n) {
|
|
6970
|
+
var a;
|
|
6971
|
+
const { data: i = {}, ignoreError: r = !1 } = n;
|
|
6972
|
+
try {
|
|
6973
|
+
return (await this.axiosInstance.post(
|
|
6974
|
+
e,
|
|
6975
|
+
i
|
|
6976
|
+
)).data;
|
|
6977
|
+
} catch (s) {
|
|
6978
|
+
if (r && W.isAxiosError(s))
|
|
6979
|
+
return (a = s.response) == null ? void 0 : a.data;
|
|
6980
|
+
throw this.handleError(s);
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
/**
|
|
6984
|
+
* Performs a PUT request to the specified path with the provided data.
|
|
6985
|
+
*
|
|
6986
|
+
* @param {string} path - The endpoint path.
|
|
6987
|
+
* @param {PostRequestInput} input - The request config.
|
|
6988
|
+
* @returns {Promise<T>} - The response data.
|
|
6989
|
+
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
6990
|
+
*/
|
|
6991
|
+
async put(e, n) {
|
|
6992
|
+
var a;
|
|
6993
|
+
const { data: i = {}, ignoreError: r = !1 } = n;
|
|
6994
|
+
try {
|
|
6995
|
+
return (await this.axiosInstance.put(
|
|
6996
|
+
e,
|
|
6997
|
+
i
|
|
6998
|
+
)).data;
|
|
6999
|
+
} catch (s) {
|
|
7000
|
+
if (r && W.isAxiosError(s))
|
|
7001
|
+
return (a = s.response) == null ? void 0 : a.data;
|
|
7002
|
+
throw this.handleError(s);
|
|
7003
|
+
}
|
|
7004
|
+
}
|
|
7005
|
+
/**
|
|
7006
|
+
* Performs a DELETE request to the specified path.
|
|
7007
|
+
*
|
|
7008
|
+
* @param {string} path - The endpoint path.
|
|
7009
|
+
* @returns {Promise<T>} - The response data.
|
|
7010
|
+
* @throws {Error} - Throws a user-friendly error message if the request fails.
|
|
7011
|
+
*/
|
|
7012
|
+
async delete(e) {
|
|
7013
|
+
try {
|
|
7014
|
+
return (await this.axiosInstance.delete(e)).data;
|
|
7015
|
+
} catch (n) {
|
|
7016
|
+
throw this.handleError(n);
|
|
7017
|
+
}
|
|
7018
|
+
}
|
|
7019
|
+
/**
|
|
7020
|
+
* Handles errors from Axios requests, logging them and returning a user-friendly error message.
|
|
7021
|
+
*
|
|
7022
|
+
* @param {unknown} error - The error object from Axios.
|
|
7023
|
+
* @returns {Error} - A new error with a user-friendly message.
|
|
7024
|
+
*/
|
|
7025
|
+
handleError(e) {
|
|
7026
|
+
var r;
|
|
7027
|
+
let n = te.GENERAL_ERROR;
|
|
7028
|
+
if (W.isAxiosError(e))
|
|
7029
|
+
if (e.response)
|
|
7030
|
+
switch (e.response.status) {
|
|
7031
|
+
case 400:
|
|
7032
|
+
n = te.BAD_REQUEST;
|
|
7033
|
+
break;
|
|
7034
|
+
case 401:
|
|
7035
|
+
n = te.UNAUTHORIZED;
|
|
7036
|
+
break;
|
|
7037
|
+
case 403:
|
|
7038
|
+
n = te.FORBIDDEN;
|
|
7039
|
+
break;
|
|
7040
|
+
case 404:
|
|
7041
|
+
n = te.NOT_FOUND;
|
|
7042
|
+
break;
|
|
7043
|
+
case 409:
|
|
7044
|
+
n = te.CONFLICT;
|
|
7045
|
+
break;
|
|
7046
|
+
case 410:
|
|
7047
|
+
n = te.GONE;
|
|
7048
|
+
break;
|
|
7049
|
+
case 415:
|
|
7050
|
+
n = te.UNSUPPORTED_MEDIA_TYPE;
|
|
7051
|
+
break;
|
|
7052
|
+
case 429:
|
|
7053
|
+
n = te.TOO_MANY_REQUESTS;
|
|
7054
|
+
break;
|
|
7055
|
+
case 500:
|
|
7056
|
+
n = te.INTERNAL_SERVER_ERROR;
|
|
7057
|
+
break;
|
|
7058
|
+
case 503:
|
|
7059
|
+
n = te.SERVICE_UNAVAILABLE;
|
|
7060
|
+
break;
|
|
7061
|
+
default:
|
|
7062
|
+
n = te.SERVER_ERROR;
|
|
7063
|
+
}
|
|
7064
|
+
else
|
|
7065
|
+
e.request ? n = te.NETWORK_ERROR : n = te.CONFIG_ERROR;
|
|
7066
|
+
const i = uh(n);
|
|
7067
|
+
return this.logger.error("Error Code:", n, "Message:", i), this.logger.error("Result Data:", (r = e.response) == null ? void 0 : r.data), new Error(i);
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
7070
|
var Ko = /* @__PURE__ */ ((t) => (t.VTEX = "VTEX", t.VTEX_IO = "VTEX-IO", t.VTEX_CMS = "PORTAL-VTEX", t.PLATFORM = "PLATFORM", t.UNKNOWN = "UNKNOWN", t))(Ko || {}), ch = /* @__PURE__ */ ((t) => (t.PLATFORM = "platform_module", t.ADENDA = "subscription_module", t.APP_STORE = "app_store", t))(ch || {}), Wo = /* @__PURE__ */ ((t) => (t.ACTIVE = "active_contract", t.INACTIVE = "inactive_contract", t))(Wo || {}), dh = /* @__PURE__ */ ((t) => (t.LITE = "lite", t.STANDARD = "standard", t.PRO = "pro", t))(dh || {}), fh = /* @__PURE__ */ ((t) => (t.LITE = "PLAN_LITE", t.STANDARD = "PLAN_ESTANDAR", t.PRO = "PLAN_PRO", t.NONE = "NO_PLAN", t))(fh || {}), hh = /* @__PURE__ */ ((t) => (t.PAST = "past", t.LIVE = "live", t.FUTURE = "future", t))(hh || {});
|
|
7071
7071
|
class Cr {
|
|
7072
7072
|
constructor(e) {
|