Skip to content
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

Client Domain Structure of Callers and Handlers should match Agent Callers and Handlers #567

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

addievo
Copy link
Contributor

@addievo addievo commented Oct 11, 2023

Description

The client domain is out of spec with the updated node domain. The goal of this PR is to match spec of client domain with nodes domain.

Issues Fixed

Tasks

  • 1. All the handlers were updated to use default exports.
  • 2. All the handlers were updated to use arrow functions.
  • 3. The ServerManifest was moved into the index.ts.
  • 4. The caller definitions were moved into client/callers.
  • 5. The caller definitions were split into separate files.
  • 6. clientManifest was moved into client/callers/index.ts.
  • 7. errors.ts, types.ts and utils.ts are in client directory now.
  • 8. Convert ClientService to startStop.
  • 9. Update everything in tests/client

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@addievo addievo linked an issue Oct 11, 2023 that may be closed by this pull request
7 tasks
@ghost
Copy link

ghost commented Oct 11, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@CMCDragonkai
Copy link
Member

Yea make sure that src/client/callers and src/client/handlers look exactly the same as src/nodes/agent.

Default exports, and utility function structure, and update all imports elsewhere, and have a look at tests too.

Make sure to rebase on staging when ready for review too.

@CMCDragonkai
Copy link
Member

Name of the PR should be more descriptive. I'm changing it.

@CMCDragonkai CMCDragonkai changed the title Fixes: Issue 563 Client Domain Structure of Callers and Handlers should match Agent Callers and Handlers Oct 11, 2023
@CMCDragonkai
Copy link
Member

I think #565 should also be fixed here.

@addievo addievo marked this pull request as draft October 11, 2023 01:24
src/client/types.ts Outdated Show resolved Hide resolved
@addievo
Copy link
Contributor Author

addievo commented Oct 11, 2023

@tegefaulkes go over ClientService, there might be a little things wrong about it, I couldn't quite figure out how to implement StartStop that well

Copy link
Contributor

@tegefaulkes tegefaulkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things stand out, otherwise seems good.

src/client/ClientService.ts Outdated Show resolved Hide resolved
src/client/ClientService.ts Outdated Show resolved Hide resolved
@addievo addievo marked this pull request as ready for review October 11, 2023 03:55
@CMCDragonkai
Copy link
Member

CMCDragonkai commented Oct 11, 2023

I'm taking over this. Will note all things missing.

  1. src/client/index.ts isn't aligned.
  2. src/client/middleware.ts and src/client/timeoutMiddleware.ts and src/client/authenticationMiddleware.ts is really awkward. This might be better put together.
  3. Code isn't linted.
  4. Probably not tested.
  5. Imports isn't aligned.
  6. Spacing isn't aligned.
  7. Indeed the import type XHandler should have been import type X.
  8. Dependencies should be type imports for src/client/handlers/index.ts

@addievo don't touch anything.

@CMCDragonkai
Copy link
Member

Client service I think is a bit broken. Will need to fix it.

@CMCDragonkai CMCDragonkai force-pushed the feature-update-client-domain branch 2 times, most recently from 6958b99 to 61f2b6e Compare October 11, 2023 06:34
* all client/handlers now default export + index now imports and exports default
* server manifest in index.ts now
* `client service handlers no longer need to use `Promise<PolykeyAgent>` due to changing to Start/Stop`
* `ClientService` is changed to `StartStop`
@CMCDragonkai CMCDragonkai force-pushed the feature-update-client-domain branch from 61f2b6e to 90e6a19 Compare October 11, 2023 06:37
@CMCDragonkai
Copy link
Member

Rebased on top of staging.

There are test failures here... could it be due to import changes?

@CMCDragonkai
Copy link
Member

Agent handlers were not aligned properly... just noticed this. File naming wasn't done correctly.

@CMCDragonkai
Copy link
Member

Ok so now we are just in the tedious process of updating all the tests/client imports and ClientService construction. Furthermore, alot of the tests is repeating the setup alot, they were originally separate files originally but @tegefaulkes gathered them together to reduce memory usage.

@CMCDragonkai
Copy link
Member

Should be finished in a next hr or so, just need confirmation on why that password behaviour is happening. @tegefaulkes

@CMCDragonkai CMCDragonkai self-assigned this Oct 12, 2023
@CMCDragonkai
Copy link
Member

CMCDragonkai commented Oct 12, 2023

All tests in tests/client is passing now. Some things of note:

  1. Import order and import deduplication has not been maintained, this resulted in lots of messy imports that was very confusing. This needs discipline here.
  2. The keysPublicKey command does not take a password message.
  3. The notificationsSend handler had the wrong type.
  4. All the cases where we are repeating test setup should be moved into describe.
  5. There's a lack of care taken when writing the order of declarations, the order should be natural following the order of usage.
  6. I think overall there's too much reliance on the IDE happening here, here's a simple trick, go get the ag command and always run it against your directory to see if things are being mis-used, and always check your imports and exports before you finish. This can save alot of time at the end.
    gs
    Most importantly! The vault tests have todos for some of the most important commands!!! These are the commands that we are actually demoing, and these require actual tests.
✎ todo clones a vault
✎ todo pulls from a vault
✎ todo scans a vault

Why are we testing small things, and not the big things? This needs to be done as we are deploying and reviewing the UX.

@CMCDragonkai CMCDragonkai force-pushed the feature-update-client-domain branch from cedc6d7 to 9838c1c Compare October 12, 2023 01:27
@CMCDragonkai
Copy link
Member

BTW @amydevs when sanity checking final build, what I do is npm run build then I do a node and I do require('./dist/index.js').

@CMCDragonkai CMCDragonkai merged commit 0ca64a8 into staging Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Convert ClientService to StartStop Update client domain structure Use default exports for handler classes
3 participants