@novu/framework 2.11.1 → 2.11.2-alpha.1

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 (89) hide show
  1. package/README.md +114 -9
  2. package/ai-sdk/package.json +4 -0
  3. package/cards/package.json +4 -0
  4. package/dist/{esm/index-D6L0Yufw.d.ts → cjs/agent.types-Dqm2VBTO.d.cts} +410 -193
  5. package/dist/cjs/ai-sdk/index.cjs +1 -0
  6. package/dist/cjs/ai-sdk/index.d.cts +40 -0
  7. package/dist/cjs/cards.cjs +57 -0
  8. package/dist/cjs/cards.d.cts +2 -0
  9. package/dist/cjs/{health-check.types-D4NEyjyC.d.cts → health-check.types-B9FbzRbm.d.cts} +6 -140
  10. package/dist/cjs/index-1DobCKAF.d.cts +160 -0
  11. package/dist/cjs/index.cjs +138 -138
  12. package/dist/cjs/index.d.cts +5 -3
  13. package/dist/cjs/internal/index.cjs +1 -1
  14. package/dist/cjs/internal/index.d.cts +98 -4
  15. package/dist/cjs/jsx-dev-runtime.cjs +1 -1
  16. package/dist/cjs/jsx-runtime.cjs +1 -1
  17. package/dist/cjs/langchain/index.cjs +1 -0
  18. package/dist/cjs/langchain/index.d.cts +106 -0
  19. package/dist/cjs/servers/express.cjs +138 -138
  20. package/dist/cjs/servers/express.d.cts +6 -4
  21. package/dist/cjs/servers/h3.cjs +137 -137
  22. package/dist/cjs/servers/h3.d.cts +6 -4
  23. package/dist/cjs/servers/lambda.cjs +137 -137
  24. package/dist/cjs/servers/lambda.d.cts +6 -5
  25. package/dist/cjs/servers/nest.cjs +138 -138
  26. package/dist/cjs/servers/nest.d.cts +21 -7
  27. package/dist/cjs/servers/next.cjs +137 -137
  28. package/dist/cjs/servers/next.d.cts +6 -4
  29. package/dist/cjs/servers/nuxt.cjs +137 -137
  30. package/dist/cjs/servers/nuxt.d.cts +6 -4
  31. package/dist/cjs/servers/remix.cjs +137 -137
  32. package/dist/cjs/servers/remix.d.cts +6 -4
  33. package/dist/cjs/servers/sveltekit.cjs +137 -137
  34. package/dist/cjs/servers/sveltekit.d.cts +6 -4
  35. package/dist/cjs/step-resolver.cjs +1 -1
  36. package/dist/cjs/step-resolver.d.cts +3 -2
  37. package/dist/cjs/{subscriber.types-PRaHFLJu.d.cts → subscriber.types-DubxcL8q.d.cts} +18 -78
  38. package/dist/cjs/util.types-DaFfsxgy.d.cts +78 -0
  39. package/dist/cjs/validators.cjs +1 -1
  40. package/dist/{cjs/index-BNiIiOE-.d.cts → esm/agent.types-E3sxq6xr.d.ts} +410 -193
  41. package/dist/esm/ai-sdk/index.d.ts +40 -0
  42. package/dist/esm/ai-sdk/index.js +1 -0
  43. package/dist/esm/cards.d.ts +2 -0
  44. package/dist/esm/cards.js +1 -0
  45. package/dist/esm/{chunk-DKQLYSZS.js → chunk-22DBAEUX.js} +1 -1
  46. package/dist/esm/{chunk-KLCBNFAF.js → chunk-3XT6S7TZ.js} +14 -14
  47. package/dist/esm/chunk-3ZWME5KT.js +0 -0
  48. package/dist/esm/chunk-C3P3ZH2I.js +36 -0
  49. package/dist/esm/{chunk-QTWEINJ4.js → chunk-CANJPWLT.js} +1 -1
  50. package/dist/esm/chunk-E2MET7IR.js +1 -0
  51. package/dist/esm/chunk-FHYMHX3T.js +1 -0
  52. package/dist/esm/chunk-Q6BV36LU.js +98 -0
  53. package/dist/esm/chunk-W6DIBD4Z.js +1 -0
  54. package/dist/esm/{health-check.types-C-81VaBO.d.ts → health-check.types-BNocZ4Wk.d.ts} +6 -140
  55. package/dist/esm/index-aVljLqR4.d.ts +160 -0
  56. package/dist/esm/index.d.ts +5 -3
  57. package/dist/esm/index.js +1 -1
  58. package/dist/esm/internal/index.d.ts +98 -4
  59. package/dist/esm/internal/index.js +1 -1
  60. package/dist/esm/jsx-dev-runtime.js +1 -1
  61. package/dist/esm/jsx-runtime-7EPQR56T.js +1 -0
  62. package/dist/esm/jsx-runtime.js +1 -1
  63. package/dist/esm/langchain/index.d.ts +106 -0
  64. package/dist/esm/langchain/index.js +1 -0
  65. package/dist/esm/servers/express.d.ts +6 -4
  66. package/dist/esm/servers/express.js +1 -1
  67. package/dist/esm/servers/h3.d.ts +6 -4
  68. package/dist/esm/servers/h3.js +1 -1
  69. package/dist/esm/servers/lambda.d.ts +6 -5
  70. package/dist/esm/servers/lambda.js +1 -1
  71. package/dist/esm/servers/nest.d.ts +21 -7
  72. package/dist/esm/servers/nest.js +1 -1
  73. package/dist/esm/servers/next.d.ts +6 -4
  74. package/dist/esm/servers/next.js +1 -1
  75. package/dist/esm/servers/nuxt.d.ts +6 -4
  76. package/dist/esm/servers/nuxt.js +1 -1
  77. package/dist/esm/servers/remix.d.ts +6 -4
  78. package/dist/esm/servers/remix.js +1 -1
  79. package/dist/esm/servers/sveltekit.d.ts +6 -4
  80. package/dist/esm/servers/sveltekit.js +1 -1
  81. package/dist/esm/step-resolver.d.ts +3 -2
  82. package/dist/esm/step-resolver.js +1 -1
  83. package/dist/esm/{subscriber.types-CC7F0JO_.d.ts → subscriber.types-CmybpXhA.d.ts} +18 -78
  84. package/dist/esm/util.types-DaFfsxgy.d.ts +78 -0
  85. package/dist/esm/validators.js +1 -1
  86. package/package.json +56 -8
  87. package/dist/esm/chunk-52LSX2V5.js +0 -1
  88. package/dist/esm/chunk-N4PZBM53.js +0 -1
  89. package/dist/esm/chunk-ND6IQFTA.js +0 -133
