@novu/framework 2.10.0-alpha.1 → 2.10.0-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.
Files changed (62) hide show
  1. package/dist/cjs/health-check.types-4uaeqZcn.d.cts +682 -0
  2. package/dist/cjs/{index-D3UJoqjc.d.cts → index-CYSvjrhq.d.cts} +2 -1
  3. package/dist/cjs/index.cjs +84 -84
  4. package/dist/cjs/index.d.cts +4 -3
  5. package/dist/cjs/internal/index.cjs +1 -1
  6. package/dist/cjs/internal/index.d.cts +3 -2
  7. package/dist/cjs/servers/express.cjs +84 -84
  8. package/dist/cjs/servers/express.d.cts +5 -4
  9. package/dist/cjs/servers/h3.cjs +84 -84
  10. package/dist/cjs/servers/h3.d.cts +5 -4
  11. package/dist/cjs/servers/lambda.cjs +84 -84
  12. package/dist/cjs/servers/lambda.d.cts +6 -5
  13. package/dist/cjs/servers/nest.cjs +81 -81
  14. package/dist/cjs/servers/nest.d.cts +7 -5
  15. package/dist/cjs/servers/next.cjs +83 -83
  16. package/dist/cjs/servers/next.d.cts +5 -4
  17. package/dist/cjs/servers/nuxt.cjs +84 -84
  18. package/dist/cjs/servers/nuxt.d.cts +5 -4
  19. package/dist/cjs/servers/remix.cjs +84 -84
  20. package/dist/cjs/servers/remix.d.cts +5 -4
  21. package/dist/cjs/servers/sveltekit.cjs +84 -84
  22. package/dist/cjs/servers/sveltekit.d.cts +5 -4
  23. package/dist/cjs/step-resolver.cjs +411 -1
  24. package/dist/cjs/step-resolver.d.cts +73 -12
  25. package/dist/{esm/health-check.types-23Z3Ne4i.d.ts → cjs/subscriber.types-CftO3aFY.d.cts} +4 -681
  26. package/dist/cjs/validators.cjs +1 -1
  27. package/dist/cjs/validators.d.cts +1 -1
  28. package/dist/esm/{chunk-7YRWUU4W.js → chunk-6TKOIKX4.js} +49 -49
  29. package/dist/esm/chunk-APAOD3BG.js +1 -0
  30. package/dist/esm/{chunk-C734BFYR.js → chunk-LPE4ME2M.js} +1 -1
  31. package/dist/esm/chunk-MQSAHSED.js +1 -0
  32. package/dist/esm/{chunk-HQVOLRIB.js → chunk-RCWIURDJ.js} +4 -4
  33. package/dist/esm/{chunk-AZJKOVFF.js → chunk-V7JTIDNT.js} +1 -1
  34. package/dist/esm/health-check.types-CbPsqNn9.d.ts +682 -0
  35. package/dist/esm/{index-B6Kq7kjS.d.ts → index-EtuVRQ6w.d.ts} +2 -1
  36. package/dist/esm/index.d.ts +4 -3
  37. package/dist/esm/index.js +1 -1
  38. package/dist/esm/internal/index.d.ts +3 -2
  39. package/dist/esm/internal/index.js +1 -1
  40. package/dist/esm/servers/express.d.ts +5 -4
  41. package/dist/esm/servers/express.js +1 -1
  42. package/dist/esm/servers/h3.d.ts +5 -4
  43. package/dist/esm/servers/h3.js +1 -1
  44. package/dist/esm/servers/lambda.d.ts +6 -5
  45. package/dist/esm/servers/lambda.js +1 -1
  46. package/dist/esm/servers/nest.d.ts +7 -5
  47. package/dist/esm/servers/nest.js +1 -1
  48. package/dist/esm/servers/next.d.ts +5 -4
  49. package/dist/esm/servers/next.js +1 -1
  50. package/dist/esm/servers/nuxt.d.ts +5 -4
  51. package/dist/esm/servers/nuxt.js +1 -1
  52. package/dist/esm/servers/remix.d.ts +5 -4
  53. package/dist/esm/servers/remix.js +1 -1
  54. package/dist/esm/servers/sveltekit.d.ts +5 -4
  55. package/dist/esm/servers/sveltekit.js +1 -1
  56. package/dist/esm/step-resolver.d.ts +73 -12
  57. package/dist/esm/step-resolver.js +1 -1
  58. package/dist/{cjs/health-check.types-CBl2aQ8k.d.cts → esm/subscriber.types-CfRj4acH.d.ts} +4 -681
  59. package/dist/esm/validators.d.ts +1 -1
  60. package/dist/esm/validators.js +1 -1
  61. package/package.json +20 -20
  62. package/dist/esm/chunk-JFMDTNSL.js +0 -1
