@agenticmail/enterprise 0.2.1

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 (69) hide show
  1. package/ARCHITECTURE.md +183 -0
  2. package/agenticmail-enterprise.db +0 -0
  3. package/dashboards/README.md +120 -0
  4. package/dashboards/dotnet/Program.cs +261 -0
  5. package/dashboards/express/app.js +146 -0
  6. package/dashboards/go/main.go +513 -0
  7. package/dashboards/html/index.html +535 -0
  8. package/dashboards/java/AgenticMailDashboard.java +376 -0
  9. package/dashboards/php/index.php +414 -0
  10. package/dashboards/python/app.py +273 -0
  11. package/dashboards/ruby/app.rb +195 -0
  12. package/dist/chunk-77IDQJL3.js +7 -0
  13. package/dist/chunk-7RGCCHIT.js +115 -0
  14. package/dist/chunk-DXNKR3TG.js +1355 -0
  15. package/dist/chunk-IQWA44WT.js +970 -0
  16. package/dist/chunk-LCUZGIDH.js +965 -0
  17. package/dist/chunk-N2JVTNNJ.js +2553 -0
  18. package/dist/chunk-O462UJBH.js +363 -0
  19. package/dist/chunk-PNKVD2UK.js +26 -0
  20. package/dist/cli.js +218 -0
  21. package/dist/dashboard/index.html +558 -0
  22. package/dist/db-adapter-DEWEFNIV.js +7 -0
  23. package/dist/dynamodb-CCGL2E77.js +426 -0
  24. package/dist/engine/index.js +1261 -0
  25. package/dist/index.js +522 -0
  26. package/dist/mongodb-ODTXIVPV.js +319 -0
  27. package/dist/mysql-RM3S2FV5.js +521 -0
  28. package/dist/postgres-LN7A6MGQ.js +518 -0
  29. package/dist/routes-2JEPIIKC.js +441 -0
  30. package/dist/routes-74ZLKJKP.js +399 -0
  31. package/dist/server.js +7 -0
  32. package/dist/sqlite-3K5YOZ4K.js +439 -0
  33. package/dist/turso-LDWODSDI.js +442 -0
  34. package/package.json +49 -0
  35. package/src/admin/routes.ts +331 -0
  36. package/src/auth/routes.ts +130 -0
  37. package/src/cli.ts +260 -0
  38. package/src/dashboard/index.html +558 -0
  39. package/src/db/adapter.ts +230 -0
  40. package/src/db/dynamodb.ts +456 -0
  41. package/src/db/factory.ts +51 -0
  42. package/src/db/mongodb.ts +360 -0
  43. package/src/db/mysql.ts +472 -0
  44. package/src/db/postgres.ts +479 -0
  45. package/src/db/sql-schema.ts +123 -0
  46. package/src/db/sqlite.ts +391 -0
  47. package/src/db/turso.ts +411 -0
  48. package/src/deploy/fly.ts +368 -0
  49. package/src/deploy/managed.ts +213 -0
  50. package/src/engine/activity.ts +474 -0
  51. package/src/engine/agent-config.ts +429 -0
  52. package/src/engine/agenticmail-bridge.ts +296 -0
  53. package/src/engine/approvals.ts +278 -0
  54. package/src/engine/db-adapter.ts +682 -0
  55. package/src/engine/db-schema.ts +335 -0
  56. package/src/engine/deployer.ts +595 -0
  57. package/src/engine/index.ts +134 -0
  58. package/src/engine/knowledge.ts +486 -0
  59. package/src/engine/lifecycle.ts +635 -0
  60. package/src/engine/openclaw-hook.ts +371 -0
  61. package/src/engine/routes.ts +528 -0
  62. package/src/engine/skills.ts +473 -0
  63. package/src/engine/tenant.ts +345 -0
  64. package/src/engine/tool-catalog.ts +189 -0
  65. package/src/index.ts +64 -0
  66. package/src/lib/resilience.ts +326 -0
  67. package/src/middleware/index.ts +286 -0
  68. package/src/server.ts +310 -0
  69. package/tsconfig.json +14 -0
