@foxpage/foxpage-node-sdk
Version:
foxpage node sdk
96 lines (95 loc) • 3.52 kB
TypeScript
import { Application, Block, ContentDetail, Context, ContextPage, FoxpageDelegatedRequest, FoxpageRequestOptions, Page, ParsedDSL, RelationInfo, Relations, StructureNode, TicketCheckData } from '@foxpage/foxpage-types';
/**
* get user request application task
* @param pathname user request pathname
* @returns Application | null |undefined
*/
export declare const appTask: (pathname: string) => {
app: Application;
matchedRoute?: import("@foxpage/foxpage-types").FoxRoute | undefined;
} | undefined;
/**
* init render context
* @param app application
* @param opt contain ctx dependency data
* @returns Context
*/
export declare const contextTask: (app: Application, opt: FoxpageRequestOptions) => Promise<Context>;
/**
* access control task
* @param app application
* @param request request
*/
export declare const accessControlTask: (app: Application, ctx: FoxpageDelegatedRequest | Context, opt?: TicketCheckData) => Promise<boolean>;
/**
* router task: get the matched content
* @param url user request url
* @param app current application
* @returns Promise<FPRouter | undefined>
*/
export declare const routerTask: (app: Application, ctx: Context) => Promise<import("@foxpage/foxpage-types").Content | import("@foxpage/foxpage-types").Route | {
id: string;
} | null>;
/**
* init relation task for create content instance by relation
* @param relations relations
* @param ctx context
*/
export declare const initRelationsTask: (relations: Relations | RelationInfo, ctx: Context) => import("@foxpage/foxpage-shared").contentInitData;
/**
* file task
* get file & set to context
* @param fileId
* @param app
* @param ctx
*/
export declare const fileTask: (fileId: string, app: Application, ctx: Context) => Promise<void>;
/**
* get page task
* @param pageId pageId
* @param app current application
* @returns Promise<Application|null|undefined>
*/
export declare const pageTask: (pageId: string, app: Application, ctx: Context) => Promise<Page | null>;
export declare const fetchDSLTask: (pageId: string, app: Application, ctx: Context) => Promise<Page | null>;
export declare const blockTask: (blockId: string, app: Application, ctx: Context) => Promise<Block | null>;
export declare const fetchBlockTask: (blockId: string, app: Application, ctx: Context) => Promise<Block | null>;
/**
* content merge task
* only support page content
* @param content base content
* @param app application
* @param ctx Context
* @returns merged content
*/
export declare const mergeTask: (content: ContentDetail<StructureNode> | null, app: Application, ctx: Context) => Promise<ContentDetail<StructureNode<Record<string, any>>> | null>;
/**
* mock task
* @param content content
* @param app application
* @param ctx context
* @returns new content with mock
*/
export declare const mockTask: (content: ContentDetail | null, app: Application, ctx: Context) => Promise<ContextPage | undefined>;
/**
* parse content task
* @param content content
* @param ctx Context
* @returns ParsedDSL
*/
export declare const parseTask: <T extends ContextPage>(content: T, ctx: Context) => Promise<{
messages: string[] | undefined;
content: T;
ctx: Context;
} | {
messages: import("@foxpage/foxpage-shared").Messages[];
content: T;
ctx: Context;
}>;
/**
* render task
* @param parsed parsed content schemas
* @param ctx render context
* @returns html string
*/
export declare const renderTask: (parsed: ParsedDSL, ctx: Context) => Promise<string | undefined>;