@azure-tools/typespec-ts 0.55.0-dev.3 → 0.55.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +1 -13
  2. package/dist/src/framework/load-static-helpers.d.ts +4 -1
  3. package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
  4. package/dist/src/framework/load-static-helpers.js +16 -21
  5. package/dist/src/framework/load-static-helpers.js.map +1 -1
  6. package/dist/src/framework/sample.js +1 -1
  7. package/dist/src/framework/sample.js.map +1 -1
  8. package/dist/src/index.d.ts.map +1 -1
  9. package/dist/src/index.js +55 -56
  10. package/dist/src/index.js.map +1 -1
  11. package/dist/src/lib.d.ts +1 -3
  12. package/dist/src/lib.d.ts.map +1 -1
  13. package/dist/src/lib.js +1 -11
  14. package/dist/src/lib.js.map +1 -1
  15. package/dist/src/modular/build-client-context.d.ts.map +1 -1
  16. package/dist/src/modular/build-client-context.js +6 -15
  17. package/dist/src/modular/build-client-context.js.map +1 -1
  18. package/dist/src/modular/build-root-index.d.ts.map +1 -1
  19. package/dist/src/modular/build-root-index.js +4 -7
  20. package/dist/src/modular/build-root-index.js.map +1 -1
  21. package/dist/src/modular/emit-logger-file.d.ts.map +1 -1
  22. package/dist/src/modular/emit-logger-file.js +0 -3
  23. package/dist/src/modular/emit-logger-file.js.map +1 -1
  24. package/dist/src/modular/emit-samples.js +7 -24
  25. package/dist/src/modular/emit-samples.js.map +1 -1
  26. package/dist/src/modular/emit-tests.d.ts +2 -1
  27. package/dist/src/modular/emit-tests.d.ts.map +1 -1
  28. package/dist/src/modular/emit-tests.js +18 -8
  29. package/dist/src/modular/emit-tests.js.map +1 -1
  30. package/dist/src/modular/helpers/client-helpers.d.ts.map +1 -1
  31. package/dist/src/modular/helpers/client-helpers.js +6 -16
  32. package/dist/src/modular/helpers/client-helpers.js.map +1 -1
  33. package/dist/src/modular/helpers/example-value-helpers.d.ts +1 -1
  34. package/dist/src/modular/helpers/example-value-helpers.d.ts.map +1 -1
  35. package/dist/src/modular/helpers/example-value-helpers.js +7 -24
  36. package/dist/src/modular/helpers/example-value-helpers.js.map +1 -1
  37. package/dist/src/modular/helpers/operation-helpers.js +1 -1
  38. package/dist/src/modular/helpers/operation-helpers.js.map +1 -1
  39. package/dist/src/rlc-common/build-client-definitions.js +1 -1
  40. package/dist/src/rlc-common/build-client-definitions.js.map +1 -1
  41. package/dist/src/rlc-common/build-client.d.ts.map +1 -1
  42. package/dist/src/rlc-common/build-client.js +14 -21
  43. package/dist/src/rlc-common/build-client.js.map +1 -1
  44. package/dist/src/rlc-common/build-index-file.d.ts.map +1 -1
  45. package/dist/src/rlc-common/build-index-file.js +7 -10
  46. package/dist/src/rlc-common/build-index-file.js.map +1 -1
  47. package/dist/src/rlc-common/build-is-unexpected-helper.js +1 -1
  48. package/dist/src/rlc-common/build-is-unexpected-helper.js.map +1 -1
  49. package/dist/src/rlc-common/build-logger.d.ts.map +1 -1
  50. package/dist/src/rlc-common/build-logger.js +1 -5
  51. package/dist/src/rlc-common/build-logger.js.map +1 -1
  52. package/dist/src/rlc-common/build-parameter-types.js +1 -1
  53. package/dist/src/rlc-common/build-parameter-types.js.map +1 -1
  54. package/dist/src/rlc-common/build-response-types.js +1 -1
  55. package/dist/src/rlc-common/build-response-types.js.map +1 -1
  56. package/dist/src/rlc-common/build-schema-type.js +1 -1
  57. package/dist/src/rlc-common/build-schema-type.js.map +1 -1
  58. package/dist/src/rlc-common/build-top-level-index-file.js +1 -1
  59. package/dist/src/rlc-common/build-top-level-index-file.js.map +1 -1
  60. package/dist/src/rlc-common/helpers/imports-util.d.ts +3 -4
  61. package/dist/src/rlc-common/helpers/imports-util.d.ts.map +1 -1
  62. package/dist/src/rlc-common/helpers/imports-util.js +43 -56
  63. package/dist/src/rlc-common/helpers/imports-util.js.map +1 -1
  64. package/dist/src/rlc-common/helpers/package-util.d.ts +1 -4
  65. package/dist/src/rlc-common/helpers/package-util.d.ts.map +1 -1
  66. package/dist/src/rlc-common/helpers/package-util.js +2 -5
  67. package/dist/src/rlc-common/helpers/package-util.js.map +1 -1
  68. package/dist/src/rlc-common/interfaces.d.ts +1 -6
  69. package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
  70. package/dist/src/rlc-common/interfaces.js.map +1 -1
  71. package/dist/src/rlc-common/metadata/build-api-extractor-config.js +1 -1
  72. package/dist/src/rlc-common/metadata/build-api-extractor-config.js.map +1 -1
  73. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts +1 -1
  74. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts.map +1 -1
  75. package/dist/src/rlc-common/metadata/build-es-lint-config.js +1 -4
  76. package/dist/src/rlc-common/metadata/build-es-lint-config.js.map +1 -1
  77. package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -1
  78. package/dist/src/rlc-common/metadata/build-package-file.js +7 -13
  79. package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -1
  80. package/dist/src/rlc-common/metadata/build-readme-file.d.ts +2 -2
  81. package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -1
  82. package/dist/src/rlc-common/metadata/build-readme-file.js +6 -10
  83. package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -1
  84. package/dist/src/rlc-common/metadata/build-rollup-config.d.ts.map +1 -1
  85. package/dist/src/rlc-common/metadata/build-rollup-config.js +2 -3
  86. package/dist/src/rlc-common/metadata/build-rollup-config.js.map +1 -1
  87. package/dist/src/rlc-common/metadata/build-sample-env-file.d.ts.map +1 -1
  88. package/dist/src/rlc-common/metadata/build-sample-env-file.js +1 -2
  89. package/dist/src/rlc-common/metadata/build-sample-env-file.js.map +1 -1
  90. package/dist/src/rlc-common/metadata/build-ts-config.js +1 -1
  91. package/dist/src/rlc-common/metadata/build-ts-config.js.map +1 -1
  92. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +0 -3
  93. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +1 -1
  94. package/dist/src/rlc-common/metadata/package-json/package-common.js +0 -3
  95. package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -1
  96. package/dist/src/rlc-common/transform-sample-groups.d.ts.map +1 -1
  97. package/dist/src/rlc-common/transform-sample-groups.js +6 -17
  98. package/dist/src/rlc-common/transform-sample-groups.js.map +1 -1
  99. package/dist/src/transform/transform-helper-function-details.d.ts +2 -2
  100. package/dist/src/transform/transform-helper-function-details.d.ts.map +1 -1
  101. package/dist/src/transform/transform-helper-function-details.js +1 -9
  102. package/dist/src/transform/transform-helper-function-details.js.map +1 -1
  103. package/dist/src/transform/transform.js +2 -2
  104. package/dist/src/transform/transform.js.map +1 -1
  105. package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -1
  106. package/dist/src/transform/transfrom-rlc-options.js +17 -44
  107. package/dist/src/transform/transfrom-rlc-options.js.map +1 -1
  108. package/dist/src/utils/emit-util.d.ts.map +1 -1
  109. package/dist/src/utils/emit-util.js +13 -10
  110. package/dist/src/utils/emit-util.js.map +1 -1
  111. package/dist/src/utils/file-system-utils.d.ts +4 -4
  112. package/dist/src/utils/file-system-utils.d.ts.map +1 -1
  113. package/dist/src/utils/file-system-utils.js +12 -13
  114. package/dist/src/utils/file-system-utils.js.map +1 -1
  115. package/dist/src/utils/resolve-project-root.d.ts +6 -4
  116. package/dist/src/utils/resolve-project-root.d.ts.map +1 -1
  117. package/dist/src/utils/resolve-project-root.js +11 -16
  118. package/dist/src/utils/resolve-project-root.js.map +1 -1
  119. package/dist/tsconfig.tsbuildinfo +1 -1
  120. package/package.json +7 -18
  121. package/src/framework/load-static-helpers.ts +26 -26
  122. package/src/framework/sample.ts +1 -1
  123. package/src/index.ts +65 -58
  124. package/src/lib.ts +2 -14
  125. package/src/modular/build-client-context.ts +6 -14
  126. package/src/modular/build-root-index.ts +4 -7
  127. package/src/modular/emit-logger-file.ts +0 -3
  128. package/src/modular/emit-samples.ts +7 -22
  129. package/src/modular/emit-tests.ts +22 -9
  130. package/src/modular/helpers/client-helpers.ts +7 -17
  131. package/src/modular/helpers/example-value-helpers.ts +7 -22
  132. package/src/modular/helpers/operation-helpers.ts +1 -1
  133. package/src/rlc-common/build-client-definitions.ts +1 -1
  134. package/src/rlc-common/build-client.ts +17 -26
  135. package/src/rlc-common/build-index-file.ts +7 -10
  136. package/src/rlc-common/build-is-unexpected-helper.ts +1 -1
  137. package/src/rlc-common/build-logger.ts +1 -5
  138. package/src/rlc-common/build-parameter-types.ts +1 -1
  139. package/src/rlc-common/build-response-types.ts +1 -1
  140. package/src/rlc-common/build-schema-type.ts +1 -1
  141. package/src/rlc-common/build-top-level-index-file.ts +1 -1
  142. package/src/rlc-common/helpers/imports-util.ts +44 -56
  143. package/src/rlc-common/helpers/package-util.ts +3 -7
  144. package/src/rlc-common/interfaces.ts +1 -8
  145. package/src/rlc-common/metadata/build-api-extractor-config.ts +1 -1
  146. package/src/rlc-common/metadata/build-es-lint-config.ts +1 -4
  147. package/src/rlc-common/metadata/build-package-file.ts +7 -19
  148. package/src/rlc-common/metadata/build-readme-file.ts +6 -10
  149. package/src/rlc-common/metadata/build-rollup-config.ts +2 -3
  150. package/src/rlc-common/metadata/build-sample-env-file.ts +1 -4
  151. package/src/rlc-common/metadata/build-ts-config.ts +1 -1
  152. package/src/rlc-common/metadata/package-json/package-common.ts +0 -4
  153. package/src/rlc-common/transform-sample-groups.ts +7 -22
  154. package/src/transform/transform-helper-function-details.ts +1 -10
  155. package/src/transform/transform.ts +2 -2
  156. package/src/transform/transfrom-rlc-options.ts +17 -51
  157. package/src/utils/emit-util.ts +13 -24
  158. package/src/utils/file-system-utils.ts +13 -13
  159. package/src/utils/resolve-project-root.ts +11 -22
  160. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.d.ts +0 -57
  161. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.d.ts.map +0 -1
  162. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.js +0 -53
  163. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.js.map +0 -1
  164. package/src/rlc-common/metadata/package-json/build-flavorless-package.ts +0 -68
