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 listProjects method for MapeoManager class #208

Merged
merged 5 commits into from
Aug 24, 2023

Conversation

achou11
Copy link
Member

@achou11 achou11 commented Aug 22, 2023

Closes #206

NOTE: Stacked on #199

Also:

  • adds a $getProjectInfo to the MapeoProject class, which is used to retrieve information that's used for the resulting MapeoManager.listProjects() return value. $getProjectInfo returns the ProjectInfo type, which represents meta information about a project (different from its settings). It is currently defined as EDIT: No longer relevant
type ProjectInfo = {
  createdAt: Date
  updatedAt: Date
  projectId: string
}

src/mapeo-manager.js Outdated Show resolved Hide resolved
@achou11 achou11 force-pushed the 206/client-list-projects branch 3 times, most recently from 71fc1d9 to f1d8bf8 Compare August 23, 2023 19:26
src/mapeo-manager.js Outdated Show resolved Hide resolved
src/mapeo-manager.js Outdated Show resolved Hide resolved
@achou11 achou11 force-pushed the 206/client-list-projects branch 2 times, most recently from 7eb7825 to aa29820 Compare August 23, 2023 21:01
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.

Hate to be that person, but I think this entire PR can be done in one line:

async listProjects() {
   return this.#db.select().from(projectTable).all()
}

(might actually need a little bit more).

Keeping the project table in the client instance was so that we can do this.

/**
* @returns {Promise<Array<ProjectInfo & Pick<ProjectValue, 'name'>>>}
*/
async listProjects() {
Copy link
Member

Choose a reason for hiding this comment

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

All the shenanigans about having a shared index writer were so that we did not have to create project instances to get the project name, and instead we can do:

this.#db.select().from(projectTable).all()

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via b29fa8b

@achou11
Copy link
Member Author

achou11 commented Aug 24, 2023

@gmaclennan ah right, forgot about the projects table 🤦‍♂️

Base automatically changed from 168/client-create-project to main August 24, 2023 11:56
src/mapeo-manager.js Outdated Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
})
.from(projectTable)
.all()
.map((value) => ({
Copy link
Member

Choose a reason for hiding this comment

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

Mapbyr use the denullify function here?

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via 5ff8aad

@gmaclennan
Copy link
Member

Looks good to me 👍

@achou11 achou11 merged commit cbdf93d into main Aug 24, 2023
6 checks passed
@achou11 achou11 deleted the 206/client-list-projects branch August 24, 2023 13:46
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 listProjects method for wrapper client class
2 participants