Skip to content

Commit

Permalink
docs(huawei & dummy): added missing descriptions and fixed breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
H4ad committed Jun 17, 2022
1 parent 3027bda commit e6baee9
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 4 deletions.
74 changes: 74 additions & 0 deletions src/@types/huawei/huawei-api-gateway-event.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,101 @@
//#region Imports

import { BothValueHeaders } from '../index';

//#endregion

/**
* The interface that represents the Api Gateway Event of Huawei when integrate with Function Graph of Event Type.
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Reference}.
*
* @public
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
*/
export interface HuaweiApiGatewayEvent {
/**
* The body value with the content of this event serialized in JSON
*/
body: string;

/**
* The headers of the request which this event represents
*/
headers: BothValueHeaders;

/**
* The HTTP Method of the request which this event represents
*/
httpMethod: string;

/**
* Tells if the body is base64 encoded
*/
isBase64Encoded: boolean;

/**
* The path of the request which this event represents
*/
path: string;

/**
* The path parameters of the request which this event represents
*/
pathParameters: HuaweiRequestPathParameters;

/**
* The query strings of the request which this event represents
*/
queryStringParameters: HuaweiRequestQueryStringParameters;

/**
* The request context with information about the stage, api and requestId
*/
requestContext: HuaweiRequestContext;

/**
* It can have more properties that I could not discover yet
*/
[key: string]: any;
}

/**
* The path parameters of the request, usually is the name of the wildcard you create in FunctionGraph, such as /\{proxy\}.
*
* @public
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
*/
export type HuaweiRequestPathParameters = Record<string, string>;

/**
* The query strings of the request
*
* @public
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
*/
export type HuaweiRequestQueryStringParameters = Record<
string,
string | string[]
>;

/**
* The interface that represents the values you can get inside request context.
*
* @public
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
*/
export interface HuaweiRequestContext {
/**
* The ID of your API inside Api Gateway
*/
apiId: string;

/**
* The ID of this request
*/
requestId: string;

/**
* The name of the stage running this Function Graph
*/
stage: string;
}
26 changes: 26 additions & 0 deletions src/@types/huawei/huawei-api-gateway-response.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
//#region Imports

import { MultiValueHeaders } from '../headers';

//#endregion

