/** * Core interfaces for the composable registry system */ /** * Registry protocol types */ export type TRegistryProtocol = 'oci' | 'npm'; /** * Unified action types across protocols */ export type TRegistryAction = 'pull' | 'push' | 'delete' | 'read' | 'write' | '*'; /** * Unified authentication token */ export interface IAuthToken { /** Token type/protocol */ type: TRegistryProtocol; /** User ID */ userId: string; /** Permission scopes (e.g., "npm:package:foo:write", "oci:repository:bar:push") */ scopes: string[]; /** Token expiration */ expiresAt?: Date; /** Read-only flag */ readonly?: boolean; /** Additional metadata */ metadata?: Record; } /** * Credentials for authentication */ export interface ICredentials { username: string; password: string; } /** * Storage backend configuration */ export interface IStorageConfig { accessKey: string; accessSecret: string; endpoint: string; port?: number; useSsl?: boolean; region?: string; bucketName: string; } /** * Authentication configuration */ export interface IAuthConfig { /** JWT secret for OCI tokens */ jwtSecret: string; /** Token storage type */ tokenStore: 'memory' | 'redis' | 'database'; /** NPM token settings */ npmTokens: { enabled: boolean; defaultReadonly?: boolean; }; /** OCI token settings */ ociTokens: { enabled: boolean; realm: string; service: string; }; } /** * Protocol-specific configuration */ export interface IProtocolConfig { enabled: boolean; basePath: string; features?: Record; } /** * Main registry configuration */ export interface IRegistryConfig { storage: IStorageConfig; auth: IAuthConfig; oci?: IProtocolConfig; npm?: IProtocolConfig; } /** * Storage backend interface */ export interface IStorageBackend { /** * Get an object from storage */ getObject(key: string): Promise; /** * Store an object */ putObject(key: string, data: Buffer, metadata?: Record): Promise; /** * Delete an object */ deleteObject(key: string): Promise; /** * List objects with a prefix */ listObjects(prefix: string): Promise; /** * Check if an object exists */ objectExists(key: string): Promise; /** * Get object metadata */ getMetadata(key: string): Promise | null>; } /** * Error response structure */ export interface IRegistryError { errors: Array<{ code: string; message: string; detail?: any; }>; } /** * Base request context */ export interface IRequestContext { method: string; path: string; headers: Record; query: Record; body?: any; token?: string; } /** * Base response structure */ export interface IResponse { status: number; headers: Record; body?: any; }