@actual-app/api 6.2.1 → 6.4.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/bundle.api.js +39693 -30682
- package/dist/app/query.js +3 -3
- package/dist/index.js +2 -1
- package/dist/jest.config.d.ts +9 -0
- package/dist/jest.config.js +24 -0
- package/dist/methods.d.ts +4 -1
- package/dist/methods.js +7 -2
- package/dist/methods.test.d.ts +1 -0
- package/dist/methods.test.js +231 -0
- package/dist/migrations/1632571489012_remove_cache.js +17 -17
- package/dist/migrations/1694438752000_add_goal_targets.sql +7 -0
- package/dist/migrations/1697046240000_add_reconciled.sql +5 -0
- package/dist/package.json +36 -0
- package/dist/validateNodeVersion.d.ts +1 -0
- package/dist/validateNodeVersion.js +38 -0
- package/package.json +12 -3
package/dist/app/query.js
CHANGED
|
@@ -23,7 +23,7 @@ class Query {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
unfilter(exprs) {
|
|
26
|
-
|
|
26
|
+
const exprSet = new Set(exprs);
|
|
27
27
|
return new Query({
|
|
28
28
|
...this.state,
|
|
29
29
|
filterExpressions: this.state.filterExpressions.filter(expr => !exprSet.has(Object.keys(expr)[0])),
|
|
@@ -33,12 +33,12 @@ class Query {
|
|
|
33
33
|
if (!Array.isArray(exprs)) {
|
|
34
34
|
exprs = [exprs];
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
const query = new Query({ ...this.state, selectExpressions: exprs });
|
|
37
37
|
query.state.calculation = false;
|
|
38
38
|
return query;
|
|
39
39
|
}
|
|
40
40
|
calculate(expr) {
|
|
41
|
-
|
|
41
|
+
const query = this.select({ result: expr });
|
|
42
42
|
query.state.calculation = true;
|
|
43
43
|
return query;
|
|
44
44
|
}
|
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);
|
|
@@ -31,6 +30,7 @@ exports.shutdown = exports.init = exports.utils = exports.methods = exports.inte
|
|
|
31
30
|
// eslint-disable-next-line import/extensions
|
|
32
31
|
const bundle = __importStar(require("./app/bundle.api.js"));
|
|
33
32
|
const injected = __importStar(require("./injected"));
|
|
33
|
+
const validateNodeVersion_1 = require("./validateNodeVersion");
|
|
34
34
|
let actualApp;
|
|
35
35
|
exports.internal = bundle.lib;
|
|
36
36
|
// DEPRECATED: remove the next line in @actual-app/api v7
|
|
@@ -41,6 +41,7 @@ async function init(config = {}) {
|
|
|
41
41
|
if (actualApp) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
+
(0, validateNodeVersion_1.validateNodeVersion)();
|
|
44
45
|
global.fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
|
|
45
46
|
await bundle.init(config);
|
|
46
47
|
actualApp = bundle.lib;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
};
|
|
@@ -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.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ export function getBudgetMonths(): any;
|
|
|
10
10
|
export function getBudgetMonth(month: any): any;
|
|
11
11
|
export function setBudgetAmount(month: any, categoryId: any, value: any): any;
|
|
12
12
|
export function setBudgetCarryover(month: any, categoryId: any, flag: any): any;
|
|
13
|
-
export function addTransactions(accountId: any, transactions: any
|
|
13
|
+
export function addTransactions(accountId: any, transactions: any, { learnCategories, runTransfers }?: {
|
|
14
|
+
learnCategories?: boolean;
|
|
15
|
+
runTransfers?: boolean;
|
|
16
|
+
}): any;
|
|
14
17
|
export function importTransactions(accountId: any, transactions: any): any;
|
|
15
18
|
export function getTransactions(accountId: any, startDate: any, endDate: any): any;
|
|
16
19
|
export function filterTransactions(accountId: any, text: any): any;
|
package/dist/methods.js
CHANGED
|
@@ -87,8 +87,13 @@ function setBudgetCarryover(month, categoryId, flag) {
|
|
|
87
87
|
return send('api/budget-set-carryover', { month, categoryId, flag });
|
|
88
88
|
}
|
|
89
89
|
exports.setBudgetCarryover = setBudgetCarryover;
|
|
90
|
-
function addTransactions(accountId, transactions) {
|
|
91
|
-
return send('api/transactions-add', {
|
|
90
|
+
function addTransactions(accountId, transactions, { learnCategories = false, runTransfers = false } = {}) {
|
|
91
|
+
return send('api/transactions-add', {
|
|
92
|
+
accountId,
|
|
93
|
+
transactions,
|
|
94
|
+
learnCategories,
|
|
95
|
+
runTransfers,
|
|
96
|
+
});
|
|
92
97
|
}
|
|
93
98
|
exports.addTransactions = addTransactions;
|
|
94
99
|
function importTransactions(accountId, transactions) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,231 @@
|
|
|
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
|
+
const fs = __importStar(require("fs/promises"));
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const api = __importStar(require("./index"));
|
|
29
|
+
const budgetName = 'test-budget';
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
// we need real datetime if we are going to mix new timestamps with our mock data
|
|
32
|
+
global.restoreDateNow();
|
|
33
|
+
const budgetPath = path.join(__dirname, '/mocks/budgets/', budgetName);
|
|
34
|
+
await fs.rm(budgetPath, { force: true, recursive: true });
|
|
35
|
+
await createTestBudget('default-budget-template', budgetName);
|
|
36
|
+
await api.init({
|
|
37
|
+
dataDir: path.join(__dirname, '/mocks/budgets/'),
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
afterEach(async () => {
|
|
41
|
+
global.currentMonth = null;
|
|
42
|
+
await api.shutdown();
|
|
43
|
+
});
|
|
44
|
+
async function createTestBudget(templateName, name) {
|
|
45
|
+
const templatePath = path.join(__dirname, '/../loot-core/src/mocks/files', templateName);
|
|
46
|
+
const budgetPath = path.join(__dirname, '/mocks/budgets/', name);
|
|
47
|
+
await fs.mkdir(budgetPath);
|
|
48
|
+
await fs.copyFile(path.join(templatePath, 'metadata.json'), path.join(budgetPath, 'metadata.json'));
|
|
49
|
+
await fs.copyFile(path.join(templatePath, 'db.sqlite'), path.join(budgetPath, 'db.sqlite'));
|
|
50
|
+
}
|
|
51
|
+
describe('API setup and teardown', () => {
|
|
52
|
+
// apis: loadBudget, getBudgetMonths
|
|
53
|
+
test('successfully loads budget', async () => {
|
|
54
|
+
await expect(api.loadBudget(budgetName)).resolves.toBeUndefined();
|
|
55
|
+
await expect(api.getBudgetMonths()).resolves.toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('API CRUD operations', () => {
|
|
59
|
+
beforeEach(async () => {
|
|
60
|
+
// load test budget
|
|
61
|
+
await api.loadBudget(budgetName);
|
|
62
|
+
});
|
|
63
|
+
// apis: createCategoryGroup, updateCategoryGroup, deleteCategoryGroup
|
|
64
|
+
test('CategoryGroups: successfully update category groups', async () => {
|
|
65
|
+
const month = '2023-10';
|
|
66
|
+
global.currentMonth = month;
|
|
67
|
+
// create our test category group
|
|
68
|
+
const mainGroupId = await api.createCategoryGroup({
|
|
69
|
+
name: 'test-group',
|
|
70
|
+
});
|
|
71
|
+
let budgetMonth = await api.getBudgetMonth(month);
|
|
72
|
+
expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
|
|
73
|
+
expect.objectContaining({
|
|
74
|
+
id: mainGroupId,
|
|
75
|
+
}),
|
|
76
|
+
]));
|
|
77
|
+
// update group
|
|
78
|
+
await api.updateCategoryGroup(mainGroupId, {
|
|
79
|
+
name: 'update-tests',
|
|
80
|
+
});
|
|
81
|
+
budgetMonth = await api.getBudgetMonth(month);
|
|
82
|
+
expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
|
|
83
|
+
expect.objectContaining({
|
|
84
|
+
id: mainGroupId,
|
|
85
|
+
}),
|
|
86
|
+
]));
|
|
87
|
+
// delete group
|
|
88
|
+
await api.deleteCategoryGroup(mainGroupId);
|
|
89
|
+
budgetMonth = await api.getBudgetMonth(month);
|
|
90
|
+
expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
|
|
91
|
+
expect.not.objectContaining({
|
|
92
|
+
id: mainGroupId,
|
|
93
|
+
}),
|
|
94
|
+
]));
|
|
95
|
+
});
|
|
96
|
+
// apis: createCategory, getCategories, updateCategory, deleteCategory
|
|
97
|
+
test('Categories: successfully update categories', async () => {
|
|
98
|
+
const month = '2023-10';
|
|
99
|
+
global.currentMonth = month;
|
|
100
|
+
// create our test category group
|
|
101
|
+
const mainGroupId = await api.createCategoryGroup({
|
|
102
|
+
name: 'test-group',
|
|
103
|
+
});
|
|
104
|
+
const secondaryGroupId = await api.createCategoryGroup({
|
|
105
|
+
name: 'test-secondary-group',
|
|
106
|
+
});
|
|
107
|
+
const categoryId = await api.createCategory({
|
|
108
|
+
name: 'test-budget',
|
|
109
|
+
group_id: mainGroupId,
|
|
110
|
+
});
|
|
111
|
+
const categoryIdHidden = await api.createCategory({
|
|
112
|
+
name: 'test-budget-hidden',
|
|
113
|
+
group_id: mainGroupId,
|
|
114
|
+
hidden: true,
|
|
115
|
+
});
|
|
116
|
+
let categories = await api.getCategories();
|
|
117
|
+
expect(categories).toEqual(expect.arrayContaining([
|
|
118
|
+
expect.objectContaining({
|
|
119
|
+
id: categoryId,
|
|
120
|
+
name: 'test-budget',
|
|
121
|
+
hidden: false,
|
|
122
|
+
group_id: mainGroupId,
|
|
123
|
+
}),
|
|
124
|
+
expect.objectContaining({
|
|
125
|
+
id: categoryIdHidden,
|
|
126
|
+
name: 'test-budget-hidden',
|
|
127
|
+
hidden: true,
|
|
128
|
+
group_id: mainGroupId,
|
|
129
|
+
}),
|
|
130
|
+
]));
|
|
131
|
+
// update/move category
|
|
132
|
+
await api.updateCategory(categoryId, {
|
|
133
|
+
name: 'updated-budget',
|
|
134
|
+
group_id: secondaryGroupId,
|
|
135
|
+
});
|
|
136
|
+
await api.updateCategory(categoryIdHidden, {
|
|
137
|
+
name: 'updated-budget-hidden',
|
|
138
|
+
group_id: secondaryGroupId,
|
|
139
|
+
hidden: false,
|
|
140
|
+
});
|
|
141
|
+
categories = await api.getCategories();
|
|
142
|
+
expect(categories).toEqual(expect.arrayContaining([
|
|
143
|
+
expect.objectContaining({
|
|
144
|
+
id: categoryId,
|
|
145
|
+
name: 'updated-budget',
|
|
146
|
+
hidden: false,
|
|
147
|
+
group_id: secondaryGroupId,
|
|
148
|
+
}),
|
|
149
|
+
expect.objectContaining({
|
|
150
|
+
id: categoryIdHidden,
|
|
151
|
+
name: 'updated-budget-hidden',
|
|
152
|
+
hidden: false,
|
|
153
|
+
group_id: secondaryGroupId,
|
|
154
|
+
}),
|
|
155
|
+
]));
|
|
156
|
+
// delete categories
|
|
157
|
+
await api.deleteCategory(categoryId);
|
|
158
|
+
expect(categories).toEqual(expect.arrayContaining([
|
|
159
|
+
expect.not.objectContaining({
|
|
160
|
+
id: categoryId,
|
|
161
|
+
}),
|
|
162
|
+
]));
|
|
163
|
+
});
|
|
164
|
+
// apis: setBudgetAmount, setBudgetCarryover, getBudgetMonth
|
|
165
|
+
test('Budgets: successfully update budgets', async () => {
|
|
166
|
+
const month = '2023-10';
|
|
167
|
+
global.currentMonth = month;
|
|
168
|
+
// create some new categories to test with
|
|
169
|
+
const groupId = await api.createCategoryGroup({
|
|
170
|
+
name: 'tests',
|
|
171
|
+
});
|
|
172
|
+
const categoryId = await api.createCategory({
|
|
173
|
+
name: 'test-budget',
|
|
174
|
+
group_id: groupId,
|
|
175
|
+
});
|
|
176
|
+
await api.setBudgetAmount(month, categoryId, 100);
|
|
177
|
+
await api.setBudgetCarryover(month, categoryId, true);
|
|
178
|
+
const budgetMonth = await api.getBudgetMonth(month);
|
|
179
|
+
expect(budgetMonth.categoryGroups).toEqual(expect.arrayContaining([
|
|
180
|
+
expect.objectContaining({
|
|
181
|
+
id: groupId,
|
|
182
|
+
categories: expect.arrayContaining([
|
|
183
|
+
expect.objectContaining({
|
|
184
|
+
id: categoryId,
|
|
185
|
+
budgeted: 100,
|
|
186
|
+
carryover: true,
|
|
187
|
+
}),
|
|
188
|
+
]),
|
|
189
|
+
}),
|
|
190
|
+
]));
|
|
191
|
+
});
|
|
192
|
+
//apis: createAccount, getAccounts, updateAccount, closeAccount, deleteAccount, reopenAccount
|
|
193
|
+
test('Accounts: successfully complete account operators', async () => {
|
|
194
|
+
const accountId1 = await api.createAccount({ name: 'test-account1', offbudget: true }, 1000);
|
|
195
|
+
const accountId2 = await api.createAccount({ name: 'test-account2' }, 0);
|
|
196
|
+
let accounts = await api.getAccounts();
|
|
197
|
+
// accounts successfully created
|
|
198
|
+
expect(accounts).toEqual(expect.arrayContaining([
|
|
199
|
+
expect.objectContaining({
|
|
200
|
+
id: accountId1,
|
|
201
|
+
name: 'test-account1',
|
|
202
|
+
offbudget: true,
|
|
203
|
+
}),
|
|
204
|
+
expect.objectContaining({ id: accountId2, name: 'test-account2' }),
|
|
205
|
+
]));
|
|
206
|
+
await api.updateAccount(accountId1, { offbudget: false });
|
|
207
|
+
await api.closeAccount(accountId1, accountId2, null);
|
|
208
|
+
await api.deleteAccount(accountId2);
|
|
209
|
+
// accounts successfully updated, and one of them deleted
|
|
210
|
+
accounts = await api.getAccounts();
|
|
211
|
+
expect(accounts).toEqual(expect.arrayContaining([
|
|
212
|
+
expect.objectContaining({
|
|
213
|
+
id: accountId1,
|
|
214
|
+
name: 'test-account1',
|
|
215
|
+
closed: true,
|
|
216
|
+
offbudget: false,
|
|
217
|
+
}),
|
|
218
|
+
expect.not.objectContaining({ id: accountId2 }),
|
|
219
|
+
]));
|
|
220
|
+
await api.reopenAccount(accountId1);
|
|
221
|
+
// the non-deleted account is reopened
|
|
222
|
+
accounts = await api.getAccounts();
|
|
223
|
+
expect(accounts).toEqual(expect.arrayContaining([
|
|
224
|
+
expect.objectContaining({
|
|
225
|
+
id: accountId1,
|
|
226
|
+
name: 'test-account1',
|
|
227
|
+
closed: false,
|
|
228
|
+
}),
|
|
229
|
+
]));
|
|
230
|
+
});
|
|
231
|
+
});
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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
|
-
|
|
66
|
+
const match = buffer.name.match(/^budget(\d+)!buffered$/);
|
|
67
67
|
if (match) {
|
|
68
|
-
|
|
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
|
-
|
|
79
|
-
|
|
78
|
+
const notes = db.runQuery(`SELECT * FROM spreadsheet_cells WHERE name LIKE 'notes!%'`, [], true);
|
|
79
|
+
const parseNote = str => {
|
|
80
80
|
try {
|
|
81
|
-
|
|
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
|
-
|
|
90
|
+
const parsed = parseNote(getValue(note));
|
|
91
91
|
if (parsed) {
|
|
92
|
-
|
|
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,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@actual-app/api",
|
|
3
|
+
"version": "6.4.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "An API for Actual",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=18.12.0"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build:app": "yarn workspace loot-core build:api",
|
|
16
|
+
"build:node": "tsc --p tsconfig.dist.json",
|
|
17
|
+
"build:migrations": "cp migrations/*.sql dist/migrations",
|
|
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"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"better-sqlite3": "^9.1.1",
|
|
24
|
+
"compare-versions": "^6.1.0",
|
|
25
|
+
"node-fetch": "^3.3.2",
|
|
26
|
+
"uuid": "^9.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@swc/core": "^1.3.82",
|
|
30
|
+
"@swc/jest": "^0.2.29",
|
|
31
|
+
"@types/jest": "^27.5.0",
|
|
32
|
+
"@types/uuid": "^9.0.2",
|
|
33
|
+
"jest": "^27.0.0",
|
|
34
|
+
"typescript": "^5.0.2"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function validateNodeVersion(): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
exports.validateNodeVersion = void 0;
|
|
27
|
+
const compare_versions_1 = require("compare-versions");
|
|
28
|
+
const packageJson = __importStar(require("./package.json"));
|
|
29
|
+
function validateNodeVersion() {
|
|
30
|
+
if (process?.versions?.node) {
|
|
31
|
+
const nodeVersion = process?.versions?.node;
|
|
32
|
+
const minimumNodeVersion = packageJson.engines.node;
|
|
33
|
+
if (!(0, compare_versions_1.satisfies)(nodeVersion, minimumNodeVersion)) {
|
|
34
|
+
throw new Error(`@actual-app/api requires a node version ${minimumNodeVersion}. Found that you are using: ${nodeVersion}. Please upgrade to a higher version`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.validateNodeVersion = validateNodeVersion;
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actual-app/api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "An API for Actual",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=18.12.0"
|
|
8
|
+
},
|
|
6
9
|
"main": "dist/index.js",
|
|
7
10
|
"types": "dist/index.d.ts",
|
|
8
11
|
"files": [
|
|
@@ -13,15 +16,21 @@
|
|
|
13
16
|
"build:node": "tsc --p tsconfig.dist.json",
|
|
14
17
|
"build:migrations": "cp migrations/*.sql dist/migrations",
|
|
15
18
|
"build:default-db": "cp default-db.sqlite dist/",
|
|
16
|
-
"build": "rm -rf dist && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db"
|
|
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"
|
|
17
21
|
},
|
|
18
22
|
"dependencies": {
|
|
19
|
-
"better-sqlite3": "^
|
|
23
|
+
"better-sqlite3": "^9.1.1",
|
|
24
|
+
"compare-versions": "^6.1.0",
|
|
20
25
|
"node-fetch": "^3.3.2",
|
|
21
26
|
"uuid": "^9.0.0"
|
|
22
27
|
},
|
|
23
28
|
"devDependencies": {
|
|
29
|
+
"@swc/core": "^1.3.82",
|
|
30
|
+
"@swc/jest": "^0.2.29",
|
|
31
|
+
"@types/jest": "^27.5.0",
|
|
24
32
|
"@types/uuid": "^9.0.2",
|
|
33
|
+
"jest": "^27.0.0",
|
|
25
34
|
"typescript": "^5.0.2"
|
|
26
35
|
}
|
|
27
36
|
}
|