Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update import naming convention (#2413)
Leendert de Borst546febad916a
diff --git a/core/client/src/transfer/export/ItemCsvExportService.ts b/core/client/src/transfer/export/AliasVaultCsvExportService.tssimilarity index 87%rename from core/client/src/transfer/export/ItemCsvExportService.tsrename to core/client/src/transfer/export/AliasVaultCsvExportService.tsindex 7dea6e9ac..9ae5c2d18 100644--- a/core/client/src/transfer/export/ItemCsvExportService.ts+++ b/core/client/src/transfer/export/AliasVaultCsvExportService.ts@@ -8,7 +8,7 @@ import { writeCsv } from './CsvWriter';import type { Item, TotpCode } from '@aliasvault/models/vault';/** The columns of the AliasVault CSV export. */-export const ITEM_CSV_COLUMNS = [+export const ALIASVAULT_CSV_COLUMNS = ['ServiceName','FolderPath','ServiceUrl',@@ -32,12 +32,12 @@ export const ITEM_CSV_COLUMNS = [] as const;/** One column of the AliasVault CSV export. */-export type ItemCsvColumn = (typeof ITEM_CSV_COLUMNS)[number];+export type AliasVaultCsvColumn = (typeof ALIASVAULT_CSV_COLUMNS)[number];/*** Exports items to the AliasVault CSV format.*/-export class ItemCsvExportService {+export class AliasVaultCsvExportService {/*** Export items to CSV.* @param items - The items to export@@ -53,18 +53,18 @@ export class ItemCsvExportService {* A single field value, or the empty string when absent.*/const field = (fieldKey: string): string => getFieldValue(item, fieldKey) ?? '';- const record: Record<ItemCsvColumn, string | Date | null> = {+ const record: Record<AliasVaultCsvColumn, string | Date | null> = {ServiceName: item.Name ?? '',FolderPath: item.FolderPath?.join('/') ?? '',ServiceUrl: getFieldValues(item, FieldKey.LoginUrl).map(url => url.trim()).filter(url => url.length > 0).join(','),Username: field(FieldKey.LoginUsername),CurrentPassword: field(FieldKey.LoginPassword),AliasEmail: field(FieldKey.LoginEmail),- TwoFactorSecret: ItemCsvExportService.formatTwoFactorSecret(getTotpCodes(item)[0] ?? null),+ TwoFactorSecret: AliasVaultCsvExportService.formatTwoFactorSecret(getTotpCodes(item)[0] ?? null),AliasGender: field(FieldKey.AliasGender),AliasFirstName: field(FieldKey.AliasFirstName),AliasLastName: field(FieldKey.AliasLastName),- AliasBirthDate: ItemCsvExportService.parseBirthDate(field(FieldKey.AliasBirthdate)),+ AliasBirthDate: AliasVaultCsvExportService.parseBirthDate(field(FieldKey.AliasBirthdate)),Notes: field(FieldKey.NotesContent),CardholderName: field(FieldKey.CardCardholderName),CardNumber: field(FieldKey.CardNumber),@@ -76,16 +76,16 @@ export class ItemCsvExportService {UpdatedAt: fromStandardFormat(item.UpdatedAt),};- return ITEM_CSV_COLUMNS.map(header => {+ return ALIASVAULT_CSV_COLUMNS.map(header => {const value = record[header];if (value instanceof Date) {- return ItemCsvExportService.formatDateTime(value);+ return AliasVaultCsvExportService.formatDateTime(value);}return value ?? '';});});- return new TextEncoder().encode(writeCsv([...ITEM_CSV_COLUMNS], rows));+ return new TextEncoder().encode(writeCsv([...ALIASVAULT_CSV_COLUMNS], rows));}/**diff --git a/core/client/src/transfer/import/importers/aliasvault/ItemCsvImportService.ts b/core/client/src/transfer/import/importers/aliasvault/AliasVaultCsvImportService.tssimilarity index 88%rename from core/client/src/transfer/import/importers/aliasvault/ItemCsvImportService.tsrename to core/client/src/transfer/import/importers/aliasvault/AliasVaultCsvImportService.tsindex 5a3d05eff..6c5cba0a3 100644--- a/core/client/src/transfer/import/importers/aliasvault/ItemCsvImportService.ts+++ b/core/client/src/transfer/import/importers/aliasvault/AliasVaultCsvImportService.ts@@ -4,7 +4,7 @@ import { nullIfBlank } from '../../../shared/StringUtils';import { dateTime, readCsvRecords, text, type CsvColumn, type CsvRecord } from '../../readers/CsvRecordMapper';import { parseUrls } from '../shared/CredentialHelpers';-import type { ItemCsvColumn } from '../../../export/ItemCsvExportService';+import type { AliasVaultCsvColumn } from '../../../export/AliasVaultCsvExportService';import type { ImportedCredential } from '../../models/ImportedCredential';/** How each column of the AliasVault CSV export is read. */@@ -29,17 +29,17 @@ const COLUMNS = {Notes: text,CreatedAt: dateTime,UpdatedAt: dateTime,-} satisfies Record<ItemCsvColumn, CsvColumn<unknown>>;+} satisfies Record<AliasVaultCsvColumn, CsvColumn<unknown>>;/*** A row of the AliasVault CSV export.*/-type ItemCsvRecord = CsvRecord<typeof COLUMNS>;+type AliasVaultCsvRecord = CsvRecord<typeof COLUMNS>;/*** Imports items from the AliasVault CSV format.*/-export class ItemCsvImportService {+export class AliasVaultCsvImportService {/*** Import items from an AliasVault CSV file.* @param fileContent - The CSV file content@@ -74,7 +74,7 @@ export class ItemCsvImportService {FolderPath: nullIfBlank(record.FolderPath),};- if (ItemCsvImportService.hasCardData(record)) {+ if (AliasVaultCsvImportService.hasCardData(record)) {credential.ItemType = ItemTypes.CreditCard;credential.Creditcard = {CardholderName: record.CardholderName,@@ -95,7 +95,7 @@ export class ItemCsvImportService {* @param record - The record* @returns True when a card field has a value*/- private static hasCardData(record: ItemCsvRecord): boolean {+ private static hasCardData(record: AliasVaultCsvRecord): boolean {return [record.CardholderName, record.CardNumber, record.CardExpiryMonth, record.CardExpiryYear, record.CardCvv, record.CardPin].some(value => value.trim().length > 0);}}