This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
The NEW ReplAPI.it Package #37
rayhanadev
started this conversation in
General Community
Replies: 3 comments 4 replies
-
pretty big release!! |
Beta Was this translation helpful? Give feedback.
1 reply
-
😏, awesome release ;) |
Beta Was this translation helpful? Give feedback.
1 reply
-
Waw thats long! I couldn't even write a paragraph...noice job! |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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:
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: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.Here are all available initialization variables:
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()
andBoard.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 commentComment.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" cookieNotifications 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.Post.createPost()
Post.updatePost()
Post.deletePost()
Post.createPostVote()
Post.deletePostVote()
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 ReplsUser 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.User.userRestfulData()
function has been created to fetch the data from Replit's Restful user endpointUser.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
andreplapi.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 technical side of things, but my hope is the ReplAPI.it community will share their custom query classes for others to use. Here is a simple example of usingreplapi.CustomDataQuery
:Creating custom classes is not as hard as it seems, and the new documentation will give a more in-depth tutorial on creating custom classes.
Meta Changes
Lastly, I want to touch on meta changes I made to the repository itself. As mentioned previously, I updated several GraphQL queries. I also updated the README (although it does not reflect changes made because of the version 2.x line), I added Code of Conduct and Contributing files for contributors, and I used ESLint on all files in order to make the code easier to read for contributors. This code is now completely formatted following the Airbnb style guidelines and it is expected that contributors do the same. I look forward to working with anyone brave enough to help!
Community
I have found that many more people than I thought depend on this package. Recently I even peaked at 444 downloads in a week. Some accidental changes to the main branch caused the package to go haywire for several people and resulted in some great projects breaking. I just wanted to say that I am sorry about that. I hope that no further accidents happen like this.
I wanted to take this moment to encourage people to use the Discussions section of this repository. Show off your projects, ask for help, and participate in upcoming changes to the package! Using Discussions or even Issues lets me know when a problem exists so I can address it quickly!
I also wanted to request some help on documenting these changes. I delayed documenting the version 1.x line for a long time and I do not want to delay the version 2.x line's documentation. I have all the styling and everything, the job is really simple. Contact me for more info!
Thank you for reading, and I hope you enjoy using the ReplAPI.it package in your projects.
This discussion was created from the release The NEW ReplAPI.it Package.
Beta Was this translation helpful? Give feedback.
All reactions