@azure-tools/typespec-ts 0.40.0-alpha.20250512.1 → 0.40.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-ts",
3
- "version": "0.40.0-alpha.20250512.1",
3
+ "version": "0.40.0",
4
4
  "description": "An experimental TypeSpec emitter for TypeScript RLC",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "@azure-tools/typespec-autorest": "0.56.0",
26
26
  "@azure-tools/typespec-azure-core": "0.56.0",
27
27
  "@azure-tools/typespec-azure-resource-manager": "0.56.0",
28
- "@azure-tools/typespec-client-generator-core": "0.56.1",
28
+ "@azure-tools/typespec-client-generator-core": "0.56.0",
29
29
  "@azure/abort-controller": "^2.1.2",
30
30
  "@azure/core-auth": "^1.6.0",
31
31
  "@azure/core-lro": "^3.1.0",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@azure-tools/typespec-azure-core": "0.56.0",
71
- "@azure-tools/typespec-client-generator-core": "0.56.1",
71
+ "@azure-tools/typespec-client-generator-core": "0.56.0",
72
72
  "@typespec/compiler": "1.0.0",
73
73
  "@typespec/http": "1.0.0",
74
74
  "@typespec/rest": "0.70.0",
@@ -76,7 +76,7 @@
76
76
  "@typespec/xml": "0.70.0"
77
77
  },
