Skip to content

Commit a9c37b9

Browse files
fix: SLS Framework types
1 parent c1f41df commit a9c37b9

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

src/frameworks/slsFramework.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33
import { EsBuildOptions, LambdaResource } from '../types/resourcesDiscovery.js';
44
import { constants } from 'fs';
55
import { findPackageJson } from '../utils/findPackageJson.js';
6-
import type Serverless from 'serverless';
6+
import type { Serverless } from './slsFrameworkTypes.js';
77
import { IFramework } from './iFrameworks.js';
88
import { LldConfigBase } from '../types/lldConfig.js';
99
import { Logger } from '../logger.js';
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* Mock types for the Serverless Framework.
3+
* Copied from node_modules/@types/serverless/index.d.ts when the 'serverless' package is not installed.
4+
* External references (AwsProvider, Service class, etc.) are inlined or simplified.
5+
*/
6+
7+
/** Stand-in for AwsProvider.Event so we don't depend on awsProvider.d.ts */
8+
type Event = unknown;
9+
10+
/**
11+
* Service instance shape (copied from @types/serverless/classes/Service.d.ts).
12+
* Only the properties used by slsFramework are typed in full.
13+
*/
14+
export interface ServerlessService {
15+
custom: { [key: string]: any };
16+
plugins: string[];
17+
functions: {
18+
[key: string]:
19+
| Serverless.FunctionDefinitionHandler
20+
| Serverless.FunctionDefinitionImage;
21+
};
22+
}
23+
24+
// --- Copied from @types/serverless/index.d.ts (declare namespace Serverless) ---
25+
// eslint-disable-next-line @typescript-eslint/no-namespace -- mirrors @types/serverless for slsFramework cast Serverless.FunctionDefinitionHandler
26+
export namespace Serverless {
27+
/**
28+
* CLI options provided to the command
29+
* @example
30+
* // serverless --verbose --stage prod
31+
* { verbose: true, stage: 'prod' }
32+
*/
33+
export interface Options {
34+
function?: string | undefined;
35+
watch?: boolean | undefined;
36+
verbose?: boolean | undefined;
37+
extraServicePath?: string | undefined;
38+
stage?: string | undefined;
39+
region?: string | undefined;
40+
noDeploy?: boolean | undefined;
41+
[key: string]: string | boolean | string[] | undefined;
42+
}
43+
44+
export interface Config {
45+
servicePath: string;
46+
serviceDir: string;
47+
}
48+
49+
export interface FunctionDefinition {
50+
name?: string | undefined;
51+
package?: Package | undefined;
52+
reservedConcurrency?: number | undefined;
53+
runtime?: string | undefined;
54+
timeout?: number | undefined;
55+
memorySize?: number | undefined;
56+
environment?: { [name: string]: string } | undefined;
57+
events: Event[];
58+
tags?: { [key: string]: string } | undefined;
59+
}
60+
61+
export interface LogOptions {
62+
color?: string | undefined;
63+
bold?: boolean | undefined;
64+
underline?: boolean | undefined;
65+
entity?: string | undefined;
66+
}
67+
68+
export interface FunctionDefinitionHandler extends FunctionDefinition {
69+
handler: string;
70+
}
71+
72+
export interface FunctionDefinitionImage extends FunctionDefinition {
73+
image: string;
74+
}
75+
76+
export interface Package {
77+
/** @deprecated use `patterns` instead */
78+
include?: string[] | undefined;
79+
/** @deprecated use `patterns` instead */
80+
exclude?: string[] | undefined;
81+
patterns?: string[] | undefined;
82+
artifact?: string | undefined;
83+
individually?: boolean | undefined;
84+
}
85+
86+
export type EventType = Event | object;
87+
}
88+
89+
// --- Serverless instance (declare class Serverless) - only the shape used by slsFramework ---
90+
91+
/**
92+
* Serverless instance. Full class in @types/serverless has more members; this mock keeps service, init(), run().
93+
*/
94+
export interface Serverless {
95+
service: ServerlessService;
96+
init(): Promise<any>;
97+
run(): Promise<any>;
98+
}

0 commit comments

Comments
 (0)