@headless-lms/core 0.1.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.
Files changed (261) hide show
  1. package/LICENSE +21 -0
  2. package/dist/assets/events.d.ts +81 -0
  3. package/dist/assets/events.js +24 -0
  4. package/dist/assets/events.js.map +1 -0
  5. package/dist/assets/index.d.ts +7 -0
  6. package/dist/assets/index.js +3 -0
  7. package/dist/assets/model.d.ts +4 -0
  8. package/dist/assets/model.js +1 -0
  9. package/dist/assets/ports.d.ts +34 -0
  10. package/dist/assets/ports.js +1 -0
  11. package/dist/assets/service.d.ts +29 -0
  12. package/dist/assets/service.js +130 -0
  13. package/dist/assets/service.js.map +1 -0
  14. package/dist/automations/actions.d.ts +24 -0
  15. package/dist/automations/actions.js +59 -0
  16. package/dist/automations/actions.js.map +1 -0
  17. package/dist/automations/catalog.d.ts +12 -0
  18. package/dist/automations/catalog.js +224 -0
  19. package/dist/automations/catalog.js.map +1 -0
  20. package/dist/automations/events.d.ts +264 -0
  21. package/dist/automations/events.js +54 -0
  22. package/dist/automations/events.js.map +1 -0
  23. package/dist/automations/index.d.ts +9 -0
  24. package/dist/automations/index.js +4 -0
  25. package/dist/automations/model.d.ts +12 -0
  26. package/dist/automations/model.js +14 -0
  27. package/dist/automations/model.js.map +1 -0
  28. package/dist/automations/ports.d.ts +56 -0
  29. package/dist/automations/ports.js +1 -0
  30. package/dist/automations/service.d.ts +53 -0
  31. package/dist/automations/service.js +225 -0
  32. package/dist/automations/service.js.map +1 -0
  33. package/dist/automations/types.d.ts +3 -0
  34. package/dist/automations/types.js +1 -0
  35. package/dist/content/events.d.ts +410 -0
  36. package/dist/content/events.js +105 -0
  37. package/dist/content/events.js.map +1 -0
  38. package/dist/content/index.d.ts +8 -0
  39. package/dist/content/index.js +3 -0
  40. package/dist/content/model.d.ts +3 -0
  41. package/dist/content/model.js +1 -0
  42. package/dist/content/ports.d.ts +85 -0
  43. package/dist/content/ports.js +1 -0
  44. package/dist/content/service.d.ts +54 -0
  45. package/dist/content/service.js +479 -0
  46. package/dist/content/service.js.map +1 -0
  47. package/dist/content/types.d.ts +4 -0
  48. package/dist/content/types.js +1 -0
  49. package/dist/discussion/events.d.ts +101 -0
  50. package/dist/discussion/events.js +29 -0
  51. package/dist/discussion/events.js.map +1 -0
  52. package/dist/discussion/index.d.ts +8 -0
  53. package/dist/discussion/index.js +3 -0
  54. package/dist/discussion/model.d.ts +5 -0
  55. package/dist/discussion/model.js +1 -0
  56. package/dist/discussion/ports.d.ts +112 -0
  57. package/dist/discussion/ports.js +1 -0
  58. package/dist/discussion/service.d.ts +67 -0
  59. package/dist/discussion/service.js +343 -0
  60. package/dist/discussion/service.js.map +1 -0
  61. package/dist/discussion/types.d.ts +4 -0
  62. package/dist/discussion/types.js +1 -0
  63. package/dist/entitlements/events.d.ts +89 -0
  64. package/dist/entitlements/events.js +29 -0
  65. package/dist/entitlements/events.js.map +1 -0
  66. package/dist/entitlements/index.d.ts +7 -0
  67. package/dist/entitlements/index.js +3 -0
  68. package/dist/entitlements/model.d.ts +4 -0
  69. package/dist/entitlements/model.js +1 -0
  70. package/dist/entitlements/ports.d.ts +34 -0
  71. package/dist/entitlements/ports.js +1 -0
  72. package/dist/entitlements/service.d.ts +27 -0
  73. package/dist/entitlements/service.js +60 -0
  74. package/dist/entitlements/service.js.map +1 -0
  75. package/dist/identity/events.d.ts +63 -0
  76. package/dist/identity/events.js +24 -0
  77. package/dist/identity/events.js.map +1 -0
  78. package/dist/identity/index.d.ts +8 -0
  79. package/dist/identity/index.js +3 -0
  80. package/dist/identity/model.d.ts +3 -0
  81. package/dist/identity/model.js +1 -0
  82. package/dist/identity/ports.d.ts +58 -0
  83. package/dist/identity/ports.js +1 -0
  84. package/dist/identity/service.d.ts +38 -0
  85. package/dist/identity/service.js +79 -0
  86. package/dist/identity/service.js.map +1 -0
  87. package/dist/identity/types.d.ts +4 -0
  88. package/dist/identity/types.js +1 -0
  89. package/dist/integrations/events.d.ts +70 -0
  90. package/dist/integrations/events.js +24 -0
  91. package/dist/integrations/events.js.map +1 -0
  92. package/dist/integrations/index.d.ts +9 -0
  93. package/dist/integrations/index.js +6 -0
  94. package/dist/integrations/model.d.ts +28 -0
  95. package/dist/integrations/model.js +45 -0
  96. package/dist/integrations/model.js.map +1 -0
  97. package/dist/integrations/ports.d.ts +62 -0
  98. package/dist/integrations/ports.js +1 -0
  99. package/dist/integrations/registry.d.ts +7 -0
  100. package/dist/integrations/registry.js +16 -0
  101. package/dist/integrations/registry.js.map +1 -0
  102. package/dist/integrations/service.d.ts +47 -0
  103. package/dist/integrations/service.js +184 -0
  104. package/dist/integrations/service.js.map +1 -0
  105. package/dist/integrations/zod.d.ts +29 -0
  106. package/dist/integrations/zod.js +40 -0
  107. package/dist/integrations/zod.js.map +1 -0
  108. package/dist/organizations/events.d.ts +197 -0
  109. package/dist/organizations/events.js +59 -0
  110. package/dist/organizations/events.js.map +1 -0
  111. package/dist/organizations/index.d.ts +11 -0
  112. package/dist/organizations/index.js +5 -0
  113. package/dist/organizations/members.d.ts +32 -0
  114. package/dist/organizations/members.js +12 -0
  115. package/dist/organizations/members.js.map +1 -0
  116. package/dist/organizations/model.d.ts +3 -0
  117. package/dist/organizations/model.js +1 -0
  118. package/dist/organizations/ports.d.ts +127 -0
  119. package/dist/organizations/ports.js +1 -0
  120. package/dist/organizations/roles.d.ts +23 -0
  121. package/dist/organizations/roles.js +70 -0
  122. package/dist/organizations/roles.js.map +1 -0
  123. package/dist/organizations/service.d.ts +58 -0
  124. package/dist/organizations/service.js +359 -0
  125. package/dist/organizations/service.js.map +1 -0
  126. package/dist/organizations/types.d.ts +39 -0
  127. package/dist/organizations/types.js +1 -0
  128. package/dist/progress/events.d.ts +55 -0
  129. package/dist/progress/events.js +19 -0
  130. package/dist/progress/events.js.map +1 -0
  131. package/dist/progress/index.d.ts +8 -0
  132. package/dist/progress/index.js +3 -0
  133. package/dist/progress/model.d.ts +3 -0
  134. package/dist/progress/model.js +1 -0
  135. package/dist/progress/ports.d.ts +37 -0
  136. package/dist/progress/ports.js +1 -0
  137. package/dist/progress/service.d.ts +33 -0
  138. package/dist/progress/service.js +181 -0
  139. package/dist/progress/service.js.map +1 -0
  140. package/dist/progress/types.d.ts +4 -0
  141. package/dist/progress/types.js +1 -0
  142. package/dist/reporting/dashboard/index.d.ts +4 -0
  143. package/dist/reporting/dashboard/index.js +2 -0
  144. package/dist/reporting/dashboard/model.d.ts +14 -0
  145. package/dist/reporting/dashboard/model.js +1 -0
  146. package/dist/reporting/dashboard/ports.d.ts +13 -0
  147. package/dist/reporting/dashboard/ports.js +1 -0
  148. package/dist/reporting/dashboard/service.d.ts +19 -0
  149. package/dist/reporting/dashboard/service.js +20 -0
  150. package/dist/reporting/dashboard/service.js.map +1 -0
  151. package/dist/reporting/learn/index.d.ts +5 -0
  152. package/dist/reporting/learn/index.js +2 -0
  153. package/dist/reporting/learn/model.d.ts +23 -0
  154. package/dist/reporting/learn/model.js +1 -0
  155. package/dist/reporting/learn/ports.d.ts +42 -0
  156. package/dist/reporting/learn/ports.js +1 -0
  157. package/dist/reporting/learn/service.d.ts +48 -0
  158. package/dist/reporting/learn/service.js +111 -0
  159. package/dist/reporting/learn/service.js.map +1 -0
  160. package/dist/reporting/students/index.d.ts +4 -0
  161. package/dist/reporting/students/index.js +2 -0
  162. package/dist/reporting/students/model.d.ts +31 -0
  163. package/dist/reporting/students/model.js +1 -0
  164. package/dist/reporting/students/ports.d.ts +13 -0
  165. package/dist/reporting/students/ports.js +1 -0
  166. package/dist/reporting/students/service.d.ts +19 -0
  167. package/dist/reporting/students/service.js +20 -0
  168. package/dist/reporting/students/service.js.map +1 -0
  169. package/dist/shared/errors.d.ts +22 -0
  170. package/dist/shared/errors.js +34 -0
  171. package/dist/shared/errors.js.map +1 -0
  172. package/dist/shared/events.d.ts +31 -0
  173. package/dist/shared/events.js +75 -0
  174. package/dist/shared/events.js.map +1 -0
  175. package/dist/shared/id.d.ts +44 -0
  176. package/dist/shared/id.js +53 -0
  177. package/dist/shared/id.js.map +1 -0
  178. package/dist/shared/invite-token.d.ts +9 -0
  179. package/dist/shared/invite-token.js +16 -0
  180. package/dist/shared/invite-token.js.map +1 -0
  181. package/dist/shared/logger.d.ts +19 -0
  182. package/dist/shared/logger.js +44 -0
  183. package/dist/shared/logger.js.map +1 -0
  184. package/dist/shared/mailer.d.ts +23 -0
  185. package/dist/shared/mailer.js +27 -0
  186. package/dist/shared/mailer.js.map +1 -0
  187. package/dist/shared/ports.d.ts +62 -0
  188. package/dist/shared/ports.js +2 -0
  189. package/dist/shared/settings.d.ts +25 -0
  190. package/dist/shared/settings.js +21 -0
  191. package/dist/shared/settings.js.map +1 -0
  192. package/dist/types/assets.d.ts +2 -0
  193. package/dist/types/assets.js +1 -0
  194. package/dist/types/automations.d.ts +23 -0
  195. package/dist/types/automations.js +1 -0
  196. package/dist/types/content.d.ts +2 -0
  197. package/dist/types/content.js +1 -0
  198. package/dist/types/discussion.d.ts +36 -0
  199. package/dist/types/discussion.js +1 -0
  200. package/dist/types/email-templates.d.ts +57 -0
  201. package/dist/types/email-templates.js +1 -0
  202. package/dist/types/entitlements.d.ts +3 -0
  203. package/dist/types/entitlements.js +1 -0
  204. package/dist/types/events.d.ts +25 -0
  205. package/dist/types/events.js +1 -0
  206. package/dist/types/identity.d.ts +37 -0
  207. package/dist/types/identity.js +1 -0
  208. package/dist/types/index.d.ts +23 -0
  209. package/dist/types/index.js +1 -0
  210. package/dist/types/integrations.d.ts +45 -0
  211. package/dist/types/integrations.js +1 -0
  212. package/dist/types/organizations.d.ts +15 -0
  213. package/dist/types/organizations.js +1 -0
  214. package/dist/types/ports.d.ts +57 -0
  215. package/dist/types/ports.js +1 -0
  216. package/dist/types/progress.d.ts +6 -0
  217. package/dist/types/progress.js +1 -0
  218. package/dist/types/schemas/assets.d.ts +109 -0
  219. package/dist/types/schemas/assets.js +49 -0
  220. package/dist/types/schemas/assets.js.map +1 -0
  221. package/dist/types/schemas/automations.d.ts +118 -0
  222. package/dist/types/schemas/automations.js +73 -0
  223. package/dist/types/schemas/automations.js.map +1 -0
  224. package/dist/types/schemas/content.d.ts +216 -0
  225. package/dist/types/schemas/content.js +138 -0
  226. package/dist/types/schemas/content.js.map +1 -0
  227. package/dist/types/schemas/credentials.d.ts +15 -0
  228. package/dist/types/schemas/credentials.js +15 -0
  229. package/dist/types/schemas/credentials.js.map +1 -0
  230. package/dist/types/schemas/discussion.d.ts +192 -0
  231. package/dist/types/schemas/discussion.js +100 -0
  232. package/dist/types/schemas/discussion.js.map +1 -0
  233. package/dist/types/schemas/entitlements.d.ts +50 -0
  234. package/dist/types/schemas/entitlements.js +38 -0
  235. package/dist/types/schemas/entitlements.js.map +1 -0
  236. package/dist/types/schemas/identity.d.ts +37 -0
  237. package/dist/types/schemas/identity.js +34 -0
  238. package/dist/types/schemas/identity.js.map +1 -0
  239. package/dist/types/schemas/index.d.ts +14 -0
  240. package/dist/types/schemas/index.js +14 -0
  241. package/dist/types/schemas/integrations.d.ts +36 -0
  242. package/dist/types/schemas/integrations.js +30 -0
  243. package/dist/types/schemas/integrations.js.map +1 -0
  244. package/dist/types/schemas/organizations.d.ts +135 -0
  245. package/dist/types/schemas/organizations.js +90 -0
  246. package/dist/types/schemas/organizations.js.map +1 -0
  247. package/dist/types/schemas/outbox.d.ts +19 -0
  248. package/dist/types/schemas/outbox.js +18 -0
  249. package/dist/types/schemas/outbox.js.map +1 -0
  250. package/dist/types/schemas/progress.d.ts +53 -0
  251. package/dist/types/schemas/progress.js +37 -0
  252. package/dist/types/schemas/progress.js.map +1 -0
  253. package/dist/types/schemas/settings.d.ts +16 -0
  254. package/dist/types/schemas/settings.js +15 -0
  255. package/dist/types/schemas/settings.js.map +1 -0
  256. package/dist/types/schemas/shared.d.ts +13 -0
  257. package/dist/types/schemas/shared.js +28 -0
  258. package/dist/types/schemas/shared.js.map +1 -0
  259. package/dist/types/shared.d.ts +25 -0
  260. package/dist/types/shared.js +1 -0
  261. package/package.json +61 -0
