move docs

This commit is contained in:
SrGooglo 2025-05-21 18:55:23 +00:00
parent 179496b061
commit d0ccdfed2b
55 changed files with 1148 additions and 941 deletions

View File

@ -1,9 +0,0 @@
---
sidebar_position: 3
---
# Authenticating
## Server Keys
## User Token

View File

@ -1,7 +0,0 @@
{
"label": "Definitions",
"position": 6,
"link": {
"type": "generated-index"
}
}

View File

@ -1,6 +0,0 @@
# Like Status Object
| Parameter | Type | Content |
| --- | --- | --- |
| post_id | string | |
| liked | Boolean | |
| count | Number | Current like count |

View File

@ -1,8 +0,0 @@
# Post Object
| Parameter | Type | Content |
| --- | --- | --- |
| _id | string | |
| user_id | string | |
| message | string | |
| created_at | string | |
| updated_at | string | |

View File

@ -1,6 +0,0 @@
# Save Status Object
| Parameter | Type | Content |
| --- | --- | --- |
| post_id | string | |
| saved | Boolean | |
| count | Number | Current global save count |

View File

@ -1,37 +0,0 @@
---
sidebar_position: 1
---
# Getting Started with Comty.JS
[https://github.com/ragestudio/comty.js](https://github.com/ragestudio/comty.js)
Welcome to Comty.JS, the official JavaScript library for interacting with the Comty API! This library is designed to simplify communication with Comty services, whether you're building a server-side application or a client-side interface.
## What is Comty.JS?
Comty.JS provides a convenient wrapper around the Comty API, handling authentication, request management, real-time communication via WebSockets, and more. It aims to make your development process smoother and more efficient by abstracting away the complexities of direct API interaction.
**Key Features:**
- **Simplified API Access:** Easy-to-use models for various Comty services like Authentication, Posts, User Management, Music, Chats, and more.
- **Authentication Handling:** Built-in support for server keys and user token-based authentication, including automatic token refresh.
- **WebSocket Integration:** Seamlessly connect to Comty's real-time services.
- **Addon System:** Extend the library's functionality with custom addons.
- **Environment Aware:** Works in both Node.js (server-side) and browser (client-side) environments.
- **Request Management:** Uses `axios` for HTTP requests with interceptors for automatic token attachment and error handling.
## Who is this for?
This library is for developers who want to:
- Integrate their JavaScript or TypeScript applications with Comty.
- Build features that utilize Comty's social, music, or other platform functionalities.
- Quickly set up communication with the Comty API without dealing with raw HTTP requests and WebSocket management.
## Next Steps
1. **[Installing Comty.JS](./installing.md)**: Learn how to add the library to your project.
2. **[Client Initialization](./client-initialization.md)**: Understand how to set up and configure the Comty.JS client.
3. **[Authentication](./authentication.md)**: Dive into how authentication works with Comty.JS.
We're excited to see what you build with Comty.JS!

44
docs/comty-js/index.mdx Normal file
View File

@ -0,0 +1,44 @@
---
id: index
title: Comty.js Library
sidebar_label: Introduction
---
Welcome to the documentation for the `comty.js` library. This library provides a set of modules and classes for interacting with the Comty platform.
## Core Models
The following are the core models available in the `comty.js` library:
* [AddonsManager](models/addons): Manages addons within the library.
* [AuthModel](models/auth): Handles user authentication and session management.
* [MusicModel](models/music): Handles Music Data.
* [Post](models/post): Handles Post Data.
* [Search](models/search): Handles Search requests.
* [SessionModel](models/session): Manages user sessions and tokens.
* [UserModel](models/user): Manages User Data.
## Helpers
* [Remotes](remotes): Describes all the remotes.
* [Settings](settings): Describes all the settings.
* [Storage](storage): Describes all the storage.
* [WebsocketManager](ws): Handles websocket connections.
## Getting Started
To get started with the `comty.js` library, you can install it using npm:
```bash
npm install comty.js
```
Then, you can import the modules you need into your project:
```javascript
import { AuthModel, SessionModel } from 'comty.js';
// Use the modules
AuthModel.login({ username: 'myuser', password: 'mypassword' })
.then(data => console.log(data));
```

View File

@ -1,103 +0,0 @@
---
sidebar_position: 2
---
# Installing Comty.JS
To get started with Comty.JS, you need to add it as a dependency to your project. The library is available on npm.
## Prerequisites
* Node.js (version 12 or higher recommended, as per `jsonwebtoken` and `sucrase` dependencies)
* A package manager like npm or Yarn
## Installation
You can install Comty.JS using either npm or Yarn:
### Using npm
```bash
npm install comty.js
```
### Using Yarn
```bash
yarn add comty.js
```
This will download Comty.JS and add it to your project's `node_modules` directory. The following dependencies will also be installed:
* `@foxify/events`: ^2.1.0
* `axios`: ^1.8.4
* `js-cookie`: ^3.0.5
* `jsonwebtoken`: ^9.0.0
* `jwt-decode`: ^4.0.0
* `linebridge-client`: ^1.1.1
* `luxon`: ^3.6.0
* `socket.io-client`: ^4.8.1
For development, if you plan to contribute or build the library locally, you'll also need:
* `@ragestudio/hermes`: ^1.0.1 (used for building the project)
## Importing the library
Once installed, you can import Comty.JS into your project:
### ES Modules (JavaScript or TypeScript)
```javascript
import createClient from 'comty.js';
// or for specific models if needed (though typically client is the main entry)
// import { AuthModel, PostModel } from 'comty.js/models'; // Adjust path based on actual export structure if modular imports are supported
```
### CommonJS (Node.js)
```javascript
const createClient = require('comty.js');
// or for specific models
// const { AuthModel, PostModel } = require('comty.js/models'); // Adjust path
```
If you look at the `package.json`, the main entry point is `"./dist/index.js"`.
```json comty-project/public-repo/comty.js/package.json#L3
{
"name": "comty.js",
"version": "0.65.5",
"main": "./dist/index.js",
"description": "Official Comty API for JavaScript",
"homepage": "https://github.com/ragestudio/comty.js",
"author": "RageStudio <support@ragestudio.net>",
"scripts": {
"build": "hermes build"
},
"files": [
"dist"
],
"license": "MIT",
"dependencies": {
"@foxify/events": "^2.1.0",
"axios": "^1.8.4",
"js-cookie": "^3.0.5",
"jsonwebtoken": "^9.0.0",
"jwt-decode": "^4.0.0",
"linebridge-client": "^1.1.1",
"luxon": "^3.6.0",
"socket.io-client": "^4.8.1"
},
"devDependencies": {
"@ragestudio/hermes": "^1.0.1"
}
}
```
Now you're ready to initialize the client and start interacting with the Comty API.
## Next Steps
* **[Client Initialization](./client-initialization.md)**: Learn how to set up and configure the Comty.JS client.

View File

@ -1,7 +0,0 @@
{
"label": "Models",
"position": 4,
"link": {
"type": "generated-index"
}
}

View File

@ -0,0 +1,46 @@
---
id: addons
title: AddonsManager
sidebar_label: AddonsManager
---
## AddonsManager
The `AddonsManager` class provides a way to register, retrieve, and manage addons within the comty.js library.
**Class Overview:**
The `AddonsManager` class allows you to register addons, retrieve them by name, and find addons that implement specific operations. It uses a `Map` internally to store the registered addons.
### Properties
* `addons`: A `Map` that stores the registered addons. The keys are the addon names, and the values are the addon instances.
### Methods
* `register(name, addon)`
* Registers a new addon with the specified name.
* Parameters:
* `name`: *string* The name of the addon.
* `addon`: *object* The addon instance.
* Returns: void
* `get(name)`
* Retrieves an addon by its name.
* Parameters:
* `name`: *string* The name of the addon to retrieve.
* Returns: *object | undefined* The addon instance if found, otherwise `undefined`.
* `getByOperation(operation)`
* Searches all registered addons and returns an array of addons that have a function for the specified operation.
* Parameters:
* `operation`: *string* The name of the operation to search for.
* Returns: *Array[object]* An array of objects, where each object contains the addon's ID and the corresponding function for the specified operation. Each object has the following structure:
* `id`: *string* The ID of the addon (addon.constructor.id).
* `fn`: *function* The addon's function for the specified operation (addon[operation]).
### API Reference
* `register(name: string, addon: object)`: void - Registers a new addon.
* `get(name: string)`: object | undefined - Retrieves an addon by name.
* `getByOperation(operation: string)`: Array[object] - Gets addons by operation.

View File

@ -0,0 +1,101 @@
---
id: auth
title: AuthModel
sidebar_label: AuthModel
---
## AuthModel
The `AuthModel` class provides static methods for handling user authentication, registration, and session management.
**Class Overview:**
The `AuthModel` class provides methods for user login, logout, registration, token verification, username validation, password management, and account activation/disabling.
### Methods
* `login(payload, callback)`
* Asynchronously handles the login process.
* Parameters:
* `payload`: *object* An object containing the username, password, and MFA code if required.
* `callback`: *function, optional* A callback function to handle further actions after login.
* Returns: *Promise[object | boolean]* A Promise that resolves with the response data if login is successful. Returns `false` if MFA is required.
* `logout()`
* Asynchronously logs out the user by destroying the current session and emitting an event for successful logout.
* Returns: *Promise[void]* A Promise that resolves after the logout process is completed.
* `register(payload)`
* Registers a new user with the provided payload.
* Parameters:
* `payload`: *object* An object containing the user's information username, password, email, tos.
* Returns: *Promise[object]* A Promise that resolves with the response data if registration is successful.
* Throws: Error if the registration fails.
* `authToken(token)`
* Verifies the given token and returns the user data associated with it.
* Parameters:
* `token`: *string, optional* The token to verify. If not provided, the stored token is used.
* Returns: *Promise[object]* A Promise that resolves with the user data if the token is valid.
* Throws: Error if there was an issue with the request.
* `usernameValidation(username)`
* Validates the existence of a username.
* Parameters:
* `username`: *string* The username to validate.
* Returns: *Promise[boolean | object]* A Promise that resolves with the response data if the validation is successful, or `false` if there was an error.
* Throws: Error if the validation fails.
* `availability(payload)`
* Retrieves the availability of a username and email.
* Parameters:
* `payload`: *object* An object containing the username and email to check availability for.
* Returns: *Promise[object | boolean]* A Promise that resolves with the availability data if successful, or `false` if an error occurred.
* `changePassword(payload)`
* Changes the user's password.
* Parameters:
* `payload`: *object* An object containing the currentPassword, newPassword, and code optional.
* Returns: *Promise[object]* The data response after changing the password.
* `activateAccount(user_id, code)`
* Activates a user account using the provided activation code.
* Parameters:
* `user_id`: *string* The ID of the user to activate.
* `code`: *string* The activation code sent to the user's email.
* Returns: *Promise[object]* A Promise that resolves with the response data after activation.
* Throws: Error if the activation process fails.
* `resendActivationCode(user_id)`
* Resends the activation code to the user.
* Parameters:
* `user_id`: *string* The ID of the user to resend the activation code to.
* Returns: *Promise[object]* A Promise that resolves with the response data after sending the activation code.
* Throws: Error if the resend activation code process fails.
* `disableAccount(options)`
* Disables the user's account.
* Parameters:
* `options`: *object, optional* An object containing options for disabling the account.
* `confirm`: *boolean* Confirmation to disable the account.
* Returns: *Promise[object]* A Promise that resolves with the response data after disabling the account.
* `recoverPassword(usernameOrEmail)`
* Recovers the password for a user account.
* Parameters:
* `usernameOrEmail`: *string* The username or email associated with the account to recover.
* Returns: *Promise[object]* A Promise that resolves with the response data after initiating the password recovery process.
### API Reference
* `login(payload: object, callback: function | undefined)`: *Promise[object | boolean]* - Asynchronously handles the login process.
* `logout()`: *Promise[void]* - Asynchronously logs out the user.
* `register(payload: object)`: *Promise[object]* - Registers a new user.
* `authToken(token: string | undefined)`: *Promise[object]* - Verifies the given token.
* `usernameValidation(username: string)`: *Promise[boolean | object]* - Validates the existence of a username.
* `availability(payload: object)`: *Promise[object | boolean]* - Retrieves the availability of a username and email.
* `changePassword(payload: object)`: *Promise[object]* - Changes the user's password.
* `activateAccount(user_id: string, code: string)`: *Promise[object]* - Activates a user account.
* `resendActivationCode(user_id: string)`: *Promise[object]* - Resends the activation code.
* `disableAccount(options: object | undefined)`: *Promise[object]* - Disables the user's account.
* `recoverPassword(usernameOrEmail: string)`: *Promise[object]* - Recovers the password for a user account.

View File

@ -1,7 +0,0 @@
{
"label": "Auth",
"position": 1,
"link": {
"type": "generated-index"
}
}

View File

@ -1,5 +0,0 @@
---
sidebar_position: 5
---
# Check if username or email is available

View File

@ -1,5 +0,0 @@
---
sidebar_position: 6
---
# Update password

View File

@ -1,79 +0,0 @@
---
sidebar_position: 1
---
# Login (Credentials)
This method allows you to create a auth session with a username and password.
:::info
Use of [**server keys**](/docs/comty-js/authentication#server-keys) is recommended instead using credentials.
:::
<div class="divider"/>
### Parameters
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| [payload](#object-payload) | Object | true | | |
| [callback](#function-callback) | Function | false | | |
#### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| username | String | true | | |
| password | String | true | | |
| mfa_code | String | false | | Required if MFA is enabled for this user |
#### [Function] Callback
Executed on successful login
| Parameter | Type | Content |
| --- | --- | --- |
| data | Object | [Successful Auth](#successful-auth) |
#### [Object] Successful Auth
Contains the token and refresh token
| Parameter | Type | Content |
| --- | --- | --- |
| token | String | |
| refreshToken | String | |
| expires_in | String | |
<div class="divider"/>
### Examples
Basic usage
```js
const auth = await AuthModel.login({
username: "testuser",
password: "testpassword",
})
console.log(auth)
// returns
// {
// token: "xxxx",
// refreshToken: "xxxx",
// }
```
Using Callback
```js
AuthModel.login({
username: "testuser",
password: "testpassword",
}, (data) => {
console.log(data)
// returns
// {
// token: "xxxx",
// refreshToken: "xxxx",
// }
})
```

View File

@ -1,5 +0,0 @@
---
sidebar_position: 2
---
# Logout

View File

@ -1,5 +0,0 @@
---
sidebar_position: 3
---
# Create a new Account

View File

@ -1,5 +0,0 @@
---
sidebar_position: 4
---
# Check if exist a username

View File

@ -1 +0,0 @@
# Chats

View File

@ -0,0 +1,29 @@
---
id: chats
title: ChatsService
sidebar_label: ChatsService
---
## ChatsService
The `ChatsService` class provides static methods for interacting with chat data.
**Class Overview:**
The `ChatsService` class offers methods for retrieving chat history and recent chats for a user.
### Static Methods
* `getChatHistory(chat_id)`
Retrieves the chat history for a given chat ID.
* `chat_id`: *string* The ID of the chat.
* Returns: A Promise that resolves with the chat history data.
* Throws: Error if the chat_id is not provided.
* `getRecentChats()`
Retrieves the recent chats for the current user.
* Returns: A Promise that resolves with the chat history data.

View File

@ -0,0 +1,31 @@
---
id: e2e
title: E2EModel
sidebar_label: E2EModel
---
## E2EModel
The `E2EModel` class provides static methods for managing end-to-end encryption keys.
**Class Overview:**
The `E2EModel` class offers methods for retrieving and updating key pairs.
### Static Methods
* `getKeyPair()`
Retrieves the key pair for the current user.
* Returns: A Promise that resolves with the key pair data.
* `updateKeyPair(str, { imSure = false } = {})`
Updates the key pair for the current user.
* `str`: *string* The new key pair, encoded as a string.
* `{ imSure = false }`: *object, optional* Options for the update.
* `imSure`: *boolean, optional* Confirmation to update the keypair. Must be set to `true` to proceed.
* Returns: A Promise that resolves with the updated key pair data.
* Throws: Error if confirmation is missing.

View File

@ -0,0 +1,28 @@
---
id: events
title: EventsModel
sidebar_label: EventsModel
---
## EventsModel
The `EventsModel` class provides static methods for retrieving event data.
**Class Overview:**
The `EventsModel` class offers methods for retrieving featured events and data for a specific event.
### Static Methods
* `getFeatured()`
Retrieves featured events.
* Returns: A Promise that resolves with the featured events data.
* `data(id)`
Retrieves data for a specific event.
* `id`: *string* The ID of the event.
* Returns: A Promise that resolves with the event data.

View File

@ -1 +0,0 @@
# Feed

View File

@ -0,0 +1,51 @@
---
id: feed
title: FeedModel
sidebar_label: FeedModel
---
## FeedModel
The `FeedModel` class provides static methods for retrieving feed data.
**Class Overview:**
The `FeedModel` class offers methods for retrieving music, global music, timeline, and global timeline feeds.
### Static Methods
* `getMusicFeed({ page, limit } = {})`
Retrieves music feed.
* `{ page, limit }`: *object, optional* An object containing the page and limit.
* `page`: *number, optional* The number of items to page from the feed.
* `limit`: *number, optional* The maximum number of items to fetch from the feed.
* Returns: A Promise that resolves with the music feed data.
* `getGlobalMusicFeed({ page, limit } = {})`
Retrieves global music feed.
* `{ page, limit }`: *object, optional* An object containing the page and limit.
* `page`: *number, optional* The number of items to page from the feed.
* `limit`: *number, optional* The maximum number of items to fetch from the feed.
* Returns: A Promise that resolves with the global music feed data.
* `getTimelineFeed({ page, limit } = {})`
Retrieves timeline feed.
* `{ page, limit }`: *object, optional* An object containing the page and limit.
* `page`: *number, optional* The number of feed items to page.
* `limit`: *number, optional* The maximum number of feed items to retrieve.
* Returns: A Promise that resolves with the timeline feed data.
* `getGlobalTimelineFeed({ page, limit } = {})`
Retrieves global timeline feed.
* `{ page, limit }`: *object, optional* An object containing the page and limit.
* `page`: *number, optional* The number of items to page from the feed.
* `limit`: *number, optional* The maximum number of posts to fetch from the feed.
* Returns: A Promise that resolves with the posts feed data.

View File

@ -0,0 +1,38 @@
---
id: follows
title: FollowsModel
sidebar_label: FollowsModel
---
## FollowsModel
The `FollowsModel` class provides static methods for interacting with user follow relationships.
**Class Overview:**
The `FollowsModel` class offers methods for checking if a user is following another user, retrieving followers, and toggling the follow status.
### Static Methods
* `imFollowing(user_id)`
Checks if the current user is following the specified user.
* `user_id`: *string* The ID of the user to check if the current user is following.
* Returns: A Promise that resolves with the response data indicating if the current user is following the specified user.
* Throws: Error if the user_id parameter is not provided.
* `getFollowers(user_id, fetchData)`
Retrieves the list of followers for a given user.
* `user_id`: *string, optional* The ID of the user. If not provided, the current user ID will be used.
* `fetchData`: *boolean* Whether to fetch additional data for each follower. Defaults to false.
* Returns: A promise that resolves with the list of followers and their data.
* `toggleFollow({ user_id })`
Toggles the follow status for a user.
* `user_id`: *string* The ID of the user to toggle follow status.
* Returns: A promise that resolves with the response data after toggling follow status.

View File

@ -1,7 +0,0 @@
{
"label": "Follows",
"position": 3,
"link": {
"type": "generated-index"
}
}

View File

@ -1,62 +0,0 @@
---
sidebar_position: 1
---
# Get followers
Retrieves the list of followers for a given user.
<div class="divider"/>
<br />
```js
async function FollowsModel.getFollowers(user_id, fetchData)
```
### Arguments
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| user_id | String | false | | |
| fetchData | Boolean | true | false | If true, the response will contain an array of users data|
| limit | Number | true | 10 | Only if fetchData is true. Limit the number of followers to fetch |
| offset | Number | true | 0 | Only if fetchData is true. Offset the list of followers to fetch |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
<div class="divider"/>
## Examples
### Basic usage
```js
const followers = await FollowsModel.getFollowers("0000")
console.log(followers)
// result: {
// count: 10
// }
```
### Retrieve user data
```js
const followers = await FollowsModel.getFollowers("0000", true, 50, 0)
console.log(followers)
// result: {
// count: 10
// list: [
// {
// _id_: "0000",
// username: "comty",
// },
// {
// _id_: "0001",
// username: "john",
// },
// ...
// ]
// }
```

View File

@ -1 +0,0 @@
# Music

View File

@ -0,0 +1,159 @@
---
id: music
title: MusicModel
sidebar_label: MusicModel
---
## MusicModel
The `MusicModel` class provides static methods for interacting with music-related data. It encapsulates various getters and setters for tracks, releases, library management, and search functionalities.
**Class Overview:**
The `MusicModel` class acts as a facade, providing a simplified interface to access and manipulate music data through its nested `Getters` and `Setters` classes.
### Static Properties
* `Getters`: An object containing static getter methods for retrieving music data.
* `Setters`: An object containing static setter methods for modifying music data.
### Track Related Methods
* `getAllTracks( { user_id, limit, page } )`
* Retrieves tracks for a given user.
* Parameters:
* `user_id`: *String* The ID of the user.
* `limit`: *Number* The number of tracks to retrieve per page.
* `page`: *Number* The page number to retrieve.
* Returns: *Promise[object]*
* `getTrackData(id: String, options: Object)`
* Retrieves data for a specific track.
* Parameters:
* `id`: *String* The ID of the track.
* `options`: *Object* Additional options for the request.
* Returns: *Promise[object]*
* `putTrack(track)`
* Creates/Updates a track.
* Parameters:
* `track`: *Object* The track object to create/update.
* Returns: *Promise[object]*
### Lyrics Related Methods
* `getTrackLyrics(id: String, options = { preferTranslation: false })`
* Retrieves lyrics for a specific track.
* Parameters:
* `id`: *String* The ID of the track.
* `options`: *Object*
* `preferTranslation`: *Boolean* If true, attempts to retrieve lyrics in the user's preferred language.
* Returns: *Promise[object]*
* `putTrackLyrics(track_id, data)`
* Updates lyrics for a specific track.
* Parameters:
* `track_id`: *String* The ID of the track.
* `data`: *Object* The lyrics data to update.
* Returns: *Promise[object]*
### Release Related Methods
* `getMyReleases({ limit, offset, keywords })`
* Retrieves the user's releases.
* Parameters:
* `limit`: *Number* The number of releases to retrieve.
* `offset`: *Number* The offset to start retrieving from.
* `keywords`: *String* Keywords to search for.
* Returns: *Promise[object]*
* `getAllReleases({ user_id, limit, page })`
* Retrieves releases for a given user.
* Parameters:
* `user_id`: *String* The ID of the user.
* `limit`: *Number* The number of releases to retrieve per page.
* `page`: *Number* The page number to retrieve.
* Returns: *Promise[object]*
* `getReleaseData(id: String)`
* Retrieves data for a specific release.
* Parameters:
* `id`: *String* The ID of the release.
* Returns: *Promise[object]*
* `putRelease(release)`
* Creates/Updates a release.
* Parameters:
* `release`: *Object* The release object to create/update.
* Returns: *Promise[object]*
* `deleteRelease(release_id)`
* Deletes a release.
* Parameters:
* `release_id`: *String* The ID of the release to delete.
* Returns: *Promise[object]*
### Library Related Methods
* `getMyLibrary({ limit = 100, offset = 0, order = "desc", kind })`
* Retrieves the user's music library.
* Parameters:
* `limit`: *Number* The number of items to retrieve.
* `offset`: *Number* The offset to start retrieving from.
* `order`: *String* The order to sort the items in ("asc" or "desc").
* `kind`: *String* Filter the library by kind (e.g., "track", "release").
* Returns: *Promise[object]*
* `toggleItemFavorite(type, item_id, to)`
* Toggles the favorite status of an item in the library.
* Parameters:
* `type`: *String* The type of item ("track", "release", etc.).
* `item_id`: *String* The ID of the item.
* `to`: *Boolean* Whether to add to favorites (true) or remove (false).
* Returns: *Promise[object]*
* `isItemFavorited(type, item_id)`
* Checks if an item is favorited in the library.
* Parameters:
* `type`: *String* The type of item ("track", "release", etc.).
* `item_id`: *String* The ID of the item.
* Returns: *Promise[object]*
### Other Methods
* `getRecentyPlayed(params)`
* Retrieves recently played tracks.
* Parameters:
* `params`: *Object* Additional parameters for the request.
* Returns: *Promise[object]*
* `search({ keywords, limit, offset })`
* Searches for music items.
* Parameters:
* `keywords`: *String* The search keywords.
* `limit`: *Number* The number of results to return.
* `offset`: *Number* The offset to start the search from.
* Returns: *Promise[object]*
### Aliases
* `toggleItemFavourite`: Alias for `toggleItemFavorite`.
* `isItemFavourited`: Alias for `isItemFavorited`.
### API Reference
* `getAllTracks( { user_id: String, limit: Number, page: Number } )`: *Promise[object]*
* `getTrackData(id: String, options: Object)`: *Promise[object]*
* `putTrack(track: Object)`: *Promise[object]*
* `getTrackLyrics(id: String, options: Object)`: *Promise[object]*
* `putTrackLyrics(track_id: String, data: Object)`: *Promise[object]*
* `getMyReleases({ limit: Number, offset: Number, keywords: String })`: *Promise[object]*
* `getAllReleases({ user_id: String, limit: Number, page: Number })`: *Promise[object]*
* `getReleaseData(id: String)`: *Promise[object]*
* `putRelease(release: Object)`: *Promise[object]*
* `deleteRelease(release_id: String)`: *Promise[object]*
* `getMyLibrary({ limit: Number, offset: Number, order: String, kind: String })`: *Promise[object]*
* `toggleItemFavorite(type: String, item_id: String, to: Boolean)`: *Promise[object]*
* `isItemFavorited(type: String, item_id: String)`: *Promise[object]*
* `getRecentyPlayed(params: Object)`: *Promise[object]*
* `search({ keywords: String, limit: Number, offset: Number })`: *Promise[object]*

View File

@ -1 +0,0 @@
# NFC

View File

@ -0,0 +1,54 @@
---
id: nfc
title: NFCModel
sidebar_label: NFCModel
---
## NFCModel
The `NFCModel` class provides static methods for interacting with NFC tags.
**Class Overview:**
The `NFCModel` class offers methods for retrieving, registering, and deleting NFC tags.
### Static Methods
* `getOwnTags()`
Retrieves the list of tags owned by the current user.
* Returns: A Promise that resolves with the data of the tags.
* `getTagById(id)`
Retrieves a tag by its ID.
* `id`: *string* The ID of the tag to retrieve.
* Returns: The data of the retrieved tag.
* Throws: Error if the ID is not provided.
* `getTagBySerial(serial)`
Retrieves a tag by its serial number.
* `serial`: *string* The serial number of the tag to retrieve.
* Returns: A Promise that resolves with the data of the tag.
* Throws: Error if the serial number is not provided.
* `registerTag(serial, payload)`
Registers a tag with the given serial number and payload.
* `serial`: *string* The serial number of the tag.
* `payload`: *object* The payload data for the tag.
* Returns: The data of the registered tag.
* Throws: Error if the serial or payload is not provided.
* `deleteTag(id)`
Deletes a tag.
* `id`: *string* The ID of the tag to delete.
* Returns: A Promise that resolves with the data of the deleted tag.
* Throws: Error if the ID is not provided.

View File

@ -0,0 +1,21 @@
---
id: payments
title: PaymentsModel
sidebar_label: PaymentsModel
---
## PaymentsModel
The `PaymentsModel` class provides static methods for interacting with payment information.
**Class Overview:**
The `PaymentsModel` class offers methods for retrieving payment data.
### Static Methods
* `fetchBalance()`
Fetches the current balance.
* Returns: A promise that resolves with the balance data received from the server.

View File

@ -0,0 +1,114 @@
---
id: post
title: Post
sidebar_label: Post
---
## Post
The `Post` class provides static methods for interacting with posts and related data on the Comty platform.
### API Reference
**Class Overview:**
The `Post` class offers a comprehensive set of methods for retrieving, creating, updating, deleting, liking, saving, and voting on posts. It also provides functionalities for retrieving trending hashtags and posts.
### Static Properties
* `maxPostTextLength`: *number* The maximum length allowed for the post text (3200).
* `maxCommentLength`: *number* The maximum length allowed for a comment (1200).
### Static Methods
* `getPostingPolicy()`
* Retrieves the posting policy from the server.
* Returns: *Promise[object]* The posting policy data.
* `post(options)`
* Retrieves the data of a post by its ID.
* Parameters:
* `options`: *object* An object containing the post_id.
* `post_id`: *string* The ID of the post to retrieve.
* Returns: *Promise[object]* The data of the post.
* Throws: Error if the post_id is not provided.
* `replies(options)`
* Retrieves the replies of a post by its ID.
* Parameters:
* `options`: *object* An object containing the post_id, page, and limit.
* `post_id`: *string* The ID of the post to retrieve replies for.
* `page`: *number, optional* The number of characters to page the reply content (default: 0).
* `limit`: *number, optional* The maximum number of replies to fetch (default: Settings.get("feed_max_fetch")).
* Returns: *Promise[object]* The data of the replies.
* Throws: Error if the post_id is not provided.
* `getSavedPosts(options)`
* Retrieves the saved posts with optional trimming and limiting.
* Parameters:
* `options`: *object* An object containing the page and limit.
* `page`: *number, optional* The number of posts to page from the result (default: 0).
* `limit`: *number, optional* The maximum number of posts to fetch (default: Settings.get("feed_max_fetch")).
* Returns: *Promise[object]* The data of the liked posts.
* `getUserPosts(options)`
* Retrieves the liked posts with optional trimming and limiting.
* Parameters:
* `options`: *object* An object containing the page and limit.
* `page`: *number, optional* The number of posts to page from the result (default: 0).
* `limit`: *number, optional* The maximum number of posts to fetch (default: Settings.get("feed_max_fetch")).
* Returns: *Promise[object]* The data of the liked posts.
* `getUserPosts(options)`
* Retrieves the posts of a user with optional trimming and limiting.
* Parameters:
* `options`: *object* An object containing the user_id, page, and limit.
* `user_id`: *string, optional* The ID of the user whose posts to retrieve. If not provided, the current user's ID will be used.
* `page`: *number, optional* The number of characters to page the post content (default: 0).
* `limit`: *number, optional* The maximum number of posts to fetch (default: Settings.get("feed_max_fetch")).
* Returns: *Promise[object]* The data of the user's posts.
* `toggleLike(options)`
* Toggles the like status of a post.
* Parameters:
* `options`: *object* An object containing the post_id.
* `post_id`: *string* The ID of the post to toggle the like status.
* Returns: *Promise[object]* The response data after toggling the like status.
* Throws: Error if the post_id is not provided.
* `toggleSave(options)`
* Toggles the save status of a post.
* Parameters:
* `options`: *object* An object containing the post_id.
* `post_id`: *string* The ID of the post to toggle the save status.
* Returns: *Promise[object]* The response data after toggling the save status.
* Throws: Error if the post_id is not provided.
* `create(payload)`
* Creates a new post with the given payload.
* Parameters:
* `payload`: *object* The data to create the post with.
* Returns: *Promise[object]* The response data after creating the post.
* `update(post_id, update)`
* Updates a post with the given post ID and update payload.
* Parameters:
* `post_id`: *string* The ID of the post to update.
* `update`: *object* The data to update the post with.
* Returns: *Promise[object]* The response data after updating the post.
* Throws: Error if the post_id is not provided.
* `delete(options)`
* Deletes a post with the given post ID.
* Parameters:
* `options`: *object* An object containing the post_id.
* `post_id`: *string* The ID of the post to delete.
* Returns: *Promise[object]* The response data after deleting the post.
* Throws: Error if the post_id is not provided.
* `votePoll(options)`
* Votes for a poll with the given post ID and option ID.
* Parameters:
* `options`: *object* An object containing the post_id and option_id.
* `post_id`: *string* The ID of the post to vote for.
* `

View File

@ -1,7 +0,0 @@
{
"label": "Post",
"position": 2,
"link": {
"type": "generated-index"
}
}

View File

@ -1,91 +0,0 @@
---
sidebar_position: 8
---
# Create a post
Creates a new post with the given payload.
<div class="divider"/>
<br />
```js
async function PostModel.create(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| message | String | false | undefined | The message of the post |
| attachments | Array | true | [] | A list of attachments |
| timestamp | String | true | DateTime.local().toISO() | |
| reply_to | String | true | null | |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Object | [post-object](/docs/comty-js/definitions/post-object) |
<div class="divider"/>
## Examples
### Basic usage
```js
const post = await PostModel.create({
message: "Testing Comty.JS",
timestamp: new Date(),
})
console.log(post)
// result: {
// _id_: "0000",
// message: "Testing Comty.JS",
// timestamp: "2024-01-01T17:00:00.000Z",
// }
```
### Add attachments
```js
const post = await PostModel.create({
message: "Look at this fox",
attachments: [
{
url: "https://upload.wikimedia.org/wikipedia/commons/3/30/Vulpes_vulpes_ssp_fulvus.jpg",
}
],
})
console.log(post)
// result: {
// _id_: "0001",
// message: "Look at this fox",
// timestamp: "2024-01-01T17:00:00.000Z",
// attachments: [
// {
// url: "https://upload.wikimedia.org/wikipedia/commons/3/30/Vulpes_vulpes_ssp_fulvus.jpg",
// }
// ]
// }
```
### Reply to a post
```js
const post = await PostModel.create({
reply_to: "0001",
message: "* pet pet *",
})
console.log(post)
// result: {
// _id_: "0002",
// reply_to: "0001",
// message: "* pat pat*",
// timestamp: "2024-01-01T17:30:00.000Z",
// }
```

View File

@ -1,45 +0,0 @@
---
sidebar_position: 10
---
# Delete a post
Delete a post with the given post ID.
Only can delete your own posts.
<div class="divider"/>
<br />
```js
async function PostModel.delete(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| post_id | String | false | undefined | |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| post_id | String | |
| deleted | Boolean | |
<div class="divider"/>
## Examples
### Basic usage
```js
const post = await PostModel.delete({
post_id: "0000",
})
console.log(post)
// result: {
// post_id: "0000",
// deleted: true,
// }
```

View File

@ -1,45 +0,0 @@
---
sidebar_position: 2
---
# Get my liked posts
Retrieves the liked posts of current authed user.
<div class="divider"/>
<br />
```js
async function PostModel.getLikedPosts(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| trim | number | true | 0 | Trim the post index content |
| limit | number | true | 10 | Limit the number of posts to fetch |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] |
<div class="divider"/>
## Examples
### Basic usage
```js
const posts = await PostModel.getLikedPosts({
trim: 0,
limit: 10,
})
console.log(posts)
// result: [
// { _id: "0000", user_id: "0000", message: "example text", ... },
// { _id: "0001", user_id: "0000", message: "example text", ... },
// ...
// ]
```

View File

@ -1,44 +0,0 @@
---
sidebar_position: 4
---
# Get post data
Retrieves the data of a post.
<div class="divider"/>
<br />
```js
async function PostModel.post(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| post_id | string | false | | Defines the ID of the post to retrieve.|
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | object | [post_obj](/docs/comty-js/definitions/post-object) |
<div class="divider"/>
## Examples
### Basic usage
```js
const post = await PostModel.post({
post_id: "0000",
})
console.log(post)
// result: {
// _id: "0000",
// user_id: "0000",
// message: "example text",
// ...
// }
```

View File

@ -1,47 +0,0 @@
---
sidebar_position: 5
---
# Get post replies
Retrieves replies of a post.
<div class="divider"/>
<br />
```js
async function PostModel.replies(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| post_id | string | false | | |
| trim | number | true | 0 | Trim the post index content |
| limit | number | true | 10 | Limit the number of posts to fetch |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] |
<div class="divider"/>
## Examples
### Basic usage
```js
const posts = await PostModel.replies({
post_id: "0000",
trim: 0,
limit: 10,
})
console.log(posts)
// result: [
// { _id: "0000", user_id: "0000", message: "example text", ... },
// { _id: "0001", user_id: "0000", message: "example text", ... },
// ...
// ]
```

View File

@ -1,45 +0,0 @@
---
sidebar_position: 3
---
# Get my saved posts
Retrieves the saved posts of current authed user.
<div class="divider"/>
<br />
```js
async function PostModel.getSavedPosts(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| trim | number | true | 0 | Trim the post index content |
| limit | number | true | 10 | Limit the number of posts to fetch |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] |
<div class="divider"/>
## Examples
### Basic usage
```js
const posts = await PostModel.getSavedPosts({
trim: 0,
limit: 10,
})
console.log(posts)
// result: [
// { _id: "0000", user_id: "0000", message: "example text", ... },
// { _id: "0001", user_id: "0000", message: "example text", ... },
// ...
// ]
```

View File

@ -1,47 +0,0 @@
---
sidebar_position: 1
---
# Get user posts
Retrieves the public posts of a user.
<div class="divider"/>
<br />
```js
async function PostModel.getUserPosts(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| user_id | string | false | | |
| trim | number | true | 0 | Trim the post index content |
| limit | number | true | 10 | Limit the number of posts to fetch |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] |
<div class="divider"/>
## Examples
### Basic usage
```js
const posts = await PostModel.getUserPosts({
user_id: "0000",
trim: 0,
limit: 10,
})
console.log(posts)
// result: [
// { _id: "0000", user_id: "0000", message: "example text", ... },
// { _id: "0001", user_id: "0000", message: "example text", ... },
// ...
// ]
```

View File

@ -1,60 +0,0 @@
---
sidebar_position: 6
---
# Toggle post like
Toggles the like status of a post.
<div class="divider"/>
<br />
```js
async function PostModel.toggleLike(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| post_id | string | false | | |
| to | Boolean | true | | Set like to true or false |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Object | [like-status-object](/docs/comty-js/definitions/like-status-object) |
<div class="divider"/>
## Examples
### Basic usage
```js
const like = await PostModel.toggleLike({
post_id: "0000",
})
console.log(like)
// result: {
// post_id: "0000",
// liked: true,
// count: 1,
// }
```
### Specify status
```js
const like = await PostModel.toggleLike({
post_id: "0000",
to: false
})
console.log(like)
// result: {
// post_id: "0000",
// liked: false,
// count: 0,
// }
```

View File

@ -1,60 +0,0 @@
---
sidebar_position: 7
---
# Toggle post save
Toggles the save status of a post.
<div class="divider"/>
<br />
```js
async function PostModel.toggleSave(payload)
```
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| post_id | string | false | | |
| to | Boolean | true | | Set save to true or false |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Object | [save-status-object](/docs/comty-js/definitions/save-status-object) |
<div class="divider"/>
## Examples
### Basic usage
```js
const save = await PostModel.toggleSave({
post_id: "0000",
})
console.log(save)
// result: {
// post_id: "0000",
// saved: true,
// count: 1,
// }
```
### Specify status
```js
const save = await PostModel.toggleSave({
post_id: "0000",
to: false
})
console.log(save)
// result: {
// post_id: "0000",
// saved: false,
// count: 0,
// }
```

View File

@ -1,76 +0,0 @@
---
sidebar_position: 9
---
# Update a post
Updates a post with the given post ID and update payload.
Only can update your own posts.
<div class="divider"/>
<br />
```js
async function PostModel.update(post_id, payload)
```
### [String] post_id
Defines the ID of the post to update.
### [Object] Payload
| Parameter | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| message | String | false | undefined | The message of the post |
| attachments | Array | true | [] | A list of attachments |
<div class="divider"/>
### Success Response
| Parameter | Type | Content |
| --- | --- | --- |
| data | Object | [post-object](/docs/comty-js/definitions/post-object) |
<div class="divider"/>
## Examples
### Basic usage
```js
const post = await PostModel.update({
post_id: "0000",
message: "Updated message",
})
console.log(post)
// result: {
// _id_: "0000",
// message: "Updated message",
// timestamp: "2024-01-01T17:00:00.000Z",
// }
```
### Modify or remove attachments
```js
const post = await PostModel.update({
post_id: "0000",
attachments: [
{
url: "https://upload.wikimedia.org/wikipedia/commons/3/30/Vulpes_vulpes_ssp_fulvus.jpg",
}
],
})
console.log(post)
// result: {
// _id_: "0000",
// message: "Updated message",
// timestamp: "2024-01-01T17:00:00.000Z",
// attachments: [
// {
// url: "https://upload.wikimedia.org/wikipedia/commons/3/30/Vulpes_vulpes_ssp_fulvus.jpg",
// }
// ]
// }
```

View File

@ -0,0 +1,30 @@
---
id: radio
title: Radio
sidebar_label: Radio
---
## Radio
The `Radio` class provides static methods for retrieving radio data.
**Class Overview:**
The `Radio` class offers methods for retrieving radio lists and trending radio stations.
### Static Methods
* `getRadioList({ limit = 50, offset = 0 } = {})`
Retrieves a list of radio stations.
* `{ limit, offset }`: *object, optional* An object containing the limit and offset for pagination.
* `limit`: *number, optional* The maximum number of radio stations to retrieve (default: 50).
* `offset`: *number, optional* The offset to start retrieving from (default: 0).
* Returns: A promise that resolves with the radio list data.
* `getTrendings()`
Retrieves trending radio stations.
* Returns: A promise that resolves with the trending radio stations data.

View File

@ -1 +0,0 @@
# Search

View File

@ -0,0 +1,32 @@
---
id: search
title: Search
sidebar_label: Search
---
## Search
The `Search` class provides a static method for performing searches using the Comty API.
**Class Overview:**
The `Search` class encapsulates the search functionality, allowing you to search for content using keywords and optional parameters. It also supports external addons to extend the search functionality.
### Static Methods
* `search(keywords, params, returnFields)`
Performs a search using the provided keywords and optional parameters.
* `keywords`: *string* The keywords to search for.
* `params`: *object, optional* Optional parameters for the search.
* `limit`: *number, optional* The maximum number of results to return default: 50.
* `offset`: *number, optional* The offset to start the search from default: 0.
* `sort`: *string, optional* The sort order "asc" or "desc" default: "desc".
* `fields`: *array, optional* An array of fields to return in the results. If empty, all fields will be returned.
* `returnFields`: *array, optional* An array of fields to return in the results. If empty, all fields will be returned.
* Returns: A promise that resolves with the search results.
### API Reference
* `search(keywords: string, params: object, returnFields: array)`: Promise[object] - Performs a search using the provided keywords and optional parameters.

View File

@ -1 +0,0 @@
# Session

View File

@ -0,0 +1,97 @@
---
id: spectrum
title: Streaming
sidebar_label: Streaming
---
## Streaming
The `Streaming` class provides static methods for interacting with streaming data on the Comty platform.
**Class Overview:**
The `Streaming` class offers methods for managing streaming profiles, streams, and websocket connections.
### Static Methods
* `getStream(stream_id)`
Retrieves data for a specific stream.
* `stream_id`: *string* The ID of the stream.
* Returns: A promise that resolves with the stream data.
* `getOwnProfiles()`
Retrieves the streaming profiles owned by the current user.
* Returns: A promise that resolves with the profiles data.
* `getProfile(profile_id)`
Retrieves data for a specific streaming profile.
* `profile_id`: *string* The ID of the profile.
* Returns: A promise that resolves with the profile data.
* `createProfile(payload)`
Creates a new streaming profile.
* `payload`: *object* The data for the new profile.
* Returns: A promise that resolves with the created profile data.
* `updateProfile(profile_id, update)`
Updates a streaming profile.
* `profile_id`: *string* The ID of the profile to update.
* `update`: *object* The data to update the profile with.
* Returns: A promise that resolves with the updated profile data.
* `deleteProfile(profile_id)`
Deletes a streaming profile.
* `profile_id`: *string* The ID of the profile to delete.
* Returns: A promise that resolves with the response data after deleting the profile.
* `addRestreamToProfile(profileId, restreamData)`
Adds a restream to a profile.
* `profileId`: *string* The ID of the profile to add the restream to.
* `restreamData`: *object* The data for the restream.
* Returns: A promise that resolves with the response data.
* `deleteRestreamFromProfile(profileId, restreamIndexData)`
Deletes a restream from a profile.
* `profileId`: *string* The ID of the profile to delete the restream from.
* `restreamIndexData`: *object* The index data for the restream to delete.
* Returns: A promise that resolves with the response data.
* `list({ limit, offset } = {})`
Lists streaming entries.
* `{ limit, offset }`: *object, optional* An object containing pagination parameters.
* `limit`: *number, optional* The maximum number of items to retrieve.
* `offset`: *number, optional* The offset to start retrieving from.
* Returns: A promise that resolves with the streaming entries data.
* `createWebsocket(params = {})`
Creates a websocket connection.
* `params`: *object, optional* Additional parameters for the websocket connection.
* Returns: A `RTEngineClient` websocket client.
* `createStreamWebsocket(stream_id, params = {})`
Creates a stream-specific websocket connection.
* `stream_id`: *string* The ID of the stream.
* `params`: *object, optional* Additional parameters for the websocket connection.
* Returns: A `RTEngineClient` websocket client.

View File

@ -0,0 +1,63 @@
---
id: spotify
title: SpotifySyncModel
sidebar_label: SpotifySyncModel
---
## SpotifySyncModel
The `SpotifySyncModel` class provides static methods for linking and interacting with the Spotify service.
**Class Overview:**
The `SpotifySyncModel` class offers methods for authorizing, linking, unlinking, and retrieving data from the Spotify service.
### Static Properties
* `spotify_redirect_uri`: *string* The redirect URI for Spotify authorization.
* `spotify_authorize_endpoint`: *string* The Spotify authorization endpoint.
### Static Methods
* `authorizeAccount()`
Opens a new tab to authorize the user's Spotify account.
* Returns: void
* `get_client_id()`
Retrieves the Spotify client ID.
* Returns: A Promise that resolves with the client ID data.
* `syncAuthCode(code)`
Syncs the Spotify authorization code.
* `code`: *string* The Spotify authorization code.
* Returns: A Promise that resolves with the sync data.
* `unlinkAccount()`
Unlinks the user's Spotify account.
* Returns: A Promise that resolves with the unlink data.
* `isAuthorized()`
Checks if the user is authorized with Spotify.
* Returns: A Promise that resolves with a boolean indicating whether the user is authorized.
* `getData()`
Retrieves Spotify data.
* Returns: A Promise that resolves with the Spotify data.
* `getCurrentPlaying()`
Retrieves the currently playing track from Spotify.
* Returns: A Promise that resolves with the currently playing track data.

View File

@ -0,0 +1,108 @@
---
id: tidal
title: TidalService
sidebar_label: TidalService
---
## TidalService
The `TidalService` class provides static methods for linking and interacting with the Tidal service.
**Class Overview:**
The `TidalService` class offers methods for linking and unlinking accounts, checking the connection status, and retrieving data from the Tidal service.
### Static Properties
* `api_instance`: Returns the API instance for the Tidal service.
### Static Methods
* `linkAccount()`
Opens a new tab to link the user's Tidal account.
* Returns: A Promise that resolves with the link data.
* Throws: Error if not running in a browser environment
* `unlinkAccount()`
Unlinks the user's Tidal account.
* Returns: A Promise that resolves with the unlink data.
* Throws: Error if not running in a browser environment
* `isActive()`
Checks if the user's Tidal account is linked.
* Returns: A Promise that resolves with a boolean indicating whether the account is linked.
* Throws: Error if not running in a browser environment
* `getCurrentUser()`
Retrieves the current Tidal user.
* Returns: A Promise that resolves with the current user data.
* `getPlaybackUrl(track_id)`
Retrieves the playback URL for a given Tidal track ID.
* `track_id`: *string* The ID of the Tidal track.
* Returns: A Promise that resolves with the playback URL data.
* `getTrackManifest(track_id)`
Retrieves the track manifest for a given Tidal track ID.
* `track_id`: *string* The ID of the Tidal track.
* Returns: A Promise that resolves with the track manifest data.
* `getMyFavoriteTracks({ limit = 50, offset = 0 } = {})`
Retrieves the user's favorite Tidal tracks.
* `{ limit, offset }`: *object, optional* An object containing pagination parameters.
* `limit`: *number* The maximum number of tracks to retrieve.
* `offset`: *number* The offset to start retrieving from.
* Returns: A Promise that resolves with the favorite tracks data.
* `getMyFavoritePlaylists({ limit = 50, offset = 0 } = {})`
Retrieves the user's favorite Tidal playlists.
* `{ limit, offset }`: *object, optional* An object containing pagination parameters.
* `limit`: *number* The maximum number of playlists to retrieve.
* `offset`: *number* The offset to start retrieving from.
* Returns: A Promise that resolves with the favorite playlists data.
* `getPlaylistData({ playlist_id, resolve_items = false, limit = 50, offset = 0 })`
Retrieves Tidal playlist data.
* `playlist_id`: *string* The ID of the Tidal playlist.
* `{ resolve_items, limit, offset }`: *object, optional* An object containing playlist options.
* `resolve_items`: *boolean* Whether to resolve playlist items.
* `limit`: *number* The maximum number of items to retrieve.
* `offset`: *number* The offset to start retrieving from.
* Returns: A Promise that resolves with the playlist data.
* `getPlaylistItems({ playlist_id, resolve_items = false, limit = 50, offset = 0 })`
Retrieves Tidal playlist items.
* `playlist_id`: *string* The ID of the Tidal playlist.
* `{ resolve_items, limit, offset }`: *object, optional* An object containing playlist options.
* `resolve_items`: *boolean* Whether to resolve playlist items.
* `limit`: *number* The maximum number of items to retrieve.
* `offset`: *number* The offset to start retrieving from.
* Returns: A Promise that resolves with the playlist items data.
* `toggleTrackLike({ track_id, to })`
Toggles a Tidal track like.
* `track_id`: *string* The ID of the Tidal track.
* `to`: *boolean* Whether to like or unlike the track.
* Returns: A Promise that resolves with the response data.

View File

@ -1 +0,0 @@
# User

View File

@ -0,0 +1,80 @@
---
id: user
title: UserModel
sidebar_label: UserModel
---
## UserModel
The `UserModel` class provides static methods for interacting with user data on the Comty platform.
**Class Overview:**
The `UserModel` class offers a set of methods for retrieving and updating user data, including profile information, roles, badges, and configuration settings.
### Static Methods
* `data(payload)`
Retrieves the data of a user.
* `payload`: *object, optional* An object containing the username and user_id.
* `username`: *string, optional* The username of the user.
* `user_id`: *string, optional* The ID of the user.
* `basic`: *boolean, optional* Whether to fetch only basic user information default: false.
* Returns: A promise that resolves with the data of the user.
* `updateData(payload)`
Updates the user data with the given payload.
* `payload`: *object* The data to update the user with.
* Returns: A promise that resolves with the updated user data.
* `unsetPublicName()`
Update the public name to null in the user data.
* Returns: A Promise that resolves with the response data after updating the public name
* `getRoles(user_id)`
Retrieves the roles of a user.
* `user_id`: *string, optional* The ID of the user. If not provided, the current user ID will be used.
* Returns: A promise that resolves with an array of roles for the user.
* `getBadges(user_id)`
Retrieves the badges for a given user.
* `user_id`: *string, optional* The ID of the user. If not provided, the current session user ID will be used.
* Returns: A promise that resolves with an array of badges for the user.
* `getConfig(key)`
Retrive user config from server
* `key`: *string* A key of config
* Returns: A Promise that resolves with a config object
* `updateConfig(update)`
Update the configuration with the given update.
* `update`: *Object* The object containing the updated configuration data
* Returns: A Promise that resolves with the response data after the configuration is updated
* `getPublicKey(user_id)`
Retrieves the public key for a given user.
* `user_id`: *string, optional* The ID of the user. If not provided, the current session user ID will be used.
* Returns: A promise that resolves with the public key for the user.
* `updatePublicKey(public_key)`
Updates the public key for the current user.
* `public_key`: *string* The new public key to set.
* Returns: A promise that resolves with the response data after updating the public key.

View File

@ -37,17 +37,34 @@ const config = {
presets: [ presets: [
[ [
"classic", "classic",
/** @type {import("@docusaurus/preset-classic").Options} */ {
({
docs: { docs: {
path: "../docs", path: "../docs",
sidebarPath: "./sidebars.js", sidebarPath: "./sidebars.js",
//editUrl: "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
}, },
theme: { theme: {
customCss: "./src/css/custom.css", customCss: "./src/css/custom.css",
}, },
}), },
],
],
plugins: [
[
"docusaurus-plugin-openapi-docs",
{
id: "api", // plugin id
docsPluginId: "classic", // configured for preset-classic
config: {
petstore: {
specPath: "examples/petstore.yaml",
outputDir: "docs/petstore",
sidebarOptions: {
groupPathsBy: "tag",
},
},
},
},
], ],
], ],

View File

@ -18,6 +18,7 @@
"@docusaurus/preset-classic": "3.5.2", "@docusaurus/preset-classic": "3.5.2",
"@mdx-js/react": "^3.0.0", "@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"docusaurus-plugin-openapi-docs": "^4.4.0",
"prism-react-renderer": "^2.3.0", "prism-react-renderer": "^2.3.0",
"react": "^18.0.0", "react": "^18.0.0",
"react-dom": "^18.0.0" "react-dom": "^18.0.0"