@actual-app/api 6.4.0 → 6.6.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/dist/app/query.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.q = void 0;
3
4
  class Query {
4
5
  constructor(state) {
5
6
  this.state = {
@@ -85,4 +86,4 @@ class Query {
85
86
  function q(table) {
86
87
  return new Query({ table });
87
88
  }
88
- exports.default = q;
89
+ exports.q = q;
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.shutdown = exports.init = exports.utils = exports.methods = exports.internal = void 0;
30
+ // @ts-ignore: bundle not available until we build it
30
31
  // eslint-disable-next-line import/extensions
31
32
  const bundle = __importStar(require("./app/bundle.api.js"));
32
33
  const injected = __importStar(require("./injected"));
@@ -42,7 +43,11 @@ async function init(config = {}) {
42
43
  return;
43
44
  }
44
45
  (0, validateNodeVersion_1.validateNodeVersion)();
45
- global.fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
46
+ if (!globalThis.fetch) {
47
+ globalThis.fetch = (url, init) => {
48
+ return Promise.resolve().then(() => __importStar(require('node-fetch'))).then(({ default: fetch }) => fetch(url, init));
49
+ };
50
+ }
46
51
  await bundle.init(config);
47
52
  actualApp = bundle.lib;
48
53
  injected.override(bundle.lib.send);
package/dist/methods.js CHANGED
@@ -22,14 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.deletePayee = exports.updatePayee = exports.createPayee = exports.getPayees = exports.deleteCategory = exports.updateCategory = exports.createCategory = exports.getCategories = exports.deleteCategoryGroup = exports.updateCategoryGroup = exports.createCategoryGroup = exports.deleteAccount = exports.reopenAccount = exports.closeAccount = exports.updateAccount = exports.createAccount = exports.getAccounts = exports.deleteTransaction = exports.updateTransaction = exports.filterTransactions = exports.getTransactions = exports.importTransactions = exports.addTransactions = exports.setBudgetCarryover = exports.setBudgetAmount = exports.getBudgetMonth = exports.getBudgetMonths = exports.runQuery = exports.batchBudgetUpdates = exports.sync = exports.downloadBudget = exports.loadBudget = exports.runImport = exports.q = void 0;
26
+ exports.deletePayee = exports.updatePayee = exports.createPayee = exports.getPayees = exports.deleteCategory = exports.updateCategory = exports.createCategory = exports.getCategories = exports.deleteCategoryGroup = exports.updateCategoryGroup = exports.createCategoryGroup = 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.sync = exports.downloadBudget = exports.loadBudget = exports.runImport = exports.q = void 0;
30
27
  const injected = __importStar(require("./injected"));
31
28
  var query_1 = require("./app/query");
32
- Object.defineProperty(exports, "q", { enumerable: true, get: function () { return __importDefault(query_1).default; } });
29
+ Object.defineProperty(exports, "q", { enumerable: true, get: function () { return query_1.q; } });
33
30
  function send(name, args) {
34
31
  return injected.send(name, args);
35
32
  }
@@ -104,10 +101,6 @@ function getTransactions(accountId, startDate, endDate) {
104
101
  return send('api/transactions-get', { accountId, startDate, endDate });
105
102
  }
106
103
  exports.getTransactions = getTransactions;
107
- function filterTransactions(accountId, text) {
108
- return send('api/transactions-filter', { accountId, text });
109
- }
110
- exports.filterTransactions = filterTransactions;
111
104
  function updateTransaction(id, fields) {
112
105
  return send('api/transaction-update', { id, fields });
113
106
  }
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ // @ts-strict-ignore
26
27
  const fs = __importStar(require("fs/promises"));
27
28
  const path = __importStar(require("path"));
28
29
  const api = __importStar(require("./index"));
@@ -228,4 +229,77 @@ describe('API CRUD operations', () => {
228
229
  }),
229
230
  ]));
230
231
  });
