@azure-tools/typespec-ts 0.29.0-alpha.20240626.1 → 0.30.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 (73) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/contextManager.d.ts +70 -0
  3. package/dist/src/contextManager.d.ts.map +1 -0
  4. package/dist/src/contextManager.js +59 -0
  5. package/dist/src/contextManager.js.map +1 -0
  6. package/dist/src/index.d.ts.map +1 -1
  7. package/dist/src/index.js +13 -2
  8. package/dist/src/index.js.map +1 -1
  9. package/dist/src/metaTree.d.ts +12 -0
  10. package/dist/src/metaTree.d.ts.map +1 -0
  11. package/dist/src/metaTree.js +2 -0
  12. package/dist/src/metaTree.js.map +1 -0
  13. package/dist/src/modular/buildClassicalClient.js +3 -1
  14. package/dist/src/modular/buildClassicalClient.js.map +1 -1
  15. package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
  16. package/dist/src/modular/buildCodeModel.js +17 -7
  17. package/dist/src/modular/buildCodeModel.js.map +1 -1
  18. package/dist/src/modular/buildHelperSerializers.d.ts +3 -0
  19. package/dist/src/modular/buildHelperSerializers.d.ts.map +1 -0
  20. package/dist/src/modular/buildHelperSerializers.js +60 -0
  21. package/dist/src/modular/buildHelperSerializers.js.map +1 -0
  22. package/dist/src/modular/buildOperations.d.ts.map +1 -1
  23. package/dist/src/modular/buildOperations.js +5 -0
  24. package/dist/src/modular/buildOperations.js.map +1 -1
  25. package/dist/src/modular/buildSerializeUtils.d.ts.map +1 -1
  26. package/dist/src/modular/buildSerializeUtils.js +11 -4
  27. package/dist/src/modular/buildSerializeUtils.js.map +1 -1
  28. package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
  29. package/dist/src/modular/buildSubpathIndex.js +6 -0
  30. package/dist/src/modular/buildSubpathIndex.js.map +1 -1
  31. package/dist/src/modular/emitModels.d.ts +5 -5
  32. package/dist/src/modular/emitModels.d.ts.map +1 -1
  33. package/dist/src/modular/emitModels.js +32 -4
  34. package/dist/src/modular/emitModels.js.map +1 -1
  35. package/dist/src/modular/helpers/operationHelpers.d.ts +10 -2
  36. package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
  37. package/dist/src/modular/helpers/operationHelpers.js +135 -56
  38. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  39. package/dist/src/modular/helpers/typeHelpers.d.ts +1 -0
  40. package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
  41. package/dist/src/modular/helpers/typeHelpers.js +24 -19
  42. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  43. package/dist/src/modular/modularCodeModel.d.ts +2 -2
  44. package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
  45. package/dist/src/modular/serialization/buildSerializerFunction.d.ts +4 -0
  46. package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -0
  47. package/dist/src/modular/serialization/buildSerializerFunction.js +160 -0
  48. package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -0
  49. package/dist/src/transform/transformSchemas.d.ts.map +1 -1
  50. package/dist/src/transform/transformSchemas.js +3 -0
  51. package/dist/src/transform/transformSchemas.js.map +1 -1
  52. package/dist/src/utils/importHelper.d.ts +10 -0
  53. package/dist/src/utils/importHelper.d.ts.map +1 -0
  54. package/dist/src/utils/importHelper.js +54 -0
  55. package/dist/src/utils/importHelper.js.map +1 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +4 -4
  58. package/src/contextManager.ts +99 -0
  59. package/src/index.ts +14 -2
  60. package/src/metaTree.ts +14 -0
  61. package/src/modular/buildClassicalClient.ts +5 -1
  62. package/src/modular/buildCodeModel.ts +22 -6
  63. package/src/modular/buildHelperSerializers.ts +71 -0
  64. package/src/modular/buildOperations.ts +7 -1
  65. package/src/modular/buildSerializeUtils.ts +19 -11
  66. package/src/modular/buildSubpathIndex.ts +10 -0
  67. package/src/modular/emitModels.ts +66 -16
  68. package/src/modular/helpers/operationHelpers.ts +198 -84
  69. package/src/modular/helpers/typeHelpers.ts +24 -17
  70. package/src/modular/modularCodeModel.ts +2 -2
  71. package/src/modular/serialization/buildSerializerFunction.ts +224 -0
  72. package/src/transform/transformSchemas.ts +3 -0
  73. package/src/utils/importHelper.ts +64 -0
@@ -1,16 +1,16 @@
1
1
  import { InterfaceDeclarationStructure, OptionalKind, SourceFile } from "ts-morph";
2
- import { Client, ModularCodeModel, Type } from "./modularCodeModel.js";
3
- export declare function isModelWithAdditionalProperties(t: Type): boolean;
2
+ import { Client, ModularCodeModel, Type as ModularType } from "./modularCodeModel.js";
3
+ export declare function isModelWithAdditionalProperties(t: ModularType): boolean;
4
4
  /**
5
5
  * Extracts all the aliases from the code model
6
6
  * 1. alias from polymorphic base model, where we need to use typescript union to combine all the sub models
7
7
  * 2. alias from unions, where we also need to use typescript union to combine all the union variants
8
8
  */
