Fix types

This commit is contained in:
Joel Jeremy Marquez
2025-01-24 14:10:29 -08:00
parent 999ed1cb3d
commit 4fe5834532
6 changed files with 11 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
import { ScheduleEntity } from '../../types/models';
import * as db from '../db';
import { Schedule } from '../db/types';
import { GOAL_PREFIX, TEMPLATE_PREFIX } from './template-notes';
@@ -41,7 +41,7 @@ export async function getCategoriesWithTemplateNotes(): Promise<
);
}
export async function getActiveSchedules(): Promise<Schedule[]> {
export async function getActiveSchedules(): Promise<ScheduleEntity[]> {
return await db.all(
'SELECT id, rule, active, completed, posts_transaction, tombstone, name from schedules WHERE name NOT NULL AND tombstone = 0',
);

View File

@@ -1,5 +1,5 @@
import { ScheduleEntity } from '../../types/models';
import * as db from '../db';
import { Schedule } from '../db/types';
import {
CategoryWithTemplateNote,
@@ -20,7 +20,7 @@ function mockGetTemplateNotesForCategories(
);
}
function mockGetActiveSchedules(schedules: Schedule[]) {
function mockGetActiveSchedules(schedules: Partial<ScheduleEntity>[]) {
(getActiveSchedules as jest.Mock).mockResolvedValue(schedules);
}
@@ -245,7 +245,7 @@ describe('checkTemplates', () => {
);
});
function mockSchedules(): Schedule[] {
function mockSchedules(): Partial<ScheduleEntity>[] {
return [
{
id: 'mock-schedule-1',

View File

@@ -176,7 +176,7 @@ async function importDashboard({ filepath }: { filepath: string }) {
exportModel.validate(parsedContent);
const customReportIds: CustomReportEntity[] = await db.all(
const customReportIds: Pick<CustomReportEntity, 'id'>[] = await db.all(
'SELECT id from custom_reports',
);
const customReportIdSet = new Set(customReportIds.map(({ id }) => id));

View File

@@ -1,9 +0,0 @@
export type Schedule = {
id: string;
rule: string;
active: number;
completed: number;
posts_transaction: number;
tombstone: number;
name: string | null;
};

View File

@@ -118,10 +118,9 @@ describe('sync migrations', () => {
await sendMessages(msgs);
await tracer.expect('applied');
const transactions = await db.all<TransactionEntity>(
'SELECT * FROM transactions',
[],
);
const transactions = await db.all<
TransactionEntity & { isChild: number }
>('SELECT * FROM transactions', []);
for (const trans of transactions) {
const transMsgs = msgs
.filter(msg => msg.row === trans.id)
@@ -138,7 +137,7 @@ describe('sync migrations', () => {
const msg = transMsgs.find(m => m.column === 'parent_id');
if (
!!trans.is_child &&
trans.isChild === 1 &&
trans.id.includes('/') &&
(msg == null || msg.value == null)
) {

View File

@@ -23,6 +23,7 @@ export interface ScheduleEntity {
id: string;
name?: string;
rule: RuleEntity['id'];
active: boolean | 1 | 0;
next_date: string;
completed: boolean | 1 | 0;
posts_transaction: boolean | 1 | 0;