4646 lines
86 KiB
JavaScript
4646 lines
86 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ConnectedAccounts = db.connected_accounts;
|
|
|
|
const StyleProfiles = db.style_profiles;
|
|
|
|
const EmailThreads = db.email_threads;
|
|
|
|
const EmailMessages = db.email_messages;
|
|
|
|
const ReplyDrafts = db.reply_drafts;
|
|
|
|
const CreditWallets = db.credit_wallets;
|
|
|
|
const CreditTransactions = db.credit_transactions;
|
|
|
|
const WebhookEvents = db.webhook_events;
|
|
|
|
const AuditLogs = db.audit_logs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ConnectedAccountsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "gmail",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"account_email": "avery.chen@gmail.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_account_identifier": "gmail_0f3a8b2c",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_primary": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"auto_send_enabled": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approval_mode": "manual_approval",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"connected_at": new Date('2026-04-20T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_sync_at": new Date('2026-05-06T18:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_expires_at": new Date('2026-06-06T18:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_storage_key": "vault_key_avery_gmail_01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_subscription_identifier": "gmail_watch_21a9",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_expires_at": new Date('2026-06-20T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_error_message": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "gmail",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"account_email": "avery.chen@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_account_identifier": "graph_71c29d10",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_primary": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"auto_send_enabled": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approval_mode": "auto_send",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"connected_at": new Date('2026-04-22T12:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_sync_at": new Date('2026-05-06T17:55:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_expires_at": new Date('2026-06-06T17:55:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_storage_key": "vault_key_avery_graph_01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_subscription_identifier": "graph_sub_9b77",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_expires_at": new Date('2026-05-22T12:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_error_message": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "microsoft365",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"account_email": "jordan.patel@gmail.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_account_identifier": "gmail_9c2d1aa4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "connecting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_primary": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"auto_send_enabled": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approval_mode": "manual_approval",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"connected_at": new Date('2026-04-28T08:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_sync_at": new Date('2026-05-06T08:50:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_expires_at": new Date('2026-06-06T08:50:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_storage_key": "vault_key_jordan_gmail_01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_subscription_identifier": "gmail_watch_31c2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_expires_at": new Date('2026-06-28T08:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_error_message": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "microsoft365",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"account_email": "morgan.rivera@fabrikam.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_account_identifier": "graph_2f88a6d1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "revoked",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_primary": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"auto_send_enabled": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approval_mode": "auto_send",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"connected_at": new Date('2026-04-25T16:40:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_sync_at": new Date('2026-05-01T10:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_expires_at": new Date('2026-05-01T10:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"token_storage_key": "vault_key_morgan_graph_01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_subscription_identifier": "graph_sub_1dd4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"webhook_expires_at": new Date('2026-05-25T16:40:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_error_message": "Token refresh failed due to invalid grant",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const StyleProfilesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_status": "not_started",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_trained_at": new Date('2026-05-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_message_count": 240,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"default_tone": "casual",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"formality_level": "high",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"verbosity": "concise",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_greeting": "Hi",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_signoff": "Best regards, Avery",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"use_emojis": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ask_clarifying_questions": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sensitive_topics_manual_review": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"style_summary": "Concise professional tone with clear asks and minimal small talk.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"dos_list": "Use short paragraphs; confirm next steps; keep greetings simple.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"donts_list": "Avoid exclamation-heavy language; do not overpromise; avoid slang.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_status": "training",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_trained_at": new Date('2026-05-03T12:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_message_count": 180,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"default_tone": "casual",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"formality_level": "medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"verbosity": "concise",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_greeting": "Hello",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_signoff": "Thanks, Jordan",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"use_emojis": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ask_clarifying_questions": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sensitive_topics_manual_review": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"style_summary": "Friendly and direct, with helpful context and polite closings.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"dos_list": "Acknowledge request; propose two options; keep bullets short.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"donts_list": "Do not sound overly formal; avoid long introductions; avoid jargon.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_status": "training",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_trained_at": new Date('2026-04-30T15:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_message_count": 95,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"default_tone": "direct",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"formality_level": "medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"verbosity": "balanced",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_greeting": "Hi there",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_signoff": "Regards, Morgan",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"use_emojis": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ask_clarifying_questions": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sensitive_topics_manual_review": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"style_summary": "Direct and efficient, prefers action items and dates.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"dos_list": "State decision early; include dates; list owners.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"donts_list": "Avoid vague language; avoid hedging; avoid extra filler.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_status": "training",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_trained_at": new Date('2026-05-06T07:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"training_message_count": 40,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"default_tone": "formal",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"formality_level": "high",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"verbosity": "detailed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_greeting": "Good morning",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"preferred_signoff": "Sincerely, Samira",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"use_emojis": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ask_clarifying_questions": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sensitive_topics_manual_review": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"style_summary": "Formal, courteous and structured with clear boundaries.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"dos_list": "Use polite phrasing; add one-sentence summary; be explicit on timelines.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"donts_list": "Avoid casual phrases; avoid contractions; avoid informal sign-offs.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EmailThreadsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_thread_identifier": "th_8a12c1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Q2 Budget Review and Next Steps",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"folder": "trash",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"thread_status": "awaiting_user",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_unread": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_flagged": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"participants_summary": "CFO Office, Avery Chen",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-06T16:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-05-06T16:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_thread_identifier": "th_1b77d9",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Lunch next week",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"folder": "inbox",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"thread_status": "awaiting_user",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_unread": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_flagged": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"participants_summary": "Taylor Nguyen, Avery Chen",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-05T12:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-05-05T12:20:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_thread_identifier": "th_31f0a2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Proposal feedback requested",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"folder": "inbox",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"thread_status": "replied",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_unread": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_flagged": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"participants_summary": "Client Team, Jordan Patel",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-06T08:40:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-05-06T08:40:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_thread_identifier": "th_5cc219",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Security questionnaire",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"folder": "spam",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"thread_status": "archived",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_unread": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_flagged": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"participants_summary": "Vendor Risk, Morgan Rivera",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-01T09:55:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_activity_at": new Date('2026-05-01T09:55:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EmailMessagesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_message_identifier": "msg_a1001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "outgoing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_name": "CFO Office",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_email": "cfo.office@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"to_emails": "avery.chen@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cc_emails": "finance.ops@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bcc_emails": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Q2 Budget Review and Next Steps",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"snippet": "Can you confirm the revised allocations by Thursday",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_text": "Hi Avery, can you confirm the revised allocations by Thursday and highlight any risks for the hiring plan. Thanks.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_html": "<p>Hi Avery, can you confirm the revised allocations by Thursday and highlight any risks for the hiring plan. Thanks.</p>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-06T16:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-06T16:05:10Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_read": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_deleted": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_message_identifier": "msg_a1002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "incoming",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_name": "Avery Chen",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_email": "avery.chen@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"to_emails": "cfo.office@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cc_emails": "finance.ops@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bcc_emails": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Re: Q2 Budget Review and Next Steps",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"snippet": "Acknowledged, I will confirm by Thursday",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_text": "Hi, acknowledged. I will confirm the revised allocations by Thursday EOD and include key risks for the hiring plan. Best regards, Avery",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_html": "<p>Hi, acknowledged. I will confirm the revised allocations by Thursday EOD and include key risks for the hiring plan.</p><p>Best regards,<br/>Avery</p>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-06T16:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-06T16:20:05Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_read": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_deleted": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_message_identifier": "msg_b2001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "outgoing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_name": "Taylor Nguyen",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_email": "taylor.nguyen@external.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"to_emails": "avery.chen@gmail.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cc_emails": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bcc_emails": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Lunch next week",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"snippet": "Are you free Wednesday or Thursday",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_text": "Hi Avery, are you free Wednesday or Thursday for lunch next week near downtown. Taylor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_html": "<p>Hi Avery, are you free Wednesday or Thursday for lunch next week near downtown.</p><p>Taylor</p>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-05T12:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-05T12:20:05Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_read": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_deleted": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider_message_identifier": "msg_c3001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"direction": "outgoing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_name": "Nina Scott",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"from_email": "nina.scott@client.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"to_emails": "jordan.patel@gmail.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cc_emails": "pm@client.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"bcc_emails": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"subject": "Proposal feedback requested",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"snippet": "Could you review the attached proposal by Friday",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_text": "Hello Jordan, could you review the attached proposal by Friday and share any recommended edits. Thank you.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"body_html": "<p>Hello Jordan, could you review the attached proposal by Friday and share any recommended edits. Thank you.</p>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-06T08:40:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-06T08:40:06Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_read": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_deleted": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ReplyDraftsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "discarded",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ai_provider": "claude",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"model_name": "gpt-4.1-mini",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"confidence_score": 0.84,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"credit_cost": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"prompt_summary": "Draft concise reply confirming timeline and offering risks summary.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"draft_body": "Hi, confirmed. I will send the revised allocations by Thursday EOD and include a brief summary of key hiring-plan risks and mitigations. Best regards, Avery",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rationale": "Uses short greeting, direct confirmation, and clear next steps consistent with prior messages.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requires_manual_review": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"risk_flags": "none",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"generated_at": new Date('2026-05-06T16:07:30Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approved_at": new Date('2026-05-06T16:18:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-06T16:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"failure_reason": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "discarded",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ai_provider": "openai",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"model_name": "claude-3-5-sonnet",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"confidence_score": 0.72,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"credit_cost": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"prompt_summary": "Suggest two times and ask for location preference.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"draft_body": "Hi Taylor, Wednesday works for me. If Thursday is better, I can also do 12:30. Do you have a place in mind downtown. Best regards, Avery",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rationale": "Matches concise style but keeps friendly scheduling tone.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requires_manual_review": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"risk_flags": "none",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"generated_at": new Date('2026-05-05T12:25:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approved_at": new Date('2026-05-05T13:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-05T13:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"failure_reason": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "edited",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ai_provider": "other",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"model_name": "gpt-4.1-mini",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"confidence_score": 0.78,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"credit_cost": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"prompt_summary": "Acknowledge receipt, confirm review by Friday, ask clarifying question.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"draft_body": "Hello Nina, thanks for sending this. I can review and share edits by Friday afternoon. Any sections you would like me to focus on first. Thanks, Jordan",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rationale": "Friendly acknowledgement, clear commitment, and a clarifying question consistent with profile.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requires_manual_review": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"risk_flags": "none",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"generated_at": new Date('2026-05-06T08:42:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approved_at": new Date('2026-05-06T09:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-06T09:07:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"failure_reason": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "proposed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ai_provider": "claude",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"model_name": "gpt-4.1-mini",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"confidence_score": 0.69,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"credit_cost": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"prompt_summary": "Confirm timeline and request any required portal link.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"draft_body": "Hi, received. I will return the completed questionnaire by Tuesday. If there is a submission portal or required format, please share the link. Regards, Morgan",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rationale": "States decision early and includes date; asks for missing submission details.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requires_manual_review": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"risk_flags": "security, compliance",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"generated_at": new Date('2026-05-01T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"approved_at": new Date('2026-05-01T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-01T12:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"failure_reason": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CreditWalletsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_credits": 120,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reserved_credits": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"wallet_status": "frozen",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_recalculated_at": new Date('2026-05-06T18:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_credits": 45,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reserved_credits": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"wallet_status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_recalculated_at": new Date('2026-05-06T09:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_credits": 10,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reserved_credits": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"wallet_status": "frozen",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_recalculated_at": new Date('2026-05-01T10:10:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_credits": 60,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reserved_credits": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"wallet_status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_recalculated_at": new Date('2026-05-06T20:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CreditTransactionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "purchase",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount_credits": 100,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_after_credits": 120,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "admin",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_kind": "subscription_cycle",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_identifier": "sub_cycle_2026_05_avery",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Monthly subscription credit grant",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-01T00:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "adjustment",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount_credits": -2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_after_credits": 118,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "admin",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_kind": "reply_draft",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_identifier": "draft_q2_budget",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "AI draft generation for Q2 budget thread",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-06T16:07:31Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "purchase",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount_credits": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_after_credits": 95,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "reversed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "system",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_kind": "top_up",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_identifier": "topup_jordan_2026_05",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Credit top-up purchase",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-02T10:20:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "usage_debit",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount_credits": -2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance_after_credits": 43,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "reversed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "api",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_kind": "reply_draft",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reference_identifier": "draft_proposal_feedback",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "AI draft generation for proposal feedback",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-06T08:42:01Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const WebhookEventsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "microsoft365",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_identifier": "evt_graph_001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_type": "message_updated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processing_status": "ignored",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"attempt_count": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-06T16:05:12Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processed_at": new Date('2026-05-06T16:06:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payload_raw": "Graph notification for new message in Inbox for avery.chen@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"error_message": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "microsoft365",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_identifier": "evt_gmail_010",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_type": "thread_updated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processing_status": "queued",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"attempt_count": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-06T08:40:08Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processed_at": new Date('2026-05-06T08:41:10Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payload_raw": "Gmail push event for thread th_31f0a2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"error_message": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "gmail",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_identifier": "evt_graph_014",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_type": "sync_required",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processing_status": "failed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"attempt_count": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-01T10:02:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processed_at": new Date('2026-05-01T10:12:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payload_raw": "Graph notification indicates delta sync required",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"error_message": "Token refresh failed due to invalid grant",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "microsoft365",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_identifier": "evt_gmail_099",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"event_type": "subscription_expired",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processing_status": "queued",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"attempt_count": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"received_at": new Date('2026-05-04T18:31:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"processed_at": new Date('2026-05-04T18:32:10Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"payload_raw": "Gmail push event for thread th_9df010",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"error_message": "None",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const AuditLogsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "oauth_connect_started",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "info",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_name": "connected_accounts",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_identifier": "avery.chen@northwind.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.10",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "ExpoApp iOS 1.0.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Microsoft 365 account connected and webhook subscription created",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-04-22T12:31:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "draft_regenerated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "warn",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_name": "reply_drafts",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_identifier": "draft_q2_budget",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.10",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "ExpoApp iOS 1.0.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Draft generated with confidence 0.84 and cost 2 credits",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-06T16:07:31Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "credits_debited",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "error",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_name": "reply_drafts",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_identifier": "draft_proposal_feedback",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "198.51.100.44",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "ExpoApp Android 1.0.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Draft approved and sent from Gmail account",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-06T09:07:10Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "oauth_connect_started",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "debug",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_name": "connected_accounts",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_identifier": "morgan.rivera@fabrikam.example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "192.0.2.25",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "ExpoApp iOS 1.0.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Token refresh failed and sync paused; user action required to reconnect",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-01T10:12:30Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateConnectedAccountWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ConnectedAccount0 = await ConnectedAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ConnectedAccount0?.setUser)
|
|
{
|
|
await
|
|
ConnectedAccount0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ConnectedAccount1 = await ConnectedAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ConnectedAccount1?.setUser)
|
|
{
|
|
await
|
|
ConnectedAccount1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ConnectedAccount2 = await ConnectedAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ConnectedAccount2?.setUser)
|
|
{
|
|
await
|
|
ConnectedAccount2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ConnectedAccount3 = await ConnectedAccounts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (ConnectedAccount3?.setUser)
|
|
{
|
|
await
|
|
ConnectedAccount3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateStyleProfileWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const StyleProfile0 = await StyleProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (StyleProfile0?.setUser)
|
|
{
|
|
await
|
|
StyleProfile0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const StyleProfile1 = await StyleProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (StyleProfile1?.setUser)
|
|
{
|
|
await
|
|
StyleProfile1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const StyleProfile2 = await StyleProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (StyleProfile2?.setUser)
|
|
{
|
|
await
|
|
StyleProfile2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const StyleProfile3 = await StyleProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (StyleProfile3?.setUser)
|
|
{
|
|
await
|
|
StyleProfile3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEmailThreadWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EmailThread0 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EmailThread0?.setUser)
|
|
{
|
|
await
|
|
EmailThread0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EmailThread1 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EmailThread1?.setUser)
|
|
{
|
|
await
|
|
EmailThread1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EmailThread2 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EmailThread2?.setUser)
|
|
{
|
|
await
|
|
EmailThread2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const EmailThread3 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (EmailThread3?.setUser)
|
|
{
|
|
await
|
|
EmailThread3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateEmailThreadWithConnected_account() {
|
|
|
|
const relatedConnected_account0 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const EmailThread0 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EmailThread0?.setConnected_account)
|
|
{
|
|
await
|
|
EmailThread0.
|
|
setConnected_account(relatedConnected_account0);
|
|
}
|
|
|
|
const relatedConnected_account1 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const EmailThread1 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EmailThread1?.setConnected_account)
|
|
{
|
|
await
|
|
EmailThread1.
|
|
setConnected_account(relatedConnected_account1);
|
|
}
|
|
|
|
const relatedConnected_account2 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const EmailThread2 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EmailThread2?.setConnected_account)
|
|
{
|
|
await
|
|
EmailThread2.
|
|
setConnected_account(relatedConnected_account2);
|
|
}
|
|
|
|
const relatedConnected_account3 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const EmailThread3 = await EmailThreads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (EmailThread3?.setConnected_account)
|
|
{
|
|
await
|
|
EmailThread3.
|
|
setConnected_account(relatedConnected_account3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEmailMessageWithThread() {
|
|
|
|
const relatedThread0 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const EmailMessage0 = await EmailMessages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (EmailMessage0?.setThread)
|
|
{
|
|
await
|
|
EmailMessage0.
|
|
setThread(relatedThread0);
|
|
}
|
|
|
|
const relatedThread1 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const EmailMessage1 = await EmailMessages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (EmailMessage1?.setThread)
|
|
{
|
|
await
|
|
EmailMessage1.
|
|
setThread(relatedThread1);
|
|
}
|
|
|
|
const relatedThread2 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const EmailMessage2 = await EmailMessages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (EmailMessage2?.setThread)
|
|
{
|
|
await
|
|
EmailMessage2.
|
|
setThread(relatedThread2);
|
|
}
|
|
|
|
const relatedThread3 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const EmailMessage3 = await EmailMessages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (EmailMessage3?.setThread)
|
|
{
|
|
await
|
|
EmailMessage3.
|
|
setThread(relatedThread3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateReplyDraftWithThread() {
|
|
|
|
const relatedThread0 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const ReplyDraft0 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ReplyDraft0?.setThread)
|
|
{
|
|
await
|
|
ReplyDraft0.
|
|
setThread(relatedThread0);
|
|
}
|
|
|
|
const relatedThread1 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const ReplyDraft1 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ReplyDraft1?.setThread)
|
|
{
|
|
await
|
|
ReplyDraft1.
|
|
setThread(relatedThread1);
|
|
}
|
|
|
|
const relatedThread2 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const ReplyDraft2 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ReplyDraft2?.setThread)
|
|
{
|
|
await
|
|
ReplyDraft2.
|
|
setThread(relatedThread2);
|
|
}
|
|
|
|
const relatedThread3 = await EmailThreads.findOne({
|
|
offset: Math.floor(Math.random() * (await EmailThreads.count())),
|
|
});
|
|
const ReplyDraft3 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (ReplyDraft3?.setThread)
|
|
{
|
|
await
|
|
ReplyDraft3.
|
|
setThread(relatedThread3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateReplyDraftWithStyle_profile() {
|
|
|
|
const relatedStyle_profile0 = await StyleProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await StyleProfiles.count())),
|
|
});
|
|
const ReplyDraft0 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ReplyDraft0?.setStyle_profile)
|
|
{
|
|
await
|
|
ReplyDraft0.
|
|
setStyle_profile(relatedStyle_profile0);
|
|
}
|
|
|
|
const relatedStyle_profile1 = await StyleProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await StyleProfiles.count())),
|
|
});
|
|
const ReplyDraft1 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ReplyDraft1?.setStyle_profile)
|
|
{
|
|
await
|
|
ReplyDraft1.
|
|
setStyle_profile(relatedStyle_profile1);
|
|
}
|
|
|
|
const relatedStyle_profile2 = await StyleProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await StyleProfiles.count())),
|
|
});
|
|
const ReplyDraft2 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ReplyDraft2?.setStyle_profile)
|
|
{
|
|
await
|
|
ReplyDraft2.
|
|
setStyle_profile(relatedStyle_profile2);
|
|
}
|
|
|
|
const relatedStyle_profile3 = await StyleProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await StyleProfiles.count())),
|
|
});
|
|
const ReplyDraft3 = await ReplyDrafts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (ReplyDraft3?.setStyle_profile)
|
|
{
|
|
await
|
|
ReplyDraft3.
|
|
setStyle_profile(relatedStyle_profile3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCreditWalletWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const CreditWallet0 = await CreditWallets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (CreditWallet0?.setUser)
|
|
{
|
|
await
|
|
CreditWallet0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const CreditWallet1 = await CreditWallets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (CreditWallet1?.setUser)
|
|
{
|
|
await
|
|
CreditWallet1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const CreditWallet2 = await CreditWallets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (CreditWallet2?.setUser)
|
|
{
|
|
await
|
|
CreditWallet2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const CreditWallet3 = await CreditWallets.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (CreditWallet3?.setUser)
|
|
{
|
|
await
|
|
CreditWallet3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCreditTransactionWithWallet() {
|
|
|
|
const relatedWallet0 = await CreditWallets.findOne({
|
|
offset: Math.floor(Math.random() * (await CreditWallets.count())),
|
|
});
|
|
const CreditTransaction0 = await CreditTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (CreditTransaction0?.setWallet)
|
|
{
|
|
await
|
|
CreditTransaction0.
|
|
setWallet(relatedWallet0);
|
|
}
|
|
|
|
const relatedWallet1 = await CreditWallets.findOne({
|
|
offset: Math.floor(Math.random() * (await CreditWallets.count())),
|
|
});
|
|
const CreditTransaction1 = await CreditTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (CreditTransaction1?.setWallet)
|
|
{
|
|
await
|
|
CreditTransaction1.
|
|
setWallet(relatedWallet1);
|
|
}
|
|
|
|
const relatedWallet2 = await CreditWallets.findOne({
|
|
offset: Math.floor(Math.random() * (await CreditWallets.count())),
|
|
});
|
|
const CreditTransaction2 = await CreditTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (CreditTransaction2?.setWallet)
|
|
{
|
|
await
|
|
CreditTransaction2.
|
|
setWallet(relatedWallet2);
|
|
}
|
|
|
|
const relatedWallet3 = await CreditWallets.findOne({
|
|
offset: Math.floor(Math.random() * (await CreditWallets.count())),
|
|
});
|
|
const CreditTransaction3 = await CreditTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (CreditTransaction3?.setWallet)
|
|
{
|
|
await
|
|
CreditTransaction3.
|
|
setWallet(relatedWallet3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateWebhookEventWithConnected_account() {
|
|
|
|
const relatedConnected_account0 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const WebhookEvent0 = await WebhookEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (WebhookEvent0?.setConnected_account)
|
|
{
|
|
await
|
|
WebhookEvent0.
|
|
setConnected_account(relatedConnected_account0);
|
|
}
|
|
|
|
const relatedConnected_account1 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const WebhookEvent1 = await WebhookEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (WebhookEvent1?.setConnected_account)
|
|
{
|
|
await
|
|
WebhookEvent1.
|
|
setConnected_account(relatedConnected_account1);
|
|
}
|
|
|
|
const relatedConnected_account2 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const WebhookEvent2 = await WebhookEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (WebhookEvent2?.setConnected_account)
|
|
{
|
|
await
|
|
WebhookEvent2.
|
|
setConnected_account(relatedConnected_account2);
|
|
}
|
|
|
|
const relatedConnected_account3 = await ConnectedAccounts.findOne({
|
|
offset: Math.floor(Math.random() * (await ConnectedAccounts.count())),
|
|
});
|
|
const WebhookEvent3 = await WebhookEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (WebhookEvent3?.setConnected_account)
|
|
{
|
|
await
|
|
WebhookEvent3.
|
|
setConnected_account(relatedConnected_account3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAuditLogWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog0 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (AuditLog0?.setUser)
|
|
{
|
|
await
|
|
AuditLog0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog1 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (AuditLog1?.setUser)
|
|
{
|
|
await
|
|
AuditLog1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog2 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (AuditLog2?.setUser)
|
|
{
|
|
await
|
|
AuditLog2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog3 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (AuditLog3?.setUser)
|
|
{
|
|
await
|
|
AuditLog3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await ConnectedAccounts.bulkCreate(ConnectedAccountsData);
|
|
|
|
|
|
|
|
|
|
await StyleProfiles.bulkCreate(StyleProfilesData);
|
|
|
|
|
|
|
|
|
|
await EmailThreads.bulkCreate(EmailThreadsData);
|
|
|
|
|
|
|
|
|
|
await EmailMessages.bulkCreate(EmailMessagesData);
|
|
|
|
|
|
|
|
|
|
await ReplyDrafts.bulkCreate(ReplyDraftsData);
|
|
|
|
|
|
|
|
|
|
await CreditWallets.bulkCreate(CreditWalletsData);
|
|
|
|
|
|
|
|
|
|
await CreditTransactions.bulkCreate(CreditTransactionsData);
|
|
|
|
|
|
|
|
|
|
await WebhookEvents.bulkCreate(WebhookEventsData);
|
|
|
|
|
|
|
|
|
|
await AuditLogs.bulkCreate(AuditLogsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateConnectedAccountWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateStyleProfileWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEmailThreadWithUser(),
|
|
|
|
|
|
|
|
|
|
await associateEmailThreadWithConnected_account(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEmailMessageWithThread(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateReplyDraftWithThread(),
|
|
|
|
|
|
|
|
|
|
await associateReplyDraftWithStyle_profile(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCreditWalletWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCreditTransactionWithWallet(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateWebhookEventWithConnected_account(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAuditLogWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('connected_accounts', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('style_profiles', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('email_threads', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('email_messages', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('reply_drafts', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('credit_wallets', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('credit_transactions', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('webhook_events', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('audit_logs', null, {});
|
|
|
|
|
|
},
|
|
}; |