@restura/core 1.0.16 → 1.0.18
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.ts +2 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -52,9 +52,10 @@ type ErrorCode = 'BAD_REQUEST' | 'UNAUTHORIZED' | 'PAYMENT_REQUIRED' | 'FORBIDDE
|
|
|
52
52
|
declare class RsError {
|
|
53
53
|
err: ErrorCode;
|
|
54
54
|
msg: string;
|
|
55
|
+
options?: Record<string, unknown>;
|
|
55
56
|
status?: number;
|
|
56
57
|
stack: string;
|
|
57
|
-
constructor(errCode: ErrorCode, message?: string);
|
|
58
|
+
constructor(errCode: ErrorCode, message?: string, options?: Record<string, unknown>);
|
|
58
59
|
static htmlStatus(code: ErrorCode): number;
|
|
59
60
|
static isRsError(error: unknown): error is RsError;
|
|
60
61
|
}
|
package/dist/index.js
CHANGED
|
@@ -233,13 +233,15 @@ var HtmlStatusCodes = /* @__PURE__ */ ((HtmlStatusCodes2) => {
|
|
|
233
233
|
var RsError = class _RsError {
|
|
234
234
|
err;
|
|
235
235
|
msg;
|
|
236
|
+
options;
|
|
236
237
|
status;
|
|
237
238
|
stack;
|
|
238
|
-
constructor(errCode, message) {
|
|
239
|
+
constructor(errCode, message, options) {
|
|
239
240
|
this.err = errCode;
|
|
240
241
|
this.msg = message || "";
|
|
241
242
|
this.status = _RsError.htmlStatus(errCode);
|
|
242
243
|
this.stack = new Error().stack || "";
|
|
244
|
+
this.options = options;
|
|
243
245
|
}
|
|
244
246
|
static htmlStatus(code) {
|
|
245
247
|
return htmlStatusMap[code];
|
|
@@ -334,7 +336,18 @@ var ResponseValidator = class _ResponseValidator {
|
|
|
334
336
|
return { validator: field.type };
|
|
335
337
|
}
|
|
336
338
|
if (field.type.includes("|")) {
|
|
337
|
-
|
|
339
|
+
const hasNull = field.type.includes("null");
|
|
340
|
+
let nonNullExpression = field.type;
|
|
341
|
+
if (hasNull) {
|
|
342
|
+
nonNullExpression = field.type.split("|").map((type) => type.trim()).filter((type) => type !== "null" && type !== "").join(" | ");
|
|
343
|
+
}
|
|
344
|
+
if (nonNullExpression === "") {
|
|
345
|
+
return { validator: "any", isOptionalOrNullable: true };
|
|
346
|
+
}
|
|
347
|
+
if (_ResponseValidator.validatorIsValidString(nonNullExpression)) {
|
|
348
|
+
return { validator: nonNullExpression, isOptionalOrNullable: hasNull };
|
|
349
|
+
}
|
|
350
|
+
return { validator: this.parseValidationEnum(nonNullExpression), isOptionalOrNullable: hasNull };
|
|
338
351
|
}
|
|
339
352
|
return { validator: "object" };
|
|
340
353
|
} else if (field.selector) {
|