@facteurjs/core 1.0.0-beta.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.
Files changed (111) hide show
  1. package/dist/api/handlers/notifications.js +77 -0
  2. package/dist/api/handlers/preferences.js +43 -0
  3. package/dist/api/index.d.ts +16 -0
  4. package/dist/api/index.js +21 -0
  5. package/dist/api/types.d.ts +22 -0
  6. package/dist/api/types.js +0 -0
  7. package/dist/channels/discord/channel.d.ts +18 -0
  8. package/dist/channels/discord/channel.js +15 -0
  9. package/dist/channels/discord/index.d.ts +3 -0
  10. package/dist/channels/discord/index.js +4 -0
  11. package/dist/channels/discord/message.d.ts +147 -0
  12. package/dist/channels/discord/message.js +176 -0
  13. package/dist/channels/discord/types.d.ts +52 -0
  14. package/dist/channels/discord/types.js +0 -0
  15. package/dist/channels/fcm/channel.d.ts +22 -0
  16. package/dist/channels/fcm/channel.js +44 -0
  17. package/dist/channels/fcm/index.d.ts +3 -0
  18. package/dist/channels/fcm/index.js +4 -0
  19. package/dist/channels/fcm/message.d.ts +64 -0
  20. package/dist/channels/fcm/message.js +122 -0
  21. package/dist/channels/fcm/types.d.ts +29 -0
  22. package/dist/channels/fcm/types.js +0 -0
  23. package/dist/channels/slack/channel.d.ts +18 -0
  24. package/dist/channels/slack/channel.js +15 -0
  25. package/dist/channels/slack/index.d.ts +3 -0
  26. package/dist/channels/slack/index.js +4 -0
  27. package/dist/channels/slack/message.d.ts +209 -0
  28. package/dist/channels/slack/message.js +390 -0
  29. package/dist/channels/slack/types.d.ts +7 -0
  30. package/dist/channels/slack/types.js +0 -0
  31. package/dist/channels/transmit/channel.d.ts +21 -0
  32. package/dist/channels/transmit/channel.js +27 -0
  33. package/dist/channels/transmit/index.d.ts +3 -0
  34. package/dist/channels/transmit/index.js +4 -0
  35. package/dist/channels/transmit/message.d.ts +11 -0
  36. package/dist/channels/transmit/message.js +17 -0
  37. package/dist/channels/transmit/types.d.ts +11 -0
  38. package/dist/channels/transmit/types.js +0 -0
  39. package/dist/channels/twilio/channel.d.ts +21 -0
  40. package/dist/channels/twilio/channel.js +56 -0
  41. package/dist/channels/twilio/index.d.ts +4 -0
  42. package/dist/channels/twilio/index.js +4 -0
  43. package/dist/channels/twilio/message.d.ts +86 -0
  44. package/dist/channels/twilio/message.js +152 -0
  45. package/dist/channels/twilio/types.d.ts +51 -0
  46. package/dist/channels/twilio/types.js +0 -0
  47. package/dist/channels/webhook/exceptions.d.ts +18 -0
  48. package/dist/channels/webhook/exceptions.js +24 -0
  49. package/dist/channels/webhook/index.d.ts +4 -0
  50. package/dist/channels/webhook/index.js +5 -0
  51. package/dist/channels/webhook/message.d.ts +24 -0
  52. package/dist/channels/webhook/message.js +40 -0
  53. package/dist/channels/webhook/provider.d.ts +19 -0
  54. package/dist/channels/webhook/provider.js +63 -0
  55. package/dist/channels/webhook/types.d.ts +15 -0
  56. package/dist/channels/webhook/types.js +0 -0
  57. package/dist/channels/webpush/channel.d.ts +26 -0
  58. package/dist/channels/webpush/channel.js +55 -0
  59. package/dist/channels/webpush/index.d.ts +3 -0
  60. package/dist/channels/webpush/index.js +4 -0
  61. package/dist/channels/webpush/message.d.ts +90 -0
  62. package/dist/channels/webpush/message.js +174 -0
  63. package/dist/channels/webpush/types.d.ts +50 -0
  64. package/dist/channels/webpush/types.js +0 -0
  65. package/dist/database/adapters/knex.d.ts +6 -0
  66. package/dist/database/adapters/knex.js +116 -0
  67. package/dist/database/adapters/kysely.d.ts +6 -0
  68. package/dist/database/adapters/kysely.js +101 -0
  69. package/dist/database/channel.d.ts +24 -0
  70. package/dist/database/channel.js +42 -0
  71. package/dist/database/database.d.ts +18 -0
  72. package/dist/database/database.js +89 -0
  73. package/dist/database/index.d.ts +3 -0
  74. package/dist/database/index.js +4 -0
  75. package/dist/database/message.d.ts +26 -0
  76. package/dist/database/message.js +51 -0
  77. package/dist/database/types.d.ts +147 -0
  78. package/dist/database/types.js +0 -0
  79. package/dist/debug.js +7 -0
  80. package/dist/errors/duplicate_notification_exception.d.ts +13 -0
  81. package/dist/errors/duplicate_notification_exception.js +21 -0
  82. package/dist/errors/http_error.d.ts +16 -0
  83. package/dist/errors/http_error.js +30 -0
  84. package/dist/errors/index.d.ts +38 -0
  85. package/dist/errors/index.js +39 -0
  86. package/dist/events/events.d.ts +90 -0
  87. package/dist/events/events.js +83 -0
  88. package/dist/facteur.d.ts +37 -0
  89. package/dist/facteur.js +83 -0
  90. package/dist/fake.d.ts +47 -0
  91. package/dist/fake.js +85 -0
  92. package/dist/index.d.ts +15 -0
  93. package/dist/index.js +16 -0
  94. package/dist/notifications/channel_resolver.js +91 -0
  95. package/dist/notifications/notification_discoverer.d.ts +40 -0
  96. package/dist/notifications/notification_discoverer.js +113 -0
  97. package/dist/notifications/notification_sender.js +210 -0
  98. package/dist/options.d.ts +22 -0
  99. package/dist/options.js +57 -0
  100. package/dist/types/channel.d.ts +18 -0
  101. package/dist/types/channel.js +5 -0
  102. package/dist/types/events.d.ts +27 -0
  103. package/dist/types/extend.d.ts +25 -0
  104. package/dist/types/index.d.ts +8 -0
  105. package/dist/types/index.js +4 -0
  106. package/dist/types/notifications.d.ts +60 -0
  107. package/dist/types/notifications.js +38 -0
  108. package/dist/types/options.d.ts +157 -0
  109. package/dist/types/preferences.d.ts +40 -0
  110. package/dist/types/queue.d.ts +11 -0
  111. package/package.json +65 -0
