@azure-tools/typespec-ts 0.23.0 → 0.25.0-alpha.20240311.1

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 (74) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/src/index.d.ts.map +1 -1
  3. package/dist/src/index.js +10 -10
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/lib.d.ts +5 -2
  6. package/dist/src/lib.d.ts.map +1 -1
  7. package/dist/src/lib.js +2 -1
  8. package/dist/src/lib.js.map +1 -1
  9. package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
  10. package/dist/src/modular/buildCodeModel.js +86 -45
  11. package/dist/src/modular/buildCodeModel.js.map +1 -1
  12. package/dist/src/modular/buildProjectFiles.js +11 -12
  13. package/dist/src/modular/buildProjectFiles.js.map +1 -1
  14. package/dist/src/modular/emitModels.d.ts.map +1 -1
  15. package/dist/src/modular/emitModels.js +3 -6
  16. package/dist/src/modular/emitModels.js.map +1 -1
  17. package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +1 -1
  18. package/dist/src/modular/helpers/classicalOperationHelpers.js +8 -2
  19. package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
  20. package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
  21. package/dist/src/modular/helpers/operationHelpers.js +22 -5
  22. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  23. package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
  24. package/dist/src/modular/helpers/typeHelpers.js +11 -5
  25. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  26. package/dist/src/transform/transform.d.ts.map +1 -1
  27. package/dist/src/transform/transform.js +2 -2
  28. package/dist/src/transform/transform.js.map +1 -1
  29. package/dist/src/transform/transformApiVersionInfo.js +2 -2
  30. package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
  31. package/dist/src/transform/transformHelperFunctionDetails.d.ts +2 -2
  32. package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
  33. package/dist/src/transform/transformHelperFunctionDetails.js +3 -3
  34. package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
  35. package/dist/src/transform/transformParameters.js +1 -1
  36. package/dist/src/transform/transformParameters.js.map +1 -1
  37. package/dist/src/transform/transformPaths.js +5 -5
  38. package/dist/src/transform/transformPaths.js.map +1 -1
  39. package/dist/src/transform/transformResponses.js +2 -2
  40. package/dist/src/transform/transformResponses.js.map +1 -1
  41. package/dist/src/transform/transfromRLCOptions.d.ts +3 -2
  42. package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
  43. package/dist/src/transform/transfromRLCOptions.js +30 -10
  44. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  45. package/dist/src/utils/emitUtil.js +9 -9
  46. package/dist/src/utils/emitUtil.js.map +1 -1
  47. package/dist/src/utils/modelUtils.d.ts +2 -6
  48. package/dist/src/utils/modelUtils.d.ts.map +1 -1
  49. package/dist/src/utils/modelUtils.js +54 -39
  50. package/dist/src/utils/modelUtils.js.map +1 -1
  51. package/dist/src/utils/operationUtil.d.ts +2 -2
  52. package/dist/src/utils/operationUtil.d.ts.map +1 -1
  53. package/dist/src/utils/operationUtil.js +10 -10
  54. package/dist/src/utils/operationUtil.js.map +1 -1
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +17 -17
  57. package/src/index.ts +6 -5
  58. package/src/lib.ts +7 -2
  59. package/src/modular/buildCodeModel.ts +89 -48
  60. package/src/modular/buildProjectFiles.ts +13 -13
  61. package/src/modular/emitModels.ts +3 -6
  62. package/src/modular/helpers/classicalOperationHelpers.ts +9 -2
  63. package/src/modular/helpers/operationHelpers.ts +28 -9
  64. package/src/modular/helpers/typeHelpers.ts +12 -6
  65. package/src/transform/transform.ts +6 -2
  66. package/src/transform/transformApiVersionInfo.ts +2 -2
  67. package/src/transform/transformHelperFunctionDetails.ts +4 -4
  68. package/src/transform/transformParameters.ts +1 -1
  69. package/src/transform/transformPaths.ts +5 -5
  70. package/src/transform/transformResponses.ts +2 -2
  71. package/src/transform/transfromRLCOptions.ts +49 -22
  72. package/src/utils/emitUtil.ts +7 -7
  73. package/src/utils/modelUtils.ts +51 -44
  74. package/src/utils/operationUtil.ts +11 -9
