quantix-mcp 0.3.7 → 0.4.3

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 (113) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/.github/agents/copilot-instructions.md +32 -32
  3. package/.github/copilot-instructions.md +17 -17
  4. package/.github/workflows/publish.yaml +28 -28
  5. package/.opencode/command/speckit.analyze.md +184 -184
  6. package/.opencode/command/speckit.checklist.md +294 -294
  7. package/.opencode/command/speckit.clarify.md +181 -181
  8. package/.opencode/command/speckit.constitution.md +84 -84
  9. package/.opencode/command/speckit.implement.md +135 -135
  10. package/.opencode/command/speckit.plan.md +89 -89
  11. package/.opencode/command/speckit.specify.md +258 -258
  12. package/.opencode/command/speckit.tasks.md +137 -137
  13. package/.opencode/command/speckit.taskstoissues.md +30 -30
  14. package/.specify/memory/constitution.md +58 -58
  15. package/.specify/templates/constitution-template.md +50 -50
  16. package/.vscode/launch.json +14 -14
  17. package/CLAUDE.md +70 -64
  18. package/GEMINI.md +58 -0
  19. package/README.md +176 -176
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +14 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/tools/accounts.d.ts.map +1 -1
  24. package/dist/tools/accounts.js +55 -34
  25. package/dist/tools/accounts.js.map +1 -1
  26. package/dist/tools/categories.d.ts.map +1 -1
  27. package/dist/tools/categories.js +46 -20
  28. package/dist/tools/categories.js.map +1 -1
  29. package/dist/tools/credit-cards.d.ts.map +1 -1
  30. package/dist/tools/credit-cards.js +104 -33
  31. package/dist/tools/credit-cards.js.map +1 -1
  32. package/dist/tools/data.d.ts.map +1 -1
  33. package/dist/tools/data.js +19 -8
  34. package/dist/tools/data.js.map +1 -1
  35. package/dist/tools/settings.d.ts.map +1 -1
  36. package/dist/tools/settings.js +28 -12
  37. package/dist/tools/settings.js.map +1 -1
  38. package/dist/tools/subscriptions.d.ts +3 -0
  39. package/dist/tools/subscriptions.d.ts.map +1 -0
  40. package/dist/tools/subscriptions.js +128 -0
  41. package/dist/tools/subscriptions.js.map +1 -0
  42. package/dist/tools/summary.d.ts.map +1 -1
  43. package/dist/tools/summary.js +17 -11
  44. package/dist/tools/summary.js.map +1 -1
  45. package/dist/tools/transactions.d.ts.map +1 -1
  46. package/dist/tools/transactions.js +85 -50
  47. package/dist/tools/transactions.js.map +1 -1
  48. package/dist/tools/transfers.d.ts +3 -0
  49. package/dist/tools/transfers.d.ts.map +1 -0
  50. package/dist/tools/transfers.js +107 -0
  51. package/dist/tools/transfers.js.map +1 -0
  52. package/dist/types/schemas.d.ts +65 -0
  53. package/dist/types/schemas.d.ts.map +1 -1
  54. package/dist/types/schemas.js +69 -3
  55. package/dist/types/schemas.js.map +1 -1
  56. package/dist/utils/toolHelpers.d.ts +7 -0
  57. package/dist/utils/toolHelpers.d.ts.map +1 -0
  58. package/dist/utils/toolHelpers.js +11 -0
  59. package/dist/utils/toolHelpers.js.map +1 -0
  60. package/openapi.yaml +2279 -1828
  61. package/package.json +41 -41
  62. package/specs/001-mcp-api-integration/checklists/requirements.md +34 -34
  63. package/specs/001-mcp-api-integration/contracts/openapi.yaml +635 -635
  64. package/specs/001-mcp-api-integration/data-model.md +106 -106
  65. package/specs/001-mcp-api-integration/plan.md +73 -73
  66. package/specs/001-mcp-api-integration/quickstart.md +74 -74
  67. package/specs/001-mcp-api-integration/research.md +58 -58
  68. package/specs/001-mcp-api-integration/spec.md +119 -119
  69. package/specs/001-mcp-api-integration/tasks.md +64 -64
  70. package/src/config.ts +36 -36
  71. package/src/index.ts +60 -47
  72. package/src/services/apiClient.ts +49 -49
  73. package/src/tools/accounts.ts +122 -111
  74. package/src/tools/categories.ts +102 -81
  75. package/src/tools/credit-cards.ts +203 -147
  76. package/src/tools/data.ts +45 -36
  77. package/src/tools/settings.ts +64 -51
  78. package/src/tools/subscriptions.ts +159 -0
  79. package/src/tools/summary.ts +29 -24
  80. package/src/tools/transactions.ts +156 -128
  81. package/src/tools/transfers.ts +122 -0
  82. package/src/types/schemas.ts +304 -235
  83. package/src/utils/toolHelpers.ts +11 -0
  84. package/tests/benchmark.test.d.ts +1 -1
  85. package/tests/benchmark.test.js +32 -32
  86. package/tests/benchmark.test.ts +38 -38
  87. package/tests/server.test.d.ts +1 -1
  88. package/tests/server.test.js +12 -12
  89. package/tests/server.test.ts +14 -14
  90. package/tests/setup.d.ts +3 -3
  91. package/tests/setup.js +16 -16
  92. package/tests/setup.ts +20 -20
  93. package/tests/tools/accounts.test.ts +159 -118
  94. package/tests/tools/categories.test.d.ts +1 -1
  95. package/tests/tools/categories.test.js +62 -62
  96. package/tests/tools/categories.test.ts +120 -78
  97. package/tests/tools/credit-cards.test.d.ts +1 -1
  98. package/tests/tools/credit-cards.test.js +70 -70
  99. package/tests/tools/credit-cards.test.ts +131 -89
  100. package/tests/tools/data.test.ts +100 -0
  101. package/tests/tools/settings.test.ts +116 -0
  102. package/tests/tools/subscriptions.test.ts +173 -0
  103. package/tests/tools/summary.test.d.ts +1 -1
  104. package/tests/tools/summary.test.js +35 -35
  105. package/tests/tools/summary.test.ts +63 -42
  106. package/tests/tools/transactions.test.d.ts +1 -1
  107. package/tests/tools/transactions.test.js +66 -66
  108. package/tests/tools/transactions.test.ts +133 -82
  109. package/tests/tools/transfers.test.ts +141 -0
  110. package/tsconfig.json +52 -52
  111. package/vitest.config.d.ts +2 -2
  112. package/vitest.config.js +13 -13
  113. package/vitest.config.ts +14 -14