@@ -0,0 +1,224 @@
1
+ import { assetEvents } from "../assets/events.js";
2
+ import { entitlementEvents } from "../entitlements/events.js";
3
+ import { contentEvents } from "../content/events.js";
4
+ import { discussionEvents } from "../discussion/events.js";
5
+ import { identityEvents } from "../identity/events.js";
6
+ import { integrationEvents } from "../integrations/events.js";
7
+ import { organizationEvents } from "../organizations/events.js";
8
+ import { progressEvents } from "../progress/events.js";
9
+ //#region src/automations/catalog.ts
10
+ /** Every EmailTemplateId — a missing key here is a compile error, kept exhaustive by construction. */
11
+ const ALL_EMAIL_TEMPLATE_IDS = {
12
+ magicLink: true,
13
+ studentInvite: true,
14
+ memberInvite: true,
15
+ passwordReset: true,
16
+ emailVerification: true,
17
+ accessGranted: true,
18
+ accessRevoked: true,
19
+ courseCompleted: true
20
+ };
21
+ function catalogActions() {
22
+ return [{
23
+ type: "sendEmail",
24
+ description: "Send a transactional email using a built-in template.",
25
+ inputSchema: {
26
+ type: "object",
27
+ required: ["template"],
28
+ properties: { template: { enum: Object.keys(ALL_EMAIL_TEMPLATE_IDS) } }
29
+ },
30
+ source: "system"
31
+ }];
32
+ }
33
+ function catalogTriggers() {
34
+ return [
35
+ {
36
+ type: identityEvents.userCreated.type,
37
+ description: "a user was created"
38
+ },
39
+ {
40
+ type: identityEvents.userUpdated.type,
41
+ description: "a user was updated"
42
+ },
43
+ {
44
+ type: organizationEvents.organizationCreated.type,
45
+ description: "an organization was created"
46
+ },
47
+ {
48
+ type: organizationEvents.organizationUpdated.type,
49
+ description: "an organization was updated"
50
+ },
51
+ {
52
+ type: organizationEvents.organizationDeleted.type,
53
+ description: "an organization was deleted"
54
+ },
55
+ {
56
+ type: organizationEvents.orgUserLinked.type,
57
+ description: "a user was linked to an organization"
58
+ },
59
+ {
60
+ type: organizationEvents.orgUserDeleted.type,
61
+ description: "a user was removed from an organization"
62
+ },
63
+ {
64
+ type: organizationEvents.inviteCreated.type,
65
+ description: "an invite was created or re-issued"
66
+ },
67
+ {
68
+ type: organizationEvents.inviteAccepted.type,
69
+ description: "an invite was accepted"
70
+ },
71
+ {
72
+ type: organizationEvents.studentCreated.type,
73
+ description: "a student was created"
74
+ },
75
+ {
76
+ type: organizationEvents.studentDeleted.type,
77
+ description: "a student was deleted"
78
+ },
79
+ {
80
+ type: organizationEvents.studentLinked.type,
81
+ description: "a pending student was linked to an auth account"
82
+ },
83
+ {
84
+ type: contentEvents.courseCreated.type,
85
+ description: "a course was created"
86
+ },
87
+ {
88
+ type: contentEvents.courseUpdated.type,
89
+ description: "a course was updated"
90
+ },
91
+ {
92
+ type: contentEvents.courseDeleted.type,
93
+ description: "a course was deleted"
94
+ },
95
+ {
96
+ type: contentEvents.moduleCreated.type,
97
+ description: "a course module was created"
98
+ },
99
+ {
100
+ type: contentEvents.moduleUpdated.type,
101
+ description: "a course module was updated"
102
+ },
103
+ {
104
+ type: contentEvents.moduleDeleted.type,
105
+ description: "a course module was deleted"
106
+ },
107
+ {
108
+ type: contentEvents.modulesReordered.type,
109
+ description: "course modules were reordered"
110
+ },
111
+ {
112
+ type: contentEvents.activityCreated.type,
113
+ description: "a course activity was created"
114
+ },
115
+ {
116
+ type: contentEvents.activityUpdated.type,
117
+ description: "a course activity was updated"
118
+ },
119
+ {
120
+ type: contentEvents.activityDeleted.type,
121
+ description: "a course activity was deleted"
122
+ },
123
+ {
124
+ type: contentEvents.activitiesReordered.type,
125
+ description: "course activities were reordered"
126
+ },
127
+ {
128
+ type: contentEvents.downloadCreated.type,
129
+ description: "a download was created"
130
+ },
131
+ {
132
+ type: contentEvents.downloadUpdated.type,
133
+ description: "a download was updated"
134
+ },
135
+ {
136
+ type: contentEvents.downloadDeleted.type,
137
+ description: "a download was deleted"
138
+ },
139
+ {
140
+ type: contentEvents.downloadAssetAdded.type,
141
+ description: "a download asset was added"
142
+ },
143
+ {
144
+ type: contentEvents.downloadAssetRemoved.type,
145
+ description: "a download asset was removed"
146
+ },
147
+ {
148
+ type: contentEvents.downloadAssetRenamed.type,
149
+ description: "a download asset was renamed"
150
+ },
151
+ {
152
+ type: contentEvents.downloadAssetsReordered.type,
153
+ description: "download assets were reordered"
154
+ },
155
+ {
156
+ type: entitlementEvents.entitlementCreated.type,
157
+ description: "a student was granted access to content"
158
+ },
159
+ {
160
+ type: entitlementEvents.entitlementUpdated.type,
161
+ description: "an entitlement's status or expiry changed"
162
+ },
163
+ {
164
+ type: entitlementEvents.entitlementDeleted.type,
165
+ description: "a student's access to content was revoked"
166
+ },
167
+ {
168
+ type: entitlementEvents.entitlementExpired.type,
169
+ description: "an entitlement passed its expiry"
170
+ },
171
+ {
172
+ type: progressEvents.progressStarted.type,
173
+ description: "a student started a progress record"
174
+ },
175
+ {
176
+ type: progressEvents.progressCompleted.type,
177
+ description: "a student completed a progress record"
178
+ },
179
+ {
180
+ type: integrationEvents.connectionCreated.type,
181
+ description: "an integration connection was established"
182
+ },
183
+ {
184
+ type: integrationEvents.connectionUpdated.type,
185
+ description: "an integration connection changed"
186
+ },
187
+ {
188
+ type: integrationEvents.connectionRemoved.type,
189
+ description: "an integration connection was removed"
190
+ },
191
+ {
192
+ type: discussionEvents.commentCreated.type,
193
+ description: "a comment was created"
194
+ },
195
+ {
196
+ type: discussionEvents.commentPublished.type,
197
+ description: "a comment was published"
198
+ },
199
+ {
200
+ type: discussionEvents.commentRemoved.type,
201
+ description: "a comment was removed"
202
+ },
203
+ {
204
+ type: discussionEvents.commentReported.type,
205
+ description: "a comment was reported"
206
+ },
207
+ {
208
+ type: assetEvents.assetCreated.type,
209
+ description: "an asset upload was requested"
210
+ },
211
+ {
212
+ type: assetEvents.assetReady.type,
213
+ description: "an asset was confirmed ready"
214
+ },
215
+ {
216
+ type: assetEvents.assetDeleted.type,
217
+ description: "an asset was deleted"
218
+ }
219
+ ];
220
+ }
221
+ //#endregion
222
+ export { ALL_EMAIL_TEMPLATE_IDS, catalogActions, catalogTriggers };
223
+
224
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","names":[],"sources":["../../src/automations/catalog.ts"],"sourcesContent":["// automations context — the code-owned catalogs `availableActions()` and\n// `availableTriggers()` serve: built-in action definitions and the domain\n// event types automations may react to.\nimport type { EmailTemplateId } from '../types/index.js';\nimport { assetEvents } from '../assets/index.js';\nimport { contentEvents } from '../content/index.js';\nimport { discussionEvents } from '../discussion/index.js';\nimport { entitlementEvents } from '../entitlements/index.js';\nimport { identityEvents } from '../identity/index.js';\nimport { integrationEvents } from '../integrations/index.js';\nimport { organizationEvents } from '../organizations/index.js';\nimport { progressEvents } from '../progress/index.js';\nimport type { AvailableActions, AvailableTriggers } from './types.js';\n\n/** Every EmailTemplateId — a missing key here is a compile error, kept exhaustive by construction. */\nexport const ALL_EMAIL_TEMPLATE_IDS: Record<EmailTemplateId, true> = {\n magicLink: true,\n studentInvite: true,\n memberInvite: true,\n passwordReset: true,\n emailVerification: true,\n accessGranted: true,\n accessRevoked: true,\n courseCompleted: true,\n};\n\nexport function catalogActions(): AvailableActions {\n return [\n {\n type: 'sendEmail',\n description: 'Send a transactional email using a built-in template.',\n inputSchema: {\n type: 'object',\n required: ['template'],\n properties: {\n template: { enum: Object.keys(ALL_EMAIL_TEMPLATE_IDS) },\n },\n },\n source: 'system',\n },\n ];\n}\n\nexport function catalogTriggers(): AvailableTriggers['triggers'] {\n return [\n { type: identityEvents.userCreated.type, description: 'a user was created' },\n { type: identityEvents.userUpdated.type, description: 'a user was updated' },\n { type: organizationEvents.organizationCreated.type, description: 'an organization was created' },\n { type: organizationEvents.organizationUpdated.type, description: 'an organization was updated' },\n { type: organizationEvents.organizationDeleted.type, description: 'an organization was deleted' },\n { type: organizationEvents.orgUserLinked.type, description: 'a user was linked to an organization' },\n { type: organizationEvents.orgUserDeleted.type, description: 'a user was removed from an organization' },\n { type: organizationEvents.inviteCreated.type, description: 'an invite was created or re-issued' },\n { type: organizationEvents.inviteAccepted.type, description: 'an invite was accepted' },\n { type: organizationEvents.studentCreated.type, description: 'a student was created' },\n { type: organizationEvents.studentDeleted.type, description: 'a student was deleted' },\n { type: organizationEvents.studentLinked.type, description: 'a pending student was linked to an auth account' },\n { type: contentEvents.courseCreated.type, description: 'a course was created' },\n { type: contentEvents.courseUpdated.type, description: 'a course was updated' },\n { type: contentEvents.courseDeleted.type, description: 'a course was deleted' },\n { type: contentEvents.moduleCreated.type, description: 'a course module was created' },\n { type: contentEvents.moduleUpdated.type, description: 'a course module was updated' },\n { type: contentEvents.moduleDeleted.type, description: 'a course module was deleted' },\n { type: contentEvents.modulesReordered.type, description: 'course modules were reordered' },\n { type: contentEvents.activityCreated.type, description: 'a course activity was created' },\n { type: contentEvents.activityUpdated.type, description: 'a course activity was updated' },\n { type: contentEvents.activityDeleted.type, description: 'a course activity was deleted' },\n { type: contentEvents.activitiesReordered.type, description: 'course activities were reordered' },\n { type: contentEvents.downloadCreated.type, description: 'a download was created' },\n { type: contentEvents.downloadUpdated.type, description: 'a download was updated' },\n { type: contentEvents.downloadDeleted.type, description: 'a download was deleted' },\n { type: contentEvents.downloadAssetAdded.type, description: 'a download asset was added' },\n { type: contentEvents.downloadAssetRemoved.type, description: 'a download asset was removed' },\n { type: contentEvents.downloadAssetRenamed.type, description: 'a download asset was renamed' },\n { type: contentEvents.downloadAssetsReordered.type, description: 'download assets were reordered' },\n { type: entitlementEvents.entitlementCreated.type, description: 'a student was granted access to content' },\n { type: entitlementEvents.entitlementUpdated.type, description: \"an entitlement's status or expiry changed\" },\n { type: entitlementEvents.entitlementDeleted.type, description: \"a student's access to content was revoked\" },\n { type: entitlementEvents.entitlementExpired.type, description: 'an entitlement passed its expiry' },\n { type: progressEvents.progressStarted.type, description: 'a student started a progress record' },\n { type: progressEvents.progressCompleted.type, description: 'a student completed a progress record' },\n { type: integrationEvents.connectionCreated.type, description: 'an integration connection was established' },\n { type: integrationEvents.connectionUpdated.type, description: \"an integration connection changed\" },\n { type: integrationEvents.connectionRemoved.type, description: 'an integration connection was removed' },\n { type: discussionEvents.commentCreated.type, description: 'a comment was created' },\n { type: discussionEvents.commentPublished.type, description: 'a comment was published' },\n { type: discussionEvents.commentRemoved.type, description: 'a comment was removed' },\n { type: discussionEvents.commentReported.type, description: 'a comment was reported' },\n { type: assetEvents.assetCreated.type, description: 'an asset upload was requested' },\n { type: assetEvents.assetReady.type, description: 'an asset was confirmed ready' },\n { type: assetEvents.assetDeleted.type, description: 'an asset was deleted' },\n ];\n}\n"],"mappings":"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"}
@@ -0,0 +1,264 @@
1
+ import { DomainEvent, JsonValue } from "../types/shared.js";
2
+ import { EventOf, EventOfValues, RuntimeEventDefinition, VersionedDomainEvent } from "../shared/events.js";
3
+ import "../shared/ports.js";
4
+ //#region src/automations/events.d.ts
5
+ declare const automationEvents: {
6
+ automationCreated: RuntimeEventDefinition<VersionedDomainEvent<{
7
+ orgId: string;
8
+ id: string;
9
+ name: string;
10
+ description: string | null;
11
+ trigger: string;
12
+ actions: {
13
+ type: string;
14
+ input: Record<string, JsonValue>;
15
+ }[];
16
+ enabled: boolean;
17
+ createdAt: Date;
18
+ updatedAt: Date;
19
+ }, "automation.created", 1>, {
20
+ orgId: string;
21
+ id: string;
22
+ name: string;
23
+ description: string | null;
24
+ trigger: string;
25
+ actions: {
26
+ type: string;
27
+ input: Record<string, unknown>;
28
+ }[];
29
+ enabled: boolean;
30
+ createdAt: unknown;
31
+ updatedAt: unknown;
32
+ }>;
33
+ automationUpdated: RuntimeEventDefinition<VersionedDomainEvent<{
34
+ orgId: string;
35
+ id: string;
36
+ name: string;
37
+ description: string | null;
38
+ trigger: string;
39
+ actions: {
40
+ type: string;
41
+ input: Record<string, JsonValue>;
42
+ }[];
43
+ enabled: boolean;
44
+ createdAt: Date;
45
+ updatedAt: Date;
46
+ }, "automation.updated", 1>, {
47
+ orgId: string;
48
+ id: string;
49
+ name: string;
50
+ description: string | null;
51
+ trigger: string;
52
+ actions: {
53
+ type: string;
54
+ input: Record<string, unknown>;
55
+ }[];
56
+ enabled: boolean;
57
+ createdAt: unknown;
58
+ updatedAt: unknown;
59
+ }>;
60
+ automationDeleted: RuntimeEventDefinition<VersionedDomainEvent<{
61
+ orgId: string;
62
+ id: string;
63
+ name: string;
64
+ description: string | null;
65
+ trigger: string;
66
+ actions: {
67
+ type: string;
68
+ input: Record<string, JsonValue>;
69
+ }[];
70
+ enabled: boolean;
71
+ createdAt: Date;
72
+ updatedAt: Date;
73
+ }, "automation.deleted", 1>, {
74
+ orgId: string;
75
+ id: string;
76
+ name: string;
77
+ description: string | null;
78
+ trigger: string;
79
+ actions: {
80
+ type: string;
81
+ input: Record<string, unknown>;
82
+ }[];
83
+ enabled: boolean;
84
+ createdAt: unknown;
85
+ updatedAt: unknown;
86
+ }>;
87
+ automationEnabled: RuntimeEventDefinition<VersionedDomainEvent<{
88
+ orgId: string;
89
+ id: string;
90
+ name: string;
91
+ description: string | null;
92
+ trigger: string;
93
+ actions: {
94
+ type: string;
95
+ input: Record<string, JsonValue>;
96
+ }[];
97
+ enabled: boolean;
98
+ createdAt: Date;
99
+ updatedAt: Date;
100
+ }, "automation.enabled", 1>, {
101
+ orgId: string;
102
+ id: string;
103
+ name: string;
104
+ description: string | null;
105
+ trigger: string;
106
+ actions: {
107
+ type: string;
108
+ input: Record<string, unknown>;
109
+ }[];
110
+ enabled: boolean;
111
+ createdAt: unknown;
112
+ updatedAt: unknown;
113
+ }>;
114
+ automationDisabled: RuntimeEventDefinition<VersionedDomainEvent<{
115
+ orgId: string;
116
+ id: string;
117
+ name: string;
118
+ description: string | null;
119
+ trigger: string;
120
+ actions: {
121
+ type: string;
122
+ input: Record<string, JsonValue>;
123
+ }[];
124
+ enabled: boolean;
125
+ createdAt: Date;
126
+ updatedAt: Date;
127
+ }, "automation.disabled", 1>, {
128
+ orgId: string;
129
+ id: string;
130
+ name: string;
131
+ description: string | null;
132
+ trigger: string;
133
+ actions: {
134
+ type: string;
135
+ input: Record<string, unknown>;
136
+ }[];
137
+ enabled: boolean;
138
+ createdAt: unknown;
139
+ updatedAt: unknown;
140
+ }>;
141
+ runStarted: RuntimeEventDefinition<VersionedDomainEvent<{
142
+ orgId: string;
143
+ id: string;
144
+ automationId: string;
145
+ trigger: string;
146
+ eventId: string;
147
+ event: DomainEvent<unknown, string, number>;
148
+ status: "running" | "completed" | "failed";
149
+ actionResults: {
150
+ index: number;
151
+ type: string;
152
+ status: "completed" | "failed";
153
+ error?: string | undefined;
154
+ }[];
155
+ startedAt: Date;
156
+ finishedAt: Date | null;
157
+ }, "automation.run.started", 1>, {
158
+ orgId: string;
159
+ id: string;
160
+ automationId: string;
161
+ trigger: string;
162
+ eventId: string;
163
+ event: unknown;
164
+ status: "running" | "completed" | "failed";
165
+ actionResults: {
166
+ index: number;
167
+ type: string;
168
+ status: "completed" | "failed";
169
+ error?: string | undefined;
170
+ }[];
171
+ startedAt: unknown;
172
+ finishedAt: unknown;
173
+ }>;
174
+ runCompleted: RuntimeEventDefinition<VersionedDomainEvent<{
175
+ orgId: string;
176
+ id: string;
177
+ automationId: string;
178
+ trigger: string;
179
+ eventId: string;
180
+ event: DomainEvent<unknown, string, number>;
181
+ status: "running" | "completed" | "failed";
182
+ actionResults: {
183
+ index: number;
184
+ type: string;
185
+ status: "completed" | "failed";
186
+ error?: string | undefined;
187
+ }[];
188
+ startedAt: Date;
189
+ finishedAt: Date | null;
190
+ }, "automation.run.completed", 1>, {
191
+ orgId: string;
192
+ id: string;
193
+ automationId: string;
194
+ trigger: string;
195
+ eventId: string;
196
+ event: unknown;
197
+ status: "running" | "completed" | "failed";
198
+ actionResults: {
199
+ index: number;
200
+ type: string;
201
+ status: "completed" | "failed";
202
+ error?: string | undefined;
203
+ }[];
204
+ startedAt: unknown;
205
+ finishedAt: unknown;
206
+ }>;
207
+ runFailed: RuntimeEventDefinition<VersionedDomainEvent<{
208
+ orgId: string;
209
+ id: string;
210
+ automationId: string;
211
+ trigger: string;
212
+ eventId: string;
213
+ event: DomainEvent<unknown, string, number>;
214
+ status: "running" | "completed" | "failed";
215
+ actionResults: {
216
+ index: number;
217
+ type: string;
218
+ status: "completed" | "failed";
219
+ error?: string | undefined;
220
+ }[];
221
+ startedAt: Date;
222
+ finishedAt: Date | null;
223
+ }, "automation.run.failed", 1>, {
224
+ orgId: string;
225
+ id: string;
226
+ automationId: string;
227
+ trigger: string;
228
+ eventId: string;
229
+ event: unknown;
230
+ status: "running" | "completed" | "failed";
231
+ actionResults: {
232
+ index: number;
233
+ type: string;
234
+ status: "completed" | "failed";
235
+ error?: string | undefined;
236
+ }[];
237
+ startedAt: unknown;
238
+ finishedAt: unknown;
239
+ }>;
240
+ actionFailed: RuntimeEventDefinition<VersionedDomainEvent<{
241
+ index: number;
242
+ type: string;
243
+ status: "completed" | "failed";
244
+ error?: string | undefined;
245
+ }, "automation.action.failed", 1>, {
246
+ index: number;
247
+ type: string;
248
+ status: "completed" | "failed";
249
+ error?: string | undefined;
250
+ }>;
251
+ };
252
+ type AutomationCreated = EventOf<typeof automationEvents.automationCreated>;
253
+ type AutomationUpdated = EventOf<typeof automationEvents.automationUpdated>;
254
+ type AutomationDeleted = EventOf<typeof automationEvents.automationDeleted>;
255
+ type AutomationEnabled = EventOf<typeof automationEvents.automationEnabled>;
256
+ type AutomationDisabled = EventOf<typeof automationEvents.automationDisabled>;
257
+ type AutomationRunStarted = EventOf<typeof automationEvents.runStarted>;
258
+ type AutomationRunCompleted = EventOf<typeof automationEvents.runCompleted>;
259
+ type AutomationRunFailed = EventOf<typeof automationEvents.runFailed>;
260
+ type AutomationActionFailed = EventOf<typeof automationEvents.actionFailed>;
261
+ type AutomationEvent = EventOfValues<typeof automationEvents>;
262
+ //#endregion
263
+ export { AutomationActionFailed, AutomationCreated, AutomationDeleted, AutomationDisabled, AutomationEnabled, AutomationEvent, AutomationRunCompleted, AutomationRunFailed, AutomationRunStarted, AutomationUpdated, automationEvents };
264
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { automationActionResultSchema, automationRunSchema, automationSchema } from "../types/schemas/automations.js";
2
+ import { defineEvent } from "../shared/events.js";
3
+ //#region src/automations/events.ts
4
+ const automationEvents = {
5
+ automationCreated: defineEvent({
6
+ type: "automation.created",
7
+ version: 1,
8
+ data: automationSchema
9
+ }),
10
+ automationUpdated: defineEvent({
11
+ type: "automation.updated",
12
+ version: 1,
13
+ data: automationSchema
14
+ }),
15
+ automationDeleted: defineEvent({
16
+ type: "automation.deleted",
17
+ version: 1,
18
+ data: automationSchema
19
+ }),
20
+ automationEnabled: defineEvent({
21
+ type: "automation.enabled",
22
+ version: 1,
23
+ data: automationSchema
24
+ }),
25
+ automationDisabled: defineEvent({
26
+ type: "automation.disabled",
27
+ version: 1,
28
+ data: automationSchema
29
+ }),
30
+ runStarted: defineEvent({
31
+ type: "automation.run.started",
32
+ version: 1,
33
+ data: automationRunSchema
34
+ }),
35
+ runCompleted: defineEvent({
36
+ type: "automation.run.completed",
37
+ version: 1,
38
+ data: automationRunSchema
39
+ }),
40
+ runFailed: defineEvent({
41
+ type: "automation.run.failed",
42
+ version: 1,
43
+ data: automationRunSchema
44
+ }),
45
+ actionFailed: defineEvent({
46
+ type: "automation.action.failed",
47
+ version: 1,
48
+ data: automationActionResultSchema
49
+ })
50
+ };
51
+ //#endregion
52
+ export { automationEvents };
53
+
54
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","names":[],"sources":["../../src/automations/events.ts"],"sourcesContent":["import {\n automationActionResultSchema,\n automationRunSchema,\n automationSchema,\n} from '../types/schemas/index.js';\nimport { defineEvent, type EventOf, type EventOfValues } from '../shared/ports.js';\n\nexport const automationEvents = {\n automationCreated: defineEvent({\n type: 'automation.created',\n version: 1,\n data: automationSchema,\n }),\n automationUpdated: defineEvent({\n type: 'automation.updated',\n version: 1,\n data: automationSchema,\n }),\n automationDeleted: defineEvent({\n type: 'automation.deleted',\n version: 1,\n data: automationSchema,\n }),\n automationEnabled: defineEvent({\n type: 'automation.enabled',\n version: 1,\n data: automationSchema,\n }),\n automationDisabled: defineEvent({\n type: 'automation.disabled',\n version: 1,\n data: automationSchema,\n }),\n runStarted: defineEvent({\n type: 'automation.run.started',\n version: 1,\n data: automationRunSchema,\n }),\n runCompleted: defineEvent({\n type: 'automation.run.completed',\n version: 1,\n data: automationRunSchema,\n }),\n runFailed: defineEvent({\n type: 'automation.run.failed',\n version: 1,\n data: automationRunSchema,\n }),\n actionFailed: defineEvent({\n type: 'automation.action.failed',\n version: 1,\n data: automationActionResultSchema,\n }),\n};\n\nexport type AutomationCreated = EventOf<typeof automationEvents.automationCreated>;\nexport type AutomationUpdated = EventOf<typeof automationEvents.automationUpdated>;\nexport type AutomationDeleted = EventOf<typeof automationEvents.automationDeleted>;\nexport type AutomationEnabled = EventOf<typeof automationEvents.automationEnabled>;\nexport type AutomationDisabled = EventOf<typeof automationEvents.automationDisabled>;\nexport type AutomationRunStarted = EventOf<typeof automationEvents.runStarted>;\nexport type AutomationRunCompleted = EventOf<typeof automationEvents.runCompleted>;\nexport type AutomationRunFailed = EventOf<typeof automationEvents.runFailed>;\nexport type AutomationActionFailed = EventOf<typeof automationEvents.actionFailed>;\nexport type AutomationEvent = EventOfValues<typeof automationEvents>;\n"],"mappings":";;;AAOA,MAAa,mBAAmB;CAC9B,mBAAmB,YAAY;EAC7B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,mBAAmB,YAAY;EAC7B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,mBAAmB,YAAY;EAC7B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,mBAAmB,YAAY;EAC7B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,oBAAoB,YAAY;EAC9B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,YAAY,YAAY;EACtB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,cAAc,YAAY;EACxB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,WAAW,YAAY;EACrB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,cAAc,YAAY;EACxB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;AACH"}
@@ -0,0 +1,9 @@
1
+ import { Page } from "../types/shared.js";
2
+ import { Automation, AutomationAction, AutomationActionResult, AutomationRun, AutomationRunStatus, AutomationRunsQuery, AutomationTrigger, AvailableAction, AvailableActions, AvailableTriggers, CreateAutomationInput, UpdateAutomationInput } from "../types/schemas/automations.js";
3
+ import { AutomationDispatch, AutomationEngine, AutomationExecutor } from "../types/automations.js";
4
+ import { InvalidTriggerError } from "./model.js";
5
+ import "./types.js";
6
+ import { AutomationActionFailed, AutomationCreated, AutomationDeleted, AutomationDisabled, AutomationEnabled, AutomationEvent, AutomationRunCompleted, AutomationRunFailed, AutomationRunStarted, AutomationUpdated, automationEvents } from "./events.js";
7
+ import { AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsUnitOfWork, NewAutomationRun } from "./ports.js";
8
+ import { AutomationsServiceImpl } from "./service.js";
9
+ export { type Automation, type AutomationAction, type AutomationActionFailed, type AutomationActionResult, type AutomationCreated, type AutomationDeleted, type AutomationDisabled, type AutomationDispatch, type AutomationEnabled, type AutomationEngine, type AutomationEvent, type AutomationExecutor, type AutomationRun, type AutomationRunCompleted, type AutomationRunFailed, type AutomationRunStarted, type AutomationRunStatus, type AutomationRunsQuery, type AutomationRunsRepository, type AutomationTrigger, type AutomationUpdated, type AutomationsRepository, type AutomationsService, AutomationsServiceImpl, type AutomationsUnitOfWork, type AvailableAction, type AvailableActions, type AvailableTriggers, type CreateAutomationInput, InvalidTriggerError, type NewAutomationRun, type Page, type UpdateAutomationInput, automationEvents };
@@ -0,0 +1,4 @@
1
+ import { automationEvents } from "./events.js";
2
+ import { InvalidTriggerError } from "./model.js";
3
+ import { AutomationsServiceImpl } from "./service.js";
4
+ export { AutomationsServiceImpl, InvalidTriggerError, automationEvents };
@@ -0,0 +1,12 @@
1
+ import { Page } from "../types/shared.js";
2
+ import { Automation, AutomationAction, AutomationActionResult, AutomationRun, AutomationRunStatus, AutomationTrigger } from "../types/schemas/automations.js";
3
+ import "../types/index.js";
4
+ //#region src/automations/model.d.ts
5
+ /** Rejected at authoring time: automation.* is reserved to avoid a self-triggering loop. */
6
+ declare class InvalidTriggerError extends Error {
7
+ readonly trigger: string;
8
+ constructor(trigger: string);
9
+ }
10
+ //#endregion
11
+ export { type Automation, type AutomationAction, type AutomationActionResult, type AutomationRun, type AutomationRunStatus, type AutomationTrigger, InvalidTriggerError, type Page };
12
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1,14 @@
1
+ //#region src/automations/model.ts
2
+ /** Rejected at authoring time: automation.* is reserved to avoid a self-triggering loop. */
3
+ var InvalidTriggerError = class extends Error {
4
+ trigger;
5
+ constructor(trigger) {
6
+ super(`trigger "${trigger}" is reserved: automations cannot trigger on automation.* events`);
7
+ this.trigger = trigger;
8
+ this.name = "InvalidTriggerError";
9
+ }
10
+ };
11
+ //#endregion
12
+ export { InvalidTriggerError };
13
+
14
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":[],"sources":["../../src/automations/model.ts"],"sourcesContent":["// automations context — domain entities, owned by @headless-lms/core/types; the\n// domain error below is runtime code and stays in core.\nexport type {\n AutomationTrigger,\n AutomationAction,\n Automation,\n AutomationRunStatus,\n AutomationActionResult,\n AutomationRun,\n Page,\n} from '../types/index.js';\n\n/** Rejected at authoring time: automation.* is reserved to avoid a self-triggering loop. */\nexport class InvalidTriggerError extends Error {\n constructor(readonly trigger: string) {\n super(`trigger \"${trigger}\" is reserved: automations cannot trigger on automation.* events`);\n this.name = 'InvalidTriggerError';\n }\n}\n"],"mappings":";;AAaA,IAAa,sBAAb,cAAyC,MAAM;CACxB;CAArB,YAAY,SAA0B;EACpC,MAAM,YAAY,QAAQ,iEAAiE;EADxE,KAAA,UAAA;EAEnB,KAAK,OAAO;CACd;AACF"}
@@ -0,0 +1,56 @@
1
+ import { DomainEvent, Page } from "../types/shared.js";
2
+ import { Automation, AutomationRun, AutomationRunsQuery, AvailableActions, AvailableTriggers, CreateAutomationInput, UpdateAutomationInput } from "../types/schemas/automations.js";
3
+ import { AutomationDispatch, AutomationEngine, AutomationExecutor } from "../types/automations.js";
4
+ import "../types/index.js";
5
+ import { OutboxAppender, UnitOfWork } from "../shared/ports.js";
6
+ import "./model.js";
7
+ import "./types.js";
8
+ //#region src/automations/ports.d.ts
9
+ /** A run row before persistence assigns its id and event_id. */
10
+ type NewAutomationRun = Omit<AutomationRun, 'id' | 'eventId'>;
11
+ interface AutomationsService {
12
+ /** Matches `event` against enabled automations and dispatches a run per match; never throws. */
13
+ handle(event: DomainEvent): Promise<void>;
14
+ /** Built-in action types plus every loaded integration's declared actions. */
15
+ availableActions(): AvailableActions;
16
+ /** The domain event types an automation may react to. */
17
+ availableTriggers(): AvailableTriggers;
18
+ list(orgId: string): Promise<Automation[]>;
19
+ get(orgId: string, id: string): Promise<Automation | null>;
20
+ create(orgId: string, input: CreateAutomationInput): Promise<Automation>;
21
+ update(orgId: string, id: string, input: UpdateAutomationInput): Promise<Automation | null>;
22
+ delete(orgId: string, id: string): Promise<boolean>;
23
+ listRuns(orgId: string, automationId: string, query: AutomationRunsQuery): Promise<Page<AutomationRun>>;
24
+ }
25
+ interface AutomationsRepository {
26
+ insert(orgId: string, input: CreateAutomationInput): Promise<Automation>;
27
+ update(orgId: string, id: string, patch: UpdateAutomationInput): Promise<Automation | null>;
28
+ /** Returns the deleted row (the event snapshot), or null if it didn't exist. */
29
+ delete(orgId: string, id: string): Promise<Automation | null>;
30
+ findById(orgId: string, id: string): Promise<Automation | null>;
31
+ listByOrg(orgId: string): Promise<Automation[]>;
32
+ /** All rows matching `trigger`, enabled and disabled alike — the service filters to `enabled`. */
33
+ listByTrigger(orgId: string, trigger: string): Promise<Automation[]>;
34
+ }
35
+ interface AutomationRunsRepository {
36
+ /** Keyed by (orgId, automationId, event.id); returns `null` if this event was already run for this automation (duplicate). */
37
+ insert(orgId: string, run: NewAutomationRun): Promise<AutomationRun | null>;
38
+ recordOutcome(orgId: string, id: string, outcome: {
39
+ status: AutomationRun['status'];
40
+ actionResults: AutomationRun['actionResults'];
41
+ finishedAt: Date;
42
+ }): Promise<AutomationRun | null>;
43
+ list(orgId: string, automationId: string, query: AutomationRunsQuery): Promise<Page<AutomationRun>>;
44
+ }
45
+ /** Tx-scoped port bundle for this context's mutating use cases — every member
46
+ * is bound to the UnitOfWork's transaction, so the write(s) and the event
47
+ * append commit or roll back as one. */
48
+ interface AutomationsTxScope {
49
+ automations: AutomationsRepository;
50
+ runs: AutomationRunsRepository;
51
+ outbox: OutboxAppender;
52
+ }
53
+ type AutomationsUnitOfWork = UnitOfWork<AutomationsTxScope>;
54
+ //#endregion
55
+ export { type AutomationDispatch, type AutomationEngine, type AutomationExecutor, AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsTxScope, AutomationsUnitOfWork, NewAutomationRun };
56
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ export {};