CRM Revenue Execution Limit Utility (receitas/limite.ts)

DeskcommCRM · lib/external-db/receitas/limite.ts · typescript · MIT
pos, crm, lang:typescript, tag:limits, tag:query

Calculates item and row limits for CRM revenue queries and agent tools to prevent excessive data loads.

// Source: https://github.com/melgarafael/DeskcommCRM | License: MIT | Copyright 2026 Rafael Melgaço
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * TETO DE ITENS de uma execução de receita — usado pela ferramenta do agente
 * (`crm_consultar_receita`) e pela pré-visualização da rota, para as duas
 * nunca divergirem.
 *
 * - `limiteItens`: o que o agente pediu (`busca.limite`), limitado ao teto da
 *   receita (`receita.tetoDeItens`).
 * - `limiteMax`: teto total enviado ao dialeto — o menor entre o `max_rows`
 *   da conexão (200 por padrão) e o `limiteItens × nº de termos` (ou 1 sem
 *   termos). É a mesma conta da prévia.
 */
export function limiteDaReceita(params: {
  buscaLimite: number | undefined;
  tetoDeItens: number;
  maxRows: number | undefined;
  termo

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key