import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-BanvmGul.cjs'; import { I as ITriggerPayload, G as TriggerRecipientsPayload, J as ISubscriberPayload, K as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-crcJBtCy.cjs'; import { C as ConditionalPartial, P as PickRequiredKeys, a as Prettify, D as DeepPartial, A as Awaitable } from './util.types-DaFfsxgy.cjs'; import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs'; declare enum PostActionEnum { TRIGGER = "trigger", EXECUTE = "execute", PREVIEW = "preview", AGENT_EVENT = "agent-event" } declare enum GetActionEnum { DISCOVER = "discover", HEALTH_CHECK = "health-check", CODE = "code" } /** * Cron expression helper. */ declare enum CronExpression { EVERY_SECOND = "* * * * * *", EVERY_5_SECONDS = "*/5 * * * * *", EVERY_10_SECONDS = "*/10 * * * * *", EVERY_30_SECONDS = "*/30 * * * * *", EVERY_MINUTE = "*/1 * * * *", EVERY_5_MINUTES = "0 */5 * * * *", EVERY_10_MINUTES = "0 */10 * * * *", EVERY_30_MINUTES = "0 */30 * * * *", EVERY_HOUR = "0 0-23/1 * * *", EVERY_2_HOURS = "0 0-23/2 * * *", EVERY_3_HOURS = "0 0-23/3 * * *", EVERY_4_HOURS = "0 0-23/4 * * *", EVERY_5_HOURS = "0 0-23/5 * * *", EVERY_6_HOURS = "0 0-23/6 * * *", EVERY_7_HOURS = "0 0-23/7 * * *", EVERY_8_HOURS = "0 0-23/8 * * *", EVERY_9_HOURS = "0 0-23/9 * * *", EVERY_10_HOURS = "0 0-23/10 * * *", EVERY_11_HOURS = "0 0-23/11 * * *", EVERY_12_HOURS = "0 0-23/12 * * *", EVERY_DAY_AT_1AM = "0 01 * * *", EVERY_DAY_AT_2AM = "0 02 * * *", EVERY_DAY_AT_3AM = "0 03 * * *", EVERY_DAY_AT_4AM = "0 04 * * *", EVERY_DAY_AT_5AM = "0 05 * * *", EVERY_DAY_AT_6AM = "0 06 * * *", EVERY_DAY_AT_7AM = "0 07 * * *", EVERY_DAY_AT_8AM = "0 08 * * *", EVERY_DAY_AT_9AM = "0 09 * * *", EVERY_DAY_AT_10AM = "0 10 * * *", EVERY_DAY_AT_11AM = "0 11 * * *", EVERY_DAY_AT_NOON = "0 12 * * *", EVERY_DAY_AT_1PM = "0 13 * * *", EVERY_DAY_AT_2PM = "0 14 * * *", EVERY_DAY_AT_3PM = "0 15 * * *", EVERY_DAY_AT_4PM = "0 16 * * *", EVERY_DAY_AT_5PM = "0 17 * * *", EVERY_DAY_AT_6PM = "0 18 * * *", EVERY_DAY_AT_7PM = "0 19 * * *", EVERY_DAY_AT_8PM = "0 20 * * *", EVERY_DAY_AT_9PM = "0 21 * * *", EVERY_DAY_AT_10PM = "0 22 * * *", EVERY_DAY_AT_11PM = "0 23 * * *", EVERY_DAY_AT_MIDNIGHT = "0 0 * * *", EVERY_WEEK = "0 0 * * 0", EVERY_WEEKDAY = "0 0 * * 1-5", EVERY_WEEKEND = "0 0 * * 6,0", EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT = "0 0 1 * *", EVERY_1ST_DAY_OF_MONTH_AT_NOON = "0 12 1 * *", EVERY_2ND_DAY_OF_MONTH_AT_10AM = "0 10 2 * *", EVERY_2ND_HOUR = "0 */2 * * *", EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM = "0 1-23/2 * * *", EVERY_2ND_MONTH = "0 0 1 */2 *", EVERY_QUARTER = "0 0 1 */3 *", EVERY_6_MONTHS = "0 0 1 */6 *", EVERY_YEAR = "0 0 1 0 *", EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM = "0 */30 9-17 * * *", EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM = "0 */30 9-18 * * *", EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM = "0 */30 10-19 * * *", MONDAY_TO_FRIDAY_AT_1AM = "0 0 01 * * 1-5", MONDAY_TO_FRIDAY_AT_2AM = "0 0 02 * * 1-5", MONDAY_TO_FRIDAY_AT_3AM = "0 0 03 * * 1-5", MONDAY_TO_FRIDAY_AT_4AM = "0 0 04 * * 1-5", MONDAY_TO_FRIDAY_AT_5AM = "0 0 05 * * 1-5", MONDAY_TO_FRIDAY_AT_6AM = "0 0 06 * * 1-5", MONDAY_TO_FRIDAY_AT_7AM = "0 0 07 * * 1-5", MONDAY_TO_FRIDAY_AT_8AM = "0 0 08 * * 1-5", MONDAY_TO_FRIDAY_AT_9AM = "0 0 09 * * 1-5", MONDAY_TO_FRIDAY_AT_09_30AM = "0 30 09 * * 1-5", MONDAY_TO_FRIDAY_AT_10AM = "0 0 10 * * 1-5", MONDAY_TO_FRIDAY_AT_11AM = "0 0 11 * * 1-5", MONDAY_TO_FRIDAY_AT_11_30AM = "0 30 11 * * 1-5", MONDAY_TO_FRIDAY_AT_12PM = "0 0 12 * * 1-5", MONDAY_TO_FRIDAY_AT_1PM = "0 0 13 * * 1-5", MONDAY_TO_FRIDAY_AT_2PM = "0 0 14 * * 1-5", MONDAY_TO_FRIDAY_AT_3PM = "0 0 15 * * 1-5", MONDAY_TO_FRIDAY_AT_4PM = "0 0 16 * * 1-5", MONDAY_TO_FRIDAY_AT_5PM = "0 0 17 * * 1-5", MONDAY_TO_FRIDAY_AT_6PM = "0 0 18 * * 1-5", MONDAY_TO_FRIDAY_AT_7PM = "0 0 19 * * 1-5", MONDAY_TO_FRIDAY_AT_8PM = "0 0 20 * * 1-5", MONDAY_TO_FRIDAY_AT_9PM = "0 0 21 * * 1-5", MONDAY_TO_FRIDAY_AT_10PM = "0 0 22 * * 1-5", MONDAY_TO_FRIDAY_AT_11PM = "0 0 23 * * 1-5" } /** * A developer-friendly variant of ChannelTypeEnum, utilizing camelCase instead of snake_case * to use consistent casing throughout the Framework. */ declare enum WorkflowChannelEnum { EMAIL = "email", SMS = "sms", PUSH = "push", CHAT = "chat", /** Differs from ChannelTypeEnum in capitalization / snake_case */ IN_APP = "inApp", TOOL = "tool" } type EventPayload = ITriggerPayload; type Actor = string | ISubscriberPayload; type Recipients = TriggerRecipientsPayload; type EventTriggerResult = { /** * Cancel the workflow execution */ cancel: () => Promise; /** * Response data for the trigger */ data: EventTriggerResponse; }; type EventTriggerParams = { /** * Workflow id */ workflowId: string; /** * Recipients to trigger the workflow to */ to: Recipients; /** * Actor to trigger the workflow from */ actor?: Actor; /** * Context to trigger the workflow with */ context?: ContextPayload; /** * Bridge url to trigger the workflow to */ bridgeUrl?: string; /** * Transaction id for trigger */ transactionId?: string; /** * Overrides for trigger */ overrides?: Record; /** * Override the workflow-assigned agent for this trigger using the public agent identifier. * Omit to use the workflow default; pass null to disable agent routing for this execution. */ agentId?: string | null; /** * Controls for the step execution */ controls?: { steps: { [stepId: string]: Record; }; }; /** * Use Novu Cloud US (https://api.novu.co) or EU deployment (https://eu.api.novu.co). Defaults to US. */ apiUrl?: string; /** * Override secret key for the trigger */ secretKey?: string; } & ConditionalPartial<{ /** * Payload to trigger the workflow with */ payload: T_Payload; }, PickRequiredKeys extends never ? true : false>; type EventTriggerResponse = { /** * If trigger was acknowledged or not */ acknowledged: boolean; /** * Status for trigger */ status: `${TriggerEventStatusEnum}`; /** * Any errors encountered during the trigger */ error?: string[]; /** * Unique transaction identifier for the event */ transactionId?: string; }; /** * Flag indicating if the event was cancelled or not. * `false` indicates the event was not cancelled because the execution was completed. * `true` indicates the in-flight execution was cancelled. */ type CancelEventTriggerResponse = boolean; /** * The severity level of a workflow. */ declare enum SeverityLevelEnum { NONE = "none", LOW = "low", MEDIUM = "medium", HIGH = "high" } /** * The parameters for the workflow function. */ type ExecuteInput, T_Controls extends Record, T_Env extends Record = Record> = { /** Define a step in your workflow. */ step: Step; /** The payload for the event, provided during trigger. */ payload: T_Payload; /** The subscriber for the event, provided during trigger. */ subscriber: Prettify; /** * Environment variables defined in the Novu Dashboard, merged with built-in * environment system variables (`name`, `type`). * * @example `env.name` — name of the current Novu environment * @example `env.type` — type of the current Novu environment ("dev" | "prod") * @example `env.MY_SECRET` — a user-defined environment variable */ env: T_Env & EnvironmentSystemVariables; /** The controls for the event. Provided via the Dashboard. */ controls: T_Controls; /** The resolved context for the event. */ context: ContextResolved; }; /** * The function to execute the workflow. */ type Execute, T_Controls extends Record, T_Env extends Record = Record> = (event: ExecuteInput) => Promise; /** * A preference for a notification delivery workflow. * * This provides a shortcut to setting all channels to the same preference. */ type WorkflowPreference = { /** * A flag specifying if notification delivery is enabled for the workflow. * * If `true`, notification delivery is enabled by default for all channels. * * This setting can be overridden by the channel preferences. * * @default true */ enabled: boolean; /** * A flag specifying if the preference is read-only. * * If `true`, the preference cannot be changed by the Subscriber. * * @default false */ readOnly: boolean; }; /** A preference for a notification delivery channel. */ type ChannelPreference = { /** * A flag specifying if notification delivery is enabled for the channel. * * If `true`, notification delivery is enabled. * * @default true */ enabled: boolean; }; /** * A partial set of workflow preferences. */ type WorkflowPreferences = DeepPartial<{ /** * A default preference for the channels. * * The values specified here will be used if no preference is specified for a channel. */ all: WorkflowPreference; /** * A preference for each notification delivery channel. * * If no preference is specified for a channel, the `all` preference will be used. */ channels: Record; }>; /** * The options for the workflow. */ type WorkflowOptions = { /** The schema for the payload. */ payloadSchema?: T_PayloadSchema; /** The schema for the controls. */ controlSchema?: T_ControlSchema; /** The schema for the environment variables. */ envSchema?: T_EnvSchema; /** * The preferences for the notification workflow. * * If no preference is specified for a channel, the `all` preference will be used. * * @example * ```ts * // Enable notification delivery for only the in-app channel by default. * { * all: { enabled: false }, * channels: { * inApp: { enabled: true }, * }, * } * ``` * * @example * ```ts * // Enable notification delivery for all channels by default. * { * all: { enabled: true } * } * ``` * * @example * ```ts * // Enable notification delivery for all channels by default, * // disallowing the Subscriber to change the preference. * { * all: { enabled: true, readOnly: true }, * } * ``` * * @example * ```ts * // Disable notification delivery for all channels by default, * // allowing the Subscriber to change the preference. * { * all: { enabled: false, readOnly: false }, * } * ``` * * @example * ```ts * // Disable notification delivery for only the in-app channel by default, * // allowing the Subscriber to change the preference. * { * all: { readOnly: false }, * channels: { * inApp: { enabled: false }, * }, * } * ``` */ preferences?: WorkflowPreferences; /** The tags for the workflow. */ tags?: string[]; /** * The name of the workflow. * * This is used to display a human-friendly name for the workflow in the Dashboard and `` component. * * If no value is specified, the `workflowId` will be used as the name. * * @example `Weekly Comment Digest` */ name?: string; /** * The description of the workflow. * * This is used to provide a brief overview of the workflow in the Dashboard. * * @example `This workflow sends a weekly digest of comments to users.` */ description?: string; /** * The severity of the workflow. * * This is used to determine the severity of the workflow. * * @example `high` */ severity?: SeverityLevelEnum; }; type StepType = `${ChannelStepEnum | ActionStepEnum}`; type DiscoverProviderOutput = { type: string; code: string; resolve: ({ controls, outputs, }: { controls: Record; outputs: Record; }) => Awaitable>>; outputs: { schema: JsonSchema; unknownSchema: Schema; }; }; type DiscoverStepOutput = { stepId: string; type: StepType; controls: { schema: JsonSchema; unknownSchema: Schema; }; outputs: { schema: JsonSchema; unknownSchema: Schema; }; results: { schema: JsonSchema; unknownSchema: Schema; }; code: string; resolve: (controls: Record) => Awaitable>; providers: Array; options: StepOptions; }; type DiscoverWorkflowOutput = { workflowId: string; execute: Execute, Record>; code: string; steps: Array; payload: { schema: JsonSchema; unknownSchema: Schema; }; controls: { schema: JsonSchema; unknownSchema: Schema; }; env: { schema: JsonSchema; unknownSchema: Schema; }; preferences: WorkflowPreferencesPartial; tags: string[]; name?: string; description?: string; severity: SeverityLevelEnum; }; /** * A workflow resource. * * @property `id` - The unique identifier for the workflow. * @property `trigger` - The function to trigger the workflow. * @property `discover` - The function to discover the workflow definition. */ type Workflow = { /** * The unique identifier for the workflow. */ id: string; /** * Trigger an event for this workflow with a strongly typed and validated `payload`, derived from the `payloadSchema`. * * @param event - The event to trigger * @returns `EventTriggerResult` - The result of the event trigger */ trigger: (event: Prettify, 'workflowId' | 'bridgeUrl' | 'controls'>>) => Promise; /** * Discover the workflow definition. * * @returns `DiscoverWorkflowOutput` - The workflow definition */ discover: () => Promise; }; type DiscoverAgentOutput = { agentId: string; }; type DiscoverOutput = { workflows: Array; agents: Array; }; type CodeResult = { code: string; }; /** * A minimal logger interface used for all of the framework's internal logging * (workflow discovery, execution and bridge error reporting). * * The methods (`info`/`warn`/`error`) are chosen so that both the global * `console` and common structured loggers (pino, winston, ...) satisfy this * interface directly, with no adapter. The global `console` is the default; * provide your own to route Novu's internal logs wherever the rest of your * application logs go. */ type Logger = { info: typeof console.info; warn: typeof console.warn; error: typeof console.error; }; type ClientOptions = { /** * Use Novu Cloud US (https://api.novu.co) or EU deployment (https://eu.api.novu.co). Defaults to US. */ apiUrl?: string; /** * Specify your Novu secret key, to secure the Bridge Endpoint, and Novu API communication. * Novu communicates securely with your endpoint using a signed HMAC header, * ensuring that only trusted requests from Novu are actioned by your Bridge API. * The secret key is used to sign the HMAC header. */ secretKey?: string; /** * Explicitly use HMAC signature verification. * Setting this to `false` will enable Novu to communicate with your Bridge API * without requiring a valid HMAC signature. * This is useful for local development and testing. * * In production you must specify an `secretKey` and set this to `true`. * * Defaults to true. */ strictAuthentication?: boolean; /** * Enable verbose logging for workflow discovery and execution. * When set to `false`, discovery and execution logs will be suppressed. * Defaults to `true` in development, `false` in production. */ verbose?: boolean; /** * A custom logger used for all of the framework's internal logging * (workflow discovery, execution and bridge error reporting). * * Defaults to the global `console`. Provide your own logger to route Novu's * internal logs through your application's structured logger. * * Note: `verbose` still controls *whether* discovery and execution logs are * emitted; `logger` only controls *where* all logs are written. Bridge errors * (HTTP status >= 500) are always logged via this logger, regardless of * `verbose`. */ logger?: Logger; }; type Event = { payload: Record; workflowId: string; stepId: string; controls: Record; state: State[]; action: Exclude; subscriber: Subscriber; actor?: Subscriber; context: ContextResolved; /** User-defined env vars merged with environment system variables (name, type). */ env: EnvironmentSystemVariables & Record; }; type State = { stepId: string; outputs: Record; state: { status: string; error?: string; }; }; type ExecuteOutputMetadata = { status: string; error: boolean; /** * The duration of the step execution in milliseconds */ duration: number; }; type ExecuteOutputOptions = { skip: boolean; }; type ExecuteOutput = { outputs: Record; providers?: Record>>; options: ExecuteOutputOptions; metadata: ExecuteOutputMetadata; }; type HealthCheck = { status: 'ok' | 'error'; sdkVersion: string; frameworkVersion: string; discovered: { workflows: number; steps: number; }; }; export { type ClientOptions as C, type DiscoverAgentOutput as D, type ExecuteInput as E, GetActionEnum as G, type HealthCheck as H, type Logger as L, PostActionEnum as P, SeverityLevelEnum as S, type Workflow as W, CronExpression as a, type CancelEventTriggerResponse as b, type ChannelPreference as c, type CodeResult as d, type DiscoverOutput as e, type DiscoverProviderOutput as f, type DiscoverStepOutput as g, type DiscoverWorkflowOutput as h, type Event as i, type EventTriggerParams as j, type EventTriggerResponse as k, type EventTriggerResult as l, type Execute as m, type ExecuteOutput as n, type ExecuteOutputMetadata as o, type ExecuteOutputOptions as p, type State as q, type StepType as r, WorkflowChannelEnum as s, type WorkflowOptions as t, type WorkflowPreference as u, type WorkflowPreferences as v };