build: run build

This commit is contained in:
wss-git 2021-10-08 16:08:18 +08:00
parent 921e32f5db
commit 2c3bcc6164
14 changed files with 194 additions and 2 deletions

2
.gitignore vendored
View File

@ -5,5 +5,3 @@ node_modules
package-lock.json package-lock.json
.idea .idea
.vscode .vscode
lib

44
lib/common/help.d.ts vendored Normal file
View File

@ -0,0 +1,44 @@
declare const _default: ({
header: string;
content: string;
optionList?: undefined;
} | {
header: string;
optionList: ({
name: string;
description: string;
type: StringConstructor;
alias?: undefined;
} | {
name: string;
description: string;
alias: string;
type: StringConstructor;
} | {
name: string;
description: string;
type: BooleanConstructor;
alias?: undefined;
})[];
content?: undefined;
} | {
header: string;
optionList: {
name: string;
description: string;
alias: string;
type: BooleanConstructor;
}[];
content?: undefined;
} | {
header: string;
content: string[];
optionList?: undefined;
} | {
header: string;
content: {
example: string;
}[];
optionList?: undefined;
})[];
export default _default;

10
lib/common/logger.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
export default class ComponentLogger {
static CONTENT: string;
static setContent(content: any): void;
static log(m: any, color?: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'whiteBright' | 'gray'): void;
static info(m: any): void;
static debug(m: any): void;
static error(m: any): void;
static warning(m: any): void;
static success(m: any): void;
}

4
lib/common/stdout-formatter.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
export default class StdoutFormatter {
static stdoutFormatter: any;
static initStdout(): Promise<void>;
}

11
lib/index.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
import { InputProps } from './interface/entity';
export default class FcRemoteInvoke {
/**
* event
* @param inputs
* @returns
*/
invoke(inputs: InputProps): Promise<any>;
private report;
private handlerInputs;
}

1
lib/index.js Normal file

File diff suppressed because one or more lines are too long

34
lib/interface/entity.d.ts vendored Normal file
View File

@ -0,0 +1,34 @@
export interface ICredentials {
AccountID?: string;
AccessKeyID?: string;
AccessKeySecret?: string;
SecurityToken?: string;
}
export interface InputProps {
props?: IProperties;
credentials: ICredentials;
appName: string;
project: {
component: string;
access: string;
projectName: string;
};
command: string;
args: string;
path: {
configPath: string;
};
}
export interface IProperties {
region: string;
serviceName: string;
functionName: string;
qualifier?: string;
domainName?: string;
}
export declare function isProperties(args: any): args is IProperties;
export interface IEventPayload {
event?: string;
eventFile?: string;
eventStdin?: boolean;
}

5
lib/lib/client.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { ICredentials } from '../interface/entity';
export default class Client {
static buildFcClient(region: string, credentials: ICredentials): Promise<any>;
private static getFcEndpoint;
}

4
lib/lib/event.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
export default class File {
static getEvent(eventFile: any): Promise<unknown>;
static eventPriority(eventPriority: any): Promise<any>;
}

1
lib/lib/handler-body.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export default function handlerBody(contentType: string, body: any): any;

39
lib/lib/remote-invoke.d.ts vendored Normal file
View File

@ -0,0 +1,39 @@
import { IProperties, IEventPayload } from '../interface/entity';
export default class RemoteInvoke {
fcClient: any;
accountId: string;
constructor(fcClient: any, accountId: string);
invoke(props: IProperties, eventPayload: IEventPayload, { invocationType }: {
invocationType: any;
}): Promise<void>;
requestDomain(url: string, event: string): Promise<void>;
getHttpTrigger(serviceName: any, functionName: any): Promise<any>;
eventInvoke({ serviceName, functionName, event, qualifier, invocationType }: {
serviceName: any;
functionName: any;
event: any;
qualifier?: string;
invocationType: any;
}): Promise<void>;
httpInvoke({ region, serviceName, functionName, event, qualifier }: {
region: any;
serviceName: any;
functionName: any;
event: any;
qualifier: any;
}): Promise<void>;
/**
* @param event: { body, headers, method, queries, path }
* path /proxy/serviceName/functionName/path ,
*/
request(event: any): Promise<void>;
handlerHttpParmase(event: any): {
headers: any;
queries: any;
method: any;
path: any;
body: any;
};
private showLog;
private getJsonEvent;
}

5
lib/lib/stdin.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
/// <reference types="node" />
export declare function getStdin(): Promise<string>;
export declare namespace getStdin {
var buffer: () => Promise<Buffer>;
}

View File

@ -30,9 +30,11 @@
"dependencies": { "dependencies": {
"@alicloud/fc2": "^2.2.2", "@alicloud/fc2": "^2.2.2",
"@serverless-devs/core": "^0.0.*", "@serverless-devs/core": "^0.0.*",
"form-data": "^4.0.0",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"got": "^11.8.2", "got": "^11.8.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"qs": "^6.10.1",
"readline": "^1.3.0" "readline": "^1.3.0"
}, },
"autoInstall": false, "autoInstall": false,

34
src/lib/handler-body.ts Normal file
View File

@ -0,0 +1,34 @@
import _ from 'lodash';
import qs from 'qs';
import FormData from 'form-data';
export default function handlerBody(contentType: string, body: any) {
if (contentType.includes('text/') || contentType.includes('application/json') || contentType.includes('application/xml')) {
if (_.isString(body)) return body;
try {
return JSON.stringify(body);
} catch (_ex) {
return body.toString();
}
}
if (contentType.includes('application/x-www-form-urlencoded')) {
return qs.stringify(body, { indices: false });
}
if (contentType.includes('multipart/form-data')) {
const form = new FormData();
try {
const newBody = _.isObject(body) ? body : JSON.parse(body);
for (const [key, value] of Object.entries(newBody)) {
form.append(key, value);
}
return form;
} catch (_ex) {
throw new Error(`Handler body error: The request header is ${contentType}, but the request body is not an object`);
}
}
return body;
}