Moved schemas into objects/ definitions

This commit is contained in:
Nicholas Wallace 2024-02-25 18:32:04 +00:00
parent cc37c3d41f
commit cc53f16185
30 changed files with 3380 additions and 3241 deletions

View file

@ -1,3 +1,25 @@
/**
* @openapi
* components:
* schemas:
* audioBookmark:
* type: object
* properties:
* libraryItemId:
* description: The ID of the library item the bookmark is for.
* type: string
* example: li_8gch9ve09orgn4fdz8
* title:
* description: The title of the bookmark.
* type: string
* example: the good part
* time:
* description: The time (in seconds) the bookmark is at in the book.
* type: integer
* example: 16
* createdAt:
* $ref: '#/components/schemas/createdAt'
*/
class AudioBookmark {
constructor(bookmark) {
this.libraryItemId = null

View file

@ -1,5 +1,111 @@
const uuidv4 = require("uuid").v4
/**
* @openapi
* components:
* schemas:
* mediaProgress:
* type: object
* properties:
* id:
* description: The ID of the media progress. If the media progress is for a book, this will just be the libraryItemId. If for a podcast episode, it will be a hyphenated combination of the libraryItemId and episodeId.
* type: string
* example: li_bufnnmp4y5o2gbbxfm-ep_lh6ko39pumnrma3dhv
* libraryItemId:
* description: The ID of the library item the media progress is of.
* type: string
* example: li_bufnnmp4y5o2gbbxfm
* episodeId:
* description: The ID of the podcast episode the media progress is of. Will be null if the progress is for a book.
* type: [string, 'null']
* example: ep_lh6ko39pumnrma3dhv
* duration:
* description: The total duration (in seconds) of the media. Will be 0 if the media was marked as finished without the user listening to it.
* type: number
* example: 1454.18449
* progress:
* description: The percentage completion progress of the media. Will be 1 if the media is finished.
* type: number
* example: 0.011193983371394644
* currentTime:
* description: The current time (in seconds) of the user's progress. If the media has been marked as finished, this will be the time the user was at beforehand.
* type: number
* example: 16.278117
* isFinished:
* description: Whether the media is finished.
* type: boolean
* example: false
* hideFromContinueListening:
* description: Whether the media will be hidden from the "Continue Listening" shelf.
* type: boolean
* example: false
* lastUpdate:
* description: The time (in ms since POSIX epoch) when the media progress was last updated.
* type: integer
* example: 1668120246620
* startedAt:
* description: The time (in ms since POSIX epoch) when the media progress was created.
* type: integer
* example: 1668120083771
* finishedAt:
* description: The time (in ms since POSIX epoch) when the media was finished. Will be null if the media has is not finished.
* type: [string, 'null']
* mediaProgressWithMedia:
* type: object
* properties:
* id:
* description: The ID of the media progress. If the media progress is for a book, this will just be the libraryItemId. If for a podcast episode, it will be a hyphenated combination of the libraryItemId and episodeId.
* type: string
* example: li_bufnnmp4y5o2gbbxfm-ep_lh6ko39pumnrma3dhv
* libraryItemId:
* description: The ID of the library item the media progress is of.
* type: string
* example: li_bufnnmp4y5o2gbbxfm
* episodeId:
* description: The ID of the podcast episode the media progress is of. Will be null if the progress is for a book.
* type: [string, 'null']
* example: ep_lh6ko39pumnrma3dhv
* duration:
* description: The total duration (in seconds) of the media. Will be 0 if the media was marked as finished without the user listening to it.
* type: number
* example: 1454.18449
* progress:
* description: The percentage completion progress of the media. Will be 1 if the media is finished.
* type: number
* example: 0.011193983371394644
* currentTime:
* description: The current time (in seconds) of the user's progress. If the media has been marked as finished, this will be the time the user was at beforehand.
* type: number
* example: 16.278117
* isFinished:
* description: Whether the media is finished.
* type: boolean
* example: false
* hideFromContinueListening:
* description: Whether the media will be hidden from the "Continue Listening" shelf.
* type: boolean
* example: false
* lastUpdate:
* description: The time (in ms since POSIX epoch) when the media progress was last updated.
* type: integer
* example: 1668120246620
* startedAt:
* description: The time (in ms since POSIX epoch) when the media progress was created.
* type: integer
* example: 1668120083771
* finishedAt:
* description: The time (in ms since POSIX epoch) when the media was finished. Will be null if the media has is not finished.
* type: [string, 'null']
* media:
* description: The media of the library item the media progress is for.
* type: object
* additionalProperties:
* oneOf:
* - $ref: '#/components/schemas/bookExpanded'
* - $ref: '#/components/schemas/podcastExpanded'
* episode:
* $ref: '#/components/schemas/podcastEpisode'
*/
class MediaProgress {
constructor(progress) {
this.id = null

View file

@ -2,6 +2,191 @@ const Logger = require('../../Logger')
const AudioBookmark = require('./AudioBookmark')
const MediaProgress = require('./MediaProgress')
/**
* @openapi
* components:
* schemas:
* user:
* type: object
* properties:
* id:
* description: The ID of the user. Only the root user has the root ID.
* type: string
* example: root
* username:
* description: The username of the user.
* type: string
* example: root
* type:
* description: The type of the user. Will be root, guest, user, or admin. There will be only one root user which is created when the server first starts.
* type: string
* example: root
* token:
* description: The authentication token of the user.
* type: string
* example: exJhbGciOiJI6IkpXVCJ9.eyJ1c2Vyi5NDEyODc4fQ.ZraBFohS4Tg39NszY
* mediaProgress:
* description: The user's media progress.
* type: array
* items:
* $ref: '#/components/schemas/mediaProgress'
* seriesHideFromContinueListening:
* description: The IDs of series to hide from the user's "Continue Series" shelf.
* type: array
* items:
* type: string
* example: ...
* bookmarks:
* description: The user's bookmarks.
* type: array
* items:
* $ref: '#/components/schemas/audioBookmark'
* isActive:
* description: Whether the user's account is active.
* type: boolean
* example: true
* isLocked:
* description: Whether the user is locked.
* type: boolean
* example: false
* lastSeen:
* description: The time (in ms since POSIX epoch) when the user was last seen by the server. Will be null if the user has never logged in.
* type: integer
* example: 1668296147437
* createdAt:
* $ref: '#/components/schemas/createdAt'
* permissions:
* $ref: '#/components/schemas/userPermissions'
* librariesAccessible:
* description: The IDs of libraries accessible to the user. An empty array means all libraries are accessible.
* type: array
* items:
* type: string
* example: ...
* itemTagsAccessible:
* description: The tags accessible to the user. An empty array means all tags are accessible.
* type: array
* items:
* type: string
* example: ...
* userWithProgressDetails:
* type: object
* properties:
* id:
* description: The ID of the user. Only the root user has the root ID.
* type: string
* example: root
* username:
* description: The username of the user.
* type: string
* example: root
* type:
* description: The type of the user. Will be root, guest, user, or admin. There will be only one root user which is created when the server first starts.
* type: string
* example: root
* token:
* description: The authentication token of the user.
* type: string
* example: exJhbGciOiJI6IkpXVCJ9.eyJ1c2Vyi5NDEyODc4fQ.ZraBFohS4Tg39NszY
* mediaProgress:
* description: The user's media progress.
* type: array
* items:
* $ref: '#/components/schemas/mediaProgressWithMedia'
* seriesHideFromContinueListening:
* description: The IDs of series to hide from the user's "Continue Series" shelf.
* type: array
* items:
* type: string
* example: ...
* bookmarks:
* description: The user's bookmarks.
* type: array
* items:
* $ref: '#/components/schemas/audioBookmark'
* isActive:
* description: Whether the user's account is active.
* type: boolean
* example: true
* isLocked:
* description: Whether the user is locked.
* type: boolean
* example: false
* lastSeen:
* description: The time (in ms since POSIX epoch) when the user was last seen by the server. Will be null if the user has never logged in.
* type: integer
* example: 1668296147437
* createdAt:
* $ref: '#/components/schemas/createdAt'
* permissions:
* $ref: '#/components/schemas/userPermissions'
* librariesAccessible:
* description: The IDs of libraries accessible to the user. An empty array means all libraries are accessible.
* type: array
* items:
* type: string
* example: ...
* itemTagsAccessible:
* description: The tags accessible to the user. An empty array means all tags are accessible.
* type: array
* items:
* type: string
* example: ...
* userWithSession:
* type: object
* properties:
* id:
* description: The ID of the user. Only the root user has the root ID.
* type: string
* example: root
* username:
* description: The username of the user.
* type: string
* example: root
* type:
* description: The type of the user. Will be root, guest, user, or admin. There will be only one root user which is created when the server first starts.
* type: string
* example: root
* session:
* $ref: '#/components/schemas/playbackSessionExpanded'
* lastSeen:
* description: The time (in ms since POSIX epoch) when the user was last seen by the server. Will be null if the user has never logged in.
* type: integer
* example: 1668296147437
* createdAt:
* $ref: '#/components/schemas/createdAt'
* userPermissions:
* type: object
* properties:
* download:
* description: Whether the user can download items to the server.
* type: boolean
* example: true
* update:
* description: Whether the user can update library items.
* type: boolean
* example: true
* delete:
* description: Whether the user can delete library items.
* type: boolean
* example: true
* upload:
* description: Whether the user can upload items to the server.
* type: boolean
* example: true
* accessAllLibraries:
* description: Whether the user can access all libraries.
* type: boolean
* example: true
* accessAllTags:
* description: Whether the user can access all tags.
* type: boolean
* example: true
* accessExplicitContent:
* description: Whether the user can access explicit content.
* type: boolean
* example: true
*/
class User {
constructor(user) {
this.id = null