@actual-app/api 6.3.0 → 6.5.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
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable import/no-unused-modules */
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -28,6 +27,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
27
  };
29
28
  Object.defineProperty(exports, "__esModule", { value: true });
30
29
  exports.shutdown = exports.init = exports.utils = exports.methods = exports.internal = void 0;
30
+ // @ts-ignore: bundle not available until we build it
31
31
  // eslint-disable-next-line import/extensions
32
32
  const bundle = __importStar(require("./app/bundle.api.js"));
33
33
  const injected = __importStar(require("./injected"));
@@ -43,7 +43,11 @@ async function init(config = {}) {
43
43
  return;
44
44
  }
45
45
  (0, validateNodeVersion_1.validateNodeVersion)();
46
- 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
+ }
47
51
  await bundle.init(config);
48
52
  actualApp = bundle.lib;
49
53
  injected.override(bundle.lib.send);
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ moduleFileExtensions: [
3
+ 'testing.js',
4
+ 'testing.ts',
5
+ 'api.js',
6
+ 'api.ts',
7
+ 'api.tsx',
8
+ 'electron.js',
9
+ 'electron.ts',
10
+ 'mjs',
11
+ 'js',
12
+ 'ts',
13
+ 'tsx',
14
+ 'json',
15
+ ],
16
+ testEnvironment: 'node',
17
+ testPathIgnorePatterns: ['/node_modules/'],
18
+ watchPathIgnorePatterns: ['<rootDir>/mocks/budgets/'],
19
+ setupFilesAfterEnv: ['<rootDir>/../loot-core/src/mocks/setup.ts'],
20
+ transformIgnorePatterns: ['/node_modules/'],
21
+ transform: {
22
+ '^.+\\.(t|j)sx?$': '@swc/jest',
23
+ },
24
+ };
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
  }
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ // @ts-strict-ignore
27
+ const fs = __importStar(require("fs/promises"));
28
+ const path = __importStar(require("path"));
29
+ const api = __importStar(require("./index"));
30
+ const budgetName = 'test-budget';
31
+ beforeEach(async () => {
32
+ // we need real datetime if we are going to mix new timestamps with our mock data
33
+ global.restoreDateNow();
34
+ const budgetPath = path.join(__dirname, '/mocks/budgets/', budgetName);
35
+ await fs.rm(budgetPath, { force: true, recursive: true });
36
+ await createTestBudget('default-budget-template', budgetName);
37
+ await api.init({
38
+ dataDir: path.join(__dirname, '/mocks/budgets/'),
39
+ });
40
+ });
41
+ afterEach(async () => {
42
+ global.currentMonth = null;
43
+ await api.shutdown();
44
+ });
45
+ async function createTestBudget(templateName, name) {
46
+ const templatePath = path.join(__dirname, '/../loot-core/src/mocks/files', templateName);
47
+ const budgetPath = path.join(__dirname, '/mocks/budgets/', name);
48
+ await fs.mkdir(budgetPath);
49
+ await fs.copyFile(path.join(templatePath, 'metadata.json'), path.join(budgetPath, 'metadata.json'));
50
+ await fs.copyFile(path.join(templatePath, 'db.sqlite'), path.join(budgetPath, 'db.sqlite'));
51
+ }
52
+ describe('API setup and teardown', () => {
53
+ // apis: loadBudget, getBudgetMonths
54
+ test('successfully loads budget', async () => {
55
+ await expect(api.loadBudget(budgetName)).resolves.toBeUndefined();
56
+ await expect(api.getBudgetMonths()).resolves.toMatchSnapshot();
57
+ });
58
+ });
59
+ describe('API CRUD operations', () => {
60
+ beforeEach(async () => {
61
+ // load test budget
62
+ await api.loadBudget(budgetName);
63
+ });
64
+ // apis: createCategoryGroup, updateCategoryGroup, deleteCategoryGroup
65
+ test('CategoryGroups: successfully update category groups', async () => {
66
+ const month = '2023-10';
67
+ global.currentMonth = month;
68
+ // create our test category group
69
+ const mainGroupId = await api.createCategoryGroup({
70
+ name: 'test-group',
71
+ });
72
+ let budgetMonth = await api.getBudgetMonth(month);
73
+ expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
74
+ expect.objectContaining({
75
+ id: mainGroupId,
76
+ }),
77
+ ]));
78
+ // update group
79
+ await api.updateCategoryGroup(mainGroupId, {
80
+ name: 'update-tests',
81
+ });
82
+ budgetMonth = await api.getBudgetMonth(month);
83
+ expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
84
+ expect.objectContaining({
85
+ id: mainGroupId,
86
+ }),
87
+ ]));
88
+ // delete group
89
+ await api.deleteCategoryGroup(mainGroupId);
90
+ budgetMonth = await api.getBudgetMonth(month);
91
+ expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
92
+ expect.not.objectContaining({
93
+ id: mainGroupId,
94
+ }),
95
+ ]));
96
+ });
97
+ // apis: createCategory, getCategories, updateCategory, deleteCategory
98
+ test('Categories: successfully update categories', async () => {
99
+ const month = '2023-10';
100
+ global.currentMonth = month;
101
+ // create our test category group
102
+ const mainGroupId = await api.createCategoryGroup({
103
+ name: 'test-group',
104
+ });
105
+ const secondaryGroupId = await api.createCategoryGroup({
106
+ name: 'test-secondary-group',
107
+ });
108
+ const categoryId = await api.createCategory({
109
+ name: 'test-budget',
110
+ group_id: mainGroupId,
111
+ });
112
+ const categoryIdHidden = await api.createCategory({
113
+ name: 'test-budget-hidden',
114
+ group_id: mainGroupId,
115
+ hidden: true,
116
+ });
117
+ let categories = await api.getCategories();
118
+ expect(categories).toEqual(expect.arrayContaining([
119
+ expect.objectContaining({
120
+ id: categoryId,
121
+ name: 'test-budget',
122
+ hidden: false,
123
+ group_id: mainGroupId,
124
+ }),
125
+ expect.objectContaining({
126
+ id: categoryIdHidden,
127
+ name: 'test-budget-hidden',
128
+ hidden: true,
129
+ group_id: mainGroupId,
130
+ }),
131
+ ]));
132
+ // update/move category
133
+ await api.updateCategory(categoryId, {
134
+ name: 'updated-budget',
135
+ group_id: secondaryGroupId,
136
+ });
137
+ await api.updateCategory(categoryIdHidden, {
138
+ name: 'updated-budget-hidden',
139
+ group_id: secondaryGroupId,
140
+ hidden: false,
141
+ });
142
+ categories = await api.getCategories();
143
+ expect(categories).toEqual(expect.arrayContaining([
144
+ expect.objectContaining({
145
+ id: categoryId,
146
+ name: 'updated-budget',
147
+ hidden: false,
148
+ group_id: secondaryGroupId,
149
+ }),
150
+ expect.objectContaining({
151
+ id: categoryIdHidden,
152
+ name: 'updated-budget-hidden',
153
+ hidden: false,
154
+ group_id: secondaryGroupId,
155
+ }),
156
+ ]));
157
+ // delete categories
158
+ await api.deleteCategory(categoryId);
159
+ expect(categories).toEqual(expect.arrayContaining([
160
+ expect.not.objectContaining({
161
+ id: categoryId,
162
+ }),
163
+ ]));
164
+ });
165
+ // apis: setBudgetAmount, setBudgetCarryover, getBudgetMonth
166
+ test('Budgets: successfully update budgets', async () => {
167
+ const month = '2023-10';
168
+ global.currentMonth = month;
169
+ // create some new categories to test with
170
+ const groupId = await api.createCategoryGroup({
171
+ name: 'tests',
172
+ });
173
+ const categoryId = await api.createCategory({
174
+ name: 'test-budget',
175
+ group_id: groupId,
176
+ });
177
+ await api.setBudgetAmount(month, categoryId, 100);
178
+ await api.setBudgetCarryover(month, categoryId, true);
179
+ const budgetMonth = await api.getBudgetMonth(month);
180
+ expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
181
+ expect.objectContaining({
182
+ id: groupId,
183
+ categories: expect.arrayContaining([
184
+ expect.objectContaining({
185
+ id: categoryId,
186
+ budgeted: 100,
187
+ carryover: true,
188
+ }),
189
+ ]),
190
+ }),
191
+ ]));
192
+ });
193
+ //apis: createAccount, getAccounts, updateAccount, closeAccount, deleteAccount, reopenAccount
194
+ test('Accounts: successfully complete account operators', async () => {
195
+ const accountId1 = await api.createAccount({ name: 'test-account1', offbudget: true }, 1000);
196
+ const accountId2 = await api.createAccount({ name: 'test-account2' }, 0);
197
+ let accounts = await api.getAccounts();
198
+ // accounts successfully created
199
+ expect(accounts).toEqual(expect.arrayContaining([
200
+ expect.objectContaining({
201
+ id: accountId1,
202
+ name: 'test-account1',
203
+ offbudget: true,
204
+ }),
205
+ expect.objectContaining({ id: accountId2, name: 'test-account2' }),
206
+ ]));
207
+ await api.updateAccount(accountId1, { offbudget: false });
208
+ await api.closeAccount(accountId1, accountId2, null);
209
+ await api.deleteAccount(accountId2);
210
+ // accounts successfully updated, and one of them deleted
211
+ accounts = await api.getAccounts();
212
+ expect(accounts).toEqual(expect.arrayContaining([
213
+ expect.objectContaining({
214
+ id: accountId1,
215
+ name: 'test-account1',
216
+ closed: true,
217
+ offbudget: false,
218
+ }),
219
+ expect.not.objectContaining({ id: accountId2 }),
220
+ ]));
221
+ await api.reopenAccount(accountId1);
222
+ // the non-deleted account is reopened
223
+ accounts = await api.getAccounts();
224
+ expect(accounts).toEqual(expect.arrayContaining([
225
+ expect.objectContaining({
226
+ id: accountId1,
227
+ name: 'test-account1',
228
+ closed: false,
229
+ }),
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
+ });
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
  }
@@ -31,25 +31,25 @@ CREATE TABLE kvcache (key TEXT PRIMARY KEY, value TEXT);
31
31
  CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
32
32
  `);
33
33
  // Migrate budget amounts and carryover
34
- let budget = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!budget-%'`, [], true);
34
+ const budget = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!budget-%'`, [], true);
35
35
  db.transaction(() => {
36
36
  budget.forEach(monthBudget => {
37
- let match = monthBudget.name.match(/^(budget-report|budget)(\d+)!budget-(.+)$/);
37
+ const match = monthBudget.name.match(/^(budget-report|budget)(\d+)!budget-(.+)$/);
38
38
  if (match == null) {
39
39
  console.log('Warning: invalid budget month name', monthBudget.name);
40
40
  return;
41
41
  }
42
- let type = match[1];
43
- let month = match[2].slice(0, 4) + '-' + match[2].slice(4);
44
- let dbmonth = parseInt(match[2]);
45
- let cat = match[3];
42
+ const type = match[1];
43
+ const month = match[2].slice(0, 4) + '-' + match[2].slice(4);
44
+ const dbmonth = parseInt(match[2]);
45
+ const cat = match[3];
46
46
  let amount = parseInt(getValue(monthBudget));
47
47
  if (isNaN(amount)) {
48
48
  amount = 0;
49
49
  }
50
- let sheetName = monthBudget.name.split('!')[0];
51
- let carryover = db.runQuery('SELECT * FROM spreadsheet_cells WHERE name = ?', [`${sheetName}!carryover-${cat}`], true);
52
- let table = type === 'budget-report' ? 'reflect_budgets' : 'zero_budgets';
50
+ const sheetName = monthBudget.name.split('!')[0];
51
+ const carryover = db.runQuery('SELECT * FROM spreadsheet_cells WHERE name = ?', [`${sheetName}!carryover-${cat}`], true);
52
+ const table = type === 'budget-report' ? 'reflect_budgets' : 'zero_budgets';
53
53
  db.runQuery(`INSERT INTO ${table} (id, month, category, amount, carryover) VALUES (?, ?, ?, ?, ?)`, [
54
54
  `${month}-${cat}`,
55
55
  dbmonth,
@@ -60,12 +60,12 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
60
60
  });
61
61
  });
62
62
  // Migrate buffers
63
- let buffers = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!buffered'`, [], true);
63
+ const buffers = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'budget%!buffered'`, [], true);
64
64
  db.transaction(() => {
65
65
  buffers.forEach(buffer => {
66
- let match = buffer.name.match(/^budget(\d+)!buffered$/);
66
+ const match = buffer.name.match(/^budget(\d+)!buffered$/);
67
67
  if (match) {
68
- let month = match[1].slice(0, 4) + '-' + match[1].slice(4);
68
+ const month = match[1].slice(0, 4) + '-' + match[1].slice(4);
69
69
  let amount = parseInt(getValue(buffer));
70
70
  if (isNaN(amount)) {
71
71
  amount = 0;
@@ -75,10 +75,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
75
75
  });
76
76
  });
77
77
  // Migrate notes
78
- let notes = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'notes!%'`, [], true);
79
- let parseNote = str => {
78
+ const notes = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'notes!%'`, [], true);
79
+ const parseNote = str => {
80
80
  try {
81
- let value = JSON.parse(str);
81
+ const value = JSON.parse(str);
82
82
  return value && value !== '' ? value : null;
83
83
  }
84
84
  catch (e) {
@@ -87,9 +87,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
87
87
  };
88
88
  db.transaction(() => {
89
89
  notes.forEach(note => {
90
- let parsed = parseNote(getValue(note));
90
+ const parsed = parseNote(getValue(note));
91
91
  if (parsed) {
92
- let [, id] = note.name.split('!');
92
+ const [, id] = note.name.split('!');
93
93
  db.runQuery(`INSERT INTO notes (id, note) VALUES (?, ?)`, [id, parsed]);
94
94
  }
95
95
  });
@@ -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;
package/dist/package.json CHANGED
@@ -1,31 +1,38 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.3.0",
3
+ "version": "6.5.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"
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"
20
22
  },
21
23
  "dependencies": {
22
- "better-sqlite3": "^9.1.1",
24
+ "better-sqlite3": "^9.2.2",
23
25
  "compare-versions": "^6.1.0",
24
26
  "node-fetch": "^3.3.2",
25
27
  "uuid": "^9.0.0"
26
28
  },
27
29
  "devDependencies": {
30
+ "@swc/core": "^1.3.105",
31
+ "@swc/jest": "^0.2.31",
32
+ "@types/jest": "^27.5.0",
28
33
  "@types/uuid": "^9.0.2",
34
+ "jest": "^27.0.0",
35
+ "tsc-alias": "^1.8.8",
29
36
  "typescript": "^5.0.2"
30
37
  }
31
38
  }
package/package.json CHANGED
@@ -1,31 +1,38 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.3.0",
3
+ "version": "6.5.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"
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"
20
22
  },
21
23
  "dependencies": {
22
- "better-sqlite3": "^9.1.1",
24
+ "better-sqlite3": "^9.2.2",
23
25
  "compare-versions": "^6.1.0",
24
26
  "node-fetch": "^3.3.2",
25
27
  "uuid": "^9.0.0"
26
28
  },
27
29
  "devDependencies": {
30
+ "@swc/core": "^1.3.105",
31
+ "@swc/jest": "^0.2.31",
32
+ "@types/jest": "^27.5.0",
28
33
  "@types/uuid": "^9.0.2",
34
+ "jest": "^27.0.0",
35
+ "tsc-alias": "^1.8.8",
29
36
  "typescript": "^5.0.2"
30
37
  }
31
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;