@azure-tools/typespec-ts 0.19.0 → 0.20.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 (93) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/src/index.d.ts.map +1 -1
  3. package/dist/src/index.js +8 -4
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/lib.d.ts +28 -1
  6. package/dist/src/lib.d.ts.map +1 -1
  7. package/dist/src/lib.js +18 -0
  8. package/dist/src/lib.js.map +1 -1
  9. package/dist/src/modular/buildClassicalClient.js +9 -0
  10. package/dist/src/modular/buildClassicalClient.js.map +1 -1
  11. package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
  12. package/dist/src/modular/buildClassicalOperationGroups.js +5 -1
  13. package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
  14. package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
  15. package/dist/src/modular/buildCodeModel.js +81 -65
  16. package/dist/src/modular/buildCodeModel.js.map +1 -1
  17. package/dist/src/modular/buildOperations.d.ts +1 -0
  18. package/dist/src/modular/buildOperations.d.ts.map +1 -1
  19. package/dist/src/modular/buildOperations.js +30 -13
  20. package/dist/src/modular/buildOperations.js.map +1 -1
  21. package/dist/src/modular/buildPagingFiles.d.ts +4 -0
  22. package/dist/src/modular/buildPagingFiles.d.ts.map +1 -0
  23. package/dist/src/modular/buildPagingFiles.js +333 -0
  24. package/dist/src/modular/buildPagingFiles.js.map +1 -0
  25. package/dist/src/modular/buildProjectFiles.d.ts.map +1 -1
  26. package/dist/src/modular/buildProjectFiles.js +15 -8
  27. package/dist/src/modular/buildProjectFiles.js.map +1 -1
  28. package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
  29. package/dist/src/modular/buildSubpathIndex.js +10 -1
  30. package/dist/src/modular/buildSubpathIndex.js.map +1 -1
  31. package/dist/src/modular/emitModels.d.ts +21 -2
  32. package/dist/src/modular/emitModels.d.ts.map +1 -1
  33. package/dist/src/modular/emitModels.js +26 -5
  34. package/dist/src/modular/emitModels.js.map +1 -1
  35. package/dist/src/modular/helpers/operationHelpers.d.ts +7 -4
  36. package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
  37. package/dist/src/modular/helpers/operationHelpers.js +135 -99
  38. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  39. package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
  40. package/dist/src/modular/helpers/typeHelpers.js +2 -1
  41. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  42. package/dist/src/modular/modularCodeModel.d.ts +2 -1
  43. package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
  44. package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
  45. package/dist/src/transform/transformApiVersionInfo.js +16 -10
  46. package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
  47. package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
  48. package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
  49. package/dist/src/transform/transformHelperFunctionDetails.js +11 -16
  50. package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
  51. package/dist/src/transform/transformParameters.d.ts.map +1 -1
  52. package/dist/src/transform/transformParameters.js +19 -14
  53. package/dist/src/transform/transformParameters.js.map +1 -1
  54. package/dist/src/transform/transformResponses.js +5 -3
  55. package/dist/src/transform/transformResponses.js.map +1 -1
  56. package/dist/src/transform/transformSchemas.d.ts.map +1 -1
  57. package/dist/src/transform/transformSchemas.js +32 -17
  58. package/dist/src/transform/transformSchemas.js.map +1 -1
  59. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  60. package/dist/src/utils/emitUtil.js +1 -1
  61. package/dist/src/utils/emitUtil.js.map +1 -1
  62. package/dist/src/utils/modelUtils.d.ts +1 -0
  63. package/dist/src/utils/modelUtils.d.ts.map +1 -1
  64. package/dist/src/utils/modelUtils.js +103 -57
  65. package/dist/src/utils/modelUtils.js.map +1 -1
  66. package/dist/src/utils/operationUtil.d.ts +3 -1
  67. package/dist/src/utils/operationUtil.d.ts.map +1 -1
  68. package/dist/src/utils/operationUtil.js +21 -7
  69. package/dist/src/utils/operationUtil.js.map +1 -1
  70. package/dist/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +18 -19
  72. package/src/index.ts +20 -4
  73. package/src/lib.ts +18 -0
  74. package/src/modular/buildClassicalClient.ts +15 -0
  75. package/src/modular/buildClassicalOperationGroups.ts +17 -1
  76. package/src/modular/buildCodeModel.ts +100 -77
  77. package/src/modular/buildOperations.ts +55 -13
  78. package/src/modular/buildPagingFiles.ts +356 -0
  79. package/src/modular/buildProjectFiles.ts +17 -15
  80. package/src/modular/buildSubpathIndex.ts +12 -1
  81. package/src/modular/emitModels.ts +29 -5
  82. package/src/modular/helpers/operationHelpers.ts +130 -119
  83. package/src/modular/helpers/typeHelpers.ts +8 -6
  84. package/src/modular/modularCodeModel.ts +2 -1
  85. package/src/transform/transformApiVersionInfo.ts +25 -15
  86. package/src/transform/transformHelperFunctionDetails.ts +19 -21
  87. package/src/transform/transformParameters.ts +33 -14
  88. package/src/transform/transformResponses.ts +8 -3
  89. package/src/transform/transformSchemas.ts +33 -17
  90. package/src/transform/transfromRLCOptions.ts +2 -2
  91. package/src/utils/emitUtil.ts +1 -1
  92. package/src/utils/modelUtils.ts +119 -63
  93. package/src/utils/operationUtil.ts +26 -10
