@novu/framework
Version:
The Code-First Notifications Workflow SDK.
124 lines (114 loc) • 4.83 kB
text/typescript
import { I as INovuRequestHandlerOptions, N as NovuRequestHandler, S as ServeHandlerOptions, C as Client } from '../index-S0QKfWxm.cjs';
export { w as workflow } from '../index-S0QKfWxm.cjs';
import { E as Either, W as Workflow } from '../health-check.types-D_KcRiM_.cjs';
export { C as CronExpression, S as SeverityLevelEnum, p as providerSchemas } from '../health-check.types-D_KcRiM_.cjs';
import { Request, Response } from 'express';
import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.cjs';
import { VercelRequest, VercelResponse } from '@vercel/node';
import * as _nestjs_common from '@nestjs/common';
import { Provider, FactoryProvider } from '@nestjs/common';
import 'json-schema-to-ts';
import 'zod';
declare class NovuHandler {
handler(incomingRequest: Either<VercelRequest, Request>, response: Either<Response, VercelResponse>): ReturnType<INovuRequestHandlerOptions['handler']>;
}
declare const frameworkName: SupportedFrameworkName;
declare class NovuClient {
private options;
private novuHandler;
novuRequestHandler: NovuRequestHandler;
constructor(options: ServeHandlerOptions, novuHandler: NovuHandler);
handleRequest(req: Request, res: Response): Promise<void>;
}
type NovuModuleOptions = ServeHandlerOptions & {
apiPath: string;
controllerDecorators?: ClassDecorator[];
};
declare const NovuBaseModule: _nestjs_common.ConfigurableModuleCls<NovuModuleOptions, "register", "createNovuModuleOptions", (definition: NovuModuleOptions) => {
isGlobal: boolean;
client?: Client;
workflows: Array<Workflow>;
apiPath: string;
controllerDecorators?: ClassDecorator[];
}>;
declare const NOVU_OPTIONS: string | symbol;
declare const OPTIONS_TYPE: ServeHandlerOptions & {
apiPath: string;
controllerDecorators?: ClassDecorator[];
} & Partial<(definition: NovuModuleOptions) => {
isGlobal: boolean;
client?: Client;
workflows: Array<Workflow>;
apiPath: string;
controllerDecorators?: ClassDecorator[];
}>;
declare const ASYNC_OPTIONS_TYPE: _nestjs_common.ConfigurableModuleAsyncOptions<NovuModuleOptions, "createNovuModuleOptions"> & Partial<(definition: NovuModuleOptions) => {
isGlobal: boolean;
client?: Client;
workflows: Array<Workflow>;
apiPath: string;
controllerDecorators?: ClassDecorator[];
}>;
declare const REGISTER_API_PATH = "REGISTER_API_PATH";
declare class NovuController {
private novuService;
constructor(novuService: NovuClient);
handleGet(req: Request, res: Response): Promise<void>;
handlePost(req: Request, res: Response): Promise<void>;
handleOptions(req: Request, res: Response): Promise<void>;
}
/**
* In NestJS, serve and register any declared workflows with Novu, making
* them available to be triggered by events.
*
* @example
* ```ts
* import { NovuModule } from "@novu/framework/nest";
* import { myWorkflow } from "./src/novu/workflows"; // Your workflows
*
* @Module({
* imports: [
* // Expose the middleware on our recommended path at `/api/novu`.
* NovuModule.register({
* apiPath: '/api/novu',
* workflows: [myWorkflow]
* })
* ]
* })
* export class AppModule {}
*
* const app = await NestFactory.create(AppModule);
*
* // Important: ensure you add JSON middleware to process incoming JSON POST payloads.
* app.use(express.json());
* ```
*/
declare class NovuModule extends NovuBaseModule {
/**
* Register the Novu module
*
* @param options - The options to register the Novu module
* @param customProviders - Custom providers to register. These will be merged with the default providers.
* @returns The Novu module
*/
static register(options: typeof OPTIONS_TYPE, customProviders?: Provider[]): _nestjs_common.DynamicModule;
/**
* Register the Novu module asynchronously
*
* @param options - The options to register the Novu module
* @param customProviders - Custom providers to register. These will be merged with the default providers.
* @returns The Novu module
*/
static registerAsync(options: typeof ASYNC_OPTIONS_TYPE, customProviders?: Provider[]): _nestjs_common.DynamicModule;
}
/**
* Workaround to dynamically set the path for the controller.
*
* A custom provider is necessary to ensure that the controller path is set during
* application initialization, because NestJS does not support declaration of
* paths after the application has been initialized.
*
* @see https://github.com/nestjs/nest/issues/1438#issuecomment-863446608
*/
declare const registerApiPath: FactoryProvider;
export { Client, NOVU_OPTIONS, NovuClient, NovuController, NovuHandler, NovuModule, type NovuModuleOptions, NovuRequestHandler, REGISTER_API_PATH, ServeHandlerOptions, Workflow, frameworkName, registerApiPath };