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

feat: $blobs.getUrl and $blobs.create methods #184

Merged
merged 18 commits into from
Aug 31, 2023
Merged

Conversation

sethvincent
Copy link
Contributor

closes #104

There are a couple todos that need to be addressed that I'm not sure about. See comment below.

src/mapeo-project.js Outdated Show resolved Hide resolved
Copy link
Member

@achou11 achou11 left a comment

Choose a reason for hiding this comment

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

feeling a little brain-drained so hopefully my comment about the hostname question makes some sense 😅

src/mapeo-project.js Outdated Show resolved Hide resolved
src/blob-store/index.js Outdated Show resolved Hide resolved
src/blob-store/index.js Outdated Show resolved Hide resolved
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.

Progress looks good, I made some comments.

How about keeping these methods (create() and getUrl()) in a separate class BlobApi that takes the blobStore as a constructor param? It feels like we're overloading the blobStore API here with something that has a different purpose.

src/mapeo-project.js Outdated Show resolved Hide resolved
src/blob-store/index.js Outdated Show resolved Hide resolved
src/mapeo-project.js Outdated Show resolved Hide resolved
src/blob-store/index.js Outdated Show resolved Hide resolved
src/blob-store/index.js Outdated Show resolved Hide resolved
src/mapeo-project.js Outdated Show resolved Hide resolved
@sethvincent
Copy link
Contributor Author

I added a couple of commits that I think addresses everything but getting the port from fastify into the BlobApi class / getUrl method. Added a comment above about that.

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.

Good work on this. It needs tests though before merging, and I left a couple of comments including a suggestion about getPort and an undefined method this.createWriteStream()

src/blob-api.js Outdated Show resolved Hide resolved
src/blob-api.js Outdated Show resolved Hide resolved
src/blob-api.js Outdated Show resolved Hide resolved
src/blob-api.js Outdated Show resolved Hide resolved
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.

Looking good. Tests are failing though - need fixed before a merge. Plus a change needed in return type of $blob.create

src/blob-api.js Outdated
* Write blobs for provided variants of a file
* @param {{ original: string, preview?: string, thumbnail?: string }} filepaths
* @param {{ mimeType: string }} metadata
* @returns {Promise<{ original: Omit<BlobId, 'driveId'>, preview?: Omit<BlobId, 'driveId'>, thumbnail?: Omit<BlobId, 'driveId'> }>}
Copy link
Member

Choose a reason for hiding this comment

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

This will actually need to return type Observation['attachments'][number] e.g.

{ driveId: string, name: string, type: 'photo' | 'video' | 'audio' }

Copy link
Contributor Author

@sethvincent sethvincent Aug 23, 2023

Choose a reason for hiding this comment

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

so far this module hasn't known about driveId. Would that be passed in the create method?

Copy link
Member

Choose a reason for hiding this comment

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

Ah very good point. It's actually a property on the writeStream e.g. blobStore.createWriteStream().driveId although I just realised that was not documented (my bad) and it's an awkward API too. Since the driveId for any written blobs will never change for a particular instance of the blobStore, I think it makes sense to just expose it as blobStore.writerDriveId, and use it from there. I've created an issue and made a fix

src/blob-api.js Outdated Show resolved Hide resolved
src/blob-api.js Outdated Show resolved Hide resolved
src/blob-api.js Outdated Show resolved Hide resolved
src/blob-api.js Outdated Show resolved Hide resolved
src/mapeo-project.js Show resolved Hide resolved
tests/helpers/blob-server.js Outdated Show resolved Hide resolved
tests/blob-api.js Show resolved Hide resolved
tests/blob-api.js Show resolved Hide resolved
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.

Great work on getting this wrapped up, looks good to merge now once the driveId question is resolved. I'll merge #219 today and then you can use blobStore.writerDriveId instead of metadata.driveId. Once that is done we can merge.

@gmaclennan
Copy link
Member

gmaclennan commented Aug 30, 2023

Great work on getting this wrapped up, looks good to merge now once the driveId question is resolved. I'll merge #219 today and then you can use blobStore.writerDriveId instead of metadata.driveId. Once that is done we can merge.

@sethvincent I saw another review request for me, but this comment still doesn't seem to be resolved?

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)
  ...
@gmaclennan gmaclennan deleted the blob-methods-#104 branch October 26, 2023 02:02
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.

Add $blob namespace methods to project instance API
3 participants