@@ -0,0 +1,518 @@
1
+ import {
2
+ getAllCreateStatements
3
+ } from "./chunk-7RGCCHIT.js";
4
+ import {
5
+ DatabaseAdapter
6
+ } from "./chunk-77IDQJL3.js";
7
+ import "./chunk-PNKVD2UK.js";
8
+
9
+ // src/db/postgres.ts
10
+ import { randomUUID, createHash } from "crypto";
11
+ var pg;
12
+ async function getPg() {
13
+ if (!pg) {
14
+ try {
15
+ pg = await import("pg");
16
+ } catch {
17
+ throw new Error(
18
+ "PostgreSQL driver not found. Install it: npm install pg\nFor Supabase/Neon/CockroachDB, the same pg driver works."
19
+ );
20
+ }
21
+ }
22
+ return pg;
23
+ }
24
+ var PostgresAdapter = class extends DatabaseAdapter {
25
+ type = "postgres";
26
+ pool = null;
27
+ async connect(config) {
28
+ const { Pool } = await getPg();
29
+ this.pool = new Pool({
30
+ connectionString: config.connectionString,
31
+ host: config.host,
32
+ port: config.port,
33
+ database: config.database,
34
+ user: config.username,
35
+ password: config.password,
36
+ ssl: config.ssl ? { rejectUnauthorized: false } : void 0,
37
+ max: 20,
38
+ idleTimeoutMillis: 3e4
39
+ });
40
+ const client = await this.pool.connect();
41
+ client.release();
42
+ }
43
+ async disconnect() {
44
+ if (this.pool) await this.pool.end();
45
+ }
46
+ isConnected() {
47
+ return this.pool !== null;
48
+ }
49
+ async migrate() {
50
+ const stmts = getAllCreateStatements();
51
+ const client = await this.pool.connect();
52
+ try {
53
+ await client.query("BEGIN");
54
+ for (const stmt of stmts) {
55
+ await client.query(stmt);
56
+ }
57
+ await client.query(`
58
+ INSERT INTO retention_policy (id) VALUES ('default')
59
+ ON CONFLICT (id) DO NOTHING
60
+ `);
61
+ await client.query("COMMIT");
62
+ } catch (err) {
63
+ await client.query("ROLLBACK");
64
+ throw err;
65
+ } finally {
66
+ client.release();
67
+ }
68
+ }
69
+ // ─── Company ─────────────────────────────────────────────
70
+ async getSettings() {
71
+ const { rows } = await this.pool.query(
72
+ "SELECT * FROM company_settings WHERE id = $1",
73
+ ["default"]
74
+ );
75
+ return rows[0] ? this.mapSettings(rows[0]) : null;
76
+ }
77
+ async updateSettings(updates) {
78
+ const fields = [];
79
+ const values = [];
80
+ let i = 1;
81
+ const map = {
82
+ name: "name",
83
+ domain: "domain",
84
+ subdomain: "subdomain",
85
+ smtpHost: "smtp_host",
86
+ smtpPort: "smtp_port",
87
+ smtpUser: "smtp_user",
88
+ smtpPass: "smtp_pass",
89
+ dkimPrivateKey: "dkim_private_key",
90
+ logoUrl: "logo_url",
91
+ primaryColor: "primary_color",
92
+ plan: "plan"
93
+ };
94
+ for (const [key, col] of Object.entries(map)) {
95
+ if (updates[key] !== void 0) {
96
+ fields.push(`${col} = $${i}`);
97
+ values.push(updates[key]);
98
+ i++;
99
+ }
100
+ }
101
+ fields.push(`updated_at = NOW()`);
102
+ values.push("default");
103
+ const { rows } = await this.pool.query(
104
+ `UPDATE company_settings SET ${fields.join(", ")} WHERE id = $${i} RETURNING *`,
105
+ values
106
+ );
107
+ return this.mapSettings(rows[0]);
108
+ }
109
+ // ─── Agents ──────────────────────────────────────────────
110
+ async createAgent(input) {
111
+ const id = randomUUID();
112
+ const email = input.email || `${input.name.toLowerCase().replace(/\s+/g, "-")}@localhost`;
113
+ const { rows } = await this.pool.query(
114
+ `INSERT INTO agents (id, name, email, role, metadata, created_by)
115
+ VALUES ($1, $2, $3, $4, $5, $6) RETURNING *`,
116
+ [id, input.name, email, input.role || "assistant", JSON.stringify(input.metadata || {}), input.createdBy]
117
+ );
118
+ return this.mapAgent(rows[0]);
119
+ }
120
+ async getAgent(id) {
121
+ const { rows } = await this.pool.query("SELECT * FROM agents WHERE id = $1", [id]);
122
+ return rows[0] ? this.mapAgent(rows[0]) : null;
123
+ }
124
+ async getAgentByName(name) {
125
+ const { rows } = await this.pool.query("SELECT * FROM agents WHERE name = $1", [name]);
126
+ return rows[0] ? this.mapAgent(rows[0]) : null;
127
+ }
128
+ async listAgents(opts) {
129
+ let q = "SELECT * FROM agents";
130
+ const params = [];
131
+ if (opts?.status) {
132
+ q += " WHERE status = $1";
133
+ params.push(opts.status);
134
+ }
135
+ q += " ORDER BY created_at DESC";
136
+ if (opts?.limit) {
137
+ q += ` LIMIT ${opts.limit}`;
138
+ }
139
+ if (opts?.offset) {
140
+ q += ` OFFSET ${opts.offset}`;
141
+ }
142
+ const { rows } = await this.pool.query(q, params);
143
+ return rows.map((r) => this.mapAgent(r));
144
+ }
145
+ async updateAgent(id, updates) {
146
+ const fields = [];
147
+ const values = [];
148
+ let i = 1;
149
+ for (const [key, col] of Object.entries({ name: "name", email: "email", role: "role", status: "status" })) {
150
+ if (updates[key] !== void 0) {
151
+ fields.push(`${col} = $${i}`);
152
+ values.push(updates[key]);
153
+ i++;
154
+ }
155
+ }
156
+ if (updates.metadata) {
157
+ fields.push(`metadata = $${i}`);
158
+ values.push(JSON.stringify(updates.metadata));
159
+ i++;
160
+ }
161
+ fields.push("updated_at = NOW()");
162
+ values.push(id);
163
+ const { rows } = await this.pool.query(
164
+ `UPDATE agents SET ${fields.join(", ")} WHERE id = $${i} RETURNING *`,
165
+ values
166
+ );
167
+ return this.mapAgent(rows[0]);
168
+ }
169
+ async archiveAgent(id) {
170
+ await this.pool.query("UPDATE agents SET status = 'archived', updated_at = NOW() WHERE id = $1", [id]);
171
+ }
172
+ async deleteAgent(id) {
173
+ await this.pool.query("DELETE FROM agents WHERE id = $1", [id]);
174
+ }
175
+ async countAgents(status) {
176
+ const q = status ? await this.pool.query("SELECT COUNT(*) FROM agents WHERE status = $1", [status]) : await this.pool.query("SELECT COUNT(*) FROM agents");
177
+ return parseInt(q.rows[0].count, 10);
178
+ }
179
+ // ─── Users ───────────────────────────────────────────────
180
+ async createUser(input) {
181
+ const id = randomUUID();
182
+ let passwordHash = null;
183
+ if (input.password) {
184
+ const { default: bcrypt } = await import("bcryptjs");
185
+ passwordHash = await bcrypt.hash(input.password, 12);
186
+ }
187
+ const { rows } = await this.pool.query(
188
+ `INSERT INTO users (id, email, name, role, password_hash, sso_provider, sso_subject)
189
+ VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *`,
190
+ [id, input.email, input.name, input.role, passwordHash, input.ssoProvider || null, input.ssoSubject || null]
191
+ );
192
+ return this.mapUser(rows[0]);
193
+ }
194
+ async getUser(id) {
195
+ const { rows } = await this.pool.query("SELECT * FROM users WHERE id = $1", [id]);
196
+ return rows[0] ? this.mapUser(rows[0]) : null;
197
+ }
198
+ async getUserByEmail(email) {
199
+ const { rows } = await this.pool.query("SELECT * FROM users WHERE email = $1", [email]);
200
+ return rows[0] ? this.mapUser(rows[0]) : null;
201
+ }
202
+ async getUserBySso(provider, subject) {
203
+ const { rows } = await this.pool.query(
204
+ "SELECT * FROM users WHERE sso_provider = $1 AND sso_subject = $2",
205
+ [provider, subject]
206
+ );
207
+ return rows[0] ? this.mapUser(rows[0]) : null;
208
+ }
209
+ async listUsers(opts) {
210
+ let q = "SELECT * FROM users ORDER BY created_at DESC";
211
+ if (opts?.limit) q += ` LIMIT ${opts.limit}`;
212
+ if (opts?.offset) q += ` OFFSET ${opts.offset}`;
213
+ const { rows } = await this.pool.query(q);
214
+ return rows.map((r) => this.mapUser(r));
215
+ }
216
+ async updateUser(id, updates) {
217
+ const fields = [];
218
+ const values = [];
219
+ let i = 1;
220
+ for (const key of ["email", "name", "role", "sso_provider", "sso_subject"]) {
221
+ const camelKey = key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
222
+ if (updates[camelKey] !== void 0) {
223
+ fields.push(`${key} = $${i}`);
224
+ values.push(updates[camelKey]);
225
+ i++;
226
+ }
227
+ }
228
+ fields.push("updated_at = NOW()");
229
+ values.push(id);
230
+ const { rows } = await this.pool.query(
231
+ `UPDATE users SET ${fields.join(", ")} WHERE id = $${i} RETURNING *`,
232
+ values
233
+ );
234
+ return this.mapUser(rows[0]);
235
+ }
236
+ async deleteUser(id) {
237
+ await this.pool.query("DELETE FROM users WHERE id = $1", [id]);
238
+ }
239
+ // ─── Audit ───────────────────────────────────────────────
240
+ async logEvent(event) {
241
+ await this.pool.query(
242
+ `INSERT INTO audit_log (id, actor, actor_type, action, resource, details, ip)
243
+ VALUES ($1, $2, $3, $4, $5, $6, $7)`,
244
+ [
245
+ randomUUID(),
246
+ event.actor,
247
+ event.actorType,
248
+ event.action,
249
+ event.resource,
250
+ JSON.stringify(event.details || {}),
251
+ event.ip || null
252
+ ]
253
+ );
254
+ }
255
+ async queryAudit(filters) {
256
+ const where = [];
257
+ const params = [];
258
+ let i = 1;
259
+ if (filters.actor) {
260
+ where.push(`actor = $${i++}`);
261
+ params.push(filters.actor);
262
+ }
263
+ if (filters.action) {
264
+ where.push(`action = $${i++}`);
265
+ params.push(filters.action);
266
+ }
267
+ if (filters.resource) {
268
+ where.push(`resource LIKE $${i++}`);
269
+ params.push(`%${filters.resource}%`);
270
+ }
271
+ if (filters.from) {
272
+ where.push(`timestamp >= $${i++}`);
273
+ params.push(filters.from);
274
+ }
275
+ if (filters.to) {
276
+ where.push(`timestamp <= $${i++}`);
277
+ params.push(filters.to);
278
+ }
279
+ const whereClause = where.length > 0 ? `WHERE ${where.join(" AND ")}` : "";
280
+ const countResult = await this.pool.query(`SELECT COUNT(*) FROM audit_log ${whereClause}`, params);
281
+ const total = parseInt(countResult.rows[0].count, 10);
282
+ let q = `SELECT * FROM audit_log ${whereClause} ORDER BY timestamp DESC`;
283
+ if (filters.limit) q += ` LIMIT ${filters.limit}`;
284
+ if (filters.offset) q += ` OFFSET ${filters.offset}`;
285
+ const { rows } = await this.pool.query(q, params);
286
+ return {
287
+ events: rows.map((r) => ({
288
+ id: r.id,
289
+ timestamp: r.timestamp,
290
+ actor: r.actor,
291
+ actorType: r.actor_type,
292
+ action: r.action,
293
+ resource: r.resource,
294
+ details: JSON.parse(r.details || "{}"),
295
+ ip: r.ip
296
+ })),
297
+ total
298
+ };
299
+ }
300
+ // ─── API Keys ────────────────────────────────────────────
301
+ async createApiKey(input) {
302
+ const id = randomUUID();
303
+ const plaintext = `ek_${randomUUID().replace(/-/g, "")}`;
304
+ const keyHash = createHash("sha256").update(plaintext).digest("hex");
305
+ const keyPrefix = plaintext.substring(0, 11);
306
+ const { rows } = await this.pool.query(
307
+ `INSERT INTO api_keys (id, name, key_hash, key_prefix, scopes, created_by, expires_at)
308
+ VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *`,
309
+ [id, input.name, keyHash, keyPrefix, JSON.stringify(input.scopes), input.createdBy, input.expiresAt || null]
310
+ );
311
+ return { key: this.mapApiKey(rows[0]), plaintext };
312
+ }
313
+ async getApiKey(id) {
314
+ const { rows } = await this.pool.query("SELECT * FROM api_keys WHERE id = $1", [id]);
315
+ return rows[0] ? this.mapApiKey(rows[0]) : null;
316
+ }
317
+ async validateApiKey(plaintext) {
318
+ const keyHash = createHash("sha256").update(plaintext).digest("hex");
319
+ const { rows } = await this.pool.query(
320
+ "SELECT * FROM api_keys WHERE key_hash = $1 AND revoked = 0",
321
+ [keyHash]
322
+ );
323
+ if (!rows[0]) return null;
324
+ const key = this.mapApiKey(rows[0]);
325
+ if (key.expiresAt && /* @__PURE__ */ new Date() > key.expiresAt) return null;
326
+ await this.pool.query("UPDATE api_keys SET last_used_at = NOW() WHERE id = $1", [key.id]);
327
+ return key;
328
+ }
329
+ async listApiKeys(opts) {
330
+ let q = "SELECT * FROM api_keys";
331
+ const params = [];
332
+ if (opts?.createdBy) {
333
+ q += " WHERE created_by = $1";
334
+ params.push(opts.createdBy);
335
+ }
336
+ q += " ORDER BY created_at DESC";
337
+ const { rows } = await this.pool.query(q, params);
338
+ return rows.map((r) => this.mapApiKey(r));
339
+ }
340
+ async revokeApiKey(id) {
341
+ await this.pool.query("UPDATE api_keys SET revoked = 1 WHERE id = $1", [id]);
342
+ }
343
+ // ─── Rules ───────────────────────────────────────────────
344
+ async createRule(rule) {
345
+ const id = randomUUID();
346
+ const { rows } = await this.pool.query(
347
+ `INSERT INTO email_rules (id, name, agent_id, conditions, actions, priority, enabled)
348
+ VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING *`,
349
+ [
350
+ id,
351
+ rule.name,
352
+ rule.agentId || null,
353
+ JSON.stringify(rule.conditions),
354
+ JSON.stringify(rule.actions),
355
+ rule.priority,
356
+ rule.enabled ? 1 : 0
357
+ ]
358
+ );
359
+ return this.mapRule(rows[0]);
360
+ }
361
+ async getRules(agentId) {
362
+ let q = "SELECT * FROM email_rules";
363
+ const params = [];
364
+ if (agentId) {
365
+ q += " WHERE agent_id = $1 OR agent_id IS NULL";
366
+ params.push(agentId);
367
+ }
368
+ q += " ORDER BY priority DESC";
369
+ const { rows } = await this.pool.query(q, params);
370
+ return rows.map((r) => this.mapRule(r));
371
+ }
372
+ async updateRule(id, updates) {
373
+ const fields = [];
374
+ const values = [];
375
+ let i = 1;
376
+ if (updates.name !== void 0) {
377
+ fields.push(`name = $${i++}`);
378
+ values.push(updates.name);
379
+ }
380
+ if (updates.conditions) {
381
+ fields.push(`conditions = $${i++}`);
382
+ values.push(JSON.stringify(updates.conditions));
383
+ }
384
+ if (updates.actions) {
385
+ fields.push(`actions = $${i++}`);
386
+ values.push(JSON.stringify(updates.actions));
387
+ }
388
+ if (updates.priority !== void 0) {
389
+ fields.push(`priority = $${i++}`);
390
+ values.push(updates.priority);
391
+ }
392
+ if (updates.enabled !== void 0) {
393
+ fields.push(`enabled = $${i++}`);
394
+ values.push(updates.enabled ? 1 : 0);
395
+ }
396
+ fields.push("updated_at = NOW()");
397
+ values.push(id);
398
+ const { rows } = await this.pool.query(
399
+ `UPDATE email_rules SET ${fields.join(", ")} WHERE id = $${i} RETURNING *`,
400
+ values
401
+ );
402
+ return this.mapRule(rows[0]);
403
+ }
404
+ async deleteRule(id) {
405
+ await this.pool.query("DELETE FROM email_rules WHERE id = $1", [id]);
406
+ }
407
+ // ─── Retention ───────────────────────────────────────────
408
+ async getRetentionPolicy() {
409
+ const { rows } = await this.pool.query("SELECT * FROM retention_policy WHERE id = $1", ["default"]);
410
+ if (!rows[0]) return { enabled: false, retainDays: 365, archiveFirst: true };
411
+ return {
412
+ enabled: !!rows[0].enabled,
413
+ retainDays: rows[0].retain_days,
414
+ excludeTags: JSON.parse(rows[0].exclude_tags || "[]"),
415
+ archiveFirst: !!rows[0].archive_first
416
+ };
417
+ }
418
+ async setRetentionPolicy(policy) {
419
+ await this.pool.query(
420
+ `UPDATE retention_policy SET enabled = $1, retain_days = $2, exclude_tags = $3, archive_first = $4
421
+ WHERE id = 'default'`,
422
+ [policy.enabled ? 1 : 0, policy.retainDays, JSON.stringify(policy.excludeTags || []), policy.archiveFirst ? 1 : 0]
423
+ );
424
+ }
425
+ // ─── Stats ───────────────────────────────────────────────
426
+ async getStats() {
427
+ const [agents, active, users, audit] = await Promise.all([
428
+ this.pool.query("SELECT COUNT(*) FROM agents"),
429
+ this.pool.query("SELECT COUNT(*) FROM agents WHERE status = 'active'"),
430
+ this.pool.query("SELECT COUNT(*) FROM users"),
431
+ this.pool.query("SELECT COUNT(*) FROM audit_log")
432
+ ]);
433
+ return {
434
+ totalAgents: parseInt(agents.rows[0].count, 10),
435
+ activeAgents: parseInt(active.rows[0].count, 10),
436
+ totalUsers: parseInt(users.rows[0].count, 10),
437
+ totalEmails: 0,
438
+ // TODO: wire to email storage
439
+ totalAuditEvents: parseInt(audit.rows[0].count, 10)
440
+ };
441
+ }
442
+ // ─── Mappers ─────────────────────────────────────────────
443
+ mapAgent(r) {
444
+ return {
445
+ id: r.id,
446
+ name: r.name,
447
+ email: r.email,
448
+ role: r.role,
449
+ status: r.status,
450
+ metadata: typeof r.metadata === "string" ? JSON.parse(r.metadata) : r.metadata,
451
+ createdAt: new Date(r.created_at),
452
+ updatedAt: new Date(r.updated_at),
453
+ createdBy: r.created_by
454
+ };
455
+ }
456
+ mapUser(r) {
457
+ return {
458
+ id: r.id,
459
+ email: r.email,
460
+ name: r.name,
461
+ role: r.role,
462
+ passwordHash: r.password_hash,
463
+ ssoProvider: r.sso_provider,
464
+ ssoSubject: r.sso_subject,
465
+ createdAt: new Date(r.created_at),
466
+ updatedAt: new Date(r.updated_at),
467
+ lastLoginAt: r.last_login_at ? new Date(r.last_login_at) : void 0
468
+ };
469
+ }
470
+ mapApiKey(r) {
471
+ return {
472
+ id: r.id,
473
+ name: r.name,
474
+ keyHash: r.key_hash,
475
+ keyPrefix: r.key_prefix,
476
+ scopes: typeof r.scopes === "string" ? JSON.parse(r.scopes) : r.scopes,
477
+ createdBy: r.created_by,
478
+ createdAt: new Date(r.created_at),
479
+ lastUsedAt: r.last_used_at ? new Date(r.last_used_at) : void 0,
480
+ expiresAt: r.expires_at ? new Date(r.expires_at) : void 0,
481
+ revoked: !!r.revoked
482
+ };
483
+ }
484
+ mapRule(r) {
485
+ return {
486
+ id: r.id,
487
+ name: r.name,
488
+ agentId: r.agent_id,
489
+ conditions: typeof r.conditions === "string" ? JSON.parse(r.conditions) : r.conditions,
490
+ actions: typeof r.actions === "string" ? JSON.parse(r.actions) : r.actions,
491
+ priority: r.priority,
492
+ enabled: !!r.enabled,
493
+ createdAt: new Date(r.created_at),
494
+ updatedAt: new Date(r.updated_at)
495
+ };
496
+ }
497
+ mapSettings(r) {
498
+ return {
499
+ id: r.id,
500
+ name: r.name,
501
+ domain: r.domain,
502
+ subdomain: r.subdomain,
503
+ smtpHost: r.smtp_host,
504
+ smtpPort: r.smtp_port,
505
+ smtpUser: r.smtp_user,
506
+ smtpPass: r.smtp_pass,
507
+ dkimPrivateKey: r.dkim_private_key,
508
+ logoUrl: r.logo_url,
509
+ primaryColor: r.primary_color,
510
+ plan: r.plan,
511
+ createdAt: new Date(r.created_at),
512
+ updatedAt: new Date(r.updated_at)
513
+ };
514
+ }
515
+ };
516
+ export {
517
+ PostgresAdapter
518
+ };