@azure-tools/typespec-java 0.16.0 → 0.16.2

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.
@@ -98,6 +98,7 @@ export declare class CodeModelBuilder {
98
98
  private getSerializedName;
99
99
  private isReadOnly;
100
100
  private isSecret;
101
+ private getMutability;
101
102
  private getConvenienceApiName;
102
103
  private logWarning;
103
104
  private trace;
@@ -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,WAAW,mCAElB;IACF,QAAQ,CAAC,iBAAiB,sCAA6C;IAEvE,OAAO,CAAC,iBAAiB,CAAkD;IAE3E,OAAO,CAAC,UAAU,CAAsB;gBAErB,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,cAAc,CAAC;IA4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,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"}
@@ -640,34 +640,29 @@ export class CodeModelBuilder {
640
640
  if (lroMetadata && lroMetadata.pollingInfo && lroMetadata.statusMonitorStep) {
641
641
  let pollingSchema = undefined;
642
642
  let finalSchema = undefined;
643
+ let pollingStrategy = undefined;
644
+ let finalResultPropertySerializedName = undefined;
643
645
  const verb = httpOperation.verb;
644
646
  const useNewPollStrategy = isLroNewPollingStrategy(httpOperation, lroMetadata);
645
- let pollingStrategy = undefined;
646
647
  if (useNewPollStrategy) {
647
- // use new experimental OperationLocationPollingStrategy
648
+ // use OperationLocationPollingStrategy
648
649
  pollingStrategy = new Metadata({
649
650
  language: {
650
651
  java: {
651
652
  name: "OperationLocationPollingStrategy",
652
- namespace: "com.azure.core.experimental.util.polling",
653
+ namespace: getJavaNamespace(this.namespace) + ".implementation",
653
654
  },
654
655
  },
655
656
  });
656
657
  }
657
658
  // pollingSchema
658
- if (useNewPollStrategy) {
659
- // com.azure.core.experimental.models.PollResult
659
+ if (modelIs(lroMetadata.pollingInfo.responseModel, "OperationStatus", "Azure.Core.Foundations")) {
660
660
  pollingSchema = this.pollResultSchema;
661
661
  }
662
662
  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
- }
663
+ const pollType = this.findResponseBody(lroMetadata.pollingInfo.responseModel);
664
+ const sdkType = getClientType(this.sdkContext, pollType);
665
+ pollingSchema = this.processSchemaFromSdkType(sdkType, "pollResult");
671
666
  }
672
667
  // finalSchema
673
668
  if (verb !== "delete" &&
@@ -679,6 +674,13 @@ export class CodeModelBuilder {
679
674
  const finalType = this.findResponseBody(finalResult);
680
675
  const sdkType = getClientType(this.sdkContext, finalType);
681
676
  finalSchema = this.processSchemaFromSdkType(sdkType, "finalResult");
677
+ if (useNewPollStrategy &&
678
+ lroMetadata.finalStep &&
679
+ lroMetadata.finalStep.kind === "pollingSuccessProperty" &&
680
+ lroMetadata.finalStep.target) {
681
+ // final result is the value in lroMetadata.finalStep.target
682
+ finalResultPropertySerializedName = this.getSerializedName(lroMetadata.finalStep.target);
683
+ }
682
684
  }
683
685
  // track usage
684
686
  if (pollingSchema) {
@@ -697,7 +699,7 @@ export class CodeModelBuilder {
697
699
  });
698
700
  }
699
701
  }
700
- op.lroMetadata = new LongRunningMetadata(true, pollingSchema, finalSchema, pollingStrategy);
702
+ op.lroMetadata = new LongRunningMetadata(true, pollingSchema, finalSchema, pollingStrategy, finalResultPropertySerializedName);
701
703
  return op.lroMetadata;
702
704
  }
703
705
  return new LongRunningMetadata(false);
