Skip to content
Snippets Groups Projects
Unverified Commit 0f960df8 authored by DJ Mountney's avatar DJ Mountney Committed by GitHub
Browse files

Improve api output types (#2567)

* Improve api output types

- Fixes some missing models
- Fixes some output path aliasing

* Add changelog
parent 915c5625
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"outDir": "dist", "outDir": "dist",
"declarationDir": "@types", "declarationDir": "@types",
"paths": { "paths": {
"loot-core/src/*": ["./loot-core/*"],
"loot-core/*": ["./@types/loot-core/*"], "loot-core/*": ["./@types/loot-core/*"],
} }
}, },
......
...@@ -8,6 +8,7 @@ import { v4 as uuidv4 } from 'uuid'; ...@@ -8,6 +8,7 @@ import { v4 as uuidv4 } from 'uuid';
import * as monthUtils from '../../shared/months'; import * as monthUtils from '../../shared/months';
import { sortByKey, groupBy } from '../../shared/util'; import { sortByKey, groupBy } from '../../shared/util';
import { CategoryGroupEntity } from '../../types/models';
import { YNAB5 } from './ynab5-types'; import { YNAB5 } from './ynab5-types';
...@@ -338,10 +339,16 @@ function equalsIgnoreCase(stringa: string, stringb: string): boolean { ...@@ -338,10 +339,16 @@ function equalsIgnoreCase(stringa: string, stringb: string): boolean {
); );
} }
function findByNameIgnoreCase(categories: YNAB5.CategoryGroup[], name: string) { function findByNameIgnoreCase(
categories: (YNAB5.CategoryGroup | CategoryGroupEntity)[],
name: string,
) {
return categories.find(cat => equalsIgnoreCase(cat.name, name)); return categories.find(cat => equalsIgnoreCase(cat.name, name));
} }
function findIdByName(categories: YNAB5.CategoryGroup[], name: string) { function findIdByName(
categories: (YNAB5.CategoryGroup | CategoryGroupEntity)[],
name: string,
) {
return findByNameIgnoreCase(categories, name)?.id; return findByNameIgnoreCase(categories, name)?.id;
} }
import { type batchUpdateTransactions } from '../server/accounts/transactions'; import { type batchUpdateTransactions } from '../server/accounts/transactions';
import type {
TransactionEntity,
AccountEntity,
CategoryGroupEntity,
CategoryEntity,
PayeeEntity,
} from './models';
import { type ServerHandlers } from './server-handlers'; import { type ServerHandlers } from './server-handlers';
export interface ApiHandlers { export interface ApiHandlers {
...@@ -107,7 +114,7 @@ export interface ApiHandlers { ...@@ -107,7 +114,7 @@ export interface ApiHandlers {
'api/categories-get': (arg: { 'api/categories-get': (arg: {
grouped; grouped;
}) => Promise<Array<CategoryGroupEntity> | Array<CategoryEntity>>; }) => Promise<Array<CategoryGroupEntity | CategoryEntity>>;
'api/category-groups-get': () => Promise<CategoryGroupEntity[]>; 'api/category-groups-get': () => Promise<CategoryGroupEntity[]>;
......
---
category: Maintenance
authors: [twk3]
---
Improve API output types.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment