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

Increment version for new core packages, fix linter errors #13691

Merged
merged 5 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sdk/core/core-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Release History

## 1.0.0-beta.2 (Unreleased)

## 1.0.0-beta.1 (2021-02-04)

- First release of package, see README.md for details.
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/core-client",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Core library for interfacing with AutoRest generated code",
"sdk-type": "client",
"main": "dist/index.js",
Expand Down Expand Up @@ -40,7 +40,7 @@
"integration-test:node": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o coreClient-lintReport.html || exit 0",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
"pack": "npm pack 2>&1",
"prebuild": "npm run clean",
"test:browser": "npm run build:test:browser && npm run unit-test:browser && npm run integration-test:browser",
Expand Down
6 changes: 3 additions & 3 deletions sdk/core/core-client/review/core-client.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface ClientPipelineOptions extends InternalPipelineOptions {
credential: TokenCredential;
};
deserializationOptions?: DeserializationPolicyOptions;
serializationOptions?: serializationPolicyOptions;
serializationOptions?: SerializationPolicyOptions;
}

// @public (undocumented)
Expand Down Expand Up @@ -309,13 +309,13 @@ export interface SequenceMapperType {
}

// @public
export function serializationPolicy(options?: serializationPolicyOptions): PipelinePolicy;
export function serializationPolicy(options?: SerializationPolicyOptions): PipelinePolicy;

// @public
export const serializationPolicyName = "serializationPolicy";