@@ -224,14 +224,14 @@ function getOperationSignatureParameters(
224
224
  });
225
225
 
226
226
  if (operation.bodyParameter) {
227
- parameters.set(
228
- operation.bodyParameter?.clientName,
229
- buildType(
227
+ parameters.set(operation.bodyParameter?.clientName, {
228
+ hasQuestionToken: operation.bodyParameter.optional,
229
+ ...buildType(
230
230
  operation.bodyParameter.clientName,
231
231
  operation.bodyParameter.type,
232
232
  operation.bodyParameter.type.format
233
233
  )
234
- );
234
+ });
235
235
  }
236
236
  // Add context as the first parameter
237
237
  const contextParam = { name: "context", type: clientType };
@@ -340,7 +340,10 @@ export function getOperationOptionsName(
340
340
  ? getClassicalLayerPrefix(operation, NameType.Interface)
341
341
  : "";
342
342
  const optionName = `${prefix}${toPascalCase(operation.name)}Options`;
343
- if (operation.bodyParameter?.type.name === optionName) {
343
+ if (
344
+ operation.bodyParameter?.type.name === optionName ||
345
+ optionName === "ClientOptions"
346
+ ) {
344
347
  return optionName.replace(/Options$/, "RequestOptions");
345
348
  }
346
349
  return optionName;
@@ -462,7 +465,10 @@ function buildBodyParameter(
462
465
  );
463
466
 
464
467
  if (bodyParameter && bodyParts.length > 0) {
465
- return `\nbody: {${bodyParts.join(",\n")}},`;
468
+ const optionalBody = bodyParameter.optional
469
+ ? `${bodyParameter.clientName} === undefined ? ${bodyParameter.clientName} : `
470
+ : "";
471
+ return `\nbody: ${optionalBody}{${bodyParts.join(",\n")}},`;
466
472
  } else if (bodyParameter && bodyParts.length === 0) {
467
473
  return `\nbody: ${bodyParameter.clientName},`;
468
474
  }
@@ -512,7 +518,7 @@ function buildBodyParameter(
512
518
  if (bodyParameter) {
513
519
  return `\nbody: ${bodyParameter.clientName},`;
514
520
  }
515
-
521
+
516
522
  return "";
517
523
  }
518
524
 
@@ -963,6 +969,12 @@ export function deserializeResponseValue(
963
969
  typeStack: Type[] = [],
964
970
  format?: string
965
971
  ): string {
972
+ const requiredPrefix = required === false ? `${restValue} === undefined` : "";
973
+ const nullablePrefix = type.nullable ? `${restValue} === null` : "";
974
+ const requiredOrNullablePrefix =
975
+ requiredPrefix !== "" && nullablePrefix !== ""
976
+ ? `(${requiredPrefix} || ${nullablePrefix})`
977
+ : `${requiredPrefix}${nullablePrefix}`;
966
978
  switch (type.type) {
967
979
  case "datetime":
968
980
  return required
@@ -974,7 +986,7 @@ export function deserializeResponseValue(
974
986
  const prefix =
975
987
  required && !type.nullable
976
988
  ? `${restValue}`
977
- : `!${restValue} ? ${restValue} : ${restValue}`;
989
+ : `${requiredOrNullablePrefix} ? ${restValue} : ${restValue}`;
978
990
  if (type.elementType?.type === "model") {
979
991
  if (!type.elementType.aliasType) {
980
992
  return `${prefix}.map(p => ({${getResponseMapping(
@@ -1049,6 +1061,13 @@ export function serializeRequestValue(
1049
1061
  typeStack: Type[] = [],
1050
1062
  format?: string
1051
1063
  ): string {
1064
+ const requiredPrefix =
1065
+ required === false ? `${clientValue} === undefined` : "";
1066
+ const nullablePrefix = type.nullable ? `${clientValue} === null` : "";
1067
+ const requiredOrNullablePrefix =
1068
+ requiredPrefix !== "" && nullablePrefix !== ""
1069
+ ? `(${requiredPrefix} || ${nullablePrefix})`
1070
+ : `${requiredPrefix}${nullablePrefix}`;
1052
1071
  switch (type.type) {
1053
1072
  case "datetime":
1054
1073
  switch (type.format ?? format) {
@@ -1069,7 +1088,7 @@ export function serializeRequestValue(
1069
1088
  const prefix =
1070
1089
  required && !type.nullable
1071
1090
  ? `${clientValue}`
1072
- : `!${clientValue} ? ${clientValue} : ${clientValue}`;
1091
+ : `${requiredOrNullablePrefix}? ${clientValue}: ${clientValue}`;
1073
1092
  if (type.elementType?.type === "model" && !type.elementType.aliasType) {
1074
1093
  return `${prefix}.map(p => ({${getRequestModelMapping(
1075
1094
  type.elementType,
@@ -128,12 +128,18 @@ function handleConstantType(type: Type): TypeMetadata {
128
128
  * Handles the conversion of enum types to TypeScript representation metadata.
129
129
  */
130
130
  function handleEnumType(type: Type): TypeMetadata {
131
- if (
132
- !type.name &&
133
- (!type?.valueType?.type ||
134
- !["string", "number"].includes(type?.valueType?.type))
135
- ) {
136
- throw new Error("Unable to process enum without name");
131
+ if (!type.name) {
132
+ const valueType = !type.isFixed
133
+ ? ((type.values?.[0] as Type).valueType?.type ?? "string") + " | "
134
+ : "";
135
+ return {
136
+ name: `${valueType}${type.values
137
+ ?.map((e) => {
138
+ return getType(e as Type).name;
139
+ })
140
+ .join(" | ")}`,
141
+ nullable: type.nullable
142
+ };
137
143
  }
138
144
  const name = handleNullableTypeName({
139
145
  name: type.name,
@@ -72,7 +72,11 @@ export async function transformRLCModel(
72
72
  client,
73
73
  dpgContext
74
74
  );
75
- const helperDetails = transformHelperFunctionDetails(client, dpgContext);
75
+ const helperDetails = transformHelperFunctionDetails(
76
+ client,
77
+ dpgContext,
78
+ options.flavor
79
+ );
76
80
  // Enrich client-level annotation detail
77
81
  helperDetails.clientLroOverload = getClientLroOverload(paths);
78
82
  const urlInfo = transformUrlInfo(dpgContext);
@@ -92,7 +96,7 @@ export async function transformRLCModel(
92
96
  telemetryOptions,
93
97
  importInfo: {
94
98
  internalImports: importSet,
95
- runtimeImports: buildRuntimeImports(options.branded)
99
+ runtimeImports: buildRuntimeImports(options.flavor)
96
100
  }
97
101
  };
98
102
  model.sampleGroups = transformSampleGroups(
@@ -15,7 +15,7 @@ import {
15
15
  } from "@azure-tools/rlc-common";
16
16
  import { getHttpOperation } from "@typespec/http";
17
17
  import {
18
- getEnrichedDefaultApiVersion,
18
+ getDefaultApiVersionString,
19
19
  getSchemaForType,
20
20
  trimUsage
21
21
  } from "../utils/modelUtils.js";
@@ -37,7 +37,7 @@ export function transformApiVersionInfo(
37
37
  pathVersionDetail?.isCrossedVersion || queryVersionDetail?.isCrossedVersion;
38
38
  const defaultValue =
39
39
  (pathVersionDetail || queryVersionDetail) && !isCrossedVersion
40
- ? getEnrichedDefaultApiVersion(program, dpgContext) ??
40
+ ? getDefaultApiVersionString(program, dpgContext) ??
41
41
  pathVersionDetail?.defaultValue ??
42
42
  queryVersionDetail?.defaultValue
43
43
  : undefined;
@@ -3,7 +3,7 @@ import {
3
3
  listOperationGroups,
4
4
  listOperationsInOperationGroup
5
5
  } from "@azure-tools/typespec-client-generator-core";
6
- import { HelperFunctionDetails } from "@azure-tools/rlc-common";
6
+ import { HelperFunctionDetails, PackageFlavor } from "@azure-tools/rlc-common";
7
7
  import { ignoreDiagnostics, Model, Program, Type } from "@typespec/compiler";
8
8
  import { getHttpOperation, HttpOperation } from "@typespec/http";
9
9
  import {
@@ -19,7 +19,7 @@ import { SdkContext } from "../utils/interfaces.js";
19
19
  export function transformHelperFunctionDetails(
20
20
  client: SdkClient,
21
21
  dpgContext: SdkContext,
22
- isBranded: boolean = true
22
+ flavor?: PackageFlavor
23
23
  ): HelperFunctionDetails {
24
24
  const program = dpgContext.program;
25
25
  const serializeInfo = extractSpecialSerializeInfo(
@@ -27,8 +27,8 @@ export function transformHelperFunctionDetails(
27
27
  client,
28
28
  dpgContext
29
29
  );
30
- // Disbale paging and long running for non-branded clients.
31
- if (!isBranded) {
30
+ // Disbale paging and long running for non-Azure clients.
31
+ if (flavor !== "azure") {
32
32
  return {
33
33
  hasLongRunning: false,
34
34
  hasPaging: false,
@@ -90,7 +90,7 @@ export function transformToParameterTypes(
90
90
  const parameters = route.parameters;
91
91
  const rlcParameter: OperationParameter = {
92
92
  operationGroup: getOperationGroupName(dpgContext, route),
93
- operationName: getOperationName(program, route.operation),
93
+ operationName: getOperationName(dpgContext, route.operation),
94
94
  parameters: []
95
95
  };
96
96
  // transform query param
@@ -78,7 +78,7 @@ function transformOperation(
78
78
  for (const resp of sortedOperationResponses(route.responses)) {
79
79
  const respName = getResponseTypeName(
80
80
  operationGroupName,
81
- getOperationName(program, route.operation),
81
+ getOperationName(dpgContext, route.operation),
82
82
  getOperationStatuscode(resp)
83
83
  );
84
84
  respNames.push(respName);
@@ -89,15 +89,15 @@ function transformOperation(
89
89
  hasOptionalOptions: !hasRequiredOptions(dpgContext, route.parameters),
90
90
  optionsName: getParameterTypeName(
91
91
  operationGroupName,
92
- getOperationName(program, route.operation)
92
+ getOperationName(dpgContext, route.operation)
93
93
  ),
94
94
  responseTypes,
95
95
  returnType: respNames.join(" | "),
96
96
  successStatus: getOperationSuccessStatus(route),
97
- operationName: getOperationName(program, route.operation),
97
+ operationName: getOperationName(dpgContext, route.operation),
98
98
  operationHelperDetail: {
99
99
  lroDetails: extractOperationLroDetail(
100
- program,
100
+ dpgContext,
101
101
  route,
102
102
  responseTypes,
103
103
  operationGroupName
@@ -116,7 +116,7 @@ function transformOperation(
116
116
  paths[route.path] = {
117
117
  description: getDoc(program, route.operation) ?? "",
118
118
  name: escapeCoreName(
119
- getOperationName(program, route.operation) || "Client"
119
+ getOperationName(dpgContext, route.operation) || "Client"
120
120
  ),
121
121
  pathParameters: route.parameters.parameters
122
122
  .filter((p) => p.type === "path")
@@ -75,7 +75,7 @@ export function transformToResponseTypes(
75
75
  function transformToResponseTypesForRoute(route: HttpOperation) {
76
76
  const rlcOperationUnit: OperationResponse = {
77
77
  operationGroup: getOperationGroupName(dpgContext, route),
78
- operationName: getOperationName(program, route.operation),
78
+ operationName: getOperationName(dpgContext, route.operation),
79
79
  path: route.path,
80
80
  responses: []
81
81
  };
@@ -237,7 +237,7 @@ function transformLroLogicalResponse(
237
237
  description: `The final response for long-running ${route.operation.name} operation`,
238
238
  predefinedName: getLroLogicalResponseName(
239
239
  operationGroupName,
240
- getOperationName(dpgContext.program, route.operation)
240
+ getOperationName(dpgContext, route.operation)
241
241
  ),
242
242
  body: successResp?.body
243
243
  };
@@ -2,6 +2,7 @@ import {
2
2
  NameType,
3
3
  normalizeName,
4
4
  PackageDetails,
5
+ PackageFlavor,
5
6
  RLCOptions,
6
7
  ServiceInfo
7
8
  } from "@azure-tools/rlc-common";
@@ -12,7 +13,7 @@ import {
12
13
  Program
13
14
  } from "@typespec/compiler";
14
15
  import { getAuthentication, getHttpOperation } from "@typespec/http";
15
- import { reportDiagnostic } from "../lib.js";
16
+ import { EmitterOptions, reportDiagnostic } from "../lib.js";
16
17
  import { getDefaultService } from "../utils/modelUtils.js";
17
18
  import { getRLCClients } from "../utils/clientUtils.js";
18
19
  import { SdkContext } from "../utils/interfaces.js";
@@ -24,7 +25,7 @@ import { getOperationName } from "../utils/operationUtil.js";
24
25
  import { detectModelConflicts } from "../utils/namespaceUtils.js";
25
26
 
26
27
  export function transformRLCOptions(
27
- emitterOptions: RLCOptions,
28
+ emitterOptions: EmitterOptions,
28
29
  dpgContext: SdkContext
29
30
  ): RLCOptions {
30
31
  // Extract the options from emitter option
@@ -40,20 +41,20 @@ export function transformRLCOptions(
40
41
 
41
42
  function extractRLCOptions(
42
43
  dpgContext: SdkContext,
43
- emitterOptions: RLCOptions,
44
+ emitterOptions: EmitterOptions,
44
45
  generationRootDir: string
45
46
  ): RLCOptions {
46
47
  const program = dpgContext.program;
47
48
  const includeShortcuts = getIncludeShortcuts(emitterOptions);
48
- const branded = getBranded(emitterOptions);
49
49
  const packageDetails = getPackageDetails(program, emitterOptions);
50
+ const flavor = getFlavor(emitterOptions, packageDetails);
50
51
  const serviceInfo = getServiceInfo(program);
51
52
  const azureSdkForJs = getAzureSdkForJs(emitterOptions);
52
53
  const generateMetadata: undefined | boolean =
53
54
  getGenerateMetadata(emitterOptions);
54
55
  const generateTest: undefined | boolean = getGenerateTest(
55
56
  emitterOptions,
56
- branded
57
+ flavor
57
58
  );
58
59
  const generateSample: undefined | boolean = getGenerateSample(emitterOptions);
59
60
  const credentialInfo = getCredentialInfo(program, emitterOptions);
@@ -70,7 +71,7 @@ function extractRLCOptions(
70
71
  return {
71
72
  ...emitterOptions,
72
73
  ...credentialInfo,
73
- branded,
74
+ flavor,
74
75
  includeShortcuts,
75
76
  packageDetails,
76
77
  generateMetadata,
@@ -143,7 +144,7 @@ function processAuth(program: Program) {
143
144
 
144
145
  function getEnableOperationGroup(
145
146
  dpgContext: SdkContext,
146
- emitterOptions: RLCOptions
147
+ emitterOptions: EmitterOptions
147
148
  ) {
148
149
  if (
149
150
  emitterOptions.enableOperationGroup === true ||
@@ -157,7 +158,7 @@ function getEnableOperationGroup(
157
158
 
158
159
  function getEnableModelNamespace(
159
160
  dpgContext: SdkContext,
160
- emitterOptions: RLCOptions
161
+ emitterOptions: EmitterOptions
161
162
  ) {
162
163
  if (
163
164
  emitterOptions.enableModelNamespace === true ||
@@ -169,7 +170,7 @@ function getEnableModelNamespace(
169
170
  return detectModelConflicts(dpgContext);
170
171
  }
171
172
 
172
- function getHierarchyClient(emitterOptions: RLCOptions) {
173
+ function getHierarchyClient(emitterOptions: EmitterOptions) {
173
174
  if (
174
175
  emitterOptions.hierarchyClient === true ||
175
176
  emitterOptions.hierarchyClient === false
@@ -189,7 +190,7 @@ function detectIfNameConflicts(dpgContext: SdkContext) {
189
190
  const clientOperations = listOperationsInOperationGroup(dpgContext, client);
190
191
  for (const clientOp of clientOperations) {
191
192
  const route = ignoreDiagnostics(getHttpOperation(program, clientOp));
192
- const name = getOperationName(program, route.operation);
193
+ const name = getOperationName(dpgContext, route.operation);
193
194
  if (nameSet.has(name)) {
194
195
  return true;
195
196
  } else {
@@ -204,7 +205,7 @@ function detectIfNameConflicts(dpgContext: SdkContext) {
204
205
  );
205
206
  for (const op of operations) {
206
207
  const route = ignoreDiagnostics(getHttpOperation(program, op));
207
- const name = getOperationName(program, route.operation);
208
+ const name = getOperationName(dpgContext, route.operation);
208
209
  if (nameSet.has(name)) {
209
210
  return true;
210
211
  } else {
@@ -218,17 +219,43 @@ function detectIfNameConflicts(dpgContext: SdkContext) {
218
219
  return false;
219
220
  }
220
221
 
221
- function getIncludeShortcuts(emitterOptions: RLCOptions) {
222
+ function getIncludeShortcuts(emitterOptions: EmitterOptions) {
222
223
  return Boolean(emitterOptions.includeShortcuts);
223
224
  }
224
225
 
225
- function getBranded(emitterOptions: RLCOptions) {
226
- return emitterOptions.branded !== undefined ? emitterOptions.branded : true;
226
+ function getFlavor(
227
+ emitterOptions: EmitterOptions,
228
+ packageDetails?: PackageDetails
229
+ ): PackageFlavor {
230
+ const flavor = emitterOptions.flavor;
231
+
232
+ if (flavor !== undefined) {
233
+ if (flavor.toLowerCase() === "azure") {
234
+ return "azure";
235
+ } else {
236
+ return undefined;
237
+ }
238
+ }
239
+
240
+ const branded = emitterOptions.branded;
241
+ if (branded !== undefined) {
242
+ return branded ? "azure" : undefined;
243
+ }
244
+
245
+ const scopeName = packageDetails?.scopeName;
246
+ if (
247
+ scopeName !== undefined &&
248
+ (scopeName.startsWith("azure") || scopeName.startsWith("msinternal"))
249
+ ) {
250
+ return "azure";
251
+ } else {
252
+ return undefined;
253
+ }
227
254
  }
228
255
 
229
256
  function getPackageDetails(
230
257
  program: Program,
231
- emitterOptions: RLCOptions
258
+ emitterOptions: EmitterOptions
232
259
  ): PackageDetails {
233
260
  const packageDetails: PackageDetails = {
234
261
  ...emitterOptions.packageDetails,
@@ -264,14 +291,14 @@ function getServiceInfo(program: Program): ServiceInfo {
264
291
  };
265
292
  }
266
293
 
267
- function getAzureSdkForJs(emitterOptions: RLCOptions) {
294
+ function getAzureSdkForJs(emitterOptions: EmitterOptions) {
268
295
  return emitterOptions.azureSdkForJs === undefined ||
269
296
  emitterOptions.azureSdkForJs === null
270
297
  ? true
271
298
  : Boolean(emitterOptions.azureSdkForJs);
272
299
  }
273
300
 
274
- function getGenerateMetadata(emitterOptions: RLCOptions) {
301
+ function getGenerateMetadata(emitterOptions: EmitterOptions) {
275
302
  if (
276
303
  emitterOptions.generateMetadata === undefined ||
277
304
  emitterOptions.generateMetadata === null
@@ -286,15 +313,15 @@ function getGenerateMetadata(emitterOptions: RLCOptions) {
286
313
  * @param emitterOptions
287
314
  * @returns
288
315
  */
289
- function getGenerateTest(emitterOptions: RLCOptions, branded: boolean) {
316
+ function getGenerateTest(emitterOptions: EmitterOptions, flavor?: "azure") {
290
317
  if (
291
- !branded &&
318
+ flavor !== "azure" &&
292
319
  (emitterOptions.generateTest === undefined ||
293
320
  emitterOptions.generateTest === null)
294
321
  ) {
295
322
  return undefined;
296
323
  } else if (
297
- branded &&
324
+ flavor === "azure" &&
298
325
  (emitterOptions.generateTest === undefined ||
299
326
  emitterOptions.generateTest === null)
300
327
  ) {
@@ -308,7 +335,7 @@ function getGenerateTest(emitterOptions: RLCOptions, branded: boolean) {
308
335
  * @param emitterOptions
309
336
  * @returns
310
337
  */
311
- function getGenerateSample(emitterOptions: RLCOptions) {
338
+ function getGenerateSample(emitterOptions: EmitterOptions) {
312
339
  if (
313
340
  emitterOptions.generateSample === undefined ||
314
341
  emitterOptions.generateSample === null
@@ -320,7 +347,7 @@ function getGenerateSample(emitterOptions: RLCOptions) {
320
347
 
321
348
  export function getCredentialInfo(
322
349
  program: Program,
323
- emitterOptions: RLCOptions
350
+ emitterOptions: EmitterOptions
324
351
  ) {
325
352
  const securityInfo = processAuth(program);
326
353
  const addCredentials =
@@ -8,14 +8,14 @@ import { prettierJSONOptions, prettierTypeScriptOptions } from "../lib.js";
8
8
 
9
9
  export async function emitModels(rlcModels: RLCModel, program: Program) {
10
10
  const schemaOutput = buildSchemaTypes(rlcModels);
11
- const isBranded = rlcModels?.options?.branded ?? true;
11
+ const isAzureFlavor = rlcModels?.options?.flavor === "azure";
12
12
  if (schemaOutput) {
13
13
  const { inputModelFile, outputModelFile } = schemaOutput;
14
14
  if (inputModelFile) {
15
- await emitFile(inputModelFile, program, isBranded);
15
+ await emitFile(inputModelFile, program, isAzureFlavor);
16
16
  }
17
17
  if (outputModelFile) {
18
- await emitFile(outputModelFile, program, isBranded);
18
+ await emitFile(outputModelFile, program, isAzureFlavor);
19
19
  }
20
20
  }
21
21
  }
@@ -29,7 +29,7 @@ export async function emitContentByBuilder(
29
29
  if (!Array.isArray(builderFnOrList)) {
30
30
  builderFnOrList = [builderFnOrList];
31
31
  }
32
- const isBranded = rlcModels?.options?.branded ?? true;
32
+ const isAzureFlavor = rlcModels?.options?.flavor === "azure";
33
33
  for (const builderFn of builderFnOrList) {
34
34
  let contentFiles: File[] | File | undefined = builderFn(rlcModels);
35
35
  if (!contentFiles) {
@@ -39,7 +39,7 @@ export async function emitContentByBuilder(
39
39
  contentFiles = [contentFiles];
40
40
  }
41
41
  for (const file of contentFiles) {
42
- await emitFile(file, program, isBranded, emitterOutputDir);
42
+ await emitFile(file, program, isAzureFlavor, emitterOutputDir);
43
43
  }
44
44
  }
45
45
  }
@@ -47,14 +47,14 @@ export async function emitContentByBuilder(
47
47
  async function emitFile(
48
48
  file: File,
49
49
  program: Program,
50
- isBranded: boolean,
50
+ isAzureFlavor: boolean,
51
51
  emitterOutputDir?: string
52
52
  ) {
53
53
  const host: CompilerHost = program.host;
54
54
  const filePath = join(emitterOutputDir ?? "", file.path);
55
55
  const isJson = /\.json$/gi.test(filePath);
56
56
  const isSourceCode = /\.(ts|js)$/gi.test(filePath);
57
- const microsoftHeader = isBranded
57
+ const microsoftHeader = isAzureFlavor
58
58
  ? `// Copyright (c) Microsoft Corporation.\n`
59
59
  : "";
60
60
  const licenseHeader = `${microsoftHeader}// Licensed under the MIT license.\n`;