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

implement addProject method for MapeoManager class #215

Merged
merged 22 commits into from
Aug 29, 2023

Conversation

achou11
Copy link
Member

@achou11 achou11 commented Aug 23, 2023

Closes #209

NOTE: Stacked on #208

Lots of implementation questions:

  • my understanding is that adding the project should update the ProjectKeys table in the client db if it's not there. However, how do we get the auth encryption key if that's the case? (which is required in the encryptionKeys column value) EDIT: addressed
  • I'm guessing that we don't want to call project.$setProjectSettings() after creating the project instance, like we do in manager.createProject(). If that's the case, does it still make sense to return the project instance in this addProject() method? doing so seems to cause some issues unless I'm missing an important step: EDIT: addressed

TODO:

  • Add tests. Not really sure what to test here...Was thinking that there's gotta be some distinction between creating a project and adding a project created by someone else i.e. you don't necessarily have the project secret key + encryption keys for the project (in the latter).
  • (non-blocking) wait for fix: invite.encryptionKeys should be required #223 to fix type issue with Invite

@achou11 achou11 marked this pull request as ready for review August 23, 2023 21:37
@achou11 achou11 marked this pull request as draft August 23, 2023 22:12
@achou11 achou11 marked this pull request as draft August 23, 2023 22:12
@achou11 achou11 force-pushed the 209/client-add-project branch 2 times, most recently from 135b900 to 1dd14f0 Compare August 23, 2023 22:37
Copy link
Member

@gmaclennan gmaclennan left a comment

Choose a reason for hiding this comment

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

Somewhere along the way the API docs got out of date.

addProject() is what we would use when receiving an invite, so the param should be the same type as an invite e.g.

addProject(invite: {
  projectKey: Buffer,
  encryptionKeys: {
    auth: Buffer;
    data?: Buffer | undefined;
    config?: Buffer | undefined;
    blobIndex?: Buffer | undefined;
    blob?: Buffer | undefined;
  },
  projectInfo: { name?: string | undefined }
}

Not sure what to do with projectInfo - once we sync we will get the project info from the replicated cores, but in the meantime it would be good to use the name passed here. Suggestions?

@gmaclennan
Copy link
Member

If the project you are trying to add already exists then I think maybe throw? And maybe return the projectId the same as createProject?

@gmaclennan
Copy link
Member

Also the proto definitions for Invite need updated - encryptionKeys should be required, since we always need an auth core encryption key. I'll do that now.

@achou11 achou11 force-pushed the 206/client-list-projects branch 2 times, most recently from 7b889a8 to 4e662ae Compare August 24, 2023 12:20
@achou11
Copy link
Member Author

achou11 commented Aug 24, 2023

Somewhere along the way the API docs got out of date.

addProject() is what we would use when receiving an invite, so the param should be the same type as an invite

Ah this make sense. Figured that something about the method params would need to be updated. I have an issue in the core docs repo (digidem/mapeo-core-docs#14) to track changes that need to be made there as a result of the implementation changes we do here, in case that's helpful (I already added it as an item there to address later)

Not sure what to do with projectInfo - once we sync we will get the project info from the replicated cores, but in the meantime it would be good to use the name passed here. Suggestions?

not sure what suggestions you're looking for, but seems like it would make sense to use whatever's passed there to update the settings of a project via project.$setProjectSettings()

EDIT: discussion with Gregor surfaced the fact that we can't just do the setProjectSettings() call like I thought. Decided on the following:

  • Update projectKeys table to have projectInfo column that's a custom json type with name field for now
  • Update listProjects implementation to read from the projectKeys table as the source of truth for what projects exist, and cross reference with queried project table to get desired information for return value (no sql join necessary for now)
  • Update addProject to save invite.projectInfo to projectKeys table

@achou11 achou11 force-pushed the 209/client-add-project branch 2 times, most recently from 7fa0c9b to 5851f5c Compare August 24, 2023 13:13
@achou11 achou11 changed the title WIP: implement addProject method for MapeoManager class implement addProject method for MapeoManager class Aug 24, 2023
@achou11 achou11 marked this pull request as ready for review August 24, 2023 13:22
Base automatically changed from 206/client-list-projects to main August 24, 2023 13:46
@achou11 achou11 deleted the 209/client-add-project branch August 29, 2023 19:34
gmaclennan added a commit that referenced this pull request Sep 6, 2023
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement addProject method for wrapper client class
2 participants