improve some of the punctuation related issues
This commit is contained in:
parent
1602d74dd5
commit
dd470d8a34
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<h4>{{ $t("Certificate Info") }}</h4>
|
||||
{{ $t("Certificate Chain") }}:
|
||||
{{ $t("Certificate Chain:") }}
|
||||
<div v-if="valid" class="rounded d-inline-flex ms-2 text-white tag-valid">
|
||||
{{ $t("Valid") }}
|
||||
</div>
|
||||
|
||||
@ -40,14 +40,13 @@
|
||||
required
|
||||
/>
|
||||
|
||||
<div class="form-text">
|
||||
{{ $t("Examples") }}:
|
||||
<i18n-t tag="div" keypath="Examples:" class="form-text">
|
||||
<ul>
|
||||
<li>/var/run/docker.sock</li>
|
||||
<li>http://localhost:2375</li>
|
||||
<li>https://localhost:2376 (TLS)</li>
|
||||
<li><code>/var/run/docker.sock</code></li>
|
||||
<li><code>http://localhost:2375</code></li>
|
||||
<li><code>https://localhost:2376 (TLS)</code></li>
|
||||
</ul>
|
||||
</div>
|
||||
</i18n-t>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -31,12 +31,9 @@
|
||||
required
|
||||
/>
|
||||
|
||||
<div class="form-text mt-3">
|
||||
{{ $t("Examples") }}:
|
||||
<ul>
|
||||
<li>ws://chrome.browserless.io/playwright?token=YOUR-API-TOKEN</li>
|
||||
</ul>
|
||||
</div>
|
||||
<i18n-t tag="div" keypath="Example:" class="form-text mt-3">
|
||||
<code>ws://chrome.browserless.io/playwright?token=YOUR-API-TOKEN</code>
|
||||
</i18n-t>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
<div class="mb-3">
|
||||
<label for="octopush-version" class="form-label">{{ $t("Octopush API Version") }}</label>
|
||||
<select id="octopush-version" v-model="$parent.notification.octopushVersion" class="form-select">
|
||||
<option value="2">{{ "octopush" }} ({{ $t("endpoint") }}: api.octopush.com)</option>
|
||||
<option value="1">{{ $t("Legacy Octopush-DM") }} ({{ $t("endpoint") }}: www.octopush-dm.com)</option>
|
||||
<option value="2">{{ $t("octopushEndpoint", {url: "api.octopush.com"}) }}</option>
|
||||
<option value="1">{{ $t("legacyOctopushEndpoint", {url: "www.octopush-dm.com"}) }}</option>
|
||||
</select>
|
||||
<div class="form-text">
|
||||
{{ $t("octopushLegacyHint") }}
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<div class="status">
|
||||
{{ $t("apiKey-" + item.status) }}
|
||||
</div>
|
||||
<div class="date">{{ $t("Created") }}: {{ item.createdDate }}</div>
|
||||
<div class="date">{{ $t("CreatedAt", { date: item.createdDate }) }}</div>
|
||||
<div class="date">
|
||||
{{ $t("Expires") }}:
|
||||
{{ item.expires || $t("Never") }}
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
<div class="logo d-flex flex-column justify-content-center align-items-center">
|
||||
<object class="my-4" width="200" height="200" data="/icon.svg" />
|
||||
<div class="fs-4 fw-bold">Uptime Kuma</div>
|
||||
<div>{{ $t("Version") }}: {{ $root.info.version }}</div>
|
||||
<div class="frontend-version">{{ $t("Frontend Version") }}: {{ $root.frontendVersion }}</div>
|
||||
<div>{{ $t("VersionIs", { version: $root.info.version }) }}</div>
|
||||
<div class="frontend-version">{{ $t("FrontendVersionIs", { version: $root.frontendVersion }) }}</div>
|
||||
|
||||
<div v-if="!$root.isFrontendBackendVersionMatched" class="alert alert-warning mt-4" role="alert">
|
||||
⚠️ {{ $t("Frontend Version do not match backend version!") }}
|
||||
|
||||
@ -4,15 +4,13 @@
|
||||
<!-- Change Password -->
|
||||
<template v-if="!settings.disableAuth">
|
||||
<p>
|
||||
{{ $t("Current User") }}:
|
||||
<strong>{{ $root.username }}</strong>
|
||||
<button
|
||||
v-if="!settings.disableAuth"
|
||||
id="logout-btn"
|
||||
class="btn btn-danger ms-4 me-2 mb-2"
|
||||
@click="$root.logout"
|
||||
>
|
||||
{{ $t("Logout") }}
|
||||
{{ $t("logoutCurrentUser", { username: $root.username }) }}
|
||||
</button>
|
||||
</p>
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
"General": "General",
|
||||
"Game": "Game",
|
||||
"Primary Base URL": "Primary Base URL",
|
||||
"Version": "Version",
|
||||
"VersionIs": "Version: {version}",
|
||||
"Check Update On GitHub": "Check Update On GitHub",
|
||||
"List": "List",
|
||||
"Home": "Home",
|
||||
@ -143,6 +143,7 @@
|
||||
"where you intend to implement third-party authentication": "where you intend to implement third-party authentication",
|
||||
"Please use this option carefully!": "Please use this option carefully!",
|
||||
"Logout": "Log out",
|
||||
"logoutCurrentUser": "Log out {username}",
|
||||
"Leave": "Leave",
|
||||
"I understand, please disable": "I understand, please disable",
|
||||
"Confirm": "Confirm",
|
||||
@ -278,7 +279,6 @@
|
||||
"records": "records",
|
||||
"One record": "One record",
|
||||
"steamApiKeyDescriptionAt": "For monitoring a Steam Game Server you need a Steam Web-API key. You can register your API key at {url}",
|
||||
"Current User": "Current User",
|
||||
"topic": "Topic",
|
||||
"topicExplanation": "MQTT topic to monitor",
|
||||
"mqttWebSocketPath": "MQTT WebSocket Path",
|
||||
@ -318,8 +318,9 @@
|
||||
"dark": "dark",
|
||||
"Post": "Post",
|
||||
"Please input title and content": "Please input title and content",
|
||||
"Created": "Created",
|
||||
"Last Updated": "Last Updated",
|
||||
"CreatedAt": "Created: {date}",
|
||||
"lastUpdatedAt": "Last Updated: {date}",
|
||||
"lastUpdatedAtFromNow": "Last Updated: {date} ({fromNow})",
|
||||
"Switch to Light Theme": "Switch to Light Theme",
|
||||
"Switch to Dark Theme": "Switch to Dark Theme",
|
||||
"Show Tags": "Show Tags",
|
||||
@ -354,7 +355,7 @@
|
||||
"proxyDescription": "Proxies must be assigned to a monitor to function.",
|
||||
"enableProxyDescription": "This proxy will not effect on monitor requests until it is activated. You can control temporarily disable the proxy from all monitors by activation status.",
|
||||
"setAsDefaultProxyDescription": "This proxy will be enabled by default for new monitors. You can still disable the proxy separately for each monitor.",
|
||||
"Certificate Chain": "Certificate Chain",
|
||||
"Certificate Chain:": "Certificate Chain:",
|
||||
"Valid": "Valid",
|
||||
"Invalid": "Invalid",
|
||||
"User": "User",
|
||||
@ -401,7 +402,7 @@
|
||||
"Add a new expiry notification day": "Add a new expiry notification day",
|
||||
"Remove the expiry notification": "Remove the expiry notification day",
|
||||
"Proxy": "Proxy",
|
||||
"Date Created": "Date Created",
|
||||
"dateCreatedAtFromNow": "Date Created: {date} ({fromNow})",
|
||||
"Footer Text": "Footer Text",
|
||||
"RSS Title": "RSS Title",
|
||||
"Leave blank to use status page title": "Leave blank to use status page title",
|
||||
@ -475,13 +476,13 @@
|
||||
"disableCloudflaredNoAuthMsg": "You are in No Auth mode, a password is not required.",
|
||||
"trustProxyDescription": "Trust 'X-Forwarded-*' headers. If you want to get the correct client IP and your Uptime Kuma is behind a proxy such as Nginx or Apache, you should enable this.",
|
||||
"wayToGetLineNotifyToken": "You can get an access token from {0}",
|
||||
"Examples": "Examples",
|
||||
"Examples:": "Examples: {0}",
|
||||
"supportBaleChatID": "Support Direct Chat / Group / Channel's Chat ID",
|
||||
"wayToGetBaleChatID": "You can get your chat ID by sending a message to the bot and going to this URL to view the chat_id:",
|
||||
"wayToGetBaleToken": "You can get a token from {0}.",
|
||||
"Home Assistant URL": "Home Assistant URL",
|
||||
"Long-Lived Access Token": "Long-Lived Access Token",
|
||||
"Long-Lived Access Token can be created by clicking on your profile name (bottom left) and scrolling to the bottom then click Create Token. ": "Long-Lived Access Token can be created by clicking on your profile name (bottom left) and scrolling to the bottom then click Create Token. ",
|
||||
"Long-Lived Access Token can be created by clicking on your profile name (bottom left) and scrolling to the bottom then click Create Token. ": "Long-Lived Access Token can be created by clicking on your profile name (bottom left) and scrolling to the bottom then click Create Token.",
|
||||
"Notification Service": "Notification Service",
|
||||
"default: notify all devices": "default: notify all devices",
|
||||
"A list of Notification Services can be found in Home Assistant under \"Developer Tools > Services\" search for \"notification\" to find your device/phone name.": "A list of Notification Services can be found in Home Assistant under \"Developer Tools > Services\" search for \"notification\" to find your device/phone name.",
|
||||
@ -490,7 +491,7 @@
|
||||
"Event type:": "Event type:",
|
||||
"Event data:": "Event data:",
|
||||
"Then choose an action, for example switch the scene to where an RGB light is red.": "Then choose an action, for example switch the scene to where an RGB light is red.",
|
||||
"Frontend Version": "Frontend Version",
|
||||
"FrontendVersionIs": "Frontend Version: {version}",
|
||||
"Frontend Version do not match backend version!": "Frontend Version do not match backend version!",
|
||||
"backupOutdatedWarning": "Deprecated: Since a lot of features were added and this backup feature is a bit unmaintained, it cannot generate or restore a complete backup.",
|
||||
"backupRecommend": "Please backup the volume or the data folder (./data/) directly instead.",
|
||||
@ -501,7 +502,7 @@
|
||||
"startDateTime": "Start Date/Time",
|
||||
"endDateTime": "End Date/Time",
|
||||
"cronExpression": "Cron Expression",
|
||||
"cronSchedule": "Schedule: ",
|
||||
"cronScheduleDescription": "Schedule: {description}",
|
||||
"Duration (Minutes)": "Duration (Minutes)",
|
||||
"invalidCronExpression": "Invalid Cron Expression: {0}",
|
||||
"recurringInterval": "Interval",
|
||||
@ -678,7 +679,6 @@
|
||||
"backupDescription": "You can backup all monitors and notifications into a JSON file.",
|
||||
"backupDescription2": "Note: history and event data is not included.",
|
||||
"backupDescription3": "Sensitive data such as notification tokens are included in the export file; please store export securely.",
|
||||
"endpoint": "endpoint",
|
||||
"octopushAPIKey": "\"API key\" from HTTP API credentials in control panel",
|
||||
"octopushLogin": "\"Login\" from HTTP API credentials in control panel",
|
||||
"promosmsLogin": "API Login Name",
|
||||
@ -730,7 +730,7 @@
|
||||
"apiCredentials": "API credentials",
|
||||
"octopushLegacyHint": "Do you use the legacy version of Octopush (2011-2020) or the new version?",
|
||||
"Check octopush prices": "Check octopush prices {0}.",
|
||||
"octopushPhoneNumber": "Phone number (intl format, eg : +33612345678) ",
|
||||
"octopushPhoneNumber": "Phone number (intl format, eg : +33612345678)",
|
||||
"octopushSMSSender": "SMS Sender Name : 3-11 alphanumeric characters and space (a-zA-Z0-9)",
|
||||
"LunaSea Device ID": "LunaSea Device ID",
|
||||
"Apprise URL": "Apprise URL",
|
||||
@ -880,7 +880,8 @@
|
||||
"From Name/Number": "From Name/Number",
|
||||
"Leave blank to use a shared sender number.": "Leave blank to use a shared sender number.",
|
||||
"Octopush API Version": "Octopush API Version",
|
||||
"Legacy Octopush-DM": "Legacy Octopush-DM",
|
||||
"octopushEndpoint": "octopush (endpoint: {url})",
|
||||
"legacyOctopushEndpoint": "Legacy Octopush-DM (endpoint: {url})",
|
||||
"ntfy Topic": "ntfy Topic",
|
||||
"Server URL should not contain the nfty topic": "Server URL should not contain the nfty topic",
|
||||
"onebotHttpAddress": "OneBot HTTP Address",
|
||||
|
||||
@ -132,7 +132,7 @@
|
||||
<label for="cron" class="form-label">
|
||||
{{ $t("cronExpression") }}
|
||||
</label>
|
||||
<p>{{ $t("cronSchedule") }}{{ cronDescription }}</p>
|
||||
<p>{{ $t("cronScheduleDescription", { description: cronDescription }) }}</p>
|
||||
<input
|
||||
id="cron"
|
||||
v-model="maintenance.cron"
|
||||
|
||||
@ -342,14 +342,20 @@
|
||||
|
||||
<!-- Incident Date -->
|
||||
<div class="date mt-3">
|
||||
{{ $t("Date Created") }}: {{ $root.datetime(incident.createdDate) }} ({{
|
||||
dateFromNow(incident.createdDate)
|
||||
}})
|
||||
{{
|
||||
$t("dateCreatedAtFromNow", {
|
||||
date: $root.datetime(incident.createdDate),
|
||||
fromNow: dateFromNow(incident.createdDate),
|
||||
})
|
||||
}}
|
||||
<br />
|
||||
<span v-if="incident.lastUpdatedDate">
|
||||
{{ $t("Last Updated") }}: {{ $root.datetime(incident.lastUpdatedDate) }} ({{
|
||||
dateFromNow(incident.lastUpdatedDate)
|
||||
}})
|
||||
{{
|
||||
$t("lastUpdatedAtFromNow", {
|
||||
date: $root.datetime(incident.lastUpdatedDate),
|
||||
fromNow: dateFromNow(incident.lastUpdatedDate),
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -572,7 +578,7 @@
|
||||
</p>
|
||||
|
||||
<div class="refresh-info mb-2">
|
||||
<div>{{ $t("Last Updated") }}: {{ lastUpdateTimeDisplay }}</div>
|
||||
<div>{{ $t("lastUpdatedAt", { date: lastUpdateTimeDisplay }) }}</div>
|
||||
<div data-testid="update-countdown-text">
|
||||
{{ $tc("statusPageRefreshIn", [updateCountdownText]) }}
|
||||
</div>
|
||||
|
||||
156
src/util.js
156
src/util.js
@ -10,12 +10,99 @@
|
||||
*/
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CONSOLE_STYLE_FgViolet = exports.CONSOLE_STYLE_FgLightBlue = exports.CONSOLE_STYLE_FgLightGreen = exports.CONSOLE_STYLE_FgOrange = exports.CONSOLE_STYLE_FgGray = exports.CONSOLE_STYLE_FgWhite = exports.CONSOLE_STYLE_FgCyan = exports.CONSOLE_STYLE_FgMagenta = exports.CONSOLE_STYLE_FgBlue = exports.CONSOLE_STYLE_FgYellow = exports.CONSOLE_STYLE_FgGreen = exports.CONSOLE_STYLE_FgRed = exports.CONSOLE_STYLE_FgBlack = exports.CONSOLE_STYLE_Hidden = exports.CONSOLE_STYLE_Reverse = exports.CONSOLE_STYLE_Blink = exports.CONSOLE_STYLE_Underscore = exports.CONSOLE_STYLE_Dim = exports.CONSOLE_STYLE_Bright = exports.CONSOLE_STYLE_Reset = exports.RESPONSE_BODY_LENGTH_MAX = exports.RESPONSE_BODY_LENGTH_DEFAULT = exports.PING_PER_REQUEST_TIMEOUT_DEFAULT = exports.PING_PER_REQUEST_TIMEOUT_MAX = exports.PING_PER_REQUEST_TIMEOUT_MIN = exports.PING_COUNT_DEFAULT = exports.PING_COUNT_MAX = exports.PING_COUNT_MIN = exports.PING_GLOBAL_TIMEOUT_DEFAULT = exports.PING_GLOBAL_TIMEOUT_MAX = exports.PING_GLOBAL_TIMEOUT_MIN = exports.PING_PACKET_SIZE_DEFAULT = exports.PING_PACKET_SIZE_MAX = exports.PING_PACKET_SIZE_MIN = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isNode = exports.isDev = void 0;
|
||||
exports.TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD = exports.evaluateJsonQuery = exports.intHash = exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.badgeConstants = exports.CONSOLE_STYLE_BgGray = exports.CONSOLE_STYLE_BgWhite = exports.CONSOLE_STYLE_BgCyan = exports.CONSOLE_STYLE_BgMagenta = exports.CONSOLE_STYLE_BgBlue = exports.CONSOLE_STYLE_BgYellow = exports.CONSOLE_STYLE_BgGreen = exports.CONSOLE_STYLE_BgRed = exports.CONSOLE_STYLE_BgBlack = exports.CONSOLE_STYLE_FgPink = exports.CONSOLE_STYLE_FgBrown = void 0;
|
||||
exports.CONSOLE_STYLE_FgViolet =
|
||||
exports.CONSOLE_STYLE_FgLightBlue =
|
||||
exports.CONSOLE_STYLE_FgLightGreen =
|
||||
exports.CONSOLE_STYLE_FgOrange =
|
||||
exports.CONSOLE_STYLE_FgGray =
|
||||
exports.CONSOLE_STYLE_FgWhite =
|
||||
exports.CONSOLE_STYLE_FgCyan =
|
||||
exports.CONSOLE_STYLE_FgMagenta =
|
||||
exports.CONSOLE_STYLE_FgBlue =
|
||||
exports.CONSOLE_STYLE_FgYellow =
|
||||
exports.CONSOLE_STYLE_FgGreen =
|
||||
exports.CONSOLE_STYLE_FgRed =
|
||||
exports.CONSOLE_STYLE_FgBlack =
|
||||
exports.CONSOLE_STYLE_Hidden =
|
||||
exports.CONSOLE_STYLE_Reverse =
|
||||
exports.CONSOLE_STYLE_Blink =
|
||||
exports.CONSOLE_STYLE_Underscore =
|
||||
exports.CONSOLE_STYLE_Dim =
|
||||
exports.CONSOLE_STYLE_Bright =
|
||||
exports.CONSOLE_STYLE_Reset =
|
||||
exports.RESPONSE_BODY_LENGTH_MAX =
|
||||
exports.RESPONSE_BODY_LENGTH_DEFAULT =
|
||||
exports.PING_PER_REQUEST_TIMEOUT_DEFAULT =
|
||||
exports.PING_PER_REQUEST_TIMEOUT_MAX =
|
||||
exports.PING_PER_REQUEST_TIMEOUT_MIN =
|
||||
exports.PING_COUNT_DEFAULT =
|
||||
exports.PING_COUNT_MAX =
|
||||
exports.PING_COUNT_MIN =
|
||||
exports.PING_GLOBAL_TIMEOUT_DEFAULT =
|
||||
exports.PING_GLOBAL_TIMEOUT_MAX =
|
||||
exports.PING_GLOBAL_TIMEOUT_MIN =
|
||||
exports.PING_PACKET_SIZE_DEFAULT =
|
||||
exports.PING_PACKET_SIZE_MAX =
|
||||
exports.PING_PACKET_SIZE_MIN =
|
||||
exports.MIN_INTERVAL_SECOND =
|
||||
exports.MAX_INTERVAL_SECOND =
|
||||
exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND =
|
||||
exports.SQL_DATETIME_FORMAT =
|
||||
exports.SQL_DATE_FORMAT =
|
||||
exports.STATUS_PAGE_MAINTENANCE =
|
||||
exports.STATUS_PAGE_PARTIAL_DOWN =
|
||||
exports.STATUS_PAGE_ALL_UP =
|
||||
exports.STATUS_PAGE_ALL_DOWN =
|
||||
exports.MAINTENANCE =
|
||||
exports.PENDING =
|
||||
exports.UP =
|
||||
exports.DOWN =
|
||||
exports.appName =
|
||||
exports.isNode =
|
||||
exports.isDev =
|
||||
void 0;
|
||||
exports.TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD =
|
||||
exports.evaluateJsonQuery =
|
||||
exports.intHash =
|
||||
exports.localToUTC =
|
||||
exports.utcToLocal =
|
||||
exports.utcToISODateTime =
|
||||
exports.isoToUTCDateTime =
|
||||
exports.parseTimeFromTimeObject =
|
||||
exports.parseTimeObject =
|
||||
exports.getMonitorRelativeURL =
|
||||
exports.genSecret =
|
||||
exports.getCryptoRandomInt =
|
||||
exports.getRandomInt =
|
||||
exports.getRandomArbitrary =
|
||||
exports.TimeLogger =
|
||||
exports.polyfill =
|
||||
exports.log =
|
||||
exports.debug =
|
||||
exports.ucfirst =
|
||||
exports.sleep =
|
||||
exports.flipStatus =
|
||||
exports.badgeConstants =
|
||||
exports.CONSOLE_STYLE_BgGray =
|
||||
exports.CONSOLE_STYLE_BgWhite =
|
||||
exports.CONSOLE_STYLE_BgCyan =
|
||||
exports.CONSOLE_STYLE_BgMagenta =
|
||||
exports.CONSOLE_STYLE_BgBlue =
|
||||
exports.CONSOLE_STYLE_BgYellow =
|
||||
exports.CONSOLE_STYLE_BgGreen =
|
||||
exports.CONSOLE_STYLE_BgRed =
|
||||
exports.CONSOLE_STYLE_BgBlack =
|
||||
exports.CONSOLE_STYLE_FgPink =
|
||||
exports.CONSOLE_STYLE_FgBrown =
|
||||
void 0;
|
||||
const dayjs_1 = require("dayjs");
|
||||
const jsonata = require("jsonata");
|
||||
exports.isDev = process.env.NODE_ENV === "development";
|
||||
exports.isNode = typeof process !== "undefined" && ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node);
|
||||
exports.isNode =
|
||||
typeof process !== "undefined" &&
|
||||
((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0
|
||||
? void 0
|
||||
: _a.node);
|
||||
const dayjs = exports.isNode ? require("dayjs") : dayjs_1.default;
|
||||
exports.appName = "Uptime Kuma";
|
||||
exports.DOWN = 0;
|
||||
@ -170,8 +257,7 @@ class Logger {
|
||||
let now;
|
||||
if (dayjs.tz) {
|
||||
now = dayjs.tz(new Date()).format();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
now = dayjs().format();
|
||||
}
|
||||
const levelColor = consoleLevelColors[level];
|
||||
@ -190,8 +276,7 @@ class Logger {
|
||||
}
|
||||
modulePart = "[" + moduleColor + module + exports.CONSOLE_STYLE_Reset + "]";
|
||||
levelPart = levelColor + `${level}:` + exports.CONSOLE_STYLE_Reset;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
timePart = now;
|
||||
modulePart = `[${module}]`;
|
||||
levelPart = `${level}:`;
|
||||
@ -265,21 +350,21 @@ function getRandomInt(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
exports.getRandomInt = getRandomInt;
|
||||
const getRandomBytes = (typeof window !== "undefined" && window.crypto
|
||||
?
|
||||
function () {
|
||||
return (numBytes) => {
|
||||
const randomBytes = new Uint8Array(numBytes);
|
||||
for (let i = 0; i < numBytes; i += 65536) {
|
||||
window.crypto.getRandomValues(randomBytes.subarray(i, i + Math.min(numBytes - i, 65536)));
|
||||
}
|
||||
return randomBytes;
|
||||
};
|
||||
}
|
||||
:
|
||||
function () {
|
||||
return require("crypto").randomBytes;
|
||||
})();
|
||||
const getRandomBytes = (
|
||||
typeof window !== "undefined" && window.crypto
|
||||
? function () {
|
||||
return (numBytes) => {
|
||||
const randomBytes = new Uint8Array(numBytes);
|
||||
for (let i = 0; i < numBytes; i += 65536) {
|
||||
window.crypto.getRandomValues(randomBytes.subarray(i, i + Math.min(numBytes - i, 65536)));
|
||||
}
|
||||
return randomBytes;
|
||||
};
|
||||
}
|
||||
: function () {
|
||||
return require("crypto").randomBytes;
|
||||
}
|
||||
)();
|
||||
function getCryptoRandomInt(min, max) {
|
||||
const range = max - min;
|
||||
if (range >= Math.pow(2, 32)) {
|
||||
@ -305,8 +390,7 @@ function getCryptoRandomInt(min, max) {
|
||||
randomValue = randomValue & mask;
|
||||
if (randomValue <= range) {
|
||||
return min + randomValue;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return getCryptoRandomInt(min, max);
|
||||
}
|
||||
}
|
||||
@ -387,8 +471,7 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue
|
||||
let response;
|
||||
try {
|
||||
response = JSON.parse(data);
|
||||
}
|
||||
catch (_a) {
|
||||
} catch (_a) {
|
||||
response =
|
||||
(typeof data === "object" || typeof data === "number") && !Buffer.isBuffer(data) ? data : data.toString();
|
||||
}
|
||||
@ -400,13 +483,17 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue
|
||||
if (Array.isArray(response)) {
|
||||
const responseStr = JSON.stringify(response);
|
||||
const truncatedResponse = responseStr.length > 25 ? responseStr.substring(0, 25) + "...]" : responseStr;
|
||||
throw new Error("JSON query returned the array " +
|
||||
truncatedResponse +
|
||||
", but a primitive value is required. " +
|
||||
"Modify your query to return a single value via [0] to get the first element or use an aggregation like $count(), $sum() or $boolean().");
|
||||
throw new Error(
|
||||
"JSON query returned the array " +
|
||||
truncatedResponse +
|
||||
", but a primitive value is required. " +
|
||||
"Modify your query to return a single value via [0] to get the first element or use an aggregation like $count(), $sum() or $boolean()."
|
||||
);
|
||||
}
|
||||
if (typeof response === "object" || response instanceof Date || typeof response === "function") {
|
||||
throw new Error(`The post-JSON query evaluated response from the server is of type ${typeof response}, which cannot be directly compared to the expected value`);
|
||||
throw new Error(
|
||||
`The post-JSON query evaluated response from the server is of type ${typeof response}, which cannot be directly compared to the expected value`
|
||||
);
|
||||
}
|
||||
let jsonQueryExpression;
|
||||
switch (jsonPathOperator) {
|
||||
@ -434,14 +521,15 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue
|
||||
expected: expectedValue.toString(),
|
||||
});
|
||||
if (status === undefined) {
|
||||
throw new Error("Query evaluation returned undefined. Check query syntax and the structure of the response data");
|
||||
throw new Error(
|
||||
"Query evaluation returned undefined. Check query syntax and the structure of the response data"
|
||||
);
|
||||
}
|
||||
return {
|
||||
status,
|
||||
response,
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
response = JSON.stringify(response);
|
||||
response = response && response.length > 50 ? `${response.substring(0, 100)}… (truncated)` : response;
|
||||
throw new Error(`Error evaluating JSON query: ${err.message}. Response from server was: ${response}`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user