From 10f286ed4982cb8bed028a6c83b92e1cda7f2f0e Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 1 Apr 2024 11:36:30 -0400 Subject: [PATCH 1/2] add sdkPackage and deprecate experimental_sdkPackage --- .../src/decorators.ts | 7 +- .../src/interfaces.ts | 4 + .../src/package.ts | 2 +- .../test/package.test.ts | 118 +++++------ .../test/public-utils.test.ts | 58 +++--- .../test/types.test.ts | 195 +++++++++--------- 6 files changed, 192 insertions(+), 192 deletions(-) diff --git a/packages/typespec-client-generator-core/src/decorators.ts b/packages/typespec-client-generator-core/src/decorators.ts index 858edb3f15..0f67400c25 100644 --- a/packages/typespec-client-generator-core/src/decorators.ts +++ b/packages/typespec-client-generator-core/src/decorators.ts @@ -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"; @@ -512,6 +512,7 @@ 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, @@ -519,7 +520,9 @@ export function createSdkContext< 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; } diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index a3a3d7f0f4..7a91f969f4 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -25,7 +25,11 @@ export interface SdkContext< TServiceOperation extends SdkServiceOperation = SdkHttpOperation, > extends TCGCContext { emitContext: EmitContext; + /** + * @deprecated This property is deprecated. Use `.sdkPackage` instead. + */ experimental_sdkPackage: SdkPackage; + sdkPackage: SdkPackage; __clients?: SdkClientType[]; } diff --git a/packages/typespec-client-generator-core/src/package.ts b/packages/typespec-client-generator-core/src/package.ts index 7a2989b6cb..70f0c62229 100644 --- a/packages/typespec-client-generator-core/src/package.ts +++ b/packages/typespec-client-generator-core/src/package.ts @@ -527,7 +527,7 @@ function createSdkClientType< return diagnostics.wrap(sdkClientType); } -export function experimental_getSdkPackage< +export function getSdkPackage< TOptions extends object, TServiceOperation extends SdkServiceOperation, >(context: SdkContext): SdkPackage { diff --git a/packages/typespec-client-generator-core/test/package.test.ts b/packages/typespec-client-generator-core/test/package.test.ts index 2e9483727c..b6b8f5b568 100644 --- a/packages/typespec-client-generator-core/test/package.test.ts +++ b/packages/typespec-client-generator-core/test/package.test.ts @@ -33,7 +33,7 @@ describe("typespec-client-generator-core: package", () => { namespace Not.My.Package.Name; `); - strictEqual(runnerWithPackageName.context.experimental_sdkPackage.name, "My.Package.Name"); + strictEqual(runnerWithPackageName.context.sdkPackage.name, "My.Package.Name"); }); it("from namespace", async () => { await runner.compile(` @@ -42,7 +42,7 @@ describe("typespec-client-generator-core: package", () => { namespace My.Package.Name; `); - strictEqual(runner.context.experimental_sdkPackage.name, "My.Package.Name"); + strictEqual(runner.context.sdkPackage.name, "My.Package.Name"); }); }); describe("root namespace", () => { @@ -53,7 +53,7 @@ describe("typespec-client-generator-core: package", () => { namespace My.Namespace; `); - strictEqual(runner.context.experimental_sdkPackage.rootNamespace, "My.Namespace"); + strictEqual(runner.context.sdkPackage.rootNamespace, "My.Namespace"); }); it("nested namespaces", async () => { @@ -67,7 +67,7 @@ describe("typespec-client-generator-core: package", () => { namespace My.Namespace.Sub {}; `); - strictEqual(runner.context.experimental_sdkPackage.rootNamespace, "My.Namespace"); + strictEqual(runner.context.sdkPackage.rootNamespace, "My.Namespace"); }); }); describe("SdkClientType", () => { @@ -77,7 +77,7 @@ describe("typespec-client-generator-core: package", () => { @service({}) namespace NotMyClient; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); strictEqual(sdkPackage.clients[0].name, "MyClient"); strictEqual(sdkPackage.clients[0].kind, "client"); @@ -88,7 +88,7 @@ describe("typespec-client-generator-core: package", () => { @service({}) namespace My.Service; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -114,7 +114,7 @@ describe("typespec-client-generator-core: package", () => { @service({}) namespace My.Service; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -155,7 +155,7 @@ describe("typespec-client-generator-core: package", () => { scopes: ["https://security.microsoft.com/.default"]; } `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -202,7 +202,7 @@ describe("typespec-client-generator-core: package", () => { scopes: ["https://security.microsoft.com/.default"]; } `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -263,7 +263,7 @@ describe("typespec-client-generator-core: package", () => { @service({}) namespace My.Service; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -329,7 +329,7 @@ describe("typespec-client-generator-core: package", () => { v1_0: "v1.0", } `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -427,7 +427,7 @@ describe("typespec-client-generator-core: package", () => { op delete is Operations.ResourceDelete; `); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -498,7 +498,7 @@ describe("typespec-client-generator-core: package", () => { op delete is Operations.ResourceDelete; `); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; strictEqual(client.name, "ServiceClient"); @@ -540,7 +540,7 @@ describe("typespec-client-generator-core: package", () => { @service({name: "ServiceTwo"}) namespace My.Service.Two {}; `); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 2); const clientOne = sdkPackage.clients.filter((c) => c.name === "OneClient")[0]; strictEqual(clientOne.nameSpace, "My.Service.One"); @@ -556,7 +556,7 @@ describe("typespec-client-generator-core: package", () => { op func(): void; } `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 2); const mainClient = sdkPackage.clients.find((c) => c.name === "TestServiceClient"); @@ -595,7 +595,7 @@ describe("typespec-client-generator-core: package", () => { two(): void; } `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.clients.length, 4); const mainClient = sdkPackage.clients.find((c) => c.name === "TestServiceClient"); @@ -681,7 +681,7 @@ describe("typespec-client-generator-core: package", () => { op withoutApiVersion(): OkResponse; `) ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; @@ -712,7 +712,7 @@ describe("typespec-client-generator-core: package", () => { op withQueryApiVersion(@query("api-version") apiVersion: string): OkResponse; `) ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; @@ -790,7 +790,7 @@ describe("typespec-client-generator-core: package", () => { op withoutApiVersion(): OkResponse; `) ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; @@ -818,7 +818,7 @@ describe("typespec-client-generator-core: package", () => { op withQueryApiVersion(@query("api-version") apiVersion: string): OkResponse; `) ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; @@ -867,7 +867,7 @@ describe("typespec-client-generator-core: package", () => { op withPathApiVersion(@path apiVersion: string): OkResponse; `) ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 1); const client = sdkPackage.clients[0]; @@ -915,7 +915,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@path path: string): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "myOp"); strictEqual(method.kind, "basic"); @@ -967,7 +967,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@path path: string | null): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); const methodParam = method.parameters[0]; strictEqual(methodParam.nullable, true); @@ -990,7 +990,7 @@ describe("typespec-client-generator-core: package", () => { name: string; } `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "pathInModel"); strictEqual(method.kind, "basic"); @@ -1028,7 +1028,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@header header: string): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "myOp"); strictEqual(method.kind, "basic"); @@ -1078,7 +1078,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@header header: string | null): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); const methodParam = method.parameters[0]; strictEqual(methodParam.nullable, true); @@ -1095,7 +1095,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@header({format: "multi"}) header: string): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.kind, "basic"); @@ -1112,7 +1112,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@query query: string): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "myOp"); strictEqual(method.kind, "basic"); @@ -1161,7 +1161,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@query query: string | null): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); const methodParam = method.parameters[0]; strictEqual(methodParam.nullable, true); @@ -1178,7 +1178,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@query({format: "multi"}) query: string): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.kind, "basic"); @@ -1199,7 +1199,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@body body: Input): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 1); strictEqual(sdkPackage.models[0].name, "Input"); @@ -1266,7 +1266,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@body body: Input | null): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); const methodBodyParam = method.parameters.find((x) => x.name === "body"); ok(methodBodyParam); @@ -1288,7 +1288,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(@body body?: Input): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 1); strictEqual(sdkPackage.models[0].name, "Input"); @@ -1353,7 +1353,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(...Input): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "myOp"); strictEqual(method.kind, "basic"); @@ -1400,7 +1400,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(...BodyParameter): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 1); strictEqual(method.name, "myOp"); @@ -1464,7 +1464,7 @@ describe("typespec-client-generator-core: package", () => { op test(...Pet): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 1); strictEqual(method.name, "test"); @@ -1520,7 +1520,7 @@ describe("typespec-client-generator-core: package", () => { op myOp(options: RequestOptions): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.models.length, 1); const method = getServiceMethodOfClient(sdkPackage); @@ -1627,7 +1627,7 @@ describe("typespec-client-generator-core: package", () => { await runner.compileWithBuiltInService(` @patch op patchNull(@body body: string): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 0); strictEqual(method.name, "patchNull"); @@ -1679,7 +1679,7 @@ describe("typespec-client-generator-core: package", () => { } @post op default(@body body: DefaultDatetimeProperty): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.parameters.length, 2); @@ -1723,7 +1723,7 @@ describe("typespec-client-generator-core: package", () => { } @get op default(): DefaultDatetimeProperty; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.parameters.length, 1); @@ -1767,7 +1767,7 @@ describe("typespec-client-generator-core: package", () => { value: bytes; }; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.parameters.length, 1); @@ -1814,7 +1814,7 @@ describe("typespec-client-generator-core: package", () => { @delete op delete(@path id: string): void | Error; ` ); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 1); strictEqual(method.name, "delete"); @@ -1857,7 +1857,7 @@ describe("typespec-client-generator-core: package", () => { @post op create(...Widget): Widget | Error; ` ); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 2); strictEqual(method.name, "create"); @@ -1900,7 +1900,7 @@ describe("typespec-client-generator-core: package", () => { op operation(): Widget; ` ); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 1); strictEqual(method.name, "operation"); @@ -1948,7 +1948,7 @@ describe("typespec-client-generator-core: package", () => { op operation(): {@header id: string | null, @body body: Widget | null}; ` ); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); const serviceResponses = method.operation.responses; @@ -1970,7 +1970,7 @@ describe("typespec-client-generator-core: package", () => { op operation(): Widget | NoContentResponse; ` ); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); const serviceResponses = method.operation.responses; @@ -1991,7 +1991,7 @@ describe("typespec-client-generator-core: package", () => { @delete op delete(@path id: string): NoContentResponse; ` ); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(sdkPackage.models.length, 0); strictEqual(method.name, "delete"); @@ -2049,7 +2049,7 @@ describe("typespec-client-generator-core: package", () => { it("vanilla widget create", async () => { await compileVanillaWidgetService(runner, "@post create(...Widget): Widget | Error;"); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "create"); strictEqual(method.kind, "basic"); @@ -2110,7 +2110,7 @@ describe("typespec-client-generator-core: package", () => { it("vanilla widget read", async () => { await compileVanillaWidgetService(runner, "@get read(@path id: string): Widget | Error;"); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "read"); strictEqual(method.kind, "basic"); @@ -2160,7 +2160,7 @@ describe("typespec-client-generator-core: package", () => { it("vanilla widget update", async () => { await compileVanillaWidgetService(runner, "@patch update(...Widget): Widget | Error;"); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "update"); strictEqual(method.kind, "basic"); @@ -2240,7 +2240,7 @@ describe("typespec-client-generator-core: package", () => { it("vanilla widget delete", async () => { await compileVanillaWidgetService(runner, "@delete delete(@path id: string): void | Error;"); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "delete"); strictEqual(method.kind, "basic"); @@ -2279,7 +2279,7 @@ describe("typespec-client-generator-core: package", () => { it("vanilla widget list", async () => { await compileVanillaWidgetService(runner, "@get list(): Widget[] | Error;"); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.name, "list"); strictEqual(method.kind, "basic"); @@ -2487,7 +2487,7 @@ describe("typespec-client-generator-core: package", () => { getWidget is Operations.ResourceRead; ` ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; const parentClient = sdkPackage.clients.filter( (c) => c.initialization.access === "public" )[0]; @@ -2578,7 +2578,7 @@ describe("typespec-client-generator-core: package", () => { createOrUpdateWidget is Operations.LongRunningResourceCreateOrUpdate; ` ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 2); const client = sdkPackage.clients.find((c) => c.initialization.access === "internal"); ok(client); @@ -2780,7 +2780,7 @@ describe("typespec-client-generator-core: package", () => { listManufacturers is Operations.ResourceList; ` ); - const sdkPackage = runnerWithCore.context.experimental_sdkPackage; + const sdkPackage = runnerWithCore.context.sdkPackage; strictEqual(sdkPackage.clients.length, 2); strictEqual(sdkPackage.models.length, 1); strictEqual(sdkPackage.models[0].name, "Manufacturer"); @@ -2893,7 +2893,7 @@ describe("typespec-client-generator-core: package", () => { extends ExtensionResourceCreateOrUpdate, ExtensionResourceList {} `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.models.length, 4); deepStrictEqual( sdkPackage.models.map((x) => x.name).sort(), @@ -2940,8 +2940,8 @@ describe("typespec-client-generator-core: package", () => { } op createShelf(...CreateShelfRequest): Shelf; `); - const method = getServiceMethodOfClient(runner.context.experimental_sdkPackage); - const models = runner.context.experimental_sdkPackage.models; + const method = getServiceMethodOfClient(runner.context.sdkPackage); + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const shelfModel = models.find((x) => x.name === "Shelf"); ok(shelfModel); @@ -3001,7 +3001,7 @@ describe("typespec-client-generator-core: package", () => { op getPet(...ApiVersionParam): void; `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; const method = getServiceMethodOfClient(sdkPackage); strictEqual(method.operation.parameters.length, 1); const apiVersionParam = method.operation.parameters[0]; diff --git a/packages/typespec-client-generator-core/test/public-utils.test.ts b/packages/typespec-client-generator-core/test/public-utils.test.ts index ef107cac16..305f9f1739 100644 --- a/packages/typespec-client-generator-core/test/public-utils.test.ts +++ b/packages/typespec-client-generator-core/test/public-utils.test.ts @@ -799,7 +799,7 @@ describe("typespec-client-generator-core: public-utils", () => { op getStatus is GetResourceOperationStatus; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const model = models.filter((x) => x.name === "ResourceOperationStatusUser")[0]; ok(model); @@ -812,7 +812,7 @@ describe("typespec-client-generator-core: public-utils", () => { await runner.compileWithBuiltInService(` op test(@body body: {name: string}): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].name, "TestRequest"); ok(models[0].isGeneratedName); @@ -822,7 +822,7 @@ describe("typespec-client-generator-core: public-utils", () => { await runner.compileWithBuiltInService(` op test(): {name: string}; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].name, "TestResponse"); ok(models[0].isGeneratedName); @@ -832,7 +832,7 @@ describe("typespec-client-generator-core: public-utils", () => { await runner.compileWithBuiltInService(` op test(@body body: {name: string}): {name: string}; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); ok(models.find((x) => x.name === "TestRequest" && x.isGeneratedName)); ok(models.find((x) => x.name === "TestResponse" && x.isGeneratedName)); @@ -847,7 +847,7 @@ describe("typespec-client-generator-core: public-utils", () => { } op test(): A; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); ok(models.find((x) => x.name === "APForA" && x.isGeneratedName)); }); @@ -864,7 +864,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); ok(models.find((x) => x.name === "APForA" && x.isGeneratedName)); }); @@ -881,7 +881,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): A; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); ok(models.find((x) => x.name === "APForA" && x.isGeneratedName)); }); @@ -897,7 +897,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); ok(models.find((x) => x.name === "AMember" && x.isGeneratedName)); }); @@ -908,7 +908,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: {name: string}[]): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].name, "TestRequest"); ok(models[0].isGeneratedName); @@ -920,7 +920,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: Record<{name: string}>): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].name, "TestRequest"); ok(models[0].isGeneratedName); @@ -935,7 +935,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); ok(models.find((x) => x.name === "AMember" && x.isGeneratedName)); ok(models.find((x) => x.name === "AMemberName" && x.isGeneratedName)); @@ -956,7 +956,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); ok(models.find((x) => x.name === "BPForB" && x.isGeneratedName)); }); @@ -986,7 +986,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: Fish): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 5); ok(models.find((x) => x.name === "SharkPForShark" && x.isGeneratedName)); ok(models.find((x) => x.name === "SalmonPForSalmon" && x.isGeneratedName)); @@ -1009,7 +1009,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); ok(models.find((x) => x.name === "BPForB" && x.isGeneratedName)); }); @@ -1034,7 +1034,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 4); ok(models.find((x) => x.name === "CP1ForC" && x.isGeneratedName)); }); @@ -1056,7 +1056,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); ok(models.find((x) => x.name === "BP2ForB" && x.isGeneratedName)); }); @@ -1075,7 +1075,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); ok(models.find((x) => x.name === "APForA" && x.isGeneratedName)); ok(models.find((x) => x.name === "APForAPForAnonymousModel" && x.isGeneratedName)); @@ -1090,7 +1090,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); ok(models.find((x) => x.name === "APForA" && x.isGeneratedName)); ok(models.find((x) => x.name === "APForAName" && x.isGeneratedName)); @@ -1107,7 +1107,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); ok(models.find((x) => x.name === "AB" && x.isGeneratedName)); }); @@ -1123,7 +1123,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const unionEnum = models[0].properties[0].type; strictEqual(unionEnum.kind, "enum"); @@ -1158,8 +1158,8 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; - const diagnostics = runner.context.experimental_sdkPackage.diagnostics; + const models = runner.context.sdkPackage.models; + const diagnostics = runner.context.sdkPackage.diagnostics; strictEqual(models.length, 4); const union = models[0].properties[0].type; strictEqual(union.kind, "union"); @@ -1186,7 +1186,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(@body body: A): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const test1 = models.find((x) => x.name === "AChoice" && x.isGeneratedName); ok(test1); @@ -1223,7 +1223,7 @@ describe("typespec-client-generator-core: public-utils", () => { op op3(@body body: B): boolean; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); ok(models.find((x) => x.name === "BPForB" && x.isGeneratedName)); }); @@ -1242,7 +1242,7 @@ describe("typespec-client-generator-core: public-utils", () => { } ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const propType = models[0].properties[0].type; strictEqual(propType.kind, "model"); @@ -1260,7 +1260,7 @@ describe("typespec-client-generator-core: public-utils", () => { } ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const unionEnum = models[0].properties[0].type; strictEqual(unionEnum.kind, "enum"); @@ -1283,7 +1283,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(...RequestParameter): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); ok(models.find((x) => x.name === "TestRequest" && x.isGeneratedName)); }); @@ -1294,7 +1294,7 @@ describe("typespec-client-generator-core: public-utils", () => { op test(foo: string, bar: string): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); ok(models.find((x) => x.name === "TestRequest" && x.isGeneratedName)); }); @@ -1426,7 +1426,7 @@ describe("typespec-client-generator-core: public-utils", () => { emitterName: "@azure-tools/typespec-java", }); await runnerWithCore.compile(lroCode); - const models = runnerWithCore.context.experimental_sdkPackage.models; + const models = runnerWithCore.context.sdkPackage.models; strictEqual(models.length, 2); deepStrictEqual(models.map((x) => x.name).sort(), ["ExportedUser", "User"].sort()); }); diff --git a/packages/typespec-client-generator-core/test/types.test.ts b/packages/typespec-client-generator-core/test/types.test.ts index 02c4d984a9..7119961b50 100644 --- a/packages/typespec-client-generator-core/test/types.test.ts +++ b/packages/typespec-client-generator-core/test/types.test.ts @@ -165,7 +165,7 @@ describe("typespec-client-generator-core: types", () => { } ` ); - const models = runnerWithCore.context.experimental_sdkPackage.models; + const models = runnerWithCore.context.sdkPackage.models; for (const property of models[0].properties) { strictEqual(property.kind, "property"); strictEqual( @@ -201,7 +201,7 @@ describe("typespec-client-generator-core: types", () => { op getStatus is GetResourceOperationStatus; } `); - const userModel = runnerWithCore.context.experimental_sdkPackage.models.find( + const userModel = runnerWithCore.context.sdkPackage.models.find( (x) => x.kind === "model" && x.name === "User" ); ok(userModel); @@ -250,11 +250,11 @@ describe("typespec-client-generator-core: types", () => { ): void; ` ); - const diagnostics = runner.context.experimental_sdkPackage.diagnostics; + const diagnostics = runner.context.sdkPackage.diagnostics; expectDiagnostics(diagnostics, []); - const m = runner.context.experimental_sdkPackage.models.find((x) => x.name === "TestModel"); - const e1 = runner.context.experimental_sdkPackage.enums.find((x) => x.name === "TestEnum"); - const e2 = runner.context.experimental_sdkPackage.enums.find((x) => x.name === "testScalar"); + const m = runner.context.sdkPackage.models.find((x) => x.name === "TestModel"); + const e1 = runner.context.sdkPackage.enums.find((x) => x.name === "TestEnum"); + const e2 = runner.context.sdkPackage.enums.find((x) => x.name === "testScalar"); ok(m && e1 && e2); strictEqual(e1.kind, "enum"); strictEqual(e1.isUnionAsEnum, false); @@ -477,7 +477,7 @@ describe("typespec-client-generator-core: types", () => { strictEqual(sdkType.kind, "float32"); // eslint-disable-next-line deprecation/deprecation strictEqual(sdkType.nullable, true); - const nameProp = runner.context.experimental_sdkPackage.models[0].properties[0]; + const nameProp = runner.context.sdkPackage.models[0].properties[0]; strictEqual(nameProp.nullable, true); }); @@ -496,7 +496,7 @@ describe("typespec-client-generator-core: types", () => { strictEqual(elementType.kind, "float32"); // eslint-disable-next-line deprecation/deprecation strictEqual(elementType.nullable, true); - const nameProp = runner.context.experimental_sdkPackage.models[0].properties[0]; + const nameProp = runner.context.sdkPackage.models[0].properties[0]; strictEqual(nameProp.nullable, false); strictEqual(sdkType.nullableValues, true); }); @@ -516,7 +516,7 @@ describe("typespec-client-generator-core: types", () => { strictEqual(elementType.kind, "float32"); // eslint-disable-next-line deprecation/deprecation strictEqual(elementType.nullable, true); - const nameProp = runner.context.experimental_sdkPackage.models[0].properties[0]; + const nameProp = runner.context.sdkPackage.models[0].properties[0]; strictEqual(nameProp.nullable, false); strictEqual(sdkType.nullableValues, true); }); @@ -572,7 +572,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 4); const modelWithNamedUnionProperty = models.find( (x) => x.kind === "model" && x.name === "ModelWithNamedUnionProperty" @@ -617,7 +617,7 @@ describe("typespec-client-generator-core: types", () => { strictEqual(sdkType.name, "PetKind"); // eslint-disable-next-line deprecation/deprecation strictEqual(sdkType.nullable, true); - const pet = runner.context.experimental_sdkPackage.models[0].properties[0]; + const pet = runner.context.sdkPackage.models[0].properties[0]; strictEqual(pet.nullable, true); const values = sdkType.values; strictEqual(values.length, 3); @@ -638,7 +638,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const model = models.find((x) => x.kind === "model" && x.name === "Test"); ok(model); @@ -671,7 +671,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); const model = models.find((x) => x.kind === "model" && x.name === "Test"); ok(model); @@ -731,13 +731,13 @@ describe("typespec-client-generator-core: types", () => { ): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const foo = models.find((x) => x.name === "Foo"); ok(foo); strictEqual(foo.usage, UsageFlags.Input); strictEqual(foo.access, "internal"); - const enums = runner.context.experimental_sdkPackage.enums; + const enums = runner.context.sdkPackage.enums; strictEqual(enums.length, 1); const unionAsEnum = enums.find((x) => x.name === "UnionAsEnum"); ok(unionAsEnum); @@ -777,13 +777,13 @@ describe("typespec-client-generator-core: types", () => { ): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const foo = models.find((x) => x.name === "Foo"); ok(foo); strictEqual(foo.usage, UsageFlags.Input | UsageFlags.Output); strictEqual(foo.access, "public"); - const enums = runner.context.experimental_sdkPackage.enums; + const enums = runner.context.sdkPackage.enums; strictEqual(enums.length, 1); const unionAsEnum = enums.find((x) => x.name === "UnionAsEnum"); ok(unionAsEnum); @@ -813,9 +813,9 @@ describe("typespec-client-generator-core: types", () => { } `); - strictEqual(runner.context.experimental_sdkPackage.models.length, 1); - strictEqual(runner.context.experimental_sdkPackage.enums.length, 1); - const sdkType = runner.context.experimental_sdkPackage.enums[0]; + strictEqual(runner.context.sdkPackage.models.length, 1); + strictEqual(runner.context.sdkPackage.enums.length, 1); + const sdkType = runner.context.sdkPackage.enums[0]; strictEqual(sdkType.isFixed, true); strictEqual(sdkType.name, "DaysOfWeekExtensibleEnum"); strictEqual(sdkType.valueType.kind, "string"); @@ -865,9 +865,9 @@ describe("typespec-client-generator-core: types", () => { } `); - strictEqual(runner.context.experimental_sdkPackage.models.length, 1); - strictEqual(runner.context.experimental_sdkPackage.enums.length, 1); - const sdkType = runner.context.experimental_sdkPackage.enums[0]; + strictEqual(runner.context.sdkPackage.models.length, 1); + strictEqual(runner.context.sdkPackage.enums.length, 1); + const sdkType = runner.context.sdkPackage.enums[0]; strictEqual(sdkType.isFixed, true); strictEqual(sdkType.name, "Integers"); strictEqual(sdkType.valueType.kind, "int32"); @@ -900,7 +900,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const sdkType = runner.context.experimental_sdkPackage.enums[0]; + const sdkType = runner.context.sdkPackage.enums[0]; ok(sdkType); strictEqual(sdkType.isFixed, true); strictEqual(sdkType.name, "Floats"); @@ -935,7 +935,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const sdkType = runner.context.experimental_sdkPackage.enums[0]; + const sdkType = runner.context.sdkPackage.enums[0]; strictEqual(sdkType.isFixed, false); strictEqual(sdkType.name, "Floats"); strictEqual(sdkType.valueType.kind, "float"); @@ -974,7 +974,7 @@ describe("typespec-client-generator-core: types", () => { prop: ExtendedEnum } `); - const sdkType = runner.context.experimental_sdkPackage.enums[0]; + const sdkType = runner.context.sdkPackage.enums[0]; ok(sdkType); strictEqual(sdkType.isFixed, false); strictEqual(sdkType.valueType.kind, "int32"); @@ -1020,9 +1020,9 @@ describe("typespec-client-generator-core: types", () => { } } `); - strictEqual(runnerWithCore.context.experimental_sdkPackage.models.length, 1); - strictEqual(runnerWithCore.context.experimental_sdkPackage.enums.length, 1); - const sdkType = runnerWithCore.context.experimental_sdkPackage.enums[0]; + strictEqual(runnerWithCore.context.sdkPackage.models.length, 1); + strictEqual(runnerWithCore.context.sdkPackage.enums.length, 1); + const sdkType = runnerWithCore.context.sdkPackage.enums[0]; strictEqual(sdkType.isFixed, true); strictEqual(sdkType.name, "DaysOfWeekFixedEnum"); strictEqual(sdkType.valueType.kind, "string"); @@ -1065,7 +1065,7 @@ describe("typespec-client-generator-core: types", () => { ): void; `); - strictEqual(runner.context.experimental_sdkPackage.enums[0].access, "internal"); + strictEqual(runner.context.sdkPackage.enums[0].access, "internal"); }); it("crossLanguageDefinitionId", async () => { await runner.compile(` @@ -1088,8 +1088,8 @@ describe("typespec-client-generator-core: types", () => { } } `); - strictEqual(runner.context.experimental_sdkPackage.enums.length, 1); - const integersEnum = runner.context.experimental_sdkPackage.enums[0]; + strictEqual(runner.context.sdkPackage.enums.length, 1); + const integersEnum = runner.context.sdkPackage.enums[0]; strictEqual(integersEnum.crossLanguageDefinitionId, "MyService.Integers"); }); @@ -1106,7 +1106,7 @@ describe("typespec-client-generator-core: types", () => { ): void; `); - strictEqual(runner.context.experimental_sdkPackage.enums[0].deprecation, "no longer support"); + strictEqual(runner.context.sdkPackage.enums[0].deprecation, "no longer support"); }); it("orphan enum", async () => { @@ -1130,11 +1130,8 @@ describe("typespec-client-generator-core: types", () => { } `); - strictEqual(runner.context.experimental_sdkPackage.enums[0].name, "Enum1"); - strictEqual( - runner.context.experimental_sdkPackage.enums[0].usage, - UsageFlags.Input | UsageFlags.Output - ); + strictEqual(runner.context.sdkPackage.enums[0].name, "Enum1"); + strictEqual(runner.context.sdkPackage.enums[0].usage, UsageFlags.Input | UsageFlags.Output); }); it("projected name", async () => { @@ -1427,7 +1424,7 @@ describe("typespec-client-generator-core: types", () => { } ` ); - const enums = runner.context.experimental_sdkPackage.enums; + const enums = runner.context.sdkPackage.enums; strictEqual(enums.length, 1); strictEqual(enums[0].name, "Versions"); strictEqual(enums[0].usage, UsageFlags.ApiVersionEnum); @@ -1456,7 +1453,7 @@ describe("typespec-client-generator-core: types", () => { } ` ); - const enums = runner.context.experimental_sdkPackage.enums; + const enums = runner.context.sdkPackage.enums; strictEqual(enums.length, 2); strictEqual(enums[0].name, "LR"); strictEqual(enums[0].usage, UsageFlags.Input); @@ -1539,7 +1536,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const sdkModel = runner.context.experimental_sdkPackage.models[0]; + const sdkModel = runner.context.sdkPackage.models[0]; strictEqual(sdkModel.name, "JavaTest"); // Java projected name test @@ -1627,9 +1624,7 @@ describe("typespec-client-generator-core: types", () => { removedProp: string; } `); - const sdkModel = runner.context.experimental_sdkPackage.models.find( - (x) => x.kind === "model" - ); + const sdkModel = runner.context.sdkPackage.models.find((x) => x.kind === "model"); ok(sdkModel); strictEqual(sdkModel.kind, "model"); @@ -1703,7 +1698,7 @@ describe("typespec-client-generator-core: types", () => { op test(@body input: InputModel): OutputModel; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual(modelNames, ["InputModel", "OutputModel"].sort()); @@ -1720,7 +1715,7 @@ describe("typespec-client-generator-core: types", () => { op test(@body input: Record): void; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual(modelNames, ["InnerModel"].sort()); @@ -1737,7 +1732,7 @@ describe("typespec-client-generator-core: types", () => { op test(@body input: InnerModel[]): void; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual(modelNames, ["InnerModel"].sort()); @@ -1758,7 +1753,7 @@ describe("typespec-client-generator-core: types", () => { op test(@body input: InputModel): void; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual(modelNames, ["InputModel", "InnerModel"].sort()); @@ -1779,7 +1774,7 @@ describe("typespec-client-generator-core: types", () => { op test(@body input: InputModel): void; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual(modelNames, ["InputModel", "BaseModel"].sort()); @@ -1797,7 +1792,7 @@ describe("typespec-client-generator-core: types", () => { op test(@body input: DerivedModel): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual(modelNames, ["InputModel", "DerivedModel"].sort()); @@ -1811,7 +1806,7 @@ describe("typespec-client-generator-core: types", () => { prop: RecursiveModel } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const recursiveModel = models[0]; strictEqual(recursiveModel.name, "RecursiveModel"); @@ -1856,7 +1851,7 @@ describe("typespec-client-generator-core: types", () => { @get op getModel(): Fish; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 5); const fish = models.find((x) => x.name === "Fish"); ok(fish); @@ -1890,7 +1885,7 @@ describe("typespec-client-generator-core: types", () => { @get op getModel(): Fish; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const fish = models.find((x) => x.name === "Fish"); ok(fish); @@ -1925,7 +1920,7 @@ describe("typespec-client-generator-core: types", () => { @get op getExtensibleModel(): Dog; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const golden = models.find((x) => x.name === "Golden"); @@ -1940,8 +1935,8 @@ describe("typespec-client-generator-core: types", () => { const dog = models.find((x) => x.name === "Dog"); ok(dog); - strictEqual(runner.context.experimental_sdkPackage.enums.length, 1); - const dogKind = runner.context.experimental_sdkPackage.enums[0]; + strictEqual(runner.context.sdkPackage.enums.length, 1); + const dogKind = runner.context.sdkPackage.enums[0]; const dogKindProperty = dog.properties.find( (x) => x.kind === "property" && x.serializedName === "kind" @@ -1966,8 +1961,8 @@ describe("typespec-client-generator-core: types", () => { @put op putPet(@body petKind: PetKind): void; `); - strictEqual(runner.context.experimental_sdkPackage.enums.length, 1); - const petKind = runner.context.experimental_sdkPackage.enums[0]; + strictEqual(runner.context.sdkPackage.enums.length, 1); + const petKind = runner.context.sdkPackage.enums[0]; strictEqual(petKind.name, "PetKind"); strictEqual(petKind.isFixed, false); strictEqual(petKind.valueType.kind, "string"); @@ -2007,7 +2002,7 @@ describe("typespec-client-generator-core: types", () => { @route("/string-extensible") interface StringExtensible extends GetAndSend {} `); - const sdkPackage = runner.context.experimental_sdkPackage; + const sdkPackage = runner.context.sdkPackage; strictEqual(sdkPackage.models.length, 2); strictEqual(sdkPackage.enums.length, 1); const prop = sdkPackage.enums.find((x) => x.name === "GetResponseProp" && x.isGeneratedName); @@ -2032,11 +2027,11 @@ describe("typespec-client-generator-core: types", () => { @put op putPet(@body pet: Pet): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const pet = models.find((x) => x.name === "Pet"); - const enums = runner.context.experimental_sdkPackage.enums; + const enums = runner.context.sdkPackage.enums; const kind = enums.find((x) => x.name === "PetKind"); ok(pet && kind); ok(kind.isGeneratedName); @@ -2064,7 +2059,7 @@ describe("typespec-client-generator-core: types", () => { @get op getExtensibleModel(): Dog; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const golden = models.find((x) => x.name === "Golden"); @@ -2079,8 +2074,8 @@ describe("typespec-client-generator-core: types", () => { const dog = models.find((x) => x.name === "Dog"); ok(dog); - strictEqual(runner.context.experimental_sdkPackage.enums.length, 1); - const dogKind = runner.context.experimental_sdkPackage.enums[0]; + strictEqual(runner.context.sdkPackage.enums.length, 1); + const dogKind = runner.context.sdkPackage.enums[0]; const dogKindProperty = dog.properties[0]; ok(dogKindProperty); @@ -2118,7 +2113,7 @@ describe("typespec-client-generator-core: types", () => { @get op getModel(): Fish; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 5); const shark = models.find((x) => x.name === "Shark"); ok(shark); @@ -2156,7 +2151,7 @@ describe("typespec-client-generator-core: types", () => { @get op getModel(): Fish; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); const fish = models.find((x) => x.name === "Fish"); ok(fish); @@ -2178,10 +2173,8 @@ describe("typespec-client-generator-core: types", () => { strictEqual(kindTypeProperty.type.kind, "enumvalue"); strictEqual(salmon.discriminatorValue, "salmon"); - strictEqual(runner.context.experimental_sdkPackage.enums.length, 1); - const kindType = runner.context.experimental_sdkPackage.enums.find( - (x) => x.name === "KindType" - ); + strictEqual(runner.context.sdkPackage.enums.length, 1); + const kindType = runner.context.sdkPackage.enums.find((x) => x.name === "KindType"); ok(kindType); strictEqual(kindType.isFixed, false); }); @@ -2213,7 +2206,7 @@ describe("typespec-client-generator-core: types", () => { op createOrUpdate is ResourceCreateOrUpdate; } `); - const models = runnerWithCore.context.experimental_sdkPackage.models; + const models = runnerWithCore.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].name, "User"); }); @@ -2246,7 +2239,7 @@ describe("typespec-client-generator-core: types", () => { op createOrUpdate is ResourceCreateOrUpdate; } `); - const models = runnerWithCore.context.experimental_sdkPackage.models; + const models = runnerWithCore.context.sdkPackage.models; strictEqual(models.length, 4); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual(modelNames, ["Error", "ErrorResponse", "InnerError", "User"].sort()); @@ -2280,7 +2273,7 @@ describe("typespec-client-generator-core: types", () => { op createOrUpdateUser is LongRunningResourceCreateOrUpdate; } `); - const models = runnerWithCore.context.experimental_sdkPackage.models; + const models = runnerWithCore.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].name, "User"); }); @@ -2313,7 +2306,7 @@ describe("typespec-client-generator-core: types", () => { op createOrUpdateUser is LongRunningResourceCreateOrUpdate; } `); - const models = runnerWithCore.context.experimental_sdkPackage.models; + const models = runnerWithCore.context.sdkPackage.models; strictEqual(models.length, 5); const modelNames = models.map((model) => model.name).sort(); deepStrictEqual( @@ -2326,15 +2319,15 @@ describe("typespec-client-generator-core: types", () => { "ResourceOperationStatusUserUserError", ].sort() ); - strictEqual(runnerWithCore.context.experimental_sdkPackage.enums.length, 1); - strictEqual(runnerWithCore.context.experimental_sdkPackage.enums[0].name, "OperationState"); + strictEqual(runnerWithCore.context.sdkPackage.enums.length, 1); + strictEqual(runnerWithCore.context.sdkPackage.enums[0].name, "OperationState"); }); it("no models filter core", async () => { await runner.compile(` @service({}) @test namespace MyService { } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 0); }); it("no models don't filter core", async () => { @@ -2342,7 +2335,7 @@ describe("typespec-client-generator-core: types", () => { @service({}) @test namespace MyService { } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 0); }); it("input usage", async () => { @@ -2352,7 +2345,7 @@ describe("typespec-client-generator-core: types", () => { } op operation(@body input: InputModel): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].usage, UsageFlags.Input); strictEqual(models.filter((x) => x.usage === UsageFlags.Input).length, 1); @@ -2366,7 +2359,7 @@ describe("typespec-client-generator-core: types", () => { } op operation(): OutputModel; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].usage, UsageFlags.Output); @@ -2381,7 +2374,7 @@ describe("typespec-client-generator-core: types", () => { } op operation(@body input: RoundtripModel): RoundtripModel; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].usage, UsageFlags.Input | UsageFlags.Output); @@ -2418,7 +2411,7 @@ describe("typespec-client-generator-core: types", () => { } op operation(@body input: Shark): Shark; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 5); strictEqual(models[0].usage, UsageFlags.Input | UsageFlags.Output); }); @@ -2433,7 +2426,7 @@ describe("typespec-client-generator-core: types", () => { @body body: Test ): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); const propreties: string[] = []; models.forEach((model) => { @@ -2455,7 +2448,7 @@ describe("typespec-client-generator-core: types", () => { ): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].access, "internal"); }); @@ -2512,7 +2505,7 @@ describe("typespec-client-generator-core: types", () => { @body body: Test6 ): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 6); const Test1 = models.find((x) => x.name === "Test1"); @@ -2557,7 +2550,7 @@ describe("typespec-client-generator-core: types", () => { prop: string; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); const AdditionalPropertiesModel = models.find((x) => x.name === "AdditionalPropertiesModel"); const AdditionalPropertiesModel2 = models.find( @@ -2589,7 +2582,7 @@ describe("typespec-client-generator-core: types", () => { op test(@body input: AdditionalPropertiesModel): AdditionalPropertiesModel2; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); const AdditionalPropertiesModel = models.find((x) => x.name === "AdditionalPropertiesModel"); const AdditionalPropertiesModel2 = models.find( @@ -2619,7 +2612,7 @@ describe("typespec-client-generator-core: types", () => { model OutputModel {} } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const inputModel = models.find((x) => x.name === "InputModel"); ok(inputModel); @@ -2665,7 +2658,7 @@ describe("typespec-client-generator-core: types", () => { deploymentDateUtc?: utcDateTime; } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 4); const catalog = models.find((x) => x.name === "Catalog"); const deployment = models.find((x) => x.name === "Deployment"); @@ -2685,7 +2678,7 @@ describe("typespec-client-generator-core: types", () => { ): void; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].deprecation, "no longer support"); }); @@ -2703,7 +2696,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); strictEqual(models[0].name, "Model1"); strictEqual(models[0].usage, UsageFlags.Input | UsageFlags.Output); @@ -2735,7 +2728,7 @@ describe("typespec-client-generator-core: types", () => { } } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); }); it("error model", async () => { @@ -2818,7 +2811,7 @@ describe("typespec-client-generator-core: types", () => { op basic(@header contentType: "multipart/form-data", @body body: MultiPartRequest): NoContentResponse; `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const model = models[0]; strictEqual(model.kind, "model"); @@ -2869,7 +2862,7 @@ describe("typespec-client-generator-core: types", () => { @post op normalOperation(...B): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const modelA = models.find((x) => x.name === "A"); ok(modelA); @@ -2912,7 +2905,7 @@ describe("typespec-client-generator-core: types", () => { @put op multipartOne(@header contentType: "multipart/form-data", @body body: AddressFirstAppearance): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 3); }); @@ -2926,7 +2919,7 @@ describe("typespec-client-generator-core: types", () => { @put op multipartOp(@header contentType: "multipart/form-data", @body body: PictureWrapper): void; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const model = models[0]; strictEqual(model.properties.length, 1); @@ -2947,7 +2940,7 @@ describe("typespec-client-generator-core: types", () => { @put op multipartOp(@header contentType: "multipart/form-data", @body body: EncodedBytesMFD): void; ` ); - expectDiagnostics(runner.context.experimental_sdkPackage.diagnostics, { + expectDiagnostics(runner.context.sdkPackage.diagnostics, { code: "@azure-tools/typespec-client-generator-core/encoding-multipart-bytes", }); }); @@ -2967,7 +2960,7 @@ describe("typespec-client-generator-core: types", () => { @post op normalOp(): void | ErrorResponse; ` ); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 2); const pictureWrapper = models.find((x) => x.name === "PictureWrapper"); @@ -3007,7 +3000,7 @@ describe("typespec-client-generator-core: types", () => { upload(...WidgetForm): Widget; } `); - const formDataMethod = runner.context.experimental_sdkPackage.clients[0].methods[0]; + const formDataMethod = runner.context.sdkPackage.clients[0].methods[0]; strictEqual(formDataMethod.kind, "basic"); strictEqual(formDataMethod.name, "upload"); strictEqual(formDataMethod.parameters.length, 3); @@ -3050,7 +3043,7 @@ describe("typespec-client-generator-core: types", () => { } `); - const models = runner.context.experimental_sdkPackage.models; + const models = runner.context.sdkPackage.models; strictEqual(models.length, 1); const scopes = models[0].properties.find((x) => x.name === "scopes"); ok(scopes); @@ -3068,7 +3061,7 @@ describe("typespec-client-generator-core: types", () => { }); function getSdkBodyModelPropertyTypeHelper(runner: SdkTestRunner): SdkBodyModelPropertyType { - const sdkModel = runner.context.experimental_sdkPackage.models.find((x) => x.kind === "model"); + const sdkModel = runner.context.sdkPackage.models.find((x) => x.kind === "model"); ok(sdkModel); strictEqual(sdkModel.kind, "model"); const property = sdkModel.properties[0]; From 6ee2f7a09260e994b9c5cf3c9bd20c23628ca29a Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 1 Apr 2024 11:37:59 -0400 Subject: [PATCH 2/2] add changeset --- .chronus/changes/add_sdk_package-2024-3-1-11-37-51.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/add_sdk_package-2024-3-1-11-37-51.md diff --git a/.chronus/changes/add_sdk_package-2024-3-1-11-37-51.md b/.chronus/changes/add_sdk_package-2024-3-1-11-37-51.md new file mode 100644 index 0000000000..e0373315e0 --- /dev/null +++ b/.chronus/changes/add_sdk_package-2024-3-1-11-37-51.md @@ -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 \ No newline at end of file