Skip to content

Commit

Permalink
[tcgc] add .sdkPackage now that the design is finalized (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft authored Apr 1, 2024
1 parent 583076d commit 5f7be00
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 193 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/add_sdk_package-2024-3-1-11-37-51.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: deprecation
packages:
- "@azure-tools/typespec-client-generator-core"
---

deprecate `SdkContext.experimetal_sdkPackage` and add `SdkContext.sdkPackage` now that the design for `sdkPackage` is set
7 changes: 5 additions & 2 deletions packages/typespec-client-generator-core/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
} from "./interfaces.js";
import { TCGCContext, parseEmitterName } from "./internal-utils.js";
import { createStateSymbol, reportDiagnostic } from "./lib.js";
import { experimental_getSdkPackage } from "./package.js";
import { getSdkPackage } from "./package.js";
import { getLibraryName } from "./public-utils.js";
import { getSdkEnum, getSdkModel, getSdkUnion } from "./types.js";

Expand Down Expand Up @@ -512,14 +512,17 @@ export function createSdkContext<
program: context.program,
emitContext: context,
experimental_sdkPackage: undefined!,
sdkPackage: undefined!,
emitterName: parseEmitterName(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,
};
sdkContext.experimental_sdkPackage = experimental_getSdkPackage(sdkContext);
sdkContext.sdkPackage = getSdkPackage(sdkContext);
// eslint-disable-next-line deprecation/deprecation
sdkContext.experimental_sdkPackage = sdkContext.sdkPackage;
return sdkContext;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/typespec-client-generator-core/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export interface SdkContext<
TServiceOperation extends SdkServiceOperation = SdkHttpOperation,
> extends TCGCContext {
emitContext: EmitContext<TOptions>;
/**
* @deprecated This property is deprecated. Use `.sdkPackage` instead.
*/
experimental_sdkPackage: SdkPackage<TServiceOperation>;
sdkPackage: SdkPackage<TServiceOperation>;
__clients?: SdkClientType<TServiceOperation>[];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-client-generator-core/src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function createSdkClientType<
return diagnostics.wrap(sdkClientType);
}

export function experimental_getSdkPackage<
export function getSdkPackage<
TOptions extends object,
TServiceOperation extends SdkServiceOperation,
>(context: SdkContext<TOptions, TServiceOperation>): SdkPackage<TServiceOperation> {
Expand Down
Loading

0 comments on commit 5f7be00

Please sign in to comment.