03b569d708
- Remove all sector-specific extensions (construction, ecommerce, export, hotel, restaurant, tech) — only general-purpose extensions remain - Move NE-bilaga and SRU export from extensions to core reports (lib/reports/) - Move moms-box-mapping from extensions/export/shared to lib/vat/ - Replace per-extension API routes with catch-all dispatcher (app/api/extensions/ext/[...path]/route.ts) - Add manifest.json for each extension with metadata, env vars, and deps - Add api-routes.ts pattern for extension-defined API endpoints - Add code generation scripts (generate-extension-registry, create-extension) - Add extensions.config.json for opt-in extension loading - Add extensions.schema.json for config validation - Add email service interface with noop default (lib/email/service.ts) - Add CI workflow (core-build.yml) to verify core builds with zero extensions - Add migration 045: expand account_type CHECK for untaxed_reserves - Update CLAUDE.md with comprehensive extension system documentation - Update all report engines and bookkeeping services for new imports - Clean up extensions.schema.json to only list existing extensions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import type { Sector, SectorSlug, ExtensionDefinition } from './types'
|
|
import { EXTENSION_DEFINITIONS } from './_generated/sector-definitions'
|
|
|
|
// ============================================================
|
|
// Sector & Extension Registry
|
|
// ============================================================
|
|
//
|
|
// Sector shells are structural and always present.
|
|
// Extension definitions per sector come from the generated file
|
|
// (controlled by extensions.config.json).
|
|
// ============================================================
|
|
|
|
/** Sector shells — structural metadata, always available */
|
|
const SECTOR_SHELLS: Omit<Sector, 'extensions'>[] = [
|
|
{
|
|
slug: 'general',
|
|
name: 'Generella verktyg',
|
|
icon: 'Layers',
|
|
description: 'Verktyg som passar alla verksamheter',
|
|
},
|
|
]
|
|
|
|
/** Full sectors with extensions merged from generated definitions */
|
|
export const SECTORS: Sector[] = SECTOR_SHELLS.map(shell => ({
|
|
...shell,
|
|
extensions: EXTENSION_DEFINITIONS[shell.slug] ?? [],
|
|
}))
|
|
|
|
// ============================================================
|
|
// Helper functions
|
|
// ============================================================
|
|
|
|
export function getSector(slug: SectorSlug): Sector | undefined {
|
|
return SECTORS.find(s => s.slug === slug)
|
|
}
|
|
|
|
export function getExtensionDefinition(sectorSlug: string, extensionSlug: string): ExtensionDefinition | undefined {
|
|
const sector = SECTORS.find(s => s.slug === sectorSlug)
|
|
return sector?.extensions.find(e => e.slug === extensionSlug)
|
|
}
|
|
|
|
export function getAllExtensions(): ExtensionDefinition[] {
|
|
return SECTORS.flatMap(s => s.extensions)
|
|
}
|
|
|
|
export function getExtensionsBySector(slug: SectorSlug): ExtensionDefinition[] {
|
|
return getSector(slug)?.extensions ?? []
|
|
}
|