@lunora/mail 1.0.0-alpha.41 → 1.0.0-alpha.42
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/dist/index.mjs +1 -1
- package/dist/packem_shared/consumeQueuedSend-CrfNFyMX.mjs +1 -0
- package/dist/packem_shared/{createCaptureSink-fVjCTUBC.mjs → createCaptureSink-7-YsQqS8.mjs} +1 -1
- package/dist/packem_shared/{createMailer-CsVLrc75.mjs → createMailer-BWaX1-ma.mjs} +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/consumeQueuedSend-BXrPhND5.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCaptureTransport as a}from"./packem_shared/createCaptureTransport-BPdMkU0O.mjs";import{createCloudflareTransport as t}from"./packem_shared/createCloudflareTransport-V23CVw7F.mjs";import{default as u}from"./packem_shared/createMailer-
|
|
1
|
+
import{createCaptureTransport as a}from"./packem_shared/createCaptureTransport-BPdMkU0O.mjs";import{createCloudflareTransport as t}from"./packem_shared/createCloudflareTransport-V23CVw7F.mjs";import{default as u}from"./packem_shared/createMailer-BWaX1-ma.mjs";import{createCaptureSink as f,createMailerFromEnv as l,shouldCaptureMail as m}from"./packem_shared/createCaptureSink-7-YsQqS8.mjs";import{consumeQueuedSend as s,toQueuedPayload as c}from"./packem_shared/consumeQueuedSend-CrfNFyMX.mjs";import{default as i}from"./packem_shared/renderEmail-DM8_pWKa.mjs";import{default as M}from"./packem_shared/createResendTransport-CpSJ4j7C.mjs";export{s as consumeQueuedSend,f as createCaptureSink,a as createCaptureTransport,t as createCloudflareTransport,u as createMailer,l as createMailerFromEnv,M as createResendTransport,i as renderEmail,m as shouldCaptureMail,c as toQueuedPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as c}from"@lunora/errors";const g=a=>{const t={...a};return delete t.react,t},d=async(a,t)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new c("INTERNAL","@lunora/mail: queue message body must be an object");const e=t;if(typeof e.subject!="string")throw new TypeError("@lunora/mail: queue message must have a string `subject`");const m=typeof e.to=="string",y=Array.isArray(e.to)&&e.to.every(o=>typeof o=="string");if(!m&&!y)throw new c("INTERNAL","@lunora/mail: queue message `to` must be a string or string[]");const s=(o,r)=>{if(r!==void 0){if(typeof r!="string")throw new TypeError(`@lunora/mail: queue message \`${o}\` must be a string`);return r}},u=(o,r)=>{if(r!==void 0){if(typeof r=="string")return[r];if(Array.isArray(r)&&r.every(n=>typeof n=="string"))return r;throw new TypeError(`@lunora/mail: queue message \`${o}\` must be a string or string[]`)}};let i;if(e.headers!==void 0){if(!e.headers||typeof e.headers!="object"||Array.isArray(e.headers))throw new TypeError("@lunora/mail: queue message `headers` must be an object of string values");const o=Object.entries(e.headers);for(const[r,n]of o)if(typeof n!="string")throw new TypeError(`@lunora/mail: queue message header "${r}" must be a string`);i=e.headers}const f={bcc:u("bcc",e.bcc),cc:u("cc",e.cc),from:s("from",e.from),headers:i,html:s("html",e.html),replyTo:s("replyTo",e.replyTo),subject:e.subject,text:s("text",e.text),to:e.to};return a.send(f)};export{d as consumeQueuedSend,g as toQueuedPayload};
|
package/dist/packem_shared/{createCaptureSink-fVjCTUBC.mjs → createCaptureSink-7-YsQqS8.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as u}from"@lunora/errors";import{createCaptureTransport as s}from"./createCaptureTransport-BPdMkU0O.mjs";import n from"./createMailer-
|
|
1
|
+
import{LunoraError as u}from"@lunora/errors";import{createCaptureTransport as s}from"./createCaptureTransport-BPdMkU0O.mjs";import n from"./createMailer-BWaX1-ma.mjs";import{d as l,u as c}from"./shard-CcKsuWAm.mjs";const f="__lunora_admin__:recordMail",p=/^(?:dev(?:elopment)?|local(?:host)?|test)$/iu,m=["CF_ENV","ENVIRONMENT","NODE_ENV","WORKER_ENV"],E=(e,t)=>{const r=e[t];if(typeof r!="string"||r==="")throw new u("INTERNAL",`@lunora/mail: missing env var \`${t}\` — set it in .dev.vars (and \`wrangler secret put ${t}\` for secrets).`);return r},_=e=>{const t=e.LUNORA_MAIL_CAPTURE;if(typeof t=="string"){const r=t.toLowerCase();if(r==="1"||r==="true")return!0;if(r==="0"||r==="false")return!1;console.warn(`@lunora/mail: unrecognized LUNORA_MAIL_CAPTURE value "${t}" — expected "1"/"true" or "0"/"false"; falling back to environment detection.`)}return m.some(r=>{const o=e[r];return typeof o=="string"&&p.test(o)})},N=(e,t=l,r)=>({record:async o=>{const a=e.SHARD,i=typeof e.LUNORA_ADMIN_TOKEN=="string"?e.LUNORA_ADMIN_TOKEN:void 0;if(a===void 0||i===void 0)return{id:"uncaptured"};try{return{id:(await c(a,{adminToken:i,envelope:{args:o,functionPath:f},jurisdiction:r,label:"@lunora/mail: recording captured mail",shardKey:t})).result?.id??"captured"}}catch(d){return console.error("@lunora/mail: failed to record captured mail into the studio inbox —",d),{id:"uncaptured"}}}}),I=(e,t={})=>{const r=E(e,"MAIL_FROM");if(_(e))return n({from:r,transport:s(N(e,t.rootShard,t.jurisdiction))});if(t.cloudflareSend)return n({cloudflareSend:t.cloudflareSend,from:r});const o=typeof e.RESEND_API_KEY=="string"?e.RESEND_API_KEY:void 0;if(o!==void 0&&o!=="")return n({apiKey:o,from:r});throw new u("INTERNAL","@lunora/mail: no transport configured — provide `cloudflareSend` (a SEND_EMAIL binding) or RESEND_API_KEY, or run in a dev environment to capture.")};export{N as createCaptureSink,I as createMailerFromEnv,_ as shouldCaptureMail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as c}from"@lunora/errors";import{m as s,f}from"./address-Y4Z--6ZO.mjs";import{isCaptureTransport as d}from"./createCaptureTransport-BPdMkU0O.mjs";import{createCloudflareTransport as l}from"./createCloudflareTransport-V23CVw7F.mjs";import{toQueuedPayload as p}from"./consumeQueuedSend-
|
|
1
|
+
import{LunoraError as c}from"@lunora/errors";import{m as s,f}from"./address-Y4Z--6ZO.mjs";import{isCaptureTransport as d}from"./createCaptureTransport-BPdMkU0O.mjs";import{createCloudflareTransport as l}from"./createCloudflareTransport-V23CVw7F.mjs";import{toQueuedPayload as p}from"./consumeQueuedSend-CrfNFyMX.mjs";import h from"./renderEmail-DM8_pWKa.mjs";import w from"./createResendTransport-CpSJ4j7C.mjs";const y=e=>{if(e.cloudflareSend)return l({from:e.from,send:e.cloudflareSend});if(e.apiKey)return w(e.apiKey,e.from);throw new c("INTERNAL","@lunora/mail: a transport is required — pass `transport`, `cloudflareSend` (Cloudflare Email Workers, the default), or `apiKey` (Resend)")},L=e=>{if(!e.from)throw new c("INTERNAL","@lunora/mail: `from` is required");const u=e.transport??y(e),n=async r=>{let{html:t}=r,{text:a}=r;if(r.react){const o=await h(r.react);t=t??o.html,a=a??o.text}if(s("subject",r.subject),r.headers)for(const[o,m]of Object.entries(r.headers))s(`header name "${o}"`,o),s(`header "${o}" value`,m);const i=r.from??e.from;return f({bcc:r.bcc,cc:r.cc,from:i,replyTo:r.replyTo,to:r.to}),{bcc:r.bcc,cc:r.cc,from:i,headers:r.headers,html:t,replyTo:r.replyTo,subject:r.subject,text:a,to:r.to}};return{queue:async r=>{if(!e.queue){if(d(u)){const a=await n(r);return await u.send(a),{queued:!0}}throw new c("INTERNAL","@lunora/mail: `queue` binding is required for mailer.queue()")}const t=await n(r);return await e.queue.send(p(t)),{queued:!0}},send:async r=>{const t=await n(r);return u.send(t)}}};export{L as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/mail",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.42",
|
|
4
4
|
"description": "Email for Lunora: Resend adapter, TSX templates, and queue-backed sends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
57
|
+
"@lunora/errors": "1.0.0-alpha.15",
|
|
58
58
|
"@react-email/render": "2.1.0",
|
|
59
59
|
"@visulima/email": "2.1.2",
|
|
60
60
|
"postal-mime": "2.7.5"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as c}from"@lunora/errors";const h=t=>({bcc:t.bcc,cc:t.cc,from:t.from,headers:t.headers,html:t.html,replyTo:t.replyTo,subject:t.subject,text:t.text,to:t.to}),b=async(t,s)=>{if(!s||typeof s!="object"||Array.isArray(s))throw new c("INTERNAL","@lunora/mail: queue message body must be an object");const e=s;if(typeof e.subject!="string")throw new TypeError("@lunora/mail: queue message must have a string `subject`");const m=typeof e.to=="string",y=Array.isArray(e.to)&&e.to.every(o=>typeof o=="string");if(!m&&!y)throw new c("INTERNAL","@lunora/mail: queue message `to` must be a string or string[]");const a=(o,r)=>{if(r!==void 0){if(typeof r!="string")throw new TypeError(`@lunora/mail: queue message \`${o}\` must be a string`);return r}},u=(o,r)=>{if(r!==void 0){if(typeof r=="string")return[r];if(Array.isArray(r)&&r.every(n=>typeof n=="string"))return r;throw new TypeError(`@lunora/mail: queue message \`${o}\` must be a string or string[]`)}};let i;if(e.headers!==void 0){if(!e.headers||typeof e.headers!="object"||Array.isArray(e.headers))throw new TypeError("@lunora/mail: queue message `headers` must be an object of string values");const o=Object.entries(e.headers);for(const[r,n]of o)if(typeof n!="string")throw new TypeError(`@lunora/mail: queue message header "${r}" must be a string`);i=e.headers}const f={bcc:u("bcc",e.bcc),cc:u("cc",e.cc),from:a("from",e.from),headers:i,html:a("html",e.html),replyTo:a("replyTo",e.replyTo),subject:e.subject,text:a("text",e.text),to:e.to};return t.send(f)};export{b as consumeQueuedSend,h as toQueuedPayload};
|