@azure-tools/typespec-java 0.15.13 → 0.15.15

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.
@@ -26,6 +26,15 @@ export declare class CodeModelBuilder {
26
26
  private deduplicateSchemaName;
27
27
  private resolveSchemaUsage;
28
28
  private processClients;
29
+ /**
30
+ * Filter api-versions for "ServiceVersion".
31
+ * TODO(xiaofei) pending TCGC design: https://github.com/Azure/typespec-azure/issues/746
32
+ *
33
+ * @param pinnedApiVersion the api-version to use as filter base
34
+ * @param versions api-versions to filter
35
+ * @returns filtered api-versions
36
+ */
37
+ private getFilteredApiVersions;
29
38
  /**
30
39
  * `@armProviderNamespace` currently will add a default server if not defined globally:
31
40
  * https://github.com/Azure/typespec-azure/blob/8b8d7c05f168d9305a09691c4fedcb88f4a57652/packages/typespec-azure-resource-manager/src/namespace.ts#L121-L128
@@ -36,11 +45,11 @@ export declare class CodeModelBuilder {
36
45
  */
37
46
  private isArmSynthesizedServer;
38
47
  private needToSkipProcessingOperation;
39
- private existsAtCurrentVersion;
40
48
  /**
41
49
  * Whether we support advanced versioning in non-breaking fashion.
42
50
  */
43
51
  private supportsAdvancedVersioning;
52
+ private getOperationExample;
44
53
  private processOperation;
45
54
  private processRouteForPaged;
46
55
  private processLroMetadata;
@@ -1 +1 @@
1
- {"version":3,"file":"code-model-builder.d.ts","sourceRoot":"","sources":["../../src/code-model-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAoBL,OAAO,EAGP,IAAI,EAEJ,KAAK,EASL,WAAW,EAQZ,MAAM,oBAAoB,CAAC;AA6C5B,OAAO,EACL,SAAS,EAGT,YAAY,EACZ,aAAa,EAUb,YAAY,EACZ,YAAY,EACZ,SAAS,EAKT,MAAM,EAIN,YAAY,EAeb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAUnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;A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ary, getVisibility, ignoreDiagnostics, isArrayModelType, isRecordModelType, isUnknownType, getDiscriminator, isNeverType, listServices, getNamespaceFullName, isNullType, getTypeName, getProjectedName, getEncode, getOverloadedOperation, walkPropertiesInherited, isVoidType, isErrorModel, } from "@typespec/compiler";
2
2
  import { getResourceOperation, getSegment } from "@typespec/rest";
3
3
  import { getAuthentication, getServers, getStatusCodeDescription, getHttpOperation, getQueryParamOptions, getHeaderFieldOptions, isPathParam, } from "@typespec/http";
4
- import { Availability, getAddedOnVersions, getAvailabilityMap, getVersion } from "@typespec/versioning";
4
+ import { getAddedOnVersions, getVersion } from "@typespec/versioning";
5
5
  import { isPollingLocation, getPagedResult, isFixed, getLroMetadata, getUnionAsEnum, } from "@azure-tools/typespec-azure-core";
6
6
  import { listClients, listOperationGroups, listOperationsInOperationGroup, isApiVersion, shouldGenerateConvenient, createSdkContext, shouldGenerateProtocol, isInternal, getCrossLanguageDefinitionId, getClientNameOverride, shouldFlattenProperty, getWireName, getDefaultApiVersion, } from "@azure-tools/typespec-client-generator-core";
7
7
  import { fail } from "assert";
@@ -20,7 +20,7 @@ import { PreNamer } from "./prenamer/prenamer.js";
20
20
  import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./external-schemas.js";
21
21
  import { ClientContext } from "./models.js";
22
22
  import { stringArrayContainsIgnoreCase, getJavaNamespace, getNamespace, pascalCase, logWarning, trace, } from "./utils.js";
23
- import { ProcessingCache, isModelReferredInTemplate, pushDistinct, modelContainsDerivedModel, getNameForTemplate, getDurationFormat, hasScalarAsBase, isNullableType, getAccess, getUsage, getUnionDescription, modelIs, getNamePrefixForProperty, isAllValueInteger, } from "./type-utils.js";
23
+ import { ProcessingCache, isModelReferredInTemplate, pushDistinct, modelContainsDerivedModel, getNameForTemplate, getDurationFormat, hasScalarAsBase, isNullableType, getAccess, getUsage, getUnionDescription, modelIs, getNamePrefixForProperty, isAllValueInteger, isStable, } from "./type-utils.js";
24
24
  import { getServiceVersion, operationIsJsonMergePatch, isPayloadProperty, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, loadExamples, isLroNewPollingStrategy, operationIsMultipleContentTypes, cloneOperationParameter, operationIsMultipart, isKnownContentType, CONTENT_TYPE_KEY, } from "./operation-utils.js";
25
25
  import { isArmCommonType } from "./type-utils.js";
26
26
  import pkg from "lodash";
@@ -84,7 +84,7 @@ export class CodeModelBuilder {
84
84
  }
85
85
  }
86
86
  async build() {
87
- this.operationExamples = await loadExamples(this.program, this.options);
87
+ this.operationExamples = await loadExamples(this.program, this.options, this.sdkContext);
88
88
  if (this.sdkContext.arm) {
89
89
  // ARM
90
90
  this.codeModel.arm = true;
@@ -351,12 +351,6 @@ export class CodeModelBuilder {
351
351
  const versioning = getVersion(this.program, client.service);
352
352
  if (versioning && versioning.getVersions()) {
353
353
  // @versioned in versioning
354
- codeModelClient.apiVersions = [];
355
- for (const version of versioning.getVersions()) {
356
- const apiVersion = new ApiVersion();
357
- apiVersion.version = version.value;
358
- codeModelClient.apiVersions.push(apiVersion);
359
- }
360
354
  if (!this.sdkContext.apiVersion || ["all", "latest"].includes(this.sdkContext.apiVersion)) {
361
355
  this.apiVersion = getDefaultApiVersion(this.sdkContext, client.service);
362
356
  }
@@ -366,6 +360,12 @@ export class CodeModelBuilder {
366
360
  throw new Error("Unrecognized api-version: " + this.sdkContext.apiVersion);
367
361
  }
368
362
  }
363
+ codeModelClient.apiVersions = [];
364
+ for (const version of this.getFilteredApiVersions(this.apiVersion, versioning.getVersions())) {
365
+ const apiVersion = new ApiVersion();
366
+ apiVersion.version = version.value;
367
+ codeModelClient.apiVersions.push(apiVersion);
368
+ }
369
369
  }
370
370
  // server
371
371
  let baseUri = "{endpoint}";
@@ -449,6 +449,22 @@ export class CodeModelBuilder {
449
449
  }
450
450
  return clients;
451
451
  }
452
+ /**
453
+ * Filter api-versions for "ServiceVersion".
454
+ * TODO(xiaofei) pending TCGC design: https://github.com/Azure/typespec-azure/issues/746
455
+ *
456
+ * @param pinnedApiVersion the api-version to use as filter base
457
+ * @param versions api-versions to filter
458
+ * @returns filtered api-versions
459
+ */
460
+ getFilteredApiVersions(pinnedApiVersion, versions) {
461
+ if (!pinnedApiVersion) {
462
+ return versions;
463
+ }
464
+ return versions
465
+ .slice(0, versions.indexOf(pinnedApiVersion) + 1)
466
+ .filter((version) => !isStable(pinnedApiVersion) || isStable(version));
467
+ }
452
468
  /**
453
469
  * `@armProviderNamespace` currently will add a default server if not defined globally:
454
470
  * https://github.com/Azure/typespec-azure/blob/8b8d7c05f168d9305a09691c4fedcb88f4a57652/packages/typespec-azure-resource-manager/src/namespace.ts#L121-L128
@@ -461,9 +477,6 @@ export class CodeModelBuilder {
461
477
  return this.isArm() && (!server.parameters || server.parameters.size == 0);
462
478
  }
463
479
  needToSkipProcessingOperation(operation, clientContext) {
464
- if (!this.existsAtCurrentVersion(operation)) {
465
- return true;
466
- }
467
480
  // don't generate protocol and convenience method for overloaded operations
468
481
  // issue link: https://github.com/Azure/autorest.java/issues/1958#issuecomment-1562558219 we will support generate overload methods for non-union type in future (TODO issue: https://github.com/Azure/autorest.java/issues/2160)
469
482
  if (getOverloadedOperation(this.program, operation)) {
@@ -472,37 +485,37 @@ export class CodeModelBuilder {
472
485
  }
473
486
  return false;
474
487
  }
475
- existsAtCurrentVersion(type) {
476
- var _a;
477
- const availabilityMap = getAvailabilityMap(this.program, type);
478
- // if unversioned then everything exists
479
- if (!availabilityMap ||
480
- !this.apiVersion ||
481
- this.supportsAdvancedVersioning() // if supports non-breaking versioning, then it always exists
482
- ) {
483
- return true;
484
- }
485
- const availability = availabilityMap.get((_a = this.apiVersion) === null || _a === void 0 ? void 0 : _a.name);
486
- return availability === Availability.Added || availability === Availability.Available;
487
- }
488
488
  /**
489
489
  * Whether we support advanced versioning in non-breaking fashion.
490
490
  */
491
491
  supportsAdvancedVersioning() {
492
492
  return Boolean(this.options["advanced-versioning"]);
493
493
  }
494
+ getOperationExample(operation) {
495
+ var _a, _b;
496
+ if (((_a = operation.projectionSource) === null || _a === void 0 ? void 0 : _a.kind) === "Operation") {
497
+ // always use the projectionSource, if available
498
+ operation = operation.projectionSource;
499
+ }
500
+ let operationExample = this.operationExamples.get(operation);
501
+ if (!operationExample && operation.sourceOperation) {
502
+ // if the operation is customized in client.tsp, the operation would be different from that of main.tsp
503
+ // try the operation.sourceOperation
504
+ operation = operation.sourceOperation;
505
+ if (((_b = operation.projectionSource) === null || _b === void 0 ? void 0 : _b.kind) === "Operation") {
506
+ operation = operation.projectionSource;
507
+ }
508
+ operationExample = this.operationExamples.get(operation);
509
+ }
510
+ return operationExample;
511
+ }
494
512
  processOperation(groupName, operation, clientContext) {
495
513
  var _a, _b, _c;
496
514
  const op = ignoreDiagnostics(getHttpOperation(this.program, operation));
497
515
  const operationGroup = this.codeModel.getOperationGroup(groupName);
498
516
  const operationName = this.getName(operation);
499
517
  const opId = groupName ? `${groupName}_${operationName}` : `${operationName}`;
500
- let operationExample = this.operationExamples.get(operation);
501
- if (!operationExample && operation.sourceOperation) {
502
- // if the operation is customized in client.tsp, the operation would be different from that of main.tsp
503
- // try the operation.sourceOperation
504
- operationExample = this.operationExamples.get(operation.sourceOperation);
505
- }
518
+ const operationExample = this.getOperationExample(operation);
506
519
  const codeModelOperation = new CodeModelOperation(operationName, this.getDoc(operation), {
507
520
  operationId: opId,
508
521
  summary: this.getSummary(operation),
@@ -572,9 +585,7 @@ export class CodeModelBuilder {
572
585
  // host
573
586
  clientContext.hostParameters.forEach((it) => codeModelOperation.addParameter(it));
574
587
  // parameters
575
- op.parameters.parameters
576
- .filter((param) => this.existsAtCurrentVersion(param.param))
577
- .map((it) => this.processParameter(codeModelOperation, it, clientContext));
588
+ op.parameters.parameters.map((it) => this.processParameter(codeModelOperation, it, clientContext));
578
589
  // "accept" header
579
590
  this.addAcceptHeaderParameter(codeModelOperation, op.responses);
580
591
  // body
@@ -1817,8 +1828,7 @@ export class CodeModelBuilder {
1817
1828
  for (const prop of type.properties.values()) {
1818
1829
  if (prop.name === discriminatorPropertyName || // skip the discriminator property
1819
1830
  isNeverType(prop.type) || // skip property of type "never"
1820
- !isPayloadProperty(this.program, prop) ||
1821
- !this.existsAtCurrentVersion(prop)) {
1831
+ !isPayloadProperty(this.program, prop)) {
1822
1832
  continue;
1823
1833
  }
1824
1834
  objectSchema.addProperty(this.processModelProperty(prop));
@@ -1850,9 +1860,7 @@ export class CodeModelBuilder {
1850
1860
  const resource = this.dummyObjectSchema(type, resourceModelName, namespace);
1851
1861
  const declaredProperties = walkPropertiesInherited(type);
1852
1862
  for (const prop of declaredProperties) {
1853
- if (this.existsAtCurrentVersion(type)) {
1854
- resource.addProperty(this.processModelProperty(prop));
1855
- }
1863
+ resource.addProperty(this.processModelProperty(prop));
1856
1864
  }
1857
1865
  return resource;
1858
1866
  }