prom-pal-ui 1.4.3 → 1.5.0
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/build/components/cjs/index.js +19 -1
- package/build/components/esm/index.js +19 -2
- package/build/function/cjs/index.js +186 -0
- package/build/function/esm/index.js +186 -1
- package/build/types/components/form/rules/mask.d.ts +2 -1
- package/build/types/function/lib/index.d.ts +1 -0
- package/build/types/function/lib/logger.d.ts +25 -0
- package/package.json +5 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
+
require('path');
|
|
5
|
+
require('fs/promises');
|
|
4
6
|
var ReactDOM = require('react-dom');
|
|
5
7
|
var reactHookForm = require('react-hook-form');
|
|
6
8
|
|
|
@@ -3960,6 +3962,13 @@ function cn() {
|
|
|
3960
3962
|
return twMerge(clsx(inputs));
|
|
3961
3963
|
}
|
|
3962
3964
|
|
|
3965
|
+
var PromLogLevel;
|
|
3966
|
+
(function (PromLogLevel) {
|
|
3967
|
+
PromLogLevel["INFO"] = "INFO";
|
|
3968
|
+
PromLogLevel["WARN"] = "WARN";
|
|
3969
|
+
PromLogLevel["ERROR"] = "ERROR";
|
|
3970
|
+
})(PromLogLevel || (PromLogLevel = {}));
|
|
3971
|
+
|
|
3963
3972
|
var buttonVariants = cva("inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
3964
3973
|
variants: {
|
|
3965
3974
|
variant: {
|
|
@@ -21772,7 +21781,7 @@ var PromInput = function (_a) {
|
|
|
21772
21781
|
};
|
|
21773
21782
|
return (jsxRuntimeExports.jsx(PromFormFiled, { control: control, name: name, render: function (_a) {
|
|
21774
21783
|
var field = _a.field, fieldState = _a.fieldState;
|
|
21775
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
|
|
21784
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col w-full", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
|
|
21776
21785
|
} }));
|
|
21777
21786
|
};
|
|
21778
21787
|
|
|
@@ -22303,6 +22312,14 @@ var promMaskPhoneWithoutPlus = function (val) {
|
|
|
22303
22312
|
}
|
|
22304
22313
|
return cleaned;
|
|
22305
22314
|
};
|
|
22315
|
+
var promMaskUrl = function (val) {
|
|
22316
|
+
if (!val)
|
|
22317
|
+
return val;
|
|
22318
|
+
var httpsIndex = val.indexOf("https");
|
|
22319
|
+
if (httpsIndex === -1)
|
|
22320
|
+
return val;
|
|
22321
|
+
return val.substring(httpsIndex);
|
|
22322
|
+
};
|
|
22306
22323
|
var promMaskEmail = function (val) {
|
|
22307
22324
|
if (!val)
|
|
22308
22325
|
return val;
|
|
@@ -24708,6 +24725,7 @@ exports.promMaskEmail = promMaskEmail;
|
|
|
24708
24725
|
exports.promMaskPhone = promMaskPhone;
|
|
24709
24726
|
exports.promMaskPhoneWithoutPlus = promMaskPhoneWithoutPlus;
|
|
24710
24727
|
exports.promMaskTelegram = promMaskTelegram;
|
|
24728
|
+
exports.promMaskUrl = promMaskUrl;
|
|
24711
24729
|
exports.promMaskWhatsapp = promMaskWhatsapp;
|
|
24712
24730
|
exports.promSchemaPhone = promSchemaPhone;
|
|
24713
24731
|
exports.promSelectFilterOptions = promSelectFilterOptions;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { forwardRef, createElement, useLayoutEffect, useState } from 'react';
|
|
3
|
+
import 'path';
|
|
4
|
+
import 'fs/promises';
|
|
3
5
|
import * as ReactDOM from 'react-dom';
|
|
4
6
|
import ReactDOM__default from 'react-dom';
|
|
5
7
|
import { get, set as set$1, appendErrors, useForm, FormProvider, useFormContext, useFormState, Controller } from 'react-hook-form';
|
|
@@ -3940,6 +3942,13 @@ function cn() {
|
|
|
3940
3942
|
return twMerge(clsx(inputs));
|
|
3941
3943
|
}
|
|
3942
3944
|
|
|
3945
|
+
var PromLogLevel;
|
|
3946
|
+
(function (PromLogLevel) {
|
|
3947
|
+
PromLogLevel["INFO"] = "INFO";
|
|
3948
|
+
PromLogLevel["WARN"] = "WARN";
|
|
3949
|
+
PromLogLevel["ERROR"] = "ERROR";
|
|
3950
|
+
})(PromLogLevel || (PromLogLevel = {}));
|
|
3951
|
+
|
|
3943
3952
|
var buttonVariants = cva("inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
3944
3953
|
variants: {
|
|
3945
3954
|
variant: {
|
|
@@ -21752,7 +21761,7 @@ var PromInput = function (_a) {
|
|
|
21752
21761
|
};
|
|
21753
21762
|
return (jsxRuntimeExports.jsx(PromFormFiled, { control: control, name: name, render: function (_a) {
|
|
21754
21763
|
var field = _a.field, fieldState = _a.fieldState;
|
|
21755
|
-
return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
|
|
21764
|
+
return (jsxRuntimeExports.jsxs("div", { className: "space-y-2 relative flex flex-col w-full", children: [label && (jsxRuntimeExports.jsx(PromLabel, { className: cn("block text-sm font-medium", styleTitle), children: label })), jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [jsxRuntimeExports.jsx("input", __assign({}, field, props, { type: inputType, onChange: function (e) { return handleChange(e.target.value); }, disabled: isLoad || props.disabled, className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", styleWrapper) })), type === "password" && (jsxRuntimeExports.jsx("button", { type: "button", onClick: togglePasswordVisibility, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 focus:outline-none", tabIndex: -1, disabled: props.disabled, children: showPassword ? (jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4" })) : (jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })) }))] }), fieldState.error && (jsxRuntimeExports.jsx("p", { className: "text-red-500 text-sm mt-1 text-center w-full", children: fieldState.error.message }))] }));
|
|
21756
21765
|
} }));
|
|
21757
21766
|
};
|
|
21758
21767
|
|
|
@@ -22283,6 +22292,14 @@ var promMaskPhoneWithoutPlus = function (val) {
|
|
|
22283
22292
|
}
|
|
22284
22293
|
return cleaned;
|
|
22285
22294
|
};
|
|
22295
|
+
var promMaskUrl = function (val) {
|
|
22296
|
+
if (!val)
|
|
22297
|
+
return val;
|
|
22298
|
+
var httpsIndex = val.indexOf("https");
|
|
22299
|
+
if (httpsIndex === -1)
|
|
22300
|
+
return val;
|
|
22301
|
+
return val.substring(httpsIndex);
|
|
22302
|
+
};
|
|
22286
22303
|
var promMaskEmail = function (val) {
|
|
22287
22304
|
if (!val)
|
|
22288
22305
|
return val;
|
|
@@ -24654,4 +24671,4 @@ var PROM_MSG_ERROR = {
|
|
|
24654
24671
|
INVALID_VALUES: "Недопустимые значения",
|
|
24655
24672
|
};
|
|
24656
24673
|
|
|
24657
|
-
export { PROM_MSG_ERROR, PromButton, PromCheckbox, PromFormFiled, PromFrom, PromInput, PromLabel, PromMessage, PromSelect, PromSelectContent, PromSelectField, PromSelectGroup, PromSelectItem, PromSelectLabel, PromSelectScrollDownButton, PromSelectScrollUpButton, PromSelectSeparator, PromSelectTrigger, PromSelectValue, PromSkeleton, PromSwitch, PromSwitchField, PromSwitchListField, PromTextarea, promAllowedPatternEmail, promAllowedPatternNaturalNumbers, promAllowedPatternOnlyRu, promAllowedPatternPhone, promAllowedPatternPhoneWithoutPlus, promAllowedPatternUrlSocial, promMaskEmail, promMaskPhone, promMaskPhoneWithoutPlus, promMaskTelegram, promMaskWhatsapp, promSchemaPhone, promSelectFilterOptions, useCreatePromForm, usePromForm };
|
|
24674
|
+
export { PROM_MSG_ERROR, PromButton, PromCheckbox, PromFormFiled, PromFrom, PromInput, PromLabel, PromMessage, PromSelect, PromSelectContent, PromSelectField, PromSelectGroup, PromSelectItem, PromSelectLabel, PromSelectScrollDownButton, PromSelectScrollUpButton, PromSelectSeparator, PromSelectTrigger, PromSelectValue, PromSkeleton, PromSwitch, PromSwitchField, PromSwitchListField, PromTextarea, promAllowedPatternEmail, promAllowedPatternNaturalNumbers, promAllowedPatternOnlyRu, promAllowedPatternPhone, promAllowedPatternPhoneWithoutPlus, promAllowedPatternUrlSocial, promMaskEmail, promMaskPhone, promMaskPhoneWithoutPlus, promMaskTelegram, promMaskUrl, promMaskWhatsapp, promSchemaPhone, promSelectFilterOptions, useCreatePromForm, usePromForm };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var fs = require('fs/promises');
|
|
4
6
|
|
|
5
7
|
/******************************************************************************
|
|
6
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -19,6 +21,17 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
19
21
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
20
22
|
|
|
21
23
|
|
|
24
|
+
var __assign = function() {
|
|
25
|
+
__assign = Object.assign || function __assign(t) {
|
|
26
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
+
s = arguments[i];
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
return __assign.apply(this, arguments);
|
|
33
|
+
};
|
|
34
|
+
|
|
22
35
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
23
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
24
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -3171,5 +3184,178 @@ function cn() {
|
|
|
3171
3184
|
return twMerge(clsx(inputs));
|
|
3172
3185
|
}
|
|
3173
3186
|
|
|
3187
|
+
var PromLogLevel;
|
|
3188
|
+
(function (PromLogLevel) {
|
|
3189
|
+
PromLogLevel["INFO"] = "INFO";
|
|
3190
|
+
PromLogLevel["WARN"] = "WARN";
|
|
3191
|
+
PromLogLevel["ERROR"] = "ERROR";
|
|
3192
|
+
})(PromLogLevel || (PromLogLevel = {}));
|
|
3193
|
+
var PromLoggerServer = /** @class */ (function () {
|
|
3194
|
+
function PromLoggerServer() {
|
|
3195
|
+
}
|
|
3196
|
+
PromLoggerServer.prototype.log = function (level, message, data) {
|
|
3197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3198
|
+
var logPath, date, fileName, filePath, logEntry, errorFilePath, error_1;
|
|
3199
|
+
return __generator(this, function (_a) {
|
|
3200
|
+
switch (_a.label) {
|
|
3201
|
+
case 0:
|
|
3202
|
+
logPath = path.join("logs");
|
|
3203
|
+
_a.label = 1;
|
|
3204
|
+
case 1:
|
|
3205
|
+
_a.trys.push([1, 6, , 7]);
|
|
3206
|
+
return [4 /*yield*/, fs.mkdir(logPath, { recursive: true })];
|
|
3207
|
+
case 2:
|
|
3208
|
+
_a.sent();
|
|
3209
|
+
date = new Date().toISOString().split("T")[0];
|
|
3210
|
+
fileName = level === "ERROR"
|
|
3211
|
+
? "errors-".concat(date, ".log")
|
|
3212
|
+
: "".concat(level.toLowerCase(), "-").concat(date, ".log");
|
|
3213
|
+
filePath = path.join(logPath, fileName);
|
|
3214
|
+
logEntry = __assign({ timestamp: new Date().toISOString(), level: level, message: message }, (data && { data: data }));
|
|
3215
|
+
return [4 /*yield*/, fs.appendFile(filePath, JSON.stringify(logEntry) + "\n", "utf8")];
|
|
3216
|
+
case 3:
|
|
3217
|
+
_a.sent();
|
|
3218
|
+
if (!(level === "ERROR")) return [3 /*break*/, 5];
|
|
3219
|
+
errorFilePath = path.join(logPath, "errors-".concat(date, ".log"));
|
|
3220
|
+
return [4 /*yield*/, fs.appendFile(errorFilePath, JSON.stringify(logEntry) + "\n", "utf8")];
|
|
3221
|
+
case 4:
|
|
3222
|
+
_a.sent();
|
|
3223
|
+
_a.label = 5;
|
|
3224
|
+
case 5: return [3 /*break*/, 7];
|
|
3225
|
+
case 6:
|
|
3226
|
+
error_1 = _a.sent();
|
|
3227
|
+
console.error("Failed to write log:", error_1);
|
|
3228
|
+
return [3 /*break*/, 7];
|
|
3229
|
+
case 7: return [2 /*return*/];
|
|
3230
|
+
}
|
|
3231
|
+
});
|
|
3232
|
+
});
|
|
3233
|
+
};
|
|
3234
|
+
PromLoggerServer.prototype.info = function (message, data) {
|
|
3235
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3236
|
+
return __generator(this, function (_a) {
|
|
3237
|
+
switch (_a.label) {
|
|
3238
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.INFO, message, data)];
|
|
3239
|
+
case 1:
|
|
3240
|
+
_a.sent();
|
|
3241
|
+
return [2 /*return*/];
|
|
3242
|
+
}
|
|
3243
|
+
});
|
|
3244
|
+
});
|
|
3245
|
+
};
|
|
3246
|
+
PromLoggerServer.prototype.warn = function (message, data) {
|
|
3247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3248
|
+
return __generator(this, function (_a) {
|
|
3249
|
+
switch (_a.label) {
|
|
3250
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.WARN, message, data)];
|
|
3251
|
+
case 1:
|
|
3252
|
+
_a.sent();
|
|
3253
|
+
return [2 /*return*/];
|
|
3254
|
+
}
|
|
3255
|
+
});
|
|
3256
|
+
});
|
|
3257
|
+
};
|
|
3258
|
+
PromLoggerServer.prototype.error = function (message, error, context) {
|
|
3259
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3260
|
+
var errorData;
|
|
3261
|
+
return __generator(this, function (_a) {
|
|
3262
|
+
switch (_a.label) {
|
|
3263
|
+
case 0:
|
|
3264
|
+
errorData = __assign(__assign({}, (error && __assign({ errorMessage: error.message, stack: error.stack }, (error.response && { status: error.response.status })))), (context && { context: context }));
|
|
3265
|
+
return [4 /*yield*/, this.log(PromLogLevel.ERROR, message, errorData)];
|
|
3266
|
+
case 1:
|
|
3267
|
+
_a.sent();
|
|
3268
|
+
return [2 /*return*/];
|
|
3269
|
+
}
|
|
3270
|
+
});
|
|
3271
|
+
});
|
|
3272
|
+
};
|
|
3273
|
+
return PromLoggerServer;
|
|
3274
|
+
}());
|
|
3275
|
+
var PromLoggerClient = /** @class */ (function () {
|
|
3276
|
+
function PromLoggerClient() {
|
|
3277
|
+
}
|
|
3278
|
+
PromLoggerClient.prototype.log = function (level, message, data) {
|
|
3279
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3280
|
+
var response, _a, _b, _c, e_1;
|
|
3281
|
+
return __generator(this, function (_d) {
|
|
3282
|
+
switch (_d.label) {
|
|
3283
|
+
case 0:
|
|
3284
|
+
_d.trys.push([0, 4, , 5]);
|
|
3285
|
+
return [4 /*yield*/, fetch("/api/log", {
|
|
3286
|
+
method: "POST",
|
|
3287
|
+
headers: { "Content-Type": "application/json" },
|
|
3288
|
+
body: JSON.stringify({
|
|
3289
|
+
level: level,
|
|
3290
|
+
message: message,
|
|
3291
|
+
data: data,
|
|
3292
|
+
timestamp: new Date().toISOString(),
|
|
3293
|
+
}),
|
|
3294
|
+
})];
|
|
3295
|
+
case 1:
|
|
3296
|
+
response = _d.sent();
|
|
3297
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
3298
|
+
_b = (_a = console).error;
|
|
3299
|
+
_c = ["Failed to send log:"];
|
|
3300
|
+
return [4 /*yield*/, response.text()];
|
|
3301
|
+
case 2:
|
|
3302
|
+
_b.apply(_a, _c.concat([_d.sent()]));
|
|
3303
|
+
_d.label = 3;
|
|
3304
|
+
case 3: return [3 /*break*/, 5];
|
|
3305
|
+
case 4:
|
|
3306
|
+
e_1 = _d.sent();
|
|
3307
|
+
console.error("Failed to send log:", e_1);
|
|
3308
|
+
return [3 /*break*/, 5];
|
|
3309
|
+
case 5: return [2 /*return*/];
|
|
3310
|
+
}
|
|
3311
|
+
});
|
|
3312
|
+
});
|
|
3313
|
+
};
|
|
3314
|
+
PromLoggerClient.prototype.info = function (message, data) {
|
|
3315
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3316
|
+
return __generator(this, function (_a) {
|
|
3317
|
+
switch (_a.label) {
|
|
3318
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.INFO, message, data)];
|
|
3319
|
+
case 1:
|
|
3320
|
+
_a.sent();
|
|
3321
|
+
return [2 /*return*/];
|
|
3322
|
+
}
|
|
3323
|
+
});
|
|
3324
|
+
});
|
|
3325
|
+
};
|
|
3326
|
+
PromLoggerClient.prototype.warn = function (message, data) {
|
|
3327
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3328
|
+
return __generator(this, function (_a) {
|
|
3329
|
+
switch (_a.label) {
|
|
3330
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.WARN, message, data)];
|
|
3331
|
+
case 1:
|
|
3332
|
+
_a.sent();
|
|
3333
|
+
return [2 /*return*/];
|
|
3334
|
+
}
|
|
3335
|
+
});
|
|
3336
|
+
});
|
|
3337
|
+
};
|
|
3338
|
+
PromLoggerClient.prototype.error = function (message, error, context) {
|
|
3339
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3340
|
+
var errorData;
|
|
3341
|
+
return __generator(this, function (_a) {
|
|
3342
|
+
switch (_a.label) {
|
|
3343
|
+
case 0:
|
|
3344
|
+
errorData = __assign(__assign({}, (error && __assign({ errorMessage: error.message, stack: error.stack }, (error.response && { status: error.response.status })))), (context && { context: context }));
|
|
3345
|
+
return [4 /*yield*/, this.log(PromLogLevel.ERROR, message, errorData)];
|
|
3346
|
+
case 1:
|
|
3347
|
+
_a.sent();
|
|
3348
|
+
return [2 /*return*/];
|
|
3349
|
+
}
|
|
3350
|
+
});
|
|
3351
|
+
});
|
|
3352
|
+
};
|
|
3353
|
+
return PromLoggerClient;
|
|
3354
|
+
}());
|
|
3355
|
+
var promLogger = typeof window === "undefined"
|
|
3356
|
+
? new PromLoggerServer()
|
|
3357
|
+
: new PromLoggerClient();
|
|
3358
|
+
|
|
3174
3359
|
exports.cn = cn;
|
|
3360
|
+
exports.promLogger = promLogger;
|
|
3175
3361
|
exports.usePromPromiseQuery = usePromPromiseQuery;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs/promises';
|
|
2
4
|
|
|
3
5
|
/******************************************************************************
|
|
4
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -17,6 +19,17 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
17
19
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
18
20
|
|
|
19
21
|
|
|
22
|
+
var __assign = function() {
|
|
23
|
+
__assign = Object.assign || function __assign(t) {
|
|
24
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25
|
+
s = arguments[i];
|
|
26
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
27
|
+
}
|
|
28
|
+
return t;
|
|
29
|
+
};
|
|
30
|
+
return __assign.apply(this, arguments);
|
|
31
|
+
};
|
|
32
|
+
|
|
20
33
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
34
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
35
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -3169,4 +3182,176 @@ function cn() {
|
|
|
3169
3182
|
return twMerge(clsx(inputs));
|
|
3170
3183
|
}
|
|
3171
3184
|
|
|
3172
|
-
|
|
3185
|
+
var PromLogLevel;
|
|
3186
|
+
(function (PromLogLevel) {
|
|
3187
|
+
PromLogLevel["INFO"] = "INFO";
|
|
3188
|
+
PromLogLevel["WARN"] = "WARN";
|
|
3189
|
+
PromLogLevel["ERROR"] = "ERROR";
|
|
3190
|
+
})(PromLogLevel || (PromLogLevel = {}));
|
|
3191
|
+
var PromLoggerServer = /** @class */ (function () {
|
|
3192
|
+
function PromLoggerServer() {
|
|
3193
|
+
}
|
|
3194
|
+
PromLoggerServer.prototype.log = function (level, message, data) {
|
|
3195
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3196
|
+
var logPath, date, fileName, filePath, logEntry, errorFilePath, error_1;
|
|
3197
|
+
return __generator(this, function (_a) {
|
|
3198
|
+
switch (_a.label) {
|
|
3199
|
+
case 0:
|
|
3200
|
+
logPath = path.join("logs");
|
|
3201
|
+
_a.label = 1;
|
|
3202
|
+
case 1:
|
|
3203
|
+
_a.trys.push([1, 6, , 7]);
|
|
3204
|
+
return [4 /*yield*/, fs.mkdir(logPath, { recursive: true })];
|
|
3205
|
+
case 2:
|
|
3206
|
+
_a.sent();
|
|
3207
|
+
date = new Date().toISOString().split("T")[0];
|
|
3208
|
+
fileName = level === "ERROR"
|
|
3209
|
+
? "errors-".concat(date, ".log")
|
|
3210
|
+
: "".concat(level.toLowerCase(), "-").concat(date, ".log");
|
|
3211
|
+
filePath = path.join(logPath, fileName);
|
|
3212
|
+
logEntry = __assign({ timestamp: new Date().toISOString(), level: level, message: message }, (data && { data: data }));
|
|
3213
|
+
return [4 /*yield*/, fs.appendFile(filePath, JSON.stringify(logEntry) + "\n", "utf8")];
|
|
3214
|
+
case 3:
|
|
3215
|
+
_a.sent();
|
|
3216
|
+
if (!(level === "ERROR")) return [3 /*break*/, 5];
|
|
3217
|
+
errorFilePath = path.join(logPath, "errors-".concat(date, ".log"));
|
|
3218
|
+
return [4 /*yield*/, fs.appendFile(errorFilePath, JSON.stringify(logEntry) + "\n", "utf8")];
|
|
3219
|
+
case 4:
|
|
3220
|
+
_a.sent();
|
|
3221
|
+
_a.label = 5;
|
|
3222
|
+
case 5: return [3 /*break*/, 7];
|
|
3223
|
+
case 6:
|
|
3224
|
+
error_1 = _a.sent();
|
|
3225
|
+
console.error("Failed to write log:", error_1);
|
|
3226
|
+
return [3 /*break*/, 7];
|
|
3227
|
+
case 7: return [2 /*return*/];
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3230
|
+
});
|
|
3231
|
+
};
|
|
3232
|
+
PromLoggerServer.prototype.info = function (message, data) {
|
|
3233
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3234
|
+
return __generator(this, function (_a) {
|
|
3235
|
+
switch (_a.label) {
|
|
3236
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.INFO, message, data)];
|
|
3237
|
+
case 1:
|
|
3238
|
+
_a.sent();
|
|
3239
|
+
return [2 /*return*/];
|
|
3240
|
+
}
|
|
3241
|
+
});
|
|
3242
|
+
});
|
|
3243
|
+
};
|
|
3244
|
+
PromLoggerServer.prototype.warn = function (message, data) {
|
|
3245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3246
|
+
return __generator(this, function (_a) {
|
|
3247
|
+
switch (_a.label) {
|
|
3248
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.WARN, message, data)];
|
|
3249
|
+
case 1:
|
|
3250
|
+
_a.sent();
|
|
3251
|
+
return [2 /*return*/];
|
|
3252
|
+
}
|
|
3253
|
+
});
|
|
3254
|
+
});
|
|
3255
|
+
};
|
|
3256
|
+
PromLoggerServer.prototype.error = function (message, error, context) {
|
|
3257
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3258
|
+
var errorData;
|
|
3259
|
+
return __generator(this, function (_a) {
|
|
3260
|
+
switch (_a.label) {
|
|
3261
|
+
case 0:
|
|
3262
|
+
errorData = __assign(__assign({}, (error && __assign({ errorMessage: error.message, stack: error.stack }, (error.response && { status: error.response.status })))), (context && { context: context }));
|
|
3263
|
+
return [4 /*yield*/, this.log(PromLogLevel.ERROR, message, errorData)];
|
|
3264
|
+
case 1:
|
|
3265
|
+
_a.sent();
|
|
3266
|
+
return [2 /*return*/];
|
|
3267
|
+
}
|
|
3268
|
+
});
|
|
3269
|
+
});
|
|
3270
|
+
};
|
|
3271
|
+
return PromLoggerServer;
|
|
3272
|
+
}());
|
|
3273
|
+
var PromLoggerClient = /** @class */ (function () {
|
|
3274
|
+
function PromLoggerClient() {
|
|
3275
|
+
}
|
|
3276
|
+
PromLoggerClient.prototype.log = function (level, message, data) {
|
|
3277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3278
|
+
var response, _a, _b, _c, e_1;
|
|
3279
|
+
return __generator(this, function (_d) {
|
|
3280
|
+
switch (_d.label) {
|
|
3281
|
+
case 0:
|
|
3282
|
+
_d.trys.push([0, 4, , 5]);
|
|
3283
|
+
return [4 /*yield*/, fetch("/api/log", {
|
|
3284
|
+
method: "POST",
|
|
3285
|
+
headers: { "Content-Type": "application/json" },
|
|
3286
|
+
body: JSON.stringify({
|
|
3287
|
+
level: level,
|
|
3288
|
+
message: message,
|
|
3289
|
+
data: data,
|
|
3290
|
+
timestamp: new Date().toISOString(),
|
|
3291
|
+
}),
|
|
3292
|
+
})];
|
|
3293
|
+
case 1:
|
|
3294
|
+
response = _d.sent();
|
|
3295
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
3296
|
+
_b = (_a = console).error;
|
|
3297
|
+
_c = ["Failed to send log:"];
|
|
3298
|
+
return [4 /*yield*/, response.text()];
|
|
3299
|
+
case 2:
|
|
3300
|
+
_b.apply(_a, _c.concat([_d.sent()]));
|
|
3301
|
+
_d.label = 3;
|
|
3302
|
+
case 3: return [3 /*break*/, 5];
|
|
3303
|
+
case 4:
|
|
3304
|
+
e_1 = _d.sent();
|
|
3305
|
+
console.error("Failed to send log:", e_1);
|
|
3306
|
+
return [3 /*break*/, 5];
|
|
3307
|
+
case 5: return [2 /*return*/];
|
|
3308
|
+
}
|
|
3309
|
+
});
|
|
3310
|
+
});
|
|
3311
|
+
};
|
|
3312
|
+
PromLoggerClient.prototype.info = function (message, data) {
|
|
3313
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3314
|
+
return __generator(this, function (_a) {
|
|
3315
|
+
switch (_a.label) {
|
|
3316
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.INFO, message, data)];
|
|
3317
|
+
case 1:
|
|
3318
|
+
_a.sent();
|
|
3319
|
+
return [2 /*return*/];
|
|
3320
|
+
}
|
|
3321
|
+
});
|
|
3322
|
+
});
|
|
3323
|
+
};
|
|
3324
|
+
PromLoggerClient.prototype.warn = function (message, data) {
|
|
3325
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3326
|
+
return __generator(this, function (_a) {
|
|
3327
|
+
switch (_a.label) {
|
|
3328
|
+
case 0: return [4 /*yield*/, this.log(PromLogLevel.WARN, message, data)];
|
|
3329
|
+
case 1:
|
|
3330
|
+
_a.sent();
|
|
3331
|
+
return [2 /*return*/];
|
|
3332
|
+
}
|
|
3333
|
+
});
|
|
3334
|
+
});
|
|
3335
|
+
};
|
|
3336
|
+
PromLoggerClient.prototype.error = function (message, error, context) {
|
|
3337
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3338
|
+
var errorData;
|
|
3339
|
+
return __generator(this, function (_a) {
|
|
3340
|
+
switch (_a.label) {
|
|
3341
|
+
case 0:
|
|
3342
|
+
errorData = __assign(__assign({}, (error && __assign({ errorMessage: error.message, stack: error.stack }, (error.response && { status: error.response.status })))), (context && { context: context }));
|
|
3343
|
+
return [4 /*yield*/, this.log(PromLogLevel.ERROR, message, errorData)];
|
|
3344
|
+
case 1:
|
|
3345
|
+
_a.sent();
|
|
3346
|
+
return [2 /*return*/];
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
});
|
|
3350
|
+
};
|
|
3351
|
+
return PromLoggerClient;
|
|
3352
|
+
}());
|
|
3353
|
+
var promLogger = typeof window === "undefined"
|
|
3354
|
+
? new PromLoggerServer()
|
|
3355
|
+
: new PromLoggerClient();
|
|
3356
|
+
|
|
3357
|
+
export { cn, promLogger, usePromPromiseQuery };
|
|
@@ -2,5 +2,6 @@ declare const promMaskTelegram: (val: string) => string;
|
|
|
2
2
|
declare const promMaskWhatsapp: (val: string) => string;
|
|
3
3
|
declare const promMaskPhone: (val: string) => string;
|
|
4
4
|
declare const promMaskPhoneWithoutPlus: (val: string) => string;
|
|
5
|
+
declare const promMaskUrl: (val: string) => string;
|
|
5
6
|
declare const promMaskEmail: (val: string) => string;
|
|
6
|
-
export { promMaskEmail, promMaskPhone, promMaskTelegram, promMaskWhatsapp, promMaskPhoneWithoutPlus, };
|
|
7
|
+
export { promMaskUrl, promMaskEmail, promMaskPhone, promMaskTelegram, promMaskWhatsapp, promMaskPhoneWithoutPlus, };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare enum PromLogLevel {
|
|
2
|
+
INFO = "INFO",
|
|
3
|
+
WARN = "WARN",
|
|
4
|
+
ERROR = "ERROR"
|
|
5
|
+
}
|
|
6
|
+
export interface PromLogger {
|
|
7
|
+
log(level: PromLogLevel, message: string, data?: any): Promise<void>;
|
|
8
|
+
info(message: string, data?: any): Promise<void>;
|
|
9
|
+
warn(message: string, data?: any): Promise<void>;
|
|
10
|
+
error(message: string, error?: any, context?: any): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
declare class PromLoggerServer implements PromLogger {
|
|
13
|
+
log(level: PromLogLevel, message: string, data?: any): Promise<void>;
|
|
14
|
+
info(message: string, data?: any): Promise<void>;
|
|
15
|
+
warn(message: string, data?: any): Promise<void>;
|
|
16
|
+
error(message: string, error?: any, context?: any): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
declare class PromLoggerClient implements PromLogger {
|
|
19
|
+
log(level: PromLogLevel, message: string, data?: any): Promise<void>;
|
|
20
|
+
info(message: string, data?: any): Promise<void>;
|
|
21
|
+
warn(message: string, data?: any): Promise<void>;
|
|
22
|
+
error(message: string, error?: any, context?: any): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare const promLogger: PromLoggerServer | PromLoggerClient;
|
|
25
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prom-pal-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "build/cjs/index.js",
|
|
6
6
|
"module": "build/esm/index.js",
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@hookform/resolvers": "^5.2.2",
|
|
36
|
+
"@radix-ui/react-checkbox": "^1.3.3",
|
|
36
37
|
"@radix-ui/react-label": "^2.1.8",
|
|
37
38
|
"@radix-ui/react-select": "^2.2.6",
|
|
38
39
|
"@radix-ui/react-slot": "^1.2.4",
|
|
39
40
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
40
41
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
41
|
-
"@radix-ui/react-checkbox": "^1.3.3",
|
|
42
42
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
43
43
|
"@tailwindcss/postcss": "^4.1.18",
|
|
44
44
|
"@tailwindcss/vite": "^4.1.18",
|
|
45
|
+
"@types/node": "^25.5.0",
|
|
45
46
|
"@types/react": "^18.3.27",
|
|
46
47
|
"@types/react-dom": "^19.2.3",
|
|
47
48
|
"autoprefixer": "^10.4.23",
|
|
@@ -74,6 +75,8 @@
|
|
|
74
75
|
"zod": "^4.3.4"
|
|
75
76
|
},
|
|
76
77
|
"dependencies": {
|
|
78
|
+
"fs": "0.0.1-security",
|
|
79
|
+
"path": "^0.12.7",
|
|
77
80
|
"postcss-selector-parser": "^7.1.1",
|
|
78
81
|
"react-jss": "^10.10.0"
|
|
79
82
|
}
|