salesflare-mcp-server 1.0.0
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/API.md +691 -0
- package/CHANGELOG.md +49 -0
- package/CLAUDE.md +117 -0
- package/CONTRIBUTING.md +399 -0
- package/FIX_PLAN.md +70 -0
- package/INSPECTOR.md +191 -0
- package/LICENSE +21 -0
- package/PUBLISH.md +73 -0
- package/README.md +383 -0
- package/dist/auth/api-key-auth.d.ts +75 -0
- package/dist/auth/api-key-auth.d.ts.map +1 -0
- package/dist/auth/api-key-auth.js +103 -0
- package/dist/auth/oauth-auth.d.ts +81 -0
- package/dist/auth/oauth-auth.d.ts.map +1 -0
- package/dist/auth/oauth-auth.js +123 -0
- package/dist/auth/token-manager.d.ts +105 -0
- package/dist/auth/token-manager.d.ts.map +1 -0
- package/dist/auth/token-manager.js +87 -0
- package/dist/client/salesflare-client.d.ts +219 -0
- package/dist/client/salesflare-client.d.ts.map +1 -0
- package/dist/client/salesflare-client.js +484 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/server.d.ts +39 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +140 -0
- package/dist/tools/companies.d.ts +45 -0
- package/dist/tools/companies.d.ts.map +1 -0
- package/dist/tools/companies.js +392 -0
- package/dist/tools/contacts.d.ts +45 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +290 -0
- package/dist/tools/deals.d.ts +46 -0
- package/dist/tools/deals.d.ts.map +1 -0
- package/dist/tools/deals.js +442 -0
- package/dist/tools/pipeline.d.ts +43 -0
- package/dist/tools/pipeline.d.ts.map +1 -0
- package/dist/tools/pipeline.js +328 -0
- package/dist/tools/tasks.d.ts +44 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +406 -0
- package/dist/transport/http-transport.d.ts +36 -0
- package/dist/transport/http-transport.d.ts.map +1 -0
- package/dist/transport/http-transport.js +173 -0
- package/dist/transport/stdio-transport.d.ts +37 -0
- package/dist/transport/stdio-transport.d.ts.map +1 -0
- package/dist/transport/stdio-transport.js +129 -0
- package/dist/types/company.d.ts +223 -0
- package/dist/types/company.d.ts.map +1 -0
- package/dist/types/company.js +8 -0
- package/dist/types/contact.d.ts +166 -0
- package/dist/types/contact.d.ts.map +1 -0
- package/dist/types/contact.js +8 -0
- package/dist/types/deal.d.ts +203 -0
- package/dist/types/deal.d.ts.map +1 -0
- package/dist/types/deal.js +8 -0
- package/dist/types/pipeline.d.ts +116 -0
- package/dist/types/pipeline.d.ts.map +1 -0
- package/dist/types/pipeline.js +8 -0
- package/dist/types/task.d.ts +154 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +8 -0
- package/dist/utils/errors.d.ts +128 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +205 -0
- package/dist/utils/validation.d.ts +354 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +716 -0
- package/package.json +49 -0
- package/test-tasks-debug.js +21 -0
- package/test-tasks-params.js +52 -0
- package/test-tools.js +171 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for Salesflare MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Provides standardized error types with actionable messages for LLM consumers.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/errors
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Standardized error codes for Salesflare MCP Server
|
|
10
|
+
*
|
|
11
|
+
* These codes enable programmatic error handling by LLMs.
|
|
12
|
+
*/
|
|
13
|
+
export var ErrorCode;
|
|
14
|
+
(function (ErrorCode) {
|
|
15
|
+
// Authentication errors
|
|
16
|
+
ErrorCode["AUTH_INVALID"] = "AUTH_INVALID";
|
|
17
|
+
ErrorCode["AUTH_EXPIRED"] = "AUTH_EXPIRED";
|
|
18
|
+
ErrorCode["AUTH_REQUIRED"] = "AUTH_REQUIRED";
|
|
19
|
+
// API errors
|
|
20
|
+
ErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
21
|
+
ErrorCode["RATE_LIMIT"] = "RATE_LIMIT";
|
|
22
|
+
ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
23
|
+
ErrorCode["API_ERROR"] = "API_ERROR";
|
|
24
|
+
ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
25
|
+
// Validation errors
|
|
26
|
+
ErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
27
|
+
ErrorCode["INVALID_INPUT"] = "INVALID_INPUT";
|
|
28
|
+
// Configuration errors
|
|
29
|
+
ErrorCode["CONFIG_ERROR"] = "CONFIG_ERROR";
|
|
30
|
+
ErrorCode["MISSING_ENV_VAR"] = "MISSING_ENV_VAR";
|
|
31
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
32
|
+
/**
|
|
33
|
+
* Base error class for Salesflare MCP Server
|
|
34
|
+
*
|
|
35
|
+
* Provides structured error information with codes, fix suggestions,
|
|
36
|
+
* and retry guidance for LLM consumers.
|
|
37
|
+
*/
|
|
38
|
+
export class SalesflareError extends Error {
|
|
39
|
+
/** Error code for programmatic handling */
|
|
40
|
+
code;
|
|
41
|
+
/** Suggested fix for the error */
|
|
42
|
+
fix;
|
|
43
|
+
/** Whether the operation can be retried */
|
|
44
|
+
retryable;
|
|
45
|
+
/** HTTP status code if applicable */
|
|
46
|
+
statusCode;
|
|
47
|
+
/** Additional error details */
|
|
48
|
+
details;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new SalesflareError
|
|
51
|
+
*
|
|
52
|
+
* @param metadata - Error metadata including code, message, and fix
|
|
53
|
+
*/
|
|
54
|
+
constructor(metadata) {
|
|
55
|
+
super(metadata.message);
|
|
56
|
+
this.name = 'SalesflareError';
|
|
57
|
+
this.code = metadata.code;
|
|
58
|
+
this.fix = metadata.fix;
|
|
59
|
+
this.retryable = metadata.retryable;
|
|
60
|
+
this.statusCode = metadata.statusCode;
|
|
61
|
+
this.details = metadata.details;
|
|
62
|
+
// Ensure proper prototype chain for instanceof checks
|
|
63
|
+
Object.setPrototypeOf(this, SalesflareError.prototype);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Convert error to JSON-serializable object
|
|
67
|
+
*
|
|
68
|
+
* @returns Error metadata as plain object
|
|
69
|
+
*/
|
|
70
|
+
toJSON() {
|
|
71
|
+
return {
|
|
72
|
+
code: this.code,
|
|
73
|
+
message: this.message,
|
|
74
|
+
fix: this.fix,
|
|
75
|
+
retryable: this.retryable,
|
|
76
|
+
statusCode: this.statusCode,
|
|
77
|
+
details: this.details,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Format error for MCP tool response
|
|
82
|
+
*
|
|
83
|
+
* @returns Formatted error string with fix suggestion
|
|
84
|
+
*/
|
|
85
|
+
toToolResponse() {
|
|
86
|
+
let response = `Error [${this.code}]: ${this.message}`;
|
|
87
|
+
if (this.fix) {
|
|
88
|
+
response += `\n\nFix: ${this.fix}`;
|
|
89
|
+
}
|
|
90
|
+
if (this.retryable) {
|
|
91
|
+
response += '\n\nThis error is retryable.';
|
|
92
|
+
}
|
|
93
|
+
return response;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create an authentication error
|
|
98
|
+
*
|
|
99
|
+
* @param message - Error message
|
|
100
|
+
* @param fix - Suggested fix
|
|
101
|
+
* @returns SalesflareError with AUTH_INVALID code
|
|
102
|
+
*/
|
|
103
|
+
export function createAuthError(message, fix) {
|
|
104
|
+
return new SalesflareError({
|
|
105
|
+
code: ErrorCode.AUTH_INVALID,
|
|
106
|
+
message,
|
|
107
|
+
fix,
|
|
108
|
+
retryable: false,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a validation error
|
|
113
|
+
*
|
|
114
|
+
* @param message - Error message
|
|
115
|
+
* @param details - Validation details
|
|
116
|
+
* @returns SalesflareError with VALIDATION_ERROR code
|
|
117
|
+
*/
|
|
118
|
+
export function createValidationError(message, details) {
|
|
119
|
+
return new SalesflareError({
|
|
120
|
+
code: ErrorCode.VALIDATION_ERROR,
|
|
121
|
+
message,
|
|
122
|
+
retryable: false,
|
|
123
|
+
details,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Create a configuration error
|
|
128
|
+
*
|
|
129
|
+
* @param message - Error message
|
|
130
|
+
* @param fix - Suggested fix
|
|
131
|
+
* @returns SalesflareError with CONFIG_ERROR code
|
|
132
|
+
*/
|
|
133
|
+
export function createConfigError(message, fix) {
|
|
134
|
+
return new SalesflareError({
|
|
135
|
+
code: ErrorCode.CONFIG_ERROR,
|
|
136
|
+
message,
|
|
137
|
+
fix,
|
|
138
|
+
retryable: false,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a missing environment variable error
|
|
143
|
+
*
|
|
144
|
+
* @param varName - Name of the missing environment variable
|
|
145
|
+
* @returns SalesflareError with MISSING_ENV_VAR code
|
|
146
|
+
*/
|
|
147
|
+
export function createMissingEnvVarError(varName) {
|
|
148
|
+
return new SalesflareError({
|
|
149
|
+
code: ErrorCode.MISSING_ENV_VAR,
|
|
150
|
+
message: `${varName} environment variable is required`,
|
|
151
|
+
fix: `Set ${varName} to the appropriate value and restart the server`,
|
|
152
|
+
retryable: false,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Error code to fix suggestion mapping
|
|
157
|
+
*/
|
|
158
|
+
const ERROR_CODE_FIXES = {
|
|
159
|
+
[ErrorCode.AUTH_INVALID]: 'Check your SALESFLARE_API_KEY environment variable',
|
|
160
|
+
[ErrorCode.AUTH_EXPIRED]: 'Re-authenticate to obtain a new token',
|
|
161
|
+
[ErrorCode.AUTH_REQUIRED]: 'Provide authentication credentials',
|
|
162
|
+
[ErrorCode.RATE_LIMIT]: 'Wait before retrying; consider reducing request frequency',
|
|
163
|
+
[ErrorCode.NOT_FOUND]: 'Verify the resource ID is correct',
|
|
164
|
+
[ErrorCode.SERVER_ERROR]: 'The Salesflare API is experiencing issues. Try again later',
|
|
165
|
+
[ErrorCode.API_ERROR]: 'Check the API documentation or try again later',
|
|
166
|
+
[ErrorCode.NETWORK_ERROR]: 'Check your internet connection and try again',
|
|
167
|
+
[ErrorCode.VALIDATION_ERROR]: 'Check the input parameters against the schema',
|
|
168
|
+
[ErrorCode.INVALID_INPUT]: 'Review the input format and try again',
|
|
169
|
+
[ErrorCode.CONFIG_ERROR]: 'Check your server configuration',
|
|
170
|
+
[ErrorCode.MISSING_ENV_VAR]: 'Set the required environment variable and restart',
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Format any error into a consistent error response with actionable fix suggestion
|
|
174
|
+
*
|
|
175
|
+
* @param error - The error to format (SalesflareError, generic Error, or unknown)
|
|
176
|
+
* @returns Formatted error response with code, message, details, retryable flag, and fix suggestion
|
|
177
|
+
*/
|
|
178
|
+
export function formatErrorResponse(error) {
|
|
179
|
+
// Handle SalesflareError
|
|
180
|
+
if (error instanceof SalesflareError) {
|
|
181
|
+
return {
|
|
182
|
+
code: error.code,
|
|
183
|
+
message: error.message,
|
|
184
|
+
details: error.details,
|
|
185
|
+
retryable: error.retryable,
|
|
186
|
+
fix: error.fix || ERROR_CODE_FIXES[error.code],
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// Handle generic Error
|
|
190
|
+
if (error instanceof Error) {
|
|
191
|
+
return {
|
|
192
|
+
code: ErrorCode.SERVER_ERROR,
|
|
193
|
+
message: error.message,
|
|
194
|
+
retryable: false,
|
|
195
|
+
fix: ERROR_CODE_FIXES[ErrorCode.SERVER_ERROR],
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
// Handle unknown errors
|
|
199
|
+
return {
|
|
200
|
+
code: ErrorCode.SERVER_ERROR,
|
|
201
|
+
message: 'Unknown error occurred',
|
|
202
|
+
retryable: false,
|
|
203
|
+
fix: ERROR_CODE_FIXES[ErrorCode.SERVER_ERROR],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for Salesflare MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Provides Zod-based input validation with SalesflareError integration
|
|
5
|
+
* for consistent error handling across the codebase.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { SalesflareError } from './errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validation result type
|
|
11
|
+
*/
|
|
12
|
+
export type ValidationResult<T> = {
|
|
13
|
+
success: true;
|
|
14
|
+
data: T;
|
|
15
|
+
} | {
|
|
16
|
+
success: false;
|
|
17
|
+
error: SalesflareError;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Validate input data against a Zod schema
|
|
21
|
+
*
|
|
22
|
+
* @param schema - Zod schema to validate against
|
|
23
|
+
* @param data - Data to validate
|
|
24
|
+
* @returns Validated data (typed)
|
|
25
|
+
* @throws SalesflareError with VALIDATION_ERROR code if validation fails
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateInput<T>(schema: z.ZodSchema<T>, data: unknown): T;
|
|
28
|
+
/**
|
|
29
|
+
* Safely validate input and return result without throwing
|
|
30
|
+
*
|
|
31
|
+
* @param schema - Zod schema to validate against
|
|
32
|
+
* @param data - Data to validate
|
|
33
|
+
* @returns ValidationResult with either data or error
|
|
34
|
+
*/
|
|
35
|
+
export declare function safeValidateInput<T>(schema: z.ZodSchema<T>, data: unknown): ValidationResult<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Pagination parameters schema
|
|
38
|
+
* Used for list operations with cursor-based pagination
|
|
39
|
+
*/
|
|
40
|
+
export interface PaginationParams {
|
|
41
|
+
/** Maximum number of items to return (1-100, default 50) */
|
|
42
|
+
limit?: number;
|
|
43
|
+
/** Cursor for pagination (opaque string from previous response) */
|
|
44
|
+
cursor?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a pagination schema with configurable defaults
|
|
48
|
+
*
|
|
49
|
+
* @param defaultLimit - Default number of items per page (default: 50)
|
|
50
|
+
* @param maxLimit - Maximum allowed items per page (default: 100)
|
|
51
|
+
* @returns Zod schema for pagination parameters
|
|
52
|
+
*/
|
|
53
|
+
export declare function createPaginationSchema(defaultLimit?: number, maxLimit?: number): z.ZodSchema<PaginationParams>;
|
|
54
|
+
/**
|
|
55
|
+
* Email filter parameters
|
|
56
|
+
*/
|
|
57
|
+
export interface EmailFilterParams {
|
|
58
|
+
/** Email address to filter by */
|
|
59
|
+
email?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create an email filter schema
|
|
63
|
+
*
|
|
64
|
+
* @returns Zod schema for email filtering
|
|
65
|
+
*/
|
|
66
|
+
export declare function createEmailFilterSchema(): z.ZodSchema<EmailFilterParams>;
|
|
67
|
+
/**
|
|
68
|
+
* Common validation schemas for Salesflare entities
|
|
69
|
+
*/
|
|
70
|
+
export declare const ValidationSchemas: {
|
|
71
|
+
/** UUID string for contact IDs */
|
|
72
|
+
readonly contactId: z.ZodString;
|
|
73
|
+
/** UUID string for company IDs */
|
|
74
|
+
readonly companyId: z.ZodString;
|
|
75
|
+
/** Valid email address */
|
|
76
|
+
readonly email: z.ZodString;
|
|
77
|
+
/** UUID string for deal/opportunity IDs */
|
|
78
|
+
readonly dealId: z.ZodString;
|
|
79
|
+
/** UUID string for task IDs */
|
|
80
|
+
readonly taskId: z.ZodString;
|
|
81
|
+
/** UUID string for pipeline IDs */
|
|
82
|
+
readonly pipelineId: z.ZodString;
|
|
83
|
+
/** UUID string for stage IDs */
|
|
84
|
+
readonly stageId: z.ZodString;
|
|
85
|
+
/** Non-empty string for names */
|
|
86
|
+
readonly name: z.ZodString;
|
|
87
|
+
/** Optional description string */
|
|
88
|
+
readonly description: z.ZodOptional<z.ZodString>;
|
|
89
|
+
/** Pagination parameters with defaults */
|
|
90
|
+
readonly pagination: z.ZodType<PaginationParams, unknown, z.core.$ZodTypeInternals<PaginationParams, unknown>>;
|
|
91
|
+
/** Email filter parameters */
|
|
92
|
+
readonly emailFilter: z.ZodType<EmailFilterParams, unknown, z.core.$ZodTypeInternals<EmailFilterParams, unknown>>;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Type helpers for common entity IDs
|
|
96
|
+
*/
|
|
97
|
+
export type ContactId = z.infer<typeof ValidationSchemas.contactId>;
|
|
98
|
+
export type CompanyId = z.infer<typeof ValidationSchemas.companyId>;
|
|
99
|
+
export type DealId = z.infer<typeof ValidationSchemas.dealId>;
|
|
100
|
+
export type TaskId = z.infer<typeof ValidationSchemas.taskId>;
|
|
101
|
+
export type PipelineId = z.infer<typeof ValidationSchemas.pipelineId>;
|
|
102
|
+
export type StageId = z.infer<typeof ValidationSchemas.stageId>;
|
|
103
|
+
/**
|
|
104
|
+
* Create a Zod schema for contact list filters
|
|
105
|
+
* Validates filter parameters for the list contacts endpoint
|
|
106
|
+
*
|
|
107
|
+
* @returns Zod schema for ContactListFilters
|
|
108
|
+
*/
|
|
109
|
+
export declare function createContactListSchema(): z.ZodSchema<{
|
|
110
|
+
email?: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
company_id?: string;
|
|
113
|
+
tags?: string[];
|
|
114
|
+
owner?: string;
|
|
115
|
+
domain?: string;
|
|
116
|
+
search?: string;
|
|
117
|
+
page?: number;
|
|
118
|
+
limit?: number;
|
|
119
|
+
}>;
|
|
120
|
+
/**
|
|
121
|
+
* Create a Zod schema for contact creation input
|
|
122
|
+
* Validates data for creating a new contact
|
|
123
|
+
*
|
|
124
|
+
* @returns Zod schema for ContactCreateInput
|
|
125
|
+
*/
|
|
126
|
+
export declare function createContactCreateSchema(): z.ZodSchema<{
|
|
127
|
+
name?: string;
|
|
128
|
+
email: string;
|
|
129
|
+
phone?: string;
|
|
130
|
+
company_id?: string;
|
|
131
|
+
job_title?: string;
|
|
132
|
+
tags?: string[];
|
|
133
|
+
owner_id?: string;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Create a Zod schema for contact update input
|
|
137
|
+
* Validates data for updating an existing contact (partial update)
|
|
138
|
+
*
|
|
139
|
+
* @returns Zod schema for ContactUpdateInput
|
|
140
|
+
*/
|
|
141
|
+
export declare function createContactUpdateSchema(): z.ZodSchema<{
|
|
142
|
+
name?: string;
|
|
143
|
+
email?: string;
|
|
144
|
+
phone?: string;
|
|
145
|
+
company_id?: string;
|
|
146
|
+
job_title?: string;
|
|
147
|
+
tags?: string[];
|
|
148
|
+
owner_id?: string;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Schema for contact ID parameter
|
|
152
|
+
* Used for update and delete operations
|
|
153
|
+
*/
|
|
154
|
+
export declare const contactIdParamSchema: z.ZodObject<{
|
|
155
|
+
contact_id: z.ZodString;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
/**
|
|
158
|
+
* Create a Zod schema for company list filters
|
|
159
|
+
* Validates filter parameters for the list companies endpoint (per D-12 to D-16)
|
|
160
|
+
*
|
|
161
|
+
* @returns Zod schema for CompanyListFilters
|
|
162
|
+
*/
|
|
163
|
+
export declare function createCompanyListSchema(): z.ZodSchema<{
|
|
164
|
+
name?: string;
|
|
165
|
+
industry?: string;
|
|
166
|
+
tags?: string[];
|
|
167
|
+
owner?: string;
|
|
168
|
+
search?: string;
|
|
169
|
+
page?: number;
|
|
170
|
+
limit?: number;
|
|
171
|
+
}>;
|
|
172
|
+
/**
|
|
173
|
+
* Create a Zod schema for company creation input
|
|
174
|
+
* Validates data for creating a new company (per D-01 to D-06)
|
|
175
|
+
*
|
|
176
|
+
* @returns Zod schema for CompanyCreateInput
|
|
177
|
+
*/
|
|
178
|
+
export declare function createCompanyCreateSchema(): z.ZodSchema<{
|
|
179
|
+
name: string;
|
|
180
|
+
website?: string;
|
|
181
|
+
industry?: string;
|
|
182
|
+
phone?: string;
|
|
183
|
+
description?: string;
|
|
184
|
+
address?: {
|
|
185
|
+
street?: string;
|
|
186
|
+
city?: string;
|
|
187
|
+
state?: string;
|
|
188
|
+
zip?: string;
|
|
189
|
+
country?: string;
|
|
190
|
+
};
|
|
191
|
+
social_media?: {
|
|
192
|
+
linkedin?: string;
|
|
193
|
+
twitter?: string;
|
|
194
|
+
facebook?: string;
|
|
195
|
+
};
|
|
196
|
+
tags?: string[];
|
|
197
|
+
owner_id?: string;
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* Create a Zod schema for company update input
|
|
201
|
+
* Validates data for updating an existing company (partial update per D-18)
|
|
202
|
+
*
|
|
203
|
+
* @returns Zod schema for CompanyUpdateInput
|
|
204
|
+
*/
|
|
205
|
+
export declare function createCompanyUpdateSchema(): z.ZodSchema<{
|
|
206
|
+
name?: string;
|
|
207
|
+
website?: string;
|
|
208
|
+
industry?: string;
|
|
209
|
+
phone?: string;
|
|
210
|
+
description?: string;
|
|
211
|
+
address?: {
|
|
212
|
+
street?: string;
|
|
213
|
+
city?: string;
|
|
214
|
+
state?: string;
|
|
215
|
+
zip?: string;
|
|
216
|
+
country?: string;
|
|
217
|
+
};
|
|
218
|
+
social_media?: {
|
|
219
|
+
linkedin?: string;
|
|
220
|
+
twitter?: string;
|
|
221
|
+
facebook?: string;
|
|
222
|
+
};
|
|
223
|
+
tags?: string[];
|
|
224
|
+
owner_id?: string;
|
|
225
|
+
}>;
|
|
226
|
+
/**
|
|
227
|
+
* Schema for company ID parameter
|
|
228
|
+
* Used for update and delete operations
|
|
229
|
+
*/
|
|
230
|
+
export declare const companyIdParamSchema: z.ZodObject<{
|
|
231
|
+
company_id: z.ZodString;
|
|
232
|
+
}, z.core.$strip>;
|
|
233
|
+
/**
|
|
234
|
+
* Create a Zod schema for deal list filters
|
|
235
|
+
* Validates filter parameters for the list deals endpoint (per D-15 to D-20)
|
|
236
|
+
*
|
|
237
|
+
* @returns Zod schema for DealListFilters
|
|
238
|
+
*/
|
|
239
|
+
export declare function createDealListSchema(): z.ZodSchema<{
|
|
240
|
+
status?: 'open' | 'won' | 'lost';
|
|
241
|
+
pipeline_id?: string;
|
|
242
|
+
assigned_user_id?: string;
|
|
243
|
+
stage_id?: string;
|
|
244
|
+
min_value?: number;
|
|
245
|
+
max_value?: number;
|
|
246
|
+
search?: string;
|
|
247
|
+
page?: number;
|
|
248
|
+
limit?: number;
|
|
249
|
+
}>;
|
|
250
|
+
/**
|
|
251
|
+
* Create a Zod schema for deal creation input
|
|
252
|
+
* Validates data for creating a new deal (per D-01 to D-06)
|
|
253
|
+
*
|
|
254
|
+
* @returns Zod schema for DealCreateInput
|
|
255
|
+
*/
|
|
256
|
+
export declare function createDealCreateSchema(): z.ZodSchema<{
|
|
257
|
+
name: string;
|
|
258
|
+
value: number;
|
|
259
|
+
currency?: string;
|
|
260
|
+
pipeline_id: string;
|
|
261
|
+
stage_id?: string;
|
|
262
|
+
close_date?: string;
|
|
263
|
+
assigned_user_id?: string;
|
|
264
|
+
company_id?: string;
|
|
265
|
+
contact_ids?: string[];
|
|
266
|
+
description?: string;
|
|
267
|
+
}>;
|
|
268
|
+
/**
|
|
269
|
+
* Create a Zod schema for deal update input
|
|
270
|
+
* Validates data for updating an existing deal (partial update per D-25)
|
|
271
|
+
*
|
|
272
|
+
* @returns Zod schema for DealUpdateInput
|
|
273
|
+
*/
|
|
274
|
+
export declare function createDealUpdateSchema(): z.ZodSchema<{
|
|
275
|
+
name?: string;
|
|
276
|
+
value?: number;
|
|
277
|
+
currency?: string;
|
|
278
|
+
pipeline_id?: string;
|
|
279
|
+
stage_id?: string;
|
|
280
|
+
close_date?: string;
|
|
281
|
+
assigned_user_id?: string;
|
|
282
|
+
company_id?: string;
|
|
283
|
+
contact_ids?: string[];
|
|
284
|
+
description?: string;
|
|
285
|
+
status?: 'open' | 'won' | 'lost';
|
|
286
|
+
}>;
|
|
287
|
+
/**
|
|
288
|
+
* Schema for deal ID parameter
|
|
289
|
+
* Used for update and delete operations
|
|
290
|
+
*/
|
|
291
|
+
export declare const dealIdParamSchema: z.ZodObject<{
|
|
292
|
+
deal_id: z.ZodString;
|
|
293
|
+
}, z.core.$strip>;
|
|
294
|
+
/**
|
|
295
|
+
* Create a Zod schema for task list filters
|
|
296
|
+
* Validates filter parameters for the list tasks endpoint (per D-06 to D-12)
|
|
297
|
+
*
|
|
298
|
+
* @returns Zod schema for TaskListFilters
|
|
299
|
+
*/
|
|
300
|
+
export declare function createTaskListSchema(): z.ZodSchema<{
|
|
301
|
+
status?: 'open' | 'completed';
|
|
302
|
+
assigned_user_id?: string;
|
|
303
|
+
related_contact_id?: string;
|
|
304
|
+
related_deal_id?: string;
|
|
305
|
+
overdue?: boolean;
|
|
306
|
+
due_before?: string;
|
|
307
|
+
due_after?: string;
|
|
308
|
+
page?: number;
|
|
309
|
+
limit?: number;
|
|
310
|
+
}>;
|
|
311
|
+
/**
|
|
312
|
+
* Create a Zod schema for task creation input
|
|
313
|
+
* Validates data for creating a new task (per D-26 to D-30)
|
|
314
|
+
*
|
|
315
|
+
* @returns Zod schema for TaskCreateInput
|
|
316
|
+
*/
|
|
317
|
+
export declare function createTaskCreateSchema(): z.ZodSchema<{
|
|
318
|
+
description: string;
|
|
319
|
+
due_date?: string;
|
|
320
|
+
assigned_user_id?: string;
|
|
321
|
+
related_contact_id?: string;
|
|
322
|
+
related_deal_id?: string;
|
|
323
|
+
status?: 'open' | 'completed';
|
|
324
|
+
}>;
|
|
325
|
+
/**
|
|
326
|
+
* Create a Zod schema for task update input
|
|
327
|
+
* Validates data for updating an existing task (partial update per D-25)
|
|
328
|
+
*
|
|
329
|
+
* @returns Zod schema for TaskUpdateInput
|
|
330
|
+
*/
|
|
331
|
+
export declare function createTaskUpdateSchema(): z.ZodSchema<{
|
|
332
|
+
description?: string;
|
|
333
|
+
due_date?: string;
|
|
334
|
+
assigned_user_id?: string;
|
|
335
|
+
status?: 'open' | 'completed';
|
|
336
|
+
}>;
|
|
337
|
+
/**
|
|
338
|
+
* Schema for task ID parameter
|
|
339
|
+
* Used for update operations
|
|
340
|
+
*/
|
|
341
|
+
export declare const taskIdParamSchema: z.ZodObject<{
|
|
342
|
+
task_id: z.ZodString;
|
|
343
|
+
}, z.core.$strip>;
|
|
344
|
+
/**
|
|
345
|
+
* Create a Zod schema for deal stage movement
|
|
346
|
+
* Validates data for moving a deal to a new stage (per D-26)
|
|
347
|
+
*
|
|
348
|
+
* @returns Zod schema for DealMoveStageInput
|
|
349
|
+
*/
|
|
350
|
+
export declare function createDealMoveStageSchema(): z.ZodSchema<{
|
|
351
|
+
deal_id: string;
|
|
352
|
+
stage_id: string;
|
|
353
|
+
}>;
|
|
354
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAa,MAAM,aAAa,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;CACT,GAAG;IACF,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,CAmBzE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAyB/F;AAED;;;GA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