Browse Source

fix type errors

pull/2037/head
Bernd Storath 1 week ago
parent
commit
a393d5a438
  1. 4
      src/eslint.config.mjs
  2. 3
      src/nuxt.config.ts
  3. 22
      src/package.json
  4. 2342
      src/pnpm-lock.yaml
  5. 4
      src/server/database/repositories/client/schema.ts
  6. 6
      src/server/database/repositories/client/types.ts
  7. 5
      src/server/database/repositories/user/schema.ts
  8. 2
      src/server/database/repositories/user/service.ts
  9. 8
      src/server/database/repositories/user/types.ts
  10. 2
      src/server/utils/handler.ts
  11. 2
      src/server/utils/session.ts
  12. 4
      src/server/utils/types.ts
  13. 2
      src/server/utils/wgHelper.ts
  14. 4
      src/shared/utils/permissions.ts

4
src/eslint.config.mjs

@ -4,9 +4,7 @@ import withNuxt from './.nuxt/eslint.config.mjs';
export default withNuxt([ export default withNuxt([
{ {
rules: { rules: {
// https://github.com/nuxt/eslint/issues/590 'import/order': 'warn',
// 'import/order': 'warn',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
}, },
}, },
eslintConfigPrettier, eslintConfigPrettier,

3
src/nuxt.config.ts

@ -73,9 +73,6 @@ export default defineNuxtConfig({
detectBrowserLanguage: { detectBrowserLanguage: {
useCookie: true, useCookie: true,
}, },
bundle: {
optimizeTranslationDirective: false,
},
}, },
nitro: { nitro: {
esbuild: { esbuild: {

22
src/package.json

@ -20,15 +20,15 @@
"cli:dev": "tsx cli/index.ts" "cli:dev": "tsx cli/index.ts"
}, },
"dependencies": { "dependencies": {
"@eschricht/nuxt-color-mode": "^1.1.5", "@eschricht/nuxt-color-mode": "^1.2.0",
"@heroicons/vue": "^2.2.0", "@heroicons/vue": "^2.2.0",
"@libsql/client": "^0.15.10", "@libsql/client": "^0.15.10",
"@nuxtjs/i18n": "^9.5.6", "@nuxtjs/i18n": "^10.0.3",
"@nuxtjs/tailwindcss": "^6.14.0", "@nuxtjs/tailwindcss": "^6.14.0",
"@phc/format": "^1.0.0", "@phc/format": "^1.0.0",
"@pinia/nuxt": "^0.11.1", "@pinia/nuxt": "^0.11.2",
"@tailwindcss/forms": "^0.5.10", "@tailwindcss/forms": "^0.5.10",
"apexcharts": "^5.2.0", "apexcharts": "^5.3.1",
"argon2": "^0.43.1", "argon2": "^0.43.1",
"cidr-tools": "^11.0.3", "cidr-tools": "^11.0.3",
"citty": "^0.1.6", "citty": "^0.1.6",
@ -40,7 +40,7 @@
"is-cidr": "^5.1.1", "is-cidr": "^5.1.1",
"is-ip": "^5.0.1", "is-ip": "^5.0.1",
"js-sha256": "^0.11.1", "js-sha256": "^0.11.1",
"nuxt": "^4.0.0", "nuxt": "^4.0.1",
"otpauth": "^9.4.0", "otpauth": "^9.4.0",
"pinia": "^3.0.3", "pinia": "^3.0.3",
"qr": "^0.5.0", "qr": "^0.5.0",
@ -48,25 +48,25 @@
"semver": "^7.7.2", "semver": "^7.7.2",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"timeago.js": "^4.0.2", "timeago.js": "^4.0.2",
"vue": "^3.5.17", "vue": "^3.5.18",
"vue-router": "^4.5.1", "vue-router": "^4.5.1",
"vue3-apexcharts": "^1.8.0", "vue3-apexcharts": "^1.8.0",
"zod": "^4.0.5" "zod": "^4.0.10"
}, },
"devDependencies": { "devDependencies": {
"@nuxt/eslint": "1.5.2", "@nuxt/eslint": "^1.7.1",
"@types/debug": "^4.1.12", "@types/debug": "^4.1.12",
"@types/phc__format": "^1.0.1", "@types/phc__format": "^1.0.1",
"@types/semver": "^7.7.0", "@types/semver": "^7.7.0",
"drizzle-kit": "^0.31.4", "drizzle-kit": "^0.31.4",
"esbuild": "^0.25.6", "esbuild": "^0.25.8",
"eslint": "^9.31.0", "eslint": "^9.31.0",
"eslint-config-prettier": "^10.1.5", "eslint-config-prettier": "^10.1.8",
"prettier": "^3.6.2", "prettier": "^3.6.2",
"prettier-plugin-tailwindcss": "^0.6.14", "prettier-plugin-tailwindcss": "^0.6.14",
"tsx": "^4.20.3", "tsx": "^4.20.3",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vue-tsc": "^3.0.1" "vue-tsc": "^3.0.4"
}, },
"packageManager": "pnpm@10.13.1" "packageManager": "pnpm@10.13.1"
} }

2342
src/pnpm-lock.yaml

File diff suppressed because it is too large

4
src/server/database/repositories/client/schema.ts

@ -1,4 +1,4 @@
import { sql, relations } from 'drizzle-orm'; import { sql, relations, type InferSelectModel } from 'drizzle-orm';
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'; import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { oneTimeLink, user, wgInterface } from '../../schema'; import { oneTimeLink, user, wgInterface } from '../../schema';
@ -62,3 +62,5 @@ export const clientsRelations = relations(client, ({ one }) => ({
references: [wgInterface.name], references: [wgInterface.name],
}), }),
})); }));
export type ClientType = InferSelectModel<typeof client>;

