@overture-stack/lyric
Version:
Data Submission system
40 lines (39 loc) • 2.07 kB
TypeScript
import { type Category, type Dictionary, type DictionaryMigration, type NewDictionaryMigration } from '@overture-stack/lyric-data-model/models';
import type { BaseDependencies } from '../config/config.js';
import type { PaginatedResult } from '../utils/result.js';
import type { MigrationAuditRecord, MigrationStatus, PaginationOptions } from '../utils/types.js';
type MigrationRepositoryRecord = Omit<DictionaryMigration, 'categoryId' | 'fromDictionaryId' | 'toDictionaryId'>;
/**
* Defines the structure of a Migration record returned by the repository,
* includes related entities like category and dictionaries.
*/
export type MigrationRecordWithRelations = MigrationRepositoryRecord & {
category: Pick<Category, 'id' | 'name'>;
fromDictionary: Pick<Dictionary, 'name' | 'version'> | null;
toDictionary: Pick<Dictionary, 'name' | 'version'> | null;
};
declare const repository: (dependencies: BaseDependencies) => {
/**
* Save a new Dictionary Migration in Database
* Returns the inserted record's ID
**/
save: (data: NewDictionaryMigration) => Promise<number>;
/** Update an existing Dictionary Migration in Database */
update: (migrationId: number, data: Partial<MigrationRepositoryRecord>) => Promise<number>;
/** Retrieve a Dictionary Migration by ID */
getMigrationById: (migrationId: number) => Promise<MigrationRecordWithRelations | undefined>;
/** Retrieve Dictionary Migrations by Category ID with filter options */
getMigrationsByCategoryId: (categoryId: number, paginationOptions: PaginationOptions, filterOptions: {
status?: MigrationStatus;
fromDictionaryId?: number;
toDictionaryId?: number;
}) => Promise<PaginatedResult<MigrationRecordWithRelations>>;
getMigrationAuditRecords: (migrationId: number, options: {
page: number;
pageSize: number;
entityNames?: string | string[];
organizations?: string | string[];
isInvalid?: boolean;
}) => Promise<PaginatedResult<MigrationAuditRecord>>;
};
export default repository;