chore: fix uuid generation for importers

This commit is contained in:
Mo
2023-08-07 05:06:11 -05:00
parent cedd8e1006
commit ee473fe34d
17 changed files with 94 additions and 47 deletions

View File

@@ -1,12 +1,17 @@
import { UuidGenerator } from '@standardnotes/utils'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { SimplenoteConverter } from './SimplenoteConverter'
import data from './testData'
UuidGenerator.SetGenerator(() => String(Math.random()))
import { GenerateUuid } from '@standardnotes/services'
describe('SimplenoteConverter', () => {
const crypto = {
generateUUID: () => String(Math.random()),
} as unknown as PureCryptoInterface
const generateUuid = new GenerateUuid(crypto)
it('should parse', () => {
const converter = new SimplenoteConverter()
const converter = new SimplenoteConverter(generateUuid)
const result = converter.parse(data)

View File

@@ -1,7 +1,7 @@
import { DecryptedTransferPayload, NoteContent } from '@standardnotes/models'
import { ContentType } from '@standardnotes/domain-core'
import { readFileAsText } from '../Utils'
import { UuidGenerator } from '@standardnotes/utils'
import { GenerateUuid } from '@standardnotes/services'
type SimplenoteItem = {
creationDate: string
@@ -18,7 +18,7 @@ type SimplenoteData = {
const isSimplenoteEntry = (entry: any): boolean => entry.id && entry.content && entry.creationDate && entry.lastModified
export class SimplenoteConverter {
constructor() {}
constructor(private _generateUuid: GenerateUuid) {}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static isValidSimplenoteJson(json: any): boolean {
@@ -55,7 +55,7 @@ export class SimplenoteConverter {
created_at_timestamp: createdAtDate.getTime(),
updated_at: updatedAtDate,
updated_at_timestamp: updatedAtDate.getTime(),
uuid: UuidGenerator.GenerateUuid(),
uuid: this._generateUuid.execute().getValue(),
content_type: ContentType.TYPES.Note,
content: {
title,