@@ -0,0 +1,682 @@
1
+ import { a as ContextPayload, b as ConditionalPartial, P as PickRequiredKeys, c as Step, d as Prettify, S as Subscriber, C as ContextResolved, D as DeepPartial$1, e as ChannelStepEnum, A as ActionStepEnum, f as Awaitable, W as WithPassthrough, g as StepOptions } from './subscriber.types-CftO3aFY.cjs';
2
+ import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs';
3
+
4
+ type CodeResult = {
5
+ code: string;
6
+ };
7
+
8
+ type ClientOptions = {
9
+ /**
10
+ * Use Novu Cloud US (https://api.novu.co) or EU deployment (https://eu.api.novu.co). Defaults to US.
11
+ */
12
+ apiUrl?: string;
13
+ /**
14
+ * Specify your Novu secret key, to secure the Bridge Endpoint, and Novu API communication.
15
+ * Novu communicates securely with your endpoint using a signed HMAC header,
16
+ * ensuring that only trusted requests from Novu are actioned by your Bridge API.
17
+ * The secret key is used to sign the HMAC header.
18
+ */
19
+ secretKey?: string;
20
+ /**
21
+ * Explicitly use HMAC signature verification.
22
+ * Setting this to `false` will enable Novu to communicate with your Bridge API
23
+ * without requiring a valid HMAC signature.
24
+ * This is useful for local development and testing.
25
+ *
26
+ * In production you must specify an `secretKey` and set this to `true`.
27
+ *
28
+ * Defaults to true.
29
+ */
30
+ strictAuthentication?: boolean;
31
+ /**
32
+ * Enable verbose logging for workflow discovery and execution.
33
+ * When set to `false`, discovery and execution logs will be suppressed.
34
+ * Defaults to `true` in development, `false` in production.
35
+ */
36
+ verbose?: boolean;
37
+ };
38
+
39
+ declare enum PostActionEnum {
40
+ TRIGGER = "trigger",
41
+ EXECUTE = "execute",
42
+ PREVIEW = "preview"
43
+ }
44
+ declare enum GetActionEnum {
45
+ DISCOVER = "discover",
46
+ HEALTH_CHECK = "health-check",
47
+ CODE = "code"
48
+ }
49
+
50
+ /**
51
+ * Cron expression helper.
52
+ */
53
+ declare enum CronExpression {
54
+ EVERY_SECOND = "* * * * * *",
55
+ EVERY_5_SECONDS = "*/5 * * * * *",
56
+ EVERY_10_SECONDS = "*/10 * * * * *",
57
+ EVERY_30_SECONDS = "*/30 * * * * *",
58
+ EVERY_MINUTE = "*/1 * * * *",
59
+ EVERY_5_MINUTES = "0 */5 * * * *",
60
+ EVERY_10_MINUTES = "0 */10 * * * *",
61
+ EVERY_30_MINUTES = "0 */30 * * * *",
62
+ EVERY_HOUR = "0 0-23/1 * * *",
63
+ EVERY_2_HOURS = "0 0-23/2 * * *",
64
+ EVERY_3_HOURS = "0 0-23/3 * * *",
65
+ EVERY_4_HOURS = "0 0-23/4 * * *",
66
+ EVERY_5_HOURS = "0 0-23/5 * * *",
67
+ EVERY_6_HOURS = "0 0-23/6 * * *",
68
+ EVERY_7_HOURS = "0 0-23/7 * * *",
69
+ EVERY_8_HOURS = "0 0-23/8 * * *",
70
+ EVERY_9_HOURS = "0 0-23/9 * * *",
71
+ EVERY_10_HOURS = "0 0-23/10 * * *",
72
+ EVERY_11_HOURS = "0 0-23/11 * * *",
73
+ EVERY_12_HOURS = "0 0-23/12 * * *",
74
+ EVERY_DAY_AT_1AM = "0 01 * * *",
75
+ EVERY_DAY_AT_2AM = "0 02 * * *",
76
+ EVERY_DAY_AT_3AM = "0 03 * * *",
77
+ EVERY_DAY_AT_4AM = "0 04 * * *",
78
+ EVERY_DAY_AT_5AM = "0 05 * * *",
79
+ EVERY_DAY_AT_6AM = "0 06 * * *",
80
+ EVERY_DAY_AT_7AM = "0 07 * * *",
81
+ EVERY_DAY_AT_8AM = "0 08 * * *",
82
+ EVERY_DAY_AT_9AM = "0 09 * * *",
83
+ EVERY_DAY_AT_10AM = "0 10 * * *",
84
+ EVERY_DAY_AT_11AM = "0 11 * * *",
85
+ EVERY_DAY_AT_NOON = "0 12 * * *",
86
+ EVERY_DAY_AT_1PM = "0 13 * * *",
87
+ EVERY_DAY_AT_2PM = "0 14 * * *",
88
+ EVERY_DAY_AT_3PM = "0 15 * * *",
89
+ EVERY_DAY_AT_4PM = "0 16 * * *",
90
+ EVERY_DAY_AT_5PM = "0 17 * * *",
91
+ EVERY_DAY_AT_6PM = "0 18 * * *",
92
+ EVERY_DAY_AT_7PM = "0 19 * * *",
93
+ EVERY_DAY_AT_8PM = "0 20 * * *",
94
+ EVERY_DAY_AT_9PM = "0 21 * * *",
95
+ EVERY_DAY_AT_10PM = "0 22 * * *",
96
+ EVERY_DAY_AT_11PM = "0 23 * * *",
97
+ EVERY_DAY_AT_MIDNIGHT = "0 0 * * *",
98
+ EVERY_WEEK = "0 0 * * 0",
99
+ EVERY_WEEKDAY = "0 0 * * 1-5",
100
+ EVERY_WEEKEND = "0 0 * * 6,0",
101
+ EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT = "0 0 1 * *",
102
+ EVERY_1ST_DAY_OF_MONTH_AT_NOON = "0 12 1 * *",
103
+ EVERY_2ND_DAY_OF_MONTH_AT_10AM = "0 10 2 * *",
104
+ EVERY_2ND_HOUR = "0 */2 * * *",
105
+ EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM = "0 1-23/2 * * *",
106
+ EVERY_2ND_MONTH = "0 0 1 */2 *",
107
+ EVERY_QUARTER = "0 0 1 */3 *",
108
+ EVERY_6_MONTHS = "0 0 1 */6 *",
109
+ EVERY_YEAR = "0 0 1 0 *",
110
+ EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM = "0 */30 9-17 * * *",
111
+ EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM = "0 */30 9-18 * * *",
112
+ EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM = "0 */30 10-19 * * *",
113
+ MONDAY_TO_FRIDAY_AT_1AM = "0 0 01 * * 1-5",
114
+ MONDAY_TO_FRIDAY_AT_2AM = "0 0 02 * * 1-5",
115
+ MONDAY_TO_FRIDAY_AT_3AM = "0 0 03 * * 1-5",
116
+ MONDAY_TO_FRIDAY_AT_4AM = "0 0 04 * * 1-5",
117
+ MONDAY_TO_FRIDAY_AT_5AM = "0 0 05 * * 1-5",
118
+ MONDAY_TO_FRIDAY_AT_6AM = "0 0 06 * * 1-5",
119
+ MONDAY_TO_FRIDAY_AT_7AM = "0 0 07 * * 1-5",
120
+ MONDAY_TO_FRIDAY_AT_8AM = "0 0 08 * * 1-5",
121
+ MONDAY_TO_FRIDAY_AT_9AM = "0 0 09 * * 1-5",
122
+ MONDAY_TO_FRIDAY_AT_09_30AM = "0 30 09 * * 1-5",
123
+ MONDAY_TO_FRIDAY_AT_10AM = "0 0 10 * * 1-5",
124
+ MONDAY_TO_FRIDAY_AT_11AM = "0 0 11 * * 1-5",
125
+ MONDAY_TO_FRIDAY_AT_11_30AM = "0 30 11 * * 1-5",
126
+ MONDAY_TO_FRIDAY_AT_12PM = "0 0 12 * * 1-5",
127
+ MONDAY_TO_FRIDAY_AT_1PM = "0 0 13 * * 1-5",
128
+ MONDAY_TO_FRIDAY_AT_2PM = "0 0 14 * * 1-5",
129
+ MONDAY_TO_FRIDAY_AT_3PM = "0 0 15 * * 1-5",
130
+ MONDAY_TO_FRIDAY_AT_4PM = "0 0 16 * * 1-5",
131
+ MONDAY_TO_FRIDAY_AT_5PM = "0 0 17 * * 1-5",
132
+ MONDAY_TO_FRIDAY_AT_6PM = "0 0 18 * * 1-5",
133
+ MONDAY_TO_FRIDAY_AT_7PM = "0 0 19 * * 1-5",
134
+ MONDAY_TO_FRIDAY_AT_8PM = "0 0 20 * * 1-5",
135
+ MONDAY_TO_FRIDAY_AT_9PM = "0 0 21 * * 1-5",
136
+ MONDAY_TO_FRIDAY_AT_10PM = "0 0 22 * * 1-5",
137
+ MONDAY_TO_FRIDAY_AT_11PM = "0 0 23 * * 1-5"
138
+ }
139
+
140
+ /**
141
+ * A developer-friendly variant of ChannelTypeEnum, utilizing camelCase instead of snake_case
142
+ * to use consistent casing throughout the Framework.
143
+ */
144
+ declare enum WorkflowChannelEnum {
145
+ EMAIL = "email",
146
+ SMS = "sms",
147
+ PUSH = "push",
148
+ CHAT = "chat",
149
+ /** Differs from ChannelTypeEnum in capitalization / snake_case */
150
+ IN_APP = "inApp"
151
+ }
152
+
153
+ declare enum ChannelTypeEnum {
154
+ IN_APP = "in_app",
155
+ EMAIL = "email",
156
+ SMS = "sms",
157
+ CHAT = "chat",
158
+ PUSH = "push"
159
+ }
160
+ interface IAttachmentOptions {
161
+ mime: string;
162
+ file: Buffer;
163
+ name?: string;
164
+ channels?: ChannelTypeEnum[];
165
+ cid?: string;
166
+ disposition?: string;
167
+ }
168
+ interface ITriggerPayload {
169
+ attachments?: IAttachmentOptions[];
170
+ [key: string]: string | string[] | boolean | number | undefined | IAttachmentOptions | IAttachmentOptions[] | Record<string, unknown>;
171
+ }
172
+ interface ISubscriberPayload {
173
+ subscriberId: string;
174
+ firstName?: string;
175
+ lastName?: string;
176
+ email?: string;
177
+ phone?: string;
178
+ avatar?: string;
179
+ locale?: string;
180
+ data?: Record<string, unknown>;
181
+ channels?: ISubscriberChannel[];
182
+ }
183
+ interface ISubscriberChannel {
184
+ providerId: ChatProviderIdEnum | PushProviderIdEnum;
185
+ integrationIdentifier?: string;
186
+ credentials: IChannelCredentials;
187
+ }
188
+ interface IChannelCredentials {
189
+ webhookUrl?: string;
190
+ deviceTokens?: string[];
191
+ }
192
+ interface ITopic {
193
+ type: 'Topic';
194
+ topicKey: string;
195
+ exclude?: string[];
196
+ }
197
+ type TriggerRecipientsPayload = string | ISubscriberPayload | ITopic | ISubscriberPayload[] | ITopic[];
198
+ declare enum TriggerEventStatusEnum {
199
+ ERROR = "error",
200
+ NOT_ACTIVE = "trigger_not_active",
201
+ NO_WORKFLOW_ACTIVE_STEPS = "no_workflow_active_steps_defined",
202
+ NO_WORKFLOW_STEPS = "no_workflow_steps_defined",
203
+ PROCESSED = "processed",
204
+ SUBSCRIBER_MISSING = "subscriber_id_missing",
205
+ TENANT_MISSING = "no_tenant_found"
206
+ }
207
+ declare enum ChatProviderIdEnum {
208
+ Slack = "slack",
209
+ Discord = "discord",
210
+ MsTeams = "msteams",
211
+ Mattermost = "mattermost",
212
+ Ryver = "ryver",
213
+ Zulip = "zulip",
214
+ GrafanaOnCall = "grafana-on-call",
215
+ GetStream = "getstream",
216
+ RocketChat = "rocket-chat",
217
+ WhatsAppBusiness = "whatsapp-business",
218
+ ChatWebhook = "chat-webhook"
219
+ }
220
+ declare enum PushProviderIdEnum {
221
+ FCM = "fcm",
222
+ APNS = "apns",
223
+ EXPO = "expo",
224
+ OneSignal = "one-signal",
225
+ Pushpad = "pushpad",
226
+ PushWebhook = "push-webhook",
227
+ PusherBeams = "pusher-beams",
228
+ AppIO = "appio"
229
+ }
230
+ /**
231
+ * A preference for a notification delivery workflow.
232
+ *
233
+ * This provides a shortcut to setting all channels to the same preference.
234
+ */
235
+ type WorkflowPreference$1 = {
236
+ /**
237
+ * A flag specifying if notification delivery is enabled for the workflow.
238
+ *
239
+ * If `true`, notification delivery is enabled by default for all channels.
240
+ *
241
+ * This setting can be overridden by the channel preferences.
242
+ *
243
+ * @default true
244
+ */
245
+ enabled: boolean;
246
+ /**
247
+ * A flag specifying if the preference is read-only.
248
+ *
249
+ * If `true`, the preference cannot be changed by the Subscriber.
250
+ *
251
+ * @default false
252
+ */
253
+ readOnly: boolean;
254
+ };
255
+ /** A preference for a notification delivery channel. */
256
+ type ChannelPreference$1 = {
257
+ /**
258
+ * A flag specifying if notification delivery is enabled for the channel.
259
+ *
260
+ * If `true`, notification delivery is enabled.
261
+ *
262
+ * @default true
263
+ */
264
+ enabled: boolean;
265
+ };
266
+ type WorkflowPreferences$1 = {
267
+ /**
268
+ * A preference for the workflow.
269
+ *
270
+ * The values specified here will be used if no preference is specified for a channel.
271
+ */
272
+ all: WorkflowPreference$1;
273
+ /**
274
+ * A preference for each notification delivery channel.
275
+ *
276
+ * If no preference is specified for a channel, the `all` preference will be used.
277
+ */
278
+ channels: Record<ChannelTypeEnum, ChannelPreference$1>;
279
+ };
280
+ /**
281
+ * Recursively make all properties of type `T` optional.
282
+ */
283
+ type DeepPartial<T> = T extends object ? {
284
+ [P in keyof T]?: DeepPartial<T[P]>;
285
+ } : T;
286
+ /** A partial set of workflow preferences. */
287
+ type WorkflowPreferencesPartial = DeepPartial<WorkflowPreferences$1>;
288
+
289
+ type EventPayload = ITriggerPayload;
290
+ type Actor = string | ISubscriberPayload;
291
+ type Recipients = TriggerRecipientsPayload;
292
+ type EventTriggerResult = {
293
+ /**
294
+ * Cancel the workflow execution
295
+ */
296
+ cancel: () => Promise<CancelEventTriggerResponse>;
297
+ /**
298
+ * Response data for the trigger
299
+ */
300
+ data: EventTriggerResponse;
301
+ };
302
+ type EventTriggerParams<T_Payload = EventPayload> = {
303
+ /**
304
+ * Workflow id
305
+ */
306
+ workflowId: string;
307
+ /**
308
+ * Recipients to trigger the workflow to
309
+ */
310
+ to: Recipients;
311
+ /**
312
+ * Actor to trigger the workflow from
313
+ */
314
+ actor?: Actor;
315
+ /**
316
+ * Context to trigger the workflow with
317
+ */
318
+ context?: ContextPayload;
319
+ /**
320
+ * Bridge url to trigger the workflow to
321
+ */
322
+ bridgeUrl?: string;
323
+ /**
324
+ * Transaction id for trigger
325
+ */
326
+ transactionId?: string;
327
+ /**
328
+ * Overrides for trigger
329
+ */
330
+ overrides?: Record<string, unknown>;
331
+ /**
332
+ * Controls for the step execution
333
+ */
334
+ controls?: {
335
+ steps: {
336
+ [stepId: string]: Record<string, unknown>;
337
+ };
338
+ };
339
+ /**
340
+ * Use Novu Cloud US (https://api.novu.co) or EU deployment (https://eu.api.novu.co). Defaults to US.
341
+ */
342
+ apiUrl?: string;
343
+ /**
344
+ * Override secret key for the trigger
345
+ */
346
+ secretKey?: string;
347
+ } & ConditionalPartial<{
348
+ /**
349
+ * Payload to trigger the workflow with
350
+ */
351
+ payload: T_Payload;
352
+ }, PickRequiredKeys<T_Payload> extends never ? true : false>;
353
+ type EventTriggerResponse = {
354
+ /**
355
+ * If trigger was acknowledged or not
356
+ */
357
+ acknowledged: boolean;
358
+ /**
359
+ * Status for trigger
360
+ */
361
+ status: `${TriggerEventStatusEnum}`;
362
+ /**
363
+ * Any errors encountered during the trigger
364
+ */
365
+ error?: string[];
366
+ /**
367
+ * Unique transaction identifier for the event
368
+ */
369
+ transactionId?: string;
370
+ };
371
+ /**
372
+ * Flag indicating if the event was cancelled or not.
373
+ * `false` indicates the event was not cancelled because the execution was completed.
374
+ * `true` indicates the in-flight execution was cancelled.
375
+ */
376
+ type CancelEventTriggerResponse = boolean;
377
+
378
+ /**
379
+ * The severity level of a workflow.
380
+ */
381
+ declare enum SeverityLevelEnum {
382
+ NONE = "none",
383
+ LOW = "low",
384
+ MEDIUM = "medium",
385
+ HIGH = "high"
386
+ }
387
+ /**
388
+ * The parameters for the workflow function.
389
+ */
390
+ type ExecuteInput<T_Payload extends Record<string, unknown>, T_Controls extends Record<string, unknown>> = {
391
+ /** Define a step in your workflow. */
392
+ step: Step;
393
+ /** The payload for the event, provided during trigger. */
394
+ payload: T_Payload;
395
+ /** The subscriber for the event, provided during trigger. */
396
+ subscriber: Prettify<Subscriber>;
397
+ /** The environment the workflow is running in. */
398
+ environment: Record<string, unknown>;
399
+ /** The controls for the event. Provided via the Dashboard. */
400
+ controls: T_Controls;
401
+ /** The resolved context for the event. */
402
+ context: ContextResolved;
403
+ };
404
+ /**
405
+ * The function to execute the workflow.
406
+ */
407
+ type Execute<T_Payload extends Record<string, unknown>, T_Controls extends Record<string, unknown>> = (event: ExecuteInput<T_Payload, T_Controls>) => Promise<void>;
408
+ /**
409
+ * A preference for a notification delivery workflow.
410
+ *
411
+ * This provides a shortcut to setting all channels to the same preference.
412
+ */
413
+ type WorkflowPreference = {
414
+ /**
415
+ * A flag specifying if notification delivery is enabled for the workflow.
416
+ *
417
+ * If `true`, notification delivery is enabled by default for all channels.
418
+ *
419
+ * This setting can be overridden by the channel preferences.
420
+ *
421
+ * @default true
422
+ */
423
+ enabled: boolean;
424
+ /**
425
+ * A flag specifying if the preference is read-only.
426
+ *
427
+ * If `true`, the preference cannot be changed by the Subscriber.
428
+ *
429
+ * @default false
430
+ */
431
+ readOnly: boolean;
432
+ };
433
+ /** A preference for a notification delivery channel. */
434
+ type ChannelPreference = {
435
+ /**
436
+ * A flag specifying if notification delivery is enabled for the channel.
437
+ *
438
+ * If `true`, notification delivery is enabled.
439
+ *
440
+ * @default true
441
+ */
442
+ enabled: boolean;
443
+ };
444
+ /**
445
+ * A partial set of workflow preferences.
446
+ */
447
+ type WorkflowPreferences = DeepPartial$1<{
448
+ /**
449
+ * A default preference for the channels.
450
+ *
451
+ * The values specified here will be used if no preference is specified for a channel.
452
+ */
453
+ all: WorkflowPreference;
454
+ /**
455
+ * A preference for each notification delivery channel.
456
+ *
457
+ * If no preference is specified for a channel, the `all` preference will be used.
458
+ */
459
+ channels: Record<WorkflowChannelEnum, ChannelPreference>;
460
+ }>;
461
+ /**
462
+ * The options for the workflow.
463
+ */
464
+ type WorkflowOptions<T_PayloadSchema extends Schema, T_ControlSchema extends Schema> = {
465
+ /** The schema for the payload. */
466
+ payloadSchema?: T_PayloadSchema;
467
+ /** The schema for the controls. */
468
+ controlSchema?: T_ControlSchema;
469
+ /**
470
+ * The preferences for the notification workflow.
471
+ *
472
+ * If no preference is specified for a channel, the `all` preference will be used.
473
+ *
474
+ * @example
475
+ * ```ts
476
+ * // Enable notification delivery for only the in-app channel by default.
477
+ * {
478
+ * all: { enabled: false },
479
+ * channels: {
480
+ * inApp: { enabled: true },
481
+ * },
482
+ * }
483
+ * ```
484
+ *
485
+ * @example
486
+ * ```ts
487
+ * // Enable notification delivery for all channels by default.
488
+ * {
489
+ * all: { enabled: true }
490
+ * }
491
+ * ```
492
+ *
493
+ * @example
494
+ * ```ts
495
+ * // Enable notification delivery for all channels by default,
496
+ * // disallowing the Subscriber to change the preference.
497
+ * {
498
+ * all: { enabled: true, readOnly: true },
499
+ * }
500
+ * ```
501
+ *
502
+ * @example
503
+ * ```ts
504
+ * // Disable notification delivery for all channels by default,
505
+ * // allowing the Subscriber to change the preference.
506
+ * {
507
+ * all: { enabled: false, readOnly: false },
508
+ * }
509
+ * ```
510
+ *
511
+ * @example
512
+ * ```ts
513
+ * // Disable notification delivery for only the in-app channel by default,
514
+ * // allowing the Subscriber to change the preference.
515
+ * {
516
+ * all: { readOnly: false },
517
+ * channels: {
518
+ * inApp: { enabled: false },
519
+ * },
520
+ * }
521
+ * ```
522
+ */
523
+ preferences?: WorkflowPreferences;
524
+ /** The tags for the workflow. */
525
+ tags?: string[];
526
+ /**
527
+ * The name of the workflow.
528
+ *
529
+ * This is used to display a human-friendly name for the workflow in the Dashboard and `<Inbox />` component.
530
+ *
531
+ * If no value is specified, the `workflowId` will be used as the name.
532
+ *
533
+ * @example `Weekly Comment Digest`
534
+ */
535
+ name?: string;
536
+ /**
537
+ * The description of the workflow.
538
+ *
539
+ * This is used to provide a brief overview of the workflow in the Dashboard.
540
+ *
541
+ * @example `This workflow sends a weekly digest of comments to users.`
542
+ */
543
+ description?: string;
544
+ /**
545
+ * The severity of the workflow.
546
+ *
547
+ * This is used to determine the severity of the workflow.
548
+ *
549
+ * @example `high`
550
+ */
551
+ severity?: SeverityLevelEnum;
552
+ };
553
+
554
+ type StepType = `${ChannelStepEnum | ActionStepEnum}`;
555
+ type DiscoverProviderOutput = {
556
+ type: string;
557
+ code: string;
558
+ resolve: ({ controls, outputs, }: {
559
+ controls: Record<string, unknown>;
560
+ outputs: Record<string, unknown>;
561
+ }) => Awaitable<WithPassthrough<Record<string, unknown>>>;
562
+ outputs: {
563
+ schema: JsonSchema;
564
+ unknownSchema: Schema;
565
+ };
566
+ };
567
+ type DiscoverStepOutput = {
568
+ stepId: string;
569
+ type: StepType;
570
+ controls: {
571
+ schema: JsonSchema;
572
+ unknownSchema: Schema;
573
+ };
574
+ outputs: {
575
+ schema: JsonSchema;
576
+ unknownSchema: Schema;
577
+ };
578
+ results: {
579
+ schema: JsonSchema;
580
+ unknownSchema: Schema;
581
+ };
582
+ code: string;
583
+ resolve: (controls: Record<string, unknown>) => Awaitable<Record<string, unknown>>;
584
+ providers: Array<DiscoverProviderOutput>;
585
+ options: StepOptions;
586
+ };
587
+ type DiscoverWorkflowOutput = {
588
+ workflowId: string;
589
+ execute: Execute<Record<string, unknown>, Record<string, unknown>>;
590
+ code: string;
591
+ steps: Array<DiscoverStepOutput>;
592
+ payload: {
593
+ schema: JsonSchema;
594
+ unknownSchema: Schema;
595
+ };
596
+ controls: {
597
+ schema: JsonSchema;
598
+ unknownSchema: Schema;
599
+ };
600
+ preferences: WorkflowPreferencesPartial;
601
+ tags: string[];
602
+ name?: string;
603
+ description?: string;
604
+ severity: SeverityLevelEnum;
605
+ };
606
+ /**
607
+ * A workflow resource.
608
+ *
609
+ * @property `id` - The unique identifier for the workflow.
610
+ * @property `trigger` - The function to trigger the workflow.
611
+ * @property `discover` - The function to discover the workflow definition.
612
+ */
613
+ type Workflow<T_Payload = never> = {
614
+ /**
615
+ * The unique identifier for the workflow.
616
+ */
617
+ id: string;
618
+ /**
619
+ * Trigger an event for this workflow with a strongly typed and validated `payload`, derived from the `payloadSchema`.
620
+ *
621
+ * @param event - The event to trigger
622
+ * @returns `EventTriggerResult` - The result of the event trigger
623
+ */
624
+ trigger: (event: Prettify<Omit<EventTriggerParams<T_Payload>, 'workflowId' | 'bridgeUrl' | 'controls'>>) => Promise<EventTriggerResult>;
625
+ /**
626
+ * Discover the workflow definition.
627
+ *
628
+ * @returns `DiscoverWorkflowOutput` - The workflow definition
629
+ */
630
+ discover: () => Promise<DiscoverWorkflowOutput>;
631
+ };
632
+ type DiscoverOutput = {
633
+ workflows: Array<DiscoverWorkflowOutput>;
634
+ };
635
+
636
+ type Event = {
637
+ payload: Record<string, unknown>;
638
+ workflowId: string;
639
+ stepId: string;
640
+ controls: Record<string, unknown>;
641
+ state: State[];
642
+ action: Exclude<PostActionEnum, PostActionEnum.TRIGGER>;
643
+ subscriber: Subscriber;
644
+ context: ContextResolved;
645
+ };
646
+ type State = {
647
+ stepId: string;
648
+ outputs: Record<string, unknown>;
649
+ state: {
650
+ status: string;
651
+ error?: string;
652
+ };
653
+ };
654
+ type ExecuteOutputMetadata = {
655
+ status: string;
656
+ error: boolean;
657
+ /**
658
+ * The duration of the step execution in milliseconds
659
+ */
660
+ duration: number;
661
+ };
662
+ type ExecuteOutputOptions = {
663
+ skip: boolean;
664
+ };
665
+ type ExecuteOutput = {
666
+ outputs: Record<string, unknown>;
667
+ providers?: Record<string, WithPassthrough<Record<string, unknown>>>;
668
+ options: ExecuteOutputOptions;
669
+ metadata: ExecuteOutputMetadata;
670
+ };
671
+
672
+ type HealthCheck = {
673
+ status: 'ok' | 'error';
674
+ sdkVersion: string;
675
+ frameworkVersion: string;
676
+ discovered: {
677
+ workflows: number;
678
+ steps: number;
679
+ };
680
+ };
681
+
682
+ export { type ClientOptions as C, type DiscoverOutput 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 DiscoverProviderOutput as e, type DiscoverStepOutput as f, type DiscoverWorkflowOutput as g, type Event as h, type EventTriggerParams as i, type EventTriggerResponse as j, type EventTriggerResult as k, type Execute as l, type ExecuteOutput as m, type ExecuteOutputMetadata as n, type ExecuteOutputOptions as o, type State as p, type StepType as q, WorkflowChannelEnum as r, type WorkflowOptions as s, type WorkflowPreference as t, type WorkflowPreferences as u };
@@ -1,4 +1,5 @@
1
- import { a as ClientOptions, W as Workflow, H as HealthCheck, m as DiscoverOutput, s as Event, w as ExecuteOutput, f as CodeResult, o as EventTriggerParams, am as Awaitable, ax as Execute, aB as WorkflowOptions } from './health-check.types-CBl2aQ8k.cjs';
1
+ import { C as ClientOptions, W as Workflow, H as HealthCheck, D as DiscoverOutput, h as Event, m as ExecuteOutput, d as CodeResult, i as EventTriggerParams, l as Execute, s as WorkflowOptions } from './health-check.types-4uaeqZcn.cjs';
2
+ import { f as Awaitable } from './subscriber.types-CftO3aFY.cjs';
2
3
  import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.cjs';
3
4
  import './step-resolver.cjs';
4
5