2024-02-06 14:43:12 +00:00
|
|
|
export type RequestLogItem = {
|
2024-02-03 09:51:35 +00:00
|
|
|
failed: boolean;
|
|
|
|
url: string;
|
|
|
|
name: string;
|
|
|
|
error?: string;
|
|
|
|
};
|
|
|
|
|
2024-02-27 12:00:03 +00:00
|
|
|
export const gridSortOrderKeys = [
|
|
|
|
'name',
|
|
|
|
'category',
|
|
|
|
'aliases',
|
|
|
|
'type',
|
|
|
|
'license',
|
|
|
|
'host',
|
|
|
|
'uri',
|
|
|
|
'publicUrl',
|
|
|
|
'isSensitive',
|
|
|
|
'localOnly',
|
|
|
|
'updatedAt',
|
|
|
|
];
|
|
|
|
export type GridSortOrderKey = typeof gridSortOrderKeys[number];
|
|
|
|
|
|
|
|
export type GridSortOrder = {
|
|
|
|
key: GridSortOrderKey;
|
|
|
|
direction: 'ASC' | 'DESC';
|
|
|
|
}
|
|
|
|
|
2024-02-07 23:12:04 +00:00
|
|
|
export function emptyStrToUndefined(value: string | null) {
|
|
|
|
return value ? value : undefined;
|
2024-01-27 03:02:50 +00:00
|
|
|
}
|
|
|
|
|
2024-02-07 23:12:04 +00:00
|
|
|
export function emptyStrToNull(value: string) {
|
|
|
|
return value === '' ? null : value;
|
2024-02-01 11:59:30 +00:00
|
|
|
}
|
2024-01-22 01:37:44 +00:00
|
|
|
|
2024-02-07 23:12:04 +00:00
|
|
|
export function emptyStrToEmptyArray(value: string) {
|
|
|
|
return value === '' ? [] : value.split(',').map(it => it.trim());
|
2024-01-21 02:39:52 +00:00
|
|
|
}
|
2024-02-06 14:43:12 +00:00
|
|
|
|
2024-02-25 23:12:37 +00:00
|
|
|
export function roleIdsParser(text: string): { id: string, name: string }[] {
|
|
|
|
// idとnameのペア配列をJSONで受け取る。それ以外の形式は許容しない
|
|
|
|
try {
|
|
|
|
const obj = JSON.parse(text);
|
|
|
|
if (!Array.isArray(obj)) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
if (!obj.every(it => typeof it === 'object' && 'id' in it && 'name' in it)) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return obj.map(it => ({ id: it.id, name: it.name }));
|
|
|
|
} catch (ex) {
|
|
|
|
console.warn(ex);
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|