quantix-mcp 0.3.6 → 0.3.9

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 (105) hide show
  1. package/.github/agents/copilot-instructions.md +32 -32
  2. package/.github/copilot-instructions.md +17 -17
  3. package/.github/workflows/publish.yaml +28 -28
  4. package/.opencode/command/speckit.analyze.md +184 -184
  5. package/.opencode/command/speckit.checklist.md +294 -294
  6. package/.opencode/command/speckit.clarify.md +181 -181
  7. package/.opencode/command/speckit.constitution.md +84 -84
  8. package/.opencode/command/speckit.implement.md +135 -135
  9. package/.opencode/command/speckit.plan.md +89 -89
  10. package/.opencode/command/speckit.specify.md +258 -258
  11. package/.opencode/command/speckit.tasks.md +137 -137
  12. package/.opencode/command/speckit.taskstoissues.md +30 -30
  13. package/.specify/memory/constitution.md +58 -58
  14. package/.specify/templates/constitution-template.md +50 -50
  15. package/.vscode/launch.json +14 -14
  16. package/CLAUDE.md +64 -64
  17. package/README.md +176 -176
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +6 -5
  20. package/dist/index.js.map +1 -1
  21. package/dist/tools/accounts.d.ts.map +1 -1
  22. package/dist/tools/accounts.js +64 -28
  23. package/dist/tools/accounts.js.map +1 -1
  24. package/dist/tools/categories.d.ts.map +1 -1
  25. package/dist/tools/categories.js +46 -20
  26. package/dist/tools/categories.js.map +1 -1
  27. package/dist/tools/credit-cards.d.ts.map +1 -1
  28. package/dist/tools/credit-cards.js +89 -33
  29. package/dist/tools/credit-cards.js.map +1 -1
  30. package/dist/tools/data.d.ts.map +1 -1
  31. package/dist/tools/data.js +19 -8
  32. package/dist/tools/data.js.map +1 -1
  33. package/dist/tools/settings.d.ts.map +1 -1
  34. package/dist/tools/settings.js +28 -12
  35. package/dist/tools/settings.js.map +1 -1
  36. package/dist/tools/summary.d.ts.map +1 -1
  37. package/dist/tools/summary.js +17 -11
  38. package/dist/tools/summary.js.map +1 -1
  39. package/dist/tools/transactions.d.ts.map +1 -1
  40. package/dist/tools/transactions.js +86 -50
  41. package/dist/tools/transactions.js.map +1 -1
  42. package/dist/tools/transfers.d.ts +3 -0
  43. package/dist/tools/transfers.d.ts.map +1 -0
  44. package/dist/tools/transfers.js +107 -0
  45. package/dist/tools/transfers.js.map +1 -0
  46. package/dist/types/schemas.d.ts +25 -0
  47. package/dist/types/schemas.d.ts.map +1 -1
  48. package/dist/types/schemas.js +28 -2
  49. package/dist/types/schemas.js.map +1 -1
  50. package/dist/utils/toolHelpers.d.ts +7 -0
  51. package/dist/utils/toolHelpers.d.ts.map +1 -0
  52. package/dist/utils/toolHelpers.js +11 -0
  53. package/dist/utils/toolHelpers.js.map +1 -0
  54. package/openapi.yaml +2045 -1786
  55. package/package.json +41 -41
  56. package/specs/001-mcp-api-integration/checklists/requirements.md +34 -34
  57. package/specs/001-mcp-api-integration/contracts/openapi.yaml +635 -635
  58. package/specs/001-mcp-api-integration/data-model.md +106 -106
  59. package/specs/001-mcp-api-integration/plan.md +73 -73
  60. package/specs/001-mcp-api-integration/quickstart.md +74 -74
  61. package/specs/001-mcp-api-integration/research.md +58 -58
  62. package/specs/001-mcp-api-integration/spec.md +119 -119
  63. package/specs/001-mcp-api-integration/tasks.md +64 -64
  64. package/src/config.ts +36 -36
  65. package/src/index.ts +49 -47
  66. package/src/services/apiClient.ts +49 -49
  67. package/src/tools/accounts.ts +140 -111
  68. package/src/tools/categories.ts +102 -81
  69. package/src/tools/credit-cards.ts +184 -132
  70. package/src/tools/data.ts +45 -36
  71. package/src/tools/settings.ts +64 -51
  72. package/src/tools/summary.ts +29 -24
  73. package/src/tools/transactions.ts +157 -128
  74. package/src/tools/transfers.ts +122 -0
  75. package/src/types/schemas.ts +260 -230
  76. package/src/utils/toolHelpers.ts +11 -0
  77. package/tests/benchmark.test.d.ts +1 -1
  78. package/tests/benchmark.test.js +32 -32
  79. package/tests/benchmark.test.ts +38 -38
  80. package/tests/server.test.d.ts +1 -1
  81. package/tests/server.test.js +12 -12
  82. package/tests/server.test.ts +14 -14
  83. package/tests/setup.d.ts +3 -3
  84. package/tests/setup.js +16 -16
  85. package/tests/setup.ts +20 -20
  86. package/tests/tools/accounts.test.ts +159 -118
  87. package/tests/tools/categories.test.d.ts +1 -1
  88. package/tests/tools/categories.test.js +62 -62
  89. package/tests/tools/categories.test.ts +120 -78
  90. package/tests/tools/credit-cards.test.d.ts +1 -1
  91. package/tests/tools/credit-cards.test.js +70 -70
  92. package/tests/tools/credit-cards.test.ts +131 -89
  93. package/tests/tools/data.test.ts +100 -0
  94. package/tests/tools/settings.test.ts +116 -0
  95. package/tests/tools/summary.test.d.ts +1 -1
  96. package/tests/tools/summary.test.js +35 -35
  97. package/tests/tools/summary.test.ts +63 -42
  98. package/tests/tools/transactions.test.d.ts +1 -1
  99. package/tests/tools/transactions.test.js +66 -66
  100. package/tests/tools/transactions.test.ts +133 -82
  101. package/tests/tools/transfers.test.ts +141 -0
  102. package/tsconfig.json +52 -52
  103. package/vitest.config.d.ts +2 -2
  104. package/vitest.config.js +13 -13
  105. package/vitest.config.ts +14 -14
