@azure-tools/typespec-java 0.16.2 → 0.16.3

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.
@@ -39,7 +39,7 @@ export declare class CodeModelBuilder {
39
39
  /**
40
40
  * `@armProviderNamespace` currently will add a default server if not defined globally:
41
41
  * https://github.com/Azure/typespec-azure/blob/8b8d7c05f168d9305a09691c4fedcb88f4a57652/packages/typespec-azure-resource-manager/src/namespace.ts#L121-L128
42
- * TODO: if the synthesized server has the right hostParameter, we can use that insteadß
42
+ * TODO: if the synthesized server has the right hostParameter, we can use that instead
43
43
  *
44
44
  * @param server returned by getServers
45
45
  * @returns whether it's synthesized by `@armProviderNamespace`
@@ -1 +1 @@
1
- {"version":3,"file":"code-model-builder.d.ts","sourceRoot":"","sources":["../../src/code-model-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIT,YAAY,EACZ,aAAa,EAeb,YAAY,EAEZ,YAAY,EAEZ,SAAS,EAKT,MAAM,EAMN,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAaL,OAAO,EAkBR,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EAMX,OAAO,EAEP,IAAI,EAEJ,KAAK,EAkBN,MAAM,oBAAoB,CAAC;AAuB5B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAkB9C,OAAO,EACL,eAAe,EAchB,MAAM,iBAAiB,CAAC;AAWzB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,cAAc,CAAkB;IAExC,QAAQ,CAAC,WAA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AS,CAEzB;IAED,OAAO,CAAC,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAE/B;IAED,OAAO,CAAC,iBAAiB,CAAC,CAAe;IACzC,IAAI,gBAAgB,IAAI,YAAY,CAKnC;IAED,OAAO,CAAC,yBAAyB;IA8BjC,OAAO,CAAC,oBAAoB,CAAC,CAAY;IACzC,IAAI,mBAAmB,IAAI,SAAS,CAKnC;IAED,OAAO,CAAC,0BAA0B,CAAC,CAAY;IAC/C,IAAI,yBAAyB,IAAI,SAAS,CAMzC;IAED,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IAoE5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,KAAK;CAGd"}
@@ -2,7 +2,7 @@ import { AnySchema, ApiVersion, ArraySchema, BinaryResponse, BinarySchema, Boole
2
2
  import { KnownMediaType } from "@azure-tools/codegen";
3
3
  import { getLroMetadata, getPagedResult, isPollingLocation } from "@azure-tools/typespec-azure-core";
4
4
  import { createSdkContext, getAllModels, getClientNameOverride, getClientType, getCrossLanguageDefinitionId, getDefaultApiVersion, getWireName, isApiVersion, isInternal, isSdkBuiltInKind, isSdkIntKind, listClients, listOperationGroups, listOperationsInOperationGroup, shouldGenerateConvenient, shouldGenerateProtocol, } from "@azure-tools/typespec-client-generator-core";
5
- import { getDoc, getEffectiveModelType, getEncode, getFriendlyName, getNamespaceFullName, getOverloadedOperation, getProjectedName, getSummary, getTypeName, getVisibility, ignoreDiagnostics, isArrayModelType, isErrorModel, isRecordModelType, isVoidType, listServices, } from "@typespec/compiler";
5
+ import { getDoc, getEffectiveModelType, getEncode, getFriendlyName, getNamespaceFullName, getOverloadedOperation, getProjectedName, getSummary, getVisibility, ignoreDiagnostics, isArrayModelType, isErrorModel, isRecordModelType, isVoidType, listServices, } from "@typespec/compiler";
6
6
  import { Visibility, getAuthentication, getHeaderFieldOptions, getHttpOperation, getQueryParamOptions, getServers, getStatusCodeDescription, isPathParam, } from "@typespec/http";
7
7
  import { getResourceOperation, getSegment } from "@typespec/rest";
8
8
  import { getAddedOnVersions, getVersion } from "@typespec/versioning";
@@ -21,7 +21,7 @@ import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./extern
21
21
  import { ClientContext } from "./models.js";
22
22
  import { CONTENT_TYPE_KEY, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, isPayloadProperty, loadExamples, operationIsJsonMergePatch, operationIsMultipart, operationIsMultipleContentTypes, } from "./operation-utils.js";
23
23
  import { PreNamer } from "./prenamer/prenamer.js";
24
- import { ProcessingCache, getAccess, getDurationFormatFromSdkType, getNameForTemplate, getNamePrefixForProperty, getUnionDescription, getUsage, hasScalarAsBase, isArmCommonType, isModelReferredInTemplate, isNullableType, isStable, modelIs, pushDistinct, } from "./type-utils.js";
24
+ import { ProcessingCache, getAccess, getDurationFormatFromSdkType, getUnionDescription, getUsage, hasScalarAsBase, isArmCommonType, isModelReferredInTemplate, isNullableType, isStable, modelIs, pushDistinct, } from "./type-utils.js";
25
25
  import { getJavaNamespace, getNamespace, logWarning, pascalCase, stringArrayContainsIgnoreCase, trace, } from "./utils.js";
26
26
  const { isEqual } = pkg;
27
27
  export class CodeModelBuilder {
@@ -115,7 +115,7 @@ export class CodeModelBuilder {
115
115
  parameter = new Parameter(it.name, this.getDoc(it), schema, {
116
116
  implementation: ImplementationLocation.Client,
117
117
  origin: "modelerfour:synthesized/host",
118
- required: true,
118
+ required: !it.optional,
119
119
  protocol: {
120
120
  http: new HttpParameter(ParameterLocation.Uri),
121
121
  },
@@ -134,6 +134,7 @@ export class CodeModelBuilder {
134
134
  return hostParameters;
135
135
  }
136
136
  else {
137
+ // use "endpoint"
137
138
  hostParameters.push(this.codeModel.addGlobalParameter(new Parameter("endpoint", "Server parameter", this.stringSchema, {
138
139
  implementation: ImplementationLocation.Client,
139
140
  origin: "modelerfour:synthesized/host",
@@ -445,7 +446,7 @@ export class CodeModelBuilder {
445
446
  /**
446
447
  * `@armProviderNamespace` currently will add a default server if not defined globally:
447
448
  * https://github.com/Azure/typespec-azure/blob/8b8d7c05f168d9305a09691c4fedcb88f4a57652/packages/typespec-azure-resource-manager/src/namespace.ts#L121-L128
448
- * TODO: if the synthesized server has the right hostParameter, we can use that insteadß
449
+ * TODO: if the synthesized server has the right hostParameter, we can use that instead
449
450
  *
450
451
  * @param server returned by getServers
451
452
  * @returns whether it's synthesized by `@armProviderNamespace`
@@ -599,8 +600,7 @@ export class CodeModelBuilder {
599
600
  // lro metadata
600
601
  const lroMetadata = this.processLroMetadata(codeModelOperation, op);
601
602
  // responses
602
- const candidateResponseSchema = lroMetadata.pollResultType; // candidate: response body type of pollingOperation
603
- op.responses.map((it) => this.processResponse(codeModelOperation, it, candidateResponseSchema));
603
+ op.responses.map((it) => this.processResponse(codeModelOperation, it, lroMetadata.longRunning));
604
604
  // check for paged
605
605
  this.processRouteForPaged(codeModelOperation, op.responses);
606
606
  // check for long-running operation
@@ -635,6 +635,7 @@ export class CodeModelBuilder {
635
635
  }
636
636
  processLroMetadata(op, httpOperation) {
637
637
  const operation = httpOperation.operation;
638
+ const trackConvenienceApi = Boolean(op.convenienceApi);
638
639
  const lroMetadata = getLroMetadata(this.program, operation);
639
640
  // needs lroMetadata.statusMonitorStep, as getLroMetadata would return for @pollingOperation operation
640
641
  if (lroMetadata && lroMetadata.pollingInfo && lroMetadata.statusMonitorStep) {
@@ -685,7 +686,7 @@ export class CodeModelBuilder {
685
686
  // track usage
686
687
  if (pollingSchema) {
687
688
  this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Output] });
688
- if (op.convenienceApi) {
689
+ if (trackConvenienceApi) {
689
690
  this.trackSchemaUsage(pollingSchema, {
690
691
  usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public],
691
692
  });
@@ -693,7 +694,7 @@ export class CodeModelBuilder {
693
694
  }
694
695
  if (finalSchema) {
695
696
  this.trackSchemaUsage(finalSchema, { usage: [SchemaContext.Output] });
696
- if (op.convenienceApi) {
697
+ if (trackConvenienceApi) {
697
698
  this.trackSchemaUsage(finalSchema, {
698
699
  usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public],
699
700
  });
@@ -1023,7 +1024,8 @@ export class CodeModelBuilder {
1023
1024
  schema = this.processSchemaFromSdkType(sdkType, body.name);
1024
1025
  }
1025
1026
  const isAnonymousModel = sdkType.kind === "model" && sdkType.isGeneratedName === true;
1026
- const parameter = new Parameter(this.getName(body), this.getDoc(body), schema, {
1027
+ const parameterName = body.kind === "Model" ? (sdkType.kind === "model" ? sdkType.name : "") : this.getName(body);
1028
+ const parameter = new Parameter(parameterName, this.getDoc(body), schema, {
1027
1029
  summary: this.getSummary(body),
1028
1030
  implementation: ImplementationLocation.Method,
1029
1031
  required: body.kind === "Model" || !body.optional,
@@ -1145,8 +1147,7 @@ export class CodeModelBuilder {
1145
1147
  // find a type that possibly without http metadata like @statusCode
1146
1148
  return this.getEffectiveSchemaType(bodyType);
1147
1149
  }
1148
- processResponse(op, resp, candidateResponseSchema = undefined) {
1149
- var _a, _b, _c, _d, _e, _f;
1150
+ processResponse(op, resp, longRunning) {
1150
1151
  // TODO: what to do if more than 1 response?
1151
1152
  // It happens when the response type is Union, on one status code.
1152
1153
  let response;
@@ -1173,7 +1174,7 @@ export class CodeModelBuilder {
1173
1174
  }
1174
1175
  let responseBody = undefined;
1175
1176
  let bodyType = undefined;
1176
- let trackConvenienceApi = (_a = op.convenienceApi) !== null && _a !== void 0 ? _a : false;
1177
+ let trackConvenienceApi = Boolean(op.convenienceApi);
1177
1178
  if (resp.responses && resp.responses.length > 0 && resp.responses[0].body) {
1178
1179
  responseBody = resp.responses[0].body;
1179
1180
  }
@@ -1202,49 +1203,13 @@ export class CodeModelBuilder {
1202
1203
  else {
1203
1204
  // schema (usually JSON)
1204
1205
  let schema = undefined;
1205
- const verb = (_d = (_c = (_b = op.requests) === null || _b === void 0 ? void 0 : _b[0].protocol) === null || _c === void 0 ? void 0 : _c.http) === null || _d === void 0 ? void 0 : _d.method;
1206
- if (
1207
- // LRO, candidateResponseSchema is Model/ObjectSchema
1208
- candidateResponseSchema &&
1209
- candidateResponseSchema instanceof ObjectSchema &&
1210
- // bodyType is templated Model
1211
- bodyType.kind === "Model" &&
1212
- bodyType.templateMapper &&
1213
- bodyType.templateMapper.args &&
1214
- bodyType.templateMapper.args.length > 0) {
1215
- if (verb === "post") {
1216
- // for LRO ResourceAction, the standard does not require a final type, hence it can be the same as intermediate type
1217
- // https://github.com/microsoft/api-guidelines/blob/vNext/azure/ConsiderationsForServiceDesign.md#long-running-action-operations
1218
- // check if we can use candidateResponseSchema as response schema (instead of the templated Model), for LRO ResourceAction
1219
- if (((_e = candidateResponseSchema.properties) === null || _e === void 0 ? void 0 : _e.length) === bodyType.properties.size) {
1220
- let match = true;
1221
- for (const prop of Array.from(bodyType.properties.values())) {
1222
- const name = this.getName(prop);
1223
- if (!((_f = candidateResponseSchema.properties) === null || _f === void 0 ? void 0 : _f.find((it) => it.language.default.name === name))) {
1224
- match = false;
1225
- break;
1226
- }
1227
- }
1228
- if (match) {
1229
- schema = candidateResponseSchema;
1230
- this.trace(`Replace TypeSpec model '${this.getName(bodyType)}' with '${candidateResponseSchema.language.default.name}'`);
1231
- }
1232
- }
1233
- }
1234
- else if (verb === "delete") {
1235
- // for LRO ResourceDelete, final type will be replaced to "Void" in convenience API, hence do not generate the class
1236
- trackConvenienceApi = false;
1237
- }
1206
+ if (longRunning) {
1207
+ // LRO uses the LroMetadata for poll/final result, not the response of activation request
1208
+ trackConvenienceApi = false;
1238
1209
  }
1239
1210
  if (!schema) {
1240
- if (verb === "post" && op.lroMetadata && op.lroMetadata.pollResultType) {
1241
- // for standard LRO action, return type is the pollResultType
1242
- schema = op.lroMetadata.pollResultType;
1243
- }
1244
- else {
1245
- const sdkType = getClientType(this.sdkContext, bodyType);
1246
- schema = this.processSchemaFromSdkType(sdkType, op.language.default.name + "Response");
1247
- }
1211
+ const sdkType = getClientType(this.sdkContext, bodyType);
1212
+ schema = this.processSchemaFromSdkType(sdkType, op.language.default.name + "Response");
1248
1213
  }
1249
1214
  response = new SchemaResponse(schema, {
1250
1215
  protocol: {
@@ -1463,14 +1428,14 @@ export class CodeModelBuilder {
1463
1428
  return this.codeModel.schemas.add(dictSchema);
1464
1429
  }
1465
1430
  processChoiceSchemaFromSdkType(type, name) {
1466
- var _a;
1431
+ var _a, _b;
1467
1432
  const rawEnumType = type.__raw;
1468
1433
  const namespace = getNamespace(rawEnumType);
1469
1434
  const valueType = this.processSchemaFromSdkType(type.valueType, type.valueType.kind);
1470
1435
  const choices = [];
1471
1436
  type.values.forEach((it) => { var _a, _b; return choices.push(new ChoiceValue(it.name, (_a = it.description) !== null && _a !== void 0 ? _a : "", (_b = it.value) !== null && _b !== void 0 ? _b : it.name)); });
1472
1437
  const schemaType = type.isFixed ? SealedChoiceSchema : ChoiceSchema;
1473
- const schema = new schemaType(type.name ? type.name : name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1438
+ const schema = new schemaType((_a = type.name) !== null && _a !== void 0 ? _a : name, (_b = type.details) !== null && _b !== void 0 ? _b : "", {
1474
1439
  summary: type.description,
1475
1440
  choiceType: valueType,
1476
1441
  choices: choices,
@@ -1487,21 +1452,21 @@ export class CodeModelBuilder {
1487
1452
  return this.codeModel.schemas.add(schema);
1488
1453
  }
1489
1454
  processConstantSchemaFromSdkType(type, name) {
1490
- var _a;
1455
+ var _a, _b;
1491
1456
  const valueType = this.processSchemaFromSdkType(type.valueType, type.valueType.kind);
1492
- return this.codeModel.schemas.add(new ConstantSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1457
+ return this.codeModel.schemas.add(new ConstantSchema((_a = type.name) !== null && _a !== void 0 ? _a : name, (_b = type.details) !== null && _b !== void 0 ? _b : "", {
1493
1458
  summary: type.description,
1494
1459
  valueType: valueType,
1495
1460
  value: new ConstantValue(type.value),
1496
1461
  }));
1497
1462
  }
1498
1463
  processConstantSchemaFromEnumValueFromSdkType(type, name) {
1499
- var _a, _b;
1464
+ var _a, _b, _c;
1500
1465
  const valueType = this.processSchemaFromSdkType(type.enumType, type.enumType.name);
1501
- return this.codeModel.schemas.add(new ConstantSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1466
+ return this.codeModel.schemas.add(new ConstantSchema((_a = type.name) !== null && _a !== void 0 ? _a : name, (_b = type.details) !== null && _b !== void 0 ? _b : "", {
1502
1467
  summary: type.description,
1503
1468
  valueType: valueType,
1504
- value: new ConstantValue((_b = type.value) !== null && _b !== void 0 ? _b : type.name),
1469
+ value: new ConstantValue((_c = type.value) !== null && _c !== void 0 ? _c : type.name),
1505
1470
  }));
1506
1471
  }
1507
1472
  processUnixTimeSchemaFromSdkType(type, name) {
@@ -1640,10 +1605,7 @@ export class CodeModelBuilder {
1640
1605
  }
1641
1606
  processModelPropertyFromSdkType(prop) {
1642
1607
  var _a;
1643
- const rawModelPropertyType = prop.__raw;
1644
- // TODO: This case is related with literal.tsp, once TCGC supports giving a name, we can use TCGC generatedName
1645
- const schemaNameHint = pascalCase(getNamePrefixForProperty(rawModelPropertyType)) + pascalCase(prop.name);
1646
- let schema = this.processSchemaFromSdkType(prop.type, schemaNameHint);
1608
+ let schema = this.processSchemaFromSdkType(prop.type, "");
1647
1609
  let nullable = prop.nullable;
1648
1610
  let extensions = undefined;
1649
1611
  if (this.isSecret(prop)) {
@@ -1679,7 +1641,6 @@ export class CodeModelBuilder {
1679
1641
  throw new Error(`Invalid type for union: '${type.kind}'.`);
1680
1642
  }
1681
1643
  const rawUnionType = type.__raw;
1682
- // TODO: name from typespec-client-generator-core
1683
1644
  const namespace = getNamespace(rawUnionType);
1684
1645
  const baseName = (_a = type.name) !== null && _a !== void 0 ? _a : pascalCase(name) + "Model";
1685
1646
  this.logWarning(`Convert TypeSpec Union '${getUnionDescription(rawUnionType, this.typeNameOptions)}' to Class '${baseName}'`);
@@ -1795,9 +1756,6 @@ export class CodeModelBuilder {
1795
1756
  return target ? getSummary(this.program, target) : undefined;
1796
1757
  }
1797
1758
  getName(target, nameHint = undefined) {
1798
- if (!target) {
1799
- return nameHint || "";
1800
- }
1801
1759
  // TODO: once getLibraryName API in typespec-client-generator-core can get projected name from language and client, as well as can handle template case, use getLibraryName API
1802
1760
  const emitterClientName = getClientNameOverride(this.sdkContext, target);
1803
1761
  if (emitterClientName && typeof emitterClientName === "string") {
@@ -1816,21 +1774,6 @@ export class CodeModelBuilder {
1816
1774
  if (friendlyName) {
1817
1775
  return friendlyName;
1818
1776
  }
1819
- // if no projectedName and friendlyName found, return the name of the target (including special handling for template)
1820
- if (target.kind === "Model" &&
1821
- target.templateMapper &&
1822
- target.templateMapper.args &&
1823
- target.templateMapper.args.length > 0) {
1824
- const tspName = getTypeName(target, this.typeNameOptions);
1825
- const newName = getNameForTemplate(target);
1826
- this.logWarning(`Rename TypeSpec Model '${tspName}' to '${newName}'`);
1827
- return newName;
1828
- }
1829
- if (!target.name && nameHint) {
1830
- const newName = nameHint;
1831
- this.logWarning(`Rename anonymous TypeSpec ${target.kind} to '${newName}'`);
1832
- return newName;
1833
- }
1834
1777
  if (typeof target.name === "symbol") {
1835
1778
  return "";
1836
1779
  }