@novu/framework 2.0.2 → 2.1.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/{handler-xDdUZXcL.d.ts → handler-8vDLpUDh.d.ts} +118 -28
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -28
- package/dist/servers/express.d.ts +1 -1
- package/dist/servers/express.js +9 -9
- package/dist/servers/h3.d.ts +1 -1
- package/dist/servers/h3.js +7 -7
- package/dist/servers/lambda.d.ts +1 -1
- package/dist/servers/lambda.js +5 -5
- package/dist/servers/next.d.ts +1 -1
- package/dist/servers/next.js +8 -8
- package/dist/servers/nuxt.d.ts +4 -2
- package/dist/servers/nuxt.js +7 -7
- package/dist/servers/remix.d.ts +3 -3
- package/dist/servers/remix.js +3 -3
- package/dist/servers/sveltekit.d.ts +1 -1
- package/dist/servers/sveltekit.js +6 -6
- package/package.json +6 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TriggerEventStatusEnum, ITriggerPayload, TriggerRecipientSubscriber, TriggerRecipientsPayload, WorkflowPreferencesPartial } from '@novu/shared';
|
|
2
2
|
import { JSONSchema, FromSchema as FromSchema$1 } from 'json-schema-to-ts';
|
|
3
3
|
import zod from 'zod';
|
|
4
4
|
|
|
@@ -55,6 +55,19 @@ declare enum ActionStepEnum {
|
|
|
55
55
|
CUSTOM = "custom"
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* A developer-friendly variant of ChannelTypeEnum, utilizing camelCase instead of snake_case
|
|
60
|
+
* to use consistent casing throughout the Framework.
|
|
61
|
+
*/
|
|
62
|
+
declare enum WorkflowChannelEnum {
|
|
63
|
+
EMAIL = "email",
|
|
64
|
+
SMS = "sms",
|
|
65
|
+
PUSH = "push",
|
|
66
|
+
CHAT = "chat",
|
|
67
|
+
/** Differs from ChannelTypeEnum in capitalization / snake_case */
|
|
68
|
+
IN_APP = "inApp"
|
|
69
|
+
}
|
|
70
|
+
|
|
58
71
|
type JsonSchema = JSONSchema;
|
|
59
72
|
/**
|
|
60
73
|
* A schema used to validate a JSON object.
|
|
@@ -4049,6 +4062,12 @@ type PickRequiredKeys<T, DEEP extends boolean = true> = keyof PickRequired<T, DE
|
|
|
4049
4062
|
* Optionally, recurses through nested objects if `DEEP` is true.
|
|
4050
4063
|
*/
|
|
4051
4064
|
type PickOptionalKeys<T, DEEP extends boolean = true> = keyof PickOptional<T, DEEP>;
|
|
4065
|
+
/**
|
|
4066
|
+
* Recursively make all properties of type `T` optional.
|
|
4067
|
+
*/
|
|
4068
|
+
type DeepPartial<T> = T extends object ? {
|
|
4069
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
4070
|
+
} : T;
|
|
4052
4071
|
|
|
4053
4072
|
type Passthrough = {
|
|
4054
4073
|
body?: Record<string, unknown>;
|
|
@@ -4256,15 +4275,15 @@ type DigestResult = FromSchema<(typeof actionStepSchemas)[ActionStepEnum.DIGEST]
|
|
|
4256
4275
|
*/
|
|
4257
4276
|
type Step = {
|
|
4258
4277
|
/** Send an email. */
|
|
4259
|
-
|
|
4278
|
+
[WorkflowChannelEnum.EMAIL]: ChannelStep<ChannelStepEnum.EMAIL, EmailOutputUnvalidated, EmailResult>;
|
|
4260
4279
|
/** Send an SMS. */
|
|
4261
|
-
|
|
4280
|
+
[WorkflowChannelEnum.SMS]: ChannelStep<ChannelStepEnum.SMS, SmsOutputUnvalidated, SmsResult>;
|
|
4262
4281
|
/** Send a push notification. */
|
|
4263
|
-
|
|
4282
|
+
[WorkflowChannelEnum.PUSH]: ChannelStep<ChannelStepEnum.PUSH, PushOutputUnvalidated, PushResult>;
|
|
4264
4283
|
/** Send a chat message. */
|
|
4265
|
-
|
|
4284
|
+
[WorkflowChannelEnum.CHAT]: ChannelStep<ChannelStepEnum.CHAT, ChatOutputUnvalidated, ChatResult>;
|
|
4266
4285
|
/** Send an in-app notification. */
|
|
4267
|
-
|
|
4286
|
+
[WorkflowChannelEnum.IN_APP]: ChannelStep<ChannelStepEnum.IN_APP, InAppOutputUnvalidated, InAppResult>;
|
|
4268
4287
|
/** Aggregate events for a period of time. */
|
|
4269
4288
|
digest: ActionStep<DigestOutputUnvalidated, DigestResult>;
|
|
4270
4289
|
/** Delay the workflow for a period of time. */
|
|
@@ -4308,16 +4327,42 @@ type ExecuteInput<T_Payload extends Record<string, unknown>, T_Controls extends
|
|
|
4308
4327
|
* The function to execute the workflow.
|
|
4309
4328
|
*/
|
|
4310
4329
|
type Execute<T_Payload extends Record<string, unknown>, T_Controls extends Record<string, unknown>> = (event: ExecuteInput<T_Payload, T_Controls>) => Promise<void>;
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4330
|
+
/** A preference for a notification delivery channel. */
|
|
4331
|
+
type ChannelPreference = {
|
|
4332
|
+
/**
|
|
4333
|
+
* A flag specifying if notification delivery is enabled for the channel.
|
|
4334
|
+
*
|
|
4335
|
+
* If `true`, notification delivery is enabled.
|
|
4336
|
+
*
|
|
4337
|
+
* @default true
|
|
4338
|
+
*/
|
|
4339
|
+
enabled: boolean;
|
|
4340
|
+
/**
|
|
4341
|
+
* A flag specifying if the preference is read-only.
|
|
4342
|
+
*
|
|
4343
|
+
* If `true`, the preference cannot be changed by the Subscriber.
|
|
4344
|
+
*
|
|
4345
|
+
* @default false
|
|
4346
|
+
*/
|
|
4347
|
+
readOnly: boolean;
|
|
4320
4348
|
};
|
|
4349
|
+
/**
|
|
4350
|
+
* A partial set of workflow preferences.
|
|
4351
|
+
*/
|
|
4352
|
+
type WorkflowPreferences = DeepPartial<{
|
|
4353
|
+
/**
|
|
4354
|
+
* A preference for the workflow.
|
|
4355
|
+
*
|
|
4356
|
+
* The values specified here will be used if no preference is specified for a channel.
|
|
4357
|
+
*/
|
|
4358
|
+
workflow: ChannelPreference;
|
|
4359
|
+
/**
|
|
4360
|
+
* A preference for each notification delivery channel.
|
|
4361
|
+
*
|
|
4362
|
+
* If no preference is specified for a channel, the `workflow` preference will be used.
|
|
4363
|
+
*/
|
|
4364
|
+
channels: Record<WorkflowChannelEnum, ChannelPreference>;
|
|
4365
|
+
}>;
|
|
4321
4366
|
/**
|
|
4322
4367
|
* The options for the workflow.
|
|
4323
4368
|
*/
|
|
@@ -4330,8 +4375,63 @@ type WorkflowOptions<T_PayloadSchema extends Schema, T_ControlSchema extends Sch
|
|
|
4330
4375
|
* @deprecated Use `controlSchema` instead
|
|
4331
4376
|
*/
|
|
4332
4377
|
inputSchema?: T_ControlSchema;
|
|
4378
|
+
/** The schema for the controls. */
|
|
4333
4379
|
controlSchema?: T_ControlSchema;
|
|
4334
|
-
|
|
4380
|
+
/**
|
|
4381
|
+
* The preferences for the notification workflow.
|
|
4382
|
+
*
|
|
4383
|
+
* If no preference is specified for a channel, the `workflow` preference will be used.
|
|
4384
|
+
*
|
|
4385
|
+
* @example
|
|
4386
|
+
* ```ts
|
|
4387
|
+
* // Enable notification delivery for only the in-app channel by default.
|
|
4388
|
+
* {
|
|
4389
|
+
* workflow: { enabled: false },
|
|
4390
|
+
* channels: {
|
|
4391
|
+
* inApp: { enabled: true },
|
|
4392
|
+
* },
|
|
4393
|
+
* }
|
|
4394
|
+
* ```
|
|
4395
|
+
*
|
|
4396
|
+
* @example
|
|
4397
|
+
* ```ts
|
|
4398
|
+
* // Enable notification delivery for all channels by default.
|
|
4399
|
+
* {
|
|
4400
|
+
* workflow: { enabled: true }
|
|
4401
|
+
* }
|
|
4402
|
+
* ```
|
|
4403
|
+
*
|
|
4404
|
+
* @example
|
|
4405
|
+
* ```ts
|
|
4406
|
+
* // Enable notification delivery for all channels by default,
|
|
4407
|
+
* // disallowing the Subscriber to change the preference.
|
|
4408
|
+
* {
|
|
4409
|
+
* workflow: { enabled: true, readOnly: true },
|
|
4410
|
+
* }
|
|
4411
|
+
* ```
|
|
4412
|
+
*
|
|
4413
|
+
* @example
|
|
4414
|
+
* ```ts
|
|
4415
|
+
* // Disable notification delivery for all channels by default,
|
|
4416
|
+
* // allowing the Subscriber to change the preference.
|
|
4417
|
+
* {
|
|
4418
|
+
* workflow: { enabled: false, readOnly: false },
|
|
4419
|
+
* }
|
|
4420
|
+
* ```
|
|
4421
|
+
*
|
|
4422
|
+
* @example
|
|
4423
|
+
* ```ts
|
|
4424
|
+
* // Disable notification delivery for only the in-app channel by default,
|
|
4425
|
+
* // allowing the Subscriber to change the preference.
|
|
4426
|
+
* {
|
|
4427
|
+
* channels: {
|
|
4428
|
+
* inApp: { enabled: false, readOnly: false },
|
|
4429
|
+
* },
|
|
4430
|
+
* }
|
|
4431
|
+
* ```
|
|
4432
|
+
*/
|
|
4433
|
+
preferences?: WorkflowPreferences;
|
|
4434
|
+
/** The tags for the workflow. */
|
|
4335
4435
|
tags?: string[];
|
|
4336
4436
|
};
|
|
4337
4437
|
|
|
@@ -4449,16 +4549,6 @@ type DiscoverStepOutput = {
|
|
|
4449
4549
|
providers: Array<DiscoverProviderOutput>;
|
|
4450
4550
|
options: StepOptions;
|
|
4451
4551
|
};
|
|
4452
|
-
type ChannelPreference = {
|
|
4453
|
-
defaultValue: boolean;
|
|
4454
|
-
readOnly: boolean;
|
|
4455
|
-
};
|
|
4456
|
-
type DiscoverWorkflowOutputPreferences = {
|
|
4457
|
-
workflow: ChannelPreference;
|
|
4458
|
-
channels: {
|
|
4459
|
-
[key in (typeof ChannelTypeEnum)[keyof typeof ChannelTypeEnum]]: ChannelPreference;
|
|
4460
|
-
};
|
|
4461
|
-
};
|
|
4462
4552
|
type DiscoverWorkflowOutput = {
|
|
4463
4553
|
workflowId: string;
|
|
4464
4554
|
execute: Execute<Record<string, unknown>, Record<string, unknown>>;
|
|
@@ -4483,7 +4573,7 @@ type DiscoverWorkflowOutput = {
|
|
|
4483
4573
|
schema: JsonSchema;
|
|
4484
4574
|
unknownSchema: Schema;
|
|
4485
4575
|
};
|
|
4486
|
-
preferences:
|
|
4576
|
+
preferences: WorkflowPreferencesPartial;
|
|
4487
4577
|
tags: string[];
|
|
4488
4578
|
};
|
|
4489
4579
|
type Workflow<T_Payload = any> = {
|
|
@@ -4644,4 +4734,4 @@ declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
|
4644
4734
|
private hashHmac;
|
|
4645
4735
|
}
|
|
4646
4736
|
|
|
4647
|
-
export { type
|
|
4737
|
+
export { type InAppOutput as $, ActionStepEnum as A, type ActionStep as B, Client as C, type DiscoverProviderOutput as D, type Execute as E, type FromSchemaUnvalidated as F, GetActionEnum as G, type HealthCheck as H, type CustomStep as I, type JsonSchema as J, type ChannelStep as K, type EmailOutput as L, type EmailOutputUnvalidated as M, NovuRequestHandler as N, type EmailResult as O, PostActionEnum as P, type SmsOutput as Q, type SmsOutputUnvalidated as R, type Schema as S, type SmsResult as T, type PushOutput as U, type PushOutputUnvalidated as V, type WorkflowOptions as W, type PushResult as X, type ChatOutput as Y, type ChatOutputUnvalidated as Z, type ChatResult as _, type FromSchema as a, type InAppOutputUnvalidated as a0, type InAppResult as a1, type DelayOutput as a2, type DelayOutputUnvalidated as a3, type DelayResult as a4, type DigestRegularOutput as a5, type DigestRegularOutputUnvalidated as a6, type DigestTimedOutput as a7, type DigestTimedOutputUnvalidated as a8, type DigestOutput as a9, type DigestOutputUnvalidated as aa, type DigestResult as ab, type Step as ac, type Subscriber as ad, type Either as ae, type Awaitable as af, type Prettify as ag, type ConditionalPartial as ah, type Indexable as ai, type PickOptional as aj, type PickRequired as ak, type PickRequiredKeys as al, type PickOptionalKeys as am, type DeepPartial as an, type ExecuteInput as ao, type ChannelPreference as ap, type WorkflowPreferences as aq, type Workflow as b, type ServeHandlerOptions as c, ChannelStepEnum as d, WorkflowChannelEnum as e, type CodeResult as f, type ClientOptions as g, type StepType as h, type DiscoverStepOutput as i, type DiscoverWorkflowOutput as j, type DiscoverOutput as k, type EventTriggerResult as l, type EventTriggerParams as m, type EventTriggerResponse as n, type CancelEventTriggerResponse as o, type Event as p, type State as q, type ExecuteOutputMetadata as r, type ExecuteOutputOptions as s, type ExecuteOutput as t, type SupportedFrameworkName as u, type Skip as v, type StepOptions as w, JobStatusEnum as x, type StepContext as y, type StepOutput as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Schema, F as FromSchemaUnvalidated, a as FromSchema, J as JsonSchema, E as Execute, W as WorkflowOptions, b as Workflow } from './handler-
|
|
2
|
-
export {
|
|
1
|
+
import { S as Schema, F as FromSchemaUnvalidated, a as FromSchema, J as JsonSchema, E as Execute, W as WorkflowOptions, b as Workflow } from './handler-8vDLpUDh.js';
|
|
2
|
+
export { B as ActionStep, A as ActionStepEnum, af as Awaitable, o as CancelEventTriggerResponse, ap as ChannelPreference, K as ChannelStep, d as ChannelStepEnum, Y as ChatOutput, Z as ChatOutputUnvalidated, _ as ChatResult, C as Client, g as ClientOptions, f as CodeResult, ah as ConditionalPartial, I as CustomStep, an as DeepPartial, a2 as DelayOutput, a3 as DelayOutputUnvalidated, a4 as DelayResult, a9 as DigestOutput, aa as DigestOutputUnvalidated, a5 as DigestRegularOutput, a6 as DigestRegularOutputUnvalidated, ab as DigestResult, a7 as DigestTimedOutput, a8 as DigestTimedOutputUnvalidated, k as DiscoverOutput, D as DiscoverProviderOutput, i as DiscoverStepOutput, j as DiscoverWorkflowOutput, ae as Either, L as EmailOutput, M as EmailOutputUnvalidated, O as EmailResult, p as Event, m as EventTriggerParams, n as EventTriggerResponse, l as EventTriggerResult, ao as ExecuteInput, t as ExecuteOutput, r as ExecuteOutputMetadata, s as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, $ as InAppOutput, a0 as InAppOutputUnvalidated, a1 as InAppResult, ai as Indexable, x as JobStatusEnum, N as NovuRequestHandler, aj as PickOptional, am as PickOptionalKeys, ak as PickRequired, al as PickRequiredKeys, P as PostActionEnum, ag as Prettify, U as PushOutput, V as PushOutputUnvalidated, X as PushResult, c as ServeHandlerOptions, v as Skip, Q as SmsOutput, R as SmsOutputUnvalidated, T as SmsResult, q as State, ac as Step, y as StepContext, w as StepOptions, z as StepOutput, h as StepType, ad as Subscriber, u as SupportedFrameworkName, e as WorkflowChannelEnum, aq as WorkflowPreferences } from './handler-8vDLpUDh.js';
|
|
3
3
|
import { ValidateFunction as ValidateFunction$1 } from 'ajv';
|
|
4
4
|
import { ParseReturnType } from 'zod';
|
|
5
5
|
import '@novu/shared';
|