@@ -0,0 +1,2 @@
1
+ export { Actions, ActionsElement, Button, ButtonElement, Card, CardChild, CardElement, CardLink, CardText, Divider, DividerElement, LinkElement, Select, SelectElement, SelectOption, SelectOptionElement, TextElement, TextInput, TextInputElement } from 'chat';
2
+ import 'chat/jsx-runtime';
@@ -1,143 +1,8 @@
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-PRaHFLJu.cjs';
1
+ import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-DubxcL8q.cjs';
2
+ import { I as ITriggerPayload, w as TriggerRecipientsPayload, x as ISubscriberPayload, y as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-Dqm2VBTO.cjs';
3
+ import { C as ConditionalPartial, P as PickRequiredKeys, a as Prettify, D as DeepPartial, A as Awaitable } from './util.types-DaFfsxgy.cjs';
2
4
  import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs';
3
5
 
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
- Telegram = "telegram"
71
- }
72
- declare enum PushProviderIdEnum {
73
- FCM = "fcm",
74
- APNS = "apns",
75
- EXPO = "expo",
76
- OneSignal = "one-signal",
77
- Pushpad = "pushpad",
78
- PushWebhook = "push-webhook",
79
- PusherBeams = "pusher-beams",
80
- AppIO = "appio"
81
- }
82
- /**
83
- * A preference for a notification delivery workflow.
84
- *
85
- * This provides a shortcut to setting all channels to the same preference.
86
- */
87
- type WorkflowPreference$1 = {
88
- /**
89
- * A flag specifying if notification delivery is enabled for the workflow.
90
- *
91
- * If `true`, notification delivery is enabled by default for all channels.
92
- *
93
- * This setting can be overridden by the channel preferences.
94
- *
95
- * @default true
96
- */
97
- enabled: boolean;
98
- /**
99
- * A flag specifying if the preference is read-only.
100
- *
101
- * If `true`, the preference cannot be changed by the Subscriber.
102
- *
103
- * @default false
104
- */
105
- readOnly: boolean;
106
- };
107
- /** A preference for a notification delivery channel. */
108
- type ChannelPreference$1 = {
109
- /**
110
- * A flag specifying if notification delivery is enabled for the channel.
111
- *
112
- * If `true`, notification delivery is enabled.
113
- *
114
- * @default true
115
- */
116
- enabled: boolean;
117
- };
118
- type WorkflowPreferences$1 = {
119
- /**
120
- * A preference for the workflow.
121
- *
122
- * The values specified here will be used if no preference is specified for a channel.
123
- */
124
- all: WorkflowPreference$1;
125
- /**
126
- * A preference for each notification delivery channel.
127
- *
128
- * If no preference is specified for a channel, the `all` preference will be used.
129
- */
130
- channels: Record<ChannelTypeEnum, ChannelPreference$1>;
131
- };
132
- /**
133
- * Recursively make all properties of type `T` optional.
134
- */
135
- type DeepPartial<T> = T extends object ? {
136
- [P in keyof T]?: DeepPartial<T[P]>;
137
- } : T;
138
- /** A partial set of workflow preferences. */
139
- type WorkflowPreferencesPartial = DeepPartial<WorkflowPreferences$1>;
140
-
141
6
  type CodeResult = {
142
7
  code: string;
143
8
  };
