@actual-app/api 6.9.0 → 6.10.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/@types/jest.config.d.ts +7 -7
- package/@types/loot-core/client/constants.d.ts +1 -0
- package/@types/loot-core/client/state-types/index.d.ts +1 -1
- package/@types/loot-core/client/state-types/modals.d.ts +18 -6
- package/@types/loot-core/client/state-types/notifications.d.ts +18 -1
- package/@types/loot-core/client/state-types/prefs.d.ts +9 -4
- package/@types/loot-core/server/accounts/parse-file.d.ts +1 -0
- package/@types/loot-core/server/accounts/rules.d.ts +2 -2
- package/@types/loot-core/server/accounts/sync.d.ts +2 -2
- package/@types/loot-core/server/accounts/transaction-rules.d.ts +1 -3
- package/@types/loot-core/server/accounts/transactions.d.ts +3 -5
- package/@types/loot-core/server/api-models.d.ts +6 -6
- package/@types/loot-core/server/aql/schema/index.d.ts +26 -3
- package/@types/loot-core/server/budget/statements.d.ts +9 -0
- package/@types/loot-core/server/budget/template-notes.d.ts +5 -0
- package/@types/loot-core/server/budget/types/templates.d.ts +82 -0
- package/@types/loot-core/server/cloud-storage.d.ts +0 -1
- package/@types/loot-core/server/dashboard/app.d.ts +12 -0
- package/@types/loot-core/server/dashboard/types/handlers.d.ts +24 -0
- package/@types/loot-core/server/db/index.d.ts +3 -2
- package/@types/loot-core/server/db/types.d.ts +9 -0
- package/@types/loot-core/server/encryption-internals.d.ts +0 -1
- package/@types/loot-core/server/encryption-internals.web.d.ts +0 -1
- package/@types/loot-core/server/encryption.d.ts +0 -1
- package/@types/loot-core/server/errors.d.ts +2 -0
- package/@types/loot-core/server/importers/actual.d.ts +0 -1
- package/@types/loot-core/server/importers/index.d.ts +0 -1
- package/@types/loot-core/server/importers/ynab4.d.ts +0 -1
- package/@types/loot-core/server/importers/ynab5.d.ts +0 -1
- package/@types/loot-core/server/main-app.d.ts +1 -1
- package/@types/loot-core/server/models.d.ts +4 -4
- package/@types/loot-core/server/prefs.d.ts +7 -2
- package/@types/loot-core/server/reports/app.d.ts +46 -0
- package/@types/loot-core/server/rules/types/handlers.d.ts +4 -6
- package/@types/loot-core/server/sync/make-test-message.d.ts +0 -1
- package/@types/loot-core/shared/dashboard.d.ts +2 -0
- package/@types/loot-core/shared/months.d.ts +7 -6
- package/@types/loot-core/shared/rules.d.ts +5 -1
- package/@types/loot-core/shared/schedules.d.ts +22 -22
- package/@types/loot-core/shared/transactions.d.ts +24 -73
- package/@types/loot-core/shared/util.d.ts +9 -12
- package/@types/loot-core/types/api-handlers.d.ts +14 -3
- package/@types/loot-core/types/handlers.d.ts +2 -0
- package/@types/loot-core/types/models/category-group.d.ts +6 -2
- package/@types/loot-core/types/models/category.d.ts +4 -2
- package/@types/loot-core/types/models/dashboard.d.ts +56 -0
- package/@types/loot-core/types/models/index.d.ts +1 -0
- package/@types/loot-core/types/models/payee.d.ts +5 -7
- package/@types/loot-core/types/models/reports.d.ts +2 -5
- package/@types/loot-core/types/models/rule.d.ts +100 -7
- package/@types/loot-core/types/models/transaction.d.ts +12 -25
- package/@types/loot-core/types/prefs.d.ts +44 -22
- package/@types/loot-core/types/server-handlers.d.ts +5 -7
- package/@types/loot-core/types/util.d.ts +4 -0
- package/@types/methods.d.ts +4 -11
- package/@types/migrations/1722717601000_reports_move_selected_categories.d.ts +1 -0
- package/@types/migrations/1722804019000_create_dashboard_table.d.ts +1 -0
- package/dist/app/bundle.api.js +4620 -1320
- package/dist/app/query.js +1 -2
- package/dist/index.js +3 -3
- package/dist/injected.js +2 -2
- package/dist/methods.js +53 -45
- package/dist/methods.test.js +8 -14
- package/dist/migrations/1632571489012_remove_cache.js +1 -1
- package/dist/migrations/1722717601000_reports_move_selected_categories.js +39 -0
- package/dist/migrations/1722804019000_create_dashboard_table.js +38 -0
- package/dist/package.json +2 -2
- package/dist/utils.js +2 -3
- package/dist/validateNodeVersion.js +1 -2
- package/package.json +2 -2
package/dist/app/query.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.q =
|
|
3
|
+
exports.q = q;
|
|
4
4
|
class Query {
|
|
5
5
|
constructor(state) {
|
|
6
6
|
this.state = {
|
|
@@ -86,4 +86,3 @@ class Query {
|
|
|
86
86
|
function q(table) {
|
|
87
87
|
return new Query({ table });
|
|
88
88
|
}
|
|
89
|
-
exports.q = q;
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.utils = exports.methods = exports.internal = void 0;
|
|
30
|
+
exports.init = init;
|
|
31
|
+
exports.shutdown = shutdown;
|
|
30
32
|
// @ts-ignore: bundle not available until we build it
|
|
31
33
|
// eslint-disable-next-line import/extensions
|
|
32
34
|
const bundle = __importStar(require("./app/bundle.api.js"));
|
|
@@ -53,7 +55,6 @@ async function init(config = {}) {
|
|
|
53
55
|
injected.override(bundle.lib.send);
|
|
54
56
|
return bundle.lib;
|
|
55
57
|
}
|
|
56
|
-
exports.init = init;
|
|
57
58
|
async function shutdown() {
|
|
58
59
|
if (actualApp) {
|
|
59
60
|
await actualApp.send('sync');
|
|
@@ -61,4 +62,3 @@ async function shutdown() {
|
|
|
61
62
|
actualApp = null;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
exports.shutdown = shutdown;
|
package/dist/injected.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// TODO: comment on why it works this way
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.send = void 0;
|
|
5
|
+
exports.override = override;
|
|
5
6
|
function override(sendImplementation) {
|
|
6
7
|
exports.send = sendImplementation;
|
|
7
8
|
}
|
|
8
|
-
exports.override = override;
|
package/dist/methods.js
CHANGED
|
@@ -23,7 +23,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.q = void 0;
|
|
27
|
+
exports.runImport = runImport;
|
|
28
|
+
exports.loadBudget = loadBudget;
|
|
29
|
+
exports.downloadBudget = downloadBudget;
|
|
30
|
+
exports.getBudgets = getBudgets;
|
|
31
|
+
exports.sync = sync;
|
|
32
|
+
exports.runBankSync = runBankSync;
|
|
33
|
+
exports.batchBudgetUpdates = batchBudgetUpdates;
|
|
34
|
+
exports.runQuery = runQuery;
|
|
35
|
+
exports.getBudgetMonths = getBudgetMonths;
|
|
36
|
+
exports.getBudgetMonth = getBudgetMonth;
|
|
37
|
+
exports.setBudgetAmount = setBudgetAmount;
|
|
38
|
+
exports.setBudgetCarryover = setBudgetCarryover;
|
|
39
|
+
exports.addTransactions = addTransactions;
|
|
40
|
+
exports.importTransactions = importTransactions;
|
|
41
|
+
exports.getTransactions = getTransactions;
|
|
42
|
+
exports.updateTransaction = updateTransaction;
|
|
43
|
+
exports.deleteTransaction = deleteTransaction;
|
|
44
|
+
exports.getAccounts = getAccounts;
|
|
45
|
+
exports.createAccount = createAccount;
|
|
46
|
+
exports.updateAccount = updateAccount;
|
|
47
|
+
exports.closeAccount = closeAccount;
|
|
48
|
+
exports.reopenAccount = reopenAccount;
|
|
49
|
+
exports.deleteAccount = deleteAccount;
|
|
50
|
+
exports.getAccountBalance = getAccountBalance;
|
|
51
|
+
exports.getCategoryGroups = getCategoryGroups;
|
|
52
|
+
exports.createCategoryGroup = createCategoryGroup;
|
|
53
|
+
exports.updateCategoryGroup = updateCategoryGroup;
|
|
54
|
+
exports.deleteCategoryGroup = deleteCategoryGroup;
|
|
55
|
+
exports.getCategories = getCategories;
|
|
56
|
+
exports.createCategory = createCategory;
|
|
57
|
+
exports.updateCategory = updateCategory;
|
|
58
|
+
exports.deleteCategory = deleteCategory;
|
|
59
|
+
exports.getCommonPayees = getCommonPayees;
|
|
60
|
+
exports.getPayees = getPayees;
|
|
61
|
+
exports.createPayee = createPayee;
|
|
62
|
+
exports.updatePayee = updatePayee;
|
|
63
|
+
exports.deletePayee = deletePayee;
|
|
64
|
+
exports.mergePayees = mergePayees;
|
|
65
|
+
exports.getRules = getRules;
|
|
66
|
+
exports.getPayeeRules = getPayeeRules;
|
|
67
|
+
exports.createRule = createRule;
|
|
68
|
+
exports.updateRule = updateRule;
|
|
69
|
+
exports.deleteRule = deleteRule;
|
|
70
|
+
exports.holdBudgetForNextMonth = holdBudgetForNextMonth;
|
|
71
|
+
exports.resetBudgetHold = resetBudgetHold;
|
|
27
72
|
const injected = __importStar(require("./injected"));
|
|
28
73
|
var query_1 = require("./app/query");
|
|
29
74
|
Object.defineProperty(exports, "q", { enumerable: true, get: function () { return query_1.q; } });
|
|
@@ -41,27 +86,21 @@ async function runImport(name, func) {
|
|
|
41
86
|
}
|
|
42
87
|
await send('api/finish-import');
|
|
43
88
|
}
|
|
44
|
-
exports.runImport = runImport;
|
|
45
89
|
async function loadBudget(budgetId) {
|
|
46
90
|
return send('api/load-budget', { id: budgetId });
|
|
47
91
|
}
|
|
48
|
-
exports.loadBudget = loadBudget;
|
|
49
92
|
async function downloadBudget(syncId, { password } = {}) {
|
|
50
93
|
return send('api/download-budget', { syncId, password });
|
|
51
94
|
}
|
|
52
|
-
exports.downloadBudget = downloadBudget;
|
|
53
95
|
async function getBudgets() {
|
|
54
96
|
return send('api/get-budgets');
|
|
55
97
|
}
|
|
56
|
-
exports.getBudgets = getBudgets;
|
|
57
98
|
async function sync() {
|
|
58
99
|
return send('api/sync');
|
|
59
100
|
}
|
|
60
|
-
exports.sync = sync;
|
|
61
101
|
async function runBankSync(args) {
|
|
62
102
|
return send('api/bank-sync', args);
|
|
63
103
|
}
|
|
64
|
-
exports.runBankSync = runBankSync;
|
|
65
104
|
async function batchBudgetUpdates(func) {
|
|
66
105
|
await send('api/batch-budget-start');
|
|
67
106
|
try {
|
|
@@ -71,27 +110,21 @@ async function batchBudgetUpdates(func) {
|
|
|
71
110
|
await send('api/batch-budget-end');
|
|
72
111
|
}
|
|
73
112
|
}
|
|
74
|
-
exports.batchBudgetUpdates = batchBudgetUpdates;
|
|
75
113
|
function runQuery(query) {
|
|
76
114
|
return send('api/query', { query: query.serialize() });
|
|
77
115
|
}
|
|
78
|
-
exports.runQuery = runQuery;
|
|
79
116
|
function getBudgetMonths() {
|
|
80
117
|
return send('api/budget-months');
|
|
81
118
|
}
|
|
82
|
-
exports.getBudgetMonths = getBudgetMonths;
|
|
83
119
|
function getBudgetMonth(month) {
|
|
84
120
|
return send('api/budget-month', { month });
|
|
85
121
|
}
|
|
86
|
-
exports.getBudgetMonth = getBudgetMonth;
|
|
87
122
|
function setBudgetAmount(month, categoryId, value) {
|
|
88
123
|
return send('api/budget-set-amount', { month, categoryId, amount: value });
|
|
89
124
|
}
|
|
90
|
-
exports.setBudgetAmount = setBudgetAmount;
|
|
91
125
|
function setBudgetCarryover(month, categoryId, flag) {
|
|
92
126
|
return send('api/budget-set-carryover', { month, categoryId, flag });
|
|
93
127
|
}
|
|
94
|
-
exports.setBudgetCarryover = setBudgetCarryover;
|
|
95
128
|
function addTransactions(accountId, transactions, { learnCategories = false, runTransfers = false } = {}) {
|
|
96
129
|
return send('api/transactions-add', {
|
|
97
130
|
accountId,
|
|
@@ -100,35 +133,27 @@ function addTransactions(accountId, transactions, { learnCategories = false, run
|
|
|
100
133
|
runTransfers,
|
|
101
134
|
});
|
|
102
135
|
}
|
|
103
|
-
exports.addTransactions = addTransactions;
|
|
104
136
|
function importTransactions(accountId, transactions) {
|
|
105
137
|
return send('api/transactions-import', { accountId, transactions });
|
|
106
138
|
}
|
|
107
|
-
exports.importTransactions = importTransactions;
|
|
108
139
|
function getTransactions(accountId, startDate, endDate) {
|
|
109
140
|
return send('api/transactions-get', { accountId, startDate, endDate });
|
|
110
141
|
}
|
|
111
|
-
exports.getTransactions = getTransactions;
|
|
112
142
|
function updateTransaction(id, fields) {
|
|
113
143
|
return send('api/transaction-update', { id, fields });
|
|
114
144
|
}
|
|
115
|
-
exports.updateTransaction = updateTransaction;
|
|
116
145
|
function deleteTransaction(id) {
|
|
117
146
|
return send('api/transaction-delete', { id });
|
|
118
147
|
}
|
|
119
|
-
exports.deleteTransaction = deleteTransaction;
|
|
120
148
|
function getAccounts() {
|
|
121
149
|
return send('api/accounts-get');
|
|
122
150
|
}
|
|
123
|
-
exports.getAccounts = getAccounts;
|
|
124
151
|
function createAccount(account, initialBalance) {
|
|
125
152
|
return send('api/account-create', { account, initialBalance });
|
|
126
153
|
}
|
|
127
|
-
exports.createAccount = createAccount;
|
|
128
154
|
function updateAccount(id, fields) {
|
|
129
155
|
return send('api/account-update', { id, fields });
|
|
130
156
|
}
|
|
131
|
-
exports.updateAccount = updateAccount;
|
|
132
157
|
function closeAccount(id, transferAccountId, transferCategoryId) {
|
|
133
158
|
return send('api/account-close', {
|
|
134
159
|
id,
|
|
@@ -136,92 +161,75 @@ function closeAccount(id, transferAccountId, transferCategoryId) {
|
|
|
136
161
|
transferCategoryId,
|
|
137
162
|
});
|
|
138
163
|
}
|
|
139
|
-
exports.closeAccount = closeAccount;
|
|
140
164
|
function reopenAccount(id) {
|
|
141
165
|
return send('api/account-reopen', { id });
|
|
142
166
|
}
|
|
143
|
-
exports.reopenAccount = reopenAccount;
|
|
144
167
|
function deleteAccount(id) {
|
|
145
168
|
return send('api/account-delete', { id });
|
|
146
169
|
}
|
|
147
|
-
exports.deleteAccount = deleteAccount;
|
|
148
170
|
function getAccountBalance(id, cutoff) {
|
|
149
171
|
return send('api/account-balance', { id, cutoff });
|
|
150
172
|
}
|
|
151
|
-
exports.getAccountBalance = getAccountBalance;
|
|
152
173
|
function getCategoryGroups() {
|
|
153
174
|
return send('api/category-groups-get');
|
|
154
175
|
}
|
|
155
|
-
exports.getCategoryGroups = getCategoryGroups;
|
|
156
176
|
function createCategoryGroup(group) {
|
|
157
177
|
return send('api/category-group-create', { group });
|
|
158
178
|
}
|
|
159
|
-
exports.createCategoryGroup = createCategoryGroup;
|
|
160
179
|
function updateCategoryGroup(id, fields) {
|
|
161
180
|
return send('api/category-group-update', { id, fields });
|
|
162
181
|
}
|
|
163
|
-
exports.updateCategoryGroup = updateCategoryGroup;
|
|
164
182
|
function deleteCategoryGroup(id, transferCategoryId) {
|
|
165
183
|
return send('api/category-group-delete', { id, transferCategoryId });
|
|
166
184
|
}
|
|
167
|
-
exports.deleteCategoryGroup = deleteCategoryGroup;
|
|
168
185
|
function getCategories() {
|
|
169
186
|
return send('api/categories-get', { grouped: false });
|
|
170
187
|
}
|
|
171
|
-
exports.getCategories = getCategories;
|
|
172
188
|
function createCategory(category) {
|
|
173
189
|
return send('api/category-create', { category });
|
|
174
190
|
}
|
|
175
|
-
exports.createCategory = createCategory;
|
|
176
191
|
function updateCategory(id, fields) {
|
|
177
192
|
return send('api/category-update', { id, fields });
|
|
178
193
|
}
|
|
179
|
-
exports.updateCategory = updateCategory;
|
|
180
194
|
function deleteCategory(id, transferCategoryId) {
|
|
181
195
|
return send('api/category-delete', { id, transferCategoryId });
|
|
182
196
|
}
|
|
183
|
-
exports.deleteCategory = deleteCategory;
|
|
184
197
|
function getCommonPayees() {
|
|
185
198
|
return send('api/common-payees-get');
|
|
186
199
|
}
|
|
187
|
-
exports.getCommonPayees = getCommonPayees;
|
|
188
200
|
function getPayees() {
|
|
189
201
|
return send('api/payees-get');
|
|
190
202
|
}
|
|
191
|
-
exports.getPayees = getPayees;
|
|
192
203
|
function createPayee(payee) {
|
|
193
204
|
return send('api/payee-create', { payee });
|
|
194
205
|
}
|
|
195
|
-
exports.createPayee = createPayee;
|
|
196
206
|
function updatePayee(id, fields) {
|
|
197
207
|
return send('api/payee-update', { id, fields });
|
|
198
208
|
}
|
|
199
|
-
exports.updatePayee = updatePayee;
|
|
200
209
|
function deletePayee(id) {
|
|
201
210
|
return send('api/payee-delete', { id });
|
|
202
211
|
}
|
|
203
|
-
exports.deletePayee = deletePayee;
|
|
204
212
|
function mergePayees(targetId, mergeIds) {
|
|
205
213
|
return send('api/payees-merge', { targetId, mergeIds });
|
|
206
214
|
}
|
|
207
|
-
exports.mergePayees = mergePayees;
|
|
208
215
|
function getRules() {
|
|
209
216
|
return send('api/rules-get');
|
|
210
217
|
}
|
|
211
|
-
exports.getRules = getRules;
|
|
212
218
|
function getPayeeRules(id) {
|
|
213
219
|
return send('api/payee-rules-get', { id });
|
|
214
220
|
}
|
|
215
|
-
exports.getPayeeRules = getPayeeRules;
|
|
216
221
|
function createRule(rule) {
|
|
217
222
|
return send('api/rule-create', { rule });
|
|
218
223
|
}
|
|
219
|
-
exports.createRule = createRule;
|
|
220
224
|
function updateRule(rule) {
|
|
221
225
|
return send('api/rule-update', { rule });
|
|
222
226
|
}
|
|
223
|
-
exports.updateRule = updateRule;
|
|
224
227
|
function deleteRule(id) {
|
|
225
|
-
return send('api/rule-delete',
|
|
228
|
+
return send('api/rule-delete', id);
|
|
229
|
+
}
|
|
230
|
+
function holdBudgetForNextMonth(month, amount) {
|
|
231
|
+
return send('api/budget-hold-for-next-month', { month, amount });
|
|
232
|
+
}
|
|
233
|
+
function resetBudgetHold(month) {
|
|
234
|
+
return send('api/budget-reset-hold', { month });
|
|
226
235
|
}
|
|
227
|
-
exports.deleteRule = deleteRule;
|
package/dist/methods.test.js
CHANGED
|
@@ -79,28 +79,22 @@ describe('API CRUD operations', () => {
|
|
|
79
79
|
const groups = await api.getCategoryGroups();
|
|
80
80
|
expect(groups).toEqual(expect.arrayContaining([
|
|
81
81
|
expect.objectContaining({
|
|
82
|
-
hidden:
|
|
82
|
+
hidden: false,
|
|
83
83
|
id: 'fc3825fd-b982-4b72-b768-5b30844cf832',
|
|
84
|
-
is_income:
|
|
84
|
+
is_income: false,
|
|
85
85
|
name: 'Usual Expenses',
|
|
86
|
-
sort_order: 16384,
|
|
87
|
-
tombstone: 0,
|
|
88
86
|
}),
|
|
89
87
|
expect.objectContaining({
|
|
90
|
-
hidden:
|
|
88
|
+
hidden: false,
|
|
91
89
|
id: 'a137772f-cf2f-4089-9432-822d2ddc1466',
|
|
92
|
-
is_income:
|
|
90
|
+
is_income: false,
|
|
93
91
|
name: 'Investments and Savings',
|
|
94
|
-
sort_order: 32768,
|
|
95
|
-
tombstone: 0,
|
|
96
92
|
}),
|
|
97
93
|
expect.objectContaining({
|
|
98
|
-
hidden:
|
|
94
|
+
hidden: false,
|
|
99
95
|
id: '2E1F5BDB-209B-43F9-AF2C-3CE28E380C00',
|
|
100
|
-
is_income:
|
|
96
|
+
is_income: true,
|
|
101
97
|
name: 'Income',
|
|
102
|
-
sort_order: 32768,
|
|
103
|
-
tombstone: 0,
|
|
104
98
|
}),
|
|
105
99
|
]));
|
|
106
100
|
// create our test category group
|
|
@@ -488,9 +482,9 @@ describe('API CRUD operations', () => {
|
|
|
488
482
|
}),
|
|
489
483
|
]));
|
|
490
484
|
// delete rules
|
|
491
|
-
await api.deleteRule(rules[1]);
|
|
485
|
+
await api.deleteRule(rules[1].id);
|
|
492
486
|
expect(await api.getRules()).toHaveLength(1);
|
|
493
|
-
await api.deleteRule(rules[0]);
|
|
487
|
+
await api.deleteRule(rules[0].id);
|
|
494
488
|
expect(await api.getRules()).toHaveLength(0);
|
|
495
489
|
});
|
|
496
490
|
// apis: addTransactions, getTransactions, importTransactions, updateTransaction, deleteTransaction
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = runMigration;
|
|
3
4
|
async function runMigration(db) {
|
|
4
5
|
function getValue(node) {
|
|
5
6
|
return node.expr != null ? node.expr : node.cachedValue;
|
|
@@ -100,4 +101,3 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
100
101
|
VACUUM;
|
|
101
102
|
`);
|
|
102
103
|
}
|
|
103
|
-
exports.default = runMigration;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = runMigration;
|
|
4
|
+
async function runMigration(db) {
|
|
5
|
+
const categories = await db.runQuery('SELECT id FROM categories WHERE tombstone = 0', [], true);
|
|
6
|
+
const customReports = await db.runQuery('SELECT id, selected_categories, conditions FROM custom_reports WHERE tombstone = 0 AND selected_categories IS NOT NULL', [], true);
|
|
7
|
+
// Move all `selected_categories` to `conditions` if possible.. otherwise skip
|
|
8
|
+
for (const report of customReports) {
|
|
9
|
+
const conditions = report.conditions ? JSON.parse(report.conditions) : [];
|
|
10
|
+
const selectedCategories = report.selected_categories
|
|
11
|
+
? JSON.parse(report.selected_categories)
|
|
12
|
+
: [];
|
|
13
|
+
const selectedCategoryIds = selectedCategories.map(({ id }) => id);
|
|
14
|
+
const areAllCategoriesSelected = !categories.find(({ id }) => !selectedCategoryIds.includes(id));
|
|
15
|
+
// Do nothing if all categories are selected.. we don't need to add a new condition for that
|
|
16
|
+
if (areAllCategoriesSelected) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
// If `conditions` already has a "category" filter - skip the entry
|
|
20
|
+
if (conditions.find(({ field }) => field === 'category')) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
// Append a new condition with the selected category IDs
|
|
24
|
+
await db.runQuery('UPDATE custom_reports SET conditions = ? WHERE id = ?', [
|
|
25
|
+
JSON.stringify([
|
|
26
|
+
...conditions,
|
|
27
|
+
{
|
|
28
|
+
field: 'category',
|
|
29
|
+
op: 'oneOf',
|
|
30
|
+
value: selectedCategoryIds,
|
|
31
|
+
type: 'id',
|
|
32
|
+
},
|
|
33
|
+
]),
|
|
34
|
+
report.id,
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
// Remove all the `selectedCategories` values - we don't need them anymore
|
|
38
|
+
await db.runQuery('UPDATE custom_reports SET selected_categories = NULL WHERE tombstone = 0');
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = runMigration;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
/* eslint-disable rulesdir/typography */
|
|
6
|
+
async function runMigration(db) {
|
|
7
|
+
db.transaction(() => {
|
|
8
|
+
db.execQuery(`
|
|
9
|
+
CREATE TABLE dashboard
|
|
10
|
+
(id TEXT PRIMARY KEY,
|
|
11
|
+
type TEXT,
|
|
12
|
+
width INTEGER,
|
|
13
|
+
height INTEGER,
|
|
14
|
+
x INTEGER,
|
|
15
|
+
y INTEGER,
|
|
16
|
+
meta TEXT,
|
|
17
|
+
tombstone INTEGER DEFAULT 0);
|
|
18
|
+
|
|
19
|
+
INSERT INTO dashboard (id, type, width, height, x, y)
|
|
20
|
+
VALUES
|
|
21
|
+
('${(0, uuid_1.v4)()}','net-worth-card', 8, 2, 0, 0),
|
|
22
|
+
('${(0, uuid_1.v4)()}', 'cash-flow-card', 4, 2, 8, 0);
|
|
23
|
+
`);
|
|
24
|
+
// Add custom reports to the dashboard
|
|
25
|
+
const reports = db.runQuery('SELECT id FROM custom_reports WHERE tombstone = 0 ORDER BY name COLLATE NOCASE ASC', [], true);
|
|
26
|
+
reports.forEach((report, id) => {
|
|
27
|
+
db.runQuery(`INSERT INTO dashboard (id, type, width, height, x, y, meta) VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
|
28
|
+
(0, uuid_1.v4)(),
|
|
29
|
+
'custom-report',
|
|
30
|
+
4,
|
|
31
|
+
2,
|
|
32
|
+
(id * 4) % 12,
|
|
33
|
+
2 + Math.floor(id / 3) * 2,
|
|
34
|
+
JSON.stringify({ id: report.id }),
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actual-app/api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "An API for Actual",
|
|
6
6
|
"engines": {
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"@types/uuid": "^9.0.2",
|
|
36
36
|
"jest": "^27.5.1",
|
|
37
37
|
"tsc-alias": "^1.8.8",
|
|
38
|
-
"typescript": "^5.
|
|
38
|
+
"typescript": "^5.5.4"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/dist/utils.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.amountToInteger = amountToInteger;
|
|
4
|
+
exports.integerToAmount = integerToAmount;
|
|
4
5
|
function amountToInteger(n) {
|
|
5
6
|
return Math.round(n * 100);
|
|
6
7
|
}
|
|
7
|
-
exports.amountToInteger = amountToInteger;
|
|
8
8
|
function integerToAmount(n) {
|
|
9
9
|
return parseFloat((n / 100).toFixed(2));
|
|
10
10
|
}
|
|
11
|
-
exports.integerToAmount = integerToAmount;
|
|
@@ -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.validateNodeVersion =
|
|
26
|
+
exports.validateNodeVersion = validateNodeVersion;
|
|
27
27
|
const compare_versions_1 = require("compare-versions");
|
|
28
28
|
const packageJson = __importStar(require("./package.json"));
|
|
29
29
|
function validateNodeVersion() {
|
|
@@ -35,4 +35,3 @@ function validateNodeVersion() {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
exports.validateNodeVersion = validateNodeVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actual-app/api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "An API for Actual",
|
|
6
6
|
"engines": {
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"@types/uuid": "^9.0.2",
|
|
36
36
|
"jest": "^27.5.1",
|
|
37
37
|
"tsc-alias": "^1.8.8",
|
|
38
|
-
"typescript": "^5.
|
|
38
|
+
"typescript": "^5.5.4"
|
|
39
39
|
}
|
|
40
40
|
}
|