refactor: reorganize files in commons package

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-05-29 18:37:06 +02:00
parent c9b98f6185
commit 4d9792bcb9
23 changed files with 94 additions and 69 deletions

View file

@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export * from './extractor.js'
export * from './types.js'

View file

@ -4,40 +4,11 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
export * from './message-transporters/mocked-backend-message-transporter.js' export * from './frontmatter-extractor/index.js'
export * from './message-transporters/message.js' export * from './message-transporters/index.js'
export * from './message-transporters/message-transporter.js' export * from './note-frontmatter/index.js'
export * from './message-transporters/realtime-user.js' export * from './note-frontmatter-parser/index.js'
export * from './message-transporters/websocket-transporter.js' export * from './parse-url/index.js'
export * from './permissions/index.js'
export { parseUrl } from './utils/parse-url.js' export * from './title-extraction/index.js'
export { export * from './y-doc-sync/index.js'
MissingTrailingSlashError,
WrongProtocolError
} from './utils/errors.js'
export * from './utils/permissions.js'
export * from './utils/permissions.types.js'
export * from './y-doc-sync/y-doc-sync-client-adapter.js'
export * from './y-doc-sync/y-doc-sync-server-adapter.js'
export * from './y-doc-sync/y-doc-sync-adapter.js'
export * from './y-doc-sync/realtime-doc.js'
export { waitForOtherPromisesToFinish } from './utils/wait-for-other-promises-to-finish.js'
export * from './frontmatter-extractor/extractor.js'
export * from './frontmatter-extractor/types.js'
export * from './note-frontmatter-parser/parse-raw-frontmatter-from-yaml.js'
export * from './note-frontmatter-parser/convert-raw-frontmatter-to-note-frontmatter.js'
export * from './note-frontmatter-parser/default-values.js'
export * from './note-frontmatter-parser/parse-tags.js'
export * from './note-frontmatter-parser/types.js'
export * from './note-frontmatter/iso6391.js'
export * from './note-frontmatter/frontmatter.js'
export * from './note-frontmatter/slide-show-options.js'
export * from './title-extraction/generate-note-title.js'
export { extractFirstHeading } from './title-extraction/extract-first-heading.js'

View file

@ -0,0 +1,11 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export * from './mocked-backend-message-transporter.js'
export * from './message.js'
export * from './message-transporter.js'
export * from './realtime-user.js'
export * from './websocket-transporter.js'

View file

@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { NoteFrontmatter } from '../note-frontmatter/frontmatter.js' import { NoteFrontmatter } from '../note-frontmatter/index.js'
import { parseTags } from './parse-tags.js' import { parseTags } from './parse-tags.js'
import { RawNoteFrontmatter } from './types.js' import { RawNoteFrontmatter } from './types.js'

View file

@ -0,0 +1,10 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export * from './parse-raw-frontmatter-from-yaml.js'
export * from './convert-raw-frontmatter-to-note-frontmatter.js'
export * from './parse-tags.js'
export * from './types.js'

View file

@ -3,14 +3,14 @@
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { defaultNoteFrontmatter } from '../note-frontmatter/index.js'
import { import {
NoteTextDirection, NoteTextDirection,
NoteType, NoteType,
OpenGraph OpenGraph
} from '../note-frontmatter/frontmatter.js' } from '../note-frontmatter/index.js'
import { SlideOptions } from '../note-frontmatter/index.js'
import { ISO6391 } from '../note-frontmatter/iso6391.js' import { ISO6391 } from '../note-frontmatter/iso6391.js'
import { SlideOptions } from '../note-frontmatter/slide-show-options.js'
import { defaultNoteFrontmatter } from './default-values.js'
import type { RawNoteFrontmatter } from './types.js' import type { RawNoteFrontmatter } from './types.js'
import type { ValidationError } from 'joi' import type { ValidationError } from 'joi'
import Joi from 'joi' import Joi from 'joi'

View file