@@ -1 +1 @@
1
- {"version":3,"file":"emitModels.js","sourceRoot":"","sources":["../../../src/modular/emitModels.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,0BAA0B;AAE1B,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AAC,iBAAiB,EAAE,CAAC;IACrC,gBAAgB;SACb,qBAAqB,EAAE;SACvB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE;QACb,OAAO,CACL,EAAE,CAAC,yBAAyB,EAAE;YAC9B,CAAC,EAAE,CAAC,uBAAuB,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAC9C,CAAC;IACJ,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACV,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,uBAAuB,EAAE,GAAG,KAAK,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IACL,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { FunctionDeclarationStructure, OptionalKind } from "ts-morph";
2
- import { ModularCodeModel, Operation, Property } from "../modularCodeModel.js";
2
+ import { Client, ModularCodeModel, Operation, Property } from "../modularCodeModel.js";
3
3
  import { Imports as RuntimeImports } from "@azure-tools/rlc-common";
4
4
  import { SdkContext } from "@azure-tools/typespec-client-generator-core";
5
- export declare function getSendPrivateFunction(dpgContext: SdkContext, operation: Operation, clientType: string, importSet: Map<string, Set<string>>, runtimeImports: RuntimeImports): OptionalKind<FunctionDeclarationStructure>;
6
- export declare function getDeserializePrivateFunction(operation: Operation, needSubClient: boolean, needUnexpectedHelper: boolean, importSet: Map<string, Set<string>>, runtimeImports: RuntimeImports): OptionalKind<FunctionDeclarationStructure>;
5
+ export declare function getSendPrivateFunction(dpgContext: SdkContext, operation: Operation, clientType: string, runtimeImports: RuntimeImports): OptionalKind<FunctionDeclarationStructure>;
6
+ export declare function getDeserializePrivateFunction(operation: Operation, needSubClient: boolean, needUnexpectedHelper: boolean, runtimeImports: RuntimeImports): OptionalKind<FunctionDeclarationStructure>;
7
7
  /**
8
8
  * This operation builds and returns the function declaration for an operation.
9
9
  */
@@ -13,7 +13,10 @@ export declare function getOperationOptionsName(operation: Operation, includeGro
13
13
  * This function helps translating an RLC response to an HLC response,
14
14
  * extracting properties from body and headers and building the HLC response object
15
15
  */
16
- export declare function getResponseMapping(properties: Property[], propertyPath: string | undefined, importSet: Map<string, Set<string>>, runtimeImports: RuntimeImports): string[];
16
+ export declare function getResponseMapping(properties: Property[], propertyPath: string | undefined, runtimeImports: RuntimeImports): string[];
17
17
  export declare function hasLROOperation(codeModel: ModularCodeModel): boolean;
18
+ export declare function isLROOperation(op: Operation): boolean;
19
+ export declare function hasPagingOperation(client: Client): boolean;
18
20
  export declare function hasPagingOperation(codeModel: ModularCodeModel): boolean;
21
+ export declare function isPagingOperation(op: Operation): boolean;
19
22
  //# sourceMappingURL=operationHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operationHelpers.d.ts","sourceRoot":"","sources":["../../../../src/modular/helpers/operationHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,YAAY,EAEb,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,gBAAgB,EAChB,SAAS,EAET,QAAQ,EAET,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,OAAO,IAAI,cAAc,EAM1B,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAsBzE,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EACnC,cAAc,EAAE,cAAc,GAC7B,YAAY,CAAC,4BAA4B,CAAC,CAkC5C;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,OAAO,EACtB,oBAAoB,EAAE,OAAO,EAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EACnC,cAAc,EAAE,cAAc,GAC7B,YAAY,CAAC,4BAA4B,CAAC,CAwF5C;AAkDD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,YAAY,CAAC,4BAA4B,CAAC,CAmC5C;AACD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,EACpB,gBAAgB,UAAQ,UAWzB;AAofD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,QAAQ,EAAE,EACtB,YAAY,oBAAwB,EACpC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EACnC,cAAc,EAAE,cAAc,YA6E/B;AAgKD,wBAAgB,eAAe,CAAC,SAAS,EAAE,gBAAgB,WAQ1D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,gBAAgB,WAS7D"}
1
+ {"version":3,"file":"operationHelpers.d.ts","sourceRoot":"","sources":["../../../../src/modular/helpers/operationHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,YAAY,EAEb,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,MAAM,EACN,gBAAgB,EAChB,SAAS,EAET,QAAQ,EAET,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,OAAO,IAAI,cAAc,EAM1B,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAsBzE,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,cAAc,GAC7B,YAAY,CAAC,4BAA4B,CAAC,CAiC5C;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,OAAO,EACtB,oBAAoB,EAAE,OAAO,EAC7B,cAAc,EAAE,cAAc,GAC7B,YAAY,CAAC,4BAA4B,CAAC,CA4F5C;AAkDD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,YAAY,CAAC,4BAA4B,CAAC,CA6D5C;AAgBD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,EACpB,gBAAgB,UAAQ,UAWzB;AAydD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,QAAQ,EAAE,EACtB,YAAY,oBAAwB,EACpC,cAAc,EAAE,cAAc,YA2E/B;AAiJD,wBAAgB,eAAe,CAAC,SAAS,EAAE,gBAAgB,WAM1D;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAErD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;AAC5D,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC;AAiBzE,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAExD"}
@@ -6,7 +6,7 @@ import { getFixmeForMultilineDocs, getDocsFromDescription } from "./docsHelpers.
6
6
  import { getCollectionFormatHelper, hasCollectionFormatInfo } from "../../utils/operationUtil.js";
7
7
  import { NoTarget } from "@typespec/compiler";
8
8
  import { reportDiagnostic } from "../../lib.js";
9
- import { getImportSpecifier } from "@azure-tools/rlc-common";
9
+ import { addImportToSpecifier } from "@azure-tools/rlc-common";
10
10
  function getRLCResponseType(rlcResponse) {
11
11
  if (!(rlcResponse === null || rlcResponse === void 0 ? void 0 : rlcResponse.responses)) {
12
12
  return;
@@ -18,7 +18,7 @@ function getRLCResponseType(rlcResponse) {
18
18
  return (_a = resp.predefinedName) !== null && _a !== void 0 ? _a : getResponseTypeName(baseResponseName);
19
19
  }).join(" | ");
20
20
  }
21
- export function getSendPrivateFunction(dpgContext, operation, clientType, importSet, runtimeImports) {
21
+ export function getSendPrivateFunction(dpgContext, operation, clientType, runtimeImports) {
22
22
  const parameters = getOperationSignatureParameters(operation, clientType);
23
23
  const { name } = getOperationName(operation);
24
24
  const returnType = `StreamableMethod<${getRLCResponseType(operation.rlcResponse)}>`;
@@ -32,14 +32,14 @@ export function getSendPrivateFunction(dpgContext, operation, clientType, import
32
32
  const operationPath = operation.url;
33
33
  const operationMethod = operation.method.toLowerCase();
34
34
  const statements = [];
35
- statements.push(`return context.path("${operationPath}", ${getPathParameters(operation)}).${operationMethod}({...operationOptionsToRequestParameters(options), ${getRequestParameters(dpgContext, operation, importSet, runtimeImports)}}) ${operation.isOverload ? `as ${returnType}` : ``} ;`);
35
+ statements.push(`return context.path("${operationPath}", ${getPathParameters(operation)}).${operationMethod}({...operationOptionsToRequestParameters(options), ${getRequestParameters(dpgContext, operation, runtimeImports)}}) ${operation.isOverload ? `as ${returnType}` : ``} ;`);
36
36
  return {
37
37
  ...functionStatement,
38
38
  statements
39
39
  };
40
40
  }
41
- export function getDeserializePrivateFunction(operation, needSubClient, needUnexpectedHelper, importSet, runtimeImports) {
42
- var _a, _b, _c;
41
+ export function getDeserializePrivateFunction(operation, needSubClient, needUnexpectedHelper, runtimeImports) {
42
+ var _a, _b, _c, _d;
43
43
  const { name } = getOperationName(operation);
44
44
  const parameters = [
45
45
  {
@@ -65,7 +65,8 @@ export function getDeserializePrivateFunction(operation, needSubClient, needUnex
65
65
  };
66
66
  const statements = [];
67
67
  if (needUnexpectedHelper) {
68
- statements.push(`if(${needSubClient ? "UnexpectedHelper." : ""}isUnexpected(result)){`, "throw result.body", "}");
68
+ statements.push(`if(${needSubClient ? "UnexpectedHelper." : ""}isUnexpected(result)){`, `throw createRestError(result);`, "}");
69
+ addImportToSpecifier("restClient", runtimeImports, "createRestError");
69
70
  }
70
71
  else {
71
72
  const validStatus = [
@@ -76,20 +77,23 @@ export function getDeserializePrivateFunction(operation, needSubClient, needUnex
76
77
  if (validStatus.length > 0) {
77
78
  statements.push(`if(${validStatus
78
79
  .map((s) => `result.status !== "${s}"`)
79
- .join(" || ")}){`, "throw result.body", "}");
80
+ .join(" || ")}){`, `throw createRestError(result);`, "}");
81
+ addImportToSpecifier("restClient", runtimeImports, "createRestError");
80
82
  }
81
83
  }
82
- if (((_b = response === null || response === void 0 ? void 0 : response.type) === null || _b === void 0 ? void 0 : _b.type) === "any" || response.isBinaryPayload) {
84
+ if (((_b = response === null || response === void 0 ? void 0 : response.type) === null || _b === void 0 ? void 0 : _b.type) === "any" ||
85
+ response.isBinaryPayload ||
86
+ ((_c = response === null || response === void 0 ? void 0 : response.type) === null || _c === void 0 ? void 0 : _c.aliasType)) {
83
87
  statements.push(`return result.body`);
84
88
  }
85
89
  else if (getAllProperties(response === null || response === void 0 ? void 0 : response.type).length > 0) {
86
- statements.push(`return {`, getResponseMapping((_c = getAllProperties(response.type)) !== null && _c !== void 0 ? _c : [], "result.body", importSet, runtimeImports).join(","), `}`);
90
+ statements.push(`return {`, getResponseMapping((_d = getAllProperties(response.type)) !== null && _d !== void 0 ? _d : [], "result.body", runtimeImports).join(","), `}`);
87
91
  }
88
92
  else if (returnType.type === "void") {
89
93
  statements.push(`return;`);
90
94
  }
91
95
  else {
92
- statements.push(`return ${deserializeResponseValue(response.type, "result.body", importSet, runtimeImports, response.type.nullable !== undefined ? !response.type.nullable : false, response.type.format)}`);
96
+ statements.push(`return ${deserializeResponseValue(response.type, "result.body", runtimeImports, response.type.nullable !== undefined ? !response.type.nullable : false, response.type.format)}`);
93
97
  }
94
98
  return {
95
99
  ...functionStatement,
@@ -127,36 +131,74 @@ function getOperationSignatureParameters(operation, clientType) {
127
131
  * This operation builds and returns the function declaration for an operation.
128
132
  */
129
133
  export function getOperationFunction(operation, clientType) {
130
- var _a;
134
+ var _a, _b;
131
135
  // Extract required parameters
132
136
  const parameters = getOperationSignatureParameters(operation, clientType);
137
+ const isPaging = isPagingOperation(operation);
133
138
  // TODO: Support operation overloads
134
139
  const response = operation.responses[0];
135
- const returnType = ((_a = response === null || response === void 0 ? void 0 : response.type) === null || _a === void 0 ? void 0 : _a.type)
136
- ? buildType(response.type.name, response.type, response.type.format)
137
- : { name: "", type: "void" };
140
+ let returnType = { name: "", type: "void" };
141
+ if ((_a = response.type) === null || _a === void 0 ? void 0 : _a.type) {
142
+ let type = response.type;
143
+ if (isPaging) {
144
+ type = (_b = extractPagingType(type, operation.itemName)) !== null && _b !== void 0 ? _b : type;
145
+ }
146
+ returnType = buildType(type.name, type, type.format);
147
+ }
138
148
  const { name, fixme = [] } = getOperationName(operation);
139
149
  const functionStatement = {
140
150
  docs: [
141
151
  ...getDocsFromDescription(operation.description),
142
152
  ...getFixmeForMultilineDocs(fixme)
143
153
  ],
144
- isAsync: true,
154
+ isAsync: !isPaging,
145
155
  isExported: true,
146
156
  name: normalizeName(operation.name, NameType.Operation, true),
147
157
  parameters,
148
- returnType: `Promise<${returnType.type}>`
158
+ returnType: isPaging
159
+ ? `PagedAsyncIterableIterator<${returnType.type}>`
160
+ : `Promise<${returnType.type}>`
149
161
  };
150
162
  const statements = [];
151
- statements.push(`const result = await _${name}Send(${parameters
152
- .map((p) => p.name)
153
- .join(", ")});`);
154
- statements.push(`return _${name}Deserialize(result);`);
163
+ if (isPaging) {
164
+ const options = [];
165
+ if (operation.itemName) {
166
+ options.push(`itemName: "${operation.itemName}"`);
167
+ }
168
+ if (operation.continuationTokenName) {
169
+ options.push(`nextLinkName: "${operation.continuationTokenName}"`);
170
+ }
171
+ statements.push(`return buildPagedAsyncIterator(
172
+ context,
173
+ () => _${name}Send(${parameters.map((p) => p.name).join(", ")}),
174
+ _${name}Deserialize,
175
+ ${options.length > 0 ? `{${options.join(", ")}}` : ``}
176
+ );`);
177
+ }
178
+ else {
179
+ statements.push(`const result = await _${name}Send(${parameters
180
+ .map((p) => p.name)
181
+ .join(", ")});`);
182
+ statements.push(`return _${name}Deserialize(result);`);
183
+ }
155
184
  return {
156
185
  ...functionStatement,
157
186
  statements
158
187
  };
159
188
  }
189
+ function extractPagingType(type, itemName) {
190
+ var _a, _b, _c;
191
+ if (!itemName) {
192
+ return undefined;
193
+ }
194
+ const prop = (_b = ((_a = type.properties) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.filter((prop) => prop.restApiName === itemName).map((prop) => prop.type);
195
+ if (prop.length === 0) {
196
+ return undefined;
197
+ }
198
+ return ((_c = prop[0]) === null || _c === void 0 ? void 0 : _c.type) === "list" && prop[0].elementType
199
+ ? prop[0].elementType
200
+ : undefined;
201
+ }
160
202
  export function getOperationOptionsName(operation, includeGroupName = false) {
161
203
  var _a;
162
204
  const prefix = includeGroupName && operation.name.indexOf("_") === -1
@@ -173,7 +215,7 @@ export function getOperationOptionsName(operation, includeGroupName = false) {
173
215
  * RLC internally. This will translate High Level parameters into the RLC ones.
174
216
  * Figuring out what goes in headers, body, path and qsp.
175
217
  */
176
- function getRequestParameters(dpgContext, operation, importSet, runtimeImports) {
218
+ function getRequestParameters(dpgContext, operation, runtimeImports) {
177
219
  if (!operation.parameters) {
178
220
  return "";
179
221
  }
@@ -189,7 +231,7 @@ function getRequestParameters(dpgContext, operation, importSet, runtimeImports)
189
231
  param.location === "query" ||
190
232
  param.location === "body") {
191
233
  parametersImplementation[param.location].push({
192
- paramMap: getParameterMap(param, importSet, runtimeImports),
234
+ paramMap: getParameterMap(param, runtimeImports),
193
235
  param
194
236
  });
195
237
  }
@@ -215,7 +257,7 @@ function getRequestParameters(dpgContext, operation, importSet, runtimeImports)
215
257
  .join(",\n")}}`;
216
258
  }
217
259
  else if (operation.bodyParameter !== undefined) {
218
- paramStr = `${paramStr}${buildBodyParameter(operation.bodyParameter, importSet, runtimeImports)}`;
260
+ paramStr = `${paramStr}${buildBodyParameter(operation.bodyParameter, runtimeImports)}`;
219
261
  }
220
262
  return paramStr;
221
263
  }
@@ -239,20 +281,25 @@ function buildHeaderParameter(program, paramMap, param) {
239
281
  ? `...(${conditions.join(" && ")} ? {${paramMap}} : {})`
240
282
  : paramMap;
241
283
  }
242
- function buildBodyParameter(bodyParameter, importSet, runtimeImports) {
284
+ function buildBodyParameter(bodyParameter, runtimeImports) {
243
285
  var _a;
244
286
  if (!bodyParameter) {
245
287
  return "";
246
288
  }
247
- if (bodyParameter.type.type === "model") {
248
- const bodyParts = getRequestModelMapping(bodyParameter.type, bodyParameter.clientName, importSet, runtimeImports);
289
+ if (bodyParameter.type.type === "model" && !bodyParameter.type.aliasType) {
290
+ const bodyParts = getRequestModelMapping(bodyParameter.type, bodyParameter.clientName, runtimeImports);
249
291
  if (bodyParameter && bodyParts.length > 0) {
250
292
  return `\nbody: {${bodyParts.join(",\n")}},`;
251
293
  }
252
294
  }
295
+ else if (bodyParameter.type.type === "model" &&
296
+ bodyParameter.type.aliasType) {
297
+ return `\nbody: ${bodyParameter.clientName},`;
298
+ }
253
299
  if (bodyParameter.type.type === "list") {
254
- if (((_a = bodyParameter.type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model") {
255
- const bodyParts = getRequestModelMapping(bodyParameter.type.elementType, "p", importSet, runtimeImports);
300
+ if (((_a = bodyParameter.type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model" &&
301
+ !bodyParameter.type.elementType.aliasType) {
302
+ const bodyParts = getRequestModelMapping(bodyParameter.type.elementType, "p", runtimeImports);
256
303
  return `\nbody: (${bodyParameter.clientName} ?? []).map((p) => { return {
257
304
  ${bodyParts.join(", ")}
258
305
  };}),`;
@@ -261,14 +308,7 @@ function buildBodyParameter(bodyParameter, importSet, runtimeImports) {
261
308
  }
262
309
  if (bodyParameter.type.type === "byte-array" &&
263
310
  !bodyParameter.isBinaryPayload) {
264
- const specifier = getImportSpecifier("coreUtil", runtimeImports);
265
- const coreUtilSet = importSet.get(specifier);
266
- if (!coreUtilSet) {
267
- importSet.set(specifier, new Set().add("uint8ArrayToString"));
268
- }
269
- else {
270
- coreUtilSet.add("uint8ArrayToString");
271
- }
311
+ addImportToSpecifier("coreUtil", runtimeImports, "uint8ArrayToString");
272
312
  return bodyParameter.optional
273
313
  ? `body: typeof ${bodyParameter.clientName} === 'string'
274
314
  ? uint8ArrayToString(${bodyParameter.clientName}, "${getEncodingFormat(bodyParameter.type)}")
@@ -291,23 +331,23 @@ function getEncodingFormat(type) {
291
331
  /**
292
332
  * This function helps with renames, translating client names to rest api names
293
333
  */
294
- function getParameterMap(param, importSet, runtimeImports) {
334
+ function getParameterMap(param, runtimeImports) {
295
335
  if (isConstant(param)) {
296
336
  return getConstantValue(param);
297
337
  }
298
338
  if (hasCollectionFormatInfo(param.location, param.format)) {
299
- return getCollectionFormat(param, importSet, runtimeImports);
339
+ return getCollectionFormat(param, runtimeImports);
300
340
  }
301
341
  // if the parameter or property is optional, we don't need to handle the default value
302
342
  if (isOptional(param)) {
303
- return getOptional(param, importSet, runtimeImports);
343
+ return getOptional(param, runtimeImports);
304
344
  }
305
345
  if (isRequired(param)) {
306
- return getRequired(param, importSet, runtimeImports);
346
+ return getRequired(param, runtimeImports);
307
347
  }
308
348
  throw new Error(`Parameter ${param.clientName} is not supported`);
309
349
  }
310
- function getCollectionFormat(param, importSet, runtimeImports) {
350
+ function getCollectionFormat(param, runtimeImports) {
311
351
  var _a, _b;
312
352
  const collectionInfo = getCollectionFormatHelper(param.location, (_a = param.format) !== null && _a !== void 0 ? _a : "");
313
353
  if (!collectionInfo) {
@@ -316,9 +356,9 @@ function getCollectionFormat(param, importSet, runtimeImports) {
316
356
  const isMulti = ((_b = param.format) !== null && _b !== void 0 ? _b : "").toLowerCase() === "multi";
317
357
  const additionalParam = isMulti ? `, "${param.restApiName}"` : "";
318
358
  if (!param.optional) {
319
- return `"${param.restApiName}": ${collectionInfo}(${serializeRequestValue(param.type, param.clientName, importSet, runtimeImports, true, param.format)}${additionalParam})`;
359
+ return `"${param.restApiName}": ${collectionInfo}(${serializeRequestValue(param.type, param.clientName, runtimeImports, true, param.format)}${additionalParam})`;
320
360
  }
321
- return `"${param.restApiName}": options?.${param.clientName} !== undefined ? ${collectionInfo}(${serializeRequestValue(param.type, "options?." + param.clientName, importSet, runtimeImports, false, param.format)}${additionalParam}): undefined`;
361
+ return `"${param.restApiName}": options?.${param.clientName} !== undefined ? ${collectionInfo}(${serializeRequestValue(param.type, "options?." + param.clientName, runtimeImports, false, param.format)}${additionalParam}): undefined`;
322
362
  }
323
363
  function isContentType(param) {
324
364
  return (param.location === "header" &&
@@ -327,24 +367,23 @@ function isContentType(param) {
327
367
  function getContentTypeValue(param) {
328
368
  var _a;
329
369
  const defaultValue = (_a = param.clientDefaultValue) !== null && _a !== void 0 ? _a : param.type.clientDefaultValue;
330
- if (!defaultValue) {
331
- throw new Error(`Constant ${param.clientName} does not have a default value`);
332
- }
333
370
  if (defaultValue) {
334
371
  return `contentType: options.${param.clientName} as any ?? "${defaultValue}"`;
335
372
  }
336
373
  else {
337
- return `contentType: options.${param.clientName}`;
374
+ return `contentType: ${!param.optional
375
+ ? "contentType"
376
+ : "options." + param.clientName + " as any"}`;
338
377
  }
339
378
  }
340
379
  function isRequired(param) {
341
380
  return !param.optional;
342
381
  }
343
- function getRequired(param, importSet, runtimeImports) {
382
+ function getRequired(param, runtimeImports) {
344
383
  if (param.type.type === "model") {
345
- return `"${param.restApiName}": {${getRequestModelMapping(param.type, param.clientName, importSet, runtimeImports).join(",")}}`;
384
+ return `"${param.restApiName}": {${getRequestModelMapping(param.type, param.clientName, runtimeImports).join(",")}}`;
346
385
  }
347
- return `"${param.restApiName}": ${serializeRequestValue(param.type, param.clientName, importSet, runtimeImports, true, param.format === undefined &&
386
+ return `"${param.restApiName}": ${serializeRequestValue(param.type, param.clientName, runtimeImports, true, param.format === undefined &&
348
387
  param.location === "header" &&
349
388
  param.type.type === "datetime"
350
389
  ? "headerDefault"
@@ -364,11 +403,11 @@ function isConstant(param) {
364
403
  function isOptional(param) {
365
404
  return Boolean(param.optional);
366
405
  }
367
- function getOptional(param, importSet, runtimeImports) {
406
+ function getOptional(param, runtimeImports) {
368
407
  if (param.type.type === "model") {
369
- return `"${param.restApiName}": {${getRequestModelMapping(param.type, "options?." + param.clientName + "?", importSet, runtimeImports).join(", ")}}`;
408
+ return `"${param.restApiName}": {${getRequestModelMapping(param.type, "options?." + param.clientName + "?", runtimeImports).join(", ")}}`;
370
409
  }
371
- return `"${param.restApiName}": ${serializeRequestValue(param.type, `options?.${param.clientName}`, importSet, runtimeImports, false, param.format === undefined &&
410
+ return `"${param.restApiName}": ${serializeRequestValue(param.type, `options?.${param.clientName}`, runtimeImports, false, param.format === undefined &&
372
411
  param.location === "header" &&
373
412
  param.type.type === "datetime"
374
413
  ? "headerDefault"
@@ -418,7 +457,7 @@ function getNullableCheck(name, type) {
418
457
  * This function helps translating an HLC request to RLC request,
419
458
  * extracting properties from body and headers and building the RLC response object
420
459
  */
421
- function getRequestModelMapping(modelPropertyType, propertyPath = "body", importSet, runtimeImports) {
460
+ function getRequestModelMapping(modelPropertyType, propertyPath = "body", runtimeImports) {
422
461
  var _a, _b, _c;
423
462
  if (getAllProperties(modelPropertyType).length <= 0) {
424
463
  return [];
@@ -444,7 +483,7 @@ function getRequestModelMapping(modelPropertyType, propertyPath = "body", import
444
483
  : `!${propertyFullName} ? undefined : ${propertyFullName} as any`}`;
445
484
  }
446
485
  else {
447
- definition = `"${property.restApiName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getRequestModelMapping(property.type, `${propertyPath}.${property.clientName}${property.optional ? "?" : ""}`, importSet, runtimeImports)}}`;
486
+ definition = `"${property.restApiName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getRequestModelMapping(property.type, `${propertyPath}.${property.clientName}${property.optional ? "?" : ""}`, runtimeImports)}}`;
448
487
  }
449
488
  props.push(definition);
450
489
  }
@@ -460,7 +499,7 @@ function getRequestModelMapping(modelPropertyType, propertyPath = "body", import
460
499
  else {
461
500
  const dot = propertyPath.endsWith("?") ? "." : "";
462
501
  const clientValue = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}["${property.clientName}"]`;
463
- props.push(`"${property.restApiName}": ${serializeRequestValue(property.type, clientValue, importSet, runtimeImports, !property.optional, property.format)}`);
502
+ props.push(`"${property.restApiName}": ${serializeRequestValue(property.type, clientValue, runtimeImports, !property.optional, property.format)}`);
464
503
  }
465
504
  }
466
505
  return props;
@@ -469,7 +508,7 @@ function getRequestModelMapping(modelPropertyType, propertyPath = "body", import
469
508
  * This function helps translating an RLC response to an HLC response,
470
509
  * extracting properties from body and headers and building the HLC response object
471
510
  */
472
- export function getResponseMapping(properties, propertyPath = "result.body", importSet, runtimeImports) {
511
+ export function getResponseMapping(properties, propertyPath = "result.body", runtimeImports) {
473
512
  var _a, _b, _c;
474
513
  const props = [];
475
514
  for (const property of properties) {
@@ -489,7 +528,7 @@ export function getResponseMapping(properties, propertyPath = "result.body", imp
489
528
  : `!${propertyFullName} ? undefined : ${propertyFullName} as any`}`;
490
529
  }
491
530
  else {
492
- definition = `"${property.clientName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getResponseMapping((_b = getAllProperties(property.type)) !== null && _b !== void 0 ? _b : [], `${propertyPath}.${property.restApiName}${property.optional ? "?" : ""}`, importSet, runtimeImports)}}`;
531
+ definition = `"${property.clientName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getResponseMapping((_b = getAllProperties(property.type)) !== null && _b !== void 0 ? _b : [], `${propertyPath}.${property.restApiName}${property.optional ? "?" : ""}`, runtimeImports)}}`;
493
532
  }
494
533
  props.push(definition);
495
534
  }
@@ -505,7 +544,7 @@ export function getResponseMapping(properties, propertyPath = "result.body", imp
505
544
  : `!${propertyFullName} ? undefined : ${propertyFullName} as any`}`);
506
545
  }
507
546
  else {
508
- props.push(`"${property.clientName}": ${deserializeResponseValue(property.type, restValue, importSet, runtimeImports, property.optional !== undefined ? !property.optional : false, property.format)}`);
547
+ props.push(`"${property.clientName}": ${deserializeResponseValue(property.type, restValue, runtimeImports, property.optional !== undefined ? !property.optional : false, property.format)}`);
509
548
  }
510
549
  }
511
550
  }
@@ -516,10 +555,8 @@ export function getResponseMapping(properties, propertyPath = "result.body", imp
516
555
  * We need to drill down into Array elements to make sure that the element type is
517
556
  * deserialized correctly
518
557
  */
519
- function deserializeResponseValue(type, restValue, importSet, runtimeImports, required, format) {
520
- var _a, _b, _c;
521
- const coreSpecifier = getImportSpecifier("coreUtil", runtimeImports);
522
- const coreUtilSet = importSet.get(coreSpecifier);
558
+ function deserializeResponseValue(type, restValue, runtimeImports, required, format) {
559
+ var _a, _b, _c, _d;
523
560
  switch (type.type) {
524
561
  case "datetime":
525
562
  return required
@@ -534,10 +571,14 @@ function deserializeResponseValue(type, restValue, importSet, runtimeImports, re
534
571
  ? `${restValue}`
535
572
  : `!${restValue} ? ${restValue} : ${restValue}`;
536
573
  if (((_a = type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model") {
537
- return `${prefix}.map(p => ({${getResponseMapping((_b = getAllProperties(type.elementType)) !== null && _b !== void 0 ? _b : [], "p", importSet, runtimeImports)}}))`;
574
+ if (!type.elementType.aliasType) {
575
+ return `${prefix}.map(p => ({${getResponseMapping((_b = getAllProperties(type.elementType)) !== null && _b !== void 0 ? _b : [], "p", runtimeImports)}}))`;
576
+ }
577
+ return `${prefix}`;
538
578
  }
539
- else if (needsDeserialize(type.elementType)) {
540
- return `${prefix}.map(p => ${deserializeResponseValue(type.elementType, "p", importSet, runtimeImports, required, (_c = type.elementType) === null || _c === void 0 ? void 0 : _c.format)})`;
579
+ else if (needsDeserialize(type.elementType) &&
580
+ !((_c = type.elementType) === null || _c === void 0 ? void 0 : _c.aliasType)) {
581
+ return `${prefix}.map(p => ${deserializeResponseValue(type.elementType, "p", runtimeImports, required, (_d = type.elementType) === null || _d === void 0 ? void 0 : _d.format)})`;
541
582
  }
542
583
  else {
543
584
  return restValue;
@@ -545,12 +586,7 @@ function deserializeResponseValue(type, restValue, importSet, runtimeImports, re
545
586
  }
546
587
  case "byte-array":
547
588
  if (format !== "binary") {
548
- if (!coreUtilSet) {
549
- importSet.set(coreSpecifier, new Set().add("stringToUint8Array"));
550
- }
551
- else {
552
- coreUtilSet.add("stringToUint8Array");
553
- }
589
+ addImportToSpecifier("coreUtil", runtimeImports, "stringToUint8Array");
554
590
  return `typeof ${restValue} === 'string'
555
591
  ? stringToUint8Array(${restValue}, "${format !== null && format !== void 0 ? format : "base64"}")
556
592
  : ${restValue}`;
@@ -565,10 +601,8 @@ function deserializeResponseValue(type, restValue, importSet, runtimeImports, re
565
601
  * We need to drill down into Array elements to make sure that the element type is
566
602
  * deserialized correctly
567
603
  */
568
- function serializeRequestValue(type, clientValue, importSet, runtimeImports, required, format) {
569
- var _a, _b, _c, _d, _e;
570
- const utilSpecifier = getImportSpecifier("coreUtil", runtimeImports);
571
- const coreUtilSet = importSet.get(utilSpecifier);
604
+ function serializeRequestValue(type, clientValue, runtimeImports, required, format) {
605
+ var _a, _b, _c, _d, _e, _f;
572
606
  switch (type.type) {
573
607
  case "datetime":
574
608
  switch ((_a = type.format) !== null && _a !== void 0 ? _a : format) {
@@ -589,11 +623,12 @@ function serializeRequestValue(type, clientValue, importSet, runtimeImports, req
589
623
  const prefix = required && !type.nullable
590
624
  ? `${clientValue}`
591
625
  : `!${clientValue} ? ${clientValue} : ${clientValue}`;
592
- if (((_b = type.elementType) === null || _b === void 0 ? void 0 : _b.type) === "model") {
593
- return `${prefix}.map(p => ({${getRequestModelMapping(type.elementType, "p", importSet, runtimeImports)}}))`;
626
+ if (((_b = type.elementType) === null || _b === void 0 ? void 0 : _b.type) === "model" && !type.elementType.aliasType) {
627
+ return `${prefix}.map(p => ({${getRequestModelMapping(type.elementType, "p", runtimeImports)}}))`;
594
628
  }
595
- else if (needsDeserialize(type.elementType)) {
596
- return `${prefix}.map(p => ${serializeRequestValue(type.elementType, "p", importSet, runtimeImports, required, (_c = type.elementType) === null || _c === void 0 ? void 0 : _c.format)})`;
629
+ else if (needsDeserialize(type.elementType) &&
630
+ !((_c = type.elementType) === null || _c === void 0 ? void 0 : _c.aliasType)) {
631
+ return `${prefix}.map(p => ${serializeRequestValue(type.elementType, "p", runtimeImports, required, (_d = type.elementType) === null || _d === void 0 ? void 0 : _d.format)})`;
597
632
  }
598
633
  else {
599
634
  return clientValue;
@@ -601,15 +636,10 @@ function serializeRequestValue(type, clientValue, importSet, runtimeImports, req
601
636
  }
602
637
  case "byte-array":
603
638
  if (format !== "binary") {
604
- if (!coreUtilSet) {
605
- importSet.set(utilSpecifier, new Set().add("uint8ArrayToString"));
606
- }
607
- else {
608
- coreUtilSet.add("uint8ArrayToString");
609
- }
639
+ addImportToSpecifier("coreUtil", runtimeImports, "uint8ArrayToString");
610
640
  return required
611
- ? `uint8ArrayToString(${clientValue}, "${(_d = getEncodingFormat({ format })) !== null && _d !== void 0 ? _d : "base64"}")`
612
- : `${clientValue} !== undefined ? uint8ArrayToString(${clientValue}, "${(_e = getEncodingFormat({ format })) !== null && _e !== void 0 ? _e : "base64"}"): undefined`;
641
+ ? `uint8ArrayToString(${clientValue}, "${(_e = getEncodingFormat({ format })) !== null && _e !== void 0 ? _e : "base64"}")`
642
+ : `${clientValue} !== undefined ? uint8ArrayToString(${clientValue}, "${(_f = getEncodingFormat({ format })) !== null && _f !== void 0 ? _f : "base64"}"): undefined`;
613
643
  }
614
644
  return clientValue;
615
645
  default:
@@ -626,22 +656,28 @@ export function hasLROOperation(codeModel) {
626
656
  var _a;
627
657
  return ((_a = codeModel.clients) !== null && _a !== void 0 ? _a : []).some((c) => {
628
658
  var _a;
629
- return ((_a = c.operationGroups) !== null && _a !== void 0 ? _a : []).some((og) => {
630
- var _a;
631
- return ((_a = og.operations) !== null && _a !== void 0 ? _a : []).some((op) => op.discriminator === "lro" || op.discriminator === "lropaging");
632
- });
659
+ return ((_a = c.operationGroups) !== null && _a !== void 0 ? _a : []).some((og) => { var _a; return ((_a = og.operations) !== null && _a !== void 0 ? _a : []).some(isLROOperation); });
633
660
  });
634
661
  }
635
- export function hasPagingOperation(codeModel) {
636
- var _a;
637
- return ((_a = codeModel.clients) !== null && _a !== void 0 ? _a : []).some((c) => {
662
+ export function isLROOperation(op) {
663
+ return op.discriminator === "lro" || op.discriminator === "lropaging";
664
+ }
665
+ export function hasPagingOperation(clientOrCodeModel) {
666
+ let clients = [];
667
+ if (clientOrCodeModel === null || clientOrCodeModel === void 0 ? void 0 : clientOrCodeModel.operationGroups) {
668
+ clients = [clientOrCodeModel];
669
+ }
670
+ else if (clientOrCodeModel === null || clientOrCodeModel === void 0 ? void 0 : clientOrCodeModel.clients) {
671
+ clients = clientOrCodeModel.clients;
672
+ }
673
+ return clients.some((c) => {
638
674
  var _a;
639
- return ((_a = c.operationGroups) !== null && _a !== void 0 ? _a : []).some((og) => {
640
- var _a;
641
- return ((_a = og.operations) !== null && _a !== void 0 ? _a : []).some((op) => op.discriminator === "paging" || op.discriminator === "lropaging");
642
- });
675
+ return ((_a = c.operationGroups) !== null && _a !== void 0 ? _a : []).some((og) => { var _a; return ((_a = og.operations) !== null && _a !== void 0 ? _a : []).some(isPagingOperation); });
643
676
  });
644
677
  }
678
+ export function isPagingOperation(op) {
679
+ return op.discriminator === "paging" || op.discriminator === "lropaging";
680
+ }
645
681
  function getAllProperties(type) {
646
682
  var _a, _b;
647
683
  const propertiesMap = new Map();