@ucptools/validator 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/auth/config.d.ts +20 -0
  2. package/dist/auth/config.d.ts.map +1 -0
  3. package/dist/auth/config.js +114 -0
  4. package/dist/auth/config.js.map +1 -0
  5. package/dist/auth/index.d.ts +5 -0
  6. package/dist/auth/index.d.ts.map +1 -0
  7. package/dist/auth/index.js +17 -0
  8. package/dist/auth/index.js.map +1 -0
  9. package/dist/auth/middleware.d.ts +45 -0
  10. package/dist/auth/middleware.d.ts.map +1 -0
  11. package/dist/auth/middleware.js +170 -0
  12. package/dist/auth/middleware.js.map +1 -0
  13. package/dist/auth/service.d.ts +80 -0
  14. package/dist/auth/service.d.ts.map +1 -0
  15. package/dist/auth/service.js +298 -0
  16. package/dist/auth/service.js.map +1 -0
  17. package/dist/cli/index.js +96 -0
  18. package/dist/cli/index.js.map +1 -1
  19. package/dist/cli/mock-server.d.ts +20 -0
  20. package/dist/cli/mock-server.d.ts.map +1 -0
  21. package/dist/cli/mock-server.js +261 -0
  22. package/dist/cli/mock-server.js.map +1 -0
  23. package/dist/db/index.d.ts +8 -2
  24. package/dist/db/index.d.ts.map +1 -1
  25. package/dist/db/index.js +22 -5
  26. package/dist/db/index.js.map +1 -1
  27. package/dist/db/schema.d.ts +3570 -128
  28. package/dist/db/schema.d.ts.map +1 -1
  29. package/dist/db/schema.js +377 -17
  30. package/dist/db/schema.js.map +1 -1
  31. package/dist/db/utils.d.ts +252 -0
  32. package/dist/db/utils.d.ts.map +1 -0
  33. package/dist/db/utils.js +295 -0
  34. package/dist/db/utils.js.map +1 -0
  35. package/dist/feed-analyzer/feed-analyzer.d.ts.map +1 -1
  36. package/dist/feed-analyzer/feed-analyzer.js +218 -4
  37. package/dist/feed-analyzer/feed-analyzer.js.map +1 -1
  38. package/dist/feed-analyzer/types.d.ts +82 -1
  39. package/dist/feed-analyzer/types.d.ts.map +1 -1
  40. package/dist/feed-analyzer/types.js +13 -0
  41. package/dist/feed-analyzer/types.js.map +1 -1
  42. package/dist/lib/analytics.d.ts +337 -0
  43. package/dist/lib/analytics.d.ts.map +1 -0
  44. package/dist/lib/analytics.js +188 -0
  45. package/dist/lib/analytics.js.map +1 -0
  46. package/dist/security/security-scanner.d.ts.map +1 -1
  47. package/dist/security/security-scanner.js +130 -2
  48. package/dist/security/security-scanner.js.map +1 -1
  49. package/dist/security/types.d.ts +32 -0
  50. package/dist/security/types.d.ts.map +1 -1
  51. package/dist/security/types.js.map +1 -1
  52. package/dist/services/analytics.d.ts +114 -0
  53. package/dist/services/analytics.d.ts.map +1 -0
  54. package/dist/services/analytics.js +862 -0
  55. package/dist/services/analytics.js.map +1 -0
  56. package/dist/services/badge.d.ts +31 -0
  57. package/dist/services/badge.d.ts.map +1 -0
  58. package/dist/services/badge.js +152 -0
  59. package/dist/services/badge.js.map +1 -0
  60. package/dist/services/cron.d.ts +125 -0
  61. package/dist/services/cron.d.ts.map +1 -0
  62. package/dist/services/cron.js +613 -0
  63. package/dist/services/cron.js.map +1 -0
  64. package/dist/services/directory.d.ts +2 -0
  65. package/dist/services/directory.d.ts.map +1 -1
  66. package/dist/services/directory.js +45 -27
  67. package/dist/services/directory.js.map +1 -1
  68. package/dist/services/email.d.ts +112 -0
  69. package/dist/services/email.d.ts.map +1 -0
  70. package/dist/services/email.js +772 -0
  71. package/dist/services/email.js.map +1 -0
  72. package/dist/services/hosted-profiles.d.ts +77 -0
  73. package/dist/services/hosted-profiles.d.ts.map +1 -0
  74. package/dist/services/hosted-profiles.js +433 -0
  75. package/dist/services/hosted-profiles.js.map +1 -0
  76. package/dist/services/latency.d.ts +67 -0
  77. package/dist/services/latency.d.ts.map +1 -0
  78. package/dist/services/latency.js +274 -0
  79. package/dist/services/latency.js.map +1 -0
  80. package/dist/services/manifest-compliance.d.ts +64 -0
  81. package/dist/services/manifest-compliance.d.ts.map +1 -0
  82. package/dist/services/manifest-compliance.js +271 -0
  83. package/dist/services/manifest-compliance.js.map +1 -0
  84. package/dist/services/monitoring-diff.d.ts +31 -0
  85. package/dist/services/monitoring-diff.d.ts.map +1 -0
  86. package/dist/services/monitoring-diff.js +189 -0
  87. package/dist/services/monitoring-diff.js.map +1 -0
  88. package/dist/services/notifications.d.ts +46 -0
  89. package/dist/services/notifications.d.ts.map +1 -0
  90. package/dist/services/notifications.js +88 -0
  91. package/dist/services/notifications.js.map +1 -0
  92. package/dist/services/stripe.d.ts +93 -0
  93. package/dist/services/stripe.d.ts.map +1 -0
  94. package/dist/services/stripe.js +490 -0
  95. package/dist/services/stripe.js.map +1 -0
  96. package/dist/services/validation-history.d.ts +99 -0
  97. package/dist/services/validation-history.d.ts.map +1 -0
  98. package/dist/services/validation-history.js +344 -0
  99. package/dist/services/validation-history.js.map +1 -0
  100. package/dist/services/validation-logging.d.ts +103 -0
  101. package/dist/services/validation-logging.d.ts.map +1 -0
  102. package/dist/services/validation-logging.js +210 -0
  103. package/dist/services/validation-logging.js.map +1 -0
  104. package/dist/services/validation.d.ts +119 -0
  105. package/dist/services/validation.d.ts.map +1 -0
  106. package/dist/services/validation.js +1185 -0
  107. package/dist/services/validation.js.map +1 -0
  108. package/dist/simulator/agent-simulator.d.ts.map +1 -1
  109. package/dist/simulator/agent-simulator.js +229 -9
  110. package/dist/simulator/agent-simulator.js.map +1 -1
  111. package/dist/simulator/types.d.ts +26 -0
  112. package/dist/simulator/types.d.ts.map +1 -1
  113. package/dist/simulator/types.js.map +1 -1
  114. package/dist/types/acp-validation.d.ts +87 -0
  115. package/dist/types/acp-validation.d.ts.map +1 -0
  116. package/dist/types/acp-validation.js +40 -0
  117. package/dist/types/acp-validation.js.map +1 -0
  118. package/dist/types/analytics.d.ts +182 -0
  119. package/dist/types/analytics.d.ts.map +1 -0
  120. package/dist/types/analytics.js +7 -0
  121. package/dist/types/analytics.js.map +1 -0
  122. package/dist/types/ucp-profile.d.ts +10 -2
  123. package/dist/types/ucp-profile.d.ts.map +1 -1
  124. package/dist/types/ucp-profile.js.map +1 -1
  125. package/dist/types/validation.d.ts +8 -0
  126. package/dist/types/validation.d.ts.map +1 -1
  127. package/dist/types/validation.js +10 -0
  128. package/dist/types/validation.js.map +1 -1
  129. package/dist/validator/acp/index.d.ts +31 -0
  130. package/dist/validator/acp/index.d.ts.map +1 -0
  131. package/dist/validator/acp/index.js +574 -0
  132. package/dist/validator/acp/index.js.map +1 -0
  133. package/dist/validator/network-validator.d.ts.map +1 -1
  134. package/dist/validator/network-validator.js +4 -4
  135. package/dist/validator/network-validator.js.map +1 -1
  136. package/dist/validator/rules-validator.d.ts +8 -0
  137. package/dist/validator/rules-validator.d.ts.map +1 -1
  138. package/dist/validator/rules-validator.js +92 -43
  139. package/dist/validator/rules-validator.js.map +1 -1
  140. package/dist/validator/structural-validator.d.ts.map +1 -1
  141. package/dist/validator/structural-validator.js +187 -53
  142. package/dist/validator/structural-validator.js.map +1 -1
  143. package/dist/validator/utils.d.ts +51 -0
  144. package/dist/validator/utils.d.ts.map +1 -0
  145. package/dist/validator/utils.js +132 -0
  146. package/dist/validator/utils.js.map +1 -0
  147. package/package.json +44 -12
  148. package/.claude/settings.local.json +0 -60
  149. package/.vercel/README.txt +0 -11
  150. package/.vercel/project.json +0 -1
  151. package/publish-output.txt +0 -0
  152. package/tsconfig.json +0 -20
