@novu/framework 2.0.1 → 2.0.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.
@@ -1,4 +1,4 @@
1
- import { ChannelTypeEnum, TriggerEventStatusEnum, ITriggerPayload, TriggerRecipientSubscriber, TriggerRecipientsPayload } from '@novu/shared';
1
+ import { TriggerEventStatusEnum, ITriggerPayload, TriggerRecipientSubscriber, TriggerRecipientsPayload, ChannelTypeEnum } 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,15 @@ declare enum ActionStepEnum {
55
55
  CUSTOM = "custom"
56
56
  }
57
57
 
58
+ declare enum WorkflowChannelEnum {
59
+ EMAIL = "email",
60
+ SMS = "sms",
61
+ PUSH = "push",
62
+ CHAT = "chat",
63
+ /** Differs from ChannelTypeEnum in capitalization / snake_case */
64
+ IN_APP = "inApp"
65
+ }
66
+
58
67
  type JsonSchema = JSONSchema;
59
68
  /**
60
69
  * A schema used to validate a JSON object.
@@ -3722,7 +3731,7 @@ declare const channelStepSchemas: {
3722
3731
  readonly properties: {
3723
3732
  readonly url: {
3724
3733
  readonly type: "string";
3725
- readonly format: "uri";
3734
+ readonly pattern: "^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$";
3726
3735
  };
3727
3736
  readonly target: {
3728
3737
  readonly type: "string";
@@ -3730,6 +3739,28 @@ declare const channelStepSchemas: {
3730
3739
  readonly default: "_blank";
3731
3740
  };
3732
3741
  };
3742
+ readonly if: {
3743
+ readonly properties: {
3744
+ readonly url: {
3745
+ readonly type: "string";
3746
+ readonly pattern: "^/";
3747
+ };
3748
+ };
3749
+ };
3750
+ readonly then: {
3751
+ readonly properties: {
3752
+ readonly target: {
3753
+ readonly default: "_self";
3754
+ };
3755
+ };
3756
+ };
3757
+ readonly else: {
3758
+ readonly properties: {
3759
+ readonly target: {
3760
+ readonly default: "_blank";
3761
+ };
3762
+ };
3763
+ };
3733
3764
  readonly required: readonly ["url"];
3734
3765
  readonly additionalProperties: false;
3735
3766
  };
@@ -3748,7 +3779,7 @@ declare const channelStepSchemas: {
3748
3779
  readonly properties: {
3749
3780
  readonly url: {
3750
3781
  readonly type: "string";
3751
- readonly format: "uri";
3782
+ readonly pattern: "^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$";
3752
3783
  };
3753
3784
  readonly target: {
3754
3785
  readonly type: "string";
@@ -3756,6 +3787,28 @@ declare const channelStepSchemas: {
3756
3787
  readonly default: "_blank";
3757
3788
  };
3758
3789
  };
3790
+ readonly if: {
3791
+ readonly properties: {
3792
+ readonly url: {
3793
+ readonly type: "string";
3794
+ readonly pattern: "^/";
3795
+ };
3796
+ };
3797
+ };
3798
+ readonly then: {
3799
+ readonly properties: {
3800
+ readonly target: {
3801
+ readonly default: "_self";
3802
+ };
3803
+ };
3804
+ };
3805
+ readonly else: {
3806
+ readonly properties: {
3807
+ readonly target: {
3808
+ readonly default: "_blank";
3809
+ };
3810
+ };
3811
+ };
3759
3812
  readonly required: readonly ["url"];
3760
3813
  readonly additionalProperties: false;
3761
3814
  };
@@ -3772,7 +3825,7 @@ declare const channelStepSchemas: {
3772
3825
  readonly properties: {
3773
3826
  readonly url: {
3774
3827
  readonly type: "string";
3775
- readonly format: "uri";
3828
+ readonly pattern: "^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$";
3776
3829
  };
3777
3830
  readonly target: {
3778
3831
  readonly type: "string";
@@ -3780,6 +3833,28 @@ declare const channelStepSchemas: {
3780
3833
  readonly default: "_blank";
3781
3834
  };
3782
3835
  };
3836
+ readonly if: {
3837
+ readonly properties: {
3838
+ readonly url: {
3839
+ readonly type: "string";
3840
+ readonly pattern: "^/";
3841
+ };
3842
+ };
3843
+ };
3844
+ readonly then: {
3845
+ readonly properties: {
3846
+ readonly target: {
3847
+ readonly default: "_self";
3848
+ };
3849
+ };
3850
+ };
3851
+ readonly else: {
3852
+ readonly properties: {
3853
+ readonly target: {
3854
+ readonly default: "_blank";
3855
+ };
3856
+ };
3857
+ };
3783
3858
  readonly required: readonly ["url"];
3784
3859
  readonly additionalProperties: false;
3785
3860
  };
@@ -4190,15 +4265,15 @@ type DigestResult = FromSchema<(typeof actionStepSchemas)[ActionStepEnum.DIGEST]
4190
4265
  */
