@azure-tools/typespec-java 0.27.6 → 0.27.8
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.map +1 -1
- package/dist/src/code-model-builder.js +165 -46
- package/dist/src/code-model-builder.js.map +1 -1
- package/dist/src/common/client.d.ts +33 -1
- package/dist/src/common/client.d.ts.map +1 -1
- package/dist/src/common/client.js +8 -1
- package/dist/src/common/client.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +57 -7
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/lib.d.ts +62 -2
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +24 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/type-utils.d.ts +3 -0
- package/dist/src/type-utils.d.ts.map +1 -1
- package/dist/src/type-utils.js +6 -3
- package/dist/src/type-utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generator/http-client-generator/target/emitter.jar +0 -0
- package/package.json +35 -35
- package/readme.md +1 -1
|
@@ -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,EAOZ,MAAM,EAMN,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,
|
|
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,EAOZ,MAAM,EAMN,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAwBL,OAAO,EAOR,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EAKX,OAAO,EACP,IA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,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,gBAAgB;IAwDxB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAK/B;IAED,OAAO,CAAC,cAAc,CAAC,CAAe;IACtC,IAAI,aAAa,IAAI,YAAY,CAOhC;IAED,OAAO,CAAC,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAO/B;IAED,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,IAAI,aAAa,IAAI,aAAa,CAOjC;IAED,OAAO,CAAC,UAAU,CAAC,CAAY;IAC/B,IAAI,SAAS,IAAI,SAAS,CAIzB;IAED,OAAO,CAAC,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAK/B;IAED,OAAO,CAAC,iBAAiB,CAAC,CAAe;IACzC,IAAI,gBAAgB,IAAI,YAAY,CAQnC;IAED,OAAO,CAAC,yBAAyB;IA8BjC,OAAO,CAAC,oBAAoB,CAAC,CAAY;IACzC,OAAO,CAAC,0BAA0B,CAAC,CAAY;IAC/C,OAAO,CAAC,4BAA4B,CAAC,CAAY;IACjD,OAAO,CAAC,uBAAuB,CAAC,CAAY;IAE5C,OAAO,CAAC,sBAAsB;IAiC9B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,uBAAuB;IAwB/B,OAAO,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IA4F5B,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 } from "./common/client.js";
|
|
10
|
+
import { Client as CodeModelClient, PageableContinuationToken, } 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";
|
|
@@ -20,7 +20,7 @@ import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./extern
|
|
|
20
20
|
import { LIB_NAME, createDiagnostic, reportDiagnostic } from "./lib.js";
|
|
21
21
|
import { ClientContext } from "./models.js";
|
|
22
22
|
import { CONTENT_TYPE_KEY, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, operationIsJsonMergePatch, operationIsMultipart, operationIsMultipleContentTypes, } from "./operation-utils.js";
|
|
23
|
-
import { ProcessingCache, getAccess, getDurationFormat, getNonNullSdkType, getPropertySerializedName, getUnionDescription, getUsage, modelIs, pushDistinct, } from "./type-utils.js";
|
|
23
|
+
import { BYTES_KNOWN_ENCODING, DATETIME_KNOWN_ENCODING, DURATION_KNOWN_ENCODING, ProcessingCache, getAccess, getDurationFormat, getNonNullSdkType, getPropertySerializedName, getUnionDescription, getUsage, modelIs, pushDistinct, } from "./type-utils.js";
|
|
24
24
|
import { DiagnosticError, getNamespace, isStableApiVersion, pascalCase, removeClientSuffix, stringArrayContainsIgnoreCase, trace, } from "./utils.js";
|
|
25
25
|
const { isEqual } = pkg;
|
|
26
26
|
const AZURE_CORE_FOUNDATIONS_ERROR_ID = "Azure.Core.Foundations.Error";
|
|
@@ -708,50 +708,132 @@ export class CodeModelBuilder {
|
|
|
708
708
|
this.processResponse(codeModelOperation, response.statusCodes, response, lroMetadata.longRunning, true);
|
|
709
709
|
}
|
|
710
710
|
// check for paged
|
|
711
|
-
this.processRouteForPaged(codeModelOperation, sdkMethod
|
|
711
|
+
this.processRouteForPaged(codeModelOperation, sdkMethod);
|
|
712
712
|
// check for long-running operation
|
|
713
713
|
this.processRouteForLongRunning(codeModelOperation, lroMetadata);
|
|
714
714
|
operationGroup.addOperation(codeModelOperation);
|
|
715
715
|
return codeModelOperation;
|
|
716
716
|
}
|
|
717
|
-
processRouteForPaged(op,
|
|
718
|
-
var _a, _b;
|
|
719
|
-
if (sdkMethod.kind
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
717
|
+
processRouteForPaged(op, sdkMethod) {
|
|
718
|
+
var _a, _b, _c;
|
|
719
|
+
if (sdkMethod.kind !== "paging" && sdkMethod.kind !== "lropaging") {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
// TCGC should already verified that there is 1 response, and response body is a model
|
|
723
|
+
const responses = sdkMethod.operation.responses;
|
|
724
|
+
if (responses.length === 0) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
const response = responses[0];
|
|
728
|
+
const bodyType = response.type;
|
|
729
|
+
if (!bodyType || bodyType.kind !== "model") {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
(_a = op.responses) === null || _a === void 0 ? void 0 : _a.forEach((r) => {
|
|
733
|
+
if (r instanceof SchemaResponse) {
|
|
734
|
+
this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] });
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
function getLastPropertySegment(segments) {
|
|
738
|
+
if (segments) {
|
|
739
|
+
const lastSegment = segments[segments.length - 1];
|
|
740
|
+
if (lastSegment.kind === "property") {
|
|
741
|
+
return lastSegment;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return undefined;
|
|
745
|
+
}
|
|
746
|
+
function getLastSegment(segments) {
|
|
747
|
+
if (segments) {
|
|
748
|
+
return segments[segments.length - 1];
|
|
749
|
+
}
|
|
750
|
+
return undefined;
|
|
751
|
+
}
|
|
752
|
+
function getLastSegmentSerializedName(segments) {
|
|
753
|
+
const lastSegment = getLastPropertySegment(segments);
|
|
754
|
+
return lastSegment ? getPropertySerializedName(lastSegment) : undefined;
|
|
755
|
+
}
|
|
756
|
+
// TODO: in future the property could be nested, so that the "itemSegments" or "nextLinkSegments" would contain more than 1 element
|
|
757
|
+
// item/result
|
|
758
|
+
// "itemsSegments" should exist for "paging"/"lropaging"
|
|
759
|
+
const itemSerializedName = getLastSegmentSerializedName(sdkMethod.response.resultSegments);
|
|
760
|
+
// nextLink
|
|
761
|
+
const nextLinkSerializedName = getLastSegmentSerializedName(sdkMethod.pagingMetadata.nextLinkSegments);
|
|
762
|
+
// continuationToken
|
|
763
|
+
let continuationTokenParameter;
|
|
764
|
+
let continuationTokenResponseProperty;
|
|
765
|
+
let continuationTokenResponseHeader;
|
|
766
|
+
if (!this.isBranded()) {
|
|
767
|
+
const continuationTokenParameterSegment = getLastSegment(sdkMethod.pagingMetadata.continuationTokenParameterSegments);
|
|
768
|
+
const continuationTokenResponseSegment = getLastSegment(sdkMethod.pagingMetadata.continuationTokenResponseSegments);
|
|
769
|
+
if (continuationTokenParameterSegment && op.parameters) {
|
|
770
|
+
// for now, continuationToken is either request query or header parameter
|
|
771
|
+
const parameter = getHttpOperationParameter(sdkMethod, continuationTokenParameterSegment);
|
|
772
|
+
if (parameter) {
|
|
773
|
+
for (const param of op.parameters) {
|
|
774
|
+
if (((_b = param.protocol.http) === null || _b === void 0 ? void 0 : _b.in) === parameter.kind) {
|
|
775
|
+
if (parameter.kind === "header" &&
|
|
776
|
+
param.language.default.serializedName.toLowerCase() ===
|
|
777
|
+
parameter.serializedName.toLowerCase()) {
|
|
778
|
+
continuationTokenParameter = param;
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
else if (param.language.default.serializedName === parameter.serializedName) {
|
|
782
|
+
continuationTokenParameter = param;
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
733
785
|
}
|
|
734
786
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (continuationTokenResponseSegment && op.responses) {
|
|
790
|
+
if ((continuationTokenResponseSegment === null || continuationTokenResponseSegment === void 0 ? void 0 : continuationTokenResponseSegment.kind) === "responseheader") {
|
|
791
|
+
// continuationToken is response header
|
|
792
|
+
for (const response of op.responses) {
|
|
793
|
+
if (response instanceof SchemaResponse && response.protocol.http) {
|
|
794
|
+
for (const header of response.protocol.http.headers) {
|
|
795
|
+
if (header.header.toLowerCase() ===
|
|
796
|
+
continuationTokenResponseSegment.serializedName.toLowerCase()) {
|
|
797
|
+
continuationTokenResponseHeader = header;
|
|
798
|
+
break;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
if (continuationTokenResponseHeader) {
|
|
803
|
+
break;
|
|
739
804
|
}
|
|
740
805
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
806
|
+
}
|
|
807
|
+
else if ((continuationTokenResponseSegment === null || continuationTokenResponseSegment === void 0 ? void 0 : continuationTokenResponseSegment.kind) === "property") {
|
|
808
|
+
// continuationToken is response body property
|
|
809
|
+
// TODO: the property could be nested
|
|
810
|
+
for (const response of op.responses) {
|
|
811
|
+
if (response instanceof SchemaResponse &&
|
|
812
|
+
response.schema instanceof ObjectSchema &&
|
|
813
|
+
response.schema.properties) {
|
|
814
|
+
for (const property of response.schema.properties) {
|
|
815
|
+
if (property.serializedName ===
|
|
816
|
+
getPropertySerializedName(continuationTokenResponseSegment)) {
|
|
817
|
+
continuationTokenResponseProperty = [property];
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
744
821
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
nextLinkName: nextLinkSerializedName,
|
|
750
|
-
};
|
|
751
|
-
break;
|
|
822
|
+
if (continuationTokenResponseProperty) {
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
752
826
|
}
|
|
753
827
|
}
|
|
754
828
|
}
|
|
829
|
+
op.extensions = (_c = op.extensions) !== null && _c !== void 0 ? _c : {};
|
|
830
|
+
op.extensions["x-ms-pageable"] = {
|
|
831
|
+
itemName: itemSerializedName,
|
|
832
|
+
nextLinkName: nextLinkSerializedName,
|
|
833
|
+
continuationToken: continuationTokenParameter
|
|
834
|
+
? new PageableContinuationToken(continuationTokenParameter, continuationTokenResponseProperty, continuationTokenResponseHeader)
|
|
835
|
+
: undefined,
|
|
836
|
+
};
|
|
755
837
|
}
|
|
756
838
|
processLroMetadata(op, sdkMethod) {
|
|
757
839
|
const trackConvenienceApi = Boolean(op.convenienceApi);
|
|
@@ -1540,7 +1622,7 @@ export class CodeModelBuilder {
|
|
|
1540
1622
|
return this.schemaCache.process(type, nameHint) || fail("Unable to process schema.");
|
|
1541
1623
|
}
|
|
1542
1624
|
processSchemaImpl(type, nameHint) {
|
|
1543
|
-
var _a;
|
|
1625
|
+
var _a, _b, _c;
|
|
1544
1626
|
if (isSdkBuiltInKind(type.kind)) {
|
|
1545
1627
|
return this.processBuiltInType(type, nameHint);
|
|
1546
1628
|
}
|
|
@@ -1559,27 +1641,48 @@ export class CodeModelBuilder {
|
|
|
1559
1641
|
case "array":
|
|
1560
1642
|
return this.processArraySchema(type, nameHint);
|
|
1561
1643
|
case "duration":
|
|
1562
|
-
|
|
1644
|
+
if (DURATION_KNOWN_ENCODING.includes(type.encode)) {
|
|
1645
|
+
return this.processDurationSchema(type, nameHint, getDurationFormat(type));
|
|
1646
|
+
}
|
|
1647
|
+
else {
|
|
1648
|
+
reportDiagnostic(this.program, {
|
|
1649
|
+
code: "unknown-encode",
|
|
1650
|
+
format: { encode: type.encode },
|
|
1651
|
+
target: (_a = type.__raw) !== null && _a !== void 0 ? _a : NoTarget,
|
|
1652
|
+
});
|
|
1653
|
+
return this.processBuiltInType(type.wireType, nameHint);
|
|
1654
|
+
}
|
|
1563
1655
|
case "constant":
|
|
1564
1656
|
return this.processConstantSchema(type, nameHint);
|
|
1565
1657
|
case "utcDateTime":
|
|
1566
1658
|
case "offsetDateTime":
|
|
1567
|
-
if (type.encode
|
|
1568
|
-
|
|
1659
|
+
if (DATETIME_KNOWN_ENCODING.includes(type.encode)) {
|
|
1660
|
+
if (type.encode === "unixTimestamp") {
|
|
1661
|
+
return this.processUnixTimeSchema(type, nameHint);
|
|
1662
|
+
}
|
|
1663
|
+
else {
|
|
1664
|
+
return this.processDateTimeSchema(type, nameHint, type.encode === "rfc7231");
|
|
1665
|
+
}
|
|
1569
1666
|
}
|
|
1570
1667
|
else {
|
|
1571
|
-
|
|
1668
|
+
reportDiagnostic(this.program, {
|
|
1669
|
+
code: "unknown-encode",
|
|
1670
|
+
format: { encode: type.encode },
|
|
1671
|
+
target: (_b = type.__raw) !== null && _b !== void 0 ? _b : NoTarget,
|
|
1672
|
+
});
|
|
1673
|
+
return this.processBuiltInType(type.wireType, nameHint);
|
|
1572
1674
|
}
|
|
1573
1675
|
}
|
|
1574
1676
|
}
|
|
1575
1677
|
const diagnostic = createDiagnostic({
|
|
1576
1678
|
code: "unrecognized-type",
|
|
1577
1679
|
format: { typeKind: type.kind },
|
|
1578
|
-
target: (
|
|
1680
|
+
target: (_c = type.__raw) !== null && _c !== void 0 ? _c : NoTarget,
|
|
1579
1681
|
});
|
|
1580
1682
|
throw new DiagnosticError(diagnostic);
|
|
1581
1683
|
}
|
|
1582
1684
|
processBuiltInType(type, nameHint) {
|
|
1685
|
+
var _a;
|
|
1583
1686
|
nameHint = nameHint || type.kind;
|
|
1584
1687
|
if (isSdkIntKind(type.kind)) {
|
|
1585
1688
|
const integerSize = type.kind === "safeint" || type.kind.includes("int64") ? 64 : 32;
|
|
@@ -1599,7 +1702,17 @@ export class CodeModelBuilder {
|
|
|
1599
1702
|
case "decimal128":
|
|
1600
1703
|
return this.processDecimalSchema(type, nameHint);
|
|
1601
1704
|
case "bytes":
|
|
1602
|
-
|
|
1705
|
+
if (!type.encode || BYTES_KNOWN_ENCODING.includes(type.encode)) {
|
|
1706
|
+
return this.processByteArraySchema(type, nameHint);
|
|
1707
|
+
}
|
|
1708
|
+
else {
|
|
1709
|
+
reportDiagnostic(this.program, {
|
|
1710
|
+
code: "unknown-encode",
|
|
1711
|
+
format: { encode: type.encode },
|
|
1712
|
+
target: (_a = type.__raw) !== null && _a !== void 0 ? _a : NoTarget,
|
|
1713
|
+
});
|
|
1714
|
+
return this.processStringSchema(type, nameHint);
|
|
1715
|
+
}
|
|
1603
1716
|
case "boolean":
|
|
1604
1717
|
return this.processBooleanSchema(type, nameHint);
|
|
1605
1718
|
case "plainTime":
|
|
@@ -1772,10 +1885,16 @@ export class CodeModelBuilder {
|
|
|
1772
1885
|
}));
|
|
1773
1886
|
}
|
|
1774
1887
|
processObjectSchema(type, name) {
|
|
1775
|
-
var _a, _b, _c;
|
|
1888
|
+
var _a, _b, _c, _d;
|
|
1776
1889
|
const rawModelType = type.__raw;
|
|
1890
|
+
if (!name && !type.name) {
|
|
1891
|
+
reportDiagnostic(this.program, {
|
|
1892
|
+
code: "empty-name",
|
|
1893
|
+
target: rawModelType !== null && rawModelType !== void 0 ? rawModelType : NoTarget,
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1777
1896
|
const namespace = getNamespace(rawModelType);
|
|
1778
|
-
const objectSchema = new ObjectSchema(name, (
|
|
1897
|
+
const objectSchema = new ObjectSchema((_a = type.name) !== null && _a !== void 0 ? _a : name, (_b = type.doc) !== null && _b !== void 0 ? _b : "", {
|
|
1779
1898
|
summary: type.summary,
|
|
1780
1899
|
language: {
|
|
1781
1900
|
default: {
|
|
@@ -1808,7 +1927,7 @@ export class CodeModelBuilder {
|
|
|
1808
1927
|
// therefore, copy all properties from "Error" to this class
|
|
1809
1928
|
const parentSchema = this.processSchema(type.baseModel, type.baseModel.name);
|
|
1810
1929
|
if (parentSchema instanceof ObjectSchema) {
|
|
1811
|
-
(
|
|
1930
|
+
(_c = parentSchema.properties) === null || _c === void 0 ? void 0 : _c.forEach((p) => {
|
|
1812
1931
|
var _a;
|
|
1813
1932
|
objectSchema.addProperty(p);
|
|
1814
1933
|
// improve the casing for Java
|
|
@@ -1862,7 +1981,7 @@ export class CodeModelBuilder {
|
|
|
1862
1981
|
decorators: [],
|
|
1863
1982
|
};
|
|
1864
1983
|
const parentSchema = this.processSchema(sdkDictType, "Record");
|
|
1865
|
-
objectSchema.parents = (
|
|
1984
|
+
objectSchema.parents = (_d = objectSchema.parents) !== null && _d !== void 0 ? _d : new Relations();
|
|
1866
1985
|
objectSchema.parents.immediate.push(parentSchema);
|
|
1867
1986
|
pushDistinct(objectSchema.parents.all, parentSchema);
|
|
1868
1987
|
objectSchema.discriminatorValue = type.discriminatorValue;
|
|
@@ -2143,7 +2262,7 @@ export class CodeModelBuilder {
|
|
|
2143
2262
|
// hopefully it is the root namespace of the SDK
|
|
2144
2263
|
let baseJavaNamespace = undefined;
|
|
2145
2264
|
this.sdkContext.sdkPackage.clients
|
|
2146
|
-
.map((it) => it.
|
|
2265
|
+
.map((it) => it.namespace)
|
|
2147
2266
|
.forEach((it) => {
|
|
2148
2267
|
if (baseJavaNamespace === undefined || baseJavaNamespace.length > it.length) {
|
|
2149
2268
|
baseJavaNamespace = it;
|
|
@@ -2157,7 +2276,7 @@ export class CodeModelBuilder {
|
|
|
2157
2276
|
}
|
|
2158
2277
|
getJavaNamespace(type = undefined) {
|
|
2159
2278
|
// clientNamespace from TCGC
|
|
2160
|
-
const clientNamespace = type === null || type === void 0 ? void 0 : type.
|
|
2279
|
+
const clientNamespace = type === null || type === void 0 ? void 0 : type.namespace;
|
|
2161
2280
|
if (type) {
|
|
2162
2281
|
const crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
2163
2282
|
if (this.isBranded()) {
|