232
+ // apis: createPayee, getPayees, updatePayee, deletePayee
233
+ test('Payees: successfully update payees', async () => {
234
+ const payeeId1 = await api.createPayee({ name: 'test-payee1' });
235
+ const payeeId2 = await api.createPayee({ name: 'test-payee2' });
236
+ let payees = await api.getPayees();
237
+ // payees successfully created
238
+ expect(payees).toEqual(expect.arrayContaining([
239
+ expect.objectContaining({
240
+ id: payeeId1,
241
+ name: 'test-payee1',
242
+ }),
243
+ expect.objectContaining({
244
+ id: payeeId2,
245
+ name: 'test-payee2',
246
+ }),
247
+ ]));
248
+ await api.updatePayee(payeeId1, { name: 'test-updated-payee' });
249
+ await api.deletePayee(payeeId2);
250
+ // confirm update and delete were successful
251
+ payees = await api.getPayees();
252
+ expect(payees).toEqual(expect.arrayContaining([
253
+ expect.objectContaining({
254
+ id: payeeId1,
255
+ name: 'test-updated-payee',
256
+ }),
257
+ expect.not.objectContaining({
258
+ name: 'test-payee1',
259
+ }),
260
+ expect.not.objectContaining({
261
+ id: payeeId2,
262
+ }),
263
+ ]));
264
+ });
265
+ // apis: addTransactions, getTransactions, importTransactions, updateTransaction, deleteTransaction
266
+ test('Transactions: successfully update transactions', async () => {
267
+ const accountId = await api.createAccount({ name: 'test-account' }, 0);
268
+ let newTransaction = [
269
+ { date: '2023-11-03', imported_id: '11', amount: 100 },
270
+ { date: '2023-11-03', imported_id: '11', amount: 100 },
271
+ ];
272
+ const addResult = await api.addTransactions(accountId, newTransaction, {
273
+ learnCategories: true,
274
+ runTransfers: true,
275
+ });
276
+ expect(addResult).toBe('ok');
277
+ // confirm added transactions exist
278
+ let transactions = await api.getTransactions(accountId, '2023-11-01', '2023-11-30');
279
+ expect(transactions).toEqual(expect.arrayContaining(newTransaction.map(trans => expect.objectContaining(trans))));
280
+ expect(transactions).toHaveLength(2);
281
+ newTransaction = [
282
+ { date: '2023-12-03', imported_id: '11', amount: 100 },
283
+ { date: '2023-12-03', imported_id: '22', amount: 200 },
284
+ ];
285
+ const reconciled = await api.importTransactions(accountId, newTransaction);
286
+ // Expect it to reconcile and to have updated one of the previous transactions
287
+ expect(reconciled.added).toHaveLength(1);
288
+ expect(reconciled.updated).toHaveLength(1);
289
+ // confirm imported transactions exist
290
+ transactions = await api.getTransactions(accountId, '2023-12-01', '2023-12-31');
291
+ expect(transactions).toEqual(expect.arrayContaining(newTransaction.map(trans => expect.objectContaining(trans))));
292
+ expect(transactions).toHaveLength(2);
293
+ const idToUpdate = reconciled.added[0];
294
+ const idToDelete = reconciled.updated[0];
295
+ await api.updateTransaction(idToUpdate, { amount: 500 });
296
+ await api.deleteTransaction(idToDelete);
297
+ // confirm updates and deletions work
298
+ transactions = await api.getTransactions(accountId, '2023-12-01', '2023-12-31');
299
+ expect(transactions).toEqual(expect.arrayContaining([
300
+ expect.objectContaining({ id: idToUpdate, amount: 500 }),
301
+ expect.not.objectContaining({ id: idToDelete }),
302
+ ]));
303
+ expect(transactions).toHaveLength(1);
304
+ });
231
305
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- async function runMigration(db, uuid) {
3
+ async function runMigration(db) {
4
4
  function getValue(node) {
5
5
  return node.expr != null ? node.expr : node.cachedValue;
6
6
  }
@@ -0,0 +1,5 @@
1
+ BEGIN TRANSACTION;
2
+
3
+ ALTER TABLE accounts ADD COLUMN account_sync_source TEXT;
4
+
5
+ COMMIT;
@@ -0,0 +1,9 @@
1
+ BEGIN TRANSACTION;
2
+
3
+ UPDATE accounts
4
+ SET
5
+ account_sync_source = 'goCardless'
6
+ WHERE account_id IS NOT NULL
7
+ AND account_sync_source IS NULL;
8
+
9
+ COMMIT;
@@ -0,0 +1,28 @@
1
+ BEGIN TRANSACTION;
2
+
3
+ CREATE TABLE custom_reports
4
+ (
5
+ id TEXT PRIMARY KEY,
6
+ name TEXT,
7
+ start_date TEXT,
8
+ end_date TEXT,
9
+ date_static INTEGER DEFAULT 0,
10
+ date_range TEXT,
11
+ mode TEXT DEFAULT 'total',
12
+ group_by TEXT DEFAULT 'Category',
13
+ balance_type TEXT DEFAULT 'Expense',
14
+ show_empty INTEGER DEFAULT 0,
15
+ show_offbudget INTEGER DEFAULT 0,
16
+ show_hidden INTEGER DEFAULT 0,
17
+ show_uncategorized INTEGER DEFAULT 0,
18
+ selected_categories TEXT,
19
+ graph_type TEXT DEFAULT 'BarGraph',
20
+ conditions TEXT,
21
+ conditions_op TEXT DEFAULT 'and',
22
+ metadata TEXT,
23
+ interval TEXT DEFAULT 'Monthly',
24
+ color_scheme TEXT,
25
+ tombstone INTEGER DEFAULT 0
26
+ );
27
+
28
+ COMMIT;
package/dist/package.json CHANGED
@@ -1,36 +1,38 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.4.0",
3
+ "version": "6.6.0",
4
4
  "license": "MIT",
5
5
  "description": "An API for Actual",
6
6
  "engines": {
7
7
  "node": ">=18.12.0"
8
8
  },
9
9
  "main": "dist/index.js",
10
- "types": "dist/index.d.ts",
10
+ "types": "@types/index.d.ts",
11
11
  "files": [
12
12
  "dist"
13
13
  ],
14
14
  "scripts": {
15
15
  "build:app": "yarn workspace loot-core build:api",
16
- "build:node": "tsc --p tsconfig.dist.json",
16
+ "build:node": "tsc --p tsconfig.dist.json && tsc-alias -p tsconfig.dist.json",
17
17
  "build:migrations": "cp migrations/*.sql dist/migrations",
18
18
  "build:default-db": "cp default-db.sqlite dist/",
19
- "build": "rm -rf dist && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db",
20
- "test": "yarn run build:app && jest -c jest.config.js"
19
+ "build": "yarn run clean && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db",
20
+ "test": "yarn run build:app && jest -c jest.config.js",
21
+ "clean": "rm -rf dist @types"
21
22
  },
22
23
  "dependencies": {
23
- "better-sqlite3": "^9.1.1",
24
+ "better-sqlite3": "^9.3.0",
24
25
  "compare-versions": "^6.1.0",
25
26
  "node-fetch": "^3.3.2",
26
- "uuid": "^9.0.0"
27
+ "uuid": "^9.0.1"
27
28
  },
28
29
  "devDependencies": {
29
- "@swc/core": "^1.3.82",
30
- "@swc/jest": "^0.2.29",
31
- "@types/jest": "^27.5.0",
30
+ "@swc/core": "^1.3.105",
31
+ "@swc/jest": "^0.2.31",
32
+ "@types/jest": "^27.5.2",
32
33
  "@types/uuid": "^9.0.2",
33
- "jest": "^27.0.0",
34
+ "jest": "^27.5.1",
35
+ "tsc-alias": "^1.8.8",
34
36
  "typescript": "^5.0.2"
35
37
  }
36
38
  }
package/package.json CHANGED
@@ -1,36 +1,38 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.4.0",
3
+ "version": "6.6.0",
4
4
  "license": "MIT",
5
5
  "description": "An API for Actual",
6
6
  "engines": {
7
7
  "node": ">=18.12.0"
8
8
  },
9
9
  "main": "dist/index.js",
10
- "types": "dist/index.d.ts",
10
+ "types": "@types/index.d.ts",
11
11
  "files": [
12
12
  "dist"
13
13
  ],
14
14
  "scripts": {
15
15
  "build:app": "yarn workspace loot-core build:api",
16
- "build:node": "tsc --p tsconfig.dist.json",
16
+ "build:node": "tsc --p tsconfig.dist.json && tsc-alias -p tsconfig.dist.json",
17
17
  "build:migrations": "cp migrations/*.sql dist/migrations",
18
18
  "build:default-db": "cp default-db.sqlite dist/",
19
- "build": "rm -rf dist && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db",
20
- "test": "yarn run build:app && jest -c jest.config.js"
19
+ "build": "yarn run clean && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db",
20
+ "test": "yarn run build:app && jest -c jest.config.js",
21
+ "clean": "rm -rf dist @types"
21
22
  },
22
23
  "dependencies": {
23
- "better-sqlite3": "^9.1.1",
24
+ "better-sqlite3": "^9.3.0",
24
25
  "compare-versions": "^6.1.0",
25
26
  "node-fetch": "^3.3.2",
26
- "uuid": "^9.0.0"
27
+ "uuid": "^9.0.1"
27
28
  },
28
29
  "devDependencies": {
29
- "@swc/core": "^1.3.82",
30
- "@swc/jest": "^0.2.29",
31
- "@types/jest": "^27.5.0",
30
+ "@swc/core": "^1.3.105",
31
+ "@swc/jest": "^0.2.31",
32
+ "@types/jest": "^27.5.2",
32
33
  "@types/uuid": "^9.0.2",
33
- "jest": "^27.0.0",
34
+ "jest": "^27.5.1",
35
+ "tsc-alias": "^1.8.8",
34
36
  "typescript": "^5.0.2"
35
37
  }
36
38
  }
