Refactor typecheck script in api package and enhance api-helpers with new schedule and rule update functions. The typecheck command was simplified by removing the strict check, and new API methods for creating schedules and updating rules were added to improve functionality.

This commit is contained in:
Matiss Janis Aboltins
2026-02-21 22:12:26 +00:00
parent 7098a5fad7
commit 0619198f50
2 changed files with 25 additions and 3 deletions

View File

@@ -17,7 +17,7 @@
"build": "yarn run clean && yarn run build:node && yarn run build:migrations && yarn run build:default-db",
"test": "yarn run clean && yarn run build:crdt && vitest --run",
"clean": "rm -rf dist @types",
"typecheck": "yarn build && tsc --noEmit && tsc-strict"
"typecheck": "yarn build && tsc --noEmit"
},
"dependencies": {
"@actual-app/crdt": "workspace:^",

View File

@@ -3,13 +3,15 @@
// This provides the same interface as @actual-app/api/methods but uses handlers directly
// to avoid cyclic dependency between loot-core and @actual-app/api
import { type Handlers } from '../../types/handlers';
import type { ImportTransactionEntity } from '../../types/models';
import type { QueryState } from '../../shared/query';
import type { Handlers } from '../../types/handlers';
import type { ImportTransactionEntity, RuleEntity } from '../../types/models';
import type {
APIAccountEntity,
APICategoryEntity,
APICategoryGroupEntity,
APIPayeeEntity,
APIScheduleEntity,
} from '../api-models';
import { app } from '../main-app';
import { runHandler } from '../mutators';
@@ -98,3 +100,23 @@ export async function setBudgetCarryover(
) {
return send('api/budget-set-carryover', { month, categoryId, flag });
}
export async function createSchedule(
schedule: Omit<APIScheduleEntity, 'id'>,
): Promise<string> {
return send('api/schedule-create', schedule);
}
export function aqlQuery(
query: QueryState | { serialize(): QueryState },
): Promise<unknown> {
const queryState =
typeof (query as { serialize?: () => QueryState }).serialize === 'function'
? (query as { serialize(): QueryState }).serialize()
: (query as QueryState);
return send('api/query', { query: queryState });
}
export async function updateRule(rule: RuleEntity): Promise<RuleEntity> {
return send('api/rule-update', { rule });
}