@azure-tools/typespec-ts 0.55.0-dev.8 → 0.55.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.
Files changed (192) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +1 -77
  3. package/dist/src/framework/hooks/sdk-types.d.ts +3 -2
  4. package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -1
  5. package/dist/src/framework/hooks/sdk-types.js +3 -2
  6. package/dist/src/framework/hooks/sdk-types.js.map +1 -1
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/index.js +24 -80
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/lib.d.ts +2 -12
  11. package/dist/src/lib.d.ts.map +1 -1
  12. package/dist/src/lib.js +0 -65
  13. package/dist/src/lib.js.map +1 -1
  14. package/dist/src/modular/build-classical-client.js +2 -2
  15. package/dist/src/modular/build-classical-client.js.map +1 -1
  16. package/dist/src/modular/emit-models.d.ts.map +1 -1
  17. package/dist/src/modular/emit-models.js +19 -5
  18. package/dist/src/modular/emit-models.js.map +1 -1
  19. package/dist/src/modular/emit-samples.js +92 -19
  20. package/dist/src/modular/emit-samples.js.map +1 -1
  21. package/dist/src/modular/serialization/serialize-utils.js +2 -2
  22. package/dist/src/modular/serialization/serialize-utils.js.map +1 -1
  23. package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +1 -1
  24. package/dist/src/rlc-common/helpers/name-constructors.js +1 -7
  25. package/dist/src/rlc-common/helpers/name-constructors.js.map +1 -1
  26. package/dist/src/rlc-common/index.d.ts +0 -16
  27. package/dist/src/rlc-common/index.d.ts.map +1 -1
  28. package/dist/src/rlc-common/index.js +0 -16
  29. package/dist/src/rlc-common/index.js.map +1 -1
  30. package/dist/src/rlc-common/interfaces.d.ts +0 -10
  31. package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
  32. package/dist/src/rlc-common/interfaces.js.map +1 -1
  33. package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -1
  34. package/dist/src/rlc-common/metadata/build-package-file.js +0 -12
  35. package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -1
  36. package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -1
  37. package/dist/src/rlc-common/metadata/build-readme-file.js +4 -89
  38. package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -1
  39. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts +0 -1
  40. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -1
  41. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js +2 -2
  42. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +1 -1
  43. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +0 -1
  44. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +1 -1
  45. package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -1
  46. package/dist/src/rlc-common/test/build-snippets.d.ts.map +1 -1
  47. package/dist/src/rlc-common/test/build-snippets.js +0 -1
  48. package/dist/src/rlc-common/test/build-snippets.js.map +1 -1
  49. package/dist/src/rlc-common/test/template.d.ts +1 -1
  50. package/dist/src/rlc-common/test/template.d.ts.map +1 -1
  51. package/dist/src/rlc-common/test/template.js +0 -4
  52. package/dist/src/rlc-common/test/template.js.map +1 -1
  53. package/dist/src/transform/transform-schemas.js +1 -1
  54. package/dist/src/transform/transform-schemas.js.map +1 -1
  55. package/dist/src/transform/transform.d.ts.map +1 -1
  56. package/dist/src/transform/transform.js +5 -11
  57. package/dist/src/transform/transform.js.map +1 -1
  58. package/dist/src/transform/transfrom-rlc-options.d.ts +2 -2
  59. package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -1
  60. package/dist/src/transform/transfrom-rlc-options.js +19 -39
  61. package/dist/src/transform/transfrom-rlc-options.js.map +1 -1
  62. package/dist/src/utils/client-utils.d.ts +1 -1
  63. package/dist/src/utils/client-utils.d.ts.map +1 -1
  64. package/dist/src/utils/client-utils.js +4 -5
  65. package/dist/src/utils/client-utils.js.map +1 -1
  66. package/dist/src/utils/emit-util.d.ts +0 -1
  67. package/dist/src/utils/emit-util.d.ts.map +1 -1
  68. package/dist/src/utils/emit-util.js +0 -13
  69. package/dist/src/utils/emit-util.js.map +1 -1
  70. package/dist/src/utils/model-utils.d.ts +1 -1
  71. package/dist/src/utils/model-utils.d.ts.map +1 -1
  72. package/dist/src/utils/model-utils.js +4 -11
  73. package/dist/src/utils/model-utils.js.map +1 -1
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +40 -44
  76. package/src/framework/hooks/sdk-types.ts +3 -2
  77. package/src/index.ts +27 -105
  78. package/src/lib.ts +1 -77
  79. package/src/modular/build-classical-client.ts +2 -2
  80. package/src/modular/emit-models.ts +20 -5
  81. package/src/modular/emit-samples.ts +119 -38
  82. package/src/modular/serialization/serialize-utils.ts +2 -2
  83. package/src/rlc-common/helpers/name-constructors.ts +1 -8
  84. package/src/rlc-common/index.ts +0 -16
  85. package/src/rlc-common/interfaces.ts +0 -11
  86. package/src/rlc-common/metadata/build-package-file.ts +0 -13
  87. package/src/rlc-common/metadata/build-readme-file.ts +4 -99
  88. package/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts +2 -3
  89. package/src/rlc-common/metadata/package-json/package-common.ts +0 -1
  90. package/src/rlc-common/test/build-snippets.ts +0 -1
  91. package/src/rlc-common/test/template.ts +0 -4
  92. package/src/transform/transform-schemas.ts +1 -1
  93. package/src/transform/transform.ts +4 -14
  94. package/src/transform/transfrom-rlc-options.ts +19 -63
  95. package/src/utils/client-utils.ts +4 -5
  96. package/src/utils/emit-util.ts +1 -14
  97. package/src/utils/model-utils.ts +4 -17
  98. package/dist/src/rlc-common/build-client-definitions.d.ts +0 -6
  99. package/dist/src/rlc-common/build-client-definitions.d.ts.map +0 -1
  100. package/dist/src/rlc-common/build-client-definitions.js +0 -157
  101. package/dist/src/rlc-common/build-client-definitions.js.map +0 -1
  102. package/dist/src/rlc-common/build-client.d.ts +0 -9
  103. package/dist/src/rlc-common/build-client.d.ts.map +0 -1
  104. package/dist/src/rlc-common/build-client.js +0 -375
  105. package/dist/src/rlc-common/build-client.js.map +0 -1
  106. package/dist/src/rlc-common/build-index-file.d.ts +0 -6
  107. package/dist/src/rlc-common/build-index-file.d.ts.map +0 -1
  108. package/dist/src/rlc-common/build-index-file.js +0 -180
  109. package/dist/src/rlc-common/build-index-file.js.map +0 -1
  110. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts +0 -6
  111. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts.map +0 -1
  112. package/dist/src/rlc-common/build-is-unexpected-helper.js +0 -219
  113. package/dist/src/rlc-common/build-is-unexpected-helper.js.map +0 -1
  114. package/dist/src/rlc-common/build-logger.d.ts +0 -6
  115. package/dist/src/rlc-common/build-logger.d.ts.map +0 -1
  116. package/dist/src/rlc-common/build-logger.js +0 -23
  117. package/dist/src/rlc-common/build-logger.js.map +0 -1
  118. package/dist/src/rlc-common/build-method-shortcuts.d.ts +0 -5
  119. package/dist/src/rlc-common/build-method-shortcuts.d.ts.map +0 -1
  120. package/dist/src/rlc-common/build-method-shortcuts.js +0 -54
  121. package/dist/src/rlc-common/build-method-shortcuts.js.map +0 -1
  122. package/dist/src/rlc-common/build-object-types.d.ts +0 -29
  123. package/dist/src/rlc-common/build-object-types.d.ts.map +0 -1
  124. package/dist/src/rlc-common/build-object-types.js +0 -410
  125. package/dist/src/rlc-common/build-object-types.js.map +0 -1
  126. package/dist/src/rlc-common/build-paginate-helper.d.ts +0 -6
  127. package/dist/src/rlc-common/build-paginate-helper.d.ts.map +0 -1
  128. package/dist/src/rlc-common/build-paginate-helper.js +0 -27
  129. package/dist/src/rlc-common/build-paginate-helper.js.map +0 -1
  130. package/dist/src/rlc-common/build-parameter-types.d.ts +0 -14
  131. package/dist/src/rlc-common/build-parameter-types.d.ts.map +0 -1
  132. package/dist/src/rlc-common/build-parameter-types.js +0 -338
  133. package/dist/src/rlc-common/build-parameter-types.js.map +0 -1
  134. package/dist/src/rlc-common/build-polling-helper.d.ts +0 -6
  135. package/dist/src/rlc-common/build-polling-helper.d.ts.map +0 -1
  136. package/dist/src/rlc-common/build-polling-helper.js +0 -59
  137. package/dist/src/rlc-common/build-polling-helper.js.map +0 -1
  138. package/dist/src/rlc-common/build-response-types.d.ts +0 -6
  139. package/dist/src/rlc-common/build-response-types.d.ts.map +0 -1
  140. package/dist/src/rlc-common/build-response-types.js +0 -140
  141. package/dist/src/rlc-common/build-response-types.js.map +0 -1
  142. package/dist/src/rlc-common/build-samples.d.ts +0 -3
  143. package/dist/src/rlc-common/build-samples.d.ts.map +0 -1
  144. package/dist/src/rlc-common/build-samples.js +0 -30
  145. package/dist/src/rlc-common/build-samples.js.map +0 -1
  146. package/dist/src/rlc-common/build-schema-type.d.ts +0 -20
  147. package/dist/src/rlc-common/build-schema-type.d.ts.map +0 -1
  148. package/dist/src/rlc-common/build-schema-type.js +0 -64
  149. package/dist/src/rlc-common/build-schema-type.js.map +0 -1
  150. package/dist/src/rlc-common/build-serialize-helper.d.ts +0 -6
  151. package/dist/src/rlc-common/build-serialize-helper.d.ts.map +0 -1
  152. package/dist/src/rlc-common/build-serialize-helper.js +0 -36
  153. package/dist/src/rlc-common/build-serialize-helper.js.map +0 -1
  154. package/dist/src/rlc-common/build-top-level-index-file.d.ts +0 -6
  155. package/dist/src/rlc-common/build-top-level-index-file.d.ts.map +0 -1
  156. package/dist/src/rlc-common/build-top-level-index-file.js +0 -44
  157. package/dist/src/rlc-common/build-top-level-index-file.js.map +0 -1
  158. package/dist/src/rlc-common/helpers/path-utils.d.ts +0 -2
  159. package/dist/src/rlc-common/helpers/path-utils.d.ts.map +0 -1
  160. package/dist/src/rlc-common/helpers/path-utils.js +0 -9
  161. package/dist/src/rlc-common/helpers/path-utils.js.map +0 -1
  162. package/dist/src/rlc-common/helpers/shortcut-methods.d.ts +0 -4
  163. package/dist/src/rlc-common/helpers/shortcut-methods.d.ts.map +0 -1
  164. package/dist/src/rlc-common/helpers/shortcut-methods.js +0 -49
  165. package/dist/src/rlc-common/helpers/shortcut-methods.js.map +0 -1
  166. package/dist/src/rlc-common/helpers/value-generation-util.d.ts +0 -12
  167. package/dist/src/rlc-common/helpers/value-generation-util.d.ts.map +0 -1
  168. package/dist/src/rlc-common/helpers/value-generation-util.js +0 -161
  169. package/dist/src/rlc-common/helpers/value-generation-util.js.map +0 -1
  170. package/dist/src/rlc-common/transform-sample-groups.d.ts +0 -9
  171. package/dist/src/rlc-common/transform-sample-groups.d.ts.map +0 -1
  172. package/dist/src/rlc-common/transform-sample-groups.js +0 -298
  173. package/dist/src/rlc-common/transform-sample-groups.js.map +0 -1
  174. package/src/rlc-common/build-client-definitions.ts +0 -226
  175. package/src/rlc-common/build-client.ts +0 -463
  176. package/src/rlc-common/build-index-file.ts +0 -220
  177. package/src/rlc-common/build-is-unexpected-helper.ts +0 -241
  178. package/src/rlc-common/build-logger.ts +0 -29
  179. package/src/rlc-common/build-method-shortcuts.ts +0 -71
  180. package/src/rlc-common/build-object-types.ts +0 -591
  181. package/src/rlc-common/build-paginate-helper.ts +0 -31
  182. package/src/rlc-common/build-parameter-types.ts +0 -460
  183. package/src/rlc-common/build-polling-helper.ts +0 -80
  184. package/src/rlc-common/build-response-types.ts +0 -170
  185. package/src/rlc-common/build-samples.ts +0 -32
  186. package/src/rlc-common/build-schema-type.ts +0 -79
  187. package/src/rlc-common/build-serialize-helper.ts +0 -49
  188. package/src/rlc-common/build-top-level-index-file.ts +0 -51
  189. package/src/rlc-common/helpers/path-utils.ts +0 -8
  190. package/src/rlc-common/helpers/shortcut-methods.ts +0 -58
  191. package/src/rlc-common/helpers/value-generation-util.ts +0 -234
  192. package/src/rlc-common/transform-sample-groups.ts +0 -383
