@azure-tools/typespec-ts 0.41.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/src/modular/buildOperations.d.ts.map +1 -1
  3. package/dist/src/modular/buildOperations.js.map +1 -1
  4. package/dist/src/modular/emitSamples.js +18 -39
  5. package/dist/src/modular/emitSamples.js.map +1 -1
  6. package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
  7. package/dist/src/modular/helpers/typeHelpers.js +3 -2
  8. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  9. package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
  10. package/dist/src/transform/transformApiVersionInfo.js +5 -43
  11. package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
  12. package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
  13. package/dist/src/transform/transformHelperFunctionDetails.js +13 -58
  14. package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
  15. package/dist/src/transform/transformParameters.d.ts.map +1 -1
  16. package/dist/src/transform/transformParameters.js +5 -17
  17. package/dist/src/transform/transformParameters.js.map +1 -1
  18. package/dist/src/transform/transformPaths.d.ts.map +1 -1
  19. package/dist/src/transform/transformPaths.js +5 -17
  20. package/dist/src/transform/transformPaths.js.map +1 -1
  21. package/dist/src/transform/transformResponses.d.ts.map +1 -1
  22. package/dist/src/transform/transformResponses.js +5 -17
  23. package/dist/src/transform/transformResponses.js.map +1 -1
  24. package/dist/src/transform/transformSchemas.d.ts.map +1 -1
  25. package/dist/src/transform/transformSchemas.js +5 -17
  26. package/dist/src/transform/transformSchemas.js.map +1 -1
  27. package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
  28. package/dist/src/transform/transformTelemetryInfo.js +4 -14
  29. package/dist/src/transform/transformTelemetryInfo.js.map +1 -1
  30. package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
  31. package/dist/src/transform/transfromRLCOptions.js +4 -19
  32. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  33. package/dist/src/utils/clientUtils.d.ts +2 -0
  34. package/dist/src/utils/clientUtils.d.ts.map +1 -1
  35. package/dist/src/utils/clientUtils.js +34 -5
  36. package/dist/src/utils/clientUtils.js.map +1 -1
  37. package/dist/src/utils/modelUtils.js +1 -1
  38. package/dist/src/utils/modelUtils.js.map +1 -1
  39. package/dist/src/utils/operationUtil.d.ts.map +1 -1
  40. package/dist/src/utils/operationUtil.js +8 -37
  41. package/dist/src/utils/operationUtil.js.map +1 -1
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +22 -22
  44. package/src/modular/buildOperations.ts +0 -1
  45. package/src/modular/emitSamples.ts +53 -38
  46. package/src/modular/helpers/typeHelpers.ts +5 -2
  47. package/src/transform/transformApiVersionInfo.ts +3 -51
  48. package/src/transform/transformHelperFunctionDetails.ts +10 -71
  49. package/src/transform/transformParameters.ts +4 -21
  50. package/src/transform/transformPaths.ts +4 -21
  51. package/src/transform/transformResponses.ts +3 -20
  52. package/src/transform/transformSchemas.ts +4 -21
  53. package/src/transform/transformTelemetryInfo.ts +3 -20
  54. package/src/transform/transfromRLCOptions.ts +7 -25
  55. package/src/utils/clientUtils.ts +53 -5
  56. package/src/utils/modelUtils.ts +1 -1
  57. package/src/utils/operationUtil.ts +5 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-ts",
3
- "version": "0.41.0",
3
+ "version": "0.41.1",
4
4
  "description": "An experimental TypeSpec emitter for TypeScript RLC",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -18,14 +18,14 @@
18
18
  "license": "MIT",
