UNPKG

lemon-core

Version:
83 lines (82 loc) 2.54 kB
import { NextMode, NextContext, NextIdentityAccess, GeneralItem } from 'lemon-model'; import { CoreWEBController } from '../cores/lambda'; /** * class: `GeneralController`. * - As WebController, routes by path `/hello/{id}/action` to method function like `getHelloAction` */ export declare class GeneralController implements CoreWEBController { /** * resource type of this Controller. */ readonly TYPE: string; /** * default constructor() */ constructor(type: string); /** * name of this resource. */ hello: () => string; /** * type of api-endpoint. */ type: () => string; /** * decode to target `next-handler` * - use pattern `<mode><type?><cmd?>` */ decode(mode: NextMode, id: string, cmd: string): any; /** * translate to camel styled method name from mode + cmd * ex: GET /0/hi -> getHelloHi * ex: GET /0/say-me -> getHelloSayMe */ asFuncName(mode: string, type?: string, cmd?: string): string; /** * translate to camel styled function name like `doGetHello()` * * ex: GET / -> doList * ex: GET /0/hi -> doGetHi * ex: POST /0/say-me -> doPostSayMe */ asFuncNameByDo(mode: string, type?: string, cmd?: string): string; } /** * class: `GeneralWEBController` * - support additional helper functions for web-controller. */ export declare class GeneralWEBController extends GeneralController { /** * the base controller to bypass. */ readonly base: CoreWEBController; /** * default constructor() * * @param type type of this controller. * @param base the base controller to bypass. */ constructor(type: string, base?: CoreWEBController); /** * name of this resource. */ hello: () => string; /** * decode func from self to base. */ decode(mode: NextMode, id: string, cmd: string): any; /** * translate to `NextIdentityAccess` from origin NextContext * - use `api://lemon-accounts-api/oauth/0/pack-context` via protocol. * * @param context the requested NextContext */ asNextIdentityAccess: (context: NextContext) => Promise<NextIdentityAccess>; /** * notify self-service's event message via SNS * - config `env.EVENT_RELAY_SNS` as SNS endpoint. * * @returns message-id */ doNotifyServiceEvent: (context: NextContext, type: string, id: string, state: string, $param?: GeneralItem, endpoint?: string) => Promise<string>; }