Azure / autorest.typescript

Extension for AutoRest (https://github.com/Azure/autorest) that generates TypeScript code. The transpiled javascript code is isomorphic. It can be run in browser and in node.js environment.
MIT License
179 stars 75 forks source link

Respect client level parameter in api client factory function #2809

Open qiaozha opened 2 months ago

qiaozha commented 2 months ago

Currently, if we have client level lifted parameter, our interface would be like Modular client constructor

export class NetworkAnalyticsClient {
  constructor(
    credential: TokenCredential,
    subscriptionId: string, // // subscriptionId will be used in buildOperationGroups or buildOperation.
    options: NetworkAnalyticsClientOptionalParams = {},
  ) {}
}

API layer client factory functions

export function createNetworkAnalytics(
  credential: TokenCredential,
  options: NetworkAnalyticsClientOptionalParams = {},
): NetworkAnalyticsContext;

In api layer, we didn't provide it as part of the client factory signature, this is inconsistent between the modular client layer and api layer, which makes sense before, because we were just importing NetworkAnalyticsContext from the rest api, and this doesn't make sense to RLC layer, but since we have decoupled the rlc library from Modular and generating our own context in modular, the consistency between modular client layer and api layer is something we could consider.

export interface NetworkAnalyticsContext extends Client {
  subscriptionId: string;
}
export function createNetworkAnalytics(
  credential: TokenCredential,
  subscriptionId: string,
  options: NetworkAnalyticsClientOptionalParams = {},
): NetworkAnalyticsContext;