9
- export declare function extractAliases(codeModel: ModularCodeModel): Type[];
9
+ export declare function extractAliases(codeModel: ModularCodeModel): ModularType[];
10
10
  type InterfaceStructure = OptionalKind<InterfaceDeclarationStructure> & {
11
11
  extends: string[];
12
12
  };
13
- export declare function buildModelInterface(model: Type, cache: {
13
+ export declare function buildModelInterface(model: ModularType, cache: {
14
14
  coreClientTypes: Set<string>;
15
15
  coreLroTypes: Set<string>;
16
16
  }): InterfaceStructure;
@@ -18,7 +18,7 @@ export declare function buildModelInterface(model: Type, cache: {
18
18
  * This function creates the file containing all the models defined in TypeSpec
19
19
  */
20
20
  export declare function buildModels(subClient: Client, codeModel: ModularCodeModel): SourceFile | undefined;
21
- export declare function buildModelTypeAlias(model: Type): {
21
+ export declare function buildModelTypeAlias(model: ModularType): {
22
22
  name: string;
23
23
  isExported: boolean;
24
24
  docs: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"emitModels.d.ts","sourceRoot":"","sources":["../../../src/modular/emitModels.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,6BAA6B,EAC7B,YAAY,EACZ,UAAU,EAEX,MAAM,UAAU,C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OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE;IAAE,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,GACjE,kBAAkB,CA+BpB;AAGD;;GAEG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,gBAAgB,GAC1B,UAAU,GAAG,SAAS,CA2HxB;AAgCD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW;;;;;EAOrD;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,gBAAgB,cAgD5B"}
@@ -1,9 +1,12 @@
1
- import { getImportSpecifier } from "@azure-tools/rlc-common";
1
+ import { addImportsToFiles, getImportSpecifier } from "@azure-tools/rlc-common";
2
2
  import * as path from "path";
3
3
  import { buildOperationOptions } from "./buildOperations.js";
4
4
  import { getDocsFromDescription } from "./helpers/docsHelpers.js";
5
5
  import { getModularModelFilePath } from "./helpers/namingHelpers.js";
6
6
  import { getType } from "./helpers/typeHelpers.js";
7
+ import { buildModelSerializer } from "./serialization/buildSerializerFunction.js";
8
+ import { toCamelCase } from "../utils/casingUtils.js";
9
+ import { addImportBySymbol } from "../utils/importHelper.js";
7
10
  // ====== UTILITIES ======
8
11
  function isAzureCoreErrorSdkType(t) {
9
12
  return (t.name &&
@@ -40,7 +43,7 @@ function extractModels(codeModel) {
40
43
  !isAnonymousModel(t)) ||
41
44
  isModelWithAdditionalProperties(t));
42
45
  for (const model of codeModel.types) {
43
- if (model.type === "combined" && model.nullable) {
46
+ if (model.type === "combined") {
44
47
  for (const unionModel of (_a = model.types) !== null && _a !== void 0 ? _a : []) {
45
48
  if (unionModel.type === "model") {
46
49
  models.push(unionModel);
@@ -158,9 +161,24 @@ export function buildModels(subClient, codeModel) {
158
161
  if (isModelWithAdditionalProperties(model)) {
159
162
  addExtendedDictInfo(model, modelInterface, codeModel.modularOptions.compatibilityMode);
160
163
  }
161
- modelsFile.addInterface(modelInterface);
164
+ if (!modelsFile.getInterface(modelInterface.name)) {
165
+ modelsFile.addInterface(modelInterface);
166
+ }
167
+ // Generate a serializer function next to each model
168
+ const serializerFunction = buildModelSerializer(model, codeModel.runtimeImports);
169
+ if (serializerFunction &&
170
+ !modelsFile.getFunction(toCamelCase(modelInterface.name + "Serializer"))) {
171
+ modelsFile.addStatements(serializerFunction);
172
+ }
173
+ addImportBySymbol("serializeRecord", modelsFile);
174
+ modelsFile.fixUnusedIdentifiers();
162
175
  }
163
176
  }
177
+ const projectRootFromModels = codeModel.clients.length > 1 ? "../.." : "../";
178
+ addImportsToFiles(codeModel.runtimeImports, modelsFile, {
179
+ rlcIndex: path.posix.join(projectRootFromModels, "rest", "index.js"),
180
+ serializerHelpers: path.posix.join(projectRootFromModels, "helpers", "serializerHelpers.js")
181
+ });
164
182
  if (coreClientTypes.size > 0) {
165
183
  modelsFile.addImportDeclarations([
166
184
  {
@@ -181,6 +199,13 @@ export function buildModels(subClient, codeModel) {
181
199
  }
182
200
  aliases.forEach((alias) => {
183
201
  modelsFile.addTypeAlias(buildModelTypeAlias(alias));
202
+ if (!models.includes(alias)) {
203
+ // Generate a serializer function next to each model
204
+ const serializerFunction = buildModelSerializer(alias, codeModel.runtimeImports);
205
+ if (serializerFunction) {
206
+ modelsFile.addStatements(serializerFunction);
207
+ }
208
+ }
184
209
  });
185
210
  return modelsFile;
186
211
  }
@@ -233,7 +258,10 @@ export function buildModelsOptions(client, codeModel) {
233
258
  namedImports: ["OperationOptions"]
234
259
  }
235
260
  ]);
236
- modelOptionsFile.fixMissingImports();
261
+ modelOptionsFile.fixMissingImports({}, {
262
+ importModuleSpecifierPreference: "shortest",
263
+ importModuleSpecifierEnding: "js"
264
+ });
237
265
  modelOptionsFile
238
266
  .getImportDeclarations()
239
267
  .filter((id) => {
@@ -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ACL,CAAC;IACD,gBAAgB,CAAC,qBAAqB,CAAC;QACrC;YACE,eAAe,EAAE,kBAAkB,CACjC,YAAY,EACZ,SAAS,CAAC,cAAc,CACzB;YACD,YAAY,EAAE,CAAC,kBAAkB,CAAC;SACnC;KACF,CAAC,CAAC;IAEH,gBAAgB,CAAC,iBAAiB,CAChC,EAAE,EACF;QACE,+BAA+B,EAAE,UAAU;QAC3C,2BAA2B,EAAE,IAAI;KAClC,CACF,CAAC;IACF,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,5 +1,5 @@
1
1
  import { Imports as RuntimeImports } from "@azure-tools/rlc-common";
2
- import { SdkContext } from "@azure-tools/typespec-client-generator-core";
2
+ import { SdkContext, SdkModelType, SdkType } from "@azure-tools/typespec-client-generator-core";
3
3
  import { FunctionDeclarationStructure, OptionalKind } from "ts-morph";
4
4
  import { Client, ModularCodeModel, Operation, Parameter, Property, Type } from "../modularCodeModel.js";
5
5
  export declare function getSendPrivateFunction(dpgContext: SdkContext, operation: Operation, clientType: string, runtimeImports: RuntimeImports): OptionalKind<FunctionDeclarationStructure>;
@@ -20,7 +20,11 @@ export declare function getParameterMap(param: Parameter | Property, runtimeImpo
20
20
  * This function helps translating an HLC request to RLC request,
21
21
  * extracting properties from body and headers and building the RLC response object
22
22
  */
23
- export declare function getRequestModelMapping(modelPropertyType: Type, propertyPath: string | undefined, runtimeImports: RuntimeImports, typeStack?: Type[]): string[];
23
+ interface RequestModelMappingResult {
24
+ propertiesStr: string[];
25
+ directAssignment?: boolean;
26
+ }
27
+ export declare function getRequestModelMapping(modelPropertyType: Type, propertyPath: string | undefined, runtimeImports: RuntimeImports, typeStack?: Type[]): RequestModelMappingResult;
24
28
  /**
25
29
  * This function helps translating an RLC response to an HLC response,
26
30
  * extracting properties from body and headers and building the HLC response object
@@ -45,4 +49,8 @@ export declare function hasPagingOnlyOperation(codeModel: ModularCodeModel, need
45
49
  export declare function isPagingOnlyOperation(op: Operation): boolean;
46
50
  export declare function getAllProperties(type: Type, parents?: Type[]): Property[];
47
51
  export declare function getAllAncestors(type: Type): Type[];
52
+ export declare function getPropertySerializationPrefix(modularType: Property | Parameter, propertyPath?: string): string;
53
+ export declare function getPropertyFullName(modularType: Property | Parameter, propertyPath?: string): string;
54
+ export declare function isDiscriminatedUnion(type?: SdkType): type is SdkModelType;
55
+ export {};
48
56
  //# 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,EAIL,OAAO,IAAI,cAAc,EAG1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAEzE,OAAO,EACL,4BAA4B,EAC5B,YAAY,EAEb,MAAM,UAAU,CAAC;AAclB,OAAO,EAEL,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACL,MAAM,wBAAwB,CAAC;AAkChC,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,cAAc,GAC7B,YAAY,CAAC,4BAA4B,CAAC,CAoC5C;AAED,wBAAgB,6BAA6B,CAC3C,SA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uBAAuB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAE9D;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAEzD;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC;AACX,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,gBAAgB,EAC3B,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC;AAoBX,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAE5D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,CAczE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAOlD"}
1
+ {"version":3,"file":"operationHelpers.d.ts","sourceRoot":"","sources":["../../../../src/modular/helpers/operationHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,IAAI,cAAc,EAG1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,YAAY,EACZ,OAAO,EACR,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACL,4BAA4B,EAC5B,YAAY,EAEb,MAAM,UAAU,CAAC;AAclB,OAAO,EAEL,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACL,MAAM,wBAAwB,CAAC;AAkChC,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,cAAc,GAC7B,YAAY,CAAC,4BAA4B,CAAC,CAoC5C;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,OAAO,EACtB,oBAAoB,EAAE,OAAO,EAC7B,cAAc,EAAE,cAAc,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,CA4GR;AAWD,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAE9D;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAEzD;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC;AACX,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,gBAAgB,EAC3B,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC;AAoBX,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAE5D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,CAczE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAOlD;AAED,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,QAAQ,GAAG,SAAS,EACjC,YAAY,CAAC,EAAE,MAAM,UAQtB;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,QAAQ,GAAG,SAAS,EACjC,YAAY,CAAC,EAAE,MAAM,UAOtB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,IAAI,YAAY,CAUzE"}
@@ -1,12 +1,12 @@
1
1
  import { addImportToSpecifier, getResponseBaseName, getResponseTypeName, NameType } from "@azure-tools/rlc-common";
2
2
  import { NoTarget } from "@typespec/compiler";
3
3
  import { reportDiagnostic } from "../../lib.js";
4
- import { toPascalCase } from "../../utils/casingUtils.js";
4
+ import { toCamelCase, toPascalCase } from "../../utils/casingUtils.js";
5
5
  import { getCollectionFormatHelper, hasCollectionFormatInfo } from "../../utils/operationUtil.js";
6
6
  import { getDeserializeFunctionName, isNormalUnion, isPolymorphicUnion, isSpecialHandledUnion, isSpecialUnionVariant } from "../buildSerializeUtils.js";
7
7
  import { getDocsFromDescription, getFixmeForMultilineDocs } from "./docsHelpers.js";
8
8
  import { getClassicalLayerPrefix, getOperationName } from "./namingHelpers.js";
9
- import { buildType } from "./typeHelpers.js";
9
+ import { buildType, isTypeNullable } from "./typeHelpers.js";
10
10
  function getRLCResponseType(rlcResponse) {
11
11
  if (!(rlcResponse === null || rlcResponse === void 0 ? void 0 : rlcResponse.responses)) {
12
12
  return;
@@ -129,7 +129,8 @@ export function getDeserializePrivateFunction(operation, needSubClient, needUnex
129
129
  ((deserializedType === null || deserializedType === void 0 ? void 0 : deserializedType.type) === "model" &&
130
130
  allParents.some((p) => p.type === "dict")) ||
131
131
  response.isBinaryPayload) {
132
- statements.push(`return result.body`);
132
+ // TODO: Fix this any cast when implementing handling dict.
133
+ statements.push(`return result.body as any`);
133
134
  }
134
135
  else if (deserializedType &&
135
136
  properties.length > 0 &&
@@ -140,9 +141,8 @@ export function getDeserializePrivateFunction(operation, needSubClient, needUnex
140
141
  statements.push(`return;`);
141
142
  }
142
143
  else {
143
- statements.push(`return ${deserializeResponseValue(deserializedType, deserializedRoot, runtimeImports, deserializedType.nullable !== undefined
144
- ? !deserializedType.nullable
145
- : false, [deserializedType], deserializedType.format)}`);
144
+ statements.push(`return ${deserializeResponseValue(deserializedType, deserializedRoot, runtimeImports, false, // TODO: Calculate if required
145
+ [deserializedType], deserializedType.format)}`);
146
146
  }
147
147
  return {
148
148
  ...functionStatement,
@@ -384,7 +384,7 @@ function getRequestParameters(dpgContext, operation, runtimeImports) {
384
384
  }
385
385
  // Specially handle the type for headers because we only allow string/number/boolean values
386
386
  function buildHeaderParameter(program, paramMap, param) {
387
- if (!param.optional && param.type.nullable === true) {
387
+ if (!param.optional && isTypeNullable(param.type) === true) {
388
388
  reportDiagnostic(program, {
389
389
  code: "nullable-required-header",
390
390
  target: NoTarget
@@ -395,7 +395,7 @@ function buildHeaderParameter(program, paramMap, param) {
395
395
  if (param.optional) {
396
396
  conditions.push(`options?.${param.clientName} !== undefined`);
397
397
  }
398
- if (param.type.nullable === true) {
398
+ if (isTypeNullable(param.type) === true) {
399
399
  conditions.push(`options?.${param.clientName} !== null`);
400
400
  }
401
401
  return conditions.length > 0
@@ -403,7 +403,7 @@ function buildHeaderParameter(program, paramMap, param) {
403
403
  : paramMap;
404
404
  }
405
405
  function buildBodyParameter(bodyParameter, runtimeImports) {
406
- var _a;
406
+ var _a, _b;
407
407
  if (!bodyParameter) {
408
408
  return "";
409
409
  }
@@ -411,7 +411,7 @@ function buildBodyParameter(bodyParameter, runtimeImports) {
411
411
  if (bodyParameter.type.type === "model" &&
412
412
  !bodyParameter.type.aliasType &&
413
413
  !allParents.some((p) => p.type === "dict")) {
414
- const bodyParts = getRequestModelMapping(bodyParameter.type, bodyParameter.clientName, runtimeImports, [bodyParameter.type]);
414
+ const { propertiesStr: bodyParts } = getRequestModelMapping(bodyParameter.type, bodyParameter.clientName, runtimeImports, [bodyParameter.type]);
415
415
  if (bodyParameter && bodyParts.length > 0) {
416
416
  const optionalBody = bodyParameter.optional
417
417
  ? `${bodyParameter.clientName} === undefined ? ${bodyParameter.clientName} : `
@@ -422,19 +422,41 @@ function buildBodyParameter(bodyParameter, runtimeImports) {
422
422
  return `\nbody: ${bodyParameter.clientName},`;
423
423
  }
424
424
  }
425
+ else if (isDiscriminatedUnion(bodyParameter.type.tcgcType)) {
426
+ const serializerName = toCamelCase(`${bodyParameter.type.name}Serializer`);
427
+ addImportToSpecifier("modularModel", runtimeImports, serializerName);
428
+ return `\nbody: ${serializerName}(${bodyParameter.clientName}),`;
429
+ }
425
430
  else if ((bodyParameter.type.type === "model" &&
426
431
  (bodyParameter.type.aliasType ||
427
432
  allParents.some((p) => p.type === "dict"))) ||
428
433
  bodyParameter.type.type === "dict") {
429
- return `\nbody: ${bodyParameter.clientName},`;
434
+ const elementSerializerName = ((_a = bodyParameter.type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model"
435
+ ? toCamelCase(`${bodyParameter.type.elementType.name}Serializer`)
436
+ : "";
437
+ let modelSerializerName = "";
438
+ if (bodyParameter.type.type !== "dict") {
439
+ modelSerializerName = toCamelCase(`${bodyParameter.type.name}Serializer`);
440
+ }
441
+ if (modelSerializerName) {
442
+ return `\nbody: ${modelSerializerName}(${bodyParameter.clientName}),`;
443
+ }
444
+ else {
445
+ // Need to do this so that Records are compatible with additional properties of other types
446
+ // this should check for compatibility mode once we support the additionalProperties property
447
+ return `\nbody: serializeRecord(${bodyParameter.clientName} as any, ${elementSerializerName}) as any,`;
448
+ }
430
449
  }
431
450
  if (bodyParameter.type.type === "list") {
432
- if (((_a = bodyParameter.type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model" &&
451
+ if (((_b = bodyParameter.type.elementType) === null || _b === void 0 ? void 0 : _b.type) === "model" &&
433
452
  !bodyParameter.type.elementType.aliasType) {
434
- const bodyParts = getRequestModelMapping(bodyParameter.type.elementType, "p", runtimeImports, [bodyParameter.type.elementType]);
435
- return `\nbody: (${bodyParameter.clientName} ?? []).map((p) => { return {
436
- ${bodyParts.join(", ")}
437
- };}),`;
453
+ const { propertiesStr: bodyParts, directAssignment } = getRequestModelMapping(bodyParameter.type.elementType, "p", runtimeImports, [bodyParameter.type.elementType]);
454
+ const mapBody = directAssignment === true
455
+ ? bodyParts.join(", ")
456
+ : `{ ${bodyParts.join(", ")} }`;
457
+ return `\nbody: (${bodyParameter.clientName} ?? []).map((p) => {
458
+ return ${mapBody};
459
+ }),`;
438
460
  }
439
461
  return `\nbody: ${bodyParameter.clientName},`;
440
462
  }
@@ -516,7 +538,8 @@ function isRequired(param) {
516
538
  }
517
539
  function getRequired(param, runtimeImports) {
518
540
  if (param.type.type === "model") {
519
- return `"${param.restApiName}": {${getRequestModelMapping(param.type, param.clientName, runtimeImports, [param.type]).join(",")}}`;
541
+ const { propertiesStr } = getRequestModelMapping(param.type, param.clientName, runtimeImports, [param.type]);
542
+ return `"${param.restApiName}": { ${propertiesStr.join(",")} }`;
520
543
  }
521
544
  return `"${param.restApiName}": ${serializeRequestValue(param.type, param.clientName, runtimeImports, true, [param.type], param.format === undefined &&
522
545
  param.location === "header" &&
@@ -540,7 +563,8 @@ function isOptional(param) {
540
563
  }
541
564
  function getOptional(param, runtimeImports) {
542
565
  if (param.type.type === "model") {
543
- return `"${param.restApiName}": {${getRequestModelMapping(param.type, "options?." + param.clientName + "?", runtimeImports, [param.type]).join(", ")}}`;
566
+ const { propertiesStr } = getRequestModelMapping(param.type, "options?." + param.clientName + "?", runtimeImports, [param.type]);
567
+ return `"${param.restApiName}": { ${propertiesStr.join(", ")} }`;
544
568
  }
545
569
  if (param.restApiName === "api-version" &&
546
570
  param.location === "query") {
@@ -588,35 +612,35 @@ function getPathParameters(operation) {
588
612
  return pathParams;
589
613
  }
590
614
  function getNullableCheck(name, type) {
591
- if (!type.nullable) {
615
+ if (!isTypeNullable(type)) {
592
616
  return "";
593
617
  }
594
618
  return `${name} === null ? null :`;
595
619
  }
596
- /**
597
- *
598
- * This function helps translating an HLC request to RLC request,
599
- * extracting properties from body and headers and building the RLC response object
600
- */
601
620
  export function getRequestModelMapping(modelPropertyType, propertyPath = "body", runtimeImports, typeStack = []) {
602
- var _a;
621
+ var _a, _b;
603
622
  const props = [];
604
623
  const allParents = getAllAncestors(modelPropertyType);
605
624
  const properties = (_a = getAllProperties(modelPropertyType, allParents)) !== null && _a !== void 0 ? _a : [];
606
625
  if (properties.length <= 0) {
607
- return [];
626
+ return { propertiesStr: [] };
608
627
  }
628
+ let serializerName = "name" in modelPropertyType && modelPropertyType.name
629
+ ? `${toCamelCase(modelPropertyType.name)}Serializer`
630
+ : undefined;
609
631
  if (isSpecialHandledUnion(modelPropertyType)) {
610
- const deserializeFunctionName = getDeserializeFunctionName(modelPropertyType, "serialize");
611
- const definition = `${deserializeFunctionName}(${propertyPath})`;
632
+ serializerName =
633
+ serializerName !== null && serializerName !== void 0 ? serializerName : getDeserializeFunctionName(modelPropertyType, "serialize");
634
+ const definition = `${serializerName}(${propertyPath})`;
612
635
  props.push(definition);
613
- return props;
636
+ return { propertiesStr: props, directAssignment: true };
614
637
  }
615
638
  for (const property of properties) {
616
639
  if (property.readonly) {
617
640
  continue;
618
641
  }
619
- const propertyFullName = `${propertyPath}.${property.clientName}`;
642
+ const nullOrUndefinedPrefix = getPropertySerializationPrefix(property, propertyPath);
643
+ const propertyFullName = getPropertyFullName(property, propertyPath);
620
644
  if (property.type.type === "model") {
621
645
  let definition;
622
646
  if (property.type.coreTypeInfo === "ErrorType") {
@@ -629,15 +653,23 @@ export function getRequestModelMapping(modelPropertyType, propertyPath = "body",
629
653
  : `!${propertyFullName} ? undefined : ${propertyFullName}${isSpecialModel ? " as any" : ""}`}`;
630
654
  }
631
655
  else if (isPolymorphicUnion(property.type)) {
632
- let nullOrUndefinedPrefix = "";
633
- if (property.optional || property.type.nullable) {
634
- nullOrUndefinedPrefix = `!${propertyFullName} ? ${propertyFullName} :`;
635
- }
636
- const deserializeFunctionName = getDeserializeFunctionName(property.type, "serialize");
656
+ const deserializeFunctionName = property.type.name
657
+ ? `${toCamelCase(property.type.name)}Serializer`
658
+ : getDeserializeFunctionName(property.type, "serialize");
637
659
  definition = `"${property.restApiName}": ${nullOrUndefinedPrefix}${deserializeFunctionName}(${propertyFullName})`;
638
660
  }
639
661
  else {
640
- definition = `"${property.restApiName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} {${getRequestModelMapping(property.type, `${propertyPath}.${property.clientName}${property.optional ? "?" : ""}`, runtimeImports, [...typeStack, property.type])}}`;
662
+ if (property.type.name) {
663
+ serializerName = `${toCamelCase(property.type.name)}Serializer`;
664
+ definition = `"${property.restApiName}": ${nullOrUndefinedPrefix}${serializerName}(${propertyPath}.${property.clientName})`;
665
+ }
666
+ else {
667
+ const { propertiesStr, directAssignment } = getRequestModelMapping(property.type, `${propertyPath}.${property.clientName}${property.optional ? "?" : ""}`, runtimeImports, [...typeStack, property.type]);
668
+ const serializeContent = directAssignment === true
669
+ ? propertiesStr.join(",")
670
+ : `{${propertiesStr.join(",")}}`;
671
+ definition = `"${property.restApiName}": ${getNullableCheck(propertyFullName, property.type)} ${!property.optional ? "" : `!${propertyFullName} ? undefined :`} ${serializeContent}`;
672
+ }
641
673
  }
642
674
  props.push(definition);
643
675
  }
@@ -648,13 +680,29 @@ export function getRequestModelMapping(modelPropertyType, propertyPath = "body",
648
680
  : `!${propertyFullName} ? undefined : ${propertyFullName}${isSpecialModel ? " as any" : ""}`}`;
649
681
  props.push(definition);
650
682
  }
683
+ else if (property.type.type === "dict") {
684
+ const modelName = (_b = property.type.elementType) === null || _b === void 0 ? void 0 : _b.name;
685
+ serializerName = modelName ? `${toCamelCase(modelName)}Serializer` : "";
686
+ // definition = `"${property.restApiName}": ${nullOrUndefinedPrefix}${serializerName}(${propertyPath}.${property.clientName})`;
687
+ const statement = `"${property.restApiName}": ${nullOrUndefinedPrefix} serializeRecord(${propertyFullName} as any, ${serializerName}) as any`;
688
+ // addImportToSpecifier(
689
+ // "serializerHelpers",
690
+ // runtimeImports,
691
+ // "serializeRecord"
692
+ // );
693
+ addImportToSpecifier("modularModel", runtimeImports, serializerName);
694
+ props.push(statement);
695
+ }
696
+ else if (modelPropertyType.type === "enum") {
697
+ props.push(`"${property.restApiName}": ${nullOrUndefinedPrefix}${propertyPath}.${property.clientName}`);
698
+ }
651
699
  else {
652
700
  const dot = propertyPath.endsWith("?") ? "." : "";
653
701
  const clientValue = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}["${property.clientName}"]`;
654
702
  props.push(`"${property.restApiName}": ${serializeRequestValue(property.type, clientValue, runtimeImports, !property.optional, [...typeStack, property.type], property.format)}`);
655
703
  }
656
704
  }
657
- return props;
705
+ return { propertiesStr: props };
658
706
  }
659
707
  /**
660
708
  * This function helps translating an RLC response to an HLC response,
@@ -683,10 +731,7 @@ export function getResponseMapping(type, propertyPath = "result.body", runtimeIm
683
731
  : `!${propertyFullName} ? undefined : ${propertyFullName}${isSpecialModel ? " as any" : ""}`}`;
684
732
  }
685
733
  else if (isSpecialHandledUnion(property.type)) {
686
- let nullOrUndefinedPrefix = "";
687
- if (property.optional || property.type.nullable) {
688
- nullOrUndefinedPrefix = `!${propertyFullName} ? ${propertyFullName} :`;
689
- }
734
+ const nullOrUndefinedPrefix = getPropertySerializationPrefix(property, propertyPath);
690
735
  const deserializeFunctionName = getDeserializeFunctionName(property.type, "deserialize");
691
736
  definition = `"${property.clientName}": ${nullOrUndefinedPrefix}${deserializeFunctionName}(${propertyFullName})`;
692
737
  }
@@ -720,19 +765,19 @@ export function getResponseMapping(type, propertyPath = "result.body", runtimeIm
720
765
  export function deserializeResponseValue(type, restValue, runtimeImports, required, typeStack = [], format) {
721
766
  var _a, _b, _c, _d, _e;
722
767
  const requiredPrefix = required === false ? `${restValue} === undefined` : "";
723
- const nullablePrefix = type.nullable ? `${restValue} === null` : "";
768
+ const nullablePrefix = isTypeNullable(type) ? `${restValue} === null` : "";
724
769
  const requiredOrNullablePrefix = requiredPrefix !== "" && nullablePrefix !== ""
725
770
  ? `(${requiredPrefix} || ${nullablePrefix})`
726
771
  : `${requiredPrefix}${nullablePrefix}`;
727
772
  switch (type.type) {
728
773
  case "datetime":
729
774
  return required
730
- ? type.nullable
775
+ ? isTypeNullable(type)
731
776
  ? `${restValue} === null ? null : new Date(${restValue})`
732
777
  : `new Date(${restValue})`
733
778
  : `${restValue} !== undefined? new Date(${restValue}): undefined`;
734
779
  case "list": {
735
- const prefix = required && !type.nullable
780
+ const prefix = required && !isTypeNullable(type)
736
781
  ? `${restValue}`
737
782
  : `${requiredOrNullablePrefix} ? ${restValue} : ${restValue}`;
738
783
  if (((_a = type.elementType) === null || _a === void 0 ? void 0 : _a.type) === "model") {
@@ -741,7 +786,7 @@ export function deserializeResponseValue(type, restValue, runtimeImports, requir
741
786
  }
742
787
  else if (isPolymorphicUnion(type.elementType)) {
743
788
  let nullOrUndefinedPrefix = "";
744
- if (type.elementType.nullable) {
789
+ if (isTypeNullable(type.elementType)) {
745
790
  nullOrUndefinedPrefix = `!p ? p :`;
746
791
  }
747
792
  const deserializeFunctionName = getDeserializeFunctionName(type.elementType, "deserialize");
@@ -801,9 +846,9 @@ export function deserializeResponseValue(type, restValue, runtimeImports, requir
801
846
  * deserialized correctly
802
847
  */
803
848
  export function serializeRequestValue(type, clientValue, runtimeImports, required, typeStack = [], format) {
804
- var _a, _b, _c, _d, _e, _f, _g;
849
+ var _a, _b, _c, _d, _e, _f, _g, _h;
805
850
  const requiredPrefix = required === false ? `${clientValue} === undefined` : "";
806
- const nullablePrefix = type.nullable ? `${clientValue} === null` : "";
851
+ const nullablePrefix = isTypeNullable(type) ? `${clientValue} === null` : "";
807
852
  const requiredOrNullablePrefix = requiredPrefix !== "" && nullablePrefix !== ""
808
853
  ? `(${requiredPrefix} || ${nullablePrefix})`
809
854
  : `${requiredPrefix}${nullablePrefix}`;
@@ -821,26 +866,36 @@ export function serializeRequestValue(type, clientValue, runtimeImports, require
821
866
  return `${clientValue}${required ? "" : "?"}.getTime()`;
822
867
  case "rfc3339":
823
868
  default:
824
- return `${clientValue}${required ? "" : "?"}.toISOString()`;
869
+ return `${getNullableCheck(clientValue, type)} ${clientValue}${required ? "" : "?"}.toISOString()`;
825
870
  }
826
871
  case "list": {
827
- const prefix = required && !type.nullable
872
+ const prefix = required && !isTypeNullable(type)
828
873
  ? `${clientValue}`
829
874
  : `${requiredOrNullablePrefix}? ${clientValue}: ${clientValue}`;
830
875
  if (((_b = type.elementType) === null || _b === void 0 ? void 0 : _b.type) === "model" && !type.elementType.aliasType) {
831
- return `${prefix}.map(p => ({${getRequestModelMapping(type.elementType, "p", runtimeImports, [...typeStack, type.elementType])}}))`;
876
+ if (!type.elementType.name) {
877
+ // If it is an anonymous model we need to serialize inline
878
+ const { propertiesStr } = getRequestModelMapping(type.elementType, "p", runtimeImports, [...typeStack, type.elementType]);
879
+ return `${prefix}.map(p => ({${propertiesStr}}))`;
880
+ }
881
+ else {
882
+ // When it is not anonymous we can hand it off to the serializer function
883
+ return `${prefix}.map(${toCamelCase(type.elementType.name + "Serializer")})`;
884
+ }
832
885
  }
833
886
  else if (needsDeserialize(type.elementType) &&
834
887
  !((_c = type.elementType) === null || _c === void 0 ? void 0 : _c.aliasType)) {
835
- return `${prefix}.map(p => ${serializeRequestValue(type.elementType, "p", runtimeImports, required, [...typeStack, type.elementType], (_d = type.elementType) === null || _d === void 0 ? void 0 : _d.format)})`;
888
+ return `${prefix}.map(p => ${serializeRequestValue(type.elementType, "p", runtimeImports, true, [...typeStack, type.elementType], (_d = type.elementType) === null || _d === void 0 ? void 0 : _d.format)})`;
836
889
  }
837
890
  else if (((_e = type.elementType) === null || _e === void 0 ? void 0 : _e.type) === "model" &&
838
891
  isPolymorphicUnion(type.elementType)) {
839
892
  let nullOrUndefinedPrefix = "";
840
- if (type.elementType.nullable) {
893
+ if (isTypeNullable(type.elementType)) {
841
894
  nullOrUndefinedPrefix = `!p ? p :`;
842
895
  }
843
- const serializeFunctionName = getDeserializeFunctionName(type.elementType, "serialize");
896
+ const serializeFunctionName = ((_f = type.elementType) === null || _f === void 0 ? void 0 : _f.name)
897
+ ? `${toCamelCase(type.elementType.name)}Serializer`
898
+ : getDeserializeFunctionName(type.elementType, "serialize");
844
899
  return `${prefix}.map(p => ${nullOrUndefinedPrefix}${serializeFunctionName}(p))`;
845
900
  }
846
901
  else {
@@ -851,8 +906,8 @@ export function serializeRequestValue(type, clientValue, runtimeImports, require
851
906
  if (format !== "binary") {
852
907
  addImportToSpecifier("coreUtil", runtimeImports, "uint8ArrayToString");
853
908
  return required
854
- ? `uint8ArrayToString(${clientValue}, "${(_f = getEncodingFormat({ format })) !== null && _f !== void 0 ? _f : "base64"}")`
855
- : `${clientValue} !== undefined ? uint8ArrayToString(${clientValue}, "${(_g = getEncodingFormat({ format })) !== null && _g !== void 0 ? _g : "base64"}"): undefined`;
909
+ ? `${getNullableCheck(clientValue, type)} uint8ArrayToString(${clientValue}, "${(_g = getEncodingFormat({ format })) !== null && _g !== void 0 ? _g : "base64"}")`
910
+ : `${clientValue} !== undefined ? uint8ArrayToString(${clientValue}, "${(_h = getEncodingFormat({ format })) !== null && _h !== void 0 ? _h : "base64"}"): undefined`;
856
911
  }
857
912
  return clientValue;
858
913
  case "combined":
@@ -860,7 +915,9 @@ export function serializeRequestValue(type, clientValue, runtimeImports, require
860
915
  return `${clientValue}`;
861
916
  }
862
917
  else if (isSpecialHandledUnion(type)) {
863
- const serializeFunctionName = getDeserializeFunctionName(type, "serialize");
918
+ const serializeFunctionName = type.name
919
+ ? `${toCamelCase(type.name)}Serializer`
920
+ : getDeserializeFunctionName(type, "serialize");
864
921
  return `${serializeFunctionName}(${clientValue})`;
865
922
  }
866
923
  else {
@@ -927,4 +984,26 @@ export function getAllAncestors(type) {
927
984
  });
928
985
  return ancestors;
929
986
  }
987
+ export function getPropertySerializationPrefix(modularType, propertyPath) {
988
+ const propertyFullName = getPropertyFullName(modularType, propertyPath);
989
+ if (modularType.optional || isTypeNullable(modularType.type)) {
990
+ return `!${propertyFullName} ? ${propertyFullName} :`;
991
+ }
992
+ return "";
993
+ }
994
+ export function getPropertyFullName(modularType, propertyPath) {
995
+ let fullName = `${modularType.clientName}`;
996
+ if (propertyPath) {
997
+ fullName = `${propertyPath}.${modularType.clientName}`;
998
+ }
999
+ return fullName;
1000
+ }
1001
+ export function isDiscriminatedUnion(type) {
1002
+ if (!type) {
1003
+ return false;
1004
+ }
1005
+ return Boolean(type.kind === "model" &&
1006
+ type.discriminatorProperty &&
1007
+ type.discriminatedSubtypes);
1008
+ }
930
1009
  //# sourceMappingURL=operationHelpers.js.map