@rpcbase/server 0.588.0 → 0.589.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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type SendEmailParams = {
1
+ export type SendEmailParams = {
2
2
  to: string | string[];
3
3
  subject: string;
4
4
  html?: string;
@@ -6,14 +6,23 @@ type SendEmailParams = {
6
6
  from?: string;
7
7
  replyTo?: string | string[];
8
8
  };
9
- export declare const sendEmail: (params: SendEmailParams) => Promise<{
10
- id: undefined;
11
- skipped: boolean;
9
+ export type SendEmailOptions = {
10
+ missingTransport?: "throw" | "skip";
11
+ };
12
+ export type SendEmailResult = {
13
+ id: string;
14
+ skipped: false;
12
15
  error?: undefined;
13
16
  } | {
14
- id: string | undefined;
15
- error: string | undefined;
16
- skipped: boolean;
17
- }>;
18
- export {};
17
+ id: undefined;
18
+ skipped: true;
19
+ skippedReason: "missing_transport";
20
+ error?: undefined;
21
+ };
22
+ export type EmailDeliveryErrorCode = "missing_transport" | "provider_rejected" | "provider_unconfirmed" | "transport_error";
23
+ export declare class EmailDeliveryError extends Error {
24
+ readonly code: EmailDeliveryErrorCode;
25
+ constructor(code: EmailDeliveryErrorCode, message: string, cause?: unknown);
26
+ }
27
+ export declare const sendEmail: (params: SendEmailParams, options?: SendEmailOptions) => Promise<SendEmailResult>;
19
28
  //# sourceMappingURL=email.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B,CAAA;AAKD,eAAO,MAAM,SAAS,GAAS,QAAQ,eAAe;;;;;;;;EAsBrD,CAAA"}
1
+ {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACrC,CAAA;AAED,MAAM,MAAM,eAAe,GACvB;IACA,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GACC;IACA,EAAE,EAAE,SAAS,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;IACd,aAAa,EAAE,mBAAmB,CAAC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAA;AAEH,MAAM,MAAM,sBAAsB,GAC9B,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,iBAAiB,CAAA;AAErB,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;gBAEzB,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM3E;AAID,eAAO,MAAM,SAAS,GACpB,QAAQ,eAAe,EACvB,UAAS,gBAAqB,KAC7B,OAAO,CAAC,eAAe,CAuDzB,CAAA"}
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import { StrictMode, createElement } from "react";
22
22
  import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
23
23
  import { jsx } from "react/jsx-runtime";
24
24
  import { createPath, matchRoutes, parsePath, createStaticRouter, StaticRouterProvider } from "@rpcbase/router";
25
- import { s } from "./email-BbPlSkbt.js";
25
+ import { E, s } from "./email-BCf24GmK.js";
26
26
  function getDefaultExportFromCjs(x) {
27
27
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
28
28
  }
@@ -5511,6 +5511,7 @@ const ssrMiddleware = ({
5511
5511
  }
5512
5512
  };
5513
5513
  export {
5514
+ E as EmailDeliveryError,
5514
5515
  bindShutdownSignals,
5515
5516
  getDerivedKey,
5516
5517
  hashPassword,
@@ -1 +1 @@
1
- {"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../src/notifications/digest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAoDjD,eAAO,MAAM,8BAA8B,GACzC,KAAK,GAAG,EACR,6BAIG;IACD,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,KACA,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CA2F5F,CAAA"}
1
+ {"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../src/notifications/digest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAoDjD,eAAO,MAAM,8BAA8B,GACzC,KAAK,GAAG,EACR,6BAIG;IACD,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,KACA,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAmG5F,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { models } from "@rpcbase/db";
3
- import { s as sendEmail } from "./email-BbPlSkbt.js";
3
+ import { s as sendEmail } from "./email-BCf24GmK.js";
4
4
  const routes = Object.entries({
5
5
  .../* @__PURE__ */ Object.assign({ "./api/notifications/handler.ts": () => import("./handler-CUOJ51-w.js") })
6
6
  }).reduce((acc, [path, mod]) => {
@@ -355,15 +355,19 @@ const sendNotificationsDigestForUser = async (ctx, {
355
355
  return line;
356
356
  }).join("");
357
357
  const html = `<div><p>Here is your notifications digest:</p><ul>${rows}</ul></div>`;
358
- const emailResult = await sendEmail({
359
- to: email,
360
- subject,
361
- html
362
- });
363
- if (emailResult.error) {
358
+ let emailResult;
359
+ try {
360
+ emailResult = await sendEmail({
361
+ to: email,
362
+ subject,
363
+ html
364
+ }, {
365
+ missingTransport: "skip"
366
+ });
367
+ } catch (error) {
364
368
  return {
365
369
  ok: false,
366
- error: emailResult.error
370
+ error: error instanceof Error ? error.message : "Email delivery failed"
367
371
  };
368
372
  }
369
373
  await SettingsModel.updateOne({
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","sources":["../src/notifications/routes.ts","../src/notifications/createNotification.ts","../src/notifications/digest.ts"],"sourcesContent":["export const routes = Object.entries({\n ...import.meta.glob(\"./api/**/handler.ts\"),\n}).reduce<Record<string, unknown>>((acc, [path, mod]) => {\n acc[path.replace(\"./api/\", \"@rpcbase/server/notifications/api/\")] = mod\n return acc\n}, {})\n\n","import { randomUUID } from \"node:crypto\"\n\nimport type { Ctx } from \"@rpcbase/api\"\nimport { models, type IRBNotificationPlatformPayload } from \"@rpcbase/db\"\nimport type { AppAbility } from \"@rpcbase/db/acl\"\n\n\nexport type NotificationDataPayload = Record<string, string>\nexport type NotificationMetadataPayload = Record<string, unknown>\nexport type NotificationPlatformPayload = IRBNotificationPlatformPayload\nexport type NotificationUrlMode = \"navigate\" | \"merge_current_search\"\n\nexport type CreateNotificationInput = {\n userId: string\n topic?: string\n tag?: string\n title: string\n body?: string\n image?: string\n url?: string\n urlMode?: NotificationUrlMode\n metadata?: NotificationMetadataPayload\n data?: NotificationDataPayload\n platform?: NotificationPlatformPayload\n}\n\nexport type CreateNotificationForUserInput = Omit<CreateNotificationInput, \"userId\">\n\nexport type CreateNotificationsForUserInput = {\n userId: string\n notifications: CreateNotificationForUserInput[]\n}\n\nconst normalizeRequiredString = (value: unknown, name: string): string => {\n const normalized = typeof value === \"string\" ? value.trim() : \"\"\n if (!normalized) {\n throw new Error(`${name} is required`)\n }\n return normalized\n}\n\nconst normalizeOptionalString = (value: string | undefined): string | undefined => {\n const normalized = typeof value === \"string\" ? value.trim() : \"\"\n return normalized || undefined\n}\n\nconst normalizeUrlMode = (value: unknown): NotificationUrlMode => {\n return value === \"merge_current_search\" ? \"merge_current_search\" : \"navigate\"\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n Boolean(value) && typeof value === \"object\" && !Array.isArray(value)\n\nconst toNotificationDataString = (value: unknown): string | undefined => {\n if (typeof value === \"string\") {\n const trimmed = value.trim()\n return trimmed || undefined\n }\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value)\n if (typeof value === \"boolean\") return String(value)\n if (typeof value === \"bigint\") return value.toString()\n if (value instanceof Date && Number.isFinite(value.getTime())) return value.toISOString()\n return undefined\n}\n\nconst normalizeNotificationActionLink = (url: string | undefined, urlMode: NotificationUrlMode): string | undefined => {\n const normalizedUrl = normalizeOptionalString(url)\n if (!normalizedUrl) return undefined\n if (urlMode === \"navigate\") return normalizedUrl\n\n try {\n const parsed = new URL(normalizedUrl, \"https://rpcbase.local/\")\n return `${parsed.search}${parsed.hash}` || undefined\n } catch {\n return normalizedUrl.startsWith(\"?\") ? normalizedUrl : undefined\n }\n}\n\nconst buildNotificationData = (\n input: Pick<CreateNotificationInput, \"data\" | \"metadata\"> & { link?: string; urlMode: NotificationUrlMode },\n): NotificationDataPayload | undefined => {\n const data: NotificationDataPayload = {}\n\n for (const [key, value] of Object.entries(input.metadata ?? {})) {\n const normalized = toNotificationDataString(value)\n if (normalized) {\n data[key] = normalized\n }\n }\n\n if (input.data) {\n Object.assign(data, input.data)\n }\n\n if (input.link) {\n data.link = input.link\n if (input.urlMode !== \"navigate\") {\n data.linkMode = input.urlMode\n }\n }\n\n return Object.keys(data).length > 0 ? data : undefined\n}\n\nconst buildNotificationPlatform = (\n platform: NotificationPlatformPayload | undefined,\n link: string | undefined,\n): NotificationPlatformPayload | undefined => {\n if (!link) return platform\n\n const webpush = isRecord(platform?.webpush) ? platform.webpush : {}\n const fcmOptions = isRecord(webpush.fcmOptions) ? webpush.fcmOptions : {}\n\n return {\n ...platform,\n webpush: {\n ...webpush,\n fcmOptions: {\n ...fcmOptions,\n link,\n },\n },\n }\n}\n\nconst createNotificationDocument = (input: CreateNotificationInput) => {\n const userId = normalizeRequiredString(input.userId, \"createNotification: userId\")\n const title = normalizeRequiredString(input.title, \"createNotification: title\")\n const topic = normalizeOptionalString(input.topic)\n const tag = normalizeOptionalString(input.tag)\n const body = normalizeOptionalString(input.body)\n const image = normalizeOptionalString(input.image)\n const urlMode = normalizeUrlMode(input.urlMode)\n const link = normalizeNotificationActionLink(input.url, urlMode)\n const data = buildNotificationData({ data: input.data, metadata: input.metadata, link, urlMode })\n const platform = buildNotificationPlatform(input.platform, link)\n\n return {\n userId,\n ...(topic ? { topic } : {}),\n ...(tag ? { tag } : {}),\n deliveryId: randomUUID(),\n title,\n ...(body ? { body } : {}),\n ...(image ? { image } : {}),\n ...(data ? { data } : {}),\n ...(platform ? { platform } : {}),\n drawerActive: true,\n createdAt: new Date(),\n }\n}\n\nconst assertCreateNotificationsForUserInput = (input: CreateNotificationsForUserInput): void => {\n if (typeof input.userId !== \"string\" || input.userId.trim().length === 0) {\n throw new Error(\"createNotificationsForUser: userId is required\")\n }\n if (!Array.isArray(input.notifications)) {\n throw new Error(\"createNotificationsForUser: notifications must be an array\")\n }\n}\n\nexport const createNotification = async (\n ctx: Ctx,\n input: CreateNotificationInput,\n ability: AppAbility,\n): Promise<{ id: string }> => {\n if (!ability.can(\"create\", \"RBNotification\")) {\n throw new Error(\"createNotification: forbidden\")\n }\n\n const modelCtx = { req: ctx.req, ability }\n const [NotificationModel, NotificationDeliveryModel] = await Promise.all([\n models.getUnsafe(\"RBNotification\", modelCtx),\n models.getUnsafe(\"RBNotificationDelivery\", modelCtx),\n ])\n const notification = createNotificationDocument(input)\n const delivery = await NotificationDeliveryModel.create(notification)\n const doc = notification.tag\n ? await NotificationModel.findOneAndReplace(\n { userId: notification.userId, tag: notification.tag, archivedAt: { $exists: false } },\n notification,\n { new: true, upsert: true, sort: { drawerActive: -1, createdAt: -1 } },\n )\n : await NotificationModel.create(notification)\n\n if (!doc) {\n throw new Error(\"createNotification: failed to persist notification\")\n }\n\n await NotificationDeliveryModel.updateOne(\n { _id: delivery._id },\n { $set: { notificationId: doc._id.toString() } },\n )\n\n return { id: doc._id.toString() }\n}\n\nexport const createNotificationsForUser = async (\n ctx: Ctx,\n input: CreateNotificationsForUserInput,\n ability: AppAbility,\n): Promise<{ ids: string[] }> => {\n assertCreateNotificationsForUserInput(input)\n if (input.notifications.length === 0) {\n return { ids: [] }\n }\n\n if (!ability.can(\"create\", \"RBNotification\")) {\n throw new Error(\"createNotificationsForUser: forbidden\")\n }\n\n const modelCtx = { req: ctx.req, ability }\n const [NotificationModel, NotificationDeliveryModel] = await Promise.all([\n models.getUnsafe(\"RBNotification\", modelCtx),\n models.getUnsafe(\"RBNotificationDelivery\", modelCtx),\n ])\n const ids: string[] = []\n for (const notification of input.notifications) {\n const document = createNotificationDocument({\n ...notification,\n userId: input.userId,\n })\n const delivery = await NotificationDeliveryModel.create(document)\n const doc = document.tag\n ? await NotificationModel.findOneAndReplace(\n { userId: document.userId, tag: document.tag, archivedAt: { $exists: false } },\n document,\n { new: true, upsert: true, sort: { drawerActive: -1, createdAt: -1 } },\n )\n : await NotificationModel.create(document)\n\n if (!doc) {\n throw new Error(\"createNotificationsForUser: failed to persist notification\")\n }\n await NotificationDeliveryModel.updateOne(\n { _id: delivery._id },\n { $set: { notificationId: doc._id.toString() } },\n )\n ids.push(doc._id.toString())\n }\n\n return { ids }\n}\n","import type { Ctx } from \"@rpcbase/api\"\nimport { models, type IRBNotification, type IRBNotificationSettings } from \"@rpcbase/db\"\nimport type { AppAbility } from \"@rpcbase/db/acl\"\n\nimport { sendEmail } from \"../email\"\n\n\nconst DAY_MS = 24 * 60 * 60 * 1000\nconst WEEK_MS = 7 * DAY_MS\n\ntype DigestFrequency = \"off\" | \"daily\" | \"weekly\"\n\ntype NotificationDoc = IRBNotification & { _id: unknown }\ntype SettingsDoc = IRBNotificationSettings & { _id: unknown }\n\nconst getDigestWindowMs = (frequency: DigestFrequency): number => {\n if (frequency === \"daily\") return DAY_MS\n if (frequency === \"weekly\") return WEEK_MS\n return 0\n}\n\nconst formatIso = (value: unknown): string | undefined => {\n if (!(value instanceof Date)) return undefined\n return value.toISOString()\n}\n\nconst getNotificationLink = (notification: NotificationDoc): string => {\n const dataLink = notification.data?.link?.trim()\n if (dataLink) return dataLink\n\n const platform = notification.platform\n if (!platform || typeof platform !== \"object\" || Array.isArray(platform)) return \"\"\n const webpush = (platform as { webpush?: unknown }).webpush\n if (!webpush || typeof webpush !== \"object\" || Array.isArray(webpush)) return \"\"\n const fcmOptions = (webpush as { fcmOptions?: unknown }).fcmOptions\n if (!fcmOptions || typeof fcmOptions !== \"object\" || Array.isArray(fcmOptions)) return \"\"\n const link = (fcmOptions as { link?: unknown }).link\n return typeof link === \"string\" ? link.trim() : \"\"\n}\n\nconst buildPreferencesByTopic = (settings: SettingsDoc | null): Record<string, { emailDigest: boolean }> => {\n const record: Record<string, { emailDigest: boolean }> = {}\n const raw = settings?.topicPreferences\n if (!Array.isArray(raw)) return record\n for (const pref of raw) {\n if (!pref || typeof pref !== \"object\") continue\n const topic = typeof (pref as { topic?: unknown }).topic === \"string\" ? (pref as { topic: string }).topic.trim() : \"\"\n if (!topic) continue\n const emailDigest = (pref as { emailDigest?: unknown }).emailDigest\n record[topic] = { emailDigest: emailDigest === true }\n }\n return record\n}\n\nexport const sendNotificationsDigestForUser = async (\n ctx: Ctx,\n {\n userId,\n ability,\n force = false,\n }: {\n userId: string\n ability: AppAbility\n force?: boolean\n },\n): Promise<{ ok: true; sent: boolean; skippedReason?: string } | { ok: false; error: string }> => {\n const modelCtx = { req: ctx.req, ability }\n const SettingsModel = await models.get(\"RBNotificationSettings\", modelCtx)\n const NotificationModel = await models.get(\"RBNotification\", modelCtx)\n\n const settings = (await SettingsModel.findOne({ userId }).lean()) as SettingsDoc | null\n\n const digestFrequencyRaw = typeof settings?.digestFrequency === \"string\" ? settings.digestFrequency : \"weekly\"\n const digestFrequency: DigestFrequency =\n digestFrequencyRaw === \"daily\" || digestFrequencyRaw === \"weekly\" || digestFrequencyRaw === \"off\"\n ? digestFrequencyRaw\n : \"weekly\"\n\n if (digestFrequency === \"off\") {\n return { ok: true, sent: false, skippedReason: \"digest_off\" }\n }\n\n const now = new Date()\n const windowMs = getDigestWindowMs(digestFrequency)\n const lastSentAt = settings?.lastDigestSentAt instanceof Date ? settings.lastDigestSentAt : null\n const since = lastSentAt ?? new Date(now.getTime() - windowMs)\n\n if (!force && lastSentAt && now.getTime() - lastSentAt.getTime() < windowMs) {\n return { ok: true, sent: false, skippedReason: \"not_due\" }\n }\n\n const preferencesByTopic = buildPreferencesByTopic(settings)\n const disabledTopics = Object.entries(preferencesByTopic)\n .filter(([, pref]) => pref.emailDigest === false)\n .map(([topic]) => topic)\n\n const query: Record<string, unknown> = {\n userId,\n archivedAt: { $exists: false },\n readAt: { $exists: false },\n createdAt: { $gt: since },\n }\n\n if (disabledTopics.length > 0) {\n query.topic = { $nin: disabledTopics }\n }\n\n const notifications = (await NotificationModel.find(query)\n .sort({ createdAt: -1 })\n .limit(50)\n .lean()) as NotificationDoc[]\n\n if (!notifications.length) {\n await SettingsModel.updateOne(\n { userId },\n { $set: { lastDigestSentAt: now }, $setOnInsert: { userId, digestFrequency: \"weekly\" } },\n { upsert: true },\n )\n return { ok: true, sent: false, skippedReason: \"empty\" }\n }\n\n const UserModel = await models.getGlobal(\"RBUser\", ctx)\n const user = (await UserModel.findById(userId, { email: 1 }).lean()) as { email?: unknown } | null\n const email = typeof user?.email === \"string\" ? user.email.trim() : \"\"\n if (!email) {\n return { ok: true, sent: false, skippedReason: \"missing_email\" }\n }\n\n const subject = \"Notifications digest\"\n const rows = notifications\n .map((n) => {\n const title = typeof n.title === \"string\" ? n.title : \"\"\n const body = typeof n.body === \"string\" ? n.body : \"\"\n const url = getNotificationLink(n)\n const createdAt = formatIso(n.createdAt) ?? \"\"\n const line = url\n ? `<li><strong>${title}</strong><br>${body}<br><a href=\"${url}\">${url}</a><br><small>${createdAt}</small></li>`\n : `<li><strong>${title}</strong><br>${body}<br><small>${createdAt}</small></li>`\n return line\n })\n .join(\"\")\n\n const html = `<div><p>Here is your notifications digest:</p><ul>${rows}</ul></div>`\n\n const emailResult = await sendEmail({ to: email, subject, html })\n if (emailResult.error) {\n return { ok: false, error: emailResult.error }\n }\n\n await SettingsModel.updateOne(\n { userId },\n { $set: { lastDigestSentAt: now }, $setOnInsert: { userId, digestFrequency: \"weekly\" } },\n { upsert: true },\n )\n\n return { ok: true, sent: emailResult.skipped !== true, ...(emailResult.skipped ? { skippedReason: \"email_skipped\" } : {}) }\n}\n"],"names":["routes","Object","entries","import","reduce","acc","path","mod","replace","normalizeRequiredString","value","name","normalized","trim","Error","normalizeOptionalString","undefined","normalizeUrlMode","isRecord","Boolean","Array","isArray","toNotificationDataString","trimmed","Number","isFinite","String","toString","Date","getTime","toISOString","normalizeNotificationActionLink","url","urlMode","normalizedUrl","parsed","URL","search","hash","startsWith","buildNotificationData","input","data","key","metadata","assign","link","linkMode","keys","length","buildNotificationPlatform","platform","webpush","fcmOptions","createNotificationDocument","userId","title","topic","tag","body","image","deliveryId","randomUUID","drawerActive","createdAt","assertCreateNotificationsForUserInput","notifications","createNotification","ctx","ability","can","modelCtx","req","NotificationModel","NotificationDeliveryModel","Promise","all","models","getUnsafe","notification","delivery","create","doc","findOneAndReplace","archivedAt","$exists","new","upsert","sort","updateOne","_id","$set","notificationId","id","createNotificationsForUser","ids","document","push","DAY_MS","WEEK_MS","getDigestWindowMs","frequency","formatIso","getNotificationLink","dataLink","buildPreferencesByTopic","settings","record","raw","topicPreferences","pref","emailDigest","sendNotificationsDigestForUser","force","SettingsModel","get","findOne","lean","digestFrequencyRaw","digestFrequency","ok","sent","skippedReason","now","windowMs","lastSentAt","lastDigestSentAt","since","preferencesByTopic","disabledTopics","filter","map","query","readAt","$gt","$nin","find","limit","$setOnInsert","UserModel","getGlobal","user","findById","email","subject","rows","n","line","join","html","emailResult","sendEmail","to","error","skipped"],"mappings":";;;AAAO,MAAMA,SAASC,OAAOC,QAAQ;AAAA,EACnC,GAAGC,uBAAAA,OAAAA,EAAAA,kCAAAA,MAAAA,OAAAA,uBAAAA,EAAAA,CAAAA;AACL,CAAC,EAAEC,OAAgC,CAACC,KAAK,CAACC,MAAMC,GAAG,MAAM;AACvDF,MAAIC,KAAKE,QAAQ,UAAU,oCAAoC,CAAC,IAAID;AACpE,SAAOF;AACT,GAAG,CAAA,CAAE;AC4BL,MAAMI,0BAA0BA,CAACC,OAAgBC,SAAyB;AACxE,QAAMC,aAAa,OAAOF,UAAU,WAAWA,MAAMG,SAAS;AAC9D,MAAI,CAACD,YAAY;AACf,UAAM,IAAIE,MAAM,GAAGH,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QAAMC,OAAO/E,cACViE,IAAKe,CAAAA,MAAM;AACV,UAAM1F,QAAQ,OAAO0F,EAAE1F,UAAU,WAAW0F,EAAE1F,QAAQ;AACtD,UAAMG,OAAO,OAAOuF,EAAEvF,SAAS,WAAWuF,EAAEvF,OAAO;AACnD,UAAM3B,MAAMuE,oBAAoB2C,CAAC;AACjC,UAAMlF,YAAYsC,UAAU4C,EAAElF,SAAS,KAAK;AAC5C,UAAMmF,OAAOnH,MACT,eAAewB,KAAK,gBAAgBG,IAAI,gBAAgB3B,GAAG,KAAKA,GAAG,kBAAkBgC,SAAS,kBAC9F,eAAeR,KAAK,gBAAgBG,IAAI,cAAcK,SAAS;AACnE,WAAOmF;AAAAA,EACT,CAAC,EACAC,KAAK,EAAE;AAEV,QAAMC,OAAO,qDAAqDJ,IAAI;AAEtE,QAAMK,cAAc,MAAMC,UAAU;AAAA,IAAEC,IAAIT;AAAAA,IAAOC;AAAAA,IAASK;AAAAA,EAAAA,CAAM;AAChE,MAAIC,YAAYG,OAAO;AACrB,WAAO;AAAA,MAAEjC,IAAI;AAAA,MAAOiC,OAAOH,YAAYG;AAAAA,IAAAA;AAAAA,EACzC;AAEA,QAAMvC,cAAczB,UAClB;AAAA,IAAElC;AAAAA,EAAAA,GACF;AAAA,IAAEoC,MAAM;AAAA,MAAEmC,kBAAkBH;AAAAA,IAAAA;AAAAA,IAAOe,cAAc;AAAA,MAAEnF;AAAAA,MAAQgE,iBAAiB;AAAA,IAAA;AAAA,EAAS,GACrF;AAAA,IAAEhC,QAAQ;AAAA,EAAA,CACZ;AAEA,SAAO;AAAA,IAAEiC,IAAI;AAAA,IAAMC,MAAM6B,YAAYI,YAAY;AAAA,IAAM,GAAIJ,YAAYI,UAAU;AAAA,MAAEhC,eAAe;AAAA,IAAA,IAAoB,CAAA;AAAA,EAAC;AACzH;"}
1
+ {"version":3,"file":"notifications.js","sources":["../src/notifications/routes.ts","../src/notifications/createNotification.ts","../src/notifications/digest.ts"],"sourcesContent":["export const routes = Object.entries({\n ...import.meta.glob(\"./api/**/handler.ts\"),\n}).reduce<Record<string, unknown>>((acc, [path, mod]) => {\n acc[path.replace(\"./api/\", \"@rpcbase/server/notifications/api/\")] = mod\n return acc\n}, {})\n\n","import { randomUUID } from \"node:crypto\"\n\nimport type { Ctx } from \"@rpcbase/api\"\nimport { models, type IRBNotificationPlatformPayload } from \"@rpcbase/db\"\nimport type { AppAbility } from \"@rpcbase/db/acl\"\n\n\nexport type NotificationDataPayload = Record<string, string>\nexport type NotificationMetadataPayload = Record<string, unknown>\nexport type NotificationPlatformPayload = IRBNotificationPlatformPayload\nexport type NotificationUrlMode = \"navigate\" | \"merge_current_search\"\n\nexport type CreateNotificationInput = {\n userId: string\n topic?: string\n tag?: string\n title: string\n body?: string\n image?: string\n url?: string\n urlMode?: NotificationUrlMode\n metadata?: NotificationMetadataPayload\n data?: NotificationDataPayload\n platform?: NotificationPlatformPayload\n}\n\nexport type CreateNotificationForUserInput = Omit<CreateNotificationInput, \"userId\">\n\nexport type CreateNotificationsForUserInput = {\n userId: string\n notifications: CreateNotificationForUserInput[]\n}\n\nconst normalizeRequiredString = (value: unknown, name: string): string => {\n const normalized = typeof value === \"string\" ? value.trim() : \"\"\n if (!normalized) {\n throw new Error(`${name} is required`)\n }\n return normalized\n}\n\nconst normalizeOptionalString = (value: string | undefined): string | undefined => {\n const normalized = typeof value === \"string\" ? value.trim() : \"\"\n return normalized || undefined\n}\n\nconst normalizeUrlMode = (value: unknown): NotificationUrlMode => {\n return value === \"merge_current_search\" ? \"merge_current_search\" : \"navigate\"\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n Boolean(value) && typeof value === \"object\" && !Array.isArray(value)\n\nconst toNotificationDataString = (value: unknown): string | undefined => {\n if (typeof value === \"string\") {\n const trimmed = value.trim()\n return trimmed || undefined\n }\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value)\n if (typeof value === \"boolean\") return String(value)\n if (typeof value === \"bigint\") return value.toString()\n if (value instanceof Date && Number.isFinite(value.getTime())) return value.toISOString()\n return undefined\n}\n\nconst normalizeNotificationActionLink = (url: string | undefined, urlMode: NotificationUrlMode): string | undefined => {\n const normalizedUrl = normalizeOptionalString(url)\n if (!normalizedUrl) return undefined\n if (urlMode === \"navigate\") return normalizedUrl\n\n try {\n const parsed = new URL(normalizedUrl, \"https://rpcbase.local/\")\n return `${parsed.search}${parsed.hash}` || undefined\n } catch {\n return normalizedUrl.startsWith(\"?\") ? normalizedUrl : undefined\n }\n}\n\nconst buildNotificationData = (\n input: Pick<CreateNotificationInput, \"data\" | \"metadata\"> & { link?: string; urlMode: NotificationUrlMode },\n): NotificationDataPayload | undefined => {\n const data: NotificationDataPayload = {}\n\n for (const [key, value] of Object.entries(input.metadata ?? {})) {\n const normalized = toNotificationDataString(value)\n if (normalized) {\n data[key] = normalized\n }\n }\n\n if (input.data) {\n Object.assign(data, input.data)\n }\n\n if (input.link) {\n data.link = input.link\n if (input.urlMode !== \"navigate\") {\n data.linkMode = input.urlMode\n }\n }\n\n return Object.keys(data).length > 0 ? data : undefined\n}\n\nconst buildNotificationPlatform = (\n platform: NotificationPlatformPayload | undefined,\n link: string | undefined,\n): NotificationPlatformPayload | undefined => {\n if (!link) return platform\n\n const webpush = isRecord(platform?.webpush) ? platform.webpush : {}\n const fcmOptions = isRecord(webpush.fcmOptions) ? webpush.fcmOptions : {}\n\n return {\n ...platform,\n webpush: {\n ...webpush,\n fcmOptions: {\n ...fcmOptions,\n link,\n },\n },\n }\n}\n\nconst createNotificationDocument = (input: CreateNotificationInput) => {\n const userId = normalizeRequiredString(input.userId, \"createNotification: userId\")\n const title = normalizeRequiredString(input.title, \"createNotification: title\")\n const topic = normalizeOptionalString(input.topic)\n const tag = normalizeOptionalString(input.tag)\n const body = normalizeOptionalString(input.body)\n const image = normalizeOptionalString(input.image)\n const urlMode = normalizeUrlMode(input.urlMode)\n const link = normalizeNotificationActionLink(input.url, urlMode)\n const data = buildNotificationData({ data: input.data, metadata: input.metadata, link, urlMode })\n const platform = buildNotificationPlatform(input.platform, link)\n\n return {\n userId,\n ...(topic ? { topic } : {}),\n ...(tag ? { tag } : {}),\n deliveryId: randomUUID(),\n title,\n ...(body ? { body } : {}),\n ...(image ? { image } : {}),\n ...(data ? { data } : {}),\n ...(platform ? { platform } : {}),\n drawerActive: true,\n createdAt: new Date(),\n }\n}\n\nconst assertCreateNotificationsForUserInput = (input: CreateNotificationsForUserInput): void => {\n if (typeof input.userId !== \"string\" || input.userId.trim().length === 0) {\n throw new Error(\"createNotificationsForUser: userId is required\")\n }\n if (!Array.isArray(input.notifications)) {\n throw new Error(\"createNotificationsForUser: notifications must be an array\")\n }\n}\n\nexport const createNotification = async (\n ctx: Ctx,\n input: CreateNotificationInput,\n ability: AppAbility,\n): Promise<{ id: string }> => {\n if (!ability.can(\"create\", \"RBNotification\")) {\n throw new Error(\"createNotification: forbidden\")\n }\n\n const modelCtx = { req: ctx.req, ability }\n const [NotificationModel, NotificationDeliveryModel] = await Promise.all([\n models.getUnsafe(\"RBNotification\", modelCtx),\n models.getUnsafe(\"RBNotificationDelivery\", modelCtx),\n ])\n const notification = createNotificationDocument(input)\n const delivery = await NotificationDeliveryModel.create(notification)\n const doc = notification.tag\n ? await NotificationModel.findOneAndReplace(\n { userId: notification.userId, tag: notification.tag, archivedAt: { $exists: false } },\n notification,\n { new: true, upsert: true, sort: { drawerActive: -1, createdAt: -1 } },\n )\n : await NotificationModel.create(notification)\n\n if (!doc) {\n throw new Error(\"createNotification: failed to persist notification\")\n }\n\n await NotificationDeliveryModel.updateOne(\n { _id: delivery._id },\n { $set: { notificationId: doc._id.toString() } },\n )\n\n return { id: doc._id.toString() }\n}\n\nexport const createNotificationsForUser = async (\n ctx: Ctx,\n input: CreateNotificationsForUserInput,\n ability: AppAbility,\n): Promise<{ ids: string[] }> => {\n assertCreateNotificationsForUserInput(input)\n if (input.notifications.length === 0) {\n return { ids: [] }\n }\n\n if (!ability.can(\"create\", \"RBNotification\")) {\n throw new Error(\"createNotificationsForUser: forbidden\")\n }\n\n const modelCtx = { req: ctx.req, ability }\n const [NotificationModel, NotificationDeliveryModel] = await Promise.all([\n models.getUnsafe(\"RBNotification\", modelCtx),\n models.getUnsafe(\"RBNotificationDelivery\", modelCtx),\n ])\n const ids: string[] = []\n for (const notification of input.notifications) {\n const document = createNotificationDocument({\n ...notification,\n userId: input.userId,\n })\n const delivery = await NotificationDeliveryModel.create(document)\n const doc = document.tag\n ? await NotificationModel.findOneAndReplace(\n { userId: document.userId, tag: document.tag, archivedAt: { $exists: false } },\n document,\n { new: true, upsert: true, sort: { drawerActive: -1, createdAt: -1 } },\n )\n : await NotificationModel.create(document)\n\n if (!doc) {\n throw new Error(\"createNotificationsForUser: failed to persist notification\")\n }\n await NotificationDeliveryModel.updateOne(\n { _id: delivery._id },\n { $set: { notificationId: doc._id.toString() } },\n )\n ids.push(doc._id.toString())\n }\n\n return { ids }\n}\n","import type { Ctx } from \"@rpcbase/api\"\nimport { models, type IRBNotification, type IRBNotificationSettings } from \"@rpcbase/db\"\nimport type { AppAbility } from \"@rpcbase/db/acl\"\n\nimport { sendEmail } from \"../email\"\n\n\nconst DAY_MS = 24 * 60 * 60 * 1000\nconst WEEK_MS = 7 * DAY_MS\n\ntype DigestFrequency = \"off\" | \"daily\" | \"weekly\"\n\ntype NotificationDoc = IRBNotification & { _id: unknown }\ntype SettingsDoc = IRBNotificationSettings & { _id: unknown }\n\nconst getDigestWindowMs = (frequency: DigestFrequency): number => {\n if (frequency === \"daily\") return DAY_MS\n if (frequency === \"weekly\") return WEEK_MS\n return 0\n}\n\nconst formatIso = (value: unknown): string | undefined => {\n if (!(value instanceof Date)) return undefined\n return value.toISOString()\n}\n\nconst getNotificationLink = (notification: NotificationDoc): string => {\n const dataLink = notification.data?.link?.trim()\n if (dataLink) return dataLink\n\n const platform = notification.platform\n if (!platform || typeof platform !== \"object\" || Array.isArray(platform)) return \"\"\n const webpush = (platform as { webpush?: unknown }).webpush\n if (!webpush || typeof webpush !== \"object\" || Array.isArray(webpush)) return \"\"\n const fcmOptions = (webpush as { fcmOptions?: unknown }).fcmOptions\n if (!fcmOptions || typeof fcmOptions !== \"object\" || Array.isArray(fcmOptions)) return \"\"\n const link = (fcmOptions as { link?: unknown }).link\n return typeof link === \"string\" ? link.trim() : \"\"\n}\n\nconst buildPreferencesByTopic = (settings: SettingsDoc | null): Record<string, { emailDigest: boolean }> => {\n const record: Record<string, { emailDigest: boolean }> = {}\n const raw = settings?.topicPreferences\n if (!Array.isArray(raw)) return record\n for (const pref of raw) {\n if (!pref || typeof pref !== \"object\") continue\n const topic = typeof (pref as { topic?: unknown }).topic === \"string\" ? (pref as { topic: string }).topic.trim() : \"\"\n if (!topic) continue\n const emailDigest = (pref as { emailDigest?: unknown }).emailDigest\n record[topic] = { emailDigest: emailDigest === true }\n }\n return record\n}\n\nexport const sendNotificationsDigestForUser = async (\n ctx: Ctx,\n {\n userId,\n ability,\n force = false,\n }: {\n userId: string\n ability: AppAbility\n force?: boolean\n },\n): Promise<{ ok: true; sent: boolean; skippedReason?: string } | { ok: false; error: string }> => {\n const modelCtx = { req: ctx.req, ability }\n const SettingsModel = await models.get(\"RBNotificationSettings\", modelCtx)\n const NotificationModel = await models.get(\"RBNotification\", modelCtx)\n\n const settings = (await SettingsModel.findOne({ userId }).lean()) as SettingsDoc | null\n\n const digestFrequencyRaw = typeof settings?.digestFrequency === \"string\" ? settings.digestFrequency : \"weekly\"\n const digestFrequency: DigestFrequency =\n digestFrequencyRaw === \"daily\" || digestFrequencyRaw === \"weekly\" || digestFrequencyRaw === \"off\"\n ? digestFrequencyRaw\n : \"weekly\"\n\n if (digestFrequency === \"off\") {\n return { ok: true, sent: false, skippedReason: \"digest_off\" }\n }\n\n const now = new Date()\n const windowMs = getDigestWindowMs(digestFrequency)\n const lastSentAt = settings?.lastDigestSentAt instanceof Date ? settings.lastDigestSentAt : null\n const since = lastSentAt ?? new Date(now.getTime() - windowMs)\n\n if (!force && lastSentAt && now.getTime() - lastSentAt.getTime() < windowMs) {\n return { ok: true, sent: false, skippedReason: \"not_due\" }\n }\n\n const preferencesByTopic = buildPreferencesByTopic(settings)\n const disabledTopics = Object.entries(preferencesByTopic)\n .filter(([, pref]) => pref.emailDigest === false)\n .map(([topic]) => topic)\n\n const query: Record<string, unknown> = {\n userId,\n archivedAt: { $exists: false },\n readAt: { $exists: false },\n createdAt: { $gt: since },\n }\n\n if (disabledTopics.length > 0) {\n query.topic = { $nin: disabledTopics }\n }\n\n const notifications = (await NotificationModel.find(query)\n .sort({ createdAt: -1 })\n .limit(50)\n .lean()) as NotificationDoc[]\n\n if (!notifications.length) {\n await SettingsModel.updateOne(\n { userId },\n { $set: { lastDigestSentAt: now }, $setOnInsert: { userId, digestFrequency: \"weekly\" } },\n { upsert: true },\n )\n return { ok: true, sent: false, skippedReason: \"empty\" }\n }\n\n const UserModel = await models.getGlobal(\"RBUser\", ctx)\n const user = (await UserModel.findById(userId, { email: 1 }).lean()) as { email?: unknown } | null\n const email = typeof user?.email === \"string\" ? user.email.trim() : \"\"\n if (!email) {\n return { ok: true, sent: false, skippedReason: \"missing_email\" }\n }\n\n const subject = \"Notifications digest\"\n const rows = notifications\n .map((n) => {\n const title = typeof n.title === \"string\" ? n.title : \"\"\n const body = typeof n.body === \"string\" ? n.body : \"\"\n const url = getNotificationLink(n)\n const createdAt = formatIso(n.createdAt) ?? \"\"\n const line = url\n ? `<li><strong>${title}</strong><br>${body}<br><a href=\"${url}\">${url}</a><br><small>${createdAt}</small></li>`\n : `<li><strong>${title}</strong><br>${body}<br><small>${createdAt}</small></li>`\n return line\n })\n .join(\"\")\n\n const html = `<div><p>Here is your notifications digest:</p><ul>${rows}</ul></div>`\n\n let emailResult\n try {\n emailResult = await sendEmail(\n { to: email, subject, html },\n { missingTransport: \"skip\" },\n )\n } catch (error) {\n return {\n ok: false,\n error: error instanceof Error ? error.message : \"Email delivery failed\",\n }\n }\n\n await SettingsModel.updateOne(\n { userId },\n { $set: { lastDigestSentAt: now }, $setOnInsert: { userId, digestFrequency: \"weekly\" } },\n { upsert: true },\n )\n\n return { ok: true, sent: emailResult.skipped !== true, ...(emailResult.skipped ? { skippedReason: \"email_skipped\" } : {}) }\n}\n"],"names":["routes","Object","entries","import","reduce","acc","path","mod","replace","normalizeRequiredString","value","name","normalized","trim","Error","normalizeOptionalString","undefined","normalizeUrlMode","isRecord","Boolean","Array","isArray","toNotificationDataString","trimmed","Number","isFinite","String","toString","Date","getTime","toISOString","normalizeNotificationActionLink","url","urlMode","normalizedUrl","parsed","URL","search","hash","startsWith","buildNotificationData","input","data","key","metadata","assign","link","linkMode","keys","length","buildNotificationPlatform","platform","webpush","fcmOptions","createNotificationDocument","userId","title","topic","tag","body","image","deliveryId","randomUUID","drawerActive","createdAt","assertCreateNotificationsForUserInput","notifications","createNotification","ctx","ability","can","modelCtx","req","NotificationModel","NotificationDeliveryModel","Promise","all","models","getUnsafe","notification","delivery","create","doc","findOneAndReplace","archivedAt","$exists","new","upsert","sort","updateOne","_id","$set","notificationId","id","createNotificationsForUser","ids","document","push","DAY_MS","WEEK_MS","getDigestWindowMs","frequency","formatIso","getNotificationLink","dataLink","buildPreferencesByTopic","settings","record","raw","topicPreferences","pref","emailDigest","sendNotificationsDigestForUser","force","SettingsModel","get","findOne","lean","digestFrequencyRaw","digestFrequency","ok","sent","skippedReason","now","windowMs","lastSentAt","lastDigestSentAt","since","preferencesByTopic","disabledTopics","filter","map","query","readAt","$gt","$nin","find","limit","$setOnInsert","UserModel","getGlobal","user","findById","email","subject","rows","n","line","join","html","emailResult","sendEmail","to","missingTransport","error","message","skipped"],"mappings":";;;AAAO,MAAMA,SAASC,OAAOC,QAAQ;AAAA,EACnC,GAAGC,uBAAAA,OAAAA,EAAAA,kCAAAA,MAAAA,OAAAA,uBAAAA,EAAAA,CAAAA;AACL,CAAC,EAAEC,OAAgC,CAACC,KAAK,CAACC,MAAMC,GAAG,MAAM;AACvDF,MAAIC,KAAKE,QAAQ,UAAU,oCAAo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