@agenticmail/enterprise 0.5.341 → 0.5.342

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.
@@ -1,116 +0,0 @@
1
- // src/db/sql-schema.ts
2
- var TABLES = {
3
- company: `
4
- CREATE TABLE IF NOT EXISTS company_settings (
5
- id TEXT PRIMARY KEY DEFAULT 'default',
6
- name TEXT NOT NULL,
7
- domain TEXT,
8
- subdomain TEXT NOT NULL UNIQUE,
9
- smtp_host TEXT,
10
- smtp_port INTEGER,
11
- smtp_user TEXT,
12
- smtp_pass TEXT,
13
- dkim_private_key TEXT,
14
- logo_url TEXT,
15
- primary_color TEXT DEFAULT '#6366f1',
16
- sso_config TEXT DEFAULT '{}',
17
- plan TEXT NOT NULL DEFAULT 'self-hosted',
18
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
19
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
20
- )`,
21
- agents: `
22
- CREATE TABLE IF NOT EXISTS agents (
23
- id TEXT PRIMARY KEY,
24
- name TEXT NOT NULL UNIQUE,
25
- email TEXT NOT NULL UNIQUE,
26
- role TEXT NOT NULL DEFAULT 'assistant',
27
- status TEXT NOT NULL DEFAULT 'active',
28
- metadata TEXT DEFAULT '{}',
29
- created_by TEXT NOT NULL,
30
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
31
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
32
- )`,
33
- users: `
34
- CREATE TABLE IF NOT EXISTS users (
35
- id TEXT PRIMARY KEY,
36
- email TEXT NOT NULL UNIQUE,
37
- name TEXT NOT NULL,
38
- role TEXT NOT NULL DEFAULT 'member',
39
- password_hash TEXT,
40
- sso_provider TEXT,
41
- sso_subject TEXT,
42
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
43
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
44
- last_login_at TIMESTAMP
45
- )`,
46
- audit_log: `
47
- CREATE TABLE IF NOT EXISTS audit_log (
48
- id TEXT PRIMARY KEY,
49
- timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
50
- actor TEXT NOT NULL,
51
- actor_type TEXT NOT NULL DEFAULT 'user',
52
- action TEXT NOT NULL,
53
- resource TEXT NOT NULL,
54
- details TEXT DEFAULT '{}',
55
- ip TEXT
56
- )`,
57
- api_keys: `
58
- CREATE TABLE IF NOT EXISTS api_keys (
59
- id TEXT PRIMARY KEY,
60
- name TEXT NOT NULL,
61
- key_hash TEXT NOT NULL,
62
- key_prefix TEXT NOT NULL,
63
- scopes TEXT NOT NULL DEFAULT '[]',
64
- created_by TEXT NOT NULL,
65
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
66
- last_used_at TIMESTAMP,
67
- expires_at TIMESTAMP,
68
- revoked INTEGER NOT NULL DEFAULT 0
69
- )`,
70
- email_rules: `
71
- CREATE TABLE IF NOT EXISTS email_rules (
72
- id TEXT PRIMARY KEY,
73
- name TEXT NOT NULL,
74
- agent_id TEXT,
75
- conditions TEXT NOT NULL DEFAULT '{}',
76
- actions TEXT NOT NULL DEFAULT '{}',
77
- priority INTEGER NOT NULL DEFAULT 0,
78
- enabled INTEGER NOT NULL DEFAULT 1,
79
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
80
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
81
- )`,
82
- retention_policy: `
83
- CREATE TABLE IF NOT EXISTS retention_policy (
84
- id TEXT PRIMARY KEY DEFAULT 'default',
85
- enabled INTEGER NOT NULL DEFAULT 0,
86
- retain_days INTEGER NOT NULL DEFAULT 365,
87
- exclude_tags TEXT DEFAULT '[]',
88
- archive_first INTEGER NOT NULL DEFAULT 1
89
- )`,
90
- // Indexes
91
- indexes: [
92
- "CREATE INDEX IF NOT EXISTS idx_agents_status ON agents(status)",
93
- "CREATE INDEX IF NOT EXISTS idx_agents_name ON agents(name)",
94
- "CREATE INDEX IF NOT EXISTS idx_users_email ON users(email)",
95
- "CREATE INDEX IF NOT EXISTS idx_users_sso ON users(sso_provider, sso_subject)",
96
- "CREATE INDEX IF NOT EXISTS idx_audit_timestamp ON audit_log(timestamp)",
97
- "CREATE INDEX IF NOT EXISTS idx_audit_actor ON audit_log(actor)",
98
- "CREATE INDEX IF NOT EXISTS idx_audit_action ON audit_log(action)",
99
- "CREATE INDEX IF NOT EXISTS idx_api_keys_hash ON api_keys(key_hash)",
100
- "CREATE INDEX IF NOT EXISTS idx_api_keys_prefix ON api_keys(key_prefix)",
101
- "CREATE INDEX IF NOT EXISTS idx_email_rules_agent ON email_rules(agent_id)"
102
- ]
103
- };
104
- function getAllCreateStatements() {
105
- const stmts = [];
106
- for (const [key, value] of Object.entries(TABLES)) {
107
- if (key === "indexes") continue;
108
- stmts.push(value);
109
- }
110
- stmts.push(...TABLES.indexes);
111
- return stmts;
112
- }
113
-
114
- export {
115
- getAllCreateStatements
116
- };