@novu/framework 2.11.0 → 2.11.2-alpha.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/README.md +114 -9
- package/ai-sdk/package.json +4 -0
- package/cards/package.json +4 -0
- package/dist/{esm/index-dylq0Kmx.d.ts → cjs/agent.types-DdgaVUb7.d.cts} +356 -192
- package/dist/cjs/ai-sdk/index.cjs +1 -0
- package/dist/cjs/ai-sdk/index.d.cts +39 -0
- package/dist/cjs/cards.cjs +57 -0
- package/dist/cjs/cards.d.cts +2 -0
- package/dist/cjs/{health-check.types-uaDLF5bo.d.cts → health-check.types-CkUmYLNG.d.cts} +34 -140
- package/dist/cjs/index-BCp3U0UG.d.cts +189 -0
- package/dist/cjs/index.cjs +138 -135
- package/dist/cjs/index.d.cts +5 -3
- package/dist/cjs/internal/index.cjs +1 -1
- package/dist/cjs/internal/index.d.cts +96 -4
- package/dist/cjs/jsx-dev-runtime.cjs +1 -1
- package/dist/cjs/jsx-runtime.cjs +1 -1
- package/dist/cjs/langchain/index.cjs +1 -0
- package/dist/cjs/langchain/index.d.cts +105 -0
- package/dist/cjs/servers/express.cjs +137 -134
- package/dist/cjs/servers/express.d.cts +6 -4
- package/dist/cjs/servers/h3.cjs +136 -133
- package/dist/cjs/servers/h3.d.cts +6 -4
- package/dist/cjs/servers/lambda.cjs +138 -135
- package/dist/cjs/servers/lambda.d.cts +6 -5
- package/dist/cjs/servers/nest.cjs +136 -133
- package/dist/cjs/servers/nest.d.cts +21 -7
- package/dist/cjs/servers/next.cjs +138 -135
- package/dist/cjs/servers/next.d.cts +6 -4
- package/dist/cjs/servers/nuxt.cjs +136 -133
- package/dist/cjs/servers/nuxt.d.cts +6 -4
- package/dist/cjs/servers/remix.cjs +138 -135
- package/dist/cjs/servers/remix.d.cts +6 -4
- package/dist/cjs/servers/sveltekit.cjs +136 -133
- package/dist/cjs/servers/sveltekit.d.cts +6 -4
- package/dist/cjs/step-resolver.d.cts +3 -2
- package/dist/cjs/{subscriber.types-PRaHFLJu.d.cts → subscriber.types-DxMMRBIi.d.cts} +2 -78
- package/dist/cjs/util.types-DaFfsxgy.d.cts +78 -0
- package/dist/{cjs/index-D-SLxj--.d.cts → esm/agent.types-Bu3DhlVb.d.ts} +356 -192
- package/dist/esm/ai-sdk/index.d.ts +39 -0
- package/dist/esm/ai-sdk/index.js +1 -0
- package/dist/esm/cards.d.ts +2 -0
- package/dist/esm/cards.js +1 -0
- package/dist/esm/{chunk-K7PM3FEJ.js → chunk-3XT6S7TZ.js} +14 -14
- package/dist/esm/chunk-3ZWME5KT.js +0 -0
- package/dist/esm/chunk-C3P3ZH2I.js +36 -0
- package/dist/esm/chunk-FHYMHX3T.js +1 -0
- package/dist/esm/chunk-KLIOXJR3.js +1 -0
- package/dist/esm/chunk-W6DIBD4Z.js +1 -0
- package/dist/esm/chunk-YF62BBGH.js +98 -0
- package/dist/esm/{health-check.types-XZwesagD.d.ts → health-check.types-nDCnGlmX.d.ts} +34 -140
- package/dist/esm/index-DEehllqa.d.ts +189 -0
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +96 -4
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/jsx-dev-runtime.js +1 -1
- package/dist/esm/jsx-runtime-7EPQR56T.js +1 -0
- package/dist/esm/jsx-runtime.js +1 -1
- package/dist/esm/langchain/index.d.ts +105 -0
- package/dist/esm/langchain/index.js +1 -0
- package/dist/esm/servers/express.d.ts +6 -4
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +6 -4
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/lambda.d.ts +6 -5
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +21 -7
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +6 -4
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +6 -4
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +6 -4
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +6 -4
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +3 -2
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-CC7F0JO_.d.ts → subscriber.types-BbyO_Cz6.d.ts} +2 -78
- package/dist/esm/util.types-DaFfsxgy.d.ts +78 -0
- package/dist/esm/validators.js +1 -1
- package/package.json +55 -7
- package/dist/esm/chunk-52LSX2V5.js +0 -1
- package/dist/esm/chunk-LJUUDK2J.js +0 -130
- package/dist/esm/chunk-N4PZBM53.js +0 -1
|
@@ -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,147 +1,27 @@
|
|
|
1
|
-
import {
|
|
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-DxMMRBIi.cjs';
|
|
2
|
+
import { I as ITriggerPayload, t as TriggerRecipientsPayload, u as ISubscriberPayload, v as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-DdgaVUb7.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
|
};
|
|
144
9
|
|
|
10
|
+
/**
|
|
11
|
+
* A minimal logger interface used for all of the framework's internal logging
|
|
12
|
+
* (workflow discovery, execution and bridge error reporting).
|
|
13
|
+
*
|
|
14
|
+
* The methods (`info`/`warn`/`error`) are chosen so that both the global
|
|
15
|
+
* `console` and common structured loggers (pino, winston, ...) satisfy this
|
|
16
|
+
* interface directly, with no adapter. The global `console` is the default;
|
|
17
|
+
* provide your own to route Novu's internal logs wherever the rest of your
|
|
18
|
+
* application logs go.
|
|
19
|
+
*/
|
|
20
|
+
type Logger = {
|
|
21
|
+
info: typeof console.info;
|
|
22
|
+
warn: typeof console.warn;
|
|
23
|
+
error: typeof console.error;
|
|
24
|
+
};
|
|
145
25
|
type ClientOptions = {
|
|
146
26
|
/**
|
|
147
27
|
* Use Novu Cloud US (https://api.novu.co) or EU deployment (https://eu.api.novu.co). Defaults to US.
|
|
@@ -171,6 +51,19 @@ type ClientOptions = {
|
|
|
171
51
|
* Defaults to `true` in development, `false` in production.
|
|
172
52
|
*/
|
|
173
53
|
verbose?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* A custom logger used for all of the framework's internal logging
|
|
56
|
+
* (workflow discovery, execution and bridge error reporting).
|
|
57
|
+
*
|
|
58
|
+
* Defaults to the global `console`. Provide your own logger to route Novu's
|
|
59
|
+
* internal logs through your application's structured logger.
|
|
60
|
+
*
|
|
61
|
+
* Note: `verbose` still controls *whether* discovery and execution logs are
|
|
62
|
+
* emitted; `logger` only controls *where* all logs are written. Bridge errors
|
|
63
|
+
* (HTTP status >= 500) are always logged via this logger, regardless of
|
|
64
|
+
* `verbose`.
|
|
65
|
+
*/
|
|
66
|
+
logger?: Logger;
|
|
174
67
|
};
|
|
175
68
|
|
|
176
69
|
declare enum PostActionEnum {
|
|
@@ -453,7 +346,7 @@ type ChannelPreference = {
|
|
|
453
346
|
/**
|
|
454
347
|
* A partial set of workflow preferences.
|
|
455
348
|
*/
|
|
456
|
-
type WorkflowPreferences = DeepPartial
|
|
349
|
+
type WorkflowPreferences = DeepPartial<{
|
|
457
350
|
/**
|
|
458
351
|
* A default preference for the channels.
|
|
459
352
|
*
|
|
@@ -660,6 +553,7 @@ type Event = {
|
|
|
660
553
|
state: State[];
|
|
661
554
|
action: Exclude<PostActionEnum, PostActionEnum.TRIGGER>;
|
|
662
555
|
subscriber: Subscriber;
|
|
556
|
+
actor?: Subscriber;
|
|
663
557
|
context: ContextResolved;
|
|
664
558
|
/** User-defined env vars merged with environment system variables (name, type). */
|
|
665
559
|
env: EnvironmentSystemVariables & Record<string, string>;
|
|
@@ -700,4 +594,4 @@ type HealthCheck = {
|
|
|
700
594
|
};
|
|
701
595
|
};
|
|
702
596
|
|
|
703
|
-
export { type ClientOptions as C, type DiscoverAgentOutput as D, type ExecuteInput as E, GetActionEnum as G, type HealthCheck as H,
|
|
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,189 @@
|
|
|
1
|
+
import { g as AgentHandlers, A as Agent } from './agent.types-DdgaVUb7.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-CkUmYLNG.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-DxMMRBIi.cjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Thrown by `ctx.reply()` and `handle.edit()` when the upstream message delivery
|
|
11
|
+
* fails — e.g. the configured email provider returns 401, Slack rejects the token,
|
|
12
|
+
* or Teams rejects the request.
|
|
13
|
+
*
|
|
14
|
+
* `message` is always a short, human-readable summary.
|
|
15
|
+
* `responseBody` preserves the raw upstream body for debugging.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { AgentDeliveryError } from '@novu/framework';
|
|
20
|
+
*
|
|
21
|
+
* try {
|
|
22
|
+
* await ctx.reply('Hello!');
|
|
23
|
+
* } catch (err) {
|
|
24
|
+
* if (err instanceof AgentDeliveryError) {
|
|
25
|
+
* console.error('Delivery failed:', err.message);
|
|
26
|
+
* return;
|
|
27
|
+
* }
|
|
28
|
+
* throw err;
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare class AgentDeliveryError extends Error {
|
|
33
|
+
readonly statusCode: number;
|
|
34
|
+
readonly responseBody: string;
|
|
35
|
+
constructor(statusCode: number, responseBody: string);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Define a new conversational agent.
|
|
40
|
+
*
|
|
41
|
+
* @param agentId - Unique identifier matching the agent entity created in Novu (e.g. 'wine-bot')
|
|
42
|
+
* @param handlers - Handler functions for agent events
|
|
43
|
+
*/
|
|
44
|
+
declare function agent(agentId: string, handlers: AgentHandlers): Agent;
|
|
45
|
+
|
|
46
|
+
declare class Client {
|
|
47
|
+
private discoveredWorkflows;
|
|
48
|
+
private discoverWorkflowPromises;
|
|
49
|
+
private registeredAgents;
|
|
50
|
+
private templateEngine;
|
|
51
|
+
secretKey: string;
|
|
52
|
+
apiUrl: string;
|
|
53
|
+
version: string;
|
|
54
|
+
strictAuthentication: boolean;
|
|
55
|
+
verbose: boolean;
|
|
56
|
+
logger: Logger;
|
|
57
|
+
constructor(options?: ClientOptions);
|
|
58
|
+
private buildOptions;
|
|
59
|
+
private log;
|
|
60
|
+
/**
|
|
61
|
+
* Adds workflows to the client.
|
|
62
|
+
*
|
|
63
|
+
* A locking mechanism is used to ensure that duplicate workflows are not added.
|
|
64
|
+
*
|
|
65
|
+
* @param workflows - The workflows to add.
|
|
66
|
+
*/
|
|
67
|
+
addWorkflows(workflows: Array<Workflow>): Promise<void>;
|
|
68
|
+
addAgents(agents: Array<Agent>): void;
|
|
69
|
+
getAgent(agentId: string): Agent | undefined;
|
|
70
|
+
private addWorkflow;
|
|
71
|
+
healthCheck(): HealthCheck;
|
|
72
|
+
private getWorkflow;
|
|
73
|
+
private getStep;
|
|
74
|
+
private getRegisteredWorkflows;
|
|
75
|
+
discover(): DiscoverOutput;
|
|
76
|
+
/**
|
|
77
|
+
* Mocks data based on the given schema.
|
|
78
|
+
* The `default` value in the schema is used as the base data.
|
|
79
|
+
* If no `default` value is provided, the data is generated using JSONSchemaFaker.
|
|
80
|
+
*
|
|
81
|
+
* @param schema
|
|
82
|
+
* @returns mocked data
|
|
83
|
+
*/
|
|
84
|
+
private mock;
|
|
85
|
+
private validate;
|
|
86
|
+
private throwInvalidProvider;
|
|
87
|
+
private throwInvalidStep;
|
|
88
|
+
private throwInvalidEvent;
|
|
89
|
+
private executeStepFactory;
|
|
90
|
+
private shouldSanitize;
|
|
91
|
+
private shouldSkip;
|
|
92
|
+
executeWorkflow(event: Event): Promise<ExecuteOutput>;
|
|
93
|
+
private createExecutionPayload;
|
|
94
|
+
private prettyPrintExecute;
|
|
95
|
+
private executeProviders;
|
|
96
|
+
private previewProvider;
|
|
97
|
+
private executeProvider;
|
|
98
|
+
private executeStep;
|
|
99
|
+
private compileControls;
|
|
100
|
+
/**
|
|
101
|
+
* Preprocesses standalone translation patterns.
|
|
102
|
+
* Transforms {{t.key}} to [T:key] placeholder (not Liquid syntax, passes through unchanged).
|
|
103
|
+
*/
|
|
104
|
+
private preprocessTranslationPatterns;
|
|
105
|
+
/**
|
|
106
|
+
* Preprocesses translation keys used as filter arguments.
|
|
107
|
+
* Transforms 't.key' to '[T:key]' placeholder (not Liquid syntax, passes through unchanged).
|
|
108
|
+
* Example: pluralize: 't.apple', 't.apples' → pluralize: '[T:apple]', '[T:apples]'
|
|
109
|
+
*/
|
|
110
|
+
private preprocessFilterTranslationArgs;
|
|
111
|
+
/**
|
|
112
|
+
* Post-processes placeholders back to translation markers after Liquid render.
|
|
113
|
+
* Transforms [T:key] back to {{t.key}} for the translation service.
|
|
114
|
+
*/
|
|
115
|
+
private postprocessTranslationMarkers;
|
|
116
|
+
/**
|
|
117
|
+
* Create the controls for a step, taking both the event controls and the default controls into account
|
|
118
|
+
*
|
|
119
|
+
* @param step The step to create the controls for
|
|
120
|
+
* @param event The event that triggered the step
|
|
121
|
+
* @returns The controls for the step
|
|
122
|
+
*/
|
|
123
|
+
private createStepControls;
|
|
124
|
+
private previewStep;
|
|
125
|
+
private constructStepForPreview;
|
|
126
|
+
private extractMockDataForPreviousSteps;
|
|
127
|
+
private previewRequiredStep;
|
|
128
|
+
private getStepState;
|
|
129
|
+
private getStepCode;
|
|
130
|
+
private getWorkflowCode;
|
|
131
|
+
getCode(workflowId: string, stepId?: string): CodeResult;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface ServeHandlerOptions {
|
|
135
|
+
client?: Client;
|
|
136
|
+
workflows?: Array<Workflow>;
|
|
137
|
+
agents?: Array<Agent>;
|
|
138
|
+
}
|
|
139
|
+
type INovuRequestHandlerOptions<Input extends any[] = any[], Output = any> = ServeHandlerOptions & {
|
|
140
|
+
frameworkName: string;
|
|
141
|
+
client?: Client;
|
|
142
|
+
workflows?: Array<Workflow>;
|
|
143
|
+
agents?: Array<Agent>;
|
|
144
|
+
handler: Handler<Input, Output>;
|
|
145
|
+
};
|
|
146
|
+
type Handler<Input extends any[] = any[], Output = any> = (...args: Input) => HandlerResponse<Output>;
|
|
147
|
+
type HandlerResponse<Output = any> = {
|
|
148
|
+
body: () => Awaitable<any>;
|
|
149
|
+
headers: (key: string) => Awaitable<string | null | undefined>;
|
|
150
|
+
method: () => Awaitable<string>;
|
|
151
|
+
queryString?: (key: string, url: URL) => Awaitable<string | null | undefined>;
|
|
152
|
+
url: () => Awaitable<URL>;
|
|
153
|
+
transformResponse: (res: IActionResponse<string>) => Output;
|
|
154
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
155
|
+
};
|
|
156
|
+
type IActionResponse<TBody extends string = string> = {
|
|
157
|
+
status: number;
|
|
158
|
+
headers: Record<string, string>;
|
|
159
|
+
body: TBody;
|
|
160
|
+
};
|
|
161
|
+
declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
162
|
+
readonly frameworkName: string;
|
|
163
|
+
readonly handler: Handler<Input, Output>;
|
|
164
|
+
readonly client: Client;
|
|
165
|
+
private readonly hmacEnabled;
|
|
166
|
+
private readonly http;
|
|
167
|
+
private readonly workflows;
|
|
168
|
+
private readonly agents;
|
|
169
|
+
constructor(options: INovuRequestHandlerOptions<Input, Output>);
|
|
170
|
+
createHandler(): (...args: Input) => Promise<Output>;
|
|
171
|
+
private getStaticHeaders;
|
|
172
|
+
private createResponse;
|
|
173
|
+
private createError;
|
|
174
|
+
private handleAction;
|
|
175
|
+
private getPostActionMap;
|
|
176
|
+
triggerAction(triggerEvent: EventTriggerParams): () => Promise<IActionResponse<string>>;
|
|
177
|
+
private getGetActionMap;
|
|
178
|
+
private handlePostAction;
|
|
179
|
+
private handleGetAction;
|
|
180
|
+
private handleError;
|
|
181
|
+
private validateHmac;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Define a new notification workflow.
|
|
186
|
+
*/
|
|
187
|
+
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>;
|
|
188
|
+
|
|
189
|
+
export { AgentDeliveryError as A, Client as C, type INovuRequestHandlerOptions as I, NovuRequestHandler as N, type ServeHandlerOptions as S, agent as a, workflow as w };
|