@centry-digital/bukku-mcp 1.1.0 → 2.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/build/config/env.d.ts +1 -0
- package/build/config/env.d.ts.map +1 -0
- package/build/config/env.js +2 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1813 -44
- package/build/tools/custom/account-tools.d.ts +2 -1
- package/build/tools/custom/account-tools.d.ts.map +1 -0
- package/build/tools/custom/account-tools.js +2 -2
- package/build/tools/custom/contact-archive.d.ts +2 -1
- package/build/tools/custom/contact-archive.d.ts.map +1 -0
- package/build/tools/custom/contact-archive.js +2 -2
- package/build/tools/custom/control-panel-archive.d.ts +2 -1
- package/build/tools/custom/control-panel-archive.d.ts.map +1 -0
- package/build/tools/custom/control-panel-archive.js +2 -2
- package/build/tools/custom/file-upload.d.ts +2 -1
- package/build/tools/custom/file-upload.d.ts.map +1 -0
- package/build/tools/custom/file-upload.js +2 -2
- package/build/tools/custom/journal-entry-tools.d.ts +2 -1
- package/build/tools/custom/journal-entry-tools.d.ts.map +1 -0
- package/build/tools/custom/journal-entry-tools.js +2 -3
- package/build/tools/custom/location-tools.d.ts +2 -1
- package/build/tools/custom/location-tools.d.ts.map +1 -0
- package/build/tools/custom/location-tools.js +2 -2
- package/build/tools/custom/product-archive.d.ts +2 -1
- package/build/tools/custom/product-archive.d.ts.map +1 -0
- package/build/tools/custom/product-archive.js +2 -2
- package/build/tools/custom/reference-data.d.ts +3 -2
- package/build/tools/custom/reference-data.d.ts.map +1 -0
- package/build/tools/custom/reference-data.js +2 -2
- package/build/tools/factory.d.ts +2 -2
- package/build/tools/factory.d.ts.map +1 -0
- package/build/tools/factory.js +2 -2
- package/build/tools/registry.d.ts +2 -1
- package/build/tools/registry.d.ts.map +1 -0
- package/build/tools/registry.js +3 -41
- package/package.json +9 -22
- package/LICENSE +0 -21
- package/README.md +0 -269
- package/build/client/bukku-client.d.ts +0 -62
- package/build/client/bukku-client.js +0 -195
- package/build/errors/transform.d.ts +0 -14
- package/build/errors/transform.js +0 -141
- package/build/errors/transform.test.d.ts +0 -1
- package/build/errors/transform.test.js +0 -101
- package/build/tools/cache/reference-cache.d.ts +0 -42
- package/build/tools/cache/reference-cache.js +0 -63
- package/build/tools/configs/account.d.ts +0 -17
- package/build/tools/configs/account.js +0 -28
- package/build/tools/configs/bank-money-in.d.ts +0 -10
- package/build/tools/configs/bank-money-in.js +0 -22
- package/build/tools/configs/bank-money-out.d.ts +0 -10
- package/build/tools/configs/bank-money-out.js +0 -22
- package/build/tools/configs/bank-transfer.d.ts +0 -11
- package/build/tools/configs/bank-transfer.js +0 -23
- package/build/tools/configs/contact-group.d.ts +0 -11
- package/build/tools/configs/contact-group.js +0 -19
- package/build/tools/configs/contact.d.ts +0 -14
- package/build/tools/configs/contact.js +0 -25
- package/build/tools/configs/delivery-order.d.ts +0 -8
- package/build/tools/configs/delivery-order.js +0 -20
- package/build/tools/configs/file.d.ts +0 -18
- package/build/tools/configs/file.js +0 -26
- package/build/tools/configs/goods-received-note.d.ts +0 -8
- package/build/tools/configs/goods-received-note.js +0 -20
- package/build/tools/configs/journal-entry.d.ts +0 -14
- package/build/tools/configs/journal-entry.js +0 -26
- package/build/tools/configs/location.d.ts +0 -20
- package/build/tools/configs/location.js +0 -28
- package/build/tools/configs/product-bundle.d.ts +0 -18
- package/build/tools/configs/product-bundle.js +0 -29
- package/build/tools/configs/product-group.d.ts +0 -14
- package/build/tools/configs/product-group.js +0 -22
- package/build/tools/configs/product.d.ts +0 -24
- package/build/tools/configs/product.js +0 -35
- package/build/tools/configs/purchase-bill.d.ts +0 -9
- package/build/tools/configs/purchase-bill.js +0 -21
- package/build/tools/configs/purchase-credit-note.d.ts +0 -8
- package/build/tools/configs/purchase-credit-note.js +0 -20
- package/build/tools/configs/purchase-order.d.ts +0 -8
- package/build/tools/configs/purchase-order.js +0 -20
- package/build/tools/configs/purchase-payment.d.ts +0 -8
- package/build/tools/configs/purchase-payment.js +0 -20
- package/build/tools/configs/purchase-refund.d.ts +0 -8
- package/build/tools/configs/purchase-refund.js +0 -20
- package/build/tools/configs/sales-credit-note.d.ts +0 -8
- package/build/tools/configs/sales-credit-note.js +0 -20
- package/build/tools/configs/sales-invoice.d.ts +0 -8
- package/build/tools/configs/sales-invoice.js +0 -20
- package/build/tools/configs/sales-order.d.ts +0 -8
- package/build/tools/configs/sales-order.js +0 -20
- package/build/tools/configs/sales-payment.d.ts +0 -8
- package/build/tools/configs/sales-payment.js +0 -20
- package/build/tools/configs/sales-quote.d.ts +0 -8
- package/build/tools/configs/sales-quote.js +0 -20
- package/build/tools/configs/sales-refund.d.ts +0 -8
- package/build/tools/configs/sales-refund.js +0 -20
- package/build/tools/configs/tag-group.d.ts +0 -11
- package/build/tools/configs/tag-group.js +0 -22
- package/build/tools/configs/tag.d.ts +0 -11
- package/build/tools/configs/tag.js +0 -22
- package/build/tools/validation/double-entry.d.ts +0 -46
- package/build/tools/validation/double-entry.js +0 -66
- package/build/types/api-responses.d.ts +0 -21
- package/build/types/api-responses.js +0 -6
- package/build/types/bukku.d.ts +0 -93
- package/build/types/bukku.js +0 -11
- package/build/utils/logger.d.ts +0 -6
- package/build/utils/logger.js +0 -8
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Double-Entry Validation for Journal Entries
|
|
3
|
-
*
|
|
4
|
-
* Validates that journal entry line items follow the fundamental accounting
|
|
5
|
-
* rule: total debits must equal total credits.
|
|
6
|
-
*
|
|
7
|
-
* This validation runs client-side (before API submission) to provide
|
|
8
|
-
* immediate, conversational error messages to Claude rather than waiting
|
|
9
|
-
* for raw API errors.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Validate double-entry accounting rule: debits must equal credits
|
|
13
|
-
*
|
|
14
|
-
* @param lines - Journal entry line items
|
|
15
|
-
* @param minLines - Minimum number of lines required (default: 2)
|
|
16
|
-
* @returns Validation result with detailed error message if invalid
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* // Balanced entry
|
|
21
|
-
* validateDoubleEntry([
|
|
22
|
-
* { debit_amount: 100, account_id: 1 },
|
|
23
|
-
* { credit_amount: 100, account_id: 2 }
|
|
24
|
-
* ]); // { valid: true }
|
|
25
|
-
*
|
|
26
|
-
* // Unbalanced entry
|
|
27
|
-
* validateDoubleEntry([
|
|
28
|
-
* { debit_amount: 1500 },
|
|
29
|
-
* { credit_amount: 1450 }
|
|
30
|
-
* ]);
|
|
31
|
-
* // {
|
|
32
|
-
* // valid: false,
|
|
33
|
-
* // error: "Journal entry is unbalanced. Total debits: 1500.00, Total credits: 1450.00. Difference: 50.00. Debits must equal credits in double-entry accounting."
|
|
34
|
-
* // }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export function validateDoubleEntry(lines, minLines = 2) {
|
|
38
|
-
// Check minimum line count
|
|
39
|
-
if (lines.length < minLines) {
|
|
40
|
-
const lineWord = lines.length === 1 ? "line" : "lines";
|
|
41
|
-
return {
|
|
42
|
-
valid: false,
|
|
43
|
-
error: `Journal entries require at least ${minLines} line items (minimum one debit and one credit). This entry has ${lines.length} ${lineWord}.`,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
// Sum debits and credits
|
|
47
|
-
let totalDebits = 0;
|
|
48
|
-
let totalCredits = 0;
|
|
49
|
-
for (const line of lines) {
|
|
50
|
-
totalDebits += line.debit_amount || 0;
|
|
51
|
-
totalCredits += line.credit_amount || 0;
|
|
52
|
-
}
|
|
53
|
-
// Compare with epsilon tolerance (1 cent)
|
|
54
|
-
// Using 0.01 instead of Number.EPSILON because currency precision
|
|
55
|
-
// is 2 decimal places, and differences smaller than 1 cent are
|
|
56
|
-
// acceptable rounding artifacts
|
|
57
|
-
const difference = Math.abs(totalDebits - totalCredits);
|
|
58
|
-
const EPSILON = 0.01;
|
|
59
|
-
if (difference >= EPSILON) {
|
|
60
|
-
return {
|
|
61
|
-
valid: false,
|
|
62
|
-
error: `Journal entry is unbalanced. Total debits: ${totalDebits.toFixed(2)}, Total credits: ${totalCredits.toFixed(2)}. Difference: ${difference.toFixed(2)}. Debits must equal credits in double-entry accounting.`,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return { valid: true };
|
|
66
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared API Response Type Helpers
|
|
3
|
-
*
|
|
4
|
-
* These types wrap Bukku API responses and MCP tool result formats
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Generic API response type for successful Bukku API calls
|
|
8
|
-
* Used throughout the codebase to type-check API responses
|
|
9
|
-
*/
|
|
10
|
-
export type BukkuApiResponse<T> = T;
|
|
11
|
-
/**
|
|
12
|
-
* MCP Tool Result format
|
|
13
|
-
* All MCP tool handlers must return this structure
|
|
14
|
-
*/
|
|
15
|
-
export interface ToolResult {
|
|
16
|
-
content: Array<{
|
|
17
|
-
type: 'text';
|
|
18
|
-
text: string;
|
|
19
|
-
}>;
|
|
20
|
-
isError?: boolean;
|
|
21
|
-
}
|
package/build/types/bukku.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Bukku API Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* Hand-crafted from OpenAPI specs in .api-specs/
|
|
5
|
-
* These types define the common patterns used across all Bukku API endpoints:
|
|
6
|
-
* - Pagination response structure
|
|
7
|
-
* - Error response format
|
|
8
|
-
* - List query parameters
|
|
9
|
-
* - CRUD entity configuration for the factory pattern
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Pagination metadata returned by Bukku list endpoints
|
|
13
|
-
* Derived from resPaging schema in sales.yaml
|
|
14
|
-
*/
|
|
15
|
-
export interface BukkuPaging {
|
|
16
|
-
current_page: number;
|
|
17
|
-
per_page: number;
|
|
18
|
-
total: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Paginated list response wrapper
|
|
22
|
-
* All list endpoints return { paging: {...}, [pluralKey]: [...] }
|
|
23
|
-
* e.g., { paging: {...}, transactions: [...] }
|
|
24
|
-
*/
|
|
25
|
-
export interface BukkuPaginatedResponse<T> {
|
|
26
|
-
paging: BukkuPaging;
|
|
27
|
-
[key: string]: T[] | BukkuPaging;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Single item response wrapper
|
|
31
|
-
* All get/create/update endpoints return { [singularKey]: {...} }
|
|
32
|
-
* e.g., { transaction: {...} }
|
|
33
|
-
*/
|
|
34
|
-
export interface BukkuSingleResponse<T> {
|
|
35
|
-
[key: string]: T;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Error response structure
|
|
39
|
-
* Derived from general-error.yaml pattern
|
|
40
|
-
* - message: Human-readable error message
|
|
41
|
-
* - errors: Optional validation errors (field -> error messages[])
|
|
42
|
-
*/
|
|
43
|
-
export interface BukkuErrorResponse {
|
|
44
|
-
message: string;
|
|
45
|
-
errors?: Record<string, string[]>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Common list query parameters shared across all list endpoints
|
|
49
|
-
* Derived from parameters/query/* in OpenAPI specs
|
|
50
|
-
*/
|
|
51
|
-
export interface BukkuListParams {
|
|
52
|
-
page?: number;
|
|
53
|
-
page_size?: number;
|
|
54
|
-
sort_by?: string;
|
|
55
|
-
sort_dir?: 'asc' | 'desc';
|
|
56
|
-
search?: string;
|
|
57
|
-
date_from?: string;
|
|
58
|
-
date_to?: string;
|
|
59
|
-
status?: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* CRUD operations supported by the factory pattern
|
|
63
|
-
*/
|
|
64
|
-
export type CrudOperation = 'list' | 'get' | 'create' | 'update' | 'delete';
|
|
65
|
-
/**
|
|
66
|
-
* Entity configuration for the CRUD factory pattern
|
|
67
|
-
* Defines all the metadata needed to generate MCP tools for a Bukku entity
|
|
68
|
-
*/
|
|
69
|
-
export interface CrudEntityConfig {
|
|
70
|
-
/** Entity identifier (e.g., "sales-invoice") */
|
|
71
|
-
entity: string;
|
|
72
|
-
/** API base path (e.g., "/sales/invoices") */
|
|
73
|
-
apiBasePath: string;
|
|
74
|
-
/** Response wrapper key for single item (e.g., "transaction") */
|
|
75
|
-
singularKey: string;
|
|
76
|
-
/** Response wrapper key for list items (e.g., "transactions") */
|
|
77
|
-
pluralKey: string;
|
|
78
|
-
/** Human-readable description for tool metadata (e.g., "sales invoice") */
|
|
79
|
-
description: string;
|
|
80
|
-
/** Which CRUD operations this entity supports */
|
|
81
|
-
operations: CrudOperation[];
|
|
82
|
-
/** Whether this entity supports status updates (e.g., draft -> posted) */
|
|
83
|
-
hasStatusUpdate?: boolean;
|
|
84
|
-
/** Additional list filter parameters beyond the common ones */
|
|
85
|
-
listFilters?: string[];
|
|
86
|
-
/** Optional business-rule context surfaced in tool descriptions to guide LLM behavior */
|
|
87
|
-
businessRules?: {
|
|
88
|
-
/** Constraints on when delete is allowed and what to do instead (appended to delete tool description) */
|
|
89
|
-
delete?: string;
|
|
90
|
-
/** Valid status transitions and lifecycle rules (appended to update-status tool description) */
|
|
91
|
-
statusTransitions?: string;
|
|
92
|
-
};
|
|
93
|
-
}
|
package/build/types/bukku.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Bukku API Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* Hand-crafted from OpenAPI specs in .api-specs/
|
|
5
|
-
* These types define the common patterns used across all Bukku API endpoints:
|
|
6
|
-
* - Pagination response structure
|
|
7
|
-
* - Error response format
|
|
8
|
-
* - List query parameters
|
|
9
|
-
* - CRUD entity configuration for the factory pattern
|
|
10
|
-
*/
|
|
11
|
-
export {};
|
package/build/utils/logger.d.ts
DELETED
package/build/utils/logger.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logger utility for MCP server.
|
|
3
|
-
* CRITICAL: All logs must go to stderr, NEVER stdout.
|
|
4
|
-
* MCP servers communicate via stdio - stdout is reserved for protocol messages.
|
|
5
|
-
*/
|
|
6
|
-
export function log(message, ...args) {
|
|
7
|
-
console.error(`[bukku-mcp] ${message}`, ...args);
|
|
8
|
-
}
|