@@ -1,38 +1,38 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { registerCategoryTools } from '../src/tools/categories.js';
3
- import { apiClient } from '../src/services/apiClient.js';
4
-
5
- vi.mock('../src/services/apiClient.js', () => ({
6
- apiClient: {
7
- get: vi.fn(),
8
- }
9
- }));
10
-
11
- describe('Performance Benchmark', () => {
12
- // This is a rough benchmark, mostly verifying it's not super slow due to overhead
13
- it('should execute tool handler with low overhead (<20ms)', async () => {
14
- const registeredTools: Record<string, Function> = {};
15
- const mockServer = {
16
- registerTool: (name: string, def: any, handler: Function) => {
17
- registeredTools[name] = handler;
18
- }
19
- };
20
-
21
- // Setup
22
- registerCategoryTools(mockServer as any);
23
- const handler = registeredTools['get_categories'];
24
- (apiClient.get as any).mockResolvedValue([]);
25
-
26
- // Warmup
27
- await handler({});
28
-
29
- // Measure
30
- const start = performance.now();
31
- await handler({});
32
- const end = performance.now();
33
- const duration = end - start;
34
-
35
- console.log(`Tool execution overhead: ${duration.toFixed(3)}ms`);
36
- expect(duration).toBeLessThan(20);
37
- });
38
- });
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { registerCategoryTools } from '../src/tools/categories.js';
3
+ import { apiClient } from '../src/services/apiClient.js';
4
+
5
+ vi.mock('../src/services/apiClient.js', () => ({
6
+ apiClient: {
7
+ get: vi.fn(),
8
+ }
9
+ }));
10
+
11
+ describe('Performance Benchmark', () => {
12
+ // This is a rough benchmark, mostly verifying it's not super slow due to overhead
13
+ it('should execute tool handler with low overhead (<20ms)', async () => {
14
+ const registeredTools: Record<string, Function> = {};
15
+ const mockServer = {
16
+ registerTool: (name: string, def: any, handler: Function) => {
17
+ registeredTools[name] = handler;
18
+ }
19
+ };
20
+
21
+ // Setup
22
+ registerCategoryTools(mockServer as any);
23
+ const handler = registeredTools['get_categories'];
24
+ (apiClient.get as any).mockResolvedValue([]);
25
+
26
+ // Warmup
27
+ await handler({});
28
+
29
+ // Measure
30
+ const start = performance.now();
31
+ await handler({});
32
+ const end = performance.now();
33
+ const duration = end - start;
34
+
35
+ console.log(`Tool execution overhead: ${duration.toFixed(3)}ms`);
36
+ expect(duration).toBeLessThan(20);
37
+ });
38
+ });
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=server.test.d.ts.map
@@ -1,13 +1,13 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { getServer } from '../src/index.js';
3
- describe('Server Startup', () => {
4
- it('should initialize McpServer', () => {
5
- const server = getServer();
6
- expect(server).toBeDefined();
7
- // expect(server.server.name).toBe('quantix_mcp_server');
8
- });
9
- // Since we can't easily inspect registered tools without private access or running it,
10
- // we'll mainly check it doesn't crash on init.
11
- // With McpServer from SDK, we might be able to check capabilities or similar if exposed.
12
- });
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { getServer } from '../src/index.js';
3
+ describe('Server Startup', () => {
4
+ it('should initialize McpServer', () => {
5
+ const server = getServer();
6
+ expect(server).toBeDefined();
7
+ // expect(server.server.name).toBe('quantix_mcp_server');
8
+ });
9
+ // Since we can't easily inspect registered tools without private access or running it,
10
+ // we'll mainly check it doesn't crash on init.
11
+ // With McpServer from SDK, we might be able to check capabilities or similar if exposed.
12
+ });
13
13
  //# sourceMappingURL=server.test.js.map
