Releases: ReplAPI-it/ReplAPI.it-NodeJS
Conditional Exports!
ReplAPI.it Version 2.1.1
Conditional Exports
In version 2.1.1 of ReplAPI.it I have added support for NodeJS using CommonJS (require('...')
) and NodeJS using ESM (import ... from '...'
).
For those who have successfully transitioned into version 2 and use ES6 syntax, there shouldn't be much change, however monitor your code for any breaks.
For those who prefer using CommonJS, you can use ReplAPI.it as follows:
const ReplAPI = require('replapi-it').default;
const replapi = ReplAPI({
username: 'your-username-here',
});
// use replapi-it classes like normal
This is a new area for me, so if any bugs arise I apologize. If you have any tips on managing a hybrid package let me know!
The NEW ReplAPI.it Package
The NEW ReplAPI.it Package
This release has a chock load of changes, and all projects that use previous version of ReplAPI.it will break when using the latest version. When upgrading to the latest version make sure you are using ES6 (more details below).
Changes
This list is... extensive. Be sure to read through it all if you are transitioning from older versions of the package.
Initializing ReplAPI.it
The biggest change you may notice in the version 2.x line is you cannot simply require the package and then use the classes. This is to accommodate initialization variables and utilize ES6 features. The new way to use ReplAPI.it is as so:
import ReplAPI from 'replapi-it'
const replapi = ReplAPI({
username: 'your-username-here',
});
// use similar to previous versions
const myUser = new replapi.User("an-username");
When you are running code be sure to use the --experimental-modules
tag. If you use Replit it is as simple as this in your .replit
file:
run = "node index.js --experimental-modules"
Initialization Variables
ReplAPI.it now has initialization variables. This is used for many things from convenience to setting preferences. When your program is run for the first time, it will create a .replapirc.json
file.
In the 2.x line, versions lower than 2.0.6 attempt to use global variables instead of dot-files. Global variables are buggy and have been depreciated.
Here are all available initialization variables:
{
username: 'Your username for Login and Mutation Interactions (no default, accepts a string)',
captcha: {
token: 'A hCaptcha token for login (no default, accepts a string)',
},
endpoints: {
gql: "Your preferred Replit GraphQL endpoint (default value: 'https://staging.replit.com/graphql')",
restful: "Your preferred Replit REST endpoint (default value: 'https://staging.replit.com')",
login: "Your preferred Replit Login endpoint (default value: 'https://staging.replit.com/login')",
},
markdown: {
length: 'Your preferred length of preview content markdown on posts and comments (default value: 150)',
removeMarkdown: 'Your preference on whether to remove markdown from previews on posts and comments (default value: false)',
},
previewCount: {
comments: "Your preference on how many comments should be fetched on a post for preview (default value: 10)",
},
experimentalFeatures: 'Your preference on whether to enable a releases experimental features, for more info see the section below (default value: false)',
}
Experimental Features
It is a pain to wait to develop something and send it in halfway when I need to patch something. I have created experimental features to solve this. By enabling experimental features you can use some exports that have been blocked off to normal users. These features are prone to break and are not recommended for production. Use at your own risk!
Query Changes
Several older queries have broken, and newer queries have come to my attention. As such, there are many new queries available. This information should not affect you too much, but there may be new information or missing information in your projects. Change your projects as necessary and check to see if data exists before using it.
Mutation Changes
Previous versions had limited, not working support for GraphQL mutations. In this version if you provide all the necessary details and have permissions you could theoretically use mutations. The amount of mutations has been stabilized and all reasonable mutations have been added to the package. This should not affect your projects since no normal user can use mutations.
Class Changes
This section will delve into the specific changes made to all the classes. Almost all classes have some changes from the 1.x line. Read this section when migrating to the 2.x versions.
Board Class
Most changes to the board class are meta and do not have major effects on projects, however it should be noted that there is more board data with Board.boardData()
and Board.boardPosts()
no longer returns full posts, instead returning post previewable data (see section Posts for more information on post previewable data).
Comment Class
The Comment class has been completely revamped with support for proper mutations. The important information:
Comment.commentData()
has been split intoComment.commentDataAbridged()
which returns a previewable comment andComment.commentDataFull()
which returns a full comment- New Mutations Include:
Comment.createCommentOnPost()
Comment.createCommentOnComment()
Comment.updateComment()
Comment.deleteComment()
Comment.createCommentVote()
Comment.deleteCommentVote()
Custom Classes
The Custom Classes are two new classes that will be touched on in the next section.
Database Class
The Database Class is an experimental feature that needs to be enabled using the experimentalFeatures
initialization variable. It's future usage will be to provide a better interface with more features to interact with ReplDB. Currently it is not useable.
Languages Class
Previously the Languages class was the only synchronous class. That is no long the case as the KNOWN_LANGUAGES variable is dynamically retrieved from Replit. The two functions exist from before under different names:
Languages.getLang()
-->Languages.langData()
Languages.getLangs()
-->Langauges.langDataAll()
These two functions are asynchronous and now always fetching the up-to-date KNOWN_LANGUAGES variable.
Leaderboard Class
This class mainly features meta changes that should not majorly impact your project, however it should be noted that it now returns a previewable user, not a full user.
Login Class
This class has many meta changes that should make it theoretically work, such as a hCaptcha support. Previously it only had one function Login.account()
. That has been scrapped and replaced with two new functions:
Login.withCredentials
which takes your passwordLogin.withSID
which takes your "client-sid" cookie
Notifications Class
This class has existed since previous versions, however it has not been documented. This will continue with the change that it is under the experimental features category. It is being worked on, and has no usage to normal users.
Post Class
Similar to the Comment Class, this class features many meta changes, and new methods. To make it short:
Post.postData()
has been split intoPost.postDataAbridged()
which returns a previewable post andPost.postDataFull()
which returns a full postPost.recentComments()
has remained the same, however it may be worth noting that the query itself hasn't functioned like before. If it does work, it will return a full comment.- New Mutations Include:
Post.createPost()
Post.updatePost()
Post.deletePost()
Post.createPostVote()
Post.deletePostVote()
- There is a new
Post.posts()
class which will return a list of posts on the ReplTalk Board. There is no noticeable difference between using this andBoard.boardPosts()
on the "all" board.
Repl Class
The Repl Class has updated query items, and will return some new data updated to reflect the new changes happening to Repls due to spotlight pages, Explore, and such. Some functions may have been renamed. Here is a list of all functions:
Repl.replGraphQLData()
~ Returns Repl Data from the GraphQL APIRepl.replRESTData()
~ Returns Repl Data from the Restful APIRepl.replComments()
~ Returns Comments made on a Repl Spotlight pageRepl.replLangs()
~ Returns statistical data from my REPLangs APIRepl.replTitleGen()
~ A logged in function that returns the random titles that Repls use (not a joke, this was an actual query)Repl.recentRepls()
~ Returns recently created Repls
User Class
This is probably the most used class, so make sure your code is up to date with everything here.
User.profileData()
has been split intoUser.userGraphQLDataAbridged()
which retuns a previewable user andUser.userGraphQLDataFull()
which returns a full user.- The subscription field on full users has been removed from the GraphQL completely. The subscription query items have been preserved elsewhere in the code, but it is no longer used in the functions to reflect this change
- A new
User.userRestfulData()
function has been created to fetch the data from Replit's Restful user endpoint User.postData()
has been split intoUser.postsDataAbridged
which returns a user's posts in a previewable format andUser.postsDataFull
which returns a user's posts in full formatUser.commentData()
has been split intoUser.commentsDataAbridged()
which returns a user's comments in previewable format andUser.commentsDataFull()
which returns a user's comments in full formatMisc.userSearch()
has been moved to the User class underUser.userSearch()
and now it returns previewable users.
There have also been many meta changes to the User class and user query items.
Misc Class
As of the version 2.x line the Misc Class has been dissolved and any salvageable queries have been moved around and re-aliased.
The Custom Class
My main drive behind ReplAPI.it was to encourage people to use the Replit GraphQL. This has changed over the course of this refactor to making the API easy to use so that anyone can use the Replit API in their project! This is why I invented the custom query class. There are actually two parts to the Custom Query Class, replapi.CustomDataQuery
and replapi.CustomRecursiveQuery
. The CustomDataQuery functions like a simple request whereas the CustomRecursiveQuery acts on unpaginate pagination for items. The usage of this requires a bit more inclination towards the t...
Major Fixes and New Classes
Version 1.2.6 of ReplAPI.it brings many new bug fixes and introduces many new classes.
Bug Fixes
- Switch to the
https://staging.replit.com
endpoints to fix any future issues - Fix an issue in the Language class causing the package to not work
- Fix several problems in the query itself
New Classes
- Additions to the Miscellaneous class (
/is_authenticated
path) - New Board Class
- New Languages Class
- New Repl Class
- New Notifications Class
- Revamped Login Class
I highly suggest switching over any older projects to the newest version manually, and using this version in your new projects.
Version 1.0.3
Initial public release, please raise an issue if you come across a problem or create a pull request if you have a suggestion!