@azure-tools/typespec-java 0.16.1 → 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,39 +635,35 @@ 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) {
641
642
  let pollingSchema = undefined;
642
643
  let finalSchema = undefined;
644
+ let pollingStrategy = undefined;
645
+ let finalResultPropertySerializedName = undefined;
643
646
  const verb = httpOperation.verb;
644
647
  const useNewPollStrategy = isLroNewPollingStrategy(httpOperation, lroMetadata);
645
- let pollingStrategy = undefined;
646
648
  if (useNewPollStrategy) {
647
- // use new experimental OperationLocationPollingStrategy
649
+ // use OperationLocationPollingStrategy
648
650
  pollingStrategy = new Metadata({
649
651
  language: {
650
652
  java: {
651
653
  name: "OperationLocationPollingStrategy",
652
- namespace: "com.azure.core.experimental.util.polling",
654
+ namespace: getJavaNamespace(this.namespace) + ".implementation",
653
655
  },
654
656
  },
655
657
  });
656
658
  }
657
659
  // pollingSchema
658
- if (useNewPollStrategy) {
659
- // com.azure.core.experimental.models.PollResult
660
+ if (modelIs(lroMetadata.pollingInfo.responseModel, "OperationStatus", "Azure.Core.Foundations")) {
660
661
  pollingSchema = this.pollResultSchema;
661
662
  }
662
663
  else {
663
- if (modelIs(lroMetadata.pollingInfo.responseModel, "OperationStatus", "Azure.Core.Foundations")) {
664
- pollingSchema = this.pollResultSchema;
665
- }
666
- else {
667
- const pollType = this.findResponseBody(lroMetadata.pollingInfo.responseModel);
668
- const sdkType = getClientType(this.sdkContext, pollType);
669
- pollingSchema = this.processSchemaFromSdkType(sdkType, "pollResult");
670
- }
664
+ const pollType = this.findResponseBody(lroMetadata.pollingInfo.responseModel);
665
+ const sdkType = getClientType(this.sdkContext, pollType);
666
+ pollingSchema = this.processSchemaFromSdkType(sdkType, "pollResult");
671
667
  }
672
668
  // finalSchema
673
669
  if (verb !== "delete" &&
@@ -679,11 +675,18 @@ export class CodeModelBuilder {
679
675
  const finalType = this.findResponseBody(finalResult);
680
676
  const sdkType = getClientType(this.sdkContext, finalType);
681
677
  finalSchema = this.processSchemaFromSdkType(sdkType, "finalResult");
678
+ if (useNewPollStrategy &&
679
+ lroMetadata.finalStep &&
680
+ lroMetadata.finalStep.kind === "pollingSuccessProperty" &&
681
+ lroMetadata.finalStep.target) {
682
+ // final result is the value in lroMetadata.finalStep.target
683
+ finalResultPropertySerializedName = this.getSerializedName(lroMetadata.finalStep.target);
684
+ }
682
685
  }
683
686
  // track usage
684
687
  if (pollingSchema) {
685
688
  this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Output] });
686
- if (op.convenienceApi) {
689
+ if (trackConvenienceApi) {
687
690
  this.trackSchemaUsage(pollingSchema, {
688
691
  usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public],
689
692
  });
@@ -691,13 +694,13 @@ export class CodeModelBuilder {
691
694
  }
692
695
  if (finalSchema) {
693
696
  this.trackSchemaUsage(finalSchema, { usage: [SchemaContext.Output] });
694
- if (op.convenienceApi) {
697
+ if (trackConvenienceApi) {
695
698
  this.trackSchemaUsage(finalSchema, {
696
699
  usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public],
697
700
  });
698
701
  }
699
702
  }
700
- op.lroMetadata = new LongRunningMetadata(true, pollingSchema, finalSchema, pollingStrategy);
703
+ op.lroMetadata = new LongRunningMetadata(true, pollingSchema, finalSchema, pollingStrategy, finalResultPropertySerializedName);
701
704
  return op.lroMetadata;
702
705
  }
703
706
  return new LongRunningMetadata(false);
@@ -1021,7 +1024,8 @@ export class CodeModelBuilder {
1021
1024
  schema = this.processSchemaFromSdkType(sdkType, body.name);
1022
1025
  }
1023
1026
  const isAnonymousModel = sdkType.kind === "model" && sdkType.isGeneratedName === true;
1024
- 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, {
1025
1029
  summary: this.getSummary(body),
1026
1030
  implementation: ImplementationLocation.Method,
1027
1031
  required: body.kind === "Model" || !body.optional,
@@ -1143,8 +1147,7 @@ export class CodeModelBuilder {
1143
1147
  // find a type that possibly without http metadata like @statusCode
1144
1148
  return this.getEffectiveSchemaType(bodyType);
1145
1149
  }
1146
- processResponse(op, resp, candidateResponseSchema = undefined) {
1147
- var _a, _b, _c, _d, _e, _f;
1150
+ processResponse(op, resp, longRunning) {
1148
1151
  // TODO: what to do if more than 1 response?
1149
1152
  // It happens when the response type is Union, on one status code.
1150
1153
  let response;
@@ -1171,7 +1174,7 @@ export class CodeModelBuilder {
1171
1174
  }
1172
1175
  let responseBody = undefined;
1173
1176
  let bodyType = undefined;
1174
- let trackConvenienceApi = (_a = op.convenienceApi) !== null && _a !== void 0 ? _a : false;
1177
+ let trackConvenienceApi = Boolean(op.convenienceApi);
1175
1178
  if (resp.responses && resp.responses.length > 0 && resp.responses[0].body) {
1176
1179
  responseBody = resp.responses[0].body;
1177
1180
  }
@@ -1200,49 +1203,13 @@ export class CodeModelBuilder {
1200
1203
  else {
1201
1204
  // schema (usually JSON)
1202
1205
  let schema = undefined;
1203
- 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;
1204
- if (
1205
- // LRO, candidateResponseSchema is Model/ObjectSchema
1206
- candidateResponseSchema &&
1207
- candidateResponseSchema instanceof ObjectSchema &&
1208
- // bodyType is templated Model
1209
- bodyType.kind === "Model" &&
1210
- bodyType.templateMapper &&
1211
- bodyType.templateMapper.args &&
1212
- bodyType.templateMapper.args.length > 0) {
1213
- if (verb === "post") {
1214
- // for LRO ResourceAction, the standard does not require a final type, hence it can be the same as intermediate type
1215
- // https://github.com/microsoft/api-guidelines/blob/vNext/azure/ConsiderationsForServiceDesign.md#long-running-action-operations
1216
- // check if we can use candidateResponseSchema as response schema (instead of the templated Model), for LRO ResourceAction
1217
- if (((_e = candidateResponseSchema.properties) === null || _e === void 0 ? void 0 : _e.length) === bodyType.properties.size) {
1218
- let match = true;
1219
- for (const prop of Array.from(bodyType.properties.values())) {
1220
- const name = this.getName(prop);
1221
- if (!((_f = candidateResponseSchema.properties) === null || _f === void 0 ? void 0 : _f.find((it) => it.language.default.name === name))) {
1222
- match = false;
1223
- break;
1224
- }
1225
- }
1226
- if (match) {
1227
- schema = candidateResponseSchema;
1228
- this.trace(`Replace TypeSpec model '${this.getName(bodyType)}' with '${candidateResponseSchema.language.default.name}'`);
1229
- }
1230
- }
1231
- }
1232
- else if (verb === "delete") {
1233
- // for LRO ResourceDelete, final type will be replaced to "Void" in convenience API, hence do not generate the class
1234
- trackConvenienceApi = false;
1235
- }
1206
+ if (longRunning) {
1207
+ // LRO uses the LroMetadata for poll/final result, not the response of activation request
1208
+ trackConvenienceApi = false;
1236
1209
  }
1237
1210
  if (!schema) {
1238
- if (verb === "post" && op.lroMetadata && op.lroMetadata.pollResultType) {
1239
- // for standard LRO action, return type is the pollResultType
1240
- schema = op.lroMetadata.pollResultType;
1241
- }
1242
- else {
1243
- const sdkType = getClientType(this.sdkContext, bodyType);
1244
- schema = this.processSchemaFromSdkType(sdkType, op.language.default.name + "Response");
1245
- }
1211
+ const sdkType = getClientType(this.sdkContext, bodyType);
1212
+ schema = this.processSchemaFromSdkType(sdkType, op.language.default.name + "Response");
1246
1213
  }
1247
1214
  response = new SchemaResponse(schema, {
1248
1215
  protocol: {
@@ -1461,14 +1428,14 @@ export class CodeModelBuilder {
1461
1428
  return this.codeModel.schemas.add(dictSchema);
1462
1429
  }
1463
1430
  processChoiceSchemaFromSdkType(type, name) {
1464
- var _a;
1431
+ var _a, _b;
1465
1432
  const rawEnumType = type.__raw;
1466
1433
  const namespace = getNamespace(rawEnumType);
1467
1434
  const valueType = this.processSchemaFromSdkType(type.valueType, type.valueType.kind);
1468
1435
  const choices = [];
1469
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)); });
1470
1437
  const schemaType = type.isFixed ? SealedChoiceSchema : ChoiceSchema;
1471
- 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 : "", {
1472
1439
  summary: type.description,
1473
1440
  choiceType: valueType,
1474
1441
  choices: choices,
@@ -1485,21 +1452,21 @@ export class CodeModelBuilder {
1485
1452
  return this.codeModel.schemas.add(schema);
1486
1453
  }
1487
1454
  processConstantSchemaFromSdkType(type, name) {
1488
- var _a;
1455
+ var _a, _b;
1489
1456
  const valueType = this.processSchemaFromSdkType(type.valueType, type.valueType.kind);
1490
- 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 : "", {
1491
1458
  summary: type.description,
1492
1459
  valueType: valueType,
1493
1460
  value: new ConstantValue(type.value),
1494
1461
  }));
1495
1462
  }
1496
1463
  processConstantSchemaFromEnumValueFromSdkType(type, name) {
1497
- var _a, _b;
1464
+ var _a, _b, _c;
1498
1465
  const valueType = this.processSchemaFromSdkType(type.enumType, type.enumType.name);
1499
- 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 : "", {
1500
1467
  summary: type.description,
1501
1468
  valueType: valueType,
1502
- 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),
1503
1470
  }));
1504
1471
  }
1505
1472
  processUnixTimeSchemaFromSdkType(type, name) {
@@ -1638,10 +1605,7 @@ export class CodeModelBuilder {
1638
1605
  }
1639
1606
  processModelPropertyFromSdkType(prop) {
1640
1607
  var _a;
1641
- const rawModelPropertyType = prop.__raw;
1642
- // TODO: This case is related with literal.tsp, once TCGC supports giving a name, we can use TCGC generatedName
1643
- const schemaNameHint = pascalCase(getNamePrefixForProperty(rawModelPropertyType)) + pascalCase(prop.name);
1644
- let schema = this.processSchemaFromSdkType(prop.type, schemaNameHint);
1608
+ let schema = this.processSchemaFromSdkType(prop.type, "");
1645
1609
  let nullable = prop.nullable;
1646
1610
  let extensions = undefined;
1647
1611
  if (this.isSecret(prop)) {
@@ -1677,7 +1641,6 @@ export class CodeModelBuilder {
1677
1641
  throw new Error(`Invalid type for union: '${type.kind}'.`);
1678
1642
  }
1679
1643
  const rawUnionType = type.__raw;
1680
- // TODO: name from typespec-client-generator-core
1681
1644
  const namespace = getNamespace(rawUnionType);
1682
1645
  const baseName = (_a = type.name) !== null && _a !== void 0 ? _a : pascalCase(name) + "Model";
1683
1646
  this.logWarning(`Convert TypeSpec Union '${getUnionDescription(rawUnionType, this.typeNameOptions)}' to Class '${baseName}'`);
@@ -1793,9 +1756,6 @@ export class CodeModelBuilder {
1793
1756
  return target ? getSummary(this.program, target) : undefined;
1794
1757
  }
1795
1758
  getName(target, nameHint = undefined) {
1796
- if (!target) {
1797
- return nameHint || "";
1798
- }
1799
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
1800
1760
  const emitterClientName = getClientNameOverride(this.sdkContext, target);
1801
1761
  if (emitterClientName && typeof emitterClientName === "string") {
@@ -1814,21 +1774,6 @@ export class CodeModelBuilder {
1814
1774
  if (friendlyName) {
1815
1775
  return friendlyName;
1816
1776
  }
1817
- // if no projectedName and friendlyName found, return the name of the target (including special handling for template)
1818
- if (target.kind === "Model" &&
1819
- target.templateMapper &&
1820
- target.templateMapper.args &&
1821
- target.templateMapper.args.length > 0) {
1822
- const tspName = getTypeName(target, this.typeNameOptions);
1823
- const newName = getNameForTemplate(target);
1824
- this.logWarning(`Rename TypeSpec Model '${tspName}' to '${newName}'`);
1825
- return newName;
1826
- }
1827
- if (!target.name && nameHint) {
1828
- const newName = nameHint;
1829
- this.logWarning(`Rename anonymous TypeSpec ${target.kind} to '${newName}'`);
1830
- return newName;
1831
- }
1832
1777
  if (typeof target.name === "symbol") {
1833
1778
  return "";
1834
1779
  }