mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 07:40:59 +00:00
188c6153d5
The assistant tables gave Users three more relations, and a spread of overrides checked against RequiredEntityData now ran tsc past its instantiation depth (TS2589). Every factory passes its overrides as createRow's own argument, the way rows.ts documents it.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { CollabMessages } from '../../../src/db/entities/CollabMessages.entity';
|
|
import { CollabNotes } from '../../../src/db/entities/CollabNotes.entity';
|
|
import type { FactoryOrm } from './context';
|
|
import { createRow } from './rows';
|
|
import type { EntityData, EntityDTO } from '@mikro-orm/core';
|
|
|
|
export type CollabNoteRow = EntityDTO<CollabNotes>;
|
|
export type CollabMessageRow = EntityDTO<CollabMessages>;
|
|
|
|
/** A note on the trip's collab board, written by `userId`. */
|
|
export function makeCollabNote(
|
|
orm: FactoryOrm,
|
|
tripId: number,
|
|
userId: number,
|
|
overrides: EntityData<CollabNotes> = {},
|
|
): Promise<CollabNoteRow> {
|
|
return createRow(
|
|
orm,
|
|
CollabNotes,
|
|
{
|
|
trip: tripId,
|
|
user: userId,
|
|
title: 'Test Note',
|
|
content: null,
|
|
category: 'General',
|
|
color: '#6366f1',
|
|
},
|
|
overrides,
|
|
);
|
|
}
|
|
|
|
/** A chat message on the trip; `replyToRef` makes it a reply. */
|
|
export function makeCollabMessage(
|
|
orm: FactoryOrm,
|
|
tripId: number,
|
|
userId: number,
|
|
overrides: EntityData<CollabMessages> = {},
|
|
): Promise<CollabMessageRow> {
|
|
return createRow(orm, CollabMessages, { trip: tripId, user: userId, text: 'Test message' }, overrides);
|
|
}
|