diff --git a/docs/comty-js/authentication.md b/docs/comty-js/authentication.md deleted file mode 100644 index 51167dfb..00000000 --- a/docs/comty-js/authentication.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -sidebar_position: 3 ---- - -# Authenticating - -## Server Keys - -## User Token \ No newline at end of file diff --git a/docs/comty-js/definitions/_category_.json b/docs/comty-js/definitions/_category_.json deleted file mode 100644 index 33898a33..00000000 --- a/docs/comty-js/definitions/_category_.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "label": "Definitions", - "position": 6, - "link": { - "type": "generated-index" - } -} diff --git a/docs/comty-js/definitions/like-status-object.md b/docs/comty-js/definitions/like-status-object.md deleted file mode 100644 index d6b6fa1f..00000000 --- a/docs/comty-js/definitions/like-status-object.md +++ /dev/null @@ -1,6 +0,0 @@ -# Like Status Object -| Parameter | Type | Content | -| --- | --- | --- | -| post_id | string | | -| liked | Boolean | | -| count | Number | Current like count | \ No newline at end of file diff --git a/docs/comty-js/definitions/post-object.md b/docs/comty-js/definitions/post-object.md deleted file mode 100644 index 2fa92991..00000000 --- a/docs/comty-js/definitions/post-object.md +++ /dev/null @@ -1,8 +0,0 @@ -# Post Object -| Parameter | Type | Content | -| --- | --- | --- | -| _id | string | | -| user_id | string | | -| message | string | | -| created_at | string | | -| updated_at | string | | diff --git a/docs/comty-js/definitions/save-status-object.md b/docs/comty-js/definitions/save-status-object.md deleted file mode 100644 index 41c0376a..00000000 --- a/docs/comty-js/definitions/save-status-object.md +++ /dev/null @@ -1,6 +0,0 @@ -# Save Status Object -| Parameter | Type | Content | -| --- | --- | --- | -| post_id | string | | -| saved | Boolean | | -| count | Number | Current global save count | \ No newline at end of file diff --git a/docs/comty-js/getting-started.md b/docs/comty-js/getting-started.md deleted file mode 100644 index 0d156ab7..00000000 --- a/docs/comty-js/getting-started.md +++ /dev/null @@ -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! diff --git a/docs/comty-js/index.mdx b/docs/comty-js/index.mdx new file mode 100644 index 00000000..bfb775ab --- /dev/null +++ b/docs/comty-js/index.mdx @@ -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)); +``` diff --git a/docs/comty-js/installing.md b/docs/comty-js/installing.md deleted file mode 100644 index 421008ad..00000000 --- a/docs/comty-js/installing.md +++ /dev/null @@ -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 ", - "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. \ No newline at end of file diff --git a/docs/comty-js/models/_category_.json b/docs/comty-js/models/_category_.json deleted file mode 100644 index bb3e21f0..00000000 --- a/docs/comty-js/models/_category_.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "label": "Models", - "position": 4, - "link": { - "type": "generated-index" - } -} diff --git a/docs/comty-js/models/addons.mdx b/docs/comty-js/models/addons.mdx new file mode 100644 index 00000000..2955f71f --- /dev/null +++ b/docs/comty-js/models/addons.mdx @@ -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. diff --git a/docs/comty-js/models/auth.mdx b/docs/comty-js/models/auth.mdx new file mode 100644 index 00000000..787922be --- /dev/null +++ b/docs/comty-js/models/auth.mdx @@ -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. diff --git a/docs/comty-js/models/auth/_category_.json b/docs/comty-js/models/auth/_category_.json deleted file mode 100644 index b50e4c7a..00000000 --- a/docs/comty-js/models/auth/_category_.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "label": "Auth", - "position": 1, - "link": { - "type": "generated-index" - } -} diff --git a/docs/comty-js/models/auth/availability.md b/docs/comty-js/models/auth/availability.md deleted file mode 100644 index 4059a6d8..00000000 --- a/docs/comty-js/models/auth/availability.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar_position: 5 ---- - -# Check if username or email is available \ No newline at end of file diff --git a/docs/comty-js/models/auth/change-password.md b/docs/comty-js/models/auth/change-password.md deleted file mode 100644 index 4b8ab475..00000000 --- a/docs/comty-js/models/auth/change-password.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar_position: 6 ---- - -# Update password \ No newline at end of file diff --git a/docs/comty-js/models/auth/login.md b/docs/comty-js/models/auth/login.md deleted file mode 100644 index efb4b1cd..00000000 --- a/docs/comty-js/models/auth/login.md +++ /dev/null @@ -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. -::: - -
- -### 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 | | - - -
- -### 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", - // } -}) -``` \ No newline at end of file diff --git a/docs/comty-js/models/auth/logout.md b/docs/comty-js/models/auth/logout.md deleted file mode 100644 index 01f405a4..00000000 --- a/docs/comty-js/models/auth/logout.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar_position: 2 ---- - -# Logout \ No newline at end of file diff --git a/docs/comty-js/models/auth/register.md b/docs/comty-js/models/auth/register.md deleted file mode 100644 index b07263fb..00000000 --- a/docs/comty-js/models/auth/register.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar_position: 3 ---- - -# Create a new Account \ No newline at end of file diff --git a/docs/comty-js/models/auth/user-validation.md b/docs/comty-js/models/auth/user-validation.md deleted file mode 100644 index fe9296b8..00000000 --- a/docs/comty-js/models/auth/user-validation.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar_position: 4 ---- - -# Check if exist a username \ No newline at end of file diff --git a/docs/comty-js/models/chats.md b/docs/comty-js/models/chats.md deleted file mode 100644 index f1a63201..00000000 --- a/docs/comty-js/models/chats.md +++ /dev/null @@ -1 +0,0 @@ -# Chats \ No newline at end of file diff --git a/docs/comty-js/models/chats.mdx b/docs/comty-js/models/chats.mdx new file mode 100644 index 00000000..8c025fe7 --- /dev/null +++ b/docs/comty-js/models/chats.mdx @@ -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. diff --git a/docs/comty-js/models/e2e.mdx b/docs/comty-js/models/e2e.mdx new file mode 100644 index 00000000..1a59b4b2 --- /dev/null +++ b/docs/comty-js/models/e2e.mdx @@ -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. diff --git a/docs/comty-js/models/events.mdx b/docs/comty-js/models/events.mdx new file mode 100644 index 00000000..aecf04cd --- /dev/null +++ b/docs/comty-js/models/events.mdx @@ -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. diff --git a/docs/comty-js/models/feed.md b/docs/comty-js/models/feed.md deleted file mode 100644 index c53658a2..00000000 --- a/docs/comty-js/models/feed.md +++ /dev/null @@ -1 +0,0 @@ -# Feed \ No newline at end of file diff --git a/docs/comty-js/models/feed.mdx b/docs/comty-js/models/feed.mdx new file mode 100644 index 00000000..6b4dd032 --- /dev/null +++ b/docs/comty-js/models/feed.mdx @@ -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. diff --git a/docs/comty-js/models/follows.mdx b/docs/comty-js/models/follows.mdx new file mode 100644 index 00000000..7d9c9ad5 --- /dev/null +++ b/docs/comty-js/models/follows.mdx @@ -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. diff --git a/docs/comty-js/models/follows/_category_.json b/docs/comty-js/models/follows/_category_.json deleted file mode 100644 index 8e5b2759..00000000 --- a/docs/comty-js/models/follows/_category_.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "label": "Follows", - "position": 3, - "link": { - "type": "generated-index" - } -} diff --git a/docs/comty-js/models/follows/im-following.md b/docs/comty-js/models/follows/im-following.md deleted file mode 100644 index 23f95cd2..00000000 --- a/docs/comty-js/models/follows/im-following.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Get followers -Retrieves the list of followers for a given user. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | - -
- -## 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", -// }, -// ... -// ] -// } -``` \ No newline at end of file diff --git a/docs/comty-js/models/music.md b/docs/comty-js/models/music.md deleted file mode 100644 index 3689238e..00000000 --- a/docs/comty-js/models/music.md +++ /dev/null @@ -1 +0,0 @@ -# Music \ No newline at end of file diff --git a/docs/comty-js/models/music.mdx b/docs/comty-js/models/music.mdx new file mode 100644 index 00000000..3267087e --- /dev/null +++ b/docs/comty-js/models/music.mdx @@ -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]* diff --git a/docs/comty-js/models/nfc.md b/docs/comty-js/models/nfc.md deleted file mode 100644 index 5db8200c..00000000 --- a/docs/comty-js/models/nfc.md +++ /dev/null @@ -1 +0,0 @@ -# NFC \ No newline at end of file diff --git a/docs/comty-js/models/nfc.mdx b/docs/comty-js/models/nfc.mdx new file mode 100644 index 00000000..3f5d78e9 --- /dev/null +++ b/docs/comty-js/models/nfc.mdx @@ -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. diff --git a/docs/comty-js/models/payments.mdx b/docs/comty-js/models/payments.mdx new file mode 100644 index 00000000..b5ed4173 --- /dev/null +++ b/docs/comty-js/models/payments.mdx @@ -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. diff --git a/docs/comty-js/models/post.mdx b/docs/comty-js/models/post.mdx new file mode 100644 index 00000000..95b4fd87 --- /dev/null +++ b/docs/comty-js/models/post.mdx @@ -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. + * ` diff --git a/docs/comty-js/models/post/_category_.json b/docs/comty-js/models/post/_category_.json deleted file mode 100644 index a0ebfd79..00000000 --- a/docs/comty-js/models/post/_category_.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "label": "Post", - "position": 2, - "link": { - "type": "generated-index" - } -} diff --git a/docs/comty-js/models/post/create-post.md b/docs/comty-js/models/post/create-post.md deleted file mode 100644 index 924616ec..00000000 --- a/docs/comty-js/models/post/create-post.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -sidebar_position: 8 ---- - -# Create a post -Creates a new post with the given payload. - -
-
-```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 | | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Object | [post-object](/docs/comty-js/definitions/post-object) | - -
- -## 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", -// } - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/delete-post.md b/docs/comty-js/models/post/delete-post.md deleted file mode 100644 index 830cee63..00000000 --- a/docs/comty-js/models/post/delete-post.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -sidebar_position: 10 ---- - -# Delete a post -Delete a post with the given post ID. - -Only can delete your own posts. - -
-
-```js -async function PostModel.delete(payload) -``` - -### [Object] Payload -| Parameter | Type | Optional | Default | Description | -| --- | --- | --- | --- | --- | -| post_id | String | false | undefined | | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| post_id | String | | -| deleted | Boolean | | - -
- -## Examples -### Basic usage -```js -const post = await PostModel.delete({ - post_id: "0000", -}) - -console.log(post) - -// result: { -// post_id: "0000", -// deleted: true, -// } - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/get-my-liked-posts.md b/docs/comty-js/models/post/get-my-liked-posts.md deleted file mode 100644 index e2746902..00000000 --- a/docs/comty-js/models/post/get-my-liked-posts.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -sidebar_position: 2 ---- - -# Get my liked posts -Retrieves the liked posts of current authed user. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] | - -
- -## 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", ... }, -// ... -// ] - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/get-post-data.md b/docs/comty-js/models/post/get-post-data.md deleted file mode 100644 index 3d3e35e1..00000000 --- a/docs/comty-js/models/post/get-post-data.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -sidebar_position: 4 ---- - -# Get post data -Retrieves the data of a post. - -
-
-```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.| - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | object | [post_obj](/docs/comty-js/definitions/post-object) | - -
- -## Examples -### Basic usage -```js -const post = await PostModel.post({ - post_id: "0000", -}) - -console.log(post) - -// result: { -// _id: "0000", -// user_id: "0000", -// message: "example text", -// ... -// } - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/get-post-replies.md b/docs/comty-js/models/post/get-post-replies.md deleted file mode 100644 index 342b728b..00000000 --- a/docs/comty-js/models/post/get-post-replies.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -sidebar_position: 5 ---- - -# Get post replies -Retrieves replies of a post. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] | - -
- -## 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", ... }, -// ... -// ] - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/get-saved-posts.md b/docs/comty-js/models/post/get-saved-posts.md deleted file mode 100644 index b8d4265a..00000000 --- a/docs/comty-js/models/post/get-saved-posts.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -sidebar_position: 3 ---- - -# Get my saved posts -Retrieves the saved posts of current authed user. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] | - -
- -## 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", ... }, -// ... -// ] - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/get-user-posts.md b/docs/comty-js/models/post/get-user-posts.md deleted file mode 100644 index c244bb3b..00000000 --- a/docs/comty-js/models/post/get-user-posts.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Get user posts -Retrieves the public posts of a user. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Array | [[post_obj](/docs/comty-js/definitions/post-object), ...] | - -
- -## 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", ... }, -// ... -// ] - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/toggle-like.md b/docs/comty-js/models/post/toggle-like.md deleted file mode 100644 index db9567c5..00000000 --- a/docs/comty-js/models/post/toggle-like.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -sidebar_position: 6 ---- - -# Toggle post like -Toggles the like status of a post. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Object | [like-status-object](/docs/comty-js/definitions/like-status-object) | - -
- -## 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, -// } - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/toggle-save.md b/docs/comty-js/models/post/toggle-save.md deleted file mode 100644 index b9a8d1ce..00000000 --- a/docs/comty-js/models/post/toggle-save.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -sidebar_position: 7 ---- - -# Toggle post save -Toggles the save status of a post. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Object | [save-status-object](/docs/comty-js/definitions/save-status-object) | - -
- -## 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, -// } - -``` \ No newline at end of file diff --git a/docs/comty-js/models/post/update-post.md b/docs/comty-js/models/post/update-post.md deleted file mode 100644 index e674de36..00000000 --- a/docs/comty-js/models/post/update-post.md +++ /dev/null @@ -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. - -
-
-```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 | - -
- -### Success Response -| Parameter | Type | Content | -| --- | --- | --- | -| data | Object | [post-object](/docs/comty-js/definitions/post-object) | - -
- -## 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", -// } -// ] -// } - -``` \ No newline at end of file diff --git a/docs/comty-js/models/radio.mdx b/docs/comty-js/models/radio.mdx new file mode 100644 index 00000000..8d9e8994 --- /dev/null +++ b/docs/comty-js/models/radio.mdx @@ -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. diff --git a/docs/comty-js/models/search.md b/docs/comty-js/models/search.md deleted file mode 100644 index 6aaea9fe..00000000 --- a/docs/comty-js/models/search.md +++ /dev/null @@ -1 +0,0 @@ -# Search \ No newline at end of file diff --git a/docs/comty-js/models/search.mdx b/docs/comty-js/models/search.mdx new file mode 100644 index 00000000..7fb6c34b --- /dev/null +++ b/docs/comty-js/models/search.mdx @@ -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. diff --git a/docs/comty-js/models/session.md b/docs/comty-js/models/session.md deleted file mode 100644 index 1abcb971..00000000 --- a/docs/comty-js/models/session.md +++ /dev/null @@ -1 +0,0 @@ -# Session \ No newline at end of file diff --git a/docs/comty-js/models/spectrum.mdx b/docs/comty-js/models/spectrum.mdx new file mode 100644 index 00000000..564fd39b --- /dev/null +++ b/docs/comty-js/models/spectrum.mdx @@ -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. diff --git a/docs/comty-js/models/spotify.mdx b/docs/comty-js/models/spotify.mdx new file mode 100644 index 00000000..6f623412 --- /dev/null +++ b/docs/comty-js/models/spotify.mdx @@ -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. diff --git a/docs/comty-js/models/tidal.mdx b/docs/comty-js/models/tidal.mdx new file mode 100644 index 00000000..56fad294 --- /dev/null +++ b/docs/comty-js/models/tidal.mdx @@ -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. diff --git a/docs/comty-js/models/user.md b/docs/comty-js/models/user.md deleted file mode 100644 index 80fd4137..00000000 --- a/docs/comty-js/models/user.md +++ /dev/null @@ -1 +0,0 @@ -# User \ No newline at end of file diff --git a/docs/comty-js/models/user.mdx b/docs/comty-js/models/user.mdx new file mode 100644 index 00000000..58caf2fb --- /dev/null +++ b/docs/comty-js/models/user.mdx @@ -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. diff --git a/docusaurus/docusaurus.config.js b/docusaurus/docusaurus.config.js index 767a3f28..d1db5f02 100644 --- a/docusaurus/docusaurus.config.js +++ b/docusaurus/docusaurus.config.js @@ -37,17 +37,34 @@ const config = { presets: [ [ "classic", - /** @type {import("@docusaurus/preset-classic").Options} */ - ({ + { docs: { path: "../docs", sidebarPath: "./sidebars.js", - //editUrl: "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/", }, theme: { 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", + }, + }, + }, + }, ], ], diff --git a/docusaurus/package.json b/docusaurus/package.json index 9869ecb8..9d675971 100644 --- a/docusaurus/package.json +++ b/docusaurus/package.json @@ -18,6 +18,7 @@ "@docusaurus/preset-classic": "3.5.2", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", + "docusaurus-plugin-openapi-docs": "^4.4.0", "prism-react-renderer": "^2.3.0", "react": "^18.0.0", "react-dom": "^18.0.0"