/**
* The interface that represents the Api Gateway Response of Huawei when integrate with Function Graph of Event Type.
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Reference}.
*
* @public
* @breadcrumb Types / Huawei / HuaweiApiGatewayResponse
*/
export interface HuaweiApiGatewayResponse {
/**
* Tells if the body was encoded as base64
*/
isBase64Encoded: boolean;

/**
* The HTTP Status code of this response
*/
statusCode: number;

/**
* The headers sent with this response
*/
headers: MultiValueHeaders;

/**
* The body value with the content of this response serialized in JSON
*/
body: string;
}
171 changes: 171 additions & 0 deletions src/@types/huawei/huawei-context.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,215 @@
/**
* The return value of {@link HuaweiContext} getRequestID
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetRequestIDSecondsReturn = string;

/**
* The return value of {@link HuaweiContext} getRemainingTimeInMilliSeconds
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetRemainingTimeInMilliSecondsReturn = number;

/**
* The return value of {@link HuaweiContext} getAccessKey
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetAccessKeyReturn = string;

/**
* The return value of {@link HuaweiContext} getSecretKey
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetSecretKeyReturn = string;

/**
* The parameters of the method {@link HuaweiContext} getUserData
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetUserDataKeyParameter = string;

/**
* The return value of {@link HuaweiContext} getUserData
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetUserDataReturn = any;

/**
* The return value of {@link HuaweiContext} getFunctionName
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetFunctionNameReturn = string;

/**
* The return value of {@link HuaweiContext} getRunningTimeInSeconds
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetRunningTimeInSecondsReturn = number;

/**
* The return value of {@link HuaweiContext} getVersion
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetVersionReturn = string;

/**
* The return value of {@link HuaweiContext} getMemorySize
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetMemorySizeReturn = number;

/**
* The return value of {@link HuaweiContext} getCPUNumber
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetCPUNumberReturn = number;

/**
* The return value of {@link HuaweiContext} getProjectID
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetProjectIdReturn = number;

/**
* The return value of {@link HuaweiContext} getPackage
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetPackageReturn = string;

/**
* The return value of {@link HuaweiContext} getToken
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetTokenReturn = string;

/**
* The return value of {@link HuaweiContext} getLogger
*
* Is the instance of logger that can be used to send logs to
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export type GetLoggerReturn = {
info(message: string): void;
};

/**
* The interface that represents methods sent by huawei to get information about the function graph.
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0410.html#section1 | Context Methods}
*
* @public
* @breadcrumb Types / Huawei / HuaweiContext
*/
export interface HuaweiContext {
/**
* Obtains a request ID.
*/
getRequestID(): GetRequestIDSecondsReturn;

/**
* Obtains the remaining running time of a function.
*/
getRemainingTimeInMilliSeconds(): GetRemainingTimeInMilliSecondsReturn;

/**
* Obtains the AK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.
*/
getAccessKey(): GetAccessKeyReturn;

/**
* Obtains the SK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.
*/
getSecretKey(): GetSecretKeyReturn;

/**
* Uses keys to obtain the values passed by environment variables.
*
* @param key - The key to get environment variables values
*/
getUserData(key: GetUserDataKeyParameter): GetUserDataReturn;

/**
* Obtains the name of a function.
*/
getFunctionName(): GetFunctionNameReturn;

/**
* Obtains the timeout of a function.
*/
getRunningTimeInSeconds(): GetRunningTimeInSecondsReturn;

/**
* Obtains the version of a function.
*/
getVersion(): GetVersionReturn;

/**
* Obtains the allocated memory.
*/
getMemorySize(): GetMemorySizeReturn;

/**
* Number of CPU millicores used by the function (1 core = 1000 millicores).
*
* The value of this field is proportional to that of MemorySize. By default, 100 CPU millicores are required for 128 MB memory. The number of CPU millicores is calculated as follows: Memory/128 x 100 + 200 (basic CPU millicores).
*/
getCPUNumber(): GetCPUNumberReturn;

/**
* Obtains a project ID.
*/
getProjectID(): GetProjectIdReturn;

/**
* Obtains a function group, that is, an app.
*/
getPackage(): GetPackageReturn;

/**
* Obtains the token (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.
*/
getToken(): GetTokenReturn;

/**
* Obtains the logger method provided by the context and returns a log output class. Logs are output in the format of Time-Request ID-Content by using the info method.
*
* For example, use the info method to output logs:
*
* @example
* ```typescript
* logg = context.getLogger()
*
* logg.info("hello")
* ```
*/
getLogger(): GetLoggerReturn;
}
2 changes: 1 addition & 1 deletion src/adapters/dummy/dummy.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EmptyResponse, IEmptyResponse } from '../../core';
/**
* The class that represents a dummy adapter that does nothing and can be used by the cloud that doesn't use adapters.
*
* @breadcrumb Adapters / Dummy
* @breadcrumb Adapters / DummyAdapter
* @public
*/
export class DummyAdapter implements AdapterContract<any, any, void> {
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/huawei/huawei-api-gateway.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
/**
* The options to customize the {@link HuaweiApiGatewayAdapter}
*
* @breadcrumb Adapters / Huawei / Api Gateway
* @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter
* @public
*/
export interface HuaweiApiGatewayOptions {
Expand All @@ -45,7 +45,7 @@ export interface HuaweiApiGatewayOptions {
* const adapter = new ApiGatewayAdapter({ stripBasePath });
* ```
*
* @breadcrumb Adapters / Huawei / Api Gateway
* @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter
* @public
*
* {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Event Reference}
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/dummy/dummy.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Resolver, ResolverContract } from '../../contracts';
/**
* The class that represents a dummy resolver that does nothing and can be used by the cloud that doesn't use resolvers.
*
* @breadcrumb Resolvers / Dummy
* @breadcrumb Resolvers / DummyResolver
* @public
*/
export class DummyResolver
Expand Down

0 comments on commit e6baee9

Please sign in to comment.