@swell/cli
Version:
Swell's command line interface/utility
128 lines (127 loc) • 3.45 kB
TypeScript
/**
* Handle a function request.
* @param {Request} originalRequest from cloudflare
* @param {*} _env cloudflare environment vars
* @param {*} context cloudflare conttext
* @returns {Promise<SwellResponse>}
*/
declare function request(originalRequest: Request, _env: any, context: any): Promise<SwellResponse>;
/**
* Invokes one of the function types that are available.
*
* Type-1: Named export function handlers
* ```
* export function post (req) {
*
* }
* ```
*
* Important note:
* - `delete` func cannot be implemented in Type-1 since it's a reserved name. So, consider using Type-3.
*
* Type-2: Default export function handlers
* ```
* export default function (req) {
*
* }
* ```
*
* Type-3: Default object with named function handlers
* ```
* export default {
* delete(req) {
*
* },
* post(req) {
*
* },
* }
* ```
*
* @param {SwellRequest} req
* @param {Event} context
*/
declare function executeModuleHandler(req: SwellRequest, context: Event): Promise<any>;
/**
* Helper to determine if a value is an ordinary object.
* @param {any} obj
* @returns {boolean}
*/
declare function isOrdinaryObject(val: any): boolean;
declare const origialConsoleLog: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
/**
* Class representing a Swell request.
*/
declare class SwellRequest {
constructor(req: any, context: any);
originalRequest: any;
context: any;
appId: any;
storeId: any;
accessToken: any;
publicKey: any;
store: any;
session: any;
logParams: any;
apiHost: any;
id: any;
swell: SwellAPI;
body: {};
query: {};
data: {};
_logs: any[];
assignRequestProps(req: any): void;
initialize(): Promise<void>;
url: URL | undefined;
parseJson(input: any): any;
log(level: any, ...line: any[]): void;
getIngestableLogs(response: any): {
params: any;
} | undefined;
ingestLogs(response: any): Promise<void>;
/**
* Merge values into app data for the current request.
* @param {object|string} idOrValues string to indicate app ID, or values to merge
* @param {object|undefined} values values to merge into app data
* @returns {object|undefined} existing app data merged with values if passed
*/
appValues(idOrValues: object | string, values?: object | undefined): object | undefined;
}
/**
* Class representing the Swell backend API.
*/
declare class SwellAPI {
constructor(req: any, context: any);
request: any;
baseUrl: any;
basicAuth: string;
context: any;
toBase64(inputString: any): string;
stringifyQuery(queryObject: any, prefix: any): any;
makeRequest(method: any, url: any, data: any): Promise<any>;
get(url: any, query: any): Promise<any>;
put(url: any, data: any): Promise<any>;
post(url: any, data: any): Promise<any>;
delete(url: any, data: any): Promise<any>;
settings(id?: any): Promise<any>;
}
/**
* Class representing a Swell error.
*/
declare class SwellError extends Error {
constructor(message: any, options?: {});
status: any;
}
/**
* Class representing a Swell response.
*/
declare class SwellResponse extends Response {
static _respond(req: any, response: any, context: any): any;
static _respondWithLogs(response: any, req: any): SwellResponse;
constructor(data: any, options?: {});
_swellData: any;
_swellOptions: {};
}