fix: resolve ESLint errors — remove unused imports and dead code
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { pgTable, uuid, varchar, text, timestamp, boolean, uniqueIndex } from 'drizzle-orm/pg-core'
|
import { pgTable, uuid, varchar, text, timestamp, boolean } from 'drizzle-orm/pg-core'
|
||||||
import { users } from './users.js'
|
import { users } from './users.js'
|
||||||
|
|
||||||
export const permissions = pgTable('permission', {
|
export const permissions = pgTable('permission', {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { pgTable, uuid, varchar, timestamp, pgEnum, uniqueIndex, boolean } from 'drizzle-orm/pg-core'
|
import { pgTable, uuid, varchar, timestamp, pgEnum, boolean } from 'drizzle-orm/pg-core'
|
||||||
|
|
||||||
export const userRoleEnum = pgEnum('user_role', [
|
export const userRoleEnum = pgEnum('user_role', [
|
||||||
'admin',
|
'admin',
|
||||||
|
|||||||
@@ -950,17 +950,6 @@ async function seedInventory(sql: any) {
|
|||||||
console.log(' Inventory seed complete.')
|
console.log(' Inventory seed complete.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns dates (YYYY-MM-DD) for every occurrence of `dayOfWeek` (0=Sun)
|
|
||||||
// starting from `startDate`, for `count` weeks.
|
|
||||||
function weeklyDates(startDate: string, dayOfWeek: number, count: number): string[] {
|
|
||||||
const d = new Date(startDate + 'T12:00:00Z')
|
|
||||||
while (d.getUTCDay() !== dayOfWeek) d.setUTCDate(d.getUTCDate() + 1)
|
|
||||||
return Array.from({ length: count }, (_, i) => {
|
|
||||||
const nd = new Date(d)
|
|
||||||
nd.setUTCDate(nd.getUTCDate() + i * 7)
|
|
||||||
return nd.toISOString().split('T')[0]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function seedLessons(sql: any) {
|
async function seedLessons(sql: any) {
|
||||||
console.log('\nSeeding lessons data...')
|
console.log('\nSeeding lessons data...')
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export const authPlugin = fp(async (app) => {
|
|||||||
// Load permissions from DB and expand with inheritance
|
// Load permissions from DB and expand with inheritance
|
||||||
const permSlugs = await RbacService.getUserPermissions(app.db, request.user.id)
|
const permSlugs = await RbacService.getUserPermissions(app.db, request.user.id)
|
||||||
request.permissions = expandPermissions(permSlugs)
|
request.permissions = expandPermissions(permSlugs)
|
||||||
} catch (_err) {
|
} catch {
|
||||||
reply.status(401).send({ error: { message: 'Unauthorized', statusCode: 401 } })
|
reply.status(401).send({ error: { message: 'Unauthorized', statusCode: 401 } })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ export const storageRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
app.delete('/storage/folder-permissions/:id', { preHandler: [app.authenticate, app.requirePermission('files.delete')] }, async (request, reply) => {
|
app.delete('/storage/folder-permissions/:id', { preHandler: [app.authenticate, app.requirePermission('files.delete')] }, async (request, reply) => {
|
||||||
const { id } = request.params as { id: string }
|
const { id } = request.params as { id: string }
|
||||||
// Look up the permission to find which folder it belongs to
|
// Look up the permission to find which folder it belongs to
|
||||||
const existing = await StoragePermissionService.listPermissions(app.db, id)
|
|
||||||
// listPermissions takes folderId, we need to find by perm id — use removePermission which fetches first
|
// listPermissions takes folderId, we need to find by perm id — use removePermission which fetches first
|
||||||
const perm = await StoragePermissionService.getPermissionById(app.db, id)
|
const perm = await StoragePermissionService.getPermissionById(app.db, id)
|
||||||
if (!perm) return reply.status(404).send({ error: { message: 'Permission not found', statusCode: 404 } })
|
if (!perm) return reply.status(404).send({ error: { message: 'Permission not found', statusCode: 404 } })
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify'
|
import type { FastifyPluginAsync, FastifyRequest } from 'fastify'
|
||||||
import { webdavBasicAuth } from '../../plugins/webdav-auth.js'
|
import { webdavBasicAuth } from '../../plugins/webdav-auth.js'
|
||||||
import { WebDavService } from '../../services/webdav.service.js'
|
import { WebDavService } from '../../services/webdav.service.js'
|
||||||
import { StoragePermissionService, StorageFolderService, StorageFileService } from '../../services/storage.service.js'
|
import { StoragePermissionService, StorageFolderService, StorageFileService } from '../../services/storage.service.js'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { eq, and, count, desc, lte, sql, type Column } from 'drizzle-orm'
|
import { eq, and, count, desc, sql, type Column } from 'drizzle-orm'
|
||||||
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js'
|
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js'
|
||||||
import { products, inventoryUnits, priceHistory as priceHistoryTable, productSuppliers, suppliers, stockReceipts } from '../db/schema/inventory.js'
|
import { products, inventoryUnits, priceHistory as priceHistoryTable, productSuppliers, suppliers, stockReceipts } from '../db/schema/inventory.js'
|
||||||
import { ValidationError } from '../lib/errors.js'
|
import { ValidationError } from '../lib/errors.js'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { eq, and, count, ilike, inArray, or, isNull, type Column } from 'drizzle-orm'
|
import { eq, and, count, ilike, inArray, isNull, type Column } from 'drizzle-orm'
|
||||||
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js'
|
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js'
|
||||||
import { storageFolders, storageFolderPermissions, storageFiles } from '../db/schema/storage.js'
|
import { storageFolders, storageFolderPermissions, storageFiles } from '../db/schema/storage.js'
|
||||||
import { userRoles } from '../db/schema/rbac.js'
|
import { userRoles } from '../db/schema/rbac.js'
|
||||||
@@ -229,15 +229,6 @@ export const StoragePermissionService = {
|
|||||||
|
|
||||||
let hasOtherPerms = false
|
let hasOtherPerms = false
|
||||||
if (descendantIds.length > 0) {
|
if (descendantIds.length > 0) {
|
||||||
const [otherPerm] = await db.select({ id: storageFolderPermissions.id }).from(storageFolderPermissions)
|
|
||||||
.where(and(
|
|
||||||
inArray(storageFolderPermissions.folderId, descendantIds),
|
|
||||||
permWhereBase,
|
|
||||||
// Exclude the traverse perm we're considering removing
|
|
||||||
// Look for any non-traverse permission
|
|
||||||
))
|
|
||||||
.limit(2) // We need to check if there's more than just the traverse perm itself
|
|
||||||
|
|
||||||
// Count how many perms exist - if only the traverse perm on this folder, it's orphaned
|
// Count how many perms exist - if only the traverse perm on this folder, it's orphaned
|
||||||
const allPerms = await db.select({ id: storageFolderPermissions.id, accessLevel: storageFolderPermissions.accessLevel, folderId: storageFolderPermissions.folderId })
|
const allPerms = await db.select({ id: storageFolderPermissions.id, accessLevel: storageFolderPermissions.accessLevel, folderId: storageFolderPermissions.folderId })
|
||||||
.from(storageFolderPermissions)
|
.from(storageFolderPermissions)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { sql, asc, desc, ilike, or, type SQL, type Column } from 'drizzle-orm'
|
import { sql, asc, desc, ilike, or, type SQL, type Column } from 'drizzle-orm'
|
||||||
import type { PgSelect } from 'drizzle-orm/pg-core'
|
import type { PgSelect } from 'drizzle-orm/pg-core'
|
||||||
import type { PaginationInput, PaginatedResponse } from '@lunarfront/shared/schemas'
|
import type { PaginatedResponse } from '@lunarfront/shared/schemas'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply pagination (offset + limit) to a Drizzle query.
|
* Apply pagination (offset + limit) to a Drizzle query.
|
||||||
|
|||||||
Reference in New Issue
Block a user