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 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 f0c72a81bb..77016093c4 100644 --- a/packages/typespec-client-generator-core/src/package.ts +++ b/packages/typespec-client-generator-core/src/package.ts @@ -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): SdkPackage { diff --git a/packages/typespec-client-generator-core/test/package.test.ts b/packages/typespec-client-generator-core/test/package.test.ts index 3e89616a65..c79f9e217c 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"); @@ -1356,7 +1356,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); @@ -1463,7 +1463,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"); @@ -1515,7 +1515,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); @@ -1559,7 +1559,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); @@ -1603,7 +1603,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); @@ -1650,7 +1650,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"); @@ -1693,7 +1693,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"); @@ -1736,7 +1736,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"); @@ -1784,7 +1784,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; @@ -1806,7 +1806,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; @@ -1827,7 +1827,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"); @@ -1885,7 +1885,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"); @@ -1946,7 +1946,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"); @@ -1996,7 +1996,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"); @@ -2076,7 +2076,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"); @@ -2115,7 +2115,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"); @@ -2323,7 +2323,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]; @@ -2414,7 +2414,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); @@ -2616,7 +2616,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"); @@ -2708,7 +2708,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"); @@ -2755,7 +2755,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"); @@ -2819,7 +2819,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"); @@ -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); @@ -2997,7 +2997,7 @@ describe("typespec-client-generator-core: package", () => { alias Intersected = DocumentTranslateContent & {}; op test(...Intersected): void; `); - const method = getServiceMethodOfClient(runner.context.experimental_sdkPackage); + const method = getServiceMethodOfClient(runner.context.sdkPackage); const documentMethodParam = method.parameters.find((x) => x.name === "document"); ok(documentMethodParam); strictEqual(documentMethodParam.kind, "method"); @@ -3021,7 +3021,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 3852540813..d280d22ab9 100644 --- a/packages/typespec-client-generator-core/test/types.test.ts +++ b/packages/typespec-client-generator-core/test/types.test.ts @@ -162,7 +162,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( @@ -194,7 +194,7 @@ describe("typespec-client-generator-core: types", () => { @doc("Gets status.") 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); @@ -243,11 +243,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); @@ -470,7 +470,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); }); @@ -489,7 +489,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); }); @@ -509,7 +509,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); }); @@ -565,7 +565,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" @@ -610,7 +610,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); @@ -631,7 +631,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); @@ -664,7 +664,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); @@ -724,13 +724,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); @@ -770,13 +770,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); @@ -806,9 +806,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"); @@ -858,9 +858,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"); @@ -893,7 +893,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"); @@ -928,7 +928,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"); @@ -967,7 +967,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"); @@ -1010,9 +1010,9 @@ describe("typespec-client-generator-core: types", () => { prop: DaysOfWeekFixedEnum } `); - 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"); @@ -1055,7 +1055,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(` @@ -1078,8 +1078,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"); }); @@ -1096,7 +1096,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 () => { @@ -1120,11 +1120,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 () => { @@ -1417,7 +1414,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); @@ -1446,7 +1443,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); @@ -1529,7 +1526,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 @@ -1617,9 +1614,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"); @@ -1693,7 +1688,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()); @@ -1710,7 +1705,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()); @@ -1727,7 +1722,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()); @@ -1748,7 +1743,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()); @@ -1769,7 +1764,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()); @@ -1787,7 +1782,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()); @@ -1801,7 +1796,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"); @@ -1846,7 +1841,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); @@ -1880,7 +1875,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); @@ -1915,7 +1910,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"); @@ -1930,8 +1925,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" @@ -1956,8 +1951,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"); @@ -1997,7 +1992,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); @@ -2022,11 +2017,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); @@ -2054,7 +2049,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"); @@ -2069,8 +2064,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); @@ -2108,7 +2103,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); @@ -2146,7 +2141,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); @@ -2168,10 +2163,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); }); @@ -2198,7 +2191,7 @@ describe("typespec-client-generator-core: types", () => { @doc("Creates or updates a User") 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"); }); @@ -2226,7 +2219,7 @@ describe("typespec-client-generator-core: types", () => { @doc("Creates or updates a User") 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()); @@ -2255,7 +2248,7 @@ describe("typespec-client-generator-core: types", () => { @pollingOperation(My.Service.getStatus) 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"); }); @@ -2284,7 +2277,7 @@ describe("typespec-client-generator-core: types", () => { @pollingOperation(My.Service.getStatus) 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( @@ -2297,15 +2290,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 () => { @@ -2313,7 +2306,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 () => { @@ -2323,7 +2316,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); @@ -2337,7 +2330,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); @@ -2352,7 +2345,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); @@ -2389,7 +2382,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); }); @@ -2404,7 +2397,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) => { @@ -2426,7 +2419,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"); }); @@ -2483,7 +2476,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"); @@ -2528,7 +2521,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( @@ -2560,7 +2553,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( @@ -2590,7 +2583,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); @@ -2636,7 +2629,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"); @@ -2656,7 +2649,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"); }); @@ -2674,7 +2667,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); @@ -2706,7 +2699,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 () => { @@ -2789,7 +2782,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"); @@ -2840,7 +2833,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); @@ -2883,7 +2876,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); }); @@ -2897,7 +2890,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); @@ -2918,7 +2911,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", }); }); @@ -2938,7 +2931,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"); @@ -2978,7 +2971,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); @@ -3021,7 +3014,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); @@ -3039,7 +3032,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];