import type { PluginErrorCode } from '@dorfteich/shared'; /** Compressed upload ceiling for a plugin ZIP (multer rejects larger). */ // Raised for bundled-app plugins (drawio ships its whole editor as assets); // still a hard bound against runaway uploads. export const MAX_PLUGIN_ZIP_BYTES = 64 * 1024 * 1024; // 64 MiB /** Total decompressed ceiling — guards against a zip bomb inflating in memory. */ export const MAX_PLUGIN_UNPACKED_BYTES = 256 * 1024 * 1024; // 256 MiB /** The two files the package structure hinges on. */ export const MANIFEST_FILE = 'manifest.json'; export const CODE_BUNDLE_FILE = 'plugin.js'; export const STYLES_FILE = 'styles.css'; /** * A rejected install/uninstall, carrying a stable {@link PluginErrorCode} and, * for manifest failures, the field-level issues to surface in the API error * body `details`. Thrown by the package/registry services; the controller maps * it to the matching HTTP status. */ export class PluginPackageError extends Error { constructor( readonly code: PluginErrorCode, message: string, readonly details?: Record, ) { super(message); this.name = 'PluginPackageError'; } }