78
78
  "dependencies": {
79
- "@azure-tools/rlc-common": "0.39.0-alpha.20250512.1",
79
+ "@azure-tools/rlc-common": "^0.39.0",
80
80
  "fs-extra": "^11.1.0",
81
81
  "lodash": "^4.17.21",
82
82
  "prettier": "^3.3.3",
package/src/index.ts CHANGED
@@ -166,7 +166,7 @@ export async function $onEmit(context: EmitContext) {
166
166
  console.timeEnd("onEmit: build RLC code models");
167
167
 
168
168
  // 4. Generate sources
169
- if (emitterOptions["is-modular-library"]) {
169
+ if (emitterOptions.isModularLibrary) {
170
170
  await generateModularSources();
171
171
  } else {
172
172
  await generateRLCSources();
@@ -180,8 +180,8 @@ export async function $onEmit(context: EmitContext) {
180
180
  await calculateGenerationDir();
181
181
  dpgContext.generationPathDetail = generationPathDetail;
182
182
  const options: RLCOptions = transformRLCOptions(emitterOptions, dpgContext);
183
- emitterOptions["is-modular-library"] = options.isModularLibrary;
184
- emitterOptions["generate-sample"] = options.generateSample;
183
+ emitterOptions.isModularLibrary = options.isModularLibrary;
184
+ emitterOptions.generateSample = options.generateSample;
185
185
  // clear output folder if needed
186
186
  if (options.clearOutputFolder) {
187
187
  await fsextra.emptyDir(context.emitterOutputDir);
@@ -345,7 +345,7 @@ export async function $onEmit(context: EmitContext) {
345
345
  }
346
346
  console.timeEnd("onEmit: emit source files");
347
347
  // Enable modular sample generation when explicitly set to true or MPG
348
- if (emitterOptions["generate-sample"] === true) {
348
+ if (emitterOptions.generateSample === true) {
349
349
  console.time("onEmit: emit samples");
350
350
  const samples = emitSamples(dpgContext);
351
351
  console.timeEnd("onEmit: emit samples");
package/src/lib.ts CHANGED
@@ -5,7 +5,8 @@ import {
5
5
  PackageDetails,
6
6
  DependencyInfo,
7
7
  ServiceInfo,
8
- PackageFlavor
8
+ PackageFlavor,
9
+ RLCOptions
9
10
  } from "@azure-tools/rlc-common";
10
11
  import {
11
12
  createTypeSpecLibrary,
@@ -14,7 +15,7 @@ import {
14
15
  } from "@typespec/compiler";
15
16
  import { Options } from "prettier";
16
17
 
17
- export interface EmitterOptions {
18
+ export interface EmitterOptions extends RLCOptions {
18
19
  "include-shortcuts"?: boolean;
19
20
  "multi-client"?: boolean;
20
21
  batch?: any[];
@@ -70,10 +71,105 @@ export interface EmitterOptions {
70
71
  "default-value-object"?: boolean;
71
72
  }
72
73
 
74
+ const _RLCOptionsSchema: JSONSchemaType<RLCOptions> = {
75
+ type: "object",
76
+ additionalProperties: true,
77
+ properties: {
78
+ includeShortcuts: { type: "boolean", nullable: true },
79
+ multiClient: { type: "boolean", nullable: true },
80
+ batch: {
81
+ type: "array",
82
+ nullable: true,
83
+ items: {
84
+ type: "string"
85
+ }
86
+ },
87
+ packageDetails: {
88
+ type: "object",
89
+ additionalProperties: true,
90
+ properties: {
91
+ name: { type: "string", nullable: false },
92
+ scopeName: { type: "string", nullable: true },
93
+ nameWithoutScope: { type: "string", nullable: true },
94
+ description: { type: "string", nullable: true },
95
+ version: { type: "string", nullable: true }
96
+ },
97
+ required: ["name"],
98
+ nullable: true
99
+ },
100
+ addCredentials: { type: "boolean", nullable: true },
101
+ credentialScopes: {
102
+ type: "array",
103
+ nullable: true,
104
+ items: { type: "string" }
105
+ },
106
+ credentialKeyHeaderName: { type: "string", nullable: true },
107
+ customHttpAuthHeaderName: { type: "string", nullable: true },
108
+ customHttpAuthSharedKeyPrefix: { type: "string", nullable: true },
109
+ generateMetadata: { type: "boolean", nullable: true },
110
+ generateTest: { type: "boolean", nullable: true },
111
+ generateSample: { type: "boolean", nullable: true },
112
+ azureSdkForJs: { type: "boolean", nullable: true },
113
+ azureOutputDirectory: { type: "string", nullable: true },
114
+ isTypeSpecTest: { type: "boolean", nullable: true },
115
+ title: { type: "string", nullable: true },
116
+ dependencyInfo: {
117
+ type: "object",
118
+ additionalProperties: true,
119
+ properties: {
120
+ link: { type: "string", nullable: false },
121
+ description: { type: "string", nullable: false }
122
+ },
123
+ required: [],
124
+ nullable: true
125
+ },
126
+ productDocLink: { type: "string", nullable: true },
127
+ serviceInfo: {
128
+ type: "object",
129
+ additionalProperties: true,
130
+ properties: {
131
+ title: { type: "string", nullable: true },
132
+ description: { type: "string", nullable: true }
133
+ },
134
+ nullable: true
135
+ },
136
+ azureArm: { type: "boolean", nullable: true },
137
+ sourceFrom: { type: "string", nullable: true },
138
+ isModularLibrary: { type: "boolean", nullable: true, default: false },
139
+ enableOperationGroup: { type: "boolean", nullable: true },
140
+ enableModelNamespace: { type: "boolean", nullable: true },
141
+ hierarchyClient: { type: "boolean", nullable: true },
142
+ branded: { type: "boolean", nullable: true },
143
+ flavor: { type: "string", nullable: true },
144
+ moduleKind: {
145
+ type: "string",
146
+ nullable: true,
147
+ enum: ["esm", "cjs"],
148
+ default: "esm"
149
+ },
150
+ compatibilityMode: { type: "boolean", nullable: true },
151
+ experimentalExtensibleEnums: { type: "boolean", nullable: true },
152
+ clearOutputFolder: { type: "boolean", nullable: true },
153
+ ignorePropertyNameNormalize: { type: "boolean", nullable: true },
154
+ ignoreEnumMemberNameNormalize: { type: "boolean", nullable: true },
155
+ compatibilityQueryMultiFormat: { type: "boolean", nullable: true },
156
+ typespecTitleMap: {
157
+ type: "object",
158
+ additionalProperties: {
159
+ type: "string"
160
+ },
161
+ required: [],
162
+ nullable: true
163
+ }
164
+ },
165
+ required: []
166
+ };
167
+
73
168
  export const RLCOptionsSchema: JSONSchemaType<EmitterOptions> = {
74
169
  type: "object",
75
170
  additionalProperties: true,
76
171
  properties: {
172
+ ..._RLCOptionsSchema.properties,
77
173
  "include-shortcuts": { type: "boolean", nullable: true },
78
174
  "multi-client": { type: "boolean", nullable: true },
79
175
  batch: {
@@ -288,6 +384,12 @@ const libDef = {
288
384
  default: paramMessage`Please note the decimal type will be converted to number. If you strongly care about precision you can use @encode to encode it as a string for the property - ${"propertyName"}.`
289
385
  }
290
386
  },
387
+ "use-kebab-case-option": {
388
+ severity: "warning",
389
+ messages: {
390
+ default: paramMessage`The option - ${"camelCaseOption"} is deprecated and please use this kebab-case one - ${"kebabCaseOption"}.`
391
+ }
392
+ },
291
393
  "unable-serialized-type": {
292
394
  severity: "warning",
293
395
  messages: {
@@ -36,23 +36,206 @@ export function transformRLCOptions(
36
36
  );
37
37
  if (
38
38
  !isAzurePackage({ options }) &&
39
- emitterOptions["is-modular-library"] !== false
39
+ emitterOptions["is-modular-library"] !== false &&
40
+ emitterOptions.isModularLibrary !== false
40
41
  ) {
41
42
  options.isModularLibrary = true;
42
43
  }
43
- if (dpgContext.arm && emitterOptions["is-modular-library"] !== false) {
44
+ if (
45
+ dpgContext.arm &&
46
+ emitterOptions["is-modular-library"] !== false &&
47
+ emitterOptions.isModularLibrary !== false
48
+ ) {
44
49
  options.isModularLibrary = true;
45
50
  }
46
51
  const batch = getRLCClients(dpgContext);
47
52
  options.batch = batch;
48
53
  return options;
49
54
  }
55
+ function reportAllCamelOptionDiagnostics(
56
+ program: Program,
57
+ emitterOptions: EmitterOptions
58
+ ) {
59
+ if (emitterOptions.includeShortcuts !== undefined) {
60
+ reportCamelOptionDiagnostic(program, {
61
+ kebabCaseOption: "include-shortcuts",
62
+ camelCaseOption: "includeShortcuts"
63
+ });
64
+ }
65
+ if (emitterOptions.packageDetails !== undefined) {
66
+ reportCamelOptionDiagnostic(program, {
67
+ kebabCaseOption: "package-details",
68
+ camelCaseOption: "packageDetails"
69
+ });
70
+ }
71
+ if (emitterOptions.moduleKind !== undefined) {
72
+ reportCamelOptionDiagnostic(program, {
73
+ kebabCaseOption: "module-kind",
74
+ camelCaseOption: "moduleKind"
75
+ });
76
+ }
77
+ if (emitterOptions.azureSdkForJs !== undefined) {
78
+ reportCamelOptionDiagnostic(program, {
79
+ kebabCaseOption: "azure-sdk-for-js",
80
+ camelCaseOption: "azureSdkForJs"
81
+ });
82
+ }
83
+ if (emitterOptions.generateMetadata !== undefined) {
84
+ reportCamelOptionDiagnostic(program, {
85
+ kebabCaseOption: "generate-metadata",
86
+ camelCaseOption: "generateMetadata"
87
+ });
88
+ }
89
+ if (emitterOptions.generateTest !== undefined) {
90
+ reportCamelOptionDiagnostic(program, {
91
+ kebabCaseOption: "generate-test",
92
+ camelCaseOption: "generateTest"
93
+ });
94
+ }
95
+ if (emitterOptions.generateSample !== undefined) {
96
+ reportCamelOptionDiagnostic(program, {
97
+ kebabCaseOption: "generate-sample",
98
+ camelCaseOption: "generateSample"
99
+ });
100
+ }
101
+ if (emitterOptions.addCredentials !== undefined) {
102
+ reportCamelOptionDiagnostic(program, {
103
+ kebabCaseOption: "add-credentials",
104
+ camelCaseOption: "addCredentials"
105
+ });
106
+ }
107
+ if (emitterOptions.credentialScopes !== undefined) {
108
+ reportCamelOptionDiagnostic(program, {
109
+ kebabCaseOption: "credential-scopes",
110
+ camelCaseOption: "credentialScopes"
111
+ });
112
+ }
113
+ if (emitterOptions.credentialKeyHeaderName !== undefined) {
114
+ reportCamelOptionDiagnostic(program, {
115
+ kebabCaseOption: "credential-key-header-name",
116
+ camelCaseOption: "credentialKeyHeaderName"
117
+ });
118
+ }
119
+ if (emitterOptions.customHttpAuthHeaderName !== undefined) {
120
+ reportCamelOptionDiagnostic(program, {
121
+ kebabCaseOption: "custom-http-auth-header-name",
122
+ camelCaseOption: "customHttpAuthHeaderName"
123
+ });
124
+ }
125
+ if (emitterOptions.customHttpAuthSharedKeyPrefix !== undefined) {
126
+ reportCamelOptionDiagnostic(program, {
127
+ kebabCaseOption: "custom-http-auth-shared-key-prefix",
128
+ camelCaseOption: "customHttpAuthSharedKeyPrefix"
129
+ });
130
+ }
131
+ if (emitterOptions.enableOperationGroup !== undefined) {
132
+ reportCamelOptionDiagnostic(program, {
133
+ kebabCaseOption: "enable-operation-group",
134
+ camelCaseOption: "enableOperationGroup"
135
+ });
136
+ }
137
+ if (emitterOptions.enableModelNamespace !== undefined) {
138
+ reportCamelOptionDiagnostic(program, {
139
+ kebabCaseOption: "enable-model-namespace",
140
+ camelCaseOption: "enableModelNamespace"
141
+ });
142
+ }
143
+ if (emitterOptions.hierarchyClient !== undefined) {
144
+ reportCamelOptionDiagnostic(program, {
145
+ kebabCaseOption: "hierarchy-client",
146
+ camelCaseOption: "hierarchyClient"
147
+ });
148
+ }
149
+ if (emitterOptions.clearOutputFolder !== undefined) {
150
+ reportCamelOptionDiagnostic(program, {
151
+ kebabCaseOption: "clear-output-folder",
152
+ camelCaseOption: "clearOutputFolder"
153
+ });
154
+ }
155
+ if (emitterOptions.multiClient !== undefined) {
156
+ reportCamelOptionDiagnostic(program, {
157
+ kebabCaseOption: "multi-client",
158
+ camelCaseOption: "multiClient"
159
+ });
160
+ }
161
+ if (emitterOptions.isTypeSpecTest !== undefined) {
162
+ reportCamelOptionDiagnostic(program, {
163
+ kebabCaseOption: "is-typespec-test",
164
+ camelCaseOption: "isTypeSpecTest"
165
+ });
166
+ }
167
+ if (emitterOptions.dependencyInfo !== undefined) {
168
+ reportCamelOptionDiagnostic(program, {
169
+ kebabCaseOption: "dependency-info",
170
+ camelCaseOption: "dependencyInfo"
171
+ });
172
+ }
173
+ if (emitterOptions.productDocLink !== undefined) {
174
+ reportCamelOptionDiagnostic(program, {
175
+ kebabCaseOption: "product-doc-link",
176
+ camelCaseOption: "productDocLink"
177
+ });
178
+ }
179
+ if (emitterOptions.isModularLibrary !== undefined) {
180
+ reportCamelOptionDiagnostic(program, {
181
+ kebabCaseOption: "is-modular-library",
182
+ camelCaseOption: "isModularLibrary"
183
+ });
184
+ }
185
+ if (emitterOptions.compatibilityMode !== undefined) {
186
+ reportCamelOptionDiagnostic(program, {
187
+ kebabCaseOption: "compatibility-mode",
188
+ camelCaseOption: "compatibilityMode"
189
+ });
190
+ }
191
+ if (emitterOptions.experimentalExtensibleEnums !== undefined) {
192
+ reportCamelOptionDiagnostic(program, {
193
+ kebabCaseOption: "experimental-extensible-enums",
194
+ camelCaseOption: "experimentalExtensibleEnums"
195
+ });
196
+ }
197
+ if (emitterOptions.ignorePropertyNameNormalize !== undefined) {
198
+ reportCamelOptionDiagnostic(program, {
199
+ kebabCaseOption: "ignore-property-name-normalize",
200
+ camelCaseOption: "ignorePropertyNameNormalize"
201
+ });
202
+ }
203
+ if (emitterOptions.compatibilityQueryMultiFormat !== undefined) {
204
+ reportCamelOptionDiagnostic(program, {
205
+ kebabCaseOption: "compatibility-query-multi-format",
206
+ camelCaseOption: "compatibilityQueryMultiFormat"
207
+ });
208
+ }
209
+ if (emitterOptions.typespecTitleMap !== undefined) {
210
+ reportCamelOptionDiagnostic(program, {
211
+ kebabCaseOption: "typespec-title-map",
212
+ camelCaseOption: "typespecTitleMap"
213
+ });
214
+ }
215
+ }
216
+ export function reportCamelOptionDiagnostic(
217
+ program: Program,
218
+ caseOption: {
219
+ kebabCaseOption: string;
220
+ camelCaseOption: string;
221
+ }
222
+ ) {
223
+ reportDiagnostic(program, {
224
+ code: "use-kebab-case-option",
225
+ format: {
226
+ kebabCaseOption: caseOption.kebabCaseOption,
227
+ camelCaseOption: caseOption.camelCaseOption
228
+ },
229
+ target: NoTarget
230
+ });
231
+ }
50
232
  function extractRLCOptions(
51
233
  dpgContext: SdkContext,
52
234
  emitterOptions: EmitterOptions,
53
235
  generationRootDir: string
54
236
  ): RLCOptions {
55
237
  const program = dpgContext.program;
238
+ reportAllCamelOptionDiagnostics(program, emitterOptions);
56
239
  const includeShortcuts = getIncludeShortcuts(emitterOptions);
57
240
  const packageDetails = getPackageDetails(program, emitterOptions);
58
241
  const flavor = getFlavor(emitterOptions, packageDetails);
@@ -74,22 +257,33 @@ function extractRLCOptions(
74
257
  );
75
258
  const hierarchyClient = getHierarchyClient(emitterOptions);
76
259
  const clearOutputFolder = getClearOutputFolder(emitterOptions);
77
- const multiClient = emitterOptions["multi-client"];
78
- const isTypeSpecTest = emitterOptions["is-typespec-test"];
260
+ const multiClient =
261
+ emitterOptions["multi-client"] ?? emitterOptions.multiClient;
262
+ const isTypeSpecTest =
263
+ emitterOptions["is-typespec-test"] ?? emitterOptions.isTypeSpecTest;
79
264
  const title = emitterOptions.title;
80
- const dependencyInfo = emitterOptions["dependency-info"];
81
- const productDocLink = emitterOptions["product-doc-link"];
82
- const isModularLibrary = emitterOptions["is-modular-library"];
83
- const compatibilityMode = emitterOptions["compatibility-mode"];
265
+ const dependencyInfo =
266
+ emitterOptions["dependency-info"] ?? emitterOptions.dependencyInfo;
267
+ const productDocLink =
268
+ emitterOptions["product-doc-link"] ?? emitterOptions.productDocLink;
269
+ const isModularLibrary =
270
+ emitterOptions["is-modular-library"] ?? emitterOptions.isModularLibrary;
271
+ const compatibilityMode =
272
+ emitterOptions["compatibility-mode"] ?? emitterOptions.compatibilityMode;
84
273
  const experimentalExtensibleEnums =
85
- emitterOptions["experimental-extensible-enums"];
274
+ emitterOptions["experimental-extensible-enums"] ??
275
+ emitterOptions.experimentalExtensibleEnums;
86
276
  const ignorePropertyNameNormalize =
87
- emitterOptions["ignore-property-name-normalize"];
277
+ emitterOptions["ignore-property-name-normalize"] ??
278
+ emitterOptions.ignorePropertyNameNormalize;
88
279
  const ignoreEnumMemberNameNormalize =
89
- emitterOptions["ignore-enum-member-name-normalize"];
280
+ emitterOptions["ignore-enum-member-name-normalize"] ??
281
+ emitterOptions.ignoreEnumMemberNameNormalize;
90
282
  const compatibilityQueryMultiFormat =
91
- emitterOptions["compatibility-query-multi-format"];
92
- const typespecTitleMap = emitterOptions["typespec-title-map"];
283
+ emitterOptions["compatibility-query-multi-format"] ??
284
+ emitterOptions.compatibilityQueryMultiFormat;
285
+ const typespecTitleMap =
286
+ emitterOptions["typespec-title-map"] ?? emitterOptions.typespecTitleMap;
93
287
 
94
288
  return {
95
289
  ...credentialInfo,
@@ -201,6 +395,12 @@ function getEnableOperationGroup(
201
395
  ) {
202
396
  return emitterOptions["enable-operation-group"];
203
397
  }
398
+ if (
399
+ emitterOptions.enableOperationGroup === true ||
400
+ emitterOptions.enableOperationGroup === false
401
+ ) {
402
+ return emitterOptions.enableOperationGroup;
403
+ }
204
404
  // Only detect if existing name conflicts if customers don't set hierarchyClient to true
205
405
  return detectIfNameConflicts(dpgContext);
206
406
  }
@@ -215,6 +415,12 @@ function getEnableModelNamespace(
215
415
  ) {
216
416
  return emitterOptions["enable-model-namespace"];
217
417
  }
418
+ if (
419
+ emitterOptions.enableModelNamespace === true ||
420
+ emitterOptions.enableModelNamespace === false
421
+ ) {
422
+ return emitterOptions.enableModelNamespace;
423
+ }
218
424
  // Detect if existing name conflicts if customers didn't set the option explicitly
219
425
  return detectModelConflicts(dpgContext);
220
426
  }
@@ -226,12 +432,24 @@ function getHierarchyClient(emitterOptions: EmitterOptions) {
226
432
  ) {
227
433
  return emitterOptions["hierarchy-client"];
228
434
  }
435
+ if (
436
+ emitterOptions.hierarchyClient === true ||
437
+ emitterOptions.hierarchyClient === false
438
+ ) {
439
+ return emitterOptions.hierarchyClient;
440
+ }
229
441
  // enable hierarchy client by default if customers didn't set the option explicitly
230
442
  return true;
231
443
  }
232
444
 
233
445
  function getClearOutputFolder(emitterOptions: EmitterOptions) {
234
- return emitterOptions["clear-output-folder"] ? true : false;
446
+ if (
447
+ emitterOptions["clear-output-folder"] === true ||
448
+ emitterOptions.clearOutputFolder === true
449
+ ) {
450
+ return true;
451
+ }
452
+ return false;
235
453
  }
236
454
 
237
455
  function detectIfNameConflicts(dpgContext: SdkContext) {
@@ -272,11 +490,14 @@ function detectIfNameConflicts(dpgContext: SdkContext) {
272
490
  }
273
491
 
274
492
  function getIncludeShortcuts(emitterOptions: EmitterOptions) {
275
- return Boolean(emitterOptions["include-shortcuts"]);
493
+ return (
494
+ Boolean(emitterOptions["include-shortcuts"]) ||
495
+ Boolean(emitterOptions.includeShortcuts)
496
+ );
276
497
  }
277
498
 
278
499
  function getModuleKind(emitterOptions: EmitterOptions) {
279
- return emitterOptions["module-kind"] ?? "esm";
500
+ return emitterOptions["module-kind"] ?? emitterOptions.moduleKind ?? "esm";
280
501
  }
281
502
 
282
503
  function getFlavor(
@@ -336,12 +557,42 @@ function buildPackageDetails(
336
557
  }
337
558
  return packageDetails ?? defaultDetail;
338
559
  }
339
-
560
+ function _buildPackageDetails(
561
+ program: Program,
562
+ emitterOptions: EmitterOptions
563
+ ): PackageDetails {
564
+ const defaultDetail = {
565
+ name: "@msinternal/unamedpackage",
566
+ nameWithoutScope: "unamedpackage",
567
+ version: "1.0.0-beta.1"
568
+ };
569
+ const packageDetails: PackageDetails = {
570
+ ...emitterOptions.packageDetails,
571
+ name:
572
+ emitterOptions.packageDetails?.name ??
573
+ normalizeName(
574
+ emitterOptions?.title ?? getDefaultService(program)?.title ?? "",
575
+ NameType.Class
576
+ ),
577
+ version: emitterOptions.packageDetails?.version ?? "1.0.0-beta.1"
578
+ };
579
+ if (emitterOptions.packageDetails?.name) {
580
+ const nameParts = emitterOptions.packageDetails?.name.split("/");
581
+ if (nameParts.length === 2) {
582
+ packageDetails.nameWithoutScope = nameParts[1];
583
+ packageDetails.scopeName = nameParts[0]?.replace("@", "");
584
+ }
585
+ }
586
+ return packageDetails ?? defaultDetail;
587
+ }
340
588
  function getPackageDetails(
341
589
  program: Program,
342
590
  emitterOptions: EmitterOptions
343
591
  ): PackageDetails {
344
- return buildPackageDetails(program, emitterOptions);
592
+ if (emitterOptions["package-details"] !== undefined) {
593
+ return buildPackageDetails(program, emitterOptions);
594
+ }
595
+ return _buildPackageDetails(program, emitterOptions);
345
596
  }
346
597
 
347
598
  function getServiceInfo(program: Program): ServiceInfo {
@@ -358,20 +609,28 @@ function getAzureSdkForJs(
358
609
  ) {
359
610
  return flavor !== "azure"
360
611
  ? false
361
- : emitterOptions["azure-sdk-for-js"] === undefined ||
362
- emitterOptions["azure-sdk-for-js"] === null
612
+ : (emitterOptions["azure-sdk-for-js"] === undefined ||
613
+ emitterOptions["azure-sdk-for-js"] === null) &&
614
+ (emitterOptions.azureSdkForJs === undefined ||
615
+ emitterOptions.azureSdkForJs === null)
363
616
  ? true
364
- : Boolean(emitterOptions["azure-sdk-for-js"]);
617
+ : Boolean(emitterOptions["azure-sdk-for-js"]) ||
618
+ Boolean(emitterOptions.azureSdkForJs);
365
619
  }
366
620
 
367
621
  function getGenerateMetadata(emitterOptions: EmitterOptions) {
368
622
  if (
369
- emitterOptions["generate-metadata"] === undefined ||
370
- emitterOptions["generate-metadata"] === null
623
+ (emitterOptions["generate-metadata"] === undefined ||
624
+ emitterOptions["generate-metadata"] === null) &&
625
+ (emitterOptions.generateMetadata === undefined ||
626
+ emitterOptions.generateMetadata === null)
371
627
  ) {
372
628
  return undefined;
373
629
  }
374
- return Boolean(emitterOptions["generate-metadata"]);
630
+ return (
631
+ Boolean(emitterOptions["generate-metadata"]) ||
632
+ Boolean(emitterOptions.generateMetadata)
633
+ );
375
634
  }
376
635
 
377
636
  /**
@@ -387,7 +646,7 @@ function getGenerateTest(
387
646
  if (!getAzureSdkForJs(emitterOptions, flavor)) {
388
647
  return false;
389
648
  }
390
- return emitterOptions["generate-test"];
649
+ return emitterOptions["generate-test"] ?? emitterOptions.generateTest;
391
650
  }
392
651
 
393
652
  /**
@@ -399,16 +658,21 @@ function getGenerateSample(
399
658
  dpgContext: SdkContext,
400
659
  emitterOptions: EmitterOptions
401
660
  ) {
402
- if (dpgContext.arm && emitterOptions["generate-sample"] === undefined) {
661
+ if (dpgContext.arm && emitterOptions.generateSample === undefined) {
403
662
  return true;
404
663
  }
405
664
  if (
406
- emitterOptions["generate-sample"] === undefined ||
407
- emitterOptions["generate-sample"] === null
665
+ (emitterOptions["generate-sample"] === undefined ||
666
+ emitterOptions["generate-sample"] === null) &&
667
+ (emitterOptions.generateSample === undefined ||
668
+ emitterOptions.generateSample === null)
408
669
  ) {
409
670
  return undefined;
410
671
  }
411
- return Boolean(emitterOptions["generate-sample"]);
672
+ return (
673
+ Boolean(emitterOptions["generate-sample"]) ||
674
+ Boolean(emitterOptions.generateSample)
675
+ );
412
676
  }
413
677
 
414
678
  export function getCredentialInfo(
@@ -417,27 +681,32 @@ export function getCredentialInfo(
417
681
  ) {
418
682
  const securityInfo = processAuth(program);
419
683
  const addCredentials =
420
- emitterOptions["add-credentials"] === false
684
+ emitterOptions["add-credentials"] === false ||
685
+ emitterOptions.addCredentials === false
421
686
  ? false
422
687
  : securityInfo
423
688
  ? securityInfo.addCredentials
424
- : emitterOptions["add-credentials"];
689
+ : (emitterOptions["add-credentials"] ?? emitterOptions.addCredentials);
425
690
  const credentialScopes =
426
691
  securityInfo && securityInfo.credentialScopes
427
692
  ? securityInfo.credentialScopes
428
- : emitterOptions["credential-scopes"];
693
+ : (emitterOptions["credential-scopes"] ??
694
+ emitterOptions.credentialScopes);
429
695
  const credentialKeyHeaderName =
430
696
  securityInfo && securityInfo.credentialKeyHeaderName
431
697
  ? securityInfo.credentialKeyHeaderName
432
- : emitterOptions["credential-key-header-name"];
698
+ : (emitterOptions["credential-key-header-name"] ??
699
+ emitterOptions.credentialKeyHeaderName);
433
700
  const customHttpAuthHeaderName =
434
701
  securityInfo && securityInfo.customHttpAuthHeaderName
435
702
  ? securityInfo.customHttpAuthHeaderName
436
- : emitterOptions["custom-http-auth-header-name"];
703
+ : (emitterOptions["custom-http-auth-header-name"] ??
704
+ emitterOptions.customHttpAuthHeaderName);
437
705
  const customHttpAuthSharedKeyPrefix =
438
706
  securityInfo && securityInfo.customHttpAuthSharedKeyPrefix
439
707
  ? securityInfo.customHttpAuthSharedKeyPrefix
440
- : emitterOptions["custom-http-auth-shared-key-prefix"];
708
+ : (emitterOptions["custom-http-auth-shared-key-prefix"] ??
709
+ emitterOptions.customHttpAuthSharedKeyPrefix);
441
710
  return {
442
711
  addCredentials,
443
712
  credentialScopes,