@wopr-network/platform-core 1.62.0 → 1.63.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.
@@ -48,7 +48,20 @@ export declare class EmailClient {
48
48
  /** Send a transactional email. */
49
49
  send(opts: SendTemplateEmailOpts): Promise<EmailSendResult>;
50
50
  }
51
- export declare function getEmailClient(): EmailClient;
51
+ export interface EmailClientOverrides {
52
+ /** Sender address — overrides EMAIL_FROM env var. */
53
+ from?: string;
54
+ /** Reply-to address — overrides EMAIL_REPLY_TO env var. */
55
+ replyTo?: string;
56
+ }
57
+ /**
58
+ * Create a lazily-initialized singleton EmailClient.
59
+ *
60
+ * Optional overrides (from DB-driven product config) take precedence
61
+ * over env vars. Pass them on first call; subsequent calls return the
62
+ * cached singleton.
63
+ */
64
+ export declare function getEmailClient(overrides?: EmailClientOverrides): EmailClient;
52
65
  /** Reset the singleton (for testing). */
53
66
  export declare function resetEmailClient(): void;
54
67
  /** Replace the singleton (for testing). */
@@ -117,10 +117,17 @@ class ResendTransport {
117
117
  * - RESEND_REPLY_TO → falls back if EMAIL_REPLY_TO is not set
118
118
  */
119
119
  let _client = null;
120
- export function getEmailClient() {
120
+ /**
121
+ * Create a lazily-initialized singleton EmailClient.
122
+ *
123
+ * Optional overrides (from DB-driven product config) take precedence
124
+ * over env vars. Pass them on first call; subsequent calls return the
125
+ * cached singleton.
126
+ */
127
+ export function getEmailClient(overrides) {
121
128
  if (!_client) {
122
- const from = process.env.EMAIL_FROM || process.env.RESEND_FROM || "noreply@wopr.bot";
123
- const replyTo = process.env.EMAIL_REPLY_TO || process.env.RESEND_REPLY_TO || "support@wopr.bot";
129
+ const from = overrides?.from || process.env.EMAIL_FROM || process.env.RESEND_FROM || "noreply@wopr.bot";
130
+ const replyTo = overrides?.replyTo || process.env.EMAIL_REPLY_TO || process.env.RESEND_REPLY_TO || "support@wopr.bot";
124
131
  const sesRegion = process.env.AWS_SES_REGION;
125
132
  if (sesRegion) {
126
133
  const transport = new SesTransport({
@@ -10,7 +10,7 @@
10
10
  */
11
11
  export type { BillingEmailServiceConfig, BillingEmailType } from "./billing-emails.js";
12
12
  export { BillingEmailService } from "./billing-emails.js";
13
- export type { EmailClientConfig, EmailSendResult, SendTemplateEmailOpts } from "./client.js";
13
+ export type { EmailClientConfig, EmailClientOverrides, EmailSendResult, SendTemplateEmailOpts } from "./client.js";
14
14
  export { EmailClient, getEmailClient, resetEmailClient, setEmailClient } from "./client.js";
15
15
  export { DEFAULT_TEMPLATES } from "./default-templates.js";
16
16
  export type { IBillingEmailRepository } from "./drizzle-billing-email-repository.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopr-network/platform-core",
3
- "version": "1.62.0",
3
+ "version": "1.63.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -158,10 +158,25 @@ class ResendTransport implements EmailTransport {
158
158
  */
159
159
  let _client: EmailClient | null = null;
160
160
 
161
- export function getEmailClient(): EmailClient {
161
+ export interface EmailClientOverrides {
162
+ /** Sender address — overrides EMAIL_FROM env var. */
163
+ from?: string;
164
+ /** Reply-to address — overrides EMAIL_REPLY_TO env var. */
165
+ replyTo?: string;
166
+ }
167
+
168
+ /**
169
+ * Create a lazily-initialized singleton EmailClient.
170
+ *
171
+ * Optional overrides (from DB-driven product config) take precedence
172
+ * over env vars. Pass them on first call; subsequent calls return the
173
+ * cached singleton.
174
+ */
175
+ export function getEmailClient(overrides?: EmailClientOverrides): EmailClient {
162
176
  if (!_client) {
163
- const from = process.env.EMAIL_FROM || process.env.RESEND_FROM || "noreply@wopr.bot";
164
- const replyTo = process.env.EMAIL_REPLY_TO || process.env.RESEND_REPLY_TO || "support@wopr.bot";
177
+ const from = overrides?.from || process.env.EMAIL_FROM || process.env.RESEND_FROM || "noreply@wopr.bot";
178
+ const replyTo =
179
+ overrides?.replyTo || process.env.EMAIL_REPLY_TO || process.env.RESEND_REPLY_TO || "support@wopr.bot";
165
180
 
166
181
  const sesRegion = process.env.AWS_SES_REGION;
167
182
  if (sesRegion) {
@@ -11,7 +11,7 @@
11
11
 
12
12
  export type { BillingEmailServiceConfig, BillingEmailType } from "./billing-emails.js";
13
13
  export { BillingEmailService } from "./billing-emails.js";
14
- export type { EmailClientConfig, EmailSendResult, SendTemplateEmailOpts } from "./client.js";
14
+ export type { EmailClientConfig, EmailClientOverrides, EmailSendResult, SendTemplateEmailOpts } from "./client.js";
15
15
  export { EmailClient, getEmailClient, resetEmailClient, setEmailClient } from "./client.js";
16
16
  export { DEFAULT_TEMPLATES } from "./default-templates.js";
17
17
  export type { IBillingEmailRepository } from "./drizzle-billing-email-repository.js";