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

[storage-blob] add missing jsdocs & export types that were missed out #5857

Merged
merged 9 commits into from
Oct 28, 2019

Conversation

chradek
Copy link
Contributor

@chradek chradek commented Oct 26, 2019

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.

@@ -3,6 +3,7 @@

import { RequestPolicy, RequestPolicyFactory, RequestPolicyOptions } from "@azure/core-http";
import { BrowserPolicy } from "./policies/BrowserPolicy";
export { BrowserPolicy };
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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 };
Copy link
Contributor

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.
Copy link
Contributor

@ramya-rao-a ramya-rao-a Oct 27, 2019

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.

Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 :)

Copy link
Member

@HarshaNalluru HarshaNalluru Oct 27, 2019

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.

Copy link
Contributor Author

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.

Copy link
Member

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,
Copy link
Member

Choose a reason for hiding this comment

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

?

@jeremymeng
Copy link
Member

jeremymeng commented Oct 27, 2019 via email

@chradek
Copy link
Contributor Author

chradek commented Oct 27, 2019

There are types that are not directly used in the public api, but cause warnings in api etractor review reports. I chose not to export them because I don't think those types are likely to be used by our users. The structure of the response results are more important.

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.

@bterlson
Copy link
Member

bterlson commented Oct 27, 2019

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.

@chradek
Copy link
Contributor Author

chradek commented Oct 27, 2019

Reverted policy renames in this PR. Will post in separate PR.

@HarshaNalluru HarshaNalluru added Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) labels Oct 27, 2019
@@ -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.
Copy link
Member

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;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

formatter removes the whitespace? :(

Copy link
Contributor Author

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!

@ramya-rao-a ramya-rao-a changed the title [storage-blob] add jsdocs [storage-blob] add missing jsdocs & export types that were missed out Oct 27, 2019
@jeremymeng
Copy link
Member

Are we concerned these interface names may change in the future?

Yeah I was thinking that we might need to rename these codegen types so was trying to reduced the exposed surface.

Copy link
Member

@XiaoningLiu XiaoningLiu left a comment

Choose a reason for hiding this comment

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

:shipit:

@chradek chradek merged commit af6345e into Azure:master Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants