@azure-tools/typespec-java 0.12.2 → 0.12.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.
@@ -28,6 +28,7 @@ export declare class CodeModelBuilder {
28
28
  private processRouteForPaged;
29
29
  private processLroMetadata;
30
30
  private processRouteForLongRunning;
31
+ private _armApiVersionParameter?;
31
32
  private processParameter;
32
33
  private addAcceptHeaderParameter;
33
34
  private processEtagHeaderParameters;
@@ -60,6 +61,8 @@ export declare class CodeModelBuilder {
60
61
  private processUrlSchema;
61
62
  private processObjectSchema;
62
63
  private getEffectiveSchemaType;
64
+ private dummyResourceSchema;
65
+ private dummyObjectSchema;
63
66
  private applyModelPropertyDecorators;
64
67
  private processModelProperty;
65
68
  private processFormatString;
@@ -93,9 +96,13 @@ export declare class CodeModelBuilder {
93
96
  get apiVersionParameter(): Parameter;
94
97
  private _apiVersionParameterInPath?;
95
98
  get apiVersionParameterInPath(): Parameter;
99
+ private isSubscriptionId;
100
+ private subscriptionIdParameter;
101
+ private _subscriptionParameter?;
96
102
  private propagateSchemaUsage;
97
103
  private trackSchemaUsage;
98
104
  private isArmLongRunningOperation;
105
+ private isArm;
99
106
  private isSchemaUsageEmpty;
100
107
  }
101
108
  //# sourceMappingURL=code-model-builder.d.ts.map
@@ -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,EAMZ,MAAM,oBAAoB,CAAC;AAgC5B,OAAO,EACL,SAAS,EAIT,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;AAW9C,OAAO,EACL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,IAAI,SAAS,CAMzC;IAED,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IAiE5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,yBAAyB;IAIjC,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,kBAAkB;CAiB3B"}
@@ -1,6 +1,6 @@
1
- import { getDoc, getEffectiveModelType, getFormat, getFriendlyName, getKnownValues, getSummary, getVisibility, ignoreDiagnostics, isArrayModelType, isRecordModelType, isUnknownType, getDiscriminator, isNeverType, listServices, getNamespaceFullName, isNullType, getTypeName, getProjectedName, getEncode, getOverloadedOperation, isErrorModel, } from "@typespec/compiler";
1
+ import { getDoc, getEffectiveModelType, getFormat, getFriendlyName, getKnownValues, getSummary, getVisibility, ignoreDiagnostics, isArrayModelType, isRecordModelType, isUnknownType, getDiscriminator, isNeverType, listServices, getNamespaceFullName, isNullType, getTypeName, getProjectedName, getEncode, getOverloadedOperation, isErrorModel, walkPropertiesInherited, getService, } from "@typespec/compiler";
2
2
  import { getResourceOperation, getSegment } from "@typespec/rest";
3
- import { getAuthentication, getServers, getStatusCodeDescription, getHttpOperation, getQueryParamOptions, getHeaderFieldOptions, } from "@typespec/http";
3
+ import { getAuthentication, getServers, getStatusCodeDescription, getHttpOperation, getQueryParamOptions, getHeaderFieldOptions, isPathParam, } from "@typespec/http";
4
4
  import { getAddedOnVersions, getVersion } from "@typespec/versioning";
5
5
  import { isPollingLocation, getPagedResult, isFixed, getLroMetadata } from "@azure-tools/typespec-azure-core";
6
6
  import { listClients, listOperationGroups, listOperationsInOperationGroup, isApiVersion, shouldGenerateConvenient, createSdkContext, shouldGenerateProtocol, isInternal, getCrossLanguageDefinitionId, } from "@azure-tools/typespec-client-generator-core";
@@ -22,6 +22,7 @@ import { ClientContext } from "./models.js";
22
22
  import { stringArrayContainsIgnoreCase, getJavaNamespace, getNamespace, pascalCase, logWarning, trace, } from "./utils.js";
23
23
  import { ProcessingCache, isModelReferredInTemplate, pushDistinct, modelContainsDerivedModel, getNameForTemplate, getDurationFormat, hasScalarAsBase, isNullableType, isSameLiteralTypes, getAccess, getUsage, getUnionDescription, modelIs, getModelNameForProperty, isAllValueInteger, } from "./type-utils.js";
24
24
  import { getClientApiVersions, getServiceVersion, operationIsJsonMergePatch, isPayloadProperty, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, loadExamples, isLroNewPollingStrategy, operationIsMultipleContentTypes, cloneOperationParameter, operationIsMultipart, isKnownContentType, CONTENT_TYPE_KEY, } from "./operation-utils.js";
25
+ import { isArmCommonType } from "./type-utils.js";
25
26
  import pkg from "lodash";
26
27
  import { getExtensions } from "@typespec/openapi";
27
28
  const { isEqual } = pkg;
@@ -267,10 +268,14 @@ export class CodeModelBuilder {
267
268
  // deduplicate model name
268
269
  const nameCount = new Map();
269
270
  const deduplicateName = (schema) => {
270
- var _a, _b;
271
+ var _a, _b, _c, _d;
272
+ // skip models under "Azure.ResourceManager"
273
+ if (this.isArm() && ((_b = (_a = schema.language.default) === null || _a === void 0 ? void 0 : _a.namespace) === null || _b === void 0 ? void 0 : _b.startsWith("Azure.ResourceManager"))) {
274
+ return;
275
+ }
271
276
  const name = schema.language.default.name;
272
277
  // skip models under "com.azure.core."
273
- if (name && !((_b = (_a = schema.language.java) === null || _a === void 0 ? void 0 : _a.namespace) === null || _b === void 0 ? void 0 : _b.startsWith("com.azure.core."))) {
278
+ if (name && !((_d = (_c = schema.language.java) === null || _c === void 0 ? void 0 : _c.namespace) === null || _d === void 0 ? void 0 : _d.startsWith("com.azure.core."))) {
274
279
  if (!nameCount.has(name)) {
275
280
  nameCount.set(name, 1);
276
281
  }
@@ -329,18 +334,16 @@ export class CodeModelBuilder {
329
334
  codeModelClient.apiVersions.push(apiVersion);
330
335
  }
331
336
  }
332
- // } else {
333
- // // fallback to @service.version
334
- // const service = getService(this.program, client.service);
335
- // if (service?.version) {
336
- // codeModelClient.apiVersions = [];
337
- // const apiVersion = new ApiVersion();
338
- // apiVersion.version = service.version;
339
- // codeModelClient.apiVersions.push(apiVersion);
340
- // } else {
341
- // throw new Error(`API version not available for client ${client.name}.`);
342
- // }
343
- // }
337
+ else {
338
+ // fallback to @service.version
339
+ const service = getService(this.program, client.service);
340
+ if (service === null || service === void 0 ? void 0 : service.version) {
341
+ codeModelClient.apiVersions = [];
342
+ const apiVersion = new ApiVersion();
343
+ apiVersion.version = service.version;
344
+ codeModelClient.apiVersions.push(apiVersion);
345
+ }
346
+ }
344
347
  // server
345
348
  let baseUri = "{endpoint}";
346
349
  const servers = getServers(this.program, client.service);
@@ -671,7 +674,24 @@ export class CodeModelBuilder {
671
674
  var _a;
672
675
  if (clientContext.apiVersions && isApiVersion(this.sdkContext, param)) {
673
676
  // pre-condition for "isApiVersion": the client supports ApiVersions
674
- const parameter = param.type === "query" ? this.apiVersionParameter : this.apiVersionParameterInPath;
677
+ if (this.isArm()) {
678
+ // Currently we assume ARM tsp only have one client and one api-version.
679
+ // TODO: How will service define mixed api-versions(like those in Compute RP)?
680
+ const apiVersion = clientContext.apiVersions[0];
681
+ if (!this._armApiVersionParameter) {
682
+ this._armApiVersionParameter = this.createApiVersionParameter("api-version", param.type === "query" ? ParameterLocation.Query : ParameterLocation.Path, apiVersion);
683
+ clientContext.addGlobalParameter(this._armApiVersionParameter);
684
+ }
685
+ op.addParameter(this._armApiVersionParameter);
686
+ }
687
+ else {
688
+ const parameter = param.type === "query" ? this.apiVersionParameter : this.apiVersionParameterInPath;
689
+ op.addParameter(parameter);
690
+ clientContext.addGlobalParameter(parameter);
691
+ }
692
+ }
693
+ else if (this.isSubscriptionId(param)) {
694
+ const parameter = this.subscriptionIdParameter(param);
675
695
  op.addParameter(parameter);
676
696
  clientContext.addGlobalParameter(parameter);
677
697
  }
@@ -1264,7 +1284,9 @@ export class CodeModelBuilder {
1264
1284
  schema = this.processChoiceSchema(knownValues, this.getName(knownValues), false);
1265
1285
  }
1266
1286
  else {
1267
- const schemaNameHint = pascalCase(getModelNameForProperty(type)) + pascalCase(nameHint);
1287
+ const schemaNameHint = type.type.kind === "Scalar" && this.program.checker.isStdType(type.type)
1288
+ ? nameHint // std scalar won't need a nameHint
1289
+ : pascalCase(getModelNameForProperty(type)) + pascalCase(nameHint);
1268
1290
  schema = this.processSchema(type.type, schemaNameHint);
1269
1291
  }
1270
1292
  return this.applyModelPropertyDecorators(type, nameHint, schema);
@@ -1291,6 +1313,7 @@ export class CodeModelBuilder {
1291
1313
  processScalar(type, formatFromDerived, nameHint) {
1292
1314
  const scalarName = type.name;
1293
1315
  if (this.program.checker.isStdType(type)) {
1316
+ nameHint = scalarName;
1294
1317
  switch (scalarName) {
1295
1318
  case "string": {
1296
1319
  const format = formatFromDerived !== null && formatFromDerived !== void 0 ? formatFromDerived : getFormat(this.program, type);
@@ -1551,6 +1574,18 @@ export class CodeModelBuilder {
1551
1574
  processObjectSchema(type, name) {
1552
1575
  var _a, _b;
1553
1576
  const namespace = getNamespace(type);
1577
+ if ((this.isArm() &&
1578
+ (namespace === null || namespace === void 0 ? void 0 : namespace.startsWith("Azure.ResourceManager")) &&
1579
+ // there's ResourceListResult under Azure.ResourceManager namespace,
1580
+ // which shouldn't be considered Resource schema parent
1581
+ ((name === null || name === void 0 ? void 0 : name.startsWith("TrackedResource")) ||
1582
+ (name === null || name === void 0 ? void 0 : name.startsWith("ExtensionResource")) ||
1583
+ (name === null || name === void 0 ? void 0 : name.startsWith("ProxyResource")))) ||
1584
+ name === "ArmResource") {
1585
+ const objectSchema = this.dummyResourceSchema(type, name, namespace);
1586
+ this.codeModel.schemas.add(objectSchema);
1587
+ return objectSchema;
1588
+ }
1554
1589
  const objectSchema = new ObjectScheme(name, this.getDoc(type), {
1555
1590
  summary: this.getSummary(type),
1556
1591
  language: {
@@ -1626,7 +1661,14 @@ export class CodeModelBuilder {
1626
1661
  else if (isRecordModelType(this.program, type)) {
1627
1662
  // "pure" Record processed elsewhere
1628
1663
  // "mixed" Record that have properties, treat the model as "additionalProperties"
1629
- const parentSchema = this.processDictionarySchema(type, this.getName(type));
1664
+ /* type should have sourceModel, as
1665
+ model Type is Record<> {
1666
+ prop1: string
1667
+ }
1668
+ */
1669
+ const parentSchema = type.sourceModel
1670
+ ? this.processSchema(type.sourceModel, this.getName(type.sourceModel))
1671
+ : this.processDictionarySchema(type, this.getName(type));
1630
1672
  objectSchema.parents = new Relations();
1631
1673
  objectSchema.parents.immediate.push(parentSchema);
1632
1674
  pushDistinct(objectSchema.parents.all, parentSchema);
@@ -1669,18 +1711,47 @@ export class CodeModelBuilder {
1669
1711
  return objectSchema;
1670
1712
  }
1671
1713
  getEffectiveSchemaType(type) {
1714
+ var _a;
1672
1715
  const program = this.program;
1673
1716
  function isSchemaProperty(property) {
1674
1717
  return isPayloadProperty(program, property);
1675
1718
  }
1676
1719
  if (type.kind === "Model") {
1677
1720
  const effective = getEffectiveModelType(program, type, isSchemaProperty);
1678
- if (effective.name) {
1721
+ if (this.isArm() && ((_a = getNamespace(effective)) === null || _a === void 0 ? void 0 : _a.startsWith("Azure.ResourceManager"))) {
1722
+ // Catalog is TrackedResource<CatalogProperties>
1723
+ return type;
1724
+ }
1725
+ else if (effective.name) {
1679
1726
  return effective;
1680
1727
  }
1681
1728
  }
1682
1729
  return type;
1683
1730
  }
1731
+ dummyResourceSchema(type, name, namespace) {
1732
+ const resourceModelName = (name === null || name === void 0 ? void 0 : name.startsWith("TrackedResource")) ? "Resource" : "ProxyResource";
1733
+ const resource = this.dummyObjectSchema(type, resourceModelName, namespace);
1734
+ const declaredProperties = walkPropertiesInherited(type);
1735
+ for (const prop of declaredProperties) {
1736
+ resource.addProperty(this.processModelProperty(prop));
1737
+ }
1738
+ return resource;
1739
+ }
1740
+ dummyObjectSchema(type, name, namespace) {
1741
+ return new ObjectScheme(name, this.getDoc(type), {
1742
+ summary: this.getSummary(type),
1743
+ language: {
1744
+ default: {
1745
+ name: name,
1746
+ namespace: namespace,
1747
+ },
1748
+ java: {
1749
+ name: name,
1750
+ namespace: getJavaNamespace(namespace),
1751
+ },
1752
+ },
1753
+ });
1754
+ }
1684
1755
  applyModelPropertyDecorators(prop, nameHint, schema) {
1685
1756
  // if (schema instanceof StringSchema) {
1686
1757
  // const decorators = {
@@ -2016,10 +2087,10 @@ export class CodeModelBuilder {
2016
2087
  var _a;
2017
2088
  return ((_a = this._pollResultSchema) !== null && _a !== void 0 ? _a : (this._pollResultSchema = createPollOperationDetailsSchema(this.codeModel.schemas, this.stringSchema)));
2018
2089
  }
2019
- createApiVersionParameter(serializedName, parameterLocation) {
2090
+ createApiVersionParameter(serializedName, parameterLocation, value = "") {
2020
2091
  return new Parameter(serializedName, "Version parameter", this.codeModel.schemas.add(new ConstantSchema(serializedName, "API Version", {
2021
2092
  valueType: this.stringSchema,
2022
- value: new ConstantValue(""),
2093
+ value: new ConstantValue(value),
2023
2094
  })), {
2024
2095
  implementation: ImplementationLocation.Client,
2025
2096
  origin: ORIGIN_API_VERSION,
@@ -2043,6 +2114,32 @@ export class CodeModelBuilder {
2043
2114
  // TODO: hardcode as "apiVersion", as it is what we get from compiler
2044
2115
  (this._apiVersionParameterInPath = this.createApiVersionParameter("apiVersion", ParameterLocation.Path)));
2045
2116
  }
2117
+ isSubscriptionId(param) {
2118
+ var _a;
2119
+ return ("subscriptionId".toLocaleLowerCase() === ((_a = param === null || param === void 0 ? void 0 : param.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) &&
2120
+ param.param &&
2121
+ isArmCommonType(param.param) &&
2122
+ isPathParam(this.program, param.param));
2123
+ }
2124
+ subscriptionIdParameter(parameter) {
2125
+ if (!this._subscriptionParameter) {
2126
+ const param = parameter.param;
2127
+ const description = getDoc(this.program, param);
2128
+ this._subscriptionParameter = new Parameter("subscriptionId", description ? description : "The ID of the target subscription.", this.stringSchema, {
2129
+ implementation: ImplementationLocation.Client,
2130
+ required: true,
2131
+ protocol: {
2132
+ http: new HttpParameter(ParameterLocation.Path),
2133
+ },
2134
+ language: {
2135
+ default: {
2136
+ serializedName: "subscriptionId",
2137
+ },
2138
+ },
2139
+ });
2140
+ }
2141
+ return this._subscriptionParameter;
2142
+ }
2046
2143
  propagateSchemaUsage(schema) {
2047
2144
  var _a, _b;
2048
2145
  const processedSchemas = new Set();
@@ -2126,7 +2223,10 @@ export class CodeModelBuilder {
2126
2223
  }
2127
2224
  isArmLongRunningOperation(program, op) {
2128
2225
  var _a;
2129
- return this.codeModel.arm && Boolean((_a = getExtensions(program, op)) === null || _a === void 0 ? void 0 : _a.get("x-ms-long-running-operation"));
2226
+ return this.isArm() && Boolean((_a = getExtensions(program, op)) === null || _a === void 0 ? void 0 : _a.get("x-ms-long-running-operation"));
2227
+ }
2228
+ isArm() {
2229
+ return this.codeModel.arm;
2130
2230
  }
2131
2231
  isSchemaUsageEmpty(schema) {
2132
2232
  if (schema instanceof ObjectSchema ||