Skip to content

Commit

Permalink
Merge branch 'master' into sf-key-accesskey
Browse files Browse the repository at this point in the history
  • Loading branch information
psybers authored Nov 3, 2024
2 parents 851f99d + 2cd3c9f commit 86a48e3
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 62 deletions.
6 changes: 4 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import run from './src/app.js';
import runMigrations from './src/migrations.js';

runMigrations()
.then(run)
.then(() => {
//import the app here becasue initial migrations need to be run first - they are dependencies of the app.js
import('./src/app.js').then((app) => app.default()); // run the app
})
.catch((err) => {
console.log('Error starting app:', err);
process.exit(1);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "actual-sync",
"version": "24.10.1",
"version": "24.11.0",
"license": "MIT",
"description": "actual syncing server",
"type": "module",
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@actual-app/crdt": "2.1.0",
"@actual-app/web": "24.10.1",
"@actual-app/web": "24.11.0",
"bcrypt": "^5.1.1",
"better-sqlite3": "^9.6.0",
"body-parser": "^1.20.3",
Expand Down
2 changes: 1 addition & 1 deletion src/app-gocardless/banks/easybank-bawaatww.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {

institutionIds: ['EASYBANK_BAWAATWW'],

accessValidForDays: 180,
accessValidForDays: 179,

// If date is same, sort by transactionId
sortTransactions: (transactions = []) =>
Expand Down
19 changes: 15 additions & 4 deletions src/app-simplefin/app-simplefin.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ app.post(
}

try {
const accounts = await getAccounts(accessKey, null, null, true);
const accounts = await getAccounts(accessKey, null, null, null, true);

res.send({
status: 'ok',
Expand Down Expand Up @@ -91,7 +91,11 @@ app.post(
: startDate;
let results;
try {
results = await getTransactions(accessKey, new Date(earliestStartDate));
results = await getTransactions(
accessKey,
Array.isArray(accountId) ? accountId : [accountId],
new Date(earliestStartDate),
);
} catch (e) {
if (e.message === 'Forbidden') {
invalidToken(res);
Expand Down Expand Up @@ -297,12 +301,12 @@ async function getAccessKey(base64Token) {
});
}

async function getTransactions(accessKey, startDate, endDate) {
async function getTransactions(accessKey, accounts, startDate, endDate) {
const now = new Date();
startDate = startDate || new Date(now.getFullYear(), now.getMonth(), 1);
endDate = endDate || new Date(now.getFullYear(), now.getMonth() + 1, 1);
console.log(`${getDate(startDate)} - ${getDate(endDate)}`);
return await getAccounts(accessKey, startDate, endDate);
return await getAccounts(accessKey, accounts, startDate, endDate);
}

function getDate(date) {
Expand All @@ -315,6 +319,7 @@ function normalizeDate(date) {

async function getAccounts(
accessKey,
accounts,
startDate,
endDate,
noTransactions = false,
Expand All @@ -341,6 +346,12 @@ async function getAccounts(
params.push(`balances-only=1`);
}

if (accounts) {
accounts.forEach((id) => {
params.push(`account=${encodeURIComponent(id)}`);
});
}

let queryString = '';
if (params.length > 0) {
queryString += '?' + params.join('&');
Expand Down
6 changes: 0 additions & 6 deletions upcoming-release-notes/432.md

This file was deleted.

6 changes: 0 additions & 6 deletions upcoming-release-notes/470.md

This file was deleted.

6 changes: 0 additions & 6 deletions upcoming-release-notes/473.md

This file was deleted.

6 changes: 0 additions & 6 deletions upcoming-release-notes/474.md

This file was deleted.

6 changes: 0 additions & 6 deletions upcoming-release-notes/478.md

This file was deleted.

6 changes: 0 additions & 6 deletions upcoming-release-notes/480.md

This file was deleted.

6 changes: 0 additions & 6 deletions upcoming-release-notes/481.md

This file was deleted.

6 changes: 0 additions & 6 deletions upcoming-release-notes/482.md

This file was deleted.

10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ __metadata:
languageName: node
linkType: hard

"@actual-app/web@npm:24.10.1":
version: 24.10.1
resolution: "@actual-app/web@npm:24.10.1"
checksum: 10c0/6eccc2cc22edd895d1661ee847ca5518a4ba29b8585c991c3da933c2ec4590dbfced02f5d3710cb4feb18bc124bbfcad021dc942650f4bef8855d6c4c883fa28
"@actual-app/web@npm:24.11.0":
version: 24.11.0
resolution: "@actual-app/web@npm:24.11.0"
checksum: 10c0/d6a49d3a2c0539dd41c1caef917f1afa48584af0746ca9f8db3b76fa8c154c081277818bf6a0ec85aeb9d724d3eb4132c13217e6a0725dd730992b57d9e57e97
languageName: node
linkType: hard

Expand Down Expand Up @@ -1531,7 +1531,7 @@ __metadata:
resolution: "actual-sync@workspace:."
dependencies:
"@actual-app/crdt": "npm:2.1.0"
"@actual-app/web": "npm:24.10.1"
"@actual-app/web": "npm:24.11.0"
"@babel/preset-typescript": "npm:^7.20.2"
"@types/bcrypt": "npm:^5.0.2"
"@types/better-sqlite3": "npm:^7.6.7"
Expand Down

0 comments on commit 86a48e3

Please sign in to comment.