feat: make extension system packageable via enriched ExtensionContext
Enrich ExtensionContext with supabase, emit(), settings, storage, log, and services so extensions can receive everything through dependency injection instead of importing core modules directly. - Add context factory and inject context into event handlers via registry - Move supplier invoice journal entry creation to core event handler - Add services.ingestTransactions to ExtensionContext for enable-banking - Create catch-all API route for extension-declared apiRoutes - Migrate 5 extensions to accept context with dynamic import fallbacks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
59d935f2cc
commit
ef5a84a5d5
@@ -4,34 +4,10 @@ import { createTransactionJournalEntry } from '@/lib/bookkeeping/transaction-ent
|
||||
import { getBestInvoiceMatch } from '@/lib/invoices/invoice-matching'
|
||||
import { tryReconcileTransaction, fetchUnlinkedGLLines } from '@/lib/reconciliation/bank-reconciliation'
|
||||
import type { UnlinkedGLLine } from '@/lib/reconciliation/bank-reconciliation'
|
||||
import type { Transaction } from '@/types'
|
||||
import type { Transaction, RawTransaction, IngestResult } from '@/types'
|
||||
|
||||
/**
|
||||
* Normalized transaction input for the generic ingestion pipeline.
|
||||
* Both file import and PSD2 sync convert to this format before ingesting.
|
||||
*/
|
||||
export interface RawTransaction {
|
||||
date: string
|
||||
description: string
|
||||
amount: number
|
||||
currency: string
|
||||
external_id: string // dedup key
|
||||
mcc_code?: number | null
|
||||
merchant_name?: string | null
|
||||
reference?: string | null // OCR number, Bankgiro ref, etc.
|
||||
bank_connection_id?: string | null
|
||||
import_source?: string // 'csv_nordea', 'camt053', 'enable_banking', etc.
|
||||
}
|
||||
|
||||
export interface IngestResult {
|
||||
imported: number
|
||||
duplicates: number
|
||||
reconciled: number
|
||||
auto_categorized: number
|
||||
auto_matched_invoices: number
|
||||
errors: number
|
||||
transaction_ids: string[]
|
||||
}
|
||||
// Re-export types for backward compatibility
|
||||
export type { RawTransaction, IngestResult } from '@/types'
|
||||
|
||||
/**
|
||||
* Generic transaction ingestion pipeline.
|
||||
|
||||
Reference in New Issue
Block a user