@@ -481,7 +346,7 @@ type ChannelPreference = {
481
346
  /**
482
347
  * A partial set of workflow preferences.
483
348
  */
484
- type WorkflowPreferences = DeepPartial$1<{
349
+ type WorkflowPreferences = DeepPartial<{
485
350
  /**
486
351
  * A default preference for the channels.
487
352
  *
@@ -688,6 +553,7 @@ type Event = {
688
553
  state: State[];
689
554
  action: Exclude<PostActionEnum, PostActionEnum.TRIGGER>;
690
555
  subscriber: Subscriber;
556
+ actor?: Subscriber;
691
557
  context: ContextResolved;
692
558
  /** User-defined env vars merged with environment system variables (name, type). */
693
559
  env: EnvironmentSystemVariables & Record<string, string>;
@@ -728,4 +594,4 @@ type HealthCheck = {
728
594
  };
729
595
  };
730
596
 
731
- export { type ClientOptions as C, type DiscoverAgentOutput as D, type ExecuteInput as E, GetActionEnum as G, type HealthCheck as H, type Logger as L, 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 };
597
+ export { type ClientOptions as C, type DiscoverAgentOutput as D, type ExecuteInput as E, GetActionEnum as G, type HealthCheck as H, type Logger as L, 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,160 @@
1
+ import { i as AgentHandlers, A as Agent } from './agent.types-Dqm2VBTO.cjs';
2
+ import { L as Logger, 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-B9FbzRbm.cjs';
3
+ import { A as Awaitable } from './util.types-DaFfsxgy.cjs';
4
+ import 'chat';
5
+ import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.cjs';
6
+ import './step-resolver.cjs';
7
+ import './subscriber.types-DubxcL8q.cjs';
8
+
9
+ /**
10
+ * Define a new conversational agent.
11
+ *
12
+ * @param agentId - Unique identifier matching the agent entity created in Novu (e.g. 'wine-bot')
13
+ * @param handlers - Handler functions for agent events
14
+ */
15
+ declare function agent(agentId: string, handlers: AgentHandlers): Agent;
16
+
17
+ declare class Client {
18
+ private discoveredWorkflows;
19
+ private discoverWorkflowPromises;
20
+ private registeredAgents;
21
+ private templateEngine;
22
+ secretKey: string;
23
+ apiUrl: string;
24
+ version: string;
25
+ strictAuthentication: boolean;
26
+ verbose: boolean;
27
+ logger: Logger;
28
+ constructor(options?: ClientOptions);
29
+ private buildOptions;
30
+ private log;
31
+ /**
32
+ * Adds workflows to the client.
33
+ *
34
+ * A locking mechanism is used to ensure that duplicate workflows are not added.
35
+ *
36
+ * @param workflows - The workflows to add.
37
+ */
38
+ addWorkflows(workflows: Array<Workflow>): Promise<void>;
39
+ addAgents(agents: Array<Agent>): void;
40
+ getAgent(agentId: string): Agent | undefined;
41
+ private addWorkflow;
42
+ healthCheck(): HealthCheck;
43
+ private getWorkflow;
44
+ private getStep;
45
+ private getRegisteredWorkflows;
46
+ discover(): DiscoverOutput;
47
+ /**
48
+ * Mocks data based on the given schema.
49
+ * The `default` value in the schema is used as the base data.
50
+ * If no `default` value is provided, the data is generated using JSONSchemaFaker.
51
+ *
52
+ * @param schema
53
+ * @returns mocked data
54
+ */
55
+ private mock;
56
+ private validate;
57
+ private throwInvalidProvider;
58
+ private throwInvalidStep;
59
+ private throwInvalidEvent;
60
+ private executeStepFactory;
61
+ private shouldSanitize;
62
+ private shouldSkip;
63
+ executeWorkflow(event: Event): Promise<ExecuteOutput>;
64
+ private createExecutionPayload;
65
+ private prettyPrintExecute;
66
+ private executeProviders;
67
+ private previewProvider;
68
+ private executeProvider;
69
+ private executeStep;
70
+ private compileControls;
71
+ /**
72
+ * Preprocesses standalone translation patterns.
73
+ * Transforms {{t.key}} to [T:key] placeholder (not Liquid syntax, passes through unchanged).
74
+ */
75
+ private preprocessTranslationPatterns;
76
+ /**
77
+ * Preprocesses translation keys used as filter arguments.
78
+ * Transforms 't.key' to '[T:key]' placeholder (not Liquid syntax, passes through unchanged).
79
+ * Example: pluralize: 't.apple', 't.apples' → pluralize: '[T:apple]', '[T:apples]'
80
+ */
81
+ private preprocessFilterTranslationArgs;
82
+ /**
83
+ * Post-processes placeholders back to translation markers after Liquid render.
84
+ * Transforms [T:key] back to {{t.key}} for the translation service.
85
+ */
86
+ private postprocessTranslationMarkers;
87
+ /**
88
+ * Create the controls for a step, taking both the event controls and the default controls into account
89
+ *
90
+ * @param step The step to create the controls for
91
+ * @param event The event that triggered the step
92
+ * @returns The controls for the step
93
+ */
94
+ private createStepControls;
95
+ private previewStep;
96
+ private constructStepForPreview;
97
+ private extractMockDataForPreviousSteps;
98
+ private previewRequiredStep;
99
+ private getStepState;
100
+ private getStepCode;
101
+ private getWorkflowCode;
102
+ getCode(workflowId: string, stepId?: string): CodeResult;
103
+ }
104
+
105
+ interface ServeHandlerOptions {
106
+ client?: Client;
107
+ workflows?: Array<Workflow>;
108
+ agents?: Array<Agent>;
109
+ }
110
+ type INovuRequestHandlerOptions<Input extends any[] = any[], Output = any> = ServeHandlerOptions & {
111
+ frameworkName: string;
112
+ client?: Client;
113
+ workflows?: Array<Workflow>;
114
+ agents?: Array<Agent>;
115
+ handler: Handler<Input, Output>;
116
+ };
117
+ type Handler<Input extends any[] = any[], Output = any> = (...args: Input) => HandlerResponse<Output>;
118
+ type HandlerResponse<Output = any> = {
119
+ body: () => Awaitable<any>;
120
+ headers: (key: string) => Awaitable<string | null | undefined>;
121
+ method: () => Awaitable<string>;
122
+ queryString?: (key: string, url: URL) => Awaitable<string | null | undefined>;
123
+ url: () => Awaitable<URL>;
124
+ transformResponse: (res: IActionResponse<string>) => Output;
125
+ waitUntil?: (promise: Promise<unknown>) => void;
126
+ };
127
+ type IActionResponse<TBody extends string = string> = {
128
+ status: number;
129
+ headers: Record<string, string>;
130
+ body: TBody;
131
+ };
132
+ declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
133
+ readonly frameworkName: string;
134
+ readonly handler: Handler<Input, Output>;
135
+ readonly client: Client;
136
+ private readonly hmacEnabled;
137
+ private readonly http;
138
+ private readonly workflows;
139
+ private readonly agents;
140
+ constructor(options: INovuRequestHandlerOptions<Input, Output>);
141
+ createHandler(): (...args: Input) => Promise<Output>;
142
+ private getStaticHeaders;
143
+ private createResponse;
144
+ private createError;
145
+ private handleAction;
146
+ private getPostActionMap;
147
+ triggerAction(triggerEvent: EventTriggerParams): () => Promise<IActionResponse<string>>;
148
+ private getGetActionMap;
149
+ private handlePostAction;
150
+ private handleGetAction;
151
+ private handleError;
152
+ private validateHmac;
153
+ }
154
+
155
+ /**
156
+ * Define a new notification workflow.
157
+ */
158
+ 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>;
159
+
160
+ export { Client as C, type INovuRequestHandlerOptions as I, NovuRequestHandler as N, type ServeHandlerOptions as S, agent as a, workflow as w };