@objectstack/runtime 7.5.0 → 7.6.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/index.d.cts CHANGED
@@ -1423,6 +1423,20 @@ declare class HttpDispatcher {
1423
1423
  * path: sub-path after /analytics/
1424
1424
  */
1425
1425
  handleAnalytics(path: string, method: string, body: any, _context: HttpProtocolContext): Promise<HttpDispatcherResult>;
1426
+ /**
1427
+ * Handles in-app notification requests (ADR-0030) — the
1428
+ * `/api/v1/notifications` surface backed by the messaging service's inbox
1429
+ * read API. Reads the L5 `sys_inbox_message` + `sys_notification_receipt`
1430
+ * join; mark-read upserts the receipt keyed `(notification_id, user_id,
1431
+ * channel:'inbox')`. The routes are `auth: true`, so an authenticated user
1432
+ * is required.
1433
+ *
1434
+ * Routes (path is the sub-path after `/notifications`):
1435
+ * GET '' → listInbox (query: read, type, limit)
1436
+ * POST /read → markRead (body: { ids: string[] })
1437
+ * POST /read/all → markAllRead
1438
+ */
1439
+ handleNotification(path: string, method: string, body: any, query: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
1426
1440
  /**
1427
1441
  * Handles i18n requests
1428
1442
  * path: sub-path after /i18n/
package/dist/index.d.ts CHANGED
@@ -1423,6 +1423,20 @@ declare class HttpDispatcher {
1423
1423
  * path: sub-path after /analytics/
1424
1424
  */
1425
1425
  handleAnalytics(path: string, method: string, body: any, _context: HttpProtocolContext): Promise<HttpDispatcherResult>;
1426
+ /**
1427
+ * Handles in-app notification requests (ADR-0030) — the
1428
+ * `/api/v1/notifications` surface backed by the messaging service's inbox
1429
+ * read API. Reads the L5 `sys_inbox_message` + `sys_notification_receipt`
1430
+ * join; mark-read upserts the receipt keyed `(notification_id, user_id,
1431
+ * channel:'inbox')`. The routes are `auth: true`, so an authenticated user
1432
+ * is required.
1433
+ *
1434
+ * Routes (path is the sub-path after `/notifications`):
1435
+ * GET '' → listInbox (query: read, type, limit)
1436
+ * POST /read → markRead (body: { ids: string[] })
1437
+ * POST /read/all → markAllRead
1438
+ */
1439
+ handleNotification(path: string, method: string, body: any, query: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
1426
1440
  /**
1427
1441
  * Handles i18n requests
1428
1442
  * path: sub-path after /i18n/
package/dist/index.js CHANGED
@@ -3680,6 +3680,46 @@ var _HttpDispatcher = class _HttpDispatcher {
3680
3680
  }
3681
3681
  return { handled: false };
3682
3682
  }
3683
+ /**
3684
+ * Handles in-app notification requests (ADR-0030) — the
3685
+ * `/api/v1/notifications` surface backed by the messaging service's inbox
3686
+ * read API. Reads the L5 `sys_inbox_message` + `sys_notification_receipt`
3687
+ * join; mark-read upserts the receipt keyed `(notification_id, user_id,
3688
+ * channel:'inbox')`. The routes are `auth: true`, so an authenticated user
3689
+ * is required.
3690
+ *
3691
+ * Routes (path is the sub-path after `/notifications`):
3692
+ * GET '' → listInbox (query: read, type, limit)
3693
+ * POST /read → markRead (body: { ids: string[] })
3694
+ * POST /read/all → markAllRead
3695
+ */
3696
+ async handleNotification(path, method, body, query, context) {
3697
+ const service = await this.resolveService(CoreServiceName.enum.notification, context.environmentId);
3698
+ if (!service || typeof service.listInbox !== "function") return { handled: false };
3699
+ const userId = context.executionContext?.userId;
3700
+ if (!userId) {
3701
+ return { handled: true, response: this.error("Authentication required", 401) };
3702
+ }
3703
+ const m = method.toUpperCase();
3704
+ const subPath = path.replace(/^\/+/, "").replace(/\/+$/, "");
3705
+ if (subPath === "" && m === "GET") {
3706
+ const read = query?.read === void 0 ? void 0 : String(query.read) === "true";
3707
+ const limit = query?.limit ? Number(query.limit) : void 0;
3708
+ const type = query?.type ? String(query.type) : void 0;
3709
+ const result = await service.listInbox(userId, { read, type, limit });
3710
+ return { handled: true, response: this.success(result) };
3711
+ }
3712
+ if (subPath === "read" && m === "POST") {
3713
+ const ids = Array.isArray(body?.ids) ? body.ids.map((x) => String(x)) : [];
3714
+ const result = await service.markRead(userId, ids);
3715
+ return { handled: true, response: this.success(result) };
3716
+ }
3717
+ if (subPath === "read/all" && m === "POST") {
3718
+ const result = await service.markAllRead(userId);
3719
+ return { handled: true, response: this.success(result) };
3720
+ }
3721
+ return { handled: false };
3722
+ }
3683
3723
  /**
3684
3724
  * Handles i18n requests
3685
3725
  * path: sub-path after /i18n/
@@ -4560,6 +4600,9 @@ var _HttpDispatcher = class _HttpDispatcher {
4560
4600
  if (cleanPath.startsWith("/analytics")) {
4561
4601
  return this.handleAnalytics(cleanPath.substring(10), method, body, context);
4562
4602
  }
4603
+ if (cleanPath.startsWith("/notifications")) {
4604
+ return this.handleNotification(cleanPath.substring(14), method, body, query, context);
4605
+ }
4563
4606
  if (cleanPath.startsWith("/packages")) {
4564
4607
  return this.handlePackages(cleanPath.substring(9), method, body, query, context);
4565
4608
  }