@@ -1401,46 +1403,54 @@ export class CodeModelBuilder {
1401
1403
  return this.anySchema;
1402
1404
  }
1403
1405
  processStringSchemaFromSdkType(type, name) {
1404
- return this.codeModel.schemas.add(new StringSchema(name, this.getDoc(type.__raw), {
1405
- summary: this.getSummary(type.__raw),
1406
+ var _a;
1407
+ return this.codeModel.schemas.add(new StringSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1408
+ summary: type.description,
1406
1409
  }));
1407
1410
  }
1408
1411
  processByteArraySchemaFromSdkType(type, name) {
1412
+ var _a;
1409
1413
  const base64Encoded = type.encode === "base64url";
1410
- return this.codeModel.schemas.add(new ByteArraySchema(name, this.getDoc(type.__raw), {
1411
- summary: this.getSummary(type.__raw),
1414
+ return this.codeModel.schemas.add(new ByteArraySchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1415
+ summary: type.description,
1412
1416
  format: base64Encoded ? "base64url" : "byte",
1413
1417
  }));
1414
1418
  }
1415
1419
  processIntegerSchemaFromSdkType(type, name, precision) {
1416
- return this.codeModel.schemas.add(new NumberSchema(name, this.getDoc(type.__raw), SchemaType.Integer, precision, {
1417
- summary: this.getSummary(type.__raw),
1420
+ var _a;
1421
+ return this.codeModel.schemas.add(new NumberSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", SchemaType.Integer, precision, {
1422
+ summary: type.description,
1418
1423
  }));
1419
1424
  }
1420
1425
  processNumberSchemaFromSdkType(type, name) {
1421
- return this.codeModel.schemas.add(new NumberSchema(name, this.getDoc(type.__raw), SchemaType.Number, 64, {
1422
- summary: this.getSummary(type.__raw),
1426
+ var _a;
1427
+ return this.codeModel.schemas.add(new NumberSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", SchemaType.Number, 64, {
1428
+ summary: type.description,
1423
1429
  }));
1424
1430
  }
1425
1431
  processDecimalSchemaFromSdkType(type, name) {
1432
+ var _a;
1426
1433
  // "Infinity" maps to "BigDecimal" in Java
1427
- return this.codeModel.schemas.add(new NumberSchema(name, this.getDoc(type.__raw), SchemaType.Number, Infinity, {
1428
- summary: this.getSummary(type.__raw),
1434
+ return this.codeModel.schemas.add(new NumberSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", SchemaType.Number, Infinity, {
1435
+ summary: type.description,
1429
1436
  }));
1430
1437
  }
1431
1438
  processBooleanSchemaFromSdkType(type, name) {
1432
- return this.codeModel.schemas.add(new BooleanSchema(name, this.getDoc(type.__raw), {
1433
- summary: this.getSummary(type.__raw),
1439
+ var _a;
1440
+ return this.codeModel.schemas.add(new BooleanSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1441
+ summary: type.description,
1434
1442
  }));
1435
1443
  }
1436
1444
  processArraySchemaFromSdkType(type, name) {
1445
+ var _a;
1437
1446
  const elementSchema = this.processSchemaFromSdkType(type.valueType, name);
1438
- return this.codeModel.schemas.add(new ArraySchema(name, this.getDoc(type.__raw), elementSchema, {
1439
- summary: this.getSummary(type.__raw),
1447
+ return this.codeModel.schemas.add(new ArraySchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", elementSchema, {
1448
+ summary: type.description,
1440
1449
  }));
1441
1450
  }
1442
1451
  processDictionarySchemaFromSdkType(type, name) {
1443
- const dictSchema = new DictionarySchema(name, type.details ? type.details : "", null, {
1452
+ var _a;
1453
+ const dictSchema = new DictionarySchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", null, {
1444
1454
  summary: type.description,
1445
1455
  });
1446
1456
  // cache this now before we accidentally recurse on this type.
@@ -1460,8 +1470,8 @@ export class CodeModelBuilder {
1460
1470
  const choices = [];
1461
1471
  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)); });
1462
1472
  const schemaType = type.isFixed ? SealedChoiceSchema : ChoiceSchema;
1463
- const schema = new schemaType(type.name ? type.name : name, (_a = type.description) !== null && _a !== void 0 ? _a : "", {
1464
- summary: this.getSummary(rawEnumType),
1473
+ const schema = new schemaType(type.name ? type.name : name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1474
+ summary: type.description,
1465
1475
  choiceType: valueType,
1466
1476
  choices: choices,
1467
1477
  language: {
@@ -1477,60 +1487,67 @@ export class CodeModelBuilder {
1477
1487
  return this.codeModel.schemas.add(schema);
1478
1488
  }
1479
1489
  processConstantSchemaFromSdkType(type, name) {
1490
+ var _a;
1480
1491
  const valueType = this.processSchemaFromSdkType(type.valueType, type.valueType.kind);
1481
- return this.codeModel.schemas.add(new ConstantSchema(name, this.getDoc(type.__raw), {
1482
- summary: this.getSummary(type.__raw),
1492
+ return this.codeModel.schemas.add(new ConstantSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1493
+ summary: type.description,
1483
1494
  valueType: valueType,
1484
1495
  value: new ConstantValue(type.value),
1485
1496
  }));
1486
1497
  }
1487
1498
  processConstantSchemaFromEnumValueFromSdkType(type, name) {
1488
- var _a;
1499
+ var _a, _b;
1489
1500
  const valueType = this.processSchemaFromSdkType(type.enumType, type.enumType.name);
1490
- return this.codeModel.schemas.add(new ConstantSchema(name, this.getDoc(type.__raw), {
1491
- summary: this.getSummary(type.__raw),
1501
+ return this.codeModel.schemas.add(new ConstantSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1502
+ summary: type.description,
1492
1503
  valueType: valueType,
1493
- value: new ConstantValue((_a = type.value) !== null && _a !== void 0 ? _a : type.name),
1504
+ value: new ConstantValue((_b = type.value) !== null && _b !== void 0 ? _b : type.name),
1494
1505
  }));
1495
1506
  }
1496
1507
  processUnixTimeSchemaFromSdkType(type, name) {
1497
- return this.codeModel.schemas.add(new UnixTimeSchema(name, this.getDoc(type.__raw), {
1498
- summary: this.getSummary(type.__raw),
1508
+ var _a;
1509
+ return this.codeModel.schemas.add(new UnixTimeSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1510
+ summary: type.description,
1499
1511
  }));
1500
1512
  }
1501
1513
  processDateTimeSchemaFromSdkType(type, name, rfc1123) {
1502
- return this.codeModel.schemas.add(new DateTimeSchema(name, this.getDoc(type.__raw), {
1503
- summary: this.getSummary(type.__raw),
1514
+ var _a;
1515
+ return this.codeModel.schemas.add(new DateTimeSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1516
+ summary: type.description,
1504
1517
  format: rfc1123 ? "date-time-rfc1123" : "date-time",
1505
1518
  }));
1506
1519
  }
1507
1520
  processDateSchemaFromSdkType(type, name) {
1508
- return this.codeModel.schemas.add(new DateSchema(name, this.getDoc(type.__raw), {
1509
- summary: this.getSummary(type.__raw),
1521
+ var _a;
1522
+ return this.codeModel.schemas.add(new DateSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1523
+ summary: type.description,
1510
1524
  }));
1511
1525
  }
1512
1526
  processTimeSchemaFromSdkType(type, name) {
1513
- return this.codeModel.schemas.add(new TimeSchema(name, this.getDoc(type.__raw), {
1514
- summary: this.getSummary(type.__raw),
1527
+ var _a;
1528
+ return this.codeModel.schemas.add(new TimeSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1529
+ summary: type.description,
1515
1530
  }));
1516
1531
  }
1517
1532
  processDurationSchemaFromSdkType(type, name, format = "duration-rfc3339") {
1518
- return this.codeModel.schemas.add(new DurationSchema(name, this.getDoc(type.__raw), {
1519
- summary: this.getSummary(type.__raw),
1533
+ var _a;
1534
+ return this.codeModel.schemas.add(new DurationSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1535
+ summary: type.description,
1520
1536
  format: format,
1521
1537
  }));
1522
1538
  }
1523
1539
  processUrlSchemaFromSdkType(type, name) {
1524
- return this.codeModel.schemas.add(new UriSchema(name, this.getDoc(type.__raw), {
1525
- summary: this.getSummary(type.__raw),
1540
+ var _a;
1541
+ return this.codeModel.schemas.add(new UriSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1542
+ summary: type.description,
1526
1543
  }));
1527
1544
  }
1528
1545
  processObjectSchemaFromSdkType(type, name) {
1529
- var _a;
1546
+ var _a, _b;
1530
1547
  const rawModelType = type.__raw;
1531
1548
  const namespace = getNamespace(rawModelType);
1532
- const objectSchema = new ObjectScheme(name, this.getDoc(rawModelType), {
1533
- summary: this.getSummary(rawModelType),
1549
+ const objectSchema = new ObjectScheme(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1550
+ summary: type.description,
1534
1551
  language: {
1535
1552
  default: {
1536
1553
  namespace: namespace,
@@ -1590,7 +1607,7 @@ export class CodeModelBuilder {
1590
1607
  valueType: type.additionalProperties,
1591
1608
  };
1592
1609
  const parentSchema = this.processSchemaFromSdkType(sdkDictType, "Record");
1593
- objectSchema.parents = (_a = objectSchema.parents) !== null && _a !== void 0 ? _a : new Relations();
1610
+ objectSchema.parents = (_b = objectSchema.parents) !== null && _b !== void 0 ? _b : new Relations();
1594
1611
  objectSchema.parents.immediate.push(parentSchema);
1595
1612
  pushDistinct(objectSchema.parents.all, parentSchema);
1596
1613
  objectSchema.discriminatorValue = type.discriminatorValue;
@@ -1622,6 +1639,7 @@ export class CodeModelBuilder {
1622
1639
  return type;
1623
1640
  }
1624
1641
  processModelPropertyFromSdkType(prop) {
1642
+ var _a;
1625
1643
  const rawModelPropertyType = prop.__raw;
1626
1644
  // TODO: This case is related with literal.tsp, once TCGC supports giving a name, we can use TCGC generatedName
1627
1645
  const schemaNameHint = pascalCase(getNamePrefixForProperty(rawModelPropertyType)) + pascalCase(prop.name);
@@ -1638,11 +1656,16 @@ export class CodeModelBuilder {
1638
1656
  extensions = extensions !== null && extensions !== void 0 ? extensions : {};
1639
1657
  extensions["x-ms-client-flatten"] = true;
1640
1658
  }
1659
+ const mutability = this.getMutability(prop);
1660
+ if (mutability) {
1661
+ extensions = extensions !== null && extensions !== void 0 ? extensions : {};
1662
+ extensions["x-ms-mutability"] = mutability;
1663
+ }
1641
1664
  if (prop.kind === "property" && prop.isMultipartFileInput) {
1642
1665
  schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop, this.namespace);
1643
1666
  }
1644
- return new Property(prop.name, this.getDoc(rawModelPropertyType), schema, {
1645
- summary: this.getSummary(rawModelPropertyType),
1667
+ return new Property(prop.name, (_a = prop.details) !== null && _a !== void 0 ? _a : "", schema, {
1668
+ summary: prop.description,
1646
1669
  required: !prop.optional,
1647
1670
  nullable: nullable,
1648
1671
  readOnly: this.isReadOnly(prop),
@@ -1651,7 +1674,7 @@ export class CodeModelBuilder {
1651
1674
  });
1652
1675
  }
1653
1676
  processUnionSchemaFromSdkType(type, name) {
1654
- var _a;
1677
+ var _a, _b;
1655
1678
  if (!(type.__raw && type.__raw.kind === "Union")) {
1656
1679
  throw new Error(`Invalid type for union: '${type.kind}'.`);
1657
1680
  }
@@ -1660,17 +1683,18 @@ export class CodeModelBuilder {
1660
1683
  const namespace = getNamespace(rawUnionType);
1661
1684
  const baseName = (_a = type.name) !== null && _a !== void 0 ? _a : pascalCase(name) + "Model";
1662
1685
  this.logWarning(`Convert TypeSpec Union '${getUnionDescription(rawUnionType, this.typeNameOptions)}' to Class '${baseName}'`);
1663
- const unionSchema = new OrSchema(baseName + "Base", this.getDoc(rawUnionType), {
1664
- summary: this.getSummary(rawUnionType),
1686
+ const unionSchema = new OrSchema(baseName + "Base", (_b = type.details) !== null && _b !== void 0 ? _b : "", {
1687
+ summary: type.description,
1665
1688
  });
1666
1689
  unionSchema.anyOf = [];
1667
1690
  type.values.forEach((it) => {
1691
+ var _a, _b;
1668
1692
  const variantName = this.getUnionVariantName(it.__raw, { depth: 0 });
1669
1693
  const modelName = variantName + baseName;
1670
1694
  const propertyName = "value";
1671
1695
  // these ObjectSchema is not added to codeModel.schemas
1672
- const objectSchema = new ObjectSchema(modelName, this.getDoc(rawUnionType), {
1673
- summary: this.getSummary(rawUnionType),
1696
+ const objectSchema = new ObjectSchema(modelName, (_a = it.details) !== null && _a !== void 0 ? _a : "", {
1697
+ summary: it.description,
1674
1698
  language: {
1675
1699
  default: {
1676
1700
  namespace: namespace,
@@ -1681,8 +1705,8 @@ export class CodeModelBuilder {
1681
1705
  },
1682
1706
  });
1683
1707
  const variantSchema = this.processSchemaFromSdkType(it, variantName);
1684
- objectSchema.addProperty(new Property(propertyName, this.getDoc(rawUnionType), variantSchema, {
1685
- summary: this.getSummary(rawUnionType),
1708
+ objectSchema.addProperty(new Property(propertyName, (_b = type.details) !== null && _b !== void 0 ? _b : "", variantSchema, {
1709
+ summary: type.description,
1686
1710
  required: true,
1687
1711
  readOnly: false,
1688
1712
  }));
@@ -1843,6 +1867,30 @@ export class CodeModelBuilder {
1843
1867
  return false;
1844
1868
  }
1845
1869
  }
1870
+ getMutability(target) {
1871
+ if (target.kind === "property" && target.visibility) {
1872
+ const mutability = [];
1873
+ if (target.visibility.includes(Visibility.Create)) {
1874
+ mutability.push("create");
1875
+ }
1876
+ if (target.visibility.includes(Visibility.Update)) {
1877
+ mutability.push("update");
1878
+ }
1879
+ if (target.visibility.includes(Visibility.Read)) {
1880
+ mutability.push("read");
1881
+ }
1882
+ if (mutability.length === 3) {
1883
+ // if all 3 (supported) mutability values are present, there is no need to set the x-ms-mutability
1884
+ return undefined;
1885
+ }
1886
+ else {
1887
+ return mutability;
1888
+ }
1889
+ }
1890
+ else {
1891
+ return undefined;
1892
+ }
1893
+ }
1846
1894
  getConvenienceApiName(op) {
1847
1895
  // check @convenienceMethod
1848
1896
  if (shouldGenerateConvenient(this.sdkContext, op)) {