19
19
  "devDependencies": {
20
20
  "@azure-rest/core-client": "^2.3.1",
21
- "@typespec/http-specs": "0.1.0-alpha.22",
22
- "@typespec/spector": "0.1.0-alpha.14",
23
- "@typespec/spec-api": "0.1.0-alpha.6",
24
- "@azure-tools/azure-http-specs": "^0.1.0-alpha.18",
25
- "@azure-tools/typespec-autorest": "^0.56.0",
26
- "@azure-tools/typespec-azure-core": "^0.56.0",
27
- "@azure-tools/typespec-azure-resource-manager": "^0.56.2",
28
- "@azure-tools/typespec-client-generator-core": "^0.56.2",
21
+ "@typespec/http-specs": "0.1.0-alpha.24-dev.0",
22
+ "@typespec/spector": "0.1.0-alpha.16-dev.0",
23
+ "@typespec/spec-api": "0.1.0-alpha.7-dev.0",
24
+ "@azure-tools/azure-http-specs": "0.1.0-alpha.20-dev.0",
25
+ "@azure-tools/typespec-autorest": "^0.57.0",
26
+ "@azure-tools/typespec-azure-core": "^0.57.0",
27
+ "@azure-tools/typespec-azure-resource-manager": "^0.57.0",
28
+ "@azure-tools/typespec-client-generator-core": "^0.57.1",
29
29
  "@azure/abort-controller": "^2.1.2",
30
30
  "@azure/core-auth": "^1.6.0",
31
31
  "@azure/core-lro": "^3.1.0",
@@ -40,12 +40,12 @@
40
40
  "@types/node": "^18.0.0",
41
41
  "@typescript-eslint/eslint-plugin": "^8.28.0",
42
42
  "@typescript-eslint/parser": "^8.28.0",
43
- "@typespec/compiler": "^1.0.0",
44
- "@typespec/http": "^1.0.1",
45
- "@typespec/openapi": "^1.0.0",
46
- "@typespec/rest": "^0.70.0",
43
+ "@typespec/compiler": "^1.1.0",
44
+ "@typespec/http": "^1.1.0",
45
+ "@typespec/openapi": "^1.1.0",
46
+ "@typespec/rest": "^0.71.0",
47
47
  "@typespec/ts-http-runtime": "^0.1.0",
48
- "@typespec/versioning": "^0.70.0",
48
+ "@typespec/versioning": "^0.71.0",
49
49
  "chai": "^4.3.6",
50
50
  "chalk": "^4.0.0",
51
51
  "cross-env": "^7.0.3",
@@ -67,16 +67,16 @@
67
67
  "js-yaml": "^4.1.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@azure-tools/typespec-azure-core": "^0.56.0",
71
- "@azure-tools/typespec-client-generator-core": "^0.56.2",
72
- "@typespec/compiler": "^1.0.0",
73
- "@typespec/http": "^1.0.1",
74
- "@typespec/rest": "^0.70.0",
75
- "@typespec/versioning": "^0.70.0",
76
- "@typespec/xml": "^0.70.0"
70
+ "@azure-tools/typespec-azure-core": "^0.57.0",
71
+ "@azure-tools/typespec-client-generator-core": "^0.57.1",
72
+ "@typespec/compiler": "^1.1.0",
73
+ "@typespec/http": "^1.1.0",
74
+ "@typespec/rest": "^0.71.0",
75
+ "@typespec/versioning": "^0.71.0",
76
+ "@typespec/xml": "^0.71.0"
77
77
  },
