ts convert

This commit is contained in:
Corban-Lee Jones 2025-04-19 12:47:00 +01:00
parent 25db5c73fb
commit b27af9c035
11 changed files with 771 additions and 216 deletions

View File

@ -1,13 +1,14 @@
{
"name": "pyrss-ng",
"version": "0.0.0",
"main": "src/app.js",
"main": "src/app.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"tailwind": "npx @tailwindcss/cli -i ./src/client/public/css/main.css -o ./src/client/public/css/tailwind.css",
"build": "./scripts/build.sh",
"migrate": "./scripts/migrate.sh",
"dev": "nodemon -r tsconfig-paths/register ./src/app.ts",
"build:server": "./scripts/build.sh",
"build:client": "npx tsc --project ./tsconfig.client.json",
"build": "npm run tailwind && npm run build:client && npm run build:server",
"dev": "cross-env TS_NODE_PROJECT=tsconfig.server.json nodemon -r tsconfig-paths/register --exec 'npm run build:client && ts-node' ./src/app.ts",
"start": "node dist/app.js"
},
"repository": {
@ -47,6 +48,7 @@
"@types/ejs": "^3.1.5",
"@types/express": "^5.0.0",
"@types/express-session": "^1.18.1",
"@types/jquery": "^3.5.32",
"@types/node": "^22.10.10",
"@types/passport": "^1.0.17",
"@types/passport-discord": "^0.1.14",

View File

@ -7,12 +7,12 @@ echo "Compiling tailwind css ..."
npx tailwindcss -i ./src/client/public/css/main.css -o ./src/client/public/css/tailwind.css
echo "Compiling typescript ..."
npx tsc --project ./tsconfig.json
npx tsc --project ./tsconfig.server.json
echo "Copying client files"
cp -r src/client dist/client
echo "Building typescript path aliases ..."
npx tsc-alias -p ./tsconfig.json
npx tsc-alias -p ./tsconfig.server.json
echo "Done!"

View File

@ -1,4 +1,4 @@
/*! tailwindcss v4.0.10 | MIT License | https://tailwindcss.com */
/*! tailwindcss v4.0.9 | MIT License | https://tailwindcss.com */
@layer theme, base, components, utilities;
@layer theme {
:root, :host {
@ -71,6 +71,7 @@
--ease-in: cubic-bezier(0.4, 0, 1, 1);
--ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
--animate-spin: spin 1s linear infinite;
--blur-sm: 8px;
--default-transition-duration: 150ms;
--default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
--default-font-family: var(--font-sans);
@ -333,6 +334,24 @@
.col-span-3 {
grid-column: span 3 / span 3;
}
.container {
width: 100%;
@media (width >= 40rem) {
max-width: 40rem;
}
@media (width >= 48rem) {
max-width: 48rem;
}
@media (width >= 64rem) {
max-width: 64rem;
}
@media (width >= 80rem) {
max-width: 80rem;
}
@media (width >= 96rem) {
max-width: 96rem;
}
}
.-m-1\.5 {
margin: calc(var(--spacing) * -1.5);
}
@ -357,9 +376,6 @@
.my-2 {
margin-block: calc(var(--spacing) * 2);
}
.\!ms-auto {
margin-inline-start: auto !important;
}
.ms-0\.5 {
margin-inline-start: calc(var(--spacing) * 0.5);
}
@ -375,12 +391,15 @@
.ms-auto {
margin-inline-start: auto;
}
.\!me-1\.5 {
margin-inline-end: calc(var(--spacing) * 1.5) !important;
.ms-auto\! {
margin-inline-start: auto !important;
}
.-me-0\.5 {
margin-inline-end: calc(var(--spacing) * -0.5);
}
.me-1\.5\! {
margin-inline-end: calc(var(--spacing) * 1.5) !important;
}
.me-2 {
margin-inline-end: calc(var(--spacing) * 2);
}
@ -623,18 +642,15 @@
padding-bottom: 0;
}
}
.\!flex {
display: flex !important;
}
.block {
display: block;
}
.contents {
display: contents;
}
.flex {
display: flex;
}
.flex\! {
display: flex !important;
}
.grid {
display: grid;
}
@ -685,6 +701,10 @@
width: calc(var(--spacing) * 16);
height: calc(var(--spacing) * 16);
}
.size-\[16px\] {
width: 16px;
height: 16px;
}
.size-\[28px\] {
width: 28px;
height: 28px;
@ -701,12 +721,12 @@
width: 1px;
height: 1px;
}
.\!h-2\.5 {
height: calc(var(--spacing) * 2.5) !important;
}
.h-2 {
height: calc(var(--spacing) * 2);
}
.h-2\.5\! {
height: calc(var(--spacing) * 2.5) !important;
}
.h-6 {
height: calc(var(--spacing) * 6);
}
@ -743,7 +763,7 @@
.min-h-\[calc\(100\%-3\.5rem\)\] {
min-height: calc(100% - 3.5rem);
}
.\!w-2\.5 {
.w-2\.5\! {
width: calc(var(--spacing) * 2.5) !important;
}
.w-4 {
@ -898,12 +918,12 @@
.items-center {
align-items: center;
}
.\!justify-between {
justify-content: space-between !important;
}
.justify-between {
justify-content: space-between;
}
.justify-between\! {
justify-content: space-between !important;
}
.justify-center {
justify-content: center;
}
@ -1015,9 +1035,6 @@
.overflow-y-hidden {
overflow-y: hidden;
}
.\!rounded-sm {
border-radius: var(--radius-sm) !important;
}
.rounded-full {
border-radius: calc(infinity * 1px);
}
@ -1036,6 +1053,9 @@
.rounded-xs {
border-radius: var(--radius-xs);
}
.rounded-xs\! {
border-radius: var(--radius-xs) !important;
}
.rounded-t-lg {
border-top-left-radius: var(--radius-lg);
border-top-right-radius: var(--radius-lg);
@ -1064,15 +1084,15 @@
--tw-border-style: solid;
border-style: solid;
}
.\!border-gray-200 {
border-color: var(--color-gray-200) !important;
}
.border-current {
border-color: currentColor;
}
.border-gray-200 {
border-color: var(--color-gray-200);
}
.border-gray-200\! {
border-color: var(--color-gray-200) !important;
}
.border-gray-300 {
border-color: var(--color-gray-300);
}
@ -1082,9 +1102,6 @@
.border-t-transparent {
border-top-color: transparent;
}
.\!bg-white {
background-color: var(--color-white) !important;
}
.bg-blue-600 {
background-color: var(--color-blue-600);
}
@ -1118,6 +1135,9 @@
.bg-white {
background-color: var(--color-white);
}
.bg-white\! {
background-color: var(--color-white) !important;
}
.fill-black {
fill: var(--color-black);
}
@ -1157,12 +1177,12 @@
.px-6 {
padding-inline: calc(var(--spacing) * 6);
}
.\!py-0\.5 {
padding-block: calc(var(--spacing) * 0.5) !important;
}
.py-0 {
padding-block: calc(var(--spacing) * 0);
}
.py-0\.5\! {
padding-block: calc(var(--spacing) * 0.5) !important;
}
.py-1 {
padding-block: calc(var(--spacing) * 1);
}
@ -1235,10 +1255,6 @@
.font-mono {
font-family: var(--font-mono);
}
.\!text-sm {
font-size: var(--text-sm) !important;
line-height: var(--tw-leading, var(--text-sm--line-height)) !important;
}
.text-2xl {
font-size: var(--text-2xl);
line-height: var(--tw-leading, var(--text-2xl--line-height));
@ -1259,6 +1275,10 @@
font-size: var(--text-sm);
line-height: var(--tw-leading, var(--text-sm--line-height));
}
.text-sm\! {
font-size: var(--text-sm) !important;
line-height: var(--tw-leading, var(--text-sm--line-height)) !important;
}
.text-xl {
font-size: var(--text-xl);
line-height: var(--tw-leading, var(--text-xl--line-height));
@ -1270,10 +1290,6 @@
.text-\[6rem\] {
font-size: 6rem;
}
.\!font-medium {
--tw-font-weight: var(--font-weight-medium) !important;
font-weight: var(--font-weight-medium) !important;
}
.font-bold {
--tw-font-weight: var(--font-weight-bold);
font-weight: var(--font-weight-bold);
@ -1282,6 +1298,10 @@
--tw-font-weight: var(--font-weight-medium);
font-weight: var(--font-weight-medium);
}
.font-medium\! {
--tw-font-weight: var(--font-weight-medium);
font-weight: var(--font-weight-medium) !important;
}
.font-semibold {
--tw-font-weight: var(--font-weight-semibold);
font-weight: var(--font-weight-semibold);
@ -1357,17 +1377,24 @@
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
}
.outline-hidden {
--tw-outline-style: none;
outline-style: none;
@media (forced-colors: active) {
outline: 2px solid transparent;
outline-offset: 2px;
}
}
.outline {
outline-style: var(--tw-outline-style);
outline-width: 1px;
}
.blur {
--tw-blur: blur(8px);
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
}
.blur-sm {
--tw-blur: blur(var(--blur-sm));
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
}
.filter {
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
}
@ -1601,13 +1628,6 @@
transition-timing-function: var(--ease-in-out);
}
}
.before\:content-\[\'\(\'\] {
&::before {
content: var(--tw-content);
--tw-content: '(';
content: var(--tw-content);
}
}
.after\:content-\[\'\)\'\] {
&::after {
content: var(--tw-content);
@ -1768,7 +1788,6 @@
}
.focus\:outline-hidden {
&:focus {
--tw-outline-style: none;
outline-style: none;
@media (forced-colors: active) {
outline: 2px solid transparent;
@ -2013,11 +2032,6 @@
border-width: 1px;
}
}
.dark\:\!border-neutral-700 {
&:where(.dark, .dark *) {
border-color: var(--color-neutral-700) !important;
}
}
.dark\:border-neutral-600 {
&:where(.dark, .dark *) {
border-color: var(--color-neutral-600);
@ -2038,11 +2052,6 @@
border-color: var(--color-neutral-800);
}
}
.dark\:\!bg-neutral-800 {
&:where(.dark, .dark *) {
background-color: var(--color-neutral-800) !important;
}
}
.dark\:bg-blue-500 {
&:where(.dark, .dark *) {
background-color: var(--color-blue-500);
@ -2063,6 +2072,11 @@
background-color: var(--color-neutral-800);
}
}
.dark\:bg-neutral-800\! {
&:where(.dark, .dark *) {
background-color: var(--color-neutral-800) !important;
}
}
.dark\:bg-neutral-900 {
&:where(.dark, .dark *) {
background-color: var(--color-neutral-900);
@ -2073,6 +2087,11 @@
background-color: color-mix(in oklab, var(--color-neutral-900) 80%, transparent);
}
}
.dark\:bg-red-500 {
&:where(.dark, .dark *) {
background-color: var(--color-red-500);
}
}
.dark\:bg-red-500\/10 {
&:where(.dark, .dark *) {
background-color: color-mix(in oklab, var(--color-red-500) 10%, transparent);
@ -2352,11 +2371,11 @@
}
.hs-overlay-open\:\!translate-x-0 {
&.open {
--tw-translate-x: calc(var(--spacing) * 0) !important;
--tw-translate-x: calc(var(--spacing) * 0);
translate: var(--tw-translate-x) var(--tw-translate-y) !important;
}
.open & {
--tw-translate-x: calc(var(--spacing) * 0) !important;
--tw-translate-x: calc(var(--spacing) * 0);
translate: var(--tw-translate-x) var(--tw-translate-y) !important;
}
}
@ -2382,6 +2401,14 @@
opacity: 100%;
}
}
.hs-selected\:block {
&.selected {
display: block;
}
.selected & {
display: block;
}
}
.hs-selected\:bg-gray-100 {
&.selected {
background-color: var(--color-gray-100);
@ -2660,7 +2687,6 @@
opacity: 80%;
}
&:focus {
--tw-outline-style: none;
outline-style: none;
@media (forced-colors: active) {
outline: 2px solid transparent;
@ -2723,7 +2749,6 @@
background-color: var(--color-gray-100);
}
&:focus {
--tw-outline-style: none;
outline-style: none;
@media (forced-colors: active) {
outline: 2px solid transparent;
@ -2762,7 +2787,6 @@
color: var(--color-blue-600);
}
&:focus {
--tw-outline-style: none;
outline-style: none;
@media (forced-colors: active) {
outline: 2px solid transparent;
@ -2875,7 +2899,6 @@
--tw-ring-color: var(--color-blue-500);
}
&:focus {
--tw-outline-style: none;
outline-style: none;
@media (forced-colors: active) {
outline: 2px solid transparent;
@ -2904,7 +2927,6 @@
}
&:where(.dark, .dark *) {
&:focus {
--tw-outline-style: none;
outline-style: none;
@media (forced-colors: active) {
outline: 2px solid transparent;
@ -3051,6 +3073,11 @@
inherits: false;
initial-value: 0 0 #0000;
}
@property --tw-outline-style {
syntax: "*";
inherits: false;
initial-value: solid;
}
@property --tw-blur {
syntax: "*";
inherits: false;

View File

@ -1,27 +1,22 @@
window.addEventListener('load', () => {
"use strict";
window.addEventListener("load", () => {
const inputs = document.querySelectorAll('.dt-container thead input');
inputs.forEach((input) => {
input.addEventListener('keydown', function (evt) {
if ((evt.metaKey || evt.ctrlKey) && evt.key === 'a') this.select();
inputs.forEach(input => {
input.addEventListener("keydown", (event) => {
if ((event.metaKey || event.ctrlKey) && event.key === "a") {
event.target.select();
}
});
});
});
const formatTimestamp = timestamp => {
let d;
if (typeof timestamp === "string") {
d = new Date(timestamp.replace(" ", "T"));
}
else {
d = new Date(timestamp);
}
const formatTimestamp = (timestamp) => {
const date = new Date(typeof timestamp === "string"
? timestamp.replace(" ", "T")
: timestamp);
const now = new Date();
// If younger than a year, show time
// otherwise show the year
return now - d < 31536000000
? `${d.getDate()} ${d.toLocaleString("en-GB", { month: "short" })}, ${d.getHours().toString().padStart(2, "0")}:${d.getMinutes().toString().padStart(2, "0")}`
: `${d.getDate()} ${d.toLocaleString("en-GB", { month: "short" })} ${d.getFullYear()}`;
}
const difference = now.getTime() - date.getTime();
const result = `${date.getDate()} ${date.toLocaleString("en-GB", { month: "short" })}`;
return difference < 31536000000
? result + `, ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`
: result + ` ${date.getFullYear()}`;
};

View File

@ -0,0 +1,286 @@
const emptyTableHtml: string = `
<div class="max-w-md w-full min-h-[400px] flex flex-col justify-center mx-auto px-6 py-4">
<div class="flex justify-center items-center size-[46px] bg-gray-100 rounded-lg dark:bg-neutral-800">
<svg class="shrink-0 size-6 text-gray-600 dark:text-neutral-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M4 11a9 9 0 0 1 9 9"></path><path d="M4 4a16 16 0 0 1 16 16"></path><circle cx="5" cy="19" r="1"></circle></svg>
</div>
<h2 class="mt-5 font-semibold text-gray-800 dark:text-white">
No results found
</h2>
<p class="mt-2 text-sm text-gray-600 dark:text-neutral-400">
Create a filter and it will appear here.
</p>
<div class="mt-5 flex flex-col sm:flex-row gap-2">
<button type="button" class="openFilterModal-js py-2 px-3 inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 focus:outline-hidden focus:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none" data-hs-overlay="#filterModal">
<svg class="shrink-0 size-4" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>
Create a filter
</button>
<button type="button" onclick="alert('not implemented');" class="py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-xs hover:bg-gray-50 focus:outline-hidden focus:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700">
Use a Template
</button>
</div>
</div>
`;
var table: any;
const defineTable = () => {
table = new HSDataTable($("#table")[0], {
ajax: {
url: `/guild/${guildId}/filters/api/datatable`,
dataSrc: "data",
data: (d: any) => {
if (d === undefined) { return ;}
d.filters = {};
const is_whitelist = $("input[name='filterType']:checked").val();
d.filters.is_whitelist = is_whitelist;
}
},
serverSide: true,
processing: true,
selecting: true,
pagingOptions: {
pageBtnClasses: "hidden"
},
rowSelectingOptions: {
selectAllSelector: "#selectAllBox"
},
language: {
zeroRecords: emptyTableHtml,
emptyTable: emptyTableHtml,
loading: "Placeholder Loading Message...",
},
rowCallback: (row: any, data: any, index: number) => {
$(row).addClass("bg-white dark:bg-neutral-900");
},
drawCallback: () => {
HSDropdown.autoInit();
},
select: {
style: "multi",
selector: "td:first-child input[type='checkbox']"
},
columnDefs: [
{
// Row select checkbox
targets: 0,
orderable: false,
searchable: false,
render: (data, type, row) => {
return `
<td class="size-px whitespace-nowrap">
<div class="ps-6 py-4">
<label for="rowSelect${row.id}-js" class="flex">
<input type="checkbox" id="rowSelect${row.id}-js" class="form-checkbox shrink-0 border-gray-300 rounded-sm text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-600 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800" data-hs-datatable-row-selecting-individual="">
<span class="sr-only">Checkbox</span>
</label>
</div>
</td>
`;
}
},
{
// Name
targets: 1,
data: "name",
orderable: true,
searchable: true,
render: (data, _type, row) => {
return `
<td class="size-px whitespace-nowrap align-top">
<span class="openFilterModal-js block px-6 py-4 text-blue-500 hover:text-blue-600 focus:text-blue-600 dark:text-blue-400 dark:hover:text-blue-500 dark:focus:text-blue-500 text-nowrap cursor-pointer" data-id="${row.id}">
${data}
</sp>
</td>
`;
}
},
{
// Match
targets: 2,
data: "match",
orderable: true,
searchable: true,
render: data => {
return `
<td class="size-px whitespace-nowrap align-top">
<a href="#" class="block px-6 py-4 text-blue-500 hover:text-blue-600 focus:text-blue-600 dark:text-blue-400 dark:hover:text-blue-500 dark:focus:text-blue-500 text-nowrap">
${data}
</a>
</td>
`;
}
},
{
// Algorithm
target: 3,
data: "algorithm",
orderable: true,
searchable: true,
render: (data, type, row) => {
return `
<td class="size-px whitespace-nowrap align-top">
<a href="#" class="block px-6 py-4 text-blue-500 hover:text-blue-600 focus:text-blue-600 dark:text-blue-400 dark:hover:text-blue-500 dark:focus:text-blue-500 text-nowrap">
${data}
</a>
</td>
`;
}
},
{
// Filters
target: 4,
data: "is_insensitive",
orderable: true,
searchable: true,
render: data => {
wrapper = $("<div>").addClass("px-6 py-4");
badge = $("<span>").addClass("py-1 px-1.5 inline-flex items-center text-xs font-medium rounded-full");
label = $("<span>");
if (data) {
badge.addClass("bg-red-100 text-red-800 dark:bg-red-500/10 dark:bg-red-500");
badge.append(label.text("No"));
} else {
badge.addClass("bg-teal-100 text-teal-800 dark:bg-teal-500/10 dark:text-teal-500");
badge.append(label.text("Yes"));
}
wrapper.append(badge);
return wrapper.get(0);
}
},
{
// Whitelist
target: 5,
data: "is_whitelist",
orderable: true,
searchable: true,
render: data => {
wrapper = $("<div>").addClass("px-6 py-4");
badge = $("<span>").addClass("py-1 px-1.5 inline-flex items-center text-xs font-medium rounded-full");
label = $("<span>");
if (data) {
badge.addClass("bg-teal-100 text-teal-800 dark:bg-teal-500/10 dark:text-teal-500");
badge.append(label.text("Whitelist"));
} else {
badge.addClass("bg-red-100 text-red-800 dark:bg-red-500/10 dark:bg-red-500");
badge.append(label.text("Blacklist"));
}
wrapper.append(badge);
return wrapper.get(0);
}
},
{
// Created At
target: 6,
data: "created_at",
orderable: true,
searchable: true,
render: data => {
return `
<td class="size-px whitespace-nowrap align-top">
<div class="px-6 py-4">
<span class="text-sm text-gray-500 dark:text-neutral-500 text-nowrap">
${formatTimestamp(data)}
</span>
</div>
</td>
`;
}
}
]
})
table.dataTable
.on("select", onTableSelectChange)
.on("deselect", onTableSelectChange)
.on("draw", onTableSelectChange);
}
// Ensure the datatable recognises when all rows are selected, otherwise rows are only visually selected
$("#selectAllBox").on("change", function() {
this.checked ? table.dataTable.rows().select() : table.dataTable.rows().deselect();
});
const onTableSelectChange = () => {
const selectedRowCount = table.dataTable.rows({ selected: true }).count();
$("#deleteRowsBtn").prop("disabled", selectedRowCount === 0);
$(".rows-selected-count-js").text(selectedRowCount);
const $elem = $(".rows-selected-count-js.zero-empty-js");
selectedRowCount === 0 ? $elem.hide() : $elem.show();
}
$(window).ready(() => {
setTimeout(defineTable, 500);
});
$("input[name='filterType']").on("change", () => {
table.dataTable.draw();
});
const openFilterForm = async id => {
$("#filterForm").removeClass("submitted");
const formAlgorithmSelect = HSSelect.getInstance("#formAlgorithm");
formAlgorithmSelect.setValue("");
if (id === -1) {
$("#formName").val("");
$("#formMatch").val("");
$("#formWhitelist").prop("checked", false);
$("#formInsensitive").prop("checked", false);
} else {
const data = await $.ajax({
url: `/guild/${guildId}/filters/api?id=${id}`,
method: "get"
});
$("#formName").val(data.name);
$("#formMatch").val(data.match);
$("#formWhitelist").prop("checked", data.is_whitelist);
$("#formInsensitive").prop("checked", data.is_insensitive);
formAlgorithmSelect.setValue(data.algorithm);
}
HSOverlay.open($("#filterModal").get(0));
}
const closeFilterForm = () => {
$("#filterForm").removeClass("submitted");
HSOverlay.close($("#filterModal").get(0));
}
$(document).on("click", ".openFilterModal-js", event => {
openFilterForm($(event.target).data("id") || -1);
});
const submitForm = async event => {
event.preventDefault();
const form = $(event.target).get(0);
$(form).addClass("submitted");
if (!form.checkValidity()) { return; }
await $.ajax({
url: `/guild/${guildId}/filters/api`,
method: "post",
dataType: "json",
data: $(event.target).serializeArray(),
success: () => {
table.dataTable.draw();
closeFilterForm();
},
error: error => {
alert(JSON.stringify(error, null, 4));
}
});
}
$("#filterForm").on("submit", submitForm);

View File

@ -0,0 +1,36 @@
// Preline: necessary for header events.
window.addEventListener("load", () => {
const inputs = document.querySelectorAll('.dt-container thead input');
inputs.forEach(input => {
(input as HTMLInputElement).addEventListener("keydown", (event: KeyboardEvent) => {
if ((event.metaKey || event.ctrlKey) && event.key === "a") {
(event.target as HTMLInputElement).select();
}
});
});
});
/**
* Formats a given timestamp to one of two formats depending on its age.
* @param timestamp
* @returns 'DD MMM, HH:mm' if younger than 1 year, else 'DD MMM YYYY'
*/
const formatTimestamp = (timestamp: string | number) => {
const date = new Date(
typeof timestamp === "string"
? timestamp.replace(" ", "T")
: timestamp
);
const now = new Date();
const difference = now.getTime() - date.getTime();
// Day and short month (example: 21 Oct)
const result = `${date.getDate()} ${date.toLocaleString("en-GB", { month: "short" })}`
// Difference is less than a year: 'DD MMM, HH:mm'
// Or, difference is more than a year: 'DD MMM YYYY'
return difference < 31536000000
? result + `, ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`
: result + ` ${date.getFullYear()}`;
}

1
src/client/public/types/globals.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare const guildId: string;

83
src/client/public/types/preline.d.ts vendored Normal file
View File

@ -0,0 +1,83 @@
import type INoUiSlider from 'nouislider';
import { ICollectionItem } from 'preline/src/interfaces';
import { IStaticMethods } from 'preline/src/static/interfaces';
import type HSCopyMarkup from 'preline/src/plugins/copy-markup';
import type HSAccordion from 'preline/src/plugins/accordion';
import type HSCarousel from 'preline/src/plugins/carousel';
import type HSCollapse from 'preline/src/plugins/collapse';
import type HSComboBox from 'preline/src/plugins/combobox';
import type HSDataTable from 'preline/src/plugins/datatable';
import type HSDropdown from 'preline/src/plugins/dropdown';
import type HSFileUpload from 'preline/src/plugins/file-upload';
import type HSInputNumber from 'preline/src/plugins/input-number';
import type HSLayoutSplitter from 'preline/src/plugins/layout-splitter';
import type HSOverlay from 'preline/src/plugins/overlay';
import type HSPinInput from 'preline/src/plugins/pin-input';
import type HSRangeSlider from 'preline/src/plugins/range-slider';
import type HSRemoveElement from 'preline/src/plugins/remove-element';
import type HSScrollNav from 'preline/src/plugins/scroll-nav';
import type HSScrollspy from 'preline/src/plugins/scrollspy';
import type HSSelect from 'preline/src/plugins/select';
import type HSStepper from 'preline/src/plugins/stepper';
import type HSStrongPassword from 'preline/src/plugins/strong-password';
import type HSTabs from 'preline/src/plugins/tabs';
import type HSTextareaAutoHeight from 'preline/src/plugins/textarea-auto-height';
import type HSThemeSwitch from 'preline/src/plugins/theme-switch';
import type HSToggleCount from 'preline/src/plugins/toggle-count';
import type HSTogglePassword from 'preline/src/plugins/toggle-password';
import type HSTooltip from 'preline/src/plugins/tooltip';
import type HSTreeView from 'preline/src/plugins/tree-view';
declare global {
var noUiSlider: typeof INoUiSlider;
var FloatingUIDOM: {
computePosition: (
reference: Element,
floating: HTMLElement,
options?: any
) => Promise<{ x: number; y: number; placement: string }>;
autoUpdate: (
reference: Element,
floating: HTMLElement,
update: () => void,
) => () => void;
offset: (offset: number | [number, number]) => any;
flip: () => any;
};
interface Window {
HS_CLIPBOARD_SELECTOR: string;
HSStaticMethods: IStaticMethods;
$hsCopyMarkupCollection: ICollectionItem<HSCopyMarkup>[];
$hsAccordionCollection: ICollectionItem<HSAccordion>[];
$hsCarouselCollection: ICollectionItem<HSCarousel>[];
$hsCollapseCollection: ICollectionItem<HSCollapse>[];
$hsComboBoxCollection: ICollectionItem<HSComboBox>[];
$hsDataTableCollection: ICollectionItem<HSDataTable>[];
$hsDropdownCollection: ICollectionItem<HSDropdown>[];
$hsFileUploadCollection: ICollectionItem<HSFileUpload>[];
$hsInputNumberCollection: { id: number; element: HSInputNumber }[];
$hsLayoutSplitterCollection: ICollectionItem<HSLayoutSplitter>[];
$hsOverlayCollection: ICollectionItem<HSOverlay>[];
$hsPinInputCollection: ICollectionItem<HSPinInput>[];
$hsRemoveElementCollection: ICollectionItem<HSRemoveElement>[];
$hsRangeSliderCollection: ICollectionItem<HSRangeSlider>[];
$hsScrollNavCollection: ICollectionItem<HSScrollNav>[];
$hsScrollspyCollection: ICollectionItem<HSScrollspy>[];
$hsSelectCollection: ICollectionItem<HSSelect>[];
$hsStepperCollection: ICollectionItem<HSStepper>[];
$hsStrongPasswordCollection: ICollectionItem<HSStrongPassword>[];
$hsTabsCollection: ICollectionItem<HSTabs>[];
$hsTextareaAutoHeightCollection: ICollectionItem<HSTextareaAutoHeight>[];
$hsThemeSwitchCollection: ICollectionItem<HSThemeSwitch>[];
$hsToggleCountCollection: ICollectionItem<HSToggleCount>[];
$hsTogglePasswordCollection: ICollectionItem<HSTogglePassword>[];
$hsTooltipCollection: ICollectionItem<HSTooltip>[];
$hsTreeViewCollection: ICollectionItem<HSTreeView>[];
}
}

120
tsconfig.client.json Normal file
View File

@ -0,0 +1,120 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "ES6", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */
"@node_modules/*": ["node_modules/*"]
},
"plugins": [],
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [ /* Specify multiple folders that act like './node_modules/@types'. */
"./node_modules/@types",
"./src/client/public/types/globals.d.ts",
"./src/client/public/types/preline.d.ts"
],
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./src/client/public/js", /* Specify an output folder for all emitted files. */
"removeComments": true, /* Disable emitting comments. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src/client/**/*"]
}

View File

@ -1,124 +1,5 @@
// The purpose of this file is for vscode to correctly identify which tsconfig to use.
// This file serves no other purpose.
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */
"@db/*": ["src/db/*"],
"@server/*": ["src/server/*"],
"@client/*": ["src/client/*"],
"@bot/*": ["src/bot/*"],
"@utils/*": ["src/utils/*"],
"@node_modules/*": ["node_modules/*"],
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths"
}
],
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["./node_modules/@types", "./src/types/"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src/**/*"]
}
"extends": "./tsconfig.server.json"
}

124
tsconfig.server.json Normal file
View File

@ -0,0 +1,124 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */
"@db/*": ["src/db/*"],
"@server/*": ["src/server/*"],
"@client/*": ["src/client/*"],
"@bot/*": ["src/bot/*"],
"@utils/*": ["src/utils/*"],
"@node_modules/*": ["node_modules/*"],
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths"
}
],
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["./node_modules/@types", "./src/types/"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src/**/*"]
}