/*
 * SPDX-FileCopyrightText: 2025 The HedgeDoc developers (see AUTHORS file)
 *
 * SPDX-License-Identifier: AGPL-3.0-only
 */

/**
 * Notes are the central part of HedgeDoc. A note is accessed and identified by a list of aliases.
 * The note object itself only contains basic metadata about the note. The content is stored in note revisions.
 * The permission management is extracted into the note-user and note-group permission tables.
 */
export interface Note {
  /** The unique id of the note for internal referencing */
  [FieldNameNote.id]: number

  /** The {@link User} id of the note owner */
  [FieldNameNote.ownerId]: number

  /** The HedgeDoc major version this note was created in. This is used to migrate certain features from HD1 to HD2 */
  [FieldNameNote.version]: number

  /** Timestamp when the note was created */
  [FieldNameNote.createdAt]: string

  /** If a note should be visible in the public notes section */
  [FieldNameNote.publiclyVisible]: boolean
}

export enum FieldNameNote {
  id = 'id',
  ownerId = 'owner_id',
  version = 'version',
  createdAt = 'created_at',
  publiclyVisible = 'publicly_visible',
}

export const TableNote = 'note'

export type TypeInsertNote = Omit<Note, FieldNameNote.id>
export type TypeUpdateNote =
  | Pick<Note, FieldNameNote.ownerId>
  | Pick<Note, FieldNameNote.publiclyVisible>