@@ -1,5 +1,4 @@
1
- import { joinPaths } from "@typespec/compiler";
2
- import { existsSync, rmSync } from "fs";
1
+ import { type CompilerHost, joinPaths } from "@typespec/compiler";
3
2
  import { SourceFile } from "ts-morph";
4
3
  import { resolveReference } from "../framework/reference.js";
5
4
  import { NameType, normalizeName } from "../rlc-common/index.js";
@@ -22,7 +21,7 @@ import { CreateRecorderHelpers } from "./static-helpers-metadata.js";
22
21
  /**
23
22
  * Clean up the test/generated folder before generating new tests
24
23
  */
25
- async function cleanupTestFolder(dpgContext: SdkContext) {
24
+ async function cleanupTestFolder(dpgContext: SdkContext, host: CompilerHost) {
26
25
  const clients = dpgContext.sdkPackage.clients;
27
26
  const baseTestFolder = joinPaths(
28
27
  dpgContext.generationPathDetail?.rootDir ?? "",
@@ -30,19 +29,28 @@ async function cleanupTestFolder(dpgContext: SdkContext) {
30
29
  "generated",
31
30
  );
32
31
 
32
+ async function dirExists(path: string): Promise<boolean> {
33
+ try {
34
+ const s = await host.stat(path);
35
+ return s.isDirectory();
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+
33
41
  // If there are multiple clients, clean up subfolders
34
42
  if (clients.length > 1) {
35
43
  for (const client of clients) {
36
44
  const subFolder = normalizeName(getClassicalClientName(client), NameType.File);
37
45
  const clientTestFolder = joinPaths(baseTestFolder, subFolder);
38
- if (existsSync(clientTestFolder)) {
39
- rmSync(clientTestFolder, { recursive: true, force: true });
46
+ if (await dirExists(clientTestFolder)) {
47
+ await host.rm(clientTestFolder, { recursive: true });
40
48
  }
41
49
  }
42
50
  } else {
43
51
  // Single client, clean up the entire test/generated folder
44
- if (existsSync(baseTestFolder)) {
45
- rmSync(baseTestFolder, { recursive: true, force: true });
52
+ if (await dirExists(baseTestFolder)) {
53
+ await host.rm(baseTestFolder, { recursive: true });
46
54
  }
47
55
  }
48
56
  }
@@ -50,9 +58,14 @@ async function cleanupTestFolder(dpgContext: SdkContext) {
50
58
  /**
51
59
  * Helpers to emit tests similar to samples
52
60
  */
53
- export async function emitTests(dpgContext: SdkContext): Promise<SourceFile[]> {
61
+ export async function emitTests(
62
+ dpgContext: SdkContext,
63
+ host?: CompilerHost,
64
+ ): Promise<SourceFile[]> {
54
65
  // Clean up the test/generated folder before generating new tests
55
- await cleanupTestFolder(dpgContext);
66
+ if (host) {
67
+ await cleanupTestFolder(dpgContext, host);
68
+ }
56
69
 
57
70
  return iterateClientsAndMethods(dpgContext, emitMethodTests);
58
71
  }
@@ -10,7 +10,7 @@ import { OptionalKind, ParameterDeclarationStructure, StatementedNode } from "ts
10
10
  import { ModularEmitterOptions } from "../interfaces.js";
11
11
 
12
12
  import { resolveReference } from "../../framework/reference.js";
13
- import { NameType, normalizeName, PackageFlavor } from "../../rlc-common/index.js";
13
+ import { NameType, normalizeName } from "../../rlc-common/index.js";
14
14
  import { SdkContext } from "../../utils/interfaces.js";
15
15
  import { CloudSettingHelpers } from "../static-helpers-metadata.js";
16
16
  import { getTypeExpression } from "../type-expressions/get-type-expression.js";
@@ -169,16 +169,10 @@ export function buildGetClientEndpointParam(
169
169
  client: SdkClientType<SdkServiceOperation>,
170
170
  ): { endpointParamName: string; assignedOptionalParams?: Set<string> } {
171
171
  const assignedOptionalParams = new Set<string>();
172
- let coreEndpointParam: string;
173
- if (dpgContext.rlcOptions?.flavor === "azure") {
174
- const cloudSettingSuffix = dpgContext.arm
175
- ? ` ?? ${resolveReference(CloudSettingHelpers.getArmEndpoint)}(options.cloudSetting)`
176
- : "";
177
- coreEndpointParam = `options.endpoint${cloudSettingSuffix}`;
178
- } else {
179
- // unbranded does not have the deprecated baseUrl parameter
180
- coreEndpointParam = `options.endpoint`;
181
- }
172
+ const cloudSettingSuffix = dpgContext.arm
173
+ ? ` ?? ${resolveReference(CloudSettingHelpers.getArmEndpoint)}(options.cloudSetting)`
174
+ : "";
175
+ const coreEndpointParam = `options.endpoint${cloudSettingSuffix}`;
182
176
  // Special case: endpoint URL not defined
183
177
  const endpointParam = getClientParameters(client, dpgContext, {
184
178
  onClientOnly: true,
@@ -248,7 +242,7 @@ export function buildGetClientOptionsParam(
248
242
  apiVersionParamName?: string,
249
243
  ): string {
250
244
  const userAgentOptions = buildUserAgentOptions(context, emitterOptions, "azsdk-js-api");
251
- const loggingOptions = buildLoggingOptions(emitterOptions.options.flavor);
245
+ const loggingOptions = buildLoggingOptions();
252
246
  const credentials = buildCredentials(emitterOptions, endpointParam);
253
247
 
254
248
  // Use the actual api version parameter name for destructuring, defaulting to "apiVersion"
@@ -315,11 +309,7 @@ function buildCredentials(
315
309
  return `{ ${scopes}${apiKeyHeaderName} }`;
316
310
  }
317
311
 
318
- function buildLoggingOptions(flavor?: PackageFlavor): string | undefined {
319
- if (flavor !== "azure") {
320
- return undefined;
321
- }
322
-
312
+ function buildLoggingOptions(): string | undefined {
323
313
  return `{ logger: options.loggingOptions?.logger ?? logger.info }`;
324
314
  }
325
315
 
@@ -12,7 +12,7 @@ import { joinPaths } from "@typespec/compiler";
12
12
  import { SourceFile } from "ts-morph";
13
13
  import { useContext } from "../../context-manager.js";
14
14
  import { resolveReference } from "../../framework/reference.js";
15
- import { isAzurePackage, NameType, normalizeName } from "../../rlc-common/index.js";
15
+ import { NameType, normalizeName } from "../../rlc-common/index.js";
16
16
  import { getSubscriptionId } from "../../transform/transfrom-rlc-options.js";
17
17
  import { hasKeyCredential, hasTokenCredential } from "../../utils/credential-utils.js";
18
18
  import { SdkContext } from "../../utils/interfaces.js";
@@ -73,7 +73,7 @@ export function prepareCommonValue(
73
73
  * Get credential value for samples
74
74
  */
75
75
  export function getCredentialSampleValue(
76
- dpgContext: SdkContext,
76
+ _dpgContext: SdkContext,
77
77
  initialization: SdkClientInitializationType,
78
78
  ): CommonValue | undefined {
79
79
  const keyCredential = hasKeyCredential(initialization),
@@ -84,26 +84,11 @@ export function getCredentialSampleValue(
84
84
  name: "credential",
85
85
  };
86
86
  if (keyCredential || tokenCredential) {
87
- if (isAzurePackage({ options: dpgContext.rlcOptions })) {
88
- // Support DefaultAzureCredential for Azure packages
89
- return {
90
- ...defaultSetting,
91
- value: `new ${resolveReference(AzureIdentityDependencies.DefaultAzureCredential)}()`,
92
- };
93
- } else if (keyCredential) {
94
- // Support ApiKeyCredential for non-Azure packages
95
- return {
96
- ...defaultSetting,
97
- value: `{ key: "INPUT_YOUR_KEY_HERE" }`,
98
- };
99
- } else if (tokenCredential) {
100
- // Support TokenCredential for non-Azure packages
101
- return {
102
- ...defaultSetting,
103
- value: `{ getToken: async () => {
104
- return { token: "INPUT_YOUR_TOKEN_HERE", expiresOnTimestamp: Date.now() }; } }`,
105
- };
106
- }
87
+ // Support DefaultAzureCredential for Azure packages
88
+ return {
89
+ ...defaultSetting,
90
+ value: `new ${resolveReference(AzureIdentityDependencies.DefaultAzureCredential)}()`,
91
+ };
107
92
  }
108
93
  return undefined;
109
94
  }
@@ -2060,7 +2060,7 @@ function getSerializationExpressionForFlatten(
2060
2060
  );
2061
2061
  const optionalPrefix = property.optional
2062
2062
  ? `${resolveReference(SerializationHelpers.areAllPropsUndefined)}(${propertyPath}, [${validProps
2063
- .map((p) => `"${p.name}"`)
2063
+ .map((p) => normalizeModelPropertyName(context, p))
2064
2064
  .join(", ")}]) ? undefined : `
2065
2065
  : "";
2066
2066
  return `${optionalPrefix}${serializeFunctionName}(${propertyPath})`;
@@ -30,7 +30,7 @@ export function buildClientDefinitions(model: RLCModel) {
30
30
  importedResponses: new Set<string>(),
31
31
  clientImports: new Set<string>(),
32
32
  };
33
- const project = new Project();
33
+ const project = new Project({ useInMemoryFileSystem: true });
34
34
  const srcPath = model.srcPath;
35
35
  const filePath = joinPaths(srcPath, `clientDefinitions.ts`);
36
36
  const clientDefinitionsFile = project.createSourceFile(filePath, undefined, {
@@ -16,7 +16,6 @@ import { buildMethodShortcutImplementation } from "./build-method-shortcuts.js";
16
16
  import { getImportSpecifier } from "./helpers/imports-util.js";
17
17
  import { getClientName, getImportModuleName } from "./helpers/name-constructors.js";
18
18
  import { NameType, normalizeName } from "./helpers/name-utils.js";
19
- import { isAzurePackage } from "./helpers/package-util.js";
20
19
  import { File, PathParameter, RLCModel } from "./interfaces.js";
21
20
 
22
21
  function getClientOptionsInterface(
@@ -62,7 +61,7 @@ function getClientOptionsInterface(
62
61
  export function buildClient(model: RLCModel): File | undefined {
63
62
  const name = normalizeName(model.libraryName, NameType.File);
64
63
  const { srcPath } = model;
65
- const project = new Project();
64
+ const project = new Project({ useInMemoryFileSystem: true });
66
65
  const filePath = joinPaths(srcPath, `${name}.ts`);
67
66
  const clientFile = project.createSourceFile(filePath, undefined, {
68
67
  overwrite: true,
@@ -192,20 +191,18 @@ export function buildClient(model: RLCModel): File | undefined {
192
191
  moduleSpecifier: getImportSpecifier("restClient", model.importInfo.runtimeImports),
193
192
  },
194
193
  ]);
195
- if (isAzurePackage(model)) {
196
- clientFile.addImportDeclarations([
197
- {
198
- namedImports: ["logger"],
199
- moduleSpecifier: getImportModuleName(
200
- {
201
- cjsName: loggerPath,
202
- esModulesName: `${loggerPath}.js`,
203
- },
204
- model,
205
- ),
206
- },
207
- ]);
208
- }
194
+ clientFile.addImportDeclarations([
195
+ {
196
+ namedImports: ["logger"],
197
+ moduleSpecifier: getImportModuleName(
198
+ {
199
+ cjsName: loggerPath,
200
+ esModulesName: `${loggerPath}.js`,
201
+ },
202
+ model,
203
+ ),
204
+ },
205
+ ]);
209
206
 
210
207
  const includeKeyCredentialHelper =
211
208
  customHttpAuthHeaderName &&
@@ -349,12 +346,10 @@ export function getClientFactoryBody(
349
346
  const apiKeyHeaderName = credentialKeyHeaderName
350
347
  ? `apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "${credentialKeyHeaderName}",`
351
348
  : "";
352
- const loggerOptions = isAzurePackage(model)
353
- ? `,
349
+ const loggerOptions = `,
354
350
  loggingOptions: {
355
351
  logger: options.loggingOptions?.logger ?? logger.info
356
- }`
357
- : "";
352
+ }`;
358
353
 
359
354
  const credentialsOptions =
360
355
  (scopes || apiKeyHeaderName) && addCredentials
@@ -400,16 +395,12 @@ export function getClientFactoryBody(
400
395
  }
401
396
 
402
397
  let apiVersionPolicyStatement = `client.pipeline.removePolicy({ name: "ApiVersionPolicy" });`;
403
- if (isAzurePackage(model) && model.apiVersionInfo?.isCrossedVersion !== false) {
398
+ if (model.apiVersionInfo?.isCrossedVersion !== false) {
404
399
  apiVersionPolicyStatement += `
405
400
  if (options.apiVersion) {
406
401
  logger.warning("This client does not support client api-version, please change it at the operation level");
407
402
  }`;
408
- } else if (
409
- isAzurePackage(model) &&
410
- !model.apiVersionInfo?.defaultValue &&
411
- model.apiVersionInfo?.required
412
- ) {
403
+ } else if (!model.apiVersionInfo?.defaultValue && model.apiVersionInfo?.required) {
413
404
  apiVersionPolicyStatement += `
414
405
  if (options.apiVersion) {
415
406
  logger.warning("This client does not support to set api-version in options, please change it at positional argument");
@@ -17,13 +17,12 @@ import {
17
17
  hasTsvCollection,
18
18
  hasUnexpectedHelper,
19
19
  } from "./helpers/operation-helpers.js";
20
- import { isAzurePackage } from "./helpers/package-util.js";
21
20
  import { RLCModel } from "./interfaces.js";
22
21
 
23
22
  export function buildIndexFile(model: RLCModel) {
24
23
  const multiClient = Boolean(model.options?.multiClient),
25
24
  batch = model.options?.batch;
26
- const project = new Project();
25
+ const project = new Project({ useInMemoryFileSystem: true });
27
26
  const { srcPath } = model;
28
27
  const filePath = joinPaths(srcPath, `index.ts`);
29
28
  const indexFile = project.createSourceFile(filePath, undefined, {
@@ -328,14 +327,12 @@ function generateRLCIndex(file: SourceFile, model: RLCModel) {
328
327
  ]);
329
328
  }
330
329
 
331
- if (isAzurePackage(model)) {
332
- file.addExportDeclarations([
333
- {
334
- moduleSpecifier: "@azure/core-rest-pipeline",
335
- namedExports: ["RestError", "isRestError"],
336
- },
337
- ]);
338
- }
330
+ file.addExportDeclarations([
331
+ {
332
+ moduleSpecifier: "@azure/core-rest-pipeline",
333
+ namedExports: ["RestError", "isRestError"],
334
+ },
335
+ ]);
339
336
 
340
337
  file.addExportAssignment({
341
338
  expression: createClientFuncName,
@@ -15,7 +15,7 @@ export function buildIsUnexpectedHelper(model: RLCModel) {
15
15
  if (!hasUnexpectedHelper(model)) {
16
16
  return;
17
17
  }
18
- const project = new Project();
18
+ const project = new Project({ useInMemoryFileSystem: true });
19
19
  const srcPath = model.srcPath;
20
20
  const filePath = joinPaths(srcPath, `isUnexpected.ts`);
21
21
  const isErrorHelper = project.createSourceFile(filePath, undefined, {
@@ -9,11 +9,7 @@ export function buildLogger(model: RLCModel) {
9
9
  if (!model.options) {
10
10
  return undefined;
11
11
  }
12
- // Disable logger for non-Azure packages
13
- if (model.options.flavor !== "azure") {
14
- return undefined;
15
- }
16
- const project = new Project();
12
+ const project = new Project({ useInMemoryFileSystem: true });
17
13
  const { srcPath, rlcSourceDir } = model;
18
14
  const { packageDetails } = model.options;
19
15
  const filePath = joinPaths(
@@ -27,7 +27,7 @@ import {
27
27
  } from "./interfaces.js";
28
28
 
29
29
  export function buildParameterTypes(model: RLCModel) {
30
- const project = new Project();
30
+ const project = new Project({ useInMemoryFileSystem: true });
31
31
  const srcPath = model.srcPath;
32
32
  const filePath = joinPaths(srcPath, `parameters.ts`);
33
33
  const partialBodyTypeNames = new Set<string>();
@@ -19,7 +19,7 @@ import { ResponseHeaderSchema, ResponseMetadata, RLCModel } from "./interfaces.j
19
19
 
20
20
  let hasErrorResponse = false;
21
21
  export function buildResponseTypes(model: RLCModel) {
22
- const project = new Project();
22
+ const project = new Project({ useInMemoryFileSystem: true });
23
23
  const srcPath = model.srcPath;
24
24
  const filePath = joinPaths(srcPath, `responses.ts`);
25
25
  hasErrorResponse = false;
@@ -17,7 +17,7 @@ import { RLCModel, SchemaContext } from "./interfaces.js";
17
17
  */
18
18
  export function buildSchemaTypes(model: RLCModel) {
19
19
  const { srcPath } = model;
20
- const project = new Project();
20
+ const project = new Project({ useInMemoryFileSystem: true });
21
21
  let filePath = joinPaths(srcPath, `models.ts`);
22
22
  const inputModelFile = generateModelFiles(model, project, filePath, [SchemaContext.Input]);
23
23
  filePath = joinPaths(srcPath, `outputModels.ts`);
@@ -14,7 +14,7 @@ export function buildTopLevelIndex(model: RLCModel) {
14
14
  if (!model.options) {
15
15
  return undefined;
16
16
  }
17
- const project = new Project();
17
+ const project = new Project({ useInMemoryFileSystem: true });
18
18
  const { srcPath } = model;
19
19
  const { multiClient } = model.options;
20
20
  const batch = model.options.batch;
@@ -1,64 +1,52 @@
1
1
  import { SourceFile } from "ts-morph";
2
- import { ImportType, Imports, PackageFlavor } from "../interfaces.js";
2
+ import { ImportType, Imports } from "../interfaces.js";
3
3
 
4
4
  /**
5
- * Build the common imports for generated SDK
6
- * @param flavor flavor of SDK to generate, if any. When set to "azure", Azure Core packages will be used. When unset, the generic `ts-http-runtime` package will be used.
5
+ * Build the common imports for generated SDK. Azure Core packages are always used.
7
6
  * @returns
8
7
  */
9
- export function buildRuntimeImports(flavor?: PackageFlavor): Imports {
10
- if (flavor === "azure") {
11
- return {
12
- restClient: {
13
- type: "restClient",
14
- specifier: "@azure-rest/core-client",
15
- version: "^2.0.0",
16
- },
17
- coreAuth: {
18
- type: "coreAuth",
19
- specifier: "@azure/core-auth",
20
- version: "^1.6.0",
21
- },
22
- restPipeline: {
23
- type: "restPipeline",
24
- specifier: "@azure/core-rest-pipeline",
25
- version: "^1.14.0",
26
- },
27
- coreUtil: {
28
- type: "coreUtil",
29
- specifier: "@azure/core-util",
30
- version: "^1.4.0",
31
- },
32
- coreLogger: {
33
- type: "coreLogger",
34
- specifier: "@azure/logger",
35
- version: "^1.0.4",
36
- },
37
- azureEslintPlugin: {
38
- type: "azureEslintPlugin",
39
- specifier: "@azure/eslint-plugin-azure-sdk",
40
- version: "^3.0.0",
41
- },
42
- azureTestRecorder: {
43
- type: "azureTestRecorder",
44
- specifier: "@azure-tools/test-recorder",
45
- version: "^3.0.0",
46
- },
47
- azureCoreLro: {
48
- type: "azureCoreLro",
49
- specifier: "@azure/core-lro",
50
- },
51
- } as Imports;
52
- } else {
53
- // In non-azure branded scope we only have one dependency that is ts-http-runtime
54
- return {
55
- commonFallback: {
56
- type: "commonFallback",
57
- specifier: "@typespec/ts-http-runtime",
58
- version: "0.1.0",
59
- },
60
- } as Imports;
61
- }
8
+ export function buildRuntimeImports(): Imports {
9
+ return {
10
+ restClient: {
11
+ type: "restClient",
12
+ specifier: "@azure-rest/core-client",
13
+ version: "^2.0.0",
14
+ },
15
+ coreAuth: {
16
+ type: "coreAuth",
17
+ specifier: "@azure/core-auth",
18
+ version: "^1.6.0",
19
+ },
20
+ restPipeline: {
21
+ type: "restPipeline",
22
+ specifier: "@azure/core-rest-pipeline",
23
+ version: "^1.14.0",
24
+ },
25
+ coreUtil: {
26
+ type: "coreUtil",
27
+ specifier: "@azure/core-util",
28
+ version: "^1.4.0",
29
+ },
30
+ coreLogger: {
31
+ type: "coreLogger",
32
+ specifier: "@azure/logger",
33
+ version: "^1.0.4",
34
+ },
35
+ azureEslintPlugin: {
36
+ type: "azureEslintPlugin",
37
+ specifier: "@azure/eslint-plugin-azure-sdk",
38
+ version: "^3.0.0",
39
+ },
40
+ azureTestRecorder: {
41
+ type: "azureTestRecorder",
42
+ specifier: "@azure-tools/test-recorder",
43
+ version: "^3.0.0",
44
+ },
45
+ azureCoreLro: {
46
+ type: "azureCoreLro",
47
+ specifier: "@azure/core-lro",
48
+ },
49
+ } as Imports;
62
50
  }
63
51
 
64
52
  /**
@@ -1,13 +1,9 @@
1
- import { RLCModel, RLCOptions } from "../interfaces.js";
2
-
3
- export function isAzurePackage(model: { options?: RLCOptions }): boolean {
4
- return Boolean(model.options?.flavor === "azure");
5
- }
1
+ import { RLCModel } from "../interfaces.js";
6
2
 
7
3
  export function isAzureMonorepoPackage(model: RLCModel): boolean {
8
- return Boolean(model.options?.azureSdkForJs) && isAzurePackage(model);
4
+ return Boolean(model.options?.azureSdkForJs);
9
5
  }
10
6
 
11
7
  export function isAzureStandalonePackage(model: RLCModel): boolean {
12
- return isAzurePackage(model) && !model.options?.azureSdkForJs;
8
+ return !model.options?.azureSdkForJs;
13
9
  }
@@ -39,7 +39,6 @@ export type ImportType =
39
39
  | "coreUtil"
40
40
  | "coreLogger"
41
41
  // this is a fallback import if above imports are not available
42
- // mainly used in non-branded scope
43
42
  | "commonFallback"
44
43
  /**azure specific imports */
45
44
  | "azureEslintPlugin"
@@ -191,11 +190,6 @@ export interface OperationLroDetail {
191
190
  precedence?: number;
192
191
  }
193
192
 
194
- /**
195
- * Flavor of the package to generate. If "azure", an Azure-branded package should be generated. If left undefined, a package without Azure branding will be generated.
196
- */
197
- export type PackageFlavor = "azure" | undefined;
198
-
199
193
  export interface RLCOptions {
200
194
  /**
201
195
  * Whether to include response headers in the generated response types. If true, the generated response types will include headers as properties.
@@ -242,7 +236,6 @@ export interface RLCOptions {
242
236
  isModularLibrary?: boolean;
243
237
  moduleKind?: "esm" | "cjs";
244
238
  enableOperationGroup?: boolean;
245
- flavor?: PackageFlavor;
246
239
  enableModelNamespace?: boolean;
247
240
  hierarchyClient?: boolean;
248
241
  compatibilityMode?: boolean;
@@ -259,7 +252,7 @@ export interface RLCOptions {
259
252
  /**
260
253
  * When set to true, non-model return types (arrays, scalars, enums, bytes with binary content type)
261
254
  * will be wrapped in an XxxResponse type to maintain backward compatibility with HLC.
262
- * This option defaults to true for Azure flavor and to false otherwise, unless explicitly set.
255
+ * This option defaults to true unless explicitly set.
263
256
  */
264
257
  wrapNonModelReturn?: boolean;
265
258
  /**
@@ -6,7 +6,7 @@ import { RLCModel } from "../interfaces.js";
6
6
 
7
7
  export function buildApiExtractorConfig(model: RLCModel) {
8
8
  const { packageDetails, isModularLibrary, generateTest, azureSdkForJs } = model.options || {};
9
- const project = new Project();
9
+ const project = new Project({ useInMemoryFileSystem: true });
10
10
 
11
11
  let mainEntryPointFilePath = "dist/esm/index.d.ts";
12
12
 
@@ -62,10 +62,7 @@ export default [
62
62
  `;
63
63
 
64
64
  export function buildEsLintConfig(model: RLCModel) {
65
- if (model.options?.flavor !== "azure") {
66
- return;
67
- }
68
- const project = new Project();
65
+ const project = new Project({ useInMemoryFileSystem: true });
69
66
  const filePath = "eslint.config.mjs";
70
67
 
71
68
  let template: string;
@@ -4,16 +4,11 @@
4
4
  import { Project, SourceFile } from "ts-morph";
5
5
  import { NameType, normalizeName } from "../helpers/name-utils.js";
6
6
  import { hasPollingOperations } from "../helpers/operation-helpers.js";
7
- import {
8
- isAzureMonorepoPackage,
9
- isAzurePackage,
10
- isAzureStandalonePackage,
11
- } from "../helpers/package-util.js";
7
+ import { isAzureMonorepoPackage } from "../helpers/package-util.js";
12
8
  import { getRelativePartFromSrcPath } from "../helpers/path-utils.js";
13
9
  import { RLCModel } from "../interfaces.js";
14
10
  import { buildAzureMonorepoPackage } from "./package-json/build-azure-monorepo-package.js";
15
11
  import { buildAzureStandalonePackage } from "./package-json/build-azure-standalone-package.js";
16
- import { buildFlavorlessPackage } from "./package-json/build-flavorless-package.js";
17
12
  import {
18
13
  PackageCommonInfoConfig,
19
14
  getTshyConfig,
@@ -46,8 +41,6 @@ export function buildPackageFile(
46
41
  generateReactNativeTarget: model.options?.generateReactNativeTarget,
47
42
  };
48
43
 
49
- let packageInfo: Record<string, any> = buildFlavorlessPackage(config);
50
-
51
44
  const extendedConfig = {
52
45
  ...config,
53
46
  clientFilePaths: [getClientFilePath(model)],
@@ -58,15 +51,11 @@ export function buildPackageFile(
58
51
  clientContextPaths,
59
52
  };
60
53
 
61
- if (isAzureMonorepoPackage(model)) {
62
- packageInfo = buildAzureMonorepoPackage(extendedConfig);
63
- }
64
-
65
- if (isAzureStandalonePackage(model)) {
66
- packageInfo = buildAzureStandalonePackage(extendedConfig);
67
- }
54
+ const packageInfo: Record<string, any> = isAzureMonorepoPackage(model)
55
+ ? buildAzureMonorepoPackage(extendedConfig)
56
+ : buildAzureStandalonePackage(extendedConfig);
68
57
 
69
- const project = new Project();
58
+ const project = new Project({ useInMemoryFileSystem: true });
70
59
  const filePath = "package.json";
71
60
 
72
61
  if (!packageInfo) {
@@ -97,8 +86,7 @@ export function updatePackageFile(
97
86
  { exports, clientContextPaths }: PackageFileOptions = {},
98
87
  ) {
99
88
  const hasLro = hasPollingOperations(model);
100
- const isAzure = isAzurePackage(model);
101
- const needsLroUpdate = isAzure && hasLro;
89
+ const needsLroUpdate = hasLro;
102
90
  const needsExportsUpdate = exports;
103
91
  const needsConstantPathsUpdate = clientContextPaths && clientContextPaths.length > 0;
104
92
  const needsPlatformImportsUpdate =
@@ -200,7 +188,7 @@ export function updatePackageFile(
200
188
  }
201
189
 
202
190
  // Update constantPaths metadata for Azure packages
203
- if (needsConstantPathsUpdate && isAzure && packageInfo["//metadata"]) {
191
+ if (needsConstantPathsUpdate && packageInfo["//metadata"]) {
204
192
  const metadata = packageInfo["//metadata"];
205
193
  // Filter out existing userAgentInfo entries
206
194
  const nonUserAgentPaths = (metadata.constantPaths || []).filter(