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

Upgrade compiler to v0.60.x and tcgc in Sep. #2819

Merged
merged 9 commits into from
Sep 20, 2024
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
324 changes: 190 additions & 134 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions packages/typespec-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"type": "module",
"dependencies": {
"@azure-tools/typespec-ts": "workspace:^0.33.0",
"@typespec/openapi": ">=0.59.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.45.0 <1.0.0",
"@typespec/openapi3": ">=0.59.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.45.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.45.4 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.45.0 <1.0.0",
"@typespec/compiler": ">=0.59.0 <1.0.0",
"@typespec/http": ">=0.59.0 <1.0.0",
"@typespec/rest": ">=0.59.0 <1.0.0",
"@typespec/versioning": ">=0.59.0 <1.0.0",
"@typespec/openapi": ">=0.60.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.46.0 <1.0.0",
"@typespec/openapi3": ">=0.60.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.46.1 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.46.0 <1.0.0",
"@typespec/compiler": ">=0.60.0 <1.0.0",
"@typespec/http": ">=0.60.0 <1.0.0",
"@typespec/rest": ">=0.60.0 <1.0.0",
"@typespec/versioning": ">=0.60.0 <1.0.0",
"prettier": "^3.1.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@
}
},
"x-ms-pageable": {
"nextLinkName": "nextLink"
"nextLinkName": "nextLink",
"itemName": "models"
}
},
"post": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ export interface MultivariateOperations {
trainMultivariateModel: (modelInfo: MultivariateModelInfo, options?: MultivariateTrainMultivariateModelOptionalParams) => Promise<MultivariateAnomalyDetectionModel>;
}

// @public
export interface MultivariateResponseError {
code: string;
message: string;
}

// @public
export interface MultivariateTrainMultivariateModelOptionalParams extends OperationOptions {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export {
UnivariateUnivariateChangePointDetectionOptions,
UnivariateUnivariateChangePointDetectionResult,
Versions,
MultivariateResponseError,
UnivariateDetectUnivariateEntireSeriesOptionalParams,
UnivariateDetectUnivariateLastPointOptionalParams,
UnivariateDetectUnivariateChangePointOptionalParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export {
UnivariateUnivariateChangePointDetectionOptions,
UnivariateUnivariateChangePointDetectionResult,
Versions,
MultivariateResponseError,
} from "./models.js";
export {
UnivariateDetectUnivariateEntireSeriesOptionalParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,3 +687,11 @@ export interface UnivariateUnivariateChangePointDetectionResult {

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

/** Error response */
export interface MultivariateResponseError {
Copy link
Member

Choose a reason for hiding this comment

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

why this model is generated?

Copy link
Member

Choose a reason for hiding this comment

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

issue tracked here: Azure/typespec-azure#1587

/** The error code. */
code: string;
/** The message explaining the error reported by the service. */
message: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@
}
},
"x-ms-pageable": {
"nextLinkName": "nextLink"
"nextLinkName": "nextLink",
"itemName": "entries"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"explode": false
}
],
"responses": {
Expand Down Expand Up @@ -414,7 +415,7 @@
}
},
"409": {
"description": "The request conflicts with the current state of the server.",
"description": "The user already exists",
"content": {
"application/json": {
"schema": {
Expand All @@ -424,7 +425,7 @@
}
},
"422": {
"description": "Client error",
"description": "The user is invalid (e.g. forgot to enter email address)",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -464,15 +465,16 @@
"required": true,
"schema": {
"type": "string"
}
},
"explode": false
}
],
"responses": {
"200": {
"description": "The request has succeeded."
},
"422": {
"description": "Client error",
"description": "The user is invalid (e.g. forgot to enter email address)",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -501,7 +503,8 @@
"type": "integer",
"format": "int32",
"default": 50
}
},
"explode": false
},
"TodoItems.PaginationControls.offset": {
"name": "offset",
Expand All @@ -512,7 +515,8 @@
"type": "integer",
"format": "int32",
"default": 0
}
},
"explode": false
}
},
"schemas": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export interface UsersCreate200Response extends HttpResponse {
body: UserCreatedResponseOutput;
}

/** The request conflicts with the current state of the server. */
/** The user already exists */
export interface UsersCreate409Response extends HttpResponse {
status: "409";
body: UserExistsResponseOutput;
}

