@astram/guard 0.25.1 → 0.27.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.
@@ -1,15 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MariaDbNotificationStore = exports.NOTIFICATION_INSERT_MAX_ROWS = void 0;
4
+ exports.likeContainsPattern = likeContainsPattern;
4
5
  const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
5
6
  const ports_js_1 = require("./ports.js");
6
7
  const DAY_MS = 24 * 60 * 60 * 1000;
7
8
  /** Rows per `insertMany` statement (the `post` recipient cap, SPEC §10). */
8
9
  exports.NOTIFICATION_INSERT_MAX_ROWS = 1000;
9
- const SELECT_COLUMNS = 'un_uuid, un_category, un_kind, un_title, un_body, un_link, un_created_at_ms, un_read_at_ms';
10
+ const SELECT_COLUMNS = 'un_uuid, un_category, un_kind, un_title, un_body, un_link, un_created_at_ms, un_read_at_ms, ' +
11
+ 'un_archived_at_ms';
12
+ /** Not archived (the default view, the badge and "mark all read"). */
13
+ const NOT_ARCHIVED = 'un_archived_at_ms IS NULL';
14
+ /**
15
+ * Per action: the SET clause, whether it takes `nowMs`, and the condition that makes the row
16
+ * change (in the WHERE, so the matched count is the changed count).
17
+ */
18
+ const ACTIONS = {
19
+ read: { set: 'un_read_at_ms = ?', usesNow: 1, changes: 'un_read_at_ms IS NULL' },
20
+ // An archived notice stays read (status is one of unread / read / archived).
21
+ unread: {
22
+ set: 'un_read_at_ms = NULL',
23
+ usesNow: 0,
24
+ changes: `un_read_at_ms IS NOT NULL AND ${NOT_ARCHIVED}`,
25
+ },
26
+ // The first read time is kept; an unread notice is read from now on.
27
+ archive: {
28
+ set: 'un_archived_at_ms = ?, un_read_at_ms = COALESCE(un_read_at_ms, ?)',
29
+ usesNow: 2,
30
+ changes: NOT_ARCHIVED,
31
+ },
32
+ unarchive: {
33
+ set: 'un_archived_at_ms = NULL',
34
+ usesNow: 0,
35
+ changes: 'un_archived_at_ms IS NOT NULL',
36
+ },
37
+ };
10
38
  function isCategory(v) {
11
39
  return ports_js_1.NOTIFICATION_CATEGORIES.includes(v);
12
40
  }
41
+ /**
42
+ * `%term%` for `LIKE ? ESCAPE '!'`: `!` first, then `%` and `_`, each prefixed with `!`. A
43
+ * backslash stays an ordinary character (no `sql_mode` dependence).
44
+ */
45
+ function likeContainsPattern(term) {
46
+ return `%${term.replace(/[!%_]/g, (c) => `!${c}`)}%`;
47
+ }
48
+ function assertEpochMs(name, v) {
49
+ if (!Number.isSafeInteger(v) || v < 0) {
50
+ throw new RangeError(`MariaDbNotificationStore: ${name} is out of range`);
51
+ }
52
+ }
13
53
  /** BIGINT columns may arrive as bigint; the epoch-ms range fits a safe integer. */
