Update dependencies, fix (auto)import problems

This commit is contained in:
Wroclaw 2023-11-06 02:57:00 +01:00
parent 267a83d484
commit 1d893c4a78
40 changed files with 5166 additions and 3047 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { order as orderType } from '~/utils/types/database';
import { type order as orderType } from '~/utils/types/database';
const props = defineProps<{
order?: orderType

8033
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -13,10 +13,10 @@
"devDependencies": {
"@mdi/font": "^7.2.96",
"@nuxtjs/eslint-config-typescript": "^12.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"eslint": "^8.39.0",
"nuxt": "3.4.0",
"nuxt": "3.8.0",
"sass": "^1.62.0",
"vite-plugin-vuetify": "^1.0.2",
"vuetify": "^3.1.15"

View file

@ -1,14 +1,14 @@
<script setup lang="ts">
/* global $fetch */
import { useRoute, useFetch, createError } from "nuxt/app";
import { ref, Ref } from "vue";
import { ref, type Ref } from "vue";
import { VBtn, VForm } from "vuetify/components";
import PagedList from "~/components/pagedList.vue";
import Snowflake from "~/utils/snowflake";
import { client as clientType, order, orderSummary } from "~/utils/types/database";
import OrderView from "~/components/orderView.vue";
import EntryEditor, { fieldDefinition } from "~/components/entryEditor.vue";
import EntryEditor, { type fieldDefinition } from "~/components/entryEditor.vue";
const route = useRoute();
const id = route.params.id;

View file

@ -1,14 +1,15 @@
<script setup lang="ts">
/* global $fetch */
import { useFetch, createError, navigateTo, NuxtError, useRoute } from "nuxt/app";
import { ref, Ref, reactive } from "vue";
import { type NuxtError } from "nuxt/app";
import { ref, type Ref, reactive } from "vue";
import { VBtn } from "vuetify/components";
import { definePageMeta } from "~/.nuxt/imports";
import { client as clientType } from "~/utils/types/database";
import { type client as clientType } from "~/utils/types/database";
import pagedTable from "~/components/pagedTable.vue";
import Alerts, { AlertData } from "~/components/alerts.vue";
import { fieldDefinition } from "~/components/entryEditor.vue";
import Alerts, { type AlertData } from "~/components/alerts.vue";
import { type fieldDefinition } from "~/components/entryEditor.vue";
import { useFetch, createError, navigateTo, useRoute, definePageMeta } from "#imports";
definePageMeta({ middleware: ["auth"] });
const route = useRoute();

View file

@ -1,11 +1,11 @@
<script setup lang="ts">
/* global $fetch */
import { ref } from 'vue';
import { NuxtError, navigateTo, useFetch } from 'nuxt/app';
import { definePageMeta } from '~/.nuxt/imports';
import { type NuxtError } from 'nuxt/app';
import { navigateTo, useFetch, definePageMeta } from '#imports';
import EntryEditor, { fieldDefinition } from '~/components/entryEditor.vue';
import Alerts, { AlertData } from '~/components/alerts.vue';
import EntryEditor, { type fieldDefinition } from '~/components/entryEditor.vue';
import Alerts, { type AlertData } from '~/components/alerts.vue';
const editorFields: Array<fieldDefinition> = [
{ key: "username", type: "text", label: "Username", optional: false },

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { navigateTo } from 'nuxt/app';
import { navigateTo } from '#imports';
navigateTo("/clients");
</script>

View file

@ -2,9 +2,8 @@
/* global $fetch */
import { ref, watch } from "vue";
import { VForm } from "vuetify/components";
import { navigateTo, useCookie, useFetch, useRoute } from "nuxt/app";
import { cookieSettings } from "~/utils/cookieSettings";
import { definePageMeta } from "~/.nuxt/imports";
import { definePageMeta, navigateTo, useCookie, useFetch, useRoute } from "#imports";
const route = useRoute();

View file

@ -1,7 +1,8 @@
/* global defineEventHandler getQuery, createError */
import { defineEventHandler, getQuery } from "h3";
import { createError } from "#imports";
import BaaPagination from "~/server/utils/baaPagination";
import { client } from "~/utils/types/database";
import { type client } from "~/utils/types/database";
export const baaWrapper = new BaaPagination<client, "id">("clients", "id");

View file

@ -1,7 +1,9 @@
/* global defineEventHandler, createError, readBody */
import { defineEventHandler, readBody } from "h3";
import { baaWrapper } from "./clients.get";
import { client } from "~/utils/types/database";
import { type client } from "~/utils/types/database";
import { createError } from "#imports";
const clientKeys: Array<string> = [
"name",

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
import { baaWrapper } from "../clients.get";

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
import { baaWrapper } from "../clients.get";

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
import { checkIsClient } from "../clients.post";
import { baaWrapper } from "../clients.get";

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
import { baaWrapper } from "~/server/api/orders.get";

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
import { baaWrapper } from "../clients.get";

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
import { database } from "~/server/utils/database";

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
export default defineEventHandler((event) => {
const message = event.node.req.read();

View file

@ -1,5 +1,5 @@
/* global defineEventHandler */
import { data, database } from "../utils/database";
import { defineEventHandler } from "h3";
import { type data, database } from "../utils/database";
export async function isFirstRun() {
const [tables] = await database.query({ sql: "SHOW TABLES", rowsAsArray: true }, []) as data<[string]>;

View file

@ -1,12 +1,13 @@
/* global defineEventHandler, setResponseStatus, readBody, createError */
import fs from "node:fs/promises";
import { defineEventHandler, setResponseStatus, readBody } from "h3";
import { database as db } from "../utils/database";
import { isFirstRun } from "./firstRun.get";
import { getPasswordHash } from "./login.post";
import Snowflake from "~/utils/snowflake";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
if (!isFirstRun()) {
setResponseStatus(e, 404);

View file

@ -1,4 +1,4 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
export default defineEventHandler(() => {
return "Hi mom!";

View file

@ -1,11 +1,13 @@
/* global defineEventHandler, getCookie, setCookie, readBody, createError */
import crypto from "crypto";
import { defineEventHandler, getCookie, setCookie, readBody } from "h3";
import { database, data } from "../utils/database";
import { database, type data } from "../utils/database";
import { isString } from "../utils/isString";
import { cookieSettings } from "../utils/rootUtils";
import Snowflake from "~/utils/snowflake";
import { createError } from "#imports";
export function getPasswordHash(password: string) {
return crypto.createHmac("sha512", "42")
.update(password)

View file

@ -1,9 +1,11 @@
/* global defineEventHandler, createError, getCookie, deleteCookie */
import { defineEventHandler, getCookie, deleteCookie } from "h3";
import { isAuthorised } from "../middleware/auth";
import { database } from "../utils/database";
import { cookieSettings } from "../utils/rootUtils";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const token = getCookie(e, "token");
if (token === undefined) {

View file

@ -1,8 +1,8 @@
/* global defineEventHandler */
import { defineEventHandler } from "h3";
import BaaPagination from "../utils/baaPagination";
import { data, database } from "../utils/database";
import { client, orderSummary } from "~/utils/types/database";
import { type data, database } from "../utils/database";
import { type client, type orderSummary } from "~/utils/types/database";
export const baaWrapper = new BaaPagination<orderSummary, "id">(
"orderSummaries",

View file

@ -1,4 +1,4 @@
/* global defineEventHandler, createError, readBody, setResponseStatus */
import { defineEventHandler, readBody, setResponseStatus } from "h3";
import { createValidationError, handleRecursedValidationError } from "../utils/validation";
import { database as db } from "../utils/database";
@ -6,6 +6,8 @@ import getRequestingUser from "../utils/getRequestingUser";
import { getOrder } from "./orders/[id].get";
import Snowflake from "~/utils/snowflake";
import { createError } from "#imports";
type importedProduct = {
name: string | null,
link: string,

View file

@ -1,8 +1,10 @@
/* global defineEventHandler, createError */
import { ResultSetHeader } from "mysql2";
import { defineEventHandler } from "h3";
import { type ResultSetHeader } from "mysql2";
import { database } from "~/server/utils/database";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const id = e.context.params?.id;

View file

@ -1,7 +1,8 @@
/* global defineEventHandler, createError */
import { defineEventHandler } from "h3";
import { createError } from "#imports";
import { offer as offerType, order } from "~/utils/types/database";
import { database, data } from "~/server/utils/database";
import { type offer as offerType, type order } from "~/utils/types/database";
import { database, type data } from "~/server/utils/database";
export async function orderExists(id: string) {
const [[exists]] = await database.query(

View file

@ -1,8 +1,10 @@
/* global defineEventHandler, readBody, createError */
import { defineEventHandler, readBody } from "h3";
import { checkIsOrder } from "../orders.post";
import { database as db } from "~/server/utils/database";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const body = await readBody(e);
const id = e.context.params?.id;

View file

@ -1,7 +1,9 @@
/* global defineEventHandler, createError */
import { defineEventHandler } from "h3";
import { orderExists, getImportedProducts } from "../[id].get";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const id = e.context.params?.id as string;

View file

@ -1,10 +1,12 @@
/* global defineEventHandler, readBody, createError, setResponseStatus */
import { defineEventHandler, readBody, setResponseStatus } from "h3";
import { checkIsImportedProduct } from "../../orders.post";
import { getImportedProducts, orderExists } from "../[id].get";
import Snowflake from "~/utils/snowflake";
import { database } from "~/server/utils/database";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const body = await readBody(e);
const idOrder = e.context.params?.id as string;

View file

@ -1,7 +1,9 @@
/* global defineEventHandler, createError */
import { defineEventHandler } from "h3";
import { orderExists, getWork } from "../[id].get";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const id = e.context.params?.id as string;

View file

@ -1,10 +1,12 @@
/* global defineEventHandler, readBody, createError, setResponseStatus */
import { defineEventHandler, readBody, setResponseStatus } from "h3";
import { checkIsWork } from "../../orders.post";
import { getWork, orderExists } from "../[id].get";
import Snowflake from "~/utils/snowflake";
import { database } from "~/server/utils/database";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const body = await readBody(e);
const idOrder = e.context.params?.id as string;

View file

@ -1,9 +1,11 @@
/* global defineEventHandler, createError */
import { defineEventHandler } from "h3";
import { ResultSetHeader } from "mysql2";
import { type ResultSetHeader } from "mysql2";
import { orderExists } from "../../[id].get";
import { database } from "~/server/utils/database";
import { createError } from "#imports";
export default defineEventHandler(async (e) => {
const idOrder = e.context.params?.id as string;
const idWork = e.context.params?.idWork as string;

View file

@ -1,7 +1,9 @@
/* global defineEventHandler, createError */
import { defineEventHandler } from "h3";
import { orderExists, getWork } from "../../[id].get";
import { createError } from "#imports";
export default defineEventHandler((e) => {
const idOrder = e.context.params?.id as string;
const idWork = e.context.params?.idWork as string;

View file

@ -1,7 +1,8 @@
/* global defineEventHandler, getCookie */
import { defineEventHandler, getCookie } from "h3";
import { database, data } from "~/server/utils/database";
import { user } from "~/utils/types/database";
import { database, type data } from "~/server/utils/database";
import { type user } from "~/utils/types/database";
export default defineEventHandler(async (e) => {
const token = getCookie(e, "token");

View file

@ -1,6 +1,7 @@
/* global defineEventHandler, createError, getCookie */
import { defineEventHandler, getCookie } from "h3";
import { createError } from "#imports";
import { database, data } from "~/server/utils/database";
import { database, type data } from "~/server/utils/database";
const endpointsWithoutAuth: string[] = [
"/dbtest",

View file

@ -1,12 +1,12 @@
/* global defineEventHandler, getQuery, createError, readBody, setResponseStatus */
import { QueryObject } from "ufo";
import { H3Event } from "h3";
import { ResultSetHeader } from "mysql2/promise";
import { defineEventHandler, getQuery, readBody, setResponseStatus, H3Event } from "h3";
import { type ResultSetHeader } from "mysql2/promise";
import { data, database } from "./database";
import { type data, database } from "./database";
import { isString } from "./isString";
import Snowflake from "~/utils/snowflake";
import { client } from "~/utils/types/database";
import { type client } from "~/utils/types/database";
import { createError } from "#imports";
type queryType = {
type: "before" | "after" | "around",
@ -33,7 +33,7 @@ export default class BaaPagination<T extends {[k: string]: any}, keyType extends
* @param query the query to parse
* @throws if query malformed (multiple before/after/around)
*/
static getLocationParameterType(query: QueryObject): queryType {
static getLocationParameterType(query: any): queryType {
const before = query.before;
const after = query.after;
const around = query.around;

View file

@ -1,4 +1,4 @@
import mysql, { Connection } from "mysql2/promise";
import mysql, { type Connection } from "mysql2/promise";
const connectionOptions: mysql.ConnectionOptions = {
host: process.env.DB_HOST,
@ -12,8 +12,8 @@ const connectionOptions: mysql.ConnectionOptions = {
export const database =
await mysql.createConnection(connectionOptions) as Connection & {
new: (localConnectionOptions: mysql.ConnectionOptions | undefined) => Promise<Connection>
new: (localConnectionOptions?: mysql.ConnectionOptions | undefined) => Promise<Connection>
};
database.new = (localConnectionOptions: mysql.ConnectionOptions | undefined) => { return mysql.createConnection({ ...localConnectionOptions, ...connectionOptions }); };
database.new = (localConnectionOptions?: mysql.ConnectionOptions | undefined) => { return mysql.createConnection({ ...localConnectionOptions, ...connectionOptions }); };
export type data<T> = [T[], mysql.FieldPacket[]];

View file

@ -1,8 +1,9 @@
/* global getCookie, createError */
import { H3Event } from "h3";
import { getCookie, H3Event } from "h3";
import { database, data } from "./database";
import { user } from "~/utils/types/database";
import { database, type data } from "./database";
import { type user } from "~/utils/types/database";
import { createError } from "#imports";
export default async function getRequestingUser(e: H3Event) {
const cookie = getCookie(e, "token");

View file

@ -1,4 +1,4 @@
/* global createError */
import { createError } from "#imports";
export function createValidationError(errors: Map<string, string>) {
let message = "Invalid parameters: ";

View file

@ -1,4 +1,4 @@
import { CookieSerializeOptions } from "cookie-es";
import { type CookieSerializeOptions } from "cookie-es";
export const cookieSettings: CookieSerializeOptions = {
sameSite: "lax",