@@ -0,0 +1,390 @@
1
+ import { WebhookMessage } from "../webhook/message.js";
2
+
3
+ //#region src/channels/slack/message.ts
4
+ var SlackMessage = class SlackMessage extends WebhookMessage {
5
+ #text = "";
6
+ #iconEmoji = "";
7
+ #iconUrl = "";
8
+ #username = "";
9
+ #channel = "";
10
+ #threadTs = "";
11
+ #unfurlLinks = false;
12
+ #unfurlMedia = false;
13
+ #blocks = [];
14
+ /**
15
+ * Creates a new instance of SlackMessage.
16
+ */
17
+ static create() {
18
+ return new SlackMessage();
19
+ }
20
+ /**
21
+ * Sets the main text content of the message. This will be displayed as fallback text.
22
+ */
23
+ setText(text) {
24
+ this.#text = text;
25
+ return this;
26
+ }
27
+ /**
28
+ * Sets the username for the bot that will send the message.
29
+ */
30
+ setBotUsername(username) {
31
+ this.#username = username;
32
+ return this;
33
+ }
34
+ /**
35
+ * Sets the emoji icon for the bot (e.g., ":ghost:").
36
+ */
37
+ setBotIconEmoji(emoji) {
38
+ this.#iconEmoji = emoji;
39
+ return this;
40
+ }
41
+ /**
42
+ * Sets the avatar URL for the bot.
43
+ */
44
+ setBotIconUrl(url) {
45
+ this.#iconUrl = url;
46
+ return this;
47
+ }
48
+ /**
49
+ * Sets the channel to send the message to.
50
+ */
51
+ setChannel(channel) {
52
+ this.#channel = channel;
53
+ return this;
54
+ }
55
+ /**
56
+ * Sets the thread timestamp to reply to a specific thread.
57
+ */
58
+ setThreadTimestamp(threadTs) {
59
+ this.#threadTs = threadTs;
60
+ return this;
61
+ }
62
+ /**
63
+ * Whether to automatically unfurl links in the message.
64
+ */
65
+ setUnfurlLinks(unfurl) {
66
+ this.#unfurlLinks = unfurl;
67
+ return this;
68
+ }
69
+ /**
70
+ * Whether to automatically unfurl media in the message.
71
+ */
72
+ setUnfurlMedia(unfurl) {
73
+ this.#unfurlMedia = unfurl;
74
+ return this;
75
+ }
76
+ /**
77
+ * Adds a section block with text content.
78
+ */
79
+ addSectionBlock(callback) {
80
+ const block = new SlackSectionBlock();
81
+ callback(block);
82
+ this.#blocks.push(block);
83
+ return this;
84
+ }
85
+ /**
86
+ * Adds a header block with plain text.
87
+ */
88
+ addHeaderBlock(text) {
89
+ this.#blocks.push(new SlackHeaderBlock(text));
90
+ return this;
91
+ }
92
+ /**
93
+ * Adds a divider block to separate content.
94
+ */
95
+ addDividerBlock() {
96
+ this.#blocks.push(new SlackDividerBlock());
97
+ return this;
98
+ }
99
+ /**
100
+ * Adds a context block with contextual information.
101
+ */
102
+ addContextBlock(callback) {
103
+ const block = new SlackContextBlock();
104
+ callback(block);
105
+ this.#blocks.push(block);
106
+ return this;
107
+ }
108
+ /**
109
+ * Adds an image block to display an image.
110
+ */
111
+ addImageBlock(callback) {
112
+ const block = new SlackImageBlock();
113
+ callback(block);
114
+ this.#blocks.push(block);
115
+ return this;
116
+ }
117
+ /**
118
+ * Adds an actions block with interactive elements.
119
+ */
120
+ addActionsBlock(callback) {
121
+ const block = new SlackActionsBlock();
122
+ callback(block);
123
+ this.#blocks.push(block);
124
+ return this;
125
+ }
126
+ serialize() {
127
+ const body = {
128
+ text: this.#text,
129
+ username: this.#username,
130
+ icon_emoji: this.#iconEmoji,
131
+ icon_url: this.#iconUrl,
132
+ channel: this.#channel,
133
+ unfurl_links: this.#unfurlLinks,
134
+ unfurl_media: this.#unfurlMedia,
135
+ blocks: this.#blocks.map((block) => block.serialize())
136
+ };
137
+ if (this.#threadTs) body.thread_ts = this.#threadTs;
138
+ return {
139
+ ...super.serialize(),
140
+ body
141
+ };
142
+ }
143
+ };
144
+ var SlackBlock = class {
145
+ blockId;
146
+ setBlockId(blockId) {
147
+ this.blockId = blockId;
148
+ return this;
149
+ }
150
+ };
151
+ var SlackSectionBlock = class extends SlackBlock {
152
+ #text;
153
+ #fields = [];
154
+ #accessory;
155
+ /**
156
+ * Sets the main text for the section using markdown formatting.
157
+ */
158
+ setMarkdownText(text) {
159
+ this.#text = {
160
+ type: "mrkdwn",
161
+ text
162
+ };
163
+ return this;
164
+ }
165
+ /**
166
+ * Sets the main text for the section using plain text.
167
+ */
168
+ setPlainText(text) {
169
+ this.#text = {
170
+ type: "plain_text",
171
+ text
172
+ };
173
+ return this;
174
+ }
175
+ /**
176
+ * Adds a field to the section using markdown formatting.
177
+ */
178
+ addMarkdownField(text) {
179
+ this.#fields.push({
180
+ type: "mrkdwn",
181
+ text
182
+ });
183
+ return this;
184
+ }
185
+ /**
186
+ * Adds a field to the section using plain text.
187
+ */
188
+ addPlainTextField(text) {
189
+ this.#fields.push({
190
+ type: "plain_text",
191
+ text
192
+ });
193
+ return this;
194
+ }
195
+ /**
196
+ * Adds a button accessory to the section.
197
+ */
198
+ addButtonAccessory(options) {
199
+ this.#accessory = {
200
+ type: "button",
201
+ text: {
202
+ type: "plain_text",
203
+ text: options.text
204
+ },
205
+ action_id: options.actionId,
206
+ value: options.value,
207
+ style: options.style
208
+ };
209
+ return this;
210
+ }
211
+ serialize() {
212
+ return {
213
+ type: "section",
214
+ block_id: this.blockId,
215
+ text: this.#text,
216
+ fields: this.#fields.length > 0 ? this.#fields : void 0,
217
+ accessory: this.#accessory
218
+ };
219
+ }
220
+ };
221
+ var SlackHeaderBlock = class extends SlackBlock {
222
+ #text;
223
+ constructor(text) {
224
+ super();
225
+ this.#text = text;
226
+ }
227
+ serialize() {
228
+ return {
229
+ type: "header",
230
+ block_id: this.blockId,
231
+ text: {
232
+ type: "plain_text",
233
+ text: this.#text
234
+ }
235
+ };
236
+ }
237
+ };
238
+ var SlackDividerBlock = class extends SlackBlock {
239
+ serialize() {
240
+ return {
241
+ type: "divider",
242
+ block_id: this.blockId
243
+ };
244
+ }
245
+ };
246
+ var SlackContextBlock = class extends SlackBlock {
247
+ #elements = [];
248
+ /**
249
+ * Adds markdown text to the context block.
250
+ */
251
+ addMarkdownText(text) {
252
+ this.#elements.push({
253
+ type: "mrkdwn",
254
+ text
255
+ });
256
+ return this;
257
+ }
258
+ /**
259
+ * Adds plain text to the context block.
260
+ */
261
+ addPlainText(text) {
262
+ this.#elements.push({
263
+ type: "plain_text",
264
+ text
265
+ });
266
+ return this;
267
+ }
268
+ /**
269
+ * Adds an image to the context block.
270
+ */
271
+ addImage(options) {
272
+ this.#elements.push({
273
+ type: "image",
274
+ image_url: options.imageUrl,
275
+ alt_text: options.altText
276
+ });
277
+ return this;
278
+ }
279
+ serialize() {
280
+ return {
281
+ type: "context",
282
+ block_id: this.blockId,
283
+ elements: this.#elements
284
+ };
285
+ }
286
+ };
287
+ var SlackImageBlock = class extends SlackBlock {
288
+ #imageUrl;
289
+ #altText;
290
+ #title;
291
+ /**
292
+ * Sets the image URL for the block.
293
+ */
294
+ setImageUrl(url) {
295
+ this.#imageUrl = url;
296
+ return this;
297
+ }
298
+ /**
299
+ * Sets the alt text for accessibility.
300
+ */
301
+ setAltText(altText) {
302
+ this.#altText = altText;
303
+ return this;
304
+ }
305
+ /**
306
+ * Sets an optional title for the image.
307
+ */
308
+ setTitle(title) {
309
+ this.#title = title;
310
+ return this;
311
+ }
312
+ serialize() {
313
+ return {
314
+ type: "image",
315
+ block_id: this.blockId,
316
+ image_url: this.#imageUrl,
317
+ alt_text: this.#altText,
318
+ title: this.#title ? {
319
+ type: "plain_text",
320
+ text: this.#title
321
+ } : void 0
322
+ };
323
+ }
324
+ };
325
+ var SlackActionsBlock = class extends SlackBlock {
326
+ #elements = [];
327
+ /**
328
+ * Adds a button to the actions block.
329
+ */
330
+ addButton(options) {
331
+ this.#elements.push({
332
+ type: "button",
333
+ text: {
334
+ type: "plain_text",
335
+ text: options.text
336
+ },
337
+ action_id: options.actionId,
338
+ value: options.value,
339
+ style: options.style,
340
+ url: options.url
341
+ });
342
+ return this;
343
+ }
344
+ /**
345
+ * Adds a static select menu to the actions block.
346
+ */
347
+ addStaticSelect(options) {
348
+ this.#elements.push({
349
+ type: "static_select",
350
+ placeholder: {
351
+ type: "plain_text",
352
+ text: options.placeholder
353
+ },
354
+ action_id: options.actionId,
355
+ options: options.options.map((option) => ({
356
+ text: {
357
+ type: "plain_text",
358
+ text: option.text
359
+ },
360
+ value: option.value
361
+ }))
362
+ });
363
+ return this;
364
+ }
365
+ /**
366
+ * Adds a date picker to the actions block.
367
+ */
368
+ addDatePicker(options) {
369
+ this.#elements.push({
370
+ type: "datepicker",
371
+ placeholder: {
372
+ type: "plain_text",
373
+ text: options.placeholder
374
+ },
375
+ action_id: options.actionId,
376
+ initial_date: options.initialDate
377
+ });
378
+ return this;
379
+ }
380
+ serialize() {
381
+ return {
382
+ type: "actions",
383
+ block_id: this.blockId,
384
+ elements: this.#elements
385
+ };
386
+ }
387
+ };
388
+
389
+ //#endregion
390
+ export { SlackMessage };
@@ -0,0 +1,7 @@
1
+ import { WebhookOptions, WebhookTargets } from "../webhook/types.js";
2
+
3
+ //#region src/channels/slack/types.d.ts
4
+ type SlackOptions<WebhooksNames extends string> = WebhookOptions<WebhooksNames>;
5
+ type SlackTargets<Options extends SlackOptions<any>> = WebhookTargets<Options>;
6
+ //#endregion
7
+ export { SlackOptions, SlackTargets };
File without changes
@@ -0,0 +1,21 @@
1
+ import { Channel, ChannelSendParams, kTargetSymbol } from "../../types/channel.js";
2
+ import { TransmitMessage } from "./message.js";
3
+ import { TransmitConfig, TransmitTargets } from "./types.js";
4
+
5
+ //#region src/channels/transmit/channel.d.ts
6
+ declare function transmitChannel(config: TransmitConfig): TransmitChannel;
7
+ declare class TransmitChannel implements Channel<TransmitConfig, TransmitMessage, any, TransmitTargets> {
8
+ #private;
9
+ private config;
10
+ name: "transmit";
11
+ [kTargetSymbol]: TransmitTargets;
12
+ constructor(config: TransmitConfig);
13
+ send(options: ChannelSendParams<TransmitMessage, TransmitTargets>): Promise<void>;
14
+ }
15
+ declare module '@facteurjs/core/types' {
16
+ interface Notification {
17
+ asTransmitMessage(): TransmitMessage;
18
+ }
19
+ }
20
+ //#endregion
21
+ export { TransmitChannel, transmitChannel };
@@ -0,0 +1,27 @@
1
+ import { errors } from "../../errors/index.js";
2
+ import { kTargetSymbol } from "../../types/channel.js";
3
+ import "../../types/index.js";
4
+
5
+ //#region src/channels/transmit/channel.ts
6
+ function transmitChannel(config) {
7
+ return new TransmitChannel(config);
8
+ }
9
+ var TransmitChannel = class {
10
+ name = "transmit";
11
+ [kTargetSymbol] = null;
12
+ constructor(config) {
13
+ this.config = config;
14
+ }
15
+ #resolveTargets(options) {
16
+ if (options.targets) return options.targets;
17
+ throw new errors.E_UNAVAILABLE_TARGETS(["Transmit"]);
18
+ }
19
+ async send(options) {
20
+ const message = options.message.serialize();
21
+ const targets = this.#resolveTargets(options);
22
+ this.config.transmit.broadcast(targets.channel, message.content);
23
+ }
24
+ };
25
+
26
+ //#endregion
27
+ export { TransmitChannel, transmitChannel };
@@ -0,0 +1,3 @@
1
+ import { TransmitMessage } from "./message.js";
2
+ import { TransmitChannel, transmitChannel } from "./channel.js";
3
+ export { TransmitChannel, TransmitMessage, transmitChannel };
@@ -0,0 +1,4 @@
1
+ import { TransmitMessage } from "./message.js";
2
+ import { TransmitChannel, transmitChannel } from "./channel.js";
3
+
4
+ export { TransmitChannel, TransmitMessage, transmitChannel };
@@ -0,0 +1,11 @@
1
+ //#region src/channels/transmit/message.d.ts
2
+ declare class TransmitMessage {
3
+ #private;
4
+ static create(): TransmitMessage;
5
+ setContent(content: Record<string, any>): this;
6
+ serialize(): {
7
+ content: Record<string, any>;
8
+ };
9
+ }
10
+ //#endregion
11
+ export { TransmitMessage };
@@ -0,0 +1,17 @@
1
+ //#region src/channels/transmit/message.ts
2
+ var TransmitMessage = class TransmitMessage {
3
+ #content = {};
4
+ static create() {
5
+ return new TransmitMessage();
6
+ }
7
+ setContent(content) {
8
+ this.#content = content;
9
+ return this;
10
+ }
11
+ serialize() {
12
+ return { content: this.#content };
13
+ }
14
+ };
15
+
16
+ //#endregion
17
+ export { TransmitMessage };
@@ -0,0 +1,11 @@
1
+ import { Transmit } from "@boringnode/transmit";
2
+
3
+ //#region src/channels/transmit/types.d.ts
4
+ interface TransmitTargets {
5
+ channel: string;
6
+ }
7
+ interface TransmitConfig {
8
+ transmit: Transmit<any>;
9
+ }
10
+ //#endregion
11
+ export { TransmitConfig, TransmitTargets };
File without changes
@@ -0,0 +1,21 @@
1
+ import { Channel, ChannelSendParams, kTargetSymbol } from "../../types/channel.js";
2
+ import { TwilioMessage } from "./message.js";
3
+ import { TwilioConfig, TwilioTargets } from "./types.js";
4
+
5
+ //#region src/channels/twilio/channel.d.ts
6
+ declare function twilioChannel(config: TwilioConfig): TwilioChannel;
7
+ declare class TwilioChannel implements Channel<TwilioConfig, TwilioMessage, any, TwilioTargets> {
8
+ #private;
9
+ private config;
10
+ name: "twilio";
11
+ [kTargetSymbol]: TwilioTargets;
12
+ constructor(config: TwilioConfig);
13
+ send(options: ChannelSendParams<TwilioMessage, TwilioTargets>): Promise<void>;
14
+ }
15
+ declare module '@facteurjs/core/types' {
16
+ interface Notification {
17
+ asTwilioMessage(): TwilioMessage;
18
+ }
19
+ }
20
+ //#endregion
21
+ export { TwilioChannel, twilioChannel };
@@ -0,0 +1,56 @@
1
+ import { errors } from "../../errors/index.js";
2
+ import { kTargetSymbol } from "../../types/channel.js";
3
+ import "../../types/index.js";
4
+ import Twilio from "twilio";
5
+
6
+ //#region src/channels/twilio/channel.ts
7
+ function twilioChannel(config) {
8
+ return new TwilioChannel(config);
9
+ }
10
+ var TwilioChannel = class {
11
+ name = "twilio";
12
+ [kTargetSymbol] = null;
13
+ #client;
14
+ constructor(config) {
15
+ this.config = config;
16
+ this.#client = new Twilio(config.accountSid, config.authToken);
17
+ }
18
+ async send(options) {
19
+ const message = options.message;
20
+ const targets = this.#resolveTargets(options);
21
+ const messageData = message.serialize();
22
+ const from = this.#resolveFrom(message, targets);
23
+ if (from) messageData.from = from;
24
+ if (this.config.messagingServiceSid && !message.getMessagingServiceSid()) messageData.messagingServiceSid = this.config.messagingServiceSid;
25
+ if (this.config.maxPrice !== void 0 && message.getMaxPrice() === void 0) messageData.maxPrice = this.config.maxPrice;
26
+ if (this.config.shortenUrls) messageData.shortenUrls = true;
27
+ const to = this.config.debugTo || targets.to;
28
+ try {
29
+ await this.#client.messages.create({
30
+ ...messageData,
31
+ to
32
+ });
33
+ } catch (error) {
34
+ if (this.config.ignoredErrorCodes && error.code) {
35
+ const isIgnored = this.config.ignoredErrorCodes.includes(error.code) || this.config.ignoredErrorCodes.includes("*");
36
+ if (isIgnored) return;
37
+ }
38
+ throw error;
39
+ }
40
+ }
41
+ #resolveTargets(options) {
42
+ if (options.targets) return options.targets;
43
+ throw new errors.E_UNAVAILABLE_TARGETS(["Twilio"]);
44
+ }
45
+ #resolveFrom(message, targets) {
46
+ if (message.getFrom()) return message.getFrom();
47
+ if (targets.from) return targets.from;
48
+ if (this.config.from) return this.config.from;
49
+ if (message.getAlphanumericSender()) return message.getAlphanumericSender();
50
+ if (this.config.alphanumericSender) return this.config.alphanumericSender;
51
+ return void 0;
52
+ }
53
+ };
54
+
55
+ //#endregion
56
+ export { TwilioChannel, twilioChannel };
@@ -0,0 +1,4 @@
1
+ import { TwilioMessage } from "./message.js";
2
+ import { TwilioConfig, TwilioTargets } from "./types.js";
3
+ import { TwilioChannel, twilioChannel } from "./channel.js";
4
+ export { TwilioChannel, type TwilioConfig, TwilioMessage, type TwilioTargets, twilioChannel };
@@ -0,0 +1,4 @@
1
+ import { TwilioMessage } from "./message.js";
2
+ import { TwilioChannel, twilioChannel } from "./channel.js";
3
+
4
+ export { TwilioChannel, TwilioMessage, twilioChannel };
@@ -0,0 +1,86 @@
1
+ //#region src/channels/twilio/message.d.ts
2
+ declare class TwilioMessage {
3
+ #private;
4
+ /**
5
+ * Creates a new instance of TwilioMessage
6
+ */
7
+ static create(): TwilioMessage;
8
+ /**
9
+ * Sets the message content/body
10
+ */
11
+ setBody(body: string): this;
12
+ /**
13
+ * Gets the message body
14
+ */
15
+ getBody(): string;
16
+ /**
17
+ * Sets the sender phone number
18
+ */
19
+ setFrom(from: string): this;
20
+ /**
21
+ * Gets the sender phone number
22
+ */
23
+ getFrom(): string | undefined;
24
+ /**
25
+ * Sets the messaging service SID
26
+ */
27
+ setMessagingServiceSid(sid: string): this;
28
+ /**
29
+ * Gets the messaging service SID.
30
+ */
31
+ getMessagingServiceSid(): string | undefined;
32
+ /**
33
+ * Sets the alphanumeric sender
34
+ */
35
+ setAlphanumericSender(sender: string): this;
36
+ /**
37
+ * Gets the alphanumeric sender
38
+ */
39
+ getAlphanumericSender(): string | undefined;
40
+ /**
41
+ * Sets the maximum price per message in USD
42
+ */
43
+ setMaxPrice(price: number): this;
44
+ /**
45
+ * Gets the maximum price.
46
+ */
47
+ getMaxPrice(): number | undefined;
48
+ /**
49
+ * Sets the validity period in seconds
50
+ */
51
+ setValidityPeriod(seconds: number): this;
52
+ /**
53
+ * Gets the validity period.
54
+ */
55
+ getValidityPeriod(): number | undefined;
56
+ /**
57
+ * Sets force delivery option.
58
+ */
59
+ setForceDelivery(force: boolean): this;
60
+ /**
61
+ * Gets force delivery option
62
+ */
63
+ getForceDelivery(): boolean | undefined;
64
+ /**
65
+ * Sets provide feedback option
66
+ */
67
+ setProvideFeedback(provide: boolean): this;
68
+ /**
69
+ * Gets provide feedback option.
70
+ */
71
+ getProvideFeedback(): boolean | undefined;
72
+ /**
73
+ * Sets the application SID for status callbacks.
74
+ */
75
+ setApplicationSid(sid: string): this;
76
+ /**
77
+ * Gets the application SID
78
+ */
79
+ getApplicationSid(): string | undefined;
80
+ /**
81
+ * Serializes the message to Twilio API format
82
+ */
83
+ serialize(): Record<string, any>;
84
+ }
85
+ //#endregion
86
+ export { TwilioMessage };