@ -8,8 +8,8 @@ import {
NoteTextDirection, NoteTextDirection,
NoteType, NoteType,
OpenGraph OpenGraph
} from '../note-frontmatter/frontmatter.js' } from '../note-frontmatter/index.js'
import { SlideOptions } from '../note-frontmatter/slide-show-options.js' import { SlideOptions } from '../note-frontmatter/index.js'
export interface RawNoteFrontmatter { export interface RawNoteFrontmatter {
title: string title: string

View file

@ -3,12 +3,8 @@
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { import { NoteFrontmatter, NoteTextDirection, NoteType } from './frontmatter.js'
NoteFrontmatter, import { SlideOptions } from './slide-show-options.js'
NoteTextDirection,
NoteType
} from '../note-frontmatter/frontmatter.js'
import { SlideOptions } from '../note-frontmatter/slide-show-options.js'
export const defaultSlideOptions: SlideOptions = { export const defaultSlideOptions: SlideOptions = {
transition: 'zoom', transition: 'zoom',

View file

@ -0,0 +1,10 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export * from './iso6391.js'
export * from './frontmatter.js'
export * from './slide-show-options.js'
export * from './default-values.js'

View file

@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export { parseUrl } from './parse-url.js'
export { MissingTrailingSlashError, WrongProtocolError } from './errors.js'

View file

@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export * from './permissions.js'
export * from './permissions.types.js'

View file

@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export * from './generate-note-title.js'
export * from './extract-first-heading.js'

View file

@ -1,17 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
/**
* Waits until all other pending promises are processed.
*
* NodeJS has a queue for async code that waits for being processed. This method adds a promise to the very end of this queue.
* If the promise is resolved then this means that all other promises before it have been processed as well.
*
* @return A promise which resolves when all other promises have been processed
*/
export function waitForOtherPromisesToFinish(): Promise<void> {
return new Promise((resolve) => process.nextTick(resolve))
}

View file

@ -0,0 +1,9 @@
/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
export * from './y-doc-sync-client-adapter.js'
export * from './y-doc-sync-server-adapter.js'
export * from './y-doc-sync-adapter.js'
export * from './realtime-doc.js'

View file

@ -122,7 +122,7 @@ declare module 'reveal.js' {
export interface Plugin { export interface Plugin {
id: string id: string
init(deck: RevealStatic): void | Promise<void> init(deck: Reveal): void | Promise<void>
} }
export default class Reveal { export default class Reveal {

View file

@ -8,10 +8,13 @@ import type { Note, NoteMetadata } from '../../../api/notes/types'
import * as useSingleStringUrlParameterModule from '../../../hooks/common/use-single-string-url-parameter' import * as useSingleStringUrlParameterModule from '../../../hooks/common/use-single-string-url-parameter'
import { mockI18n } from '../../../test-utils/mock-i18n' import { mockI18n } from '../../../test-utils/mock-i18n'
import { CreateNonExistingNoteHint } from './create-non-existing-note-hint' import { CreateNonExistingNoteHint } from './create-non-existing-note-hint'
import { waitForOtherPromisesToFinish } from '@hedgedoc/commons'
import { act, render, screen, waitFor } from '@testing-library/react' import { act, render, screen, waitFor } from '@testing-library/react'
import { Mock } from 'ts-mockery' import { Mock } from 'ts-mockery'
function waitForOtherPromisesToFinish(): Promise<void> {
return new Promise((resolve) => process.nextTick(resolve))
}
jest.mock('../../../api/notes') jest.mock('../../../api/notes')
jest.mock('../../../hooks/common/use-single-string-url-parameter') jest.mock('../../../hooks/common/use-single-string-url-parameter')

View file

@ -122,7 +122,7 @@ declare module 'reveal.js' {
export interface Plugin { export interface Plugin {
id: string id: string
init(deck: RevealStatic): void | Promise<void> init(deck: Reveal): void | Promise<void>
} }
export default class Reveal { export default class Reveal {