diff --git a/.chronus/changes/separate_package_creation-2024-6-18-17-1-40.md b/.chronus/changes/separate_package_creation-2024-6-18-17-1-40.md new file mode 100644 index 0000000000..084a032315 --- /dev/null +++ b/.chronus/changes/separate_package_creation-2024-6-18-17-1-40.md @@ -0,0 +1,9 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-autorest-canonical" + - "@azure-tools/typespec-autorest" + - "@azure-tools/typespec-client-generator-core" +--- + +expose createTcgcContext, which is the minimal context object that handles scope \ No newline at end of file diff --git a/packages/typespec-autorest-canonical/src/emitter.ts b/packages/typespec-autorest-canonical/src/emitter.ts index b43668b838..28c04295b0 100644 --- a/packages/typespec-autorest-canonical/src/emitter.ts +++ b/packages/typespec-autorest-canonical/src/emitter.ts @@ -5,20 +5,20 @@ import { sortOpenAPIDocument, } from "@azure-tools/typespec-autorest"; import { isArmCommonType } from "@azure-tools/typespec-azure-resource-manager"; -import { SdkContext, createSdkContext } from "@azure-tools/typespec-client-generator-core"; +import { createTCGCContext, type TCGCContext } from "@azure-tools/typespec-client-generator-core"; import { EmitContext, - Namespace, - Program, - Service, - Type, emitFile, getDirectoryPath, getNamespaceFullName, interpolatePath, listServices, + Namespace, navigateType, + Program, resolvePath, + Service, + Type, } from "@typespec/compiler"; import { getRenamedFrom, @@ -50,8 +50,8 @@ interface ResolvedAutorestCanonicalEmitterOptions extends AutorestDocumentEmitte export async function $onEmit(context: EmitContext) { const resolvedOptions = { ...defaultOptions, ...context.options }; - const tcgcSdkContext = await createSdkContext( - context, + const tcgcSdkContext = createTCGCContext( + context.program, "@azure-tools/typespec-autorest-canonical" ); const armTypesDir = interpolatePath( @@ -77,7 +77,7 @@ export async function $onEmit(context: EmitContext, + tcgcSdkContext: TCGCContext, options: ResolvedAutorestCanonicalEmitterOptions ) { const services = listServices(program); diff --git a/packages/typespec-autorest/src/emit.ts b/packages/typespec-autorest/src/emit.ts index 4a2577f8c7..8ee77db68d 100644 --- a/packages/typespec-autorest/src/emit.ts +++ b/packages/typespec-autorest/src/emit.ts @@ -1,4 +1,4 @@ -import { createSdkContext } from "@azure-tools/typespec-client-generator-core"; +import { createTCGCContext } from "@azure-tools/typespec-client-generator-core"; import { EmitContext, Namespace, @@ -100,15 +100,7 @@ export async function getAllServicesAtAllVersions( program: Program, options: ResolvedAutorestEmitterOptions ): Promise { - const tcgcSdkContext = await createSdkContext( - { program, options: {} } as any, - "@azure-tools/typespec-autorest", - { - versioning: { - strategy: "ignore", - }, - } - ); + const tcgcSdkContext = createTCGCContext(program, "@azure-tools/typespec-autorest"); const services = listServices(program); if (services.length === 0) { diff --git a/packages/typespec-autorest/src/utils.ts b/packages/typespec-autorest/src/utils.ts index 44e41bb429..8e2fe8b61a 100644 --- a/packages/typespec-autorest/src/utils.ts +++ b/packages/typespec-autorest/src/utils.ts @@ -1,16 +1,19 @@ -import { SdkContext, getClientNameOverride } from "@azure-tools/typespec-client-generator-core"; import { - ModelProperty, - Operation, - Program, - Service, - Type, + getClientNameOverride, + type TCGCContext, +} from "@azure-tools/typespec-client-generator-core"; +import { getFriendlyName, getProjectedName, getVisibility, isGlobalNamespace, isService, isTemplateInstance, + ModelProperty, + Operation, + Program, + Service, + Type, } from "@typespec/compiler"; import { getOperationId } from "@typespec/openapi"; import { pascalCase } from "change-case"; @@ -19,7 +22,7 @@ export interface AutorestEmitterContext { readonly program: Program; readonly service: Service; readonly outputFile: string; - readonly tcgcSdkContext: SdkContext; + readonly tcgcSdkContext: TCGCContext; readonly version?: string; } diff --git a/packages/typespec-client-generator-core/src/decorators.ts b/packages/typespec-client-generator-core/src/decorators.ts index 4b6f5b2bb1..aca05237c0 100644 --- a/packages/typespec-client-generator-core/src/decorators.ts +++ b/packages/typespec-client-generator-core/src/decorators.ts @@ -41,11 +41,11 @@ import { SdkHttpOperation, SdkOperationGroup, SdkServiceOperation, + TCGCContext, UsageFlags, } from "./interfaces.js"; import { AllScopes, - TCGCContext, clientNameKey, getValidApiVersion, parseEmitterName, @@ -590,6 +590,20 @@ export function listOperationsInOperationGroup( return operations; } +export function createTCGCContext(program: Program, emitterName: string): TCGCContext { + const diagnostics = createDiagnosticCollector(); + return { + program, + emitterName: diagnostics.pipe(parseEmitterName(program, emitterName)), + diagnostics: diagnostics.diagnostics, + originalProgram: program, + __namespaceToApiVersionParameter: new Map(), + __tspTypeToApiVersions: new Map(), + __namespaceToApiVersionClientDefaultValue: new Map(), + previewStringRegex: /-preview$/, + }; +} + interface VersioningStrategy { readonly strategy?: "ignore"; readonly previewStringRegex?: RegExp; // regex to match preview versions @@ -614,27 +628,23 @@ export async function createSdkContext< const generateProtocolMethods = context.options["generate-protocol-methods"] ?? protocolOptions; const generateConvenienceMethods = context.options["generate-convenience-methods"] ?? convenienceOptions; + const tcgcContext = createTCGCContext( + context.program, + (emitterName ?? context.program.emitters[0]?.metadata?.name)! + ); const sdkContext: SdkContext = { - program: context.program, + ...tcgcContext, emitContext: context, sdkPackage: undefined!, - emitterName: diagnostics.pipe( - parseEmitterName(context.program, emitterName ?? context.program.emitters[0]?.metadata?.name) - ), // eslint-disable-line deprecation/deprecation generateProtocolMethods: generateProtocolMethods, generateConvenienceMethods: generateConvenienceMethods, filterOutCoreModels: context.options["filter-out-core-models"] ?? true, packageName: context.options["package-name"], flattenUnionAsEnum: context.options["flatten-union-as-enum"] ?? true, - diagnostics: diagnostics.diagnostics, apiVersion: options?.versioning?.strategy === "ignore" ? "all" : context.options["api-version"], - originalProgram: context.program, - __namespaceToApiVersionParameter: new Map(), - __tspTypeToApiVersions: new Map(), - __namespaceToApiVersionClientDefaultValue: new Map(), examplesDirectory: context.options["examples-directory"], decoratorsAllowList: [...defaultDecoratorsAllowList, ...(options?.additionalDecorators ?? [])], - previewStringRegex: options?.versioning?.previewStringRegex || /-preview$/, + previewStringRegex: options?.versioning?.previewStringRegex || tcgcContext.previewStringRegex, }; sdkContext.sdkPackage = getSdkPackage(sdkContext); for (const client of sdkContext.sdkPackage.clients) { diff --git a/packages/typespec-client-generator-core/src/http.ts b/packages/typespec-client-generator-core/src/http.ts index a9f0fbae77..07ea45cba5 100644 --- a/packages/typespec-client-generator-core/src/http.ts +++ b/packages/typespec-client-generator-core/src/http.ts @@ -36,9 +36,9 @@ import { SdkQueryParameter, SdkServiceResponseHeader, SdkType, + TCGCContext, } from "./interfaces.js"; import { - TCGCContext, getAvailableApiVersions, getDocHelper, getHttpOperationResponseHeaders, diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index cc7d59af21..9d626db726 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -6,10 +6,14 @@ import { EmitContext, Interface, IntrinsicScalarName, + Model, ModelProperty, Namespace, Operation, + Program, + ProjectedProgram, Type, + Union, } from "@typespec/compiler"; import { HttpAuth, @@ -19,7 +23,38 @@ import { HttpVerb, Visibility, } from "@typespec/http"; -import { TCGCContext } from "./internal-utils.js"; +import { TspLiteralType } from "./internal-utils.js"; + +export interface TCGCContext { + program: Program; + emitterName: string; + generateProtocolMethods?: boolean; + generateConvenienceMethods?: boolean; + filterOutCoreModels?: boolean; + packageName?: string; + flattenUnionAsEnum?: boolean; + arm?: boolean; + modelsMap?: Map; + operationModelsMap?: Map>; + generatedNames?: Map; + spreadModels?: Map; + httpOperationCache?: Map; + unionsMap?: Map; + __namespaceToApiVersionParameter: Map; + __tspTypeToApiVersions: Map; + __namespaceToApiVersionClientDefaultValue: Map; + knownScalars?: Record; + diagnostics: readonly Diagnostic[]; + __subscriptionIdParameter?: SdkParameter; + __rawClients?: SdkClient[]; + apiVersion?: string; + __service_projection?: Map; + __httpOperationExamples?: Map; + originalProgram: Program; + examplesDirectory?: string; + decoratorsAllowList?: string[]; + previewStringRegex: RegExp; +} export interface SdkContext< TOptions extends object = Record, diff --git a/packages/typespec-client-generator-core/src/internal-utils.ts b/packages/typespec-client-generator-core/src/internal-utils.ts index 4a7664993a..156c1fcc5a 100644 --- a/packages/typespec-client-generator-core/src/internal-utils.ts +++ b/packages/typespec-client-generator-core/src/internal-utils.ts @@ -10,14 +10,12 @@ import { isNeverType, isNullType, isVoidType, - Model, ModelProperty, Namespace, Numeric, NumericLiteral, Operation, Program, - ProjectedProgram, StringLiteral, Type, Union, @@ -27,17 +25,13 @@ import { HttpOperation, HttpOperationResponseContent, HttpStatusCodeRange } from import { getAddedOnVersions, getRemovedOnVersions, getVersions } from "@typespec/versioning"; import { DecoratorInfo, - SdkBuiltInKinds, SdkBuiltInType, SdkClient, SdkEnumType, - SdkHttpOperationExample, SdkHttpResponse, SdkModelPropertyType, - SdkModelType, - SdkParameter, SdkType, - SdkUnionType, + TCGCContext, } from "./interfaces.js"; import { createDiagnostic, createStateSymbol } from "./lib.js"; import { @@ -389,50 +383,6 @@ export function isHttpOperation(context: TCGCContext, obj: any): obj is HttpOper export type TspLiteralType = StringLiteral | NumericLiteral | BooleanLiteral; -export interface TCGCContext { - program: Program; - emitterName: string; - generateProtocolMethods?: boolean; - generateConvenienceMethods?: boolean; - filterOutCoreModels?: boolean; - packageName?: string; - flattenUnionAsEnum?: boolean; - arm?: boolean; - modelsMap?: Map; - operationModelsMap?: Map>; - generatedNames?: Map; - spreadModels?: Map; - httpOperationCache?: Map; - unionsMap?: Map; - __namespaceToApiVersionParameter: Map; - __tspTypeToApiVersions: Map; - __namespaceToApiVersionClientDefaultValue: Map; - knownScalars?: Record; - diagnostics: readonly Diagnostic[]; - __subscriptionIdParameter?: SdkParameter; - __rawClients?: SdkClient[]; - apiVersion?: string; - __service_projection?: Map; - __httpOperationExamples?: Map; - originalProgram: Program; - examplesDirectory?: string; - decoratorsAllowList?: string[]; - previewStringRegex: RegExp; -} - -export function createTCGCContext(program: Program): TCGCContext { - return { - program, - emitterName: "__TCGC_INTERNAL__", - diagnostics: [], - originalProgram: program, - __namespaceToApiVersionParameter: new Map(), - __tspTypeToApiVersions: new Map(), - __namespaceToApiVersionClientDefaultValue: new Map(), - previewStringRegex: /-preview$/, - }; -} - export function getNonNullOptions(type: Union): Type[] { return [...type.variants.values()].map((x) => x.type).filter((t) => !isNullType(t)); } diff --git a/packages/typespec-client-generator-core/src/package.ts b/packages/typespec-client-generator-core/src/package.ts index e6b1d896ab..5b13dcb760 100644 --- a/packages/typespec-client-generator-core/src/package.ts +++ b/packages/typespec-client-generator-core/src/package.ts @@ -24,7 +24,6 @@ import { getCorrespondingMethodParams, getSdkHttpOperation, getSdkHttpParameter import { SdkClient, SdkClientType, - SdkContext, SdkEndpointParameter, SdkEndpointType, SdkEnumType, @@ -45,10 +44,10 @@ import { SdkServiceOperation, SdkServiceParameter, SdkType, + TCGCContext, UsageFlags, } from "./interfaces.js"; import { - TCGCContext, createGeneratedName, filterApiVersionsWithDecorators, getAllResponseBodiesAndNonBodyExists, @@ -78,11 +77,8 @@ import { getTypeSpecBuiltInType, } from "./types.js"; -function getSdkServiceOperation< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkServiceOperation( + context: TCGCContext, operation: Operation, methodParameters: SdkMethodParameter[] ): [TServiceOperation, readonly Diagnostic[]] { @@ -103,33 +99,25 @@ function getSdkServiceOperation< ); return diagnostics.wrap(undefined as any); } -function getSdkLroPagingServiceMethod< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkLroPagingServiceMethod( + context: TCGCContext, operation: Operation ): [SdkLroPagingServiceMethod, readonly Diagnostic[]] { const diagnostics = createDiagnosticCollector(); return diagnostics.wrap({ - ...diagnostics.pipe(getSdkLroServiceMethod(context, operation)), - ...diagnostics.pipe(getSdkPagingServiceMethod(context, operation)), + ...diagnostics.pipe(getSdkLroServiceMethod(context, operation)), + ...diagnostics.pipe(getSdkPagingServiceMethod(context, operation)), kind: "lropaging", }); } -function getSdkPagingServiceMethod< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkPagingServiceMethod( + context: TCGCContext, operation: Operation ): [SdkPagingServiceMethod, readonly Diagnostic[]] { const diagnostics = createDiagnosticCollector(); const pagedMetadata = getPagedResult(context.program, operation)!; - const basic = diagnostics.pipe( - getSdkBasicServiceMethod(context, operation) - ); + const basic = diagnostics.pipe(getSdkBasicServiceMethod(context, operation)); if (pagedMetadata.itemsProperty) { basic.response.type = diagnostics.pipe( getClientTypeWithDiagnostics(context, pagedMetadata.itemsProperty.type) @@ -143,7 +131,7 @@ function getSdkPagingServiceMethod< nextLinkPath: pagedMetadata?.nextLinkSegments?.join("."), nextLinkOperation: pagedMetadata?.nextLinkOperation ? diagnostics.pipe( - getSdkServiceOperation( + getSdkServiceOperation( context, pagedMetadata.nextLinkOperation, basic.parameters @@ -156,17 +144,14 @@ function getSdkPagingServiceMethod< }); } -function getSdkLroServiceMethod< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkLroServiceMethod( + context: TCGCContext, operation: Operation ): [SdkLroServiceMethod, readonly Diagnostic[]] { const diagnostics = createDiagnosticCollector(); const metadata = getLroMetadata(context.program, operation)!; const basicServiceMethod = diagnostics.pipe( - getSdkBasicServiceMethod(context, operation) + getSdkBasicServiceMethod(context, operation) ); if (metadata.finalResult === undefined || metadata.finalResult === "void") { @@ -184,7 +169,7 @@ function getSdkLroServiceMethod< kind: "lro", __raw_lro_metadata: metadata, operation: diagnostics.pipe( - getSdkServiceOperation( + getSdkServiceOperation( context, metadata.operation, basicServiceMethod.parameters @@ -196,11 +181,8 @@ function getSdkLroServiceMethod< }); } -function getSdkMethodResponse< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkMethodResponse( + context: TCGCContext, operation: Operation, sdkOperation: SdkServiceOperation ): SdkMethodResponse { @@ -236,11 +218,8 @@ function getSdkMethodResponse< }; } -function getSdkBasicServiceMethod< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkBasicServiceMethod( + context: TCGCContext, operation: Operation ): [SdkServiceMethod, readonly Diagnostic[]] { const diagnostics = createDiagnosticCollector(); @@ -259,7 +238,7 @@ function getSdkBasicServiceMethod< } const serviceOperation = diagnostics.pipe( - getSdkServiceOperation(context, operation, methodParameters) + getSdkServiceOperation(context, operation, methodParameters) ); const response = getSdkMethodResponse(context, operation, serviceOperation); const name = getLibraryName(context, operation); @@ -291,30 +270,24 @@ function getSdkBasicServiceMethod< }); } -function getSdkServiceMethod< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkServiceMethod( + context: TCGCContext, operation: Operation ): [SdkServiceMethod, readonly Diagnostic[]] { const lro = getLroMetadata(context.program, operation); const paging = getPagedResult(context.program, operation); if (lro && paging) { - return getSdkLroPagingServiceMethod(context, operation); + return getSdkLroPagingServiceMethod(context, operation); } else if (paging) { - return getSdkPagingServiceMethod(context, operation); + return getSdkPagingServiceMethod(context, operation); } else if (lro) { - return getSdkLroServiceMethod(context, operation); + return getSdkLroServiceMethod(context, operation); } - return getSdkBasicServiceMethod(context, operation); + return getSdkBasicServiceMethod(context, operation); } -function getClientDefaultApiVersion< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getClientDefaultApiVersion( + context: TCGCContext, client: SdkClient | SdkOperationGroup ): string | undefined { if (context.apiVersion && !["latest", "all"].includes(context.apiVersion)) { @@ -328,11 +301,8 @@ function getClientDefaultApiVersion< return defaultVersion; } -function getSdkInitializationType< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function getSdkInitializationType( + context: TCGCContext, client: SdkClient | SdkOperationGroup ): [SdkInitializationType, readonly Diagnostic[]] { const diagnostics = createDiagnosticCollector(); @@ -412,20 +382,20 @@ function getSdkMethodParameter( }); } -function getSdkMethods( - context: SdkContext, +function getSdkMethods( + context: TCGCContext, client: SdkClient | SdkOperationGroup ): [SdkMethod[], readonly Diagnostic[]] { const diagnostics = createDiagnosticCollector(); const retval: SdkMethod[] = []; for (const operation of listOperationsInOperationGroup(context, client)) { - retval.push( - diagnostics.pipe(getSdkServiceMethod(context, operation)) - ); + retval.push(diagnostics.pipe(getSdkServiceMethod(context, operation))); } for (const operationGroup of listOperationGroups(context, client)) { // We create a client accessor for each operation group - const operationGroupClient = diagnostics.pipe(createSdkClientType(context, operationGroup)); + const operationGroupClient = diagnostics.pipe( + createSdkClientType(context, operationGroup) + ); const name = `get${operationGroup.type.name}`; retval.push({ kind: "clientaccessor", @@ -528,11 +498,8 @@ function getSdkEndpointParameter( }); } -function createSdkClientType< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->( - context: SdkContext, +function createSdkClientType( + context: TCGCContext, client: SdkClient | SdkOperationGroup ): [SdkClientType, readonly Diagnostic[]] { const diagnostics = createDiagnosticCollector(); @@ -544,7 +511,7 @@ function createSdkClientType< name = getClientNameOverride(context, client.type) ?? client.type.name; } // NOTE: getSdkMethods recursively calls createSdkClientType - const methods = diagnostics.pipe(getSdkMethods(context, client)); + const methods = diagnostics.pipe(getSdkMethods(context, client)); const docWrapper = getDocHelper(context, client.type); const sdkClientType: SdkClientType = { kind: "client", @@ -554,9 +521,7 @@ function createSdkClientType< methods: methods, apiVersions: context.__tspTypeToApiVersions.get(client.type)!, nameSpace: getClientNamespaceStringHelper(context, client.service)!, - initialization: diagnostics.pipe( - getSdkInitializationType(context, client) - ), // MUST call this after getSdkMethods has been called + initialization: diagnostics.pipe(getSdkInitializationType(context, client)), // MUST call this after getSdkMethods has been called // eslint-disable-next-line deprecation/deprecation arm: client.kind === "SdkClient" ? client.arm : false, decorators: diagnostics.pipe(getTypeDecorators(context, client.type)), @@ -564,7 +529,7 @@ function createSdkClientType< return diagnostics.wrap(sdkClientType); } -function populateApiVersionInformation(context: SdkContext): void { +function populateApiVersionInformation(context: TCGCContext): void { for (const client of listClients(context)) { let clientApiVersions = resolveVersions(context.program, client.service) .filter((x) => x.rootVersion) @@ -595,10 +560,9 @@ function populateApiVersionInformation(context: SdkContext): void { } } -export function getSdkPackage< - TOptions extends object, - TServiceOperation extends SdkServiceOperation, ->(context: SdkContext): SdkPackage { +export function getSdkPackage( + context: TCGCContext +): SdkPackage { const diagnostics = createDiagnosticCollector(); populateApiVersionInformation(context); const modelsAndEnums = diagnostics.pipe(getAllModelsWithDiagnostics(context)); diff --git a/packages/typespec-client-generator-core/src/public-utils.ts b/packages/typespec-client-generator-core/src/public-utils.ts index 40110975a8..88afbd6ff9 100644 --- a/packages/typespec-client-generator-core/src/public-utils.ts +++ b/packages/typespec-client-generator-core/src/public-utils.ts @@ -28,9 +28,8 @@ import { listOperationGroups, listOperationsInOperationGroup, } from "./decorators.js"; -import { SdkHttpOperationExample } from "./interfaces.js"; +import { SdkHttpOperationExample, TCGCContext } from "./interfaces.js"; import { - TCGCContext, TspLiteralType, getClientNamespaceStringHelper, getHttpOperationResponseHeaders, diff --git a/packages/typespec-client-generator-core/src/types.ts b/packages/typespec-client-generator-core/src/types.ts index 6b2a9d8952..ee2ae7ea04 100644 --- a/packages/typespec-client-generator-core/src/types.ts +++ b/packages/typespec-client-generator-core/src/types.ts @@ -73,6 +73,7 @@ import { SdkTupleType, SdkType, SdkUnionType, + TCGCContext, UsageFlags, getKnownScalars, isSdkBuiltInKind, @@ -110,7 +111,6 @@ import { import { getVersions } from "@typespec/versioning"; import { UnionEnumVariant } from "../../typespec-azure-core/dist/src/helpers/union-enums.js"; import { getSdkHttpParameter, isSdkHttpParameter } from "./http.js"; -import { TCGCContext } from "./internal-utils.js"; export function getTypeSpecBuiltInType( context: TCGCContext, diff --git a/packages/typespec-client-generator-core/src/validate.ts b/packages/typespec-client-generator-core/src/validate.ts index fea0987a94..5af4dd87d9 100644 --- a/packages/typespec-client-generator-core/src/validate.ts +++ b/packages/typespec-client-generator-core/src/validate.ts @@ -16,12 +16,13 @@ import { UnionVariant, } from "@typespec/compiler"; import { DuplicateTracker } from "@typespec/compiler/utils"; -import { getClientNameOverride } from "./decorators.js"; -import { AllScopes, clientNameKey, createTCGCContext, TCGCContext } from "./internal-utils.js"; +import { createTCGCContext, getClientNameOverride } from "./decorators.js"; +import { TCGCContext } from "./interfaces.js"; +import { AllScopes, clientNameKey } from "./internal-utils.js"; import { reportDiagnostic } from "./lib.js"; export function $onValidate(program: Program) { - const tcgcContext = createTCGCContext(program); + const tcgcContext = createTCGCContext(program, "@azure-tools/typespec-client-generator-core"); const languageScopes = getDefinedLanguageScopes(program); for (const scope of languageScopes) { validateClientNamesPerNamespace(tcgcContext, scope, program.getGlobalNamespaceType());