@@ -1,6 +0,0 @@
1
- export = __webpack_exports__;
2
- export = __webpack_exports__;
3
- /******/
4
- /************************************************************************/
5
- /******/
6
- /******/ /******/ /******/ /******/ declare var __webpack_exports__: any;
@@ -1,19 +0,0 @@
1
- export default function q(table: any): Query;
2
- declare class Query {
3
- constructor(state: any);
4
- state: any;
5
- filter(expr: any): Query;
6
- unfilter(exprs: any): Query;
7
- select(exprs?: any[]): Query;
8
- calculate(expr: any): Query;
9
- groupBy(exprs: any): Query;
10
- orderBy(exprs: any): Query;
11
- limit(num: any): Query;
12
- offset(num: any): Query;
13
- raw(): Query;
14
- withDead(): Query;
15
- withoutValidatedRefs(): Query;
16
- options(opts: any): Query;
17
- serialize(): any;
18
- }
19
- export {};
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export function init(config?: {}): Promise<any>;
2
- export function shutdown(): Promise<void>;
3
- export const internal: any;
4
- export * as methods from "./methods";
5
- export * from "./methods";
6
- export * as utils from "./utils";
@@ -1,2 +0,0 @@
1
- export function override(sendImplementation: any): void;
2
- export let send: any;
@@ -1,9 +0,0 @@
1
- export const moduleFileExtensions: string[];
2
- export const testEnvironment: string;
3
- export const testPathIgnorePatterns: string[];
4
- export const watchPathIgnorePatterns: string[];
5
- export const setupFilesAfterEnv: string[];
6
- export const transformIgnorePatterns: string[];
7
- export const transform: {
8
- '^.+\\.(t|j)sx?$': string;
9
- };
package/dist/methods.d.ts DELETED
@@ -1,39 +0,0 @@
1
- export function runImport(name: any, func: any): Promise<void>;
2
- export function loadBudget(budgetId: any): Promise<any>;
3
- export function downloadBudget(syncId: any, { password }?: {
4
- password: any;
5
- }): Promise<any>;
6
- export function sync(): Promise<any>;
7
- export function batchBudgetUpdates(func: any): Promise<void>;
8
- export function runQuery(query: any): any;
9
- export function getBudgetMonths(): any;
10
- export function getBudgetMonth(month: any): any;
11
- export function setBudgetAmount(month: any, categoryId: any, value: any): any;
12
- export function setBudgetCarryover(month: any, categoryId: any, flag: any): any;
13
- export function addTransactions(accountId: any, transactions: any, { learnCategories, runTransfers }?: {
14
- learnCategories?: boolean;
15
- runTransfers?: boolean;
16
- }): any;
17
- export function importTransactions(accountId: any, transactions: any): any;
18
- export function getTransactions(accountId: any, startDate: any, endDate: any): any;
19
- export function filterTransactions(accountId: any, text: any): any;
20
- export function updateTransaction(id: any, fields: any): any;
21
- export function deleteTransaction(id: any): any;
22
- export function getAccounts(): any;
23
- export function createAccount(account: any, initialBalance: any): any;
24
- export function updateAccount(id: any, fields: any): any;
25
- export function closeAccount(id: any, transferAccountId: any, transferCategoryId: any): any;
26
- export function reopenAccount(id: any): any;
27
- export function deleteAccount(id: any): any;
28
- export function createCategoryGroup(group: any): any;
29
- export function updateCategoryGroup(id: any, fields: any): any;
30
- export function deleteCategoryGroup(id: any, transferCategoryId: any): any;
31
- export function getCategories(): any;
32
- export function createCategory(category: any): any;
33
- export function updateCategory(id: any, fields: any): any;
34
- export function deleteCategory(id: any, transferCategoryId: any): any;
35
- export function getPayees(): any;
36
- export function createPayee(payee: any): any;
37
- export function updatePayee(id: any, fields: any): any;
38
- export function deletePayee(id: any): any;
39
- export { default as q } from "./app/query";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export default function runMigration(db: any, uuid: any): Promise<void>;
package/dist/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export function amountToInteger(n: any): number;
2
- export function integerToAmount(n: any): number;
@@ -1 +0,0 @@
1
- export function validateNodeVersion(): void;