@claroshq/claros 0.0.0-stage → 0.8.4

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 (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -2
  3. package/assets/dashboard/apple-touch-icon.png +0 -0
  4. package/assets/dashboard/assets/bricolage-grotesque-latin-ext-wght-normal-CcLUaPy7.woff2 +0 -0
  5. package/assets/dashboard/assets/bricolage-grotesque-latin-wght-normal-DLoelf7F.woff2 +0 -0
  6. package/assets/dashboard/assets/bricolage-grotesque-vietnamese-wght-normal-BUzh504Q.woff2 +0 -0
  7. package/assets/dashboard/assets/index-Dvs1k10B.js +23 -0
  8. package/assets/dashboard/assets/index-gR64IOwq.css +1 -0
  9. package/assets/dashboard/assets/instrument-sans-latin-ext-wght-normal-B5bTHO_g.woff2 +0 -0
  10. package/assets/dashboard/assets/instrument-sans-latin-wght-normal-BbzFLZTg.woff2 +0 -0
  11. package/assets/dashboard/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  12. package/assets/dashboard/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  13. package/assets/dashboard/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  14. package/assets/dashboard/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  15. package/assets/dashboard/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  16. package/assets/dashboard/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  17. package/assets/dashboard/assets/quicksand-latin-ext-wght-normal-CrJ75Ewg.woff2 +0 -0
  18. package/assets/dashboard/assets/quicksand-latin-wght-normal-Buj9m_3d.woff2 +0 -0
  19. package/assets/dashboard/assets/quicksand-vietnamese-wght-normal-ei70gACF.woff2 +0 -0
  20. package/assets/dashboard/claros.js +122 -0
  21. package/assets/dashboard/favicon-16.png +0 -0
  22. package/assets/dashboard/favicon-32.png +0 -0
  23. package/assets/dashboard/favicon.ico +0 -0
  24. package/assets/dashboard/favicon.svg +17 -0
  25. package/assets/dashboard/fonts-license.txt +119 -0
  26. package/assets/dashboard/index.html +34 -0
  27. package/assets/migrations/0000_baseline.sql +343 -0
  28. package/assets/migrations/0001_kb_fts.sql +22 -0
  29. package/assets/migrations/0002_instance_layer.sql +51 -0
  30. package/assets/migrations/0003_suppressions_lower_email.sql +22 -0
  31. package/assets/migrations/0004_claim_tokens.sql +9 -0
  32. package/assets/migrations/0005_topics_transports.sql +36 -0
  33. package/assets/migrations/0006_ops_alerts.sql +28 -0
  34. package/assets/migrations/0007_integration_surface.sql +46 -0
  35. package/assets/migrations/0008_p5_engine.sql +31 -0
  36. package/assets/migrations/0009_p5b_readiness.sql +11 -0
  37. package/assets/migrations/meta/0000_snapshot.json +2489 -0
  38. package/assets/migrations/meta/0002_snapshot.json +2645 -0
  39. package/assets/migrations/meta/0004_snapshot.json +2698 -0
  40. package/assets/migrations/meta/0005_snapshot.json +2959 -0
  41. package/assets/migrations/meta/0006_snapshot.json +3138 -0
  42. package/assets/migrations/meta/0007_snapshot.json +3469 -0
  43. package/assets/migrations/meta/0008_snapshot.json +3709 -0
  44. package/assets/migrations/meta/0009_snapshot.json +3785 -0
  45. package/assets/migrations/meta/_journal.json +76 -0
  46. package/assets/worker/index.js +57902 -0
  47. package/bin/claros.mjs +13 -0
  48. package/dist/apply.d.ts +10 -0
  49. package/dist/apply.d.ts.map +1 -0
  50. package/dist/apply.js +72 -0
  51. package/dist/apply.js.map +1 -0
  52. package/dist/assets.d.ts +15 -0
  53. package/dist/assets.d.ts.map +1 -0
  54. package/dist/assets.js +48 -0
  55. package/dist/assets.js.map +1 -0
  56. package/dist/claim.d.ts +12 -0
  57. package/dist/claim.d.ts.map +1 -0
  58. package/dist/claim.js +26 -0
  59. package/dist/claim.js.map +1 -0
  60. package/dist/cli.d.ts +13 -0
  61. package/dist/cli.d.ts.map +1 -0
  62. package/dist/cli.js +158 -0
  63. package/dist/cli.js.map +1 -0
  64. package/dist/cloudflare-api.d.ts +48 -0
  65. package/dist/cloudflare-api.d.ts.map +1 -0
  66. package/dist/cloudflare-api.js +94 -0
  67. package/dist/cloudflare-api.js.map +1 -0
  68. package/dist/import.d.ts +16 -0
  69. package/dist/import.d.ts.map +1 -0
  70. package/dist/import.js +97 -0
  71. package/dist/import.js.map +1 -0
  72. package/dist/ops.d.ts +84 -0
  73. package/dist/ops.d.ts.map +1 -0
  74. package/dist/ops.js +552 -0
  75. package/dist/ops.js.map +1 -0
  76. package/dist/state.d.ts +53 -0
  77. package/dist/state.d.ts.map +1 -0
  78. package/dist/state.js +87 -0
  79. package/dist/state.js.map +1 -0
  80. package/dist/template.d.ts +77 -0
  81. package/dist/template.d.ts.map +1 -0
  82. package/dist/template.js +127 -0
  83. package/dist/template.js.map +1 -0
  84. package/dist/version.d.ts +3 -0
  85. package/dist/version.d.ts.map +1 -0
  86. package/dist/version.js +36 -0
  87. package/dist/version.js.map +1 -0
  88. package/dist/wrangler.d.ts +116 -0
  89. package/dist/wrangler.d.ts.map +1 -0
  90. package/dist/wrangler.js +210 -0
  91. package/dist/wrangler.js.map +1 -0
  92. package/package.json +53 -4
@@ -0,0 +1,2959 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "951c4454-fe23-41cd-a7d3-8fa56c594ded",
5
+ "prevId": "88741939-e981-4d5e-b531-3f24fd1e8c3d",
6
+ "tables": {
7
+ "api_keys": {
8
+ "name": "api_keys",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "tenant_id": {
18
+ "name": "tenant_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": false,
22
+ "autoincrement": false
23
+ },
24
+ "key_hash": {
25
+ "name": "key_hash",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "prefix": {
32
+ "name": "prefix",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "label": {
39
+ "name": "label",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": false,
43
+ "autoincrement": false
44
+ },
45
+ "kind": {
46
+ "name": "kind",
47
+ "type": "text",
48
+ "primaryKey": false,
49
+ "notNull": true,
50
+ "autoincrement": false,
51
+ "default": "'secret'"
52
+ },
53
+ "allowed_origins": {
54
+ "name": "allowed_origins",
55
+ "type": "text",
56
+ "primaryKey": false,
57
+ "notNull": false,
58
+ "autoincrement": false
59
+ },
60
+ "last_used_at": {
61
+ "name": "last_used_at",
62
+ "type": "integer",
63
+ "primaryKey": false,
64
+ "notNull": false,
65
+ "autoincrement": false
66
+ },
67
+ "created_at": {
68
+ "name": "created_at",
69
+ "type": "integer",
70
+ "primaryKey": false,
71
+ "notNull": false,
72
+ "autoincrement": false
73
+ },
74
+ "revoked_at": {
75
+ "name": "revoked_at",
76
+ "type": "integer",
77
+ "primaryKey": false,
78
+ "notNull": false,
79
+ "autoincrement": false
80
+ }
81
+ },
82
+ "indexes": {
83
+ "uq_api_keys_hash_active": {
84
+ "name": "uq_api_keys_hash_active",
85
+ "columns": [
86
+ "key_hash"
87
+ ],
88
+ "isUnique": true,
89
+ "where": "revoked_at IS NULL"
90
+ },
91
+ "idx_api_keys_tenant": {
92
+ "name": "idx_api_keys_tenant",
93
+ "columns": [
94
+ "tenant_id"
95
+ ],
96
+ "isUnique": false
97
+ }
98
+ },
99
+ "foreignKeys": {
100
+ "api_keys_tenant_id_tenants_id_fk": {
101
+ "name": "api_keys_tenant_id_tenants_id_fk",
102
+ "tableFrom": "api_keys",
103
+ "tableTo": "tenants",
104
+ "columnsFrom": [
105
+ "tenant_id"
106
+ ],
107
+ "columnsTo": [
108
+ "id"
109
+ ],
110
+ "onDelete": "no action",
111
+ "onUpdate": "no action"
112
+ }
113
+ },
114
+ "compositePrimaryKeys": {},
115
+ "uniqueConstraints": {},
116
+ "checkConstraints": {}
117
+ },
118
+ "claim_tokens": {
119
+ "name": "claim_tokens",
120
+ "columns": {
121
+ "id": {
122
+ "name": "id",
123
+ "type": "text",
124
+ "primaryKey": true,
125
+ "notNull": true,
126
+ "autoincrement": false
127
+ },
128
+ "token_hash": {
129
+ "name": "token_hash",
130
+ "type": "text",
131
+ "primaryKey": false,
132
+ "notNull": true,
133
+ "autoincrement": false
134
+ },
135
+ "expires_at": {
136
+ "name": "expires_at",
137
+ "type": "integer",
138
+ "primaryKey": false,
139
+ "notNull": true,
140
+ "autoincrement": false
141
+ },
142
+ "consumed_at": {
143
+ "name": "consumed_at",
144
+ "type": "integer",
145
+ "primaryKey": false,
146
+ "notNull": false,
147
+ "autoincrement": false
148
+ },
149
+ "created_at": {
150
+ "name": "created_at",
151
+ "type": "integer",
152
+ "primaryKey": false,
153
+ "notNull": false,
154
+ "autoincrement": false
155
+ }
156
+ },
157
+ "indexes": {
158
+ "uq_claim_tokens_token_hash": {
159
+ "name": "uq_claim_tokens_token_hash",
160
+ "columns": [
161
+ "token_hash"
162
+ ],
163
+ "isUnique": true
164
+ }
165
+ },
166
+ "foreignKeys": {},
167
+ "compositePrimaryKeys": {},
168
+ "uniqueConstraints": {},
169
+ "checkConstraints": {}
170
+ },
171
+ "contact_conflicts": {
172
+ "name": "contact_conflicts",
173
+ "columns": {
174
+ "id": {
175
+ "name": "id",
176
+ "type": "text",
177
+ "primaryKey": true,
178
+ "notNull": true,
179
+ "autoincrement": false
180
+ },
181
+ "tenant_id": {
182
+ "name": "tenant_id",
183
+ "type": "text",
184
+ "primaryKey": false,
185
+ "notNull": true,
186
+ "autoincrement": false
187
+ },
188
+ "contact_id": {
189
+ "name": "contact_id",
190
+ "type": "text",
191
+ "primaryKey": false,
192
+ "notNull": true,
193
+ "autoincrement": false
194
+ },
195
+ "field": {
196
+ "name": "field",
197
+ "type": "text",
198
+ "primaryKey": false,
199
+ "notNull": true,
200
+ "autoincrement": false
201
+ },
202
+ "rejected_value": {
203
+ "name": "rejected_value",
204
+ "type": "text",
205
+ "primaryKey": false,
206
+ "notNull": true,
207
+ "autoincrement": false
208
+ },
209
+ "event_id": {
210
+ "name": "event_id",
211
+ "type": "text",
212
+ "primaryKey": false,
213
+ "notNull": true,
214
+ "autoincrement": false
215
+ },
216
+ "created_at": {
217
+ "name": "created_at",
218
+ "type": "integer",
219
+ "primaryKey": false,
220
+ "notNull": false,
221
+ "autoincrement": false
222
+ }
223
+ },
224
+ "indexes": {
225
+ "idx_contact_conflicts_tenant": {
226
+ "name": "idx_contact_conflicts_tenant",
227
+ "columns": [
228
+ "tenant_id",
229
+ "created_at"
230
+ ],
231
+ "isUnique": false
232
+ },
233
+ "idx_contact_conflicts_contact": {
234
+ "name": "idx_contact_conflicts_contact",
235
+ "columns": [
236
+ "contact_id"
237
+ ],
238
+ "isUnique": false
239
+ }
240
+ },
241
+ "foreignKeys": {
242
+ "contact_conflicts_tenant_id_tenants_id_fk": {
243
+ "name": "contact_conflicts_tenant_id_tenants_id_fk",
244
+ "tableFrom": "contact_conflicts",
245
+ "tableTo": "tenants",
246
+ "columnsFrom": [
247
+ "tenant_id"
248
+ ],
249
+ "columnsTo": [
250
+ "id"
251
+ ],
252
+ "onDelete": "no action",
253
+ "onUpdate": "no action"
254
+ },
255
+ "contact_conflicts_contact_id_contacts_id_fk": {
256
+ "name": "contact_conflicts_contact_id_contacts_id_fk",
257
+ "tableFrom": "contact_conflicts",
258
+ "tableTo": "contacts",
259
+ "columnsFrom": [
260
+ "contact_id"
261
+ ],
262
+ "columnsTo": [
263
+ "id"
264
+ ],
265
+ "onDelete": "no action",
266
+ "onUpdate": "no action"
267
+ }
268
+ },
269
+ "compositePrimaryKeys": {},
270
+ "uniqueConstraints": {},
271
+ "checkConstraints": {}
272
+ },
273
+ "contact_topics": {
274
+ "name": "contact_topics",
275
+ "columns": {
276
+ "tenant_id": {
277
+ "name": "tenant_id",
278
+ "type": "text",
279
+ "primaryKey": false,
280
+ "notNull": true,
281
+ "autoincrement": false
282
+ },
283
+ "contact_id": {
284
+ "name": "contact_id",
285
+ "type": "text",
286
+ "primaryKey": false,
287
+ "notNull": true,
288
+ "autoincrement": false
289
+ },
290
+ "topic_id": {
291
+ "name": "topic_id",
292
+ "type": "text",
293
+ "primaryKey": false,
294
+ "notNull": true,
295
+ "autoincrement": false
296
+ },
297
+ "status": {
298
+ "name": "status",
299
+ "type": "text",
300
+ "primaryKey": false,
301
+ "notNull": true,
302
+ "autoincrement": false
303
+ },
304
+ "updated_at": {
305
+ "name": "updated_at",
306
+ "type": "integer",
307
+ "primaryKey": false,
308
+ "notNull": false,
309
+ "autoincrement": false
310
+ },
311
+ "source": {
312
+ "name": "source",
313
+ "type": "text",
314
+ "primaryKey": false,
315
+ "notNull": false,
316
+ "autoincrement": false
317
+ }
318
+ },
319
+ "indexes": {
320
+ "idx_contact_topics_tenant_topic": {
321
+ "name": "idx_contact_topics_tenant_topic",
322
+ "columns": [
323
+ "tenant_id",
324
+ "topic_id"
325
+ ],
326
+ "isUnique": false
327
+ }
328
+ },
329
+ "foreignKeys": {
330
+ "contact_topics_tenant_id_tenants_id_fk": {
331
+ "name": "contact_topics_tenant_id_tenants_id_fk",
332
+ "tableFrom": "contact_topics",
333
+ "tableTo": "tenants",
334
+ "columnsFrom": [
335
+ "tenant_id"
336
+ ],
337
+ "columnsTo": [
338
+ "id"
339
+ ],
340
+ "onDelete": "no action",
341
+ "onUpdate": "no action"
342
+ },
343
+ "contact_topics_contact_id_contacts_id_fk": {
344
+ "name": "contact_topics_contact_id_contacts_id_fk",
345
+ "tableFrom": "contact_topics",
346
+ "tableTo": "contacts",
347
+ "columnsFrom": [
348
+ "contact_id"
349
+ ],
350
+ "columnsTo": [
351
+ "id"
352
+ ],
353
+ "onDelete": "no action",
354
+ "onUpdate": "no action"
355
+ },
356
+ "contact_topics_topic_id_topics_id_fk": {
357
+ "name": "contact_topics_topic_id_topics_id_fk",
358
+ "tableFrom": "contact_topics",
359
+ "tableTo": "topics",
360
+ "columnsFrom": [
361
+ "topic_id"
362
+ ],
363
+ "columnsTo": [
364
+ "id"
365
+ ],
366
+ "onDelete": "no action",
367
+ "onUpdate": "no action"
368
+ }
369
+ },
370
+ "compositePrimaryKeys": {
371
+ "contact_topics_pkey": {
372
+ "columns": [
373
+ "contact_id",
374
+ "topic_id"
375
+ ],
376
+ "name": "contact_topics_pkey"
377
+ }
378
+ },
379
+ "uniqueConstraints": {},
380
+ "checkConstraints": {}
381
+ },
382
+ "contacts": {
383
+ "name": "contacts",
384
+ "columns": {
385
+ "id": {
386
+ "name": "id",
387
+ "type": "text",
388
+ "primaryKey": true,
389
+ "notNull": true,
390
+ "autoincrement": false
391
+ },
392
+ "tenant_id": {
393
+ "name": "tenant_id",
394
+ "type": "text",
395
+ "primaryKey": false,
396
+ "notNull": true,
397
+ "autoincrement": false
398
+ },
399
+ "external_id": {
400
+ "name": "external_id",
401
+ "type": "text",
402
+ "primaryKey": false,
403
+ "notNull": true,
404
+ "autoincrement": false
405
+ },
406
+ "email": {
407
+ "name": "email",
408
+ "type": "text",
409
+ "primaryKey": false,
410
+ "notNull": false,
411
+ "autoincrement": false
412
+ },
413
+ "name": {
414
+ "name": "name",
415
+ "type": "text",
416
+ "primaryKey": false,
417
+ "notNull": false,
418
+ "autoincrement": false
419
+ },
420
+ "company": {
421
+ "name": "company",
422
+ "type": "text",
423
+ "primaryKey": false,
424
+ "notNull": false,
425
+ "autoincrement": false
426
+ },
427
+ "properties": {
428
+ "name": "properties",
429
+ "type": "text",
430
+ "primaryKey": false,
431
+ "notNull": false,
432
+ "autoincrement": false
433
+ },
434
+ "lifecycle_state": {
435
+ "name": "lifecycle_state",
436
+ "type": "text",
437
+ "primaryKey": false,
438
+ "notNull": true,
439
+ "autoincrement": false
440
+ },
441
+ "engagement_depth": {
442
+ "name": "engagement_depth",
443
+ "type": "text",
444
+ "primaryKey": false,
445
+ "notNull": false,
446
+ "autoincrement": false
447
+ },
448
+ "payment_status": {
449
+ "name": "payment_status",
450
+ "type": "text",
451
+ "primaryKey": false,
452
+ "notNull": false,
453
+ "autoincrement": false,
454
+ "default": "'free'"
455
+ },
456
+ "first_seen_at": {
457
+ "name": "first_seen_at",
458
+ "type": "integer",
459
+ "primaryKey": false,
460
+ "notNull": false,
461
+ "autoincrement": false
462
+ },
463
+ "last_seen_at": {
464
+ "name": "last_seen_at",
465
+ "type": "integer",
466
+ "primaryKey": false,
467
+ "notNull": false,
468
+ "autoincrement": false
469
+ },
470
+ "activated_at": {
471
+ "name": "activated_at",
472
+ "type": "integer",
473
+ "primaryKey": false,
474
+ "notNull": false,
475
+ "autoincrement": false
476
+ },
477
+ "created_at": {
478
+ "name": "created_at",
479
+ "type": "integer",
480
+ "primaryKey": false,
481
+ "notNull": false,
482
+ "autoincrement": false
483
+ },
484
+ "event_count_bucket_current": {
485
+ "name": "event_count_bucket_current",
486
+ "type": "integer",
487
+ "primaryKey": false,
488
+ "notNull": false,
489
+ "autoincrement": false,
490
+ "default": 0
491
+ },
492
+ "event_count_bucket_prev": {
493
+ "name": "event_count_bucket_prev",
494
+ "type": "integer",
495
+ "primaryKey": false,
496
+ "notNull": false,
497
+ "autoincrement": false,
498
+ "default": 0
499
+ },
500
+ "last_counter_reset_at": {
501
+ "name": "last_counter_reset_at",
502
+ "type": "integer",
503
+ "primaryKey": false,
504
+ "notNull": false,
505
+ "autoincrement": false
506
+ }
507
+ },
508
+ "indexes": {
509
+ "uq_contacts_tenant_external_id": {
510
+ "name": "uq_contacts_tenant_external_id",
511
+ "columns": [
512
+ "tenant_id",
513
+ "external_id"
514
+ ],
515
+ "isUnique": true
516
+ },
517
+ "uq_contacts_tenant_email": {
518
+ "name": "uq_contacts_tenant_email",
519
+ "columns": [
520
+ "tenant_id",
521
+ "email"
522
+ ],
523
+ "isUnique": true,
524
+ "where": "email IS NOT NULL"
525
+ },
526
+ "idx_contacts_tenant_state": {
527
+ "name": "idx_contacts_tenant_state",
528
+ "columns": [
529
+ "tenant_id",
530
+ "lifecycle_state"
531
+ ],
532
+ "isUnique": false
533
+ },
534
+ "idx_contacts_last_seen": {
535
+ "name": "idx_contacts_last_seen",
536
+ "columns": [
537
+ "tenant_id",
538
+ "last_seen_at"
539
+ ],
540
+ "isUnique": false
541
+ },
542
+ "idx_contacts_tenant_created": {
543
+ "name": "idx_contacts_tenant_created",
544
+ "columns": [
545
+ "tenant_id",
546
+ "created_at",
547
+ "id"
548
+ ],
549
+ "isUnique": false
550
+ }
551
+ },
552
+ "foreignKeys": {
553
+ "contacts_tenant_id_tenants_id_fk": {
554
+ "name": "contacts_tenant_id_tenants_id_fk",
555
+ "tableFrom": "contacts",
556
+ "tableTo": "tenants",
557
+ "columnsFrom": [
558
+ "tenant_id"
559
+ ],
560
+ "columnsTo": [
561
+ "id"
562
+ ],
563
+ "onDelete": "no action",
564
+ "onUpdate": "no action"
565
+ }
566
+ },
567
+ "compositePrimaryKeys": {},
568
+ "uniqueConstraints": {},
569
+ "checkConstraints": {}
570
+ },
571
+ "events": {
572
+ "name": "events",
573
+ "columns": {
574
+ "id": {
575
+ "name": "id",
576
+ "type": "text",
577
+ "primaryKey": true,
578
+ "notNull": true,
579
+ "autoincrement": false
580
+ },
581
+ "tenant_id": {
582
+ "name": "tenant_id",
583
+ "type": "text",
584
+ "primaryKey": false,
585
+ "notNull": true,
586
+ "autoincrement": false
587
+ },
588
+ "contact_id": {
589
+ "name": "contact_id",
590
+ "type": "text",
591
+ "primaryKey": false,
592
+ "notNull": true,
593
+ "autoincrement": false
594
+ },
595
+ "type": {
596
+ "name": "type",
597
+ "type": "text",
598
+ "primaryKey": false,
599
+ "notNull": true,
600
+ "autoincrement": false
601
+ },
602
+ "event_name": {
603
+ "name": "event_name",
604
+ "type": "text",
605
+ "primaryKey": false,
606
+ "notNull": false,
607
+ "autoincrement": false
608
+ },
609
+ "properties": {
610
+ "name": "properties",
611
+ "type": "text",
612
+ "primaryKey": false,
613
+ "notNull": false,
614
+ "autoincrement": false
615
+ },
616
+ "context": {
617
+ "name": "context",
618
+ "type": "text",
619
+ "primaryKey": false,
620
+ "notNull": false,
621
+ "autoincrement": false
622
+ },
623
+ "message_id": {
624
+ "name": "message_id",
625
+ "type": "text",
626
+ "primaryKey": false,
627
+ "notNull": false,
628
+ "autoincrement": false
629
+ },
630
+ "timestamp": {
631
+ "name": "timestamp",
632
+ "type": "integer",
633
+ "primaryKey": false,
634
+ "notNull": true,
635
+ "autoincrement": false
636
+ },
637
+ "received_at": {
638
+ "name": "received_at",
639
+ "type": "integer",
640
+ "primaryKey": false,
641
+ "notNull": true,
642
+ "autoincrement": false
643
+ }
644
+ },
645
+ "indexes": {
646
+ "idx_events_contact_time": {
647
+ "name": "idx_events_contact_time",
648
+ "columns": [
649
+ "contact_id",
650
+ "timestamp"
651
+ ],
652
+ "isUnique": false
653
+ },
654
+ "idx_events_tenant_name": {
655
+ "name": "idx_events_tenant_name",
656
+ "columns": [
657
+ "tenant_id",
658
+ "event_name",
659
+ "timestamp"
660
+ ],
661
+ "isUnique": false
662
+ },
663
+ "idx_events_tenant_time": {
664
+ "name": "idx_events_tenant_time",
665
+ "columns": [
666
+ "tenant_id",
667
+ "timestamp"
668
+ ],
669
+ "isUnique": false
670
+ },
671
+ "idx_events_dedup_lookup": {
672
+ "name": "idx_events_dedup_lookup",
673
+ "columns": [
674
+ "tenant_id",
675
+ "message_id"
676
+ ],
677
+ "isUnique": false,
678
+ "where": "message_id IS NOT NULL"
679
+ }
680
+ },
681
+ "foreignKeys": {
682
+ "events_tenant_id_tenants_id_fk": {
683
+ "name": "events_tenant_id_tenants_id_fk",
684
+ "tableFrom": "events",
685
+ "tableTo": "tenants",
686
+ "columnsFrom": [
687
+ "tenant_id"
688
+ ],
689
+ "columnsTo": [
690
+ "id"
691
+ ],
692
+ "onDelete": "no action",
693
+ "onUpdate": "no action"
694
+ },
695
+ "events_contact_id_contacts_id_fk": {
696
+ "name": "events_contact_id_contacts_id_fk",
697
+ "tableFrom": "events",
698
+ "tableTo": "contacts",
699
+ "columnsFrom": [
700
+ "contact_id"
701
+ ],
702
+ "columnsTo": [
703
+ "id"
704
+ ],
705
+ "onDelete": "no action",
706
+ "onUpdate": "no action"
707
+ }
708
+ },
709
+ "compositePrimaryKeys": {},
710
+ "uniqueConstraints": {},
711
+ "checkConstraints": {}
712
+ },
713
+ "flow_memberships": {
714
+ "name": "flow_memberships",
715
+ "columns": {
716
+ "id": {
717
+ "name": "id",
718
+ "type": "text",
719
+ "primaryKey": true,
720
+ "notNull": true,
721
+ "autoincrement": false
722
+ },
723
+ "tenant_id": {
724
+ "name": "tenant_id",
725
+ "type": "text",
726
+ "primaryKey": false,
727
+ "notNull": true,
728
+ "autoincrement": false
729
+ },
730
+ "contact_id": {
731
+ "name": "contact_id",
732
+ "type": "text",
733
+ "primaryKey": false,
734
+ "notNull": true,
735
+ "autoincrement": false
736
+ },
737
+ "flow_id": {
738
+ "name": "flow_id",
739
+ "type": "text",
740
+ "primaryKey": false,
741
+ "notNull": true,
742
+ "autoincrement": false
743
+ },
744
+ "current_step": {
745
+ "name": "current_step",
746
+ "type": "integer",
747
+ "primaryKey": false,
748
+ "notNull": true,
749
+ "autoincrement": false,
750
+ "default": 1
751
+ },
752
+ "status": {
753
+ "name": "status",
754
+ "type": "text",
755
+ "primaryKey": false,
756
+ "notNull": true,
757
+ "autoincrement": false,
758
+ "default": "'active'"
759
+ },
760
+ "entered_at": {
761
+ "name": "entered_at",
762
+ "type": "integer",
763
+ "primaryKey": false,
764
+ "notNull": true,
765
+ "autoincrement": false
766
+ },
767
+ "completed_at": {
768
+ "name": "completed_at",
769
+ "type": "integer",
770
+ "primaryKey": false,
771
+ "notNull": false,
772
+ "autoincrement": false
773
+ },
774
+ "exited_at": {
775
+ "name": "exited_at",
776
+ "type": "integer",
777
+ "primaryKey": false,
778
+ "notNull": false,
779
+ "autoincrement": false
780
+ },
781
+ "exit_reason": {
782
+ "name": "exit_reason",
783
+ "type": "text",
784
+ "primaryKey": false,
785
+ "notNull": false,
786
+ "autoincrement": false
787
+ },
788
+ "condition_error": {
789
+ "name": "condition_error",
790
+ "type": "text",
791
+ "primaryKey": false,
792
+ "notNull": false,
793
+ "autoincrement": false
794
+ }
795
+ },
796
+ "indexes": {
797
+ "uq_flow_membership_active": {
798
+ "name": "uq_flow_membership_active",
799
+ "columns": [
800
+ "contact_id",
801
+ "flow_id"
802
+ ],
803
+ "isUnique": true,
804
+ "where": "status = 'active'"
805
+ },
806
+ "idx_flow_members_contact": {
807
+ "name": "idx_flow_members_contact",
808
+ "columns": [
809
+ "contact_id",
810
+ "status"
811
+ ],
812
+ "isUnique": false
813
+ },
814
+ "idx_flow_members_flow": {
815
+ "name": "idx_flow_members_flow",
816
+ "columns": [
817
+ "flow_id",
818
+ "status",
819
+ "current_step"
820
+ ],
821
+ "isUnique": false
822
+ }
823
+ },
824
+ "foreignKeys": {
825
+ "flow_memberships_tenant_id_tenants_id_fk": {
826
+ "name": "flow_memberships_tenant_id_tenants_id_fk",
827
+ "tableFrom": "flow_memberships",
828
+ "tableTo": "tenants",
829
+ "columnsFrom": [
830
+ "tenant_id"
831
+ ],
832
+ "columnsTo": [
833
+ "id"
834
+ ],
835
+ "onDelete": "no action",
836
+ "onUpdate": "no action"
837
+ },
838
+ "flow_memberships_contact_id_contacts_id_fk": {
839
+ "name": "flow_memberships_contact_id_contacts_id_fk",
840
+ "tableFrom": "flow_memberships",
841
+ "tableTo": "contacts",
842
+ "columnsFrom": [
843
+ "contact_id"
844
+ ],
845
+ "columnsTo": [
846
+ "id"
847
+ ],
848
+ "onDelete": "no action",
849
+ "onUpdate": "no action"
850
+ },
851
+ "flow_memberships_flow_id_flows_id_fk": {
852
+ "name": "flow_memberships_flow_id_flows_id_fk",
853
+ "tableFrom": "flow_memberships",
854
+ "tableTo": "flows",
855
+ "columnsFrom": [
856
+ "flow_id"
857
+ ],
858
+ "columnsTo": [
859
+ "id"
860
+ ],
861
+ "onDelete": "no action",
862
+ "onUpdate": "no action"
863
+ }
864
+ },
865
+ "compositePrimaryKeys": {},
866
+ "uniqueConstraints": {},
867
+ "checkConstraints": {}
868
+ },
869
+ "flows": {
870
+ "name": "flows",
871
+ "columns": {
872
+ "id": {
873
+ "name": "id",
874
+ "type": "text",
875
+ "primaryKey": true,
876
+ "notNull": true,
877
+ "autoincrement": false
878
+ },
879
+ "tenant_id": {
880
+ "name": "tenant_id",
881
+ "type": "text",
882
+ "primaryKey": false,
883
+ "notNull": true,
884
+ "autoincrement": false
885
+ },
886
+ "name": {
887
+ "name": "name",
888
+ "type": "text",
889
+ "primaryKey": false,
890
+ "notNull": true,
891
+ "autoincrement": false
892
+ },
893
+ "description": {
894
+ "name": "description",
895
+ "type": "text",
896
+ "primaryKey": false,
897
+ "notNull": false,
898
+ "autoincrement": false
899
+ },
900
+ "priority": {
901
+ "name": "priority",
902
+ "type": "integer",
903
+ "primaryKey": false,
904
+ "notNull": false,
905
+ "autoincrement": false,
906
+ "default": 0
907
+ },
908
+ "trigger_type": {
909
+ "name": "trigger_type",
910
+ "type": "text",
911
+ "primaryKey": false,
912
+ "notNull": true,
913
+ "autoincrement": false
914
+ },
915
+ "trigger_config": {
916
+ "name": "trigger_config",
917
+ "type": "text",
918
+ "primaryKey": false,
919
+ "notNull": true,
920
+ "autoincrement": false
921
+ },
922
+ "steps": {
923
+ "name": "steps",
924
+ "type": "text",
925
+ "primaryKey": false,
926
+ "notNull": true,
927
+ "autoincrement": false
928
+ },
929
+ "source": {
930
+ "name": "source",
931
+ "type": "text",
932
+ "primaryKey": false,
933
+ "notNull": false,
934
+ "autoincrement": false,
935
+ "default": "'manual'"
936
+ },
937
+ "content_mode": {
938
+ "name": "content_mode",
939
+ "type": "text",
940
+ "primaryKey": false,
941
+ "notNull": false,
942
+ "autoincrement": false,
943
+ "default": "'ai_drafted'"
944
+ },
945
+ "status": {
946
+ "name": "status",
947
+ "type": "text",
948
+ "primaryKey": false,
949
+ "notNull": false,
950
+ "autoincrement": false,
951
+ "default": "'draft'"
952
+ },
953
+ "approval_mode": {
954
+ "name": "approval_mode",
955
+ "type": "text",
956
+ "primaryKey": false,
957
+ "notNull": false,
958
+ "autoincrement": false,
959
+ "default": "'require'"
960
+ },
961
+ "flow_class": {
962
+ "name": "flow_class",
963
+ "type": "text",
964
+ "primaryKey": false,
965
+ "notNull": true,
966
+ "autoincrement": false,
967
+ "default": "'nurture'"
968
+ },
969
+ "reentry_policy": {
970
+ "name": "reentry_policy",
971
+ "type": "text",
972
+ "primaryKey": false,
973
+ "notNull": true,
974
+ "autoincrement": false,
975
+ "default": "'cooldown'"
976
+ },
977
+ "reentry_cooldown_days": {
978
+ "name": "reentry_cooldown_days",
979
+ "type": "integer",
980
+ "primaryKey": false,
981
+ "notNull": false,
982
+ "autoincrement": false,
983
+ "default": 30
984
+ },
985
+ "prompt_source": {
986
+ "name": "prompt_source",
987
+ "type": "text",
988
+ "primaryKey": false,
989
+ "notNull": false,
990
+ "autoincrement": false
991
+ },
992
+ "compiled_plan": {
993
+ "name": "compiled_plan",
994
+ "type": "text",
995
+ "primaryKey": false,
996
+ "notNull": false,
997
+ "autoincrement": false
998
+ },
999
+ "compiled_at": {
1000
+ "name": "compiled_at",
1001
+ "type": "integer",
1002
+ "primaryKey": false,
1003
+ "notNull": false,
1004
+ "autoincrement": false
1005
+ },
1006
+ "compile_status": {
1007
+ "name": "compile_status",
1008
+ "type": "text",
1009
+ "primaryKey": false,
1010
+ "notNull": false,
1011
+ "autoincrement": false
1012
+ },
1013
+ "compile_error": {
1014
+ "name": "compile_error",
1015
+ "type": "text",
1016
+ "primaryKey": false,
1017
+ "notNull": false,
1018
+ "autoincrement": false
1019
+ },
1020
+ "topic_id": {
1021
+ "name": "topic_id",
1022
+ "type": "text",
1023
+ "primaryKey": false,
1024
+ "notNull": false,
1025
+ "autoincrement": false
1026
+ },
1027
+ "created_at": {
1028
+ "name": "created_at",
1029
+ "type": "integer",
1030
+ "primaryKey": false,
1031
+ "notNull": false,
1032
+ "autoincrement": false
1033
+ },
1034
+ "updated_at": {
1035
+ "name": "updated_at",
1036
+ "type": "integer",
1037
+ "primaryKey": false,
1038
+ "notNull": false,
1039
+ "autoincrement": false
1040
+ }
1041
+ },
1042
+ "indexes": {},
1043
+ "foreignKeys": {
1044
+ "flows_tenant_id_tenants_id_fk": {
1045
+ "name": "flows_tenant_id_tenants_id_fk",
1046
+ "tableFrom": "flows",
1047
+ "tableTo": "tenants",
1048
+ "columnsFrom": [
1049
+ "tenant_id"
1050
+ ],
1051
+ "columnsTo": [
1052
+ "id"
1053
+ ],
1054
+ "onDelete": "no action",
1055
+ "onUpdate": "no action"
1056
+ },
1057
+ "flows_topic_id_topics_id_fk": {
1058
+ "name": "flows_topic_id_topics_id_fk",
1059
+ "tableFrom": "flows",
1060
+ "tableTo": "topics",
1061
+ "columnsFrom": [
1062
+ "topic_id"
1063
+ ],
1064
+ "columnsTo": [
1065
+ "id"
1066
+ ],
1067
+ "onDelete": "no action",
1068
+ "onUpdate": "no action"
1069
+ }
1070
+ },
1071
+ "compositePrimaryKeys": {},
1072
+ "uniqueConstraints": {},
1073
+ "checkConstraints": {}
1074
+ },
1075
+ "instance_settings": {
1076
+ "name": "instance_settings",
1077
+ "columns": {
1078
+ "key": {
1079
+ "name": "key",
1080
+ "type": "text",
1081
+ "primaryKey": true,
1082
+ "notNull": true,
1083
+ "autoincrement": false
1084
+ },
1085
+ "value": {
1086
+ "name": "value",
1087
+ "type": "text",
1088
+ "primaryKey": false,
1089
+ "notNull": true,
1090
+ "autoincrement": false
1091
+ },
1092
+ "updated_at": {
1093
+ "name": "updated_at",
1094
+ "type": "integer",
1095
+ "primaryKey": false,
1096
+ "notNull": false,
1097
+ "autoincrement": false
1098
+ }
1099
+ },
1100
+ "indexes": {},
1101
+ "foreignKeys": {},
1102
+ "compositePrimaryKeys": {},
1103
+ "uniqueConstraints": {},
1104
+ "checkConstraints": {}
1105
+ },
1106
+ "invites": {
1107
+ "name": "invites",
1108
+ "columns": {
1109
+ "id": {
1110
+ "name": "id",
1111
+ "type": "text",
1112
+ "primaryKey": true,
1113
+ "notNull": true,
1114
+ "autoincrement": false
1115
+ },
1116
+ "tenant_id": {
1117
+ "name": "tenant_id",
1118
+ "type": "text",
1119
+ "primaryKey": false,
1120
+ "notNull": true,
1121
+ "autoincrement": false
1122
+ },
1123
+ "email": {
1124
+ "name": "email",
1125
+ "type": "text",
1126
+ "primaryKey": false,
1127
+ "notNull": true,
1128
+ "autoincrement": false
1129
+ },
1130
+ "role": {
1131
+ "name": "role",
1132
+ "type": "text",
1133
+ "primaryKey": false,
1134
+ "notNull": true,
1135
+ "autoincrement": false,
1136
+ "default": "'member'"
1137
+ },
1138
+ "token_hash": {
1139
+ "name": "token_hash",
1140
+ "type": "text",
1141
+ "primaryKey": false,
1142
+ "notNull": true,
1143
+ "autoincrement": false
1144
+ },
1145
+ "invited_by": {
1146
+ "name": "invited_by",
1147
+ "type": "text",
1148
+ "primaryKey": false,
1149
+ "notNull": true,
1150
+ "autoincrement": false
1151
+ },
1152
+ "expires_at": {
1153
+ "name": "expires_at",
1154
+ "type": "integer",
1155
+ "primaryKey": false,
1156
+ "notNull": true,
1157
+ "autoincrement": false
1158
+ },
1159
+ "accepted_at": {
1160
+ "name": "accepted_at",
1161
+ "type": "integer",
1162
+ "primaryKey": false,
1163
+ "notNull": false,
1164
+ "autoincrement": false
1165
+ },
1166
+ "created_at": {
1167
+ "name": "created_at",
1168
+ "type": "integer",
1169
+ "primaryKey": false,
1170
+ "notNull": false,
1171
+ "autoincrement": false
1172
+ }
1173
+ },
1174
+ "indexes": {
1175
+ "idx_invites_token_hash": {
1176
+ "name": "idx_invites_token_hash",
1177
+ "columns": [
1178
+ "token_hash"
1179
+ ],
1180
+ "isUnique": false
1181
+ },
1182
+ "idx_invites_tenant": {
1183
+ "name": "idx_invites_tenant",
1184
+ "columns": [
1185
+ "tenant_id"
1186
+ ],
1187
+ "isUnique": false
1188
+ }
1189
+ },
1190
+ "foreignKeys": {
1191
+ "invites_tenant_id_tenants_id_fk": {
1192
+ "name": "invites_tenant_id_tenants_id_fk",
1193
+ "tableFrom": "invites",
1194
+ "tableTo": "tenants",
1195
+ "columnsFrom": [
1196
+ "tenant_id"
1197
+ ],
1198
+ "columnsTo": [
1199
+ "id"
1200
+ ],
1201
+ "onDelete": "no action",
1202
+ "onUpdate": "no action"
1203
+ },
1204
+ "invites_invited_by_users_id_fk": {
1205
+ "name": "invites_invited_by_users_id_fk",
1206
+ "tableFrom": "invites",
1207
+ "tableTo": "users",
1208
+ "columnsFrom": [
1209
+ "invited_by"
1210
+ ],
1211
+ "columnsTo": [
1212
+ "id"
1213
+ ],
1214
+ "onDelete": "no action",
1215
+ "onUpdate": "no action"
1216
+ }
1217
+ },
1218
+ "compositePrimaryKeys": {},
1219
+ "uniqueConstraints": {},
1220
+ "checkConstraints": {}
1221
+ },
1222
+ "kb_entries": {
1223
+ "name": "kb_entries",
1224
+ "columns": {
1225
+ "id": {
1226
+ "name": "id",
1227
+ "type": "text",
1228
+ "primaryKey": true,
1229
+ "notNull": true,
1230
+ "autoincrement": false
1231
+ },
1232
+ "tenant_id": {
1233
+ "name": "tenant_id",
1234
+ "type": "text",
1235
+ "primaryKey": false,
1236
+ "notNull": true,
1237
+ "autoincrement": false
1238
+ },
1239
+ "title": {
1240
+ "name": "title",
1241
+ "type": "text",
1242
+ "primaryKey": false,
1243
+ "notNull": true,
1244
+ "autoincrement": false
1245
+ },
1246
+ "content": {
1247
+ "name": "content",
1248
+ "type": "text",
1249
+ "primaryKey": false,
1250
+ "notNull": true,
1251
+ "autoincrement": false
1252
+ },
1253
+ "content_type": {
1254
+ "name": "content_type",
1255
+ "type": "text",
1256
+ "primaryKey": false,
1257
+ "notNull": false,
1258
+ "autoincrement": false,
1259
+ "default": "'markdown'"
1260
+ },
1261
+ "source": {
1262
+ "name": "source",
1263
+ "type": "text",
1264
+ "primaryKey": false,
1265
+ "notNull": false,
1266
+ "autoincrement": false,
1267
+ "default": "'manual'"
1268
+ },
1269
+ "source_url": {
1270
+ "name": "source_url",
1271
+ "type": "text",
1272
+ "primaryKey": false,
1273
+ "notNull": false,
1274
+ "autoincrement": false
1275
+ },
1276
+ "tags": {
1277
+ "name": "tags",
1278
+ "type": "text",
1279
+ "primaryKey": false,
1280
+ "notNull": false,
1281
+ "autoincrement": false
1282
+ },
1283
+ "embedding": {
1284
+ "name": "embedding",
1285
+ "type": "text",
1286
+ "primaryKey": false,
1287
+ "notNull": false,
1288
+ "autoincrement": false
1289
+ },
1290
+ "embedding_status": {
1291
+ "name": "embedding_status",
1292
+ "type": "text",
1293
+ "primaryKey": false,
1294
+ "notNull": false,
1295
+ "autoincrement": false
1296
+ },
1297
+ "embedding_error": {
1298
+ "name": "embedding_error",
1299
+ "type": "text",
1300
+ "primaryKey": false,
1301
+ "notNull": false,
1302
+ "autoincrement": false
1303
+ },
1304
+ "is_active": {
1305
+ "name": "is_active",
1306
+ "type": "integer",
1307
+ "primaryKey": false,
1308
+ "notNull": false,
1309
+ "autoincrement": false,
1310
+ "default": true
1311
+ },
1312
+ "created_at": {
1313
+ "name": "created_at",
1314
+ "type": "integer",
1315
+ "primaryKey": false,
1316
+ "notNull": false,
1317
+ "autoincrement": false
1318
+ },
1319
+ "updated_at": {
1320
+ "name": "updated_at",
1321
+ "type": "integer",
1322
+ "primaryKey": false,
1323
+ "notNull": false,
1324
+ "autoincrement": false
1325
+ }
1326
+ },
1327
+ "indexes": {
1328
+ "idx_kb_entries_tenant_created": {
1329
+ "name": "idx_kb_entries_tenant_created",
1330
+ "columns": [
1331
+ "tenant_id",
1332
+ "created_at",
1333
+ "id"
1334
+ ],
1335
+ "isUnique": false
1336
+ }
1337
+ },
1338
+ "foreignKeys": {
1339
+ "kb_entries_tenant_id_tenants_id_fk": {
1340
+ "name": "kb_entries_tenant_id_tenants_id_fk",
1341
+ "tableFrom": "kb_entries",
1342
+ "tableTo": "tenants",
1343
+ "columnsFrom": [
1344
+ "tenant_id"
1345
+ ],
1346
+ "columnsTo": [
1347
+ "id"
1348
+ ],
1349
+ "onDelete": "no action",
1350
+ "onUpdate": "no action"
1351
+ }
1352
+ },
1353
+ "compositePrimaryKeys": {},
1354
+ "uniqueConstraints": {},
1355
+ "checkConstraints": {}
1356
+ },
1357
+ "lifecycle_messages": {
1358
+ "name": "lifecycle_messages",
1359
+ "columns": {
1360
+ "id": {
1361
+ "name": "id",
1362
+ "type": "text",
1363
+ "primaryKey": true,
1364
+ "notNull": true,
1365
+ "autoincrement": false
1366
+ },
1367
+ "tenant_id": {
1368
+ "name": "tenant_id",
1369
+ "type": "text",
1370
+ "primaryKey": false,
1371
+ "notNull": true,
1372
+ "autoincrement": false
1373
+ },
1374
+ "contact_id": {
1375
+ "name": "contact_id",
1376
+ "type": "text",
1377
+ "primaryKey": false,
1378
+ "notNull": true,
1379
+ "autoincrement": false
1380
+ },
1381
+ "flow_id": {
1382
+ "name": "flow_id",
1383
+ "type": "text",
1384
+ "primaryKey": false,
1385
+ "notNull": true,
1386
+ "autoincrement": false
1387
+ },
1388
+ "membership_id": {
1389
+ "name": "membership_id",
1390
+ "type": "text",
1391
+ "primaryKey": false,
1392
+ "notNull": true,
1393
+ "autoincrement": false
1394
+ },
1395
+ "flow_step_order": {
1396
+ "name": "flow_step_order",
1397
+ "type": "integer",
1398
+ "primaryKey": false,
1399
+ "notNull": false,
1400
+ "autoincrement": false
1401
+ },
1402
+ "status": {
1403
+ "name": "status",
1404
+ "type": "text",
1405
+ "primaryKey": false,
1406
+ "notNull": true,
1407
+ "autoincrement": false
1408
+ },
1409
+ "feedback": {
1410
+ "name": "feedback",
1411
+ "type": "text",
1412
+ "primaryKey": false,
1413
+ "notNull": false,
1414
+ "autoincrement": false
1415
+ },
1416
+ "subject": {
1417
+ "name": "subject",
1418
+ "type": "text",
1419
+ "primaryKey": false,
1420
+ "notNull": false,
1421
+ "autoincrement": false
1422
+ },
1423
+ "body_html": {
1424
+ "name": "body_html",
1425
+ "type": "text",
1426
+ "primaryKey": false,
1427
+ "notNull": false,
1428
+ "autoincrement": false
1429
+ },
1430
+ "body_text": {
1431
+ "name": "body_text",
1432
+ "type": "text",
1433
+ "primaryKey": false,
1434
+ "notNull": false,
1435
+ "autoincrement": false
1436
+ },
1437
+ "brain_reasoning": {
1438
+ "name": "brain_reasoning",
1439
+ "type": "text",
1440
+ "primaryKey": false,
1441
+ "notNull": false,
1442
+ "autoincrement": false
1443
+ },
1444
+ "brain_action_type": {
1445
+ "name": "brain_action_type",
1446
+ "type": "text",
1447
+ "primaryKey": false,
1448
+ "notNull": false,
1449
+ "autoincrement": false
1450
+ },
1451
+ "scheduled_send_at": {
1452
+ "name": "scheduled_send_at",
1453
+ "type": "integer",
1454
+ "primaryKey": false,
1455
+ "notNull": false,
1456
+ "autoincrement": false
1457
+ },
1458
+ "approved_at": {
1459
+ "name": "approved_at",
1460
+ "type": "integer",
1461
+ "primaryKey": false,
1462
+ "notNull": false,
1463
+ "autoincrement": false
1464
+ },
1465
+ "sent_at": {
1466
+ "name": "sent_at",
1467
+ "type": "integer",
1468
+ "primaryKey": false,
1469
+ "notNull": false,
1470
+ "autoincrement": false
1471
+ },
1472
+ "retry_count": {
1473
+ "name": "retry_count",
1474
+ "type": "integer",
1475
+ "primaryKey": false,
1476
+ "notNull": false,
1477
+ "autoincrement": false,
1478
+ "default": 0
1479
+ },
1480
+ "provider_message_id": {
1481
+ "name": "provider_message_id",
1482
+ "type": "text",
1483
+ "primaryKey": false,
1484
+ "notNull": false,
1485
+ "autoincrement": false
1486
+ },
1487
+ "recipient_address": {
1488
+ "name": "recipient_address",
1489
+ "type": "text",
1490
+ "primaryKey": false,
1491
+ "notNull": false,
1492
+ "autoincrement": false
1493
+ },
1494
+ "topic_id": {
1495
+ "name": "topic_id",
1496
+ "type": "text",
1497
+ "primaryKey": false,
1498
+ "notNull": false,
1499
+ "autoincrement": false
1500
+ },
1501
+ "transport_id": {
1502
+ "name": "transport_id",
1503
+ "type": "text",
1504
+ "primaryKey": false,
1505
+ "notNull": false,
1506
+ "autoincrement": false
1507
+ },
1508
+ "status_reason": {
1509
+ "name": "status_reason",
1510
+ "type": "text",
1511
+ "primaryKey": false,
1512
+ "notNull": false,
1513
+ "autoincrement": false
1514
+ },
1515
+ "created_at": {
1516
+ "name": "created_at",
1517
+ "type": "integer",
1518
+ "primaryKey": false,
1519
+ "notNull": false,
1520
+ "autoincrement": false
1521
+ },
1522
+ "updated_at": {
1523
+ "name": "updated_at",
1524
+ "type": "integer",
1525
+ "primaryKey": false,
1526
+ "notNull": false,
1527
+ "autoincrement": false
1528
+ }
1529
+ },
1530
+ "indexes": {
1531
+ "idx_messages_drain": {
1532
+ "name": "idx_messages_drain",
1533
+ "columns": [
1534
+ "tenant_id",
1535
+ "status",
1536
+ "scheduled_send_at"
1537
+ ],
1538
+ "isUnique": false,
1539
+ "where": "status IN ('approved', 'sending')"
1540
+ },
1541
+ "idx_messages_contact": {
1542
+ "name": "idx_messages_contact",
1543
+ "columns": [
1544
+ "contact_id",
1545
+ "status",
1546
+ "created_at"
1547
+ ],
1548
+ "isUnique": false
1549
+ },
1550
+ "idx_messages_contact_sent": {
1551
+ "name": "idx_messages_contact_sent",
1552
+ "columns": [
1553
+ "contact_id",
1554
+ "sent_at"
1555
+ ],
1556
+ "isUnique": false,
1557
+ "where": "status IN ('sending', 'sent')"
1558
+ },
1559
+ "uq_messages_membership_step": {
1560
+ "name": "uq_messages_membership_step",
1561
+ "columns": [
1562
+ "membership_id",
1563
+ "flow_step_order"
1564
+ ],
1565
+ "isUnique": true
1566
+ },
1567
+ "idx_messages_generation": {
1568
+ "name": "idx_messages_generation",
1569
+ "columns": [
1570
+ "tenant_id",
1571
+ "status",
1572
+ "created_at"
1573
+ ],
1574
+ "isUnique": false,
1575
+ "where": "status IN ('pending_generation', 'generating')"
1576
+ },
1577
+ "idx_messages_provider_id": {
1578
+ "name": "idx_messages_provider_id",
1579
+ "columns": [
1580
+ "provider_message_id"
1581
+ ],
1582
+ "isUnique": false,
1583
+ "where": "provider_message_id IS NOT NULL"
1584
+ },
1585
+ "idx_messages_tenant_sent": {
1586
+ "name": "idx_messages_tenant_sent",
1587
+ "columns": [
1588
+ "tenant_id",
1589
+ "sent_at"
1590
+ ],
1591
+ "isUnique": false,
1592
+ "where": "sent_at IS NOT NULL"
1593
+ }
1594
+ },
1595
+ "foreignKeys": {
1596
+ "lifecycle_messages_tenant_id_tenants_id_fk": {
1597
+ "name": "lifecycle_messages_tenant_id_tenants_id_fk",
1598
+ "tableFrom": "lifecycle_messages",
1599
+ "tableTo": "tenants",
1600
+ "columnsFrom": [
1601
+ "tenant_id"
1602
+ ],
1603
+ "columnsTo": [
1604
+ "id"
1605
+ ],
1606
+ "onDelete": "no action",
1607
+ "onUpdate": "no action"
1608
+ },
1609
+ "lifecycle_messages_contact_id_contacts_id_fk": {
1610
+ "name": "lifecycle_messages_contact_id_contacts_id_fk",
1611
+ "tableFrom": "lifecycle_messages",
1612
+ "tableTo": "contacts",
1613
+ "columnsFrom": [
1614
+ "contact_id"
1615
+ ],
1616
+ "columnsTo": [
1617
+ "id"
1618
+ ],
1619
+ "onDelete": "no action",
1620
+ "onUpdate": "no action"
1621
+ },
1622
+ "lifecycle_messages_flow_id_flows_id_fk": {
1623
+ "name": "lifecycle_messages_flow_id_flows_id_fk",
1624
+ "tableFrom": "lifecycle_messages",
1625
+ "tableTo": "flows",
1626
+ "columnsFrom": [
1627
+ "flow_id"
1628
+ ],
1629
+ "columnsTo": [
1630
+ "id"
1631
+ ],
1632
+ "onDelete": "no action",
1633
+ "onUpdate": "no action"
1634
+ },
1635
+ "lifecycle_messages_membership_id_flow_memberships_id_fk": {
1636
+ "name": "lifecycle_messages_membership_id_flow_memberships_id_fk",
1637
+ "tableFrom": "lifecycle_messages",
1638
+ "tableTo": "flow_memberships",
1639
+ "columnsFrom": [
1640
+ "membership_id"
1641
+ ],
1642
+ "columnsTo": [
1643
+ "id"
1644
+ ],
1645
+ "onDelete": "no action",
1646
+ "onUpdate": "no action"
1647
+ }
1648
+ },
1649
+ "compositePrimaryKeys": {},
1650
+ "uniqueConstraints": {},
1651
+ "checkConstraints": {}
1652
+ },
1653
+ "lifecycle_transitions": {
1654
+ "name": "lifecycle_transitions",
1655
+ "columns": {
1656
+ "id": {
1657
+ "name": "id",
1658
+ "type": "text",
1659
+ "primaryKey": true,
1660
+ "notNull": true,
1661
+ "autoincrement": false
1662
+ },
1663
+ "tenant_id": {
1664
+ "name": "tenant_id",
1665
+ "type": "text",
1666
+ "primaryKey": false,
1667
+ "notNull": true,
1668
+ "autoincrement": false
1669
+ },
1670
+ "contact_id": {
1671
+ "name": "contact_id",
1672
+ "type": "text",
1673
+ "primaryKey": false,
1674
+ "notNull": true,
1675
+ "autoincrement": false
1676
+ },
1677
+ "from_state": {
1678
+ "name": "from_state",
1679
+ "type": "text",
1680
+ "primaryKey": false,
1681
+ "notNull": true,
1682
+ "autoincrement": false
1683
+ },
1684
+ "to_state": {
1685
+ "name": "to_state",
1686
+ "type": "text",
1687
+ "primaryKey": false,
1688
+ "notNull": true,
1689
+ "autoincrement": false
1690
+ },
1691
+ "trigger_event_id": {
1692
+ "name": "trigger_event_id",
1693
+ "type": "text",
1694
+ "primaryKey": false,
1695
+ "notNull": false,
1696
+ "autoincrement": false
1697
+ },
1698
+ "metadata": {
1699
+ "name": "metadata",
1700
+ "type": "text",
1701
+ "primaryKey": false,
1702
+ "notNull": false,
1703
+ "autoincrement": false
1704
+ },
1705
+ "transitioned_at": {
1706
+ "name": "transitioned_at",
1707
+ "type": "integer",
1708
+ "primaryKey": false,
1709
+ "notNull": true,
1710
+ "autoincrement": false
1711
+ }
1712
+ },
1713
+ "indexes": {
1714
+ "idx_transitions_contact": {
1715
+ "name": "idx_transitions_contact",
1716
+ "columns": [
1717
+ "contact_id",
1718
+ "transitioned_at"
1719
+ ],
1720
+ "isUnique": false
1721
+ },
1722
+ "idx_transitions_tenant_time": {
1723
+ "name": "idx_transitions_tenant_time",
1724
+ "columns": [
1725
+ "tenant_id",
1726
+ "transitioned_at"
1727
+ ],
1728
+ "isUnique": false
1729
+ }
1730
+ },
1731
+ "foreignKeys": {
1732
+ "lifecycle_transitions_tenant_id_tenants_id_fk": {
1733
+ "name": "lifecycle_transitions_tenant_id_tenants_id_fk",
1734
+ "tableFrom": "lifecycle_transitions",
1735
+ "tableTo": "tenants",
1736
+ "columnsFrom": [
1737
+ "tenant_id"
1738
+ ],
1739
+ "columnsTo": [
1740
+ "id"
1741
+ ],
1742
+ "onDelete": "no action",
1743
+ "onUpdate": "no action"
1744
+ },
1745
+ "lifecycle_transitions_contact_id_contacts_id_fk": {
1746
+ "name": "lifecycle_transitions_contact_id_contacts_id_fk",
1747
+ "tableFrom": "lifecycle_transitions",
1748
+ "tableTo": "contacts",
1749
+ "columnsFrom": [
1750
+ "contact_id"
1751
+ ],
1752
+ "columnsTo": [
1753
+ "id"
1754
+ ],
1755
+ "onDelete": "no action",
1756
+ "onUpdate": "no action"
1757
+ }
1758
+ },
1759
+ "compositePrimaryKeys": {},
1760
+ "uniqueConstraints": {},
1761
+ "checkConstraints": {}
1762
+ },
1763
+ "llm_configs": {
1764
+ "name": "llm_configs",
1765
+ "columns": {
1766
+ "id": {
1767
+ "name": "id",
1768
+ "type": "text",
1769
+ "primaryKey": true,
1770
+ "notNull": true,
1771
+ "autoincrement": false
1772
+ },
1773
+ "tenant_id": {
1774
+ "name": "tenant_id",
1775
+ "type": "text",
1776
+ "primaryKey": false,
1777
+ "notNull": true,
1778
+ "autoincrement": false
1779
+ },
1780
+ "provider": {
1781
+ "name": "provider",
1782
+ "type": "text",
1783
+ "primaryKey": false,
1784
+ "notNull": true,
1785
+ "autoincrement": false
1786
+ },
1787
+ "config": {
1788
+ "name": "config",
1789
+ "type": "text",
1790
+ "primaryKey": false,
1791
+ "notNull": true,
1792
+ "autoincrement": false
1793
+ },
1794
+ "is_active": {
1795
+ "name": "is_active",
1796
+ "type": "integer",
1797
+ "primaryKey": false,
1798
+ "notNull": false,
1799
+ "autoincrement": false,
1800
+ "default": true
1801
+ },
1802
+ "created_at": {
1803
+ "name": "created_at",
1804
+ "type": "integer",
1805
+ "primaryKey": false,
1806
+ "notNull": false,
1807
+ "autoincrement": false
1808
+ }
1809
+ },
1810
+ "indexes": {},
1811
+ "foreignKeys": {
1812
+ "llm_configs_tenant_id_tenants_id_fk": {
1813
+ "name": "llm_configs_tenant_id_tenants_id_fk",
1814
+ "tableFrom": "llm_configs",
1815
+ "tableTo": "tenants",
1816
+ "columnsFrom": [
1817
+ "tenant_id"
1818
+ ],
1819
+ "columnsTo": [
1820
+ "id"
1821
+ ],
1822
+ "onDelete": "no action",
1823
+ "onUpdate": "no action"
1824
+ }
1825
+ },
1826
+ "compositePrimaryKeys": {},
1827
+ "uniqueConstraints": {},
1828
+ "checkConstraints": {}
1829
+ },
1830
+ "magic_link_tokens": {
1831
+ "name": "magic_link_tokens",
1832
+ "columns": {
1833
+ "id": {
1834
+ "name": "id",
1835
+ "type": "text",
1836
+ "primaryKey": true,
1837
+ "notNull": true,
1838
+ "autoincrement": false
1839
+ },
1840
+ "tenant_id": {
1841
+ "name": "tenant_id",
1842
+ "type": "text",
1843
+ "primaryKey": false,
1844
+ "notNull": true,
1845
+ "autoincrement": false
1846
+ },
1847
+ "user_id": {
1848
+ "name": "user_id",
1849
+ "type": "text",
1850
+ "primaryKey": false,
1851
+ "notNull": true,
1852
+ "autoincrement": false
1853
+ },
1854
+ "token_hash": {
1855
+ "name": "token_hash",
1856
+ "type": "text",
1857
+ "primaryKey": false,
1858
+ "notNull": true,
1859
+ "autoincrement": false
1860
+ },
1861
+ "expires_at": {
1862
+ "name": "expires_at",
1863
+ "type": "integer",
1864
+ "primaryKey": false,
1865
+ "notNull": true,
1866
+ "autoincrement": false
1867
+ },
1868
+ "consumed_at": {
1869
+ "name": "consumed_at",
1870
+ "type": "integer",
1871
+ "primaryKey": false,
1872
+ "notNull": false,
1873
+ "autoincrement": false
1874
+ },
1875
+ "created_at": {
1876
+ "name": "created_at",
1877
+ "type": "integer",
1878
+ "primaryKey": false,
1879
+ "notNull": false,
1880
+ "autoincrement": false
1881
+ }
1882
+ },
1883
+ "indexes": {
1884
+ "idx_magic_link_tokens_hash": {
1885
+ "name": "idx_magic_link_tokens_hash",
1886
+ "columns": [
1887
+ "token_hash"
1888
+ ],
1889
+ "isUnique": false
1890
+ }
1891
+ },
1892
+ "foreignKeys": {
1893
+ "magic_link_tokens_tenant_id_tenants_id_fk": {
1894
+ "name": "magic_link_tokens_tenant_id_tenants_id_fk",
1895
+ "tableFrom": "magic_link_tokens",
1896
+ "tableTo": "tenants",
1897
+ "columnsFrom": [
1898
+ "tenant_id"
1899
+ ],
1900
+ "columnsTo": [
1901
+ "id"
1902
+ ],
1903
+ "onDelete": "no action",
1904
+ "onUpdate": "no action"
1905
+ },
1906
+ "magic_link_tokens_user_id_users_id_fk": {
1907
+ "name": "magic_link_tokens_user_id_users_id_fk",
1908
+ "tableFrom": "magic_link_tokens",
1909
+ "tableTo": "users",
1910
+ "columnsFrom": [
1911
+ "user_id"
1912
+ ],
1913
+ "columnsTo": [
1914
+ "id"
1915
+ ],
1916
+ "onDelete": "cascade",
1917
+ "onUpdate": "no action"
1918
+ }
1919
+ },
1920
+ "compositePrimaryKeys": {},
1921
+ "uniqueConstraints": {},
1922
+ "checkConstraints": {}
1923
+ },
1924
+ "memberships": {
1925
+ "name": "memberships",
1926
+ "columns": {
1927
+ "user_id": {
1928
+ "name": "user_id",
1929
+ "type": "text",
1930
+ "primaryKey": false,
1931
+ "notNull": true,
1932
+ "autoincrement": false
1933
+ },
1934
+ "tenant_id": {
1935
+ "name": "tenant_id",
1936
+ "type": "text",
1937
+ "primaryKey": false,
1938
+ "notNull": true,
1939
+ "autoincrement": false
1940
+ },
1941
+ "role": {
1942
+ "name": "role",
1943
+ "type": "text",
1944
+ "primaryKey": false,
1945
+ "notNull": true,
1946
+ "autoincrement": false
1947
+ },
1948
+ "created_at": {
1949
+ "name": "created_at",
1950
+ "type": "integer",
1951
+ "primaryKey": false,
1952
+ "notNull": false,
1953
+ "autoincrement": false
1954
+ }
1955
+ },
1956
+ "indexes": {
1957
+ "idx_memberships_tenant": {
1958
+ "name": "idx_memberships_tenant",
1959
+ "columns": [
1960
+ "tenant_id"
1961
+ ],
1962
+ "isUnique": false
1963
+ }
1964
+ },
1965
+ "foreignKeys": {
1966
+ "memberships_user_id_users_id_fk": {
1967
+ "name": "memberships_user_id_users_id_fk",
1968
+ "tableFrom": "memberships",
1969
+ "tableTo": "users",
1970
+ "columnsFrom": [
1971
+ "user_id"
1972
+ ],
1973
+ "columnsTo": [
1974
+ "id"
1975
+ ],
1976
+ "onDelete": "cascade",
1977
+ "onUpdate": "no action"
1978
+ },
1979
+ "memberships_tenant_id_tenants_id_fk": {
1980
+ "name": "memberships_tenant_id_tenants_id_fk",
1981
+ "tableFrom": "memberships",
1982
+ "tableTo": "tenants",
1983
+ "columnsFrom": [
1984
+ "tenant_id"
1985
+ ],
1986
+ "columnsTo": [
1987
+ "id"
1988
+ ],
1989
+ "onDelete": "no action",
1990
+ "onUpdate": "no action"
1991
+ }
1992
+ },
1993
+ "compositePrimaryKeys": {
1994
+ "memberships_pkey": {
1995
+ "columns": [
1996
+ "user_id",
1997
+ "tenant_id"
1998
+ ],
1999
+ "name": "memberships_pkey"
2000
+ }
2001
+ },
2002
+ "uniqueConstraints": {},
2003
+ "checkConstraints": {}
2004
+ },
2005
+ "message_events": {
2006
+ "name": "message_events",
2007
+ "columns": {
2008
+ "id": {
2009
+ "name": "id",
2010
+ "type": "text",
2011
+ "primaryKey": true,
2012
+ "notNull": true,
2013
+ "autoincrement": false
2014
+ },
2015
+ "tenant_id": {
2016
+ "name": "tenant_id",
2017
+ "type": "text",
2018
+ "primaryKey": false,
2019
+ "notNull": true,
2020
+ "autoincrement": false
2021
+ },
2022
+ "message_id": {
2023
+ "name": "message_id",
2024
+ "type": "text",
2025
+ "primaryKey": false,
2026
+ "notNull": true,
2027
+ "autoincrement": false
2028
+ },
2029
+ "event_type": {
2030
+ "name": "event_type",
2031
+ "type": "text",
2032
+ "primaryKey": false,
2033
+ "notNull": true,
2034
+ "autoincrement": false
2035
+ },
2036
+ "occurred_at": {
2037
+ "name": "occurred_at",
2038
+ "type": "integer",
2039
+ "primaryKey": false,
2040
+ "notNull": true,
2041
+ "autoincrement": false
2042
+ },
2043
+ "provider_event_id": {
2044
+ "name": "provider_event_id",
2045
+ "type": "text",
2046
+ "primaryKey": false,
2047
+ "notNull": false,
2048
+ "autoincrement": false
2049
+ },
2050
+ "metadata": {
2051
+ "name": "metadata",
2052
+ "type": "text",
2053
+ "primaryKey": false,
2054
+ "notNull": false,
2055
+ "autoincrement": false
2056
+ },
2057
+ "created_at": {
2058
+ "name": "created_at",
2059
+ "type": "integer",
2060
+ "primaryKey": false,
2061
+ "notNull": false,
2062
+ "autoincrement": false
2063
+ }
2064
+ },
2065
+ "indexes": {
2066
+ "idx_message_events_message": {
2067
+ "name": "idx_message_events_message",
2068
+ "columns": [
2069
+ "message_id",
2070
+ "occurred_at"
2071
+ ],
2072
+ "isUnique": false
2073
+ },
2074
+ "idx_message_events_tenant_type_day": {
2075
+ "name": "idx_message_events_tenant_type_day",
2076
+ "columns": [
2077
+ "tenant_id",
2078
+ "event_type",
2079
+ "occurred_at"
2080
+ ],
2081
+ "isUnique": false
2082
+ },
2083
+ "uq_message_events_provider_dedup": {
2084
+ "name": "uq_message_events_provider_dedup",
2085
+ "columns": [
2086
+ "tenant_id",
2087
+ "provider_event_id"
2088
+ ],
2089
+ "isUnique": true,
2090
+ "where": "provider_event_id IS NOT NULL"
2091
+ }
2092
+ },
2093
+ "foreignKeys": {
2094
+ "message_events_tenant_id_tenants_id_fk": {
2095
+ "name": "message_events_tenant_id_tenants_id_fk",
2096
+ "tableFrom": "message_events",
2097
+ "tableTo": "tenants",
2098
+ "columnsFrom": [
2099
+ "tenant_id"
2100
+ ],
2101
+ "columnsTo": [
2102
+ "id"
2103
+ ],
2104
+ "onDelete": "no action",
2105
+ "onUpdate": "no action"
2106
+ },
2107
+ "message_events_message_id_lifecycle_messages_id_fk": {
2108
+ "name": "message_events_message_id_lifecycle_messages_id_fk",
2109
+ "tableFrom": "message_events",
2110
+ "tableTo": "lifecycle_messages",
2111
+ "columnsFrom": [
2112
+ "message_id"
2113
+ ],
2114
+ "columnsTo": [
2115
+ "id"
2116
+ ],
2117
+ "onDelete": "no action",
2118
+ "onUpdate": "no action"
2119
+ }
2120
+ },
2121
+ "compositePrimaryKeys": {},
2122
+ "uniqueConstraints": {},
2123
+ "checkConstraints": {}
2124
+ },
2125
+ "retention_grid_snapshots": {
2126
+ "name": "retention_grid_snapshots",
2127
+ "columns": {
2128
+ "tenant_id": {
2129
+ "name": "tenant_id",
2130
+ "type": "text",
2131
+ "primaryKey": false,
2132
+ "notNull": true,
2133
+ "autoincrement": false
2134
+ },
2135
+ "snapshot_date": {
2136
+ "name": "snapshot_date",
2137
+ "type": "text",
2138
+ "primaryKey": false,
2139
+ "notNull": true,
2140
+ "autoincrement": false
2141
+ },
2142
+ "tenure_bucket": {
2143
+ "name": "tenure_bucket",
2144
+ "type": "text",
2145
+ "primaryKey": false,
2146
+ "notNull": true,
2147
+ "autoincrement": false
2148
+ },
2149
+ "recency_bucket": {
2150
+ "name": "recency_bucket",
2151
+ "type": "text",
2152
+ "primaryKey": false,
2153
+ "notNull": true,
2154
+ "autoincrement": false
2155
+ },
2156
+ "contact_count": {
2157
+ "name": "contact_count",
2158
+ "type": "integer",
2159
+ "primaryKey": false,
2160
+ "notNull": true,
2161
+ "autoincrement": false
2162
+ },
2163
+ "paying_count": {
2164
+ "name": "paying_count",
2165
+ "type": "integer",
2166
+ "primaryKey": false,
2167
+ "notNull": true,
2168
+ "autoincrement": false
2169
+ }
2170
+ },
2171
+ "indexes": {},
2172
+ "foreignKeys": {
2173
+ "retention_grid_snapshots_tenant_id_tenants_id_fk": {
2174
+ "name": "retention_grid_snapshots_tenant_id_tenants_id_fk",
2175
+ "tableFrom": "retention_grid_snapshots",
2176
+ "tableTo": "tenants",
2177
+ "columnsFrom": [
2178
+ "tenant_id"
2179
+ ],
2180
+ "columnsTo": [
2181
+ "id"
2182
+ ],
2183
+ "onDelete": "no action",
2184
+ "onUpdate": "no action"
2185
+ }
2186
+ },
2187
+ "compositePrimaryKeys": {
2188
+ "retention_grid_snapshots_tenant_id_snapshot_date_tenure_bucket_recency_bucket_pk": {
2189
+ "columns": [
2190
+ "tenant_id",
2191
+ "snapshot_date",
2192
+ "tenure_bucket",
2193
+ "recency_bucket"
2194
+ ],
2195
+ "name": "retention_grid_snapshots_tenant_id_snapshot_date_tenure_bucket_recency_bucket_pk"
2196
+ }
2197
+ },
2198
+ "uniqueConstraints": {},
2199
+ "checkConstraints": {}
2200
+ },
2201
+ "scan_checkpoints": {
2202
+ "name": "scan_checkpoints",
2203
+ "columns": {
2204
+ "scan_phase": {
2205
+ "name": "scan_phase",
2206
+ "type": "text",
2207
+ "primaryKey": false,
2208
+ "notNull": true,
2209
+ "autoincrement": false
2210
+ },
2211
+ "tenant_id": {
2212
+ "name": "tenant_id",
2213
+ "type": "text",
2214
+ "primaryKey": false,
2215
+ "notNull": true,
2216
+ "autoincrement": false
2217
+ },
2218
+ "last_id": {
2219
+ "name": "last_id",
2220
+ "type": "text",
2221
+ "primaryKey": false,
2222
+ "notNull": true,
2223
+ "autoincrement": false
2224
+ },
2225
+ "started_at": {
2226
+ "name": "started_at",
2227
+ "type": "integer",
2228
+ "primaryKey": false,
2229
+ "notNull": true,
2230
+ "autoincrement": false
2231
+ },
2232
+ "discard_count": {
2233
+ "name": "discard_count",
2234
+ "type": "integer",
2235
+ "primaryKey": false,
2236
+ "notNull": true,
2237
+ "autoincrement": false,
2238
+ "default": 0
2239
+ }
2240
+ },
2241
+ "indexes": {},
2242
+ "foreignKeys": {
2243
+ "scan_checkpoints_tenant_id_tenants_id_fk": {
2244
+ "name": "scan_checkpoints_tenant_id_tenants_id_fk",
2245
+ "tableFrom": "scan_checkpoints",
2246
+ "tableTo": "tenants",
2247
+ "columnsFrom": [
2248
+ "tenant_id"
2249
+ ],
2250
+ "columnsTo": [
2251
+ "id"
2252
+ ],
2253
+ "onDelete": "no action",
2254
+ "onUpdate": "no action"
2255
+ }
2256
+ },
2257
+ "compositePrimaryKeys": {
2258
+ "scan_checkpoints_scan_phase_tenant_id_pk": {
2259
+ "columns": [
2260
+ "scan_phase",
2261
+ "tenant_id"
2262
+ ],
2263
+ "name": "scan_checkpoints_scan_phase_tenant_id_pk"
2264
+ }
2265
+ },
2266
+ "uniqueConstraints": {},
2267
+ "checkConstraints": {}
2268
+ },
2269
+ "sessions": {
2270
+ "name": "sessions",
2271
+ "columns": {
2272
+ "id": {
2273
+ "name": "id",
2274
+ "type": "text",
2275
+ "primaryKey": true,
2276
+ "notNull": true,
2277
+ "autoincrement": false
2278
+ },
2279
+ "tenant_id": {
2280
+ "name": "tenant_id",
2281
+ "type": "text",
2282
+ "primaryKey": false,
2283
+ "notNull": true,
2284
+ "autoincrement": false
2285
+ },
2286
+ "user_id": {
2287
+ "name": "user_id",
2288
+ "type": "text",
2289
+ "primaryKey": false,
2290
+ "notNull": true,
2291
+ "autoincrement": false
2292
+ },
2293
+ "expires_at": {
2294
+ "name": "expires_at",
2295
+ "type": "integer",
2296
+ "primaryKey": false,
2297
+ "notNull": true,
2298
+ "autoincrement": false
2299
+ },
2300
+ "created_at": {
2301
+ "name": "created_at",
2302
+ "type": "integer",
2303
+ "primaryKey": false,
2304
+ "notNull": false,
2305
+ "autoincrement": false
2306
+ }
2307
+ },
2308
+ "indexes": {},
2309
+ "foreignKeys": {
2310
+ "sessions_tenant_id_tenants_id_fk": {
2311
+ "name": "sessions_tenant_id_tenants_id_fk",
2312
+ "tableFrom": "sessions",
2313
+ "tableTo": "tenants",
2314
+ "columnsFrom": [
2315
+ "tenant_id"
2316
+ ],
2317
+ "columnsTo": [
2318
+ "id"
2319
+ ],
2320
+ "onDelete": "no action",
2321
+ "onUpdate": "no action"
2322
+ },
2323
+ "sessions_user_id_users_id_fk": {
2324
+ "name": "sessions_user_id_users_id_fk",
2325
+ "tableFrom": "sessions",
2326
+ "tableTo": "users",
2327
+ "columnsFrom": [
2328
+ "user_id"
2329
+ ],
2330
+ "columnsTo": [
2331
+ "id"
2332
+ ],
2333
+ "onDelete": "cascade",
2334
+ "onUpdate": "no action"
2335
+ }
2336
+ },
2337
+ "compositePrimaryKeys": {},
2338
+ "uniqueConstraints": {},
2339
+ "checkConstraints": {}
2340
+ },
2341
+ "suppressions": {
2342
+ "name": "suppressions",
2343
+ "columns": {
2344
+ "id": {
2345
+ "name": "id",
2346
+ "type": "text",
2347
+ "primaryKey": true,
2348
+ "notNull": true,
2349
+ "autoincrement": false
2350
+ },
2351
+ "tenant_id": {
2352
+ "name": "tenant_id",
2353
+ "type": "text",
2354
+ "primaryKey": false,
2355
+ "notNull": true,
2356
+ "autoincrement": false
2357
+ },
2358
+ "email": {
2359
+ "name": "email",
2360
+ "type": "text",
2361
+ "primaryKey": false,
2362
+ "notNull": true,
2363
+ "autoincrement": false
2364
+ },
2365
+ "reason": {
2366
+ "name": "reason",
2367
+ "type": "text",
2368
+ "primaryKey": false,
2369
+ "notNull": true,
2370
+ "autoincrement": false
2371
+ },
2372
+ "source": {
2373
+ "name": "source",
2374
+ "type": "text",
2375
+ "primaryKey": false,
2376
+ "notNull": false,
2377
+ "autoincrement": false
2378
+ },
2379
+ "created_at": {
2380
+ "name": "created_at",
2381
+ "type": "integer",
2382
+ "primaryKey": false,
2383
+ "notNull": false,
2384
+ "autoincrement": false
2385
+ }
2386
+ },
2387
+ "indexes": {},
2388
+ "foreignKeys": {
2389
+ "suppressions_tenant_id_tenants_id_fk": {
2390
+ "name": "suppressions_tenant_id_tenants_id_fk",
2391
+ "tableFrom": "suppressions",
2392
+ "tableTo": "tenants",
2393
+ "columnsFrom": [
2394
+ "tenant_id"
2395
+ ],
2396
+ "columnsTo": [
2397
+ "id"
2398
+ ],
2399
+ "onDelete": "no action",
2400
+ "onUpdate": "no action"
2401
+ }
2402
+ },
2403
+ "compositePrimaryKeys": {},
2404
+ "uniqueConstraints": {},
2405
+ "checkConstraints": {}
2406
+ },
2407
+ "templates": {
2408
+ "name": "templates",
2409
+ "columns": {
2410
+ "id": {
2411
+ "name": "id",
2412
+ "type": "text",
2413
+ "primaryKey": true,
2414
+ "notNull": true,
2415
+ "autoincrement": false
2416
+ },
2417
+ "tenant_id": {
2418
+ "name": "tenant_id",
2419
+ "type": "text",
2420
+ "primaryKey": false,
2421
+ "notNull": true,
2422
+ "autoincrement": false
2423
+ },
2424
+ "name": {
2425
+ "name": "name",
2426
+ "type": "text",
2427
+ "primaryKey": false,
2428
+ "notNull": true,
2429
+ "autoincrement": false
2430
+ },
2431
+ "slug": {
2432
+ "name": "slug",
2433
+ "type": "text",
2434
+ "primaryKey": false,
2435
+ "notNull": true,
2436
+ "autoincrement": false
2437
+ },
2438
+ "subject": {
2439
+ "name": "subject",
2440
+ "type": "text",
2441
+ "primaryKey": false,
2442
+ "notNull": true,
2443
+ "autoincrement": false
2444
+ },
2445
+ "body_html": {
2446
+ "name": "body_html",
2447
+ "type": "text",
2448
+ "primaryKey": false,
2449
+ "notNull": true,
2450
+ "autoincrement": false
2451
+ },
2452
+ "body_text": {
2453
+ "name": "body_text",
2454
+ "type": "text",
2455
+ "primaryKey": false,
2456
+ "notNull": false,
2457
+ "autoincrement": false
2458
+ },
2459
+ "variables": {
2460
+ "name": "variables",
2461
+ "type": "text",
2462
+ "primaryKey": false,
2463
+ "notNull": false,
2464
+ "autoincrement": false
2465
+ },
2466
+ "category": {
2467
+ "name": "category",
2468
+ "type": "text",
2469
+ "primaryKey": false,
2470
+ "notNull": false,
2471
+ "autoincrement": false
2472
+ },
2473
+ "is_active": {
2474
+ "name": "is_active",
2475
+ "type": "integer",
2476
+ "primaryKey": false,
2477
+ "notNull": false,
2478
+ "autoincrement": false,
2479
+ "default": true
2480
+ },
2481
+ "created_at": {
2482
+ "name": "created_at",
2483
+ "type": "integer",
2484
+ "primaryKey": false,
2485
+ "notNull": false,
2486
+ "autoincrement": false
2487
+ }
2488
+ },
2489
+ "indexes": {
2490
+ "uq_templates_tenant_slug": {
2491
+ "name": "uq_templates_tenant_slug",
2492
+ "columns": [
2493
+ "tenant_id",
2494
+ "slug"
2495
+ ],
2496
+ "isUnique": true
2497
+ }
2498
+ },
2499
+ "foreignKeys": {
2500
+ "templates_tenant_id_tenants_id_fk": {
2501
+ "name": "templates_tenant_id_tenants_id_fk",
2502
+ "tableFrom": "templates",
2503
+ "tableTo": "tenants",
2504
+ "columnsFrom": [
2505
+ "tenant_id"
2506
+ ],
2507
+ "columnsTo": [
2508
+ "id"
2509
+ ],
2510
+ "onDelete": "no action",
2511
+ "onUpdate": "no action"
2512
+ }
2513
+ },
2514
+ "compositePrimaryKeys": {},
2515
+ "uniqueConstraints": {},
2516
+ "checkConstraints": {}
2517
+ },
2518
+ "tenants": {
2519
+ "name": "tenants",
2520
+ "columns": {
2521
+ "id": {
2522
+ "name": "id",
2523
+ "type": "text",
2524
+ "primaryKey": true,
2525
+ "notNull": true,
2526
+ "autoincrement": false
2527
+ },
2528
+ "name": {
2529
+ "name": "name",
2530
+ "type": "text",
2531
+ "primaryKey": false,
2532
+ "notNull": true,
2533
+ "autoincrement": false
2534
+ },
2535
+ "slug": {
2536
+ "name": "slug",
2537
+ "type": "text",
2538
+ "primaryKey": false,
2539
+ "notNull": true,
2540
+ "autoincrement": false
2541
+ },
2542
+ "plan": {
2543
+ "name": "plan",
2544
+ "type": "text",
2545
+ "primaryKey": false,
2546
+ "notNull": false,
2547
+ "autoincrement": false,
2548
+ "default": "'free'"
2549
+ },
2550
+ "settings": {
2551
+ "name": "settings",
2552
+ "type": "text",
2553
+ "primaryKey": false,
2554
+ "notNull": false,
2555
+ "autoincrement": false
2556
+ },
2557
+ "business_model": {
2558
+ "name": "business_model",
2559
+ "type": "text",
2560
+ "primaryKey": false,
2561
+ "notNull": false,
2562
+ "autoincrement": false
2563
+ },
2564
+ "created_at": {
2565
+ "name": "created_at",
2566
+ "type": "integer",
2567
+ "primaryKey": false,
2568
+ "notNull": false,
2569
+ "autoincrement": false
2570
+ },
2571
+ "archived_at": {
2572
+ "name": "archived_at",
2573
+ "type": "integer",
2574
+ "primaryKey": false,
2575
+ "notNull": false,
2576
+ "autoincrement": false
2577
+ },
2578
+ "public_host": {
2579
+ "name": "public_host",
2580
+ "type": "text",
2581
+ "primaryKey": false,
2582
+ "notNull": false,
2583
+ "autoincrement": false
2584
+ },
2585
+ "locale": {
2586
+ "name": "locale",
2587
+ "type": "text",
2588
+ "primaryKey": false,
2589
+ "notNull": false,
2590
+ "autoincrement": false
2591
+ },
2592
+ "config_version": {
2593
+ "name": "config_version",
2594
+ "type": "integer",
2595
+ "primaryKey": false,
2596
+ "notNull": true,
2597
+ "autoincrement": false,
2598
+ "default": 0
2599
+ }
2600
+ },
2601
+ "indexes": {
2602
+ "tenants_slug_unique": {
2603
+ "name": "tenants_slug_unique",
2604
+ "columns": [
2605
+ "slug"
2606
+ ],
2607
+ "isUnique": true
2608
+ },
2609
+ "uq_tenants_public_host": {
2610
+ "name": "uq_tenants_public_host",
2611
+ "columns": [
2612
+ "public_host"
2613
+ ],
2614
+ "isUnique": true,
2615
+ "where": "public_host IS NOT NULL"
2616
+ }
2617
+ },
2618
+ "foreignKeys": {},
2619
+ "compositePrimaryKeys": {},
2620
+ "uniqueConstraints": {},
2621
+ "checkConstraints": {}
2622
+ },
2623
+ "topics": {
2624
+ "name": "topics",
2625
+ "columns": {
2626
+ "id": {
2627
+ "name": "id",
2628
+ "type": "text",
2629
+ "primaryKey": true,
2630
+ "notNull": true,
2631
+ "autoincrement": false
2632
+ },
2633
+ "tenant_id": {
2634
+ "name": "tenant_id",
2635
+ "type": "text",
2636
+ "primaryKey": false,
2637
+ "notNull": true,
2638
+ "autoincrement": false
2639
+ },
2640
+ "slug": {
2641
+ "name": "slug",
2642
+ "type": "text",
2643
+ "primaryKey": false,
2644
+ "notNull": true,
2645
+ "autoincrement": false
2646
+ },
2647
+ "name": {
2648
+ "name": "name",
2649
+ "type": "text",
2650
+ "primaryKey": false,
2651
+ "notNull": true,
2652
+ "autoincrement": false
2653
+ },
2654
+ "kind": {
2655
+ "name": "kind",
2656
+ "type": "text",
2657
+ "primaryKey": false,
2658
+ "notNull": true,
2659
+ "autoincrement": false
2660
+ },
2661
+ "description": {
2662
+ "name": "description",
2663
+ "type": "text",
2664
+ "primaryKey": false,
2665
+ "notNull": false,
2666
+ "autoincrement": false
2667
+ },
2668
+ "default_subscribed": {
2669
+ "name": "default_subscribed",
2670
+ "type": "integer",
2671
+ "primaryKey": false,
2672
+ "notNull": true,
2673
+ "autoincrement": false,
2674
+ "default": true
2675
+ },
2676
+ "created_at": {
2677
+ "name": "created_at",
2678
+ "type": "integer",
2679
+ "primaryKey": false,
2680
+ "notNull": false,
2681
+ "autoincrement": false
2682
+ }
2683
+ },
2684
+ "indexes": {
2685
+ "uq_topics_tenant_slug": {
2686
+ "name": "uq_topics_tenant_slug",
2687
+ "columns": [
2688
+ "tenant_id",
2689
+ "slug"
2690
+ ],
2691
+ "isUnique": true
2692
+ }
2693
+ },
2694
+ "foreignKeys": {
2695
+ "topics_tenant_id_tenants_id_fk": {
2696
+ "name": "topics_tenant_id_tenants_id_fk",
2697
+ "tableFrom": "topics",
2698
+ "tableTo": "tenants",
2699
+ "columnsFrom": [
2700
+ "tenant_id"
2701
+ ],
2702
+ "columnsTo": [
2703
+ "id"
2704
+ ],
2705
+ "onDelete": "no action",
2706
+ "onUpdate": "no action"
2707
+ }
2708
+ },
2709
+ "compositePrimaryKeys": {},
2710
+ "uniqueConstraints": {},
2711
+ "checkConstraints": {}
2712
+ },
2713
+ "transport_configs": {
2714
+ "name": "transport_configs",
2715
+ "columns": {
2716
+ "id": {
2717
+ "name": "id",
2718
+ "type": "text",
2719
+ "primaryKey": true,
2720
+ "notNull": true,
2721
+ "autoincrement": false
2722
+ },
2723
+ "tenant_id": {
2724
+ "name": "tenant_id",
2725
+ "type": "text",
2726
+ "primaryKey": false,
2727
+ "notNull": true,
2728
+ "autoincrement": false
2729
+ },
2730
+ "provider": {
2731
+ "name": "provider",
2732
+ "type": "text",
2733
+ "primaryKey": false,
2734
+ "notNull": true,
2735
+ "autoincrement": false
2736
+ },
2737
+ "config": {
2738
+ "name": "config",
2739
+ "type": "text",
2740
+ "primaryKey": false,
2741
+ "notNull": true,
2742
+ "autoincrement": false
2743
+ },
2744
+ "is_active": {
2745
+ "name": "is_active",
2746
+ "type": "integer",
2747
+ "primaryKey": false,
2748
+ "notNull": false,
2749
+ "autoincrement": false,
2750
+ "default": true
2751
+ },
2752
+ "dkim_verified": {
2753
+ "name": "dkim_verified",
2754
+ "type": "integer",
2755
+ "primaryKey": false,
2756
+ "notNull": false,
2757
+ "autoincrement": false,
2758
+ "default": false
2759
+ },
2760
+ "from_email": {
2761
+ "name": "from_email",
2762
+ "type": "text",
2763
+ "primaryKey": false,
2764
+ "notNull": true,
2765
+ "autoincrement": false
2766
+ },
2767
+ "from_name": {
2768
+ "name": "from_name",
2769
+ "type": "text",
2770
+ "primaryKey": false,
2771
+ "notNull": false,
2772
+ "autoincrement": false
2773
+ },
2774
+ "daily_limit": {
2775
+ "name": "daily_limit",
2776
+ "type": "integer",
2777
+ "primaryKey": false,
2778
+ "notNull": false,
2779
+ "autoincrement": false
2780
+ },
2781
+ "kind": {
2782
+ "name": "kind",
2783
+ "type": "text",
2784
+ "primaryKey": false,
2785
+ "notNull": false,
2786
+ "autoincrement": false
2787
+ },
2788
+ "name": {
2789
+ "name": "name",
2790
+ "type": "text",
2791
+ "primaryKey": false,
2792
+ "notNull": false,
2793
+ "autoincrement": false
2794
+ },
2795
+ "reply_to": {
2796
+ "name": "reply_to",
2797
+ "type": "text",
2798
+ "primaryKey": false,
2799
+ "notNull": false,
2800
+ "autoincrement": false
2801
+ },
2802
+ "created_at": {
2803
+ "name": "created_at",
2804
+ "type": "integer",
2805
+ "primaryKey": false,
2806
+ "notNull": false,
2807
+ "autoincrement": false
2808
+ }
2809
+ },
2810
+ "indexes": {},
2811
+ "foreignKeys": {
2812
+ "transport_configs_tenant_id_tenants_id_fk": {
2813
+ "name": "transport_configs_tenant_id_tenants_id_fk",
2814
+ "tableFrom": "transport_configs",
2815
+ "tableTo": "tenants",
2816
+ "columnsFrom": [
2817
+ "tenant_id"
2818
+ ],
2819
+ "columnsTo": [
2820
+ "id"
2821
+ ],
2822
+ "onDelete": "no action",
2823
+ "onUpdate": "no action"
2824
+ }
2825
+ },
2826
+ "compositePrimaryKeys": {},
2827
+ "uniqueConstraints": {},
2828
+ "checkConstraints": {}
2829
+ },
2830
+ "users": {
2831
+ "name": "users",
2832
+ "columns": {
2833
+ "id": {
2834
+ "name": "id",
2835
+ "type": "text",
2836
+ "primaryKey": true,
2837
+ "notNull": true,
2838
+ "autoincrement": false
2839
+ },
2840
+ "tenant_id": {
2841
+ "name": "tenant_id",
2842
+ "type": "text",
2843
+ "primaryKey": false,
2844
+ "notNull": true,
2845
+ "autoincrement": false
2846
+ },
2847
+ "email": {
2848
+ "name": "email",
2849
+ "type": "text",
2850
+ "primaryKey": false,
2851
+ "notNull": true,
2852
+ "autoincrement": false
2853
+ },
2854
+ "name": {
2855
+ "name": "name",
2856
+ "type": "text",
2857
+ "primaryKey": false,
2858
+ "notNull": false,
2859
+ "autoincrement": false
2860
+ },
2861
+ "role": {
2862
+ "name": "role",
2863
+ "type": "text",
2864
+ "primaryKey": false,
2865
+ "notNull": true,
2866
+ "autoincrement": false,
2867
+ "default": "'member'"
2868
+ },
2869
+ "instance_role": {
2870
+ "name": "instance_role",
2871
+ "type": "text",
2872
+ "primaryKey": false,
2873
+ "notNull": false,
2874
+ "autoincrement": false
2875
+ },
2876
+ "last_login_at": {
2877
+ "name": "last_login_at",
2878
+ "type": "integer",
2879
+ "primaryKey": false,
2880
+ "notNull": false,
2881
+ "autoincrement": false
2882
+ },
2883
+ "deactivated_at": {
2884
+ "name": "deactivated_at",
2885
+ "type": "integer",
2886
+ "primaryKey": false,
2887
+ "notNull": false,
2888
+ "autoincrement": false
2889
+ },
2890
+ "pending_email": {
2891
+ "name": "pending_email",
2892
+ "type": "text",
2893
+ "primaryKey": false,
2894
+ "notNull": false,
2895
+ "autoincrement": false
2896
+ },
2897
+ "pending_email_token_hash": {
2898
+ "name": "pending_email_token_hash",
2899
+ "type": "text",
2900
+ "primaryKey": false,
2901
+ "notNull": false,
2902
+ "autoincrement": false
2903
+ },
2904
+ "pending_email_expires_at": {
2905
+ "name": "pending_email_expires_at",
2906
+ "type": "integer",
2907
+ "primaryKey": false,
2908
+ "notNull": false,
2909
+ "autoincrement": false
2910
+ },
2911
+ "created_at": {
2912
+ "name": "created_at",
2913
+ "type": "integer",
2914
+ "primaryKey": false,
2915
+ "notNull": false,
2916
+ "autoincrement": false
2917
+ }
2918
+ },
2919
+ "indexes": {
2920
+ "uq_users_tenant_email": {
2921
+ "name": "uq_users_tenant_email",
2922
+ "columns": [
2923
+ "tenant_id",
2924
+ "email"
2925
+ ],
2926
+ "isUnique": true
2927
+ }
2928
+ },
2929
+ "foreignKeys": {
2930
+ "users_tenant_id_tenants_id_fk": {
2931
+ "name": "users_tenant_id_tenants_id_fk",
2932
+ "tableFrom": "users",
2933
+ "tableTo": "tenants",
2934
+ "columnsFrom": [
2935
+ "tenant_id"
2936
+ ],
2937
+ "columnsTo": [
2938
+ "id"
2939
+ ],
2940
+ "onDelete": "no action",
2941
+ "onUpdate": "no action"
2942
+ }
2943
+ },
2944
+ "compositePrimaryKeys": {},
2945
+ "uniqueConstraints": {},
2946
+ "checkConstraints": {}
2947
+ }
2948
+ },
2949
+ "views": {},
2950
+ "enums": {},
2951
+ "_meta": {
2952
+ "schemas": {},
2953
+ "tables": {},
2954
+ "columns": {}
2955
+ },
2956
+ "internal": {
2957
+ "indexes": {}
2958
+ }
2959
+ }