@actual-app/api 5.1.1 → 6.0.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.d.ts +3 -0
- package/dist/app/bundle.api.js +74496 -0
- package/dist/app/query.d.ts +19 -0
- package/dist/app/query.js +102 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +110 -0
- package/dist/injected.d.ts +2 -0
- package/dist/injected.js +8 -0
- package/dist/methods.d.ts +35 -0
- package/dist/methods.js +258 -0
- package/dist/migrations/1632571489012_remove_cache.d.ts +1 -0
- package/dist/migrations/1632571489012_remove_cache.js +129 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +79 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +11 -0
- package/migrations/1679728867040_rules_conditions.sql +5 -0
- package/migrations/1681115033845_add_schedule_name.sql +5 -0
- package/migrations/1682974838138_remove_payee_rules.sql +5 -0
- package/package.json +11 -9
- package/app/bundle.api.js +0 -68608
- package/app/bundle.api.js.map +0 -1
- package/app/query.js +0 -104
- package/index.js +0 -34
- package/injected.js +0 -5
- package/methods.js +0 -212
- package/migrations/.force-copy-windows +0 -0
- package/utils.js +0 -9
package/app/query.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
class Query {
|
|
2
|
-
constructor(state) {
|
|
3
|
-
this.state = {
|
|
4
|
-
filterExpressions: state.filterExpressions || [],
|
|
5
|
-
selectExpressions: state.selectExpressions || [],
|
|
6
|
-
groupExpressions: state.groupExpressions || [],
|
|
7
|
-
orderExpressions: state.orderExpressions || [],
|
|
8
|
-
calculation: false,
|
|
9
|
-
rawMode: false,
|
|
10
|
-
withDead: false,
|
|
11
|
-
validateRefs: true,
|
|
12
|
-
limit: null,
|
|
13
|
-
offset: null,
|
|
14
|
-
...state,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
filter(expr) {
|
|
19
|
-
return new Query({
|
|
20
|
-
...this.state,
|
|
21
|
-
filterExpressions: [...this.state.filterExpressions, expr],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
unfilter(exprs) {
|
|
26
|
-
let exprSet = new Set(exprs);
|
|
27
|
-
return new Query({
|
|
28
|
-
...this.state,
|
|
29
|
-
filterExpressions: this.state.filterExpressions.filter(
|
|
30
|
-
expr => !exprSet.has(Object.keys(expr)[0]),
|
|
31
|
-
),
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
select(exprs = []) {
|
|
36
|
-
if (!Array.isArray(exprs)) {
|
|
37
|
-
exprs = [exprs];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let query = new Query({ ...this.state, selectExpressions: exprs });
|
|
41
|
-
query.state.calculation = false;
|
|
42
|
-
return query;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
calculate(expr) {
|
|
46
|
-
let query = this.select({ result: expr });
|
|
47
|
-
query.state.calculation = true;
|
|
48
|
-
return query;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
groupBy(exprs) {
|
|
52
|
-
if (!Array.isArray(exprs)) {
|
|
53
|
-
exprs = [exprs];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return new Query({
|
|
57
|
-
...this.state,
|
|
58
|
-
groupExpressions: [...this.state.groupExpressions, ...exprs],
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
orderBy(exprs) {
|
|
63
|
-
if (!Array.isArray(exprs)) {
|
|
64
|
-
exprs = [exprs];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return new Query({
|
|
68
|
-
...this.state,
|
|
69
|
-
orderExpressions: [...this.state.orderExpressions, ...exprs],
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
limit(num) {
|
|
74
|
-
return new Query({ ...this.state, limit: num });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
offset(num) {
|
|
78
|
-
return new Query({ ...this.state, offset: num });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
raw() {
|
|
82
|
-
return new Query({ ...this.state, rawMode: true });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
withDead() {
|
|
86
|
-
return new Query({ ...this.state, withDead: true });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
withoutValidatedRefs() {
|
|
90
|
-
return new Query({ ...this.state, validateRefs: false });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
options(opts) {
|
|
94
|
-
return new Query({ ...this.state, tableOptions: opts });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
serialize() {
|
|
98
|
-
return this.state;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
module.exports = function q(table) {
|
|
103
|
-
return new Query({ table });
|
|
104
|
-
};
|
package/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
let bundle = require('./app/bundle.api.js');
|
|
2
|
-
let injected = require('./injected');
|
|
3
|
-
let methods = require('./methods');
|
|
4
|
-
let utils = require('./utils');
|
|
5
|
-
let actualApp;
|
|
6
|
-
|
|
7
|
-
async function init(config = {}) {
|
|
8
|
-
if (actualApp) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
global.fetch = require('node-fetch');
|
|
13
|
-
|
|
14
|
-
await bundle.init(config);
|
|
15
|
-
actualApp = bundle.lib;
|
|
16
|
-
|
|
17
|
-
injected.send = bundle.lib.send;
|
|
18
|
-
return bundle.lib;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function shutdown() {
|
|
22
|
-
if (actualApp) {
|
|
23
|
-
await actualApp.send('close-budget');
|
|
24
|
-
actualApp = null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = {
|
|
29
|
-
init,
|
|
30
|
-
shutdown,
|
|
31
|
-
utils,
|
|
32
|
-
internal: bundle.lib,
|
|
33
|
-
...methods,
|
|
34
|
-
};
|
package/injected.js
DELETED
package/methods.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
const q = require('./app/query');
|
|
2
|
-
const injected = require('./injected');
|
|
3
|
-
|
|
4
|
-
function send(name, args) {
|
|
5
|
-
return injected.send(name, args);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
async function runImport(name, func) {
|
|
9
|
-
await send('api/start-import', { budgetName: name });
|
|
10
|
-
try {
|
|
11
|
-
await func();
|
|
12
|
-
} catch (e) {
|
|
13
|
-
await send('api/abort-import');
|
|
14
|
-
throw e;
|
|
15
|
-
}
|
|
16
|
-
await send('api/finish-import');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function loadBudget(budgetId) {
|
|
20
|
-
return send('api/load-budget', { id: budgetId });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function downloadBudget(syncId, { password } = {}) {
|
|
24
|
-
return send('api/download-budget', { syncId, password });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function batchBudgetUpdates(func) {
|
|
28
|
-
await send('api/batch-budget-start');
|
|
29
|
-
try {
|
|
30
|
-
await func();
|
|
31
|
-
} finally {
|
|
32
|
-
await send('api/batch-budget-end');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function runQuery(query) {
|
|
37
|
-
return send('api/query', { query: query.serialize() });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function getBudgetMonths() {
|
|
41
|
-
return send('api/budget-months');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getBudgetMonth(month) {
|
|
45
|
-
return send('api/budget-month', { month });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function setBudgetAmount(month, categoryId, value) {
|
|
49
|
-
return send('api/budget-set-amount', { month, categoryId, amount: value });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function setBudgetCarryover(month, categoryId, flag) {
|
|
53
|
-
return send('api/budget-set-carryover', { month, categoryId, flag });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function addTransactions(accountId, transactions) {
|
|
57
|
-
return send('api/transactions-add', { accountId, transactions });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function importTransactions(accountId, transactions) {
|
|
61
|
-
return send('api/transactions-import', { accountId, transactions });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function getTransactions(accountId, startDate, endDate) {
|
|
65
|
-
return send('api/transactions-get', { accountId, startDate, endDate });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function filterTransactions(accountId, text) {
|
|
69
|
-
return send('api/transactions-filter', { accountId, text });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function updateTransaction(id, fields) {
|
|
73
|
-
return send('api/transaction-update', { id, fields });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function deleteTransaction(id) {
|
|
77
|
-
return send('api/transaction-delete', { id });
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function getAccounts() {
|
|
81
|
-
return send('api/accounts-get');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function createAccount(account, initialBalance) {
|
|
85
|
-
return send('api/account-create', { account, initialBalance });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function updateAccount(id, fields) {
|
|
89
|
-
return send('api/account-update', { id, fields });
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function closeAccount(id, transferAccountId, transferCategoryId) {
|
|
93
|
-
return send('api/account-close', {
|
|
94
|
-
id,
|
|
95
|
-
transferAccountId,
|
|
96
|
-
transferCategoryId,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function reopenAccount(id) {
|
|
101
|
-
return send('api/account-reopen', { id });
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function deleteAccount(id) {
|
|
105
|
-
return send('api/account-delete', { id });
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function createCategoryGroup(group) {
|
|
109
|
-
return send('api/category-group-create', { group });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function updateCategoryGroup(id, fields) {
|
|
113
|
-
return send('api/category-group-update', { id, fields });
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function deleteCategoryGroup(id, transferCategoryId) {
|
|
117
|
-
return send('api/category-group-delete', { id, transferCategoryId });
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function getCategories() {
|
|
121
|
-
return send('api/categories-get', { grouped: false });
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function createCategory(category) {
|
|
125
|
-
return send('api/category-create', { category });
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function updateCategory(id, fields) {
|
|
129
|
-
return send('api/category-update', { id, fields });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function deleteCategory(id, transferCategoryId) {
|
|
133
|
-
return send('api/category-delete', { id, transferCategoryId });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function getPayees() {
|
|
137
|
-
return send('api/payees-get');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function createPayee(payee) {
|
|
141
|
-
return send('api/payee-create', { payee });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function updatePayee(id, fields) {
|
|
145
|
-
return send('api/payee-update', { id, fields });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function deletePayee(id) {
|
|
149
|
-
return send('api/payee-delete', { id });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function getPayeeRules(payeeId) {
|
|
153
|
-
return send('api/payee-rules-get', { payeeId });
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function createPayeeRule(payeeId, rule) {
|
|
157
|
-
return send('api/payee-rule-create', { payee_id: payeeId, rule });
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function updatePayeeRule(id, fields) {
|
|
161
|
-
return send('api/payee-rule-update', { id, fields });
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function deletePayeeRule(id) {
|
|
165
|
-
return send('api/payee-rule-delete', { id });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
module.exports = {
|
|
169
|
-
runImport,
|
|
170
|
-
|
|
171
|
-
runQuery,
|
|
172
|
-
q,
|
|
173
|
-
|
|
174
|
-
loadBudget,
|
|
175
|
-
downloadBudget,
|
|
176
|
-
batchBudgetUpdates,
|
|
177
|
-
getBudgetMonths,
|
|
178
|
-
getBudgetMonth,
|
|
179
|
-
setBudgetAmount,
|
|
180
|
-
setBudgetCarryover,
|
|
181
|
-
|
|
182
|
-
addTransactions,
|
|
183
|
-
importTransactions,
|
|
184
|
-
filterTransactions,
|
|
185
|
-
getTransactions,
|
|
186
|
-
updateTransaction,
|
|
187
|
-
deleteTransaction,
|
|
188
|
-
|
|
189
|
-
getAccounts,
|
|
190
|
-
createAccount,
|
|
191
|
-
updateAccount,
|
|
192
|
-
closeAccount,
|
|
193
|
-
reopenAccount,
|
|
194
|
-
deleteAccount,
|
|
195
|
-
|
|
196
|
-
getCategories,
|
|
197
|
-
createCategoryGroup,
|
|
198
|
-
updateCategoryGroup,
|
|
199
|
-
deleteCategoryGroup,
|
|
200
|
-
createCategory,
|
|
201
|
-
updateCategory,
|
|
202
|
-
deleteCategory,
|
|
203
|
-
|
|
204
|
-
getPayees,
|
|
205
|
-
createPayee,
|
|
206
|
-
updatePayee,
|
|
207
|
-
deletePayee,
|
|
208
|
-
getPayeeRules,
|
|
209
|
-
createPayeeRule,
|
|
210
|
-
deletePayeeRule,
|
|
211
|
-
updatePayeeRule,
|
|
212
|
-
};
|
|
File without changes
|