forked from mscdex/node-imap
-
Notifications
You must be signed in to change notification settings - Fork 1
Modern API #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
LoveAndCoding
wants to merge
10
commits into
main
Choose a base branch
from
modern-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Modern API #3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is the beginning of the new command style strcture. Commands will be added as self managing classes that know how to generate and send the actual command text as well as process parsed responses. The base class implements a common strategy of sending a tagged command and listening for a tagged response, capturing everything in between. The no-op is the most simple implementation of this command system.
Adding command classes for the ID and Capability commands, which will be common to run on intiating the connection. Also included is the first command encoding function for creating IMAP safe strings.
This class will eventually serve as the base class that is exposed and that other systems would interface with. This will contain the public- facing API for the library and will be both a mirror and an update of existing functionality. Note that this commit does not expose this class nor remove or change the original `Connection` class which currently acts as the public interface. Eventually the `Connection` class will be cleaned up and it will serve purely as the connection for the session without any logic for actual commands.
Pulled everything out of the connection class that is not actually related to the connection. This means almost all IMAP related commands and controls will be in a new class. The code went from almost 2k lines to around 300, which should be a lot easier to understand. From a practical perspective, I chose to write a brand new class and just remove the old copy completely. The old code was inter-weaved with a lot of implicit assumptions and untangling that would have been a nightmare. This does, however, mean this is all (or almost all) new code. Which is extra terrifying. But that's a future me problem.
Actually connects and exposes the Session class so that it functions and can create and manage an IMAP session! This is exciting, and I was able to connect a new session to GMail and get the capabilities and server info 💃 **Test plan:** Connect to GMail using the Session class Celebrate 🙌
Instead of just using A0, A1, etc. we want to use A1, B1, etc. This us to send *a lot* more commands before we reuse tags
Creating a baseline E2E suite that can be used to test compatibility against various servers. **Test plan:** yarn test:e2e
With the update to tag names, the tests needed updating. **Test plan:** `yarn test` `yarn test:e2e`
Testing out reporting coverage via GH Actions. **Test plan:** Hope that this all works because GH actions are a pain sometimes
Languages that use indentation as syntax should burn. Spacing should not determine validity 🔥
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goals
Have clean and easy to understand API that utilizes modern JS functionality. Under the hood, the code should also better differentiate between an IMAP connection and an IMAP session, and utilize the rewritten parser engine.
Work
async
/await
/promise
methods