@astram/guard 0.26.0 → 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.
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/notifications/mariadb-notification-store.d.ts +26 -1
- package/dist/notifications/mariadb-notification-store.d.ts.map +1 -1
- package/dist/notifications/mariadb-notification-store.js +128 -3
- package/dist/notifications/notification.service.d.ts +40 -5
- package/dist/notifications/notification.service.d.ts.map +1 -1
- package/dist/notifications/notification.service.js +86 -4
- package/dist/notifications/notifications.controller.d.ts +43 -3
- package/dist/notifications/notifications.controller.d.ts.map +1 -1
- package/dist/notifications/notifications.controller.js +233 -6
- package/dist/notifications/ports.d.ts +52 -2
- package/dist/notifications/ports.d.ts.map +1 -1
- package/dist/notifications/ports.js +12 -2
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -44,8 +44,8 @@ export { S3ObjectStore, type S3ObjectStoreConfig, type S3ObjectStoreOptions, } f
|
|
|
44
44
|
export { NodeSha256Digest } from './storage/node-sha256-digest.js';
|
|
45
45
|
export { NodeSha256Hash } from './audit/node-sha256-hash.js';
|
|
46
46
|
export { loadAuditSealConfig, type AuditSealConfig } from './audit/audit-seal-config.js';
|
|
47
|
-
export { NotificationService, type NotificationPostInput, type NotificationPostResult, } from './notifications/notification.service.js';
|
|
48
|
-
export { NOTIFICATION_CATEGORIES, NotificationKindError, NotificationValidationError, NotificationUnavailableError, type NotificationCategory, type NotificationKindRegistration, type NotificationQuery, type NotificationWriteOptions, } from './notifications/ports.js';
|
|
47
|
+
export { NotificationService, type NotificationKindInfo, type NotificationPostInput, type NotificationPostResult, } from './notifications/notification.service.js';
|
|
48
|
+
export { NOTIFICATION_CATEGORIES, NOTIFICATION_SEVERITIES, NOTIFICATION_STATUSES, NOTIFICATION_BULK_ACTIONS, NotificationKindError, NotificationValidationError, NotificationUnavailableError, type NotificationBulkAction, type NotificationCategory, type NotificationKindRegistration, type NotificationQuery, type NotificationSeverity, type NotificationStatus, type NotificationWriteOptions, } from './notifications/ports.js';
|
|
49
49
|
export { loadNotificationConfig, type NotificationConfig } from './config/notification-config.js';
|
|
50
50
|
export { SHIELD_NOTIFICATIONS } from './auth/tokens.js';
|
|
51
51
|
export { ObjectStoreBootCheck } from './storage/object-store-boot-check.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASzD,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAE9C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EACV,SAAS,GACV,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,YAAY,EACZ,yBAAyB,EAGzB,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAI7B,KAAK,yBAAyB,GAC/B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,MAAM,EACN,UAAU,EACV,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,2CAA2C,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAKhF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAKpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACjG,YAAY,EAAE,gBAAgB,EAAE,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tE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAClF,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAK5E,YAAY,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAMlE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAOjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,KAAK,mBAAmB,GACzB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAQ5E,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.assertNoUnresolvedSecretRefs = exports.createSecretsProviderFromEnv = exports.resolveBootSecrets = exports.EncryptedFileSecretsProvider = exports.LocalKekCrypto = exports.resolveAuthLinkBaseUrls = exports.CredentialExistsError = exports.isLockedHash = exports.lockedPasswordHash = exports.SHIELD_PASSWORD_HASHER = exports.argon2idHasherProvider = exports.Argon2idPasswordHasher = exports.stubDecisionAuthority = exports.GlobalEnforcementGuard = exports.NO_SESSION_FACTS = exports.SHIELD_SESSION_FACTS_ALS = exports.MariaDbApiKeyStore = exports.isApiKey = exports.extractBearerToken = exports.principalFromClaims = exports.resolveRequestAuth = exports.resolveRequestPrincipal = exports.SessionTokenBinder = exports.SHIELD_SERVICE_AUTHENTICATOR = exports.SHIELD_SESSION_TOKEN_BINDER = exports.CatalogGatabilityError = exports.CatalogReconciler = exports.OperationInventoryScanner = exports.uuidArrayField = exports.optionalUuidField = exports.uuidField = exports.UuidPipe = exports.normalizeClassification = exports.DEFAULT_CLASSIFIED_ACTION = exports.CLASSIFICATION_METADATA = exports.Classified = exports.Public = exports.SHIELD_RECORD_AUTHORIZATION = exports.SHIELD_DECISION_AUTHORITY = exports.ShieldModule = exports.actionsOf = exports.actionsFor = exports.SERVICE_ACCOUNT_ACTIONS = exports.RECORD_SHARE_ACTIONS = exports.CROSS_TENANT_GRANT_ACTIONS = exports.IDENTITY_ACTIONS = exports.MODULE_KEY = exports.permissionTextByKey = exports.buildIdentityModuleRegistry = exports.guardMigrationsDir = void 0;
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.ScopeUnknownParentError = exports.ScopeDepthError = exports.ScopeCycleError = exports.buildClosureRows = exports.ConfirmEmailController = exports.AccountController = exports.generateRecoveryCodes = exports.buildOtpauthUri = exports.generateTotpSecret = exports.SHIELD_LOGIN_TOTP_VERIFIER = exports.SHIELD_MFA_STEP_UP = exports.SHIELD_MFA_LIMITER = exports.challengeMatches = exports.credentialFingerprint = exports.CredentialMfaStepUp = exports.RedisPendingMfaStore = exports.PendingMfaStore = exports.AuthController = exports.SHIELD_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_SESSION_FACTS_PROJECTOR = exports.ProfileNameTakenError = exports.maskPhone = exports.MAX_MESSAGE_SEND_TIMEOUT_MS = exports.DEFAULT_MESSAGE_SEND_TIMEOUT_MS = exports.EMAIL_PROVIDER_VALUES = exports.loadMessageConfig = exports.MariaDbEmailAddressChanger = void 0;
|
|
20
|
+
exports.MariaDbRecordShareAdapter = exports.UnknownScopeFieldError = exports.translateListScope = exports.SHIELD_LIST_SCOPE_PORT = exports.MariaDbListScopeAdapter = exports.SHIELD_POLICY_STORE = exports.MariaDbPolicyStore = exports.SHIELD_RECORD_RULE_PORT = exports.MariaDbRecordPermissionRuleAdapter = exports.accessBindingTtlMs = exports.ROTATE_GRACE_MS = exports.SHIELD_SESSION_LIFETIMES = exports.HotRevokingSessionRecordStore = exports.SHIELD_CLOCK = exports.SHIELD_REFRESH_HASHER = exports.SHIELD_TOKEN_GENERATOR = exports.systemClockProvider = exports.refreshHasherProvider = exports.cryptoTokenGeneratorProvider = exports.SystemClock = exports.Sha256RefreshTokenHasher = exports.CryptoTokenGenerator = exports.RedisRecentRotationStore = exports.SHIELD_HOT_SESSION_STORE = exports.RedisHotSessionStore = exports.SHIELD_SESSION_RECORD_STORE = exports.MariaDbSessionRecordStore = exports.DEFAULT_OBJECT_STORAGE_MAX_BYTES = exports.loadObjectStorageConfig = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.FILE_INTAKE_DEFAULT_MAX_BYTES = exports.FILE_INTAKE_REQUEST_KEY = exports.FileIntake = exports.ObjectStoreBootCheck = exports.SHIELD_NOTIFICATIONS = exports.loadNotificationConfig = exports.NotificationUnavailableError = exports.NotificationValidationError = exports.NotificationKindError = exports.NOTIFICATION_BULK_ACTIONS = exports.NOTIFICATION_STATUSES = exports.NOTIFICATION_SEVERITIES = exports.NOTIFICATION_CATEGORIES = exports.NotificationService = exports.loadAuditSealConfig = exports.NodeSha256Hash = exports.NodeSha256Digest = exports.S3ObjectStore = exports.wasResolvedFromSecretRef = void 0;
|
|
21
|
+
exports.loadLoginIpLimit = exports.DEFAULT_REDIS_URL = exports.DEFAULT_DB_CONFIG = exports.assertRefreshHmacKey = exports.loadRefreshHmacKey = exports.loadSessionLifetimes = exports.loadRedisConfig = exports.loadDbConfig = exports.SCHEMA_SVC_POOL_HARD_CAP = exports.DEFAULT_POOL_BUDGET = exports.evaluatePoolBudget = exports.loadPoolBudget = exports.loadAppConfig = exports.frameworkSchemasOf = exports.FRAMEWORK_SCHEMAS = exports.APP_CONFIG = exports.resolveMigrationLedgerCheck = exports.resolveMigrationLedger = exports.frameworkMigrationIds = exports.assertFrameworkMigrationsApplied = exports.SHIELD_MIGRATION_LEDGER_REGISTRY = exports.MigrationLedgerRegistry = exports.FrameworkMigrationLedgerCheck = exports.frameworkDatabasesLogLine = exports.assertPoolBudget = exports.BootSequence = exports.buildListScopeFn = exports.MariaDbSessionRestrictionStore = exports.SHIELD_SESSION_RESTRICTIONS = exports.SHIELD_PERMISSION_VERSION_CACHE = exports.DEFAULT_PERMISSION_VERSION_TTL_MS = exports.PERMISSION_VERSION_KEY_PREFIX = exports.RedisPermissionVersionCache = exports.withRedisPermissionVersion = exports.buildRecordAuthorization = exports.SHIELD_OPERATION_AUTHORITY_PORT = exports.ManifestOperationAuthorityAdapter = exports.GrantStoreUnavailableError = exports.InvalidGrantError = exports.GrantNotPermittedError = exports.SHIELD_CROSS_TENANT_GRANT_WRITER = exports.CrossTenantGrantWriter = exports.SHIELD_CROSS_TENANT_GRANT_PORT = exports.MariaDbCrossTenantGrantAdapter = exports.makeShareDeleteCascade = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHIELD_RECORD_SHARE_WRITER = exports.RecordShareWriter = exports.SHIELD_RECORD_SHARE_PORT = void 0;
|
|
22
|
+
exports.hmacSha1 = exports.resolveTotpVerifier = exports.makeDefaultTotpVerifier = exports.AuthModule = exports.SHIELD_CAPTCHA_GATE = exports.RECAPTCHA_SITEVERIFY_URL = exports.RecaptchaVerifier = exports.TURNSTILE_SITEVERIFY_URL = exports.TurnstileVerifier = exports.MAX_CAPTCHA_TIMEOUT_MS = exports.DEFAULT_CAPTCHA_TIMEOUT_MS = exports.DEFAULT_CAPTCHA_MIN_SCORE = exports.DEFAULT_CAPTCHA_THRESHOLD = exports.CAPTCHA_FAIL_MODES = exports.CAPTCHA_MODES = exports.CAPTCHA_ENDPOINTS = exports.loadCaptchaConfig = exports.SHIELD_SIGN_IN_WITH = exports.DEFAULT_SIGN_IN_WITH = exports.resolveSignInWith = exports.MariaDbCredentialResolver = exports.SHIELD_TOTP_VERIFIER_OVERRIDE = exports.SHIELD_MFA_DEVICE_STORE = exports.SHIELD_AUDIT_SINK = exports.SHIELD_SESSION_SWEEPER = exports.SHIELD_PROFILE_WRITER = exports.SHIELD_RECOVERY_CODE_STORE = exports.SHIELD_MESSAGE_DISPATCHER = exports.SHIELD_EMAIL_SENDER = exports.SHIELD_EMAIL_CHANGE_TOKEN_STORE = exports.SHIELD_RESET_TOKEN_STORE = exports.SHIELD_CREDENTIAL_WRITER = exports.SHIELD_SESSION_AUTHORITY = exports.SHIELD_AUTHENTICATOR = exports.SHIELD_PROFILE_RESOLVER = exports.SHIELD_CREDENTIAL_RESOLVER = exports.SHIELD_REDIS = exports.withoutStatementTimeout = exports.mariadbPoolTuningOptions = exports.mariadbSslOption = exports.reservedOperationPrincipal = exports.RESERVED_OPERATION_PRINCIPALS = exports.assertNoReservedRootId = exports.ORG_BOOTSTRAP_PRINCIPAL_ID = exports.rootIdsFromEnv = exports.loadPoolTuning = exports.loadDbTlsConfig = exports.isDevOrTestNodeEnv = exports.DEFAULT_LOGIN_IP_LIMIT = exports.loadRefreshReplayWindowMs = void 0;
|
|
23
|
+
exports.ScopeUnknownParentError = exports.ScopeDepthError = exports.ScopeCycleError = exports.buildClosureRows = exports.ConfirmEmailController = exports.AccountController = exports.generateRecoveryCodes = exports.buildOtpauthUri = exports.generateTotpSecret = exports.SHIELD_LOGIN_TOTP_VERIFIER = exports.SHIELD_MFA_STEP_UP = exports.SHIELD_MFA_LIMITER = exports.challengeMatches = exports.credentialFingerprint = exports.CredentialMfaStepUp = exports.RedisPendingMfaStore = exports.PendingMfaStore = exports.AuthController = exports.SHIELD_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_SESSION_FACTS_PROJECTOR = exports.ProfileNameTakenError = exports.maskPhone = exports.MAX_MESSAGE_SEND_TIMEOUT_MS = exports.DEFAULT_MESSAGE_SEND_TIMEOUT_MS = exports.EMAIL_PROVIDER_VALUES = exports.loadMessageConfig = exports.MariaDbEmailAddressChanger = exports.maskEmail = exports.isEmailShaped = exports.canonicalEmail = void 0;
|
|
24
24
|
// Framework authz migrations (shield_authz DDL — permission / role_permission /
|
|
25
25
|
// authz_permission_version). Absolute path a consumer's `@astram/migrate` setup merges in.
|
|
26
26
|
var migrations_dir_js_1 = require("./migrations-dir.js");
|
|
@@ -163,10 +163,14 @@ var audit_seal_config_js_1 = require("./audit/audit-seal-config.js");
|
|
|
163
163
|
Object.defineProperty(exports, "loadAuditSealConfig", { enumerable: true, get: function () { return audit_seal_config_js_1.loadAuditSealConfig; } });
|
|
164
164
|
// Notification store (G-027 step 2, notification-store SPEC §5B, §5C, §5F): post notices under
|
|
165
165
|
// kinds registered in `ShieldModule.forRoot({ notificationKinds })`; bound with `auth: true`.
|
|
166
|
+
// G-035 (notification-center SPEC §5A, §6): kind `label` / `severity` and `kindInfo`.
|
|
166
167
|
var notification_service_js_1 = require("./notifications/notification.service.js");
|
|
167
168
|
Object.defineProperty(exports, "NotificationService", { enumerable: true, get: function () { return notification_service_js_1.NotificationService; } });
|
|
168
169
|
var ports_js_1 = require("./notifications/ports.js");
|
|
169
170
|
Object.defineProperty(exports, "NOTIFICATION_CATEGORIES", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_CATEGORIES; } });
|
|
171
|
+
Object.defineProperty(exports, "NOTIFICATION_SEVERITIES", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_SEVERITIES; } });
|
|
172
|
+
Object.defineProperty(exports, "NOTIFICATION_STATUSES", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_STATUSES; } });
|
|
173
|
+
Object.defineProperty(exports, "NOTIFICATION_BULK_ACTIONS", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_BULK_ACTIONS; } });
|
|
170
174
|
Object.defineProperty(exports, "NotificationKindError", { enumerable: true, get: function () { return ports_js_1.NotificationKindError; } });
|
|
171
175
|
Object.defineProperty(exports, "NotificationValidationError", { enumerable: true, get: function () { return ports_js_1.NotificationValidationError; } });
|
|
172
176
|
Object.defineProperty(exports, "NotificationUnavailableError", { enumerable: true, get: function () { return ports_js_1.NotificationUnavailableError; } });
|
|
@@ -15,12 +15,30 @@
|
|
|
15
15
|
* `lib/config/connection-options.js`), so an ODKU row left unchanged reports 1, the same as an
|
|
16
16
|
* insert. Instead the store counts its own freshly generated `un_uuid`s right after the insert, on
|
|
17
17
|
* the same `query` (the caller's transaction when given, so it sees its own uncommitted rows).
|
|
18
|
+
*
|
|
19
|
+
* G-035 (notification-center SPEC §5B; column `un_archived_at_ms`, identity migration 110):
|
|
20
|
+
* - `list` filters by kind, status, creation range and a title/body search. The search is
|
|
21
|
+
* `LIKE ? ESCAPE '!'` with `!`, `%`, `_` escaped as `!!`, `!%`, `!_` ({@link likeContainsPattern}):
|
|
22
|
+
* never `ESCAPE '\\'`, whose meaning changes under `NO_BACKSLASH_ESCAPES`; a backslash in the term
|
|
23
|
+
* is an ordinary character. Case and accents follow the column collation (`utf8mb4_unicode_ci`).
|
|
24
|
+
* - Without a status, archived notices are left out; `unread` / `read` leave them out too.
|
|
25
|
+
* - `countUnread` and `markAllRead` skip archived rows; `archive` also sets the read time when
|
|
26
|
+
* unread, so an archived notice never holds the badge; `unarchive` brings it back as read.
|
|
27
|
+
* - Every single-notice update puts its "would change" condition in the WHERE, so `affectedRows`
|
|
28
|
+
* (matched rows, `CLIENT_FOUND_ROWS`) counts changes only; 0 ⇒ one scoped lookup tells an
|
|
29
|
+
* unchanged own notice (found) from a foreign or unknown one (not found).
|
|
30
|
+
* - `purge` is unchanged: archiving never extends retention.
|
|
18
31
|
*/
|
|
19
32
|
import type { Pool } from 'mariadb';
|
|
20
33
|
import { type FrameworkSchemaNames } from '../config/framework-schema-names.js';
|
|
21
|
-
import { type NotificationCategory, type NotificationInsert, type NotificationListQuery, type NotificationListResult, type NotificationRetentionPolicy, type NotificationStore, type NotificationUnreadCounts, type NotificationWriteOptions } from './ports.js';
|
|
34
|
+
import { type NotificationBulkAction, type NotificationCategory, type NotificationInsert, type NotificationKindSummary, type NotificationListQuery, type NotificationListResult, type NotificationRetentionPolicy, type NotificationStore, type NotificationUnreadCounts, type NotificationWriteOptions } from './ports.js';
|
|
22
35
|
/** Rows per `insertMany` statement (the `post` recipient cap, SPEC §10). */
|
|
23
36
|
export declare const NOTIFICATION_INSERT_MAX_ROWS = 1000;
|
|
37
|
+
/**
|
|
38
|
+
* `%term%` for `LIKE ? ESCAPE '!'`: `!` first, then `%` and `_`, each prefixed with `!`. A
|
|
39
|
+
* backslash stays an ordinary character (no `sql_mode` dependence).
|
|
40
|
+
*/
|
|
41
|
+
export declare function likeContainsPattern(term: string): string;
|
|
24
42
|
export declare class MariaDbNotificationStore implements NotificationStore {
|
|
25
43
|
private readonly pool;
|
|
26
44
|
/** `<identity>`.`user_notification`, resolved at construction. */
|
|
@@ -31,6 +49,13 @@ export declare class MariaDbNotificationStore implements NotificationStore {
|
|
|
31
49
|
list(userId: string, tenantId: string, query: NotificationListQuery): Promise<NotificationListResult>;
|
|
32
50
|
countUnread(userId: string, tenantId: string): Promise<NotificationUnreadCounts>;
|
|
33
51
|
markRead(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
52
|
+
listKinds(userId: string, tenantId: string): Promise<readonly NotificationKindSummary[]>;
|
|
53
|
+
markUnread(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
54
|
+
archive(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
55
|
+
unarchive(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
56
|
+
bulk(userId: string, tenantId: string, action: NotificationBulkAction, uuids: readonly string[], nowMs: number): Promise<number>;
|
|
57
|
+
/** One scoped single-notice update; 0 changed ⇒ a scoped lookup decides found / not found. */
|
|
58
|
+
private updateOne;
|
|
34
59
|
markAllRead(userId: string, tenantId: string, category: NotificationCategory | undefined, nowMs: number): Promise<number>;
|
|
35
60
|
insertMany(rows: readonly NotificationInsert[], opts?: NotificationWriteOptions): Promise<number>;
|
|
36
61
|
purge(nowMs: number, policy: NotificationRetentionPolicy, maxRows: number): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-notification-store.d.ts","sourceRoot":"","sources":["../../src/notifications/mariadb-notification-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mariadb-notification-store.d.ts","sourceRoot":"","sources":["../../src/notifications/mariadb-notification-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE3B,KAAK,2BAA2B,EAEhC,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AAIpB,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAoDjD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAqCD,qBAAa,wBAAyB,YAAW,iBAAiB;IAK9D,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,kEAAkE;IAClE,O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AAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC;IAWZ,UAAU,CACd,IAAI,EAAE,SAAS,kBAAkB,EAAE,EACnC,IAAI,GAAE,wBAA6B,GAClC,OAAO,CAAC,MAAM,CAAC;IAuDZ,KAAK,CACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;CAiBnB"}
|
|
@@ -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
|
-
/**
|
|
34
|
-
export
|
|
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
|
-
*
|
|
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":"
|
|
1
|
+
{"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../src/notifications/notification.service.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EASL,KAAK,oBAAoB,EAEzB,KAAK,4BAA4B,EAEjC,KAAK,oBAAoB,EACzB,KAAK,iBAAi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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
|
-
{
|
|
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
|
-
*
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
-
/**
|
|
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":"
|
|
1
|
+
{"version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G,SAAS,GAC1D,OAAO,CAAC,2BAA2B,CAAC;IAWvC,wEAAwE;IAIlE,OAAO,CACe,aAAa,EAAE,MAAM,GAAG,SAAS,EAClD,KAAK,EAAE,WAAW,GAC1B,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAU/B;;;;OAIG;IAIG,IAAI,CACkB,aAAa,EAAE,MAAM,GAAG,SAAS,EACnD,IAAI,EAAE,OAAO,GACpB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAe/B;;;;OAIG;IAIG,IAAI,CACkB,aAAa,EAAE,MAAM,GAAG,SAAS,EAC5C,OAAO,EAAE,MAAM,GAC7B,OAAO,CAAC,IAAI,CAAC;IAQhB,wFAAwF;IAIlF,MAAM,CACgB,aAAa,EAAE,MAAM,GAAG,SAAS,EAC5C,OAAO,EAAE,MAAM,GAC7B,OAAO,CAAC,IAAI,CAAC;IAQhB,0FAA0F;IAIpF,OAAO,CACe,aAAa,EAAE,MAAM,GAAG,SAAS,EAC5C,OAAO,EAAE,MAAM,GAC7B,OAAO,CAAC,IAAI,CAAC;IAQhB,+FAA+F;IAIzF,SAAS,CACa,aAAa,EAAE,MAAM,GAAG,SAAS,EAC5C,OAAO,EAAE,MAAM,GAC7B,OAAO,CAAC,IAAI,CAAC;CAOjB"}
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.NotificationsController = void 0;
|
|
15
|
+
exports.NotificationsController = exports.NOTIFICATION_SEARCH_MAX = void 0;
|
|
16
16
|
/**
|
|
17
17
|
* `/account/notifications` — the signed-in user's own notice inbox (G-027 step 2,
|
|
18
18
|
* notification-store SPEC §3, §5D, §13).
|
|
@@ -30,20 +30,33 @@ exports.NotificationsController = void 0;
|
|
|
30
30
|
* Order on every route: 401 (no/invalid session) → 403 (restricted session) → 501 (store not
|
|
31
31
|
* wired) → 400 (bad query parameter or `:uuid`, naming the parameter, never echoing the value) →
|
|
32
32
|
* store call (any throw ⇒ 503 `notifications_unavailable`, the driver message never surfaces).
|
|
33
|
+
*
|
|
34
|
+
* G-035 (notification-center SPEC §3, §5C, §13): the list takes `kind`, `status`, `from` / `to`
|
|
35
|
+
* (UTC days, inclusive) and `search`; rows carry `kindLabel` / `severity` (from the kind
|
|
36
|
+
* registration, `NotificationService.kindInfo`) and `archivedAt`. New: `GET kinds`, `POST
|
|
37
|
+
* :uuid/{unread,archive,unarchive}` (as `:uuid/read`) and `POST bulk` ⇒ `{ updated }`. Static
|
|
38
|
+
* routes are declared before the `:uuid/*` ones.
|
|
33
39
|
*/
|
|
34
40
|
const common_1 = require("@nestjs/common");
|
|
41
|
+
const engine_1 = require("@astram/engine");
|
|
35
42
|
const classification_decorator_js_1 = require("../enforcement/classification.decorator.js");
|
|
36
43
|
const uuid_pipe_js_1 = require("../enforcement/uuid.pipe.js");
|
|
37
44
|
const request_principal_js_1 = require("../request-auth/request-principal.js");
|
|
38
45
|
const tokens_js_1 = require("../request-auth/tokens.js");
|
|
39
46
|
const tokens_js_2 = require("../auth/tokens.js");
|
|
40
47
|
const session_restriction_js_1 = require("../session/session-restriction.js");
|
|
48
|
+
const notification_service_js_1 = require("./notification.service.js");
|
|
41
49
|
const ports_js_1 = require("./ports.js");
|
|
42
50
|
/** Default and maximum page size (SPEC §10). */
|
|
43
51
|
const DEFAULT_LIMIT = 20;
|
|
44
52
|
const MAX_LIMIT = 100;
|
|
53
|
+
/** Longest `search` after trimming, in code points (notification-center SPEC §3). */
|
|
54
|
+
exports.NOTIFICATION_SEARCH_MAX = 100;
|
|
45
55
|
/** A decimal integer as a query string (no sign, no exponent, no whitespace). */
|
|
46
56
|
const DIGITS = /^[0-9]{1,16}$/;
|
|
57
|
+
/** An ISO calendar date `YYYY-MM-DD` (UTC day). */
|
|
58
|
+
const ISO_DATE = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/;
|
|
59
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
47
60
|
/** The generic 401, as `/account/*` (never distinguishes no token / bad token / API key). */
|
|
48
61
|
function unauthorized() {
|
|
49
62
|
throw new common_1.HttpException({ error: 'unauthorized' }, common_1.HttpStatus.UNAUTHORIZED);
|
|
@@ -95,16 +108,95 @@ function parseBoundedInt(name, value, fallback, max) {
|
|
|
95
108
|
badParameter(name);
|
|
96
109
|
return n;
|
|
97
110
|
}
|
|
98
|
-
|
|
111
|
+
/** Optional `kind`: absent ⇒ every kind; otherwise a well-formed kind (≤ 64, dotted segments). */
|
|
112
|
+
function parseKind(value) {
|
|
113
|
+
if (value === undefined)
|
|
114
|
+
return undefined;
|
|
115
|
+
if (typeof value !== 'string' ||
|
|
116
|
+
value.length > ports_js_1.NOTIFICATION_KIND_MAX_LENGTH ||
|
|
117
|
+
!ports_js_1.NOTIFICATION_KIND_PATTERN.test(value)) {
|
|
118
|
+
badParameter('kind');
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
/** Optional `status`: absent ⇒ not archived; otherwise `unread`, `read` or `archived`. */
|
|
123
|
+
function parseStatus(value) {
|
|
124
|
+
if (value === undefined)
|
|
125
|
+
return undefined;
|
|
126
|
+
if (typeof value !== 'string' || !ports_js_1.NOTIFICATION_STATUSES.includes(value)) {
|
|
127
|
+
badParameter('status');
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Optional ISO date `YYYY-MM-DD` as a UTC day ⇒ its first millisecond, or with `endOfDay` its
|
|
133
|
+
* last (inclusive days). A date that does not exist (2026-02-30) is refused.
|
|
134
|
+
*/
|
|
135
|
+
function parseDay(name, value, endOfDay) {
|
|
136
|
+
if (value === undefined)
|
|
137
|
+
return undefined;
|
|
138
|
+
const m = typeof value === 'string' ? ISO_DATE.exec(value) : null;
|
|
139
|
+
if (m === null)
|
|
140
|
+
return badParameter(name);
|
|
141
|
+
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
142
|
+
const start = Date.UTC(y, mo - 1, d);
|
|
143
|
+
const back = new Date(start);
|
|
144
|
+
if (y < 1970 ||
|
|
145
|
+
back.getUTCFullYear() !== y ||
|
|
146
|
+
back.getUTCMonth() !== mo - 1 ||
|
|
147
|
+
back.getUTCDate() !== d) {
|
|
148
|
+
badParameter(name);
|
|
149
|
+
}
|
|
150
|
+
return endOfDay ? start + DAY_MS - 1 : start;
|
|
151
|
+
}
|
|
152
|
+
/** Optional `search`: trimmed; empty ⇒ absent (not an error); over 100 code points ⇒ 400. */
|
|
153
|
+
function parseSearch(value) {
|
|
154
|
+
if (value === undefined)
|
|
155
|
+
return undefined;
|
|
156
|
+
if (typeof value !== 'string')
|
|
157
|
+
badParameter('search');
|
|
158
|
+
const term = value.trim();
|
|
159
|
+
if (term.length === 0)
|
|
160
|
+
return undefined;
|
|
161
|
+
if (Array.from(term).length > exports.NOTIFICATION_SEARCH_MAX)
|
|
162
|
+
badParameter('search');
|
|
163
|
+
return term;
|
|
164
|
+
}
|
|
165
|
+
/** Body `action` of `POST bulk`. */
|
|
166
|
+
function parseBulkAction(value) {
|
|
167
|
+
if (typeof value !== 'string' ||
|
|
168
|
+
!ports_js_1.NOTIFICATION_BULK_ACTIONS.includes(value)) {
|
|
169
|
+
badParameter('action');
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
/** Body `uuids` of `POST bulk`: 1–100 uuids, canonical and de-duplicated. */
|
|
174
|
+
function parseBulkUuids(value) {
|
|
175
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > ports_js_1.NOTIFICATION_BULK_MAX) {
|
|
176
|
+
throw new common_1.BadRequestException(`uuids must be a list of 1 to ${ports_js_1.NOTIFICATION_BULK_MAX} uuids`);
|
|
177
|
+
}
|
|
178
|
+
const out = new Set();
|
|
179
|
+
for (const v of value) {
|
|
180
|
+
const canonical = (0, engine_1.canonicalUuid)(v);
|
|
181
|
+
if (canonical === null)
|
|
182
|
+
throw new common_1.BadRequestException('uuids must contain uuids only');
|
|
183
|
+
out.add(canonical);
|
|
184
|
+
}
|
|
185
|
+
return [...out];
|
|
186
|
+
}
|
|
187
|
+
function toView(row, info) {
|
|
99
188
|
return {
|
|
100
189
|
uuid: row.uuid,
|
|
101
190
|
category: row.category,
|
|
102
191
|
kind: row.kind,
|
|
192
|
+
kindLabel: info.label,
|
|
193
|
+
severity: info.severity,
|
|
103
194
|
title: row.title,
|
|
104
195
|
body: row.body,
|
|
105
196
|
link: row.link,
|
|
106
197
|
createdAt: new Date(row.createdAtMs).toISOString(),
|
|
107
198
|
readAt: row.readAtMs === null ? null : new Date(row.readAtMs).toISOString(),
|
|
199
|
+
archivedAt: row.archivedAtMs === null ? null : new Date(row.archivedAtMs).toISOString(),
|
|
108
200
|
};
|
|
109
201
|
}
|
|
110
202
|
/** Run one store call; any throw is the fixed 503. */
|
|
@@ -120,10 +212,15 @@ let NotificationsController = class NotificationsController {
|
|
|
120
212
|
binder;
|
|
121
213
|
store;
|
|
122
214
|
mfaRequirement;
|
|
123
|
-
|
|
215
|
+
notifications;
|
|
216
|
+
constructor(binder, store, mfaRequirement, notifications) {
|
|
124
217
|
this.binder = binder;
|
|
125
218
|
this.store = store;
|
|
126
219
|
this.mfaRequirement = mfaRequirement;
|
|
220
|
+
this.notifications = notifications;
|
|
221
|
+
}
|
|
222
|
+
kindInfo(kind, category) {
|
|
223
|
+
return this.notifications?.kindInfo(kind, category) ?? (0, notification_service_js_1.fallbackKindInfo)(kind, category);
|
|
127
224
|
}
|
|
128
225
|
/**
|
|
129
226
|
* The caller's claims after the mandatory-2FA refresh and the restriction gate (mirrors
|
|
@@ -153,12 +250,24 @@ let NotificationsController = class NotificationsController {
|
|
|
153
250
|
notAvailable();
|
|
154
251
|
return this.store;
|
|
155
252
|
}
|
|
156
|
-
/**
|
|
253
|
+
/**
|
|
254
|
+
* `GET /account/notifications` — newest first ⇒ `{ total, rows, page, limit }`. Filters
|
|
255
|
+
* `category`, `unread`, `kind`, `status` (absent ⇒ not archived), `from` / `to` (UTC days,
|
|
256
|
+
* inclusive), `search` (title or body; blank ⇒ no search).
|
|
257
|
+
*/
|
|
157
258
|
async list(authorization, query) {
|
|
158
259
|
const claims = await this.requireSession(authorization);
|
|
159
260
|
const store = this.requireStore();
|
|
160
261
|
const category = parseCategory(query?.category);
|
|
161
262
|
const unreadOnly = parseUnread(query?.unread);
|
|
263
|
+
const kind = parseKind(query?.kind);
|
|
264
|
+
const status = parseStatus(query?.status);
|
|
265
|
+
const fromMs = parseDay('from', query?.from, false);
|
|
266
|
+
const toMs = parseDay('to', query?.to, true);
|
|
267
|
+
if (fromMs !== undefined && toMs !== undefined && fromMs > toMs) {
|
|
268
|
+
throw new common_1.BadRequestException('from must not be after to');
|
|
269
|
+
}
|
|
270
|
+
const search = parseSearch(query?.search);
|
|
162
271
|
const limit = parseBoundedInt('limit', query?.limit, DEFAULT_LIMIT, MAX_LIMIT);
|
|
163
272
|
const page = parseBoundedInt('page', query?.page, 1, Number.MAX_SAFE_INTEGER);
|
|
164
273
|
// The store refuses an offset past the safe-integer range; answer that as the caller's 400.
|
|
@@ -167,10 +276,36 @@ let NotificationsController = class NotificationsController {
|
|
|
167
276
|
const result = await guarded(() => store.list(claims.id, claims.tenantId, {
|
|
168
277
|
...(category !== undefined ? { category } : {}),
|
|
169
278
|
unreadOnly,
|
|
279
|
+
...(kind !== undefined ? { kind } : {}),
|
|
280
|
+
...(status !== undefined ? { status } : {}),
|
|
281
|
+
...(fromMs !== undefined ? { fromMs } : {}),
|
|
282
|
+
...(toMs !== undefined ? { toMs } : {}),
|
|
283
|
+
...(search !== undefined ? { search } : {}),
|
|
170
284
|
page,
|
|
171
285
|
limit,
|
|
172
286
|
}));
|
|
173
|
-
return {
|
|
287
|
+
return {
|
|
288
|
+
total: result.total,
|
|
289
|
+
rows: result.rows.map((r) => toView(r, this.kindInfo(r.kind, r.category))),
|
|
290
|
+
page,
|
|
291
|
+
limit,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* `GET /account/notifications/kinds` ⇒ `{ kinds: [{ kind, label, category }] }`: the types the
|
|
296
|
+
* caller has notices of in the active company (the Type filter). The category is the stored one.
|
|
297
|
+
*/
|
|
298
|
+
async kinds(authorization) {
|
|
299
|
+
const claims = await this.requireSession(authorization);
|
|
300
|
+
const store = this.requireStore();
|
|
301
|
+
const rows = await guarded(() => store.listKinds(claims.id, claims.tenantId));
|
|
302
|
+
return {
|
|
303
|
+
kinds: rows.map((r) => ({
|
|
304
|
+
kind: r.kind,
|
|
305
|
+
label: this.kindInfo(r.kind, r.category).label,
|
|
306
|
+
category: r.category,
|
|
307
|
+
})),
|
|
308
|
+
};
|
|
174
309
|
}
|
|
175
310
|
/** `GET /account/notifications/unread-count` ⇒ `{ announcement, personal, total }`. */
|
|
176
311
|
async unreadCount(authorization) {
|
|
@@ -191,6 +326,20 @@ let NotificationsController = class NotificationsController {
|
|
|
191
326
|
const updated = await guarded(() => store.markAllRead(claims.id, claims.tenantId, category, Date.now()));
|
|
192
327
|
return { updated };
|
|
193
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* `POST /account/notifications/bulk` body `{ action: read|unread|archive|unarchive, uuids:
|
|
331
|
+
* 1–100 }` ⇒ `{ updated }`: the number of the caller's own notices in the active company that
|
|
332
|
+
* changed (another user's or company's uuid, or an unknown one, counts 0).
|
|
333
|
+
*/
|
|
334
|
+
async bulk(authorization, body) {
|
|
335
|
+
const claims = await this.requireSession(authorization);
|
|
336
|
+
const store = this.requireStore();
|
|
337
|
+
const input = (typeof body === 'object' && body !== null ? body : {});
|
|
338
|
+
const action = parseBulkAction(input.action);
|
|
339
|
+
const uuids = parseBulkUuids(input.uuids);
|
|
340
|
+
const updated = await guarded(() => store.bulk(claims.id, claims.tenantId, action, uuids, Date.now()));
|
|
341
|
+
return { updated };
|
|
342
|
+
}
|
|
194
343
|
/**
|
|
195
344
|
* `POST /account/notifications/:uuid/read` ⇒ 204 (idempotent: the first read time is kept).
|
|
196
345
|
* The uuid is canonicalised here, after the session check (401 before 400), as
|
|
@@ -204,6 +353,33 @@ let NotificationsController = class NotificationsController {
|
|
|
204
353
|
if (!found)
|
|
205
354
|
notFound();
|
|
206
355
|
}
|
|
356
|
+
/** `POST /account/notifications/:uuid/unread` ⇒ 204 (an archived notice stays read). */
|
|
357
|
+
async unread(authorization, rawUuid) {
|
|
358
|
+
const claims = await this.requireSession(authorization);
|
|
359
|
+
const store = this.requireStore();
|
|
360
|
+
const uuid = (0, uuid_pipe_js_1.uuidField)(rawUuid, 'uuid');
|
|
361
|
+
const found = await guarded(() => store.markUnread(claims.id, claims.tenantId, uuid));
|
|
362
|
+
if (!found)
|
|
363
|
+
notFound();
|
|
364
|
+
}
|
|
365
|
+
/** `POST /account/notifications/:uuid/archive` ⇒ 204 (idempotent; also marks it read). */
|
|
366
|
+
async archive(authorization, rawUuid) {
|
|
367
|
+
const claims = await this.requireSession(authorization);
|
|
368
|
+
const store = this.requireStore();
|
|
369
|
+
const uuid = (0, uuid_pipe_js_1.uuidField)(rawUuid, 'uuid');
|
|
370
|
+
const found = await guarded(() => store.archive(claims.id, claims.tenantId, uuid, Date.now()));
|
|
371
|
+
if (!found)
|
|
372
|
+
notFound();
|
|
373
|
+
}
|
|
374
|
+
/** `POST /account/notifications/:uuid/unarchive` ⇒ 204 (idempotent; it comes back as read). */
|
|
375
|
+
async unarchive(authorization, rawUuid) {
|
|
376
|
+
const claims = await this.requireSession(authorization);
|
|
377
|
+
const store = this.requireStore();
|
|
378
|
+
const uuid = (0, uuid_pipe_js_1.uuidField)(rawUuid, 'uuid');
|
|
379
|
+
const found = await guarded(() => store.unarchive(claims.id, claims.tenantId, uuid));
|
|
380
|
+
if (!found)
|
|
381
|
+
notFound();
|
|
382
|
+
}
|
|
207
383
|
};
|
|
208
384
|
exports.NotificationsController = NotificationsController;
|
|
209
385
|
__decorate([
|
|
@@ -216,6 +392,15 @@ __decorate([
|
|
|
216
392
|
__metadata("design:paramtypes", [Object, Object]),
|
|
217
393
|
__metadata("design:returntype", Promise)
|
|
218
394
|
], NotificationsController.prototype, "list", null);
|
|
395
|
+
__decorate([
|
|
396
|
+
(0, classification_decorator_js_1.Public)(),
|
|
397
|
+
(0, common_1.Get)('kinds'),
|
|
398
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
399
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
400
|
+
__metadata("design:type", Function),
|
|
401
|
+
__metadata("design:paramtypes", [Object]),
|
|
402
|
+
__metadata("design:returntype", Promise)
|
|
403
|
+
], NotificationsController.prototype, "kinds", null);
|
|
219
404
|
__decorate([
|
|
220
405
|
(0, classification_decorator_js_1.Public)(),
|
|
221
406
|
(0, common_1.Get)('unread-count'),
|
|
@@ -235,6 +420,16 @@ __decorate([
|
|
|
235
420
|
__metadata("design:paramtypes", [Object, Object]),
|
|
236
421
|
__metadata("design:returntype", Promise)
|
|
237
422
|
], NotificationsController.prototype, "readAll", null);
|
|
423
|
+
__decorate([
|
|
424
|
+
(0, classification_decorator_js_1.Public)(),
|
|
425
|
+
(0, common_1.Post)('bulk'),
|
|
426
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
427
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
428
|
+
__param(1, (0, common_1.Body)()),
|
|
429
|
+
__metadata("design:type", Function),
|
|
430
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
431
|
+
__metadata("design:returntype", Promise)
|
|
432
|
+
], NotificationsController.prototype, "bulk", null);
|
|
238
433
|
__decorate([
|
|
239
434
|
(0, classification_decorator_js_1.Public)(),
|
|
240
435
|
(0, common_1.Post)(':uuid/read'),
|
|
@@ -245,6 +440,36 @@ __decorate([
|
|
|
245
440
|
__metadata("design:paramtypes", [Object, String]),
|
|
246
441
|
__metadata("design:returntype", Promise)
|
|
247
442
|
], NotificationsController.prototype, "read", null);
|
|
443
|
+
__decorate([
|
|
444
|
+
(0, classification_decorator_js_1.Public)(),
|
|
445
|
+
(0, common_1.Post)(':uuid/unread'),
|
|
446
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
447
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
448
|
+
__param(1, (0, common_1.Param)('uuid')),
|
|
449
|
+
__metadata("design:type", Function),
|
|
450
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
451
|
+
__metadata("design:returntype", Promise)
|
|
452
|
+
], NotificationsController.prototype, "unread", null);
|
|
453
|
+
__decorate([
|
|
454
|
+
(0, classification_decorator_js_1.Public)(),
|
|
455
|
+
(0, common_1.Post)(':uuid/archive'),
|
|
456
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
457
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
458
|
+
__param(1, (0, common_1.Param)('uuid')),
|
|
459
|
+
__metadata("design:type", Function),
|
|
460
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
461
|
+
__metadata("design:returntype", Promise)
|
|
462
|
+
], NotificationsController.prototype, "archive", null);
|
|
463
|
+
__decorate([
|
|
464
|
+
(0, classification_decorator_js_1.Public)(),
|
|
465
|
+
(0, common_1.Post)(':uuid/unarchive'),
|
|
466
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
467
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
468
|
+
__param(1, (0, common_1.Param)('uuid')),
|
|
469
|
+
__metadata("design:type", Function),
|
|
470
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
471
|
+
__metadata("design:returntype", Promise)
|
|
472
|
+
], NotificationsController.prototype, "unarchive", null);
|
|
248
473
|
exports.NotificationsController = NotificationsController = __decorate([
|
|
249
474
|
(0, common_1.Controller)('account/notifications'),
|
|
250
475
|
__param(0, (0, common_1.Optional)()),
|
|
@@ -253,5 +478,7 @@ exports.NotificationsController = NotificationsController = __decorate([
|
|
|
253
478
|
__param(1, (0, common_1.Inject)(tokens_js_2.SHIELD_NOTIFICATION_STORE)),
|
|
254
479
|
__param(2, (0, common_1.Optional)()),
|
|
255
480
|
__param(2, (0, common_1.Inject)(tokens_js_2.SHIELD_MFA_REQUIREMENT)),
|
|
256
|
-
|
|
481
|
+
__param(3, (0, common_1.Optional)()),
|
|
482
|
+
__param(3, (0, common_1.Inject)(tokens_js_2.SHIELD_NOTIFICATIONS)),
|
|
483
|
+
__metadata("design:paramtypes", [Function, Object, Object, Object])
|
|
257
484
|
], NotificationsController);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10
|
|
2
|
+
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10; G-035
|
|
3
|
+
* notification-center SPEC §5A, §5B: kind label / severity, list filters, unread, archive, bulk).
|
|
3
4
|
*
|
|
4
5
|
* One per-user, tenant-walled inbox in `<ns>_identity.user_notification` (identity migration
|
|
5
6
|
* 108). Every per-user statement is scoped by BOTH the user and the tenant (the session's active
|
|
@@ -11,10 +12,35 @@
|
|
|
11
12
|
/** The two inbox categories (SPEC §10). The category always comes from the kind registration. */
|
|
12
13
|
export declare const NOTIFICATION_CATEGORIES: readonly ["announcement", "personal"];
|
|
13
14
|
export type NotificationCategory = (typeof NOTIFICATION_CATEGORIES)[number];
|
|
15
|
+
/** How a notice type is marked in the UI (notification-center SPEC §10); default `info`. */
|
|
16
|
+
export declare const NOTIFICATION_SEVERITIES: readonly ["info", "success", "warning"];
|
|
17
|
+
export type NotificationSeverity = (typeof NOTIFICATION_SEVERITIES)[number];
|
|
18
|
+
/** The longest label (code points) an app may register (notification-center SPEC §5A). */
|
|
19
|
+
export declare const NOTIFICATION_LABEL_MAX = 40;
|
|
14
20
|
/** One `notificationKinds` registration (`ShieldModule.forRoot({ notificationKinds })`). */
|
|
15
21
|
export interface NotificationKindRegistration {
|
|
16
22
|
readonly kind: string;
|
|
17
23
|
readonly category: NotificationCategory;
|
|
24
|
+
/**
|
|
25
|
+
* Plain-text type name shown to every company (e.g. "Task assigned"), 1–40 characters, no
|
|
26
|
+
* control characters; no company or person names. Absent ⇒ generated from the kind's last
|
|
27
|
+
* segment (one boot warning lists such kinds).
|
|
28
|
+
*/
|
|
29
|
+
readonly label?: string;
|
|
30
|
+
/** Default `info`. */
|
|
31
|
+
readonly severity?: NotificationSeverity;
|
|
32
|
+
}
|
|
33
|
+
/** Status filter of the notice list (notification-center SPEC §10). Absent ⇒ not archived. */
|
|
34
|
+
export declare const NOTIFICATION_STATUSES: readonly ["unread", "read", "archived"];
|
|
35
|
+
export type NotificationStatus = (typeof NOTIFICATION_STATUSES)[number];
|
|
36
|
+
/** Bulk actions (notification-center SPEC §10); 1–100 uuids per call. */
|
|
37
|
+
export declare const NOTIFICATION_BULK_ACTIONS: readonly ["read", "unread", "archive", "unarchive"];
|
|
38
|
+
export type NotificationBulkAction = (typeof NOTIFICATION_BULK_ACTIONS)[number];
|
|
39
|
+
export declare const NOTIFICATION_BULK_MAX = 100;
|
|
40
|
+
/** One distinct type the user has notices of (`listKinds`). */
|
|
41
|
+
export interface NotificationKindSummary {
|
|
42
|
+
readonly kind: string;
|
|
43
|
+
readonly category: NotificationCategory;
|
|
18
44
|
}
|
|
19
45
|
/** A stored notice as the store returns it (no tenant id, user id or dedupe key). */
|
|
20
46
|
export interface NotificationRow {
|
|
@@ -27,6 +53,8 @@ export interface NotificationRow {
|
|
|
27
53
|
readonly createdAtMs: number;
|
|
28
54
|
/** `null` ⇒ unread. */
|
|
29
55
|
readonly readAtMs: number | null;
|
|
56
|
+
/** `null` ⇒ not archived. An archived notice is always read. */
|
|
57
|
+
readonly archivedAtMs: number | null;
|
|
30
58
|
}
|
|
31
59
|
/** A row to insert; every field already validated and server-stamped by the service. */
|
|
32
60
|
export interface NotificationInsert {
|
|
@@ -44,7 +72,18 @@ export interface NotificationInsert {
|
|
|
44
72
|
export interface NotificationListQuery {
|
|
45
73
|
/** Absent ⇒ both categories. */
|
|
46
74
|
readonly category?: NotificationCategory;
|
|
75
|
+
/** The dropdown's filter: unread (and so never archived) only. */
|
|
47
76
|
readonly unreadOnly: boolean;
|
|
77
|
+
/** Absent ⇒ every kind. */
|
|
78
|
+
readonly kind?: string;
|
|
79
|
+
/** Absent ⇒ not archived; `unread` / `read` also leave archived notices out. */
|
|
80
|
+
readonly status?: NotificationStatus;
|
|
81
|
+
/** Inclusive lower bound on the creation time (epoch ms). */
|
|
82
|
+
readonly fromMs?: number;
|
|
83
|
+
/** Inclusive upper bound on the creation time (epoch ms). */
|
|
84
|
+
readonly toMs?: number;
|
|
85
|
+
/** Plain text matched inside title or body (the store escapes `LIKE` wildcards); non-empty. */
|
|
86
|
+
readonly search?: string;
|
|
48
87
|
/** ≥ 1. */
|
|
49
88
|
readonly page: number;
|
|
50
89
|
/** 1–100. */
|
|
@@ -72,10 +111,21 @@ export interface NotificationWriteOptions {
|
|
|
72
111
|
/** The persistence port; `MariaDbNotificationStore` is the framework default. */
|
|
73
112
|
export interface NotificationStore {
|
|
74
113
|
list(userId: string, tenantId: string, query: NotificationListQuery): Promise<NotificationListResult>;
|
|
114
|
+
/** Unread, not archived, per category. */
|
|
75
115
|
countUnread(userId: string, tenantId: string): Promise<NotificationUnreadCounts>;
|
|
116
|
+
/** The distinct `(kind, category)` pairs of this user's notices in this tenant. */
|
|
117
|
+
listKinds(userId: string, tenantId: string): Promise<readonly NotificationKindSummary[]>;
|
|
76
118
|
/** `true` when the notice exists for this user in this tenant (read already or now). */
|
|
77
119
|
markRead(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
78
|
-
/**
|
|
120
|
+
/** `true` when the notice exists for this user in this tenant (an archived one stays read). */
|
|
121
|
+
markUnread(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
122
|
+
/** `true` when the notice exists for this user in this tenant; also marks it read. */
|
|
123
|
+
archive(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
124
|
+
/** `true` when the notice exists for this user in this tenant; it comes back as read. */
|
|
125
|
+
unarchive(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
126
|
+
/** One action on 1–100 of this user's notices in this tenant ⇒ the number changed. */
|
|
127
|
+
bulk(userId: string, tenantId: string, action: NotificationBulkAction, uuids: readonly string[], nowMs: number): Promise<number>;
|
|
128
|
+
/** Number of notices changed from unread to read (archived ones are skipped). */
|
|
79
129
|
markAllRead(userId: string, tenantId: string, category: NotificationCategory | undefined, nowMs: number): Promise<number>;
|
|
80
130
|
/** Inserted count; a repeated dedupe key is a no-op, not an error. */
|
|
81
131
|
insertMany(rows: readonly NotificationInsert[], opts?: NotificationWriteOptions): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/notifications/ports.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/notifications/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,iGAAiG;AACjG,eAAO,MAAM,uBAAuB,uCAAwC,CAAC;AAC7E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,yCAA0C,CAAC;AAC/E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,4FAA4F;AAC5F,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC;;;;OAIG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AK,EAAE,MAAM;IAFxB,SAAkB,IAAI,iCAAiC;gBAE5C,KAAK,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM;CAIjB;AAED,kFAAkF;AAClF,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,SAAkB,IAAI,kCAAkC;;CAIzD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10
|
|
3
|
+
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10; G-035
|
|
4
|
+
* notification-center SPEC §5A, §5B: kind label / severity, list filters, unread, archive, bulk).
|
|
4
5
|
*
|
|
5
6
|
* One per-user, tenant-walled inbox in `<ns>_identity.user_notification` (identity migration
|
|
6
7
|
* 108). Every per-user statement is scoped by BOTH the user and the tenant (the session's active
|
|
@@ -10,9 +11,18 @@
|
|
|
10
11
|
* Errors carry the FIELD, kind or variable name only, never a submitted value (core 50 #10).
|
|
11
12
|
*/
|
|
12
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.NotificationUnavailableError = exports.NotificationValidationError = exports.NotificationKindError = exports.NOTIFICATION_KIND_MAX_LENGTH = exports.NOTIFICATION_KIND_PATTERN = exports.NOTIFICATION_CATEGORIES = void 0;
|
|
14
|
+
exports.NotificationUnavailableError = exports.NotificationValidationError = exports.NotificationKindError = exports.NOTIFICATION_KIND_MAX_LENGTH = exports.NOTIFICATION_KIND_PATTERN = exports.NOTIFICATION_BULK_MAX = exports.NOTIFICATION_BULK_ACTIONS = exports.NOTIFICATION_STATUSES = exports.NOTIFICATION_LABEL_MAX = exports.NOTIFICATION_SEVERITIES = exports.NOTIFICATION_CATEGORIES = void 0;
|
|
14
15
|
/** The two inbox categories (SPEC §10). The category always comes from the kind registration. */
|
|
15
16
|
exports.NOTIFICATION_CATEGORIES = ['announcement', 'personal'];
|
|
17
|
+
/** How a notice type is marked in the UI (notification-center SPEC §10); default `info`. */
|
|
18
|
+
exports.NOTIFICATION_SEVERITIES = ['info', 'success', 'warning'];
|
|
19
|
+
/** The longest label (code points) an app may register (notification-center SPEC §5A). */
|
|
20
|
+
exports.NOTIFICATION_LABEL_MAX = 40;
|
|
21
|
+
/** Status filter of the notice list (notification-center SPEC §10). Absent ⇒ not archived. */
|
|
22
|
+
exports.NOTIFICATION_STATUSES = ['unread', 'read', 'archived'];
|
|
23
|
+
/** Bulk actions (notification-center SPEC §10); 1–100 uuids per call. */
|
|
24
|
+
exports.NOTIFICATION_BULK_ACTIONS = ['read', 'unread', 'archive', 'unarchive'];
|
|
25
|
+
exports.NOTIFICATION_BULK_MAX = 100;
|
|
16
26
|
/** Kind pattern (SPEC §10): dotted lower-case segments, at least two. */
|
|
17
27
|
exports.NOTIFICATION_KIND_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
|
|
18
28
|
exports.NOTIFICATION_KIND_MAX_LENGTH = 64;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — the enforcement guard + real-world adapters (the 'hands'). One global deny-by-default gate every request passes through (ADR-0002), classification decorators, boot-pool assertion (ADR-0018), the forRoot() registration seam, and the DB/Redis/crypto adapters that connect the sealed core to a real backend. Depends on @astram/core (ADR-0003, ADR-0023).",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"argon2": "^0.41.1",
|
|
37
37
|
"ioredis": "^5.4.1",
|
|
38
38
|
"mariadb": "^3.5.4",
|
|
39
|
-
"@astram/
|
|
40
|
-
"@astram/
|
|
39
|
+
"@astram/engine": "0.16.2",
|
|
40
|
+
"@astram/core": "1.14.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@nestjs/common": "^11",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@nestjs/platform-express": "^11",
|
|
46
46
|
"reflect-metadata": "^0.2",
|
|
47
47
|
"rxjs": "^7",
|
|
48
|
-
"@astram/messaging": "^0.1.
|
|
48
|
+
"@astram/messaging": "^0.1.13"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"@astram/messaging": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^5.7.0",
|
|
69
69
|
"unplugin-swc": "^1.5.1",
|
|
70
70
|
"vitest": "^2.1.8",
|
|
71
|
-
"@astram/messaging": "0.1.
|
|
71
|
+
"@astram/messaging": "0.1.13"
|
|
72
72
|
},
|
|
73
73
|
"repository": {
|
|
74
74
|
"type": "git",
|