refactor: importer
This commit is contained in:
@@ -67,6 +67,7 @@ export class AegisToAuthenticatorConverter implements Converter {
|
||||
text,
|
||||
noteType: NoteType.Authentication,
|
||||
editorIdentifier: NativeFeatureIdentifier.TYPES.TokenVaultEditor,
|
||||
useSuperIfPossible: false,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ export type CreateNoteFn = (options: {
|
||||
pinned?: boolean
|
||||
trashed?: boolean
|
||||
editorIdentifier?: NoteContent['editorIdentifier']
|
||||
useSuperIfPossible: boolean
|
||||
}) => DecryptedTransferPayload<NoteContent>
|
||||
|
||||
export type CreateTagFn = (options: {
|
||||
|
||||
@@ -3,7 +3,6 @@ import dayjs from 'dayjs'
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat'
|
||||
import utc from 'dayjs/plugin/utc'
|
||||
import { GenerateUuid } from '@standardnotes/services'
|
||||
import { NoteType } from '@standardnotes/features'
|
||||
import MD5 from 'crypto-js/md5'
|
||||
import Base64 from 'crypto-js/enc-base64'
|
||||
import { Converter } from '../Converter'
|
||||
@@ -109,7 +108,7 @@ export class EvernoteConverter implements Converter {
|
||||
updatedAt: updatedAtDate,
|
||||
title: !title ? `Imported note ${index + 1} from Evernote` : title,
|
||||
text,
|
||||
noteType: NoteType.Super,
|
||||
useSuperIfPossible: canUseSuper,
|
||||
})
|
||||
|
||||
const xmlTags = xmlNote.getElementsByTagName('tag')
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { DecryptedTransferPayload, NoteContent } from '@standardnotes/models'
|
||||
import { NoteType } from '@standardnotes/features'
|
||||
import { Converter, CreateNoteFn } from '../Converter'
|
||||
|
||||
type Content =
|
||||
@@ -125,7 +124,7 @@ export class GoogleKeepConverter implements Converter {
|
||||
updatedAt: date,
|
||||
title: title,
|
||||
text: content,
|
||||
noteType: NoteType.Super,
|
||||
useSuperIfPossible: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -181,7 +180,7 @@ export class GoogleKeepConverter implements Converter {
|
||||
archived: Boolean(parsed.isArchived),
|
||||
trashed: Boolean(parsed.isTrashed),
|
||||
pinned: Boolean(parsed.isPinned),
|
||||
noteType: NoteType.Super,
|
||||
useSuperIfPossible: true,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { NoteType } from '@standardnotes/features'
|
||||
import { parseFileName } from '@standardnotes/filepicker'
|
||||
import { Converter } from '../Converter'
|
||||
|
||||
@@ -33,7 +32,7 @@ export class HTMLConverter implements Converter {
|
||||
updatedAt: updatedAtDate,
|
||||
title: name,
|
||||
text,
|
||||
noteType: NoteType.Super,
|
||||
useSuperIfPossible: true,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ export class Importer {
|
||||
trashed,
|
||||
archived,
|
||||
pinned,
|
||||
useSuperIfPossible,
|
||||
}) => {
|
||||
if (noteType === NoteType.Super && !this.isEntitledToSuper()) {
|
||||
noteType = undefined
|
||||
@@ -111,6 +112,8 @@ export class Importer {
|
||||
editorIdentifier = undefined
|
||||
}
|
||||
|
||||
const shouldUseSuper = useSuperIfPossible && this.isEntitledToSuper()
|
||||
|
||||
return {
|
||||
created_at: createdAt,
|
||||
created_at_timestamp: createdAt.getTime(),
|
||||
@@ -122,11 +125,11 @@ export class Importer {
|
||||
title,
|
||||
text,
|
||||
references: [],
|
||||
noteType,
|
||||
noteType: shouldUseSuper ? NoteType.Super : noteType,
|
||||
trashed,
|
||||
archived,
|
||||
pinned,
|
||||
editorIdentifier,
|
||||
editorIdentifier: shouldUseSuper ? NativeFeatureIdentifier.TYPES.SuperEditor : editorIdentifier,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { parseFileName } from '@standardnotes/filepicker'
|
||||
import { Converter } from '../Converter'
|
||||
import { NoteType } from '@standardnotes/features'
|
||||
|
||||
export class PlaintextConverter implements Converter {
|
||||
constructor() {}
|
||||
@@ -35,7 +34,7 @@ export class PlaintextConverter implements Converter {
|
||||
updatedAt: updatedAtDate,
|
||||
title: name,
|
||||
text: convertMarkdownToSuper(content),
|
||||
noteType: NoteType.Super,
|
||||
useSuperIfPossible: true,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ export class SimplenoteConverter implements Converter {
|
||||
title,
|
||||
text: content,
|
||||
trashed,
|
||||
useSuperIfPossible: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { SuperConverterServiceInterface } from '@standardnotes/files'
|
||||
import { parseFileName } from '@standardnotes/filepicker'
|
||||
import { NoteType } from '@standardnotes/features'
|
||||
import { Converter } from '../Converter'
|
||||
|
||||
export class SuperConverter implements Converter {
|
||||
@@ -36,7 +35,7 @@ export class SuperConverter implements Converter {
|
||||
updatedAt: updatedAtDate,
|
||||
title: name,
|
||||
text: content,
|
||||
noteType: NoteType.Super,
|
||||
useSuperIfPossible: true,
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user