@livetronics/wocul-domain 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/events/data.d.ts +1155 -0
- package/dist/events/data.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/notifications.d.ts +35 -0
- package/dist/notifications.js +125 -0
- package/package.json +1 -1
package/dist/events/data.js
CHANGED
|
@@ -92,6 +92,13 @@ exports.eventFactsSchema = zod_1.z
|
|
|
92
92
|
/** Why something stopped (a paused routine), and when. */
|
|
93
93
|
reasonCode: zod_1.z.string().optional(),
|
|
94
94
|
pausedAt: zod_1.z.string().optional(),
|
|
95
|
+
/** The routine a pause is of. */
|
|
96
|
+
idTaskRoutine: id.optional(),
|
|
97
|
+
/** The decision that asked for the AI's feedback, when there was one. */
|
|
98
|
+
idTaskFeedbackDecision: id.optional(),
|
|
99
|
+
/** A member's role before and after a role change: OWNER, MEMBER… */
|
|
100
|
+
roleFrom: zod_1.z.string().optional(),
|
|
101
|
+
roleTo: zod_1.z.string().optional(),
|
|
95
102
|
/** Tasks a finished import created, or a board's open tasks. */
|
|
96
103
|
count: zod_1.z.number().int().nonnegative().optional(),
|
|
97
104
|
idSprint: id.optional()
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -42,4 +42,5 @@ __exportStar(require("./events/data"), exports);
|
|
|
42
42
|
__exportStar(require("./events/message"), exports);
|
|
43
43
|
__exportStar(require("./channels"), exports);
|
|
44
44
|
__exportStar(require("./intents"), exports);
|
|
45
|
+
__exportStar(require("./notifications"), exports);
|
|
45
46
|
exports.api = __importStar(require("./api"));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification groups (notification-ts docs/RULES.md). core-ts's call sites
|
|
3
|
+
* decide who hears about a change today; notification-ts's rules take that
|
|
4
|
+
* over one group at a time. Both services read this map, so they agree on
|
|
5
|
+
* which rows a handed-over group covers.
|
|
6
|
+
*
|
|
7
|
+
* core-ts keeps a copy until it imports this package; coreParity.test.ts
|
|
8
|
+
* fails when the two drift.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NOTIFICATION_GROUPS: readonly ["watchers", "approvals", "task-details", "status", "comments", "membership", "feedback", "timers", "runs"];
|
|
11
|
+
export type NotificationGroup = (typeof NOTIFICATION_GROUPS)[number];
|
|
12
|
+
export declare const isNotificationGroup: (value: string) => value is NotificationGroup;
|
|
13
|
+
/** An `email_queue` row's eventType in the map: behind this prefix. */
|
|
14
|
+
export declare const EMAIL_TYPE_PREFIX = "email:";
|
|
15
|
+
/**
|
|
16
|
+
* The group that owns each queue row type: a `notification_queue` row by
|
|
17
|
+
* its eventType, an `email_queue` row by `email:<eventType>`. A type no rule
|
|
18
|
+
* plans (a command: the digest, an invitation email, billing mail) is not
|
|
19
|
+
* here and stays with core-ts.
|
|
20
|
+
*
|
|
21
|
+
* One owner per type. Task-Updated is planned by a watchers rule (someone
|
|
22
|
+
* stopped watching) and a task-details rule (the reporter changed); it goes
|
|
23
|
+
* over with task-details.
|
|
24
|
+
*/
|
|
25
|
+
export declare const NOTIFICATION_GROUP_OF: Readonly<Record<string, NotificationGroup>>;
|
|
26
|
+
/** The owning group of a queue row, or undefined for a type no rule plans. */
|
|
27
|
+
export declare const notificationGroupOf: (eventType: string, queue?: "notification" | "email") => NotificationGroup | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The payload field on which core-ts names the groups it had handed over
|
|
30
|
+
* when it published a domain event: it wrote no queue row for them, so the
|
|
31
|
+
* rules must.
|
|
32
|
+
*/
|
|
33
|
+
export declare const HANDED_OVER_FIELD = "handedOver";
|
|
34
|
+
/** The groups an event's `data` says core-ts had handed over. */
|
|
35
|
+
export declare function handedOverGroups(data: unknown): NotificationGroup[];
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HANDED_OVER_FIELD = exports.notificationGroupOf = exports.NOTIFICATION_GROUP_OF = exports.EMAIL_TYPE_PREFIX = exports.isNotificationGroup = exports.NOTIFICATION_GROUPS = void 0;
|
|
4
|
+
exports.handedOverGroups = handedOverGroups;
|
|
5
|
+
/**
|
|
6
|
+
* Notification groups (notification-ts docs/RULES.md). core-ts's call sites
|
|
7
|
+
* decide who hears about a change today; notification-ts's rules take that
|
|
8
|
+
* over one group at a time. Both services read this map, so they agree on
|
|
9
|
+
* which rows a handed-over group covers.
|
|
10
|
+
*
|
|
11
|
+
* core-ts keeps a copy until it imports this package; coreParity.test.ts
|
|
12
|
+
* fails when the two drift.
|
|
13
|
+
*/
|
|
14
|
+
exports.NOTIFICATION_GROUPS = [
|
|
15
|
+
'watchers',
|
|
16
|
+
'approvals',
|
|
17
|
+
'task-details',
|
|
18
|
+
'status',
|
|
19
|
+
'comments',
|
|
20
|
+
'membership',
|
|
21
|
+
'feedback',
|
|
22
|
+
'timers',
|
|
23
|
+
'runs'
|
|
24
|
+
];
|
|
25
|
+
const isNotificationGroup = (value) => exports.NOTIFICATION_GROUPS.includes(value);
|
|
26
|
+
exports.isNotificationGroup = isNotificationGroup;
|
|
27
|
+
/** An `email_queue` row's eventType in the map: behind this prefix. */
|
|
28
|
+
exports.EMAIL_TYPE_PREFIX = 'email:';
|
|
29
|
+
/**
|
|
30
|
+
* The group that owns each queue row type: a `notification_queue` row by
|
|
31
|
+
* its eventType, an `email_queue` row by `email:<eventType>`. A type no rule
|
|
32
|
+
* plans (a command: the digest, an invitation email, billing mail) is not
|
|
33
|
+
* here and stays with core-ts.
|
|
34
|
+
*
|
|
35
|
+
* One owner per type. Task-Updated is planned by a watchers rule (someone
|
|
36
|
+
* stopped watching) and a task-details rule (the reporter changed); it goes
|
|
37
|
+
* over with task-details.
|
|
38
|
+
*/
|
|
39
|
+
exports.NOTIFICATION_GROUP_OF = {
|
|
40
|
+
// watchers
|
|
41
|
+
'Task-Watcher-Added': 'watchers',
|
|
42
|
+
'Task-Watcher-Removed': 'watchers',
|
|
43
|
+
// approvals
|
|
44
|
+
'Approver-Added': 'approvals',
|
|
45
|
+
'Approver-Removed': 'approvals',
|
|
46
|
+
'Task-Approved': 'approvals',
|
|
47
|
+
'Task-Changes-Requested': 'approvals',
|
|
48
|
+
'Task-Approvals-Reset': 'approvals',
|
|
49
|
+
'Approval-Needed': 'approvals',
|
|
50
|
+
// task-details
|
|
51
|
+
'Task-Title-Edited': 'task-details',
|
|
52
|
+
'Task-Description-Edited': 'task-details',
|
|
53
|
+
'Task-Priority-Changed': 'task-details',
|
|
54
|
+
'Task-Reassign-Option-Updated': 'task-details',
|
|
55
|
+
'Task-Deadline-Updated': 'task-details',
|
|
56
|
+
'Task-Linked-To-OKR': 'task-details',
|
|
57
|
+
'Task-Unlinked-From-OKR': 'task-details',
|
|
58
|
+
'Task-Assigned': 'task-details',
|
|
59
|
+
'Task-Reassigned': 'task-details',
|
|
60
|
+
'Task-Unassigned': 'task-details',
|
|
61
|
+
'Task-Updated': 'task-details',
|
|
62
|
+
'Task-Board-Changed': 'task-details',
|
|
63
|
+
'Task-Removed': 'task-details',
|
|
64
|
+
'email:Task-Assigned': 'task-details',
|
|
65
|
+
'email:Task-Unassigned': 'task-details',
|
|
66
|
+
// status
|
|
67
|
+
'Task-Column-Changed': 'status',
|
|
68
|
+
'Task-Completed': 'status',
|
|
69
|
+
'Task-Reopened': 'status',
|
|
70
|
+
// comments
|
|
71
|
+
'Comment-Added': 'comments',
|
|
72
|
+
'User-Mentioned': 'comments',
|
|
73
|
+
'AI-Mention': 'comments',
|
|
74
|
+
'email:User-Mention': 'comments',
|
|
75
|
+
// membership
|
|
76
|
+
'Project-Kickstart': 'membership',
|
|
77
|
+
'Member-Invitation': 'membership',
|
|
78
|
+
'Project-Invitation-Accepted': 'membership',
|
|
79
|
+
'Project-Invitation-Declined': 'membership',
|
|
80
|
+
'Project-Archived': 'membership',
|
|
81
|
+
'Project-Unarchived': 'membership',
|
|
82
|
+
'Project-Members-Removed': 'membership',
|
|
83
|
+
'Board-Members-Added': 'membership',
|
|
84
|
+
'email:Member-Removed': 'membership',
|
|
85
|
+
'email:Project-Role-Changed': 'membership',
|
|
86
|
+
// feedback
|
|
87
|
+
'Feedback-Created': 'feedback',
|
|
88
|
+
'AI-Feedback': 'feedback',
|
|
89
|
+
'email:Feedback-Received': 'feedback',
|
|
90
|
+
'email:AI-Feedback': 'feedback',
|
|
91
|
+
// timers
|
|
92
|
+
'Task-Overdue': 'timers',
|
|
93
|
+
'Task-Deadline-Alert': 'timers',
|
|
94
|
+
'Board-Past-End': 'timers',
|
|
95
|
+
'Routine-Paused': 'timers',
|
|
96
|
+
'email:Task-Deadline-Alert': 'timers',
|
|
97
|
+
// runs
|
|
98
|
+
'Agent-Run-Completed': 'runs',
|
|
99
|
+
'Routine-Report-Ready': 'runs',
|
|
100
|
+
'Agent-Run-Failed': 'runs',
|
|
101
|
+
'Board-Pulse-Ready': 'runs',
|
|
102
|
+
'Bulk-Import-Completed': 'runs',
|
|
103
|
+
'email:Agent-Run-Completed': 'runs',
|
|
104
|
+
'email:Agent-Run-Needs-Input': 'runs',
|
|
105
|
+
'email:Agent-Run-Failed': 'runs',
|
|
106
|
+
'email:Board-Pulse-Ready': 'runs'
|
|
107
|
+
};
|
|
108
|
+
/** The owning group of a queue row, or undefined for a type no rule plans. */
|
|
109
|
+
const notificationGroupOf = (eventType, queue = 'notification') => Object.prototype.hasOwnProperty.call(exports.NOTIFICATION_GROUP_OF, queue === 'email' ? `${exports.EMAIL_TYPE_PREFIX}${eventType}` : eventType)
|
|
110
|
+
? exports.NOTIFICATION_GROUP_OF[queue === 'email' ? `${exports.EMAIL_TYPE_PREFIX}${eventType}` : eventType]
|
|
111
|
+
: undefined;
|
|
112
|
+
exports.notificationGroupOf = notificationGroupOf;
|
|
113
|
+
/**
|
|
114
|
+
* The payload field on which core-ts names the groups it had handed over
|
|
115
|
+
* when it published a domain event: it wrote no queue row for them, so the
|
|
116
|
+
* rules must.
|
|
117
|
+
*/
|
|
118
|
+
exports.HANDED_OVER_FIELD = 'handedOver';
|
|
119
|
+
/** The groups an event's `data` says core-ts had handed over. */
|
|
120
|
+
function handedOverGroups(data) {
|
|
121
|
+
const value = data?.[exports.HANDED_OVER_FIELD];
|
|
122
|
+
return Array.isArray(value)
|
|
123
|
+
? value.filter((group) => typeof group === 'string' && (0, exports.isNotificationGroup)(group))
|
|
124
|
+
: [];
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livetronics/wocul-domain",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Shared Wocul domain contracts: realtime event and intent schemas, channel names, and Core API types generated from the OpenAPI spec",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|