1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

refactor: use Record to type objects

This commit is contained in:
2024-01-19 18:03:20 +01:00
parent eb5d3f14f1
commit 8928510fb5
40 changed files with 70 additions and 81 deletions

View File

@ -113,7 +113,7 @@ const selectedGroup: Ref<string> = ref('manual');
const selectedMethod: Ref<string> = ref('');
const selectedValue: Ref<string> = ref('');
const debounceTimeout: Ref<NodeJS.Timeout> = ref(null);
const methodParams: Ref<{[key: string]: string}> = ref({});
const methodParams: Ref<Record<string, string>> = ref({});
const enumArray: Ref<string[]> = ref(null);
const fakerGroups = computed(() => {

View File

@ -73,7 +73,7 @@ const props = defineProps({
const emit = defineEmits(['confirm', 'close']);
const firstInput: Ref<HTMLInputElement[]> = ref(null);
const values: Ref<{[key: string]: string}> = ref({});
const values: Ref<Record<string, string>> = ref({});
const inParameters = computed(() => {
return props.localRoutine.parameters.filter(param => param.context === 'IN');

View File

@ -327,7 +327,7 @@ const tables: Ref<{
}[]> = ref([]);
const options: Ref<Partial<ExportOptions>> = ref({
schema: selectedSchema.value,
includes: {} as {[key: string]: boolean},
includes: {} as Record<string, boolean>,
outputFormat: 'sql' as 'sql' | 'sql.zip',
sqlInsertAfter: 250,
sqlInsertDivider: 'bytes' as 'bytes' | 'rows'

View File

@ -142,7 +142,7 @@ const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
const { trapRef } = useFocusTrap({ disableAutofocus: true });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const localRow: Ref<{[key: string]: any}> = ref({});
const localRow: Ref<Record<string, any>> = ref({});
const fieldsToExclude = ref([]);
const nInserts = ref(1);
const isInserting = ref(false);
@ -225,7 +225,7 @@ const insertRows = async () => {
delete rowToInsert[key];
});
const fieldTypes: {[key: string]: string} = {};
const fieldTypes: Record<string, string> = {};
props.fields.forEach(field => {
fieldTypes[field.name] = field.type;
});
@ -290,7 +290,7 @@ onMounted(() => {
}
}, 50);
const rowObj: {[key: string]: unknown} = {};
const rowObj: Record<string, unknown> = {};
if (!props.rowToDuplicate) {
// Set default values

View File

@ -67,7 +67,7 @@ const props = defineProps({
const emit = defineEmits(['select-row', 'contextmenu', 'stop-refresh']);
const isInlineEditor: Ref<{[key: string]: boolean}> = ref({});
const isInlineEditor: Ref<Record<string, boolean>> = ref({});
const isInfoModal = ref(false);
const editorMode = ref('sql');

View File

@ -32,7 +32,7 @@ const { removeNotification } = notificationsStore;
const { notifications } = storeToRefs(notificationsStore);
const { notificationsTimeout } = storeToRefs(settingsStore);
const timeouts: Ref<{[key: string]: NodeJS.Timeout}> = ref({});
const timeouts: Ref<Record<string, NodeJS.Timeout>> = ref({});
const latestNotifications = computed(() => notifications.value.slice(0, 10));

View File

@ -695,7 +695,7 @@ const openAsPermanentTab = (tab: WorkspaceTab) => {
routine: 'routine-props',
procedure: 'routine-props',
scheduler: 'scheduler-props'
} as {[key: string]: string};
} as Record<string, string>;
newTab({
uid: props.connection.uid,

View File

@ -572,11 +572,11 @@ const pathSelection = (event: Event & {target: {files: {path: string}[]}}, name:
const { files } = event.target;
if (!files.length) return;
(connection.value as unknown as {[key: string]: string})[name] = files[0].path as string;
(connection.value as unknown as Record<string, string>)[name] = files[0].path as string;
};
const pathClear = (name: keyof ConnectionParams) => {
(connection.value as unknown as {[key: string]: string})[name] = '';
(connection.value as unknown as Record<string, string>)[name] = '';
};
setDefaults();

View File

@ -569,11 +569,11 @@ const pathSelection = (event: Event & {target: {files: {path: string}[]}}, name:
const { files } = event.target;
if (!files.length) return;
(localConnection.value as unknown as {[key: string]: string})[name] = files[0].path;
(localConnection.value as unknown as Record<string, string>)[name] = files[0].path;
};
const pathClear = (name: keyof ConnectionParams) => {
(localConnection.value as unknown as {[key: string]: string})[name] = '';
(localConnection.value as unknown as Record<string, string>)[name] = '';
};
localConnection.value = JSON.parse(JSON.stringify(props.connection));

View File

@ -382,7 +382,7 @@ const getFieldsData = async () => {
if (status === 'success') {
const indexesObj = response
.filter((index: TableIndex) => index.type !== 'FOREIGN KEY')
.reduce((acc: {[key: string]: TableIndex[]}, curr: TableIndex) => {
.reduce((acc: Record<string, TableIndex[]>, curr: TableIndex) => {
acc[curr.name] = acc[curr.name] || [];
acc[curr.name].push(curr);
return acc;

View File

@ -258,7 +258,7 @@ const indexesPanel: Ref<HTMLDivElement> = ref(null);
const foreignProxy = ref([]);
const selectedForeignID = ref('');
const modalInnerHeight = ref(400);
const refFields = ref({} as {[key: string]: TableField[]});
const refFields = ref({} as Record<string, TableField[]>);
const foreignActions = computed(() => props.workspace.customizations.foreignActions);
const selectedForeignObj = computed(() => foreignProxy.value.find(foreign => foreign._antares_id === selectedForeignID.value));

View File

@ -28,7 +28,7 @@ export function useFilters () {
return `(${num})`;
};
const parseKeys = (keys: {[key: number]: string}[]) => {
const parseKeys = (keys: Record<number, string>[]) => {
const isMacOS = process.platform === 'darwin';
return (keys as string[]).map(k => (
k.split('+')

View File

@ -1,4 +1,4 @@
export const localesNames: {[key: string]: string} = {
export const localesNames: Record<string, string> = {
'en-US': 'English',
'it-IT': 'Italiano',
'ar-SA': 'العربية',

View File

@ -64,7 +64,7 @@ export default class {
primary?: string;
field: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
rows: {[key: string]: any};
rows: Record<string, any>;
}): Promise<IpcResponse> {
return ipcRenderer.invoke('delete-table-rows', unproxify(params));
}
@ -73,9 +73,9 @@ export default class {
uid: string;
schema: string;
table: string;
row: {[key: string]: string | number | boolean | Date | Buffer};
row: Record<string, string | number | boolean | Date | Buffer>;
repeat: number;
fields: {[key: string]: string};
fields: Record<string, string>;
locale: string;
}): Promise<IpcResponse> {
return ipcRenderer.invoke('insert-table-fake-rows', unproxify(params));

View File

@ -13,7 +13,7 @@ export interface HistoryRecord {
export const useHistoryStore = defineStore('history', {
state: () => ({
history: persistentStore.get('history', {}) as {[key: string]: HistoryRecord[]},
history: persistentStore.get('history', {}) as Record<string, HistoryRecord[]>,
favorites: persistentStore.get('favorites', {})
}),
getters: {

View File

@ -86,11 +86,11 @@ export interface Workspace {
arch: string;
os: string;
};
engines?: {[key: string]: string | boolean | number}[];
engines?: Record<string, string | boolean | number>[];
}
const persistentStore = new Store({ name: 'tabs' });
const tabIndex: {[key: string]: number} = {};
const tabIndex: Record<string, number> = {};
export const useWorkspacesStore = defineStore('workspaces', {
state: () => ({