@rpcbase/server 0.588.0 → 0.590.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/dist/{email-BbPlSkbt.js → email-BCf24GmK.js} +45 -19
- package/dist/{email-BbPlSkbt.js.map → email-BCf24GmK.js.map} +1 -1
- package/dist/email.d.ts +18 -9
- package/dist/email.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/notifications/digest.d.ts.map +1 -1
- package/dist/notifications.js +12 -8
- package/dist/notifications.js.map +1 -1
- package/package.json +1 -1
|
@@ -8014,32 +8014,58 @@ var Resend = class {
|
|
|
8014
8014
|
return this.fetchRequest(path, requestOptions);
|
|
8015
8015
|
}
|
|
8016
8016
|
};
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8017
|
+
class EmailDeliveryError extends Error {
|
|
8018
|
+
code;
|
|
8019
|
+
constructor(code, message2, cause) {
|
|
8020
|
+
super(message2);
|
|
8021
|
+
this.name = "EmailDeliveryError";
|
|
8022
|
+
this.code = code;
|
|
8023
|
+
this.cause = cause;
|
|
8024
|
+
}
|
|
8025
|
+
}
|
|
8026
|
+
const getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
8027
|
+
const sendEmail = async (params, options = {}) => {
|
|
8028
|
+
const apiKey = process.env.RESEND_API_KEY?.trim();
|
|
8020
8029
|
if (!apiKey) {
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8030
|
+
if (options.missingTransport === "skip") {
|
|
8031
|
+
console.warn("RESEND_API_KEY not set, skipping email");
|
|
8032
|
+
return {
|
|
8033
|
+
id: void 0,
|
|
8034
|
+
skipped: true,
|
|
8035
|
+
skippedReason: "missing_transport"
|
|
8036
|
+
};
|
|
8037
|
+
}
|
|
8038
|
+
throw new EmailDeliveryError("missing_transport", "RESEND_API_KEY is required to send email");
|
|
8026
8039
|
}
|
|
8027
8040
|
const resend = new Resend(apiKey);
|
|
8028
|
-
const
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8041
|
+
const defaultFrom = process.env.RESEND_FROM?.trim() || "hello@rpcbase.com";
|
|
8042
|
+
let response;
|
|
8043
|
+
try {
|
|
8044
|
+
response = await resend.emails.send({
|
|
8045
|
+
from: params.from || defaultFrom,
|
|
8046
|
+
to: params.to,
|
|
8047
|
+
subject: params.subject,
|
|
8048
|
+
html: params.html,
|
|
8049
|
+
text: params.text,
|
|
8050
|
+
replyTo: params.replyTo
|
|
8051
|
+
});
|
|
8052
|
+
} catch (error) {
|
|
8053
|
+
throw new EmailDeliveryError("transport_error", `Email provider request failed: ${getErrorMessage(error)}`, error);
|
|
8054
|
+
}
|
|
8055
|
+
if (response.error) {
|
|
8056
|
+
throw new EmailDeliveryError("provider_rejected", `Email provider rejected the request: ${response.error.message}`, response.error);
|
|
8057
|
+
}
|
|
8058
|
+
const id = response.data?.id?.trim();
|
|
8059
|
+
if (!id) {
|
|
8060
|
+
throw new EmailDeliveryError("provider_unconfirmed", "Email provider did not confirm the request");
|
|
8061
|
+
}
|
|
8036
8062
|
return {
|
|
8037
|
-
id
|
|
8038
|
-
error: response.error?.message,
|
|
8063
|
+
id,
|
|
8039
8064
|
skipped: false
|
|
8040
8065
|
};
|
|
8041
8066
|
};
|
|
8042
8067
|
export {
|
|
8068
|
+
EmailDeliveryError as E,
|
|
8043
8069
|
sendEmail as s
|
|
8044
8070
|
};
|
|
8045
|
-
//# sourceMappingURL=email-
|
|
8071
|
+
//# sourceMappingURL=email-BCf24GmK.js.map
|