@opentabs-dev/opentabs-plugin-ynab 0.0.85 → 0.0.87
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/dist/adapter.iife.js +1315 -545
- package/dist/adapter.iife.js.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -16
- package/dist/index.js.map +1 -1
- package/dist/tools/create-category-group.d.ts +11 -0
- package/dist/tools/create-category-group.d.ts.map +1 -0
- package/dist/tools/create-category-group.js +37 -0
- package/dist/tools/create-category-group.js.map +1 -0
- package/dist/tools/create-category.d.ts +59 -0
- package/dist/tools/create-category.d.ts.map +1 -0
- package/dist/tools/create-category.js +63 -0
- package/dist/tools/create-category.js.map +1 -0
- package/dist/tools/create-transaction.d.ts +2 -2
- package/dist/tools/create-transaction.d.ts.map +1 -1
- package/dist/tools/create-transaction.js +63 -22
- package/dist/tools/create-transaction.js.map +1 -1
- package/dist/tools/delete-category-group.d.ts +8 -0
- package/dist/tools/delete-category-group.d.ts.map +1 -0
- package/dist/tools/delete-category-group.js +33 -0
- package/dist/tools/delete-category-group.js.map +1 -0
- package/dist/tools/delete-category.d.ts +7 -0
- package/dist/tools/delete-category.d.ts.map +1 -0
- package/dist/tools/delete-category.js +28 -0
- package/dist/tools/delete-category.js.map +1 -0
- package/dist/tools/delete-transaction.d.ts.map +1 -1
- package/dist/tools/delete-transaction.js +22 -7
- package/dist/tools/delete-transaction.js.map +1 -1
- package/dist/tools/get-account.d.ts.map +1 -1
- package/dist/tools/get-account.js +3 -3
- package/dist/tools/get-account.js.map +1 -1
- package/dist/tools/get-month.d.ts +2 -1
- package/dist/tools/get-month.d.ts.map +1 -1
- package/dist/tools/get-month.js +10 -33
- package/dist/tools/get-month.js.map +1 -1
- package/dist/tools/get-plan.d.ts.map +1 -1
- package/dist/tools/get-plan.js +12 -5
- package/dist/tools/get-plan.js.map +1 -1
- package/dist/tools/get-transaction.d.ts +2 -2
- package/dist/tools/get-transaction.d.ts.map +1 -1
- package/dist/tools/get-transaction.js +5 -4
- package/dist/tools/get-transaction.js.map +1 -1
- package/dist/tools/list-accounts.d.ts.map +1 -1
- package/dist/tools/list-accounts.js +4 -4
- package/dist/tools/list-accounts.js.map +1 -1
- package/dist/tools/list-categories.d.ts.map +1 -1
- package/dist/tools/list-categories.js +9 -29
- package/dist/tools/list-categories.js.map +1 -1
- package/dist/tools/list-months.d.ts +1 -1
- package/dist/tools/list-months.d.ts.map +1 -1
- package/dist/tools/list-months.js +5 -14
- package/dist/tools/list-months.js.map +1 -1
- package/dist/tools/list-payees.d.ts.map +1 -1
- package/dist/tools/list-payees.js +3 -3
- package/dist/tools/list-payees.js.map +1 -1
- package/dist/tools/list-scheduled-transactions.d.ts.map +1 -1
- package/dist/tools/list-scheduled-transactions.js +7 -5
- package/dist/tools/list-scheduled-transactions.js.map +1 -1
- package/dist/tools/list-transactions.d.ts +4 -2
- package/dist/tools/list-transactions.d.ts.map +1 -1
- package/dist/tools/list-transactions.js +40 -8
- package/dist/tools/list-transactions.js.map +1 -1
- package/dist/tools/move-category-budget.d.ts +24 -0
- package/dist/tools/move-category-budget.d.ts.map +1 -0
- package/dist/tools/move-category-budget.js +100 -0
- package/dist/tools/move-category-budget.js.map +1 -0
- package/dist/tools/schemas.d.ts +185 -28
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +411 -28
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/snooze-category-goal.d.ts +10 -0
- package/dist/tools/snooze-category-goal.d.ts.map +1 -0
- package/dist/tools/snooze-category-goal.js +53 -0
- package/dist/tools/snooze-category-goal.js.map +1 -0
- package/dist/tools/update-category-budget.d.ts.map +1 -1
- package/dist/tools/update-category-budget.js +51 -26
- package/dist/tools/update-category-budget.js.map +1 -1
- package/dist/tools/update-category.d.ts +61 -0
- package/dist/tools/update-category.d.ts.map +1 -0
- package/dist/tools/update-category.js +46 -0
- package/dist/tools/update-category.js.map +1 -0
- package/dist/tools/update-transaction.d.ts +3 -2
- package/dist/tools/update-transaction.d.ts.map +1 -1
- package/dist/tools/update-transaction.js +84 -31
- package/dist/tools/update-transaction.js.map +1 -1
- package/dist/tools.json +965 -43
- package/dist/ynab-api.d.ts +4 -1
- package/dist/ynab-api.d.ts.map +1 -1
- package/dist/ynab-api.js +47 -26
- package/dist/ynab-api.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OpenTabsPlugin } from '@opentabs-dev/plugin-sdk';
|
|
2
1
|
import type { ToolDefinition } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { OpenTabsPlugin } from '@opentabs-dev/plugin-sdk';
|
|
3
3
|
declare class YnabPlugin extends OpenTabsPlugin {
|
|
4
4
|
readonly name = "ynab";
|
|
5
5
|
readonly description = "OpenTabs plugin for YNAB (You Need A Budget)";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAyB1D,cAAM,UAAW,SAAQ,cAAc;IACrC,QAAQ,CAAC,IAAI,UAAU;IACvB,QAAQ,CAAC,WAAW,kDAAkD;IACtE,SAAkB,WAAW,UAAU;IACvC,QAAQ,CAAC,WAAW,WAA0B;IAC9C,SAAkB,QAAQ,0BAA0B;IACpD,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,CA8B9B;IAEI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAIlC;;AAED,wBAAgC"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { OpenTabsPlugin } from '@opentabs-dev/plugin-sdk';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { createCategory } from './tools/create-category.js';
|
|
3
|
+
import { createCategoryGroup } from './tools/create-category-group.js';
|
|
4
|
+
import { createTransaction } from './tools/create-transaction.js';
|
|
5
|
+
import { deleteCategory } from './tools/delete-category.js';
|
|
6
|
+
import { deleteCategoryGroup } from './tools/delete-category-group.js';
|
|
7
|
+
import { deleteTransaction } from './tools/delete-transaction.js';
|
|
8
|
+
import { getAccount } from './tools/get-account.js';
|
|
4
9
|
import { getCurrentUser } from './tools/get-current-user.js';
|
|
5
|
-
|
|
10
|
+
import { getMonth } from './tools/get-month.js';
|
|
6
11
|
import { getPlan } from './tools/get-plan.js';
|
|
7
|
-
|
|
12
|
+
import { getTransaction } from './tools/get-transaction.js';
|
|
8
13
|
import { listAccounts } from './tools/list-accounts.js';
|
|
9
|
-
import { getAccount } from './tools/get-account.js';
|
|
10
|
-
// Categories
|
|
11
14
|
import { listCategories } from './tools/list-categories.js';
|
|
12
|
-
import {
|
|
13
|
-
// Payees
|
|
15
|
+
import { listMonths } from './tools/list-months.js';
|
|
14
16
|
import { listPayees } from './tools/list-payees.js';
|
|
15
|
-
|
|
17
|
+
import { listScheduledTransactions } from './tools/list-scheduled-transactions.js';
|
|
16
18
|
import { listTransactions } from './tools/list-transactions.js';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
+
import { moveCategoryBudget } from './tools/move-category-budget.js';
|
|
20
|
+
import { snoozeCategoryGoal } from './tools/snooze-category-goal.js';
|
|
21
|
+
import { updateCategory } from './tools/update-category.js';
|
|
22
|
+
import { updateCategoryBudget } from './tools/update-category-budget.js';
|
|
19
23
|
import { updateTransaction } from './tools/update-transaction.js';
|
|
20
|
-
import {
|
|
21
|
-
import { listScheduledTransactions } from './tools/list-scheduled-transactions.js';
|
|
22
|
-
// Months
|
|
23
|
-
import { listMonths } from './tools/list-months.js';
|
|
24
|
-
import { getMonth } from './tools/get-month.js';
|
|
24
|
+
import { isAuthenticated, waitForAuth } from './ynab-api.js';
|
|
25
25
|
class YnabPlugin extends OpenTabsPlugin {
|
|
26
26
|
name = 'ynab';
|
|
27
27
|
description = 'OpenTabs plugin for YNAB (You Need A Budget)';
|
|
@@ -38,7 +38,14 @@ class YnabPlugin extends OpenTabsPlugin {
|
|
|
38
38
|
getAccount,
|
|
39
39
|
// Categories
|
|
40
40
|
listCategories,
|
|
41
|
+
createCategory,
|
|
42
|
+
updateCategory,
|
|
43
|
+
deleteCategory,
|
|
44
|
+
createCategoryGroup,
|
|
45
|
+
deleteCategoryGroup,
|
|
41
46
|
updateCategoryBudget,
|
|
47
|
+
moveCategoryBudget,
|
|
48
|
+
snoozeCategoryGoal,
|
|
42
49
|
// Payees
|
|
43
50
|
listPayees,
|
|
44
51
|
// Transactions
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC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;QACT,UAAU;QACV,eAAe;QACf,gBAAgB;QAChB,cAAc;QACd,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,yBAAyB;QACzB,SAAS;QACT,UAAU;QACV,QAAQ;KACT,CAAC;IAEF,KAAK,CAAC,OAAO;QACX,IAAI,eAAe,EAAE;YAAE,OAAO,IAAI,CAAC;QACnC,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;CACF;AAED,eAAe,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const createCategoryGroup: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
5
|
+
group: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
hidden: z.ZodBoolean;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
//# sourceMappingURL=create-category-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-category-group.d.ts","sourceRoot":"","sources":["../../src/tools/create-category-group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,mBAAmB;;;;;;;;kBAmC9B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getPlanId, syncBudget, syncWrite } from '../ynab-api.js';
|
|
4
|
+
import { categoryGroupSchema, mapCategoryGroup, nextTopSortableIndex } from './schemas.js';
|
|
5
|
+
export const createCategoryGroup = defineTool({
|
|
6
|
+
name: 'create_category_group',
|
|
7
|
+
displayName: 'Create Category Group',
|
|
8
|
+
description: 'Create a new category group in the active YNAB plan.',
|
|
9
|
+
summary: 'Create a category group',
|
|
10
|
+
icon: 'folder-plus',
|
|
11
|
+
group: 'Categories',
|
|
12
|
+
input: z.object({
|
|
13
|
+
name: z.string().min(1).describe('Name of the new category group'),
|
|
14
|
+
}),
|
|
15
|
+
output: z.object({
|
|
16
|
+
group: categoryGroupSchema,
|
|
17
|
+
}),
|
|
18
|
+
handle: async (params) => {
|
|
19
|
+
const planId = getPlanId();
|
|
20
|
+
const groupId = crypto.randomUUID();
|
|
21
|
+
const budget = await syncBudget(planId);
|
|
22
|
+
const serverKnowledge = budget.current_server_knowledge ?? 0;
|
|
23
|
+
const groupEntry = {
|
|
24
|
+
id: groupId,
|
|
25
|
+
is_tombstone: false,
|
|
26
|
+
internal_name: '',
|
|
27
|
+
deletable: true,
|
|
28
|
+
sortable_index: nextTopSortableIndex(budget.changed_entities?.be_master_categories ?? []),
|
|
29
|
+
name: params.name,
|
|
30
|
+
note: '',
|
|
31
|
+
is_hidden: false,
|
|
32
|
+
};
|
|
33
|
+
await syncWrite(planId, { be_master_categories: [groupEntry] }, serverKnowledge);
|
|
34
|
+
return { group: mapCategoryGroup(groupEntry) };
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=create-category-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-category-group.js","sourceRoot":"","sources":["../../src/tools/create-category-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE3F,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC5C,IAAI,EAAE,uBAAuB;IAC7B,WAAW,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Definition<z.ZodObject<{
|
|
3
|
+
group_id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
goal: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6
|
+
target: z.ZodNumber;
|
|
7
|
+
cadence: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
weekly: "weekly";
|
|
9
|
+
monthly: "monthly";
|
|
10
|
+
yearly: "yearly";
|
|
11
|
+
}>>;
|
|
12
|
+
every: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
day: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
start_date: z.ZodOptional<z.ZodString>;
|
|
15
|
+
type: z.ZodLiteral<"set_aside">;
|
|
16
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
17
|
+
target: z.ZodNumber;
|
|
18
|
+
cadence: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
weekly: "weekly";
|
|
20
|
+
monthly: "monthly";
|
|
21
|
+
yearly: "yearly";
|
|
22
|
+
}>>;
|
|
23
|
+
every: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
day: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
start_date: z.ZodOptional<z.ZodString>;
|
|
26
|
+
type: z.ZodLiteral<"refill">;
|
|
27
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
28
|
+
type: z.ZodLiteral<"target_balance">;
|
|
29
|
+
target: z.ZodNumber;
|
|
30
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"target_by_date">;
|
|
32
|
+
target: z.ZodNumber;
|
|
33
|
+
date: z.ZodString;
|
|
34
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"debt">;
|
|
36
|
+
target: z.ZodNumber;
|
|
37
|
+
day: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
type: z.ZodLiteral<"none">;
|
|
40
|
+
}, z.core.$strict>], "type">>;
|
|
41
|
+
note: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
category: z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
category_group_id: z.ZodString;
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
hidden: z.ZodBoolean;
|
|
48
|
+
budgeted: z.ZodString;
|
|
49
|
+
activity: z.ZodString;
|
|
50
|
+
balance: z.ZodString;
|
|
51
|
+
budgeted_milliunits: z.ZodNumber;
|
|
52
|
+
activity_milliunits: z.ZodNumber;
|
|
53
|
+
balance_milliunits: z.ZodNumber;
|
|
54
|
+
goal_type: z.ZodString;
|
|
55
|
+
goal_target: z.ZodString;
|
|
56
|
+
goal_percentage_complete: z.ZodNumber;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
//# sourceMappingURL=create-category.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-category.d.ts","sourceRoot":"","sources":["../../src/tools/create-category.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuEzB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getPlanId, syncBudget, syncWrite } from '../ynab-api.js';
|
|
4
|
+
import { assertCategoryGroupDeletable, buildGoalFields, CATEGORY_TYPE_DEFAULT, categorySchema, currentMonthKey, findCategoryGroup, formatMonthlyBudgetId, formatSubcategoryBudgetId, goalSpecSchema, mapCategory, nextTopSortableIndex, } from './schemas.js';
|
|
5
|
+
export const createCategory = defineTool({
|
|
6
|
+
name: 'create_category',
|
|
7
|
+
displayName: 'Create Category',
|
|
8
|
+
description: 'Create a new category in an existing category group. Optionally set an initial goal: "set_aside" (set aside X per cadence), "refill" (refill the balance up to X per cadence), "target_balance" (have a balance of X), or "target_by_date" (have a balance of X by a specific date). NEED-style goals (set_aside, refill) accept weekly/monthly/yearly cadence. Debt goals are not supported for new categories — they only apply to existing debt-account categories.',
|
|
9
|
+
summary: 'Create a new budget category',
|
|
10
|
+
icon: 'plus',
|
|
11
|
+
group: 'Categories',
|
|
12
|
+
input: z.object({
|
|
13
|
+
group_id: z.string().min(1).describe('Category group ID to create the category in'),
|
|
14
|
+
name: z.string().min(1).describe('Name of the new category'),
|
|
15
|
+
goal: goalSpecSchema.optional().describe('Optional initial goal for the category'),
|
|
16
|
+
note: z.string().optional().describe('Optional note for the category'),
|
|
17
|
+
}),
|
|
18
|
+
output: z.object({
|
|
19
|
+
category: categorySchema,
|
|
20
|
+
}),
|
|
21
|
+
handle: async (params) => {
|
|
22
|
+
if (params.goal?.type === 'debt') {
|
|
23
|
+
throw ToolError.validation('Debt goals can only be set on debt-account categories.');
|
|
24
|
+
}
|
|
25
|
+
const planId = getPlanId();
|
|
26
|
+
const categoryId = crypto.randomUUID();
|
|
27
|
+
const budget = await syncBudget(planId);
|
|
28
|
+
const serverKnowledge = budget.current_server_knowledge ?? 0;
|
|
29
|
+
assertCategoryGroupDeletable(findCategoryGroup(budget.changed_entities, params.group_id));
|
|
30
|
+
const childCategories = (budget.changed_entities?.be_subcategories ?? []).filter(c => c.entities_master_category_id === params.group_id);
|
|
31
|
+
const monthKey = currentMonthKey();
|
|
32
|
+
const categoryEntry = {
|
|
33
|
+
id: categoryId,
|
|
34
|
+
is_tombstone: false,
|
|
35
|
+
entities_master_category_id: params.group_id,
|
|
36
|
+
entities_account_id: null,
|
|
37
|
+
internal_name: null,
|
|
38
|
+
sortable_index: nextTopSortableIndex(childCategories, 5),
|
|
39
|
+
name: params.name,
|
|
40
|
+
type: CATEGORY_TYPE_DEFAULT,
|
|
41
|
+
note: params.note ?? null,
|
|
42
|
+
monthly_funding: 0,
|
|
43
|
+
is_hidden: false,
|
|
44
|
+
pinned_index: null,
|
|
45
|
+
pinned_goal_index: null,
|
|
46
|
+
...buildGoalFields(params.goal),
|
|
47
|
+
};
|
|
48
|
+
// YNAB's UI also creates a current-month budget row alongside the category.
|
|
49
|
+
const budgetEntry = {
|
|
50
|
+
id: formatSubcategoryBudgetId(monthKey, categoryId),
|
|
51
|
+
is_tombstone: false,
|
|
52
|
+
entities_monthly_budget_id: formatMonthlyBudgetId(monthKey, planId),
|
|
53
|
+
entities_subcategory_id: categoryId,
|
|
54
|
+
budgeted: 0,
|
|
55
|
+
};
|
|
56
|
+
await syncWrite(planId, {
|
|
57
|
+
be_subcategories: [categoryEntry],
|
|
58
|
+
be_monthly_subcategory_budgets: [budgetEntry],
|
|
59
|
+
}, serverKnowledge);
|
|
60
|
+
return { category: mapCategory(categoryEntry) };
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=create-category.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-category.js","sourceRoot":"","sources":["../../src/tools/create-category.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACd,WAAW,EACX,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACvC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EACT,wcAAwc;IAC1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AA2B,KAAK,MAAM,CAAC,QAAQ,CACvD,CAAC;QACF,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;QACnC,MAAM,aAAa,GAAgB;YACjC,EAAE,EAAE,UAAU;YACd,YAAY,EAAE,KAAK;YACnB,2BAA2B,EAAE,MAAM,CAAC,QAAQ;YAC5C,mBAAmB,EAAE,IAAI;YACzB,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,oBAAoB,CAAC,eAAe,EAAE,CAAC,CAAC;YACxD,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;YACzB,eAAe,EAAE,CAAC;YAClB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,IAAI;YAClB,iBAAiB,EAAE,IAAI;YACvB,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC;SAChC,CAAC;QAEF,4EAA4E;QAC5E,MAAM,WAAW,GAAgC;YAC/C,EAAE,EAAE,yBAAyB,CAAC,QAAQ,EAAE,UAAU,CAAC;YACnD,YAAY,EAAE,KAAK;YACnB,0BAA0B,EAAE,qBAAqB,CAAC,QAAQ,EAAE,MAAM,CAAC;YACnE,uBAAuB,EAAE,UAAU;YACnC,QAAQ,EAAE,CAAC;SACZ,CAAC;QAEF,MAAM,SAAS,CACb,MAAM,EACN;YACE,gBAAgB,EAAE,CAAC,aAAa,CAAC;YACjC,8BAA8B,EAAE,CAAC,WAAW,CAAC;SAC9C,EACD,eAAe,CAChB,CAAC;QAEF,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;IAClD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -31,7 +31,6 @@ export declare const createTransaction: import("@opentabs-dev/plugin-sdk").ToolD
|
|
|
31
31
|
cleared: z.ZodString;
|
|
32
32
|
approved: z.ZodBoolean;
|
|
33
33
|
flag_color: z.ZodString;
|
|
34
|
-
flag_name: z.ZodString;
|
|
35
34
|
account_id: z.ZodString;
|
|
36
35
|
account_name: z.ZodString;
|
|
37
36
|
payee_id: z.ZodString;
|
|
@@ -39,7 +38,8 @@ export declare const createTransaction: import("@opentabs-dev/plugin-sdk").ToolD
|
|
|
39
38
|
category_id: z.ZodString;
|
|
40
39
|
category_name: z.ZodString;
|
|
41
40
|
transfer_account_id: z.ZodString;
|
|
42
|
-
|
|
41
|
+
imported_payee: z.ZodString;
|
|
42
|
+
original_imported_payee: z.ZodString;
|
|
43
43
|
deleted: z.ZodBoolean;
|
|
44
44
|
}, z.core.$strip>;
|
|
45
45
|
}, z.core.$strip>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-transaction.d.ts","sourceRoot":"","sources":["../../src/tools/create-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"create-transaction.d.ts","sourceRoot":"","sources":["../../src/tools/create-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAoG5B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getPlanId, syncWrite } from '../ynab-api.js';
|
|
4
|
-
import { mapTransaction, transactionSchema } from './schemas.js';
|
|
3
|
+
import { getPlanId, syncBudget, syncWrite } from '../ynab-api.js';
|
|
4
|
+
import { buildLookups, CLEARED_MAP, FLAG_MAP, mapTransaction, resolvePayee, toMilliunits, transactionSchema, } from './schemas.js';
|
|
5
5
|
export const createTransaction = defineTool({
|
|
6
6
|
name: 'create_transaction',
|
|
7
7
|
displayName: 'Create Transaction',
|
|
@@ -28,30 +28,71 @@ export const createTransaction = defineTool({
|
|
|
28
28
|
}),
|
|
29
29
|
handle: async (params) => {
|
|
30
30
|
const planId = getPlanId();
|
|
31
|
-
const milliunits =
|
|
31
|
+
const milliunits = toMilliunits(params.amount);
|
|
32
32
|
const txId = crypto.randomUUID();
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
const budget = await syncBudget(planId);
|
|
34
|
+
const serverKnowledge = budget.current_server_knowledge ?? 0;
|
|
35
|
+
const lookups = buildLookups(budget.changed_entities ?? {});
|
|
36
|
+
const changedEntities = {};
|
|
37
|
+
let payeeId = params.payee_id ?? null;
|
|
38
|
+
if (!payeeId && params.payee_name) {
|
|
39
|
+
const resolved = resolvePayee(budget.changed_entities?.be_payees ?? [], params.payee_name);
|
|
40
|
+
payeeId = resolved.payeeId;
|
|
41
|
+
if (resolved.newPayee) {
|
|
42
|
+
changedEntities.be_payees = [resolved.newPayee];
|
|
43
|
+
lookups.payees.set(resolved.payeeId, params.payee_name);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
changedEntities.be_transaction_groups = [
|
|
47
|
+
{
|
|
48
|
+
id: txId,
|
|
49
|
+
be_transaction: {
|
|
50
|
+
id: txId,
|
|
51
|
+
is_tombstone: false,
|
|
52
|
+
entities_account_id: params.account_id,
|
|
53
|
+
entities_payee_id: payeeId,
|
|
54
|
+
entities_subcategory_id: params.category_id ?? null,
|
|
55
|
+
entities_scheduled_transaction_id: null,
|
|
56
|
+
date: params.date,
|
|
57
|
+
date_entered_from_schedule: null,
|
|
58
|
+
amount: milliunits,
|
|
59
|
+
// cash_amount and credit_amount are server-computed splits the account
|
|
60
|
+
// type determines. Captured from a credit card account create where
|
|
61
|
+
// YNAB's UI sent zeros and the server populated them on response —
|
|
62
|
+
// not yet verified for cash/checking accounts but likely the same
|
|
63
|
+
// pattern.
|
|
64
|
+
cash_amount: 0,
|
|
65
|
+
credit_amount: 0,
|
|
66
|
+
credit_amount_adjusted: 0,
|
|
67
|
+
subcategory_credit_amount_preceding: 0,
|
|
68
|
+
memo: params.memo ?? null,
|
|
69
|
+
cleared: CLEARED_MAP[params.cleared ?? 'uncleared'],
|
|
70
|
+
// YNAB's wire format calls this "accepted"; the public tool surface uses "approved".
|
|
71
|
+
accepted: params.approved ?? true,
|
|
72
|
+
check_number: null,
|
|
73
|
+
flag: params.flag_color ? FLAG_MAP[params.flag_color] : null,
|
|
74
|
+
transfer_account_id: null,
|
|
75
|
+
transfer_transaction_id: null,
|
|
76
|
+
transfer_subtransaction_id: null,
|
|
77
|
+
matched_transaction_id: null,
|
|
78
|
+
ynab_id: null,
|
|
79
|
+
// Import-related fields are only populated by bank-feed imports, not manual entry.
|
|
80
|
+
imported_payee: null,
|
|
81
|
+
imported_date: null,
|
|
82
|
+
original_imported_payee: null,
|
|
83
|
+
provider_cleansed_payee: null,
|
|
84
|
+
source: null,
|
|
85
|
+
debt_transaction_type: null,
|
|
86
|
+
},
|
|
87
|
+
be_subtransactions: null,
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
const result = await syncWrite(planId, changedEntities, serverKnowledge);
|
|
91
|
+
const saved = result.changed_entities?.be_transactions?.find(t => t.id === txId);
|
|
51
92
|
if (!saved) {
|
|
52
93
|
throw ToolError.internal('Transaction was created but no data was returned');
|
|
53
94
|
}
|
|
54
|
-
return { transaction: mapTransaction(saved) };
|
|
95
|
+
return { transaction: mapTransaction(saved, lookups) };
|
|
55
96
|
},
|
|
56
97
|
});
|
|
57
98
|
//# sourceMappingURL=create-transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-transaction.js","sourceRoot":"","sources":["../../src/tools/create-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,E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Y,EAAE,IAAI;oBAClB,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI;oBAC5D,mBAAmB,EAAE,IAAI;oBACzB,uBAAuB,EAAE,IAAI;oBAC7B,0BAA0B,EAAE,IAAI;oBAChC,sBAAsB,EAAE,IAAI;oBAC5B,OAAO,EAAE,IAAI;oBACb,mFAAmF;oBACnF,cAAc,EAAE,IAAI;oBACpB,aAAa,EAAE,IAAI;oBACnB,uBAAuB,EAAE,IAAI;oBAC7B,uBAAuB,EAAE,IAAI;oBAC7B,MAAM,EAAE,IAAI;oBACZ,qBAAqB,EAAE,IAAI;iBAC5B;gBACD,kBAAkB,EAAE,IAAI;aACzB;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAiB,MAAM,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAEzF,MAAM,KAAK,GAAG,MAAM,CAAC,gBAAgB,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,SAAS,CAAC,QAAQ,CAAC,kDAAkD,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;IACzD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const deleteCategoryGroup: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
3
|
+
group_id: z.ZodString;
|
|
4
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
5
|
+
success: z.ZodBoolean;
|
|
6
|
+
deleted_category_count: z.ZodNumber;
|
|
7
|
+
}, z.core.$strip>>;
|
|
8
|
+
//# sourceMappingURL=delete-category-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-category-group.d.ts","sourceRoot":"","sources":["../../src/tools/delete-category-group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,mBAAmB;;;;;kBAuC9B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getPlanId, syncBudget, syncWrite } from '../ynab-api.js';
|
|
4
|
+
import { assertCategoryGroupDeletable, findCategoryGroup, notTombstone } from './schemas.js';
|
|
5
|
+
export const deleteCategoryGroup = defineTool({
|
|
6
|
+
name: 'delete_category_group',
|
|
7
|
+
displayName: 'Delete Category Group',
|
|
8
|
+
description: 'Delete a category group and all of its child categories from the active YNAB plan. This is a soft delete (tombstone). Internal/non-deletable groups (Credit Card Payments, Hidden Categories, Internal Master Category) cannot be deleted.',
|
|
9
|
+
summary: 'Delete a category group and its children',
|
|
10
|
+
icon: 'folder-x',
|
|
11
|
+
group: 'Categories',
|
|
12
|
+
input: z.object({
|
|
13
|
+
group_id: z.string().min(1).describe('Category group ID to delete'),
|
|
14
|
+
}),
|
|
15
|
+
output: z.object({
|
|
16
|
+
success: z.boolean(),
|
|
17
|
+
deleted_category_count: z.number().describe('Number of child categories that were also tombstoned'),
|
|
18
|
+
}),
|
|
19
|
+
handle: async (params) => {
|
|
20
|
+
const planId = getPlanId();
|
|
21
|
+
const budget = await syncBudget(planId);
|
|
22
|
+
const serverKnowledge = budget.current_server_knowledge ?? 0;
|
|
23
|
+
const group = findCategoryGroup(budget.changed_entities, params.group_id);
|
|
24
|
+
assertCategoryGroupDeletable(group);
|
|
25
|
+
const childCategories = (budget.changed_entities?.be_subcategories ?? []).filter(c => c.entities_master_category_id === params.group_id && notTombstone(c));
|
|
26
|
+
await syncWrite(planId, {
|
|
27
|
+
be_master_categories: [{ ...group, is_tombstone: true }],
|
|
28
|
+
be_subcategories: childCategories.map(c => ({ ...c, is_tombstone: true })),
|
|
29
|
+
}, serverKnowledge);
|
|
30
|
+
return { success: true, deleted_category_count: childCategories.length };
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=delete-category-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-category-group.js","sourceRoot":"","sources":["../../src/tools/delete-category-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7F,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC5C,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EACT,4OAA4O;IAC9O,OAAO,EAAE,0CAA0C;IACnD,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;KACpE,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;QACpB,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;KACpG,CAAC;IACF,MAAM,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;QACrB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAE3B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAiB,MAAM,CAAC,CAAC;QACxD,MAAM,eAAe,GAAG,MAAM,CAAC,wBAAwB,IAAI,CAAC,CAAC;QAE7D,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1E,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAEpC,MAAM,eAAe,GAAG,CAAC,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,IAAI,EAAE,CAAC,CAAC,MAAM,CAC9E,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,2BAA2B,KAAK,MAAM,CAAC,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,CAC1E,CAAC;QAEF,MAAM,SAAS,CACb,MAAM,EACN;YACE,oBAAoB,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YACxD,gBAAgB,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;SAC3E,EACD,eAAe,CAChB,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,eAAe,CAAC,MAAM,EAAE,CAAC;IAC3E,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const deleteCategory: import("@opentabs-dev/plugin-sdk").ToolDefinition<z.ZodObject<{
|
|
3
|
+
category_id: z.ZodString;
|
|
4
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
5
|
+
success: z.ZodBoolean;
|
|
6
|
+
}, z.core.$strip>>;
|
|
7
|
+
//# sourceMappingURL=delete-category.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-category.d.ts","sourceRoot":"","sources":["../../src/tools/delete-category.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,cAAc;;;;kBA8BzB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getPlanId, syncBudget, syncWrite } from '../ynab-api.js';
|
|
4
|
+
import { assertCategoryDeletable, findCategory } from './schemas.js';
|
|
5
|
+
export const deleteCategory = defineTool({
|
|
6
|
+
name: 'delete_category',
|
|
7
|
+
displayName: 'Delete Category',
|
|
8
|
+
description: 'Delete a category from the active YNAB plan. This is a soft delete (tombstone). Existing transactions assigned to this category remain in place but the category will no longer appear in budget views.',
|
|
9
|
+
summary: 'Delete a category',
|
|
10
|
+
icon: 'trash-2',
|
|
11
|
+
group: 'Categories',
|
|
12
|
+
input: z.object({
|
|
13
|
+
category_id: z.string().min(1).describe('Category ID to delete'),
|
|
14
|
+
}),
|
|
15
|
+
output: z.object({
|
|
16
|
+
success: z.boolean(),
|
|
17
|
+
}),
|
|
18
|
+
handle: async (params) => {
|
|
19
|
+
const planId = getPlanId();
|
|
20
|
+
const budget = await syncBudget(planId);
|
|
21
|
+
const serverKnowledge = budget.current_server_knowledge ?? 0;
|
|
22
|
+
const existing = findCategory(budget.changed_entities, params.category_id);
|
|
23
|
+
assertCategoryDeletable(existing);
|
|
24
|
+
await syncWrite(planId, { be_subcategories: [{ ...existing, is_tombstone: true }] }, serverKnowledge);
|
|
25
|
+
return { success: true };
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=delete-category.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-category.js","sourceRoot":"","sources":["../../src/tools/delete-category.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KA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ction.d.ts","sourceRoot":"","sources":["../../src/tools/delete-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"delete-transaction.d.ts","sourceRoot":"","sources":["../../src/tools/delete-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB;;;;;kBAqD5B,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineTool } from '@opentabs-dev/plugin-sdk';
|
|
1
|
+
import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { getPlanId, syncWrite } from '../ynab-api.js';
|
|
3
|
+
import { getPlanId, syncBudget, syncWrite } from '../ynab-api.js';
|
|
4
4
|
export const deleteTransaction = defineTool({
|
|
5
5
|
name: 'delete_transaction',
|
|
6
6
|
displayName: 'Delete Transaction',
|
|
7
|
-
description: 'Delete a transaction from the active YNAB plan. This marks the transaction as deleted (soft delete).',
|
|
7
|
+
description: 'Delete a transaction from the active YNAB plan. This marks the transaction as deleted (soft delete). Transfer transactions cannot be deleted through this tool — delete them directly in YNAB.',
|
|
8
8
|
summary: 'Delete a transaction',
|
|
9
9
|
icon: 'trash-2',
|
|
10
10
|
group: 'Transactions',
|
|
@@ -17,15 +17,30 @@ export const deleteTransaction = defineTool({
|
|
|
17
17
|
}),
|
|
18
18
|
handle: async (params) => {
|
|
19
19
|
const planId = getPlanId();
|
|
20
|
+
const budget = await syncBudget(planId);
|
|
21
|
+
const serverKnowledge = budget.current_server_knowledge ?? 0;
|
|
22
|
+
const existing = budget.changed_entities?.be_transactions?.find(t => t.id === params.transaction_id && !t.is_tombstone);
|
|
23
|
+
if (!existing) {
|
|
24
|
+
throw ToolError.notFound(`Transaction not found: ${params.transaction_id}`);
|
|
25
|
+
}
|
|
26
|
+
if (existing.transfer_account_id) {
|
|
27
|
+
throw ToolError.validation('Cannot delete transfer transactions — delete them in YNAB directly.');
|
|
28
|
+
}
|
|
29
|
+
// YNAB rejects minimal payloads here with 400 — the full transaction shape
|
|
30
|
+
// is required even for tombstoning. Verified by capturing the YNAB UI's
|
|
31
|
+
// own delete request and reproducing the failure with a partial payload.
|
|
20
32
|
await syncWrite(planId, {
|
|
21
|
-
|
|
33
|
+
be_transaction_groups: [
|
|
22
34
|
{
|
|
23
35
|
id: params.transaction_id,
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
be_transaction: {
|
|
37
|
+
...existing,
|
|
38
|
+
is_tombstone: true,
|
|
39
|
+
},
|
|
40
|
+
be_subtransactions: null,
|
|
26
41
|
},
|
|
27
42
|
],
|
|
28
|
-
});
|
|
43
|
+
}, serverKnowledge);
|
|
29
44
|
return { success: true };
|
|
30
45
|
},
|
|
31
46
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-transaction.js","sourceRoot":"","sources":["../../src/tools/delete-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"delete-transaction.js","sourceRoot":"","sources":["../../src/tools/delete-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGlE,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EACT,gMAAgM;IAClM,OAAO,EAAE,sBAAsB;IAC/B,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,cAAc,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ACF,EACD,eAAe,CAChB,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-account.d.ts","sourceRoot":"","sources":["../../src/tools/get-account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"get-account.d.ts","sourceRoot":"","sources":["../../src/tools/get-account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;kBA6BrB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineTool, ToolError } from '@opentabs-dev/plugin-sdk';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
4
|
-
import { accountSchema, mapAccount } from './schemas.js';
|
|
3
|
+
import { getPlanId, syncBudget } from '../ynab-api.js';
|
|
4
|
+
import { accountSchema, buildAccountCalcMap, mapAccount } from './schemas.js';
|
|
5
5
|
export const getAccount = defineTool({
|
|
6
6
|
name: 'get_account',
|
|
7
7
|
displayName: 'Get Account',
|
|
@@ -20,7 +20,7 @@ export const getAccount = defineTool({
|
|
|
20
20
|
const result = await syncBudget(planId);
|
|
21
21
|
const entities = result.changed_entities;
|
|
22
22
|
const raw = entities?.be_accounts ?? [];
|
|
23
|
-
const calcMap =
|
|
23
|
+
const calcMap = buildAccountCalcMap(entities ?? {});
|
|
24
24
|
const account = raw.find(a => a.id === params.account_id && !a.is_tombstone);
|
|
25
25
|
if (!account) {
|
|
26
26
|
throw ToolError.notFound(`Account not found: ${params.account_id}`);
|