@headless-lms/core 0.3.0 → 0.5.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/assets/events.d.ts +24 -18
- package/dist/assets/file-urls.d.ts +11 -7
- package/dist/assets/file-urls.js +14 -4
- package/dist/assets/file-urls.js.map +1 -1
- package/dist/assets/index.d.ts +5 -4
- package/dist/assets/index.js +4 -3
- package/dist/assets/jobs.d.ts +15 -0
- package/dist/assets/jobs.js +30 -0
- package/dist/assets/jobs.js.map +1 -0
- package/dist/assets/ports.d.ts +37 -17
- package/dist/assets/service.d.ts +30 -15
- package/dist/assets/service.js +229 -59
- package/dist/assets/service.js.map +1 -1
- package/dist/automations/actions.js +2 -63
- package/dist/automations/actions.js.map +1 -1
- package/dist/automations/catalog.d.ts +1 -2
- package/dist/automations/catalog.js +137 -65
- package/dist/automations/catalog.js.map +1 -1
- package/dist/automations/community-derivations.js +20 -20
- package/dist/automations/community-derivations.js.map +1 -1
- package/dist/automations/community-mail.d.ts +36 -20
- package/dist/automations/community-mail.js +32 -24
- package/dist/automations/community-mail.js.map +1 -1
- package/dist/automations/event-permissions.d.ts +12 -0
- package/dist/automations/event-permissions.js +38 -0
- package/dist/automations/event-permissions.js.map +1 -0
- package/dist/automations/events.d.ts +0 -10
- package/dist/automations/index.d.ts +12 -4
- package/dist/automations/index.js +9 -1
- package/dist/automations/notifications/applicable.d.ts +8 -0
- package/dist/automations/notifications/applicable.js +12 -0
- package/dist/automations/notifications/applicable.js.map +1 -0
- package/dist/automations/notifications/debounce.d.ts +25 -0
- package/dist/automations/notifications/debounce.js +93 -0
- package/dist/automations/notifications/debounce.js.map +1 -0
- package/dist/automations/notifications/defaults.d.ts +8 -0
- package/dist/automations/notifications/defaults.js +346 -0
- package/dist/automations/notifications/defaults.js.map +1 -0
- package/dist/automations/notifications/delivery.d.ts +28 -0
- package/dist/automations/notifications/delivery.js +88 -0
- package/dist/automations/notifications/delivery.js.map +1 -0
- package/dist/automations/notifications/processor.d.ts +64 -0
- package/dist/automations/notifications/processor.js +270 -0
- package/dist/automations/notifications/processor.js.map +1 -0
- package/dist/automations/notifications/rules/content.d.ts +6 -0
- package/dist/automations/notifications/rules/content.js +96 -0
- package/dist/automations/notifications/rules/content.js.map +1 -0
- package/dist/automations/notifications/rules/discussion.d.ts +7 -0
- package/dist/automations/notifications/rules/discussion.js +678 -0
- package/dist/automations/notifications/rules/discussion.js.map +1 -0
- package/dist/automations/notifications/rules/entitlements.d.ts +6 -0
- package/dist/automations/notifications/rules/entitlements.js +276 -0
- package/dist/automations/notifications/rules/entitlements.js.map +1 -0
- package/dist/automations/notifications/rules/events.d.ts +9 -0
- package/dist/automations/notifications/rules/events.js +27 -0
- package/dist/automations/notifications/rules/events.js.map +1 -0
- package/dist/automations/notifications/rules/index.d.ts +6 -0
- package/dist/automations/notifications/rules/index.js +15 -0
- package/dist/automations/notifications/rules/index.js.map +1 -0
- package/dist/automations/notifications/rules/organizations.d.ts +6 -0
- package/dist/automations/notifications/rules/organizations.js +35 -0
- package/dist/automations/notifications/rules/organizations.js.map +1 -0
- package/dist/automations/notifications/rules/recipients.d.ts +32 -0
- package/dist/automations/notifications/rules/recipients.js +98 -0
- package/dist/automations/notifications/rules/recipients.js.map +1 -0
- package/dist/automations/notifications/service.d.ts +29 -0
- package/dist/automations/notifications/service.js +45 -0
- package/dist/automations/notifications/service.js.map +1 -0
- package/dist/automations/notifications/types.d.ts +7 -0
- package/dist/automations/notifications/types.js +560 -0
- package/dist/automations/notifications/types.js.map +1 -0
- package/dist/automations/ports.d.ts +134 -21
- package/dist/automations/service.d.ts +30 -30
- package/dist/automations/service.js +111 -144
- package/dist/automations/service.js.map +1 -1
- package/dist/content/event-sight.d.ts +11 -0
- package/dist/content/event-sight.js +11 -0
- package/dist/content/event-sight.js.map +1 -0
- package/dist/content/events.d.ts +437 -46
- package/dist/content/events.js +45 -1
- package/dist/content/events.js.map +1 -1
- package/dist/content/index.d.ts +8 -4
- package/dist/content/index.js +5 -1
- package/dist/content/jobs.d.ts +16 -0
- package/dist/content/jobs.js +37 -0
- package/dist/content/jobs.js.map +1 -0
- package/dist/content/model.d.ts +2 -2
- package/dist/content/notification-categories.d.ts +37 -0
- package/dist/content/notification-categories.js +73 -0
- package/dist/content/notification-categories.js.map +1 -0
- package/dist/content/ports.d.ts +132 -68
- package/dist/content/service.d.ts +100 -68
- package/dist/content/service.js +703 -146
- package/dist/content/service.js.map +1 -1
- package/dist/content/titles.d.ts +25 -0
- package/dist/content/titles.js +82 -0
- package/dist/content/titles.js.map +1 -0
- package/dist/content/types.d.ts +2 -2
- package/dist/discussion/authors.d.ts +4 -2
- package/dist/discussion/authors.js +9 -5
- package/dist/discussion/authors.js.map +1 -1
- package/dist/discussion/chats.d.ts +63 -39
- package/dist/discussion/chats.js +455 -190
- package/dist/discussion/chats.js.map +1 -1
- package/dist/discussion/digests.d.ts +24 -0
- package/dist/discussion/digests.js +104 -0
- package/dist/discussion/digests.js.map +1 -0
- package/dist/discussion/events.d.ts +227 -23
- package/dist/discussion/events.js +114 -19
- package/dist/discussion/events.js.map +1 -1
- package/dist/discussion/index.d.ts +12 -4
- package/dist/discussion/index.js +9 -2
- package/dist/discussion/jobs.d.ts +16 -0
- package/dist/discussion/jobs.js +40 -0
- package/dist/discussion/jobs.js.map +1 -0
- package/dist/discussion/live.d.ts +106 -0
- package/dist/discussion/live.js +642 -0
- package/dist/discussion/live.js.map +1 -0
- package/dist/discussion/mentions.d.ts +11 -0
- package/dist/discussion/mentions.js +35 -0
- package/dist/discussion/mentions.js.map +1 -0
- package/dist/discussion/ports.d.ts +279 -114
- package/dist/discussion/ports.js.map +1 -1
- package/dist/discussion/posts.d.ts +60 -44
- package/dist/discussion/posts.js +453 -287
- package/dist/discussion/posts.js.map +1 -1
- package/dist/discussion/rules.d.ts +18 -0
- package/dist/discussion/rules.js +22 -0
- package/dist/discussion/rules.js.map +1 -0
- package/dist/discussion/service.d.ts +50 -35
- package/dist/discussion/service.js +333 -205
- package/dist/discussion/service.js.map +1 -1
- package/dist/discussion/subscriptions.d.ts +37 -0
- package/dist/discussion/subscriptions.js +115 -0
- package/dist/discussion/subscriptions.js.map +1 -0
- package/dist/discussion/titles.d.ts +28 -0
- package/dist/discussion/titles.js +98 -0
- package/dist/discussion/titles.js.map +1 -0
- package/dist/entitlements/events.d.ts +20 -20
- package/dist/entitlements/index.d.ts +5 -4
- package/dist/entitlements/index.js +3 -2
- package/dist/entitlements/jobs.d.ts +12 -0
- package/dist/entitlements/jobs.js +18 -0
- package/dist/entitlements/jobs.js.map +1 -0
- package/dist/entitlements/model.d.ts +2 -2
- package/dist/entitlements/ports.d.ts +68 -38
- package/dist/entitlements/rules.d.ts +3 -6
- package/dist/entitlements/rules.js +5 -10
- package/dist/entitlements/rules.js.map +1 -1
- package/dist/entitlements/service.d.ts +43 -28
- package/dist/entitlements/service.js +387 -160
- package/dist/entitlements/service.js.map +1 -1
- package/dist/identity/devices.d.ts +30 -0
- package/dist/identity/devices.js +109 -0
- package/dist/identity/devices.js.map +1 -0
- package/dist/identity/index.d.ts +6 -5
- package/dist/identity/index.js +4 -3
- package/dist/identity/model.d.ts +2 -2
- package/dist/identity/notification-settings.d.ts +28 -0
- package/dist/identity/notification-settings.js +114 -0
- package/dist/identity/notification-settings.js.map +1 -0
- package/dist/identity/ports.d.ts +80 -56
- package/dist/identity/service.d.ts +8 -7
- package/dist/identity/service.js +17 -13
- package/dist/identity/service.js.map +1 -1
- package/dist/integrations/ports.d.ts +9 -8
- package/dist/integrations/service.d.ts +9 -8
- package/dist/integrations/service.js +33 -16
- package/dist/integrations/service.js.map +1 -1
- package/dist/organizations/default-roles.d.ts +22 -0
- package/dist/organizations/default-roles.js +89 -0
- package/dist/organizations/default-roles.js.map +1 -0
- package/dist/organizations/effective-permissions.d.ts +45 -0
- package/dist/organizations/effective-permissions.js +113 -0
- package/dist/organizations/effective-permissions.js.map +1 -0
- package/dist/organizations/events.d.ts +320 -181
- package/dist/organizations/events.js +90 -18
- package/dist/organizations/events.js.map +1 -1
- package/dist/organizations/index.d.ts +15 -10
- package/dist/organizations/index.js +8 -3
- package/dist/organizations/members.d.ts +66 -8
- package/dist/organizations/members.js.map +1 -1
- package/dist/organizations/notification-catalog.d.ts +31 -0
- package/dist/organizations/notification-catalog.js +32 -0
- package/dist/organizations/notification-catalog.js.map +1 -0
- package/dist/organizations/notification-categories.d.ts +34 -0
- package/dist/organizations/notification-categories.js +66 -0
- package/dist/organizations/notification-categories.js.map +1 -0
- package/dist/organizations/org-roles.d.ts +33 -0
- package/dist/organizations/org-roles.js +49 -0
- package/dist/organizations/org-roles.js.map +1 -0
- package/dist/organizations/permissions.d.ts +311 -0
- package/dist/organizations/permissions.js +327 -0
- package/dist/organizations/permissions.js.map +1 -0
- package/dist/organizations/ports.d.ts +187 -65
- package/dist/organizations/service.d.ts +104 -35
- package/dist/organizations/service.js +1247 -323
- package/dist/organizations/service.js.map +1 -1
- package/dist/organizations/testing.d.ts +18 -0
- package/dist/organizations/testing.js +37 -0
- package/dist/organizations/testing.js.map +1 -0
- package/dist/organizations/types.d.ts +5 -16
- package/dist/progress/index.d.ts +2 -2
- package/dist/progress/ports.d.ts +11 -3
- package/dist/progress/service.d.ts +6 -5
- package/dist/progress/service.js +23 -8
- package/dist/progress/service.js.map +1 -1
- package/dist/reporting/admin/index.d.ts +6 -4
- package/dist/reporting/admin/model.d.ts +36 -3
- package/dist/reporting/admin/ports.d.ts +39 -14
- package/dist/reporting/admin/service.d.ts +32 -11
- package/dist/reporting/admin/service.js +102 -18
- package/dist/reporting/admin/service.js.map +1 -1
- package/dist/reporting/events/index.d.ts +27 -0
- package/dist/reporting/events/index.js +20 -0
- package/dist/reporting/events/index.js.map +1 -0
- package/dist/reporting/member/calendar.d.ts +11 -0
- package/dist/reporting/member/calendar.js +75 -0
- package/dist/reporting/member/calendar.js.map +1 -0
- package/dist/reporting/member/index.d.ts +3 -2
- package/dist/reporting/member/model.d.ts +80 -26
- package/dist/reporting/member/ports.d.ts +50 -28
- package/dist/reporting/member/service.d.ts +81 -35
- package/dist/reporting/member/service.js +438 -145
- package/dist/reporting/member/service.js.map +1 -1
- package/dist/shared/actor.d.ts +22 -3
- package/dist/shared/errors.d.ts +15 -2
- package/dist/shared/errors.js +21 -2
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/id.d.ts +7 -0
- package/dist/shared/id.js +8 -1
- package/dist/shared/id.js.map +1 -1
- package/dist/shared/logger.d.ts +2 -1
- package/dist/shared/logger.js +10 -1
- package/dist/shared/logger.js.map +1 -1
- package/dist/shared/mailer.d.ts +11 -1
- package/dist/shared/mailer.js +32 -5
- package/dist/shared/mailer.js.map +1 -1
- package/dist/shared/notification-categories.d.ts +16 -0
- package/dist/shared/notification-categories.js +94 -0
- package/dist/shared/notification-categories.js.map +1 -0
- package/dist/shared/notification-settings.d.ts +14 -0
- package/dist/shared/notification-settings.js +61 -0
- package/dist/shared/notification-settings.js.map +1 -0
- package/dist/shared/ports.d.ts +68 -2
- package/dist/shared/settings.d.ts +2 -1
- package/dist/shared/settings.js +1 -0
- package/dist/shared/settings.js.map +1 -1
- package/dist/types/automations.d.ts +8 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/discussion.d.ts +4 -5
- package/dist/types/email-templates.d.ts +119 -6
- package/dist/types/entitlements.d.ts +2 -2
- package/dist/types/identity.d.ts +14 -17
- package/dist/types/index.d.ts +13 -12
- package/dist/types/index.js +2 -1
- package/dist/types/notifications.d.ts +157 -0
- package/dist/types/notifications.js +1 -0
- package/dist/types/organizations.d.ts +3 -2
- package/dist/types/ports.d.ts +8 -1
- package/dist/types/ports.js +7 -1
- package/dist/types/ports.js.map +1 -0
- package/dist/types/schemas/assets.d.ts +5 -5
- package/dist/types/schemas/assets.js +4 -3
- package/dist/types/schemas/assets.js.map +1 -1
- package/dist/types/schemas/automations.d.ts +1 -10
- package/dist/types/schemas/automations.js +1 -3
- package/dist/types/schemas/automations.js.map +1 -1
- package/dist/types/schemas/content.d.ts +596 -11
- package/dist/types/schemas/content.js +225 -9
- package/dist/types/schemas/content.js.map +1 -1
- package/dist/types/schemas/discussion.d.ts +362 -66
- package/dist/types/schemas/discussion.js +123 -15
- package/dist/types/schemas/discussion.js.map +1 -1
- package/dist/types/schemas/entitlements.d.ts +14 -1
- package/dist/types/schemas/entitlements.js +11 -4
- package/dist/types/schemas/entitlements.js.map +1 -1
- package/dist/types/schemas/identity.d.ts +1 -85
- package/dist/types/schemas/identity.js +1 -42
- package/dist/types/schemas/identity.js.map +1 -1
- package/dist/types/schemas/index.d.ts +8 -7
- package/dist/types/schemas/index.js +8 -7
- package/dist/types/schemas/notifications.d.ts +96 -0
- package/dist/types/schemas/notifications.js +57 -0
- package/dist/types/schemas/notifications.js.map +1 -0
- package/dist/types/schemas/organizations.d.ts +96 -60
- package/dist/types/schemas/organizations.js +78 -27
- package/dist/types/schemas/organizations.js.map +1 -1
- package/dist/types/schemas/progress.d.ts +0 -1
- package/dist/types/schemas/progress.js +0 -1
- package/dist/types/schemas/progress.js.map +1 -1
- package/package.json +1 -1
- package/dist/automations/community-notifications.d.ts +0 -16
- package/dist/automations/community-notifications.js +0 -84
- package/dist/automations/community-notifications.js.map +0 -1
- package/dist/automations/seeds.d.ts +0 -17
- package/dist/automations/seeds.js +0 -235
- package/dist/automations/seeds.js.map +0 -1
- package/dist/identity/notifications.d.ts +0 -27
- package/dist/identity/notifications.js +0 -101
- package/dist/identity/notifications.js.map +0 -1
- package/dist/organizations/access-scopes.d.ts +0 -19
- package/dist/organizations/access-scopes.js +0 -89
- package/dist/organizations/access-scopes.js.map +0 -1
- package/dist/organizations/roles.d.ts +0 -19
- package/dist/organizations/roles.js +0 -82
- package/dist/organizations/roles.js.map +0 -1
|
@@ -1,42 +1,155 @@
|
|
|
1
1
|
import { DomainEvent, Page } from "../types/shared.js";
|
|
2
|
+
import { Event } from "../types/schemas/content.js";
|
|
2
3
|
import { Automation, AutomationKind, AutomationRun, AutomationRunsQuery, AutomationsQuery, AvailableActions, AvailableTriggers, CreateAutomationInput, CreateWebhookInput, CreatedWebhook, UpdateAutomationInput, UpdateWebhookInput, Webhook, WebhookSecret } from "../types/schemas/automations.js";
|
|
3
|
-
import { AutomationDispatch, AutomationEngine, AutomationExecutor, ScheduledAutomation, WebhookRequest, WebhookResponse, WebhookSender } from "../types/automations.js";
|
|
4
|
+
import { AutomationDispatch, AutomationEngine, AutomationExecutor, DeliveryDispatch, ScheduledAutomation, WebhookRequest, WebhookResponse, WebhookSender } from "../types/automations.js";
|
|
5
|
+
import { Delivery, NotificationCategory, NotificationFilter, RecipientList, StoredNotification, SubjectRef } from "../types/notifications.js";
|
|
4
6
|
import "../types/index.js";
|
|
7
|
+
import { Actor } from "../shared/actor.js";
|
|
5
8
|
import { CredentialStore, OutboxAppender, UnitOfWork } from "../shared/ports.js";
|
|
6
9
|
import "./model.js";
|
|
10
|
+
import "../content/index.js";
|
|
7
11
|
import "./types.js";
|
|
12
|
+
import { MemberActor } from "../identity/ports.js";
|
|
13
|
+
import "../identity/index.js";
|
|
14
|
+
import { CommunityMailReads } from "./community-mail.js";
|
|
8
15
|
//#region src/automations/ports.d.ts
|
|
9
16
|
type NewAutomation = CreateAutomationInput & {
|
|
10
17
|
kind: AutomationKind;
|
|
11
|
-
source?: 'system' | 'user';
|
|
12
18
|
};
|
|
19
|
+
interface NotificationCategories {
|
|
20
|
+
listFor(orgId: string, communityId: string | null): Promise<NotificationCategory[]>;
|
|
21
|
+
}
|
|
22
|
+
interface NotificationReads extends Omit<CommunityMailReads, 'recentMessageRecipients'> {
|
|
23
|
+
threadParticipants(orgId: string, item: SubjectRef): Promise<string[]>;
|
|
24
|
+
mutedAmong(orgId: string, item: SubjectRef, orgUserIds: string[], at: Date): Promise<string[]>;
|
|
25
|
+
communityMembers(orgId: string, communityId: string): Promise<string[]>;
|
|
26
|
+
switchedOn(orgId: string, communityId: string, category: string, spaceId: string | null): Promise<string[]>;
|
|
27
|
+
courseMembers(orgId: string, courseId: string): Promise<string[]>;
|
|
28
|
+
event(orgId: string, eventId: string): Promise<Event | null>;
|
|
29
|
+
eventAttendees(orgId: string, eventId: string): Promise<string[]>;
|
|
30
|
+
contentLostBy(orgId: string, grant: {
|
|
31
|
+
orgUserId: string;
|
|
32
|
+
contentId: string | null;
|
|
33
|
+
bundleId: string | null;
|
|
34
|
+
}): Promise<string[]>;
|
|
35
|
+
activity(orgId: string, activityId: string): Promise<{
|
|
36
|
+
title: string;
|
|
37
|
+
moduleTitle: string;
|
|
38
|
+
courseId: string;
|
|
39
|
+
courseTitle: string;
|
|
40
|
+
} | null>;
|
|
41
|
+
userIdsOf(orgId: string, orgUserIds: string[]): Promise<Record<string, string>>;
|
|
42
|
+
emailOf(orgId: string, userId: string): Promise<string | null>;
|
|
43
|
+
message(orgId: string, messageId: string): Promise<{
|
|
44
|
+
orgUserId: string;
|
|
45
|
+
chatId: string;
|
|
46
|
+
body: string;
|
|
47
|
+
} | null>;
|
|
48
|
+
postsPublished(orgId: string, communityId: string, from: Date, to: Date): Promise<{
|
|
49
|
+
postId: string;
|
|
50
|
+
spaceId: string;
|
|
51
|
+
title: string;
|
|
52
|
+
authorName: string;
|
|
53
|
+
spaceName: string;
|
|
54
|
+
commentCount: number;
|
|
55
|
+
}[]>;
|
|
56
|
+
unreadInChat(orgId: string, chatId: string, orgUserId: string): Promise<{
|
|
57
|
+
count: number;
|
|
58
|
+
latest: {
|
|
59
|
+
messageId: string;
|
|
60
|
+
senderOrgUserId: string;
|
|
61
|
+
body: string;
|
|
62
|
+
} | null;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
type RecipientRule = (event: DomainEvent, reads: NotificationReads) => Promise<RecipientList[]>;
|
|
66
|
+
interface ChatDebounce {
|
|
67
|
+
arm(orgId: string, list: RecipientList, occurredAt: Date): Promise<void>;
|
|
68
|
+
mentioned(orgId: string, userId: string, chatId: string): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
interface NewNotification extends Omit<StoredNotification, 'orgId'> {
|
|
71
|
+
sourceEventId: string | null;
|
|
72
|
+
inApp: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface NewDelivery {
|
|
75
|
+
id: string;
|
|
76
|
+
notificationId: string;
|
|
77
|
+
channel: string;
|
|
78
|
+
}
|
|
79
|
+
type ListedNotification = StoredNotification & {
|
|
80
|
+
readAt: Date | null;
|
|
81
|
+
};
|
|
82
|
+
interface NotificationPage {
|
|
83
|
+
items: ListedNotification[];
|
|
84
|
+
total: number;
|
|
85
|
+
unreadCount: number;
|
|
86
|
+
}
|
|
87
|
+
interface UnreadCounts {
|
|
88
|
+
org: number;
|
|
89
|
+
communities: {
|
|
90
|
+
communityId: string;
|
|
91
|
+
unread: number;
|
|
92
|
+
}[];
|
|
93
|
+
}
|
|
94
|
+
interface NotificationsService {
|
|
95
|
+
list(filter: NotificationFilter, page: {
|
|
96
|
+
page: number;
|
|
97
|
+
pageSize: number;
|
|
98
|
+
}, actor: MemberActor): Promise<NotificationPage>;
|
|
99
|
+
get(notificationId: string, actor: MemberActor): Promise<ListedNotification | null>;
|
|
100
|
+
unreadCounts(communityIds: string[], actor: MemberActor): Promise<UnreadCounts>;
|
|
101
|
+
markRead(notificationId: string, actor: MemberActor): Promise<void>;
|
|
102
|
+
markAllRead(filter: NotificationFilter, actor: MemberActor): Promise<{
|
|
103
|
+
marked: number;
|
|
104
|
+
}>;
|
|
105
|
+
}
|
|
106
|
+
interface NotificationsRepository {
|
|
107
|
+
insert(orgId: string, rows: NewNotification[], deliveries: NewDelivery[]): Promise<void>;
|
|
108
|
+
pendingDeliveriesForEvent(orgId: string, sourceEventId: string): Promise<{
|
|
109
|
+
id: string;
|
|
110
|
+
}[]>;
|
|
111
|
+
findDelivery(orgId: string, deliveryId: string): Promise<{
|
|
112
|
+
delivery: Delivery;
|
|
113
|
+
notification: StoredNotification;
|
|
114
|
+
} | null>;
|
|
115
|
+
markSent(orgId: string, deliveryId: string, at: Date): Promise<void>;
|
|
116
|
+
recordError(orgId: string, deliveryId: string, error: string): Promise<void>;
|
|
117
|
+
markFailed(orgId: string, deliveryId: string, error: string): Promise<void>;
|
|
118
|
+
page(orgId: string, userId: string, filter: NotificationFilter, page: {
|
|
119
|
+
page: number;
|
|
120
|
+
pageSize: number;
|
|
121
|
+
}): Promise<NotificationPage>;
|
|
122
|
+
find(orgId: string, userId: string, notificationId: string): Promise<ListedNotification | null>;
|
|
123
|
+
unreadCounts(orgId: string, userId: string, communityIds: string[]): Promise<UnreadCounts>;
|
|
124
|
+
markRead(orgId: string, userId: string, notificationId: string, at: Date): Promise<boolean>;
|
|
125
|
+
markAllRead(orgId: string, userId: string, filter: NotificationFilter, at: Date): Promise<number>;
|
|
126
|
+
}
|
|
13
127
|
/** A run row before persistence assigns its id and event_id. */
|
|
14
128
|
type NewAutomationRun = Omit<AutomationRun, 'id' | 'eventId'>;
|
|
15
129
|
interface AutomationsService {
|
|
16
|
-
/**
|
|
130
|
+
/** Dispatches a run per enabled automation the event matches, then runs the notification process; throws only when the notification process fails, so the outbox redelivers. */
|
|
17
131
|
handle(event: DomainEvent): Promise<void>;
|
|
18
132
|
/** Built-in action types plus every loaded integration's declared actions. */
|
|
19
|
-
availableActions(): AvailableActions;
|
|
133
|
+
availableActions(actor: Actor): AvailableActions;
|
|
20
134
|
/** The domain event types an automation may react to. */
|
|
21
|
-
availableTriggers(): AvailableTriggers;
|
|
22
|
-
list(
|
|
23
|
-
get(
|
|
24
|
-
create(
|
|
25
|
-
update(
|
|
26
|
-
delete(
|
|
27
|
-
listRuns(
|
|
28
|
-
rerun(
|
|
29
|
-
listWebhooks(
|
|
30
|
-
getWebhook(
|
|
31
|
-
createWebhook(
|
|
32
|
-
updateWebhook(
|
|
33
|
-
deleteWebhook(
|
|
34
|
-
revealWebhookSecret(
|
|
35
|
-
rotateWebhookSecret(
|
|
135
|
+
availableTriggers(actor: Actor): AvailableTriggers;
|
|
136
|
+
list(query: AutomationsQuery | undefined, actor: Actor): Promise<Automation[]>;
|
|
137
|
+
get(id: string, actor: Actor): Promise<Automation>;
|
|
138
|
+
create(input: CreateAutomationInput, actor: Actor): Promise<Automation>;
|
|
139
|
+
update(id: string, input: UpdateAutomationInput, actor: Actor): Promise<Automation>;
|
|
140
|
+
delete(id: string, actor: Actor): Promise<void>;
|
|
141
|
+
listRuns(automationId: string, query: AutomationRunsQuery, actor: Actor): Promise<Page<AutomationRun>>;
|
|
142
|
+
rerun(automationId: string, runId: string, actor: Actor): Promise<AutomationRun>;
|
|
143
|
+
listWebhooks(actor: Actor): Promise<Webhook[]>;
|
|
144
|
+
getWebhook(id: string, actor: Actor): Promise<Webhook>;
|
|
145
|
+
createWebhook(input: CreateWebhookInput, actor: Actor): Promise<CreatedWebhook>;
|
|
146
|
+
updateWebhook(id: string, input: UpdateWebhookInput, actor: Actor): Promise<Webhook>;
|
|
147
|
+
deleteWebhook(id: string, actor: Actor): Promise<void>;
|
|
148
|
+
revealWebhookSecret(id: string, actor: Actor): Promise<WebhookSecret>;
|
|
149
|
+
rotateWebhookSecret(id: string, actor: Actor): Promise<WebhookSecret>;
|
|
36
150
|
}
|
|
37
151
|
interface AutomationsRepository {
|
|
38
152
|
insert(orgId: string, input: NewAutomation): Promise<Automation>;
|
|
39
|
-
insertSeed(orgId: string, input: NewAutomation): Promise<Automation | null>;
|
|
40
153
|
update(orgId: string, id: string, patch: UpdateAutomationInput): Promise<Automation | null>;
|
|
41
154
|
/** Returns the deleted row (the event snapshot), or null if it didn't exist. */
|
|
42
155
|
delete(orgId: string, id: string): Promise<Automation | null>;
|
|
@@ -71,5 +184,5 @@ interface AutomationsTxScope {
|
|
|
71
184
|
}
|
|
72
185
|
type AutomationsUnitOfWork = UnitOfWork<AutomationsTxScope>;
|
|
73
186
|
//#endregion
|
|
74
|
-
export { type AutomationDispatch, type AutomationEngine, type AutomationExecutor, AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsTxScope, AutomationsUnitOfWork, NewAutomation, NewAutomationRun, type WebhookRequest, type WebhookResponse, type WebhookSender };
|
|
187
|
+
export { type AutomationDispatch, type AutomationEngine, type AutomationExecutor, AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsTxScope, AutomationsUnitOfWork, ChatDebounce, type DeliveryDispatch, ListedNotification, NewAutomation, NewAutomationRun, NewDelivery, NewNotification, NotificationCategories, NotificationPage, NotificationReads, NotificationsRepository, NotificationsService, RecipientRule, UnreadCounts, type WebhookRequest, type WebhookResponse, type WebhookSender };
|
|
75
188
|
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { DomainEvent, Page } from "../types/shared.js";
|
|
2
2
|
import { Logger } from "../types/ports.js";
|
|
3
3
|
import { Automation, AutomationActionResult, AutomationRun, AutomationRunsQuery, AutomationsQuery, AvailableActions, AvailableTriggers, CreateAutomationInput, CreateWebhookInput, CreatedWebhook, UpdateAutomationInput, UpdateWebhookInput, Webhook, WebhookSecret } from "../types/schemas/automations.js";
|
|
4
|
-
import { AutomationDispatch, AutomationEngine, AutomationExecutor, ScheduledAutomation, WebhookSender } from "../types/automations.js";
|
|
4
|
+
import { AutomationDispatch, AutomationEngine, AutomationExecutor, DeliveryDispatch, ScheduledAutomation, WebhookSender } from "../types/automations.js";
|
|
5
5
|
import "../types/index.js";
|
|
6
|
+
import { Actor } from "../shared/actor.js";
|
|
6
7
|
import { CredentialStore } from "../shared/ports.js";
|
|
7
8
|
import "./model.js";
|
|
8
|
-
import { NotificationDesk } from "../identity/ports.js";
|
|
9
9
|
import { Mailer, MailerLookups } from "../shared/mailer.js";
|
|
10
|
-
import "../identity/index.js";
|
|
11
10
|
import "./types.js";
|
|
12
11
|
import { AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsUnitOfWork } from "./ports.js";
|
|
13
|
-
import { CommunityMailReads, GrantWriter
|
|
12
|
+
import { CommunityMailReads, GrantWriter } from "./community-mail.js";
|
|
13
|
+
import { NotificationDelivery } from "./notifications/delivery.js";
|
|
14
|
+
import { NotificationProcessor } from "./notifications/processor.js";
|
|
14
15
|
import { IntegrationsService } from "../integrations/ports.js";
|
|
15
16
|
import "../integrations/index.js";
|
|
16
17
|
//#region src/automations/service.d.ts
|
|
@@ -24,12 +25,13 @@ type AutomationsServiceParams = {
|
|
|
24
25
|
mailer: Pick<Mailer, 'send'>;
|
|
25
26
|
lookups: MailerLookups;
|
|
26
27
|
integrations: Pick<IntegrationsService, 'available'>;
|
|
28
|
+
systemActor: (orgId: string) => Actor;
|
|
27
29
|
credentials: CredentialStore;
|
|
28
30
|
webhooks: WebhookSender;
|
|
29
31
|
mail: Omit<CommunityMailReads, 'recentMessageRecipients'>;
|
|
30
32
|
grants: GrantWriter;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
delivery: Pick<NotificationDelivery, 'run'>;
|
|
34
|
+
processor: Pick<NotificationProcessor, 'process'>;
|
|
33
35
|
logger?: Logger;
|
|
34
36
|
};
|
|
35
37
|
declare class AutomationsServiceImpl implements AutomationsService, AutomationExecutor {
|
|
@@ -40,48 +42,46 @@ declare class AutomationsServiceImpl implements AutomationsService, AutomationEx
|
|
|
40
42
|
private readonly mailer;
|
|
41
43
|
private readonly lookups;
|
|
42
44
|
private readonly integrations;
|
|
45
|
+
private readonly systemActor;
|
|
43
46
|
private readonly credentials;
|
|
44
47
|
private readonly webhooks;
|
|
45
48
|
private readonly mail;
|
|
46
49
|
private readonly grants;
|
|
47
|
-
private readonly
|
|
48
|
-
private readonly
|
|
50
|
+
private readonly delivery;
|
|
51
|
+
private readonly processor;
|
|
49
52
|
private readonly logger;
|
|
50
53
|
constructor(params: AutomationsServiceParams);
|
|
51
54
|
handle(event: DomainEvent): Promise<void>;
|
|
52
|
-
private seedsFor;
|
|
53
|
-
private seedFor;
|
|
54
55
|
private reconcileSchedules;
|
|
55
56
|
private safeListByTrigger;
|
|
56
57
|
private dispatchOne;
|
|
57
58
|
private openRun;
|
|
58
59
|
private dispatchFor;
|
|
59
|
-
/** Best-effort: logs and never rethrows
|
|
60
|
+
/** Best-effort: logs and never rethrows, so an org automation never fails `handle`. */
|
|
60
61
|
private recordFailure;
|
|
61
62
|
runAction(d: AutomationDispatch, index: number): Promise<AutomationActionResult>;
|
|
63
|
+
runDelivery(d: DeliveryDispatch, lastAttempt: boolean): Promise<void>;
|
|
62
64
|
listSchedules(): Promise<ScheduledAutomation[]>;
|
|
63
65
|
fireSchedule(orgId: string, automationId: string, at: Date): Promise<void>;
|
|
64
|
-
private scheduleHasWork;
|
|
65
|
-
private pendingWork;
|
|
66
66
|
finalize(d: AutomationDispatch, results: AutomationActionResult[]): Promise<void>;
|
|
67
67
|
private logOutcome;
|
|
68
|
-
create(
|
|
69
|
-
update(
|
|
70
|
-
delete(
|
|
71
|
-
list(
|
|
72
|
-
get(
|
|
73
|
-
listRuns(
|
|
74
|
-
rerun(
|
|
75
|
-
listWebhooks(
|
|
76
|
-
getWebhook(
|
|
77
|
-
createWebhook(
|
|
78
|
-
updateWebhook(
|
|
79
|
-
deleteWebhook(
|
|
80
|
-
revealWebhookSecret(
|
|
81
|
-
rotateWebhookSecret(
|
|
82
|
-
private
|
|
83
|
-
availableActions(): AvailableActions;
|
|
84
|
-
availableTriggers(): AvailableTriggers;
|
|
68
|
+
create(input: CreateAutomationInput, actor: Actor): Promise<Automation>;
|
|
69
|
+
update(id: string, input: UpdateAutomationInput, actor: Actor): Promise<Automation>;
|
|
70
|
+
delete(id: string, actor: Actor): Promise<void>;
|
|
71
|
+
list(query: AutomationsQuery | undefined, actor: Actor): Promise<Automation[]>;
|
|
72
|
+
get(id: string, actor: Actor): Promise<Automation>;
|
|
73
|
+
listRuns(automationId: string, query: AutomationRunsQuery, actor: Actor): Promise<Page<AutomationRun>>;
|
|
74
|
+
rerun(automationId: string, runId: string, actor: Actor): Promise<AutomationRun>;
|
|
75
|
+
listWebhooks(actor: Actor): Promise<Webhook[]>;
|
|
76
|
+
getWebhook(id: string, actor: Actor): Promise<Webhook>;
|
|
77
|
+
createWebhook(input: CreateWebhookInput, actor: Actor): Promise<CreatedWebhook>;
|
|
78
|
+
updateWebhook(id: string, input: UpdateWebhookInput, actor: Actor): Promise<Webhook>;
|
|
79
|
+
deleteWebhook(id: string, actor: Actor): Promise<void>;
|
|
80
|
+
revealWebhookSecret(id: string, actor: Actor): Promise<WebhookSecret>;
|
|
81
|
+
rotateWebhookSecret(id: string, actor: Actor): Promise<WebhookSecret>;
|
|
82
|
+
private requireWebhook;
|
|
83
|
+
availableActions(actor: Actor): AvailableActions;
|
|
84
|
+
availableTriggers(actor: Actor): AvailableTriggers;
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
87
|
export { AutomationsServiceImpl, AutomationsServiceParams };
|