@azure-tools/typespec-ts 0.15.0 → 0.16.0-alpha.20230918.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 (98) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/src/index.d.ts.map +1 -1
  3. package/dist/src/index.js +14 -17
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/lib.d.ts.map +1 -1
  6. package/dist/src/lib.js +3 -3
  7. package/dist/src/lib.js.map +1 -1
  8. package/dist/src/modular/buildClassicalClient.d.ts +2 -3
  9. package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
  10. package/dist/src/modular/buildClassicalClient.js +26 -12
  11. package/dist/src/modular/buildClassicalClient.js.map +1 -1
  12. package/dist/src/modular/buildClientContext.d.ts +3 -3
  13. package/dist/src/modular/buildClientContext.d.ts.map +1 -1
  14. package/dist/src/modular/buildClientContext.js +5 -4
  15. package/dist/src/modular/buildClientContext.js.map +1 -1
  16. package/dist/src/modular/buildCodeModel.d.ts +3 -2
  17. package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
  18. package/dist/src/modular/buildCodeModel.js +163 -69
  19. package/dist/src/modular/buildCodeModel.js.map +1 -1
  20. package/dist/src/modular/buildOperations.d.ts +2 -2
  21. package/dist/src/modular/buildOperations.d.ts.map +1 -1
  22. package/dist/src/modular/buildOperations.js +15 -8
  23. package/dist/src/modular/buildOperations.js.map +1 -1
  24. package/dist/src/modular/buildProjectFiles.js +2 -2
  25. package/dist/src/modular/buildProjectFiles.js.map +1 -1
  26. package/dist/src/modular/buildRootIndex.d.ts +4 -4
  27. package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
  28. package/dist/src/modular/buildRootIndex.js +12 -5
  29. package/dist/src/modular/buildRootIndex.js.map +1 -1
  30. package/dist/src/modular/buildSubpathIndex.d.ts +2 -2
  31. package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
  32. package/dist/src/modular/buildSubpathIndex.js +7 -4
  33. package/dist/src/modular/buildSubpathIndex.js.map +1 -1
  34. package/dist/src/modular/emitModels.d.ts +3 -3
  35. package/dist/src/modular/emitModels.d.ts.map +1 -1
  36. package/dist/src/modular/emitModels.js +28 -18
  37. package/dist/src/modular/emitModels.js.map +1 -1
  38. package/dist/src/modular/helpers/clientHelpers.js +1 -1
  39. package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
  40. package/dist/src/modular/helpers/operationHelpers.d.ts +1 -1
  41. package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
  42. package/dist/src/modular/helpers/operationHelpers.js +167 -88
  43. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  44. package/dist/src/modular/helpers/typeHelpers.d.ts +2 -2
  45. package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
  46. package/dist/src/modular/helpers/typeHelpers.js +13 -7
  47. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  48. package/dist/src/modular/modularCodeModel.d.ts +11 -0
  49. package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
  50. package/dist/src/transform/transformHelperFunctionDetails.js +3 -4
  51. package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
  52. package/dist/src/transform/transformParameters.d.ts +0 -10
  53. package/dist/src/transform/transformParameters.d.ts.map +1 -1
  54. package/dist/src/transform/transformParameters.js +7 -51
  55. package/dist/src/transform/transformParameters.js.map +1 -1
  56. package/dist/src/transform/transformResponses.js +3 -4
  57. package/dist/src/transform/transformResponses.js.map +1 -1
  58. package/dist/src/transform/transformSchemas.d.ts.map +1 -1
  59. package/dist/src/transform/transformSchemas.js +4 -8
  60. package/dist/src/transform/transformSchemas.js.map +1 -1
  61. package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
  62. package/dist/src/transform/transformTelemetryInfo.js +3 -10
  63. package/dist/src/transform/transformTelemetryInfo.js.map +1 -1
  64. package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
  65. package/dist/src/transform/transfromRLCOptions.js +48 -9
  66. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  67. package/dist/src/utils/modelUtils.d.ts +2 -1
  68. package/dist/src/utils/modelUtils.d.ts.map +1 -1
  69. package/dist/src/utils/modelUtils.js +83 -73
  70. package/dist/src/utils/modelUtils.js.map +1 -1
  71. package/dist/src/utils/operationUtil.d.ts +15 -1
  72. package/dist/src/utils/operationUtil.d.ts.map +1 -1
  73. package/dist/src/utils/operationUtil.js +82 -3
  74. package/dist/src/utils/operationUtil.js.map +1 -1
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +13 -11
  77. package/src/index.ts +24 -51
  78. package/src/lib.ts +3 -3
  79. package/src/modular/buildClassicalClient.ts +29 -16
  80. package/src/modular/buildClientContext.ts +8 -9
  81. package/src/modular/buildCodeModel.ts +212 -75
  82. package/src/modular/buildOperations.ts +16 -11
  83. package/src/modular/buildProjectFiles.ts +2 -2
  84. package/src/modular/buildRootIndex.ts +19 -12
  85. package/src/modular/buildSubpathIndex.ts +10 -8
  86. package/src/modular/emitModels.ts +35 -24
  87. package/src/modular/helpers/clientHelpers.ts +1 -1
  88. package/src/modular/helpers/operationHelpers.ts +256 -127
  89. package/src/modular/helpers/typeHelpers.ts +19 -7
  90. package/src/modular/modularCodeModel.ts +11 -0
  91. package/src/transform/transformHelperFunctionDetails.ts +10 -4
  92. package/src/transform/transformParameters.ts +15 -57
  93. package/src/transform/transformResponses.ts +2 -4
  94. package/src/transform/transformSchemas.ts +5 -9
  95. package/src/transform/transformTelemetryInfo.ts +4 -18
  96. package/src/transform/transfromRLCOptions.ts +67 -9
  97. package/src/utils/modelUtils.ts +81 -72
  98. package/src/utils/operationUtil.ts +121 -4