78
78
  "dependencies": {
79
- "@azure-tools/rlc-common": "^0.41.0",
79
+ "@azure-tools/rlc-common": "^0.41.1",
80
80
  "fs-extra": "^11.1.0",
81
81
  "lodash": "^4.17.21",
82
82
  "prettier": "^3.3.3",
@@ -161,7 +161,6 @@ export function buildOperationOptions(
161
161
  return {
162
162
  docs: getDocsFromDescription(p.doc),
163
163
  hasQuestionToken: true,
164
-
165
164
  type: getTypeExpression(context, p.type),
166
165
  name: normalizeName(p.name, NameType.Parameter)
167
166
  };
@@ -237,13 +237,25 @@ function emitMethodSamples(
237
237
  function buildParameterValueMap(example: SdkHttpOperationExample) {
238
238
  const parameterMap: Record<string, SdkHttpParameterExampleValue> = {};
239
239
  example.parameters.forEach(
240
- (param) =>
241
- (parameterMap[param.parameter.serializedName ?? param.parameter.name] =
242
- param)
240
+ (param) => (parameterMap[param.parameter.serializedName] = param)
243
241
  );
244
242
  return parameterMap;
245
243
  }
246
244
 
245
+ function prepareExampleValue(
246
+ name: string,
247
+ value: SdkExampleValue | string,
248
+ isOptional?: boolean,
249
+ onClient?: boolean
250
+ ): ExampleValue {
251
+ return {
252
+ name: normalizeName(name, NameType.Parameter),
253
+ value: typeof value === "string" ? value : getParameterValue(value),
254
+ isOptional: Boolean(isOptional),
255
+ onClient: Boolean(onClient)
256
+ };
257
+ }
258
+
247
259
  function prepareExampleParameters(
248
260
  dpgContext: SdkContext,
249
261
  method: ServiceOperation,
@@ -294,25 +306,24 @@ function prepareExampleParameters(
294
306
  subscriptionIdValue = getParameterValue(exampleValue.value);
295
307
  continue;
296
308
  }
297
- result.push({
298
- name: exampleValue.parameter.name,
299
- value: getParameterValue(exampleValue.value),
300
- isOptional: Boolean(param.optional),
301
- onClient: Boolean(param.onClient)
302
- });
309
+ result.push(
310
+ prepareExampleValue(
311
+ exampleValue.parameter.name,
312
+ exampleValue.value,
313
+ param.optional,
314
+ param.onClient
315
+ )
316
+ );
303
317
  }
304
318
  // add subscriptionId for ARM clients if ARM clients need it
305
319
  if (dpgContext.arm && getSubscriptionId(dpgContext)) {
306
- result.push({
307
- name: "subscriptionId",
308
- value: subscriptionIdValue,
309
- isOptional: false,
310
- onClient: true
311
- });
320
+ result.push(
321
+ prepareExampleValue("subscriptionId", subscriptionIdValue, false, true)
322
+ );
312
323
  }
313
324
  // required/optional body parameters
314
325
  const bodyParam = method.operation.bodyParam;
315
- const bodyName = bodyParam?.name;
326
+ const bodyName = bodyParam?.serializedName;
316
327
  const bodyExample = parameterMap[bodyName ?? ""];
317
328
  if (bodyName && bodyExample && bodyExample.value) {
318
329
  if (
@@ -325,20 +336,24 @@ function prepareExampleParameters(
325
336
  if (!propExample) {
326
337
  continue;
327
338
  }
328
- result.push({
329
- name: prop.name,
330
- value: getParameterValue(propExample),
331
- isOptional: Boolean(prop.optional),
332
- onClient: Boolean(prop.onClient)
333
- });
339
+ result.push(
340
+ prepareExampleValue(
341
+ prop.name,
342
+ propExample,
343
+ prop.optional,
344
+ prop.onClient
345
+ )
346
+ );
334
347
  }
335
348
  } else {
336
- result.push({
337
- name: bodyName,
338
- value: getParameterValue(bodyExample.value),
339
- isOptional: Boolean(method.operation.bodyParam?.optional),
340
- onClient: Boolean(method.operation.bodyParam?.onClient)
341
- });
349
+ result.push(
350
+ prepareExampleValue(
351
+ bodyName,
352
+ bodyExample.value,
353
+ bodyParam.optional,
354
+ bodyParam.onClient
355
+ )
356
+ );
342
357
  }
343
358
  }
344
359
  // optional parameters
@@ -351,12 +366,14 @@ function prepareExampleParameters(
351
366
  )
352
367
  .map((param) => parameterMap[param.serializedName]!)
353
368
  .forEach((param) => {
354
- result.push({
355
- name: param.parameter.name,
356
- value: getParameterValue(param.value),
357
- isOptional: true,
358
- onClient: Boolean(param.parameter.onClient)
359
- });
369
+ result.push(
370
+ prepareExampleValue(
371
+ param.parameter.name,
372
+ param.value,
373
+ true,
374
+ param.parameter.onClient
375
+ )
376
+ );
360
377
  });
361
378
 
362
379
  return result;
@@ -428,7 +445,7 @@ function getParameterValue(value: SdkExampleValue): string {
428
445
  case "null":
429
446
  case "unknown":
430
447
  case "union":
431
- retValue = `${value.value}`;
448
+ retValue = `${JSON.stringify(value.value)}`;
432
449
  break;
433
450
  case "dict":
434
451
  case "model": {
@@ -455,9 +472,7 @@ function getParameterValue(value: SdkExampleValue): string {
455
472
  break;
456
473
  }
457
474
  case "array": {
458
- const valuesArr = value.value.map((element) =>
459
- getParameterValue(element)
460
- );
475
+ const valuesArr = value.value.map(getParameterValue);
461
476
  retValue = `[${valuesArr.join(", ")}]`;
462
477
  break;
463
478
  }
@@ -1,3 +1,4 @@
1
+ import { NameType, normalizeName } from "@azure-tools/rlc-common";
1
2
  import {
2
3
  SdkBodyParameter,
3
4
  SdkModelPropertyType,
@@ -88,8 +89,10 @@ export function buildPropertyNameMapper(model: SdkType) {
88
89
  if (prop.kind !== "property") {
89
90
  continue;
90
91
  }
91
- // eslint-disable-next-line
92
- mapper.set(prop.serializedName, prop.name);
92
+ mapper.set(
93
+ prop.serializationOptions.json?.name || prop.name,
94
+ normalizeName(prop.name, NameType.Property)
95
+ );
93
96
  }
94
97
  return mapper;
95
98
  }
@@ -9,8 +9,6 @@ import {
9
9
  import {
10
10
  getHttpOperationWithCache,
11
11
  isApiVersion,
12
- listOperationGroups,
13
- listOperationsInOperationGroup,
14
12
  SdkClient
15
13
  } from "@azure-tools/typespec-client-generator-core";
16
14
  import { SdkContext } from "../utils/interfaces.js";
@@ -19,6 +17,7 @@ import {
19
17
  getSchemaForType,
20
18
  trimUsage
21
19
  } from "../utils/modelUtils.js";
20
+ import { listOperationsUnderRLCClient } from "../utils/clientUtils.js";
22
21
 
23
22
  export function transformApiVersionInfo(
24
23
  client: SdkClient,
@@ -65,12 +64,11 @@ export function getOperationApiVersion(
65
64
  const apiVersionTypes = new Set<string>();
66
65
  const locations = new Set<ApiVersionPosition>();
67
66
  const required = new Set<boolean>();
68
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
69
67
  dpgContext.hasApiVersionInClient = true;
70
68
  let hasApiVersionInOperation = true;
71
- for (const clientOp of clientOperations) {
69
+ for (const op of listOperationsUnderRLCClient(client)) {
72
70
  hasApiVersionInOperation = false;
73
- const route = getHttpOperationWithCache(dpgContext, clientOp);
71
+ const route = getHttpOperationWithCache(dpgContext, op);
74
72
  // ignore overload base operation
75
73
  if (route.overloads && route.overloads?.length > 0) {
76
74
  continue;
@@ -102,52 +100,6 @@ export function getOperationApiVersion(
102
100
  dpgContext.hasApiVersionInClient = false;
103
101
  }
104
102
  }
105
- const operationGroups = listOperationGroups(dpgContext, client, true);
106
- for (const operationGroup of operationGroups) {
107
- const operations = listOperationsInOperationGroup(
108
- dpgContext,
109
- operationGroup
110
- );
111
- for (const op of operations) {
112
- hasApiVersionInOperation = false;
113
- const route = getHttpOperationWithCache(dpgContext, op);
114
- // ignore overload base operation
115
- if (route.overloads && route.overloads?.length > 0) {
116
- continue;
117
- }
118
- const params = route.parameters.parameters.filter(
119
- (p) =>
120
- (p.type === "query" || p.type === "path") &&
121
- isApiVersion(dpgContext, p)
122
- );
123
- params.map((p) => {
124
- const type = getSchemaForType(dpgContext, p.param.type, {
125
- usage: [SchemaContext.Exception, SchemaContext.Input],
126
- needRef: false,
127
- relevantProperty: p.param
128
- });
129
- required.add(!p.param.optional);
130
- if (p.type === "query" || p.type === "path") {
131
- locations.add(p.type);
132
- }
133
- const typeString = JSON.stringify(trimUsage(type));
134
- apiVersionTypes.add(typeString);
135
- });
136
- if (
137
- apiVersionTypes.size > 1 ||
138
- !dpgContext.hasApiVersionInClient ||
139
- required.size > 1
140
- ) {
141
- break;
142
- }
143
- if (params.length === 1) {
144
- hasApiVersionInOperation = true;
145
- }
146
- if (!hasApiVersionInOperation) {
147
- dpgContext.hasApiVersionInClient = false;
148
- }
149
- }
150
- }
151
103
  // If no api-version parameter defined return directly
152
104
  if (apiVersionTypes.size === 0 || !dpgContext.hasApiVersionInClient) {
153
105
  return;
@@ -1,8 +1,6 @@
1
1
  import { HelperFunctionDetails, PackageFlavor } from "@azure-tools/rlc-common";
2
2
  import {
3
3
  getHttpOperationWithCache,
4
- listOperationGroups,
5
- listOperationsInOperationGroup,
6
4
  SdkClient
7
5
  } from "@azure-tools/typespec-client-generator-core";
8
6
  import { Model, Program, Type } from "@typespec/compiler";
@@ -17,6 +15,7 @@ import {
17
15
  parseNextLinkName
18
16
  } from "../utils/operationUtil.js";
19
17
  import { getCollectionFormat } from "../utils/modelUtils.js";
18
+ import { listOperationsUnderRLCClient } from "../utils/clientUtils.js";
20
19
 
21
20
  export function transformHelperFunctionDetails(
22
21
  client: SdkClient,
@@ -48,9 +47,8 @@ export function transformHelperFunctionDetails(
48
47
  }
49
48
  // TODO: Remove this when @pageable is finally removed.
50
49
  const nextLinks = new Set<string>();
51
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
52
- for (const clientOp of clientOperations) {
53
- const route = getHttpOperationWithCache(dpgContext, clientOp);
50
+ for (const op of listOperationsUnderRLCClient(client)) {
51
+ const route = getHttpOperationWithCache(dpgContext, op);
54
52
  // ignore overload base operation
55
53
  if (route.overloads && route.overloads?.length > 0) {
56
54
  continue;
@@ -62,27 +60,6 @@ export function transformHelperFunctionDetails(
62
60
  }
63
61
  }
64
62
  }
65
- const operationGroups = listOperationGroups(dpgContext, client, true);
66
- for (const operationGroup of operationGroups) {
67
- const operations = listOperationsInOperationGroup(
68
- dpgContext,
69
- operationGroup
70
- );
71
- for (const op of operations) {
72
- const route = getHttpOperationWithCache(dpgContext, op);
73
- // ignore overload base operation
74
- if (route.overloads && route.overloads?.length > 0) {
75
- continue;
76
- }
77
- if (getPageable(program, route.operation)) {
78
- const nextLinkName =
79
- getPageable(program, route.operation) || "nextLink";
80
- if (nextLinkName) {
81
- nextLinks.add(nextLinkName);
82
- }
83
- }
84
- }
85
- }
86
63
  if (nextLinks.size === 0) {
87
64
  return {
88
65
  ...annotationDetails,
@@ -118,30 +95,14 @@ function extractPageDetailFromCore(client: SdkClient, dpgContext: SdkContext) {
118
95
  // Add default values
119
96
  nextLinks.add("nextLink");
120
97
  itemNames.add("value");
121
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
122
- for (const clientOp of clientOperations) {
123
- const route = getHttpOperationWithCache(dpgContext, clientOp);
98
+ for (const op of listOperationsUnderRLCClient(client)) {
99
+ const route = getHttpOperationWithCache(dpgContext, op);
124
100
  // ignore overload base operation
125
101
  if (route.overloads && route.overloads?.length > 0) {
126
102
  continue;
127
103
  }
128
104
  extractPageDetailFromCoreForRoute(route);
129
105
  }
130
- const operationGroups = listOperationGroups(dpgContext, client, true);
131
- for (const operationGroup of operationGroups) {
132
- const operations = listOperationsInOperationGroup(
133
- dpgContext,
134
- operationGroup
135
- );
136
- for (const op of operations) {
137
- const route = getHttpOperationWithCache(dpgContext, op);
138
- // ignore overload base operation
139
- if (route.overloads && route.overloads?.length > 0) {
140
- continue;
141
- }
142
- extractPageDetailFromCoreForRoute(route);
143
- }
144
- }
145
106
 
146
107
  function extractPageDetailFromCoreForRoute(route: HttpOperation) {
147
108
  for (const response of route.responses) {
@@ -179,9 +140,8 @@ function extractSpecialSerializeInfo(
179
140
  ) {
180
141
  let hasMultiCollection = false;
181
142
  let hasCsvCollection = false;
182
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
183
- for (const clientOp of clientOperations) {
184
- const route = getHttpOperationWithCache(dpgContext, clientOp);
143
+ for (const op of listOperationsUnderRLCClient(client)) {
144
+ const route = getHttpOperationWithCache(dpgContext, op);
185
145
  route.parameters.parameters.forEach((parameter) => {
186
146
  const format = getCollectionFormat(dpgContext, parameter as any);
187
147
  const serializeInfo = getSpecialSerializeInfo(
@@ -192,32 +152,11 @@ function extractSpecialSerializeInfo(
192
152
  hasMultiCollection = hasMultiCollection
193
153
  ? hasMultiCollection
194
154
  : serializeInfo.hasMultiCollection;
155
+ hasCsvCollection = hasCsvCollection
156
+ ? hasCsvCollection
157
+ : serializeInfo.hasCsvCollection;
195
158
  });
196
159
  }
197
- const operationGroups = listOperationGroups(dpgContext, client, true);
198
- for (const operationGroup of operationGroups) {
199
- const operations = listOperationsInOperationGroup(
200
- dpgContext,
201
- operationGroup
202
- );
203
- for (const op of operations) {
204
- const route = getHttpOperationWithCache(dpgContext, op);
205
- route.parameters.parameters.forEach((parameter) => {
206
- const format = getCollectionFormat(dpgContext, parameter as any);
207
- const serializeInfo = getSpecialSerializeInfo(
208
- dpgContext,
209
- parameter.type,
210
- format!
211
- );
212
- hasMultiCollection = hasMultiCollection
213
- ? hasMultiCollection
214
- : serializeInfo.hasMultiCollection;
215
- hasCsvCollection = hasCsvCollection
216
- ? hasCsvCollection
217
- : serializeInfo.hasCsvCollection;
218
- });
219
- }
220
- }
221
160
  return {
222
161
  hasMultiCollection,
223
162
  hasCsvCollection
@@ -25,9 +25,7 @@ import {
25
25
  import {
26
26
  SdkClient,
27
27
  getHttpOperationWithCache,
28
- isApiVersion,
29
- listOperationGroups,
30
- listOperationsInOperationGroup
28
+ isApiVersion
31
29
  } from "@azure-tools/typespec-client-generator-core";
32
30
  import { NoTarget, Type, isVoidType } from "@typespec/compiler";
33
31
  import {
@@ -48,6 +46,7 @@ import {
48
46
  import { SdkContext } from "../utils/interfaces.js";
49
47
  import { getParameterSerializationInfo } from "../utils/parameterUtils.js";
50
48
  import { reportDiagnostic } from "../lib.js";
49
+ import { listOperationsUnderRLCClient } from "../utils/clientUtils.js";
51
50
 
52
51
  interface ParameterTransformationOptions {
53
52
  apiVersionInfo?: ApiVersionInfo;
@@ -64,30 +63,14 @@ export function transformToParameterTypes(
64
63
  ): OperationParameter[] {
65
64
  const rlcParameters: OperationParameter[] = [];
66
65
  const outputImportedSet = new Set<string>();
67
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
68
- for (const clientOp of clientOperations) {
69
- const route = getHttpOperationWithCache(dpgContext, clientOp);
66
+ for (const op of listOperationsUnderRLCClient(client)) {
67
+ const route = getHttpOperationWithCache(dpgContext, op);
70
68
  // ignore overload base operation
71
69
  if (route.overloads && route.overloads?.length > 0) {
72
70
  continue;
73
71
  }
74
72
  transformToParameterTypesForRoute(route);
75
73
  }
76
- const operationGroups = listOperationGroups(dpgContext, client, true);
77
- for (const operationGroup of operationGroups) {
78
- const operations = listOperationsInOperationGroup(
79
- dpgContext,
80
- operationGroup
81
- );
82
- for (const op of operations) {
83
- const route = getHttpOperationWithCache(dpgContext, op);
84
- // ignore overload base operation
85
- if (route.overloads && route.overloads?.length > 0) {
86
- continue;
87
- }
88
- transformToParameterTypesForRoute(route);
89
- }
90
- }
91
74
 
92
75
  if (outputImportedSet.size > 0) {
93
76
  importDetails.parameter.importsSet = outputImportedSet;
@@ -14,9 +14,7 @@ import {
14
14
  import {
15
15
  SdkClient,
16
16
  getHttpOperationWithCache,
17
- isApiVersion,
18
- listOperationGroups,
19
- listOperationsInOperationGroup
17
+ isApiVersion
20
18
  } from "@azure-tools/typespec-client-generator-core";
21
19
  import {
22
20
  extractOperationLroDetail,
@@ -37,6 +35,7 @@ import {
37
35
  import { SdkContext } from "../utils/interfaces.js";
38
36
  import { getDoc } from "@typespec/compiler";
39
37
  import { getParameterSerializationInfo } from "../utils/parameterUtils.js";
38
+ import { listOperationsUnderRLCClient } from "../utils/clientUtils.js";
40
39
 
41
40
  export function transformPaths(
42
41
  client: SdkClient,
@@ -45,30 +44,14 @@ export function transformPaths(
45
44
  ): Paths {
46
45
  const pathParamsImportedSet = new Set<string>();
47
46
  const paths: Paths = {};
48
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
49
- for (const clientOp of clientOperations) {
50
- const route = getHttpOperationWithCache(dpgContext, clientOp);
47
+ for (const op of listOperationsUnderRLCClient(client)) {
48
+ const route = getHttpOperationWithCache(dpgContext, op);
51
49
  // ignore overload base operation
52
50
  if (route.overloads && route.overloads?.length > 0) {
53
51
  continue;
54
52
  }
55
53
  transformOperation(dpgContext, route, paths, pathParamsImportedSet);
56
54
  }
57
- const operationGroups = listOperationGroups(dpgContext, client, true);
58
- for (const operationGroup of operationGroups) {
59
- const operations = listOperationsInOperationGroup(
60
- dpgContext,
61
- operationGroup
62
- );
63
- for (const op of operations) {
64
- const route = getHttpOperationWithCache(dpgContext, op);
65
- // ignore overload base operation
66
- if (route.overloads && route.overloads?.length > 0) {
67
- continue;
68
- }
69
- transformOperation(dpgContext, route, paths, pathParamsImportedSet);
70
- }
71
- }
72
55
 
73
56
  if (pathParamsImportedSet.size > 0) {
74
57
  importDetails.rlcClientDefinition.importsSet = pathParamsImportedSet;
@@ -12,8 +12,6 @@ import {
12
12
  } from "@azure-tools/rlc-common";
13
13
  import {
14
14
  getHttpOperationWithCache,
15
- listOperationGroups,
16
- listOperationsInOperationGroup,
17
15
  SdkClient
18
16
  } from "@azure-tools/typespec-client-generator-core";
19
17
  import { getDoc, isVoidType } from "@typespec/compiler";
@@ -33,6 +31,7 @@ import {
33
31
  isBinaryPayload,
34
32
  sortedOperationResponses
35
33
  } from "../utils/operationUtil.js";
34
+ import { listOperationsUnderRLCClient } from "../utils/clientUtils.js";
36
35
 
37
36
  export function transformToResponseTypes(
38
37
  client: SdkClient,
@@ -41,30 +40,14 @@ export function transformToResponseTypes(
41
40
  ): OperationResponse[] {
42
41
  const rlcResponses: OperationResponse[] = [];
43
42
  const inputImportedSet = new Set<string>();
44
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
45
- for (const clientOp of clientOperations) {
46
- const route = getHttpOperationWithCache(dpgContext, clientOp);
43
+ for (const op of listOperationsUnderRLCClient(client)) {
44
+ const route = getHttpOperationWithCache(dpgContext, op);
47
45
  // ignore overload base operation
48
46
  if (route.overloads && route.overloads?.length > 0) {
49
47
  continue;
50
48
  }
51
49
  transformToResponseTypesForRoute(route);
52
50
  }
53
- const operationGroups = listOperationGroups(dpgContext, client, true);
54
- for (const operationGroup of operationGroups) {
55
- const operations = listOperationsInOperationGroup(
56
- dpgContext,
57
- operationGroup
58
- );
59
- for (const op of operations) {
60
- const route = getHttpOperationWithCache(dpgContext, op);
61
- // ignore overload base operation
62
- if (route.overloads && route.overloads?.length > 0) {
63
- continue;
64
- }
65
- transformToResponseTypesForRoute(route);
66
- }
67
- }
68
51
  if (inputImportedSet.size > 0) {
69
52
  importDetails.response.importsSet = inputImportedSet;
70
53
  }
@@ -6,9 +6,7 @@ import { KnownMediaType, extractMediaTypes } from "../utils/mediaTypes.js";
6
6
  import { Model, Type } from "@typespec/compiler";
7
7
  import {
8
8
  SdkClient,
9
- getHttpOperationWithCache,
10
- listOperationGroups,
11
- listOperationsInOperationGroup
9
+ getHttpOperationWithCache
12
10
  } from "@azure-tools/typespec-client-generator-core";
13
11
  import {
14
12
  getBodyType,
@@ -22,6 +20,7 @@ import {
22
20
  import { SchemaContext } from "@azure-tools/rlc-common";
23
21
  import { SdkContext } from "../utils/interfaces.js";
24
22
  import { useContext } from "../contextManager.js";
23
+ import { listOperationsUnderRLCClient } from "../utils/clientUtils.js";
25
24
 
26
25
  export function transformSchemas(client: SdkClient, dpgContext: SdkContext) {
27
26
  const program = dpgContext.program;
@@ -34,30 +33,14 @@ export function transformSchemas(client: SdkClient, dpgContext: SdkContext) {
34
33
  const usageMap = new Map<Type, SchemaContext[]>();
35
34
  const requestBodySet = new Set<Type>();
36
35
  const contentTypeMap = new Map<Type, KnownMediaType[]>();
37
- const clientOperations = listOperationsInOperationGroup(dpgContext, client);
38
- for (const clientOp of clientOperations) {
39
- const route = getHttpOperationWithCache(dpgContext, clientOp);
36
+ for (const op of listOperationsUnderRLCClient(client)) {
37
+ const route = getHttpOperationWithCache(dpgContext, op);
40
38
  // ignore overload base operation
41
39
  if (route.overloads && route.overloads?.length > 0) {
42
40
  continue;
43
41
  }
44
42
  transformSchemaForRoute(route);
45
43
  }
46
- const operationGroups = listOperationGroups(dpgContext, client, true);
47
- for (const operationGroup of operationGroups) {
48
- const operations = listOperationsInOperationGroup(
49
- dpgContext,
50
- operationGroup
51
- );
52
- for (const op of operations) {
53
- const route = getHttpOperationWithCache(dpgContext, op);
54
- // ignore overload base operation
55
- if (route.overloads && route.overloads?.length > 0) {
56
- continue;
57
- }
58
- transformSchemaForRoute(route);
59
- }
60
- }
61
44
  function transformSchemaForRoute(route: HttpOperation) {
62
45
  if (route.parameters) {
63
46
  for (const param of route.parameters.parameters) {