@headless-lms/core 0.1.0 → 0.2.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 (154) hide show
  1. package/dist/assets/events.d.ts +66 -3
  2. package/dist/assets/events.js +19 -3
  3. package/dist/assets/events.js.map +1 -1
  4. package/dist/assets/service.js +5 -3
  5. package/dist/assets/service.js.map +1 -1
  6. package/dist/automations/actions.d.ts +11 -3
  7. package/dist/automations/actions.js +38 -5
  8. package/dist/automations/actions.js.map +1 -1
  9. package/dist/automations/catalog.d.ts +4 -1
  10. package/dist/automations/catalog.js +289 -188
  11. package/dist/automations/catalog.js.map +1 -1
  12. package/dist/automations/events.d.ts +46 -24
  13. package/dist/automations/events.js +5 -5
  14. package/dist/automations/events.js.map +1 -1
  15. package/dist/automations/index.d.ts +5 -5
  16. package/dist/automations/index.js +2 -2
  17. package/dist/automations/model.d.ts +13 -3
  18. package/dist/automations/model.js +23 -3
  19. package/dist/automations/model.js.map +1 -1
  20. package/dist/automations/ports.d.ts +23 -8
  21. package/dist/automations/service.d.ts +21 -5
  22. package/dist/automations/service.js +267 -47
  23. package/dist/automations/service.js.map +1 -1
  24. package/dist/automations/types.d.ts +2 -2
  25. package/dist/automations/webhook-signing.d.ts +7 -0
  26. package/dist/automations/webhook-signing.js +22 -0
  27. package/dist/automations/webhook-signing.js.map +1 -0
  28. package/dist/content/events.d.ts +401 -25
  29. package/dist/content/events.js +125 -19
  30. package/dist/content/events.js.map +1 -1
  31. package/dist/content/index.d.ts +5 -5
  32. package/dist/content/index.js +2 -2
  33. package/dist/content/model.d.ts +2 -2
  34. package/dist/content/ports.d.ts +42 -11
  35. package/dist/content/service.d.ts +15 -9
  36. package/dist/content/service.js +153 -45
  37. package/dist/content/service.js.map +1 -1
  38. package/dist/content/types.d.ts +2 -2
  39. package/dist/discussion/events.d.ts +60 -4
  40. package/dist/discussion/events.js +30 -4
  41. package/dist/discussion/events.js.map +1 -1
  42. package/dist/discussion/model.d.ts +1 -2
  43. package/dist/discussion/ports.d.ts +1 -1
  44. package/dist/discussion/service.d.ts +1 -1
  45. package/dist/discussion/service.js +11 -10
  46. package/dist/discussion/service.js.map +1 -1
  47. package/dist/entitlements/events.d.ts +96 -12
  48. package/dist/entitlements/events.js +21 -4
  49. package/dist/entitlements/events.js.map +1 -1
  50. package/dist/entitlements/service.js +1 -0
  51. package/dist/entitlements/service.js.map +1 -1
  52. package/dist/identity/events.d.ts +17 -3
  53. package/dist/identity/events.js +12 -2
  54. package/dist/identity/events.js.map +1 -1
  55. package/dist/identity/ports.d.ts +3 -0
  56. package/dist/identity/service.d.ts +3 -0
  57. package/dist/identity/service.js +12 -1
  58. package/dist/identity/service.js.map +1 -1
  59. package/dist/integrations/events.d.ts +27 -3
  60. package/dist/integrations/events.js +15 -3
  61. package/dist/integrations/events.js.map +1 -1
  62. package/dist/integrations/service.js +1 -1
  63. package/dist/integrations/service.js.map +1 -1
  64. package/dist/organizations/events.d.ts +178 -11
  65. package/dist/organizations/events.js +52 -9
  66. package/dist/organizations/events.js.map +1 -1
  67. package/dist/organizations/index.d.ts +3 -3
  68. package/dist/organizations/members.js.map +1 -1
  69. package/dist/organizations/ports.d.ts +6 -10
  70. package/dist/organizations/roles.js.map +1 -1
  71. package/dist/organizations/service.d.ts +9 -4
  72. package/dist/organizations/service.js +131 -72
  73. package/dist/organizations/service.js.map +1 -1
  74. package/dist/organizations/types.d.ts +2 -2
  75. package/dist/progress/events.d.ts +34 -2
  76. package/dist/progress/events.js +15 -2
  77. package/dist/progress/events.js.map +1 -1
  78. package/dist/progress/service.d.ts +2 -2
  79. package/dist/progress/service.js +4 -2
  80. package/dist/progress/service.js.map +1 -1
  81. package/dist/reporting/courses/index.d.ts +4 -0
  82. package/dist/reporting/courses/index.js +2 -0
  83. package/dist/reporting/courses/model.d.ts +24 -0
  84. package/dist/reporting/courses/model.js +1 -0
  85. package/dist/reporting/courses/ports.d.ts +13 -0
  86. package/dist/reporting/courses/ports.js +1 -0
  87. package/dist/reporting/courses/service.d.ts +19 -0
  88. package/dist/reporting/courses/service.js +20 -0
  89. package/dist/reporting/courses/service.js.map +1 -0
  90. package/dist/reporting/learn/model.d.ts +2 -2
  91. package/dist/reporting/learn/ports.d.ts +2 -1
  92. package/dist/reporting/learn/service.d.ts +2 -1
  93. package/dist/reporting/learn/service.js +5 -0
  94. package/dist/reporting/learn/service.js.map +1 -1
  95. package/dist/reporting/students/index.d.ts +2 -2
  96. package/dist/reporting/students/model.d.ts +21 -1
  97. package/dist/reporting/students/ports.d.ts +3 -1
  98. package/dist/reporting/students/service.d.ts +2 -1
  99. package/dist/reporting/students/service.js +3 -0
  100. package/dist/reporting/students/service.js.map +1 -1
  101. package/dist/shared/events.d.ts +5 -3
  102. package/dist/shared/events.js +1 -0
  103. package/dist/shared/events.js.map +1 -1
  104. package/dist/shared/id.d.ts +1 -0
  105. package/dist/shared/id.js +1 -0
  106. package/dist/shared/id.js.map +1 -1
  107. package/dist/shared/mailer.d.ts +2 -0
  108. package/dist/shared/mailer.js.map +1 -1
  109. package/dist/shared/settings.js.map +1 -1
  110. package/dist/types/automations.d.ts +13 -2
  111. package/dist/types/content.d.ts +2 -2
  112. package/dist/types/discussion.d.ts +3 -2
  113. package/dist/types/email-templates.d.ts +3 -1
  114. package/dist/types/events.d.ts +3 -3
  115. package/dist/types/index.d.ts +6 -6
  116. package/dist/types/organizations.d.ts +2 -2
  117. package/dist/types/ports.d.ts +1 -1
  118. package/dist/types/schemas/assets.d.ts +3 -0
  119. package/dist/types/schemas/assets.js +2 -1
  120. package/dist/types/schemas/assets.js.map +1 -1
  121. package/dist/types/schemas/automations.d.ts +71 -4
  122. package/dist/types/schemas/automations.js +35 -4
  123. package/dist/types/schemas/automations.js.map +1 -1
  124. package/dist/types/schemas/content.d.ts +51 -18
  125. package/dist/types/schemas/content.js +40 -13
  126. package/dist/types/schemas/content.js.map +1 -1
  127. package/dist/types/schemas/credentials.js.map +1 -1
  128. package/dist/types/schemas/discussion.d.ts +10 -2
  129. package/dist/types/schemas/discussion.js +12 -5
  130. package/dist/types/schemas/discussion.js.map +1 -1
  131. package/dist/types/schemas/entitlements.d.ts +8 -2
  132. package/dist/types/schemas/entitlements.js +10 -4
  133. package/dist/types/schemas/entitlements.js.map +1 -1
  134. package/dist/types/schemas/identity.d.ts +4 -4
  135. package/dist/types/schemas/identity.js +5 -5
  136. package/dist/types/schemas/identity.js.map +1 -1
  137. package/dist/types/schemas/index.d.ts +6 -6
  138. package/dist/types/schemas/index.js +6 -6
  139. package/dist/types/schemas/integrations.js.map +1 -1
  140. package/dist/types/schemas/organizations.d.ts +19 -5
  141. package/dist/types/schemas/organizations.js +12 -7
  142. package/dist/types/schemas/organizations.js.map +1 -1
  143. package/dist/types/schemas/outbox.d.ts +1 -0
  144. package/dist/types/schemas/outbox.js +1 -0
  145. package/dist/types/schemas/outbox.js.map +1 -1
  146. package/dist/types/schemas/progress.d.ts +1 -0
  147. package/dist/types/schemas/progress.js +1 -0
  148. package/dist/types/schemas/progress.js.map +1 -1
  149. package/dist/types/schemas/settings.js.map +1 -1
  150. package/dist/types/schemas/shared.d.ts +2 -1
  151. package/dist/types/schemas/shared.js +3 -1
  152. package/dist/types/schemas/shared.js.map +1 -1
  153. package/dist/types/shared.d.ts +1 -1
  154. package/package.json +1 -1