// @public
export interface serializationPolicyOptions {
export interface SerializationPolicyOptions {
serializerOptions?: SerializerOptions;
stringifyXML?: (obj: any, opts?: XmlOptions) => string;
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-client/src/deserializationPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ async function deserializeResponseBody(
valueToDeserialize,
"operationRes.parsedBody"
);
} catch (error) {
} catch (deserializeError) {
const restError = new RestError(
`Error ${error} occurred in deserializing the responseBody - ${parsedResponse.bodyAsText}`,
`Error ${deserializeError} occurred in deserializing the responseBody - ${parsedResponse.bodyAsText}`,
{
statusCode: parsedResponse.status,
request: parsedResponse.request,
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ export {
export {
serializationPolicy,
serializationPolicyName,
serializationPolicyOptions
SerializationPolicyOptions
} from "./serializationPolicy";
6 changes: 3 additions & 3 deletions sdk/core/core-client/src/serializationPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const serializationPolicyName = "serializationPolicy";
/**
* Options to configure API request serialization.
*/
export interface serializationPolicyOptions {
export interface SerializationPolicyOptions {
/**
* A function that is able to write XML. Required for XML support.
*/
Expand All @@ -44,7 +44,7 @@ export interface serializationPolicyOptions {
* This policy handles assembling the request body and headers using
* an OperationSpec and OperationArguments on the request.
*/
export function serializationPolicy(options: serializationPolicyOptions = {}): PipelinePolicy {
export function serializationPolicy(options: SerializationPolicyOptions = {}): PipelinePolicy {
const stringifyXML = options.stringifyXML;

return {
Expand All @@ -66,7 +66,7 @@ function serializeHeaders(
request: OperationRequest,
operationArguments: OperationArguments,
operationSpec: OperationSpec
) {
): void {
if (operationSpec.headerParameters) {
for (const headerParameter of operationSpec.headerParameters) {
let headerValue = getOperationArgumentValueFromParameter(operationArguments, headerParameter);
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-client/src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ function getXmlObjectValue(
serializedValue: any,
isXml: boolean,
options: RequiredSerializerOptions
) {
): any {
if (!isXml || !propertyMapper.xmlNamespace) {
return serializedValue;
}
Expand Down
6 changes: 3 additions & 3 deletions sdk/core/core-client/src/serviceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { getRequestUrl } from "./urlHelpers";
import { isPrimitiveType } from "./utils";
import { deserializationPolicy, DeserializationPolicyOptions } from "./deserializationPolicy";
import { URL } from "./url";
import { serializationPolicy, serializationPolicyOptions } from "./serializationPolicy";
import { serializationPolicy, SerializationPolicyOptions } from "./serializationPolicy";
import { getCachedDefaultHttpsClient } from "./httpClientCache";
import { getOperationRequestInfo } from "./operationHelpers";

Expand Down Expand Up @@ -124,7 +124,7 @@ export class ServiceClient {

/**
* Send an HTTP request that is populated using the provided OperationSpec.
* @typeParam T The typed result of the request, based on the OperationSpec.
* @typeParam T - The typed result of the request, based on the OperationSpec.
* @param operationArguments - The arguments that the HTTP request's templated values will be populated from.
* @param operationSpec - The OperationSpec to use to populate the httpRequest.
*/
Expand Down Expand Up @@ -261,7 +261,7 @@ export interface ClientPipelineOptions extends InternalPipelineOptions {
/**
* Options to customize serializationPolicy.
*/
serializationOptions?: serializationPolicyOptions;
serializationOptions?: SerializationPolicyOptions;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-client/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @param value - Value to test
* @hidden @internal
*/
export function isPrimitiveType(value: any): boolean {
export function isPrimitiveType(value: unknown): boolean {
return (typeof value !== "object" && typeof value !== "function") || value === null;
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-client/test/serviceClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe("ServiceClient", function() {

let rawResponse: FullOperationResponse | undefined;

const response = await client.sendOperationRequest(
const operationResponse = await client.sendOperationRequest(
{ options: { onResponse: (response) => (rawResponse = response) } },
{
httpMethod: "GET",
Expand All @@ -285,7 +285,7 @@ describe("ServiceClient", function() {
);

assert(request!);
assert.strictEqual(JSON.stringify(response), "{}");
assert.strictEqual(JSON.stringify(operationResponse), "{}");
assert.strictEqual(rawResponse?.status, 200);
assert.strictEqual(rawResponse?.request, request!);
assert.strictEqual(rawResponse?.headers.get("X-Extra-Info"), "foo");
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/core-https/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Release History

## 1.0.0-beta.2 (Unreleased)

## 1.0.0-beta.1 (2021-02-04)

- Changes from `core-http`:
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-https/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/core-https",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Isomorphic client library for making HTTPS requests in node.js and browser.",
"sdk-type": "client",
"main": "dist/index.js",
Expand Down Expand Up @@ -45,7 +45,7 @@
"integration-test:node": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o coreHttps-lintReport.html || exit 0",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
"pack": "npm pack 2>&1",
"prebuild": "npm run clean",
"test:browser": "npm run build:test:browser && npm run unit-test:browser && npm run integration-test:browser",
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-https/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const SDK_VERSION: string = "1.0.0-beta.1";
export const SDK_VERSION: string = "1.0.0-beta.2";
4 changes: 3 additions & 1 deletion sdk/core/core-https/src/nodeHttpsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ function isArrayBuffer(body: any): body is ArrayBuffer | ArrayBufferView {
class ReportTransform extends Transform {
private loadedBytes = 0;
private progressCallback: (progress: TransferProgressEvent) => void;

// eslint-disable-next-line @typescript-eslint/ban-types
_transform(chunk: string | Buffer, _encoding: string, callback: Function): void {
Copy link
Member

Choose a reason for hiding this comment

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

Would that work instead of disabling the rule?

Suggested change
_transform(chunk: string | Buffer, _encoding: string, callback: Function): void {
_transform(chunk: string | Buffer, _encoding: string, callback: (error?: any) => void): void {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we are overriding a method from the parent class which we do not own. So, thought it best to not change the signature compared to the same method in the parent class

Copy link
Member

Choose a reason for hiding this comment

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

Function may have came from the definition of _transform in base.d.ts.

Would (error?: Error) => void be better? The doc says it must be an Error object if an error occurred.

this.push(chunk);
this.loadedBytes += chunk.length;
Expand Down Expand Up @@ -127,7 +129,7 @@ export class NodeHttpsClient implements HttpsClient {
request
};

let responseStream = shouldDecompress ? getDecodedResponseStream(res, headers) : res;
responseStream = shouldDecompress ? getDecodedResponseStream(res, headers) : res;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xirzec This causes change in behavior. The responseStream used in the catch block was never assigned to anything. Am assuming this is what you had originally wanted

Copy link
Member

Choose a reason for hiding this comment

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

Looks like I didn't catch this problem when I reviewed #12038 -- nice find!


const onDownloadProgress = request.onDownloadProgress;
if (onDownloadProgress) {
Expand Down
8 changes: 4 additions & 4 deletions sdk/core/core-https/src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ class HttpsPipeline implements Pipeline {

const pipeline = policies.reduceRight<SendRequest>(
(next, policy) => {
return (request: PipelineRequest) => {
return policy.sendRequest(request, next);
return (req: PipelineRequest) => {
return policy.sendRequest(req, next);
};
},
(request: PipelineRequest) => httpsClient.sendRequest(request)
(req: PipelineRequest) => httpsClient.sendRequest(req)
);

return pipeline(request);
Expand Down Expand Up @@ -346,7 +346,7 @@ class HttpsPipeline implements Pipeline {
}
}

function walkPhases() {
function walkPhases(): void {
let noPhaseRan = false;

for (const phase of orderedPhases) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export function bearerTokenAuthenticationPolicy(
): PipelinePolicy {
const { credential, scopes } = options;
const tokenCache: AccessTokenCache = new ExpiringAccessTokenCache();
async function getToken(options: GetTokenOptions): Promise<string | undefined> {
async function getToken(tokenOptions: GetTokenOptions): Promise<string | undefined> {
let accessToken = tokenCache.getCachedToken();
if (accessToken === undefined) {
accessToken = (await credential.getToken(scopes, options)) || undefined;
accessToken = (await credential.getToken(scopes, tokenOptions)) || undefined;
tokenCache.setCachedToken(accessToken);
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-https/src/util/sanitizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class Sanitizer {
this.allowedQueryParameters = new Set(allowedQueryParameters.map((p) => p.toLowerCase()));
}

public sanitize(obj: object): string {
public sanitize(obj: unknown): string {
return JSON.stringify(obj, this.replacer.bind(this), 2);
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-https/src/xhrHttpsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function handleBlobResponse(
request: PipelineRequest,
res: (value: PipelineResponse | PromiseLike<PipelineResponse>) => void,
rej: (reason?: any) => void
) {
): void {
xhr.addEventListener("readystatechange", () => {
// Resolve as soon as headers are loaded
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
Expand Down
Loading