@actual-app/api 6.8.1 → 6.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/@types/loot-core/client/constants.d.ts +1 -0
  2. package/@types/loot-core/client/state-types/modals.d.ts +14 -4
  3. package/@types/loot-core/client/state-types/queries.d.ts +8 -0
  4. package/@types/loot-core/platform/server/sqlite/index.d.ts +3 -3
  5. package/@types/loot-core/server/accounts/sync.d.ts +12 -1
  6. package/@types/loot-core/server/accounts/transactions.d.ts +4 -16
  7. package/@types/loot-core/server/api-models.d.ts +15 -0
  8. package/@types/loot-core/server/aql/schema/index.d.ts +18 -0
  9. package/@types/loot-core/server/budget/actions.d.ts +6 -1
  10. package/@types/loot-core/server/budget/app.d.ts +1 -1
  11. package/@types/loot-core/server/budget/types/handlers.d.ts +5 -0
  12. package/@types/loot-core/server/db/index.d.ts +48 -7
  13. package/@types/loot-core/server/main-app.d.ts +1 -1
  14. package/@types/loot-core/server/migrate/migrations.d.ts +1 -1
  15. package/@types/loot-core/server/post.d.ts +1 -1
  16. package/@types/loot-core/shared/normalisation.d.ts +1 -0
  17. package/@types/loot-core/shared/rules.d.ts +1 -1
  18. package/@types/loot-core/shared/transactions.d.ts +27 -2
  19. package/@types/loot-core/shared/util.d.ts +1 -1
  20. package/@types/loot-core/types/api-handlers.d.ts +15 -0
  21. package/@types/loot-core/types/file.d.ts +2 -0
  22. package/@types/loot-core/types/models/payee.d.ts +1 -0
  23. package/@types/loot-core/types/models/reports.d.ts +26 -0
  24. package/@types/loot-core/types/models/rule.d.ts +2 -1
  25. package/@types/loot-core/types/prefs.d.ts +8 -6
  26. package/@types/loot-core/types/server-handlers.d.ts +9 -2
  27. package/@types/methods.d.ts +4 -0
  28. package/dist/app/bundle.api.js +1156 -613
  29. package/dist/methods.js +17 -1
  30. package/dist/methods.test.js +15 -1
  31. package/dist/migrations/1716359441000_include_current.sql +5 -0
  32. package/dist/migrations/1720310586000_link_transfer_schedules.sql +19 -0
  33. package/dist/migrations/1720664867241_add_payee_favorite.sql +5 -0
  34. package/dist/migrations/1720665000000_goal_context.sql +6 -0
  35. package/dist/package.json +1 -1
  36. package/package.json +1 -1
package/dist/methods.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.deleteRule = exports.updateRule = exports.createRule = exports.getPayeeRules = exports.getRules = exports.deletePayee = exports.updatePayee = exports.createPayee = exports.getPayees = exports.deleteCategory = exports.updateCategory = exports.createCategory = exports.getCategories = exports.deleteCategoryGroup = exports.updateCategoryGroup = exports.createCategoryGroup = exports.getCategoryGroups = exports.deleteAccount = exports.reopenAccount = exports.closeAccount = exports.updateAccount = exports.createAccount = exports.getAccounts = exports.deleteTransaction = exports.updateTransaction = exports.getTransactions = exports.importTransactions = exports.addTransactions = exports.setBudgetCarryover = exports.setBudgetAmount = exports.getBudgetMonth = exports.getBudgetMonths = exports.runQuery = exports.batchBudgetUpdates = exports.runBankSync = exports.sync = exports.downloadBudget = exports.loadBudget = exports.runImport = exports.q = void 0;
26
+ exports.deleteRule = exports.updateRule = exports.createRule = exports.getPayeeRules = exports.getRules = exports.mergePayees = exports.deletePayee = exports.updatePayee = exports.createPayee = exports.getPayees = exports.getCommonPayees = exports.deleteCategory = exports.updateCategory = exports.createCategory = exports.getCategories = exports.deleteCategoryGroup = exports.updateCategoryGroup = exports.createCategoryGroup = exports.getCategoryGroups = exports.getAccountBalance = exports.deleteAccount = exports.reopenAccount = exports.closeAccount = exports.updateAccount = exports.createAccount = exports.getAccounts = exports.deleteTransaction = exports.updateTransaction = exports.getTransactions = exports.importTransactions = exports.addTransactions = exports.setBudgetCarryover = exports.setBudgetAmount = exports.getBudgetMonth = exports.getBudgetMonths = exports.runQuery = exports.batchBudgetUpdates = exports.runBankSync = exports.sync = exports.getBudgets = exports.downloadBudget = exports.loadBudget = exports.runImport = exports.q = void 0;
27
27
  const injected = __importStar(require("./injected"));
28
28
  var query_1 = require("./app/query");
29
29
  Object.defineProperty(exports, "q", { enumerable: true, get: function () { return query_1.q; } });
@@ -50,6 +50,10 @@ async function downloadBudget(syncId, { password } = {}) {
50
50
  return send('api/download-budget', { syncId, password });
51
51
  }
52
52
  exports.downloadBudget = downloadBudget;
53
+ async function getBudgets() {
54
+ return send('api/get-budgets');
55
+ }
56
+ exports.getBudgets = getBudgets;
53
57
  async function sync() {
54
58
  return send('api/sync');
55
59
  }
@@ -141,6 +145,10 @@ function deleteAccount(id) {
141
145
  return send('api/account-delete', { id });
142
146
  }
143
147
  exports.deleteAccount = deleteAccount;
