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

fix: add types for storage handler #307

Merged
merged 3 commits into from
Dec 25, 2019
Merged

fix: add types for storage handler #307

merged 3 commits into from
Dec 25, 2019

Conversation

juanpicado
Copy link
Member

Type: fix
Scope: types

Description:

Improve and fix types for ILocalPackageManager

verdaccio/generator-verdaccio-plugin#18

@codecov
Copy link

codecov bot commented Dec 25, 2019

Codecov Report

Merging #307 into master will decrease coverage by 0.02%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #307      +/-   ##
==========================================
- Coverage   65.45%   65.42%   -0.03%     
==========================================
  Files          26       26              
  Lines        1401     1400       -1     
  Branches      201      204       +3     
==========================================
- Hits          917      916       -1     
+ Misses        482      481       -1     
- Partials        2        3       +1
Flag Coverage Δ
#core 88.18% <ø> (ø) ⬆️
#plugins 58.4% <83.33%> (-0.04%) ⬇️
Impacted Files Coverage Δ
plugins/aws-s3-storage/src/s3PackageManager.ts 0.64% <0%> (ø) ⬆️
plugins/memory/src/memory-handler.ts 87.17% <100%> (ø) ⬆️
plugins/google-cloud/src/storage.ts 44.13% <100%> (-0.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f0887bd...defe386. Read the comment docs.

it removes return data from deletePackage is not required
type StorageUpdateHandler = (name: string, cb: StorageUpdateCallback) => void;
type StorageWriteCallback = (name: string, json: Package, callback: Callback) => void;
type PackageTransformer = (pkg: Package) => Package;
type ReadPackageCallback = (err: any | null, data?: Package) => void;
Copy link
Member

@anikethsaha anikethsaha Dec 25, 2019

Choose a reason for hiding this comment

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

err: any | null

how about err: Error | null ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Verdccio core not use Error, it uses VerdaccioError which are http status codes, the problem is these types are in @verdaccio/common-api and include them here would create a circle dependency. I added a comment in that file so in the future we can find a better solution, for now it must be any.

Copy link
Member Author

Choose a reason for hiding this comment

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

Plugins must return errors defined in @verdaccio/common-api , there are a complete library of methods ready to use, this will be documented in future blog posts.

Copy link
Member

Choose a reason for hiding this comment

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

// FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
// but this type is on @verdaccio/commons-api and cannot be used here yet

This one, I see !!!
will it break if you can move that here and use this package in common-api ? for types ?

Copy link
Member Author

@juanpicado juanpicado Dec 25, 2019

Choose a reason for hiding this comment

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

No, but @verdaccio/types must be free of dependencies, and VerdaccioError has one from http-status ... I think we must create a custom type and get rid of http-status in the future, so then, that would not be a problem anymore.

Copy link
Member

Choose a reason for hiding this comment

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

I think we must create a custom type and get rid of http-status in the future, so then, that would not be a problem anymore.

Yup this one is better solution I think

Copy link
Member Author

Choose a reason for hiding this comment

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

🙃 so ... can I merge?

Copy link
Member

Choose a reason for hiding this comment

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

sure 😀

Copy link
Member

@anikethsaha anikethsaha left a comment

Choose a reason for hiding this comment

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

🚀

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.

3 participants