diff --git a/.chronus/changes/add_package_id-2024-3-9-18-55-43.md b/.chronus/changes/add_package_id-2024-3-9-18-55-43.md new file mode 100644 index 0000000000..b9354a9c21 --- /dev/null +++ b/.chronus/changes/add_package_id-2024-3-9-18-55-43.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +add `.crossLanguagePackageId` onto `SdkContext` types. This is a package id that is shared across languages, allowing linkage between packages generated across different languages \ No newline at end of file diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index e8bee5d160..c881b5f424 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -546,6 +546,7 @@ export interface SdkPackage { * @deprecated This property is deprecated. Look at `.diagnostics` on SdkContext instead */ diagnostics: readonly Diagnostic[]; + crossLanguagePackageId: string; } export type SdkHttpPackage = SdkPackage; diff --git a/packages/typespec-client-generator-core/src/package.ts b/packages/typespec-client-generator-core/src/package.ts index 356dd5cabb..3e5768da38 100644 --- a/packages/typespec-client-generator-core/src/package.ts +++ b/packages/typespec-client-generator-core/src/package.ts @@ -59,6 +59,7 @@ import { import { createDiagnostic } from "./lib.js"; import { getClientNamespaceString, + getCrossLanguagePackageId, getDefaultApiVersion, getEffectivePayloadType, getHttpOperationWithCache, @@ -562,6 +563,7 @@ export function getSdkPackage< for (const client of listClients(context)) { createSdkClientType(context, client); } + const crossLanguagePackageId = diagnostics.pipe(getCrossLanguagePackageId(context)); return { name: getClientNamespaceString(context)!, rootNamespace: getClientNamespaceString(context)!, @@ -569,5 +571,6 @@ export function getSdkPackage< models: modelsAndEnums.filter((x): x is SdkModelType => x.kind === "model"), enums: modelsAndEnums.filter((x): x is SdkEnumType => x.kind === "enum"), diagnostics: diagnostics.diagnostics, + crossLanguagePackageId, }; }