Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.\"fileType\" as \"file_type!\",\n COALESCE(db.id, di.id, dipdf.id) as \"document_version_id!\",\n d.\"updatedAt\"::timestamptz as \"updated_at\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dst ON dst.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" ASC\n LIMIT 1\n ) dipdf ON d.\"fileType\" = 'pdf'\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"createdAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx' AND d.\"fileType\" IS DISTINCT FROM 'pdf'\n WHERE\n d.\"fileType\" IS NOT NULL\n AND ($3::text[] IS NULL OR d.\"fileType\" = ANY($3))\n AND ($4::text IS NULL OR dst.sub_type::text = $4)\n AND ($5::timestamptz IS NULL OR d.\"updatedAt\" >= $5)\n AND ($6::timestamptz IS NULL OR d.\"updatedAt\" < $6)\n AND (\n $7::bool IS NULL\n OR ($7 AND d.\"deletedAt\" IS NOT NULL)\n OR (NOT $7 AND d.\"deletedAt\" IS NULL)\n )\n AND (\n $2::timestamptz IS NULL\n OR (d.\"updatedAt\", d.id) > ($2, $8::text)\n )\n ORDER BY d.\"updatedAt\" ASC, d.id ASC\n LIMIT $1\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "document_id",
"type_info": "Text"
},
{
"ordinal": 1,
"name": "owner",
"type_info": "Text"
},
{
"ordinal": 2,
"name": "file_type!",
"type_info": "Text"
},
{
"ordinal": 3,
"name": "document_version_id!",
"type_info": "Int8"
},
{
"ordinal": 4,
"name": "updated_at",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Int8",
"Timestamptz",
"TextArray",
"Text",
"Timestamptz",
"Timestamptz",
"Bool",
"Text"
]
},
"nullable": [
false,
false,
true,
null,
null
]
},
"hash": "91368040542b31a69ae76bfc12b127970920fb761ec08d3303bffc94402b984e"
}