Skip to content

Commit

Permalink
Upgrade typespec http runtime version to v0.1.0 for unbranded client (#…
Browse files Browse the repository at this point in the history
…2947)

* upgrade typespec http runtime version

* update

* fix ci

* format

* fix ci

* update

---------

Co-authored-by: Mary Gao <[email protected]>
  • Loading branch information
v-jiaodi and MaryGao authored Dec 17, 2024
1 parent b80c904 commit 9e1b744
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 39 deletions.
34 changes: 7 additions & 27 deletions common/config/rush/pnpm-lock.yaml

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

13 changes: 10 additions & 3 deletions packages/rlc-common/src/buildClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,17 @@ export function getClientFactoryBody(
`\${${urlParameter.name}}`
);
});

endpointUrl = `options.endpoint ?? options.baseUrl ?? \`${parsedEndpoint}\``;
if (model.options.flavor !== "azure") {
endpointUrl = `options.endpoint ?? \`${parsedEndpoint}\``;
} else {
endpointUrl = `options.endpoint ?? options.baseUrl ?? \`${parsedEndpoint}\``;
}
} else {
endpointUrl = `options.endpoint ?? options.baseUrl ?? "${endpoint}"`;
if (model.options.flavor !== "azure") {
endpointUrl = `options.endpoint ??"${endpoint}"`;
} else {
endpointUrl = `options.endpoint ?? options.baseUrl ?? "${endpoint}"`;
}
}

if (!model.options.isModularLibrary && !clientPackageName.endsWith("-rest")) {
Expand Down
2 changes: 1 addition & 1 deletion packages/rlc-common/src/helpers/importsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function buildRuntimeImports(flavor?: PackageFlavor): Imports {
commonFallback: {
type: "commonFallback",
specifier: "@typespec/ts-http-runtime",
version: "1.0.0-alpha.20240314.2"
version: "0.1.0"
}
} as Imports;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function buildFlavorlessPackage(config: PackageCommonInfoConfig) {
},
dependencies: {
...commonPackageDependencies,
"@typespec/ts-http-runtime": "1.0.0-alpha.20240314.2"
"@typespec/ts-http-runtime": "0.1.0"
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/rlc-common/test/helpers/importsUtil.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("#buildRuntimeImports", () => {
expect(imports.commonFallback).to.deep.equal({
type: "commonFallback",
specifier: "@typespec/ts-http-runtime",
version: "1.0.0-alpha.20240314.2"
version: "0.1.0"
});
expect(imports.restClient).to.be.undefined;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"dependencies": {
"tslib": "^2.6.2",
"@typespec/ts-http-runtime": "1.0.0-alpha.20240314.2"
"@typespec/ts-http-runtime": "0.1.0"
},
"exports": {
"./package.json": "./package.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export function createOpenAI(
credential: KeyCredential,
options: OpenAIClientOptionalParams = {},
): OpenAIContext {
const endpointUrl =
options.endpoint ?? options.baseUrl ?? `https://api.openai.com/v1`;
const endpointUrl = options.endpoint ?? `https://api.openai.com/v1`;
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
const userAgentInfo = `azsdk-js-openai-non-branded/1.0.0-beta.1`;
const userAgentPrefix = prefixFromOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"dependencies": {
"tslib": "^2.6.2",
"@typespec/ts-http-runtime": "1.0.0-alpha.20240314.2"
"@typespec/ts-http-runtime": "0.1.0"
},
"exports": {
"./package.json": "./package.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@typespec/http": ">=0.63.0 <1.0.0",
"@typespec/openapi": ">=0.63.0, <1.0.0",
"@typespec/rest": ">=0.63.0 <1.0.0",
"@typespec/ts-http-runtime": "1.0.0-alpha.20240314.2",
"@typespec/ts-http-runtime": "0.1.0",
"@typespec/versioning": ">=0.63.0 <1.0.0",
"chai": "^4.3.6",
"chalk": "^4.0.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/typespec-ts/src/modular/helpers/clientHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ export function buildGetClientEndpointParam(
`\${${getClientParameterName(param)}}`
);
}
const endpointUrl = `const endpointUrl = options.endpoint ?? options.baseUrl ?? \`${parameterizedEndpointUrl}\``;
let endpointUrl = "";
if (dpgContext.rlcOptions?.flavor === "azure") {
endpointUrl = `const endpointUrl = options.endpoint ?? options.baseUrl ?? \`${parameterizedEndpointUrl}\``;
} else {
// unbranded does not have the deprecated baseUrl parameter
endpointUrl = `const endpointUrl = options.endpoint ?? \`${parameterizedEndpointUrl}\``;
}
context.addStatements(endpointUrl);
return "endpointUrl";
}
Expand Down

0 comments on commit 9e1b744

Please sign in to comment.