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

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 (172) hide show
  1. package/README.md +3 -24
  2. package/dist/src/framework/hooks/binder.d.ts +1 -1
  3. package/dist/src/framework/hooks/binder.d.ts.map +1 -1
  4. package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
  5. package/dist/src/framework/load-static-helpers.js +6 -8
  6. package/dist/src/framework/load-static-helpers.js.map +1 -1
  7. package/dist/src/index.d.ts.map +1 -1
  8. package/dist/src/index.js +20 -29
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/lib.d.ts +0 -4
  11. package/dist/src/lib.d.ts.map +1 -1
  12. package/dist/src/lib.js +3 -21
  13. package/dist/src/lib.js.map +1 -1
  14. package/dist/src/rlc-common/build-client-definitions.d.ts.map +1 -1
  15. package/dist/src/rlc-common/build-client-definitions.js +4 -4
  16. package/dist/src/rlc-common/build-client-definitions.js.map +1 -1
  17. package/dist/src/rlc-common/build-client.d.ts.map +1 -1
  18. package/dist/src/rlc-common/build-client.js +4 -13
  19. package/dist/src/rlc-common/build-client.js.map +1 -1
  20. package/dist/src/rlc-common/build-index-file.d.ts.map +1 -1
  21. package/dist/src/rlc-common/build-index-file.js +21 -79
  22. package/dist/src/rlc-common/build-index-file.js.map +1 -1
  23. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts.map +1 -1
  24. package/dist/src/rlc-common/build-is-unexpected-helper.js +1 -5
  25. package/dist/src/rlc-common/build-is-unexpected-helper.js.map +1 -1
  26. package/dist/src/rlc-common/build-logger.d.ts.map +1 -1
  27. package/dist/src/rlc-common/build-logger.js +2 -6
  28. package/dist/src/rlc-common/build-logger.js.map +1 -1
  29. package/dist/src/rlc-common/build-object-types.d.ts +1 -1
  30. package/dist/src/rlc-common/build-object-types.d.ts.map +1 -1
  31. package/dist/src/rlc-common/build-object-types.js +9 -11
  32. package/dist/src/rlc-common/build-object-types.js.map +1 -1
  33. package/dist/src/rlc-common/build-parameter-types.d.ts.map +1 -1
  34. package/dist/src/rlc-common/build-parameter-types.js +13 -66
  35. package/dist/src/rlc-common/build-parameter-types.js.map +1 -1
  36. package/dist/src/rlc-common/build-polling-helper.d.ts.map +1 -1
  37. package/dist/src/rlc-common/build-polling-helper.js +0 -2
  38. package/dist/src/rlc-common/build-polling-helper.js.map +1 -1
  39. package/dist/src/rlc-common/build-response-types.d.ts.map +1 -1
  40. package/dist/src/rlc-common/build-response-types.js +2 -5
  41. package/dist/src/rlc-common/build-response-types.js.map +1 -1
  42. package/dist/src/rlc-common/build-schema-type.d.ts.map +1 -1
  43. package/dist/src/rlc-common/build-schema-type.js +1 -8
  44. package/dist/src/rlc-common/build-schema-type.js.map +1 -1
  45. package/dist/src/rlc-common/build-top-level-index-file.d.ts.map +1 -1
  46. package/dist/src/rlc-common/build-top-level-index-file.js +1 -5
  47. package/dist/src/rlc-common/build-top-level-index-file.js.map +1 -1
  48. package/dist/src/rlc-common/helpers/name-constructors.d.ts +0 -9
  49. package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +1 -1
  50. package/dist/src/rlc-common/helpers/name-constructors.js +0 -10
  51. package/dist/src/rlc-common/helpers/name-constructors.js.map +1 -1
  52. package/dist/src/rlc-common/index.d.ts +0 -2
  53. package/dist/src/rlc-common/index.d.ts.map +1 -1
  54. package/dist/src/rlc-common/index.js +0 -2
  55. package/dist/src/rlc-common/index.js.map +1 -1
  56. package/dist/src/rlc-common/interfaces.d.ts +1 -4
  57. package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
  58. package/dist/src/rlc-common/interfaces.js.map +1 -1
  59. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts +1 -1
  60. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts.map +1 -1
  61. package/dist/src/rlc-common/metadata/build-api-extractor-config.js +4 -41
  62. package/dist/src/rlc-common/metadata/build-api-extractor-config.js.map +1 -1
  63. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts +1 -1
  64. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts.map +1 -1
  65. package/dist/src/rlc-common/metadata/build-es-lint-config.js +2 -37
  66. package/dist/src/rlc-common/metadata/build-es-lint-config.js.map +1 -1
  67. package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -1
  68. package/dist/src/rlc-common/metadata/build-package-file.js +22 -52
  69. package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -1
  70. package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -1
  71. package/dist/src/rlc-common/metadata/build-readme-file.js +6 -7
  72. package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -1
  73. package/dist/src/rlc-common/metadata/build-test-config.d.ts.map +1 -1
  74. package/dist/src/rlc-common/metadata/build-test-config.js +1 -4
  75. package/dist/src/rlc-common/metadata/build-test-config.js.map +1 -1
  76. package/dist/src/rlc-common/metadata/build-ts-config.d.ts +2 -2
  77. package/dist/src/rlc-common/metadata/build-ts-config.d.ts.map +1 -1
  78. package/dist/src/rlc-common/metadata/build-ts-config.js +18 -59
  79. package/dist/src/rlc-common/metadata/build-ts-config.js.map +1 -1
  80. package/dist/src/rlc-common/metadata/build-warp-config.d.ts +1 -1
  81. package/dist/src/rlc-common/metadata/build-warp-config.d.ts.map +1 -1
  82. package/dist/src/rlc-common/metadata/build-warp-config.js +0 -3
  83. package/dist/src/rlc-common/metadata/build-warp-config.js.map +1 -1
  84. package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts +1 -38
  85. package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts.map +1 -1
  86. package/dist/src/rlc-common/metadata/package-json/azure-package-common.js +1 -108
  87. package/dist/src/rlc-common/metadata/package-json/azure-package-common.js.map +1 -1
  88. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts +0 -38
  89. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -1
  90. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js +2 -18
  91. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +1 -1
  92. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +1 -18
  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 +20 -94
  95. package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -1
  96. package/dist/src/rlc-common/static/polling-content.d.ts +1 -1
  97. package/dist/src/rlc-common/static/polling-content.d.ts.map +1 -1
  98. package/dist/src/rlc-common/static/polling-content.js +1 -1
  99. package/dist/src/rlc-common/test/build-recorded-client.d.ts +1 -1
  100. package/dist/src/rlc-common/test/build-recorded-client.d.ts.map +1 -1
  101. package/dist/src/rlc-common/test/build-recorded-client.js +2 -5
  102. package/dist/src/rlc-common/test/build-recorded-client.js.map +1 -1
  103. package/dist/src/rlc-common/test/build-sample-test.d.ts +1 -1
  104. package/dist/src/rlc-common/test/build-sample-test.d.ts.map +1 -1
  105. package/dist/src/rlc-common/test/build-sample-test.js +2 -5
  106. package/dist/src/rlc-common/test/build-sample-test.js.map +1 -1
  107. package/dist/src/rlc-common/test/build-snippets.d.ts +1 -1
  108. package/dist/src/rlc-common/test/build-snippets.d.ts.map +1 -1
  109. package/dist/src/rlc-common/test/build-snippets.js +2 -5
  110. package/dist/src/rlc-common/test/build-snippets.js.map +1 -1
  111. package/dist/src/rlc-common/test/template.d.ts +2 -2
  112. package/dist/src/rlc-common/test/template.d.ts.map +1 -1
  113. package/dist/src/rlc-common/test/template.js +1 -31
  114. package/dist/src/rlc-common/test/template.js.map +1 -1
  115. package/dist/src/rlc-common/transform-sample-groups.d.ts.map +1 -1
  116. package/dist/src/rlc-common/transform-sample-groups.js +4 -8
  117. package/dist/src/rlc-common/transform-sample-groups.js.map +1 -1
  118. package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -1
  119. package/dist/src/transform/transfrom-rlc-options.js +0 -18
  120. package/dist/src/transform/transfrom-rlc-options.js.map +1 -1
  121. package/dist/tsconfig.tsbuildinfo +1 -1
  122. package/package.json +1 -1
  123. package/src/framework/hooks/binder.ts +1 -1
  124. package/src/framework/load-static-helpers.ts +8 -10
  125. package/src/index.ts +19 -31
  126. package/src/lib.ts +3 -26
  127. package/src/rlc-common/build-client-definitions.ts +4 -13
  128. package/src/rlc-common/build-client.ts +4 -22
  129. package/src/rlc-common/build-index-file.ts +21 -142
  130. package/src/rlc-common/build-is-unexpected-helper.ts +1 -8
  131. package/src/rlc-common/build-logger.ts +2 -12
  132. package/src/rlc-common/build-object-types.ts +5 -17
  133. package/src/rlc-common/build-parameter-types.ts +9 -103
  134. package/src/rlc-common/build-polling-helper.ts +0 -3
  135. package/src/rlc-common/build-response-types.ts +2 -12
  136. package/src/rlc-common/build-schema-type.ts +1 -11
  137. package/src/rlc-common/build-top-level-index-file.ts +1 -8
  138. package/src/rlc-common/helpers/name-constructors.ts +0 -15
  139. package/src/rlc-common/index.ts +0 -2
  140. package/src/rlc-common/interfaces.ts +1 -4
  141. package/src/rlc-common/metadata/build-api-extractor-config.ts +4 -46
  142. package/src/rlc-common/metadata/build-es-lint-config.ts +2 -38
  143. package/src/rlc-common/metadata/build-package-file.ts +21 -58
  144. package/src/rlc-common/metadata/build-readme-file.ts +6 -9
  145. package/src/rlc-common/metadata/build-test-config.ts +1 -6
  146. package/src/rlc-common/metadata/build-ts-config.ts +28 -70
  147. package/src/rlc-common/metadata/build-warp-config.ts +0 -4
  148. package/src/rlc-common/metadata/package-json/azure-package-common.ts +2 -134
  149. package/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts +2 -21
  150. package/src/rlc-common/metadata/package-json/package-common.ts +21 -114
  151. package/src/rlc-common/static/polling-content.ts +1 -1
  152. package/src/rlc-common/test/build-recorded-client.ts +2 -5
  153. package/src/rlc-common/test/build-sample-test.ts +2 -5
  154. package/src/rlc-common/test/build-snippets.ts +2 -5
  155. package/src/rlc-common/test/template.ts +1 -31
  156. package/src/rlc-common/transform-sample-groups.ts +3 -12
  157. package/src/transform/transfrom-rlc-options.ts +0 -20
  158. package/dist/src/rlc-common/helpers/package-util.d.ts +0 -4
  159. package/dist/src/rlc-common/helpers/package-util.d.ts.map +0 -1
  160. package/dist/src/rlc-common/helpers/package-util.js +0 -7
  161. package/dist/src/rlc-common/helpers/package-util.js.map +0 -1
  162. package/dist/src/rlc-common/metadata/build-rollup-config.d.ts +0 -6
  163. package/dist/src/rlc-common/metadata/build-rollup-config.d.ts.map +0 -1
  164. package/dist/src/rlc-common/metadata/build-rollup-config.js +0 -139
  165. package/dist/src/rlc-common/metadata/build-rollup-config.js.map +0 -1
  166. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts +0 -8
  167. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts.map +0 -1
  168. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js +0 -101
  169. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js.map +0 -1
  170. package/src/rlc-common/helpers/package-util.ts +0 -9
  171. package/src/rlc-common/metadata/build-rollup-config.ts +0 -146
  172. package/src/rlc-common/metadata/package-json/build-azure-standalone-package.ts +0 -123