@@ -1,14 +1,14 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { getServer } from '../src/index.js';
3
-
4
- describe('Server Startup', () => {
5
- it('should initialize McpServer', () => {
6
- const server = getServer();
7
- expect(server).toBeDefined();
8
- // expect(server.server.name).toBe('quantix_mcp_server');
9
- });
10
-
11
- // Since we can't easily inspect registered tools without private access or running it,
12
- // we'll mainly check it doesn't crash on init.
13
- // With McpServer from SDK, we might be able to check capabilities or similar if exposed.
14
- });
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { getServer } from '../src/index.js';
3
+
4
+ describe('Server Startup', () => {
5
+ it('should initialize McpServer', () => {
6
+ const server = getServer();
7
+ expect(server).toBeDefined();
8
+ // expect(server.server.name).toBe('quantix_mcp_server');
9
+ });
10
+
11
+ // Since we can't easily inspect registered tools without private access or running it,
12
+ // we'll mainly check it doesn't crash on init.
13
+ // With McpServer from SDK, we might be able to check capabilities or similar if exposed.
14
+ });
package/tests/setup.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { vi } from 'vitest';
2
- export declare const mockFetch: ReturnType<typeof vi.fn>;
3
- export declare function resetMocks(): void;
1
+ import { vi } from 'vitest';
2
+ export declare const mockFetch: ReturnType<typeof vi.fn>;
3
+ export declare function resetMocks(): void;
4
4
  //# sourceMappingURL=setup.d.ts.map
