From dd21eaaa0c3515eefbc8028c5565a936207dfdfe Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 15:30:21 -0500 Subject: [PATCH 01/15] chore(typespec-ts): remove dead rlc-common code (static/, karma config) The static/ helpers (paginate-content, polling-content, serialize-helper, sample-template) and the Karma config builder are leftovers from the removed RLC generator. They are not imported or invoked anywhere in the Modular emit path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/src/rlc-common/index.ts | 1 - .../src/rlc-common/static/paginate-content.ts | 345 ------------------ .../src/rlc-common/static/polling-content.ts | 225 ------------ .../src/rlc-common/static/sample-template.ts | 56 --- .../src/rlc-common/static/serialize-helper.ts | 34 -- .../src/rlc-common/test/build-karma-config.ts | 12 - 6 files changed, 673 deletions(-) delete mode 100644 packages/typespec-ts/src/rlc-common/static/paginate-content.ts delete mode 100644 packages/typespec-ts/src/rlc-common/static/polling-content.ts delete mode 100644 packages/typespec-ts/src/rlc-common/static/sample-template.ts delete mode 100644 packages/typespec-ts/src/rlc-common/static/serialize-helper.ts delete mode 100644 packages/typespec-ts/src/rlc-common/test/build-karma-config.ts diff --git a/packages/typespec-ts/src/rlc-common/index.ts b/packages/typespec-ts/src/rlc-common/index.ts index 74088f4a4e..6ca9a42143 100644 --- a/packages/typespec-ts/src/rlc-common/index.ts +++ b/packages/typespec-ts/src/rlc-common/index.ts @@ -19,7 +19,6 @@ export * from "./metadata/build-test-config.js"; export * from "./metadata/build-ts-config.js"; export * from "./metadata/build-vitest-config.js"; export * from "./metadata/build-warp-config.js"; -export * from "./test/build-karma-config.js"; export * from "./test/build-recorded-client.js"; export * from "./test/build-sample-test.js"; export * from "./test/build-snippets.js"; diff --git a/packages/typespec-ts/src/rlc-common/static/paginate-content.ts b/packages/typespec-ts/src/rlc-common/static/paginate-content.ts deleted file mode 100644 index ba0af9d93a..0000000000 --- a/packages/typespec-ts/src/rlc-common/static/paginate-content.ts +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -export const paginateContent = ` -import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; -import { createRestError } from "@azure-rest/core-client"; - -/** - * returns an async iterator that iterates over results. It also has a \`byPage\` - * method that returns pages of items at once. - * - * @param pagedResult - an object that specifies how to get pages. - * @returns a paged async iterator that iterates over results. - */ -function getPagedAsyncIterator< - TElement, - TPage = TElement[], - TPageSettings = PageSettings, - TLink = string, ->( - pagedResult: PagedResult, -): PagedAsyncIterableIterator { - const iter = getItemAsyncIterator(pagedResult); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: - pagedResult?.byPage ?? - (((settings?: PageSettings) => { - const { continuationToken } = settings ?? {}; - return getPageAsyncIterator(pagedResult, { - pageLink: continuationToken as unknown as TLink | undefined, - }); - }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator), - }; -} - -async function* getItemAsyncIterator( - pagedResult: PagedResult, -): AsyncIterableIterator { - const pages = getPageAsyncIterator(pagedResult); - const firstVal = await pages.next(); - // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is - if (!Array.isArray(firstVal.value)) { - // can extract elements from this page - const { toElements } = pagedResult; - if (toElements) { - yield* toElements(firstVal.value) as TElement[]; - for await (const page of pages) { - yield* toElements(page) as TElement[]; - } - } else { - yield firstVal.value; - // \`pages\` is of type \`AsyncIterableIterator\` but TPage = TElement in this case - yield* pages as unknown as AsyncIterableIterator; - } - } else { - yield* firstVal.value; - for await (const page of pages) { - // pages is of type \`AsyncIterableIterator\` so \`page\` is of type \`TPage\`. In this branch, - // it must be the case that \`TPage = TElement[]\` - yield* page as unknown as TElement[]; - } - } -} - -async function* getPageAsyncIterator( - pagedResult: PagedResult, - options: { - pageLink?: TLink; - } = {}, -): AsyncIterableIterator { - const { pageLink } = options; - let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); - if (!response) { - return; - } - yield response.page; - while (response.nextPageLink) { - response = await pagedResult.getPage(response.nextPageLink); - if (!response) { - return; - } - yield response.page; - } -} - -/** - * An interface that tracks the settings for paged iteration - */ -export interface PageSettings { - /** - * The token that keeps track of where to continue the iterator - */ - continuationToken?: string; -} - -/** - * An interface that allows async iterable iteration both to completion and by page. - */ -export interface PagedAsyncIterableIterator< - TElement, - TPage = TElement[], - TPageSettings = PageSettings, -> { - /** - * The next method, part of the iteration protocol - */ - next(): Promise>; - /** - * The connection to the async iterator, part of the iteration protocol - */ - [Symbol.asyncIterator](): PagedAsyncIterableIterator; - /** - * Return an AsyncIterableIterator that works a page at a time - */ - byPage: (settings?: TPageSettings) => AsyncIterableIterator; -} - -/** - * An interface that describes how to communicate with the service. - */ -interface PagedResult { - /** - * Link to the first page of results. - */ - firstPageLink: TLink; - /** - * A method that returns a page of results. - */ - getPage: ( - pageLink: TLink, - ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; - /** - * a function to implement the \`byPage\` method on the paged async iterator. - */ - byPage?: (settings?: TPageSettings) => AsyncIterableIterator; - - /** - * A function to extract elements from a page. - */ - toElements?: (page: TPage) => unknown[]; -} - -/** - * Helper type to extract the type of an array - */ -export type GetArrayType = T extends Array ? TData : never; - -/** - * The type of a custom function that defines how to get a page and a link to the next one if any. - */ -export type GetPage = ( - pageLink: string, -) => Promise<{ - page: TPage; - nextPageLink?: string; -}>; - -/** - * Options for the paging helper - */ -export interface PagingOptions { - /** - * Custom function to extract pagination details for crating the PagedAsyncIterableIterator - */ - customGetPage?: GetPage[]> -} - -/** - * Helper type to infer the Type of the paged elements from the response type - * This type is generated based on the swagger information for x-ms-pageable - * specifically on the itemName property which indicates the property of the response - * where the page items are found. The default value is \`value\`. - * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter - */ - export type PaginateReturn = TResult extends {{#each itemNames}} - { - - body: { {{this}}?: infer TPage } - -} {{#if @last }}{{else}} | {{/if}} -{{/each}} - ? GetArrayType - : Array; - - /** - * Helper to paginate results from an initial response that follows the specification of Autorest \`x-ms-pageable\` extension - * @param client - Client to use for sending the next page requests - * @param initialResponse - Initial response containing the nextLink and current page of elements - * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results - * @returns - PagedAsyncIterableIterator to iterate the elements - */ - export function paginate( - client: Client, - initialResponse: TResponse, - options: PagingOptions = {} - ): PagedAsyncIterableIterator> { - // Extract element type from initial response - type TElement = PaginateReturn; - let firstRun = true; - {{#if isComplexPaging}} - // We need to check the response for success before trying to inspect it looking for - // the properties to use for nextLink and itemName - checkPagingRequest(initialResponse); - const { itemName, nextLinkName } = getPaginationProperties(initialResponse); - {{else}} - const itemName = {{ quoteWrap itemNames }}; - const nextLinkName = {{quoteWrap nextLinkNames}}; - {{/if}} - const { customGetPage } = options; - const pagedResult: PagedResult = { - firstPageLink: "", - getPage: - typeof customGetPage === "function" - ? customGetPage - : async (pageLink: string) => { - const result = firstRun - ? initialResponse - : await client.pathUnchecked(pageLink).get(); - firstRun = false; - checkPagingRequest(result); - const nextLink = getNextLink(result.body, nextLinkName); - const values = getElements(result.body, itemName); - return { - page: values, - nextPageLink: nextLink - }; - } - }; - - return getPagedAsyncIterator(pagedResult); -} - -/** - * Gets for the value of nextLink in the body - */ -function getNextLink(body: unknown, nextLinkName?: string): string | undefined { - if (!nextLinkName) { - return undefined; - } - - const nextLink = (body as Record)[nextLinkName]; - - if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error( - \`Body Property \${nextLinkName} should be a string or undefined\` - ); - } - - return nextLink; -} - -/** - * Gets the elements of the current request in the body. - */ -function getElements(body: unknown, itemName: string): T[] { - const value = (body as Record)[itemName] as T[]; - - // value has to be an array according to the x-ms-pageable extension. - // The fact that this must be an array is used above to calculate the - // type of elements in the page in PaginateReturn - if (!Array.isArray(value)) { - throw new Error( - \`Couldn't paginate response\\n Body doesn't contain an array property with name: \${itemName}\` - ); - } - - return value ?? []; -} - -/** - * Checks if a request failed - */ -function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = [ - "200", - "201", - "202", - "203", - "204", - "205", - "206", - "207", - "208", - "226" - ]; - if (!Http2xxStatusCodes.includes(response.status)) { - throw createRestError( - \`Pagination failed with unexpected statusCode \${response.status}\`, - response - ); - } -} - -{{#if isComplexPaging}} -/** - * Extracts the itemName and nextLinkName from the initial response to use them for pagination - */ -function getPaginationProperties(initialResponse: PathUncheckedResponse) { - // Build a set with the passed custom nextLinkNames - const nextLinkNames = new Set([{{ quoteWrap nextLinkNames }}]); - - // Build a set with the passed custom set of itemNames - const itemNames = new Set([{{ quoteWrap itemNames }}]); - - let nextLinkName: string | undefined; - let itemName: string | undefined; - - for (const name of nextLinkNames) { - const nextLink = (initialResponse.body as Record)[ - name - ] as string; - if (nextLink) { - nextLinkName = name; - break; - } - } - - for (const name of itemNames) { - const item = (initialResponse.body as Record)[ - name - ] as string; - if (item) { - itemName = name; - break; - } - } - - if (!itemName) { - throw new Error( - \`Couldn't paginate response\\n Body doesn't contain an array property with name: \${[ - ...itemNames - ].join(" OR ")}\` - ); - } - - return { itemName, nextLinkName }; -} -{{/if}} -`; diff --git a/packages/typespec-ts/src/rlc-common/static/polling-content.ts b/packages/typespec-ts/src/rlc-common/static/polling-content.ts deleted file mode 100644 index 737d4e0711..0000000000 --- a/packages/typespec-ts/src/rlc-common/static/polling-content.ts +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -export const pollingContent = ` -import type { Client, HttpResponse } from "@azure-rest/core-client"; -import type { AbortSignalLike } from "@azure/abort-controller"; -import type { - CancelOnProgress, - CreateHttpPollerOptions, - RunningOperation, - OperationResponse, - OperationState, -} from "@azure/core-lro"; - import { createHttpPoller } from "@azure/core-lro"; -{{#if clientOverload}} -import type { - {{#each importedResponses}} - {{this}}, - {{/each}} -} from "./responses.js"; -{{/if}} - -/** - * A simple poller that can be used to poll a long running operation. - */ -export interface SimplePollerLike< - TState extends OperationState, - TResult -> { - /** - * Returns true if the poller has finished polling. - */ - isDone(): boolean; - /** - * Returns the state of the operation. - */ - getOperationState(): TState; - /** - * Returns the result value of the operation, - * regardless of the state of the poller. - * It can return undefined or an incomplete form of the final TResult value - * depending on the implementation. - */ - getResult(): TResult | undefined; - /** - * Returns a promise that will resolve once a single polling request finishes. - * It does this by calling the update method of the Poller's operation. - */ - poll(options?: { abortSignal?: AbortSignalLike }): Promise; - /** - * Returns a promise that will resolve once the underlying operation is completed. - */ - pollUntilDone(pollOptions?: { - abortSignal?: AbortSignalLike; - }): Promise; - /** - * Invokes the provided callback after each polling is completed, - * sending the current state of the poller's operation. - * - * It returns a method that can be used to stop receiving updates on the given callback function. - */ - onProgress(callback: (state: TState) => void): CancelOnProgress; - - /** - * Returns a promise that could be used for serialized version of the poller's operation - * by invoking the operation's serialize method. - */ - serialize(): Promise; - - /** - * Wait the poller to be submitted. - */ - submitted(): Promise; - - /** - * Returns a string representation of the poller's operation. Similar to serialize but returns a string. - * @deprecated Use serialize() instead. - */ - toString(): string; - - /** - * Stops the poller from continuing to poll. Please note this will only stop the client-side polling - * @deprecated Use abortSignal to stop polling instead. - */ - stopPolling(): void; - - /** - * Returns true if the poller is stopped. - * @deprecated Use abortSignal status to track this instead. - */ - isStopped(): boolean; -} - -/** - * Helper function that builds a Poller object to help polling a long running operation. - * @param client - Client to use for sending the request to get additional pages. - * @param initialResponse - The initial response. - * @param options - Options to set a resume state or custom polling interval. - * @returns - A poller object to poll for operation state updates and eventually get the final response. - */ -{{#if clientOverload}} -{{#each overloadMap}} -export async function getLongRunningPoller< - TResult extends {{ this.finalResponses }} ->( - client: Client, - initialResponse: {{ this.initialResponses }}, - options?: CreateHttpPollerOptions> -): Promise, TResult>>; -{{/each}} -{{/if}} -export async function getLongRunningPoller( - client: Client, - initialResponse: TResult, - options: CreateHttpPollerOptions> = {} - ): Promise, TResult>> { - const abortController = new AbortController(); - const poller: RunningOperation = { - sendInitialRequest: async () => { - // In the case of Rest Clients we are building the LRO poller object from a response that's the reason - // we are not triggering the initial request here, just extracting the information from the - // response we were provided. - return getLroResponse(initialResponse); - }, - sendPollRequest: async ( - path: string, - pollOptions?: { abortSignal?: AbortSignalLike } - ) => { - // This is the callback that is going to be called to poll the service - // to get the latest status. We use the client provided and the polling path - // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location - // depending on the lro pattern that the service implements. If non is provided we default to the initial path. - function abortListener(): void { - abortController.abort(); - } - const inputAbortSignal = pollOptions?.abortSignal; - const abortSignal = abortController.signal; - if (inputAbortSignal?.aborted) { - abortController.abort(); - } else if (!abortSignal.aborted) { - inputAbortSignal?.addEventListener("abort", abortListener, { - once: true - }); - } - let response; - try { - response = await client - .pathUnchecked(path ?? initialResponse.request.url) - .get({ abortSignal }); - } finally { - inputAbortSignal?.removeEventListener("abort", abortListener); - } - const lroResponse = getLroResponse(response as TResult); - lroResponse.rawResponse.headers["x-ms-original-url"] = - initialResponse.request.url; - return lroResponse; - } - }; - - options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; - const httpPoller = createHttpPoller(poller, options); - const simplePoller: SimplePollerLike, TResult> = { - isDone() { - return httpPoller.isDone; - }, - isStopped() { - return abortController.signal.aborted; - }, - getOperationState() { - if (!httpPoller.operationState) { - throw new Error( - "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState()." - ); - } - return httpPoller.operationState; - }, - getResult() { - return httpPoller.result; - }, - toString() { - if (!httpPoller.operationState) { - throw new Error( - "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState()." - ); - } - return JSON.stringify({ - state: httpPoller.operationState - }); - }, - stopPolling() { - abortController.abort(); - }, - onProgress: httpPoller.onProgress, - poll: httpPoller.poll, - pollUntilDone: httpPoller.pollUntilDone, - serialize: httpPoller.serialize, - submitted: httpPoller.submitted - }; - return simplePoller; -} - -/** - * Converts a Rest Client response to a response that the LRO implementation understands - * @param response - a rest client http response - * @returns - An LRO response that the LRO implementation understands - */ -function getLroResponse( - response: TResult -): OperationResponse { - if (Number.isNaN(response.status)) { - throw new TypeError( - \`Status code of the response is not a number. Value: \${response.status}\` - ); - } - - return { - flatResponse: response, - rawResponse: { - ...response, - statusCode: Number.parseInt(response.status), - body: response.body - } - }; -} -`; diff --git a/packages/typespec-ts/src/rlc-common/static/sample-template.ts b/packages/typespec-ts/src/rlc-common/static/sample-template.ts deleted file mode 100644 index 85437dbd5f..0000000000 --- a/packages/typespec-ts/src/rlc-common/static/sample-template.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -export const sampleTemplate = ` -{{#each importedTypes}} -{{this}} -{{/each}} -import "dotenv/config"; - -{{#each samples}} -/** - * This sample demonstrates how to {{this.description}} - * - * @summary {{this.description}} - {{#if this.originalFileLocation}} - * x-ms-original-file: {{this.originalFileLocation}} - {{/if}} - */ -async function {{name}}(): Promise { - {{#each this.clientParamAssignments}} - {{this}} - {{/each}} - const client = {{this.defaultFactoryName}}({{this.clientParamNames}}); - {{#each this.pathParamAssignments}} - {{this}} - {{/each}} - {{#each this.methodParamAssignments}} - {{this}} - {{/each}} - {{#if this.isPaging}} - const initialResponse = await client.path({{this.pathParamNames}}).{{method}}({{methodParamNames}}); - const pageData = paginate(client, initialResponse); - const result = []; - for await (const item of pageData) { - result.push(item); - } - {{else if this.isLRO}} - const initialResponse ={{#unless this.useLegacyLro}} await{{/unless}} client.path({{this.pathParamNames}}).{{method}}({{methodParamNames}}); - const poller = await getLongRunningPoller(client, initialResponse); - const result = await poller.pollUntilDone(); - {{else}} - const result = await client.path({{this.pathParamNames}}).{{method}}({{methodParamNames}}); - {{/if}} - console.log(result); -} - -{{/each}} - -async function main(): Promise { -{{#each samples}} - await {{this.name}}(); -{{/each}} -} - -main().catch(console.error); -`; diff --git a/packages/typespec-ts/src/rlc-common/static/serialize-helper.ts b/packages/typespec-ts/src/rlc-common/static/serialize-helper.ts deleted file mode 100644 index 1e9b7ca8c0..0000000000 --- a/packages/typespec-ts/src/rlc-common/static/serialize-helper.ts +++ /dev/null @@ -1,34 +0,0 @@ -export const buildMultiCollectionContent = ` -export function buildMultiCollection( - items: string[], - parameterName: string -): string { - return items - .map((item, index) => { - if (index === 0) { - return item; - } - return \`\${parameterName}=\${item}\`; - }) - .join("&"); -}`; - -export const buildPipeCollectionContent = ` -export function buildPipeCollection(items: string[] | number[]): string { - return items.join("|"); -}`; - -export const buildSsvCollectionContent = ` -export function buildSsvCollection(items: string[] | number[]): string { - return items.join(" "); -}`; - -export const buildTsvCollectionContent = ` -export function buildTsvCollection(items: string[] | number[]): string { - return items.join("\\t"); -}`; - -export const buildCsvCollectionContent = ` -export function buildCsvCollection(items: string[] | number[]): string { - return items.join(","); -}`; diff --git a/packages/typespec-ts/src/rlc-common/test/build-karma-config.ts b/packages/typespec-ts/src/rlc-common/test/build-karma-config.ts deleted file mode 100644 index 8e33af45cd..0000000000 --- a/packages/typespec-ts/src/rlc-common/test/build-karma-config.ts +++ /dev/null @@ -1,12 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore: to fix the handlebars issue -import hbs from "handlebars"; -import { RLCModel } from "../interfaces.js"; -import { karmaConfig } from "./template.js"; - -export function buildKarmaConfigFile(_model: RLCModel) { - return { - path: "karma.conf.js", - content: hbs.compile(karmaConfig, { noEscape: true })({}), - }; -} From 3f1b19732cfeb32841993773f21f2699149e6ee9 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 15:53:50 -0500 Subject: [PATCH 02/15] refactor(typespec-ts): relocate rlc-common code into logical homes Move the former rlc-common module's live code out of the vestigial rlc-common/ folder: naming/model helpers to src/utils, the client model interfaces to src/interfaces.ts, and the metadata/test scaffolding builders to src/metadata. Drop the barrel; callers import from the new homes directly. No symbol renames or behavior change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../src/framework/hooks/sdk-types.ts | 2 +- packages/typespec-ts/src/index.ts | 48 +++++++------------ .../src/{rlc-common => }/interfaces.ts | 0 packages/typespec-ts/src/lib.ts | 2 +- packages/typespec-ts/src/meta-tree.ts | 2 +- .../metadata/build-api-extractor-config.ts | 0 .../metadata/build-changelog-file.ts | 0 .../metadata/build-es-lint-config.ts | 0 .../metadata/build-license-file.ts | 0 .../metadata/build-package-file.ts | 2 +- .../metadata/build-readme-file.ts | 4 +- .../metadata/build-sample-env-file.ts | 0 .../metadata/build-test-config.ts | 0 .../metadata/build-ts-config.ts | 0 .../metadata/build-vitest-config.ts | 0 .../metadata/build-warp-config.ts | 0 .../package-json/azure-package-common.ts | 0 .../build-azure-monorepo-package.ts | 0 .../metadata/package-json/package-common.ts | 0 .../test/build-recorded-client.ts | 2 +- .../test/build-sample-test.ts | 2 +- .../test/build-snippets.ts | 4 +- .../{rlc-common => metadata}/test/template.ts | 0 .../src/{rlc-common => }/metadata/utils.ts | 0 .../src/modular/build-classical-client.ts | 2 +- .../build-classical-operation-groups.ts | 2 +- .../src/modular/build-client-context.ts | 2 +- .../src/modular/build-operations.ts | 2 +- .../src/modular/build-project-files.ts | 3 +- .../src/modular/build-restore-poller.ts | 2 +- .../src/modular/build-root-index.ts | 2 +- .../src/modular/emit-models-options.ts | 2 +- .../typespec-ts/src/modular/emit-models.ts | 2 +- .../typespec-ts/src/modular/emit-samples.ts | 2 +- .../typespec-ts/src/modular/emit-tests.ts | 2 +- .../helpers/classical-operation-helpers.ts | 2 +- .../src/modular/helpers/client-helpers.ts | 2 +- .../modular/helpers/example-value-helpers.ts | 2 +- .../src/modular/helpers/naming-helpers.ts | 2 +- .../src/modular/helpers/operation-helpers.ts | 2 +- .../src/modular/helpers/type-helpers.ts | 2 +- .../typespec-ts/src/modular/interfaces.ts | 2 +- .../build-deserializer-function.ts | 2 +- .../build-serializer-function.ts | 2 +- .../build-xml-serializer-function.ts | 2 +- .../type-expressions/get-type-expression.ts | 2 +- packages/typespec-ts/src/rlc-common/index.ts | 24 ---------- .../transform/transform-api-version-info.ts | 10 +--- .../transform-helper-function-details.ts | 2 +- .../src/transform/transform-parameters.ts | 11 +---- .../src/transform/transform-paths.ts | 11 +---- .../src/transform/transform-responses.ts | 11 +---- .../src/transform/transform-schemas.ts | 2 +- .../src/transform/transform-telemetry-info.ts | 2 +- .../typespec-ts/src/transform/transform.ts | 19 ++------ .../src/transform/transfrom-rlc-options.ts | 10 +--- .../helpers => utils}/api-version-util.ts | 0 .../typespec-ts/src/utils/client-utils.ts | 2 +- .../src/utils/cross-language-def.ts | 2 +- packages/typespec-ts/src/utils/emit-util.ts | 2 +- .../helpers => utils}/imports-util.ts | 0 packages/typespec-ts/src/utils/interfaces.ts | 2 +- packages/typespec-ts/src/utils/model-utils.ts | 13 ++--- .../helpers => utils}/name-constructors.ts | 0 .../helpers => utils}/name-utils.ts | 0 .../helpers => utils}/operation-helpers.ts | 0 .../typespec-ts/src/utils/operation-util.ts | 15 ++---- .../typespec-ts/src/utils/parameter-utils.ts | 3 +- .../helpers => utils}/schema-helpers.ts | 0 .../helpers => utils}/type-util.ts | 0 .../assets/static-helpers/platform-import.ts | 2 +- .../rlc-common/helpers/imports-util.test.ts | 2 +- .../rlc-common/helpers/name-utils.test.ts | 2 +- .../unit/rlc-common/helpers/type-util.test.ts | 2 +- .../rlc-common/integration/mock-helper.ts | 4 +- .../integration/package-json.test.ts | 2 +- .../rlc-common/integration/snippets.test.ts | 2 +- .../integration/vitest-config.test.ts | 2 +- .../integration/warp-config.test.ts | 2 +- packages/typespec-ts/test/util/emit-util.ts | 2 +- 80 files changed, 87 insertions(+), 189 deletions(-) rename packages/typespec-ts/src/{rlc-common => }/interfaces.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-api-extractor-config.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-changelog-file.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-es-lint-config.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-license-file.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-package-file.ts (98%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-readme-file.ts (99%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-sample-env-file.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-test-config.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-ts-config.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-vitest-config.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/build-warp-config.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/package-json/azure-package-common.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/package-json/build-azure-monorepo-package.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/package-json/package-common.ts (100%) rename packages/typespec-ts/src/{rlc-common => metadata}/test/build-recorded-client.ts (90%) rename packages/typespec-ts/src/{rlc-common => metadata}/test/build-sample-test.ts (88%) rename packages/typespec-ts/src/{rlc-common => metadata}/test/build-snippets.ts (87%) rename packages/typespec-ts/src/{rlc-common => metadata}/test/template.ts (100%) rename packages/typespec-ts/src/{rlc-common => }/metadata/utils.ts (100%) delete mode 100644 packages/typespec-ts/src/rlc-common/index.ts rename packages/typespec-ts/src/{rlc-common/helpers => utils}/api-version-util.ts (100%) rename packages/typespec-ts/src/{rlc-common/helpers => utils}/imports-util.ts (100%) rename packages/typespec-ts/src/{rlc-common/helpers => utils}/name-constructors.ts (100%) rename packages/typespec-ts/src/{rlc-common/helpers => utils}/name-utils.ts (100%) rename packages/typespec-ts/src/{rlc-common/helpers => utils}/operation-helpers.ts (100%) rename packages/typespec-ts/src/{rlc-common/helpers => utils}/schema-helpers.ts (100%) rename packages/typespec-ts/src/{rlc-common/helpers => utils}/type-util.ts (100%) diff --git a/packages/typespec-ts/src/framework/hooks/sdk-types.ts b/packages/typespec-ts/src/framework/hooks/sdk-types.ts index c7b48622f6..97647a6231 100644 --- a/packages/typespec-ts/src/framework/hooks/sdk-types.ts +++ b/packages/typespec-ts/src/framework/hooks/sdk-types.ts @@ -14,8 +14,8 @@ import { reportDiagnostic } from "../../lib.js"; import { visitPackageTypes } from "../../modular/emit-models.js"; import { getAllAncestors, getAllProperties } from "../../modular/helpers/operation-helpers.js"; import { normalizeModelPropertyName } from "../../modular/type-expressions/get-type-expression.js"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; export const emitQueue: Set = new Set(); export const flattenPropertyModelMap: Map = new Map< diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index 469b215404..a07a487b92 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -31,37 +31,6 @@ import { UrlTemplateHelpers, XmlHelpers, } from "./modular/static-helpers-metadata.js"; -import { - RLCModel, - RLCOptions, - buildApiExtractorConfig, - buildChangelogFile, - buildEsLintConfig, - buildLicenseFile, - buildPackageFile, - buildReadmeFile, - buildRecordedClientFile, - buildSampleEnvFile, - buildSampleTest, - buildSnippets, - buildTestBrowserTsConfig, - buildTestNodeTsConfig, - buildTsConfig, - buildTsLintConfig, - buildTsSampleConfig, - buildTsSnippetsConfig, - buildTsSrcBrowserConfig, - buildTsSrcCjsConfig, - buildTsSrcEsmConfig, - buildTsSrcReactNativeConfig, - buildVitestConfig, - buildWarpConfig, - getClientName, - hasClientNameChanged, - hasUnexpectedHelper, - updatePackageFile, - updateReadmeFile, -} from "./rlc-common/index.js"; import { emitContentByBuilder } from "./utils/emit-util.js"; import { clearDirectory, emptyDir, pathExists } from "./utils/file-system-utils.js"; import { GenerationDirDetail, SdkContext } from "./utils/interfaces.js"; @@ -101,6 +70,23 @@ import { getRLCClients, } from "./utils/client-utils.js"; import { generateCrossLanguageDefinitionFile } from "./utils/cross-language-def.js"; +import { RLCModel, RLCOptions } from "./interfaces.js"; +import { buildApiExtractorConfig } from "./metadata/build-api-extractor-config.js"; +import { buildChangelogFile } from "./metadata/build-changelog-file.js"; +import { buildEsLintConfig } from "./metadata/build-es-lint-config.js"; +import { buildLicenseFile } from "./metadata/build-license-file.js"; +import { buildPackageFile, updatePackageFile } from "./metadata/build-package-file.js"; +import { buildReadmeFile, hasClientNameChanged, updateReadmeFile } from "./metadata/build-readme-file.js"; +import { buildRecordedClientFile } from "./metadata/test/build-recorded-client.js"; +import { buildSampleEnvFile } from "./metadata/build-sample-env-file.js"; +import { buildSampleTest } from "./metadata/test/build-sample-test.js"; +import { buildSnippets } from "./metadata/test/build-snippets.js"; +import { buildTestBrowserTsConfig, buildTestNodeTsConfig } from "./metadata/build-test-config.js"; +import { buildTsConfig, buildTsLintConfig, buildTsSampleConfig, buildTsSnippetsConfig, buildTsSrcBrowserConfig, buildTsSrcCjsConfig, buildTsSrcEsmConfig, buildTsSrcReactNativeConfig } from "./metadata/build-ts-config.js"; +import { buildVitestConfig } from "./metadata/build-vitest-config.js"; +import { buildWarpConfig } from "./metadata/build-warp-config.js"; +import { getClientName } from "./utils/name-constructors.js"; +import { hasUnexpectedHelper } from "./utils/operation-helpers.js"; export * from "./lib.js"; diff --git a/packages/typespec-ts/src/rlc-common/interfaces.ts b/packages/typespec-ts/src/interfaces.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/interfaces.ts rename to packages/typespec-ts/src/interfaces.ts diff --git a/packages/typespec-ts/src/lib.ts b/packages/typespec-ts/src/lib.ts index f0232fa342..7429fa71f3 100644 --- a/packages/typespec-ts/src/lib.ts +++ b/packages/typespec-ts/src/lib.ts @@ -3,7 +3,7 @@ import { createTypeSpecLibrary, JSONSchemaType, paramMessage } from "@typespec/compiler"; import { Options } from "prettier"; -import { PackageDetails } from "./rlc-common/index.js"; +import { PackageDetails } from "./interfaces.js"; export interface EmitterOptions { /** diff --git a/packages/typespec-ts/src/meta-tree.ts b/packages/typespec-ts/src/meta-tree.ts index cdcb6cff47..97129a3ab2 100644 --- a/packages/typespec-ts/src/meta-tree.ts +++ b/packages/typespec-ts/src/meta-tree.ts @@ -1,5 +1,5 @@ import { Type } from "@typespec/compiler"; -import { Schema as RlcType } from "./rlc-common/index.js"; +import { Schema as RlcType } from "./interfaces.js"; export interface RlcTypeMetadata { rlcType: RlcType; diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-api-extractor-config.ts b/packages/typespec-ts/src/metadata/build-api-extractor-config.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-api-extractor-config.ts rename to packages/typespec-ts/src/metadata/build-api-extractor-config.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-changelog-file.ts b/packages/typespec-ts/src/metadata/build-changelog-file.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-changelog-file.ts rename to packages/typespec-ts/src/metadata/build-changelog-file.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-es-lint-config.ts b/packages/typespec-ts/src/metadata/build-es-lint-config.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-es-lint-config.ts rename to packages/typespec-ts/src/metadata/build-es-lint-config.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-license-file.ts b/packages/typespec-ts/src/metadata/build-license-file.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-license-file.ts rename to packages/typespec-ts/src/metadata/build-license-file.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-package-file.ts b/packages/typespec-ts/src/metadata/build-package-file.ts similarity index 98% rename from packages/typespec-ts/src/rlc-common/metadata/build-package-file.ts rename to packages/typespec-ts/src/metadata/build-package-file.ts index 34dd7f0df7..ff8be9653a 100644 --- a/packages/typespec-ts/src/rlc-common/metadata/build-package-file.ts +++ b/packages/typespec-ts/src/metadata/build-package-file.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { Project, SourceFile } from "ts-morph"; -import { hasPollingOperations } from "../helpers/operation-helpers.js"; +import { hasPollingOperations } from "../utils/operation-helpers.js"; import { RLCModel } from "../interfaces.js"; import { buildAzureMonorepoPackage } from "./package-json/build-azure-monorepo-package.js"; import { PackageCommonInfoConfig, resolveWarpExports } from "./package-json/package-common.js"; diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-readme-file.ts b/packages/typespec-ts/src/metadata/build-readme-file.ts similarity index 99% rename from packages/typespec-ts/src/rlc-common/metadata/build-readme-file.ts rename to packages/typespec-ts/src/metadata/build-readme-file.ts index 09fa65e83f..4fcf02114f 100644 --- a/packages/typespec-ts/src/rlc-common/metadata/build-readme-file.ts +++ b/packages/typespec-ts/src/metadata/build-readme-file.ts @@ -4,8 +4,8 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; -import { getClientName } from "../helpers/name-constructors.js"; -import { NameType, normalizeName } from "../helpers/name-utils.js"; +import { getClientName } from "../utils/name-constructors.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { RLCModel } from "../interfaces.js"; const azureReadmeModularTemplate = `# {{ clientDescriptiveName }} library for JavaScript diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-sample-env-file.ts b/packages/typespec-ts/src/metadata/build-sample-env-file.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-sample-env-file.ts rename to packages/typespec-ts/src/metadata/build-sample-env-file.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-test-config.ts b/packages/typespec-ts/src/metadata/build-test-config.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-test-config.ts rename to packages/typespec-ts/src/metadata/build-test-config.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-ts-config.ts b/packages/typespec-ts/src/metadata/build-ts-config.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-ts-config.ts rename to packages/typespec-ts/src/metadata/build-ts-config.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-vitest-config.ts b/packages/typespec-ts/src/metadata/build-vitest-config.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-vitest-config.ts rename to packages/typespec-ts/src/metadata/build-vitest-config.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/build-warp-config.ts b/packages/typespec-ts/src/metadata/build-warp-config.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/build-warp-config.ts rename to packages/typespec-ts/src/metadata/build-warp-config.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/package-json/azure-package-common.ts b/packages/typespec-ts/src/metadata/package-json/azure-package-common.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/package-json/azure-package-common.ts rename to packages/typespec-ts/src/metadata/package-json/azure-package-common.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts b/packages/typespec-ts/src/metadata/package-json/build-azure-monorepo-package.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts rename to packages/typespec-ts/src/metadata/package-json/build-azure-monorepo-package.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/package-json/package-common.ts b/packages/typespec-ts/src/metadata/package-json/package-common.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/package-json/package-common.ts rename to packages/typespec-ts/src/metadata/package-json/package-common.ts diff --git a/packages/typespec-ts/src/rlc-common/test/build-recorded-client.ts b/packages/typespec-ts/src/metadata/test/build-recorded-client.ts similarity index 90% rename from packages/typespec-ts/src/rlc-common/test/build-recorded-client.ts rename to packages/typespec-ts/src/metadata/test/build-recorded-client.ts index 022b150c64..29f26e145c 100644 --- a/packages/typespec-ts/src/rlc-common/test/build-recorded-client.ts +++ b/packages/typespec-ts/src/metadata/test/build-recorded-client.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; -import { RLCModel } from "../interfaces.js"; +import { RLCModel } from "../../interfaces.js"; import { recordedClientContent } from "./template.js"; export function buildRecordedClientFile(_model: RLCModel) { diff --git a/packages/typespec-ts/src/rlc-common/test/build-sample-test.ts b/packages/typespec-ts/src/metadata/test/build-sample-test.ts similarity index 88% rename from packages/typespec-ts/src/rlc-common/test/build-sample-test.ts rename to packages/typespec-ts/src/metadata/test/build-sample-test.ts index a297f61516..64e708a786 100644 --- a/packages/typespec-ts/src/rlc-common/test/build-sample-test.ts +++ b/packages/typespec-ts/src/metadata/test/build-sample-test.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; -import { RLCModel } from "../interfaces.js"; +import { RLCModel } from "../../interfaces.js"; import { sampleTestContent } from "./template.js"; export function buildSampleTest(_model: RLCModel) { diff --git a/packages/typespec-ts/src/rlc-common/test/build-snippets.ts b/packages/typespec-ts/src/metadata/test/build-snippets.ts similarity index 87% rename from packages/typespec-ts/src/rlc-common/test/build-snippets.ts rename to packages/typespec-ts/src/metadata/test/build-snippets.ts index 654de2c554..d7bbe4de85 100644 --- a/packages/typespec-ts/src/rlc-common/test/build-snippets.ts +++ b/packages/typespec-ts/src/metadata/test/build-snippets.ts @@ -1,8 +1,8 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; -import { getClientName } from "../helpers/name-constructors.js"; -import { RLCModel } from "../interfaces.js"; +import { getClientName } from "../../utils/name-constructors.js"; +import { RLCModel } from "../../interfaces.js"; import { snippetsContent } from "./template.js"; export function buildSnippets(model: RLCModel, clientName?: string) { diff --git a/packages/typespec-ts/src/rlc-common/test/template.ts b/packages/typespec-ts/src/metadata/test/template.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/test/template.ts rename to packages/typespec-ts/src/metadata/test/template.ts diff --git a/packages/typespec-ts/src/rlc-common/metadata/utils.ts b/packages/typespec-ts/src/metadata/utils.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/metadata/utils.ts rename to packages/typespec-ts/src/metadata/utils.ts diff --git a/packages/typespec-ts/src/modular/build-classical-client.ts b/packages/typespec-ts/src/modular/build-classical-client.ts index aef108e2af..95ff512262 100644 --- a/packages/typespec-ts/src/modular/build-classical-client.ts +++ b/packages/typespec-ts/src/modular/build-classical-client.ts @@ -5,7 +5,6 @@ import { SourceFile, StructureKind, } from "ts-morph"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { buildUserAgentOptions, getClientParametersDeclaration } from "./helpers/client-helpers.js"; import { getClassicalClientName, getClientName } from "./helpers/naming-helpers.js"; import { ModularEmitterOptions } from "./interfaces.js"; @@ -28,6 +27,7 @@ import { getPagingLROMethodName } from "./helpers/classical-operation-helpers.js import { getDocsFromDescription } from "./helpers/docs-helpers.js"; import { getOperationFunction } from "./helpers/operation-helpers.js"; import { PagingHelpers, SimplePollerHelpers } from "./static-helpers-metadata.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; export function buildClassicalClient( dpgContext: SdkContext, diff --git a/packages/typespec-ts/src/modular/build-classical-operation-groups.ts b/packages/typespec-ts/src/modular/build-classical-operation-groups.ts index c8e1486e46..e6156c84ce 100644 --- a/packages/typespec-ts/src/modular/build-classical-operation-groups.ts +++ b/packages/typespec-ts/src/modular/build-classical-operation-groups.ts @@ -1,13 +1,13 @@ import { SdkClientType, SdkServiceOperation } from "@azure-tools/typespec-client-generator-core"; import { SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; -import { NameType } from "../rlc-common/index.js"; import { getModularClientOptions } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { getClassicalOperation } from "./helpers/classical-operation-helpers.js"; import { getClassicalLayerPrefix } from "./helpers/naming-helpers.js"; import { ModularEmitterOptions } from "./interfaces.js"; +import { NameType } from "../utils/name-utils.js"; export function buildClassicOperationFiles( dpgContext: SdkContext, diff --git a/packages/typespec-ts/src/modular/build-client-context.ts b/packages/typespec-ts/src/modular/build-client-context.ts index 944fca6886..f0d40d0f79 100644 --- a/packages/typespec-ts/src/modular/build-client-context.ts +++ b/packages/typespec-ts/src/modular/build-client-context.ts @@ -1,4 +1,3 @@ -import { NameType, normalizeName } from "../rlc-common/index.js"; import { buildGetClientCredentialParam, buildGetClientEndpointParam, @@ -31,6 +30,7 @@ import { getDocsFromDescription } from "./helpers/docs-helpers.js"; import { getClassicalClientName, getClientName } from "./helpers/naming-helpers.js"; import { CloudSettingHelpers } from "./static-helpers-metadata.js"; import { getTypeExpression } from "./type-expressions/get-type-expression.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; /** * This function gets the path of the file containing the modular client context diff --git a/packages/typespec-ts/src/modular/build-operations.ts b/packages/typespec-ts/src/modular/build-operations.ts index 3823e21711..c93c915ea0 100644 --- a/packages/typespec-ts/src/modular/build-operations.ts +++ b/packages/typespec-ts/src/modular/build-operations.ts @@ -1,5 +1,4 @@ import { InterfaceDeclarationStructure, SourceFile, StructureKind } from "ts-morph"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { getDeserializeExceptionHeadersPrivateFunction, getDeserializeHeadersPrivateFunction, @@ -34,6 +33,7 @@ import { getDocsFromDescription } from "./helpers/docs-helpers.js"; import { getOperationName } from "./helpers/naming-helpers.js"; import { OperationPathAndDeserDetails } from "./interfaces.js"; import { getTypeExpression } from "./type-expressions/get-type-expression.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; /** * This function creates a file under /api for each operation group. diff --git a/packages/typespec-ts/src/modular/build-project-files.ts b/packages/typespec-ts/src/modular/build-project-files.ts index 98e69525a4..d07928e31c 100644 --- a/packages/typespec-ts/src/modular/build-project-files.ts +++ b/packages/typespec-ts/src/modular/build-project-files.ts @@ -1,5 +1,3 @@ -import { NameType } from "../rlc-common/index.js"; - import { getRelativePathFromDirectory, joinPaths } from "@typespec/compiler"; import { useContext } from "../context-manager.js"; import { getClientHierarchyMap, getModularClientOptions } from "../utils/client-utils.js"; @@ -7,6 +5,7 @@ import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { getClassicalLayerPrefix } from "./helpers/naming-helpers.js"; import { ModularEmitterOptions } from "./interfaces.js"; +import { NameType } from "../utils/name-utils.js"; /** * Computes the relative path prefix (e.g. `./src` or `./src/generated`) from diff --git a/packages/typespec-ts/src/modular/build-restore-poller.ts b/packages/typespec-ts/src/modular/build-restore-poller.ts index c814e1f314..f58c609e94 100644 --- a/packages/typespec-ts/src/modular/build-restore-poller.ts +++ b/packages/typespec-ts/src/modular/build-restore-poller.ts @@ -4,7 +4,6 @@ import { SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { getModularClientOptions } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; @@ -14,6 +13,7 @@ import { getClassicalClientName } from "./helpers/naming-helpers.js"; import { isLroOnlyOperation } from "./helpers/operation-helpers.js"; import { ModularEmitterOptions } from "./interfaces.js"; import { PollingHelpers } from "./static-helpers-metadata.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; export function buildRestorePoller( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/build-root-index.ts b/packages/typespec-ts/src/modular/build-root-index.ts index 07fcb5482e..c3997d3905 100644 --- a/packages/typespec-ts/src/modular/build-root-index.ts +++ b/packages/typespec-ts/src/modular/build-root-index.ts @@ -4,7 +4,6 @@ import { Project, SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; import { resolveReference } from "../framework/reference.js"; import { reportDiagnostic } from "../lib.js"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { getModularClientOptions } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; @@ -18,6 +17,7 @@ import { PagingHelpers, PlatformTypeHelpers, } from "./static-helpers-metadata.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; export function buildRootIndex( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/emit-models-options.ts b/packages/typespec-ts/src/modular/emit-models-options.ts index 19928110b8..ef145cc608 100644 --- a/packages/typespec-ts/src/modular/emit-models-options.ts +++ b/packages/typespec-ts/src/modular/emit-models-options.ts @@ -4,11 +4,11 @@ import { ModularEmitterOptions } from "./interfaces.js"; import { SdkClientType, SdkServiceOperation } from "@azure-tools/typespec-client-generator-core"; import { useContext } from "../context-manager.js"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { getModularClientOptions } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { buildOperationOptions } from "./build-operations.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; // ====== UTILITIES ====== diff --git a/packages/typespec-ts/src/modular/emit-models.ts b/packages/typespec-ts/src/modular/emit-models.ts index bd5275ad5a..aeda192858 100644 --- a/packages/typespec-ts/src/modular/emit-models.ts +++ b/packages/typespec-ts/src/modular/emit-models.ts @@ -28,7 +28,6 @@ import { StructureKind, TypeAliasDeclarationStructure, } from "ts-morph"; -import { fixLeadingNumber, NameType, normalizeName } from "../rlc-common/index.js"; // import { isKey } from "@typespec/compiler"; import { getExternalModel, @@ -85,6 +84,7 @@ import { getTypeExpression, normalizeModelPropertyName, } from "./type-expressions/get-type-expression.js"; +import { fixLeadingNumber, NameType, normalizeName } from "../utils/name-utils.js"; type InterfaceStructure = OptionalKind & { extends?: string[]; diff --git a/packages/typespec-ts/src/modular/emit-samples.ts b/packages/typespec-ts/src/modular/emit-samples.ts index ffae853c81..60d4d7fc18 100644 --- a/packages/typespec-ts/src/modular/emit-samples.ts +++ b/packages/typespec-ts/src/modular/emit-samples.ts @@ -14,7 +14,6 @@ import { useContext } from "../context-manager.js"; import { resolveReference } from "../framework/reference.js"; import { reportDiagnostic } from "../index.js"; import { AzureIdentityDependencies } from "../modular/external-dependencies.js"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { getSubscriptionId } from "../transform/transfrom-rlc-options.js"; import { hasKeyCredential, hasTokenCredential } from "../utils/credential-utils.js"; import { SdkContext } from "../utils/interfaces.js"; @@ -33,6 +32,7 @@ import { getClassicalClientName } from "./helpers/naming-helpers.js"; import { getOperationFunction } from "./helpers/operation-helpers.js"; import { buildPropertyNameMapper, isSpreadBodyParameter } from "./helpers/type-helpers.js"; import { ModelOverrideOptions } from "./serialization/serialize-utils.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; /** * Interfaces for samples generations diff --git a/packages/typespec-ts/src/modular/emit-tests.ts b/packages/typespec-ts/src/modular/emit-tests.ts index 6b853a7fdd..91badb8acb 100644 --- a/packages/typespec-ts/src/modular/emit-tests.ts +++ b/packages/typespec-ts/src/modular/emit-tests.ts @@ -1,7 +1,6 @@ import { type CompilerHost, joinPaths } from "@typespec/compiler"; import { SourceFile } from "ts-morph"; import { resolveReference } from "../framework/reference.js"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { SdkContext } from "../utils/interfaces.js"; import { ServiceOperation } from "../utils/operation-util.js"; import { AzureTestDependencies } from "./external-dependencies.js"; @@ -17,6 +16,7 @@ import { } from "./helpers/example-value-helpers.js"; import { getClassicalClientName } from "./helpers/naming-helpers.js"; import { CreateRecorderHelpers } from "./static-helpers-metadata.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; /** * Clean up the test/generated folder before generating new tests diff --git a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts index a66ff57d7e..9ec182ac36 100644 --- a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts @@ -10,7 +10,6 @@ import { import { addDeclaration } from "../../framework/declaration.js"; import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { getModularClientOptions } from "../../utils/client-utils.js"; import { SdkContext } from "../../utils/interfaces.js"; import { ServiceOperation } from "../../utils/operation-util.js"; @@ -18,6 +17,7 @@ import { AzurePollingDependencies } from "../external-dependencies.js"; import { PagingHelpers, SimplePollerHelpers } from "../static-helpers-metadata.js"; import { getClassicalLayerPrefix } from "./naming-helpers.js"; import { getOperationFunction } from "./operation-helpers.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; interface OperationDeclarationInfo { // the operation function diff --git a/packages/typespec-ts/src/modular/helpers/client-helpers.ts b/packages/typespec-ts/src/modular/helpers/client-helpers.ts index 295bef0a86..7c80b6284d 100644 --- a/packages/typespec-ts/src/modular/helpers/client-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/client-helpers.ts @@ -10,12 +10,12 @@ import { OptionalKind, ParameterDeclarationStructure, StatementedNode } from "ts import { ModularEmitterOptions } from "../interfaces.js"; import { resolveReference } from "../../framework/reference.js"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { CloudSettingHelpers } from "../static-helpers-metadata.js"; import { getTypeExpression } from "../type-expressions/get-type-expression.js"; import { getClassicalClientName } from "./naming-helpers.js"; import { isCredentialType } from "./type-helpers.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; interface ClientParameterOptions { onClientOnly?: boolean; diff --git a/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts b/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts index d009ea3703..9867f68fb2 100644 --- a/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts @@ -12,7 +12,6 @@ import { joinPaths } from "@typespec/compiler"; import { SourceFile } from "ts-morph"; import { useContext } from "../../context-manager.js"; import { resolveReference } from "../../framework/reference.js"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { getSubscriptionId } from "../../transform/transfrom-rlc-options.js"; import { hasKeyCredential, hasTokenCredential } from "../../utils/credential-utils.js"; import { SdkContext } from "../../utils/interfaces.js"; @@ -22,6 +21,7 @@ import { getClientParametersDeclaration } from "./client-helpers.js"; import { getClassicalClientName } from "./naming-helpers.js"; import { getOperationFunction } from "./operation-helpers.js"; import { isSpreadBodyParameter } from "./type-helpers.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; /** * Common interfaces for both samples and tests diff --git a/packages/typespec-ts/src/modular/helpers/naming-helpers.ts b/packages/typespec-ts/src/modular/helpers/naming-helpers.ts index 54908cd67c..166257b505 100644 --- a/packages/typespec-ts/src/modular/helpers/naming-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/naming-helpers.ts @@ -1,7 +1,7 @@ import { SdkClientType, SdkServiceOperation } from "@azure-tools/typespec-client-generator-core"; -import { NameType, normalizeName, ReservedModelNames } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { ServiceOperation } from "../../utils/operation-util.js"; +import { NameType, normalizeName, ReservedModelNames } from "../../utils/name-utils.js"; export function getClientName(client: SdkClientType): string { return client.name.replace(/Client$/, ""); diff --git a/packages/typespec-ts/src/modular/helpers/operation-helpers.ts b/packages/typespec-ts/src/modular/helpers/operation-helpers.ts index 0f474c2f65..33ec3b6077 100644 --- a/packages/typespec-ts/src/modular/helpers/operation-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/operation-helpers.ts @@ -33,7 +33,6 @@ import { useDependencies } from "../../framework/hooks/use-dependencies.js"; import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; import { @@ -92,6 +91,7 @@ import { getOperationName, } from "./naming-helpers.js"; import { getNullableValidType, isSpreadBodyParameter, isTypeNullable } from "./type-helpers.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; /** * Checks whether a header should be skipped during serialization/deserialization. diff --git a/packages/typespec-ts/src/modular/helpers/type-helpers.ts b/packages/typespec-ts/src/modular/helpers/type-helpers.ts index b6c847e24b..3bc0ddf52d 100644 --- a/packages/typespec-ts/src/modular/helpers/type-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/type-helpers.ts @@ -6,13 +6,13 @@ import { SdkModelType, SdkType, } from "@azure-tools/typespec-client-generator-core"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { getPropertyWithOverrides, ModelOverrideOptions, } from "../serialization/serialize-utils.js"; import { getAllAncestors, getAllProperties } from "./operation-helpers.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; export function getDirectSubtypes(type: SdkModelType) { if (!type.discriminatedSubtypes) { diff --git a/packages/typespec-ts/src/modular/interfaces.ts b/packages/typespec-ts/src/modular/interfaces.ts index 3567349de0..996b9861dd 100644 --- a/packages/typespec-ts/src/modular/interfaces.ts +++ b/packages/typespec-ts/src/modular/interfaces.ts @@ -1,4 +1,4 @@ -import { RLCOptions } from "../rlc-common/index.js"; +import { RLCOptions } from "../interfaces.js"; export interface ModularOptions { sourceRoot: string; diff --git a/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts index f44aaa83e1..0b1a5c2b87 100644 --- a/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts @@ -13,7 +13,6 @@ import { useContext } from "../../context-manager.js"; import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; import { getAdditionalPropertiesName, normalizeModelName } from "../emit-models.js"; @@ -31,6 +30,7 @@ import { isSupportedSerializeType, ModelSerializeOptions, } from "./serialize-utils.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; export function buildPropertyDeserializer( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts index 5f3bc6420c..df7748b6ac 100644 --- a/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts @@ -14,7 +14,6 @@ import { useContext } from "../../context-manager.js"; import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; import { getAdditionalPropertiesName, normalizeModelName } from "../emit-models.js"; @@ -33,6 +32,7 @@ import { isSupportedSerializeType, ModelSerializeOptions, } from "./serialize-utils.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; export function buildPropertySerializer( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts index 54fe244fdb..2664f85c18 100644 --- a/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts @@ -16,7 +16,6 @@ import { useDependencies } from "../../framework/hooks/use-dependencies.js"; import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; -import { NameType } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; import { getAdditionalPropertiesName, normalizeModelName } from "../emit-models.js"; @@ -25,6 +24,7 @@ import { getAdditionalPropertiesType } from "../helpers/type-helpers.js"; import { XmlHelpers } from "../static-helpers-metadata.js"; import { normalizeModelPropertyName } from "../type-expressions/get-type-expression.js"; import { isSupportedSerializeType, ModelSerializeOptions } from "./serialize-utils.js"; +import { NameType } from "../../utils/name-utils.js"; /** * Checks if a model type has XML serialization options defined diff --git a/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts b/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts index 5583e1bafa..0c1c8021d1 100644 --- a/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts +++ b/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts @@ -4,13 +4,13 @@ import { SdkServiceResponseHeader, SdkType, } from "@azure-tools/typespec-client-generator-core"; -import { NameType, normalizeName } from "../../rlc-common/index.js"; import { SdkContext } from "../../utils/interfaces.js"; import { getCredentialExpression } from "./get-credential-expression.js"; import { getEnumExpression } from "./get-enum-expression.js"; import { getModelExpression } from "./get-model-expression.js"; import { getNullableExpression } from "./get-nullable-expression.js"; import { getUnionExpression } from "./get-union-expression.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; export interface EmitTypeOptions { emitInline?: boolean; diff --git a/packages/typespec-ts/src/rlc-common/index.ts b/packages/typespec-ts/src/rlc-common/index.ts deleted file mode 100644 index 6ca9a42143..0000000000 --- a/packages/typespec-ts/src/rlc-common/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -export * from "./helpers/api-version-util.js"; -export * from "./helpers/imports-util.js"; -export * from "./helpers/name-constructors.js"; -export * from "./helpers/name-utils.js"; -export * from "./helpers/operation-helpers.js"; -export * from "./helpers/schema-helpers.js"; -export * from "./interfaces.js"; -export * from "./metadata/build-api-extractor-config.js"; -export * from "./metadata/build-changelog-file.js"; -export * from "./metadata/build-es-lint-config.js"; -export * from "./metadata/build-license-file.js"; -export * from "./metadata/build-package-file.js"; -export * from "./metadata/build-readme-file.js"; -export * from "./metadata/build-sample-env-file.js"; -export * from "./metadata/build-test-config.js"; -export * from "./metadata/build-ts-config.js"; -export * from "./metadata/build-vitest-config.js"; -export * from "./metadata/build-warp-config.js"; -export * from "./test/build-recorded-client.js"; -export * from "./test/build-sample-test.js"; -export * from "./test/build-snippets.js"; diff --git a/packages/typespec-ts/src/transform/transform-api-version-info.ts b/packages/typespec-ts/src/transform/transform-api-version-info.ts index 5ab94a12f1..059f53d733 100644 --- a/packages/typespec-ts/src/transform/transform-api-version-info.ts +++ b/packages/typespec-ts/src/transform/transform-api-version-info.ts @@ -3,17 +3,11 @@ import { isApiVersion, SdkClient, } from "@azure-tools/typespec-client-generator-core"; -import { - ApiVersionInfo, - ApiVersionPosition, - extractDefinedPosition, - extractPathApiVersion, - SchemaContext, - UrlInfo, -} from "../rlc-common/index.js"; import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultApiVersionString, getSchemaForType, trimUsage } from "../utils/model-utils.js"; +import { ApiVersionInfo, ApiVersionPosition, SchemaContext, UrlInfo } from "../interfaces.js"; +import { extractDefinedPosition, extractPathApiVersion } from "../utils/api-version-util.js"; export function transformApiVersionInfo( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-helper-function-details.ts b/packages/typespec-ts/src/transform/transform-helper-function-details.ts index 0156142d88..4fc34bd4b2 100644 --- a/packages/typespec-ts/src/transform/transform-helper-function-details.ts +++ b/packages/typespec-ts/src/transform/transform-helper-function-details.ts @@ -1,5 +1,4 @@ import { getHttpOperationWithCache, SdkClient } from "@azure-tools/typespec-client-generator-core"; -import { HelperFunctionDetails } from "../rlc-common/index.js"; import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getCollectionFormat } from "../utils/model-utils.js"; @@ -9,6 +8,7 @@ import { hasPagingOperations, hasPollingOperations, } from "../utils/operation-util.js"; +import { HelperFunctionDetails } from "../interfaces.js"; export function transformHelperFunctionDetails( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-parameters.ts b/packages/typespec-ts/src/transform/transform-parameters.ts index 0d20f2fc06..628d54bf36 100644 --- a/packages/typespec-ts/src/transform/transform-parameters.ts +++ b/packages/typespec-ts/src/transform/transform-parameters.ts @@ -9,16 +9,6 @@ import { import { NoTarget, Type, isVoidType } from "@typespec/compiler"; import { HttpOperation, HttpOperationParameter, HttpOperationParameters } from "@typespec/http"; import { reportDiagnostic } from "../lib.js"; -import { - ApiVersionInfo, - Imports, - ObjectSchema, - OperationParameter, - ParameterBodyMetadata, - ParameterMetadata, - Schema, - SchemaContext, -} from "../rlc-common/index.js"; import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { @@ -43,6 +33,7 @@ import { getSpecialSerializeInfo, } from "../utils/operation-util.js"; import { getParameterSerializationInfo } from "../utils/parameter-utils.js"; +import { ApiVersionInfo, Imports, ObjectSchema, OperationParameter, ParameterBodyMetadata, ParameterMetadata, Schema, SchemaContext } from "../interfaces.js"; interface ParameterTransformationOptions { apiVersionInfo?: ApiVersionInfo; diff --git a/packages/typespec-ts/src/transform/transform-paths.ts b/packages/typespec-ts/src/transform/transform-paths.ts index 48214fb07c..ad26b95358 100644 --- a/packages/typespec-ts/src/transform/transform-paths.ts +++ b/packages/typespec-ts/src/transform/transform-paths.ts @@ -7,15 +7,6 @@ import { isApiVersion, } from "@azure-tools/typespec-client-generator-core"; import { HttpOperation, HttpOperationParameters } from "@typespec/http"; -import { - Imports, - OperationMethod, - PathMetadata, - Paths, - SchemaContext, - getParameterTypeName, - getResponseTypeName, -} from "../rlc-common/index.js"; import { getImportedModelName, getSchemaForType, isBodyRequired } from "../utils/model-utils.js"; import { extractOperationLroDetail, @@ -32,6 +23,8 @@ import { getDoc } from "@typespec/compiler"; import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getParameterSerializationInfo } from "../utils/parameter-utils.js"; +import { Imports, OperationMethod, PathMetadata, Paths, SchemaContext } from "../interfaces.js"; +import { getParameterTypeName, getResponseTypeName } from "../utils/name-constructors.js"; export function transformPaths( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-responses.ts b/packages/typespec-ts/src/transform/transform-responses.ts index d2a0458077..e55097ac44 100644 --- a/packages/typespec-ts/src/transform/transform-responses.ts +++ b/packages/typespec-ts/src/transform/transform-responses.ts @@ -4,15 +4,6 @@ import { getHttpOperationWithCache, SdkClient } from "@azure-tools/typespec-client-generator-core"; import { getDoc, isVoidType } from "@typespec/compiler"; import { HttpOperation, HttpOperationResponse } from "@typespec/http"; -import { - getLroLogicalResponseName, - Imports, - OperationResponse, - ResponseHeaderSchema, - ResponseMetadata, - Schema, - SchemaContext, -} from "../rlc-common/index.js"; import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { @@ -29,6 +20,8 @@ import { isBinaryPayload, sortedOperationResponses, } from "../utils/operation-util.js"; +import { getLroLogicalResponseName } from "../utils/name-constructors.js"; +import { Imports, OperationResponse, ResponseHeaderSchema, ResponseMetadata, Schema, SchemaContext } from "../interfaces.js"; export function transformToResponseTypes( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-schemas.ts b/packages/typespec-ts/src/transform/transform-schemas.ts index e1de5a27cf..408db391bc 100644 --- a/packages/typespec-ts/src/transform/transform-schemas.ts +++ b/packages/typespec-ts/src/transform/transform-schemas.ts @@ -15,9 +15,9 @@ import { } from "../utils/model-utils.js"; import { useContext } from "../context-manager.js"; -import { SchemaContext } from "../rlc-common/index.js"; import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { SchemaContext } from "../interfaces.js"; export function transformSchemas(client: SdkClient, dpgContext: SdkContext) { const program = dpgContext.program; diff --git a/packages/typespec-ts/src/transform/transform-telemetry-info.ts b/packages/typespec-ts/src/transform/transform-telemetry-info.ts index da9bd22ae1..387c9e90c6 100644 --- a/packages/typespec-ts/src/transform/transform-telemetry-info.ts +++ b/packages/typespec-ts/src/transform/transform-telemetry-info.ts @@ -3,9 +3,9 @@ import { SdkClient, SdkContext, } from "@azure-tools/typespec-client-generator-core"; -import { TelemetryInfo } from "../rlc-common/index.js"; import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { getCustomRequestHeaderNameForOperation } from "../utils/operation-util.js"; +import { TelemetryInfo } from "../interfaces.js"; export function transformTelemetryInfo( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform.ts b/packages/typespec-ts/src/transform/transform.ts index 88ad056921..90e86dff12 100644 --- a/packages/typespec-ts/src/transform/transform.ts +++ b/packages/typespec-ts/src/transform/transform.ts @@ -4,22 +4,6 @@ import { SdkClient } from "@azure-tools/typespec-client-generator-core"; import { getDoc, joinPaths } from "@typespec/compiler"; import { getServers } from "@typespec/http"; -import { - buildRuntimeImports, - Imports, - initInternalImports, - NameType, - normalizeName, - OperationParameter, - OperationResponse, - PathParameter, - Paths, - RLCModel, - RLCOptions, - Schema, - SchemaContext, - UrlInfo, -} from "../rlc-common/index.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultService, @@ -37,6 +21,9 @@ import { transformPaths } from "./transform-paths.js"; import { transformToResponseTypes } from "./transform-responses.js"; import { transformSchemas } from "./transform-schemas.js"; import { transformTelemetryInfo } from "./transform-telemetry-info.js"; +import { buildRuntimeImports, initInternalImports } from "../utils/imports-util.js"; +import { Imports, OperationParameter, OperationResponse, PathParameter, Paths, RLCModel, RLCOptions, Schema, SchemaContext, UrlInfo } from "../interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; export async function transformRLCModel( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transfrom-rlc-options.ts b/packages/typespec-ts/src/transform/transfrom-rlc-options.ts index 0007c9d202..a165e1a5c2 100644 --- a/packages/typespec-ts/src/transform/transfrom-rlc-options.ts +++ b/packages/typespec-ts/src/transform/transfrom-rlc-options.ts @@ -3,20 +3,14 @@ import { getDoc, NoTarget, Program } from "@typespec/compiler"; import { getAuthentication } from "@typespec/http"; import { EmitterOptions, reportDiagnostic } from "../lib.js"; import { getClientParameters } from "../modular/helpers/client-helpers.js"; -import { - NameType, - normalizeName, - PackageDetails, - pascalCase, - RLCOptions, - ServiceInfo, -} from "../rlc-common/index.js"; import { getRLCClients, listOperationsUnderRLCClient } from "../utils/client-utils.js"; import { getSupportedHttpAuth } from "../utils/credential-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultService } from "../utils/model-utils.js"; import { detectModelConflicts } from "../utils/namespace-utils.js"; import { getOperationName } from "../utils/operation-util.js"; +import { NameType, normalizeName, pascalCase } from "../utils/name-utils.js"; +import { PackageDetails, RLCOptions, ServiceInfo } from "../interfaces.js"; export function transformRLCOptions( emitterOptions: EmitterOptions, diff --git a/packages/typespec-ts/src/rlc-common/helpers/api-version-util.ts b/packages/typespec-ts/src/utils/api-version-util.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/helpers/api-version-util.ts rename to packages/typespec-ts/src/utils/api-version-util.ts diff --git a/packages/typespec-ts/src/utils/client-utils.ts b/packages/typespec-ts/src/utils/client-utils.ts index 62c737bc8f..0e02efc10f 100644 --- a/packages/typespec-ts/src/utils/client-utils.ts +++ b/packages/typespec-ts/src/utils/client-utils.ts @@ -15,8 +15,8 @@ import { Operation, } from "@typespec/compiler"; import { ModularClientOptions } from "../modular/interfaces.js"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { SdkContext } from "./interfaces.js"; +import { NameType, normalizeName } from "./name-utils.js"; export function getRLCClients(dpgContext: SdkContext): SdkClient[] { const clients = listClients(dpgContext); diff --git a/packages/typespec-ts/src/utils/cross-language-def.ts b/packages/typespec-ts/src/utils/cross-language-def.ts index 48ee6fc835..8468f9332f 100644 --- a/packages/typespec-ts/src/utils/cross-language-def.ts +++ b/packages/typespec-ts/src/utils/cross-language-def.ts @@ -3,9 +3,9 @@ import { UsageFlags } from "@azure-tools/typespec-client-generator-core"; import { transformModularEmitterOptions } from "../modular/build-modular-options.js"; -import { NameType, normalizeName } from "../rlc-common/index.js"; import { SdkContext } from "./interfaces.js"; import { getMethodHierarchiesMap } from "./operation-util.js"; +import { NameType, normalizeName } from "./name-utils.js"; export function generateCrossLanguageDefinitionFile(dpgContext: SdkContext): { CrossLanguagePackageId: string; diff --git a/packages/typespec-ts/src/utils/emit-util.ts b/packages/typespec-ts/src/utils/emit-util.ts index 8a39f6e1bb..294305717c 100644 --- a/packages/typespec-ts/src/utils/emit-util.ts +++ b/packages/typespec-ts/src/utils/emit-util.ts @@ -4,7 +4,7 @@ import prettierPluginBabel from "prettier/plugins/babel"; import prettierPluginEstree from "prettier/plugins/estree"; import prettierPluginTypescript from "prettier/plugins/typescript"; import { prettierJSONOptions, prettierTypeScriptOptions, reportDiagnostic } from "../lib.js"; -import { ContentBuilder, File, RLCModel } from "../rlc-common/index.js"; +import { ContentBuilder, File, RLCModel } from "../interfaces.js"; export async function emitContentByBuilder( program: Program, diff --git a/packages/typespec-ts/src/rlc-common/helpers/imports-util.ts b/packages/typespec-ts/src/utils/imports-util.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/helpers/imports-util.ts rename to packages/typespec-ts/src/utils/imports-util.ts diff --git a/packages/typespec-ts/src/utils/interfaces.ts b/packages/typespec-ts/src/utils/interfaces.ts index 0ebe1ba530..241fdbe61d 100644 --- a/packages/typespec-ts/src/utils/interfaces.ts +++ b/packages/typespec-ts/src/utils/interfaces.ts @@ -1,7 +1,7 @@ import { SdkContext as TCGCSdkContext } from "@azure-tools/typespec-client-generator-core"; import { ModelProperty, Namespace } from "@typespec/compiler"; -import { RLCOptions, SchemaContext } from "../rlc-common/index.js"; import { KnownMediaType } from "./media-types.js"; +import { RLCOptions, SchemaContext } from "../interfaces.js"; export interface SdkContext extends TCGCSdkContext { rlcOptions?: RLCOptions; diff --git a/packages/typespec-ts/src/utils/model-utils.ts b/packages/typespec-ts/src/utils/model-utils.ts index 5e48781ac9..35d38271c7 100644 --- a/packages/typespec-ts/src/utils/model-utils.ts +++ b/packages/typespec-ts/src/utils/model-utils.ts @@ -64,21 +64,14 @@ import { isBody, isStatusCode, } from "@typespec/http"; -import { - ArraySchema, - DictionarySchema, - NameType, - ObjectSchema, - Schema, - SchemaContext, - isArraySchema, - normalizeName, -} from "../rlc-common/index.js"; import { GetSchemaOptions, SdkContext } from "./interfaces.js"; import { KnownMediaType, hasMediaType, isMediaTypeMultipartFormData } from "./media-types.js"; import { reportDiagnostic } from "../lib.js"; import { getModelNamespaceName } from "./namespace-utils.js"; +import { ArraySchema, DictionarySchema, ObjectSchema, Schema, SchemaContext } from "../interfaces.js"; +import { NameType, normalizeName } from "./name-utils.js"; +import { isArraySchema } from "./schema-helpers.js"; export const BINARY_TYPE_UNION = "string | Uint8Array | ReadableStream | NodeReadableStream"; diff --git a/packages/typespec-ts/src/rlc-common/helpers/name-constructors.ts b/packages/typespec-ts/src/utils/name-constructors.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/helpers/name-constructors.ts rename to packages/typespec-ts/src/utils/name-constructors.ts diff --git a/packages/typespec-ts/src/rlc-common/helpers/name-utils.ts b/packages/typespec-ts/src/utils/name-utils.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/helpers/name-utils.ts rename to packages/typespec-ts/src/utils/name-utils.ts diff --git a/packages/typespec-ts/src/rlc-common/helpers/operation-helpers.ts b/packages/typespec-ts/src/utils/operation-helpers.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/helpers/operation-helpers.ts rename to packages/typespec-ts/src/utils/operation-helpers.ts diff --git a/packages/typespec-ts/src/utils/operation-util.ts b/packages/typespec-ts/src/utils/operation-util.ts index 4883abad43..afc775f61b 100644 --- a/packages/typespec-ts/src/utils/operation-util.ts +++ b/packages/typespec-ts/src/utils/operation-util.ts @@ -28,18 +28,6 @@ import { import { resolveReference } from "../framework/reference.js"; import { reportDiagnostic } from "../lib.js"; import { SerializationHelpers } from "../modular/static-helpers-metadata.js"; -import { - getLroLogicalResponseName, - getResponseTypeName, - NameType, - normalizeName, - OPERATION_LRO_HIGH_PRIORITY, - OPERATION_LRO_LOW_PRIORITY, - OperationLroDetail, - Paths, - ResponseMetadata, - ResponseTypes, -} from "../rlc-common/index.js"; import { listOperationsUnderRLCClient } from "./client-utils.js"; import { SdkContext } from "./interfaces.js"; import { @@ -50,6 +38,9 @@ import { } from "./media-types.js"; import { isByteOrByteUnion } from "./model-utils.js"; import { getOperationNamespaceInterfaceName } from "./namespace-utils.js"; +import { getLroLogicalResponseName, getResponseTypeName } from "./name-constructors.js"; +import { NameType, normalizeName } from "./name-utils.js"; +import { OPERATION_LRO_HIGH_PRIORITY, OPERATION_LRO_LOW_PRIORITY, OperationLroDetail, Paths, ResponseMetadata, ResponseTypes } from "../interfaces.js"; // Sorts the responses by status code export function sortedOperationResponses(responses: HttpOperationResponse[]) { diff --git a/packages/typespec-ts/src/utils/parameter-utils.ts b/packages/typespec-ts/src/utils/parameter-utils.ts index c38f3e604d..02ef5c58c2 100644 --- a/packages/typespec-ts/src/utils/parameter-utils.ts +++ b/packages/typespec-ts/src/utils/parameter-utils.ts @@ -1,9 +1,10 @@ import { getEncode, NoTarget, Program } from "@typespec/compiler"; import { HttpOperationParameter } from "@typespec/http"; import { reportDiagnostic } from "../lib.js"; -import { NameType, normalizeName, Schema, SchemaContext } from "../rlc-common/index.js"; import { SdkContext } from "./interfaces.js"; import { getTypeName, isArrayType, isObjectOrDictType } from "./model-utils.js"; +import { NameType, normalizeName } from "./name-utils.js"; +import { Schema, SchemaContext } from "../interfaces.js"; export interface ParameterSerializationInfo { typeName: string; diff --git a/packages/typespec-ts/src/rlc-common/helpers/schema-helpers.ts b/packages/typespec-ts/src/utils/schema-helpers.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/helpers/schema-helpers.ts rename to packages/typespec-ts/src/utils/schema-helpers.ts diff --git a/packages/typespec-ts/src/rlc-common/helpers/type-util.ts b/packages/typespec-ts/src/utils/type-util.ts similarity index 100% rename from packages/typespec-ts/src/rlc-common/helpers/type-util.ts rename to packages/typespec-ts/src/utils/type-util.ts diff --git a/packages/typespec-ts/test-next/integration/assets/static-helpers/platform-import.ts b/packages/typespec-ts/test-next/integration/assets/static-helpers/platform-import.ts index 9937790324..611b511455 100644 --- a/packages/typespec-ts/test-next/integration/assets/static-helpers/platform-import.ts +++ b/packages/typespec-ts/test-next/integration/assets/static-helpers/platform-import.ts @@ -1,4 +1,4 @@ -import { platformTag } from "./platform-types"; +import { platformTag } from "./platform-types.js"; export function usesPlatformImport() { return platformTag; diff --git a/packages/typespec-ts/test-next/unit/rlc-common/helpers/imports-util.test.ts b/packages/typespec-ts/test-next/unit/rlc-common/helpers/imports-util.test.ts index 42bb9faee6..9515bcb3fb 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/helpers/imports-util.test.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/helpers/imports-util.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; import { buildRuntimeImports, getImportSpecifier, -} from "../../../../src/rlc-common/helpers/imports-util.js"; +} from "../../../../src/utils/imports-util.js"; describe("#buildRuntimeImports", () => { it("should return the correct import set", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/helpers/name-utils.test.ts b/packages/typespec-ts/test-next/unit/rlc-common/helpers/name-utils.test.ts index cdc9230b8c..0ef2153cc5 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/helpers/name-utils.test.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/helpers/name-utils.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { NameType, normalizeName } from "../../../../src/rlc-common/helpers/name-utils.js"; +import { NameType, normalizeName } from "../../../../src/utils/name-utils.js"; describe("#normalizeName", () => { describe("general cases", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/helpers/type-util.test.ts b/packages/typespec-ts/test-next/unit/rlc-common/helpers/type-util.test.ts index a5abfef7ba..51470d60df 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/helpers/type-util.test.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/helpers/type-util.test.ts @@ -17,7 +17,7 @@ import { leaveStringQuotes, toTypeScriptTypeFromName, toTypeScriptTypeFromSchema, -} from "../../../../src/rlc-common/helpers/type-util.js"; +} from "../../../../src/utils/type-util.js"; describe("#isStringLiteral", () => { it("should return true if the string is quoted", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/mock-helper.ts b/packages/typespec-ts/test-next/unit/rlc-common/integration/mock-helper.ts index 12a1b93cdc..75f82aeb8e 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/mock-helper.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/integration/mock-helper.ts @@ -1,8 +1,8 @@ import { buildRuntimeImports, initInternalImports, -} from "../../../../src/rlc-common/helpers/imports-util.js"; -import { RLCModel } from "../../../../src/rlc-common/interfaces.js"; +} from "../../../../src/utils/imports-util.js"; +import { RLCModel } from "../../../../src/interfaces.js"; export type TestModelConfig = { description?: string; diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/package-json.test.ts b/packages/typespec-ts/test-next/unit/rlc-common/integration/package-json.test.ts index 09d3f753c1..765438886e 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/package-json.test.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/integration/package-json.test.ts @@ -6,7 +6,7 @@ import { describe, expect, it } from "vitest"; import { buildPackageFile, updatePackageFile, -} from "../../../../src/rlc-common/metadata/build-package-file.js"; +} from "../../../../src/metadata/build-package-file.js"; import { TestModelConfig, createMockModel } from "./mock-helper.js"; describe("Package file generation", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/snippets.test.ts b/packages/typespec-ts/test-next/unit/rlc-common/integration/snippets.test.ts index 757ff775ae..8fc6d10442 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/snippets.test.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/integration/snippets.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; -import { buildSnippets } from "../../../../src/rlc-common/test/build-snippets.js"; +import { buildSnippets } from "../../../../src/metadata/test/build-snippets.js"; import { createMockModel } from "./mock-helper.js"; describe("Snippets file generation", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/vitest-config.test.ts b/packages/typespec-ts/test-next/unit/rlc-common/integration/vitest-config.test.ts index 63edf9c62d..9801c3c9a9 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/vitest-config.test.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/integration/vitest-config.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { buildVitestConfig } from "../../../../src/rlc-common/metadata/build-vitest-config.js"; +import { buildVitestConfig } from "../../../../src/metadata/build-vitest-config.js"; import { createMockModel } from "./mock-helper.js"; diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/warp-config.test.ts b/packages/typespec-ts/test-next/unit/rlc-common/integration/warp-config.test.ts index 7fa3ad1ac6..f8084ca84d 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/warp-config.test.ts +++ b/packages/typespec-ts/test-next/unit/rlc-common/integration/warp-config.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; -import { buildWarpConfig } from "../../../../src/rlc-common/metadata/build-warp-config.js"; +import { buildWarpConfig } from "../../../../src/metadata/build-warp-config.js"; import { createMockModel } from "./mock-helper.js"; describe("warp.config.yml generation", () => { diff --git a/packages/typespec-ts/test/util/emit-util.ts b/packages/typespec-ts/test/util/emit-util.ts index c55696c86f..b82d71a238 100644 --- a/packages/typespec-ts/test/util/emit-util.ts +++ b/packages/typespec-ts/test/util/emit-util.ts @@ -4,7 +4,6 @@ import { emitTypes, getModelsPath, } from "../../src/modular/emit-models.js"; -import { RLCOptions } from "../../src/rlc-common/index.js"; import { compileTypeSpecFor, createDpgContextTestHelper, @@ -26,6 +25,7 @@ import { buildSubpathIndexFile } from "../../src/modular/build-subpath-index.js" import { emitSamples } from "../../src/modular/emit-samples.js"; import { emitTests } from "../../src/modular/emit-tests.js"; import { getClientHierarchyMap } from "../../src/utils/client-utils.js"; +import { RLCOptions } from "../../src/interfaces.js"; export interface ModelConfigOptions extends RLCOptions { needOptions?: boolean; From 28154a321cbe3c5695404ea4ceaf197a78be6b24 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 15:57:35 -0500 Subject: [PATCH 03/15] test(typespec-ts): move rlc-common unit tests to mirror new homes Relocate the former test-next/unit/rlc-common tests alongside the code they exercise: helper tests to test-next/unit/utils and metadata/test builder tests to test-next/unit/metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../unit/{rlc-common/integration => metadata}/mock-helper.ts | 4 ++-- .../{rlc-common/integration => metadata}/package-json.test.ts | 2 +- .../{rlc-common/integration => metadata}/snippets.test.ts | 2 +- .../{rlc-common/integration => metadata}/static/package.json | 0 .../integration => metadata}/vitest-config.test.ts | 2 +- .../{rlc-common/integration => metadata}/warp-config.test.ts | 2 +- .../unit/{rlc-common/helpers => utils}/imports-util.test.ts | 2 +- .../unit/{rlc-common/helpers => utils}/name-utils.test.ts | 2 +- .../unit/{rlc-common/helpers => utils}/type-util.test.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) rename packages/typespec-ts/test-next/unit/{rlc-common/integration => metadata}/mock-helper.ts (94%) rename packages/typespec-ts/test-next/unit/{rlc-common/integration => metadata}/package-json.test.ts (99%) rename packages/typespec-ts/test-next/unit/{rlc-common/integration => metadata}/snippets.test.ts (94%) rename packages/typespec-ts/test-next/unit/{rlc-common/integration => metadata}/static/package.json (100%) rename packages/typespec-ts/test-next/unit/{rlc-common/integration => metadata}/vitest-config.test.ts (85%) rename packages/typespec-ts/test-next/unit/{rlc-common/integration => metadata}/warp-config.test.ts (96%) rename packages/typespec-ts/test-next/unit/{rlc-common/helpers => utils}/imports-util.test.ts (96%) rename packages/typespec-ts/test-next/unit/{rlc-common/helpers => utils}/name-utils.test.ts (98%) rename packages/typespec-ts/test-next/unit/{rlc-common/helpers => utils}/type-util.test.ts (99%) diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/mock-helper.ts b/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts similarity index 94% rename from packages/typespec-ts/test-next/unit/rlc-common/integration/mock-helper.ts rename to packages/typespec-ts/test-next/unit/metadata/mock-helper.ts index 75f82aeb8e..80dfe35ddb 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/mock-helper.ts +++ b/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts @@ -1,8 +1,8 @@ import { buildRuntimeImports, initInternalImports, -} from "../../../../src/utils/imports-util.js"; -import { RLCModel } from "../../../../src/interfaces.js"; +} from "../../../src/utils/imports-util.js"; +import { RLCModel } from "../../../src/interfaces.js"; export type TestModelConfig = { description?: string; diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/package-json.test.ts b/packages/typespec-ts/test-next/unit/metadata/package-json.test.ts similarity index 99% rename from packages/typespec-ts/test-next/unit/rlc-common/integration/package-json.test.ts rename to packages/typespec-ts/test-next/unit/metadata/package-json.test.ts index 765438886e..50140464a7 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/package-json.test.ts +++ b/packages/typespec-ts/test-next/unit/metadata/package-json.test.ts @@ -6,7 +6,7 @@ import { describe, expect, it } from "vitest"; import { buildPackageFile, updatePackageFile, -} from "../../../../src/metadata/build-package-file.js"; +} from "../../../src/metadata/build-package-file.js"; import { TestModelConfig, createMockModel } from "./mock-helper.js"; describe("Package file generation", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/snippets.test.ts b/packages/typespec-ts/test-next/unit/metadata/snippets.test.ts similarity index 94% rename from packages/typespec-ts/test-next/unit/rlc-common/integration/snippets.test.ts rename to packages/typespec-ts/test-next/unit/metadata/snippets.test.ts index 8fc6d10442..728b8e9c7c 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/snippets.test.ts +++ b/packages/typespec-ts/test-next/unit/metadata/snippets.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; -import { buildSnippets } from "../../../../src/metadata/test/build-snippets.js"; +import { buildSnippets } from "../../../src/metadata/test/build-snippets.js"; import { createMockModel } from "./mock-helper.js"; describe("Snippets file generation", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/static/package.json b/packages/typespec-ts/test-next/unit/metadata/static/package.json similarity index 100% rename from packages/typespec-ts/test-next/unit/rlc-common/integration/static/package.json rename to packages/typespec-ts/test-next/unit/metadata/static/package.json diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/vitest-config.test.ts b/packages/typespec-ts/test-next/unit/metadata/vitest-config.test.ts similarity index 85% rename from packages/typespec-ts/test-next/unit/rlc-common/integration/vitest-config.test.ts rename to packages/typespec-ts/test-next/unit/metadata/vitest-config.test.ts index 9801c3c9a9..d430ed97ce 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/vitest-config.test.ts +++ b/packages/typespec-ts/test-next/unit/metadata/vitest-config.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { buildVitestConfig } from "../../../../src/metadata/build-vitest-config.js"; +import { buildVitestConfig } from "../../../src/metadata/build-vitest-config.js"; import { createMockModel } from "./mock-helper.js"; diff --git a/packages/typespec-ts/test-next/unit/rlc-common/integration/warp-config.test.ts b/packages/typespec-ts/test-next/unit/metadata/warp-config.test.ts similarity index 96% rename from packages/typespec-ts/test-next/unit/rlc-common/integration/warp-config.test.ts rename to packages/typespec-ts/test-next/unit/metadata/warp-config.test.ts index f8084ca84d..c60e4206b2 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/integration/warp-config.test.ts +++ b/packages/typespec-ts/test-next/unit/metadata/warp-config.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; -import { buildWarpConfig } from "../../../../src/metadata/build-warp-config.js"; +import { buildWarpConfig } from "../../../src/metadata/build-warp-config.js"; import { createMockModel } from "./mock-helper.js"; describe("warp.config.yml generation", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/helpers/imports-util.test.ts b/packages/typespec-ts/test-next/unit/utils/imports-util.test.ts similarity index 96% rename from packages/typespec-ts/test-next/unit/rlc-common/helpers/imports-util.test.ts rename to packages/typespec-ts/test-next/unit/utils/imports-util.test.ts index 9515bcb3fb..c90d87f53d 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/helpers/imports-util.test.ts +++ b/packages/typespec-ts/test-next/unit/utils/imports-util.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; import { buildRuntimeImports, getImportSpecifier, -} from "../../../../src/utils/imports-util.js"; +} from "../../../src/utils/imports-util.js"; describe("#buildRuntimeImports", () => { it("should return the correct import set", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/helpers/name-utils.test.ts b/packages/typespec-ts/test-next/unit/utils/name-utils.test.ts similarity index 98% rename from packages/typespec-ts/test-next/unit/rlc-common/helpers/name-utils.test.ts rename to packages/typespec-ts/test-next/unit/utils/name-utils.test.ts index 0ef2153cc5..7927daf676 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/helpers/name-utils.test.ts +++ b/packages/typespec-ts/test-next/unit/utils/name-utils.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { NameType, normalizeName } from "../../../../src/utils/name-utils.js"; +import { NameType, normalizeName } from "../../../src/utils/name-utils.js"; describe("#normalizeName", () => { describe("general cases", () => { diff --git a/packages/typespec-ts/test-next/unit/rlc-common/helpers/type-util.test.ts b/packages/typespec-ts/test-next/unit/utils/type-util.test.ts similarity index 99% rename from packages/typespec-ts/test-next/unit/rlc-common/helpers/type-util.test.ts rename to packages/typespec-ts/test-next/unit/utils/type-util.test.ts index 51470d60df..f85393b2b0 100644 --- a/packages/typespec-ts/test-next/unit/rlc-common/helpers/type-util.test.ts +++ b/packages/typespec-ts/test-next/unit/utils/type-util.test.ts @@ -17,7 +17,7 @@ import { leaveStringQuotes, toTypeScriptTypeFromName, toTypeScriptTypeFromSchema, -} from "../../../../src/utils/type-util.js"; +} from "../../../src/utils/type-util.js"; describe("#isStringLiteral", () => { it("should return true if the string is quoted", () => { From f3d8afbd28c159b7dfcebbc0905c4764d9add894 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 16:13:29 -0500 Subject: [PATCH 04/15] refactor: de-RLC public type and function names (rename pass 1) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/src/context-manager.ts | 4 +- packages/typespec-ts/src/index.ts | 40 +++++++++---------- packages/typespec-ts/src/interfaces.ts | 16 ++++---- packages/typespec-ts/src/lib.ts | 4 +- packages/typespec-ts/src/meta-tree.ts | 4 +- .../metadata/build-api-extractor-config.ts | 4 +- .../src/metadata/build-changelog-file.ts | 6 +-- .../src/metadata/build-es-lint-config.ts | 4 +- .../src/metadata/build-package-file.ts | 10 ++--- .../src/metadata/build-readme-file.ts | 12 +++--- .../src/metadata/build-sample-env-file.ts | 4 +- .../src/metadata/build-test-config.ts | 8 ++-- .../src/metadata/build-ts-config.ts | 6 +-- .../src/metadata/build-vitest-config.ts | 4 +- .../src/metadata/build-warp-config.ts | 4 +- .../metadata/test/build-recorded-client.ts | 4 +- .../src/metadata/test/build-sample-test.ts | 4 +- .../src/metadata/test/build-snippets.ts | 4 +- packages/typespec-ts/src/metadata/utils.ts | 4 +- .../src/modular/build-classical-client.ts | 4 +- .../src/modular/build-operations.ts | 4 +- .../typespec-ts/src/modular/emit-samples.ts | 2 +- .../modular/helpers/example-value-helpers.ts | 2 +- .../typespec-ts/src/modular/interfaces.ts | 4 +- .../transform/transform-api-version-info.ts | 4 +- ...options.ts => transform-client-options.ts} | 18 ++++----- .../transform-helper-function-details.ts | 6 +-- .../src/transform/transform-parameters.ts | 4 +- .../src/transform/transform-paths.ts | 4 +- .../src/transform/transform-responses.ts | 4 +- .../src/transform/transform-schemas.ts | 4 +- .../src/transform/transform-telemetry-info.ts | 4 +- .../typespec-ts/src/transform/transform.ts | 10 ++--- .../typespec-ts/src/utils/client-utils.ts | 8 ++-- packages/typespec-ts/src/utils/emit-util.ts | 6 +-- packages/typespec-ts/src/utils/interfaces.ts | 4 +- .../src/utils/name-constructors.ts | 4 +- .../src/utils/operation-helpers.ts | 24 +++++------ .../typespec-ts/src/utils/operation-util.ts | 6 +-- .../typespec-ts/src/utils/schema-helpers.ts | 4 +- .../test-next/unit/metadata/mock-helper.ts | 4 +- packages/typespec-ts/test/util/emit-util.ts | 4 +- 42 files changed, 142 insertions(+), 142 deletions(-) rename packages/typespec-ts/src/transform/{transfrom-rlc-options.ts => transform-client-options.ts} (96%) diff --git a/packages/typespec-ts/src/context-manager.ts b/packages/typespec-ts/src/context-manager.ts index e9ef85e3ed..d63405a0c8 100644 --- a/packages/typespec-ts/src/context-manager.ts +++ b/packages/typespec-ts/src/context-manager.ts @@ -4,7 +4,7 @@ import { Project, SourceFile } from "ts-morph"; import { ExternalDependencies } from "./framework/dependency.js"; import { Binder } from "./framework/hooks/binder.js"; import { SdkTypeContext } from "./framework/hooks/sdk-types.js"; -import { RlcMetaTree } from "./meta-tree.js"; +import { ClientTypeMetaTree } from "./meta-tree.js"; /** * Contexts Object Guidelines @@ -20,7 +20,7 @@ import { RlcMetaTree } from "./meta-tree.js"; * Remember, adding too many contexts can lead to complex dependencies and harder-to-maintain code. Always evaluate if the context is truly necessary or if there are better alternatives such as localized state management or passing props for simpler scenarios. */ type Contexts = { - rlcMetaTree: RlcMetaTree; // Context for RLC types metadata. + rlcMetaTree: ClientTypeMetaTree; // Context for RLC types metadata. outputProject: Project; // The TS-Morph root project context for code generation. symbolMap: Map; // Mapping of symbols to their corresponding source files. sdkTypes: SdkTypeContext; diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index a07a487b92..2e752b1e48 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -62,15 +62,15 @@ import { emitTests } from "./modular/emit-tests.js"; import { getClassicalClientName } from "./modular/helpers/naming-helpers.js"; import { ModularEmitterOptions } from "./modular/interfaces.js"; import { packageUsesXmlSerialization } from "./modular/serialization/build-xml-serializer-function.js"; -import { transformRLCModel } from "./transform/transform.js"; -import { transformRLCOptions } from "./transform/transfrom-rlc-options.js"; +import { transformClientModel } from "./transform/transform.js"; +import { transformClientOptions } from "./transform/transform-client-options.js"; import { getClientHierarchyMap, getModularClientOptions, - getRLCClients, + getClients, } from "./utils/client-utils.js"; import { generateCrossLanguageDefinitionFile } from "./utils/cross-language-def.js"; -import { RLCModel, RLCOptions } from "./interfaces.js"; +import { ClientModel, ClientOptions } from "./interfaces.js"; import { buildApiExtractorConfig } from "./metadata/build-api-extractor-config.js"; import { buildChangelogFile } from "./metadata/build-changelog-file.js"; import { buildEsLintConfig } from "./metadata/build-es-lint-config.js"; @@ -117,7 +117,7 @@ export async function $onEmit(context: EmitContext) { const rlcOptions = dpgContext.rlcOptions ?? {}; const needUnexpectedHelper: Map = new Map(); - const serviceNameToRlcModelsMap: Map = new Map(); + const serviceNameToRlcModelsMap: Map = new Map(); provideContext("rlcMetaTree", new Map()); provideContext("symbolMap", new Map()); provideContext("outputProject", outputProject); @@ -164,13 +164,13 @@ export async function $onEmit(context: EmitContext) { }); provideSdkTypes(dpgContext); - const rlcCodeModels: RLCModel[] = []; + const clientCodeModels: ClientModel[] = []; let modularEmitterOptions: ModularEmitterOptions; // 1. Clear sources folder await clearSrcFolder(); // 2. Generate RLC code model // TODO: skip this step in modular once modular generator is sufficiently decoupled - await buildRLCCodeModels(); + await buildClientCodeModels(); // 3. Clear samples-dev folder if generateSample is true await clearSamplesDevFolder(); @@ -191,7 +191,7 @@ export async function $onEmit(context: EmitContext) { const generationPathDetail: GenerationDirDetail = await calculateGenerationDir(); dpgContext.generationPathDetail = generationPathDetail; dpgContext.allServiceNamespaces = listAllServiceNamespaces(dpgContext); - const options: RLCOptions = transformRLCOptions(emitterOptions, dpgContext); + const options: ClientOptions = transformClientOptions(emitterOptions, dpgContext); emitterOptions["generate-sample"] = options.generateSample; // clear output folder if needed if (options.clearOutputFolder) { @@ -248,14 +248,14 @@ export async function $onEmit(context: EmitContext) { } } - async function buildRLCCodeModels() { - const clients = getRLCClients(dpgContext); + async function buildClientCodeModels() { + const clients = getClients(dpgContext); for (const client of clients) { - const rlcModels = await transformRLCModel(client, dpgContext); - rlcCodeModels.push(rlcModels); + const clientModels = await transformClientModel(client, dpgContext); + clientCodeModels.push(clientModels); const serviceName = client.services[0]?.name ?? "Unknown"; - serviceNameToRlcModelsMap.set(serviceName, rlcModels); - needUnexpectedHelper.set(getClientName(rlcModels), hasUnexpectedHelper(rlcModels)); + serviceNameToRlcModelsMap.set(serviceName, clientModels); + needUnexpectedHelper.set(getClientName(clientModels), hasUnexpectedHelper(clientModels)); } } @@ -368,10 +368,10 @@ export async function $onEmit(context: EmitContext) { async function generateMetadataAndTest(context: SdkContext) { const project = useContext("outputProject"); - if (rlcCodeModels.length === 0 || !rlcCodeModels[0]) { + if (clientCodeModels.length === 0 || !clientCodeModels[0]) { return; } - const rlcClient: RLCModel = rlcCodeModels[0]; + const rlcClient: ClientModel = clientCodeModels[0]; const option = dpgContext.rlcOptions!; // When generateMetadata is explicitly false and the sources are generated // into a path ending with "generated" (e.g. src/generated), this package @@ -522,13 +522,13 @@ export async function $onEmit(context: EmitContext) { } catch { packageInfo = {}; } - updateBuilders.push((model: RLCModel) => + updateBuilders.push((model: ClientModel) => updatePackageFile(model, packageInfo, modularPackageInfo), ); } // Update warp.config.yml for Azure monorepo packages - updateBuilders.push((model: RLCModel) => buildWarpConfig(model, modularPackageInfo)); + updateBuilders.push((model: ClientModel) => buildWarpConfig(model, modularPackageInfo)); // If the client name changed, regenerate the README and snippets completely; // otherwise update only the API reference link in-place. @@ -539,13 +539,13 @@ export async function $onEmit(context: EmitContext) { updateBuilders.push( clientNameChanged ? buildReadmeFile - : (model: RLCModel) => updateReadmeFile(model, existingReadmeContent), + : (model: ClientModel) => updateReadmeFile(model, existingReadmeContent), ); // Regenerate snippets.spec.ts only when the client name changed if (clientNameChanged) { for (const subClient of dpgContext.sdkPackage.clients) { - updateBuilders.push((model: RLCModel) => + updateBuilders.push((model: ClientModel) => buildSnippets(model, getClassicalClientName(subClient)), ); } diff --git a/packages/typespec-ts/src/interfaces.ts b/packages/typespec-ts/src/interfaces.ts index 2a4ddbf000..33df5d95fb 100644 --- a/packages/typespec-ts/src/interfaces.ts +++ b/packages/typespec-ts/src/interfaces.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export interface RLCModel { +export interface ClientModel { libraryName: string; srcPath: string; paths: Paths; importInfo: ImportInfo; - options?: RLCOptions; + options?: ClientOptions; schemas: Schema[]; apiVersionInfo?: ApiVersionInfo; parameters?: OperationParameter[]; @@ -13,7 +13,7 @@ export interface RLCModel { helperDetails?: HelperFunctionDetails; urlInfo?: UrlInfo; telemetryOptions?: TelemetryInfo; - sampleGroups?: RLCSampleGroup[]; + sampleGroups?: SampleGroup[]; rlcSourceDir?: string; } @@ -60,18 +60,18 @@ export interface ImportMetadata { /** * A group of samples in operation_id level and they are used to generate in a sample file */ -export interface RLCSampleGroup { +export interface SampleGroup { filename: string; clientPackageName: string; defaultFactoryName: string; - samples: RLCSampleDetail[]; + samples: SampleDetail[]; importedTypes?: string[]; } /** * An independent sample detail and it will be wrapped as a func */ -export interface RLCSampleDetail { +export interface SampleDetail { /** * metadata for comments */ @@ -190,7 +190,7 @@ export interface OperationLroDetail { precedence?: number; } -export interface RLCOptions { +export interface ClientOptions { /** * Whether to include response headers in the generated response types. If true, the generated response types will include headers as properties. */ @@ -398,7 +398,7 @@ export type ResponseHeaderSchema = Schema; export type ResponseBodySchema = Schema; export type ContentBuilder = { - (model: RLCModel): File | File[] | undefined; + (model: ClientModel): File | File[] | undefined; }; export type SampleParameterPosition = "client" | "path" | "method"; diff --git a/packages/typespec-ts/src/lib.ts b/packages/typespec-ts/src/lib.ts index 7429fa71f3..7df32d7b58 100644 --- a/packages/typespec-ts/src/lib.ts +++ b/packages/typespec-ts/src/lib.ts @@ -82,7 +82,7 @@ export interface EmitterOptions { "generate-react-native-target"?: boolean; } -export const RLCOptionsSchema: JSONSchemaType = { +export const EmitterOptionsSchema: JSONSchemaType = { type: "object", additionalProperties: true, properties: { @@ -561,7 +561,7 @@ const libDef = { }, }, emitter: { - options: RLCOptionsSchema, + options: EmitterOptionsSchema, }, } as const; diff --git a/packages/typespec-ts/src/meta-tree.ts b/packages/typespec-ts/src/meta-tree.ts index 97129a3ab2..108d4d15aa 100644 --- a/packages/typespec-ts/src/meta-tree.ts +++ b/packages/typespec-ts/src/meta-tree.ts @@ -1,8 +1,8 @@ import { Type } from "@typespec/compiler"; import { Schema as RlcType } from "./interfaces.js"; -export interface RlcTypeMetadata { +export interface ClientTypeMetadata { rlcType: RlcType; } -export type RlcMetaTree = Map; +export type ClientTypeMetaTree = Map; diff --git a/packages/typespec-ts/src/metadata/build-api-extractor-config.ts b/packages/typespec-ts/src/metadata/build-api-extractor-config.ts index 51d76a71d4..96002f9d98 100644 --- a/packages/typespec-ts/src/metadata/build-api-extractor-config.ts +++ b/packages/typespec-ts/src/metadata/build-api-extractor-config.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { Project } from "ts-morph"; -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; -export function buildApiExtractorConfig(_model: RLCModel) { +export function buildApiExtractorConfig(_model: ClientModel) { const project = new Project({ useInMemoryFileSystem: true }); const config = { diff --git a/packages/typespec-ts/src/metadata/build-changelog-file.ts b/packages/typespec-ts/src/metadata/build-changelog-file.ts index 32b0b1a1c6..3200f278ef 100644 --- a/packages/typespec-ts/src/metadata/build-changelog-file.ts +++ b/packages/typespec-ts/src/metadata/build-changelog-file.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; -function getPackageVersion(model: RLCModel): string { +function getPackageVersion(model: ClientModel): string { return model.options?.packageDetails?.version ?? "1.0.0-beta.1"; } -export function buildChangelogFile(model: RLCModel) { +export function buildChangelogFile(model: ClientModel) { const version = getPackageVersion(model); const content = `# Release History diff --git a/packages/typespec-ts/src/metadata/build-es-lint-config.ts b/packages/typespec-ts/src/metadata/build-es-lint-config.ts index 8b14d2d7cb..573f0042fe 100644 --- a/packages/typespec-ts/src/metadata/build-es-lint-config.ts +++ b/packages/typespec-ts/src/metadata/build-es-lint-config.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { Project } from "ts-morph"; -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; const esLintConfigEsmAzureSdk = `import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; @@ -31,7 +31,7 @@ export default [ ]; `; -export function buildEsLintConfig(_model: RLCModel) { +export function buildEsLintConfig(_model: ClientModel) { const project = new Project({ useInMemoryFileSystem: true }); const filePath = "eslint.config.mjs"; diff --git a/packages/typespec-ts/src/metadata/build-package-file.ts b/packages/typespec-ts/src/metadata/build-package-file.ts index ff8be9653a..c3b2b33fe5 100644 --- a/packages/typespec-ts/src/metadata/build-package-file.ts +++ b/packages/typespec-ts/src/metadata/build-package-file.ts @@ -3,7 +3,7 @@ import { Project, SourceFile } from "ts-morph"; import { hasPollingOperations } from "../utils/operation-helpers.js"; -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; import { buildAzureMonorepoPackage } from "./package-json/build-azure-monorepo-package.js"; import { PackageCommonInfoConfig, resolveWarpExports } from "./package-json/package-common.js"; import { getPackageName } from "./utils.js"; @@ -15,7 +15,7 @@ interface PackageFileOptions { } export function buildPackageFile( - model: RLCModel, + model: ClientModel, { exports, dependencies, clientContextPaths }: PackageFileOptions = {}, ) { const config: PackageCommonInfoConfig = { @@ -66,7 +66,7 @@ export function buildPackageFile( * - Updates `//metadata.constantPaths` when `clientContextPaths` is provided. */ export function updatePackageFile( - model: RLCModel, + model: ClientModel, existingFilePathOrContent: string | Record, { exports, clientContextPaths }: PackageFileOptions = {}, ) { @@ -167,11 +167,11 @@ export function updatePackageFile( }; } -function getPackageVersion(model: RLCModel): string { +function getPackageVersion(model: ClientModel): string { return model.options?.packageDetails?.version ?? "1.0.0-beta.1"; } -function getDescription(model: RLCModel): string { +function getDescription(model: ClientModel): string { const description = model.options?.packageDetails?.description; if (!description) { return `A generated SDK for ${model.libraryName}.`; diff --git a/packages/typespec-ts/src/metadata/build-readme-file.ts b/packages/typespec-ts/src/metadata/build-readme-file.ts index 4fcf02114f..d3159150a3 100644 --- a/packages/typespec-ts/src/metadata/build-readme-file.ts +++ b/packages/typespec-ts/src/metadata/build-readme-file.ts @@ -6,7 +6,7 @@ import hbs from "handlebars"; import { getClientName } from "../utils/name-constructors.js"; import { NameType, normalizeName } from "../utils/name-utils.js"; -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; const azureReadmeModularTemplate = `# {{ clientDescriptiveName }} library for JavaScript @@ -269,7 +269,7 @@ interface Metadata { hasSubscriptionId?: boolean; } -export function buildReadmeFile(model: RLCModel) { +export function buildReadmeFile(model: ClientModel) { const metadata = createMetadata(model) ?? {}; const readmeFileContents = hbs.compile( model.options ? azureReadmeModularTemplate : nonBrandedReadmeTemplate, @@ -281,7 +281,7 @@ export function buildReadmeFile(model: RLCModel) { }; } -export function hasClientNameChanged(model: RLCModel, existingReadmeContent: string): boolean { +export function hasClientNameChanged(model: ClientModel, existingReadmeContent: string): boolean { try { const importMatch = existingReadmeContent.match( /import\s*\{\s*([A-Za-z0-9_]+)\s*\}\s*from\s*["'][^"']*["']/, @@ -295,7 +295,7 @@ export function hasClientNameChanged(model: RLCModel, existingReadmeContent: str } export function updateReadmeFile( - model: RLCModel, + model: ClientModel, existingReadmeContent: string, ): { path: string; content: string } | undefined { try { @@ -324,7 +324,7 @@ export function updateReadmeFile( * @param codeModel - include the client details * @returns inferred metadata about the service, the package, and the client */ -function createMetadata(model: RLCModel): Metadata | undefined { +function createMetadata(model: ClientModel): Metadata | undefined { if (!model.options || !model.options.packageDetails) { return; } @@ -379,7 +379,7 @@ function createMetadata(model: RLCModel): Metadata | undefined { }; } -function getServiceName(model: RLCModel) { +function getServiceName(model: ClientModel) { const azureHuh = model?.options?.packageDetails?.scopeName === "azure" || model?.options?.packageDetails?.scopeName === "azure-rest"; diff --git a/packages/typespec-ts/src/metadata/build-sample-env-file.ts b/packages/typespec-ts/src/metadata/build-sample-env-file.ts index 11c27f1e13..fd345ef52e 100644 --- a/packages/typespec-ts/src/metadata/build-sample-env-file.ts +++ b/packages/typespec-ts/src/metadata/build-sample-env-file.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; const sampleEnvText = ` # Feel free to add your own environment variables. `; -export function buildSampleEnvFile(model: RLCModel) { +export function buildSampleEnvFile(model: ClientModel) { if (model.options?.generateMetadata === true || model.options?.generateSample === true) { const filePath = "sample.env"; return { diff --git a/packages/typespec-ts/src/metadata/build-test-config.ts b/packages/typespec-ts/src/metadata/build-test-config.ts index 09986af760..5f10287a72 100644 --- a/packages/typespec-ts/src/metadata/build-test-config.ts +++ b/packages/typespec-ts/src/metadata/build-test-config.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; import { getPackageName } from "./utils.js"; -function shouldGenerateTestConfig(model: RLCModel): boolean { +function shouldGenerateTestConfig(model: ClientModel): boolean { return !(model.options?.generateMetadata === false || model.options?.generateTest === false); } /** * Builds config/tsconfig.test.browser.json — extends eng/tsconfigs/test.browser.json */ -export function buildTestBrowserTsConfig(model: RLCModel) { +export function buildTestBrowserTsConfig(model: ClientModel) { if (!shouldGenerateTestConfig(model)) { return; } @@ -40,7 +40,7 @@ export function buildTestBrowserTsConfig(model: RLCModel) { /** * Builds config/tsconfig.test.node.json — extends eng/tsconfigs/test.node.json */ -export function buildTestNodeTsConfig(model: RLCModel) { +export function buildTestNodeTsConfig(model: ClientModel) { if (!shouldGenerateTestConfig(model)) { return; } diff --git a/packages/typespec-ts/src/metadata/build-ts-config.ts b/packages/typespec-ts/src/metadata/build-ts-config.ts index a1058de16d..66c64f42fe 100644 --- a/packages/typespec-ts/src/metadata/build-ts-config.ts +++ b/packages/typespec-ts/src/metadata/build-ts-config.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { Project } from "ts-morph"; -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; /** * Builds the root tsconfig.json. @@ -10,7 +10,7 @@ import { RLCModel } from "../interfaces.js"; * Emits project references pointing into the `config/` subfolder * (following the eng/tsconfigs pattern). */ -export function buildTsConfig(model: RLCModel) { +export function buildTsConfig(model: ClientModel) { const { generateTest, generateSample, generateReactNativeTarget } = model.options || {}; const project = new Project({ useInMemoryFileSystem: true }); @@ -123,7 +123,7 @@ export function buildTsSrcCjsConfig() { /** * Builds config/tsconfig.samples.json — extends eng/tsconfigs/samples.json */ -export function buildTsSampleConfig(model: RLCModel) { +export function buildTsSampleConfig(model: ClientModel) { const { packageDetails } = model.options || {}; const clientPackageName = packageDetails?.name ?? ""; return { diff --git a/packages/typespec-ts/src/metadata/build-vitest-config.ts b/packages/typespec-ts/src/metadata/build-vitest-config.ts index a93091795b..5d3ebb2096 100644 --- a/packages/typespec-ts/src/metadata/build-vitest-config.ts +++ b/packages/typespec-ts/src/metadata/build-vitest-config.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; const nodeConfig = `import viteConfig from "../../../vitest.shared.config.ts"; @@ -11,7 +11,7 @@ export default viteConfig; const browserConfig = `export { default } from "../../../eng/vitestconfigs/browser.config.ts"; `; -export function buildVitestConfig(model: RLCModel, platform: "browser" | "node") { +export function buildVitestConfig(model: ClientModel, platform: "browser" | "node") { if (model.options?.generateMetadata === false || model.options?.generateTest === false) { return; } diff --git a/packages/typespec-ts/src/metadata/build-warp-config.ts b/packages/typespec-ts/src/metadata/build-warp-config.ts index 50c38ca03f..0871623a25 100644 --- a/packages/typespec-ts/src/metadata/build-warp-config.ts +++ b/packages/typespec-ts/src/metadata/build-warp-config.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; export interface WarpConfigOptions { /** Source-level exports, e.g. { ".": "./src/index.ts", "./models": "./src/models/index.ts" } */ @@ -67,7 +67,7 @@ targets: * By default, react-native target is NOT included. Set `generateReactNativeTarget: true` * in options to include it. */ -export function buildWarpConfig(model: RLCModel, { exports }: WarpConfigOptions = {}) { +export function buildWarpConfig(model: ClientModel, { exports }: WarpConfigOptions = {}) { const allExports: Record = { ...BASE_EXPORTS, ...exports, diff --git a/packages/typespec-ts/src/metadata/test/build-recorded-client.ts b/packages/typespec-ts/src/metadata/test/build-recorded-client.ts index 29f26e145c..24dd499e15 100644 --- a/packages/typespec-ts/src/metadata/test/build-recorded-client.ts +++ b/packages/typespec-ts/src/metadata/test/build-recorded-client.ts @@ -1,10 +1,10 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; -import { RLCModel } from "../../interfaces.js"; +import { ClientModel } from "../../interfaces.js"; import { recordedClientContent } from "./template.js"; -export function buildRecordedClientFile(_model: RLCModel) { +export function buildRecordedClientFile(_model: ClientModel) { const recordedClientFileContents = hbs.compile(recordedClientContent, { noEscape: true, }); diff --git a/packages/typespec-ts/src/metadata/test/build-sample-test.ts b/packages/typespec-ts/src/metadata/test/build-sample-test.ts index 64e708a786..3384ed61b8 100644 --- a/packages/typespec-ts/src/metadata/test/build-sample-test.ts +++ b/packages/typespec-ts/src/metadata/test/build-sample-test.ts @@ -1,10 +1,10 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; -import { RLCModel } from "../../interfaces.js"; +import { ClientModel } from "../../interfaces.js"; import { sampleTestContent } from "./template.js"; -export function buildSampleTest(_model: RLCModel) { +export function buildSampleTest(_model: ClientModel) { return { path: "test/public/sampleTest.spec.ts", content: hbs.compile(sampleTestContent, { noEscape: true })({}), diff --git a/packages/typespec-ts/src/metadata/test/build-snippets.ts b/packages/typespec-ts/src/metadata/test/build-snippets.ts index d7bbe4de85..fe02aa644d 100644 --- a/packages/typespec-ts/src/metadata/test/build-snippets.ts +++ b/packages/typespec-ts/src/metadata/test/build-snippets.ts @@ -2,10 +2,10 @@ // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; import { getClientName } from "../../utils/name-constructors.js"; -import { RLCModel } from "../../interfaces.js"; +import { ClientModel } from "../../interfaces.js"; import { snippetsContent } from "./template.js"; -export function buildSnippets(model: RLCModel, clientName?: string) { +export function buildSnippets(model: ClientModel, clientName?: string) { // to keep the same config for azure scope in buildReadmeFile.ts if ( (model?.options?.packageDetails?.scopeName === "azure" || diff --git a/packages/typespec-ts/src/metadata/utils.ts b/packages/typespec-ts/src/metadata/utils.ts index bf5bddda62..e40748fd85 100644 --- a/packages/typespec-ts/src/metadata/utils.ts +++ b/packages/typespec-ts/src/metadata/utils.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; -export function getPackageName(model: RLCModel): string { +export function getPackageName(model: ClientModel): string { return model.options?.packageDetails?.name ?? model.libraryName; } diff --git a/packages/typespec-ts/src/modular/build-classical-client.ts b/packages/typespec-ts/src/modular/build-classical-client.ts index 95ff512262..55c07d8115 100644 --- a/packages/typespec-ts/src/modular/build-classical-client.ts +++ b/packages/typespec-ts/src/modular/build-classical-client.ts @@ -19,7 +19,7 @@ import { useContext } from "../context-manager.js"; import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; import { refkey } from "../framework/refkey.js"; -import { getModularClientOptions, isRLCMultiEndpoint } from "../utils/client-utils.js"; +import { getModularClientOptions, isMultiEndpointClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap, isTenantLevelOperation } from "../utils/operation-util.js"; import { AzurePollingDependencies } from "./external-dependencies.js"; @@ -68,7 +68,7 @@ export function buildClassicalClient( }); // Add the private client member. This will be the client context from /api - if (isRLCMultiEndpoint(dpgContext)) { + if (isMultiEndpointClient(dpgContext)) { clientClass.addProperty({ name: "_client", type: `Client.${rlcClientName}`, diff --git a/packages/typespec-ts/src/modular/build-operations.ts b/packages/typespec-ts/src/modular/build-operations.ts index c93c915ea0..2f070726a1 100644 --- a/packages/typespec-ts/src/modular/build-operations.ts +++ b/packages/typespec-ts/src/modular/build-operations.ts @@ -22,7 +22,7 @@ import { addDeclaration } from "../framework/declaration.js"; import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; import { refkey } from "../framework/refkey.js"; -import { getModularClientOptions, isRLCMultiEndpoint } from "../utils/client-utils.js"; +import { getModularClientOptions, isMultiEndpointClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap, @@ -49,7 +49,7 @@ export function buildOperationFiles( const [_, client] = clientMap; const operationFiles: Set = new Set(); const { subfolder, rlcClientName } = getModularClientOptions(clientMap); - const isMultiEndpoint = isRLCMultiEndpoint(dpgContext); + const isMultiEndpoint = isMultiEndpointClient(dpgContext); const clientType = isMultiEndpoint ? `Client.${rlcClientName}` : "Client"; const methodMap = getMethodHierarchiesMap(dpgContext, client); for (const [prefixKey, operations] of methodMap) { diff --git a/packages/typespec-ts/src/modular/emit-samples.ts b/packages/typespec-ts/src/modular/emit-samples.ts index 60d4d7fc18..5ff30a4f33 100644 --- a/packages/typespec-ts/src/modular/emit-samples.ts +++ b/packages/typespec-ts/src/modular/emit-samples.ts @@ -14,7 +14,7 @@ import { useContext } from "../context-manager.js"; import { resolveReference } from "../framework/reference.js"; import { reportDiagnostic } from "../index.js"; import { AzureIdentityDependencies } from "../modular/external-dependencies.js"; -import { getSubscriptionId } from "../transform/transfrom-rlc-options.js"; +import { getSubscriptionId } from "../transform/transform-client-options.js"; import { hasKeyCredential, hasTokenCredential } from "../utils/credential-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { diff --git a/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts b/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts index 9867f68fb2..876d510e42 100644 --- a/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts @@ -12,7 +12,7 @@ import { joinPaths } from "@typespec/compiler"; import { SourceFile } from "ts-morph"; import { useContext } from "../../context-manager.js"; import { resolveReference } from "../../framework/reference.js"; -import { getSubscriptionId } from "../../transform/transfrom-rlc-options.js"; +import { getSubscriptionId } from "../../transform/transform-client-options.js"; import { hasKeyCredential, hasTokenCredential } from "../../utils/credential-utils.js"; import { SdkContext } from "../../utils/interfaces.js"; import { getMethodHierarchiesMap, ServiceOperation } from "../../utils/operation-util.js"; diff --git a/packages/typespec-ts/src/modular/interfaces.ts b/packages/typespec-ts/src/modular/interfaces.ts index 996b9861dd..49df8aa9ca 100644 --- a/packages/typespec-ts/src/modular/interfaces.ts +++ b/packages/typespec-ts/src/modular/interfaces.ts @@ -1,4 +1,4 @@ -import { RLCOptions } from "../interfaces.js"; +import { ClientOptions } from "../interfaces.js"; export interface ModularOptions { sourceRoot: string; @@ -6,7 +6,7 @@ export interface ModularOptions { experimentalExtensibleEnums: boolean; } export interface ModularEmitterOptions { - options: RLCOptions; + options: ClientOptions; modularOptions: ModularOptions; } diff --git a/packages/typespec-ts/src/transform/transform-api-version-info.ts b/packages/typespec-ts/src/transform/transform-api-version-info.ts index 059f53d733..e8358fcdd2 100644 --- a/packages/typespec-ts/src/transform/transform-api-version-info.ts +++ b/packages/typespec-ts/src/transform/transform-api-version-info.ts @@ -3,7 +3,7 @@ import { isApiVersion, SdkClient, } from "@azure-tools/typespec-client-generator-core"; -import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultApiVersionString, getSchemaForType, trimUsage } from "../utils/model-utils.js"; import { ApiVersionInfo, ApiVersionPosition, SchemaContext, UrlInfo } from "../interfaces.js"; @@ -50,7 +50,7 @@ export function getOperationApiVersion( const required = new Set(); dpgContext.hasApiVersionInClient = true; let hasApiVersionInOperation: boolean; - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { hasApiVersionInOperation = false; const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation diff --git a/packages/typespec-ts/src/transform/transfrom-rlc-options.ts b/packages/typespec-ts/src/transform/transform-client-options.ts similarity index 96% rename from packages/typespec-ts/src/transform/transfrom-rlc-options.ts rename to packages/typespec-ts/src/transform/transform-client-options.ts index a165e1a5c2..27e7809786 100644 --- a/packages/typespec-ts/src/transform/transfrom-rlc-options.ts +++ b/packages/typespec-ts/src/transform/transform-client-options.ts @@ -3,26 +3,26 @@ import { getDoc, NoTarget, Program } from "@typespec/compiler"; import { getAuthentication } from "@typespec/http"; import { EmitterOptions, reportDiagnostic } from "../lib.js"; import { getClientParameters } from "../modular/helpers/client-helpers.js"; -import { getRLCClients, listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { getClients, listOperationsUnderClient } from "../utils/client-utils.js"; import { getSupportedHttpAuth } from "../utils/credential-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultService } from "../utils/model-utils.js"; import { detectModelConflicts } from "../utils/namespace-utils.js"; import { getOperationName } from "../utils/operation-util.js"; import { NameType, normalizeName, pascalCase } from "../utils/name-utils.js"; -import { PackageDetails, RLCOptions, ServiceInfo } from "../interfaces.js"; +import { PackageDetails, ClientOptions, ServiceInfo } from "../interfaces.js"; -export function transformRLCOptions( +export function transformClientOptions( emitterOptions: EmitterOptions, dpgContext: SdkContext, -): RLCOptions { +): ClientOptions { // Extract the options from emitter option const options = extractRLCOptions( dpgContext, emitterOptions, dpgContext.generationPathDetail?.rootDir ?? "", ); - const batch = getRLCClients(dpgContext); + const batch = getClients(dpgContext); options.batch = batch; return options; } @@ -30,7 +30,7 @@ function extractRLCOptions( dpgContext: SdkContext, emitterOptions: EmitterOptions, generationRootDir: string, -): RLCOptions { +): ClientOptions { const program = dpgContext.program; const packageDetails = getPackageDetails(program, emitterOptions); const serviceInfo = getServiceInfo(program); @@ -101,7 +101,7 @@ function processAuth(program: Program) { if (!authorization || !authorization.options) { return undefined; } - const securityInfo: RLCOptions = {}; + const securityInfo: ClientOptions = {}; for (const auth of getSupportedHttpAuth(program, authorization)) { switch (auth.type) { case "http": @@ -193,11 +193,11 @@ function getClearOutputFolder(emitterOptions: EmitterOptions) { } function detectIfNameConflicts(dpgContext: SdkContext) { - const clients = getRLCClients(dpgContext); + const clients = getClients(dpgContext); for (const client of clients) { // only consider it's conflict when there are conflicts in the same client const nameSet = new Set(); - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); const name = getOperationName(dpgContext, route.operation); if (nameSet.has(name)) { diff --git a/packages/typespec-ts/src/transform/transform-helper-function-details.ts b/packages/typespec-ts/src/transform/transform-helper-function-details.ts index 4fc34bd4b2..c60873855c 100644 --- a/packages/typespec-ts/src/transform/transform-helper-function-details.ts +++ b/packages/typespec-ts/src/transform/transform-helper-function-details.ts @@ -1,5 +1,5 @@ import { getHttpOperationWithCache, SdkClient } from "@azure-tools/typespec-client-generator-core"; -import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getCollectionFormat } from "../utils/model-utils.js"; import { @@ -34,7 +34,7 @@ function extractClientPageDetails(client: SdkClient, dpgContext: SdkContext) { } const nextLinks = new Set(["nextLink"]); const itemNames = new Set(["value"]); - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation if (route.overloads && route.overloads?.length > 0) { @@ -61,7 +61,7 @@ function extractClientPageDetails(client: SdkClient, dpgContext: SdkContext) { function extractSpecialSerializeInfo(client: SdkClient, dpgContext: SdkContext) { let hasMultiCollection = false; let hasCsvCollection = false; - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); route.parameters.parameters.forEach((parameter) => { const format = getCollectionFormat(dpgContext, parameter as any); diff --git a/packages/typespec-ts/src/transform/transform-parameters.ts b/packages/typespec-ts/src/transform/transform-parameters.ts index 628d54bf36..4bcdd7f3dc 100644 --- a/packages/typespec-ts/src/transform/transform-parameters.ts +++ b/packages/typespec-ts/src/transform/transform-parameters.ts @@ -9,7 +9,7 @@ import { import { NoTarget, Type, isVoidType } from "@typespec/compiler"; import { HttpOperation, HttpOperationParameter, HttpOperationParameters } from "@typespec/http"; import { reportDiagnostic } from "../lib.js"; -import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { KnownMediaType, @@ -50,7 +50,7 @@ export function transformToParameterTypes( ): OperationParameter[] { const rlcParameters: OperationParameter[] = []; const outputImportedSet = new Set(); - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation if (route.overloads && route.overloads?.length > 0) { diff --git a/packages/typespec-ts/src/transform/transform-paths.ts b/packages/typespec-ts/src/transform/transform-paths.ts index ad26b95358..19dd4a8442 100644 --- a/packages/typespec-ts/src/transform/transform-paths.ts +++ b/packages/typespec-ts/src/transform/transform-paths.ts @@ -20,7 +20,7 @@ import { } from "../utils/operation-util.js"; import { getDoc } from "@typespec/compiler"; -import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getParameterSerializationInfo } from "../utils/parameter-utils.js"; import { Imports, OperationMethod, PathMetadata, Paths, SchemaContext } from "../interfaces.js"; @@ -33,7 +33,7 @@ export function transformPaths( ): Paths { const pathParamsImportedSet = new Set(); const paths: Paths = {}; - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation if (route.overloads && route.overloads?.length > 0) { diff --git a/packages/typespec-ts/src/transform/transform-responses.ts b/packages/typespec-ts/src/transform/transform-responses.ts index e55097ac44..14d9a26049 100644 --- a/packages/typespec-ts/src/transform/transform-responses.ts +++ b/packages/typespec-ts/src/transform/transform-responses.ts @@ -4,7 +4,7 @@ import { getHttpOperationWithCache, SdkClient } from "@azure-tools/typespec-client-generator-core"; import { getDoc, isVoidType } from "@typespec/compiler"; import { HttpOperation, HttpOperationResponse } from "@typespec/http"; -import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getBinaryType, @@ -30,7 +30,7 @@ export function transformToResponseTypes( ): OperationResponse[] { const rlcResponses: OperationResponse[] = []; const inputImportedSet = new Set(); - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation if (route.overloads && route.overloads?.length > 0) { diff --git a/packages/typespec-ts/src/transform/transform-schemas.ts b/packages/typespec-ts/src/transform/transform-schemas.ts index 408db391bc..10a6a65df1 100644 --- a/packages/typespec-ts/src/transform/transform-schemas.ts +++ b/packages/typespec-ts/src/transform/transform-schemas.ts @@ -15,7 +15,7 @@ import { } from "../utils/model-utils.js"; import { useContext } from "../context-manager.js"; -import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { SchemaContext } from "../interfaces.js"; @@ -27,7 +27,7 @@ export function transformSchemas(client: SdkClient, dpgContext: SdkContext) { const usageMap = new Map(); const requestBodySet = new Set(); const contentTypeMap = new Map(); - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation if (route.overloads && route.overloads?.length > 0) { diff --git a/packages/typespec-ts/src/transform/transform-telemetry-info.ts b/packages/typespec-ts/src/transform/transform-telemetry-info.ts index 387c9e90c6..ffa4872a96 100644 --- a/packages/typespec-ts/src/transform/transform-telemetry-info.ts +++ b/packages/typespec-ts/src/transform/transform-telemetry-info.ts @@ -3,7 +3,7 @@ import { SdkClient, SdkContext, } from "@azure-tools/typespec-client-generator-core"; -import { listOperationsUnderRLCClient } from "../utils/client-utils.js"; +import { listOperationsUnderClient } from "../utils/client-utils.js"; import { getCustomRequestHeaderNameForOperation } from "../utils/operation-util.js"; import { TelemetryInfo } from "../interfaces.js"; @@ -21,7 +21,7 @@ export function transformTelemetryInfo( } function getCustomRequestHeaderNameForClient(dpgContext: SdkContext, client: SdkClient) { - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const headerName = getCustomRequestHeaderNameForOperation( getHttpOperationWithCache(dpgContext, op), ); diff --git a/packages/typespec-ts/src/transform/transform.ts b/packages/typespec-ts/src/transform/transform.ts index 90e86dff12..00ba747767 100644 --- a/packages/typespec-ts/src/transform/transform.ts +++ b/packages/typespec-ts/src/transform/transform.ts @@ -22,15 +22,15 @@ import { transformToResponseTypes } from "./transform-responses.js"; import { transformSchemas } from "./transform-schemas.js"; import { transformTelemetryInfo } from "./transform-telemetry-info.js"; import { buildRuntimeImports, initInternalImports } from "../utils/imports-util.js"; -import { Imports, OperationParameter, OperationResponse, PathParameter, Paths, RLCModel, RLCOptions, Schema, SchemaContext, UrlInfo } from "../interfaces.js"; +import { Imports, OperationParameter, OperationResponse, PathParameter, Paths, ClientModel, ClientOptions, Schema, SchemaContext, UrlInfo } from "../interfaces.js"; import { NameType, normalizeName } from "../utils/name-utils.js"; -export async function transformRLCModel( +export async function transformClientModel( client: SdkClient, dpgContext: SdkContext, -): Promise { +): Promise { const program = dpgContext.program; - const options: RLCOptions = dpgContext.rlcOptions!; + const options: ClientOptions = dpgContext.rlcOptions!; const rlcSourceDir = dpgContext.generationPathDetail?.rlcSourcesDir; const srcPath = joinPaths( dpgContext.generationPathDetail?.rlcSourcesDir ?? "", @@ -58,7 +58,7 @@ export async function transformRLCModel( helperDetails.clientLroOverload = getClientLroOverload(paths); const telemetryOptions = transformTelemetryInfo(client, dpgContext); - const model: RLCModel = { + const model: ClientModel = { srcPath, libraryName, paths, diff --git a/packages/typespec-ts/src/utils/client-utils.ts b/packages/typespec-ts/src/utils/client-utils.ts index 0e02efc10f..261642e9af 100644 --- a/packages/typespec-ts/src/utils/client-utils.ts +++ b/packages/typespec-ts/src/utils/client-utils.ts @@ -18,7 +18,7 @@ import { ModularClientOptions } from "../modular/interfaces.js"; import { SdkContext } from "./interfaces.js"; import { NameType, normalizeName } from "./name-utils.js"; -export function getRLCClients(dpgContext: SdkContext): SdkClient[] { +export function getClients(dpgContext: SdkContext): SdkClient[] { const clients = listClients(dpgContext); const rawServiceNamespaces = dpgContext.allServiceNamespaces ?? listAllServiceNamespaces(dpgContext); @@ -79,7 +79,7 @@ export function getRLCClients(dpgContext: SdkContext): SdkClient[] { }); } -export function listOperationsUnderRLCClient(client: SdkClient): Operation[] { +export function listOperationsUnderClient(client: SdkClient): Operation[] { const operations = []; const serviceArray = client.services; const queue: (Namespace | Interface)[] = [...serviceArray]; @@ -110,8 +110,8 @@ export function listOperationsUnderRLCClient(client: SdkClient): Operation[] { return operations; } -export function isRLCMultiEndpoint(dpgContext: SdkContext): boolean { - return getRLCClients(dpgContext).length > 1; +export function isMultiEndpointClient(dpgContext: SdkContext): boolean { + return getClients(dpgContext).length > 1; } export function getModularClientOptions(clientMap: [string[], SdkClientType]) { diff --git a/packages/typespec-ts/src/utils/emit-util.ts b/packages/typespec-ts/src/utils/emit-util.ts index 294305717c..50e784b609 100644 --- a/packages/typespec-ts/src/utils/emit-util.ts +++ b/packages/typespec-ts/src/utils/emit-util.ts @@ -4,19 +4,19 @@ import prettierPluginBabel from "prettier/plugins/babel"; import prettierPluginEstree from "prettier/plugins/estree"; import prettierPluginTypescript from "prettier/plugins/typescript"; import { prettierJSONOptions, prettierTypeScriptOptions, reportDiagnostic } from "../lib.js"; -import { ContentBuilder, File, RLCModel } from "../interfaces.js"; +import { ContentBuilder, File, ClientModel } from "../interfaces.js"; export async function emitContentByBuilder( program: Program, builderFnOrList: ContentBuilder | ContentBuilder[], - rlcModels: RLCModel, + clientModels: ClientModel, emitterOutputDir?: string, ) { if (!Array.isArray(builderFnOrList)) { builderFnOrList = [builderFnOrList]; } for (const builderFn of builderFnOrList) { - let contentFiles: File[] | File | undefined = builderFn(rlcModels); + let contentFiles: File[] | File | undefined = builderFn(clientModels); if (!contentFiles) { continue; } diff --git a/packages/typespec-ts/src/utils/interfaces.ts b/packages/typespec-ts/src/utils/interfaces.ts index 241fdbe61d..8b258a60d3 100644 --- a/packages/typespec-ts/src/utils/interfaces.ts +++ b/packages/typespec-ts/src/utils/interfaces.ts @@ -1,10 +1,10 @@ import { SdkContext as TCGCSdkContext } from "@azure-tools/typespec-client-generator-core"; import { ModelProperty, Namespace } from "@typespec/compiler"; import { KnownMediaType } from "./media-types.js"; -import { RLCOptions, SchemaContext } from "../interfaces.js"; +import { ClientOptions, SchemaContext } from "../interfaces.js"; export interface SdkContext extends TCGCSdkContext { - rlcOptions?: RLCOptions; + rlcOptions?: ClientOptions; generationPathDetail?: GenerationDirDetail; hasApiVersionInClient?: boolean; allServiceNamespaces?: Namespace[]; diff --git a/packages/typespec-ts/src/utils/name-constructors.ts b/packages/typespec-ts/src/utils/name-constructors.ts index a613fc5ece..e2c80997ad 100644 --- a/packages/typespec-ts/src/utils/name-constructors.ts +++ b/packages/typespec-ts/src/utils/name-constructors.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { RLCModel } from "../interfaces.js"; +import { ClientModel } from "../interfaces.js"; import { NameType, normalizeName } from "./name-utils.js"; /** @@ -76,7 +76,7 @@ export function getParameterTypeName(baseNameOrOperationGroup: string, operation return normalizeName(`${baseNameOrOperationGroup}_Parameters`, NameType.Interface); } -export function getClientName(model: RLCModel) { +export function getClientName(model: ClientModel) { return model.libraryName; } diff --git a/packages/typespec-ts/src/utils/operation-helpers.ts b/packages/typespec-ts/src/utils/operation-helpers.ts index face6caa11..89bcfe74c5 100644 --- a/packages/typespec-ts/src/utils/operation-helpers.ts +++ b/packages/typespec-ts/src/utils/operation-helpers.ts @@ -7,7 +7,7 @@ import { ObjectSchema, ParameterMetadata, PathParameter, - RLCModel, + ClientModel, Schema, SchemaContext, } from "../interfaces.js"; @@ -59,35 +59,35 @@ export function getPathParamDefinitions( }); } -export function hasPagingOperations(model: RLCModel) { +export function hasPagingOperations(model: ClientModel) { return Boolean(model.helperDetails?.hasPaging); } -export function hasPollingOperations(model: RLCModel) { +export function hasPollingOperations(model: ClientModel) { return Boolean(model.helperDetails?.hasLongRunning); } -export function hasMultiCollection(model: RLCModel) { +export function hasMultiCollection(model: ClientModel) { return Boolean(model.helperDetails?.hasMultiCollection); } -export function hasPipeCollection(model: RLCModel) { +export function hasPipeCollection(model: ClientModel) { return Boolean(model.helperDetails?.hasPipeCollection); } -export function hasSsvCollection(model: RLCModel) { +export function hasSsvCollection(model: ClientModel) { return Boolean(model.helperDetails?.hasSsvCollection); } -export function hasTsvCollection(model: RLCModel) { +export function hasTsvCollection(model: ClientModel) { return Boolean(model.helperDetails?.hasTsvCollection); } -export function hasCsvCollection(model: RLCModel) { +export function hasCsvCollection(model: ClientModel) { return Boolean(model.helperDetails?.hasCsvCollection); } -export function hasUnexpectedHelper(model: RLCModel) { +export function hasUnexpectedHelper(model: ClientModel) { const pathDictionary = model.paths; for (const details of Object.values(pathDictionary)) { for (const methodDetails of Object.values(details.methods)) { @@ -106,14 +106,14 @@ export function hasUnexpectedHelper(model: RLCModel) { return false; } -export function hasInputModels(model: RLCModel) { +export function hasInputModels(model: ClientModel) { return hasSchemaContextObject(model, [SchemaContext.Input]); } -export function hasOutputModels(model: RLCModel) { +export function hasOutputModels(model: ClientModel) { return hasSchemaContextObject(model, [SchemaContext.Output, SchemaContext.Exception]); } -function hasSchemaContextObject(model: RLCModel, schemaUsage: SchemaContext[]) { +function hasSchemaContextObject(model: ClientModel, schemaUsage: SchemaContext[]) { const objectSchemas: ObjectSchema[] = (model.schemas ?? []).filter( (o) => isObjectSchema(o) && (o as ObjectSchema).usage?.some((u) => schemaUsage.includes(u)), ); diff --git a/packages/typespec-ts/src/utils/operation-util.ts b/packages/typespec-ts/src/utils/operation-util.ts index afc775f61b..a4efaa732a 100644 --- a/packages/typespec-ts/src/utils/operation-util.ts +++ b/packages/typespec-ts/src/utils/operation-util.ts @@ -28,7 +28,7 @@ import { import { resolveReference } from "../framework/reference.js"; import { reportDiagnostic } from "../lib.js"; import { SerializationHelpers } from "../modular/static-helpers-metadata.js"; -import { listOperationsUnderRLCClient } from "./client-utils.js"; +import { listOperationsUnderClient } from "./client-utils.js"; import { SdkContext } from "./interfaces.js"; import { isMediaTypeMultipart, @@ -311,7 +311,7 @@ export function extractOperationLroDetail( export function hasPollingOperations(client: SdkClient, dpgContext: SdkContext) { const program = dpgContext.program; - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation if (route.overloads && route.overloads?.length > 0) { @@ -428,7 +428,7 @@ function findRootSourceProperty(property: ModelProperty): ModelProperty { } export function hasPagingOperations(client: SdkClient, dpgContext: SdkContext) { - for (const op of listOperationsUnderRLCClient(client)) { + for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); // ignore overload base operation if (route.overloads && route.overloads?.length > 0) { diff --git a/packages/typespec-ts/src/utils/schema-helpers.ts b/packages/typespec-ts/src/utils/schema-helpers.ts index 4447f0af0d..d9b387345f 100644 --- a/packages/typespec-ts/src/utils/schema-helpers.ts +++ b/packages/typespec-ts/src/utils/schema-helpers.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ArraySchema, ObjectSchema, RLCModel, Schema, SchemaContext } from "../interfaces.js"; +import { ArraySchema, ObjectSchema, ClientModel, Schema, SchemaContext } from "../interfaces.js"; export interface IsDictionaryOptions { filterEmpty?: boolean; @@ -34,7 +34,7 @@ export function isConstantSchema(schema: Schema) { return false; } -export function buildSchemaObjectMap(model: RLCModel) { +export function buildSchemaObjectMap(model: ClientModel) { // include interfaces const map = new Map(); const allSchemas = (model.schemas ?? []).filter( diff --git a/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts b/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts index 80dfe35ddb..830efc81d4 100644 --- a/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts +++ b/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts @@ -2,7 +2,7 @@ import { buildRuntimeImports, initInternalImports, } from "../../../src/utils/imports-util.js"; -import { RLCModel } from "../../../src/interfaces.js"; +import { ClientModel } from "../../../src/interfaces.js"; export type TestModelConfig = { description?: string; @@ -22,7 +22,7 @@ export type TestModelConfig = { generateReactNativeTarget?: boolean; }; -export function createMockModel(config: TestModelConfig = {}): RLCModel { +export function createMockModel(config: TestModelConfig = {}): ClientModel { return { importInfo: { runtimeImports: buildRuntimeImports(), diff --git a/packages/typespec-ts/test/util/emit-util.ts b/packages/typespec-ts/test/util/emit-util.ts index b82d71a238..76781e4ef2 100644 --- a/packages/typespec-ts/test/util/emit-util.ts +++ b/packages/typespec-ts/test/util/emit-util.ts @@ -25,9 +25,9 @@ import { buildSubpathIndexFile } from "../../src/modular/build-subpath-index.js" import { emitSamples } from "../../src/modular/emit-samples.js"; import { emitTests } from "../../src/modular/emit-tests.js"; import { getClientHierarchyMap } from "../../src/utils/client-utils.js"; -import { RLCOptions } from "../../src/interfaces.js"; +import { ClientOptions } from "../../src/interfaces.js"; -export interface ModelConfigOptions extends RLCOptions { +export interface ModelConfigOptions extends ClientOptions { needOptions?: boolean; withRawContent?: boolean; needAzureCore?: boolean; From 8b93afed05455cbda9cf9dda014850af4eab9895 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 16:29:41 -0500 Subject: [PATCH 05/15] refactor: de-RLC internal names, discriminants, and comments (rename pass 2) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/src/context-manager.ts | 2 +- packages/typespec-ts/src/index.ts | 45 +++++++++---------- packages/typespec-ts/src/interfaces.ts | 12 ++--- packages/typespec-ts/src/lib.ts | 2 +- packages/typespec-ts/src/meta-tree.ts | 4 +- .../src/modular/build-classical-client.ts | 10 ++--- .../src/modular/build-client-context.ts | 8 ++-- .../src/modular/build-modular-options.ts | 6 +-- .../src/modular/build-operations.ts | 6 +-- .../src/modular/build-root-index.ts | 2 +- .../typespec-ts/src/modular/emit-models.ts | 14 +++--- .../typespec-ts/src/modular/emit-samples.ts | 6 +-- .../helpers/classical-operation-helpers.ts | 18 ++++---- .../src/modular/helpers/client-helpers.ts | 4 +- .../src/modular/helpers/naming-helpers.ts | 2 +- .../src/modular/helpers/operation-helpers.ts | 32 ++++++------- .../typespec-ts/src/modular/interfaces.ts | 2 +- .../build-deserializer-function.ts | 2 +- .../build-serializer-function.ts | 2 +- .../type-expressions/get-enum-expression.ts | 2 +- .../get-nullable-expression.ts | 2 +- .../type-expressions/get-type-expression.ts | 4 +- .../src/transform/transform-client-options.ts | 4 +- .../src/transform/transform-parameters.ts | 14 +++--- .../src/transform/transform-paths.ts | 2 +- .../src/transform/transform-responses.ts | 30 ++++++------- .../src/transform/transform-schemas.ts | 4 +- .../typespec-ts/src/transform/transform.ts | 14 +++--- .../typespec-ts/src/utils/client-utils.ts | 2 +- .../src/utils/cross-language-def.ts | 2 +- .../typespec-ts/src/utils/imports-util.ts | 12 ++--- packages/typespec-ts/src/utils/interfaces.ts | 4 +- packages/typespec-ts/src/utils/model-utils.ts | 2 +- .../typespec-ts/src/utils/namespace-utils.ts | 8 ++-- .../typespec-ts/src/utils/operation-util.ts | 14 +++--- .../typespec-ts/src/utils/parameter-utils.ts | 2 +- packages/typespec-ts/test/util/emit-util.ts | 40 ++++++++--------- packages/typespec-ts/test/util/test-util.ts | 2 +- 38 files changed, 171 insertions(+), 172 deletions(-) diff --git a/packages/typespec-ts/src/context-manager.ts b/packages/typespec-ts/src/context-manager.ts index d63405a0c8..1001a6d9fd 100644 --- a/packages/typespec-ts/src/context-manager.ts +++ b/packages/typespec-ts/src/context-manager.ts @@ -20,7 +20,7 @@ import { ClientTypeMetaTree } from "./meta-tree.js"; * Remember, adding too many contexts can lead to complex dependencies and harder-to-maintain code. Always evaluate if the context is truly necessary or if there are better alternatives such as localized state management or passing props for simpler scenarios. */ type Contexts = { - rlcMetaTree: ClientTypeMetaTree; // Context for RLC types metadata. + clientTypeMetaTree: ClientTypeMetaTree; // Context for client type metadata. outputProject: Project; // The TS-Morph root project context for code generation. symbolMap: Map; // Mapping of symbols to their corresponding source files. sdkTypes: SdkTypeContext; diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index 2e752b1e48..f540b1d1a0 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -114,11 +114,11 @@ export async function $onEmit(context: EmitContext) { // Enrich the dpg context with path detail and common options await enrichDpgContext(); - const rlcOptions = dpgContext.rlcOptions ?? {}; + const resolvedEmitterOptions = dpgContext.emitterOptions ?? {}; const needUnexpectedHelper: Map = new Map(); - const serviceNameToRlcModelsMap: Map = new Map(); - provideContext("rlcMetaTree", new Map()); + const serviceNameToClientModelsMap: Map = new Map(); + provideContext("clientTypeMetaTree", new Map()); provideContext("symbolMap", new Map()); provideContext("outputProject", outputProject); provideContext("emitContext", { @@ -137,13 +137,13 @@ export async function $onEmit(context: EmitContext) { ...PlatformTypeHelpers, ...CloudSettingHelpers, ...XmlHelpers, - ...(rlcOptions.generateTest ? CreateRecorderHelpers : {}), - ...(rlcOptions.enableStorageCompat ? StorageCompatHelpers : {}), + ...(resolvedEmitterOptions.generateTest ? CreateRecorderHelpers : {}), + ...(resolvedEmitterOptions.enableStorageCompat ? StorageCompatHelpers : {}), }, { sourcesDir: dpgContext.generationPathDetail?.modularSourcesDir, rootDir: dpgContext.generationPathDetail?.rootDir, - options: rlcOptions, + options: resolvedEmitterOptions, program, host, packageRoot: emitterPackageRoot, @@ -168,7 +168,7 @@ export async function $onEmit(context: EmitContext) { let modularEmitterOptions: ModularEmitterOptions; // 1. Clear sources folder await clearSrcFolder(); - // 2. Generate RLC code model + // 2. Generate client code model // TODO: skip this step in modular once modular generator is sufficiently decoupled await buildClientCodeModels(); // 3. Clear samples-dev folder if generateSample is true @@ -205,7 +205,7 @@ export async function $onEmit(context: EmitContext) { options.generateTest = options.generateTest === true || (options.generateTest === undefined && (!hasTestFolder || options.azureArm)); - dpgContext.rlcOptions = options; + dpgContext.emitterOptions = options; } async function calculateGenerationDir(): Promise { @@ -222,7 +222,7 @@ export async function $onEmit(context: EmitContext) { return { rootDir: projectRoot, metadataDir: projectRoot, - rlcSourcesDir: sourcesRoot, + sourcesDir: sourcesRoot, modularSourcesDir: sourcesRoot, }; } @@ -231,7 +231,7 @@ export async function $onEmit(context: EmitContext) { await emptyDir( host, dpgContext.generationPathDetail?.modularSourcesDir ?? - dpgContext.generationPathDetail?.rlcSourcesDir ?? + dpgContext.generationPathDetail?.sourcesDir ?? "", ); } @@ -254,7 +254,7 @@ export async function $onEmit(context: EmitContext) { const clientModels = await transformClientModel(client, dpgContext); clientCodeModels.push(clientModels); const serviceName = client.services[0]?.name ?? "Unknown"; - serviceNameToRlcModelsMap.set(serviceName, clientModels); + serviceNameToClientModelsMap.set(serviceName, clientModels); needUnexpectedHelper.set(getClientName(clientModels), hasUnexpectedHelper(clientModels)); } } @@ -288,7 +288,7 @@ export async function $onEmit(context: EmitContext) { buildOperationFiles(dpgContext, subClient, modularEmitterOptions); buildClientContext(dpgContext, subClient, modularEmitterOptions); buildRestorePoller(dpgContext, subClient, modularEmitterOptions); - if (dpgContext.rlcOptions?.hierarchyClient) { + if (dpgContext.emitterOptions?.hierarchyClient) { buildSubpathIndexFile(modularEmitterOptions, "api", subClient, { exportIndex: false, recursive: true, @@ -316,10 +316,9 @@ export async function $onEmit(context: EmitContext) { // Enable modular sample generation when explicitly set to true or MPG if (emitterOptions["generate-sample"] === true) { const samples = emitSamples(dpgContext); - // Refine the rlc sample generation logic - // TODO: remember to remove this out when RLC is splitted from Modular + // Mark sample generation as enabled when modular samples were emitted. if (samples.length > 0) { - dpgContext.rlcOptions!.generateSample = true; + dpgContext.emitterOptions!.generateSample = true; } } @@ -371,8 +370,8 @@ export async function $onEmit(context: EmitContext) { if (clientCodeModels.length === 0 || !clientCodeModels[0]) { return; } - const rlcClient: ClientModel = clientCodeModels[0]; - const option = dpgContext.rlcOptions!; + const clientModel: ClientModel = clientCodeModels[0]; + const option = dpgContext.emitterOptions!; // When generateMetadata is explicitly false and the sources are generated // into a path ending with "generated" (e.g. src/generated), this package // has a manual convenience layer. Skip all metadata/test file generation @@ -412,7 +411,7 @@ export async function $onEmit(context: EmitContext) { //TODO Need consider multi-client cases for (const subClient of dpgContext.sdkPackage.clients) { - rlcClient.libraryName = subClient.name; + clientModel.libraryName = subClient.name; } if (shouldGenerateMetadata) { @@ -482,7 +481,7 @@ export async function $onEmit(context: EmitContext) { await emitContentByBuilder( program, commonBuilders, - rlcClient, + clientModel, dpgContext.generationPathDetail?.metadataDir, ); @@ -535,7 +534,7 @@ export async function $onEmit(context: EmitContext) { if (hasReadmeFile) { const readmeSourceFile = await host.readFile(existingReadmeFilePath); const existingReadmeContent = readmeSourceFile.text; - const clientNameChanged = hasClientNameChanged(rlcClient, existingReadmeContent); + const clientNameChanged = hasClientNameChanged(clientModel, existingReadmeContent); updateBuilders.push( clientNameChanged ? buildReadmeFile @@ -556,14 +555,14 @@ export async function $onEmit(context: EmitContext) { await emitContentByBuilder( program, updateBuilders, - rlcClient, + clientModel, dpgContext.generationPathDetail?.metadataDir, ); } await emitContentByBuilder( program, buildMetadataJson, - rlcClient, + clientModel, dpgContext.generationPathDetail?.metadataDir, ); @@ -572,7 +571,7 @@ export async function $onEmit(context: EmitContext) { await emitContentByBuilder( program, [buildRecordedClientFile, buildSampleTest], - rlcClient, + clientModel, dpgContext.generationPathDetail?.metadataDir, ); } diff --git a/packages/typespec-ts/src/interfaces.ts b/packages/typespec-ts/src/interfaces.ts index 33df5d95fb..172d34a0b2 100644 --- a/packages/typespec-ts/src/interfaces.ts +++ b/packages/typespec-ts/src/interfaces.ts @@ -14,7 +14,7 @@ export interface ClientModel { urlInfo?: UrlInfo; telemetryOptions?: TelemetryInfo; sampleGroups?: SampleGroup[]; - rlcSourceDir?: string; + sourceDir?: string; } export interface ImportInfo { @@ -28,10 +28,10 @@ export type ImportType = /**inner models' imports for parameter and response */ | "parameter" | "response" - | "rlcIndex" + | "index" | "modularModel" - | "rlcClientFactory" - | "rlcClientDefinition" + | "clientFactory" + | "clientDefinition" /**common third party imports */ | "restClient" | "coreAuth" @@ -357,8 +357,8 @@ export interface ParameterMetadatas { export interface ParameterBodyMetadata { /** * In case of formData we'd get multiple properties in body marked as partialBody - * If yes, rlc-common would prepare the whole part shape; - * usually false in typespec source because rlc-common doesn't have to prepare the whole part shape + * If yes, the emitter would prepare the whole part shape; + * usually false in typespec source because the emitter doesn't have to prepare the whole part shape */ isPartialBody?: boolean; body?: ParameterBodySchema[]; diff --git a/packages/typespec-ts/src/lib.ts b/packages/typespec-ts/src/lib.ts index 7df32d7b58..633a6f7a00 100644 --- a/packages/typespec-ts/src/lib.ts +++ b/packages/typespec-ts/src/lib.ts @@ -238,7 +238,7 @@ export const EmitterOptionsSchema: JSONSchemaType = { type: "boolean", nullable: true, description: - "Whether to generate the backward-compatible code for query parameter serialization for array types in RLC. Defaults to `false`", + "Whether to generate the backward-compatible code for query parameter serialization for array types. Defaults to `false`", }, "typespec-title-map": { type: "object", diff --git a/packages/typespec-ts/src/meta-tree.ts b/packages/typespec-ts/src/meta-tree.ts index 108d4d15aa..4889ae3e97 100644 --- a/packages/typespec-ts/src/meta-tree.ts +++ b/packages/typespec-ts/src/meta-tree.ts @@ -1,8 +1,8 @@ import { Type } from "@typespec/compiler"; -import { Schema as RlcType } from "./interfaces.js"; +import { Schema } from "./interfaces.js"; export interface ClientTypeMetadata { - rlcType: RlcType; + clientType: Schema; } export type ClientTypeMetaTree = Map; diff --git a/packages/typespec-ts/src/modular/build-classical-client.ts b/packages/typespec-ts/src/modular/build-classical-client.ts index 55c07d8115..2b641e4233 100644 --- a/packages/typespec-ts/src/modular/build-classical-client.ts +++ b/packages/typespec-ts/src/modular/build-classical-client.ts @@ -47,7 +47,7 @@ export function buildClassicalClient( requiredOnly: true, }); const srcPath = emitterOptions.modularOptions.sourceRoot; - const { subfolder, rlcClientName } = getModularClientOptions(clientMap); + const { subfolder, clientName } = getModularClientOptions(clientMap); const clientFile = project.createSourceFile( `${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}${normalizeName( @@ -71,13 +71,13 @@ export function buildClassicalClient( if (isMultiEndpointClient(dpgContext)) { clientClass.addProperty({ name: "_client", - type: `Client.${rlcClientName}`, + type: `Client.${clientName}`, scope: Scope.Private, }); } else { clientClass.addProperty({ name: "_client", - type: `${rlcClientName}`, + type: `${clientName}`, scope: Scope.Private, }); } @@ -214,7 +214,7 @@ function generateMethod( }); // add LRO helper methods if applicable - if (context.rlcOptions?.compatibilityLro && declaration?.isLro && !declaration?.isLroPaging) { + if (context.emitterOptions?.compatibilityLro && declaration?.isLro && !declaration?.isLroPaging) { const operationStateReference = resolveReference(AzurePollingDependencies.OperationState); const simplePollerLikeReference = resolveReference(SimplePollerHelpers.SimplePollerLike); const getSimplePollerReference = resolveReference(SimplePollerHelpers.getSimplePoller); @@ -244,7 +244,7 @@ function generateMethod( statements: `return await ${declarationRefKey}(${methodParamStr});`, }); } // For LRO+Paging operations, use different return types and implementation - else if (context.rlcOptions?.compatibilityLro && declaration?.isLroPaging) { + else if (context.emitterOptions?.compatibilityLro && declaration?.isLroPaging) { const returnType = declaration?.lropagingFinalReturnType ?? "void"; const pagedAsyncIterableIteratorReference = resolveReference( PagingHelpers.PagedAsyncIterableIterator, diff --git a/packages/typespec-ts/src/modular/build-client-context.ts b/packages/typespec-ts/src/modular/build-client-context.ts index f0d40d0f79..579f3d9837 100644 --- a/packages/typespec-ts/src/modular/build-client-context.ts +++ b/packages/typespec-ts/src/modular/build-client-context.ts @@ -61,7 +61,7 @@ export function buildClientContext( const dependencies = useDependencies(); const [hierarchy, client] = clientMap; const name = getClientName(client); - const { rlcClientName } = getModularClientOptions(clientMap); + const { clientName } = getModularClientOptions(clientMap); const requiredParams = getClientParametersDeclaration(client, dpgContext, { onClientOnly: false, requiredOnly: true, @@ -116,7 +116,7 @@ export function buildClientContext( clientContextFile.addInterface({ isExported: true, - name: `${rlcClientName}`, + name: `${clientName}`, extends: [resolveReference(dependencies.Client)], docs: getDocsFromDescription(client.doc), properties: [...requiredInterfaceProperties, ...optionalInterfaceProperties], @@ -172,7 +172,7 @@ export function buildClientContext( const factoryFunction = clientContextFile.addFunction({ docs: getDocsFromDescription(client.doc), name: `create${name}`, - returnType: `${rlcClientName}`, + returnType: `${clientName}`, parameters: getClientParametersDeclaration(client, dpgContext, { onClientOnly: false, requiredOnly: true, @@ -286,7 +286,7 @@ export function buildClientContext( if (allContextParams.length) { factoryFunction.addStatements( - `return { ...clientContext, ${allContextParams.join(", ")}} as ${rlcClientName};`, + `return { ...clientContext, ${allContextParams.join(", ")}} as ${clientName};`, ); } else { factoryFunction.addStatements(`return clientContext;`); diff --git a/packages/typespec-ts/src/modular/build-modular-options.ts b/packages/typespec-ts/src/modular/build-modular-options.ts index 0c579bf925..dfab767f1a 100644 --- a/packages/typespec-ts/src/modular/build-modular-options.ts +++ b/packages/typespec-ts/src/modular/build-modular-options.ts @@ -10,11 +10,11 @@ export function transformModularEmitterOptions( ): ModularEmitterOptions { CASING = options.casing ?? CASING; const emitterOptions: ModularEmitterOptions = { - options: dpgContext.rlcOptions ?? {}, + options: dpgContext.emitterOptions ?? {}, modularOptions: { sourceRoot: modularSourcesRoot, - compatibilityMode: !!dpgContext.rlcOptions?.compatibilityMode, - experimentalExtensibleEnums: !!dpgContext.rlcOptions?.experimentalExtensibleEnums, + compatibilityMode: !!dpgContext.emitterOptions?.compatibilityMode, + experimentalExtensibleEnums: !!dpgContext.emitterOptions?.experimentalExtensibleEnums, }, }; diff --git a/packages/typespec-ts/src/modular/build-operations.ts b/packages/typespec-ts/src/modular/build-operations.ts index 2f070726a1..84d5ee538e 100644 --- a/packages/typespec-ts/src/modular/build-operations.ts +++ b/packages/typespec-ts/src/modular/build-operations.ts @@ -48,9 +48,9 @@ export function buildOperationFiles( const project = useContext("outputProject"); const [_, client] = clientMap; const operationFiles: Set = new Set(); - const { subfolder, rlcClientName } = getModularClientOptions(clientMap); + const { subfolder, clientName } = getModularClientOptions(clientMap); const isMultiEndpoint = isMultiEndpointClient(dpgContext); - const clientType = isMultiEndpoint ? `Client.${rlcClientName}` : "Client"; + const clientType = isMultiEndpoint ? `Client.${clientName}` : "Client"; const methodMap = getMethodHierarchiesMap(dpgContext, client); for (const [prefixKey, operations] of methodMap) { const prefixes = prefixKey.split("/"); @@ -102,7 +102,7 @@ export function buildOperationFiles( const indexPathPrefix = "../".repeat(prefixKey === "" ? 0 : prefixes.length) || "./"; operationGroupFile.addImportDeclaration({ - namedImports: [`${rlcClientName} as Client`], + namedImports: [`${clientName} as Client`], moduleSpecifier: `${indexPathPrefix}index.js`, }); operationGroupFile.fixUnusedIdentifiers(); diff --git a/packages/typespec-ts/src/modular/build-root-index.ts b/packages/typespec-ts/src/modular/build-root-index.ts index c3997d3905..265a418c25 100644 --- a/packages/typespec-ts/src/modular/build-root-index.ts +++ b/packages/typespec-ts/src/modular/build-root-index.ts @@ -208,7 +208,7 @@ function exportSimplePollerLike( const hasLro = Array.from(methodMap.values()).some((operations) => { return operations.some(isLroOnlyOperation); }); - if (!hasLro || context.rlcOptions?.compatibilityLro !== true) { + if (!hasLro || context.emitterOptions?.compatibilityLro !== true) { return; } const helperFile = project.getSourceFile( diff --git a/packages/typespec-ts/src/modular/emit-models.ts b/packages/typespec-ts/src/modular/emit-models.ts index aeda192858..91d525f2d5 100644 --- a/packages/typespec-ts/src/modular/emit-models.ts +++ b/packages/typespec-ts/src/modular/emit-models.ts @@ -245,7 +245,7 @@ function emitType(context: SdkContext, type: SdkType, sourceFile: SourceFile) { } const apiVersionEnumOnly = type.usage === UsageFlags.ApiVersionEnum; // Skip known api version enums for multi-service scenarios as users are not allowed to set api versions - if (apiVersionEnumOnly && context.rlcOptions?.isMultiService) { + if (apiVersionEnumOnly && context.emitterOptions?.isMultiService) { return; } const inputUsage = (type.usage & UsageFlags.Input) === UsageFlags.Input; @@ -290,7 +290,7 @@ function emitType(context: SdkContext, type: SdkType, sourceFile: SourceFile) { export function getApiVersionEnum(context: SdkContext) { // Skip api version enum for multi-service scenarios since each service may have different versions - if (context.rlcOptions?.isMultiService) { + if (context.emitterOptions?.isMultiService) { return; } const apiVersionEnum = context.sdkPackage.enums.find( @@ -325,7 +325,7 @@ export function getModelNamespaces(context: SdkContext, model: SdkType): string[ } const segments = model.namespace.split("."); // Keep full namespace segments if multiple services are present because there isn't a root namespace to trim - if (context.rlcOptions?.isMultiService) { + if (context.emitterOptions?.isMultiService) { return segments; } @@ -603,7 +603,7 @@ function emitEnumMember( ): EnumMemberStructure { const shouldNormalizeName = !member.name.startsWith("$DO_NOT_NORMALIZE$"); const enumTypeName = normalizeName(member.enumType.name, NameType.Interface, true); - let normalizedMemberName = context.rlcOptions?.ignoreEnumMemberNameNormalize + let normalizedMemberName = context.emitterOptions?.ignoreEnumMemberNameNormalize ? fixLeadingNumber(member.name, NameType.EnumMemberName) // need to fix the leading number also for enum member : normalizeName(member.name, NameType.EnumMemberName, true); // If the member name starts with _ due to a leading digit (not because the original has _), @@ -744,7 +744,7 @@ function addExtendedDictInfo( const additionalPropertiesType = model.additionalProperties ? getTypeExpression(context, model.additionalProperties) : undefined; - if (context.rlcOptions?.compatibilityMode) { + if (context.emitterOptions?.compatibilityMode) { const ancestors = getAllAncestors(model); const properties = getAllProperties(context, model, ancestors); let anyType: boolean; @@ -839,7 +839,7 @@ export function normalizeModelName( unionSuffix = "Union"; } } - const namespacePrefix = context.rlcOptions?.enableModelNamespace ? segments.join("") : ""; + const namespacePrefix = context.emitterOptions?.enableModelNamespace ? segments.join("") : ""; const internalModelPrefix = (isPagedResultModel(context, type) && !pagedModelsKeptPublic.has(type)) || type.isGeneratedName ? "_" @@ -883,7 +883,7 @@ function buildModelProperty( ): PropertySignatureStructure { const normalizedPropName = normalizeModelPropertyName(context, property); if ( - !context.rlcOptions?.ignorePropertyNameNormalize && + !context.emitterOptions?.ignorePropertyNameNormalize && normalizedPropName !== `"${property.name}"` ) { reportDiagnostic(context.program, { diff --git a/packages/typespec-ts/src/modular/emit-samples.ts b/packages/typespec-ts/src/modular/emit-samples.ts index 5ff30a4f33..c6d02cd45a 100644 --- a/packages/typespec-ts/src/modular/emit-samples.ts +++ b/packages/typespec-ts/src/modular/emit-samples.ts @@ -115,9 +115,9 @@ function emitMethodSamples( }); const exampleFunctions = []; // TODO: remove hard-coded for package - if (dpgContext.rlcOptions?.packageDetails?.name) { + if (dpgContext.emitterOptions?.packageDetails?.name) { sourceFile.addImportDeclaration({ - moduleSpecifier: dpgContext.rlcOptions?.packageDetails?.name, + moduleSpecifier: dpgContext.emitterOptions?.packageDetails?.name, namedImports: [getClassicalClientName(options.topLevelClient)], }); } @@ -606,7 +606,7 @@ function getParameterValue( retValue = `${JSON.stringify(value.value)}`; break; case "null": { - const ignoreNullableOnOptional = context.rlcOptions?.ignoreNullableOnOptional ?? false; + const ignoreNullableOnOptional = context.emitterOptions?.ignoreNullableOnOptional ?? false; if (ignoreNullableOnOptional) { // When ignore-nullable-on-optional is true, the TypeScript type won't include // | null for optional properties, so we convert null to a type-appropriate default diff --git a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts index 9ec182ac36..7964e45b08 100644 --- a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts @@ -55,18 +55,18 @@ export function getClassicalOperation( ) { const prefixes = operationGroup[0]; const operations = operationGroup[1]; - const { rlcClientName } = getModularClientOptions(clientMap); + const { clientName } = getModularClientOptions(clientMap); const hasClientContextImport = classicFile.getImportDeclarations().filter((i) => { return ( i.getModuleSpecifierValue() === - `${"../".repeat(layer + 2)}api/${normalizeName(rlcClientName, NameType.File)}.js` + `${"../".repeat(layer + 2)}api/${normalizeName(clientName, NameType.File)}.js` ); }); if (!hasClientContextImport || hasClientContextImport.length === 0) { classicFile.addImportDeclaration({ - namedImports: [rlcClientName], + namedImports: [clientName], moduleSpecifier: `${"../".repeat(layer + 2)}api/${normalizeName( - rlcClientName, + clientName, NameType.File, )}.js`, }); @@ -78,7 +78,7 @@ export function getClassicalOperation( >(); const operationDeclarations: OptionalKind[] = operations.map( (operation) => { - const declaration = getOperationFunction(dpgContext, [prefixes, operation], rlcClientName); + const declaration = getOperationFunction(dpgContext, [prefixes, operation], clientName); operationDeclarationMap.set(declaration, { declaration, oriName: operation.oriName, @@ -141,7 +141,7 @@ export function getClassicalOperation( }); // add LRO helper methods if applicable if ( - dpgContext.rlcOptions?.compatibilityLro && + dpgContext.emitterOptions?.compatibilityLro && (operationInfo?.isLro || operationInfo?.isLroPaging) ) { const operationStateReference = resolveReference(AzurePollingDependencies.OperationState); @@ -207,7 +207,7 @@ export function getClassicalOperation( parameters: [ { name: "context", - type: rlcClientName, + type: clientName, }, ], statements: `return { @@ -237,7 +237,7 @@ export function getClassicalOperation( ]; // add LRO helper methods if applicable if ( - dpgContext.rlcOptions?.compatibilityLro && + dpgContext.emitterOptions?.compatibilityLro && (operationInfo?.isLro || operationInfo?.isLroPaging) ) { const getSimplePollerReference = resolveReference( @@ -336,7 +336,7 @@ export function getClassicalOperation( parameters: [ { name: "context", - type: rlcClientName, + type: clientName, }, ], returnType: resolveReference(refkey(interfaceName, layer, "classicOperations")), diff --git a/packages/typespec-ts/src/modular/helpers/client-helpers.ts b/packages/typespec-ts/src/modular/helpers/client-helpers.ts index 7c80b6284d..98ab1dfe9e 100644 --- a/packages/typespec-ts/src/modular/helpers/client-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/client-helpers.ts @@ -87,10 +87,10 @@ export function getClientParameters( const armSpecific = (p: SdkParameter) => !(p.kind === "endpoint" && dpgContext.arm); // Skip apiVersion parameter when it's multi-service (each service has its own default apiVersion) const skipApiVersionOnMultiService = (p: SdkParameter) => - !(dpgContext.rlcOptions?.isMultiService && p.isApiVersionParam); + !(dpgContext.emitterOptions?.isMultiService && p.isApiVersionParam); const filters = [ options.requiredOnly ? isRequired : undefined, - dpgContext.rlcOptions?.addCredentials === false ? skipCredentials : undefined, + dpgContext.emitterOptions?.addCredentials === false ? skipCredentials : undefined, options.optionalOnly ? isOptional : undefined, options.onClientOnly ? skipMethodParam : undefined, options.skipArmSpecific ? undefined : armSpecific, diff --git a/packages/typespec-ts/src/modular/helpers/naming-helpers.ts b/packages/typespec-ts/src/modular/helpers/naming-helpers.ts index 166257b505..d8560675a8 100644 --- a/packages/typespec-ts/src/modular/helpers/naming-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/naming-helpers.ts @@ -21,7 +21,7 @@ export function getOperationName( dpgContext?: SdkContext, ): GuardedName { const norm = normalizeName(operation.name, NameType.Method, true); - const isDataplane = dpgContext !== undefined && !dpgContext.rlcOptions?.azureArm; + const isDataplane = dpgContext !== undefined && !dpgContext.emitterOptions?.azureArm; if (isReservedName(operation.name, NameType.Method) && isDataplane) { return { name: norm, diff --git a/packages/typespec-ts/src/modular/helpers/operation-helpers.ts b/packages/typespec-ts/src/modular/helpers/operation-helpers.ts index 33ec3b6077..b6a1af401c 100644 --- a/packages/typespec-ts/src/modular/helpers/operation-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/operation-helpers.ts @@ -464,8 +464,8 @@ export function getDeserializeHeadersPrivateFunction( operation: ServiceOperation, ): OptionalKind | undefined { const responseHeaders = getResponseHeaders(operation.operation.responses); - const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true; - const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true; + const isResponseHeadersEnabled = context.emitterOptions?.includeHeadersInResponse === true; + const isStorageCompatEnabled = context.emitterOptions?.enableStorageCompat === true; // Only generate if headers exist and a relevant feature is enabled if (responseHeaders.length === 0 || (!isResponseHeadersEnabled && !isStorageCompatEnabled)) { @@ -617,7 +617,7 @@ export function getDeserializeExceptionHeadersPrivateFunction( context: SdkContext, operation: ServiceOperation, ): OptionalKind | undefined { - const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true; + const isResponseHeadersEnabled = context.emitterOptions?.includeHeadersInResponse === true; if (!isResponseHeadersEnabled) { return undefined; } @@ -673,7 +673,7 @@ function getExceptionThrowStatement(context: SdkContext, operation: ServiceOpera const { customized, defaultDeserializer, defaultXmlDeserializer, defaultIsXmlOnly } = getExceptionDetails(context, operation); - const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true; + const isResponseHeadersEnabled = context.emitterOptions?.includeHeadersInResponse === true; // Check if exception headers function exists and build the call const exceptionHeaders = getExceptionResponseHeaders(operation.operation.exceptions); @@ -916,8 +916,8 @@ export function getOperationFunction( const response = operation.response; const responseHeaders = getResponseHeaders(operation.operation.responses); const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0; - const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true; - const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true; + const isResponseHeadersEnabled = context.emitterOptions?.includeHeadersInResponse === true; + const isStorageCompatEnabled = context.emitterOptions?.enableStorageCompat === true; // Track the raw body type separately for storage-compat (before header merging) const hasResponseBody = !!response.type; @@ -1404,7 +1404,7 @@ export function getOperationOptionsName( /** * This function build the request parameters that we will provide to the - * RLC internally. This will translate High Level parameters into the RLC ones. + * REST-level request internally. This will translate high-level parameters into the REST-level ones. * Figuring out what goes in headers, body, path and qsp. */ function getHeaderAndBodyParameters( @@ -1632,7 +1632,7 @@ export function getParameterMap( // Special case for api-version parameters with default values if (param.isApiVersionParam && param.clientDefaultValue) { // For multi-service, use only the default value (don't reference context.apiVersion) - if (context.rlcOptions?.isMultiService) { + if (context.emitterOptions?.isMultiService) { return `"${serializedName}": "${param.clientDefaultValue}"`; } return `"${serializedName}": ${param.onClient ? "context." : ""}${param.name} ?? "${param.clientDefaultValue}"`; @@ -2141,8 +2141,8 @@ export function getRequestModelProperties( /** * - * This function helps translating an HLC request to RLC request, - * extracting properties from body and headers and building the RLC response object + * This function helps translating a high-level request to a REST-level request, + * extracting properties from body and headers and building the REST-level request object */ export function getRequestModelMapping( context: SdkContext, @@ -2177,8 +2177,8 @@ function getHeaderSerializedName(param: SdkHttpParameter) { } /** - * This function helps translating an RLC response to an HLC response, - * extracting properties from body and headers and building the HLC response object + * This function helps translating a REST-level response to a high-level response, + * extracting properties from body and headers and building the high-level response object */ export function getResponseMapping( context: SdkContext, @@ -2324,7 +2324,7 @@ export function serializeRequestValue( } else if ( isSpecialHandledUnion({ ...type, - isNonExhaustive: context.rlcOptions?.experimentalExtensibleEnums ?? false, + isNonExhaustive: context.emitterOptions?.experimentalExtensibleEnums ?? false, }) ) { const sdkType = getSdkType(type.__raw!); @@ -2750,7 +2750,7 @@ function getApiVersionExpression( return undefined; } // For multi-service, use only the default value (don't reference context.apiVersion) - if (dpgContext.rlcOptions?.isMultiService) { + if (dpgContext.emitterOptions?.isMultiService) { return queryApiVersionParam.clientDefaultValue ? `"${queryApiVersionParam.clientDefaultValue}"` : undefined; @@ -2918,7 +2918,7 @@ export function getOperationResponseTypeName(method: [string[], ServiceOperation function isWrappableType(context: SdkContext, type: SdkType): boolean { if (type.kind === "array" && type.valueType.kind === "model") return false; if (type.kind === "dict" || type.kind === "model") return false; - if (type.kind === "unknown" && context.rlcOptions?.treatUnknownAsRecord) return false; + if (type.kind === "unknown" && context.emitterOptions?.treatUnknownAsRecord) return false; return true; } @@ -2952,7 +2952,7 @@ export function checkWrapNonModelReturn( } // Only if the feature flag is enabled - if (!context.rlcOptions?.wrapNonModelReturn) { + if (!context.emitterOptions?.wrapNonModelReturn) { return noWrap; } diff --git a/packages/typespec-ts/src/modular/interfaces.ts b/packages/typespec-ts/src/modular/interfaces.ts index 49df8aa9ca..2e9330fdf0 100644 --- a/packages/typespec-ts/src/modular/interfaces.ts +++ b/packages/typespec-ts/src/modular/interfaces.ts @@ -12,7 +12,7 @@ export interface ModularEmitterOptions { export interface ModularClientOptions { subfolder?: string; - rlcClientName: string; + clientName: string; } export interface OperationPathAndDeserDetails { diff --git a/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts index 0b1a5c2b87..0a904957ed 100644 --- a/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts @@ -447,7 +447,7 @@ function getAdditionalPropertiesStatement( if (typeof deserializerFunction === "string") { params.push(deserializerFunction); } - return context.rlcOptions?.compatibilityMode === true + return context.emitterOptions?.compatibilityMode === true ? "...item," : `${getAdditionalPropertiesName(context, type)}: ${resolveReference(SerializationHelpers.serializeRecord)}(${params.join(",")}),`; } diff --git a/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts index df7748b6ac..eaf7235042 100644 --- a/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts @@ -498,7 +498,7 @@ function getAdditionalPropertiesStatement( params.push("undefined"); params.push(deserializerFunction); } - return context.rlcOptions?.compatibilityMode === true + return context.emitterOptions?.compatibilityMode === true ? "...item" : `...${resolveReference(SerializationHelpers.serializeRecord)}(${params.join(",")})`; } diff --git a/packages/typespec-ts/src/modular/type-expressions/get-enum-expression.ts b/packages/typespec-ts/src/modular/type-expressions/get-enum-expression.ts index 59879d6a35..12bb29ade6 100644 --- a/packages/typespec-ts/src/modular/type-expressions/get-enum-expression.ts +++ b/packages/typespec-ts/src/modular/type-expressions/get-enum-expression.ts @@ -19,5 +19,5 @@ export function getEnumExpression( } export function isExtensibleEnum(context: SdkContext, type: SdkEnumType): boolean { - return !type.isFixed && context.rlcOptions?.experimentalExtensibleEnums === true; + return !type.isFixed && context.emitterOptions?.experimentalExtensibleEnums === true; } diff --git a/packages/typespec-ts/src/modular/type-expressions/get-nullable-expression.ts b/packages/typespec-ts/src/modular/type-expressions/get-nullable-expression.ts index ba4737bfcd..276c4cbbdf 100644 --- a/packages/typespec-ts/src/modular/type-expressions/get-nullable-expression.ts +++ b/packages/typespec-ts/src/modular/type-expressions/get-nullable-expression.ts @@ -11,7 +11,7 @@ export function getNullableExpression( ): string { if (shouldEmitInline(type, options)) { // Check if we should ignore null for optional properties - const ignoreNullableOnOptional = context.rlcOptions?.ignoreNullableOnOptional ?? false; + const ignoreNullableOnOptional = context.emitterOptions?.ignoreNullableOnOptional ?? false; const isOptional = options.isOptional ?? false; const nonNullableType = getTypeExpression(context, type.type, options); diff --git a/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts b/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts index 0c1c8021d1..3f0f956efe 100644 --- a/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts +++ b/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts @@ -22,7 +22,7 @@ export function normalizeModelPropertyName( property: SdkModelPropertyType | SdkHttpParameter | SdkServiceResponseHeader, ): string { const normalizedPropName = normalizeName(property.name, NameType.Property); - return context.rlcOptions?.ignorePropertyNameNormalize + return context.emitterOptions?.ignorePropertyNameNormalize ? `"${property.name}"` : `"${normalizedPropName}"`; } @@ -40,7 +40,7 @@ export function getTypeExpression( case "enum": return getEnumExpression(context, type); case "unknown": - return context.rlcOptions?.treatUnknownAsRecord ? "Record" : "any"; + return context.emitterOptions?.treatUnknownAsRecord ? "Record" : "any"; case "boolean": return "boolean"; case "decimal": diff --git a/packages/typespec-ts/src/transform/transform-client-options.ts b/packages/typespec-ts/src/transform/transform-client-options.ts index 27e7809786..e73b96f376 100644 --- a/packages/typespec-ts/src/transform/transform-client-options.ts +++ b/packages/typespec-ts/src/transform/transform-client-options.ts @@ -17,7 +17,7 @@ export function transformClientOptions( dpgContext: SdkContext, ): ClientOptions { // Extract the options from emitter option - const options = extractRLCOptions( + const options = extractClientOptions( dpgContext, emitterOptions, dpgContext.generationPathDetail?.rootDir ?? "", @@ -26,7 +26,7 @@ export function transformClientOptions( options.batch = batch; return options; } -function extractRLCOptions( +function extractClientOptions( dpgContext: SdkContext, emitterOptions: EmitterOptions, generationRootDir: string, diff --git a/packages/typespec-ts/src/transform/transform-parameters.ts b/packages/typespec-ts/src/transform/transform-parameters.ts index 4bcdd7f3dc..920c341bc6 100644 --- a/packages/typespec-ts/src/transform/transform-parameters.ts +++ b/packages/typespec-ts/src/transform/transform-parameters.ts @@ -48,7 +48,7 @@ export function transformToParameterTypes( importDetails: Imports, apiVersionInfo?: ApiVersionInfo, ): OperationParameter[] { - const rlcParameters: OperationParameter[] = []; + const clientParameters: OperationParameter[] = []; const outputImportedSet = new Set(); for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); @@ -64,15 +64,15 @@ export function transformToParameterTypes( } function transformToParameterTypesForRoute(route: HttpOperation) { const parameters = route.parameters; - const rlcParameter: OperationParameter = { + const clientParameter: OperationParameter = { operationGroup: getOperationGroupName(dpgContext, route), operationName: getOperationName(dpgContext, route.operation), parameters: [], }; const options = { apiVersionInfo, - operationGroupName: rlcParameter.operationGroup, - operationName: rlcParameter.operationName, + operationGroupName: clientParameter.operationGroup, + operationName: clientParameter.operationName, importModels: outputImportedSet, }; // transform query param @@ -95,13 +95,13 @@ export function transformToParameterTypes( bodyType, ); } - rlcParameter.parameters.push({ + clientParameter.parameters.push({ parameters: [...queryParams, ...pathParams, ...headerParams], body: bodyParameter, }); - rlcParameters.push(rlcParameter); + clientParameters.push(clientParameter); } - return rlcParameters; + return clientParameters; } function getParameterMetadata( diff --git a/packages/typespec-ts/src/transform/transform-paths.ts b/packages/typespec-ts/src/transform/transform-paths.ts index 19dd4a8442..846f74fe66 100644 --- a/packages/typespec-ts/src/transform/transform-paths.ts +++ b/packages/typespec-ts/src/transform/transform-paths.ts @@ -43,7 +43,7 @@ export function transformPaths( } if (pathParamsImportedSet.size > 0) { - importDetails.rlcClientDefinition.importsSet = pathParamsImportedSet; + importDetails.clientDefinition.importsSet = pathParamsImportedSet; } return paths; diff --git a/packages/typespec-ts/src/transform/transform-responses.ts b/packages/typespec-ts/src/transform/transform-responses.ts index 14d9a26049..d7aa70c877 100644 --- a/packages/typespec-ts/src/transform/transform-responses.ts +++ b/packages/typespec-ts/src/transform/transform-responses.ts @@ -28,7 +28,7 @@ export function transformToResponseTypes( dpgContext: SdkContext, importDetails: Imports, ): OperationResponse[] { - const rlcResponses: OperationResponse[] = []; + const clientResponses: OperationResponse[] = []; const inputImportedSet = new Set(); for (const op of listOperationsUnderClient(client)) { const route = getHttpOperationWithCache(dpgContext, op); @@ -42,7 +42,7 @@ export function transformToResponseTypes( importDetails.response.importsSet = inputImportedSet; } function transformToResponseTypesForRoute(route: HttpOperation) { - const rlcOperationUnit: OperationResponse = { + const operationUnit: OperationResponse = { operationGroup: getOperationGroupName(dpgContext, route), operationName: getOperationName(dpgContext, route.operation), path: route.path, @@ -52,7 +52,7 @@ export function transformToResponseTypes( nonDefaultSchemas: Schema[] = []; for (const resp of sortedOperationResponses(route.responses)) { const statusCode = getOperationStatuscode(resp); - const rlcResponseUnit: ResponseMetadata = { + const responseUnit: ResponseMetadata = { statusCode, description: resp.description, }; @@ -60,8 +60,8 @@ export function transformToResponseTypes( const headers = transformHeaders(dpgContext, resp, inputImportedSet); // transform body const [body, schemas] = transformBody(dpgContext, resp, inputImportedSet) ?? [undefined, []]; - rlcOperationUnit.responses.push({ - ...rlcResponseUnit, + operationUnit.responses.push({ + ...responseUnit, headers, body, }); @@ -75,20 +75,20 @@ export function transformToResponseTypes( dpgContext, route, getOperationGroupName(dpgContext, route), - rlcOperationUnit.responses, + operationUnit.responses, ); if (lroLogicalResponse) { - rlcOperationUnit.responses.push(lroLogicalResponse); + operationUnit.responses.push(lroLogicalResponse); } - rlcResponses.push(rlcOperationUnit); + clientResponses.push(operationUnit); } - return rlcResponses; + return clientResponses; } /** * Return undefined if no valid header param * @param response response detail - * @returns rlc header schema + * @returns the response header schema */ function transformHeaders( dpgContext: SdkContext, @@ -99,8 +99,8 @@ function transformHeaders( return; } - const rlcHeaders: Map = new Map(); - // Current RLC client can't represent different headers per content type. + const responseHeaders: Map = new Map(); + // The client can't represent different headers per content type. // So we merge headers here, and report any duplicates. // It may be possible in principle to not error for identically declared // headers. @@ -132,11 +132,11 @@ function transformHeaders( required: !value?.optional, description: getDoc(dpgContext.program, value!), }; - rlcHeaders.set(header.name, header); + responseHeaders.set(header.name, header); } } - return rlcHeaders.size ? Array.from(rlcHeaders.values()) : undefined; + return responseHeaders.size ? Array.from(responseHeaders.values()) : undefined; } function transformBody( @@ -147,7 +147,7 @@ function transformBody( if (!response.responses.length) { return; } - // Currently RLC response only have one header and body defined + // Currently a response only has one header and body defined // So we'll union all body shapes together with "|" const typeSet = new Set(); const descriptions = new Set(); diff --git a/packages/typespec-ts/src/transform/transform-schemas.ts b/packages/typespec-ts/src/transform/transform-schemas.ts index 10a6a65df1..d9d639d79e 100644 --- a/packages/typespec-ts/src/transform/transform-schemas.ts +++ b/packages/typespec-ts/src/transform/transform-schemas.ts @@ -21,7 +21,7 @@ import { SchemaContext } from "../interfaces.js"; export function transformSchemas(client: SdkClient, dpgContext: SdkContext) { const program = dpgContext.program; - const metatree = useContext("rlcMetaTree"); + const metatree = useContext("clientTypeMetaTree"); const schemas: Map = new Map(); const schemaMap: Map = new Map(); const usageMap = new Map(); @@ -103,7 +103,7 @@ export function transformSchemas(client: SdkClient, dpgContext: SdkContext) { if (model) { model.usage = context; } - metatree.set(tspModel, { rlcType: model }); + metatree.set(tspModel, { clientType: model }); if (model.name === "") { return; } diff --git a/packages/typespec-ts/src/transform/transform.ts b/packages/typespec-ts/src/transform/transform.ts index 00ba747767..099a673eee 100644 --- a/packages/typespec-ts/src/transform/transform.ts +++ b/packages/typespec-ts/src/transform/transform.ts @@ -30,10 +30,10 @@ export async function transformClientModel( dpgContext: SdkContext, ): Promise { const program = dpgContext.program; - const options: ClientOptions = dpgContext.rlcOptions!; - const rlcSourceDir = dpgContext.generationPathDetail?.rlcSourcesDir; + const options: ClientOptions = dpgContext.emitterOptions!; + const sourceDir = dpgContext.generationPathDetail?.sourcesDir; const srcPath = joinPaths( - dpgContext.generationPathDetail?.rlcSourcesDir ?? "", + dpgContext.generationPathDetail?.sourcesDir ?? "", options.batch && options.batch.length > 1 ? normalizeName(client.name.replace("Client", ""), NameType.File) : "", @@ -74,10 +74,10 @@ export async function transformClientModel( internalImports: importSet, runtimeImports: buildRuntimeImports(), }, - rlcSourceDir, + sourceDir, }; - // RLC sample generation has been removed; modular samples are emitted separately, - // so the RLC model never carries sample groups. + // Legacy sample generation has been removed; modular samples are emitted separately, + // so the client model never carries sample groups. options.generateSample = false; return model; } @@ -132,7 +132,7 @@ export function transformUrlInfo( } } if (importedModels.size > 0) { - importDetails.rlcClientFactory.importsSet = importedModels; + importDetails.clientFactory.importsSet = importedModels; } if (endpoint && urlParameters.length > 0) { for (const param of urlParameters) { diff --git a/packages/typespec-ts/src/utils/client-utils.ts b/packages/typespec-ts/src/utils/client-utils.ts index 261642e9af..0e910628b5 100644 --- a/packages/typespec-ts/src/utils/client-utils.ts +++ b/packages/typespec-ts/src/utils/client-utils.ts @@ -117,7 +117,7 @@ export function isMultiEndpointClient(dpgContext: SdkContext): boolean { export function getModularClientOptions(clientMap: [string[], SdkClientType]) { const [hierarchy, client] = clientMap; const clientOptions: ModularClientOptions = { - rlcClientName: `${client.name.replace(/Client$/, "")}Context`, + clientName: `${client.name.replace(/Client$/, "")}Context`, }; clientOptions.subfolder = hierarchy.join("/"); return clientOptions; diff --git a/packages/typespec-ts/src/utils/cross-language-def.ts b/packages/typespec-ts/src/utils/cross-language-def.ts index 8468f9332f..a4afd6270d 100644 --- a/packages/typespec-ts/src/utils/cross-language-def.ts +++ b/packages/typespec-ts/src/utils/cross-language-def.ts @@ -24,7 +24,7 @@ export function generateCrossLanguageDefinitionFile(dpgContext: SdkContext): { } for (const enm of dpgContext.sdkPackage.enums) { // Skip api version enum for multi-service scenarios since each service may have different versions - if (dpgContext.rlcOptions?.isMultiService && enm.usage === UsageFlags.ApiVersionEnum) { + if (dpgContext.emitterOptions?.isMultiService && enm.usage === UsageFlags.ApiVersionEnum) { continue; } CrossLanguageDefinitionId[`${packageName}!Known${enm.name}:enum`] = diff --git a/packages/typespec-ts/src/utils/imports-util.ts b/packages/typespec-ts/src/utils/imports-util.ts index 046af414e8..63fa1849e9 100644 --- a/packages/typespec-ts/src/utils/imports-util.ts +++ b/packages/typespec-ts/src/utils/imports-util.ts @@ -63,20 +63,20 @@ export function initInternalImports(): Imports { type: "response", importsSet: new Set(), }, - rlcIndex: { - type: "rlcIndex", + index: { + type: "index", importsSet: new Set(), }, modularModel: { type: "modularModel", importsSet: new Set(), }, - rlcClientFactory: { - type: "rlcClientFactory", + clientFactory: { + type: "clientFactory", importsSet: new Set(), }, - rlcClientDefinition: { - type: "rlcClientDefinition", + clientDefinition: { + type: "clientDefinition", importsSet: new Set(), }, serializerHelpers: { diff --git a/packages/typespec-ts/src/utils/interfaces.ts b/packages/typespec-ts/src/utils/interfaces.ts index 8b258a60d3..546ce59e0b 100644 --- a/packages/typespec-ts/src/utils/interfaces.ts +++ b/packages/typespec-ts/src/utils/interfaces.ts @@ -4,7 +4,7 @@ import { KnownMediaType } from "./media-types.js"; import { ClientOptions, SchemaContext } from "../interfaces.js"; export interface SdkContext extends TCGCSdkContext { - rlcOptions?: ClientOptions; + emitterOptions?: ClientOptions; generationPathDetail?: GenerationDirDetail; hasApiVersionInClient?: boolean; allServiceNamespaces?: Namespace[]; @@ -12,7 +12,7 @@ export interface SdkContext extends TCGCSdkContext { export interface GenerationDirDetail { rootDir: string; - rlcSourcesDir: string; + sourcesDir: string; modularSourcesDir?: string; metadataDir: string; } diff --git a/packages/typespec-ts/src/utils/model-utils.ts b/packages/typespec-ts/src/utils/model-utils.ts index 35d38271c7..6e4056aee8 100644 --- a/packages/typespec-ts/src/utils/model-utils.ts +++ b/packages/typespec-ts/src/utils/model-utils.ts @@ -852,7 +852,7 @@ function getModelName(dpgContext: SdkContext, model: Model) { fullNamespacePrefix = ""; } // 5. check if this model should be namespaced - return dpgContext.rlcOptions?.enableModelNamespace ? `${fullNamespacePrefix}${name}` : name; + return dpgContext.emitterOptions?.enableModelNamespace ? `${fullNamespacePrefix}${name}` : name; } // Map an typespec type to an OA schema. Returns undefined when the resulting diff --git a/packages/typespec-ts/src/utils/namespace-utils.ts b/packages/typespec-ts/src/utils/namespace-utils.ts index 54e903b1f4..b239ce1fef 100644 --- a/packages/typespec-ts/src/utils/namespace-utils.ts +++ b/packages/typespec-ts/src/utils/namespace-utils.ts @@ -22,15 +22,15 @@ export function getOperationNamespaceInterfaceName( ): string[] { const result: string[] = []; if ( - dpgContext.rlcOptions?.hierarchyClient === false && - dpgContext.rlcOptions?.enableOperationGroup !== true + dpgContext.emitterOptions?.hierarchyClient === false && + dpgContext.emitterOptions?.enableOperationGroup !== true ) { return result; } if (operation.interface) { if ( - dpgContext.rlcOptions?.enableOperationGroup === true && - dpgContext.rlcOptions?.hierarchyClient === false + dpgContext.emitterOptions?.enableOperationGroup === true && + dpgContext.emitterOptions?.hierarchyClient === false ) { result.push(operation.interface.name); return result; diff --git a/packages/typespec-ts/src/utils/operation-util.ts b/packages/typespec-ts/src/utils/operation-util.ts index a4efaa732a..c499a3d770 100644 --- a/packages/typespec-ts/src/utils/operation-util.ts +++ b/packages/typespec-ts/src/utils/operation-util.ts @@ -126,7 +126,7 @@ export function getOperationGroupName( dpgContext: SdkContext, operationOrRoute?: Operation | HttpOperation, ) { - if (!dpgContext.rlcOptions?.enableOperationGroup || !operationOrRoute) { + if (!dpgContext.emitterOptions?.enableOperationGroup || !operationOrRoute) { return ""; } // If this is a HttpOperation @@ -461,7 +461,7 @@ export function getSpecialSerializeInfo( paramType, paramFormat, // Include query multi support in compatibility mode - dpgContext.rlcOptions?.compatibilityQueryMultiFormat ?? false, + dpgContext.emitterOptions?.compatibilityQueryMultiFormat ?? false, ); const hasCsvCollection = getHasCsvCollection(paramType, paramFormat); const descriptions = []; @@ -635,8 +635,8 @@ export function getMethodHierarchiesMap( continue; } const prefixes = - context.rlcOptions?.hierarchyClient === false && - context.rlcOptions?.enableOperationGroup && + context.emitterOptions?.hierarchyClient === false && + context.emitterOptions?.enableOperationGroup && method[0].length > 0 ? [method[0][method[0].length - 1] as string] : method[0]; @@ -659,13 +659,13 @@ export function getMethodHierarchiesMap( } } else { const prefixKey = - context.rlcOptions?.hierarchyClient || context.rlcOptions?.enableOperationGroup + context.emitterOptions?.hierarchyClient || context.emitterOptions?.enableOperationGroup ? prefixes.join("/") : ""; const groupName = prefixes.map((p) => normalizeName(p, NameType.OperationGroup)).join(""); if ( - context.rlcOptions?.hierarchyClient === false && - context.rlcOptions?.enableOperationGroup && + context.emitterOptions?.hierarchyClient === false && + context.emitterOptions?.enableOperationGroup && groupName !== "" && !operationOrGroup.name.startsWith(groupName + "_") ) { diff --git a/packages/typespec-ts/src/utils/parameter-utils.ts b/packages/typespec-ts/src/utils/parameter-utils.ts index 02ef5c58c2..c08670f492 100644 --- a/packages/typespec-ts/src/utils/parameter-utils.ts +++ b/packages/typespec-ts/src/utils/parameter-utils.ts @@ -67,7 +67,7 @@ export function getParameterSerializationInfo( }); } - if (dpgContext.rlcOptions?.compatibilityQueryMultiFormat) { + if (dpgContext.emitterOptions?.compatibilityQueryMultiFormat) { wrapperType = buildUnionType([wrapperType, { type: "string", name: "string" }]); } return buildSerializationInfo(wrapperType); diff --git a/packages/typespec-ts/test/util/emit-util.ts b/packages/typespec-ts/test/util/emit-util.ts index 76781e4ef2..4fb5e3b055 100644 --- a/packages/typespec-ts/test/util/emit-util.ts +++ b/packages/typespec-ts/test/util/emit-util.ts @@ -68,15 +68,15 @@ export async function emitModularModelsFromTypeSpec( const binder = useBinder(); let modelFile: any; const includeResponseHeaders = options["include-headers-in-response"] === true; - dpgContext.rlcOptions!.includeHeadersInResponse = includeResponseHeaders; - dpgContext.rlcOptions!.compatibilityMode = options["compatibility-mode"]; - dpgContext.rlcOptions!.experimentalExtensibleEnums = options["experimental-extensible-enums"]; - dpgContext.rlcOptions!.ignoreNullableOnOptional = options["ignore-nullable-on-optional"] ?? true; + dpgContext.emitterOptions!.includeHeadersInResponse = includeResponseHeaders; + dpgContext.emitterOptions!.compatibilityMode = options["compatibility-mode"]; + dpgContext.emitterOptions!.experimentalExtensibleEnums = options["experimental-extensible-enums"]; + dpgContext.emitterOptions!.ignoreNullableOnOptional = options["ignore-nullable-on-optional"] ?? true; if (options["wrap-non-model-return"] !== undefined) { - dpgContext.rlcOptions!.wrapNonModelReturn = options["wrap-non-model-return"] === true; + dpgContext.emitterOptions!.wrapNonModelReturn = options["wrap-non-model-return"] === true; } if (options["treat-unknown-as-record"] !== undefined) { - dpgContext.rlcOptions!.treatUnknownAsRecord = options["treat-unknown-as-record"] === true; + dpgContext.emitterOptions!.treatUnknownAsRecord = options["treat-unknown-as-record"] === true; } const modularEmitterOptions = transformModularEmitterOptions(dpgContext, "", { casing: "camel", @@ -138,9 +138,9 @@ export async function emitRootIndexFromTypeSpec( const binder = useBinder(); const project = useContext("outputProject"); const includeResponseHeaders = options["include-headers-in-response"] === true; - dpgContext.rlcOptions!.includeHeadersInResponse = includeResponseHeaders; - dpgContext.rlcOptions!.compatibilityMode = options["compatibility-mode"]; - dpgContext.rlcOptions!.experimentalExtensibleEnums = options["experimental-extensible-enums"]; + dpgContext.emitterOptions!.includeHeadersInResponse = includeResponseHeaders; + dpgContext.emitterOptions!.compatibilityMode = options["compatibility-mode"]; + dpgContext.emitterOptions!.experimentalExtensibleEnums = options["experimental-extensible-enums"]; // need to specify the root path for this case const modularEmitterOptions = transformModularEmitterOptions(dpgContext, "/any/path", { casing: "camel", @@ -201,14 +201,14 @@ export async function emitModularOperationsFromTypeSpec( const dpgContext = await createDpgContextTestHelper(context.program); const binder = useBinder(); const includeResponseHeaders = options["include-headers-in-response"] === true; - dpgContext.rlcOptions!.includeHeadersInResponse = includeResponseHeaders; - dpgContext.rlcOptions!.experimentalExtensibleEnums = options["experimental-extensible-enums"]; + dpgContext.emitterOptions!.includeHeadersInResponse = includeResponseHeaders; + dpgContext.emitterOptions!.experimentalExtensibleEnums = options["experimental-extensible-enums"]; if (options["wrap-non-model-return"] !== undefined) { - dpgContext.rlcOptions!.wrapNonModelReturn = options["wrap-non-model-return"] === true; + dpgContext.emitterOptions!.wrapNonModelReturn = options["wrap-non-model-return"] === true; } - dpgContext.rlcOptions!.enableStorageCompat = options["enable-storage-compat"] === true; + dpgContext.emitterOptions!.enableStorageCompat = options["enable-storage-compat"] === true; if (options["treat-unknown-as-record"] !== undefined) { - dpgContext.rlcOptions!.treatUnknownAsRecord = options["treat-unknown-as-record"] === true; + dpgContext.emitterOptions!.treatUnknownAsRecord = options["treat-unknown-as-record"] === true; } const modularEmitterOptions = transformModularEmitterOptions(dpgContext, "", { casing: "camel", @@ -249,8 +249,8 @@ export async function emitModularClientContextFromTypeSpec( const dpgContext = await createDpgContextTestHelper(context.program); const binder = useBinder(); const includeResponseHeaders = options["include-headers-in-response"] === true; - dpgContext.rlcOptions!.includeHeadersInResponse = includeResponseHeaders; - dpgContext.rlcOptions!.typespecTitleMap = options["typespec-title-map"]; + dpgContext.emitterOptions!.includeHeadersInResponse = includeResponseHeaders; + dpgContext.emitterOptions!.typespecTitleMap = options["typespec-title-map"]; const modularEmitterOptions = transformModularEmitterOptions(dpgContext, "", { casing: "camel", }); @@ -284,9 +284,9 @@ export async function emitModularClientFromTypeSpec( const dpgContext = await createDpgContextTestHelper(context.program); const binder = useBinder(); const includeResponseHeaders = options["include-headers-in-response"] === true; - dpgContext.rlcOptions!.includeHeadersInResponse = includeResponseHeaders; - dpgContext.rlcOptions!.typespecTitleMap = options["typespec-title-map"]; - dpgContext.rlcOptions!.hierarchyClient = options["hierarchy-client"] ?? true; + dpgContext.emitterOptions!.includeHeadersInResponse = includeResponseHeaders; + dpgContext.emitterOptions!.typespecTitleMap = options["typespec-title-map"]; + dpgContext.emitterOptions!.hierarchyClient = options["hierarchy-client"] ?? true; const modularEmitterOptions = transformModularEmitterOptions(dpgContext, "", { casing: "camel", }); @@ -325,7 +325,7 @@ export async function emitSamplesFromTypeSpec( }, ...configs, }); - dpgContext.rlcOptions!.ignoreNullableOnOptional = configs["ignore-nullable-on-optional"] ?? true; + dpgContext.emitterOptions!.ignoreNullableOnOptional = configs["ignore-nullable-on-optional"] ?? true; const modularEmitterOptions = transformModularEmitterOptions(dpgContext, "", { casing: "camel", }); diff --git a/packages/typespec-ts/test/util/test-util.ts b/packages/typespec-ts/test/util/test-util.ts index 1926b6904c..7c8dd034a4 100644 --- a/packages/typespec-ts/test/util/test-util.ts +++ b/packages/typespec-ts/test/util/test-util.ts @@ -331,7 +331,7 @@ export async function createDpgContextTestHelper( const sdkContext = { ...context, program, - rlcOptions: { + emitterOptions: { enableModelNamespace, ...configs, }, From 6420872f52051d8e585a54f38ce9e37d54b16147 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 16:56:29 -0500 Subject: [PATCH 06/15] refactor: decouple client code model build from modular generation The client code model is only consumed by metadata generation, not by modular source generation. Move buildClientCodeModels() to be owned by generateMetadataAndTest(), make it a pure function, and relocate the generateSample baseline reset out of transformClientModel() so the two phases no longer have a hidden ordering dependency. Also removes the dead serviceNameToClientModelsMap/needUnexpectedHelper maps. Works toward Azure/autorest.typescript#2726. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/src/index.ts | 30 +++++++------------ .../typespec-ts/src/transform/transform.ts | 3 -- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index f540b1d1a0..fda5cc0cf2 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -85,8 +85,6 @@ import { buildTestBrowserTsConfig, buildTestNodeTsConfig } from "./metadata/buil import { buildTsConfig, buildTsLintConfig, buildTsSampleConfig, buildTsSnippetsConfig, buildTsSrcBrowserConfig, buildTsSrcCjsConfig, buildTsSrcEsmConfig, buildTsSrcReactNativeConfig } from "./metadata/build-ts-config.js"; import { buildVitestConfig } from "./metadata/build-vitest-config.js"; import { buildWarpConfig } from "./metadata/build-warp-config.js"; -import { getClientName } from "./utils/name-constructors.js"; -import { hasUnexpectedHelper } from "./utils/operation-helpers.js"; export * from "./lib.js"; @@ -116,8 +114,6 @@ export async function $onEmit(context: EmitContext) { await enrichDpgContext(); const resolvedEmitterOptions = dpgContext.emitterOptions ?? {}; - const needUnexpectedHelper: Map = new Map(); - const serviceNameToClientModelsMap: Map = new Map(); provideContext("clientTypeMetaTree", new Map()); provideContext("symbolMap", new Map()); provideContext("outputProject", outputProject); @@ -164,20 +160,16 @@ export async function $onEmit(context: EmitContext) { }); provideSdkTypes(dpgContext); - const clientCodeModels: ClientModel[] = []; let modularEmitterOptions: ModularEmitterOptions; // 1. Clear sources folder await clearSrcFolder(); - // 2. Generate client code model - // TODO: skip this step in modular once modular generator is sufficiently decoupled - await buildClientCodeModels(); - // 3. Clear samples-dev folder if generateSample is true + // 2. Clear samples-dev folder if generateSample is true await clearSamplesDevFolder(); - // 4. Generate sources + // 3. Generate modular sources await generateModularSources(); - // 5. Generate metadata and test files + // 4. Generate metadata and test files function getTypespecTsVersion(context: EmitContext): string | undefined { const emitterMetadata = context.program.emitters.find( (emitter) => emitter.metadata.name === "@azure-tools/typespec-ts", @@ -248,15 +240,13 @@ export async function $onEmit(context: EmitContext) { } } - async function buildClientCodeModels() { + async function buildClientCodeModels(): Promise { + const models: ClientModel[] = []; const clients = getClients(dpgContext); for (const client of clients) { - const clientModels = await transformClientModel(client, dpgContext); - clientCodeModels.push(clientModels); - const serviceName = client.services[0]?.name ?? "Unknown"; - serviceNameToClientModelsMap.set(serviceName, clientModels); - needUnexpectedHelper.set(getClientName(clientModels), hasUnexpectedHelper(clientModels)); + models.push(await transformClientModel(client, dpgContext)); } + return models; } async function generateModularSources() { @@ -313,10 +303,11 @@ export async function $onEmit(context: EmitContext) { } buildRootIndex(dpgContext, modularEmitterOptions, rootIndexFile, subClient); } - // Enable modular sample generation when explicitly set to true or MPG + // Sample generation is enabled only when the modular generator actually emits + // samples. Reset the baseline here, then re-enable it below if any are emitted. + dpgContext.emitterOptions!.generateSample = false; if (emitterOptions["generate-sample"] === true) { const samples = emitSamples(dpgContext); - // Mark sample generation as enabled when modular samples were emitted. if (samples.length > 0) { dpgContext.emitterOptions!.generateSample = true; } @@ -367,6 +358,7 @@ export async function $onEmit(context: EmitContext) { async function generateMetadataAndTest(context: SdkContext) { const project = useContext("outputProject"); + const clientCodeModels = await buildClientCodeModels(); if (clientCodeModels.length === 0 || !clientCodeModels[0]) { return; } diff --git a/packages/typespec-ts/src/transform/transform.ts b/packages/typespec-ts/src/transform/transform.ts index 099a673eee..afe36b16ce 100644 --- a/packages/typespec-ts/src/transform/transform.ts +++ b/packages/typespec-ts/src/transform/transform.ts @@ -76,9 +76,6 @@ export async function transformClientModel( }, sourceDir, }; - // Legacy sample generation has been removed; modular samples are emitted separately, - // so the client model never carries sample groups. - options.generateSample = false; return model; } From 73af58f2a856bc0ee39038f5eecf4a84e9cb3df1 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 16:59:53 -0500 Subject: [PATCH 07/15] refactor: collapse redundant modularSourcesDir into sourcesDir GenerationDirDetail carried both sourcesDir and modularSourcesDir, which were always assigned the same value - a leftover from when RLC and modular emitted to separate directories. Unify on a single sourcesDir field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/src/index.ts | 14 ++++---------- .../typespec-ts/src/utils/cross-language-def.ts | 2 +- packages/typespec-ts/src/utils/interfaces.ts | 1 - 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index fda5cc0cf2..f0f139a1fd 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -137,7 +137,7 @@ export async function $onEmit(context: EmitContext) { ...(resolvedEmitterOptions.enableStorageCompat ? StorageCompatHelpers : {}), }, { - sourcesDir: dpgContext.generationPathDetail?.modularSourcesDir, + sourcesDir: dpgContext.generationPathDetail?.sourcesDir, rootDir: dpgContext.generationPathDetail?.rootDir, options: resolvedEmitterOptions, program, @@ -215,17 +215,11 @@ export async function $onEmit(context: EmitContext) { rootDir: projectRoot, metadataDir: projectRoot, sourcesDir: sourcesRoot, - modularSourcesDir: sourcesRoot, }; } async function clearSrcFolder() { - await emptyDir( - host, - dpgContext.generationPathDetail?.modularSourcesDir ?? - dpgContext.generationPathDetail?.sourcesDir ?? - "", - ); + await emptyDir(host, dpgContext.generationPathDetail?.sourcesDir ?? ""); } async function clearSamplesDevFolder() { @@ -250,7 +244,7 @@ export async function $onEmit(context: EmitContext) { } async function generateModularSources() { - const modularSourcesRoot = dpgContext.generationPathDetail?.modularSourcesDir ?? "src"; + const modularSourcesRoot = dpgContext.generationPathDetail?.sourcesDir ?? "src"; const project = useContext("outputProject"); modularEmitterOptions = transformModularEmitterOptions(dpgContext, modularSourcesRoot, { casing: "camel", @@ -369,7 +363,7 @@ export async function $onEmit(context: EmitContext) { // has a manual convenience layer. Skip all metadata/test file generation // to avoid unexpected modifications to files like package.json, README.md, // warp.config.yml, and snippets.spec.ts. metadata.json is still updated. - const sourcesDir = dpgContext.generationPathDetail?.modularSourcesDir ?? ""; + const sourcesDir = dpgContext.generationPathDetail?.sourcesDir ?? ""; const hasManualConvenienceLayer = getBaseFileName(sourcesDir) === "generated"; // Generate metadata const existingPackageFilePath = joinPaths( diff --git a/packages/typespec-ts/src/utils/cross-language-def.ts b/packages/typespec-ts/src/utils/cross-language-def.ts index a4afd6270d..b15178f990 100644 --- a/packages/typespec-ts/src/utils/cross-language-def.ts +++ b/packages/typespec-ts/src/utils/cross-language-def.ts @@ -11,7 +11,7 @@ export function generateCrossLanguageDefinitionFile(dpgContext: SdkContext): { CrossLanguagePackageId: string; CrossLanguageDefinitionId: Record; } { - const modularSourcesRoot = dpgContext.generationPathDetail?.modularSourcesDir ?? "src"; + const modularSourcesRoot = dpgContext.generationPathDetail?.sourcesDir ?? "src"; const emitterOptions = transformModularEmitterOptions(dpgContext, modularSourcesRoot, { casing: "camel", }); diff --git a/packages/typespec-ts/src/utils/interfaces.ts b/packages/typespec-ts/src/utils/interfaces.ts index 546ce59e0b..45a3b9bc05 100644 --- a/packages/typespec-ts/src/utils/interfaces.ts +++ b/packages/typespec-ts/src/utils/interfaces.ts @@ -13,7 +13,6 @@ export interface SdkContext extends TCGCSdkContext { export interface GenerationDirDetail { rootDir: string; sourcesDir: string; - modularSourcesDir?: string; metadataDir: string; } From 7d6d2490d3bfcb3038af1fa1f5f710fb731d4026 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 17:04:53 -0500 Subject: [PATCH 08/15] refactor: elide redundant "modular" qualifier from index.ts locals Modular is the only generation mode, so the qualifier added no signal on index.ts-local names. Renames generateModularSources -> generateSources and modularSourcesRoot -> sourcesRoot, and drops the vestigial "for modular packages" framing from a comment. Shared Modular* types are intentionally left untouched: dropping "modular" there would collide with EmitterOptions and ClientOptions, which are genuinely distinct concepts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/src/index.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index f0f139a1fd..3f40e50ab7 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -166,8 +166,8 @@ export async function $onEmit(context: EmitContext) { // 2. Clear samples-dev folder if generateSample is true await clearSamplesDevFolder(); - // 3. Generate modular sources - await generateModularSources(); + // 3. Generate sources + await generateSources(); // 4. Generate metadata and test files function getTypespecTsVersion(context: EmitContext): string | undefined { @@ -243,21 +243,21 @@ export async function $onEmit(context: EmitContext) { return models; } - async function generateModularSources() { - const modularSourcesRoot = dpgContext.generationPathDetail?.sourcesDir ?? "src"; + async function generateSources() { + const sourcesRoot = dpgContext.generationPathDetail?.sourcesDir ?? "src"; const project = useContext("outputProject"); - modularEmitterOptions = transformModularEmitterOptions(dpgContext, modularSourcesRoot, { + modularEmitterOptions = transformModularEmitterOptions(dpgContext, sourcesRoot, { casing: "camel", }); - emitLoggerFile(modularEmitterOptions, modularSourcesRoot); + emitLoggerFile(modularEmitterOptions, sourcesRoot); - const rootIndexFile = project.createSourceFile(`${modularSourcesRoot}/index.ts`, "", { + const rootIndexFile = project.createSourceFile(`${sourcesRoot}/index.ts`, "", { overwrite: true, }); - emitTypes(dpgContext, { sourceRoot: modularSourcesRoot }); - emitNonModelResponseTypes(dpgContext, { sourceRoot: modularSourcesRoot }); + emitTypes(dpgContext, { sourceRoot: sourcesRoot }); + emitNonModelResponseTypes(dpgContext, { sourceRoot: sourcesRoot }); buildSubpathIndexFile(modularEmitterOptions, "models", undefined, { recursive: true, }); @@ -307,7 +307,7 @@ export async function $onEmit(context: EmitContext) { } } - binder.resolveAllReferences(modularSourcesRoot, dpgContext.generationPathDetail?.rootDir); + binder.resolveAllReferences(sourcesRoot, dpgContext.generationPathDetail?.rootDir); if (program.compilerOptions.noEmit || program.hasError()) { return; } @@ -496,8 +496,8 @@ export async function $onEmit(context: EmitContext) { }), }; - // Always update package.json (adds #platform/* imports) and, for modular - // packages, exports, clientContextPaths and LRO deps. + // Always update package.json (adds #platform/* imports) along with + // exports, clientContextPaths and LRO deps. { // Read package.json content via host and pass parsed object const pkgSourceFile = await host.readFile(existingPackageFilePath); From 0fe1a80f991a4f175b07624a4ff3f82dc93dbb6d Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 17:16:49 -0500 Subject: [PATCH 09/15] refactor: rename ModularClientOptions to ClientModuleInfo The type carries a per-sub-client path/name descriptor (subfolder, clientName) and is unrelated to the ClientOptions resolved-options bag despite the similar name. Rename it and its producer getModularClientOptions -> getClientModuleInfo (and the local var) so the name reflects what it actually models. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/src/index.ts | 4 ++-- .../typespec-ts/src/modular/build-classical-client.ts | 6 +++--- .../src/modular/build-classical-operation-groups.ts | 4 ++-- .../typespec-ts/src/modular/build-client-context.ts | 6 +++--- packages/typespec-ts/src/modular/build-operations.ts | 4 ++-- .../typespec-ts/src/modular/build-project-files.ts | 6 +++--- .../typespec-ts/src/modular/build-restore-poller.ts | 4 ++-- packages/typespec-ts/src/modular/build-root-index.ts | 6 +++--- .../typespec-ts/src/modular/build-subpath-index.ts | 4 ++-- .../typespec-ts/src/modular/emit-models-options.ts | 4 ++-- .../src/modular/helpers/classical-operation-helpers.ts | 4 ++-- packages/typespec-ts/src/modular/interfaces.ts | 2 +- packages/typespec-ts/src/utils/client-utils.ts | 10 +++++----- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index 3f40e50ab7..5d0628a573 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -66,7 +66,7 @@ import { transformClientModel } from "./transform/transform.js"; import { transformClientOptions } from "./transform/transform-client-options.js"; import { getClientHierarchyMap, - getModularClientOptions, + getClientModuleInfo, getClients, } from "./utils/client-utils.js"; import { generateCrossLanguageDefinitionFile } from "./utils/cross-language-def.js"; @@ -290,7 +290,7 @@ export async function $onEmit(context: EmitContext) { exportIndex: true, interfaceOnly: true, }); - const { subfolder } = getModularClientOptions(subClient); + const { subfolder } = getClientModuleInfo(subClient); // Generate index file for clients with subfolders (multi-client scenarios and nested clients) if (subfolder) { buildSubClientIndexFile(dpgContext, subClient, modularEmitterOptions); diff --git a/packages/typespec-ts/src/modular/build-classical-client.ts b/packages/typespec-ts/src/modular/build-classical-client.ts index 2b641e4233..10d5864e99 100644 --- a/packages/typespec-ts/src/modular/build-classical-client.ts +++ b/packages/typespec-ts/src/modular/build-classical-client.ts @@ -19,7 +19,7 @@ import { useContext } from "../context-manager.js"; import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; import { refkey } from "../framework/refkey.js"; -import { getModularClientOptions, isMultiEndpointClient } from "../utils/client-utils.js"; +import { getClientModuleInfo, isMultiEndpointClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap, isTenantLevelOperation } from "../utils/operation-util.js"; import { AzurePollingDependencies } from "./external-dependencies.js"; @@ -47,7 +47,7 @@ export function buildClassicalClient( requiredOnly: true, }); const srcPath = emitterOptions.modularOptions.sourceRoot; - const { subfolder, clientName } = getModularClientOptions(clientMap); + const { subfolder, clientName } = getClientModuleInfo(clientMap); const clientFile = project.createSourceFile( `${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}${normalizeName( @@ -274,7 +274,7 @@ function buildClientOperationGroups( ) { let clientType = "Client"; const [_hierarchy, client] = clientMap; - const { subfolder } = getModularClientOptions(clientMap); + const { subfolder } = getClientModuleInfo(clientMap); if (subfolder && subfolder !== "") { clientType = `Client.${clientClass.getName()}`; } diff --git a/packages/typespec-ts/src/modular/build-classical-operation-groups.ts b/packages/typespec-ts/src/modular/build-classical-operation-groups.ts index e6156c84ce..96a7d82895 100644 --- a/packages/typespec-ts/src/modular/build-classical-operation-groups.ts +++ b/packages/typespec-ts/src/modular/build-classical-operation-groups.ts @@ -1,7 +1,7 @@ import { SdkClientType, SdkServiceOperation } from "@azure-tools/typespec-client-generator-core"; import { SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; -import { getModularClientOptions } from "../utils/client-utils.js"; +import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { getClassicalOperation } from "./helpers/classical-operation-helpers.js"; @@ -17,7 +17,7 @@ export function buildClassicOperationFiles( // const sdkPackage = dpgContext.sdkPackage; const project = useContext("outputProject"); const [_hierarchy, client] = clientMap; - const { subfolder } = getModularClientOptions(clientMap); + const { subfolder } = getClientModuleInfo(clientMap); const classicOperationFiles: Map = new Map(); const methodMap = getMethodHierarchiesMap(dpgContext, client); for (const [prefixKey, operations] of methodMap) { diff --git a/packages/typespec-ts/src/modular/build-client-context.ts b/packages/typespec-ts/src/modular/build-client-context.ts index 579f3d9837..b001541fac 100644 --- a/packages/typespec-ts/src/modular/build-client-context.ts +++ b/packages/typespec-ts/src/modular/build-client-context.ts @@ -23,7 +23,7 @@ import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; import { refkey } from "../framework/refkey.js"; import { reportDiagnostic } from "../lib.js"; -import { getModularClientOptions } from "../utils/client-utils.js"; +import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { buildEnumTypes, getApiVersionEnum } from "./emit-models.js"; import { getDocsFromDescription } from "./helpers/docs-helpers.js"; @@ -40,7 +40,7 @@ export function getClientContextPath( emitterOptions: ModularEmitterOptions, ): string { const [_, client] = clientMap; - const { subfolder } = getModularClientOptions(clientMap); + const { subfolder } = getClientModuleInfo(clientMap); const name = getClientName(client); const srcPath = emitterOptions.modularOptions.sourceRoot; const contentPath = `${srcPath}/${ @@ -61,7 +61,7 @@ export function buildClientContext( const dependencies = useDependencies(); const [hierarchy, client] = clientMap; const name = getClientName(client); - const { clientName } = getModularClientOptions(clientMap); + const { clientName } = getClientModuleInfo(clientMap); const requiredParams = getClientParametersDeclaration(client, dpgContext, { onClientOnly: false, requiredOnly: true, diff --git a/packages/typespec-ts/src/modular/build-operations.ts b/packages/typespec-ts/src/modular/build-operations.ts index 84d5ee538e..e0c7f546e2 100644 --- a/packages/typespec-ts/src/modular/build-operations.ts +++ b/packages/typespec-ts/src/modular/build-operations.ts @@ -22,7 +22,7 @@ import { addDeclaration } from "../framework/declaration.js"; import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; import { refkey } from "../framework/refkey.js"; -import { getModularClientOptions, isMultiEndpointClient } from "../utils/client-utils.js"; +import { getClientModuleInfo, isMultiEndpointClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap, @@ -48,7 +48,7 @@ export function buildOperationFiles( const project = useContext("outputProject"); const [_, client] = clientMap; const operationFiles: Set = new Set(); - const { subfolder, clientName } = getModularClientOptions(clientMap); + const { subfolder, clientName } = getClientModuleInfo(clientMap); const isMultiEndpoint = isMultiEndpointClient(dpgContext); const clientType = isMultiEndpoint ? `Client.${clientName}` : "Client"; const methodMap = getMethodHierarchiesMap(dpgContext, client); diff --git a/packages/typespec-ts/src/modular/build-project-files.ts b/packages/typespec-ts/src/modular/build-project-files.ts index d07928e31c..c8a1d3cb75 100644 --- a/packages/typespec-ts/src/modular/build-project-files.ts +++ b/packages/typespec-ts/src/modular/build-project-files.ts @@ -1,6 +1,6 @@ import { getRelativePathFromDirectory, joinPaths } from "@typespec/compiler"; import { useContext } from "../context-manager.js"; -import { getClientHierarchyMap, getModularClientOptions } from "../utils/client-utils.js"; +import { getClientHierarchyMap, getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { getClassicalLayerPrefix } from "./helpers/naming-helpers.js"; @@ -41,7 +41,7 @@ function buildExportsForMultiClient( if (hierarchy.length === 0) { hasTopLevelClient = true; } - const { subfolder } = getModularClientOptions([hierarchy, client]); + const { subfolder } = getClientModuleInfo([hierarchy, client]); if (subfolder !== "" && methodMap.size > 0) { packageInfo.exports[`./${subfolder}`] = `${srcPrefix}/${subfolder}/index.ts`; @@ -55,7 +55,7 @@ function buildExportsForMultiClient( // TODO: support api subpath exports for multi-service. Skip for now. https://github.com/Azure/autorest.typescript/issues/3717 if (!emitterOptions.options.isMultiService) { for (const flattenedClient of clientMap) { - const { subfolder } = getModularClientOptions(flattenedClient); + const { subfolder } = getClientModuleInfo(flattenedClient); const client = flattenedClient[1]; const methodMap = getMethodHierarchiesMap(context, client); for (const [prefixKey, _] of methodMap) { diff --git a/packages/typespec-ts/src/modular/build-restore-poller.ts b/packages/typespec-ts/src/modular/build-restore-poller.ts index f58c609e94..e9426573f9 100644 --- a/packages/typespec-ts/src/modular/build-restore-poller.ts +++ b/packages/typespec-ts/src/modular/build-restore-poller.ts @@ -4,7 +4,7 @@ import { SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; -import { getModularClientOptions } from "../utils/client-utils.js"; +import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { buildLroDeserDetailMap } from "./build-operations.js"; @@ -23,7 +23,7 @@ export function buildRestorePoller( const project = useContext("outputProject"); const [_, client] = clientMap; const dependencies = useDependencies(); - const { subfolder } = getModularClientOptions(clientMap); + const { subfolder } = getClientModuleInfo(clientMap); const methodMap = getMethodHierarchiesMap(context, client); const hasLro = Array.from(methodMap.values()).some((operations) => { return operations.some(isLroOnlyOperation); diff --git a/packages/typespec-ts/src/modular/build-root-index.ts b/packages/typespec-ts/src/modular/build-root-index.ts index 265a418c25..5ad982177c 100644 --- a/packages/typespec-ts/src/modular/build-root-index.ts +++ b/packages/typespec-ts/src/modular/build-root-index.ts @@ -4,7 +4,7 @@ import { Project, SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; import { resolveReference } from "../framework/reference.js"; import { reportDiagnostic } from "../lib.js"; -import { getModularClientOptions } from "../utils/client-utils.js"; +import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { partitionAndEmitExports } from "./build-subpath-index.js"; @@ -34,7 +34,7 @@ export function buildRootIndex( const project = useContext("outputProject"); const [_, client] = clientMap; const srcPath = emitterOptions.modularOptions.sourceRoot; - const { subfolder } = getModularClientOptions(clientMap); + const { subfolder } = getClientModuleInfo(clientMap); const clientName = `${getClassicalClientName(client)}`; const clientFile = project.getSourceFile( `${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}${normalizeName( @@ -365,7 +365,7 @@ export function buildSubClientIndexFile( ) { const project = useContext("outputProject"); const [_, client] = clientMap; - const { subfolder } = getModularClientOptions(clientMap); + const { subfolder } = getClientModuleInfo(clientMap); const srcPath = emitterOptions.modularOptions.sourceRoot; const subClientIndexFile = project.createSourceFile( `${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}index.ts`, diff --git a/packages/typespec-ts/src/modular/build-subpath-index.ts b/packages/typespec-ts/src/modular/build-subpath-index.ts index e4edf19ec5..797548fba7 100644 --- a/packages/typespec-ts/src/modular/build-subpath-index.ts +++ b/packages/typespec-ts/src/modular/build-subpath-index.ts @@ -4,7 +4,7 @@ import { ModularEmitterOptions } from "./interfaces.js"; import { Node, SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; -import { getModularClientOptions } from "../utils/client-utils.js"; +import { getClientModuleInfo } from "../utils/client-utils.js"; export interface buildSubpathIndexFileOptions { exportIndex?: boolean; @@ -19,7 +19,7 @@ export function buildSubpathIndexFile( options: buildSubpathIndexFileOptions = {}, ) { const project = useContext("outputProject"); - const subfolder = clientMap ? (getModularClientOptions(clientMap).subfolder ?? "") : ""; + const subfolder = clientMap ? (getClientModuleInfo(clientMap).subfolder ?? "") : ""; const srcPath = emitterOptions.modularOptions.sourceRoot; // Skip to export these files because they are used internally. const skipFiles = ["pagingHelpers.ts", "pollingHelpers.ts"]; diff --git a/packages/typespec-ts/src/modular/emit-models-options.ts b/packages/typespec-ts/src/modular/emit-models-options.ts index ef145cc608..d77a473328 100644 --- a/packages/typespec-ts/src/modular/emit-models-options.ts +++ b/packages/typespec-ts/src/modular/emit-models-options.ts @@ -4,7 +4,7 @@ import { ModularEmitterOptions } from "./interfaces.js"; import { SdkClientType, SdkServiceOperation } from "@azure-tools/typespec-client-generator-core"; import { useContext } from "../context-manager.js"; -import { getModularClientOptions } from "../utils/client-utils.js"; +import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { buildOperationOptions } from "./build-operations.js"; @@ -20,7 +20,7 @@ export function buildApiOptions( const project = useContext("outputProject"); const [_, client] = clientMap; const modelOptionsFiles = []; - const { subfolder } = getModularClientOptions(clientMap); + const { subfolder } = getClientModuleInfo(clientMap); const methodMap = getMethodHierarchiesMap(context, client); for (const [prefixKey, operations] of methodMap) { const prefixes = prefixKey.split("/"); diff --git a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts index 7964e45b08..9f153646b9 100644 --- a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts @@ -10,7 +10,7 @@ import { import { addDeclaration } from "../../framework/declaration.js"; import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; -import { getModularClientOptions } from "../../utils/client-utils.js"; +import { getClientModuleInfo } from "../../utils/client-utils.js"; import { SdkContext } from "../../utils/interfaces.js"; import { ServiceOperation } from "../../utils/operation-util.js"; import { AzurePollingDependencies } from "../external-dependencies.js"; @@ -55,7 +55,7 @@ export function getClassicalOperation( ) { const prefixes = operationGroup[0]; const operations = operationGroup[1]; - const { clientName } = getModularClientOptions(clientMap); + const { clientName } = getClientModuleInfo(clientMap); const hasClientContextImport = classicFile.getImportDeclarations().filter((i) => { return ( i.getModuleSpecifierValue() === diff --git a/packages/typespec-ts/src/modular/interfaces.ts b/packages/typespec-ts/src/modular/interfaces.ts index 2e9330fdf0..91f58b1768 100644 --- a/packages/typespec-ts/src/modular/interfaces.ts +++ b/packages/typespec-ts/src/modular/interfaces.ts @@ -10,7 +10,7 @@ export interface ModularEmitterOptions { modularOptions: ModularOptions; } -export interface ModularClientOptions { +export interface ClientModuleInfo { subfolder?: string; clientName: string; } diff --git a/packages/typespec-ts/src/utils/client-utils.ts b/packages/typespec-ts/src/utils/client-utils.ts index 0e910628b5..1561fd0718 100644 --- a/packages/typespec-ts/src/utils/client-utils.ts +++ b/packages/typespec-ts/src/utils/client-utils.ts @@ -14,7 +14,7 @@ import { Namespace, Operation, } from "@typespec/compiler"; -import { ModularClientOptions } from "../modular/interfaces.js"; +import { ClientModuleInfo } from "../modular/interfaces.js"; import { SdkContext } from "./interfaces.js"; import { NameType, normalizeName } from "./name-utils.js"; @@ -114,13 +114,13 @@ export function isMultiEndpointClient(dpgContext: SdkContext): boolean { return getClients(dpgContext).length > 1; } -export function getModularClientOptions(clientMap: [string[], SdkClientType]) { +export function getClientModuleInfo(clientMap: [string[], SdkClientType]) { const [hierarchy, client] = clientMap; - const clientOptions: ModularClientOptions = { + const clientModuleInfo: ClientModuleInfo = { clientName: `${client.name.replace(/Client$/, "")}Context`, }; - clientOptions.subfolder = hierarchy.join("/"); - return clientOptions; + clientModuleInfo.subfolder = hierarchy.join("/"); + return clientModuleInfo; } export function getClientHierarchyMap( From e2980a4ed7a83b2dab6bbff4d4a8050c8eed09e4 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 17:25:38 -0500 Subject: [PATCH 10/15] docs: rewrite typespec-ts CONTRIBUTING for current reality The old guide predated the move into typespec-azure and described the defunct RLC generator: wrong clone URL, nonexistent test suites/scripts, dead start-test-server/smoke-test flows, and VS Code launch profiles that no longer exist. Rewrite it around the actual monorepo setup (submodule init, pnpm filtered build), the three vitest projects, the spector generate -> check:tree pipeline, and the real Debug Current Test File profile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/CONTRIBUTING.md | 160 ++++++++++++--------------- 1 file changed, 73 insertions(+), 87 deletions(-) diff --git a/packages/typespec-ts/CONTRIBUTING.md b/packages/typespec-ts/CONTRIBUTING.md index b175053188..922881f2f5 100644 --- a/packages/typespec-ts/CONTRIBUTING.md +++ b/packages/typespec-ts/CONTRIBUTING.md @@ -1,70 +1,80 @@ # How to Contribute -## Prerequisite +## Prerequisites -Please follow the **[Prerequisite](../../CONTRIBUTING.md#prerequisites)** part to install the dependencies. +Follow the repository-level **[Prerequisites](../../CONTRIBUTING.md#prerequisites)** to install +the required tooling (Node.js and `pnpm`). The command scripts under `test/commands/*` run on +`node` directly (no `tsx`), which requires **Node >= 22.18**. -## Steps to clone, build & test +## Clone, build & test -1. Use the following command to clone the Typescript/Javascript SDK generator repository: +1. Clone the `typespec-azure` monorepo (this emitter lives in `packages/typespec-ts`). The repo + uses a git submodule for `core/`, so initialize submodules when cloning: -``` -git clone https://github.com/Azure/autorest.typescript.git -``` + ```bash + git clone --recurse-submodules https://github.com/Azure/typespec-azure.git + ``` -2. Use the following commands to build the SDK generator: + If you already cloned without `--recurse-submodules`, run `git submodule update --init`. -``` -pnpm install -pnpm build -``` +2. Install dependencies and build from the repo root: -3. There are also 3 test-suites in the RLC generator: - 1. Unit tests (which could be found at `test/unit/*`) - 2. Integration tests (which could be found at `test/integration/*`) - 3. Smoke tests (which could be found at `../../packages/typespec-test`) + ```bash + pnpm install + pnpm build + ``` -1. You can run the Unit tests & Integration tests using the following command: + To build only this package and its dependencies: -``` -npm run test -``` + ```bash + pnpm -r --filter "@azure-tools/typespec-ts..." build + ``` -Running the command above will do the following things: +3. Run the commands below from `packages/typespec-ts`. -- Start TestServer -- Build TypeSpec TS -- Generate all scenarios in parallel (i.e. Dictionary, Extensible Enums, Models, Resiliency) -- Run all the tests under test/integration -- Stop TestServer +## Test suites -**_Note_**: If your development environment is Windows, then run the command `npm run start-test-server`(in a seperate window) before running `npm run test` and run the command `npm run stop-test-server` after. (In non windows machines, we could run the test-server in the background automatically. But, in Windows machines, it has to be done manually.) +The package is tested through three vitest projects (configured in `vitest.config.ts`): -5. You can run the Smoke tests using the following command: +| Project | Location | Covers | Command | +| --- | --- | --- | --- | +| `test-next` | `test-next/**` | Modern unit tests | `pnpm test-next` | +| `unit-modular` | `test/modular-unit/**` | Modular unit tests | `pnpm unit-test` | +| `integration-azure-modular` | `test/azure-modular-integration/**` | Modular spector end-to-end tests | `pnpm integration-test-ci:azure-modular` | -```shell -cd ../../packages/typespec-test -npm run smoke-test -``` +`pnpm lint` runs ESLint with `--max-warnings=0`. -## How to add an integration test case +The integration suite generates real clients from specs and runs them against a local spector +test server; `pnpm integration-test-ci:azure-modular` starts the server, generates, and runs the +assertions for you. To (re)generate the tracked baselines without running the tests: -Whenever you work on adding a feature/fixing a bug, this would probably be your first step. You create a test case and then run it through the generator, see the result, modify the generator, run it again and so on, until you get the desired output. +```bash +pnpm copy:typespec # assemble ./temp/specs from the http-specs packages +pnpm generate-tsp-only # regenerate all Azure modular baselines (client + declarations) +pnpm check:tree # fails if regeneration left the git tree dirty +``` -1. Pick up a typespec as your test input in spector. Below are some examples +> Only `src/index.d.ts` is tracked per generated package, so `check:tree` is what guards the +> generated API surface in CI. See `.github/instructions/typespec-ts.instructions.md` for the +> full pipeline details. - Let us say your test input is `authentication/api-key/main.tsp` in @typespec/http-specs or @azure-tools/azure-http-specs. +## How to add an integration (spector) test case -1. Now add an entry to the TypeSpecRanchConfig to the file [`spector-list.js`](./test/commands/spector-list.js). In the file, add the following to the array. +1. Pick a spec from `@typespec/http-specs` or `@azure-tools/azure-http-specs` as your input + (for example `authentication/api-key`). - ```typescript - { - outputPath: "authentication/apiKey", - inputPath: "authentication/api-key" - }, +2. Add an entry to the `azureModularTsps` array in + [`test/commands/spector-list.js`](./test/commands/spector-list.js): + + ```js + { + outputPath: "authentication/apiKey", + inputPath: "authentication/api-key", + }, ``` -1. Create a tspconfig.yaml in `./test/integration/generated/authentication/apiKey` folder and put the following content in it. +3. Create a `tspconfig.yaml` under + `test/azure-modular-integration/generated/authentication/apiKey/`: ```yaml emit: @@ -73,60 +83,36 @@ Whenever you work on adding a feature/fixing a bug, this would probably be your "@azure-tools/typespec-ts": emitter-output-dir: "{project-root}" generate-metadata: true - generate-test: true - include-shortcuts: true - add-credentials: false + generate-test: false is-typespec-test: true - title: AuthApiKeyClient + hierarchy-client: false package-details: name: "@msinternal/auth-apikey" description: "Auth api key Test Service" - version: "1.0.0" ``` -1. Now, You can generate the RLC for your test case with the following command: (Initially, during your development, you do not want to run all the cases during every step of your development, you can comment out other test cases. But, once your code changes are complete for your case, then you need to run the entire suite to ensure that your changes did not cause any unwanted changes.) +4. Generate the client for your case. During development you can temporarily trim + `azureModularTsps` to just your entry for a faster loop, and emit only the importable sources: - ```shell - npm run generate-tsp-only + ```bash + pnpm copy:typespec + pnpm generate-tsp-only:azure-modular:client ``` -1. Once you are satisfied with the generated code, you can add a spec file such as `testUserCaseRest.spec.ts` file [here](./test/integration). You can find several examples in the same place. - -## How to debug + Once your change is complete, regenerate the whole suite and verify there are no unexpected + diffs: -### `generate-tsp-only` step - -If you would like to debug the `generate-tsp-only` step for our test input, Open the repository in VS Code -> Select `Generate code for TypeSpec Emitter` section -> Click `Attach`. - -### Spec file - -If you would like to debug the `testUserCase.spec.ts` file (after the SDK is generated), Open the repository in VS Code -> Open the `testUserCase.spec.ts` file -> Select `Run and Debug` section -> Click `IntegrationTests - Current File`. - -### How to debug an unit test case - -- In VS Code, We have created a Debugging profile for UnitTests to start debugging: - 1. Go to the debugger tab - 2. Select the "[TypeSpec] - Unit Test" Profile - 3. Click the "Play" button - -- Your breakpoints will start hitting, you can set breakpoints in either Test or Generator code - -### Integration Tests - -- In order to debug integration tests you need to start the test server, by running: - - npm run start-test-server:v1 - -- Once the Test Server is running - 1. In VSCode go to the debugger tab - 2. Select the "[TypeSpec] - Integration Test" profile from the drop down - 3. Click the "Play" button - -- **\*\***IMPORTANT**\*\***: Running Integration Tests for debugging, does not re-generate the test clients so make sure that after each change you do: - - Re-generate all the test swaggers + ```bash + pnpm generate-tsp-only + pnpm check:tree + ``` - npm run generate-tsp-only -- --build +5. Add a `*.test.ts` file under `test/azure-modular-integration/` with your assertions. There are + many existing examples in that folder (e.g. `auth-api-key.test.ts`). - - Re-generate a specific swagger +## How to debug - npm run generate-tsp-only -- -i bodyComplexRest -b +The repo ships a **Debug Current Test File** VS Code launch profile (`.vscode/launch.json`) that +runs the currently open file through vitest with the debugger attached. Open any `*.test.ts` +file (unit or integration), select that profile, and press play — breakpoints work in both the +test and the emitter `src/`. \ No newline at end of file From 59d0e0234fbc98a04e25f832462a003728c10c08 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 17:31:32 -0500 Subject: [PATCH 11/15] docs: fix RLC-era wording and drop "experimental" framing README documented an option as applying "in RLC"; lib.ts already dropped that qualifier, so align the README. Also remove the stale "experimental" descriptor from the README tagline and the package.json description -- this is the production Azure TypeScript emitter, not an experiment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/README.md | 4 ++-- packages/typespec-ts/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/typespec-ts/README.md b/packages/typespec-ts/README.md index bf56045eaa..cf270d2894 100644 --- a/packages/typespec-ts/README.md +++ b/packages/typespec-ts/README.md @@ -1,6 +1,6 @@ # @azure-tools/typespec-ts -An experimental TypeSpec emitter for TypeScript +A TypeSpec emitter for TypeScript ## Install @@ -196,7 +196,7 @@ The emitter has a normalization logic for enum member key, to ignore this normal **Type:** `boolean` -Whether to generate the backward-compatible code for query parameter serialization for array types in RLC. Defaults to `false` +Whether to generate the backward-compatible code for query parameter serialization for array types. Defaults to `false` ### `typespec-title-map` diff --git a/packages/typespec-ts/package.json b/packages/typespec-ts/package.json index ddc9a1490a..04f91cc47a 100644 --- a/packages/typespec-ts/package.json +++ b/packages/typespec-ts/package.json @@ -1,7 +1,7 @@ { "name": "@azure-tools/typespec-ts", "version": "0.55.0", - "description": "An experimental TypeSpec emitter for TypeScript", + "description": "A TypeSpec emitter for TypeScript", "main": "dist/src/index.js", "type": "module", "exports": { From 944917461d3230e69dacb6ad38046814e7a5d687 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 17:47:17 -0500 Subject: [PATCH 12/15] refactor: remove vestigial compatibility-query-multi-format option This option only ever influenced the transform/client-code-model (RLC lineage) serialization path -- it was read solely by getSpecialSerializeInfo and getParameterSerializationInfo, both reached only from transform/*. The modular query-collection serialization goes through getCollectionFormatHelper, which never consulted the flag. With RLC output gone the option is dead, and no spec/SDK repo sets it. Remove the option (lib.ts interface + schema, ClientOptions field) and the now-dead branches. Its default was false, so getHasMultiCollection collapses to header-only multi and the parameter-utils union fallback drops -- both identical to prior default behavior, making this output-neutral. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/README.md | 6 ----- packages/typespec-ts/src/interfaces.ts | 1 - packages/typespec-ts/src/lib.ts | 7 ------ .../src/transform/transform-client-options.ts | 2 -- .../transform-helper-function-details.ts | 2 +- .../src/transform/transform-parameters.ts | 2 +- .../typespec-ts/src/utils/operation-util.ts | 22 +++++-------------- .../typespec-ts/src/utils/parameter-utils.ts | 3 --- 8 files changed, 7 insertions(+), 38 deletions(-) diff --git a/packages/typespec-ts/README.md b/packages/typespec-ts/README.md index cf270d2894..0a87ddbf0c 100644 --- a/packages/typespec-ts/README.md +++ b/packages/typespec-ts/README.md @@ -192,12 +192,6 @@ The emitter will use camel case to normalize the property name, to ignore this n The emitter has a normalization logic for enum member key, to ignore this normalization, you can set this option to true -### `compatibility-query-multi-format` - -**Type:** `boolean` - -Whether to generate the backward-compatible code for query parameter serialization for array types. Defaults to `false` - ### `typespec-title-map` **Type:** `object` diff --git a/packages/typespec-ts/src/interfaces.ts b/packages/typespec-ts/src/interfaces.ts index 172d34a0b2..cb79c5c332 100644 --- a/packages/typespec-ts/src/interfaces.ts +++ b/packages/typespec-ts/src/interfaces.ts @@ -234,7 +234,6 @@ export interface ClientOptions { clearOutputFolder?: boolean; ignorePropertyNameNormalize?: boolean; ignoreEnumMemberNameNormalize?: boolean; - compatibilityQueryMultiFormat?: boolean; typespecTitleMap?: Record; hasSubscriptionId?: boolean; compatibilityLro?: boolean; diff --git a/packages/typespec-ts/src/lib.ts b/packages/typespec-ts/src/lib.ts index 633a6f7a00..b8764e79b9 100644 --- a/packages/typespec-ts/src/lib.ts +++ b/packages/typespec-ts/src/lib.ts @@ -49,7 +49,6 @@ export interface EmitterOptions { "experimental-extensible-enums"?: boolean; "clear-output-folder"?: boolean; "ignore-property-name-normalize"?: boolean; - "compatibility-query-multi-format"?: boolean; "typespec-title-map"?: Record; "ignore-enum-member-name-normalize"?: boolean; //TODO should remove this after finish the release tool test @@ -234,12 +233,6 @@ export const EmitterOptionsSchema: JSONSchemaType = { description: "The emitter has a normalization logic for enum member key, to ignore this normalization, you can set this option to true", }, - "compatibility-query-multi-format": { - type: "boolean", - nullable: true, - description: - "Whether to generate the backward-compatible code for query parameter serialization for array types. Defaults to `false`", - }, "typespec-title-map": { type: "object", additionalProperties: { diff --git a/packages/typespec-ts/src/transform/transform-client-options.ts b/packages/typespec-ts/src/transform/transform-client-options.ts index e73b96f376..ad3b9de948 100644 --- a/packages/typespec-ts/src/transform/transform-client-options.ts +++ b/packages/typespec-ts/src/transform/transform-client-options.ts @@ -50,7 +50,6 @@ function extractClientOptions( const experimentalExtensibleEnums = emitterOptions["experimental-extensible-enums"]; const ignorePropertyNameNormalize = emitterOptions["ignore-property-name-normalize"]; const ignoreEnumMemberNameNormalize = emitterOptions["ignore-enum-member-name-normalize"]; - const compatibilityQueryMultiFormat = emitterOptions["compatibility-query-multi-format"]; const enableStorageCompat = emitterOptions["enable-storage-compat"] === true; const treatUnknownAsRecord = emitterOptions["treat-unknown-as-record"] === true; const typespecTitleMap = emitterOptions["typespec-title-map"]; @@ -79,7 +78,6 @@ function extractClientOptions( compatibilityLro, experimentalExtensibleEnums, ignorePropertyNameNormalize, - compatibilityQueryMultiFormat, typespecTitleMap, ignoreEnumMemberNameNormalize, hasSubscriptionId, diff --git a/packages/typespec-ts/src/transform/transform-helper-function-details.ts b/packages/typespec-ts/src/transform/transform-helper-function-details.ts index c60873855c..f1d5f95de1 100644 --- a/packages/typespec-ts/src/transform/transform-helper-function-details.ts +++ b/packages/typespec-ts/src/transform/transform-helper-function-details.ts @@ -65,7 +65,7 @@ function extractSpecialSerializeInfo(client: SdkClient, dpgContext: SdkContext) const route = getHttpOperationWithCache(dpgContext, op); route.parameters.parameters.forEach((parameter) => { const format = getCollectionFormat(dpgContext, parameter as any); - const serializeInfo = getSpecialSerializeInfo(dpgContext, parameter.type, format!); + const serializeInfo = getSpecialSerializeInfo(parameter.type, format!); hasMultiCollection = hasMultiCollection ? hasMultiCollection : serializeInfo.hasMultiCollection; diff --git a/packages/typespec-ts/src/transform/transform-parameters.ts b/packages/typespec-ts/src/transform/transform-parameters.ts index 920c341bc6..724966df51 100644 --- a/packages/typespec-ts/src/transform/transform-parameters.ts +++ b/packages/typespec-ts/src/transform/transform-parameters.ts @@ -122,7 +122,7 @@ function getParameterMetadata( let description = getFormattedPropertyDoc(program, parameter.param, schema) ?? ""; const format = getCollectionFormat(dpgContext, parameter as any); if (isArrayType(schema) && format) { - const serializeInfo = getSpecialSerializeInfo(dpgContext, parameter.type, format); + const serializeInfo = getSpecialSerializeInfo(parameter.type, format); if (serializeInfo.hasMultiCollection || serializeInfo.hasCsvCollection) { description += `${description ? "\n" : ""}This parameter could be formatted as ${serializeInfo.collectionInfo.join( ", ", diff --git a/packages/typespec-ts/src/utils/operation-util.ts b/packages/typespec-ts/src/utils/operation-util.ts index c499a3d770..ceb291625b 100644 --- a/packages/typespec-ts/src/utils/operation-util.ts +++ b/packages/typespec-ts/src/utils/operation-util.ts @@ -443,7 +443,7 @@ export function hasPagingOperations(client: SdkClient, dpgContext: SdkContext) { export function hasCollectionFormatInfo(paramType: string, paramFormat: string) { return ( - getHasMultiCollection(paramType, paramFormat, false) || + getHasMultiCollection(paramType, paramFormat) || getHasSsvCollection(paramType, paramFormat) || getHasTsvCollection(paramType, paramFormat) || getHasCsvCollection(paramType, paramFormat) || @@ -452,17 +452,8 @@ export function hasCollectionFormatInfo(paramType: string, paramFormat: string) ); } -export function getSpecialSerializeInfo( - dpgContext: SdkContext, - paramType: string, - paramFormat: string, -) { - const hasMultiCollection = getHasMultiCollection( - paramType, - paramFormat, - // Include query multi support in compatibility mode - dpgContext.emitterOptions?.compatibilityQueryMultiFormat ?? false, - ); +export function getSpecialSerializeInfo(paramType: string, paramFormat: string) { + const hasMultiCollection = getHasMultiCollection(paramType, paramFormat); const hasCsvCollection = getHasCsvCollection(paramType, paramFormat); const descriptions = []; const collectionInfo = []; @@ -483,11 +474,8 @@ export function getSpecialSerializeInfo( }; } -function getHasMultiCollection(paramType: string, paramFormat: string, includeQuery = true) { - return ( - ((includeQuery && paramType === "query") || paramType === "header") && - paramFormat === KnownCollectionFormat.Multi - ); +function getHasMultiCollection(paramType: string, paramFormat: string) { + return paramType === "header" && paramFormat === KnownCollectionFormat.Multi; } function getHasSsvCollection(paramType: string, paramFormat: string) { return ( diff --git a/packages/typespec-ts/src/utils/parameter-utils.ts b/packages/typespec-ts/src/utils/parameter-utils.ts index c08670f492..902e6d4f02 100644 --- a/packages/typespec-ts/src/utils/parameter-utils.ts +++ b/packages/typespec-ts/src/utils/parameter-utils.ts @@ -67,9 +67,6 @@ export function getParameterSerializationInfo( }); } - if (dpgContext.emitterOptions?.compatibilityQueryMultiFormat) { - wrapperType = buildUnionType([wrapperType, { type: "string", name: "string" }]); - } return buildSerializationInfo(wrapperType); } From aa9659dff5e428fe0aa82d50aab87ced3e903310 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 17:48:09 -0500 Subject: [PATCH 13/15] chore: add changeset for typespec-ts rlc-common cleanup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../typespec-ts-rlc-common-cleanup-2026-6-26-17-30-0.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/typespec-ts-rlc-common-cleanup-2026-6-26-17-30-0.md diff --git a/.chronus/changes/typespec-ts-rlc-common-cleanup-2026-6-26-17-30-0.md b/.chronus/changes/typespec-ts-rlc-common-cleanup-2026-6-26-17-30-0.md new file mode 100644 index 0000000000..3e11366584 --- /dev/null +++ b/.chronus/changes/typespec-ts-rlc-common-cleanup-2026-6-26-17-30-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@azure-tools/typespec-ts" +--- + +Clean up vestigial RLC technical debt in the emitter now that only Modular generation is supported: remove the dead `rlc-common` subfolder and relocate its live code into the main source tree, de-RLC internal type/function names (for example `RLCModel` -> `ClientModel`, `ModularClientOptions` -> `ClientModuleInfo`), decouple the client code model build from source generation, collapse the redundant `modularSourcesDir`, remove the dead `compatibility-query-multi-format` emitter option, and refresh the README and CONTRIBUTING docs. No changes to the generated output. From 7f7c71fd5c7b23c4de35e7df2f063b0144607b13 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 20:49:28 -0500 Subject: [PATCH 14/15] Apply prettier formatting Run prettier --write across files touched by the rlc-common cleanup and de-RLC rename passes. The relocation appended/modified imports that prettier's import-sort plugin reorders and re-wraps; this brings them in line so `prettier . --check` (CI format job) passes. Formatting-only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/typespec-ts/CONTRIBUTING.md | 16 +++--- packages/typespec-ts/src/index.ts | 51 +++++++++++-------- .../src/metadata/build-package-file.ts | 2 +- .../src/metadata/build-readme-file.ts | 2 +- .../src/metadata/test/build-snippets.ts | 2 +- .../src/modular/build-classical-client.ts | 2 +- .../build-classical-operation-groups.ts | 2 +- .../src/modular/build-client-context.ts | 2 +- .../src/modular/build-operations.ts | 2 +- .../src/modular/build-project-files.ts | 2 +- .../src/modular/build-restore-poller.ts | 2 +- .../src/modular/build-root-index.ts | 2 +- .../src/modular/emit-models-options.ts | 2 +- .../typespec-ts/src/modular/emit-models.ts | 2 +- .../typespec-ts/src/modular/emit-samples.ts | 2 +- .../typespec-ts/src/modular/emit-tests.ts | 2 +- .../helpers/classical-operation-helpers.ts | 2 +- .../src/modular/helpers/client-helpers.ts | 2 +- .../modular/helpers/example-value-helpers.ts | 2 +- .../src/modular/helpers/naming-helpers.ts | 2 +- .../src/modular/helpers/operation-helpers.ts | 2 +- .../src/modular/helpers/type-helpers.ts | 2 +- .../build-deserializer-function.ts | 2 +- .../build-serializer-function.ts | 2 +- .../build-xml-serializer-function.ts | 2 +- .../type-expressions/get-type-expression.ts | 2 +- .../transform/transform-api-version-info.ts | 4 +- .../src/transform/transform-client-options.ts | 4 +- .../transform-helper-function-details.ts | 2 +- .../src/transform/transform-parameters.ts | 11 +++- .../src/transform/transform-paths.ts | 4 +- .../src/transform/transform-responses.ts | 11 +++- .../src/transform/transform-schemas.ts | 2 +- .../src/transform/transform-telemetry-info.ts | 2 +- .../typespec-ts/src/transform/transform.ts | 17 +++++-- .../src/utils/cross-language-def.ts | 2 +- packages/typespec-ts/src/utils/emit-util.ts | 2 +- packages/typespec-ts/src/utils/interfaces.ts | 2 +- packages/typespec-ts/src/utils/model-utils.ts | 10 +++- .../src/utils/operation-helpers.ts | 2 +- .../typespec-ts/src/utils/operation-util.ts | 11 +++- .../typespec-ts/src/utils/parameter-utils.ts | 2 +- .../typespec-ts/src/utils/schema-helpers.ts | 2 +- .../test-next/unit/metadata/mock-helper.ts | 5 +- .../unit/metadata/package-json.test.ts | 5 +- .../test-next/unit/utils/imports-util.test.ts | 5 +- packages/typespec-ts/test/util/emit-util.ts | 8 +-- 47 files changed, 135 insertions(+), 93 deletions(-) diff --git a/packages/typespec-ts/CONTRIBUTING.md b/packages/typespec-ts/CONTRIBUTING.md index 922881f2f5..560dc74938 100644 --- a/packages/typespec-ts/CONTRIBUTING.md +++ b/packages/typespec-ts/CONTRIBUTING.md @@ -36,10 +36,10 @@ the required tooling (Node.js and `pnpm`). The command scripts under `test/comma The package is tested through three vitest projects (configured in `vitest.config.ts`): -| Project | Location | Covers | Command | -| --- | --- | --- | --- | -| `test-next` | `test-next/**` | Modern unit tests | `pnpm test-next` | -| `unit-modular` | `test/modular-unit/**` | Modular unit tests | `pnpm unit-test` | +| Project | Location | Covers | Command | +| --------------------------- | ----------------------------------- | -------------------------------- | ---------------------------------------- | +| `test-next` | `test-next/**` | Modern unit tests | `pnpm test-next` | +| `unit-modular` | `test/modular-unit/**` | Modular unit tests | `pnpm unit-test` | | `integration-azure-modular` | `test/azure-modular-integration/**` | Modular spector end-to-end tests | `pnpm integration-test-ci:azure-modular` | `pnpm lint` runs ESLint with `--max-warnings=0`. @@ -49,9 +49,9 @@ test server; `pnpm integration-test-ci:azure-modular` starts the server, generat assertions for you. To (re)generate the tracked baselines without running the tests: ```bash -pnpm copy:typespec # assemble ./temp/specs from the http-specs packages -pnpm generate-tsp-only # regenerate all Azure modular baselines (client + declarations) -pnpm check:tree # fails if regeneration left the git tree dirty +pnpm copy:typespec # assemble ./temp/specs from the http-specs packages +pnpm generate-tsp-only # regenerate all Azure modular baselines (client + declarations) +pnpm check:tree # fails if regeneration left the git tree dirty ``` > Only `src/index.d.ts` is tracked per generated package, so `check:tree` is what guards the @@ -115,4 +115,4 @@ pnpm check:tree # fails if regeneration left the git tree dirty The repo ships a **Debug Current Test File** VS Code launch profile (`.vscode/launch.json`) that runs the currently open file through vitest with the debugger attached. Open any `*.test.ts` file (unit or integration), select that profile, and press play — breakpoints work in both the -test and the emitter `src/`. \ No newline at end of file +test and the emitter `src/`. diff --git a/packages/typespec-ts/src/index.ts b/packages/typespec-ts/src/index.ts index 5d0628a573..68a1aa716e 100644 --- a/packages/typespec-ts/src/index.ts +++ b/packages/typespec-ts/src/index.ts @@ -45,7 +45,35 @@ import { Project } from "ts-morph"; import { provideBinder } from "./framework/hooks/binder.js"; import { provideSdkTypes } from "./framework/hooks/sdk-types.js"; import { loadStaticHelpers } from "./framework/load-static-helpers.js"; +import { ClientModel, ClientOptions } from "./interfaces.js"; import { EmitterOptions } from "./lib.js"; +import { buildApiExtractorConfig } from "./metadata/build-api-extractor-config.js"; +import { buildChangelogFile } from "./metadata/build-changelog-file.js"; +import { buildEsLintConfig } from "./metadata/build-es-lint-config.js"; +import { buildLicenseFile } from "./metadata/build-license-file.js"; +import { buildPackageFile, updatePackageFile } from "./metadata/build-package-file.js"; +import { + buildReadmeFile, + hasClientNameChanged, + updateReadmeFile, +} from "./metadata/build-readme-file.js"; +import { buildSampleEnvFile } from "./metadata/build-sample-env-file.js"; +import { buildTestBrowserTsConfig, buildTestNodeTsConfig } from "./metadata/build-test-config.js"; +import { + buildTsConfig, + buildTsLintConfig, + buildTsSampleConfig, + buildTsSnippetsConfig, + buildTsSrcBrowserConfig, + buildTsSrcCjsConfig, + buildTsSrcEsmConfig, + buildTsSrcReactNativeConfig, +} from "./metadata/build-ts-config.js"; +import { buildVitestConfig } from "./metadata/build-vitest-config.js"; +import { buildWarpConfig } from "./metadata/build-warp-config.js"; +import { buildRecordedClientFile } from "./metadata/test/build-recorded-client.js"; +import { buildSampleTest } from "./metadata/test/build-sample-test.js"; +import { buildSnippets } from "./metadata/test/build-snippets.js"; import { buildClassicalClient } from "./modular/build-classical-client.js"; import { buildClassicOperationFiles } from "./modular/build-classical-operation-groups.js"; import { buildClientContext, getClientContextPath } from "./modular/build-client-context.js"; @@ -62,29 +90,10 @@ import { emitTests } from "./modular/emit-tests.js"; import { getClassicalClientName } from "./modular/helpers/naming-helpers.js"; import { ModularEmitterOptions } from "./modular/interfaces.js"; import { packageUsesXmlSerialization } from "./modular/serialization/build-xml-serializer-function.js"; -import { transformClientModel } from "./transform/transform.js"; import { transformClientOptions } from "./transform/transform-client-options.js"; -import { - getClientHierarchyMap, - getClientModuleInfo, - getClients, -} from "./utils/client-utils.js"; +import { transformClientModel } from "./transform/transform.js"; +import { getClientHierarchyMap, getClientModuleInfo, getClients } from "./utils/client-utils.js"; import { generateCrossLanguageDefinitionFile } from "./utils/cross-language-def.js"; -import { ClientModel, ClientOptions } from "./interfaces.js"; -import { buildApiExtractorConfig } from "./metadata/build-api-extractor-config.js"; -import { buildChangelogFile } from "./metadata/build-changelog-file.js"; -import { buildEsLintConfig } from "./metadata/build-es-lint-config.js"; -import { buildLicenseFile } from "./metadata/build-license-file.js"; -import { buildPackageFile, updatePackageFile } from "./metadata/build-package-file.js"; -import { buildReadmeFile, hasClientNameChanged, updateReadmeFile } from "./metadata/build-readme-file.js"; -import { buildRecordedClientFile } from "./metadata/test/build-recorded-client.js"; -import { buildSampleEnvFile } from "./metadata/build-sample-env-file.js"; -import { buildSampleTest } from "./metadata/test/build-sample-test.js"; -import { buildSnippets } from "./metadata/test/build-snippets.js"; -import { buildTestBrowserTsConfig, buildTestNodeTsConfig } from "./metadata/build-test-config.js"; -import { buildTsConfig, buildTsLintConfig, buildTsSampleConfig, buildTsSnippetsConfig, buildTsSrcBrowserConfig, buildTsSrcCjsConfig, buildTsSrcEsmConfig, buildTsSrcReactNativeConfig } from "./metadata/build-ts-config.js"; -import { buildVitestConfig } from "./metadata/build-vitest-config.js"; -import { buildWarpConfig } from "./metadata/build-warp-config.js"; export * from "./lib.js"; diff --git a/packages/typespec-ts/src/metadata/build-package-file.ts b/packages/typespec-ts/src/metadata/build-package-file.ts index c3b2b33fe5..3c66c015dd 100644 --- a/packages/typespec-ts/src/metadata/build-package-file.ts +++ b/packages/typespec-ts/src/metadata/build-package-file.ts @@ -2,8 +2,8 @@ // Licensed under the MIT License. import { Project, SourceFile } from "ts-morph"; -import { hasPollingOperations } from "../utils/operation-helpers.js"; import { ClientModel } from "../interfaces.js"; +import { hasPollingOperations } from "../utils/operation-helpers.js"; import { buildAzureMonorepoPackage } from "./package-json/build-azure-monorepo-package.js"; import { PackageCommonInfoConfig, resolveWarpExports } from "./package-json/package-common.js"; import { getPackageName } from "./utils.js"; diff --git a/packages/typespec-ts/src/metadata/build-readme-file.ts b/packages/typespec-ts/src/metadata/build-readme-file.ts index d3159150a3..c819fdb119 100644 --- a/packages/typespec-ts/src/metadata/build-readme-file.ts +++ b/packages/typespec-ts/src/metadata/build-readme-file.ts @@ -4,9 +4,9 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; +import { ClientModel } from "../interfaces.js"; import { getClientName } from "../utils/name-constructors.js"; import { NameType, normalizeName } from "../utils/name-utils.js"; -import { ClientModel } from "../interfaces.js"; const azureReadmeModularTemplate = `# {{ clientDescriptiveName }} library for JavaScript diff --git a/packages/typespec-ts/src/metadata/test/build-snippets.ts b/packages/typespec-ts/src/metadata/test/build-snippets.ts index fe02aa644d..7d1da33b6c 100644 --- a/packages/typespec-ts/src/metadata/test/build-snippets.ts +++ b/packages/typespec-ts/src/metadata/test/build-snippets.ts @@ -1,8 +1,8 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: to fix the handlebars issue import hbs from "handlebars"; -import { getClientName } from "../../utils/name-constructors.js"; import { ClientModel } from "../../interfaces.js"; +import { getClientName } from "../../utils/name-constructors.js"; import { snippetsContent } from "./template.js"; export function buildSnippets(model: ClientModel, clientName?: string) { diff --git a/packages/typespec-ts/src/modular/build-classical-client.ts b/packages/typespec-ts/src/modular/build-classical-client.ts index 10d5864e99..d1836e82c7 100644 --- a/packages/typespec-ts/src/modular/build-classical-client.ts +++ b/packages/typespec-ts/src/modular/build-classical-client.ts @@ -21,13 +21,13 @@ import { resolveReference } from "../framework/reference.js"; import { refkey } from "../framework/refkey.js"; import { getClientModuleInfo, isMultiEndpointClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { getMethodHierarchiesMap, isTenantLevelOperation } from "../utils/operation-util.js"; import { AzurePollingDependencies } from "./external-dependencies.js"; import { getPagingLROMethodName } from "./helpers/classical-operation-helpers.js"; import { getDocsFromDescription } from "./helpers/docs-helpers.js"; import { getOperationFunction } from "./helpers/operation-helpers.js"; import { PagingHelpers, SimplePollerHelpers } from "./static-helpers-metadata.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; export function buildClassicalClient( dpgContext: SdkContext, diff --git a/packages/typespec-ts/src/modular/build-classical-operation-groups.ts b/packages/typespec-ts/src/modular/build-classical-operation-groups.ts index 96a7d82895..4bf2525247 100644 --- a/packages/typespec-ts/src/modular/build-classical-operation-groups.ts +++ b/packages/typespec-ts/src/modular/build-classical-operation-groups.ts @@ -3,11 +3,11 @@ import { SourceFile } from "ts-morph"; import { useContext } from "../context-manager.js"; import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType } from "../utils/name-utils.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { getClassicalOperation } from "./helpers/classical-operation-helpers.js"; import { getClassicalLayerPrefix } from "./helpers/naming-helpers.js"; import { ModularEmitterOptions } from "./interfaces.js"; -import { NameType } from "../utils/name-utils.js"; export function buildClassicOperationFiles( dpgContext: SdkContext, diff --git a/packages/typespec-ts/src/modular/build-client-context.ts b/packages/typespec-ts/src/modular/build-client-context.ts index b001541fac..a6440a5271 100644 --- a/packages/typespec-ts/src/modular/build-client-context.ts +++ b/packages/typespec-ts/src/modular/build-client-context.ts @@ -25,12 +25,12 @@ import { refkey } from "../framework/refkey.js"; import { reportDiagnostic } from "../lib.js"; import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { buildEnumTypes, getApiVersionEnum } from "./emit-models.js"; import { getDocsFromDescription } from "./helpers/docs-helpers.js"; import { getClassicalClientName, getClientName } from "./helpers/naming-helpers.js"; import { CloudSettingHelpers } from "./static-helpers-metadata.js"; import { getTypeExpression } from "./type-expressions/get-type-expression.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; /** * This function gets the path of the file containing the modular client context diff --git a/packages/typespec-ts/src/modular/build-operations.ts b/packages/typespec-ts/src/modular/build-operations.ts index e0c7f546e2..b6a6910825 100644 --- a/packages/typespec-ts/src/modular/build-operations.ts +++ b/packages/typespec-ts/src/modular/build-operations.ts @@ -24,6 +24,7 @@ import { resolveReference } from "../framework/reference.js"; import { refkey } from "../framework/refkey.js"; import { getClientModuleInfo, isMultiEndpointClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { getMethodHierarchiesMap, hasDualFormatSupport, @@ -33,7 +34,6 @@ import { getDocsFromDescription } from "./helpers/docs-helpers.js"; import { getOperationName } from "./helpers/naming-helpers.js"; import { OperationPathAndDeserDetails } from "./interfaces.js"; import { getTypeExpression } from "./type-expressions/get-type-expression.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; /** * This function creates a file under /api for each operation group. diff --git a/packages/typespec-ts/src/modular/build-project-files.ts b/packages/typespec-ts/src/modular/build-project-files.ts index c8a1d3cb75..f111347f08 100644 --- a/packages/typespec-ts/src/modular/build-project-files.ts +++ b/packages/typespec-ts/src/modular/build-project-files.ts @@ -2,10 +2,10 @@ import { getRelativePathFromDirectory, joinPaths } from "@typespec/compiler"; import { useContext } from "../context-manager.js"; import { getClientHierarchyMap, getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType } from "../utils/name-utils.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { getClassicalLayerPrefix } from "./helpers/naming-helpers.js"; import { ModularEmitterOptions } from "./interfaces.js"; -import { NameType } from "../utils/name-utils.js"; /** * Computes the relative path prefix (e.g. `./src` or `./src/generated`) from diff --git a/packages/typespec-ts/src/modular/build-restore-poller.ts b/packages/typespec-ts/src/modular/build-restore-poller.ts index e9426573f9..4348de6b32 100644 --- a/packages/typespec-ts/src/modular/build-restore-poller.ts +++ b/packages/typespec-ts/src/modular/build-restore-poller.ts @@ -6,6 +6,7 @@ import { useDependencies } from "../framework/hooks/use-dependencies.js"; import { resolveReference } from "../framework/reference.js"; import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { buildLroDeserDetailMap } from "./build-operations.js"; import { AzurePollingDependencies } from "./external-dependencies.js"; @@ -13,7 +14,6 @@ import { getClassicalClientName } from "./helpers/naming-helpers.js"; import { isLroOnlyOperation } from "./helpers/operation-helpers.js"; import { ModularEmitterOptions } from "./interfaces.js"; import { PollingHelpers } from "./static-helpers-metadata.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; export function buildRestorePoller( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/build-root-index.ts b/packages/typespec-ts/src/modular/build-root-index.ts index 5ad982177c..9281ae634a 100644 --- a/packages/typespec-ts/src/modular/build-root-index.ts +++ b/packages/typespec-ts/src/modular/build-root-index.ts @@ -6,6 +6,7 @@ import { resolveReference } from "../framework/reference.js"; import { reportDiagnostic } from "../lib.js"; import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { partitionAndEmitExports } from "./build-subpath-index.js"; import { getClassicalClientName } from "./helpers/naming-helpers.js"; @@ -17,7 +18,6 @@ import { PagingHelpers, PlatformTypeHelpers, } from "./static-helpers-metadata.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; export function buildRootIndex( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/emit-models-options.ts b/packages/typespec-ts/src/modular/emit-models-options.ts index d77a473328..8afa86e93a 100644 --- a/packages/typespec-ts/src/modular/emit-models-options.ts +++ b/packages/typespec-ts/src/modular/emit-models-options.ts @@ -6,9 +6,9 @@ import { SdkClientType, SdkServiceOperation } from "@azure-tools/typespec-client import { useContext } from "../context-manager.js"; import { getClientModuleInfo } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { buildOperationOptions } from "./build-operations.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; // ====== UTILITIES ====== diff --git a/packages/typespec-ts/src/modular/emit-models.ts b/packages/typespec-ts/src/modular/emit-models.ts index 91d525f2d5..aa7e5a6938 100644 --- a/packages/typespec-ts/src/modular/emit-models.ts +++ b/packages/typespec-ts/src/modular/emit-models.ts @@ -50,6 +50,7 @@ import { reportDiagnostic } from "../lib.js"; import { getClientHierarchyMap } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { isAzureCoreErrorType } from "../utils/model-utils.js"; +import { fixLeadingNumber, NameType, normalizeName } from "../utils/name-utils.js"; import { getMethodHierarchiesMap } from "../utils/operation-util.js"; import { getHeaderClientOptions } from "./helpers/client-option-helpers.js"; import { @@ -84,7 +85,6 @@ import { getTypeExpression, normalizeModelPropertyName, } from "./type-expressions/get-type-expression.js"; -import { fixLeadingNumber, NameType, normalizeName } from "../utils/name-utils.js"; type InterfaceStructure = OptionalKind & { extends?: string[]; diff --git a/packages/typespec-ts/src/modular/emit-samples.ts b/packages/typespec-ts/src/modular/emit-samples.ts index c6d02cd45a..2daeb54dfd 100644 --- a/packages/typespec-ts/src/modular/emit-samples.ts +++ b/packages/typespec-ts/src/modular/emit-samples.ts @@ -17,6 +17,7 @@ import { AzureIdentityDependencies } from "../modular/external-dependencies.js"; import { getSubscriptionId } from "../transform/transform-client-options.js"; import { hasKeyCredential, hasTokenCredential } from "../utils/credential-utils.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { getMethodHierarchiesMap, isTenantLevelOperation, @@ -32,7 +33,6 @@ import { getClassicalClientName } from "./helpers/naming-helpers.js"; import { getOperationFunction } from "./helpers/operation-helpers.js"; import { buildPropertyNameMapper, isSpreadBodyParameter } from "./helpers/type-helpers.js"; import { ModelOverrideOptions } from "./serialization/serialize-utils.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; /** * Interfaces for samples generations diff --git a/packages/typespec-ts/src/modular/emit-tests.ts b/packages/typespec-ts/src/modular/emit-tests.ts index 91badb8acb..b76ef6c1ac 100644 --- a/packages/typespec-ts/src/modular/emit-tests.ts +++ b/packages/typespec-ts/src/modular/emit-tests.ts @@ -2,6 +2,7 @@ import { type CompilerHost, joinPaths } from "@typespec/compiler"; import { SourceFile } from "ts-morph"; import { resolveReference } from "../framework/reference.js"; import { SdkContext } from "../utils/interfaces.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { ServiceOperation } from "../utils/operation-util.js"; import { AzureTestDependencies } from "./external-dependencies.js"; import { @@ -16,7 +17,6 @@ import { } from "./helpers/example-value-helpers.js"; import { getClassicalClientName } from "./helpers/naming-helpers.js"; import { CreateRecorderHelpers } from "./static-helpers-metadata.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; /** * Clean up the test/generated folder before generating new tests diff --git a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts index 9f153646b9..37ebc45456 100644 --- a/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/classical-operation-helpers.ts @@ -12,12 +12,12 @@ import { resolveReference } from "../../framework/reference.js"; import { refkey } from "../../framework/refkey.js"; import { getClientModuleInfo } from "../../utils/client-utils.js"; import { SdkContext } from "../../utils/interfaces.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { ServiceOperation } from "../../utils/operation-util.js"; import { AzurePollingDependencies } from "../external-dependencies.js"; import { PagingHelpers, SimplePollerHelpers } from "../static-helpers-metadata.js"; import { getClassicalLayerPrefix } from "./naming-helpers.js"; import { getOperationFunction } from "./operation-helpers.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; interface OperationDeclarationInfo { // the operation function diff --git a/packages/typespec-ts/src/modular/helpers/client-helpers.ts b/packages/typespec-ts/src/modular/helpers/client-helpers.ts index 98ab1dfe9e..878b994a7f 100644 --- a/packages/typespec-ts/src/modular/helpers/client-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/client-helpers.ts @@ -11,11 +11,11 @@ import { ModularEmitterOptions } from "../interfaces.js"; import { resolveReference } from "../../framework/reference.js"; import { SdkContext } from "../../utils/interfaces.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { CloudSettingHelpers } from "../static-helpers-metadata.js"; import { getTypeExpression } from "../type-expressions/get-type-expression.js"; import { getClassicalClientName } from "./naming-helpers.js"; import { isCredentialType } from "./type-helpers.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; interface ClientParameterOptions { onClientOnly?: boolean; diff --git a/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts b/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts index 876d510e42..ef39425610 100644 --- a/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/example-value-helpers.ts @@ -15,13 +15,13 @@ import { resolveReference } from "../../framework/reference.js"; import { getSubscriptionId } from "../../transform/transform-client-options.js"; import { hasKeyCredential, hasTokenCredential } from "../../utils/credential-utils.js"; import { SdkContext } from "../../utils/interfaces.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { getMethodHierarchiesMap, ServiceOperation } from "../../utils/operation-util.js"; import { AzureIdentityDependencies, AzureTestDependencies } from "../external-dependencies.js"; import { getClientParametersDeclaration } from "./client-helpers.js"; import { getClassicalClientName } from "./naming-helpers.js"; import { getOperationFunction } from "./operation-helpers.js"; import { isSpreadBodyParameter } from "./type-helpers.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; /** * Common interfaces for both samples and tests diff --git a/packages/typespec-ts/src/modular/helpers/naming-helpers.ts b/packages/typespec-ts/src/modular/helpers/naming-helpers.ts index d8560675a8..5e0e2b341d 100644 --- a/packages/typespec-ts/src/modular/helpers/naming-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/naming-helpers.ts @@ -1,7 +1,7 @@ import { SdkClientType, SdkServiceOperation } from "@azure-tools/typespec-client-generator-core"; import { SdkContext } from "../../utils/interfaces.js"; -import { ServiceOperation } from "../../utils/operation-util.js"; import { NameType, normalizeName, ReservedModelNames } from "../../utils/name-utils.js"; +import { ServiceOperation } from "../../utils/operation-util.js"; export function getClientName(client: SdkClientType): string { return client.name.replace(/Client$/, ""); diff --git a/packages/typespec-ts/src/modular/helpers/operation-helpers.ts b/packages/typespec-ts/src/modular/helpers/operation-helpers.ts index b6a1af401c..12faef4f40 100644 --- a/packages/typespec-ts/src/modular/helpers/operation-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/operation-helpers.ts @@ -35,6 +35,7 @@ import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { getCollectionFormatFromArrayEncoding, getCollectionFormatHelper, @@ -91,7 +92,6 @@ import { getOperationName, } from "./naming-helpers.js"; import { getNullableValidType, isSpreadBodyParameter, isTypeNullable } from "./type-helpers.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; /** * Checks whether a header should be skipped during serialization/deserialization. diff --git a/packages/typespec-ts/src/modular/helpers/type-helpers.ts b/packages/typespec-ts/src/modular/helpers/type-helpers.ts index 3bc0ddf52d..82eabb0b0a 100644 --- a/packages/typespec-ts/src/modular/helpers/type-helpers.ts +++ b/packages/typespec-ts/src/modular/helpers/type-helpers.ts @@ -7,12 +7,12 @@ import { SdkType, } from "@azure-tools/typespec-client-generator-core"; import { SdkContext } from "../../utils/interfaces.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { getPropertyWithOverrides, ModelOverrideOptions, } from "../serialization/serialize-utils.js"; import { getAllAncestors, getAllProperties } from "./operation-helpers.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; export function getDirectSubtypes(type: SdkModelType) { if (!type.discriminatedSubtypes) { diff --git a/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts index 0a904957ed..a88cf09efc 100644 --- a/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-deserializer-function.ts @@ -15,6 +15,7 @@ import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { getAdditionalPropertiesName, normalizeModelName } from "../emit-models.js"; import { getAllAncestors, @@ -30,7 +31,6 @@ import { isSupportedSerializeType, ModelSerializeOptions, } from "./serialize-utils.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; export function buildPropertyDeserializer( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts index eaf7235042..f5581e4bdb 100644 --- a/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-serializer-function.ts @@ -16,6 +16,7 @@ import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { getAdditionalPropertiesName, normalizeModelName } from "../emit-models.js"; import { getAllAncestors, @@ -32,7 +33,6 @@ import { isSupportedSerializeType, ModelSerializeOptions, } from "./serialize-utils.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; export function buildPropertySerializer( context: SdkContext, diff --git a/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts b/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts index 2664f85c18..98da7770e1 100644 --- a/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts +++ b/packages/typespec-ts/src/modular/serialization/build-xml-serializer-function.ts @@ -18,13 +18,13 @@ import { refkey } from "../../framework/refkey.js"; import { reportDiagnostic } from "../../lib.js"; import { SdkContext } from "../../utils/interfaces.js"; import { isAzureCoreErrorType } from "../../utils/model-utils.js"; +import { NameType } from "../../utils/name-utils.js"; import { getAdditionalPropertiesName, normalizeModelName } from "../emit-models.js"; import { getAllAncestors, getAllProperties } from "../helpers/operation-helpers.js"; import { getAdditionalPropertiesType } from "../helpers/type-helpers.js"; import { XmlHelpers } from "../static-helpers-metadata.js"; import { normalizeModelPropertyName } from "../type-expressions/get-type-expression.js"; import { isSupportedSerializeType, ModelSerializeOptions } from "./serialize-utils.js"; -import { NameType } from "../../utils/name-utils.js"; /** * Checks if a model type has XML serialization options defined diff --git a/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts b/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts index 3f0f956efe..82218d392d 100644 --- a/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts +++ b/packages/typespec-ts/src/modular/type-expressions/get-type-expression.ts @@ -5,12 +5,12 @@ import { SdkType, } from "@azure-tools/typespec-client-generator-core"; import { SdkContext } from "../../utils/interfaces.js"; +import { NameType, normalizeName } from "../../utils/name-utils.js"; import { getCredentialExpression } from "./get-credential-expression.js"; import { getEnumExpression } from "./get-enum-expression.js"; import { getModelExpression } from "./get-model-expression.js"; import { getNullableExpression } from "./get-nullable-expression.js"; import { getUnionExpression } from "./get-union-expression.js"; -import { NameType, normalizeName } from "../../utils/name-utils.js"; export interface EmitTypeOptions { emitInline?: boolean; diff --git a/packages/typespec-ts/src/transform/transform-api-version-info.ts b/packages/typespec-ts/src/transform/transform-api-version-info.ts index e8358fcdd2..bdb16d0e33 100644 --- a/packages/typespec-ts/src/transform/transform-api-version-info.ts +++ b/packages/typespec-ts/src/transform/transform-api-version-info.ts @@ -3,11 +3,11 @@ import { isApiVersion, SdkClient, } from "@azure-tools/typespec-client-generator-core"; +import { ApiVersionInfo, ApiVersionPosition, SchemaContext, UrlInfo } from "../interfaces.js"; +import { extractDefinedPosition, extractPathApiVersion } from "../utils/api-version-util.js"; import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultApiVersionString, getSchemaForType, trimUsage } from "../utils/model-utils.js"; -import { ApiVersionInfo, ApiVersionPosition, SchemaContext, UrlInfo } from "../interfaces.js"; -import { extractDefinedPosition, extractPathApiVersion } from "../utils/api-version-util.js"; export function transformApiVersionInfo( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-client-options.ts b/packages/typespec-ts/src/transform/transform-client-options.ts index ad3b9de948..95803dbe85 100644 --- a/packages/typespec-ts/src/transform/transform-client-options.ts +++ b/packages/typespec-ts/src/transform/transform-client-options.ts @@ -1,16 +1,16 @@ import { getHttpOperationWithCache } from "@azure-tools/typespec-client-generator-core"; import { getDoc, NoTarget, Program } from "@typespec/compiler"; import { getAuthentication } from "@typespec/http"; +import { ClientOptions, PackageDetails, ServiceInfo } from "../interfaces.js"; import { EmitterOptions, reportDiagnostic } from "../lib.js"; import { getClientParameters } from "../modular/helpers/client-helpers.js"; import { getClients, listOperationsUnderClient } from "../utils/client-utils.js"; import { getSupportedHttpAuth } from "../utils/credential-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultService } from "../utils/model-utils.js"; +import { NameType, normalizeName, pascalCase } from "../utils/name-utils.js"; import { detectModelConflicts } from "../utils/namespace-utils.js"; import { getOperationName } from "../utils/operation-util.js"; -import { NameType, normalizeName, pascalCase } from "../utils/name-utils.js"; -import { PackageDetails, ClientOptions, ServiceInfo } from "../interfaces.js"; export function transformClientOptions( emitterOptions: EmitterOptions, diff --git a/packages/typespec-ts/src/transform/transform-helper-function-details.ts b/packages/typespec-ts/src/transform/transform-helper-function-details.ts index f1d5f95de1..3bdb2fb26c 100644 --- a/packages/typespec-ts/src/transform/transform-helper-function-details.ts +++ b/packages/typespec-ts/src/transform/transform-helper-function-details.ts @@ -1,4 +1,5 @@ import { getHttpOperationWithCache, SdkClient } from "@azure-tools/typespec-client-generator-core"; +import { HelperFunctionDetails } from "../interfaces.js"; import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { getCollectionFormat } from "../utils/model-utils.js"; @@ -8,7 +9,6 @@ import { hasPagingOperations, hasPollingOperations, } from "../utils/operation-util.js"; -import { HelperFunctionDetails } from "../interfaces.js"; export function transformHelperFunctionDetails( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-parameters.ts b/packages/typespec-ts/src/transform/transform-parameters.ts index 724966df51..e4c3c9babd 100644 --- a/packages/typespec-ts/src/transform/transform-parameters.ts +++ b/packages/typespec-ts/src/transform/transform-parameters.ts @@ -8,6 +8,16 @@ import { } from "@azure-tools/typespec-client-generator-core"; import { NoTarget, Type, isVoidType } from "@typespec/compiler"; import { HttpOperation, HttpOperationParameter, HttpOperationParameters } from "@typespec/http"; +import { + ApiVersionInfo, + Imports, + ObjectSchema, + OperationParameter, + ParameterBodyMetadata, + ParameterMetadata, + Schema, + SchemaContext, +} from "../interfaces.js"; import { reportDiagnostic } from "../lib.js"; import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; @@ -33,7 +43,6 @@ import { getSpecialSerializeInfo, } from "../utils/operation-util.js"; import { getParameterSerializationInfo } from "../utils/parameter-utils.js"; -import { ApiVersionInfo, Imports, ObjectSchema, OperationParameter, ParameterBodyMetadata, ParameterMetadata, Schema, SchemaContext } from "../interfaces.js"; interface ParameterTransformationOptions { apiVersionInfo?: ApiVersionInfo; diff --git a/packages/typespec-ts/src/transform/transform-paths.ts b/packages/typespec-ts/src/transform/transform-paths.ts index 846f74fe66..d32bbc87b8 100644 --- a/packages/typespec-ts/src/transform/transform-paths.ts +++ b/packages/typespec-ts/src/transform/transform-paths.ts @@ -20,11 +20,11 @@ import { } from "../utils/operation-util.js"; import { getDoc } from "@typespec/compiler"; +import { Imports, OperationMethod, PathMetadata, Paths, SchemaContext } from "../interfaces.js"; import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; -import { getParameterSerializationInfo } from "../utils/parameter-utils.js"; -import { Imports, OperationMethod, PathMetadata, Paths, SchemaContext } from "../interfaces.js"; import { getParameterTypeName, getResponseTypeName } from "../utils/name-constructors.js"; +import { getParameterSerializationInfo } from "../utils/parameter-utils.js"; export function transformPaths( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-responses.ts b/packages/typespec-ts/src/transform/transform-responses.ts index d7aa70c877..003d3b88dc 100644 --- a/packages/typespec-ts/src/transform/transform-responses.ts +++ b/packages/typespec-ts/src/transform/transform-responses.ts @@ -4,6 +4,14 @@ import { getHttpOperationWithCache, SdkClient } from "@azure-tools/typespec-client-generator-core"; import { getDoc, isVoidType } from "@typespec/compiler"; import { HttpOperation, HttpOperationResponse } from "@typespec/http"; +import { + Imports, + OperationResponse, + ResponseHeaderSchema, + ResponseMetadata, + Schema, + SchemaContext, +} from "../interfaces.js"; import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; import { @@ -12,6 +20,7 @@ import { getSchemaForType, getTypeName, } from "../utils/model-utils.js"; +import { getLroLogicalResponseName } from "../utils/name-constructors.js"; import { getOperationGroupName, getOperationLroOverload, @@ -20,8 +29,6 @@ import { isBinaryPayload, sortedOperationResponses, } from "../utils/operation-util.js"; -import { getLroLogicalResponseName } from "../utils/name-constructors.js"; -import { Imports, OperationResponse, ResponseHeaderSchema, ResponseMetadata, Schema, SchemaContext } from "../interfaces.js"; export function transformToResponseTypes( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform-schemas.ts b/packages/typespec-ts/src/transform/transform-schemas.ts index d9d639d79e..cad626566c 100644 --- a/packages/typespec-ts/src/transform/transform-schemas.ts +++ b/packages/typespec-ts/src/transform/transform-schemas.ts @@ -15,9 +15,9 @@ import { } from "../utils/model-utils.js"; import { useContext } from "../context-manager.js"; +import { SchemaContext } from "../interfaces.js"; import { listOperationsUnderClient } from "../utils/client-utils.js"; import { SdkContext } from "../utils/interfaces.js"; -import { SchemaContext } from "../interfaces.js"; export function transformSchemas(client: SdkClient, dpgContext: SdkContext) { const program = dpgContext.program; diff --git a/packages/typespec-ts/src/transform/transform-telemetry-info.ts b/packages/typespec-ts/src/transform/transform-telemetry-info.ts index ffa4872a96..dcb2d1ea96 100644 --- a/packages/typespec-ts/src/transform/transform-telemetry-info.ts +++ b/packages/typespec-ts/src/transform/transform-telemetry-info.ts @@ -3,9 +3,9 @@ import { SdkClient, SdkContext, } from "@azure-tools/typespec-client-generator-core"; +import { TelemetryInfo } from "../interfaces.js"; import { listOperationsUnderClient } from "../utils/client-utils.js"; import { getCustomRequestHeaderNameForOperation } from "../utils/operation-util.js"; -import { TelemetryInfo } from "../interfaces.js"; export function transformTelemetryInfo( client: SdkClient, diff --git a/packages/typespec-ts/src/transform/transform.ts b/packages/typespec-ts/src/transform/transform.ts index afe36b16ce..f09783400f 100644 --- a/packages/typespec-ts/src/transform/transform.ts +++ b/packages/typespec-ts/src/transform/transform.ts @@ -4,6 +4,19 @@ import { SdkClient } from "@azure-tools/typespec-client-generator-core"; import { getDoc, joinPaths } from "@typespec/compiler"; import { getServers } from "@typespec/http"; +import { + ClientModel, + ClientOptions, + Imports, + OperationParameter, + OperationResponse, + PathParameter, + Paths, + Schema, + SchemaContext, + UrlInfo, +} from "../interfaces.js"; +import { buildRuntimeImports, initInternalImports } from "../utils/imports-util.js"; import { SdkContext } from "../utils/interfaces.js"; import { getDefaultService, @@ -13,6 +26,7 @@ import { getTypeName, predictDefaultValue, } from "../utils/model-utils.js"; +import { NameType, normalizeName } from "../utils/name-utils.js"; import { getClientLroOverload } from "../utils/operation-util.js"; import { transformApiVersionInfo } from "./transform-api-version-info.js"; import { transformHelperFunctionDetails } from "./transform-helper-function-details.js"; @@ -21,9 +35,6 @@ import { transformPaths } from "./transform-paths.js"; import { transformToResponseTypes } from "./transform-responses.js"; import { transformSchemas } from "./transform-schemas.js"; import { transformTelemetryInfo } from "./transform-telemetry-info.js"; -import { buildRuntimeImports, initInternalImports } from "../utils/imports-util.js"; -import { Imports, OperationParameter, OperationResponse, PathParameter, Paths, ClientModel, ClientOptions, Schema, SchemaContext, UrlInfo } from "../interfaces.js"; -import { NameType, normalizeName } from "../utils/name-utils.js"; export async function transformClientModel( client: SdkClient, diff --git a/packages/typespec-ts/src/utils/cross-language-def.ts b/packages/typespec-ts/src/utils/cross-language-def.ts index b15178f990..4cdcc22076 100644 --- a/packages/typespec-ts/src/utils/cross-language-def.ts +++ b/packages/typespec-ts/src/utils/cross-language-def.ts @@ -4,8 +4,8 @@ import { UsageFlags } from "@azure-tools/typespec-client-generator-core"; import { transformModularEmitterOptions } from "../modular/build-modular-options.js"; import { SdkContext } from "./interfaces.js"; -import { getMethodHierarchiesMap } from "./operation-util.js"; import { NameType, normalizeName } from "./name-utils.js"; +import { getMethodHierarchiesMap } from "./operation-util.js"; export function generateCrossLanguageDefinitionFile(dpgContext: SdkContext): { CrossLanguagePackageId: string; diff --git a/packages/typespec-ts/src/utils/emit-util.ts b/packages/typespec-ts/src/utils/emit-util.ts index 50e784b609..354a60c6ca 100644 --- a/packages/typespec-ts/src/utils/emit-util.ts +++ b/packages/typespec-ts/src/utils/emit-util.ts @@ -3,8 +3,8 @@ import { format } from "prettier"; import prettierPluginBabel from "prettier/plugins/babel"; import prettierPluginEstree from "prettier/plugins/estree"; import prettierPluginTypescript from "prettier/plugins/typescript"; +import { ClientModel, ContentBuilder, File } from "../interfaces.js"; import { prettierJSONOptions, prettierTypeScriptOptions, reportDiagnostic } from "../lib.js"; -import { ContentBuilder, File, ClientModel } from "../interfaces.js"; export async function emitContentByBuilder( program: Program, diff --git a/packages/typespec-ts/src/utils/interfaces.ts b/packages/typespec-ts/src/utils/interfaces.ts index 45a3b9bc05..78591fc815 100644 --- a/packages/typespec-ts/src/utils/interfaces.ts +++ b/packages/typespec-ts/src/utils/interfaces.ts @@ -1,7 +1,7 @@ import { SdkContext as TCGCSdkContext } from "@azure-tools/typespec-client-generator-core"; import { ModelProperty, Namespace } from "@typespec/compiler"; -import { KnownMediaType } from "./media-types.js"; import { ClientOptions, SchemaContext } from "../interfaces.js"; +import { KnownMediaType } from "./media-types.js"; export interface SdkContext extends TCGCSdkContext { emitterOptions?: ClientOptions; diff --git a/packages/typespec-ts/src/utils/model-utils.ts b/packages/typespec-ts/src/utils/model-utils.ts index 6e4056aee8..a17e82757a 100644 --- a/packages/typespec-ts/src/utils/model-utils.ts +++ b/packages/typespec-ts/src/utils/model-utils.ts @@ -67,10 +67,16 @@ import { import { GetSchemaOptions, SdkContext } from "./interfaces.js"; import { KnownMediaType, hasMediaType, isMediaTypeMultipartFormData } from "./media-types.js"; +import { + ArraySchema, + DictionarySchema, + ObjectSchema, + Schema, + SchemaContext, +} from "../interfaces.js"; import { reportDiagnostic } from "../lib.js"; -import { getModelNamespaceName } from "./namespace-utils.js"; -import { ArraySchema, DictionarySchema, ObjectSchema, Schema, SchemaContext } from "../interfaces.js"; import { NameType, normalizeName } from "./name-utils.js"; +import { getModelNamespaceName } from "./namespace-utils.js"; import { isArraySchema } from "./schema-helpers.js"; export const BINARY_TYPE_UNION = diff --git a/packages/typespec-ts/src/utils/operation-helpers.ts b/packages/typespec-ts/src/utils/operation-helpers.ts index 89bcfe74c5..9a1cf8aaa5 100644 --- a/packages/typespec-ts/src/utils/operation-helpers.ts +++ b/packages/typespec-ts/src/utils/operation-helpers.ts @@ -3,11 +3,11 @@ import { MethodSignatureStructure, OptionalKind, ParameterDeclarationStructure } from "ts-morph"; import { + ClientModel, Methods, ObjectSchema, ParameterMetadata, PathParameter, - ClientModel, Schema, SchemaContext, } from "../interfaces.js"; diff --git a/packages/typespec-ts/src/utils/operation-util.ts b/packages/typespec-ts/src/utils/operation-util.ts index ceb291625b..837afba2b6 100644 --- a/packages/typespec-ts/src/utils/operation-util.ts +++ b/packages/typespec-ts/src/utils/operation-util.ts @@ -26,6 +26,14 @@ import { HttpStatusCodesEntry, } from "@typespec/http"; import { resolveReference } from "../framework/reference.js"; +import { + OPERATION_LRO_HIGH_PRIORITY, + OPERATION_LRO_LOW_PRIORITY, + OperationLroDetail, + Paths, + ResponseMetadata, + ResponseTypes, +} from "../interfaces.js"; import { reportDiagnostic } from "../lib.js"; import { SerializationHelpers } from "../modular/static-helpers-metadata.js"; import { listOperationsUnderClient } from "./client-utils.js"; @@ -37,10 +45,9 @@ import { knownMediaType, } from "./media-types.js"; import { isByteOrByteUnion } from "./model-utils.js"; -import { getOperationNamespaceInterfaceName } from "./namespace-utils.js"; import { getLroLogicalResponseName, getResponseTypeName } from "./name-constructors.js"; import { NameType, normalizeName } from "./name-utils.js"; -import { OPERATION_LRO_HIGH_PRIORITY, OPERATION_LRO_LOW_PRIORITY, OperationLroDetail, Paths, ResponseMetadata, ResponseTypes } from "../interfaces.js"; +import { getOperationNamespaceInterfaceName } from "./namespace-utils.js"; // Sorts the responses by status code export function sortedOperationResponses(responses: HttpOperationResponse[]) { diff --git a/packages/typespec-ts/src/utils/parameter-utils.ts b/packages/typespec-ts/src/utils/parameter-utils.ts index 902e6d4f02..667b96a2f6 100644 --- a/packages/typespec-ts/src/utils/parameter-utils.ts +++ b/packages/typespec-ts/src/utils/parameter-utils.ts @@ -1,10 +1,10 @@ import { getEncode, NoTarget, Program } from "@typespec/compiler"; import { HttpOperationParameter } from "@typespec/http"; +import { Schema, SchemaContext } from "../interfaces.js"; import { reportDiagnostic } from "../lib.js"; import { SdkContext } from "./interfaces.js"; import { getTypeName, isArrayType, isObjectOrDictType } from "./model-utils.js"; import { NameType, normalizeName } from "./name-utils.js"; -import { Schema, SchemaContext } from "../interfaces.js"; export interface ParameterSerializationInfo { typeName: string; diff --git a/packages/typespec-ts/src/utils/schema-helpers.ts b/packages/typespec-ts/src/utils/schema-helpers.ts index d9b387345f..83495a1191 100644 --- a/packages/typespec-ts/src/utils/schema-helpers.ts +++ b/packages/typespec-ts/src/utils/schema-helpers.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ArraySchema, ObjectSchema, ClientModel, Schema, SchemaContext } from "../interfaces.js"; +import { ArraySchema, ClientModel, ObjectSchema, Schema, SchemaContext } from "../interfaces.js"; export interface IsDictionaryOptions { filterEmpty?: boolean; diff --git a/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts b/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts index 830efc81d4..2b2a62bf89 100644 --- a/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts +++ b/packages/typespec-ts/test-next/unit/metadata/mock-helper.ts @@ -1,8 +1,5 @@ -import { - buildRuntimeImports, - initInternalImports, -} from "../../../src/utils/imports-util.js"; import { ClientModel } from "../../../src/interfaces.js"; +import { buildRuntimeImports, initInternalImports } from "../../../src/utils/imports-util.js"; export type TestModelConfig = { description?: string; diff --git a/packages/typespec-ts/test-next/unit/metadata/package-json.test.ts b/packages/typespec-ts/test-next/unit/metadata/package-json.test.ts index 50140464a7..c80db458b1 100644 --- a/packages/typespec-ts/test-next/unit/metadata/package-json.test.ts +++ b/packages/typespec-ts/test-next/unit/metadata/package-json.test.ts @@ -3,10 +3,7 @@ import { describe, expect, it } from "vitest"; -import { - buildPackageFile, - updatePackageFile, -} from "../../../src/metadata/build-package-file.js"; +import { buildPackageFile, updatePackageFile } from "../../../src/metadata/build-package-file.js"; import { TestModelConfig, createMockModel } from "./mock-helper.js"; describe("Package file generation", () => { diff --git a/packages/typespec-ts/test-next/unit/utils/imports-util.test.ts b/packages/typespec-ts/test-next/unit/utils/imports-util.test.ts index c90d87f53d..222e441cc4 100644 --- a/packages/typespec-ts/test-next/unit/utils/imports-util.test.ts +++ b/packages/typespec-ts/test-next/unit/utils/imports-util.test.ts @@ -1,9 +1,6 @@ import { describe, expect, it } from "vitest"; -import { - buildRuntimeImports, - getImportSpecifier, -} from "../../../src/utils/imports-util.js"; +import { buildRuntimeImports, getImportSpecifier } from "../../../src/utils/imports-util.js"; describe("#buildRuntimeImports", () => { it("should return the correct import set", () => { diff --git a/packages/typespec-ts/test/util/emit-util.ts b/packages/typespec-ts/test/util/emit-util.ts index 4fb5e3b055..9c04d1b7de 100644 --- a/packages/typespec-ts/test/util/emit-util.ts +++ b/packages/typespec-ts/test/util/emit-util.ts @@ -15,6 +15,7 @@ import { expectDiagnosticEmpty } from "@typespec/compiler/testing"; import { useContext } from "../../src/context-manager.js"; import { useBinder } from "../../src/framework/hooks/binder.js"; import { renameClientName } from "../../src/index.js"; +import { ClientOptions } from "../../src/interfaces.js"; import { buildClassicalClient } from "../../src/modular/build-classical-client.js"; import { buildClassicOperationFiles } from "../../src/modular/build-classical-operation-groups.js"; import { buildClientContext } from "../../src/modular/build-client-context.js"; @@ -25,7 +26,6 @@ import { buildSubpathIndexFile } from "../../src/modular/build-subpath-index.js" import { emitSamples } from "../../src/modular/emit-samples.js"; import { emitTests } from "../../src/modular/emit-tests.js"; import { getClientHierarchyMap } from "../../src/utils/client-utils.js"; -import { ClientOptions } from "../../src/interfaces.js"; export interface ModelConfigOptions extends ClientOptions { needOptions?: boolean; @@ -71,7 +71,8 @@ export async function emitModularModelsFromTypeSpec( dpgContext.emitterOptions!.includeHeadersInResponse = includeResponseHeaders; dpgContext.emitterOptions!.compatibilityMode = options["compatibility-mode"]; dpgContext.emitterOptions!.experimentalExtensibleEnums = options["experimental-extensible-enums"]; - dpgContext.emitterOptions!.ignoreNullableOnOptional = options["ignore-nullable-on-optional"] ?? true; + dpgContext.emitterOptions!.ignoreNullableOnOptional = + options["ignore-nullable-on-optional"] ?? true; if (options["wrap-non-model-return"] !== undefined) { dpgContext.emitterOptions!.wrapNonModelReturn = options["wrap-non-model-return"] === true; } @@ -325,7 +326,8 @@ export async function emitSamplesFromTypeSpec( }, ...configs, }); - dpgContext.emitterOptions!.ignoreNullableOnOptional = configs["ignore-nullable-on-optional"] ?? true; + dpgContext.emitterOptions!.ignoreNullableOnOptional = + configs["ignore-nullable-on-optional"] ?? true; const modularEmitterOptions = transformModularEmitterOptions(dpgContext, "", { casing: "camel", }); From 788355fc203be5b51cac5275b4b547057cedc9e4 Mon Sep 17 00:00:00 2001 From: Jeff Fisher Date: Fri, 26 Jun 2026 20:50:33 -0500 Subject: [PATCH 15/15] Regenerate emitter reference docs Run `pnpm regen-docs` so the website reference reflects the removed `compatibility-query-multi-format` emitter option and the dropped "experimental" framing in the emitter description. The Website CI job regenerates these docs during validation and fails on any drift. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../docs/emitters/clients/typespec-ts/reference/emitter.md | 6 ------ .../docs/emitters/clients/typespec-ts/reference/index.mdx | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/emitter.md b/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/emitter.md index 886c1e6f05..dc3b26e2f2 100644 --- a/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/emitter.md +++ b/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/emitter.md @@ -186,12 +186,6 @@ The emitter will use camel case to normalize the property name, to ignore this n The emitter has a normalization logic for enum member key, to ignore this normalization, you can set this option to true -### `compatibility-query-multi-format` - -**Type:** `boolean` - -Whether to generate the backward-compatible code for query parameter serialization for array types in RLC. Defaults to `false` - ### `typespec-title-map` **Type:** `object` diff --git a/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/index.mdx b/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/index.mdx index bcd96821c8..06b75e32bb 100644 --- a/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/index.mdx +++ b/website/src/content/docs/docs/emitters/clients/typespec-ts/reference/index.mdx @@ -7,7 +7,7 @@ toc_max_heading_level: 3 import { Tabs, TabItem } from '@astrojs/starlight/components'; -An experimental TypeSpec emitter for TypeScript +A TypeSpec emitter for TypeScript ## Install