@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.
Files changed (109) hide show
  1. package/build/config/env.d.ts +1 -0
  2. package/build/config/env.d.ts.map +1 -0
  3. package/build/config/env.js +2 -1
  4. package/build/index.d.ts +1 -0
  5. package/build/index.d.ts.map +1 -0
  6. package/build/index.js +1813 -44
  7. package/build/tools/custom/account-tools.d.ts +2 -1
  8. package/build/tools/custom/account-tools.d.ts.map +1 -0
  9. package/build/tools/custom/account-tools.js +2 -2
  10. package/build/tools/custom/contact-archive.d.ts +2 -1
  11. package/build/tools/custom/contact-archive.d.ts.map +1 -0
  12. package/build/tools/custom/contact-archive.js +2 -2
  13. package/build/tools/custom/control-panel-archive.d.ts +2 -1
  14. package/build/tools/custom/control-panel-archive.d.ts.map +1 -0
  15. package/build/tools/custom/control-panel-archive.js +2 -2
  16. package/build/tools/custom/file-upload.d.ts +2 -1
  17. package/build/tools/custom/file-upload.d.ts.map +1 -0
  18. package/build/tools/custom/file-upload.js +2 -2
  19. package/build/tools/custom/journal-entry-tools.d.ts +2 -1
  20. package/build/tools/custom/journal-entry-tools.d.ts.map +1 -0
  21. package/build/tools/custom/journal-entry-tools.js +2 -3
  22. package/build/tools/custom/location-tools.d.ts +2 -1
  23. package/build/tools/custom/location-tools.d.ts.map +1 -0
  24. package/build/tools/custom/location-tools.js +2 -2
  25. package/build/tools/custom/product-archive.d.ts +2 -1
  26. package/build/tools/custom/product-archive.d.ts.map +1 -0
  27. package/build/tools/custom/product-archive.js +2 -2
  28. package/build/tools/custom/reference-data.d.ts +3 -2
  29. package/build/tools/custom/reference-data.d.ts.map +1 -0
  30. package/build/tools/custom/reference-data.js +2 -2
  31. package/build/tools/factory.d.ts +2 -2
  32. package/build/tools/factory.d.ts.map +1 -0
  33. package/build/tools/factory.js +2 -2
  34. package/build/tools/registry.d.ts +2 -1
  35. package/build/tools/registry.d.ts.map +1 -0
  36. package/build/tools/registry.js +3 -41
  37. package/package.json +9 -22
  38. package/LICENSE +0 -21
  39. package/README.md +0 -269
  40. package/build/client/bukku-client.d.ts +0 -62
  41. package/build/client/bukku-client.js +0 -195
  42. package/build/errors/transform.d.ts +0 -14
  43. package/build/errors/transform.js +0 -141
  44. package/build/errors/transform.test.d.ts +0 -1
  45. package/build/errors/transform.test.js +0 -101
  46. package/build/tools/cache/reference-cache.d.ts +0 -42
  47. package/build/tools/cache/reference-cache.js +0 -63
  48. package/build/tools/configs/account.d.ts +0 -17
  49. package/build/tools/configs/account.js +0 -28
  50. package/build/tools/configs/bank-money-in.d.ts +0 -10
  51. package/build/tools/configs/bank-money-in.js +0 -22
  52. package/build/tools/configs/bank-money-out.d.ts +0 -10
  53. package/build/tools/configs/bank-money-out.js +0 -22
  54. package/build/tools/configs/bank-transfer.d.ts +0 -11
  55. package/build/tools/configs/bank-transfer.js +0 -23
  56. package/build/tools/configs/contact-group.d.ts +0 -11
  57. package/build/tools/configs/contact-group.js +0 -19
  58. package/build/tools/configs/contact.d.ts +0 -14
  59. package/build/tools/configs/contact.js +0 -25
  60. package/build/tools/configs/delivery-order.d.ts +0 -8
  61. package/build/tools/configs/delivery-order.js +0 -20
  62. package/build/tools/configs/file.d.ts +0 -18
  63. package/build/tools/configs/file.js +0 -26
  64. package/build/tools/configs/goods-received-note.d.ts +0 -8
  65. package/build/tools/configs/goods-received-note.js +0 -20
  66. package/build/tools/configs/journal-entry.d.ts +0 -14
  67. package/build/tools/configs/journal-entry.js +0 -26
  68. package/build/tools/configs/location.d.ts +0 -20
  69. package/build/tools/configs/location.js +0 -28
  70. package/build/tools/configs/product-bundle.d.ts +0 -18
  71. package/build/tools/configs/product-bundle.js +0 -29
  72. package/build/tools/configs/product-group.d.ts +0 -14
  73. package/build/tools/configs/product-group.js +0 -22
  74. package/build/tools/configs/product.d.ts +0 -24
  75. package/build/tools/configs/product.js +0 -35
  76. package/build/tools/configs/purchase-bill.d.ts +0 -9
  77. package/build/tools/configs/purchase-bill.js +0 -21
  78. package/build/tools/configs/purchase-credit-note.d.ts +0 -8
  79. package/build/tools/configs/purchase-credit-note.js +0 -20
  80. package/build/tools/configs/purchase-order.d.ts +0 -8
  81. package/build/tools/configs/purchase-order.js +0 -20
  82. package/build/tools/configs/purchase-payment.d.ts +0 -8
  83. package/build/tools/configs/purchase-payment.js +0 -20
  84. package/build/tools/configs/purchase-refund.d.ts +0 -8
  85. package/build/tools/configs/purchase-refund.js +0 -20
  86. package/build/tools/configs/sales-credit-note.d.ts +0 -8
  87. package/build/tools/configs/sales-credit-note.js +0 -20
  88. package/build/tools/configs/sales-invoice.d.ts +0 -8
  89. package/build/tools/configs/sales-invoice.js +0 -20
  90. package/build/tools/configs/sales-order.d.ts +0 -8
  91. package/build/tools/configs/sales-order.js +0 -20
  92. package/build/tools/configs/sales-payment.d.ts +0 -8
  93. package/build/tools/configs/sales-payment.js +0 -20
  94. package/build/tools/configs/sales-quote.d.ts +0 -8
  95. package/build/tools/configs/sales-quote.js +0 -20
  96. package/build/tools/configs/sales-refund.d.ts +0 -8
  97. package/build/tools/configs/sales-refund.js +0 -20
  98. package/build/tools/configs/tag-group.d.ts +0 -11
  99. package/build/tools/configs/tag-group.js +0 -22
  100. package/build/tools/configs/tag.d.ts +0 -11
  101. package/build/tools/configs/tag.js +0 -22
  102. package/build/tools/validation/double-entry.d.ts +0 -46
  103. package/build/tools/validation/double-entry.js +0 -66
  104. package/build/types/api-responses.d.ts +0 -21
  105. package/build/types/api-responses.js +0 -6
  106. package/build/types/bukku.d.ts +0 -93
  107. package/build/types/bukku.js +0 -11
  108. package/build/utils/logger.d.ts +0 -6
  109. 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
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Shared API Response Type Helpers
3
- *
4
- * These types wrap Bukku API responses and MCP tool result formats
5
- */
6
- export {};
@@ -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
- }
@@ -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 {};
@@ -1,6 +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 declare function log(message: string, ...args: unknown[]): void;
@@ -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
- }