4191
4266
  type Step = {
4192
4267
  /** Send an email. */
4193
- email: ChannelStep<ChannelStepEnum.EMAIL, EmailOutputUnvalidated, EmailResult>;
4268
+ [WorkflowChannelEnum.EMAIL]: ChannelStep<ChannelStepEnum.EMAIL, EmailOutputUnvalidated, EmailResult>;
4194
4269
  /** Send an SMS. */
4195
- sms: ChannelStep<ChannelStepEnum.SMS, SmsOutputUnvalidated, SmsResult>;
4270
+ [WorkflowChannelEnum.SMS]: ChannelStep<ChannelStepEnum.SMS, SmsOutputUnvalidated, SmsResult>;
4196
4271
  /** Send a push notification. */
4197
- push: ChannelStep<ChannelStepEnum.PUSH, PushOutputUnvalidated, PushResult>;
4272
+ [WorkflowChannelEnum.PUSH]: ChannelStep<ChannelStepEnum.PUSH, PushOutputUnvalidated, PushResult>;
4198
4273
  /** Send a chat message. */
4199
- chat: ChannelStep<ChannelStepEnum.CHAT, ChatOutputUnvalidated, ChatResult>;
4274
+ [WorkflowChannelEnum.CHAT]: ChannelStep<ChannelStepEnum.CHAT, ChatOutputUnvalidated, ChatResult>;
4200
4275
  /** Send an in-app notification. */
4201
- inApp: ChannelStep<ChannelStepEnum.IN_APP, InAppOutputUnvalidated, InAppResult>;
4276
+ [WorkflowChannelEnum.IN_APP]: ChannelStep<ChannelStepEnum.IN_APP, InAppOutputUnvalidated, InAppResult>;
4202
4277
  /** Aggregate events for a period of time. */
4203
4278
  digest: ActionStep<DigestOutputUnvalidated, DigestResult>;
4204
4279
  /** Delay the workflow for a period of time. */
@@ -4248,9 +4323,7 @@ type WorkflowOptionChannelPreference = {
4248
4323
  };
4249
4324
  type WorkflowOptionsPreferences = {
4250
4325
  workflow?: WorkflowOptionChannelPreference;
4251
- channels?: {
4252
- [key in (typeof ChannelTypeEnum)[keyof typeof ChannelTypeEnum]]?: WorkflowOptionChannelPreference;
4253
- };
4326
+ channels?: Partial<Record<WorkflowChannelEnum, WorkflowOptionChannelPreference>>;
4254
4327
  };
4255
4328
  /**
4256
4329
  * The options for the workflow.
@@ -4578,4 +4651,4 @@ declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
4578
4651
  private hashHmac;
4579
4652
  }
4580
4653
 
4581
- export { type ChatResult as $, ActionStepEnum as A, type StepOutput 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 ActionStep as I, type JsonSchema as J, type CustomStep as K, type ChannelStep as L, type EmailOutput as M, NovuRequestHandler as N, type EmailOutputUnvalidated as O, PostActionEnum as P, type EmailResult as Q, type SmsOutput as R, type Schema as S, type SmsOutputUnvalidated as T, type SmsResult as U, type PushOutput as V, type WorkflowOptions as W, type PushOutputUnvalidated as X, type PushResult as Y, type ChatOutput as Z, type ChatOutputUnvalidated as _, type FromSchema as a, type InAppOutput as a0, type InAppOutputUnvalidated as a1, type InAppResult as a2, type DelayOutput as a3, type DelayOutputUnvalidated as a4, type DelayResult as a5, type DigestRegularOutput as a6, type DigestRegularOutputUnvalidated as a7, type DigestTimedOutput as a8, type DigestTimedOutputUnvalidated as a9, type DigestOutput as aa, type DigestOutputUnvalidated as ab, type DigestResult as ac, type Step as ad, type Subscriber as ae, type Either as af, type Awaitable as ag, type Prettify as ah, type ConditionalPartial as ai, type Indexable as aj, type PickOptional as ak, type PickRequired as al, type PickRequiredKeys as am, type PickOptionalKeys as an, type ExecuteInput as ao, type WorkflowOptionChannelPreference as ap, type WorkflowOptionsPreferences as aq, type Workflow as b, type ServeHandlerOptions as c, ChannelStepEnum as d, type CodeResult as e, type ClientOptions as f, type StepType as g, type DiscoverStepOutput as h, type ChannelPreference as i, type DiscoverWorkflowOutputPreferences as j, type DiscoverWorkflowOutput as k, type DiscoverOutput as l, type EventTriggerResult as m, type EventTriggerParams as n, type EventTriggerResponse as o, type CancelEventTriggerResponse as p, type Event as q, type State as r, type ExecuteOutputMetadata as s, type ExecuteOutputOptions as t, type ExecuteOutput as u, type SupportedFrameworkName as v, type Skip as w, type StepOptions as x, JobStatusEnum as y, type StepContext as z };
4654
+ export { type ChatOutputUnvalidated as $, ActionStepEnum as A, type StepContext 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 StepOutput as I, type JsonSchema as J, type ActionStep as K, type CustomStep as L, type ChannelStep as M, NovuRequestHandler as N, type EmailOutput as O, PostActionEnum as P, type EmailOutputUnvalidated as Q, type EmailResult as R, type Schema as S, type SmsOutput as T, type SmsOutputUnvalidated as U, type SmsResult as V, type WorkflowOptions as W, type PushOutput as X, type PushOutputUnvalidated as Y, type PushResult as Z, type ChatOutput as _, type FromSchema as a, type ChatResult as a0, type InAppOutput as a1, type InAppOutputUnvalidated as a2, type InAppResult as a3, type DelayOutput as a4, type DelayOutputUnvalidated as a5, type DelayResult as a6, type DigestRegularOutput as a7, type DigestRegularOutputUnvalidated as a8, type DigestTimedOutput as a9, type DigestTimedOutputUnvalidated as aa, type DigestOutput as ab, type DigestOutputUnvalidated as ac, type DigestResult as ad, type Step as ae, type Subscriber as af, type Either as ag, type Awaitable as ah, type Prettify as ai, type ConditionalPartial as aj, type Indexable as ak, type PickOptional as al, type PickRequired as am, type PickRequiredKeys as an, type PickOptionalKeys as ao, type ExecuteInput as ap, type WorkflowOptionChannelPreference as aq, type WorkflowOptionsPreferences as ar, 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 ChannelPreference as j, type DiscoverWorkflowOutputPreferences as k, type DiscoverWorkflowOutput as l, type DiscoverOutput as m, type EventTriggerResult as n, type EventTriggerParams as o, type EventTriggerResponse as p, type CancelEventTriggerResponse as q, type Event as r, type State as s, type ExecuteOutputMetadata as t, type ExecuteOutputOptions as u, type ExecuteOutput as v, type SupportedFrameworkName as w, type Skip as x, type StepOptions as y, JobStatusEnum 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-gB0GtvM6.js';
2
- export { I as ActionStep, A as ActionStepEnum, ag as Awaitable, p as CancelEventTriggerResponse, i as ChannelPreference, L as ChannelStep, d as ChannelStepEnum, Z as ChatOutput, _ as ChatOutputUnvalidated, $ as ChatResult, C as Client, f as ClientOptions, e as CodeResult, ai as ConditionalPartial, K as CustomStep, a3 as DelayOutput, a4 as DelayOutputUnvalidated, a5 as DelayResult, aa as DigestOutput, ab as DigestOutputUnvalidated, a6 as DigestRegularOutput, a7 as DigestRegularOutputUnvalidated, ac as DigestResult, a8 as DigestTimedOutput, a9 as DigestTimedOutputUnvalidated, l as DiscoverOutput, D as DiscoverProviderOutput, h as DiscoverStepOutput, k as DiscoverWorkflowOutput, j as DiscoverWorkflowOutputPreferences, af as Either, M as EmailOutput, O as EmailOutputUnvalidated, Q as EmailResult, q as Event, n as EventTriggerParams, o as EventTriggerResponse, m as EventTriggerResult, ao as ExecuteInput, u as ExecuteOutput, s as ExecuteOutputMetadata, t as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, a0 as InAppOutput, a1 as InAppOutputUnvalidated, a2 as InAppResult, aj as Indexable, y as JobStatusEnum, N as NovuRequestHandler, ak as PickOptional, an as PickOptionalKeys, al as PickRequired, am as PickRequiredKeys, P as PostActionEnum, ah as Prettify, V as PushOutput, X as PushOutputUnvalidated, Y as PushResult, c as ServeHandlerOptions, w as Skip, R as SmsOutput, T as SmsOutputUnvalidated, U as SmsResult, r as State, ad as Step, z as StepContext, x as StepOptions, B as StepOutput, g as StepType, ae as Subscriber, v as SupportedFrameworkName, ap as WorkflowOptionChannelPreference, aq as WorkflowOptionsPreferences } from './handler-gB0GtvM6.js';
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-WKKD7ESp.js';
2
+ export { K as ActionStep, A as ActionStepEnum, ah as Awaitable, q as CancelEventTriggerResponse, j as ChannelPreference, M as ChannelStep, d as ChannelStepEnum, _ as ChatOutput, $ as ChatOutputUnvalidated, a0 as ChatResult, C as Client, g as ClientOptions, f as CodeResult, aj as ConditionalPartial, L as CustomStep, a4 as DelayOutput, a5 as DelayOutputUnvalidated, a6 as DelayResult, ab as DigestOutput, ac as DigestOutputUnvalidated, a7 as DigestRegularOutput, a8 as DigestRegularOutputUnvalidated, ad as DigestResult, a9 as DigestTimedOutput, aa as DigestTimedOutputUnvalidated, m as DiscoverOutput, D as DiscoverProviderOutput, i as DiscoverStepOutput, l as DiscoverWorkflowOutput, k as DiscoverWorkflowOutputPreferences, ag as Either, O as EmailOutput, Q as EmailOutputUnvalidated, R as EmailResult, r as Event, o as EventTriggerParams, p as EventTriggerResponse, n as EventTriggerResult, ap as ExecuteInput, v as ExecuteOutput, t as ExecuteOutputMetadata, u as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, a1 as InAppOutput, a2 as InAppOutputUnvalidated, a3 as InAppResult, ak as Indexable, z as JobStatusEnum, N as NovuRequestHandler, al as PickOptional, ao as PickOptionalKeys, am as PickRequired, an as PickRequiredKeys, P as PostActionEnum, ai as Prettify, X as PushOutput, Y as PushOutputUnvalidated, Z as PushResult, c as ServeHandlerOptions, x as Skip, T as SmsOutput, U as SmsOutputUnvalidated, V as SmsResult, s as State, ae as Step, B as StepContext, y as StepOptions, I as StepOutput, h as StepType, af as Subscriber, w as SupportedFrameworkName, e as WorkflowChannelEnum, aq as WorkflowOptionChannelPreference, ar as WorkflowOptionsPreferences } from './handler-WKKD7ESp.js';
3
3
  import { ValidateFunction as ValidateFunction$1 } from 'ajv';
4
4
  import { ParseReturnType } from 'zod';
5
5
  import '@novu/shared';