@azure-tools/typespec-java 0.27.0 → 0.27.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.
- package/dist/src/code-model-builder.d.ts +0 -1
- package/dist/src/code-model-builder.d.ts.map +1 -1
- package/dist/src/code-model-builder.js +112 -57
- package/dist/src/code-model-builder.js.map +1 -1
- package/dist/src/common/client.d.ts +1 -4
- package/dist/src/common/client.d.ts.map +1 -1
- package/dist/src/common/operation.d.ts +1 -2
- package/dist/src/common/operation.d.ts.map +1 -1
- package/dist/src/common/operation.js.map +1 -1
- package/dist/src/emitter.d.ts +0 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +62 -94
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/external-schemas.d.ts.map +1 -1
- package/dist/src/external-schemas.js +3 -4
- package/dist/src/external-schemas.js.map +1 -1
- package/dist/src/utils.d.ts +13 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +58 -6
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validate.d.ts +5 -0
- package/dist/src/validate.d.ts.map +1 -0
- package/dist/src/validate.js +92 -0
- package/dist/src/validate.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generator/http-client-generator/target/emitter.jar +0 -0
- package/package.json +28 -28
- package/readme.md +68 -4
|
@@ -15,7 +15,6 @@ export declare class CodeModelBuilder {
|
|
|
15
15
|
private codeModel;
|
|
16
16
|
private emitterContext;
|
|
17
17
|
private serviceNamespace;
|
|
18
|
-
private loggingEnabled;
|
|
19
18
|
readonly schemaCache: ProcessingCache<SdkType, Schema>;
|
|
20
19
|
readonly typeUnionRefCache: Map<Type, Union | null | undefined>;
|
|
21
20
|
private apiVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-model-builder.d.ts","sourceRoot":"","sources":["../../src/code-model-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EA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AI,gBAAgB,IAAI,YAAY,CAQnC;IAED,OAAO,CAAC,yBAAyB;IA8BjC,OAAO,CAAC,oBAAoB,CAAC,CAAY;IACzC,IAAI,mBAAmB,IAAI,SAAS,CAQnC;IAED,OAAO,CAAC,0BAA0B,CAAC,CAAY;IAC/C,IAAI,yBAAyB,IAAI,SAAS,CASzC;IAED,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,uBAAuB;IAwB/B,OAAO,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IA+E5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -7,7 +7,7 @@ import { getSegment } from "@typespec/rest";
|
|
|
7
7
|
import { getAddedOnVersions } from "@typespec/versioning";
|
|
8
8
|
import { fail } from "assert";
|
|
9
9
|
import pkg from "lodash";
|
|
10
|
-
import { Client as CodeModelClient
|
|
10
|
+
import { Client as CodeModelClient } from "./common/client.js";
|
|
11
11
|
import { CodeModel } from "./common/code-model.js";
|
|
12
12
|
import { LongRunningMetadata } from "./common/long-running-metadata.js";
|
|
13
13
|
import { Operation as CodeModelOperation, ConvenienceApi, Request } from "./common/operation.js";
|
|
@@ -25,24 +25,20 @@ const { isEqual } = pkg;
|
|
|
25
25
|
export class CodeModelBuilder {
|
|
26
26
|
constructor(program1, context) {
|
|
27
27
|
var _a, _b;
|
|
28
|
-
this.loggingEnabled = false;
|
|
29
28
|
this.schemaCache = new ProcessingCache((type, name) => this.processSchemaImpl(type, name));
|
|
30
29
|
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
|
|
31
30
|
this.options = context.options;
|
|
32
31
|
this.program = program1;
|
|
33
32
|
this.emitterContext = context;
|
|
34
|
-
if ((_a = this.options["dev-options"]) === null || _a === void 0 ? void 0 : _a.loglevel) {
|
|
35
|
-
this.loggingEnabled = true;
|
|
36
|
-
}
|
|
37
33
|
if (this.options["skip-special-headers"]) {
|
|
38
34
|
this.options["skip-special-headers"].forEach((it) => SPECIAL_HEADER_NAMES.add(it.toLowerCase()));
|
|
39
35
|
}
|
|
40
36
|
const service = listServices(this.program)[0];
|
|
41
37
|
if (!service) {
|
|
42
|
-
this.
|
|
38
|
+
this.logWarning("TypeSpec for HTTP client should define a service.");
|
|
43
39
|
}
|
|
44
|
-
this.serviceNamespace = service.type;
|
|
45
|
-
this.namespace = getNamespaceFullName(this.serviceNamespace) || "
|
|
40
|
+
this.serviceNamespace = (_a = service === null || service === void 0 ? void 0 : service.type) !== null && _a !== void 0 ? _a : this.program.getGlobalNamespaceType();
|
|
41
|
+
this.namespace = getNamespaceFullName(this.serviceNamespace) || "Client";
|
|
46
42
|
const namespace1 = this.namespace;
|
|
47
43
|
this.typeNameOptions = {
|
|
48
44
|
// shorten type names by removing TypeSpec and service namespace
|
|
@@ -70,6 +66,9 @@ export class CodeModelBuilder {
|
|
|
70
66
|
});
|
|
71
67
|
}
|
|
72
68
|
async build() {
|
|
69
|
+
if (this.program.hasError()) {
|
|
70
|
+
return this.codeModel;
|
|
71
|
+
}
|
|
73
72
|
this.sdkContext = await createSdkContext(this.emitterContext, "@azure-tools/typespec-java", {
|
|
74
73
|
versioning: { previewStringRegex: /$/ },
|
|
75
74
|
}); // include all versions and do the filter by ourselves
|
|
@@ -87,9 +86,8 @@ export class CodeModelBuilder {
|
|
|
87
86
|
this.baseJavaNamespace = this.getBaseJavaNamespace();
|
|
88
87
|
}
|
|
89
88
|
this.codeModel.language.java.namespace = this.baseJavaNamespace;
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
// this.program.reportDiagnostics(this.sdkContext.diagnostics);
|
|
89
|
+
// potential problem https://github.com/Azure/typespec-azure/issues/1675
|
|
90
|
+
this.program.reportDiagnostics(this.sdkContext.diagnostics);
|
|
93
91
|
// auth
|
|
94
92
|
// TODO: it is not very likely, but different client could have different auth
|
|
95
93
|
const auth = getAuthentication(this.program, this.serviceNamespace);
|
|
@@ -150,11 +148,22 @@ export class CodeModelBuilder {
|
|
|
150
148
|
switch (scheme.type) {
|
|
151
149
|
case "oauth2":
|
|
152
150
|
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
151
|
+
if (this.isBranded()) {
|
|
152
|
+
const oauth2Scheme = new OAuth2SecurityScheme({
|
|
153
|
+
scopes: [],
|
|
154
|
+
});
|
|
155
|
+
scheme.flows.forEach((it) => oauth2Scheme.scopes.push(...it.scopes.map((it) => it.value)));
|
|
156
|
+
securitySchemes.push(oauth2Scheme);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// there is no TokenCredential in clientcore, hence use Bearer Authentication directly
|
|
160
|
+
this.logWarning(`OAuth2 auth scheme is generated as KeyCredential.`);
|
|
161
|
+
const keyScheme = new KeySecurityScheme({
|
|
162
|
+
name: "authorization",
|
|
163
|
+
});
|
|
164
|
+
keyScheme.prefix = "Bearer";
|
|
165
|
+
securitySchemes.push(keyScheme);
|
|
166
|
+
}
|
|
158
167
|
}
|
|
159
168
|
break;
|
|
160
169
|
case "apiKey":
|
|
@@ -339,7 +348,7 @@ export class CodeModelBuilder {
|
|
|
339
348
|
// at present, use global security definition
|
|
340
349
|
security: this.codeModel.security,
|
|
341
350
|
});
|
|
342
|
-
codeModelClient.crossLanguageDefinitionId = client.crossLanguageDefinitionId;
|
|
351
|
+
codeModelClient.language.default.crossLanguageDefinitionId = client.crossLanguageDefinitionId;
|
|
343
352
|
// versioning
|
|
344
353
|
const versions = client.apiVersions;
|
|
345
354
|
if (versions && versions.length > 0) {
|
|
@@ -376,7 +385,7 @@ export class CodeModelBuilder {
|
|
|
376
385
|
}
|
|
377
386
|
}
|
|
378
387
|
else if (initializationProperty.type.variantTypes.length > 2) {
|
|
379
|
-
this.logError("Multiple server
|
|
388
|
+
this.logError("Multiple server URL defined for one client is not supported yet.");
|
|
380
389
|
}
|
|
381
390
|
}
|
|
382
391
|
else if (initializationProperty.type.kind === "endpoint") {
|
|
@@ -393,6 +402,7 @@ export class CodeModelBuilder {
|
|
|
393
402
|
// operations without operation group
|
|
394
403
|
const serviceMethodsWithoutSubClient = this.listServiceMethodsUnderClient(client);
|
|
395
404
|
let codeModelGroup = new OperationGroup("");
|
|
405
|
+
codeModelGroup.language.default.crossLanguageDefinitionId = client.crossLanguageDefinitionId;
|
|
396
406
|
for (const serviceMethod of serviceMethodsWithoutSubClient) {
|
|
397
407
|
if (!this.needToSkipProcessingOperation(serviceMethod.__raw, clientContext)) {
|
|
398
408
|
codeModelGroup.addOperation(this.processOperation(serviceMethod, clientContext, ""));
|
|
@@ -416,6 +426,8 @@ export class CodeModelBuilder {
|
|
|
416
426
|
// operation group with no operation is skipped
|
|
417
427
|
if (serviceMethods.length > 0) {
|
|
418
428
|
codeModelGroup = new OperationGroup(subClient.name);
|
|
429
|
+
codeModelGroup.language.default.crossLanguageDefinitionId =
|
|
430
|
+
subClient.crossLanguageDefinitionId;
|
|
419
431
|
for (const serviceMethod of serviceMethods) {
|
|
420
432
|
if (!this.needToSkipProcessingOperation(serviceMethod.__raw, clientContext)) {
|
|
421
433
|
codeModelGroup.addOperation(this.processOperation(serviceMethod, clientContext, subClient.name));
|
|
@@ -558,8 +570,8 @@ export class CodeModelBuilder {
|
|
|
558
570
|
"x-ms-examples": operationExamples,
|
|
559
571
|
},
|
|
560
572
|
});
|
|
561
|
-
codeModelOperation.crossLanguageDefinitionId =
|
|
562
|
-
sdkMethod.
|
|
573
|
+
codeModelOperation.language.default.crossLanguageDefinitionId =
|
|
574
|
+
sdkMethod.crossLanguageDefinitionId;
|
|
563
575
|
codeModelOperation.internalApi = sdkMethod.access === "internal";
|
|
564
576
|
const convenienceApiName = this.getConvenienceApiName(sdkMethod);
|
|
565
577
|
let generateConvenienceApi = sdkMethod.generateConvenient;
|
|
@@ -670,24 +682,45 @@ export class CodeModelBuilder {
|
|
|
670
682
|
for (const response of responses) {
|
|
671
683
|
const bodyType = response.type;
|
|
672
684
|
if (bodyType && bodyType.kind === "model") {
|
|
673
|
-
const
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
};
|
|
680
|
-
(_b = op.responses) === null || _b === void 0 ? void 0 : _b.forEach((r) => {
|
|
685
|
+
const itemClientName = sdkMethod.response.resultPath;
|
|
686
|
+
const nextLinkClientName = sdkMethod.nextLinkPath;
|
|
687
|
+
let itemSerializedName = undefined;
|
|
688
|
+
let nextLinkSerializedName = undefined;
|
|
689
|
+
(_a = op.responses) === null || _a === void 0 ? void 0 : _a.forEach((r) => {
|
|
690
|
+
var _a;
|
|
681
691
|
if (r instanceof SchemaResponse) {
|
|
682
692
|
this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] });
|
|
693
|
+
// find serializedName for items and nextLink
|
|
694
|
+
if (r.schema instanceof ObjectSchema) {
|
|
695
|
+
(_a = r.schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
696
|
+
if (itemClientName &&
|
|
697
|
+
!itemSerializedName &&
|
|
698
|
+
p.serializedName &&
|
|
699
|
+
p.language.default.name === itemClientName) {
|
|
700
|
+
itemSerializedName = p.serializedName;
|
|
701
|
+
}
|
|
702
|
+
if (nextLinkClientName &&
|
|
703
|
+
!nextLinkSerializedName &&
|
|
704
|
+
p.serializedName &&
|
|
705
|
+
p.language.default.name === nextLinkClientName) {
|
|
706
|
+
nextLinkSerializedName = p.serializedName;
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
}
|
|
683
710
|
}
|
|
684
711
|
});
|
|
712
|
+
op.extensions = (_b = op.extensions) !== null && _b !== void 0 ? _b : {};
|
|
713
|
+
op.extensions["x-ms-pageable"] = {
|
|
714
|
+
itemName: itemSerializedName,
|
|
715
|
+
nextLinkName: nextLinkSerializedName,
|
|
716
|
+
};
|
|
685
717
|
break;
|
|
686
718
|
}
|
|
687
719
|
}
|
|
688
720
|
}
|
|
689
721
|
}
|
|
690
722
|
processLroMetadata(op, sdkMethod) {
|
|
723
|
+
var _a;
|
|
691
724
|
const trackConvenienceApi = Boolean(op.convenienceApi);
|
|
692
725
|
const lroMetadata = sdkMethod.lroMetadata;
|
|
693
726
|
if (lroMetadata && lroMetadata.pollingStep) {
|
|
@@ -732,8 +765,19 @@ export class CodeModelBuilder {
|
|
|
732
765
|
lroMetadata.finalStep &&
|
|
733
766
|
lroMetadata.finalStep.kind === "pollingSuccessProperty" &&
|
|
734
767
|
lroMetadata.finalResponse.resultPath) {
|
|
735
|
-
|
|
736
|
-
|
|
768
|
+
const finalResultPropertyClientName = lroMetadata.finalResponse.resultPath;
|
|
769
|
+
// find serializedName for lro result
|
|
770
|
+
if (finalResultPropertyClientName) {
|
|
771
|
+
(_a = lroMetadata.finalResponse.envelopeResult.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
772
|
+
var _a;
|
|
773
|
+
// TODO: "p.__raw?.name" should be "p.name", after TCGC fix https://github.com/Azure/typespec-azure/issues/2072
|
|
774
|
+
if (p.kind === "property" &&
|
|
775
|
+
p.serializedName &&
|
|
776
|
+
((_a = p.__raw) === null || _a === void 0 ? void 0 : _a.name) === finalResultPropertyClientName) {
|
|
777
|
+
finalResultPropertySerializedName = p.serializedName;
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}
|
|
737
781
|
}
|
|
738
782
|
}
|
|
739
783
|
// track usage
|
|
@@ -1497,7 +1541,7 @@ export class CodeModelBuilder {
|
|
|
1497
1541
|
},
|
|
1498
1542
|
},
|
|
1499
1543
|
});
|
|
1500
|
-
schema.crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1544
|
+
schema.language.default.crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1501
1545
|
return this.codeModel.schemas.add(schema);
|
|
1502
1546
|
}
|
|
1503
1547
|
processConstantSchema(type, name) {
|
|
@@ -1571,8 +1615,7 @@ export class CodeModelBuilder {
|
|
|
1571
1615
|
},
|
|
1572
1616
|
},
|
|
1573
1617
|
});
|
|
1574
|
-
objectSchema.crossLanguageDefinitionId =
|
|
1575
|
-
type.crossLanguageDefinitionId;
|
|
1618
|
+
objectSchema.language.default.crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1576
1619
|
this.codeModel.schemas.add(objectSchema);
|
|
1577
1620
|
// cache this now before we accidentally recurse on this type.
|
|
1578
1621
|
if (!this.schemaCache.has(type)) {
|
|
@@ -1754,7 +1797,7 @@ export class CodeModelBuilder {
|
|
|
1754
1797
|
getUnionVariantName(type, option) {
|
|
1755
1798
|
var _a, _b;
|
|
1756
1799
|
if (type === undefined) {
|
|
1757
|
-
this.
|
|
1800
|
+
this.logWarning("Union variant type is undefined.");
|
|
1758
1801
|
return "UnionVariant";
|
|
1759
1802
|
}
|
|
1760
1803
|
switch (type.kind) {
|
|
@@ -1812,7 +1855,7 @@ export class CodeModelBuilder {
|
|
|
1812
1855
|
case "UnionVariant":
|
|
1813
1856
|
return (_b = (typeof type.name === "string" ? type.name : undefined)) !== null && _b !== void 0 ? _b : "UnionVariant";
|
|
1814
1857
|
default:
|
|
1815
|
-
this.
|
|
1858
|
+
this.logWarning(`Unrecognized type for union variable: '${type.kind}'.`);
|
|
1816
1859
|
return "UnionVariant";
|
|
1817
1860
|
}
|
|
1818
1861
|
}
|
|
@@ -1943,26 +1986,40 @@ export class CodeModelBuilder {
|
|
|
1943
1986
|
getJavaNamespace(type = undefined) {
|
|
1944
1987
|
// clientNamespace from TCGC
|
|
1945
1988
|
const clientNamespace = type === null || type === void 0 ? void 0 : type.clientNamespace;
|
|
1946
|
-
if (
|
|
1947
|
-
|
|
1948
|
-
if (
|
|
1949
|
-
//
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1989
|
+
if (type) {
|
|
1990
|
+
const crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1991
|
+
if (this.isBranded()) {
|
|
1992
|
+
// special handling for namespace of model that cannot be mapped to azure-core
|
|
1993
|
+
if (crossLanguageDefinitionId === "TypeSpec.Http.File") {
|
|
1994
|
+
// TypeSpec.Http.File
|
|
1995
|
+
return this.baseJavaNamespace;
|
|
1996
|
+
}
|
|
1997
|
+
else if (crossLanguageDefinitionId === "Azure.Core.Foundations.OperationState") {
|
|
1998
|
+
// Azure.Core.OperationState
|
|
1999
|
+
return this.baseJavaNamespace;
|
|
2000
|
+
}
|
|
2001
|
+
else if (crossLanguageDefinitionId === "Azure.Core.ResourceOperationStatus" ||
|
|
2002
|
+
crossLanguageDefinitionId === "Azure.Core.Foundations.OperationStatus") {
|
|
2003
|
+
// Azure.Core.ResourceOperationStatus<>
|
|
2004
|
+
// Azure.Core.Foundations.OperationStatus<>
|
|
2005
|
+
// usually this model will not be generated, but javadoc of protocol method requires it be in SDK namespace
|
|
2006
|
+
return this.baseJavaNamespace;
|
|
2007
|
+
}
|
|
2008
|
+
else if (type.crossLanguageDefinitionId.startsWith("Azure.ResourceManager.")) {
|
|
2009
|
+
// models in Azure.ResourceManager
|
|
2010
|
+
return this.baseJavaNamespace;
|
|
2011
|
+
}
|
|
1962
2012
|
}
|
|
1963
|
-
else
|
|
1964
|
-
//
|
|
1965
|
-
|
|
2013
|
+
else {
|
|
2014
|
+
// special handling for namespace of model in TypeSpec
|
|
2015
|
+
if (crossLanguageDefinitionId === "TypeSpec.Http.File") {
|
|
2016
|
+
// TypeSpec.Http.File
|
|
2017
|
+
return this.baseJavaNamespace;
|
|
2018
|
+
}
|
|
2019
|
+
else if (crossLanguageDefinitionId.startsWith("TypeSpec.Rest.Resource.")) {
|
|
2020
|
+
// models in TypeSpec.Rest.Resource
|
|
2021
|
+
return this.baseJavaNamespace;
|
|
2022
|
+
}
|
|
1966
2023
|
}
|
|
1967
2024
|
}
|
|
1968
2025
|
if (this.legacyJavaNamespace || !clientNamespace) {
|
|
@@ -1976,9 +2033,7 @@ export class CodeModelBuilder {
|
|
|
1976
2033
|
logError(this.program, msg);
|
|
1977
2034
|
}
|
|
1978
2035
|
logWarning(msg) {
|
|
1979
|
-
|
|
1980
|
-
logWarning(this.program, msg);
|
|
1981
|
-
}
|
|
2036
|
+
logWarning(this.program, msg);
|
|
1982
2037
|
}
|
|
1983
2038
|
trace(msg) {
|
|
1984
2039
|
trace(this.program, msg);
|