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