/** * Core plugin interface definitions for the Craft Code extensibility framework */ import * as React from 'react'; export interface PluginMetadata { id: string; name: string; version: string; description: string; author: string; homepage?: string; repository?: string; license: string; keywords: string[]; engines: { craftCode: string; node: string; }; dependencies?: Record; peerDependencies?: Record; icon?: string; screenshots?: string[]; category: PluginCategory; tags: string[]; pricing?: PluginPricing; publishedAt: Date; updatedAt: Date; downloads: number; rating: { average: number; count: number; }; } export declare enum PluginCategory { AI_INTEGRATION = "ai-integration", CODE_GENERATION = "code-generation", DEPLOYMENT = "deployment", TESTING = "testing", VERSION_CONTROL = "version-control", DATABASE = "database", CLOUD_SERVICES = "cloud-services", BLOCKCHAIN = "blockchain", PAYMENT = "payment", UTILITIES = "utilities", THEMES = "themes", LANGUAGES = "languages", FRAMEWORKS = "frameworks", CONTAINERS = "containers" } export interface PluginPricing { type: 'free' | 'paid' | 'freemium'; price?: number; currency?: string; billingCycle?: 'monthly' | 'yearly' | 'one-time'; trialPeriod?: number; } export interface PluginCapabilities { codeGeneration?: boolean; fileSystemAccess?: boolean; networkAccess?: boolean; shellAccess?: boolean; databaseAccess?: boolean; cloudAccess?: boolean; uiExtensions?: boolean; apiAccess?: boolean; webhooks?: boolean; storage?: boolean; } export interface PluginConfiguration { schema: Record; defaults: Record; } export interface ConfigurationField { type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'select' | 'multiselect'; label: string; description?: string; required?: boolean; default?: any; validation?: { min?: number; max?: number; pattern?: string; enum?: any[]; }; options?: Array<{ value: any; label: string; }>; sensitive?: boolean; } export interface PluginContext { id: string; version: string; config: Record; logger: PluginLogger; storage: PluginStorage; api: PluginAPI; workspace: WorkspaceAPI; ui: PluginUI; events: EventEmitter; } export interface PluginLogger { debug(message: string, ...args: any[]): void; info(message: string, ...args: any[]): void; warn(message: string, ...args: any[]): void; error(message: string, ...args: any[]): void; } export interface PluginStorage { get(key: string): Promise; set(key: string, value: T): Promise; delete(key: string): Promise; clear(): Promise; keys(): Promise; } export interface PluginAPI { request(options: RequestOptions): Promise; webhook: WebhookAPI; } export interface RequestOptions { url: string; method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; headers?: Record; body?: any; timeout?: number; } export interface WebhookAPI { create(options: WebhookOptions): Promise; delete(id: string): Promise; list(): Promise; } export interface WebhookOptions { events: string[]; secret?: string; metadata?: Record; } export interface Webhook { id: string; url: string; events: string[]; secret?: string; createdAt: Date; metadata?: Record; } export interface WorkspaceAPI { rootPath: string; getProject(): Promise; createFile(path: string, content: string): Promise; readFile(path: string): Promise; updateFile(path: string, content: string): Promise; deleteFile(path: string): Promise; listFiles(pattern?: string): Promise; executeCommand(command: string, args?: string[]): Promise; watchFiles(pattern: string, callback: (event: FileEvent) => void): Promise; } export interface Project { id: string; name: string; path: string; type: string; framework?: string; language: string; metadata: Record; } export interface CommandResult { stdout: string; stderr: string; exitCode: number; duration: number; } export interface FileEvent { type: 'created' | 'modified' | 'deleted'; path: string; timestamp: Date; } export interface FileWatcher { stop(): void; } export interface PluginUI { showInputDialog(arg0: { title: string; placeholder: string; multiline: boolean; }): string | PromiseLike | null; showNotification(options: NotificationOptions): void; showModal(options: ModalOptions): Promise; registerCommand(command: PluginCommand): void; registerView(view: PluginView): void; registerStatusBarItem(item: StatusBarItem): void; registerContextMenuItem(item: ContextMenuItem): void; createPanel(options: PanelOptions): Panel; createStatusBarItem(options: StatusBarItemOptions): StatusBarItem; showQuickPick(items: QuickPickItem[], options?: QuickPickOptions): Promise; showConfirmDialog(options: ConfirmDialogOptions): Promise; showOutput(channel: string): void; appendOutput(channel: string, text: string): void; showProgress(options: ProgressOptions): Progress; hideProgress(progress: Progress): void; createTerminal(options: TerminalOptions): Terminal; } export interface NotificationOptions { type: 'info' | 'success' | 'warning' | 'error'; title: string; message: string; actions?: Array<{ label: string; action: () => void; }>; timeout?: number; } export interface ModalOptions { title: string; content: string | React.ComponentType; width?: number; height?: number; buttons?: Array<{ label: string; variant: 'primary' | 'secondary' | 'danger'; action: () => any; }>; } export interface PluginCommand { id: string; title: string; category?: string; keybinding?: string; when?: string; handler: (args?: any) => Promise; } export interface PluginView { id: string; title: string; icon?: string; location: 'sidebar' | 'panel' | 'editor'; component: React.ComponentType; when?: string; } export interface StatusBarItem { id: string; text: string; tooltip?: string; command?: string; alignment: 'left' | 'right'; priority: number; } export interface ContextMenuItem { id: string; label: string; command: string; when?: string; group?: string; } export interface PanelOptions { id: string; title: string; icon?: string; position: 'left' | 'right' | 'bottom'; width?: number; height?: number; content?: React.ComponentType; } export interface Panel { id: string; show(): void; hide(): void; dispose(): void; } export interface StatusBarItemOptions { id: string; text: string; tooltip?: string; command?: string; alignment: 'left' | 'right'; priority: number; } export interface QuickPickItem { label: string; title?: string; description?: string; detail?: string; value: T; } export interface QuickPickOptions { title?: string; placeholder?: string; canPickMany?: boolean; ignoreFocusOut?: boolean; } export interface ConfirmDialogOptions { title: string; message: string; confirmLabel?: string; confirmText?: string; cancelLabel?: string; type?: 'info' | 'warning' | 'error'; } export interface ProgressOptions { title: string; cancellable?: boolean; location?: 'notification' | 'window' | 'source-control'; } export interface Progress { report(value: { message?: string; increment?: number; }): void; cancel(): void; } export interface TerminalOptions { id?: string; name: string; title?: string; cwd?: string; env?: Record; shellPath?: string; shellArgs?: string[]; } export interface Terminal { sendText(text: string, addNewLine?: boolean): void; show(preserveFocus?: boolean): void; hide(): void; dispose(): void; } export interface PluginHooks { onActivate?(context: PluginContext): Promise; onDeactivate?(): Promise; onProjectOpen?(project: Project): Promise; onProjectClose?(): Promise; onFileCreate?(path: string): Promise; onFileChange?(path: string): Promise; onFileDelete?(path: string): Promise; onCommand?(command: string, args?: any): Promise; onConfigChange?(newConfig: Record): Promise; } export interface Plugin extends PluginHooks { metadata: PluginMetadata; capabilities: PluginCapabilities; configuration?: PluginConfiguration; activate(context: PluginContext): Promise; deactivate(): Promise; } export interface PluginManifest { name: string; version: string; main: string; craftCodePlugin: { metadata: Omit; capabilities: PluginCapabilities; configuration?: PluginConfiguration; activationEvents?: string[]; contributes?: PluginContributions; }; } export interface PluginContributions { commands?: PluginCommand[]; views?: PluginView[]; statusBarItems?: StatusBarItem[]; contextMenuItems?: ContextMenuItem[]; languages?: LanguageContribution[]; themes?: ThemeContribution[]; snippets?: SnippetContribution[]; keybindings?: KeybindingContribution[]; } export interface LanguageContribution { id: string; aliases: string[]; extensions: string[]; mimetypes?: string[]; configuration?: string; } export interface ThemeContribution { id: string; label: string; uiTheme: 'light' | 'dark'; path: string; } export interface SnippetContribution { language: string; path: string; } export interface KeybindingContribution { command: string; key: string; when?: string; mac?: string; linux?: string; win?: string; } export declare class PluginError extends Error { pluginId: string; code: PluginErrorCode; details?: any | undefined; constructor(message: string, pluginId: string, code: PluginErrorCode, details?: any | undefined); } export declare enum PluginErrorCode { ACTIVATION_FAILED = "ACTIVATION_FAILED", DEACTIVATION_FAILED = "DEACTIVATION_FAILED", INVALID_MANIFEST = "INVALID_MANIFEST", DEPENDENCY_NOT_FOUND = "DEPENDENCY_NOT_FOUND", PERMISSION_DENIED = "PERMISSION_DENIED", CONFIGURATION_ERROR = "CONFIGURATION_ERROR", RUNTIME_ERROR = "RUNTIME_ERROR", SANDBOX_VIOLATION = "SANDBOX_VIOLATION", VERSION_INCOMPATIBLE = "VERSION_INCOMPATIBLE" } export interface PluginEvent { type: string; pluginId: string; timestamp: Date; data?: any; } export interface PluginAnalytics { activations: number; deactivations: number; errors: number; lastUsed: Date; totalUsageTime: number; commandsExecuted: number; filesCreated: number; apiCalls: number; } export interface PluginSecurity { permissions: string[]; trustedDomains?: string[]; sandboxConfig: SandboxConfig; codeSignature?: string; publisher: { id: string; verified: boolean; reputation: number; }; } export interface SandboxConfig { allowNetworkAccess: boolean; allowFileSystemAccess: boolean; allowShellAccess: boolean; allowedDomains?: string[]; allowedPaths?: string[]; allowedCommands?: string[]; timeoutMs: number; memoryLimitMB: number; cpuLimitPercent: number; } export interface PluginDependency { name: string; version: string; type: 'plugin' | 'npm' | 'binary'; optional?: boolean; platforms?: string[]; } export interface PluginUpdate { currentVersion: string; latestVersion: string; changelog: string; breaking: boolean; size: number; releaseDate: Date; downloadUrl: string; } export interface PluginInstallOptions { version?: string; force?: boolean; skipDependencies?: boolean; dev?: boolean; } export interface PluginSearchOptions { query?: string; category?: PluginCategory; tags?: string[]; author?: string; pricing?: 'free' | 'paid'; sortBy?: 'relevance' | 'downloads' | 'rating' | 'updated'; limit?: number; offset?: number; } export interface PluginSearchResult { plugins: PluginMetadata[]; total: number; hasMore: boolean; } export interface EventEmitter { on(event: string, listener: (...args: any[]) => void): void; off(event: string, listener: (...args: any[]) => void): void; emit(event: string, ...args: any[]): void; once(event: string, listener: (...args: any[]) => void): void; } export interface PluginTestUtils { createMockContext(): PluginContext; createMockProject(): Project; mockAPI(responses: Record): void; assertFileExists(path: string): void; assertFileContent(path: string, expectedContent: string): void; waitForEvent(event: string, timeout?: number): Promise; } export interface PluginTemplate { id: string; name: string; description: string; category: PluginCategory; files: Array<{ path: string; content: string; template?: boolean; }>; variables: Record; } export interface TemplateVariable { type: 'string' | 'boolean' | 'number' | 'select'; label: string; description?: string; default?: any; options?: any[]; required?: boolean; } export default Plugin; //# sourceMappingURL=types.d.ts.map