vintasend 0.2.3 → 0.4.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 (133) hide show
  1. package/README.md +227 -12
  2. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/next.config.d.ts +1 -1
  3. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/next.config.js +9 -4
  4. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/forgot-password-notification-context.d.ts +6 -6
  5. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/forgot-password-notification-context.js +16 -17
  6. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/route.d.ts +7 -5
  7. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/route.js +105 -79
  8. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/login/route.d.ts +4 -5
  9. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/login/route.js +96 -66
  10. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.d.ts +7 -5
  11. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.js +95 -71
  12. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/email-verification-notification-context.d.ts +6 -6
  13. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/email-verification-notification-context.js +18 -18
  14. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.d.ts +4 -5
  15. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.js +124 -96
  16. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/verify-email/route.d.ts +7 -5
  17. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/verify-email/route.js +94 -70
  18. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/login/page.d.ts +1 -1
  19. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/login/page.js +67 -55
  20. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/reset-password/[token]/page.d.ts +1 -1
  21. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/reset-password/[token]/page.js +76 -63
  22. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/signup/page.d.ts +1 -1
  23. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/signup/page.js +87 -63
  24. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email/[token]/page.d.ts +1 -1
  25. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email/[token]/page.js +50 -35
  26. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email-sent/page.d.ts +1 -1
  27. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email-sent/page.js +12 -12
  28. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/layout.d.ts +7 -5
  29. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/layout.js +15 -16
  30. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/page.d.ts +1 -1
  31. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/page.js +65 -21
  32. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/AuthLayout.d.ts +7 -4
  33. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/AuthLayout.js +7 -8
  34. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/accordion.d.ts +18 -6
  35. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/accordion.js +86 -48
  36. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert-dialog.d.ts +58 -14
  37. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert-dialog.js +135 -53
  38. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert.d.ts +21 -7
  39. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert.js +85 -49
  40. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/avatar.d.ts +14 -5
  41. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/avatar.js +77 -40
  42. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/button.d.ts +25 -9
  43. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/button.js +80 -58
  44. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/card.d.ts +19 -7
  45. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/card.js +98 -48
  46. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/checkbox.d.ts +6 -3
  47. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/checkbox.js +66 -42
  48. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/collapsible.d.ts +10 -4
  49. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/collapsible.js +48 -35
  50. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dialog.d.ts +40 -13
  51. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dialog.js +116 -50
  52. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dropdown-menu.d.ts +83 -19
  53. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dropdown-menu.js +170 -68
  54. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/form.d.ts +53 -21
  55. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/form.js +137 -83
  56. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/input.d.ts +8 -2
  57. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/input.js +60 -37
  58. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/label.d.ts +10 -4
  59. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/label.js +61 -40
  60. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/menubar.d.ts +77 -23
  61. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/menubar.js +188 -64
  62. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/select.d.ts +48 -12
  63. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/select.js +148 -66
  64. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/textarea.d.ts +8 -2
  65. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/textarea.js +59 -37
  66. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/auth.d.ts +10 -10
  67. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/auth.js +54 -55
  68. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/core.d.ts +14 -11
  69. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/core.js +1 -2
  70. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/email.js +0 -1
  71. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/logger.d.ts +3 -3
  72. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/logger.js +9 -10
  73. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/schemas/auth.d.ts +66 -32
  74. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/schemas/auth.js +74 -54
  75. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/auth.js +7 -8
  76. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications-with-queue.d.ts +14 -4
  77. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications-with-queue.js +14 -10
  78. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications.d.ts +11 -7
  79. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications.js +39 -26
  80. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/temporal-queue-service.d.ts +11 -8
  81. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/temporal-queue-service.js +14 -15
  82. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/temporal.d.ts +1 -1
  83. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/temporal.js +9 -10
  84. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/utils.d.ts +1 -1
  85. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/utils.js +4 -5
  86. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/activities.d.ts +6 -5
  87. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/activities.js +14 -14
  88. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/config.d.ts +1 -1
  89. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/config.js +2 -3
  90. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/constants.d.ts +1 -1
  91. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/constants.js +1 -2
  92. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/worker.js +20 -22
  93. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/workflows.d.ts +3 -2
  94. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/workflows.js +10 -9
  95. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/tailwind.config.d.ts +74 -74
  96. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/tailwind.config.js +80 -81
  97. package/dist/implementations/vintasend-nodemailer/src/index.js +6 -4
  98. package/dist/implementations/vintasend-nodemailer/src/nodemailer-notification-adapter.d.ts +36 -14
  99. package/dist/implementations/vintasend-nodemailer/src/nodemailer-notification-adapter.js +26 -28
  100. package/dist/implementations/vintasend-prisma/src/index.js +6 -4
  101. package/dist/implementations/vintasend-prisma/src/prisma-notification-backend.d.ts +232 -138
  102. package/dist/implementations/vintasend-prisma/src/prisma-notification-backend.js +275 -262
  103. package/dist/implementations/vintasend-pug/src/index.js +6 -4
  104. package/dist/implementations/vintasend-pug/src/pug-email-template-renderer.d.ts +18 -7
  105. package/dist/implementations/vintasend-pug/src/pug-email-template-renderer.js +19 -21
  106. package/dist/implementations/vintasend-winston/src/index.js +6 -4
  107. package/dist/implementations/vintasend-winston/src/winston-logger.d.ts +6 -6
  108. package/dist/implementations/vintasend-winston/src/winston-logger.js +65 -50
  109. package/dist/index.d.ts +13 -5
  110. package/dist/index.js +13 -1
  111. package/dist/services/attachment-manager/base-attachment-manager.d.ts +42 -0
  112. package/dist/services/attachment-manager/base-attachment-manager.js +115 -0
  113. package/dist/services/attachment-manager/local-file-attachment-manager.d.ts +58 -0
  114. package/dist/services/attachment-manager/local-file-attachment-manager.js +192 -0
  115. package/dist/services/notification-adapters/base-notification-adapter.d.ts +36 -4
  116. package/dist/services/notification-adapters/base-notification-adapter.js +73 -4
  117. package/dist/services/notification-backends/base-notification-backend.d.ts +54 -11
  118. package/dist/services/notification-backends/base-notification-backend.js +12 -0
  119. package/dist/services/notification-context-generators-map.d.ts +1 -1
  120. package/dist/services/notification-context-registry.d.ts +14 -9
  121. package/dist/services/notification-context-registry.js +30 -31
  122. package/dist/services/notification-queue-service/base-notification-queue-service.d.ts +1 -1
  123. package/dist/services/notification-service.d.ts +73 -13
  124. package/dist/services/notification-service.js +125 -8
  125. package/dist/services/notification-template-renderers/base-email-template-renderer.d.ts +3 -3
  126. package/dist/services/notification-template-renderers/base-notification-template-renderer.d.ts +2 -2
  127. package/dist/types/attachment.d.ts +42 -0
  128. package/dist/types/attachment.js +7 -0
  129. package/dist/types/notification-type-config.d.ts +2 -2
  130. package/dist/types/notification.d.ts +21 -0
  131. package/dist/types/one-off-notification.d.ts +72 -0
  132. package/dist/types/one-off-notification.js +2 -0
  133. package/package.json +13 -11
