-
Notifications
You must be signed in to change notification settings - Fork 1
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
initial implementation of invite method for MemberApi #232
Conversation
0843ad2
to
ef392b2
Compare
tests/member-api.js
Outdated
import { MemberApi } from '../src/member-api.js' | ||
import { replicate } from './helpers/rpc.js' | ||
|
||
test('Invite sends expected project-related details', async (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test kind of overlaps with some of the rpc unit tests. okay for now since I just want something here until i figure out what else to test
src/member-api.js
Outdated
* @param {string} deviceId | ||
* | ||
* @param {Object} opts | ||
* @param {string} opts.role |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this and how should it be used with MapeoRPC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be roleId
. After the device responds to the invite we should write that role assignment e.g:
const response = await this.#rpc.invite()
if (response === 'ACCEPT') {
capabilities.assignRole(deviceId, roleId)
}
(not sure if I have the correct return type of invite())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does the device being invited know what role they will be assigned prior to responding? Shouldn't the call to rpc.invite()
also accept some param about the role to send to the target peer?
My understanding is that from a UX perspective, someone with an invite should see something like "Bob has invited you to be ROLE in PROJECT NAME"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param name addressed via 562f73d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role assignment addressed via e26ff99
9e9b3d7
to
c1d0acd
Compare
src/member-api.js
Outdated
* @param {string} deviceId | ||
* | ||
* @param {Object} opts | ||
* @param {string} opts.role |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be roleId
. After the device responds to the invite we should write that role assignment e.g:
const response = await this.#rpc.invite()
if (response === 'ACCEPT') {
capabilities.assignRole(deviceId, roleId)
}
(not sure if I have the correct return type of invite())
c1d0acd
to
88a3ef4
Compare
88a3ef4
to
562f73d
Compare
562f73d
to
e26ff99
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the role assignment bit. wanted to have some tests to cover that part but they may be diving into implementation details too much. perhaps better to write an e2e for this?
replicate(r1, r2) | ||
}) | ||
|
||
test('invite() does not assign role to invited device if invite is not accepted', async (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe testing implementation details too much?
replicate(r1, r2) | ||
}) | ||
|
||
test('invite() assigns role to invited device after invite accepted', async (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe testing implementation details too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, good work on this. I think tests are ok - we can eventually replace with e2e tests but at this stage these tests are helpful for making sure the internals of this are working as expected as we build upon it.
* main: (25 commits) add initial implementation of MemberApi (#232) feat: $blobs.getUrl and $blobs.create methods (#184) chore: update manager e2e tests (#237) feat: add capabilities (#231) feat: coreOwnership integration [3/3] (#230) feat: CoreOwnership class w getOwner & getCoreKey [2/3] (#229) feat: handle `coreOwnership` records in `IndexWriter` [1/3] (#214) fix: adjust storage options for MapeoManager and MapeoProject (#235) implement addProject method for MapeoManager class (#215) implement listProjects method for MapeoManager class (#208) feat: expose blobStore.writerDriveId (#219) implement wrapper client containing createProject and getProject methods (#199) add project settings functionality to MapeoProject (#187) feat: Add encode/decode for project keys [3/3] (#203) feat: update protobuf for RPC [2/3] (#202) chore: move protobuf messages into src/generated [1/3] (#201) feat: Add internal `dataType.createWithDocId()` (#192) chore: explicitly set "mode" opt for encryptionKeys column creation (#186) chore: fix linting and type checking (#183) chore: consolidate encryption key columns in projectKeys table (#181) ...
Towards #225
MemberApi
classinvite
methodTODO:
role
here and how does it work with MapeoRPC? Our original documentation suggests that it's some human-readable string, but given the recent work on capabilities, wondering if that changes to a role id or something like that. EDIT: answered in initial implementation of invite method for MemberApi #232 (comment)