From 0d60c4a6647bf4abd46c8a5de37ba11b63316d5c Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Mon, 5 Feb 2024 13:13:13 -0800 Subject: [PATCH 1/2] Typescript: pass 2 at updating api-handlers to match server handlers --- .../loot-core/src/types/api-handlers.d.ts | 59 +++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/packages/loot-core/src/types/api-handlers.d.ts b/packages/loot-core/src/types/api-handlers.d.ts index 30ecac4cf36..7ad399073d8 100644 --- a/packages/loot-core/src/types/api-handlers.d.ts +++ b/packages/loot-core/src/types/api-handlers.d.ts @@ -1,3 +1,5 @@ +import { type batchUpdateTransactions } from '../server/accounts/transactions'; + import { type ServerHandlers } from './server-handlers'; export interface ApiHandlers { @@ -9,20 +11,23 @@ export interface ApiHandlers { ...args: Parameters ) => Promise; - 'api/download-budget': (arg: { syncId; password }) => Promise; + 'api/download-budget': (arg: { + syncId: string; + password?: string; + }) => Promise; - 'api/start-import': (arg: { budgetName }) => Promise; + 'api/start-import': (arg: { budgetName: string }) => Promise; - 'api/finish-import': () => Promise; + 'api/finish-import': () => Promise; - 'api/abort-import': () => Promise; + 'api/abort-import': () => Promise; 'api/query': (arg: { query }) => Promise; - 'api/budget-months': () => Promise; + 'api/budget-months': () => Promise; 'api/budget-month': (arg: { month }) => Promise<{ - month; + month: string; incomeAvailable: number; lastMonthOverspent: number; forNextMonth: number; @@ -37,16 +42,16 @@ export interface ApiHandlers { }>; 'api/budget-set-amount': (arg: { - month; - categoryId; - amount; - }) => Promise; + month: string; + categoryId: string; + amount: number; + }) => Promise; 'api/budget-set-carryover': (arg: { - month; - categoryId; - flag; - }) => Promise; + month: string; + categoryId: string; + flag: boolean; + }) => Promise; 'api/transactions-export': (arg: { transactions; @@ -68,22 +73,27 @@ export interface ApiHandlers { }) => Promise<'ok'>; 'api/transactions-get': (arg: { - accountId; - startDate; - endDate; - }) => Promise; + accountId?: string; + startDate?: string; + endDate?: string; + }) => Promise; - 'api/transaction-update': (arg: { id; fields }) => Promise; + 'api/transaction-update': (arg: { + id; + fields; + }) => Promise>['updated']>; - 'api/transaction-delete': (arg: { id }) => Promise; + 'api/transaction-delete': (arg: { + id; + }) => Promise>['updated']>; - 'api/sync': () => Promise; + 'api/sync': () => Promise; 'api/accounts-get': () => Promise; 'api/account-create': (arg: { account; initialBalance? }) => Promise; - 'api/account-update': (arg: { id; fields }) => Promise; + 'api/account-update': (arg: { id; fields }) => Promise; 'api/account-close': (arg: { id; @@ -112,7 +122,10 @@ export interface ApiHandlers { 'api/category-update': (arg: { id; fields }) => Promise; - 'api/category-delete': (arg: { id; transferCategoryId }) => Promise; + 'api/category-delete': (arg: { + id; + transferCategoryId?; + }) => Promise<{ error?: string }>; 'api/payees-get': () => Promise; From 7d64191427e1fd4e70977a1a97d899f4b54f773c Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Mon, 5 Feb 2024 13:22:28 -0800 Subject: [PATCH 2/2] Add release note --- upcoming-release-notes/2334.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 upcoming-release-notes/2334.md diff --git a/upcoming-release-notes/2334.md b/upcoming-release-notes/2334.md new file mode 100644 index 00000000000..35fd366ef4b --- /dev/null +++ b/upcoming-release-notes/2334.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [twk3] +--- + +Define more of the returns types in api-handlers.