chore: create import map utilities

This commit is contained in:
cv
2023-09-27 12:15:50 +02:00
parent b8188c7485
commit 52ca04e063
2 changed files with 51 additions and 0 deletions
+7
View File
@@ -23,3 +23,10 @@ export { deepmerge } from './src/externals/deepmerge.js';
// generic utilities
export { isNumeric } from './src/types/types.js';
// feature business logic - excel import
export {
type ExcelImportMap,
type ExcelImportOptions,
defaultExcelImportMap,
isExcelImportMap,
} from './src/feature/excel-import/excelImport.js';
@@ -0,0 +1,44 @@
export type ExcelImportOptions = keyof typeof defaultExcelImportMap;
export type ExcelImportMap = typeof defaultExcelImportMap;
export const defaultExcelImportMap = {
worksheet: 'event schedule',
projectName: 'project name',
projectDescription: 'project descriptotion',
publicUrl: 'public url',
publicInfo: 'public info',
backstageUrl: 'backstage url',
backstageInfo: 'backstage info',
timeStart: 'time start',
timeEnd: 'time end',
duration: 'duration',
cue: 'cue',
title: 'event title',
presenter: 'presenter name',
subtitle: 'event subtitle',
isPublic: 'is public? (x)',
skip: 'skip? (x)',
note: 'notes',
colour: 'colour',
endAction: 'end action',
timerType: 'timer type',
user0: 'user0',
user1: 'user1',
user2: 'user2',
user3: 'user3',
user4: 'user4',
user5: 'user5',
user6: 'user6',
user7: 'user7',
user8: 'user8',
user9: 'user9',
};
export function isExcelImportMap(obj: unknown): obj is ExcelImportMap {
if (typeof obj !== 'object' || obj === null) {
return false;
}
const keys = Object.keys(obj);
return keys.every((key) => Object.hasOwn(defaultExcelImportMap, key));
}