alepha 0.20.1 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/files/index.js +2 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.browser.js +64 -148
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +371 -573
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +605 -1012
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/notifications/index.d.ts +78 -17
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +90 -23
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/payments/index.d.ts +2 -1
- package/dist/api/payments/index.d.ts.map +1 -1
- package/dist/api/payments/index.js +4 -2
- package/dist/api/payments/index.js.map +1 -1
- package/dist/api/users/index.d.ts +34 -31
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +13 -7
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.js +2 -1
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/cli/core/index.d.ts +8 -34
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +43 -232
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +36 -11
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +93 -27
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/command/index.d.ts +1 -1
- package/dist/core/index.browser.js +6 -0
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +6 -0
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +6 -0
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/react/form/index.d.ts +60 -1
- package/dist/react/form/index.d.ts.map +1 -1
- package/dist/react/form/index.js +86 -1
- package/dist/react/form/index.js.map +1 -1
- package/dist/react/head/index.browser.js +16 -1
- package/dist/react/head/index.browser.js.map +1 -1
- package/dist/react/head/index.d.ts +6 -0
- package/dist/react/head/index.d.ts.map +1 -1
- package/dist/react/head/index.js +16 -1
- package/dist/react/head/index.js.map +1 -1
- package/dist/react/router/index.browser.js +0 -10
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +35 -12
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +0 -10
- package/dist/react/router/index.js.map +1 -1
- package/dist/react/ui/index.d.ts +124 -0
- package/dist/react/ui/index.d.ts.map +1 -0
- package/dist/react/ui/index.js +206 -0
- package/dist/react/ui/index.js.map +1 -0
- package/dist/router/index.d.ts +13 -13
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +45 -32
- package/dist/router/index.js.map +1 -1
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +1 -0
- package/dist/system/index.js.map +1 -1
- package/dist/topic/core/index.js +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/package.json +6 -23
- package/src/api/files/jobs/FileJobs.ts +2 -1
- package/src/api/jobs/__tests__/$job.spec.ts +316 -2867
- package/src/api/jobs/controllers/AdminJobController.ts +29 -138
- package/src/api/jobs/entities/jobExecutionEntity.ts +27 -19
- package/src/api/jobs/index.browser.ts +5 -7
- package/src/api/jobs/index.ts +23 -51
- package/src/api/jobs/primitives/$job.ts +66 -58
- package/src/api/jobs/providers/JobProvider.ts +561 -566
- package/src/api/jobs/providers/JobQueueProvider.ts +18 -19
- package/src/api/jobs/schemas/jobConfigAtom.ts +20 -23
- package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +3 -27
- package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +5 -7
- package/src/api/jobs/schemas/jobRegistrationSchema.ts +7 -4
- package/src/api/jobs/schemas/triggerJobSchema.ts +0 -1
- package/src/api/jobs/services/JobService.ts +90 -483
- package/src/api/notifications/controllers/AdminNotificationController.ts +19 -12
- package/src/api/notifications/index.ts +7 -4
- package/src/api/notifications/jobs/NotificationJobs.ts +83 -12
- package/src/api/payments/services/PaymentService.ts +4 -2
- package/src/api/users/__tests__/UserJobs.spec.ts +10 -49
- package/src/api/users/audits/UserAudits.ts +3 -1
- package/src/api/users/buckets/UserBuckets.ts +2 -1
- package/src/api/users/index.ts +1 -4
- package/src/api/users/jobs/UserJobs.ts +5 -4
- package/src/api/verifications/jobs/VerificationJobs.ts +2 -1
- package/src/cli/core/__tests__/init.spec.ts +1 -1
- package/src/cli/core/commands/init.ts +0 -12
- package/src/cli/core/services/PackageManagerUtils.ts +2 -9
- package/src/cli/core/services/ProjectScaffolder.ts +17 -65
- package/src/cli/core/templates/agentMd.ts +2 -8
- package/src/cli/core/templates/apiIndexTs.ts +4 -18
- package/src/cli/core/templates/mainCss.ts +1 -36
- package/src/cli/core/templates/vitestConfigTs.ts +17 -0
- package/src/cli/core/templates/webAppRouterTs.ts +2 -85
- package/src/cli/platform/__tests__/CloudflareAdapter.spec.ts +22 -71
- package/src/cli/platform/adapters/CloudflareAdapter.ts +12 -11
- package/src/cli/platform/atoms/platformOptions.ts +9 -0
- package/src/cli/platform/schemas/cloudflare.ts +3 -2
- package/src/cli/platform/services/CloudflareApi.ts +164 -25
- package/src/cli/platform/services/WranglerApi.ts +0 -17
- package/src/core/Alepha.ts +9 -0
- package/src/react/form/index.ts +2 -0
- package/src/react/form/services/parseField.ts +163 -0
- package/src/react/form/services/prettyName.ts +19 -0
- package/src/react/head/providers/BrowserHeadProvider.ts +31 -10
- package/src/react/router/primitives/$page.ts +35 -12
- package/src/react/ui/atoms/uiAtom.ts +28 -0
- package/src/react/ui/components/ColorScheme.tsx +36 -0
- package/src/react/ui/hooks/useColorMode.ts +49 -0
- package/src/react/ui/hooks/useSidebarState.ts +26 -0
- package/src/react/ui/hooks/useTheme.ts +22 -0
- package/src/react/ui/index.ts +35 -0
- package/src/react/ui/services/UiPersistence.ts +41 -0
- package/src/router/TemplatedPathParser.ts +50 -51
- package/src/router/__tests__/RouterProvider.spec.ts +62 -0
- package/src/router/__tests__/TemplatedPathParser.spec.ts +18 -0
- package/src/router/providers/RouterProvider.ts +10 -5
- package/src/system/providers/NodeShellProvider.ts +1 -0
- package/src/topic/core/providers/TopicProvider.ts +1 -1
- package/dist/api/invitations/index.d.ts +0 -790
- package/dist/api/invitations/index.d.ts.map +0 -1
- package/dist/api/invitations/index.js +0 -662
- package/dist/api/invitations/index.js.map +0 -1
- package/dist/api/issues/index.d.ts +0 -810
- package/dist/api/issues/index.d.ts.map +0 -1
- package/dist/api/issues/index.js +0 -444
- package/dist/api/issues/index.js.map +0 -1
- package/dist/api/subscriptions/index.d.ts +0 -1692
- package/dist/api/subscriptions/index.d.ts.map +0 -1
- package/dist/api/subscriptions/index.js +0 -1867
- package/dist/api/subscriptions/index.js.map +0 -1
- package/dist/api/workflows/index.browser.js +0 -246
- package/dist/api/workflows/index.browser.js.map +0 -1
- package/dist/api/workflows/index.d.ts +0 -1618
- package/dist/api/workflows/index.d.ts.map +0 -1
- package/dist/api/workflows/index.js +0 -1495
- package/dist/api/workflows/index.js.map +0 -1
- package/src/api/invitations/__tests__/InvitationService.spec.ts +0 -439
- package/src/api/invitations/controllers/AdminInvitationController.ts +0 -86
- package/src/api/invitations/controllers/InvitationController.ts +0 -84
- package/src/api/invitations/entities/invitations.ts +0 -33
- package/src/api/invitations/index.ts +0 -58
- package/src/api/invitations/jobs/InvitationJobs.ts +0 -37
- package/src/api/invitations/providers/InvitationProvider.ts +0 -45
- package/src/api/invitations/schemas/createInvitationSchema.ts +0 -12
- package/src/api/invitations/schemas/invitationConfigAtom.ts +0 -20
- package/src/api/invitations/schemas/invitationQuerySchema.ts +0 -15
- package/src/api/invitations/schemas/invitationResourceSchema.ts +0 -6
- package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +0 -22
- package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +0 -10
- package/src/api/invitations/services/InvitationService.ts +0 -556
- package/src/api/issues/__tests__/IssueService.spec.ts +0 -263
- package/src/api/issues/controllers/AdminIssueController.ts +0 -149
- package/src/api/issues/controllers/IssueController.ts +0 -44
- package/src/api/issues/entities/issues.ts +0 -49
- package/src/api/issues/index.ts +0 -50
- package/src/api/issues/schemas/createIssueSchema.ts +0 -13
- package/src/api/issues/schemas/issueConfigAtom.ts +0 -13
- package/src/api/issues/schemas/issueQuerySchema.ts +0 -18
- package/src/api/issues/schemas/issueResourceSchema.ts +0 -6
- package/src/api/issues/schemas/myIssueQuerySchema.ts +0 -10
- package/src/api/issues/schemas/updateIssueSchema.ts +0 -13
- package/src/api/issues/services/IssueService.ts +0 -264
- package/src/api/jobs/__tests__/$job-middleware.spec.ts +0 -126
- package/src/api/jobs/__tests__/JobService.spec.ts +0 -31
- package/src/api/jobs/entities/jobExecutionLogEntity.ts +0 -13
- package/src/api/jobs/schemas/jobActivitySchema.ts +0 -15
- package/src/api/jobs/schemas/jobCronInfoSchema.ts +0 -22
- package/src/api/jobs/schemas/jobExecutionDetailResourceSchema.ts +0 -20
- package/src/api/jobs/schemas/jobFailureSchema.ts +0 -9
- package/src/api/jobs/schemas/jobQueueDepthSchema.ts +0 -14
- package/src/api/jobs/schemas/jobStatsSchema.ts +0 -14
- package/src/api/jobs/services/JobService-tests.ts +0 -157
- package/src/api/subscriptions/__tests__/BillingService.spec.ts +0 -218
- package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +0 -278
- package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +0 -212
- package/src/api/subscriptions/controllers/SubscriptionController.ts +0 -189
- package/src/api/subscriptions/entities/subscriptionEvents.ts +0 -54
- package/src/api/subscriptions/entities/subscriptions.ts +0 -68
- package/src/api/subscriptions/index.ts +0 -133
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +0 -382
- package/src/api/subscriptions/middleware/$requireLimit.ts +0 -50
- package/src/api/subscriptions/middleware/$requirePlan.ts +0 -49
- package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +0 -110
- package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +0 -8
- package/src/api/subscriptions/schemas/changePlanSchema.ts +0 -9
- package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +0 -11
- package/src/api/subscriptions/schemas/entitlementsSchema.ts +0 -21
- package/src/api/subscriptions/schemas/mrrSchema.ts +0 -13
- package/src/api/subscriptions/schemas/planDefinitionSchema.ts +0 -71
- package/src/api/subscriptions/schemas/planResourceSchema.ts +0 -25
- package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +0 -8
- package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +0 -19
- package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +0 -6
- package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +0 -32
- package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +0 -23
- package/src/api/subscriptions/services/BillingService.ts +0 -437
- package/src/api/subscriptions/services/SubscriptionConfig.ts +0 -56
- package/src/api/subscriptions/services/SubscriptionService.ts +0 -867
- package/src/api/subscriptions/services/UsageService.ts +0 -118
- package/src/api/workflows/__tests__/$workflow.spec.ts +0 -616
- package/src/api/workflows/controllers/AdminWorkflowController.ts +0 -191
- package/src/api/workflows/entities/workflowExecutions.ts +0 -74
- package/src/api/workflows/entities/workflowStepExecutions.ts +0 -74
- package/src/api/workflows/entities/workflowStepLogs.ts +0 -13
- package/src/api/workflows/index.browser.ts +0 -22
- package/src/api/workflows/index.ts +0 -115
- package/src/api/workflows/jobs/WorkflowJobs.ts +0 -77
- package/src/api/workflows/primitives/$workflow.ts +0 -202
- package/src/api/workflows/providers/WorkflowProvider.ts +0 -1284
- package/src/api/workflows/schemas/workflowActivitySchema.ts +0 -15
- package/src/api/workflows/schemas/workflowConfigAtom.ts +0 -51
- package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +0 -18
- package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +0 -26
- package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +0 -30
- package/src/api/workflows/schemas/workflowRegistrationSchema.ts +0 -26
- package/src/api/workflows/schemas/workflowStatsSchema.ts +0 -16
- package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +0 -15
- package/src/api/workflows/services/WorkflowService.ts +0 -382
- package/src/cli/core/templates/apiAppSecurityTs.ts +0 -43
- package/src/cli/core/templates/webAdminDashboardTsx.ts +0 -17
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as _$alepha from "alepha";
|
|
2
2
|
import { Alepha, KIND, Primitive, Static, StaticEncode, TObject } from "alepha";
|
|
3
3
|
import * as _$alepha_api_jobs0 from "alepha/api/jobs";
|
|
4
|
-
import
|
|
5
|
-
import * as _$alepha_server0 from "alepha/server";
|
|
4
|
+
import * as _$alepha_api_parameters0 from "alepha/api/parameters";
|
|
6
5
|
import * as _$alepha_orm0 from "alepha/orm";
|
|
7
|
-
import
|
|
6
|
+
import * as _$alepha_server0 from "alepha/server";
|
|
7
|
+
import { DateTimeProvider } from "alepha/datetime";
|
|
8
8
|
import * as _$alepha_logger0 from "alepha/logger";
|
|
9
|
+
import { EmailProvider } from "alepha/email";
|
|
9
10
|
import { SmsProvider } from "alepha/sms";
|
|
10
11
|
import * as _$typebox from "typebox";
|
|
11
12
|
|
|
@@ -129,7 +130,26 @@ declare class NotificationSenderService {
|
|
|
129
130
|
}
|
|
130
131
|
//#endregion
|
|
131
132
|
//#region ../../src/api/notifications/jobs/NotificationJobs.d.ts
|
|
133
|
+
/**
|
|
134
|
+
* Notification jobs + runtime-editable retention.
|
|
135
|
+
*
|
|
136
|
+
* - `settings` — a `$parameter` exposing `retentionDays` that admins can
|
|
137
|
+
* update at runtime. Changes propagate across instances via the parameter
|
|
138
|
+
* pub/sub; the next purge run picks up the new value with no restart.
|
|
139
|
+
* - `sendNotification` — queue-mode, audit-oriented. Every execution is kept
|
|
140
|
+
* (`record: "all"`, `keep: { ok: 0, error: 0 }` disables the ring-buffer
|
|
141
|
+
* trim) so the audit trail survives even under heavy volume.
|
|
142
|
+
* - `purgeOldNotifications` — cron sweep that deletes notification execution
|
|
143
|
+
* rows whose `completedAt` is older than the current `retentionDays`.
|
|
144
|
+
*
|
|
145
|
+
* Cron expression note: the purge cron is declared statically (`0 3 * * *`)
|
|
146
|
+
* because some runtimes (Cloudflare Workers) freeze cron triggers at deploy
|
|
147
|
+
* time. The *retention window* is fully runtime-editable — that's the knob
|
|
148
|
+
* that actually matters for operators.
|
|
149
|
+
*/
|
|
132
150
|
declare class NotificationJobs {
|
|
151
|
+
protected readonly log: _$alepha_logger0.Logger;
|
|
152
|
+
protected readonly dt: DateTimeProvider;
|
|
133
153
|
protected readonly notificationSenderService: NotificationSenderService;
|
|
134
154
|
protected readonly executions: _$alepha_orm0.Repository<_$alepha.TObject<{
|
|
135
155
|
id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
@@ -137,22 +157,34 @@ declare class NotificationJobs {
|
|
|
137
157
|
updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
138
158
|
jobName: _$alepha.TString;
|
|
139
159
|
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
140
|
-
|
|
141
|
-
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "dead" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
160
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
142
161
|
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
143
162
|
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
144
163
|
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
164
|
+
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
145
165
|
scheduledAt: _$alepha.TOptional<_$alepha.TString>;
|
|
146
166
|
startedAt: _$alepha.TOptional<_$alepha.TString>;
|
|
147
167
|
completedAt: _$alepha.TOptional<_$alepha.TString>;
|
|
148
|
-
result: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
149
168
|
error: _$alepha.TOptional<_$alepha.TString>;
|
|
150
|
-
|
|
169
|
+
logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
|
|
170
|
+
level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
171
|
+
message: _$alepha.TString;
|
|
172
|
+
service: _$alepha.TString;
|
|
173
|
+
module: _$alepha.TString;
|
|
174
|
+
context: _$alepha.TOptional<_$alepha.TString>;
|
|
175
|
+
app: _$alepha.TOptional<_$alepha.TString>;
|
|
176
|
+
data: _$alepha.TOptional<_$alepha.TAny>;
|
|
177
|
+
timestamp: _$alepha.TNumber;
|
|
178
|
+
}>>>;
|
|
151
179
|
triggeredBy: _$alepha.TOptional<_$alepha.TString>;
|
|
152
180
|
triggeredByName: _$alepha.TOptional<_$alepha.TString>;
|
|
153
181
|
cancelledBy: _$alepha.TOptional<_$alepha.TString>;
|
|
154
182
|
cancelledByName: _$alepha.TOptional<_$alepha.TString>;
|
|
155
183
|
}>>;
|
|
184
|
+
/** Runtime-editable config. Admins can change retentionDays without deploy. */
|
|
185
|
+
readonly settings: _$alepha_api_parameters0.ParameterPrimitive<_$alepha.TObject<{
|
|
186
|
+
retentionDays: _$alepha.TInteger;
|
|
187
|
+
}>>;
|
|
156
188
|
readonly sendNotification: _$alepha_api_jobs0.JobPrimitive<_$alepha.TObject<{
|
|
157
189
|
type: _$alepha.TUnsafe<"email" | "sms">;
|
|
158
190
|
template: _$alepha.TString;
|
|
@@ -162,21 +194,51 @@ declare class NotificationJobs {
|
|
|
162
194
|
critical: _$alepha.TOptional<_$alepha.TBoolean>;
|
|
163
195
|
sensitive: _$alepha.TOptional<_$alepha.TBoolean>;
|
|
164
196
|
}>>;
|
|
197
|
+
readonly purgeOldNotifications: _$alepha_api_jobs0.JobPrimitive<_$alepha.TSchema>;
|
|
165
198
|
}
|
|
166
199
|
//#endregion
|
|
167
200
|
//#region ../../src/api/notifications/controllers/AdminNotificationController.d.ts
|
|
168
201
|
declare class AdminNotificationController {
|
|
169
202
|
protected readonly url: string;
|
|
170
203
|
protected readonly group: string;
|
|
171
|
-
protected readonly jobService: JobService;
|
|
172
204
|
protected readonly notificationJobs: NotificationJobs;
|
|
205
|
+
protected readonly executions: _$alepha_orm0.Repository<_$alepha.TObject<{
|
|
206
|
+
id: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_PRIMARY_KEY>, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
207
|
+
createdAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_CREATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
208
|
+
updatedAt: _$alepha_orm0.PgAttr<_$alepha_orm0.PgAttr<_$alepha.TString, typeof _$alepha_orm0.PG_UPDATED_AT>, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
209
|
+
jobName: _$alepha.TString;
|
|
210
|
+
key: _$alepha.TOptional<_$alepha.TUnion<[_$alepha.TNull, _$alepha.TString]>>;
|
|
211
|
+
status: _$alepha_orm0.PgAttr<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "ok" | "error" | "cancelled">, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
212
|
+
priority: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
213
|
+
attempt: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
214
|
+
maxAttempts: _$alepha_orm0.PgAttr<_$alepha.TInteger, typeof _$alepha_orm0.PG_DEFAULT>;
|
|
215
|
+
payload: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
216
|
+
scheduledAt: _$alepha.TOptional<_$alepha.TString>;
|
|
217
|
+
startedAt: _$alepha.TOptional<_$alepha.TString>;
|
|
218
|
+
completedAt: _$alepha.TOptional<_$alepha.TString>;
|
|
219
|
+
error: _$alepha.TOptional<_$alepha.TString>;
|
|
220
|
+
logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
|
|
221
|
+
level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
222
|
+
message: _$alepha.TString;
|
|
223
|
+
service: _$alepha.TString;
|
|
224
|
+
module: _$alepha.TString;
|
|
225
|
+
context: _$alepha.TOptional<_$alepha.TString>;
|
|
226
|
+
app: _$alepha.TOptional<_$alepha.TString>;
|
|
227
|
+
data: _$alepha.TOptional<_$alepha.TAny>;
|
|
228
|
+
timestamp: _$alepha.TNumber;
|
|
229
|
+
}>>>;
|
|
230
|
+
triggeredBy: _$alepha.TOptional<_$alepha.TString>;
|
|
231
|
+
triggeredByName: _$alepha.TOptional<_$alepha.TString>;
|
|
232
|
+
cancelledBy: _$alepha.TOptional<_$alepha.TString>;
|
|
233
|
+
cancelledByName: _$alepha.TOptional<_$alepha.TString>;
|
|
234
|
+
}>>;
|
|
173
235
|
protected get jobName(): string;
|
|
174
236
|
readonly findNotifications: _$alepha_server0.ActionPrimitiveFn<{
|
|
175
237
|
query: _$alepha.TObject<{
|
|
176
238
|
page: _$alepha.TOptional<_$alepha.TInteger>;
|
|
177
239
|
size: _$alepha.TOptional<_$alepha.TInteger>;
|
|
178
240
|
sort: _$alepha.TOptional<_$alepha.TString>;
|
|
179
|
-
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "
|
|
241
|
+
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "cancelled" | "retrying" | "completed" | "dead">>;
|
|
180
242
|
}>;
|
|
181
243
|
response: _$alepha.TPage<_$alepha.TObject<{
|
|
182
244
|
id: _$alepha.TString;
|
|
@@ -213,7 +275,7 @@ declare class AdminNotificationController {
|
|
|
213
275
|
variables: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
214
276
|
rendered: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
215
277
|
logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
|
|
216
|
-
level: _$alepha.TUnsafe<"
|
|
278
|
+
level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
217
279
|
message: _$alepha.TString;
|
|
218
280
|
service: _$alepha.TString;
|
|
219
281
|
module: _$alepha.TString;
|
|
@@ -240,7 +302,6 @@ declare class AdminNotificationController {
|
|
|
240
302
|
};
|
|
241
303
|
protected toDetailResource(exec: Record<string, unknown>): {
|
|
242
304
|
variables: unknown;
|
|
243
|
-
rendered: unknown;
|
|
244
305
|
logs: unknown;
|
|
245
306
|
id: unknown;
|
|
246
307
|
createdAt: unknown;
|
|
@@ -291,7 +352,7 @@ declare const notificationDetailResourceSchema: _$alepha.TObject<{
|
|
|
291
352
|
variables: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
292
353
|
rendered: _$alepha.TOptional<_$alepha.TRecord<"^.*$", _$alepha.TAny>>;
|
|
293
354
|
logs: _$alepha.TOptional<_$alepha.TArray<_$alepha.TObject<{
|
|
294
|
-
level: _$alepha.TUnsafe<"
|
|
355
|
+
level: _$alepha.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
295
356
|
message: _$alepha.TString;
|
|
296
357
|
service: _$alepha.TString;
|
|
297
358
|
module: _$alepha.TString;
|
|
@@ -308,7 +369,7 @@ declare const notificationQuerySchema: _$alepha.TObject<{
|
|
|
308
369
|
page: _$alepha.TOptional<_$alepha.TInteger>;
|
|
309
370
|
size: _$alepha.TOptional<_$alepha.TInteger>;
|
|
310
371
|
sort: _$alepha.TOptional<_$alepha.TString>;
|
|
311
|
-
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "
|
|
372
|
+
status: _$alepha.TOptional<_$alepha.TUnsafe<"pending" | "running" | "scheduled" | "cancelled" | "retrying" | "completed" | "dead">>;
|
|
312
373
|
}>;
|
|
313
374
|
type NotificationQuery = Static<typeof notificationQuerySchema>;
|
|
314
375
|
//#endregion
|
|
@@ -334,10 +395,10 @@ type NotificationResource = Static<typeof notificationResourceSchema>;
|
|
|
334
395
|
* User notification management.
|
|
335
396
|
*
|
|
336
397
|
* **Features:**
|
|
337
|
-
* - Notification definitions
|
|
338
|
-
* -
|
|
339
|
-
* -
|
|
340
|
-
* -
|
|
398
|
+
* - Notification definitions (email/SMS templates)
|
|
399
|
+
* - Queue-based delivery with retry and audit trail (`record: "all"` + no ring buffer trim)
|
|
400
|
+
* - Runtime-editable retention window via `$parameter` — purge cron respects it live
|
|
401
|
+
* - Admin API for inspecting sent notifications
|
|
341
402
|
*
|
|
342
403
|
* @module alepha.api.notifications
|
|
343
404
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/schemas/notificationDetailResourceSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/schemas/notificationResourceSchema.ts","../../../src/api/notifications/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/schemas/notificationDetailResourceSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/schemas/notificationResourceSchema.ts","../../../src/api/notifications/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;;;;;;;;cAAa,aAAA;EAAA,WAA2B,OAAA,EAAO,OAAA,EACpC,4BAAA,CAA6B,CAAA,IAAE,qBAAA,CAAA,CAAA;EAAA;;UAKzB,4BAAA,WAAuC,OAAA,UAC9C,mBAAA,CAAoB,CAAA;EAC5B,IAAA;EACA,WAAA;EACA,QAAA;EACA,QAAA;EACA,SAAA;EACA,YAAA;IAAA,CAEG,IAAA,WAAe,mBAAA,CAAoB,CAAA;EAAA;EAEtC,MAAA,EAAQ,CAAA;AAAA;AAAA,cAKG,qBAAA,WAAgC,OAAA,UAAiB,SAAA,CAC5D,4BAAA,CAA6B,CAAA;EAAA,mBAEV,gBAAA,EAAgB,gBAAA;EAAA,IAExB,IAAA,CAAA;EAIE,IAAA,CAAK,OAAA,EAAS,uBAAA,CAAwB,CAAA,IAAE,OAAA;EAoC9C,SAAA,CAAU,OAAA,EAAS,OAAA,CAAQ,4BAAA,CAA6B,CAAA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
|
import { $inject, $module, Alepha, AlephaError, KIND, Primitive, createPrimitive, t } from "alepha";
|
|
2
|
-
import { $job,
|
|
3
|
-
import { $
|
|
4
|
-
import { $action } from "alepha/server";
|
|
2
|
+
import { $job, AlephaApiJobsQueue, jobExecutionEntity } from "alepha/api/jobs";
|
|
3
|
+
import { $parameter, AlephaApiParameters } from "alepha/api/parameters";
|
|
5
4
|
import { $repository, pageQuerySchema } from "alepha/orm";
|
|
6
|
-
import {
|
|
5
|
+
import { $secure } from "alepha/security";
|
|
6
|
+
import { $action, NotFoundError } from "alepha/server";
|
|
7
|
+
import { DateTimeProvider } from "alepha/datetime";
|
|
7
8
|
import { $logger, logEntrySchema } from "alepha/logger";
|
|
9
|
+
import { EmailProvider } from "alepha/email";
|
|
8
10
|
import { SmsProvider } from "alepha/sms";
|
|
9
11
|
//#region ../../src/api/notifications/schemas/notificationPayloadSchema.ts
|
|
10
12
|
const notificationPayloadSchema = t.object({
|
|
@@ -152,10 +154,41 @@ var NotificationSenderService = class {
|
|
|
152
154
|
};
|
|
153
155
|
//#endregion
|
|
154
156
|
//#region ../../src/api/notifications/jobs/NotificationJobs.ts
|
|
157
|
+
/**
|
|
158
|
+
* Notification jobs + runtime-editable retention.
|
|
159
|
+
*
|
|
160
|
+
* - `settings` — a `$parameter` exposing `retentionDays` that admins can
|
|
161
|
+
* update at runtime. Changes propagate across instances via the parameter
|
|
162
|
+
* pub/sub; the next purge run picks up the new value with no restart.
|
|
163
|
+
* - `sendNotification` — queue-mode, audit-oriented. Every execution is kept
|
|
164
|
+
* (`record: "all"`, `keep: { ok: 0, error: 0 }` disables the ring-buffer
|
|
165
|
+
* trim) so the audit trail survives even under heavy volume.
|
|
166
|
+
* - `purgeOldNotifications` — cron sweep that deletes notification execution
|
|
167
|
+
* rows whose `completedAt` is older than the current `retentionDays`.
|
|
168
|
+
*
|
|
169
|
+
* Cron expression note: the purge cron is declared statically (`0 3 * * *`)
|
|
170
|
+
* because some runtimes (Cloudflare Workers) freeze cron triggers at deploy
|
|
171
|
+
* time. The *retention window* is fully runtime-editable — that's the knob
|
|
172
|
+
* that actually matters for operators.
|
|
173
|
+
*/
|
|
155
174
|
var NotificationJobs = class {
|
|
175
|
+
log = $logger();
|
|
176
|
+
dt = $inject(DateTimeProvider);
|
|
156
177
|
notificationSenderService = $inject(NotificationSenderService);
|
|
157
178
|
executions = $repository(jobExecutionEntity);
|
|
179
|
+
/** Runtime-editable config. Admins can change retentionDays without deploy. */
|
|
180
|
+
settings = $parameter({
|
|
181
|
+
name: "alepha.api.notifications",
|
|
182
|
+
description: "Notification delivery & retention settings.",
|
|
183
|
+
schema: t.object({ retentionDays: t.integer({
|
|
184
|
+
description: "Days to keep notification execution rows before the purge sweep removes them.",
|
|
185
|
+
minimum: 1
|
|
186
|
+
}) }),
|
|
187
|
+
default: { retentionDays: 7 }
|
|
188
|
+
});
|
|
158
189
|
sendNotification = $job({
|
|
190
|
+
name: "api:notifications:sendNotification",
|
|
191
|
+
description: "Sends a notification (email/SMS) and keeps every execution for audit.",
|
|
159
192
|
schema: notificationPayloadSchema,
|
|
160
193
|
retry: {
|
|
161
194
|
retries: 3,
|
|
@@ -167,12 +200,45 @@ var NotificationJobs = class {
|
|
|
167
200
|
}
|
|
168
201
|
},
|
|
169
202
|
timeout: [30, "seconds"],
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
203
|
+
record: "all",
|
|
204
|
+
keep: {
|
|
205
|
+
ok: 0,
|
|
206
|
+
error: 0
|
|
207
|
+
},
|
|
208
|
+
handler: async ({ payload }) => {
|
|
209
|
+
await this.notificationSenderService.send(payload);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
purgeOldNotifications = $job({
|
|
213
|
+
name: "api:notifications:purgeOldNotifications",
|
|
214
|
+
description: "Hourly sweep that deletes notification execution rows older than the configured retention window.",
|
|
215
|
+
cron: "0 * * * *",
|
|
216
|
+
handler: async ({ now }) => {
|
|
217
|
+
const { retentionDays } = this.settings.cachedCurrentContent;
|
|
218
|
+
const cutoff = now.subtract(retentionDays, "day").toISOString();
|
|
219
|
+
const jobName = this.sendNotification.name;
|
|
220
|
+
const expired = await this.executions.findMany({
|
|
221
|
+
where: {
|
|
222
|
+
jobName: { eq: jobName },
|
|
223
|
+
status: { inArray: [
|
|
224
|
+
"ok",
|
|
225
|
+
"error",
|
|
226
|
+
"cancelled"
|
|
227
|
+
] },
|
|
228
|
+
completedAt: { lt: cutoff }
|
|
229
|
+
},
|
|
230
|
+
columns: ["id"],
|
|
231
|
+
limit: 5e3
|
|
232
|
+
});
|
|
233
|
+
if (expired.length === 0) {
|
|
234
|
+
this.log.debug("Notification purge: nothing to delete", {
|
|
235
|
+
cutoff,
|
|
236
|
+
retentionDays
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
175
239
|
}
|
|
240
|
+
await this.executions.deleteMany({ id: { inArray: expired.map((r) => r.id) } });
|
|
241
|
+
this.log.info(`Notification purge: deleted ${expired.length} row(s) older than ${retentionDays} days`, { cutoff });
|
|
176
242
|
}
|
|
177
243
|
});
|
|
178
244
|
};
|
|
@@ -218,8 +284,8 @@ const notificationQuerySchema = t.extend(pageQuerySchema, { status: t.optional(t
|
|
|
218
284
|
var AdminNotificationController = class {
|
|
219
285
|
url = "/notifications";
|
|
220
286
|
group = "admin:notifications";
|
|
221
|
-
jobService = $inject(JobService);
|
|
222
287
|
notificationJobs = $inject(NotificationJobs);
|
|
288
|
+
executions = $repository(jobExecutionEntity);
|
|
223
289
|
get jobName() {
|
|
224
290
|
return this.notificationJobs.sendNotification.name;
|
|
225
291
|
}
|
|
@@ -232,13 +298,13 @@ var AdminNotificationController = class {
|
|
|
232
298
|
response: t.page(notificationResourceSchema)
|
|
233
299
|
},
|
|
234
300
|
handler: async ({ query }) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
});
|
|
301
|
+
query.sort ??= "-createdAt";
|
|
302
|
+
const where = this.executions.createQueryWhere();
|
|
303
|
+
where.jobName = { eq: this.jobName };
|
|
304
|
+
const page = await this.executions.paginate(query, { where }, { count: true });
|
|
239
305
|
return {
|
|
240
|
-
...
|
|
241
|
-
content:
|
|
306
|
+
...page,
|
|
307
|
+
content: page.content.map((exec) => this.toResource(exec))
|
|
242
308
|
};
|
|
243
309
|
}
|
|
244
310
|
});
|
|
@@ -251,8 +317,9 @@ var AdminNotificationController = class {
|
|
|
251
317
|
response: notificationDetailResourceSchema
|
|
252
318
|
},
|
|
253
319
|
handler: async ({ params }) => {
|
|
254
|
-
const
|
|
255
|
-
|
|
320
|
+
const exec = await this.executions.findById(params.id);
|
|
321
|
+
if (!exec || exec.jobName !== this.jobName) throw new NotFoundError(`Notification not found: ${params.id}`);
|
|
322
|
+
return this.toDetailResource(exec);
|
|
256
323
|
}
|
|
257
324
|
});
|
|
258
325
|
toResource(exec) {
|
|
@@ -277,7 +344,6 @@ var AdminNotificationController = class {
|
|
|
277
344
|
return {
|
|
278
345
|
...this.toResource(exec),
|
|
279
346
|
variables: payload.variables,
|
|
280
|
-
rendered: exec.result,
|
|
281
347
|
logs: exec.logs
|
|
282
348
|
};
|
|
283
349
|
}
|
|
@@ -303,15 +369,16 @@ const notificationContactSchema = t.object({
|
|
|
303
369
|
* User notification management.
|
|
304
370
|
*
|
|
305
371
|
* **Features:**
|
|
306
|
-
* - Notification definitions
|
|
307
|
-
* -
|
|
308
|
-
* -
|
|
309
|
-
* -
|
|
372
|
+
* - Notification definitions (email/SMS templates)
|
|
373
|
+
* - Queue-based delivery with retry and audit trail (`record: "all"` + no ring buffer trim)
|
|
374
|
+
* - Runtime-editable retention window via `$parameter` — purge cron respects it live
|
|
375
|
+
* - Admin API for inspecting sent notifications
|
|
310
376
|
*
|
|
311
377
|
* @module alepha.api.notifications
|
|
312
378
|
*/
|
|
313
379
|
const AlephaApiNotifications = $module({
|
|
314
380
|
name: "alepha.api.notifications",
|
|
381
|
+
imports: [AlephaApiJobsQueue, AlephaApiParameters],
|
|
315
382
|
primitives: [$notification],
|
|
316
383
|
services: [
|
|
317
384
|
NotificationSenderService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/schemas/notificationResourceSchema.ts","../../../src/api/notifications/schemas/notificationDetailResourceSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/index.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\n\nexport const notificationPayloadSchema = t.object({\n type: t.enum([\"email\", \"sms\"]),\n template: t.text(),\n contact: t.text(),\n variables: t.optional(t.record(t.text(), t.any())),\n category: t.optional(t.text()),\n critical: t.optional(t.boolean()),\n sensitive: t.optional(t.boolean()),\n});\n\nexport type NotificationPayload = Static<typeof notificationPayloadSchema>;\n","import {\n $inject,\n createPrimitive,\n KIND,\n Primitive,\n type Static,\n type StaticEncode,\n type TObject,\n} from \"alepha\";\nimport { NotificationJobs } from \"../jobs/NotificationJobs.ts\";\n\n/**\n * Creates a notification primitive for managing email/SMS notification templates.\n *\n * Provides type-safe, reusable notification templates with multi-language support,\n * variable substitution, and categorization for different notification channels.\n *\n * @example\n * ```ts\n * class NotificationTemplates {\n * welcomeEmail = $notification({\n * name: \"welcome-email\",\n * category: \"onboarding\",\n * schema: t.object({ username: t.text(), activationLink: t.text() }),\n * email: {\n * subject: \"Welcome to our platform!\",\n * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`\n * }\n * });\n *\n * async sendWelcome(user: User) {\n * await this.welcomeEmail.push({\n * variables: { username: user.name, activationLink: generateLink() },\n * contact: user.email\n * });\n * }\n * }\n * ```\n */\nexport const $notification = <T extends TObject>(\n options: NotificationPrimitiveOptions<T>,\n) => createPrimitive(NotificationPrimitive<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPrimitiveOptions<T extends TObject>\n extends NotificationMessage<T> {\n name?: string;\n description?: string;\n category?: string;\n critical?: boolean;\n sensitive?: boolean;\n translations?: {\n // e.g., \"en\", \"fr\", even \"en-US\"\n [lang: string]: NotificationMessage<T>;\n };\n schema: T;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class NotificationPrimitive<T extends TObject> extends Primitive<\n NotificationPrimitiveOptions<T>\n> {\n protected readonly notificationJobs = $inject(NotificationJobs);\n\n public get name() {\n return this.options.name ?? `${this.config.propertyKey}`;\n }\n\n public async push(options: NotificationPushOptions<T>) {\n const pushOpts = this.options.critical\n ? ({ priority: \"critical\" } as const)\n : undefined;\n\n if (this.options.email) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"email\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n\n if (this.options.sms) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"sms\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n }\n\n public configure(options: Partial<NotificationPrimitiveOptions<T>>) {\n Object.assign(this.options, options);\n }\n}\n\n$notification[KIND] = NotificationPrimitive;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPushOptions<T extends TObject> {\n variables: StaticEncode<T>;\n contact: string;\n}\n\nexport interface NotificationMessage<T extends TObject> {\n email?: {\n subject: string;\n body: string | ((variables: Static<T>) => string);\n };\n sms?: {\n message: string | ((variables: Static<T>) => string);\n };\n}\n","import { $inject, Alepha, AlephaError } from \"alepha\";\nimport { EmailProvider } from \"alepha/email\";\nimport { $logger } from \"alepha/logger\";\nimport { SmsProvider } from \"alepha/sms\";\nimport { $notification } from \"../primitives/$notification.ts\";\nimport type { NotificationPayload } from \"../schemas/notificationPayloadSchema.ts\";\n\nexport class NotificationSenderService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly emailProvider = $inject(EmailProvider);\n protected readonly smsProvider = $inject(SmsProvider);\n\n public async send(payload: NotificationPayload) {\n this.log.debug(\"Processing notification\", {\n type: payload.type,\n template: payload.template,\n contact: payload.contact,\n });\n\n if (payload.type === \"email\") {\n const rendered = this.renderEmail(payload);\n await this.emailProvider.send(rendered);\n this.log.info(\"Email notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n return {\n type: \"email\" as const,\n to: rendered.to,\n subject: rendered.subject,\n body: rendered.body,\n };\n }\n\n if (payload.type === \"sms\") {\n const rendered = this.renderSms(payload);\n await this.smsProvider.send(rendered);\n this.log.info(\"SMS notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n return {\n type: \"sms\" as const,\n to: rendered.to,\n message: rendered.message,\n };\n }\n }\n\n public renderSms(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const sms = template.options.sms;\n if (!sms) {\n throw new AlephaError(\n `Notification template ${payload.template} has no sms defined`,\n );\n }\n\n const message =\n typeof sms.message === \"function\"\n ? sms.message(variables as any)\n : sms.message;\n\n return { to: contact, message };\n }\n\n public renderEmail(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const email = template.options.email;\n if (!email) {\n throw new AlephaError(\n `Notification template ${payload.template} has no email defined`,\n );\n }\n\n const subject = email.subject;\n const body =\n typeof email.body === \"function\"\n ? email.body(variables as any)\n : email.body;\n\n return { to: contact, subject, body };\n }\n\n protected load(payload: NotificationPayload) {\n const variables = payload.variables || {};\n const contact = payload.contact;\n const template = this.alepha\n .primitives($notification)\n .find((it) => it.name === payload.template);\n\n if (!template) {\n throw new AlephaError(\n `No notification template found for ${payload.template}`,\n );\n }\n\n return { template, variables, contact };\n }\n}\n","import { $inject } from \"alepha\";\nimport { $job, jobExecutionEntity } from \"alepha/api/jobs\";\nimport { $repository } from \"alepha/orm\";\nimport { notificationPayloadSchema } from \"../schemas/notificationPayloadSchema.ts\";\nimport { NotificationSenderService } from \"../services/NotificationSenderService.ts\";\n\nexport class NotificationJobs {\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n protected readonly executions = $repository(jobExecutionEntity);\n\n public readonly sendNotification = $job({\n schema: notificationPayloadSchema,\n retry: {\n retries: 3,\n backoff: {\n initial: [5, \"seconds\"],\n factor: 4,\n max: [10, \"minutes\"],\n jitter: true,\n },\n },\n timeout: [30, \"seconds\"],\n concurrency: 5,\n handler: async ({ items }) => {\n for (const item of items) {\n const rendered = await this.notificationSenderService.send(\n item.payload,\n );\n if (rendered) {\n await this.executions.updateById(item.id, {\n result: rendered as Record<string, unknown>,\n });\n }\n }\n },\n });\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationResourceSchema = t.object({\n id: t.uuid(),\n createdAt: t.datetime(),\n status: t.text(),\n template: t.optional(t.text()),\n type: t.optional(t.text()),\n contact: t.optional(t.text()),\n category: t.optional(t.text()),\n critical: t.optional(t.boolean()),\n sensitive: t.optional(t.boolean()),\n startedAt: t.optional(t.datetime()),\n completedAt: t.optional(t.datetime()),\n error: t.optional(t.text()),\n});\n\nexport type NotificationResource = Static<typeof notificationResourceSchema>;\n","import { type Static, t } from \"alepha\";\nimport { logEntrySchema } from \"alepha/logger\";\nimport { notificationResourceSchema } from \"./notificationResourceSchema.ts\";\n\nexport const notificationDetailResourceSchema = t.extend(\n notificationResourceSchema,\n {\n variables: t.optional(t.record(t.text(), t.any())),\n rendered: t.optional(t.record(t.text(), t.any())),\n logs: t.optional(t.array(logEntrySchema)),\n },\n {\n title: \"NotificationDetailResource\",\n description: \"A notification resource with rendered content and logs.\",\n },\n);\n\nexport type NotificationDetailResource = Static<\n typeof notificationDetailResourceSchema\n>;\n","import { type Static, t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const notificationQuerySchema = t.extend(pageQuerySchema, {\n status: t.optional(\n t.enum([\n \"pending\",\n \"scheduled\",\n \"retrying\",\n \"running\",\n \"completed\",\n \"dead\",\n \"cancelled\",\n ]),\n ),\n});\n\nexport type NotificationQuery = Static<typeof notificationQuerySchema>;\n","import { $inject, t } from \"alepha\";\nimport { JobService } from \"alepha/api/jobs\";\nimport { $secure } from \"alepha/security\";\nimport { $action } from \"alepha/server\";\nimport { NotificationJobs } from \"../jobs/NotificationJobs.ts\";\nimport { notificationDetailResourceSchema } from \"../schemas/notificationDetailResourceSchema.ts\";\nimport { notificationQuerySchema } from \"../schemas/notificationQuerySchema.ts\";\nimport { notificationResourceSchema } from \"../schemas/notificationResourceSchema.ts\";\n\nexport class AdminNotificationController {\n protected readonly url: string = \"/notifications\";\n protected readonly group: string = \"admin:notifications\";\n protected readonly jobService = $inject(JobService);\n protected readonly notificationJobs = $inject(NotificationJobs);\n\n protected get jobName(): string {\n return this.notificationJobs.sendNotification.name;\n }\n\n public readonly findNotifications = $action({\n path: this.url,\n group: this.group,\n use: [$secure({ permissions: [\"admin:notification:read\"] })],\n schema: {\n query: notificationQuerySchema,\n response: t.page(notificationResourceSchema),\n },\n handler: async ({ query }) => {\n const result = await this.jobService.findExecutions({\n ...query,\n job: this.jobName,\n });\n return {\n ...result,\n content: result.content.map((exec) => this.toResource(exec)),\n } as any;\n },\n });\n\n public readonly getNotification = $action({\n path: `${this.url}/:id`,\n group: this.group,\n use: [$secure({ permissions: [\"admin:notification:read\"] })],\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: notificationDetailResourceSchema,\n },\n handler: async ({ params }) => {\n const detail = await this.jobService.getExecution(params.id);\n return this.toDetailResource(detail) as any;\n },\n });\n\n protected toResource(exec: Record<string, unknown>) {\n const payload = (exec.payload ?? {}) as Record<string, unknown>;\n return {\n id: exec.id,\n createdAt: exec.createdAt,\n status: exec.status,\n template: payload.template,\n type: payload.type,\n contact: payload.contact,\n category: payload.category,\n critical: payload.critical,\n sensitive: payload.sensitive,\n startedAt: exec.startedAt,\n completedAt: exec.completedAt,\n error: exec.error,\n };\n }\n\n protected toDetailResource(exec: Record<string, unknown>) {\n const payload = (exec.payload ?? {}) as Record<string, unknown>;\n return {\n ...this.toResource(exec),\n variables: payload.variables,\n rendered: exec.result,\n logs: exec.logs,\n };\n }\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactPreferencesSchema = t.object({\n language: t.optional(t.text()),\n exclude: t.array(t.text()),\n});\n\nexport type NotificationContactPreferences = Static<\n typeof notificationContactPreferencesSchema\n>;\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactSchema = t.object({\n email: t.optional(t.email()),\n phoneNumber: t.optional(t.e164()),\n firstName: t.optional(t.shortText()),\n lastName: t.optional(t.text({ size: \"short\" })),\n language: t.optional(t.bcp47()),\n});\n\nexport type NotificationContact = Static<typeof notificationContactSchema>;\n","import { $module } from \"alepha\";\nimport { AdminNotificationController } from \"./controllers/AdminNotificationController.ts\";\nimport { NotificationJobs } from \"./jobs/NotificationJobs.ts\";\nimport { $notification } from \"./primitives/$notification.ts\";\nimport { NotificationSenderService } from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./controllers/AdminNotificationController.ts\";\nexport * from \"./jobs/NotificationJobs.ts\";\nexport * from \"./primitives/$notification.ts\";\nexport * from \"./schemas/notificationContactPreferencesSchema.ts\";\nexport * from \"./schemas/notificationContactSchema.ts\";\nexport * from \"./schemas/notificationDetailResourceSchema.ts\";\nexport * from \"./schemas/notificationPayloadSchema.ts\";\nexport * from \"./schemas/notificationQuerySchema.ts\";\nexport * from \"./schemas/notificationResourceSchema.ts\";\nexport * from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * User notification management.\n *\n * **Features:**\n * - Notification definitions\n * - Email/SMS notification sending\n * - Job-based delivery with retry and tracking\n * - User preferences\n *\n * @module alepha.api.notifications\n */\nexport const AlephaApiNotifications = $module({\n name: \"alepha.api.notifications\",\n primitives: [$notification],\n services: [\n NotificationSenderService,\n NotificationJobs,\n AdminNotificationController,\n ],\n});\n"],"mappings":";;;;;;;;;AAEA,MAAa,4BAA4B,EAAE,OAAO;CAChD,MAAM,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;CAC9B,UAAU,EAAE,MAAM;CAClB,SAAS,EAAE,MAAM;CACjB,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;CAClD,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC;CAC9B,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC;CACjC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;CACnC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6BF,MAAa,iBACX,YACG,gBAAgB,uBAA0B,QAAQ;AAoBvD,IAAa,wBAAb,cAA8D,UAE5D;CACA,mBAAsC,QAAQ,iBAAiB;CAE/D,IAAW,OAAO;AAChB,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK,OAAO;;CAG7C,MAAa,KAAK,SAAqC;EACrD,MAAM,WAAW,KAAK,QAAQ,WACzB,EAAE,UAAU,YAAY,GACzB,KAAA;AAEJ,MAAI,KAAK,QAAQ,MACf,OAAM,KAAK,iBAAiB,iBAAiB,KAC3C;GACE,MAAM;GACN,UAAU,KAAK;GACf,SAAS,QAAQ;GACjB,WAAW,QAAQ;GACnB,UAAU,KAAK,QAAQ;GACvB,UAAU,KAAK,QAAQ;GACvB,WAAW,KAAK,QAAQ;GACzB,EACD,SACD;AAGH,MAAI,KAAK,QAAQ,IACf,OAAM,KAAK,iBAAiB,iBAAiB,KAC3C;GACE,MAAM;GACN,UAAU,KAAK;GACf,SAAS,QAAQ;GACjB,WAAW,QAAQ;GACnB,UAAU,KAAK,QAAQ;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AE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC,CAAC;CAC/C,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,CAAC;;;;;;;;;;;;;;ACwBF,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,YAAY,CAAC,cAAc;CAC3B,UAAU;EACR;EACA;EACA;EACD;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/schemas/notificationResourceSchema.ts","../../../src/api/notifications/schemas/notificationDetailResourceSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/index.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\n\nexport const notificationPayloadSchema = t.object({\n type: t.enum([\"email\", \"sms\"]),\n template: t.text(),\n contact: t.text(),\n variables: t.optional(t.record(t.text(), t.any())),\n category: t.optional(t.text()),\n critical: t.optional(t.boolean()),\n sensitive: t.optional(t.boolean()),\n});\n\nexport type NotificationPayload = Static<typeof notificationPayloadSchema>;\n","import {\n $inject,\n createPrimitive,\n KIND,\n Primitive,\n type Static,\n type StaticEncode,\n type TObject,\n} from \"alepha\";\nimport { NotificationJobs } from \"../jobs/NotificationJobs.ts\";\n\n/**\n * Creates a notification primitive for managing email/SMS notification templates.\n *\n * Provides type-safe, reusable notification templates with multi-language support,\n * variable substitution, and categorization for different notification channels.\n *\n * @example\n * ```ts\n * class NotificationTemplates {\n * welcomeEmail = $notification({\n * name: \"welcome-email\",\n * category: \"onboarding\",\n * schema: t.object({ username: t.text(), activationLink: t.text() }),\n * email: {\n * subject: \"Welcome to our platform!\",\n * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`\n * }\n * });\n *\n * async sendWelcome(user: User) {\n * await this.welcomeEmail.push({\n * variables: { username: user.name, activationLink: generateLink() },\n * contact: user.email\n * });\n * }\n * }\n * ```\n */\nexport const $notification = <T extends TObject>(\n options: NotificationPrimitiveOptions<T>,\n) => createPrimitive(NotificationPrimitive<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPrimitiveOptions<T extends TObject>\n extends NotificationMessage<T> {\n name?: string;\n description?: string;\n category?: string;\n critical?: boolean;\n sensitive?: boolean;\n translations?: {\n // e.g., \"en\", \"fr\", even \"en-US\"\n [lang: string]: NotificationMessage<T>;\n };\n schema: T;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class NotificationPrimitive<T extends TObject> extends Primitive<\n NotificationPrimitiveOptions<T>\n> {\n protected readonly notificationJobs = $inject(NotificationJobs);\n\n public get name() {\n return this.options.name ?? `${this.config.propertyKey}`;\n }\n\n public async push(options: NotificationPushOptions<T>) {\n const pushOpts = this.options.critical\n ? ({ priority: \"critical\" } as const)\n : undefined;\n\n if (this.options.email) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"email\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n\n if (this.options.sms) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"sms\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n }\n\n public configure(options: Partial<NotificationPrimitiveOptions<T>>) {\n Object.assign(this.options, options);\n }\n}\n\n$notification[KIND] = NotificationPrimitive;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPushOptions<T extends TObject> {\n variables: StaticEncode<T>;\n contact: string;\n}\n\nexport interface NotificationMessage<T extends TObject> {\n email?: {\n subject: string;\n body: string | ((variables: Static<T>) => string);\n };\n sms?: {\n message: string | ((variables: Static<T>) => string);\n };\n}\n","import { $inject, Alepha, AlephaError } from \"alepha\";\nimport { EmailProvider } from \"alepha/email\";\nimport { $logger } from \"alepha/logger\";\nimport { SmsProvider } from \"alepha/sms\";\nimport { $notification } from \"../primitives/$notification.ts\";\nimport type { NotificationPayload } from \"../schemas/notificationPayloadSchema.ts\";\n\nexport class NotificationSenderService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly emailProvider = $inject(EmailProvider);\n protected readonly smsProvider = $inject(SmsProvider);\n\n public async send(payload: NotificationPayload) {\n this.log.debug(\"Processing notification\", {\n type: payload.type,\n template: payload.template,\n contact: payload.contact,\n });\n\n if (payload.type === \"email\") {\n const rendered = this.renderEmail(payload);\n await this.emailProvider.send(rendered);\n this.log.info(\"Email notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n return {\n type: \"email\" as const,\n to: rendered.to,\n subject: rendered.subject,\n body: rendered.body,\n };\n }\n\n if (payload.type === \"sms\") {\n const rendered = this.renderSms(payload);\n await this.smsProvider.send(rendered);\n this.log.info(\"SMS notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n return {\n type: \"sms\" as const,\n to: rendered.to,\n message: rendered.message,\n };\n }\n }\n\n public renderSms(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const sms = template.options.sms;\n if (!sms) {\n throw new AlephaError(\n `Notification template ${payload.template} has no sms defined`,\n );\n }\n\n const message =\n typeof sms.message === \"function\"\n ? sms.message(variables as any)\n : sms.message;\n\n return { to: contact, message };\n }\n\n public renderEmail(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const email = template.options.email;\n if (!email) {\n throw new AlephaError(\n `Notification template ${payload.template} has no email defined`,\n );\n }\n\n const subject = email.subject;\n const body =\n typeof email.body === \"function\"\n ? email.body(variables as any)\n : email.body;\n\n return { to: contact, subject, body };\n }\n\n protected load(payload: NotificationPayload) {\n const variables = payload.variables || {};\n const contact = payload.contact;\n const template = this.alepha\n .primitives($notification)\n .find((it) => it.name === payload.template);\n\n if (!template) {\n throw new AlephaError(\n `No notification template found for ${payload.template}`,\n );\n }\n\n return { template, variables, contact };\n }\n}\n","import { $inject, t } from \"alepha\";\nimport { $job, jobExecutionEntity } from \"alepha/api/jobs\";\nimport { $parameter } from \"alepha/api/parameters\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository } from \"alepha/orm\";\nimport { notificationPayloadSchema } from \"../schemas/notificationPayloadSchema.ts\";\nimport { NotificationSenderService } from \"../services/NotificationSenderService.ts\";\n\n/**\n * Notification jobs + runtime-editable retention.\n *\n * - `settings` — a `$parameter` exposing `retentionDays` that admins can\n * update at runtime. Changes propagate across instances via the parameter\n * pub/sub; the next purge run picks up the new value with no restart.\n * - `sendNotification` — queue-mode, audit-oriented. Every execution is kept\n * (`record: \"all\"`, `keep: { ok: 0, error: 0 }` disables the ring-buffer\n * trim) so the audit trail survives even under heavy volume.\n * - `purgeOldNotifications` — cron sweep that deletes notification execution\n * rows whose `completedAt` is older than the current `retentionDays`.\n *\n * Cron expression note: the purge cron is declared statically (`0 3 * * *`)\n * because some runtimes (Cloudflare Workers) freeze cron triggers at deploy\n * time. The *retention window* is fully runtime-editable — that's the knob\n * that actually matters for operators.\n */\nexport class NotificationJobs {\n protected readonly log = $logger();\n protected readonly dt = $inject(DateTimeProvider);\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n protected readonly executions = $repository(jobExecutionEntity);\n\n /** Runtime-editable config. Admins can change retentionDays without deploy. */\n public readonly settings = $parameter({\n name: \"alepha.api.notifications\",\n description: \"Notification delivery & retention settings.\",\n schema: t.object({\n retentionDays: t.integer({\n description:\n \"Days to keep notification execution rows before the purge sweep removes them.\",\n minimum: 1,\n }),\n }),\n default: {\n retentionDays: 7,\n },\n });\n\n public readonly sendNotification = $job({\n name: \"api:notifications:sendNotification\",\n description:\n \"Sends a notification (email/SMS) and keeps every execution for audit.\",\n schema: notificationPayloadSchema,\n retry: {\n retries: 3,\n backoff: {\n initial: [5, \"seconds\"],\n factor: 4,\n max: [10, \"minutes\"],\n jitter: true,\n },\n },\n timeout: [30, \"seconds\"],\n record: \"all\",\n keep: { ok: 0, error: 0 },\n handler: async ({ payload }) => {\n await this.notificationSenderService.send(payload);\n },\n });\n\n public readonly purgeOldNotifications = $job({\n name: \"api:notifications:purgeOldNotifications\",\n description:\n \"Hourly sweep that deletes notification execution rows older than the configured retention window.\",\n cron: \"0 * * * *\",\n handler: async ({ now }) => {\n const { retentionDays } = this.settings.cachedCurrentContent;\n const cutoff = now.subtract(retentionDays, \"day\").toISOString();\n const jobName = this.sendNotification.name;\n\n const expired = await this.executions.findMany({\n where: {\n jobName: { eq: jobName },\n status: { inArray: [\"ok\", \"error\", \"cancelled\"] },\n completedAt: { lt: cutoff },\n },\n columns: [\"id\"] as any,\n limit: 5_000,\n });\n\n if (expired.length === 0) {\n this.log.debug(\"Notification purge: nothing to delete\", {\n cutoff,\n retentionDays,\n });\n return;\n }\n\n await this.executions.deleteMany({\n id: { inArray: expired.map((r) => r.id) },\n });\n this.log.info(\n `Notification purge: deleted ${expired.length} row(s) older than ${retentionDays} days`,\n { cutoff },\n );\n },\n });\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationResourceSchema = t.object({\n id: t.uuid(),\n createdAt: t.datetime(),\n status: t.text(),\n template: t.optional(t.text()),\n type: t.optional(t.text()),\n contact: t.optional(t.text()),\n category: t.optional(t.text()),\n critical: t.optional(t.boolean()),\n sensitive: t.optional(t.boolean()),\n startedAt: t.optional(t.datetime()),\n completedAt: t.optional(t.datetime()),\n error: t.optional(t.text()),\n});\n\nexport type NotificationResource = Static<typeof notificationResourceSchema>;\n","import { type Static, t } from \"alepha\";\nimport { logEntrySchema } from \"alepha/logger\";\nimport { notificationResourceSchema } from \"./notificationResourceSchema.ts\";\n\nexport const notificationDetailResourceSchema = t.extend(\n notificationResourceSchema,\n {\n variables: t.optional(t.record(t.text(), t.any())),\n rendered: t.optional(t.record(t.text(), t.any())),\n logs: t.optional(t.array(logEntrySchema)),\n },\n {\n title: \"NotificationDetailResource\",\n description: \"A notification resource with rendered content and logs.\",\n },\n);\n\nexport type NotificationDetailResource = Static<\n typeof notificationDetailResourceSchema\n>;\n","import { type Static, t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const notificationQuerySchema = t.extend(pageQuerySchema, {\n status: t.optional(\n t.enum([\n \"pending\",\n \"scheduled\",\n \"retrying\",\n \"running\",\n \"completed\",\n \"dead\",\n \"cancelled\",\n ]),\n ),\n});\n\nexport type NotificationQuery = Static<typeof notificationQuerySchema>;\n","import { $inject, t } from \"alepha\";\nimport { jobExecutionEntity } from \"alepha/api/jobs\";\nimport { $repository } from \"alepha/orm\";\nimport { $secure } from \"alepha/security\";\nimport { $action, NotFoundError } from \"alepha/server\";\nimport { NotificationJobs } from \"../jobs/NotificationJobs.ts\";\nimport { notificationDetailResourceSchema } from \"../schemas/notificationDetailResourceSchema.ts\";\nimport { notificationQuerySchema } from \"../schemas/notificationQuerySchema.ts\";\nimport { notificationResourceSchema } from \"../schemas/notificationResourceSchema.ts\";\n\nexport class AdminNotificationController {\n protected readonly url: string = \"/notifications\";\n protected readonly group: string = \"admin:notifications\";\n protected readonly notificationJobs = $inject(NotificationJobs);\n protected readonly executions = $repository(jobExecutionEntity);\n\n protected get jobName(): string {\n return this.notificationJobs.sendNotification.name;\n }\n\n public readonly findNotifications = $action({\n path: this.url,\n group: this.group,\n use: [$secure({ permissions: [\"admin:notification:read\"] })],\n schema: {\n query: notificationQuerySchema,\n response: t.page(notificationResourceSchema),\n },\n handler: async ({ query }) => {\n query.sort ??= \"-createdAt\";\n const where = this.executions.createQueryWhere();\n where.jobName = { eq: this.jobName };\n const page = await this.executions.paginate(\n query,\n { where },\n { count: true },\n );\n return {\n ...page,\n content: page.content.map((exec) => this.toResource(exec)),\n } as any;\n },\n });\n\n public readonly getNotification = $action({\n path: `${this.url}/:id`,\n group: this.group,\n use: [$secure({ permissions: [\"admin:notification:read\"] })],\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: notificationDetailResourceSchema,\n },\n handler: async ({ params }) => {\n const exec = await this.executions.findById(params.id);\n if (!exec || exec.jobName !== this.jobName) {\n throw new NotFoundError(`Notification not found: ${params.id}`);\n }\n return this.toDetailResource(exec) as any;\n },\n });\n\n protected toResource(exec: Record<string, unknown>) {\n const payload = (exec.payload ?? {}) as Record<string, unknown>;\n return {\n id: exec.id,\n createdAt: exec.createdAt,\n status: exec.status,\n template: payload.template,\n type: payload.type,\n contact: payload.contact,\n category: payload.category,\n critical: payload.critical,\n sensitive: payload.sensitive,\n startedAt: exec.startedAt,\n completedAt: exec.completedAt,\n error: exec.error,\n };\n }\n\n protected toDetailResource(exec: Record<string, unknown>) {\n const payload = (exec.payload ?? {}) as Record<string, unknown>;\n return {\n ...this.toResource(exec),\n variables: payload.variables,\n logs: exec.logs,\n };\n }\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactPreferencesSchema = t.object({\n language: t.optional(t.text()),\n exclude: t.array(t.text()),\n});\n\nexport type NotificationContactPreferences = Static<\n typeof notificationContactPreferencesSchema\n>;\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactSchema = t.object({\n email: t.optional(t.email()),\n phoneNumber: t.optional(t.e164()),\n firstName: t.optional(t.shortText()),\n lastName: t.optional(t.text({ size: \"short\" })),\n language: t.optional(t.bcp47()),\n});\n\nexport type NotificationContact = Static<typeof notificationContactSchema>;\n","import { $module } from \"alepha\";\nimport { AlephaApiJobsQueue } from \"alepha/api/jobs\";\nimport { AlephaApiParameters } from \"alepha/api/parameters\";\nimport { AdminNotificationController } from \"./controllers/AdminNotificationController.ts\";\nimport { NotificationJobs } from \"./jobs/NotificationJobs.ts\";\nimport { $notification } from \"./primitives/$notification.ts\";\nimport { NotificationSenderService } from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./controllers/AdminNotificationController.ts\";\nexport * from \"./jobs/NotificationJobs.ts\";\nexport * from \"./primitives/$notification.ts\";\nexport * from \"./schemas/notificationContactPreferencesSchema.ts\";\nexport * from \"./schemas/notificationContactSchema.ts\";\nexport * from \"./schemas/notificationDetailResourceSchema.ts\";\nexport * from \"./schemas/notificationPayloadSchema.ts\";\nexport * from \"./schemas/notificationQuerySchema.ts\";\nexport * from \"./schemas/notificationResourceSchema.ts\";\nexport * from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * User notification management.\n *\n * **Features:**\n * - Notification definitions (email/SMS templates)\n * - Queue-based delivery with retry and audit trail (`record: \"all\"` + no ring buffer trim)\n * - Runtime-editable retention window via `$parameter` — purge cron respects it live\n * - Admin API for inspecting sent notifications\n *\n * @module alepha.api.notifications\n */\nexport const AlephaApiNotifications = $module({\n name: \"alepha.api.notifications\",\n imports: [AlephaApiJobsQueue, AlephaApiParameters],\n primitives: [$notification],\n services: [\n NotificationSenderService,\n NotificationJobs,\n AdminNotificationController,\n ],\n});\n"],"mappings":";;;;;;;;;;;AAEA,MAAa,4BAA4B,EAAE,OAAO;CAChD,MAAM,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;CAC9B,UAAU,EAAE,MAAM;CAClB,SAAS,EAAE,MAAM;CACjB,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;CAClD,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC;CAC9B,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC;CACjC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;CACnC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6BF,MAAa,iBACX,YACG,gBAAgB,uBAA0B,QAAQ;AAoBvD,IAAa,wBAAb,cAA8D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;EACxD,MAAM,UAAW,KAAK,WAAW,EAAE;AACnC,SAAO;GACL,GAAG,KAAK,WAAW,KAAK;GACxB,WAAW,QAAQ;GACnB,MAAM,KAAK;GACZ;;;;;ACrFL,MAAa,uCAAuC,EAAE,OAAO;CAC3D,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC;CAC9B,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;CAC3B,CAAC;;;ACHF,MAAa,4BAA4B,EAAE,OAAO;CAChD,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,aAAa,EAAE,SAAS,EAAE,MAAM,CAAC;CACjC,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC;CACpC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC,CAAC;CAC/C,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,CAAC;;;;;;;;;;;;;;AC0BF,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,SAAS,CAAC,oBAAoB,oBAAoB;CAClD,YAAY,CAAC,cAAc;CAC3B,UAAU;EACR;EACA;EACA;EACD;CACF,CAAC"}
|
|
@@ -450,7 +450,8 @@ declare class PaymentService {
|
|
|
450
450
|
}>>;
|
|
451
451
|
/**
|
|
452
452
|
* Expires stale payment intents that have been in "processing" status
|
|
453
|
-
* for more than 30 minutes. Runs every
|
|
453
|
+
* for more than 30 minutes. Runs every 5 minutes — shares the CF wrangler
|
|
454
|
+
* trigger with the jobs sweep so no extra binding is consumed.
|
|
454
455
|
*/
|
|
455
456
|
protected readonly expireStaleIntents: _$alepha_api_jobs0.JobPrimitive<_$alepha.TSchema>;
|
|
456
457
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/orm/core/schemas/insertSchema.ts","../../../src/orm/core/schemas/updateSchema.ts","../../../src/orm/core/primitives/$entity.ts","../../../src/orm/core/constants/PG_SYMBOLS.ts","../../../src/orm/core/helpers/pgAttr.ts","../../../src/orm/core/schemas/databaseEnvSchema.ts","../../../src/api/payments/entities/paymentIntents.ts","../../../src/api/payments/entities/refunds.ts","../../../src/api/payments/providers/PaymentProvider.ts","../../../src/api/payments/services/PaymentService.ts","../../../src/api/payments/controllers/AdminPaymentController.ts","../../../src/api/payments/entities/paymentMethods.ts","../../../src/api/payments/services/PaymentMethodService.ts","../../../src/api/payments/controllers/PaymentController.ts","../../../src/api/payments/errors/PaymentError.ts","../../../src/api/payments/providers/MemoryPaymentProvider.ts","../../../src/api/payments/schemas/intentSchemas.ts","../../../src/api/payments/schemas/paymentMethodSchemas.ts","../../../src/api/payments/schemas/refundSchemas.ts","../../../src/api/payments/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAaY,aAAA,WAAwB,OAAA,IAAW,OAAA,eACjC,CAAA,kBAAmB,CAAA,eAAgB,CAAA;EAAA,CAC5C,YAAA;AAAA,YAGC,CAAA,GAAI,CAAA,eAAgB,CAAA;EAAA,CACjB,UAAA;AAAA;EACD,WAAA;AAAA,IACF,SAAA,CAAU,CAAA,eAAgB,CAAA,KAC1B,CAAA,eAAgB,CAAA;;;;;;;;;;;;KCJV,aAAA,WAAwB,OAAA,IAAW,OAAA,eACjC,CAAA,kBAAmB,CAAA,eAAgB,CAAA;EAAA,CAC5C,YAAA;AAAA,YAGC,CAAA,GAAI,CAAA,eAAgB,CAAA,UAAW,SAAA,YAC/B,SAAA,CAAU,MAAA,EAAQ,CAAA,EAAG,KAAA,MACrB,CAAA,eAAgB,CAAA;;;UCWL,sBAAA,WACL,OAAA,eACG,MAAA,CAAO,CAAA;EFpBZ;;;;EE0BR,IAAA;EFvBI;;;EE4BJ,MAAA,EAAQ,CAAA;EFpC4C;;;EEyCpD,OAAA,IACI,IAAA;IF1CyC;;;IE+CvC,MAAA,EAAQ,IAAA;IF9CiC;;;IEkDzC,MAAA;IF9CkB;;;IEkDlB,IAAA;IF/CQ;;;IEmDR,KAAA,GAAQ,GAAA;EAAA;IFl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AA;;;;KAEU,UAAA,GAAa,MAAA,QAAc,gBAAA;AAAA,cAE1B,iBAAA,WAAiB,OAAA;2BAG5B,QAAA,CAAA,QAAA;;;;;;KAEU,WAAA,GAAc,MAAA,QAAc,iBAAA;AAAA,cAE3B,oBAAA,WAAoB,OAAA;gDAAwB,QAAA,CAAA,OAAA;;;;;;;;;;;;;;KAE7C,cAAA,GAAiB,MAAA,QAAc,oBAAA;;;cCvD9B,sBAAA,EAEX,QAAA,CAFiC,OAAA;SAEjC,QAAA,CAAA,OAAA;AAAA;AAAA,KAEU,gBAAA,GAAmB,MAAA,QAAc,sBAAA;AAAA,cAEhC,2BAAA,WAA2B,OAAA;oBAAwB,QAAA,CAAA,OAAA;;;;;;;;;;;;;;KAEpD,qBAAA,GAAwB,MAAA,QAAc,2BAAA;;;cCTrC,oBAAA,WAAoB,OAAA;oBAAiB,QAAA,CAAA,OAAA;;;;;;;;;;;;KAEtC,cAAA,GAAiB,MAAA,QAAc,oBAAA;;;;YCkB/B,KAAA;IACR,qBAAA;MACE,QAAA;MACA,MAAA;MACA,QAAA;MACA,QAAA;IAAA;IAEF,mBAAA;MACE,QAAA;MACA,MAAA;MACA,QAAA;MACA,QAAA;IAAA;IAEF,iBAAA;MACE,QAAA;MACA,MAAA;MACA,QAAA;MACA,QAAA;IAAA;IAEF,iBAAA;MACE,QAAA;MACA,MAAA;MACA,QAAA;MACA,QAAA;IAAA;IAEF,mBAAA;MACE,QAAA;MACA,QAAA;MACA,MAAA;MACA,QAAA;MACA,QAAA;IAAA;IAEF,oBAAA;MACE,QAAA;MACA,MAAA;MACA,QAAA;MACA,QAAA;IAAA;EAAA;AAAA;AAAA,cAKO,iBAAA,EAAiB,QAAA,CAAA,OAAA,CAiB5B,QAAA,CAjB4B,MAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/orm/core/schemas/insertSchema.ts","../../../src/orm/core/schemas/updateSchema.ts","../../../src/orm/core/primitives/$entity.ts","../../../src/orm/core/constants/PG_SYMBOLS.ts","../../../src/orm/core/helpers/pgAttr.ts","../../../src/orm/core/schemas/databaseEnvSchema.ts","../../../src/api/payments/entities/paymentIntents.ts","../../../src/api/payments/entities/refunds.ts","../../../src/api/payments/providers/PaymentProvider.ts","../../../src/api/payments/services/PaymentService.ts","../../../src/api/payments/controllers/AdminPaymentController.ts","../../../src/api/payments/entities/paymentMethods.ts","../../../src/api/payments/services/PaymentMethodService.ts","../../../src/api/payments/controllers/PaymentController.ts","../../../src/api/payments/errors/PaymentError.ts","../../../src/api/payments/providers/MemoryPaymentProvider.ts","../../../src/api/payments/schemas/intentSchemas.ts","../../../src/api/payments/schemas/paymentMethodSchemas.ts","../../../src/api/payments/schemas/refundSchemas.ts","../../../src/api/payments/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAaY,aAAA,WAAwB,OAAA,IAAW,OAAA,eACjC,CAAA,kBAAmB,CAAA,eAAgB,CAAA;EAAA,CAC5C,YAAA;AAAA,YAGC,CAAA,GAAI,CAAA,eAAgB,CAAA;EAAA,CACjB,UAAA;AAAA;EACD,WAAA;AAAA,IACF,SAAA,CAAU,CAAA,eAAgB,CAAA,KAC1B,CAAA,eAAgB,CAAA;;;;;;;;;;;;KCJV,aAAA,WAAwB,OAAA,IAAW,OAAA,eACjC,CAAA,kBAAmB,CAAA,eAAgB,CAAA;EAAA,CAC5C,YAAA;AAAA,YAGC,CAAA,GAAI,CAAA,eAAgB,CAAA,UAAW,SAAA,YAC/B,SAAA,CAAU,MAAA,EAAQ,CAAA,EAAG,KAAA,MACrB,CAAA,eAAgB,CAAA;;;UCWL,sBAAA,WACL,OAAA,eACG,MAAA,CAAO,CAAA;EFpBZ;;;;EE0BR,IAAA;EFvBI;;;EE4BJ,MAAA,EAAQ,CAAA;EFpC4C;;;EEyCpD,OAAA,IACI,IAAA;IF1CyC;;;IE+CvC,MAAA,EAAQ,IAAA;IF9CiC;;;IEkDzC,MAAA;IF9CkB;;;IEkDlB,IAAA;IF/C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|
|
126
126
|
* Expires stale payment intents that have been in "processing" status
|
|
127
|
-
* for more than 30 minutes. Runs every
|
|
127
|
+
* for more than 30 minutes. Runs every 5 minutes — shares the CF wrangler
|
|
128
|
+
* trigger with the jobs sweep so no extra binding is consumed.
|
|
128
129
|
*/
|
|
129
130
|
expireStaleIntents = $job({
|
|
130
|
-
|
|
131
|
+
name: "api:payments:expireStaleIntents",
|
|
132
|
+
cron: "*/5 * * * *",
|
|
131
133
|
handler: async () => {
|
|
132
134
|
const cutoff = this.dateTime.now().subtract(30, "minutes").toISOString();
|
|
133
135
|
const stale = await this.intentRepo.findMany({ where: {
|