14
54
  const toRow = (r) => ({
15
55
  uuid: String(r.un_uuid),
@@ -21,6 +61,7 @@ const toRow = (r) => ({
21
61
  link: r.un_link ?? null,
22
62
  createdAtMs: Number(r.un_created_at_ms),
23
63
  readAtMs: r.un_read_at_ms == null ? null : Number(r.un_read_at_ms),
64
+ archivedAtMs: r.un_archived_at_ms == null ? null : Number(r.un_archived_at_ms),
24
65
  });
25
66
  function affected(res) {
26
67
  return Number(res?.affectedRows ?? 0);
@@ -53,8 +94,51 @@ class MariaDbNotificationStore {
53
94
  where.push('un_category = ?');
54
95
  params.push(query.category);
55
96
  }
97
+ if (query.kind !== undefined) {
98
+ if (typeof query.kind !== 'string') {
99
+ throw new RangeError('MariaDbNotificationStore: kind is out of range');
100
+ }
101
+ where.push('un_kind = ?');
102
+ params.push(query.kind);
103
+ }
104
+ switch (query.status) {
105
+ case undefined:
106
+ where.push(NOT_ARCHIVED);
107
+ break;
108
+ case 'unread':
109
+ where.push('un_read_at_ms IS NULL', NOT_ARCHIVED);
110
+ break;
111
+ case 'read':
112
+ where.push('un_read_at_ms IS NOT NULL', NOT_ARCHIVED);
113
+ break;
114
+ case 'archived':
115
+ where.push('un_archived_at_ms IS NOT NULL');
116
+ break;
117
+ default:
118
+ if (!ports_js_1.NOTIFICATION_STATUSES.includes(query.status)) {
119
+ throw new RangeError('MariaDbNotificationStore: status is out of range');
120
+ }
121
+ }
56
122
  if (query.unreadOnly)
57
123
  where.push('un_read_at_ms IS NULL');
124
+ if (query.fromMs !== undefined) {
125
+ assertEpochMs('fromMs', query.fromMs);
126
+ where.push('un_created_at_ms >= ?');
127
+ params.push(query.fromMs);
128
+ }
129
+ if (query.toMs !== undefined) {
130
+ assertEpochMs('toMs', query.toMs);
131
+ where.push('un_created_at_ms <= ?');
132
+ params.push(query.toMs);
133
+ }
134
+ if (query.search !== undefined) {
135
+ if (typeof query.search !== 'string' || query.search.length === 0) {
136
+ throw new RangeError('MariaDbNotificationStore: search is out of range');
137
+ }
138
+ const pattern = likeContainsPattern(query.search);
139
+ where.push("(un_title LIKE ? ESCAPE '!' OR un_body LIKE ? ESCAPE '!')");
140
+ params.push(pattern, pattern);
141
+ }
58
142
  const clause = where.join(' AND ');
59
143
  const total = countOf(await this.pool.query(`SELECT COUNT(*) AS c FROM ${this.table} WHERE ${clause}`, params));
60
144
  if (total === 0)
@@ -69,7 +153,7 @@ class MariaDbNotificationStore {
69
153
  }
70
154
  async countUnread(userId, tenantId) {
71
155
  const rows = (await this.pool.query(`SELECT un_category, COUNT(*) AS c FROM ${this.table}
72
- WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL
156
+ WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL AND ${NOT_ARCHIVED}
73
157
  GROUP BY un_category`, [userId, tenantId]));
74
158
  const counts = { announcement: 0, personal: 0 };
75
159
  for (const r of rows) {
@@ -88,10 +172,51 @@ class MariaDbNotificationStore {
88
172
  WHERE un_uuid = ? AND un_user_uuid = ? AND un_tenant_id = ? LIMIT 1`, [uuid, userId, tenantId]));
89
173
  return rows.length > 0;
90
174
  }
175
+ async listKinds(userId, tenantId) {
176
+ const rows = (await this.pool.query(`SELECT DISTINCT un_kind, un_category FROM ${this.table}
177
+ WHERE un_user_uuid = ? AND un_tenant_id = ?
178
+ ORDER BY un_kind, un_category`, [userId, tenantId]));
179
+ return rows
180
+ .filter((r) => isCategory(r.un_category))
181
+ .map((r) => ({ kind: String(r.un_kind), category: r.un_category }));
182
+ }
183
+ markUnread(userId, tenantId, uuid) {
184
+ return this.updateOne('unread', userId, tenantId, uuid, 0);
185
+ }
186
+ archive(userId, tenantId, uuid, nowMs) {
187
+ return this.updateOne('archive', userId, tenantId, uuid, nowMs);
188
+ }
189
+ unarchive(userId, tenantId, uuid) {
190
+ return this.updateOne('unarchive', userId, tenantId, uuid, 0);
191
+ }
192
+ async bulk(userId, tenantId, action, uuids, nowMs) {
193
+ if (!ports_js_1.NOTIFICATION_BULK_ACTIONS.includes(action)) {
194
+ throw new RangeError('MariaDbNotificationStore: action is out of range');
195
+ }
196
+ if (!Array.isArray(uuids) || uuids.length < 1 || uuids.length > ports_js_1.NOTIFICATION_BULK_MAX) {
197
+ throw new RangeError('MariaDbNotificationStore: uuids is out of range');
198
+ }
199
+ const a = ACTIONS[action];
200
+ const marks = uuids.map(() => '?').join(', ');
201
+ // Only the caller's own rows in this tenant can match; foreign or unknown uuids count 0.
202
+ return affected(await this.pool.query(`UPDATE ${this.table} SET ${a.set}
203
+ WHERE un_uuid IN (${marks}) AND un_user_uuid = ? AND un_tenant_id = ? AND ${a.changes}`, [...new Array(a.usesNow).fill(nowMs), ...uuids, userId, tenantId]));
204
+ }
205
+ /** One scoped single-notice update; 0 changed ⇒ a scoped lookup decides found / not found. */
206
+ async updateOne(action, userId, tenantId, uuid, nowMs) {
207
+ const a = ACTIONS[action];
208
+ const res = await this.pool.query(`UPDATE ${this.table} SET ${a.set}
209
+ WHERE un_uuid = ? AND un_user_uuid = ? AND un_tenant_id = ? AND ${a.changes}`, [...new Array(a.usesNow).fill(nowMs), uuid, userId, tenantId]);
210
+ if (affected(res) > 0)
211
+ return true;
212
+ const rows = (await this.pool.query(`SELECT 1 AS found FROM ${this.table}
213
+ WHERE un_uuid = ? AND un_user_uuid = ? AND un_tenant_id = ? LIMIT 1`, [uuid, userId, tenantId]));
214
+ return rows.length > 0;
215
+ }
91
216
  async markAllRead(userId, tenantId, category, nowMs) {
92
217
  const params = [nowMs, userId, tenantId];
93
218
  let sql = `UPDATE ${this.table} SET un_read_at_ms = ?
94
- WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL`;
219
+ WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL AND ${NOT_ARCHIVED}`;
95
220
  if (category !== undefined) {
96
221
  sql += ' AND un_category = ?';
97
222
  params.push(category);
@@ -1,6 +1,6 @@
1
1
  import type { Pool } from 'mariadb';
2
2
  import { type FrameworkSchemaNames } from '../config/framework-schema-names.js';
3
- import { type NotificationCategory, type NotificationKindRegistration, type NotificationStore, type NotificationWriteOptions } from './ports.js';
3
+ import { type NotificationCategory, type NotificationKindRegistration, type NotificationSeverity, type NotificationStore, type NotificationWriteOptions } from './ports.js';
4
4
  /** SPEC §10 limits. */
5
5
  export declare const NOTIFICATION_TITLE_MAX = 160;
6
6
  export declare const NOTIFICATION_BODY_MAX = 1000;
@@ -30,17 +30,46 @@ export interface NotificationPostResult {
30
30
  readonly created: number;
31
31
  readonly skipped: number;
32
32
  }
33
- /** Validated kind registry: kind ⇒ category. */
34
- export type NotificationKindRegistry = ReadonlyMap<string, NotificationCategory>;
33
+ /** A kind's label, severity and category, as the API shows them (notification-center SPEC §5A). */
34
+ export interface NotificationKindInfo {
35
+ readonly label: string;
36
+ readonly severity: NotificationSeverity;
37
+ /**
38
+ * The registered category; for a kind no longer registered, the category the caller passed
39
+ * (the stored row's), else `undefined`.
40
+ */
41
+ readonly category: NotificationCategory | undefined;
42
+ }
43
+ /** One validated registration in the registry. */
44
+ export interface NotificationKindDefinition {
45
+ readonly category: NotificationCategory;
46
+ readonly label: string;
47
+ readonly severity: NotificationSeverity;
48
+ /** `true` when the app gave no label and it was generated from the kind (boot warning). */
49
+ readonly labelGenerated: boolean;
50
+ }
51
+ /** Validated kind registry: kind ⇒ category, label, severity. */
52
+ export type NotificationKindRegistry = ReadonlyMap<string, NotificationKindDefinition>;
53
+ /**
54
+ * The label generated from a kind's last segment (`app.task_assigned` ⇒ "Task assigned"): `_`
55
+ * becomes a space, the first letter upper-case; over 40 code points ⇒ the first 39 and "…".
56
+ * Total for any string (an old row's kind is shown, never thrown on).
57
+ */
58
+ export declare function generatedKindLabel(kind: string): string;
59
+ /** The info of a kind the registry does not know (an old row): generated label, `info`. */
60
+ export declare function fallbackKindInfo(kind: string, storedCategory?: NotificationCategory): NotificationKindInfo;
35
61
  /**
36
62
  * Build the kind registry from the app's `notificationKinds` (validated at boot, SPEC §5C) and the
37
63
  * framework's own kinds. Refuses a malformed or over-long kind, an unknown category, a duplicate,
38
- * and an app kind under the reserved `shield.` prefix; each error names the kind.
64
+ * an app kind under the reserved `shield.` prefix, a bad label (not 1–40 characters of plain text)
65
+ * and an unknown severity; each error names the kind, never the label.
39
66
  */
40
67
  export declare function resolveNotificationKinds(appKinds: readonly NotificationKindRegistration[] | undefined, frameworkKinds?: readonly NotificationKindRegistration[]): NotificationKindRegistry;
41
- /** Logs counts only (Nest `Logger` shape). */
68
+ /** Logs counts and kind names only (Nest `Logger` shape). */
42
69
  export interface NotificationServiceLogger {
43
70
  debug(message: string): void;
71
+ /** The one boot warning naming kinds registered without a label (absent ⇒ not logged). */
72
+ warn?(message: string): void;
44
73
  }
45
74
  export interface NotificationServiceOptions {
46
75
  /** Default `Date.now`. */
@@ -64,6 +93,12 @@ export declare class NotificationService {
64
93
  schemas?: FrameworkSchemaNames, options?: NotificationServiceOptions);
65
94
  /** Whether `kind` is registered (framework or app). */
66
95
  hasKind(kind: string): boolean;
96
+ /**
97
+ * The label, severity and category shown for `kind` (notification-center SPEC §5A). A kind no
98
+ * longer registered (old rows stay readable) ⇒ a label generated from the kind, `info`, and
99
+ * `storedCategory` (the row's) as the category.
100
+ */
101
+ kindInfo(kind: string, storedCategory?: NotificationCategory): NotificationKindInfo;
67
102
  post(input: NotificationPostInput, opts?: NotificationWriteOptions): Promise<NotificationPostResult>;
68
103
  /** ONE parameterized SELECT: active users with an active membership in `tenantId`. */
69
104
  private activeRecipients;
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../src/notifications/notification.service.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAOL,KAAK,oBAAoB,EAEzB,KAAK,4BAA4B,EAEjC,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AAEpB,uBAAuB;AACvB,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAOhD,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,4BAA4B,EAE/E,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,CAAC,EAA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WAAW,0BAA0B;IACzC,0BAA0B;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,sCAAsC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,yBAAyB,CAAC;CAC7C;AAED,qBAAa,mBAAmB;IAO5B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,yFAAyF;IACzF,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IATxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;gBAGhC,KAAK,EAAE,iBAAiB;IACzC,yFAAyF;IACxE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EACzB,KAAK,EAAE,wBAAwB;IAChD,yFAAyF;IACzF,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,GAAE,0BAA+B;IAkB1C,uDAAuD;IACvD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,oBAAoB,GAAG,oBAAoB;IAM7E,IAAI,CACR,KAAK,EAAE,qBAAqB,EAC5B,IAAI,GAAE,wBAA6B,GAClC,OAAO,CAAC,sBAAsB,CAAC;IA8ClC,sFAAsF;YACxE,gBAAgB;CAwB/B"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NotificationService = exports.FRAMEWORK_NOTIFICATION_KINDS = exports.FRAMEWORK_KIND_PREFIX = exports.NOTIFICATION_RECIPIENTS_MAX = exports.NOTIFICATION_LINK_MAX = exports.NOTIFICATION_BODY_MAX = exports.NOTIFICATION_TITLE_MAX = void 0;
4
+ exports.generatedKindLabel = generatedKindLabel;
5
+ exports.fallbackKindInfo = fallbackKindInfo;
4
6
  exports.resolveNotificationKinds = resolveNotificationKinds;
5
7
  /**
6
8
  * `NotificationService` — the one way app and framework code posts notices (notification-store
@@ -22,6 +24,10 @@ exports.resolveNotificationKinds = resolveNotificationKinds;
22
24
  *
23
25
  * The tenant is the caller's server-side decision (e.g. the session's active company or the
24
26
  * granting transaction's company), never request input passed through unchecked (core 50 #7).
27
+ *
28
+ * G-035 (notification-center SPEC §5A): each kind carries a `label` and a `severity`, checked at
29
+ * boot by {@link resolveNotificationKinds}; `kindInfo(kind)` answers them at read time (labels are
30
+ * never stored), with a generated fallback for a kind no longer registered.
25
31
  */
26
32
  const node_crypto_1 = require("node:crypto");
27
33
  const common_1 = require("@nestjs/common");
@@ -39,6 +45,13 @@ const DEDUPE_KEY_PATTERN = /^[A-Za-z0-9._:-]{1,64}$/;
39
45
  const CONTROL_CHARS = /[\u0000-\u001f\u007f]/;
40
46
  // eslint-disable-next-line no-control-regex
41
47
  const CONTROL_CHARS_EXCEPT_NEWLINE = /[\u0000-\u0009\u000b-\u001f\u007f]/;
48
+ /**
49
+ * Not allowed in a kind label (shown to every company): C0/C1 controls, DEL, zero-width and
50
+ * direction-override characters, which could hide or reorder the visible text.
51
+ */
52
+ const LABEL_DISALLOWED =
53
+ // eslint-disable-next-line no-control-regex
54
+ /[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2060-\u2069\ufeff]/;
42
55
  /** The prefix reserved for the framework's own kinds. */
43
56
  exports.FRAMEWORK_KIND_PREFIX = 'shield.';
44
57
  /**
@@ -46,7 +59,12 @@ exports.FRAMEWORK_KIND_PREFIX = 'shield.';
46
59
  * `AccessChangeNotifier`, a personal notice listing the recipient's gained / lost capabilities).
47
60
  */
48
61
  exports.FRAMEWORK_NOTIFICATION_KINDS = [
49
- { kind: `${exports.FRAMEWORK_KIND_PREFIX}access_changed`, category: 'personal' },
62
+ {
63
+ kind: `${exports.FRAMEWORK_KIND_PREFIX}access_changed`,
64
+ category: 'personal',
65
+ label: 'Access change',
66
+ severity: 'info',
67
+ },
50
68
  ];
51
69
  /** Length in characters (code points), as `VARCHAR(n)` in utf8mb4 counts them. */
52
70
  function codePoints(s) {
@@ -55,10 +73,36 @@ function codePoints(s) {
55
73
  function isCategory(v) {
56
74
  return ports_js_1.NOTIFICATION_CATEGORIES.includes(v);
57
75
  }
76
+ function isSeverity(v) {
77
+ return ports_js_1.NOTIFICATION_SEVERITIES.includes(v);
78
+ }
79
+ /**
80
+ * The label generated from a kind's last segment (`app.task_assigned` ⇒ "Task assigned"): `_`
81
+ * becomes a space, the first letter upper-case; over 40 code points ⇒ the first 39 and "…".
82
+ * Total for any string (an old row's kind is shown, never thrown on).
83
+ */
84
+ function generatedKindLabel(kind) {
85
+ const last = kind.slice(kind.lastIndexOf('.') + 1);
86
+ const words = last.split('_').filter((w) => w.length > 0);
87
+ const joined = words.join(' ');
88
+ if (joined === '')
89
+ return 'Notification';
90
+ // Upper-case first, then count: one code point can grow ("ß" ⇒ "SS").
91
+ const first = Array.from(joined)[0];
92
+ const chars = Array.from(first.toUpperCase() + joined.slice(first.length));
93
+ return chars.length > ports_js_1.NOTIFICATION_LABEL_MAX
94
+ ? `${chars.slice(0, ports_js_1.NOTIFICATION_LABEL_MAX - 1).join('')}…`
95
+ : chars.join('');
96
+ }
97
+ /** The info of a kind the registry does not know (an old row): generated label, `info`. */
98
+ function fallbackKindInfo(kind, storedCategory) {
99
+ return { label: generatedKindLabel(kind), severity: 'info', category: storedCategory };
100
+ }
58
101
  /**
59
102
  * Build the kind registry from the app's `notificationKinds` (validated at boot, SPEC §5C) and the
60
103
  * framework's own kinds. Refuses a malformed or over-long kind, an unknown category, a duplicate,
61
- * and an app kind under the reserved `shield.` prefix; each error names the kind.
104
+ * an app kind under the reserved `shield.` prefix, a bad label (not 1–40 characters of plain text)
105
+ * and an unknown severity; each error names the kind, never the label.
62
106
  */
63
107
  function resolveNotificationKinds(appKinds, frameworkKinds = exports.FRAMEWORK_NOTIFICATION_KINDS) {
64
108
  if (appKinds !== undefined && !Array.isArray(appKinds)) {
@@ -68,6 +112,8 @@ function resolveNotificationKinds(appKinds, frameworkKinds = exports.FRAMEWORK_N
68
112
  const add = (entry, framework) => {
69
113
  const kind = entry?.kind;
70
114
  const category = entry?.category;
115
+ const label = entry?.label;
116
+ const severity = entry?.severity;
71
117
  if (typeof kind !== 'string') {
72
118
  throw ports_js_1.NotificationKindError.registration(kind, 'must be a string');
73
119
  }
@@ -83,10 +129,28 @@ function resolveNotificationKinds(appKinds, frameworkKinds = exports.FRAMEWORK_N
83
129
  if (!isCategory(category)) {
84
130
  throw ports_js_1.NotificationKindError.registration(kind, 'needs a category: announcement or personal');
85
131
  }
132
+ // An app label is trimmed, then must be 1–40 code points with no control character (a longer
133
+ // one fails the boot; only a GENERATED label is cut). The label itself is never printed.
134
+ const text = typeof label === 'string' ? label.trim() : undefined;
135
+ if (label !== undefined &&
136
+ (text === undefined ||
137
+ codePoints(text) < 1 ||
138
+ codePoints(text) > ports_js_1.NOTIFICATION_LABEL_MAX ||
139
+ LABEL_DISALLOWED.test(text))) {
140
+ throw ports_js_1.NotificationKindError.registration(kind, `needs a label of 1 to ${ports_js_1.NOTIFICATION_LABEL_MAX} characters of plain text (no control, zero-width or direction characters)`);
141
+ }
142
+ if (severity !== undefined && !isSeverity(severity)) {
143
+ throw ports_js_1.NotificationKindError.registration(kind, 'needs a severity: info, success or warning');
144
+ }
86
145
  if (registry.has(kind)) {
87
146
  throw ports_js_1.NotificationKindError.registration(kind, 'is registered more than once');
88
147
  }
89
- registry.set(kind, category);
148
+ registry.set(kind, {
149
+ category,
150
+ label: text ?? generatedKindLabel(kind),
151
+ severity: severity ?? 'info',
152
+ labelGenerated: text === undefined,
153
+ });
90
154
  };
91
155
  for (const entry of frameworkKinds)
92
156
  add(entry, true);
@@ -115,11 +179,29 @@ class NotificationService {
115
179
  this.membershipTable = (0, framework_schema_names_js_1.qualifiedTableName)(s.app, 'company_membership');
116
180
  this.now = options.now ?? Date.now;
117
181
  this.logger = options.logger ?? new common_1.Logger('Shield');
182
+ // One boot warning (the service is built once per app): kind names only, never a label.
183
+ const unlabelled = [...this.kinds]
184
+ .filter(([, def]) => def.labelGenerated)
185
+ .map(([kind]) => kind);
186
+ if (unlabelled.length > 0) {
187
+ this.logger.warn?.(`[notifications] kinds without a label (generated from the kind): ${unlabelled.join(', ')}`);
188
+ }
118
189
  }
119
190
  /** Whether `kind` is registered (framework or app). */
120
191
  hasKind(kind) {
121
192
  return this.kinds.has(kind);
122
193
  }
194
+ /**
195
+ * The label, severity and category shown for `kind` (notification-center SPEC §5A). A kind no
196
+ * longer registered (old rows stay readable) ⇒ a label generated from the kind, `info`, and
197
+ * `storedCategory` (the row's) as the category.
198
+ */
199
+ kindInfo(kind, storedCategory) {
200
+ const def = this.kinds.get(kind);
201
+ if (def === undefined)
202
+ return fallbackKindInfo(kind, storedCategory);
203
+ return { label: def.label, severity: def.severity, category: def.category };
204
+ }
123
205
  async post(input, opts = {}) {
124
206
  if (typeof input !== 'object' || input === null) {
125
207
  throw new ports_js_1.NotificationValidationError('input', 'must be an object');
@@ -130,7 +212,7 @@ class NotificationService {
130
212
  const tenantId = (0, engine_1.canonicalUuid)(input.tenantId);
131
213
  if (tenantId === null)
132
214
  throw new ports_js_1.NotificationValidationError('tenantId', 'must be a uuid');
133
- const category = typeof input.kind === 'string' ? this.kinds.get(input.kind) : undefined;
215
+ const category = typeof input.kind === 'string' ? this.kinds.get(input.kind)?.category : undefined;
134
216
  if (category === undefined)
135
217
  throw new ports_js_1.NotificationKindError(input.kind);
136
218
  const title = validTitle(input.title);
@@ -1,11 +1,17 @@
1
1
  import type { SessionTokenBinder } from '../request-auth/session-token-binder.js';
2
2
  import type { MfaRequirementService } from '../session/mfa-requirement-service.js';
3
- import { type NotificationCategory, type NotificationStore } from './ports.js';
3
+ import { type NotificationService } from './notification.service.js';
4
+ import { type NotificationCategory, type NotificationSeverity, type NotificationStore } from './ports.js';
5
+ /** Longest `search` after trimming, in code points (notification-center SPEC §3). */
6
+ export declare const NOTIFICATION_SEARCH_MAX = 100;
4
7
  /** One notice as the API returns it: no tenant id, user id or dedupe key (SPEC §5D). */
5
8
  export interface NotificationView {
6
9
  readonly uuid: string;
7
10
  readonly category: NotificationCategory;
8
11
  readonly kind: string;
12
+ /** The kind's registered label, or one generated from the kind (never the raw kind). */
13
+ readonly kindLabel: string;
14
+ readonly severity: NotificationSeverity;
9
15
  readonly title: string;
10
16
  readonly body: string | null;
11
17
  readonly link: string | null;
@@ -13,6 +19,13 @@ export interface NotificationView {
13
19
  readonly createdAt: string;
14
20
  /** ISO 8601; `null` ⇒ unread. */
15
21
  readonly readAt: string | null;
22
+ /** ISO 8601; `null` ⇒ not archived. */
23
+ readonly archivedAt: string | null;
24
+ }
25
+ export interface NotificationKindView {
26
+ readonly kind: string;
27
+ readonly label: string;
28
+ readonly category: NotificationCategory;
16
29
  }
17
30
  export interface NotificationListView {
18
31
  readonly total: number;
@@ -30,7 +43,9 @@ export declare class NotificationsController {
30
43
  private readonly binder?;
31
44
  private readonly store?;
32
45
  private readonly mfaRequirement?;
33
- constructor(binder?: SessionTokenBinder | undefined, store?: (NotificationStore | null) | undefined, mfaRequirement?: (MfaRequirementService | null) | undefined);
46
+ private readonly notifications?;
47
+ constructor(binder?: SessionTokenBinder | undefined, store?: (NotificationStore | null) | undefined, mfaRequirement?: (MfaRequirementService | null) | undefined, notifications?: (NotificationService | null) | undefined);
48
+ private kindInfo;
34
49
  /**
35
50
  * The caller's claims after the mandatory-2FA refresh and the restriction gate (mirrors
36
51
  * `AccountController.requireClaims` + `enforceReenroll(claims, false)`): no notification route is
@@ -38,20 +53,45 @@ export declare class NotificationsController {
38
53
  */
39
54
  private requireSession;
40
55
  private requireStore;
41
- /** `GET /account/notifications` — newest first ⇒ `{ total, rows, page, limit }`. */
56
+ /**
57
+ * `GET /account/notifications` — newest first ⇒ `{ total, rows, page, limit }`. Filters
58
+ * `category`, `unread`, `kind`, `status` (absent ⇒ not archived), `from` / `to` (UTC days,
59
+ * inclusive), `search` (title or body; blank ⇒ no search).
60
+ */
42
61
  list(authorization: string | undefined, query: QueryParams): Promise<NotificationListView>;
62
+ /**
63
+ * `GET /account/notifications/kinds` ⇒ `{ kinds: [{ kind, label, category }] }`: the types the
64
+ * caller has notices of in the active company (the Type filter). The category is the stored one.
65
+ */
66
+ kinds(authorization: string | undefined): Promise<{
67
+ kinds: NotificationKindView[];
68
+ }>;
43
69
  /** `GET /account/notifications/unread-count` ⇒ `{ announcement, personal, total }`. */
44
70
  unreadCount(authorization: string | undefined): Promise<NotificationUnreadCountView>;
45
71
  /** `POST /account/notifications/read-all?category=` ⇒ `{ updated }`. */
46
72
  readAll(authorization: string | undefined, query: QueryParams): Promise<{
47
73
  updated: number;
48
74
  }>;
75
+ /**
76
+ * `POST /account/notifications/bulk` body `{ action: read|unread|archive|unarchive, uuids:
77
+ * 1–100 }` ⇒ `{ updated }`: the number of the caller's own notices in the active company that
78
+ * changed (another user's or company's uuid, or an unknown one, counts 0).
79
+ */
80
+ bulk(authorization: string | undefined, body: unknown): Promise<{
81
+ updated: number;
82
+ }>;
49
83
  /**
50
84
  * `POST /account/notifications/:uuid/read` ⇒ 204 (idempotent: the first read time is kept).
51
85
  * The uuid is canonicalised here, after the session check (401 before 400), as
52
86
  * `/account/mfa/devices/:id` does.
53
87
  */
54
88
  read(authorization: string | undefined, rawUuid: string): Promise<void>;
89
+ /** `POST /account/notifications/:uuid/unread` ⇒ 204 (an archived notice stays read). */
90
+ unread(authorization: string | undefined, rawUuid: string): Promise<void>;
91
+ /** `POST /account/notifications/:uuid/archive` ⇒ 204 (idempotent; also marks it read). */
92
+ archive(authorization: string | undefined, rawUuid: string): Promise<void>;
93
+ /** `POST /account/notifications/:uuid/unarchive` ⇒ 204 (idempotent; it comes back as read). */
94
+ unarchive(authorization: string | undefined, rawUuid: string): Promise<void>;
55
95
  }
56
96
  export {};
57
97
  //# sourceMappingURL=notifications.controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.controller.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications.controller.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAEV,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAEnF,OAAO,EAEL,KAAK,oBAAoB,EAEzB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AASpB,wFAAwF;AACxF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB;IAChB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,EAAE,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AA8ED,KAAK,WAAW,GAAG,MAAM,CAAC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