Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added @lambda-lambda-lambda/cli types #69502

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions types/lambda-lambda-lambda__cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/no-invalid-void-type": "off"
nuxy marked this conversation as resolved.
Show resolved Hide resolved
}
}
5 changes: 5 additions & 0 deletions types/lambda-lambda-lambda__cli/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
105 changes: 105 additions & 0 deletions types/lambda-lambda-lambda__cli/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
export interface AppConfig {

/**
* Application name (Example: restfulApiHandler)
*/
name: string,

/**
* Application description
*/
description: string,

/**
* Request prefix (Example: /api)
*/
prefix: string,

/**
* Use asynchronous handler?
*/
asynchronous: string,

/**
* Function timeout (in seconds)
*/
timeout: string,

/**
* AWS SDK for JavaScript version
*/
sdkVersion: string,

/**
* Node.js Lambda runtime identifier
*/
runtime: string
}

export interface PluginInfo {
[key: string]: any

/**
* Middleware plugin name.
*/
name: string,

/**
* Github content URL
*/
html_url: string
}

export interface TemplateVars {

appName?: AppConfig['name'],
appDescription?: AppConfig['description'],
appPrefix?: AppConfig['prefix'],
appTimeout?: AppConfig['timeout'],
appRuntime?: AppConfig['runtime'],

/**
* Package name (Example: restful-api-handler)
*/
pkgName?: string | undefined,

/**
* AWS SDK mock library (Options: aws-sdk-client-mock|aws-sdk-mock)'
*/
sdkPackage?: string | undefined,

/**
* CloudFront resource name
*/
cfResourceName?: string | undefined,

/**
* Router path (Example: /api)
*/
routePath: string,

/**
* Node version number
*/
nodeVersion?: string | undefined
}

/**
* Generate app sources from templates.
*/
export function createFiles(appConfig: AppConfig, outPath: string): Promise<void>

/**
* Generate file source from a template.
*/
export function createFile(name: string, outPath: string, basePath: string): Promise<void>

/**
* Install remote middleware
*/
export function addPackage(name: string): Promise<string|undefined>

/**
* Request plugin list from the package repo.
*/
export function listPackages(): Promise<PluginInfo[]>
49 changes: 49 additions & 0 deletions types/lambda-lambda-lambda__cli/lambda-lambda-lambda__cli-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {
createFiles,
createFile,
listPackages,
addPackage
} from '@lambda-lambda-lambda/cli';

const basePath = './workspace';
const outPath = 'path/to/output';

const appConfig = {
name: 'restfulApiHandler',
description: 'This is my awesome serverless application.',
prefix: '/api',
asynchronous: 'Yes',
timeout: '15',
sdkVersion: '3',
runtime: 'nodejs20.x'
}

// $ExpectType Promise<void>
createFiles(appConfig, outPath);

// @ts-expect-error
createFiles(appConfig, null);

// @ts-expect-error
createFiles({}, outPath);

// $ExpectType Promise<void>
createFile(appConfig.name, outPath, basePath);

// @ts-expect-error
createFile(appConfig.name, null, basePath);

// @ts-expect-error
createFile(appConfig.name, outPath, null);

// @ts-expect-error
createFile(null, outPath, basePath);

// $ExpectType Promise<PluginInfo[]>
listPackages();

// $ExpectType Promise<string|undefined>
addPackage('AccessControlHeaders');

// @ts-expect-error
addPackage(null);
17 changes: 17 additions & 0 deletions types/lambda-lambda-lambda__cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"name": "@types/lambda-lambda-lambda__cli",
"version": "0.6.9999",
"projects": [
"https://github.com/lambda-lambda-lambda/cli"
],
"devDependencies": {
"@types/lambda-lambda-lambda__cli": "workspace:."
},
"owners": [
{
"name": "Marc S. Brooks",
"githubUsername": "nuxy"
}
]
}
19 changes: 19 additions & 0 deletions types/lambda-lambda-lambda__cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "Node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"lambda-lambda-lambda__cli-tests.ts"
]
}