All files / web/src/db/schema scanner-settings.ts

100% Statements 59/59
100% Branches 1/1
100% Functions 1/1
100% Lines 59/59

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 602x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
import { integer, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'
import { users } from './users'
 
/**
 * Scanner settings table - document scanner configuration per user
 *
 * One-to-one with users table. Stores quad detector configuration.
 * Deleted when user is deleted (cascade).
 */
export const scannerSettings = sqliteTable('scanner_settings', {
  /** Primary key and foreign key to users table */
  userId: text('user_id')
    .primaryKey()
    .references(() => users.id, { onDelete: 'cascade' }),
 
  /** Preprocessing strategy */
  preprocessing: text('preprocessing', {
    enum: ['standard', 'enhanced', 'adaptive', 'multi'],
  })
    .notNull()
    .default('multi'),
 
  /** Enable histogram equalization - improves contrast in low light */
  enableHistogramEqualization: integer('enable_histogram_equalization', {
    mode: 'boolean',
  })
    .notNull()
    .default(true),
 
  /** Enable adaptive threshold - better for uneven lighting */
  enableAdaptiveThreshold: integer('enable_adaptive_threshold', {
    mode: 'boolean',
  })
    .notNull()
    .default(true),
 
  /** Enable morphological gradient - enhances document edges */
  enableMorphGradient: integer('enable_morph_gradient', { mode: 'boolean' })
    .notNull()
    .default(true),
 
  /** Canny edge detection low threshold */
  cannyLow: integer('canny_low').notNull().default(50),
 
  /** Canny edge detection high threshold */
  cannyHigh: integer('canny_high').notNull().default(150),
 
  /** Adaptive threshold block size (must be odd) */
  adaptiveBlockSize: integer('adaptive_block_size').notNull().default(11),
 
  /** Adaptive threshold constant C */
  adaptiveC: real('adaptive_c').notNull().default(2),
 
  /** Enable Hough line detection - helps with finger occlusion */
  enableHoughLines: integer('enable_hough_lines', { mode: 'boolean' }).notNull().default(true),
})
 
export type ScannerSettings = typeof scannerSettings.$inferSelect
export type NewScannerSettings = typeof scannerSettings.$inferInsert