/** Client error */
/** The user is invalid (e.g. forgot to enter email address) */
export interface UsersCreate422Response extends HttpResponse {
status: "422";
body: InvalidUserResponseOutput;
Expand All @@ -34,7 +34,7 @@ export interface UsersValidate200Response extends HttpResponse {
status: "200";
}

/** Client error */
/** The user is invalid (e.g. forgot to enter email address) */
export interface UsersValidate422Response extends HttpResponse {
status: "422";
body: InvalidUserResponseOutput;
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.37.1",
"@azure-tools/cadl-ranch": "^0.14.5",
"@azure-tools/cadl-ranch-api": "^0.4.6",
"@azure-tools/typespec-autorest": ">=0.45.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.45.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.45.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.45.4 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.46.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.46.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.46.1 <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.59.0 <1.0.0",
"@typespec/http": ">=0.59.0 <1.0.0",
"@typespec/openapi": ">=0.59.0, <1.0.0",
"@typespec/rest": ">=0.59.0 <1.0.0",
"@typespec/compiler": ">=0.60.0 <1.0.0",
"@typespec/http": ">=0.60.0 <1.0.0",
"@typespec/openapi": ">=0.60.0, <1.0.0",
"@typespec/rest": ">=0.60.0 <1.0.0",
"@typespec/ts-http-runtime": "1.0.0-alpha.20240314.2",
"@typespec/versioning": ">=0.59.0 <1.0.0",
"@typespec/versioning": ">=0.60.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.45.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.45.4 <1.0.0",
"@typespec/compiler": ">=0.59.0 <1.0.0",
"@typespec/http": ">=0.59.0 <1.0.0",
"@typespec/rest": ">=0.59.0 <1.0.0",
"@typespec/versioning": ">=0.59.0 <1.0.0"
"@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.46.1 <1.0.0",
"@typespec/compiler": ">=0.60.0 <1.0.0",
"@typespec/http": ">=0.60.0 <1.0.0",
"@typespec/rest": ">=0.60.0 <1.0.0",
"@typespec/versioning": ">=0.60.0 <1.0.0"
},
"dependencies": {
"@azure-tools/rlc-common": "workspace:^0.33.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-ts/src/modular/buildCodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ function emitUnion(
: type.name;
const discriminatorPropertyName = getDiscriminator(context.program, type)
?.propertyName;
const variantTypes = sdkType.values.map((x) => {
const variantTypes = sdkType.variantTypes.map((x) => {
const valueType = getType(context, x.__raw!, { usage });
if (valueType.properties && discriminatorPropertyName) {
valueType.discriminatorValue = valueType.properties.filter(
Expand Down
25 changes: 16 additions & 9 deletions packages/typespec-ts/src/modular/emitSamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { SdkContext } from "../utils/interfaces.js";
import {
SdkClientType,
SdkHttpOperationExample,
SdkHttpParameterExample,
SdkHttpParameterExampleValue,
SdkInitializationType,
SdkServiceMethod,
SdkServiceOperation,
SdkTypeExample
SdkExampleValue
} from "@azure-tools/typespec-client-generator-core";
import {
isAzurePackage,
Expand Down Expand Up @@ -148,7 +148,7 @@ function emitMethodSamples(
returnType: "void",
body: exampleFunctionBody
};
const parameterMap: Record<string, SdkHttpParameterExample> =
const parameterMap: Record<string, SdkHttpParameterExampleValue> =
buildParameterValueMap(example);
const parameters = prepareExampleParameters(
dpgContext,
Expand Down Expand Up @@ -240,7 +240,7 @@ function emitMethodSamples(
}

function buildParameterValueMap(example: SdkHttpOperationExample) {
const parameterMap: Record<string, SdkHttpParameterExample> = {};
const parameterMap: Record<string, SdkHttpParameterExampleValue> = {};
example.parameters.forEach(
(param) =>
(parameterMap[
Expand All @@ -253,7 +253,7 @@ function buildParameterValueMap(example: SdkHttpOperationExample) {
function prepareExampleParameters(
dpgContext: SdkContext,
method: SdkServiceMethod<SdkServiceOperation>,
parameterMap: Record<string, SdkHttpParameterExample>,
parameterMap: Record<string, SdkHttpParameterExampleValue>,
topLevelClient: SdkClientType<SdkServiceOperation>
): ExampleValue[] {
// TODO: blocked by TCGC issue: https://github.com/Azure/typespec-azure/issues/1419
Expand All @@ -270,7 +270,11 @@ function prepareExampleParameters(
let subscriptionIdValue = `"00000000-0000-0000-0000-00000000000"`;
// required parameters
for (const param of method.operation.parameters) {
if (param.optional === true || param.type.kind === "constant") {
if (
param.optional === true ||
param.type.kind === "constant" ||
param.clientDefaultValue
) {
continue;
}

Expand Down Expand Up @@ -346,7 +350,10 @@ function prepareExampleParameters(
// optional parameters
method.operation.parameters
.filter(
(param) => param.optional === true && parameterMap[param.serializedName]
(param) =>
param.optional === true &&
parameterMap[param.serializedName] &&
!param.clientDefaultValue
)
.map((param) => parameterMap[param.serializedName]!)
.forEach((param) => {
Expand Down Expand Up @@ -399,7 +406,7 @@ function getCredentialExampleValue(
return undefined;
}

function getParameterValue(value: SdkTypeExample): string {
function getParameterValue(value: SdkExampleValue): string {
let retValue = `{} as any`;
switch (value.kind) {
case "string": {
Expand All @@ -416,7 +423,7 @@ function getParameterValue(value: SdkTypeExample): string {
case "boolean":
case "number":
case "null":
case "any":
case "unknown":
case "union":
retValue = `${value.value}`;
break;
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-ts/src/utils/credentialUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function getAuthScheme(initialization: SdkInitializationType): HttpAuth[] {
if (kind === "credential") {
authScheme.push(credentialParams.type.scheme);
} else if (kind === "union") {
for (const param of credentialParams.type.values) {
for (const param of credentialParams.type.variantTypes) {
authScheme.push(param.scheme);
}
}
Expand Down
Loading