@@ -1 +1 @@
1
- {"version":3,"file":"emitModels.js","sourceRoot":"","sources":["../../../src/modular/emitModels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;A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AC,CAAC,EAAE,gBAAgB,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;KACJ;IACD,gBAAgB,CAAC,qBAAqB,CAAC;QACrC;YACE,eAAe,EAAE,yBAAyB;YAC1C,YAAY,EAAE,CAAC,kBAAkB,CAAC;SACnC;KACF,CAAC,CAAC;IAEH,gBAAgB,CAAC,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;AACP,CAAC"}
@@ -15,7 +15,7 @@ export function getClientParameters(client) {
15
15
  .map((p) => {
16
16
  return {
17
17
  name: p.clientName,
18
- type: getType(p.type).name
18
+ type: getType(p.type, p.format).name
19
19
  };
20
20
  }),
21
21
  optionsParam
@@ -1 +1 @@
1
- {"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../../../src/modular/helpers/clientHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,UAAU,mBAAmB,CACjC,MAAc;IAEd,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,YAAY,GAAG;QACnB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,GAAG,IAAI,eAAe;QAC5B,WAAW,EA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O;gBACL,IAAI,EAAE,CAAC,CAAC,UAAU;gBAClB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI;aACrC,CAAC;QACJ,CAAC,CAAC;QACJ,YAAY;KACb,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -6,7 +6,7 @@ export declare function getDeserializePrivateFunction(operation: Operation, need
6
6
  * This operation builds and returns the function declaration for an operation.
7
7
  */
8
8
  export declare function getOperationFunction(operation: Operation, clientType: string): OptionalKind<FunctionDeclarationStructure>;
9
- export declare function getOperationOptionsName(operation: Operation): string;
9
+ export declare function getOperationOptionsName(operation: Operation, includeGroupName?: boolean): string;
10
10
  /**
11
11
  * This function helps translating an RLC response to an HLC response,
12
12
  * extracting properties from body and headers and building the HLC response object
@@ -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;AAgChC,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GAClC,YAAY,CAAC,4BAA4B,CAAC,CA6B5C;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,GAClC,YAAY,CAAC,4BAA4B,CAAC,CAyE5C;AA6DD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,YAAY,CAAC,4BAA4B,CAAC,CAmC5C;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,UAI3D;AA6XD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,QAAQ,EAAE,EACtB,YAAY,oBAAwB,EACpC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,YAgDpC;AA8GD,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,gBAAgB,EAChB,SAAS,EAET,QAAQ,EAET,MAAM,wBAAwB,CAAC;AAoChC,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GAClC,YAAY,CAAC,4BAA4B,CAAC,CA6B5C;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,GAClC,YAAY,CAAC,4BAA4B,CAAC,CAwF5C;AA8DD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,YAAY,CAAC,4BAA4B,CAAC,CAmC5C;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,EACpB,gBAAgB,UAAQ,UAQzB;AAmaD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,QAAQ,EAAE,EACtB,YAAY,oBAAwB,EACpC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,YA2EpC;AAoID,wBAAgB,eAAe,CAAC,SAAS,EAAE,gBAAgB,WAQ1D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,gBAAgB,WAS7D"}
@@ -3,6 +3,7 @@ import { buildType } from "./typeHelpers.js";
3
3
  import { NameType, getResponseBaseName, getResponseTypeName, normalizeName } from "@azure-tools/rlc-common";
4
4
  import { getOperationName } from "./namingHelpers.js";
5
5
  import { getFixmeForMultilineDocs, getDocsFromDescription } from "./docsHelpers.js";
6
+ import { getCollectionFormatHelper, hasCollectionFormatInfo } from "../../utils/operationUtil.js";
6
7
  function getRLCResponseType(rlcResponse) {
7
8
  if (!(rlcResponse === null || rlcResponse === void 0 ? void 0 : rlcResponse.responses)) {
8
9
  return;
@@ -34,9 +35,9 @@ export function getSendPrivateFunction(operation, clientType, importSet) {
34
35
  };
35
36
  }
36
37
  export function getDeserializePrivateFunction(operation, needSubClient, needUnexpectedHelper, importSet) {
37
- var _a, _b, _c, _d, _e;
38
+ var _a, _b, _c, _d;
38
39
  const { name } = getOperationName(operation);
39
- let parameters = [
40
+ const parameters = [
40
41
  {
41
42
  name: "result",
42
43
  type: getRLCResponseType(operation.rlcResponse)
@@ -46,17 +47,9 @@ export function getDeserializePrivateFunction(operation, needSubClient, needUnex
46
47
  const response = operation.responses[0];
47
48
  let returnType;
48
49
  if ((_a = response === null || response === void 0 ? void 0 : response.type) === null || _a === void 0 ? void 0 : _a.type) {
49
- returnType = buildType(response.type.name, response.type);
50
+ returnType = buildType(response.type.name, response.type, response.type.format);
50
51
  }
51
52
  else {
52
- if (!needUnexpectedHelper) {
53
- parameters = [
54
- {
55
- name: "_result",
56
- type: getRLCResponseType(operation.rlcResponse)
57
- }
58
- ];
59
- }
60
53
  returnType = { name: "", type: "void" };
61
54
  }
62
55
  const functionStatement = {
@@ -70,14 +63,26 @@ export function getDeserializePrivateFunction(operation, needSubClient, needUnex
70
63
  if (needUnexpectedHelper) {
71
64
  statements.push(`if(${needSubClient ? "UnexpectedHelper." : ""}isUnexpected(result)){`, "throw result.body", "}");
72
65
  }
66
+ else {
67
+ const validStatus = [
68
+ ...new Set(operation.responses
69
+ .flatMap((r) => r.statusCodes)
70
+ .filter((s) => s !== "default"))
71
+ ];
72
+ if (validStatus.length > 0) {
73
+ statements.push(`if(${validStatus
74
+ .map((s) => `result.status !== "${s}"`)
75
+ .join(" || ")}){`, "throw result.body", "}");
76
+ }
77
+ }
73
78
  if (((_b = response === null || response === void 0 ? void 0 : response.type) === null || _b === void 0 ? void 0 : _b.type) === "any") {
74
79
  statements.push(`return result.body`);
75
80
  }
76
81
  else if ((_c = response === null || response === void 0 ? void 0 : response.type) === null || _c === void 0 ? void 0 : _c.elementType) {
77
- statements.push(`return ${deserializeResponseValue(response.type, "result.body", importSet, response.type.nullable !== undefined ? !response.type.nullable : false)}`);
82
+ statements.push(`return ${deserializeResponseValue(response.type, "result.body", importSet, response.type.nullable !== undefined ? !response.type.nullable : false, response.type.format)}`);
78
83
  }
79
- else if ((_d = response === null || response === void 0 ? void 0 : response.type) === null || _d === void 0 ? void 0 : _d.properties) {
80
- statements.push(`return {`, getResponseMapping((_e = response.type.properties) !== null && _e !== void 0 ? _e : [], "result.body", importSet).join(","), `}`);
84
+ else if (getAllProperties(response === null || response === void 0 ? void 0 : response.type).length > 0) {
85
+ statements.push(`return {`, getResponseMapping((_d = getAllProperties(response.type)) !== null && _d !== void 0 ? _d : [], "result.body", importSet).join(","), `}`);
81
86
  }
82
87
  else if (returnType.type === "void") {
83
88
  statements.push(`return;`);
@@ -95,25 +100,25 @@ function getOperationSignatureParameters(operation, clientType) {
95
100
  const optionsType = getOperationOptionsName(operation);
96
101
  const parameters = new Map();
97
102
  if (((_a = operation.bodyParameter) === null || _a === void 0 ? void 0 : _a.type.type) === "model") {
98
- ((_c = (_b = operation.bodyParameter) === null || _b === void 0 ? void 0 : _b.type.properties) !== null && _c !== void 0 ? _c : [])
103
+ ((_c = getAllProperties((_b = operation.bodyParameter) === null || _b === void 0 ? void 0 : _b.type)) !== null && _c !== void 0 ? _c : [])
99
104
  .filter((p) => !p.optional)
100
105
  .filter((p) => !p.readonly)
101
- .map((p) => buildType(p.clientName, p.type))
106
+ .map((p) => buildType(p.clientName, p.type, p.format))
102
107
  .forEach((p) => parameters.set(p.name, p));
103
108
  }
104
109
  else if (((_d = operation.bodyParameter) === null || _d === void 0 ? void 0 : _d.type.type) === "list") {
105
110
  const bodyArray = operation.bodyParameter;
106
- parameters.set(bodyArray.clientName, buildType(bodyArray.clientName, bodyArray.type));
111
+ parameters.set(bodyArray.clientName, buildType(bodyArray.clientName, bodyArray.type, bodyArray.type.format));
107
112
  }
108
113
  else if (((_e = operation.bodyParameter) === null || _e === void 0 ? void 0 : _e.type.type) === "byte-array") {
109
- parameters.set(operation.bodyParameter.clientName, buildType(operation.bodyParameter.clientName, operation.bodyParameter.type));
114
+ parameters.set(operation.bodyParameter.clientName, buildType(operation.bodyParameter.clientName, operation.bodyParameter.type, operation.bodyParameter.type.format));
110
115
  }
111
116
  operation.parameters
112
117
  .filter((p) => p.implementation === "Method" &&
113
118
  p.type.type !== "constant" &&
114
119
  p.clientDefaultValue === undefined &&
115
120
  !p.optional)
116
- .map((p) => buildType(p.clientName, p.type))
121
+ .map((p) => buildType(p.clientName, p.type, p.format))
117
122
  .forEach((p) => {
118
123
  parameters.set(p.name, p);
119
124
  });
@@ -138,7 +143,7 @@ export function getOperationFunction(operation, clientType) {
138
143
  // TODO: Support operation overloads
139
144
  const response = operation.responses[0];
140
145
  const returnType = ((_a = response === null || response === void 0 ? void 0 : response.type) === null || _a === void 0 ? void 0 : _a.type)
141
- ? buildType(response.type.name, response.type)
146
+ ? buildType(response.type.name, response.type, response.type.format)
142
147
  : { name: "", type: "void" };
143
148
  const { name, fixme = [] } = getOperationName(operation);
144
149
  const functionStatement = {
@@ -162,8 +167,14 @@ export function getOperationFunction(operation, clientType) {
162
167
  statements
163
168
  };
164
169
  }
165
- export function getOperationOptionsName(operation) {
166
- return `${toPascalCase(operation.groupName)}${toPascalCase(operation.name)}Options`;
170
+ export function getOperationOptionsName(operation, includeGroupName = false) {
171
+ var _a;
172
+ const prefix = includeGroupName ? toPascalCase(operation.groupName) : "";
173
+ const optionName = `${prefix}${toPascalCase(operation.name)}Options`;
174
+ if (((_a = operation.bodyParameter) === null || _a === void 0 ? void 0 : _a.type.name) === optionName) {
175
+ return optionName.replace(/Options$/, "RequestOptions");
176
+ }
177
+ return optionName;
167
178
  }
168
179
  /**
169
180
  * This function build the request parameters that we will provide to the
@@ -191,7 +202,7 @@ function getRequestParameters(operation, importSet) {
191
202
  paramStr = `${getContentTypeValue(contentTypeParameter)},`;
192
203
  }
193
204
  if (parametersImplementation.header.length) {
194
- paramStr = `${paramStr}\nheaders: {${parametersImplementation.header.join(",\n") + ","},`;
205
+ paramStr = `${paramStr}\nheaders: {${parametersImplementation.header.join(",\n")}},`;
195
206
  }
196
207
  if (parametersImplementation.query.length) {
197
208
  paramStr = `${paramStr}\nqueryParameters: {${parametersImplementation.query.join(",\n")}},`;
@@ -200,33 +211,26 @@ function getRequestParameters(operation, importSet) {
200
211
  return paramStr;
201
212
  }
202
213
  function buildBodyParameter(bodyParameter, importSet) {
203
- var _a, _b, _c;
214
+ var _a, _b;
204
215
  if (!bodyParameter) {
205
216
  return "";
206
217
  }
207
218
  if (bodyParameter.type.type === "model") {
208
219
  const bodyParts = [];
209
- let hasSerializeBody = false;
210
- for (const param of (_b = (_a = bodyParameter === null || bodyParameter === void 0 ? void 0 : bodyParameter.type.properties) === null || _a === void 0 ? void 0 : _a.filter((p) => !p.readonly)) !== null && _b !== void 0 ? _b : []) {
220
+ for (const param of (_a = getAllProperties(bodyParameter === null || bodyParameter === void 0 ? void 0 : bodyParameter.type).filter((p) => !p.readonly)) !== null && _a !== void 0 ? _a : []) {
211
221
  if (param.type.type === "model" && isRequired(param)) {
212
- hasSerializeBody = true;
213
- bodyParts.push(...getRequestModelMapping(param.type, param.clientName, importSet));
222
+ bodyParts.push(`"${param.restApiName}": {${getRequestModelMapping(param.type, param.clientName, importSet).join(",\n")}}`);
214
223
  }
215
224
  else {
216
225
  bodyParts.push(getParameterMap(param, importSet));
217
226
  }
218
227
  }
219
- if (bodyParameter && bodyParameter.type.properties) {
220
- if (hasSerializeBody) {
221
- return `\nbody: {"${bodyParameter.restApiName}": {${bodyParts.join(",\n")}}},`;
222
- }
223
- else {
224
- return `\nbody: {${bodyParts.join(",\n")}},`;
225
- }
228
+ if (bodyParameter && getAllProperties(bodyParameter.type).length > 0) {
229
+ return `\nbody: {${bodyParts.join(",\n")}},`;
226
230
  }
227
231
  }
228
232
  if (bodyParameter.type.type === "list") {
229
- if (((_c = bodyParameter.type.elementType) === null || _c === void 0 ? void 0 : _c.type) === "model") {
233
+ if (((_b = bodyParameter.type.elementType) === null || _b === void 0 ? void 0 : _b.type) === "model") {
230
234
  const bodyParts = getRequestModelMapping(bodyParameter.type.elementType, "p", importSet);
231
235
  return `\nbody: (${bodyParameter.clientName} ?? []).map((p) => { return {
232
236
  ${bodyParts.join(", ")}
@@ -246,17 +250,31 @@ function getParameterMap(param, importSet) {
246
250
  if (isConstant(param)) {
247
251
  return getConstantValue(param);
248
252
  }
249
- if (isOptionalWithouDefault(param)) {
250
- return getOptionalWithoutDefault(param, importSet);
253
+ if (hasCollectionFormatInfo(param.location, param.format)) {
254
+ return getCollectionFormat(param, importSet);
251
255
  }
252
- if (isOptionalWithDefault(param)) {
253
- return getOptionalWithDefault(param, importSet);
256
+ // if the parameter or property is optional, we don't need to handle the default value
257
+ if (isOptional(param)) {
258
+ return getOptional(param, importSet);
254
259
  }
255
260
  if (isRequired(param)) {
256
261
  return getRequired(param, importSet);
257
262
  }
258
263
  throw new Error(`Parameter ${param.clientName} is not supported`);
259
264
  }
265
+ function getCollectionFormat(param, importSet) {
266
+ var _a, _b;
267
+ const collectionInfo = getCollectionFormatHelper(param.location, (_a = param.format) !== null && _a !== void 0 ? _a : "");
268
+ if (!collectionInfo) {
269
+ throw "Has collection format info but without helper function detected";
270
+ }
271
+ const isMulti = ((_b = param.format) !== null && _b !== void 0 ? _b : "").toLowerCase() === "multi";
272
+ const additionalParam = isMulti ? `, "${param.restApiName}"` : "";
273
+ if (!param.optional) {
274
+ return `"${param.restApiName}": ${collectionInfo}(${serializeRequestValue(param.type, param.clientName, importSet, true, param.format)}${additionalParam})`;
275
+ }
276
+ return `"${param.restApiName}": options?.${param.clientName} !== undefined ? ${collectionInfo}(${serializeRequestValue(param.type, "options?." + param.clientName, importSet, false, param.format)}${additionalParam}): undefined`;
277
+ }
260
278
  function isContentType(param) {
261
279
  return (param.location === "header" &&
262
280
  param.restApiName.toLowerCase() === "content-type");
@@ -281,7 +299,11 @@ function getRequired(param, importSet) {
281
299
  if (param.type.type === "model") {
282
300
  return `"${param.restApiName}": ${getRequestModelMapping(param.type, param.clientName, importSet).join(",")}`;
283
301
  }
284
- return `"${param.restApiName}": ${param.clientName}`;
302
+ return `"${param.restApiName}": ${serializeRequestValue(param.type, param.clientName, importSet, true, param.format === undefined &&
303
+ param.location === "header" &&
304
+ param.type.type === "datetime"
305
+ ? "headerDefault"
306
+ : param.format)}`;
285
307
  }
286
308
  function getConstantValue(param) {
287
309
  var _a;
@@ -294,31 +316,18 @@ function getConstantValue(param) {
294
316
  function isConstant(param) {
295
317
  return (param.type.type === "constant" && param.clientDefaultValue !== undefined);
296
318
  }
297
- function isOptionalWithouDefault(param) {
298
- return Boolean(param.optional && !param.clientDefaultValue);
319
+ function isOptional(param) {
320
+ return Boolean(param.optional);
299
321
  }
300
- function getOptionalWithoutDefault(param, importSet) {
322
+ function getOptional(param, importSet) {
301
323
  if (param.type.type === "model") {
302
324
  return `"${param.restApiName}": {${getRequestModelMapping(param.type, "options?." + param.clientName + "?", importSet).join(", ")}}`;
303
325
  }
304
- return `"${param.restApiName}": options?.${param.clientName}`;
305
- }
306
- function isOptionalWithDefault(param) {
307
- return Boolean(param.clientDefaultValue);
308
- }
309
- function getOptionalWithDefault(param, importSet) {
310
- if (param.type.type === "model") {
311
- return `"${param.restApiName}": {${getRequestModelMapping(param.type, "options?." + param.clientName, importSet).join(", ")}} ?? ${getQuotedValue(param)}`;
312
- }
313
- return `"${param.restApiName}": options.${param.clientName} ?? ${getQuotedValue(param)}`;
314
- }
315
- function getQuotedValue(param) {
316
- if (param.type.type === "string") {
317
- return `"${param.clientDefaultValue}"`;
318
- }
319
- else {
320
- return param.clientDefaultValue;
321
- }
326
+ return `"${param.restApiName}": ${serializeRequestValue(param.type, `options?.${param.clientName}`, importSet, false, param.format === undefined &&
327
+ param.location === "header" &&
328
+ param.type.type === "datetime"
329
+ ? "headerDefault"
330
+ : param.format)}`;
322
331
  }
323
332
  /**
324
333
  * Builds the assignment for when a property or parameter has a default value
@@ -365,30 +374,48 @@ function getNullableCheck(name, type) {
365
374
  * extracting properties from body and headers and building the RLC response object
366
375
  */
367
376
  function getRequestModelMapping(modelPropertyType, propertyPath = "body", importSet) {
368
- if (!modelPropertyType.properties || !modelPropertyType.properties) {
377
+ var _a, _b, _c;
378
+ if (getAllProperties(modelPropertyType).length <= 0) {
369
379
  return [];
370
380
  }
371
381
  const props = [];
372
- const properties = modelPropertyType.properties;
382
+ const properties = (_a = getAllProperties(modelPropertyType)) !== null && _a !== void 0 ? _a : [];
373
383
  for (const property of properties) {
374
384
  if (property.readonly) {
375
385
  continue;
376
386
  }
377
- const propertyFullName = `${propertyPath}.${property.restApiName}`;
387
+ const propertyFullName = `${propertyPath}.${property.clientName}`;
378
388
  if (property.type.type === "model") {
379
389
  let definition;
380
390
  if (property.type.isCoreErrorType) {
381
391
  definition = `"${property.restApiName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} ${propertyFullName}`;
382
392
  }
393
+ else if ((property.restApiName === "message" ||
394
+ property.restApiName === "messages") &&
395
+ (property.type.name === "ChatMessage" ||
396
+ ((_b = property.type.elementType) === null || _b === void 0 ? void 0 : _b.name) === "ChatMessage")) {
397
+ definition = `"${property.restApiName}": ${!property.optional
398
+ ? `${propertyFullName} as any`
399
+ : `!${propertyFullName} ? undefined : ${propertyFullName} as any`}`;
400
+ }
383
401
  else {
384
- definition = `"${property.restApiName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getRequestModelMapping(property.type, `${propertyPath}.${property.restApiName}${property.optional ? "?" : ""}`, importSet)}}`;
402
+ definition = `"${property.restApiName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getRequestModelMapping(property.type, `${propertyPath}.${property.clientName}${property.optional ? "?" : ""}`, importSet)}}`;
385
403
  }
386
404
  props.push(definition);
387
405
  }
406
+ else if ((property.restApiName === "message" ||
407
+ property.restApiName === "messages") &&
408
+ (property.type.name === "ChatMessage" ||
409
+ ((_c = property.type.elementType) === null || _c === void 0 ? void 0 : _c.name) === "ChatMessage")) {
410
+ const definition = `"${property.restApiName}": ${!property.optional
411
+ ? `${propertyFullName} as any`
412
+ : `!${propertyFullName} ? undefined : ${propertyFullName} as any`}`;
413
+ props.push(definition);
414
+ }
388
415
  else {
389
416
  const dot = propertyPath.endsWith("?") ? "." : "";
390
- const restValue = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}["${property.clientName}"]`;
391
- props.push(`"${property.restApiName}": ${serializeRequestValue(property.type, restValue, importSet)}`);
417
+ const clientValue = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}["${property.clientName}"]`;
418
+ props.push(`"${property.restApiName}": ${serializeRequestValue(property.type, clientValue, importSet, !property.optional, property.format)}`);
392
419
  }
393
420
  }
394
421
  return props;
@@ -398,7 +425,7 @@ function getRequestModelMapping(modelPropertyType, propertyPath = "body", import
398
425
  * extracting properties from body and headers and building the HLC response object
399
426
  */
400
427
  export function getResponseMapping(properties, propertyPath = "result.body", importSet) {
401
- var _a;
428
+ var _a, _b, _c;
402
429
  const props = [];
403
430
  for (const property of properties) {
404
431
  // TODO: Do we need to also add headers in the result type?
@@ -408,15 +435,33 @@ export function getResponseMapping(properties, propertyPath = "result.body", imp
408
435
  if (property.type.isCoreErrorType) {
409
436
  definition = `"${property.clientName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} ${propertyFullName}`;
410
437
  }
438
+ else if ((property.restApiName === "message" ||
439
+ property.restApiName === "messages") &&
440
+ (property.type.name === "ChatMessage" ||
441
+ ((_a = property.type.elementType) === null || _a === void 0 ? void 0 : _a.name) === "ChatMessage")) {
442
+ definition = `"${property.clientName}": ${!property.optional
443
+ ? `${propertyFullName} as any`
444
+ : `!${propertyFullName} ? undefined : ${propertyFullName} as any`}`;
445
+ }
411
446
  else {
412
- definition = `"${property.clientName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getResponseMapping((_a = property.type.properties) !== null && _a !== void 0 ? _a : [], `${propertyPath}.${property.restApiName}${property.optional ? "?" : ""}`, importSet)}}`;
447
+ 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)}}`;
413
448
  }
414
449
  props.push(definition);
415
450
  }
416
451
  else {
417
452
  const dot = propertyPath.endsWith("?") ? "." : "";
418
453
  const restValue = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}["${property.restApiName}"]`;
419
- props.push(`"${property.clientName}": ${deserializeResponseValue(property.type, restValue, importSet, property.optional !== undefined ? !property.optional : false)}`);
454
+ if ((property.restApiName === "message" ||
455
+ property.restApiName === "messages") &&
456
+ (property.type.name === "ChatMessage" ||
457
+ ((_c = property.type.elementType) === null || _c === void 0 ? void 0 : _c.name) === "ChatMessage")) {
458
+ props.push(`"${property.clientName}": ${!property.optional
459
+ ? `${propertyFullName} as any`
460
+ : `!${propertyFullName} ? undefined : ${propertyFullName} as any`}`);
461
+ }
462
+ else {
463
+ props.push(`"${property.clientName}": ${deserializeResponseValue(property.type, restValue, importSet, property.optional !== undefined ? !property.optional : false, property.format)}`);
464
+ }
420
465
  }
421
466
  }
422
467
  return props;
@@ -426,8 +471,8 @@ export function getResponseMapping(properties, propertyPath = "result.body", imp
426
471
  * We need to drill down into Array elements to make sure that the element type is
427
472
  * deserialized correctly
428
473
  */
429
- function deserializeResponseValue(type, restValue, importSet, required) {
430
- var _a, _b, _c, _d, _e, _f;
474
+ function deserializeResponseValue(type, restValue, importSet, required, format) {
475
+ var _a, _b, _c;
431
476
  const coreUtilSet = importSet.get("@azure/core-util");
432
477
  switch (type.type) {
433
478
  case "datetime":
@@ -438,10 +483,10 @@ function deserializeResponseValue(type, restValue, importSet, required) {
438
483
  return `${restValue} as any`;
439
484
  case "list":
440
485
  if (((_a = type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model") {
441
- return `(${restValue} ?? []).map(p => ({${getResponseMapping((_c = (_b = type.elementType) === null || _b === void 0 ? void 0 : _b.properties) !== null && _c !== void 0 ? _c : [], "p", importSet)}}))`;
486
+ return `(${restValue} ?? []).map(p => ({${getResponseMapping((_b = getAllProperties(type.elementType)) !== null && _b !== void 0 ? _b : [], "p", importSet)}}))`;
442
487
  }
443
- else if ((_e = (_d = type.elementType) === null || _d === void 0 ? void 0 : _d.properties) === null || _e === void 0 ? void 0 : _e.some((p) => needsDeserialize(p.type))) {
444
- return `(${restValue} ?? []).map(p => ${deserializeResponseValue(type.elementType, "p", importSet, required)})`;
488
+ else if (needsDeserialize(type.elementType)) {
489
+ return `(${restValue} ?? []).map(p => ${deserializeResponseValue(type.elementType, "p", importSet, required, (_c = type.elementType) === null || _c === void 0 ? void 0 : _c.format)})`;
445
490
  }
446
491
  else {
447
492
  return restValue;
@@ -454,7 +499,7 @@ function deserializeResponseValue(type, restValue, importSet, required) {
454
499
  coreUtilSet.add("stringToUint8Array");
455
500
  }
456
501
  return `typeof ${restValue} === 'string'
457
- ? stringToUint8Array(${restValue}, "${(_f = type.format) !== null && _f !== void 0 ? _f : "base64"}")
502
+ ? stringToUint8Array(${restValue}, "${format !== null && format !== void 0 ? format : "base64"}")
458
503
  : ${restValue}`;
459
504
  default:
460
505
  return restValue;
@@ -465,21 +510,34 @@ function deserializeResponseValue(type, restValue, importSet, required) {
465
510
  * We need to drill down into Array elements to make sure that the element type is
466
511
  * deserialized correctly
467
512
  */
468
- function serializeRequestValue(type, restValue, importSet = new Map()) {
469
- var _a, _b, _c, _d, _e, _f;
513
+ function serializeRequestValue(type, clientValue, importSet, required, format) {
514
+ var _a, _b, _c;
470
515
  const coreUtilSet = importSet.get("@azure/core-util");
471
516
  switch (type.type) {
472
517
  case "datetime":
473
- return `${restValue} !== undefined ? new Date(${restValue}): undefined`;
518
+ switch ((_a = type.format) !== null && _a !== void 0 ? _a : format) {
519
+ case "date":
520
+ return `${clientValue}${required ? "" : "?"}.toDateString()`;
521
+ case "time":
522
+ return `${clientValue}${required ? "" : "?"}.toTimeString()`;
523
+ case "rfc7231":
524
+ case "headerDefault":
525
+ return `${clientValue}${required ? "" : "?"}.toUTCString()`;
526
+ case "unixTimestamp":
527
+ return `${clientValue}${required ? "" : "?"}.getTime()`;
528
+ case "rfc3339":
529
+ default:
530
+ return `${clientValue}${required ? "" : "?"}.toISOString()`;
531
+ }
474
532
  case "list":
475
- if (((_a = type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model") {
476
- return `(${restValue} ?? []).map(p => ({${getResponseMapping((_c = (_b = type.elementType) === null || _b === void 0 ? void 0 : _b.properties) !== null && _c !== void 0 ? _c : [], "p", importSet)}}))`;
533
+ if (((_b = type.elementType) === null || _b === void 0 ? void 0 : _b.type) === "model") {
534
+ return `(${clientValue} ?? []).map(p => ({${getRequestModelMapping(type.elementType, "p", importSet)}}))`;
477
535
  }
478
- else if ((_e = (_d = type.elementType) === null || _d === void 0 ? void 0 : _d.properties) === null || _e === void 0 ? void 0 : _e.some((p) => needsDeserialize(p.type))) {
479
- return `(${restValue} ?? []).map(p => ${serializeRequestValue(type.elementType, "p", importSet)})`;
536
+ else if (needsDeserialize(type.elementType)) {
537
+ return `(${clientValue} ?? []).map(p => ${serializeRequestValue(type.elementType, "p", importSet, required, (_c = type.elementType) === null || _c === void 0 ? void 0 : _c.format)})`;
480
538
  }
481
539
  else {
482
- return restValue;
540
+ return clientValue;
483
541
  }
484
542
  case "byte-array":
485
543
  if (!coreUtilSet) {
@@ -488,13 +546,18 @@ function serializeRequestValue(type, restValue, importSet = new Map()) {
488
546
  else {
489
547
  coreUtilSet.add("uint8ArrayToString");
490
548
  }
491
- return `${restValue} !== undefined ? uint8ArrayToString(${restValue}, "${(_f = type.format) !== null && _f !== void 0 ? _f : "base64"}"): undefined`;
549
+ return required
550
+ ? `uint8ArrayToString(${clientValue}, "${format !== null && format !== void 0 ? format : "base64"}")`
551
+ : `${clientValue} !== undefined ? uint8ArrayToString(${clientValue}, "${format !== null && format !== void 0 ? format : "base64"}"): undefined`;
492
552
  default:
493
- return restValue;
553
+ return clientValue;
494
554
  }
495
555
  }
496
556
  function needsDeserialize(type) {
497
- return (type === null || type === void 0 ? void 0 : type.type) === "datetime" || (type === null || type === void 0 ? void 0 : type.type) === "model";
557
+ return ((type === null || type === void 0 ? void 0 : type.type) === "datetime" ||
558
+ (type === null || type === void 0 ? void 0 : type.type) === "model" ||
559
+ (type === null || type === void 0 ? void 0 : type.type) === "list" ||
560
+ (type === null || type === void 0 ? void 0 : type.type) === "byte-array");
498
561
  }
499
562
  export function hasLROOperation(codeModel) {
500
563
  var _a;
@@ -516,4 +579,20 @@ export function hasPagingOperation(codeModel) {
516
579
  });
517
580
  });
518
581
  }
582
+ function getAllProperties(type) {
583
+ var _a, _b;
584
+ const propertiesMap = new Map();
585
+ if (!type) {
586
+ return [];
587
+ }
588
+ (_a = type.parents) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
589
+ getAllProperties(p).forEach((prop) => {
590
+ propertiesMap.set(prop.clientName, prop);
591
+ });
592
+ });
593
+ (_b = type.properties) === null || _b === void 0 ? void 0 : _b.forEach((p) => {
594
+ propertiesMap.set(p.clientName, p);
595
+ });
596
+ return [...propertiesMap.values()];
597
+ }
519
598
  //# sourceMappingURL=operationHelpers.js.map