package/tests/setup.js CHANGED
@@ -1,17 +1,17 @@
1
- import { vi } from 'vitest';
2
- // Define the global fetch if not already (Vitest/Node should have it, but for explicit typing)
3
- global.fetch = vi.fn();
4
- export const mockFetch = global.fetch;
5
- export function resetMocks() {
6
- mockFetch.mockReset();
7
- }
8
- // Basic mocks for config to ensure tests don't fail on missing env
9
- vi.mock('../src/config.js', () => ({
10
- config: {
11
- QUANTIX_API_URL: 'https://test-api.quantix.com',
12
- QUANTIX_API_KEY: 'test-key',
13
- MCPPORT: '3000',
14
- NODE_ENV: 'test'
15
- }
16
- }));
1
+ import { vi } from 'vitest';
2
+ // Define the global fetch if not already (Vitest/Node should have it, but for explicit typing)
3
+ global.fetch = vi.fn();
4
+ export const mockFetch = global.fetch;
5
+ export function resetMocks() {
6
+ mockFetch.mockReset();
7
+ }
8
+ // Basic mocks for config to ensure tests don't fail on missing env
9
+ vi.mock('../src/config.js', () => ({
10
+ config: {
11
+ QUANTIX_API_URL: 'https://test-api.quantix.com',
12
+ QUANTIX_API_KEY: 'test-key',
13
+ MCPPORT: '3000',
14
+ NODE_ENV: 'test'
15
+ }
16
+ }));
17
17
  //# sourceMappingURL=setup.js.map
