@azure-tools/typespec-java 0.18.2 → 0.18.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.
@@ -11,10 +11,11 @@ export declare class CodeModelBuilder {
11
11
  private sdkContext;
12
12
  private options;
13
13
  private codeModel;
14
+ private emitterContext;
15
+ private serviceNamespace;
14
16
  private loggingEnabled;
15
17
  readonly schemaCache: ProcessingCache<SdkType, Schema>;
16
18
  readonly typeUnionRefCache: Map<Type, Union | null | undefined>;
17
- private operationExamples;
18
19
  private apiVersion;
19
20
  constructor(program1: Program, context: EmitContext<EmitterOptions>);
20
21
  build(): Promise<CodeModel>;
@@ -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,EAmBR,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EAIX,OAAO,EAEP,IAAI,EAEJ,KAAK,EAeN,MAAM,oBAAoB,CAAC;AA4B5B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAiB9C,OAAO,EACL,eAAe,EAahB,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,i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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"}
@@ -1,14 +1,14 @@
1
1
  import { AnySchema, ApiVersion, ArraySchema, BinaryResponse, BinarySchema, BooleanSchema, ByteArraySchema, ChoiceValue, DateSchema, DateTimeSchema, DictionarySchema, Discriminator, GroupProperty, GroupSchema, HttpHeader, HttpParameter, ImplementationLocation, KeySecurityScheme, Language, Metadata, NumberSchema, OAuth2SecurityScheme, ObjectSchema, OperationGroup, Parameter, ParameterLocation, Property, Relations, Response, SchemaResponse, SchemaType, Security, SerializationStyle, StringSchema, TimeSchema, UnixTimeSchema, UriSchema, VirtualParameter, } from "@autorest/codemodel";
2
2
  import { KnownMediaType } from "@azure-tools/codegen";
3
3
  import { getLroMetadata, getPagedResult, isPollingLocation } from "@azure-tools/typespec-azure-core";
4
- import { createSdkContext, getAllModels, getClientNameOverride, getClientType, getCrossLanguageDefinitionId, getDefaultApiVersion, getHttpOperationWithCache, getWireName, isApiVersion, isInternal, isSdkBuiltInKind, isSdkIntKind, listClients, listOperationGroups, listOperationsInOperationGroup, shouldGenerateConvenient, shouldGenerateProtocol, } from "@azure-tools/typespec-client-generator-core";
4
+ import { createSdkContext, getAllModels, getClientNameOverride, getClientType, getCrossLanguageDefinitionId, getDefaultApiVersion, getHttpOperationWithCache, getWireName, isApiVersion, isInternal, isSdkBuiltInKind, isSdkIntKind, listClients, listOperationGroups, listOperationsInOperationGroup, shouldGenerateConvenient, shouldGenerateProtocol, getHttpOperationExamples, } from "@azure-tools/typespec-client-generator-core";
5
5
  import { getDoc, getEffectiveModelType, getEncode, getFriendlyName, getNamespaceFullName, getOverloadedOperation, getProjectedName, getSummary, getVisibility, isArrayModelType, isErrorModel, isRecordModelType, isVoidType, listServices, } from "@typespec/compiler";
6
6
  import { Visibility, getAuthentication, getHeaderFieldName, getHeaderFieldOptions, getPathParamName, getQueryParamName, getQueryParamOptions, getServers, getStatusCodeDescription, isHeader, isPathParam, isQueryParam, } from "@typespec/http";
7
7
  import { getResourceOperation, getSegment } from "@typespec/rest";
8
8
  import { getAddedOnVersions, getVersion } from "@typespec/versioning";
9
9
  import { fail } from "assert";
10
10
  import pkg from "lodash";
11
- import { Client as CodeModelClient, ObjectScheme } from "./common/client.js";
11
+ import { Client as CodeModelClient } from "./common/client.js";
12
12
  import { CodeModel } from "./common/code-model.js";
13
13
  import { LongRunningMetadata } from "./common/long-running-metadata.js";
14
14
  import { Operation as CodeModelOperation, ConvenienceApi, Request } from "./common/operation.js";
@@ -19,10 +19,11 @@ import { DurationSchema } from "./common/schemas/time.js";
19
19
  import { SchemaContext } from "./common/schemas/usage.js";
20
20
  import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./external-schemas.js";
21
21
  import { ClientContext } from "./models.js";
22
- import { ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, isPayloadProperty, loadExamples, operationIsJsonMergePatch, operationIsMultipart, operationIsMultipleContentTypes, } from "./operation-utils.js";
22
+ import { ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, isPayloadProperty, operationIsJsonMergePatch, operationIsMultipart, operationIsMultipleContentTypes, } from "./operation-utils.js";
23
23
  import { PreNamer } from "./prenamer/prenamer.js";
24
24
  import { ProcessingCache, getAccess, getDurationFormatFromSdkType, getNonNullSdkType, 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
+ import { pathToFileURL } from "url";
26
27
  const { isEqual } = pkg;
27
28
  export class CodeModelBuilder {
28
29
  constructor(program1, context) {
@@ -30,30 +31,30 @@ export class CodeModelBuilder {
30
31
  this.loggingEnabled = false;
31
32
  this.schemaCache = new ProcessingCache((type, name) => this.processSchemaFromSdkTypeImpl(type, name));
32
33
  this.typeUnionRefCache = new Map(); // Union means it ref a Union type, null means it does not ref any Union, undefined means type visited but not completed
33
- this.operationExamples = new Map();
34
34
  this.options = context.options;
35
35
  this.program = program1;
36
+ this.emitterContext = context;
36
37
  if ((_a = this.options["dev-options"]) === null || _a === void 0 ? void 0 : _a.loglevel) {
37
38
  this.loggingEnabled = true;
38
39
  }
39
40
  if (this.options["skip-special-headers"]) {
40
41
  this.options["skip-special-headers"].forEach((it) => SPECIAL_HEADER_NAMES.add(it.toLowerCase()));
41
42
  }
42
- this.sdkContext = createSdkContext(context, "@azure-tools/typespec-java");
43
43
  const service = listServices(this.program)[0];
44
44
  const serviceNamespace = service.type;
45
45
  if (serviceNamespace === undefined) {
46
46
  throw Error("Cannot emit yaml for a namespace that doesn't exist.");
47
47
  }
48
- // java namespace
48
+ this.serviceNamespace = serviceNamespace;
49
49
  this.namespace = getNamespaceFullName(serviceNamespace) || "Azure.Client";
50
+ // java namespace
50
51
  const javaNamespace = getJavaNamespace(this.namespace);
51
52
  const namespace1 = this.namespace;
52
53
  this.typeNameOptions = {
53
54
  // shorten type names by removing TypeSpec and service namespace
54
55
  namespaceFilter(ns) {
55
56
  const name = getNamespaceFullName(ns);
56
- return name !== "Cadl" && name !== namespace1;
57
+ return name !== "TypeSpec" && name !== namespace1;
57
58
  },
58
59
  };
59
60
  // init code model
@@ -75,15 +76,15 @@ export class CodeModelBuilder {
75
76
  },
76
77
  },
77
78
  });
79
+ }
80
+ async build() {
81
+ this.sdkContext = await createSdkContext(this.emitterContext, "@azure-tools/typespec-java");
78
82
  // auth
79
83
  // TODO: it is not very likely, but different client could have different auth
80
- const auth = getAuthentication(this.program, serviceNamespace);
84
+ const auth = getAuthentication(this.program, this.serviceNamespace);
81
85
  if (auth) {
82
86
  this.processAuth(auth);
83
87
  }
84
- }
85
- async build() {
86
- this.operationExamples = await loadExamples(this.program, this.options, this.sdkContext);
87
88
  if (this.sdkContext.arm) {
88
89
  // ARM
89
90
  this.codeModel.arm = true;
@@ -473,36 +474,33 @@ export class CodeModelBuilder {
473
474
  }
474
475
  getOperationExample(operation) {
475
476
  var _a, _b;
476
- if (((_a = operation.projectionSource) === null || _a === void 0 ? void 0 : _a.kind) === "Operation") {
477
- // always use the projectionSource, if available
478
- operation = operation.projectionSource;
479
- }
480
- let operationExample = this.operationExamples.get(operation);
481
- if (!operationExample && operation.sourceOperation) {
482
- // if the operation is customized in client.tsp, the operation would be different from that of main.tsp
483
- // try the operation.sourceOperation
484
- operation = operation.sourceOperation;
485
- if (((_b = operation.projectionSource) === null || _b === void 0 ? void 0 : _b.kind) === "Operation") {
486
- operation = operation.projectionSource;
477
+ const httpOperationExamples = getHttpOperationExamples(this.sdkContext, operation);
478
+ if (httpOperationExamples && httpOperationExamples.length > 0) {
479
+ const operationExamples = {};
480
+ for (const example of httpOperationExamples) {
481
+ const operationExample = example.rawExample;
482
+ operationExample["x-ms-original-file"] = pathToFileURL(example.filePath).toString();
483
+ operationExamples[(_b = (_a = operationExample.title) !== null && _a !== void 0 ? _a : operationExample.operationId) !== null && _b !== void 0 ? _b : operation.operation.name] =
484
+ operationExample;
487
485
  }
488
- operationExample = this.operationExamples.get(operation);
486
+ return operationExamples;
487
+ }
488
+ else {
489
+ return undefined;
489
490
  }
490
- return operationExample;
491
491
  }
492
492
  processOperation(groupName, operation, clientContext) {
493
- var _a, _b, _c;
493
+ var _a;
494
494
  const op = getHttpOperationWithCache(this.sdkContext, operation);
495
495
  const operationGroup = this.codeModel.getOperationGroup(groupName);
496
496
  const operationName = this.getName(operation);
497
497
  const opId = groupName ? `${groupName}_${operationName}` : `${operationName}`;
498
- const operationExample = this.getOperationExample(operation);
498
+ const operationExamples = this.getOperationExample(op);
499
499
  const codeModelOperation = new CodeModelOperation(operationName, this.getDoc(operation), {
500
500
  operationId: opId,
501
501
  summary: this.getSummary(operation),
502
502
  extensions: {
503
- "x-ms-examples": operationExample
504
- ? { [(_b = (_a = operationExample.title) !== null && _a !== void 0 ? _a : operationExample.operationId) !== null && _b !== void 0 ? _b : operation.name]: operationExample }
505
- : undefined,
503
+ "x-ms-examples": operationExamples,
506
504
  },
507
505
  });
508
506
  codeModelOperation.crossLanguageDefinitionId = getCrossLanguageDefinitionId(this.sdkContext, operation);
@@ -579,7 +577,7 @@ export class CodeModelBuilder {
579
577
  let bodyType = op.parameters.body.type;
580
578
  if (bodyType.kind === "Model") {
581
579
  // try use resource type as round-trip model
582
- const resourceType = (_c = getResourceOperation(this.program, operation)) === null || _c === void 0 ? void 0 : _c.resourceType;
580
+ const resourceType = (_a = getResourceOperation(this.program, operation)) === null || _a === void 0 ? void 0 : _a.resourceType;
583
581
  if (resourceType && op.responses && op.responses.length > 0) {
584
582
  const resp = op.responses[0];
585
583
  if (resp.responses && resp.responses.length > 0 && resp.responses[0].body) {
@@ -1331,16 +1329,7 @@ export class CodeModelBuilder {
1331
1329
  case "any":
1332
1330
  return this.processAnySchemaFromSdkType();
1333
1331
  case "string":
1334
- case "password":
1335
- case "guid":
1336
- case "ipAddress":
1337
- case "uuid":
1338
- case "ipV4Address":
1339
- case "ipV6Address":
1340
- case "eTag":
1341
- case "armId":
1342
- case "azureLocation":
1343
- return this.processStringSchemaFromSdkType(type, type.kind);
1332
+ return this.processStringSchemaFromSdkType(type, nameHint);
1344
1333
  case "float":
1345
1334
  case "float32":
1346
1335
  case "float64":
@@ -1357,7 +1346,6 @@ export class CodeModelBuilder {
1357
1346
  case "plainDate":
1358
1347
  return this.processDateSchemaFromSdkType(type, nameHint);
1359
1348
  case "url":
1360
- case "uri":
1361
1349
  return this.processUrlSchemaFromSdkType(type, nameHint);
1362
1350
  }
1363
1351
  }
@@ -1522,7 +1510,7 @@ export class CodeModelBuilder {
1522
1510
  var _a, _b;
1523
1511
  const rawModelType = type.__raw;
1524
1512
  const namespace = getNamespace(rawModelType);
1525
- const objectSchema = new ObjectScheme(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1513
+ const objectSchema = new ObjectSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
1526
1514
  summary: type.description,
1527
1515
  language: {
1528
1516
  default: {
@@ -1576,6 +1564,8 @@ export class CodeModelBuilder {
1576
1564
  kind: "string",
1577
1565
  encode: "string",
1578
1566
  decorators: [],
1567
+ name: "string",
1568
+ crossLanguageDefinitionId: type.crossLanguageDefinitionId,
1579
1569
  },
1580
1570
  description: type.description,
1581
1571
  valueType: type.additionalProperties,
@@ -1638,8 +1628,11 @@ export class CodeModelBuilder {
1638
1628
  extensions = extensions !== null && extensions !== void 0 ? extensions : {};
1639
1629
  extensions["x-ms-mutability"] = mutability;
1640
1630
  }
1641
- if (prop.kind === "property" && prop.isMultipartFileInput) {
1642
- schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop, this.namespace);
1631
+ if (prop.kind === "property" && prop.multipartOptions) {
1632
+ // TODO: handle MultipartOptions.isMulti
1633
+ if (prop.multipartOptions.isFilePart) {
1634
+ schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop, this.namespace);
1635
+ }
1643
1636
  }
1644
1637
  return new Property(prop.name, (_a = prop.details) !== null && _a !== void 0 ? _a : "", schema, {
1645
1638
  summary: prop.description,
@@ -1756,13 +1749,19 @@ export class CodeModelBuilder {
1756
1749
  }
1757
1750
  processMultipartFormDataFilePropertySchemaFromSdkType(property, namespace) {
1758
1751
  var _a;
1759
- if (property.type.kind === "bytes") {
1760
- return getFileDetailsSchema(property.name, namespace, this.codeModel.schemas, this.binarySchema, this.stringSchema);
1752
+ const processSchemaFunc = (type) => this.processSchemaFromSdkType(type, "");
1753
+ if (property.type.kind === "bytes" || property.type.kind === "model") {
1754
+ return getFileDetailsSchema(property, namespace, this.codeModel.schemas, this.binarySchema, this.stringSchema, processSchemaFunc);
1755
+ }
1756
+ else if (property.type.kind === "array" &&
1757
+ (property.type.valueType.kind === "bytes" || property.type.valueType.kind === "model")) {
1758
+ return new ArraySchema(property.name, (_a = property.details) !== null && _a !== void 0 ? _a : "", getFileDetailsSchema(property, namespace, this.codeModel.schemas, this.binarySchema, this.stringSchema, processSchemaFunc), {
1759
+ summary: property.description,
1760
+ });
1761
1761
  }
1762
- else if (property.type.kind === "array" && property.type.valueType.kind === "bytes") {
1763
- return new ArraySchema(property.name, (_a = property.description) !== null && _a !== void 0 ? _a : "", getFileDetailsSchema(property.name, namespace, this.codeModel.schemas, this.binarySchema, this.stringSchema));
1762
+ else {
1763
+ throw new Error(`Invalid type for multipart form data: '${property.type.kind}'.`);
1764
1764
  }
1765
- throw new Error(`Invalid type for multipart form data: '${property.type.kind}'.`);
1766
1765
  }
1767
1766
  getDoc(target) {
1768
1767
  return target ? getDoc(this.program, target) || "" : "";