Skip to content

Commit

Permalink
fix(serverless): update config properties
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Feb 8, 2021
1 parent 27ccf29 commit d56076c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
29 changes: 22 additions & 7 deletions types/serverless/plugins/aws/provider/awsProvider.d.ts
Expand Up @@ -6,8 +6,12 @@ declare namespace Aws {
*/
interface Serverless {
service: Service | string;
frameworkVersion: string;
configValidationMode?: string;
useDotenv?: boolean;
frameworkVersion?: string;
enableLocalInstallationFallback?: boolean;
unresolvedVariablesNotificationMode?: 'warn' | 'error';
disabledDeprecations?: string[];
configValidationMode?: 'warn' | 'error' | 'off';
provider: Provider;
package?: Package;
functions?: Functions;
Expand All @@ -22,6 +26,7 @@ declare namespace Aws {

interface Service {
name: string;
/** @deprecated in favor of `kmsKeyArn` at the provider level */
awsKmsKeyArn?: string;
}

Expand Down Expand Up @@ -64,6 +69,7 @@ declare namespace Aws {
tags?: Tags;
tracing?: Tracing;
logs?: Logs;
kmsKeyArn?: string;
}

interface Tags {
Expand Down Expand Up @@ -93,7 +99,7 @@ declare namespace Aws {
[key: string]: string;
};
websocketApiId?: any;
apiKeySourceType?: string;
apiKeySourceType?: 'HEADER' | 'AUTHORIZER' | 'header' | 'authorizer';
minimumCompressionSize?: number | string;
description?: string;
binaryMediaTypes?: string[];
Expand Down Expand Up @@ -218,21 +224,21 @@ declare namespace Aws {

interface Tracing {
apiGateway: boolean;
lambda?: boolean;
lambda?: 'Active' | 'PassThrough' | boolean;
}

interface RestApiLogs {
accessLogging?: boolean;
format?: string;
executionLogging?: boolean;
level?: string;
level?: 'INFO' | 'ERROR';
fullExecutionData?: boolean;
role?: string;
roleManagedExternally?: boolean;
}

interface WebsocketLogs {
level?: string;
level?: 'INFO' | 'ERROR';
}

interface HttpApiLogs {
Expand Down Expand Up @@ -512,6 +518,11 @@ declare namespace Aws {
cloudFront?: CloudFront;
}

interface FileSystemConfig {
arn: string;
localMountPath: string;
}

interface AwsFunction {
name?: string;
description?: string;
Expand All @@ -522,17 +533,21 @@ declare namespace Aws {
timeout?: number | string;
role?: string;
onError?: string;
/** @deprecated in favor of `kmsKeyArn` */
awsKmsKeyArn?: string;
kmsKeyArn?: string;
environment?: Environment;
tags?: Tags;
vpc?: string | Vpc;
package?: Package;
layers?: Array<string | Record<string, string>>;
tracing?: string;
tracing?: 'Active' | 'PassThrough' | boolean;
condition?: string;
dependsOn?: string[];
fileSystemConfig?: FileSystemConfig;
destinations?: Destinations;
events?: Event[];
disableLogs?: boolean;
}

interface AwsFunctionHandler extends AwsFunction {
Expand Down
37 changes: 33 additions & 4 deletions types/serverless/serverless-tests.ts
Expand Up @@ -166,7 +166,7 @@ const awsServerless: Aws.Serverless = {
testrestapiresource: 'testrestapiresource'
},
websocketApiId: 'testwebsocketApiId',
apiKeySourceType: 'testapiKeySourceType',
apiKeySourceType: 'HEADER',
minimumCompressionSize: 1,
description: 'testdescription',
binaryMediaTypes: ['testbinaryMediaTypes']
Expand Down Expand Up @@ -308,13 +308,13 @@ const awsServerless: Aws.Serverless = {
accessLogging: false,
format: 'testformat',
executionLogging: false,
level: 'testlevel',
level: 'ERROR',
fullExecutionData: false,
role: 'testrole',
roleManagedExternally: false,
},
websocket: {
level: 'testlevel'
level: 'INFO'
},
httpApi: {
format: 'testformat'
Expand Down Expand Up @@ -363,7 +363,7 @@ const awsServerless: Aws.Serverless = {
individually: true
},
layers: ['testlayers'],
tracing: 'testtracing',
tracing: 'PassThrough',
condition: 'testcondition',
dependsOn: ['testdependson'],
destinations: {
Expand Down Expand Up @@ -644,6 +644,35 @@ const awsServerless: Aws.Serverless = {
awsServerless.provider.vpc = 'serverless reference';
awsServerless.functions![0].vpc = 'serverless reference';

const bunchOfConfigs: Aws.Serverless[] = [
{
service: 'users',
provider: { name: 'aws' },
functions: {}
},
{
service: 'users',
useDotenv: true,
provider: { name: 'aws' },
functions: {}
},
{
service: 'users',
configValidationMode: 'off',
unresolvedVariablesNotificationMode: 'error',
provider: { name: 'aws' },
functions: {}
},
{
service: 'users',
disabledDeprecations: [
'*'
],
provider: { name: 'aws' },
functions: {}
}
];

// Test Aws Class
const aws = new Aws(serverless, options);

Expand Down

0 comments on commit d56076c

Please sign in to comment.