@@ -316,12 +316,36 @@ function prepareExampleParameters(
316
316
 
317
317
  let subscriptionIdValue = `"00000000-0000-0000-0000-000000000000"`;
318
318
  let isSubscriptionIdAdded = false;
319
- // required parameters
319
+
320
+ // Map each HTTP parameter to its method parameter via `methodParameterSegments`
321
+ // and place its example value at that path, yielding one argument per method
322
+ // parameter regardless of flat, nested, or grouped shape. Client- and
323
+ // body-carried roots are emitted by their own sections and skipped here.
324
+ const bodyParam = method.operation.bodyParam;
325
+ let bodyRootName: string | undefined;
326
+ if (
327
+ bodyParam &&
328
+ !isSpreadBodyParameter(bodyParam) &&
329
+ bodyParam.methodParameterSegments.length === 1 &&
330
+ bodyParam.methodParameterSegments[0] !== undefined &&
331
+ bodyParam.methodParameterSegments[0].length >= 1
332
+ ) {
333
+ bodyRootName = bodyParam.methodParameterSegments[0][0]!.name;
334
+ }
335
+
336
+ const methodArguments = new Map<
337
+ string,
338
+ { name: string; isOptional: boolean; value: ValueTreeNode | string }
339
+ >();
320
340
  for (const param of method.operation.parameters) {
321
- if (param.optional === true || param.type.kind === "constant" || param.clientDefaultValue) {
341
+ if (param.type.kind === "constant" || param.clientDefaultValue) {
322
342
  continue;
323
343
  }
324
-
344
+ const path = param.methodParameterSegments[0];
345
+ if (path === undefined || path.length === 0) {
346
+ continue;
347
+ }
348
+ const root = path[0]!;
325
349
  const exampleValue = parameterMap[param.serializedName];
326
350
 
327
351
  // Handle subscriptionId parameter separately for ARM clients
@@ -343,28 +367,27 @@ function prepareExampleParameters(
343
367
  continue;
344
368
  }
345
369
 
370
+ // Roots emitted by the client and body sections.
371
+ if (root.onClient || (bodyRootName !== undefined && root.name === bodyRootName)) {
372
+ continue;
373
+ }
374
+
346
375
  if (!exampleValue || !exampleValue.value) {
347
376
  // report diagnostic if required parameter is missing
348
- reportDiagnostic(dpgContext.program, {
349
- code: "required-sample-parameter",
350
- format: {
351
- exampleName: method.oriName ?? method.name,
352
- paramName: param.name,
353
- },
354
- target: NoTarget,
355
- });
377
+ if (path.length === 1 && !param.optional) {
378
+ reportDiagnostic(dpgContext.program, {
379
+ code: "required-sample-parameter",
380
+ format: {
381
+ exampleName: method.oriName ?? method.name,
382
+ paramName: param.name,
383
+ },
384
+ target: NoTarget,
385
+ });
386
+ }
356
387
  continue;
357
388
  }
358
389
 
359
- result.push(
360
- prepareExampleValue(
361
- dpgContext,
362
- exampleValue.parameter.name,
363
- exampleValue.value,
364
- param.optional,
365
- param.onClient,
366
- ),
367
- );
390
+ placeMethodArgument(methodArguments, path, getParameterValue(dpgContext, exampleValue.value));
368
391
  }
369
392
 
370
393
  // If client-level subscriptionId is needed on the client for this method, then add it
@@ -381,7 +404,6 @@ function prepareExampleParameters(
381
404
  }
382
405
 
383
406
  // required/optional body parameters
384
- const bodyParam = method.operation.bodyParam;
385
407
  const bodySerializeName = bodyParam?.serializedName;
386
408
  const bodyExample = parameterMap[bodySerializeName ?? ""];
387
409
  if (bodyParam && bodyExample && bodyExample.value) {
@@ -441,28 +463,87 @@ function prepareExampleParameters(
441
463
  }
442
464
  }
443
465
  }
444
- // optional parameters
445
- method.operation.parameters
446
- .filter(
447
- (param) =>
448
- param.optional === true && parameterMap[param.serializedName] && !param.clientDefaultValue,
449
- )
450
- .map((param) => parameterMap[param.serializedName]!)
451
- .forEach((param) => {
452
- result.push(
453
- prepareExampleValue(
454
- dpgContext,
455
- param.parameter.name,
456
- param.value,
457
- true,
458
- param.parameter.onClient,
459
- ),
460
- );
466
+ // Emit one argument per top-level method parameter. A normal parameter carries
467
+ // a scalar value; a parameter with nested leaves carries an object literal.
468
+ for (const arg of methodArguments.values()) {
469
+ result.push({
470
+ name: normalizeName(arg.name, NameType.Parameter, true),
471
+ value: serializeNestedValue(arg.value),
472
+ isOptional: arg.isOptional,
473
+ onClient: false,
461
474
  });
475
+ }
462
476
 
463
477
  return result;
464
478
  }
465
479
 
480
+ /** A nested value tree: leaves are TypeScript value expressions, interior nodes are objects. */
481
+ interface ValueTreeNode {
482
+ [key: string]: ValueTreeNode | string;
483
+ }
484
+
485
+ /**
486
+ * Records `leaf` for the method parameter addressed by `path`. `path[0]` is the
487
+ * top-level method parameter (the argument key); a single-segment path stores a
488
+ * scalar, a longer path stores the leaf inside a nested object merged with
489
+ * sibling leaves sharing the same root.
490
+ */
491
+ function placeMethodArgument(
492
+ methodArguments: Map<
493
+ string,
494
+ { name: string; isOptional: boolean; value: ValueTreeNode | string }
495
+ >,
496
+ path: readonly { name: string; optional?: boolean }[],
497
+ leaf: string,
498
+ ): void {
499
+ const root = path[0]!;
500
+ let arg = methodArguments.get(root.name);
501
+ if (!arg) {
502
+ arg = { name: root.name, isOptional: Boolean(root.optional), value: {} };
503
+ methodArguments.set(root.name, arg);
504
+ }
505
+ if (path.length === 1) {
506
+ arg.value = leaf;
507
+ return;
508
+ }
509
+ if (typeof arg.value !== "object") {
510
+ arg.value = {};
511
+ }
512
+ setNestedValue(arg.value, path.slice(1), leaf);
513
+ }
514
+
515
+ /** Places `leaf` at `path` (segments after the root), creating intermediate objects as needed. */
516
+ function setNestedValue(
517
+ root: ValueTreeNode,
518
+ path: readonly { name: string }[],
519
+ leaf: string,
520
+ ): void {
521
+ let node = root;
522
+ for (let i = 0; i < path.length; i++) {
523
+ const key = normalizeName(path[i]!.name, NameType.Property, true);
524
+ if (i === path.length - 1) {
525
+ node[key] = leaf;
526
+ } else {
527
+ const existing = node[key];
528
+ if (typeof existing !== "object" || existing === null) {
529
+ node[key] = {};
530
+ }
531
+ node = node[key] as ValueTreeNode;
532
+ }
533
+ }
534
+ }
535
+
536
+ /** Serializes a {@link ValueTreeNode} into a TypeScript object literal string. */
537
+ function serializeNestedValue(node: ValueTreeNode | string): string {
538
+ if (typeof node === "string") {
539
+ return node;
540
+ }
541
+ const entries = Object.entries(node).map(
542
+ ([key, value]) => `${key}: ${serializeNestedValue(value)}`,
543
+ );
544
+ return `{ ${entries.join(", ")} }`;
545
+ }
546
+
466
547
  function getCredentialExampleValue(
467
548
  _dpgContext: SdkContext,
468
549
  initialization: SdkClientInitializationType,
@@ -61,7 +61,7 @@ export function isSupportedSerializeType(type: SdkType): boolean {
61
61
  * 6. nested model i.e. model with property that is a model with one of the above three conditions.
62
62
  * If we consider array type, with all the above 6 types as the element types.
63
63
  */
64
- const specialVariantMap = new Map<SdkType, boolean>();
64
+ const specialVariantMap = new WeakMap<SdkType, boolean>();
65
65
  export function isSpecialUnionVariant(
66
66
  t: SdkType & { isNonExhaustive?: boolean },
67
67
  variantStack: SdkType[] = [],
@@ -146,7 +146,7 @@ export function isSpecialHandledUnion(t: SdkType & { isNonExhaustive?: boolean }
146
146
  return isDiscriminatedUnion(t!) || isPolymorphicUnion(t);
147
147
  }
148
148
 
149
- const polymorphicUnionMap = new Map<SdkType, boolean>();
149
+ const polymorphicUnionMap = new WeakMap<SdkType, boolean>();
150
150
  export function isPolymorphicUnion(t: SdkType): boolean {
151
151
  if (polymorphicUnionMap.has(t)) {
152
152
  return polymorphicUnionMap.get(t) ?? false;
@@ -77,14 +77,7 @@ export function getParameterTypeName(baseNameOrOperationGroup: string, operation
77
77
  }
78
78
 
79
79
  export function getClientName(model: RLCModel) {
80
- const clientName = model.libraryName;
81
- const clientInterfaceName = model.options?.isModularLibrary
82
- ? model.libraryName
83
- : clientName.endsWith("Client")
84
- ? `${clientName}`
85
- : `${clientName}Client`;
86
-
87
- return clientInterfaceName;
80
+ return model.libraryName;
88
81
  }
89
82
 
90
83
  export function getMultipartPartTypeName(schemaName: string, partName: string) {
@@ -1,27 +1,12 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
 
4
- export * from "./build-client-definitions.js";
5
- export * from "./build-client.js";
6
- export * from "./build-index-file.js";
7
- export * from "./build-is-unexpected-helper.js";
8
- export * from "./build-logger.js";
9
- export * from "./build-paginate-helper.js";
10
- export * from "./build-parameter-types.js";
11
- export * from "./build-polling-helper.js";
12
- export * from "./build-response-types.js";
13
- export * from "./build-samples.js";
14
- export * from "./build-schema-type.js";
15
- export * from "./build-serialize-helper.js";
16
- export * from "./build-top-level-index-file.js";
17
4
  export * from "./helpers/api-version-util.js";
18
5
  export * from "./helpers/imports-util.js";
19
6
  export * from "./helpers/name-constructors.js";
20
7
  export * from "./helpers/name-utils.js";
21
8
  export * from "./helpers/operation-helpers.js";
22
9
  export * from "./helpers/schema-helpers.js";
23
- export * from "./helpers/shortcut-methods.js";
24
- export * from "./helpers/value-generation-util.js";
25
10
  export * from "./interfaces.js";
26
11
  export * from "./metadata/build-api-extractor-config.js";
27
12
  export * from "./metadata/build-changelog-file.js";
@@ -38,4 +23,3 @@ export * from "./test/build-karma-config.js";
38
23
  export * from "./test/build-recorded-client.js";
39
24
  export * from "./test/build-sample-test.js";
40
25
  export * from "./test/build-snippets.js";
41
- export * from "./transform-sample-groups.js";
@@ -195,8 +195,6 @@ export interface RLCOptions {
195
195
  * Whether to include response headers in the generated response types. If true, the generated response types will include headers as properties.
196
196
  */
197
197
  includeHeadersInResponse?: boolean;
198
- includeShortcuts?: boolean;
199
- multiClient?: boolean;
200
198
  batch?: any[];
201
199
  packageDetails?: PackageDetails;
202
200
  addCredentials?: boolean;
@@ -226,12 +224,8 @@ export interface RLCOptions {
226
224
  generateSample?: boolean;
227
225
  azureOutputDirectory?: string;
228
226
  isTypeSpecTest?: boolean;
229
- title?: string;
230
- dependencyInfo?: DependencyInfo;
231
- productDocLink?: string;
232
227
  serviceInfo?: ServiceInfo;
233
228
  azureArm?: boolean;
234
- isModularLibrary?: boolean;
235
229
  enableOperationGroup?: boolean;
236
230
  enableModelNamespace?: boolean;
237
231
  hierarchyClient?: boolean;
@@ -275,11 +269,6 @@ export interface ServiceInfo {
275
269
  description?: string;
276
270
  }
277
271
 
278
- export interface DependencyInfo {
279
- link: string;
280
- description: string;
281
- }
282
-
283
272
  export interface File {
284
273
  path: string;
285
274
  content: string;
@@ -2,9 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  import { Project, SourceFile } from "ts-morph";
5
- import { NameType, normalizeName } from "../helpers/name-utils.js";
6
5
  import { hasPollingOperations } from "../helpers/operation-helpers.js";
7
- import { getRelativePartFromSrcPath } from "../helpers/path-utils.js";
8
6
  import { RLCModel } from "../interfaces.js";
9
7
  import { buildAzureMonorepoPackage } from "./package-json/build-azure-monorepo-package.js";
10
8
  import { PackageCommonInfoConfig, resolveWarpExports } from "./package-json/package-common.js";
@@ -29,13 +27,11 @@ export function buildPackageFile(
29
27
  nameWithoutScope: model.options?.packageDetails?.nameWithoutScope,
30
28
  exports,
31
29
  azureArm: model.options?.azureArm,
32
- isModularLibrary: model.options?.isModularLibrary ?? false,
33
30
  generateReactNativeTarget: model.options?.generateReactNativeTarget,
34
31
  };
35
32
 
36
33
  const extendedConfig = {
37
34
  ...config,
38
- clientFilePaths: [getClientFilePath(model)],
39
35
  hasLro: hasPollingOperations(model),
40
36
  monorepoPackageDirectory: model.options?.azureOutputDirectory,
41
37
  dependencies,
@@ -182,12 +178,3 @@ function getDescription(model: RLCModel): string {
182
178
  }
183
179
  return description;
184
180
  }
185
-
186
- function getClientFilePath(model: RLCModel) {
187
- const { srcPath } = model;
188
- const sdkReletivePart = getRelativePartFromSrcPath(srcPath);
189
- const clientFilename = normalizeName(model.libraryName, NameType.File);
190
- return sdkReletivePart
191
- ? `src/${sdkReletivePart}/${clientFilename}.ts`
192
- : `src/${clientFilename}.ts`;
193
- }
@@ -8,80 +8,6 @@ import { getClientName } from "../helpers/name-constructors.js";
8
8
  import { NameType, normalizeName } from "../helpers/name-utils.js";
9
9
  import { RLCModel } from "../interfaces.js";
10
10
 
11
- const azureReadmeRLCTemplate = `# {{ clientDescriptiveName }} library for JavaScript
12
-
13
- {{ description }}
14
-
15
- {{#if azureArm}}
16
- **If you are not familiar with our REST client, please spend 5 minutes to take a look at {{#if serviceDocURL}}[the service's documentation]({{ serviceDocURL }}) and {{/if}}our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library, the REST client provides a light-weighted & developer friendly way to call azure rest api
17
- {{else}}
18
- **Please rely heavily on {{#if serviceDocURL}}[the service's documentation]({{ serviceDocURL }}) and {{/if}}our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
19
- {{/if}}
20
-
21
- Key links:
22
-
23
- {{#if packageSourceURL}}
24
- - [Source code]({{ packageSourceURL }})
25
- {{/if}}
26
- {{#if packageNPMURL}}
27
- - [Package (NPM)]({{ packageNPMURL }})
28
- {{/if}}
29
- {{#if apiRefURL}}
30
- - [API reference documentation]({{ apiRefURL }})
31
- {{/if}}
32
- {{#if serviceDocURL}}
33
- - [Product documentation]({{ serviceDocURL }})
34
- {{/if}}
35
- {{#if samplesURL}}
36
- - [Samples]({{ samplesURL }})
37
- {{/if}}
38
-
39
- ## Getting started
40
-
41
- ### Currently supported environments
42
-
43
- - LTS versions of Node.js
44
-
45
- ### Prerequisites
46
-
47
- - You must have an [Azure subscription](https://azure.microsoft.com/free/){{#if dependencyLink}} and follow [these]({{ dependencyLink }}) instructions{{/if}} to use this package.
48
-
49
- ### Install the \`{{ clientPackageName }}\` package
50
-
51
- Install the {{ clientDescriptiveName }} REST client library for JavaScript with \`npm\`:
52
-
53
- \`\`\`bash
54
- npm install {{ clientPackageName }}
55
- \`\`\`
56
-
57
- ### Create and authenticate a \`{{ clientClassName }}\`
58
-
59
- To use a [Microsoft Entra token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
60
- provide an instance of the desired credential type obtained from the
61
- [@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
62
-
63
- To authenticate with Microsoft Entra ID, you must first \`npm\` install [\`@azure/identity\`](https://www.npmjs.com/package/@azure/identity) {{#if dependencyLink}}and
64
- [{{dependencyDescription }}]({{ dependencyLink }}){{/if}}
65
-
66
- After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from \`@azure/identity\` to use.
67
- As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
68
- can be used to authenticate the client.
69
-
70
- ## Troubleshooting
71
-
72
- ### Logging
73
-
74
- Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the \`AZURE_LOG_LEVEL\` environment variable to \`info\`. Alternatively, logging can be enabled at runtime by calling \`setLogLevel\` in the \`@azure/logger\`:
75
-
76
- \`\`\`ts {{#if generateTest}}snippet:SetLogLevel{{/if}}
77
- import { setLogLevel } from "@azure/logger";
78
-
79
- setLogLevel("info");
80
- \`\`\`
81
-
82
- For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
83
- `;
84
-
85
11
  const azureReadmeModularTemplate = `# {{ clientDescriptiveName }} library for JavaScript
86
12
 
87
13
  This package contains an isomorphic SDK (runs both in Node.js and in browsers) for {{ clientDescriptiveName }}.
@@ -346,11 +272,7 @@ interface Metadata {
346
272
  export function buildReadmeFile(model: RLCModel) {
347
273
  const metadata = createMetadata(model) ?? {};
348
274
  const readmeFileContents = hbs.compile(
349
- model.options
350
- ? model.options.isModularLibrary
351
- ? azureReadmeModularTemplate
352
- : azureReadmeRLCTemplate
353
- : nonBrandedReadmeTemplate,
275
+ model.options ? azureReadmeModularTemplate : nonBrandedReadmeTemplate,
354
276
  { noEscape: true },
355
277
  );
356
278
  return {
@@ -407,16 +329,7 @@ function createMetadata(model: RLCModel): Metadata | undefined {
407
329
  return;
408
330
  }
409
331
  // const packageDetails = model.options.packageDetails;
410
- const {
411
- packageDetails,
412
- azureOutputDirectory,
413
- productDocLink,
414
- dependencyInfo,
415
- multiClient,
416
- batch,
417
- serviceInfo,
418
- isTypeSpecTest,
419
- } = model.options;
332
+ const { packageDetails, azureOutputDirectory, serviceInfo, isTypeSpecTest } = model.options;
420
333
 
421
334
  const azureHuh =
422
335
  packageDetails?.scopeName === "azure" || packageDetails?.scopeName === "azure-rest";
@@ -444,11 +357,8 @@ function createMetadata(model: RLCModel): Metadata | undefined {
444
357
  serviceName,
445
358
  clientClassName,
446
359
  clientPackageName: clientPackageName,
447
- clientDescriptiveName: model.options.isModularLibrary
448
- ? `${serviceName} client`
449
- : `${serviceName} REST client`,
360
+ clientDescriptiveName: `${serviceName} client`,
450
361
  description: serviceInfo?.description ?? packageDetails.description,
451
- serviceDocURL: productDocLink,
452
362
  packageSourceURL: packageSourceURL,
453
363
  packageNPMURL: `https://www.npmjs.com/package/${clientPackageName}`,
454
364
  samplesURL:
@@ -456,9 +366,6 @@ function createMetadata(model: RLCModel): Metadata | undefined {
456
366
  apiRefURL: azureHuh
457
367
  ? `https://learn.microsoft.com/javascript/api/${clientPackageName}${apiRefUrlQueryParameter}`
458
368
  : undefined,
459
- dependencyDescription: dependencyInfo?.description,
460
- dependencyLink: dependencyInfo?.link,
461
- hasMultiClients: multiClient && batch && batch.length > 1,
462
369
  azureArm: Boolean(model.options.azureArm),
463
370
  azure: azureHuh,
464
371
  isReleasablePackage: !isTypeSpecTest,
@@ -477,9 +384,7 @@ function getServiceName(model: RLCModel) {
477
384
  model?.options?.packageDetails?.scopeName === "azure" ||
478
385
  model?.options?.packageDetails?.scopeName === "azure-rest";
479
386
  const libraryName = model.libraryName;
480
- const serviceTitle = model.options?.isModularLibrary
481
- ? model.libraryName
482
- : (model.options?.serviceInfo?.title ?? model.libraryName);
387
+ const serviceTitle = model.libraryName;
483
388
  const batch = model?.options?.batch,
484
389
  packageDetails = model?.options?.packageDetails;
485
390
  let simpleServiceName =
@@ -6,7 +6,6 @@ import { getCommonPackageScripts, getPackageCommonInfo } from "./package-common.
6
6
 
7
7
  export interface AzureMonorepoInfoConfig extends AzurePackageInfoConfig {
8
8
  monorepoPackageDirectory?: string;
9
- clientFilePaths: string[];
10
9
  clientContextPaths?: string[];
11
10
  }
12
11
 
@@ -128,7 +127,7 @@ function getSampleMetadata({ name, version, withSamples }: AzureMonorepoInfoConf
128
127
 
129
128
  function getAzureMonorepoScripts(config: AzureMonorepoInfoConfig) {
130
129
  const esmScripts = getEsmScripts();
131
- const skipLinting = config.azureArm && config.isModularLibrary;
130
+ const skipLinting = config.azureArm;
132
131
  const buildSampleScripts = config.azureArm
133
132
  ? "tsc -p config/tsconfig.samples.json && dev-tool samples publish -f"
134
133
  : "tsc -p config/tsconfig.samples.json";
@@ -168,7 +167,7 @@ function getMetadataInfo(config: AzureMonorepoInfoConfig) {
168
167
  const metadata: Record<string, any> = {
169
168
  constantPaths: [],
170
169
  };
171
- const paths = config.isModularLibrary ? config.clientContextPaths : config.clientFilePaths;
170
+ const paths = config.clientContextPaths;
172
171
  for (const path of paths ?? []) {
173
172
  metadata["constantPaths"].push({
174
173
  path: path,
@@ -11,7 +11,6 @@ export interface PackageCommonInfoConfig {
11
11
  exports?: Record<string, any>;
12
12
  dependencies?: Record<string, string>;
13
13
  azureArm?: boolean;
14
- isModularLibrary?: boolean;
15
14
  /**
16
15
  * When true, generates React Native build targets (dist/react-native, exports condition).
17
16
  * Defaults to false.
@@ -17,7 +17,6 @@ export function buildSnippets(model: RLCModel, clientName?: string) {
17
17
  content: hbs.compile(snippetsContent, { noEscape: true })({
18
18
  clientClassName: clientName ? clientName : getClientName(model),
19
19
  azureArm: model.options?.azureArm,
20
- isModularLibrary: model.options.isModularLibrary,
21
20
  hasSubscriptionId: model.options.hasSubscriptionId,
22
21
  }),
23
22
  };
@@ -182,15 +182,12 @@ describe("My test", () => {
182
182
  `;
183
183
 
184
184
  export const snippetsContent = `
185
- {{#if isModularLibrary}}
186
185
  import { {{ clientClassName }} } from "../src/index.js";
187
186
  import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity";
188
- {{/if}}
189
187
  import { setLogLevel } from "@azure/logger";
190
188
  import { describe, it } from "vitest";
191
189
 
192
190
  describe("snippets", () => {
193
- {{#if isModularLibrary}}
194
191
  it("ReadmeSampleCreateClient_Node", async () => {
195
192
  {{#if azureArm}}
196
193
  {{#if hasSubscriptionId}}
@@ -224,7 +221,6 @@ describe("snippets", () => {
224
221
  const client = new {{ clientClassName }}("<endpoint>", credential);
225
222
  {{/if}}
226
223
  });
227
- {{/if}}
228
224
 
229
225
  it("SetLogLevel", async () => {
230
226
  setLogLevel("info");
@@ -78,7 +78,7 @@ export function transformSchemas(client: SdkClient, dpgContext: SdkContext) {
78
78
  }
79
79
  }
80
80
  function transformHostParameters() {
81
- const serviceNs = getDefaultService(program, dpgContext.rlcOptions?.isModularLibrary)?.type;
81
+ const serviceNs = getDefaultService(program)?.type;
82
82
  if (serviceNs) {
83
83
  const host = getServers(program, serviceNs);
84
84
  if (host && host?.[0] && host?.[0]?.parameters) {
@@ -18,7 +18,6 @@ import {
18
18
  RLCOptions,
19
19
  Schema,
20
20
  SchemaContext,
21
- transformSampleGroups,
22
21
  UrlInfo,
23
22
  } from "../rlc-common/index.js";
24
23
  import { SdkContext } from "../utils/interfaces.js";
@@ -53,12 +52,7 @@ export async function transformRLCModel(
53
52
  : "",
54
53
  );
55
54
  const libraryName = normalizeName(
56
- options.batch && (options.isModularLibrary || options.batch.length > 1)
57
- ? client.name
58
- : (options?.title ??
59
- client.name ??
60
- getDefaultService(program, options.isModularLibrary)?.title ??
61
- ""),
55
+ options.batch ? client.name : (client.name ?? getDefaultService(program)?.title ?? ""),
62
56
  NameType.Class,
63
57
  );
64
58
  const importSet = initInternalImports();
@@ -95,13 +89,9 @@ export async function transformRLCModel(
95
89
  },
96
90
  rlcSourceDir,
97
91
  };
98
- model.sampleGroups = transformSampleGroups(
99
- model,
100
- options?.generateSample === true /* Enable mock sample content if generateSample === true */,
101
- );
102
- options.generateSample =
103
- (options.generateSample === true || options.generateSample === undefined) &&
104
- (model.sampleGroups ?? []).length > 0;
92
+ // RLC sample generation has been removed; modular samples are emitted separately,
93
+ // so the RLC model never carries sample groups.
94
+ options.generateSample = false;
105
95
  return model;
106
96
  }
107
97