Skip to content

Commit

Permalink
Upgrade compiler to v0.62.x and tcgc in Nov. (#2892)
Browse files Browse the repository at this point in the history
* upgrade tcgc cadl-ranch and compiler to latest

* Fix the build issue for upgrading

* Report warnings for cookie parameter in RLC

* update the ut for rlc and modular

* Merge to main

* Update the lock file

* Update the nextlink to azure core's one

* Fix RLC ut failure

* Update the comments

* Update the ruleset dependency

* update @nextlink to @Azure.core.nextLink

* Update the failure for todo-non-branded.api

* Remove the list decorator with error thrown

* Update the smoke test

* Downgrade the cadl ranch version

* Revert cadl-ranch version

---------

Co-authored-by: Mary Gao <[email protected]>
  • Loading branch information
v-jiaodi and MaryGao authored Nov 13, 2024
1 parent f8429c7 commit 4ca2bb3
Show file tree
Hide file tree
Showing 21 changed files with 429 additions and 234 deletions.
402 changes: 237 additions & 165 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions packages/typespec-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"type": "module",
"dependencies": {
"@azure-tools/typespec-ts": "workspace:^0.34.0",
"@typespec/openapi": ">=0.61.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.47.0 <1.0.0",
"@typespec/openapi3": ">=0.61.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.47.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.47.4 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.47.0 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.47.0 <1.0.0",
"@typespec/compiler": ">=0.61.2 <1.0.0",
"@typespec/http": ">=0.61.0 <1.0.0",
"@typespec/rest": ">=0.61.0 <1.0.0",
"@typespec/versioning": ">=0.61.0 <1.0.0",
"@typespec/openapi": ">=0.62.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.48.0 <1.0.0",
"@typespec/openapi3": ">=0.62.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.48.0 <1.0.0",
"@typespec/compiler": ">=0.62.0 <1.0.0",
"@typespec/http": ">=0.62.0 <1.0.0",
"@typespec/rest": ">=0.62.0 <1.0.0",
"@typespec/versioning": ">=0.62.0 <1.0.0",
"prettier": "^3.1.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export interface AnomalyDetectorClientOptionalParams extends ClientOptions {
apiVersion?: string;
}

// @public
export type APIVersion = "v1.1";

// @public
export type ContinuablePage<TElement, TPage = TElement[]> = TPage & {
continuationToken?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export {
UnivariateUnivariateLastDetectionResult,
UnivariateUnivariateChangePointDetectionOptions,
UnivariateUnivariateChangePointDetectionResult,
APIVersion,
KnownVersions,
} from "./models/index.js";
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ export {
UnivariateUnivariateLastDetectionResult,
UnivariateUnivariateChangePointDetectionOptions,
UnivariateUnivariateChangePointDetectionResult,
APIVersion,
KnownVersions,
} from "./models.js";
Original file line number Diff line number Diff line change
Expand Up @@ -1071,9 +1071,6 @@ export function univariateUnivariateChangePointDetectionResultDeserializer(
};
}

/** Type of APIVersion */
export type APIVersion = "v1.1";

/** Known values of {@link Versions} that the service accepts. */
export enum KnownVersions {
v1_1 = "v1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ model ModelList {
maxCount: int32;

@doc("The link to fetch more models.")
@nextLink
@Azure.Core.nextLink
nextLink?: string;
}

Expand Down
26 changes: 13 additions & 13 deletions packages/typespec-test/test/batch_modular/spec/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ model ApplicationListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -642,7 +642,7 @@ model PoolListUsageMetricsResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -673,7 +673,7 @@ model AccountListSupportedImagesResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -738,7 +738,7 @@ model PoolNodeCountsListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -1001,7 +1001,7 @@ model CertificateListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand All @@ -1017,7 +1017,7 @@ model NodeFileListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -2228,7 +2228,7 @@ model BatchJobScheduleListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -2461,7 +2461,7 @@ model BatchJobListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand All @@ -2477,7 +2477,7 @@ model BatchJobListPreparationAndReleaseTaskStatusResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -2998,7 +2998,7 @@ model BatchPoolListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -3422,7 +3422,7 @@ model BatchTaskListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -3783,7 +3783,7 @@ model BatchNodeListResult {

#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Property types must use camelCase"
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down Expand Up @@ -3840,6 +3840,6 @@ model NodeVMExtensionList {
value?: NodeVMExtension[];

@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ model PagedLedgerEntries {
state: LedgerQueryState;

@doc("Path from which to retrieve the next page of results.")
@nextLink
@Azure.Core.nextLink
nextLink?: ResourceLocation<LedgerEntry>;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/typespec-test/test/todo_non_branded/spec/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ namespace TodoItems {

model TodoPage {
/** The items in the page */
@pageItems
items: TodoItem[];

pagination: {
Expand Down Expand Up @@ -248,7 +249,7 @@ namespace TodoItems {

@route("{itemId}/attachments")
namespace Attachments {
@list op list(
op list(
@path itemId: TodoItem.id,
): TodoAttachment[] | NotFoundResponse;

Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-test/test/widget_dpg/spec/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ model ListWidgetsPagesResults {
@items
results: Widget[];
@doc("The URL to get the next set of results.")
@nextLink
@Azure.Core.nextLink
`odata.nextLink`?: string;
}

Expand Down
30 changes: 15 additions & 15 deletions packages/typespec-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@
"@azure-tools/cadl-ranch-specs": "^0.38.0",
"@azure-tools/cadl-ranch": "^0.15.0",
"@azure-tools/cadl-ranch-api": "^0.5.0",
"@azure-tools/typespec-autorest": ">=0.47.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.47.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.47.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.47.4 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.48.0 <1.0.0",
"@azure/abort-controller": "^2.1.2",
"@azure/core-auth": "^1.6.0",
"@azure/core-lro": "^3.1.0",
Expand All @@ -85,12 +85,12 @@
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@typespec/compiler": ">=0.61.2 <1.0.0",
"@typespec/http": ">=0.61.0 <1.0.0",
"@typespec/openapi": ">=0.61.0, <1.0.0",
"@typespec/rest": ">=0.61.0 <1.0.0",
"@typespec/compiler": ">=0.62.0 <1.0.0",
"@typespec/http": ">=0.62.0 <1.0.0",
"@typespec/openapi": ">=0.62.0, <1.0.0",
"@typespec/rest": ">=0.62.0 <1.0.0",
"@typespec/ts-http-runtime": "1.0.0-alpha.20240314.2",
"@typespec/versioning": ">=0.61.0 <1.0.0",
"@typespec/versioning": ">=0.62.0 <1.0.0",
"chai": "^4.3.6",
"chalk": "^4.0.0",
"cross-env": "^7.0.3",
Expand All @@ -110,12 +110,12 @@
"tsx": "^4.16.5"
},
"peerDependencies": {
"@azure-tools/typespec-azure-core": ">=0.47.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.47.4 <1.0.0",
"@typespec/compiler": ">=0.61.2 <1.0.0",
"@typespec/http": ">=0.61.0 <1.0.0",
"@typespec/rest": ">=0.61.0 <1.0.0",
"@typespec/versioning": ">=0.61.0 <1.0.0"
"@azure-tools/typespec-azure-core": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.48.0 <1.0.0",
"@typespec/compiler": ">=0.62.0 <1.0.0",
"@typespec/http": ">=0.62.0 <1.0.0",
"@typespec/rest": ">=0.62.0 <1.0.0",
"@typespec/versioning": ">=0.62.0 <1.0.0"
},
"dependencies": {
"@azure-tools/rlc-common": "workspace:^0.34.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/typespec-ts/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ const libDef = {
messages: {
default: paramMessage`Path parameter '${"paramName"}' cannot be optional.`
}
},
"parameter-type-not-supported": {
severity: "warning",
messages: {
default: paramMessage`Parameter '${"paramName"}' with type '${"paramType"}' is not supported and we would ignore this parameter.`
}
}
},
emitter: {
Expand Down
20 changes: 19 additions & 1 deletion packages/typespec-ts/src/modular/buildCodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,19 @@ function emitParameter(
context: SdkContext,
parameter: HttpOperationParameter | HttpServerParameter,
implementation: string
): Parameter {
): Parameter | undefined {
if (parameter.type === "cookie") {
// TODO: support cookie parameters, https://github.com/Azure/autorest.typescript/issues/2898
reportDiagnostic(context.program, {
code: "parameter-type-not-supported",
format: {
paramType: parameter.type,
paramName: parameter.name
},
target: NoTarget
});
return undefined;
}
const base = emitParamBase(context, parameter.param);
let type = getType(context, parameter.param.type, {
usage: UsageFlags.Input
Expand Down Expand Up @@ -857,6 +869,9 @@ function emitBasicOperation(
continue;
}
const emittedParam = emitParameter(context, param, "Method");
if (emittedParam === undefined) {
continue;
}
if (isApiVersion(context, param)) {
emittedParam.isApiVersion = true;
methodApiVersionParam = emittedParam;
Expand Down Expand Up @@ -1719,6 +1734,9 @@ function emitServerParams(
serverParameter,
"Client"
);
if (emittedParameter === undefined) {
continue;
}
endpointPathParameters.push(emittedParameter);
if (isApiVersion(context, serverParameter as any)) {
emittedParameter.isApiVersion = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-ts/src/transform/transformApiVersionInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function getOperationApiVersion(
relevantProperty: p.param
});
required.add(!p.param.optional);
if (p.type !== "header") {
if (p.type === "query" || p.type === "path") {
locations.add(p.type);
}
const typeString = JSON.stringify(trimUsage(type));
Expand Down Expand Up @@ -127,7 +127,7 @@ export function getOperationApiVersion(
relevantProperty: p.param
});
required.add(!p.param.optional);
if (p.type !== "header") {
if (p.type === "query" || p.type === "path") {
locations.add(p.type);
}
const typeString = JSON.stringify(trimUsage(type));
Expand Down
24 changes: 23 additions & 1 deletion packages/typespec-ts/src/transform/transformParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
listOperationGroups,
listOperationsInOperationGroup
} from "@azure-tools/typespec-client-generator-core";
import { Type, isVoidType } from "@typespec/compiler";
import { NoTarget, Type, isVoidType } from "@typespec/compiler";
import {
getBodyType,
getFormattedPropertyDoc,
Expand All @@ -46,6 +46,7 @@ import {
} from "../utils/operationUtil.js";

import { SdkContext } from "../utils/interfaces.js";
import { reportDiagnostic } from "../lib.js";

export function transformToParameterTypes(
client: SdkClient,
Expand Down Expand Up @@ -99,6 +100,8 @@ export function transformToParameterTypes(
);
// transform path param
const pathParams = transformPathParameters();
// TODO: support cookie parameters, https://github.com/Azure/autorest.typescript/issues/2898
transformCookieParameters(dpgContext, parameters);
// transform header param including content-type
const headerParams = transformHeaderParameters(
dpgContext,
Expand Down Expand Up @@ -200,6 +203,25 @@ function getParameterName(name: string) {
return `"${name}"`;
}

function transformCookieParameters(
dpgContext: SdkContext,
parameters: HttpOperationParameters
) {
// TODO: support cookie parameters, https://github.com/Azure/autorest.typescript/issues/2898
parameters.parameters
.filter((p) => p.type === "cookie")
.forEach((p) => {
reportDiagnostic(dpgContext.program, {
code: "parameter-type-not-supported",
format: {
paramName: p.name,
paramType: p.type
},
target: NoTarget
});
});
}

function transformQueryParameters(
dpgContext: SdkContext,
parameters: HttpOperationParameters,
Expand Down
Loading

0 comments on commit 4ca2bb3

Please sign in to comment.