Skip to content

Hierarchy nested client support#3163

Merged
qiaozha merged 31 commits intoAzure:mainfrom
qiaozha:hierarchy-nested-client-support
May 21, 2025
Merged

Hierarchy nested client support#3163
qiaozha merged 31 commits intoAzure:mainfrom
qiaozha:hierarchy-nested-client-support

Conversation

@qiaozha
Copy link
Copy Markdown
Member

@qiaozha qiaozha commented Apr 14, 2025

fixes #2887
fixes #2612

implementation of the hierarchy nested clients. See design doc here

@lirenhe lirenhe requested a review from Copilot May 15, 2025 08:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements hierarchical nested client support across the TypeSpec-TS generator, filtering out individually-initialized children where appropriate and threading a [hierarchy, client] tuple (clientMap) through modular codegen helpers.

  • Introduces InitializedByFlags filtering in getMethodHierarchiesMap and a new getClientHierarchyMap utility.
  • Updates getModularClientOptions to accept the [hierarchy, client] tuple and adjust subfolder logic.
  • Refactors all modular emit and build helpers (e.g., operations, subpath indices, client context) to use the new tuple signature.
  • Adds a nested-client test configuration and spec under packages/typespec-test.

Reviewed Changes

Copilot reviewed 62 out of 63 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/typespec-ts/src/utils/operationUtil.ts Filter out individually initialized nested clients in method queue
packages/typespec-ts/src/utils/clientUtils.ts Added getClientHierarchyMap, updated getModularClientOptions
packages/typespec-ts/src/modular/* Propagate [hierarchy, client] through emit/build helper signatures
packages/typespec-ts/src/index.ts Switch emitter flow to iterate getClientHierarchyMap tuples
packages/typespec-test/test/nestedClient/* Add nested client test config and TypeSpec spec
.vscode/settings.json Add formatting settings for TypeSpec files
Files not reviewed (1)
  • common/config/rush/pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (3)

packages/typespec-ts/src/utils/operationUtil.ts:568

  • [nitpick] The filtering logic for child clients based on InitializedByFlags.Individually is duplicated later in this function. Extract it into a helper (e.g., getNonIndependentChildren) to reduce duplication and improve readability.
client.children?.filter((p) => {

packages/typespec-ts/src/modular/buildProjectFiles.ts:38

  • [nitpick] Destructure the tuple directly for clarity. For example:
for (const [hierarchy, client] of clientMap) {
  // use `client` directly
}
for (const flattenedClient of clientMap) {

packages/typespec-test/test/nestedClient/spec/main.tsp:1

  • You’ve added a nested client spec, but there’s no assertion or test verifying the actual generated code for nested clients. Consider adding an end-to-end test that inspects the generated folder structure and client hierarchy to catch any regressions.
import "@typespec/http";

Comment thread packages/typespec-ts/src/utils/clientUtils.ts Outdated
Comment thread packages/typespec-ts/src/utils/clientUtils.ts Outdated
@qiaozha qiaozha requested a review from lirenhe May 16, 2025 01:48
Comment thread packages/typespec-test/test/nestedClient/spec/client.tsp
Comment thread packages/typespec-ts/src/modular/buildProjectFiles.ts
Copy link
Copy Markdown
Member

@MaryGao MaryGao left a comment

Choose a reason for hiding this comment

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

Approved and please resolve any left small comments!

@qiaozha qiaozha enabled auto-merge (squash) May 20, 2025 11:55
@qiaozha qiaozha merged commit 8b914fe into Azure:main May 21, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientInitialization/ParamAlias Implementation Support hierarchy nested client like storage blob

5 participants