mcp-agendor 1.0.1
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.
- package/.env.example +9 -0
- package/README.md +3 -0
- package/dist/agendor/client.d.ts +40 -0
- package/dist/agendor/client.js +215 -0
- package/dist/agendor/types.d.ts +63 -0
- package/dist/agendor/types.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -0
- package/dist/schemas/inputs.d.ts +232 -0
- package/dist/schemas/inputs.js +65 -0
- package/dist/tools/deals.d.ts +20 -0
- package/dist/tools/deals.js +42 -0
- package/dist/tools/funnels.d.ts +6 -0
- package/dist/tools/funnels.js +11 -0
- package/dist/tools/pipeline-aging.d.ts +10 -0
- package/dist/tools/pipeline-aging.js +44 -0
- package/dist/tools/pipeline-overview.d.ts +10 -0
- package/dist/tools/pipeline-overview.js +57 -0
- package/dist/tools/pipeline-rep-performance.d.ts +10 -0
- package/dist/tools/pipeline-rep-performance.js +78 -0
- package/dist/tools/pipeline-report.d.ts +10 -0
- package/dist/tools/pipeline-report.js +235 -0
- package/dist/tools/pipeline-stage-metrics.d.ts +10 -0
- package/dist/tools/pipeline-stage-metrics.js +48 -0
- package/dist/tools/pipeline-trends.d.ts +10 -0
- package/dist/tools/pipeline-trends.js +76 -0
- package/dist/tools/users.d.ts +6 -0
- package/dist/tools/users.js +7 -0
- package/package.json +31 -0
- package/scripts/test-metrics-week.mjs +141 -0
- package/src/agendor/client.ts +248 -0
- package/src/agendor/types.ts +67 -0
- package/src/index.ts +31 -0
- package/src/schemas/inputs.ts +75 -0
- package/src/tools/deals.ts +61 -0
- package/src/tools/funnels.ts +16 -0
- package/src/tools/pipeline-aging.ts +51 -0
- package/src/tools/pipeline-overview.ts +68 -0
- package/src/tools/pipeline-rep-performance.ts +82 -0
- package/src/tools/pipeline-report.ts +263 -0
- package/src/tools/pipeline-stage-metrics.ts +61 -0
- package/src/tools/pipeline-trends.ts +88 -0
- package/src/tools/users.ts +12 -0
- package/tsconfig.json +16 -0
package/.env.example
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Agendor API (required)
|
|
2
|
+
AGENDOR_TOKEN=your_agendor_token_here
|
|
3
|
+
AGENDOR_BASE_URL=https://api.agendor.com.br/v3
|
|
4
|
+
|
|
5
|
+
# Optional: Postgres for event store (Fase 2)
|
|
6
|
+
# DATABASE_URL=postgresql://user:pass@localhost:5432/agendor_mcp
|
|
7
|
+
|
|
8
|
+
# Optional: HTTP server port (default: stdio only)
|
|
9
|
+
# PORT=3000
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agendor API V3 client: auth (Token header), pagination, retry (429/5xx), throttle.
|
|
3
|
+
* Normaliza respostas da API (camelCase) para snake_case usado pelas tools.
|
|
4
|
+
*/
|
|
5
|
+
import type { AgendorDeal, AgendorFunnel, AgendorTask, AgendorUser } from "./types.js";
|
|
6
|
+
export declare class AgendorClient {
|
|
7
|
+
private token;
|
|
8
|
+
private baseUrl;
|
|
9
|
+
constructor();
|
|
10
|
+
getFunnels(): Promise<AgendorFunnel[]>;
|
|
11
|
+
getUsers(): Promise<AgendorUser[]>;
|
|
12
|
+
getDeals(params?: {
|
|
13
|
+
dealStage?: number;
|
|
14
|
+
dealStatus?: string;
|
|
15
|
+
userOwner?: number;
|
|
16
|
+
organization?: number;
|
|
17
|
+
withCustomFields?: boolean;
|
|
18
|
+
page?: number;
|
|
19
|
+
per_page?: number;
|
|
20
|
+
created_after?: string;
|
|
21
|
+
updated_after?: string;
|
|
22
|
+
}): Promise<AgendorDeal[]>;
|
|
23
|
+
getAllDeals(params?: Omit<Parameters<AgendorClient["getDeals"]>[0], "page" | "per_page">): Promise<AgendorDeal[]>;
|
|
24
|
+
getDeal(id: number, withCustomFields?: boolean): Promise<AgendorDeal | null>;
|
|
25
|
+
getDealsStream(since: string): Promise<AgendorDeal[]>;
|
|
26
|
+
getDealsMovementsHistory(params?: {
|
|
27
|
+
deal_id?: number;
|
|
28
|
+
since?: string;
|
|
29
|
+
}): Promise<unknown[]>;
|
|
30
|
+
getTasks(params?: {
|
|
31
|
+
deal_id?: number;
|
|
32
|
+
since?: string;
|
|
33
|
+
}): Promise<AgendorTask[]>;
|
|
34
|
+
getDealTasks(dealId: number): Promise<AgendorTask[]>;
|
|
35
|
+
createDealTask(dealId: number, body: {
|
|
36
|
+
title: string;
|
|
37
|
+
due_date?: string;
|
|
38
|
+
}): Promise<AgendorTask>;
|
|
39
|
+
}
|
|
40
|
+
export declare function getAgendorClient(): AgendorClient;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agendor API V3 client: auth (Token header), pagination, retry (429/5xx), throttle.
|
|
3
|
+
* Normaliza respostas da API (camelCase) para snake_case usado pelas tools.
|
|
4
|
+
*/
|
|
5
|
+
import Bottleneck from "bottleneck";
|
|
6
|
+
import pRetry from "p-retry";
|
|
7
|
+
import { fetch as undiciFetch } from "undici";
|
|
8
|
+
const DEFAULT_BASE = "https://api.agendor.com.br/v3";
|
|
9
|
+
const PER_PAGE = 50;
|
|
10
|
+
const RATE_LIMIT_MIN_TIME = 1100; // ~1 req/s to avoid 429
|
|
11
|
+
function getConfig() {
|
|
12
|
+
const token = process.env.AGENDOR_TOKEN;
|
|
13
|
+
const baseUrl = process.env.AGENDOR_BASE_URL ?? DEFAULT_BASE;
|
|
14
|
+
if (!token) {
|
|
15
|
+
throw new Error("AGENDOR_TOKEN is required");
|
|
16
|
+
}
|
|
17
|
+
return { token, baseUrl: baseUrl.replace(/\/$/, "") };
|
|
18
|
+
}
|
|
19
|
+
function authHeaders(token) {
|
|
20
|
+
return {
|
|
21
|
+
Authorization: `Token ${token}`,
|
|
22
|
+
"Content-Type": "application/json",
|
|
23
|
+
Accept: "application/json",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Throttle all requests per process
|
|
27
|
+
const limiter = new Bottleneck({ minTime: RATE_LIMIT_MIN_TIME });
|
|
28
|
+
async function request(url, token, options = {}) {
|
|
29
|
+
const run = () => limiter.schedule(async () => {
|
|
30
|
+
const res = await undiciFetch(url, {
|
|
31
|
+
method: options.method ?? "GET",
|
|
32
|
+
headers: authHeaders(token),
|
|
33
|
+
body: options.body,
|
|
34
|
+
});
|
|
35
|
+
if (res.status === 429 || (res.status >= 500 && res.status < 600)) {
|
|
36
|
+
throw new Error(`HTTP ${res.status}`);
|
|
37
|
+
}
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
const text = await res.text();
|
|
40
|
+
throw new Error(`Agendor API ${res.status}: ${text.slice(0, 200)}`);
|
|
41
|
+
}
|
|
42
|
+
return res.json();
|
|
43
|
+
});
|
|
44
|
+
return pRetry(run, {
|
|
45
|
+
retries: 3,
|
|
46
|
+
onFailedAttempt: (e) => {
|
|
47
|
+
if (e.retriesLeft > 0) {
|
|
48
|
+
console.error(`[agendor] Retry after ${e.message}`);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** API retorna dealStages (camelCase); tools usam stages */
|
|
54
|
+
function normalizeFunnel(f) {
|
|
55
|
+
if (!f)
|
|
56
|
+
return;
|
|
57
|
+
const stages = (f.dealStages ?? f.stageList ?? f.stages);
|
|
58
|
+
if (Array.isArray(stages) && stages.length > 0)
|
|
59
|
+
f.stages = stages;
|
|
60
|
+
}
|
|
61
|
+
/** API retorna createdAt, dealStage, dealStatus (objeto); preenche snake_case no mesmo objeto */
|
|
62
|
+
function normalizeDeal(d) {
|
|
63
|
+
if (!d)
|
|
64
|
+
return;
|
|
65
|
+
const ds = d.dealStage;
|
|
66
|
+
if (ds != null && typeof ds.id === "number") {
|
|
67
|
+
d.deal_stage_id = ds.id;
|
|
68
|
+
d.deal_stage = d.deal_stage ?? { id: ds.id, name: ds.name ?? "" };
|
|
69
|
+
}
|
|
70
|
+
if (d.createdAt != null)
|
|
71
|
+
d.created_at = d.createdAt;
|
|
72
|
+
if (d.updatedAt != null)
|
|
73
|
+
d.updated_at = d.updatedAt;
|
|
74
|
+
const status = d.dealStatus;
|
|
75
|
+
if (status !== undefined && status !== null) {
|
|
76
|
+
const raw = typeof status === "string" ? status : status?.name ?? "";
|
|
77
|
+
const lower = String(raw).toLowerCase();
|
|
78
|
+
if (lower === "ganho")
|
|
79
|
+
d.deal_status = "won";
|
|
80
|
+
else if (lower === "perdido")
|
|
81
|
+
d.deal_status = "lost";
|
|
82
|
+
else
|
|
83
|
+
d.deal_status = raw;
|
|
84
|
+
}
|
|
85
|
+
if (d.wonAt != null && d.deal_status !== "won")
|
|
86
|
+
d.deal_status = "won";
|
|
87
|
+
if (d.lostAt != null && d.deal_status !== "lost")
|
|
88
|
+
d.deal_status = "lost";
|
|
89
|
+
const owner = d.owner;
|
|
90
|
+
if (owner != null && typeof owner.id === "number")
|
|
91
|
+
d.user_owner_id = owner.id;
|
|
92
|
+
}
|
|
93
|
+
export class AgendorClient {
|
|
94
|
+
token;
|
|
95
|
+
baseUrl;
|
|
96
|
+
constructor() {
|
|
97
|
+
const { token, baseUrl } = getConfig();
|
|
98
|
+
this.token = token;
|
|
99
|
+
this.baseUrl = baseUrl;
|
|
100
|
+
}
|
|
101
|
+
async getFunnels() {
|
|
102
|
+
const data = await request(`${this.baseUrl}/funnels`, this.token);
|
|
103
|
+
const list = Array.isArray(data) ? data : (data.data ?? []);
|
|
104
|
+
list.forEach((f) => normalizeFunnel(f));
|
|
105
|
+
return list;
|
|
106
|
+
}
|
|
107
|
+
async getUsers() {
|
|
108
|
+
const all = [];
|
|
109
|
+
let page = 1;
|
|
110
|
+
for (;;) {
|
|
111
|
+
const data = await request(`${this.baseUrl}/users?page=${page}&per_page=${PER_PAGE}`, this.token);
|
|
112
|
+
const list = data.data ?? [];
|
|
113
|
+
all.push(...list);
|
|
114
|
+
if (list.length < PER_PAGE)
|
|
115
|
+
break;
|
|
116
|
+
page += 1;
|
|
117
|
+
}
|
|
118
|
+
return all;
|
|
119
|
+
}
|
|
120
|
+
async getDeals(params = {}) {
|
|
121
|
+
const q = new URLSearchParams();
|
|
122
|
+
if (params.dealStage != null)
|
|
123
|
+
q.set("deal_stage_id", String(params.dealStage));
|
|
124
|
+
if (params.dealStatus)
|
|
125
|
+
q.set("deal_status", params.dealStatus);
|
|
126
|
+
if (params.userOwner != null)
|
|
127
|
+
q.set("user_owner_id", String(params.userOwner));
|
|
128
|
+
if (params.organization != null)
|
|
129
|
+
q.set("organization_id", String(params.organization));
|
|
130
|
+
if (params.withCustomFields !== false)
|
|
131
|
+
q.set("withCustomFields", "true");
|
|
132
|
+
q.set("page", String(params.page ?? 1));
|
|
133
|
+
q.set("per_page", String(params.per_page ?? PER_PAGE));
|
|
134
|
+
if (params.created_after)
|
|
135
|
+
q.set("created_after", params.created_after);
|
|
136
|
+
if (params.updated_after)
|
|
137
|
+
q.set("updated_after", params.updated_after);
|
|
138
|
+
const data = await request(`${this.baseUrl}/deals?${q.toString()}`, this.token);
|
|
139
|
+
const list = data.data ?? [];
|
|
140
|
+
list.forEach((d) => normalizeDeal(d));
|
|
141
|
+
return list;
|
|
142
|
+
}
|
|
143
|
+
async getAllDeals(params = {}) {
|
|
144
|
+
const all = [];
|
|
145
|
+
let page = 1;
|
|
146
|
+
for (;;) {
|
|
147
|
+
const list = await this.getDeals({ ...params, page, per_page: PER_PAGE });
|
|
148
|
+
all.push(...list);
|
|
149
|
+
if (list.length < PER_PAGE)
|
|
150
|
+
break;
|
|
151
|
+
page += 1;
|
|
152
|
+
}
|
|
153
|
+
return all;
|
|
154
|
+
}
|
|
155
|
+
async getDeal(id, withCustomFields = true) {
|
|
156
|
+
try {
|
|
157
|
+
const q = withCustomFields ? "?withCustomFields=true" : "";
|
|
158
|
+
const d = await request(`${this.baseUrl}/deals/${id}${q}`, this.token);
|
|
159
|
+
normalizeDeal(d);
|
|
160
|
+
return d;
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
if (e instanceof Error && e.message.includes("404"))
|
|
164
|
+
return null;
|
|
165
|
+
throw e;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async getDealsStream(since) {
|
|
169
|
+
const data = await request(`${this.baseUrl}/deals/stream?since=${encodeURIComponent(since)}`, this.token);
|
|
170
|
+
const list = Array.isArray(data) ? data : (data.data ?? []);
|
|
171
|
+
list.forEach((d) => normalizeDeal(d));
|
|
172
|
+
return list;
|
|
173
|
+
}
|
|
174
|
+
async getDealsMovementsHistory(params = {}) {
|
|
175
|
+
const q = new URLSearchParams();
|
|
176
|
+
if (params.deal_id != null)
|
|
177
|
+
q.set("deal_id", String(params.deal_id));
|
|
178
|
+
if (params.since)
|
|
179
|
+
q.set("since", params.since);
|
|
180
|
+
const url = `${this.baseUrl}/deals/movements_history${q.toString() ? `?${q.toString()}` : ""}`;
|
|
181
|
+
try {
|
|
182
|
+
const data = await request(url, this.token);
|
|
183
|
+
return Array.isArray(data) ? data : (data.data ?? []);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async getTasks(params = {}) {
|
|
190
|
+
const q = new URLSearchParams();
|
|
191
|
+
if (params.deal_id != null)
|
|
192
|
+
q.set("deal_id", String(params.deal_id));
|
|
193
|
+
if (params.since)
|
|
194
|
+
q.set("since", params.since);
|
|
195
|
+
const url = `${this.baseUrl}/tasks${q.toString() ? `?${q.toString()}` : ""}`;
|
|
196
|
+
const data = await request(url, this.token);
|
|
197
|
+
return Array.isArray(data) ? data : (data.data ?? []);
|
|
198
|
+
}
|
|
199
|
+
async getDealTasks(dealId) {
|
|
200
|
+
const data = await request(`${this.baseUrl}/deals/${dealId}/tasks`, this.token);
|
|
201
|
+
return Array.isArray(data) ? data : (data.data ?? []);
|
|
202
|
+
}
|
|
203
|
+
async createDealTask(dealId, body) {
|
|
204
|
+
return request(`${this.baseUrl}/deals/${dealId}/tasks`, this.token, {
|
|
205
|
+
method: "POST",
|
|
206
|
+
body: JSON.stringify(body),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
let defaultClient = null;
|
|
211
|
+
export function getAgendorClient() {
|
|
212
|
+
if (!defaultClient)
|
|
213
|
+
defaultClient = new AgendorClient();
|
|
214
|
+
return defaultClient;
|
|
215
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal types for Agendor API V3 responses (funnels, deals, users, tasks).
|
|
3
|
+
* Extend as needed when API docs are available.
|
|
4
|
+
*/
|
|
5
|
+
export interface AgendorFunnelStage {
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
order?: number;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface AgendorFunnel {
|
|
12
|
+
id: number;
|
|
13
|
+
name: string;
|
|
14
|
+
stages?: AgendorFunnelStage[];
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface AgendorUser {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface AgendorDeal {
|
|
24
|
+
id: number;
|
|
25
|
+
name?: string;
|
|
26
|
+
value?: number;
|
|
27
|
+
deal_stage_id?: number;
|
|
28
|
+
deal_stage?: {
|
|
29
|
+
id: number;
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
deal_status?: string;
|
|
33
|
+
user_owner_id?: number;
|
|
34
|
+
user_owner?: AgendorUser;
|
|
35
|
+
organization_id?: number;
|
|
36
|
+
created_at?: string;
|
|
37
|
+
updated_at?: string;
|
|
38
|
+
customFields?: Record<string, unknown>;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface AgendorTask {
|
|
42
|
+
id: number;
|
|
43
|
+
deal_id?: number;
|
|
44
|
+
title?: string;
|
|
45
|
+
due_date?: string;
|
|
46
|
+
completed_at?: string;
|
|
47
|
+
created_at?: string;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
export interface AgendorDealMovement {
|
|
51
|
+
deal_id: number;
|
|
52
|
+
from_stage_id?: number;
|
|
53
|
+
to_stage_id?: number;
|
|
54
|
+
created_at?: string;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
export interface AgendorPagedResponse<T> {
|
|
58
|
+
data?: T[];
|
|
59
|
+
total?: number;
|
|
60
|
+
page?: number;
|
|
61
|
+
per_page?: number;
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { funnelsList } from "./tools/funnels.js";
|
|
6
|
+
import { usersList } from "./tools/users.js";
|
|
7
|
+
import { dealsList, dealsGet, dealsTimeline } from "./tools/deals.js";
|
|
8
|
+
import { pipelineOverview } from "./tools/pipeline-overview.js";
|
|
9
|
+
import { pipelineStageMetrics } from "./tools/pipeline-stage-metrics.js";
|
|
10
|
+
import { pipelineTrends } from "./tools/pipeline-trends.js";
|
|
11
|
+
import { pipelineAging } from "./tools/pipeline-aging.js";
|
|
12
|
+
import { pipelineRepPerformance } from "./tools/pipeline-rep-performance.js";
|
|
13
|
+
import { pipelineReport } from "./tools/pipeline-report.js";
|
|
14
|
+
import * as schemas from "./schemas/inputs.js";
|
|
15
|
+
const server = new McpServer({ name: "mcp-agendor", version: "1.0.0" });
|
|
16
|
+
server.registerTool("funnels_list", { title: "List funnels", description: "Lista funis e etapas", inputSchema: z.object({}) }, () => funnelsList());
|
|
17
|
+
server.registerTool("users_list", { title: "List users", description: "Lista usuarios", inputSchema: z.object({}) }, () => usersList());
|
|
18
|
+
server.registerTool("deals_list", { title: "List deals", description: "Lista negocios", inputSchema: schemas.dealsListSchema }, (a) => dealsList(a));
|
|
19
|
+
server.registerTool("deals_get", { title: "Get deal", description: "Negocio por ID", inputSchema: schemas.dealsGetSchema }, (a) => dealsGet(a));
|
|
20
|
+
server.registerTool("deals_timeline", { title: "Deal timeline", description: "Movimentacoes e tarefas", inputSchema: schemas.dealsTimelineSchema }, (a) => dealsTimeline(a));
|
|
21
|
+
server.registerTool("pipeline_overview", { title: "Pipeline overview", description: "Snapshot e distribuicao", inputSchema: schemas.pipelineOverviewSchema }, (a) => pipelineOverview(a));
|
|
22
|
+
server.registerTool("pipeline_stage_metrics", { title: "Stage metrics", description: "Metricas por coluna", inputSchema: schemas.pipelineStageMetricsSchema }, (a) => pipelineStageMetrics(a));
|
|
23
|
+
server.registerTool("pipeline_trends", { title: "Pipeline trends", description: "Novos ganhos perdidos por periodo", inputSchema: schemas.pipelineTrendsSchema }, (a) => pipelineTrends(a));
|
|
24
|
+
server.registerTool("pipeline_aging", { title: "Pipeline aging", description: "Parados e ranking risco", inputSchema: schemas.pipelineAgingSchema }, (a) => pipelineAging(a));
|
|
25
|
+
server.registerTool("pipeline_rep_performance", { title: "Rep performance", description: "Por responsavel", inputSchema: schemas.pipelineRepPerformanceSchema }, (a) => pipelineRepPerformance(a));
|
|
26
|
+
server.registerTool("pipeline_report", { title: "Pipeline full report", description: "Relatório completo: leads por status, valor em análise (forecast), valores ganhos/perdidos, tempo médio por coluna", inputSchema: schemas.pipelineReportSchema }, (a) => pipelineReport(a));
|
|
27
|
+
const transport = new StdioServerTransport();
|
|
28
|
+
await server.connect(transport);
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const pipelineIdSchema: z.ZodOptional<z.ZodNumber>;
|
|
3
|
+
export declare const rangeSchema: z.ZodOptional<z.ZodObject<{
|
|
4
|
+
start: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
5
|
+
end: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
start: string;
|
|
8
|
+
end: string;
|
|
9
|
+
}, {
|
|
10
|
+
start: string;
|
|
11
|
+
end: string;
|
|
12
|
+
}>>;
|
|
13
|
+
export declare const timezoneSchema: z.ZodDefault<z.ZodString>;
|
|
14
|
+
export declare const groupBySchema: z.ZodOptional<z.ZodEnum<["day", "week", "month", "quarter"]>>;
|
|
15
|
+
export declare const ownerIdSchema: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
export declare const includeValueSchema: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
17
|
+
export declare const pipelineOverviewSchema: z.ZodObject<{
|
|
18
|
+
pipeline_id: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
range: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
start: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
21
|
+
end: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
start: string;
|
|
24
|
+
end: string;
|
|
25
|
+
}, {
|
|
26
|
+
start: string;
|
|
27
|
+
end: string;
|
|
28
|
+
}>>;
|
|
29
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
30
|
+
group_by: z.ZodOptional<z.ZodEnum<["day", "week", "month", "quarter"]>>;
|
|
31
|
+
owner_id: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
include_value: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
timezone: string;
|
|
35
|
+
include_value: boolean;
|
|
36
|
+
pipeline_id?: number | undefined;
|
|
37
|
+
range?: {
|
|
38
|
+
start: string;
|
|
39
|
+
end: string;
|
|
40
|
+
} | undefined;
|
|
41
|
+
group_by?: "day" | "week" | "month" | "quarter" | undefined;
|
|
42
|
+
owner_id?: number | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
pipeline_id?: number | undefined;
|
|
45
|
+
range?: {
|
|
46
|
+
start: string;
|
|
47
|
+
end: string;
|
|
48
|
+
} | undefined;
|
|
49
|
+
timezone?: string | undefined;
|
|
50
|
+
group_by?: "day" | "week" | "month" | "quarter" | undefined;
|
|
51
|
+
owner_id?: number | undefined;
|
|
52
|
+
include_value?: boolean | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const pipelineStageMetricsSchema: z.ZodObject<{
|
|
55
|
+
pipeline_id: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
range: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
start: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
58
|
+
end: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
start: string;
|
|
61
|
+
end: string;
|
|
62
|
+
}, {
|
|
63
|
+
start: string;
|
|
64
|
+
end: string;
|
|
65
|
+
}>>;
|
|
66
|
+
owner_id: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
pipeline_id?: number | undefined;
|
|
69
|
+
range?: {
|
|
70
|
+
start: string;
|
|
71
|
+
end: string;
|
|
72
|
+
} | undefined;
|
|
73
|
+
owner_id?: number | undefined;
|
|
74
|
+
}, {
|
|
75
|
+
pipeline_id?: number | undefined;
|
|
76
|
+
range?: {
|
|
77
|
+
start: string;
|
|
78
|
+
end: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
owner_id?: number | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
export declare const pipelineTrendsSchema: z.ZodObject<{
|
|
83
|
+
pipeline_id: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
range: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
85
|
+
start: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
86
|
+
end: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
start: string;
|
|
89
|
+
end: string;
|
|
90
|
+
}, {
|
|
91
|
+
start: string;
|
|
92
|
+
end: string;
|
|
93
|
+
}>>>;
|
|
94
|
+
group_by: z.ZodOptional<z.ZodEnum<["day", "week", "month", "quarter"]>>;
|
|
95
|
+
owner_id: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
pipeline_id?: number | undefined;
|
|
98
|
+
range?: {
|
|
99
|
+
start: string;
|
|
100
|
+
end: string;
|
|
101
|
+
} | undefined;
|
|
102
|
+
group_by?: "day" | "week" | "month" | "quarter" | undefined;
|
|
103
|
+
owner_id?: number | undefined;
|
|
104
|
+
}, {
|
|
105
|
+
pipeline_id?: number | undefined;
|
|
106
|
+
range?: {
|
|
107
|
+
start: string;
|
|
108
|
+
end: string;
|
|
109
|
+
} | undefined;
|
|
110
|
+
group_by?: "day" | "week" | "month" | "quarter" | undefined;
|
|
111
|
+
owner_id?: number | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
export declare const pipelineAgingSchema: z.ZodObject<{
|
|
114
|
+
pipeline_id: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
days_without_activity: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
116
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
days_without_activity: number;
|
|
119
|
+
limit: number;
|
|
120
|
+
pipeline_id?: number | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
pipeline_id?: number | undefined;
|
|
123
|
+
days_without_activity?: number | undefined;
|
|
124
|
+
limit?: number | undefined;
|
|
125
|
+
}>;
|
|
126
|
+
export declare const pipelineRepPerformanceSchema: z.ZodObject<{
|
|
127
|
+
pipeline_id: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
range: z.ZodOptional<z.ZodObject<{
|
|
129
|
+
start: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
130
|
+
end: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
start: string;
|
|
133
|
+
end: string;
|
|
134
|
+
}, {
|
|
135
|
+
start: string;
|
|
136
|
+
end: string;
|
|
137
|
+
}>>;
|
|
138
|
+
owner_id: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
pipeline_id?: number | undefined;
|
|
141
|
+
range?: {
|
|
142
|
+
start: string;
|
|
143
|
+
end: string;
|
|
144
|
+
} | undefined;
|
|
145
|
+
owner_id?: number | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
pipeline_id?: number | undefined;
|
|
148
|
+
range?: {
|
|
149
|
+
start: string;
|
|
150
|
+
end: string;
|
|
151
|
+
} | undefined;
|
|
152
|
+
owner_id?: number | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
export declare const pipelineReportSchema: z.ZodObject<{
|
|
155
|
+
pipeline_id: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
todos_os_funis: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
157
|
+
range: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
158
|
+
start: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
159
|
+
end: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
start: string;
|
|
162
|
+
end: string;
|
|
163
|
+
}, {
|
|
164
|
+
start: string;
|
|
165
|
+
end: string;
|
|
166
|
+
}>>>;
|
|
167
|
+
owner_id: z.ZodOptional<z.ZodNumber>;
|
|
168
|
+
include_tempo_medio: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
169
|
+
}, "strip", z.ZodTypeAny, {
|
|
170
|
+
todos_os_funis: boolean;
|
|
171
|
+
include_tempo_medio: boolean;
|
|
172
|
+
pipeline_id?: number | undefined;
|
|
173
|
+
range?: {
|
|
174
|
+
start: string;
|
|
175
|
+
end: string;
|
|
176
|
+
} | undefined;
|
|
177
|
+
owner_id?: number | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
pipeline_id?: number | undefined;
|
|
180
|
+
range?: {
|
|
181
|
+
start: string;
|
|
182
|
+
end: string;
|
|
183
|
+
} | undefined;
|
|
184
|
+
owner_id?: number | undefined;
|
|
185
|
+
todos_os_funis?: boolean | undefined;
|
|
186
|
+
include_tempo_medio?: boolean | undefined;
|
|
187
|
+
}>;
|
|
188
|
+
export declare const dealsListSchema: z.ZodObject<{
|
|
189
|
+
pipeline_id: z.ZodOptional<z.ZodNumber>;
|
|
190
|
+
stage_id: z.ZodOptional<z.ZodNumber>;
|
|
191
|
+
status: z.ZodOptional<z.ZodEnum<["open", "won", "lost"]>>;
|
|
192
|
+
owner_id: z.ZodOptional<z.ZodNumber>;
|
|
193
|
+
organization_id: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
with_custom_fields: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
195
|
+
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
196
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
197
|
+
}, "strip", z.ZodTypeAny, {
|
|
198
|
+
page: number;
|
|
199
|
+
per_page: number;
|
|
200
|
+
with_custom_fields: boolean;
|
|
201
|
+
organization_id?: number | undefined;
|
|
202
|
+
status?: "won" | "lost" | "open" | undefined;
|
|
203
|
+
pipeline_id?: number | undefined;
|
|
204
|
+
owner_id?: number | undefined;
|
|
205
|
+
stage_id?: number | undefined;
|
|
206
|
+
}, {
|
|
207
|
+
organization_id?: number | undefined;
|
|
208
|
+
page?: number | undefined;
|
|
209
|
+
per_page?: number | undefined;
|
|
210
|
+
status?: "won" | "lost" | "open" | undefined;
|
|
211
|
+
pipeline_id?: number | undefined;
|
|
212
|
+
owner_id?: number | undefined;
|
|
213
|
+
stage_id?: number | undefined;
|
|
214
|
+
with_custom_fields?: boolean | undefined;
|
|
215
|
+
}>;
|
|
216
|
+
export declare const dealsGetSchema: z.ZodObject<{
|
|
217
|
+
id: z.ZodNumber;
|
|
218
|
+
with_custom_fields: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
219
|
+
}, "strip", z.ZodTypeAny, {
|
|
220
|
+
id: number;
|
|
221
|
+
with_custom_fields: boolean;
|
|
222
|
+
}, {
|
|
223
|
+
id: number;
|
|
224
|
+
with_custom_fields?: boolean | undefined;
|
|
225
|
+
}>;
|
|
226
|
+
export declare const dealsTimelineSchema: z.ZodObject<{
|
|
227
|
+
id: z.ZodNumber;
|
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
|
229
|
+
id: number;
|
|
230
|
+
}, {
|
|
231
|
+
id: number;
|
|
232
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const pipelineIdSchema = z.number().int().positive().optional();
|
|
3
|
+
export const rangeSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
start: z.string().datetime().or(z.string().regex(/^\d{4}-\d{2}-\d{2}$/)),
|
|
6
|
+
end: z.string().datetime().or(z.string().regex(/^\d{4}-\d{2}-\d{2}$/)),
|
|
7
|
+
})
|
|
8
|
+
.optional();
|
|
9
|
+
export const timezoneSchema = z.string().default("America/Sao_Paulo");
|
|
10
|
+
export const groupBySchema = z.enum(["day", "week", "month", "quarter"]).optional();
|
|
11
|
+
export const ownerIdSchema = z.number().int().positive().optional();
|
|
12
|
+
export const includeValueSchema = z.boolean().optional().default(true);
|
|
13
|
+
export const pipelineOverviewSchema = z.object({
|
|
14
|
+
pipeline_id: pipelineIdSchema,
|
|
15
|
+
range: rangeSchema,
|
|
16
|
+
timezone: timezoneSchema,
|
|
17
|
+
group_by: groupBySchema,
|
|
18
|
+
owner_id: ownerIdSchema,
|
|
19
|
+
include_value: includeValueSchema,
|
|
20
|
+
});
|
|
21
|
+
export const pipelineStageMetricsSchema = z.object({
|
|
22
|
+
pipeline_id: pipelineIdSchema,
|
|
23
|
+
range: rangeSchema,
|
|
24
|
+
owner_id: ownerIdSchema,
|
|
25
|
+
});
|
|
26
|
+
export const pipelineTrendsSchema = z.object({
|
|
27
|
+
pipeline_id: pipelineIdSchema,
|
|
28
|
+
range: rangeSchema.optional(),
|
|
29
|
+
group_by: groupBySchema,
|
|
30
|
+
owner_id: ownerIdSchema,
|
|
31
|
+
});
|
|
32
|
+
export const pipelineAgingSchema = z.object({
|
|
33
|
+
pipeline_id: pipelineIdSchema,
|
|
34
|
+
days_without_activity: z.number().int().min(0).optional().default(7),
|
|
35
|
+
limit: z.number().int().min(1).max(100).optional().default(20),
|
|
36
|
+
});
|
|
37
|
+
export const pipelineRepPerformanceSchema = z.object({
|
|
38
|
+
pipeline_id: pipelineIdSchema,
|
|
39
|
+
range: rangeSchema,
|
|
40
|
+
owner_id: ownerIdSchema,
|
|
41
|
+
});
|
|
42
|
+
export const pipelineReportSchema = z.object({
|
|
43
|
+
pipeline_id: pipelineIdSchema,
|
|
44
|
+
todos_os_funis: z.boolean().optional().default(true),
|
|
45
|
+
range: rangeSchema.optional(),
|
|
46
|
+
owner_id: ownerIdSchema,
|
|
47
|
+
include_tempo_medio: z.boolean().optional().default(true),
|
|
48
|
+
});
|
|
49
|
+
export const dealsListSchema = z.object({
|
|
50
|
+
pipeline_id: pipelineIdSchema,
|
|
51
|
+
stage_id: z.number().int().positive().optional(),
|
|
52
|
+
status: z.enum(["open", "won", "lost"]).optional(),
|
|
53
|
+
owner_id: ownerIdSchema,
|
|
54
|
+
organization_id: z.number().int().positive().optional(),
|
|
55
|
+
with_custom_fields: z.boolean().optional().default(true),
|
|
56
|
+
page: z.number().int().min(1).optional().default(1),
|
|
57
|
+
per_page: z.number().int().min(1).max(100).optional().default(50),
|
|
58
|
+
});
|
|
59
|
+
export const dealsGetSchema = z.object({
|
|
60
|
+
id: z.number().int().positive(),
|
|
61
|
+
with_custom_fields: z.boolean().optional().default(true),
|
|
62
|
+
});
|
|
63
|
+
export const dealsTimelineSchema = z.object({
|
|
64
|
+
id: z.number().int().positive(),
|
|
65
|
+
});
|