-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[storage-blob] add missing jsdocs & export types that were missed out #5857
Conversation
@@ -3,6 +3,7 @@ | |||
|
|||
import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "@azure/core-http"; | |||
import { BrowserPolicy } from "./policies/BrowserPolicy"; | |||
export { BrowserPolicy }; |
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.
Why is this being exported?
From what I can see, the BrowserPolicy
is used only in the BrowserPolicyFactory
which in turn is internal to the library and not exposed to the user
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.
There may be a mistake then, because some of the policy factories are currently being exported. Are the factories meant to be exported?
I exported this and the RetryPolicy
because the factories referenced them and were being exported for users.
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.
That's interesting. @bterlson are we ok with these policies being exported?
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.
If we are exporting it, then we should probably add a "Storage" prefix to it, right?
Especially for the retry policy.
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.
cc @bterlson
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.
BrowserPolicy should be exported since it's a policy specific to Storage and users might want to compose their own pipeline with BrowserPolicy in it.
StorageBrowserPolicy makes sense (and so too does a general guideline requiring some prefix for policies so it's clear their service-specific), but considering that they can only import this from the storage package itself, it's not super important I think.
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.
Renamed to StorageBlobBrowserPolicy
since the policies aren't shared across storage packages.
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.
The rename is part of #5862
@@ -5,6 +5,7 @@ import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "@azur | |||
import { RetryPolicy, RetryPolicyType } from "./policies/RetryPolicy"; | |||
|
|||
export { RetryPolicyType } from "./policies/RetryPolicy"; | |||
export { RetryPolicy }; |
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.
Why is this being exported?
From what I can see, the RetryPolicy
is used only in the RetryPolicyFactory
which in turn is internal to the library and not exposed to the user
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.
The RetryPolicyFactory/RetryPolicy should be exported as it is useful when composing a custom pipeline.
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.
Renamed to StorageBlobRetryPolicy
since storage queue exports its own retry policy as well.
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.
Rename is part of #5862
@@ -24,7 +23,7 @@ export interface KeyInfo { | |||
} | |||
|
|||
/** | |||
* A user delegation key | |||
* A user delegation key. |
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.
Please revert the changes to this file. It is auto-generated code and will get overwritten the next time we generate the same.
We should log a separate issue to track docs for auto-generated entities and fix the swagger/transformations as part of that.
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.
@XiaoningLiu Is there any other way to improve the docs in the generated models?
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.
@joheredi had fixed comments on the generated model by updating the swagger with a transformation in #5742
@HarshaNalluru Is this the suggested way to edit the comments on a generated model?
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.
Ah, I should have realized that this was a generated file. I'll revert the changes to this file.
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.
Keep a copy of it somewhere, such that if we do decide to update the transformations, we have something to refer to :)
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.
Though we can add transformations in readme like #5742, adding too many transformations for the comments doesn't make sense. Ideally, all these comments must be updated in the original swagger JSON file (other languages will also likely get benefitted by this).
Options -
- Add transformations in swagger readme like [Storage][Blob] Fix comment on BlobGetPropertiesHeaders.contentLength #5742 and the generated code will have the docs updated.
- Update swagger JSON file with these comments ASAP and regenerate the code before GA.
- If we don't want to update the swagger JSON at this point of time(keeping GA in mind),
We can consider updating the JS Docs like the way Chris did in this PR, assuming there won't be any significant updates to the swagger just before GA(which means code-gen won't change).
[ and track the future work to update the swagger JSON with these doc-comments updates and to regenerate the code. ] - Not update the docs for code-gen files and keep this work-item for post GA and fix the docs in swagger as a high priority and do a quick minor/patch release right after GA.
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.
I added a commit to this PR to remove the comments in the generated file, but we can remove that commit if we decide to go ahead with the docs and fast-follow on updating the swagger file.
I would not want to add transformations based on the sheer number of updates we'd have to make.
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.
I agree. I'd suggest option-3 (and making a separate PR for it just for the generated files).
cc - @XiaoningLiu
AppendPositionAccessConditions, | ||
ServiceGetUserDelegationKeyHeaders, | ||
ServiceSubmitBatchHeaders, | ||
ServiceGetAccountInfoHeaders, | ||
ServiceGetPropertiesHeaders, |
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.
?
Why would we not want to export these though? Are we concerned these interface names may change in the future? I noticed the typings that are used today are not the rolled-up ones. So, type inference does work, but if a user wanted to reference a type that isn't exported from index.ts they end up having to reach into our package: import {BlobServiceClient, SharedKeyCredential} from '@azure/storage-blob';
import { ServiceGetAccountInfoHeaders } from '@azure/storage-blob/typings/src/generated/src/models';
async function getAccountParsedHeaders(): Promise<ServiceGetAccountInfoHeaders> {
const client = new BlobServiceClient(`url`, new SharedKeyCredential('account', 'key'));
const result = await client.getAccountInfo();
// return the parsed headers...
return result._response.parsedHeaders;
} My fear with the above is that now the typings will break if we ever change the internal structure of our package. If we did use the rollup-typings (Should we be? We do in the other SDK packages), these interfaces actually get pulled into the flattened typings so are available from the root of the package. In this case, exporting them from the index.ts file gets rid of the ae-forgotten-export warnings. |
I tend to think those types should be exported from the root. @chradek re: question about rollup types, I think we should do that eventually, but I wasn't going to push for pre-GA it since api-extractor was broken with storage until @jeremymeng fixed it very recently. |
Reverted policy renames in this PR. Will post in separate PR. |
@@ -1356,6 +1362,7 @@ export class BlobClient extends StorageClient { | |||
* This method returns a long running operation poller that allows you to wait | |||
* indefinitely until the copy is completed. | |||
* You can also cancel a copy before it is completed by calling `cancelOperation` on the poller. | |||
* Note that attempting to cancel a completed copy will result in an error being thrown. |
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.
Thanks :)
* The parsed HTTP response headers. | ||
*/ | ||
parsedHeaders: ServiceSetPropertiesHeaders; | ||
}; |
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.
formatter removes the whitespace? :(
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.
Unfortunately :( But plus side, we can refer back to this PR for these docs when we add them to the swagger file!
Yeah I was thinking that we might need to rename these codegen types so was trying to reduced the exposed surface. |
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.
Exports the APIs that were missing from the index.ts file, and adds TSDoc comments where needed.
One caveat...I did not export the abstract StorageClient class from index.ts, since I don't think we actually want users to use it directly. If we do want to export it we'll have to export the StorageClientContext (and possibly other interfaces) as well.