Skip to content

Commit

Permalink
Merge branch 'master' into zach/simplefin
Browse files Browse the repository at this point in the history
  • Loading branch information
zachwhelchel authored Jan 20, 2024
2 parents c613c31 + 83f13cb commit 2d9d028
Show file tree
Hide file tree
Showing 138 changed files with 1,254 additions and 695 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
packages/api/app/bundle.api.js
packages/api/dist
packages/api/@types
packages/api/migrations

packages/crdt/dist
Expand Down
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = {
extends: [
'react-app',
'plugin:react/recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
Expand All @@ -46,6 +47,7 @@ module.exports = {
reportUnusedDisableDirectives: true,
globals: {
globalThis: false,
vi: true,
},
rules: {
'prettier/prettier': 'warn',
Expand Down Expand Up @@ -163,6 +165,11 @@ module.exports = {
{ patterns: [...restrictedImportPatterns, ...restrictedImportColors] },
],

'@typescript-eslint/ban-ts-comment': [
'error',
{ 'ts-ignore': 'allow-with-description' },
],

// Rules disable during TS migration
'@typescript-eslint/no-var-requires': 'off',
'prefer-const': 'warn',
Expand Down
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ body:
required: true
validations:
required: true
- type: checkboxes
id: bank-sync-issue
attributes:
label: 'Is this related to GoCardless, Simplefin or another bank-sync provider?'
description: 'Most issues with bank-sync providers are due to a lack of a custom bank-mapper (i.e. payee or other fields not coming through). In such cases you can create a custom bank mapper in [actual-server](https://github.com/actualbudget/actual-server/blob/master/src/app-gocardless/README.md) repository. Other likely issue is misconfigured server - in which case please reach out via the [community Discord](https://discord.gg/pRYNYr4W5A) to get support.'
options:
- label: 'I have checked my server logs and could not see any errors there'
- label: 'I will be attaching my server logs to this issue'
- label: 'I will be attaching my client-side (browser) logs to this issue'
- label: 'I understand that this issue will be automatically closed if insufficient information is provided'
validations:
required: false
- type: textarea
id: what-happened
attributes:
Expand Down
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Support
url: https://discord.gg/pRYNYr4W5A
about: Need help with something? Perhaps having issues setting up bank-sync with GoCardless or SimpleFin? Reach out to the community on Discord.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!data/.gitkeep
/data2
packages/api/dist
packages/api/@types
packages/crdt/dist
packages/desktop-electron/client-build
packages/desktop-electron/.electron-symbols
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,24 @@
"vrt": "yarn workspaces foreach --all --parallel --verbose run vrt",
"rebuild-electron": "./node_modules/.bin/electron-rebuild -f -m ./packages/loot-core",
"rebuild-node": "yarn workspace loot-core rebuild",
"lint": "eslint . --max-warnings 0",
"lint": "eslint . --max-warnings 0 --ext .js,.jsx,.ts,.tsx",
"lint:verbose": "DEBUG=eslint:cli-engine eslint . --max-warnings 0",
"typecheck": "yarn tsc && tsc-strict",
"jq": "./node_modules/node-jq/bin/jq"
},
"devDependencies": {
"cross-env": "^7.0.3",
"eslint": "^8.37.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "7.0.1",
"eslint-import-resolver-typescript": "3.5.5",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-rulesdir": "^0.2.2",
"node-jq": "^4.0.1",
"npm-run-all": "^4.1.3",
"prettier": "2.8.2",
"prettier": "3.2.4",
"react-refresh": "^0.14.0",
"source-map-support": "^0.5.21",
"typescript": "^5.0.2",
Expand Down
38 changes: 0 additions & 38 deletions packages/api/index.js

This file was deleted.

53 changes: 53 additions & 0 deletions packages/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type {
RequestInfo as FetchInfo,
RequestInit as FetchInit,
// @ts-ignore: false-positive commonjs module error on build until typescript 5.3
} from 'node-fetch'; // with { 'resolution-mode': 'import' };

// loot-core types
import type { InitConfig } from 'loot-core/server/main';

// @ts-ignore: bundle not available until we build it
// eslint-disable-next-line import/extensions
import * as bundle from './app/bundle.api.js';
import * as injected from './injected';
import { validateNodeVersion } from './validateNodeVersion';

let actualApp: null | typeof bundle.lib;
export const internal = bundle.lib;

// DEPRECATED: remove the next line in @actual-app/api v7
export * as methods from './methods';

export * from './methods';
export * as utils from './utils';

export async function init(config: InitConfig = {}) {
if (actualApp) {
return;
}

validateNodeVersion();

if (!globalThis.fetch) {
globalThis.fetch = (url: URL | RequestInfo, init?: RequestInit) => {
return import('node-fetch').then(({ default: fetch }) =>
fetch(url as unknown as FetchInfo, init as unknown as FetchInit),
) as unknown as Promise<Response>;
};
}

await bundle.init(config);
actualApp = bundle.lib;

injected.override(bundle.lib.send);
return bundle.lib;
}

export async function shutdown() {
if (actualApp) {
await actualApp.send('sync');
await actualApp.send('close-budget');
actualApp = null;
}
}
22 changes: 12 additions & 10 deletions packages/api/methods.js → packages/api/methods.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// @ts-strict-ignore
import type { Handlers } from 'loot-core/src/types/handlers';

import * as injected from './injected';

export { q } from './app/query';

function send(name, args) {
function send<K extends keyof Handlers, T extends Handlers[K]>(
name: K,
args?: Parameters<T>[0],
): Promise<Awaited<ReturnType<T>>> {
return injected.send(name, args);
}

Expand All @@ -21,7 +27,7 @@ export async function loadBudget(budgetId) {
return send('api/load-budget', { id: budgetId });
}

export async function downloadBudget(syncId, { password } = {}) {
export async function downloadBudget(syncId, { password }: { password? } = {}) {
return send('api/download-budget', { syncId, password });
}

Expand Down Expand Up @@ -79,10 +85,6 @@ export function getTransactions(accountId, startDate, endDate) {
return send('api/transactions-get', { accountId, startDate, endDate });
}

export function filterTransactions(accountId, text) {
return send('api/transactions-filter', { accountId, text });
}

export function updateTransaction(id, fields) {
return send('api/transaction-update', { id, fields });
}
Expand All @@ -95,15 +97,15 @@ export function getAccounts() {
return send('api/accounts-get');
}

export function createAccount(account, initialBalance) {
export function createAccount(account, initialBalance?) {
return send('api/account-create', { account, initialBalance });
}

export function updateAccount(id, fields) {
return send('api/account-update', { id, fields });
}

export function closeAccount(id, transferAccountId, transferCategoryId) {
export function closeAccount(id, transferAccountId?, transferCategoryId?) {
return send('api/account-close', {
id,
transferAccountId,
Expand All @@ -127,7 +129,7 @@ export function updateCategoryGroup(id, fields) {
return send('api/category-group-update', { id, fields });
}

export function deleteCategoryGroup(id, transferCategoryId) {
export function deleteCategoryGroup(id, transferCategoryId?) {
return send('api/category-group-delete', { id, transferCategoryId });
}

Expand All @@ -143,7 +145,7 @@ export function updateCategory(id, fields) {
return send('api/category-update', { id, fields });
}

export function deleteCategory(id, transferCategoryId) {
export function deleteCategory(id, transferCategoryId?) {
return send('api/category-delete', { id, transferCategoryId });
}

Expand Down
10 changes: 6 additions & 4 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
"node": ">=18.12.0"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"types": "@types/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build:app": "yarn workspace loot-core build:api",
"build:node": "tsc --p tsconfig.dist.json",
"build:node": "tsc --p tsconfig.dist.json && tsc-alias -p tsconfig.dist.json",
"build:migrations": "cp migrations/*.sql dist/migrations",
"build:default-db": "cp default-db.sqlite dist/",
"build": "rm -rf dist && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db",
"test": "yarn run build:app && jest -c jest.config.js"
"build": "yarn run clean && yarn run build:app && yarn run build:node && yarn run build:migrations && yarn run build:default-db",
"test": "yarn run build:app && jest -c jest.config.js",
"clean": "rm -rf dist @types"
},
"dependencies": {
"better-sqlite3": "^9.2.2",
Expand All @@ -31,6 +32,7 @@
"@types/jest": "^27.5.0",
"@types/uuid": "^9.0.2",
"jest": "^27.0.0",
"tsc-alias": "^1.8.8",
"typescript": "^5.0.2"
}
}
8 changes: 6 additions & 2 deletions packages/api/tsconfig.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
"moduleResolution": "Node16",
"noEmit": false,
"declaration": true,
"outDir": "dist"
"outDir": "dist",
"declarationDir": "@types",
"paths": {
"loot-core/*": ["./@types/loot-core/*"],
}
},
"include": ["."],
"exclude": ["dist"]
"exclude": ["**/node_modules/*", "dist", "@types"]
}
8 changes: 4 additions & 4 deletions packages/crdt/src/crdt/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ export class Timestamp {
lNew === lOld && lNew === lMsg
? Math.max(cOld, cMsg) + 1
: lNew === lOld
? cOld + 1
: lNew === lMsg
? cMsg + 1
: 0;
? cOld + 1
: lNew === lMsg
? cMsg + 1
: 0;

// check the result for drift and counter overflow
if (lNew - phys > config.maxDrift) {
Expand Down
20 changes: 10 additions & 10 deletions packages/desktop-client/src/components/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ function Notification({
color: positive
? theme.noticeText
: error
? theme.errorTextDark
: theme.warningTextDark,
? theme.errorTextDark
: theme.warningTextDark,
}}
>
<Stack
Expand All @@ -132,14 +132,14 @@ function Notification({
backgroundColor: positive
? theme.noticeBackgroundLight
: error
? theme.errorBackground
: theme.warningBackground,
? theme.errorBackground
: theme.warningBackground,
borderTop: `3px solid ${
positive
? theme.noticeBorder
: error
? theme.errorBorder
: theme.warningBorder
? theme.errorBorder
: theme.warningBorder
}`,
...styles.shadowLarge,
maxWidth: 550,
Expand Down Expand Up @@ -184,8 +184,8 @@ function Notification({
positive
? theme.noticeBorder
: error
? theme.errorBorder
: theme.warningBorder
? theme.errorBorder
: theme.warningBorder
}`,
color: 'currentColor',
fontSize: 14,
Expand All @@ -194,8 +194,8 @@ function Notification({
backgroundColor: positive
? theme.noticeBackground
: error
? theme.errorBackground
: theme.warningBackground,
? theme.errorBackground
: theme.warningBackground,
},
}}
>
Expand Down
Loading

0 comments on commit 2d9d028

Please sign in to comment.