package/tests/setup.ts CHANGED
@@ -1,20 +1,20 @@
1
- import { vi } from 'vitest';
2
-
3
- // Define the global fetch if not already (Vitest/Node should have it, but for explicit typing)
4
- global.fetch = vi.fn();
5
-
6
- export const mockFetch = global.fetch as unknown as ReturnType<typeof vi.fn>;
7
-
8
- export function resetMocks() {
9
- mockFetch.mockReset();
10
- }
11
-
12
- // Basic mocks for config to ensure tests don't fail on missing env
13
- vi.mock('../src/config.js', () => ({
14
- config: {
15
- QUANTIX_API_URL: 'https://test-api.quantix.com',
16
- QUANTIX_API_KEY: 'test-key',
17
- MCPPORT: '3000',
18
- NODE_ENV: 'test'
19
- }
20
- }));
1
+ import { vi } from 'vitest';
2
+
3
+ // Define the global fetch if not already (Vitest/Node should have it, but for explicit typing)
4
+ global.fetch = vi.fn();
5
+
6
+ export const mockFetch = global.fetch as unknown as ReturnType<typeof vi.fn>;
7
+
8
+ export function resetMocks() {
9
+ mockFetch.mockReset();
10
+ }
11
+
12
+ // Basic mocks for config to ensure tests don't fail on missing env
13
+ vi.mock('../src/config.js', () => ({
14
+ config: {
15
+ QUANTIX_API_URL: 'https://test-api.quantix.com',
16
+ QUANTIX_API_KEY: 'test-key',
17
+ MCPPORT: '3000',
18
+ NODE_ENV: 'test'
19
+ }
20
+ }));
@@ -1,118 +1,159 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { registerAccountTools } from '../../src/tools/accounts.js';
3
- import { apiClient } from '../../src/services/apiClient.js';
4
-
5
- vi.mock('../../src/services/apiClient.js', () => ({
6
- apiClient: {
7
- get: vi.fn(),
8
- post: vi.fn(),
9
- patch: vi.fn(),
10
- delete: vi.fn(),
11
- }
12
- }));
13
-
14
- describe('Account Tools', () => {
15
- let mockServer: any;
16
- let registeredTools: Record<string, Function> = {};
17
-
18
- beforeEach(() => {
19
- registeredTools = {};
20
- mockServer = {
21
- registerTool: vi.fn((name, def, handler) => {
22
- registeredTools[name] = handler;
23
- })
24
- };
25
- vi.clearAllMocks();
26
- });
27
-
28
- it('should register all account tools', () => {
29
- registerAccountTools(mockServer);
30
- expect(mockServer.registerTool).toHaveBeenCalledTimes(7);
31
- expect(registeredTools['create_account']).toBeDefined();
32
- expect(registeredTools['get_accounts']).toBeDefined();
33
- expect(registeredTools['get_account']).toBeDefined();
34
- expect(registeredTools['update_account']).toBeDefined();
35
- expect(registeredTools['delete_account']).toBeDefined();
36
- expect(registeredTools['get_account_balance']).toBeDefined();
37
- });
38
-
39
- describe('create_account', () => {
40
- it('should post new account data', async () => {
41
- registerAccountTools(mockServer);
42
- const handler = registeredTools['create_account'];
43
- (apiClient.post as any).mockResolvedValue({ id: 'acc_1', name: 'My Bank' });
44
-
45
- const input = { name: 'My Bank', type: 'BANK_ACCOUNT', initialBalance: 1000 };
46
- const result = await handler(input);
47
-
48
- expect(apiClient.post).toHaveBeenCalledWith('/accounts', input);
49
- expect(result.content[0].text).toContain('My Bank');
50
- });
51
- });
52
-
53
- describe('get_accounts', () => {
54
- it('should list accounts', async () => {
55
- registerAccountTools(mockServer);
56
- const handler = registeredTools['get_accounts'];
57
- (apiClient.get as any).mockResolvedValue([{ id: 'acc_1', name: 'My Bank' }]);
58
-
59
- const result = await handler({});
60
-
61
- expect(apiClient.get).toHaveBeenCalledWith('/accounts');
62
- expect(result.content[0].text).toContain('My Bank');
63
- });
64
- });
65
-
66
- describe('get_account', () => {
67
- it('should get account details', async () => {
68
- registerAccountTools(mockServer);
69
- const handler = registeredTools['get_account'];
70
- (apiClient.get as any).mockResolvedValue({ id: 'acc_1', name: 'My Bank' });
71
-
72
- const result = await handler({ id: 'acc_1' });
73
-
74
- expect(apiClient.get).toHaveBeenCalledWith('/accounts/acc_1');
75
- expect(result.content[0].text).toContain('My Bank');
76
- });
77
- });
78
-
79
- describe('update_account', () => {
80
- it('should update account', async () => {
81
- registerAccountTools(mockServer);
82
- const handler = registeredTools['update_account'];
83
- (apiClient.patch as any).mockResolvedValue({ id: 'acc_1', name: 'Updated Name' });
84
-
85
- const input = { id: 'acc_1', name: 'Updated Name' };
86
- const result = await handler(input);
87
-
88
- expect(apiClient.patch).toHaveBeenCalledWith('/accounts/acc_1', { name: 'Updated Name' });
89
- expect(result.content[0].text).toContain('Updated Name');
90
- });
91
- });
92
-
93
- describe('delete_account', () => {
94
- it('should delete account', async () => {
95
- registerAccountTools(mockServer);
96
- const handler = registeredTools['delete_account'];
97
- (apiClient.delete as any).mockResolvedValue({});
98
-
99
- const result = await handler({ id: 'acc_1' });
100
-
101
- expect(apiClient.delete).toHaveBeenCalledWith('/accounts/acc_1');
102
- expect(result.content[0].text).toContain('deleted successfully');
103
- });
104
- });
105
-
106
- describe('get_account_balance', () => {
107
- it('should get account balance', async () => {
108
- registerAccountTools(mockServer);
109
- const handler = registeredTools['get_account_balance'];
110
- (apiClient.get as any).mockResolvedValue({ accountId: 'acc_1', currentBalance: 500 });
111
-
112
- const result = await handler({ id: 'acc_1' });
113
-
114
- expect(apiClient.get).toHaveBeenCalledWith('/accounts/acc_1/balance');
115
- expect(result.content[0].text).toContain('500');
116
- });
117
- });
118
- });
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { registerAccountTools } from '../../src/tools/accounts.js';
3
+ import { apiClient } from '../../src/services/apiClient.js';
4
+ import { ApiClientError } from '../../src/services/apiClient.js';
5
+
6
+ vi.mock('../../src/services/apiClient.js', () => ({
7
+ apiClient: {
8
+ get: vi.fn(),
9
+ post: vi.fn(),
10
+ patch: vi.fn(),
11
+ delete: vi.fn(),
12
+ },
13
+ ApiClientError: class ApiClientError extends Error {
14
+ status: number;
15
+ statusText: string;
16
+ constructor(message: string, status: number, statusText: string) {
17
+ super(message);
18
+ this.name = 'ApiClientError';
19
+ this.status = status;
20
+ this.statusText = statusText;
21
+ }
22
+ }
23
+ }));
24
+
25
+ describe('Account Tools', () => {
26
+ let mockServer: any;
27
+ let registeredTools: Record<string, Function> = {};
28
+
29
+ beforeEach(() => {
30
+ registeredTools = {};
31
+ mockServer = {
32
+ registerTool: vi.fn((name, def, handler) => {
33
+ registeredTools[name] = handler;
34
+ })
35
+ };
36
+ vi.clearAllMocks();
37
+ });
38
+
39
+ it('should register all account tools', () => {
40
+ registerAccountTools(mockServer);
41
+ expect(mockServer.registerTool).toHaveBeenCalledTimes(7);
42
+ expect(registeredTools['create_account']).toBeDefined();
43
+ expect(registeredTools['get_accounts']).toBeDefined();
44
+ expect(registeredTools['get_account']).toBeDefined();
45
+ expect(registeredTools['update_account']).toBeDefined();
46
+ expect(registeredTools['delete_account']).toBeDefined();
47
+ expect(registeredTools['get_account_balance']).toBeDefined();
48
+ });
49
+
50
+ describe('create_account', () => {
51
+ it('should post new account data', async () => {
52
+ registerAccountTools(mockServer);
53
+ const handler = registeredTools['create_account'];
54
+ (apiClient.post as any).mockResolvedValue({ id: 'acc_1', name: 'My Bank' });
55
+
56
+ const input = { name: 'My Bank', type: 'BANK_ACCOUNT', initialBalance: 1000 };
57
+ const result = await handler(input);
58
+
59
+ expect(apiClient.post).toHaveBeenCalledWith('/accounts', input);
60
+ expect(result.content[0].text).toContain('My Bank');
61
+ });
62
+
63
+ it('should return API error on failure', async () => {
64
+ registerAccountTools(mockServer);
65
+ const handler = registeredTools['create_account'];
66
+ (apiClient.post as any).mockRejectedValue(new ApiClientError('fail', 400, 'Bad Request'));
67
+
68
+ const result = await handler({ name: 'My Bank', type: 'BANK_ACCOUNT' });
69
+
70
+ expect(result.content[0].text).toMatch(/^API error 400/);
71
+ });
72
+ });
73
+
74
+ describe('get_accounts', () => {
75
+ it('should list accounts', async () => {
76
+ registerAccountTools(mockServer);
77
+ const handler = registeredTools['get_accounts'];
78
+ (apiClient.get as any).mockResolvedValue([{ id: 'acc_1', name: 'My Bank' }]);
79
+
80
+ const result = await handler({});
81
+
82
+ expect(apiClient.get).toHaveBeenCalledWith('/accounts');
83
+ expect(result.content[0].text).toContain('My Bank');
84
+ });
85
+
86
+ it('should return API error on failure', async () => {
87
+ registerAccountTools(mockServer);
88
+ const handler = registeredTools['get_accounts'];
89
+ (apiClient.get as any).mockRejectedValue(new ApiClientError('fail', 500, 'Internal Server Error'));
90
+
91
+ const result = await handler({});
92
+
93
+ expect(result.content[0].text).toMatch(/^API error 500/);
94
+ });
95
+ });
96
+
97
+ describe('get_account', () => {
98
+ it('should get account details', async () => {
99
+ registerAccountTools(mockServer);
100
+ const handler = registeredTools['get_account'];
101
+ (apiClient.get as any).mockResolvedValue({ id: 'acc_1', name: 'My Bank' });
102
+
103
+ const result = await handler({ id: 'acc_1' });
104
+
105
+ expect(apiClient.get).toHaveBeenCalledWith('/accounts/acc_1');
106
+ expect(result.content[0].text).toContain('My Bank');
107
+ });
108
+ });
109
+
110
+ describe('update_account', () => {
111
+ it('should update account', async () => {
112
+ registerAccountTools(mockServer);
113
+ const handler = registeredTools['update_account'];
114
+ (apiClient.patch as any).mockResolvedValue({ id: 'acc_1', name: 'Updated Name' });
115
+
116
+ const input = { id: 'acc_1', name: 'Updated Name' };
117
+ const result = await handler(input);
118
+
119
+ expect(apiClient.patch).toHaveBeenCalledWith('/accounts/acc_1', { name: 'Updated Name' });
120
+ expect(result.content[0].text).toContain('Updated Name');
121
+ });
122
+ });
123
+
124
+ describe('delete_account', () => {
125
+ it('should delete account', async () => {
126
+ registerAccountTools(mockServer);
127
+ const handler = registeredTools['delete_account'];
128
+ (apiClient.delete as any).mockResolvedValue({});
129
+
130
+ const result = await handler({ id: 'acc_1' });
131
+
132
+ expect(apiClient.delete).toHaveBeenCalledWith('/accounts/acc_1');
133
+ expect(result.content[0].text).toContain('deleted successfully');
134
+ });
135
+
136
+ it('should return API error on failure', async () => {
137
+ registerAccountTools(mockServer);
138
+ const handler = registeredTools['delete_account'];
139
+ (apiClient.delete as any).mockRejectedValue(new ApiClientError('fail', 404, 'Not Found'));
140
+
141
+ const result = await handler({ id: 'acc_1' });
142
+
143
+ expect(result.content[0].text).toMatch(/^API error 404/);
144
+ });
145
+ });
146
+
147
+ describe('get_account_balance', () => {
148
+ it('should get account balance', async () => {
149
+ registerAccountTools(mockServer);
150
+ const handler = registeredTools['get_account_balance'];
151
+ (apiClient.get as any).mockResolvedValue({ accountId: 'acc_1', currentBalance: 500 });
152
+
153
+ const result = await handler({ id: 'acc_1' });
154
+
155
+ expect(apiClient.get).toHaveBeenCalledWith('/accounts/acc_1/balance');
156
+ expect(result.content[0].text).toContain('500');
157
+ });
158
+ });
159
+ });
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=categories.test.d.ts.map
@@ -1,63 +1,63 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { registerCategoryTools } from '../../src/tools/categories.js';
3
- import { apiClient } from '../../src/services/apiClient.js';
4
- // Mock apiClient
5
- vi.mock('../../src/services/apiClient.js', () => ({
6
- apiClient: {
7
- get: vi.fn(),
8
- post: vi.fn(),
9
- delete: vi.fn(),
10
- }
11
- }));
12
- describe('Category Tools', () => {
13
- let mockServer;
14
- let registeredTools = {};
15
- beforeEach(() => {
16
- registeredTools = {};
17
- mockServer = {
18
- registerTool: vi.fn((name, def, handler) => {
19
- registeredTools[name] = handler;
20
- })
21
- };
22
- vi.clearAllMocks();
23
- });
24
- it('should register category tools', () => {
25
- registerCategoryTools(mockServer);
26
- expect(mockServer.registerTool).toHaveBeenCalledTimes(3);
27
- expect(registeredTools['create_category']).toBeDefined();
28
- expect(registeredTools['get_categories']).toBeDefined();
29
- expect(registeredTools['delete_category']).toBeDefined();
30
- });
31
- describe('create_category', () => {
32
- it('should call api.post with correct data', async () => {
33
- registerCategoryTools(mockServer);
34
- const handler = registeredTools['create_category'];
35
- apiClient.post.mockResolvedValue({ id: 'cat_1', name: 'Test' });
36
- const result = await handler({ name: 'Test', type: 'EXPENSE' });
37
- expect(apiClient.post).toHaveBeenCalledWith('/categories', { name: 'Test', type: 'EXPENSE' });
38
- expect(result.content[0].text).toContain('Category created');
39
- expect(result.content[0].text).toContain('Test');
40
- });
41
- });
42
- describe('get_categories', () => {
43
- it('should call api.get', async () => {
44
- registerCategoryTools(mockServer);
45
- const handler = registeredTools['get_categories'];
46
- apiClient.get.mockResolvedValue([{ id: 'cat_1', name: 'Test' }]);
47
- const result = await handler({});
48
- expect(apiClient.get).toHaveBeenCalledWith('/categories');
49
- expect(result.content[0].text).toContain('Test');
50
- });
51
- });
52
- describe('delete_category', () => {
53
- it('should call api.delete', async () => {
54
- registerCategoryTools(mockServer);
55
- const handler = registeredTools['delete_category'];
56
- apiClient.delete.mockResolvedValue({});
57
- const result = await handler({ id: 'cat_1' });
58
- expect(apiClient.delete).toHaveBeenCalledWith('/categories/cat_1');
59
- expect(result.content[0].text).toContain('Category deleted');
60
- });
61
- });
62
- });
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { registerCategoryTools } from '../../src/tools/categories.js';
3
+ import { apiClient } from '../../src/services/apiClient.js';
4
+ // Mock apiClient
5
+ vi.mock('../../src/services/apiClient.js', () => ({
6
+ apiClient: {
7
+ get: vi.fn(),
8
+ post: vi.fn(),
9
+ delete: vi.fn(),
10
+ }
11
+ }));
12
+ describe('Category Tools', () => {
13
+ let mockServer;
14
+ let registeredTools = {};
15
+ beforeEach(() => {
16
+ registeredTools = {};
17
+ mockServer = {
18
+ registerTool: vi.fn((name, def, handler) => {
19
+ registeredTools[name] = handler;
20
+ })
21
+ };
22
+ vi.clearAllMocks();
23
+ });
24
+ it('should register category tools', () => {
25
+ registerCategoryTools(mockServer);
26
+ expect(mockServer.registerTool).toHaveBeenCalledTimes(3);
27
+ expect(registeredTools['create_category']).toBeDefined();
28
+ expect(registeredTools['get_categories']).toBeDefined();
29
+ expect(registeredTools['delete_category']).toBeDefined();
30
+ });
31
+ describe('create_category', () => {
32
+ it('should call api.post with correct data', async () => {
33
+ registerCategoryTools(mockServer);
34
+ const handler = registeredTools['create_category'];
35
+ apiClient.post.mockResolvedValue({ id: 'cat_1', name: 'Test' });
36
+ const result = await handler({ name: 'Test', type: 'EXPENSE' });
37
+ expect(apiClient.post).toHaveBeenCalledWith('/categories', { name: 'Test', type: 'EXPENSE' });
38
+ expect(result.content[0].text).toContain('Category created');
39
+ expect(result.content[0].text).toContain('Test');
40
+ });
41
+ });
42
+ describe('get_categories', () => {
43
+ it('should call api.get', async () => {
44
+ registerCategoryTools(mockServer);
45
+ const handler = registeredTools['get_categories'];
46
+ apiClient.get.mockResolvedValue([{ id: 'cat_1', name: 'Test' }]);
47
+ const result = await handler({});
48
+ expect(apiClient.get).toHaveBeenCalledWith('/categories');
49
+ expect(result.content[0].text).toContain('Test');
50
+ });
51
+ });
52
+ describe('delete_category', () => {
53
+ it('should call api.delete', async () => {
54
+ registerCategoryTools(mockServer);
55
+ const handler = registeredTools['delete_category'];
56
+ apiClient.delete.mockResolvedValue({});
57
+ const result = await handler({ id: 'cat_1' });
58
+ expect(apiClient.delete).toHaveBeenCalledWith('/categories/cat_1');
59
+ expect(result.content[0].text).toContain('Category deleted');
60
+ });
61
+ });
62
+ });
63
63
  //# sourceMappingURL=categories.test.js.map