@azure-tools/typespec-rust 0.14.2 → 0.16.0
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/codegen/clients.js +64 -22
- package/dist/src/codegen/clients.js.map +1 -1
- package/dist/src/codegen/codeGenerator.d.ts.map +1 -1
- package/dist/src/codegen/codeGenerator.js +14 -24
- package/dist/src/codegen/codeGenerator.js.map +1 -1
- package/dist/src/codegen/context.d.ts +16 -15
- package/dist/src/codegen/context.d.ts.map +1 -1
- package/dist/src/codegen/context.js +63 -41
- package/dist/src/codegen/context.js.map +1 -1
- package/dist/src/codegen/enums.d.ts.map +1 -1
- package/dist/src/codegen/enums.js +2 -2
- package/dist/src/codegen/enums.js.map +1 -1
- package/dist/src/codegen/headerTraits.js +3 -3
- package/dist/src/codegen/headerTraits.js.map +1 -1
- package/dist/src/codegen/helpers.d.ts +9 -0
- package/dist/src/codegen/helpers.d.ts.map +1 -1
- package/dist/src/codegen/helpers.js +24 -14
- package/dist/src/codegen/helpers.js.map +1 -1
- package/dist/src/codegen/models.d.ts +2 -0
- package/dist/src/codegen/models.d.ts.map +1 -1
- package/dist/src/codegen/models.js +37 -20
- package/dist/src/codegen/models.js.map +1 -1
- package/dist/src/codegen/use.d.ts.map +1 -1
- package/dist/src/codegen/use.js +7 -6
- package/dist/src/codegen/use.js.map +1 -1
- package/dist/src/codemodel/client.d.ts +5 -3
- package/dist/src/codemodel/client.d.ts.map +1 -1
- package/dist/src/codemodel/client.js.map +1 -1
- package/dist/src/codemodel/types.d.ts +44 -24
- package/dist/src/codemodel/types.d.ts.map +1 -1
- package/dist/src/codemodel/types.js +23 -6
- package/dist/src/codemodel/types.js.map +1 -1
- package/dist/src/tcgcadapter/adapter.d.ts +10 -3
- package/dist/src/tcgcadapter/adapter.d.ts.map +1 -1
- package/dist/src/tcgcadapter/adapter.js +137 -81
- package/dist/src/tcgcadapter/adapter.js.map +1 -1
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/codemodel/types.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAS,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/codemodel/types.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAS,eAAe,EAAE,MAAM,YAAY,CAAC;AA+MpD,gEAAgE;AAChE,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,mEAAe,CAAA;IAEf,2DAA2D;IAC3D,+DAAa,CAAA;AACf,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,2DAA2D;AAC3D,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,yDAAe,CAAA;IAEf,yCAAyC;IACzC,6CAAS,CAAA;IAET,4CAA4C;IAC5C,+CAAU,CAAA;AACZ,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB;AAuOD,MAAM,OAAO,aAAa;IACxB,YAAY,IAAY,EAAE,IAAY;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAgBD,MAAM,QAAS,SAAQ,aAAa;IAClC,YAAY,KAAY,EAAE,IAAY,EAAE,IAAY,EAAE,WAAW,IAAI,KAAa;QAChF,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClB,IAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAChB,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,IAAI,eAA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CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,EAAe,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,eAAe;IAC9C,YAAY,IAAY,EAAE,UAAsB,EAAE,IAAU;QAC1D,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,KAAY,EAAE,MAAqB;QAC7C,KAAK,CAAC,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,OAAO,IAAI;IACf;QACE,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;IACrB,CAAC;CACF;AAED,MAAM,OAAO,GAAI,SAAQ,QAAQ;IAC/B,YAAY,KAAY;QACtB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;CACF;AAED,MAAM,OAAO,MAAM;IACjB,YAAY,IAAc;QACxB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -229,11 +229,18 @@ export declare class Adapter {
|
|
|
229
229
|
*/
|
|
230
230
|
private adaptMethodSpreadParameter;
|
|
231
231
|
/**
|
|
232
|
-
* converts a Content-Type header value into a
|
|
232
|
+
* converts a Content-Type header value into a payload format
|
|
233
233
|
*
|
|
234
234
|
* @param contentType the value of the Content-Type header
|
|
235
|
-
* @returns a
|
|
235
|
+
* @returns a payload format
|
|
236
236
|
*/
|
|
237
|
-
private
|
|
237
|
+
private adaptPayloadFormat;
|
|
238
|
+
/**
|
|
239
|
+
* converts an accept header value into a response format
|
|
240
|
+
*
|
|
241
|
+
* @param accept the value of the Content-Type header
|
|
242
|
+
* @returns a response format
|
|
243
|
+
*/
|
|
244
|
+
private adaptResponseFormat;
|
|
238
245
|
}
|
|
239
246
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyB,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAIpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAE9C,oDAAoD;AACpD,MAAM,MAAM,SAAS;AACnB,mFAAmF;AACnF,eAAe;AAEf,mDAAmD;AACnD,iBAAiB;AAEjB;;;GAGG;AACH,eAAe;AAEf,sEAAsE;AACtE,gBAAgB,CAAC;AAEnB;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,QAAQ,CAAC;gBAExC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB;CAKxE;AAED,2DAA2D;AAC3D,qBAAa,OAAO;IAClB;;;;;OAKG;WACU,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAY/E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAG7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;IAG/C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoC;IAG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ACH,OAAO,CAAC,2BAA2B;IA+EnC;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAsH5B;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAqC5B;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IA2BtB;;;;;;;OAOG;IACH,OAAO,CAAC,0BAA0B;IA0BlC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAa5B"}
|
|
@@ -69,6 +69,10 @@ export class Adapter {
|
|
|
69
69
|
let done = false;
|
|
70
70
|
for (const method of client.methods) {
|
|
71
71
|
if (method.kind === 'pageable') {
|
|
72
|
+
if (method.returns.type.kind === 'pager') {
|
|
73
|
+
this.crate.addDependency(new rust.CrateDependency('async-trait')); // required for azure_core::http::Page trait
|
|
74
|
+
}
|
|
75
|
+
// TODO: why is this here?
|
|
72
76
|
this.crate.addDependency(new rust.CrateDependency('futures'));
|
|
73
77
|
done = true;
|
|
74
78
|
break;
|
|
@@ -800,23 +804,22 @@ export class Adapter {
|
|
|
800
804
|
}
|
|
801
805
|
}
|
|
802
806
|
else if (parent) {
|
|
803
|
-
// this is a sub-client. it will share the fields of the parent.
|
|
807
|
+
// this is a sub-client. it will share some/all the fields of the parent.
|
|
804
808
|
// NOTE: we must propagate parant params before a potential recursive call
|
|
805
809
|
// to create a child client that will need to inherit our client params.
|
|
806
|
-
// also note that we need to make a copy of the fields array so that
|
|
807
|
-
// adding client-unique fields don't inadvertently get shared.
|
|
808
|
-
rustClient.fields = new Array(...parent.fields);
|
|
809
|
-
// adapt any unique fields on this client
|
|
810
810
|
for (const prop of client.clientInitialization.parameters) {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
811
|
+
const name = snakeCaseName(prop.name);
|
|
812
|
+
const parentField = parent.fields.find((v) => v.name === name);
|
|
813
|
+
if (parentField) {
|
|
814
|
+
rustClient.fields.push(parentField);
|
|
814
815
|
continue;
|
|
815
816
|
}
|
|
816
|
-
|
|
817
|
-
|
|
817
|
+
else if (prop.kind !== 'method') {
|
|
818
|
+
// we don't need to care about non-method properties (e.g. credential)
|
|
819
|
+
// as these are handled in the parent client.
|
|
818
820
|
continue;
|
|
819
821
|
}
|
|
822
|
+
// unique field for this client
|
|
820
823
|
rustClient.fields.push(new rust.StructField(name, 'pubCrate', this.getType(prop.type)));
|
|
821
824
|
}
|
|
822
825
|
}
|
|
@@ -877,13 +880,17 @@ export class Adapter {
|
|
|
877
880
|
* @returns the Rust client parameter
|
|
878
881
|
*/
|
|
879
882
|
adaptClientParameter(param, constructable) {
|
|
880
|
-
var _a;
|
|
881
883
|
let paramType;
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
884
|
+
// the second clause is a workaround for https://github.com/Azure/typespec-azure/issues/2745
|
|
885
|
+
if (param.isApiVersionParam || (param.type.kind === 'enum' && (param.type.usage & tcgc.UsageFlags.ApiVersionEnum) === tcgc.UsageFlags.ApiVersionEnum)) {
|
|
886
|
+
if (param.clientDefaultValue) {
|
|
887
|
+
// this is optional so it goes into the client options type as a String
|
|
888
|
+
paramType = this.getStringType();
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
// this is a required param so its type is a &str
|
|
892
|
+
paramType = this.getRefType(this.getStringSlice());
|
|
885
893
|
}
|
|
886
|
-
paramType = this.getStringType();
|
|
887
894
|
}
|
|
888
895
|
else {
|
|
889
896
|
paramType = this.getType(param.type);
|
|
@@ -950,7 +957,7 @@ export class Adapter {
|
|
|
950
957
|
* @param rustClient the client to which the method belongs
|
|
951
958
|
*/
|
|
952
959
|
adaptMethod(method, rustClient) {
|
|
953
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
960
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
954
961
|
let srcMethodName = method.name;
|
|
955
962
|
if (method.kind === 'paging' && !srcMethodName.match(/^list/i)) {
|
|
956
963
|
const chunks = codegen.deconstruct(srcMethodName);
|
|
@@ -1032,7 +1039,7 @@ export class Adapter {
|
|
|
1032
1039
|
// if the method param's type DOES match the op param's type and the op param has multiple corresponding method params, it's a spread param
|
|
1033
1040
|
// - e.g. op param is an intersection of multiple model types, and each model type is exposed as a discrete param
|
|
1034
1041
|
if (opParam.kind === 'body' && opParam.type.kind === 'model' && (opParam.type.kind !== param.type.kind || opParam.correspondingMethodParams.length > 1)) {
|
|
1035
|
-
adaptedParam = this.adaptMethodSpreadParameter(param, this.
|
|
1042
|
+
adaptedParam = this.adaptMethodSpreadParameter(param, this.adaptPayloadFormat(opParam.defaultContentType), opParam.type);
|
|
1036
1043
|
}
|
|
1037
1044
|
else {
|
|
1038
1045
|
adaptedParam = this.adaptMethodParameter(opParam);
|
|
@@ -1042,7 +1049,10 @@ export class Adapter {
|
|
|
1042
1049
|
}
|
|
1043
1050
|
adaptedParam.docs = this.adaptDocs(param.summary, param.doc);
|
|
1044
1051
|
rustMethod.params.push(adaptedParam);
|
|
1045
|
-
|
|
1052
|
+
// we specially handle an optional content-type header to ensure it's omitted
|
|
1053
|
+
// from the options bag type. this shows up when the request body is optional.
|
|
1054
|
+
// we can't generalize this to optional literal headers though.
|
|
1055
|
+
if (adaptedParam.optional && (adaptedParam.kind !== 'header' || adaptedParam.header.toLowerCase() !== 'content-type')) {
|
|
1046
1056
|
let fieldType;
|
|
1047
1057
|
if (adaptedParam.kind === 'partialBody') {
|
|
1048
1058
|
// for partial body params, adaptedParam.type is the model type that's
|
|
@@ -1072,9 +1082,8 @@ export class Adapter {
|
|
|
1072
1082
|
rustMethod.params.push(adaptedParam);
|
|
1073
1083
|
}
|
|
1074
1084
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
var _a, _b;
|
|
1085
|
+
const getResponseFormat = () => {
|
|
1086
|
+
var _a;
|
|
1078
1087
|
// fetch the body format from the HTTP responses.
|
|
1079
1088
|
// they should all have the same type so no need to match responses to type.
|
|
1080
1089
|
let defaultContentType;
|
|
@@ -1090,9 +1099,9 @@ export class Adapter {
|
|
|
1090
1099
|
defaultContentType = httpResp.defaultContentType;
|
|
1091
1100
|
}
|
|
1092
1101
|
if (!defaultContentType) {
|
|
1093
|
-
|
|
1102
|
+
return 'NoFormat';
|
|
1094
1103
|
}
|
|
1095
|
-
return this.
|
|
1104
|
+
return this.adaptResponseFormat(defaultContentType);
|
|
1096
1105
|
};
|
|
1097
1106
|
// add any response headers
|
|
1098
1107
|
const responseHeaders = new Array();
|
|
@@ -1111,28 +1120,40 @@ export class Adapter {
|
|
|
1111
1120
|
// response headers if they need it.
|
|
1112
1121
|
continue;
|
|
1113
1122
|
}
|
|
1123
|
+
else if (header.access === 'internal') {
|
|
1124
|
+
// if a header has been marked as internal then skip it.
|
|
1125
|
+
// this happens if the tsp includes the header for documentation
|
|
1126
|
+
// purposes but the desire is to omit it from the generated code.
|
|
1127
|
+
// we skip them instead of making them pub(crate) to avoid the
|
|
1128
|
+
// case where all headers are internal, which would result in a
|
|
1129
|
+
// marker type where all its trait methods aren't public, making
|
|
1130
|
+
// it effectively useless.
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1114
1133
|
responseHeaders.push(header);
|
|
1115
1134
|
}
|
|
1116
1135
|
}
|
|
1117
|
-
|
|
1136
|
+
const responseFormat = getResponseFormat();
|
|
1118
1137
|
if (method.kind === 'paging') {
|
|
1138
|
+
if (responseFormat === 'NoFormat') {
|
|
1139
|
+
throw new AdapterError('InternalError', `paged method ${method.name} unexpected response format ${responseFormat}`, (_f = method.__raw) === null || _f === void 0 ? void 0 : _f.node);
|
|
1140
|
+
}
|
|
1119
1141
|
// for paged methods, tcgc models method.response.type as an Array<T>.
|
|
1120
1142
|
// however, we want the synthesized paged response envelope type instead.
|
|
1121
1143
|
const synthesizedType = method.operation.responses[0].type;
|
|
1122
1144
|
if (!synthesizedType) {
|
|
1123
|
-
throw new AdapterError('InternalError', `paged method ${method.name} has no synthesized response type`, (
|
|
1145
|
+
throw new AdapterError('InternalError', `paged method ${method.name} has no synthesized response type`, (_g = method.__raw) === null || _g === void 0 ? void 0 : _g.node);
|
|
1124
1146
|
}
|
|
1125
1147
|
else if (synthesizedType.kind !== 'model') {
|
|
1126
|
-
throw new AdapterError('UnsupportedTsp', `paged method ${method.name} synthesized response type has unexpected kind ${synthesizedType.kind}`, (
|
|
1148
|
+
throw new AdapterError('UnsupportedTsp', `paged method ${method.name} synthesized response type has unexpected kind ${synthesizedType.kind}`, (_h = method.__raw) === null || _h === void 0 ? void 0 : _h.node);
|
|
1127
1149
|
}
|
|
1128
|
-
const format = getBodyFormat();
|
|
1129
1150
|
const synthesizedModel = this.getModel(synthesizedType, new Array());
|
|
1130
1151
|
if (!this.crate.models.includes(synthesizedModel)) {
|
|
1131
1152
|
this.crate.models.push(synthesizedModel);
|
|
1132
1153
|
}
|
|
1133
1154
|
// for the pager response type, remove the Option<T> around the Vec<T> for the page items
|
|
1134
1155
|
if (!method.pagingMetadata.pageItemsSegments) {
|
|
1135
|
-
throw new AdapterError('InternalError', `paged method ${method.name} has no pageItemsSegments`, (
|
|
1156
|
+
throw new AdapterError('InternalError', `paged method ${method.name} has no pageItemsSegments`, (_j = method.__raw) === null || _j === void 0 ? void 0 : _j.node);
|
|
1136
1157
|
}
|
|
1137
1158
|
// unwrap all of the segments for the paged response
|
|
1138
1159
|
let unwrappedCount = 0;
|
|
@@ -1140,11 +1161,17 @@ export class Adapter {
|
|
|
1140
1161
|
for (const pageItemsSegment of method.pagingMetadata.pageItemsSegments) {
|
|
1141
1162
|
const segment = pageItemsSegment;
|
|
1142
1163
|
let serde;
|
|
1143
|
-
switch (
|
|
1144
|
-
case '
|
|
1164
|
+
switch (responseFormat) {
|
|
1165
|
+
case 'JsonFormat':
|
|
1166
|
+
if (!segment.serializationOptions.json) {
|
|
1167
|
+
throw new AdapterError('InternalError', `paged method ${method.name} is missing JSON serialization data`, (_k = method.__raw) === null || _k === void 0 ? void 0 : _k.node);
|
|
1168
|
+
}
|
|
1145
1169
|
serde = segment.serializationOptions.json.name;
|
|
1146
1170
|
break;
|
|
1147
|
-
case '
|
|
1171
|
+
case 'XmlFormat':
|
|
1172
|
+
if (!segment.serializationOptions.xml) {
|
|
1173
|
+
throw new AdapterError('InternalError', `paged method ${method.name} is missing XML serialization data`, (_l = method.__raw) === null || _l === void 0 ? void 0 : _l.node);
|
|
1174
|
+
}
|
|
1148
1175
|
serde = segment.serializationOptions.xml.name;
|
|
1149
1176
|
break;
|
|
1150
1177
|
}
|
|
@@ -1154,6 +1181,7 @@ export class Adapter {
|
|
|
1154
1181
|
// check if this has already been unwrapped (e.g. type is shared across operations)
|
|
1155
1182
|
if (field.type.kind === 'option') {
|
|
1156
1183
|
typeToUnwrap.fields[i].type = typeToUnwrap.fields[i].type.type;
|
|
1184
|
+
typeToUnwrap.fields[i].flags |= rust.ModelFieldFlags.PageItems;
|
|
1157
1185
|
}
|
|
1158
1186
|
// move to the next segment
|
|
1159
1187
|
if (field.type.kind === 'model') {
|
|
@@ -1165,29 +1193,35 @@ export class Adapter {
|
|
|
1165
1193
|
}
|
|
1166
1194
|
}
|
|
1167
1195
|
if (unwrappedCount !== method.pagingMetadata.pageItemsSegments.length) {
|
|
1168
|
-
throw new AdapterError('InternalError', `failed to unwrap paged items for method ${method.name}`, (
|
|
1196
|
+
throw new AdapterError('InternalError', `failed to unwrap paged items for method ${method.name}`, (_m = method.__raw) === null || _m === void 0 ? void 0 : _m.node);
|
|
1197
|
+
}
|
|
1198
|
+
// if the response contains more than the Vec<T> and next_link then use a PageIterator
|
|
1199
|
+
if (synthesizedModel.fields.length > 2) {
|
|
1200
|
+
rustMethod.returns = new rust.Result(this.crate, new rust.PageIterator(this.crate, new rust.Response(this.crate, synthesizedModel, responseFormat)));
|
|
1201
|
+
}
|
|
1202
|
+
else {
|
|
1203
|
+
rustMethod.returns = new rust.Result(this.crate, new rust.Pager(this.crate, new rust.Response(this.crate, synthesizedModel, responseFormat)));
|
|
1169
1204
|
}
|
|
1170
|
-
returnType = new rust.Pager(this.crate, new rust.Payload(synthesizedModel, format));
|
|
1171
1205
|
}
|
|
1172
1206
|
else if (method.response.type && !(method.response.type.kind === 'bytes' && method.response.type.encode === 'bytes')) {
|
|
1173
|
-
|
|
1207
|
+
const response = new rust.Response(this.crate, this.typeToWireType(this.getType(method.response.type)), responseFormat);
|
|
1208
|
+
rustMethod.returns = new rust.Result(this.crate, response);
|
|
1174
1209
|
}
|
|
1175
1210
|
else if (responseHeaders.length > 0) {
|
|
1176
1211
|
// for methods that don't return a modeled type but return headers,
|
|
1177
1212
|
// we need to return a marker type
|
|
1178
1213
|
const markerType = new rust.MarkerType(`${rustClient.name}${codegen.pascalCase(method.name)}Result`);
|
|
1179
1214
|
markerType.docs.summary = `Contains results for ${this.asDocLink(`${rustClient.name}::${methodName}()`, `crate::generated::clients::${rustClient.name}::${methodName}()`)}`;
|
|
1180
|
-
returnType = new rust.Response(this.crate, markerType);
|
|
1181
1215
|
this.crate.models.push(markerType);
|
|
1216
|
+
rustMethod.returns = new rust.Result(this.crate, new rust.Response(this.crate, markerType, responseFormat));
|
|
1182
1217
|
}
|
|
1183
1218
|
else if (method.response.type && method.response.type.kind === 'bytes' && method.response.type.encode === 'bytes') {
|
|
1184
1219
|
// bytes encoding indicates a streaming binary response
|
|
1185
|
-
|
|
1220
|
+
rustMethod.returns = new rust.Result(this.crate, new rust.RawResponse(this.crate));
|
|
1186
1221
|
}
|
|
1187
1222
|
else {
|
|
1188
|
-
|
|
1223
|
+
rustMethod.returns = new rust.Result(this.crate, new rust.Response(this.crate, this.getUnitType(), responseFormat));
|
|
1189
1224
|
}
|
|
1190
|
-
rustMethod.returns = new rust.Result(this.crate, returnType);
|
|
1191
1225
|
const responseHeadersMap = this.adaptResposeHeaders(responseHeaders);
|
|
1192
1226
|
rustMethod.responseHeaders = this.adaptResponseHeadersTrait(rustClient, rustMethod, Array.from(responseHeadersMap.values()));
|
|
1193
1227
|
if (method.kind === 'paging') {
|
|
@@ -1245,6 +1279,7 @@ export class Adapter {
|
|
|
1245
1279
|
const recursiveTypeName = function (type) {
|
|
1246
1280
|
switch (type.kind) {
|
|
1247
1281
|
case 'enum':
|
|
1282
|
+
case 'marker':
|
|
1248
1283
|
case 'model':
|
|
1249
1284
|
return type.name;
|
|
1250
1285
|
case 'hashmap':
|
|
@@ -1264,29 +1299,24 @@ export class Adapter {
|
|
|
1264
1299
|
// response header traits are only ever for marker types and payloads
|
|
1265
1300
|
let implFor;
|
|
1266
1301
|
switch (method.returns.type.kind) {
|
|
1302
|
+
case 'pageIterator':
|
|
1267
1303
|
case 'pager':
|
|
1268
1304
|
implFor = method.returns.type.type;
|
|
1269
1305
|
break;
|
|
1270
1306
|
case 'response':
|
|
1271
|
-
if (method.returns.type.content.kind
|
|
1307
|
+
if (method.returns.type.content.kind === 'unit') {
|
|
1308
|
+
// this is to filter out unit from ResponseTypes.
|
|
1309
|
+
// methods that return unit should have been skipped by our caller
|
|
1310
|
+
// so we should never hit this (if we do, we have a bug elsewhere).
|
|
1272
1311
|
throw new AdapterError('InternalError', `unexpected method content kind ${method.returns.type.content.kind}`);
|
|
1273
1312
|
}
|
|
1274
|
-
implFor = method.returns.type
|
|
1313
|
+
implFor = method.returns.type;
|
|
1275
1314
|
break;
|
|
1276
1315
|
default:
|
|
1277
|
-
// this is
|
|
1316
|
+
// this is RawResponse which should have been previously skipped
|
|
1278
1317
|
throw new AdapterError('InternalError', `unexpected method return kind ${method.returns.type.kind}`);
|
|
1279
1318
|
}
|
|
1280
|
-
|
|
1281
|
-
switch (implFor.kind) {
|
|
1282
|
-
case 'marker':
|
|
1283
|
-
traitName = implFor.name;
|
|
1284
|
-
break;
|
|
1285
|
-
case 'payload':
|
|
1286
|
-
traitName = recursiveTypeName(implFor.type);
|
|
1287
|
-
break;
|
|
1288
|
-
}
|
|
1289
|
-
traitName += 'Headers';
|
|
1319
|
+
const traitName = `${recursiveTypeName(implFor.content)}Headers`;
|
|
1290
1320
|
// NOTE: the complete doc text will be emitted at codegen time
|
|
1291
1321
|
const docs = this.asDocLink(`${client.name}::${method.name}()`, `crate::generated::clients::${client.name}::${method.name}()`);
|
|
1292
1322
|
const responseHeadersTrait = new rust.ResponseHeadersTrait(traitName, implFor, docs);
|
|
@@ -1432,7 +1462,7 @@ export class Adapter {
|
|
|
1432
1462
|
requestType = new rust.Bytes(this.crate);
|
|
1433
1463
|
}
|
|
1434
1464
|
else {
|
|
1435
|
-
requestType = new rust.Payload(this.typeToWireType(paramType), this.
|
|
1465
|
+
requestType = new rust.Payload(this.typeToWireType(paramType), this.adaptPayloadFormat(param.defaultContentType));
|
|
1436
1466
|
}
|
|
1437
1467
|
adaptedParam = new rust.BodyParameter(paramName, paramLoc, param.optional, new rust.RequestContent(this.crate, requestType));
|
|
1438
1468
|
break;
|
|
@@ -1585,42 +1615,36 @@ export class Adapter {
|
|
|
1585
1615
|
*/
|
|
1586
1616
|
adaptMethodSpreadParameter(param, format, opParamType) {
|
|
1587
1617
|
var _a, _b;
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
if (property.name === param.name) {
|
|
1595
|
-
serializedName = property.serializedName;
|
|
1596
|
-
break;
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
if (serializedName === undefined) {
|
|
1600
|
-
throw new AdapterError('InternalError', `didn't find body model property for spread parameter ${param.name}`, (_a = param.__raw) === null || _a === void 0 ? void 0 : _a.node);
|
|
1601
|
-
}
|
|
1602
|
-
// this is the internal model type that the spread params coalesce into
|
|
1603
|
-
const payloadType = this.getType(opParamType);
|
|
1604
|
-
if (payloadType.kind !== 'model') {
|
|
1605
|
-
throw new AdapterError('InternalError', `unexpected kind ${payloadType.kind} for spread body param`, (_b = opParamType.__raw) === null || _b === void 0 ? void 0 : _b.node);
|
|
1606
|
-
}
|
|
1607
|
-
const paramName = naming.getEscapedReservedName(snakeCaseName(param.name), 'param');
|
|
1608
|
-
const paramLoc = 'method';
|
|
1609
|
-
const adaptedParam = new rust.PartialBodyParameter(paramName, paramLoc, param.optional, serializedName, this.getType(param.type), new rust.RequestContent(this.crate, new rust.Payload(payloadType, format)));
|
|
1610
|
-
return adaptedParam;
|
|
1618
|
+
// find the corresponding field within the model so we can get its index
|
|
1619
|
+
let serializedName;
|
|
1620
|
+
for (const property of opParamType.properties) {
|
|
1621
|
+
if (property.name === param.name) {
|
|
1622
|
+
serializedName = property.serializedName;
|
|
1623
|
+
break;
|
|
1611
1624
|
}
|
|
1612
1625
|
}
|
|
1626
|
+
if (serializedName === undefined) {
|
|
1627
|
+
throw new AdapterError('InternalError', `didn't find body model property for spread parameter ${param.name}`, (_a = param.__raw) === null || _a === void 0 ? void 0 : _a.node);
|
|
1628
|
+
}
|
|
1629
|
+
// this is the internal model type that the spread params coalesce into
|
|
1630
|
+
const payloadType = this.getType(opParamType);
|
|
1631
|
+
if (payloadType.kind !== 'model') {
|
|
1632
|
+
throw new AdapterError('InternalError', `unexpected kind ${payloadType.kind} for spread body param`, (_b = opParamType.__raw) === null || _b === void 0 ? void 0 : _b.node);
|
|
1633
|
+
}
|
|
1634
|
+
const paramName = naming.getEscapedReservedName(snakeCaseName(param.name), 'param');
|
|
1635
|
+
const paramLoc = 'method';
|
|
1636
|
+
const adaptedParam = new rust.PartialBodyParameter(paramName, paramLoc, param.optional, serializedName, this.getType(param.type), new rust.RequestContent(this.crate, new rust.Payload(payloadType, format)));
|
|
1637
|
+
return adaptedParam;
|
|
1613
1638
|
}
|
|
1614
1639
|
/**
|
|
1615
|
-
* converts a Content-Type header value into a
|
|
1640
|
+
* converts a Content-Type header value into a payload format
|
|
1616
1641
|
*
|
|
1617
1642
|
* @param contentType the value of the Content-Type header
|
|
1618
|
-
* @returns a
|
|
1643
|
+
* @returns a payload format
|
|
1619
1644
|
*/
|
|
1620
|
-
|
|
1621
|
-
// we only recognize/support JSON
|
|
1645
|
+
adaptPayloadFormat(contentType) {
|
|
1646
|
+
// we only recognize/support JSON and XML content types.
|
|
1622
1647
|
if (contentType.match(/json/i)) {
|
|
1623
|
-
this.crate.addDependency(new rust.CrateDependency('serde_json'));
|
|
1624
1648
|
return 'json';
|
|
1625
1649
|
}
|
|
1626
1650
|
else if (contentType.match(/xml/i)) {
|
|
@@ -1632,6 +1656,27 @@ export class Adapter {
|
|
|
1632
1656
|
throw new AdapterError('InternalError', `unexpected contentType ${contentType}`);
|
|
1633
1657
|
}
|
|
1634
1658
|
}
|
|
1659
|
+
/**
|
|
1660
|
+
* converts an accept header value into a response format
|
|
1661
|
+
*
|
|
1662
|
+
* @param accept the value of the Content-Type header
|
|
1663
|
+
* @returns a response format
|
|
1664
|
+
*/
|
|
1665
|
+
adaptResponseFormat(accept) {
|
|
1666
|
+
// we only recognize/support JSON and XML content types.
|
|
1667
|
+
// anything else is NoFormat
|
|
1668
|
+
if (accept.match(/json/i)) {
|
|
1669
|
+
return 'JsonFormat';
|
|
1670
|
+
}
|
|
1671
|
+
else if (accept.match(/xml/i)) {
|
|
1672
|
+
// XML support is disabled by default
|
|
1673
|
+
this.crate.addDependency(new rust.CrateDependency('azure_core', ['xml']));
|
|
1674
|
+
return 'XmlFormat';
|
|
1675
|
+
}
|
|
1676
|
+
else {
|
|
1677
|
+
return 'NoFormat';
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1635
1680
|
}
|
|
1636
1681
|
/** typeguard to determine if type is a Ref<Slice> */
|
|
1637
1682
|
function isRefSlice(type) {
|
|
@@ -1651,6 +1696,17 @@ function isRefSlice(type) {
|
|
|
1651
1696
|
function fixETagName(name) {
|
|
1652
1697
|
return name.match(/^etag$/i) ? 'etag' : name;
|
|
1653
1698
|
}
|
|
1699
|
+
/**
|
|
1700
|
+
* removes any illegal characters from the provided name.
|
|
1701
|
+
* note that characters _ and - are preserved so that the
|
|
1702
|
+
* proper snake-casing can be performed.
|
|
1703
|
+
*
|
|
1704
|
+
* @param name the name to transform
|
|
1705
|
+
* @returns the transformed name or the original value
|
|
1706
|
+
*/
|
|
1707
|
+
function removeIllegalChars(name) {
|
|
1708
|
+
return name.replace(/[!@#$%^&*()+=]/g, '');
|
|
1709
|
+
}
|
|
1654
1710
|
/**
|
|
1655
1711
|
* snake-cases the provided name
|
|
1656
1712
|
*
|
|
@@ -1658,7 +1714,7 @@ function fixETagName(name) {
|
|
|
1658
1714
|
* @returns name in snake-case format
|
|
1659
1715
|
*/
|
|
1660
1716
|
function snakeCaseName(name) {
|
|
1661
|
-
return codegen.deconstruct(fixETagName(name)).join('_');
|
|
1717
|
+
return codegen.deconstruct(fixETagName(removeIllegalChars(name))).join('_');
|
|
1662
1718
|
}
|
|
1663
1719
|
/**
|
|
1664
1720
|
* recursively creates a map key from the specified type.
|