@@ -0,0 +1,613 @@
1
+ "use strict";
2
+ /**
3
+ * Cron Service
4
+ *
5
+ * Handles scheduled tasks like weekly domain validation.
6
+ * Designed to be triggered by Vercel Cron, external scheduler, or manual API call.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getDomainsNeedingValidation = getDomainsNeedingValidation;
10
+ exports.runWeeklyValidation = runWeeklyValidation;
11
+ exports.getCronStats = getCronStats;
12
+ exports.runTrialEmailSequence = runTrialEmailSequence;
13
+ exports.runHostedProfileMaintenance = runHostedProfileMaintenance;
14
+ exports.runExpireTrials = runExpireTrials;
15
+ const index_js_1 = require("../db/index.js");
16
+ const schema_js_1 = require("../db/schema.js");
17
+ const drizzle_orm_1 = require("drizzle-orm");
18
+ const validation_history_js_1 = require("./validation-history.js");
19
+ const email_js_1 = require("./email.js");
20
+ const monitoring_diff_js_1 = require("./monitoring-diff.js");
21
+ const notifications_js_1 = require("./notifications.js");
22
+ const hosted_profiles_js_1 = require("./hosted-profiles.js");
23
+ /**
24
+ * Get all domains that need validation based on their monitoring frequency.
25
+ * - Must be active
26
+ * - User must have active or trialing subscription
27
+ * - Filters by frequency: daily → 24h threshold, weekly → 7d threshold
28
+ * - Never-checked domains are always included
29
+ */
30
+ async function getDomainsNeedingValidation() {
31
+ const db = (0, index_js_1.getDb)();
32
+ // Get all active domains with active/trialing subscriptions
33
+ const domains = await db
34
+ .select({
35
+ id: schema_js_1.monitoredDomains.id,
36
+ domain: schema_js_1.monitoredDomains.domain,
37
+ userId: schema_js_1.monitoredDomains.userId,
38
+ userEmail: schema_js_1.users.email,
39
+ userName: schema_js_1.users.name,
40
+ lastCheckedAt: schema_js_1.monitoredDomains.lastCheckedAt,
41
+ lastScore: schema_js_1.monitoredDomains.lastScore,
42
+ lastGrade: schema_js_1.monitoredDomains.lastGrade,
43
+ alertOnScoreChange: schema_js_1.monitoredDomains.alertOnScoreChange,
44
+ alertOnGradeChange: schema_js_1.monitoredDomains.alertOnGradeChange,
45
+ alertThreshold: schema_js_1.monitoredDomains.alertThreshold,
46
+ monitoringFrequency: schema_js_1.monitoredDomains.monitoringFrequency,
47
+ webhookUrl: schema_js_1.monitoredDomains.webhookUrl,
48
+ webhookEnabled: schema_js_1.monitoredDomains.webhookEnabled,
49
+ })
50
+ .from(schema_js_1.monitoredDomains)
51
+ .innerJoin(schema_js_1.users, (0, drizzle_orm_1.eq)(schema_js_1.monitoredDomains.userId, schema_js_1.users.id))
52
+ .innerJoin(schema_js_1.subscriptions, (0, drizzle_orm_1.eq)(schema_js_1.users.id, schema_js_1.subscriptions.userId))
53
+ .where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema_js_1.monitoredDomains.isActive, true), (0, drizzle_orm_1.or)((0, drizzle_orm_1.eq)(schema_js_1.subscriptions.status, 'active'), (0, drizzle_orm_1.eq)(schema_js_1.subscriptions.status, 'trialing'), (0, drizzle_orm_1.eq)(schema_js_1.subscriptions.status, 'expired'))));
54
+ // Filter in JS by frequency threshold
55
+ const now = Date.now();
56
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000;
57
+ const SEVEN_DAYS_MS = 7 * ONE_DAY_MS;
58
+ return domains.filter(d => {
59
+ // Never checked → always include
60
+ if (!d.lastCheckedAt)
61
+ return true;
62
+ const elapsed = now - new Date(d.lastCheckedAt).getTime();
63
+ const frequency = d.monitoringFrequency || 'weekly';
64
+ if (frequency === 'daily') {
65
+ return elapsed >= ONE_DAY_MS;
66
+ }
67
+ // weekly (default)
68
+ return elapsed >= SEVEN_DAYS_MS;
69
+ });
70
+ }
71
+ /**
72
+ * Run domain validation for all eligible domains (frequency-aware).
73
+ * Includes diff analysis, severity classification, and webhook dispatch.
74
+ *
75
+ * @param maxDomains - Maximum number of domains to process (for rate limiting)
76
+ * @param delayBetweenMs - Delay between validations in milliseconds
77
+ */
78
+ async function runWeeklyValidation(maxDomains = 100, delayBetweenMs = 1000) {
79
+ const startTime = Date.now();
80
+ const result = {
81
+ success: true,
82
+ domainsProcessed: 0,
83
+ domainsValidated: 0,
84
+ domainsFailed: 0,
85
+ alertsSent: 0,
86
+ alertsFailed: 0,
87
+ webhooksSent: 0,
88
+ errors: [],
89
+ durationMs: 0,
90
+ };
91
+ const dashboardBaseUrl = process.env.DASHBOARD_URL || 'https://ucptools.dev/dashboard';
92
+ try {
93
+ const domains = await getDomainsNeedingValidation();
94
+ const toProcess = domains.slice(0, maxDomains);
95
+ console.log(`[Cron] Found ${domains.length} domains needing validation, processing ${toProcess.length}`);
96
+ for (const domainInfo of toProcess) {
97
+ result.domainsProcessed++;
98
+ try {
99
+ console.log(`[Cron] Validating domain: ${domainInfo.domain}`);
100
+ // Run validation and store history
101
+ const { result: validationResult, historyEntry } = await (0, validation_history_js_1.validateAndStoreHistory)(domainInfo.id, domainInfo.domain);
102
+ result.domainsValidated++;
103
+ const newScore = validationResult.ai_readiness.score;
104
+ const newGrade = validationResult.ai_readiness.grade;
105
+ console.log(`[Cron] Successfully validated: ${domainInfo.domain} (score: ${newScore})`);
106
+ // ── Diff analysis ──────────────────────────────────────────
107
+ let diff = null;
108
+ const previousEntry = await (0, validation_history_js_1.getPreviousValidation)(domainInfo.id, historyEntry?.id);
109
+ if (previousEntry?.resultJson) {
110
+ try {
111
+ const previousResult = JSON.parse(previousEntry.resultJson);
112
+ diff = (0, monitoring_diff_js_1.diffValidationResults)(previousResult, validationResult, domainInfo.alertThreshold ?? 10);
113
+ // Store severity + changes summary on the history entry
114
+ if (historyEntry) {
115
+ await (0, validation_history_js_1.updateHistorySeverity)(historyEntry.id, diff.severity, JSON.stringify({ text: diff.summary, changes: diff.changes }));
116
+ }
117
+ // Update lastSeverity on the monitored domain
118
+ const db = (0, index_js_1.getDb)();
119
+ await db
120
+ .update(schema_js_1.monitoredDomains)
121
+ .set({ lastSeverity: diff.severity, updatedAt: new Date() })
122
+ .where((0, drizzle_orm_1.eq)(schema_js_1.monitoredDomains.id, domainInfo.id));
123
+ console.log(`[Cron] Diff for ${domainInfo.domain}: severity=${diff.severity}, changes=${diff.changes.length}`);
124
+ }
125
+ catch (diffError) {
126
+ console.error(`[Cron] Diff error for ${domainInfo.domain}:`, diffError);
127
+ }
128
+ }
129
+ // ── Severity-based alerting ────────────────────────────────
130
+ const severity = diff?.severity;
131
+ const dashboardUrl = `${dashboardBaseUrl}/domains/${domainInfo.id}`;
132
+ const shouldEmail = severity === 'broken'
133
+ || (severity === 'degraded' && (domainInfo.alertOnScoreChange || domainInfo.alertOnGradeChange))
134
+ || (!diff && domainInfo.alertOnScoreChange && domainInfo.lastScore !== null && Math.abs(newScore - domainInfo.lastScore) >= (domainInfo.alertThreshold ?? 10));
135
+ if (shouldEmail) {
136
+ try {
137
+ let emailResult;
138
+ // Use severity-aware template when we have diff data
139
+ if (diff && (severity === 'broken' || severity === 'degraded' || severity === 'changed')) {
140
+ emailResult = await (0, email_js_1.sendSeverityAlert)({
141
+ to: {
142
+ email: domainInfo.userEmail,
143
+ name: domainInfo.userName || undefined,
144
+ },
145
+ domain: domainInfo.domain,
146
+ severity,
147
+ oldScore: domainInfo.lastScore,
148
+ newScore,
149
+ oldGrade: domainInfo.lastGrade,
150
+ newGrade,
151
+ summary: diff.summary,
152
+ changes: diff.changes.map(c => ({
153
+ field: c.field,
154
+ type: c.type,
155
+ oldValue: c.oldValue,
156
+ newValue: c.newValue,
157
+ })),
158
+ dashboardUrl,
159
+ });
160
+ }
161
+ else {
162
+ // Fallback to basic score change alert
163
+ emailResult = await (0, email_js_1.sendScoreChangeAlert)({
164
+ to: {
165
+ email: domainInfo.userEmail,
166
+ name: domainInfo.userName || undefined,
167
+ },
168
+ domain: domainInfo.domain,
169
+ oldScore: domainInfo.lastScore ?? 0,
170
+ newScore,
171
+ oldGrade: domainInfo.lastGrade || 'F',
172
+ newGrade,
173
+ dashboardUrl,
174
+ });
175
+ }
176
+ if (emailResult.success) {
177
+ result.alertsSent++;
178
+ console.log(`[Cron] Alert sent to ${domainInfo.userEmail} (severity: ${severity || 'score-change'})`);
179
+ }
180
+ else {
181
+ result.alertsFailed++;
182
+ console.error(`[Cron] Failed to send alert: ${emailResult.error}`);
183
+ }
184
+ }
185
+ catch (emailError) {
186
+ result.alertsFailed++;
187
+ console.error(`[Cron] Email error:`, emailError);
188
+ }
189
+ }
190
+ // ── Webhook dispatch ───────────────────────────────────────
191
+ if (diff && diff.severity !== 'stable' && domainInfo.webhookEnabled && domainInfo.webhookUrl) {
192
+ const eventMap = {
193
+ broken: 'profile_broken',
194
+ degraded: 'profile_degraded',
195
+ changed: 'profile_changed',
196
+ };
197
+ const payload = {
198
+ event: eventMap[diff.severity] || 'profile_changed',
199
+ domain: domainInfo.domain,
200
+ severity: diff.severity,
201
+ oldScore: domainInfo.lastScore,
202
+ newScore,
203
+ oldGrade: domainInfo.lastGrade,
204
+ newGrade,
205
+ changes: diff.changes.map(c => ({
206
+ field: c.field,
207
+ type: c.type,
208
+ oldValue: c.oldValue,
209
+ newValue: c.newValue,
210
+ })),
211
+ summary: diff.summary,
212
+ timestamp: new Date().toISOString(),
213
+ dashboardUrl,
214
+ };
215
+ const sent = await (0, notifications_js_1.sendDomainWebhook)(domainInfo.webhookUrl, payload);
216
+ if (sent)
217
+ result.webhooksSent++;
218
+ }
219
+ }
220
+ catch (error) {
221
+ result.domainsFailed++;
222
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
223
+ result.errors.push({ domain: domainInfo.domain, error: errorMessage });
224
+ console.error(`[Cron] Failed to validate ${domainInfo.domain}:`, errorMessage);
225
+ }
226
+ // Add delay between validations to avoid overwhelming the system
227
+ if (delayBetweenMs > 0 && result.domainsProcessed < toProcess.length) {
228
+ await sleep(delayBetweenMs);
229
+ }
230
+ }
231
+ result.success = result.domainsFailed === 0;
232
+ }
233
+ catch (error) {
234
+ result.success = false;
235
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
236
+ result.errors.push({ domain: 'system', error: errorMessage });
237
+ console.error('[Cron] Domain validation failed:', errorMessage);
238
+ }
239
+ result.durationMs = Date.now() - startTime;
240
+ console.log(`[Cron] Completed: ${result.domainsValidated}/${result.domainsProcessed} validated, ${result.alertsSent} alerts, ${result.webhooksSent} webhooks in ${result.durationMs}ms`);
241
+ return result;
242
+ }
243
+ /**
244
+ * Get cron status/stats
245
+ */
246
+ async function getCronStats() {
247
+ const domains = await getDomainsNeedingValidation();
248
+ // Next run is typically handled by external scheduler
249
+ // For Vercel Cron, this would be configured in vercel.json
250
+ const nextRunAt = new Date();
251
+ nextRunAt.setDate(nextRunAt.getDate() + 7);
252
+ nextRunAt.setHours(0, 0, 0, 0);
253
+ return {
254
+ pendingDomains: domains.length,
255
+ lastRunAt: null, // Would need separate tracking for this
256
+ nextRunAt,
257
+ };
258
+ }
259
+ function sleep(ms) {
260
+ return new Promise(resolve => setTimeout(resolve, ms));
261
+ }
262
+ /**
263
+ * Send trial sequence emails to users
264
+ *
265
+ * - Day 3: Value reminder + Feature highlight
266
+ * - Day 6: Trial ending + Conversion CTA
267
+ *
268
+ * This should be run daily via cron job.
269
+ */
270
+ async function runTrialEmailSequence() {
271
+ const startTime = Date.now();
272
+ const result = {
273
+ success: true,
274
+ day1Sent: 0,
275
+ day1Failed: 0,
276
+ day3Sent: 0,
277
+ day3Failed: 0,
278
+ day6Sent: 0,
279
+ day6Failed: 0,
280
+ errors: [],
281
+ durationMs: 0,
282
+ };
283
+ const dashboardBaseUrl = process.env.DASHBOARD_URL || 'https://ucptools.dev/dashboard';
284
+ try {
285
+ const db = (0, index_js_1.getDb)();
286
+ // Get trialing users with their trial start dates
287
+ const trialingUsers = await db
288
+ .select({
289
+ userId: schema_js_1.users.id,
290
+ email: schema_js_1.users.email,
291
+ name: schema_js_1.users.name,
292
+ trialStartedAt: schema_js_1.subscriptions.createdAt,
293
+ currentPeriodEnd: schema_js_1.subscriptions.currentPeriodEnd,
294
+ })
295
+ .from(schema_js_1.subscriptions)
296
+ .innerJoin(schema_js_1.users, (0, drizzle_orm_1.eq)(schema_js_1.subscriptions.userId, schema_js_1.users.id))
297
+ .where((0, drizzle_orm_1.eq)(schema_js_1.subscriptions.status, 'trialing'));
298
+ console.log(`[Cron] Found ${trialingUsers.length} users in trial`);
299
+ const now = new Date();
300
+ for (const user of trialingUsers) {
301
+ if (!user.trialStartedAt)
302
+ continue;
303
+ const trialStart = new Date(user.trialStartedAt);
304
+ const daysSinceTrialStart = Math.floor((now.getTime() - trialStart.getTime()) / (1000 * 60 * 60 * 24));
305
+ // Get user's domain count for personalization
306
+ const domainCount = await db
307
+ .select({ count: schema_js_1.monitoredDomains.id })
308
+ .from(schema_js_1.monitoredDomains)
309
+ .where((0, drizzle_orm_1.eq)(schema_js_1.monitoredDomains.userId, user.userId))
310
+ .then((rows) => rows.length);
311
+ // Day 1 email - Quick Start Guide
312
+ if (daysSinceTrialStart === 1) {
313
+ try {
314
+ console.log(`[Cron] Sending Day 1 email to ${user.email}`);
315
+ const emailResult = await (0, email_js_1.sendTrialDay1Email)({
316
+ to: {
317
+ email: user.email,
318
+ name: user.name || undefined,
319
+ },
320
+ dashboardUrl: dashboardBaseUrl,
321
+ });
322
+ if (emailResult.success) {
323
+ result.day1Sent++;
324
+ console.log(`[Cron] Day 1 email sent to ${user.email}`);
325
+ }
326
+ else {
327
+ result.day1Failed++;
328
+ result.errors.push({
329
+ userId: user.userId,
330
+ email: user.email,
331
+ error: emailResult.error || 'Unknown error',
332
+ });
333
+ }
334
+ }
335
+ catch (error) {
336
+ result.day1Failed++;
337
+ result.errors.push({
338
+ userId: user.userId,
339
+ email: user.email,
340
+ error: error instanceof Error ? error.message : 'Unknown error',
341
+ });
342
+ }
343
+ }
344
+ // Day 3 email (send on day 3)
345
+ if (daysSinceTrialStart === 3) {
346
+ try {
347
+ console.log(`[Cron] Sending Day 3 email to ${user.email}`);
348
+ const emailResult = await (0, email_js_1.sendTrialDay3Email)({
349
+ to: {
350
+ email: user.email,
351
+ name: user.name || undefined,
352
+ },
353
+ dashboardUrl: dashboardBaseUrl,
354
+ domainsAdded: domainCount,
355
+ });
356
+ if (emailResult.success) {
357
+ result.day3Sent++;
358
+ console.log(`[Cron] Day 3 email sent to ${user.email}`);
359
+ }
360
+ else {
361
+ result.day3Failed++;
362
+ result.errors.push({
363
+ userId: user.userId,
364
+ email: user.email,
365
+ error: emailResult.error || 'Unknown error',
366
+ });
367
+ }
368
+ }
369
+ catch (error) {
370
+ result.day3Failed++;
371
+ result.errors.push({
372
+ userId: user.userId,
373
+ email: user.email,
374
+ error: error instanceof Error ? error.message : 'Unknown error',
375
+ });
376
+ }
377
+ }
378
+ // Day 6 email (send on day 6)
379
+ if (daysSinceTrialStart === 6) {
380
+ try {
381
+ console.log(`[Cron] Sending Day 6 email to ${user.email}`);
382
+ // Get validation count for this user
383
+ const validationCount = await db
384
+ .select({ count: schema_js_1.monitoredDomains.id })
385
+ .from(schema_js_1.monitoredDomains)
386
+ .where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema_js_1.monitoredDomains.userId, user.userId),
387
+ // Has been validated at least once
388
+ (0, drizzle_orm_1.lt)(schema_js_1.monitoredDomains.lastCheckedAt, now)))
389
+ .then((rows) => rows.length);
390
+ const emailResult = await (0, email_js_1.sendTrialDay6Email)({
391
+ to: {
392
+ email: user.email,
393
+ name: user.name || undefined,
394
+ },
395
+ dashboardUrl: dashboardBaseUrl,
396
+ domainsAdded: domainCount,
397
+ validationsRun: validationCount,
398
+ });
399
+ if (emailResult.success) {
400
+ result.day6Sent++;
401
+ console.log(`[Cron] Day 6 email sent to ${user.email}`);
402
+ }
403
+ else {
404
+ result.day6Failed++;
405
+ result.errors.push({
406
+ userId: user.userId,
407
+ email: user.email,
408
+ error: emailResult.error || 'Unknown error',
409
+ });
410
+ }
411
+ }
412
+ catch (error) {
413
+ result.day6Failed++;
414
+ result.errors.push({
415
+ userId: user.userId,
416
+ email: user.email,
417
+ error: error instanceof Error ? error.message : 'Unknown error',
418
+ });
419
+ }
420
+ }
421
+ // Small delay between emails to avoid rate limits
422
+ await sleep(100);
423
+ }
424
+ result.success =
425
+ result.day1Failed === 0 && result.day3Failed === 0 && result.day6Failed === 0;
426
+ }
427
+ catch (error) {
428
+ result.success = false;
429
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
430
+ result.errors.push({ userId: 'system', email: '', error: errorMessage });
431
+ console.error('[Cron] Trial email sequence failed:', errorMessage);
432
+ }
433
+ result.durationMs = Date.now() - startTime;
434
+ console.log(`[Cron] Trial emails completed: Day 1: ${result.day1Sent}, Day 3: ${result.day3Sent}, Day 6: ${result.day6Sent} sent in ${result.durationMs}ms`);
435
+ return result;
436
+ }
437
+ /**
438
+ * Run validation on active hosted profiles that haven't been validated in 7+ days.
439
+ * Also checks pending DNS verifications.
440
+ */
441
+ async function runHostedProfileMaintenance(maxProfiles = 100, delayBetweenMs = 500) {
442
+ const startTime = Date.now();
443
+ const result = {
444
+ success: true,
445
+ profilesValidated: 0,
446
+ profilesFailed: 0,
447
+ verificationsChecked: 0,
448
+ verificationsConfirmed: 0,
449
+ errors: [],
450
+ durationMs: 0,
451
+ };
452
+ try {
453
+ // 1. Re-validate active profiles needing validation
454
+ const profilesToValidate = await (0, hosted_profiles_js_1.getProfilesNeedingValidation)(maxProfiles);
455
+ console.log(`[Cron] Found ${profilesToValidate.length} hosted profiles needing validation`);
456
+ for (const profile of profilesToValidate) {
457
+ try {
458
+ await (0, hosted_profiles_js_1.validateHostedProfile)(profile.id);
459
+ result.profilesValidated++;
460
+ }
461
+ catch (error) {
462
+ result.profilesFailed++;
463
+ result.errors.push({
464
+ profileId: profile.id,
465
+ error: error instanceof Error ? error.message : 'Unknown error',
466
+ });
467
+ }
468
+ if (delayBetweenMs > 0) {
469
+ await sleep(delayBetweenMs);
470
+ }
471
+ }
472
+ // 2. Check pending verifications
473
+ const pendingVerifications = await (0, hosted_profiles_js_1.getProfilesPendingVerification)(50);
474
+ console.log(`[Cron] Found ${pendingVerifications.length} profiles pending DNS verification`);
475
+ for (const profile of pendingVerifications) {
476
+ result.verificationsChecked++;
477
+ try {
478
+ const check = await (0, hosted_profiles_js_1.checkDnsVerification)(profile.id);
479
+ if (check.verified) {
480
+ result.verificationsConfirmed++;
481
+ console.log(`[Cron] DNS verified for ${profile.domain}`);
482
+ }
483
+ }
484
+ catch (error) {
485
+ result.errors.push({
486
+ profileId: profile.id,
487
+ error: error instanceof Error ? error.message : 'DNS check failed',
488
+ });
489
+ }
490
+ if (delayBetweenMs > 0) {
491
+ await sleep(delayBetweenMs);
492
+ }
493
+ }
494
+ result.success = result.profilesFailed === 0;
495
+ }
496
+ catch (error) {
497
+ result.success = false;
498
+ result.errors.push({
499
+ profileId: 'system',
500
+ error: error instanceof Error ? error.message : 'Unknown error',
501
+ });
502
+ console.error('[Cron] Hosted profile maintenance failed:', error);
503
+ }
504
+ result.durationMs = Date.now() - startTime;
505
+ console.log(`[Cron] Hosted profile maintenance: ${result.profilesValidated} validated, ${result.verificationsConfirmed}/${result.verificationsChecked} DNS verified in ${result.durationMs}ms`);
506
+ return result;
507
+ }
508
+ /**
509
+ * Expire trials that have passed their currentPeriodEnd date.
510
+ *
511
+ * Downgrades users from trialing/starter → canceled/free.
512
+ * Sends a "trial expired" email with upgrade CTA.
513
+ *
514
+ * Should be run daily via cron job (same schedule as trial-emails).
515
+ */
516
+ async function runExpireTrials() {
517
+ const startTime = Date.now();
518
+ const result = {
519
+ success: true,
520
+ expired: 0,
521
+ emailsSent: 0,
522
+ emailsFailed: 0,
523
+ errors: [],
524
+ durationMs: 0,
525
+ };
526
+ const dashboardBaseUrl = process.env.DASHBOARD_URL || 'https://ucptools.dev/dashboard';
527
+ try {
528
+ const db = (0, index_js_1.getDb)();
529
+ const now = new Date();
530
+ // Find all trialing subscriptions where currentPeriodEnd has passed
531
+ const expiredTrials = await db
532
+ .select({
533
+ userId: schema_js_1.subscriptions.userId,
534
+ currentPeriodEnd: schema_js_1.subscriptions.currentPeriodEnd,
535
+ userEmail: schema_js_1.users.email,
536
+ userName: schema_js_1.users.name,
537
+ })
538
+ .from(schema_js_1.subscriptions)
539
+ .innerJoin(schema_js_1.users, (0, drizzle_orm_1.eq)(schema_js_1.subscriptions.userId, schema_js_1.users.id))
540
+ .where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema_js_1.subscriptions.status, 'trialing'), (0, drizzle_orm_1.lt)(schema_js_1.subscriptions.currentPeriodEnd, now)));
541
+ console.log(`[Cron] Found ${expiredTrials.length} expired trials to downgrade`);
542
+ for (const trial of expiredTrials) {
543
+ try {
544
+ // Expire trial — keep tier so monitoring continues, set status to expired
545
+ await db
546
+ .update(schema_js_1.subscriptions)
547
+ .set({
548
+ status: 'expired',
549
+ updatedAt: new Date(),
550
+ })
551
+ .where((0, drizzle_orm_1.eq)(schema_js_1.subscriptions.userId, trial.userId));
552
+ result.expired++;
553
+ console.log(`[Cron] Expired trial for user ${trial.userId} (${trial.userEmail})`);
554
+ // Get domain count for email personalization
555
+ const domainCount = await db
556
+ .select({ id: schema_js_1.monitoredDomains.id })
557
+ .from(schema_js_1.monitoredDomains)
558
+ .where((0, drizzle_orm_1.eq)(schema_js_1.monitoredDomains.userId, trial.userId))
559
+ .then((rows) => rows.length);
560
+ // Send trial expired email
561
+ try {
562
+ const emailResult = await (0, email_js_1.sendTrialExpiredEmail)({
563
+ to: {
564
+ email: trial.userEmail,
565
+ name: trial.userName || undefined,
566
+ },
567
+ dashboardUrl: dashboardBaseUrl,
568
+ domainsAdded: domainCount,
569
+ });
570
+ if (emailResult.success) {
571
+ result.emailsSent++;
572
+ console.log(`[Cron] Trial expired email sent to ${trial.userEmail}`);
573
+ }
574
+ else {
575
+ result.emailsFailed++;
576
+ result.errors.push({
577
+ userId: trial.userId,
578
+ error: `Email failed: ${emailResult.error}`,
579
+ });
580
+ }
581
+ }
582
+ catch (emailError) {
583
+ result.emailsFailed++;
584
+ result.errors.push({
585
+ userId: trial.userId,
586
+ error: `Email error: ${emailError instanceof Error ? emailError.message : 'Unknown'}`,
587
+ });
588
+ }
589
+ }
590
+ catch (error) {
591
+ result.errors.push({
592
+ userId: trial.userId,
593
+ error: error instanceof Error ? error.message : 'Unknown error',
594
+ });
595
+ console.error(`[Cron] Failed to expire trial for ${trial.userId}:`, error);
596
+ }
597
+ await sleep(100);
598
+ }
599
+ result.success = result.errors.length === 0;
600
+ }
601
+ catch (error) {
602
+ result.success = false;
603
+ result.errors.push({
604
+ userId: 'system',
605
+ error: error instanceof Error ? error.message : 'Unknown error',
606
+ });
607
+ console.error('[Cron] Trial expiration failed:', error);
608
+ }
609
+ result.durationMs = Date.now() - startTime;
610
+ console.log(`[Cron] Trial expiration completed: ${result.expired} expired, ${result.emailsSent} emails sent in ${result.durationMs}ms`);
611
+ return result;
612
+ }
613
+ //# sourceMappingURL=cron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.js","sourceRoot":"","sources":["../../src/services/cron.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAoDH,kEAqDC;AASD,kDA6LC;AAKD,oCAkBC;AA6BD,sDA0LC;AAoBD,kEA6EC;AAuBD,0CAgHC;AAnwBD,6CAAuC;AACvC,+CAAyE;AACzE,6CAA8C;AAC9C,mEAAgH;AAChH,yCAAwJ;AACxJ,6DAA+E;AAC/E,yDAA4E;AAC5E,6DAK8B;AA+B9B;;;;;;GAMG;AACI,KAAK,UAAU,2BAA2B;IAC/C,MAAM,EAAE,GAAG,IAAA,gBAAK,GAAE,CAAC;IAEnB,4DAA4D;IAC5D,MAAM,OAAO,GAAG,MAAM,EAAE;SACrB,MAAM,CAAC;QACN,EAAE,EAAE,4BAAgB,CAAC,EAAE;QACvB,MAAM,EAAE,4BAAgB,CAAC,MAAM;QAC/B,MAAM,EAAE,4BAAgB,CAAC,MAAM;QAC/B,SAAS,EAAE,iBAAK,CAAC,KAAK;QACtB,QAAQ,EAAE,iBAAK,CAAC,IAAI;QACpB,aAAa,EAAE,4BAAgB,CAAC,aAAa;QAC7C,SAAS,EAAE,4BAAgB,CAAC,SAAS;QACrC,SAAS,EAAE,4BAAgB,CAAC,SAAS;QACrC,kBAAkB,EAAE,4BAAgB,CAAC,kBAAkB;QACvD,kBAAkB,EAAE,4BAAgB,CAAC,kBAAkB;QACvD,cAAc,EAAE,4BAAgB,CAAC,cAAc;QAC/C,mBAAmB,EAAE,4BAAgB,CAAC,mBAAmB;QACzD,UAAU,EAAE,4BAAgB,CAAC,UAAU;QACvC,cAAc,EAAE,4BAAgB,CAAC,cAAc;KAChD,CAAC;SACD,IAAI,CAAC,4BAAgB,CAAC;SACtB,SAAS,CAAC,iBAAK,EAAE,IAAA,gBAAE,EAAC,4BAAgB,CAAC,MAAM,EAAE,iBAAK,CAAC,EAAE,CAAC,CAA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12
+ grades?: string;
12
13
  sort?: 'score' | 'domain' | 'displayName' | 'createdAt';
13
14
  order?: 'asc' | 'desc';
14
15
  }
@@ -68,6 +69,7 @@ export interface ValidationResult {
68
69
  grade?: string;
69
70
  transports?: string;
70
71
  ucpVersion?: string;
72
+ profileUrl?: string;
71
73
  }
72
74
  /**
73
75
  * Validate a domain's UCP profile