@novu/framework 2.10.1-alpha.2 → 2.10.1-alpha.3
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-Nhsa_lGZ.d.cts → health-check.types-S8oS3AQZ.d.cts} +138 -138
- package/dist/cjs/{index-gi0_Wcu3.d.cts → index-C5CigDlK.d.cts} +88 -13
- package/dist/cjs/index.cjs +58 -58
- package/dist/cjs/index.d.cts +3 -3
- package/dist/cjs/internal/index.d.cts +3 -3
- package/dist/cjs/servers/express.cjs +58 -58
- package/dist/cjs/servers/express.d.cts +4 -4
- package/dist/cjs/servers/h3.cjs +58 -58
- package/dist/cjs/servers/h3.d.cts +4 -4
- package/dist/cjs/servers/lambda.cjs +58 -58
- package/dist/cjs/servers/lambda.d.cts +5 -5
- package/dist/cjs/servers/nest.cjs +58 -58
- package/dist/cjs/servers/nest.d.cts +6 -6
- package/dist/cjs/servers/next.cjs +58 -58
- package/dist/cjs/servers/next.d.cts +4 -4
- package/dist/cjs/servers/nuxt.cjs +58 -58
- package/dist/cjs/servers/nuxt.d.cts +4 -4
- package/dist/cjs/servers/remix.cjs +58 -58
- package/dist/cjs/servers/remix.d.cts +4 -4
- package/dist/cjs/servers/sveltekit.cjs +58 -58
- package/dist/cjs/servers/sveltekit.d.cts +4 -4
- package/dist/cjs/step-resolver.d.cts +2 -2
- package/dist/esm/{chunk-FURRAVE4.js → chunk-CBVFNQC3.js} +56 -56
- package/dist/esm/{health-check.types-zMcfbkrA.d.ts → health-check.types-C5lg4csi.d.ts} +138 -138
- package/dist/esm/{index-DBjXwxNK.d.ts → index-DCSlowxV.d.ts} +88 -13
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +3 -3
- package/dist/esm/servers/express.d.ts +4 -4
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +4 -4
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/lambda.d.ts +5 -5
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +6 -6
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +4 -4
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +4 -4
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +4 -4
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +4 -4
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +2 -2
- package/package.json +2 -2
- package/dist/cjs/{subscriber.types-CNLicO8m.d.cts → subscriber.types-DgRgSKMw.d.cts} +77 -77
- package/dist/esm/{subscriber.types-B0sKq6v3.d.ts → subscriber.types-CbMgjzR-.d.ts} +77 -77
|
@@ -1,6 +1,142 @@
|
|
|
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-
|
|
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-DgRgSKMw.cjs';
|
|
2
2
|
import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs';
|
|
3
3
|
|
|
4
|
+
declare enum ChannelTypeEnum {
|
|
5
|
+
IN_APP = "in_app",
|
|
6
|
+
EMAIL = "email",
|
|
7
|
+
SMS = "sms",
|
|
8
|
+
CHAT = "chat",
|
|
9
|
+
PUSH = "push"
|
|
10
|
+
}
|
|
11
|
+
interface IAttachmentOptions {
|
|
12
|
+
mime: string;
|
|
13
|
+
file: Buffer;
|
|
14
|
+
name?: string;
|
|
15
|
+
channels?: ChannelTypeEnum[];
|
|
16
|
+
cid?: string;
|
|
17
|
+
disposition?: string;
|
|
18
|
+
}
|
|
19
|
+
interface ITriggerPayload {
|
|
20
|
+
attachments?: IAttachmentOptions[];
|
|
21
|
+
[key: string]: string | string[] | boolean | number | undefined | IAttachmentOptions | IAttachmentOptions[] | Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
interface ISubscriberPayload {
|
|
24
|
+
subscriberId: string;
|
|
25
|
+
firstName?: string;
|
|
26
|
+
lastName?: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
phone?: string;
|
|
29
|
+
avatar?: string;
|
|
30
|
+
locale?: string;
|
|
31
|
+
data?: Record<string, unknown>;
|
|
32
|
+
channels?: ISubscriberChannel[];
|
|
33
|
+
}
|
|
34
|
+
interface ISubscriberChannel {
|
|
35
|
+
providerId: ChatProviderIdEnum | PushProviderIdEnum;
|
|
36
|
+
integrationIdentifier?: string;
|
|
37
|
+
credentials: IChannelCredentials;
|
|
38
|
+
}
|
|
39
|
+
interface IChannelCredentials {
|
|
40
|
+
webhookUrl?: string;
|
|
41
|
+
deviceTokens?: string[];
|
|
42
|
+
}
|
|
43
|
+
interface ITopic {
|
|
44
|
+
type: 'Topic';
|
|
45
|
+
topicKey: string;
|
|
46
|
+
exclude?: string[];
|
|
47
|
+
}
|
|
48
|
+
type TriggerRecipientsPayload = string | ISubscriberPayload | ITopic | ISubscriberPayload[] | ITopic[];
|
|
49
|
+
declare enum TriggerEventStatusEnum {
|
|
50
|
+
ERROR = "error",
|
|
51
|
+
NOT_ACTIVE = "trigger_not_active",
|
|
52
|
+
NO_WORKFLOW_ACTIVE_STEPS = "no_workflow_active_steps_defined",
|
|
53
|
+
NO_WORKFLOW_STEPS = "no_workflow_steps_defined",
|
|
54
|
+
PROCESSED = "processed",
|
|
55
|
+
SUBSCRIBER_MISSING = "subscriber_id_missing",
|
|
56
|
+
TENANT_MISSING = "no_tenant_found"
|
|
57
|
+
}
|
|
58
|
+
declare enum ChatProviderIdEnum {
|
|
59
|
+
Slack = "slack",
|
|
60
|
+
Discord = "discord",
|
|
61
|
+
MsTeams = "msteams",
|
|
62
|
+
Mattermost = "mattermost",
|
|
63
|
+
Ryver = "ryver",
|
|
64
|
+
Zulip = "zulip",
|
|
65
|
+
GrafanaOnCall = "grafana-on-call",
|
|
66
|
+
GetStream = "getstream",
|
|
67
|
+
RocketChat = "rocket-chat",
|
|
68
|
+
WhatsAppBusiness = "whatsapp-business",
|
|
69
|
+
ChatWebhook = "chat-webhook"
|
|
70
|
+
}
|
|
71
|
+
declare enum PushProviderIdEnum {
|
|
72
|
+
FCM = "fcm",
|
|
73
|
+
APNS = "apns",
|
|
74
|
+
EXPO = "expo",
|
|
75
|
+
OneSignal = "one-signal",
|
|
76
|
+
Pushpad = "pushpad",
|
|
77
|
+
PushWebhook = "push-webhook",
|
|
78
|
+
PusherBeams = "pusher-beams",
|
|
79
|
+
AppIO = "appio"
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A preference for a notification delivery workflow.
|
|
83
|
+
*
|
|
84
|
+
* This provides a shortcut to setting all channels to the same preference.
|
|
85
|
+
*/
|
|
86
|
+
type WorkflowPreference$1 = {
|
|
87
|
+
/**
|
|
88
|
+
* A flag specifying if notification delivery is enabled for the workflow.
|
|
89
|
+
*
|
|
90
|
+
* If `true`, notification delivery is enabled by default for all channels.
|
|
91
|
+
*
|
|
92
|
+
* This setting can be overridden by the channel preferences.
|
|
93
|
+
*
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* A flag specifying if the preference is read-only.
|
|
99
|
+
*
|
|
100
|
+
* If `true`, the preference cannot be changed by the Subscriber.
|
|
101
|
+
*
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
readOnly: boolean;
|
|
105
|
+
};
|
|
106
|
+
/** A preference for a notification delivery channel. */
|
|
107
|
+
type ChannelPreference$1 = {
|
|
108
|
+
/**
|
|
109
|
+
* A flag specifying if notification delivery is enabled for the channel.
|
|
110
|
+
*
|
|
111
|
+
* If `true`, notification delivery is enabled.
|
|
112
|
+
*
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
};
|
|
117
|
+
type WorkflowPreferences$1 = {
|
|
118
|
+
/**
|
|
119
|
+
* A preference for the workflow.
|
|
120
|
+
*
|
|
121
|
+
* The values specified here will be used if no preference is specified for a channel.
|
|
122
|
+
*/
|
|
123
|
+
all: WorkflowPreference$1;
|
|
124
|
+
/**
|
|
125
|
+
* A preference for each notification delivery channel.
|
|
126
|
+
*
|
|
127
|
+
* If no preference is specified for a channel, the `all` preference will be used.
|
|
128
|
+
*/
|
|
129
|
+
channels: Record<ChannelTypeEnum, ChannelPreference$1>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Recursively make all properties of type `T` optional.
|
|
133
|
+
*/
|
|
134
|
+
type DeepPartial<T> = T extends object ? {
|
|
135
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
136
|
+
} : T;
|
|
137
|
+
/** A partial set of workflow preferences. */
|
|
138
|
+
type WorkflowPreferencesPartial = DeepPartial<WorkflowPreferences$1>;
|
|
139
|
+
|
|
4
140
|
type CodeResult = {
|
|
5
141
|
code: string;
|
|
6
142
|
};
|
|
@@ -151,142 +287,6 @@ declare enum WorkflowChannelEnum {
|
|
|
151
287
|
IN_APP = "inApp"
|
|
152
288
|
}
|
|
153
289
|
|
|
154
|
-
declare enum ChannelTypeEnum {
|
|
155
|
-
IN_APP = "in_app",
|
|
156
|
-
EMAIL = "email",
|
|
157
|
-
SMS = "sms",
|
|
158
|
-
CHAT = "chat",
|
|
159
|
-
PUSH = "push"
|
|
160
|
-
}
|
|
161
|
-
interface IAttachmentOptions {
|
|
162
|
-
mime: string;
|
|
163
|
-
file: Buffer;
|
|
164
|
-
name?: string;
|
|
165
|
-
channels?: ChannelTypeEnum[];
|
|
166
|
-
cid?: string;
|
|
167
|
-
disposition?: string;
|
|
168
|
-
}
|
|
169
|
-
interface ITriggerPayload {
|
|
170
|
-
attachments?: IAttachmentOptions[];
|
|
171
|
-
[key: string]: string | string[] | boolean | number | undefined | IAttachmentOptions | IAttachmentOptions[] | Record<string, unknown>;
|
|
172
|
-
}
|
|
173
|
-
interface ISubscriberPayload {
|
|
174
|
-
subscriberId: string;
|
|
175
|
-
firstName?: string;
|
|
176
|
-
lastName?: string;
|
|
177
|
-
email?: string;
|
|
178
|
-
phone?: string;
|
|
179
|
-
avatar?: string;
|
|
180
|
-
locale?: string;
|
|
181
|
-
data?: Record<string, unknown>;
|
|
182
|
-
channels?: ISubscriberChannel[];
|
|
183
|
-
}
|
|
184
|
-
interface ISubscriberChannel {
|
|
185
|
-
providerId: ChatProviderIdEnum | PushProviderIdEnum;
|
|
186
|
-
integrationIdentifier?: string;
|
|
187
|
-
credentials: IChannelCredentials;
|
|
188
|
-
}
|
|
189
|
-
interface IChannelCredentials {
|
|
190
|
-
webhookUrl?: string;
|
|
191
|
-
deviceTokens?: string[];
|
|
192
|
-
}
|
|
193
|
-
interface ITopic {
|
|
194
|
-
type: 'Topic';
|
|
195
|
-
topicKey: string;
|
|
196
|
-
exclude?: string[];
|
|
197
|
-
}
|
|
198
|
-
type TriggerRecipientsPayload = string | ISubscriberPayload | ITopic | ISubscriberPayload[] | ITopic[];
|
|
199
|
-
declare enum TriggerEventStatusEnum {
|
|
200
|
-
ERROR = "error",
|
|
201
|
-
NOT_ACTIVE = "trigger_not_active",
|
|
202
|
-
NO_WORKFLOW_ACTIVE_STEPS = "no_workflow_active_steps_defined",
|
|
203
|
-
NO_WORKFLOW_STEPS = "no_workflow_steps_defined",
|
|
204
|
-
PROCESSED = "processed",
|
|
205
|
-
SUBSCRIBER_MISSING = "subscriber_id_missing",
|
|
206
|
-
TENANT_MISSING = "no_tenant_found"
|
|
207
|
-
}
|
|
208
|
-
declare enum ChatProviderIdEnum {
|
|
209
|
-
Slack = "slack",
|
|
210
|
-
Discord = "discord",
|
|
211
|
-
MsTeams = "msteams",
|
|
212
|
-
Mattermost = "mattermost",
|
|
213
|
-
Ryver = "ryver",
|
|
214
|
-
Zulip = "zulip",
|
|
215
|
-
GrafanaOnCall = "grafana-on-call",
|
|
216
|
-
GetStream = "getstream",
|
|
217
|
-
RocketChat = "rocket-chat",
|
|
218
|
-
WhatsAppBusiness = "whatsapp-business",
|
|
219
|
-
ChatWebhook = "chat-webhook"
|
|
220
|
-
}
|
|
221
|
-
declare enum PushProviderIdEnum {
|
|
222
|
-
FCM = "fcm",
|
|
223
|
-
APNS = "apns",
|
|
224
|
-
EXPO = "expo",
|
|
225
|
-
OneSignal = "one-signal",
|
|
226
|
-
Pushpad = "pushpad",
|
|
227
|
-
PushWebhook = "push-webhook",
|
|
228
|
-
PusherBeams = "pusher-beams",
|
|
229
|
-
AppIO = "appio"
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* A preference for a notification delivery workflow.
|
|
233
|
-
*
|
|
234
|
-
* This provides a shortcut to setting all channels to the same preference.
|
|
235
|
-
*/
|
|
236
|
-
type WorkflowPreference$1 = {
|
|
237
|
-
/**
|
|
238
|
-
* A flag specifying if notification delivery is enabled for the workflow.
|
|
239
|
-
*
|
|
240
|
-
* If `true`, notification delivery is enabled by default for all channels.
|
|
241
|
-
*
|
|
242
|
-
* This setting can be overridden by the channel preferences.
|
|
243
|
-
*
|
|
244
|
-
* @default true
|
|
245
|
-
*/
|
|
246
|
-
enabled: boolean;
|
|
247
|
-
/**
|
|
248
|
-
* A flag specifying if the preference is read-only.
|
|
249
|
-
*
|
|
250
|
-
* If `true`, the preference cannot be changed by the Subscriber.
|
|
251
|
-
*
|
|
252
|
-
* @default false
|
|
253
|
-
*/
|
|
254
|
-
readOnly: boolean;
|
|
255
|
-
};
|
|
256
|
-
/** A preference for a notification delivery channel. */
|
|
257
|
-
type ChannelPreference$1 = {
|
|
258
|
-
/**
|
|
259
|
-
* A flag specifying if notification delivery is enabled for the channel.
|
|
260
|
-
*
|
|
261
|
-
* If `true`, notification delivery is enabled.
|
|
262
|
-
*
|
|
263
|
-
* @default true
|
|
264
|
-
*/
|
|
265
|
-
enabled: boolean;
|
|
266
|
-
};
|
|
267
|
-
type WorkflowPreferences$1 = {
|
|
268
|
-
/**
|
|
269
|
-
* A preference for the workflow.
|
|
270
|
-
*
|
|
271
|
-
* The values specified here will be used if no preference is specified for a channel.
|
|
272
|
-
*/
|
|
273
|
-
all: WorkflowPreference$1;
|
|
274
|
-
/**
|
|
275
|
-
* A preference for each notification delivery channel.
|
|
276
|
-
*
|
|
277
|
-
* If no preference is specified for a channel, the `all` preference will be used.
|
|
278
|
-
*/
|
|
279
|
-
channels: Record<ChannelTypeEnum, ChannelPreference$1>;
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Recursively make all properties of type `T` optional.
|
|
283
|
-
*/
|
|
284
|
-
type DeepPartial<T> = T extends object ? {
|
|
285
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
286
|
-
} : T;
|
|
287
|
-
/** A partial set of workflow preferences. */
|
|
288
|
-
type WorkflowPreferencesPartial = DeepPartial<WorkflowPreferences$1>;
|
|
289
|
-
|
|
290
290
|
type EventPayload = ITriggerPayload;
|
|
291
291
|
type Actor = string | ISubscriberPayload;
|
|
292
292
|
type Recipients = TriggerRecipientsPayload;
|
|
@@ -699,4 +699,4 @@ type HealthCheck = {
|
|
|
699
699
|
};
|
|
700
700
|
};
|
|
701
701
|
|
|
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 };
|
|
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 TriggerRecipientsPayload as T, 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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ChatElement, CardElement } 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-
|
|
3
|
-
import { g as Awaitable } from './subscriber.types-
|
|
1
|
+
import { ChatElement, Emoji, CardElement } from 'chat';
|
|
2
|
+
import { T as TriggerRecipientsPayload, 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-S8oS3AQZ.cjs';
|
|
3
|
+
import { g as Awaitable } from './subscriber.types-DgRgSKMw.cjs';
|
|
4
4
|
import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.cjs';
|
|
5
5
|
import './step-resolver.cjs';
|
|
6
6
|
|
|
@@ -76,8 +76,8 @@ interface FileRef {
|
|
|
76
76
|
/**
|
|
77
77
|
* Content accepted by ctx.reply() and handle.edit().
|
|
78
78
|
*
|
|
79
|
-
* - `string` — plain text
|
|
80
|
-
* - `{ markdown, files? }` — markdown
|
|
79
|
+
* - `string` — plain text or markdown; converted to platform format by the chat SDK
|
|
80
|
+
* - `{ markdown, files? }` — markdown with optional file attachments
|
|
81
81
|
* - `ChatElement` — interactive card built with Card(), Button(), etc.
|
|
82
82
|
* (must be a CardElement at runtime; validated by serializeContent)
|
|
83
83
|
*/
|
|
@@ -87,7 +87,6 @@ type MessageContent = string | {
|
|
|
87
87
|
} | ChatElement;
|
|
88
88
|
/** Normalized content shape sent over HTTP to the reply endpoint. */
|
|
89
89
|
interface ReplyContent {
|
|
90
|
-
text?: string;
|
|
91
90
|
markdown?: string;
|
|
92
91
|
card?: CardElement;
|
|
93
92
|
files?: FileRef[];
|
|
@@ -141,16 +140,49 @@ interface AgentContext {
|
|
|
141
140
|
metadata: {
|
|
142
141
|
set(key: string, value: unknown): void;
|
|
143
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* Trigger a Novu workflow from within this agent handler.
|
|
145
|
+
*
|
|
146
|
+
* Signals are batched and flushed with the next `ctx.reply()`, or automatically when the
|
|
147
|
+
* handler completes. The workflow executes asynchronously — the agent reply is not blocked.
|
|
148
|
+
*
|
|
149
|
+
* @param workflowId - Workflow identifier (e.g. `'escalation-email'`).
|
|
150
|
+
* @param opts.to - Recipient(s). Omit to target the conversation's resolved subscriber.
|
|
151
|
+
* @param opts.payload - Data forwarded to the workflow payload schema.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* // Target the conversation subscriber automatically
|
|
155
|
+
* ctx.trigger('follow-up-email', { payload: { reason: 'unresolved' } });
|
|
156
|
+
*
|
|
157
|
+
* // Explicit recipient
|
|
158
|
+
* ctx.trigger('escalation-email', { to: 'agent-inbox', payload: { priority: 'high' } });
|
|
159
|
+
*
|
|
160
|
+
* // Topic broadcast
|
|
161
|
+
* ctx.trigger('team-alert', { to: { type: 'Topic', topicKey: 'support-team' } });
|
|
162
|
+
*/
|
|
144
163
|
trigger(workflowId: string, opts?: {
|
|
145
|
-
to?:
|
|
164
|
+
to?: TriggerRecipientsPayload;
|
|
146
165
|
payload?: Record<string, unknown>;
|
|
147
166
|
}): void;
|
|
167
|
+
/**
|
|
168
|
+
* Add an emoji reaction to any platform message.
|
|
169
|
+
* Reactions are queued and sent with the next `ctx.reply()`, or flushed automatically
|
|
170
|
+
* when the handler completes (same batching contract as `ctx.trigger()`).
|
|
171
|
+
*
|
|
172
|
+
* @param messageId - Platform-native message ID to react to (e.g. Slack `ts`).
|
|
173
|
+
* @param emojiName - Emoji short-name (e.g. `'thumbs_up'`, `'check_mark'`).
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ctx.addReaction(ctx.reaction!.messageId, 'check_mark');
|
|
177
|
+
* await ctx.reply('Done!');
|
|
178
|
+
*/
|
|
179
|
+
addReaction(messageId: string, emojiName: Emoji): void;
|
|
148
180
|
}
|
|
149
181
|
interface AgentHandlers {
|
|
150
|
-
onMessage: (ctx: AgentContext) =>
|
|
151
|
-
onReaction?: (ctx: AgentContext) =>
|
|
152
|
-
onAction?: (ctx: AgentContext) =>
|
|
153
|
-
onResolve?: (ctx: AgentContext) =>
|
|
182
|
+
onMessage: (ctx: AgentContext) => Awaitable<MessageContent | void>;
|
|
183
|
+
onReaction?: (ctx: AgentContext) => Awaitable<MessageContent | void>;
|
|
184
|
+
onAction?: (ctx: AgentContext) => Awaitable<MessageContent | void>;
|
|
185
|
+
onResolve?: (ctx: AgentContext) => Awaitable<MessageContent | void>;
|
|
154
186
|
}
|
|
155
187
|
interface Agent {
|
|
156
188
|
id: string;
|
|
@@ -179,10 +211,19 @@ type MetadataSignal = {
|
|
|
179
211
|
key: string;
|
|
180
212
|
value: unknown;
|
|
181
213
|
};
|
|
214
|
+
/**
|
|
215
|
+
* Queued by `ctx.trigger()` — instructs Novu to fire a workflow from inside an agent handler.
|
|
216
|
+
*
|
|
217
|
+
* - `workflowId` — the workflow identifier (same string used in `novu.events.trigger()`).
|
|
218
|
+
* - `to` — recipient(s) for the workflow. Accepts a subscriberId string, a subscriber object,
|
|
219
|
+
* a topic, or arrays thereof. When omitted, Novu falls back to the conversation's resolved
|
|
220
|
+
* subscriber. If no subscriber can be resolved, the trigger is skipped and a warning is logged.
|
|
221
|
+
* - `payload` — arbitrary data forwarded to the workflow's payload schema.
|
|
222
|
+
*/
|
|
182
223
|
type TriggerSignal = {
|
|
183
224
|
type: 'trigger';
|
|
184
225
|
workflowId: string;
|
|
185
|
-
to?:
|
|
226
|
+
to?: TriggerRecipientsPayload;
|
|
186
227
|
payload?: Record<string, unknown>;
|
|
187
228
|
};
|
|
188
229
|
type Signal = MetadataSignal | TriggerSignal;
|
|
@@ -191,6 +232,11 @@ interface EditPayload {
|
|
|
191
232
|
messageId: string;
|
|
192
233
|
content: ReplyContent;
|
|
193
234
|
}
|
|
235
|
+
/** An emoji reaction to be added to a platform message. */
|
|
236
|
+
interface AddReactionPayload {
|
|
237
|
+
messageId: string;
|
|
238
|
+
emojiName: Emoji;
|
|
239
|
+
}
|
|
194
240
|
interface AgentReplyPayload {
|
|
195
241
|
conversationId: string;
|
|
196
242
|
integrationIdentifier: string;
|
|
@@ -200,6 +246,7 @@ interface AgentReplyPayload {
|
|
|
200
246
|
summary?: string;
|
|
201
247
|
};
|
|
202
248
|
signals?: Signal[];
|
|
249
|
+
addReactions?: AddReactionPayload[];
|
|
203
250
|
}
|
|
204
251
|
/** Shape returned by /agents/:id/reply when a reply or edit was delivered. */
|
|
205
252
|
interface SentMessageInfo {
|
|
@@ -207,6 +254,34 @@ interface SentMessageInfo {
|
|
|
207
254
|
platformThreadId: string;
|
|
208
255
|
}
|
|
209
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Thrown by `ctx.reply()` and `handle.edit()` when the upstream message delivery
|
|
259
|
+
* fails — e.g. the configured email provider returns 401, Slack rejects the token,
|
|
260
|
+
* or Teams rejects the request.
|
|
261
|
+
*
|
|
262
|
+
* The `message` property contains the original provider error text
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* import { AgentDeliveryError } from '@novu/framework';
|
|
267
|
+
*
|
|
268
|
+
* try {
|
|
269
|
+
* await ctx.reply('Hello!');
|
|
270
|
+
* } catch (err) {
|
|
271
|
+
* if (err instanceof AgentDeliveryError) {
|
|
272
|
+
* // Delivery failed (misconfigured provider, rate limit, etc.)
|
|
273
|
+
* console.error('Delivery failed:', err.message);
|
|
274
|
+
* return;
|
|
275
|
+
* }
|
|
276
|
+
* throw err;
|
|
277
|
+
* }
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
declare class AgentDeliveryError extends Error {
|
|
281
|
+
readonly statusCode: number;
|
|
282
|
+
constructor(statusCode: number, message: string);
|
|
283
|
+
}
|
|
284
|
+
|
|
210
285
|
/**
|
|
211
286
|
* Define a new conversational agent.
|
|
212
287
|
*
|
|
@@ -358,4 +433,4 @@ declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
|
358
433
|
*/
|
|
359
434
|
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>;
|
|
360
435
|
|
|
361
|
-
export { type Agent as A, Client as C, type EditPayload as E, type FileRef as F, type INovuRequestHandlerOptions as I, type MessageContent as M, NovuRequestHandler as N, type ReplyContent as R, type ServeHandlerOptions as S, type TriggerSignal as T, type AgentAction as a, type AgentAttachment as b, type AgentBridgeRequest as c, type AgentContext as d, type AgentConversation as e,
|
|
436
|
+
export { type Agent as A, Client as C, type EditPayload as E, type FileRef as F, type INovuRequestHandlerOptions as I, type MessageContent as M, NovuRequestHandler as N, type ReplyContent as R, type ServeHandlerOptions as S, type TriggerSignal as T, type AgentAction as a, type AgentAttachment as b, type AgentBridgeRequest as c, type AgentContext as d, type AgentConversation as e, AgentDeliveryError as f, AgentEventEnum as g, type AgentHandlers as h, type AgentHistoryEntry as i, type AgentMessage as j, type AgentMessageAuthor as k, type AgentPlatformContext as l, type AgentReaction as m, type AgentReplyPayload as n, type AgentSubscriber as o, type MetadataSignal as p, type ReplyHandle as q, type SentMessageInfo as r, type Signal as s, agent as t, workflow as w };
|