consolidated-interfaces-template.json•7.13 kB
{
"id": "consolidated-interfaces-template",
"name": "Consolidated TypeScript Interfaces Template",
"description": "A template for creating a unified TypeScript interfaces file that consolidates related interfaces into a centralized location",
"content": "/**\n * {{project_name}} - Unified Interface Definitions\n * \n * This file contains all interface definitions for the {{project_name}} project, \n * organized by domain and responsibility.\n */\n\n// ============================\n// Core Domain Interfaces\n// ============================\n\n/**\n * {{primary_entity}} interface\n * {{primary_entity_description}}\n */\nexport interface {{primary_entity}} {\n /** Unique identifier */\n id: string;\n \n /** Name for display purposes */\n name: string;\n \n /** Optional description */\n description?: string;\n \n /** Content or data */\n content: string;\n \n /** Additional properties */\n {{additional_properties}}\n \n /** Creation timestamp (ISO string) */\n createdAt: string;\n \n /** Last update timestamp (ISO string) */\n updatedAt: string;\n \n /** Version number, incremented on updates */\n version: number;\n \n /** Optional metadata */\n metadata?: Record<string, any>;\n}\n\n// ============================\n// Service Interfaces\n// ============================\n\n/**\n * {{service_name}} interface\n * Defines the contract for service operations on {{primary_entity}} objects\n */\nexport interface {{service_name}} {\n /**\n * Get a {{primary_entity}} by ID\n * @param id {{primary_entity}} ID\n * @returns The {{primary_entity}}\n */\n get{{primary_entity}}(id: string): Promise<{{primary_entity}}>;\n \n /**\n * Add a new {{primary_entity}}\n * @param data Partial {{primary_entity}} data\n * @returns The created {{primary_entity}}\n */\n add{{primary_entity}}(data: Partial<{{primary_entity}}>): Promise<{{primary_entity}}>;\n \n /**\n * Update an existing {{primary_entity}}\n * @param id {{primary_entity}} ID\n * @param data Updated {{primary_entity}} data\n * @returns The updated {{primary_entity}}\n */\n update{{primary_entity}}(id: string, data: Partial<{{primary_entity}}>): Promise<{{primary_entity}}>;\n \n /**\n * List {{primary_entity}} objects with optional filtering\n * @param options Filter options\n * @returns Filtered list of {{primary_entity}} objects\n */\n list{{primary_entity}}s(options?: {{list_options_interface}}): Promise<{{primary_entity}}[]>;\n \n /**\n * Delete a {{primary_entity}}\n * @param id {{primary_entity}} ID\n */\n delete{{primary_entity}}(id: string): Promise<void>;\n \n /**\n * Additional service methods\n */\n {{additional_service_methods}}\n}\n\n// ============================\n// Storage Interfaces\n// ============================\n\n/**\n * Storage adapter interface for {{primary_entity}} persistence\n */\nexport interface StorageAdapter {\n /**\n * Connect to the storage\n */\n connect(): Promise<void>;\n \n /**\n * Disconnect from the storage\n */\n disconnect(): Promise<void>;\n \n /**\n * Check if connected to the storage\n */\n isConnected(): boolean | Promise<boolean>;\n \n /**\n * Save a {{primary_entity}} to storage\n * @param {{primary_entity_lowercase}} {{primary_entity}} to save\n * @returns {{primary_entity}} ID or the full {{primary_entity}}\n */\n save{{primary_entity}}({{primary_entity_lowercase}}: Partial<{{primary_entity}}>): Promise<string | {{primary_entity}}>;\n \n /**\n * Get a {{primary_entity}} by ID\n * @param id {{primary_entity}} ID\n * @returns {{primary_entity}}\n */\n get{{primary_entity}}(id: string): Promise<{{primary_entity}}>;\n \n /**\n * Update a {{primary_entity}}\n * @param id {{primary_entity}} ID\n * @param data Updated {{primary_entity}} data\n * @returns Updated {{primary_entity}} or void\n */\n update{{primary_entity}}?(id: string, data: Partial<{{primary_entity}}>): Promise<{{primary_entity}} | void>;\n \n /**\n * List {{primary_entity}} objects with filtering options\n * @param options Filtering options\n * @returns Array of {{primary_entity}} objects matching options\n */\n list{{primary_entity}}s(options?: {{list_options_interface}}): Promise<{{primary_entity}}[]>;\n \n /**\n * Delete a {{primary_entity}}\n * @param id {{primary_entity}} ID\n */\n delete{{primary_entity}}(id: string): Promise<void>;\n \n /**\n * Clear all {{primary_entity}} objects\n * Removes all {{primary_entity}} objects from storage\n */\n clearAll?(): Promise<void>;\n \n /**\n * Additional storage methods\n */\n {{additional_storage_methods}}\n}\n\n// ============================\n// Configuration Interfaces\n// ============================\n\n/**\n * {{project_name}} configuration interface\n */\nexport interface {{config_interface_name}} {\n /** Application name */\n name: string;\n \n /** Application version */\n version: string;\n \n /** Environment: production, development, etc. */\n environment: string;\n \n /** Storage configuration */\n storage: {\n type: string;\n path?: string;\n connectionString?: string;\n };\n \n /** Server configuration */\n server: {\n port: number;\n host: string;\n {{additional_server_config}}\n };\n \n /** Logging configuration */\n logging: {\n level: 'debug' | 'info' | 'warn' | 'error';\n {{additional_logging_config}}\n };\n \n /** Additional configuration properties */\n {{additional_config_properties}}\n}\n\n// ============================\n// Utility Types\n// ============================\n\n/**\n * Options for listing {{primary_entity}} objects\n */\nexport interface {{list_options_interface}} {\n /** Filter options */\n {{filter_options}}\n \n /** Pagination options */\n offset?: number;\n limit?: number;\n \n /** Sorting options */\n sort?: string;\n order?: 'asc' | 'desc';\n}\n\n/**\n * Error interface with additional context\n */\nexport interface ErrorWithContext extends Error {\n /** Error code */\n code?: string;\n \n /** HTTP status code */\n statusCode?: number;\n \n /** Additional context object */\n context?: Record<string, any>;\n \n /** Original error if this wraps another error */\n originalError?: Error;\n}\n\n// ============================\n// Additional Interfaces\n// ============================\n\n{{additional_interfaces}}",
"isTemplate": true,
"variables": [
"project_name",
"primary_entity",
"primary_entity_description",
"primary_entity_lowercase",
"additional_properties",
"service_name",
"list_options_interface",
"additional_service_methods",
"additional_storage_methods",
"config_interface_name",
"additional_server_config",
"additional_logging_config",
"additional_config_properties",
"filter_options",
"additional_interfaces"
],
"tags": [
"development",
"typescript",
"interfaces",
"consolidation",
"template"
],
"category": "development",
"createdAt": "2024-08-08T15:45:00.000Z",
"updatedAt": "2024-08-08T15:45:00.000Z",
"version": 1
}