@open-norantec/utilities 2.0.5 → 2.1.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/array-util.class.js +93 -28
- package/dist/attempt-util.class.js +58 -17
- package/dist/crypto-util.class.d.ts +1 -0
- package/dist/crypto-util.class.js +104 -33
- package/dist/date-util.class.js +12 -12
- package/dist/ecdh-util.class.d.ts +0 -2
- package/dist/ecdh-util.class.js +21 -22
- package/dist/enum-util.class.d.ts +1 -1
- package/dist/enum-util.class.js +66 -24
- package/dist/enums.js +2 -5
- package/dist/error-util.class.js +48 -26
- package/dist/eslint-util.class.d.ts +3 -25
- package/dist/eslint-util.class.js +31 -18
- package/dist/header-util.class.js +31 -14
- package/dist/index.js +15 -31
- package/dist/json-util.class.js +8 -8
- package/dist/log-util.class.js +23 -24
- package/dist/schemas.js +56 -59
- package/dist/string-util.class.js +28 -25
- package/dist/url-util.class.js +91 -24
- package/dist/user-agent-util.class.js +10 -10
- package/dist/uuid-util.class.js +13 -13
- package/dist/vm-util.class.js +20 -14
- package/dist/zod.js +1 -17
- package/package.json +4 -2
package/dist/error-util.class.js
CHANGED
|
@@ -1,26 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { UUIDUtil } from './uuid-util.class';
|
|
5
17
|
function isZodError(error) {
|
|
6
18
|
return typeof error === 'object' && error !== null && 'issues' in error && Array.isArray(error.issues);
|
|
7
19
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
var ResponseError = (function (_super) {
|
|
21
|
+
__extends(ResponseError, _super);
|
|
22
|
+
function ResponseError(message, statusCode, status, code) {
|
|
23
|
+
if (statusCode === void 0) { statusCode = 500; }
|
|
24
|
+
if (status === void 0) { status = 500; }
|
|
25
|
+
if (code === void 0) { code = 500; }
|
|
26
|
+
var _this = _super.call(this, message) || this;
|
|
27
|
+
_this.statusCode = statusCode;
|
|
28
|
+
_this.status = status;
|
|
29
|
+
_this.code = code;
|
|
30
|
+
return _this;
|
|
14
31
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
return ResponseError;
|
|
33
|
+
}(Error));
|
|
34
|
+
var ErrorUtil = (function () {
|
|
35
|
+
function ErrorUtil() {
|
|
19
36
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
ErrorUtil.createResponseError = function (error, statusCode) {
|
|
38
|
+
if (statusCode === void 0) { statusCode = 500; }
|
|
39
|
+
return new ResponseError(error.message, statusCode, statusCode, statusCode);
|
|
40
|
+
};
|
|
41
|
+
ErrorUtil.formatError = function (error) {
|
|
42
|
+
var id = UUIDUtil.generateV4();
|
|
43
|
+
var message;
|
|
44
|
+
var errorLogs = [];
|
|
24
45
|
if (isZodError(error)) {
|
|
25
46
|
message = JSON.stringify({
|
|
26
47
|
message: 'Failed to validate your input data ({{context.trace}})',
|
|
@@ -32,7 +53,7 @@ class ErrorUtil {
|
|
|
32
53
|
}
|
|
33
54
|
else {
|
|
34
55
|
message = JSON.stringify({
|
|
35
|
-
message:
|
|
56
|
+
message: "".concat(error.message || 'An unknown error occurred', " ({{context.trace}})"),
|
|
36
57
|
context: {
|
|
37
58
|
trace: id,
|
|
38
59
|
},
|
|
@@ -40,11 +61,11 @@ class ErrorUtil {
|
|
|
40
61
|
}
|
|
41
62
|
errorLogs.push((error === null || error === void 0 ? void 0 : error.stack) || 'No stack trace available');
|
|
42
63
|
return {
|
|
43
|
-
id,
|
|
44
|
-
message,
|
|
45
|
-
logs: errorLogs.map((log)
|
|
64
|
+
id: id,
|
|
65
|
+
message: message,
|
|
66
|
+
logs: errorLogs.map(function (log) { return "[AUTO_ERROR] [".concat(id, "] [").concat(new Date().toISOString(), "] ").concat(log); }),
|
|
46
67
|
response: new Response(message, {
|
|
47
|
-
status: (()
|
|
68
|
+
status: (function () {
|
|
48
69
|
if (isZodError(error))
|
|
49
70
|
return 400;
|
|
50
71
|
if (error instanceof ResponseError)
|
|
@@ -54,6 +75,7 @@ class ErrorUtil {
|
|
|
54
75
|
headers: { 'Content-Type': 'application/json' },
|
|
55
76
|
}),
|
|
56
77
|
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
};
|
|
79
|
+
return ErrorUtil;
|
|
80
|
+
}());
|
|
81
|
+
export { ErrorUtil };
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
import * as tsParser from '@typescript-eslint/parser';
|
|
2
|
-
import * as stylistic from '@stylistic/eslint-plugin';
|
|
3
1
|
export declare class ESLintUtil {
|
|
4
|
-
static create({ ignores, project }: {
|
|
2
|
+
static create({ ignores, project, rules, }: {
|
|
5
3
|
ignores?: string[];
|
|
6
4
|
project?: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
languageOptions: {
|
|
10
|
-
parser: typeof tsParser;
|
|
11
|
-
parserOptions: {
|
|
12
|
-
project: string;
|
|
13
|
-
tsconfigRootDir: string;
|
|
14
|
-
sourceType: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
ignores: string[];
|
|
18
|
-
plugins: {
|
|
19
|
-
'@typescript-eslint': {
|
|
20
|
-
configs: Record<string, ClassicConfig.Config>;
|
|
21
|
-
meta: FlatConfig.PluginMeta;
|
|
22
|
-
rules: import("@typescript-eslint/eslint-plugin/rules").TypeScriptESLintRules;
|
|
23
|
-
};
|
|
24
|
-
'@stylistic': typeof stylistic;
|
|
25
|
-
prettier: import("@eslint/core").Plugin;
|
|
26
|
-
};
|
|
27
|
-
rules: any;
|
|
28
|
-
}[];
|
|
5
|
+
rules?: Record<string, any>;
|
|
6
|
+
}): Record<string, any>[];
|
|
29
7
|
}
|
|
@@ -1,31 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import * as tsParser from '@typescript-eslint/parser';
|
|
13
|
+
import * as tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
14
|
+
import * as stylistic from '@stylistic/eslint-plugin';
|
|
15
|
+
import * as prettier from 'eslint-plugin-prettier';
|
|
16
|
+
import * as _ from 'lodash';
|
|
17
|
+
var ESLintUtil = (function () {
|
|
18
|
+
function ESLintUtil() {
|
|
19
|
+
}
|
|
20
|
+
ESLintUtil.create = function (_a) {
|
|
21
|
+
var _b, _c, _d, _e;
|
|
22
|
+
var _f = _a.ignores, ignores = _f === void 0 ? [] : _f, _g = _a.project, project = _g === void 0 ? './tsconfig.json' : _g, rules = _a.rules;
|
|
11
23
|
return [
|
|
12
24
|
{
|
|
13
25
|
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.mts', '**/*.cts', '**/*.mjs', '**/*.cjs'],
|
|
14
26
|
languageOptions: {
|
|
15
27
|
parser: tsParser,
|
|
16
28
|
parserOptions: {
|
|
17
|
-
project,
|
|
29
|
+
project: project,
|
|
18
30
|
tsconfigRootDir: process.cwd(),
|
|
19
31
|
sourceType: 'module',
|
|
20
32
|
},
|
|
21
33
|
},
|
|
22
|
-
ignores,
|
|
34
|
+
ignores: ignores,
|
|
23
35
|
plugins: {
|
|
24
36
|
'@typescript-eslint': tsPlugin,
|
|
25
37
|
'@stylistic': stylistic,
|
|
26
|
-
prettier,
|
|
38
|
+
prettier: prettier,
|
|
27
39
|
},
|
|
28
|
-
rules:
|
|
40
|
+
rules: _.merge(__assign(__assign(__assign({}, (_c = (_b = tsPlugin === null || tsPlugin === void 0 ? void 0 : tsPlugin.configs) === null || _b === void 0 ? void 0 : _b.recommended) === null || _c === void 0 ? void 0 : _c.rules), (_e = (_d = prettier === null || prettier === void 0 ? void 0 : prettier.configs) === null || _d === void 0 ? void 0 : _d.recommended) === null || _e === void 0 ? void 0 : _e.rules), { 'prettier/prettier': [
|
|
29
41
|
'error',
|
|
30
42
|
{
|
|
31
43
|
singleQuote: true,
|
|
@@ -48,9 +60,10 @@ class ESLintUtil {
|
|
|
48
60
|
requireLast: false,
|
|
49
61
|
},
|
|
50
62
|
},
|
|
51
|
-
], 'object-curly-newline': ['error', { multiline: true, consistent: true }] }),
|
|
63
|
+
], 'object-curly-newline': ['error', { multiline: true, consistent: true }], 'multiline-ternary': 'off' }), rules || {}),
|
|
52
64
|
},
|
|
53
65
|
];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
66
|
+
};
|
|
67
|
+
return ESLintUtil;
|
|
68
|
+
}());
|
|
69
|
+
export { ESLintUtil };
|
|
@@ -1,17 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
import { StringUtil } from './string-util.class';
|
|
18
|
+
var HeaderUtil = (function () {
|
|
19
|
+
function HeaderUtil() {
|
|
20
|
+
}
|
|
21
|
+
HeaderUtil.parse = function (headers) {
|
|
22
|
+
var getValue = function (name) {
|
|
8
23
|
var _a;
|
|
9
|
-
if (!headers ||
|
|
24
|
+
if (!headers || StringUtil.isFalsyString(name)) {
|
|
10
25
|
return null;
|
|
11
26
|
}
|
|
12
27
|
try {
|
|
13
|
-
return (_a = Object.entries(headers).find((
|
|
14
|
-
|
|
28
|
+
return (_a = Object.entries(headers).find(function (_a) {
|
|
29
|
+
var _b = __read(_a, 1), key = _b[0];
|
|
30
|
+
if (StringUtil.isFalsyString(key) || key.toUpperCase() !== name.toUpperCase()) {
|
|
15
31
|
return false;
|
|
16
32
|
}
|
|
17
33
|
return true;
|
|
@@ -22,8 +38,9 @@ class HeaderUtil {
|
|
|
22
38
|
}
|
|
23
39
|
};
|
|
24
40
|
return {
|
|
25
|
-
getValue,
|
|
41
|
+
getValue: getValue,
|
|
26
42
|
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
};
|
|
44
|
+
return HeaderUtil;
|
|
45
|
+
}());
|
|
46
|
+
export { HeaderUtil };
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./array-util.class"), exports);
|
|
18
|
-
__exportStar(require("./attempt-util.class"), exports);
|
|
19
|
-
__exportStar(require("./header-util.class"), exports);
|
|
20
|
-
__exportStar(require("./json-util.class"), exports);
|
|
21
|
-
__exportStar(require("./string-util.class"), exports);
|
|
22
|
-
__exportStar(require("./user-agent-util.class"), exports);
|
|
23
|
-
__exportStar(require("./enum-util.class"), exports);
|
|
24
|
-
__exportStar(require("./log-util.class"), exports);
|
|
25
|
-
__exportStar(require("./crypto-util.class"), exports);
|
|
26
|
-
__exportStar(require("./date-util.class"), exports);
|
|
27
|
-
__exportStar(require("./url-util.class"), exports);
|
|
28
|
-
__exportStar(require("./error-util.class"), exports);
|
|
29
|
-
__exportStar(require("./zod"), exports);
|
|
30
|
-
__exportStar(require("./schemas"), exports);
|
|
31
|
-
__exportStar(require("./enums"), exports);
|
|
1
|
+
export * from './array-util.class';
|
|
2
|
+
export * from './attempt-util.class';
|
|
3
|
+
export * from './header-util.class';
|
|
4
|
+
export * from './json-util.class';
|
|
5
|
+
export * from './string-util.class';
|
|
6
|
+
export * from './user-agent-util.class';
|
|
7
|
+
export * from './enum-util.class';
|
|
8
|
+
export * from './log-util.class';
|
|
9
|
+
export * from './crypto-util.class';
|
|
10
|
+
export * from './date-util.class';
|
|
11
|
+
export * from './url-util.class';
|
|
12
|
+
export * from './error-util.class';
|
|
13
|
+
export * from './zod';
|
|
14
|
+
export * from './schemas';
|
|
15
|
+
export * from './enums';
|
package/dist/json-util.class.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static parse(literal, onError) {
|
|
1
|
+
var JSONUtil = (function () {
|
|
2
|
+
function JSONUtil() {
|
|
3
|
+
}
|
|
4
|
+
JSONUtil.parse = function (literal, onError) {
|
|
6
5
|
var _a;
|
|
7
6
|
try {
|
|
8
7
|
return JSON.parse(literal);
|
|
@@ -10,6 +9,7 @@ class JSONUtil {
|
|
|
10
9
|
catch (e) {
|
|
11
10
|
return (_a = onError === null || onError === void 0 ? void 0 : onError(e)) !== null && _a !== void 0 ? _a : null;
|
|
12
11
|
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
};
|
|
13
|
+
return JSONUtil;
|
|
14
|
+
}());
|
|
15
|
+
export { JSONUtil };
|
package/dist/log-util.class.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class LogUtil {
|
|
8
|
-
constructor(defaultLogLevel = 'info') {
|
|
1
|
+
import { StringUtil } from './string-util.class';
|
|
2
|
+
import { cyan, gray, yellow, red } from 'colors';
|
|
3
|
+
var LOG_LEVELS = ['debug', 'verbose', 'info', 'warn', 'error'];
|
|
4
|
+
var LogUtil = (function () {
|
|
5
|
+
function LogUtil(defaultLogLevel) {
|
|
6
|
+
if (defaultLogLevel === void 0) { defaultLogLevel = 'info'; }
|
|
9
7
|
this.defaultLogLevel = defaultLogLevel;
|
|
10
8
|
}
|
|
11
|
-
match(bottomLogLevel, logLevel) {
|
|
9
|
+
LogUtil.prototype.match = function (bottomLogLevel, logLevel) {
|
|
12
10
|
if (bottomLogLevel === false)
|
|
13
11
|
return false;
|
|
14
12
|
if (bottomLogLevel === true)
|
|
15
13
|
return true;
|
|
16
|
-
return LOG_LEVELS.slice(LOG_LEVELS.findIndex((level)
|
|
17
|
-
}
|
|
18
|
-
log(level, message) {
|
|
14
|
+
return LOG_LEVELS.slice(LOG_LEVELS.findIndex(function (level) { return level === bottomLogLevel; })).includes(logLevel);
|
|
15
|
+
};
|
|
16
|
+
LogUtil.prototype.log = function (level, message) {
|
|
19
17
|
var _a, _b, _c, _d;
|
|
20
|
-
|
|
18
|
+
var colorizer = (function () {
|
|
21
19
|
switch (level) {
|
|
22
20
|
case 'debug':
|
|
23
|
-
return
|
|
21
|
+
return gray;
|
|
24
22
|
case 'verbose':
|
|
25
|
-
return
|
|
23
|
+
return cyan;
|
|
26
24
|
case 'info':
|
|
27
|
-
return (text)
|
|
25
|
+
return function (text) { return text; };
|
|
28
26
|
case 'warn':
|
|
29
|
-
return
|
|
27
|
+
return yellow;
|
|
30
28
|
case 'error':
|
|
31
|
-
return
|
|
29
|
+
return red;
|
|
32
30
|
default:
|
|
33
|
-
return (text)
|
|
31
|
+
return function (text) { return text; };
|
|
34
32
|
}
|
|
35
33
|
})();
|
|
36
34
|
if (this.match(this.defaultLogLevel, level) === false)
|
|
37
35
|
return;
|
|
38
|
-
|
|
36
|
+
var finalExtraMessage = level === 'debug' || (this.defaultLogLevel === 'debug' && level === 'error')
|
|
39
37
|
? (_d = (_c = (_b = (_a = (message instanceof Error ? message : new Error()).stack) === null || _a === void 0 ? void 0 : _a.split) === null || _b === void 0 ? void 0 : _b.call(_a, '\n')) === null || _c === void 0 ? void 0 : _c.slice(1)) === null || _d === void 0 ? void 0 : _d.join('\n')
|
|
40
38
|
: '';
|
|
41
|
-
console.log(colorizer(
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
console.log(colorizer("[".concat(new Date().toLocaleString(), "] [").concat(level.toUpperCase(), "] ").concat(message instanceof Error ? message.message : message).concat(StringUtil.isFalsyString(finalExtraMessage) ? '' : "\n".concat(finalExtraMessage))));
|
|
40
|
+
};
|
|
41
|
+
return LogUtil;
|
|
42
|
+
}());
|
|
43
|
+
export { LogUtil };
|
package/dist/schemas.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const enums_1 = require("./enums");
|
|
7
|
-
const zod_1 = require("./zod");
|
|
8
|
-
const FIND_ONE_OPTIONS_OMIT_PARAMS = {
|
|
1
|
+
import { DateUtil } from './date-util.class';
|
|
2
|
+
import { EnumUtil } from './enum-util.class';
|
|
3
|
+
import { Enums } from './enums';
|
|
4
|
+
import { z } from './zod';
|
|
5
|
+
var FIND_ONE_OPTIONS_OMIT_PARAMS = {
|
|
9
6
|
limit: true,
|
|
10
7
|
lastCursor: true,
|
|
11
8
|
};
|
|
12
|
-
var Schemas;
|
|
9
|
+
export var Schemas;
|
|
13
10
|
(function (Schemas) {
|
|
14
|
-
Schemas.ID =
|
|
15
|
-
Schemas.ID_LIST =
|
|
16
|
-
Schemas.ID_LIST_OBJECT =
|
|
11
|
+
Schemas.ID = z.uuid();
|
|
12
|
+
Schemas.ID_LIST = z.array(Schemas.ID).min(1);
|
|
13
|
+
Schemas.ID_LIST_OBJECT = z.object({
|
|
17
14
|
idList: Schemas.ID_LIST,
|
|
18
15
|
});
|
|
19
|
-
Schemas.ID_OBJECT =
|
|
16
|
+
Schemas.ID_OBJECT = z.object({
|
|
20
17
|
id: Schemas.ID,
|
|
21
18
|
});
|
|
22
|
-
Schemas.JSON_STRING =
|
|
19
|
+
Schemas.JSON_STRING = z.string().refine(function (value) {
|
|
23
20
|
try {
|
|
24
21
|
JSON.parse(value);
|
|
25
22
|
return true;
|
|
@@ -28,35 +25,35 @@ var Schemas;
|
|
|
28
25
|
return false;
|
|
29
26
|
}
|
|
30
27
|
});
|
|
31
|
-
Schemas.DATE_STRING =
|
|
32
|
-
Schemas.TIME_RECORD =
|
|
28
|
+
Schemas.DATE_STRING = z.string().refine(function (value) { return DateUtil.isValidDateString(value); });
|
|
29
|
+
Schemas.TIME_RECORD = z.object({
|
|
33
30
|
createdAt: Schemas.DATE_STRING.nullable().optional(),
|
|
34
31
|
updatedAt: Schemas.DATE_STRING.nullable().optional(),
|
|
35
32
|
});
|
|
36
|
-
Schemas.ORDER_ORIENTATION =
|
|
37
|
-
Schemas.WHERE_CLAUSE_OP =
|
|
38
|
-
Schemas.LOG_LEVEL =
|
|
39
|
-
Schemas.COMMON_RESULT =
|
|
33
|
+
Schemas.ORDER_ORIENTATION = EnumUtil.createEnumSchema(Enums.OrderOrientation);
|
|
34
|
+
Schemas.WHERE_CLAUSE_OP = EnumUtil.createEnumSchema(Enums.WhereClauseOp);
|
|
35
|
+
Schemas.LOG_LEVEL = EnumUtil.createEnumSchema(Enums.LogLevel);
|
|
36
|
+
Schemas.COMMON_RESULT = z
|
|
40
37
|
.object({
|
|
41
|
-
succeeded:
|
|
42
|
-
content:
|
|
38
|
+
succeeded: z.boolean(),
|
|
39
|
+
content: z.string().optional(),
|
|
43
40
|
})
|
|
44
41
|
.extend(Schemas.ID_OBJECT.partial().shape)
|
|
45
42
|
.extend(Schemas.TIME_RECORD.shape);
|
|
46
|
-
Schemas.WHERE_CLAUSE =
|
|
47
|
-
|
|
48
|
-
field:
|
|
43
|
+
Schemas.WHERE_CLAUSE = z.discriminatedUnion('type', [
|
|
44
|
+
z.object({
|
|
45
|
+
field: z.string(),
|
|
49
46
|
op: Schemas.WHERE_CLAUSE_OP,
|
|
50
|
-
type:
|
|
47
|
+
type: z.literal('condition'),
|
|
51
48
|
value: Schemas.JSON_STRING,
|
|
52
49
|
}),
|
|
53
|
-
|
|
54
|
-
literal:
|
|
55
|
-
params:
|
|
56
|
-
type:
|
|
50
|
+
z.object({
|
|
51
|
+
literal: z.string().min(1),
|
|
52
|
+
params: z.array(z.any()).optional(),
|
|
53
|
+
type: z.literal('literal'),
|
|
57
54
|
}),
|
|
58
55
|
]);
|
|
59
|
-
Schemas.CONDITION_ONLY_WHERE_CLAUSE = Schemas.WHERE_CLAUSE.superRefine((value, context)
|
|
56
|
+
Schemas.CONDITION_ONLY_WHERE_CLAUSE = Schemas.WHERE_CLAUSE.superRefine(function (value, context) {
|
|
60
57
|
if ((value === null || value === void 0 ? void 0 : value.type) === 'literal') {
|
|
61
58
|
context.addIssue({
|
|
62
59
|
code: 'custom',
|
|
@@ -64,49 +61,49 @@ var Schemas;
|
|
|
64
61
|
});
|
|
65
62
|
}
|
|
66
63
|
});
|
|
67
|
-
Schemas.ORDER_ITEM =
|
|
68
|
-
field:
|
|
64
|
+
Schemas.ORDER_ITEM = z.object({
|
|
65
|
+
field: z.string(),
|
|
69
66
|
orientation: Schemas.ORDER_ORIENTATION,
|
|
70
67
|
});
|
|
71
|
-
Schemas.PAGINATION_OPTIONS =
|
|
72
|
-
cursorField:
|
|
68
|
+
Schemas.PAGINATION_OPTIONS = z.object({
|
|
69
|
+
cursorField: z.string().default('id').optional(),
|
|
73
70
|
cursorFieldOrderOrientation: Schemas.ORDER_ORIENTATION.default('DESC').optional(),
|
|
74
|
-
lastCursor:
|
|
75
|
-
limit:
|
|
76
|
-
search:
|
|
71
|
+
lastCursor: z.string().optional(),
|
|
72
|
+
limit: z.number().min(0).optional(),
|
|
73
|
+
search: z
|
|
77
74
|
.object({
|
|
78
|
-
fields:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
field:
|
|
82
|
-
ratio:
|
|
75
|
+
fields: z.array(z.union([
|
|
76
|
+
z.string().min(1),
|
|
77
|
+
z.object({
|
|
78
|
+
field: z.string().min(1),
|
|
79
|
+
ratio: z.number().min(-1).max(1).default(1).optional(),
|
|
83
80
|
}),
|
|
84
81
|
])),
|
|
85
|
-
value:
|
|
82
|
+
value: z.string().min(1),
|
|
86
83
|
})
|
|
87
84
|
.optional(),
|
|
88
|
-
order:
|
|
89
|
-
orderField:
|
|
85
|
+
order: z.array(Schemas.ORDER_ITEM).optional(),
|
|
86
|
+
orderField: z.string().default('createdAt').optional(),
|
|
90
87
|
orderFieldOrderOrientation: Schemas.ORDER_ORIENTATION.default('DESC').optional(),
|
|
91
|
-
where:
|
|
88
|
+
where: z.array(z.array(Schemas.WHERE_CLAUSE).min(1)).optional(),
|
|
92
89
|
});
|
|
93
90
|
Schemas.FIND_ONE_OPTIONS = Schemas.PAGINATION_OPTIONS.omit(FIND_ONE_OPTIONS_OMIT_PARAMS);
|
|
94
|
-
Schemas.PAGINATION_RESULT =
|
|
95
|
-
hasNext:
|
|
96
|
-
nextCursor:
|
|
97
|
-
previousCursor:
|
|
91
|
+
Schemas.PAGINATION_RESULT = z.object({
|
|
92
|
+
hasNext: z.boolean(),
|
|
93
|
+
nextCursor: z.union([z.string(), z.null()]),
|
|
94
|
+
previousCursor: z.union([z.string(), z.null()]),
|
|
98
95
|
});
|
|
99
|
-
Schemas.FILE =
|
|
96
|
+
Schemas.FILE = z
|
|
100
97
|
.object({
|
|
101
|
-
mimeType:
|
|
102
|
-
name:
|
|
103
|
-
progres:
|
|
104
|
-
size:
|
|
105
|
-
url:
|
|
98
|
+
mimeType: z.string(),
|
|
99
|
+
name: z.string(),
|
|
100
|
+
progres: z.number().min(0).max(1),
|
|
101
|
+
size: z.number().min(0),
|
|
102
|
+
url: z.string(),
|
|
106
103
|
})
|
|
107
104
|
.extend(Schemas.TIME_RECORD.shape);
|
|
108
105
|
Schemas.CONDITION_ONLY_PAGINATION_OPTIONS = Schemas.PAGINATION_OPTIONS.omit({
|
|
109
106
|
where: true,
|
|
110
|
-
}).extend({ where:
|
|
107
|
+
}).extend({ where: z.array(z.array(Schemas.CONDITION_ONLY_WHERE_CLAUSE).min(1)).optional() });
|
|
111
108
|
Schemas.CONDITION_ONLY_FIND_ONE_OPTIONS = Schemas.CONDITION_ONLY_PAGINATION_OPTIONS.omit(FIND_ONE_OPTIONS_OMIT_PARAMS);
|
|
112
|
-
})(Schemas || (
|
|
109
|
+
})(Schemas || (Schemas = {}));
|