|
| 1 | +/** |
| 2 | + * Mock types for the Serverless Framework. |
| 3 | + * Used when the 'serverless' package is not installed (e.g. optional/peer dependency). |
| 4 | + * Mirrors @types/serverless shapes used by this project. |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * Service instance shape (matches Service class in @types/serverless). |
| 9 | + * This project only supports handler-based functions; functions is typed accordingly so no cast is needed. |
| 10 | + */ |
| 11 | +export interface ServerlessService { |
| 12 | + custom: Record<string, any>; |
| 13 | + plugins: string[]; |
| 14 | + functions?: Record<string, ServerlessFunctionDefinitionHandler>; |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Base function definition (matches Serverless.FunctionDefinition in @types/serverless). |
| 19 | + */ |
| 20 | +export interface ServerlessFunctionDefinitionBase { |
| 21 | + name?: string; |
| 22 | + package?: Record<string, any>; |
| 23 | + reservedConcurrency?: number; |
| 24 | + runtime?: string; |
| 25 | + timeout?: number; |
| 26 | + memorySize?: number; |
| 27 | + environment?: Record<string, string>; |
| 28 | + events?: unknown[]; |
| 29 | + tags?: Record<string, string>; |
| 30 | + [key: string]: any; |
| 31 | +} |
| 32 | + |
| 33 | +/** |
| 34 | + * Handler-based function (matches Serverless.FunctionDefinitionHandler). |
| 35 | + */ |
| 36 | +export interface ServerlessFunctionDefinitionHandler extends ServerlessFunctionDefinitionBase { |
| 37 | + handler: string; |
| 38 | +} |
| 39 | + |
| 40 | +/** |
| 41 | + * Serverless instance (matches Serverless class in @types/serverless). |
| 42 | + * The real class is loaded dynamically; this type describes the shape we use. |
| 43 | + */ |
| 44 | +export interface Serverless { |
| 45 | + service: ServerlessService; |
| 46 | + init(): Promise<void>; |
| 47 | + run(): Promise<void>; |
| 48 | +} |
| 49 | + |
| 50 | +/** Namespace for Serverless.FunctionDefinitionHandler (used in slsFramework cast). */ |
| 51 | +// eslint-disable-next-line @typescript-eslint/no-namespace -- needed for Serverless.FunctionDefinitionHandler with no slsFramework changes |
| 52 | +export namespace Serverless { |
| 53 | + export type FunctionDefinitionHandler = ServerlessFunctionDefinitionHandler; |
| 54 | +} |
0 commit comments