@@ -1,235 +1,304 @@
1
- import { z } from 'zod';
2
-
3
- // --- Domain Entities ---
4
-
5
- export const CategorySchema = z.object({
6
- id: z.string(),
7
- name: z.string(),
8
- type: z.enum(["INCOME", "EXPENSE"]),
9
- color: z.string().optional(),
10
- createdAt: z.string().datetime().optional()
11
- });
12
-
13
- export const TransactionSchema = z.object({
14
- id: z.string(),
15
- type: z.enum(["INCOME", "EXPENSE"]),
16
- name: z.string(),
17
- amount: z.number().min(0),
18
- date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Invalid date format YYYY-MM-DD"),
19
- categoryId: z.string().optional(),
20
- paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
21
- creditCardId: z.string().optional(),
22
- installmentGroupId: z.string().optional(),
23
- installmentNumber: z.number().int().optional(),
24
- installmentTotal: z.number().int().optional(),
25
- recurrenceRuleId: z.string().optional(),
26
- accountId: z.string().optional(),
27
- paid: z.boolean().default(false),
28
- createdAt: z.string().datetime().optional()
29
- });
30
-
31
- export const CreditCardSchema = z.object({
32
- id: z.string(),
33
- name: z.string(),
34
- brand: z.string().optional(),
35
- limitAmount: z.number().min(0),
36
- closingDay: z.number().int().min(1).max(31),
37
- dueDay: z.number().int().min(1).max(31),
38
- createdAt: z.string().datetime().optional()
39
- });
40
-
41
- export const AccountSchema = z.object({
42
- id: z.string(),
43
- name: z.string(),
44
- type: z.enum(["BANK_ACCOUNT", "WALLET", "SAVINGS_ACCOUNT", "INVESTMENT_ACCOUNT", "OTHER"]),
45
- initialBalance: z.number(),
46
- currentBalance: z.number().optional(),
47
- createdAt: z.string().datetime().optional(),
48
- updatedAt: z.string().datetime().optional()
49
- });
50
-
51
- export const AccountBalanceSchema = z.object({
52
- accountId: z.string(),
53
- currentBalance: z.number(),
54
- calculatedAt: z.string().datetime()
55
- });
56
-
57
- export const StatementSchema = z.object({
58
- cardId: z.string(),
59
- periodStart: z.string(),
60
- periodEnd: z.string(),
61
- dueDate: z.string(),
62
- transactions: z.array(TransactionSchema).optional(),
63
- total: z.number(),
64
- availableLimit: z.number()
65
- });
66
-
67
- export const StatementStatusSchema = z.object({
68
- cardId: z.string(),
69
- month: z.string(),
70
- isPaid: z.boolean()
71
- });
72
-
73
- export const SummarySchema = z.object({
74
- period: z.object({
75
- month: z.string().optional(),
76
- startDate: z.string().optional(),
77
- endDate: z.string().optional()
78
- }).optional(),
79
- income: z.number(),
80
- expenses: z.number(),
81
- pendingIncome: z.number().optional(),
82
- pendingExpenses: z.number().optional(),
83
- balance: z.number(),
84
- creditCardExpenses: z.array(z.any()).optional(),
85
- expensesByCategory: z.array(z.any()).optional(),
86
- incomeByCategory: z.array(z.any()).optional(),
87
- accounts: z.array(z.any()).optional(),
88
- totalBalance: z.number().optional()
89
- });
90
-
91
- export const SettingsSchema = z.object({
92
- userName: z.string(),
93
- language: z.enum(["pt-BR", "en-US"]),
94
- currency: z.enum(["BRL", "USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF"]),
95
- createdAt: z.string().datetime().optional(),
96
- updatedAt: z.string().datetime().optional()
97
- });
98
-
99
- // --- Tool Inputs ---
100
-
101
- export const CreateCategoryInput = z.object({
102
- name: z.string(),
103
- type: z.enum(["INCOME", "EXPENSE"]),
104
- color: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Invalid hex color").optional()
105
- });
106
-
107
- export const UpdateCategoryInput = z.object({
108
- id: z.string(),
109
- name: z.string().optional(),
110
- color: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Invalid hex color").optional()
111
- });
112
-
113
- export const CreateCreditCardInput = z.object({
114
- name: z.string(),
115
- brand: z.string().optional(),
116
- limitAmount: z.number().min(0),
117
- closingDay: z.number().int().min(1).max(31),
118
- dueDay: z.number().int().min(1).max(31)
119
- });
120
-
121
- export const UpdateCreditCardInput = z.object({
122
- id: z.string(),
123
- name: z.string().optional(),
124
- brand: z.string().optional(),
125
- limitAmount: z.number().min(0).optional(),
126
- closingDay: z.number().int().min(1).max(31).optional(),
127
- dueDay: z.number().int().min(1).max(31).optional()
128
- });
129
-
130
- export const CreateTransactionInput = z.object({
131
- type: z.enum(["INCOME", "EXPENSE"]),
132
- name: z.string(),
133
- amount: z.number().positive(),
134
- date: z.string().describe("ISO date string YYYY-MM-DD"),
135
- categoryId: z.string().optional(),
136
- paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
137
- creditCardId: z.string().optional(),
138
- accountId: z.string().optional(),
139
- installments: z.number().int().min(1).optional(),
140
- targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/).optional(),
141
- purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Actual purchase date (credit card only), YYYY-MM-DD").optional(),
142
- isPaid: z.boolean().describe("Whether the transaction is already paid at creation time").optional(),
143
- recurrence: z.object({
144
- frequency: z.enum(["MONTHLY", "WEEKLY", "YEARLY"]),
145
- interval: z.number().int().min(1).optional(),
146
- endDate: z.string().optional(),
147
- occurrences: z.number().int().min(2).describe("Number of occurrences (mutually exclusive with endDate)").optional()
148
- }).optional()
149
- });
150
-
151
- export const UpdateTransactionInput = z.object({
152
- id: z.string(),
153
- mode: z.enum(["SINGLE", "PENDING", "ALL"]).default("SINGLE").optional(),
154
- type: z.enum(["INCOME", "EXPENSE"]).optional(),
155
- name: z.string().optional(),
156
- amount: z.number().positive().optional(),
157
- date: z.string().describe("ISO date string YYYY-MM-DD").optional(),
158
- categoryId: z.string().optional(),
159
- paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
160
- creditCardId: z.string().optional(),
161
- accountId: z.string().optional(),
162
- targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/).optional(),
163
- recurrence: z.object({
164
- frequency: z.enum(["MONTHLY", "WEEKLY", "YEARLY"]).optional(),
165
- interval: z.number().int().min(1).optional(),
166
- endDate: z.string().optional(),
167
- occurrences: z.number().int().min(2).describe("Number of occurrences (mutually exclusive with endDate)").optional()
168
- }).optional()
169
- });
170
-
171
- export const CreateAccountInput = z.object({
172
- name: z.string(),
173
- type: z.enum(["BANK_ACCOUNT", "WALLET", "SAVINGS_ACCOUNT", "INVESTMENT_ACCOUNT", "OTHER"]),
174
- initialBalance: z.number().optional()
175
- });
176
-
177
- export const UpdateAccountInput = z.object({
178
- id: z.string(),
179
- name: z.string().optional(),
180
- type: z.enum(["BANK_ACCOUNT", "WALLET", "SAVINGS_ACCOUNT", "INVESTMENT_ACCOUNT", "OTHER"]).optional()
181
- });
182
-
183
- export const GetTransactionsInput = z.object({
184
- month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM").describe("Filter by month, format: YYYY-MM").optional(),
185
- accountId: z.string().describe("Filter by account ID").optional(),
186
- categoryId: z.string().describe("Filter by category ID").optional(),
187
- creditCardId: z.string().describe("Filter by credit card ID").optional(),
188
- type: z.enum(["INCOME", "EXPENSE"]).describe("Filter by transaction type").optional(),
189
- startDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Filter from this date (inclusive), YYYY-MM-DD").optional(),
190
- endDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Filter up to this date (inclusive), YYYY-MM-DD").optional(),
191
- paid: z.boolean().describe("Filter by payment status (true = paid, false = unpaid)").optional()
192
- });
193
-
194
- export const PayStatementInput = z.object({
195
- cardId: z.string(),
196
- month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM"),
197
- paymentAccountId: z.string()
198
- });
199
-
200
- export const ReopenStatementInput = z.object({
201
- cardId: z.string().describe('Credit card ID'),
202
- month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM").describe('Month in YYYY-MM format')
203
- });
204
-
205
- export const GetSummaryInput = z.object({
206
- month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM").describe("Month in YYYY-MM format (use this OR startDate+endDate)").optional(),
207
- startDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Start date for custom range, YYYY-MM-DD (use with endDate)").optional(),
208
- endDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("End date for custom range, YYYY-MM-DD (use with startDate)").optional()
209
- });
210
-
211
- export const CreateSettingsInput = z.object({
212
- userName: z.string(),
213
- language: z.enum(["pt-BR", "en-US"]),
214
- currency: z.enum(["BRL", "USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF"])
215
- });
216
-
217
- export const UpdateSettingsInput = z.object({
218
- userName: z.string().optional(),
219
- language: z.enum(["pt-BR", "en-US"]).optional(),
220
- currency: z.enum(["BRL", "USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF"]).optional()
221
- });
222
-
223
- export const ImportDataInput = z.object({
224
- mode: z.enum(["reset", "increment"]).describe("reset: clears all data before import; increment: adds new records, skipping existing IDs"),
225
- version: z.string().describe('Export format version, must be "1.0"'),
226
- exportedAt: z.string().datetime().describe("ISO timestamp of when the data was exported"),
227
- data: z.object({
228
- settings: z.any().nullable().optional(),
229
- categories: z.array(z.any()).optional(),
230
- accounts: z.array(z.any()).optional(),
231
- creditCards: z.array(z.any()).optional(),
232
- recurrenceRules: z.array(z.any()).optional(),
233
- transactions: z.array(z.any()).optional()
234
- })
235
- });
1
+ import { z } from 'zod';
2
+
3
+ // --- Transfer Entities ---
4
+ export const TransferSchema = z.object({
5
+ id: z.string(),
6
+ sourceAccountId: z.string(),
7
+ destinationAccountId: z.string(),
8
+ amount: z.number().min(0.01),
9
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
10
+ createdAt: z.string().datetime().optional(),
11
+ updatedAt: z.string().datetime().optional(),
12
+ });
13
+
14
+ export const CreateTransferRequestSchema = z.object({
15
+ sourceAccountId: z.string().describe("Source account ID (required — must ask the user if not provided, do not assume or default)"),
16
+ destinationAccountId: z.string().describe("Destination account ID (required — must ask the user if not provided, do not assume or default)"),
17
+ amount: z.number().min(0.01).describe("Transfer amount (required — must ask the user if not provided, do not assume or default)"),
18
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Transfer date (required — must ask the user if not provided, do not assume or default)"),
19
+ });
20
+
21
+ export const UpdateTransferRequestSchema = z.object({
22
+ sourceAccountId: z.string().optional(),
23
+ destinationAccountId: z.string().optional(),
24
+ amount: z.number().min(0.01).optional(),
25
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
26
+ });
27
+
28
+ // --- Domain Entities ---
29
+
30
+ export const CategorySchema = z.object({
31
+ id: z.string(),
32
+ name: z.string(),
33
+ type: z.enum(["INCOME", "EXPENSE"]),
34
+ color: z.string().optional(),
35
+ createdAt: z.string().datetime().optional()
36
+ });
37
+
38
+ export const TransactionSchema = z.object({
39
+ id: z.string(),
40
+ type: z.enum(["INCOME", "EXPENSE"]),
41
+ name: z.string(),
42
+ amount: z.number().min(0),
43
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Invalid date format YYYY-MM-DD"),
44
+ categoryId: z.string().optional(),
45
+ paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
46
+ creditCardId: z.string().optional(),
47
+ installmentGroupId: z.string().optional(),
48
+ installmentNumber: z.number().int().optional(),
49
+ installmentTotal: z.number().int().optional(),
50
+ recurrenceRuleId: z.string().optional(),
51
+ accountId: z.string().optional(),
52
+ paid: z.boolean().default(false),
53
+ createdAt: z.string().datetime().optional()
54
+ });
55
+
56
+ export const CreditCardSchema = z.object({
57
+ id: z.string(),
58
+ name: z.string(),
59
+ brand: z.string().optional(),
60
+ limitAmount: z.number().min(0),
61
+ closingDay: z.number().int().min(1).max(31),
62
+ dueDay: z.number().int().min(1).max(31),
63
+ createdAt: z.string().datetime().optional()
64
+ });
65
+
66
+ export const AccountSchema = z.object({
67
+ id: z.string(),
68
+ name: z.string(),
69
+ type: z.enum(["BANK_ACCOUNT", "WALLET", "SAVINGS_ACCOUNT", "INVESTMENT_ACCOUNT", "OTHER"]),
70
+ initialBalance: z.number(),
71
+ currentBalance: z.number().optional(),
72
+ createdAt: z.string().datetime().optional(),
73
+ updatedAt: z.string().datetime().optional()
74
+ });
75
+
76
+ export const AccountBalanceSchema = z.object({
77
+ accountId: z.string(),
78
+ currentBalance: z.number(),
79
+ calculatedAt: z.string().datetime()
80
+ });
81
+
82
+ export const StatementSchema = z.object({
83
+ cardId: z.string(),
84
+ periodStart: z.string(),
85
+ periodEnd: z.string(),
86
+ dueDate: z.string(),
87
+ transactions: z.array(TransactionSchema).optional(),
88
+ total: z.number(),
89
+ availableLimit: z.number()
90
+ });
91
+
92
+ export const StatementStatusSchema = z.object({
93
+ cardId: z.string(),
94
+ month: z.string(),
95
+ isPaid: z.boolean()
96
+ });
97
+
98
+ export const SummarySchema = z.object({
99
+ period: z.object({
100
+ month: z.string().optional(),
101
+ startDate: z.string().optional(),
102
+ endDate: z.string().optional()
103
+ }).optional(),
104
+ income: z.number(),
105
+ expenses: z.number(),
106
+ pendingIncome: z.number().optional(),
107
+ pendingExpenses: z.number().optional(),
108
+ balance: z.number(),
109
+ creditCardExpenses: z.array(z.any()).optional(),
110
+ expensesByCategory: z.array(z.any()).optional(),
111
+ incomeByCategory: z.array(z.any()).optional(),
112
+ accounts: z.array(z.any()).optional(),
113
+ totalBalance: z.number().optional()
114
+ });
115
+
116
+ export const SettingsSchema = z.object({
117
+ userName: z.string(),
118
+ language: z.enum(["pt-BR", "en-US"]),
119
+ currency: z.enum(["BRL", "USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF"]),
120
+ createdAt: z.string().datetime().optional(),
121
+ updatedAt: z.string().datetime().optional()
122
+ });
123
+
124
+ // --- Tool Inputs ---
125
+
126
+ export const CreateCategoryInput = z.object({
127
+ name: z.string(),
128
+ type: z.enum(["INCOME", "EXPENSE"]),
129
+ color: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Invalid hex color").optional()
130
+ });
131
+
132
+ export const UpdateCategoryInput = z.object({
133
+ id: z.string(),
134
+ name: z.string().optional(),
135
+ color: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Invalid hex color").optional()
136
+ });
137
+
138
+ export const CreateCreditCardInput = z.object({
139
+ name: z.string(),
140
+ brand: z.string().optional(),
141
+ limitAmount: z.number().min(0),
142
+ closingDay: z.number().int().min(1).max(31),
143
+ dueDay: z.number().int().min(1).max(31)
144
+ });
145
+
146
+ export const UpdateCreditCardInput = z.object({
147
+ id: z.string(),
148
+ name: z.string().optional(),
149
+ brand: z.string().optional(),
150
+ limitAmount: z.number().min(0).optional(),
151
+ closingDay: z.number().int().min(1).max(31).optional(),
152
+ dueDay: z.number().int().min(1).max(31).optional()
153
+ });
154
+
155
+ export const CreateTransactionInput = z.object({
156
+ type: z.enum(["INCOME", "EXPENSE"]),
157
+ name: z.string(),
158
+ amount: z.number().nonnegative().describe("Transaction amount (required — must ask the user if not provided, do not assume or default)"),
159
+ date: z.string().describe("ISO date string YYYY-MM-DD"),
160
+ categoryId: z.string().optional(),
161
+ paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
162
+ creditCardId: z.string().optional(),
163
+ accountId: z.string().optional(),
164
+ installments: z.number().int().min(1).optional(),
165
+ targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/).optional(),
166
+ purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Actual purchase date (credit card only), YYYY-MM-DD").optional(),
167
+ isPaid: z.boolean().describe("Whether the transaction is already paid at creation time").optional(),
168
+ recurrence: z.object({
169
+ frequency: z.enum(["MONTHLY", "WEEKLY", "YEARLY"]),
170
+ interval: z.number().int().min(1).optional(),
171
+ endDate: z.string().optional(),
172
+ occurrences: z.number().int().min(2).describe("Number of occurrences (mutually exclusive with endDate)").optional()
173
+ }).optional()
174
+ });
175
+
176
+ export const UpdateTransactionInput = z.object({
177
+ id: z.string(),
178
+ mode: z.enum(["SINGLE", "PENDING", "ALL"]).default("SINGLE").optional(),
179
+ type: z.enum(["INCOME", "EXPENSE"]).optional(),
180
+ name: z.string().optional(),
181
+ amount: z.number().nonnegative().optional(),
182
+ date: z.string().describe("ISO date string YYYY-MM-DD").optional(),
183
+ categoryId: z.string().optional(),
184
+ paymentMethod: z.enum(["CASH", "PIX", "DEBIT", "CREDIT"]).optional(),
185
+ creditCardId: z.string().optional(),
186
+ accountId: z.string().optional(),
187
+ installments: z.number().int().min(1).optional(),
188
+ targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/).optional(),
189
+ isPaid: z.boolean().optional(),
190
+ purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Actual purchase date (credit card only), YYYY-MM-DD").optional(),
191
+ recurrence: z.object({
192
+ frequency: z.enum(["MONTHLY", "WEEKLY", "YEARLY"]).optional(),
193
+ interval: z.number().int().min(1).optional(),
194
+ endDate: z.string().optional(),
195
+ occurrences: z.number().int().min(2).describe("Number of occurrences (mutually exclusive with endDate)").optional()
196
+ }).optional()
197
+ });
198
+
199
+ export const CreateAccountInput = z.object({
200
+ name: z.string(),
201
+ type: z.enum(["BANK_ACCOUNT", "WALLET", "SAVINGS_ACCOUNT", "INVESTMENT_ACCOUNT", "OTHER"]),
202
+ initialBalance: z.number().optional()
203
+ });
204
+
205
+ export const UpdateAccountInput = z.object({
206
+ id: z.string(),
207
+ name: z.string().optional(),
208
+ type: z.enum(["BANK_ACCOUNT", "WALLET", "SAVINGS_ACCOUNT", "INVESTMENT_ACCOUNT", "OTHER"]).optional(),
209
+ initialBalance: z.number().optional()
210
+ });
211
+
212
+ export const GetTransactionsInput = z.object({
213
+ month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM").describe("Filter by month, format: YYYY-MM").optional(),
214
+ accountId: z.string().describe("Filter by account ID").optional(),
215
+ categoryId: z.string().describe("Filter by category ID").optional(),
216
+ creditCardId: z.string().describe("Filter by credit card ID").optional(),
217
+ type: z.enum(["INCOME", "EXPENSE"]).describe("Filter by transaction type").optional(),
218
+ startDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Filter from this date (inclusive), YYYY-MM-DD").optional(),
219
+ endDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Filter up to this date (inclusive), YYYY-MM-DD").optional(),
220
+ paid: z.boolean().describe("Filter by payment status (true = paid, false = unpaid)").optional()
221
+ });
222
+
223
+ export const PayStatementInput = z.object({
224
+ cardId: z.string(),
225
+ month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM"),
226
+ paymentAccountId: z.string()
227
+ });
228
+
229
+ export const ReopenStatementInput = z.object({
230
+ cardId: z.string().describe('Credit card ID'),
231
+ month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM").describe('Month in YYYY-MM format')
232
+ });
233
+
234
+ export const GetSummaryInput = z.object({
235
+ month: z.string().regex(/^\d{4}-\d{2}$/, "Format: YYYY-MM").describe("Month in YYYY-MM format (use this OR startDate+endDate)").optional(),
236
+ startDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Start date for custom range, YYYY-MM-DD (use with endDate)").optional(),
237
+ endDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("End date for custom range, YYYY-MM-DD (use with startDate)").optional()
238
+ });
239
+
240
+ export const CreateSettingsInput = z.object({
241
+ userName: z.string(),
242
+ language: z.enum(["pt-BR", "en-US"]),
243
+ currency: z.enum(["BRL", "USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF"])
244
+ });
245
+
246
+ export const UpdateSettingsInput = z.object({
247
+ userName: z.string().optional(),
248
+ language: z.enum(["pt-BR", "en-US"]).optional(),
249
+ currency: z.enum(["BRL", "USD", "EUR", "GBP", "JPY", "CAD", "AUD", "CHF"]).optional()
250
+ });
251
+
252
+ export const CreateAnticipationInput = z.object({
253
+ cardId: z.string().describe('Credit card ID'),
254
+ name: z.string().describe('Name/description of the anticipation'),
255
+ amount: z.number().min(0.01).describe('Amount to anticipate'),
256
+ purchaseDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe('Date the money leaves the account (YYYY-MM-DD)'),
257
+ targetDueMonth: z.string().regex(/^\d{4}-\d{2}$/).describe('Target statement due month (YYYY-MM)'),
258
+ accountId: z.string().describe('Account ID from which money will be debited'),
259
+ categoryId: z.string().optional().describe('Category ID for both transactions')
260
+ });
261
+
262
+ export const ImportDataInput = z.object({
263
+ mode: z.enum(["reset", "increment"]).describe("reset: clears all data before import; increment: adds new records, skipping existing IDs"),
264
+ version: z.string().describe('Export format version, must be "1.0"'),
265
+ exportedAt: z.string().datetime().describe("ISO timestamp of when the data was exported"),
266
+ data: z.object({
267
+ settings: z.any().nullable().optional(),
268
+ categories: z.array(z.any()).optional(),
269
+ accounts: z.array(z.any()).optional(),
270
+ creditCards: z.array(z.any()).optional(),
271
+ recurrenceRules: z.array(z.any()).optional(),
272
+ transactions: z.array(z.any()).optional()
273
+ })
274
+ });
275
+
276
+ export const SubscriptionSchema = z.object({
277
+ id: z.string(),
278
+ name: z.string(),
279
+ amount: z.number().min(0.01),
280
+ billingDay: z.number().int().min(1).max(31),
281
+ creditCardId: z.string(),
282
+ categoryId: z.string().optional(),
283
+ active: z.boolean(),
284
+ createdAt: z.string().datetime().optional(),
285
+ updatedAt: z.string().datetime().optional()
286
+ });
287
+
288
+ export const CreateSubscriptionInput = z.object({
289
+ name: z.string().describe("Name of the subscription (e.g., Netflix, Spotify)"),
290
+ amount: z.number().min(0.01).describe("Monthly amount charged"),
291
+ billingDay: z.number().int().min(1).max(31).describe("Day of the month when the subscription is charged (1-31)"),
292
+ creditCardId: z.string().describe("ID of the credit card used for this subscription"),
293
+ categoryId: z.string().describe("ID of the expense category").optional()
294
+ });
295
+
296
+ export const UpdateSubscriptionInput = z.object({
297
+ id: z.string(),
298
+ name: z.string().optional(),
299
+ amount: z.number().min(0.01).optional(),
300
+ billingDay: z.number().int().min(1).max(31).optional(),
301
+ creditCardId: z.string().optional(),
302
+ categoryId: z.string().optional(),
303
+ active: z.boolean().optional()
304
+ });
@@ -0,0 +1,11 @@
1
+ import { ApiClientError } from '../services/apiClient.js';
2
+
3
+ export function handleToolError(error: unknown): { content: [{ type: 'text'; text: string }] } {
4
+ if (error instanceof ApiClientError) {
5
+ return { content: [{ type: 'text', text: `API error ${error.status}: ${error.statusText}` }] };
6
+ }
7
+ if (error instanceof Error) {
8
+ return { content: [{ type: 'text', text: `Error: ${error.message}` }] };
9
+ }
10
+ return { content: [{ type: 'text', text: 'An unexpected error occurred.' }] };
11
+ }
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=benchmark.test.d.ts.map
@@ -1,33 +1,33 @@
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
- vi.mock('../src/services/apiClient.js', () => ({
5
- apiClient: {
6
- get: vi.fn(),
7
- }
8
- }));
9
- describe('Performance Benchmark', () => {
10
- // This is a rough benchmark, mostly verifying it's not super slow due to overhead
11
- it('should execute tool handler with low overhead (<20ms)', async () => {
12
- const registeredTools = {};
13
- const mockServer = {
14
- registerTool: (name, def, handler) => {
15
- registeredTools[name] = handler;
16
- }
17
- };
18
- // Setup
19
- registerCategoryTools(mockServer);
20
- const handler = registeredTools['get_categories'];
21
- apiClient.get.mockResolvedValue([]);
22
- // Warmup
23
- await handler({});
24
- // Measure
25
- const start = performance.now();
26
- await handler({});
27
- const end = performance.now();
28
- const duration = end - start;
29
- console.log(`Tool execution overhead: ${duration.toFixed(3)}ms`);
30
- expect(duration).toBeLessThan(20);
31
- });
32
- });
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
+ vi.mock('../src/services/apiClient.js', () => ({
5
+ apiClient: {
6
+ get: vi.fn(),
7
+ }
8
+ }));
9
+ describe('Performance Benchmark', () => {
10
+ // This is a rough benchmark, mostly verifying it's not super slow due to overhead
11
+ it('should execute tool handler with low overhead (<20ms)', async () => {
12
+ const registeredTools = {};
13
+ const mockServer = {
14
+ registerTool: (name, def, handler) => {
15
+ registeredTools[name] = handler;
16
+ }
17
+ };
18
+ // Setup
19
+ registerCategoryTools(mockServer);
20
+ const handler = registeredTools['get_categories'];
21
+ apiClient.get.mockResolvedValue([]);
22
+ // Warmup
23
+ await handler({});
24
+ // Measure
25
+ const start = performance.now();
26
+ await handler({});
27
+ const end = performance.now();
28
+ const duration = end - start;
29
+ console.log(`Tool execution overhead: ${duration.toFixed(3)}ms`);
30
+ expect(duration).toBeLessThan(20);
31
+ });
32
+ });
33
33
  //# sourceMappingURL=benchmark.test.js.map