@@ -1,9 +1,9 @@
1
1
  import type { BaseLogger } from 'vintasend/src/services/loggers/base-logger';
2
- import * as winston from 'winston';
2
+ import type * as winston from 'winston';
3
3
  export declare class WinstonLogger implements BaseLogger {
4
- private logger;
5
- constructor(winstonOptions?: Parameters<typeof winston.createLogger>[0]);
6
- info(message: string): void;
7
- error(message: string): void;
8
- warn(message: string): void;
4
+ private logger;
5
+ constructor(winstonOptions?: Parameters<typeof winston.createLogger>[0]);
6
+ info(message: string): void;
7
+ error(message: string): void;
8
+ warn(message: string): void;
9
9
  }
@@ -1,57 +1,72 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
1
+ var __createBinding =
2
+ (this && this.__createBinding) ||
3
+ (Object.create
4
+ ? (o, m, k, k2) => {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: () => m[k] };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }
12
+ : (o, m, k, k2) => {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ });
16
+ var __setModuleDefault =
17
+ (this && this.__setModuleDefault) ||
18
+ (Object.create
19
+ ? (o, v) => {
20
+ Object.defineProperty(o, 'default', { enumerable: true, value: v });
21
+ }
22
+ : (o, v) => {
23
+ o['default'] = v;
24
+ });
25
+ var __importStar =
26
+ (this && this.__importStar) ||
27
+ (() => {
28
+ var ownKeys = (o) => {
29
+ ownKeys =
30
+ Object.getOwnPropertyNames ||
31
+ ((o) => {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ });
36
+ return ownKeys(o);
26
37
  };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
38
+ return (mod) => {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null)
42
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++)
43
+ if (k[i] !== 'default') __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
33
46
  };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