148
+ function getAccountBalance(id, cutoff) {
149
+ return send('api/account-balance', { id, cutoff });
150
+ }
151
+ exports.getAccountBalance = getAccountBalance;
144
152
  function getCategoryGroups() {
145
153
  return send('api/category-groups-get');
146
154
  }
@@ -173,6 +181,10 @@ function deleteCategory(id, transferCategoryId) {
173
181
  return send('api/category-delete', { id, transferCategoryId });
174
182
  }
175
183
  exports.deleteCategory = deleteCategory;
184
+ function getCommonPayees() {
185
+ return send('api/common-payees-get');
186
+ }
187
+ exports.getCommonPayees = getCommonPayees;
176
188
  function getPayees() {
177
189
  return send('api/payees-get');
178
190
  }
@@ -189,6 +201,10 @@ function deletePayee(id) {
189
201
  return send('api/payee-delete', { id });
190
202
  }
191
203
  exports.deletePayee = deletePayee;
204
+ function mergePayees(targetId, mergeIds) {
205
+ return send('api/payees-merge', { targetId, mergeIds });
206
+ }
207
+ exports.mergePayees = mergePayees;
192
208
  function getRules() {
193
209
  return send('api/rules-get');
194
210
  }
@@ -61,6 +61,16 @@ describe('API CRUD operations', () => {
61
61
  // load test budget
62
62
  await api.loadBudget(budgetName);
63
63
  });
64
+ // api: getBudgets
65
+ test('getBudgets', async () => {
66
+ const budgets = await api.getBudgets();
67
+ expect(budgets).toEqual(expect.arrayContaining([
68
+ expect.objectContaining({
69
+ id: 'test-budget',
70
+ name: 'Default Test Db',
71
+ }),
72
+ ]));
73
+ });
64
74
  // apis: getCategoryGroups, createCategoryGroup, updateCategoryGroup, deleteCategoryGroup
65
75
  test('CategoryGroups: successfully update category groups', async () => {
66
76
  const month = '2023-10';
@@ -218,7 +228,7 @@ describe('API CRUD operations', () => {
218
228
  }),
219
229
  ]));
220
230
  });
221
- //apis: createAccount, getAccounts, updateAccount, closeAccount, deleteAccount, reopenAccount
231
+ //apis: createAccount, getAccounts, updateAccount, closeAccount, deleteAccount, reopenAccount, getAccountBalance
222
232
  test('Accounts: successfully complete account operators', async () => {
223
233
  const accountId1 = await api.createAccount({ name: 'test-account1', offbudget: true }, 1000);
224
234
  const accountId2 = await api.createAccount({ name: 'test-account2' }, 0);
@@ -232,6 +242,8 @@ describe('API CRUD operations', () => {
232
242
  }),
233
243
  expect.objectContaining({ id: accountId2, name: 'test-account2' }),
234
244
  ]));
245
+ expect(await api.getAccountBalance(accountId1)).toEqual(1000);
246
+ expect(await api.getAccountBalance(accountId2)).toEqual(0);
235
247
  await api.updateAccount(accountId1, { offbudget: false });
236
248
  await api.closeAccount(accountId1, accountId2, null);
237
249
  await api.deleteAccount(accountId2);
@@ -493,6 +505,8 @@ describe('API CRUD operations', () => {
493
505
  runTransfers: true,
494
506
  });
495
507
  expect(addResult).toBe('ok');
508
+ expect(await api.getAccountBalance(accountId)).toEqual(200);
509
+ expect(await api.getAccountBalance(accountId, new Date(2023, 10, 2))).toEqual(0);
496
510
  // confirm added transactions exist
497
511
  let transactions = await api.getTransactions(accountId, '2023-11-01', '2023-11-30');
498
512
  expect(transactions).toEqual(expect.arrayContaining(newTransaction.map(trans => expect.objectContaining(trans))));
@@ -0,0 +1,5 @@
1
+ BEGIN TRANSACTION;
2
+
3
+ ALTER TABLE custom_reports ADD COLUMN include_current INTEGER DEFAULT 0;
4
+
5
+ COMMIT;
@@ -0,0 +1,19 @@
1
+ BEGIN TRANSACTION;
2
+
3
+ UPDATE transactions AS t1
4
+ SET schedule = (
5
+ SELECT t2.schedule FROM transactions AS t2
6
+ WHERE t2.id = t1.transferred_id
7
+ AND t2.schedule IS NOT NULL
8
+ LIMIT 1
9
+ )
10
+ WHERE t1.schedule IS NULL
11
+ AND t1.transferred_id IS NOT NULL
12
+ AND EXISTS (
13
+ SELECT 1 FROM transactions AS t2
14
+ WHERE t2.id = t1.transferred_id
15
+ AND t2.schedule IS NOT NULL
16
+ LIMIT 1
17
+ );
18
+
19
+ COMMIT;
@@ -0,0 +1,5 @@
1
+ BEGIN TRANSACTION;
2
+
3
+ ALTER TABLE payees ADD COLUMN favorite INTEGER DEFAULT 0 DEFAULT FALSE;
4
+
5
+ COMMIT;
@@ -0,0 +1,6 @@
1
+ BEGIN TRANSACTION;
2
+
3
+ ALTER TABLE zero_budgets ADD COLUMN long_goal INTEGER DEFAULT null;
4
+ ALTER TABLE reflect_budgets ADD COLUMN long_goal INTEGER DEFAULT null;
5
+
6
+ COMMIT;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.8.1",
3
+ "version": "6.9.0",
4
4
  "license": "MIT",
5
5
  "description": "An API for Actual",
6
6
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.8.1",
3
+ "version": "6.9.0",
4
4
  "license": "MIT",
5
5
  "description": "An API for Actual",
6
6
  "engines": {