@@ -7,8 +7,9 @@ declare const automationEvents: {
7
7
  orgId: string;
8
8
  id: string;
9
9
  name: string;
10
+ kind: "workflow" | "webhook";
10
11
  description: string | null;
11
- trigger: string;
12
+ triggers: string[];
12
13
  actions: {
13
14
  type: string;
14
15
  input: Record<string, JsonValue>;
@@ -16,12 +17,13 @@ declare const automationEvents: {
16
17
  enabled: boolean;
17
18
  createdAt: Date;
18
19
  updatedAt: Date;
19
- }, "automation.created", 1>, {
20
+ }, "automation.created", 2>, {
20
21
  orgId: string;
21
22
  id: string;
22
23
  name: string;
24
+ kind: "workflow" | "webhook";
23
25
  description: string | null;
24
- trigger: string;
26
+ triggers: string[];
25
27
  actions: {
26
28
  type: string;
27
29
  input: Record<string, unknown>;
@@ -29,13 +31,14 @@ declare const automationEvents: {
29
31
  enabled: boolean;
30
32
  createdAt: unknown;
31
33
  updatedAt: unknown;
32
- }>;
34
+ }, undefined>;
33
35
  automationUpdated: RuntimeEventDefinition<VersionedDomainEvent<{
34
36
  orgId: string;
35
37
  id: string;
36
38
  name: string;
39
+ kind: "workflow" | "webhook";
37
40
  description: string | null;
38
- trigger: string;
41
+ triggers: string[];
39
42
  actions: {
40
43
  type: string;
41
44
  input: Record<string, JsonValue>;
@@ -43,12 +46,13 @@ declare const automationEvents: {
43
46
  enabled: boolean;
44
47
  createdAt: Date;
45
48
  updatedAt: Date;
46
- }, "automation.updated", 1>, {
49
+ }, "automation.updated", 2>, {
47
50
  orgId: string;
48
51
  id: string;
49
52
  name: string;
53
+ kind: "workflow" | "webhook";
50
54
  description: string | null;
51
- trigger: string;
55
+ triggers: string[];
52
56
  actions: {
53
57
  type: string;
54
58
  input: Record<string, unknown>;
@@ -56,13 +60,14 @@ declare const automationEvents: {
56
60
  enabled: boolean;
57
61
  createdAt: unknown;
58
62
  updatedAt: unknown;
59
- }>;
63
+ }, undefined>;
60
64
  automationDeleted: RuntimeEventDefinition<VersionedDomainEvent<{
61
65
  orgId: string;
62
66
  id: string;
63
67
  name: string;
68
+ kind: "workflow" | "webhook";
64
69
  description: string | null;
65
- trigger: string;
70
+ triggers: string[];
66
71
  actions: {
67
72
  type: string;
68
73
  input: Record<string, JsonValue>;
@@ -70,12 +75,13 @@ declare const automationEvents: {
70
75
  enabled: boolean;
71
76
  createdAt: Date;
72
77
  updatedAt: Date;
73
- }, "automation.deleted", 1>, {
78
+ }, "automation.deleted", 2>, {
74
79
  orgId: string;
75
80
  id: string;
76
81
  name: string;
82
+ kind: "workflow" | "webhook";
77
83
  description: string | null;
78
- trigger: string;
84
+ triggers: string[];
79
85
  actions: {
80
86
  type: string;
81
87
  input: Record<string, unknown>;
@@ -83,13 +89,14 @@ declare const automationEvents: {
83
89
  enabled: boolean;
84
90
  createdAt: unknown;
85
91
  updatedAt: unknown;
86
- }>;
92
+ }, undefined>;
87
93
  automationEnabled: RuntimeEventDefinition<VersionedDomainEvent<{
88
94
  orgId: string;
89
95
  id: string;
90
96
  name: string;
97
+ kind: "workflow" | "webhook";
91
98
  description: string | null;
92
- trigger: string;
99
+ triggers: string[];
93
100
  actions: {
94
101
  type: string;
95
102
  input: Record<string, JsonValue>;
@@ -97,12 +104,13 @@ declare const automationEvents: {
97
104
  enabled: boolean;
98
105
  createdAt: Date;
99
106
  updatedAt: Date;
100
- }, "automation.enabled", 1>, {
107
+ }, "automation.enabled", 2>, {
101
108
  orgId: string;
102
109
  id: string;
103
110
  name: string;
111
+ kind: "workflow" | "webhook";
104
112
  description: string | null;
105
- trigger: string;
113
+ triggers: string[];
106
114
  actions: {
107
115
  type: string;
108
116
  input: Record<string, unknown>;
@@ -110,13 +118,14 @@ declare const automationEvents: {
110
118
  enabled: boolean;
111
119
  createdAt: unknown;
112
120
  updatedAt: unknown;
113
- }>;
121
+ }, undefined>;
114
122
  automationDisabled: RuntimeEventDefinition<VersionedDomainEvent<{
115
123
  orgId: string;
116
124
  id: string;
117
125
  name: string;
126
+ kind: "workflow" | "webhook";
118
127
  description: string | null;
119
- trigger: string;
128
+ triggers: string[];
120
129
  actions: {
121
130
  type: string;
122
131
  input: Record<string, JsonValue>;
@@ -124,12 +133,13 @@ declare const automationEvents: {
124
133
  enabled: boolean;
125
134
  createdAt: Date;
126
135
  updatedAt: Date;
127
- }, "automation.disabled", 1>, {
136
+ }, "automation.disabled", 2>, {
128
137
  orgId: string;
129
138
  id: string;
130
139
  name: string;
140
+ kind: "workflow" | "webhook";
131
141
  description: string | null;
132
- trigger: string;
142
+ triggers: string[];
133
143
  actions: {
134
144
  type: string;
135
145
  input: Record<string, unknown>;
@@ -137,7 +147,7 @@ declare const automationEvents: {
137
147
  enabled: boolean;
138
148
  createdAt: unknown;
139
149
  updatedAt: unknown;
140
- }>;
150
+ }, undefined>;
141
151
  runStarted: RuntimeEventDefinition<VersionedDomainEvent<{
142
152
  orgId: string;
143
153
  id: string;
@@ -154,6 +164,8 @@ declare const automationEvents: {
154
164
  }[];
155
165
  startedAt: Date;
156
166
  finishedAt: Date | null;
167
+ createdAt: Date;
168
+ updatedAt: Date;
157
169
  }, "automation.run.started", 1>, {
158
170
  orgId: string;
159
171
  id: string;
@@ -170,7 +182,9 @@ declare const automationEvents: {
170
182
  }[];
171
183
  startedAt: unknown;
172
184
  finishedAt: unknown;
173
- }>;
185
+ createdAt: unknown;
186
+ updatedAt: unknown;
187
+ }, undefined>;
174
188
  runCompleted: RuntimeEventDefinition<VersionedDomainEvent<{
175
189
  orgId: string;
176
190
  id: string;
@@ -187,6 +201,8 @@ declare const automationEvents: {
187
201
  }[];
188
202
  startedAt: Date;
189
203
  finishedAt: Date | null;
204
+ createdAt: Date;
205
+ updatedAt: Date;
190
206
  }, "automation.run.completed", 1>, {
191
207
  orgId: string;
192
208
  id: string;
@@ -203,7 +219,9 @@ declare const automationEvents: {
203
219
  }[];
204
220
  startedAt: unknown;
205
221
  finishedAt: unknown;
206
- }>;
222
+ createdAt: unknown;
223
+ updatedAt: unknown;
224
+ }, undefined>;
207
225
  runFailed: RuntimeEventDefinition<VersionedDomainEvent<{
208
226
  orgId: string;
209
227
  id: string;
@@ -220,6 +238,8 @@ declare const automationEvents: {
220
238
  }[];
221
239
  startedAt: Date;
222
240
  finishedAt: Date | null;
241
+ createdAt: Date;
242
+ updatedAt: Date;
223
243
  }, "automation.run.failed", 1>, {
224
244
  orgId: string;
225
245
  id: string;
@@ -236,7 +256,9 @@ declare const automationEvents: {
236
256
  }[];
237
257
  startedAt: unknown;
238
258
  finishedAt: unknown;
239
- }>;
259
+ createdAt: unknown;
260
+ updatedAt: unknown;
261
+ }, undefined>;
240
262
  actionFailed: RuntimeEventDefinition<VersionedDomainEvent<{
241
263
  index: number;
242
264
  type: string;
@@ -247,7 +269,7 @@ declare const automationEvents: {
247
269
  type: string;
248
270
  status: "completed" | "failed";
249
271
  error?: string | undefined;
250
- }>;
272
+ }, undefined>;
251
273
  };
252
274
  type AutomationCreated = EventOf<typeof automationEvents.automationCreated>;
253
275
  type AutomationUpdated = EventOf<typeof automationEvents.automationUpdated>;
@@ -4,27 +4,27 @@ import { defineEvent } from "../shared/events.js";
4
4
  const automationEvents = {
5
5
  automationCreated: defineEvent({
6
6
  type: "automation.created",
7
- version: 1,
7
+ version: 2,
8
8
  data: automationSchema
9
9
  }),
10
10
  automationUpdated: defineEvent({
11
11
  type: "automation.updated",
12
- version: 1,
12
+ version: 2,
13
13
  data: automationSchema
14
14
  }),
15
15
  automationDeleted: defineEvent({
16
16
  type: "automation.deleted",
17
- version: 1,
17
+ version: 2,
18
18
  data: automationSchema
19
19
  }),
20
20
  automationEnabled: defineEvent({
21
21
  type: "automation.enabled",
22
- version: 1,
22
+ version: 2,
23
23
  data: automationSchema
24
24
  }),
25
25
  automationDisabled: defineEvent({
26
26
  type: "automation.disabled",
27
- version: 1,
27
+ version: 2,
28
28
  data: automationSchema
29
29
  }),
30
30
  runStarted: defineEvent({
@@ -1 +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"}
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: 2,\n data: automationSchema,\n }),\n automationUpdated: defineEvent({\n type: 'automation.updated',\n version: 2,\n data: automationSchema,\n }),\n automationDeleted: defineEvent({\n type: 'automation.deleted',\n version: 2,\n data: automationSchema,\n }),\n automationEnabled: defineEvent({\n type: 'automation.enabled',\n version: 2,\n data: automationSchema,\n }),\n automationDisabled: defineEvent({\n type: 'automation.disabled',\n version: 2,\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"}
@@ -1,9 +1,9 @@
1
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";
2
+ import { Automation, AutomationAction, AutomationActionResult, AutomationKind, AutomationRun, AutomationRunStatus, AutomationRunsQuery, AutomationTrigger, AutomationsQuery, AvailableAction, AvailableActions, AvailableTriggers, CreateAutomationInput, CreateWebhookInput, CreatedWebhook, UpdateAutomationInput, UpdateWebhookInput, Webhook, WebhookSecret } from "../types/schemas/automations.js";
3
+ import { AutomationDispatch, AutomationEngine, AutomationExecutor, WebhookRequest, WebhookResponse, WebhookSender } from "../types/automations.js";
4
+ import { AutomationKindMismatchError, InvalidTriggerError, ReservedActionError } from "./model.js";
5
5
  import "./types.js";
6
+ import { AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsUnitOfWork, NewAutomation, NewAutomationRun } from "./ports.js";
6
7
  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
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 };
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 AutomationKind, AutomationKindMismatchError, type AutomationRun, type AutomationRunCompleted, type AutomationRunFailed, type AutomationRunStarted, type AutomationRunStatus, type AutomationRunsQuery, type AutomationRunsRepository, type AutomationTrigger, type AutomationUpdated, type AutomationsQuery, type AutomationsRepository, type AutomationsService, AutomationsServiceImpl, type AutomationsUnitOfWork, type AvailableAction, type AvailableActions, type AvailableTriggers, type CreateAutomationInput, type CreateWebhookInput, type CreatedWebhook, InvalidTriggerError, type NewAutomation, type NewAutomationRun, type Page, ReservedActionError, type UpdateAutomationInput, type UpdateWebhookInput, type Webhook, type WebhookRequest, type WebhookResponse, type WebhookSecret, type WebhookSender, automationEvents };
@@ -1,4 +1,4 @@
1
1
  import { automationEvents } from "./events.js";
2
- import { InvalidTriggerError } from "./model.js";
2
+ import { AutomationKindMismatchError, InvalidTriggerError, ReservedActionError } from "./model.js";
3
3
  import { AutomationsServiceImpl } from "./service.js";
4
- export { AutomationsServiceImpl, InvalidTriggerError, automationEvents };
4
+ export { AutomationKindMismatchError, AutomationsServiceImpl, InvalidTriggerError, ReservedActionError, automationEvents };
@@ -1,12 +1,22 @@
1
1
  import { Page } from "../types/shared.js";
2
- import { Automation, AutomationAction, AutomationActionResult, AutomationRun, AutomationRunStatus, AutomationTrigger } from "../types/schemas/automations.js";
2
+ import { Automation, AutomationAction, AutomationActionResult, AutomationKind, AutomationRun, AutomationRunStatus, AutomationTrigger, CreatedWebhook, DeliverWebhookInput, Webhook, WebhookSecret } from "../types/schemas/automations.js";
3
3
  import "../types/index.js";
4
4
  //#region src/automations/model.d.ts
5
5
  /** Rejected at authoring time: automation.* is reserved to avoid a self-triggering loop. */
6
6
  declare class InvalidTriggerError extends Error {
7
7
  readonly trigger: string;
8
- constructor(trigger: string);
8
+ readonly reason: 'reserved' | 'unknown';
9
+ constructor(trigger: string, reason?: 'reserved' | 'unknown');
10
+ }
11
+ declare class ReservedActionError extends Error {
12
+ readonly actionType: string;
13
+ constructor(actionType: string);
14
+ }
15
+ declare class AutomationKindMismatchError extends Error {
16
+ readonly automationId: string;
17
+ readonly kind: AutomationKind;
18
+ constructor(automationId: string, kind: AutomationKind);
9
19
  }
10
20
  //#endregion
11
- export { type Automation, type AutomationAction, type AutomationActionResult, type AutomationRun, type AutomationRunStatus, type AutomationTrigger, InvalidTriggerError, type Page };
21
+ export { type Automation, type AutomationAction, type AutomationActionResult, type AutomationKind, AutomationKindMismatchError, type AutomationRun, type AutomationRunStatus, type AutomationTrigger, type CreatedWebhook, type DeliverWebhookInput, InvalidTriggerError, type Page, ReservedActionError, type Webhook, type WebhookSecret };
12
22
  //# sourceMappingURL=model.d.ts.map
@@ -2,13 +2,33 @@
2
2
  /** Rejected at authoring time: automation.* is reserved to avoid a self-triggering loop. */
3
3
  var InvalidTriggerError = class extends Error {
4
4
  trigger;
5
- constructor(trigger) {
6
- super(`trigger "${trigger}" is reserved: automations cannot trigger on automation.* events`);
5
+ reason;
6
+ constructor(trigger, reason = "reserved") {
7
+ super(reason === "reserved" ? `trigger "${trigger}" is reserved: automations cannot trigger on automation.* events` : `trigger "${trigger}" is not an event the system emits`);
7
8
  this.trigger = trigger;
9
+ this.reason = reason;
8
10
  this.name = "InvalidTriggerError";
9
11
  }
10
12
  };
13
+ var ReservedActionError = class extends Error {
14
+ actionType;
15
+ constructor(actionType) {
16
+ super(`action "${actionType}" is reserved to webhooks`);
17
+ this.actionType = actionType;
18
+ this.name = "ReservedActionError";
19
+ }
20
+ };
21
+ var AutomationKindMismatchError = class extends Error {
22
+ automationId;
23
+ kind;
24
+ constructor(automationId, kind) {
25
+ super(`automation "${automationId}" is a ${kind} and can't be changed through this operation`);
26
+ this.automationId = automationId;
27
+ this.kind = kind;
28
+ this.name = "AutomationKindMismatchError";
29
+ }
30
+ };
11
31
  //#endregion
12
- export { InvalidTriggerError };
32
+ export { AutomationKindMismatchError, InvalidTriggerError, ReservedActionError };
13
33
 
14
34
  //# sourceMappingURL=model.js.map
@@ -1 +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"}
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 errors below are runtime code and stay in core.\nimport type { AutomationKind } from '../types/index.js';\n\nexport type {\n AutomationTrigger,\n AutomationAction,\n AutomationKind,\n Automation,\n AutomationRunStatus,\n AutomationActionResult,\n AutomationRun,\n Webhook,\n CreatedWebhook,\n WebhookSecret,\n DeliverWebhookInput,\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(\n readonly trigger: string,\n readonly reason: 'reserved' | 'unknown' = 'reserved',\n ) {\n super(\n reason === 'reserved'\n ? `trigger \"${trigger}\" is reserved: automations cannot trigger on automation.* events`\n : `trigger \"${trigger}\" is not an event the system emits`,\n );\n this.name = 'InvalidTriggerError';\n }\n}\n\nexport class ReservedActionError extends Error {\n constructor(readonly actionType: string) {\n super(`action \"${actionType}\" is reserved to webhooks`);\n this.name = 'ReservedActionError';\n }\n}\n\nexport class AutomationKindMismatchError extends Error {\n constructor(\n readonly automationId: string,\n readonly kind: AutomationKind,\n ) {\n super(`automation \"${automationId}\" is a ${kind} and can't be changed through this operation`);\n this.name = 'AutomationKindMismatchError';\n }\n}\n"],"mappings":";;AAoBA,IAAa,sBAAb,cAAyC,MAAM;CAElC;CACA;CAFX,YACE,SACA,SAA0C,YAC1C;EACA,MACE,WAAW,aACP,YAAY,QAAQ,oEACpB,YAAY,QAAQ,mCAC1B;EAPS,KAAA,UAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACd;AACF;AAEA,IAAa,sBAAb,cAAyC,MAAM;CACxB;CAArB,YAAY,YAA6B;EACvC,MAAM,WAAW,WAAW,0BAA0B;EADnC,KAAA,aAAA;EAEnB,KAAK,OAAO;CACd;AACF;AAEA,IAAa,8BAAb,cAAiD,MAAM;CAE1C;CACA;CAFX,YACE,cACA,MACA;EACA,MAAM,eAAe,aAAa,SAAS,KAAK,6CAA6C;EAHpF,KAAA,eAAA;EACA,KAAA,OAAA;EAGT,KAAK,OAAO;CACd;AACF"}
@@ -1,11 +1,14 @@
1
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";
2
+ 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, WebhookRequest, WebhookResponse, WebhookSender } from "../types/automations.js";
4
4
  import "../types/index.js";
5
- import { OutboxAppender, UnitOfWork } from "../shared/ports.js";
5
+ import { CredentialStore, OutboxAppender, UnitOfWork } from "../shared/ports.js";
6
6
  import "./model.js";
7
7
  import "./types.js";
8
8
  //#region src/automations/ports.d.ts
9
+ type NewAutomation = CreateAutomationInput & {
10
+ kind: AutomationKind;
11
+ };
9
12
  /** A run row before persistence assigns its id and event_id. */
10
13
  type NewAutomationRun = Omit<AutomationRun, 'id' | 'eventId'>;
11
14
  interface AutomationsService {
@@ -15,26 +18,37 @@ interface AutomationsService {
15
18
  availableActions(): AvailableActions;
16
19
  /** The domain event types an automation may react to. */
17
20
  availableTriggers(): AvailableTriggers;
18
- list(orgId: string): Promise<Automation[]>;
21
+ list(orgId: string, query?: AutomationsQuery): Promise<Automation[]>;
19
22
  get(orgId: string, id: string): Promise<Automation | null>;
20
23
  create(orgId: string, input: CreateAutomationInput): Promise<Automation>;
21
24
  update(orgId: string, id: string, input: UpdateAutomationInput): Promise<Automation | null>;
22
25
  delete(orgId: string, id: string): Promise<boolean>;
23
26
  listRuns(orgId: string, automationId: string, query: AutomationRunsQuery): Promise<Page<AutomationRun>>;
27
+ rerun(orgId: string, automationId: string, runId: string): Promise<AutomationRun>;
28
+ listWebhooks(orgId: string): Promise<Webhook[]>;
29
+ getWebhook(orgId: string, id: string): Promise<Webhook | null>;
30
+ createWebhook(orgId: string, input: CreateWebhookInput): Promise<CreatedWebhook>;
31
+ updateWebhook(orgId: string, id: string, input: UpdateWebhookInput): Promise<Webhook | null>;
32
+ deleteWebhook(orgId: string, id: string): Promise<boolean>;
33
+ revealWebhookSecret(orgId: string, id: string): Promise<WebhookSecret | null>;
34
+ rotateWebhookSecret(orgId: string, id: string): Promise<WebhookSecret | null>;
24
35
  }
25
36
  interface AutomationsRepository {
26
- insert(orgId: string, input: CreateAutomationInput): Promise<Automation>;
37
+ insert(orgId: string, input: NewAutomation): Promise<Automation>;
27
38
  update(orgId: string, id: string, patch: UpdateAutomationInput): Promise<Automation | null>;
28
39
  /** Returns the deleted row (the event snapshot), or null if it didn't exist. */
29
40
  delete(orgId: string, id: string): Promise<Automation | null>;
30
41
  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`. */
42
+ listByOrg(orgId: string, kind?: AutomationKind): Promise<Automation[]>;
43
+ /** All rows whose triggers include `trigger`, enabled and disabled alike — the service filters to `enabled`. */
33
44
  listByTrigger(orgId: string, trigger: string): Promise<Automation[]>;
34
45
  }
35
46
  interface AutomationRunsRepository {
36
47
  /** Keyed by (orgId, automationId, event.id); returns `null` if this event was already run for this automation (duplicate). */
37
48
  insert(orgId: string, run: NewAutomationRun): Promise<AutomationRun | null>;
49
+ findById(orgId: string, id: string): Promise<AutomationRun | null>;
50
+ /** Puts a finished run back to running with no results; `null` if it's missing or still running. */
51
+ restart(orgId: string, id: string, startedAt: Date): Promise<AutomationRun | null>;
38
52
  recordOutcome(orgId: string, id: string, outcome: {
39
53
  status: AutomationRun['status'];
40
54
  actionResults: AutomationRun['actionResults'];
@@ -48,9 +62,10 @@ interface AutomationRunsRepository {
48
62
  interface AutomationsTxScope {
49
63
  automations: AutomationsRepository;
50
64
  runs: AutomationRunsRepository;
65
+ credentials: CredentialStore;
51
66
  outbox: OutboxAppender;
52
67
  }
53
68
  type AutomationsUnitOfWork = UnitOfWork<AutomationsTxScope>;
54
69
  //#endregion
55
- export { type AutomationDispatch, type AutomationEngine, type AutomationExecutor, AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsTxScope, AutomationsUnitOfWork, NewAutomationRun };
70
+ export { type AutomationDispatch, type AutomationEngine, type AutomationExecutor, AutomationRunsRepository, AutomationsRepository, AutomationsService, AutomationsTxScope, AutomationsUnitOfWork, NewAutomation, NewAutomationRun, type WebhookRequest, type WebhookResponse, type WebhookSender };
56
71
  //# sourceMappingURL=ports.d.ts.map
@@ -1,8 +1,8 @@
1
1
  import { DomainEvent, Page } from "../types/shared.js";
2
2
  import { Logger } from "../types/ports.js";
3
- import { Automation, AutomationActionResult, AutomationRun, AutomationRunsQuery, AvailableActions, AvailableTriggers, CreateAutomationInput, UpdateAutomationInput } from "../types/schemas/automations.js";
4
- import { AutomationDispatch, AutomationEngine, AutomationExecutor } from "../types/automations.js";
5
- import "../shared/ports.js";
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, WebhookSender } from "../types/automations.js";
5
+ import { CredentialStore } from "../shared/ports.js";
6
6
  import { Mailer, MailerLookups } from "../shared/mailer.js";
7
7
  import "./model.js";
8
8
  import "./types.js";
@@ -14,12 +14,14 @@ type AutomationsServiceParams = {
14
14
  /** Read-only access (list/get/available) — runs outside any transaction. */
15
15
  repo: AutomationsRepository;
16
16
  runsRepo: AutomationRunsRepository;
17
- /** Atomic write scope: tx-bound repos + outbox appender. */
17
+ /** Atomic write scope: tx-bound repos + credential store + outbox appender. */
18
18
  uow: AutomationsUnitOfWork;
19
19
  engine: AutomationEngine;
20
20
  mailer: Pick<Mailer, 'send'>;
21
21
  lookups: MailerLookups;
22
22
  integrations: Pick<IntegrationsService, 'available'>;
23
+ credentials: CredentialStore;
24
+ webhooks: WebhookSender;
23
25
  logger?: Logger;
24
26
  };
25
27
  declare class AutomationsServiceImpl implements AutomationsService, AutomationExecutor {
@@ -30,11 +32,15 @@ declare class AutomationsServiceImpl implements AutomationsService, AutomationEx
30
32
  private readonly mailer;
31
33
  private readonly lookups;
32
34
  private readonly integrations;
35
+ private readonly credentials;
36
+ private readonly webhooks;
33
37
  private readonly logger;
34
38
  constructor(params: AutomationsServiceParams);
35
39
  handle(event: DomainEvent): Promise<void>;
36
40
  private safeListByTrigger;
37
41
  private dispatchOne;
42
+ private openRun;
43
+ private dispatchFor;
38
44
  /** Best-effort: logs and never rethrows — `handle` must never throw. */
39
45
  private recordFailure;
40
46
  runAction(d: AutomationDispatch, index: number): Promise<AutomationActionResult>;
@@ -42,9 +48,19 @@ declare class AutomationsServiceImpl implements AutomationsService, AutomationEx
42
48
  create(orgId: string, input: CreateAutomationInput): Promise<Automation>;
43
49
  update(orgId: string, id: string, input: UpdateAutomationInput): Promise<Automation | null>;
44
50
  delete(orgId: string, id: string): Promise<boolean>;
45
- list(orgId: string): Promise<Automation[]>;
51
+ list(orgId: string, query?: AutomationsQuery): Promise<Automation[]>;
46
52
  get(orgId: string, id: string): Promise<Automation | null>;
47
53
  listRuns(orgId: string, automationId: string, query: AutomationRunsQuery): Promise<Page<AutomationRun>>;
54
+ rerun(orgId: string, automationId: string, runId: string): Promise<AutomationRun>;
55
+ listWebhooks(orgId: string): Promise<Webhook[]>;
56
+ getWebhook(orgId: string, id: string): Promise<Webhook | null>;
57
+ createWebhook(orgId: string, input: CreateWebhookInput): Promise<CreatedWebhook>;
58
+ updateWebhook(orgId: string, id: string, input: UpdateWebhookInput): Promise<Webhook | null>;
59
+ deleteWebhook(orgId: string, id: string): Promise<boolean>;
60
+ revealWebhookSecret(orgId: string, id: string): Promise<WebhookSecret | null>;
61
+ rotateWebhookSecret(orgId: string, id: string): Promise<WebhookSecret | null>;
62
+ private findWebhook;
63
+ private assertSubscribableEvents;
48
64
  availableActions(): AvailableActions;
49
65
  availableTriggers(): AvailableTriggers;
50
66
  }