@dizzlkheinz/ynab-mcpb 0.18.4 → 0.19.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/CLAUDE.md +87 -8
- package/bin/ynab-mcp-server.cjs +2 -2
- package/bin/ynab-mcp-server.js +3 -3
- package/biome.json +39 -0
- package/dist/bundle/index.cjs +67 -67
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -27
- package/dist/server/YNABMCPServer.d.ts +3 -4
- package/dist/server/YNABMCPServer.js +111 -116
- package/dist/server/budgetResolver.d.ts +6 -5
- package/dist/server/budgetResolver.js +46 -36
- package/dist/server/cacheKeys.js +6 -6
- package/dist/server/cacheManager.js +14 -11
- package/dist/server/completions.d.ts +2 -2
- package/dist/server/completions.js +20 -15
- package/dist/server/config.d.ts +10 -5
- package/dist/server/config.js +24 -7
- package/dist/server/deltaCache.d.ts +2 -2
- package/dist/server/deltaCache.js +22 -16
- package/dist/server/deltaCache.merge.d.ts +2 -2
- package/dist/server/diagnostics.d.ts +4 -4
- package/dist/server/diagnostics.js +38 -32
- package/dist/server/errorHandler.d.ts +5 -12
- package/dist/server/errorHandler.js +219 -217
- package/dist/server/prompts.d.ts +2 -2
- package/dist/server/prompts.js +45 -45
- package/dist/server/rateLimiter.js +4 -4
- package/dist/server/requestLogger.d.ts +1 -1
- package/dist/server/requestLogger.js +40 -35
- package/dist/server/resources.d.ts +3 -3
- package/dist/server/resources.js +55 -52
- package/dist/server/responseFormatter.js +6 -6
- package/dist/server/securityMiddleware.d.ts +2 -2
- package/dist/server/securityMiddleware.js +22 -20
- package/dist/server/serverKnowledgeStore.js +1 -1
- package/dist/server/toolRegistry.d.ts +3 -3
- package/dist/server/toolRegistry.js +47 -40
- package/dist/tools/__tests__/deltaTestUtils.d.ts +3 -3
- package/dist/tools/__tests__/deltaTestUtils.js +2 -2
- package/dist/tools/accountTools.d.ts +9 -8
- package/dist/tools/accountTools.js +47 -47
- package/dist/tools/adapters.d.ts +13 -8
- package/dist/tools/adapters.js +21 -11
- package/dist/tools/budgetTools.d.ts +8 -7
- package/dist/tools/budgetTools.js +22 -22
- package/dist/tools/categoryTools.d.ts +9 -8
- package/dist/tools/categoryTools.js +68 -59
- package/dist/tools/compareTransactions/formatter.d.ts +3 -3
- package/dist/tools/compareTransactions/formatter.js +9 -9
- package/dist/tools/compareTransactions/index.d.ts +6 -6
- package/dist/tools/compareTransactions/index.js +58 -43
- package/dist/tools/compareTransactions/matcher.d.ts +1 -1
- package/dist/tools/compareTransactions/matcher.js +28 -15
- package/dist/tools/compareTransactions/parser.d.ts +2 -2
- package/dist/tools/compareTransactions/parser.js +144 -138
- package/dist/tools/compareTransactions/types.d.ts +4 -4
- package/dist/tools/compareTransactions.d.ts +1 -1
- package/dist/tools/compareTransactions.js +1 -1
- package/dist/tools/deltaFetcher.d.ts +2 -2
- package/dist/tools/deltaFetcher.js +16 -15
- package/dist/tools/deltaSupport.d.ts +4 -4
- package/dist/tools/deltaSupport.js +35 -41
- package/dist/tools/exportTransactions.d.ts +5 -4
- package/dist/tools/exportTransactions.js +61 -59
- package/dist/tools/monthTools.d.ts +7 -6
- package/dist/tools/monthTools.js +31 -29
- package/dist/tools/payeeTools.d.ts +7 -6
- package/dist/tools/payeeTools.js +28 -28
- package/dist/tools/reconcileAdapter.d.ts +2 -2
- package/dist/tools/reconcileAdapter.js +19 -12
- package/dist/tools/reconciliation/analyzer.d.ts +4 -4
- package/dist/tools/reconciliation/analyzer.js +73 -59
- package/dist/tools/reconciliation/csvParser.d.ts +3 -3
- package/dist/tools/reconciliation/csvParser.js +128 -104
- package/dist/tools/reconciliation/executor.d.ts +4 -4
- package/dist/tools/reconciliation/executor.js +148 -109
- package/dist/tools/reconciliation/index.d.ts +10 -10
- package/dist/tools/reconciliation/index.js +96 -83
- package/dist/tools/reconciliation/matcher.d.ts +3 -3
- package/dist/tools/reconciliation/matcher.js +17 -16
- package/dist/tools/reconciliation/payeeNormalizer.js +19 -8
- package/dist/tools/reconciliation/recommendationEngine.d.ts +1 -1
- package/dist/tools/reconciliation/recommendationEngine.js +40 -40
- package/dist/tools/reconciliation/reportFormatter.d.ts +2 -2
- package/dist/tools/reconciliation/reportFormatter.js +59 -58
- package/dist/tools/reconciliation/signDetector.d.ts +1 -1
- package/dist/tools/reconciliation/types.d.ts +16 -16
- package/dist/tools/reconciliation/ynabAdapter.d.ts +2 -2
- package/dist/tools/schemas/common.d.ts +1 -1
- package/dist/tools/schemas/common.js +1 -1
- package/dist/tools/schemas/outputs/accountOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/accountOutputs.js +24 -18
- package/dist/tools/schemas/outputs/budgetOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/budgetOutputs.js +14 -11
- package/dist/tools/schemas/outputs/categoryOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/categoryOutputs.js +49 -29
- package/dist/tools/schemas/outputs/comparisonOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/comparisonOutputs.js +12 -12
- package/dist/tools/schemas/outputs/index.d.ts +14 -14
- package/dist/tools/schemas/outputs/index.js +14 -14
- package/dist/tools/schemas/outputs/monthOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/monthOutputs.js +56 -41
- package/dist/tools/schemas/outputs/payeeOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/payeeOutputs.js +10 -10
- package/dist/tools/schemas/outputs/reconciliationOutputs.d.ts +2 -2
- package/dist/tools/schemas/outputs/reconciliationOutputs.js +45 -45
- package/dist/tools/schemas/outputs/transactionMutationOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/transactionMutationOutputs.js +28 -22
- package/dist/tools/schemas/outputs/transactionOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/transactionOutputs.js +43 -35
- package/dist/tools/schemas/outputs/utilityOutputs.d.ts +1 -1
- package/dist/tools/schemas/outputs/utilityOutputs.js +5 -3
- package/dist/tools/schemas/shared/commonOutputs.d.ts +1 -1
- package/dist/tools/schemas/shared/commonOutputs.js +15 -9
- package/dist/tools/transactionReadTools.d.ts +11 -0
- package/dist/tools/transactionReadTools.js +202 -0
- package/dist/tools/transactionSchemas.d.ts +7 -7
- package/dist/tools/transactionSchemas.js +77 -57
- package/dist/tools/transactionTools.d.ts +6 -24
- package/dist/tools/transactionTools.js +7 -1499
- package/dist/tools/transactionUtils.d.ts +6 -6
- package/dist/tools/transactionUtils.js +78 -63
- package/dist/tools/transactionWriteTools.d.ts +20 -0
- package/dist/tools/transactionWriteTools.js +1342 -0
- package/dist/tools/utilityTools.d.ts +5 -4
- package/dist/tools/utilityTools.js +11 -11
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.js +6 -6
- package/dist/types/reconciliation.d.ts +1 -1
- package/dist/types/toolRegistration.d.ts +14 -12
- package/dist/utils/amountUtils.js +1 -1
- package/dist/utils/dateUtils.js +4 -4
- package/dist/utils/errors.d.ts +3 -3
- package/dist/utils/errors.js +4 -4
- package/dist/utils/money.d.ts +2 -2
- package/dist/utils/money.js +8 -8
- package/dist/utils/validationError.d.ts +1 -1
- package/dist/utils/validationError.js +1 -1
- package/docs/assets/examples/reconciliation-with-recommendations.json +66 -66
- package/docs/assets/schemas/reconciliation-v2.json +360 -336
- package/esbuild.config.mjs +53 -50
- package/meta.json +12548 -12548
- package/package.json +98 -111
- package/scripts/analyze-bundle.mjs +33 -30
- package/scripts/create-pr-description.js +169 -120
- package/scripts/run-all-tests.js +178 -169
- package/scripts/run-domain-integration-tests.js +28 -18
- package/scripts/run-generate-mcpb.js +19 -17
- package/scripts/run-throttled-integration-tests.js +92 -83
- package/scripts/test-delta-params.mjs +149 -120
- package/scripts/test-recommendations.ts +36 -32
- package/scripts/tmpTransaction.ts +80 -43
- package/scripts/validate-env.js +98 -91
- package/scripts/verify-build.js +78 -76
- package/src/__tests__/comprehensive.integration.test.ts +1281 -1154
- package/src/__tests__/performance.test.ts +723 -671
- package/src/__tests__/setup.ts +442 -395
- package/src/__tests__/smoke.e2e.test.ts +41 -39
- package/src/__tests__/testRunner.ts +314 -295
- package/src/__tests__/testUtils.ts +456 -364
- package/src/__tests__/tools/reconciliation/csvParser.integration.test.ts +109 -107
- package/src/__tests__/tools/reconciliation/real-world.integration.test.ts +41 -41
- package/src/index.ts +68 -59
- package/src/server/CLAUDE.md +480 -0
- package/src/server/YNABMCPServer.ts +821 -794
- package/src/server/__tests__/YNABMCPServer.integration.test.ts +929 -893
- package/src/server/__tests__/YNABMCPServer.test.ts +903 -899
- package/src/server/__tests__/budgetResolver.test.ts +466 -423
- package/src/server/__tests__/cacheManager.test.ts +891 -874
- package/src/server/__tests__/completions.integration.test.ts +115 -106
- package/src/server/__tests__/completions.test.ts +334 -313
- package/src/server/__tests__/config.test.ts +98 -86
- package/src/server/__tests__/deltaCache.merge.test.ts +774 -703
- package/src/server/__tests__/deltaCache.swr.test.ts +198 -153
- package/src/server/__tests__/deltaCache.test.ts +946 -759
- package/src/server/__tests__/diagnostics.test.ts +825 -792
- package/src/server/__tests__/errorHandler.integration.test.ts +512 -462
- package/src/server/__tests__/errorHandler.test.ts +402 -397
- package/src/server/__tests__/prompts.test.ts +424 -347
- package/src/server/__tests__/rateLimiter.test.ts +313 -309
- package/src/server/__tests__/requestLogger.test.ts +443 -403
- package/src/server/__tests__/resources.template.test.ts +196 -185
- package/src/server/__tests__/resources.test.ts +294 -288
- package/src/server/__tests__/security.integration.test.ts +487 -421
- package/src/server/__tests__/securityMiddleware.test.ts +519 -444
- package/src/server/__tests__/server-startup.integration.test.ts +509 -490
- package/src/server/__tests__/serverKnowledgeStore.test.ts +174 -173
- package/src/server/__tests__/toolRegistration.test.ts +239 -210
- package/src/server/__tests__/toolRegistry.test.ts +907 -845
- package/src/server/budgetResolver.ts +221 -181
- package/src/server/cacheKeys.ts +6 -6
- package/src/server/cacheManager.ts +498 -484
- package/src/server/completions.ts +267 -243
- package/src/server/config.ts +35 -14
- package/src/server/deltaCache.merge.ts +146 -128
- package/src/server/deltaCache.ts +352 -309
- package/src/server/diagnostics.ts +257 -242
- package/src/server/errorHandler.ts +747 -744
- package/src/server/prompts.ts +181 -176
- package/src/server/rateLimiter.ts +131 -129
- package/src/server/requestLogger.ts +350 -322
- package/src/server/resources.ts +442 -374
- package/src/server/responseFormatter.ts +41 -37
- package/src/server/securityMiddleware.ts +223 -205
- package/src/server/serverKnowledgeStore.ts +67 -67
- package/src/server/toolRegistry.ts +508 -474
- package/src/tools/CLAUDE.md +604 -0
- package/src/tools/__tests__/accountTools.delta.integration.test.ts +128 -111
- package/src/tools/__tests__/accountTools.integration.test.ts +129 -111
- package/src/tools/__tests__/accountTools.test.ts +685 -638
- package/src/tools/__tests__/adapters.test.ts +142 -108
- package/src/tools/__tests__/budgetTools.delta.integration.test.ts +73 -73
- package/src/tools/__tests__/budgetTools.integration.test.ts +132 -124
- package/src/tools/__tests__/budgetTools.test.ts +442 -413
- package/src/tools/__tests__/categoryTools.delta.integration.test.ts +76 -68
- package/src/tools/__tests__/categoryTools.integration.test.ts +314 -288
- package/src/tools/__tests__/categoryTools.test.ts +656 -625
- package/src/tools/__tests__/compareTransactions/formatter.test.ts +535 -462
- package/src/tools/__tests__/compareTransactions/index.test.ts +378 -358
- package/src/tools/__tests__/compareTransactions/matcher.test.ts +497 -398
- package/src/tools/__tests__/compareTransactions/parser.test.ts +765 -747
- package/src/tools/__tests__/compareTransactions.test.ts +352 -332
- package/src/tools/__tests__/compareTransactions.window.test.ts +150 -146
- package/src/tools/__tests__/deltaFetcher.scheduled.integration.test.ts +69 -65
- package/src/tools/__tests__/deltaFetcher.test.ts +325 -265
- package/src/tools/__tests__/deltaSupport.test.ts +211 -184
- package/src/tools/__tests__/deltaTestUtils.ts +37 -33
- package/src/tools/__tests__/exportTransactions.test.ts +205 -200
- package/src/tools/__tests__/monthTools.delta.integration.test.ts +68 -68
- package/src/tools/__tests__/monthTools.integration.test.ts +178 -166
- package/src/tools/__tests__/monthTools.test.ts +561 -512
- package/src/tools/__tests__/payeeTools.delta.integration.test.ts +68 -68
- package/src/tools/__tests__/payeeTools.integration.test.ts +158 -142
- package/src/tools/__tests__/payeeTools.test.ts +486 -434
- package/src/tools/__tests__/transactionSchemas.test.ts +1202 -1186
- package/src/tools/__tests__/transactionTools.integration.test.ts +875 -825
- package/src/tools/__tests__/transactionTools.test.ts +4923 -4366
- package/src/tools/__tests__/transactionUtils.test.ts +1004 -977
- package/src/tools/__tests__/utilityTools.integration.test.ts +32 -32
- package/src/tools/__tests__/utilityTools.test.ts +68 -58
- package/src/tools/accountTools.ts +293 -271
- package/src/tools/adapters.ts +120 -63
- package/src/tools/budgetTools.ts +121 -116
- package/src/tools/categoryTools.ts +379 -339
- package/src/tools/compareTransactions/formatter.ts +131 -119
- package/src/tools/compareTransactions/index.ts +249 -214
- package/src/tools/compareTransactions/matcher.ts +259 -209
- package/src/tools/compareTransactions/parser.ts +517 -487
- package/src/tools/compareTransactions/types.ts +38 -38
- package/src/tools/compareTransactions.ts +1 -1
- package/src/tools/deltaFetcher.ts +281 -260
- package/src/tools/deltaSupport.ts +264 -259
- package/src/tools/exportTransactions.ts +230 -218
- package/src/tools/monthTools.ts +180 -165
- package/src/tools/payeeTools.ts +152 -140
- package/src/tools/reconcileAdapter.ts +297 -252
- package/src/tools/reconciliation/CLAUDE.md +506 -0
- package/src/tools/reconciliation/__tests__/adapter.causes.test.ts +133 -124
- package/src/tools/reconciliation/__tests__/adapter.test.ts +249 -230
- package/src/tools/reconciliation/__tests__/analyzer.test.ts +408 -400
- package/src/tools/reconciliation/__tests__/csvParser.test.ts +71 -69
- package/src/tools/reconciliation/__tests__/executor.integration.test.ts +348 -323
- package/src/tools/reconciliation/__tests__/executor.progress.test.ts +503 -457
- package/src/tools/reconciliation/__tests__/executor.test.ts +898 -831
- package/src/tools/reconciliation/__tests__/matcher.test.ts +667 -663
- package/src/tools/reconciliation/__tests__/payeeNormalizer.test.ts +296 -276
- package/src/tools/reconciliation/__tests__/recommendationEngine.integration.test.ts +692 -624
- package/src/tools/reconciliation/__tests__/recommendationEngine.test.ts +1008 -989
- package/src/tools/reconciliation/__tests__/reconciliation.delta.integration.test.ts +187 -146
- package/src/tools/reconciliation/__tests__/reportFormatter.test.ts +583 -533
- package/src/tools/reconciliation/__tests__/scenarios/adapterCurrency.scenario.test.ts +75 -74
- package/src/tools/reconciliation/__tests__/scenarios/extremes.scenario.test.ts +70 -62
- package/src/tools/reconciliation/__tests__/scenarios/repeatAmount.scenario.test.ts +102 -88
- package/src/tools/reconciliation/__tests__/schemaUrl.test.ts +56 -55
- package/src/tools/reconciliation/__tests__/signDetector.test.ts +209 -206
- package/src/tools/reconciliation/__tests__/ynabAdapter.test.ts +66 -60
- package/src/tools/reconciliation/analyzer.ts +564 -504
- package/src/tools/reconciliation/csvParser.ts +656 -609
- package/src/tools/reconciliation/executor.ts +1290 -1128
- package/src/tools/reconciliation/index.ts +580 -528
- package/src/tools/reconciliation/matcher.ts +256 -240
- package/src/tools/reconciliation/payeeNormalizer.ts +92 -78
- package/src/tools/reconciliation/recommendationEngine.ts +357 -345
- package/src/tools/reconciliation/reportFormatter.ts +343 -307
- package/src/tools/reconciliation/signDetector.ts +89 -83
- package/src/tools/reconciliation/types.ts +164 -159
- package/src/tools/reconciliation/ynabAdapter.ts +17 -15
- package/src/tools/schemas/CLAUDE.md +546 -0
- package/src/tools/schemas/common.ts +1 -1
- package/src/tools/schemas/outputs/__tests__/accountOutputs.test.ts +410 -409
- package/src/tools/schemas/outputs/__tests__/budgetOutputs.test.ts +305 -299
- package/src/tools/schemas/outputs/__tests__/categoryOutputs.test.ts +431 -430
- package/src/tools/schemas/outputs/__tests__/comparisonOutputs.test.ts +510 -495
- package/src/tools/schemas/outputs/__tests__/dateValidation.test.ts +179 -153
- package/src/tools/schemas/outputs/__tests__/discrepancyDirection.test.ts +293 -254
- package/src/tools/schemas/outputs/__tests__/monthOutputs.test.ts +457 -457
- package/src/tools/schemas/outputs/__tests__/payeeOutputs.test.ts +362 -356
- package/src/tools/schemas/outputs/__tests__/reconciliationOutputs.test.ts +402 -399
- package/src/tools/schemas/outputs/__tests__/transactionMutationSchemas.test.ts +225 -211
- package/src/tools/schemas/outputs/__tests__/transactionOutputs.test.ts +457 -454
- package/src/tools/schemas/outputs/__tests__/utilityOutputs.test.ts +316 -315
- package/src/tools/schemas/outputs/accountOutputs.ts +40 -34
- package/src/tools/schemas/outputs/budgetOutputs.ts +24 -19
- package/src/tools/schemas/outputs/categoryOutputs.ts +76 -56
- package/src/tools/schemas/outputs/comparisonOutputs.ts +192 -169
- package/src/tools/schemas/outputs/index.ts +163 -163
- package/src/tools/schemas/outputs/monthOutputs.ts +95 -80
- package/src/tools/schemas/outputs/payeeOutputs.ts +18 -18
- package/src/tools/schemas/outputs/reconciliationOutputs.ts +386 -373
- package/src/tools/schemas/outputs/transactionMutationOutputs.ts +259 -231
- package/src/tools/schemas/outputs/transactionOutputs.ts +81 -71
- package/src/tools/schemas/outputs/utilityOutputs.ts +90 -84
- package/src/tools/schemas/shared/commonOutputs.ts +27 -19
- package/src/tools/toolCategories.ts +114 -114
- package/src/tools/transactionReadTools.ts +327 -0
- package/src/tools/transactionSchemas.ts +322 -291
- package/src/tools/transactionTools.ts +84 -2246
- package/src/tools/transactionUtils.ts +507 -422
- package/src/tools/transactionWriteTools.ts +2110 -0
- package/src/tools/utilityTools.ts +46 -41
- package/src/types/CLAUDE.md +477 -0
- package/src/types/__tests__/index.test.ts +51 -51
- package/src/types/index.ts +43 -39
- package/src/types/integration-tests.d.ts +26 -26
- package/src/types/reconciliation.ts +29 -29
- package/src/types/toolAnnotations.ts +30 -30
- package/src/types/toolRegistration.ts +43 -32
- package/src/utils/CLAUDE.md +508 -0
- package/src/utils/__tests__/dateUtils.test.ts +174 -168
- package/src/utils/__tests__/money.test.ts +193 -187
- package/src/utils/amountUtils.ts +5 -5
- package/src/utils/baseError.ts +5 -5
- package/src/utils/dateUtils.ts +29 -26
- package/src/utils/errors.ts +14 -14
- package/src/utils/money.ts +66 -52
- package/src/utils/validationError.ts +1 -1
- package/tsconfig.json +29 -29
- package/tsconfig.prod.json +16 -16
- package/vitest-reporters/split-json-reporter.ts +247 -204
- package/vitest.config.ts +99 -95
- package/.prettierignore +0 -10
- package/.prettierrc.json +0 -10
- package/eslint.config.js +0 -49
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { CACHE_TTLS, CacheManager, cacheManager, } from "../server/cacheManager.js";
|
|
2
|
+
import { responseFormatter } from "../server/responseFormatter.js";
|
|
3
|
+
import { withToolErrorHandling } from "../types/index.js";
|
|
4
|
+
import { milliunitsToAmount } from "../utils/amountUtils.js";
|
|
5
|
+
import { createAdapters, createBudgetResolver } from "./adapters.js";
|
|
6
|
+
import { resolveDeltaFetcherArgs } from "./deltaSupport.js";
|
|
7
|
+
import { ExportTransactionsSchema, handleExportTransactions, } from "./exportTransactions.js";
|
|
8
|
+
import { ToolAnnotationPresets } from "./toolCategories.js";
|
|
9
|
+
import { GetTransactionSchema, ListTransactionsSchema, } from "./transactionSchemas.js";
|
|
10
|
+
import { ensureTransaction, handleTransactionError, } from "./transactionUtils.js";
|
|
11
|
+
export async function handleListTransactions(ynabAPI, deltaFetcherOrParams, maybeParams, errorHandler) {
|
|
12
|
+
const { deltaFetcher, params } = resolveDeltaFetcherArgs(ynabAPI, deltaFetcherOrParams, maybeParams);
|
|
13
|
+
return await withToolErrorHandling(async () => {
|
|
14
|
+
let transactions;
|
|
15
|
+
let cacheHit = false;
|
|
16
|
+
let usedDelta = false;
|
|
17
|
+
if (params.account_id) {
|
|
18
|
+
const accountsResult = await deltaFetcher.fetchAccounts(params.budget_id);
|
|
19
|
+
const accountExists = accountsResult.data.some((account) => account.id === params.account_id);
|
|
20
|
+
if (!accountExists) {
|
|
21
|
+
throw new Error(`Account ${params.account_id} not found in budget ${params.budget_id}`);
|
|
22
|
+
}
|
|
23
|
+
const result = await deltaFetcher.fetchTransactionsByAccount(params.budget_id, params.account_id, params.since_date);
|
|
24
|
+
transactions = result.data;
|
|
25
|
+
cacheHit = result.wasCached;
|
|
26
|
+
usedDelta = result.usedDelta;
|
|
27
|
+
}
|
|
28
|
+
else if (params.category_id) {
|
|
29
|
+
const response = await ynabAPI.transactions.getTransactionsByCategory(params.budget_id, params.category_id, params.since_date);
|
|
30
|
+
transactions = response.data.transactions;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const result = await deltaFetcher.fetchTransactions(params.budget_id, params.since_date, params.type);
|
|
34
|
+
transactions = result.data;
|
|
35
|
+
cacheHit = result.wasCached;
|
|
36
|
+
usedDelta = result.usedDelta;
|
|
37
|
+
}
|
|
38
|
+
const estimatedSize = JSON.stringify(transactions).length;
|
|
39
|
+
const sizeLimit = 90000;
|
|
40
|
+
if (estimatedSize > sizeLimit) {
|
|
41
|
+
const preview = transactions.slice(0, 50);
|
|
42
|
+
return {
|
|
43
|
+
content: [
|
|
44
|
+
{
|
|
45
|
+
type: "text",
|
|
46
|
+
text: responseFormatter.format({
|
|
47
|
+
message: `Found ${transactions.length} transactions (${Math.round(estimatedSize / 1024)}KB). Too large to display all.`,
|
|
48
|
+
suggestion: "Use 'export_transactions' tool to save all transactions to a file.",
|
|
49
|
+
showing: `First ${preview.length} transactions:`,
|
|
50
|
+
total_count: transactions.length,
|
|
51
|
+
estimated_size_kb: Math.round(estimatedSize / 1024),
|
|
52
|
+
cached: cacheHit,
|
|
53
|
+
cache_info: cacheHit
|
|
54
|
+
? `Data retrieved from cache for improved performance${usedDelta ? " (delta merge applied)" : ""}`
|
|
55
|
+
: "Fresh data retrieved from YNAB API",
|
|
56
|
+
preview_transactions: preview.map((transaction) => ({
|
|
57
|
+
id: transaction.id,
|
|
58
|
+
date: transaction.date,
|
|
59
|
+
amount: milliunitsToAmount(transaction.amount),
|
|
60
|
+
memo: transaction.memo,
|
|
61
|
+
payee_name: transaction.payee_name,
|
|
62
|
+
category_name: transaction.category_name,
|
|
63
|
+
})),
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: "text",
|
|
73
|
+
text: responseFormatter.format({
|
|
74
|
+
total_count: transactions.length,
|
|
75
|
+
cached: cacheHit,
|
|
76
|
+
cache_info: cacheHit
|
|
77
|
+
? `Data retrieved from cache for improved performance${usedDelta ? " (delta merge applied)" : ""}`
|
|
78
|
+
: "Fresh data retrieved from YNAB API",
|
|
79
|
+
transactions: transactions.map((transaction) => ({
|
|
80
|
+
id: transaction.id,
|
|
81
|
+
date: transaction.date,
|
|
82
|
+
amount: milliunitsToAmount(transaction.amount),
|
|
83
|
+
memo: transaction.memo,
|
|
84
|
+
cleared: transaction.cleared,
|
|
85
|
+
approved: transaction.approved,
|
|
86
|
+
flag_color: transaction.flag_color,
|
|
87
|
+
account_id: transaction.account_id,
|
|
88
|
+
payee_id: transaction.payee_id,
|
|
89
|
+
category_id: transaction.category_id,
|
|
90
|
+
transfer_account_id: transaction.transfer_account_id,
|
|
91
|
+
transfer_transaction_id: transaction.transfer_transaction_id,
|
|
92
|
+
matched_transaction_id: transaction.matched_transaction_id,
|
|
93
|
+
import_id: transaction.import_id,
|
|
94
|
+
deleted: transaction.deleted,
|
|
95
|
+
})),
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
}, "ynab:list_transactions", "listing transactions", errorHandler);
|
|
101
|
+
}
|
|
102
|
+
export async function handleGetTransaction(ynabAPI, params, _errorHandler) {
|
|
103
|
+
try {
|
|
104
|
+
const useCache = process.env["NODE_ENV"] !== "test";
|
|
105
|
+
let transaction;
|
|
106
|
+
let cacheHit = false;
|
|
107
|
+
if (useCache) {
|
|
108
|
+
const cacheKey = CacheManager.generateKey("transaction", "get", params.budget_id, params.transaction_id);
|
|
109
|
+
cacheHit = cacheManager.has(cacheKey);
|
|
110
|
+
transaction = await cacheManager.wrap(cacheKey, {
|
|
111
|
+
ttl: CACHE_TTLS.TRANSACTIONS,
|
|
112
|
+
loader: async () => {
|
|
113
|
+
const response = await ynabAPI.transactions.getTransactionById(params.budget_id, params.transaction_id);
|
|
114
|
+
return ensureTransaction(response.data.transaction, "Transaction not found");
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const response = await ynabAPI.transactions.getTransactionById(params.budget_id, params.transaction_id);
|
|
120
|
+
transaction = ensureTransaction(response.data.transaction, "Transaction not found");
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: "text",
|
|
126
|
+
text: responseFormatter.format({
|
|
127
|
+
transaction: {
|
|
128
|
+
id: transaction.id,
|
|
129
|
+
date: transaction.date,
|
|
130
|
+
amount: milliunitsToAmount(transaction.amount),
|
|
131
|
+
memo: transaction.memo,
|
|
132
|
+
cleared: transaction.cleared,
|
|
133
|
+
approved: transaction.approved,
|
|
134
|
+
flag_color: transaction.flag_color,
|
|
135
|
+
account_id: transaction.account_id,
|
|
136
|
+
payee_id: transaction.payee_id,
|
|
137
|
+
category_id: transaction.category_id,
|
|
138
|
+
transfer_account_id: transaction.transfer_account_id,
|
|
139
|
+
transfer_transaction_id: transaction.transfer_transaction_id,
|
|
140
|
+
matched_transaction_id: transaction.matched_transaction_id,
|
|
141
|
+
import_id: transaction.import_id,
|
|
142
|
+
deleted: transaction.deleted,
|
|
143
|
+
account_name: transaction.account_name,
|
|
144
|
+
payee_name: transaction.payee_name,
|
|
145
|
+
category_name: transaction.category_name,
|
|
146
|
+
},
|
|
147
|
+
cached: cacheHit,
|
|
148
|
+
cache_info: cacheHit
|
|
149
|
+
? "Data retrieved from cache for improved performance"
|
|
150
|
+
: "Fresh data retrieved from YNAB API",
|
|
151
|
+
}),
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
return handleTransactionError(error, "Failed to get transaction");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export function registerTransactionReadTools(registry, context) {
|
|
161
|
+
const { adapt, adaptWithDelta } = createAdapters(context);
|
|
162
|
+
const budgetResolver = createBudgetResolver(context);
|
|
163
|
+
registry.register({
|
|
164
|
+
name: "list_transactions",
|
|
165
|
+
description: "List transactions for a budget with optional filtering",
|
|
166
|
+
inputSchema: ListTransactionsSchema,
|
|
167
|
+
handler: adaptWithDelta(handleListTransactions),
|
|
168
|
+
defaultArgumentResolver: budgetResolver(),
|
|
169
|
+
metadata: {
|
|
170
|
+
annotations: {
|
|
171
|
+
...ToolAnnotationPresets.READ_ONLY_EXTERNAL,
|
|
172
|
+
title: "YNAB: List Transactions",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
registry.register({
|
|
177
|
+
name: "export_transactions",
|
|
178
|
+
description: "Export all transactions to a JSON file with descriptive filename",
|
|
179
|
+
inputSchema: ExportTransactionsSchema,
|
|
180
|
+
handler: adapt(handleExportTransactions),
|
|
181
|
+
defaultArgumentResolver: budgetResolver(),
|
|
182
|
+
metadata: {
|
|
183
|
+
annotations: {
|
|
184
|
+
...ToolAnnotationPresets.READ_ONLY_EXTERNAL,
|
|
185
|
+
title: "YNAB: Export Transactions",
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
registry.register({
|
|
190
|
+
name: "get_transaction",
|
|
191
|
+
description: "Get detailed information for a specific transaction",
|
|
192
|
+
inputSchema: GetTransactionSchema,
|
|
193
|
+
handler: adapt(handleGetTransaction),
|
|
194
|
+
defaultArgumentResolver: budgetResolver(),
|
|
195
|
+
metadata: {
|
|
196
|
+
annotations: {
|
|
197
|
+
...ToolAnnotationPresets.READ_ONLY_EXTERNAL,
|
|
198
|
+
title: "YNAB: Get Transaction Details",
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type * as ynab from "ynab";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
3
|
export declare const ListTransactionsSchema: z.ZodObject<{
|
|
4
4
|
budget_id: z.ZodString;
|
|
5
5
|
account_id: z.ZodOptional<z.ZodString>;
|
|
@@ -57,7 +57,7 @@ export interface SubtransactionInput {
|
|
|
57
57
|
category_id?: string;
|
|
58
58
|
memo?: string;
|
|
59
59
|
}
|
|
60
|
-
export type BulkTransactionInput = Omit<CreateTransactionParams,
|
|
60
|
+
export type BulkTransactionInput = Omit<CreateTransactionParams, "budget_id" | "dry_run" | "subtransactions">;
|
|
61
61
|
export declare const CreateTransactionsSchema: z.ZodObject<{
|
|
62
62
|
budget_id: z.ZodString;
|
|
63
63
|
transactions: z.ZodArray<z.ZodObject<{
|
|
@@ -89,7 +89,7 @@ export declare const CreateTransactionsSchema: z.ZodObject<{
|
|
|
89
89
|
export type CreateTransactionsParams = z.infer<typeof CreateTransactionsSchema>;
|
|
90
90
|
export interface BulkTransactionResult {
|
|
91
91
|
request_index: number;
|
|
92
|
-
status:
|
|
92
|
+
status: "created" | "duplicate" | "failed";
|
|
93
93
|
transaction_id?: string | undefined;
|
|
94
94
|
correlation_key: string;
|
|
95
95
|
error_code?: string | undefined;
|
|
@@ -108,7 +108,7 @@ export interface BulkCreateResponse {
|
|
|
108
108
|
transactions?: ynab.TransactionDetail[];
|
|
109
109
|
duplicate_import_ids?: string[];
|
|
110
110
|
message?: string;
|
|
111
|
-
mode?:
|
|
111
|
+
mode?: "full" | "summary" | "ids_only";
|
|
112
112
|
}
|
|
113
113
|
export declare const CreateReceiptSplitTransactionSchema: z.ZodObject<{
|
|
114
114
|
budget_id: z.ZodString;
|
|
@@ -243,7 +243,7 @@ export declare const UpdateTransactionsSchema: z.ZodObject<{
|
|
|
243
243
|
export type UpdateTransactionsParams = z.infer<typeof UpdateTransactionsSchema>;
|
|
244
244
|
export interface BulkUpdateResult {
|
|
245
245
|
request_index: number;
|
|
246
|
-
status:
|
|
246
|
+
status: "updated" | "failed";
|
|
247
247
|
transaction_id: string;
|
|
248
248
|
correlation_key: string;
|
|
249
249
|
error_code?: string;
|
|
@@ -260,7 +260,7 @@ export interface BulkUpdateResponse {
|
|
|
260
260
|
results: BulkUpdateResult[];
|
|
261
261
|
transactions?: ynab.TransactionDetail[];
|
|
262
262
|
message?: string;
|
|
263
|
-
mode?:
|
|
263
|
+
mode?: "full" | "summary" | "ids_only";
|
|
264
264
|
}
|
|
265
265
|
export declare const DeleteTransactionSchema: z.ZodObject<{
|
|
266
266
|
budget_id: z.ZodString;
|
|
@@ -1,48 +1,54 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
2
|
export const ListTransactionsSchema = z
|
|
3
3
|
.object({
|
|
4
|
-
budget_id: z.string().min(1,
|
|
4
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
5
5
|
account_id: z.string().optional(),
|
|
6
6
|
category_id: z.string().optional(),
|
|
7
7
|
since_date: z
|
|
8
8
|
.string()
|
|
9
|
-
.regex(/^\d{4}-\d{2}-\d{2}$/,
|
|
9
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in ISO format (YYYY-MM-DD)")
|
|
10
10
|
.optional(),
|
|
11
|
-
type: z.enum([
|
|
11
|
+
type: z.enum(["uncategorized", "unapproved"]).optional(),
|
|
12
12
|
})
|
|
13
13
|
.strict();
|
|
14
14
|
export const GetTransactionSchema = z
|
|
15
15
|
.object({
|
|
16
|
-
budget_id: z.string().min(1,
|
|
17
|
-
transaction_id: z.string().min(1,
|
|
16
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
17
|
+
transaction_id: z.string().min(1, "Transaction ID is required"),
|
|
18
18
|
})
|
|
19
19
|
.strict();
|
|
20
20
|
export const CreateTransactionSchema = z
|
|
21
21
|
.object({
|
|
22
|
-
budget_id: z.string().min(1,
|
|
23
|
-
account_id: z.string().min(1,
|
|
24
|
-
amount: z.number().int(
|
|
25
|
-
date: z
|
|
22
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
23
|
+
account_id: z.string().min(1, "Account ID is required"),
|
|
24
|
+
amount: z.number().int("Amount must be an integer in milliunits"),
|
|
25
|
+
date: z
|
|
26
|
+
.string()
|
|
27
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in ISO format (YYYY-MM-DD)"),
|
|
26
28
|
payee_name: z.string().optional(),
|
|
27
29
|
payee_id: z.string().optional(),
|
|
28
30
|
category_id: z.string().optional(),
|
|
29
31
|
memo: z.string().optional(),
|
|
30
|
-
cleared: z.enum([
|
|
32
|
+
cleared: z.enum(["cleared", "uncleared", "reconciled"]).optional(),
|
|
31
33
|
approved: z.boolean().optional(),
|
|
32
|
-
flag_color: z
|
|
33
|
-
|
|
34
|
+
flag_color: z
|
|
35
|
+
.enum(["red", "orange", "yellow", "green", "blue", "purple"])
|
|
36
|
+
.optional(),
|
|
37
|
+
import_id: z.string().min(1, "Import ID cannot be empty").optional(),
|
|
34
38
|
dry_run: z.boolean().optional(),
|
|
35
39
|
subtransactions: z
|
|
36
40
|
.array(z
|
|
37
41
|
.object({
|
|
38
|
-
amount: z
|
|
42
|
+
amount: z
|
|
43
|
+
.number()
|
|
44
|
+
.int("Subtransaction amount must be an integer in milliunits"),
|
|
39
45
|
payee_name: z.string().optional(),
|
|
40
46
|
payee_id: z.string().optional(),
|
|
41
47
|
category_id: z.string().optional(),
|
|
42
48
|
memo: z.string().optional(),
|
|
43
49
|
})
|
|
44
50
|
.strict())
|
|
45
|
-
.min(1,
|
|
51
|
+
.min(1, "At least one subtransaction is required when provided")
|
|
46
52
|
.optional(),
|
|
47
53
|
})
|
|
48
54
|
.strict()
|
|
@@ -52,8 +58,8 @@ export const CreateTransactionSchema = z
|
|
|
52
58
|
if (total !== data.amount) {
|
|
53
59
|
ctx.addIssue({
|
|
54
60
|
code: z.ZodIssueCode.custom,
|
|
55
|
-
message:
|
|
56
|
-
path: [
|
|
61
|
+
message: "Amount must equal the sum of subtransaction amounts",
|
|
62
|
+
path: ["amount"],
|
|
57
63
|
});
|
|
58
64
|
}
|
|
59
65
|
}
|
|
@@ -74,59 +80,63 @@ const BulkTransactionInputSchemaBase = CreateTransactionSchema.pick({
|
|
|
74
80
|
const BulkTransactionInputSchema = BulkTransactionInputSchemaBase.strict();
|
|
75
81
|
export const CreateTransactionsSchema = z
|
|
76
82
|
.object({
|
|
77
|
-
budget_id: z.string().min(1,
|
|
83
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
78
84
|
transactions: z
|
|
79
85
|
.array(BulkTransactionInputSchema)
|
|
80
|
-
.min(1,
|
|
81
|
-
.max(100,
|
|
86
|
+
.min(1, "At least one transaction is required")
|
|
87
|
+
.max(100, "A maximum of 100 transactions may be created at once"),
|
|
82
88
|
dry_run: z.boolean().optional(),
|
|
83
89
|
})
|
|
84
90
|
.strict();
|
|
85
91
|
const ReceiptSplitItemSchema = z
|
|
86
92
|
.object({
|
|
87
|
-
name: z.string().min(1,
|
|
88
|
-
amount: z.number().finite(
|
|
93
|
+
name: z.string().min(1, "Item name is required"),
|
|
94
|
+
amount: z.number().finite("Item amount must be a finite number"),
|
|
89
95
|
quantity: z
|
|
90
96
|
.number()
|
|
91
|
-
.finite(
|
|
92
|
-
.positive(
|
|
97
|
+
.finite("Quantity must be a finite number")
|
|
98
|
+
.positive("Quantity must be greater than zero")
|
|
93
99
|
.optional(),
|
|
94
100
|
memo: z.string().optional(),
|
|
95
101
|
})
|
|
96
102
|
.strict();
|
|
97
103
|
const ReceiptSplitCategorySchema = z
|
|
98
104
|
.object({
|
|
99
|
-
category_id: z.string().min(1,
|
|
105
|
+
category_id: z.string().min(1, "Category ID is required"),
|
|
100
106
|
category_name: z.string().optional(),
|
|
101
|
-
items: z
|
|
107
|
+
items: z
|
|
108
|
+
.array(ReceiptSplitItemSchema)
|
|
109
|
+
.min(1, "Each category must include at least one item"),
|
|
102
110
|
})
|
|
103
111
|
.strict();
|
|
104
112
|
export const CreateReceiptSplitTransactionSchema = z
|
|
105
113
|
.object({
|
|
106
|
-
budget_id: z.string().min(1,
|
|
107
|
-
account_id: z.string().min(1,
|
|
108
|
-
payee_name: z.string().min(1,
|
|
114
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
115
|
+
account_id: z.string().min(1, "Account ID is required"),
|
|
116
|
+
payee_name: z.string().min(1, "Payee name is required"),
|
|
109
117
|
date: z
|
|
110
118
|
.string()
|
|
111
|
-
.regex(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/,
|
|
119
|
+
.regex(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/, "Date must be in ISO format (YYYY-MM-DD)")
|
|
112
120
|
.optional(),
|
|
113
121
|
memo: z.string().optional(),
|
|
114
122
|
receipt_subtotal: z
|
|
115
123
|
.number()
|
|
116
|
-
.finite(
|
|
117
|
-
.refine((value) => value >= 0,
|
|
124
|
+
.finite("Receipt subtotal must be a finite number")
|
|
125
|
+
.refine((value) => value >= 0, "Receipt subtotal must be zero or greater")
|
|
118
126
|
.optional(),
|
|
119
|
-
receipt_tax: z.number().finite(
|
|
127
|
+
receipt_tax: z.number().finite("Receipt tax must be a finite number"),
|
|
120
128
|
receipt_total: z
|
|
121
129
|
.number()
|
|
122
|
-
.finite(
|
|
123
|
-
.refine((value) => value > 0,
|
|
130
|
+
.finite("Receipt total must be a finite number")
|
|
131
|
+
.refine((value) => value > 0, "Receipt total must be greater than zero"),
|
|
124
132
|
categories: z
|
|
125
133
|
.array(ReceiptSplitCategorySchema)
|
|
126
|
-
.min(1,
|
|
127
|
-
cleared: z.enum([
|
|
134
|
+
.min(1, "At least one categorized group is required to create a split transaction"),
|
|
135
|
+
cleared: z.enum(["cleared", "uncleared", "reconciled"]).optional(),
|
|
128
136
|
approved: z.boolean().optional(),
|
|
129
|
-
flag_color: z
|
|
137
|
+
flag_color: z
|
|
138
|
+
.enum(["red", "orange", "yellow", "green", "blue", "purple"])
|
|
139
|
+
.optional(),
|
|
130
140
|
dry_run: z.boolean().optional(),
|
|
131
141
|
})
|
|
132
142
|
.strict()
|
|
@@ -140,7 +150,7 @@ export const CreateReceiptSplitTransactionSchema = z
|
|
|
140
150
|
ctx.addIssue({
|
|
141
151
|
code: z.ZodIssueCode.custom,
|
|
142
152
|
message: `Receipt subtotal (${data.receipt_subtotal.toFixed(2)}) does not match categorized items total (${itemsSubtotal.toFixed(2)})`,
|
|
143
|
-
path: [
|
|
153
|
+
path: ["receipt_subtotal"],
|
|
144
154
|
});
|
|
145
155
|
}
|
|
146
156
|
}
|
|
@@ -150,66 +160,76 @@ export const CreateReceiptSplitTransactionSchema = z
|
|
|
150
160
|
ctx.addIssue({
|
|
151
161
|
code: z.ZodIssueCode.custom,
|
|
152
162
|
message: `Receipt total (${data.receipt_total.toFixed(2)}) does not match subtotal plus tax (${expectedTotal.toFixed(2)})`,
|
|
153
|
-
path: [
|
|
163
|
+
path: ["receipt_total"],
|
|
154
164
|
});
|
|
155
165
|
}
|
|
156
166
|
});
|
|
157
167
|
export const UpdateTransactionSchema = z
|
|
158
168
|
.object({
|
|
159
|
-
budget_id: z.string().min(1,
|
|
160
|
-
transaction_id: z.string().min(1,
|
|
169
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
170
|
+
transaction_id: z.string().min(1, "Transaction ID is required"),
|
|
161
171
|
account_id: z.string().optional(),
|
|
162
|
-
amount: z
|
|
172
|
+
amount: z
|
|
173
|
+
.number()
|
|
174
|
+
.int("Amount must be an integer in milliunits")
|
|
175
|
+
.optional(),
|
|
163
176
|
date: z
|
|
164
177
|
.string()
|
|
165
|
-
.regex(/^\d{4}-\d{2}-\d{2}$/,
|
|
178
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in ISO format (YYYY-MM-DD)")
|
|
166
179
|
.optional(),
|
|
167
180
|
payee_name: z.string().optional(),
|
|
168
181
|
payee_id: z.string().optional(),
|
|
169
182
|
category_id: z.string().optional(),
|
|
170
183
|
memo: z.string().optional(),
|
|
171
|
-
cleared: z.enum([
|
|
184
|
+
cleared: z.enum(["cleared", "uncleared", "reconciled"]).optional(),
|
|
172
185
|
approved: z.boolean().optional(),
|
|
173
|
-
flag_color: z
|
|
186
|
+
flag_color: z
|
|
187
|
+
.enum(["red", "orange", "yellow", "green", "blue", "purple"])
|
|
188
|
+
.optional(),
|
|
174
189
|
dry_run: z.boolean().optional(),
|
|
175
190
|
})
|
|
176
191
|
.strict();
|
|
177
192
|
const BulkUpdateTransactionInputSchema = z
|
|
178
193
|
.object({
|
|
179
|
-
id: z.string().min(1,
|
|
180
|
-
amount: z
|
|
194
|
+
id: z.string().min(1, "Transaction ID is required"),
|
|
195
|
+
amount: z
|
|
196
|
+
.number()
|
|
197
|
+
.int("Amount must be an integer in milliunits")
|
|
198
|
+
.optional(),
|
|
181
199
|
date: z
|
|
182
200
|
.string()
|
|
183
|
-
.regex(/^\d{4}-\d{2}-\d{2}$/,
|
|
201
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in ISO format (YYYY-MM-DD)")
|
|
184
202
|
.optional(),
|
|
185
203
|
payee_name: z.string().optional(),
|
|
186
204
|
payee_id: z.string().optional(),
|
|
187
205
|
category_id: z.string().optional(),
|
|
188
206
|
memo: z.string().optional(),
|
|
189
|
-
cleared: z.enum([
|
|
207
|
+
cleared: z.enum(["cleared", "uncleared", "reconciled"]).optional(),
|
|
190
208
|
approved: z.boolean().optional(),
|
|
191
|
-
flag_color: z
|
|
209
|
+
flag_color: z
|
|
210
|
+
.enum(["red", "orange", "yellow", "green", "blue", "purple"])
|
|
211
|
+
.optional(),
|
|
192
212
|
original_account_id: z.string().optional(),
|
|
193
213
|
original_date: z
|
|
194
214
|
.string()
|
|
195
|
-
.regex(/^\d{4}-\d{2}-\d{2}$/,
|
|
215
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in ISO format (YYYY-MM-DD)")
|
|
196
216
|
.optional(),
|
|
197
217
|
})
|
|
198
218
|
.strict();
|
|
199
219
|
export const UpdateTransactionsSchema = z
|
|
200
220
|
.object({
|
|
201
|
-
budget_id: z.string().min(1,
|
|
221
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
202
222
|
transactions: z
|
|
203
223
|
.array(BulkUpdateTransactionInputSchema)
|
|
204
|
-
.min(1,
|
|
205
|
-
.max(100,
|
|
224
|
+
.min(1, "At least one transaction is required")
|
|
225
|
+
.max(100, "A maximum of 100 transactions may be updated at once"),
|
|
206
226
|
dry_run: z.boolean().optional(),
|
|
207
227
|
})
|
|
208
228
|
.strict();
|
|
209
229
|
export const DeleteTransactionSchema = z
|
|
210
230
|
.object({
|
|
211
|
-
budget_id: z.string().min(1,
|
|
212
|
-
transaction_id: z.string().min(1,
|
|
231
|
+
budget_id: z.string().min(1, "Budget ID is required"),
|
|
232
|
+
transaction_id: z.string().min(1, "Transaction ID is required"),
|
|
213
233
|
dry_run: z.boolean().optional(),
|
|
214
234
|
})
|
|
215
235
|
.strict();
|
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { DeltaFetcher } from './deltaFetcher.js';
|
|
5
|
-
import type { DeltaCache } from '../server/deltaCache.js';
|
|
6
|
-
import type { ServerKnowledgeStore } from '../server/serverKnowledgeStore.js';
|
|
7
|
-
import { ListTransactionsParams, GetTransactionParams, CreateTransactionParams, CreateTransactionsParams, CreateReceiptSplitTransactionParams, UpdateTransactionParams, UpdateTransactionsParams, DeleteTransactionParams } from './transactionSchemas.js';
|
|
8
|
-
export declare function handleListTransactions(ynabAPI: ynab.API, deltaFetcher: DeltaFetcher, params: ListTransactionsParams): Promise<CallToolResult>;
|
|
9
|
-
export declare function handleListTransactions(ynabAPI: ynab.API, params: ListTransactionsParams): Promise<CallToolResult>;
|
|
10
|
-
export declare function handleGetTransaction(ynabAPI: ynab.API, params: GetTransactionParams): Promise<CallToolResult>;
|
|
11
|
-
export declare function handleCreateTransaction(ynabAPI: ynab.API, deltaCache: DeltaCache, knowledgeStore: ServerKnowledgeStore, params: CreateTransactionParams): Promise<CallToolResult>;
|
|
12
|
-
export declare function handleCreateTransaction(ynabAPI: ynab.API, params: CreateTransactionParams): Promise<CallToolResult>;
|
|
13
|
-
export declare function handleCreateReceiptSplitTransaction(ynabAPI: ynab.API, deltaCache: DeltaCache, knowledgeStore: ServerKnowledgeStore, params: CreateReceiptSplitTransactionParams): Promise<CallToolResult>;
|
|
14
|
-
export declare function handleCreateReceiptSplitTransaction(ynabAPI: ynab.API, params: CreateReceiptSplitTransactionParams): Promise<CallToolResult>;
|
|
15
|
-
export declare function handleUpdateTransaction(ynabAPI: ynab.API, deltaCache: DeltaCache, knowledgeStore: ServerKnowledgeStore, params: UpdateTransactionParams): Promise<CallToolResult>;
|
|
16
|
-
export declare function handleUpdateTransaction(ynabAPI: ynab.API, params: UpdateTransactionParams): Promise<CallToolResult>;
|
|
17
|
-
export declare function handleDeleteTransaction(ynabAPI: ynab.API, deltaCache: DeltaCache, knowledgeStore: ServerKnowledgeStore, params: DeleteTransactionParams): Promise<CallToolResult>;
|
|
18
|
-
export declare function handleDeleteTransaction(ynabAPI: ynab.API, params: DeleteTransactionParams): Promise<CallToolResult>;
|
|
19
|
-
export declare function handleCreateTransactions(ynabAPI: ynab.API, deltaCache: DeltaCache, knowledgeStore: ServerKnowledgeStore, params: CreateTransactionsParams): Promise<CallToolResult>;
|
|
20
|
-
export declare function handleCreateTransactions(ynabAPI: ynab.API, params: CreateTransactionsParams): Promise<CallToolResult>;
|
|
21
|
-
export declare function handleUpdateTransactions(ynabAPI: ynab.API, deltaCache: DeltaCache, knowledgeStore: ServerKnowledgeStore, params: UpdateTransactionsParams): Promise<CallToolResult>;
|
|
22
|
-
export declare function handleUpdateTransactions(ynabAPI: ynab.API, params: UpdateTransactionsParams): Promise<CallToolResult>;
|
|
1
|
+
import type { ToolFactory } from "../types/toolRegistration.js";
|
|
2
|
+
import { handleGetTransaction, handleListTransactions } from "./transactionReadTools.js";
|
|
3
|
+
import { handleCreateReceiptSplitTransaction, handleCreateTransaction, handleCreateTransactions, handleDeleteTransaction, handleUpdateTransaction, handleUpdateTransactions } from "./transactionWriteTools.js";
|
|
23
4
|
export declare const registerTransactionTools: ToolFactory;
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
5
|
+
export { handleListTransactions, handleGetTransaction, handleCreateTransaction, handleCreateReceiptSplitTransaction, handleUpdateTransaction, handleDeleteTransaction, handleCreateTransactions, handleUpdateTransactions, };
|
|
6
|
+
export { ListTransactionsSchema, type ListTransactionsParams, GetTransactionSchema, type GetTransactionParams, CreateTransactionSchema, type CreateTransactionParams, CreateTransactionsSchema, type CreateTransactionsParams, CreateReceiptSplitTransactionSchema, type CreateReceiptSplitTransactionParams, UpdateTransactionSchema, type UpdateTransactionParams, UpdateTransactionsSchema, type UpdateTransactionsParams, type BulkUpdateTransactionInput, DeleteTransactionSchema, type DeleteTransactionParams, type BulkTransactionResult, type BulkCreateResponse, type BulkUpdateResult, type BulkUpdateResponse, type CorrelationPayload, type CorrelationPayloadInput, type CategorySource, type TransactionCacheInvalidationOptions, type ReceiptCategoryCalculation, type SubtransactionInput, type BulkTransactionInput, } from "./transactionSchemas.js";
|
|
7
|
+
export { generateCorrelationKey, toCorrelationPayload, correlateResults, estimatePayloadSize, finalizeResponse, finalizeBulkUpdateResponse, handleTransactionError, toMonthKey, ensureTransaction, appendCategoryIds, collectCategoryIdsFromSources, setsEqual, invalidateTransactionCaches, } from "./transactionUtils.js";
|