47
+ })();
48
+ Object.defineProperty(exports, '__esModule', { value: true });
36
49
  exports.WinstonLogger = void 0;
37
- const winston = __importStar(require("winston"));
50
+ const winston = __importStar(require('winston'));
38
51
  class WinstonLogger {
39
- constructor(winstonOptions) {
40
- this.logger = winston.createLogger(winstonOptions || {});
41
- if (process.env.NODE_ENV === 'development') {
42
- this.logger.add(new winston.transports.Console({
43
- format: winston.format.simple(),
44
- }));
45
- }
46
- }
47
- info(message) {
48
- this.logger.info(message);
49
- }
50
- error(message) {
51
- this.logger.error(message);
52
- }
53
- warn(message) {
54
- this.logger.warn(message);
52
+ constructor(winstonOptions) {
53
+ this.logger = winston.createLogger(winstonOptions || {});
54
+ if (process.env.NODE_ENV === 'development') {
55
+ this.logger.add(
56
+ new winston.transports.Console({
57
+ format: winston.format.simple(),
58
+ }),
59
+ );
55
60
  }
61
+ }
62
+ info(message) {
63
+ this.logger.info(message);
64
+ }
65
+ error(message) {
66
+ this.logger.error(message);
67
+ }
68
+ warn(message) {
69
+ this.logger.warn(message);
70
+ }
56
71
  }
57
72
  exports.WinstonLogger = WinstonLogger;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,16 @@
1
- export { VintaSendFactory } from './services/notification-service';
1
+ export { BaseAttachmentManager } from './services/attachment-manager/base-attachment-manager';
2
+ export type { LocalFileAttachmentManagerConfig } from './services/attachment-manager/local-file-attachment-manager';
3
+ export { LocalFileAttachmentManager } from './services/attachment-manager/local-file-attachment-manager';
4
+ export { BaseNotificationAdapter, isOneOffNotification, } from './services/notification-adapters/base-notification-adapter';
5
+ export type { BaseNotificationBackend } from './services/notification-backends/base-notification-backend';
6
+ export { supportsAttachments } from './services/notification-backends/base-notification-backend';
7
+ export type { BaseNotificationQueueService } from './services/notification-queue-service/base-notification-queue-service';
2
8
  export type { VintaSend } from './services/notification-service';
3
- export type { Notification, DatabaseNotification, NotificationInput, NotificationResendWithContextInput, } from './types/notification';
9
+ export { VintaSendFactory } from './services/notification-service';
10
+ export type { BaseEmailTemplateRenderer } from './services/notification-template-renderers/base-email-template-renderer';
11
+ export type { BaseNotificationTemplateRenderer } from './services/notification-template-renderers/base-notification-template-renderer';
12
+ export type { AttachmentFile, AttachmentFileRecord, FileAttachment, NotificationAttachment, NotificationAttachmentReference, NotificationAttachmentUpload, StoredAttachment, } from './types/attachment';
13
+ export { isAttachmentReference } from './types/attachment';
14
+ export type { AnyDatabaseNotification, AnyNotification, AnyNotificationInput, DatabaseNotification, DatabaseOneOffNotification, Notification, NotificationInput, NotificationResendWithContextInput, OneOffNotification, OneOffNotificationInput, OneOffNotificationResendWithContextInput, } from './types/notification';
4
15
  export type { ContextGenerator } from './types/notification-context-generators';
5
16
  export type { BaseNotificationTypeConfig } from './types/notification-type-config';
6
- export type { BaseNotificationQueueService } from './services/notification-queue-service/base-notification-queue-service';
7
- export type { BaseNotificationTemplateRenderer } from './services/notification-template-renderers/base-notification-template-renderer';
8
- export type { BaseEmailTemplateRenderer } from './services/notification-template-renderers/base-email-template-renderer';
package/dist/index.js CHANGED
@@ -1,5 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VintaSendFactory = void 0;
3
+ exports.isAttachmentReference = exports.VintaSendFactory = exports.supportsAttachments = exports.isOneOffNotification = exports.BaseNotificationAdapter = exports.LocalFileAttachmentManager = exports.BaseAttachmentManager = void 0;
4
+ // Attachment Manager
5
+ var base_attachment_manager_1 = require("./services/attachment-manager/base-attachment-manager");
6
+ Object.defineProperty(exports, "BaseAttachmentManager", { enumerable: true, get: function () { return base_attachment_manager_1.BaseAttachmentManager; } });
7
+ var local_file_attachment_manager_1 = require("./services/attachment-manager/local-file-attachment-manager");
8
+ Object.defineProperty(exports, "LocalFileAttachmentManager", { enumerable: true, get: function () { return local_file_attachment_manager_1.LocalFileAttachmentManager; } });
9
+ var base_notification_adapter_1 = require("./services/notification-adapters/base-notification-adapter");
10
+ Object.defineProperty(exports, "BaseNotificationAdapter", { enumerable: true, get: function () { return base_notification_adapter_1.BaseNotificationAdapter; } });
11
+ Object.defineProperty(exports, "isOneOffNotification", { enumerable: true, get: function () { return base_notification_adapter_1.isOneOffNotification; } });
12
+ var base_notification_backend_1 = require("./services/notification-backends/base-notification-backend");
13
+ Object.defineProperty(exports, "supportsAttachments", { enumerable: true, get: function () { return base_notification_backend_1.supportsAttachments; } });
4
14
  var notification_service_1 = require("./services/notification-service");
5
15
  Object.defineProperty(exports, "VintaSendFactory", { enumerable: true, get: function () { return notification_service_1.VintaSendFactory; } });
16
+ var attachment_1 = require("./types/attachment");
17
+ Object.defineProperty(exports, "isAttachmentReference", { enumerable: true, get: function () { return attachment_1.isAttachmentReference; } });
@@ -0,0 +1,42 @@
1
+ import type { AttachmentFile, AttachmentFileRecord, FileAttachment } from '../../types/attachment';
2
+ export declare abstract class BaseAttachmentManager {
3
+ /**
4
+ * Upload a file and return file record (reusable across notifications)
5
+ */
6
+ abstract uploadFile(file: FileAttachment, filename: string, contentType?: string): Promise<AttachmentFileRecord>;
7
+ /**
8
+ * Delete a file (only if not referenced by any notifications)
9
+ */
10
+ abstract deleteFile(fileId: string): Promise<void>;
11
+ /**
12
+ * Reconstruct AttachmentFile from storage metadata
13
+ */
14
+ abstract reconstructAttachmentFile(storageMetadata: Record<string, unknown>): AttachmentFile;
15
+ /**
16
+ * Detect content type from filename
17
+ * Public to allow backends and custom implementations to use it
18
+ */
19
+ detectContentType(filename: string): string;
20
+ /**
21
+ * Calculate checksum for file data
22
+ * Public to allow backends to perform deduplication checks
23
+ */
24
+ calculateChecksum(data: Buffer): string;
25
+ /**
26
+ * Convert various file formats to Buffer
27
+ * Public to allow backends and custom implementations to use it
28
+ */
29
+ fileToBuffer(file: FileAttachment): Promise<Buffer>;
30
+ /**
31
+ * Type guard to check if value is a Node.js Readable stream
32
+ */
33
+ private isNodeReadable;
34
+ /**
35
+ * Convert Web ReadableStream to Buffer
36
+ */
37
+ private webStreamToBuffer;
38
+ /**
39
+ * Convert Node.js Readable stream to Buffer
40
+ */
41
+ private nodeStreamToBuffer;
42
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BaseAttachmentManager = void 0;
37
+ const crypto = __importStar(require("node:crypto"));
38
+ const mime = __importStar(require("mime-types"));
39
+ class BaseAttachmentManager {
40
+ /**
41
+ * Detect content type from filename
42
+ * Public to allow backends and custom implementations to use it
43
+ */
44
+ detectContentType(filename) {
45
+ return mime.lookup(filename) || 'application/octet-stream';
46
+ }
47
+ /**
48
+ * Calculate checksum for file data
49
+ * Public to allow backends to perform deduplication checks
50
+ */
51
+ calculateChecksum(data) {
52
+ return crypto.createHash('sha256').update(data).digest('hex');
53
+ }
54
+ /**
55
+ * Convert various file formats to Buffer
56
+ * Public to allow backends and custom implementations to use it
57
+ */
58
+ async fileToBuffer(file) {
59
+ if (Buffer.isBuffer(file)) {
60
+ return file;
61
+ }
62
+ // Support both Web ReadableStream and Node.js Readable streams
63
+ if (typeof ReadableStream !== 'undefined' && file instanceof ReadableStream) {
64
+ return this.webStreamToBuffer(file);
65
+ }
66
+ // Check for Node.js Readable stream
67
+ if (this.isNodeReadable(file)) {
68
+ return this.nodeStreamToBuffer(file);
69
+ }
70
+ if (typeof file === 'string') {
71
+ const fs = await Promise.resolve().then(() => __importStar(require('node:fs/promises')));
72
+ return fs.readFile(file);
73
+ }
74
+ throw new Error('Unsupported file type');
75
+ }
76
+ /**
77
+ * Type guard to check if value is a Node.js Readable stream
78
+ */
79
+ isNodeReadable(value) {
80
+ return (typeof value === 'object' &&
81
+ value !== null &&
82
+ // biome-ignore lint/suspicious/noExplicitAny: checking for stream methods
83
+ typeof value.read === 'function' &&
84
+ // biome-ignore lint/suspicious/noExplicitAny: checking for stream methods
85
+ typeof value.on === 'function' &&
86
+ // biome-ignore lint/suspicious/noExplicitAny: checking for stream methods
87
+ typeof value.pipe === 'function');
88
+ }
89
+ /**
90
+ * Convert Web ReadableStream to Buffer
91
+ */
92
+ async webStreamToBuffer(stream) {
93
+ const reader = stream.getReader();
94
+ const chunks = [];
95
+ while (true) {
96
+ const { done, value } = await reader.read();
97
+ if (done)
98
+ break;
99
+ chunks.push(value);
100
+ }
101
+ return Buffer.concat(chunks);
102
+ }
103
+ /**
104
+ * Convert Node.js Readable stream to Buffer
105
+ */
106
+ async nodeStreamToBuffer(stream) {
107
+ const chunks = [];
108
+ return new Promise((resolve, reject) => {
109
+ stream.on('data', (chunk) => chunks.push(chunk));
110
+ stream.on('error', reject);
111
+ stream.on('end', () => resolve(Buffer.concat(chunks)));
112
+ });
113
+ }
114
+ }
115
+ exports.BaseAttachmentManager = BaseAttachmentManager;
@@ -0,0 +1,58 @@
1
+ import type { AttachmentFile, AttachmentFileRecord, FileAttachment } from '../../types/attachment';
2
+ import { BaseAttachmentManager } from './base-attachment-manager';
3
+ /**
4
+ * Configuration options for LocalFileAttachmentManager
5
+ */
6
+ export interface LocalFileAttachmentManagerConfig {
7
+ /**
8
+ * Base directory where attachment files will be stored
9
+ * Defaults to './attachments' relative to process.cwd()
10
+ */
11
+ baseDirectory?: string;
12
+ /**
13
+ * Whether to create the base directory if it doesn't exist
14
+ * Defaults to true
15
+ */
16
+ createDirectoryIfNotExists?: boolean;
17
+ }
18
+ /**
19
+ * Local filesystem-based attachment manager for development and testing.
20
+ *
21
+ * WARNING: This implementation is NOT recommended for production use.
22
+ * Use cloud storage solutions (S3, Azure Blob, GCS) for production.
23
+ *
24
+ * Features:
25
+ * - Simple filesystem-based storage
26
+ * - No external dependencies beyond Node.js
27
+ * - Useful for development and testing
28
+ * - Quick setup for prototyping
29
+ *
30
+ * Limitations:
31
+ * - Not scalable across multiple servers
32
+ * - No built-in redundancy or backup
33
+ * - File URLs are local file paths, not HTTP URLs
34
+ * - Performance degrades with large numbers of files
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const attachmentManager = new LocalFileAttachmentManager({
39
+ * baseDirectory: './uploads/attachments'
40
+ * });
41
+ * ```
42
+ */
43
+ export declare class LocalFileAttachmentManager extends BaseAttachmentManager {
44
+ private baseDirectory;
45
+ constructor(config?: LocalFileAttachmentManagerConfig);
46
+ /**
47
+ * Upload a file to the local filesystem
48
+ */
49
+ uploadFile(file: FileAttachment, filename: string, contentType?: string): Promise<AttachmentFileRecord>;
50
+ /**
51
+ * Delete a file from the local filesystem
52
+ */
53
+ deleteFile(fileId: string): Promise<void>;
54
+ /**
55
+ * Reconstruct an AttachmentFile interface from stored metadata
56
+ */
57
+ reconstructAttachmentFile(storageMetadata: Record<string, unknown>): AttachmentFile;
58
+ }
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.LocalFileAttachmentManager = void 0;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ const node_stream_1 = require("node:stream");
40
+ const node_util_1 = require("node:util");
41
+ const base_attachment_manager_1 = require("./base-attachment-manager");
42
+ const writeFile = (0, node_util_1.promisify)(fs.writeFile);
43
+ const readFile = (0, node_util_1.promisify)(fs.readFile);
44
+ const unlink = (0, node_util_1.promisify)(fs.unlink);
45
+ const access = (0, node_util_1.promisify)(fs.access);
46
+ /**
47
+ * Local filesystem-based attachment manager for development and testing.
48
+ *
49
+ * WARNING: This implementation is NOT recommended for production use.
50
+ * Use cloud storage solutions (S3, Azure Blob, GCS) for production.
51
+ *
52
+ * Features:
53
+ * - Simple filesystem-based storage
54
+ * - No external dependencies beyond Node.js
55
+ * - Useful for development and testing
56
+ * - Quick setup for prototyping
57
+ *
58
+ * Limitations:
59
+ * - Not scalable across multiple servers
60
+ * - No built-in redundancy or backup
61
+ * - File URLs are local file paths, not HTTP URLs
62
+ * - Performance degrades with large numbers of files
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const attachmentManager = new LocalFileAttachmentManager({
67
+ * baseDirectory: './uploads/attachments'
68
+ * });
69
+ * ```
70
+ */
71
+ class LocalFileAttachmentManager extends base_attachment_manager_1.BaseAttachmentManager {
72
+ constructor(config = {}) {
73
+ super();
74
+ this.baseDirectory = config.baseDirectory || './attachments';
75
+ if (config.createDirectoryIfNotExists !== false) {
76
+ // Create directory synchronously during construction
77
+ if (!fs.existsSync(this.baseDirectory)) {
78
+ fs.mkdirSync(this.baseDirectory, { recursive: true });
79
+ }
80
+ }
81
+ }
82
+ /**
83
+ * Upload a file to the local filesystem
84
+ */
85
+ async uploadFile(file, filename, contentType) {
86
+ // Convert file to buffer
87
+ const buffer = await this.fileToBuffer(file);
88
+ // Detect content type if not provided
89
+ const finalContentType = contentType || this.detectContentType(filename);
90
+ // Calculate checksum
91
+ const checksum = this.calculateChecksum(buffer);
92
+ // Generate unique file ID
93
+ const fileId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
94
+ // Sanitize filename to prevent directory traversal
95
+ const sanitizedFilename = path.basename(filename);
96
+ // Create file path
97
+ const filePath = path.join(this.baseDirectory, fileId);
98
+ // Write file to disk
99
+ await writeFile(filePath, buffer);
100
+ // Get file size
101
+ const size = buffer.length;
102
+ // Return file record
103
+ return {
104
+ id: fileId,
105
+ filename: sanitizedFilename,
106
+ contentType: finalContentType,
107
+ size,
108
+ checksum,
109
+ storageMetadata: {
110
+ path: filePath,
111
+ backend: 'local-filesystem',
112
+ },
113
+ createdAt: new Date(),
114
+ updatedAt: new Date(),
115
+ };
116
+ }
117
+ /**
118
+ * Delete a file from the local filesystem
119
+ */
120
+ async deleteFile(fileId) {
121
+ const filePath = path.join(this.baseDirectory, fileId);
122
+ try {
123
+ await access(filePath, fs.constants.F_OK);
124
+ await unlink(filePath);
125
+ }
126
+ catch (error) {
127
+ if (error.code === 'ENOENT') {
128
+ // File doesn't exist, consider it already deleted
129
+ return;
130
+ }
131
+ throw error;
132
+ }
133
+ }
134
+ /**
135
+ * Reconstruct an AttachmentFile interface from stored metadata
136
+ */
137
+ reconstructAttachmentFile(storageMetadata) {
138
+ if (!storageMetadata.path || typeof storageMetadata.path !== 'string') {
139
+ throw new Error('Invalid storage metadata: missing path');
140
+ }
141
+ const filePath = storageMetadata.path;
142
+ return new LocalAttachmentFile(filePath, this);
143
+ }
144
+ }
145
+ exports.LocalFileAttachmentManager = LocalFileAttachmentManager;
146
+ /**
147
+ * Local filesystem implementation of AttachmentFile interface
148
+ */
149
+ class LocalAttachmentFile {
150
+ constructor(filePath, manager) {
151
+ this.filePath = filePath;
152
+ this.manager = manager;
153
+ }
154
+ /**
155
+ * Read the entire file into memory as a Buffer
156
+ */
157
+ async read() {
158
+ try {
159
+ return await readFile(this.filePath);
160
+ }
161
+ catch (error) {
162
+ throw new Error(`Failed to read file ${this.filePath}: ${error instanceof Error ? error.message : String(error)}`);
163
+ }
164
+ }
165
+ /**
166
+ * Get a readable stream for the file
167
+ */
168
+ async stream() {
169
+ const nodeStream = fs.createReadStream(this.filePath);
170
+ // Convert Node.js Readable to Web ReadableStream
171
+ return node_stream_1.Readable.toWeb(nodeStream);
172
+ }
173
+ /**
174
+ * Get a local file path (not an HTTP URL)
175
+ *
176
+ * WARNING: This returns a local file path, not an HTTP URL.
177
+ * This is only useful for development/testing scenarios.
178
+ */
179
+ async url(_expiresIn) {
180
+ // For local files, just return the absolute file path
181
+ // Note: This is not an HTTP URL and won't work in browsers
182
+ return `file://${path.resolve(this.filePath)}`;
183
+ }
184
+ /**
185
+ * Delete the file from local filesystem
186
+ */
187
+ async delete() {
188
+ // Extract file ID from path (last component)
189
+ const fileId = path.basename(this.filePath);
190
+ await this.manager.deleteFile(fileId);
191
+ }
192
+ }
@@ -1,16 +1,48 @@
1
- import type { NotificationType } from '../../types/notification-type';
2
- import type { DatabaseNotification } from '../../types/notification';
3
- import type { BaseNotificationTemplateRenderer } from '../notification-template-renderers/base-notification-template-renderer';
1
+ import type { StoredAttachment } from '../../types/attachment';
4
2
  import type { JsonValue } from '../../types/json-values';
3
+ import type { AnyDatabaseNotification, DatabaseOneOffNotification } from '../../types/notification';
4
+ import type { NotificationType } from '../../types/notification-type';
5
5
  import type { BaseNotificationTypeConfig } from '../../types/notification-type-config';
6
+ import type { BaseLogger } from '../loggers/base-logger';
6
7
  import type { BaseNotificationBackend } from '../notification-backends/base-notification-backend';
8
+ import type { BaseNotificationTemplateRenderer } from '../notification-template-renderers/base-notification-template-renderer';
9
+ /**
10
+ * Type guard to check if a notification is a one-off notification
11
+ */
12
+ export declare function isOneOffNotification<Config extends BaseNotificationTypeConfig>(notification: AnyDatabaseNotification<Config>): notification is DatabaseOneOffNotification<Config>;
7
13
  export declare abstract class BaseNotificationAdapter<TemplateRenderer extends BaseNotificationTemplateRenderer<Config>, Config extends BaseNotificationTypeConfig> {
8
14
  protected templateRenderer: TemplateRenderer;
9
15
  readonly notificationType: NotificationType;
10
16
  readonly enqueueNotifications: boolean;
11
17
  key: string | null;
12
18
  backend: BaseNotificationBackend<Config> | null;
19
+ logger: BaseLogger | null;
13
20
  constructor(templateRenderer: TemplateRenderer, notificationType: NotificationType, enqueueNotifications: boolean);
14
- send(notification: DatabaseNotification<Config>, context: JsonValue): Promise<void>;
21
+ send(_notification: AnyDatabaseNotification<Config>, _context: JsonValue): Promise<void>;
22
+ /**
23
+ * Check if this adapter supports attachments
24
+ */
25
+ get supportsAttachments(): boolean;
26
+ /**
27
+ * Prepare attachments for sending
28
+ * Override in adapters that support attachments
29
+ */
30
+ protected prepareAttachments(attachments: StoredAttachment[]): Promise<unknown>;
31
+ /**
32
+ * Get the recipient email address from a notification.
33
+ * For one-off notifications, returns the emailOrPhone field directly.
34
+ * For regular notifications, fetches the email from the user via backend.
35
+ */
36
+ protected getRecipientEmail(notification: AnyDatabaseNotification<Config>): Promise<string>;
37
+ /**
38
+ * Get the recipient name from a notification.
39
+ * For one-off notifications, returns the firstName and lastName fields directly.
40
+ * For regular notifications, attempts to extract from context or returns empty strings.
41
+ */
42
+ protected getRecipientName(notification: AnyDatabaseNotification<Config>, context: JsonValue): {
43
+ firstName: string;
44
+ lastName: string;
45
+ };
15
46
  injectBackend(backend: BaseNotificationBackend<Config>): void;
47
+ injectLogger(logger: BaseLogger): void;
16
48
  }