@@ -49,7 +49,6 @@ export function buildObjectInterfaces(
49
49
 
50
50
  const baseName = getObjectBaseName(objectSchema, schemaUsage);
51
51
  const interfaceDeclaration = getObjectInterfaceDeclaration(
52
- model,
53
52
  baseName,
54
53
  objectSchema,
55
54
  schemaUsage,
@@ -273,7 +272,6 @@ function getPolymorphicTypeAlias(
273
272
  * root node it will suffix it with Base.
274
273
  */
275
274
  export function getObjectInterfaceDeclaration(
276
- model: RLCModel,
277
275
  baseName: string,
278
276
  objectSchema: ObjectSchema,
279
277
  schemaUsage: SchemaContext[],
@@ -289,12 +287,7 @@ export function getObjectInterfaceDeclaration(
289
287
  let propertySignatures = getPropertySignatures(properties, schemaUsage, importedModels);
290
288
 
291
289
  // Add the polymorphic property if exists
292
- propertySignatures = addDiscriminatorProperty(
293
- model,
294
- objectSchema,
295
- propertySignatures,
296
- schemaUsage,
297
- );
290
+ propertySignatures = addDiscriminatorProperty(objectSchema, propertySignatures, schemaUsage);
298
291
 
299
292
  // Calculate the parents of the current object
300
293
  const extendFrom = getImmediateParentsNames(objectSchema, schemaUsage);
@@ -315,12 +308,11 @@ function isPolymorphicParent(objectSchema: ObjectSchema) {
315
308
  }
316
309
 
317
310
  function addDiscriminatorProperty(
318
- model: RLCModel,
319
311
  objectSchema: ObjectSchema,
320
312
  properties: PropertySignatureStructure[],
321
313
  schemaUsage: SchemaContext[],
322
314
  ): PropertySignatureStructure[] {
323
- const polymorphicProperty = getDiscriminatorProperty(model, objectSchema, schemaUsage);
315
+ const polymorphicProperty = getDiscriminatorProperty(objectSchema, schemaUsage);
324
316
 
325
317
  if (polymorphicProperty) {
326
318
  // It is possible that the polymorphic property needs to override an existing property.
@@ -337,7 +329,6 @@ function addDiscriminatorProperty(
337
329
  * Finds the name of the property used as discriminator and the discriminator value.
338
330
  */
339
331
  function getDiscriminatorProperty(
340
- model: RLCModel,
341
332
  objectSchema: ObjectSchema,
342
333
  schemaUsage: SchemaContext[],
343
334
  ): PropertySignatureStructure | undefined {
@@ -359,12 +350,9 @@ function getDiscriminatorProperty(
359
350
  return {
360
351
  kind: StructureKind.PropertySignature,
361
352
  name: `"${discriminatorPropertyName}"`,
362
- type:
363
- model.options?.sourceFrom === "Swagger"
364
- ? discriminators
365
- : schemaUsage.includes(SchemaContext.Output)
366
- ? (objectSchema.discriminator?.outputTypeName ?? inputTypeName)
367
- : inputTypeName,
353
+ type: schemaUsage.includes(SchemaContext.Output)
354
+ ? (objectSchema.discriminator?.outputTypeName ?? inputTypeName)
355
+ : inputTypeName,
368
356
  };
369
357
  }
370
358
 
@@ -11,11 +11,7 @@ import {
11
11
  } from "ts-morph";
12
12
  import { getObjectInterfaceDeclaration } from "./build-object-types.js";
13
13
  import { getImportSpecifier } from "./helpers/imports-util.js";
14
- import {
15
- getImportModuleName,
16
- getParameterBaseName,
17
- getParameterTypeName,
18
- } from "./helpers/name-constructors.js";
14
+ import { getParameterBaseName, getParameterTypeName } from "./helpers/name-constructors.js";
19
15
  import { getGeneratedWrapperTypes } from "./helpers/operation-helpers.js";
20
16
  import {
21
17
  ObjectSchema,
@@ -62,20 +58,12 @@ export function buildParameterTypes(model: RLCModel) {
62
58
  const parameterInterfaceName =
63
59
  requestCount > 1 ? `${baseParameterName}RequestParameters${nameSuffix}` : topParamName;
64
60
  const queryParameterDefinitions = buildQueryParameterDefinition(
65
- model,
66
- parameter,
67
- baseParameterName,
68
- internalReferences,
69
- i,
70
- );
71
- const pathParameterDefinitions = buildPathParameterDefinitions(
72
- model,
73
61
  parameter,
74
62
  baseParameterName,
75
- parametersFile,
76
63
  internalReferences,
77
64
  i,
78
65
  );
66
+ const pathParameterDefinitions = buildPathParameterDefinitions(parameter);
79
67
 
80
68
  const headerParameterDefinitions = buildHeaderParameterDefinitions(
81
69
  parameter,
@@ -159,13 +147,7 @@ export function buildParameterTypes(model: RLCModel) {
159
147
  {
160
148
  isTypeOnly: true,
161
149
  namedImports: Array.from(model.importInfo.internalImports.parameter.importsSet!),
162
- moduleSpecifier: getImportModuleName(
163
- {
164
- cjsName: `./models`,
165
- esModulesName: `./models.js`,
166
- },
167
- model,
168
- ),
150
+ moduleSpecifier: `./models.js`,
169
151
  },
170
152
  ]);
171
153
  }
@@ -176,20 +158,11 @@ export function buildParameterTypes(model: RLCModel) {
176
158
  // NodeJS.ReadableStream on Node and `never` on browser/react-native, so the
177
159
  // union arm drops out naturally in non-Node builds.
178
160
  if (parametersFile.getFullText().includes("NodeReadableStream")) {
179
- const platformTypesModuleSpecifier = model.options?.azureSdkForJs
180
- ? "#platform/platform-types"
181
- : getImportModuleName(
182
- {
183
- cjsName: `./platform-types`,
184
- esModulesName: `./platform-types.js`,
185
- },
186
- model,
187
- );
188
161
  parametersFile.addImportDeclarations([
189
162
  {
190
163
  isTypeOnly: true,
191
164
  namedImports: ["NodeReadableStream"],
192
- moduleSpecifier: platformTypesModuleSpecifier,
165
+ moduleSpecifier: "#platform/platform-types",
193
166
  },
194
167
  ]);
195
168
  }
@@ -197,7 +170,6 @@ export function buildParameterTypes(model: RLCModel) {
197
170
  }
198
171
 
199
172
  function buildQueryParameterDefinition(
200
- model: RLCModel,
201
173
  parameters: ParameterMetadatas,
202
174
  baseName: string,
203
175
  internalReferences: Set<string>,
@@ -218,7 +190,6 @@ function buildQueryParameterDefinition(
218
190
  // Get wrapper types for query parameters
219
191
  const wrapperTypesDefinition = getGeneratedWrapperTypes(queryParameters).map((wrapObj) => {
220
192
  return getObjectInterfaceDeclaration(
221
- model,
222
193
  wrapObj.name,
223
194
  wrapObj,
224
195
  [SchemaContext.Input],
@@ -267,12 +238,7 @@ function getPropertyFromSchema(schema: Schema): PropertySignatureStructure {
267
238
  }
268
239
 
269
240
  function buildPathParameterDefinitions(
270
- model: RLCModel,
271
241
  parameters: ParameterMetadatas,
272
- baseName: string,
273
- parametersFile: SourceFile,
274
- internalReferences: Set<string>,
275
- requestIndex: number,
276
242
  ): InterfaceDeclarationStructure[] | undefined {
277
243
  const pathParameters = (parameters.parameters || []).filter((p) => p.type === "path");
278
244
  if (!pathParameters.length) {
@@ -280,72 +246,12 @@ function buildPathParameterDefinitions(
280
246
  }
281
247
  const allDefinitions: InterfaceDeclarationStructure[] = [];
282
248
 
283
- buildClientPathParameters();
284
- buildMethodWrapParameters();
249
+ // we only need to build the wrapper types if the path parameters are objects
250
+ const wrapperTypesDefinition = getGeneratedWrapperTypes(pathParameters).map((wrap) => {
251
+ return getObjectInterfaceDeclaration(wrap.name, wrap, [SchemaContext.Input], new Set<string>());
252
+ });
253
+ allDefinitions.push(...wrapperTypesDefinition);
285
254
  return allDefinitions;
286
- function buildClientPathParameters() {
287
- // we only have client-level path parameters if the source is from swagger
288
- if (model.options?.sourceFrom === "TypeSpec") {
289
- return;
290
- }
291
- const clientPathParams = pathParameters.length > 0 ? pathParameters : [];
292
- const nameSuffix = requestIndex > 0 ? `${requestIndex}` : "";
293
- const pathParameterInterfaceName = `${baseName}PathParam${nameSuffix}`;
294
-
295
- const pathInterface = getPathInterfaceDefinition(clientPathParams, baseName);
296
-
297
- if (pathInterface) {
298
- parametersFile.addInterface(pathInterface);
299
- }
300
-
301
- internalReferences.add(pathParameterInterfaceName);
302
-
303
- allDefinitions.push({
304
- isExported: true,
305
- kind: StructureKind.Interface,
306
- name: pathParameterInterfaceName,
307
- properties: [
308
- {
309
- name: "pathParameters",
310
- type: `${baseName}PathParameters`,
311
- kind: StructureKind.PropertySignature,
312
- },
313
- ],
314
- });
315
- }
316
-
317
- function buildMethodWrapParameters() {
318
- if (model.options?.sourceFrom === "Swagger") {
319
- return;
320
- }
321
- // we only have method-level path parameters if the source is from typespec
322
- const methodPathParams = pathParameters.length > 0 ? pathParameters : [];
323
-
324
- // we only need to build the wrapper types if the path parameters are objects
325
- const wrapperTypesDefinition = getGeneratedWrapperTypes(methodPathParams).map((wrap) => {
326
- return getObjectInterfaceDeclaration(
327
- model,
328
- wrap.name,
329
- wrap,
330
- [SchemaContext.Input],
331
- new Set<string>(),
332
- );
333
- });
334
- allDefinitions.push(...wrapperTypesDefinition);
335
- }
336
- }
337
-
338
- function getPathInterfaceDefinition(
339
- pathParameters: ParameterMetadata[],
340
- baseName: string,
341
- ): undefined | InterfaceDeclarationStructure {
342
- const pathInterfaceName = `${baseName}PathParameters`;
343
- return {
344
- kind: StructureKind.Interface,
345
- isExported: true,
346
- name: pathInterfaceName,
347
- properties: pathParameters.map((p: ParameterMetadata) => getPropertyFromSchema(p.param)),
348
- };
349
255
  }
350
256
 
351
257
  function buildHeaderParameterDefinitions(
@@ -10,7 +10,6 @@ interface LroDetail {
10
10
  clientOverload?: boolean;
11
11
  overloadMap?: ResponseMap[];
12
12
  importedResponses?: string[];
13
- isEsm?: boolean;
14
13
  }
15
14
 
16
15
  interface ResponseMap {
@@ -37,7 +36,6 @@ function buildLroHelperDetail(model: RLCModel): LroDetail {
37
36
  if (!model.helperDetails?.clientLroOverload) {
38
37
  return {
39
38
  clientOverload: false,
40
- isEsm: model.options?.moduleKind === "esm",
41
39
  };
42
40
  }
43
41
  const mapDetail = [];
@@ -78,6 +76,5 @@ function buildLroHelperDetail(model: RLCModel): LroDetail {
78
76
  clientOverload: responses.size > 0 && mapDetail.length > 0,
79
77
  importedResponses: Array.from(responses),
80
78
  overloadMap: mapDetail,
81
- isEsm: model.options?.moduleKind === "esm",
82
79
  };
83
80
  }
@@ -10,11 +10,7 @@ import {
10
10
  StructureKind,
11
11
  } from "ts-morph";
12
12
  import { getImportSpecifier } from "./helpers/imports-util.js";
13
- import {
14
- getImportModuleName,
15
- getResponseBaseName,
16
- getResponseTypeName,
17
- } from "./helpers/name-constructors.js";
13
+ import { getResponseBaseName, getResponseTypeName } from "./helpers/name-constructors.js";
18
14
  import { ResponseHeaderSchema, ResponseMetadata, RLCModel } from "./interfaces.js";
19
15
 
20
16
  let hasErrorResponse = false;
@@ -102,13 +98,7 @@ export function buildResponseTypes(model: RLCModel) {
102
98
  {
103
99
  isTypeOnly: true,
104
100
  namedImports: modelNamedImports,
105
- moduleSpecifier: getImportModuleName(
106
- {
107
- cjsName: `./outputModels`,
108
- esModulesName: `./outputModels.js`,
109
- },
110
- model,
111
- ),
101
+ moduleSpecifier: `./outputModels.js`,
112
102
  },
113
103
  ]);
114
104
  }
@@ -9,7 +9,6 @@ import {
9
9
  buildPolymorphicAliases,
10
10
  } from "./build-object-types.js";
11
11
  import { getImportSpecifier } from "./helpers/imports-util.js";
12
- import { getImportModuleName } from "./helpers/name-constructors.js";
13
12
  import { RLCModel, SchemaContext } from "./interfaces.js";
14
13
 
15
14
  /**
@@ -66,20 +65,11 @@ export function generateModelFiles(
66
65
  // NodeJS.ReadableStream on Node and `never` on browser/react-native, so the
67
66
  // union arm drops out naturally in non-Node builds.
68
67
  if (modelsFile.getFullText().includes("NodeReadableStream")) {
69
- const platformTypesModuleSpecifier = model.options?.azureSdkForJs
70
- ? "#platform/platform-types"
71
- : getImportModuleName(
72
- {
73
- cjsName: `./platform-types`,
74
- esModulesName: `./platform-types.js`,
75
- },
76
- model,
77
- );
78
68
  modelsFile.addImportDeclarations([
79
69
  {
80
70
  isTypeOnly: true,
81
71
  namedImports: ["NodeReadableStream"],
82
- moduleSpecifier: platformTypesModuleSpecifier,
72
+ moduleSpecifier: "#platform/platform-types",
83
73
  },
84
74
  ]);
85
75
  }
@@ -3,7 +3,6 @@
3
3
 
4
4
  import { joinPaths } from "@typespec/compiler";
5
5
  import { Project } from "ts-morph";
6
- import { getImportModuleName } from "./helpers/name-constructors.js";
7
6
  import { NameType, normalizeName } from "./helpers/name-utils.js";
8
7
  import { getRelativePartFromSrcPath } from "./helpers/path-utils.js";
9
8
  import { RLCModel } from "./interfaces.js";
@@ -33,13 +32,7 @@ export function buildTopLevelIndex(model: RLCModel) {
33
32
  indexFile.addImportDeclaration({
34
33
  isTypeOnly: true,
35
34
  namespaceImport: item[1],
36
- moduleSpecifier: getImportModuleName(
37
- {
38
- cjsName: `${item[0]}`,
39
- esModulesName: `${item[0]}/index.js`,
40
- },
41
- model,
42
- ),
35
+ moduleSpecifier: `${item[0]}/index.js`,
43
36
  });
44
37
  allModules.push(item[1]);
45
38
  });
@@ -76,21 +76,6 @@ export function getParameterTypeName(baseNameOrOperationGroup: string, operation
76
76
  return normalizeName(`${baseNameOrOperationGroup}_Parameters`, NameType.Interface);
77
77
  }
78
78
 
79
- export interface ModuleName {
80
- esModulesName: string;
81
- cjsName: string;
82
- }
83
- /**
84
- * This is a helper function that gets the right import module depending on the type of
85
- * library being generated
86
- */
87
- export function getImportModuleName(name: ModuleName, codeModel: RLCModel) {
88
- if (codeModel.options?.moduleKind === "cjs") {
89
- return name.cjsName;
90
- }
91
- return name.esModulesName;
92
- }
93
-
94
79
  export function getClientName(model: RLCModel) {
95
80
  const clientName = model.libraryName;
96
81
  const clientInterfaceName = model.options?.isModularLibrary
@@ -19,7 +19,6 @@ export * from "./helpers/imports-util.js";
19
19
  export * from "./helpers/name-constructors.js";
20
20
  export * from "./helpers/name-utils.js";
21
21
  export * from "./helpers/operation-helpers.js";
22
- export * from "./helpers/package-util.js";
23
22
  export * from "./helpers/schema-helpers.js";
24
23
  export * from "./helpers/shortcut-methods.js";
25
24
  export * from "./helpers/value-generation-util.js";
@@ -30,7 +29,6 @@ export * from "./metadata/build-es-lint-config.js";
30
29
  export * from "./metadata/build-license-file.js";
31
30
  export * from "./metadata/build-package-file.js";
32
31
  export * from "./metadata/build-readme-file.js";
33
- export * from "./metadata/build-rollup-config.js";
34
32
  export * from "./metadata/build-sample-env-file.js";
35
33
  export * from "./metadata/build-test-config.js";
36
34
  export * from "./metadata/build-ts-config.js";
@@ -224,7 +224,6 @@ export interface RLCOptions {
224
224
  */
225
225
  generateTest?: boolean;
226
226
  generateSample?: boolean;
227
- azureSdkForJs?: boolean;
228
227
  azureOutputDirectory?: string;
229
228
  isTypeSpecTest?: boolean;
230
229
  title?: string;
@@ -232,9 +231,7 @@ export interface RLCOptions {
232
231
  productDocLink?: string;
233
232
  serviceInfo?: ServiceInfo;
234
233
  azureArm?: boolean;
235
- sourceFrom?: "TypeSpec" | "Swagger";
236
234
  isModularLibrary?: boolean;
237
- moduleKind?: "esm" | "cjs";
238
235
  enableOperationGroup?: boolean;
239
236
  enableModelNamespace?: boolean;
240
237
  hierarchyClient?: boolean;
@@ -268,7 +265,7 @@ export interface RLCOptions {
268
265
  treatUnknownAsRecord?: boolean;
269
266
  /**
270
267
  * When set to true, generates React Native build targets (tsconfig, warp target, package.json exports).
271
- * Defaults to false. Only applicable when azureSdkForJs is true.
268
+ * Defaults to false.
272
269
  */
273
270
  generateReactNativeTarget?: boolean;
274
271
  }
@@ -4,54 +4,12 @@
4
4
  import { Project } from "ts-morph";
5
5
  import { RLCModel } from "../interfaces.js";
6
6
 
7
- export function buildApiExtractorConfig(model: RLCModel) {
8
- const { packageDetails, isModularLibrary, generateTest, azureSdkForJs } = model.options || {};
7
+ export function buildApiExtractorConfig(_model: RLCModel) {
9
8
  const project = new Project({ useInMemoryFileSystem: true });
10
9
 
11
- let mainEntryPointFilePath = "dist/esm/index.d.ts";
12
-
13
- if (model.options?.moduleKind === "cjs") {
14
- mainEntryPointFilePath = `./types${generateTest || isModularLibrary ? "/src" : ""}/index.d.ts`;
15
- }
16
-
17
- const config = azureSdkForJs
18
- ? {
19
- extends: "../../../api-extractor-base.json",
20
- }
21
- : {
22
- $schema:
23
- "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
24
- mainEntryPointFilePath,
25
- docModel: {
26
- enabled: true,
27
- },
28
- apiReport: {
29
- enabled: true,
30
- reportFolder: "./review",
31
- },
32
- dtsRollup: {
33
- enabled: true,
34
- untrimmedFilePath: "",
35
- publicTrimmedFilePath: `dist/${
36
- packageDetails?.nameWithoutScope ?? packageDetails?.name
37
- }.d.ts`,
38
- },
39
- messages: {
40
- tsdocMessageReporting: {
41
- default: {
42
- logLevel: "none",
43
- },
44
- },
45
- extractorMessageReporting: {
46
- "ae-missing-release-tag": {
47
- logLevel: "none",
48
- },
49
- "ae-unresolved-link": {
50
- logLevel: "none",
51
- },
52
- },
53
- },
54
- };
10
+ const config = {
11
+ extends: "../../../api-extractor-base.json",
12
+ };
55
13
 
56
14
  const filePath = "api-extractor.json";
57
15
  const configFile = project.createSourceFile(filePath, JSON.stringify(config), {
@@ -4,36 +4,6 @@
4
4
  import { Project } from "ts-morph";
5
5
  import { RLCModel } from "../interfaces.js";
6
6
 
7
- const eslintConfig = `import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
8
-
9
- export default azsdkEslint.config([
10
- {
11
- rules: {
12
- "@azure/azure-sdk/ts-modules-only-named": "warn",
13
- "@azure/azure-sdk/ts-package-json-types": "warn",
14
- "@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
15
- "tsdoc/syntax": "warn"
16
- }
17
- }
18
- ]);
19
- `;
20
-
21
- const esLintConfigEsm = `import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
22
-
23
- export default azsdkEslint.config([
24
- {
25
- rules: {
26
- "@azure/azure-sdk/ts-modules-only-named": "warn",
27
- "@azure/azure-sdk/ts-package-json-types": "warn",
28
- "@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
29
- "@azure/azure-sdk/ts-package-json-files-required": "off",
30
- "@azure/azure-sdk/ts-package-json-main-is-cjs": "off",
31
- "tsdoc/syntax": "warn"
32
- }
33
- }
34
- ]);
35
- `;
36
-
37
7
  const esLintConfigEsmAzureSdk = `import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
38
8
 
39
9
  export default [
@@ -61,17 +31,11 @@ export default [
61
31
  ];
62
32
  `;
63
33
 
64
- export function buildEsLintConfig(model: RLCModel) {
34
+ export function buildEsLintConfig(_model: RLCModel) {
65
35
  const project = new Project({ useInMemoryFileSystem: true });
66
36
  const filePath = "eslint.config.mjs";
67
37
 
68
- let template: string;
69
- if (model.options?.moduleKind === "esm") {
70
- template = model.options?.azureSdkForJs ? esLintConfigEsmAzureSdk : esLintConfigEsm;
71
- } else {
72
- template = eslintConfig;
73
- }
74
- const configFile = project.createSourceFile("eslint.config.mjs", template, {
38
+ const configFile = project.createSourceFile("eslint.config.mjs", esLintConfigEsmAzureSdk, {
75
39
  overwrite: true,
76
40
  });
77
41
  return {
@@ -4,16 +4,10 @@
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 { isAzureMonorepoPackage } from "../helpers/package-util.js";
8
7
  import { getRelativePartFromSrcPath } from "../helpers/path-utils.js";
9
8
  import { RLCModel } from "../interfaces.js";
10
9
  import { buildAzureMonorepoPackage } from "./package-json/build-azure-monorepo-package.js";
11
- import { buildAzureStandalonePackage } from "./package-json/build-azure-standalone-package.js";
12
- import {
13
- PackageCommonInfoConfig,
14
- getTshyConfig,
15
- resolveWarpExports,
16
- } from "./package-json/package-common.js";
10
+ import { PackageCommonInfoConfig, resolveWarpExports } from "./package-json/package-common.js";
17
11
  import { getPackageName } from "./utils.js";
18
12
 
19
13
  interface PackageFileOptions {
@@ -28,7 +22,6 @@ export function buildPackageFile(
28
22
  ) {
29
23
  const config: PackageCommonInfoConfig = {
30
24
  description: getDescription(model),
31
- moduleKind: model.options?.moduleKind ?? "esm",
32
25
  name: getPackageName(model),
33
26
  version: getPackageVersion(model),
34
27
  withSamples: model.options?.generateSample === true,
@@ -37,7 +30,6 @@ export function buildPackageFile(
37
30
  exports,
38
31
  azureArm: model.options?.azureArm,
39
32
  isModularLibrary: model.options?.isModularLibrary ?? false,
40
- azureSdkForJs: model.options?.azureSdkForJs,
41
33
  generateReactNativeTarget: model.options?.generateReactNativeTarget,
42
34
  };
43
35
 
@@ -46,14 +38,11 @@ export function buildPackageFile(
46
38
  clientFilePaths: [getClientFilePath(model)],
47
39
  hasLro: hasPollingOperations(model),
48
40
  monorepoPackageDirectory: model.options?.azureOutputDirectory,
49
- specSource: model.options?.sourceFrom ?? "TypeSpec",
50
41
  dependencies,
51
42
  clientContextPaths,
52
43
  };
53
44
 
54
- const packageInfo: Record<string, any> = isAzureMonorepoPackage(model)
55
- ? buildAzureMonorepoPackage(extendedConfig)
56
- : buildAzureStandalonePackage(extendedConfig);
45
+ const packageInfo: Record<string, any> = buildAzureMonorepoPackage(extendedConfig);
57
46
 
58
47
  const project = new Project({ useInMemoryFileSystem: true });
59
48
  const filePath = "package.json";
@@ -89,8 +78,6 @@ export function updatePackageFile(
89
78
  const needsLroUpdate = hasLro;
90
79
  const needsExportsUpdate = exports;
91
80
  const needsConstantPathsUpdate = clientContextPaths && clientContextPaths.length > 0;
92
- const needsPlatformImportsUpdate =
93
- model.options?.azureSdkForJs && model.options?.moduleKind === "esm";
94
81
 
95
82
  let packageInfo;
96
83
  if (typeof existingFilePathOrContent === "string") {
@@ -116,57 +103,33 @@ export function updatePackageFile(
116
103
  needsCoreClientUpdate = true;
117
104
  }
118
105
 
119
- // Early return if nothing needs to be updated
120
- if (
121
- !needsLroUpdate &&
122
- !needsExportsUpdate &&
123
- !needsConstantPathsUpdate &&
124
- !needsPlatformImportsUpdate &&
125
- !needsCoreClientUpdate
126
- ) {
127
- return;
128
- }
129
-
130
106
  // Ensure warp packages have #platform/* imports for polyfill resolution.
131
107
  // The `react-native` condition is only added when explicitly opted in via
132
108
  // `generateReactNativeTarget`, matching the fresh-generation path in
133
109
  // `getEsmEntrypointInformation` (packageCommon.ts).
134
- if (needsPlatformImportsUpdate) {
135
- const platformImports: Record<string, string> = {
136
- browser: "./src/*-browser.mts",
137
- default: "./src/*.ts",
110
+ const platformImports: Record<string, string> = {
111
+ browser: "./src/*-browser.mts",
112
+ default: "./src/*.ts",
113
+ };
114
+ if (model.options?.generateReactNativeTarget) {
115
+ // Insert `react-native` before `default` so Node's conditional
116
+ // resolution order matches the fresh-generation output.
117
+ packageInfo.imports = {
118
+ "#platform/*": {
119
+ browser: platformImports["browser"],
120
+ "react-native": "./src/*-react-native.mts",
121
+ default: platformImports["default"],
122
+ },
123
+ };
124
+ } else {
125
+ packageInfo.imports = {
126
+ "#platform/*": platformImports,
138
127
  };
139
- if (model.options?.generateReactNativeTarget) {
140
- // Insert `react-native` before `default` so Node's conditional
141
- // resolution order matches the fresh-generation output.
142
- packageInfo.imports = {
143
- "#platform/*": {
144
- browser: platformImports["browser"],
145
- "react-native": "./src/*-react-native.mts",
146
- default: platformImports["default"],
147
- },
148
- };
149
- } else {
150
- packageInfo.imports = {
151
- "#platform/*": platformImports,
152
- };
153
- }
154
128
  }
155
129
 
156
- // Update exports based on build system (warp for monorepo, tshy for others)
130
+ // Update exports (warp: resolved exports in package.json)
157
131
  if (needsExportsUpdate) {
158
- if (model.options?.azureSdkForJs) {
159
- // Warp: update resolved exports in package.json
160
- packageInfo.exports = resolveWarpExports(exports, model.options?.generateReactNativeTarget);
161
- } else if (packageInfo.tshy) {
162
- // Tshy: update tshy.exports in package.json
163
- const newTshy = getTshyConfig({
164
- exports,
165
- azureSdkForJs: model.options?.azureSdkForJs,
166
- generateReactNativeTarget: model.options?.generateReactNativeTarget,
167
- } as PackageCommonInfoConfig);
168
- packageInfo.tshy["exports"] = newTshy["exports"];
169
- }
132
+ packageInfo.exports = resolveWarpExports(exports, model.options?.generateReactNativeTarget);
170
133
  }
171
134
 
172
135
  // Update Core Client dependency