chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers (#2150)

* chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers

Remove 33 dead files, ~270 unreferenced exports/types, 13 dead i18n
namespaces and 4 unused dependencies; fold byte-identical helper copies
into one canonical home each (lib/utils chunk/sleep/utcDateStamp,
lib/dates/iso, lib/invariants/uuid, lib/xml/escape, lib/reports/sru/format,
lib/pdf/number-text, lib/browser/panel-request, lib/api/v1/body +
v1ValidationError rolled out to ~55 v1 routes, booking-template schemas).

No behaviour change: v1 bodies and status codes, MCP tool schemas, DB
writes and money math are untouched. Naive ore rounding was deliberately
not swapped for roundOre; see DECISIONS.md 2026-09-02 for the full list
of things left alone on purpose.

tsc, lint, 19588 unit tests and check:guards green; antipattern baseline
ratcheted (naive-ore-round 622 -> 620, hand-rolled-invariant 115 -> 113).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(transactions): import RawTransaction from @/types after the ingest re-export removal

CI's type ratchet (check:types, full tsconfig) caught the one test file
that still imported the type through lib/transactions/ingest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-09-02 11:51:16 +02:00
committed by GitHub
co-authored by Claude Fable 5.1 Jakob Wennberg
parent 18cbc4c30a
commit f266c386f3
359 changed files with 1796 additions and 11199 deletions
-6
View File
@@ -72,12 +72,6 @@ export interface ArticleImportParseResult {
warnings: string[]
}
/** Input for executing the article import. */
export interface ArticleImportExecuteInput {
rows: ParsedArticleRow[]
update_duplicates: boolean
}
/** Result of executing the article import. */
export interface ArticleImportExecuteResult {
success: boolean
@@ -165,15 +165,6 @@ export function parseGenericCSV(
}
}
/**
* Get column headers from a CSV file for the mapping UI
*/
export function getCSVHeaders(content: string, delimiter: string = ','): string[] {
const prepared = prepareContent(content)
const firstLine = prepared.split('\n')[0] || ''
return parseCSVLine(firstLine, delimiter).map((h) => h.trim().replace(/^"|"$/g, ''))
}
/**
* Get a preview of the first few rows of a CSV file
*/
-19
View File
@@ -79,25 +79,6 @@ export interface BankFileFormat {
parse: (content: string) => BankFileParseResult
}
/** Import tracking record stored in DB */
export interface BankFileImport {
id: string
user_id: string
filename: string
file_hash: string
file_format: string
transaction_count: number
imported_count: number
duplicate_count: number
matched_count: number
date_from: string | null
date_to: string | null
status: 'pending' | 'processing' | 'completed' | 'failed'
error_message: string | null
created_at: string
updated_at: string
}
/** Column mapping for generic CSV format */
export interface GenericCSVColumnMapping {
date: number
-6
View File
@@ -61,12 +61,6 @@ export interface CustomerImportParseResult {
warnings: string[]
}
/** Input for executing the customer import. */
export interface CustomerImportExecuteInput {
rows: ParsedCustomerRow[]
update_duplicates: boolean
}
/** Result of executing the customer import. */
export interface CustomerImportExecuteResult {
success: boolean
-10
View File
@@ -52,16 +52,6 @@ export interface OpeningBalanceParseResult {
detected_bank_format: string | null
}
/** Input for executing the opening balance import */
export interface OpeningBalanceExecuteInput {
fiscal_period_id: string
lines: {
account_number: string
debit_amount: number
credit_amount: number
}[]
}
/** Result of executing the opening balance import */
export interface OpeningBalanceExecuteResult {
success: boolean
+9
View File
@@ -66,3 +66,12 @@ export function normalizeEmail(value: string | null): string | null {
if (!value) return null
return value.trim().toLowerCase() || null
}
/**
* Lowercased dedup key for matching a row by name (articles, and any other
* importer that dedupes on a free-text name). Same rule as normalizeEmail.
*/
export function normalizeNameKey(value: string | null): string | null {
if (!value) return null
return value.trim().toLowerCase() || null
}
+1 -1
View File
@@ -541,7 +541,7 @@ export async function ensureFiscalPeriod(
// lib/bookkeeping/validate-period-duration.ts, the same arithmetic and the
// same threshold validatePeriodDuration() applies on every other
// period-creation path (fiscal-periods POST/PATCH, period-service's
// createNextPeriod/createPreviousPeriod, onboarding's computeFiscalPeriod),
// createNextPeriod, onboarding's computeFiscalPeriod),
// so an 18-month förlängt räkenskapsår imports exactly as it does there and
// a 19-month one does not. 18 is the ceiling for an extended or re-laid
// year; ongoing years are 12. BFL sets no minimum, so there is no floor here.
-5
View File
@@ -73,11 +73,6 @@ export interface SupplierImportParseResult {
warnings: string[]
}
/** Input for executing the supplier import. */
export interface SupplierImportExecuteInput {
rows: ParsedSupplierRow[]
update_duplicates: boolean
}
/** Result of executing the supplier import. */
export interface SupplierImportExecuteResult {
-55
View File
@@ -192,14 +192,6 @@ export interface AccountMapping {
requiresVatTreatmentReview?: boolean
}
/**
* Account mapping context for the mapper
*/
export interface MappingContext {
sourceAccounts: SIEAccount[]
existingMappings?: Map<string, AccountMapping>
}
/**
* SIE import record (matches database table)
*/
@@ -243,39 +235,6 @@ export interface SIEAccountMappingRecord {
updated_at: string
}
/**
* Options for executing an import
*/
export interface ImportOptions {
// The parsed SIE data
parsed: ParsedSIEFile
// Account mappings to use
mappings: AccountMapping[]
// Whether to create a new fiscal period
createFiscalPeriod: boolean
// Whether to import opening balances as a journal entry
importOpeningBalances: boolean
// Whether to import transactions (SIE4 only)
importTransactions: boolean
// Voucher series to use for imported entries
voucherSeries?: string
// Voucher series for the opening-balance (Ingående balanser) entry.
// Defaults to a series the file's own vouchers do not use (see
// lib/import/opening-balance-defaults.ts) so the IB voucher never shifts
// the numbering of the file's series (issue #1882).
openingBalanceSeries?: string
// Opt-in: mark imported verifikat as "Inget underlag krävs" so a migration
// doesn't flood "Att hantera: saknade underlag". OFF by default.
markImportedNoDocRequired?: boolean
}
/**
* Structured import details for UI display.
* Provides machine-readable data so the UI can render proper explanations
@@ -495,17 +454,3 @@ export interface MigrationDocumentation {
* Wizard step state
*/
export type ImportWizardStep = 'upload' | 'preview' | 'mapping' | 'review' | 'result'
/**
* Full wizard state
*/
export interface ImportWizardState {
step: ImportWizardStep
file: File | null
parsed: ParsedSIEFile | null
mappings: AccountMapping[]
preview: ImportPreview | null
importResult: ImportResult | null
isLoading: boolean
error: string | null
}