@happyvertical/smrt-messages 0.51.39 → 0.52.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/AGENTS.md +20 -0
- package/README.md +31 -0
- package/dist/chunks/{AccountCollection-DCF0TWbR.js → AccountCollection-Br2mRkSe.js} +2 -2
- package/dist/chunks/{AccountCollection-DCF0TWbR.js.map → AccountCollection-Br2mRkSe.js.map} +1 -1
- package/dist/chunks/{Email-vrwFmhSB.js → Email-C6TU_YXp.js} +3 -3
- package/dist/chunks/{Email-vrwFmhSB.js.map → Email-C6TU_YXp.js.map} +1 -1
- package/dist/chunks/{EmailFolder-DfL2gUXy.js → EmailFolder-CvGCE75K.js} +2 -2
- package/dist/chunks/{EmailFolder-DfL2gUXy.js.map → EmailFolder-CvGCE75K.js.map} +1 -1
- package/dist/chunks/{Message-CwXVgr93.js → Message-jz7qKbcY.js} +4 -4
- package/dist/chunks/{Message-CwXVgr93.js.map → Message-jz7qKbcY.js.map} +1 -1
- package/dist/chunks/{MessageCollection-BatENTTm.js → MessageCollection-B9mLJ6Jt.js} +2 -2
- package/dist/chunks/{MessageCollection-BatENTTm.js.map → MessageCollection-B9mLJ6Jt.js.map} +1 -1
- package/dist/chunks/__smrt-register__-Mwpskcnl.js +6 -0
- package/dist/chunks/{__smrt-register__-CQyfwBLY.js.map → __smrt-register__-Mwpskcnl.js.map} +1 -1
- package/dist/collections/UserNotificationCollection.d.ts +6 -0
- package/dist/collections/UserNotificationCollection.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +293 -41
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +409 -1
- package/dist/models/UserNotification.d.ts +60 -0
- package/dist/models/UserNotification.d.ts.map +1 -0
- package/dist/services/UserNotificationService.d.ts +74 -0
- package/dist/services/UserNotificationService.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +131 -9
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +3 -1
- package/dist/ui.js.map +1 -1
- package/package.json +16 -16
- package/dist/chunks/__smrt-register__-CQyfwBLY.js +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__smrt-register__-
|
|
1
|
+
{"version":3,"file":"__smrt-register__-Mwpskcnl.js","names":[],"sources":["../../src/__smrt-register__.ts"],"sourcesContent":["/**\n * Self-registers this package's build-time manifest before any @smrt() decorator\n * in the package fires. Fixes issue #1132: in consumer runtimes (tsx, SvelteKit\n * SSR, plain `vite dev`) the decorator's synchronous manifest lookup previously\n * missed because no step populated the global manifest cache — classes got\n * registered with zero fields and `save()` / `toJSON()` silently dropped every\n * declared property.\n *\n * Import this module as the first statement in `src/index.ts` so its top-level\n * side effect runs ahead of any class module's @smrt() decorator.\n *\n * Silent no-op in dev/test, where the vitest plugin already populates manifests\n * via a different path. Only needs to succeed in the published dist output.\n *\n * @see https://github.com/happyvertical/smrt/issues/1132\n */\nimport { ObjectRegistry } from '@happyvertical/smrt-core';\n\n// During library builds, smrtPlugin replaces this entire module with generated\n// code that embeds the scanned manifest inline (#1506/#1507) — published dists\n// never resolve this URL, so downstream bundlers cannot break registration by\n// relocating the compiled module away from dist/manifest.json. The runtime\n// lookup below is the fallback for source-mode runs without that transform.\nObjectRegistry.registerPackageManifest(\n new URL('./manifest.json', import.meta.url),\n);\n"],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { UserNotification } from '../models/UserNotification.js';
|
|
3
|
+
export declare class UserNotificationCollection extends SmrtCollection<UserNotification> {
|
|
4
|
+
static readonly _itemClass: typeof UserNotification;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=UserNotificationCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserNotificationCollection.d.ts","sourceRoot":"","sources":["../../src/collections/UserNotificationCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,qBAAa,0BAA2B,SAAQ,cAAc,CAAC,gBAAgB,CAAC;IAC9E,MAAM,CAAC,QAAQ,CAAC,UAAU,0BAAoB;CAC/C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,11 +11,13 @@ export { AttachmentCollection } from './collections/AttachmentCollection';
|
|
|
11
11
|
export { MessageCollection } from './collections/MessageCollection';
|
|
12
12
|
export { MessagingEndpointCollection } from './collections/MessagingEndpointCollection.js';
|
|
13
13
|
export { PersonaMessageRouteCollection } from './collections/PersonaMessageRouteCollection.js';
|
|
14
|
+
export { UserNotificationCollection } from './collections/UserNotificationCollection.js';
|
|
14
15
|
export { Account } from './models/Account';
|
|
15
16
|
export { Attachment } from './models/Attachment';
|
|
16
17
|
export { Message } from './models/Message';
|
|
17
18
|
export { MessagingEndpoint } from './models/MessagingEndpoint.js';
|
|
18
19
|
export { PersonaMessageRoute } from './models/PersonaMessageRoute.js';
|
|
20
|
+
export { USER_NOTIFICATION_SEVERITIES, UserNotification, type UserNotificationOptions, type UserNotificationSeverity, } from './models/UserNotification.js';
|
|
19
21
|
export { EmailAccountCollection } from './collections/EmailAccountCollection';
|
|
20
22
|
export { EmailAttachmentCollection } from './collections/EmailAttachmentCollection';
|
|
21
23
|
export { EmailCollection } from './collections/EmailCollection';
|
|
@@ -43,5 +45,6 @@ export { TweetSender } from './senders/TweetSender';
|
|
|
43
45
|
export { ZulipSender } from './senders/ZulipSender.js';
|
|
44
46
|
export { type MessagingAccountInput, type MessagingAccountView, type MessagingEndpointInput, type MessagingEndpointView, MessagingSettingsService, type PersonaMessageRouteInput, } from './services/MessagingSettingsService.js';
|
|
45
47
|
export { type PersonaMessageSendResult, PersonaMessagingService, } from './services/PersonaMessagingService.js';
|
|
48
|
+
export { type UserNotificationInput, type UserNotificationListOptions, type UserNotificationNotifyResult, type UserNotificationScope, UserNotificationService, } from './services/UserNotificationService.js';
|
|
46
49
|
export type { AccountOptions, AccountSearchFilters, AccountType, AttachmentOptions, EmailAccountOptions, EmailAccountSearchFilters, EmailAttachmentOptions, EmailFolderOptions, EmailFolderSearchFilters, EmailOptions, EmailSearchFilters, KnownMessagingChannel, MessageOptions, MessageSearchFilters, MessageSenderInterface, MessageSendResult, MessageType, MessagingChannel, MessagingEndpointOptions, PersonaMessageRouteOptions, ProviderType, SendEmailOptions, SendMessageOptions, SendPersonaMessageOptions, SendSlackOptions, SendStatus, SendTweetOptions, SlackAccountOptions, SlackMessageOptions, SyncOptions, SyncProgress, SyncResult, TweetOptions, TwitterAccountOptions, } from './types';
|
|
47
50
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,wBAAwB,CAAC;AAShC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":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B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,uBAAuB,GACxB,MAAM,uCAAuC,CAAC;AAM/C,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EAEjB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EAErB,cAAc,EAEd,oBAAoB,EACpB,sBAAsB,EAEtB,iBAAiB,EAEjB,WAAW,EACX,gBAAgB,EAChB,wBAAwB,EACxB,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EAEnB,WAAW,EACX,YAAY,EACZ,UAAU,EAEV,YAAY,EACZ,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunks/rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import "./chunks/__smrt-register__-
|
|
2
|
+
import "./chunks/__smrt-register__-Mwpskcnl.js";
|
|
3
3
|
import { a as registerMessagingProvider, n as getMessagingProvider, o as ZulipSender, r as listMessagingProviders, s as TelegramSender, t as ensureBuiltinMessagingProvidersRegistered } from "./chunks/providers-4iLula-V.js";
|
|
4
|
-
import { r as Account, t as AccountCollection } from "./chunks/AccountCollection-
|
|
5
|
-
import { t as Message } from "./chunks/Message-
|
|
6
|
-
import { t as MessageCollection } from "./chunks/MessageCollection-
|
|
7
|
-
import { t as Email } from "./chunks/Email-
|
|
8
|
-
import { t as EmailFolder } from "./chunks/EmailFolder-
|
|
4
|
+
import { r as Account, t as AccountCollection } from "./chunks/AccountCollection-Br2mRkSe.js";
|
|
5
|
+
import { t as Message } from "./chunks/Message-jz7qKbcY.js";
|
|
6
|
+
import { t as MessageCollection } from "./chunks/MessageCollection-B9mLJ6Jt.js";
|
|
7
|
+
import { t as Email } from "./chunks/Email-C6TU_YXp.js";
|
|
8
|
+
import { t as EmailFolder } from "./chunks/EmailFolder-CvGCE75K.js";
|
|
9
9
|
import { t as SlackSender } from "./chunks/SlackSender-CjSvwY1K.js";
|
|
10
10
|
import { t as TweetSender } from "./chunks/TweetSender-CcLPNNi1.js";
|
|
11
|
-
import { SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, importOptionalDependency, smrt } from "@happyvertical/smrt-core";
|
|
11
|
+
import { SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, importOptionalDependency, isUniqueViolationError, smrt } from "@happyvertical/smrt-core";
|
|
12
12
|
import { registerPermissionDefinitions } from "@happyvertical/smrt-users";
|
|
13
13
|
import { TenantScoped, queryGlobal, queryWithGlobals, tenantId, withTenant } from "@happyvertical/smrt-tenancy";
|
|
14
14
|
//#region src/permissions.ts
|
|
@@ -54,12 +54,12 @@ function ensureMessagingPermissionsRegistered() {
|
|
|
54
54
|
}
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/models/Attachment.ts
|
|
57
|
-
var __defProp$
|
|
58
|
-
var __getOwnPropDesc$
|
|
59
|
-
var __decorateClass$
|
|
60
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
57
|
+
var __defProp$12 = Object.defineProperty;
|
|
58
|
+
var __getOwnPropDesc$12 = Object.getOwnPropertyDescriptor;
|
|
59
|
+
var __decorateClass$12 = (decorators, target, key, kind) => {
|
|
60
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$12(target, key) : target;
|
|
61
61
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
62
|
-
if (kind && result) __defProp$
|
|
62
|
+
if (kind && result) __defProp$12(target, key, result);
|
|
63
63
|
return result;
|
|
64
64
|
};
|
|
65
65
|
var Attachment = class extends SmrtObject {
|
|
@@ -91,7 +91,7 @@ var Attachment = class extends SmrtObject {
|
|
|
91
91
|
*/
|
|
92
92
|
async getMessage() {
|
|
93
93
|
if (!this.messageId) return null;
|
|
94
|
-
const { MessageCollection } = await import("./chunks/MessageCollection-
|
|
94
|
+
const { MessageCollection } = await import("./chunks/MessageCollection-B9mLJ6Jt.js").then((n) => n.n);
|
|
95
95
|
return await (await MessageCollection.create(this.options)).get({ id: this.messageId });
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
@@ -162,9 +162,9 @@ var Attachment = class extends SmrtObject {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
|
-
__decorateClass$
|
|
166
|
-
__decorateClass$
|
|
167
|
-
Attachment = __decorateClass$
|
|
165
|
+
__decorateClass$12([tenantId({ nullable: true })], Attachment.prototype, "tenantId", 2);
|
|
166
|
+
__decorateClass$12([foreignKey("Message")], Attachment.prototype, "messageId", 2);
|
|
167
|
+
Attachment = __decorateClass$12([TenantScoped({ mode: "optional" }), smrt({
|
|
168
168
|
api: { include: [
|
|
169
169
|
"list",
|
|
170
170
|
"get",
|
|
@@ -291,12 +291,12 @@ var AttachmentCollection = class extends SmrtCollection {
|
|
|
291
291
|
};
|
|
292
292
|
//#endregion
|
|
293
293
|
//#region src/models/MessagingEndpoint.ts
|
|
294
|
-
var __defProp$
|
|
295
|
-
var __getOwnPropDesc$
|
|
296
|
-
var __decorateClass$
|
|
297
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
294
|
+
var __defProp$11 = Object.defineProperty;
|
|
295
|
+
var __getOwnPropDesc$11 = Object.getOwnPropertyDescriptor;
|
|
296
|
+
var __decorateClass$11 = (decorators, target, key, kind) => {
|
|
297
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$11(target, key) : target;
|
|
298
298
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
299
|
-
if (kind && result) __defProp$
|
|
299
|
+
if (kind && result) __defProp$11(target, key, result);
|
|
300
300
|
return result;
|
|
301
301
|
};
|
|
302
302
|
var MessagingEndpoint = class extends SmrtObject {
|
|
@@ -343,15 +343,15 @@ var MessagingEndpoint = class extends SmrtObject {
|
|
|
343
343
|
return value.length <= 4 ? "••••" : `\u2022\u2022\u2022\u2022${value.slice(-4)}`;
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
|
-
__decorateClass$
|
|
347
|
-
__decorateClass$
|
|
348
|
-
__decorateClass$
|
|
349
|
-
__decorateClass$
|
|
350
|
-
__decorateClass$
|
|
346
|
+
__decorateClass$11([tenantId()], MessagingEndpoint.prototype, "tenantId", 2);
|
|
347
|
+
__decorateClass$11([crossPackageRef("@happyvertical/smrt-profiles:Profile", { nullable: true })], MessagingEndpoint.prototype, "profileId", 2);
|
|
348
|
+
__decorateClass$11([field({ required: true })], MessagingEndpoint.prototype, "label", 2);
|
|
349
|
+
__decorateClass$11([field({ required: true })], MessagingEndpoint.prototype, "channel", 2);
|
|
350
|
+
__decorateClass$11([field({
|
|
351
351
|
required: true,
|
|
352
352
|
sensitive: true
|
|
353
353
|
})], MessagingEndpoint.prototype, "address", 2);
|
|
354
|
-
MessagingEndpoint = __decorateClass$
|
|
354
|
+
MessagingEndpoint = __decorateClass$11([TenantScoped({ mode: "required" }), smrt({
|
|
355
355
|
tableName: "messaging_endpoints",
|
|
356
356
|
api: { include: ["list", "get"] },
|
|
357
357
|
mcp: { include: ["list", "get"] },
|
|
@@ -370,12 +370,12 @@ var MessagingEndpointCollection = class extends SmrtCollection {
|
|
|
370
370
|
};
|
|
371
371
|
//#endregion
|
|
372
372
|
//#region src/models/PersonaMessageRoute.ts
|
|
373
|
-
var __defProp$
|
|
374
|
-
var __getOwnPropDesc$
|
|
375
|
-
var __decorateClass$
|
|
376
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
373
|
+
var __defProp$10 = Object.defineProperty;
|
|
374
|
+
var __getOwnPropDesc$10 = Object.getOwnPropertyDescriptor;
|
|
375
|
+
var __decorateClass$10 = (decorators, target, key, kind) => {
|
|
376
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$10(target, key) : target;
|
|
377
377
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
378
|
-
if (kind && result) __defProp$
|
|
378
|
+
if (kind && result) __defProp$10(target, key, result);
|
|
379
379
|
return result;
|
|
380
380
|
};
|
|
381
381
|
var PersonaMessageRoute = class extends SmrtObject {
|
|
@@ -401,12 +401,12 @@ var PersonaMessageRoute = class extends SmrtObject {
|
|
|
401
401
|
if (options.updatedAt !== void 0) this.updatedAt = options.updatedAt;
|
|
402
402
|
}
|
|
403
403
|
};
|
|
404
|
-
__decorateClass$
|
|
405
|
-
__decorateClass$
|
|
406
|
-
__decorateClass$
|
|
407
|
-
__decorateClass$
|
|
408
|
-
__decorateClass$
|
|
409
|
-
PersonaMessageRoute = __decorateClass$
|
|
404
|
+
__decorateClass$10([tenantId()], PersonaMessageRoute.prototype, "tenantId", 2);
|
|
405
|
+
__decorateClass$10([crossPackageRef("@happyvertical/smrt-personas:AgentPersona", { required: true })], PersonaMessageRoute.prototype, "personaId", 2);
|
|
406
|
+
__decorateClass$10([foreignKey("Account", { required: true })], PersonaMessageRoute.prototype, "accountId", 2);
|
|
407
|
+
__decorateClass$10([foreignKey("MessagingEndpoint", { required: true })], PersonaMessageRoute.prototype, "endpointId", 2);
|
|
408
|
+
__decorateClass$10([field({ required: true })], PersonaMessageRoute.prototype, "purpose", 2);
|
|
409
|
+
PersonaMessageRoute = __decorateClass$10([TenantScoped({ mode: "required" }), smrt({
|
|
410
410
|
tableName: "persona_message_routes",
|
|
411
411
|
api: { include: ["list", "get"] },
|
|
412
412
|
mcp: { include: ["list", "get"] },
|
|
@@ -431,6 +431,89 @@ var PersonaMessageRouteCollection = class extends SmrtCollection {
|
|
|
431
431
|
}
|
|
432
432
|
};
|
|
433
433
|
//#endregion
|
|
434
|
+
//#region src/models/UserNotification.ts
|
|
435
|
+
var __defProp$9 = Object.defineProperty;
|
|
436
|
+
var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
|
|
437
|
+
var __decorateClass$9 = (decorators, target, key, kind) => {
|
|
438
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
|
|
439
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
440
|
+
if (kind && result) __defProp$9(target, key, result);
|
|
441
|
+
return result;
|
|
442
|
+
};
|
|
443
|
+
var USER_NOTIFICATION_SEVERITIES = [
|
|
444
|
+
"info",
|
|
445
|
+
"success",
|
|
446
|
+
"warning",
|
|
447
|
+
"error"
|
|
448
|
+
];
|
|
449
|
+
var UserNotification = class extends SmrtObject {
|
|
450
|
+
tenantId = "";
|
|
451
|
+
recipientUserId = "";
|
|
452
|
+
kind = "";
|
|
453
|
+
title = "";
|
|
454
|
+
/** Optional detail line. */
|
|
455
|
+
body = "";
|
|
456
|
+
/** Where the notification leads (host-relative path or URL). */
|
|
457
|
+
href = null;
|
|
458
|
+
severity = "info";
|
|
459
|
+
sourceRef = "";
|
|
460
|
+
/** When the underlying event happened (sort key). */
|
|
461
|
+
occurredAt = /* @__PURE__ */ new Date();
|
|
462
|
+
/** Set when the recipient has seen it. */
|
|
463
|
+
readAt = null;
|
|
464
|
+
/** Set when the recipient has cleared it; dismissed rows are hidden. */
|
|
465
|
+
dismissedAt = null;
|
|
466
|
+
constructor(options = {}) {
|
|
467
|
+
super(options);
|
|
468
|
+
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
469
|
+
if (options.recipientUserId !== void 0) this.recipientUserId = options.recipientUserId;
|
|
470
|
+
if (options.kind !== void 0) this.kind = options.kind;
|
|
471
|
+
if (options.title !== void 0) this.title = options.title;
|
|
472
|
+
if (options.body !== void 0) this.body = options.body;
|
|
473
|
+
if (options.href !== void 0) this.href = options.href;
|
|
474
|
+
if (options.severity !== void 0) this.severity = options.severity;
|
|
475
|
+
if (options.sourceRef !== void 0) this.sourceRef = options.sourceRef;
|
|
476
|
+
if (options.occurredAt !== void 0) this.occurredAt = options.occurredAt;
|
|
477
|
+
if (options.readAt !== void 0) this.readAt = options.readAt;
|
|
478
|
+
if (options.dismissedAt !== void 0) this.dismissedAt = options.dismissedAt;
|
|
479
|
+
}
|
|
480
|
+
get isRead() {
|
|
481
|
+
return this.readAt !== null;
|
|
482
|
+
}
|
|
483
|
+
get isDismissed() {
|
|
484
|
+
return this.dismissedAt !== null;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
__decorateClass$9([tenantId()], UserNotification.prototype, "tenantId", 2);
|
|
488
|
+
__decorateClass$9([crossPackageRef("@happyvertical/smrt-users:User", { required: true })], UserNotification.prototype, "recipientUserId", 2);
|
|
489
|
+
__decorateClass$9([field({ required: true })], UserNotification.prototype, "kind", 2);
|
|
490
|
+
__decorateClass$9([field({ required: true })], UserNotification.prototype, "title", 2);
|
|
491
|
+
__decorateClass$9([field({ required: true })], UserNotification.prototype, "sourceRef", 2);
|
|
492
|
+
UserNotification = __decorateClass$9([TenantScoped({ mode: "required" }), smrt({
|
|
493
|
+
tableName: "user_notifications",
|
|
494
|
+
api: false,
|
|
495
|
+
mcp: false,
|
|
496
|
+
cli: false,
|
|
497
|
+
conflictColumns: [
|
|
498
|
+
"tenant_id",
|
|
499
|
+
"recipient_user_id",
|
|
500
|
+
"source_ref"
|
|
501
|
+
],
|
|
502
|
+
indexes: [{
|
|
503
|
+
name: "user_notifications_recipient_occurred_idx",
|
|
504
|
+
columns: [
|
|
505
|
+
"tenantId",
|
|
506
|
+
"recipientUserId",
|
|
507
|
+
"occurredAt"
|
|
508
|
+
]
|
|
509
|
+
}]
|
|
510
|
+
})], UserNotification);
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/collections/UserNotificationCollection.ts
|
|
513
|
+
var UserNotificationCollection = class extends SmrtCollection {
|
|
514
|
+
static _itemClass = UserNotification;
|
|
515
|
+
};
|
|
516
|
+
//#endregion
|
|
434
517
|
//#region src/models/EmailAccount.ts
|
|
435
518
|
var __defProp$8 = Object.defineProperty;
|
|
436
519
|
var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
|
|
@@ -526,7 +609,7 @@ var EmailAccount = class extends Account {
|
|
|
526
609
|
for (const folderName of foldersToSync) try {
|
|
527
610
|
let folder = await folderCollection.getByPath(accountId, folderName);
|
|
528
611
|
if (!folder) {
|
|
529
|
-
const { EmailFolder } = await import("./chunks/EmailFolder-
|
|
612
|
+
const { EmailFolder } = await import("./chunks/EmailFolder-CvGCE75K.js").then((n) => n.n);
|
|
530
613
|
folder = new EmailFolder({
|
|
531
614
|
...this.childOptions(),
|
|
532
615
|
accountId,
|
|
@@ -551,7 +634,7 @@ var EmailAccount = class extends Account {
|
|
|
551
634
|
result.messagesSkipped++;
|
|
552
635
|
continue;
|
|
553
636
|
}
|
|
554
|
-
const { Email } = await import("./chunks/Email-
|
|
637
|
+
const { Email } = await import("./chunks/Email-C6TU_YXp.js").then((n) => n.n);
|
|
555
638
|
let email = existingEmail;
|
|
556
639
|
if (!email) {
|
|
557
640
|
email = new Email({
|
|
@@ -2013,10 +2096,179 @@ var PersonaMessagingService = class {
|
|
|
2013
2096
|
}
|
|
2014
2097
|
};
|
|
2015
2098
|
//#endregion
|
|
2099
|
+
//#region src/services/UserNotificationService.ts
|
|
2100
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
2101
|
+
var DEFAULT_LIMIT = 50;
|
|
2102
|
+
var MAX_LIMIT = 200;
|
|
2103
|
+
function requireText(value, name) {
|
|
2104
|
+
const text = value?.trim();
|
|
2105
|
+
if (!text) throw new Error(`A notification ${name} is required.`);
|
|
2106
|
+
return text;
|
|
2107
|
+
}
|
|
2108
|
+
function clampLimit(limit) {
|
|
2109
|
+
if (limit === void 0) return DEFAULT_LIMIT;
|
|
2110
|
+
if (!Number.isInteger(limit) || limit < 1) throw new Error("Notification list limit must be a positive integer.");
|
|
2111
|
+
return Math.min(limit, MAX_LIMIT);
|
|
2112
|
+
}
|
|
2113
|
+
var UserNotificationService = class {
|
|
2114
|
+
constructor(options) {
|
|
2115
|
+
this.options = options;
|
|
2116
|
+
}
|
|
2117
|
+
options;
|
|
2118
|
+
collection() {
|
|
2119
|
+
return UserNotificationCollection.create({ db: this.options.db });
|
|
2120
|
+
}
|
|
2121
|
+
/** Store a notification unless its `sourceRef` already exists. */
|
|
2122
|
+
async notify(input) {
|
|
2123
|
+
const tenantId = requireText(input.tenantId, "tenant");
|
|
2124
|
+
const recipientUserId = requireText(input.recipientUserId, "recipient");
|
|
2125
|
+
const kind = requireText(input.kind, "kind");
|
|
2126
|
+
const title = requireText(input.title, "title");
|
|
2127
|
+
const severity = input.severity ?? "info";
|
|
2128
|
+
if (!USER_NOTIFICATION_SEVERITIES.includes(severity)) throw new Error(`Unknown notification severity '${severity}'.`);
|
|
2129
|
+
const sourceRef = input.sourceRef?.trim() || `notification:${crypto.randomUUID()}`;
|
|
2130
|
+
return withTenant({ tenantId }, async () => {
|
|
2131
|
+
const notifications = await this.collection();
|
|
2132
|
+
const findExisting = async () => (await notifications.list({
|
|
2133
|
+
where: {
|
|
2134
|
+
tenantId,
|
|
2135
|
+
recipientUserId,
|
|
2136
|
+
sourceRef
|
|
2137
|
+
},
|
|
2138
|
+
limit: 1
|
|
2139
|
+
}))[0];
|
|
2140
|
+
const existing = await findExisting();
|
|
2141
|
+
if (existing) return {
|
|
2142
|
+
notification: existing,
|
|
2143
|
+
created: false
|
|
2144
|
+
};
|
|
2145
|
+
let notification;
|
|
2146
|
+
try {
|
|
2147
|
+
notification = await notifications.create({
|
|
2148
|
+
_insertOnly: true,
|
|
2149
|
+
tenantId,
|
|
2150
|
+
recipientUserId,
|
|
2151
|
+
kind,
|
|
2152
|
+
title,
|
|
2153
|
+
body: input.body?.trim() ?? "",
|
|
2154
|
+
href: input.href ?? null,
|
|
2155
|
+
severity,
|
|
2156
|
+
sourceRef,
|
|
2157
|
+
occurredAt: input.occurredAt ?? /* @__PURE__ */ new Date(),
|
|
2158
|
+
readAt: null,
|
|
2159
|
+
dismissedAt: null
|
|
2160
|
+
});
|
|
2161
|
+
} catch (error) {
|
|
2162
|
+
if (!isUniqueViolationError(error)) throw error;
|
|
2163
|
+
const winner = await findExisting();
|
|
2164
|
+
if (!winner) throw error;
|
|
2165
|
+
return {
|
|
2166
|
+
notification: winner,
|
|
2167
|
+
created: false
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
return {
|
|
2171
|
+
notification,
|
|
2172
|
+
created: true
|
|
2173
|
+
};
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
/** `notify()` for each recipient (duplicates in the list are ignored). */
|
|
2177
|
+
async notifyMany(recipientUserIds, input) {
|
|
2178
|
+
const results = [];
|
|
2179
|
+
for (const recipientUserId of new Set(recipientUserIds)) results.push(await this.notify({
|
|
2180
|
+
...input,
|
|
2181
|
+
recipientUserId
|
|
2182
|
+
}));
|
|
2183
|
+
return results;
|
|
2184
|
+
}
|
|
2185
|
+
/** A user's notifications across the given tenants, newest first. */
|
|
2186
|
+
async listForUser(userId, options) {
|
|
2187
|
+
const recipientUserId = requireText(userId, "recipient");
|
|
2188
|
+
const limit = clampLimit(options.limit);
|
|
2189
|
+
const tenantIds = [...new Set(options.tenantIds.filter(Boolean))];
|
|
2190
|
+
const notifications = await this.collection();
|
|
2191
|
+
return (await Promise.all(tenantIds.map((tenantId) => withTenant({ tenantId }, () => notifications.list({
|
|
2192
|
+
where: {
|
|
2193
|
+
tenantId,
|
|
2194
|
+
recipientUserId,
|
|
2195
|
+
...options.includeDismissed ? {} : { dismissedAt: null },
|
|
2196
|
+
...options.unreadOnly ? { readAt: null } : {},
|
|
2197
|
+
...options.since ? { "occurredAt >=": options.since } : {}
|
|
2198
|
+
},
|
|
2199
|
+
orderBy: "occurredAt DESC",
|
|
2200
|
+
limit
|
|
2201
|
+
}))))).flat().sort((a, b) => b.occurredAt.getTime() - a.occurredAt.getTime()).slice(0, limit);
|
|
2202
|
+
}
|
|
2203
|
+
/** Unread, undismissed count across the given tenants. */
|
|
2204
|
+
async countUnread(userId, options) {
|
|
2205
|
+
const recipientUserId = requireText(userId, "recipient");
|
|
2206
|
+
const notifications = await this.collection();
|
|
2207
|
+
return (await Promise.all([...new Set(options.tenantIds.filter(Boolean))].map((tenantId) => withTenant({ tenantId }, () => notifications.count({ where: {
|
|
2208
|
+
tenantId,
|
|
2209
|
+
recipientUserId,
|
|
2210
|
+
readAt: null,
|
|
2211
|
+
dismissedAt: null,
|
|
2212
|
+
...options.since ? { "occurredAt >=": options.since } : {}
|
|
2213
|
+
} }))))).reduce((sum, count) => sum + Number(count), 0);
|
|
2214
|
+
}
|
|
2215
|
+
/** Mark the user's own notifications read; returns how many changed. */
|
|
2216
|
+
async markRead(userId, ids, scope) {
|
|
2217
|
+
return this.stamp(userId, ids, scope, "readAt");
|
|
2218
|
+
}
|
|
2219
|
+
/** Dismiss (and mark read) the user's own notifications. */
|
|
2220
|
+
async dismiss(userId, ids, scope) {
|
|
2221
|
+
return this.stamp(userId, ids, scope, "dismissedAt");
|
|
2222
|
+
}
|
|
2223
|
+
/** Mark every unread notification of the user in these tenants read. */
|
|
2224
|
+
async markAllRead(userId, options) {
|
|
2225
|
+
const recipientUserId = requireText(userId, "recipient");
|
|
2226
|
+
const notifications = await this.collection();
|
|
2227
|
+
const now = /* @__PURE__ */ new Date();
|
|
2228
|
+
let changed = 0;
|
|
2229
|
+
for (const tenantId of new Set(options.tenantIds.filter(Boolean))) changed += await withTenant({ tenantId }, async () => {
|
|
2230
|
+
const unread = await notifications.list({ where: {
|
|
2231
|
+
tenantId,
|
|
2232
|
+
recipientUserId,
|
|
2233
|
+
readAt: null
|
|
2234
|
+
} });
|
|
2235
|
+
for (const notification of unread) {
|
|
2236
|
+
notification.readAt = now;
|
|
2237
|
+
await notification.save();
|
|
2238
|
+
}
|
|
2239
|
+
return unread.length;
|
|
2240
|
+
});
|
|
2241
|
+
return changed;
|
|
2242
|
+
}
|
|
2243
|
+
async stamp(userId, ids, scope, column) {
|
|
2244
|
+
const recipientUserId = requireText(userId, "recipient");
|
|
2245
|
+
const tenantId = requireText(scope.tenantId, "tenant");
|
|
2246
|
+
const wanted = [...new Set(ids.filter((id) => typeof id === "string" && UUID_PATTERN.test(id)))];
|
|
2247
|
+
if (wanted.length === 0) return 0;
|
|
2248
|
+
return withTenant({ tenantId }, async () => {
|
|
2249
|
+
const rows = await (await this.collection()).list({ where: {
|
|
2250
|
+
tenantId,
|
|
2251
|
+
recipientUserId,
|
|
2252
|
+
"id in": wanted
|
|
2253
|
+
} });
|
|
2254
|
+
const now = /* @__PURE__ */ new Date();
|
|
2255
|
+
let changed = 0;
|
|
2256
|
+
for (const notification of rows) {
|
|
2257
|
+
if (notification[column] !== null) continue;
|
|
2258
|
+
notification[column] = now;
|
|
2259
|
+
if (column === "dismissedAt" && notification.readAt === null) notification.readAt = now;
|
|
2260
|
+
await notification.save();
|
|
2261
|
+
changed += 1;
|
|
2262
|
+
}
|
|
2263
|
+
return changed;
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
//#endregion
|
|
2016
2268
|
//#region src/index.ts
|
|
2017
2269
|
ensureBuiltinMessagingProvidersRegistered();
|
|
2018
2270
|
ensureMessagingPermissionsRegistered();
|
|
2019
2271
|
//#endregion
|
|
2020
|
-
export { Account, AccountCollection, Attachment, AttachmentCollection, Blacklist, BlacklistCollection, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGING_PERMISSION_DEFINITIONS, Message, MessageCollection, MessagingEndpoint, MessagingEndpointCollection, MessagingSettingsService, PersonaMessageRoute, PersonaMessageRouteCollection, PersonaMessagingService, SEND_MESSAGES_PERMISSION, SlackAccount, SlackMessage, SlackSender, TelegramAccount, TelegramSender, Tweet, TweetSender, TwitterAccount, Whitelist, WhitelistCollection, ZulipAccount, ZulipSender, AttachmentCollection_exports as a, assertMessagingPermission, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, MessagingEndpointCollection_exports as i, listMessagingProviders, messagingPrincipalFromPermissions, EmailCollection_exports as n, EmailAccountCollection_exports as r, registerMessagingProvider, EmailFolderCollection_exports as t };
|
|
2272
|
+
export { Account, AccountCollection, Attachment, AttachmentCollection, Blacklist, BlacklistCollection, Email, EmailAccount, EmailAccountCollection, EmailAttachment, EmailAttachmentCollection, EmailCollection, EmailFolder, EmailFolderCollection, EmailSender, MANAGE_MESSAGE_CREDENTIALS_PERMISSION, MANAGE_MESSAGE_ROUTES_PERMISSION, MESSAGING_PERMISSION_DEFINITIONS, Message, MessageCollection, MessagingEndpoint, MessagingEndpointCollection, MessagingSettingsService, PersonaMessageRoute, PersonaMessageRouteCollection, PersonaMessagingService, SEND_MESSAGES_PERMISSION, SlackAccount, SlackMessage, SlackSender, TelegramAccount, TelegramSender, Tweet, TweetSender, TwitterAccount, USER_NOTIFICATION_SEVERITIES, UserNotification, UserNotificationCollection, UserNotificationService, Whitelist, WhitelistCollection, ZulipAccount, ZulipSender, AttachmentCollection_exports as a, assertMessagingPermission, ensureBuiltinMessagingProvidersRegistered, ensureMessagingPermissionsRegistered, getMessagingProvider, MessagingEndpointCollection_exports as i, listMessagingProviders, messagingPrincipalFromPermissions, EmailCollection_exports as n, EmailAccountCollection_exports as r, registerMessagingProvider, EmailFolderCollection_exports as t };
|
|
2021
2273
|
|
|
2022
2274
|
//# sourceMappingURL=index.js.map
|