@open-norantec/utilities 1.0.1-alpha.11 → 1.0.1-alpha.13

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.
@@ -0,0 +1,3 @@
1
+ export declare class ErrorUtil {
2
+ static getErrorMessage(error: Error): string;
3
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorUtil = void 0;
4
+ const zod_1 = require("zod");
5
+ class ErrorUtil {
6
+ static getErrorMessage(error) {
7
+ var _a, _b;
8
+ if (error instanceof zod_1.ZodError)
9
+ return ((_b = (_a = error === null || error === void 0 ? void 0 : error.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || 'Validation error';
10
+ return (error === null || error === void 0 ? void 0 : error.message) || 'An unknown error occurred';
11
+ }
12
+ }
13
+ exports.ErrorUtil = ErrorUtil;
package/dist/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from './log-util.class';
10
10
  export * from './crypto-util.class';
11
11
  export * from './date-util.class';
12
12
  export * from './url-util.class';
13
+ export * from './error-util.class';
package/dist/index.js CHANGED
@@ -26,3 +26,4 @@ __exportStar(require("./log-util.class"), exports);
26
26
  __exportStar(require("./crypto-util.class"), exports);
27
27
  __exportStar(require("./date-util.class"), exports);
28
28
  __exportStar(require("./url-util.class"), exports);
29
+ __exportStar(require("./error-util.class"), exports);
@@ -51,7 +51,7 @@ export declare namespace Enum {
51
51
  };
52
52
  }
53
53
  export declare class SchemaUtil {
54
- static createEnumSchema<const T extends Record<string, string>>(object: T): z.ZodEnum<[T[keyof T], ...T[keyof T][]]>;
54
+ static createEnumSchema<const T extends Record<string, string>>(object: T, params?: z.RawCreateParams): z.ZodEnum<[T[keyof T], ...T[keyof T][]]>;
55
55
  static readonly ID: z.ZodString;
56
56
  static readonly ID_LIST: z.ZodArray<z.ZodString, "many">;
57
57
  static readonly ID_LIST_OBJECT: z.ZodObject<{
@@ -60,8 +60,8 @@ var Enum;
60
60
  };
61
61
  })(Enum || (exports.Enum = Enum = {}));
62
62
  class SchemaUtil {
63
- static createEnumSchema(object) {
64
- return zod_1.z.enum(Object.values(object));
63
+ static createEnumSchema(object, params) {
64
+ return zod_1.z.enum(Object.values(object), params);
65
65
  }
66
66
  }
67
67
  exports.SchemaUtil = SchemaUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-norantec/utilities",
3
- "version": "1.0.1-alpha.11",
3
+ "version": "1.0.1-alpha.13",
4
4
  "description": "NoranTec Utilities",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {