@novu/framework 2.10.0 → 2.10.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{health-check.types-DwKatX-8.d.cts → health-check.types-Nhsa_lGZ.d.cts} +28 -9
- package/dist/cjs/index-naFCU9MB.d.cts +268 -0
- package/dist/cjs/index.cjs +148 -92
- package/dist/cjs/index.d.cts +4 -3
- package/dist/cjs/internal/index.cjs +1 -1
- package/dist/cjs/internal/index.d.cts +6 -4
- package/dist/cjs/jsx-dev-runtime.cjs +1 -0
- package/dist/cjs/jsx-dev-runtime.d.cts +1 -0
- package/dist/cjs/jsx-runtime.cjs +1 -0
- package/dist/cjs/jsx-runtime.d.cts +1 -0
- package/dist/cjs/servers/express.cjs +148 -92
- package/dist/cjs/servers/express.d.cts +5 -4
- package/dist/cjs/servers/h3.cjs +148 -92
- package/dist/cjs/servers/h3.d.cts +5 -4
- package/dist/cjs/servers/lambda.cjs +148 -92
- package/dist/cjs/servers/lambda.d.cts +6 -5
- package/dist/cjs/servers/nest.cjs +148 -92
- package/dist/cjs/servers/nest.d.cts +14 -10
- package/dist/cjs/servers/next.cjs +148 -92
- package/dist/cjs/servers/next.d.cts +5 -4
- package/dist/cjs/servers/nuxt.cjs +148 -92
- package/dist/cjs/servers/nuxt.d.cts +5 -4
- package/dist/cjs/servers/remix.cjs +148 -92
- package/dist/cjs/servers/remix.d.cts +5 -4
- package/dist/cjs/servers/sveltekit.cjs +148 -92
- package/dist/cjs/servers/sveltekit.d.cts +5 -4
- package/dist/cjs/step-resolver.cjs +4 -4
- package/dist/cjs/step-resolver.d.cts +85 -36
- package/dist/cjs/{subscriber.types-CftO3aFY.d.cts → subscriber.types-CNLicO8m.d.cts} +12 -1
- package/dist/cjs/validators.cjs +1 -1
- package/dist/esm/chunk-2GCKOQK4.js +0 -0
- package/dist/esm/chunk-2M25EATE.js +1 -0
- package/dist/esm/chunk-52LSX2V5.js +1 -0
- package/dist/esm/chunk-6GCCKYZC.js +1 -0
- package/dist/esm/{chunk-RCWIURDJ.js → chunk-CBLKARLC.js} +4 -4
- package/dist/esm/chunk-EWC7I6UD.js +1 -0
- package/dist/esm/chunk-T2VIX2ZH.js +22 -0
- package/dist/esm/{chunk-JKG63DBC.js → chunk-U3IL7QCI.js} +1 -1
- package/dist/esm/chunk-WUP5SBTV.js +130 -0
- package/dist/esm/{health-check.types-C4vZDz5x.d.ts → health-check.types-zMcfbkrA.d.ts} +28 -9
- package/dist/esm/index-cfmN-nqZ.d.ts +268 -0
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +6 -4
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/jsx-dev-runtime.d.ts +1 -0
- package/dist/esm/jsx-dev-runtime.js +1 -0
- package/dist/esm/jsx-runtime.d.ts +1 -0
- package/dist/esm/jsx-runtime.js +1 -0
- package/dist/esm/servers/express.d.ts +5 -4
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +5 -4
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/lambda.d.ts +6 -5
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +14 -10
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +5 -4
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +5 -4
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +5 -4
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +5 -4
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +85 -36
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-CfRj4acH.d.ts → subscriber.types-B0sKq6v3.d.ts} +12 -1
- package/dist/esm/validators.js +1 -1
- package/jsx-dev-runtime/package.json +3 -0
- package/jsx-runtime/package.json +3 -0
- package/package.json +26 -3
- package/dist/cjs/index-BTTxx1ad.d.cts +0 -141
- package/dist/esm/chunk-APAOD3BG.js +0 -1
- package/dist/esm/chunk-LPE4ME2M.js +0 -1
- package/dist/esm/chunk-MQSAHSED.js +0 -1
- package/dist/esm/chunk-PLPQUHX6.js +0 -1
- package/dist/esm/chunk-WSQ6EEHO.js +0 -95
- package/dist/esm/index-D4Rt1gOC.d.ts +0 -141
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as ContextPayload, c as ConditionalPartial, P as PickRequiredKeys, d as Step, e as Prettify, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, D as DeepPartial$1, f as ChannelStepEnum, A as ActionStepEnum, g as Awaitable, W as WithPassthrough, h as StepOptions } from './subscriber.types-CNLicO8m.cjs';
|
|
2
2
|
import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs';
|
|
3
3
|
|
|
4
4
|
type CodeResult = {
|
|
@@ -39,7 +39,8 @@ type ClientOptions = {
|
|
|
39
39
|
declare enum PostActionEnum {
|
|
40
40
|
TRIGGER = "trigger",
|
|
41
41
|
EXECUTE = "execute",
|
|
42
|
-
PREVIEW = "preview"
|
|
42
|
+
PREVIEW = "preview",
|
|
43
|
+
AGENT_EVENT = "agent-event"
|
|
43
44
|
}
|
|
44
45
|
declare enum GetActionEnum {
|
|
45
46
|
DISCOVER = "discover",
|
|
@@ -387,15 +388,22 @@ declare enum SeverityLevelEnum {
|
|
|
387
388
|
/**
|
|
388
389
|
* The parameters for the workflow function.
|
|
389
390
|
*/
|
|
390
|
-
type ExecuteInput<T_Payload extends Record<string, unknown>, T_Controls extends Record<string, unknown>> = {
|
|
391
|
+
type ExecuteInput<T_Payload extends Record<string, unknown>, T_Controls extends Record<string, unknown>, T_Env extends Record<string, unknown> = Record<string, unknown>> = {
|
|
391
392
|
/** Define a step in your workflow. */
|
|
392
393
|
step: Step;
|
|
393
394
|
/** The payload for the event, provided during trigger. */
|
|
394
395
|
payload: T_Payload;
|
|
395
396
|
/** The subscriber for the event, provided during trigger. */
|
|
396
397
|
subscriber: Prettify<Subscriber>;
|
|
397
|
-
/**
|
|
398
|
-
|
|
398
|
+
/**
|
|
399
|
+
* Environment variables defined in the Novu Dashboard, merged with built-in
|
|
400
|
+
* environment system variables (`name`, `type`).
|
|
401
|
+
*
|
|
402
|
+
* @example `env.name` — name of the current Novu environment
|
|
403
|
+
* @example `env.type` — type of the current Novu environment ("dev" | "prod")
|
|
404
|
+
* @example `env.MY_SECRET` — a user-defined environment variable
|
|
405
|
+
*/
|
|
406
|
+
env: T_Env & EnvironmentSystemVariables;
|
|
399
407
|
/** The controls for the event. Provided via the Dashboard. */
|
|
400
408
|
controls: T_Controls;
|
|
401
409
|
/** The resolved context for the event. */
|
|
@@ -404,7 +412,7 @@ type ExecuteInput<T_Payload extends Record<string, unknown>, T_Controls extends
|
|
|
404
412
|
/**
|
|
405
413
|
* The function to execute the workflow.
|
|
406
414
|
*/
|
|
407
|
-
type Execute<T_Payload extends Record<string, unknown>, T_Controls extends Record<string, unknown>> = (event: ExecuteInput<T_Payload, T_Controls>) => Promise<void>;
|
|
415
|
+
type Execute<T_Payload extends Record<string, unknown>, T_Controls extends Record<string, unknown>, T_Env extends Record<string, unknown> = Record<string, unknown>> = (event: ExecuteInput<T_Payload, T_Controls, T_Env>) => Promise<void>;
|
|
408
416
|
/**
|
|
409
417
|
* A preference for a notification delivery workflow.
|
|
410
418
|
*
|
|
@@ -461,11 +469,13 @@ type WorkflowPreferences = DeepPartial$1<{
|
|
|
461
469
|
/**
|
|
462
470
|
* The options for the workflow.
|
|
463
471
|
*/
|
|
464
|
-
type WorkflowOptions<T_PayloadSchema extends Schema, T_ControlSchema extends Schema> = {
|
|
472
|
+
type WorkflowOptions<T_PayloadSchema extends Schema, T_ControlSchema extends Schema, T_EnvSchema extends Schema = Schema> = {
|
|
465
473
|
/** The schema for the payload. */
|
|
466
474
|
payloadSchema?: T_PayloadSchema;
|
|
467
475
|
/** The schema for the controls. */
|
|
468
476
|
controlSchema?: T_ControlSchema;
|
|
477
|
+
/** The schema for the environment variables. */
|
|
478
|
+
envSchema?: T_EnvSchema;
|
|
469
479
|
/**
|
|
470
480
|
* The preferences for the notification workflow.
|
|
471
481
|
*
|
|
@@ -597,6 +607,10 @@ type DiscoverWorkflowOutput = {
|
|
|
597
607
|
schema: JsonSchema;
|
|
598
608
|
unknownSchema: Schema;
|
|
599
609
|
};
|
|
610
|
+
env: {
|
|
611
|
+
schema: JsonSchema;
|
|
612
|
+
unknownSchema: Schema;
|
|
613
|
+
};
|
|
600
614
|
preferences: WorkflowPreferencesPartial;
|
|
601
615
|
tags: string[];
|
|
602
616
|
name?: string;
|
|
@@ -629,8 +643,12 @@ type Workflow<T_Payload = never> = {
|
|
|
629
643
|
*/
|
|
630
644
|
discover: () => Promise<DiscoverWorkflowOutput>;
|
|
631
645
|
};
|
|
646
|
+
type DiscoverAgentOutput = {
|
|
647
|
+
agentId: string;
|
|
648
|
+
};
|
|
632
649
|
type DiscoverOutput = {
|
|
633
650
|
workflows: Array<DiscoverWorkflowOutput>;
|
|
651
|
+
agents: Array<DiscoverAgentOutput>;
|
|
634
652
|
};
|
|
635
653
|
|
|
636
654
|
type Event = {
|
|
@@ -642,7 +660,8 @@ type Event = {
|
|
|
642
660
|
action: Exclude<PostActionEnum, PostActionEnum.TRIGGER>;
|
|
643
661
|
subscriber: Subscriber;
|
|
644
662
|
context: ContextResolved;
|
|
645
|
-
env
|
|
663
|
+
/** User-defined env vars merged with environment system variables (name, type). */
|
|
664
|
+
env: EnvironmentSystemVariables & Record<string, string>;
|
|
646
665
|
};
|
|
647
666
|
type State = {
|
|
648
667
|
stepId: string;
|
|
@@ -680,4 +699,4 @@ type HealthCheck = {
|
|
|
680
699
|
};
|
|
681
700
|
};
|
|
682
701
|
|
|
683
|
-
export { type ClientOptions as C, type
|
|
702
|
+
export { type ClientOptions as C, type DiscoverAgentOutput as D, type ExecuteInput as E, GetActionEnum as G, type HealthCheck as H, 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 };
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { ChatElement } from 'chat';
|
|
2
|
+
import { C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-Nhsa_lGZ.cjs';
|
|
3
|
+
import { g as Awaitable } from './subscriber.types-CNLicO8m.cjs';
|
|
4
|
+
import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.cjs';
|
|
5
|
+
import './step-resolver.cjs';
|
|
6
|
+
|
|
7
|
+
interface AgentMessageAuthor {
|
|
8
|
+
userId: string;
|
|
9
|
+
fullName: string;
|
|
10
|
+
userName: string;
|
|
11
|
+
isBot: boolean | 'unknown';
|
|
12
|
+
}
|
|
13
|
+
interface AgentMessage {
|
|
14
|
+
text: string;
|
|
15
|
+
platformMessageId: string;
|
|
16
|
+
author: AgentMessageAuthor;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
}
|
|
19
|
+
interface AgentConversation {
|
|
20
|
+
identifier: string;
|
|
21
|
+
status: string;
|
|
22
|
+
metadata: Record<string, unknown>;
|
|
23
|
+
messageCount: number;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
lastActivityAt: string;
|
|
26
|
+
}
|
|
27
|
+
interface AgentSubscriber {
|
|
28
|
+
subscriberId: string;
|
|
29
|
+
firstName?: string;
|
|
30
|
+
lastName?: string;
|
|
31
|
+
email?: string;
|
|
32
|
+
phone?: string;
|
|
33
|
+
avatar?: string;
|
|
34
|
+
locale?: string;
|
|
35
|
+
data?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
interface AgentHistoryEntry {
|
|
38
|
+
role: string;
|
|
39
|
+
type: string;
|
|
40
|
+
content: string;
|
|
41
|
+
senderName?: string;
|
|
42
|
+
signalData?: {
|
|
43
|
+
type: string;
|
|
44
|
+
payload?: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
createdAt: string;
|
|
47
|
+
}
|
|
48
|
+
interface AgentPlatformContext {
|
|
49
|
+
threadId: string;
|
|
50
|
+
channelId: string;
|
|
51
|
+
isDM: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface FileRef {
|
|
54
|
+
filename: string;
|
|
55
|
+
mimeType?: string;
|
|
56
|
+
/** Base64-encoded file data (< 1 MB decoded) */
|
|
57
|
+
data?: string;
|
|
58
|
+
/** Publicly-accessible HTTPS URL */
|
|
59
|
+
url?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Content accepted by ctx.reply() and ctx.update().
|
|
63
|
+
*
|
|
64
|
+
* - `string` — plain text
|
|
65
|
+
* - `{ markdown, files? }` — markdown-formatted text, optionally with file attachments
|
|
66
|
+
* - `ChatElement` — interactive card built with Card(), Button(), etc.
|
|
67
|
+
* (must be a CardElement at runtime; validated by serializeContent)
|
|
68
|
+
*/
|
|
69
|
+
type MessageContent = string | {
|
|
70
|
+
markdown: string;
|
|
71
|
+
files?: FileRef[];
|
|
72
|
+
} | ChatElement;
|
|
73
|
+
interface AgentAction {
|
|
74
|
+
actionId: string;
|
|
75
|
+
value?: string;
|
|
76
|
+
}
|
|
77
|
+
interface AgentReaction {
|
|
78
|
+
messageId: string;
|
|
79
|
+
emoji: {
|
|
80
|
+
name: string;
|
|
81
|
+
};
|
|
82
|
+
added: boolean;
|
|
83
|
+
message: AgentMessage | null;
|
|
84
|
+
}
|
|
85
|
+
interface AgentContext {
|
|
86
|
+
readonly event: string;
|
|
87
|
+
readonly action: AgentAction | null;
|
|
88
|
+
readonly message: AgentMessage | null;
|
|
89
|
+
readonly reaction: AgentReaction | null;
|
|
90
|
+
readonly conversation: AgentConversation;
|
|
91
|
+
readonly subscriber: AgentSubscriber | null;
|
|
92
|
+
readonly history: AgentHistoryEntry[];
|
|
93
|
+
readonly platform: string;
|
|
94
|
+
readonly platformContext: AgentPlatformContext;
|
|
95
|
+
reply(content: MessageContent): Promise<void>;
|
|
96
|
+
update(content: MessageContent): Promise<void>;
|
|
97
|
+
resolve(summary?: string): void;
|
|
98
|
+
metadata: {
|
|
99
|
+
set(key: string, value: unknown): void;
|
|
100
|
+
};
|
|
101
|
+
trigger(workflowId: string, opts?: {
|
|
102
|
+
to?: string;
|
|
103
|
+
payload?: Record<string, unknown>;
|
|
104
|
+
}): void;
|
|
105
|
+
}
|
|
106
|
+
interface AgentHandlers {
|
|
107
|
+
onMessage: (ctx: AgentContext) => Promise<void>;
|
|
108
|
+
onReaction?: (ctx: AgentContext) => Promise<void>;
|
|
109
|
+
onAction?: (ctx: AgentContext) => Promise<void>;
|
|
110
|
+
onResolve?: (ctx: AgentContext) => Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
interface Agent {
|
|
113
|
+
id: string;
|
|
114
|
+
handlers: AgentHandlers;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Define a new conversational agent.
|
|
119
|
+
*
|
|
120
|
+
* @param agentId - Unique identifier matching the agent entity created in Novu (e.g. 'wine-bot')
|
|
121
|
+
* @param handlers - Handler functions for agent events
|
|
122
|
+
*/
|
|
123
|
+
declare function agent(agentId: string, handlers: AgentHandlers): Agent;
|
|
124
|
+
|
|
125
|
+
declare class Client {
|
|
126
|
+
private discoveredWorkflows;
|
|
127
|
+
private discoverWorkflowPromises;
|
|
128
|
+
private registeredAgents;
|
|
129
|
+
private templateEngine;
|
|
130
|
+
secretKey: string;
|
|
131
|
+
apiUrl: string;
|
|
132
|
+
version: string;
|
|
133
|
+
strictAuthentication: boolean;
|
|
134
|
+
verbose: boolean;
|
|
135
|
+
constructor(options?: ClientOptions);
|
|
136
|
+
private buildOptions;
|
|
137
|
+
private log;
|
|
138
|
+
/**
|
|
139
|
+
* Adds workflows to the client.
|
|
140
|
+
*
|
|
141
|
+
* A locking mechanism is used to ensure that duplicate workflows are not added.
|
|
142
|
+
*
|
|
143
|
+
* @param workflows - The workflows to add.
|
|
144
|
+
*/
|
|
145
|
+
addWorkflows(workflows: Array<Workflow>): Promise<void>;
|
|
146
|
+
addAgents(agents: Array<Agent>): void;
|
|
147
|
+
getAgent(agentId: string): Agent | undefined;
|
|
148
|
+
private addWorkflow;
|
|
149
|
+
healthCheck(): HealthCheck;
|
|
150
|
+
private getWorkflow;
|
|
151
|
+
private getStep;
|
|
152
|
+
private getRegisteredWorkflows;
|
|
153
|
+
discover(): DiscoverOutput;
|
|
154
|
+
/**
|
|
155
|
+
* Mocks data based on the given schema.
|
|
156
|
+
* The `default` value in the schema is used as the base data.
|
|
157
|
+
* If no `default` value is provided, the data is generated using JSONSchemaFaker.
|
|
158
|
+
*
|
|
159
|
+
* @param schema
|
|
160
|
+
* @returns mocked data
|
|
161
|
+
*/
|
|
162
|
+
private mock;
|
|
163
|
+
private validate;
|
|
164
|
+
private throwInvalidProvider;
|
|
165
|
+
private throwInvalidStep;
|
|
166
|
+
private throwInvalidEvent;
|
|
167
|
+
private executeStepFactory;
|
|
168
|
+
private shouldSanitize;
|
|
169
|
+
private shouldSkip;
|
|
170
|
+
executeWorkflow(event: Event): Promise<ExecuteOutput>;
|
|
171
|
+
private createExecutionPayload;
|
|
172
|
+
private prettyPrintExecute;
|
|
173
|
+
private executeProviders;
|
|
174
|
+
private previewProvider;
|
|
175
|
+
private executeProvider;
|
|
176
|
+
private executeStep;
|
|
177
|
+
private compileControls;
|
|
178
|
+
/**
|
|
179
|
+
* Preprocesses standalone translation patterns.
|
|
180
|
+
* Transforms {{t.key}} to [T:key] placeholder (not Liquid syntax, passes through unchanged).
|
|
181
|
+
*/
|
|
182
|
+
private preprocessTranslationPatterns;
|
|
183
|
+
/**
|
|
184
|
+
* Preprocesses translation keys used as filter arguments.
|
|
185
|
+
* Transforms 't.key' to '[T:key]' placeholder (not Liquid syntax, passes through unchanged).
|
|
186
|
+
* Example: pluralize: 't.apple', 't.apples' → pluralize: '[T:apple]', '[T:apples]'
|
|
187
|
+
*/
|
|
188
|
+
private preprocessFilterTranslationArgs;
|
|
189
|
+
/**
|
|
190
|
+
* Post-processes placeholders back to translation markers after Liquid render.
|
|
191
|
+
* Transforms [T:key] back to {{t.key}} for the translation service.
|
|
192
|
+
*/
|
|
193
|
+
private postprocessTranslationMarkers;
|
|
194
|
+
/**
|
|
195
|
+
* Create the controls for a step, taking both the event controls and the default controls into account
|
|
196
|
+
*
|
|
197
|
+
* @param step The step to create the controls for
|
|
198
|
+
* @param event The event that triggered the step
|
|
199
|
+
* @returns The controls for the step
|
|
200
|
+
*/
|
|
201
|
+
private createStepControls;
|
|
202
|
+
private previewStep;
|
|
203
|
+
private constructStepForPreview;
|
|
204
|
+
private extractMockDataForPreviousSteps;
|
|
205
|
+
private previewRequiredStep;
|
|
206
|
+
private getStepState;
|
|
207
|
+
private getStepCode;
|
|
208
|
+
private getWorkflowCode;
|
|
209
|
+
getCode(workflowId: string, stepId?: string): CodeResult;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface ServeHandlerOptions {
|
|
213
|
+
client?: Client;
|
|
214
|
+
workflows?: Array<Workflow>;
|
|
215
|
+
agents?: Array<Agent>;
|
|
216
|
+
}
|
|
217
|
+
type INovuRequestHandlerOptions<Input extends any[] = any[], Output = any> = ServeHandlerOptions & {
|
|
218
|
+
frameworkName: string;
|
|
219
|
+
client?: Client;
|
|
220
|
+
workflows?: Array<Workflow>;
|
|
221
|
+
agents?: Array<Agent>;
|
|
222
|
+
handler: Handler<Input, Output>;
|
|
223
|
+
};
|
|
224
|
+
type Handler<Input extends any[] = any[], Output = any> = (...args: Input) => HandlerResponse<Output>;
|
|
225
|
+
type HandlerResponse<Output = any> = {
|
|
226
|
+
body: () => Awaitable<any>;
|
|
227
|
+
headers: (key: string) => Awaitable<string | null | undefined>;
|
|
228
|
+
method: () => Awaitable<string>;
|
|
229
|
+
queryString?: (key: string, url: URL) => Awaitable<string | null | undefined>;
|
|
230
|
+
url: () => Awaitable<URL>;
|
|
231
|
+
transformResponse: (res: IActionResponse<string>) => Output;
|
|
232
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
233
|
+
};
|
|
234
|
+
type IActionResponse<TBody extends string = string> = {
|
|
235
|
+
status: number;
|
|
236
|
+
headers: Record<string, string>;
|
|
237
|
+
body: TBody;
|
|
238
|
+
};
|
|
239
|
+
declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
240
|
+
readonly frameworkName: string;
|
|
241
|
+
readonly handler: Handler<Input, Output>;
|
|
242
|
+
readonly client: Client;
|
|
243
|
+
private readonly hmacEnabled;
|
|
244
|
+
private readonly http;
|
|
245
|
+
private readonly workflows;
|
|
246
|
+
private readonly agents;
|
|
247
|
+
constructor(options: INovuRequestHandlerOptions<Input, Output>);
|
|
248
|
+
createHandler(): (...args: Input) => Promise<Output>;
|
|
249
|
+
private getStaticHeaders;
|
|
250
|
+
private createResponse;
|
|
251
|
+
private createError;
|
|
252
|
+
private handleAction;
|
|
253
|
+
private getPostActionMap;
|
|
254
|
+
triggerAction(triggerEvent: EventTriggerParams): () => Promise<IActionResponse<string>>;
|
|
255
|
+
private getGetActionMap;
|
|
256
|
+
private handlePostAction;
|
|
257
|
+
private handleGetAction;
|
|
258
|
+
private runAgentHandler;
|
|
259
|
+
private handleError;
|
|
260
|
+
private validateHmac;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Define a new notification workflow.
|
|
265
|
+
*/
|
|
266
|
+
declare function workflow<T_PayloadSchema extends Schema, T_ControlSchema extends Schema, T_EnvSchema extends Schema, T_PayloadValidated extends Record<string, unknown> = FromSchema<T_PayloadSchema>, T_PayloadUnvalidated extends Record<string, unknown> = FromSchemaUnvalidated<T_PayloadSchema>, T_Controls extends Record<string, unknown> = FromSchema<T_ControlSchema>, T_Env extends Record<string, unknown> = FromSchema<T_EnvSchema>>(workflowId: string, execute: Execute<T_PayloadValidated, T_Controls, T_Env>, workflowOptions?: WorkflowOptions<T_PayloadSchema, T_ControlSchema, T_EnvSchema>): Workflow<T_PayloadUnvalidated>;
|
|
267
|
+
|
|
268
|
+
export { type Agent as A, Client as C, type FileRef as F, type INovuRequestHandlerOptions as I, type MessageContent as M, NovuRequestHandler as N, type ServeHandlerOptions as S, type AgentContext as a, type AgentHandlers as b, type AgentReaction as c, agent as d, workflow as w };
|