6
src/server/database/repositories/client/types.ts

@ -1,9 +1,5 @@
import type { InferSelectModel } from 'drizzle-orm';
import z from 'zod'; import z from 'zod';
import type { ClientType } from './schema';
import type { client } from './schema';
export type ClientType = InferSelectModel<typeof client>;
export type ClientNextIpType = Pick<ClientType, 'ipv4Address' | 'ipv6Address'>; export type ClientNextIpType = Pick<ClientType, 'ipv4Address' | 'ipv6Address'>;

5
src/server/database/repositories/user/schema.ts

@ -1,7 +1,8 @@
import { sql, relations } from 'drizzle-orm'; import { sql, relations, type InferSelectModel } from 'drizzle-orm';
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'; import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { client } from '../../schema'; import { client } from '../../schema';
import type { Role } from '#shared/utils/permissions';
export const user = sqliteTable('users_table', { export const user = sqliteTable('users_table', {
id: int().primaryKey({ autoIncrement: true }), id: int().primaryKey({ autoIncrement: true }),
@ -25,3 +26,5 @@ export const user = sqliteTable('users_table', {
export const usersRelations = relations(user, ({ many }) => ({ export const usersRelations = relations(user, ({ many }) => ({
clients: many(client), clients: many(client),
})); }));
export type UserType = InferSelectModel<typeof user>;

2
src/server/database/repositories/user/service.ts

@ -1,7 +1,7 @@
import { eq, sql } from 'drizzle-orm'; import { eq, sql } from 'drizzle-orm';
import { TOTP } from 'otpauth'; import { TOTP } from 'otpauth';
import { user } from './schema'; import { user } from './schema';
import type { UserType } from './types'; import type { UserType } from './schema';
import type { DBType } from '#db/sqlite'; import type { DBType } from '#db/sqlite';
type LoginResult = type LoginResult =

8
src/server/database/repositories/user/types.ts

@ -1,8 +1,4 @@
import type { InferSelectModel } from 'drizzle-orm';
import z from 'zod'; import z from 'zod';
import type { user } from './schema';
export type UserType = InferSelectModel<typeof user>;
const username = z const username = z
.string({ message: t('zod.user.username') }) .string({ message: t('zod.user.username') })
@ -44,9 +40,7 @@ const name = z
.pipe(safeStringRefine); .pipe(safeStringRefine);
const email = z const email = z
.string({ message: t('zod.user.email') }) .email({ message: t('zod.user.email') })
.min(5, t('zod.user.email'))
.email({ message: t('zod.user.emailInvalid') })
.pipe(safeStringRefine) .pipe(safeStringRefine)
.nullable(); .nullable();

2
src/server/utils/handler.ts

@ -1,5 +1,5 @@
import type { EventHandlerRequest, EventHandlerResponse, H3Event } from 'h3'; import type { EventHandlerRequest, EventHandlerResponse, H3Event } from 'h3';
import type { UserType } from '#db/repositories/user/types'; import type { UserType } from '#db/repositories/user/schema';
import type { SetupStepType } from '#db/repositories/general/types'; import type { SetupStepType } from '#db/repositories/general/types';
import { import {
type Permissions, type Permissions,

2
src/server/utils/session.ts

@ -1,5 +1,5 @@
import type { H3Event } from 'h3'; import type { H3Event } from 'h3';
import type { UserType } from '#db/repositories/user/types'; import type { UserType } from '#db/repositories/user/schema';
export type WGSession = Partial<{ export type WGSession = Partial<{
userId: ID; userId: ID;

4
src/server/utils/types.ts

@ -1,4 +1,4 @@
import type { ZodSchema } from 'zod'; import type { ZodType } from 'zod';
import z from 'zod'; import z from 'zod';
import type { H3Event, EventHandlerRequest } from 'h3'; import type { H3Event, EventHandlerRequest } from 'h3';
@ -64,7 +64,7 @@ export const schemaForType =
}; };
export function validateZod<T>( export function validateZod<T>(
schema: ZodSchema<T>, schema: ZodType<T>,
event: H3Event<EventHandlerRequest> event: H3Event<EventHandlerRequest>
) { ) {
return async (data: unknown) => { return async (data: unknown) => {

2
src/server/utils/wgHelper.ts

@ -1,6 +1,6 @@
import { parseCidr } from 'cidr-tools'; import { parseCidr } from 'cidr-tools';
import { stringifyIp } from 'ip-bigint'; import { stringifyIp } from 'ip-bigint';
import type { ClientType } from '#db/repositories/client/types'; import type { ClientType } from '#db/repositories/client/schema';
import type { InterfaceType } from '#db/repositories/interface/types'; import type { InterfaceType } from '#db/repositories/interface/types';
import type { UserConfigType } from '#db/repositories/userConfig/types'; import type { UserConfigType } from '#db/repositories/userConfig/types';
import type { HooksType } from '#db/repositories/hooks/types'; import type { HooksType } from '#db/repositories/hooks/types';

4
src/shared/utils/permissions.ts

@ -1,5 +1,5 @@
import type { ClientType } from '#db/repositories/client/types'; import type { ClientType } from '#db/repositories/client/schema';
import type { UserType } from '#db/repositories/user/types'; import type { UserType } from '#db/repositories/user/schema';
type BrandedRole = { type BrandedRole = {
readonly __role: unique symbol; readonly __role: unique symbol;

Loading…
Cancel
Save